40 GUINT numIndices = endIndex - startIndex;
42 for (i = startIndex; i < endIndex; i++)
45 primitive_boxes[i].m_bound.m_min);
50 for (i = startIndex; i < endIndex; i++)
53 primitive_boxes[i].m_bound.m_min);
55 diff2 = diff2 * diff2;
68 GUINT splitIndex = startIndex;
69 GUINT numIndices = endIndex - startIndex;
73 for (i = startIndex; i < endIndex; i++)
75 splitValue += 0.5f * (primitive_boxes[i].m_bound.m_max[splitAxis] +
76 primitive_boxes[i].m_bound.m_min[splitAxis]);
81 for (i = startIndex; i < endIndex; i++)
83 btScalar center = 0.5f * (primitive_boxes[i].m_bound.m_max[splitAxis] +
84 primitive_boxes[i].m_bound.m_min[splitAxis]);
85 if (center > splitValue)
88 primitive_boxes.
swap(i, splitIndex);
102 GUINT rangeBalancedIndices = numIndices / 3;
103 bool unbalanced = ((splitIndex <= (startIndex + rangeBalancedIndices)) || (splitIndex >= (endIndex - 1 - rangeBalancedIndices)));
107 splitIndex = startIndex + (numIndices >> 1);
110 btAssert(!((splitIndex == startIndex) || (splitIndex == (endIndex))));
119 btAssert((endIndex - startIndex) > 0);
121 if ((endIndex - startIndex) == 1)
127 m_node_array[current_index].m_bound = primitive_boxes[startIndex].m_bound;
138 for (splitIndex = startIndex; splitIndex < endIndex; splitIndex++)
140 m_node_array[current_index].m_bound.merge(primitive_boxes[splitIndex].m_bound);
149 primitive_boxes, startIndex, endIndex, splitIndex);
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
GUINT _calc_splitting_axis(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex)
gim_array< GIM_BOX_TREE_NODE > m_node_array
GUINT _sort_and_calc_splitting_index(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex, GUINT splitAxis)
void _build_sub_tree(gim_array< GIM_AABB_DATA > &primitive_boxes, GUINT startIndex, GUINT endIndex)
void build_tree(gim_array< GIM_AABB_DATA > &primitive_boxes)
prototype functions for box tree management
btVector3 can be used to represent 3D points and vectors.
int maxAxis() const
Return the axis with the largest value Note return values are 0,1,2 for x, y, or z.
Very simple array container with fast access and simd memory.
void swap(GUINT i, GUINT j)
void resize(GUINT size, bool call_constructor=true, const T &fillData=T())