simplify draw call logic
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-29 15:53:07 -04:00
parent f7d8072122
commit 897b867641
3 changed files with 39 additions and 25 deletions

View File

@ -2061,6 +2061,8 @@ More tests
Move actor masks into dedicated package Move actor masks into dedicated package
Actor code cleanup Actor code cleanup
Refactor animation logic into dedicated actor class Refactor animation logic into dedicated actor class
Simplify draw call logic
Error report on window.java

View File

@ -173,45 +173,54 @@ public class Actor {
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState){ public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState){
Globals.profiler.beginAggregateCpuSample("Actor.draw"); Globals.profiler.beginAggregateCpuSample("Actor.draw");
//
//fetch the model //fetch the model
String pathToFetch = this.baseModelPath; String pathToFetch = this.baseModelPath;
if(this.lodLevel <= Actor.LOD_LEVEL_LOWER && this.lowResBaseModelPath != null){ if(this.lodLevel <= Actor.LOD_LEVEL_LOWER && this.lowResBaseModelPath != null){
pathToFetch = this.lowResBaseModelPath; pathToFetch = this.lowResBaseModelPath;
} }
Model model = Globals.assetManager.fetchModel(pathToFetch); Model model = Globals.assetManager.fetchModel(pathToFetch);
if(model == null){ if(model == null){
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
return; return;
} }
//
//update core data on the model
model.setModelMatrix(this.modelMatrix); model.setModelMatrix(this.modelMatrix);
model.setWorldPos(this.worldPos); model.setWorldPos(this.worldPos);
//frustum cull then draw //
if(Actor.isWithinFrustumBox(renderPipelineState,model,frustumCull)){ //frustum cull
this.animationData.applyAnimationMasks(model); if(!Actor.isWithinFrustumBox(renderPipelineState,model,frustumCull)){
meshMask.processMeshMaskQueue(); Globals.profiler.endCpuSample();
model.setMeshMask(meshMask); return;
model.setTextureMask(textureMap);
for(ActorShaderMask shaderMask : shaderMasks){
if(shaderMask.getModelName().equals(pathToFetch)){
model.getShaderMask().put(shaderMask.getMeshName(),shaderMask);
}
}
this.animationData.calculateNodeTransforms(model);
//apply uniform overrides
if(this.uniformMap.getMeshes() != null && this.uniformMap.getMeshes().size() > 0){
for(String meshName : this.uniformMap.getMeshes()){
List<UniformValue> uniforms = this.uniformMap.getUniforms(meshName);
for(UniformValue uniform : uniforms){
model.pushUniformToMesh(meshName, uniform.getUniformName(), uniform.getValue());
}
}
}
model.draw(renderPipelineState,openGLState);
model.getShaderMask().clear();
model.setTextureMask(null);
} }
//
//main draw logic
this.animationData.applyAnimationMasks(model);
meshMask.processMeshMaskQueue();
model.setMeshMask(meshMask);
model.setTextureMask(textureMap);
for(ActorShaderMask shaderMask : shaderMasks){
if(shaderMask.getModelName().equals(pathToFetch)){
model.getShaderMask().put(shaderMask.getMeshName(),shaderMask);
}
}
this.animationData.calculateNodeTransforms(model);
//apply uniform overrides
if(this.uniformMap.getMeshes() != null && this.uniformMap.getMeshes().size() > 0){
for(String meshName : this.uniformMap.getMeshes()){
List<UniformValue> uniforms = this.uniformMap.getUniforms(meshName);
for(UniformValue uniform : uniforms){
model.pushUniformToMesh(meshName, uniform.getUniformName(), uniform.getValue());
}
}
}
model.draw(renderPipelineState,openGLState);
model.getShaderMask().clear();
model.setTextureMask(null);
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
} }

View File

@ -631,6 +631,9 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
@Override @Override
public void addChild(Element child) { public void addChild(Element child) {
if(child.getParent() != null){
throw new Error("Child has a parent!");
}
childList.add(child); childList.add(child);
child.setParent(this); child.setParent(this);
if(child instanceof DrawableElement){ if(child instanceof DrawableElement){