aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-05-01 16:35:00 +0000
committerAdam Frisby2008-05-01 16:35:00 +0000
commit13526097f24b7a8ad63b1d482c44b44397fa055f (patch)
tree7a82c20ed7c63e2aea5ad3863325e37f64e1cbea /OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
parent* Breaking all the code, breaking all the code..! (diff)
downloadopensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.zip
opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.gz
opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.bz2
opensim-SC-13526097f24b7a8ad63b1d482c44b44397fa055f.tar.xz
* Spring cleaning on Region.Environment.
* Converted a large number of read-only fields to be actually, readonly. * Reformatted code sections. * Removed redundant code.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs377
1 files changed, 183 insertions, 194 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 5d39790..1ea2f24 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -72,7 +72,7 @@ namespace OpenSim.Region.Environment.Scenes
72 object_rez = 4194304 72 object_rez = 4194304
73 } 73 }
74 74
75 struct scriptPosTarget 75 internal struct scriptPosTarget
76 { 76 {
77 public LLVector3 targetPos; 77 public LLVector3 targetPos;
78 public float tolerance; 78 public float tolerance;
@@ -82,14 +82,14 @@ namespace OpenSim.Region.Environment.Scenes
82 82
83 public partial class SceneObjectGroup : EntityBase 83 public partial class SceneObjectGroup : EntityBase
84 { 84 {
85 private PrimCountTaintedDelegate handlerPrimCountTainted = null; 85 private readonly Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>();
86 private PrimCountTaintedDelegate handlerPrimCountTainted;
86 87
87 /// <summary> 88 /// <summary>
88 /// Signal whether the non-inventory attributes of any prims in the group have changed 89 /// Signal whether the non-inventory attributes of any prims in the group have changed
89 /// since the group's last persistent backup 90 /// since the group's last persistent backup
90 /// </summary> 91 /// </summary>
91 public bool HasGroupChanged = false; 92 public bool HasGroupChanged;
92
93 93
94 94
95 private LLVector3 lastPhysGroupPos; 95 private LLVector3 lastPhysGroupPos;
@@ -104,11 +104,8 @@ namespace OpenSim.Region.Environment.Scenes
104 protected SceneObjectPart m_rootPart; 104 protected SceneObjectPart m_rootPart;
105 private Dictionary<LLUUID, scriptEvents> m_scriptEvents = new Dictionary<LLUUID, scriptEvents>(); 105 private Dictionary<LLUUID, scriptEvents> m_scriptEvents = new Dictionary<LLUUID, scriptEvents>();
106 106
107 private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); 107 private bool m_scriptListens_atTarget;
108 108 private bool m_scriptListens_notAtTarget;
109 private bool m_scriptListens_atTarget = false;
110 private bool m_scriptListens_notAtTarget = false;
111
112 109
113 #region Properties 110 #region Properties
114 111
@@ -119,7 +116,7 @@ namespace OpenSim.Region.Environment.Scenes
119 /// think really there should be a list (or whatever) in each scenepresence 116 /// think really there should be a list (or whatever) in each scenepresence
120 /// saying what prim(s) that user has selected. 117 /// saying what prim(s) that user has selected.
121 /// </summary> 118 /// </summary>
122 protected bool m_isSelected = false; 119 protected bool m_isSelected;
123 120
124 /// <summary> 121 /// <summary>
125 /// 122 ///
@@ -186,7 +183,6 @@ namespace OpenSim.Region.Environment.Scenes
186 string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid)); 183 string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid));
187 } 184 }
188 185
189
190 186
191 return m_rootPart.GroupPosition; 187 return m_rootPart.GroupPosition;
192 } 188 }
@@ -206,7 +202,7 @@ namespace OpenSim.Region.Environment.Scenes
206 part.GroupPosition = val; 202 part.GroupPosition = val;
207 } 203 }
208 } 204 }
209 205
210 //if (m_rootPart.PhysActor != null) 206 //if (m_rootPart.PhysActor != null)
211 //{ 207 //{
212 //m_rootPart.PhysActor.Position = 208 //m_rootPart.PhysActor.Position =
@@ -216,7 +212,7 @@ namespace OpenSim.Region.Environment.Scenes
216 //} 212 //}
217 } 213 }
218 } 214 }
219 215
220 public override uint LocalId 216 public override uint LocalId
221 { 217 {
222 get 218 get
@@ -515,10 +511,11 @@ namespace OpenSim.Region.Environment.Scenes
515 m_scene.EventManager.OnBackup += ProcessBackup; 511 m_scene.EventManager.OnBackup += ProcessBackup;
516 } 512 }
517 } 513 }
514
518 public LLVector3 GroupScale() 515 public LLVector3 GroupScale()
519 { 516 {
520 LLVector3 minScale = new LLVector3(Constants.RegionSize,Constants.RegionSize,Constants.RegionSize); 517 LLVector3 minScale = new LLVector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize);
521 LLVector3 maxScale = new LLVector3(0f,0f,0f); 518 LLVector3 maxScale = new LLVector3(0f, 0f, 0f);
522 LLVector3 finalScale = new LLVector3(0.5f, 0.5f, 0.5f); 519 LLVector3 finalScale = new LLVector3(0.5f, 0.5f, 0.5f);
523 520
524 lock (m_parts) 521 lock (m_parts)
@@ -541,8 +538,8 @@ namespace OpenSim.Region.Environment.Scenes
541 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; 538 finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y;
542 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; 539 finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z;
543 return finalScale; 540 return finalScale;
544
545 } 541 }
542
546 public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters) 543 public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters)
547 { 544 {
548 // We got a request from the inner_scene to raytrace along the Ray hRay 545 // We got a request from the inner_scene to raytrace along the Ray hRay
@@ -565,7 +562,7 @@ namespace OpenSim.Region.Environment.Scenes
565 // Telling the prim to raytrace. 562 // Telling the prim to raytrace.
566 //EntityIntersection inter = part.TestIntersection(hRay, parentrotation); 563 //EntityIntersection inter = part.TestIntersection(hRay, parentrotation);
567 564
568 EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation,frontFacesOnly, faceCenters); 565 EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters);
569 566
570 // This may need to be updated to the maximum draw distance possible.. 567 // This may need to be updated to the maximum draw distance possible..
571 // We might (and probably will) be checking for prim creation from other sims 568 // We might (and probably will) be checking for prim creation from other sims
@@ -684,12 +681,11 @@ namespace OpenSim.Region.Environment.Scenes
684 DetachFromBackup(this); 681 DetachFromBackup(this);
685 m_rootPart.m_attachedAvatar = agentID; 682 m_rootPart.m_attachedAvatar = agentID;
686 683
687 684
688 if (m_rootPart.PhysActor != null) 685 if (m_rootPart.PhysActor != null)
689 { 686 {
690 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); 687 m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor);
691 m_rootPart.PhysActor = null; 688 m_rootPart.PhysActor = null;
692
693 } 689 }
694 690
695 AbsolutePosition = AttachOffset; 691 AbsolutePosition = AttachOffset;
@@ -709,27 +705,28 @@ namespace OpenSim.Region.Environment.Scenes
709 m_rootPart.ScheduleFullUpdate(); 705 m_rootPart.ScheduleFullUpdate();
710 } 706 }
711 } 707 }
708
712 public byte GetAttachmentPoint() 709 public byte GetAttachmentPoint()
713 { 710 {
714 if (m_rootPart != null) 711 if (m_rootPart != null)
715 { 712 {
716 return m_rootPart.Shape.State; 713 return m_rootPart.Shape.State;
717 } 714 }
718 return (byte)0; 715 return 0;
719 } 716 }
720 717
721 public void ClearPartAttachmentData() 718 public void ClearPartAttachmentData()
722 { 719 {
723 foreach (SceneObjectPart part in m_parts.Values) 720 foreach (SceneObjectPart part in m_parts.Values)
724 { 721 {
725 part.SetAttachmentPoint((Byte)0); 722 part.SetAttachmentPoint(0);
726 } 723 }
727 } 724 }
728 725
729 public void DetachToGround() 726 public void DetachToGround()
730 { 727 {
731 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); 728 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar);
732 LLVector3 detachedpos = new LLVector3(127f,127f,127f); 729 LLVector3 detachedpos = new LLVector3(127f, 127f, 127f);
733 if (avatar != null) 730 if (avatar != null)
734 { 731 {
735 detachedpos = avatar.AbsolutePosition; 732 detachedpos = avatar.AbsolutePosition;
@@ -738,14 +735,14 @@ namespace OpenSim.Region.Environment.Scenes
738 AbsolutePosition = detachedpos; 735 AbsolutePosition = detachedpos;
739 m_rootPart.m_attachedAvatar = LLUUID.Zero; 736 m_rootPart.m_attachedAvatar = LLUUID.Zero;
740 m_rootPart.SetParentLocalId(0); 737 m_rootPart.SetParentLocalId(0);
741 m_rootPart.SetAttachmentPoint((byte)0); 738 m_rootPart.SetAttachmentPoint(0);
742 m_rootPart.m_IsAttachment = false; 739 m_rootPart.m_IsAttachment = false;
743 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); 740 m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
744 AttachToBackup(); 741 AttachToBackup();
745 m_rootPart.ScheduleFullUpdate(); 742 m_rootPart.ScheduleFullUpdate();
746 m_rootPart.ClearUndoState(); 743 m_rootPart.ClearUndoState();
747
748 } 744 }
745
749 public void DetachToInventoryPrep() 746 public void DetachToInventoryPrep()
750 { 747 {
751 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); 748 ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar);
@@ -755,7 +752,7 @@ namespace OpenSim.Region.Environment.Scenes
755 //detachedpos = avatar.AbsolutePosition; 752 //detachedpos = avatar.AbsolutePosition;
756 avatar.RemoveAttachment(this); 753 avatar.RemoveAttachment(this);
757 } 754 }
758 755
759 m_rootPart.m_attachedAvatar = LLUUID.Zero; 756 m_rootPart.m_attachedAvatar = LLUUID.Zero;
760 m_rootPart.SetParentLocalId(0); 757 m_rootPart.SetParentLocalId(0);
761 //m_rootPart.SetAttachmentPoint((byte)0); 758 //m_rootPart.SetAttachmentPoint((byte)0);
@@ -764,8 +761,8 @@ namespace OpenSim.Region.Environment.Scenes
764 //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); 761 //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
765 //AttachToBackup(); 762 //AttachToBackup();
766 //m_rootPart.ScheduleFullUpdate(); 763 //m_rootPart.ScheduleFullUpdate();
767
768 } 764 }
765
769 /// <summary> 766 /// <summary>
770 /// 767 ///
771 /// </summary> 768 /// </summary>
@@ -826,7 +823,6 @@ namespace OpenSim.Region.Environment.Scenes
826 try 823 try
827 { 824 {
828 m_parts.Add(part.UUID, part); 825 m_parts.Add(part.UUID, part);
829
830 } 826 }
831 catch (Exception e) 827 catch (Exception e)
832 { 828 {
@@ -847,7 +843,6 @@ namespace OpenSim.Region.Environment.Scenes
847 if (part.UUID != m_rootPart.UUID) 843 if (part.UUID != m_rootPart.UUID)
848 { 844 {
849 part.ParentID = m_rootPart.LocalId; 845 part.ParentID = m_rootPart.LocalId;
850
851 } 846 }
852 } 847 }
853 } 848 }
@@ -860,10 +855,10 @@ namespace OpenSim.Region.Environment.Scenes
860 foreach (SceneObjectPart part in m_parts.Values) 855 foreach (SceneObjectPart part in m_parts.Values)
861 { 856 {
862 part.UUID = LLUUID.Random(); 857 part.UUID = LLUUID.Random();
863
864 } 858 }
865 } 859 }
866 } 860 }
861
867 // helper provided for parts. 862 // helper provided for parts.
868 public int GetSceneMaxUndo() 863 public int GetSceneMaxUndo()
869 { 864 {
@@ -871,6 +866,7 @@ namespace OpenSim.Region.Environment.Scenes
871 return m_scene.MaxUndoCount; 866 return m_scene.MaxUndoCount;
872 return 5; 867 return 5;
873 } 868 }
869
874 public void ResetChildPrimPhysicsPositions() 870 public void ResetChildPrimPhysicsPositions()
875 { 871 {
876 AbsolutePosition = AbsolutePosition; 872 AbsolutePosition = AbsolutePosition;
@@ -897,7 +893,6 @@ namespace OpenSim.Region.Environment.Scenes
897 { 893 {
898 SceneObjectPart part = GetChildPart(localId); 894 SceneObjectPart part = GetChildPart(localId);
899 OnGrabPart(part, offsetPos, remoteClient); 895 OnGrabPart(part, offsetPos, remoteClient);
900
901 } 896 }
902 } 897 }
903 898
@@ -905,7 +900,6 @@ namespace OpenSim.Region.Environment.Scenes
905 { 900 {
906 part.StoreUndoState(); 901 part.StoreUndoState();
907 part.OnGrab(offsetPos, remoteClient); 902 part.OnGrab(offsetPos, remoteClient);
908
909 } 903 }
910 904
911 public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient) 905 public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient)
@@ -969,19 +963,19 @@ namespace OpenSim.Region.Environment.Scenes
969 963
970 public void aggregateScriptEvents() 964 public void aggregateScriptEvents()
971 { 965 {
972 uint objectflagupdate=(uint)RootPart.GetEffectiveObjectFlags(); 966 uint objectflagupdate = RootPart.GetEffectiveObjectFlags();
973 967
974 scriptEvents aggregateScriptEvents=0; 968 scriptEvents aggregateScriptEvents = 0;
975 969
976 lock (m_parts) 970 lock (m_parts)
977 { 971 {
978 foreach (SceneObjectPart part in m_parts.Values) 972 foreach (SceneObjectPart part in m_parts.Values)
979 { 973 {
980 if(part == null) 974 if (part == null)
981 continue; 975 continue;
982 if(part != RootPart) 976 if (part != RootPart)
983 part.ObjectFlags = objectflagupdate; 977 part.ObjectFlags = objectflagupdate;
984 aggregateScriptEvents |= part.m_aggregateScriptEvents; 978 aggregateScriptEvents |= part.m_aggregateScriptEvents;
985 } 979 }
986 } 980 }
987 981
@@ -1065,6 +1059,139 @@ namespace OpenSim.Region.Environment.Scenes
1065 } 1059 }
1066 } 1060 }
1067 1061
1062 internal void SetAxisRotation(int axis, int rotate10)
1063 {
1064 bool setX = false;
1065 bool setY = false;
1066 bool setZ = false;
1067
1068 int xaxis = 2;
1069 int yaxis = 4;
1070 int zaxis = 8;
1071
1072 if (m_rootPart != null)
1073 {
1074 setX = ((axis & xaxis) != 0) ? true : false;
1075 setY = ((axis & yaxis) != 0) ? true : false;
1076 setZ = ((axis & zaxis) != 0) ? true : false;
1077
1078 float setval = (rotate10 > 0) ? 1f : 0f;
1079
1080 if (setX)
1081 m_rootPart.m_rotationAxis.X = setval;
1082 if (setY)
1083 m_rootPart.m_rotationAxis.Y = setval;
1084 if (setZ)
1085 m_rootPart.m_rotationAxis.Z = setval;
1086
1087 if (setX || setY || setZ)
1088 {
1089 m_rootPart.SetPhysicsAxisRotation();
1090 }
1091 }
1092 }
1093
1094 public int registerTargetWaypoint(LLVector3 target, float tolerance)
1095 {
1096 scriptPosTarget waypoint = new scriptPosTarget();
1097 waypoint.targetPos = target;
1098 waypoint.tolerance = tolerance;
1099 uint handle = m_scene.PrimIDAllocate();
1100 lock (m_targets)
1101 {
1102 m_targets.Add(handle, waypoint);
1103 }
1104 return (int) handle;
1105 }
1106
1107 public void unregisterTargetWaypoint(int handle)
1108 {
1109 lock (m_targets)
1110 {
1111 if (m_targets.ContainsKey((uint) handle))
1112 m_targets.Remove((uint) handle);
1113 }
1114 }
1115
1116 private void checkAtTargets()
1117 {
1118 if (m_scriptListens_atTarget || m_scriptListens_notAtTarget)
1119 {
1120 if (m_targets.Count > 0)
1121 {
1122 bool at_target = false;
1123 //LLVector3 targetPos;
1124 //uint targetHandle;
1125 Dictionary<uint, scriptPosTarget> atTargets = new Dictionary<uint, scriptPosTarget>();
1126 lock (m_targets)
1127 {
1128 foreach (uint idx in m_targets.Keys)
1129 {
1130 scriptPosTarget target = m_targets[idx];
1131 if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance)
1132 {
1133 // trigger at_target
1134 if (m_scriptListens_atTarget)
1135 {
1136 // Reusing att.tolerance to hold the index of the target in the targets dictionary
1137 // to avoid deadlocking the sim.
1138 at_target = true;
1139 scriptPosTarget att = new scriptPosTarget();
1140 att.targetPos = target.targetPos;
1141 att.tolerance = idx;
1142 atTargets.Add(idx, att);
1143 }
1144 }
1145 }
1146 }
1147 if (atTargets.Count > 0)
1148 {
1149 uint[] localids = new uint[0];
1150 lock (m_parts)
1151 {
1152 localids = new uint[m_parts.Count];
1153 int cntr = 0;
1154 foreach (SceneObjectPart part in m_parts.Values)
1155 {
1156 localids[cntr] = part.LocalId;
1157 cntr++;
1158 }
1159 }
1160 for (int ctr = 0; ctr < localids.Length; ctr++)
1161 {
1162 foreach (uint target in atTargets.Keys)
1163 {
1164 scriptPosTarget att = atTargets[target];
1165 // Reusing att.tolerance to hold the index of the target in the targets dictionary
1166 // to avoid deadlocking the sim.
1167 m_scene.TriggerAtTargetEvent(localids[ctr], (uint) att.tolerance, att.targetPos, m_rootPart.GroupPosition);
1168 }
1169 }
1170 return;
1171 }
1172 if (m_scriptListens_notAtTarget && !at_target)
1173 {
1174 //trigger not_at_target
1175 uint[] localids = new uint[0];
1176 lock (m_parts)
1177 {
1178 localids = new uint[m_parts.Count];
1179 int cntr = 0;
1180 foreach (SceneObjectPart part in m_parts.Values)
1181 {
1182 localids[cntr] = part.LocalId;
1183 cntr++;
1184 }
1185 }
1186 for (int ctr = 0; ctr < localids.Length; ctr++)
1187 {
1188 m_scene.TriggerNotAtTargetEvent(localids[ctr]);
1189 }
1190 }
1191 }
1192 }
1193 }
1194
1068 #region Events 1195 #region Events
1069 1196
1070 /// <summary> 1197 /// <summary>
@@ -1362,9 +1489,8 @@ namespace OpenSim.Region.Environment.Scenes
1362 { 1489 {
1363 m_parts.Add(newPart.UUID, newPart); 1490 m_parts.Add(newPart.UUID, newPart);
1364 } 1491 }
1365 1492
1366 SetPartAsNonRoot(newPart); 1493 SetPartAsNonRoot(newPart);
1367
1368 } 1494 }
1369 1495
1370 /// <summary> 1496 /// <summary>
@@ -1434,32 +1560,30 @@ namespace OpenSim.Region.Environment.Scenes
1434 /// </summary> 1560 /// </summary>
1435 public override void Update() 1561 public override void Update()
1436 { 1562 {
1437
1438 lock (m_parts) 1563 lock (m_parts)
1439 { 1564 {
1440 //if (m_rootPart.m_IsAttachment) 1565 //if (m_rootPart.m_IsAttachment)
1441 //{ 1566 //{
1442 //foreach (SceneObjectPart part in m_parts.Values) 1567 //foreach (SceneObjectPart part in m_parts.Values)
1443 //{ 1568 //{
1444 //part.SendScheduledUpdates(); 1569 //part.SendScheduledUpdates();
1445 //}
1446 //return;
1447 //} 1570 //}
1448 1571 //return;
1572 //}
1573
1449 if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) 1574 if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02)
1450 { 1575 {
1451 m_rootPart.UpdateFlag = 1; 1576 m_rootPart.UpdateFlag = 1;
1452 lastPhysGroupPos = AbsolutePosition; 1577 lastPhysGroupPos = AbsolutePosition;
1453 } 1578 }
1454 //foreach (SceneObjectPart part in m_parts.Values) 1579 //foreach (SceneObjectPart part in m_parts.Values)
1455 //{ 1580 //{
1456 //if (part.UpdateFlag == 0) part.UpdateFlag = 1; 1581 //if (part.UpdateFlag == 0) part.UpdateFlag = 1;
1457 //} 1582 //}
1583
1584
1585 checkAtTargets();
1458 1586
1459
1460
1461 checkAtTargets();
1462
1463 1587
1464 if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) 1588 if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1)
1465 || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) 1589 || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1)
@@ -1763,7 +1887,7 @@ namespace OpenSim.Region.Environment.Scenes
1763 public void DelinkFromGroup(uint partID) 1887 public void DelinkFromGroup(uint partID)
1764 { 1888 {
1765 SceneObjectPart linkPart = GetChildPart(partID); 1889 SceneObjectPart linkPart = GetChildPart(partID);
1766 1890
1767 if (null != linkPart) 1891 if (null != linkPart)
1768 { 1892 {
1769 linkPart.ClearUndoState(); 1893 linkPart.ClearUndoState();
@@ -1948,10 +2072,10 @@ namespace OpenSim.Region.Environment.Scenes
1948 proper.ObjectData[0].FromTaskID = LLUUID.Zero; 2072 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
1949 proper.ObjectData[0].GroupID = LLUUID.Zero; 2073 proper.ObjectData[0].GroupID = LLUUID.Zero;
1950 proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial; 2074 proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial;
1951 2075
1952 proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID; 2076 proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID;
1953// proper.ObjectData[0].LastOwnerID = LLUUID.Zero; 2077// proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
1954 2078
1955 proper.ObjectData[0].ObjectID = UUID; 2079 proper.ObjectData[0].ObjectID = UUID;
1956 proper.ObjectData[0].OwnerID = m_rootPart.OwnerID; 2080 proper.ObjectData[0].OwnerID = m_rootPart.OwnerID;
1957 proper.ObjectData[0].TouchName = Helpers.StringToField(m_rootPart.TouchName); 2081 proper.ObjectData[0].TouchName = Helpers.StringToField(m_rootPart.TouchName);
@@ -2391,140 +2515,5 @@ namespace OpenSim.Region.Environment.Scenes
2391 } 2515 }
2392 2516
2393 #endregion 2517 #endregion
2394
2395 internal void SetAxisRotation(int axis, int rotate10)
2396 {
2397 bool setX = false;
2398 bool setY = false;
2399 bool setZ = false;
2400
2401 int xaxis = 2;
2402 int yaxis = 4;
2403 int zaxis = 8;
2404
2405 if (m_rootPart != null)
2406 {
2407 setX = ((axis & xaxis) != 0) ? true : false;
2408 setY = ((axis & yaxis) != 0) ? true : false;
2409 setZ = ((axis & zaxis) != 0) ? true : false;
2410
2411 float setval = (rotate10 > 0) ? 1f : 0f;
2412
2413 if (setX)
2414 m_rootPart.m_rotationAxis.X = setval;
2415 if (setY)
2416 m_rootPart.m_rotationAxis.Y = setval;
2417 if (setZ)
2418 m_rootPart.m_rotationAxis.Z = setval;
2419
2420 if (setX || setY || setZ)
2421 {
2422 m_rootPart.SetPhysicsAxisRotation();
2423 }
2424
2425 }
2426 }
2427
2428 public int registerTargetWaypoint(LLVector3 target, float tolerance)
2429 {
2430 scriptPosTarget waypoint = new scriptPosTarget();
2431 waypoint.targetPos = target;
2432 waypoint.tolerance = tolerance;
2433 uint handle = m_scene.PrimIDAllocate();
2434 lock (m_targets)
2435 {
2436 m_targets.Add(handle, waypoint);
2437 }
2438 return (int)handle;
2439 }
2440 public void unregisterTargetWaypoint(int handle)
2441 {
2442 lock (m_targets)
2443 {
2444 if (m_targets.ContainsKey((uint)handle))
2445 m_targets.Remove((uint)handle);
2446 }
2447 }
2448
2449 private void checkAtTargets()
2450 {
2451 if (m_scriptListens_atTarget || m_scriptListens_notAtTarget)
2452 {
2453 if (m_targets.Count > 0)
2454 {
2455 bool at_target = false;
2456 //LLVector3 targetPos;
2457 //uint targetHandle;
2458 Dictionary<uint, scriptPosTarget> atTargets = new Dictionary<uint, scriptPosTarget>();
2459 lock (m_targets)
2460 {
2461 foreach (uint idx in m_targets.Keys)
2462 {
2463 scriptPosTarget target = m_targets[idx];
2464 if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance)
2465 {
2466 // trigger at_target
2467 if (m_scriptListens_atTarget)
2468 {
2469 // Reusing att.tolerance to hold the index of the target in the targets dictionary
2470 // to avoid deadlocking the sim.
2471 at_target = true;
2472 scriptPosTarget att = new scriptPosTarget();
2473 att.targetPos = target.targetPos;
2474 att.tolerance = (float)idx;
2475 atTargets.Add(idx, att);
2476 }
2477 }
2478 }
2479 }
2480 if (atTargets.Count > 0)
2481 {
2482 uint[] localids = new uint[0];
2483 lock (m_parts)
2484 {
2485 localids = new uint[m_parts.Count];
2486 int cntr = 0;
2487 foreach (SceneObjectPart part in m_parts.Values)
2488 {
2489 localids[cntr] = part.LocalId;
2490 cntr++;
2491 }
2492 }
2493 for (int ctr = 0; ctr < localids.Length; ctr++)
2494 {
2495 foreach (uint target in atTargets.Keys)
2496 {
2497 scriptPosTarget att = atTargets[target];
2498 // Reusing att.tolerance to hold the index of the target in the targets dictionary
2499 // to avoid deadlocking the sim.
2500 m_scene.TriggerAtTargetEvent(localids[ctr], (uint)att.tolerance, att.targetPos, m_rootPart.GroupPosition);
2501
2502
2503 }
2504 }
2505 return;
2506 }
2507 if (m_scriptListens_notAtTarget && !at_target)
2508 {
2509 //trigger not_at_target
2510 uint[] localids = new uint[0];
2511 lock (m_parts)
2512 {
2513 localids = new uint[m_parts.Count];
2514 int cntr = 0;
2515 foreach (SceneObjectPart part in m_parts.Values)
2516 {
2517 localids[cntr] = part.LocalId;
2518 cntr++;
2519 }
2520 }
2521 for (int ctr = 0; ctr < localids.Length; ctr++)
2522 {
2523 m_scene.TriggerNotAtTargetEvent(localids[ctr]);
2524 }
2525 }
2526 }
2527 }
2528 }
2529 } 2518 }
2530} 2519} \ No newline at end of file