THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/07/2011 at 13:57, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Windows ;
Language(s) : C++ ;
---------
Hi,
i have a problem with te Collider Engine.
I want to fill the Collider Cache with all Objects in the Scene,
to make a hiddenline Test.
So all is ok with my function, but if there is a Null-Objekct in the Scene, than
my memory usage increases rapidly so that the plugin finaly crashes the computer
if I don't stop. I think the problem is in FillColliderCache which i have mostly taken from the SDK help.
I don't know why this happens and how to work around this.
Maybe you have an Idea ?
Thanks,:slightly_smiling_face:
Mackel
For the hiddenlineTest I use this:
while(opc){
GePrint(opc->GetName());
if(!FillColliderCache(cCache, opc)) GePrint("Fail Cache");
else{
GePrint(opc->GetName());
for(int i = 0; i <= 100; i++){
if(opc->GetType() != Onull) //make shure it is not my code in here that causes the problem
{
//Do some stuff
if(cEngine->DoRayCollide(cCache,wtail, !oray,op != opc ? ldist : (ldist-0.1)) != COL_OK)
GePrint("Error");
else if(cEngine->GetNumPairs() > 0){
count ++;
GePrint(opc->GetName() + "Collision begin" + LongToString(cEngine->GetNumPairs()));
collisions _= true;
}
else if(cEngine->GetNumPairs()== 0){
count ++;
}
}
}
}
if(opc->GetDown()){
level++;
opc = opc->GetDown();
}else if(opc->GetNext()){
opc = opc->GetNext();
}else if( level > 0){
opc = opc->GetUp()->GetNext();
level--;
}else{
opc = opc->GetNext();
}
}
Filling the ColliderChace I using this:
Bool FillColliderCache(GeColliderCache* c, BaseObject* obj)
{
// Get polygon object
ModelingCommandData md1;
md1.op = obj; md1.doc = obj->GetDocument();
if (!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, md1)) return FALSE;
// Triangulate it
ModelingCommandData md2;
md2.op = static_cast<BaseObject*>(md1.result->GetIndex(0));
if (!SendModelingCommand(MCOMMAND_TRIANGULATE, md2)) return FALSE;
AutoAlloc<PolygonObject> poly(static_cast<PolygonObject*>(md2.op)); if (!poly) return FALSE;
// Get the polygon data
const CPolygon* tris = poly->GetPolygonR();
const Vector* points = poly->GetPointR();
//GeColliderCache* c = GeColliderCache::Alloc();
// Fill the cache
if (c->BeginInput(poly->GetPolygonCount()) != COL_OK) return FALSE;
for (int i = 0; i < poly->GetPolygonCount(); ++i)
{
if (c->AddTriangle(obj->GetMg() * points[tris _.a], obj- >GetMg() * points[tris _.b], obj- >GetMg() * points[tris _.c], i) != COL_OK) return FALSE;
}
if (c->EndInput() != COL_OK) return FALSE;
//bool succ = c->CopyTo(dest);
poly.Free();
//GeColliderCache::Free(c);
return true;//succ;
}