Skip to content

Conversation

@vuaieo
Copy link

@vuaieo vuaieo commented Sep 9, 2025

… '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

… '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
@youle31 youle31 self-assigned this Sep 9, 2025
@youle31
Copy link
Collaborator

youle31 commented Sep 9, 2025

Hello, I quickly tested, it sounds ~ok overhaul but there are several things to fix.

In my human vocabulary:

  • python API is missing for the new functions in bge.logic.rst
  • when we set physics steps to 30 instead of 60 in fixed mode, the displayed framerate by the bge profiler sounds messed -> display values like 500000 fps.
  • std::sleep_for can cause stutters dépending on platforms, it's why I commented it. You can use it if you want but use it with "busy wait" -> ask gpt or the AI you use about that. I think it is the reason why when I enable fixed mode with use_fixed_fps_cap set to 60, the displayed FPS on my computer is 57/58.
  • Please enable use_fixed_fps_cap by default (both for consistency with variable mode and energy savings)
  • UI is a bit confusing about Physics steps (Physics steps per second). Same name for max physics steps and physics steps per second.

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

vuaieo and others added 12 commits September 10, 2025 08:14
…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
fixed padding to follow blender standarts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants