diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 318 |
1 files changed, 170 insertions, 148 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 32171a0..70f3112 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -102,16 +102,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
102 | 102 | ||
103 | #region Fields | 103 | #region Fields |
104 | 104 | ||
105 | public bool AllowedDrop = false; | 105 | public bool AllowedDrop; |
106 | 106 | ||
107 | [XmlIgnore] | 107 | [XmlIgnore] |
108 | public bool DIE_AT_EDGE = false; | 108 | public bool DIE_AT_EDGE; |
109 | 109 | ||
110 | // TODO: This needs to be persisted in next XML version update! | 110 | // TODO: This needs to be persisted in next XML version update! |
111 | [XmlIgnore] | 111 | [XmlIgnore] |
112 | public int[] PayPrice = {-2,-2,-2,-2,-2}; | 112 | public readonly int[] PayPrice = {-2,-2,-2,-2,-2}; |
113 | [XmlIgnore] | 113 | [XmlIgnore] |
114 | public PhysicsActor PhysActor = null; | 114 | public PhysicsActor PhysActor; |
115 | 115 | ||
116 | //Xantor 20080528 Sound stuff: | 116 | //Xantor 20080528 Sound stuff: |
117 | // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. | 117 | // Note: This isn't persisted in the database right now, as the fields for that aren't just there yet. |
@@ -130,55 +130,56 @@ namespace OpenSim.Region.Framework.Scenes | |||
130 | public double SoundRadius; | 130 | public double SoundRadius; |
131 | 131 | ||
132 | [XmlIgnore] | 132 | [XmlIgnore] |
133 | public uint TimeStampFull = 0; | 133 | public uint TimeStampFull; |
134 | 134 | ||
135 | [XmlIgnore] | 135 | [XmlIgnore] |
136 | public uint TimeStampLastActivity = 0; // Will be used for AutoReturn | 136 | public uint TimeStampLastActivity; // Will be used for AutoReturn |
137 | 137 | ||
138 | [XmlIgnore] | 138 | [XmlIgnore] |
139 | public uint TimeStampTerse = 0; | 139 | public uint TimeStampTerse; |
140 | 140 | ||
141 | [XmlIgnore] | 141 | [XmlIgnore] |
142 | public UUID FromItemID = UUID.Zero; | 142 | public UUID FromItemID; |
143 | 143 | ||
144 | /// <value> | 144 | /// <value> |
145 | /// The UUID of the user inventory item from which this object was rezzed if this is a root part. | 145 | /// The UUID of the user inventory item from which this object was rezzed if this is a root part. |
146 | /// If UUID.Zero then either this is not a root part or there is no connection with a user inventory item. | 146 | /// If UUID.Zero then either this is not a root part or there is no connection with a user inventory item. |
147 | /// </value> | 147 | /// </value> |
148 | private UUID m_fromUserInventoryItemID = UUID.Zero; | 148 | private UUID m_fromUserInventoryItemID; |
149 | 149 | ||
150 | [XmlIgnore] | 150 | [XmlIgnore] |
151 | public UUID FromUserInventoryItemID | 151 | public UUID FromUserInventoryItemID |
152 | { | 152 | { |
153 | get { return m_fromUserInventoryItemID; } | 153 | get { return m_fromUserInventoryItemID; } |
154 | } | 154 | } |
155 | 155 | ||
156 | [XmlIgnore] | 156 | [XmlIgnore] |
157 | public bool IsAttachment = false; | 157 | public bool IsAttachment; |
158 | 158 | ||
159 | [XmlIgnore] | 159 | [XmlIgnore] |
160 | public scriptEvents AggregateScriptEvents = 0; | 160 | public scriptEvents AggregateScriptEvents; |
161 | 161 | ||
162 | [XmlIgnore] | 162 | [XmlIgnore] |
163 | public UUID AttachedAvatar = UUID.Zero; | 163 | public UUID AttachedAvatar; |
164 | 164 | ||
165 | [XmlIgnore] | 165 | [XmlIgnore] |
166 | public Vector3 AttachedPos = Vector3.Zero; | 166 | public Vector3 AttachedPos; |
167 | 167 | ||
168 | [XmlIgnore] | 168 | [XmlIgnore] |
169 | public uint AttachmentPoint = (byte)0; | 169 | public uint AttachmentPoint; |
170 | 170 | ||
171 | [XmlIgnore] | 171 | [XmlIgnore] |
172 | public PhysicsVector RotationAxis = new PhysicsVector(1f,1f,1f); | 172 | public Vector3 RotationAxis = Vector3.One; |
173 | 173 | ||
174 | [XmlIgnore] | 174 | [XmlIgnore] |
175 | public bool VolumeDetectActive = false; // XmlIgnore set to avoid problems with persistance until I come to care for this | 175 | public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this |
176 | // Certainly this must be a persistant setting finally | 176 | // Certainly this must be a persistant setting finally |
177 | 177 | ||
178 | [XmlIgnore] | 178 | [XmlIgnore] |
179 | public bool IsWaitingForFirstSpinUpdatePacket = false; | 179 | public bool IsWaitingForFirstSpinUpdatePacket; |
180 | |||
180 | [XmlIgnore] | 181 | [XmlIgnore] |
181 | public Quaternion SpinOldOrientation = new Quaternion(); | 182 | public Quaternion SpinOldOrientation = Quaternion.Identity; |
182 | 183 | ||
183 | /// <summary> | 184 | /// <summary> |
184 | /// This part's inventory | 185 | /// This part's inventory |
@@ -191,34 +192,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
191 | protected SceneObjectPartInventory m_inventory; | 192 | protected SceneObjectPartInventory m_inventory; |
192 | 193 | ||
193 | [XmlIgnore] | 194 | [XmlIgnore] |
194 | public bool Undoing = false; | 195 | public bool Undoing; |
195 | 196 | ||
196 | [XmlIgnore] | 197 | [XmlIgnore] |
197 | private PrimFlags LocalFlags = 0; | 198 | private PrimFlags LocalFlags; |
198 | [XmlIgnore] | 199 | [XmlIgnore] |
199 | private float m_damage = -1.0f; | 200 | private float m_damage = -1.0f; |
200 | private byte[] m_TextureAnimation; | 201 | private byte[] m_TextureAnimation; |
201 | private byte m_clickAction = 0; | 202 | private byte m_clickAction; |
202 | private Color m_color = Color.Black; | 203 | private Color m_color = Color.Black; |
203 | private string m_description = String.Empty; | 204 | private string m_description = String.Empty; |
204 | private readonly List<uint> m_lastColliders = new List<uint>(); | 205 | private readonly List<uint> m_lastColliders = new List<uint>(); |
205 | // private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero; | 206 | private int m_linkNum; |
206 | private int m_linkNum = 0; | ||
207 | [XmlIgnore] | 207 | [XmlIgnore] |
208 | private int m_scriptAccessPin = 0; | 208 | private int m_scriptAccessPin; |
209 | [XmlIgnore] | 209 | [XmlIgnore] |
210 | private readonly Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); | 210 | private readonly Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); |
211 | private string m_sitName = String.Empty; | 211 | private string m_sitName = String.Empty; |
212 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; | 212 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; |
213 | private Vector3 m_sitTargetPosition = Vector3.Zero; | 213 | private Vector3 m_sitTargetPosition; |
214 | private string m_sitAnimation = "SIT"; | 214 | private string m_sitAnimation = "SIT"; |
215 | private string m_text = String.Empty; | 215 | private string m_text = String.Empty; |
216 | private string m_touchName = String.Empty; | 216 | private string m_touchName = String.Empty; |
217 | private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5); | 217 | private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5); |
218 | private UUID _creatorID; | 218 | private UUID _creatorID; |
219 | 219 | ||
220 | 220 | private bool m_passTouches; | |
221 | private bool m_passTouches = false; | ||
222 | 221 | ||
223 | /// <summary> | 222 | /// <summary> |
224 | /// Only used internally to schedule client updates. | 223 | /// Only used internally to schedule client updates. |
@@ -236,28 +235,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
236 | //unkown if this will be kept, added as a way of removing the group position from the group class | 235 | //unkown if this will be kept, added as a way of removing the group position from the group class |
237 | protected Vector3 m_groupPosition; | 236 | protected Vector3 m_groupPosition; |
238 | protected uint m_localId; | 237 | protected uint m_localId; |
239 | protected Material m_material = (Material)3; // Wood | 238 | protected Material m_material = OpenMetaverse.Material.Wood; |
240 | protected string m_name; | 239 | protected string m_name; |
241 | protected Vector3 m_offsetPosition; | 240 | protected Vector3 m_offsetPosition; |
242 | 241 | ||
243 | // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out. | 242 | // FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out. |
244 | protected SceneObjectGroup m_parentGroup; | 243 | protected SceneObjectGroup m_parentGroup; |
245 | protected byte[] m_particleSystem = new byte[0]; | 244 | protected byte[] m_particleSystem = Utils.EmptyBytes; |
246 | protected ulong m_regionHandle; | 245 | protected ulong m_regionHandle; |
247 | protected Quaternion m_rotationOffset; | 246 | protected Quaternion m_rotationOffset; |
248 | protected PrimitiveBaseShape m_shape = null; | 247 | protected PrimitiveBaseShape m_shape; |
249 | protected UUID m_uuid; | 248 | protected UUID m_uuid; |
250 | protected Vector3 m_velocity; | 249 | protected Vector3 m_velocity; |
251 | 250 | ||
251 | protected Vector3 m_lastPosition; | ||
252 | protected Quaternion m_lastRotation; | ||
253 | protected Vector3 m_lastVelocity; | ||
254 | protected Vector3 m_lastAcceleration; | ||
255 | protected Vector3 m_lastAngularVelocity; | ||
256 | |||
252 | // TODO: Those have to be changed into persistent properties at some later point, | 257 | // TODO: Those have to be changed into persistent properties at some later point, |
253 | // or sit-camera on vehicles will break on sim-crossing. | 258 | // or sit-camera on vehicles will break on sim-crossing. |
254 | private Vector3 m_cameraEyeOffset = new Vector3(0.0f, 0.0f, 0.0f); | 259 | private Vector3 m_cameraEyeOffset; |
255 | private Vector3 m_cameraAtOffset = new Vector3(0.0f, 0.0f, 0.0f); | 260 | private Vector3 m_cameraAtOffset; |
256 | private bool m_forceMouselook = false; | 261 | private bool m_forceMouselook; |
257 | 262 | ||
258 | // TODO: Collision sound should have default. | 263 | // TODO: Collision sound should have default. |
259 | private UUID m_collisionSound = UUID.Zero; | 264 | private UUID m_collisionSound; |
260 | private float m_collisionSoundVolume = 0.0f; | 265 | private float m_collisionSoundVolume; |
261 | 266 | ||
262 | #endregion Fields | 267 | #endregion Fields |
263 | 268 | ||
@@ -269,9 +274,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
269 | public SceneObjectPart() | 274 | public SceneObjectPart() |
270 | { | 275 | { |
271 | // It's not necessary to persist this | 276 | // It's not necessary to persist this |
272 | m_TextureAnimation = new byte[0]; | 277 | m_TextureAnimation = Utils.EmptyBytes; |
273 | m_particleSystem = new byte[0]; | 278 | m_particleSystem = Utils.EmptyBytes; |
274 | Rezzed = DateTime.Now; | 279 | Rezzed = DateTime.UtcNow; |
275 | 280 | ||
276 | m_inventory = new SceneObjectPartInventory(this); | 281 | m_inventory = new SceneObjectPartInventory(this); |
277 | } | 282 | } |
@@ -290,8 +295,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
290 | { | 295 | { |
291 | m_name = "Primitive"; | 296 | m_name = "Primitive"; |
292 | 297 | ||
293 | Rezzed = DateTime.Now; | 298 | Rezzed = DateTime.UtcNow; |
294 | _creationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | 299 | _creationDate = (int)Utils.DateTimeToUnixTime(Rezzed); |
295 | _ownerID = ownerID; | 300 | _ownerID = ownerID; |
296 | _creatorID = _ownerID; | 301 | _creatorID = _ownerID; |
297 | _lastOwnerID = UUID.Zero; | 302 | _lastOwnerID = UUID.Zero; |
@@ -299,19 +304,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
299 | Shape = shape; | 304 | Shape = shape; |
300 | // Todo: Add More Object Parameter from above! | 305 | // Todo: Add More Object Parameter from above! |
301 | _ownershipCost = 0; | 306 | _ownershipCost = 0; |
302 | _objectSaleType = (byte) 0; | 307 | _objectSaleType = 0; |
303 | _salePrice = 0; | 308 | _salePrice = 0; |
304 | _category = (uint) 0; | 309 | _category = 0; |
305 | _lastOwnerID = _creatorID; | 310 | _lastOwnerID = _creatorID; |
306 | // End Todo: /// | 311 | // End Todo: /// |
307 | GroupPosition = groupPosition; | 312 | GroupPosition = groupPosition; |
308 | OffsetPosition = offsetPosition; | 313 | OffsetPosition = offsetPosition; |
309 | RotationOffset = rotationOffset; | 314 | RotationOffset = rotationOffset; |
310 | Velocity = new Vector3(0, 0, 0); | 315 | Velocity = Vector3.Zero; |
311 | AngularVelocity = new Vector3(0, 0, 0); | 316 | AngularVelocity = Vector3.Zero; |
312 | Acceleration = new Vector3(0, 0, 0); | 317 | Acceleration = Vector3.Zero; |
313 | m_TextureAnimation = new byte[0]; | 318 | m_TextureAnimation = Utils.EmptyBytes; |
314 | m_particleSystem = new byte[0]; | 319 | m_particleSystem = Utils.EmptyBytes; |
315 | 320 | ||
316 | // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, | 321 | // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, |
317 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 322 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
@@ -532,13 +537,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
532 | // Root prim actually goes at Position | 537 | // Root prim actually goes at Position |
533 | if (_parentID == 0) | 538 | if (_parentID == 0) |
534 | { | 539 | { |
535 | PhysActor.Position = new PhysicsVector(value.X, value.Y, value.Z); | 540 | PhysActor.Position = value; |
536 | } | 541 | } |
537 | else | 542 | else |
538 | { | 543 | { |
539 | // To move the child prim in respect to the group position and rotation we have to calculate | 544 | // To move the child prim in respect to the group position and rotation we have to calculate |
540 | Vector3 resultingposition = GetWorldPosition(); | 545 | Vector3 resultingposition = GetWorldPosition(); |
541 | PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); | 546 | PhysActor.Position = resultingposition; |
542 | Quaternion resultingrot = GetWorldRotation(); | 547 | Quaternion resultingrot = GetWorldRotation(); |
543 | PhysActor.Orientation = resultingrot; | 548 | PhysActor.Orientation = resultingrot; |
544 | } | 549 | } |
@@ -580,7 +585,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
580 | if (_parentID != 0 && PhysActor != null) | 585 | if (_parentID != 0 && PhysActor != null) |
581 | { | 586 | { |
582 | Vector3 resultingposition = GetWorldPosition(); | 587 | Vector3 resultingposition = GetWorldPosition(); |
583 | PhysActor.Position = new PhysicsVector(resultingposition.X, resultingposition.Y, resultingposition.Z); | 588 | PhysActor.Position = resultingposition; |
584 | Quaternion resultingrot = GetWorldRotation(); | 589 | Quaternion resultingrot = GetWorldRotation(); |
585 | PhysActor.Orientation = resultingrot; | 590 | PhysActor.Orientation = resultingrot; |
586 | 591 | ||
@@ -670,7 +675,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
670 | { | 675 | { |
671 | if (PhysActor.IsPhysical) | 676 | if (PhysActor.IsPhysical) |
672 | { | 677 | { |
673 | PhysActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z); | 678 | PhysActor.Velocity = value; |
674 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 679 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
675 | } | 680 | } |
676 | } | 681 | } |
@@ -812,7 +817,7 @@ if (m_shape != null) { | |||
812 | { | 817 | { |
813 | if (m_parentGroup.Scene.PhysicsScene != null) | 818 | if (m_parentGroup.Scene.PhysicsScene != null) |
814 | { | 819 | { |
815 | PhysActor.Size = new PhysicsVector(m_shape.Scale.X, m_shape.Scale.Y, m_shape.Scale.Z); | 820 | PhysActor.Size = m_shape.Scale; |
816 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 821 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); |
817 | } | 822 | } |
818 | } | 823 | } |
@@ -1077,8 +1082,8 @@ if (m_shape != null) { | |||
1077 | 1082 | ||
1078 | private void SendObjectPropertiesToClient(UUID AgentID) | 1083 | private void SendObjectPropertiesToClient(UUID AgentID) |
1079 | { | 1084 | { |
1080 | List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); | 1085 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); |
1081 | for (int i = 0; i < avatars.Count; i++) | 1086 | for (int i = 0; i < avatars.Length; i++) |
1082 | { | 1087 | { |
1083 | // Ugly reference :( | 1088 | // Ugly reference :( |
1084 | if (avatars[i].UUID == AgentID) | 1089 | if (avatars[i].UUID == AgentID) |
@@ -1140,8 +1145,8 @@ if (m_shape != null) { | |||
1140 | /// </summary> | 1145 | /// </summary> |
1141 | public void AddFullUpdateToAllAvatars() | 1146 | public void AddFullUpdateToAllAvatars() |
1142 | { | 1147 | { |
1143 | List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); | 1148 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); |
1144 | for (int i = 0; i < avatars.Count; i++) | 1149 | for (int i = 0; i < avatars.Length; i++) |
1145 | { | 1150 | { |
1146 | avatars[i].SceneViewer.QueuePartForUpdate(this); | 1151 | avatars[i].SceneViewer.QueuePartForUpdate(this); |
1147 | } | 1152 | } |
@@ -1165,8 +1170,8 @@ if (m_shape != null) { | |||
1165 | /// Terse updates | 1170 | /// Terse updates |
1166 | public void AddTerseUpdateToAllAvatars() | 1171 | public void AddTerseUpdateToAllAvatars() |
1167 | { | 1172 | { |
1168 | List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); | 1173 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); |
1169 | for (int i = 0; i < avatars.Count; i++) | 1174 | for (int i = 0; i < avatars.Length; i++) |
1170 | { | 1175 | { |
1171 | avatars[i].SceneViewer.QueuePartForUpdate(this); | 1176 | avatars[i].SceneViewer.QueuePartForUpdate(this); |
1172 | } | 1177 | } |
@@ -1220,7 +1225,7 @@ if (m_shape != null) { | |||
1220 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | 1225 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> |
1221 | public void ApplyImpulse(Vector3 impulsei, bool localGlobalTF) | 1226 | public void ApplyImpulse(Vector3 impulsei, bool localGlobalTF) |
1222 | { | 1227 | { |
1223 | PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); | 1228 | Vector3 impulse = impulsei; |
1224 | 1229 | ||
1225 | if (localGlobalTF) | 1230 | if (localGlobalTF) |
1226 | { | 1231 | { |
@@ -1228,7 +1233,7 @@ if (m_shape != null) { | |||
1228 | Quaternion AXgrot = grot; | 1233 | Quaternion AXgrot = grot; |
1229 | Vector3 AXimpulsei = impulsei; | 1234 | Vector3 AXimpulsei = impulsei; |
1230 | Vector3 newimpulse = AXimpulsei * AXgrot; | 1235 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1231 | impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z); | 1236 | impulse = newimpulse; |
1232 | } | 1237 | } |
1233 | 1238 | ||
1234 | if (m_parentGroup != null) | 1239 | if (m_parentGroup != null) |
@@ -1246,7 +1251,7 @@ if (m_shape != null) { | |||
1246 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | 1251 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> |
1247 | public void ApplyAngularImpulse(Vector3 impulsei, bool localGlobalTF) | 1252 | public void ApplyAngularImpulse(Vector3 impulsei, bool localGlobalTF) |
1248 | { | 1253 | { |
1249 | PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); | 1254 | Vector3 impulse = impulsei; |
1250 | 1255 | ||
1251 | if (localGlobalTF) | 1256 | if (localGlobalTF) |
1252 | { | 1257 | { |
@@ -1254,7 +1259,7 @@ if (m_shape != null) { | |||
1254 | Quaternion AXgrot = grot; | 1259 | Quaternion AXgrot = grot; |
1255 | Vector3 AXimpulsei = impulsei; | 1260 | Vector3 AXimpulsei = impulsei; |
1256 | Vector3 newimpulse = AXimpulsei * AXgrot; | 1261 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1257 | impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z); | 1262 | impulse = newimpulse; |
1258 | } | 1263 | } |
1259 | 1264 | ||
1260 | if (m_parentGroup != null) | 1265 | if (m_parentGroup != null) |
@@ -1272,7 +1277,7 @@ if (m_shape != null) { | |||
1272 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | 1277 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> |
1273 | public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) | 1278 | public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) |
1274 | { | 1279 | { |
1275 | PhysicsVector impulse = new PhysicsVector(impulsei.X, impulsei.Y, impulsei.Z); | 1280 | Vector3 impulse = impulsei; |
1276 | 1281 | ||
1277 | if (localGlobalTF) | 1282 | if (localGlobalTF) |
1278 | { | 1283 | { |
@@ -1280,7 +1285,7 @@ if (m_shape != null) { | |||
1280 | Quaternion AXgrot = grot; | 1285 | Quaternion AXgrot = grot; |
1281 | Vector3 AXimpulsei = impulsei; | 1286 | Vector3 AXimpulsei = impulsei; |
1282 | Vector3 newimpulse = AXimpulsei * AXgrot; | 1287 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1283 | impulse = new PhysicsVector(newimpulse.X, newimpulse.Y, newimpulse.Z); | 1288 | impulse = newimpulse; |
1284 | } | 1289 | } |
1285 | 1290 | ||
1286 | if (m_parentGroup != null) | 1291 | if (m_parentGroup != null) |
@@ -1328,8 +1333,8 @@ if (m_shape != null) { | |||
1328 | PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( | 1333 | PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( |
1329 | Name, | 1334 | Name, |
1330 | Shape, | 1335 | Shape, |
1331 | new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z), | 1336 | AbsolutePosition, |
1332 | new PhysicsVector(Scale.X, Scale.Y, Scale.Z), | 1337 | Scale, |
1333 | RotationOffset, | 1338 | RotationOffset, |
1334 | RigidBody); | 1339 | RigidBody); |
1335 | 1340 | ||
@@ -1518,7 +1523,7 @@ if (m_shape != null) { | |||
1518 | PhysicsJoint joint; | 1523 | PhysicsJoint joint; |
1519 | 1524 | ||
1520 | joint = m_parentGroup.Scene.PhysicsScene.RequestJointCreation(Name, jointType, | 1525 | joint = m_parentGroup.Scene.PhysicsScene.RequestJointCreation(Name, jointType, |
1521 | new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z), | 1526 | AbsolutePosition, |
1522 | this.RotationOffset, | 1527 | this.RotationOffset, |
1523 | Description, | 1528 | Description, |
1524 | bodyNames, | 1529 | bodyNames, |
@@ -1703,12 +1708,12 @@ if (m_shape != null) { | |||
1703 | } | 1708 | } |
1704 | } | 1709 | } |
1705 | 1710 | ||
1706 | public PhysicsVector GetForce() | 1711 | public Vector3 GetForce() |
1707 | { | 1712 | { |
1708 | if (PhysActor != null) | 1713 | if (PhysActor != null) |
1709 | return PhysActor.Force; | 1714 | return PhysActor.Force; |
1710 | else | 1715 | else |
1711 | return new PhysicsVector(); | 1716 | return Vector3.Zero; |
1712 | } | 1717 | } |
1713 | 1718 | ||
1714 | public void GetProperties(IClientAPI client) | 1719 | public void GetProperties(IClientAPI client) |
@@ -1894,24 +1899,24 @@ if (m_shape != null) { | |||
1894 | } | 1899 | } |
1895 | else | 1900 | else |
1896 | { | 1901 | { |
1897 | List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); | 1902 | ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); |
1898 | if (avlist != null) | 1903 | |
1904 | for (int i = 0; i < avlist.Length; i++) | ||
1899 | { | 1905 | { |
1900 | foreach (ScenePresence av in avlist) | 1906 | ScenePresence av = avlist[i]; |
1907 | |||
1908 | if (av.LocalId == localId) | ||
1901 | { | 1909 | { |
1902 | if (av.LocalId == localId) | 1910 | DetectedObject detobj = new DetectedObject(); |
1903 | { | 1911 | detobj.keyUUID = av.UUID; |
1904 | DetectedObject detobj = new DetectedObject(); | 1912 | detobj.nameStr = av.ControllingClient.Name; |
1905 | detobj.keyUUID = av.UUID; | 1913 | detobj.ownerUUID = av.UUID; |
1906 | detobj.nameStr = av.ControllingClient.Name; | 1914 | detobj.posVector = av.AbsolutePosition; |
1907 | detobj.ownerUUID = av.UUID; | 1915 | detobj.rotQuat = av.Rotation; |
1908 | detobj.posVector = av.AbsolutePosition; | 1916 | detobj.velVector = av.Velocity; |
1909 | detobj.rotQuat = av.Rotation; | 1917 | detobj.colliderType = 0; |
1910 | detobj.velVector = av.Velocity; | 1918 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; |
1911 | detobj.colliderType = 0; | 1919 | colliding.Add(detobj); |
1912 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
1913 | colliding.Add(detobj); | ||
1914 | } | ||
1915 | } | 1920 | } |
1916 | } | 1921 | } |
1917 | } | 1922 | } |
@@ -1965,26 +1970,25 @@ if (m_shape != null) { | |||
1965 | } | 1970 | } |
1966 | else | 1971 | else |
1967 | { | 1972 | { |
1968 | List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); | 1973 | ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); |
1969 | if (avlist != null) | 1974 | |
1975 | for (int i = 0; i < avlist.Length; i++) | ||
1970 | { | 1976 | { |
1971 | foreach (ScenePresence av in avlist) | 1977 | ScenePresence av = avlist[i]; |
1978 | |||
1979 | if (av.LocalId == localId) | ||
1972 | { | 1980 | { |
1973 | if (av.LocalId == localId) | 1981 | DetectedObject detobj = new DetectedObject(); |
1974 | { | 1982 | detobj.keyUUID = av.UUID; |
1975 | DetectedObject detobj = new DetectedObject(); | 1983 | detobj.nameStr = av.Name; |
1976 | detobj.keyUUID = av.UUID; | 1984 | detobj.ownerUUID = av.UUID; |
1977 | detobj.nameStr = av.Name; | 1985 | detobj.posVector = av.AbsolutePosition; |
1978 | detobj.ownerUUID = av.UUID; | 1986 | detobj.rotQuat = av.Rotation; |
1979 | detobj.posVector = av.AbsolutePosition; | 1987 | detobj.velVector = av.Velocity; |
1980 | detobj.rotQuat = av.Rotation; | 1988 | detobj.colliderType = 0; |
1981 | detobj.velVector = av.Velocity; | 1989 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; |
1982 | detobj.colliderType = 0; | 1990 | colliding.Add(detobj); |
1983 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
1984 | colliding.Add(detobj); | ||
1985 | } | ||
1986 | } | 1991 | } |
1987 | |||
1988 | } | 1992 | } |
1989 | } | 1993 | } |
1990 | } | 1994 | } |
@@ -2035,24 +2039,24 @@ if (m_shape != null) { | |||
2035 | } | 2039 | } |
2036 | else | 2040 | else |
2037 | { | 2041 | { |
2038 | List<ScenePresence> avlist = m_parentGroup.Scene.GetScenePresences(); | 2042 | ScenePresence[] avlist = m_parentGroup.Scene.GetScenePresences(); |
2039 | if (avlist != null) | 2043 | |
2044 | for (int i = 0; i < avlist.Length; i++) | ||
2040 | { | 2045 | { |
2041 | foreach (ScenePresence av in avlist) | 2046 | ScenePresence av = avlist[i]; |
2047 | |||
2048 | if (av.LocalId == localId) | ||
2042 | { | 2049 | { |
2043 | if (av.LocalId == localId) | 2050 | DetectedObject detobj = new DetectedObject(); |
2044 | { | 2051 | detobj.keyUUID = av.UUID; |
2045 | DetectedObject detobj = new DetectedObject(); | 2052 | detobj.nameStr = av.Name; |
2046 | detobj.keyUUID = av.UUID; | 2053 | detobj.ownerUUID = av.UUID; |
2047 | detobj.nameStr = av.Name; | 2054 | detobj.posVector = av.AbsolutePosition; |
2048 | detobj.ownerUUID = av.UUID; | 2055 | detobj.rotQuat = av.Rotation; |
2049 | detobj.posVector = av.AbsolutePosition; | 2056 | detobj.velVector = av.Velocity; |
2050 | detobj.rotQuat = av.Rotation; | 2057 | detobj.colliderType = 0; |
2051 | detobj.velVector = av.Velocity; | 2058 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; |
2052 | detobj.colliderType = 0; | 2059 | colliding.Add(detobj); |
2053 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
2054 | colliding.Add(detobj); | ||
2055 | } | ||
2056 | } | 2060 | } |
2057 | } | 2061 | } |
2058 | } | 2062 | } |
@@ -2074,7 +2078,7 @@ if (m_shape != null) { | |||
2074 | } | 2078 | } |
2075 | } | 2079 | } |
2076 | 2080 | ||
2077 | public void PhysicsOutOfBounds(PhysicsVector pos) | 2081 | public void PhysicsOutOfBounds(Vector3 pos) |
2078 | { | 2082 | { |
2079 | m_log.Error("[PHYSICS]: Physical Object went out of bounds."); | 2083 | m_log.Error("[PHYSICS]: Physical Object went out of bounds."); |
2080 | 2084 | ||
@@ -2312,8 +2316,8 @@ if (m_shape != null) { | |||
2312 | /// </summary> | 2316 | /// </summary> |
2313 | public void SendFullUpdateToAllClients() | 2317 | public void SendFullUpdateToAllClients() |
2314 | { | 2318 | { |
2315 | List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); | 2319 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); |
2316 | for (int i = 0; i < avatars.Count; i++) | 2320 | for (int i = 0; i < avatars.Length; i++) |
2317 | { | 2321 | { |
2318 | // Ugly reference :( | 2322 | // Ugly reference :( |
2319 | m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, | 2323 | m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, |
@@ -2323,8 +2327,8 @@ if (m_shape != null) { | |||
2323 | 2327 | ||
2324 | public void SendFullUpdateToAllClientsExcept(UUID agentID) | 2328 | public void SendFullUpdateToAllClientsExcept(UUID agentID) |
2325 | { | 2329 | { |
2326 | List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); | 2330 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); |
2327 | for (int i = 0; i < avatars.Count; i++) | 2331 | for (int i = 0; i < avatars.Length; i++) |
2328 | { | 2332 | { |
2329 | // Ugly reference :( | 2333 | // Ugly reference :( |
2330 | if (avatars[i].UUID != agentID) | 2334 | if (avatars[i].UUID != agentID) |
@@ -2389,18 +2393,36 @@ if (m_shape != null) { | |||
2389 | /// </summary> | 2393 | /// </summary> |
2390 | public void SendScheduledUpdates() | 2394 | public void SendScheduledUpdates() |
2391 | { | 2395 | { |
2392 | if (m_updateFlag == 1) //some change has been made so update the clients | 2396 | const float VELOCITY_TOLERANCE = 0.01f; |
2397 | const float POSITION_TOLERANCE = 10.0f; | ||
2398 | |||
2399 | if (m_updateFlag == 1) | ||
2393 | { | 2400 | { |
2394 | AddTerseUpdateToAllAvatars(); | 2401 | // Throw away duplicate or insignificant updates |
2395 | ClearUpdateSchedule(); | 2402 | if (RotationOffset != m_lastRotation || |
2403 | Acceleration != m_lastAcceleration || | ||
2404 | (Velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || | ||
2405 | (RotationalVelocity - m_lastAngularVelocity).Length() > VELOCITY_TOLERANCE || | ||
2406 | (OffsetPosition - m_lastPosition).Length() > POSITION_TOLERANCE) | ||
2407 | { | ||
2408 | AddTerseUpdateToAllAvatars(); | ||
2409 | ClearUpdateSchedule(); | ||
2396 | 2410 | ||
2397 | // This causes the Scene to 'poll' physical objects every couple of frames | 2411 | // This causes the Scene to 'poll' physical objects every couple of frames |
2398 | // bad, so it's been replaced by an event driven method. | 2412 | // bad, so it's been replaced by an event driven method. |
2399 | //if ((ObjectFlags & (uint)PrimFlags.Physics) != 0) | 2413 | //if ((ObjectFlags & (uint)PrimFlags.Physics) != 0) |
2400 | //{ | 2414 | //{ |
2401 | // Only send the constant terse updates on physical objects! | 2415 | // Only send the constant terse updates on physical objects! |
2402 | //ScheduleTerseUpdate(); | 2416 | //ScheduleTerseUpdate(); |
2403 | //} | 2417 | //} |
2418 | |||
2419 | // Update the "last" values | ||
2420 | m_lastPosition = OffsetPosition; | ||
2421 | m_lastRotation = RotationOffset; | ||
2422 | m_lastVelocity = Velocity; | ||
2423 | m_lastAcceleration = Acceleration; | ||
2424 | m_lastAngularVelocity = RotationalVelocity; | ||
2425 | } | ||
2404 | } | 2426 | } |
2405 | else | 2427 | else |
2406 | { | 2428 | { |
@@ -2467,8 +2489,8 @@ if (m_shape != null) { | |||
2467 | /// </summary> | 2489 | /// </summary> |
2468 | public void SendTerseUpdateToAllClients() | 2490 | public void SendTerseUpdateToAllClients() |
2469 | { | 2491 | { |
2470 | List<ScenePresence> avatars = m_parentGroup.Scene.GetScenePresences(); | 2492 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); |
2471 | for (int i = 0; i < avatars.Count; i++) | 2493 | for (int i = 0; i < avatars.Length; i++) |
2472 | { | 2494 | { |
2473 | SendTerseUpdateToClient(avatars[i].ControllingClient); | 2495 | SendTerseUpdateToClient(avatars[i].ControllingClient); |
2474 | } | 2496 | } |
@@ -2542,7 +2564,7 @@ if (m_shape != null) { | |||
2542 | } | 2564 | } |
2543 | } | 2565 | } |
2544 | 2566 | ||
2545 | public void SetForce(PhysicsVector force) | 2567 | public void SetForce(Vector3 force) |
2546 | { | 2568 | { |
2547 | if (PhysActor != null) | 2569 | if (PhysActor != null) |
2548 | { | 2570 | { |
@@ -2566,7 +2588,7 @@ if (m_shape != null) { | |||
2566 | } | 2588 | } |
2567 | } | 2589 | } |
2568 | 2590 | ||
2569 | public void SetVehicleVectorParam(int param, PhysicsVector value) | 2591 | public void SetVehicleVectorParam(int param, Vector3 value) |
2570 | { | 2592 | { |
2571 | if (PhysActor != null) | 2593 | if (PhysActor != null) |
2572 | { | 2594 | { |
@@ -3408,8 +3430,8 @@ if (m_shape != null) { | |||
3408 | PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( | 3430 | PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( |
3409 | Name, | 3431 | Name, |
3410 | Shape, | 3432 | Shape, |
3411 | new PhysicsVector(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z), | 3433 | AbsolutePosition, |
3412 | new PhysicsVector(Scale.X, Scale.Y, Scale.Z), | 3434 | Scale, |
3413 | RotationOffset, | 3435 | RotationOffset, |
3414 | UsePhysics); | 3436 | UsePhysics); |
3415 | 3437 | ||
@@ -3549,7 +3571,7 @@ if (m_shape != null) { | |||
3549 | // in SL. | 3571 | // in SL. |
3550 | // | 3572 | // |
3551 | if (ParentGroup.RootPart != this) | 3573 | if (ParentGroup.RootPart != this) |
3552 | ParentGroup.RootPart.Rezzed = DateTime.Now; | 3574 | ParentGroup.RootPart.Rezzed = DateTime.UtcNow; |
3553 | 3575 | ||
3554 | ParentGroup.HasGroupChanged = true; | 3576 | ParentGroup.HasGroupChanged = true; |
3555 | ScheduleFullUpdate(); | 3577 | ScheduleFullUpdate(); |