Small Dynamica and Serializer feature requests

Physics APIs, Physics file formats, Maya, Max, XSI, Cinema 4D, Lightwave, Blender, thinkingParticles™ and other simulation tools, exporters and importers
Post Reply
VicariousEnt
Posts: 50
Joined: Fri Oct 29, 2010 1:37 am

Small Dynamica and Serializer feature requests

Post by VicariousEnt »

Hellow Erwin. The new .bullet format and Dynamica plugin is exciting stuff. These requests will probably be in a future release soon anyways but if not they're something I will impliment myself.

1. Can we have a flag added to the RigidBody nodes in Maya\Max to indicate whether or not the btRigidBody class needs to be created by the serializer loadFile function at runtime for static geometry? I was thinking there is no point in creating btRigidBodies for geo that will always be static in a game and searching the forum I found a thread about this subject and apparently they can create alot of overhead and your reconmendation was to just create btCollisionObjects for such geo. I would delete the RigidBody nodes in Maya but the friction and restitution values are set in the RigidBody node and need to get to the CollisionObject structures somehow (not to mention this breaks things).

2. Can we also have a flag to automatically create the btOptimizedBvhs during the .bullet file generation instead of having them created during the load? Or just move the btOptimizedBvhs generation to the save code from the load code all together.

3. I'm sure they're coming, but support for the rest of the Bullet primitives in Dynamica would be awesome.

Thank you for your time, energy and your excellent physics engine!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Small Dynamica and Serializer feature requests

Post by Erwin Coumans »

VicariousEnt wrote:Hellow Erwin. The new .bullet format and Dynamica plugin is exciting stuff. These requests will probably be in a future release soon anyways but if not they're something I will impliment myself.

1. Can we have a flag added to the RigidBody nodes in Maya\Max to indicate whether or not the btRigidBody class needs to be created by the serializer loadFile function at runtime for static geometry? I was thinking there is no point in creating btRigidBodies for geo that will always be static in a game and searching the forum I found a thread about this subject and apparently they can create alot of overhead and your reconmendation was to just create btCollisionObjects for such geo. I would delete the RigidBody nodes in Maya but the friction and restitution values are set in the RigidBody node and need to get to the CollisionObject structures somehow (not to mention this breaks things).
You could modify the BulletWorldImporter to always create btCollisionObject instead of btRigidBody when the mass is 0. Would that help?
2. Can we also have a flag to automatically create the btOptimizedBvhs during the .bullet file generation instead of having them created during the load? Or just move the btOptimizedBvhs generation to the save code from the load code all together.

3. I'm sure they're coming, but support for the rest of the Bullet primitives in Dynamica would be awesome.
I'll check about this. Do you have particular Bullet primitives that you need more urgently?

Thanks,
Erwin
VicariousEnt
Posts: 50
Joined: Fri Oct 29, 2010 1:37 am

Re: Small Dynamica and Serializer feature requests

Post by VicariousEnt »

Erwin Coumans wrote:You could modify the BulletWorldImporter to always create btCollisionObject instead of btRigidBody when the mass is 0. Would that help?
I could yes, but isn't this a common problem that most people are going to face? Plus I am trying to avoid having to make modifications to Bullet as I would like to be able to make adopting future builds as smooth as possible. Perhaps it could be an optional parameter in the WorldImporter loadFile() function? Now that I think of it I can't think of any cases where I'd want to load a world with some 0 mass static objects with rigid bodies and others without.
Erwin Coumans wrote: I'll check about this. Do you have particular Bullet primitives that you need more urgently?

Thanks,
Erwin
Nothing super urgent, but I will probably need cylinders and capsules at some point. I would especially like to be able to create rag dolls for characters in Maya so the whole process is more data driven and its possible for artists to make unique rag dolls for different proportioned bodies. That would require the Cone Twist constraint as well (which appears in the mel scripts, but commented out). Anyways like I said I'm sure the full Bullet feature set will eventually make it into Dynamica, I'm just moving my pipeline in that direction to take advantage of it when it does.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Small Dynamica and Serializer feature requests

Post by Erwin Coumans »

VicariousEnt wrote: Perhaps it could be an optional parameter in the WorldImporter loadFile() function?
Yes, we can add a flag/setting to the btBulletWorldImporter, to create collision objects for objects with mass 0.
VicariousEnt wrote: Nothing super urgent, but I will probably need cylinders and capsules at some point.
OK, I filed an issue request here: http://code.google.com/p/dynamica/issues/detail?id=12

If you have other specific feature requests for Dynamica, please add them there (or if you are not sure discuss them here first)
Thanks,
Erwin
VicariousEnt
Posts: 50
Joined: Fri Oct 29, 2010 1:37 am

Re: Small Dynamica and Serializer feature requests

Post by VicariousEnt »

Awesome, thank you very much!
VicariousEnt
Posts: 50
Joined: Fri Oct 29, 2010 1:37 am

Re: Small Dynamica and Serializer feature requests

Post by VicariousEnt »

