call RBs' _physics_rollback_tick(...) with tick rather than NetworkTi…#633
call RBs' _physics_rollback_tick(...) with tick rather than NetworkTi…#633jburdecki wants to merge 3 commits into
Conversation
…me.tick, so as to sim/resim with historically-accurate tick info. Separately, only apply state to valid (unfreed) RBs during rollback.
| 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]) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Closes #632
Fixes
rollback_space(tick)trying to apply state to freed bodiestickavailable during rollback onNetworkRigidbodys. Now pass thetickbeing resimulated to RBs, rather than passing the currentNetworkTime.tick