mirror of
https://github.com/devZoGok/vb01.git
synced 2026-08-26 19:43:30 +00:00
nodes to be rendered are sorted by distance to camera plane
This commit is contained in:
@@ -58,9 +58,6 @@ namespace vb01{
|
||||
|
||||
for(Skeleton *sk : skeletons)
|
||||
sk->update();
|
||||
|
||||
for(Node *c : children)
|
||||
c->update();
|
||||
}
|
||||
|
||||
for(Driver *driver : drivers)
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace vb01{
|
||||
|
||||
AnimationController::getSingleton()->update();
|
||||
|
||||
rootNode->update();
|
||||
updateNodeTree(rootNode);
|
||||
|
||||
LineRenderer::getSingleton()->drawLines();
|
||||
|
||||
@@ -167,12 +167,38 @@ namespace vb01{
|
||||
updateGuiPlane();
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
guiNode->update();
|
||||
updateNodeTree(guiNode);
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
//TODO replace sorting algorithm and sort only transparent objects
|
||||
void Root::updateNodeTree(Node *node){
|
||||
vector<Node*> descendants;
|
||||
node->getDescendants(descendants);
|
||||
|
||||
int numDesc = descendants.size();
|
||||
|
||||
for(int i = 0; i < numDesc; i++){
|
||||
Vector3 v1 = descendants[i]->getPosition() - camera->getPosition();
|
||||
float a1 = v1.norm().getAngleBetween(camera->getDirection());
|
||||
float d1 = v1.getLength() * cos(a1);
|
||||
|
||||
for(int j = i; j < numDesc; j++){
|
||||
Vector3 v2 = descendants[j]->getPosition() - camera->getPosition();
|
||||
float a2 = v2.norm().getAngleBetween(camera->getDirection());
|
||||
float d2 = v2.getLength() * cos(a2);
|
||||
|
||||
if(d1 < d2)
|
||||
swap(descendants[i], descendants[j]);
|
||||
}
|
||||
}
|
||||
|
||||
for(Node *desc : descendants)
|
||||
desc->update();
|
||||
}
|
||||
|
||||
void Root::updateBloomFramebuffer(){
|
||||
bool horizontal = false;
|
||||
blurShader->use();
|
||||
|
||||
Reference in New Issue
Block a user