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:
@@ -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) {
|
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) {
|
for(std::vector<KRNode *>::iterator itr=m_childNodes.begin(); itr < m_childNodes.end(); ++itr) {
|
||||||
KRNode *child = (*itr);
|
KRNode *child = (*itr);
|
||||||
child->render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
child->render(pCamera, pContext, frustrumVolume, viewMatrix, cameraPosition, lightDirection, pShadowMatrices, shadowDepthTextures, cShadowBuffers, renderPass);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,3 +82,14 @@ void KROctree::shrink()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KROctreeNode *KROctree::getRootNode()
|
||||||
|
{
|
||||||
|
return m_pRootNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<KRNode *> &KROctree::getOuterSceneNodes()
|
||||||
|
{
|
||||||
|
return m_outerSceneNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,12 @@
|
|||||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef KRAABBTREE_H
|
#ifndef KROCTREE_H
|
||||||
#define KRAABBTREE_H
|
#define KROCTREE_H
|
||||||
|
|
||||||
#import "KREngine-common.h"
|
#import "KREngine-common.h"
|
||||||
#include "KROctreeNode.h"
|
#include "KROctreeNode.h"
|
||||||
|
#include "KRMat4.h"
|
||||||
|
|
||||||
class KRNode;
|
class KRNode;
|
||||||
|
|
||||||
@@ -23,11 +24,15 @@ public:
|
|||||||
void remove(KRNode *pNode);
|
void remove(KRNode *pNode);
|
||||||
void update(KRNode *pNode);
|
void update(KRNode *pNode);
|
||||||
|
|
||||||
|
KROctreeNode *getRootNode();
|
||||||
|
std::set<KRNode *> &getOuterSceneNodes();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KROctreeNode *m_pRootNode;
|
KROctreeNode *m_pRootNode;
|
||||||
std::set<KRNode *>m_outerSceneNodes;
|
std::set<KRNode *>m_outerSceneNodes;
|
||||||
|
//std::set<KRMat4> visibleMVPs;
|
||||||
|
|
||||||
void shrink();
|
void shrink();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(KRAABBTREE_H) */
|
#endif /* defined(KROCTREE_H) */
|
||||||
|
|||||||
@@ -170,3 +170,14 @@ KROctreeNode *KROctreeNode::stripChild()
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
KROctreeNode **KROctreeNode::getChildren()
|
||||||
|
{
|
||||||
|
return m_children;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<KRNode *> &KROctreeNode::getSceneNodes()
|
||||||
|
{
|
||||||
|
return m_sceneNodes;
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@
|
|||||||
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef KRAABBTREENODE_H
|
#ifndef KROCTREENODE_H
|
||||||
#define KRAABBTREENODE_H
|
#define KROCTREENODE_H
|
||||||
|
|
||||||
#import "KREngine-common.h"
|
#import "KREngine-common.h"
|
||||||
#include "KRVector3.h"
|
#include "KRVector3.h"
|
||||||
@@ -20,6 +20,9 @@ public:
|
|||||||
KROctreeNode(const KRVector3 &minPoint, const KRVector3 &maxPoint, int iChild, KROctreeNode *pChild);
|
KROctreeNode(const KRVector3 &minPoint, const KRVector3 &maxPoint, int iChild, KROctreeNode *pChild);
|
||||||
~KROctreeNode();
|
~KROctreeNode();
|
||||||
|
|
||||||
|
KROctreeNode **getChildren();
|
||||||
|
std::set<KRNode *> &getSceneNodes();
|
||||||
|
|
||||||
void add(KRNode *pNode);
|
void add(KRNode *pNode);
|
||||||
void remove(KRNode *pNode);
|
void remove(KRNode *pNode);
|
||||||
void update(KRNode *pNode);
|
void update(KRNode *pNode);
|
||||||
@@ -44,4 +47,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* defined(KRAABBTREENODE_H) */
|
#endif /* defined(KROCTREENODE_H) */
|
||||||
|
|||||||
@@ -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
|
#endif
|
||||||
|
|||||||
@@ -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(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
|
#endif
|
||||||
|
|
||||||
KRBoundingVolume getExtents(KRContext *pContext);
|
KRBoundingVolume getExtents(KRContext *pContext);
|
||||||
|
|||||||
Reference in New Issue
Block a user