Closed lpares12 closed 1 year ago
Hi @lpares12,
Hi, thanks for the quick reply!
As for (2), yes, actually this is just a copy-paste of my bigger project, so might be I made a typo (due to the copy paste). And you are right, I actually divide/2 the size. But in any case, the density is not being computed correctly, seems to not take the volume of the shape into account. Even fixing the typo and so on, I can see the same behavior.
Let's say I set one box shape half-size to: (0.5, 0.5, 0.5)
(meaning its volume will be 1m3) and a density of 1000. It means the shape should have a mass of 1000, correct? But then if I set another box to (1, 1, 1)
(meaning its volume will be 8m3
and a density of 1000
it should have a mass of 8000, correct? But when I do so, it still says the mass is 1000, instead of 8000.
I wonder if I'm updating the shapes sizes correctly. Would it be enough to do:
PxGeometryHolder new_geometry = PxBoxGeometry(PxVec3(4, 4, 4));
px_shape->setGeometry(new_geometry.any());
// Recompute mass
PxRigidBodyExt::updateMassAndInertia(*px_actor1, &densities[0], 1);
This I'd expect to update the mass of the first actor to 512
assuming a density of 1.
@lpares12 The issue is that your shapes are shared and not exclusive. In that case you are not allowed to update them. It is a good idea to run in debug or checked configs, which will print issues.
I.e. you should see something like this:
C:\p\physx\PhysXSDK\trunk\source\physx\src\NpShape.cpp (272) : invalid parameter : PxShape::setGeometry: shared shapes attached to actors are not writable.
Thank you, this was the issue. I did see the logs, but seeing how the shape position and sizes and everything were correctly modified I still expected it to be okay.
Thanks again and sorry for opening a non-issue!
Yay! Glad it's resolved.
Hi, it seems like the gravity might be ignoring the mass of the dynamic bodies I'm creating.
First of all I initialize PhysX, create a scene, and check the gravity in it:
And then I create two dynamic bodies with two shapes, calculate their mass and attach them to the scene:
And when stepping through the simulation, both bodies fall down at the same velocity, which should not be the case.
If the shape 2 has size of 2x2x2m and a density of 1000, the mass of the px_actor2 should be 2000, but the getMass call for that shape is returning 1000.
So I see two problems in my script:
In the docs I can't find any setting that I need to enable to make this work, is there something else I'm missing?