Permalink
Browse files

Fixed octree box rendering loop limit. Added keys (,/.) to decrease/i…

…ncrease tree rendering depth
  • Loading branch information...
1 parent 7933232 commit f624c5ec13a1a452291e458fa5fc183ce5dea70a @harrism harrism committed Apr 20, 2012
Showing with 17 additions and 6 deletions.
  1. +17 −6 runtime/src/renderloop.cpp
View
@@ -77,7 +77,8 @@ class BonsaiDemo
: m_tree(tree), m_idata(idata), iterationsRemaining(true),
m_displayMode(ParticleRenderer::PARTICLE_SPRITES),
m_ox(0), m_oy(0), m_buttonState(0), m_inertia(0.1f),
- m_paused(false), m_displayBoxes(false)
+ m_paused(false), m_displayBoxes(false),
+ m_octreeDisplayLevel(3)
{
m_windowDims = make_int2(720, 480);
m_cameraTrans = make_float3(0, -2, -100);
@@ -106,6 +107,10 @@ class BonsaiDemo
void togglePause() { m_paused = !m_paused; }
void toggleBoxes() { m_displayBoxes = !m_displayBoxes; }
+ void incrementOctreeDisplayLevel(int inc) {
+ m_octreeDisplayLevel += inc;
+ m_octreeDisplayLevel = std::max(0, std::min(m_octreeDisplayLevel, 30));
+ }
void step() {
if (!m_paused && iterationsRemaining)
@@ -139,12 +144,10 @@ class BonsaiDemo
m_tree->localTree.boxCenterInfo.d2h();
m_tree->localTree.boxSizeInfo.d2h();
m_tree->localTree.node_level_list.d2h(); //Should not be needed is created on host
+
+ int displayLevel = min(m_octreeDisplayLevel, m_tree->localTree.n_levels);
- uint drawUpToLevel = 6;
-
- drawUpToLevel = min(drawUpToLevel, m_tree->localTree.n_levels);
-
- for(uint i=0; i < m_tree->localTree.node_level_list[drawUpToLevel]; i++)
+ for(uint i=0; i < m_tree->localTree.level_list[displayLevel].y; i++)
{
float3 boxMin, boxMax;
boxMin.x = m_tree->localTree.boxCenterInfo[i].x-m_tree->localTree.boxSizeInfo[i].x;
@@ -270,6 +273,7 @@ class BonsaiDemo
ParticleRenderer m_renderer;
ParticleRenderer::DisplayMode m_displayMode;
+ int m_octreeDisplayLevel;
// view params
int m_ox; // = 0
@@ -352,6 +356,13 @@ void key(unsigned char key, int /*x*/, int /*y*/)
case 'F':
theDemo->fitCamera();
break;
+ case ',':
+ case '<':
+ theDemo->incrementOctreeDisplayLevel(-1);
+ break;
+ case '.':
+ theDemo->incrementOctreeDisplayLevel(+1);
+ break;
}
glutPostRedisplay();

0 comments on commit f624c5e

Please sign in to comment.