grid-align work
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-28 13:23:21 -04:00
parent f1a7f10f50
commit 22e6f80207
6 changed files with 47 additions and 8 deletions

View File

@ -85,6 +85,11 @@
}
}
},
"gridAlignedData" : {
"width" : 10,
"height" : 10,
"length" : 10
},
"graphicsTemplate": {
"model": {
"path" : "Models/objects/furniture/workbench1.glb"

View File

@ -1577,6 +1577,7 @@ Filter procedural worlds out of level select menu
(04/28/2025)
Area selection utility
RoomTool item
Grid alignment actually aligns entity to grid

View File

@ -30,4 +30,9 @@ public class EntityTags {
public static final String DRAW_VOLUMETIC_SOLIDS_PASS = "drawVolumetricSolidsPass"; //draw in the non-volumetic phase of the volumetric pass
public static final String DRAW_FOLIAGE_PASS = "drawFoliagePass"; //draw in the foliage pass
/**
* Entities that occupy block positions
*/
public static final String BLOCK_OCCUPANT = "blockOccupant";
}

View File

@ -417,6 +417,10 @@ public class CommonEntityUtils {
if(rawType.getBoneGroups() != null){
creatureActor.setBoneGroups(rawType.getBoneGroups());
}
//grid alignment
if(rawType.getGridAlignedData() != null){
Globals.clientScene.registerEntityToTag(entity, EntityTags.BLOCK_OCCUPANT);
}
//add health system
if(rawType.getHealthSystem() != null){
ClientLifeTree.attachTree(entity,rawType.getHealthSystem());
@ -721,6 +725,13 @@ public class CommonEntityUtils {
creatureActor.setBoneGroups(rawType.getBoneGroups());
}
//grid alignment
if(rawType.getGridAlignedData() != null){
position.set(realm.getServerWorldData().clampRealToBlock(position));
Globals.clientScene.registerEntityToTag(entity, EntityTags.BLOCK_OCCUPANT);
//TODO: must register with all nearby scenes as well because it could possibly occupy other chunks
}
///
///
/// AI (This SHOULD only be applied on the server with the way AI architected currently)

View File

@ -8,23 +8,23 @@ public class GridAlignedData {
/**
* The width in blocks to occupy on the block grid
*/
int width;
Integer width;
/**
* The length in blocks to occupy on the block grid
*/
int length;
Integer length;
/**
* The height in blocks to occupy on the block grid
*/
int height;
Integer height;
/**
* Gets the height in blocks to occupy on the block grid
* @return The height in blocks to occupy on the block grid
*/
public int getWidth() {
public Integer getWidth() {
return width;
}
@ -32,7 +32,7 @@ public class GridAlignedData {
* Gets the length in blocks to occupy on the block grid
* @return The length in blocks to occupy on the block grid
*/
public int getLength() {
public Integer getLength() {
return length;
}
@ -40,7 +40,7 @@ public class GridAlignedData {
* Gets the width in blocks to occupy on the block grid
* @return The width in blocks to occupy on the block grid
*/
public int getHeight() {
public Integer getHeight() {
return height;
}

View File

@ -61,10 +61,14 @@ public class ServerWorldData {
boolean isArena = false;
//terrain data
/**
* terrain data
*/
private ServerTerrainManager serverTerrainManager;
//fluid data
/**
* fluid data
*/
private ServerFluidManager serverFluidManager;
/**
@ -345,6 +349,19 @@ public class ServerWorldData {
public int clampWorldToMacro(int worldPos){
return (worldPos / this.serverTerrainManager.getModel().getMacroDataScale()) * this.serverTerrainManager.getModel().getMacroDataScale();
}
/**
* Clamps a real space position to the closest block space position
* @param realPos The real space position
* @return The real space position that is clamped to the closest block space position
*/
public Vector3d clampRealToBlock(Vector3d realPos){
return new Vector3d(
realPos.x - realPos.x % BlockChunkData.BLOCK_SIZE_MULTIPLIER,
realPos.y - realPos.y % BlockChunkData.BLOCK_SIZE_MULTIPLIER,
realPos.z - realPos.z % BlockChunkData.BLOCK_SIZE_MULTIPLIER
);
}
/**
* Gets the terrain manager for this world