Thread Previous • Date Previous • Date Next • Thread Next |
I->geom is now (r2517) replaced by a ScGeom6D instance in Ig2_Sphere_Sphere_ScGeom6D::go, using ScGeom::operator= :we were just reading the ScGeom6D code and there a serious bug. Suppose a potential interaction of 2 spheres; Ig2_Sphere_Sphere_ScGeom6D::go calls Ig2_Sphere_Sphere_ScGeom::go, which, if it succeeds, creates a new ScGeom object and assigns it to I->geom. Then the execution goes back to Ig2_Sphere_Sphere_ScGeom6D::go, which will cast I->geom to ScGeom6D!
if (isNew) {//generate a 6DOF interaction from the 3DOF one generated by Ig2_Sphere_Sphere_ScGeom
shared_ptr<ScGeom6D> sc (new ScGeom6D());*(YADE_PTR_CAST<ScGeom>(sc)) = *(YADE_PTR_CAST<ScGeom>(c->geom));
c->geom=sc;}It is at the price of two instanciations, but the cost is probably negligeable, and I see advantages in conversion. Namely, the same trick will apply for box-sphere6D, facet-sphere6D, cylinder-sphere6D, sphere-sphere9D,... in fact anything, without modifying the 3D code. I'm wondering if it couldn't be used to smoothly change the constitutive law during a simulation...
Too bad I couldn't use the default assignment operator due to references radius1 and radius2. I wish we could get rid of them. Wouldn't it be enough to name radii with the same name everywhere (either radius1 or refR1)? I was also wondering if there was nothing to be re-used from serialization, instead of equal operator (something feeding attributes with data from another object). Any suggestion?
Bruno
Thread Previous • Date Previous • Date Next • Thread Next |