priority based foliage placement

This commit is contained in:
austin 2025-04-24 19:51:00 -04:00
parent bd5e7b562f
commit 3ca9cd1247
4 changed files with 32 additions and 19 deletions

View File

@ -86,7 +86,7 @@
"regularity": 0.6,
"threshold": 0.03,
"scale": 0.5,
"priority": 1.0
"priority": 5.0
},
{
"entityIDs": [
@ -95,14 +95,14 @@
"regularity": 0.6,
"threshold": 0.05,
"scale": 0.5,
"priority": 1.0
"priority": 3.0
},
{
"entityIDs": [
"rock_static"
],
"regularity": 0.6,
"threshold": 0.04,
"threshold": 0.06,
"scale": 0.5,
"priority": 1.0
}

View File

@ -1520,7 +1520,9 @@ Fix nav mesh construction params
(04/24/2025)
GriddedDataCellManager debugging tools
NavMesh bugfix
Fix jump tree not enabling physics body
Fix jump trees not enabling physics body
Priority based foliage content placement

View File

@ -6,7 +6,6 @@ import electrosphere.client.ui.menu.WindowStrings;
import electrosphere.client.ui.menu.WindowUtils;
import electrosphere.engine.Globals;
import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.engine.signal.Signal.SignalType;
import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.types.item.ItemUtils;
import electrosphere.game.data.item.Item;

View File

@ -66,26 +66,38 @@ public class ServerContentGenerator {
realm.getServerWorldData().convertVoxelToRealSpace(0, worldPos.y) < height &&
realm.getServerWorldData().convertVoxelToRealSpace(ServerTerrainChunk.CHUNK_DIMENSION, worldPos.y) > height
){
BiomeFoliageDescription toPlace = null;
double foundPriority = -1;
double realX = realm.getServerWorldData().convertVoxelToRealSpace(x, worldPos.x);
double realZ = realm.getServerWorldData().convertVoxelToRealSpace(z, worldPos.z);
for(BiomeFoliageDescription foliageDescription : foliageDescriptions){
double scale = foliageDescription.getScale();
double regularity = foliageDescription.getRegularity();
double threshold = foliageDescription.getThreshold();
double realX = realm.getServerWorldData().convertVoxelToRealSpace(x, worldPos.x);
double realZ = realm.getServerWorldData().convertVoxelToRealSpace(z, worldPos.z);
if(NoiseUtils.relaxedPointGen(realX * scale, realZ * scale, regularity, threshold) > 0){
String type = foliageDescription.getEntityIDs().get(random.nextInt(0,foliageDescription.getEntityIDs().size()));
FoliageUtils.serverSpawnTreeFoliage(
realm,
new Vector3d(
realX,
height,
realZ
),
type,
random.nextLong()
);
double value = NoiseUtils.relaxedPointGen(realX * scale, realZ * scale, regularity, threshold);
if(value > 0){
if(toPlace == null){
foundPriority = foliageDescription.getPriority();
toPlace = foliageDescription;
} else if(foliageDescription.getPriority() > foundPriority) {
foundPriority = foliageDescription.getPriority();
toPlace = foliageDescription;
}
}
}
if(toPlace != null){
String type = toPlace.getEntityIDs().get(random.nextInt(0,toPlace.getEntityIDs().size()));
FoliageUtils.serverSpawnTreeFoliage(
realm,
new Vector3d(
realX,
height,
realZ
),
type,
random.nextLong()
);
}
}
}
}