From 20a9bf08f51351e1e0a9de94f184ff56cd572665 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 1 May 2008 18:04:42 +0000 Subject: * Rolled back a few changes. --- .../Region/Environment/Scenes/SceneObjectGroup.cs | 377 +++++++++++---------- 1 file changed, 194 insertions(+), 183 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs') diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 1ea2f24..5d39790 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -72,7 +72,7 @@ namespace OpenSim.Region.Environment.Scenes object_rez = 4194304 } - internal struct scriptPosTarget + struct scriptPosTarget { public LLVector3 targetPos; public float tolerance; @@ -82,14 +82,14 @@ namespace OpenSim.Region.Environment.Scenes public partial class SceneObjectGroup : EntityBase { - private readonly Dictionary m_targets = new Dictionary(); - private PrimCountTaintedDelegate handlerPrimCountTainted; + private PrimCountTaintedDelegate handlerPrimCountTainted = null; /// /// Signal whether the non-inventory attributes of any prims in the group have changed /// since the group's last persistent backup /// - public bool HasGroupChanged; + public bool HasGroupChanged = false; + private LLVector3 lastPhysGroupPos; @@ -104,8 +104,11 @@ namespace OpenSim.Region.Environment.Scenes protected SceneObjectPart m_rootPart; private Dictionary m_scriptEvents = new Dictionary(); - private bool m_scriptListens_atTarget; - private bool m_scriptListens_notAtTarget; + private Dictionary m_targets = new Dictionary(); + + private bool m_scriptListens_atTarget = false; + private bool m_scriptListens_notAtTarget = false; + #region Properties @@ -116,7 +119,7 @@ namespace OpenSim.Region.Environment.Scenes /// think really there should be a list (or whatever) in each scenepresence /// saying what prim(s) that user has selected. /// - protected bool m_isSelected; + protected bool m_isSelected = false; /// /// @@ -183,6 +186,7 @@ namespace OpenSim.Region.Environment.Scenes string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid)); } + return m_rootPart.GroupPosition; } @@ -202,7 +206,7 @@ namespace OpenSim.Region.Environment.Scenes part.GroupPosition = val; } } - + //if (m_rootPart.PhysActor != null) //{ //m_rootPart.PhysActor.Position = @@ -212,7 +216,7 @@ namespace OpenSim.Region.Environment.Scenes //} } } - + public override uint LocalId { get @@ -511,11 +515,10 @@ namespace OpenSim.Region.Environment.Scenes m_scene.EventManager.OnBackup += ProcessBackup; } } - public LLVector3 GroupScale() { - LLVector3 minScale = new LLVector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); - LLVector3 maxScale = new LLVector3(0f, 0f, 0f); + LLVector3 minScale = new LLVector3(Constants.RegionSize,Constants.RegionSize,Constants.RegionSize); + LLVector3 maxScale = new LLVector3(0f,0f,0f); LLVector3 finalScale = new LLVector3(0.5f, 0.5f, 0.5f); lock (m_parts) @@ -538,8 +541,8 @@ namespace OpenSim.Region.Environment.Scenes finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; return finalScale; - } + } public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters) { // We got a request from the inner_scene to raytrace along the Ray hRay @@ -562,7 +565,7 @@ namespace OpenSim.Region.Environment.Scenes // Telling the prim to raytrace. //EntityIntersection inter = part.TestIntersection(hRay, parentrotation); - EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); + EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation,frontFacesOnly, faceCenters); // This may need to be updated to the maximum draw distance possible.. // We might (and probably will) be checking for prim creation from other sims @@ -681,11 +684,12 @@ namespace OpenSim.Region.Environment.Scenes DetachFromBackup(this); m_rootPart.m_attachedAvatar = agentID; - + if (m_rootPart.PhysActor != null) { m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); m_rootPart.PhysActor = null; + } AbsolutePosition = AttachOffset; @@ -705,28 +709,27 @@ namespace OpenSim.Region.Environment.Scenes m_rootPart.ScheduleFullUpdate(); } } - public byte GetAttachmentPoint() { if (m_rootPart != null) { return m_rootPart.Shape.State; } - return 0; + return (byte)0; } public void ClearPartAttachmentData() { foreach (SceneObjectPart part in m_parts.Values) { - part.SetAttachmentPoint(0); + part.SetAttachmentPoint((Byte)0); } } public void DetachToGround() { ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); - LLVector3 detachedpos = new LLVector3(127f, 127f, 127f); + LLVector3 detachedpos = new LLVector3(127f,127f,127f); if (avatar != null) { detachedpos = avatar.AbsolutePosition; @@ -735,14 +738,14 @@ namespace OpenSim.Region.Environment.Scenes AbsolutePosition = detachedpos; m_rootPart.m_attachedAvatar = LLUUID.Zero; m_rootPart.SetParentLocalId(0); - m_rootPart.SetAttachmentPoint(0); + m_rootPart.SetAttachmentPoint((byte)0); m_rootPart.m_IsAttachment = false; m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); AttachToBackup(); m_rootPart.ScheduleFullUpdate(); m_rootPart.ClearUndoState(); + } - public void DetachToInventoryPrep() { ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); @@ -752,7 +755,7 @@ namespace OpenSim.Region.Environment.Scenes //detachedpos = avatar.AbsolutePosition; avatar.RemoveAttachment(this); } - + m_rootPart.m_attachedAvatar = LLUUID.Zero; m_rootPart.SetParentLocalId(0); //m_rootPart.SetAttachmentPoint((byte)0); @@ -761,8 +764,8 @@ namespace OpenSim.Region.Environment.Scenes //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); //AttachToBackup(); //m_rootPart.ScheduleFullUpdate(); + } - /// /// /// @@ -823,6 +826,7 @@ namespace OpenSim.Region.Environment.Scenes try { m_parts.Add(part.UUID, part); + } catch (Exception e) { @@ -843,6 +847,7 @@ namespace OpenSim.Region.Environment.Scenes if (part.UUID != m_rootPart.UUID) { part.ParentID = m_rootPart.LocalId; + } } } @@ -855,10 +860,10 @@ namespace OpenSim.Region.Environment.Scenes foreach (SceneObjectPart part in m_parts.Values) { part.UUID = LLUUID.Random(); + } } } - // helper provided for parts. public int GetSceneMaxUndo() { @@ -866,7 +871,6 @@ namespace OpenSim.Region.Environment.Scenes return m_scene.MaxUndoCount; return 5; } - public void ResetChildPrimPhysicsPositions() { AbsolutePosition = AbsolutePosition; @@ -893,6 +897,7 @@ namespace OpenSim.Region.Environment.Scenes { SceneObjectPart part = GetChildPart(localId); OnGrabPart(part, offsetPos, remoteClient); + } } @@ -900,6 +905,7 @@ namespace OpenSim.Region.Environment.Scenes { part.StoreUndoState(); part.OnGrab(offsetPos, remoteClient); + } public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient) @@ -963,19 +969,19 @@ namespace OpenSim.Region.Environment.Scenes public void aggregateScriptEvents() { - uint objectflagupdate = RootPart.GetEffectiveObjectFlags(); + uint objectflagupdate=(uint)RootPart.GetEffectiveObjectFlags(); - scriptEvents aggregateScriptEvents = 0; + scriptEvents aggregateScriptEvents=0; lock (m_parts) { foreach (SceneObjectPart part in m_parts.Values) { - if (part == null) - continue; - if (part != RootPart) - part.ObjectFlags = objectflagupdate; - aggregateScriptEvents |= part.m_aggregateScriptEvents; + if(part == null) + continue; + if(part != RootPart) + part.ObjectFlags = objectflagupdate; + aggregateScriptEvents |= part.m_aggregateScriptEvents; } } @@ -1059,139 +1065,6 @@ namespace OpenSim.Region.Environment.Scenes } } - internal void SetAxisRotation(int axis, int rotate10) - { - bool setX = false; - bool setY = false; - bool setZ = false; - - int xaxis = 2; - int yaxis = 4; - int zaxis = 8; - - if (m_rootPart != null) - { - setX = ((axis & xaxis) != 0) ? true : false; - setY = ((axis & yaxis) != 0) ? true : false; - setZ = ((axis & zaxis) != 0) ? true : false; - - float setval = (rotate10 > 0) ? 1f : 0f; - - if (setX) - m_rootPart.m_rotationAxis.X = setval; - if (setY) - m_rootPart.m_rotationAxis.Y = setval; - if (setZ) - m_rootPart.m_rotationAxis.Z = setval; - - if (setX || setY || setZ) - { - m_rootPart.SetPhysicsAxisRotation(); - } - } - } - - public int registerTargetWaypoint(LLVector3 target, float tolerance) - { - scriptPosTarget waypoint = new scriptPosTarget(); - waypoint.targetPos = target; - waypoint.tolerance = tolerance; - uint handle = m_scene.PrimIDAllocate(); - lock (m_targets) - { - m_targets.Add(handle, waypoint); - } - return (int) handle; - } - - public void unregisterTargetWaypoint(int handle) - { - lock (m_targets) - { - if (m_targets.ContainsKey((uint) handle)) - m_targets.Remove((uint) handle); - } - } - - private void checkAtTargets() - { - if (m_scriptListens_atTarget || m_scriptListens_notAtTarget) - { - if (m_targets.Count > 0) - { - bool at_target = false; - //LLVector3 targetPos; - //uint targetHandle; - Dictionary atTargets = new Dictionary(); - lock (m_targets) - { - foreach (uint idx in m_targets.Keys) - { - scriptPosTarget target = m_targets[idx]; - if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) - { - // trigger at_target - if (m_scriptListens_atTarget) - { - // Reusing att.tolerance to hold the index of the target in the targets dictionary - // to avoid deadlocking the sim. - at_target = true; - scriptPosTarget att = new scriptPosTarget(); - att.targetPos = target.targetPos; - att.tolerance = idx; - atTargets.Add(idx, att); - } - } - } - } - if (atTargets.Count > 0) - { - uint[] localids = new uint[0]; - lock (m_parts) - { - localids = new uint[m_parts.Count]; - int cntr = 0; - foreach (SceneObjectPart part in m_parts.Values) - { - localids[cntr] = part.LocalId; - cntr++; - } - } - for (int ctr = 0; ctr < localids.Length; ctr++) - { - foreach (uint target in atTargets.Keys) - { - scriptPosTarget att = atTargets[target]; - // Reusing att.tolerance to hold the index of the target in the targets dictionary - // to avoid deadlocking the sim. - m_scene.TriggerAtTargetEvent(localids[ctr], (uint) att.tolerance, att.targetPos, m_rootPart.GroupPosition); - } - } - return; - } - if (m_scriptListens_notAtTarget && !at_target) - { - //trigger not_at_target - uint[] localids = new uint[0]; - lock (m_parts) - { - localids = new uint[m_parts.Count]; - int cntr = 0; - foreach (SceneObjectPart part in m_parts.Values) - { - localids[cntr] = part.LocalId; - cntr++; - } - } - for (int ctr = 0; ctr < localids.Length; ctr++) - { - m_scene.TriggerNotAtTargetEvent(localids[ctr]); - } - } - } - } - } - #region Events /// @@ -1489,8 +1362,9 @@ namespace OpenSim.Region.Environment.Scenes { m_parts.Add(newPart.UUID, newPart); } - + SetPartAsNonRoot(newPart); + } /// @@ -1560,30 +1434,32 @@ namespace OpenSim.Region.Environment.Scenes /// public override void Update() { + lock (m_parts) { //if (m_rootPart.m_IsAttachment) //{ - //foreach (SceneObjectPart part in m_parts.Values) - //{ - //part.SendScheduledUpdates(); + //foreach (SceneObjectPart part in m_parts.Values) + //{ + //part.SendScheduledUpdates(); + //} + //return; //} - //return; - //} - + if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) { m_rootPart.UpdateFlag = 1; lastPhysGroupPos = AbsolutePosition; } - //foreach (SceneObjectPart part in m_parts.Values) - //{ - //if (part.UpdateFlag == 0) part.UpdateFlag = 1; - //} - - - checkAtTargets(); + //foreach (SceneObjectPart part in m_parts.Values) + //{ + //if (part.UpdateFlag == 0) part.UpdateFlag = 1; + //} + + + checkAtTargets(); + if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) @@ -1887,7 +1763,7 @@ namespace OpenSim.Region.Environment.Scenes public void DelinkFromGroup(uint partID) { SceneObjectPart linkPart = GetChildPart(partID); - + if (null != linkPart) { linkPart.ClearUndoState(); @@ -2072,10 +1948,10 @@ namespace OpenSim.Region.Environment.Scenes proper.ObjectData[0].FromTaskID = LLUUID.Zero; proper.ObjectData[0].GroupID = LLUUID.Zero; proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial; - + proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID; // proper.ObjectData[0].LastOwnerID = LLUUID.Zero; - + proper.ObjectData[0].ObjectID = UUID; proper.ObjectData[0].OwnerID = m_rootPart.OwnerID; proper.ObjectData[0].TouchName = Helpers.StringToField(m_rootPart.TouchName); @@ -2515,5 +2391,140 @@ namespace OpenSim.Region.Environment.Scenes } #endregion + + internal void SetAxisRotation(int axis, int rotate10) + { + bool setX = false; + bool setY = false; + bool setZ = false; + + int xaxis = 2; + int yaxis = 4; + int zaxis = 8; + + if (m_rootPart != null) + { + setX = ((axis & xaxis) != 0) ? true : false; + setY = ((axis & yaxis) != 0) ? true : false; + setZ = ((axis & zaxis) != 0) ? true : false; + + float setval = (rotate10 > 0) ? 1f : 0f; + + if (setX) + m_rootPart.m_rotationAxis.X = setval; + if (setY) + m_rootPart.m_rotationAxis.Y = setval; + if (setZ) + m_rootPart.m_rotationAxis.Z = setval; + + if (setX || setY || setZ) + { + m_rootPart.SetPhysicsAxisRotation(); + } + + } + } + + public int registerTargetWaypoint(LLVector3 target, float tolerance) + { + scriptPosTarget waypoint = new scriptPosTarget(); + waypoint.targetPos = target; + waypoint.tolerance = tolerance; + uint handle = m_scene.PrimIDAllocate(); + lock (m_targets) + { + m_targets.Add(handle, waypoint); + } + return (int)handle; + } + public void unregisterTargetWaypoint(int handle) + { + lock (m_targets) + { + if (m_targets.ContainsKey((uint)handle)) + m_targets.Remove((uint)handle); + } + } + + private void checkAtTargets() + { + if (m_scriptListens_atTarget || m_scriptListens_notAtTarget) + { + if (m_targets.Count > 0) + { + bool at_target = false; + //LLVector3 targetPos; + //uint targetHandle; + Dictionary atTargets = new Dictionary(); + lock (m_targets) + { + foreach (uint idx in m_targets.Keys) + { + scriptPosTarget target = m_targets[idx]; + if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) + { + // trigger at_target + if (m_scriptListens_atTarget) + { + // Reusing att.tolerance to hold the index of the target in the targets dictionary + // to avoid deadlocking the sim. + at_target = true; + scriptPosTarget att = new scriptPosTarget(); + att.targetPos = target.targetPos; + att.tolerance = (float)idx; + atTargets.Add(idx, att); + } + } + } + } + if (atTargets.Count > 0) + { + uint[] localids = new uint[0]; + lock (m_parts) + { + localids = new uint[m_parts.Count]; + int cntr = 0; + foreach (SceneObjectPart part in m_parts.Values) + { + localids[cntr] = part.LocalId; + cntr++; + } + } + for (int ctr = 0; ctr < localids.Length; ctr++) + { + foreach (uint target in atTargets.Keys) + { + scriptPosTarget att = atTargets[target]; + // Reusing att.tolerance to hold the index of the target in the targets dictionary + // to avoid deadlocking the sim. + m_scene.TriggerAtTargetEvent(localids[ctr], (uint)att.tolerance, att.targetPos, m_rootPart.GroupPosition); + + + } + } + return; + } + if (m_scriptListens_notAtTarget && !at_target) + { + //trigger not_at_target + uint[] localids = new uint[0]; + lock (m_parts) + { + localids = new uint[m_parts.Count]; + int cntr = 0; + foreach (SceneObjectPart part in m_parts.Values) + { + localids[cntr] = part.LocalId; + cntr++; + } + } + for (int ctr = 0; ctr < localids.Length; ctr++) + { + m_scene.TriggerNotAtTargetEvent(localids[ctr]); + } + } + } + } + } } -} \ No newline at end of file +} -- cgit v1.1