Report any bugs here and we'll post fixes
Moderators: Sascha Willems, Thomas
by Bird » Mon Nov 24, 2014 11:49 am
Hi Julio,
I'm trying to interactively change the shape of a NewtonCompound. It works ok in some cases but fails when larger changes are made to the shape of the original compound. But if I save the scene that fails and reload it, it works fine. I think my transformation math is ok and I call NewtonBodySetMassProperties() after each edit is made Is there anything else I need to do, like resetting the center of mass after each edit? I pretty much used the same code from the sandbox demo.
http://hurleyworks.com/media/flash/CompoundEdits/CompoundEdits.htmlDo you have any idea what might be happening.? I can't export a scene because it works fine when first loaded and only fails during interactive edits
-Bird
-
Bird
-
- Posts: 623
- Joined: Tue Nov 22, 2011 1:27 am
by Julio Jerez » Mon Nov 24, 2014 12:08 pm
what your are doing should do it.
Can I see your function?
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Bird » Mon Nov 24, 2014 12:46 pm
Here's the function I'm calling when the user transforms one of the compound parts:
-Bird
- Code: Select all
void setCompoundPartPose(PhysicsBody * const pBody)
{
CompoundInfo & info = PhysicsModel::getInstance()->getCompound(pBody->bodyDesc.compoundID);
PhysicsBody * const compoundBody = PhysicsModel::getInstance()->findPhysicsBody(info.bodyID);
const NewtonBody * const newtonBody = (NewtonBody*)compoundBody->component->userData;
NewtonCollision * const compound = NewtonBodyGetCollision(newtonBody);
NewtonCompoundCollisionBeginAddRemove(compound);
for (void* node = NewtonCompoundCollisionGetFirstNode(compound); node; node = NewtonCompoundCollisionGetNextNode(compound, node))
{
NewtonCollision * const collision = NewtonCompoundCollisionGetCollisionFromNode(compound, node);
BodyID nodeID = static_cast<BodyID>(NewtonCollisionGetUserID(collision));
PhysicsBody * const part = static_cast<PhysicsBody*>(NewtonCollisionGetUserData(collision));
if (part && pBody == part && nodeID == part->bodyID)
{
pBody->component->localTransform = compoundBody->component->worldTransform.inverse(Eigen::Isometry) * pBody->component->worldTransform;
dMatrix matrix;
NewtonCollisionSetMatrix(collision, &matrix[0][0]);
}
}
NewtonCompoundCollisionEndAddRemove(compound);
NewtonBodySetMassProperties(newtonBody, compoundBody->bodyDesc.mass, compound);
}
-
Bird
-
- Posts: 623
- Joined: Tue Nov 22, 2011 1:27 am
by Julio Jerez » Mon Nov 24, 2014 1:12 pm
I am not sure if NewtonBodySetMassProperties is doing the right thing, I will verify.
I know there is a way, I just do no remember now.
I believe at some prion some one showed me that NewtonBodySetMassProperties soudl no recalculate the compound. I think is assume the shape is already organized.
I verify tonight and let you know.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Bird » Mon Nov 24, 2014 1:18 pm
Ok, thanks for looking into it.
-Bird
-
Bird
-
- Posts: 623
- Joined: Tue Nov 22, 2011 1:27 am
by Bird » Sat Dec 06, 2014 9:31 am
Hi Julio,
Any chance you can take a look at this one this weekend. It's kind of a big problem for me if I'm going to support Compound edits in my project.
Thanks
-Bird
-
Bird
-
- Posts: 623
- Joined: Tue Nov 22, 2011 1:27 am
by Julio Jerez » Mon Dec 08, 2014 1:40 pm
Oh no I did no do anything the last week.
I was talking a week off.
I see if I can check it out tonight.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Bird » Mon Dec 08, 2014 5:37 pm
Julio Jerez wrote:Oh no I did no do anything the last week.
I was talking a week off.
I see if I can check it out tonight.
Great. Thank you!
-Bird
-
Bird
-
- Posts: 623
- Joined: Tue Nov 22, 2011 1:27 am
Return to Bugs and Fixes
Who is online
Users browsing this forum: No registered users and 1 guest