fix door tree physics
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2025-04-29 11:51:49 -04:00
parent 147cad77d7
commit 4c6c30db0f
4 changed files with 30 additions and 4 deletions

View File

@ -1579,6 +1579,9 @@ Area selection utility
RoomTool item
Grid alignment actually aligns entity to grid
(04/29/2025)
Fix door tree physics

View File

@ -676,5 +676,14 @@ public class PhysicsEntityUtils {
PhysicsUtils.disableBody(collisionEngine, body);
}
}
/**
* Gets the physics template for the entity
* @param entity The entity
* @return The template
*/
public static CollidableTemplate getPhysicsTemplate(Entity entity){
return (CollidableTemplate)entity.getData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE);
}
}

View File

@ -1,14 +1,19 @@
package electrosphere.entity.state.furniture;
import org.joml.Quaterniond;
import org.joml.Vector3d;
import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.engine.Globals;
import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils;
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
import electrosphere.entity.Entity;
import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.btree.StateTransitionUtil;
import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem;
import electrosphere.entity.types.collision.CollisionObjUtils;
import electrosphere.game.data.furniture.DoorData;
import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
@ -87,7 +92,7 @@ public class ClientDoorState implements BehaviorTree {
doorData.getOpening(),
() -> {
this.setState(DoorState.OPEN);
PhysicsEntityUtils.disableBody(Globals.clientSceneWrapper.getCollisionEngine(), this.parent);
Globals.clientSceneWrapper.getCollisionEngine().destroyPhysics(this.parent);
}
),
StateTransitionUtilItem.create(
@ -100,7 +105,10 @@ public class ClientDoorState implements BehaviorTree {
doorData.getClosing(),
() -> {
this.setState(DoorState.CLOSED);
PhysicsEntityUtils.enableBody(Globals.clientSceneWrapper.getCollisionEngine(), this.parent);
Vector3d pos = EntityUtils.getPosition(this.parent);
Quaterniond rot = EntityUtils.getRotation(this.parent);
PhysicsEntityUtils.clientAttachCollidableTemplate(this.parent, PhysicsEntityUtils.getPhysicsTemplate(this.parent));
CollisionObjUtils.clientPositionCharacter(this.parent, pos, rot);
}
),
});

View File

@ -1,9 +1,13 @@
package electrosphere.entity.state.furniture;
import org.joml.Vector3d;
import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.engine.Globals;
import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.ServerEntityUtils;
import electrosphere.net.synchronization.enums.FieldIdEnums;
import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.utils.DataCellSearchUtils;
@ -67,7 +71,7 @@ public class ServerDoorState implements BehaviorTree {
() -> {
this.setState(DoorState.OPEN);
Realm parentRealm = Globals.realmManager.getEntityRealm(this.parent);
PhysicsEntityUtils.disableBody(parentRealm.getCollisionEngine(), this.parent);
parentRealm.getCollisionEngine().destroyPhysics(this.parent);
}
),
StateTransitionUtilItem.create(
@ -81,7 +85,9 @@ public class ServerDoorState implements BehaviorTree {
() -> {
this.setState(DoorState.CLOSED);
Realm parentRealm = Globals.realmManager.getEntityRealm(this.parent);
PhysicsEntityUtils.enableBody(parentRealm.getCollisionEngine(), this.parent);
Vector3d pos = EntityUtils.getPosition(this.parent);
PhysicsEntityUtils.serverAttachCollidableTemplate(parentRealm, this.parent, PhysicsEntityUtils.getPhysicsTemplate(this.parent));
ServerEntityUtils.repositionEntity(this.parent, pos);
}
),
});