CompoundCollisionSetSubCollisionMatrix:no effect

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

CompoundCollisionSetSubCollisionMatrix:no effect

Postby Crashy » Tue Apr 02, 2013 12:30 pm

Hi,
I try to use the new feature allowing to change sub collision transform after the creation of the compound collision, but my sub collision is not moving at all :?

The NewtonCompoundCollisionRemoveSubCollisionByIndex function is working nice, so I'm sure that this is the right node I'm calling the function on.

This is what I do, nothing extraordinary:
Code: Select all
void CompoundCollision::setSubCollisionTransform(int collisionIndex
                                       ,const Ogre::Vector3 & position
                                       ,const Ogre::Quaternion & orientation)
   {
      void* node = NewtonCompoundCollisionGetNodeByIndex(m_col,collisionIndex);
      Ogre::Real matrix[16];

       OgreNewt::Converters::QuatPosToMatrix(orientation, position, &matrix[0]);
      
      NewtonCompoundCollisionSetSubCollisionMatrix(m_col,node,matrix);

   }


In the sdk samples this is only used between calls of begin/end add subcollision, is it necessary?
Crashy
 
Posts: 101
Joined: Fri Dec 03, 2010 6:30 am

Re: CompoundCollisionSetSubCollisionMatrix:no effect

Postby Julio Jerez » Wed Apr 03, 2013 10:28 am

Crashy wrote:In the sdk samples this is only used between calls of begin/end add subcollision, is it necessary?

yes, any set operation on a compound collision most be form within a begin/end block
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CompoundCollisionSetSubCollisionMatrix:no effect

Postby pitsikoko » Thu Aug 08, 2013 4:31 pm

It seems to have no effect even when placed in between a begin end block. However the visual debugging shows the the collision matrix has been updated. only the collision detection routine seems to not take it into account.

Any idea ?
pitsikoko
 
Posts: 5
Joined: Thu Aug 01, 2013 6:20 pm

Re: CompoundCollisionSetSubCollisionMatrix:no effect

Postby Julio Jerez » Thu Aug 08, 2013 5:28 pm

That's strange, the colllion geometry of the vehicle is in fact a compound collision and I move the tires with this code
Code: Select all
void CustomVehicleController::UpdateTireTransforms ()
{
   for (TireList::CustomListNode* node = m_tireList.GetFirst(); node; node = node->GetNext()) {
      TireBodyState* const tire = &node->GetInfo();
      tire->UpdateTransform();
   }
}


I will add a demo that set the scale matrix of a compound collsion maybe ther is a problem that I have not seem.


edit:
Oh I see you say the shape do change but the collision is not notified.
yes that that could be the case, if a body is a rest and you change a sub shape, them there is not way the broaphase can know about.
colliion shapes are no aware of the body who own them. you will have to call
NetwonBodySeetSleepoinState (body, false)

so that the body wakes up and upade its AABB represenation in the broaphase.
in the vehicle code this works because the tire do not collide, rath the use convex cast to predict the tire contact.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: CompoundCollisionSetSubCollisionMatrix:no effect

Postby pitsikoko » Thu Aug 08, 2013 6:51 pm

My body is not sleeping.

I'm actually setting the transform of the sub shape while the body is simulated. Just because i m tweaking it in realtime with a tool.

I think there is a problem, the visual representation of the shape is updated, but the collision is happening with the subshape with an identity transform relative to the body (no transform whatsoever affects the subshape of the coumpound. it's like if i never offset the position of the sub shape ).
pitsikoko
 
Posts: 5
Joined: Thu Aug 01, 2013 6:20 pm

Re: CompoundCollisionSetSubCollisionMatrix:no effect

Postby pitsikoko » Thu Aug 08, 2013 7:02 pm

I tried NewtonBodySetSleepState, no luck.

But i have another info:

- if NewtonCompoundCollisionSetSubCollisionMatrix is called before the collision is added to the body, it works as expected.
- if it's called after the collision has been added, the collision seems to not be updated, it still collides as the old position, however the visual rendering of NewtonPerPolyDo is updated.
pitsikoko
 
Posts: 5
Joined: Thu Aug 01, 2013 6:20 pm

Re: CompoundCollisionSetSubCollisionMatrix:no effect

Postby pitsikoko » Thu Aug 08, 2013 7:10 pm

one for thing. if I call again NewtonBodySetCollision with the collision returned by NewtonBodyGetCollision, then it updates the shape as expected. Is that an expected behavior ? Maybe there should be another function NewtonBodyRefreshCollision, to do the same thing.

best
pierre
pitsikoko
 
Posts: 5
Joined: Thu Aug 01, 2013 6:20 pm

Re: CompoundCollisionSetSubCollisionMatrix:no effect

Postby Julio Jerez » Thu Aug 08, 2013 8:28 pm

can you list here the snep of code you are using to set that up
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 3 guests