GDevelop icon indicating copy to clipboard operation
GDevelop copied to clipboard

[Platformer] Make the platforms AABB updates more predictable

Open D8H opened this issue 3 years ago • 1 comments

It fixes this issue:

  • https://github.com/4ian/GDevelop/issues/2562

Context

  • At 1st frame, a platform exists from the start.
  • After the 1st frame, a platform is teleported from one location to another.

Actual

  • Platforms AABB are updated to the RBush in the doStepPreEvents method.
  • The doStepPreEvents call order does not impose Platforms AABB to be updated before that platformer objects doStepPreEvents are called.
  • As a result, the spacial search may be inconsistent with the actual location of the object (getX(), getHeight()...).

Running the new test on the master give this failure because at the 1st doStepPreEvents call on the platformer object the platform AABB is still the one from onCreate and the position set by the test will only be taken into account when the doStepPreEvents of the platform is called. So the object falls.

HeadlessChrome 90.0.4430 (Windows 10.0.0) gdjs.PlatformerObjectRuntimeBehavior (falling) must not move down when on the floor at startup FAILED
        Error: expected -29.75 to be below -29.99
            at Assertion.assert (node_modules/expect.js/index.js:96:13)
            at Assertion.lessThan.Assertion.below (node_modules/expect.js/index.js:313:10)
            at Function.below (node_modules/expect.js/index.js:499:17)
            at context.<anonymous> (GDevelop/Extensions/PlatformBehavior/tests/platformerobjectruntimebehavior.spec.js:174:35)

Expected

  • Platforms AABB are updated at the 1rst call the doStepPreEvents of a platformer object for each frame.
  • The spacial search is consistent with the location of the object.

D8H avatar May 02 '21 13:05 D8H