Hi all,
I'm having some problems to set up collision with a lot of objects, it works but it's slow down my application more than 300frames. My situation is that I'm creating the scenario according to a xml custom file, thanks to that anyone could create his own scenario. For example, I'm giving the user 3 types of pieces, and they can put as much as they want and in the order they prefer. I'm only loading 3 meshes but a lot of SceneNodes (in the particular case I'm working there are more than 200 SceneNodes). I resolved my problem of drawing a lot of triangles by putting a far to the camera and a fog, but I still have the probleme that my main character have to collide with all the elements of the scenario. I created a triangle selector for each node, and add it to a MetaTriangleSelector, which I'm using to create a CollisionResponseAnimator with my player. The problem, as I said in the begining is that is dropping down my frame rate, which is not desirable as you know.
I'm planning to add and remove dynamically each triangle selector according to the position of the character, but this is a lot of work(have to take into accound the size of every mesh, where is positioned...) and I wonder if I there is an easier method to do that.
Thank you in advance!!!
Cheers
Collision with multiple objects
Re: Collision with multiple objects
Do not use irr's collision for huge amounts of objects like that. Use a physics engine like bullet. It simply scales much better.
Re: Collision with multiple objects
Hi Hendu,
Thanks for the answer. I think using a physics engine just to detect if two objects are touching themselves seems like killing a flea with a sledgehammer... but if there is no other solution I will go for that, seems easier than the solution I'm thinking Any other thought?
Thanks for the answer. I think using a physics engine just to detect if two objects are touching themselves seems like killing a flea with a sledgehammer... but if there is no other solution I will go for that, seems easier than the solution I'm thinking Any other thought?
Re: Collision with multiple objects
Slowing down by 300 frames doesn't mean much ... (measure speed in milliseconds not in frames).
One optimization you can use when you are working with static scenes is using an octree (also experiment with the octree defines in Irrlicht octree header - results differ vastly).
Also adding/removing selectors might be expensive. Maybe you can work with collisions-flags (the node-id).
One optimization you can use when you are working with static scenes is using an octree (also experiment with the octree defines in Irrlicht octree header - results differ vastly).
Also adding/removing selectors might be expensive. Maybe you can work with collisions-flags (the node-id).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: Collision with multiple objects
Depending on how exact you want the collision to be, maybe you could build an invisible pyramid from 4 triangles around your scenenode and use that pyramid for the triangleselector. It should speed things up, unless you are using very low poly graphics.
Otherwise, I'd recommend bullet as well. It's pretty simple to get started, and to get it working with irrlich, there is a bullet "motionstate" for Ogre3d on this page: http://bulletphysics.org/mediawiki-1.5. ... tionStates, I've used that for irrlicht and I think I only had to change one or two lines.
Otherwise, I'd recommend bullet as well. It's pretty simple to get started, and to get it working with irrlich, there is a bullet "motionstate" for Ogre3d on this page: http://bulletphysics.org/mediawiki-1.5. ... tionStates, I've used that for irrlicht and I think I only had to change one or two lines.