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()
|
public Vector3 GetTorque()
|
||||||
{
|
{
|
||||||
if (RootPart.PhysActor != null)
|
return RootPart.Torque;
|
||||||
{
|
|
||||||
if (!IsAttachment)
|
|
||||||
{
|
|
||||||
Vector3 torque = RootPart.PhysActor.Torque;
|
|
||||||
return torque;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Vector3.Zero;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object
|
// 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 Vector3 m_lastAngularVelocity;
|
||||||
protected int m_lastTerseSent;
|
protected int m_lastTerseSent;
|
||||||
protected float m_buoyancy = 0.0f;
|
protected float m_buoyancy = 0.0f;
|
||||||
|
protected Vector3 m_force;
|
||||||
|
protected Vector3 m_torque;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores media texture data
|
/// Stores media texture data
|
||||||
|
@ -1302,14 +1304,66 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public float Buoyancy
|
public float Buoyancy
|
||||||
{
|
{
|
||||||
get { return m_buoyancy; }
|
get
|
||||||
|
{
|
||||||
|
if (ParentID != 0 && ParentGroup != null)
|
||||||
|
m_buoyancy = ParentGroup.RootPart.Buoyancy;
|
||||||
|
return m_buoyancy;
|
||||||
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
m_buoyancy = value;
|
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>
|
/// </summary>
|
||||||
/// <param name="impulsei">Vector force</param>
|
/// <param name="impulsei">Vector force</param>
|
||||||
/// <param name="localGlobalTF">true for the local frame, false for the global frame</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)
|
if (localGlobalTF)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
Quaternion grot = GetWorldRotation();
|
Quaternion grot = GetWorldRotation();
|
||||||
Quaternion AXgrot = grot;
|
Quaternion AXgrot = grot;
|
||||||
Vector3 AXimpulsei = impulsei;
|
Vector3 AXimpulsei = impulsei;
|
||||||
Vector3 newimpulse = AXimpulsei * AXgrot;
|
Vector3 newimpulse = AXimpulsei * AXgrot;
|
||||||
impulse = newimpulse;
|
*/
|
||||||
|
torque *= GetWorldRotation();
|
||||||
}
|
}
|
||||||
|
|
||||||
ParentGroup.setAngularImpulse(impulse);
|
Torque = torque;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1571,14 +1629,22 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
DoPhysicsPropertyUpdate(RigidBody, true);
|
DoPhysicsPropertyUpdate(RigidBody, true);
|
||||||
PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
|
PhysActor.SetVolumeDetect(VolumeDetectActive ? 1 : 0);
|
||||||
|
|
||||||
|
if (!building)
|
||||||
|
PhysActor.Building = false;
|
||||||
|
|
||||||
Velocity = velocity;
|
Velocity = velocity;
|
||||||
AngularVelocity = rotationalVelocity;
|
AngularVelocity = rotationalVelocity;
|
||||||
PhysActor.Velocity = velocity;
|
PhysActor.Velocity = velocity;
|
||||||
PhysActor.RotationalVelocity = rotationalVelocity;
|
PhysActor.RotationalVelocity = rotationalVelocity;
|
||||||
|
|
||||||
if (!building)
|
// if not vehicle and root part apply force and torque
|
||||||
PhysActor.Building = false;
|
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()
|
public Vector3 GetForce()
|
||||||
{
|
{
|
||||||
if (PhysActor != null)
|
return Force;
|
||||||
return PhysActor.Force;
|
|
||||||
else
|
|
||||||
return Vector3.Zero;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -3150,10 +3213,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public void SetBuoyancy(float fvalue)
|
public void SetBuoyancy(float fvalue)
|
||||||
{
|
{
|
||||||
|
Buoyancy = fvalue;
|
||||||
|
/*
|
||||||
if (PhysActor != null)
|
if (PhysActor != null)
|
||||||
{
|
{
|
||||||
PhysActor.Buoyancy = fvalue;
|
PhysActor.Buoyancy = fvalue;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDieAtEdge(bool p)
|
public void SetDieAtEdge(bool p)
|
||||||
|
@ -3181,10 +3247,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public void SetForce(Vector3 force)
|
public void SetForce(Vector3 force)
|
||||||
{
|
{
|
||||||
|
Force = force;
|
||||||
|
/*
|
||||||
if (PhysActor != null)
|
if (PhysActor != null)
|
||||||
{
|
{
|
||||||
PhysActor.Force = force;
|
PhysActor.Force = force;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public SOPVehicle sopVehicle
|
public SOPVehicle sopVehicle
|
||||||
|
|
|
@ -349,6 +349,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4);
|
m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4);
|
||||||
|
|
||||||
m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy);
|
m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy);
|
||||||
|
m_SOPXmlProcessors.Add("Force", ProcessForce);
|
||||||
|
m_SOPXmlProcessors.Add("Torque", ProcessTorque);
|
||||||
m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive);
|
m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive);
|
||||||
|
|
||||||
//Ubit comented until proper testing
|
//Ubit comented until proper testing
|
||||||
|
@ -762,7 +764,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
|
|
||||||
private static void ProcessBuoyancy(SceneObjectPart obj, XmlTextReader reader)
|
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)
|
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("PayPrice4", sop.PayPrice[4].ToString());
|
||||||
|
|
||||||
writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString());
|
writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString());
|
||||||
|
|
||||||
|
WriteVector(writer, "Force", sop.Force);
|
||||||
|
WriteVector(writer, "Torque", sop.Torque);
|
||||||
|
|
||||||
writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
|
writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower());
|
||||||
|
|
||||||
//Ubit comented until proper testing
|
//Ubit comented until proper testing
|
||||||
|
|
Loading…
Reference in New Issue