Unfrozen objects don't collide
3 posters
Unfrozen objects don't collide
I guess this is more a Bullet question than a SIO2 question, but I'm trying anyway. I'm freezing objects with
Does anyone have an idea how to fix this?
Best,
Matt
- Code:
object->_btRigidBody->setActivationState( DISABLE_SIMULATION );
- Code:
object->_btRigidBody->forceActivationState( ACTIVE_TAG );
object->_btRigidBody->setDeactivationTime( .0f );
Does anyone have an idea how to fix this?
Best,
Matt
Re: Unfrozen objects don't collide
setActivationState(WANTS_DEACTIVATION )
setActivationState(DISABLE_DEACTIVATION)
setActivationState(DISABLE_DEACTIVATION)
sw- Posts : 73
Join date : 2008-10-12
Re: Unfrozen objects don't collide
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
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
Re: Unfrozen objects don't collide
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.
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?
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.
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?
jlperan- Posts : 41
Join date : 2008-10-10
Re: Unfrozen objects don't collide
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:1. I donīt see any code with the btrigidbody part of the duplicated object.
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:2. The duplicated object is not added to the sio2 resource so if you try to "sio2resourceget" it, you donīt find it.
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.jlperan wrote:Collision sometimes works for duplicated objects and sometimes not.
Best,
Matt
Re: Unfrozen objects don't collide
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
Re: Unfrozen objects don't collide
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?
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
Re: Unfrozen objects don't collide
I guess there are three points which are important:jlperan wrote:How have you solved it? Have you used the code published here in the forum? Update bullet version? Pray god?
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
Similar topics
» Objects failing to collide at high velocities, tunneling through floor etc.
» duplicating objects at runtime and changing textures on the duplicated objects
» Parenting Objects
» Objects pushing through
» Duplicating objects
» duplicating objects at runtime and changing textures on the duplicated objects
» Parenting Objects
» Objects pushing through
» Duplicating objects
Permissions in this forum:
You cannot reply to topics in this forum