So I've implemented some collision code into my game but my FPS drops a fair bit and I'm guessing it's the way I've implemented it. I'm currently doing it the same way the terrain tutorial does the terrain itself, for each individual object (e.g. 4 different fences). So at the moment I'm duplicating the same code which I'm guessing is the problem. At the moment I'm doing it like this...
Code: Select all
scene::ITriangleSelector* FenceCollisionNorth = 0;
scene::ITriangleSelector* FenceCollisionWest = 0;
scene::ITriangleSelector* FenceCollisionEast = 0;
scene::ITriangleSelector* FenceCollisionSouth = 0;
Code: Select all
//Collision detection for FENCE's
FenceCollisionNorth = smgr->createOctreeTriangleSelector(metalFenceNodeNorth->getMesh(), metalFenceNodeNorth, 20);
metalFenceNodeNorth->setTriangleSelector(FenceCollisionNorth);
FenceCollisionEast = smgr->createOctreeTriangleSelector(metalFenceNodeEast->getMesh(), metalFenceNodeEast, 20);
metalFenceNodeEast->setTriangleSelector(FenceCollisionEast);
FenceCollisionWest = smgr->createOctreeTriangleSelector(metalFenceNodeWest->getMesh(), metalFenceNodeWest, 20);
metalFenceNodeWest->setTriangleSelector(FenceCollisionWest);
FenceCollisionSouth = smgr->createOctreeTriangleSelector(metalFenceNodeSouth->getMesh(), metalFenceNodeSouth, 20);
metalFenceNodeSouth->setTriangleSelector(FenceCollisionSouth);
Code: Select all
//Create collision on camera for Fence's...
scene::ISceneNodeAnimator* coll1 = smgr->createCollisionResponseAnimator(FenceCollisionNorth, fps_camera, core::vector3df(80,50,40),
core::vector3df(0,0,0),
core::vector3df(0,0,0));
FenceCollisionNorth->drop();
fps_camera->addAnimator(coll1);
coll1->drop();
Thanks in advance guys