simplify draw call logic
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
f7d8072122
commit
897b867641
@ -2061,6 +2061,8 @@ More tests
|
||||
Move actor masks into dedicated package
|
||||
Actor code cleanup
|
||||
Refactor animation logic into dedicated actor class
|
||||
Simplify draw call logic
|
||||
Error report on window.java
|
||||
|
||||
|
||||
|
||||
|
||||
@ -173,45 +173,54 @@ public class Actor {
|
||||
public void draw(RenderPipelineState renderPipelineState, OpenGLState openGLState){
|
||||
Globals.profiler.beginAggregateCpuSample("Actor.draw");
|
||||
|
||||
//
|
||||
//fetch the model
|
||||
String pathToFetch = this.baseModelPath;
|
||||
if(this.lodLevel <= Actor.LOD_LEVEL_LOWER && this.lowResBaseModelPath != null){
|
||||
pathToFetch = this.lowResBaseModelPath;
|
||||
}
|
||||
Model model = Globals.assetManager.fetchModel(pathToFetch);
|
||||
|
||||
if(model == null){
|
||||
Globals.profiler.endCpuSample();
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
//update core data on the model
|
||||
model.setModelMatrix(this.modelMatrix);
|
||||
model.setWorldPos(this.worldPos);
|
||||
|
||||
//frustum cull then draw
|
||||
if(Actor.isWithinFrustumBox(renderPipelineState,model,frustumCull)){
|
||||
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);
|
||||
//
|
||||
//frustum cull
|
||||
if(!Actor.isWithinFrustumBox(renderPipelineState,model,frustumCull)){
|
||||
Globals.profiler.endCpuSample();
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
@ -631,6 +631,9 @@ public class Window implements DrawableElement, ContainerElement, NavigableEleme
|
||||
|
||||
@Override
|
||||
public void addChild(Element child) {
|
||||
if(child.getParent() != null){
|
||||
throw new Error("Child has a parent!");
|
||||
}
|
||||
childList.add(child);
|
||||
child.setParent(this);
|
||||
if(child instanceof DrawableElement){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user