Adding a fixedUpdate for full control over physics.#7754
Open
AlexAPPi wants to merge 14 commits intoplaycanvas:mainfrom
Open
Adding a fixedUpdate for full control over physics.#7754AlexAPPi wants to merge 14 commits intoplaycanvas:mainfrom
AlexAPPi wants to merge 14 commits intoplaycanvas:mainfrom
Conversation
Collaborator
|
This PR introduces some new APIs and changes some existing internals.
// pc.XrManager
xr.meshDetection // XrMeshDetection interface that provides an access to XrMeshe's
xr.start(camera, pc.XRTYPE_AR, pc.XRSPACE_LOCALFLOOR, {
meshDetection: true // new option to request mesh detection features
});
The naming conventions and style for the code, please refer to contributors doc, more specifically the event names, they need to follow a camelCase naming convention, as the rest of the codebase. |
Contributor
Author
|
There are no breaking changes in this PR, as the main modifications relate to physics, to activate the new features, you need to explicitly set usePostFixedUpdateForPhysicsSim to true. Essentially, this PR adds a fixed update event, the step size of which can be adjusted in real time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds two new events — fixedUpdate and postFixedUpdate — to the engine, allowing for more flexible update management. It also introduces the ability to dynamically change the fixed timestep via app.fixedTimeStep (in seconds), providing greater control over update frequency.
A fixedUpdate method has also been added for scripts, which will be called on the fixedUpdate event with a fixed timestep of app.fixedTimeStep (in seconds), regardless of whether the usePostFixedUpdateForPhysicsSim flag is set to false.
Additionally, a new parameter usePostFixedUpdateForPhysicsSim has been added, which controls the physics simulation mode. If set to false, physics will continue to run via the standard Ammo stepSimulation call, with no changes for existing projects. If set to true, the simulation will be executed strictly after fixedUpdate with the fixedTimeStep, enabling more precise and predictable physics behavior without inaccuracies.
This will also mark the beginning of the integration of the Jolt Physics engine into the playcanvas ecosystem. PR data is coming soon.
Cycle application:
PhysicsExampleScript.mjs: