Scaling A Compound Collision Body

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Sun Sep 08, 2013 8:36 am

what are you talking about? the engine does support non uniform scale on all shapes.
what I am saying that global non uniform scale on compound shape requires some extra calculations, that can penalize the rum time collision system.

I seriously doubt the users complaining about the physic because does not support global non uniform scale of compound collision, know what they are talking about either.
Most like it those people has no idea what there are talking about, and they are driven by different motivation.

I can assure you that packages like 3dxMax and Maya gets it wrong too, not one can get it right because it is not possible by applying the rules or orthonormal linear transformations.
the only reason it appear they can do is because they apply polar decomposition to scale matrices on each transformation and store the component separate on each mesh.
but that is not a linear processes, that you can applied for real time very efficient.

Code: Select all
I had to bypass Newton's scaling and implement my own technique since it is presently incomplete.

I do not know what this means. maybe you have a way to apply the arithmetic of algebra that I do not know.
as far as I know the concatenation of matrixes with no uniform scale yield to non orthonormal matrices, therefore all of the property of convexities, and invariantly are no longer valid.
stuff like affine transform, rotation, and support vertex are not longer valid, because the matrices not longer preserve that the operation are invariant under transformations.
therefore how are you doing, is anyone guess.

for example if you apply global scale to a matrix, you can no longed Invert the matrix by using the transpose, so you either keep the inverse, or calculate the invers on each frame.
the vectors no longer preserve size and directions, you need to normalize and, goes on and on.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Sun Sep 08, 2013 4:52 pm

Ha, I think I have the global non unioform scale on compound shape working.
and the good newton Is that is does not affect the performance of the nor scale collision even by one instructions

In fact with the change that I made early calculation of contact point is progressive.
tow uniform scale are faster than, uniform scale, faster than non uniform, faster that compound non uniform

but remarkably the cost of the most expensive is only 4 extra matrix multiply per supporting vertex, (which could be significant, but no prohibitive)
but now the engine support scaling on all shape with no exceptions

the core code is this

Code: Select all
   void SupportVertex (const dgVector& dir, dgInt32 vertexIndex)
   {
      dgAssert (dir.m_w == dgFloat32 (0.0f));
      dgAssert (dgAbsf (dir % dir - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f));

      dgVector p (m_myShape->ConvexConicSupporVertex(dir));
      dgAssert (p.m_w == dgFloat32 (0.0f));

      switch(m_scaleType)
      {
         case dgCollisionInstance::m_unit:
         {
            dgVector dir1 (m_matrix.UnrotateVector (dir.CompProduct4(dgVector::m_negOne)));
            dgAssert (dir1.m_w == dgFloat32 (0.0f));
            dgAssert (dgAbsf(dir1 % dir1 - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f));
            dgVector q (m_matrix.TransformVector (m_otherShape->SupportVertex (dir1, &m_polygonFaceIndex[vertexIndex])) & dgVector::m_triplexMask);
            dgAssert (q.m_w == dgFloat32 (0.0f));

            m_hullDiff[vertexIndex] = p - q;
            m_hullSum[vertexIndex] = p + q;
            break;
         }

         case dgCollisionInstance::m_uniform:
         {
            dgVector dir1 (m_matrix.UnrotateVector (dir.CompProduct4(dgVector::m_negOne)));
            dgAssert (dir1.m_w == dgFloat32 (0.0f));

            dgVector q (m_invScale.CompProduct4(m_matrix.TransformVector (m_scale.CompProduct4 (m_otherShape->SupportVertex (dir1, &m_polygonFaceIndex[vertexIndex])))));
            dgAssert (q.m_w == dgFloat32 (0.0f));

            m_hullDiff[vertexIndex] = p - q;
            m_hullSum[vertexIndex] = p + q;
            break;
         }

         case dgCollisionInstance::m_nonUniform:
         {
            dgVector dir1 (m_scale.CompProduct4(m_matrix.UnrotateVector (m_invScale.CompProduct4(dir.CompProduct4(dgVector::m_negOne)))));
            dgAssert (dir1.m_w == dgFloat32 (0.0f));

            dir1 = dir1.CompProduct4(dir1.InvMagSqrt());
            dgAssert (dgAbsf(dir1 % dir1 - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f));

            dgVector q (m_invScale.CompProduct4(m_matrix.TransformVector (m_scale.CompProduct4 (m_otherShape->SupportVertex (dir1, &m_polygonFaceIndex[vertexIndex])))));
            dgAssert (q.m_w == dgFloat32 (0.0f));

            m_hullDiff[vertexIndex] = p - q;
            m_hullSum[vertexIndex] = p + q;
            break;
         }

         case dgCollisionInstance::m_global:
         default:
         {
            const dgCollisionInstance* const myCollisionInstance = m_proxy->m_referenceCollision;
            const dgCollisionInstance* const otherCollsionInstance = m_proxy->m_floatingCollision;

            dgAssert (myCollisionInstance->GetChildShape() == m_myShape);
            dgAssert (otherCollsionInstance->GetChildShape() == m_otherShape);

            const dgMatrix& myMatrix = myCollisionInstance->m_aligmentMatrix;
            const dgMatrix& otherMatrix = otherCollsionInstance->m_aligmentMatrix;

            dgVector alignedDir (myMatrix.RotateVector(dir));
            dgVector dir1 (m_scale.CompProduct4(m_matrix.UnrotateVector (m_invScale.CompProduct4(alignedDir.CompProduct4(dgVector::m_negOne)))));
            dir1 = otherMatrix.UnrotateVector(dir1.CompProduct4(dir1.InvMagSqrt()));
            dgAssert (dir1.m_w == dgFloat32 (0.0f));
            dgAssert (dgAbsf(dir1 % dir1 - dgFloat32 (1.0f)) < dgFloat32 (1.0e-3f));

            dgVector q1 (otherMatrix.TransformVector (m_otherShape->SupportVertex (dir1, &m_polygonFaceIndex[vertexIndex])));
            dgVector q (myMatrix.UntransformVector(m_invScale.CompProduct4(m_matrix.TransformVector (m_scale.CompProduct4 (q1)))));
            dgAssert (q.m_w == dgFloat32 (0.0f));

            m_hullDiff[vertexIndex] = p - q;
            m_hullSum[vertexIndex] = p + q;
            break;
         }
      }
   }


you can see how each case is progressive depend of the degree of complexity.

Bird can you please try this with your wrapper?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Bird » Sun Sep 08, 2013 5:41 pm

Bird can you please try this with your wrapper?


Uniform is working great but when I stretch on 1 axis then there's no collision detection.

http://hurleyworks.com/media/flash/NonUniformScaling/NonUniformScaling.html

-Bird
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Sun Sep 08, 2013 5:52 pm

oh, that definitely looks wrong.

I'l see what it is
thank for testing.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Mon Sep 09, 2013 10:46 am

Ha I see what the bug is. there are some other place that I need to consider the extra transformation, otherwise the contacts are in the wrong space.
I do not see it because in my test the matrix was almost identity.

not big deal I will fix it.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Mon Sep 09, 2013 11:04 am

Ok bird, I believe I have the general path working now (convex vs convex shapes)
please try again.

it should work with the test that you are showing in the video, and in your case should work almost every where since you are using convex shapes.
please give it a try.

after that, all I have to do is go find all of the special cases where scale is applied and check If the shape has a non identity alignment matrix, and apply the appropriate transformations.
I think that all in all is no that bad.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Bird » Mon Sep 09, 2013 12:00 pm

Ok bird, I believe I have the general path working now (convex vs convex shapes)
please try again.


Making progress but still not working properly. Here's what I'm seeing today.

http://hurleyworks.com/media/flash/NonUniformScaling2/NonUniformScaling2.html

-Bird
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Mon Sep 09, 2013 12:56 pm

I will try to set a similar test.
I know tha cow is make by convex decomposition.
is the hollow box also made the same way? and is the hollow box scaled too?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Bird » Mon Sep 09, 2013 1:12 pm

Julio Jerez wrote:I will try to set a similar test.
I know tha cow is make by convex decomposition.
is the hollow box also made the same way? and is the hollow box scaled too?


Yes, the hollow box is made using convex decomposition. It is not scaled in the video but if I do a non-uniform scale, it has the same problems that the cow does.

And just a heads-up. I can't compile the demoSandbox cleanly using VSExpress 2010. Here's the link errors: Also the pthreads project needs to be re-added from it's new location in coreLibrary_300

-Bird

