aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs132
1 files changed, 68 insertions, 64 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 20a6626..7cab841 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -37,6 +37,7 @@ using System.Xml.Serialization;
37using log4net; 37using log4net;
38using OpenMetaverse; 38using OpenMetaverse;
39using OpenMetaverse.Packets; 39using OpenMetaverse.Packets;
40using OpenMetaverse.StructuredData;
40using OpenSim.Framework; 41using OpenSim.Framework;
41using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes.Scripting; 43using OpenSim.Region.Framework.Scenes.Scripting;
@@ -116,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes
116 117
117 #endregion Enumerations 118 #endregion Enumerations
118 119
119 public class SceneObjectPart : IScriptHost, ISceneEntity 120 public class SceneObjectPart : ISceneEntity
120 { 121 {
121 /// <value> 122 /// <value>
122 /// Denote all sides of the prim 123 /// Denote all sides of the prim
@@ -136,6 +137,11 @@ namespace OpenSim.Region.Framework.Scenes
136 137
137 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 138 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
138 139
140 /// <summary>
141 /// Dynamic attributes can be created and deleted as required.
142 /// </summary>
143 public DAMap DynAttrs { get; set; }
144
139 /// <value> 145 /// <value>
140 /// Is this a root part? 146 /// Is this a root part?
141 /// </value> 147 /// </value>
@@ -386,6 +392,7 @@ namespace OpenSim.Region.Framework.Scenes
386 m_particleSystem = Utils.EmptyBytes; 392 m_particleSystem = Utils.EmptyBytes;
387 Rezzed = DateTime.UtcNow; 393 Rezzed = DateTime.UtcNow;
388 Description = String.Empty; 394 Description = String.Empty;
395 DynAttrs = new DAMap();
389 396
390 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol, 397 // Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
391 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from 398 // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
@@ -1342,7 +1349,7 @@ namespace OpenSim.Region.Framework.Scenes
1342 public UUID SitTargetAvatar { get; set; } 1349 public UUID SitTargetAvatar { get; set; }
1343 1350
1344 /// <summary> 1351 /// <summary>
1345 /// IDs of all avatars start on this object part. 1352 /// IDs of all avatars sat on this part.
1346 /// </summary> 1353 /// </summary>
1347 /// <remarks> 1354 /// <remarks>
1348 /// We need to track this so that we can stop sat upon prims from being attached. 1355 /// We need to track this so that we can stop sat upon prims from being attached.
@@ -2133,6 +2140,8 @@ namespace OpenSim.Region.Framework.Scenes
2133 // safeguard actual copy is done in sog.copy 2140 // safeguard actual copy is done in sog.copy
2134 dupe.KeyframeMotion = null; 2141 dupe.KeyframeMotion = null;
2135 2142
2143 dupe.DynAttrs.CopyFrom(DynAttrs);
2144
2136 if (userExposed) 2145 if (userExposed)
2137 { 2146 {
2138/* 2147/*
@@ -2446,11 +2455,11 @@ namespace OpenSim.Region.Framework.Scenes
2446 public int GetAxisRotation(int axis) 2455 public int GetAxisRotation(int axis)
2447 { 2456 {
2448 //Cannot use ScriptBaseClass constants as no referance to it currently. 2457 //Cannot use ScriptBaseClass constants as no referance to it currently.
2449 if (axis == 2)//STATUS_ROTATE_X 2458 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_X)
2450 return STATUS_ROTATE_X; 2459 return STATUS_ROTATE_X;
2451 if (axis == 4)//STATUS_ROTATE_Y 2460 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y)
2452 return STATUS_ROTATE_Y; 2461 return STATUS_ROTATE_Y;
2453 if (axis == 8)//STATUS_ROTATE_Z 2462 if (axis == (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z)
2454 return STATUS_ROTATE_Z; 2463 return STATUS_ROTATE_Z;
2455 2464
2456 return 0; 2465 return 0;
@@ -2485,18 +2494,6 @@ namespace OpenSim.Region.Framework.Scenes
2485 return new Vector3(0, 0, 0); 2494 return new Vector3(0, 0, 0);
2486 2495
2487 return ParentGroup.GetGeometricCenter(); 2496 return ParentGroup.GetGeometricCenter();
2488
2489 /*
2490 PhysicsActor pa = PhysActor;
2491
2492 if (pa != null)
2493 {
2494 Vector3 vtmp = pa.CenterOfMass;
2495 return vtmp;
2496 }
2497 else
2498 return new Vector3(0, 0, 0);
2499 */
2500 } 2497 }
2501 2498
2502 public float GetMass() 2499 public float GetMass()
@@ -2910,11 +2907,14 @@ namespace OpenSim.Region.Framework.Scenes
2910 2907
2911 public void PhysicsOutOfBounds(Vector3 pos) 2908 public void PhysicsOutOfBounds(Vector3 pos)
2912 { 2909 {
2913 m_log.Error("[PHYSICS]: Physical Object went out of bounds."); 2910 // Note: This is only being called on the root prim at this time.
2911
2912 m_log.ErrorFormat(
2913 "[SCENE OBJECT PART]: Physical object {0}, localID {1} went out of bounds at {2} in {3}. Stopping at {4} and making non-physical.",
2914 Name, LocalId, pos, ParentGroup.Scene.Name, AbsolutePosition);
2914 2915
2915 RemFlag(PrimFlags.Physics); 2916 RemFlag(PrimFlags.Physics);
2916 DoPhysicsPropertyUpdate(false, true); 2917 DoPhysicsPropertyUpdate(false, true);
2917 //ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
2918 } 2918 }
2919 2919
2920 public void PhysicsRequestingTerseUpdate() 2920 public void PhysicsRequestingTerseUpdate()
@@ -3337,13 +3337,13 @@ namespace OpenSim.Region.Framework.Scenes
3337 ParentGroup.SetAxisRotation(axis, rotate); 3337 ParentGroup.SetAxisRotation(axis, rotate);
3338 3338
3339 //Cannot use ScriptBaseClass constants as no referance to it currently. 3339 //Cannot use ScriptBaseClass constants as no referance to it currently.
3340 if (axis == 2)//STATUS_ROTATE_X 3340 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_X) != 0)
3341 STATUS_ROTATE_X = rotate; 3341 STATUS_ROTATE_X = rotate;
3342 3342
3343 if (axis == 4)//STATUS_ROTATE_Y 3343 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y) != 0)
3344 STATUS_ROTATE_Y = rotate; 3344 STATUS_ROTATE_Y = rotate;
3345 3345
3346 if (axis == 8)//STATUS_ROTATE_Z 3346 if ((axis & (int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) != 0)
3347 STATUS_ROTATE_Z = rotate; 3347 STATUS_ROTATE_Z = rotate;
3348 } 3348 }
3349 3349
@@ -4250,6 +4250,7 @@ namespace OpenSim.Region.Framework.Scenes
4250 result.distance = distance2; 4250 result.distance = distance2;
4251 result.HitTF = true; 4251 result.HitTF = true;
4252 result.ipoint = q; 4252 result.ipoint = q;
4253 result.face = i;
4253 //m_log.Info("[FACE]:" + i.ToString()); 4254 //m_log.Info("[FACE]:" + i.ToString());
4254 //m_log.Info("[POINT]: " + q.ToString()); 4255 //m_log.Info("[POINT]: " + q.ToString());
4255 //m_log.Info("[DIST]: " + distance2.ToString()); 4256 //m_log.Info("[DIST]: " + distance2.ToString());
@@ -4573,7 +4574,7 @@ namespace OpenSim.Region.Framework.Scenes
4573 if (ParentGroup.RootPart == this) 4574 if (ParentGroup.RootPart == this)
4574 AngularVelocity = new Vector3(0, 0, 0); 4575 AngularVelocity = new Vector3(0, 0, 0);
4575 } 4576 }
4576 else 4577 else if (SetVD != wasVD)
4577 { 4578 {
4578 if (ParentGroup.Scene.CollidablePrims) 4579 if (ParentGroup.Scene.CollidablePrims)
4579 { 4580 {
@@ -4661,9 +4662,9 @@ namespace OpenSim.Region.Framework.Scenes
4661 PhysicsShapeType, 4662 PhysicsShapeType,
4662 m_localId); 4663 m_localId);
4663 } 4664 }
4664 catch (Exception ex) 4665 catch (Exception e)
4665 { 4666 {
4666 m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message); 4667 m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e);
4667 pa = null; 4668 pa = null;
4668 } 4669 }
4669 4670
@@ -4737,7 +4738,9 @@ namespace OpenSim.Region.Framework.Scenes
4737 } 4738 }
4738 4739
4739 PhysActor = pa; 4740 PhysActor = pa;
4740 } 4741
4742 ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this);
4743 }
4741 4744
4742 /// <summary> 4745 /// <summary>
4743 /// This removes the part from the physics scene. 4746 /// This removes the part from the physics scene.
@@ -4756,6 +4759,8 @@ namespace OpenSim.Region.Framework.Scenes
4756 pa.OnOutOfBounds -= PhysicsOutOfBounds; 4759 pa.OnOutOfBounds -= PhysicsOutOfBounds;
4757 4760
4758 ParentGroup.Scene.PhysicsScene.RemovePrim(pa); 4761 ParentGroup.Scene.PhysicsScene.RemovePrim(pa);
4762
4763 ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this);
4759 } 4764 }
4760 PhysActor = null; 4765 PhysActor = null;
4761 } 4766 }
@@ -5222,18 +5227,22 @@ namespace OpenSim.Region.Framework.Scenes
5222 /// <param name='avatarId'></param> 5227 /// <param name='avatarId'></param>
5223 protected internal bool AddSittingAvatar(UUID avatarId) 5228 protected internal bool AddSittingAvatar(UUID avatarId)
5224 { 5229 {
5225 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero) 5230 lock (ParentGroup.m_sittingAvatars)
5226 SitTargetAvatar = avatarId; 5231 {
5232 if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
5233 SitTargetAvatar = avatarId;
5227 5234
5228 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5235 if (m_sittingAvatars == null)
5236 m_sittingAvatars = new HashSet<UUID>();
5229 5237
5230 if (sittingAvatars == null) 5238 if (m_sittingAvatars.Add(avatarId))
5231 sittingAvatars = new HashSet<UUID>(); 5239 {
5240 ParentGroup.m_sittingAvatars.Add(avatarId);
5232 5241
5233 lock (sittingAvatars) 5242 return true;
5234 { 5243 }
5235 m_sittingAvatars = sittingAvatars; 5244
5236 return m_sittingAvatars.Add(avatarId); 5245 return false;
5237 } 5246 }
5238 } 5247 }
5239 5248
@@ -5247,27 +5256,26 @@ namespace OpenSim.Region.Framework.Scenes
5247 /// <param name='avatarId'></param> 5256 /// <param name='avatarId'></param>
5248 protected internal bool RemoveSittingAvatar(UUID avatarId) 5257 protected internal bool RemoveSittingAvatar(UUID avatarId)
5249 { 5258 {
5250 if (SitTargetAvatar == avatarId) 5259 lock (ParentGroup.m_sittingAvatars)
5251 SitTargetAvatar = UUID.Zero; 5260 {
5252 5261 if (SitTargetAvatar == avatarId)
5253 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5262 SitTargetAvatar = UUID.Zero;
5254 5263
5255 // This can occur under a race condition where another thread 5264 if (m_sittingAvatars == null)
5256 if (sittingAvatars == null) 5265 return false;
5257 return false;
5258 5266
5259 lock (sittingAvatars) 5267 if (m_sittingAvatars.Remove(avatarId))
5260 {
5261 if (sittingAvatars.Remove(avatarId))
5262 { 5268 {
5263 if (sittingAvatars.Count == 0) 5269 if (m_sittingAvatars.Count == 0)
5264 m_sittingAvatars = null; 5270 m_sittingAvatars = null;
5265 5271
5272 ParentGroup.m_sittingAvatars.Remove(avatarId);
5273
5266 return true; 5274 return true;
5267 } 5275 }
5268 }
5269 5276
5270 return false; 5277 return false;
5278 }
5271 } 5279 }
5272 5280
5273 /// <summary> 5281 /// <summary>
@@ -5277,16 +5285,12 @@ namespace OpenSim.Region.Framework.Scenes
5277 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns> 5285 /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
5278 public HashSet<UUID> GetSittingAvatars() 5286 public HashSet<UUID> GetSittingAvatars()
5279 { 5287 {
5280 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5288 lock (ParentGroup.m_sittingAvatars)
5281
5282 if (sittingAvatars == null)
5283 { 5289 {
5284 return null; 5290 if (m_sittingAvatars == null)
5285 } 5291 return null;
5286 else 5292 else
5287 { 5293 return new HashSet<UUID>(m_sittingAvatars);
5288 lock (sittingAvatars)
5289 return new HashSet<UUID>(sittingAvatars);
5290 } 5294 }
5291 } 5295 }
5292 5296
@@ -5297,13 +5301,13 @@ namespace OpenSim.Region.Framework.Scenes
5297 /// <returns></returns> 5301 /// <returns></returns>
5298 public int GetSittingAvatarsCount() 5302 public int GetSittingAvatarsCount()
5299 { 5303 {
5300 HashSet<UUID> sittingAvatars = m_sittingAvatars; 5304 lock (ParentGroup.m_sittingAvatars)
5301 5305 {
5302 if (sittingAvatars == null) 5306 if (m_sittingAvatars == null)
5303 return 0; 5307 return 0;
5304 5308 else
5305 lock (sittingAvatars) 5309 return m_sittingAvatars.Count;
5306 return sittingAvatars.Count; 5310 }
5307 } 5311 }
5308 } 5312 }
5309} 5313}