Erwin Coumans wrote:
VicariousEnt wrote: Perhaps it could be an optional parameter in the WorldImporter loadFile() function?
Yes, we can add a flag/setting to the btBulletWorldImporter, to create collision objects for objects with mass 0.
This will of course require the btCollisionObjects to be added to the DynamicWorld as well as the RigidBodies and Constraints that are right now. This brings up one other issue. The WorldImporter is automatically adding these object types to the DynamicWorld but it never removes them. btBulletWorldImporter::deleteAllData() should really remove the objects from the DynamicWorld that it added before it deletes them. This isn't an issue if you're already manually removing all objects from the DynamicsWorld before the WorldImporter is destroyed (and calling deleteAllData()), but it is if you want to be able to use multiple btBulletWorldImporters and be able to load and remove groups of collision without recreating the DynamicsWorld as I am. Plus it forces you to be very careful with the order in which you destroy the Importer and World.

I've altered the function myself to do this but I would imagine this change should be propagated into the next release. I did it like this (the blue is the new stuff)...

void btBulletWorldImporter::deleteAllData()
{
int i;
for (i=0;i<m_allocatedCollisionShapes.size();i++)
{
delete m_allocatedCollisionShapes;
}
m_allocatedCollisionShapes.clear();

if(m_dynamicsWorld)
{
for (i=0;i<m_allocatedRigidBodies.size();i++)
{
m_dynamicsWorld->removeRigidBody(btRigidBody::upcast(m_allocatedRigidBodies));

delete m_allocatedRigidBodies;
}
}
else
{
for (i=0;i<m_allocatedRigidBodies.size();i++)
{
delete m_allocatedRigidBodies;
}
} m_allocatedRigidBodies.clear();

if(m_dynamicsWorld)
{
for (i=0;i<m_allocatedConstraints.size();i++)
{
m_dynamicsWorld->removeConstraint(m_allocatedConstraints);

delete m_allocatedConstraints;
}
}
else
{
for (i=0;i<m_allocatedConstraints.size();i++)
{
delete m_allocatedConstraints;
}
} m_allocatedConstraints.clear();
.
.
. nothing else changed from here

I could add this to the Issue list if you like, assuming you agree that this is a problem.
VicariousEnt
Posts: 50
Joined: Fri Oct 29, 2010 1:37 am

Re: Small Dynamica and Serializer feature requests

Post by VicariousEnt »

Sorry to be a pest, but I wanted to discuss one more issue.

I ran into a crash in the btGimpactTriangleMeshShape code during debug rendering and collision tests. This issue has been raised in a couple threads already so I posted my fix to it in one of them...
http://bulletphysics.org/Bullet/phpBB3/ ... 843#p21843

Feel free to adopt it if you like. That fix has allowed me to continue developing my tech but I may have to move to the Collada exporter in the future to get my data in a game friendly state. In addition to the RigidBodies that are being created for static collision created in Dynamica, single Triangle meshes are being created as single btGimpactTriangleMeshShapes inside of btCompoundShapes. I see that Gimpacts share some code with bvhs but looking at the Bullet user manual it indicates that optimized btBvhTriangleMeshShapes are the ideal choice for static concave collision geo. Obviously speed is paramount in games. Would it be possible for Dynamica to have an option to or will switch to btBvhTriangleMeshShapes or better yet btOptimizedBvhs for static collision meshes?

I can wait for the next version of Bullet to come out, but if these changes aren't going to be in it I will have to make a build tool that processes Collada files, creates the ideal Bullet shapes for my uses and then serializes the data to .bullet for the game to load. No pressure here, I'm just thinking that this would be ideal for anyone using Bullet for developing games.
VicariousEnt
Posts: 50
Joined: Fri Oct 29, 2010 1:37 am

Re: Small Dynamica and Serializer feature requests

Post by VicariousEnt »

As requested I've added my fixes and requests to the google code Dynamica Project. I've included SVN Patches for the code changes.

The fix to make btBulletWorldImporter remove objects from its DynamicWorld before deleting them is here...
http://code.google.com/p/dynamica/issues/detail?id=16

The crash fix for btGimpactTriangleMeshShapes when loaded from btBulletWorldImporter is here...
http://code.google.com/p/dynamica/issues/detail?id=17

My game friendly feature requests are here...
http://code.google.com/p/dynamica/issues/detail?id=18
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Small Dynamica and Serializer feature requests

Post by Erwin Coumans »

Most of the patches/requests have been implemented now, in Dynamica and btBulletWorldImporter.

The only remaining thing is creation of btCollisionShape for static rigid bodies.

See also http://code.google.com/p/dynamica/source/detail?r=64
and http://code.google.com/p/bullet/source/detail?r=2336
http://code.google.com/p/bullet/source/detail?r=2333

Thanks for the feedback!
Erwin
VicariousEnt
Posts: 50
Joined: Fri Oct 29, 2010 1:37 am

Re: Small Dynamica and Serializer feature requests

Post by VicariousEnt »

Awesome!
Post Reply