Objects with different shapes move differently?

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
mcmonkey
Posts: 92
Joined: Fri Apr 17, 2015 11:42 pm

Objects with different shapes move differently?

Post by mcmonkey »

I've noticed the oddest thing:

I have a constraint controlling the properties of an object. In particular updating relevant velocities.

As best I can determine currently, it appears the /shape/ of an object affects how it moves?

Velocities are being worked with the same, mass is the same.

A 1x1x1 cube will rotate super rapidly, spinning on the slightest impulse.

A wider shaped object will rotate slowly.

They have the same mass and same damping values and same impulses being applied...

If relevant, their is a non-colliding second object jointed to be at the origin of the object, which may effect motion a bit? But it's the same object every time...

Also I'm not 100% sure they're rotating around ... the correct point (IE the center)

I'm a bit confused...

Unless there's an "oh yeah shape does <this and that>" type of thing, I guess this topic is a request for debugging ideas?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Objects with different shapes move differently?

Post by Norbo »

If one of the shapes is larger, it will have a larger inertia tensor even if the mass is the same. In other words, given an impulse, the angular velocity of a large shape will tend to change less than a small shape. The same principle allows a figure skater to speed up in a spin by pulling in their limbs, reducing their moment of inertia.
mcmonkey
Posts: 92
Joined: Fri Apr 17, 2015 11:42 pm

Re: Objects with different shapes move differently?

Post by mcmonkey »

Norbo wrote: Mon Jun 26, 2017 5:31 am If one of the shapes is larger, it will have a larger inertia tensor even if the mass is the same. In other words, given an impulse, the angular velocity of a large shape will tend to change less than a small shape. The same principle allows a figure skater to speed up in a spin by pulling in their limbs, reducing their moment of inertia.
That would do it in exactum, yup! Your physics is too clever for me.

And I found some relevant example of the code in question:

Code: Select all


            angularVelocity.X += impulse.X * inertiaTensorInverse.M11 + impulse.Y * inertiaTensorInverse.M21 + impulse.Z * inertiaTensorInverse.M31;
            angularVelocity.Y += impulse.X * inertiaTensorInverse.M12 + impulse.Y * inertiaTensorInverse.M22 + impulse.Z * inertiaTensorInverse.M32;
angularVelocity.Z += impulse.X * inertiaTensorInverse.M13 + impulse.Y * inertiaTensorInverse.M23 + impulse.Z * inertiaTensorInverse.M33;
So, my first guess as to how to bypass this would be not using that method (ApplyAngularImpulse)
but, er, I'm not using it in the first place.

In fact, due to some insanity from past problems, I manually update the orientation and angular velocity...

(Orientation updates are based on angular velocity trickery, I don't remember what half of this code's intent was, but it seems to work for specific cases well enough, and I imagine it shouldn't be too hard to make them consistent across all cases...)

Is the angular velocity damping also affected by this?

Either way, how would I bypass this effect and achieve 100% matching results across all shapes?
My worst case scenario option is to replace the angular velocity with my own variable for it, and apply simplified math to keep it in check...
(and damp the built-in angular velocity heavily of course - weak enough to let it roll with impacts, but strong enough that it stops rolling when needed... probably modified with linear velocity...)
mcmonkey
Posts: 92
Joined: Fri Apr 17, 2015 11:42 pm

Re: Objects with different shapes move differently?

Post by mcmonkey »

Update: I am dumb and bad at reading my own code

I use ApplyImpulse as a method of achieving rotation in some areas of code that I wasn't properly looking at.

So... yeah ideally I'd make that logic work as though the inertia tensor was irrelevant, or replace the logic entirely.

Any suggestion which route would be better?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Objects with different shapes move differently?

Post by Norbo »

An angular impulse boils down to a simple change in angular velocity after being transformed by the inertia tensor. If you don't want to deal with the influence of the inertia tensor, you can instead just directly change the angular velocity. (Damping is also unaffected by the inertia tensor; it operates directly on velocity.)

If you'd like to make a shape respond to all angular impulses in the same way as another shape, you can change the inertia tensor:

Code: Select all

entityA.LocalInertiaTensor = entityB.LocalInertiaTensor;
Post Reply