Skip to content

call RBs' _physics_rollback_tick(...) with tick rather than NetworkTi…#633

Open
jburdecki wants to merge 3 commits into
foxssake:mainfrom
jburdecki:fix-issue-632
Open

call RBs' _physics_rollback_tick(...) with tick rather than NetworkTi…#633
jburdecki wants to merge 3 commits into
foxssake:mainfrom
jburdecki:fix-issue-632

Conversation

@jburdecki

Copy link
Copy Markdown

Closes #632

Fixes

  1. The issue of rollback_space(tick) trying to apply state to freed bodies
  2. Issues caused by not having the correct tick available during rollback on NetworkRigidbodys. Now pass the tick being resimulated to RBs, rather than passing the current NetworkTime.tick

…me.tick, so as to sim/resim with historically-accurate tick info. Separately, only apply state to valid (unfreed) RBs during rollback.

@albertok albertok left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

set_body_states(rid, rid_states[rid])
# Skip bodies freed (eg: despawned) since the snapshot was taken
if valid_rids.has(rid):
set_body_states(rid, rid_states[rid])

@albertok albertok Jul 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the looping checks maybe we can clear out the object as soon as it's going to queue free.

Instead of node_removed being called from get_tree().node_removed.connect(node_removed) signal on line 16 we directly hook into the https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-signal-tree-exiting signal from the node itself.

We do this in node_added ( second last function in this class ) as the node is being registered.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of moving away from the loop. I changed it to a dictionary to improve lookup times.

Unfortunately though, to your point, tree_exiting() is called on any tree removal (including remove_child(), which could be a valid gameplay operation for moving RBs around a scene's tree/heirarchy). https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-private-method-exit-tree And alternatively checking is_queued_for_deletion() would miss direct free() calls on RBs. So from what I see we're stuck without a proper (engine/solver-driven) event-based approach on this.

@albertok albertok left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Comment thread addons/netfox.extras/physics/physics_driver.gd Outdated
Comment thread addons/netfox.extras/physics/physics_driver.gd Outdated
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.

PhysicsDriver passes wrong tick to _physics_rollback_tick(), and _rollback_space can restore state onto freed bodies

3 participants