← Back to team overview

yade-dev team mailing list archive

Re: acces to sphere/wall information

 

> I usually use classIndexes, but it needs a bit more than one line. Do we 
> have a simpler way now (checking class names takes too much time)?
You should try 1. dynamic_cast and 2. class indices. I am not sure which
one will be the winner:

FOREACH(const shared_ptr<Body>& b, *scene->bodies){
	if(!b) continue; // deleted bodies

	// first possibility
	// (not tested, but I think static indices should work just fine)
	if(b->shape->getClassIndexStatic()==Sphere::getClassIndexStatic()){ /* ... */ }
	else if(b->shape->getClassIndexStatic()==Wall::getClassIndexState()) { /* ... */ }

	// second possibility
	if(dynamic_cast<Sphere>(b->shape->get())){ /* ... */ }
	else if(dynamic_cast<Wall>(b->shape->get())){ /* ... */ }
}

v





Follow ups

References