/Aurora/Region/SceneObjectPart.cs
C# | 5027 lines | 3865 code | 578 blank | 584 comment | 942 complexity | fdcecf184a40ea269bf0a51eedb27a9b MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- /*
- * Copyright (c) Contributors, http://aurora-sim.org/, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the Aurora-Sim Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
- using Aurora.Framework;
- using Aurora.Framework.ClientInterfaces;
- using Aurora.Framework.ConsoleFramework;
- using Aurora.Framework.Modules;
- using Aurora.Framework.Physics;
- using Aurora.Framework.PresenceInfo;
- using Aurora.Framework.SceneInfo;
- using Aurora.Framework.SceneInfo.Entities;
- using Aurora.Framework.Serialization;
- using Aurora.Framework.Services.ClassHelpers.Assets;
- using Aurora.Framework.Utilities;
- using OpenMetaverse;
- using OpenMetaverse.Packets;
- using OpenMetaverse.StructuredData;
- using ProtoBuf;
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Xml;
- using System.Xml.Serialization;
- using PrimType = Aurora.Framework.SceneInfo.PrimType;
-
- namespace Aurora.Region
- {
- [Serializable, ProtoContract()]
- public class SceneObjectPart : ISceneChildEntity
- {
- /// <value>
- /// Denote all sides of the prim
- /// </value>
- public const int ALL_SIDES = -1;
-
- public virtual Quaternion GroupRotation
- {
- get { return ParentGroup.GroupRotation; }
- }
-
- #region ISceneChildEntity Members
-
- /// <value>
- /// Is this sop a root part?
- /// </value>
- [XmlIgnore]
- public bool IsRoot
- {
- get { return ParentGroup.RootPart == this; }
- }
-
- public virtual Quaternion Rotation
- {
- get { return ParentGroup.GroupRotation; }
- set { }
- }
-
- //---------------
-
- public void ApplyNextOwnerPermissions()
- {
- _baseMask &= _nextOwnerMask;
- _ownerMask &= _nextOwnerMask;
- _everyoneMask &= _nextOwnerMask;
-
- Inventory.ApplyNextOwnerPermissions();
- }
-
- public Color4 GetTextColor()
- {
- Color color = Color;
- return new Color4(color.R, color.G, color.B, (byte) (0xFF - color.A));
- }
-
- public void SetSoundQueueing(int queue)
- {
- UseSoundQueue = queue;
- }
-
- public void SetConeOfSilence(double radius)
- {
- ISoundModule module = m_parentGroup.Scene.RequestModuleInterface<ISoundModule>();
- //TODO: Save SetConeOfSilence
- if (module != null)
- {
- if (radius != 0)
- module.AddConeOfSilence(UUID, AbsolutePosition, radius);
- else
- module.RemoveConeOfSilence(UUID);
- }
- }
-
- #endregion
-
- #region Fields
-
- private readonly List<uint> m_lastColliders = new List<uint>();
- [XmlIgnore] public scriptEvents AggregateScriptEvents;
- [XmlIgnore] public bool IgnoreUndoUpdate;
- [XmlIgnore] public bool IsWaitingForFirstSpinUpdatePacket;
- [XmlIgnore] private PrimFlags LocalFlags;
- [XmlIgnore] public Vector3 RotationAxis = Vector3.One;
- [XmlIgnore] public Quaternion SpinOldOrientation = Quaternion.Identity;
- [XmlIgnore] public uint TimeStampLastActivity; // Will be used for AutoReturn
-
- [XmlIgnore]
- public bool Undoing { get; set; }
-
- private UUID _creatorID;
-
- [XmlIgnore] private UUID m_AttachedAvatar;
- [XmlIgnore] private Dictionary<int, string> m_CollisionFilter = new Dictionary<int, string>();
- [XmlIgnore] private bool m_IsAttachment;
- [XmlIgnore] private bool m_IsSelected;
- [XmlIgnore] private int[] m_PayPrice = {-2, -2, -2, -2, -2};
- [XmlIgnore] private bool m_ValidpartOOB; // control recalcutation
- protected Vector3 m_acceleration;
- protected Vector3 m_angularVelocity;
- private byte m_clickAction;
- private UUID m_collisionSound;
- private float m_collisionSoundVolume;
- private UUID m_collisionSprite;
- protected uint m_crc;
- private string m_creatorData = string.Empty;
- private string m_description = String.Empty;
- protected Vector3 m_groupPosition;
- private Vector3 m_initialPIDLocation = Vector3.Zero;
- protected SceneObjectPartInventory m_inventory;
- protected Vector3 m_lastAcceleration;
- protected Vector3 m_lastAngularVelocity;
- protected Vector3 m_lastGroupPosition;
- protected Vector3 m_lastPosition;
- protected Quaternion m_lastRotation;
- protected Vector3 m_lastVelocity;
- private int m_linkNum;
- protected uint m_localId;
-
- /// <summary>
- /// Stores media texture data
- /// </summary>
- protected string m_mediaUrl;
-
- protected string m_name;
- protected Vector3 m_offsetPosition;
-
- protected SceneObjectGroup m_parentGroup;
- [XmlIgnore] private float m_partBSphereRadiusSQ; // the square of the radius of a sphere containing the oob
-
- [XmlIgnore] private Vector3 m_partOOBoffset;
- // the position center of the bounding box relative to it's Position
-
- [XmlIgnore] private Vector3 m_partOOBsize;
- // the size of a bounding box oriented as prim, is future will consider cutted prims, meshs etc
-
- protected byte[] m_particleSystem = Utils.EmptyBytes;
- private int m_passTouches;
-
- private PhysicsObject m_physActor;
- private bool m_pidActive;
- private bool m_pidhoverActive;
- private UndoStack<UndoState> m_redo = new UndoStack<UndoState>(5);
- protected ulong m_regionHandle;
- [XmlIgnore] private int m_scriptAccessPin;
- [XmlIgnore] private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>();
- protected PrimitiveBaseShape m_shape;
- private string m_sitAnimation = "SIT";
- private string m_sitName = String.Empty;
- private UUID m_sound;
- private string m_text = String.Empty;
- private string m_touchName = String.Empty;
- private UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5);
- protected UUID m_uuid;
- private bool m_volumeDetectActive;
-
- [XmlIgnore]
- [ProtoMember(92)]
- public bool RETURN_AT_EDGE { get; set; }
-
- [XmlIgnore]
- [ProtoMember(93)]
- public bool BlockGrab { get; set; }
-
- [XmlIgnore]
- [ProtoMember(94)]
- public bool BlockGrabObject { get; set; }
-
- [XmlIgnore]
- public bool IsLoading { get; set; }
-
- [XmlIgnore]
- [ProtoMember(96)]
- public bool StatusSandbox { get; set; }
-
- [XmlIgnore]
- [ProtoMember(97)]
- public Vector3 StatusSandboxPos { get; set; }
-
- [XmlIgnore]
- [ProtoMember(98)]
- public int STATUS_ROTATE_X { get; set; }
-
- [XmlIgnore]
- [ProtoMember(99)]
- public int STATUS_ROTATE_Y { get; set; }
-
- [XmlIgnore]
- [ProtoMember(100)]
- public int STATUS_ROTATE_Z { get; set; }
-
- [XmlIgnore]
- public bool ValidpartOOB
- {
- set { m_ValidpartOOB = value; }
- }
-
- // the size of a bounding box oriented as the prim, is future will consider cutted prims, meshs etc
- [XmlIgnore]
- public Vector3 OOBsize
- {
- get
- {
- if (!m_ValidpartOOB)
- UpdateOOBfromOOBs();
- return m_partOOBsize;
- }
- }
-
- // the position center of the bounding box relative to it's Position
- // on complex forms this will not be zero
- [XmlIgnore]
- public Vector3 OOBoffset
- {
- get
- {
- if (!m_ValidpartOOB)
- UpdateOOBfromOOBs();
- return m_partOOBoffset;
- }
- }
-
- // the square of the radius of a sphere containing the oobb
- [XmlIgnore]
- public float BSphereRadiusSQ
- {
- get
- {
- if (!m_ValidpartOOB)
- UpdateOOBfromOOBs();
- return m_partBSphereRadiusSQ;
- }
- }
-
- [ProtoMember(1)]
- public bool AllowedDrop { get; set; }
-
- [XmlIgnore]
- [ProtoMember(91)]
- public bool DIE_AT_EDGE { get; set; }
-
- [XmlIgnore]
- [ProtoMember(90)]
- public int UseSoundQueue { get; set; }
-
- [ProtoMember(70, OverwriteList = true)]
- public int[] PayPrice
- {
- get { return m_PayPrice; }
- set { m_PayPrice = value; }
- }
-
- [XmlIgnore]
- public PhysicsObject PhysActor
- {
- get { return m_physActor; }
- set
- {
- // MainConsole.Instance.DebugFormat("[SOP]: PhysActor set to {0} for {1} {2}", value, Name, UUID);
- m_physActor = value;
- }
- }
-
- [XmlIgnore]
- [ProtoMember(71)]
- public UUID Sound
- {
- get { return m_sound; }
- set { m_sound = value; }
- }
-
- [XmlIgnore]
- [ProtoMember(72)]
- public byte SoundFlags { get; set; }
-
- [XmlIgnore]
- [ProtoMember(73)]
- public double SoundGain { get; set; }
-
- [XmlIgnore]
- [ProtoMember(74)]
- public double SoundRadius { get; set; }
-
- [XmlIgnore]
- [ProtoMember(75)]
- public Vector3 PIDTarget { get; set; }
-
- [XmlIgnore]
- [ProtoMember(76)]
- public bool PIDActive
- {
- get { return m_pidActive; }
- set
- {
- IScene s = ParentGroup == null ? null : ParentGroup.Scene ?? null;
- if (s != null)
- {
- if (value)
- s.EventManager.OnFrame += UpdateLookAt;
- else
- s.EventManager.OnFrame -= UpdateLookAt;
- }
- m_pidActive = value;
- }
- }
-
- [XmlIgnore]
- [ProtoMember(77)]
- public float PIDTau { get; set; }
-
- [ProtoMember(78)]
- public float PIDHoverHeight { get; set; }
-
- [ProtoMember(79)]
- public float PIDHoverTau { get; set; }
-
- [ProtoMember(80)]
- public bool PIDHoverActive
- {
- get { return m_pidhoverActive; }
- set { m_pidhoverActive = value; }
- }
-
- [ProtoMember(81)]
- public PIDHoverType PIDHoverType { get; set; }
-
- [XmlIgnore]
- [ProtoMember(82)]
- public UUID FromUserInventoryItemID { get; set; }
-
- [XmlIgnore]
- [ProtoMember(83)]
- public UUID FromUserInventoryAssetID { get; set; }
-
- [XmlIgnore]
- public bool IsAttachment
- {
- get { return m_IsAttachment; }
- set { m_IsAttachment = value; }
- }
-
- [XmlIgnore]
- public UUID AttachedAvatar
- {
- get { return m_AttachedAvatar; }
- set { m_AttachedAvatar = value; }
- }
-
- [XmlIgnore]
- public Vector3 AttachedPos { get; set; }
-
- /// <summary>
- /// NOTE: THIS WILL NOT BE UP TO DATE AS THEY WILL BE ONE REV BEHIND
- /// Used to save attachment pos and point over rezzing/taking
- /// </summary>
- [XmlIgnore]
- public int AttachmentPoint { get; set; }
-
- /// <summary>
- /// NOTE: THIS WILL NOT BE UP TO DATE AS THEY WILL BE ONE REV BEHIND
- /// Used to save attachment pos and point over rezzing/taking
- /// </summary>
- [ProtoMember(84)]
- public Vector3 SavedAttachedPos { get; set; }
-
-
- [ProtoMember(85)]
- public int SavedAttachmentPoint { get; set; }
-
- [XmlIgnore]
- [ProtoMember(86)]
- public bool VolumeDetectActive
- {
- get { return m_volumeDetectActive; }
- set { m_volumeDetectActive = value; }
- }
-
- /// <summary>
- /// This part's inventory
- /// </summary>
- [XmlIgnore]
- public IEntityInventory Inventory
- {
- get { return m_inventory; }
- }
-
- [ProtoMember(87)]
- public Vector3 CameraEyeOffset { get; set; }
-
- [ProtoMember(88)]
- public Vector3 CameraAtOffset { get; set; }
-
- [ProtoMember(89)]
- public bool ForceMouselook { get; set; }
-
- [ProtoMember(102)]
- public KeyframeAnimation KeyframeAnimation { get; set; }
-
- [ProtoMember(103)]
- public Dictionary<UUID, StateSave> StateSaves { get; set; }
-
- public Vector3 GroupScale()
- {
- return m_parentGroup.GroupScale();
- }
-
- #endregion Fields
-
- #region Constructors
-
- /// <summary>
- /// No arg constructor called by region restore db code
- /// </summary>
- public SceneObjectPart()
- {
- SitTargetAvatar = new List<UUID>();
- StateSaves = new Dictionary<UUID, StateSave>();
-
- m_inventory = new SceneObjectPartInventory(this);
- m_shape = new PrimitiveBaseShape();
- Material = (int) OpenMetaverse.Material.Wood;
- }
-
- /// <summary>
- /// Create a completely new SceneObjectPart (prim). This will need to be added separately to a SceneObjectGroup
- /// </summary>
- /// <param name="ownerID"></param>
- /// <param name="shape"></param>
- /// <param name="groupPosition"></param>
- /// <param name="rotationOffset"></param>
- /// <param name="offsetPosition"></param>
- /// <param name="name"></param>
- public SceneObjectPart(
- UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition,
- Quaternion rotationOffset, Vector3 offsetPosition, string name)
- {
- m_name = name;
-
- CreationDate = (int) Utils.DateTimeToUnixTime(DateTime.Now);
- _ownerID = ownerID;
- _creatorID = _ownerID;
- LastOwnerID = UUID.Zero;
- UUID = UUID.Random();
- Shape = shape;
- CRC = 1;
- _ownershipCost = 0;
- _flags = 0;
- _groupID = UUID.Zero;
- _objectSaleType = 0;
- _salePrice = 0;
- _category = 0;
- LastOwnerID = _creatorID;
- m_groupPosition = groupPosition;
- m_offsetPosition = offsetPosition;
- RotationOffset = rotationOffset;
- Velocity = Vector3.Zero;
- AngularVelocity = Vector3.Zero;
- Acceleration = Vector3.Zero;
- SitTargetAvatar = new List<UUID>();
- StateSaves = new Dictionary<UUID, StateSave>();
-
- ValidpartOOB = false;
-
- // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
- // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
- // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log
-
- Flags = 0;
- CreateSelected = true;
-
- TrimPermissions();
- //m_undo = new UndoStack<UndoState>(ParentGroup.GetSceneMaxUndo());
-
- m_inventory = new SceneObjectPartInventory(this);
- Material = (int) OpenMetaverse.Material.Wood;
- }
-
- public override int GetHashCode()
- {
- return UUID.GetHashCode();
- }
-
- #endregion Constructors
-
- #region XML Schema
-
- private uint _baseMask = (uint) PermissionMask.All;
- private uint _category;
- private uint _everyoneMask = (uint) PermissionMask.None;
- private PrimFlags _flags = PrimFlags.None;
- private UUID _groupID;
- private uint _groupMask = (uint) PermissionMask.None;
- private uint _nextOwnerMask = (uint) PermissionMask.All;
- private byte _objectSaleType;
- private UUID _ownerID;
- private uint _ownerMask = (uint) PermissionMask.All;
- private int _ownershipCost;
- private uint _parentID;
- private int _salePrice;
- private List<SceneObjectPart> m_LoopSoundSlavePrims = new List<SceneObjectPart>();
- private byte[] m_ParticleSystem;
- private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
- private string m_currentMediaVersion = "x-mv:0000000001/00000000-0000-0000-0000-000000000000";
- private int m_passCollision;
- private byte[] m_textureAnimation;
-
- [XmlIgnore]
- public string CurrentMediaVersion
- {
- get { return m_currentMediaVersion; }
- set { m_currentMediaVersion = value; }
- }
-
- /// <summary>
- /// Used by the DB layer to retrieve / store the entire user identification.
- /// The identification can either be a simple UUID or a string of the form
- /// uuid[;profile_url[;name]]
- /// </summary>
- public string CreatorIdentification
- {
- get
- {
- if (!string.IsNullOrEmpty(m_creatorData))
- return _creatorID.ToString() + ';' + m_creatorData;
- else
- return _creatorID.ToString();
- }
- set
- {
- if ((value == null) || (value != null && value == string.Empty))
- {
- m_creatorData = string.Empty;
- return;
- }
-
- if (!value.Contains(";")) // plain UUID
- {
- UUID uuid = UUID.Zero;
- UUID.TryParse(value, out uuid);
- _creatorID = uuid;
- }
- else // <uuid>[;<endpoint>[;name]]
- {
- string name = "Unknown User";
- string[] parts = value.Split(';');
- if (parts.Length >= 1)
- {
- UUID uuid = UUID.Zero;
- UUID.TryParse(parts[0], out uuid);
- _creatorID = uuid;
- }
- if (parts.Length >= 2)
- m_creatorData = parts[1];
- if (parts.Length >= 3)
- name = parts[2];
-
- m_creatorData += ';' + name;
- }
- }
- }
-
- /// <summary>
- /// This is idential to the Flags property, except that the returned value is uint rather than PrimFlags
- /// </summary>
- [Obsolete("Use Flags property instead")]
- public uint ObjectFlags
- {
- get { return (uint) Flags; }
- set
- {
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- Flags = (PrimFlags) value;
- }
- }
-
- private Quaternion m_APIDTarget;
-
- [XmlIgnore, ProtoMember(65)]
- public Quaternion APIDTarget
- {
- get { return m_APIDTarget; }
- set
- {
- IScene s = ParentGroup == null ? null : ParentGroup.Scene ?? null;
- if (s != null)
- {
- if (value != Quaternion.Identity)
- s.EventManager.OnFrame += UpdateLookAt;
- else
- s.EventManager.OnFrame -= UpdateLookAt;
- }
- m_APIDTarget = value;
- }
- }
-
- [XmlIgnore, ProtoMember(66)]
- public float APIDDamp { get; set; }
-
- [XmlIgnore, ProtoMember(67)]
- public float APIDStrength { get; set; }
-
- [ProtoMember(68)]
- public int APIDIterations { get; set; }
-
- [ProtoMember(69)]
- public bool APIDEnabled { get; set; }
-
- [XmlIgnore]
- public SceneObjectPart PlaySoundMasterPrim { get; set; }
-
- [XmlIgnore]
- public List<SceneObjectPart> PlaySoundSlavePrims
- {
- get { return m_PlaySoundSlavePrims; }
- set { m_PlaySoundSlavePrims = value; }
- }
-
- [XmlIgnore]
- public SceneObjectPart LoopSoundMasterPrim { get; set; }
-
- [XmlIgnore]
- public List<SceneObjectPart> LoopSoundSlavePrims
- {
- get { return m_LoopSoundSlavePrims; }
- set { m_LoopSoundSlavePrims = value; }
- }
-
- [XmlIgnore, ProtoMember(64)]
- public float Damage { get; set; }
-
- public Vector3 RelativePosition
- {
- get
- {
- if (IsRoot)
- {
- if (IsAttachment)
- return OffsetPosition;
- else
- return AbsolutePosition;
- }
- else
- {
- return OffsetPosition;
- }
- }
- }
-
- [ProtoMember(2)]
- public UUID CreatorID
- {
- get { return _creatorID; }
- set { _creatorID = value; }
- }
-
- /// <summary>
- /// Data about the creator in the form profile_url;name
- /// </summary>
- [ProtoMember(3)]
- public string CreatorData
- {
- get { return m_creatorData; }
- set { m_creatorData = value; }
- }
-
- /// <value>
- /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes
- /// </value>
- [ProtoMember(4)]
- public uint InventorySerial
- {
- get { return m_inventory.Serial; }
- set { m_inventory.Serial = value; }
- }
-
- /// <value>
- /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes
- /// </value>
- [ProtoMember(5)]
- public TaskInventoryDictionary TaskInventory
- {
- get { return m_inventory.Items; }
- set { m_inventory.Items = value; }
- }
-
- [ProtoMember(6)]
- public UUID UUID
- {
- get { return m_uuid; }
- set
- {
- UUID oldID = m_uuid;
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_uuid = value;
-
- // This is necessary so that TaskInventoryItem parent ids correctly reference the new uuid of this part
- if (Inventory != null)
- Inventory.ResetObjectID();
- }
- }
-
- [ProtoMember(7)]
- public uint LocalId
- {
- get { return m_localId; }
- set { m_localId = value; }
- }
-
- [XmlIgnore]
- public uint CRC { get; set; }
-
- [ProtoMember(8)]
- public virtual string Name
- {
- get { return m_name; }
- set
- {
- if (m_name != value)
- {
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_name = value;
- }
- }
- }
-
- [ProtoMember(9)]
- public int Material { get; set; }
-
- public void UpdateMaterial(int val)
- {
- if (Material == val)
- return;
-
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
-
- Material = val;
- if (PhysActor != null)
- PhysActor.SetMaterial(val, true);
- }
-
- [ProtoMember(10)]
- public int PassTouch
- {
- get { return m_passTouches; }
- set
- {
- m_passTouches = value;
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- }
- }
-
- [ProtoMember(11)]
- public int PassCollisions
- {
- get { return m_passCollision; }
- set
- {
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_passCollision = value;
- }
- }
-
-
- [XmlIgnore, ProtoMember(12)]
- public Dictionary<int, string> CollisionFilter
- {
- get { return m_CollisionFilter; }
- set
- {
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_CollisionFilter = value;
- }
- }
-
- [ProtoMember(13)]
- public int ScriptAccessPin
- {
- get { return m_scriptAccessPin; }
- set { m_scriptAccessPin = value; }
- }
-
- [ProtoMember(60, OverwriteList = true)]
- public Byte[] TextureAnimation
- {
- get { return m_textureAnimation; }
- set { m_textureAnimation = value; }
- }
-
- [XmlIgnore]
- [ProtoMember(61, OverwriteList = true)]
- public Byte[] ParticleSystem
- {
- get { return m_ParticleSystem; }
- set { m_ParticleSystem = value; }
- }
-
- [XmlIgnore, ProtoMember(62)]
- public DateTime Expires { get; set; }
-
- [XmlIgnore, ProtoMember(63)]
- public DateTime Rezzed { get; set; }
-
- /// <summary>
- /// The position of the entire group that this prim belongs to.
- /// </summary>
- [ProtoMember(14)]
- public Vector3 GroupPosition
- {
- get { return GetGroupPosition(); }
- set { FixGroupPosition(value, false); }
- }
-
- public Vector3 GetGroupPosition()
- {
- // If this is a linkset, we don't want the physics engine mucking up our group position here.
- PhysicsObject actor = PhysActor;
- if (actor != null && _parentID == 0)
- {
- m_groupPosition = actor.Position;
- }
-
- if (IsAttachment)
- {
- IScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar);
- if (sp != null)
- return sp.AbsolutePosition;
- }
-
- return m_groupPosition;
- }
-
- [ProtoMember(15)]
- public Vector3 OffsetPosition
- {
- get { return m_offsetPosition; }
- set
- {
- m_offsetPosition = value;
- ValidpartOOB = false;
- }
- }
-
- [ProtoMember(16)]
- public Quaternion RotationOffset { get; set; }
-
- public Quaternion GetRotationOffset()
- {
- PhysicsObject actor = m_physActor;
- if (_parentID == 0 && (m_shape.PCode != 9 || m_shape.State == 0) && actor != null)
- {
- if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f
- || actor.Orientation.Z != 0f || actor.Orientation.W != 0f)
- {
- RotationOffset = actor.Orientation;
- }
- }
- return RotationOffset;
- }
-
- private Vector3 m_tempVelocity = Vector3.Zero;
-
- /// <summary>
- /// </summary>
- [ProtoMember(17)]
- public Vector3 Velocity
- {
- get
- {
- PhysicsObject actor = PhysActor;
- if (actor != null)
- {
- if (actor.IsPhysical)
- {
- return actor.Velocity;
- }
- }
-
- return m_tempVelocity;
- }
-
- set
- {
- PhysicsObject actor = PhysActor;
- if (actor != null)
- {
- if (actor.IsPhysical)
- {
- actor.Velocity = value;
- m_tempVelocity = Vector3.Zero;
- }
- else
- m_tempVelocity = value;
- }
- else
- m_tempVelocity = value;
- }
- }
-
- /// <summary>
- /// </summary>
- [ProtoMember(18)]
- public Vector3 AngularVelocity
- {
- get
- {
- PhysicsObject actor = PhysActor;
- if ((actor != null) && actor.IsPhysical)
- {
- m_angularVelocity = actor.RotationalVelocity;
- }
- return m_angularVelocity;
- }
- set { m_angularVelocity = value; }
- }
-
- public void GenerateRotationalVelocityFromOmega()
- {
- if (OmegaGain == 0.0f) //Disable spin
- AngularVelocity = Vector3.Zero;
- else
- AngularVelocity = new Vector3((float) (OmegaAxis.X*OmegaSpinRate),
- (float) (OmegaAxis.Y*OmegaSpinRate),
- (float) (OmegaAxis.Z*OmegaSpinRate));
- }
-
- /// <summary>
- /// </summary>
- [ProtoMember(19)]
- public Vector3 Acceleration
- {
- get { return m_acceleration; }
- set { m_acceleration = value; }
- }
-
- [ProtoMember(20)]
- public string Description
- {
- get { return m_description; }
- set
- {
- if (m_description == value)
- return;
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_description = value;
- }
- }
-
- /// <value>
- /// Text color.
- /// </value>
- [XmlIgnore]
- [ProtoMember(21)]
- public Color Color { get; set; }
-
- public void UpdateColor(Color c, bool triggerChangedColor)
- {
- if (c.A != Color.A ||
- c.B != Color.B ||
- c.G != Color.G ||
- c.R != Color.R)
- {
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- Color = c;
- if (triggerChangedColor)
- TriggerScriptChangedEvent(Changed.COLOR);
-
- /* ScheduleFullUpdate() need not be called b/c after
- * setting the color, the text will be set, so then
- * ScheduleFullUpdate() will be called. */
- //ScheduleFullUpdate();
- }
- }
-
- [ProtoMember(22)]
- public string Text
- {
- get
- {
- string returnstr = m_text;
- if (returnstr.Length > 255)
- {
- returnstr = returnstr.Substring(0, 254);
- }
- return returnstr;
- }
- set
- {
- if (m_text == value)
- return;
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_text = value;
- }
- }
-
-
- [ProtoMember(23)]
- public string SitName
- {
- get { return m_sitName; }
- set
- {
- if (m_sitName == value)
- return;
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_sitName = value;
- }
- }
-
- [ProtoMember(24)]
- public string TouchName
- {
- get { return m_touchName; }
- set
- {
- if (m_touchName == value)
- return;
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_touchName = value;
- }
- }
-
- [ProtoMember(25)]
- public int LinkNum
- {
- get { return m_linkNum; }
- set
- {
- if (m_linkNum == value)
- return;
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_linkNum = value;
- }
- }
-
- [ProtoMember(26)]
- public byte ClickAction
- {
- get { return m_clickAction; }
- set
- {
- if (m_clickAction == value)
- return;
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_clickAction = value;
- }
- }
-
- [ProtoMember(27)]
- public PrimitiveBaseShape Shape
- {
- get { return m_shape; }
- set
- {
- ValidpartOOB = false;
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- bool shape_changed = false;
- // TODO: this should really be restricted to the right
- // set of attributes on shape change. For instance,
- // changing the lighting on a shape shouldn't cause
- // this.
- if (m_shape != null)
- shape_changed = true;
-
- m_shape = value;
-
- if (shape_changed)
- TriggerScriptChangedEvent(Changed.SHAPE);
- }
- }
-
- public Vector3 Scale
- {
- get { return m_shape.Scale; }
- set
- {
- ValidpartOOB = false;
- if (m_shape != null)
- {
- if (m_shape.Scale != value)
- {
- StoreUndoState();
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
-
- m_shape.Scale = value;
-
- PhysicsActor actor = PhysActor;
- if (actor != null && m_parentGroup != null &&
- m_parentGroup.Scene != null &&
- m_parentGroup.Scene.PhysicsScene != null)
- actor.Size = m_shape.Scale;
- TriggerScriptChangedEvent(Changed.SCALE);
- }
- }
- }
- }
-
- /// <summary>
- /// Used for media on a prim.
- /// </summary>
- /// Do not change this value directly - always do it through an IMoapModule.
- [ProtoMember(29)]
- public string MediaUrl
- {
- get { return m_mediaUrl; }
-
- set
- {
- if (m_mediaUrl == value)
- return;
- m_mediaUrl = value;
-
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- }
- }
-
- [XmlIgnore]
- public bool CreateSelected { get; set; }
-
- [XmlIgnore]
- public bool IsSelected
- {
- get { return m_IsSelected; }
- set
- {
- if (m_IsSelected != value)
- {
- if (PhysActor != null)
- {
- PhysActor.Selected = value;
- }
- if (ParentID != 0 && ParentGroup != null &&
- ParentGroup.RootPart != null && ParentGroup.RootPart != this &&
- ParentGroup.RootPart.IsSelected != value)
- ParentGroup.RootPart.IsSelected = value;
-
- m_IsSelected = value;
- }
- }
- }
-
- #endregion
-
- #region Public Properties with only Get
-
- private UUID _parentUUID = UUID.Zero;
- private float m_friction;
- private float m_density;
- private float m_gravityMultiplier;
- private float m_restitution;
-
- public SceneObjectGroup ParentGroup
- {
- get { return m_parentGroup; }
- }
-
- public scriptEvents ScriptEvents
- {
- get { return AggregateScriptEvents; }
- }
-
- public bool Stopped
- {
- get
- {
- double threshold = 0.02;
- return (Math.Abs(Velocity.X) < threshold &&
- Math.Abs(Velocity.Y) < threshold &&
- Math.Abs(Velocity.Z) < threshold &&
- Math.Abs(AngularVelocity.X) < threshold &&
- Math.Abs(AngularVelocity.Y) < threshold &&
- Math.Abs(AngularVelocity.Z) < threshold);
- }
- }
-
- [ProtoMember(39)]
- public uint Category
- {
- get { return _category; }
- set { _category = value; }
- }
-
- [ProtoMember(40)]
- public int OwnershipCost
- {
- get { return _ownershipCost; }
- set { _ownershipCost = value; }
- }
-
- [XmlIgnore]
- public virtual UUID RegionID
- {
- get
- {
- if (ParentGroup != null && ParentGroup.Scene != null)
- return ParentGroup.Scene.RegionInfo.RegionID;
- else
- return UUID.Zero;
- }
- set { } // read only
- }
-
- public Vector3 AbsolutePosition
- {
- get
- {
- if (IsAttachment)
- return GroupPosition;
-
- return GetWorldPosition();
- }
- set { }
- }
-
- public ISceneEntity ParentEntity
- {
- get { return m_parentGroup; }
- }
-
- [ProtoMember(30)]
- public Quaternion SitTargetOrientation { get; set; }
-
- [ProtoMember(31)]
- public Vector3 SitTargetPosition { get; set; }
-
- [ProtoMember(32)]
- public Vector3 OmegaAxis { get; set; }
-
- [ProtoMember(33)]
- public double OmegaSpinRate { get; set; }
-
- [ProtoMember(34)]
- public double OmegaGain { get; set; }
-
- [ProtoMember(35)]
- public uint ParentID
- {
- get { return _parentID; }
- set { _parentID = value; }
- }
-
- [ProtoMember(36)]
- public int CreationDate { get; set; }
-
- [ProtoMember(37)]
- public int SalePrice
- {
- get { return _salePrice; }
- set { _salePrice = value; }
- }
-
- [ProtoMember(38)]
- public byte ObjectSaleType
- {
- get { return _objectSaleType; }
- set { _objectSaleType = value; }
- }
-
- [ProtoMember(43)]
- public UUID GroupID
- {
- get { return _groupID; }
- set { _groupID = value; }
- }
-
- [ProtoMember(44)]
- public UUID OwnerID
- {
- get { return _ownerID; }
- set { _ownerID = value; }
- }
-
- [ProtoMember(45)]
- public UUID LastOwnerID { get; set; }
-
- [ProtoMember(46)]
- public uint BaseMask
- {
- get { return _baseMask; }
- set { _baseMask = value; }
- }
-
- [ProtoMember(101)]
- public uint OwnerMask
- {
- get { return _ownerMask; }
- set { _ownerMask = value; }
- }
-
- [ProtoMember(47)]
- public uint GroupMask
- {
- get { return _groupMask; }
- set { _groupMask = value; }
- }
-
- [ProtoMember(48)]
- public uint EveryoneMask
- {
- get { return _everyoneMask; }
- set { _everyoneMask = value; }
- }
-
- [ProtoMember(49)]
- public uint NextOwnerMask
- {
- get { return _nextOwnerMask; }
- set { _nextOwnerMask = value; }
- }
-
- [ProtoMember(50)]
- public byte PhysicsType { get; set; }
-
- [ProtoMember(51)]
- public float Density
- {
- get
- {
- if (m_density != 0)
- return m_density;
- return (m_density = 1000f);
- }
- set { m_density = value; }
- }
-
- [ProtoMember(52)]
- public float Friction
- {
- get
- {
- if (m_friction != 0)
- return m_friction;
- return (m_friction = 0.6f);
- }
- set { m_friction = value; }
- }
-
- [ProtoMember(53)]
- public float Restitution
- {
- get
- {
- if (m_restitution != 0)
- return m_restitution;
- return (m_restitution = 0.5f);
- }
- set { m_restitution = value; }
- }
-
- [ProtoMember(54)]
- public float GravityMultiplier
- {
- get
- {
- if (m_gravityMultiplier != 0)
- return m_gravityMultiplier;
- return (m_gravityMultiplier = 1);
- }
- set { m_gravityMultiplier = value; }
- }
-
- /// <summary>
- /// Property flags. See OpenMetaverse.PrimFlags
- /// </summary>
- /// Example properties are PrimFlags.Phantom and PrimFlags.DieAtEdge
- [ProtoMember(55)]
- public PrimFlags Flags
- {
- get { return _flags; }
- set
- {
- // MainConsole.Instance.DebugFormat("[SOP]: Setting flags for {0} {1} to {2}", UUID, Name, value);
- //if (ParentGroup != null && _flags != value)
- // ParentGroup.HasGroupChanged = true;
- _flags = value;
- }
- }
-
- [XmlIgnore]
- public List<UUID> SitTargetAvatar { get; set; }
-
- [XmlIgnore]
- public UUID ParentUUID
- {
- get
- {
- if (ParentGroup != null)
- _parentUUID = ParentGroup.UUID;
- return _parentUUID;
- }
- set
- {
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- _parentUUID = value;
- }
- }
-
- [XmlIgnore]
- [ProtoMember(56)]
- public string SitAnimation
- {
- get { return m_sitAnimation; }
- set
- {
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_sitAnimation = value;
- }
- }
-
- [ProtoMember(57)]
- public UUID CollisionSound
- {
- get { return m_collisionSound; }
- set
- {
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_collisionSound = value;
- //Why?
- //aggregateScriptEvents();
- }
- }
-
- [ProtoMember(58)]
- public UUID CollisionSprite
- {
- get { return m_collisionSprite; }
- set
- {
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_collisionSprite = value;
- }
- }
-
- [ProtoMember(59)]
- public float CollisionSoundVolume
- {
- get { return m_collisionSoundVolume; }
- set
- {
- if (ParentGroup != null)
- ParentGroup.HasGroupChanged = true;
- m_collisionSoundVolume = value;
- }
- }
-
- #endregion Public Properties with only Get
-
- #region Private Methods
-
- public void FinishedSerializingGenericProperties()
- {
- if ((APIDEnabled || PIDActive) && this.ParentEntity != null) //Make sure to activate it
- this.ParentEntity.Scene.EventManager.OnFrame += UpdateLookAt;
- }
-
- private void UpdateOOBfromOOBs()
- {
- m_partOOBoffset = Vector3.Zero;
-
- Vector3 ts = Scale;
-
- m_partOOBsize.X = ts.X*0.5f;
- m_partOOBsize.Y = ts.Y*0.5f;
- m_partOOBsize.Z = ts.Z*0.5f;
-
- m_partBSphereRadiusSQ = m_partOOBsize.LengthSquared();
- ValidpartOOB = true;
- }
-
- // distance from aabb to point ( untested)
- public float AABdistanceToSQ(Vector3 target)
- {
- // distance to group in world
- Vector3 vtmp = target - m_groupPosition; // assume this updated
-
- if (ParentID != 0)
- {
- // rotate into group reference
- vtmp *= Quaternion.Inverse(ParentGroup.GroupRotation);
- // move into offseted local ref
- vtmp -= m_offsetPosition;
- }
-
- // rotate into local reference ( part or grp )
- vtmp *= Quaternion.Inverse(GetRotationOffset());
-
- // now oob pos
- vtmp -= OOBoffset; // force update
-
- Vector3 box = OOBsize;
-
- // hack distance to box: inside == 0
- if (vtmp.X > 0)
- {
- vtmp.X -= box.X;
- if (vtmp.X < 0.0)
- vtmp.X = 0.0f;
- }
- else
- {
- vtmp.X += box.X;
- if (vtmp.X > 0.0)
- vtmp.X = 0.0f;
- }
-
- if (vtmp.Y > 0)
- {
- vtmp.Y -= box.Y;
- if (vtmp.Y < 0.0)
- vtmp.Y = 0.0f;
- }
- else
- {
- vtmp.Y += box.Y;
- if (vtmp.Y > 0.0)
- vtmp.Y = 0.0f;
- }
-
- if (vtmp.Z > 0)
- {
- vtmp.Z -= box.Z;
- if (vtmp.Z < 0.0)
- vtmp.Z = 0.0f;
- }
- else
- {
- vtmp.Z += box.Z;
- if (vtmp.Z > 0.0)
- vtmp.Z = 0.0f;
- }
-
- return vtmp.LengthSquared();
- }
-
- // distance from aabb to point ( untested)
- // if smaller than simplied distance to group returns that one
- // hack to send root prims first
-
- public float clampedAABdistanceToSQ(Vector3 target)
- {
- float grpdSQ = 0;
- // distance to group in world
- Vector3 vtmp = target - m_groupPosition; // assume this updated
-
-
- if (ParentID != 0)
- {
- // rotate into group reference
- vtmp *= Quaternion.Inverse(ParentGroup.GroupRotation);
- // compute distance to grp oob
- Vector3 grpv = vtmp - ParentGroup.OOBoffset;
- grpdSQ = grpv.LengthSquared() - ParentGroup.BSphereRadiusSQ;
- if (grpdSQ < 0)
- grpdSQ = 0;
-
- // back
- // move into offseted local ref
- vtmp -= m_offsetPosition;
- }
-
- // rotate into local reference
- vtmp *= Quaternion.Inverse(GetRotationOffset());
- // now oob pos
- vtmp -= OOBoffset; // force update
-
- Vector3 box = OOBsize;
-
- // ha…
Large files files are truncated, but you can click here to view the full file