crash if to many selectors for collision-detection?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Edwart
Posts: 46
Joined: Fri Dec 30, 2005 12:29 pm

crash if to many selectors for collision-detection?

Post by Edwart »

hello,

i am using this code for collision-detection.
i am creating the maps in irredit.
every object which should have a collision-detection is added as octree.

now i saw, when i add one object more in the map, the game crashes when this map is loaded. with one object less it works.
with 13 octree object it works - with 14 not.
Or is there any poly limit?


any ideas?

Code: Select all

void recursiveFillMetaSelector(scene::ISceneNode* node, scene::IMetaTriangleSelector* meta );
scene::ISceneNodeAnimatorCollisionResponse* anim;

void lvl_collision() {
     
     metaSelector = smgr->createMetaTriangleSelector();
   recursiveFillMetaSelector( smgr->getRootSceneNode(), metaSelector );
   // DEfine the collision reponse for the FPS Camera
   anim = smgr->createCollisionResponseAnimator(   metaSelector, camera, core::vector3df(1,0.1,1),
      core::vector3df(0,0,0),
      core::vector3df(0,20,0));
   camera->addAnimator(anim);
   anim->drop();
    metaSelector->drop(); 
    
}



void recursiveFillMetaSelector(scene::ISceneNode* node, scene::IMetaTriangleSelector* meta )
{
     
    
     
  //
  // the following if is basically the same as ISceneNode_assignTriangleSelector
  //
  printf ("Node name is: %s \n",node->getName());
  printf ("Node id is: %d \n",node->getID());
  printf ("Node type:");
  //  printf ("Node type: %s=",smgr->getSceneNodeTypeName());
  if (node->getType() ==   ESNT_UNKNOWN) printf("Unknown mesh type \n\n");
  if (node->getType() ==   ESNT_MESH) printf("Standard Mesh \n\n");
  if (node->getType() ==   ESNT_ANIMATED_MESH) printf("Animated Mesh! \n\n");
  if (node->getType() ==   ESNT_SKY_BOX) printf("SkyBox! \n\n");
  if (node->getType() ==   ESNT_CAMERA_FPS) printf("Fps Camera! \n\n");
  if (node->getType() ==   ESNT_CAMERA_MAYA ) printf("Maya Camera! \n\n");
  if (node->getType() ==   ESNT_CAMERA )
  { printf("STD Camera! \n");
   printf ("The current position of this camera is: %f,%f,%f\n\n",node->getPosition().X,node->getPosition().Y,node->getPosition().Z);
   camera->setPosition(node->getPosition());
  }
  if (node->getType() ==   ESNT_PARTICLE_SYSTEM ) printf("Particles! \n\n");
  if (node->getType() ==   ESNT_LIGHT  ) printf("Light! \n\n");
  if (node->getType() ==   ESNT_OCT_TREE)
  {
      // Occ Trees are for land
      printf("Occtree! \n");
      io::IAttributes* attribs = device->getFileSystem()->createEmptyAttributes();
      if (attribs)
        {// get the mesh name out
         node->serializeAttributes(attribs);
         core::stringc name = attribs->getAttributeAsString("Mesh");
         attribs->drop();
         // get the animated mesh for the object
         scene::IAnimatedMesh* mesh = smgr->getMesh(name.c_str());
         if (mesh)
         {
            scene::ITriangleSelector* selector =
            smgr->createOctTreeTriangleSelector(mesh->getMesh(0), node, 256);
            node->setTriangleSelector(selector);
            metaSelector->addTriangleSelector(selector);
            selector->drop();
         }

     }
     
  } 
  // now recurse on children...
  core::list<scene::ISceneNode*>::ConstIterator  begin = node->getChildren().begin();
  core::list<scene::ISceneNode*>::ConstIterator  end   = node->getChildren().end();

  for (; begin != end; ++begin)
    recursiveFillMetaSelector(*begin, meta);
}
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I took a quick glance at your code and it looks fine.

It would be easiest to resolve the problem if you could tell us where the program actually crashes (i.e. a stack trace). You should be able to get this information from the debugger. You are using a debugger, aren't you?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

It looks OK to me too. I like the method of getting the oct tree node's mesh, although it's unfortunate that it's necessary.

Any chance of a compilable project with resources?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply