Fix positioning the colliders from PropDataStaticBody in TerrainPropJob and VoxelPropJob.

This commit is contained in:
Relintai 2023-10-14 08:10:06 +02:00
parent 9142600d70
commit 1ff5cdf911
2 changed files with 8 additions and 2 deletions

View File

@ -132,6 +132,9 @@ void TerrainPropJob::phase_physics_process() {
#ifdef MODULE_PROPS_ENABLED
for (int i = 0; i < chunk->prop_get_count(); ++i) {
Ref<PropData> prop = chunk->prop_get(i);
Transform prop_transform = chunk->prop_get_tarnsform(i);
Transform chunk_prop_local_tform = prop_transform;
chunk_prop_local_tform.origin = chunk->to_local(chunk_prop_local_tform.origin);
for (int j = 0; j < prop->get_prop_count(); ++j) {
Ref<PropDataStaticBody> psb = prop->get_prop(j);
@ -154,7 +157,7 @@ void TerrainPropJob::phase_physics_process() {
RID body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
Transform transform = chunk->prop_get_tarnsform(i);
Transform transform = chunk_prop_local_tform;
transform *= offset;
PhysicsServer::get_singleton()->body_add_shape(body, shape->get_rid());

View File

@ -133,6 +133,9 @@ void VoxelPropJob::phase_physics_process() {
#ifdef MODULE_PROPS_ENABLED
for (int i = 0; i < chunk->prop_get_count(); ++i) {
Ref<PropData> prop = chunk->prop_get(i);
Transform prop_transform = chunk->prop_get_tarnsform(i);
Transform chunk_prop_local_tform = prop_transform;
chunk_prop_local_tform.origin = chunk->to_local(chunk_prop_local_tform.origin);
for (int j = 0; j < prop->get_prop_count(); ++j) {
Ref<PropDataStaticBody> psb = prop->get_prop(j);
@ -155,7 +158,7 @@ void VoxelPropJob::phase_physics_process() {
RID body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
Transform transform = chunk->prop_get_tarnsform(i);
Transform transform = chunk_prop_local_tform;
transform *= offset;
PhysicsServer::get_singleton()->body_add_shape(body, shape->get_rid());