changed SOP Force and Torque, adding XML (de/)serialization, also changed Buoyance. PLEASE trap deserialization from inventory etc, making force and torque vector3.Zero, unless we want then to rez moving. (needs checking/testing as usual)
parent
7b6649177e
commit
e07440d0c5
|
@ -2045,30 +2045,9 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void setAngularImpulse(Vector3 impulse)
|
||||
{
|
||||
if (RootPart.PhysActor != null)
|
||||
{
|
||||
if (!IsAttachment)
|
||||
{
|
||||
RootPart.PhysActor.Torque = impulse;
|
||||
m_scene.PhysicsScene.AddPhysicsActorTaint(RootPart.PhysActor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 GetTorque()
|
||||
{
|
||||
if (RootPart.PhysActor != null)
|
||||
{
|
||||
if (!IsAttachment)
|
||||
{
|
||||
Vector3 torque = RootPart.PhysActor.Torque;
|
||||
return torque;
|
||||
}
|
||||
}
|
||||
|
||||
return Vector3.Zero;
|
||||
return RootPart.Torque;
|
||||
}
|
||||
|
||||
// This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object
|
||||
|
|
|
@ -294,6 +294,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
protected Vector3 m_lastAngularVelocity;
|
||||
protected int m_lastTerseSent;
|
||||
protected float m_buoyancy = 0.0f;
|
||||
protected Vector3 m_force;
|
||||
protected Vector3 m_torque;
|
||||
|
||||
/// <summary>
|
||||
/// Stores media texture data
|
||||
|
@ -1302,14 +1304,66 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public float Buoyancy
|
||||
{
|
||||
get { return m_buoyancy; }
|
||||
get
|
||||
{
|
||||
if (ParentID != 0 && ParentGroup != null)
|
||||
m_buoyancy = ParentGroup.RootPart.Buoyancy;
|
||||
return m_buoyancy;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_buoyancy = value;
|
||||
if (PhysActor != null)
|
||||
if (ParentID != 0)
|
||||
{
|
||||
PhysActor.Buoyancy = value;
|
||||
if (ParentGroup != null)
|
||||
ParentGroup.RootPart.Buoyancy = value;
|
||||
}
|
||||
else if (PhysActor != null)
|
||||
PhysActor.Buoyancy = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Force
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ParentID != 0 && ParentGroup != null)
|
||||
m_force = ParentGroup.RootPart.Force;
|
||||
return m_force;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
m_force = value;
|
||||
if (ParentID != 0)
|
||||
{
|
||||
if (ParentGroup != null)
|
||||
ParentGroup.RootPart.Force = value;
|
||||
}
|
||||
else if (PhysActor != null)
|
||||
PhysActor.Force = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 Torque
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ParentID != 0 && ParentGroup != null)
|
||||
m_torque = ParentGroup.RootPart.Torque;
|
||||
return m_torque;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
m_torque = value;
|
||||
if (ParentID != 0)
|
||||
{
|
||||
if (ParentGroup != null)
|
||||
ParentGroup.RootPart.Torque = value;
|
||||
}
|
||||
else if (PhysActor != null)
|
||||
PhysActor.Torque = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1488,20 +1542,24 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// </summary>
|
||||
/// <param name="impulsei">Vector force</param>
|
||||
/// <param name="localGlobalTF">true for the local frame, false for the global frame</param>
|
||||
public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF)
|
||||
|
||||
// this is actualy Set Torque.. keeping naming so not to edit lslapi also
|
||||
public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF)
|
||||
{
|
||||
Vector3 impulse = impulsei;
|
||||
Vector3 torque = torquei;
|
||||
|
||||
if (localGlobalTF)
|
||||
{
|
||||
/*
|
||||
Quaternion grot = GetWorldRotation();
|
||||
Quaternion AXgrot = grot;
|
||||
Vector3 AXimpulsei = impulsei;
|
||||
Vector3 newimpulse = AXimpulsei * AXgrot;
|
||||
impulse = newimpulse;
|
||||
*/
|
||||
torque *= GetWorldRotation();
|
||||
}
|
||||
|
||||
ParentGroup.setAngularImpulse(impulse);
|
||||
Torque = torque;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1571,14 +1629,22 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
DoPhysicsPropertyUpdate(RigidBody, true);
|
||||
PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
|
||||
|
||||
if (!building)
|
||||
PhysActor.Building = false;
|
||||
|
||||
Velocity = velocity;
|
||||
AngularVelocity = rotationalVelocity;
|
||||
PhysActor.Velocity = velocity;
|
||||
PhysActor.RotationalVelocity = rotationalVelocity;
|
||||
|
||||
if (!building)
|
||||
PhysActor.Building = false;
|
||||
// if not vehicle and root part apply force and torque
|
||||
if ((m_vehicle == null || m_vehicle.Type == Vehicle.TYPE_NONE)
|
||||
&& LocalId == ParentGroup.RootPart.LocalId)
|
||||
{
|
||||
PhysActor.Force = Force;
|
||||
PhysActor.Torque = Torque;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2002,10 +2068,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public Vector3 GetForce()
|
||||
{
|
||||
if (PhysActor != null)
|
||||
return PhysActor.Force;
|
||||
else
|
||||
return Vector3.Zero;
|
||||
return Force;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -3150,10 +3213,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public void SetBuoyancy(float fvalue)
|
||||
{
|
||||
Buoyancy = fvalue;
|
||||
/*
|
||||
if (PhysActor != null)
|
||||
{
|
||||
PhysActor.Buoyancy = fvalue;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void SetDieAtEdge(bool p)
|
||||
|
@ -3181,10 +3247,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public void SetForce(Vector3 force)
|
||||
{
|
||||
Force = force;
|
||||
/*
|
||||
if (PhysActor != null)
|
||||
{
|
||||
PhysActor.Force = force;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public SOPVehicle sopVehicle
|
||||
|
|
|
@ -349,6 +349,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4);
|
||||
|
||||
m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy);
|
||||
m_SOPXmlProcessors.Add("Force", ProcessForce);
|
||||
m_SOPXmlProcessors.Add("Torque", ProcessTorque);
|
||||
m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive);
|
||||
|
||||
//Ubit comented until proper testing
|
||||
|
@ -762,7 +764,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
|
||||
private static void ProcessBuoyancy(SceneObjectPart obj, XmlTextReader reader)
|
||||
{
|
||||
obj.Buoyancy = (int)reader.ReadElementContentAsFloat("Buoyancy", String.Empty);
|
||||
obj.Buoyancy = (float)reader.ReadElementContentAsFloat("Buoyancy", String.Empty);
|
||||
}
|
||||
|
||||
private static void ProcessForce(SceneObjectPart obj, XmlTextReader reader)
|
||||
{
|
||||
obj.Force = Util.ReadVector(reader, "Force");
|
||||
}
|
||||
private static void ProcessTorque(SceneObjectPart obj, XmlTextReader reader)
|
||||
{
|
||||
obj.Torque = Util.ReadVector(reader, "Torque");
|
||||
}
|
||||
|
||||
private static void ProcessVolumeDetectActive(SceneObjectPart obj, XmlTextReader reader)
|
||||
|
@ -1256,6 +1267,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString());
|
||||
|
||||
writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString());
|
||||
|
||||
WriteVector(writer, "Force", sop.Force);
|
||||
WriteVector(writer, "Torque", sop.Torque);
|
||||
|
||||
writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
|
||||
|
||||
//Ubit comented until proper testing
|
||||
|
|
Loading…
Reference in New Issue