Fix misaligned physics problem

This commit is contained in:
austin 2021-11-07 17:41:26 -05:00
parent 863fd4b665
commit c2380b0bdc
3 changed files with 7 additions and 5 deletions

View File

@ -12,8 +12,8 @@
"graphicsPerformanceEnableVSync" : false, "graphicsPerformanceEnableVSync" : false,
"graphicsPerformanceDrawShadows" : true, "graphicsPerformanceDrawShadows" : true,
"graphicsDebugDrawCollisionSpheres" : false, "graphicsDebugDrawCollisionSpheres" : true,
"graphicsDebugDrawPhysicsObjects" : false, "graphicsDebugDrawPhysicsObjects" : true,
"graphicsDebugDrawMovementVectors" : false, "graphicsDebugDrawMovementVectors" : false,
"graphicsDebugDrawNavmesh" : false "graphicsDebugDrawNavmesh" : false

View File

@ -7,6 +7,7 @@ import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.GravityTree; import electrosphere.entity.state.GravityTree;
import electrosphere.game.collision.PhysicsUtils; import electrosphere.game.collision.PhysicsUtils;
import electrosphere.game.collision.collidable.Collidable; import electrosphere.game.collision.collidable.Collidable;
import electrosphere.game.data.creature.type.CollidableTemplate;
import electrosphere.main.Globals; import electrosphere.main.Globals;
import org.joml.Quaternionf; import org.joml.Quaternionf;
import org.joml.Vector3d; import org.joml.Vector3d;
@ -80,7 +81,8 @@ public class CollidableTree {
position.set(newPosition); position.set(newPosition);
//update collision engine of this thing's position //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)); 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); // bodyTransformMatrix = new javax.vecmath.Matrix4f(PhysicsUtils.jomlToVecmathQuaternionf(rotation),PhysicsUtils.jomlToVecmathVector3f(new Vector3f((float)newPosition.x,(float)newPosition.y,(float)newPosition.z)),1.0f);

View File

@ -107,8 +107,8 @@ public class ServerConnectionHandler implements Runnable {
Globals.dataCellManager.addPlayer(newPlayerObject); Globals.dataCellManager.addPlayer(newPlayerObject);
Globals.dataCellManager.movePlayer(newPlayerObject, Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x), Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z)); Globals.dataCellManager.movePlayer(newPlayerObject, Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.x), Globals.serverWorldData.convertRealToChunkSpace(Globals.spawnPoint.z));
//spawn player sword //spawn player sword
// Entity sword = ItemUtils.spawnBasicItem("Katana"); Entity sword = ItemUtils.spawnBasicItem("Katana");
// AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031"); AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031");
//set controller id //set controller id
CreatureUtils.setControllerPlayerId(newPlayerCharacter, playerID); CreatureUtils.setControllerPlayerId(newPlayerCharacter, playerID);
if(Globals.RUN_SERVER && Main.playerId == -1){ if(Globals.RUN_SERVER && Main.playerId == -1){