performance improvements
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-25 10:30:37 -04:00
parent 2f58d38a1f
commit bdcdc266cd
7 changed files with 85 additions and 40 deletions

View File

@ -148,8 +148,8 @@
"movementSystems" : [ "movementSystems" : [
{ {
"type" : "GROUND", "type" : "GROUND",
"acceleration" : 400.0, "acceleration" : 800.0,
"maxVelocity" : 80.5, "maxVelocity" : 120.0,
"strafeMultiplier" : 1.0, "strafeMultiplier" : 1.0,
"backpedalMultiplier" : 0.5, "backpedalMultiplier" : 0.5,
"footstepFirstAudioOffset" : 0.2, "footstepFirstAudioOffset" : 0.2,

View File

@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file #maven.buildNumber.plugin properties file
#Sat May 24 23:29:15 EDT 2025 #Sun May 25 09:48:39 EDT 2025
buildNumber=633 buildNumber=634

View File

@ -1984,6 +1984,9 @@ Upgrade target framerate
Flag to enable/disable opengl error checking calls Flag to enable/disable opengl error checking calls
Performance improvements Performance improvements
- Foliage cell quits earlier - Foliage cell quits earlier
- Behavior tree addition/subtraction from scene optimization
- Reduce bones on LOD human model
Increase human move speed

View File

@ -9,6 +9,7 @@ import electrosphere.logger.LoggerInterface;
import electrosphere.util.annotation.Exclude; import electrosphere.util.annotation.Exclude;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
@ -25,22 +26,32 @@ public class Scene {
/** /**
* The map of id -> entity * The map of id -> entity
*/ */
Map<Integer,Entity> entityIdMap; private Map<Integer,Entity> entityIdMap;
/** /**
* The map of tag -> set of entities corresponding to that tag * The map of tag -> set of entities corresponding to that tag
*/ */
Map<String,Set<Entity>> tagEntityMap; private Map<String,Set<Entity>> tagEntityMap;
/** /**
* The map of entity -> tags that entity is registered to * The map of entity -> tags that entity is registered to
*/ */
Map<Entity,List<String>> entityTagMap; private Map<Entity,List<String>> entityTagMap;
/** /**
* The list of behavior trees * The list of behavior trees
*/ */
List<BehaviorTree> behaviorTreeList; private List<BehaviorTree> behaviorTreeList;
/**
* Accumulator for new behavior trees
*/
private List<BehaviorTree> additionList;
/**
* The list of trees to remove
*/
private List<BehaviorTree> removalList;
@Exclude @Exclude
/** /**
@ -52,29 +63,31 @@ public class Scene {
* Constructor * Constructor
*/ */
public Scene(){ public Scene(){
entityIdMap = new HashMap<Integer,Entity>(); this.entityIdMap = new HashMap<Integer,Entity>();
tagEntityMap = new HashMap<String,Set<Entity>>(); this.tagEntityMap = new HashMap<String,Set<Entity>>();
behaviorTreeList = new LinkedList<BehaviorTree>(); this.behaviorTreeList = new LinkedList<BehaviorTree>();
entityTagMap = new HashMap<Entity,List<String>>(); this.entityTagMap = new HashMap<Entity,List<String>>();
tagEntityMap.put(EntityTags.BONE_ATTACHED, new HashSet<Entity>()); this.additionList = new LinkedList<BehaviorTree>();
tagEntityMap.put(EntityTags.COLLIDABLE, new HashSet<Entity>()); this.removalList = new LinkedList<BehaviorTree>();
tagEntityMap.put(EntityTags.SPRINTABLE, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.BONE_ATTACHED, new HashSet<Entity>());
tagEntityMap.put(EntityTags.MOVEABLE, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.COLLIDABLE, new HashSet<Entity>());
tagEntityMap.put(EntityTags.ATTACKER, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.SPRINTABLE, new HashSet<Entity>());
tagEntityMap.put(EntityTags.TARGETABLE, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.MOVEABLE, new HashSet<Entity>());
tagEntityMap.put(EntityTags.LIFE_STATE, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.ATTACKER, new HashSet<Entity>());
tagEntityMap.put(EntityTags.CREATURE, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.TARGETABLE, new HashSet<Entity>());
tagEntityMap.put(EntityTags.UI, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.LIFE_STATE, new HashSet<Entity>());
tagEntityMap.put(EntityTags.DRAWABLE, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.CREATURE, new HashSet<Entity>());
tagEntityMap.put(EntityTags.DRAW_INSTANCED, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.UI, new HashSet<Entity>());
tagEntityMap.put(EntityTags.DRAW_VOLUMETIC_SOLIDS_PASS, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.DRAWABLE, new HashSet<Entity>());
tagEntityMap.put(EntityTags.DRAW_VOLUMETIC_DEPTH_PASS, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.DRAW_INSTANCED, new HashSet<Entity>());
tagEntityMap.put(EntityTags.DRAW_CAST_SHADOW, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.DRAW_VOLUMETIC_SOLIDS_PASS, new HashSet<Entity>());
tagEntityMap.put(EntityTags.LIGHT, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.DRAW_VOLUMETIC_DEPTH_PASS, new HashSet<Entity>());
tagEntityMap.put(EntityTags.ITEM, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.DRAW_CAST_SHADOW, new HashSet<Entity>());
tagEntityMap.put(EntityTags.GRAVITY, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.LIGHT, new HashSet<Entity>());
tagEntityMap.put(EntityTags.PARTICLE, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.ITEM, new HashSet<Entity>());
tagEntityMap.put(EntityTags.TRANSFORM_ATTACHED, new HashSet<Entity>()); this.tagEntityMap.put(EntityTags.GRAVITY, new HashSet<Entity>());
this.tagEntityMap.put(EntityTags.PARTICLE, new HashSet<Entity>());
this.tagEntityMap.put(EntityTags.TRANSFORM_ATTACHED, new HashSet<Entity>());
} }
/** /**
@ -164,7 +177,10 @@ public class Scene {
* @return The list of tags this entity is registered to * @return The list of tags this entity is registered to
*/ */
public List<String> extractTags(Entity e){ public List<String> extractTags(Entity e){
return this.entityTagMap.get(e); lock.lock();
List<String> rVal = this.entityTagMap.get(e);
lock.unlock();
return rVal;
} }
/** /**
@ -224,7 +240,7 @@ public class Scene {
*/ */
public void registerBehaviorTree(BehaviorTree tree){ public void registerBehaviorTree(BehaviorTree tree){
lock.lock(); lock.lock();
behaviorTreeList.add(tree); this.additionList.add(tree);
lock.unlock(); lock.unlock();
} }
@ -246,9 +262,7 @@ public class Scene {
*/ */
public void deregisterBehaviorTree(BehaviorTree tree){ public void deregisterBehaviorTree(BehaviorTree tree){
lock.lock(); lock.lock();
while(behaviorTreeList.contains(tree)){ this.removalList.add(tree);
behaviorTreeList.remove(tree);
}
lock.unlock(); lock.unlock();
} }
@ -258,8 +272,18 @@ public class Scene {
public void simulateBehaviorTrees(float deltaTime){ public void simulateBehaviorTrees(float deltaTime){
lock.lock(); lock.lock();
Globals.profiler.beginAggregateCpuSample("Scene.simulateBehaviorTrees"); Globals.profiler.beginAggregateCpuSample("Scene.simulateBehaviorTrees");
List<BehaviorTree> trees = new LinkedList<BehaviorTree>(behaviorTreeList); //remove all trees that were queued to be removed
for(BehaviorTree tree : trees){ this.behaviorTreeList.removeAll(this.removalList);
//add all trees that were queued to be added
this.behaviorTreeList.addAll(this.additionList);
//clear both the lists that are accumulating
this.removalList.clear();
this.additionList.clear();
//simulate all trees
for(BehaviorTree tree : this.behaviorTreeList){
tree.simulate(deltaTime); tree.simulate(deltaTime);
} }
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
@ -283,7 +307,19 @@ public class Scene {
*/ */
public Collection<BehaviorTree> getBehaviorTrees(){ public Collection<BehaviorTree> getBehaviorTrees(){
lock.lock(); lock.lock();
Collection<BehaviorTree> rVal = new LinkedList<BehaviorTree>(this.behaviorTreeList); Collection<BehaviorTree> rVal = Collections.unmodifiableList(this.behaviorTreeList);
lock.unlock();
return rVal;
}
/**
* Gets the number of behavior trees that will execute next frame
* @return The number of trees
*/
public int getNumBehaviorTrees(){
int rVal = 0;
lock.lock();
rVal = this.behaviorTreeList.size() + this.additionList.size();
lock.unlock(); lock.unlock();
return rVal; return rVal;
} }

View File

@ -354,6 +354,12 @@ public class Model {
if(animationCurrent != null){ if(animationCurrent != null){
for(String boneName : mask){ for(String boneName : mask){
AnimChannel currentChannel = animationCurrent.getChannel(boneName); AnimChannel currentChannel = animationCurrent.getChannel(boneName);
if(currentChannel == null){
//this happens when we have an animation key for a bone that is not on this model
//this can happen if, for example, you model a character, animate it, then delete a bone after the fact
//if the animation key hasn't explicitly been removed in blender, it will show up here for the non-existant bone
continue;
}
Bone currentBone = boneMap.get(currentChannel.getNodeID()); Bone currentBone = boneMap.get(currentChannel.getNodeID());
currentChannel.setTime(time); currentChannel.setTime(time);
// System.out.println(currentChannel + " " + currentBone); // System.out.println(currentChannel + " " + currentBone);

View File

@ -68,7 +68,7 @@ public class MicroSimulation {
// //
//simulate behavior trees //simulate behavior trees
if(dataCell.getScene().getBehaviorTrees().size() > 0){ if(dataCell.getScene().getNumBehaviorTrees() > 0){
dataCell.getScene().simulateBehaviorTrees((float)Globals.engineState.timekeeper.getSimFrameTime()); dataCell.getScene().simulateBehaviorTrees((float)Globals.engineState.timekeeper.getSimFrameTime());
} }