diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPart.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 174 |
1 files changed, 109 insertions, 65 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 20a6626..b8c209e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -37,6 +37,7 @@ using System.Xml.Serialization; | |||
37 | using log4net; | 37 | using log4net; |
38 | using OpenMetaverse; | 38 | using OpenMetaverse; |
39 | using OpenMetaverse.Packets; | 39 | using OpenMetaverse.Packets; |
40 | using OpenMetaverse.StructuredData; | ||
40 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
41 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes.Scripting; | 43 | using 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,8 @@ 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 | |
4578 | else | ||
4577 | { | 4579 | { |
4578 | if (ParentGroup.Scene.CollidablePrims) | 4580 | if (ParentGroup.Scene.CollidablePrims) |
4579 | { | 4581 | { |
@@ -4619,9 +4621,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
4619 | UpdatePhysicsSubscribedEvents(); | 4621 | UpdatePhysicsSubscribedEvents(); |
4620 | } | 4622 | } |
4621 | } | 4623 | } |
4622 | 4624 | if (SetVD) | |
4625 | { | ||
4626 | // If the above logic worked (this is urgent candidate to unit tests!) | ||
4627 | // we now have a physicsactor. | ||
4628 | // Defensive programming calls for a check here. | ||
4629 | // Better would be throwing an exception that could be catched by a unit test as the internal | ||
4630 | // logic should make sure, this Physactor is always here. | ||
4631 | if (pa != null) | ||
4632 | { | ||
4633 | pa.SetVolumeDetect(1); | ||
4634 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | ||
4635 | VolumeDetectActive = true; | ||
4636 | } | ||
4623 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | 4637 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); |
4638 | } | ||
4639 | else if (SetVD != wasVD) | ||
4640 | { | ||
4641 | // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like | ||
4642 | // (mumbles, well, at least if you have infinte CPU powers :-)) | ||
4643 | if (pa != null) | ||
4644 | pa.SetVolumeDetect(0); | ||
4624 | 4645 | ||
4646 | RemFlag(PrimFlags.Phantom); | ||
4647 | VolumeDetectActive = false; | ||
4648 | } | ||
4625 | // and last in case we have a new actor and not building | 4649 | // and last in case we have a new actor and not building |
4626 | 4650 | ||
4627 | if (ParentGroup != null) | 4651 | if (ParentGroup != null) |
@@ -4661,9 +4685,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4661 | PhysicsShapeType, | 4685 | PhysicsShapeType, |
4662 | m_localId); | 4686 | m_localId); |
4663 | } | 4687 | } |
4664 | catch (Exception ex) | 4688 | catch (Exception e) |
4665 | { | 4689 | { |
4666 | m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message); | 4690 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); |
4667 | pa = null; | 4691 | pa = null; |
4668 | } | 4692 | } |
4669 | 4693 | ||
@@ -4737,7 +4761,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4737 | } | 4761 | } |
4738 | 4762 | ||
4739 | PhysActor = pa; | 4763 | PhysActor = pa; |
4740 | } | 4764 | |
4765 | ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); | ||
4766 | } | ||
4741 | 4767 | ||
4742 | /// <summary> | 4768 | /// <summary> |
4743 | /// This removes the part from the physics scene. | 4769 | /// This removes the part from the physics scene. |
@@ -4756,6 +4782,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4756 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | 4782 | pa.OnOutOfBounds -= PhysicsOutOfBounds; |
4757 | 4783 | ||
4758 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | 4784 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); |
4785 | |||
4786 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | ||
4759 | } | 4787 | } |
4760 | PhysActor = null; | 4788 | PhysActor = null; |
4761 | } | 4789 | } |
@@ -4931,8 +4959,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
4931 | 4959 | ||
4932 | Changed changeFlags = 0; | 4960 | Changed changeFlags = 0; |
4933 | 4961 | ||
4962 | Primitive.TextureEntryFace fallbackNewFace = newTex.DefaultTexture; | ||
4963 | Primitive.TextureEntryFace fallbackOldFace = oldTex.DefaultTexture; | ||
4964 | |||
4965 | // On Incoming packets, sometimes newText.DefaultTexture is null. The assumption is that all | ||
4966 | // other prim-sides are set, but apparently that's not always the case. Lets assume packet/data corruption at this point. | ||
4967 | if (fallbackNewFace == null) | ||
4968 | { | ||
4969 | fallbackNewFace = new Primitive.TextureEntry(Util.BLANK_TEXTURE_UUID).CreateFace(0); | ||
4970 | newTex.DefaultTexture = fallbackNewFace; | ||
4971 | } | ||
4972 | if (fallbackOldFace == null) | ||
4973 | { | ||
4974 | fallbackOldFace = new Primitive.TextureEntry(Util.BLANK_TEXTURE_UUID).CreateFace(0); | ||
4975 | oldTex.DefaultTexture = fallbackOldFace; | ||
4976 | } | ||
4977 | |||
4934 | for (int i = 0 ; i < GetNumberOfSides(); i++) | 4978 | for (int i = 0 ; i < GetNumberOfSides(); i++) |
4935 | { | 4979 | { |
4980 | |||
4936 | Primitive.TextureEntryFace newFace = newTex.DefaultTexture; | 4981 | Primitive.TextureEntryFace newFace = newTex.DefaultTexture; |
4937 | Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture; | 4982 | Primitive.TextureEntryFace oldFace = oldTex.DefaultTexture; |
4938 | 4983 | ||
@@ -5222,18 +5267,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
5222 | /// <param name='avatarId'></param> | 5267 | /// <param name='avatarId'></param> |
5223 | protected internal bool AddSittingAvatar(UUID avatarId) | 5268 | protected internal bool AddSittingAvatar(UUID avatarId) |
5224 | { | 5269 | { |
5225 | if (IsSitTargetSet && SitTargetAvatar == UUID.Zero) | 5270 | lock (ParentGroup.m_sittingAvatars) |
5226 | SitTargetAvatar = avatarId; | 5271 | { |
5272 | if (IsSitTargetSet && SitTargetAvatar == UUID.Zero) | ||
5273 | SitTargetAvatar = avatarId; | ||
5227 | 5274 | ||
5228 | HashSet<UUID> sittingAvatars = m_sittingAvatars; | 5275 | if (m_sittingAvatars == null) |
5276 | m_sittingAvatars = new HashSet<UUID>(); | ||
5229 | 5277 | ||
5230 | if (sittingAvatars == null) | 5278 | if (m_sittingAvatars.Add(avatarId)) |
5231 | sittingAvatars = new HashSet<UUID>(); | 5279 | { |
5280 | ParentGroup.m_sittingAvatars.Add(avatarId); | ||
5232 | 5281 | ||
5233 | lock (sittingAvatars) | 5282 | return true; |
5234 | { | 5283 | } |
5235 | m_sittingAvatars = sittingAvatars; | 5284 | |
5236 | return m_sittingAvatars.Add(avatarId); | 5285 | return false; |
5237 | } | 5286 | } |
5238 | } | 5287 | } |
5239 | 5288 | ||
@@ -5247,27 +5296,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
5247 | /// <param name='avatarId'></param> | 5296 | /// <param name='avatarId'></param> |
5248 | protected internal bool RemoveSittingAvatar(UUID avatarId) | 5297 | protected internal bool RemoveSittingAvatar(UUID avatarId) |
5249 | { | 5298 | { |
5250 | if (SitTargetAvatar == avatarId) | 5299 | lock (ParentGroup.m_sittingAvatars) |
5251 | SitTargetAvatar = UUID.Zero; | 5300 | { |
5252 | 5301 | if (SitTargetAvatar == avatarId) | |
5253 | HashSet<UUID> sittingAvatars = m_sittingAvatars; | 5302 | SitTargetAvatar = UUID.Zero; |
5254 | 5303 | ||
5255 | // This can occur under a race condition where another thread | 5304 | if (m_sittingAvatars == null) |
5256 | if (sittingAvatars == null) | 5305 | return false; |
5257 | return false; | ||
5258 | 5306 | ||
5259 | lock (sittingAvatars) | 5307 | if (m_sittingAvatars.Remove(avatarId)) |
5260 | { | ||
5261 | if (sittingAvatars.Remove(avatarId)) | ||
5262 | { | 5308 | { |
5263 | if (sittingAvatars.Count == 0) | 5309 | if (m_sittingAvatars.Count == 0) |
5264 | m_sittingAvatars = null; | 5310 | m_sittingAvatars = null; |
5265 | 5311 | ||
5312 | ParentGroup.m_sittingAvatars.Remove(avatarId); | ||
5313 | |||
5266 | return true; | 5314 | return true; |
5267 | } | 5315 | } |
5268 | } | ||
5269 | 5316 | ||
5270 | return false; | 5317 | return false; |
5318 | } | ||
5271 | } | 5319 | } |
5272 | 5320 | ||
5273 | /// <summary> | 5321 | /// <summary> |
@@ -5277,16 +5325,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5277 | /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns> | 5325 | /// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns> |
5278 | public HashSet<UUID> GetSittingAvatars() | 5326 | public HashSet<UUID> GetSittingAvatars() |
5279 | { | 5327 | { |
5280 | HashSet<UUID> sittingAvatars = m_sittingAvatars; | 5328 | lock (ParentGroup.m_sittingAvatars) |
5281 | |||
5282 | if (sittingAvatars == null) | ||
5283 | { | ||
5284 | return null; | ||
5285 | } | ||
5286 | else | ||
5287 | { | 5329 | { |
5288 | lock (sittingAvatars) | 5330 | if (m_sittingAvatars == null) |
5289 | return new HashSet<UUID>(sittingAvatars); | 5331 | return null; |
5332 | else | ||
5333 | return new HashSet<UUID>(m_sittingAvatars); | ||
5290 | } | 5334 | } |
5291 | } | 5335 | } |
5292 | 5336 | ||
@@ -5297,13 +5341,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
5297 | /// <returns></returns> | 5341 | /// <returns></returns> |
5298 | public int GetSittingAvatarsCount() | 5342 | public int GetSittingAvatarsCount() |
5299 | { | 5343 | { |
5300 | HashSet<UUID> sittingAvatars = m_sittingAvatars; | 5344 | lock (ParentGroup.m_sittingAvatars) |
5301 | 5345 | { | |
5302 | if (sittingAvatars == null) | 5346 | if (m_sittingAvatars == null) |
5303 | return 0; | 5347 | return 0; |
5304 | 5348 | else | |
5305 | lock (sittingAvatars) | 5349 | return m_sittingAvatars.Count; |
5306 | return sittingAvatars.Count; | 5350 | } |
5307 | } | 5351 | } |
5308 | } | 5352 | } |
5309 | } | 5353 | } |