Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Thu Jun 28, 2012 2:31 pm 
Offline

Joined: Thu Jun 28, 2012 2:21 pm
Posts: 12
Usually btMultiSphereShape's setLocalScaling appears to scale only the spheres on their own origin, this patch I created appears to fix the problem:

Code:
Index: src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp
===================================================================
--- src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp   (revision 2540)
+++ src/BulletCollision/CollisionShapes/btMultiSphereShape.cpp   (working copy)
@@ -73,7 +73,7 @@
         int inner_count = MIN( numSpheres - k, 128 );
         for( long i = 0; i < inner_count; i++ )
         {
-            temp[i] = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
+            temp[i] = (*pos)*m_localScaling +vec*m_localScaling*(*rad) - vec * getMargin();
             pos++;
             rad++;
         }
@@ -111,7 +111,7 @@
             int inner_count = MIN( numSpheres - k, 128 );
             for( long i = 0; i < inner_count; i++ )
             {
-                temp[i] = (*pos) +vec*m_localScaling*(*rad) - vec * getMargin();
+                temp[i] = (*pos)*m_localScaling +vec*m_localScaling*(*rad) - vec * getMargin();
                 pos++;
                 rad++;
             }


Should I put this on the issue tracker?


Top
 Profile  
 
PostPosted: Mon Apr 08, 2013 11:07 am 
Offline

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 316
Old topic, I know :oops:

But I'd like to know if this mod actually works, because there were some scaling issues when using a scaled btMultisphereShape with vertices != (0,0,0), since the positions were not scaled at all.

As far as I can understand (if the modification does not break some internal collision algorithm) the only shapes affected by this change should be btMultisphereShapes with:
-> a scaling applied and at least one vertex!=(0,0,0).

That probably means that all the Bullet demos shouldn't be affected by this change as far as I can remember.


Top
 Profile  
 
PostPosted: Mon Apr 08, 2013 12:23 pm 
Offline

Joined: Thu Jun 28, 2012 2:21 pm
Posts: 12
I have tested the code before and it did work, however sometimes there were issues when the shape scaled down due to caching of contact points (if something was on top of the shape and it scaled down, it would remain there "floating" until it moved or something), however clearing the cache for these shapes did help.


Top
 Profile  
 
PostPosted: Tue Apr 09, 2013 10:18 am 
Offline

Joined: Tue Dec 25, 2007 1:06 pm
Posts: 316
mdias wrote:
(if something was on top of the shape and it scaled down, it would remain there "floating" until it moved or something
Well, if this happens only when the btMultiSphereShaped body is (local) scaled at runtime, the problem can probably be solved by removing/readding the body from/to the world, so that the contact cache gets cleared (and I think this could happen with other shapes too: clearing the contact cache and re-activating the body can help).

I was just referring to the collision behavior of the body in general, and from your response it seems to be working.

I wonder why the original code does not allow scaling the positions... maybe they wanted to keep the bounding box as small as possible... but this is not consistent with the behavior of other shapes (btConvexHullShape). Or maybe just because in some particular cases scaling the radii without scaling the vertices can be useful to implement some kind of shape transformation... I don't know :cry:

Anyway thank you for your feedback: I hope your patch will be integrated into Bullet if there's nothing preventing it :)


Top
 Profile  
 
PostPosted: Tue Apr 09, 2013 11:52 am 
Offline

Joined: Thu Jun 28, 2012 2:21 pm
Posts: 12
No problem :)

And yes, collision in general worked fine in the tests I made.

The bug was already reported almost a year ago here:
http://code.google.com/p/bullet/issues/detail?id=636

It seems there is a need to support the old behaviour by having a flag before it's integrated on master.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: Exabot [Bot], Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group