void Gl1_PotentialParticle::go( const shared_ptr<Shape>& cm, const shared_ptr<State>& state ,bool wire2, const GLViewInfo&) { PotentialParticle* pp = static_cast<PotentialParticle*>(cm.get()); int shapeId = pp->id; if(store == false) { if(SF.size()>0) { SF.clear(); initialized = false; } } if(initialized == false ) { FOREACH(const shared_ptr<Body>& b, *scene->bodies) { if (!b) continue; PotentialParticle* cmbody = dynamic_cast<PotentialParticle*>(b->shape.get()); if (!cmbody) continue; calcMinMax(*cmbody); mc.init(sizeX,sizeY,sizeZ,min,max); mc.resizeScalarField(scalarField,sizeX,sizeY,sizeZ); SF.push_back(scalarF()); generateScalarField(*cmbody); mc.computeTriangulation(scalarField,0.0); SF[b->id].triangles = mc.getTriangles(); SF[b->id].normals = mc.getNormals(); SF[b->id].nbTriangles = mc.getNbTriangles(); for(unsigned int i=0; i<scalarField.size(); i++) { for(unsigned int j=0; j<scalarField[i].size(); j++) scalarField[i][j].clear(); scalarField[i].clear(); } scalarField.clear(); } initialized = true; }
void Gl1_PotentialBlock::go( const shared_ptr<Shape>& cm, const shared_ptr<State>& state ,bool wire2, const GLViewInfo&){ PotentialBlock* pp = static_cast<PotentialBlock*>(cm.get()); int shapeId = pp->id; if(store == false) { if(SF.size()>0) { SF.clear(); initialized = false; } } if(initialized == false ) { FOREACH(const shared_ptr<Body>& b, *scene->bodies) { if (!b) continue; PotentialBlock* cmbody = dynamic_cast<PotentialBlock*>(b->shape.get()); if (!cmbody) continue; Eigen::Matrix3d rotation = b->state->ori.toRotationMatrix(); //*pb->oriAabb.conjugate(); int count = 0; for (int i=0; i<3; i++){ for (int j=0; j<3; j++){ //function->rotationMatrix[count] = directionCos(j,i); rotationMatrix(i,j) = rotation(i,j); //input is actually direction cosine? count++; } } calcMinMax(*cmbody); mc.init(sizeX,sizeY,sizeZ,min,max); mc.resizeScalarField(scalarField,sizeX,sizeY,sizeZ); SF.push_back(scalarF()); generateScalarField(*cmbody); mc.computeTriangulation(scalarField,0.0); SF[cmbody->id].triangles = mc.getTriangles(); SF[cmbody->id].normals = mc.getNormals(); SF[cmbody->id].nbTriangles = mc.getNbTriangles(); for(unsigned int i=0; i<scalarField.size(); i++) { for(unsigned int j=0; j<scalarField[i].size(); j++) scalarField[i][j].clear(); scalarField[i].clear(); } scalarField.clear(); } initialized = true; }