Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind PhysicsServer*D::body_set_state_sync_callback #94653

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

mihe
Copy link
Contributor

@mihe mihe commented Jul 23, 2024

Currently if you want to implement your own RigidBody*D-like physics nodes from the script side of things, whether that's GDScript, C#, C++, Rust or any other scripting language, you're forced to hack the state synchronization (i.e. pulling the latest state from the physics server) by using the callback passed to body_set_force_integration_callback, which can sort of serve the same purpose as the callback passed to body_set_state_sync_callback.

This is a hack though, and body_set_state_sync_callback should rightfully be exposed/bound, so this PR does exactly that.

@mihe mihe requested review from a team as code owners July 23, 2024 11:18
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Looks good.

You can also update the docs for the GDExtension equivalent:

diff --git a/doc/classes/PhysicsServer2DExtension.xml b/doc/classes/PhysicsServer2DExtension.xml
index 41826ea7c2..07c65915c6 100644
--- a/doc/classes/PhysicsServer2DExtension.xml
+++ b/doc/classes/PhysicsServer2DExtension.xml
@@ -713,7 +713,7 @@
 			<param index="1" name="callable" type="Callable" />
 			<description>
 				Assigns the [param body] to call the given [param callable] during the synchronization phase of the loop, before [method _step] is called. See also [method _sync].
-				Overridable version of [PhysicsServer2D]'s internal [code]body_set_state_sync_callback[/code] method.
+				Overridable version of [method PhysicsServer2D.body_set_state_sync_callback].
 			</description>
 		</method>
 		<method name="_body_test_motion" qualifiers="virtual const">

(there's no docs for PhysicsServer3DExtension yet)

@mihe
Copy link
Contributor Author

mihe commented Jul 23, 2024

@akien-mga Done.

@akien-mga akien-mga merged commit 29e1bde into godotengine:master Jul 23, 2024
18 checks passed
@akien-mga
Copy link
Member

Thanks!

@mihe mihe deleted the bind-physics-state-sync branch July 23, 2024 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants