FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Unfrozen objects don't collide

3 posters

Go down

Unfrozen objects don't collide Empty Unfrozen objects don't collide

Post  matt Tue Nov 11, 2008 4:26 pm

I guess this is more a Bullet question than a SIO2 question, but I'm trying anyway. I'm freezing objects with
Code:
object->_btRigidBody->setActivationState( DISABLE_SIMULATION );
and later unfreeze them again with
Code:
object->_btRigidBody->forceActivationState( ACTIVE_TAG );
object->_btRigidBody->setDeactivationTime( .0f );
Basically, this works pretty well. The only problem is that unfrozen objects don't collide anymore with anything.

Does anyone have an idea how to fix this?

Best,
Matt

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Unfrozen objects don't collide Empty Re: Unfrozen objects don't collide

Post  sw Tue Nov 11, 2008 9:39 pm

setActivationState(WANTS_DEACTIVATION )
setActivationState(DISABLE_DEACTIVATION) Basketball
sw
sw

Posts : 73
Join date : 2008-10-12

Back to top Go down

Unfrozen objects don't collide Empty Re: Unfrozen objects don't collide

Post  matt Wed Nov 12, 2008 2:26 pm

This doesn't really work. What I do is: I duplicate an object, freeze it, thaw it, freeze it again, thaw it again. It behaves correctly until I thaw it the second time, then no collision is detected. In your case, the object doesn't move at all after thawn for the first time.

Moreover, if I get it correctly, there's a slight difference in both ways. In my version, the objects don't take part in the physics simulation at all (what I want), in your case they would still response to collision (what I don't want), or am I on the wrong track here?

Best,
Matt

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Unfrozen objects don't collide Empty Re: Unfrozen objects don't collide

Post  jlperan Wed Nov 12, 2008 3:25 pm

Iīm having problems because of object duplication and I think thatīs also your problem.

Iīm looking at the duplication code and :

1. I donīt see any code with the btrigidbody part of the duplicated object.
2. The duplicated object is not added to the sio2 resource so if you try to "sio2resourceget" it, you donīt find it. Am I wrong? If I try to add it with sio2ResourceAdd I get problems sometimes in sio2 source code, sometimes in bullet code. Mad

Collision sometimes works for duplicated objects and sometimes not.

I think Iīm going to take a further look at the duplication code and see what I find.

But Iīm sure sio2interactive has a better solution, hasnīt you? Razz

jlperan

Posts : 41
Join date : 2008-10-10

Back to top Go down

Unfrozen objects don't collide Empty Re: Unfrozen objects don't collide

Post  matt Wed Nov 12, 2008 3:32 pm

jlperan wrote:1. I donīt see any code with the btrigidbody part of the duplicated object.
That's because you need to use sio2PhysicsAdd after you duplicated the object. But beware, you'll probably need to unmap VBOs and indices if you do that at run-time and use triangle meshes for collision because the buffers get free'd once sio2XXXGenId is called on it. (I wrote a method sio2VertexGroupMapBuffer/UnmapBuffer, it's here in the forums, search for it if you need it.)

jlperan wrote:2. The duplicated object is not added to the sio2 resource so if you try to "sio2resourceget" it, you donīt find it.
It is indeed, look into sio2ObjectInit which is called from sio2ObjectDuplicate. You're probably using the same name and the method always returns the first object it encounters with the matching name.

jlperan wrote:Collision sometimes works for duplicated objects and sometimes not.
This appears more a general physics engine precision problem to me than a SIO2 problem. Instead of calling sio2PhysicsRender I have written my own stepSimulation call with some tweaked parameters in order to improve the result.

Best,
Matt

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Unfrozen objects don't collide Empty Re: Unfrozen objects don't collide

Post  jlperan Thu Nov 13, 2008 2:55 am

That's because you need to use sio2PhysicsAdd after you duplicated the object.

I mean if you have changed some bullet physics value (as I do) itīs not duplicated on the new object.

But beware, you'll probably need to unmap VBOs and indices if you do that at run-time and use triangle meshes for collision because the buffers get free'd once sio2XXXGenId is called on it. (I wrote a method sio2VertexGroupMapBuffer/UnmapBuffer, it's here in the forums, search for it if you need it.)

ummm, Yep, I do it in runtime so Iīm going to search for sio2VertexGroupMapBuffer/UnmapBuffer. Thank you!

It is indeed, look into sio2ObjectInit which is called from sio2ObjectDuplicate. You're probably using the same name and the method always returns the first object it encounters with the matching name.

Youīre right. Itīs my fault for not looking further but the name is not the problem because I change it for each object. I think itīs in the mapping you talk about.

Additionally and sometimes, when I duplicate an object I donīt get just one, I get two in the same place colliding. Are you having this problem?

jlperan

Posts : 41
Join date : 2008-10-10

Back to top Go down

Unfrozen objects don't collide Empty Re: Unfrozen objects don't collide

Post  jlperan Mon Dec 01, 2008 3:13 pm

I'm having problems with the bundled collision detection. You're right, there's some precision problem.

How have you solved it? Have you used the code published here in the forum? Update bullet version? Pray god?

jlperan

Posts : 41
Join date : 2008-10-10

Back to top Go down

Unfrozen objects don't collide Empty Re: Unfrozen objects don't collide

Post  matt Tue Dec 02, 2008 12:44 pm

jlperan wrote:How have you solved it? Have you used the code published here in the forum? Update bullet version? Pray god?
I guess there are three points which are important:
1. Limit the initial number of FPS to a sensible amount, because the time-delta after loading etc. may be much higher than the normal framerate. sio2interactive shows how to do that in the tutorials.
2. The scale of the mesh. You'll get precision problems if Bullet has to deal with very small distances e.g. between two vertices. You're better off with numbers like 3 and 4 instead of 0.0000003 and 0.0000004 - you get the idea.
3. The physics loop. I included some own collision management stuff there so I wrote my own method which calls stepSimulation and passed a concrete number as the maxSubSteps parameter to the stepSimulation call. In my particular case, 5 worked pretty well. There's a decent explanation of the three parameters in the Bullet wiki.

Best,
Matt

matt

Posts : 155
Join date : 2008-09-30

http://elfrun.net

Back to top Go down

Unfrozen objects don't collide Empty Re: Unfrozen objects don't collide

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum