voxel lookup alignment
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
austin 2025-04-26 16:52:39 -04:00
parent c8696226f0
commit e64c23f7f8
5 changed files with 18 additions and 4 deletions

View File

@ -1549,6 +1549,7 @@ Fab tool can show transparent, loaded version of fab file
Interaction target tooltip at top of window
Interaction target tooltip shows entity target, voxel targets
Fix bug where inventory items aren't destroying physics on server
Align voxel lookups for movement audio and interaction targeting

View File

@ -261,7 +261,11 @@ public class ClientInteractionEngine {
}
if(!set){
Vector3d collisionPosition = Globals.clientSceneWrapper.getCollisionEngine().rayCastPosition(centerPos, new Vector3d(eyePos).mul(-1), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
if(collisionPosition != null && collisionPosition.distance(centerPos) < CollisionEngine.DEFAULT_INTERACT_DISTANCE){
if(
collisionPosition != null &&
collisionPosition.distance(centerPos) < CollisionEngine.DEFAULT_INTERACT_DISTANCE &&
collisionPosition.x >= 0 && collisionPosition.y >= 0 && collisionPosition.z >= 0
){
//grab block at point
BlockChunkData blockChunkData = Globals.clientBlockManager.getChunkDataAtWorldPoint(Globals.clientWorldData.convertRealToWorldSpace(collisionPosition), 0);
if(blockChunkData != null){
@ -277,7 +281,7 @@ public class ClientInteractionEngine {
if(!set){
ChunkData chunkData = Globals.clientTerrainManager.getChunkDataAtWorldPoint(Globals.clientWorldData.convertRealToWorldSpace(collisionPosition), 0);
if(chunkData != null){
int voxelType = chunkData.getType(Globals.clientWorldData.convertRealToVoxelSpace(collisionPosition));
int voxelType = chunkData.getType(Globals.clientWorldData.convertRealToVoxelSpace(new Vector3d(collisionPosition).add(new Vector3d(ServerTerrainChunk.VOXEL_SIZE / 2.0f))));
if(voxelType != ServerTerrainChunk.VOXEL_TYPE_AIR){
String text = Globals.gameConfigCurrent.getVoxelData().getTypeFromId(voxelType).getName();
InteractionTargetMenu.setInteractionTargetString(text);

View File

@ -7,6 +7,7 @@ import electrosphere.client.terrain.cache.ChunkData;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils;
import electrosphere.server.physics.terrain.manager.ServerTerrainChunk;
/**
* Samples voxels
@ -24,7 +25,7 @@ public class ClientVoxelSampler {
* @return The voxel type, INVALID_POSITION if the position queried is invalid
*/
public static int getVoxelTypeBeneathEntity(Entity entity){
return ClientVoxelSampler.getVoxelType(EntityUtils.getPosition(entity));
return ClientVoxelSampler.getVoxelType(new Vector3d(EntityUtils.getPosition(entity)).add(new Vector3d(ServerTerrainChunk.VOXEL_SIZE / 2.0f)));
}
/**

View File

@ -168,6 +168,9 @@ public class ServerDataCell {
case COMMON: {
CommonEntityUtils.sendEntityToPlayer(player, entity);
} break;
case ENGINE: {
//silently ignore
} break;
}
}
}

View File

@ -12,10 +12,15 @@ import electrosphere.server.physics.terrain.models.TerrainModification;
*/
public class ServerTerrainChunk {
/**
* Size of a single voxel
*/
public static final int VOXEL_SIZE = 1;
/**
* All chunks are 16x16x16
*/
public static final int CHUNK_DIMENSION = 16;
public static final int CHUNK_DIMENSION = 16 * VOXEL_SIZE;
/**
* The size of the data passed into marching cubes/transvoxel to generate a fully connected and seamless chunk