btConvexHullShape reutilization
-
- Posts: 8
- Joined: Thu May 03, 2012 10:56 pm
btConvexHullShape reutilization
Hi all, i'm currently integrating bullet on my game engine for android and i would like to know if anyone can tell me how can i reuse a btConvexHullShape on multiple rigid bodies? I'm currently trying to implement "gibs" and have already solved most collision problems, but if i reuse a convex hull on a different rigid body the previous body dissapears in place of the new one. I create each subsequent new rigid body with the "localCreateRigidBody" found on the samples, i'm doing something wrong?
-
- Posts: 57
- Joined: Tue Mar 16, 2010 1:42 am
Re: btConvexHullShape reutilization
As long as the local scaling and margin of the convex hull shape remains the same, I see no reason why it shouldn't work.
-
- Posts: 8
- Joined: Thu May 03, 2012 10:56 pm
Re: btConvexHullShape reutilization
That's weird. I will post some code this monday when i'm back to the office to show you exactly what i'm doing. I'm trying to understand Bullet and C++ in one step so maybe i'm doing something stupid and don't realize it.
-
- Posts: 8
- Joined: Thu May 03, 2012 10:56 pm
Re: btConvexHullShape reutilization
Check the code if you can:
http://pae.st/c2L2/
The first two class functions are for creating the convex shape (very suboptimal) and the last two functions are for the JNI Interface with the java side in Android.
As you can see, my engine"revolves around one Bullet instance globally visible to the C++ code, and has some functions for the java side to call and interact with Bullet.
The problem is that when i insert a dynamic rigid body with the previously constructed convex hull, the previous rigid body gets overwritten somehow and it disapears.
http://pae.st/c2L2/
The first two class functions are for creating the convex shape (very suboptimal) and the last two functions are for the JNI Interface with the java side in Android.
Code: Select all
// Class functions
BulletEngine::crearShapeConvexoTriMesh
BulletEngine::insertarDynamicDesdeShape
// JNI Calls
Java_com_contimita_utils_BulletNdk_crearShapeConvexoTriMesh
Java_com_contimita_utils_BulletNdk_insertarDynamicConShape
The problem is that when i insert a dynamic rigid body with the previously constructed convex hull, the previous rigid body gets overwritten somehow and it disapears.
-
- Posts: 8
- Joined: Thu May 03, 2012 10:56 pm
-
- Posts: 135
- Joined: Fri Nov 04, 2005 2:22 pm
Re: btConvexHullShape reutilization
I, for example, for each models, including gibs, create a new btConvexHullShape.
until the gibs have a life (including collisions), then free the resources.
here the demo
you tried to do it this way? (sorry 4 engrish)
until the gibs have a life (including collisions), then free the resources.
here the demo
you tried to do it this way? (sorry 4 engrish)
-
- Posts: 8
- Joined: Thu May 03, 2012 10:56 pm
Re: btConvexHullShape reutilization
I'm aiming at something like that. But the problem is that with each new instance of a RigidBody that uses the shape the previous rigid body ceases to exist (or render in the same place, as far as i've seen)
-
- Posts: 8
- Joined: Thu May 03, 2012 10:56 pm
Re: btConvexHullShape reutilization
Btw, here's how i obtain the transformation matrix for my geometry in the render pipeline.
http://pae.st/hBj8/
Is that the right way?
http://pae.st/hBj8/
Is that the right way?
-
- Posts: 135
- Joined: Fri Nov 04, 2005 2:22 pm
Re: btConvexHullShape reutilization
I also use opengl, so here's the code ... does not seem different...
and this is the definition of the matrix:
typedef float mat4_t[16];
Code: Select all
inline void C_Math::Matrix4_Copy (const mat4_t in, mat4_t out)
{
out[ 0] = in[ 0];
out[ 1] = in[ 1];
out[ 2] = in[ 2];
out[ 3] = in[ 3];
out[ 4] = in[ 4];
out[ 5] = in[ 5];
out[ 6] = in[ 6];
out[ 7] = in[ 7];
out[ 8] = in[ 8];
out[ 9] = in[ 9];
out[10] = in[10];
out[11] = in[11];
out[12] = in[12];
out[13] = in[13];
out[14] = in[14];
out[15] = in[15];
}
typedef float mat4_t[16];
-
- Posts: 8
- Joined: Thu May 03, 2012 10:56 pm
Re: btConvexHullShape reutilization
Was just reading your previous post, and i'm trying to use only ONE convex hull for type of gib, that means i'm reutilizing one ConvexHull with different rigid bodies.
Maybe that isn't possible
Maybe that isn't possible
-
- Posts: 135
- Joined: Fri Nov 04, 2005 2:22 pm
Re: btConvexHullShape reutilization
mhmmm...
I do:
if the model is already listed, then resume it.
So I have the old btConvexHullShape.
otherwise create a new stuff for the new model.
I am sorry being unable to express, english is not my language ...
I have trouble with google ... sorry
I do:
if the model is already listed, then resume it.
So I have the old btConvexHullShape.
otherwise create a new stuff for the new model.
I am sorry being unable to express, english is not my language ...
I have trouble with google ... sorry
-
- Posts: 57
- Joined: Tue Mar 16, 2010 1:42 am
Re: btConvexHullShape reutilization
Maybe you have a mixup between an object index and a collision shape pointer?
I see that for obtenerMatrizRigidBody() you use sim as an index into the object array, while in Java_com_contimita_utils_BulletNdk_insertarDynamicConShape() sim is a collision shape pointer.
If the objects are actually appearing at the same place, instead of disappearing, that would suggest a problem with the motion state. The motion state has nothing to do with the collision shape.
---JvdL---
I see that for obtenerMatrizRigidBody() you use sim as an index into the object array, while in Java_com_contimita_utils_BulletNdk_insertarDynamicConShape() sim is a collision shape pointer.
If the objects are actually appearing at the same place, instead of disappearing, that would suggest a problem with the motion state. The motion state has nothing to do with the collision shape.
---JvdL---
-
- Posts: 8
- Joined: Thu May 03, 2012 10:56 pm
Re: btConvexHullShape reutilization
Thanks all... it was just an stupid bug on my part
This library rocks!
This library rocks!
-
- Posts: 135
- Joined: Fri Nov 04, 2005 2:22 pm
Re: btConvexHullShape reutilization
Goood!johnvillar wrote:Thanks all... it was just an stupid bug on my part
This library rocks!
Yeah! Bullet is a....Bomb!