Collision with multiple objects

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
Tekkai
Posts: 24
Joined: Tue Mar 30, 2010 2:02 pm
Contact:

Collision with multiple objects

Post by Tekkai »

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
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Collision with multiple objects

Post by hendu »

Do not use irr's collision for huge amounts of objects like that. Use a physics engine like bullet. It simply scales much better.
Tekkai
Posts: 24
Joined: Tue Mar 30, 2010 2:02 pm
Contact:

Re: Collision with multiple objects

Post by Tekkai »

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?
CuteAlien
Admin
Posts: 9682
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Collision with multiple objects

Post by CuteAlien »

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).
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
Rusk
Posts: 7
Joined: Fri Feb 03, 2012 1:51 am

Re: Collision with multiple objects

Post by Rusk »

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.
Post Reply