Added Fixed Physics Steps feature and Renamed the 'Use Frame Rate' to…#1992
Open
vuaieo wants to merge 38 commits into
Open
Added Fixed Physics Steps feature and Renamed the 'Use Frame Rate' to…#1992vuaieo wants to merge 38 commits into
vuaieo wants to merge 38 commits into
Conversation
Collaborator
|
Hello, I quickly tested, it sounds ~ok overhaul but there are several things to fix. In my human vocabulary:
EDIT: I edited my review because timescale and external clock time were taken into account On my side, I will change UpdateSoftBody function name to UpdateSoftBodyRenderedShape |
8d759b3 to
a8e432d
Compare
… 'FPS Limit' because its the most common describtions in any game engine to understand what it do... and moved it to the Game Physics panel in Scene properties editor becuase it affects the physics fundamentaly when using Variable mode
…dded colons on the end of the label of the fixed timestep method so is same like others. fixed the stuttering when using fixed physics mode
changed files which caused the git clone problem
refactored for clarity and etc.
refactored all the code for fixed physics and variable physics modes so they would not have shared code and so would not interfere with each other...
1. fixed the logic rate , it was still tied together with frames and not physics, now is with physics steps (industry standart) 2. fixed the game would speed up if FPS > than physics steps
fixed UI and removed redundant/leftover code...
[Root cause] In camera view, rendering stayed entirely inside the game rasterizer so the interpolated transform from KX_Scene::ApplyPhysicsInterpolation() was displayed directly. In non-camera viewport mode, KX_Scene::ViewportRender() called Blender’s wm_draw_update(), which redraws the 3D View using the depsgraph’s evaluated matrices. Those matrices were still the raw physics poses because KX_GameObject::TagForTransformUpdateEvaluated() only copied the SG transform for dupli tagging and never injected the interpolated state. [Fix implemented] KX_GameObject::ApplyPhysicsInterpolation() now caches the interpolated MT_Transform, and KX_GameObject::TagForTransformUpdateEvaluated() chooses that cached transform when UseViewportRender() is active. It applies the matrix to both the original Object and its evaluated copy via BKE_object_apply_mat4(...) and tags ID_RECALC_TRANSFORM, ensuring wm_draw_update() draws the interpolated pose.
[Always clear on interpolation frames] KX_KetsjiEngine::NextFrameFixed() now runs scene->ClearPhysicsInterpolationState() every frame when interpolation is enabled, ensuring no stale render transforms even if physics didn’t advance (source/gameengine/Ketsji/KX_KetsjiEngine.cpp:800-807). [Store only when needed] StorePhysicsInterpolationState() remains conditional on physics advancement or initialization, keeping the heavier snapshot pass to a minimum while preserving correctness (KX_KetsjiEngine.cpp:808-813). [Per-scene tracking] KX_Scene now keeps m_interpolatedObjects plus RegisterInterpolatedObject() / UnregisterInterpolatedObject() so only objects that actually interpolated in the last frame need clearing (source/gameengine/Ketsji/KX_Scene.h:150-435, KX_Scene.cpp:552-574). [Automatic registration] KX_GameObject::ApplyPhysicsInterpolation() registers itself the first time it interpolates; StorePhysicsInterpolationState() and ClearPhysicsInterpolationState() unregister by clearing the cached flag, keeping the scene list accurate and preventing redundant work (source/gameengine/Ketsji/KX_GameObject.cpp:1842-1904). [Targeted clearing] KX_Scene::ClearPhysicsInterpolationState() now iterates m_interpolatedObjects and only falls back to the full object list when no tracked entries exist, then resets the vector to reclaim memory (KX_Scene.cpp:150-164). [Visibility gating] Optional skip for invisible objects avoids interpolation work when m_skipInvisibleInterpolation is true (default), while setters allow opting back in if a project needs interpolation even for culled items (KX_Scene.cpp:137-147, 585-593). [Documentation] Added inline comments explaining caching, restoration, visibility gating, and default behaviors to help new contributors follow the logic.
for fixed physics mode
refactored/addresses youles wishes
now users can use blenders rigid body constraints inside game, this allows fast and easy setting up rigid bodies with constraints because the rigid body joints object constraints are terrible hard and lack of springs for example.
this operator allows to create blender rigid body constraints between objects but without need the objects to be as rigid bodys in blender. this is because when having enables the objects as rigid body in properties>physics Ui , the performence is decreased in the game, so this operator allows to setup RB constraints without having to enable rigid body for the objects ( blender side )
puts the rigid bodies constraints in the selected collection in outliner.
… collection - now is possible to spawn collection ( instanced ) and have working blenders rigid body constraints on the object. - now is possible to remove the RB constraint binding by deleting the rigid body constraint empty obj in game. - when running the "connect Rigid Bodies" operator and having selected active collection in outliner, it will just move the rigid body constraint empty in that collection automatically.
this mode has 2 options, 1. "Disable RB constraints" and 2. "enable RB Constraints" which enables to have super performence for removing the constraints binding instead of deleting (if many objects)...
and can animate their values even
…nstraints Before this feature, if user had rigid bodies as childs(parented) and they had blender rigid body constraints and then started game and then unparented them during game, these rigid bodies would lose their RB constraint bindings... but not anymore, now the constraints bindings remain intact.
currently when user scales the rigid body or its rigid body constraint empty object, then it can cause glitches, the bigger they get... this fixes it so it behaves more like rigid body joints. = less worry for the user to remember to apply scales... 1. With the axis normalization fix: Scale of obj1 (Rigid Body): You can scale it however you want (uniform or non-uniform) before game start. The constraint axes will be normalized to length 1, preventing instability. 2. Scale of Constraint Empty: You can accidentally scale the Empty (e.g. while moving it). The fix will ignore that scale for the physics calculation. 3. Parented Empty: If the Empty is parented to a scaled object (inheriting scale), the fix will strip out that inherited scale from the axes. The Result: The physics constraint will be stable, its axes will point in the correct direction, and limits/springs/motors will behave predictably—regardless of how messy the scaling is in the Blender scene. The only remaining limitation would be runtime (in-game) scaling, which neither system handles automatically. But for scene setup, the fix solves all your headache scenarios.⚠️ ⚠️ ⚠️ to remember: "in future need build operator/possibility that would recompute constraints, for example when spawning things in different sizes that has rigid body constraints..."⚠️ ⚠️ ⚠️
1. Added auto-parenting for rigid body constraint empties to the first rigid body during scene conversion (BL_DataConversion.cpp) so the visual constraint follows its target immediately at game start. 2. Added the same auto-parenting during runtime replication (KX_GameObject::ReplicateRigidBodyConstraints) so constraints spawned via “Add Object”/instanced collections also follow their target.
Constraint empties created by the operator now force game physics type to “No Collision.” Added a “Place on 3D Cursor” toggle that, when enabled, places the constraint at the cursor and disables the Location and Connection Pattern controls. Operator can run without an active object; it promotes the first eligible selected object to active. Added “Custom Distance” connection pattern with a “Connect Distance” float; it disables the cursor option and connects pairs within the given range. Objects with game physics type “No Collision” are skipped entirely for constraint creation, and the operator warns if none are eligible.
now when using the custom distance option, then it will visualize the connection distance with circles.
it triggers if the rigid body constraint breaks
dont make sense to have it since all logic bricks sensors are self referencing and can use messege...
Fixed physics timestep now uses the user’s maxphystep even when fixed mode is enabled after creation, preventing physics slowdown when lowering Render FPS
added a button to duplicate logic brick on sensor,controller, actuator added seperator to increase the seperation visibility of each logic brick vertically. added a button on logic brick header window to copy logic brick to selected added a button to clear/delete all logic bricks from selected objects.
…id body, force fields now work with jolt physics, FPS fix agains overshooting when recovering
- Add authored vehicle physics with separate chassis and wheel objects, including motorcycle support. - Add vehicle data saving, copying, UI/RNA integration, and blend-file migration for old setups. - Add Jolt vehicle runtime support with per-wheel setup, traction/brake/steering/handbrake control, and drivetrain tuning. - Add vehicle motion actuator support for throttle, brake, steering, and handbrake inputs. - Add proportional joystick input with deadzone/strength settings, and use it to scale linked actuators. - Update Jolt physics defaults and behavior for sleep thresholds and native velocity limits. - Update vehicle-related docs/templates and fix logic editor link cutting. - Mark the bge_bricknodes submodule as locally modified.
Add Jolt soft-body plasticity UI, RNA/DNA storage, runtime rest-length deformation, and repair. Add contact-vertex collection for Jolt soft-body plasticity during simulation. Add Follow Pin Transform for Jolt pinned soft bodies to move deformed bodies with their pin object. Add Jolt soft-body collision group/mask UI and hide unsupported collision bounds controls. Bump UPBGE file subversion to 13 and version default values for new plasticity fields. Update soft-body defaults to higher stiffness, higher friction, smaller margin, and zero object damping. Use DNA constructor defaults for BulletSoftBody instead of duplicating defaults in bsbNew. Add render-only subdivision support for Bullet and Jolt soft-body runtime deformation. Add owned runtime mesh handling so generated meshes are freed safely by RAS_MeshObject. Add legacy curve collision mesh conversion for collidable curve objects. Fix curve-path parent inverse conversion so child transforms are preserved in-game. Add Jolt vehicle chassis center of mass offset UI/RNA/DNA and apply it at runtime. Preserve stored vehicle flags when reading blend files instead of forcing vehicle state from allocated settings. Preserve Jolt compound parent center of mass and mass properties when adding compound children. Improve Jolt ray tests and floating-height spring rays with filtered closest-hit collection. Add applied impulse reporting for Jolt collision callbacks and constraints. Fix Jolt environment merge to transfer soft bodies, characters, controllers, pins, listeners, and active body state correctly. Clean up Jolt controller removal from callback maps, Blender-object maps, character maps, and soft-body pin links. Harden soft-body pin vertex-group lookup for generated and evaluated meshes. Remove only Jolt-created soft-body deform modifiers during cleanup. Preserve soft-body plasticity and pin-follow state when cloning replicas. Avoid saving Jolt runtime default collision bounds back into Blender authoring data.
…zation Jolt now uses a single scene-wide correction strength instead of exposing misleading ERP/ERP2 behavior SetERPNonContact maps to Jolt Baumgarte, SetERPContact is kept as a compatibility no-op Added Jolt-specific UI label and one Correction Strength slider Removed deprecated depsgraph transform optimization path and preserved DNA padding for struct stability
Game defaults: Jolt as default physics engine; fixed physics timestep and render FPS cap enabled by default; versioning sets interpolation off for Jolt and on for Bullet in old files; startup sets gravity_factor = 1.0 where applicable. DNA: Default engine id → Jolt; object linear damping default 0.04; global physics interpolation default off. RNA: Engine-aware defaults for damping and fixed-timestep/interpolation/FPS-cap options; damping UI range expanded to 0–5. Bullet: Safer shutdown (tear down vehicles, constraints, bodies); aligned allocation for culling pair cache; safer constraint removal; remap legacy ambiguous damping values to Bullet linear/angular defaults. Jolt: Remap old Bullet-style damping defaults (0.04 / 0.1) to Jolt defaults (0.05 / 0.05). Draw: Add #include <cstdint> in GPU modifier headers for portable integer types.
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.
… 'FPS Limit' because its the most common describtions in any game engine to understand what it do... and moved it to the Game Physics panel in Scene properties editor becuase it affects the physics fundamentaly when using Variable mode