grid-align work
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
f1a7f10f50
commit
22e6f80207
@ -85,6 +85,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"gridAlignedData" : {
|
||||
"width" : 10,
|
||||
"height" : 10,
|
||||
"length" : 10
|
||||
},
|
||||
"graphicsTemplate": {
|
||||
"model": {
|
||||
"path" : "Models/objects/furniture/workbench1.glb"
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
|
||||
|
||||
@ -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";
|
||||
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -61,10 +61,14 @@ public class ServerWorldData {
|
||||
boolean isArena = false;
|
||||
|
||||
|
||||
//terrain data
|
||||
/**
|
||||
* terrain data
|
||||
*/
|
||||
private ServerTerrainManager serverTerrainManager;
|
||||
|
||||
//fluid data
|
||||
/**
|
||||
* fluid data
|
||||
*/
|
||||
private ServerFluidManager serverFluidManager;
|
||||
|
||||
/**
|
||||
@ -346,6 +350,19 @@ public class ServerWorldData {
|
||||
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
|
||||
* @return The terrain manager if it exists, null otherwise
|
||||
|
||||
Loading…
Reference in New Issue
Block a user