From c2380b0bdcd1862e8843e51a5bddee4940cefa8a Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 7 Nov 2021 17:41:26 -0500 Subject: [PATCH] Fix misaligned physics problem --- assets/Config/settings.json | 4 ++-- .../electrosphere/entity/state/collidable/CollidableTree.java | 4 +++- .../electrosphere/net/server/ServerConnectionHandler.java | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/assets/Config/settings.json b/assets/Config/settings.json index cd9e6e31..f3e76ec1 100644 --- a/assets/Config/settings.json +++ b/assets/Config/settings.json @@ -12,8 +12,8 @@ "graphicsPerformanceEnableVSync" : false, "graphicsPerformanceDrawShadows" : true, - "graphicsDebugDrawCollisionSpheres" : false, - "graphicsDebugDrawPhysicsObjects" : false, + "graphicsDebugDrawCollisionSpheres" : true, + "graphicsDebugDrawPhysicsObjects" : true, "graphicsDebugDrawMovementVectors" : false, "graphicsDebugDrawNavmesh" : false diff --git a/src/main/java/electrosphere/entity/state/collidable/CollidableTree.java b/src/main/java/electrosphere/entity/state/collidable/CollidableTree.java index 553d226b..c2d98a38 100644 --- a/src/main/java/electrosphere/entity/state/collidable/CollidableTree.java +++ b/src/main/java/electrosphere/entity/state/collidable/CollidableTree.java @@ -7,6 +7,7 @@ import electrosphere.entity.EntityUtils; import electrosphere.entity.state.GravityTree; import electrosphere.game.collision.PhysicsUtils; import electrosphere.game.collision.collidable.Collidable; +import electrosphere.game.data.creature.type.CollidableTemplate; import electrosphere.main.Globals; import org.joml.Quaternionf; import org.joml.Vector3d; @@ -80,7 +81,8 @@ public class CollidableTree { position.set(newPosition); //update collision engine of this thing's position - bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(new Vector3f((float)position.x,(float)position.y,(float)position.z)),1.0f); + CollidableTemplate template = (CollidableTemplate)parent.getData(EntityDataStrings.PHYSICS_MODEL_TEMPLATE); + bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(new Vector3f((float)position.x + template.getOffsetX(),(float)position.y + template.getOffsetY(),(float)position.z + template.getOffsetZ())),1.0f); body.setWorldTransform(new electrosphere.linearmath.Transform(bodyTransformMatrix)); // bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(new Vector3f((float)newPosition.x,(float)newPosition.y,(float)newPosition.z)),1.0f); diff --git a/src/main/java/electrosphere/net/server/ServerConnectionHandler.java b/src/main/java/electrosphere/net/server/ServerConnectionHandler.java index 0410fa46..4aa56d50 100644 --- a/src/main/java/electrosphere/net/server/ServerConnectionHandler.java +++ b/src/main/java/electrosphere/net/server/ServerConnectionHandler.java @@ -107,8 +107,8 @@ public class ServerConnectionHandler implements Runnable { Globals.dataCellManager.addPlayer(newPlayerObject); Globals.dataCellManager.movePlayer(newPlayerObject, Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x), Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z)); //spawn player sword -// Entity sword = ItemUtils.spawnBasicItem("Katana"); -// AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031"); + Entity sword = ItemUtils.spawnBasicItem("Katana"); + AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031"); //set controller id CreatureUtils.setControllerPlayerId(newPlayerCharacter, playerID); if(Globals.RUN_SERVER && Main.playerId == -1){