]> Dogcows Code - chaz/yoink/blobdiff - src/Moof/Engine.cc
fixed layer bugs; generalized octree
[chaz/yoink] / src / Moof / Engine.cc
index 5bfaaf3cd8d715d0927c9a284a5199a6686e98a6..16da8d40620edd59199a02e46ef43302113f8984 100644 (file)
@@ -82,11 +82,13 @@ public:
                if (settings.get("rngseed", randomSeed)) setSeed(randomSeed);
                else setSeed();
 
                if (settings.get("rngseed", randomSeed)) setSeed(randomSeed);
                else setSeed();
 
-               settings.get("timestep", timestep);
+               Scalar timeStep = 80.0;
+               settings.get("timestep", timeStep);
+               timestep = 1.0 / timeStep;
 
 
-               long maxFps = 40;
+               Scalar maxFps = 40.0;
                settings.get("maxfps", maxFps);
                settings.get("maxfps", maxFps);
-               drawRate = 1.0 / Scalar(maxFps);
+               drawRate = 1.0 / maxFps;
 
                settings.get("printfps", printFps);
 
 
                settings.get("printfps", printFps);
 
@@ -246,55 +248,66 @@ public:
        }
 
 
        }
 
 
-       void pushLayer(LayerP layer)
+       void push(LayerP layer)
        {
                ASSERT(layer && "cannot push null layer");
                stack.push_front(layer);
        {
                ASSERT(layer && "cannot push null layer");
                stack.push_front(layer);
+               logInfo(" push: %d", stack.size());
                layer->pushed(interface);
        }
 
                layer->pushed(interface);
        }
 
-       void popLayer()
+       LayerP pop()
        {
                bool fixIt = false;
                if (stack.begin() == stackIt) fixIt = true;
 
                LayerP popped = stack.front();
                stack.pop_front();
        {
                bool fixIt = false;
                if (stack.begin() == stackIt) fixIt = true;
 
                LayerP popped = stack.front();
                stack.pop_front();
+               logInfo("  pop: %d", stack.size());
                popped->popped(interface);
 
                if (fixIt) stackIt = --stack.begin();
                popped->popped(interface);
 
                if (fixIt) stackIt = --stack.begin();
+
+               return popped;
        }
 
        }
 
-       void popLayer(Layer* layer)
+       LayerP pop(Layer* layer)
        {
                bool fixIt = false;
 
        {
                bool fixIt = false;
 
+               std::list<LayerP> popped;
+
                std::list<LayerP>::iterator it;
                for (it = stack.begin(); it != stack.end(); ++it)
                {
                std::list<LayerP>::iterator it;
                for (it = stack.begin(); it != stack.end(); ++it)
                {
+                       popped.push_back(*it);
+
                        if (it == stackIt) fixIt = true;
 
                        if ((*it).get() == layer)
                        {
                                ++it;
                        if (it == stackIt) fixIt = true;
 
                        if ((*it).get() == layer)
                        {
                                ++it;
-                               do
+                               stack.erase(stack.begin(), it);
+
+                               for (it = popped.begin(); it != popped.end(); ++it)
                                {
                                {
-                                       LayerP popped = stack.front();
-                                       stack.pop_front();
-                                       popped->popped(interface);
+                                       (*it)->popped(interface);
                                }
                                }
-                               while (stack.begin() != it);
 
                                if (fixIt) stackIt = --stack.begin();
 
                                if (fixIt) stackIt = --stack.begin();
-                               return;
+
+                               return popped.back();
                        }
                }
                        }
                }
+
+               return LayerP();
        }
 
        }
 
-       void clearLayers()
+       void clear()
        {
                stack.clear();
                stackIt = stack.begin();
        {
                stack.clear();
                stackIt = stack.begin();
+               logInfo("clear: %d", stack.size());
        }
 
 
        }
 
 
@@ -327,6 +340,8 @@ Engine& Engine::getInstance()
 {
        ASSERT(instance && "dereferencing null pointer");
        return *instance;
 {
        ASSERT(instance && "dereferencing null pointer");
        return *instance;
+       //static Engine engine;
+       //return engine;
 }
 
 
 }
 
 
@@ -367,28 +382,28 @@ long Engine::getFrameRate() const
 }
 
 
 }
 
 
-void Engine::pushLayer(LayerP layer)
+void Engine::push(LayerP layer)
 {
        // pass through
 {
        // pass through
-       impl_->pushLayer(layer);
+       impl_->push(layer);
 }
 
 }
 
-void Engine::popLayer()
+LayerP Engine::pop()
 {
        // pass through
 {
        // pass through
-       impl_->popLayer();
+       return impl_->pop();
 }
 
 }
 
-void Engine::popLayer(Layer* layer)
+LayerP Engine::pop(Layer* layer)
 {
        // pass through
 {
        // pass through
-       impl_->popLayer(layer);
+       return impl_->pop(layer);
 }
 
 }
 
-void Engine::clearLayers()
+void Engine::clear()
 {
        // pass through
 {
        // pass through
-       impl_->clearLayers();
+       impl_->clear();
 }
 
 
 }
 
 
This page took 0.026441 seconds and 4 git commands to generate.