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);
}