From abf16b91e5cca4b23a76e67ddee171f797bbf810 Mon Sep 17 00:00:00 2001 From: Logan Date: Wed, 25 Oct 2023 13:13:57 -0600 Subject: [PATCH 01/14] fix ordering of shape collision data so listener data matches order of bodies --- echo/Shape.hx | 6 +++--- echo/shape/Circle.hx | 11 +++++++---- echo/shape/Polygon.hx | 13 ++++++++----- echo/shape/Rect.hx | 15 ++++++++------- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/echo/Shape.hx b/echo/Shape.hx index 1938a1f..30b0875 100644 --- a/echo/Shape.hx +++ b/echo/Shape.hx @@ -206,11 +206,11 @@ class Shape #if cog implements cog.IComponent #end { public function collides(s:Shape):Null return null; - function collide_rect(r:Rect):Null return null; + function collide_rect(r:Rect, flip:Bool = false):Null return null; - function collide_circle(c:Circle):Null return null; + function collide_circle(c:Circle, flip:Bool = false):Null return null; - function collide_polygon(p:Polygon):Null return null; + function collide_polygon(p:Polygon, flip:Bool = false):Null return null; function toString() { var s = switch (type) { diff --git a/echo/shape/Circle.hx b/echo/shape/Circle.hx index 833e6e3..a52237e 100644 --- a/echo/shape/Circle.hx +++ b/echo/shape/Circle.hx @@ -87,13 +87,16 @@ class Circle extends Shape implements Poolable { return false; } - override inline function collides(s:Shape):Null return s.collide_circle(this); + // collision calculated as s against this. So flip result + override inline function collides(s:Shape):Null return s.collide_circle(this, true); - override inline function collide_rect(r:Rect):Null return r.rect_and_circle(this, true); + // collision calculated as r against this. So invert flip value + override inline function collide_rect(r:Rect, flip:Bool = false):Null return r.rect_and_circle(this, !flip); - override inline function collide_circle(c:Circle):Null return c.circle_and_circle(this); + // collision calculated as c against this. So invert flip value + override inline function collide_circle(c:Circle, flip:Bool = false):Null return c.circle_and_circle(this, !flip); - override inline function collide_polygon(p:Polygon):Null return this.circle_and_polygon(p, true); + override inline function collide_polygon(p:Polygon, flip:Bool = false):Null return this.circle_and_polygon(p, flip); // getters inline function get_radius():Float return local_radius * scale_x; diff --git a/echo/shape/Polygon.hx b/echo/shape/Polygon.hx index add301f..285653b 100644 --- a/echo/shape/Polygon.hx +++ b/echo/shape/Polygon.hx @@ -5,8 +5,8 @@ import echo.shape.*; import echo.util.AABB; import echo.util.Poolable; -using echo.util.SAT; using echo.math.Vector2; +using echo.util.SAT; class Polygon extends Shape implements Poolable { /** @@ -197,13 +197,16 @@ class Polygon extends Shape implements Poolable { return false; } - override inline function collides(s:Shape):Null return s.collide_polygon(this); + // collision calculated as s against this. So flip result + override inline function collides(s:Shape):Null return s.collide_polygon(this, true); - override inline function collide_rect(r:Rect):Null return r.rect_and_polygon(this, true); + // collision calculated as r against this. So invert flip value + override inline function collide_rect(r:Rect, flip:Bool = false):Null return r.rect_and_polygon(this, !flip); - override inline function collide_circle(c:Circle):Null return c.circle_and_polygon(this); + // collision calculated as c against this. So invert flip value + override inline function collide_circle(c:Circle, flip:Bool = false):Null return c.circle_and_polygon(this, !flip); - override inline function collide_polygon(p:Polygon):Null return p.polygon_and_polygon(this, true); + override inline function collide_polygon(p:Polygon, flip:Bool = false):Null return this.polygon_and_polygon(p, flip); override inline function get_top():Float { if (count == 0 || vertices[0] == null) return y; diff --git a/echo/shape/Rect.hx b/echo/shape/Rect.hx index 7d5ba23..ff16511 100644 --- a/echo/shape/Rect.hx +++ b/echo/shape/Rect.hx @@ -1,10 +1,10 @@ package echo.shape; -import echo.util.AABB; -import echo.shape.*; -import echo.util.Poolable; import echo.data.Data; import echo.math.Vector2; +import echo.shape.*; +import echo.util.AABB; +import echo.util.Poolable; using echo.util.SAT; @@ -174,13 +174,14 @@ class Rect extends Shape implements Poolable { return false; } - override inline function collides(s:Shape):Null return s.collide_rect(this); + // collision calculated as s against this. So flip result + override inline function collides(s:Shape):Null return s.collide_rect(this, true); - override inline function collide_rect(r:Rect):Null return r.rect_and_rect(this); + override inline function collide_rect(r:Rect, flip:Bool = false):Null return this.rect_and_rect(r, flip); - override inline function collide_circle(c:Circle):Null return this.rect_and_circle(c); + override inline function collide_circle(c:Circle, flip:Bool = false):Null return this.rect_and_circle(c, flip); - override inline function collide_polygon(p:Polygon):Null return this.rect_and_polygon(p); + override inline function collide_polygon(p:Polygon, flip:Bool = false):Null return this.rect_and_polygon(p, flip); override function set_parent(?body:Body) { super.set_parent(body); From 83e670bea1807f849e895f122b80b81bf9b67c49 Mon Sep 17 00:00:00 2001 From: Logan Date: Sat, 28 Oct 2023 00:46:54 -0600 Subject: [PATCH 02/14] build actions to use heaps 1.10.0 explicitly --- .github/composites/build/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/composites/build/action.yml b/.github/composites/build/action.yml index 5714a37..47ce821 100644 --- a/.github/composites/build/action.yml +++ b/.github/composites/build/action.yml @@ -16,7 +16,7 @@ runs: shell: bash run: | haxelib git dox https://github.com/HaxeFoundation/dox.git - haxelib git heaps https://github.com/HeapsIO/heaps.git + haxelib git heaps https://github.com/HeapsIO/heaps.git 1.10.0 haxelib dev echo . - name: Run Builds From e6ca792f863f34546be4a59083987babf5272cf2 Mon Sep 17 00:00:00 2001 From: itulau Date: Fri, 29 Dec 2023 08:47:56 -0300 Subject: [PATCH 03/14] fix rotational drag Correcting the order of parameters when calling `compute_velocity` for `rotational_velocity` fixed an issue with rotational drag having the inverse intended behavior. --- echo/Physics.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/echo/Physics.hx b/echo/Physics.hx index 2276cf8..9a9299f 100644 --- a/echo/Physics.hx +++ b/echo/Physics.hx @@ -52,7 +52,7 @@ class Physics { // Apply Rotational Acceleration, Drag, and Max Velocity var accel_rot = body.torque * body.inverse_mass; - body.rotational_velocity = compute_velocity(body.rotational_velocity, body.rotational_drag, accel_rot, body.max_rotational_velocity, dt); + body.rotational_velocity = compute_velocity(body.rotational_velocity, accel_rot, body.rotational_drag, body.max_rotational_velocity, dt); // Apply Rotational Velocity body.rotation += body.rotational_velocity * dt; From 4fa1f14e4c5d6a9d8b6b2737a363a87d3576d882 Mon Sep 17 00:00:00 2001 From: Austin East Date: Tue, 9 Jan 2024 16:55:20 -0800 Subject: [PATCH 04/14] 4.2.2 -> 4.2.3 --- haxelib.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haxelib.json b/haxelib.json index 9f897b5..6dead79 100644 --- a/haxelib.json +++ b/haxelib.json @@ -10,6 +10,6 @@ "austineast" ], "url": "https://austineast.dev/echo", - "releasenote": "fix webpage gen", - "version": "4.2.2" + "releasenote": "community updates & fixes :D", + "version": "4.2.3" } From cd0905d1de7556a57b26a5f6361794dad4bb8336 Mon Sep 17 00:00:00 2001 From: Austin East Date: Tue, 9 Jan 2024 23:39:20 -0800 Subject: [PATCH 05/14] add fixed step rate option --- echo/Echo.hx | 59 +++++++++++++++++++++++++++++++------------------- echo/World.hx | 2 ++ sample/Main.hx | 5 +++-- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/echo/Echo.hx b/echo/Echo.hx index 092e8a6..e3cc466 100644 --- a/echo/Echo.hx +++ b/echo/Echo.hx @@ -76,31 +76,46 @@ class Echo { /** * Steps a `World` forward. * @param world - * @param dt + * @param dt The Delta Time to step the `World` Forward + * @param rate The target rate of Step-Per-Second. If set to 0, the target rate is unlimited. */ - public static function step(world:World, dt:Float) { - // Save World State to History - if (world.history != null) world.history.add([ - for (b in world.members) { - id: b.id, - x: b.x, - y: b.y, - rotation: b.rotation, - velocity_x: b.velocity.x, - velocity_y: b.velocity.y, - acceleration_x: b.acceleration.x, - acceleration_y: b.acceleration.y, - rotational_velocity: b.rotational_velocity + public static function step(world:World, dt:Float, rate:Float = 0) { + function step_world(world:World, dt:Float) { + // Save World State to History + if (world.history != null) world.history.add([ + for (b in world.members) { + id: b.id, + x: b.x, + y: b.y, + rotation: b.rotation, + velocity_x: b.velocity.x, + velocity_y: b.velocity.y, + acceleration_x: b.acceleration.x, + acceleration_y: b.acceleration.y, + rotational_velocity: b.rotational_velocity + } + ]); + + // Step the World incrementally based on the number of iterations + var fdt = dt / world.iterations; + for (i in 0...world.iterations) { + Physics.step(world, fdt); + Collisions.query(world); + Physics.separate(world); + Collisions.notify(world); } - ]); + } - // Step the World incrementally based on the number of iterations - var fdt = dt / world.iterations; - for (i in 0...world.iterations) { - Physics.step(world, fdt); - Collisions.query(world); - Physics.separate(world); - Collisions.notify(world); + if (rate > 0) { + world.accumulatedTime += dt; + var step = 1.0 / rate; + while (world.accumulatedTime >= step) { + world.accumulatedTime -= step; + step_world(world, step); + } + } + else { + step_world(world, dt); } } /** diff --git a/echo/World.hx b/echo/World.hx index 8b010c2..b2072b6 100644 --- a/echo/World.hx +++ b/echo/World.hx @@ -52,6 +52,8 @@ class World implements Disposable { public var history:Null>>; + public var accumulatedTime:Float = 0; + var init:Bool; public function new(options:WorldOptions) { diff --git a/sample/Main.hx b/sample/Main.hx index fa8fbd6..df38fa2 100644 --- a/sample/Main.hx +++ b/sample/Main.hx @@ -1,5 +1,6 @@ package; +import hxd.Window; import hxd.Key; import echo.Echo; import echo.World; @@ -86,8 +87,8 @@ class Main extends BaseApp { var fdt = Key.isDown(Key.SHIFT) ? dt * 0.3 : dt; // Update the current Sample State fsm.step(fdt); - // Step the World Forward - if (playing) world.step(fdt); + // Step the World Forward, with a fixed step rate of 60 per second + if (playing) world.step(fdt, 60); // Update GUI text members_text.text = 'Bodies: ${world.count}'; From 4981c63d63d8337dc7ef6cf0a582f5ddffcb9f7e Mon Sep 17 00:00:00 2001 From: Austin East Date: Tue, 9 Jan 2024 23:39:42 -0800 Subject: [PATCH 06/14] leave note about heaps resize issue --- assets/index.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/index.html b/assets/index.html index 920ac76..2c33100 100644 --- a/assets/index.html +++ b/assets/index.html @@ -84,6 +84,8 @@

Echo

Simple Arcade Physics Library for Haxe

+

Known issue: the sample buttons do not work correctly! as a quick fix, resize your browser window and they'll work just fine ;)

+
Get Started API From 935d12b091ee76bcab3809dc315275da3c2bb543 Mon Sep 17 00:00:00 2001 From: Austin East Date: Tue, 9 Jan 2024 23:40:01 -0800 Subject: [PATCH 07/14] set heaps to 2.0.0 --- .github/composites/build/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/composites/build/action.yml b/.github/composites/build/action.yml index 47ce821..c578c32 100644 --- a/.github/composites/build/action.yml +++ b/.github/composites/build/action.yml @@ -6,7 +6,7 @@ runs: steps: - uses: krdlab/setup-haxe@v1 with: - haxe-version: 4.2.4 + haxe-version: 4.3.2 - uses: actions/checkout@v3 with: @@ -16,7 +16,7 @@ runs: shell: bash run: | haxelib git dox https://github.com/HaxeFoundation/dox.git - haxelib git heaps https://github.com/HeapsIO/heaps.git 1.10.0 + haxelib install heaps 2.0.0 haxelib dev echo . - name: Run Builds From 185dcebde2a578a5536d8d0654f0fb29348268a3 Mon Sep 17 00:00:00 2001 From: Austin East Date: Tue, 9 Jan 2024 23:40:14 -0800 Subject: [PATCH 08/14] Revert "Merge pull request #41 from MondayHopscotch/shape-collision-data" This reverts commit 77e0f4f947f3aa45d3f455e8751b606f1f76196d, reversing changes made to 3ca8cc942f4f3164dd71267a31783a86cee33503. --- echo/Shape.hx | 6 +++--- echo/shape/Circle.hx | 11 ++++------- echo/shape/Polygon.hx | 13 +++++-------- echo/shape/Rect.hx | 15 +++++++-------- 4 files changed, 19 insertions(+), 26 deletions(-) diff --git a/echo/Shape.hx b/echo/Shape.hx index 30b0875..1938a1f 100644 --- a/echo/Shape.hx +++ b/echo/Shape.hx @@ -206,11 +206,11 @@ class Shape #if cog implements cog.IComponent #end { public function collides(s:Shape):Null return null; - function collide_rect(r:Rect, flip:Bool = false):Null return null; + function collide_rect(r:Rect):Null return null; - function collide_circle(c:Circle, flip:Bool = false):Null return null; + function collide_circle(c:Circle):Null return null; - function collide_polygon(p:Polygon, flip:Bool = false):Null return null; + function collide_polygon(p:Polygon):Null return null; function toString() { var s = switch (type) { diff --git a/echo/shape/Circle.hx b/echo/shape/Circle.hx index a52237e..833e6e3 100644 --- a/echo/shape/Circle.hx +++ b/echo/shape/Circle.hx @@ -87,16 +87,13 @@ class Circle extends Shape implements Poolable { return false; } - // collision calculated as s against this. So flip result - override inline function collides(s:Shape):Null return s.collide_circle(this, true); + override inline function collides(s:Shape):Null return s.collide_circle(this); - // collision calculated as r against this. So invert flip value - override inline function collide_rect(r:Rect, flip:Bool = false):Null return r.rect_and_circle(this, !flip); + override inline function collide_rect(r:Rect):Null return r.rect_and_circle(this, true); - // collision calculated as c against this. So invert flip value - override inline function collide_circle(c:Circle, flip:Bool = false):Null return c.circle_and_circle(this, !flip); + override inline function collide_circle(c:Circle):Null return c.circle_and_circle(this); - override inline function collide_polygon(p:Polygon, flip:Bool = false):Null return this.circle_and_polygon(p, flip); + override inline function collide_polygon(p:Polygon):Null return this.circle_and_polygon(p, true); // getters inline function get_radius():Float return local_radius * scale_x; diff --git a/echo/shape/Polygon.hx b/echo/shape/Polygon.hx index 285653b..add301f 100644 --- a/echo/shape/Polygon.hx +++ b/echo/shape/Polygon.hx @@ -5,8 +5,8 @@ import echo.shape.*; import echo.util.AABB; import echo.util.Poolable; -using echo.math.Vector2; using echo.util.SAT; +using echo.math.Vector2; class Polygon extends Shape implements Poolable { /** @@ -197,16 +197,13 @@ class Polygon extends Shape implements Poolable { return false; } - // collision calculated as s against this. So flip result - override inline function collides(s:Shape):Null return s.collide_polygon(this, true); + override inline function collides(s:Shape):Null return s.collide_polygon(this); - // collision calculated as r against this. So invert flip value - override inline function collide_rect(r:Rect, flip:Bool = false):Null return r.rect_and_polygon(this, !flip); + override inline function collide_rect(r:Rect):Null return r.rect_and_polygon(this, true); - // collision calculated as c against this. So invert flip value - override inline function collide_circle(c:Circle, flip:Bool = false):Null return c.circle_and_polygon(this, !flip); + override inline function collide_circle(c:Circle):Null return c.circle_and_polygon(this); - override inline function collide_polygon(p:Polygon, flip:Bool = false):Null return this.polygon_and_polygon(p, flip); + override inline function collide_polygon(p:Polygon):Null return p.polygon_and_polygon(this, true); override inline function get_top():Float { if (count == 0 || vertices[0] == null) return y; diff --git a/echo/shape/Rect.hx b/echo/shape/Rect.hx index ff16511..7d5ba23 100644 --- a/echo/shape/Rect.hx +++ b/echo/shape/Rect.hx @@ -1,10 +1,10 @@ package echo.shape; -import echo.data.Data; -import echo.math.Vector2; -import echo.shape.*; import echo.util.AABB; +import echo.shape.*; import echo.util.Poolable; +import echo.data.Data; +import echo.math.Vector2; using echo.util.SAT; @@ -174,14 +174,13 @@ class Rect extends Shape implements Poolable { return false; } - // collision calculated as s against this. So flip result - override inline function collides(s:Shape):Null return s.collide_rect(this, true); + override inline function collides(s:Shape):Null return s.collide_rect(this); - override inline function collide_rect(r:Rect, flip:Bool = false):Null return this.rect_and_rect(r, flip); + override inline function collide_rect(r:Rect):Null return r.rect_and_rect(this); - override inline function collide_circle(c:Circle, flip:Bool = false):Null return this.rect_and_circle(c, flip); + override inline function collide_circle(c:Circle):Null return this.rect_and_circle(c); - override inline function collide_polygon(p:Polygon, flip:Bool = false):Null return this.rect_and_polygon(p, flip); + override inline function collide_polygon(p:Polygon):Null return this.rect_and_polygon(p); override function set_parent(?body:Body) { super.set_parent(body); From 8da415e8d4e3961158f8b859fc4fe79b0682c89d Mon Sep 17 00:00:00 2001 From: Austin East Date: Tue, 9 Jan 2024 23:50:22 -0800 Subject: [PATCH 09/14] 4.2.3 -> 4.2.4 --- haxelib.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haxelib.json b/haxelib.json index 6dead79..4a9e2fa 100644 --- a/haxelib.json +++ b/haxelib.json @@ -10,6 +10,6 @@ "austineast" ], "url": "https://austineast.dev/echo", - "releasenote": "community updates & fixes :D", - "version": "4.2.3" + "releasenote": "revert regression", + "version": "4.2.4" } From 5f78de73fefefa45529f4061971eca67b9b7d5c8 Mon Sep 17 00:00:00 2001 From: RblSb Date: Wed, 14 Feb 2024 19:42:59 +0300 Subject: [PATCH 10/14] Fix warnings --- echo/Body.hx | 7 ++++--- echo/data/Data.hx | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/echo/Body.hx b/echo/Body.hx index c1ce6ca..ebd65ce 100644 --- a/echo/Body.hx +++ b/echo/Body.hx @@ -241,12 +241,13 @@ class Body implements Disposable #if cog implements cog.IComponent #end { scale_y = options.scale_y; kinematic = options.kinematic; + final noWarnOptions:Dynamic = options; if (options.material != null) material = options.material; - else if (options.gravity_scale != null || options.elasticity != null) { + else if (noWarnOptions.gravity_scale != null || noWarnOptions.elasticity != null) { // Temp: Support deprecated values material = { - elasticity: options.elasticity, - gravity_scale: options.gravity_scale + elasticity: noWarnOptions.elasticity, + gravity_scale: noWarnOptions.gravity_scale } } else material = Material.global; diff --git a/echo/data/Data.hx b/echo/data/Data.hx index 02eae63..7700094 100644 --- a/echo/data/Data.hx +++ b/echo/data/Data.hx @@ -244,7 +244,6 @@ class QuadTreeData { public var flag = false; } -@:enum -abstract Direction(Int) from Int to Int { +enum abstract Direction(Int) from Int to Int { var TOP = 0; } From a561f4e19c8c00ff8eceeb5f8150fe6a84d8cada Mon Sep 17 00:00:00 2001 From: RblSb Date: Wed, 14 Feb 2024 20:56:33 +0300 Subject: [PATCH 11/14] fix other enums --- echo/data/Types.hx | 6 +++--- echo/util/Bezier.hx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/echo/data/Types.hx b/echo/data/Types.hx index 0f25d2c..8315c05 100644 --- a/echo/data/Types.hx +++ b/echo/data/Types.hx @@ -1,17 +1,17 @@ package echo.data; -@:enum abstract MassType(Float) from Float to Float { +enum abstract MassType(Float) from Float to Float { var AUTO = -1; var STATIC = 0; } -@:enum abstract ShapeType(Int) from Int to Int { +enum abstract ShapeType(Int) from Int to Int { var RECT; var CIRCLE; var POLYGON; } -@:enum abstract ForceType(Int) from Int to Int { +enum abstract ForceType(Int) from Int to Int { var ACCELERATION; var VELOCITY; var POSITION; diff --git a/echo/util/Bezier.hx b/echo/util/Bezier.hx index 09a7e07..6819d1d 100644 --- a/echo/util/Bezier.hx +++ b/echo/util/Bezier.hx @@ -600,7 +600,7 @@ class Bezier implements Disposable { } } -@:enum abstract BezierCurve(Int) to Int from Int { +enum abstract BezierCurve(Int) to Int from Int { var Linear = 1; var Quadratic = 2; var Cubic = 3; From 9d63872c4225084963419c409312571f2581bf92 Mon Sep 17 00:00:00 2001 From: RblSb Date: Wed, 14 Feb 2024 20:57:09 +0300 Subject: [PATCH 12/14] disable whitespace trimming on save --- .vscode/settings.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 782aca5..2d19c9c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "[haxe]": { - "editor.formatOnSave": true + "editor.formatOnSave": true, + "files.trimTrailingWhitespace": false, } -} \ No newline at end of file +} From ce9b28153f12cfb10f9320151229115397e83c54 Mon Sep 17 00:00:00 2001 From: RblSb Date: Wed, 14 Feb 2024 20:59:00 +0300 Subject: [PATCH 13/14] Better function types for vscode codegen --- echo/Body.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/echo/Body.hx b/echo/Body.hx index ebd65ce..eabfca4 100644 --- a/echo/Body.hx +++ b/echo/Body.hx @@ -198,11 +198,11 @@ class Body implements Disposable #if cog implements cog.IComponent #end { /** * If set, this method is called whenever the Body's X or Y changes. */ - public var on_move:NullFloat->Void>; + public var on_move:Null<(x:Float, y:Float) -> Void>; /** * If set, this method is called whenever the Body's rotation changes. */ - public var on_rotate:NullVoid>; + public var on_rotate:Null<(angle:Float) -> Void>; @:allow(echo.Physics.step_body) public var last_x(default, null):Float; From 21b8039819e867660059e47159c58c209302ec39 Mon Sep 17 00:00:00 2001 From: RblSb Date: Fri, 16 Feb 2024 17:18:47 +0300 Subject: [PATCH 14/14] use @:haxe.warning --- echo/Body.hx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/echo/Body.hx b/echo/Body.hx index eabfca4..e13821e 100644 --- a/echo/Body.hx +++ b/echo/Body.hx @@ -231,6 +231,7 @@ class Body implements Disposable #if cog implements cog.IComponent #end { * Sets a Body's values from a `BodyOptions` object. * @param options */ + @:haxe.warning("-WDeprecated") public function load_options(?options:BodyOptions) { options = echo.util.JSON.copy_fields(options, defaults); clear_shapes(); @@ -241,13 +242,12 @@ class Body implements Disposable #if cog implements cog.IComponent #end { scale_y = options.scale_y; kinematic = options.kinematic; - final noWarnOptions:Dynamic = options; if (options.material != null) material = options.material; - else if (noWarnOptions.gravity_scale != null || noWarnOptions.elasticity != null) { + else if (options.gravity_scale != null || options.elasticity != null) { // Temp: Support deprecated values material = { - elasticity: noWarnOptions.elasticity, - gravity_scale: noWarnOptions.gravity_scale + elasticity: options.elasticity, + gravity_scale: options.gravity_scale } } else material = Material.global;