fix server terrain physics positioning

This commit is contained in:
austin 2025-01-24 14:41:10 -05:00
parent 65e3c0703b
commit 2de1468ad2
2 changed files with 16 additions and 0 deletions

View File

@ -5,11 +5,13 @@ import java.util.concurrent.Executors;
import org.joml.Quaterniond;
import org.joml.Vector3d;
import org.ode4j.ode.DBody;
import electrosphere.client.block.BlockChunkData;
import electrosphere.client.block.cells.BlockDrawCell;
import electrosphere.client.block.cells.BlockTextureAtlas;
import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.collision.PhysicsUtils;
import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.queue.QueuedModel;
import electrosphere.entity.ClientEntityUtils;
@ -21,6 +23,7 @@ import electrosphere.entity.types.collision.CollisionObjUtils;
import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.meshgen.BlockMeshgen;
import electrosphere.renderer.meshgen.BlockMeshgen.BlockMeshData;
import electrosphere.server.datacell.Realm;
/**
* Generates block chunk entities
@ -110,6 +113,11 @@ public class BlockChunkEntity {
public static void serverCreateBlockChunkEntity(Entity entity, BlockMeshData blockChunkData){
if(blockChunkData.getVertices().length > 0){
PhysicsEntityUtils.serverAttachTriGeomRigidBody(entity, blockChunkData);
Realm realm = Globals.realmManager.getEntityRealm(entity);
DBody terrainBody = PhysicsEntityUtils.getDBody(entity);
Vector3d entityPos = EntityUtils.getPosition(entity);
Quaterniond entityRot = EntityUtils.getRotation(entity);
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), entityPos, entityRot, terrainBody);
entity.putData(EntityDataStrings.TERRAIN_IS_TERRAIN, true);
}
}

View File

@ -6,6 +6,7 @@ import java.util.concurrent.Executors;
import org.joml.Quaterniond;
import org.joml.Vector3d;
import org.joml.Vector3i;
import org.ode4j.ode.DBody;
import electrosphere.client.block.BlockChunkData;
import electrosphere.client.terrain.cells.ClientDrawCellManager;
@ -13,6 +14,7 @@ import electrosphere.client.terrain.cells.DrawCell;
import electrosphere.client.terrain.cells.VoxelTextureAtlas;
import electrosphere.client.terrain.manager.ClientTerrainManager;
import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.collision.PhysicsUtils;
import electrosphere.engine.Globals;
import electrosphere.entity.ClientEntityUtils;
import electrosphere.entity.Entity;
@ -23,6 +25,7 @@ import electrosphere.entity.types.collision.CollisionObjUtils;
import electrosphere.logger.LoggerInterface;
import electrosphere.renderer.meshgen.TransvoxelModelGeneration;
import electrosphere.renderer.meshgen.TransvoxelModelGeneration.TransvoxelChunkData;
import electrosphere.server.datacell.Realm;
/**
* Utilities for creating terrain chunk entities
@ -115,6 +118,11 @@ public class TerrainChunk {
if(data.vertices.length > 0){
PhysicsEntityUtils.serverAttachTriGeomRigidBody(entity, data);
Realm realm = Globals.realmManager.getEntityRealm(entity);
DBody terrainBody = PhysicsEntityUtils.getDBody(entity);
Vector3d entityPos = EntityUtils.getPosition(entity);
Quaterniond entityRot = EntityUtils.getRotation(entity);
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), entityPos, entityRot, terrainBody);
entity.putData(EntityDataStrings.TERRAIN_IS_TERRAIN, true);
// ServerEntityUtils.initiallyPositionEntity(realm, rVal, position);
// physicsObject = PhysicsUtils.attachTerrainRigidBody(physicsEntity,heightmap,true);