diff options
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 377 |
1 files changed, 194 insertions, 183 deletions
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 | |||
72 | object_rez = 4194304 | 72 | object_rez = 4194304 |
73 | } | 73 | } |
74 | 74 | ||
75 | internal struct scriptPosTarget | 75 | 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 readonly Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); | 85 | private PrimCountTaintedDelegate handlerPrimCountTainted = null; |
86 | private PrimCountTaintedDelegate handlerPrimCountTainted; | ||
87 | 86 | ||
88 | /// <summary> | 87 | /// <summary> |
89 | /// Signal whether the non-inventory attributes of any prims in the group have changed | 88 | /// Signal whether the non-inventory attributes of any prims in the group have changed |
90 | /// since the group's last persistent backup | 89 | /// since the group's last persistent backup |
91 | /// </summary> | 90 | /// </summary> |
92 | public bool HasGroupChanged; | 91 | public bool HasGroupChanged = false; |
92 | |||
93 | 93 | ||
94 | 94 | ||
95 | private LLVector3 lastPhysGroupPos; | 95 | private LLVector3 lastPhysGroupPos; |
@@ -104,8 +104,11 @@ 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 bool m_scriptListens_atTarget; | 107 | private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); |
108 | private bool m_scriptListens_notAtTarget; | 108 | |
109 | private bool m_scriptListens_atTarget = false; | ||
110 | private bool m_scriptListens_notAtTarget = false; | ||
111 | |||
109 | 112 | ||
110 | #region Properties | 113 | #region Properties |
111 | 114 | ||
@@ -116,7 +119,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
116 | /// think really there should be a list (or whatever) in each scenepresence | 119 | /// think really there should be a list (or whatever) in each scenepresence |
117 | /// saying what prim(s) that user has selected. | 120 | /// saying what prim(s) that user has selected. |
118 | /// </summary> | 121 | /// </summary> |
119 | protected bool m_isSelected; | 122 | protected bool m_isSelected = false; |
120 | 123 | ||
121 | /// <summary> | 124 | /// <summary> |
122 | /// | 125 | /// |
@@ -183,6 +186,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
183 | string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid)); | 186 | string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid)); |
184 | } | 187 | } |
185 | 188 | ||
189 | |||
186 | 190 | ||
187 | return m_rootPart.GroupPosition; | 191 | return m_rootPart.GroupPosition; |
188 | } | 192 | } |
@@ -202,7 +206,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
202 | part.GroupPosition = val; | 206 | part.GroupPosition = val; |
203 | } | 207 | } |
204 | } | 208 | } |
205 | 209 | ||
206 | //if (m_rootPart.PhysActor != null) | 210 | //if (m_rootPart.PhysActor != null) |
207 | //{ | 211 | //{ |
208 | //m_rootPart.PhysActor.Position = | 212 | //m_rootPart.PhysActor.Position = |
@@ -212,7 +216,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
212 | //} | 216 | //} |
213 | } | 217 | } |
214 | } | 218 | } |
215 | 219 | ||
216 | public override uint LocalId | 220 | public override uint LocalId |
217 | { | 221 | { |
218 | get | 222 | get |
@@ -511,11 +515,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
511 | m_scene.EventManager.OnBackup += ProcessBackup; | 515 | m_scene.EventManager.OnBackup += ProcessBackup; |
512 | } | 516 | } |
513 | } | 517 | } |
514 | |||
515 | public LLVector3 GroupScale() | 518 | public LLVector3 GroupScale() |
516 | { | 519 | { |
517 | LLVector3 minScale = new LLVector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); | 520 | LLVector3 minScale = new LLVector3(Constants.RegionSize,Constants.RegionSize,Constants.RegionSize); |
518 | LLVector3 maxScale = new LLVector3(0f, 0f, 0f); | 521 | LLVector3 maxScale = new LLVector3(0f,0f,0f); |
519 | LLVector3 finalScale = new LLVector3(0.5f, 0.5f, 0.5f); | 522 | LLVector3 finalScale = new LLVector3(0.5f, 0.5f, 0.5f); |
520 | 523 | ||
521 | lock (m_parts) | 524 | lock (m_parts) |
@@ -538,8 +541,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
538 | finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; | 541 | finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; |
539 | finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; | 542 | finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; |
540 | return finalScale; | 543 | return finalScale; |
541 | } | ||
542 | 544 | ||
545 | } | ||
543 | public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters) | 546 | public EntityIntersection TestIntersection(Ray hRay, bool frontFacesOnly, bool faceCenters) |
544 | { | 547 | { |
545 | // We got a request from the inner_scene to raytrace along the Ray hRay | 548 | // We got a request from the inner_scene to raytrace along the Ray hRay |
@@ -562,7 +565,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
562 | // Telling the prim to raytrace. | 565 | // Telling the prim to raytrace. |
563 | //EntityIntersection inter = part.TestIntersection(hRay, parentrotation); | 566 | //EntityIntersection inter = part.TestIntersection(hRay, parentrotation); |
564 | 567 | ||
565 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); | 568 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation,frontFacesOnly, faceCenters); |
566 | 569 | ||
567 | // This may need to be updated to the maximum draw distance possible.. | 570 | // This may need to be updated to the maximum draw distance possible.. |
568 | // We might (and probably will) be checking for prim creation from other sims | 571 | // We might (and probably will) be checking for prim creation from other sims |
@@ -681,11 +684,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
681 | DetachFromBackup(this); | 684 | DetachFromBackup(this); |
682 | m_rootPart.m_attachedAvatar = agentID; | 685 | m_rootPart.m_attachedAvatar = agentID; |
683 | 686 | ||
684 | 687 | ||
685 | if (m_rootPart.PhysActor != null) | 688 | if (m_rootPart.PhysActor != null) |
686 | { | 689 | { |
687 | m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); | 690 | m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor); |
688 | m_rootPart.PhysActor = null; | 691 | m_rootPart.PhysActor = null; |
692 | |||
689 | } | 693 | } |
690 | 694 | ||
691 | AbsolutePosition = AttachOffset; | 695 | AbsolutePosition = AttachOffset; |
@@ -705,28 +709,27 @@ namespace OpenSim.Region.Environment.Scenes | |||
705 | m_rootPart.ScheduleFullUpdate(); | 709 | m_rootPart.ScheduleFullUpdate(); |
706 | } | 710 | } |
707 | } | 711 | } |
708 | |||
709 | public byte GetAttachmentPoint() | 712 | public byte GetAttachmentPoint() |
710 | { | 713 | { |
711 | if (m_rootPart != null) | 714 | if (m_rootPart != null) |
712 | { | 715 | { |
713 | return m_rootPart.Shape.State; | 716 | return m_rootPart.Shape.State; |
714 | } | 717 | } |
715 | return 0; | 718 | return (byte)0; |
716 | } | 719 | } |
717 | 720 | ||
718 | public void ClearPartAttachmentData() | 721 | public void ClearPartAttachmentData() |
719 | { | 722 | { |
720 | foreach (SceneObjectPart part in m_parts.Values) | 723 | foreach (SceneObjectPart part in m_parts.Values) |
721 | { | 724 | { |
722 | part.SetAttachmentPoint(0); | 725 | part.SetAttachmentPoint((Byte)0); |
723 | } | 726 | } |
724 | } | 727 | } |
725 | 728 | ||
726 | public void DetachToGround() | 729 | public void DetachToGround() |
727 | { | 730 | { |
728 | ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); | 731 | ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); |
729 | LLVector3 detachedpos = new LLVector3(127f, 127f, 127f); | 732 | LLVector3 detachedpos = new LLVector3(127f,127f,127f); |
730 | if (avatar != null) | 733 | if (avatar != null) |
731 | { | 734 | { |
732 | detachedpos = avatar.AbsolutePosition; | 735 | detachedpos = avatar.AbsolutePosition; |
@@ -735,14 +738,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
735 | AbsolutePosition = detachedpos; | 738 | AbsolutePosition = detachedpos; |
736 | m_rootPart.m_attachedAvatar = LLUUID.Zero; | 739 | m_rootPart.m_attachedAvatar = LLUUID.Zero; |
737 | m_rootPart.SetParentLocalId(0); | 740 | m_rootPart.SetParentLocalId(0); |
738 | m_rootPart.SetAttachmentPoint(0); | 741 | m_rootPart.SetAttachmentPoint((byte)0); |
739 | m_rootPart.m_IsAttachment = false; | 742 | m_rootPart.m_IsAttachment = false; |
740 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); | 743 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); |
741 | AttachToBackup(); | 744 | AttachToBackup(); |
742 | m_rootPart.ScheduleFullUpdate(); | 745 | m_rootPart.ScheduleFullUpdate(); |
743 | m_rootPart.ClearUndoState(); | 746 | m_rootPart.ClearUndoState(); |
747 | |||
744 | } | 748 | } |
745 | |||
746 | public void DetachToInventoryPrep() | 749 | public void DetachToInventoryPrep() |
747 | { | 750 | { |
748 | ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); | 751 | ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.m_attachedAvatar); |
@@ -752,7 +755,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
752 | //detachedpos = avatar.AbsolutePosition; | 755 | //detachedpos = avatar.AbsolutePosition; |
753 | avatar.RemoveAttachment(this); | 756 | avatar.RemoveAttachment(this); |
754 | } | 757 | } |
755 | 758 | ||
756 | m_rootPart.m_attachedAvatar = LLUUID.Zero; | 759 | m_rootPart.m_attachedAvatar = LLUUID.Zero; |
757 | m_rootPart.SetParentLocalId(0); | 760 | m_rootPart.SetParentLocalId(0); |
758 | //m_rootPart.SetAttachmentPoint((byte)0); | 761 | //m_rootPart.SetAttachmentPoint((byte)0); |
@@ -761,8 +764,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
761 | //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); | 764 | //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); |
762 | //AttachToBackup(); | 765 | //AttachToBackup(); |
763 | //m_rootPart.ScheduleFullUpdate(); | 766 | //m_rootPart.ScheduleFullUpdate(); |
767 | |||
764 | } | 768 | } |
765 | |||
766 | /// <summary> | 769 | /// <summary> |
767 | /// | 770 | /// |
768 | /// </summary> | 771 | /// </summary> |
@@ -823,6 +826,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
823 | try | 826 | try |
824 | { | 827 | { |
825 | m_parts.Add(part.UUID, part); | 828 | m_parts.Add(part.UUID, part); |
829 | |||
826 | } | 830 | } |
827 | catch (Exception e) | 831 | catch (Exception e) |
828 | { | 832 | { |
@@ -843,6 +847,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
843 | if (part.UUID != m_rootPart.UUID) | 847 | if (part.UUID != m_rootPart.UUID) |
844 | { | 848 | { |
845 | part.ParentID = m_rootPart.LocalId; | 849 | part.ParentID = m_rootPart.LocalId; |
850 | |||
846 | } | 851 | } |
847 | } | 852 | } |
848 | } | 853 | } |
@@ -855,10 +860,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
855 | foreach (SceneObjectPart part in m_parts.Values) | 860 | foreach (SceneObjectPart part in m_parts.Values) |
856 | { | 861 | { |
857 | part.UUID = LLUUID.Random(); | 862 | part.UUID = LLUUID.Random(); |
863 | |||
858 | } | 864 | } |
859 | } | 865 | } |
860 | } | 866 | } |
861 | |||
862 | // helper provided for parts. | 867 | // helper provided for parts. |
863 | public int GetSceneMaxUndo() | 868 | public int GetSceneMaxUndo() |
864 | { | 869 | { |
@@ -866,7 +871,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
866 | return m_scene.MaxUndoCount; | 871 | return m_scene.MaxUndoCount; |
867 | return 5; | 872 | return 5; |
868 | } | 873 | } |
869 | |||
870 | public void ResetChildPrimPhysicsPositions() | 874 | public void ResetChildPrimPhysicsPositions() |
871 | { | 875 | { |
872 | AbsolutePosition = AbsolutePosition; | 876 | AbsolutePosition = AbsolutePosition; |
@@ -893,6 +897,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
893 | { | 897 | { |
894 | SceneObjectPart part = GetChildPart(localId); | 898 | SceneObjectPart part = GetChildPart(localId); |
895 | OnGrabPart(part, offsetPos, remoteClient); | 899 | OnGrabPart(part, offsetPos, remoteClient); |
900 | |||
896 | } | 901 | } |
897 | } | 902 | } |
898 | 903 | ||
@@ -900,6 +905,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
900 | { | 905 | { |
901 | part.StoreUndoState(); | 906 | part.StoreUndoState(); |
902 | part.OnGrab(offsetPos, remoteClient); | 907 | part.OnGrab(offsetPos, remoteClient); |
908 | |||
903 | } | 909 | } |
904 | 910 | ||
905 | public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient) | 911 | public virtual void OnGrabGroup(LLVector3 offsetPos, IClientAPI remoteClient) |
@@ -963,19 +969,19 @@ namespace OpenSim.Region.Environment.Scenes | |||
963 | 969 | ||
964 | public void aggregateScriptEvents() | 970 | public void aggregateScriptEvents() |
965 | { | 971 | { |
966 | uint objectflagupdate = RootPart.GetEffectiveObjectFlags(); | 972 | uint objectflagupdate=(uint)RootPart.GetEffectiveObjectFlags(); |
967 | 973 | ||
968 | scriptEvents aggregateScriptEvents = 0; | 974 | scriptEvents aggregateScriptEvents=0; |
969 | 975 | ||
970 | lock (m_parts) | 976 | lock (m_parts) |
971 | { | 977 | { |
972 | foreach (SceneObjectPart part in m_parts.Values) | 978 | foreach (SceneObjectPart part in m_parts.Values) |
973 | { | 979 | { |
974 | if (part == null) | 980 | if(part == null) |
975 | continue; | 981 | continue; |
976 | if (part != RootPart) | 982 | if(part != RootPart) |
977 | part.ObjectFlags = objectflagupdate; | 983 | part.ObjectFlags = objectflagupdate; |
978 | aggregateScriptEvents |= part.m_aggregateScriptEvents; | 984 | aggregateScriptEvents |= part.m_aggregateScriptEvents; |
979 | } | 985 | } |
980 | } | 986 | } |
981 | 987 | ||
@@ -1059,139 +1065,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
1059 | } | 1065 | } |
1060 | } | 1066 | } |
1061 | 1067 | ||
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 | |||
1195 | #region Events | 1068 | #region Events |
1196 | 1069 | ||
1197 | /// <summary> | 1070 | /// <summary> |
@@ -1489,8 +1362,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
1489 | { | 1362 | { |
1490 | m_parts.Add(newPart.UUID, newPart); | 1363 | m_parts.Add(newPart.UUID, newPart); |
1491 | } | 1364 | } |
1492 | 1365 | ||
1493 | SetPartAsNonRoot(newPart); | 1366 | SetPartAsNonRoot(newPart); |
1367 | |||
1494 | } | 1368 | } |
1495 | 1369 | ||
1496 | /// <summary> | 1370 | /// <summary> |
@@ -1560,30 +1434,32 @@ namespace OpenSim.Region.Environment.Scenes | |||
1560 | /// </summary> | 1434 | /// </summary> |
1561 | public override void Update() | 1435 | public override void Update() |
1562 | { | 1436 | { |
1437 | |||
1563 | lock (m_parts) | 1438 | lock (m_parts) |
1564 | { | 1439 | { |
1565 | //if (m_rootPart.m_IsAttachment) | 1440 | //if (m_rootPart.m_IsAttachment) |
1566 | //{ | 1441 | //{ |
1567 | //foreach (SceneObjectPart part in m_parts.Values) | 1442 | //foreach (SceneObjectPart part in m_parts.Values) |
1568 | //{ | 1443 | //{ |
1569 | //part.SendScheduledUpdates(); | 1444 | //part.SendScheduledUpdates(); |
1445 | //} | ||
1446 | //return; | ||
1570 | //} | 1447 | //} |
1571 | //return; | 1448 | |
1572 | //} | ||
1573 | |||
1574 | if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) | 1449 | if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) |
1575 | { | 1450 | { |
1576 | m_rootPart.UpdateFlag = 1; | 1451 | m_rootPart.UpdateFlag = 1; |
1577 | lastPhysGroupPos = AbsolutePosition; | 1452 | lastPhysGroupPos = AbsolutePosition; |
1578 | } | 1453 | } |
1579 | //foreach (SceneObjectPart part in m_parts.Values) | 1454 | //foreach (SceneObjectPart part in m_parts.Values) |
1580 | //{ | 1455 | //{ |
1581 | //if (part.UpdateFlag == 0) part.UpdateFlag = 1; | 1456 | //if (part.UpdateFlag == 0) part.UpdateFlag = 1; |
1582 | //} | 1457 | //} |
1583 | |||
1584 | |||
1585 | checkAtTargets(); | ||
1586 | 1458 | ||
1459 | |||
1460 | |||
1461 | checkAtTargets(); | ||
1462 | |||
1587 | 1463 | ||
1588 | if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) | 1464 | if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) |
1589 | || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) | 1465 | || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) |
@@ -1887,7 +1763,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1887 | public void DelinkFromGroup(uint partID) | 1763 | public void DelinkFromGroup(uint partID) |
1888 | { | 1764 | { |
1889 | SceneObjectPart linkPart = GetChildPart(partID); | 1765 | SceneObjectPart linkPart = GetChildPart(partID); |
1890 | 1766 | ||
1891 | if (null != linkPart) | 1767 | if (null != linkPart) |
1892 | { | 1768 | { |
1893 | linkPart.ClearUndoState(); | 1769 | linkPart.ClearUndoState(); |
@@ -2072,10 +1948,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
2072 | proper.ObjectData[0].FromTaskID = LLUUID.Zero; | 1948 | proper.ObjectData[0].FromTaskID = LLUUID.Zero; |
2073 | proper.ObjectData[0].GroupID = LLUUID.Zero; | 1949 | proper.ObjectData[0].GroupID = LLUUID.Zero; |
2074 | proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial; | 1950 | proper.ObjectData[0].InventorySerial = (short) m_rootPart.InventorySerial; |
2075 | 1951 | ||
2076 | proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID; | 1952 | proper.ObjectData[0].LastOwnerID = m_rootPart.LastOwnerID; |
2077 | // proper.ObjectData[0].LastOwnerID = LLUUID.Zero; | 1953 | // proper.ObjectData[0].LastOwnerID = LLUUID.Zero; |
2078 | 1954 | ||
2079 | proper.ObjectData[0].ObjectID = UUID; | 1955 | proper.ObjectData[0].ObjectID = UUID; |
2080 | proper.ObjectData[0].OwnerID = m_rootPart.OwnerID; | 1956 | proper.ObjectData[0].OwnerID = m_rootPart.OwnerID; |
2081 | proper.ObjectData[0].TouchName = Helpers.StringToField(m_rootPart.TouchName); | 1957 | proper.ObjectData[0].TouchName = Helpers.StringToField(m_rootPart.TouchName); |
@@ -2515,5 +2391,140 @@ namespace OpenSim.Region.Environment.Scenes | |||
2515 | } | 2391 | } |
2516 | 2392 | ||
2517 | #endregion | 2393 | #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 | } | ||
2518 | } | 2529 | } |
2519 | } \ No newline at end of file | 2530 | } |