Report any bugs here and we'll post fixes
Moderators: Sascha Willems, Thomas
by Julio Jerez » Fri Nov 28, 2014 7:43 pm
Ha, I see now what Is the problem that you are having.
basically you are scaling the body but you are not considering the mass of the body.
if you have a box of 1 x 1 x 1 and the box is 1 ton (1000 kg)
the density is 1000 kg/m^3
assuming the water has a density if 1000/kg/m^3 the that box will be perfectly buoyance because it
will displace the same volume of water.
if you scale the box to a 2 x 2 x 2 now the box is 0.125 kg / m^3
if you place it on water, if can only submerge until a volume of 1 m^3 which is 1000 kg/m3
therefore a large part of the box will state afloat
if you now set the scale to 0.5 x 0.5 x 0.5
when you put in the fluid it only displace a volume ox 05 x 0.5 x 0.5 which
which is only 125 kg therefore but the box still weight 1000 kg so there is a balance of
1000 - 125 kg of weight, the box will sink to the bottom
if you want to keep the same buoyance ration you have to scale the mass by the same factor.
This is the principle that makes submarine and hot air balloon work.
that is not a bug that is how is supposed to work.
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by arkeon » Sat Nov 29, 2014 4:53 am
hmm ok but if I take the same model, scale and mass.
and just change it to convex shape it float.
even a simple box do not react the same.
do that test :
a simple box convex shape with scale 1 3.5 1 and mass 1
and the same box with same scale and mass but created as compound.
the compound jump and spin harder just like the plane or volume were different.
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
by arkeon » Thu Dec 04, 2014 6:05 am
Hello,
could you make that test ? does it do the same for you ?
-
arkeon
-
- Posts: 261
- Joined: Sat Sep 13, 2014 5:25 pm
by AntonSynytsia » Sat Dec 06, 2014 8:44 pm
I was able to do the test.
The green boxes consist of box collision. The purple boxes consist of compound collision with box sub-collision.
It turns out the same; however, scaled compound volume turns out to be half of the scaled box volume, which makes it to be more buoyant than other bodies. It seems that the NewtonConvexCollisionCalculateVolume function doesn't include scale for scaled compound, but I'm not sure. Maybe there's a bug in my own code. I will look into my code and post results.
-
AntonSynytsia
-
- Posts: 193
- Joined: Sat Dec 28, 2013 6:36 pm
by Julio Jerez » Sat Dec 06, 2014 11:43 pm
so a scale of 2, 1, 1 behave different with a compound, I will check tomorrow.
are the offset matrix of the compound identity?
-
Julio Jerez
- Moderator
-
- Posts: 12249
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by AntonSynytsia » Sun Dec 07, 2014 6:36 am
I was able to test two approaches of scaled compound collision. One approach is by creating a scaled compound collision with a non-scaled box sub-collision. Another approach is by creating a non-scaled compound collision with with a scaled box sub-collision. As of results the volume in both approaches is expected to be two. Unfortunately, the volume of compound shape in both approaches turns out one.
Here is the code below for the two compound approaches. The first code segment was added to ensure NewtonConvexCollisionCalculateVolume works properly for scaled box collision. The rest of the two code segments rely to the two approaches of creating the compound shape.
Scaled box collision:
- Code: Select all
// Scaled box collision.
NewtonCollision* box = NewtonCreateBox(world, 1.0f, 1.0f, 1.0f, 0, NULL);
NewtonConvexCollisionCalculateVolume(box); // Returns 1
NewtonCollisionSetScale(box, 2.0f, 1.0f, 1.0f);
NewtonConvexCollisionCalculateVolume(box); // Returns 2 - GOOD
Scaled compound collision consisting of box sub-collision:
- Code: Select all
// Scaled compound collision consisting of box sub-collision.
NewtonCollision* sub_box = NewtonCreateBox(world, 1.0f, 1.0f, 1.0f, 0, NULL);
NewtonCollision* compound = NewtonCreateCompoundCollision(world, 0);
NewtonCompoundCollisionBeginAddRemove(compound);
NewtonCompoundCollisionAddSubCollision(compound, sub_box);
NewtonDestroyCollision(sub_box);
NewtonCompoundCollisionEndAddRemove(compound);
NewtonConvexCollisionCalculateVolume(compound); // Returns 1
newtonCollisionSetScale(compound, 2.0f, 1.0f, 1.0f);
NewtonConvexCollisionCalculateVolume(compound); // Returns 1 - BAD
Compound collision consisting of scaled box sub-collision.
- Code: Select all
// Compound collision consisting of scaled box sub-collision.
NewtonCollision* sub_box2 = NewtonCreateBox(world, 1.0f, 1.0f, 1.0f, 0, NULL);
Newton.collisionSetScale(sub_box2, 2.0f, 1.0f, 1.0f);
NewtonCollision* compound2 = NewtonCreateCompoundCollision(world, 0);
NewtonCompoundCollisionBeginAddRemove(compound2);
NewtonCompoundCollisionAddSubCollision(compound2, sub_box2);
NewtonDestroyCollision(sub_box2);
NewtonCompoundCollisionEndAddRemove(compound2);
NewtonConvexCollisionCalculateVolume(compound); // Returns 1 -- BAD
The following tests were done with GitHub revision 2194.
Julio Jerez wrote:are the offset matrix of the compound identity?
Do you want me to test the collision offset? Can you clarify the question?
-
AntonSynytsia
-
- Posts: 193
- Joined: Sat Dec 28, 2013 6:36 pm
Return to Bugs and Fixes
Who is online
Users browsing this forum: No registered users and 7 guests