Skip to content

Commit 441f531

Browse files
committed
relative shape rotation fixes
1 parent 55891b8 commit 441f531

File tree

7 files changed

+10
-15
lines changed

7 files changed

+10
-15
lines changed

echo/Shape.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class Shape implements IProxy {
148148

149149
public function set_parent(?frame:Frame2) {
150150
parent_frame = frame;
151-
if (parent_frame != null) sync();
151+
sync();
152152
}
153153
/**
154154
* Returns an AABB `Rect` representing the bounds of the `Shape`.

echo/shape/Circle.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Circle extends Shape implements IPooled {
7777
var pos = parent_frame.transformFrom(get_local_position());
7878
_x = pos.x;
7979
_y = pos.y;
80-
_rotation = parent_frame.angleDegrees.degToRad() + local_rotation;
80+
_rotation = parent_frame.angleDegrees + local_rotation;
8181
}
8282
else {
8383
_x = local_x;

echo/shape/Polygon.hx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class Polygon extends Shape implements IPooled {
156156
var pos = parent_frame.transformFrom(get_local_position());
157157
_x = pos.x;
158158
_y = pos.y;
159-
_rotation = parent_frame.angleDegrees.degToRad() + local_rotation;
159+
_rotation = parent_frame.angleDegrees + local_rotation;
160160
}
161161
else {
162162
_x = local_x;
@@ -232,11 +232,11 @@ class Polygon extends Shape implements IPooled {
232232
var pos = get_local_position();
233233
vertices.resize(0);
234234
local_frame.offset.set(pos.x, pos.y);
235-
local_frame.angleDegrees = rotation;
235+
local_frame.angleDegrees = local_rotation;
236+
if (parent_frame != null) local_frame = parent_frame.concat(local_frame);
236237
for (i in 0...count) {
237238
if (local_vertices[i] == null) continue;
238-
if (parent_frame == null) vertices[i] = local_frame.transformFrom(local_vertices[i].clone());
239-
else vertices[i] = parent_frame.concat(local_frame).transformFrom(local_vertices[i].clone());
239+
vertices[i] = local_frame.transformFrom(local_vertices[i].clone());
240240
}
241241
}
242242
/**

echo/shape/Rect.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class Rect extends Shape implements IPooled {
130130
var pos = parent_frame.transformFrom(get_local_position());
131131
_x = pos.x;
132132
_y = pos.y;
133-
_rotation = parent_frame.angleDegrees.degToRad() + local_rotation;
133+
_rotation = parent_frame.angleDegrees + local_rotation;
134134
}
135135
else {
136136
_x = local_x;

haxelib.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"description": "Simple Physics Library written in Haxe",
66
"contributors": ["austineast"],
77
"url": "https://austineast.dev/echo",
8-
"releasenote": "TileMap Collider Generation",
9-
"version": "1.2.0",
8+
"releasenote": "relative shape rotation fixes",
9+
"version": "1.2.1",
1010
"dependencies": {
1111
"hxmath": ""
1212
}

sample/state/MultiShapeState.hx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ class MultiShapeState extends BaseState {
1818
// rotational_velocity: 25,
1919
rotation: Random.range(0, 360),
2020
shapes: [
21-
// {
22-
// type: RECT,
23-
// width: 32,
24-
// radius: 16
25-
// },
2621
{
2722
type: i % 2 == 0 ? CIRCLE : RECT,
2823
offset_x: 16,

sample/state/TileMapState.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class TileMapState extends BaseState {
8282

8383
// Reset any off-screen Bodies
8484
world.for_each((member) -> {
85-
if (offscreen(member, world)) {
85+
if (member != cursor && offscreen(member, world)) {
8686
member.velocity.set(0, 0);
8787
member.set_position(Random.range(0, world.width), 0);
8888
}

0 commit comments

Comments
 (0)