From: <ole...@us...> - 2012-12-01 21:56:17
|
Revision: 1910 http://opende.svn.sourceforge.net/opende/?rev=1910&view=rev Author: oleh_derevenko Date: 2012-12-01 21:56:10 +0000 (Sat, 01 Dec 2012) Log Message: ----------- Fixed: Issues reported in patches #151 and #22 fixed (collisions with SAPSpace and QuadTreeSpace might not work because geometries list was misused in them) Modified Paths: -------------- trunk/CHANGELOG.txt trunk/ode/src/collision_kernel.cpp trunk/ode/src/collision_kernel.h trunk/ode/src/collision_quadtreespace.cpp trunk/ode/src/collision_sapspace.cpp Modified: trunk/CHANGELOG.txt =================================================================== --- trunk/CHANGELOG.txt 2012-12-01 21:49:07 UTC (rev 1909) +++ trunk/CHANGELOG.txt 2012-12-01 21:56:10 UTC (rev 1910) @@ -9,8 +9,11 @@ ------------------------------------------------------------------------------ 12/01/12 Oleh_Derevenko - * Applied patch #160 "IsPointInPolygon in convex.cpp returns wrong - results" (by Janis Rucis) + * Fixed issues reported in patches #151 and #22 (collisions with + SAPSpace and QuadTreeSpace might not work because geometries list + was misused in them). + * Applied patch #160 "IsPointInPolygon in convex.cpp returns wrong + results" (by Janis Rucis) 11/25/12 Oleh Derevenko * Configuration option --disable-threading-intf added Modified: trunk/ode/src/collision_kernel.cpp =================================================================== --- trunk/ode/src/collision_kernel.cpp 2012-12-01 21:49:07 UTC (rev 1909) +++ trunk/ode/src/collision_kernel.cpp 2012-12-01 21:56:10 UTC (rev 1910) @@ -361,6 +361,8 @@ // setup space vars next = 0; tome = 0; + next_ex = 0; + tome_ex = 0; parent_space = 0; dSetZero (aabb,6); category_bits = ~0; Modified: trunk/ode/src/collision_kernel.h =================================================================== --- trunk/ode/src/collision_kernel.h 2012-12-01 21:49:07 UTC (rev 1909) +++ trunk/ode/src/collision_kernel.h 2012-12-01 21:56:10 UTC (rev 1910) @@ -105,6 +105,8 @@ // information used by spaces dxGeom *next; // next geom in linked list of geoms dxGeom **tome; // linked list backpointer + dxGeom *next_ex; // next geom in extra linked list of geoms (for higher level structures) + dxGeom **tome_ex; // extra linked list backpointer (for higher level structures) dxSpace *parent_space;// the space this geom is contained in, 0 if none dReal aabb[6]; // cached AABB for this space unsigned long category_bits,collide_bits; Modified: trunk/ode/src/collision_quadtreespace.cpp =================================================================== --- trunk/ode/src/collision_quadtreespace.cpp 2012-12-01 21:49:07 UTC (rev 1909) +++ trunk/ode/src/collision_quadtreespace.cpp 2012-12-01 21:56:10 UTC (rev 1910) @@ -182,9 +182,9 @@ dxGeom* g = mFirst; while (g){ if (GEOM_ENABLED(g)){ - Collide(g, g->next, UserData, Callback); + Collide(g, g->next_ex, UserData, Callback); } - g = g->next; + g = g->next_ex; } // Recurse for children @@ -209,7 +209,7 @@ if (GEOM_ENABLED(g2)){ collideAABBs (g1, g2, UserData, Callback); } - g2 = g2->next; + g2 = g2->next_ex; } // Collide against children @@ -244,15 +244,15 @@ if (GEOM_ENABLED(g1)){ collideAABBs (g1, g2, UserData, Callback); } - g1 = g1->next; + g1 = g1->next_ex; } } void Block::AddObject(dGeomID Object){ // Add the geom - Object->next = mFirst; + Object->next_ex = mFirst; mFirst = Object; - Object->tome = (dxGeom**)this; + Object->tome_ex = (dxGeom**)this; // Now traverse upwards to tell that we have a geom Block* Block = this; @@ -270,17 +270,17 @@ while (g){ if (g == Object){ if (Last){ - Last->next = g->next; + Last->next_ex = g->next_ex; } - else mFirst = g->next; + else mFirst = g->next_ex; break; } Last = g; - g = g->next; + g = g->next_ex; } - Object->tome = 0; + Object->tome_ex = 0; // Now traverse upwards to tell that we have lost a geom Block* Block = this; @@ -424,7 +424,7 @@ CHILDRECURSE: if (CurrentObject){ dGeomID g = CurrentObject; - CurrentObject = CurrentObject->next; + CurrentObject = CurrentObject->next_ex; CurrentIndex++; #ifdef DRAWBLOCKS @@ -471,7 +471,7 @@ if (current_geom && current_index == Index - 1){ - //current_geom = current_geom->next; // next + //current_geom = current_geom->next_ex; // next current_index = Index; return current_geom; } @@ -486,20 +486,12 @@ void dxQuadTreeSpace::add(dxGeom* g){ CHECK_NOT_LOCKED (this); dAASSERT(g); - dUASSERT(g->parent_space == 0 && g->next == 0, "geom is already in a space"); + dUASSERT(g->tome_ex == 0 && g->next_ex == 0, "geom is already in a space"); - g->gflags |= GEOM_DIRTY | GEOM_AABB_BAD; DirtyList.push(g); - - // add - g->parent_space = this; Blocks[0].GetBlock(g->aabb)->AddObject(g); // Add to best block - count++; - // enumerator has been invalidated - current_geom = 0; - - dGeomMoved(this); + dxSpace::add(g); } void dxQuadTreeSpace::remove(dxGeom* g){ @@ -508,8 +500,7 @@ dUASSERT(g->parent_space == this,"object is not in this space"); // remove - ((Block*)g->tome)->DelObject(g); - count--; + ((Block*)g->tome_ex)->DelObject(g); for (int i = 0; i < DirtyList.size(); i++){ if (DirtyList[i] == g){ @@ -519,17 +510,7 @@ } } - // safeguard - g->next = 0; - g->tome = 0; - g->parent_space = 0; - - // enumerator has been invalidated - current_geom = 0; - - // the bounding box of this space (and that of all the parents) may have - // changed as a consequence of the removal. - dGeomMoved(this); + dxSpace::remove(g); } void dxQuadTreeSpace::dirty(dxGeom* g){ @@ -552,7 +533,7 @@ g->recomputeAABB(); g->gflags &= (~(GEOM_DIRTY|GEOM_AABB_BAD)); - ((Block*)g->tome)->Traverse(g); + ((Block*)g->tome_ex)->Traverse(g); } DirtyList.setSize(0); @@ -592,7 +573,7 @@ if (g2->parent_space == this){ // The block the geom is in - Block* CurrentBlock = (Block*)g2->tome; + Block* CurrentBlock = (Block*)g2->tome_ex; // Collide against block and its children DataCallback dc = {UserData, Callback}; Modified: trunk/ode/src/collision_sapspace.cpp =================================================================== --- trunk/ode/src/collision_sapspace.cpp 2012-12-01 21:49:07 UTC (rev 1909) +++ trunk/ode/src/collision_sapspace.cpp 2012-12-01 21:56:10 UTC (rev 1910) @@ -219,11 +219,11 @@ #define GEOM_ENABLED(g) (((g)->gflags & GEOM_ENABLE_TEST_MASK) == GEOM_ENABLE_TEST_VALUE) -// HACK: We abuse 'next' and 'tome' members of dxGeom to store indice into dirty/geom lists. -#define GEOM_SET_DIRTY_IDX(g,idx) { (g)->next = (dxGeom*)(size_t)(idx); } -#define GEOM_SET_GEOM_IDX(g,idx) { (g)->tome = (dxGeom**)(size_t)(idx); } -#define GEOM_GET_DIRTY_IDX(g) ((int)(size_t)(g)->next) -#define GEOM_GET_GEOM_IDX(g) ((int)(size_t)(g)->tome) +// HACK: We abuse 'next' and 'tome' members of dxGeom to store indices into dirty/geom lists. +#define GEOM_SET_DIRTY_IDX(g,idx) { (g)->next_ex = (dxGeom*)(size_t)(idx); } +#define GEOM_SET_GEOM_IDX(g,idx) { (g)->tome_ex = (dxGeom**)(size_t)(idx); } +#define GEOM_GET_DIRTY_IDX(g) ((int)(size_t)(g)->next_ex) +#define GEOM_GET_GEOM_IDX(g) ((int)(size_t)(g)->tome_ex) #define GEOM_INVALID_IDX (-1) @@ -304,19 +304,15 @@ { CHECK_NOT_LOCKED (this); dAASSERT(g); - dUASSERT(g->parent_space == 0 && g->next == 0, "geom is already in a space"); + dUASSERT(g->tome_ex == 0 && g->next_ex == 0, "geom is already in a space"); - g->gflags |= GEOM_DIRTY | GEOM_AABB_BAD; // add to dirty list GEOM_SET_DIRTY_IDX( g, DirtyList.size() ); GEOM_SET_GEOM_IDX( g, GEOM_INVALID_IDX ); DirtyList.push( g ); - g->parent_space = this; - this->count++; - - dGeomMoved(this); + dxSpace::add(g); } void dxSAPSpace::remove( dxGeom* g ) @@ -350,14 +346,8 @@ GEOM_SET_GEOM_IDX(g,GEOM_INVALID_IDX); GeomList.setSize( geomSize-1 ); } - count--; - // safeguard - g->parent_space = 0; - - // the bounding box of this space (and that of all the parents) may have - // changed as a consequence of the removal. - dGeomMoved(this); + dxSpace::remove(g); } void dxSAPSpace::dirty( dxGeom* g ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |