lod emitter service work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
11b519ef79
commit
f29638ad00
@ -1969,6 +1969,7 @@ Performance improvements
|
||||
- Normal outline pipeline use draw accumulator
|
||||
- Reduced the visual LOD cutoff
|
||||
- Multiple visual LOD levels
|
||||
Lod emitter service checker function
|
||||
|
||||
|
||||
|
||||
|
||||
@ -54,15 +54,7 @@ public class ServerLODComponent implements BehaviorTree {
|
||||
@Override
|
||||
public void simulate(float deltaTime) {
|
||||
Vector3d parentLoc = EntityUtils.getPosition(this.parent);
|
||||
boolean fullRes = false;
|
||||
for(Entity emitter : Globals.serverState.lodEmitterService.getEmitters()){
|
||||
Vector3d emitterLoc = EntityUtils.getPosition(emitter);
|
||||
double dist = parentLoc.distance(emitterLoc);
|
||||
if(dist < LOD_RADIUS){
|
||||
fullRes = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
boolean fullRes = Globals.serverState.lodEmitterService.isFullLod(parentLoc);
|
||||
if(fullRes){
|
||||
if(lodLevel != FULL_RES){
|
||||
//make full res
|
||||
|
||||
@ -5,9 +5,14 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import org.joml.Vector3d;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.engine.signal.SignalServiceImpl;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.lod.ServerLODComponent;
|
||||
|
||||
/**
|
||||
* Manages lod emitters
|
||||
@ -62,5 +67,21 @@ public class LODEmitterService extends SignalServiceImpl {
|
||||
this.emitters.remove(entity);
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given position would be full LOD
|
||||
* @param position The position
|
||||
* @return true if it is full lod, false otherwise
|
||||
*/
|
||||
public boolean isFullLod(Vector3d position){
|
||||
for(Entity emitter : Globals.serverState.lodEmitterService.getEmitters()){
|
||||
Vector3d emitterLoc = EntityUtils.getPosition(emitter);
|
||||
double dist = position.distance(emitterLoc);
|
||||
if(dist < ServerLODComponent.FULL_RES){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user