42 GUINT numIndices = endIndex-startIndex;
44 for (i=startIndex;i<endIndex;i++)
47 primitive_boxes[i].m_bound.m_min);
52 for (i=startIndex;i<endIndex;i++)
55 primitive_boxes[i].m_bound.m_min);
57 diff2 = diff2 * diff2;
71 GUINT splitIndex =startIndex;
72 GUINT numIndices = endIndex - startIndex;
76 for (i=startIndex;i<endIndex;i++)
78 splitValue+= 0.5f*(primitive_boxes[i].m_bound.m_max[splitAxis] +
79 primitive_boxes[i].m_bound.m_min[splitAxis]);
84 for (i=startIndex;i<endIndex;i++)
86 btScalar center = 0.5f*(primitive_boxes[i].m_bound.m_max[splitAxis] +
87 primitive_boxes[i].m_bound.m_min[splitAxis]);
88 if (center > splitValue)
91 primitive_boxes.
swap(i,splitIndex);
105 GUINT rangeBalancedIndices = numIndices/3;
106 bool unbalanced = ((splitIndex<=(startIndex+rangeBalancedIndices)) || (splitIndex >=(endIndex-1-rangeBalancedIndices)));
110 splitIndex = startIndex+ (numIndices>>1);
113 btAssert(!((splitIndex==startIndex) || (splitIndex == (endIndex))));
125 if((endIndex-startIndex) == 1)
131 m_node_array[current_index].m_bound = primitive_boxes[startIndex].m_bound;
142 for (splitIndex=startIndex;splitIndex<endIndex;splitIndex++)
144 m_node_array[current_index].m_bound.merge(primitive_boxes[splitIndex].m_bound);
153 primitive_boxes,startIndex,endIndex,splitIndex);
void build_tree(gim_array< GIM_AABB_DATA > &primitive_boxes)
prototype functions for box tree management
void resize(GUINT size, bool call_constructor=true, const T &fillData=T())
Very simple array container with fast access and simd memory.
void swap(GUINT i, GUINT j)
btVector3 can be used to represent 3D points and vectors.
GUINT _sort_and_calc_splitting_index(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex, GUINT splitAxis)
GUINT _calc_splitting_axis(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex)
gim_array< GIM_BOX_TREE_NODE > m_node_array
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
void _build_sub_tree(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex)
int maxAxis() const
Return the axis with the largest value Note return values are 0,1,2 for x, y, or z.