Tested versions
This issue is present when using a physics engine module such as GodotPhysics or the new JoltPhysics module.
This is not an issue when using Jolt physics as a GDExtension.
System information
Windows 11
Issue description
The following code prevents access to the PhysicsDirectSpaceState3D outside of the main thread,
|
// this function only works on physics process, errors and returns null otherwise |
|
PhysicsDirectSpaceState3D *space_get_direct_state(RID p_space) override { |
|
ERR_FAIL_COND_V(!Thread::is_main_thread(), nullptr); |
|
return physics_server_3d->space_get_direct_state(p_space); |
|
} |
I don't believe this check is necessary as there is another check later that verifies that the space state is available,
|
PhysicsDirectSpaceState3D *JoltPhysicsServer3D::space_get_direct_state(RID p_space) { |
|
JoltSpace3D *space = space_owner.get_or_null(p_space); |
|
ERR_FAIL_NULL_V(space, nullptr); |
|
ERR_FAIL_COND_V_MSG((on_separate_thread && !doing_sync) || space->is_stepping(), nullptr, "Space state is inaccessible right now, wait for iteration or physics process notification."); |
|
|
|
return space->get_direct_state(); |
|
} |
Removing the main thread check in a custom build allows my project to work with the integrated Jolt physics module just as it does with the GDExtension version.
Steps to reproduce
Attempt a raycast from a thread or from a node running on a sub thread group.
Minimal reproduction project (MRP)
N/A
Tested versions
This issue is present when using a physics engine module such as GodotPhysics or the new JoltPhysics module.
This is not an issue when using Jolt physics as a GDExtension.
System information
Windows 11
Issue description
The following code prevents access to the PhysicsDirectSpaceState3D outside of the main thread,
redot-engine/servers/physics_server_3d_wrap_mt.h
Lines 116 to 120 in da61fa2
I don't believe this check is necessary as there is another check later that verifies that the space state is available,
redot-engine/modules/jolt_physics/jolt_physics_server_3d.cpp
Lines 233 to 239 in da61fa2
Removing the main thread check in a custom build allows my project to work with the integrated Jolt physics module just as it does with the GDExtension version.
Steps to reproduce
Attempt a raycast from a thread or from a node running on a sub thread group.
Minimal reproduction project (MRP)
N/A