Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AABBNoLeafNode Class Reference

#include <OPC_OptimizedTree.h>

Related Functions

(Note that these are not member functions.)

 _BuildNoLeafTree (AABBNoLeafNode *linear, const udword box_id, udword &current_id, const AABBTreeNode *current_node)
 

Detailed Description

Definition at line 102 of file OPC_OptimizedTree.h.

Friends And Related Function Documentation

_BuildNoLeafTree ( AABBNoLeafNode linear,
const udword  box_id,
udword current_id,
const AABBTreeNode current_node 
)
related

Builds a "no-leaf" tree from a standard one. This is a tree whose leaf nodes have been removed.

Layout for no-leaf trees:

Node:

  • box
  • P pointer => a node (LSB=0) or a primitive (LSB=1)
  • N pointer => a node (LSB=0) or a primitive (LSB=1)
Parameters
linear[in] base address of destination nodes
box_id[in] index of destination node
current_id[in] current running index
current_node[in] current node from input tree

Definition at line 152 of file OPC_OptimizedTree.cpp.

153 {
154  const AABBTreeNode* P = current_node->GetPos();
155  const AABBTreeNode* N = current_node->GetNeg();
156  // Leaf nodes here?!
157  OPASSERT(P);
158  OPASSERT(N);
159  // Internal node => keep the box
160  current_node->GetAABB()->GetCenter(linear[box_id].mAABB.mCenter);
161  current_node->GetAABB()->GetExtents(linear[box_id].mAABB.mExtents);
162 
163  if(P->IsLeaf())
164  {
165  // The input tree must be complete => i.e. one primitive/leaf
166  OPASSERT(P->GetNbPrimitives()==1);
167  // Get the primitive index from the input tree
168  udword PrimitiveIndex = P->GetPrimitives()[0];
169  // Setup prev box data as the primitive index, marked as leaf
170  linear[box_id].mPosData = (PrimitiveIndex<<1)|1;
171  }
172  else
173  {
174  // Get a new id for positive child
175  udword PosID = current_id++;
176  // Setup box data
177  linear[box_id].mPosData = (uintptr_t)&linear[PosID];
178  // Make sure it's not marked as leaf
179  OPASSERT(!(linear[box_id].mPosData&1));
180  // Recurse
181  _BuildNoLeafTree(linear, PosID, current_id, P);
182  }
183 
184  if(N->IsLeaf())
185  {
186  // The input tree must be complete => i.e. one primitive/leaf
187  OPASSERT(N->GetNbPrimitives()==1);
188  // Get the primitive index from the input tree
189  udword PrimitiveIndex = N->GetPrimitives()[0];
190  // Setup prev box data as the primitive index, marked as leaf
191  linear[box_id].mNegData = (PrimitiveIndex<<1)|1;
192  }
193  else
194  {
195  // Get a new id for negative child
196  udword NegID = current_id++;
197  // Setup box data
198  linear[box_id].mNegData = (uintptr_t)&linear[NegID];
199  // Make sure it's not marked as leaf
200  OPASSERT(!(linear[box_id].mNegData&1));
201  // Recurse
202  _BuildNoLeafTree(linear, NegID, current_id, N);
203  }
204 }

The documentation for this class was generated from the following files: