]> Dogcows Code - chaz/yoink/commitdiff
more cleanup
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Thu, 3 Sep 2009 14:37:28 +0000 (08:37 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Thu, 3 Sep 2009 14:37:28 +0000 (08:37 -0600)
src/Character.cc
src/Moof/Octree.cc
src/Moof/Octree.hh
src/Moof/Scene.cc
src/YoinkApp.cc
src/YoinkApp.hh

index 873f9e13c74db5a2103ddb893d27af2ac010f9b1..411c0327e641ba8c5ff0883f0efc0d4a22d6f366 100644 (file)
@@ -143,7 +143,7 @@ void Character::draw(Mf::Scalar alpha) const
 
        Mf::Scalar s = 16.0;
 
-       glBegin(GL_QUADS);
+       glBegin(GL_TRIANGLE_FAN);
                glTexCoord2f(coords[0], coords[1]);
                glVertex3(state.position[0]-s, state.position[1]-s, z);
                glTexCoord2f(coords[2], coords[3]);
index 300dbcdea7a9f2537d0499667374f22d777c2cb3..bd1b410a6faa17cbc837df55527646b54c5232fb 100644 (file)
@@ -66,6 +66,9 @@ OctreeNodeP Octree::insert(EntityP entity, OctreeNodeP node)
                        entity->getAabb().max[2] < node->getAabb().max[2] &&
                        entity->getAabb().min[2] > node->getAabb().min[2]))
        {
+               // TODO this check is only needed for the root node, if we're inside the
+               // volume of the root node, we'll be fully inside the child as
+               // determined by trying to insert the parent node
                goto done;
        }
 
index 4dc0c5c7e460e801594585200e47d3a70bc34064..3614606fd911882dc96195cb28cedd3f83282120 100644 (file)
@@ -39,6 +39,7 @@
 #include <Moof/Aabb.hh>
 #include <Moof/Drawable.hh>
 #include <Moof/Entity.hh>
+#include <Moof/Log.hh>
 #include <Moof/Math.hh>
 #include <Moof/Sphere.hh>
        
@@ -138,6 +139,13 @@ class Octree
 
 public:
 
+       inline void print(OctreeNodeP node)
+       {
+               logDebug("-----");
+               logDebug("depth to node: %d", tree_.depth(node));
+               logDebug("size of node: %d", tree_.size(node));
+       }
+
        inline static OctreeP alloc(const OctreeNode& rootNode)
        {
                return OctreeP(new Octree(rootNode));
index ccfd4f934060b605ad5de663c9e62bf84414c9e0..454726817a3fc9285616efbcf47e405f6fe24aa8 100644 (file)
@@ -26,7 +26,6 @@
 
 *******************************************************************************/
 
-#include <iostream>
 #include <map>
 #include <vector>
 
@@ -34,6 +33,7 @@
 #include "Camera.hh"
 #include "Deserializer.hh"
 #include "Entity.hh"
+#include "Log.hh"
 #include "Math.hh"
 #include "Mippleton.hh"
 #include "OpenGL.hh"
@@ -67,7 +67,13 @@ class Scene::Impl : public Mippleton<Impl>
 
                        if (!tilemap_.getTileCoords(tileIndex, texCoords_))
                        {
-                               std::cerr << "no coords for tile's texture" << std::endl;
+                               logWarning("no index %d in texture %s", tileIndex,
+                                               texture.c_str());
+
+                               texCoords_[0] = texCoords_[1] =
+                                       texCoords_[3] = texCoords_[6] = 0.0;
+                               texCoords_[2] = texCoords_[4] =
+                                       texCoords_[5] = texCoords_[7] = 1.0;
                        }
 
                        aabb_.encloseVertices(vertices, 4);
@@ -165,7 +171,7 @@ public:
 
                if (!root->get(rootObj))
                {
-                       std::cerr << "error loading scene instructions" << std::endl;
+                       logError("scene instructions must be an array");
                        return;
                }
 
@@ -299,7 +305,7 @@ public:
 
                if (!root->get(rootObj))
                {
-                       std::cerr << "error loading scene tilemap object" << std::endl;
+                       logError("invalid tilemap instruction");
                        return;
                }
 
@@ -313,7 +319,7 @@ public:
                }
                else
                {
-                       std::cerr << "width is a required field of a tilemap" << std::endl;
+                       logError("missing required field width for tilemap instruction");
                        return;
                }
 
@@ -352,7 +358,7 @@ public:
                }
                else
                {
-                       std::cerr << "error loading tiles from tilemap object" << std::endl;
+                       logError("invalid tiles in tilemap instruction");
                        return;
                }
 
@@ -480,7 +486,7 @@ public:
 
                if (!root || !root->get(rootObj))
                {
-                       std::cerr << "error loading scene file" << std::endl;
+                       logError("no root map in scene file");
                        return;
                }
 
@@ -494,7 +500,7 @@ public:
                }
                else
                {
-                       std::cerr << "maximum bounds required in scene" << std::endl;
+                       logError("missing required maximum bounds");
                        return;
                }
 
@@ -506,6 +512,8 @@ public:
                        loadInstructions((*it).second);
                }
 
+
+
                octree->sort();
        }
 
index 86816e5295a61d78e6dbb0ae02df255d06b6acc1..d391927d02b364bc1a07c8ba170de838a03a4ad0 100644 (file)
@@ -134,7 +134,7 @@ YoinkApp::YoinkApp(int argc, char* argv[]) :
        Mf::Scalar coeff[2] = {1.0, 0.0};
        fadeIn.init(coeff, 0.1);
 
-       testScene = new Mf::Scene("Test");
+       testScene = Mf::Scene::alloc("Test");
        heroine->treeNode = testScene->getOctree()->insert(heroine);
 }
 
@@ -142,7 +142,6 @@ YoinkApp::~YoinkApp()
 {
        //delete heroine;
        delete font;
-       delete testScene;
 
        Mf::dispatcher::removeHandler(this);
 }
@@ -202,6 +201,7 @@ void YoinkApp::update(Mf::Scalar t, Mf::Scalar dt)
 
        heroine->update(t, dt);
        heroine->treeNode = testScene->getOctree()->reinsert(heroine, heroine->treeNode);
+       testScene->getOctree()->print(heroine->treeNode);
        
        //camera.lookAt(heroine->getSphere().point);
        camera.setPosition(Mf::Vector3(-heroine->current.position[0], -heroine->current.position[1], -256));
index 65e730bccbeca19729edd2ae8a3330b5b1086280..6a947f9d8dfcb51408798258b2fea42f4c963589 100644 (file)
@@ -80,7 +80,7 @@ private:
        Mf::Lerps fadeIn;
 
        Mf::Camera camera;
-       Mf::Scene* testScene;
+       Mf::SceneP testScene;
 
        Mf::Scalar state;
        Mf::Scalar prevstate;
This page took 0.033134 seconds and 4 git commands to generate.