11>------ Build started: Project: demosSandbox, Configuration: debug x64 ------
11>AdvancedPlayerController.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl CustomInputManager::~CustomInputManager(void)" (??1CustomInputManager@@UEAA@XZ) referenced in function "int `public: __cdecl AdvancedPlayerInputManager::AdvancedPlayerInputManager(class DemoEntityManager * const)'::`1'::dtor$0" (?dtor$0@?0???0AdvancedPlayerInputManager@@QEAA@QEAVDemoEntityManager@@@Z@4HA)
11>BasicPlayerController.obj : error LNK2001: unresolved external symbol "public: virtual __cdecl CustomInputManager::~CustomInputManager(void)" (??1CustomInputManager@@UEAA@XZ)
11>AdvancedPlayerController.obj : error LNK2019: unresolved external symbol "public: __cdecl CustomInputManager::CustomInputManager(struct NewtonWorld * const)" (??0CustomInputManager@@QEAA@QEAUNewtonWorld@@@Z) referenced in function "public: __cdecl AdvancedPlayerInputManager::AdvancedPlayerInputManager(class DemoEntityManager * const)" (??0AdvancedPlayerInputManager@@QEAA@QEAVDemoEntityManager@@@Z)
11>BasicPlayerController.obj : error LNK2001: unresolved external symbol "public: __cdecl CustomInputManager::CustomInputManager(struct NewtonWorld * const)" (??0CustomInputManager@@QEAA@QEAUNewtonWorld@@@Z)
11>AdvancedPlayerController.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl CustomInputManager::PreUpdate(float)" (?PreUpdate@CustomInputManager@@MEAAXM@Z)
11>BasicPlayerController.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl CustomInputManager::PreUpdate(float)" (?PreUpdate@CustomInputManager@@MEAAXM@Z)
11>AdvancedPlayerController.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl CustomInputManager::PostUpdate(float)" (?PostUpdate@CustomInputManager@@MEAAXM@Z)
11>BasicPlayerController.obj : error LNK2001: unresolved external symbol "protected: virtual void __cdecl CustomInputManager::PostUpdate(float)" (?PostUpdate@CustomInputManager@@MEAAXM@Z)
11>NewtonDemos.obj : error LNK2001: unresolved external symbol "void __cdecl StructuredConvexFracturing(class DemoEntityManager * const)" (?StructuredConvexFracturing@@YAXQEAVDemoEntityManager@@@Z)

11>../../x64\demosSandbox_d.exe : fatal error LNK1120: 5 unresolved externals
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Mon Sep 09, 2013 2:05 pm

ok I updated VS2010 and VS2012 projects.

thanks.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Wed Sep 11, 2013 11:23 am

Now I added the face that prepresses the mesh using a the p[olygon reduction tool.
The armadillo origin mesh has 99,990 triangle, I reduced to 1000 triangle and this is how the mesh looks
actually the newton poly reduction tool does a job as good as 3dsMax pro optimizer in some case is does a better job, and it is much faster than max,
polyReduction1.png
polyReduction1.png (557.78 KiB) Viewed 8507 times


now I only nee to make so that the collision tree support no collapsing points that are too close. I will provably have this ready sometime tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Wed Sep 11, 2013 11:38 am

actually I run some more test at different face count, and it looks like newton reduction tool does a substantially better job than Max pro optimizer.
It preserve the contort and volume better.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Scaling A Compound Collision Body

Postby Bird » Wed Sep 11, 2013 12:29 pm

Julio Jerez wrote:actually I run some more test at different face count, and it looks like newton reduction tool does a substantially better job than Max pro optimizer.
It preserve the contort and volume better.


That's excellent news! I'm looking forward to trying it out. Would it be possible to make Dynamic collision tree shapes with the reduced polygon mesh now instead of having to resort to convex decomposition?

-Bird
Bird
 
Posts: 623
Joined: Tue Nov 22, 2011 1:27 am

Re: Scaling A Compound Collision Body

Postby Julio Jerez » Wed Sep 11, 2013 1:33 pm

not at the moment, however after I am done with the compound scale, the convex decomposition bug, and the bug with the joint.

I will resume the soft bodies, and for that I will add the a new collsion shape type,the voxel collision shape.
the voxel collsion shape will voxelize a closed manifor mesh in a signed distance field voxel space.
Signed distance firld work very well with support vertex algrithms, thefore in theory these sphepe can interat effceintly other shapes in the game.

I will try first wit cloth, and then with solid soft bodies. theso are made of low res dynamics mesh, by the could lbe extended to support low res meshed and even anymamated low res meshes. But first I need to complete the scalling stuff and publish core 3.11

core 3.12 will introduce the stuff above. I have the softbody cloth already working by I nee the collison

In thoery the voxel methos sould support a full human body clothed. No stupid capsules and sphere approximations.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Previous

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 3 guests

cron