Permalink
Browse files

debug info. Null nodes

  • Loading branch information...
1 parent f1e80b6 commit 33de82be2ab055a8d34802dcdad00a2fb2e4bbd2 @timgarbos committed May 10, 2012
Showing with 19 additions and 20 deletions.
  1. +12 −18 src/LevelNode.cpp
  2. +1 −1 src/LevelNode.h
  3. +6 −1 src/main.cpp
View
@@ -17,47 +17,41 @@ LevelNode::~LevelNode(void)
}
-void LevelNode::CreateRandomWorld(int depth, int dir, LevelNode* back)
+void LevelNode::CreateRandomWorld(int depth)
{
//create piece of geometry
Geom* newGeom = new Geom(true,Vec2(2,1));
GeomInstance* newGeomInst = new GeomInstance(Vec2(0,0),newGeom);
objs.push_back(newGeomInst);
- if(depth<3) //stop at some test level
+ printf("\ndepth: %i",depth);
+
+ if(false) //stop at some test level
{
depth++;
LevelNode* wNode = new LevelNode();
- wNode->CreateRandomWorld(depth,0,this);
+ wNode->CreateRandomWorld(depth);
w->Node = wNode;
+ wNode->e->Node = this;
LevelNode* eNode = new LevelNode();
- eNode->CreateRandomWorld(depth,1,this);
+ eNode->CreateRandomWorld(depth);
e->Node = eNode;
+ eNode->w->Node = this;
LevelNode* nNode = new LevelNode();
- nNode->CreateRandomWorld(depth,2,this);
+ nNode->CreateRandomWorld(depth);
n->Node = nNode;
+ nNode->s->Node = this;
LevelNode* sNode = new LevelNode();
- sNode->CreateRandomWorld(depth,3,this);
+ sNode->CreateRandomWorld(depth);
s->Node = sNode;
+ sNode->n->Node = this;
}
-
- switch(dir) //set back node. TODO: We should delete the old one first!
- {
- case 0: w->Node = back;
- break;
- case 1: e->Node = back;
- break;
- case 2: n->Node = back;
- break;
- case 3: s->Node = back;
- break;
- }
}
View
@@ -13,7 +13,7 @@ class LevelNode
public:
LevelNode(void);
~LevelNode(void);
- void CreateRandomWorld(int depth, int dir, LevelNode* parent);
+ void CreateRandomWorld(int depth);
LevelEdge *w;
LevelEdge *e;
View
@@ -111,24 +111,28 @@ inline void trace(LevelNode * node, Vec2 pos, Vec2 dir, float dMax, float & dOut
// transfer to edge
if (rayline(pos, dir, v00, v10, ut, vt))
{
+ printf("\ngoing south",0);
e = node->s;// => south
pos.x = ut*dir.x;
pos.y = -1.0f;
}
else if (rayline(pos, dir, v10, v11, ut, vt))
{
+ printf("\ngoing east",0);
e = node->e;// => east
pos.x = 1.0f;
pos.y = ut*dir.y;
}
else if (rayline(pos, dir, v11, v01, ut, vt))
{
+ printf("\ngoing north",0);
e = node->n;// => north
pos.x = ut*dir.x;
pos.y = 1.0f;
}
else if (rayline(pos, dir, v01, v00, ut, vt))
{
+ printf("\ngoing west",0);
e = node->w;// => west
pos.x = -1.0f;
pos.y = ut*dir.y;
@@ -150,6 +154,7 @@ inline void trace(LevelNode * node, Vec2 pos, Vec2 dir, float dMax, float & dOut
rot90(dir, e->ccwSteps);
// move to connecting node
+ printf("\n node: %i",node);
node = e->Node;
}
@@ -175,7 +180,7 @@ inline void trace(LevelNode * node, Vec2 pos, Vec2 dir, float dMax, float & dOut
LevelNode* createDebugWorld()
{
LevelNode* worldCenter = new LevelNode();
- worldCenter->CreateRandomWorld(0,0,0);
+ worldCenter->CreateRandomWorld(0);
return worldCenter;
}

0 comments on commit 33de82b

Please sign in to comment.