From: Charles McGarvey Date: Thu, 3 Sep 2009 14:37:28 +0000 (-0600) Subject: more cleanup X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=1dd005530930657fd6216edc1dfcfa4c270a81c9;p=chaz%2Fyoink more cleanup --- diff --git a/src/Character.cc b/src/Character.cc index 873f9e1..411c032 100644 --- a/src/Character.cc +++ b/src/Character.cc @@ -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]); diff --git a/src/Moof/Octree.cc b/src/Moof/Octree.cc index 300dbcd..bd1b410 100644 --- a/src/Moof/Octree.cc +++ b/src/Moof/Octree.cc @@ -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; } diff --git a/src/Moof/Octree.hh b/src/Moof/Octree.hh index 4dc0c5c..3614606 100644 --- a/src/Moof/Octree.hh +++ b/src/Moof/Octree.hh @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -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)); diff --git a/src/Moof/Scene.cc b/src/Moof/Scene.cc index ccfd4f9..4547268 100644 --- a/src/Moof/Scene.cc +++ b/src/Moof/Scene.cc @@ -26,7 +26,6 @@ *******************************************************************************/ -#include #include #include @@ -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 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(); } diff --git a/src/YoinkApp.cc b/src/YoinkApp.cc index 86816e5..d391927 100644 --- a/src/YoinkApp.cc +++ b/src/YoinkApp.cc @@ -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)); diff --git a/src/YoinkApp.hh b/src/YoinkApp.hh index 65e730b..6a947f9 100644 --- a/src/YoinkApp.hh +++ b/src/YoinkApp.hh @@ -80,7 +80,7 @@ private: Mf::Lerps fadeIn; Mf::Camera camera; - Mf::Scene* testScene; + Mf::SceneP testScene; Mf::Scalar state; Mf::Scalar prevstate;