store the physics inertia override in Mysql and add it to serializer. run prebuild is required

This commit is contained in:
UbitUmarov
2017-04-01 17:49:17 +01:00
parent 24b7903cd0
commit 443fc60cdf
8 changed files with 336 additions and 38 deletions

View File

@@ -5037,20 +5037,22 @@ namespace OpenSim.Region.Framework.Scenes
public void SetInertiaData(float TotalMass, Vector3 CenterOfMass, Vector3 Inertia, Vector4 aux )
{
PhysicsInertiaData inertia = new PhysicsInertiaData();
inertia.TotalMass = TotalMass;
inertia.CenterOfMass = CenterOfMass;
inertia.Inertia = Inertia;
inertia.InertiaRotation = aux;
if(TotalMass < 0)
RootPart.PhysicsInertia = null;
else
RootPart.PhysicsInertia = new PhysicsInertiaData(inertia);
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>

View File

@@ -406,6 +406,8 @@ namespace OpenSim.Region.Framework.Scenes
private SOPVehicle m_vehicleParams = null;
private PhysicsInertiaData m_physicsInertia;
public KeyframeMotion KeyframeMotion
{
get; set;
@@ -3548,6 +3550,18 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
Force = force;
}
public PhysicsInertiaData PhysicsInertia
{
get
{
return m_physicsInertia;
}
set
{
m_physicsInertia = value;
}
}
public SOPVehicle VehicleParams
{
get
@@ -4748,8 +4762,13 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter
if (VolumeDetectActive) // change if not the default only
pa.SetVolumeDetect(1);
bool isroot = (m_localId == ParentGroup.RootPart.LocalId);
if (m_vehicleParams != null && m_localId == ParentGroup.RootPart.LocalId)
if(isroot && m_physicsInertia != null)
pa.SetInertiaData(m_physicsInertia);
if (isroot && m_vehicleParams != null )
{
m_vehicleParams.SetVehicle(pa);
if(isPhysical && !isPhantom && m_vehicleParams.CameraDecoupled)

View File

@@ -453,9 +453,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
m_SOPXmlProcessors.Add("Torque", ProcessTorque);
m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive);
m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle);
m_SOPXmlProcessors.Add("PhysicsInertia", ProcessPhysicsInertia);
m_SOPXmlProcessors.Add("RotationAxisLocks", ProcessRotationAxisLocks);
m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType);
m_SOPXmlProcessors.Add("Density", ProcessDensity);
@@ -781,6 +782,23 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
}
}
private static void ProcessPhysicsInertia(SceneObjectPart obj, XmlReader reader)
{
PhysicsInertiaData pdata = PhysicsInertiaData.FromXml2(reader);
if (pdata == null)
{
obj.PhysicsInertia = null;
m_log.DebugFormat(
"[SceneObjectSerializer]: Parsing PhysicsInertiaData for object part {0} {1} encountered errors. Please see earlier log entries.",
obj.Name, obj.UUID);
}
else
{
obj.PhysicsInertia = pdata;
}
}
private static void ProcessShape(SceneObjectPart obj, XmlReader reader)
{
List<string> errorNodeNames;
@@ -1498,6 +1516,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
if (sop.VehicleParams != null)
sop.VehicleParams.ToXml2(writer);
if (sop.PhysicsInertia != null)
sop.PhysicsInertia.ToXml2(writer);
if(sop.RotationAxisLocks != 0)
writer.WriteElementString("RotationAxisLocks", sop.RotationAxisLocks.ToString().ToLower());
writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower());

View File

@@ -55,28 +55,6 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
Absolute
}
public class PhysicsInertiaData
{
public float TotalMass; // the total mass of a linkset
public Vector3 CenterOfMass; // the center of mass position relative to root part position
public Vector3 Inertia; // (Ixx, Iyy, Izz) moment of inertia relative to center of mass and principal axis in local coords
public Vector4 InertiaRotation; // if principal axis don't match local axis, the principal axis rotation
// or the upper triangle of the inertia tensor
// Ixy (= Iyx), Ixz (= Izx), Iyz (= Izy))
public PhysicsInertiaData()
{
}
public PhysicsInertiaData(PhysicsInertiaData source)
{
TotalMass = source.TotalMass;
CenterOfMass = source.CenterOfMass;
Inertia = source.Inertia;
InertiaRotation = source.InertiaRotation;
}
}
public struct CameraData
{
public Quaternion CameraRotation;

View File

@@ -568,9 +568,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{
get
{
if(!childPrim && m_fakeInertiaOverride != null)
return m_fakeInertiaOverride.CenterOfMass;
lock (_parent_scene.OdeLock)
{
d.AllocateODEDataForThread(0);