[ODE] Problem with the colliders table initialisation order with user define geoms.

slipch slipch <slipch at gsc-game.kiev.ua>
Wed Jun 18 00:52:01 2003


Hello Sébastien,

Tuesday, June 17, 2003, 9:57:28 PM, you wrote:

SD> I encountered a problem with the colliders table initialisation combine with a user define geom.

SD> This table is declared in collision_kernel.cpp and used as a cache of collide function pointers.These function pointers are resolved using a selector function (typedef dColliderFn *
SD> dGetColliderFnFn (int num);) and then cached in the table for future use.

SD> Anyway, this table is initialised (all entry set to NULL) when the first geom is created by calling the function initColliders() in the dxGeom constructor.

SD> The problem comes if a user define type (geom) is defined. The dCreateGeomClass(const dGeomClass *c) must be called to add pointers on the dCollideUserGeomWithGeom function (this function may
SD> later be called to call the selector functions) in the table. At this point, the table might not have been initialised.

SD> The problem is that before creating an instance of a geom, its class must be created. When the first geom instance is created all changes to the table will be wipeout because the table is
SD> initialised.

SD> The problem is encountered only when the first geom to be created is a user defined one, because the method initColliders() (of course) init the table with known types.  

SD> Anyway, I propose to add a call to initColliders() in the dCreateGeomClass function:



SD> int dCreateGeomClass (const dGeomClass *c)
SD> {
SD>   dUASSERT(c && c->bytes >= 0 && c->collider && c->aabb,"bad geom class");

SD>   if (num_user_classes >= dMaxUserClasses) {
SD>     dDebug (0,"too many user classes, you must increase the limit and "
SD>        "recompile ODE");
SD>   }
SD>   user_classes[num_user_classes] = *c;
SD>   int class_number = num_user_classes + dFirstUserClass;

SD>   // Make sure the collider table has been initialized.
SD>   initColliders();

SD>   setAllColliders (class_number,&dCollideUserGeomWithGeom);

SD>   num_user_classes++;
SD>   return class_number;
SD> }


If you call dHashSpaceCreate before creating your firs geom the
problem is solved because dHashSpaceCreate calls  initColliders() from
dxGeom constructor.

-- 
Best regards,
 slipch                            mailto:slipch@gsc-game.kiev.ua