mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 20:05:33 +08:00
add OSSL functions to override linksets total mass, center of mass and inertia. replacing the crude automatic estimation based on prims known to physics and density. Changed parameters are still not saved, and are lost on region crossings. only suported by UbODE. EXPERIMENTAL feature, only test it for now.. don't try to use in products.
This commit is contained in:
@@ -5010,6 +5010,47 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return Ptot;
|
||||
}
|
||||
|
||||
public void GetInertiaData(out float TotalMass, out Vector3 CenterOfMass, out Vector3 Inertia, out Vector4 aux )
|
||||
{
|
||||
PhysicsActor pa = RootPart.PhysActor;
|
||||
|
||||
if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null)
|
||||
{
|
||||
PhysicsInertiaData inertia;
|
||||
|
||||
inertia = pa.GetInertiaData();
|
||||
|
||||
TotalMass = inertia.TotalMass;
|
||||
CenterOfMass = inertia.CenterOfMass;
|
||||
Inertia = inertia.Inertia;
|
||||
aux = inertia.InertiaRotation;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
TotalMass = GetMass();
|
||||
CenterOfMass = GetCenterOfMass() - AbsolutePosition;
|
||||
CenterOfMass *= Quaternion.Conjugate(RootPart.RotationOffset);
|
||||
Inertia = Vector3.Zero;
|
||||
aux = Vector4.Zero;
|
||||
}
|
||||
|
||||
public void SetInertiaData(float TotalMass, Vector3 CenterOfMass, Vector3 Inertia, Vector4 aux )
|
||||
{
|
||||
PhysicsActor pa = RootPart.PhysActor;
|
||||
|
||||
if(pa !=null)
|
||||
{
|
||||
PhysicsInertiaData inertia = new PhysicsInertiaData();
|
||||
inertia.TotalMass = TotalMass;
|
||||
inertia.CenterOfMass = CenterOfMass;
|
||||
inertia.Inertia = Inertia;
|
||||
inertia.InertiaRotation = aux;
|
||||
pa.SetInertiaData(inertia);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set the user group to which this scene object belongs.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user