Now iterating through the octree rather than the scene graph structure during render, in preparation for occlusion culling

--HG--
extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%4084
This commit is contained in:
kearwood
2012-08-30 19:31:38 +00:00
parent 99b6d6771d
commit cee504408a
7 changed files with 59 additions and 7 deletions

View File

@@ -160,10 +160,12 @@ KRNode *KRNode::LoadXML(KRScene &scene, tinyxml2::XMLElement *e) {
bool KRNode::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass) {
/*
for(std::vector<KRNode *>::iterator itr=m_childNodes.begin(); itr < m_childNodes.end(); ++itr) {
KRNode *child = (*itr);
child->render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
}
*/
return false;
}

View File

@@ -82,3 +82,14 @@ void KROctree::shrink()
}
}
}
KROctreeNode *KROctree::getRootNode()
{
return m_pRootNode;
}
std::set<KRNode *> &KROctree::getOuterSceneNodes()
{
return m_outerSceneNodes;
}

View File

@@ -6,11 +6,12 @@
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#ifndef KRAABBTREE_H
#define KRAABBTREE_H
#ifndef KROCTREE_H
#define KROCTREE_H
#import "KREngine-common.h"
#include "KROctreeNode.h"
#include "KRMat4.h"
class KRNode;
@@ -23,11 +24,15 @@ public:
void remove(KRNode *pNode);
void update(KRNode *pNode);
KROctreeNode *getRootNode();
std::set<KRNode *> &getOuterSceneNodes();
private:
KROctreeNode *m_pRootNode;
std::set<KRNode *>m_outerSceneNodes;
//std::set<KRMat4> visibleMVPs;
void shrink();
};
#endif /* defined(KRAABBTREE_H) */
#endif /* defined(KROCTREE_H) */

View File

@@ -170,3 +170,14 @@ KROctreeNode *KROctreeNode::stripChild()
}
return NULL;
}
KROctreeNode **KROctreeNode::getChildren()
{
return m_children;
}
std::set<KRNode *> &KROctreeNode::getSceneNodes()
{
return m_sceneNodes;
}

View File

@@ -6,8 +6,8 @@
// Copyright (c) 2012 Kearwood Software. All rights reserved.
//
#ifndef KRAABBTREENODE_H
#define KRAABBTREENODE_H
#ifndef KROCTREENODE_H
#define KROCTREENODE_H
#import "KREngine-common.h"
#include "KRVector3.h"
@@ -20,6 +20,9 @@ public:
KROctreeNode(const KRVector3 &minPoint, const KRVector3 &maxPoint, int iChild, KROctreeNode *pChild);
~KROctreeNode();
KROctreeNode **getChildren();
std::set<KRNode *> &getSceneNodes();
void add(KRNode *pNode);
void remove(KRNode *pNode);
void update(KRNode *pNode);
@@ -44,4 +47,4 @@ private:
};
#endif /* defined(KRAABBTREENODE_H) */
#endif /* defined(KROCTREENODE_H) */

View File

@@ -123,7 +123,25 @@ void KRScene::render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &f
*/
m_pRootNode->render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, forward_render_light_direction, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
//m_pRootNode->render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, forward_render_light_direction, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
render(m_nodeTree.getRootNode(), pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, forward_render_light_direction, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
for(std::set<KRNode *>::iterator itr=m_nodeTree.getOuterSceneNodes().begin(); itr != m_nodeTree.getOuterSceneNodes().end(); itr++) {
(*itr)->render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
}
}
void KRScene::render(KROctreeNode *pOctreeNode, KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass)
{
if(pOctreeNode) {
for(std::set<KRNode *>::iterator itr=pOctreeNode->getSceneNodes().begin(); itr != pOctreeNode->getSceneNodes().end(); itr++) {
(*itr)->render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
}
for(int i=0; i<8; i++) {
render(pOctreeNode->getChildren()[i], pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
}
}
}
#endif

View File

@@ -66,6 +66,8 @@ public:
void render(KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass);
void render(KROctreeNode *pOctreeNode, KRCamera *pCamera, KRContext *pContext, KRBoundingVolume &frustrumVolume, KRMat4 &viewMatrix, KRVector3 &cameraPosition, KRVector3 &lightDirection, KRMat4 *pShadowMatrices, GLuint *shadowDepthTextures, int cShadowBuffers, KRNode::RenderPass renderPass);
#endif
KRBoundingVolume getExtents(KRContext *pContext);