hkpPhysicsSystem.clone() crash!

hkpPhysicsSystem.clone() crash!

Ritratto di kevin_lee

Hi, I encountered a strange errors when I'm trying to import .hkx file into engine.
In my engine, I wanna generate .hkx file for each actor, when loading the actor, I load the corresponding physics data. So every time I initialize the actor's physics' data, I'm trying to clone the physics system in .hkx file. But when the constraints constraint to the world, the errors pop up "Rigidbodies are referenced by a constraint in the physics system that are not in the physics' system."
How can I fix this error? Or is there any better way to import the physics' data into my own actors?
Pls anybody help me out!

9 post / 0 new
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
Ritratto di havokdaniel

Hi Kevin,

It is not possible to clone constraints which are constrained to the world right now. This is a known issue and a fix is in progress. I do not know when it will be complete though.

For the meantime you can try using hkpConstraintInstance::setFixedRigidBodyPointersToZero() on everything in hkpPhysicsSystem::getConstraints() to make sure there are no invalid references.

Let me know if you have any trouble getting this going.

Thanks,
Daniel

Ritratto di kevin_lee

Thank you very much, Daniel! I'll try the functions you mentioned. Hope you guys will fix this soon. It's anoying without this support.

Ritratto di kevin_lee

Hi Daniel,
I used the functions you mentioned before. It didn't work. Still get the error message!
Maybe I should tell you more about our situation, then you can give me some suggestions.
We wanna use Havok Content Tool to create some physics objects attached to our own actors. Each our own actor has their own data file. So we wanna export these physics objects data file .hkx for each actor. When we add the actor into the scene, if it's the first time adding this actor, then we'll import the .hkx file, and clone the physics system in physics data. Each time we wanna create an instance of this actor, we just need to clone the physics system and add them into the world.
If the bug can't be fixed right now, any suggestions can you give us?

Ritratto di havokdaniel

Hi Kevin,

Can you try cloning the physics system and before adding to the world, debug into hkpPhysicsSystem::getConstraints() and check that neither hkpConstraintInstance::m_entities[0] nor hkpConstraintInstance::m_entities[1] are hkpWorld::getFixedRigidBody() ?

Also, could you explain how you're adding the cloned physics system to the world?

Thanks,
Daniel

Ritratto di kevin_lee

Hi Daniel,

I checked all the constraints in the physics system, if there's one entity pointer is NULL, then when I clone the physics system, I got the Assert failure message:" Rigidbodies are referenced by a constraint in the physics system that are not in the physics sytem." If there's no constraints constraint to the world, there's no such error messages, and I will change the rigidbodies' positions according to my own actors. Then add the physics system into the world. The problem occurs when I cloning the physics system. Adding them into the world is OK.

After all these failures, now I use another way to solve this problem: when I found there's some entity pointers are NULL, I reload the .hkx file. And I didn't clone them, just added them into the world. It's ugly. But it worked.

And I got another problem: how can I change the constraints' position? I mean, when the constraint constrainted to the world, I need to change the fixed point sometime before I adding them into the world. From the demos and the headers, I can't find any functions can help me do this kind of job! I can change the position of the rigidbodies, but the constraints didn't go with them.

Can you give me any sugestions?

Thanks for your quickly reply!

Kevin

Ritratto di havokdaniel

Hi Kevin,

Glad you got a workaround to that problem. Unfortunately the only way to move a constraint like that is to get at the constraint data. This is a different for every constraint type so you'll have to check which type of constraint you're dealing with, then get the constraint data, cast it to the correct constraint data type, and modify that.

What you're looking for is in Havok 6.0 (hkpPhysicsSystem::transform()) but we don't have the free SDK version released yet.

I haven't have a chance to implement this code myself but I think you'll need to do something like

if (constraintInstance->getData()->getType() == hkpConstraintData::CONSTRAINT_TYPE_BALLANDSOCKET)
{
hkpBallAndSocketConstraintData* ballSocketData = static_cast(data);
// Grab the transforms of constraintInstance->getEntityA and constraintInstance->getEntityB, transform them, and do
// ballSocketData->setInWorldSpace() with the new positions.
}
else if (constraintInstance->getData()->getType() == hkpConstraintData::CONSTRAINT_TYPE_HINGE)
{
// Do the same for this type of constraint instance...
}

Hope this puts you on the right track,
Daniel

Ritratto di kevin_lee

Hi Daniel,

It's great to hear that there's a function can do this job. So when I get the Havok 6.0 lisence, the job will be very easy. I've implemented this in the same way you talked about. Thanks!

I notice that some wierd thing happen to capsule, when you hit it. Not so realistic. The ragdoll is OK, but the single capsule seems a little bit wierd. Is that a bug or something?

Kevin

Ritratto di sean.thurston

Hi Kevin,

In what context are you using the capsule? Is it just a general capsule rigid body? Does it have constraints attached to it? What kind of "weirdness" are you experiencing? If you had some more information that would definitely help us understand the issue.
Thanks,
Sean

Developer Support Engineer Havok www.havok.com

Accedere per lasciare un commento.