more on ubode

This commit is contained in:
UbitUmarov
2022-08-07 17:41:14 +01:00
parent ef2d075395
commit 920c6ddfdf
3 changed files with 12 additions and 17 deletions
@@ -122,10 +122,13 @@ public:
((T*)_data)[i] = item;
}
void remove (int i) {
if (i >= 0 && i < _size) { // passing this test guarantees size>0
int n = _size-1-i;
if (n>0) memmove (((T*)_data) + i, ((T*)_data) + i+1, n*sizeof(T));
void remove (int i)
{
if (i >= 0 && i < _size)
{ // passing this test guarantees size>0
int n = _size -1 - i;
if (n > 0)
memmove (((T*)_data) + i, ((T*)_data) + i + 1, n*sizeof(T));
_size--;
}
}
@@ -247,15 +247,7 @@ inline bool Block::Inside(const dReal* AABB)
Block* Block::GetBlock(const dReal* AABB)
{
if (Inside(AABB))
{
return GetBlockChild(AABB); // Child or this will have a good block
}
else if (mParent)
{
return mParent->GetBlock(AABB); // Parent has a good block
}
else return this; // We are at the root, so we have little choice
return Inside(AABB) ? GetBlockChild(AABB) : ( mParent ? mParent->GetBlock(AABB) : this );
}
Block* Block::GetBlockChild(const dReal* AABB)
@@ -259,7 +259,6 @@ dxSimpleSpace::dxSimpleSpace(dSpaceID _space) : dxSpace(_space)
type = dSimpleSpaceClass;
}
void dxSimpleSpace::cleanGeoms()
{
// compute the AABBs of all dirty geoms, and clear the dirty flags
@@ -847,8 +846,8 @@ void dSpaceCollide2(dxGeom *g1, dxGeom *g2, void *data, dNearCallback *callback)
dxSpace *s1, *s2;
// see if either geom is a space
if (IS_SPACE(g1)) s1 = (dxSpace*)g1; else s1 = 0;
if (IS_SPACE(g2)) s2 = (dxSpace*)g2; else s2 = 0;
s1 = (IS_SPACE(g1)) ? (dxSpace*)g1 : 0;
s2 = (IS_SPACE(g2)) ? (dxSpace*)g2 : 0;
if (s1 && s2)
{
@@ -919,7 +918,8 @@ void dSpaceCollide2(dxGeom *g1, dxGeom *g2, void *data, dNearCallback *callback)
// make sure they have valid AABBs
g1->recomputeAABB();
g2->recomputeAABB();
collideAABBs(g1, g2, data, callback);
if (testCollideAABBs(g1, g2))
callback(data, g1, g2);
}
}
}