* ApplyPhysics now creates the PhysActor as well.

afrisby
lbsa71 2007-12-04 13:46:18 +00:00
parent 90611ebf8d
commit bf8239c7fa
2 changed files with 104 additions and 83 deletions

View File

@ -48,7 +48,8 @@ namespace OpenSim.Region.Environment.Scenes
private string m_inventoryFileName = "";
private LLUUID m_folderID = LLUUID.Zero;
[XmlIgnore] public PhysicsActor PhysActor = null;
[XmlIgnore]
public PhysicsActor PhysActor = null;
protected Dictionary<LLUUID, TaskInventoryItem> TaskInventory = new Dictionary<LLUUID, TaskInventoryItem>();
public LLUUID LastOwnerID;
@ -70,9 +71,12 @@ namespace OpenSim.Region.Environment.Scenes
protected byte[] m_particleSystem = new byte[0];
[XmlIgnore] public uint TimeStampFull = 0;
[XmlIgnore] public uint TimeStampTerse = 0;
[XmlIgnore] public uint TimeStampLastActivity = 0; // Will be used for AutoReturn
[XmlIgnore]
public uint TimeStampFull = 0;
[XmlIgnore]
public uint TimeStampTerse = 0;
[XmlIgnore]
public uint TimeStampLastActivity = 0; // Will be used for AutoReturn
/// <summary>
@ -128,16 +132,16 @@ namespace OpenSim.Region.Environment.Scenes
public uint ObjectFlags
{
get { return (uint) m_flags;}
set {m_flags = (LLObject.ObjectFlags) value;}
get { return (uint)m_flags; }
set { m_flags = (LLObject.ObjectFlags)value; }
}
protected LLObject.MaterialType m_material = 0;
public byte Material
{
get { return (byte) m_material; }
set { m_material = (LLObject.MaterialType) value; }
get { return (byte)m_material; }
set { m_material = (LLObject.MaterialType)value; }
}
protected ulong m_regionHandle;
@ -205,7 +209,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (PhysActor != null)
{
if(PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0
if (PhysActor.Orientation.x != 0 || PhysActor.Orientation.y != 0
|| PhysActor.Orientation.z != 0 || PhysActor.Orientation.w != 0)
{
m_rotationOffset.X = PhysActor.Orientation.x;
@ -243,7 +247,8 @@ namespace OpenSim.Region.Environment.Scenes
/// <summary></summary>
public LLVector3 Velocity
{
get {
get
{
//if (PhysActor.Velocity.x != 0 || PhysActor.Velocity.y != 0
//|| PhysActor.Velocity.z != 0)
//{
@ -431,12 +436,12 @@ namespace OpenSim.Region.Environment.Scenes
m_regionHandle = regionHandle;
m_parentGroup = parent;
CreationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
OwnerID = ownerID;
CreatorID = OwnerID;
LastOwnerID = LLUUID.Zero;
UUID = LLUUID.Random();
LocalID = (uint) (localID);
LocalID = (uint)(localID);
Shape = shape;
// Todo: Add More Object Parameter from above!
OwnershipCost = 0;
@ -495,7 +500,7 @@ namespace OpenSim.Region.Environment.Scenes
CreatorID = creatorID;
LastOwnerID = lastOwnerID;
UUID = LLUUID.Random();
LocalID = (uint) (localID);
LocalID = (uint)(localID);
Shape = shape;
OwnershipCost = 0;
ObjectSaleType = (byte)0;
@ -521,15 +526,31 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns>
public static SceneObjectPart FromXml(XmlReader xmlReader)
{
XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
SceneObjectPart newobject = (SceneObjectPart) serializer.Deserialize(xmlReader);
XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart));
SceneObjectPart newobject = (SceneObjectPart)serializer.Deserialize(xmlReader);
return newobject;
}
public void ApplyPhysics()
{
bool UsePhysics = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0);
DoPhysicsPropertyUpdate(UsePhysics, true);
bool isPhysical = ((ObjectFlags & (uint)LLObject.ObjectFlags.Physics) != 0);
bool isPhantom = ((ObjectFlags & (uint)LLObject.ObjectFlags.Phantom) != 0);
bool usePhysics = isPhysical && !isPhantom;
if (usePhysics)
{
PhysActor = m_parentGroup.m_scene.PhysicsScene.AddPrimShape(
Name,
Shape,
new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y,
AbsolutePosition.Z),
new PhysicsVector(Scale.X, Scale.Y, Scale.Z),
new Quaternion(RotationOffset.W, RotationOffset.X,
RotationOffset.Y, RotationOffset.Z), usePhysics);
}
DoPhysicsPropertyUpdate(usePhysics, true);
}
public void ApplyPermissions()
@ -557,7 +578,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <param name="xmlWriter"></param>
public void ToXml(XmlWriter xmlWriter)
{
XmlSerializer serializer = new XmlSerializer(typeof (SceneObjectPart));
XmlSerializer serializer = new XmlSerializer(typeof(SceneObjectPart));
serializer.Serialize(xmlWriter, this);
}
@ -613,7 +634,7 @@ namespace OpenSim.Region.Environment.Scenes
//radius = radius;
float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z -(2.0f * (tmVal6.x + tmVal6.y + tmVal6.z + (radius * radius)));
float itestPart3 = tmVal4.x + tmVal4.y + tmVal4.z + tmVal5.x + tmVal5.y + tmVal5.z - (2.0f * (tmVal6.x + tmVal6.y + tmVal6.z + (radius * radius)));
// Yuk Quadradrics.. Solve first
float rootsqr = (itestPart2 * itestPart2) - (4.0f * itestPart1 * itestPart3);
@ -639,19 +660,19 @@ namespace OpenSim.Region.Environment.Scenes
// We got an intersection. putting together an EntityIntersection object with the
// intersection information
Vector3 ipoint = new Vector3(iray.Origin.x + (iray.Direction.x * root),iray.Origin.y + (iray.Direction.y * root),iray.Origin.z + (iray.Direction.z * root));
Vector3 ipoint = new Vector3(iray.Origin.x + (iray.Direction.x * root), iray.Origin.y + (iray.Direction.y * root), iray.Origin.z + (iray.Direction.z * root));
returnresult.HitTF = true;
returnresult.ipoint = ipoint;
// Normal is calculated by the difference and then normalizing the result
Vector3 normalpart = ipoint-vAbsolutePosition;
Vector3 normalpart = ipoint - vAbsolutePosition;
returnresult.normal = normalpart.Normalize();
// It's funny how the LLVector3 object has a Distance function, but the Axiom.Math object doesnt.
// I can write a function to do it.. but I like the fact that this one is Static.
LLVector3 distanceConvert1 = new LLVector3(iray.Origin.x,iray.Origin.y,iray.Origin.z);
LLVector3 distanceConvert1 = new LLVector3(iray.Origin.x, iray.Origin.y, iray.Origin.z);
LLVector3 distanceConvert2 = new LLVector3(ipoint.x, ipoint.y, ipoint.z);
float distance = (float)distanceConvert1.GetDistanceTo(distanceConvert2);
@ -687,7 +708,7 @@ namespace OpenSim.Region.Environment.Scenes
/// <returns></returns>
public SceneObjectPart Copy(uint localID, LLUUID AgentID, LLUUID GroupID)
{
SceneObjectPart dupe = (SceneObjectPart) MemberwiseClone();
SceneObjectPart dupe = (SceneObjectPart)MemberwiseClone();
dupe.m_shape = m_shape.Copy();
dupe.m_regionHandle = m_regionHandle;
dupe.UUID = LLUUID.Random();
@ -741,7 +762,7 @@ namespace OpenSim.Region.Environment.Scenes
{
m_parentGroup.HasChanged = true;
}
TimeStampFull = (uint) Util.UnixTimeSinceEpoch();
TimeStampFull = (uint)Util.UnixTimeSinceEpoch();
m_updateFlag = 2;
}
@ -749,7 +770,7 @@ namespace OpenSim.Region.Environment.Scenes
{
LLObject.ObjectFlags prevflag = m_flags;
//uint objflags = m_flags;
if ((ObjectFlags & (uint) flag) == 0)
if ((ObjectFlags & (uint)flag) == 0)
{
//Console.WriteLine("Adding flag: " + ((LLObject.ObjectFlags) flag).ToString());
m_flags |= flag;
@ -757,7 +778,7 @@ namespace OpenSim.Region.Environment.Scenes
GroupMask |= (uint)flag;
EveryoneMask |= (uint)flag;
}
uint currflag = (uint) m_flags;
uint currflag = (uint)m_flags;
//System.Console.WriteLine("Aprev: " + prevflag.ToString() + " curr: " + m_flags.ToString());
//ScheduleFullUpdate();
}
@ -765,7 +786,7 @@ namespace OpenSim.Region.Environment.Scenes
public void RemFlag(LLObject.ObjectFlags flag)
{
LLObject.ObjectFlags prevflag = m_flags;
if ((ObjectFlags & (uint) flag) != 0)
if ((ObjectFlags & (uint)flag) != 0)
{
//Console.WriteLine("Removing flag: " + ((LLObject.ObjectFlags)flag).ToString());
m_flags &= ~flag;
@ -788,7 +809,7 @@ namespace OpenSim.Region.Environment.Scenes
{
m_parentGroup.HasChanged = true;
}
TimeStampTerse = (uint) Util.UnixTimeSinceEpoch();
TimeStampTerse = (uint)Util.UnixTimeSinceEpoch();
m_updateFlag = 1;
}
}
@ -898,7 +919,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (m_inventorySerial > 0)
{
client.SendTaskInventory(m_uuid, (short) m_inventorySerial,
client.SendTaskInventory(m_uuid, (short)m_inventorySerial,
Helpers.StringToField(m_inventoryFileName));
return true;
}
@ -981,12 +1002,12 @@ namespace OpenSim.Region.Environment.Scenes
//Silently ignore it - TODO: FIXME Quick
}
if (usePhysics )
if (usePhysics)
{
AddFlag(LLObject.ObjectFlags.Physics);
if (!wasUsingPhysics)
{
DoPhysicsPropertyUpdate(usePhysics,false);
DoPhysicsPropertyUpdate(usePhysics, false);
}
}
@ -1031,7 +1052,7 @@ namespace OpenSim.Region.Environment.Scenes
else
{
PhysActor.IsPhysical = usePhysics;
DoPhysicsPropertyUpdate(usePhysics,false);
DoPhysicsPropertyUpdate(usePhysics, false);
}
}
@ -1043,7 +1064,7 @@ namespace OpenSim.Region.Environment.Scenes
{
RemFlag(LLObject.ObjectFlags.TemporaryOnRez);
}
// System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
// System.Console.WriteLine("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());
ScheduleFullUpdate();
}
public void DoPhysicsPropertyUpdate(bool UsePhysics, bool isNew)
@ -1092,15 +1113,15 @@ namespace OpenSim.Region.Environment.Scenes
{
m_shape.ExtraParams = new byte[data.Length + 7];
int i = 0;
uint length = (uint) data.Length;
uint length = (uint)data.Length;
m_shape.ExtraParams[i++] = 1;
m_shape.ExtraParams[i++] = (byte) (type%256);
m_shape.ExtraParams[i++] = (byte) ((type >> 8)%256);
m_shape.ExtraParams[i++] = (byte)(type % 256);
m_shape.ExtraParams[i++] = (byte)((type >> 8) % 256);
m_shape.ExtraParams[i++] = (byte) (length%256);
m_shape.ExtraParams[i++] = (byte) ((length >> 8)%256);
m_shape.ExtraParams[i++] = (byte) ((length >> 16)%256);
m_shape.ExtraParams[i++] = (byte) ((length >> 24)%256);
m_shape.ExtraParams[i++] = (byte)(length % 256);
m_shape.ExtraParams[i++] = (byte)((length >> 8) % 256);
m_shape.ExtraParams[i++] = (byte)((length >> 16) % 256);
m_shape.ExtraParams[i++] = (byte)((length >> 24) % 256);
Array.Copy(data, 0, m_shape.ExtraParams, i, data.Length);
ScheduleFullUpdate();
@ -1234,7 +1255,7 @@ namespace OpenSim.Region.Environment.Scenes
{
LLQuaternion lRot;
lRot = RotationOffset;
uint clientFlags = ObjectFlags & ~(uint) LLObject.ObjectFlags.CreateSelected;
uint clientFlags = ObjectFlags & ~(uint)LLObject.ObjectFlags.CreateSelected;
List<ScenePresence> avatars = m_parentGroup.GetScenePresences();
foreach (ScenePresence s in avatars)
@ -1267,12 +1288,12 @@ namespace OpenSim.Region.Environment.Scenes
clientFlags = ObjectFlags;
if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanCopyPermission(remoteClient.AgentId, this.ParentGroup.UUID))
{
clientFlags = (clientFlags &= ~(uint) LLObject.ObjectFlags.ObjectCopy);
clientFlags = (clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectCopy);
}
if (!ParentGroup.m_scene.PermissionsMngr.AnyoneCanMovePermission(remoteClient.AgentId, this.ParentGroup.UUID))
{
clientFlags = clientFlags &= ~(uint) LLObject.ObjectFlags.ObjectMove;
clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectMove;
}
clientFlags = EveryoneMask;
clientFlags = clientFlags &= ~(uint)LLObject.ObjectFlags.ObjectModify;
@ -1374,7 +1395,7 @@ namespace OpenSim.Region.Environment.Scenes
{
OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS", "Physical Object went out of bounds.");
RemFlag(LLObject.ObjectFlags.Physics);
DoPhysicsPropertyUpdate(false,true);
DoPhysicsPropertyUpdate(false, true);
m_parentGroup.m_scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
@ -1387,7 +1408,7 @@ namespace OpenSim.Region.Environment.Scenes
public void SetText(string text, Vector3 color, double alpha)
{
Color = Color.FromArgb (0xff - (int)(alpha * 0xff),
Color = Color.FromArgb(0xff - (int)(alpha * 0xff),
(int)(color.x * 0xff),
(int)(color.y * 0xff),
(int)(color.z * 0xff));