diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
31 files changed, 5518 insertions, 1984 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 5beee73..c1394aa 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -80,12 +80,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
80 | m_scenePresence = sp; | 80 | m_scenePresence = sp; |
81 | CurrentMovementAnimation = "CROUCH"; | 81 | CurrentMovementAnimation = "CROUCH"; |
82 | } | 82 | } |
83 | 83 | ||
84 | public void AddAnimation(UUID animID, UUID objectID) | 84 | public void AddAnimation(UUID animID, UUID objectID) |
85 | { | 85 | { |
86 | if (m_scenePresence.IsChildAgent) | 86 | if (m_scenePresence.IsChildAgent) |
87 | return; | 87 | return; |
88 | 88 | ||
89 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); | ||
89 | if (m_scenePresence.Scene.DebugAnimations) | 90 | if (m_scenePresence.Scene.DebugAnimations) |
90 | m_log.DebugFormat( | 91 | m_log.DebugFormat( |
91 | "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", | 92 | "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", |
@@ -140,6 +141,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
140 | } | 141 | } |
141 | } | 142 | } |
142 | 143 | ||
144 | public void avnChangeAnim(UUID animID, bool addRemove, bool sendPack) | ||
145 | { | ||
146 | if (m_scenePresence.IsChildAgent) | ||
147 | return; | ||
148 | |||
149 | if (animID != UUID.Zero) | ||
150 | { | ||
151 | if (addRemove) | ||
152 | m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero); | ||
153 | else | ||
154 | m_animations.Remove(animID, true); | ||
155 | } | ||
156 | if(sendPack) | ||
157 | SendAnimPack(); | ||
158 | } | ||
159 | |||
143 | // Called from scripts | 160 | // Called from scripts |
144 | public void RemoveAnimation(string name) | 161 | public void RemoveAnimation(string name) |
145 | { | 162 | { |
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs new file mode 100644 index 0000000..075724e --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs | |||
@@ -0,0 +1,304 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | // Ubit 2012 | ||
28 | |||
29 | using System; | ||
30 | using System.Reflection; | ||
31 | using System.Collections.Generic; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using log4net; | ||
35 | |||
36 | namespace OpenSim.Region.Framework.Scenes | ||
37 | { | ||
38 | public struct CollisionForSoundInfo | ||
39 | { | ||
40 | public uint colliderID; | ||
41 | public Vector3 position; | ||
42 | public float relativeVel; | ||
43 | } | ||
44 | |||
45 | public static class CollisionSounds | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private const int MaxMaterials = 7; | ||
50 | // part part | ||
51 | |||
52 | private static UUID snd_StoneStone = new UUID("be7295c0-a158-11e1-b3dd-0800200c9a66"); | ||
53 | private static UUID snd_StoneMetal = new UUID("be7295c0-a158-11e1-b3dd-0800201c9a66"); | ||
54 | private static UUID snd_StoneGlass = new UUID("be7295c0-a158-11e1-b3dd-0800202c9a66"); | ||
55 | private static UUID snd_StoneWood = new UUID("be7295c0-a158-11e1-b3dd-0800203c9a66"); | ||
56 | private static UUID snd_StoneFlesh = new UUID("be7295c0-a158-11e1-b3dd-0800204c9a66"); | ||
57 | private static UUID snd_StonePlastic = new UUID("be7295c0-a158-11e1-b3dd-0800205c9a66"); | ||
58 | private static UUID snd_StoneRubber = new UUID("be7295c0-a158-11e1-b3dd-0800206c9a66"); | ||
59 | |||
60 | private static UUID snd_MetalMetal = new UUID("be7295c0-a158-11e1-b3dd-0801201c9a66"); | ||
61 | private static UUID snd_MetalGlass = new UUID("be7295c0-a158-11e1-b3dd-0801202c9a66"); | ||
62 | private static UUID snd_MetalWood = new UUID("be7295c0-a158-11e1-b3dd-0801203c9a66"); | ||
63 | private static UUID snd_MetalFlesh = new UUID("be7295c0-a158-11e1-b3dd-0801204c9a66"); | ||
64 | private static UUID snd_MetalPlastic = new UUID("be7295c0-a158-11e1-b3dd-0801205c9a66"); | ||
65 | private static UUID snd_MetalRubber = new UUID("be7295c0-a158-11e1-b3dd-0801206c9a66"); | ||
66 | |||
67 | private static UUID snd_GlassGlass = new UUID("be7295c0-a158-11e1-b3dd-0802202c9a66"); | ||
68 | private static UUID snd_GlassWood = new UUID("be7295c0-a158-11e1-b3dd-0802203c9a66"); | ||
69 | private static UUID snd_GlassFlesh = new UUID("be7295c0-a158-11e1-b3dd-0802204c9a66"); | ||
70 | private static UUID snd_GlassPlastic = new UUID("be7295c0-a158-11e1-b3dd-0802205c9a66"); | ||
71 | private static UUID snd_GlassRubber = new UUID("be7295c0-a158-11e1-b3dd-0802206c9a66"); | ||
72 | |||
73 | private static UUID snd_WoodWood = new UUID("be7295c0-a158-11e1-b3dd-0803203c9a66"); | ||
74 | private static UUID snd_WoodFlesh = new UUID("be7295c0-a158-11e1-b3dd-0803204c9a66"); | ||
75 | private static UUID snd_WoodPlastic = new UUID("be7295c0-a158-11e1-b3dd-0803205c9a66"); | ||
76 | private static UUID snd_WoodRubber = new UUID("be7295c0-a158-11e1-b3dd-0803206c9a66"); | ||
77 | |||
78 | private static UUID snd_FleshFlesh = new UUID("be7295c0-a158-11e1-b3dd-0804204c9a66"); | ||
79 | private static UUID snd_FleshPlastic = new UUID("be7295c0-a158-11e1-b3dd-0804205c9a66"); | ||
80 | private static UUID snd_FleshRubber = new UUID("be7295c0-a158-11e1-b3dd-0804206c9a66"); | ||
81 | |||
82 | private static UUID snd_PlasticPlastic = new UUID("be7295c0-a158-11e1-b3dd-0805205c9a66"); | ||
83 | private static UUID snd_PlasticRubber = new UUID("be7295c0-a158-11e1-b3dd-0805206c9a66"); | ||
84 | |||
85 | private static UUID snd_RubberRubber = new UUID("be7295c0-a158-11e1-b3dd-0806206c9a66"); | ||
86 | |||
87 | // terrain part | ||
88 | private static UUID snd_TerrainStone = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
89 | private static UUID snd_TerrainMetal = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
90 | private static UUID snd_TerrainGlass = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
91 | private static UUID snd_TerrainWood = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
92 | private static UUID snd_TerrainFlesh = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
93 | private static UUID snd_TerrainPlastic = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
94 | private static UUID snd_TerrainRubber = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
95 | |||
96 | public static UUID[] m_TerrainPart = { | ||
97 | snd_TerrainStone, | ||
98 | snd_TerrainMetal, | ||
99 | snd_TerrainGlass, | ||
100 | snd_TerrainWood, | ||
101 | snd_TerrainFlesh, | ||
102 | snd_TerrainPlastic, | ||
103 | snd_TerrainRubber | ||
104 | }; | ||
105 | |||
106 | // simetric sounds | ||
107 | public static UUID[] m_PartPart = { | ||
108 | snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, | ||
109 | snd_StoneMetal, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, | ||
110 | snd_StoneGlass, snd_MetalGlass, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber, | ||
111 | snd_StoneWood, snd_MetalWood, snd_GlassWood, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber, | ||
112 | snd_StoneFlesh, snd_MetalFlesh, snd_GlassFlesh, snd_WoodFlesh, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber, | ||
113 | snd_StonePlastic, snd_MetalPlastic, snd_GlassPlastic, snd_WoodPlastic, snd_FleshPlastic, snd_PlasticPlastic, snd_PlasticRubber, | ||
114 | snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber | ||
115 | }; | ||
116 | |||
117 | public static void PartCollisionSound(SceneObjectPart part, List<CollisionForSoundInfo> collidersinfolist) | ||
118 | { | ||
119 | if (collidersinfolist.Count == 0 || part == null) | ||
120 | return; | ||
121 | |||
122 | if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) | ||
123 | return; | ||
124 | |||
125 | if (part.ParentGroup == null) | ||
126 | return; | ||
127 | |||
128 | if (part.CollisionSoundType < 0) | ||
129 | return; | ||
130 | |||
131 | float volume = 0.0f; | ||
132 | bool HaveSound = false; | ||
133 | |||
134 | UUID soundID = part.CollisionSound; | ||
135 | |||
136 | if (part.CollisionSoundType > 0) | ||
137 | { | ||
138 | // soundID = part.CollisionSound; | ||
139 | volume = part.CollisionSoundVolume; | ||
140 | if (volume == 0.0f) | ||
141 | return; | ||
142 | HaveSound = true; | ||
143 | } | ||
144 | |||
145 | bool doneownsound = false; | ||
146 | |||
147 | int thisMaterial = (int)part.Material; | ||
148 | if (thisMaterial >= MaxMaterials) | ||
149 | thisMaterial = 3; | ||
150 | int thisMatScaled = thisMaterial * MaxMaterials; | ||
151 | |||
152 | CollisionForSoundInfo colInfo; | ||
153 | uint id; | ||
154 | |||
155 | for(int i = 0; i< collidersinfolist.Count; i++) | ||
156 | { | ||
157 | colInfo = collidersinfolist[i]; | ||
158 | |||
159 | id = colInfo.colliderID; | ||
160 | if (id == 0) // terrain collision | ||
161 | { | ||
162 | if (!doneownsound) | ||
163 | { | ||
164 | if (!HaveSound) | ||
165 | { | ||
166 | volume = Math.Abs(colInfo.relativeVel); | ||
167 | if (volume < 0.2f) | ||
168 | continue; | ||
169 | |||
170 | volume *= volume * .0625f; // 4m/s == full volume | ||
171 | if (volume > 1.0f) | ||
172 | volume = 1.0f; | ||
173 | |||
174 | soundID = m_TerrainPart[thisMaterial]; | ||
175 | } | ||
176 | part.SendCollisionSound(soundID, volume, colInfo.position); | ||
177 | doneownsound = true; | ||
178 | } | ||
179 | continue; | ||
180 | } | ||
181 | |||
182 | SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); | ||
183 | if (otherPart != null) | ||
184 | { | ||
185 | if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive) | ||
186 | continue; | ||
187 | |||
188 | if (!HaveSound) | ||
189 | { | ||
190 | if (otherPart.CollisionSoundType > 0) | ||
191 | { | ||
192 | soundID = otherPart.CollisionSound; | ||
193 | volume = otherPart.CollisionSoundVolume; | ||
194 | if (volume == 0.0f) | ||
195 | continue; | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | volume = Math.Abs(colInfo.relativeVel); | ||
200 | if (volume < 0.2f) | ||
201 | continue; | ||
202 | |||
203 | volume *= volume * .0625f; // 4m/s == full volume | ||
204 | if (volume > 1.0f) | ||
205 | volume = 1.0f; | ||
206 | |||
207 | int otherMaterial = (int)otherPart.Material; | ||
208 | if (otherMaterial >= MaxMaterials) | ||
209 | otherMaterial = 3; | ||
210 | |||
211 | soundID = m_PartPart[thisMatScaled + otherMaterial]; | ||
212 | } | ||
213 | } | ||
214 | |||
215 | if (doneownsound) | ||
216 | otherPart.SendCollisionSound(soundID, volume, colInfo.position); | ||
217 | else | ||
218 | { | ||
219 | part.SendCollisionSound(soundID, volume, colInfo.position); | ||
220 | doneownsound = true; | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | |||
226 | public static void AvatarCollisionSound(ScenePresence av, List<CollisionForSoundInfo> collidersinfolist) | ||
227 | { | ||
228 | if (collidersinfolist.Count == 0 || av == null) | ||
229 | return; | ||
230 | |||
231 | UUID soundID; | ||
232 | int otherMaterial; | ||
233 | |||
234 | int thisMaterial = 4; // flesh | ||
235 | |||
236 | int thisMatScaled = thisMaterial * MaxMaterials; | ||
237 | |||
238 | // bool doneownsound = false; | ||
239 | |||
240 | CollisionForSoundInfo colInfo; | ||
241 | uint id; | ||
242 | float volume; | ||
243 | |||
244 | for(int i = 0; i< collidersinfolist.Count; i++) | ||
245 | { | ||
246 | colInfo = collidersinfolist[i]; | ||
247 | |||
248 | id = colInfo.colliderID; | ||
249 | |||
250 | if (id == 0) // no terrain collision sounds for now | ||
251 | { | ||
252 | continue; | ||
253 | // volume = Math.Abs(colInfo.relativeVel); | ||
254 | // if (volume < 0.2f) | ||
255 | // continue; | ||
256 | |||
257 | } | ||
258 | |||
259 | SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); | ||
260 | if (otherPart != null) | ||
261 | { | ||
262 | if (otherPart.CollisionSoundType < 0) | ||
263 | continue; | ||
264 | if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f) | ||
265 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); | ||
266 | else | ||
267 | { | ||
268 | volume = Math.Abs(colInfo.relativeVel); | ||
269 | // Most noral collisions (running into walls, stairs) | ||
270 | // should never be heard. | ||
271 | if (volume < 3.2f) | ||
272 | continue; | ||
273 | // m_log.DebugFormat("Collision speed was {0}", volume); | ||
274 | |||
275 | // Cap to 0.2 times volume because climbing stairs should not be noisy | ||
276 | // Also changed scaling | ||
277 | volume *= volume * .0125f; // 4m/s == volume 0.2 | ||
278 | if (volume > 0.2f) | ||
279 | volume = 0.2f; | ||
280 | otherMaterial = (int)otherPart.Material; | ||
281 | if (otherMaterial >= MaxMaterials) | ||
282 | otherMaterial = 3; | ||
283 | |||
284 | soundID = m_PartPart[thisMatScaled + otherMaterial]; | ||
285 | otherPart.SendCollisionSound(soundID, volume, colInfo.position); | ||
286 | } | ||
287 | continue; | ||
288 | } | ||
289 | /* | ||
290 | else if (!doneownsound) | ||
291 | { | ||
292 | ScenePresence otherav = av.Scene.GetScenePresence(Id); | ||
293 | if (otherav != null && (!otherav.IsChildAgent)) | ||
294 | { | ||
295 | soundID = snd_FleshFlesh; | ||
296 | av.SendCollisionSound(soundID, 1.0); | ||
297 | doneownsound = true; | ||
298 | } | ||
299 | } | ||
300 | */ | ||
301 | } | ||
302 | } | ||
303 | } | ||
304 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 37b5776..7f06e82 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -90,6 +90,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
90 | /// </remarks> | 90 | /// </remarks> |
91 | public event OnTerrainTickDelegate OnTerrainTick; | 91 | public event OnTerrainTickDelegate OnTerrainTick; |
92 | 92 | ||
93 | public delegate void OnTerrainUpdateDelegate(); | ||
94 | |||
95 | public event OnTerrainUpdateDelegate OnTerrainUpdate; | ||
96 | |||
93 | public delegate void OnBackupDelegate(ISimulationDataService datastore, bool forceBackup); | 97 | public delegate void OnBackupDelegate(ISimulationDataService datastore, bool forceBackup); |
94 | 98 | ||
95 | /// <summary> | 99 | /// <summary> |
@@ -339,8 +343,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
339 | /// in <see cref="Scene.SetScriptRunning"/> | 343 | /// in <see cref="Scene.SetScriptRunning"/> |
340 | /// via <see cref="OpenSim.Framework.IClientAPI.OnSetScriptRunning"/>, | 344 | /// via <see cref="OpenSim.Framework.IClientAPI.OnSetScriptRunning"/>, |
341 | /// via <see cref="OpenSim.Region.ClientStack.LindenUDP.HandleSetScriptRunning"/> | 345 | /// via <see cref="OpenSim.Region.ClientStack.LindenUDP.HandleSetScriptRunning"/> |
342 | /// XXX: This is only triggered when it is the client that starts the script, not in other situations where | ||
343 | /// a script is started, unlike OnStopScript! | ||
344 | /// </remarks> | 346 | /// </remarks> |
345 | public event StartScript OnStartScript; | 347 | public event StartScript OnStartScript; |
346 | 348 | ||
@@ -354,7 +356,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
354 | /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>, | 356 | /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>, |
355 | /// <see cref="SceneObjectPartInventory.StopScriptInstance"/>, | 357 | /// <see cref="SceneObjectPartInventory.StopScriptInstance"/>, |
356 | /// <see cref="Scene.SetScriptRunning"/> | 358 | /// <see cref="Scene.SetScriptRunning"/> |
357 | /// XXX: This is triggered when a sciprt is stopped for any reason, unlike OnStartScript! | ||
358 | /// </remarks> | 359 | /// </remarks> |
359 | public event StopScript OnStopScript; | 360 | public event StopScript OnStopScript; |
360 | 361 | ||
@@ -842,6 +843,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
842 | public event ParcelPrimCountTainted OnParcelPrimCountTainted; | 843 | public event ParcelPrimCountTainted OnParcelPrimCountTainted; |
843 | public event GetScriptRunning OnGetScriptRunning; | 844 | public event GetScriptRunning OnGetScriptRunning; |
844 | 845 | ||
846 | public delegate void ThrottleUpdate(ScenePresence scenePresence); | ||
847 | |||
848 | public event ThrottleUpdate OnThrottleUpdate; | ||
849 | |||
845 | /// <summary> | 850 | /// <summary> |
846 | /// RegisterCapsEvent is called by Scene after the Caps object | 851 | /// RegisterCapsEvent is called by Scene after the Caps object |
847 | /// has been instantiated and before it is return to the | 852 | /// has been instantiated and before it is return to the |
@@ -1435,6 +1440,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1435 | } | 1440 | } |
1436 | } | 1441 | } |
1437 | } | 1442 | } |
1443 | public void TriggerTerrainUpdate() | ||
1444 | { | ||
1445 | OnTerrainUpdateDelegate handlerTerrainUpdate = OnTerrainUpdate; | ||
1446 | if (handlerTerrainUpdate != null) | ||
1447 | { | ||
1448 | foreach (OnTerrainUpdateDelegate d in handlerTerrainUpdate.GetInvocationList()) | ||
1449 | { | ||
1450 | try | ||
1451 | { | ||
1452 | d(); | ||
1453 | } | ||
1454 | catch (Exception e) | ||
1455 | { | ||
1456 | m_log.ErrorFormat( | ||
1457 | "[EVENT MANAGER]: Delegate for TriggerTerrainUpdate failed - continuing. {0} {1}", | ||
1458 | e.Message, e.StackTrace); | ||
1459 | } | ||
1460 | } | ||
1461 | } | ||
1462 | } | ||
1438 | 1463 | ||
1439 | public void TriggerTerrainTick() | 1464 | public void TriggerTerrainTick() |
1440 | { | 1465 | { |
@@ -1767,6 +1792,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1767 | m_log.ErrorFormat( | 1792 | m_log.ErrorFormat( |
1768 | "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", | 1793 | "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", |
1769 | e.Message, e.StackTrace); | 1794 | e.Message, e.StackTrace); |
1795 | m_log.ErrorFormat(Environment.StackTrace); | ||
1770 | } | 1796 | } |
1771 | } | 1797 | } |
1772 | } | 1798 | } |
@@ -3045,6 +3071,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3045 | { | 3071 | { |
3046 | foreach (Action<Scene> d in handler.GetInvocationList()) | 3072 | foreach (Action<Scene> d in handler.GetInvocationList()) |
3047 | { | 3073 | { |
3074 | m_log.InfoFormat("[EVENT MANAGER]: TriggerSceneShuttingDown invoque {0}", d.Method.Name.ToString()); | ||
3048 | try | 3075 | try |
3049 | { | 3076 | { |
3050 | d(s); | 3077 | d(s); |
@@ -3057,6 +3084,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3057 | } | 3084 | } |
3058 | } | 3085 | } |
3059 | } | 3086 | } |
3087 | m_log.Info("[EVENT MANAGER]: TriggerSceneShuttingDown done"); | ||
3060 | } | 3088 | } |
3061 | 3089 | ||
3062 | public void TriggerOnRegionStarted(Scene scene) | 3090 | public void TriggerOnRegionStarted(Scene scene) |
@@ -3248,6 +3276,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3248 | } | 3276 | } |
3249 | } | 3277 | } |
3250 | 3278 | ||
3279 | public void TriggerThrottleUpdate(ScenePresence scenePresence) | ||
3280 | { | ||
3281 | ThrottleUpdate handler = OnThrottleUpdate; | ||
3282 | if (handler != null) | ||
3283 | { | ||
3284 | handler(scenePresence); | ||
3285 | } | ||
3286 | } | ||
3287 | |||
3251 | // public void TriggerGatherUuids(SceneObjectPart sop, IDictionary<UUID, AssetType> assetUuids) | 3288 | // public void TriggerGatherUuids(SceneObjectPart sop, IDictionary<UUID, AssetType> assetUuids) |
3252 | // { | 3289 | // { |
3253 | // GatherUuids handler = OnGatherUuids; | 3290 | // GatherUuids handler = OnGatherUuids; |
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 29652aa..4d153da 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | |||
@@ -498,6 +498,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
498 | k.Position = pos; | 498 | k.Position = pos; |
499 | // k.Velocity = Vector3.Zero; | 499 | // k.Velocity = Vector3.Zero; |
500 | } | 500 | } |
501 | k.AngularVelocity = (Vector3)k.Position; | ||
501 | 502 | ||
502 | k.StartRotation = rot; | 503 | k.StartRotation = rot; |
503 | if (k.Rotation.HasValue) | 504 | if (k.Rotation.HasValue) |
@@ -632,13 +633,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
632 | 633 | ||
633 | // Do the frame processing | 634 | // Do the frame processing |
634 | double steps = (double)m_currentFrame.TimeMS / tickDuration; | 635 | double steps = (double)m_currentFrame.TimeMS / tickDuration; |
635 | 636 | ||
636 | if (steps <= 0.0) | 637 | if (steps <= 0.0) |
637 | { | 638 | { |
638 | m_group.RootPart.Velocity = Vector3.Zero; | 639 | m_group.RootPart.Velocity = Vector3.Zero; |
639 | m_group.RootPart.AngularVelocity = Vector3.Zero; | 640 | m_group.RootPart.AngularVelocity = Vector3.Zero; |
640 | 641 | ||
641 | m_nextPosition = (Vector3)m_currentFrame.Position; | 642 | m_nextPosition = NormalizeVector(m_currentFrame.AngularVelocity); |
642 | m_group.AbsolutePosition = m_nextPosition; | 643 | m_group.AbsolutePosition = m_nextPosition; |
643 | 644 | ||
644 | // we are sending imediate updates, no doing force a extra terseUpdate | 645 | // we are sending imediate updates, no doing force a extra terseUpdate |
@@ -726,7 +727,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
726 | m_group.SendGroupRootTerseUpdate(); | 727 | m_group.SendGroupRootTerseUpdate(); |
727 | } | 728 | } |
728 | } | 729 | } |
730 | private Vector3 NormalizeVector(Vector3? pPosition) | ||
731 | { | ||
732 | if (pPosition == null) | ||
733 | return Vector3.Zero; | ||
734 | |||
735 | Vector3 tmp = (Vector3) pPosition; | ||
729 | 736 | ||
737 | while (tmp.X > Constants.RegionSize) | ||
738 | tmp.X -= Constants.RegionSize; | ||
739 | while (tmp.X < 0) | ||
740 | tmp.X += Constants.RegionSize; | ||
741 | while (tmp.Y > Constants.RegionSize) | ||
742 | tmp.Y -= Constants.RegionSize; | ||
743 | while (tmp.Y < 0) | ||
744 | tmp.Y += Constants.RegionSize; | ||
745 | |||
746 | return tmp; | ||
747 | |||
748 | |||
749 | } | ||
730 | public Byte[] Serialize() | 750 | public Byte[] Serialize() |
731 | { | 751 | { |
732 | StopTimer(); | 752 | StopTimer(); |
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 1b10e3c..ddae073 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs | |||
@@ -157,7 +157,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
157 | 157 | ||
158 | private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) | 158 | private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) |
159 | { | 159 | { |
160 | uint pqueue = ComputeDistancePriority(client,entity,true); | 160 | uint pqueue = ComputeDistancePriority(client,entity,false); |
161 | 161 | ||
162 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); | 162 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); |
163 | if (presence != null) | 163 | if (presence != null) |
@@ -212,9 +212,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
212 | } | 212 | } |
213 | 213 | ||
214 | // Use the camera position for local agents and avatar position for remote agents | 214 | // Use the camera position for local agents and avatar position for remote agents |
215 | Vector3 presencePos = (presence.IsChildAgent) ? | 215 | // Why would I want that? They could be camming but I still see them at the |
216 | presence.AbsolutePosition : | 216 | // avatar position, so why should I update them as if they were at their |
217 | presence.CameraPosition; | 217 | // camera positions? Makes no sense! |
218 | // TODO: Fix this mess | ||
219 | //Vector3 presencePos = (presence.IsChildAgent) ? | ||
220 | // presence.AbsolutePosition : | ||
221 | // presence.CameraPosition; | ||
222 | |||
223 | Vector3 presencePos = presence.AbsolutePosition; | ||
218 | 224 | ||
219 | // Compute the distance... | 225 | // Compute the distance... |
220 | double distance = Vector3.Distance(presencePos, entityPos); | 226 | double distance = Vector3.Distance(presencePos, entityPos); |
@@ -226,7 +232,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
226 | 232 | ||
227 | for (int i = 0; i < queues - 1; i++) | 233 | for (int i = 0; i < queues - 1; i++) |
228 | { | 234 | { |
229 | if (distance < 10 * Math.Pow(2.0,i)) | 235 | if (distance < 30 * Math.Pow(2.0,i)) |
230 | break; | 236 | break; |
231 | pqueue++; | 237 | pqueue++; |
232 | } | 238 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SOPMaterial.cs b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs new file mode 100644 index 0000000..10ac37c --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Region.Framework.Scenes | ||
34 | { | ||
35 | public static class SOPMaterialData | ||
36 | { | ||
37 | public enum SopMaterial : int // redundante and not in use for now | ||
38 | { | ||
39 | Stone = 0, | ||
40 | Metal = 1, | ||
41 | Glass = 2, | ||
42 | Wood = 3, | ||
43 | Flesh = 4, | ||
44 | Plastic = 5, | ||
45 | Rubber = 6, | ||
46 | light = 7 // compatibility with old viewers | ||
47 | } | ||
48 | |||
49 | private struct MaterialData | ||
50 | { | ||
51 | public float friction; | ||
52 | public float bounce; | ||
53 | public MaterialData(float f, float b) | ||
54 | { | ||
55 | friction = f; | ||
56 | bounce = b; | ||
57 | } | ||
58 | } | ||
59 | |||
60 | private static MaterialData[] m_materialdata = { | ||
61 | new MaterialData(0.8f,0.4f), // Stone | ||
62 | new MaterialData(0.3f,0.4f), // Metal | ||
63 | new MaterialData(0.2f,0.7f), // Glass | ||
64 | new MaterialData(0.6f,0.5f), // Wood | ||
65 | new MaterialData(0.9f,0.3f), // Flesh | ||
66 | new MaterialData(0.4f,0.7f), // Plastic | ||
67 | new MaterialData(0.9f,0.95f), // Rubber | ||
68 | new MaterialData(0.0f,0.0f) // light ?? | ||
69 | }; | ||
70 | |||
71 | public static Material MaxMaterial | ||
72 | { | ||
73 | get { return (Material)(m_materialdata.Length - 1); } | ||
74 | } | ||
75 | |||
76 | public static float friction(Material material) | ||
77 | { | ||
78 | int indx = (int)material; | ||
79 | if (indx < m_materialdata.Length) | ||
80 | return (m_materialdata[indx].friction); | ||
81 | else | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | public static float bounce(Material material) | ||
86 | { | ||
87 | int indx = (int)material; | ||
88 | if (indx < m_materialdata.Length) | ||
89 | return (m_materialdata[indx].bounce); | ||
90 | else | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | } | ||
95 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs new file mode 100644 index 0000000..9cb901a --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs | |||
@@ -0,0 +1,791 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Physics.Manager; | ||
33 | using System.Text; | ||
34 | using System.IO; | ||
35 | using System.Xml; | ||
36 | using OpenSim.Framework.Serialization; | ||
37 | using OpenSim.Framework.Serialization.External; | ||
38 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
39 | |||
40 | namespace OpenSim.Region.Framework.Scenes | ||
41 | { | ||
42 | public class SOPVehicle | ||
43 | { | ||
44 | public VehicleData vd; | ||
45 | |||
46 | public Vehicle Type | ||
47 | { | ||
48 | get { return vd.m_type; } | ||
49 | } | ||
50 | |||
51 | public SOPVehicle() | ||
52 | { | ||
53 | vd = new VehicleData(); | ||
54 | ProcessTypeChange(Vehicle.TYPE_NONE); // is needed? | ||
55 | } | ||
56 | |||
57 | public void ProcessFloatVehicleParam(Vehicle pParam, float pValue) | ||
58 | { | ||
59 | float len; | ||
60 | float timestep = 0.01f; | ||
61 | switch (pParam) | ||
62 | { | ||
63 | case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: | ||
64 | if (pValue < 0f) pValue = 0f; | ||
65 | if (pValue > 1f) pValue = 1f; | ||
66 | vd.m_angularDeflectionEfficiency = pValue; | ||
67 | break; | ||
68 | case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: | ||
69 | if (pValue < timestep) pValue = timestep; | ||
70 | vd.m_angularDeflectionTimescale = pValue; | ||
71 | break; | ||
72 | case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: | ||
73 | if (pValue < timestep) pValue = timestep; | ||
74 | else if (pValue > 120) pValue = 120; | ||
75 | vd.m_angularMotorDecayTimescale = pValue; | ||
76 | break; | ||
77 | case Vehicle.ANGULAR_MOTOR_TIMESCALE: | ||
78 | if (pValue < timestep) pValue = timestep; | ||
79 | vd.m_angularMotorTimescale = pValue; | ||
80 | break; | ||
81 | case Vehicle.BANKING_EFFICIENCY: | ||
82 | if (pValue < -1f) pValue = -1f; | ||
83 | if (pValue > 1f) pValue = 1f; | ||
84 | vd.m_bankingEfficiency = pValue; | ||
85 | break; | ||
86 | case Vehicle.BANKING_MIX: | ||
87 | if (pValue < 0f) pValue = 0f; | ||
88 | if (pValue > 1f) pValue = 1f; | ||
89 | vd.m_bankingMix = pValue; | ||
90 | break; | ||
91 | case Vehicle.BANKING_TIMESCALE: | ||
92 | if (pValue < timestep) pValue = timestep; | ||
93 | vd.m_bankingTimescale = pValue; | ||
94 | break; | ||
95 | case Vehicle.BUOYANCY: | ||
96 | if (pValue < -1f) pValue = -1f; | ||
97 | if (pValue > 1f) pValue = 1f; | ||
98 | vd.m_VehicleBuoyancy = pValue; | ||
99 | break; | ||
100 | case Vehicle.HOVER_EFFICIENCY: | ||
101 | if (pValue < 0f) pValue = 0f; | ||
102 | if (pValue > 1f) pValue = 1f; | ||
103 | vd.m_VhoverEfficiency = pValue; | ||
104 | break; | ||
105 | case Vehicle.HOVER_HEIGHT: | ||
106 | vd.m_VhoverHeight = pValue; | ||
107 | break; | ||
108 | case Vehicle.HOVER_TIMESCALE: | ||
109 | if (pValue < timestep) pValue = timestep; | ||
110 | vd.m_VhoverTimescale = pValue; | ||
111 | break; | ||
112 | case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: | ||
113 | if (pValue < 0f) pValue = 0f; | ||
114 | if (pValue > 1f) pValue = 1f; | ||
115 | vd.m_linearDeflectionEfficiency = pValue; | ||
116 | break; | ||
117 | case Vehicle.LINEAR_DEFLECTION_TIMESCALE: | ||
118 | if (pValue < timestep) pValue = timestep; | ||
119 | vd.m_linearDeflectionTimescale = pValue; | ||
120 | break; | ||
121 | case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: | ||
122 | if (pValue < timestep) pValue = timestep; | ||
123 | else if (pValue > 120) pValue = 120; | ||
124 | vd.m_linearMotorDecayTimescale = pValue; | ||
125 | break; | ||
126 | case Vehicle.LINEAR_MOTOR_TIMESCALE: | ||
127 | if (pValue < timestep) pValue = timestep; | ||
128 | vd.m_linearMotorTimescale = pValue; | ||
129 | break; | ||
130 | case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: | ||
131 | if (pValue < 0f) pValue = 0f; | ||
132 | if (pValue > 1f) pValue = 1f; | ||
133 | vd.m_verticalAttractionEfficiency = pValue; | ||
134 | break; | ||
135 | case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: | ||
136 | if (pValue < timestep) pValue = timestep; | ||
137 | vd.m_verticalAttractionTimescale = pValue; | ||
138 | break; | ||
139 | |||
140 | // These are vector properties but the engine lets you use a single float value to | ||
141 | // set all of the components to the same value | ||
142 | case Vehicle.ANGULAR_FRICTION_TIMESCALE: | ||
143 | if (pValue < timestep) pValue = timestep; | ||
144 | vd.m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue); | ||
145 | break; | ||
146 | case Vehicle.ANGULAR_MOTOR_DIRECTION: | ||
147 | vd.m_angularMotorDirection = new Vector3(pValue, pValue, pValue); | ||
148 | len = vd.m_angularMotorDirection.Length(); | ||
149 | if (len > 12.566f) | ||
150 | vd.m_angularMotorDirection *= (12.566f / len); | ||
151 | break; | ||
152 | case Vehicle.LINEAR_FRICTION_TIMESCALE: | ||
153 | if (pValue < timestep) pValue = timestep; | ||
154 | vd.m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); | ||
155 | break; | ||
156 | case Vehicle.LINEAR_MOTOR_DIRECTION: | ||
157 | vd.m_linearMotorDirection = new Vector3(pValue, pValue, pValue); | ||
158 | len = vd.m_linearMotorDirection.Length(); | ||
159 | if (len > 30.0f) | ||
160 | vd.m_linearMotorDirection *= (30.0f / len); | ||
161 | break; | ||
162 | case Vehicle.LINEAR_MOTOR_OFFSET: | ||
163 | vd.m_linearMotorOffset = new Vector3(pValue, pValue, pValue); | ||
164 | len = vd.m_linearMotorOffset.Length(); | ||
165 | if (len > 100.0f) | ||
166 | vd.m_linearMotorOffset *= (100.0f / len); | ||
167 | break; | ||
168 | } | ||
169 | }//end ProcessFloatVehicleParam | ||
170 | |||
171 | public void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue) | ||
172 | { | ||
173 | float len; | ||
174 | float timestep = 0.01f; | ||
175 | switch (pParam) | ||
176 | { | ||
177 | case Vehicle.ANGULAR_FRICTION_TIMESCALE: | ||
178 | if (pValue.X < timestep) pValue.X = timestep; | ||
179 | if (pValue.Y < timestep) pValue.Y = timestep; | ||
180 | if (pValue.Z < timestep) pValue.Z = timestep; | ||
181 | |||
182 | vd.m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
183 | break; | ||
184 | case Vehicle.ANGULAR_MOTOR_DIRECTION: | ||
185 | vd.m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
186 | // Limit requested angular speed to 2 rps= 4 pi rads/sec | ||
187 | len = vd.m_angularMotorDirection.Length(); | ||
188 | if (len > 12.566f) | ||
189 | vd.m_angularMotorDirection *= (12.566f / len); | ||
190 | break; | ||
191 | case Vehicle.LINEAR_FRICTION_TIMESCALE: | ||
192 | if (pValue.X < timestep) pValue.X = timestep; | ||
193 | if (pValue.Y < timestep) pValue.Y = timestep; | ||
194 | if (pValue.Z < timestep) pValue.Z = timestep; | ||
195 | vd.m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
196 | break; | ||
197 | case Vehicle.LINEAR_MOTOR_DIRECTION: | ||
198 | vd.m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
199 | len = vd.m_linearMotorDirection.Length(); | ||
200 | if (len > 30.0f) | ||
201 | vd.m_linearMotorDirection *= (30.0f / len); | ||
202 | break; | ||
203 | case Vehicle.LINEAR_MOTOR_OFFSET: | ||
204 | vd.m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
205 | len = vd.m_linearMotorOffset.Length(); | ||
206 | if (len > 100.0f) | ||
207 | vd.m_linearMotorOffset *= (100.0f / len); | ||
208 | break; | ||
209 | } | ||
210 | }//end ProcessVectorVehicleParam | ||
211 | |||
212 | public void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) | ||
213 | { | ||
214 | switch (pParam) | ||
215 | { | ||
216 | case Vehicle.REFERENCE_FRAME: | ||
217 | vd.m_referenceFrame = pValue; | ||
218 | break; | ||
219 | } | ||
220 | }//end ProcessRotationVehicleParam | ||
221 | |||
222 | public void ProcessVehicleFlags(int pParam, bool remove) | ||
223 | { | ||
224 | if (remove) | ||
225 | { | ||
226 | vd.m_flags &= ~((VehicleFlag)pParam); | ||
227 | } | ||
228 | else | ||
229 | { | ||
230 | vd.m_flags |= (VehicleFlag)pParam; | ||
231 | } | ||
232 | }//end ProcessVehicleFlags | ||
233 | |||
234 | public void ProcessTypeChange(Vehicle pType) | ||
235 | { | ||
236 | vd.m_linearMotorDirection = Vector3.Zero; | ||
237 | vd.m_angularMotorDirection = Vector3.Zero; | ||
238 | vd.m_linearMotorOffset = Vector3.Zero; | ||
239 | vd.m_referenceFrame = Quaternion.Identity; | ||
240 | |||
241 | // Set Defaults For Type | ||
242 | vd.m_type = pType; | ||
243 | switch (pType) | ||
244 | { | ||
245 | case Vehicle.TYPE_NONE: | ||
246 | vd.m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
247 | vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
248 | vd.m_linearMotorTimescale = 1000; | ||
249 | vd.m_linearMotorDecayTimescale = 120; | ||
250 | vd.m_angularMotorTimescale = 1000; | ||
251 | vd.m_angularMotorDecayTimescale = 1000; | ||
252 | vd.m_VhoverHeight = 0; | ||
253 | vd.m_VhoverEfficiency = 1; | ||
254 | vd.m_VhoverTimescale = 1000; | ||
255 | vd.m_VehicleBuoyancy = 0; | ||
256 | vd.m_linearDeflectionEfficiency = 0; | ||
257 | vd.m_linearDeflectionTimescale = 1000; | ||
258 | vd.m_angularDeflectionEfficiency = 0; | ||
259 | vd.m_angularDeflectionTimescale = 1000; | ||
260 | vd.m_bankingEfficiency = 0; | ||
261 | vd.m_bankingMix = 1; | ||
262 | vd.m_bankingTimescale = 1000; | ||
263 | vd.m_verticalAttractionEfficiency = 0; | ||
264 | vd.m_verticalAttractionTimescale = 1000; | ||
265 | |||
266 | vd.m_flags = (VehicleFlag)0; | ||
267 | break; | ||
268 | |||
269 | case Vehicle.TYPE_SLED: | ||
270 | vd.m_linearFrictionTimescale = new Vector3(30, 1, 1000); | ||
271 | vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
272 | vd.m_linearMotorTimescale = 1000; | ||
273 | vd.m_linearMotorDecayTimescale = 120; | ||
274 | vd.m_angularMotorTimescale = 1000; | ||
275 | vd.m_angularMotorDecayTimescale = 120; | ||
276 | vd.m_VhoverHeight = 0; | ||
277 | vd.m_VhoverEfficiency = 1; | ||
278 | vd.m_VhoverTimescale = 10; | ||
279 | vd.m_VehicleBuoyancy = 0; | ||
280 | vd.m_linearDeflectionEfficiency = 1; | ||
281 | vd.m_linearDeflectionTimescale = 1; | ||
282 | vd.m_angularDeflectionEfficiency = 0; | ||
283 | vd.m_angularDeflectionTimescale = 1000; | ||
284 | vd.m_bankingEfficiency = 0; | ||
285 | vd.m_bankingMix = 1; | ||
286 | vd.m_bankingTimescale = 10; | ||
287 | vd.m_flags &= | ||
288 | ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | ||
289 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); | ||
290 | vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); | ||
291 | break; | ||
292 | case Vehicle.TYPE_CAR: | ||
293 | vd.m_linearFrictionTimescale = new Vector3(100, 2, 1000); | ||
294 | vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
295 | vd.m_linearMotorTimescale = 1; | ||
296 | vd.m_linearMotorDecayTimescale = 60; | ||
297 | vd.m_angularMotorTimescale = 1; | ||
298 | vd.m_angularMotorDecayTimescale = 0.8f; | ||
299 | vd.m_VhoverHeight = 0; | ||
300 | vd.m_VhoverEfficiency = 0; | ||
301 | vd.m_VhoverTimescale = 1000; | ||
302 | vd.m_VehicleBuoyancy = 0; | ||
303 | vd.m_linearDeflectionEfficiency = 1; | ||
304 | vd.m_linearDeflectionTimescale = 2; | ||
305 | vd.m_angularDeflectionEfficiency = 0; | ||
306 | vd.m_angularDeflectionTimescale = 10; | ||
307 | vd.m_verticalAttractionEfficiency = 1f; | ||
308 | vd.m_verticalAttractionTimescale = 10f; | ||
309 | vd.m_bankingEfficiency = -0.2f; | ||
310 | vd.m_bankingMix = 1; | ||
311 | vd.m_bankingTimescale = 1; | ||
312 | vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); | ||
313 | vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | | ||
314 | VehicleFlag.LIMIT_MOTOR_UP | VehicleFlag.HOVER_UP_ONLY); | ||
315 | break; | ||
316 | case Vehicle.TYPE_BOAT: | ||
317 | vd.m_linearFrictionTimescale = new Vector3(10, 3, 2); | ||
318 | vd.m_angularFrictionTimescale = new Vector3(10, 10, 10); | ||
319 | vd.m_linearMotorTimescale = 5; | ||
320 | vd.m_linearMotorDecayTimescale = 60; | ||
321 | vd.m_angularMotorTimescale = 4; | ||
322 | vd.m_angularMotorDecayTimescale = 4; | ||
323 | vd.m_VhoverHeight = 0; | ||
324 | vd.m_VhoverEfficiency = 0.5f; | ||
325 | vd.m_VhoverTimescale = 2; | ||
326 | vd.m_VehicleBuoyancy = 1; | ||
327 | vd.m_linearDeflectionEfficiency = 0.5f; | ||
328 | vd.m_linearDeflectionTimescale = 3; | ||
329 | vd.m_angularDeflectionEfficiency = 0.5f; | ||
330 | vd.m_angularDeflectionTimescale = 5; | ||
331 | vd.m_verticalAttractionEfficiency = 0.5f; | ||
332 | vd.m_verticalAttractionTimescale = 5f; | ||
333 | vd.m_bankingEfficiency = -0.3f; | ||
334 | vd.m_bankingMix = 0.8f; | ||
335 | vd.m_bankingTimescale = 1; | ||
336 | vd.m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | | ||
337 | VehicleFlag.HOVER_GLOBAL_HEIGHT | | ||
338 | VehicleFlag.HOVER_UP_ONLY | | ||
339 | VehicleFlag.LIMIT_ROLL_ONLY); | ||
340 | vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | | ||
341 | VehicleFlag.LIMIT_MOTOR_UP | | ||
342 | VehicleFlag.HOVER_WATER_ONLY); | ||
343 | break; | ||
344 | case Vehicle.TYPE_AIRPLANE: | ||
345 | vd.m_linearFrictionTimescale = new Vector3(200, 10, 5); | ||
346 | vd.m_angularFrictionTimescale = new Vector3(20, 20, 20); | ||
347 | vd.m_linearMotorTimescale = 2; | ||
348 | vd.m_linearMotorDecayTimescale = 60; | ||
349 | vd.m_angularMotorTimescale = 4; | ||
350 | vd.m_angularMotorDecayTimescale = 8; | ||
351 | vd.m_VhoverHeight = 0; | ||
352 | vd.m_VhoverEfficiency = 0.5f; | ||
353 | vd.m_VhoverTimescale = 1000; | ||
354 | vd.m_VehicleBuoyancy = 0; | ||
355 | vd.m_linearDeflectionEfficiency = 0.5f; | ||
356 | vd.m_linearDeflectionTimescale = 0.5f; | ||
357 | vd.m_angularDeflectionEfficiency = 1; | ||
358 | vd.m_angularDeflectionTimescale = 2; | ||
359 | vd.m_verticalAttractionEfficiency = 0.9f; | ||
360 | vd.m_verticalAttractionTimescale = 2f; | ||
361 | vd.m_bankingEfficiency = 1; | ||
362 | vd.m_bankingMix = 0.7f; | ||
363 | vd.m_bankingTimescale = 2; | ||
364 | vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | | ||
365 | VehicleFlag.HOVER_TERRAIN_ONLY | | ||
366 | VehicleFlag.HOVER_GLOBAL_HEIGHT | | ||
367 | VehicleFlag.HOVER_UP_ONLY | | ||
368 | VehicleFlag.NO_DEFLECTION_UP | | ||
369 | VehicleFlag.LIMIT_MOTOR_UP); | ||
370 | vd.m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); | ||
371 | break; | ||
372 | case Vehicle.TYPE_BALLOON: | ||
373 | vd.m_linearFrictionTimescale = new Vector3(5, 5, 5); | ||
374 | vd.m_angularFrictionTimescale = new Vector3(10, 10, 10); | ||
375 | vd.m_linearMotorTimescale = 5; | ||
376 | vd.m_linearMotorDecayTimescale = 60; | ||
377 | vd.m_angularMotorTimescale = 6; | ||
378 | vd.m_angularMotorDecayTimescale = 10; | ||
379 | vd.m_VhoverHeight = 5; | ||
380 | vd.m_VhoverEfficiency = 0.8f; | ||
381 | vd.m_VhoverTimescale = 10; | ||
382 | vd.m_VehicleBuoyancy = 1; | ||
383 | vd.m_linearDeflectionEfficiency = 0; | ||
384 | vd.m_linearDeflectionTimescale = 5; | ||
385 | vd.m_angularDeflectionEfficiency = 0; | ||
386 | vd.m_angularDeflectionTimescale = 5; | ||
387 | vd.m_verticalAttractionEfficiency = 0f; | ||
388 | vd.m_verticalAttractionTimescale = 1000f; | ||
389 | vd.m_bankingEfficiency = 0; | ||
390 | vd.m_bankingMix = 0.7f; | ||
391 | vd.m_bankingTimescale = 5; | ||
392 | vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | | ||
393 | VehicleFlag.HOVER_TERRAIN_ONLY | | ||
394 | VehicleFlag.HOVER_UP_ONLY | | ||
395 | VehicleFlag.NO_DEFLECTION_UP | | ||
396 | VehicleFlag.LIMIT_MOTOR_UP); | ||
397 | vd.m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | | ||
398 | VehicleFlag.HOVER_GLOBAL_HEIGHT); | ||
399 | break; | ||
400 | } | ||
401 | } | ||
402 | public void SetVehicle(PhysicsActor ph) | ||
403 | { | ||
404 | if (ph == null) | ||
405 | return; | ||
406 | ph.SetVehicle(vd); | ||
407 | } | ||
408 | |||
409 | private XmlTextWriter writer; | ||
410 | |||
411 | private void XWint(string name, int i) | ||
412 | { | ||
413 | writer.WriteElementString(name, i.ToString()); | ||
414 | } | ||
415 | |||
416 | private void XWfloat(string name, float f) | ||
417 | { | ||
418 | writer.WriteElementString(name, f.ToString(Utils.EnUsCulture)); | ||
419 | } | ||
420 | |||
421 | private void XWVector(string name, Vector3 vec) | ||
422 | { | ||
423 | writer.WriteStartElement(name); | ||
424 | writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture)); | ||
425 | writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture)); | ||
426 | writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture)); | ||
427 | writer.WriteEndElement(); | ||
428 | } | ||
429 | |||
430 | private void XWQuat(string name, Quaternion quat) | ||
431 | { | ||
432 | writer.WriteStartElement(name); | ||
433 | writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture)); | ||
434 | writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture)); | ||
435 | writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture)); | ||
436 | writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture)); | ||
437 | writer.WriteEndElement(); | ||
438 | } | ||
439 | |||
440 | public void ToXml2(XmlTextWriter twriter) | ||
441 | { | ||
442 | writer = twriter; | ||
443 | writer.WriteStartElement("Vehicle"); | ||
444 | |||
445 | XWint("TYPE", (int)vd.m_type); | ||
446 | XWint("FLAGS", (int)vd.m_flags); | ||
447 | |||
448 | // Linear properties | ||
449 | XWVector("LMDIR", vd.m_linearMotorDirection); | ||
450 | XWVector("LMFTIME", vd.m_linearFrictionTimescale); | ||
451 | XWfloat("LMDTIME", vd.m_linearMotorDecayTimescale); | ||
452 | XWfloat("LMTIME", vd.m_linearMotorTimescale); | ||
453 | XWVector("LMOFF", vd.m_linearMotorOffset); | ||
454 | |||
455 | //Angular properties | ||
456 | XWVector("AMDIR", vd.m_angularMotorDirection); | ||
457 | XWfloat("AMTIME", vd.m_angularMotorTimescale); | ||
458 | XWfloat("AMDTIME", vd.m_angularMotorDecayTimescale); | ||
459 | XWVector("AMFTIME", vd.m_angularFrictionTimescale); | ||
460 | |||
461 | //Deflection properties | ||
462 | XWfloat("ADEFF", vd.m_angularDeflectionEfficiency); | ||
463 | XWfloat("ADTIME", vd.m_angularDeflectionTimescale); | ||
464 | XWfloat("LDEFF", vd.m_linearDeflectionEfficiency); | ||
465 | XWfloat("LDTIME", vd.m_linearDeflectionTimescale); | ||
466 | |||
467 | //Banking properties | ||
468 | XWfloat("BEFF", vd.m_bankingEfficiency); | ||
469 | XWfloat("BMIX", vd.m_bankingMix); | ||
470 | XWfloat("BTIME", vd.m_bankingTimescale); | ||
471 | |||
472 | //Hover and Buoyancy properties | ||
473 | XWfloat("HHEI", vd.m_VhoverHeight); | ||
474 | XWfloat("HEFF", vd.m_VhoverEfficiency); | ||
475 | XWfloat("HTIME", vd.m_VhoverTimescale); | ||
476 | XWfloat("VBUO", vd.m_VehicleBuoyancy); | ||
477 | |||
478 | //Attractor properties | ||
479 | XWfloat("VAEFF", vd.m_verticalAttractionEfficiency); | ||
480 | XWfloat("VATIME", vd.m_verticalAttractionTimescale); | ||
481 | |||
482 | XWQuat("REF_FRAME", vd.m_referenceFrame); | ||
483 | |||
484 | writer.WriteEndElement(); | ||
485 | writer = null; | ||
486 | } | ||
487 | |||
488 | |||
489 | |||
490 | XmlTextReader reader; | ||
491 | |||
492 | private int XRint() | ||
493 | { | ||
494 | return reader.ReadElementContentAsInt(); | ||
495 | } | ||
496 | |||
497 | private float XRfloat() | ||
498 | { | ||
499 | return reader.ReadElementContentAsFloat(); | ||
500 | } | ||
501 | |||
502 | public Vector3 XRvector() | ||
503 | { | ||
504 | Vector3 vec; | ||
505 | reader.ReadStartElement(); | ||
506 | vec.X = reader.ReadElementContentAsFloat(); | ||
507 | vec.Y = reader.ReadElementContentAsFloat(); | ||
508 | vec.Z = reader.ReadElementContentAsFloat(); | ||
509 | reader.ReadEndElement(); | ||
510 | return vec; | ||
511 | } | ||
512 | |||
513 | public Quaternion XRquat() | ||
514 | { | ||
515 | Quaternion q; | ||
516 | reader.ReadStartElement(); | ||
517 | q.X = reader.ReadElementContentAsFloat(); | ||
518 | q.Y = reader.ReadElementContentAsFloat(); | ||
519 | q.Z = reader.ReadElementContentAsFloat(); | ||
520 | q.W = reader.ReadElementContentAsFloat(); | ||
521 | reader.ReadEndElement(); | ||
522 | return q; | ||
523 | } | ||
524 | |||
525 | public static bool EReadProcessors( | ||
526 | Dictionary<string, Action> processors, | ||
527 | XmlTextReader xtr) | ||
528 | { | ||
529 | bool errors = false; | ||
530 | |||
531 | string nodeName = string.Empty; | ||
532 | while (xtr.NodeType != XmlNodeType.EndElement) | ||
533 | { | ||
534 | nodeName = xtr.Name; | ||
535 | |||
536 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Processing: {0}", nodeName); | ||
537 | |||
538 | Action p = null; | ||
539 | if (processors.TryGetValue(xtr.Name, out p)) | ||
540 | { | ||
541 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Found {0} processor, nodeName); | ||
542 | |||
543 | try | ||
544 | { | ||
545 | p(); | ||
546 | } | ||
547 | catch (Exception e) | ||
548 | { | ||
549 | errors = true; | ||
550 | if (xtr.NodeType == XmlNodeType.EndElement) | ||
551 | xtr.Read(); | ||
552 | } | ||
553 | } | ||
554 | else | ||
555 | { | ||
556 | // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName); | ||
557 | xtr.ReadOuterXml(); // ignore | ||
558 | } | ||
559 | } | ||
560 | |||
561 | return errors; | ||
562 | } | ||
563 | |||
564 | |||
565 | public string ToXml2() | ||
566 | { | ||
567 | MemoryStream ms = new MemoryStream(512); | ||
568 | UTF8Encoding enc = new UTF8Encoding(); | ||
569 | XmlTextWriter xwriter = new XmlTextWriter(ms, enc); | ||
570 | ToXml2(xwriter); | ||
571 | xwriter.Flush(); | ||
572 | string s = ms.GetStreamString(); | ||
573 | xwriter.Close(); | ||
574 | return s; | ||
575 | } | ||
576 | |||
577 | public static SOPVehicle FromXml2(string text) | ||
578 | { | ||
579 | if (text == String.Empty) | ||
580 | return null; | ||
581 | |||
582 | UTF8Encoding enc = new UTF8Encoding(); | ||
583 | MemoryStream ms = new MemoryStream(enc.GetBytes(text)); | ||
584 | XmlTextReader xreader = new XmlTextReader(ms); | ||
585 | |||
586 | SOPVehicle v = new SOPVehicle(); | ||
587 | bool error; | ||
588 | |||
589 | v.FromXml2(xreader, out error); | ||
590 | |||
591 | xreader.Close(); | ||
592 | |||
593 | if (error) | ||
594 | { | ||
595 | v = null; | ||
596 | return null; | ||
597 | } | ||
598 | return v; | ||
599 | } | ||
600 | |||
601 | public static SOPVehicle FromXml2(XmlTextReader reader) | ||
602 | { | ||
603 | SOPVehicle vehicle = new SOPVehicle(); | ||
604 | |||
605 | bool errors = false; | ||
606 | |||
607 | vehicle.FromXml2(reader, out errors); | ||
608 | if (errors) | ||
609 | return null; | ||
610 | |||
611 | return vehicle; | ||
612 | } | ||
613 | |||
614 | private void FromXml2(XmlTextReader _reader, out bool errors) | ||
615 | { | ||
616 | errors = false; | ||
617 | reader = _reader; | ||
618 | |||
619 | Dictionary<string, Action> m_VehicleXmlProcessors | ||
620 | = new Dictionary<string, Action>(); | ||
621 | |||
622 | m_VehicleXmlProcessors.Add("TYPE", ProcessXR_type); | ||
623 | m_VehicleXmlProcessors.Add("FLAGS", ProcessXR_flags); | ||
624 | |||
625 | // Linear properties | ||
626 | m_VehicleXmlProcessors.Add("LMDIR", ProcessXR_linearMotorDirection); | ||
627 | m_VehicleXmlProcessors.Add("LMFTIME", ProcessXR_linearFrictionTimescale); | ||
628 | m_VehicleXmlProcessors.Add("LMDTIME", ProcessXR_linearMotorDecayTimescale); | ||
629 | m_VehicleXmlProcessors.Add("LMTIME", ProcessXR_linearMotorTimescale); | ||
630 | m_VehicleXmlProcessors.Add("LMOFF", ProcessXR_linearMotorOffset); | ||
631 | |||
632 | //Angular properties | ||
633 | m_VehicleXmlProcessors.Add("AMDIR", ProcessXR_angularMotorDirection); | ||
634 | m_VehicleXmlProcessors.Add("AMTIME", ProcessXR_angularMotorTimescale); | ||
635 | m_VehicleXmlProcessors.Add("AMDTIME", ProcessXR_angularMotorDecayTimescale); | ||
636 | m_VehicleXmlProcessors.Add("AMFTIME", ProcessXR_angularFrictionTimescale); | ||
637 | |||
638 | //Deflection properties | ||
639 | m_VehicleXmlProcessors.Add("ADEFF", ProcessXR_angularDeflectionEfficiency); | ||
640 | m_VehicleXmlProcessors.Add("ADTIME", ProcessXR_angularDeflectionTimescale); | ||
641 | m_VehicleXmlProcessors.Add("LDEFF", ProcessXR_linearDeflectionEfficiency); | ||
642 | m_VehicleXmlProcessors.Add("LDTIME", ProcessXR_linearDeflectionTimescale); | ||
643 | |||
644 | //Banking properties | ||
645 | m_VehicleXmlProcessors.Add("BEFF", ProcessXR_bankingEfficiency); | ||
646 | m_VehicleXmlProcessors.Add("BMIX", ProcessXR_bankingMix); | ||
647 | m_VehicleXmlProcessors.Add("BTIME", ProcessXR_bankingTimescale); | ||
648 | |||
649 | //Hover and Buoyancy properties | ||
650 | m_VehicleXmlProcessors.Add("HHEI", ProcessXR_VhoverHeight); | ||
651 | m_VehicleXmlProcessors.Add("HEFF", ProcessXR_VhoverEfficiency); | ||
652 | m_VehicleXmlProcessors.Add("HTIME", ProcessXR_VhoverTimescale); | ||
653 | |||
654 | m_VehicleXmlProcessors.Add("VBUO", ProcessXR_VehicleBuoyancy); | ||
655 | |||
656 | //Attractor properties | ||
657 | m_VehicleXmlProcessors.Add("VAEFF", ProcessXR_verticalAttractionEfficiency); | ||
658 | m_VehicleXmlProcessors.Add("VATIME", ProcessXR_verticalAttractionTimescale); | ||
659 | |||
660 | m_VehicleXmlProcessors.Add("REF_FRAME", ProcessXR_referenceFrame); | ||
661 | |||
662 | vd = new VehicleData(); | ||
663 | |||
664 | reader.ReadStartElement("Vehicle", String.Empty); | ||
665 | |||
666 | errors = EReadProcessors( | ||
667 | m_VehicleXmlProcessors, | ||
668 | reader); | ||
669 | |||
670 | reader.ReadEndElement(); | ||
671 | reader = null; | ||
672 | } | ||
673 | |||
674 | private void ProcessXR_type() | ||
675 | { | ||
676 | vd.m_type = (Vehicle)XRint(); | ||
677 | } | ||
678 | private void ProcessXR_flags() | ||
679 | { | ||
680 | vd.m_flags = (VehicleFlag)XRint(); | ||
681 | } | ||
682 | // Linear properties | ||
683 | private void ProcessXR_linearMotorDirection() | ||
684 | { | ||
685 | vd.m_linearMotorDirection = XRvector(); | ||
686 | } | ||
687 | |||
688 | private void ProcessXR_linearFrictionTimescale() | ||
689 | { | ||
690 | vd.m_linearFrictionTimescale = XRvector(); | ||
691 | } | ||
692 | |||
693 | private void ProcessXR_linearMotorDecayTimescale() | ||
694 | { | ||
695 | vd.m_linearMotorDecayTimescale = XRfloat(); | ||
696 | } | ||
697 | private void ProcessXR_linearMotorTimescale() | ||
698 | { | ||
699 | vd.m_linearMotorTimescale = XRfloat(); | ||
700 | } | ||
701 | private void ProcessXR_linearMotorOffset() | ||
702 | { | ||
703 | vd.m_linearMotorOffset = XRvector(); | ||
704 | } | ||
705 | |||
706 | |||
707 | //Angular properties | ||
708 | private void ProcessXR_angularMotorDirection() | ||
709 | { | ||
710 | vd.m_angularMotorDirection = XRvector(); | ||
711 | } | ||
712 | private void ProcessXR_angularMotorTimescale() | ||
713 | { | ||
714 | vd.m_angularMotorTimescale = XRfloat(); | ||
715 | } | ||
716 | private void ProcessXR_angularMotorDecayTimescale() | ||
717 | { | ||
718 | vd.m_angularMotorDecayTimescale = XRfloat(); | ||
719 | } | ||
720 | private void ProcessXR_angularFrictionTimescale() | ||
721 | { | ||
722 | vd.m_angularFrictionTimescale = XRvector(); | ||
723 | } | ||
724 | |||
725 | //Deflection properties | ||
726 | private void ProcessXR_angularDeflectionEfficiency() | ||
727 | { | ||
728 | vd.m_angularDeflectionEfficiency = XRfloat(); | ||
729 | } | ||
730 | private void ProcessXR_angularDeflectionTimescale() | ||
731 | { | ||
732 | vd.m_angularDeflectionTimescale = XRfloat(); | ||
733 | } | ||
734 | private void ProcessXR_linearDeflectionEfficiency() | ||
735 | { | ||
736 | vd.m_linearDeflectionEfficiency = XRfloat(); | ||
737 | } | ||
738 | private void ProcessXR_linearDeflectionTimescale() | ||
739 | { | ||
740 | vd.m_linearDeflectionTimescale = XRfloat(); | ||
741 | } | ||
742 | |||
743 | //Banking properties | ||
744 | private void ProcessXR_bankingEfficiency() | ||
745 | { | ||
746 | vd.m_bankingEfficiency = XRfloat(); | ||
747 | } | ||
748 | private void ProcessXR_bankingMix() | ||
749 | { | ||
750 | vd.m_bankingMix = XRfloat(); | ||
751 | } | ||
752 | private void ProcessXR_bankingTimescale() | ||
753 | { | ||
754 | vd.m_bankingTimescale = XRfloat(); | ||
755 | } | ||
756 | |||
757 | //Hover and Buoyancy properties | ||
758 | private void ProcessXR_VhoverHeight() | ||
759 | { | ||
760 | vd.m_VhoverHeight = XRfloat(); | ||
761 | } | ||
762 | private void ProcessXR_VhoverEfficiency() | ||
763 | { | ||
764 | vd.m_VhoverEfficiency = XRfloat(); | ||
765 | } | ||
766 | private void ProcessXR_VhoverTimescale() | ||
767 | { | ||
768 | vd.m_VhoverTimescale = XRfloat(); | ||
769 | } | ||
770 | |||
771 | private void ProcessXR_VehicleBuoyancy() | ||
772 | { | ||
773 | vd.m_VehicleBuoyancy = XRfloat(); | ||
774 | } | ||
775 | |||
776 | //Attractor properties | ||
777 | private void ProcessXR_verticalAttractionEfficiency() | ||
778 | { | ||
779 | vd.m_verticalAttractionEfficiency = XRfloat(); | ||
780 | } | ||
781 | private void ProcessXR_verticalAttractionTimescale() | ||
782 | { | ||
783 | vd.m_verticalAttractionTimescale = XRfloat(); | ||
784 | } | ||
785 | |||
786 | private void ProcessXR_referenceFrame() | ||
787 | { | ||
788 | vd.m_referenceFrame = XRquat(); | ||
789 | } | ||
790 | } | ||
791 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 65536db..f384462 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -103,12 +103,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
103 | engine.StartProcessing(); | 103 | engine.StartProcessing(); |
104 | } | 104 | } |
105 | 105 | ||
106 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) | 106 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item, uint cost) |
107 | { | 107 | { |
108 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); | 108 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); |
109 | if (money != null) | 109 | if (money != null) |
110 | { | 110 | { |
111 | money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload"); | 111 | money.ApplyUploadCharge(agentID, (int)cost, "Asset upload"); |
112 | } | 112 | } |
113 | 113 | ||
114 | AddInventoryItem(item); | 114 | AddInventoryItem(item); |
@@ -171,7 +171,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
171 | return false; | 171 | return false; |
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | if (InventoryService.AddItem(item)) | 175 | if (InventoryService.AddItem(item)) |
176 | { | 176 | { |
177 | int userlevel = 0; | 177 | int userlevel = 0; |
@@ -326,8 +326,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
326 | 326 | ||
327 | // Update item with new asset | 327 | // Update item with new asset |
328 | item.AssetID = asset.FullID; | 328 | item.AssetID = asset.FullID; |
329 | if (group.UpdateInventoryItem(item)) | 329 | group.UpdateInventoryItem(item); |
330 | remoteClient.SendAlertMessage("Script saved"); | ||
331 | 330 | ||
332 | part.SendPropertiesToClient(remoteClient); | 331 | part.SendPropertiesToClient(remoteClient); |
333 | 332 | ||
@@ -338,12 +337,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
338 | { | 337 | { |
339 | // Needs to determine which engine was running it and use that | 338 | // Needs to determine which engine was running it and use that |
340 | // | 339 | // |
341 | part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); | 340 | errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 1); |
342 | errors = part.Inventory.GetScriptErrors(item.ItemID); | ||
343 | } | ||
344 | else | ||
345 | { | ||
346 | remoteClient.SendAlertMessage("Script saved"); | ||
347 | } | 341 | } |
348 | 342 | ||
349 | // Tell anyone managing scripts that a script has been reloaded/changed | 343 | // Tell anyone managing scripts that a script has been reloaded/changed |
@@ -409,6 +403,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
409 | if (item.Owner != remoteClient.AgentId) | 403 | if (item.Owner != remoteClient.AgentId) |
410 | return; | 404 | return; |
411 | 405 | ||
406 | item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); | ||
412 | item.Name = itemUpd.Name; | 407 | item.Name = itemUpd.Name; |
413 | item.Description = itemUpd.Description; | 408 | item.Description = itemUpd.Description; |
414 | 409 | ||
@@ -857,6 +852,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
857 | return; | 852 | return; |
858 | } | 853 | } |
859 | 854 | ||
855 | if (newName == null) newName = item.Name; | ||
856 | |||
860 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 857 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
861 | 858 | ||
862 | if (asset != null) | 859 | if (asset != null) |
@@ -917,6 +914,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
917 | } | 914 | } |
918 | 915 | ||
919 | /// <summary> | 916 | /// <summary> |
917 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
918 | /// </summary> | ||
919 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
920 | { | ||
921 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
922 | foreach (InventoryItemBase b in items) | ||
923 | { | ||
924 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
925 | InventoryItemBase n = InventoryService.GetItem(b); | ||
926 | n.Folder = destfolder; | ||
927 | moveitems.Add(n); | ||
928 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
929 | } | ||
930 | |||
931 | MoveInventoryItem(remoteClient, moveitems); | ||
932 | } | ||
933 | |||
934 | /// <summary> | ||
920 | /// Move an item within the agent's inventory. | 935 | /// Move an item within the agent's inventory. |
921 | /// </summary> | 936 | /// </summary> |
922 | /// <param name="remoteClient"></param> | 937 | /// <param name="remoteClient"></param> |
@@ -951,11 +966,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
951 | public void CreateNewInventoryItem( | 966 | public void CreateNewInventoryItem( |
952 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 967 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
953 | string name, string description, uint flags, uint callbackID, | 968 | string name, string description, uint flags, uint callbackID, |
954 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) | 969 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate, UUID transationID) |
955 | { | 970 | { |
956 | CreateNewInventoryItem( | 971 | CreateNewInventoryItem( |
957 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, | 972 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, |
958 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate); | 973 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate, transationID); |
974 | } | ||
975 | |||
976 | |||
977 | private void CreateNewInventoryItem( | ||
978 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | ||
979 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | ||
980 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | ||
981 | { | ||
982 | CreateNewInventoryItem(remoteClient, creatorID, creatorData, folderID, | ||
983 | name, description, flags, callbackID, asset, invType, | ||
984 | baseMask, currentMask, everyoneMask, nextOwnerMask, groupMask, creationDate, UUID.Zero); | ||
959 | } | 985 | } |
960 | 986 | ||
961 | /// <summary> | 987 | /// <summary> |
@@ -980,7 +1006,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
980 | private void CreateNewInventoryItem( | 1006 | private void CreateNewInventoryItem( |
981 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 1007 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
982 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | 1008 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, |
983 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | 1009 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate,UUID transationID) |
984 | { | 1010 | { |
985 | InventoryItemBase item = new InventoryItemBase(); | 1011 | InventoryItemBase item = new InventoryItemBase(); |
986 | item.Owner = remoteClient.AgentId; | 1012 | item.Owner = remoteClient.AgentId; |
@@ -1003,7 +1029,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1003 | 1029 | ||
1004 | if (AddInventoryItem(item)) | 1030 | if (AddInventoryItem(item)) |
1005 | { | 1031 | { |
1006 | remoteClient.SendInventoryItemCreateUpdate(item, callbackID); | 1032 | remoteClient.SendInventoryItemCreateUpdate(item, transationID, callbackID); |
1007 | } | 1033 | } |
1008 | else | 1034 | else |
1009 | { | 1035 | { |
@@ -1278,6 +1304,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1278 | { | 1304 | { |
1279 | SceneObjectPart part = GetSceneObjectPart(primLocalId); | 1305 | SceneObjectPart part = GetSceneObjectPart(primLocalId); |
1280 | 1306 | ||
1307 | // Can't move a null item | ||
1308 | if (itemId == UUID.Zero) | ||
1309 | return; | ||
1310 | |||
1281 | if (null == part) | 1311 | if (null == part) |
1282 | { | 1312 | { |
1283 | m_log.WarnFormat( | 1313 | m_log.WarnFormat( |
@@ -1382,21 +1412,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1382 | return; | 1412 | return; |
1383 | } | 1413 | } |
1384 | 1414 | ||
1385 | if (part.OwnerID != destPart.OwnerID) | 1415 | // Can't transfer this |
1416 | // | ||
1417 | if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1418 | return; | ||
1419 | |||
1420 | bool overrideNoMod = false; | ||
1421 | if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) | ||
1422 | overrideNoMod = true; | ||
1423 | |||
1424 | if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1386 | { | 1425 | { |
1387 | // Source must have transfer permissions | 1426 | // object cannot copy items to an object owned by a different owner |
1388 | if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | 1427 | // unless llAllowInventoryDrop has been called |
1389 | return; | ||
1390 | 1428 | ||
1391 | // Object cannot copy items to an object owned by a different owner | 1429 | return; |
1392 | // unless llAllowInventoryDrop has been called on the destination | ||
1393 | if ((destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1394 | return; | ||
1395 | } | 1430 | } |
1396 | 1431 | ||
1397 | // must have both move and modify permission to put an item in an object | 1432 | // must have both move and modify permission to put an item in an object |
1398 | if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) | 1433 | if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) |
1434 | { | ||
1399 | return; | 1435 | return; |
1436 | } | ||
1400 | 1437 | ||
1401 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); | 1438 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); |
1402 | 1439 | ||
@@ -1452,6 +1489,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1452 | 1489 | ||
1453 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1490 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1454 | { | 1491 | { |
1492 | SceneObjectPart destPart = GetSceneObjectPart(destID); | ||
1493 | if (destPart != null) // Move into a prim | ||
1494 | { | ||
1495 | foreach(UUID itemID in items) | ||
1496 | MoveTaskInventoryItem(destID, host, itemID); | ||
1497 | return destID; // Prim folder ID == prim ID | ||
1498 | } | ||
1499 | |||
1455 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1500 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1456 | 1501 | ||
1457 | UUID newFolderID = UUID.Random(); | 1502 | UUID newFolderID = UUID.Random(); |
@@ -1634,12 +1679,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1634 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( | 1679 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( |
1635 | remoteClient, part, transactionID, currentItem); | 1680 | remoteClient, part, transactionID, currentItem); |
1636 | 1681 | ||
1637 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | 1682 | // if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) |
1638 | remoteClient.SendAlertMessage("Notecard saved"); | 1683 | // remoteClient.SendAgentAlertMessage("Notecard saved", false); |
1639 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | 1684 | // else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) |
1640 | remoteClient.SendAlertMessage("Script saved"); | 1685 | // remoteClient.SendAgentAlertMessage("Script saved", false); |
1641 | else | 1686 | // else |
1642 | remoteClient.SendAlertMessage("Item saved"); | 1687 | // remoteClient.SendAgentAlertMessage("Item saved", false); |
1643 | } | 1688 | } |
1644 | 1689 | ||
1645 | // Base ALWAYS has move | 1690 | // Base ALWAYS has move |
@@ -2009,23 +2054,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
2009 | // build a list of eligible objects | 2054 | // build a list of eligible objects |
2010 | List<uint> deleteIDs = new List<uint>(); | 2055 | List<uint> deleteIDs = new List<uint>(); |
2011 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 2056 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
2012 | 2057 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
2013 | // Start with true for both, then remove the flags if objects | ||
2014 | // that we can't derez are part of the selection | ||
2015 | bool permissionToTake = true; | ||
2016 | bool permissionToTakeCopy = true; | ||
2017 | bool permissionToDelete = true; | ||
2018 | 2058 | ||
2019 | foreach (uint localID in localIDs) | 2059 | foreach (uint localID in localIDs) |
2020 | { | 2060 | { |
2061 | // Start with true for both, then remove the flags if objects | ||
2062 | // that we can't derez are part of the selection | ||
2063 | bool permissionToTake = true; | ||
2064 | bool permissionToTakeCopy = true; | ||
2065 | bool permissionToDelete = true; | ||
2066 | |||
2021 | // Invalid id | 2067 | // Invalid id |
2022 | SceneObjectPart part = GetSceneObjectPart(localID); | 2068 | SceneObjectPart part = GetSceneObjectPart(localID); |
2023 | if (part == null) | 2069 | if (part == null) |
2070 | { | ||
2071 | //Client still thinks the object exists, kill it | ||
2072 | deleteIDs.Add(localID); | ||
2024 | continue; | 2073 | continue; |
2074 | } | ||
2025 | 2075 | ||
2026 | // Already deleted by someone else | 2076 | // Already deleted by someone else |
2027 | if (part.ParentGroup.IsDeleted) | 2077 | if (part.ParentGroup.IsDeleted) |
2078 | { | ||
2079 | //Client still thinks the object exists, kill it | ||
2080 | deleteIDs.Add(localID); | ||
2028 | continue; | 2081 | continue; |
2082 | } | ||
2029 | 2083 | ||
2030 | // Can't delete child prims | 2084 | // Can't delete child prims |
2031 | if (part != part.ParentGroup.RootPart) | 2085 | if (part != part.ParentGroup.RootPart) |
@@ -2033,8 +2087,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2033 | 2087 | ||
2034 | SceneObjectGroup grp = part.ParentGroup; | 2088 | SceneObjectGroup grp = part.ParentGroup; |
2035 | 2089 | ||
2036 | deleteIDs.Add(localID); | 2090 | // If child prims have invalid perms, fix them |
2037 | deleteGroups.Add(grp); | 2091 | grp.AdjustChildPrimPermissions(); |
2038 | 2092 | ||
2039 | // If child prims have invalid perms, fix them | 2093 | // If child prims have invalid perms, fix them |
2040 | grp.AdjustChildPrimPermissions(); | 2094 | grp.AdjustChildPrimPermissions(); |
@@ -2055,86 +2109,198 @@ namespace OpenSim.Region.Framework.Scenes | |||
2055 | } | 2109 | } |
2056 | else | 2110 | else |
2057 | { | 2111 | { |
2058 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 2112 | if (action == DeRezAction.TakeCopy) |
2113 | { | ||
2114 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
2115 | permissionToTakeCopy = false; | ||
2116 | } | ||
2117 | else | ||
2118 | { | ||
2059 | permissionToTakeCopy = false; | 2119 | permissionToTakeCopy = false; |
2060 | 2120 | } | |
2061 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 2121 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
2062 | permissionToTake = false; | 2122 | permissionToTake = false; |
2063 | 2123 | ||
2064 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 2124 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
2065 | permissionToDelete = false; | 2125 | permissionToDelete = false; |
2066 | } | 2126 | } |
2067 | } | ||
2068 | 2127 | ||
2069 | // Handle god perms | 2128 | // Handle god perms |
2070 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 2129 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
2071 | { | ||
2072 | permissionToTake = true; | ||
2073 | permissionToTakeCopy = true; | ||
2074 | permissionToDelete = true; | ||
2075 | } | ||
2076 | |||
2077 | // If we're re-saving, we don't even want to delete | ||
2078 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | ||
2079 | permissionToDelete = false; | ||
2080 | |||
2081 | // if we want to take a copy, we also don't want to delete | ||
2082 | // Note: after this point, the permissionToTakeCopy flag | ||
2083 | // becomes irrelevant. It already includes the permissionToTake | ||
2084 | // permission and after excluding no copy items here, we can | ||
2085 | // just use that. | ||
2086 | if (action == DeRezAction.TakeCopy) | ||
2087 | { | ||
2088 | // If we don't have permission, stop right here | ||
2089 | if (!permissionToTakeCopy) | ||
2090 | { | 2130 | { |
2091 | remoteClient.SendAlertMessage("You don't have permission to take the object"); | 2131 | permissionToTake = true; |
2092 | return; | 2132 | permissionToTakeCopy = true; |
2133 | permissionToDelete = true; | ||
2093 | } | 2134 | } |
2094 | 2135 | ||
2095 | permissionToTake = true; | 2136 | // If we're re-saving, we don't even want to delete |
2096 | // Don't delete | 2137 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
2097 | permissionToDelete = false; | 2138 | permissionToDelete = false; |
2098 | } | ||
2099 | 2139 | ||
2100 | if (action == DeRezAction.Return) | 2140 | // if we want to take a copy, we also don't want to delete |
2101 | { | 2141 | // Note: after this point, the permissionToTakeCopy flag |
2102 | if (remoteClient != null) | 2142 | // becomes irrelevant. It already includes the permissionToTake |
2143 | // permission and after excluding no copy items here, we can | ||
2144 | // just use that. | ||
2145 | if (action == DeRezAction.TakeCopy) | ||
2103 | { | 2146 | { |
2104 | if (Permissions.CanReturnObjects( | 2147 | // If we don't have permission, stop right here |
2105 | null, | 2148 | if (!permissionToTakeCopy) |
2106 | remoteClient.AgentId, | ||
2107 | deleteGroups)) | ||
2108 | { | 2149 | { |
2109 | permissionToTake = true; | 2150 | remoteClient.SendAlertMessage("You don't have permission to take the object"); |
2110 | permissionToDelete = true; | 2151 | return; |
2152 | } | ||
2153 | |||
2154 | permissionToTake = true; | ||
2155 | // Don't delete | ||
2156 | permissionToDelete = false; | ||
2157 | } | ||
2111 | 2158 | ||
2112 | foreach (SceneObjectGroup g in deleteGroups) | 2159 | if (action == DeRezAction.Return) |
2160 | { | ||
2161 | if (remoteClient != null) | ||
2162 | { | ||
2163 | if (Permissions.CanReturnObjects( | ||
2164 | null, | ||
2165 | remoteClient.AgentId, | ||
2166 | new List<SceneObjectGroup>() {grp})) | ||
2113 | { | 2167 | { |
2114 | AddReturn(g.OwnerID == g.GroupID ? g.LastOwnerID : g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 2168 | permissionToTake = true; |
2169 | permissionToDelete = true; | ||
2170 | |||
2171 | AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
2115 | } | 2172 | } |
2116 | } | 2173 | } |
2174 | else // Auto return passes through here with null agent | ||
2175 | { | ||
2176 | permissionToTake = true; | ||
2177 | permissionToDelete = true; | ||
2178 | } | ||
2117 | } | 2179 | } |
2118 | else // Auto return passes through here with null agent | 2180 | |
2181 | if (permissionToTake && (!permissionToDelete)) | ||
2182 | takeGroups.Add(grp); | ||
2183 | |||
2184 | if (permissionToDelete) | ||
2119 | { | 2185 | { |
2120 | permissionToTake = true; | 2186 | if (permissionToTake) |
2121 | permissionToDelete = true; | 2187 | deleteGroups.Add(grp); |
2188 | deleteIDs.Add(grp.LocalId); | ||
2122 | } | 2189 | } |
2123 | } | 2190 | } |
2124 | 2191 | ||
2125 | if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) | 2192 | SendKillObject(deleteIDs); |
2193 | |||
2194 | if (deleteGroups.Count > 0) | ||
2126 | { | 2195 | { |
2196 | foreach (SceneObjectGroup g in deleteGroups) | ||
2197 | deleteIDs.Remove(g.LocalId); | ||
2198 | |||
2127 | m_asyncSceneObjectDeleter.DeleteToInventory( | 2199 | m_asyncSceneObjectDeleter.DeleteToInventory( |
2128 | action, destinationID, deleteGroups, remoteClient, | 2200 | action, destinationID, deleteGroups, remoteClient, |
2129 | permissionToDelete); | 2201 | true); |
2130 | } | 2202 | } |
2131 | else if (permissionToDelete) | 2203 | if (takeGroups.Count > 0) |
2204 | { | ||
2205 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
2206 | action, destinationID, takeGroups, remoteClient, | ||
2207 | false); | ||
2208 | } | ||
2209 | if (deleteIDs.Count > 0) | ||
2132 | { | 2210 | { |
2133 | foreach (SceneObjectGroup g in deleteGroups) | 2211 | foreach (SceneObjectGroup g in deleteGroups) |
2134 | DeleteSceneObject(g, false); | 2212 | DeleteSceneObject(g, true); |
2135 | } | 2213 | } |
2136 | } | 2214 | } |
2137 | 2215 | ||
2216 | public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) | ||
2217 | { | ||
2218 | itemID = UUID.Zero; | ||
2219 | if (grp != null) | ||
2220 | { | ||
2221 | Vector3 inventoryStoredPosition = new Vector3 | ||
2222 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
2223 | ? 250 | ||
2224 | : grp.AbsolutePosition.X) | ||
2225 | , | ||
2226 | (grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
2227 | ? 250 | ||
2228 | : grp.AbsolutePosition.X, | ||
2229 | grp.AbsolutePosition.Z); | ||
2230 | |||
2231 | Vector3 originalPosition = grp.AbsolutePosition; | ||
2232 | |||
2233 | grp.AbsolutePosition = inventoryStoredPosition; | ||
2234 | |||
2235 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
2236 | |||
2237 | grp.AbsolutePosition = originalPosition; | ||
2238 | |||
2239 | AssetBase asset = CreateAsset( | ||
2240 | grp.GetPartName(grp.LocalId), | ||
2241 | grp.GetPartDescription(grp.LocalId), | ||
2242 | (sbyte)AssetType.Object, | ||
2243 | Utils.StringToBytes(sceneObjectXml), | ||
2244 | remoteClient.AgentId); | ||
2245 | AssetService.Store(asset); | ||
2246 | |||
2247 | InventoryItemBase item = new InventoryItemBase(); | ||
2248 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
2249 | item.CreatorData = grp.RootPart.CreatorData; | ||
2250 | item.Owner = remoteClient.AgentId; | ||
2251 | item.ID = UUID.Random(); | ||
2252 | item.AssetID = asset.FullID; | ||
2253 | item.Description = asset.Description; | ||
2254 | item.Name = asset.Name; | ||
2255 | item.AssetType = asset.Type; | ||
2256 | item.InvType = (int)InventoryType.Object; | ||
2257 | |||
2258 | InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
2259 | if (folder != null) | ||
2260 | item.Folder = folder.ID; | ||
2261 | else // oopsies | ||
2262 | item.Folder = UUID.Zero; | ||
2263 | |||
2264 | // Set up base perms properly | ||
2265 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
2266 | permsBase &= grp.RootPart.BaseMask; | ||
2267 | permsBase |= (uint)PermissionMask.Move; | ||
2268 | |||
2269 | // Make sure we don't lock it | ||
2270 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
2271 | |||
2272 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
2273 | { | ||
2274 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2275 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2276 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2277 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
2278 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
2279 | } | ||
2280 | else | ||
2281 | { | ||
2282 | item.BasePermissions = permsBase; | ||
2283 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; | ||
2284 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2285 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; | ||
2286 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; | ||
2287 | } | ||
2288 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
2289 | |||
2290 | // sets itemID so client can show item as 'attached' in inventory | ||
2291 | grp.FromItemID = item.ID; | ||
2292 | |||
2293 | if (AddInventoryItem(item)) | ||
2294 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
2295 | else | ||
2296 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
2297 | |||
2298 | itemID = item.ID; | ||
2299 | return item.AssetID; | ||
2300 | } | ||
2301 | return UUID.Zero; | ||
2302 | } | ||
2303 | |||
2138 | /// <summary> | 2304 | /// <summary> |
2139 | /// Returns the list of Scene Objects in an asset. | 2305 | /// Returns the list of Scene Objects in an asset. |
2140 | /// </summary> | 2306 | /// </summary> |
@@ -2163,6 +2329,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2163 | if (e == null || attachment) // Single | 2329 | if (e == null || attachment) // Single |
2164 | { | 2330 | { |
2165 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 2331 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
2332 | |||
2333 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
2334 | g.RootPart.AttachOffset = g.AbsolutePosition; | ||
2335 | g.RootPart.AttachRotation = g.GroupRotation; | ||
2336 | if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && | ||
2337 | g.RootPart.Shape.PCode != (byte)PCode.Tree) | ||
2338 | g.RootPart.Shape.State = 0; | ||
2339 | |||
2166 | objlist.Add(g); | 2340 | objlist.Add(g); |
2167 | veclist.Add(new Vector3(0, 0, 0)); | 2341 | veclist.Add(new Vector3(0, 0, 0)); |
2168 | bbox = g.GetAxisAlignedBoundingBox(out offsetHeight); | 2342 | bbox = g.GetAxisAlignedBoundingBox(out offsetHeight); |
@@ -2181,6 +2355,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2181 | foreach (XmlNode n in groups) | 2355 | foreach (XmlNode n in groups) |
2182 | { | 2356 | { |
2183 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); | 2357 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); |
2358 | |||
2359 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
2360 | g.RootPart.AttachOffset = g.AbsolutePosition; | ||
2361 | g.RootPart.AttachRotation = g.GroupRotation; | ||
2362 | if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && | ||
2363 | g.RootPart.Shape.PCode != (byte)PCode.Tree) | ||
2364 | g.RootPart.Shape.State = 0; | ||
2365 | |||
2184 | objlist.Add(g); | 2366 | objlist.Add(g); |
2185 | 2367 | ||
2186 | XmlElement el = (XmlElement)n; | 2368 | XmlElement el = (XmlElement)n; |
@@ -2343,6 +2525,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2343 | 2525 | ||
2344 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2526 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2345 | { | 2527 | { |
2528 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2529 | return; | ||
2530 | |||
2346 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2531 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2347 | if (part == null) | 2532 | if (part == null) |
2348 | return; | 2533 | return; |
@@ -2399,7 +2584,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2399 | } | 2584 | } |
2400 | else | 2585 | else |
2401 | { | 2586 | { |
2402 | if (!Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) | 2587 | if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId) |
2588 | continue; | ||
2589 | |||
2590 | if (!Permissions.CanTransferObject(sog.UUID, groupID)) | ||
2403 | continue; | 2591 | continue; |
2404 | 2592 | ||
2405 | if (sog.GroupID != groupID) | 2593 | if (sog.GroupID != groupID) |
@@ -2511,6 +2699,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2511 | } | 2699 | } |
2512 | 2700 | ||
2513 | m_sceneGraph.LinkObjects(root, children); | 2701 | m_sceneGraph.LinkObjects(root, children); |
2702 | |||
2703 | ScenePresence sp; | ||
2704 | if (TryGetScenePresence(agentId, out sp)) | ||
2705 | { | ||
2706 | root.SendPropertiesToClient(sp.ControllingClient); | ||
2707 | } | ||
2514 | } | 2708 | } |
2515 | 2709 | ||
2516 | private string PermissionString(uint permissions) | 2710 | private string PermissionString(uint permissions) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index cddf818..46b2d2e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
50 | /// <param name='targetID'></param> | 50 | /// <param name='targetID'></param> |
51 | /// <param name='fromAgent'></param> | 51 | /// <param name='fromAgent'></param> |
52 | /// <param name='broadcast'></param> | 52 | /// <param name='broadcast'></param> |
53 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 53 | public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
54 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) | 54 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) |
55 | { | 55 | { |
56 | OSChatMessage args = new OSChatMessage(); | 56 | OSChatMessage args = new OSChatMessage(); |
@@ -61,6 +61,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
61 | args.Position = fromPos; | 61 | args.Position = fromPos; |
62 | args.SenderUUID = fromID; | 62 | args.SenderUUID = fromID; |
63 | args.Scene = this; | 63 | args.Scene = this; |
64 | args.Destination = targetID; | ||
64 | 65 | ||
65 | if (fromAgent) | 66 | if (fromAgent) |
66 | { | 67 | { |
@@ -75,7 +76,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
75 | } | 76 | } |
76 | 77 | ||
77 | args.From = fromName; | 78 | args.From = fromName; |
78 | args.TargetUUID = targetID; | 79 | //args. |
79 | 80 | ||
80 | // m_log.DebugFormat( | 81 | // m_log.DebugFormat( |
81 | // "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}", | 82 | // "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}", |
@@ -86,7 +87,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
86 | else | 87 | else |
87 | EventManager.TriggerOnChatFromWorld(this, args); | 88 | EventManager.TriggerOnChatFromWorld(this, args); |
88 | } | 89 | } |
89 | 90 | ||
90 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 91 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
91 | UUID fromID, bool fromAgent, bool broadcast) | 92 | UUID fromID, bool fromAgent, bool broadcast) |
92 | { | 93 | { |
@@ -130,19 +131,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
130 | { | 131 | { |
131 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); | 132 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); |
132 | } | 133 | } |
133 | /// <summary> | ||
134 | /// | ||
135 | /// </summary> | ||
136 | /// <param name="message"></param> | ||
137 | /// <param name="type"></param> | ||
138 | /// <param name="fromPos"></param> | ||
139 | /// <param name="fromName"></param> | ||
140 | /// <param name="fromAgentID"></param> | ||
141 | /// <param name="targetID"></param> | ||
142 | public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent) | ||
143 | { | ||
144 | SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false); | ||
145 | } | ||
146 | 134 | ||
147 | /// <summary> | 135 | /// <summary> |
148 | /// Invoked when the client requests a prim. | 136 | /// Invoked when the client requests a prim. |
@@ -164,27 +152,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
164 | /// <param name="remoteClient"></param> | 152 | /// <param name="remoteClient"></param> |
165 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) | 153 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) |
166 | { | 154 | { |
155 | /* | ||
156 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | ||
157 | |||
158 | if (null == part) | ||
159 | return; | ||
160 | |||
161 | if (part.IsRoot) | ||
162 | { | ||
163 | SceneObjectGroup sog = part.ParentGroup; | ||
164 | sog.SendPropertiesToClient(remoteClient); | ||
165 | |||
166 | // A prim is only tainted if it's allowed to be edited by the person clicking it. | ||
167 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) | ||
168 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) | ||
169 | { | ||
170 | sog.IsSelected = true; | ||
171 | EventManager.TriggerParcelPrimCountTainted(); | ||
172 | } | ||
173 | } | ||
174 | else | ||
175 | { | ||
176 | part.SendPropertiesToClient(remoteClient); | ||
177 | } | ||
178 | */ | ||
167 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | 179 | SceneObjectPart part = GetSceneObjectPart(primLocalID); |
168 | 180 | ||
169 | if (null == part) | 181 | if (null == part) |
170 | return; | 182 | return; |
171 | 183 | ||
172 | if (part.IsRoot) | 184 | SceneObjectGroup sog = part.ParentGroup; |
173 | { | 185 | if (sog == null) |
174 | SceneObjectGroup sog = part.ParentGroup; | 186 | return; |
175 | sog.SendPropertiesToClient(remoteClient); | ||
176 | sog.IsSelected = true; | ||
177 | 187 | ||
178 | // A prim is only tainted if it's allowed to be edited by the person clicking it. | 188 | part.SendPropertiesToClient(remoteClient); |
179 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) | 189 | |
180 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) | 190 | // A prim is only tainted if it's allowed to be edited by the person clicking it. |
181 | { | 191 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) |
182 | EventManager.TriggerParcelPrimCountTainted(); | 192 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) |
183 | } | ||
184 | } | ||
185 | else | ||
186 | { | 193 | { |
187 | part.SendPropertiesToClient(remoteClient); | 194 | part.IsSelected = true; |
195 | EventManager.TriggerParcelPrimCountTainted(); | ||
188 | } | 196 | } |
189 | } | 197 | } |
190 | 198 | ||
@@ -237,7 +245,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
237 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | 245 | SceneObjectPart part = GetSceneObjectPart(primLocalID); |
238 | if (part == null) | 246 | if (part == null) |
239 | return; | 247 | return; |
240 | 248 | /* | |
241 | // A deselect packet contains all the local prims being deselected. However, since selection is still | 249 | // A deselect packet contains all the local prims being deselected. However, since selection is still |
242 | // group based we only want the root prim to trigger a full update - otherwise on objects with many prims | 250 | // group based we only want the root prim to trigger a full update - otherwise on objects with many prims |
243 | // we end up sending many duplicate ObjectUpdates | 251 | // we end up sending many duplicate ObjectUpdates |
@@ -248,7 +256,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
248 | // handled by group, but by prim. Legacy cruft. | 256 | // handled by group, but by prim. Legacy cruft. |
249 | // TODO: Make selection flagging per prim! | 257 | // TODO: Make selection flagging per prim! |
250 | // | 258 | // |
251 | part.ParentGroup.IsSelected = false; | 259 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) |
260 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
261 | part.ParentGroup.IsSelected = false; | ||
252 | 262 | ||
253 | part.ParentGroup.ScheduleGroupForFullUpdate(); | 263 | part.ParentGroup.ScheduleGroupForFullUpdate(); |
254 | 264 | ||
@@ -265,6 +275,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | part.UUID, remoteClient.AgentId)) | 275 | part.UUID, remoteClient.AgentId)) |
266 | EventManager.TriggerParcelPrimCountTainted(); | 276 | EventManager.TriggerParcelPrimCountTainted(); |
267 | } | 277 | } |
278 | */ | ||
279 | |||
280 | bool oldgprSelect = part.ParentGroup.IsSelected; | ||
281 | |||
282 | // This is wrong, wrong, wrong. Selection should not be | ||
283 | // handled by group, but by prim. Legacy cruft. | ||
284 | // TODO: Make selection flagging per prim! | ||
285 | // | ||
286 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) | ||
287 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
288 | { | ||
289 | part.IsSelected = false; | ||
290 | if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) | ||
291 | EventManager.TriggerParcelPrimCountTainted(); | ||
292 | } | ||
293 | |||
268 | } | 294 | } |
269 | 295 | ||
270 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, | 296 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, |
@@ -419,12 +445,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
419 | } | 445 | } |
420 | }); | 446 | }); |
421 | } | 447 | } |
422 | 448 | ||
423 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) | 449 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) |
424 | { | 450 | { |
425 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; | 451 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; |
426 | } | 452 | } |
427 | 453 | ||
454 | private class DescendentsRequestData | ||
455 | { | ||
456 | public IClientAPI RemoteClient; | ||
457 | public UUID FolderID; | ||
458 | public UUID OwnerID; | ||
459 | public bool FetchFolders; | ||
460 | public bool FetchItems; | ||
461 | public int SortOrder; | ||
462 | } | ||
463 | |||
464 | private Queue<DescendentsRequestData> m_descendentsRequestQueue = new Queue<DescendentsRequestData>(); | ||
465 | private Object m_descendentsRequestLock = new Object(); | ||
466 | private bool m_descendentsRequestProcessing = false; | ||
467 | |||
428 | /// <summary> | 468 | /// <summary> |
429 | /// Tell the client about the various child items and folders contained in the requested folder. | 469 | /// Tell the client about the various child items and folders contained in the requested folder. |
430 | /// </summary> | 470 | /// </summary> |
@@ -461,17 +501,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
461 | } | 501 | } |
462 | } | 502 | } |
463 | 503 | ||
464 | // We're going to send the reply async, because there may be | 504 | lock (m_descendentsRequestLock) |
465 | // an enormous quantity of packets -- basically the entire inventory! | 505 | { |
466 | // We don't want to block the client thread while all that is happening. | 506 | if (!m_descendentsRequestProcessing) |
467 | SendInventoryDelegate d = SendInventoryAsync; | 507 | { |
468 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | 508 | m_descendentsRequestProcessing = true; |
509 | |||
510 | // We're going to send the reply async, because there may be | ||
511 | // an enormous quantity of packets -- basically the entire inventory! | ||
512 | // We don't want to block the client thread while all that is happening. | ||
513 | SendInventoryDelegate d = SendInventoryAsync; | ||
514 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | ||
515 | |||
516 | return; | ||
517 | } | ||
518 | |||
519 | DescendentsRequestData req = new DescendentsRequestData(); | ||
520 | req.RemoteClient = remoteClient; | ||
521 | req.FolderID = folderID; | ||
522 | req.OwnerID = ownerID; | ||
523 | req.FetchFolders = fetchFolders; | ||
524 | req.FetchItems = fetchItems; | ||
525 | req.SortOrder = sortOrder; | ||
526 | |||
527 | m_descendentsRequestQueue.Enqueue(req); | ||
528 | } | ||
469 | } | 529 | } |
470 | 530 | ||
471 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); | 531 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); |
472 | 532 | ||
473 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) | 533 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) |
474 | { | 534 | { |
535 | Thread.Sleep(20); | ||
475 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); | 536 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); |
476 | } | 537 | } |
477 | 538 | ||
@@ -479,6 +540,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
479 | { | 540 | { |
480 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; | 541 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; |
481 | d.EndInvoke(iar); | 542 | d.EndInvoke(iar); |
543 | |||
544 | lock (m_descendentsRequestLock) | ||
545 | { | ||
546 | if (m_descendentsRequestQueue.Count > 0) | ||
547 | { | ||
548 | DescendentsRequestData req = m_descendentsRequestQueue.Dequeue(); | ||
549 | |||
550 | d = SendInventoryAsync; | ||
551 | d.BeginInvoke(req.RemoteClient, req.FolderID, req.OwnerID, req.FetchFolders, req.FetchItems, req.SortOrder, SendInventoryComplete, d); | ||
552 | |||
553 | return; | ||
554 | } | ||
555 | |||
556 | m_descendentsRequestProcessing = false; | ||
557 | } | ||
482 | } | 558 | } |
483 | 559 | ||
484 | /// <summary> | 560 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 610bcd6..3fd7485 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -227,8 +227,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
227 | // TODO: need to figure out how allow client agents but deny | 227 | // TODO: need to figure out how allow client agents but deny |
228 | // root agents when ACL denies access to root agent | 228 | // root agents when ACL denies access to root agent |
229 | public bool m_strictAccessControl = true; | 229 | public bool m_strictAccessControl = true; |
230 | 230 | public bool m_seeIntoBannedRegion = false; | |
231 | public int MaxUndoCount { get; set; } | 231 | public int MaxUndoCount = 5; |
232 | 232 | ||
233 | public bool SeeIntoRegion { get; set; } | 233 | public bool SeeIntoRegion { get; set; } |
234 | 234 | ||
@@ -246,11 +246,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
246 | 246 | ||
247 | protected int m_splitRegionID; | 247 | protected int m_splitRegionID; |
248 | protected Timer m_restartWaitTimer = new Timer(); | 248 | protected Timer m_restartWaitTimer = new Timer(); |
249 | protected Timer m_timerWatchdog = new Timer(); | ||
249 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 250 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
250 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 251 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
251 | protected string m_simulatorVersion = "OpenSimulator Server"; | 252 | protected string m_simulatorVersion = "OpenSimulator Server"; |
252 | protected AgentCircuitManager m_authenticateHandler; | 253 | protected AgentCircuitManager m_authenticateHandler; |
253 | protected SceneCommunicationService m_sceneGridService; | 254 | protected SceneCommunicationService m_sceneGridService; |
255 | protected ISnmpModule m_snmpService = null; | ||
254 | 256 | ||
255 | protected ISimulationDataService m_SimulationDataService; | 257 | protected ISimulationDataService m_SimulationDataService; |
256 | protected IEstateDataService m_EstateDataService; | 258 | protected IEstateDataService m_EstateDataService; |
@@ -313,8 +315,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
313 | private int m_update_presences = 1; // Update scene presence movements | 315 | private int m_update_presences = 1; // Update scene presence movements |
314 | private int m_update_events = 1; | 316 | private int m_update_events = 1; |
315 | private int m_update_backup = 200; | 317 | private int m_update_backup = 200; |
316 | private int m_update_terrain = 50; | 318 | private int m_update_terrain = 1000; |
317 | // private int m_update_land = 1; | 319 | private int m_update_land = 10; |
318 | private int m_update_coarse_locations = 50; | 320 | private int m_update_coarse_locations = 50; |
319 | 321 | ||
320 | private int agentMS; | 322 | private int agentMS; |
@@ -327,13 +329,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
327 | private int backupMS; | 329 | private int backupMS; |
328 | private int terrainMS; | 330 | private int terrainMS; |
329 | private int landMS; | 331 | private int landMS; |
330 | private int spareMS; | ||
331 | 332 | ||
332 | /// <summary> | 333 | /// <summary> |
333 | /// Tick at which the last frame was processed. | 334 | /// Tick at which the last frame was processed. |
334 | /// </summary> | 335 | /// </summary> |
335 | private int m_lastFrameTick; | 336 | private int m_lastFrameTick; |
336 | 337 | ||
338 | public bool CombineRegions = false; | ||
337 | /// <summary> | 339 | /// <summary> |
338 | /// Tick at which the last maintenance run occurred. | 340 | /// Tick at which the last maintenance run occurred. |
339 | /// </summary> | 341 | /// </summary> |
@@ -353,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
353 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 355 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
354 | private volatile bool m_backingup; | 356 | private volatile bool m_backingup; |
355 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 357 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
356 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); | 358 | private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); |
357 | 359 | ||
358 | private string m_defaultScriptEngine; | 360 | private string m_defaultScriptEngine; |
359 | 361 | ||
@@ -362,6 +364,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
362 | /// </summary> | 364 | /// </summary> |
363 | private int m_LastLogin; | 365 | private int m_LastLogin; |
364 | 366 | ||
367 | private int m_lastIncoming; | ||
368 | private int m_lastOutgoing; | ||
369 | private int m_hbRestarts = 0; | ||
370 | |||
371 | |||
365 | /// <summary> | 372 | /// <summary> |
366 | /// Thread that runs the scene loop. | 373 | /// Thread that runs the scene loop. |
367 | /// </summary> | 374 | /// </summary> |
@@ -404,7 +411,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
404 | private volatile bool m_active; | 411 | private volatile bool m_active; |
405 | 412 | ||
406 | // private int m_lastUpdate; | 413 | // private int m_lastUpdate; |
407 | // private bool m_firstHeartbeat = true; | 414 | private bool m_firstHeartbeat = true; |
408 | 415 | ||
409 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 416 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
410 | private bool m_reprioritizationEnabled = true; | 417 | private bool m_reprioritizationEnabled = true; |
@@ -448,6 +455,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
448 | get { return m_sceneGridService; } | 455 | get { return m_sceneGridService; } |
449 | } | 456 | } |
450 | 457 | ||
458 | public ISnmpModule SnmpService | ||
459 | { | ||
460 | get | ||
461 | { | ||
462 | if (m_snmpService == null) | ||
463 | { | ||
464 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
465 | } | ||
466 | |||
467 | return m_snmpService; | ||
468 | } | ||
469 | } | ||
470 | |||
451 | public ISimulationDataService SimulationDataService | 471 | public ISimulationDataService SimulationDataService |
452 | { | 472 | { |
453 | get | 473 | get |
@@ -741,6 +761,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
741 | m_SimulationDataService = simDataService; | 761 | m_SimulationDataService = simDataService; |
742 | m_EstateDataService = estateDataService; | 762 | m_EstateDataService = estateDataService; |
743 | m_regionHandle = RegionInfo.RegionHandle; | 763 | m_regionHandle = RegionInfo.RegionHandle; |
764 | m_lastIncoming = 0; | ||
765 | m_lastOutgoing = 0; | ||
744 | 766 | ||
745 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 767 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
746 | m_asyncSceneObjectDeleter.Enabled = true; | 768 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -834,7 +856,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
834 | 856 | ||
835 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | 857 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); |
836 | 858 | ||
837 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | 859 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
838 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); | 860 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); |
839 | if (!UseBackup) | 861 | if (!UseBackup) |
840 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 862 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
@@ -846,9 +868,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
846 | 868 | ||
847 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); | 869 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); |
848 | 870 | ||
849 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | 871 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
850 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | 872 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
851 | |||
852 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); | 873 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); |
853 | if (RegionInfo.NonphysPrimMin > 0) | 874 | if (RegionInfo.NonphysPrimMin > 0) |
854 | { | 875 | { |
@@ -868,11 +889,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
868 | } | 889 | } |
869 | 890 | ||
870 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 891 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
892 | |||
871 | if (RegionInfo.PhysPrimMax > 0) | 893 | if (RegionInfo.PhysPrimMax > 0) |
872 | { | 894 | { |
873 | m_maxPhys = RegionInfo.PhysPrimMax; | 895 | m_maxPhys = RegionInfo.PhysPrimMax; |
874 | } | 896 | } |
875 | 897 | ||
898 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | ||
899 | if (RegionInfo.LinksetCapacity > 0) | ||
900 | { | ||
901 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
902 | } | ||
903 | |||
904 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
905 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
906 | |||
876 | // Here, if clamping is requested in either global or | 907 | // Here, if clamping is requested in either global or |
877 | // local config, it will be used | 908 | // local config, it will be used |
878 | // | 909 | // |
@@ -882,13 +913,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
882 | m_clampPrimSize = true; | 913 | m_clampPrimSize = true; |
883 | } | 914 | } |
884 | 915 | ||
885 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | 916 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
886 | if (RegionInfo.LinksetCapacity > 0) | ||
887 | { | ||
888 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
889 | } | ||
890 | |||
891 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | ||
892 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 917 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
893 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 918 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
894 | m_dontPersistBefore = | 919 | m_dontPersistBefore = |
@@ -899,11 +924,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
899 | m_persistAfter *= 10000000; | 924 | m_persistAfter *= 10000000; |
900 | 925 | ||
901 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 926 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
902 | 927 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | |
903 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
904 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
905 | 928 | ||
906 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 929 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
930 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
931 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
907 | 932 | ||
908 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; | 933 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; |
909 | 934 | ||
@@ -948,7 +973,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
948 | 973 | ||
949 | if (grant.Length > 0) | 974 | if (grant.Length > 0) |
950 | { | 975 | { |
951 | foreach (string viewer in grant.Split('|')) | 976 | foreach (string viewer in grant.Split(',')) |
952 | { | 977 | { |
953 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 978 | m_AllowedViewers.Add(viewer.Trim().ToLower()); |
954 | } | 979 | } |
@@ -960,7 +985,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
960 | 985 | ||
961 | if (grant.Length > 0) | 986 | if (grant.Length > 0) |
962 | { | 987 | { |
963 | foreach (string viewer in grant.Split('|')) | 988 | foreach (string viewer in grant.Split(',')) |
964 | { | 989 | { |
965 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 990 | m_BannedViewers.Add(viewer.Trim().ToLower()); |
966 | } | 991 | } |
@@ -1020,6 +1045,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1020 | StatsReporter = new SimStatsReporter(this); | 1045 | StatsReporter = new SimStatsReporter(this); |
1021 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1046 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
1022 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1047 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1048 | |||
1049 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | ||
1023 | } | 1050 | } |
1024 | 1051 | ||
1025 | public Scene(RegionInfo regInfo) : base(regInfo) | 1052 | public Scene(RegionInfo regInfo) : base(regInfo) |
@@ -1315,8 +1342,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1315 | // Stop all client threads. | 1342 | // Stop all client threads. |
1316 | ForEachScenePresence(delegate(ScenePresence avatar) { CloseAgent(avatar.UUID, false); }); | 1343 | ForEachScenePresence(delegate(ScenePresence avatar) { CloseAgent(avatar.UUID, false); }); |
1317 | 1344 | ||
1318 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1345 | m_log.Debug("[SCENE]: TriggerSceneShuttingDown"); |
1319 | EventManager.TriggerSceneShuttingDown(this); | 1346 | EventManager.TriggerSceneShuttingDown(this); |
1347 | |||
1348 | m_log.Debug("[SCENE]: Persisting changed objects"); | ||
1349 | |||
1320 | Backup(false); | 1350 | Backup(false); |
1321 | m_sceneGraph.Close(); | 1351 | m_sceneGraph.Close(); |
1322 | 1352 | ||
@@ -1330,6 +1360,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1330 | // attempt to reference a null or disposed physics scene. | 1360 | // attempt to reference a null or disposed physics scene. |
1331 | if (PhysicsScene != null) | 1361 | if (PhysicsScene != null) |
1332 | { | 1362 | { |
1363 | m_log.Debug("[SCENE]: Dispose Physics"); | ||
1333 | PhysicsScene phys = PhysicsScene; | 1364 | PhysicsScene phys = PhysicsScene; |
1334 | // remove the physics engine from both Scene and SceneGraph | 1365 | // remove the physics engine from both Scene and SceneGraph |
1335 | PhysicsScene = null; | 1366 | PhysicsScene = null; |
@@ -1360,11 +1391,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1360 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1391 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1361 | if (m_heartbeatThread != null) | 1392 | if (m_heartbeatThread != null) |
1362 | { | 1393 | { |
1394 | m_hbRestarts++; | ||
1395 | if(m_hbRestarts > 10) | ||
1396 | Environment.Exit(1); | ||
1397 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1398 | |||
1399 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1400 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1401 | //proc.EnableRaisingEvents=false; | ||
1402 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1403 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1404 | //proc.Start(); | ||
1405 | //proc.WaitForExit(); | ||
1406 | //Thread.Sleep(1000); | ||
1407 | //Environment.Exit(1); | ||
1363 | m_heartbeatThread.Abort(); | 1408 | m_heartbeatThread.Abort(); |
1409 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1364 | m_heartbeatThread = null; | 1410 | m_heartbeatThread = null; |
1365 | } | 1411 | } |
1366 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1412 | // m_lastUpdate = Util.EnvironmentTickCount(); |
1367 | 1413 | ||
1414 | // m_sceneGraph.PreparePhysicsSimulation(); | ||
1415 | |||
1416 | |||
1368 | m_heartbeatThread | 1417 | m_heartbeatThread |
1369 | = Watchdog.StartThread( | 1418 | = Watchdog.StartThread( |
1370 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); | 1419 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); |
@@ -1509,16 +1558,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1509 | endFrame = Frame + frames; | 1558 | endFrame = Frame + frames; |
1510 | 1559 | ||
1511 | float physicsFPS = 0f; | 1560 | float physicsFPS = 0f; |
1512 | int previousFrameTick, tmpMS; | 1561 | int tmpMS; |
1513 | int maintc = Util.EnvironmentTickCount(); | 1562 | int previousFrameTick; |
1563 | int maintc; | ||
1564 | int sleepMS; | ||
1565 | int framestart; | ||
1514 | 1566 | ||
1515 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) | 1567 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) |
1516 | { | 1568 | { |
1569 | framestart = Util.EnvironmentTickCount(); | ||
1517 | ++Frame; | 1570 | ++Frame; |
1518 | 1571 | ||
1519 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1572 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1520 | 1573 | ||
1521 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; | 1574 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
1522 | 1575 | ||
1523 | try | 1576 | try |
1524 | { | 1577 | { |
@@ -1572,6 +1625,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1572 | m_sceneGraph.UpdatePresences(); | 1625 | m_sceneGraph.UpdatePresences(); |
1573 | 1626 | ||
1574 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); | 1627 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1628 | |||
1575 | 1629 | ||
1576 | // Delete temp-on-rez stuff | 1630 | // Delete temp-on-rez stuff |
1577 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | 1631 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) |
@@ -1653,34 +1707,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1653 | 1707 | ||
1654 | Watchdog.UpdateThread(); | 1708 | Watchdog.UpdateThread(); |
1655 | 1709 | ||
1710 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1711 | |||
1712 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1713 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1714 | StatsReporter.AddFPS(1); | ||
1715 | |||
1716 | StatsReporter.addAgentMS(agentMS); | ||
1717 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1718 | StatsReporter.addOtherMS(otherMS); | ||
1719 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1720 | |||
1656 | previousFrameTick = m_lastFrameTick; | 1721 | previousFrameTick = m_lastFrameTick; |
1657 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1722 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1658 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1723 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1659 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1724 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1660 | 1725 | ||
1726 | m_firstHeartbeat = false; | ||
1727 | |||
1728 | sleepMS = Util.EnvironmentTickCount(); | ||
1729 | |||
1661 | if (tmpMS > 0) | 1730 | if (tmpMS > 0) |
1662 | { | ||
1663 | Thread.Sleep(tmpMS); | 1731 | Thread.Sleep(tmpMS); |
1664 | spareMS += tmpMS; | ||
1665 | } | ||
1666 | 1732 | ||
1667 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | 1733 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); |
1668 | maintc = Util.EnvironmentTickCount(); | 1734 | frameMS = Util.EnvironmentTickCountSubtract(framestart); |
1669 | 1735 | StatsReporter.addSleepMS(sleepMS); | |
1670 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1736 | StatsReporter.addFrameMS(frameMS); |
1671 | 1737 | ||
1672 | // if (Frame%m_update_avatars == 0) | 1738 | // if (Frame%m_update_avatars == 0) |
1673 | // UpdateInWorldTime(); | 1739 | // UpdateInWorldTime(); |
1674 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1675 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1676 | StatsReporter.AddFPS(1); | ||
1677 | 1740 | ||
1678 | StatsReporter.addFrameMS(frameMS); | ||
1679 | StatsReporter.addAgentMS(agentMS); | ||
1680 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1681 | StatsReporter.addOtherMS(otherMS); | ||
1682 | StatsReporter.AddSpareMS(spareMS); | ||
1683 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1684 | 1741 | ||
1685 | // Optionally warn if a frame takes double the amount of time that it should. | 1742 | // Optionally warn if a frame takes double the amount of time that it should. |
1686 | if (DebugUpdates | 1743 | if (DebugUpdates |
@@ -1697,7 +1754,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1697 | public void AddGroupTarget(SceneObjectGroup grp) | 1754 | public void AddGroupTarget(SceneObjectGroup grp) |
1698 | { | 1755 | { |
1699 | lock (m_groupsWithTargets) | 1756 | lock (m_groupsWithTargets) |
1700 | m_groupsWithTargets[grp.UUID] = grp; | 1757 | m_groupsWithTargets[grp.UUID] = 0; |
1701 | } | 1758 | } |
1702 | 1759 | ||
1703 | public void RemoveGroupTarget(SceneObjectGroup grp) | 1760 | public void RemoveGroupTarget(SceneObjectGroup grp) |
@@ -1708,18 +1765,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1708 | 1765 | ||
1709 | private void CheckAtTargets() | 1766 | private void CheckAtTargets() |
1710 | { | 1767 | { |
1711 | List<SceneObjectGroup> objs = null; | 1768 | List<UUID> objs = null; |
1712 | 1769 | ||
1713 | lock (m_groupsWithTargets) | 1770 | lock (m_groupsWithTargets) |
1714 | { | 1771 | { |
1715 | if (m_groupsWithTargets.Count != 0) | 1772 | if (m_groupsWithTargets.Count != 0) |
1716 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); | 1773 | objs = new List<UUID>(m_groupsWithTargets.Keys); |
1717 | } | 1774 | } |
1718 | 1775 | ||
1719 | if (objs != null) | 1776 | if (objs != null) |
1720 | { | 1777 | { |
1721 | foreach (SceneObjectGroup entry in objs) | 1778 | foreach (UUID entry in objs) |
1722 | entry.checkAtTargets(); | 1779 | { |
1780 | SceneObjectGroup grp = GetSceneObjectGroup(entry); | ||
1781 | if (grp == null) | ||
1782 | m_groupsWithTargets.Remove(entry); | ||
1783 | else | ||
1784 | grp.checkAtTargets(); | ||
1785 | } | ||
1723 | } | 1786 | } |
1724 | } | 1787 | } |
1725 | 1788 | ||
@@ -1798,7 +1861,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1798 | msg.fromAgentName = "Server"; | 1861 | msg.fromAgentName = "Server"; |
1799 | msg.dialog = (byte)19; // Object msg | 1862 | msg.dialog = (byte)19; // Object msg |
1800 | msg.fromGroup = false; | 1863 | msg.fromGroup = false; |
1801 | msg.offline = (byte)0; | 1864 | msg.offline = (byte)1; |
1802 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1865 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1803 | msg.Position = Vector3.Zero; | 1866 | msg.Position = Vector3.Zero; |
1804 | msg.RegionID = RegionInfo.RegionID.Guid; | 1867 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -2032,7 +2095,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2032 | return PhysicsScene.SupportsRaycastWorldFiltered(); | 2095 | return PhysicsScene.SupportsRaycastWorldFiltered(); |
2033 | } | 2096 | } |
2034 | 2097 | ||
2035 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | 2098 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) |
2036 | { | 2099 | { |
2037 | if (PhysicsScene == null) | 2100 | if (PhysicsScene == null) |
2038 | return null; | 2101 | return null; |
@@ -2054,14 +2117,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2054 | /// <returns></returns> | 2117 | /// <returns></returns> |
2055 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 2118 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
2056 | { | 2119 | { |
2120 | |||
2121 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
2122 | Vector3 wpos = Vector3.Zero; | ||
2123 | // Check for water surface intersection from above | ||
2124 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
2125 | { | ||
2126 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
2127 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
2128 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
2129 | wpos.Z = wheight; | ||
2130 | } | ||
2131 | |||
2057 | Vector3 pos = Vector3.Zero; | 2132 | Vector3 pos = Vector3.Zero; |
2058 | if (RayEndIsIntersection == (byte)1) | 2133 | if (RayEndIsIntersection == (byte)1) |
2059 | { | 2134 | { |
2060 | pos = RayEnd; | 2135 | pos = RayEnd; |
2061 | return pos; | ||
2062 | } | 2136 | } |
2063 | 2137 | else if (RayTargetID != UUID.Zero) | |
2064 | if (RayTargetID != UUID.Zero) | ||
2065 | { | 2138 | { |
2066 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 2139 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
2067 | 2140 | ||
@@ -2083,7 +2156,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2083 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 2156 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
2084 | 2157 | ||
2085 | // Un-comment out the following line to Get Raytrace results printed to the console. | 2158 | // Un-comment out the following line to Get Raytrace results printed to the console. |
2086 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 2159 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
2087 | float ScaleOffset = 0.5f; | 2160 | float ScaleOffset = 0.5f; |
2088 | 2161 | ||
2089 | // If we hit something | 2162 | // If we hit something |
@@ -2106,13 +2179,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2106 | //pos.Z -= 0.25F; | 2179 | //pos.Z -= 0.25F; |
2107 | 2180 | ||
2108 | } | 2181 | } |
2109 | |||
2110 | return pos; | ||
2111 | } | 2182 | } |
2112 | else | 2183 | else |
2113 | { | 2184 | { |
2114 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2185 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
2115 | |||
2116 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2186 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
2117 | 2187 | ||
2118 | // Un-comment the following line to print the raytrace results to the console. | 2188 | // Un-comment the following line to print the raytrace results to the console. |
@@ -2121,13 +2191,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2121 | if (ei.HitTF) | 2191 | if (ei.HitTF) |
2122 | { | 2192 | { |
2123 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2193 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
2124 | } else | 2194 | } |
2195 | else | ||
2125 | { | 2196 | { |
2126 | // fall back to our stupid functionality | 2197 | // fall back to our stupid functionality |
2127 | pos = RayEnd; | 2198 | pos = RayEnd; |
2128 | } | 2199 | } |
2129 | |||
2130 | return pos; | ||
2131 | } | 2200 | } |
2132 | } | 2201 | } |
2133 | else | 2202 | else |
@@ -2138,8 +2207,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2138 | //increase height so its above the ground. | 2207 | //increase height so its above the ground. |
2139 | //should be getting the normal of the ground at the rez point and using that? | 2208 | //should be getting the normal of the ground at the rez point and using that? |
2140 | pos.Z += scale.Z / 2f; | 2209 | pos.Z += scale.Z / 2f; |
2141 | return pos; | 2210 | // return pos; |
2142 | } | 2211 | } |
2212 | |||
2213 | // check against posible water intercept | ||
2214 | if (wpos.Z > pos.Z) pos = wpos; | ||
2215 | return pos; | ||
2143 | } | 2216 | } |
2144 | 2217 | ||
2145 | 2218 | ||
@@ -2230,12 +2303,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2230 | { | 2303 | { |
2231 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) | 2304 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) |
2232 | { | 2305 | { |
2306 | sceneObject.IsDeleted = false; | ||
2233 | EventManager.TriggerObjectAddedToScene(sceneObject); | 2307 | EventManager.TriggerObjectAddedToScene(sceneObject); |
2234 | return true; | 2308 | return true; |
2235 | } | 2309 | } |
2236 | 2310 | ||
2237 | return false; | 2311 | return false; |
2238 | |||
2239 | } | 2312 | } |
2240 | 2313 | ||
2241 | /// <summary> | 2314 | /// <summary> |
@@ -2327,6 +2400,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2327 | /// </summary> | 2400 | /// </summary> |
2328 | public void DeleteAllSceneObjects() | 2401 | public void DeleteAllSceneObjects() |
2329 | { | 2402 | { |
2403 | DeleteAllSceneObjects(false); | ||
2404 | } | ||
2405 | |||
2406 | /// <summary> | ||
2407 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2408 | /// </summary> | ||
2409 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2410 | { | ||
2411 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2330 | lock (Entities) | 2412 | lock (Entities) |
2331 | { | 2413 | { |
2332 | EntityBase[] entities = Entities.GetEntities(); | 2414 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2335,11 +2417,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2335 | if (e is SceneObjectGroup) | 2417 | if (e is SceneObjectGroup) |
2336 | { | 2418 | { |
2337 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2419 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2338 | if (!sog.IsAttachment) | 2420 | if (sog != null && !sog.IsAttachment) |
2339 | DeleteSceneObject((SceneObjectGroup)e, false); | 2421 | { |
2422 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2423 | { | ||
2424 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2425 | } | ||
2426 | else | ||
2427 | { | ||
2428 | toReturn.Add((SceneObjectGroup)e); | ||
2429 | } | ||
2430 | } | ||
2340 | } | 2431 | } |
2341 | } | 2432 | } |
2342 | } | 2433 | } |
2434 | if (toReturn.Count > 0) | ||
2435 | { | ||
2436 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2437 | } | ||
2343 | } | 2438 | } |
2344 | 2439 | ||
2345 | /// <summary> | 2440 | /// <summary> |
@@ -2370,6 +2465,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2370 | else | 2465 | else |
2371 | group.StopScriptInstances(); | 2466 | group.StopScriptInstances(); |
2372 | 2467 | ||
2468 | List<UUID> avatars = group.GetSittingAvatars(); | ||
2469 | foreach (UUID av in avatars) | ||
2470 | { | ||
2471 | ScenePresence p = GetScenePresence(av); | ||
2472 | if (p != null) | ||
2473 | p.StandUp(); | ||
2474 | } | ||
2475 | |||
2373 | SceneObjectPart[] partList = group.Parts; | 2476 | SceneObjectPart[] partList = group.Parts; |
2374 | 2477 | ||
2375 | foreach (SceneObjectPart part in partList) | 2478 | foreach (SceneObjectPart part in partList) |
@@ -2397,6 +2500,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2397 | } | 2500 | } |
2398 | 2501 | ||
2399 | group.DeleteGroupFromScene(silent); | 2502 | group.DeleteGroupFromScene(silent); |
2503 | if (!silent) | ||
2504 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2400 | 2505 | ||
2401 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2506 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2402 | } | 2507 | } |
@@ -2686,7 +2791,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2686 | // If the user is banned, we won't let any of their objects | 2791 | // If the user is banned, we won't let any of their objects |
2687 | // enter. Period. | 2792 | // enter. Period. |
2688 | // | 2793 | // |
2689 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2794 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2690 | { | 2795 | { |
2691 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2796 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2692 | return false; | 2797 | return false; |
@@ -2722,8 +2827,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2722 | newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); | 2827 | newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); |
2723 | newObject.ResumeScripts(); | 2828 | newObject.ResumeScripts(); |
2724 | 2829 | ||
2725 | if (newObject.RootPart.KeyframeMotion != null) | 2830 | // AddSceneObject already does this and doing it again messes |
2726 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | 2831 | // up region crossings, so don't. |
2832 | //if (newObject.RootPart.KeyframeMotion != null) | ||
2833 | // newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2727 | } | 2834 | } |
2728 | 2835 | ||
2729 | // Do this as late as possible so that listeners have full access to the incoming object | 2836 | // Do this as late as possible so that listeners have full access to the incoming object |
@@ -2741,6 +2848,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2741 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2848 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2742 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2849 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2743 | { | 2850 | { |
2851 | if (sceneObject.OwnerID == UUID.Zero) | ||
2852 | { | ||
2853 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2854 | return false; | ||
2855 | } | ||
2856 | |||
2857 | // If the user is banned, we won't let any of their objects | ||
2858 | // enter. Period. | ||
2859 | // | ||
2860 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2861 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2862 | { | ||
2863 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2864 | |||
2865 | return false; | ||
2866 | } | ||
2867 | |||
2744 | // Force allocation of new LocalId | 2868 | // Force allocation of new LocalId |
2745 | // | 2869 | // |
2746 | SceneObjectPart[] parts = sceneObject.Parts; | 2870 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2777,16 +2901,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2777 | // information that this is due to a teleport/border cross rather than an ordinary attachment. | 2901 | // information that this is due to a teleport/border cross rather than an ordinary attachment. |
2778 | // We currently do this in Scene.MakeRootAgent() instead. | 2902 | // We currently do this in Scene.MakeRootAgent() instead. |
2779 | if (AttachmentsModule != null) | 2903 | if (AttachmentsModule != null) |
2780 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); | 2904 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true); |
2781 | } | 2905 | } |
2782 | else | 2906 | else |
2783 | { | 2907 | { |
2908 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2784 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2909 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2785 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2910 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2786 | } | 2911 | } |
2912 | if (sceneObject.OwnerID == UUID.Zero) | ||
2913 | { | ||
2914 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2915 | return false; | ||
2916 | } | ||
2787 | } | 2917 | } |
2788 | else | 2918 | else |
2789 | { | 2919 | { |
2920 | if (sceneObject.OwnerID == UUID.Zero) | ||
2921 | { | ||
2922 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2923 | return false; | ||
2924 | } | ||
2790 | AddRestoredSceneObject(sceneObject, true, false); | 2925 | AddRestoredSceneObject(sceneObject, true, false); |
2791 | } | 2926 | } |
2792 | 2927 | ||
@@ -2803,6 +2938,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2803 | return 2; // StateSource.PrimCrossing | 2938 | return 2; // StateSource.PrimCrossing |
2804 | } | 2939 | } |
2805 | 2940 | ||
2941 | public int GetUserFlags(UUID user) | ||
2942 | { | ||
2943 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2944 | /* | ||
2945 | ScenePresence sp; | ||
2946 | if (TryGetScenePresence(user, out sp)) | ||
2947 | { | ||
2948 | return sp.UserFlags; | ||
2949 | } | ||
2950 | else | ||
2951 | { | ||
2952 | */ | ||
2953 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2954 | if (uac == null) | ||
2955 | return 0; | ||
2956 | return uac.UserFlags; | ||
2957 | //} | ||
2958 | } | ||
2806 | #endregion | 2959 | #endregion |
2807 | 2960 | ||
2808 | #region Add/Remove Avatar Methods | 2961 | #region Add/Remove Avatar Methods |
@@ -2836,7 +2989,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2836 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2989 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2837 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2990 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2838 | 2991 | ||
2839 | // CheckHeartbeat(); | 2992 | CheckHeartbeat(); |
2840 | 2993 | ||
2841 | sp = GetScenePresence(client.AgentId); | 2994 | sp = GetScenePresence(client.AgentId); |
2842 | 2995 | ||
@@ -2854,6 +3007,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2854 | SubscribeToClientEvents(client); | 3007 | SubscribeToClientEvents(client); |
2855 | 3008 | ||
2856 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); | 3009 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); |
3010 | InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46); | ||
3011 | if (cof == null) | ||
3012 | sp.COF = UUID.Zero; | ||
3013 | else | ||
3014 | sp.COF = cof.ID; | ||
3015 | |||
3016 | m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF); | ||
2857 | m_eventManager.TriggerOnNewPresence(sp); | 3017 | m_eventManager.TriggerOnNewPresence(sp); |
2858 | 3018 | ||
2859 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; | 3019 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; |
@@ -2974,19 +3134,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2974 | // and the scene presence and the client, if they exist | 3134 | // and the scene presence and the client, if they exist |
2975 | try | 3135 | try |
2976 | { | 3136 | { |
2977 | // We need to wait for the client to make UDP contact first. | 3137 | ScenePresence sp = GetScenePresence(agentID); |
2978 | // It's the UDP contact that creates the scene presence | 3138 | |
2979 | ScenePresence sp = WaitGetScenePresence(agentID); | ||
2980 | if (sp != null) | 3139 | if (sp != null) |
2981 | { | 3140 | { |
2982 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 3141 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2983 | 3142 | ||
2984 | CloseAgent(sp.UUID, false); | 3143 | CloseAgent(sp.UUID, false); |
2985 | } | 3144 | } |
2986 | else | 3145 | |
2987 | { | ||
2988 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2989 | } | ||
2990 | // BANG! SLASH! | 3146 | // BANG! SLASH! |
2991 | m_authenticateHandler.RemoveCircuit(agentID); | 3147 | m_authenticateHandler.RemoveCircuit(agentID); |
2992 | 3148 | ||
@@ -3031,6 +3187,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3031 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3187 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
3032 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3188 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
3033 | 3189 | ||
3190 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3191 | |||
3034 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3192 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3035 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3193 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3036 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3194 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3087,6 +3245,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3087 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3245 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
3088 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3246 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
3089 | client.OnCopyInventoryItem += CopyInventoryItem; | 3247 | client.OnCopyInventoryItem += CopyInventoryItem; |
3248 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
3090 | client.OnMoveInventoryItem += MoveInventoryItem; | 3249 | client.OnMoveInventoryItem += MoveInventoryItem; |
3091 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3250 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
3092 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3251 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3156,6 +3315,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3156 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3315 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
3157 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3316 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
3158 | 3317 | ||
3318 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3319 | |||
3159 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3320 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3160 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3321 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3161 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3322 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3467,7 +3628,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3467 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop | 3628 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop |
3468 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI | 3629 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI |
3469 | if (closeChildAgents && CapsModule != null) | 3630 | if (closeChildAgents && CapsModule != null) |
3470 | CapsModule.RemoveCaps(agentID); | 3631 | CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode); |
3471 | 3632 | ||
3472 | if (closeChildAgents && !isChildAgent) | 3633 | if (closeChildAgents && !isChildAgent) |
3473 | { | 3634 | { |
@@ -3500,6 +3661,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3500 | // It's possible for child agents to have transactions if changes are being made cross-border. | 3661 | // It's possible for child agents to have transactions if changes are being made cross-border. |
3501 | if (AgentTransactionsModule != null) | 3662 | if (AgentTransactionsModule != null) |
3502 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3663 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3664 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3503 | } | 3665 | } |
3504 | catch (Exception e) | 3666 | catch (Exception e) |
3505 | { | 3667 | { |
@@ -3807,13 +3969,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3807 | // On login test land permisions | 3969 | // On login test land permisions |
3808 | if (vialogin) | 3970 | if (vialogin) |
3809 | { | 3971 | { |
3972 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); | ||
3973 | if (cache != null) | ||
3974 | cache.Remove(acd.firstname + " " + acd.lastname); | ||
3810 | if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y)) | 3975 | if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y)) |
3811 | { | 3976 | { |
3812 | m_authenticateHandler.RemoveCircuit(acd.circuitcode); | 3977 | m_authenticateHandler.RemoveCircuit(acd.circuitcode); |
3813 | return false; | 3978 | return false; |
3814 | } | 3979 | } |
3815 | } | 3980 | } |
3816 | 3981 | ||
3817 | if (sp == null) // We don't have an [child] agent here already | 3982 | if (sp == null) // We don't have an [child] agent here already |
3818 | { | 3983 | { |
3819 | if (requirePresenceLookup) | 3984 | if (requirePresenceLookup) |
@@ -3835,7 +4000,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3835 | return false; | 4000 | return false; |
3836 | } | 4001 | } |
3837 | } | 4002 | } |
3838 | 4003 | ||
3839 | try | 4004 | try |
3840 | { | 4005 | { |
3841 | if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason)) | 4006 | if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason)) |
@@ -3852,7 +4017,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3852 | m_authenticateHandler.RemoveCircuit(acd.circuitcode); | 4017 | m_authenticateHandler.RemoveCircuit(acd.circuitcode); |
3853 | return false; | 4018 | return false; |
3854 | } | 4019 | } |
3855 | 4020 | ||
3856 | m_log.InfoFormat( | 4021 | m_log.InfoFormat( |
3857 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", | 4022 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", |
3858 | Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname, | 4023 | Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname, |
@@ -3861,7 +4026,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3861 | if (CapsModule != null) | 4026 | if (CapsModule != null) |
3862 | { | 4027 | { |
3863 | CapsModule.SetAgentCapsSeeds(acd); | 4028 | CapsModule.SetAgentCapsSeeds(acd); |
3864 | CapsModule.CreateCaps(acd.AgentID); | 4029 | CapsModule.CreateCaps(acd.AgentID, acd.circuitcode); |
3865 | } | 4030 | } |
3866 | } | 4031 | } |
3867 | else | 4032 | else |
@@ -3881,7 +4046,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3881 | if (CapsModule != null) | 4046 | if (CapsModule != null) |
3882 | { | 4047 | { |
3883 | CapsModule.SetAgentCapsSeeds(acd); | 4048 | CapsModule.SetAgentCapsSeeds(acd); |
3884 | CapsModule.CreateCaps(acd.AgentID); | 4049 | CapsModule.CreateCaps(acd.AgentID, acd.circuitcode); |
3885 | } | 4050 | } |
3886 | } | 4051 | } |
3887 | } | 4052 | } |
@@ -3892,6 +4057,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3892 | CacheUserName(null, acd); | 4057 | CacheUserName(null, acd); |
3893 | } | 4058 | } |
3894 | 4059 | ||
4060 | if (CapsModule != null) | ||
4061 | { | ||
4062 | CapsModule.ActivateCaps(acd.circuitcode); | ||
4063 | } | ||
4064 | |||
3895 | if (vialogin) | 4065 | if (vialogin) |
3896 | { | 4066 | { |
3897 | // CleanDroppedAttachments(); | 4067 | // CleanDroppedAttachments(); |
@@ -3983,6 +4153,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3983 | } | 4153 | } |
3984 | 4154 | ||
3985 | // Honor parcel landing type and position. | 4155 | // Honor parcel landing type and position. |
4156 | /* | ||
4157 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3986 | if (land != null) | 4158 | if (land != null) |
3987 | { | 4159 | { |
3988 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 4160 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3990,6 +4162,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3990 | acd.startpos = land.LandData.UserLocation; | 4162 | acd.startpos = land.LandData.UserLocation; |
3991 | } | 4163 | } |
3992 | } | 4164 | } |
4165 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3993 | } | 4166 | } |
3994 | 4167 | ||
3995 | return true; | 4168 | return true; |
@@ -4087,7 +4260,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4087 | 4260 | ||
4088 | if (!m_strictAccessControl) return true; | 4261 | if (!m_strictAccessControl) return true; |
4089 | if (Permissions.IsGod(agent.AgentID)) return true; | 4262 | if (Permissions.IsGod(agent.AgentID)) return true; |
4090 | 4263 | ||
4091 | if (AuthorizationService != null) | 4264 | if (AuthorizationService != null) |
4092 | { | 4265 | { |
4093 | if (!AuthorizationService.IsAuthorizedForRegion( | 4266 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -4108,7 +4281,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4108 | { | 4281 | { |
4109 | if (RegionInfo.EstateSettings != null) | 4282 | if (RegionInfo.EstateSettings != null) |
4110 | { | 4283 | { |
4111 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 4284 | int flags = GetUserFlags(agent.AgentID); |
4285 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, flags)) | ||
4112 | { | 4286 | { |
4113 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 4287 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
4114 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 4288 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -4297,6 +4471,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4297 | m_log.DebugFormat( | 4471 | m_log.DebugFormat( |
4298 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); | 4472 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); |
4299 | 4473 | ||
4474 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4475 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4476 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4477 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4478 | { | ||
4479 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4480 | return false; | ||
4481 | } | ||
4482 | |||
4300 | // TODO: This check should probably be in QueryAccess(). | 4483 | // TODO: This check should probably be in QueryAccess(). |
4301 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4484 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4302 | if (nearestParcel == null) | 4485 | if (nearestParcel == null) |
@@ -4397,7 +4580,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4397 | /// <param name='agentID'></param> | 4580 | /// <param name='agentID'></param> |
4398 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 4581 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4399 | { | 4582 | { |
4400 | int ntimes = 20; | 4583 | int ntimes = 30; |
4401 | ScenePresence sp = null; | 4584 | ScenePresence sp = null; |
4402 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 4585 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4403 | Thread.Sleep(1000); | 4586 | Thread.Sleep(1000); |
@@ -4459,6 +4642,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4459 | return false; | 4642 | return false; |
4460 | } | 4643 | } |
4461 | 4644 | ||
4645 | // public bool IncomingCloseAgent(UUID agentID) | ||
4646 | // { | ||
4647 | // return IncomingCloseAgent(agentID, false); | ||
4648 | // } | ||
4649 | |||
4650 | // public bool IncomingCloseChildAgent(UUID agentID) | ||
4651 | // { | ||
4652 | // return IncomingCloseAgent(agentID, true); | ||
4653 | // } | ||
4654 | |||
4462 | /// <summary> | 4655 | /// <summary> |
4463 | /// Tell a single client to prepare to close. | 4656 | /// Tell a single client to prepare to close. |
4464 | /// </summary> | 4657 | /// </summary> |
@@ -4557,7 +4750,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4557 | 4750 | ||
4558 | if (sp != null) | 4751 | if (sp != null) |
4559 | { | 4752 | { |
4560 | sp.ControllingClient.Close(force); | 4753 | sp.ControllingClient.Close(force, force); |
4561 | return true; | 4754 | return true; |
4562 | } | 4755 | } |
4563 | 4756 | ||
@@ -5175,7 +5368,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5175 | { | 5368 | { |
5176 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 5369 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
5177 | { | 5370 | { |
5178 | if (grp.RootPart.Expires <= DateTime.Now) | 5371 | if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now) |
5179 | DeleteSceneObject(grp, false); | 5372 | DeleteSceneObject(grp, false); |
5180 | } | 5373 | } |
5181 | } | 5374 | } |
@@ -5189,35 +5382,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
5189 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 5382 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
5190 | } | 5383 | } |
5191 | 5384 | ||
5192 | public int GetHealth() | 5385 | public int GetHealth(out int flags, out string message) |
5193 | { | 5386 | { |
5194 | // Returns: | 5387 | // Returns: |
5195 | // 1 = sim is up and accepting http requests. The heartbeat has | 5388 | // 1 = sim is up and accepting http requests. The heartbeat has |
5196 | // stopped and the sim is probably locked up, but a remote | 5389 | // stopped and the sim is probably locked up, but a remote |
5197 | // admin restart may succeed | 5390 | // admin restart may succeed |
5198 | // | 5391 | // |
5199 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 5392 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
5200 | // usable for people within and logins _may_ work | 5393 | // usable for people within |
5394 | // | ||
5395 | // 3 = Sim is up and one packet thread is running. Sim is | ||
5396 | // unstable and will not accept new logins | ||
5201 | // | 5397 | // |
5202 | // 3 = We have seen a new user enter within the past 4 minutes | 5398 | // 4 = Sim is up and both packet threads are running. Sim is |
5399 | // likely usable | ||
5400 | // | ||
5401 | // 5 = We have seen a new user enter within the past 4 minutes | ||
5203 | // which can be seen as positive confirmation of sim health | 5402 | // which can be seen as positive confirmation of sim health |
5204 | // | 5403 | // |
5404 | |||
5405 | flags = 0; | ||
5406 | message = String.Empty; | ||
5407 | |||
5408 | CheckHeartbeat(); | ||
5409 | |||
5410 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
5411 | { | ||
5412 | // We're still starting | ||
5413 | // 0 means "in startup", it can't happen another way, since | ||
5414 | // to get here, we must be able to accept http connections | ||
5415 | return 0; | ||
5416 | } | ||
5417 | |||
5205 | int health=1; // Start at 1, means we're up | 5418 | int health=1; // Start at 1, means we're up |
5206 | 5419 | ||
5207 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5420 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
5208 | health += 1; | 5421 | { |
5422 | health+=1; | ||
5423 | flags |= 1; | ||
5424 | } | ||
5425 | |||
5426 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
5427 | { | ||
5428 | health+=1; | ||
5429 | flags |= 2; | ||
5430 | } | ||
5431 | |||
5432 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
5433 | { | ||
5434 | health+=1; | ||
5435 | flags |= 4; | ||
5436 | } | ||
5209 | else | 5437 | else |
5438 | { | ||
5439 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
5440 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
5441 | proc.EnableRaisingEvents=false; | ||
5442 | proc.StartInfo.FileName = "/bin/kill"; | ||
5443 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
5444 | proc.Start(); | ||
5445 | proc.WaitForExit(); | ||
5446 | Thread.Sleep(1000); | ||
5447 | Environment.Exit(1); | ||
5448 | } | ||
5449 | |||
5450 | if (flags != 7) | ||
5210 | return health; | 5451 | return health; |
5211 | 5452 | ||
5212 | // A login in the last 4 mins? We can't be doing too badly | 5453 | // A login in the last 4 mins? We can't be doing too badly |
5213 | // | 5454 | // |
5214 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 5455 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
5215 | health++; | 5456 | health++; |
5216 | else | 5457 | else |
5217 | return health; | 5458 | return health; |
5218 | 5459 | ||
5219 | // CheckHeartbeat(); | ||
5220 | |||
5221 | return health; | 5460 | return health; |
5222 | } | 5461 | } |
5223 | 5462 | ||
@@ -5305,7 +5544,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5305 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5544 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
5306 | if (wasUsingPhysics) | 5545 | if (wasUsingPhysics) |
5307 | { | 5546 | { |
5308 | jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock | 5547 | jointProxyObject.UpdatePrimFlags(false, false, true, false,false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock |
5309 | } | 5548 | } |
5310 | } | 5549 | } |
5311 | 5550 | ||
@@ -5404,14 +5643,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5404 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5643 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
5405 | } | 5644 | } |
5406 | 5645 | ||
5407 | // private void CheckHeartbeat() | 5646 | private void CheckHeartbeat() |
5408 | // { | 5647 | { |
5409 | // if (m_firstHeartbeat) | 5648 | if (m_firstHeartbeat) |
5410 | // return; | 5649 | return; |
5411 | // | 5650 | |
5412 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5651 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
5413 | // StartTimer(); | 5652 | Start(); |
5414 | // } | 5653 | } |
5415 | 5654 | ||
5416 | public override ISceneObject DeserializeObject(string representation) | 5655 | public override ISceneObject DeserializeObject(string representation) |
5417 | { | 5656 | { |
@@ -5469,7 +5708,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5469 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); | 5708 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); |
5470 | 5709 | ||
5471 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); | 5710 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); |
5472 | 5711 | ||
5473 | return nearestRegionEdgePoint; | 5712 | return nearestRegionEdgePoint; |
5474 | } | 5713 | } |
5475 | 5714 | ||
@@ -5723,7 +5962,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5723 | mapModule.GenerateMaptile(); | 5962 | mapModule.GenerateMaptile(); |
5724 | } | 5963 | } |
5725 | 5964 | ||
5726 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5965 | // public void CleanDroppedAttachments() |
5966 | // { | ||
5967 | // List<SceneObjectGroup> objectsToDelete = | ||
5968 | // new List<SceneObjectGroup>(); | ||
5969 | // | ||
5970 | // lock (m_cleaningAttachments) | ||
5971 | // { | ||
5972 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5973 | // { | ||
5974 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5975 | // { | ||
5976 | // UUID agentID = grp.OwnerID; | ||
5977 | // if (agentID == UUID.Zero) | ||
5978 | // { | ||
5979 | // objectsToDelete.Add(grp); | ||
5980 | // return; | ||
5981 | // } | ||
5982 | // | ||
5983 | // ScenePresence sp = GetScenePresence(agentID); | ||
5984 | // if (sp == null) | ||
5985 | // { | ||
5986 | // objectsToDelete.Add(grp); | ||
5987 | // return; | ||
5988 | // } | ||
5989 | // } | ||
5990 | // }); | ||
5991 | // } | ||
5992 | // | ||
5993 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5994 | // { | ||
5995 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5996 | // DeleteSceneObject(grp, true); | ||
5997 | // } | ||
5998 | // } | ||
5999 | |||
6000 | public void ThreadAlive(int threadCode) | ||
6001 | { | ||
6002 | switch(threadCode) | ||
6003 | { | ||
6004 | case 1: // Incoming | ||
6005 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
6006 | break; | ||
6007 | case 2: // Incoming | ||
6008 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
6009 | break; | ||
6010 | } | ||
6011 | } | ||
6012 | |||
6013 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5727 | { | 6014 | { |
5728 | RegenerateMaptile(); | 6015 | RegenerateMaptile(); |
5729 | 6016 | ||
@@ -5874,7 +6161,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
5874 | return true; | 6161 | return true; |
5875 | } | 6162 | } |
5876 | 6163 | ||
5877 | /// <summary> | 6164 | public void StartTimerWatchdog() |
6165 | { | ||
6166 | m_timerWatchdog.Interval = 1000; | ||
6167 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
6168 | m_timerWatchdog.AutoReset = true; | ||
6169 | m_timerWatchdog.Start(); | ||
6170 | } | ||
6171 | |||
6172 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
6173 | { | ||
6174 | CheckHeartbeat(); | ||
6175 | } | ||
6176 | |||
5878 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 6177 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5879 | /// autopilot that moves an avatar to a sit target!. | 6178 | /// autopilot that moves an avatar to a sit target!. |
5880 | /// </summary> | 6179 | /// </summary> |
@@ -5953,6 +6252,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5953 | return m_SpawnPoint - 1; | 6252 | return m_SpawnPoint - 1; |
5954 | } | 6253 | } |
5955 | 6254 | ||
6255 | private void HandleGcCollect(string module, string[] args) | ||
6256 | { | ||
6257 | GC.Collect(); | ||
6258 | } | ||
6259 | |||
5956 | /// <summary> | 6260 | /// <summary> |
5957 | /// Wrappers to get physics modules retrieve assets. | 6261 | /// Wrappers to get physics modules retrieve assets. |
5958 | /// </summary> | 6262 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index c86f412..08e26c5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -144,7 +144,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
144 | 144 | ||
145 | protected ulong m_regionHandle; | 145 | protected ulong m_regionHandle; |
146 | protected string m_regionName; | 146 | protected string m_regionName; |
147 | protected RegionInfo m_regInfo; | ||
148 | 147 | ||
149 | public ITerrainChannel Heightmap; | 148 | public ITerrainChannel Heightmap; |
150 | 149 | ||
@@ -169,6 +168,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
169 | get { return m_permissions; } | 168 | get { return m_permissions; } |
170 | } | 169 | } |
171 | 170 | ||
171 | protected string m_datastore; | ||
172 | |||
172 | /* Used by the loadbalancer plugin on GForge */ | 173 | /* Used by the loadbalancer plugin on GForge */ |
173 | protected RegionStatus m_regStatus; | 174 | protected RegionStatus m_regStatus; |
174 | public RegionStatus RegionStatus | 175 | public RegionStatus RegionStatus |
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 77889fa..52f46f2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -194,8 +194,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | public delegate void SendCloseChildAgentDelegate(UUID agentID, ulong regionHandle); | ||
198 | |||
197 | /// <summary> | 199 | /// <summary> |
198 | /// Closes a child agent on a given region | 200 | /// This Closes child agents on neighboring regions |
201 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | ||
199 | /// </summary> | 202 | /// </summary> |
200 | protected void SendCloseChildAgent(UUID agentID, ulong regionHandle, string auth_token) | 203 | protected void SendCloseChildAgent(UUID agentID, ulong regionHandle, string auth_token) |
201 | { | 204 | { |
@@ -223,16 +226,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
223 | { | 226 | { |
224 | foreach (ulong handle in regionslst) | 227 | foreach (ulong handle in regionslst) |
225 | { | 228 | { |
226 | // We must take a copy here since handle is acts like a reference when used in an iterator. | ||
227 | // This leads to race conditions if directly passed to SendCloseChildAgent with more than one neighbour region. | ||
228 | ulong handleCopy = handle; | 229 | ulong handleCopy = handle; |
229 | Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy, auth_code); }); | 230 | Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy, auth_code); }); |
230 | } | 231 | } |
231 | } | 232 | } |
232 | 233 | ||
233 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) | 234 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) |
234 | { | 235 | { |
235 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); | 236 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); |
236 | } | 237 | } |
237 | } | 238 | } |
238 | } \ No newline at end of file | 239 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 1aecce5..b0f8991 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -41,6 +41,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
41 | { | 41 | { |
42 | public delegate void PhysicsCrash(); | 42 | public delegate void PhysicsCrash(); |
43 | 43 | ||
44 | public delegate void AttachToBackupDelegate(SceneObjectGroup sog); | ||
45 | |||
46 | public delegate void DetachFromBackupDelegate(SceneObjectGroup sog); | ||
47 | |||
48 | public delegate void ChangedBackupDelegate(SceneObjectGroup sog); | ||
49 | |||
44 | /// <summary> | 50 | /// <summary> |
45 | /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components | 51 | /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components |
46 | /// should be migrated out over time. | 52 | /// should be migrated out over time. |
@@ -54,11 +60,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
54 | protected internal event PhysicsCrash UnRecoverableError; | 60 | protected internal event PhysicsCrash UnRecoverableError; |
55 | private PhysicsCrash handlerPhysicsCrash = null; | 61 | private PhysicsCrash handlerPhysicsCrash = null; |
56 | 62 | ||
63 | public event AttachToBackupDelegate OnAttachToBackup; | ||
64 | public event DetachFromBackupDelegate OnDetachFromBackup; | ||
65 | public event ChangedBackupDelegate OnChangeBackup; | ||
66 | |||
57 | #endregion | 67 | #endregion |
58 | 68 | ||
59 | #region Fields | 69 | #region Fields |
60 | 70 | ||
61 | protected object m_presenceLock = new object(); | 71 | protected OpenMetaverse.ReaderWriterLockSlim m_scenePresencesLock = new OpenMetaverse.ReaderWriterLockSlim(); |
62 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); | 72 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); |
63 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); | 73 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); |
64 | 74 | ||
@@ -127,13 +137,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
127 | 137 | ||
128 | protected internal void Close() | 138 | protected internal void Close() |
129 | { | 139 | { |
130 | lock (m_presenceLock) | 140 | m_scenePresencesLock.EnterWriteLock(); |
141 | try | ||
131 | { | 142 | { |
132 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); | 143 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); |
133 | List<ScenePresence> newlist = new List<ScenePresence>(); | 144 | List<ScenePresence> newlist = new List<ScenePresence>(); |
134 | m_scenePresenceMap = newmap; | 145 | m_scenePresenceMap = newmap; |
135 | m_scenePresenceArray = newlist; | 146 | m_scenePresenceArray = newlist; |
136 | } | 147 | } |
148 | finally | ||
149 | { | ||
150 | m_scenePresencesLock.ExitWriteLock(); | ||
151 | } | ||
137 | 152 | ||
138 | lock (SceneObjectGroupsByFullID) | 153 | lock (SceneObjectGroupsByFullID) |
139 | SceneObjectGroupsByFullID.Clear(); | 154 | SceneObjectGroupsByFullID.Clear(); |
@@ -254,6 +269,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
254 | protected internal bool AddRestoredSceneObject( | 269 | protected internal bool AddRestoredSceneObject( |
255 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 270 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
256 | { | 271 | { |
272 | if (!m_parentScene.CombineRegions) | ||
273 | { | ||
274 | // KF: Check for out-of-region, move inside and make static. | ||
275 | Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, | ||
276 | sceneObject.RootPart.GroupPosition.Y, | ||
277 | sceneObject.RootPart.GroupPosition.Z); | ||
278 | if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || | ||
279 | npos.X > Constants.RegionSize || | ||
280 | npos.Y > Constants.RegionSize)) | ||
281 | { | ||
282 | if (npos.X < 0.0) npos.X = 1.0f; | ||
283 | if (npos.Y < 0.0) npos.Y = 1.0f; | ||
284 | if (npos.Z < 0.0) npos.Z = 0.0f; | ||
285 | if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; | ||
286 | if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; | ||
287 | |||
288 | foreach (SceneObjectPart part in sceneObject.Parts) | ||
289 | { | ||
290 | part.GroupPosition = npos; | ||
291 | } | ||
292 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
293 | sceneObject.RootPart.AngularVelocity = Vector3.Zero; | ||
294 | sceneObject.RootPart.Acceleration = Vector3.Zero; | ||
295 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
296 | } | ||
297 | } | ||
298 | |||
257 | if (attachToBackup && (!alreadyPersisted)) | 299 | if (attachToBackup && (!alreadyPersisted)) |
258 | { | 300 | { |
259 | sceneObject.ForceInventoryPersistence(); | 301 | sceneObject.ForceInventoryPersistence(); |
@@ -317,9 +359,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
317 | if (pa != null && pa.IsPhysical && vel != Vector3.Zero) | 359 | if (pa != null && pa.IsPhysical && vel != Vector3.Zero) |
318 | { | 360 | { |
319 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); | 361 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); |
320 | sceneObject.Velocity = vel; | ||
321 | } | 362 | } |
322 | 363 | ||
323 | return true; | 364 | return true; |
324 | } | 365 | } |
325 | 366 | ||
@@ -344,6 +385,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
344 | /// </returns> | 385 | /// </returns> |
345 | protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) | 386 | protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
346 | { | 387 | { |
388 | if (sceneObject == null) | ||
389 | { | ||
390 | m_log.ErrorFormat("[SCENEGRAPH]: Tried to add null scene object"); | ||
391 | return false; | ||
392 | } | ||
347 | if (sceneObject.UUID == UUID.Zero) | 393 | if (sceneObject.UUID == UUID.Zero) |
348 | { | 394 | { |
349 | m_log.ErrorFormat( | 395 | m_log.ErrorFormat( |
@@ -475,6 +521,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
475 | m_updateList[obj.UUID] = obj; | 521 | m_updateList[obj.UUID] = obj; |
476 | } | 522 | } |
477 | 523 | ||
524 | public void FireAttachToBackup(SceneObjectGroup obj) | ||
525 | { | ||
526 | if (OnAttachToBackup != null) | ||
527 | { | ||
528 | OnAttachToBackup(obj); | ||
529 | } | ||
530 | } | ||
531 | |||
532 | public void FireDetachFromBackup(SceneObjectGroup obj) | ||
533 | { | ||
534 | if (OnDetachFromBackup != null) | ||
535 | { | ||
536 | OnDetachFromBackup(obj); | ||
537 | } | ||
538 | } | ||
539 | |||
540 | public void FireChangeBackup(SceneObjectGroup obj) | ||
541 | { | ||
542 | if (OnChangeBackup != null) | ||
543 | { | ||
544 | OnChangeBackup(obj); | ||
545 | } | ||
546 | } | ||
547 | |||
478 | /// <summary> | 548 | /// <summary> |
479 | /// Process all pending updates | 549 | /// Process all pending updates |
480 | /// </summary> | 550 | /// </summary> |
@@ -566,7 +636,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
566 | 636 | ||
567 | Entities[presence.UUID] = presence; | 637 | Entities[presence.UUID] = presence; |
568 | 638 | ||
569 | lock (m_presenceLock) | 639 | m_scenePresencesLock.EnterWriteLock(); |
640 | try | ||
570 | { | 641 | { |
571 | m_numChildAgents++; | 642 | m_numChildAgents++; |
572 | 643 | ||
@@ -592,6 +663,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
592 | m_scenePresenceMap = newmap; | 663 | m_scenePresenceMap = newmap; |
593 | m_scenePresenceArray = newlist; | 664 | m_scenePresenceArray = newlist; |
594 | } | 665 | } |
666 | finally | ||
667 | { | ||
668 | m_scenePresencesLock.ExitWriteLock(); | ||
669 | } | ||
595 | 670 | ||
596 | return presence; | 671 | return presence; |
597 | } | 672 | } |
@@ -608,7 +683,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
608 | agentID); | 683 | agentID); |
609 | } | 684 | } |
610 | 685 | ||
611 | lock (m_presenceLock) | 686 | m_scenePresencesLock.EnterWriteLock(); |
687 | try | ||
612 | { | 688 | { |
613 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 689 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
614 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 690 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -630,6 +706,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
630 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); | 706 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); |
631 | } | 707 | } |
632 | } | 708 | } |
709 | finally | ||
710 | { | ||
711 | m_scenePresencesLock.ExitWriteLock(); | ||
712 | } | ||
633 | } | 713 | } |
634 | 714 | ||
635 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) | 715 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) |
@@ -1183,6 +1263,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
1183 | 1263 | ||
1184 | #region Client Event handlers | 1264 | #region Client Event handlers |
1185 | 1265 | ||
1266 | protected internal void ClientChangeObject(uint localID, object odata, IClientAPI remoteClient) | ||
1267 | { | ||
1268 | SceneObjectPart part = GetSceneObjectPart(localID); | ||
1269 | ObjectChangeData data = (ObjectChangeData)odata; | ||
1270 | |||
1271 | if (part != null) | ||
1272 | { | ||
1273 | SceneObjectGroup grp = part.ParentGroup; | ||
1274 | if (grp != null) | ||
1275 | { | ||
1276 | if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) | ||
1277 | { | ||
1278 | // These two are exceptions SL makes in the interpretation | ||
1279 | // of the change flags. Must check them here because otherwise | ||
1280 | // the group flag (see below) would be lost | ||
1281 | if (data.change == ObjectChangeType.groupS) | ||
1282 | data.change = ObjectChangeType.primS; | ||
1283 | if (data.change == ObjectChangeType.groupPS) | ||
1284 | data.change = ObjectChangeType.primPS; | ||
1285 | part.StoreUndoState(data.change); // lets test only saving what we changed | ||
1286 | grp.doChangeObject(part, (ObjectChangeData)data); | ||
1287 | } | ||
1288 | else | ||
1289 | { | ||
1290 | // Is this any kind of group operation? | ||
1291 | if ((data.change & ObjectChangeType.Group) != 0) | ||
1292 | { | ||
1293 | // Is a move and/or rotation requested? | ||
1294 | if ((data.change & (ObjectChangeType.Position | ObjectChangeType.Rotation)) != 0) | ||
1295 | { | ||
1296 | // Are we allowed to move it? | ||
1297 | if (m_parentScene.Permissions.CanMoveObject(grp.UUID, remoteClient.AgentId)) | ||
1298 | { | ||
1299 | // Strip all but move and rotation from request | ||
1300 | data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation); | ||
1301 | |||
1302 | part.StoreUndoState(data.change); | ||
1303 | grp.doChangeObject(part, (ObjectChangeData)data); | ||
1304 | } | ||
1305 | } | ||
1306 | } | ||
1307 | } | ||
1308 | } | ||
1309 | } | ||
1310 | } | ||
1311 | |||
1186 | /// <summary> | 1312 | /// <summary> |
1187 | /// Update the scale of an individual prim. | 1313 | /// Update the scale of an individual prim. |
1188 | /// </summary> | 1314 | /// </summary> |
@@ -1197,7 +1323,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1197 | { | 1323 | { |
1198 | if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) | 1324 | if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) |
1199 | { | 1325 | { |
1326 | bool physbuild = false; | ||
1327 | if (part.ParentGroup.RootPart.PhysActor != null) | ||
1328 | { | ||
1329 | part.ParentGroup.RootPart.PhysActor.Building = true; | ||
1330 | physbuild = true; | ||
1331 | } | ||
1332 | |||
1200 | part.Resize(scale); | 1333 | part.Resize(scale); |
1334 | |||
1335 | if (physbuild) | ||
1336 | part.ParentGroup.RootPart.PhysActor.Building = false; | ||
1201 | } | 1337 | } |
1202 | } | 1338 | } |
1203 | } | 1339 | } |
@@ -1209,7 +1345,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1209 | { | 1345 | { |
1210 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) | 1346 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) |
1211 | { | 1347 | { |
1348 | bool physbuild = false; | ||
1349 | if (group.RootPart.PhysActor != null) | ||
1350 | { | ||
1351 | group.RootPart.PhysActor.Building = true; | ||
1352 | physbuild = true; | ||
1353 | } | ||
1354 | |||
1212 | group.GroupResize(scale); | 1355 | group.GroupResize(scale); |
1356 | |||
1357 | if (physbuild) | ||
1358 | group.RootPart.PhysActor.Building = false; | ||
1213 | } | 1359 | } |
1214 | } | 1360 | } |
1215 | } | 1361 | } |
@@ -1337,8 +1483,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1337 | { | 1483 | { |
1338 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) | 1484 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) |
1339 | { | 1485 | { |
1340 | if (m_parentScene.AttachmentsModule != null) | 1486 | // Set the new attachment point data in the object |
1341 | m_parentScene.AttachmentsModule.UpdateAttachmentPosition(group, pos); | 1487 | byte attachmentPoint = group.GetAttachmentPoint(); |
1488 | group.UpdateGroupPosition(pos); | ||
1489 | group.IsAttachment = false; | ||
1490 | group.AbsolutePosition = group.RootPart.AttachedPos; | ||
1491 | group.AttachmentPoint = attachmentPoint; | ||
1492 | group.HasGroupChanged = true; | ||
1342 | } | 1493 | } |
1343 | else | 1494 | else |
1344 | { | 1495 | { |
@@ -1559,6 +1710,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1559 | { | 1710 | { |
1560 | part.Material = Convert.ToByte(material); | 1711 | part.Material = Convert.ToByte(material); |
1561 | group.HasGroupChanged = true; | 1712 | group.HasGroupChanged = true; |
1713 | remoteClient.SendPartPhysicsProprieties(part); | ||
1562 | } | 1714 | } |
1563 | } | 1715 | } |
1564 | } | 1716 | } |
@@ -1637,8 +1789,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1637 | return; | 1789 | return; |
1638 | 1790 | ||
1639 | Monitor.Enter(m_updateLock); | 1791 | Monitor.Enter(m_updateLock); |
1792 | |||
1640 | try | 1793 | try |
1641 | { | 1794 | { |
1795 | |||
1642 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); | 1796 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); |
1643 | 1797 | ||
1644 | // We do this in reverse to get the link order of the prims correct | 1798 | // We do this in reverse to get the link order of the prims correct |
@@ -1653,9 +1807,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1653 | // Make sure no child prim is set for sale | 1807 | // Make sure no child prim is set for sale |
1654 | // So that, on delink, no prims are unwittingly | 1808 | // So that, on delink, no prims are unwittingly |
1655 | // left for sale and sold off | 1809 | // left for sale and sold off |
1656 | child.RootPart.ObjectSaleType = 0; | 1810 | |
1657 | child.RootPart.SalePrice = 10; | 1811 | if (child != null) |
1658 | childGroups.Add(child); | 1812 | { |
1813 | child.RootPart.ObjectSaleType = 0; | ||
1814 | child.RootPart.SalePrice = 10; | ||
1815 | childGroups.Add(child); | ||
1816 | } | ||
1659 | } | 1817 | } |
1660 | 1818 | ||
1661 | foreach (SceneObjectGroup child in childGroups) | 1819 | foreach (SceneObjectGroup child in childGroups) |
@@ -1684,6 +1842,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1684 | } | 1842 | } |
1685 | finally | 1843 | finally |
1686 | { | 1844 | { |
1845 | lock (SceneObjectGroupsByLocalPartID) | ||
1846 | { | ||
1847 | foreach (SceneObjectPart part in parentGroup.Parts) | ||
1848 | SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; | ||
1849 | } | ||
1850 | |||
1851 | parentGroup.AdjustChildPrimPermissions(); | ||
1852 | parentGroup.HasGroupChanged = true; | ||
1853 | parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); | ||
1854 | parentGroup.ScheduleGroupForFullUpdate(); | ||
1687 | Monitor.Exit(m_updateLock); | 1855 | Monitor.Exit(m_updateLock); |
1688 | } | 1856 | } |
1689 | } | 1857 | } |
@@ -1725,21 +1893,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
1725 | 1893 | ||
1726 | SceneObjectGroup group = part.ParentGroup; | 1894 | SceneObjectGroup group = part.ParentGroup; |
1727 | if (!affectedGroups.Contains(group)) | 1895 | if (!affectedGroups.Contains(group)) |
1896 | { | ||
1728 | affectedGroups.Add(group); | 1897 | affectedGroups.Add(group); |
1898 | } | ||
1729 | } | 1899 | } |
1730 | } | 1900 | } |
1731 | } | 1901 | } |
1732 | 1902 | ||
1733 | foreach (SceneObjectPart child in childParts) | 1903 | if (childParts.Count > 0) |
1734 | { | 1904 | { |
1735 | // Unlink all child parts from their groups | 1905 | foreach (SceneObjectPart child in childParts) |
1736 | // | 1906 | { |
1737 | child.ParentGroup.DelinkFromGroup(child, true); | 1907 | // Unlink all child parts from their groups |
1738 | 1908 | // | |
1739 | // These are not in affected groups and will not be | 1909 | child.ParentGroup.DelinkFromGroup(child, true); |
1740 | // handled further. Do the honors here. | 1910 | child.ParentGroup.HasGroupChanged = true; |
1741 | child.ParentGroup.HasGroupChanged = true; | 1911 | child.ParentGroup.ScheduleGroupForFullUpdate(); |
1742 | child.ParentGroup.ScheduleGroupForFullUpdate(); | 1912 | } |
1743 | } | 1913 | } |
1744 | 1914 | ||
1745 | foreach (SceneObjectPart root in rootParts) | 1915 | foreach (SceneObjectPart root in rootParts) |
@@ -1753,52 +1923,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1753 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); | 1923 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); |
1754 | int numChildren = newSet.Count; | 1924 | int numChildren = newSet.Count; |
1755 | 1925 | ||
1926 | if (numChildren == 1) | ||
1927 | break; | ||
1928 | |||
1756 | // If there are prims left in a link set, but the root is | 1929 | // If there are prims left in a link set, but the root is |
1757 | // slated for unlink, we need to do this | 1930 | // slated for unlink, we need to do this |
1931 | // Unlink the remaining set | ||
1758 | // | 1932 | // |
1759 | if (numChildren != 1) | 1933 | bool sendEventsToRemainder = true; |
1760 | { | 1934 | if (numChildren > 1) |
1761 | // Unlink the remaining set | 1935 | sendEventsToRemainder = false; |
1762 | // | ||
1763 | bool sendEventsToRemainder = true; | ||
1764 | if (numChildren > 1) | ||
1765 | sendEventsToRemainder = false; | ||
1766 | 1936 | ||
1767 | foreach (SceneObjectPart p in newSet) | 1937 | foreach (SceneObjectPart p in newSet) |
1938 | { | ||
1939 | if (p != group.RootPart) | ||
1768 | { | 1940 | { |
1769 | if (p != group.RootPart) | 1941 | group.DelinkFromGroup(p, sendEventsToRemainder); |
1770 | group.DelinkFromGroup(p, sendEventsToRemainder); | 1942 | if (numChildren > 2) |
1943 | { | ||
1944 | } | ||
1945 | else | ||
1946 | { | ||
1947 | p.ParentGroup.HasGroupChanged = true; | ||
1948 | p.ParentGroup.ScheduleGroupForFullUpdate(); | ||
1949 | } | ||
1771 | } | 1950 | } |
1951 | } | ||
1772 | 1952 | ||
1773 | // If there is more than one prim remaining, we | 1953 | // If there is more than one prim remaining, we |
1774 | // need to re-link | 1954 | // need to re-link |
1955 | // | ||
1956 | if (numChildren > 2) | ||
1957 | { | ||
1958 | // Remove old root | ||
1775 | // | 1959 | // |
1776 | if (numChildren > 2) | 1960 | if (newSet.Contains(root)) |
1961 | newSet.Remove(root); | ||
1962 | |||
1963 | // Preserve link ordering | ||
1964 | // | ||
1965 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) | ||
1777 | { | 1966 | { |
1778 | // Remove old root | 1967 | return a.LinkNum.CompareTo(b.LinkNum); |
1779 | // | 1968 | }); |
1780 | if (newSet.Contains(root)) | ||
1781 | newSet.Remove(root); | ||
1782 | |||
1783 | // Preserve link ordering | ||
1784 | // | ||
1785 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) | ||
1786 | { | ||
1787 | return a.LinkNum.CompareTo(b.LinkNum); | ||
1788 | }); | ||
1789 | 1969 | ||
1790 | // Determine new root | 1970 | // Determine new root |
1791 | // | 1971 | // |
1792 | SceneObjectPart newRoot = newSet[0]; | 1972 | SceneObjectPart newRoot = newSet[0]; |
1793 | newSet.RemoveAt(0); | 1973 | newSet.RemoveAt(0); |
1794 | 1974 | ||
1795 | foreach (SceneObjectPart newChild in newSet) | 1975 | foreach (SceneObjectPart newChild in newSet) |
1796 | newChild.ClearUpdateSchedule(); | 1976 | newChild.ClearUpdateSchedule(); |
1797 | 1977 | ||
1798 | LinkObjects(newRoot, newSet); | 1978 | LinkObjects(newRoot, newSet); |
1799 | if (!affectedGroups.Contains(newRoot.ParentGroup)) | 1979 | if (!affectedGroups.Contains(newRoot.ParentGroup)) |
1800 | affectedGroups.Add(newRoot.ParentGroup); | 1980 | affectedGroups.Add(newRoot.ParentGroup); |
1801 | } | ||
1802 | } | 1981 | } |
1803 | } | 1982 | } |
1804 | 1983 | ||
@@ -1806,6 +1985,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1806 | // | 1985 | // |
1807 | foreach (SceneObjectGroup g in affectedGroups) | 1986 | foreach (SceneObjectGroup g in affectedGroups) |
1808 | { | 1987 | { |
1988 | // Child prims that have been unlinked and deleted will | ||
1989 | // return unless the root is deleted. This will remove them | ||
1990 | // from the database. They will be rewritten immediately, | ||
1991 | // minus the rows for the unlinked child prims. | ||
1992 | g.AdjustChildPrimPermissions(); | ||
1993 | m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); | ||
1809 | g.TriggerScriptChangedEvent(Changed.LINK); | 1994 | g.TriggerScriptChangedEvent(Changed.LINK); |
1810 | g.HasGroupChanged = true; // Persist | 1995 | g.HasGroupChanged = true; // Persist |
1811 | g.ScheduleGroupForFullUpdate(); | 1996 | g.ScheduleGroupForFullUpdate(); |
@@ -1879,108 +2064,96 @@ namespace OpenSim.Region.Framework.Scenes | |||
1879 | /// <param name="GroupID"></param> | 2064 | /// <param name="GroupID"></param> |
1880 | /// <param name="rot"></param> | 2065 | /// <param name="rot"></param> |
1881 | /// <returns>null if duplication fails, otherwise the duplicated object</returns> | 2066 | /// <returns>null if duplication fails, otherwise the duplicated object</returns> |
1882 | public SceneObjectGroup DuplicateObject( | 2067 | /// <summary> |
1883 | uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) | 2068 | public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) |
1884 | { | 2069 | { |
1885 | Monitor.Enter(m_updateLock); | 2070 | // m_log.DebugFormat( |
2071 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | ||
2072 | // originalPrimID, offset, AgentID); | ||
1886 | 2073 | ||
1887 | try | 2074 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); |
2075 | if (original != null) | ||
1888 | { | 2076 | { |
1889 | // m_log.DebugFormat( | 2077 | if (m_parentScene.Permissions.CanDuplicateObject( |
1890 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | 2078 | original.PrimCount, original.UUID, AgentID, original.AbsolutePosition)) |
1891 | // originalPrimID, offset, AgentID); | ||
1892 | |||
1893 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); | ||
1894 | if (original == null) | ||
1895 | { | 2079 | { |
1896 | m_log.WarnFormat( | 2080 | SceneObjectGroup copy = original.Copy(true); |
1897 | "[SCENEGRAPH]: Attempt to duplicate nonexistant prim id {0} by {1}", originalPrimID, AgentID); | 2081 | copy.AbsolutePosition = copy.AbsolutePosition + offset; |
1898 | 2082 | ||
1899 | return null; | 2083 | if (original.OwnerID != AgentID) |
1900 | } | 2084 | { |
2085 | copy.SetOwnerId(AgentID); | ||
2086 | copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); | ||
1901 | 2087 | ||
1902 | if (!m_parentScene.Permissions.CanDuplicateObject( | 2088 | SceneObjectPart[] partList = copy.Parts; |
1903 | original.PrimCount, original.UUID, AgentID, original.AbsolutePosition)) | 2089 | |
1904 | return null; | 2090 | if (m_parentScene.Permissions.PropagatePermissions()) |
2091 | { | ||
2092 | foreach (SceneObjectPart child in partList) | ||
2093 | { | ||
2094 | child.Inventory.ChangeInventoryOwner(AgentID); | ||
2095 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
2096 | child.ApplyNextOwnerPermissions(); | ||
2097 | } | ||
2098 | } | ||
2099 | } | ||
1905 | 2100 | ||
1906 | SceneObjectGroup copy = original.Copy(true); | 2101 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() |
1907 | copy.AbsolutePosition = copy.AbsolutePosition + offset; | 2102 | Entities.Add(copy); |
1908 | 2103 | ||
1909 | if (original.OwnerID != AgentID) | 2104 | lock (SceneObjectGroupsByFullID) |
1910 | { | 2105 | SceneObjectGroupsByFullID[copy.UUID] = copy; |
1911 | copy.SetOwnerId(AgentID); | ||
1912 | copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); | ||
1913 | 2106 | ||
1914 | SceneObjectPart[] partList = copy.Parts; | 2107 | SceneObjectPart[] children = copy.Parts; |
1915 | 2108 | ||
1916 | if (m_parentScene.Permissions.PropagatePermissions()) | 2109 | lock (SceneObjectGroupsByFullPartID) |
1917 | { | 2110 | { |
1918 | foreach (SceneObjectPart child in partList) | 2111 | SceneObjectGroupsByFullPartID[copy.UUID] = copy; |
1919 | { | 2112 | foreach (SceneObjectPart part in children) |
1920 | child.Inventory.ChangeInventoryOwner(AgentID); | 2113 | SceneObjectGroupsByFullPartID[part.UUID] = copy; |
1921 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
1922 | child.ApplyNextOwnerPermissions(); | ||
1923 | } | ||
1924 | } | 2114 | } |
1925 | 2115 | ||
1926 | copy.RootPart.ObjectSaleType = 0; | 2116 | lock (SceneObjectGroupsByLocalPartID) |
1927 | copy.RootPart.SalePrice = 10; | 2117 | { |
1928 | } | 2118 | SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; |
2119 | foreach (SceneObjectPart part in children) | ||
2120 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; | ||
2121 | } | ||
2122 | // PROBABLE END OF FIXME | ||
1929 | 2123 | ||
1930 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() | 2124 | // Since we copy from a source group that is in selected |
1931 | Entities.Add(copy); | 2125 | // state, but the copy is shown deselected in the viewer, |
1932 | 2126 | // We need to clear the selection flag here, else that | |
1933 | lock (SceneObjectGroupsByFullID) | 2127 | // prim never gets persisted at all. The client doesn't |
1934 | SceneObjectGroupsByFullID[copy.UUID] = copy; | 2128 | // think it's selected, so it will never send a deselect... |
1935 | 2129 | copy.IsSelected = false; | |
1936 | SceneObjectPart[] children = copy.Parts; | 2130 | |
1937 | 2131 | m_numPrim += copy.Parts.Length; | |
1938 | lock (SceneObjectGroupsByFullPartID) | 2132 | |
1939 | { | 2133 | if (rot != Quaternion.Identity) |
1940 | SceneObjectGroupsByFullPartID[copy.UUID] = copy; | 2134 | { |
1941 | foreach (SceneObjectPart part in children) | 2135 | copy.UpdateGroupRotationR(rot); |
1942 | SceneObjectGroupsByFullPartID[part.UUID] = copy; | 2136 | } |
1943 | } | ||
1944 | |||
1945 | lock (SceneObjectGroupsByLocalPartID) | ||
1946 | { | ||
1947 | SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; | ||
1948 | foreach (SceneObjectPart part in children) | ||
1949 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; | ||
1950 | } | ||
1951 | // PROBABLE END OF FIXME | ||
1952 | |||
1953 | // Since we copy from a source group that is in selected | ||
1954 | // state, but the copy is shown deselected in the viewer, | ||
1955 | // We need to clear the selection flag here, else that | ||
1956 | // prim never gets persisted at all. The client doesn't | ||
1957 | // think it's selected, so it will never send a deselect... | ||
1958 | copy.IsSelected = false; | ||
1959 | |||
1960 | m_numPrim += copy.Parts.Length; | ||
1961 | |||
1962 | if (rot != Quaternion.Identity) | ||
1963 | { | ||
1964 | copy.UpdateGroupRotationR(rot); | ||
1965 | } | ||
1966 | 2137 | ||
1967 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); | 2138 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); |
1968 | copy.HasGroupChanged = true; | 2139 | copy.HasGroupChanged = true; |
1969 | copy.ScheduleGroupForFullUpdate(); | 2140 | copy.ScheduleGroupForFullUpdate(); |
1970 | copy.ResumeScripts(); | 2141 | copy.ResumeScripts(); |
1971 | 2142 | ||
1972 | // required for physics to update it's position | 2143 | // required for physics to update it's position |
1973 | copy.AbsolutePosition = copy.AbsolutePosition; | 2144 | copy.AbsolutePosition = copy.AbsolutePosition; |
1974 | 2145 | ||
1975 | return copy; | 2146 | return copy; |
2147 | } | ||
1976 | } | 2148 | } |
1977 | finally | 2149 | else |
1978 | { | 2150 | { |
1979 | Monitor.Exit(m_updateLock); | 2151 | m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); |
1980 | } | 2152 | } |
2153 | |||
2154 | return null; | ||
1981 | } | 2155 | } |
1982 | 2156 | ||
1983 | /// <summary> | ||
1984 | /// Calculates the distance between two Vector3s | 2157 | /// Calculates the distance between two Vector3s |
1985 | /// </summary> | 2158 | /// </summary> |
1986 | /// <param name="v1"></param> | 2159 | /// <param name="v1"></param> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 28f7896..c5c083a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -99,11 +99,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | private readonly List<Scene> m_localScenes = new List<Scene>(); | 102 | private readonly DoubleDictionary<UUID, string, Scene> m_localScenes = new DoubleDictionary<UUID, string, Scene>(); |
103 | 103 | ||
104 | public List<Scene> Scenes | 104 | public List<Scene> Scenes |
105 | { | 105 | { |
106 | get { return new List<Scene>(m_localScenes); } | 106 | get { return new List<Scene>(m_localScenes.FindAll(delegate(Scene s) { return true; })); } |
107 | } | 107 | } |
108 | 108 | ||
109 | /// <summary> | 109 | /// <summary> |
@@ -120,13 +120,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
120 | { | 120 | { |
121 | if (CurrentScene == null) | 121 | if (CurrentScene == null) |
122 | { | 122 | { |
123 | lock (m_localScenes) | 123 | List<Scene> sceneList = Scenes; |
124 | { | 124 | if (sceneList.Count == 0) |
125 | if (m_localScenes.Count > 0) | 125 | return null; |
126 | return m_localScenes[0]; | 126 | return sceneList[0]; |
127 | else | ||
128 | return null; | ||
129 | } | ||
130 | } | 127 | } |
131 | else | 128 | else |
132 | { | 129 | { |
@@ -138,41 +135,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
138 | public SceneManager() | 135 | public SceneManager() |
139 | { | 136 | { |
140 | m_instance = this; | 137 | m_instance = this; |
141 | m_localScenes = new List<Scene>(); | 138 | m_localScenes = new DoubleDictionary<UUID, string, Scene>(); |
142 | } | 139 | } |
143 | 140 | ||
144 | public void Close() | 141 | public void Close() |
145 | { | 142 | { |
143 | List<Scene> localScenes = null; | ||
144 | |||
146 | lock (m_localScenes) | 145 | lock (m_localScenes) |
147 | { | 146 | { |
148 | for (int i = 0; i < m_localScenes.Count; i++) | 147 | localScenes = Scenes; |
149 | { | 148 | } |
150 | m_localScenes[i].Close(); | 149 | |
151 | } | 150 | for (int i = 0; i < localScenes.Count; i++) |
151 | { | ||
152 | localScenes[i].Close(); | ||
152 | } | 153 | } |
153 | } | 154 | } |
154 | 155 | ||
155 | public void Close(Scene cscene) | 156 | public void Close(Scene cscene) |
156 | { | 157 | { |
157 | lock (m_localScenes) | 158 | if (!m_localScenes.ContainsKey(cscene.RegionInfo.RegionID)) |
158 | { | 159 | return; |
159 | if (m_localScenes.Contains(cscene)) | 160 | cscene.Close(); |
160 | { | ||
161 | for (int i = 0; i < m_localScenes.Count; i++) | ||
162 | { | ||
163 | if (m_localScenes[i].Equals(cscene)) | ||
164 | { | ||
165 | m_localScenes[i].Close(); | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | } | 161 | } |
171 | 162 | ||
172 | public void Add(Scene scene) | 163 | public void Add(Scene scene) |
173 | { | 164 | { |
174 | lock (m_localScenes) | 165 | lock (m_localScenes) |
175 | m_localScenes.Add(scene); | 166 | m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene); |
176 | 167 | ||
177 | scene.OnRestart += HandleRestart; | 168 | scene.OnRestart += HandleRestart; |
178 | scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange; | 169 | scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange; |
@@ -184,15 +175,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
184 | 175 | ||
185 | lock (m_localScenes) | 176 | lock (m_localScenes) |
186 | { | 177 | { |
187 | for (int i = 0; i < m_localScenes.Count; i++) | 178 | m_localScenes.TryGetValue(rdata.RegionID, out restartedScene); |
188 | { | 179 | m_localScenes.Remove(rdata.RegionID); |
189 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) | ||
190 | { | ||
191 | restartedScene = m_localScenes[i]; | ||
192 | m_localScenes.RemoveAt(i); | ||
193 | break; | ||
194 | } | ||
195 | } | ||
196 | } | 180 | } |
197 | 181 | ||
198 | // If the currently selected scene has been restarted, then we can't reselect here since we the scene | 182 | // If the currently selected scene has been restarted, then we can't reselect here since we the scene |
@@ -207,39 +191,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
207 | private void HandleRegionReadyStatusChange(IScene scene) | 191 | private void HandleRegionReadyStatusChange(IScene scene) |
208 | { | 192 | { |
209 | lock (m_localScenes) | 193 | lock (m_localScenes) |
210 | AllRegionsReady = m_localScenes.TrueForAll(s => s.Ready); | 194 | AllRegionsReady = m_localScenes.FindAll(s => !s.Ready).Count == 0; |
211 | } | 195 | } |
212 | 196 | ||
213 | public void SendSimOnlineNotification(ulong regionHandle) | 197 | public void SendSimOnlineNotification(ulong regionHandle) |
214 | { | 198 | { |
215 | RegionInfo Result = null; | 199 | RegionInfo Result = null; |
216 | 200 | ||
217 | lock (m_localScenes) | 201 | Scene s = m_localScenes.FindValue(delegate(Scene x) |
218 | { | ||
219 | for (int i = 0; i < m_localScenes.Count; i++) | ||
220 | { | ||
221 | if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) | ||
222 | { | 202 | { |
223 | // Inform other regions to tell their avatar about me | 203 | if (x.RegionInfo.RegionHandle == regionHandle) |
224 | Result = m_localScenes[i].RegionInfo; | 204 | return true; |
225 | } | 205 | return false; |
226 | } | 206 | }); |
207 | |||
208 | if (s != null) | ||
209 | { | ||
210 | List<Scene> sceneList = Scenes; | ||
227 | 211 | ||
228 | if (Result != null) | 212 | for (int i = 0; i < sceneList.Count; i++) |
229 | { | 213 | { |
230 | for (int i = 0; i < m_localScenes.Count; i++) | 214 | if (sceneList[i]!= s) |
231 | { | 215 | { |
232 | if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) | 216 | // Inform other regions to tell their avatar about me |
233 | { | 217 | //sceneList[i].OtherRegionUp(Result); |
234 | // Inform other regions to tell their avatar about me | ||
235 | //m_localScenes[i].OtherRegionUp(Result); | ||
236 | } | ||
237 | } | 218 | } |
238 | } | 219 | } |
239 | else | 220 | } |
240 | { | 221 | else |
241 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); | 222 | { |
242 | } | 223 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); |
243 | } | 224 | } |
244 | } | 225 | } |
245 | 226 | ||
@@ -368,16 +349,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
368 | } | 349 | } |
369 | else | 350 | else |
370 | { | 351 | { |
371 | lock (m_localScenes) | 352 | Scene s; |
353 | |||
354 | if (m_localScenes.TryGetValue(regionName, out s)) | ||
372 | { | 355 | { |
373 | foreach (Scene scene in m_localScenes) | 356 | CurrentScene = s; |
374 | { | 357 | return true; |
375 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) | ||
376 | { | ||
377 | CurrentScene = scene; | ||
378 | return true; | ||
379 | } | ||
380 | } | ||
381 | } | 358 | } |
382 | 359 | ||
383 | return false; | 360 | return false; |
@@ -386,18 +363,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
386 | 363 | ||
387 | public bool TrySetCurrentScene(UUID regionID) | 364 | public bool TrySetCurrentScene(UUID regionID) |
388 | { | 365 | { |
389 | m_log.Debug("Searching for Region: '" + regionID + "'"); | 366 | // m_log.Debug("Searching for Region: '" + regionID + "'"); |
390 | 367 | ||
391 | lock (m_localScenes) | 368 | Scene s; |
369 | |||
370 | if (m_localScenes.TryGetValue(regionID, out s)) | ||
392 | { | 371 | { |
393 | foreach (Scene scene in m_localScenes) | 372 | CurrentScene = s; |
394 | { | 373 | return true; |
395 | if (scene.RegionInfo.RegionID == regionID) | ||
396 | { | ||
397 | CurrentScene = scene; | ||
398 | return true; | ||
399 | } | ||
400 | } | ||
401 | } | 374 | } |
402 | 375 | ||
403 | return false; | 376 | return false; |
@@ -405,52 +378,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
405 | 378 | ||
406 | public bool TryGetScene(string regionName, out Scene scene) | 379 | public bool TryGetScene(string regionName, out Scene scene) |
407 | { | 380 | { |
408 | lock (m_localScenes) | 381 | return m_localScenes.TryGetValue(regionName, out scene); |
409 | { | ||
410 | foreach (Scene mscene in m_localScenes) | ||
411 | { | ||
412 | if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) | ||
413 | { | ||
414 | scene = mscene; | ||
415 | return true; | ||
416 | } | ||
417 | } | ||
418 | } | ||
419 | |||
420 | scene = null; | ||
421 | return false; | ||
422 | } | 382 | } |
423 | 383 | ||
424 | public bool TryGetScene(UUID regionID, out Scene scene) | 384 | public bool TryGetScene(UUID regionID, out Scene scene) |
425 | { | 385 | { |
426 | lock (m_localScenes) | 386 | return m_localScenes.TryGetValue(regionID, out scene); |
427 | { | ||
428 | foreach (Scene mscene in m_localScenes) | ||
429 | { | ||
430 | if (mscene.RegionInfo.RegionID == regionID) | ||
431 | { | ||
432 | scene = mscene; | ||
433 | return true; | ||
434 | } | ||
435 | } | ||
436 | } | ||
437 | |||
438 | scene = null; | ||
439 | return false; | ||
440 | } | 387 | } |
441 | 388 | ||
442 | public bool TryGetScene(uint locX, uint locY, out Scene scene) | 389 | public bool TryGetScene(uint locX, uint locY, out Scene scene) |
443 | { | 390 | { |
444 | lock (m_localScenes) | 391 | List<Scene> sceneList = Scenes; |
392 | foreach (Scene mscene in sceneList) | ||
445 | { | 393 | { |
446 | foreach (Scene mscene in m_localScenes) | 394 | if (mscene.RegionInfo.RegionLocX == locX && |
395 | mscene.RegionInfo.RegionLocY == locY) | ||
447 | { | 396 | { |
448 | if (mscene.RegionInfo.RegionLocX == locX && | 397 | scene = mscene; |
449 | mscene.RegionInfo.RegionLocY == locY) | 398 | return true; |
450 | { | ||
451 | scene = mscene; | ||
452 | return true; | ||
453 | } | ||
454 | } | 399 | } |
455 | } | 400 | } |
456 | 401 | ||
@@ -460,16 +405,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
460 | 405 | ||
461 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) | 406 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) |
462 | { | 407 | { |
463 | lock (m_localScenes) | 408 | List<Scene> sceneList = Scenes; |
409 | foreach (Scene mscene in sceneList) | ||
464 | { | 410 | { |
465 | foreach (Scene mscene in m_localScenes) | 411 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && |
412 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | ||
466 | { | 413 | { |
467 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && | 414 | scene = mscene; |
468 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | 415 | return true; |
469 | { | ||
470 | scene = mscene; | ||
471 | return true; | ||
472 | } | ||
473 | } | 416 | } |
474 | } | 417 | } |
475 | 418 | ||
@@ -511,15 +454,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
511 | 454 | ||
512 | public RegionInfo GetRegionInfo(UUID regionID) | 455 | public RegionInfo GetRegionInfo(UUID regionID) |
513 | { | 456 | { |
514 | lock (m_localScenes) | 457 | Scene s; |
458 | if (m_localScenes.TryGetValue(regionID, out s)) | ||
515 | { | 459 | { |
516 | foreach (Scene scene in m_localScenes) | 460 | return s.RegionInfo; |
517 | { | ||
518 | if (scene.RegionInfo.RegionID == regionID) | ||
519 | { | ||
520 | return scene.RegionInfo; | ||
521 | } | ||
522 | } | ||
523 | } | 461 | } |
524 | 462 | ||
525 | return null; | 463 | return null; |
@@ -537,14 +475,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
537 | 475 | ||
538 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) | 476 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) |
539 | { | 477 | { |
540 | lock (m_localScenes) | 478 | List<Scene> sceneList = Scenes; |
479 | foreach (Scene scene in sceneList) | ||
541 | { | 480 | { |
542 | foreach (Scene scene in m_localScenes) | 481 | if (scene.TryGetScenePresence(avatarId, out avatar)) |
543 | { | 482 | { |
544 | if (scene.TryGetScenePresence(avatarId, out avatar)) | 483 | return true; |
545 | { | ||
546 | return true; | ||
547 | } | ||
548 | } | 484 | } |
549 | } | 485 | } |
550 | 486 | ||
@@ -554,15 +490,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
554 | 490 | ||
555 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) | 491 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) |
556 | { | 492 | { |
557 | lock (m_localScenes) | 493 | List<Scene> sceneList = Scenes; |
494 | foreach (Scene scene in sceneList) | ||
558 | { | 495 | { |
559 | foreach (Scene scene in m_localScenes) | 496 | avatar = scene.GetScenePresence(avatarId); |
560 | { | ||
561 | avatar = scene.GetScenePresence(avatarId); | ||
562 | 497 | ||
563 | if (avatar != null && !avatar.IsChildAgent) | 498 | if (avatar != null && !avatar.IsChildAgent) |
564 | return true; | 499 | return true; |
565 | } | ||
566 | } | 500 | } |
567 | 501 | ||
568 | avatar = null; | 502 | avatar = null; |
@@ -572,21 +506,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
572 | public void CloseScene(Scene scene) | 506 | public void CloseScene(Scene scene) |
573 | { | 507 | { |
574 | lock (m_localScenes) | 508 | lock (m_localScenes) |
575 | m_localScenes.Remove(scene); | 509 | m_localScenes.Remove(scene.RegionInfo.RegionID); |
576 | 510 | ||
577 | scene.Close(); | 511 | scene.Close(); |
578 | } | 512 | } |
579 | 513 | ||
580 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 514 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
581 | { | 515 | { |
582 | lock (m_localScenes) | 516 | List<Scene> sceneList = Scenes; |
517 | foreach (Scene scene in sceneList) | ||
583 | { | 518 | { |
584 | foreach (Scene scene in m_localScenes) | 519 | if (scene.TryGetAvatarByName(avatarName, out avatar)) |
585 | { | 520 | { |
586 | if (scene.TryGetAvatarByName(avatarName, out avatar)) | 521 | return true; |
587 | { | ||
588 | return true; | ||
589 | } | ||
590 | } | 522 | } |
591 | } | 523 | } |
592 | 524 | ||
@@ -596,14 +528,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
596 | 528 | ||
597 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) | 529 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) |
598 | { | 530 | { |
599 | lock (m_localScenes) | 531 | List<Scene> sceneList = Scenes; |
532 | foreach (Scene scene in sceneList) | ||
600 | { | 533 | { |
601 | foreach (Scene scene in m_localScenes) | 534 | sp = scene.GetScenePresence(firstName, lastName); |
602 | { | 535 | if (sp != null && !sp.IsChildAgent) |
603 | sp = scene.GetScenePresence(firstName, lastName); | 536 | return true; |
604 | if (sp != null && !sp.IsChildAgent) | ||
605 | return true; | ||
606 | } | ||
607 | } | 537 | } |
608 | 538 | ||
609 | sp = null; | 539 | sp = null; |
@@ -612,8 +542,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
612 | 542 | ||
613 | public void ForEachScene(Action<Scene> action) | 543 | public void ForEachScene(Action<Scene> action) |
614 | { | 544 | { |
615 | lock (m_localScenes) | 545 | List<Scene> sceneList = Scenes; |
616 | m_localScenes.ForEach(action); | 546 | sceneList.ForEach(action); |
617 | } | 547 | } |
618 | } | 548 | } |
619 | } | 549 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 527ca35..8c50a81 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -88,10 +88,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
88 | /// <summary> | 88 | /// <summary> |
89 | /// Stop and remove the scripts contained in all the prims in this group | 89 | /// Stop and remove the scripts contained in all the prims in this group |
90 | /// </summary> | 90 | /// </summary> |
91 | /// <param name="sceneObjectBeingDeleted"> | ||
92 | /// Should be true if these scripts are being removed because the scene | ||
93 | /// object is being deleted. This will prevent spurious updates to the client. | ||
94 | /// </param> | ||
95 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 91 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
96 | { | 92 | { |
97 | SceneObjectPart[] parts = m_parts.GetArray(); | 93 | SceneObjectPart[] parts = m_parts.GetArray(); |
@@ -254,6 +250,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
254 | 250 | ||
255 | public uint GetEffectivePermissions() | 251 | public uint GetEffectivePermissions() |
256 | { | 252 | { |
253 | return GetEffectivePermissions(false); | ||
254 | } | ||
255 | |||
256 | public uint GetEffectivePermissions(bool useBase) | ||
257 | { | ||
257 | uint perms=(uint)(PermissionMask.Modify | | 258 | uint perms=(uint)(PermissionMask.Modify | |
258 | PermissionMask.Copy | | 259 | PermissionMask.Copy | |
259 | PermissionMask.Move | | 260 | PermissionMask.Move | |
@@ -265,7 +266,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | for (int i = 0; i < parts.Length; i++) | 266 | for (int i = 0; i < parts.Length; i++) |
266 | { | 267 | { |
267 | SceneObjectPart part = parts[i]; | 268 | SceneObjectPart part = parts[i]; |
268 | ownerMask &= part.OwnerMask; | 269 | if (useBase) |
270 | ownerMask &= part.BaseMask; | ||
271 | else | ||
272 | ownerMask &= part.OwnerMask; | ||
269 | perms &= part.Inventory.MaskEffectivePermissions(); | 273 | perms &= part.Inventory.MaskEffectivePermissions(); |
270 | } | 274 | } |
271 | 275 | ||
@@ -407,6 +411,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
407 | 411 | ||
408 | public void ResumeScripts() | 412 | public void ResumeScripts() |
409 | { | 413 | { |
414 | if (m_scene.RegionInfo.RegionSettings.DisableScripts) | ||
415 | return; | ||
416 | |||
410 | SceneObjectPart[] parts = m_parts.GetArray(); | 417 | SceneObjectPart[] parts = m_parts.GetArray(); |
411 | for (int i = 0; i < parts.Length; i++) | 418 | for (int i = 0; i < parts.Length; i++) |
412 | parts[i].Inventory.ResumeScripts(); | 419 | parts[i].Inventory.ResumeScripts(); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index a2e4417..9db34fd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -24,12 +24,13 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.ComponentModel; | 29 | using System.ComponentModel; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Drawing; | 31 | using System.Drawing; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Diagnostics; | ||
33 | using System.Linq; | 34 | using System.Linq; |
34 | using System.Threading; | 35 | using System.Threading; |
35 | using System.Xml; | 36 | using System.Xml; |
@@ -44,6 +45,7 @@ using PermissionMask = OpenSim.Framework.PermissionMask; | |||
44 | 45 | ||
45 | namespace OpenSim.Region.Framework.Scenes | 46 | namespace OpenSim.Region.Framework.Scenes |
46 | { | 47 | { |
48 | |||
47 | [Flags] | 49 | [Flags] |
48 | public enum scriptEvents | 50 | public enum scriptEvents |
49 | { | 51 | { |
@@ -78,14 +80,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
78 | object_rez = 4194304 | 80 | object_rez = 4194304 |
79 | } | 81 | } |
80 | 82 | ||
81 | struct scriptPosTarget | 83 | public struct scriptPosTarget |
82 | { | 84 | { |
83 | public Vector3 targetPos; | 85 | public Vector3 targetPos; |
84 | public float tolerance; | 86 | public float tolerance; |
85 | public uint handle; | 87 | public uint handle; |
86 | } | 88 | } |
87 | 89 | ||
88 | struct scriptRotTarget | 90 | public struct scriptRotTarget |
89 | { | 91 | { |
90 | public Quaternion targetRot; | 92 | public Quaternion targetRot; |
91 | public float tolerance; | 93 | public float tolerance; |
@@ -116,8 +118,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
116 | /// since the group's last persistent backup | 118 | /// since the group's last persistent backup |
117 | /// </summary> | 119 | /// </summary> |
118 | private bool m_hasGroupChanged = false; | 120 | private bool m_hasGroupChanged = false; |
119 | private long timeFirstChanged; | 121 | private long timeFirstChanged = 0; |
120 | private long timeLastChanged; | 122 | private long timeLastChanged = 0; |
123 | private long m_maxPersistTime = 0; | ||
124 | private long m_minPersistTime = 0; | ||
125 | // private Random m_rand; | ||
121 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); | 126 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); |
122 | 127 | ||
123 | /// <summary> | 128 | /// <summary> |
@@ -135,9 +140,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
135 | { | 140 | { |
136 | if (value) | 141 | if (value) |
137 | { | 142 | { |
143 | |||
144 | if (m_isBackedUp) | ||
145 | { | ||
146 | m_scene.SceneGraph.FireChangeBackup(this); | ||
147 | } | ||
138 | timeLastChanged = DateTime.Now.Ticks; | 148 | timeLastChanged = DateTime.Now.Ticks; |
139 | if (!m_hasGroupChanged) | 149 | if (!m_hasGroupChanged) |
140 | timeFirstChanged = DateTime.Now.Ticks; | 150 | timeFirstChanged = DateTime.Now.Ticks; |
151 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | ||
152 | { | ||
153 | /* | ||
154 | if (m_rand == null) | ||
155 | { | ||
156 | byte[] val = new byte[16]; | ||
157 | m_rootPart.UUID.ToBytes(val, 0); | ||
158 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
159 | } | ||
160 | */ | ||
161 | if (m_scene.GetRootAgentCount() == 0) | ||
162 | { | ||
163 | //If the region is empty, this change has been made by an automated process | ||
164 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
165 | |||
166 | // float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
167 | float factor = 2.0f; | ||
168 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); | ||
169 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); | ||
170 | } | ||
171 | else | ||
172 | { | ||
173 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
174 | //but add a random factor so we stagger the object persistance a little | ||
175 | // m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
176 | // m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
177 | m_maxPersistTime = m_scene.m_persistAfter; | ||
178 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
179 | } | ||
180 | } | ||
141 | } | 181 | } |
142 | m_hasGroupChanged = value; | 182 | m_hasGroupChanged = value; |
143 | 183 | ||
@@ -152,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
152 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since | 192 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since |
153 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. | 193 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. |
154 | /// </summary> | 194 | /// </summary> |
155 | public bool HasGroupChangedDueToDelink { get; private set; } | 195 | public bool HasGroupChangedDueToDelink { get; set; } |
156 | 196 | ||
157 | private bool isTimeToPersist() | 197 | private bool isTimeToPersist() |
158 | { | 198 | { |
@@ -162,8 +202,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
162 | return false; | 202 | return false; |
163 | if (m_scene.ShuttingDown) | 203 | if (m_scene.ShuttingDown) |
164 | return true; | 204 | return true; |
205 | |||
206 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
207 | { | ||
208 | m_maxPersistTime = m_scene.m_persistAfter; | ||
209 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
210 | } | ||
211 | |||
165 | long currentTime = DateTime.Now.Ticks; | 212 | long currentTime = DateTime.Now.Ticks; |
166 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 213 | |
214 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
215 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
216 | |||
217 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
167 | return true; | 218 | return true; |
168 | return false; | 219 | return false; |
169 | } | 220 | } |
@@ -221,6 +272,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
221 | { | 272 | { |
222 | AttachmentPoint = 0; | 273 | AttachmentPoint = 0; |
223 | 274 | ||
275 | // Don't zap trees | ||
276 | if (RootPart.Shape.PCode == (byte)PCode.Tree || | ||
277 | RootPart.Shape.PCode == (byte)PCode.NewTree) | ||
278 | return; | ||
279 | |||
224 | // Even though we don't use child part state parameters for attachments any more, we still need to set | 280 | // Even though we don't use child part state parameters for attachments any more, we still need to set |
225 | // these to zero since having them non-zero in rezzed scene objects will crash some clients. Even if | 281 | // these to zero since having them non-zero in rezzed scene objects will crash some clients. Even if |
226 | // we store them correctly, scene objects that we receive from elsewhere might not. | 282 | // we store them correctly, scene objects that we receive from elsewhere might not. |
@@ -266,26 +322,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
266 | get { return RootPart.VolumeDetectActive; } | 322 | get { return RootPart.VolumeDetectActive; } |
267 | } | 323 | } |
268 | 324 | ||
269 | private Vector3 lastPhysGroupPos; | ||
270 | private Quaternion lastPhysGroupRot; | ||
271 | |||
272 | private bool m_isBackedUp; | 325 | private bool m_isBackedUp; |
273 | 326 | ||
327 | public bool IsBackedUp | ||
328 | { | ||
329 | get { return m_isBackedUp; } | ||
330 | } | ||
331 | |||
274 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); | 332 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); |
275 | 333 | ||
276 | protected ulong m_regionHandle; | 334 | protected ulong m_regionHandle; |
277 | protected SceneObjectPart m_rootPart; | 335 | protected SceneObjectPart m_rootPart; |
278 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); | 336 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); |
279 | 337 | ||
280 | private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); | 338 | private SortedDictionary<uint, scriptPosTarget> m_targets = new SortedDictionary<uint, scriptPosTarget>(); |
281 | private Dictionary<uint, scriptRotTarget> m_rotTargets = new Dictionary<uint, scriptRotTarget>(); | 339 | private SortedDictionary<uint, scriptRotTarget> m_rotTargets = new SortedDictionary<uint, scriptRotTarget>(); |
340 | |||
341 | public SortedDictionary<uint, scriptPosTarget> AtTargets | ||
342 | { | ||
343 | get { return m_targets; } | ||
344 | } | ||
345 | |||
346 | public SortedDictionary<uint, scriptRotTarget> RotTargets | ||
347 | { | ||
348 | get { return m_rotTargets; } | ||
349 | } | ||
282 | 350 | ||
283 | private bool m_scriptListens_atTarget; | 351 | private bool m_scriptListens_atTarget; |
284 | private bool m_scriptListens_notAtTarget; | 352 | private bool m_scriptListens_notAtTarget; |
285 | |||
286 | private bool m_scriptListens_atRotTarget; | 353 | private bool m_scriptListens_atRotTarget; |
287 | private bool m_scriptListens_notAtRotTarget; | 354 | private bool m_scriptListens_notAtRotTarget; |
288 | 355 | ||
356 | public bool m_dupeInProgress = false; | ||
289 | internal Dictionary<UUID, string> m_savedScriptState; | 357 | internal Dictionary<UUID, string> m_savedScriptState; |
290 | 358 | ||
291 | #region Properties | 359 | #region Properties |
@@ -322,6 +390,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
322 | get { return m_parts.Count; } | 390 | get { return m_parts.Count; } |
323 | } | 391 | } |
324 | 392 | ||
393 | // protected Quaternion m_rotation = Quaternion.Identity; | ||
394 | // | ||
395 | // public virtual Quaternion Rotation | ||
396 | // { | ||
397 | // get { return m_rotation; } | ||
398 | // set { | ||
399 | // m_rotation = value; | ||
400 | // } | ||
401 | // } | ||
402 | |||
325 | public Quaternion GroupRotation | 403 | public Quaternion GroupRotation |
326 | { | 404 | { |
327 | get { return m_rootPart.RotationOffset; } | 405 | get { return m_rootPart.RotationOffset; } |
@@ -597,9 +675,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
597 | // Restuff the new GroupPosition into each SOP of the linkset. | 675 | // Restuff the new GroupPosition into each SOP of the linkset. |
598 | // This has the affect of resetting and tainting the physics actors. | 676 | // This has the affect of resetting and tainting the physics actors. |
599 | SceneObjectPart[] parts = m_parts.GetArray(); | 677 | SceneObjectPart[] parts = m_parts.GetArray(); |
600 | for (int i = 0; i < parts.Length; i++) | 678 | bool triggerScriptEvent = m_rootPart.GroupPosition != val; |
601 | parts[i].GroupPosition = val; | 679 | if (m_dupeInProgress) |
680 | triggerScriptEvent = false; | ||
681 | foreach (SceneObjectPart part in parts) | ||
682 | { | ||
683 | part.GroupPosition = val; | ||
684 | if (triggerScriptEvent) | ||
685 | part.TriggerScriptChangedEvent(Changed.POSITION); | ||
686 | } | ||
602 | 687 | ||
688 | /* | ||
689 | This seems not needed and should not be needed: | ||
690 | sp absolute position depends on sit part absolute position fixed above. | ||
691 | sp ParentPosition is not used anywhere. | ||
692 | Since presence is sitting, viewer considers it 'linked' to root prim, so it will move/rotate it | ||
693 | Sending a extra packet with avatar position is not only bandwidth waste, but may cause jitter in viewers due to UPD nature. | ||
694 | |||
695 | if (!m_dupeInProgress) | ||
696 | { | ||
697 | foreach (ScenePresence av in m_linkedAvatars) | ||
698 | { | ||
699 | SceneObjectPart p = m_scene.GetSceneObjectPart(av.ParentID); | ||
700 | if (p != null && m_parts.TryGetValue(p.UUID, out p)) | ||
701 | { | ||
702 | Vector3 offset = p.GetWorldPosition() - av.ParentPosition; | ||
703 | av.AbsolutePosition += offset; | ||
704 | // av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition | ||
705 | av.SendAvatarDataToAllAgents(); | ||
706 | } | ||
707 | } | ||
708 | } | ||
709 | */ | ||
603 | //if (m_rootPart.PhysActor != null) | 710 | //if (m_rootPart.PhysActor != null) |
604 | //{ | 711 | //{ |
605 | //m_rootPart.PhysActor.Position = | 712 | //m_rootPart.PhysActor.Position = |
@@ -716,6 +823,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
716 | m_isSelected = value; | 823 | m_isSelected = value; |
717 | // Tell physics engine that group is selected | 824 | // Tell physics engine that group is selected |
718 | 825 | ||
826 | // this is not right | ||
827 | // but ode engines should only really need to know about root part | ||
828 | // so they can put entire object simulation on hold and not colliding | ||
829 | // keep as was for now | ||
830 | |||
719 | PhysicsActor pa = m_rootPart.PhysActor; | 831 | PhysicsActor pa = m_rootPart.PhysActor; |
720 | if (pa != null) | 832 | if (pa != null) |
721 | { | 833 | { |
@@ -737,6 +849,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
737 | } | 849 | } |
738 | } | 850 | } |
739 | 851 | ||
852 | public void PartSelectChanged(bool partSelect) | ||
853 | { | ||
854 | // any part selected makes group selected | ||
855 | if (m_isSelected == partSelect) | ||
856 | return; | ||
857 | |||
858 | if (partSelect) | ||
859 | { | ||
860 | IsSelected = partSelect; | ||
861 | // if (!IsAttachment) | ||
862 | // ScheduleGroupForFullUpdate(); | ||
863 | } | ||
864 | else | ||
865 | { | ||
866 | // bad bad bad 2 heavy for large linksets | ||
867 | // since viewer does send lot of (un)selects | ||
868 | // this needs to be replaced by a specific list or count ? | ||
869 | // but that will require extra code in several places | ||
870 | |||
871 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
872 | for (int i = 0; i < parts.Length; i++) | ||
873 | { | ||
874 | SceneObjectPart part = parts[i]; | ||
875 | if (part.IsSelected) | ||
876 | return; | ||
877 | } | ||
878 | IsSelected = partSelect; | ||
879 | if (!IsAttachment) | ||
880 | { | ||
881 | ScheduleGroupForFullUpdate(); | ||
882 | } | ||
883 | } | ||
884 | } | ||
885 | |||
740 | private SceneObjectPart m_PlaySoundMasterPrim = null; | 886 | private SceneObjectPart m_PlaySoundMasterPrim = null; |
741 | public SceneObjectPart PlaySoundMasterPrim | 887 | public SceneObjectPart PlaySoundMasterPrim |
742 | { | 888 | { |
@@ -831,6 +977,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
831 | /// </summary> | 977 | /// </summary> |
832 | public SceneObjectGroup() | 978 | public SceneObjectGroup() |
833 | { | 979 | { |
980 | |||
834 | } | 981 | } |
835 | 982 | ||
836 | /// <summary> | 983 | /// <summary> |
@@ -848,8 +995,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
848 | /// Constructor. This object is added to the scene later via AttachToScene() | 995 | /// Constructor. This object is added to the scene later via AttachToScene() |
849 | /// </summary> | 996 | /// </summary> |
850 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 997 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
851 | :this(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)) | 998 | { |
852 | { | 999 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
853 | } | 1000 | } |
854 | 1001 | ||
855 | /// <summary> | 1002 | /// <summary> |
@@ -884,6 +1031,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
884 | /// </summary> | 1031 | /// </summary> |
885 | public virtual void AttachToBackup() | 1032 | public virtual void AttachToBackup() |
886 | { | 1033 | { |
1034 | if (IsAttachment) return; | ||
1035 | m_scene.SceneGraph.FireAttachToBackup(this); | ||
1036 | |||
887 | if (InSceneBackup) | 1037 | if (InSceneBackup) |
888 | { | 1038 | { |
889 | //m_log.DebugFormat( | 1039 | //m_log.DebugFormat( |
@@ -931,6 +1081,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
931 | 1081 | ||
932 | ApplyPhysics(); | 1082 | ApplyPhysics(); |
933 | 1083 | ||
1084 | if (RootPart.PhysActor != null) | ||
1085 | RootPart.Force = RootPart.Force; | ||
1086 | if (RootPart.PhysActor != null) | ||
1087 | RootPart.Torque = RootPart.Torque; | ||
1088 | if (RootPart.PhysActor != null) | ||
1089 | RootPart.Buoyancy = RootPart.Buoyancy; | ||
1090 | |||
934 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | 1091 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
935 | // for the same object with very different properties. The caller must schedule the update. | 1092 | // for the same object with very different properties. The caller must schedule the update. |
936 | //ScheduleGroupForFullUpdate(); | 1093 | //ScheduleGroupForFullUpdate(); |
@@ -946,6 +1103,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
946 | EntityIntersection result = new EntityIntersection(); | 1103 | EntityIntersection result = new EntityIntersection(); |
947 | 1104 | ||
948 | SceneObjectPart[] parts = m_parts.GetArray(); | 1105 | SceneObjectPart[] parts = m_parts.GetArray(); |
1106 | |||
1107 | // Find closest hit here | ||
1108 | float idist = float.MaxValue; | ||
1109 | |||
949 | for (int i = 0; i < parts.Length; i++) | 1110 | for (int i = 0; i < parts.Length; i++) |
950 | { | 1111 | { |
951 | SceneObjectPart part = parts[i]; | 1112 | SceneObjectPart part = parts[i]; |
@@ -960,11 +1121,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
960 | 1121 | ||
961 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); | 1122 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); |
962 | 1123 | ||
963 | // This may need to be updated to the maximum draw distance possible.. | ||
964 | // We might (and probably will) be checking for prim creation from other sims | ||
965 | // when the camera crosses the border. | ||
966 | float idist = Constants.RegionSize; | ||
967 | |||
968 | if (inter.HitTF) | 1124 | if (inter.HitTF) |
969 | { | 1125 | { |
970 | // We need to find the closest prim to return to the testcaller along the ray | 1126 | // We need to find the closest prim to return to the testcaller along the ray |
@@ -975,10 +1131,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
975 | result.obj = part; | 1131 | result.obj = part; |
976 | result.normal = inter.normal; | 1132 | result.normal = inter.normal; |
977 | result.distance = inter.distance; | 1133 | result.distance = inter.distance; |
1134 | |||
1135 | idist = inter.distance; | ||
978 | } | 1136 | } |
979 | } | 1137 | } |
980 | } | 1138 | } |
981 | |||
982 | return result; | 1139 | return result; |
983 | } | 1140 | } |
984 | 1141 | ||
@@ -990,25 +1147,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
990 | /// <returns></returns> | 1147 | /// <returns></returns> |
991 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) | 1148 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) |
992 | { | 1149 | { |
993 | maxX = -256f; | 1150 | maxX = float.MinValue; |
994 | maxY = -256f; | 1151 | maxY = float.MinValue; |
995 | maxZ = -256f; | 1152 | maxZ = float.MinValue; |
996 | minX = 256f; | 1153 | minX = float.MaxValue; |
997 | minY = 256f; | 1154 | minY = float.MaxValue; |
998 | minZ = 8192f; | 1155 | minZ = float.MaxValue; |
999 | 1156 | ||
1000 | SceneObjectPart[] parts = m_parts.GetArray(); | 1157 | SceneObjectPart[] parts = m_parts.GetArray(); |
1001 | for (int i = 0; i < parts.Length; i++) | 1158 | foreach (SceneObjectPart part in parts) |
1002 | { | 1159 | { |
1003 | SceneObjectPart part = parts[i]; | ||
1004 | |||
1005 | Vector3 worldPos = part.GetWorldPosition(); | 1160 | Vector3 worldPos = part.GetWorldPosition(); |
1006 | Vector3 offset = worldPos - AbsolutePosition; | 1161 | Vector3 offset = worldPos - AbsolutePosition; |
1007 | Quaternion worldRot; | 1162 | Quaternion worldRot; |
1008 | if (part.ParentID == 0) | 1163 | if (part.ParentID == 0) |
1164 | { | ||
1009 | worldRot = part.RotationOffset; | 1165 | worldRot = part.RotationOffset; |
1166 | } | ||
1010 | else | 1167 | else |
1168 | { | ||
1011 | worldRot = part.GetWorldRotation(); | 1169 | worldRot = part.GetWorldRotation(); |
1170 | } | ||
1012 | 1171 | ||
1013 | Vector3 frontTopLeft; | 1172 | Vector3 frontTopLeft; |
1014 | Vector3 frontTopRight; | 1173 | Vector3 frontTopRight; |
@@ -1020,6 +1179,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1020 | Vector3 backBottomLeft; | 1179 | Vector3 backBottomLeft; |
1021 | Vector3 backBottomRight; | 1180 | Vector3 backBottomRight; |
1022 | 1181 | ||
1182 | // Vector3[] corners = new Vector3[8]; | ||
1183 | |||
1023 | Vector3 orig = Vector3.Zero; | 1184 | Vector3 orig = Vector3.Zero; |
1024 | 1185 | ||
1025 | frontTopLeft.X = orig.X - (part.Scale.X / 2); | 1186 | frontTopLeft.X = orig.X - (part.Scale.X / 2); |
@@ -1054,6 +1215,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
1054 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); | 1215 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); |
1055 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); | 1216 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); |
1056 | 1217 | ||
1218 | |||
1219 | |||
1220 | //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1221 | //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1222 | //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1223 | //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1224 | //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1225 | //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1226 | //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1227 | //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1228 | |||
1229 | //for (int i = 0; i < 8; i++) | ||
1230 | //{ | ||
1231 | // corners[i] = corners[i] * worldRot; | ||
1232 | // corners[i] += offset; | ||
1233 | |||
1234 | // if (corners[i].X > maxX) | ||
1235 | // maxX = corners[i].X; | ||
1236 | // if (corners[i].X < minX) | ||
1237 | // minX = corners[i].X; | ||
1238 | |||
1239 | // if (corners[i].Y > maxY) | ||
1240 | // maxY = corners[i].Y; | ||
1241 | // if (corners[i].Y < minY) | ||
1242 | // minY = corners[i].Y; | ||
1243 | |||
1244 | // if (corners[i].Z > maxZ) | ||
1245 | // maxZ = corners[i].Y; | ||
1246 | // if (corners[i].Z < minZ) | ||
1247 | // minZ = corners[i].Z; | ||
1248 | //} | ||
1249 | |||
1057 | frontTopLeft = frontTopLeft * worldRot; | 1250 | frontTopLeft = frontTopLeft * worldRot; |
1058 | frontTopRight = frontTopRight * worldRot; | 1251 | frontTopRight = frontTopRight * worldRot; |
1059 | frontBottomLeft = frontBottomLeft * worldRot; | 1252 | frontBottomLeft = frontBottomLeft * worldRot; |
@@ -1075,6 +1268,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1075 | backTopLeft += offset; | 1268 | backTopLeft += offset; |
1076 | backTopRight += offset; | 1269 | backTopRight += offset; |
1077 | 1270 | ||
1271 | //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1272 | //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1273 | //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1274 | //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1275 | //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1276 | //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1277 | //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1278 | //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1279 | |||
1078 | if (frontTopRight.X > maxX) | 1280 | if (frontTopRight.X > maxX) |
1079 | maxX = frontTopRight.X; | 1281 | maxX = frontTopRight.X; |
1080 | if (frontTopLeft.X > maxX) | 1282 | if (frontTopLeft.X > maxX) |
@@ -1218,17 +1420,118 @@ namespace OpenSim.Region.Framework.Scenes | |||
1218 | 1420 | ||
1219 | #endregion | 1421 | #endregion |
1220 | 1422 | ||
1423 | public void GetResourcesCosts(SceneObjectPart apart, | ||
1424 | out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost) | ||
1425 | { | ||
1426 | // this information may need to be cached | ||
1427 | |||
1428 | float cost; | ||
1429 | float tmpcost; | ||
1430 | |||
1431 | bool ComplexCost = false; | ||
1432 | |||
1433 | SceneObjectPart p; | ||
1434 | SceneObjectPart[] parts; | ||
1435 | |||
1436 | lock (m_parts) | ||
1437 | { | ||
1438 | parts = m_parts.GetArray(); | ||
1439 | } | ||
1440 | |||
1441 | int nparts = parts.Length; | ||
1442 | |||
1443 | |||
1444 | for (int i = 0; i < nparts; i++) | ||
1445 | { | ||
1446 | p = parts[i]; | ||
1447 | |||
1448 | if (p.UsesComplexCost) | ||
1449 | { | ||
1450 | ComplexCost = true; | ||
1451 | break; | ||
1452 | } | ||
1453 | } | ||
1454 | |||
1455 | if (ComplexCost) | ||
1456 | { | ||
1457 | linksetResCost = 0; | ||
1458 | linksetPhysCost = 0; | ||
1459 | partCost = 0; | ||
1460 | partPhysCost = 0; | ||
1461 | |||
1462 | for (int i = 0; i < nparts; i++) | ||
1463 | { | ||
1464 | p = parts[i]; | ||
1465 | |||
1466 | cost = p.StreamingCost; | ||
1467 | tmpcost = p.SimulationCost; | ||
1468 | if (tmpcost > cost) | ||
1469 | cost = tmpcost; | ||
1470 | tmpcost = p.PhysicsCost; | ||
1471 | if (tmpcost > cost) | ||
1472 | cost = tmpcost; | ||
1473 | |||
1474 | linksetPhysCost += tmpcost; | ||
1475 | linksetResCost += cost; | ||
1476 | |||
1477 | if (p == apart) | ||
1478 | { | ||
1479 | partCost = cost; | ||
1480 | partPhysCost = tmpcost; | ||
1481 | } | ||
1482 | } | ||
1483 | } | ||
1484 | else | ||
1485 | { | ||
1486 | partPhysCost = 1.0f; | ||
1487 | partCost = 1.0f; | ||
1488 | linksetResCost = (float)nparts; | ||
1489 | linksetPhysCost = linksetResCost; | ||
1490 | } | ||
1491 | } | ||
1492 | |||
1493 | public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost) | ||
1494 | { | ||
1495 | SceneObjectPart p; | ||
1496 | SceneObjectPart[] parts; | ||
1497 | |||
1498 | lock (m_parts) | ||
1499 | { | ||
1500 | parts = m_parts.GetArray(); | ||
1501 | } | ||
1502 | |||
1503 | int nparts = parts.Length; | ||
1504 | |||
1505 | PhysCost = 0; | ||
1506 | StreamCost = 0; | ||
1507 | SimulCost = 0; | ||
1508 | |||
1509 | for (int i = 0; i < nparts; i++) | ||
1510 | { | ||
1511 | p = parts[i]; | ||
1512 | |||
1513 | StreamCost += p.StreamingCost; | ||
1514 | SimulCost += p.SimulationCost; | ||
1515 | PhysCost += p.PhysicsCost; | ||
1516 | } | ||
1517 | } | ||
1518 | |||
1221 | public void SaveScriptedState(XmlTextWriter writer) | 1519 | public void SaveScriptedState(XmlTextWriter writer) |
1222 | { | 1520 | { |
1521 | SaveScriptedState(writer, false); | ||
1522 | } | ||
1523 | |||
1524 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1525 | { | ||
1223 | XmlDocument doc = new XmlDocument(); | 1526 | XmlDocument doc = new XmlDocument(); |
1224 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1527 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
1225 | 1528 | ||
1226 | SceneObjectPart[] parts = m_parts.GetArray(); | 1529 | SceneObjectPart[] parts = m_parts.GetArray(); |
1227 | for (int i = 0; i < parts.Length; i++) | 1530 | for (int i = 0; i < parts.Length; i++) |
1228 | { | 1531 | { |
1229 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(); | 1532 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(oldIDs); |
1230 | foreach (KeyValuePair<UUID, string> kvp in pstates) | 1533 | foreach (KeyValuePair<UUID, string> kvp in pstates) |
1231 | states.Add(kvp.Key, kvp.Value); | 1534 | states[kvp.Key] = kvp.Value; |
1232 | } | 1535 | } |
1233 | 1536 | ||
1234 | if (states.Count > 0) | 1537 | if (states.Count > 0) |
@@ -1247,16 +1550,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1247 | } | 1550 | } |
1248 | } | 1551 | } |
1249 | 1552 | ||
1250 | |||
1251 | /// <summary> | ||
1252 | /// | ||
1253 | /// </summary> | ||
1254 | /// <param name="part"></param> | ||
1255 | private void SetPartAsNonRoot(SceneObjectPart part) | ||
1256 | { | ||
1257 | part.ParentID = m_rootPart.LocalId; | ||
1258 | part.ClearUndoState(); | ||
1259 | } | ||
1260 | /// <summary> | 1553 | /// <summary> |
1261 | /// Add the avatar to this linkset (avatar is sat). | 1554 | /// Add the avatar to this linkset (avatar is sat). |
1262 | /// </summary> | 1555 | /// </summary> |
@@ -1298,6 +1591,139 @@ namespace OpenSim.Region.Framework.Scenes | |||
1298 | return m_linkedAvatars; | 1591 | return m_linkedAvatars; |
1299 | } | 1592 | } |
1300 | 1593 | ||
1594 | /// <summary> | ||
1595 | /// Attach this scene object to the given avatar. | ||
1596 | /// </summary> | ||
1597 | /// <param name="agentID"></param> | ||
1598 | /// <param name="attachmentpoint"></param> | ||
1599 | /// <param name="AttachOffset"></param> | ||
1600 | private void AttachToAgent( | ||
1601 | ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | ||
1602 | { | ||
1603 | if (avatar != null) | ||
1604 | { | ||
1605 | // don't attach attachments to child agents | ||
1606 | if (avatar.IsChildAgent) return; | ||
1607 | |||
1608 | // Remove from database and parcel prim count | ||
1609 | m_scene.DeleteFromStorage(so.UUID); | ||
1610 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1611 | |||
1612 | so.AttachedAvatar = avatar.UUID; | ||
1613 | |||
1614 | if (so.RootPart.PhysActor != null) | ||
1615 | { | ||
1616 | m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); | ||
1617 | so.RootPart.PhysActor = null; | ||
1618 | } | ||
1619 | |||
1620 | so.AbsolutePosition = attachOffset; | ||
1621 | so.RootPart.AttachedPos = attachOffset; | ||
1622 | so.IsAttachment = true; | ||
1623 | so.RootPart.SetParentLocalId(avatar.LocalId); | ||
1624 | so.AttachmentPoint = attachmentpoint; | ||
1625 | |||
1626 | avatar.AddAttachment(this); | ||
1627 | |||
1628 | if (!silent) | ||
1629 | { | ||
1630 | // Killing it here will cause the client to deselect it | ||
1631 | // It then reappears on the avatar, deselected | ||
1632 | // through the full update below | ||
1633 | // | ||
1634 | if (IsSelected) | ||
1635 | { | ||
1636 | m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId }); | ||
1637 | } | ||
1638 | |||
1639 | IsSelected = false; // fudge.... | ||
1640 | ScheduleGroupForFullUpdate(); | ||
1641 | } | ||
1642 | } | ||
1643 | else | ||
1644 | { | ||
1645 | m_log.WarnFormat( | ||
1646 | "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", | ||
1647 | UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName); | ||
1648 | } | ||
1649 | } | ||
1650 | |||
1651 | public byte GetAttachmentPoint() | ||
1652 | { | ||
1653 | return m_rootPart.Shape.State; | ||
1654 | } | ||
1655 | |||
1656 | public void DetachToGround() | ||
1657 | { | ||
1658 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1659 | if (avatar == null) | ||
1660 | return; | ||
1661 | m_rootPart.Shape.LastAttachPoint = m_rootPart.Shape.State; | ||
1662 | m_rootPart.AttachedPos = m_rootPart.OffsetPosition; | ||
1663 | avatar.RemoveAttachment(this); | ||
1664 | |||
1665 | Vector3 detachedpos = new Vector3(127f,127f,127f); | ||
1666 | if (avatar == null) | ||
1667 | return; | ||
1668 | |||
1669 | detachedpos = avatar.AbsolutePosition; | ||
1670 | FromItemID = UUID.Zero; | ||
1671 | |||
1672 | AbsolutePosition = detachedpos; | ||
1673 | AttachedAvatar = UUID.Zero; | ||
1674 | |||
1675 | //SceneObjectPart[] parts = m_parts.GetArray(); | ||
1676 | //for (int i = 0; i < parts.Length; i++) | ||
1677 | // parts[i].AttachedAvatar = UUID.Zero; | ||
1678 | |||
1679 | m_rootPart.SetParentLocalId(0); | ||
1680 | AttachmentPoint = (byte)0; | ||
1681 | // must check if buildind should be true or false here | ||
1682 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false); | ||
1683 | HasGroupChanged = true; | ||
1684 | RootPart.Rezzed = DateTime.Now; | ||
1685 | RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
1686 | AttachToBackup(); | ||
1687 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1688 | m_rootPart.ScheduleFullUpdate(); | ||
1689 | m_rootPart.ClearUndoState(); | ||
1690 | } | ||
1691 | |||
1692 | public void DetachToInventoryPrep() | ||
1693 | { | ||
1694 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1695 | //Vector3 detachedpos = new Vector3(127f, 127f, 127f); | ||
1696 | if (avatar != null) | ||
1697 | { | ||
1698 | //detachedpos = avatar.AbsolutePosition; | ||
1699 | avatar.RemoveAttachment(this); | ||
1700 | } | ||
1701 | |||
1702 | AttachedAvatar = UUID.Zero; | ||
1703 | |||
1704 | /*SceneObjectPart[] parts = m_parts.GetArray(); | ||
1705 | for (int i = 0; i < parts.Length; i++) | ||
1706 | parts[i].AttachedAvatar = UUID.Zero;*/ | ||
1707 | |||
1708 | m_rootPart.SetParentLocalId(0); | ||
1709 | //m_rootPart.SetAttachmentPoint((byte)0); | ||
1710 | IsAttachment = false; | ||
1711 | AbsolutePosition = m_rootPart.AttachedPos; | ||
1712 | //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); | ||
1713 | //AttachToBackup(); | ||
1714 | //m_rootPart.ScheduleFullUpdate(); | ||
1715 | } | ||
1716 | |||
1717 | /// <summary> | ||
1718 | /// | ||
1719 | /// </summary> | ||
1720 | /// <param name="part"></param> | ||
1721 | private void SetPartAsNonRoot(SceneObjectPart part) | ||
1722 | { | ||
1723 | part.ParentID = m_rootPart.LocalId; | ||
1724 | part.ClearUndoState(); | ||
1725 | } | ||
1726 | |||
1301 | public ushort GetTimeDilation() | 1727 | public ushort GetTimeDilation() |
1302 | { | 1728 | { |
1303 | return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f); | 1729 | return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f); |
@@ -1328,7 +1754,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1328 | public void AddPart(SceneObjectPart part) | 1754 | public void AddPart(SceneObjectPart part) |
1329 | { | 1755 | { |
1330 | part.SetParent(this); | 1756 | part.SetParent(this); |
1331 | part.LinkNum = m_parts.Add(part.UUID, part); | 1757 | m_parts.Add(part.UUID, part); |
1758 | |||
1759 | part.LinkNum = m_parts.Count; | ||
1760 | |||
1332 | if (part.LinkNum == 2) | 1761 | if (part.LinkNum == 2) |
1333 | RootPart.LinkNum = 1; | 1762 | RootPart.LinkNum = 1; |
1334 | } | 1763 | } |
@@ -1354,6 +1783,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1354 | parts[i].UUID = UUID.Random(); | 1783 | parts[i].UUID = UUID.Random(); |
1355 | } | 1784 | } |
1356 | 1785 | ||
1786 | // helper provided for parts. | ||
1787 | public int GetSceneMaxUndo() | ||
1788 | { | ||
1789 | if (m_scene != null) | ||
1790 | return m_scene.MaxUndoCount; | ||
1791 | return 5; | ||
1792 | } | ||
1793 | |||
1357 | // justincc: I don't believe this hack is needed any longer, especially since the physics | 1794 | // justincc: I don't believe this hack is needed any longer, especially since the physics |
1358 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false | 1795 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false |
1359 | // this method was preventing proper reload of scene objects. | 1796 | // this method was preventing proper reload of scene objects. |
@@ -1411,7 +1848,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1411 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", | 1848 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", |
1412 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); | 1849 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); |
1413 | 1850 | ||
1414 | part.StoreUndoState(); | 1851 | // part.StoreUndoState(); |
1415 | part.OnGrab(offsetPos, remoteClient); | 1852 | part.OnGrab(offsetPos, remoteClient); |
1416 | } | 1853 | } |
1417 | 1854 | ||
@@ -1431,6 +1868,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1431 | /// <param name="silent">If true then deletion is not broadcast to clients</param> | 1868 | /// <param name="silent">If true then deletion is not broadcast to clients</param> |
1432 | public void DeleteGroupFromScene(bool silent) | 1869 | public void DeleteGroupFromScene(bool silent) |
1433 | { | 1870 | { |
1871 | // We need to keep track of this state in case this group is still queued for backup. | ||
1872 | IsDeleted = true; | ||
1873 | |||
1874 | DetachFromBackup(); | ||
1875 | |||
1434 | SceneObjectPart[] parts = m_parts.GetArray(); | 1876 | SceneObjectPart[] parts = m_parts.GetArray(); |
1435 | for (int i = 0; i < parts.Length; i++) | 1877 | for (int i = 0; i < parts.Length; i++) |
1436 | { | 1878 | { |
@@ -1454,6 +1896,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1454 | } | 1896 | } |
1455 | }); | 1897 | }); |
1456 | } | 1898 | } |
1899 | |||
1457 | } | 1900 | } |
1458 | 1901 | ||
1459 | public void AddScriptLPS(int count) | 1902 | public void AddScriptLPS(int count) |
@@ -1523,28 +1966,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1523 | /// </summary> | 1966 | /// </summary> |
1524 | public void ApplyPhysics() | 1967 | public void ApplyPhysics() |
1525 | { | 1968 | { |
1526 | // Apply physics to the root prim | ||
1527 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); | ||
1528 | |||
1529 | // Apply physics to child prims | ||
1530 | SceneObjectPart[] parts = m_parts.GetArray(); | 1969 | SceneObjectPart[] parts = m_parts.GetArray(); |
1531 | if (parts.Length > 1) | 1970 | if (parts.Length > 1) |
1532 | { | 1971 | { |
1972 | ResetChildPrimPhysicsPositions(); | ||
1973 | |||
1974 | // Apply physics to the root prim | ||
1975 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true); | ||
1976 | |||
1977 | |||
1533 | for (int i = 0; i < parts.Length; i++) | 1978 | for (int i = 0; i < parts.Length; i++) |
1534 | { | 1979 | { |
1535 | SceneObjectPart part = parts[i]; | 1980 | SceneObjectPart part = parts[i]; |
1536 | if (part.LocalId != m_rootPart.LocalId) | 1981 | if (part.LocalId != m_rootPart.LocalId) |
1537 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); | 1982 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, true); |
1538 | } | 1983 | } |
1539 | |||
1540 | // Hack to get the physics scene geometries in the right spot | 1984 | // Hack to get the physics scene geometries in the right spot |
1541 | ResetChildPrimPhysicsPositions(); | 1985 | // ResetChildPrimPhysicsPositions(); |
1986 | if (m_rootPart.PhysActor != null) | ||
1987 | { | ||
1988 | m_rootPart.PhysActor.Building = false; | ||
1989 | } | ||
1990 | } | ||
1991 | else | ||
1992 | { | ||
1993 | // Apply physics to the root prim | ||
1994 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); | ||
1542 | } | 1995 | } |
1543 | } | 1996 | } |
1544 | 1997 | ||
1545 | public void SetOwnerId(UUID userId) | 1998 | public void SetOwnerId(UUID userId) |
1546 | { | 1999 | { |
1547 | ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); | 2000 | ForEachPart(delegate(SceneObjectPart part) |
2001 | { | ||
2002 | |||
2003 | part.OwnerID = userId; | ||
2004 | |||
2005 | }); | ||
1548 | } | 2006 | } |
1549 | 2007 | ||
1550 | public void ForEachPart(Action<SceneObjectPart> whatToDo) | 2008 | public void ForEachPart(Action<SceneObjectPart> whatToDo) |
@@ -1576,11 +2034,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1576 | return; | 2034 | return; |
1577 | } | 2035 | } |
1578 | 2036 | ||
2037 | if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | ||
2038 | return; | ||
2039 | |||
1579 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let | 2040 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let |
1580 | // any exception propogate upwards. | 2041 | // any exception propogate upwards. |
1581 | try | 2042 | try |
1582 | { | 2043 | { |
1583 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart | 2044 | if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart |
2045 | !m_scene.LoginsEnabled || // We're starting up or doing maintenance, don't mess with things | ||
2046 | m_scene.LoadingPrims) // Land may not be valid yet | ||
2047 | |||
1584 | { | 2048 | { |
1585 | ILandObject parcel = m_scene.LandChannel.GetLandObject( | 2049 | ILandObject parcel = m_scene.LandChannel.GetLandObject( |
1586 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); | 2050 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); |
@@ -1607,6 +2071,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1607 | } | 2071 | } |
1608 | } | 2072 | } |
1609 | } | 2073 | } |
2074 | |||
1610 | } | 2075 | } |
1611 | 2076 | ||
1612 | if (m_scene.UseBackup && HasGroupChanged) | 2077 | if (m_scene.UseBackup && HasGroupChanged) |
@@ -1614,10 +2079,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
1614 | // don't backup while it's selected or you're asking for changes mid stream. | 2079 | // don't backup while it's selected or you're asking for changes mid stream. |
1615 | if (isTimeToPersist() || forcedBackup) | 2080 | if (isTimeToPersist() || forcedBackup) |
1616 | { | 2081 | { |
2082 | if (m_rootPart.PhysActor != null && | ||
2083 | (!m_rootPart.PhysActor.IsPhysical)) | ||
2084 | { | ||
2085 | // Possible ghost prim | ||
2086 | if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) | ||
2087 | { | ||
2088 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
2089 | { | ||
2090 | // Re-set physics actor positions and | ||
2091 | // orientations | ||
2092 | part.GroupPosition = m_rootPart.GroupPosition; | ||
2093 | } | ||
2094 | } | ||
2095 | } | ||
1617 | // m_log.DebugFormat( | 2096 | // m_log.DebugFormat( |
1618 | // "[SCENE]: Storing {0}, {1} in {2}", | 2097 | // "[SCENE]: Storing {0}, {1} in {2}", |
1619 | // Name, UUID, m_scene.RegionInfo.RegionName); | 2098 | // Name, UUID, m_scene.RegionInfo.RegionName); |
1620 | 2099 | ||
2100 | if (RootPart.Shape.PCode == 9 && RootPart.Shape.State != 0) | ||
2101 | { | ||
2102 | RootPart.Shape.LastAttachPoint = RootPart.Shape.State; | ||
2103 | RootPart.Shape.State = 0; | ||
2104 | ScheduleGroupForFullUpdate(); | ||
2105 | } | ||
2106 | |||
1621 | SceneObjectGroup backup_group = Copy(false); | 2107 | SceneObjectGroup backup_group = Copy(false); |
1622 | backup_group.RootPart.Velocity = RootPart.Velocity; | 2108 | backup_group.RootPart.Velocity = RootPart.Velocity; |
1623 | backup_group.RootPart.Acceleration = RootPart.Acceleration; | 2109 | backup_group.RootPart.Acceleration = RootPart.Acceleration; |
@@ -1627,6 +2113,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1627 | HasGroupChangedDueToDelink = false; | 2113 | HasGroupChangedDueToDelink = false; |
1628 | 2114 | ||
1629 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); | 2115 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); |
2116 | /* | ||
2117 | backup_group.ForEachPart(delegate(SceneObjectPart part) | ||
2118 | { | ||
2119 | if (part.KeyframeMotion != null) | ||
2120 | { | ||
2121 | part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); | ||
2122 | // part.KeyframeMotion.UpdateSceneObject(this); | ||
2123 | } | ||
2124 | }); | ||
2125 | */ | ||
1630 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); | 2126 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); |
1631 | 2127 | ||
1632 | backup_group.ForEachPart(delegate(SceneObjectPart part) | 2128 | backup_group.ForEachPart(delegate(SceneObjectPart part) |
@@ -1683,10 +2179,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1683 | /// <returns></returns> | 2179 | /// <returns></returns> |
1684 | public SceneObjectGroup Copy(bool userExposed) | 2180 | public SceneObjectGroup Copy(bool userExposed) |
1685 | { | 2181 | { |
2182 | m_dupeInProgress = true; | ||
1686 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); | 2183 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); |
1687 | dupe.m_isBackedUp = false; | 2184 | dupe.m_isBackedUp = false; |
1688 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); | 2185 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); |
1689 | 2186 | ||
2187 | // new group as no sitting avatars | ||
2188 | dupe.m_linkedAvatars = new List<ScenePresence>(); | ||
2189 | |||
1690 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of | 2190 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of |
1691 | // attachments do not bordercross while they're being duplicated. This is hacktastic! | 2191 | // attachments do not bordercross while they're being duplicated. This is hacktastic! |
1692 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! | 2192 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! |
@@ -1697,7 +2197,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1697 | // This is only necessary when userExposed is false! | 2197 | // This is only necessary when userExposed is false! |
1698 | 2198 | ||
1699 | bool previousAttachmentStatus = dupe.IsAttachment; | 2199 | bool previousAttachmentStatus = dupe.IsAttachment; |
1700 | 2200 | ||
1701 | if (!userExposed) | 2201 | if (!userExposed) |
1702 | dupe.IsAttachment = true; | 2202 | dupe.IsAttachment = true; |
1703 | 2203 | ||
@@ -1710,16 +2210,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1710 | 2210 | ||
1711 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); | 2211 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); |
1712 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; | 2212 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; |
2213 | |||
1713 | 2214 | ||
1714 | if (userExposed) | 2215 | if (userExposed) |
1715 | dupe.m_rootPart.TrimPermissions(); | 2216 | dupe.m_rootPart.TrimPermissions(); |
1716 | 2217 | ||
1717 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); | 2218 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); |
1718 | 2219 | ||
1719 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | 2220 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) |
1720 | { | 2221 | { |
1721 | return p1.LinkNum.CompareTo(p2.LinkNum); | 2222 | return p1.LinkNum.CompareTo(p2.LinkNum); |
1722 | } | 2223 | } |
1723 | ); | 2224 | ); |
1724 | 2225 | ||
1725 | foreach (SceneObjectPart part in partList) | 2226 | foreach (SceneObjectPart part in partList) |
@@ -1729,43 +2230,56 @@ namespace OpenSim.Region.Framework.Scenes | |||
1729 | { | 2230 | { |
1730 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); | 2231 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); |
1731 | newPart.LinkNum = part.LinkNum; | 2232 | newPart.LinkNum = part.LinkNum; |
1732 | } | 2233 | if (userExposed) |
2234 | newPart.ParentID = dupe.m_rootPart.LocalId; | ||
2235 | } | ||
1733 | else | 2236 | else |
1734 | { | 2237 | { |
1735 | newPart = dupe.m_rootPart; | 2238 | newPart = dupe.m_rootPart; |
1736 | } | 2239 | } |
2240 | /* | ||
2241 | bool isphys = ((newPart.Flags & PrimFlags.Physics) != 0); | ||
2242 | bool isphan = ((newPart.Flags & PrimFlags.Phantom) != 0); | ||
1737 | 2243 | ||
1738 | // Need to duplicate the physics actor as well | 2244 | // Need to duplicate the physics actor as well |
1739 | PhysicsActor originalPartPa = part.PhysActor; | 2245 | if (userExposed && (isphys || !isphan || newPart.VolumeDetectActive)) |
1740 | if (originalPartPa != null && userExposed) | ||
1741 | { | 2246 | { |
1742 | PrimitiveBaseShape pbs = newPart.Shape; | 2247 | PrimitiveBaseShape pbs = newPart.Shape; |
1743 | |||
1744 | newPart.PhysActor | 2248 | newPart.PhysActor |
1745 | = m_scene.PhysicsScene.AddPrimShape( | 2249 | = m_scene.PhysicsScene.AddPrimShape( |
1746 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), | 2250 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), |
1747 | pbs, | 2251 | pbs, |
1748 | newPart.AbsolutePosition, | 2252 | newPart.AbsolutePosition, |
1749 | newPart.Scale, | 2253 | newPart.Scale, |
1750 | newPart.RotationOffset, | 2254 | newPart.GetWorldRotation(), |
1751 | originalPartPa.IsPhysical, | 2255 | isphys, |
2256 | isphan, | ||
1752 | newPart.LocalId); | 2257 | newPart.LocalId); |
1753 | 2258 | ||
1754 | newPart.DoPhysicsPropertyUpdate(originalPartPa.IsPhysical, true); | 2259 | newPart.DoPhysicsPropertyUpdate(isphys, true); |
1755 | } | 2260 | */ |
2261 | if (userExposed) | ||
2262 | newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true); | ||
2263 | // } | ||
2264 | // copy keyframemotion | ||
1756 | if (part.KeyframeMotion != null) | 2265 | if (part.KeyframeMotion != null) |
1757 | newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); | 2266 | newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); |
1758 | } | 2267 | } |
1759 | 2268 | ||
1760 | if (userExposed) | 2269 | if (userExposed) |
1761 | { | 2270 | { |
1762 | dupe.UpdateParentIDs(); | 2271 | // done above dupe.UpdateParentIDs(); |
2272 | |||
2273 | if (dupe.m_rootPart.PhysActor != null) | ||
2274 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building | ||
2275 | |||
1763 | dupe.HasGroupChanged = true; | 2276 | dupe.HasGroupChanged = true; |
1764 | dupe.AttachToBackup(); | 2277 | dupe.AttachToBackup(); |
1765 | 2278 | ||
1766 | ScheduleGroupForFullUpdate(); | 2279 | ScheduleGroupForFullUpdate(); |
1767 | } | 2280 | } |
1768 | 2281 | ||
2282 | m_dupeInProgress = false; | ||
1769 | return dupe; | 2283 | return dupe; |
1770 | } | 2284 | } |
1771 | 2285 | ||
@@ -1777,7 +2291,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1777 | /// <param name="cGroupID"></param> | 2291 | /// <param name="cGroupID"></param> |
1778 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2292 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1779 | { | 2293 | { |
1780 | SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); | 2294 | // SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); |
2295 | // give newpart a new local ID lettng old part keep same | ||
2296 | SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed); | ||
2297 | newpart.LocalId = m_scene.AllocateLocalId(); | ||
2298 | |||
2299 | SetRootPart(newpart); | ||
2300 | if (userExposed) | ||
2301 | RootPart.Velocity = Vector3.Zero; // In case source is moving | ||
1781 | } | 2302 | } |
1782 | 2303 | ||
1783 | public void ScriptSetPhysicsStatus(bool usePhysics) | 2304 | public void ScriptSetPhysicsStatus(bool usePhysics) |
@@ -1835,13 +2356,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1835 | 2356 | ||
1836 | if (pa != null) | 2357 | if (pa != null) |
1837 | { | 2358 | { |
1838 | pa.AddForce(impulse, true); | 2359 | // false to be applied as a impulse |
2360 | pa.AddForce(impulse, false); | ||
1839 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2361 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1840 | } | 2362 | } |
1841 | } | 2363 | } |
1842 | } | 2364 | } |
1843 | 2365 | ||
1844 | public void applyAngularImpulse(Vector3 impulse) | 2366 | public void ApplyAngularImpulse(Vector3 impulse) |
1845 | { | 2367 | { |
1846 | PhysicsActor pa = RootPart.PhysActor; | 2368 | PhysicsActor pa = RootPart.PhysActor; |
1847 | 2369 | ||
@@ -1849,21 +2371,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1849 | { | 2371 | { |
1850 | if (!IsAttachment) | 2372 | if (!IsAttachment) |
1851 | { | 2373 | { |
1852 | pa.AddAngularForce(impulse, true); | 2374 | // false to be applied as a impulse |
1853 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2375 | pa.AddAngularForce(impulse, false); |
1854 | } | ||
1855 | } | ||
1856 | } | ||
1857 | |||
1858 | public void setAngularImpulse(Vector3 impulse) | ||
1859 | { | ||
1860 | PhysicsActor pa = RootPart.PhysActor; | ||
1861 | |||
1862 | if (pa != null) | ||
1863 | { | ||
1864 | if (!IsAttachment) | ||
1865 | { | ||
1866 | pa.Torque = impulse; | ||
1867 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2376 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1868 | } | 2377 | } |
1869 | } | 2378 | } |
@@ -1871,20 +2380,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1871 | 2380 | ||
1872 | public Vector3 GetTorque() | 2381 | public Vector3 GetTorque() |
1873 | { | 2382 | { |
1874 | PhysicsActor pa = RootPart.PhysActor; | 2383 | return RootPart.Torque; |
1875 | |||
1876 | if (pa != null) | ||
1877 | { | ||
1878 | if (!IsAttachment) | ||
1879 | { | ||
1880 | Vector3 torque = pa.Torque; | ||
1881 | return torque; | ||
1882 | } | ||
1883 | } | ||
1884 | |||
1885 | return Vector3.Zero; | ||
1886 | } | 2384 | } |
1887 | 2385 | ||
2386 | // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object | ||
1888 | public void moveToTarget(Vector3 target, float tau) | 2387 | public void moveToTarget(Vector3 target, float tau) |
1889 | { | 2388 | { |
1890 | if (IsAttachment) | 2389 | if (IsAttachment) |
@@ -1914,8 +2413,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
1914 | 2413 | ||
1915 | if (pa != null) | 2414 | if (pa != null) |
1916 | pa.PIDActive = false; | 2415 | pa.PIDActive = false; |
2416 | |||
2417 | RootPart.ScheduleTerseUpdate(); // send a stop information | ||
2418 | } | ||
2419 | |||
2420 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2421 | { | ||
2422 | SceneObjectPart rootpart = m_rootPart; | ||
2423 | if (rootpart != null) | ||
2424 | { | ||
2425 | if (IsAttachment) | ||
2426 | { | ||
2427 | /* | ||
2428 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
2429 | if (avatar != null) | ||
2430 | { | ||
2431 | Rotate the Av? | ||
2432 | } */ | ||
2433 | } | ||
2434 | else | ||
2435 | { | ||
2436 | if (rootpart.PhysActor != null) | ||
2437 | { // APID must be implemented in your physics system for this to function. | ||
2438 | rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); | ||
2439 | rootpart.PhysActor.APIDStrength = strength; | ||
2440 | rootpart.PhysActor.APIDDamping = damping; | ||
2441 | rootpart.PhysActor.APIDActive = true; | ||
2442 | } | ||
2443 | } | ||
2444 | } | ||
1917 | } | 2445 | } |
2446 | |||
2447 | public void stopLookAt() | ||
2448 | { | ||
2449 | SceneObjectPart rootpart = m_rootPart; | ||
2450 | if (rootpart != null) | ||
2451 | { | ||
2452 | if (rootpart.PhysActor != null) | ||
2453 | { // APID must be implemented in your physics system for this to function. | ||
2454 | rootpart.PhysActor.APIDActive = false; | ||
2455 | } | ||
2456 | } | ||
1918 | 2457 | ||
2458 | } | ||
2459 | |||
1919 | /// <summary> | 2460 | /// <summary> |
1920 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. | 2461 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. |
1921 | /// </summary> | 2462 | /// </summary> |
@@ -1932,7 +2473,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1932 | { | 2473 | { |
1933 | pa.PIDHoverHeight = height; | 2474 | pa.PIDHoverHeight = height; |
1934 | pa.PIDHoverType = hoverType; | 2475 | pa.PIDHoverType = hoverType; |
1935 | pa.PIDTau = tau; | 2476 | pa.PIDHoverTau = tau; |
1936 | pa.PIDHoverActive = true; | 2477 | pa.PIDHoverActive = true; |
1937 | } | 2478 | } |
1938 | else | 2479 | else |
@@ -1972,7 +2513,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1972 | /// <param name="cGroupID"></param> | 2513 | /// <param name="cGroupID"></param> |
1973 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2514 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1974 | { | 2515 | { |
1975 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | 2516 | // give new ID to the new part, letting old keep original |
2517 | // SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | ||
2518 | SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); | ||
2519 | newPart.LocalId = m_scene.AllocateLocalId(); | ||
2520 | newPart.SetParent(this); | ||
2521 | |||
1976 | AddPart(newPart); | 2522 | AddPart(newPart); |
1977 | 2523 | ||
1978 | SetPartAsNonRoot(newPart); | 2524 | SetPartAsNonRoot(newPart); |
@@ -2022,6 +2568,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2022 | 2568 | ||
2023 | #endregion | 2569 | #endregion |
2024 | 2570 | ||
2571 | |||
2025 | public override void Update() | 2572 | public override void Update() |
2026 | { | 2573 | { |
2027 | // Check that the group was not deleted before the scheduled update | 2574 | // Check that the group was not deleted before the scheduled update |
@@ -2040,19 +2587,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2040 | // check to see if the physical position or rotation warrant an update. | 2587 | // check to see if the physical position or rotation warrant an update. |
2041 | if (m_rootPart.UpdateFlag == UpdateRequired.NONE) | 2588 | if (m_rootPart.UpdateFlag == UpdateRequired.NONE) |
2042 | { | 2589 | { |
2043 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); | 2590 | // rootpart SendScheduledUpdates will check if a update is needed |
2044 | 2591 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | |
2045 | if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) | ||
2046 | { | ||
2047 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | ||
2048 | lastPhysGroupPos = AbsolutePosition; | ||
2049 | } | ||
2050 | |||
2051 | if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) | ||
2052 | { | ||
2053 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | ||
2054 | lastPhysGroupRot = GroupRotation; | ||
2055 | } | ||
2056 | } | 2592 | } |
2057 | 2593 | ||
2058 | SceneObjectPart[] parts = m_parts.GetArray(); | 2594 | SceneObjectPart[] parts = m_parts.GetArray(); |
@@ -2111,11 +2647,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2111 | /// Immediately send a full update for this scene object. | 2647 | /// Immediately send a full update for this scene object. |
2112 | /// </summary> | 2648 | /// </summary> |
2113 | public void SendGroupFullUpdate() | 2649 | public void SendGroupFullUpdate() |
2114 | { | 2650 | { |
2115 | if (IsDeleted) | 2651 | if (IsDeleted) |
2116 | return; | 2652 | return; |
2117 | 2653 | ||
2118 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); | 2654 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); |
2119 | 2655 | ||
2120 | RootPart.SendFullUpdateToAllClients(); | 2656 | RootPart.SendFullUpdateToAllClients(); |
2121 | 2657 | ||
@@ -2271,6 +2807,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2271 | // 'linkPart' == the root of the group being linked into this group | 2807 | // 'linkPart' == the root of the group being linked into this group |
2272 | SceneObjectPart linkPart = objectGroup.m_rootPart; | 2808 | SceneObjectPart linkPart = objectGroup.m_rootPart; |
2273 | 2809 | ||
2810 | if (m_rootPart.PhysActor != null) | ||
2811 | m_rootPart.PhysActor.Building = true; | ||
2812 | if (linkPart.PhysActor != null) | ||
2813 | linkPart.PhysActor.Building = true; | ||
2814 | |||
2274 | // physics flags from group to be applied to linked parts | 2815 | // physics flags from group to be applied to linked parts |
2275 | bool grpusephys = UsesPhysics; | 2816 | bool grpusephys = UsesPhysics; |
2276 | bool grptemporary = IsTemporary; | 2817 | bool grptemporary = IsTemporary; |
@@ -2296,12 +2837,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2296 | Vector3 axPos = linkPart.OffsetPosition; | 2837 | Vector3 axPos = linkPart.OffsetPosition; |
2297 | // Rotate the linking root SOP's position to be relative to the new root prim | 2838 | // Rotate the linking root SOP's position to be relative to the new root prim |
2298 | Quaternion parentRot = m_rootPart.RotationOffset; | 2839 | Quaternion parentRot = m_rootPart.RotationOffset; |
2299 | axPos *= Quaternion.Inverse(parentRot); | 2840 | axPos *= Quaternion.Conjugate(parentRot); |
2300 | linkPart.OffsetPosition = axPos; | 2841 | linkPart.OffsetPosition = axPos; |
2301 | 2842 | ||
2302 | // Make the linking root SOP's rotation relative to the new root prim | 2843 | // Make the linking root SOP's rotation relative to the new root prim |
2303 | Quaternion oldRot = linkPart.RotationOffset; | 2844 | Quaternion oldRot = linkPart.RotationOffset; |
2304 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 2845 | Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; |
2305 | linkPart.RotationOffset = newRot; | 2846 | linkPart.RotationOffset = newRot; |
2306 | 2847 | ||
2307 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. | 2848 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. |
@@ -2335,7 +2876,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2335 | linkPart.CreateSelected = true; | 2876 | linkPart.CreateSelected = true; |
2336 | 2877 | ||
2337 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now | 2878 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now |
2338 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive); | 2879 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); |
2339 | 2880 | ||
2340 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 2881 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2341 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2882 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2345,6 +2886,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2345 | } | 2886 | } |
2346 | 2887 | ||
2347 | linkPart.LinkNum = linkNum++; | 2888 | linkPart.LinkNum = linkNum++; |
2889 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2348 | 2890 | ||
2349 | // Get a list of the SOP's in the old group in order of their linknum's. | 2891 | // Get a list of the SOP's in the old group in order of their linknum's. |
2350 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2892 | SceneObjectPart[] ogParts = objectGroup.Parts; |
@@ -2363,7 +2905,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2363 | 2905 | ||
2364 | // Update the physics flags for the newly added SOP | 2906 | // Update the physics flags for the newly added SOP |
2365 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) | 2907 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) |
2366 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive); | 2908 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); |
2367 | 2909 | ||
2368 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 2910 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2369 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2911 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2381,7 +2923,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2381 | objectGroup.IsDeleted = true; | 2923 | objectGroup.IsDeleted = true; |
2382 | 2924 | ||
2383 | objectGroup.m_parts.Clear(); | 2925 | objectGroup.m_parts.Clear(); |
2384 | 2926 | ||
2385 | // Can't do this yet since backup still makes use of the root part without any synchronization | 2927 | // Can't do this yet since backup still makes use of the root part without any synchronization |
2386 | // objectGroup.m_rootPart = null; | 2928 | // objectGroup.m_rootPart = null; |
2387 | 2929 | ||
@@ -2395,6 +2937,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2395 | // unmoved prims! | 2937 | // unmoved prims! |
2396 | ResetChildPrimPhysicsPositions(); | 2938 | ResetChildPrimPhysicsPositions(); |
2397 | 2939 | ||
2940 | if (m_rootPart.PhysActor != null) | ||
2941 | m_rootPart.PhysActor.Building = false; | ||
2942 | |||
2398 | //HasGroupChanged = true; | 2943 | //HasGroupChanged = true; |
2399 | //ScheduleGroupForFullUpdate(); | 2944 | //ScheduleGroupForFullUpdate(); |
2400 | } | 2945 | } |
@@ -2462,7 +3007,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2462 | // m_log.DebugFormat( | 3007 | // m_log.DebugFormat( |
2463 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", | 3008 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", |
2464 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); | 3009 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); |
2465 | 3010 | ||
3011 | if (m_rootPart.PhysActor != null) | ||
3012 | m_rootPart.PhysActor.Building = true; | ||
3013 | |||
2466 | linkPart.ClearUndoState(); | 3014 | linkPart.ClearUndoState(); |
2467 | 3015 | ||
2468 | Vector3 worldPos = linkPart.GetWorldPosition(); | 3016 | Vector3 worldPos = linkPart.GetWorldPosition(); |
@@ -2533,6 +3081,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2533 | 3081 | ||
2534 | // When we delete a group, we currently have to force persist to the database if the object id has changed | 3082 | // When we delete a group, we currently have to force persist to the database if the object id has changed |
2535 | // (since delete works by deleting all rows which have a given object id) | 3083 | // (since delete works by deleting all rows which have a given object id) |
3084 | |||
3085 | // this is as it seems to be in sl now | ||
3086 | if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none) | ||
3087 | linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now | ||
3088 | |||
3089 | if (m_rootPart.PhysActor != null) | ||
3090 | m_rootPart.PhysActor.Building = false; | ||
3091 | |||
2536 | objectGroup.HasGroupChangedDueToDelink = true; | 3092 | objectGroup.HasGroupChangedDueToDelink = true; |
2537 | 3093 | ||
2538 | return objectGroup; | 3094 | return objectGroup; |
@@ -2544,6 +3100,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2544 | /// <param name="objectGroup"></param> | 3100 | /// <param name="objectGroup"></param> |
2545 | public virtual void DetachFromBackup() | 3101 | public virtual void DetachFromBackup() |
2546 | { | 3102 | { |
3103 | if (m_scene != null) | ||
3104 | m_scene.SceneGraph.FireDetachFromBackup(this); | ||
2547 | if (m_isBackedUp && Scene != null) | 3105 | if (m_isBackedUp && Scene != null) |
2548 | m_scene.EventManager.OnBackup -= ProcessBackup; | 3106 | m_scene.EventManager.OnBackup -= ProcessBackup; |
2549 | 3107 | ||
@@ -2564,7 +3122,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2564 | Vector3 axPos = part.OffsetPosition; | 3122 | Vector3 axPos = part.OffsetPosition; |
2565 | axPos *= parentRot; | 3123 | axPos *= parentRot; |
2566 | part.OffsetPosition = axPos; | 3124 | part.OffsetPosition = axPos; |
2567 | part.GroupPosition = oldGroupPosition + part.OffsetPosition; | 3125 | Vector3 newPos = oldGroupPosition + part.OffsetPosition; |
3126 | part.GroupPosition = newPos; | ||
2568 | part.OffsetPosition = Vector3.Zero; | 3127 | part.OffsetPosition = Vector3.Zero; |
2569 | 3128 | ||
2570 | // Compution our rotation to be not relative to the old parent | 3129 | // Compution our rotation to be not relative to the old parent |
@@ -2579,7 +3138,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2579 | part.LinkNum = linkNum; | 3138 | part.LinkNum = linkNum; |
2580 | 3139 | ||
2581 | // Compute the new position of this SOP relative to the group position | 3140 | // Compute the new position of this SOP relative to the group position |
2582 | part.OffsetPosition = part.GroupPosition - AbsolutePosition; | 3141 | part.OffsetPosition = newPos - AbsolutePosition; |
2583 | 3142 | ||
2584 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. | 3143 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. |
2585 | // It would have the affect of setting the physics engine position multiple | 3144 | // It would have the affect of setting the physics engine position multiple |
@@ -2589,18 +3148,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2589 | // Rotate the relative position by the rotation of the group | 3148 | // Rotate the relative position by the rotation of the group |
2590 | Quaternion rootRotation = m_rootPart.RotationOffset; | 3149 | Quaternion rootRotation = m_rootPart.RotationOffset; |
2591 | Vector3 pos = part.OffsetPosition; | 3150 | Vector3 pos = part.OffsetPosition; |
2592 | pos *= Quaternion.Inverse(rootRotation); | 3151 | pos *= Quaternion.Conjugate(rootRotation); |
2593 | part.OffsetPosition = pos; | 3152 | part.OffsetPosition = pos; |
2594 | 3153 | ||
2595 | // Compute the SOP's rotation relative to the rotation of the group. | 3154 | // Compute the SOP's rotation relative to the rotation of the group. |
2596 | parentRot = m_rootPart.RotationOffset; | 3155 | parentRot = m_rootPart.RotationOffset; |
2597 | oldRot = part.RotationOffset; | 3156 | oldRot = part.RotationOffset; |
2598 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 3157 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
2599 | part.RotationOffset = newRot; | 3158 | part.RotationOffset = newRot; |
2600 | 3159 | ||
2601 | // Since this SOP's state has changed, push those changes into the physics engine | 3160 | // Since this SOP's state has changed, push those changes into the physics engine |
2602 | // and the simulator. | 3161 | // and the simulator. |
2603 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 3162 | // done on caller |
3163 | // part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2604 | } | 3164 | } |
2605 | 3165 | ||
2606 | /// <summary> | 3166 | /// <summary> |
@@ -2622,10 +3182,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2622 | { | 3182 | { |
2623 | if (!m_rootPart.BlockGrab) | 3183 | if (!m_rootPart.BlockGrab) |
2624 | { | 3184 | { |
2625 | Vector3 llmoveforce = pos - AbsolutePosition; | 3185 | /* Vector3 llmoveforce = pos - AbsolutePosition; |
2626 | Vector3 grabforce = llmoveforce; | 3186 | Vector3 grabforce = llmoveforce; |
2627 | grabforce = (grabforce / 10) * pa.Mass; | 3187 | grabforce = (grabforce / 10) * pa.Mass; |
2628 | pa.AddForce(grabforce, true); | 3188 | */ |
3189 | // empirically convert distance diference to a impulse | ||
3190 | Vector3 grabforce = pos - AbsolutePosition; | ||
3191 | grabforce = grabforce * (pa.Mass/ 10.0f); | ||
3192 | pa.AddForce(grabforce, false); | ||
2629 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 3193 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
2630 | } | 3194 | } |
2631 | } | 3195 | } |
@@ -2821,6 +3385,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2821 | /// <param name="SetVolumeDetect"></param> | 3385 | /// <param name="SetVolumeDetect"></param> |
2822 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) | 3386 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) |
2823 | { | 3387 | { |
3388 | HasGroupChanged = true; | ||
3389 | |||
2824 | SceneObjectPart selectionPart = GetPart(localID); | 3390 | SceneObjectPart selectionPart = GetPart(localID); |
2825 | 3391 | ||
2826 | if (SetTemporary && Scene != null) | 3392 | if (SetTemporary && Scene != null) |
@@ -2851,8 +3417,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2851 | } | 3417 | } |
2852 | } | 3418 | } |
2853 | 3419 | ||
2854 | for (int i = 0; i < parts.Length; i++) | 3420 | if (parts.Length > 1) |
2855 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); | 3421 | { |
3422 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3423 | |||
3424 | for (int i = 0; i < parts.Length; i++) | ||
3425 | { | ||
3426 | |||
3427 | if (parts[i].UUID != m_rootPart.UUID) | ||
3428 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3429 | } | ||
3430 | |||
3431 | if (m_rootPart.PhysActor != null) | ||
3432 | m_rootPart.PhysActor.Building = false; | ||
3433 | } | ||
3434 | else | ||
3435 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); | ||
2856 | } | 3436 | } |
2857 | } | 3437 | } |
2858 | 3438 | ||
@@ -2865,6 +3445,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2865 | } | 3445 | } |
2866 | } | 3446 | } |
2867 | 3447 | ||
3448 | |||
3449 | |||
3450 | /// <summary> | ||
3451 | /// Gets the number of parts | ||
3452 | /// </summary> | ||
3453 | /// <returns></returns> | ||
3454 | public int GetPartCount() | ||
3455 | { | ||
3456 | return Parts.Count(); | ||
3457 | } | ||
3458 | |||
2868 | /// <summary> | 3459 | /// <summary> |
2869 | /// Update the texture entry for this part | 3460 | /// Update the texture entry for this part |
2870 | /// </summary> | 3461 | /// </summary> |
@@ -2902,8 +3493,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2902 | { | 3493 | { |
2903 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); | 3494 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); |
2904 | 3495 | ||
3496 | bool god = Scene.Permissions.IsGod(AgentID); | ||
3497 | |||
3498 | if (field == 1 && god) | ||
3499 | { | ||
3500 | ForEachPart(part => | ||
3501 | { | ||
3502 | part.BaseMask = RootPart.BaseMask; | ||
3503 | }); | ||
3504 | } | ||
3505 | |||
2905 | AdjustChildPrimPermissions(); | 3506 | AdjustChildPrimPermissions(); |
2906 | 3507 | ||
3508 | if (field == 1 && god) // Base mask was set. Update all child part inventories | ||
3509 | { | ||
3510 | foreach (SceneObjectPart part in Parts) | ||
3511 | part.Inventory.ApplyGodPermissions(RootPart.BaseMask); | ||
3512 | } | ||
3513 | |||
2907 | HasGroupChanged = true; | 3514 | HasGroupChanged = true; |
2908 | 3515 | ||
2909 | // Send the group's properties to all clients once all parts are updated | 3516 | // Send the group's properties to all clients once all parts are updated |
@@ -2949,8 +3556,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2949 | 3556 | ||
2950 | PhysicsActor pa = m_rootPart.PhysActor; | 3557 | PhysicsActor pa = m_rootPart.PhysActor; |
2951 | 3558 | ||
2952 | RootPart.StoreUndoState(true); | ||
2953 | |||
2954 | if (Scene != null) | 3559 | if (Scene != null) |
2955 | { | 3560 | { |
2956 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); | 3561 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); |
@@ -2978,7 +3583,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2978 | SceneObjectPart obPart = parts[i]; | 3583 | SceneObjectPart obPart = parts[i]; |
2979 | if (obPart.UUID != m_rootPart.UUID) | 3584 | if (obPart.UUID != m_rootPart.UUID) |
2980 | { | 3585 | { |
2981 | // obPart.IgnoreUndoUpdate = true; | ||
2982 | Vector3 oldSize = new Vector3(obPart.Scale); | 3586 | Vector3 oldSize = new Vector3(obPart.Scale); |
2983 | 3587 | ||
2984 | float f = 1.0f; | 3588 | float f = 1.0f; |
@@ -3090,8 +3694,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3090 | z *= a; | 3694 | z *= a; |
3091 | } | 3695 | } |
3092 | } | 3696 | } |
3093 | |||
3094 | // obPart.IgnoreUndoUpdate = false; | ||
3095 | } | 3697 | } |
3096 | } | 3698 | } |
3097 | } | 3699 | } |
@@ -3101,9 +3703,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3101 | prevScale.Y *= y; | 3703 | prevScale.Y *= y; |
3102 | prevScale.Z *= z; | 3704 | prevScale.Z *= z; |
3103 | 3705 | ||
3104 | // RootPart.IgnoreUndoUpdate = true; | ||
3105 | RootPart.Resize(prevScale); | 3706 | RootPart.Resize(prevScale); |
3106 | // RootPart.IgnoreUndoUpdate = false; | ||
3107 | 3707 | ||
3108 | for (int i = 0; i < parts.Length; i++) | 3708 | for (int i = 0; i < parts.Length; i++) |
3109 | { | 3709 | { |
@@ -3111,8 +3711,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3111 | 3711 | ||
3112 | if (obPart.UUID != m_rootPart.UUID) | 3712 | if (obPart.UUID != m_rootPart.UUID) |
3113 | { | 3713 | { |
3114 | obPart.IgnoreUndoUpdate = true; | ||
3115 | |||
3116 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); | 3714 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); |
3117 | currentpos.X *= x; | 3715 | currentpos.X *= x; |
3118 | currentpos.Y *= y; | 3716 | currentpos.Y *= y; |
@@ -3125,16 +3723,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3125 | 3723 | ||
3126 | obPart.Resize(newSize); | 3724 | obPart.Resize(newSize); |
3127 | obPart.UpdateOffSet(currentpos); | 3725 | obPart.UpdateOffSet(currentpos); |
3128 | |||
3129 | obPart.IgnoreUndoUpdate = false; | ||
3130 | } | 3726 | } |
3131 | 3727 | ||
3132 | // obPart.IgnoreUndoUpdate = false; | 3728 | HasGroupChanged = true; |
3133 | // obPart.StoreUndoState(); | 3729 | m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); |
3730 | ScheduleGroupForTerseUpdate(); | ||
3134 | } | 3731 | } |
3135 | |||
3136 | // m_log.DebugFormat( | ||
3137 | // "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); | ||
3138 | } | 3732 | } |
3139 | 3733 | ||
3140 | #endregion | 3734 | #endregion |
@@ -3147,14 +3741,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3147 | /// <param name="pos"></param> | 3741 | /// <param name="pos"></param> |
3148 | public void UpdateGroupPosition(Vector3 pos) | 3742 | public void UpdateGroupPosition(Vector3 pos) |
3149 | { | 3743 | { |
3150 | // m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); | ||
3151 | |||
3152 | RootPart.StoreUndoState(true); | ||
3153 | |||
3154 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3155 | // for (int i = 0; i < parts.Length; i++) | ||
3156 | // parts[i].StoreUndoState(); | ||
3157 | |||
3158 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 3744 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
3159 | { | 3745 | { |
3160 | if (IsAttachment) | 3746 | if (IsAttachment) |
@@ -3187,21 +3773,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
3187 | /// </summary> | 3773 | /// </summary> |
3188 | /// <param name="pos"></param> | 3774 | /// <param name="pos"></param> |
3189 | /// <param name="localID"></param> | 3775 | /// <param name="localID"></param> |
3776 | /// | ||
3777 | |||
3190 | public void UpdateSinglePosition(Vector3 pos, uint localID) | 3778 | public void UpdateSinglePosition(Vector3 pos, uint localID) |
3191 | { | 3779 | { |
3192 | SceneObjectPart part = GetPart(localID); | 3780 | SceneObjectPart part = GetPart(localID); |
3193 | 3781 | ||
3194 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3195 | // for (int i = 0; i < parts.Length; i++) | ||
3196 | // parts[i].StoreUndoState(); | ||
3197 | |||
3198 | if (part != null) | 3782 | if (part != null) |
3199 | { | 3783 | { |
3200 | // m_log.DebugFormat( | 3784 | // unlock parts position change |
3201 | // "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); | 3785 | if (m_rootPart.PhysActor != null) |
3202 | 3786 | m_rootPart.PhysActor.Building = true; | |
3203 | part.StoreUndoState(false); | ||
3204 | part.IgnoreUndoUpdate = true; | ||
3205 | 3787 | ||
3206 | if (part.UUID == m_rootPart.UUID) | 3788 | if (part.UUID == m_rootPart.UUID) |
3207 | { | 3789 | { |
@@ -3212,8 +3794,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3212 | part.UpdateOffSet(pos); | 3794 | part.UpdateOffSet(pos); |
3213 | } | 3795 | } |
3214 | 3796 | ||
3797 | if (m_rootPart.PhysActor != null) | ||
3798 | m_rootPart.PhysActor.Building = false; | ||
3799 | |||
3215 | HasGroupChanged = true; | 3800 | HasGroupChanged = true; |
3216 | part.IgnoreUndoUpdate = false; | ||
3217 | } | 3801 | } |
3218 | } | 3802 | } |
3219 | 3803 | ||
@@ -3223,13 +3807,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3223 | /// <param name="newPos"></param> | 3807 | /// <param name="newPos"></param> |
3224 | public void UpdateRootPosition(Vector3 newPos) | 3808 | public void UpdateRootPosition(Vector3 newPos) |
3225 | { | 3809 | { |
3226 | // m_log.DebugFormat( | 3810 | // needs to be called with phys building true |
3227 | // "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); | ||
3228 | |||
3229 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3230 | // for (int i = 0; i < parts.Length; i++) | ||
3231 | // parts[i].StoreUndoState(); | ||
3232 | |||
3233 | Vector3 oldPos; | 3811 | Vector3 oldPos; |
3234 | 3812 | ||
3235 | // FIXME: This improves the situation where editing just the root prim of an attached object would send | 3813 | // FIXME: This improves the situation where editing just the root prim of an attached object would send |
@@ -3255,7 +3833,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3255 | AbsolutePosition = newPos; | 3833 | AbsolutePosition = newPos; |
3256 | 3834 | ||
3257 | HasGroupChanged = true; | 3835 | HasGroupChanged = true; |
3258 | ScheduleGroupForTerseUpdate(); | 3836 | if (m_rootPart.Undoing) |
3837 | { | ||
3838 | ScheduleGroupForFullUpdate(); | ||
3839 | } | ||
3840 | else | ||
3841 | { | ||
3842 | ScheduleGroupForTerseUpdate(); | ||
3843 | } | ||
3259 | } | 3844 | } |
3260 | 3845 | ||
3261 | #endregion | 3846 | #endregion |
@@ -3268,24 +3853,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3268 | /// <param name="rot"></param> | 3853 | /// <param name="rot"></param> |
3269 | public void UpdateGroupRotationR(Quaternion rot) | 3854 | public void UpdateGroupRotationR(Quaternion rot) |
3270 | { | 3855 | { |
3271 | // m_log.DebugFormat( | ||
3272 | // "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); | ||
3273 | |||
3274 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3275 | // for (int i = 0; i < parts.Length; i++) | ||
3276 | // parts[i].StoreUndoState(); | ||
3277 | |||
3278 | m_rootPart.StoreUndoState(true); | ||
3279 | |||
3280 | m_rootPart.UpdateRotation(rot); | 3856 | m_rootPart.UpdateRotation(rot); |
3281 | 3857 | ||
3858 | /* this is done by rootpart RotationOffset set called by UpdateRotation | ||
3282 | PhysicsActor actor = m_rootPart.PhysActor; | 3859 | PhysicsActor actor = m_rootPart.PhysActor; |
3283 | if (actor != null) | 3860 | if (actor != null) |
3284 | { | 3861 | { |
3285 | actor.Orientation = m_rootPart.RotationOffset; | 3862 | actor.Orientation = m_rootPart.RotationOffset; |
3286 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); | 3863 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
3287 | } | 3864 | } |
3288 | 3865 | */ | |
3289 | HasGroupChanged = true; | 3866 | HasGroupChanged = true; |
3290 | ScheduleGroupForTerseUpdate(); | 3867 | ScheduleGroupForTerseUpdate(); |
3291 | } | 3868 | } |
@@ -3297,16 +3874,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3297 | /// <param name="rot"></param> | 3874 | /// <param name="rot"></param> |
3298 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) | 3875 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) |
3299 | { | 3876 | { |
3300 | // m_log.DebugFormat( | ||
3301 | // "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); | ||
3302 | |||
3303 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3304 | // for (int i = 0; i < parts.Length; i++) | ||
3305 | // parts[i].StoreUndoState(); | ||
3306 | |||
3307 | RootPart.StoreUndoState(true); | ||
3308 | RootPart.IgnoreUndoUpdate = true; | ||
3309 | |||
3310 | m_rootPart.UpdateRotation(rot); | 3877 | m_rootPart.UpdateRotation(rot); |
3311 | 3878 | ||
3312 | PhysicsActor actor = m_rootPart.PhysActor; | 3879 | PhysicsActor actor = m_rootPart.PhysActor; |
@@ -3325,8 +3892,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3325 | 3892 | ||
3326 | HasGroupChanged = true; | 3893 | HasGroupChanged = true; |
3327 | ScheduleGroupForTerseUpdate(); | 3894 | ScheduleGroupForTerseUpdate(); |
3328 | |||
3329 | RootPart.IgnoreUndoUpdate = false; | ||
3330 | } | 3895 | } |
3331 | 3896 | ||
3332 | /// <summary> | 3897 | /// <summary> |
@@ -3339,13 +3904,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3339 | SceneObjectPart part = GetPart(localID); | 3904 | SceneObjectPart part = GetPart(localID); |
3340 | 3905 | ||
3341 | SceneObjectPart[] parts = m_parts.GetArray(); | 3906 | SceneObjectPart[] parts = m_parts.GetArray(); |
3342 | for (int i = 0; i < parts.Length; i++) | ||
3343 | parts[i].StoreUndoState(); | ||
3344 | 3907 | ||
3345 | if (part != null) | 3908 | if (part != null) |
3346 | { | 3909 | { |
3347 | // m_log.DebugFormat( | 3910 | if (m_rootPart.PhysActor != null) |
3348 | // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); | 3911 | m_rootPart.PhysActor.Building = true; |
3349 | 3912 | ||
3350 | if (part.UUID == m_rootPart.UUID) | 3913 | if (part.UUID == m_rootPart.UUID) |
3351 | { | 3914 | { |
@@ -3355,6 +3918,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3355 | { | 3918 | { |
3356 | part.UpdateRotation(rot); | 3919 | part.UpdateRotation(rot); |
3357 | } | 3920 | } |
3921 | |||
3922 | if (m_rootPart.PhysActor != null) | ||
3923 | m_rootPart.PhysActor.Building = false; | ||
3358 | } | 3924 | } |
3359 | } | 3925 | } |
3360 | 3926 | ||
@@ -3368,12 +3934,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3368 | SceneObjectPart part = GetPart(localID); | 3934 | SceneObjectPart part = GetPart(localID); |
3369 | if (part != null) | 3935 | if (part != null) |
3370 | { | 3936 | { |
3371 | // m_log.DebugFormat( | 3937 | if (m_rootPart.PhysActor != null) |
3372 | // "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", | 3938 | m_rootPart.PhysActor.Building = true; |
3373 | // part.Name, part.LocalId, rot); | ||
3374 | |||
3375 | part.StoreUndoState(); | ||
3376 | part.IgnoreUndoUpdate = true; | ||
3377 | 3939 | ||
3378 | if (part.UUID == m_rootPart.UUID) | 3940 | if (part.UUID == m_rootPart.UUID) |
3379 | { | 3941 | { |
@@ -3386,7 +3948,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3386 | part.OffsetPosition = pos; | 3948 | part.OffsetPosition = pos; |
3387 | } | 3949 | } |
3388 | 3950 | ||
3389 | part.IgnoreUndoUpdate = false; | 3951 | if (m_rootPart.PhysActor != null) |
3952 | m_rootPart.PhysActor.Building = false; | ||
3390 | } | 3953 | } |
3391 | } | 3954 | } |
3392 | 3955 | ||
@@ -3396,15 +3959,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3396 | /// <param name="rot"></param> | 3959 | /// <param name="rot"></param> |
3397 | public void UpdateRootRotation(Quaternion rot) | 3960 | public void UpdateRootRotation(Quaternion rot) |
3398 | { | 3961 | { |
3399 | // m_log.DebugFormat( | 3962 | // needs to be called with phys building true |
3400 | // "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", | ||
3401 | // Name, LocalId, rot); | ||
3402 | |||
3403 | Quaternion axRot = rot; | 3963 | Quaternion axRot = rot; |
3404 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 3964 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
3405 | 3965 | ||
3406 | m_rootPart.StoreUndoState(); | 3966 | //Don't use UpdateRotation because it schedules an update prematurely |
3407 | m_rootPart.UpdateRotation(rot); | 3967 | m_rootPart.RotationOffset = rot; |
3408 | 3968 | ||
3409 | PhysicsActor pa = m_rootPart.PhysActor; | 3969 | PhysicsActor pa = m_rootPart.PhysActor; |
3410 | 3970 | ||
@@ -3420,35 +3980,145 @@ namespace OpenSim.Region.Framework.Scenes | |||
3420 | SceneObjectPart prim = parts[i]; | 3980 | SceneObjectPart prim = parts[i]; |
3421 | if (prim.UUID != m_rootPart.UUID) | 3981 | if (prim.UUID != m_rootPart.UUID) |
3422 | { | 3982 | { |
3423 | prim.IgnoreUndoUpdate = true; | 3983 | Quaternion NewRot = oldParentRot * prim.RotationOffset; |
3984 | NewRot = Quaternion.Inverse(axRot) * NewRot; | ||
3985 | prim.RotationOffset = NewRot; | ||
3986 | |||
3424 | Vector3 axPos = prim.OffsetPosition; | 3987 | Vector3 axPos = prim.OffsetPosition; |
3988 | |||
3425 | axPos *= oldParentRot; | 3989 | axPos *= oldParentRot; |
3426 | axPos *= Quaternion.Inverse(axRot); | 3990 | axPos *= Quaternion.Inverse(axRot); |
3427 | prim.OffsetPosition = axPos; | 3991 | prim.OffsetPosition = axPos; |
3428 | Quaternion primsRot = prim.RotationOffset; | 3992 | } |
3429 | Quaternion newRot = oldParentRot * primsRot; | 3993 | } |
3430 | newRot = Quaternion.Inverse(axRot) * newRot; | ||
3431 | prim.RotationOffset = newRot; | ||
3432 | prim.ScheduleTerseUpdate(); | ||
3433 | prim.IgnoreUndoUpdate = false; | ||
3434 | } | ||
3435 | } | ||
3436 | |||
3437 | // for (int i = 0; i < parts.Length; i++) | ||
3438 | // { | ||
3439 | // SceneObjectPart childpart = parts[i]; | ||
3440 | // if (childpart != m_rootPart) | ||
3441 | // { | ||
3442 | //// childpart.IgnoreUndoUpdate = false; | ||
3443 | //// childpart.StoreUndoState(); | ||
3444 | // } | ||
3445 | // } | ||
3446 | 3994 | ||
3447 | m_rootPart.ScheduleTerseUpdate(); | 3995 | HasGroupChanged = true; |
3996 | ScheduleGroupForFullUpdate(); | ||
3997 | } | ||
3448 | 3998 | ||
3449 | // m_log.DebugFormat( | 3999 | private enum updatetype :int |
3450 | // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", | 4000 | { |
3451 | // Name, LocalId, rot); | 4001 | none = 0, |
4002 | partterse = 1, | ||
4003 | partfull = 2, | ||
4004 | groupterse = 3, | ||
4005 | groupfull = 4 | ||
4006 | } | ||
4007 | |||
4008 | public void doChangeObject(SceneObjectPart part, ObjectChangeData data) | ||
4009 | { | ||
4010 | // TODO this still as excessive *.Schedule*Update()s | ||
4011 | |||
4012 | if (part != null && part.ParentGroup != null) | ||
4013 | { | ||
4014 | ObjectChangeType change = data.change; | ||
4015 | bool togroup = ((change & ObjectChangeType.Group) != 0); | ||
4016 | // bool uniform = ((what & ObjectChangeType.UniformScale) != 0); not in use | ||
4017 | |||
4018 | SceneObjectGroup group = part.ParentGroup; | ||
4019 | PhysicsActor pha = group.RootPart.PhysActor; | ||
4020 | |||
4021 | updatetype updateType = updatetype.none; | ||
4022 | |||
4023 | if (togroup) | ||
4024 | { | ||
4025 | // related to group | ||
4026 | if ((change & (ObjectChangeType.Rotation | ObjectChangeType.Position)) != 0) | ||
4027 | { | ||
4028 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4029 | { | ||
4030 | group.RootPart.UpdateRotation(data.rotation); | ||
4031 | updateType = updatetype.none; | ||
4032 | } | ||
4033 | if ((change & ObjectChangeType.Position) != 0) | ||
4034 | { | ||
4035 | if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) | ||
4036 | UpdateGroupPosition(data.position); | ||
4037 | updateType = updatetype.groupterse; | ||
4038 | } | ||
4039 | else | ||
4040 | // ugly rotation update of all parts | ||
4041 | { | ||
4042 | group.ResetChildPrimPhysicsPositions(); | ||
4043 | } | ||
4044 | |||
4045 | } | ||
4046 | if ((change & ObjectChangeType.Scale) != 0) | ||
4047 | { | ||
4048 | if (pha != null) | ||
4049 | pha.Building = true; | ||
4050 | |||
4051 | group.GroupResize(data.scale); | ||
4052 | updateType = updatetype.none; | ||
4053 | |||
4054 | if (pha != null) | ||
4055 | pha.Building = false; | ||
4056 | } | ||
4057 | } | ||
4058 | else | ||
4059 | { | ||
4060 | // related to single prim in a link-set ( ie group) | ||
4061 | if (pha != null) | ||
4062 | pha.Building = true; | ||
4063 | |||
4064 | // root part is special | ||
4065 | // parts offset positions or rotations need to change also | ||
4066 | |||
4067 | if (part == group.RootPart) | ||
4068 | { | ||
4069 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4070 | group.UpdateRootRotation(data.rotation); | ||
4071 | if ((change & ObjectChangeType.Position) != 0) | ||
4072 | group.UpdateRootPosition(data.position); | ||
4073 | if ((change & ObjectChangeType.Scale) != 0) | ||
4074 | part.Resize(data.scale); | ||
4075 | } | ||
4076 | else | ||
4077 | { | ||
4078 | if ((change & ObjectChangeType.Position) != 0) | ||
4079 | { | ||
4080 | part.OffsetPosition = data.position; | ||
4081 | updateType = updatetype.partterse; | ||
4082 | } | ||
4083 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4084 | { | ||
4085 | part.UpdateRotation(data.rotation); | ||
4086 | updateType = updatetype.none; | ||
4087 | } | ||
4088 | if ((change & ObjectChangeType.Scale) != 0) | ||
4089 | { | ||
4090 | part.Resize(data.scale); | ||
4091 | updateType = updatetype.none; | ||
4092 | } | ||
4093 | } | ||
4094 | |||
4095 | if (pha != null) | ||
4096 | pha.Building = false; | ||
4097 | } | ||
4098 | |||
4099 | if (updateType != updatetype.none) | ||
4100 | { | ||
4101 | group.HasGroupChanged = true; | ||
4102 | |||
4103 | switch (updateType) | ||
4104 | { | ||
4105 | case updatetype.partterse: | ||
4106 | part.ScheduleTerseUpdate(); | ||
4107 | break; | ||
4108 | case updatetype.partfull: | ||
4109 | part.ScheduleFullUpdate(); | ||
4110 | break; | ||
4111 | case updatetype.groupterse: | ||
4112 | group.ScheduleGroupForTerseUpdate(); | ||
4113 | break; | ||
4114 | case updatetype.groupfull: | ||
4115 | group.ScheduleGroupForFullUpdate(); | ||
4116 | break; | ||
4117 | default: | ||
4118 | break; | ||
4119 | } | ||
4120 | } | ||
4121 | } | ||
3452 | } | 4122 | } |
3453 | 4123 | ||
3454 | #endregion | 4124 | #endregion |
@@ -3489,6 +4159,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3489 | waypoint.handle = handle; | 4159 | waypoint.handle = handle; |
3490 | lock (m_rotTargets) | 4160 | lock (m_rotTargets) |
3491 | { | 4161 | { |
4162 | if (m_rotTargets.Count >= 8) | ||
4163 | m_rotTargets.Remove(m_rotTargets.ElementAt(0).Key); | ||
3492 | m_rotTargets.Add(handle, waypoint); | 4164 | m_rotTargets.Add(handle, waypoint); |
3493 | } | 4165 | } |
3494 | m_scene.AddGroupTarget(this); | 4166 | m_scene.AddGroupTarget(this); |
@@ -3514,6 +4186,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3514 | waypoint.handle = handle; | 4186 | waypoint.handle = handle; |
3515 | lock (m_targets) | 4187 | lock (m_targets) |
3516 | { | 4188 | { |
4189 | if (m_targets.Count >= 8) | ||
4190 | m_targets.Remove(m_targets.ElementAt(0).Key); | ||
3517 | m_targets.Add(handle, waypoint); | 4191 | m_targets.Add(handle, waypoint); |
3518 | } | 4192 | } |
3519 | m_scene.AddGroupTarget(this); | 4193 | m_scene.AddGroupTarget(this); |
@@ -3547,10 +4221,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3547 | scriptPosTarget target = m_targets[idx]; | 4221 | scriptPosTarget target = m_targets[idx]; |
3548 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) | 4222 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) |
3549 | { | 4223 | { |
4224 | at_target = true; | ||
4225 | |||
3550 | // trigger at_target | 4226 | // trigger at_target |
3551 | if (m_scriptListens_atTarget) | 4227 | if (m_scriptListens_atTarget) |
3552 | { | 4228 | { |
3553 | at_target = true; | ||
3554 | scriptPosTarget att = new scriptPosTarget(); | 4229 | scriptPosTarget att = new scriptPosTarget(); |
3555 | att.targetPos = target.targetPos; | 4230 | att.targetPos = target.targetPos; |
3556 | att.tolerance = target.tolerance; | 4231 | att.tolerance = target.tolerance; |
@@ -3668,11 +4343,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
3668 | } | 4343 | } |
3669 | } | 4344 | } |
3670 | } | 4345 | } |
3671 | 4346 | ||
4347 | public Vector3 GetGeometricCenter() | ||
4348 | { | ||
4349 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
4350 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
4351 | // ignoring tortured prims details since sl also seems to ignore | ||
4352 | // so no real use in doing it on physics | ||
4353 | |||
4354 | Vector3 gc = Vector3.Zero; | ||
4355 | |||
4356 | int nparts = m_parts.Count; | ||
4357 | if (nparts <= 1) | ||
4358 | return gc; | ||
4359 | |||
4360 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4361 | nparts = parts.Length; // just in case it changed | ||
4362 | if (nparts <= 1) | ||
4363 | return gc; | ||
4364 | |||
4365 | Quaternion parentRot = RootPart.RotationOffset; | ||
4366 | Vector3 pPos; | ||
4367 | |||
4368 | // average all parts positions | ||
4369 | for (int i = 0; i < nparts; i++) | ||
4370 | { | ||
4371 | // do it directly | ||
4372 | // gc += parts[i].GetWorldPosition(); | ||
4373 | if (parts[i] != RootPart) | ||
4374 | { | ||
4375 | pPos = parts[i].OffsetPosition; | ||
4376 | gc += pPos; | ||
4377 | } | ||
4378 | |||
4379 | } | ||
4380 | gc /= nparts; | ||
4381 | |||
4382 | // relative to root: | ||
4383 | // gc -= AbsolutePosition; | ||
4384 | return gc; | ||
4385 | } | ||
4386 | |||
3672 | public float GetMass() | 4387 | public float GetMass() |
3673 | { | 4388 | { |
3674 | float retmass = 0f; | 4389 | float retmass = 0f; |
3675 | |||
3676 | SceneObjectPart[] parts = m_parts.GetArray(); | 4390 | SceneObjectPart[] parts = m_parts.GetArray(); |
3677 | for (int i = 0; i < parts.Length; i++) | 4391 | for (int i = 0; i < parts.Length; i++) |
3678 | retmass += parts[i].GetMass(); | 4392 | retmass += parts[i].GetMass(); |
@@ -3680,6 +4394,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3680 | return retmass; | 4394 | return retmass; |
3681 | } | 4395 | } |
3682 | 4396 | ||
4397 | // center of mass of full object | ||
4398 | public Vector3 GetCenterOfMass() | ||
4399 | { | ||
4400 | PhysicsActor pa = RootPart.PhysActor; | ||
4401 | |||
4402 | if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null) | ||
4403 | { | ||
4404 | // physics knows better about center of mass of physical prims | ||
4405 | Vector3 tmp = pa.CenterOfMass; | ||
4406 | return tmp; | ||
4407 | } | ||
4408 | |||
4409 | Vector3 Ptot = Vector3.Zero; | ||
4410 | float totmass = 0f; | ||
4411 | float m; | ||
4412 | |||
4413 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4414 | for (int i = 0; i < parts.Length; i++) | ||
4415 | { | ||
4416 | m = parts[i].GetMass(); | ||
4417 | Ptot += parts[i].GetPartCenterOfMass() * m; | ||
4418 | totmass += m; | ||
4419 | } | ||
4420 | |||
4421 | if (totmass == 0) | ||
4422 | totmass = 0; | ||
4423 | else | ||
4424 | totmass = 1 / totmass; | ||
4425 | Ptot *= totmass; | ||
4426 | |||
4427 | return Ptot; | ||
4428 | } | ||
4429 | |||
3683 | /// <summary> | 4430 | /// <summary> |
3684 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that | 4431 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that |
3685 | /// the physics engine can use it. | 4432 | /// the physics engine can use it. |
@@ -3859,6 +4606,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3859 | FromItemID = uuid; | 4606 | FromItemID = uuid; |
3860 | } | 4607 | } |
3861 | 4608 | ||
4609 | public void ResetOwnerChangeFlag() | ||
4610 | { | ||
4611 | ForEachPart(delegate(SceneObjectPart part) | ||
4612 | { | ||
4613 | part.ResetOwnerChangeFlag(); | ||
4614 | }); | ||
4615 | } | ||
4616 | |||
3862 | #endregion | 4617 | #endregion |
3863 | } | 4618 | } |
3864 | } | 4619 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ea9d0d8..5851ec6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -64,7 +64,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
64 | TELEPORT = 512, | 64 | TELEPORT = 512, |
65 | REGION_RESTART = 1024, | 65 | REGION_RESTART = 1024, |
66 | MEDIA = 2048, | 66 | MEDIA = 2048, |
67 | ANIMATION = 16384 | 67 | ANIMATION = 16384, |
68 | POSITION = 32768 | ||
68 | } | 69 | } |
69 | 70 | ||
70 | // I don't really know where to put this except here. | 71 | // I don't really know where to put this except here. |
@@ -123,7 +124,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
123 | /// Denote all sides of the prim | 124 | /// Denote all sides of the prim |
124 | /// </value> | 125 | /// </value> |
125 | public const int ALL_SIDES = -1; | 126 | public const int ALL_SIDES = -1; |
126 | 127 | ||
128 | private const scriptEvents PhysicsNeededSubsEvents = ( | ||
129 | scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | | ||
130 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
131 | ); | ||
132 | private const scriptEvents PhyscicsPhantonSubsEvents = ( | ||
133 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
134 | ); | ||
135 | private const scriptEvents PhyscicsVolumeDtcSubsEvents = ( | ||
136 | scriptEvents.collision_start | scriptEvents.collision_end | ||
137 | ); | ||
138 | |||
127 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 139 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
128 | 140 | ||
129 | /// <summary> | 141 | /// <summary> |
@@ -160,7 +172,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
160 | /// </remarks> | 172 | /// </remarks> |
161 | public bool IsRoot | 173 | public bool IsRoot |
162 | { | 174 | { |
163 | get { return ParentGroup.RootPart == this; } | 175 | get { return Object.ReferenceEquals(ParentGroup.RootPart, this); } |
164 | } | 176 | } |
165 | 177 | ||
166 | /// <summary> | 178 | /// <summary> |
@@ -233,6 +245,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
233 | 245 | ||
234 | public uint TimeStampTerse; | 246 | public uint TimeStampTerse; |
235 | 247 | ||
248 | // The following two are to hold the attachment data | ||
249 | // while an object is inworld | ||
250 | [XmlIgnore] | ||
251 | public byte AttachPoint = 0; | ||
252 | |||
253 | [XmlIgnore] | ||
254 | public Vector3 AttachOffset = Vector3.Zero; | ||
255 | |||
256 | [XmlIgnore] | ||
257 | public Quaternion AttachRotation = Quaternion.Identity; | ||
258 | |||
259 | [XmlIgnore] | ||
236 | public int STATUS_ROTATE_X; | 260 | public int STATUS_ROTATE_X; |
237 | 261 | ||
238 | public int STATUS_ROTATE_Y; | 262 | public int STATUS_ROTATE_Y; |
@@ -259,8 +283,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
259 | 283 | ||
260 | public Vector3 RotationAxis = Vector3.One; | 284 | public Vector3 RotationAxis = Vector3.One; |
261 | 285 | ||
262 | public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this | 286 | public bool VolumeDetectActive; |
263 | // Certainly this must be a persistant setting finally | ||
264 | 287 | ||
265 | public bool IsWaitingForFirstSpinUpdatePacket; | 288 | public bool IsWaitingForFirstSpinUpdatePacket; |
266 | 289 | ||
@@ -300,10 +323,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
300 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; | 323 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; |
301 | private Vector3 m_sitTargetPosition; | 324 | private Vector3 m_sitTargetPosition; |
302 | private string m_sitAnimation = "SIT"; | 325 | private string m_sitAnimation = "SIT"; |
326 | private bool m_occupied; // KF if any av is sitting on this prim | ||
303 | private string m_text = String.Empty; | 327 | private string m_text = String.Empty; |
304 | private string m_touchName = String.Empty; | 328 | private string m_touchName = String.Empty; |
305 | private readonly List<UndoState> m_undo = new List<UndoState>(5); | 329 | private UndoRedoState m_UndoRedo = null; |
306 | private readonly List<UndoState> m_redo = new List<UndoState>(5); | ||
307 | 330 | ||
308 | private bool m_passTouches = false; | 331 | private bool m_passTouches = false; |
309 | private bool m_passCollisions = false; | 332 | private bool m_passCollisions = false; |
@@ -331,14 +354,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
331 | protected Vector3 m_lastVelocity; | 354 | protected Vector3 m_lastVelocity; |
332 | protected Vector3 m_lastAcceleration; | 355 | protected Vector3 m_lastAcceleration; |
333 | protected Vector3 m_lastAngularVelocity; | 356 | protected Vector3 m_lastAngularVelocity; |
334 | protected int m_lastTerseSent; | 357 | protected int m_lastUpdateSentTime; |
358 | protected float m_buoyancy = 0.0f; | ||
359 | protected Vector3 m_force; | ||
360 | protected Vector3 m_torque; | ||
335 | 361 | ||
336 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; | 362 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; |
337 | protected float m_density = 1000.0f; // in kg/m^3 | 363 | protected float m_density = 1000.0f; // in kg/m^3 |
338 | protected float m_gravitymod = 1.0f; | 364 | protected float m_gravitymod = 1.0f; |
339 | protected float m_friction = 0.6f; // wood | 365 | protected float m_friction = 0.6f; // wood |
340 | protected float m_bounce = 0.5f; // wood | 366 | protected float m_bounce = 0.5f; // wood |
341 | 367 | ||
368 | |||
369 | protected bool m_isSelected = false; | ||
370 | |||
342 | /// <summary> | 371 | /// <summary> |
343 | /// Stores media texture data | 372 | /// Stores media texture data |
344 | /// </summary> | 373 | /// </summary> |
@@ -350,15 +379,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
350 | private Vector3 m_cameraAtOffset; | 379 | private Vector3 m_cameraAtOffset; |
351 | private bool m_forceMouselook; | 380 | private bool m_forceMouselook; |
352 | 381 | ||
353 | // TODO: Collision sound should have default. | 382 | |
383 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
384 | private sbyte m_collisionSoundType; | ||
354 | private UUID m_collisionSound; | 385 | private UUID m_collisionSound; |
355 | private float m_collisionSoundVolume; | 386 | private float m_collisionSoundVolume; |
356 | 387 | ||
388 | private int LastColSoundSentTime; | ||
389 | |||
390 | |||
391 | private SOPVehicle m_vehicleParams = null; | ||
392 | |||
357 | public KeyframeMotion KeyframeMotion | 393 | public KeyframeMotion KeyframeMotion |
358 | { | 394 | { |
359 | get; set; | 395 | get; set; |
360 | } | 396 | } |
361 | 397 | ||
398 | |||
362 | #endregion Fields | 399 | #endregion Fields |
363 | 400 | ||
364 | // ~SceneObjectPart() | 401 | // ~SceneObjectPart() |
@@ -388,6 +425,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
388 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 425 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
389 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log | 426 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log |
390 | m_inventory = new SceneObjectPartInventory(this); | 427 | m_inventory = new SceneObjectPartInventory(this); |
428 | LastColSoundSentTime = Util.EnvironmentTickCount(); | ||
391 | } | 429 | } |
392 | 430 | ||
393 | /// <summary> | 431 | /// <summary> |
@@ -402,7 +440,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
402 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, | 440 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, |
403 | Quaternion rotationOffset, Vector3 offsetPosition) : this() | 441 | Quaternion rotationOffset, Vector3 offsetPosition) : this() |
404 | { | 442 | { |
405 | m_name = "Primitive"; | 443 | m_name = "Object"; |
406 | 444 | ||
407 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); | 445 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); |
408 | LastOwnerID = CreatorID = OwnerID = ownerID; | 446 | LastOwnerID = CreatorID = OwnerID = ownerID; |
@@ -441,7 +479,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
441 | private uint _ownerMask = (uint)(PermissionMask.All | PermissionMask.Export); | 479 | private uint _ownerMask = (uint)(PermissionMask.All | PermissionMask.Export); |
442 | private uint _groupMask = (uint)PermissionMask.None; | 480 | private uint _groupMask = (uint)PermissionMask.None; |
443 | private uint _everyoneMask = (uint)PermissionMask.None; | 481 | private uint _everyoneMask = (uint)PermissionMask.None; |
444 | private uint _nextOwnerMask = (uint)PermissionMask.All; | 482 | private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); |
445 | private PrimFlags _flags = PrimFlags.None; | 483 | private PrimFlags _flags = PrimFlags.None; |
446 | private DateTime m_expires; | 484 | private DateTime m_expires; |
447 | private DateTime m_rezzed; | 485 | private DateTime m_rezzed; |
@@ -539,12 +577,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
539 | } | 577 | } |
540 | 578 | ||
541 | /// <value> | 579 | /// <value> |
542 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 580 | /// Get the inventory list |
543 | /// </value> | 581 | /// </value> |
544 | public TaskInventoryDictionary TaskInventory | 582 | public TaskInventoryDictionary TaskInventory |
545 | { | 583 | { |
546 | get { return m_inventory.Items; } | 584 | get { |
547 | set { m_inventory.Items = value; } | 585 | return m_inventory.Items; |
586 | } | ||
587 | set { | ||
588 | m_inventory.Items = value; | ||
589 | } | ||
548 | } | 590 | } |
549 | 591 | ||
550 | /// <summary> | 592 | /// <summary> |
@@ -594,20 +636,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
594 | } | 636 | } |
595 | } | 637 | } |
596 | 638 | ||
597 | public byte Material | ||
598 | { | ||
599 | get { return (byte) m_material; } | ||
600 | set | ||
601 | { | ||
602 | m_material = (Material)value; | ||
603 | |||
604 | PhysicsActor pa = PhysActor; | ||
605 | |||
606 | if (pa != null) | ||
607 | pa.SetMaterial((int)value); | ||
608 | } | ||
609 | } | ||
610 | |||
611 | [XmlIgnore] | 639 | [XmlIgnore] |
612 | public bool PassTouches | 640 | public bool PassTouches |
613 | { | 641 | { |
@@ -633,6 +661,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
633 | } | 661 | } |
634 | } | 662 | } |
635 | 663 | ||
664 | public bool IsSelected | ||
665 | { | ||
666 | get { return m_isSelected; } | ||
667 | set | ||
668 | { | ||
669 | m_isSelected = value; | ||
670 | if (ParentGroup != null) | ||
671 | ParentGroup.PartSelectChanged(value); | ||
672 | } | ||
673 | } | ||
674 | |||
675 | |||
636 | public Dictionary<int, string> CollisionFilter | 676 | public Dictionary<int, string> CollisionFilter |
637 | { | 677 | { |
638 | get { return m_CollisionFilter; } | 678 | get { return m_CollisionFilter; } |
@@ -701,14 +741,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
701 | set { m_LoopSoundSlavePrims = value; } | 741 | set { m_LoopSoundSlavePrims = value; } |
702 | } | 742 | } |
703 | 743 | ||
704 | |||
705 | public Byte[] TextureAnimation | 744 | public Byte[] TextureAnimation |
706 | { | 745 | { |
707 | get { return m_TextureAnimation; } | 746 | get { return m_TextureAnimation; } |
708 | set { m_TextureAnimation = value; } | 747 | set { m_TextureAnimation = value; } |
709 | } | 748 | } |
710 | 749 | ||
711 | |||
712 | public Byte[] ParticleSystem | 750 | public Byte[] ParticleSystem |
713 | { | 751 | { |
714 | get { return m_particleSystem; } | 752 | get { return m_particleSystem; } |
@@ -745,9 +783,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
745 | { | 783 | { |
746 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 784 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
747 | PhysicsActor actor = PhysActor; | 785 | PhysicsActor actor = PhysActor; |
748 | // If physical and the root prim of a linkset, the position of the group is what physics thinks. | 786 | if (ParentID == 0) |
749 | if (actor != null && ParentID == 0) | 787 | { |
750 | m_groupPosition = actor.Position; | 788 | if (actor != null) |
789 | m_groupPosition = actor.Position; | ||
790 | return m_groupPosition; | ||
791 | } | ||
751 | 792 | ||
752 | // If I'm an attachment, my position is reported as the position of who I'm attached to | 793 | // If I'm an attachment, my position is reported as the position of who I'm attached to |
753 | if (ParentGroup.IsAttachment) | 794 | if (ParentGroup.IsAttachment) |
@@ -757,14 +798,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
757 | return sp.AbsolutePosition; | 798 | return sp.AbsolutePosition; |
758 | } | 799 | } |
759 | 800 | ||
801 | // use root prim's group position. Physics may have updated it | ||
802 | if (ParentGroup.RootPart != this) | ||
803 | m_groupPosition = ParentGroup.RootPart.GroupPosition; | ||
760 | return m_groupPosition; | 804 | return m_groupPosition; |
761 | } | 805 | } |
762 | set | 806 | set |
763 | { | 807 | { |
764 | m_groupPosition = value; | 808 | m_groupPosition = value; |
765 | |||
766 | PhysicsActor actor = PhysActor; | 809 | PhysicsActor actor = PhysActor; |
767 | if (actor != null) | 810 | if (actor != null && ParentGroup.Scene.PhysicsScene != null) |
768 | { | 811 | { |
769 | try | 812 | try |
770 | { | 813 | { |
@@ -797,7 +840,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
797 | get { return m_offsetPosition; } | 840 | get { return m_offsetPosition; } |
798 | set | 841 | set |
799 | { | 842 | { |
800 | // StoreUndoState(); | 843 | Vector3 oldpos = m_offsetPosition; |
801 | m_offsetPosition = value; | 844 | m_offsetPosition = value; |
802 | 845 | ||
803 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 846 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
@@ -809,10 +852,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
809 | actor.Orientation = GetWorldRotation(); | 852 | actor.Orientation = GetWorldRotation(); |
810 | 853 | ||
811 | // Tell the physics engines that this prim changed. | 854 | // Tell the physics engines that this prim changed. |
812 | if (ParentGroup.Scene != null) | 855 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene != null) |
813 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 856 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
814 | } | 857 | } |
858 | |||
859 | if (!m_parentGroup.m_dupeInProgress) | ||
860 | { | ||
861 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); | ||
862 | foreach (ScenePresence av in avs) | ||
863 | { | ||
864 | if (av.ParentID == m_localId) | ||
865 | { | ||
866 | Vector3 offset = (m_offsetPosition - oldpos); | ||
867 | av.AbsolutePosition += offset; | ||
868 | av.SendAvatarDataToAllAgents(); | ||
869 | } | ||
870 | } | ||
871 | } | ||
815 | } | 872 | } |
873 | TriggerScriptChangedEvent(Changed.POSITION); | ||
816 | } | 874 | } |
817 | } | 875 | } |
818 | 876 | ||
@@ -863,7 +921,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
863 | 921 | ||
864 | set | 922 | set |
865 | { | 923 | { |
866 | StoreUndoState(); | 924 | // StoreUndoState(); |
867 | m_rotationOffset = value; | 925 | m_rotationOffset = value; |
868 | 926 | ||
869 | PhysicsActor actor = PhysActor; | 927 | PhysicsActor actor = PhysActor; |
@@ -951,19 +1009,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
951 | get | 1009 | get |
952 | { | 1010 | { |
953 | PhysicsActor actor = PhysActor; | 1011 | PhysicsActor actor = PhysActor; |
954 | if ((actor != null) && actor.IsPhysical) | 1012 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this) |
955 | { | 1013 | { |
956 | m_angularVelocity = actor.RotationalVelocity; | 1014 | m_angularVelocity = actor.RotationalVelocity; |
957 | } | 1015 | } |
958 | return m_angularVelocity; | 1016 | return m_angularVelocity; |
959 | } | 1017 | } |
960 | set { m_angularVelocity = value; } | 1018 | set |
1019 | { | ||
1020 | m_angularVelocity = value; | ||
1021 | PhysicsActor actor = PhysActor; | ||
1022 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this && VehicleType == (int)Vehicle.TYPE_NONE) | ||
1023 | { | ||
1024 | actor.RotationalVelocity = m_angularVelocity; | ||
1025 | } | ||
1026 | } | ||
961 | } | 1027 | } |
962 | 1028 | ||
963 | /// <summary></summary> | 1029 | /// <summary></summary> |
964 | public Vector3 Acceleration | 1030 | public Vector3 Acceleration |
965 | { | 1031 | { |
966 | get { return m_acceleration; } | 1032 | get |
1033 | { | ||
1034 | PhysicsActor actor = PhysActor; | ||
1035 | if (actor != null) | ||
1036 | { | ||
1037 | m_acceleration = actor.Acceleration; | ||
1038 | } | ||
1039 | return m_acceleration; | ||
1040 | } | ||
1041 | |||
967 | set { m_acceleration = value; } | 1042 | set { m_acceleration = value; } |
968 | } | 1043 | } |
969 | 1044 | ||
@@ -1031,7 +1106,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1031 | public PrimitiveBaseShape Shape | 1106 | public PrimitiveBaseShape Shape |
1032 | { | 1107 | { |
1033 | get { return m_shape; } | 1108 | get { return m_shape; } |
1034 | set { m_shape = value;} | 1109 | set |
1110 | { | ||
1111 | m_shape = value; | ||
1112 | } | ||
1035 | } | 1113 | } |
1036 | 1114 | ||
1037 | /// <summary> | 1115 | /// <summary> |
@@ -1044,7 +1122,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1044 | { | 1122 | { |
1045 | if (m_shape != null) | 1123 | if (m_shape != null) |
1046 | { | 1124 | { |
1047 | StoreUndoState(); | ||
1048 | 1125 | ||
1049 | m_shape.Scale = value; | 1126 | m_shape.Scale = value; |
1050 | 1127 | ||
@@ -1112,10 +1189,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1112 | { | 1189 | { |
1113 | get | 1190 | get |
1114 | { | 1191 | { |
1115 | if (ParentGroup.IsAttachment) | 1192 | return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); |
1116 | return GroupPosition; | ||
1117 | |||
1118 | return m_offsetPosition + m_groupPosition; | ||
1119 | } | 1193 | } |
1120 | } | 1194 | } |
1121 | 1195 | ||
@@ -1284,6 +1358,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1284 | _flags = value; | 1358 | _flags = value; |
1285 | } | 1359 | } |
1286 | } | 1360 | } |
1361 | |||
1362 | [XmlIgnore] | ||
1363 | public bool IsOccupied // KF If an av is sittingon this prim | ||
1364 | { | ||
1365 | get { return m_occupied; } | ||
1366 | set { m_occupied = value; } | ||
1367 | } | ||
1287 | 1368 | ||
1288 | /// <summary> | 1369 | /// <summary> |
1289 | /// ID of the avatar that is sat on us if we have a sit target. If there is no such avatar then is UUID.Zero | 1370 | /// ID of the avatar that is sat on us if we have a sit target. If there is no such avatar then is UUID.Zero |
@@ -1334,12 +1415,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1334 | set { m_sitAnimation = value; } | 1415 | set { m_sitAnimation = value; } |
1335 | } | 1416 | } |
1336 | 1417 | ||
1418 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); | ||
1419 | |||
1420 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
1421 | // runtime thing.. do not persist | ||
1422 | [XmlIgnore] | ||
1423 | public sbyte CollisionSoundType | ||
1424 | { | ||
1425 | get | ||
1426 | { | ||
1427 | return m_collisionSoundType; | ||
1428 | } | ||
1429 | set | ||
1430 | { | ||
1431 | m_collisionSoundType = value; | ||
1432 | if (value == -1) | ||
1433 | m_collisionSound = invalidCollisionSoundUUID; | ||
1434 | else if (value == 0) | ||
1435 | m_collisionSound = UUID.Zero; | ||
1436 | } | ||
1437 | } | ||
1438 | |||
1337 | public UUID CollisionSound | 1439 | public UUID CollisionSound |
1338 | { | 1440 | { |
1339 | get { return m_collisionSound; } | 1441 | get { return m_collisionSound; } |
1340 | set | 1442 | set |
1341 | { | 1443 | { |
1342 | m_collisionSound = value; | 1444 | m_collisionSound = value; |
1445 | |||
1446 | if (value == invalidCollisionSoundUUID) | ||
1447 | m_collisionSoundType = -1; | ||
1448 | else if (value == UUID.Zero) | ||
1449 | m_collisionSoundType = 0; | ||
1450 | else | ||
1451 | m_collisionSoundType = 1; | ||
1452 | |||
1343 | aggregateScriptEvents(); | 1453 | aggregateScriptEvents(); |
1344 | } | 1454 | } |
1345 | } | 1455 | } |
@@ -1350,6 +1460,125 @@ namespace OpenSim.Region.Framework.Scenes | |||
1350 | set { m_collisionSoundVolume = value; } | 1460 | set { m_collisionSoundVolume = value; } |
1351 | } | 1461 | } |
1352 | 1462 | ||
1463 | public float Buoyancy | ||
1464 | { | ||
1465 | get | ||
1466 | { | ||
1467 | if (ParentGroup.RootPart == this) | ||
1468 | return m_buoyancy; | ||
1469 | |||
1470 | return ParentGroup.RootPart.Buoyancy; | ||
1471 | } | ||
1472 | set | ||
1473 | { | ||
1474 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1475 | { | ||
1476 | ParentGroup.RootPart.Buoyancy = value; | ||
1477 | return; | ||
1478 | } | ||
1479 | m_buoyancy = value; | ||
1480 | if (PhysActor != null) | ||
1481 | PhysActor.Buoyancy = value; | ||
1482 | } | ||
1483 | } | ||
1484 | |||
1485 | public Vector3 Force | ||
1486 | { | ||
1487 | get | ||
1488 | { | ||
1489 | if (ParentGroup.RootPart == this) | ||
1490 | return m_force; | ||
1491 | |||
1492 | return ParentGroup.RootPart.Force; | ||
1493 | } | ||
1494 | |||
1495 | set | ||
1496 | { | ||
1497 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1498 | { | ||
1499 | ParentGroup.RootPart.Force = value; | ||
1500 | return; | ||
1501 | } | ||
1502 | m_force = value; | ||
1503 | if (PhysActor != null) | ||
1504 | PhysActor.Force = value; | ||
1505 | } | ||
1506 | } | ||
1507 | |||
1508 | public Vector3 Torque | ||
1509 | { | ||
1510 | get | ||
1511 | { | ||
1512 | if (ParentGroup.RootPart == this) | ||
1513 | return m_torque; | ||
1514 | |||
1515 | return ParentGroup.RootPart.Torque; | ||
1516 | } | ||
1517 | |||
1518 | set | ||
1519 | { | ||
1520 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1521 | { | ||
1522 | ParentGroup.RootPart.Torque = value; | ||
1523 | return; | ||
1524 | } | ||
1525 | m_torque = value; | ||
1526 | if (PhysActor != null) | ||
1527 | PhysActor.Torque = value; | ||
1528 | } | ||
1529 | } | ||
1530 | |||
1531 | public byte Material | ||
1532 | { | ||
1533 | get { return (byte)m_material; } | ||
1534 | set | ||
1535 | { | ||
1536 | if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial) | ||
1537 | { | ||
1538 | bool update = false; | ||
1539 | |||
1540 | if (m_material != (Material)value) | ||
1541 | { | ||
1542 | update = true; | ||
1543 | m_material = (Material)value; | ||
1544 | } | ||
1545 | |||
1546 | if (m_friction != SOPMaterialData.friction(m_material)) | ||
1547 | { | ||
1548 | update = true; | ||
1549 | m_friction = SOPMaterialData.friction(m_material); | ||
1550 | } | ||
1551 | |||
1552 | if (m_bounce != SOPMaterialData.bounce(m_material)) | ||
1553 | { | ||
1554 | update = true; | ||
1555 | m_bounce = SOPMaterialData.bounce(m_material); | ||
1556 | } | ||
1557 | |||
1558 | if (update) | ||
1559 | { | ||
1560 | if (PhysActor != null) | ||
1561 | { | ||
1562 | PhysActor.SetMaterial((int)value); | ||
1563 | } | ||
1564 | if(ParentGroup != null) | ||
1565 | ParentGroup.HasGroupChanged = true; | ||
1566 | ScheduleFullUpdateIfNone(); | ||
1567 | UpdatePhysRequired = true; | ||
1568 | } | ||
1569 | } | ||
1570 | } | ||
1571 | } | ||
1572 | |||
1573 | // not a propriety to move to methods place later | ||
1574 | private bool HasMesh() | ||
1575 | { | ||
1576 | if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) | ||
1577 | return true; | ||
1578 | return false; | ||
1579 | } | ||
1580 | |||
1581 | // not a propriety to move to methods place later | ||
1353 | public byte DefaultPhysicsShapeType() | 1582 | public byte DefaultPhysicsShapeType() |
1354 | { | 1583 | { |
1355 | byte type; | 1584 | byte type; |
@@ -1362,6 +1591,65 @@ namespace OpenSim.Region.Framework.Scenes | |||
1362 | return type; | 1591 | return type; |
1363 | } | 1592 | } |
1364 | 1593 | ||
1594 | [XmlIgnore] | ||
1595 | public bool UsesComplexCost | ||
1596 | { | ||
1597 | get | ||
1598 | { | ||
1599 | byte pst = PhysicsShapeType; | ||
1600 | if(pst == (byte) PhysShapeType.none || pst == (byte) PhysShapeType.convex || HasMesh()) | ||
1601 | return true; | ||
1602 | return false; | ||
1603 | } | ||
1604 | } | ||
1605 | |||
1606 | [XmlIgnore] | ||
1607 | public float PhysicsCost | ||
1608 | { | ||
1609 | get | ||
1610 | { | ||
1611 | if(PhysicsShapeType == (byte)PhysShapeType.none) | ||
1612 | return 0; | ||
1613 | |||
1614 | float cost = 0.1f; | ||
1615 | if (PhysActor != null) | ||
1616 | cost = PhysActor.PhysicsCost; | ||
1617 | else | ||
1618 | cost = 0.1f; | ||
1619 | |||
1620 | if ((Flags & PrimFlags.Physics) != 0) | ||
1621 | cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 | ||
1622 | return cost; | ||
1623 | } | ||
1624 | } | ||
1625 | |||
1626 | [XmlIgnore] | ||
1627 | public float StreamingCost | ||
1628 | { | ||
1629 | get | ||
1630 | { | ||
1631 | float cost; | ||
1632 | if (PhysActor != null) | ||
1633 | cost = PhysActor.StreamCost; | ||
1634 | else | ||
1635 | cost = 1.0f; | ||
1636 | return 1.0f; | ||
1637 | } | ||
1638 | } | ||
1639 | |||
1640 | [XmlIgnore] | ||
1641 | public float SimulationCost | ||
1642 | { | ||
1643 | get | ||
1644 | { | ||
1645 | // ignoring scripts. Don't like considering them for this | ||
1646 | if((Flags & PrimFlags.Physics) != 0) | ||
1647 | return 1.0f; | ||
1648 | |||
1649 | return 0.5f; | ||
1650 | } | ||
1651 | } | ||
1652 | |||
1365 | public byte PhysicsShapeType | 1653 | public byte PhysicsShapeType |
1366 | { | 1654 | { |
1367 | get { return m_physicsShapeType; } | 1655 | get { return m_physicsShapeType; } |
@@ -1395,11 +1683,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1395 | } | 1683 | } |
1396 | else if (PhysActor == null) | 1684 | else if (PhysActor == null) |
1397 | { | 1685 | { |
1398 | ApplyPhysics((uint)Flags, VolumeDetectActive); | 1686 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); |
1687 | UpdatePhysicsSubscribedEvents(); | ||
1399 | } | 1688 | } |
1400 | else | 1689 | else |
1401 | { | 1690 | { |
1402 | PhysActor.PhysicsShapeType = m_physicsShapeType; | 1691 | PhysActor.PhysicsShapeType = m_physicsShapeType; |
1692 | // if (Shape.SculptEntry) | ||
1693 | // CheckSculptAndLoad(); | ||
1403 | } | 1694 | } |
1404 | 1695 | ||
1405 | if (ParentGroup != null) | 1696 | if (ParentGroup != null) |
@@ -1501,6 +1792,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1501 | } | 1792 | } |
1502 | } | 1793 | } |
1503 | 1794 | ||
1795 | |||
1504 | #endregion Public Properties with only Get | 1796 | #endregion Public Properties with only Get |
1505 | 1797 | ||
1506 | private uint ApplyMask(uint val, bool set, uint mask) | 1798 | private uint ApplyMask(uint val, bool set, uint mask) |
@@ -1646,6 +1938,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1646 | } | 1938 | } |
1647 | } | 1939 | } |
1648 | 1940 | ||
1941 | // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future | ||
1942 | public void SetVelocity(Vector3 pVel, bool localGlobalTF) | ||
1943 | { | ||
1944 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
1945 | return; | ||
1946 | |||
1947 | if (ParentGroup.IsAttachment) | ||
1948 | return; // don't work on attachments (for now ??) | ||
1949 | |||
1950 | SceneObjectPart root = ParentGroup.RootPart; | ||
1951 | |||
1952 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
1953 | return; | ||
1954 | |||
1955 | PhysicsActor pa = root.PhysActor; | ||
1956 | |||
1957 | if (pa == null || !pa.IsPhysical) | ||
1958 | return; | ||
1959 | |||
1960 | if (localGlobalTF) | ||
1961 | { | ||
1962 | pVel = pVel * GetWorldRotation(); | ||
1963 | } | ||
1964 | |||
1965 | ParentGroup.Velocity = pVel; | ||
1966 | } | ||
1967 | |||
1968 | // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future | ||
1969 | public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF) | ||
1970 | { | ||
1971 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
1972 | return; | ||
1973 | |||
1974 | if (ParentGroup.IsAttachment) | ||
1975 | return; // don't work on attachments (for now ??) | ||
1976 | |||
1977 | SceneObjectPart root = ParentGroup.RootPart; | ||
1978 | |||
1979 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
1980 | return; | ||
1981 | |||
1982 | PhysicsActor pa = root.PhysActor; | ||
1983 | |||
1984 | if (pa == null || !pa.IsPhysical) | ||
1985 | return; | ||
1986 | |||
1987 | if (localGlobalTF) | ||
1988 | { | ||
1989 | pAngVel = pAngVel * GetWorldRotation(); | ||
1990 | } | ||
1991 | |||
1992 | root.AngularVelocity = pAngVel; | ||
1993 | } | ||
1994 | |||
1995 | |||
1649 | /// <summary> | 1996 | /// <summary> |
1650 | /// hook to the physics scene to apply angular impulse | 1997 | /// hook to the physics scene to apply angular impulse |
1651 | /// This is sent up to the group, which then finds the root prim | 1998 | /// This is sent up to the group, which then finds the root prim |
@@ -1666,7 +2013,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1666 | impulse = newimpulse; | 2013 | impulse = newimpulse; |
1667 | } | 2014 | } |
1668 | 2015 | ||
1669 | ParentGroup.applyAngularImpulse(impulse); | 2016 | ParentGroup.ApplyAngularImpulse(impulse); |
1670 | } | 2017 | } |
1671 | 2018 | ||
1672 | /// <summary> | 2019 | /// <summary> |
@@ -1676,20 +2023,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1676 | /// </summary> | 2023 | /// </summary> |
1677 | /// <param name="impulsei">Vector force</param> | 2024 | /// <param name="impulsei">Vector force</param> |
1678 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | 2025 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> |
1679 | public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) | 2026 | |
2027 | // this is actualy Set Torque.. keeping naming so not to edit lslapi also | ||
2028 | public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF) | ||
1680 | { | 2029 | { |
1681 | Vector3 impulse = impulsei; | 2030 | Vector3 torque = torquei; |
1682 | 2031 | ||
1683 | if (localGlobalTF) | 2032 | if (localGlobalTF) |
1684 | { | 2033 | { |
2034 | /* | ||
1685 | Quaternion grot = GetWorldRotation(); | 2035 | Quaternion grot = GetWorldRotation(); |
1686 | Quaternion AXgrot = grot; | 2036 | Quaternion AXgrot = grot; |
1687 | Vector3 AXimpulsei = impulsei; | 2037 | Vector3 AXimpulsei = impulsei; |
1688 | Vector3 newimpulse = AXimpulsei * AXgrot; | 2038 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1689 | impulse = newimpulse; | 2039 | */ |
2040 | torque *= GetWorldRotation(); | ||
1690 | } | 2041 | } |
1691 | 2042 | ||
1692 | ParentGroup.setAngularImpulse(impulse); | 2043 | Torque = torque; |
1693 | } | 2044 | } |
1694 | 2045 | ||
1695 | /// <summary> | 2046 | /// <summary> |
@@ -1697,7 +2048,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1697 | /// </summary> | 2048 | /// </summary> |
1698 | /// <param name="rootObjectFlags"></param> | 2049 | /// <param name="rootObjectFlags"></param> |
1699 | /// <param name="VolumeDetectActive"></param> | 2050 | /// <param name="VolumeDetectActive"></param> |
1700 | public void ApplyPhysics(uint rootObjectFlags, bool _VolumeDetectActive) | 2051 | /// <param name="building"></param> |
2052 | |||
2053 | public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building) | ||
1701 | { | 2054 | { |
1702 | VolumeDetectActive = _VolumeDetectActive; | 2055 | VolumeDetectActive = _VolumeDetectActive; |
1703 | 2056 | ||
@@ -1707,8 +2060,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1707 | if (PhysicsShapeType == (byte)PhysShapeType.none) | 2060 | if (PhysicsShapeType == (byte)PhysShapeType.none) |
1708 | return; | 2061 | return; |
1709 | 2062 | ||
1710 | bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; | 2063 | bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0; |
1711 | bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; | 2064 | bool isPhantom = (_ObjectFlags & (uint)PrimFlags.Phantom) != 0; |
1712 | 2065 | ||
1713 | if (_VolumeDetectActive) | 2066 | if (_VolumeDetectActive) |
1714 | isPhantom = true; | 2067 | isPhantom = true; |
@@ -1722,7 +2075,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1722 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment | 2075 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment |
1723 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) | 2076 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) |
1724 | { | 2077 | { |
1725 | AddToPhysics(isPhysical, isPhantom, isPhysical); | 2078 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); |
2079 | UpdatePhysicsSubscribedEvents(); // not sure if appliable here | ||
1726 | } | 2080 | } |
1727 | else | 2081 | else |
1728 | PhysActor = null; // just to be sure | 2082 | PhysActor = null; // just to be sure |
@@ -1777,6 +2131,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1777 | dupe.Category = Category; | 2131 | dupe.Category = Category; |
1778 | dupe.m_rezzed = m_rezzed; | 2132 | dupe.m_rezzed = m_rezzed; |
1779 | 2133 | ||
2134 | dupe.m_UndoRedo = null; | ||
2135 | dupe.m_isSelected = false; | ||
2136 | |||
2137 | dupe.IgnoreUndoUpdate = false; | ||
2138 | dupe.Undoing = false; | ||
2139 | |||
1780 | dupe.m_inventory = new SceneObjectPartInventory(dupe); | 2140 | dupe.m_inventory = new SceneObjectPartInventory(dupe); |
1781 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); | 2141 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); |
1782 | 2142 | ||
@@ -1792,6 +2152,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1792 | 2152 | ||
1793 | // Move afterwards ResetIDs as it clears the localID | 2153 | // Move afterwards ResetIDs as it clears the localID |
1794 | dupe.LocalId = localID; | 2154 | dupe.LocalId = localID; |
2155 | |||
1795 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. | 2156 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. |
1796 | dupe.LastOwnerID = OwnerID; | 2157 | dupe.LastOwnerID = OwnerID; |
1797 | 2158 | ||
@@ -1816,8 +2177,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1816 | */ | 2177 | */ |
1817 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); | 2178 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); |
1818 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); | 2179 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); |
2180 | // dupe.UpdatePhysicsSubscribedEvents(); // not sure... | ||
1819 | } | 2181 | } |
1820 | 2182 | ||
2183 | if (dupe.PhysActor != null) | ||
2184 | dupe.PhysActor.LocalID = localID; | ||
2185 | |||
1821 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); | 2186 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); |
1822 | 2187 | ||
1823 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); | 2188 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); |
@@ -1836,10 +2201,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1836 | { | 2201 | { |
1837 | if (asset != null) | 2202 | if (asset != null) |
1838 | SculptTextureCallback(asset); | 2203 | SculptTextureCallback(asset); |
1839 | else | 2204 | // else |
1840 | m_log.WarnFormat( | 2205 | // m_log.WarnFormat( |
1841 | "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", | 2206 | // "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", |
1842 | Name, UUID, id); | 2207 | // Name, UUID, id); |
1843 | } | 2208 | } |
1844 | */ | 2209 | */ |
1845 | /// <summary> | 2210 | /// <summary> |
@@ -1938,6 +2303,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1938 | 2303 | ||
1939 | /// <summary> | 2304 | /// <summary> |
1940 | /// Do a physics propery update for this part. | 2305 | /// Do a physics propery update for this part. |
2306 | /// now also updates phantom and volume detector | ||
1941 | /// </summary> | 2307 | /// </summary> |
1942 | /// <param name="UsePhysics"></param> | 2308 | /// <param name="UsePhysics"></param> |
1943 | /// <param name="isNew"></param> | 2309 | /// <param name="isNew"></param> |
@@ -1963,64 +2329,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
1963 | { | 2329 | { |
1964 | if (pa.IsPhysical) // implies UsePhysics==false for this block | 2330 | if (pa.IsPhysical) // implies UsePhysics==false for this block |
1965 | { | 2331 | { |
1966 | if (!isNew) | 2332 | if (!isNew) // implies UsePhysics==false for this block |
2333 | { | ||
1967 | ParentGroup.Scene.RemovePhysicalPrim(1); | 2334 | ParentGroup.Scene.RemovePhysicalPrim(1); |
1968 | 2335 | ||
1969 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | 2336 | Velocity = new Vector3(0, 0, 0); |
1970 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | 2337 | Acceleration = new Vector3(0, 0, 0); |
1971 | pa.delink(); | 2338 | if (ParentGroup.RootPart == this) |
2339 | AngularVelocity = new Vector3(0, 0, 0); | ||
1972 | 2340 | ||
1973 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) | 2341 | if (pa.Phantom && !VolumeDetectActive) |
1974 | { | 2342 | { |
1975 | // destroy all joints connected to this now deactivated body | 2343 | RemoveFromPhysics(); |
1976 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | 2344 | return; |
1977 | } | 2345 | } |
1978 | 2346 | ||
1979 | // stop client-side interpolation of all joint proxy objects that have just been deleted | 2347 | pa.IsPhysical = UsePhysics; |
1980 | // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback, | 2348 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; |
1981 | // which stops client-side interpolation of deactivated joint proxy objects. | 2349 | pa.OnOutOfBounds -= PhysicsOutOfBounds; |
2350 | pa.delink(); | ||
2351 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | ||
2352 | { | ||
2353 | // destroy all joints connected to this now deactivated body | ||
2354 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | ||
2355 | } | ||
2356 | } | ||
1982 | } | 2357 | } |
1983 | 2358 | ||
1984 | if (!UsePhysics && !isNew) | 2359 | if (pa.IsPhysical != UsePhysics) |
1985 | { | 2360 | pa.IsPhysical = UsePhysics; |
1986 | // reset velocity to 0 on physics switch-off. Without that, the client thinks the | ||
1987 | // prim still has velocity and continues to interpolate its position along the old | ||
1988 | // velocity-vector. | ||
1989 | Velocity = new Vector3(0, 0, 0); | ||
1990 | Acceleration = new Vector3(0, 0, 0); | ||
1991 | AngularVelocity = new Vector3(0, 0, 0); | ||
1992 | //RotationalVelocity = new Vector3(0, 0, 0); | ||
1993 | } | ||
1994 | 2361 | ||
1995 | pa.IsPhysical = UsePhysics; | 2362 | if (UsePhysics) |
2363 | { | ||
2364 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
2365 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2366 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2367 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
1996 | 2368 | ||
1997 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. | 2369 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
1998 | //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 2370 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; |
1999 | /// that's not wholesome. Had to make Scene public | ||
2000 | //PhysActor = null; | ||
2001 | 2371 | ||
2002 | if ((Flags & PrimFlags.Phantom) == 0) | 2372 | if (ParentID != 0 && ParentID != LocalId) |
2003 | { | ||
2004 | if (UsePhysics) | ||
2005 | { | 2373 | { |
2006 | if (ParentGroup.RootPart.KeyframeMotion != null) | 2374 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; |
2007 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2008 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2009 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
2010 | |||
2011 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | ||
2012 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
2013 | if (ParentID != 0 && ParentID != LocalId) | ||
2014 | { | ||
2015 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | ||
2016 | 2375 | ||
2017 | if (parentPa != null) | 2376 | if (parentPa != null) |
2018 | { | 2377 | { |
2019 | pa.link(parentPa); | 2378 | pa.link(parentPa); |
2020 | } | ||
2021 | } | 2379 | } |
2022 | } | 2380 | } |
2023 | } | 2381 | } |
2382 | } | ||
2383 | |||
2384 | bool phan = ((Flags & PrimFlags.Phantom) != 0); | ||
2385 | if (pa.Phantom != phan) | ||
2386 | pa.Phantom = phan; | ||
2387 | |||
2388 | // some engines dont' have this check still | ||
2389 | // if (VolumeDetectActive != pa.IsVolumeDtc) | ||
2390 | { | ||
2391 | if (VolumeDetectActive) | ||
2392 | pa.SetVolumeDetect(1); | ||
2393 | else | ||
2394 | pa.SetVolumeDetect(0); | ||
2024 | } | 2395 | } |
2025 | 2396 | ||
2026 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the | 2397 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the |
@@ -2139,42 +2510,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
2139 | 2510 | ||
2140 | public Vector3 GetGeometricCenter() | 2511 | public Vector3 GetGeometricCenter() |
2141 | { | 2512 | { |
2513 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
2514 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
2515 | // ignoring tortured prims details since sl also seems to ignore | ||
2516 | // so no real use in doing it on physics | ||
2517 | if (ParentGroup.IsDeleted) | ||
2518 | return new Vector3(0, 0, 0); | ||
2519 | |||
2520 | return ParentGroup.GetGeometricCenter(); | ||
2521 | } | ||
2522 | |||
2523 | public float GetMass() | ||
2524 | { | ||
2142 | PhysicsActor pa = PhysActor; | 2525 | PhysicsActor pa = PhysActor; |
2143 | 2526 | ||
2144 | if (pa != null) | 2527 | if (pa != null) |
2145 | return pa.GeometricCenter; | 2528 | return pa.Mass; |
2146 | else | 2529 | else |
2147 | return Vector3.Zero; | 2530 | return 0; |
2148 | } | 2531 | } |
2149 | 2532 | ||
2150 | public Vector3 GetCenterOfMass() | 2533 | public Vector3 GetCenterOfMass() |
2151 | { | 2534 | { |
2535 | if (ParentGroup.RootPart == this) | ||
2536 | { | ||
2537 | if (ParentGroup.IsDeleted) | ||
2538 | return AbsolutePosition; | ||
2539 | return ParentGroup.GetCenterOfMass(); | ||
2540 | } | ||
2541 | |||
2152 | PhysicsActor pa = PhysActor; | 2542 | PhysicsActor pa = PhysActor; |
2153 | 2543 | ||
2154 | if (pa != null) | 2544 | if (pa != null) |
2155 | return pa.CenterOfMass; | 2545 | { |
2546 | Vector3 tmp = pa.CenterOfMass; | ||
2547 | return tmp; | ||
2548 | } | ||
2156 | else | 2549 | else |
2157 | return Vector3.Zero; | 2550 | return AbsolutePosition; |
2158 | } | 2551 | } |
2159 | 2552 | ||
2160 | public float GetMass() | 2553 | public Vector3 GetPartCenterOfMass() |
2161 | { | 2554 | { |
2162 | PhysicsActor pa = PhysActor; | 2555 | PhysicsActor pa = PhysActor; |
2163 | 2556 | ||
2164 | if (pa != null) | 2557 | if (pa != null) |
2165 | return pa.Mass; | 2558 | { |
2559 | Vector3 tmp = pa.CenterOfMass; | ||
2560 | return tmp; | ||
2561 | } | ||
2166 | else | 2562 | else |
2167 | return 0; | 2563 | return AbsolutePosition; |
2168 | } | 2564 | } |
2169 | 2565 | ||
2566 | |||
2170 | public Vector3 GetForce() | 2567 | public Vector3 GetForce() |
2171 | { | 2568 | { |
2172 | PhysicsActor pa = PhysActor; | 2569 | return Force; |
2173 | |||
2174 | if (pa != null) | ||
2175 | return pa.Force; | ||
2176 | else | ||
2177 | return Vector3.Zero; | ||
2178 | } | 2570 | } |
2179 | 2571 | ||
2180 | /// <summary> | 2572 | /// <summary> |
@@ -2389,15 +2781,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2389 | 2781 | ||
2390 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) | 2782 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) |
2391 | { | 2783 | { |
2392 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) | 2784 | bool sendToRoot = true; |
2393 | { | 2785 | |
2394 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | 2786 | ColliderArgs LandCollidingMessage = new ColliderArgs(); |
2395 | List<DetectedObject> colliding = new List<DetectedObject>(); | 2787 | List<DetectedObject> colliding = new List<DetectedObject>(); |
2396 | 2788 | ||
2397 | colliding.Add(CreateDetObjectForGround()); | 2789 | colliding.Add(CreateDetObjectForGround()); |
2398 | LandCollidingMessage.Colliders = colliding; | 2790 | LandCollidingMessage.Colliders = colliding; |
2399 | 2791 | ||
2792 | if (Inventory.ContainsScripts()) | ||
2793 | { | ||
2794 | if (!PassCollisions) | ||
2795 | sendToRoot = false; | ||
2796 | } | ||
2797 | if ((ScriptEvents & ev) != 0) | ||
2400 | notify(LocalId, LandCollidingMessage); | 2798 | notify(LocalId, LandCollidingMessage); |
2799 | |||
2800 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot) | ||
2801 | { | ||
2802 | notify(ParentGroup.RootPart.LocalId, LandCollidingMessage); | ||
2401 | } | 2803 | } |
2402 | } | 2804 | } |
2403 | 2805 | ||
@@ -2413,44 +2815,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
2413 | List<uint> endedColliders = new List<uint>(); | 2815 | List<uint> endedColliders = new List<uint>(); |
2414 | List<uint> startedColliders = new List<uint>(); | 2816 | List<uint> startedColliders = new List<uint>(); |
2415 | 2817 | ||
2416 | // calculate things that started colliding this time | 2818 | if (collissionswith.Count == 0) |
2417 | // and build up list of colliders this time | ||
2418 | foreach (uint localid in collissionswith.Keys) | ||
2419 | { | 2819 | { |
2420 | thisHitColliders.Add(localid); | 2820 | if (m_lastColliders.Count == 0) |
2421 | if (!m_lastColliders.Contains(localid)) | 2821 | return; // nothing to do |
2422 | startedColliders.Add(localid); | ||
2423 | } | ||
2424 | 2822 | ||
2425 | // calculate things that ended colliding | 2823 | foreach (uint localID in m_lastColliders) |
2426 | foreach (uint localID in m_lastColliders) | 2824 | { |
2427 | { | ||
2428 | if (!thisHitColliders.Contains(localID)) | ||
2429 | endedColliders.Add(localID); | 2825 | endedColliders.Add(localID); |
2826 | } | ||
2827 | m_lastColliders.Clear(); | ||
2430 | } | 2828 | } |
2431 | 2829 | ||
2432 | //add the items that started colliding this time to the last colliders list. | 2830 | else |
2433 | foreach (uint localID in startedColliders) | 2831 | { |
2434 | m_lastColliders.Add(localID); | 2832 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); |
2833 | |||
2834 | // calculate things that started colliding this time | ||
2835 | // and build up list of colliders this time | ||
2836 | if (!VolumeDetectActive && CollisionSoundType >= 0) | ||
2837 | { | ||
2838 | CollisionForSoundInfo soundinfo; | ||
2839 | ContactPoint curcontact; | ||
2435 | 2840 | ||
2436 | // remove things that ended colliding from the last colliders list | 2841 | foreach (uint id in collissionswith.Keys) |
2437 | foreach (uint localID in endedColliders) | 2842 | { |
2438 | m_lastColliders.Remove(localID); | 2843 | thisHitColliders.Add(id); |
2844 | if (!m_lastColliders.Contains(id)) | ||
2845 | { | ||
2846 | startedColliders.Add(id); | ||
2439 | 2847 | ||
2440 | // play the sound. | 2848 | curcontact = collissionswith[id]; |
2441 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) | 2849 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) |
2442 | { | 2850 | { |
2443 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | 2851 | soundinfo = new CollisionForSoundInfo(); |
2444 | if (soundModule != null) | 2852 | soundinfo.colliderID = id; |
2853 | soundinfo.position = curcontact.Position; | ||
2854 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2855 | soundinfolist.Add(soundinfo); | ||
2856 | } | ||
2857 | } | ||
2858 | } | ||
2859 | } | ||
2860 | else | ||
2861 | { | ||
2862 | foreach (uint id in collissionswith.Keys) | ||
2863 | { | ||
2864 | thisHitColliders.Add(id); | ||
2865 | if (!m_lastColliders.Contains(id)) | ||
2866 | startedColliders.Add(id); | ||
2867 | } | ||
2868 | } | ||
2869 | |||
2870 | // calculate things that ended colliding | ||
2871 | foreach (uint localID in m_lastColliders) | ||
2445 | { | 2872 | { |
2446 | soundModule.SendSound(UUID, CollisionSound, | 2873 | if (!thisHitColliders.Contains(localID)) |
2447 | CollisionSoundVolume, true, 0, 0, false, | 2874 | endedColliders.Add(localID); |
2448 | false); | ||
2449 | } | 2875 | } |
2876 | |||
2877 | //add the items that started colliding this time to the last colliders list. | ||
2878 | foreach (uint localID in startedColliders) | ||
2879 | m_lastColliders.Add(localID); | ||
2880 | |||
2881 | // remove things that ended colliding from the last colliders list | ||
2882 | foreach (uint localID in endedColliders) | ||
2883 | m_lastColliders.Remove(localID); | ||
2884 | |||
2885 | // play sounds. | ||
2886 | if (soundinfolist.Count > 0) | ||
2887 | CollisionSounds.PartCollisionSound(this, soundinfolist); | ||
2450 | } | 2888 | } |
2451 | 2889 | ||
2452 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2890 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2453 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2891 | if (!VolumeDetectActive) |
2892 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | ||
2454 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2893 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2455 | 2894 | ||
2456 | if (startedColliders.Contains(0)) | 2895 | if (startedColliders.Contains(0)) |
@@ -2461,6 +2900,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
2461 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); | 2900 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); |
2462 | } | 2901 | } |
2463 | 2902 | ||
2903 | // The Collision sounds code calls this | ||
2904 | public void SendCollisionSound(UUID soundID, double volume, Vector3 position) | ||
2905 | { | ||
2906 | if (soundID == UUID.Zero) | ||
2907 | return; | ||
2908 | |||
2909 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | ||
2910 | if (soundModule == null) | ||
2911 | return; | ||
2912 | |||
2913 | if (volume > 1) | ||
2914 | volume = 1; | ||
2915 | if (volume < 0) | ||
2916 | volume = 0; | ||
2917 | |||
2918 | int now = Util.EnvironmentTickCount(); | ||
2919 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) | ||
2920 | return; | ||
2921 | |||
2922 | LastColSoundSentTime = now; | ||
2923 | |||
2924 | UUID ownerID = OwnerID; | ||
2925 | UUID objectID = ParentGroup.RootPart.UUID; | ||
2926 | UUID parentID = ParentGroup.UUID; | ||
2927 | ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; | ||
2928 | |||
2929 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 ); | ||
2930 | } | ||
2931 | |||
2464 | public void PhysicsOutOfBounds(Vector3 pos) | 2932 | public void PhysicsOutOfBounds(Vector3 pos) |
2465 | { | 2933 | { |
2466 | // Note: This is only being called on the root prim at this time. | 2934 | // Note: This is only being called on the root prim at this time. |
@@ -2482,9 +2950,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2482 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | 2950 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); |
2483 | 2951 | ||
2484 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | 2952 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) |
2485 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | 2953 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) |
2486 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | 2954 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) |
2487 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) | 2955 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) |
2488 | { | 2956 | { |
2489 | ParentGroup.AbsolutePosition = newpos; | 2957 | ParentGroup.AbsolutePosition = newpos; |
2490 | return; | 2958 | return; |
@@ -2790,6 +3258,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2790 | if (ParentGroup == null) | 3258 | if (ParentGroup == null) |
2791 | return; | 3259 | return; |
2792 | 3260 | ||
3261 | // Update the "last" values | ||
3262 | m_lastPosition = OffsetPosition; | ||
3263 | m_lastRotation = RotationOffset; | ||
3264 | m_lastVelocity = Velocity; | ||
3265 | m_lastAcceleration = Acceleration; | ||
3266 | m_lastAngularVelocity = AngularVelocity; | ||
3267 | m_lastUpdateSentTime = Environment.TickCount; | ||
3268 | |||
2793 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 3269 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2794 | { | 3270 | { |
2795 | SendFullUpdate(avatar.ControllingClient); | 3271 | SendFullUpdate(avatar.ControllingClient); |
@@ -2848,8 +3324,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2848 | { | 3324 | { |
2849 | const float ROTATION_TOLERANCE = 0.01f; | 3325 | const float ROTATION_TOLERANCE = 0.01f; |
2850 | const float VELOCITY_TOLERANCE = 0.001f; | 3326 | const float VELOCITY_TOLERANCE = 0.001f; |
2851 | const float POSITION_TOLERANCE = 0.05f; | 3327 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
2852 | const int TIME_MS_TOLERANCE = 3000; | 3328 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
2853 | 3329 | ||
2854 | switch (UpdateFlag) | 3330 | switch (UpdateFlag) |
2855 | { | 3331 | { |
@@ -2863,17 +3339,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2863 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || | 3339 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || |
2864 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || | 3340 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || |
2865 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 3341 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
2866 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 3342 | Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) |
2867 | { | 3343 | { |
2868 | SendTerseUpdateToAllClients(); | 3344 | SendTerseUpdateToAllClients(); |
2869 | 3345 | ||
2870 | // Update the "last" values | ||
2871 | m_lastPosition = OffsetPosition; | ||
2872 | m_lastRotation = RotationOffset; | ||
2873 | m_lastVelocity = Velocity; | ||
2874 | m_lastAcceleration = Acceleration; | ||
2875 | m_lastAngularVelocity = AngularVelocity; | ||
2876 | m_lastTerseSent = Environment.TickCount; | ||
2877 | } | 3346 | } |
2878 | break; | 3347 | break; |
2879 | } | 3348 | } |
@@ -2891,6 +3360,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2891 | /// </summary> | 3360 | /// </summary> |
2892 | public void SendTerseUpdateToAllClients() | 3361 | public void SendTerseUpdateToAllClients() |
2893 | { | 3362 | { |
3363 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3364 | return; | ||
3365 | |||
3366 | // Update the "last" values | ||
3367 | m_lastPosition = OffsetPosition; | ||
3368 | m_lastRotation = RotationOffset; | ||
3369 | m_lastVelocity = Velocity; | ||
3370 | m_lastAcceleration = Acceleration; | ||
3371 | m_lastAngularVelocity = AngularVelocity; | ||
3372 | m_lastUpdateSentTime = Environment.TickCount; | ||
3373 | |||
2894 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | 3374 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) |
2895 | { | 3375 | { |
2896 | SendTerseUpdateToClient(client); | 3376 | SendTerseUpdateToClient(client); |
@@ -2914,10 +3394,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2914 | 3394 | ||
2915 | public void SetBuoyancy(float fvalue) | 3395 | public void SetBuoyancy(float fvalue) |
2916 | { | 3396 | { |
2917 | PhysicsActor pa = PhysActor; | 3397 | Buoyancy = fvalue; |
2918 | 3398 | /* | |
2919 | if (pa != null) | 3399 | if (PhysActor != null) |
2920 | pa.Buoyancy = fvalue; | 3400 | { |
3401 | PhysActor.Buoyancy = fvalue; | ||
3402 | } | ||
3403 | */ | ||
2921 | } | 3404 | } |
2922 | 3405 | ||
2923 | public void SetDieAtEdge(bool p) | 3406 | public void SetDieAtEdge(bool p) |
@@ -2933,47 +3416,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2933 | PhysicsActor pa = PhysActor; | 3416 | PhysicsActor pa = PhysActor; |
2934 | 3417 | ||
2935 | if (pa != null) | 3418 | if (pa != null) |
2936 | pa.FloatOnWater = floatYN == 1; | 3419 | pa.FloatOnWater = (floatYN == 1); |
2937 | } | 3420 | } |
2938 | 3421 | ||
2939 | public void SetForce(Vector3 force) | 3422 | public void SetForce(Vector3 force) |
2940 | { | 3423 | { |
2941 | PhysicsActor pa = PhysActor; | 3424 | Force = force; |
3425 | } | ||
2942 | 3426 | ||
2943 | if (pa != null) | 3427 | public SOPVehicle VehicleParams |
2944 | pa.Force = force; | 3428 | { |
3429 | get | ||
3430 | { | ||
3431 | return m_vehicleParams; | ||
3432 | } | ||
3433 | set | ||
3434 | { | ||
3435 | m_vehicleParams = value; | ||
3436 | } | ||
3437 | } | ||
3438 | |||
3439 | |||
3440 | public int VehicleType | ||
3441 | { | ||
3442 | get | ||
3443 | { | ||
3444 | if (m_vehicleParams == null) | ||
3445 | return (int)Vehicle.TYPE_NONE; | ||
3446 | else | ||
3447 | return (int)m_vehicleParams.Type; | ||
3448 | } | ||
3449 | set | ||
3450 | { | ||
3451 | SetVehicleType(value); | ||
3452 | } | ||
2945 | } | 3453 | } |
2946 | 3454 | ||
2947 | public void SetVehicleType(int type) | 3455 | public void SetVehicleType(int type) |
2948 | { | 3456 | { |
2949 | PhysicsActor pa = PhysActor; | 3457 | m_vehicleParams = null; |
3458 | |||
3459 | if (type == (int)Vehicle.TYPE_NONE) | ||
3460 | { | ||
3461 | if (_parentID ==0 && PhysActor != null) | ||
3462 | PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; | ||
3463 | return; | ||
3464 | } | ||
3465 | m_vehicleParams = new SOPVehicle(); | ||
3466 | m_vehicleParams.ProcessTypeChange((Vehicle)type); | ||
3467 | { | ||
3468 | if (_parentID ==0 && PhysActor != null) | ||
3469 | PhysActor.VehicleType = type; | ||
3470 | return; | ||
3471 | } | ||
3472 | } | ||
2950 | 3473 | ||
2951 | if (pa != null) | 3474 | public void SetVehicleFlags(int param, bool remove) |
2952 | pa.VehicleType = type; | 3475 | { |
3476 | if (m_vehicleParams == null) | ||
3477 | return; | ||
3478 | |||
3479 | m_vehicleParams.ProcessVehicleFlags(param, remove); | ||
3480 | |||
3481 | if (_parentID ==0 && PhysActor != null) | ||
3482 | { | ||
3483 | PhysActor.VehicleFlags(param, remove); | ||
3484 | } | ||
2953 | } | 3485 | } |
2954 | 3486 | ||
2955 | public void SetVehicleFloatParam(int param, float value) | 3487 | public void SetVehicleFloatParam(int param, float value) |
2956 | { | 3488 | { |
2957 | PhysicsActor pa = PhysActor; | 3489 | if (m_vehicleParams == null) |
3490 | return; | ||
2958 | 3491 | ||
2959 | if (pa != null) | 3492 | m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value); |
2960 | pa.VehicleFloatParam(param, value); | 3493 | |
3494 | if (_parentID == 0 && PhysActor != null) | ||
3495 | { | ||
3496 | PhysActor.VehicleFloatParam(param, value); | ||
3497 | } | ||
2961 | } | 3498 | } |
2962 | 3499 | ||
2963 | public void SetVehicleVectorParam(int param, Vector3 value) | 3500 | public void SetVehicleVectorParam(int param, Vector3 value) |
2964 | { | 3501 | { |
2965 | PhysicsActor pa = PhysActor; | 3502 | if (m_vehicleParams == null) |
3503 | return; | ||
2966 | 3504 | ||
2967 | if (pa != null) | 3505 | m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value); |
2968 | pa.VehicleVectorParam(param, value); | 3506 | |
3507 | if (_parentID == 0 && PhysActor != null) | ||
3508 | { | ||
3509 | PhysActor.VehicleVectorParam(param, value); | ||
3510 | } | ||
2969 | } | 3511 | } |
2970 | 3512 | ||
2971 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 3513 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
2972 | { | 3514 | { |
2973 | PhysicsActor pa = PhysActor; | 3515 | if (m_vehicleParams == null) |
3516 | return; | ||
2974 | 3517 | ||
2975 | if (pa != null) | 3518 | m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation); |
2976 | pa.VehicleRotationParam(param, rotation); | 3519 | |
3520 | if (_parentID == 0 && PhysActor != null) | ||
3521 | { | ||
3522 | PhysActor.VehicleRotationParam(param, rotation); | ||
3523 | } | ||
2977 | } | 3524 | } |
2978 | 3525 | ||
2979 | /// <summary> | 3526 | /// <summary> |
@@ -3174,14 +3721,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3174 | hasProfileCut = hasDimple; // is it the same thing? | 3721 | hasProfileCut = hasDimple; // is it the same thing? |
3175 | } | 3722 | } |
3176 | 3723 | ||
3177 | public void SetVehicleFlags(int param, bool remove) | ||
3178 | { | ||
3179 | PhysicsActor pa = PhysActor; | ||
3180 | |||
3181 | if (pa != null) | ||
3182 | pa.VehicleFlags(param, remove); | ||
3183 | } | ||
3184 | |||
3185 | public void SetGroup(UUID groupID, IClientAPI client) | 3724 | public void SetGroup(UUID groupID, IClientAPI client) |
3186 | { | 3725 | { |
3187 | // Scene.AddNewPrims() calls with client == null so can't use this. | 3726 | // Scene.AddNewPrims() calls with client == null so can't use this. |
@@ -3285,71 +3824,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3285 | { | 3824 | { |
3286 | ParentGroup.stopMoveToTarget(); | 3825 | ParentGroup.stopMoveToTarget(); |
3287 | 3826 | ||
3288 | ParentGroup.ScheduleGroupForTerseUpdate(); | 3827 | // ParentGroup.ScheduleGroupForTerseUpdate(); |
3289 | //ParentGroup.ScheduleGroupForFullUpdate(); | 3828 | //ParentGroup.ScheduleGroupForFullUpdate(); |
3290 | } | 3829 | } |
3291 | 3830 | ||
3292 | public void StoreUndoState() | 3831 | public void StoreUndoState(ObjectChangeType change) |
3293 | { | ||
3294 | StoreUndoState(false); | ||
3295 | } | ||
3296 | |||
3297 | public void StoreUndoState(bool forGroup) | ||
3298 | { | 3832 | { |
3299 | if (ParentGroup == null || ParentGroup.Scene == null) | 3833 | if (m_UndoRedo == null) |
3300 | return; | 3834 | m_UndoRedo = new UndoRedoState(5); |
3301 | |||
3302 | if (Undoing) | ||
3303 | { | ||
3304 | // m_log.DebugFormat( | ||
3305 | // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); | ||
3306 | return; | ||
3307 | } | ||
3308 | |||
3309 | if (IgnoreUndoUpdate) | ||
3310 | { | ||
3311 | // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); | ||
3312 | return; | ||
3313 | } | ||
3314 | 3835 | ||
3315 | lock (m_undo) | 3836 | lock (m_UndoRedo) |
3316 | { | 3837 | { |
3317 | if (m_undo.Count > 0) | 3838 | if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended |
3318 | { | ||
3319 | UndoState last = m_undo[m_undo.Count - 1]; | ||
3320 | if (last != null) | ||
3321 | { | ||
3322 | // TODO: May need to fix for group comparison | ||
3323 | if (last.Compare(this)) | ||
3324 | { | ||
3325 | // m_log.DebugFormat( | ||
3326 | // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", | ||
3327 | // Name, LocalId, m_undo.Count); | ||
3328 | |||
3329 | return; | ||
3330 | } | ||
3331 | } | ||
3332 | } | ||
3333 | |||
3334 | // m_log.DebugFormat( | ||
3335 | // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", | ||
3336 | // Name, LocalId, forGroup, m_undo.Count); | ||
3337 | |||
3338 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3339 | { | 3839 | { |
3340 | UndoState nUndo = new UndoState(this, forGroup); | 3840 | m_UndoRedo.StoreUndo(this, change); |
3341 | |||
3342 | m_undo.Add(nUndo); | ||
3343 | |||
3344 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3345 | m_undo.RemoveAt(0); | ||
3346 | |||
3347 | if (m_redo.Count > 0) | ||
3348 | m_redo.Clear(); | ||
3349 | |||
3350 | // m_log.DebugFormat( | ||
3351 | // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", | ||
3352 | // Name, LocalId, forGroup, m_undo.Count); | ||
3353 | } | 3841 | } |
3354 | } | 3842 | } |
3355 | } | 3843 | } |
@@ -3361,88 +3849,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
3361 | { | 3849 | { |
3362 | get | 3850 | get |
3363 | { | 3851 | { |
3364 | lock (m_undo) | 3852 | if (m_UndoRedo == null) |
3365 | return m_undo.Count; | 3853 | return 0; |
3854 | return m_UndoRedo.Count; | ||
3366 | } | 3855 | } |
3367 | } | 3856 | } |
3368 | 3857 | ||
3369 | public void Undo() | 3858 | public void Undo() |
3370 | { | 3859 | { |
3371 | lock (m_undo) | 3860 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3372 | { | 3861 | return; |
3373 | // m_log.DebugFormat( | ||
3374 | // "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}", | ||
3375 | // Name, LocalId, m_undo.Count); | ||
3376 | |||
3377 | if (m_undo.Count > 0) | ||
3378 | { | ||
3379 | UndoState goback = m_undo[m_undo.Count - 1]; | ||
3380 | m_undo.RemoveAt(m_undo.Count - 1); | ||
3381 | |||
3382 | UndoState nUndo = null; | ||
3383 | |||
3384 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3385 | { | ||
3386 | nUndo = new UndoState(this, goback.ForGroup); | ||
3387 | } | ||
3388 | |||
3389 | goback.PlaybackState(this); | ||
3390 | |||
3391 | if (nUndo != null) | ||
3392 | { | ||
3393 | m_redo.Add(nUndo); | ||
3394 | |||
3395 | if (m_redo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3396 | m_redo.RemoveAt(0); | ||
3397 | } | ||
3398 | } | ||
3399 | 3862 | ||
3400 | // m_log.DebugFormat( | 3863 | lock (m_UndoRedo) |
3401 | // "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", | 3864 | { |
3402 | // Name, LocalId, m_undo.Count); | 3865 | Undoing = true; |
3866 | m_UndoRedo.Undo(this); | ||
3867 | Undoing = false; | ||
3403 | } | 3868 | } |
3404 | } | 3869 | } |
3405 | 3870 | ||
3406 | public void Redo() | 3871 | public void Redo() |
3407 | { | 3872 | { |
3408 | lock (m_undo) | 3873 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3409 | { | 3874 | return; |
3410 | // m_log.DebugFormat( | ||
3411 | // "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}", | ||
3412 | // Name, LocalId, m_redo.Count); | ||
3413 | |||
3414 | if (m_redo.Count > 0) | ||
3415 | { | ||
3416 | UndoState gofwd = m_redo[m_redo.Count - 1]; | ||
3417 | m_redo.RemoveAt(m_redo.Count - 1); | ||
3418 | |||
3419 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3420 | { | ||
3421 | UndoState nUndo = new UndoState(this, gofwd.ForGroup); | ||
3422 | |||
3423 | m_undo.Add(nUndo); | ||
3424 | |||
3425 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3426 | m_undo.RemoveAt(0); | ||
3427 | } | ||
3428 | |||
3429 | gofwd.PlayfwdState(this); | ||
3430 | 3875 | ||
3431 | // m_log.DebugFormat( | 3876 | lock (m_UndoRedo) |
3432 | // "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", | 3877 | { |
3433 | // Name, LocalId, m_redo.Count); | 3878 | Undoing = true; |
3434 | } | 3879 | m_UndoRedo.Redo(this); |
3880 | Undoing = false; | ||
3435 | } | 3881 | } |
3436 | } | 3882 | } |
3437 | 3883 | ||
3438 | public void ClearUndoState() | 3884 | public void ClearUndoState() |
3439 | { | 3885 | { |
3440 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); | 3886 | if (m_UndoRedo == null || Undoing) |
3887 | return; | ||
3441 | 3888 | ||
3442 | lock (m_undo) | 3889 | lock (m_UndoRedo) |
3443 | { | 3890 | { |
3444 | m_undo.Clear(); | 3891 | m_UndoRedo.Clear(); |
3445 | m_redo.Clear(); | ||
3446 | } | 3892 | } |
3447 | } | 3893 | } |
3448 | 3894 | ||
@@ -3994,7 +4440,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3994 | if (god) | 4440 | if (god) |
3995 | { | 4441 | { |
3996 | BaseMask = ApplyMask(BaseMask, set, mask); | 4442 | BaseMask = ApplyMask(BaseMask, set, mask); |
3997 | Inventory.ApplyGodPermissions(_baseMask); | 4443 | Inventory.ApplyGodPermissions(BaseMask); |
3998 | } | 4444 | } |
3999 | 4445 | ||
4000 | break; | 4446 | break; |
@@ -4025,7 +4471,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4025 | } | 4471 | } |
4026 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & | 4472 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & |
4027 | baseMask; | 4473 | baseMask; |
4028 | // Prevent the client from creating no mod, no copy | 4474 | // Prevent the client from creating no copy, no transfer |
4029 | // objects | 4475 | // objects |
4030 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) | 4476 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) |
4031 | NextOwnerMask |= (uint)PermissionMask.Transfer; | 4477 | NextOwnerMask |= (uint)PermissionMask.Transfer; |
@@ -4043,20 +4489,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4043 | { | 4489 | { |
4044 | bool update = false; | 4490 | bool update = false; |
4045 | 4491 | ||
4046 | if (BaseMask != source.BaseMask || | 4492 | uint prevOwnerMask = OwnerMask; |
4047 | OwnerMask != source.OwnerMask || | 4493 | uint prevGroupMask = GroupMask; |
4048 | GroupMask != source.GroupMask || | 4494 | uint prevEveryoneMask = EveryoneMask; |
4049 | EveryoneMask != source.EveryoneMask || | 4495 | uint prevNextOwnerMask = NextOwnerMask; |
4050 | NextOwnerMask != source.NextOwnerMask) | ||
4051 | update = true; | ||
4052 | 4496 | ||
4053 | BaseMask = source.BaseMask; | 4497 | OwnerMask = source.OwnerMask & BaseMask; |
4054 | OwnerMask = source.OwnerMask; | 4498 | GroupMask = source.GroupMask & BaseMask; |
4055 | GroupMask = source.GroupMask; | 4499 | EveryoneMask = source.EveryoneMask & BaseMask; |
4056 | EveryoneMask = source.EveryoneMask; | 4500 | NextOwnerMask = source.NextOwnerMask & BaseMask; |
4057 | NextOwnerMask = source.NextOwnerMask; | ||
4058 | 4501 | ||
4059 | if (update) | 4502 | if (OwnerMask != prevOwnerMask || |
4503 | GroupMask != prevGroupMask || | ||
4504 | EveryoneMask != prevEveryoneMask || | ||
4505 | NextOwnerMask != prevNextOwnerMask) | ||
4060 | SendFullUpdateToAllClients(); | 4506 | SendFullUpdateToAllClients(); |
4061 | } | 4507 | } |
4062 | 4508 | ||
@@ -4107,6 +4553,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4107 | } | 4553 | } |
4108 | } | 4554 | } |
4109 | 4555 | ||
4556 | |||
4110 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) | 4557 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) |
4111 | { | 4558 | { |
4112 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) | 4559 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) |
@@ -4134,7 +4581,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4134 | /// <param name="SetTemporary"></param> | 4581 | /// <param name="SetTemporary"></param> |
4135 | /// <param name="SetPhantom"></param> | 4582 | /// <param name="SetPhantom"></param> |
4136 | /// <param name="SetVD"></param> | 4583 | /// <param name="SetVD"></param> |
4137 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) | 4584 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) |
4138 | { | 4585 | { |
4139 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); | 4586 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); |
4140 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); | 4587 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); |
@@ -4144,97 +4591,103 @@ namespace OpenSim.Region.Framework.Scenes | |||
4144 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) | 4591 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) |
4145 | return; | 4592 | return; |
4146 | 4593 | ||
4147 | PhysicsActor pa = PhysActor; | 4594 | VolumeDetectActive = SetVD; |
4148 | |||
4149 | // Special cases for VD. VD can only be called from a script | ||
4150 | // and can't be combined with changes to other states. So we can rely | ||
4151 | // that... | ||
4152 | // ... if VD is changed, all others are not. | ||
4153 | // ... if one of the others is changed, VD is not. | ||
4154 | if (SetVD) // VD is active, special logic applies | ||
4155 | { | ||
4156 | // State machine logic for VolumeDetect | ||
4157 | // More logic below | ||
4158 | bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; | ||
4159 | |||
4160 | if (phanReset) // Phantom changes from on to off switch VD off too | ||
4161 | { | ||
4162 | SetVD = false; // Switch it of for the course of this routine | ||
4163 | VolumeDetectActive = false; // and also permanently | ||
4164 | |||
4165 | if (pa != null) | ||
4166 | pa.SetVolumeDetect(0); // Let physics know about it too | ||
4167 | } | ||
4168 | else | ||
4169 | { | ||
4170 | // If volumedetect is active we don't want phantom to be applied. | ||
4171 | // If this is a new call to VD out of the state "phantom" | ||
4172 | // this will also cause the prim to be visible to physics | ||
4173 | SetPhantom = false; | ||
4174 | } | ||
4175 | } | ||
4176 | 4595 | ||
4177 | if (UsePhysics && IsJoint()) | 4596 | // volume detector implies phantom |
4178 | { | 4597 | if (VolumeDetectActive) |
4179 | SetPhantom = true; | 4598 | SetPhantom = true; |
4180 | } | ||
4181 | 4599 | ||
4182 | if (UsePhysics) | 4600 | if (UsePhysics) |
4183 | { | ||
4184 | AddFlag(PrimFlags.Physics); | 4601 | AddFlag(PrimFlags.Physics); |
4185 | if (!wasUsingPhysics) | ||
4186 | { | ||
4187 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4188 | } | ||
4189 | } | ||
4190 | else | 4602 | else |
4191 | { | ||
4192 | RemFlag(PrimFlags.Physics); | 4603 | RemFlag(PrimFlags.Physics); |
4193 | if (wasUsingPhysics) | ||
4194 | { | ||
4195 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4196 | } | ||
4197 | } | ||
4198 | 4604 | ||
4199 | if (SetPhantom | 4605 | if (SetPhantom) |
4200 | || ParentGroup.IsAttachment | ||
4201 | || PhysicsShapeType == (byte)PhysShapeType.none | ||
4202 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints | ||
4203 | { | ||
4204 | AddFlag(PrimFlags.Phantom); | 4606 | AddFlag(PrimFlags.Phantom); |
4607 | else | ||
4608 | RemFlag(PrimFlags.Phantom); | ||
4205 | 4609 | ||
4206 | if (PhysActor != null) | 4610 | if (SetTemporary) |
4611 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4612 | else | ||
4613 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4614 | |||
4615 | |||
4616 | if (ParentGroup.Scene == null) | ||
4617 | return; | ||
4618 | |||
4619 | PhysicsActor pa = PhysActor; | ||
4620 | |||
4621 | if (pa != null && building && pa.Building != building) | ||
4622 | pa.Building = building; | ||
4623 | |||
4624 | if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none | ||
4625 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
4626 | { | ||
4627 | if (pa != null) | ||
4207 | { | 4628 | { |
4629 | if(wasUsingPhysics) | ||
4630 | ParentGroup.Scene.RemovePhysicalPrim(1); | ||
4208 | RemoveFromPhysics(); | 4631 | RemoveFromPhysics(); |
4209 | pa = null; | ||
4210 | } | 4632 | } |
4633 | |||
4634 | Velocity = new Vector3(0, 0, 0); | ||
4635 | Acceleration = new Vector3(0, 0, 0); | ||
4636 | if (ParentGroup.RootPart == this) | ||
4637 | AngularVelocity = new Vector3(0, 0, 0); | ||
4211 | } | 4638 | } |
4212 | else // Not phantom | 4639 | |
4640 | else | ||
4213 | { | 4641 | { |
4214 | RemFlag(PrimFlags.Phantom); | 4642 | if (ParentGroup.Scene.CollidablePrims) |
4215 | |||
4216 | if (ParentGroup.Scene == null) | ||
4217 | return; | ||
4218 | |||
4219 | if (ParentGroup.Scene.CollidablePrims && pa == null) | ||
4220 | { | 4643 | { |
4221 | AddToPhysics(UsePhysics, SetPhantom, false); | 4644 | if (pa == null) |
4222 | pa = PhysActor; | 4645 | { |
4223 | 4646 | AddToPhysics(UsePhysics, SetPhantom, building, false); | |
4224 | if (pa != null) | 4647 | pa = PhysActor; |
4648 | /* | ||
4649 | if (pa != null) | ||
4650 | { | ||
4651 | if ( | ||
4652 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4653 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4654 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4655 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4656 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4657 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4658 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4659 | ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4660 | (CollisionSound != UUID.Zero) | ||
4661 | ) | ||
4662 | { | ||
4663 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4664 | pa.SubscribeEvents(1000); | ||
4665 | } | ||
4666 | } | ||
4667 | */ | ||
4668 | if (pa != null) | ||
4669 | { | ||
4670 | pa.SetMaterial(Material); | ||
4671 | DoPhysicsPropertyUpdate(UsePhysics, true); | ||
4672 | } | ||
4673 | } | ||
4674 | else // it already has a physical representation | ||
4225 | { | 4675 | { |
4226 | pa.SetMaterial(Material); | 4676 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. |
4227 | DoPhysicsPropertyUpdate(UsePhysics, true); | 4677 | /* moved into DoPhysicsPropertyUpdate |
4678 | if(VolumeDetectActive) | ||
4679 | pa.SetVolumeDetect(1); | ||
4680 | else | ||
4681 | pa.SetVolumeDetect(0); | ||
4682 | */ | ||
4228 | 4683 | ||
4229 | SubscribeForCollisionEvents(); | 4684 | if (pa.Building != building) |
4685 | pa.Building = building; | ||
4230 | } | 4686 | } |
4231 | } | ||
4232 | else // it already has a physical representation | ||
4233 | { | ||
4234 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim | ||
4235 | } | ||
4236 | } | ||
4237 | 4687 | ||
4688 | UpdatePhysicsSubscribedEvents(); | ||
4689 | } | ||
4690 | } | ||
4238 | if (SetVD) | 4691 | if (SetVD) |
4239 | { | 4692 | { |
4240 | // If the above logic worked (this is urgent candidate to unit tests!) | 4693 | // If the above logic worked (this is urgent candidate to unit tests!) |
@@ -4248,6 +4701,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4248 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 4701 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active |
4249 | VolumeDetectActive = true; | 4702 | VolumeDetectActive = true; |
4250 | } | 4703 | } |
4704 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | ||
4251 | } | 4705 | } |
4252 | else if (SetVD != wasVD) | 4706 | else if (SetVD != wasVD) |
4253 | { | 4707 | { |
@@ -4259,105 +4713,51 @@ namespace OpenSim.Region.Framework.Scenes | |||
4259 | RemFlag(PrimFlags.Phantom); | 4713 | RemFlag(PrimFlags.Phantom); |
4260 | VolumeDetectActive = false; | 4714 | VolumeDetectActive = false; |
4261 | } | 4715 | } |
4262 | 4716 | // and last in case we have a new actor and not building | |
4263 | if (SetTemporary) | ||
4264 | { | ||
4265 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4266 | } | ||
4267 | else | ||
4268 | { | ||
4269 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4270 | } | ||
4271 | |||
4272 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | ||
4273 | 4717 | ||
4274 | if (ParentGroup != null) | 4718 | if (ParentGroup != null) |
4275 | { | 4719 | { |
4276 | ParentGroup.HasGroupChanged = true; | 4720 | ParentGroup.HasGroupChanged = true; |
4277 | ScheduleFullUpdate(); | 4721 | ScheduleFullUpdate(); |
4278 | } | 4722 | } |
4279 | 4723 | ||
4280 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); | 4724 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); |
4281 | } | 4725 | } |
4282 | 4726 | ||
4283 | /// <summary> | 4727 | /// <summary> |
4284 | /// Subscribe for physics collision events if needed for scripts and sounds | ||
4285 | /// </summary> | ||
4286 | public void SubscribeForCollisionEvents() | ||
4287 | { | ||
4288 | PhysicsActor pa = PhysActor; | ||
4289 | |||
4290 | if (pa != null) | ||
4291 | { | ||
4292 | if ( | ||
4293 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4294 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4295 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4296 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4297 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4298 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4299 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4300 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4301 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4302 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4303 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4304 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4305 | (CollisionSound != UUID.Zero) | ||
4306 | ) | ||
4307 | { | ||
4308 | if (!pa.SubscribedEvents()) | ||
4309 | { | ||
4310 | // If not already subscribed for event, set up for a collision event. | ||
4311 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4312 | pa.SubscribeEvents(1000); | ||
4313 | } | ||
4314 | } | ||
4315 | else | ||
4316 | { | ||
4317 | // There is no need to be subscribed to collisions so, if subscribed, remove subscription | ||
4318 | if (pa.SubscribedEvents()) | ||
4319 | { | ||
4320 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4321 | pa.UnSubscribeEvents(); | ||
4322 | } | ||
4323 | } | ||
4324 | } | ||
4325 | } | ||
4326 | |||
4327 | /// <summary> | ||
4328 | /// Adds this part to the physics scene. | 4728 | /// Adds this part to the physics scene. |
4729 | /// and sets the PhysActor property | ||
4329 | /// </summary> | 4730 | /// </summary> |
4330 | /// <remarks>This method also sets the PhysActor property.</remarks> | 4731 | /// <param name="isPhysical">Add this prim as physical.</param> |
4331 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | 4732 | /// <param name="isPhantom">Add this prim as phantom.</param> |
4332 | /// <returns> | 4733 | /// <param name="building">tells physics to delay full construction of object</param> |
4333 | /// The physics actor. null if there was a failure. | 4734 | /// <param name="applyDynamics">applies velocities, force and torque</param> |
4334 | /// </returns> | 4735 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) |
4335 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool applyDynamics) | 4736 | { |
4336 | { | ||
4337 | PhysicsActor pa; | 4737 | PhysicsActor pa; |
4338 | 4738 | ||
4339 | Vector3 velocity = Velocity; | 4739 | Vector3 velocity = Velocity; |
4340 | Vector3 rotationalVelocity = AngularVelocity;; | 4740 | Vector3 rotationalVelocity = AngularVelocity;; |
4341 | 4741 | ||
4342 | try | 4742 | try |
4343 | { | 4743 | { |
4344 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | 4744 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( |
4345 | string.Format("{0}/{1}", Name, UUID), | 4745 | string.Format("{0}/{1}", Name, UUID), |
4346 | Shape, | 4746 | Shape, |
4347 | AbsolutePosition, | 4747 | AbsolutePosition, |
4348 | Scale, | 4748 | Scale, |
4349 | GetWorldRotation(), | 4749 | GetWorldRotation(), |
4350 | isPhysical, | 4750 | isPhysical, |
4351 | isPhantom, | 4751 | isPhantom, |
4352 | PhysicsShapeType, | 4752 | PhysicsShapeType, |
4353 | m_localId); | 4753 | m_localId); |
4354 | } | 4754 | } |
4355 | catch (Exception e) | 4755 | catch (Exception e) |
4356 | { | 4756 | { |
4357 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); | 4757 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); |
4358 | pa = null; | 4758 | pa = null; |
4359 | } | 4759 | } |
4360 | 4760 | ||
4361 | if (pa != null) | 4761 | if (pa != null) |
4362 | { | 4762 | { |
4363 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | 4763 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info |
@@ -4370,9 +4770,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4370 | 4770 | ||
4371 | if (VolumeDetectActive) // change if not the default only | 4771 | if (VolumeDetectActive) // change if not the default only |
4372 | pa.SetVolumeDetect(1); | 4772 | pa.SetVolumeDetect(1); |
4773 | |||
4774 | if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) | ||
4775 | m_vehicleParams.SetVehicle(pa); | ||
4776 | |||
4373 | // we are going to tell rest of code about physics so better have this here | 4777 | // we are going to tell rest of code about physics so better have this here |
4374 | PhysActor = pa; | 4778 | PhysActor = pa; |
4375 | 4779 | ||
4780 | // DoPhysicsPropertyUpdate(isPhysical, true); | ||
4781 | // lets expand it here just with what it really needs to do | ||
4782 | |||
4376 | if (isPhysical) | 4783 | if (isPhysical) |
4377 | { | 4784 | { |
4378 | if (ParentGroup.RootPart.KeyframeMotion != null) | 4785 | if (ParentGroup.RootPart.KeyframeMotion != null) |
@@ -4394,19 +4801,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
4394 | } | 4801 | } |
4395 | } | 4802 | } |
4396 | 4803 | ||
4397 | if (applyDynamics) | 4804 | if (applyDynamics) |
4398 | // do independent of isphysical so parameters get setted (at least some) | 4805 | // do independent of isphysical so parameters get setted (at least some) |
4399 | { | 4806 | { |
4400 | Velocity = velocity; | 4807 | Velocity = velocity; |
4401 | AngularVelocity = rotationalVelocity; | 4808 | AngularVelocity = rotationalVelocity; |
4402 | // pa.Velocity = velocity; | 4809 | // pa.Velocity = velocity; |
4403 | pa.RotationalVelocity = rotationalVelocity; | 4810 | pa.RotationalVelocity = rotationalVelocity; |
4811 | |||
4812 | // if not vehicle and root part apply force and torque | ||
4813 | if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE) | ||
4814 | && LocalId == ParentGroup.RootPart.LocalId) | ||
4815 | { | ||
4816 | pa.Force = Force; | ||
4817 | pa.Torque = Torque; | ||
4818 | } | ||
4404 | } | 4819 | } |
4405 | 4820 | ||
4406 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 4821 | // if (Shape.SculptEntry) |
4822 | // CheckSculptAndLoad(); | ||
4823 | // else | ||
4824 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
4825 | |||
4826 | if (!building) | ||
4827 | pa.Building = false; | ||
4407 | } | 4828 | } |
4408 | 4829 | ||
4409 | PhysActor = pa; | 4830 | PhysActor = pa; |
4831 | |||
4410 | ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); | 4832 | ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); |
4411 | } | 4833 | } |
4412 | 4834 | ||
@@ -4415,14 +4837,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
4415 | /// </summary> | 4837 | /// </summary> |
4416 | /// <remarks> | 4838 | /// <remarks> |
4417 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 4839 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |
4418 | /// representation for collision detection. Rather, this would be used in situations such as making a prim | 4840 | /// representation for collision detection. |
4419 | /// phantom. | ||
4420 | /// </remarks> | 4841 | /// </remarks> |
4421 | public void RemoveFromPhysics() | 4842 | public void RemoveFromPhysics() |
4422 | { | 4843 | { |
4423 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | 4844 | PhysicsActor pa = PhysActor; |
4424 | if (ParentGroup.Scene.PhysicsScene != null) | 4845 | if (pa != null) |
4425 | ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 4846 | { |
4847 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4848 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | ||
4849 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | ||
4850 | |||
4851 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | ||
4852 | |||
4853 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | ||
4854 | } | ||
4426 | PhysActor = null; | 4855 | PhysActor = null; |
4427 | } | 4856 | } |
4428 | 4857 | ||
@@ -4554,6 +4983,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4554 | { | 4983 | { |
4555 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); | 4984 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); |
4556 | 4985 | ||
4986 | return; | ||
4987 | |||
4557 | if (ParentGroup.IsDeleted) | 4988 | if (ParentGroup.IsDeleted) |
4558 | return; | 4989 | return; |
4559 | 4990 | ||
@@ -4677,6 +5108,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
4677 | } | 5108 | } |
4678 | } | 5109 | } |
4679 | 5110 | ||
5111 | |||
5112 | private void UpdatePhysicsSubscribedEvents() | ||
5113 | { | ||
5114 | PhysicsActor pa = PhysActor; | ||
5115 | if (pa == null) | ||
5116 | return; | ||
5117 | |||
5118 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5119 | |||
5120 | bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0)); | ||
5121 | |||
5122 | scriptEvents CombinedEvents = AggregateScriptEvents; | ||
5123 | |||
5124 | // merge with root part | ||
5125 | if (ParentGroup != null && ParentGroup.RootPart != null) | ||
5126 | CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents; | ||
5127 | |||
5128 | // submit to this part case | ||
5129 | if (VolumeDetectActive) | ||
5130 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | ||
5131 | else if ((Flags & PrimFlags.Phantom) != 0) | ||
5132 | CombinedEvents &= PhyscicsPhantonSubsEvents; | ||
5133 | else | ||
5134 | CombinedEvents &= PhysicsNeededSubsEvents; | ||
5135 | |||
5136 | if (hassound || CombinedEvents != 0) | ||
5137 | { | ||
5138 | // subscribe to physics updates. | ||
5139 | pa.OnCollisionUpdate += PhysicsCollision; | ||
5140 | pa.SubscribeEvents(50); // 20 reports per second | ||
5141 | } | ||
5142 | else | ||
5143 | { | ||
5144 | pa.UnSubscribeEvents(); | ||
5145 | } | ||
5146 | } | ||
5147 | |||
5148 | |||
4680 | public void aggregateScriptEvents() | 5149 | public void aggregateScriptEvents() |
4681 | { | 5150 | { |
4682 | if (ParentGroup == null || ParentGroup.RootPart == null) | 5151 | if (ParentGroup == null || ParentGroup.RootPart == null) |
@@ -4713,8 +5182,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
4713 | { | 5182 | { |
4714 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 5183 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4715 | } | 5184 | } |
4716 | 5185 | /* | |
4717 | SubscribeForCollisionEvents(); | 5186 | PhysicsActor pa = PhysActor; |
5187 | if (pa != null) | ||
5188 | { | ||
5189 | if ( | ||
5190 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
5191 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
5192 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
5193 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
5194 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
5195 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
5196 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | ||
5197 | ) | ||
5198 | { | ||
5199 | // subscribe to physics updates. | ||
5200 | pa.OnCollisionUpdate += PhysicsCollision; | ||
5201 | pa.SubscribeEvents(1000); | ||
5202 | } | ||
5203 | else | ||
5204 | { | ||
5205 | pa.UnSubscribeEvents(); | ||
5206 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5207 | } | ||
5208 | } | ||
5209 | */ | ||
5210 | UpdatePhysicsSubscribedEvents(); | ||
4718 | 5211 | ||
4719 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 5212 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4720 | //{ | 5213 | //{ |
@@ -4848,6 +5341,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4848 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 5341 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4849 | } | 5342 | } |
4850 | 5343 | ||
5344 | public void ResetOwnerChangeFlag() | ||
5345 | { | ||
5346 | List<UUID> inv = Inventory.GetInventoryList(); | ||
5347 | |||
5348 | foreach (UUID itemID in inv) | ||
5349 | { | ||
5350 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
5351 | item.OwnerChanged = false; | ||
5352 | Inventory.UpdateInventoryItem(item, false, false); | ||
5353 | } | ||
5354 | } | ||
5355 | |||
4851 | /// <summary> | 5356 | /// <summary> |
4852 | /// Record an avatar sitting on this part. | 5357 | /// Record an avatar sitting on this part. |
4853 | /// </summary> | 5358 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 380e402..b4fc472 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -49,6 +49,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
49 | private string m_inventoryFileName = String.Empty; | 49 | private string m_inventoryFileName = String.Empty; |
50 | private byte[] m_inventoryFileData = new byte[0]; | 50 | private byte[] m_inventoryFileData = new byte[0]; |
51 | private uint m_inventoryFileNameSerial = 0; | 51 | private uint m_inventoryFileNameSerial = 0; |
52 | private bool m_inventoryPrivileged = false; | ||
53 | |||
54 | private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); | ||
52 | 55 | ||
53 | /// <value> | 56 | /// <value> |
54 | /// The part to which the inventory belongs. | 57 | /// The part to which the inventory belongs. |
@@ -85,7 +88,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
85 | /// </value> | 88 | /// </value> |
86 | protected internal TaskInventoryDictionary Items | 89 | protected internal TaskInventoryDictionary Items |
87 | { | 90 | { |
88 | get { return m_items; } | 91 | get { |
92 | return m_items; | ||
93 | } | ||
89 | set | 94 | set |
90 | { | 95 | { |
91 | m_items = value; | 96 | m_items = value; |
@@ -134,38 +139,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
134 | public void ResetInventoryIDs() | 139 | public void ResetInventoryIDs() |
135 | { | 140 | { |
136 | if (null == m_part) | 141 | if (null == m_part) |
137 | return; | 142 | m_items.LockItemsForWrite(true); |
138 | 143 | ||
139 | lock (m_items) | 144 | if (Items.Count == 0) |
140 | { | 145 | { |
141 | if (0 == m_items.Count) | 146 | m_items.LockItemsForWrite(false); |
142 | return; | 147 | return; |
148 | } | ||
143 | 149 | ||
144 | IList<TaskInventoryItem> items = GetInventoryItems(); | 150 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
145 | m_items.Clear(); | 151 | Items.Clear(); |
146 | 152 | ||
147 | foreach (TaskInventoryItem item in items) | 153 | foreach (TaskInventoryItem item in items) |
148 | { | 154 | { |
149 | item.ResetIDs(m_part.UUID); | 155 | item.ResetIDs(m_part.UUID); |
150 | m_items.Add(item.ItemID, item); | 156 | Items.Add(item.ItemID, item); |
151 | } | ||
152 | } | 157 | } |
158 | m_items.LockItemsForWrite(false); | ||
153 | } | 159 | } |
154 | 160 | ||
155 | public void ResetObjectID() | 161 | public void ResetObjectID() |
156 | { | 162 | { |
157 | lock (Items) | 163 | m_items.LockItemsForWrite(true); |
164 | |||
165 | if (Items.Count == 0) | ||
158 | { | 166 | { |
159 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 167 | m_items.LockItemsForWrite(false); |
160 | Items.Clear(); | 168 | return; |
161 | |||
162 | foreach (TaskInventoryItem item in items) | ||
163 | { | ||
164 | item.ParentPartID = m_part.UUID; | ||
165 | item.ParentID = m_part.UUID; | ||
166 | Items.Add(item.ItemID, item); | ||
167 | } | ||
168 | } | 169 | } |
170 | |||
171 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
172 | Items.Clear(); | ||
173 | |||
174 | foreach (TaskInventoryItem item in items) | ||
175 | { | ||
176 | item.ParentPartID = m_part.UUID; | ||
177 | item.ParentID = m_part.UUID; | ||
178 | Items.Add(item.ItemID, item); | ||
179 | } | ||
180 | m_items.LockItemsForWrite(false); | ||
169 | } | 181 | } |
170 | 182 | ||
171 | /// <summary> | 183 | /// <summary> |
@@ -174,17 +186,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
174 | /// <param name="ownerId"></param> | 186 | /// <param name="ownerId"></param> |
175 | public void ChangeInventoryOwner(UUID ownerId) | 187 | public void ChangeInventoryOwner(UUID ownerId) |
176 | { | 188 | { |
177 | lock (Items) | 189 | List<TaskInventoryItem> items = GetInventoryItems(); |
178 | { | 190 | |
179 | if (0 == Items.Count) | 191 | if (items.Count == 0) |
180 | { | 192 | return; |
181 | return; | ||
182 | } | ||
183 | } | ||
184 | 193 | ||
194 | m_items.LockItemsForWrite(true); | ||
185 | HasInventoryChanged = true; | 195 | HasInventoryChanged = true; |
186 | m_part.ParentGroup.HasGroupChanged = true; | 196 | m_part.ParentGroup.HasGroupChanged = true; |
187 | List<TaskInventoryItem> items = GetInventoryItems(); | ||
188 | foreach (TaskInventoryItem item in items) | 197 | foreach (TaskInventoryItem item in items) |
189 | { | 198 | { |
190 | if (ownerId != item.OwnerID) | 199 | if (ownerId != item.OwnerID) |
@@ -195,6 +204,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
195 | item.PermsGranter = UUID.Zero; | 204 | item.PermsGranter = UUID.Zero; |
196 | item.OwnerChanged = true; | 205 | item.OwnerChanged = true; |
197 | } | 206 | } |
207 | m_items.LockItemsForWrite(false); | ||
198 | } | 208 | } |
199 | 209 | ||
200 | /// <summary> | 210 | /// <summary> |
@@ -203,12 +213,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
203 | /// <param name="groupID"></param> | 213 | /// <param name="groupID"></param> |
204 | public void ChangeInventoryGroup(UUID groupID) | 214 | public void ChangeInventoryGroup(UUID groupID) |
205 | { | 215 | { |
206 | lock (Items) | 216 | m_items.LockItemsForWrite(true); |
217 | if (0 == Items.Count) | ||
207 | { | 218 | { |
208 | if (0 == Items.Count) | 219 | m_items.LockItemsForWrite(false); |
209 | { | 220 | return; |
210 | return; | ||
211 | } | ||
212 | } | 221 | } |
213 | 222 | ||
214 | // Don't let this set the HasGroupChanged flag for attachments | 223 | // Don't let this set the HasGroupChanged flag for attachments |
@@ -220,12 +229,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
220 | m_part.ParentGroup.HasGroupChanged = true; | 229 | m_part.ParentGroup.HasGroupChanged = true; |
221 | } | 230 | } |
222 | 231 | ||
223 | List<TaskInventoryItem> items = GetInventoryItems(); | 232 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
224 | foreach (TaskInventoryItem item in items) | 233 | foreach (TaskInventoryItem item in items) |
225 | { | 234 | { |
226 | if (groupID != item.GroupID) | 235 | if (groupID != item.GroupID) |
236 | { | ||
227 | item.GroupID = groupID; | 237 | item.GroupID = groupID; |
238 | } | ||
228 | } | 239 | } |
240 | m_items.LockItemsForWrite(false); | ||
229 | } | 241 | } |
230 | 242 | ||
231 | private void QueryScriptStates() | 243 | private void QueryScriptStates() |
@@ -233,15 +245,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
233 | if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) | 245 | if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) |
234 | return; | 246 | return; |
235 | 247 | ||
236 | lock (Items) | 248 | Items.LockItemsForRead(true); |
249 | foreach (TaskInventoryItem item in Items.Values) | ||
237 | { | 250 | { |
238 | foreach (TaskInventoryItem item in Items.Values) | 251 | if (item.InvType == (int)InventoryType.LSL) |
239 | { | 252 | { |
240 | bool running; | 253 | bool running; |
241 | if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running)) | 254 | if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running)) |
242 | item.ScriptRunning = running; | 255 | item.ScriptRunning = running; |
243 | } | 256 | } |
244 | } | 257 | } |
258 | |||
259 | Items.LockItemsForRead(false); | ||
245 | } | 260 | } |
246 | 261 | ||
247 | public bool TryGetScriptInstanceRunning(UUID itemId, out bool running) | 262 | public bool TryGetScriptInstanceRunning(UUID itemId, out bool running) |
@@ -318,7 +333,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
318 | { | 333 | { |
319 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | 334 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
320 | foreach (TaskInventoryItem item in scripts) | 335 | foreach (TaskInventoryItem item in scripts) |
336 | { | ||
321 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | 337 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
338 | m_part.RemoveScriptEvents(item.ItemID); | ||
339 | } | ||
322 | } | 340 | } |
323 | 341 | ||
324 | /// <summary> | 342 | /// <summary> |
@@ -340,7 +358,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
340 | // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 358 | // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
341 | 359 | ||
342 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) | 360 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) |
361 | { | ||
362 | StoreScriptError(item.ItemID, "no permission"); | ||
343 | return false; | 363 | return false; |
364 | } | ||
344 | 365 | ||
345 | m_part.AddFlag(PrimFlags.Scripted); | 366 | m_part.AddFlag(PrimFlags.Scripted); |
346 | 367 | ||
@@ -350,14 +371,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
350 | if (stateSource == 2 && // Prim crossing | 371 | if (stateSource == 2 && // Prim crossing |
351 | m_part.ParentGroup.Scene.m_trustBinaries) | 372 | m_part.ParentGroup.Scene.m_trustBinaries) |
352 | { | 373 | { |
353 | lock (m_items) | 374 | m_items.LockItemsForWrite(true); |
354 | { | 375 | m_items[item.ItemID].PermsMask = 0; |
355 | m_items[item.ItemID].PermsMask = 0; | 376 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
356 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 377 | m_items.LockItemsForWrite(false); |
357 | } | ||
358 | |||
359 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 378 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
360 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 379 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
380 | StoreScriptErrors(item.ItemID, null); | ||
361 | m_part.ParentGroup.AddActiveScriptCount(1); | 381 | m_part.ParentGroup.AddActiveScriptCount(1); |
362 | m_part.ScheduleFullUpdate(); | 382 | m_part.ScheduleFullUpdate(); |
363 | return true; | 383 | return true; |
@@ -366,6 +386,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
366 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); | 386 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
367 | if (null == asset) | 387 | if (null == asset) |
368 | { | 388 | { |
389 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | ||
390 | StoreScriptError(item.ItemID, msg); | ||
369 | m_log.ErrorFormat( | 391 | m_log.ErrorFormat( |
370 | "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", | 392 | "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
371 | item.Name, item.ItemID, m_part.AbsolutePosition, | 393 | item.Name, item.ItemID, m_part.AbsolutePosition, |
@@ -378,16 +400,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
378 | if (m_part.ParentGroup.m_savedScriptState != null) | 400 | if (m_part.ParentGroup.m_savedScriptState != null) |
379 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); | 401 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); |
380 | 402 | ||
381 | lock (m_items) | 403 | m_items.LockItemsForWrite(true); |
382 | { | 404 | |
383 | m_items[item.ItemID].OldItemID = item.OldItemID; | 405 | m_items[item.ItemID].OldItemID = item.OldItemID; |
384 | m_items[item.ItemID].PermsMask = 0; | 406 | m_items[item.ItemID].PermsMask = 0; |
385 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 407 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
386 | } | ||
387 | 408 | ||
409 | m_items.LockItemsForWrite(false); | ||
410 | |||
388 | string script = Utils.BytesToString(asset.Data); | 411 | string script = Utils.BytesToString(asset.Data); |
389 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 412 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
390 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 413 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
414 | StoreScriptErrors(item.ItemID, null); | ||
391 | if (!item.ScriptRunning) | 415 | if (!item.ScriptRunning) |
392 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript( | 416 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript( |
393 | m_part.LocalId, item.ItemID); | 417 | m_part.LocalId, item.ItemID); |
@@ -460,22 +484,149 @@ namespace OpenSim.Region.Framework.Scenes | |||
460 | return stateID; | 484 | return stateID; |
461 | } | 485 | } |
462 | 486 | ||
487 | /// <summary> | ||
488 | /// Start a script which is in this prim's inventory. | ||
489 | /// Some processing may occur in the background, but this routine returns asap. | ||
490 | /// </summary> | ||
491 | /// <param name="itemId"> | ||
492 | /// A <see cref="UUID"/> | ||
493 | /// </param> | ||
463 | public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 494 | public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
464 | { | 495 | { |
465 | TaskInventoryItem item = GetInventoryItem(itemId); | 496 | lock (m_scriptErrors) |
466 | if (item != null) | ||
467 | { | 497 | { |
468 | return CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | 498 | // Indicate to CreateScriptInstanceInternal() we don't want it to wait for completion |
499 | m_scriptErrors.Remove(itemId); | ||
500 | } | ||
501 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
502 | return true; | ||
503 | } | ||
504 | |||
505 | private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
506 | { | ||
507 | m_items.LockItemsForRead(true); | ||
508 | if (m_items.ContainsKey(itemId)) | ||
509 | { | ||
510 | if (m_items.ContainsKey(itemId)) | ||
511 | { | ||
512 | m_items.LockItemsForRead(false); | ||
513 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | ||
514 | } | ||
515 | else | ||
516 | { | ||
517 | m_items.LockItemsForRead(false); | ||
518 | string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, | ||
519 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
520 | StoreScriptError(itemId, msg); | ||
521 | m_log.ErrorFormat( | ||
522 | "[PRIM INVENTORY]: " + | ||
523 | "Couldn't start script with ID {0} since it {1}", itemId, msg); | ||
524 | } | ||
469 | } | 525 | } |
470 | else | 526 | else |
471 | { | 527 | { |
528 | m_items.LockItemsForRead(false); | ||
529 | string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); | ||
530 | StoreScriptError(itemId, msg); | ||
472 | m_log.ErrorFormat( | 531 | m_log.ErrorFormat( |
473 | "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 532 | "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", |
474 | itemId, m_part.Name, m_part.UUID, | 533 | itemId, m_part.Name, m_part.UUID, |
475 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 534 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
535 | } | ||
536 | |||
537 | } | ||
476 | 538 | ||
477 | return false; | 539 | /// <summary> |
540 | /// Start a script which is in this prim's inventory and return any compilation error messages. | ||
541 | /// </summary> | ||
542 | /// <param name="itemId"> | ||
543 | /// A <see cref="UUID"/> | ||
544 | /// </param> | ||
545 | public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
546 | { | ||
547 | ArrayList errors; | ||
548 | |||
549 | // Indicate to CreateScriptInstanceInternal() we want it to | ||
550 | // post any compilation/loading error messages | ||
551 | lock (m_scriptErrors) | ||
552 | { | ||
553 | m_scriptErrors[itemId] = null; | ||
554 | } | ||
555 | |||
556 | // Perform compilation/loading | ||
557 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
558 | |||
559 | // Wait for and retrieve any errors | ||
560 | lock (m_scriptErrors) | ||
561 | { | ||
562 | while ((errors = m_scriptErrors[itemId]) == null) | ||
563 | { | ||
564 | if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000)) | ||
565 | { | ||
566 | m_log.ErrorFormat( | ||
567 | "[PRIM INVENTORY]: " + | ||
568 | "timedout waiting for script {0} errors", itemId); | ||
569 | errors = m_scriptErrors[itemId]; | ||
570 | if (errors == null) | ||
571 | { | ||
572 | errors = new ArrayList(1); | ||
573 | errors.Add("timedout waiting for errors"); | ||
574 | } | ||
575 | break; | ||
576 | } | ||
577 | } | ||
578 | m_scriptErrors.Remove(itemId); | ||
478 | } | 579 | } |
580 | return errors; | ||
581 | } | ||
582 | |||
583 | // Signal to CreateScriptInstanceEr() that compilation/loading is complete | ||
584 | private void StoreScriptErrors(UUID itemId, ArrayList errors) | ||
585 | { | ||
586 | lock (m_scriptErrors) | ||
587 | { | ||
588 | // If compilation/loading initiated via CreateScriptInstance(), | ||
589 | // it does not want the errors, so just get out | ||
590 | if (!m_scriptErrors.ContainsKey(itemId)) | ||
591 | { | ||
592 | return; | ||
593 | } | ||
594 | |||
595 | // Initiated via CreateScriptInstanceEr(), if we know what the | ||
596 | // errors are, save them and wake CreateScriptInstanceEr(). | ||
597 | if (errors != null) | ||
598 | { | ||
599 | m_scriptErrors[itemId] = errors; | ||
600 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
601 | return; | ||
602 | } | ||
603 | } | ||
604 | |||
605 | // Initiated via CreateScriptInstanceEr() but we don't know what | ||
606 | // the errors are yet, so retrieve them from the script engine. | ||
607 | // This may involve some waiting internal to GetScriptErrors(). | ||
608 | errors = GetScriptErrors(itemId); | ||
609 | |||
610 | // Get a default non-null value to indicate success. | ||
611 | if (errors == null) | ||
612 | { | ||
613 | errors = new ArrayList(); | ||
614 | } | ||
615 | |||
616 | // Post to CreateScriptInstanceEr() and wake it up | ||
617 | lock (m_scriptErrors) | ||
618 | { | ||
619 | m_scriptErrors[itemId] = errors; | ||
620 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
621 | } | ||
622 | } | ||
623 | |||
624 | // Like StoreScriptErrors(), but just posts a single string message | ||
625 | private void StoreScriptError(UUID itemId, string message) | ||
626 | { | ||
627 | ArrayList errors = new ArrayList(1); | ||
628 | errors.Add(message); | ||
629 | StoreScriptErrors(itemId, errors); | ||
479 | } | 630 | } |
480 | 631 | ||
481 | /// <summary> | 632 | /// <summary> |
@@ -488,15 +639,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
488 | /// </param> | 639 | /// </param> |
489 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) | 640 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) |
490 | { | 641 | { |
491 | bool scriptPresent = false; | 642 | if (m_items.ContainsKey(itemId)) |
492 | |||
493 | lock (m_items) | ||
494 | { | ||
495 | if (m_items.ContainsKey(itemId)) | ||
496 | scriptPresent = true; | ||
497 | } | ||
498 | |||
499 | if (scriptPresent) | ||
500 | { | 643 | { |
501 | if (!sceneObjectBeingDeleted) | 644 | if (!sceneObjectBeingDeleted) |
502 | m_part.RemoveScriptEvents(itemId); | 645 | m_part.RemoveScriptEvents(itemId); |
@@ -567,14 +710,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
567 | /// <returns></returns> | 710 | /// <returns></returns> |
568 | private bool InventoryContainsName(string name) | 711 | private bool InventoryContainsName(string name) |
569 | { | 712 | { |
570 | lock (m_items) | 713 | m_items.LockItemsForRead(true); |
714 | foreach (TaskInventoryItem item in m_items.Values) | ||
571 | { | 715 | { |
572 | foreach (TaskInventoryItem item in m_items.Values) | 716 | if (item.Name == name) |
573 | { | 717 | { |
574 | if (item.Name == name) | 718 | m_items.LockItemsForRead(false); |
575 | return true; | 719 | return true; |
576 | } | 720 | } |
577 | } | 721 | } |
722 | m_items.LockItemsForRead(false); | ||
578 | return false; | 723 | return false; |
579 | } | 724 | } |
580 | 725 | ||
@@ -616,8 +761,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
616 | /// <param name="item"></param> | 761 | /// <param name="item"></param> |
617 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 762 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
618 | { | 763 | { |
619 | List<TaskInventoryItem> il = GetInventoryItems(); | 764 | m_items.LockItemsForRead(true); |
620 | 765 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | |
766 | m_items.LockItemsForRead(false); | ||
621 | foreach (TaskInventoryItem i in il) | 767 | foreach (TaskInventoryItem i in il) |
622 | { | 768 | { |
623 | if (i.Name == item.Name) | 769 | if (i.Name == item.Name) |
@@ -655,14 +801,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
655 | item.Name = name; | 801 | item.Name = name; |
656 | item.GroupID = m_part.GroupID; | 802 | item.GroupID = m_part.GroupID; |
657 | 803 | ||
658 | lock (m_items) | 804 | m_items.LockItemsForWrite(true); |
659 | m_items.Add(item.ItemID, item); | 805 | m_items.Add(item.ItemID, item); |
660 | 806 | m_items.LockItemsForWrite(false); | |
661 | if (allowedDrop) | 807 | if (allowedDrop) |
662 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 808 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
663 | else | 809 | else |
664 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 810 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
665 | 811 | ||
666 | m_inventorySerial++; | 812 | m_inventorySerial++; |
667 | //m_inventorySerial += 2; | 813 | //m_inventorySerial += 2; |
668 | HasInventoryChanged = true; | 814 | HasInventoryChanged = true; |
@@ -678,15 +824,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
678 | /// <param name="items"></param> | 824 | /// <param name="items"></param> |
679 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 825 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
680 | { | 826 | { |
681 | lock (m_items) | 827 | m_items.LockItemsForWrite(true); |
828 | foreach (TaskInventoryItem item in items) | ||
682 | { | 829 | { |
683 | foreach (TaskInventoryItem item in items) | 830 | m_items.Add(item.ItemID, item); |
684 | { | 831 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
685 | m_items.Add(item.ItemID, item); | ||
686 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
687 | } | ||
688 | m_inventorySerial++; | ||
689 | } | 832 | } |
833 | m_items.LockItemsForWrite(false); | ||
834 | |||
835 | m_inventorySerial++; | ||
690 | } | 836 | } |
691 | 837 | ||
692 | /// <summary> | 838 | /// <summary> |
@@ -697,23 +843,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
697 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 843 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
698 | { | 844 | { |
699 | TaskInventoryItem item; | 845 | TaskInventoryItem item; |
700 | 846 | m_items.LockItemsForRead(true); | |
701 | lock (m_items) | 847 | m_items.TryGetValue(itemId, out item); |
702 | m_items.TryGetValue(itemId, out item); | 848 | m_items.LockItemsForRead(false); |
703 | |||
704 | return item; | 849 | return item; |
705 | } | 850 | } |
706 | 851 | ||
707 | public TaskInventoryItem GetInventoryItem(string name) | 852 | public TaskInventoryItem GetInventoryItem(string name) |
708 | { | 853 | { |
709 | lock (m_items) | 854 | m_items.LockItemsForRead(true); |
855 | foreach (TaskInventoryItem item in m_items.Values) | ||
710 | { | 856 | { |
711 | foreach (TaskInventoryItem item in m_items.Values) | 857 | if (item.Name == name) |
712 | { | 858 | { |
713 | if (item.Name == name) | 859 | m_items.LockItemsForRead(false); |
714 | return item; | 860 | return item; |
715 | } | 861 | } |
716 | } | 862 | } |
863 | m_items.LockItemsForRead(false); | ||
717 | 864 | ||
718 | return null; | 865 | return null; |
719 | } | 866 | } |
@@ -722,15 +869,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
722 | { | 869 | { |
723 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 870 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
724 | 871 | ||
725 | lock (m_items) | 872 | m_items.LockItemsForRead(true); |
873 | |||
874 | foreach (TaskInventoryItem item in m_items.Values) | ||
726 | { | 875 | { |
727 | foreach (TaskInventoryItem item in m_items.Values) | 876 | if (item.Name == name) |
728 | { | 877 | items.Add(item); |
729 | if (item.Name == name) | ||
730 | items.Add(item); | ||
731 | } | ||
732 | } | 878 | } |
733 | 879 | ||
880 | m_items.LockItemsForRead(false); | ||
881 | |||
734 | return items; | 882 | return items; |
735 | } | 883 | } |
736 | 884 | ||
@@ -757,6 +905,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
757 | { | 905 | { |
758 | SceneObjectGroup group = objlist[i]; | 906 | SceneObjectGroup group = objlist[i]; |
759 | 907 | ||
908 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
909 | group.RootPart.AttachOffset = group.AbsolutePosition; | ||
910 | group.RootPart.AttachRotation = group.GroupRotation; | ||
911 | |||
760 | group.ResetIDs(); | 912 | group.ResetIDs(); |
761 | 913 | ||
762 | SceneObjectPart rootPart = group.GetPart(group.UUID); | 914 | SceneObjectPart rootPart = group.GetPart(group.UUID); |
@@ -832,8 +984,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
832 | 984 | ||
833 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) | 985 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) |
834 | { | 986 | { |
835 | TaskInventoryItem it = GetInventoryItem(item.ItemID); | 987 | m_items.LockItemsForWrite(true); |
836 | if (it != null) | 988 | |
989 | if (m_items.ContainsKey(item.ItemID)) | ||
837 | { | 990 | { |
838 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); | 991 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); |
839 | 992 | ||
@@ -846,14 +999,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
846 | item.GroupID = m_part.GroupID; | 999 | item.GroupID = m_part.GroupID; |
847 | 1000 | ||
848 | if (item.AssetID == UUID.Zero) | 1001 | if (item.AssetID == UUID.Zero) |
849 | item.AssetID = it.AssetID; | 1002 | item.AssetID = m_items[item.ItemID].AssetID; |
850 | 1003 | ||
851 | lock (m_items) | 1004 | m_items[item.ItemID] = item; |
852 | { | 1005 | m_inventorySerial++; |
853 | m_items[item.ItemID] = item; | ||
854 | m_inventorySerial++; | ||
855 | } | ||
856 | |||
857 | if (fireScriptEvents) | 1006 | if (fireScriptEvents) |
858 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 1007 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
859 | 1008 | ||
@@ -862,7 +1011,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
862 | HasInventoryChanged = true; | 1011 | HasInventoryChanged = true; |
863 | m_part.ParentGroup.HasGroupChanged = true; | 1012 | m_part.ParentGroup.HasGroupChanged = true; |
864 | } | 1013 | } |
865 | 1014 | m_items.LockItemsForWrite(false); | |
866 | return true; | 1015 | return true; |
867 | } | 1016 | } |
868 | else | 1017 | else |
@@ -873,8 +1022,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
873 | item.ItemID, m_part.Name, m_part.UUID, | 1022 | item.ItemID, m_part.Name, m_part.UUID, |
874 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 1023 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
875 | } | 1024 | } |
876 | return false; | 1025 | m_items.LockItemsForWrite(false); |
877 | 1026 | ||
1027 | return false; | ||
878 | } | 1028 | } |
879 | 1029 | ||
880 | /// <summary> | 1030 | /// <summary> |
@@ -885,43 +1035,59 @@ namespace OpenSim.Region.Framework.Scenes | |||
885 | /// in this prim's inventory.</returns> | 1035 | /// in this prim's inventory.</returns> |
886 | public int RemoveInventoryItem(UUID itemID) | 1036 | public int RemoveInventoryItem(UUID itemID) |
887 | { | 1037 | { |
888 | TaskInventoryItem item = GetInventoryItem(itemID); | 1038 | m_items.LockItemsForRead(true); |
889 | if (item != null) | 1039 | |
1040 | if (m_items.ContainsKey(itemID)) | ||
890 | { | 1041 | { |
891 | int type = m_items[itemID].InvType; | 1042 | int type = m_items[itemID].InvType; |
1043 | m_items.LockItemsForRead(false); | ||
892 | if (type == 10) // Script | 1044 | if (type == 10) // Script |
893 | { | 1045 | { |
894 | m_part.RemoveScriptEvents(itemID); | ||
895 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 1046 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
896 | } | 1047 | } |
1048 | m_items.LockItemsForWrite(true); | ||
897 | m_items.Remove(itemID); | 1049 | m_items.Remove(itemID); |
1050 | m_items.LockItemsForWrite(false); | ||
898 | m_inventorySerial++; | 1051 | m_inventorySerial++; |
899 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 1052 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
900 | 1053 | ||
901 | HasInventoryChanged = true; | 1054 | HasInventoryChanged = true; |
902 | m_part.ParentGroup.HasGroupChanged = true; | 1055 | m_part.ParentGroup.HasGroupChanged = true; |
903 | 1056 | ||
904 | if (!ContainsScripts()) | 1057 | int scriptcount = 0; |
1058 | m_items.LockItemsForRead(true); | ||
1059 | foreach (TaskInventoryItem item in m_items.Values) | ||
1060 | { | ||
1061 | if (item.Type == 10) | ||
1062 | { | ||
1063 | scriptcount++; | ||
1064 | } | ||
1065 | } | ||
1066 | m_items.LockItemsForRead(false); | ||
1067 | |||
1068 | |||
1069 | if (scriptcount <= 0) | ||
1070 | { | ||
905 | m_part.RemFlag(PrimFlags.Scripted); | 1071 | m_part.RemFlag(PrimFlags.Scripted); |
1072 | } | ||
906 | 1073 | ||
907 | m_part.ScheduleFullUpdate(); | 1074 | m_part.ScheduleFullUpdate(); |
908 | 1075 | ||
909 | return type; | 1076 | return type; |
910 | |||
911 | } | 1077 | } |
912 | else | 1078 | else |
913 | { | 1079 | { |
1080 | m_items.LockItemsForRead(false); | ||
914 | m_log.ErrorFormat( | 1081 | m_log.ErrorFormat( |
915 | "[PRIM INVENTORY]: " + | 1082 | "[PRIM INVENTORY]: " + |
916 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 1083 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", |
917 | itemID, m_part.Name, m_part.UUID, | 1084 | itemID, m_part.Name, m_part.UUID); |
918 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
919 | } | 1085 | } |
920 | 1086 | ||
921 | return -1; | 1087 | return -1; |
922 | } | 1088 | } |
923 | 1089 | ||
924 | private bool CreateInventoryFile() | 1090 | private bool CreateInventoryFileName() |
925 | { | 1091 | { |
926 | // m_log.DebugFormat( | 1092 | // m_log.DebugFormat( |
927 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", | 1093 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", |
@@ -930,70 +1096,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
930 | if (m_inventoryFileName == String.Empty || | 1096 | if (m_inventoryFileName == String.Empty || |
931 | m_inventoryFileNameSerial < m_inventorySerial) | 1097 | m_inventoryFileNameSerial < m_inventorySerial) |
932 | { | 1098 | { |
933 | // Something changed, we need to create a new file | ||
934 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; | 1099 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; |
935 | m_inventoryFileNameSerial = m_inventorySerial; | 1100 | m_inventoryFileNameSerial = m_inventorySerial; |
936 | 1101 | ||
937 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | ||
938 | |||
939 | lock (m_items) | ||
940 | { | ||
941 | foreach (TaskInventoryItem item in m_items.Values) | ||
942 | { | ||
943 | // m_log.DebugFormat( | ||
944 | // "[PRIM INVENTORY]: Adding item {0} {1} for serial {2} on prim {3} {4} {5}", | ||
945 | // item.Name, item.ItemID, m_inventorySerial, m_part.Name, m_part.UUID, m_part.LocalId); | ||
946 | |||
947 | UUID ownerID = item.OwnerID; | ||
948 | uint everyoneMask = 0; | ||
949 | uint baseMask = item.BasePermissions; | ||
950 | uint ownerMask = item.CurrentPermissions; | ||
951 | uint groupMask = item.GroupPermissions; | ||
952 | |||
953 | invString.AddItemStart(); | ||
954 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | ||
955 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
956 | |||
957 | invString.AddPermissionsStart(); | ||
958 | |||
959 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | ||
960 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
961 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
962 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
963 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
964 | |||
965 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
966 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
967 | |||
968 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | ||
969 | |||
970 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | ||
971 | invString.AddSectionEnd(); | ||
972 | |||
973 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | ||
974 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | ||
975 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | ||
976 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
977 | |||
978 | invString.AddSaleStart(); | ||
979 | invString.AddNameValueLine("sale_type", "not"); | ||
980 | invString.AddNameValueLine("sale_price", "0"); | ||
981 | invString.AddSectionEnd(); | ||
982 | |||
983 | invString.AddNameValueLine("name", item.Name + "|"); | ||
984 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
985 | |||
986 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | ||
987 | invString.AddSectionEnd(); | ||
988 | } | ||
989 | } | ||
990 | |||
991 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | ||
992 | |||
993 | return true; | 1102 | return true; |
994 | } | 1103 | } |
995 | 1104 | ||
996 | // No need to recreate, the existing file is fine | ||
997 | return false; | 1105 | return false; |
998 | } | 1106 | } |
999 | 1107 | ||
@@ -1003,43 +1111,110 @@ namespace OpenSim.Region.Framework.Scenes | |||
1003 | /// <param name="xferManager"></param> | 1111 | /// <param name="xferManager"></param> |
1004 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) | 1112 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) |
1005 | { | 1113 | { |
1006 | lock (m_items) | 1114 | bool changed = CreateInventoryFileName(); |
1007 | { | ||
1008 | // Don't send a inventory xfer name if there are no items. Doing so causes viewer 3 to crash when rezzing | ||
1009 | // a new script if any previous deletion has left the prim inventory empty. | ||
1010 | if (m_items.Count == 0) // No inventory | ||
1011 | { | ||
1012 | // m_log.DebugFormat( | ||
1013 | // "[PRIM INVENTORY]: Not sending inventory data for part {0} {1} {2} for {3} since no items", | ||
1014 | // m_part.Name, m_part.LocalId, m_part.UUID, client.Name); | ||
1015 | 1115 | ||
1016 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | 1116 | bool includeAssets = false; |
1017 | return; | 1117 | if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) |
1018 | } | 1118 | includeAssets = true; |
1119 | |||
1120 | if (m_inventoryPrivileged != includeAssets) | ||
1121 | changed = true; | ||
1122 | |||
1123 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | ||
1019 | 1124 | ||
1020 | CreateInventoryFile(); | 1125 | Items.LockItemsForRead(true); |
1126 | |||
1127 | if (m_inventorySerial == 0) // No inventory | ||
1128 | { | ||
1129 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1130 | Items.LockItemsForRead(false); | ||
1131 | return; | ||
1132 | } | ||
1133 | |||
1134 | if (m_items.Count == 0) // No inventory | ||
1135 | { | ||
1136 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1137 | Items.LockItemsForRead(false); | ||
1138 | return; | ||
1139 | } | ||
1021 | 1140 | ||
1022 | // In principle, we should only do the rest if the inventory changed; | 1141 | if (!changed) |
1023 | // by sending m_inventorySerial to the client, it ought to know | 1142 | { |
1024 | // that nothing changed and that it doesn't need to request the file. | ||
1025 | // Unfortunately, it doesn't look like the client optimizes this; | ||
1026 | // the client seems to always come back and request the Xfer, | ||
1027 | // no matter what value m_inventorySerial has. | ||
1028 | // FIXME: Could probably be > 0 here rather than > 2 | ||
1029 | if (m_inventoryFileData.Length > 2) | 1143 | if (m_inventoryFileData.Length > 2) |
1030 | { | 1144 | { |
1031 | // Add the file for Xfer | 1145 | xferManager.AddNewFile(m_inventoryFileName, |
1032 | // m_log.DebugFormat( | 1146 | m_inventoryFileData); |
1033 | // "[PRIM INVENTORY]: Adding inventory file {0} (length {1}) for transfer on {2} {3} {4}", | 1147 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, |
1034 | // m_inventoryFileName, m_inventoryFileData.Length, m_part.Name, m_part.UUID, m_part.LocalId); | 1148 | Util.StringToBytes256(m_inventoryFileName)); |
1035 | 1149 | ||
1036 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | 1150 | Items.LockItemsForRead(false); |
1151 | return; | ||
1037 | } | 1152 | } |
1038 | |||
1039 | // Tell the client we're ready to Xfer the file | ||
1040 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
1041 | Util.StringToBytes256(m_inventoryFileName)); | ||
1042 | } | 1153 | } |
1154 | |||
1155 | m_inventoryPrivileged = includeAssets; | ||
1156 | |||
1157 | foreach (TaskInventoryItem item in m_items.Values) | ||
1158 | { | ||
1159 | UUID ownerID = item.OwnerID; | ||
1160 | uint everyoneMask = 0; | ||
1161 | uint baseMask = item.BasePermissions; | ||
1162 | uint ownerMask = item.CurrentPermissions; | ||
1163 | uint groupMask = item.GroupPermissions; | ||
1164 | |||
1165 | invString.AddItemStart(); | ||
1166 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | ||
1167 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
1168 | |||
1169 | invString.AddPermissionsStart(); | ||
1170 | |||
1171 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | ||
1172 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
1173 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
1174 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
1175 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
1176 | |||
1177 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
1178 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
1179 | |||
1180 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | ||
1181 | |||
1182 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | ||
1183 | invString.AddSectionEnd(); | ||
1184 | |||
1185 | if (includeAssets) | ||
1186 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | ||
1187 | else | ||
1188 | invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); | ||
1189 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | ||
1190 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | ||
1191 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
1192 | |||
1193 | invString.AddSaleStart(); | ||
1194 | invString.AddNameValueLine("sale_type", "not"); | ||
1195 | invString.AddNameValueLine("sale_price", "0"); | ||
1196 | invString.AddSectionEnd(); | ||
1197 | |||
1198 | invString.AddNameValueLine("name", item.Name + "|"); | ||
1199 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
1200 | |||
1201 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | ||
1202 | invString.AddSectionEnd(); | ||
1203 | } | ||
1204 | |||
1205 | Items.LockItemsForRead(false); | ||
1206 | |||
1207 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | ||
1208 | |||
1209 | if (m_inventoryFileData.Length > 2) | ||
1210 | { | ||
1211 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | ||
1212 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
1213 | Util.StringToBytes256(m_inventoryFileName)); | ||
1214 | return; | ||
1215 | } | ||
1216 | |||
1217 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1043 | } | 1218 | } |
1044 | 1219 | ||
1045 | /// <summary> | 1220 | /// <summary> |
@@ -1048,13 +1223,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1048 | /// <param name="datastore"></param> | 1223 | /// <param name="datastore"></param> |
1049 | public void ProcessInventoryBackup(ISimulationDataService datastore) | 1224 | public void ProcessInventoryBackup(ISimulationDataService datastore) |
1050 | { | 1225 | { |
1051 | if (HasInventoryChanged) | 1226 | // Removed this because linking will cause an immediate delete of the new |
1052 | { | 1227 | // child prim from the database and the subsequent storing of the prim sees |
1053 | HasInventoryChanged = false; | 1228 | // the inventory of it as unchanged and doesn't store it at all. The overhead |
1054 | List<TaskInventoryItem> items = GetInventoryItems(); | 1229 | // of storing prim inventory needlessly is much less than the aggravation |
1055 | datastore.StorePrimInventory(m_part.UUID, items); | 1230 | // of prim inventory loss. |
1231 | // if (HasInventoryChanged) | ||
1232 | // { | ||
1233 | Items.LockItemsForRead(true); | ||
1234 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | ||
1235 | Items.LockItemsForRead(false); | ||
1056 | 1236 | ||
1057 | } | 1237 | HasInventoryChanged = false; |
1238 | // } | ||
1058 | } | 1239 | } |
1059 | 1240 | ||
1060 | public class InventoryStringBuilder | 1241 | public class InventoryStringBuilder |
@@ -1120,87 +1301,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
1120 | { | 1301 | { |
1121 | uint mask=0x7fffffff; | 1302 | uint mask=0x7fffffff; |
1122 | 1303 | ||
1123 | lock (m_items) | 1304 | foreach (TaskInventoryItem item in m_items.Values) |
1124 | { | 1305 | { |
1125 | foreach (TaskInventoryItem item in m_items.Values) | 1306 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) |
1307 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1308 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1309 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1310 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1311 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1312 | |||
1313 | if (item.InvType == (int)InventoryType.Object) | ||
1126 | { | 1314 | { |
1127 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | 1315 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1128 | mask &= ~((uint)PermissionMask.Copy >> 13); | 1316 | mask &= ~((uint)PermissionMask.Copy >> 13); |
1129 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | 1317 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1130 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1318 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
1131 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | 1319 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1132 | mask &= ~((uint)PermissionMask.Modify >> 13); | 1320 | mask &= ~((uint)PermissionMask.Modify >> 13); |
1133 | |||
1134 | if (item.InvType != (int)InventoryType.Object) | ||
1135 | { | ||
1136 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | ||
1137 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1138 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1139 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1140 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1141 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1142 | } | ||
1143 | else | ||
1144 | { | ||
1145 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1146 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1147 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1148 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1149 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1150 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1151 | } | ||
1152 | |||
1153 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1154 | mask &= ~(uint)PermissionMask.Copy; | ||
1155 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1156 | mask &= ~(uint)PermissionMask.Transfer; | ||
1157 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1158 | mask &= ~(uint)PermissionMask.Modify; | ||
1159 | } | 1321 | } |
1322 | |||
1323 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1324 | mask &= ~(uint)PermissionMask.Copy; | ||
1325 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1326 | mask &= ~(uint)PermissionMask.Transfer; | ||
1327 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1328 | mask &= ~(uint)PermissionMask.Modify; | ||
1160 | } | 1329 | } |
1161 | |||
1162 | return mask; | 1330 | return mask; |
1163 | } | 1331 | } |
1164 | 1332 | ||
1165 | public void ApplyNextOwnerPermissions() | 1333 | public void ApplyNextOwnerPermissions() |
1166 | { | 1334 | { |
1167 | lock (m_items) | 1335 | foreach (TaskInventoryItem item in m_items.Values) |
1168 | { | 1336 | { |
1169 | foreach (TaskInventoryItem item in m_items.Values) | 1337 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) |
1170 | { | 1338 | { |
1171 | // m_log.DebugFormat ( | 1339 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1172 | // "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", | 1340 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |
1173 | // item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); | 1341 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1174 | 1342 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | |
1175 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) | 1343 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1176 | { | 1344 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
1177 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1178 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | ||
1179 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1180 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | ||
1181 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1182 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | ||
1183 | } | ||
1184 | |||
1185 | item.CurrentPermissions &= item.NextPermissions; | ||
1186 | item.BasePermissions &= item.NextPermissions; | ||
1187 | item.EveryonePermissions &= item.NextPermissions; | ||
1188 | item.OwnerChanged = true; | ||
1189 | item.PermsMask = 0; | ||
1190 | item.PermsGranter = UUID.Zero; | ||
1191 | } | 1345 | } |
1346 | item.CurrentPermissions &= item.NextPermissions; | ||
1347 | item.BasePermissions &= item.NextPermissions; | ||
1348 | item.EveryonePermissions &= item.NextPermissions; | ||
1349 | item.OwnerChanged = true; | ||
1350 | item.PermsMask = 0; | ||
1351 | item.PermsGranter = UUID.Zero; | ||
1192 | } | 1352 | } |
1193 | } | 1353 | } |
1194 | 1354 | ||
1195 | public void ApplyGodPermissions(uint perms) | 1355 | public void ApplyGodPermissions(uint perms) |
1196 | { | 1356 | { |
1197 | lock (m_items) | 1357 | foreach (TaskInventoryItem item in m_items.Values) |
1198 | { | 1358 | { |
1199 | foreach (TaskInventoryItem item in m_items.Values) | 1359 | item.CurrentPermissions = perms; |
1200 | { | 1360 | item.BasePermissions = perms; |
1201 | item.CurrentPermissions = perms; | ||
1202 | item.BasePermissions = perms; | ||
1203 | } | ||
1204 | } | 1361 | } |
1205 | 1362 | ||
1206 | m_inventorySerial++; | 1363 | m_inventorySerial++; |
@@ -1213,14 +1370,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1213 | /// <returns></returns> | 1370 | /// <returns></returns> |
1214 | public bool ContainsScripts() | 1371 | public bool ContainsScripts() |
1215 | { | 1372 | { |
1216 | lock (m_items) | 1373 | foreach (TaskInventoryItem item in m_items.Values) |
1217 | { | 1374 | { |
1218 | foreach (TaskInventoryItem item in m_items.Values) | 1375 | if (item.InvType == (int)InventoryType.LSL) |
1219 | { | 1376 | { |
1220 | if (item.InvType == (int)InventoryType.LSL) | 1377 | return true; |
1221 | { | ||
1222 | return true; | ||
1223 | } | ||
1224 | } | 1378 | } |
1225 | } | 1379 | } |
1226 | 1380 | ||
@@ -1234,17 +1388,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1234 | public int ScriptCount() | 1388 | public int ScriptCount() |
1235 | { | 1389 | { |
1236 | int count = 0; | 1390 | int count = 0; |
1237 | lock (m_items) | 1391 | Items.LockItemsForRead(true); |
1392 | foreach (TaskInventoryItem item in m_items.Values) | ||
1238 | { | 1393 | { |
1239 | foreach (TaskInventoryItem item in m_items.Values) | 1394 | if (item.InvType == (int)InventoryType.LSL) |
1240 | { | 1395 | { |
1241 | if (item.InvType == (int)InventoryType.LSL) | 1396 | count++; |
1242 | { | ||
1243 | count++; | ||
1244 | } | ||
1245 | } | 1397 | } |
1246 | } | 1398 | } |
1247 | 1399 | Items.LockItemsForRead(false); | |
1248 | return count; | 1400 | return count; |
1249 | } | 1401 | } |
1250 | /// <summary> | 1402 | /// <summary> |
@@ -1280,11 +1432,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1280 | { | 1432 | { |
1281 | List<UUID> ret = new List<UUID>(); | 1433 | List<UUID> ret = new List<UUID>(); |
1282 | 1434 | ||
1283 | lock (m_items) | 1435 | foreach (TaskInventoryItem item in m_items.Values) |
1284 | { | 1436 | ret.Add(item.ItemID); |
1285 | foreach (TaskInventoryItem item in m_items.Values) | ||
1286 | ret.Add(item.ItemID); | ||
1287 | } | ||
1288 | 1437 | ||
1289 | return ret; | 1438 | return ret; |
1290 | } | 1439 | } |
@@ -1293,8 +1442,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1293 | { | 1442 | { |
1294 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1443 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1295 | 1444 | ||
1296 | lock (m_items) | 1445 | Items.LockItemsForRead(true); |
1297 | ret = new List<TaskInventoryItem>(m_items.Values); | 1446 | ret = new List<TaskInventoryItem>(m_items.Values); |
1447 | Items.LockItemsForRead(false); | ||
1298 | 1448 | ||
1299 | return ret; | 1449 | return ret; |
1300 | } | 1450 | } |
@@ -1303,18 +1453,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1303 | { | 1453 | { |
1304 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1454 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1305 | 1455 | ||
1306 | lock (m_items) | 1456 | Items.LockItemsForRead(true); |
1307 | { | 1457 | |
1308 | foreach (TaskInventoryItem item in m_items.Values) | 1458 | foreach (TaskInventoryItem item in m_items.Values) |
1309 | if (item.InvType == (int)type) | 1459 | if (item.InvType == (int)type) |
1310 | ret.Add(item); | 1460 | ret.Add(item); |
1311 | } | 1461 | |
1462 | Items.LockItemsForRead(false); | ||
1312 | 1463 | ||
1313 | return ret; | 1464 | return ret; |
1314 | } | 1465 | } |
1315 | 1466 | ||
1316 | public Dictionary<UUID, string> GetScriptStates() | 1467 | public Dictionary<UUID, string> GetScriptStates() |
1317 | { | 1468 | { |
1469 | return GetScriptStates(false); | ||
1470 | } | ||
1471 | |||
1472 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1473 | { | ||
1318 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1474 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
1319 | 1475 | ||
1320 | if (m_part.ParentGroup.Scene == null) // Group not in a scene | 1476 | if (m_part.ParentGroup.Scene == null) // Group not in a scene |
@@ -1340,14 +1496,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1340 | string n = e.GetXMLState(item.ItemID); | 1496 | string n = e.GetXMLState(item.ItemID); |
1341 | if (n != String.Empty) | 1497 | if (n != String.Empty) |
1342 | { | 1498 | { |
1343 | if (!ret.ContainsKey(item.ItemID)) | 1499 | if (oldIDs) |
1344 | ret[item.ItemID] = n; | 1500 | { |
1501 | if (!ret.ContainsKey(item.OldItemID)) | ||
1502 | ret[item.OldItemID] = n; | ||
1503 | } | ||
1504 | else | ||
1505 | { | ||
1506 | if (!ret.ContainsKey(item.ItemID)) | ||
1507 | ret[item.ItemID] = n; | ||
1508 | } | ||
1345 | break; | 1509 | break; |
1346 | } | 1510 | } |
1347 | } | 1511 | } |
1348 | } | 1512 | } |
1349 | } | 1513 | } |
1350 | |||
1351 | return ret; | 1514 | return ret; |
1352 | } | 1515 | } |
1353 | 1516 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cf98ef2..8ff17f6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -936,8 +936,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
936 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 936 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
937 | ControllingClient.OnStartAnim += HandleStartAnim; | 937 | ControllingClient.OnStartAnim += HandleStartAnim; |
938 | ControllingClient.OnStopAnim += HandleStopAnim; | 938 | ControllingClient.OnStopAnim += HandleStopAnim; |
939 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
939 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 940 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
940 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 941 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
942 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
941 | 943 | ||
942 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 944 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
943 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 945 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -1553,9 +1555,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1553 | 1555 | ||
1554 | public void SetSize(Vector3 size, float feetoffset) | 1556 | public void SetSize(Vector3 size, float feetoffset) |
1555 | { | 1557 | { |
1556 | // TODO: Merge the physics bits | 1558 | if (PhysicsActor != null && !IsChildAgent) |
1557 | // if (PhysicsActor != null && !IsChildAgent) | 1559 | PhysicsActor.setAvatarSize(size, feetoffset); |
1558 | // PhysicsActor.setAvatarSize(size, feetoffset); | ||
1559 | 1560 | ||
1560 | } | 1561 | } |
1561 | 1562 | ||
@@ -2705,9 +2706,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2705 | // returns false if does not suport so older sit can be tried | 2706 | // returns false if does not suport so older sit can be tried |
2706 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) | 2707 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) |
2707 | { | 2708 | { |
2708 | // TODO: Pull in these bits | ||
2709 | return false; | ||
2710 | /* | ||
2711 | if (part == null || part.ParentGroup.IsAttachment) | 2709 | if (part == null || part.ParentGroup.IsAttachment) |
2712 | { | 2710 | { |
2713 | return true; | 2711 | return true; |
@@ -2737,7 +2735,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2737 | return true; | 2735 | return true; |
2738 | 2736 | ||
2739 | return false; | 2737 | return false; |
2740 | */ | ||
2741 | } | 2738 | } |
2742 | 2739 | ||
2743 | 2740 | ||
@@ -2952,6 +2949,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2952 | TriggerScenePresenceUpdated(); | 2949 | TriggerScenePresenceUpdated(); |
2953 | } | 2950 | } |
2954 | 2951 | ||
2952 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2953 | { | ||
2954 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2955 | } | ||
2956 | |||
2957 | |||
2958 | |||
2955 | /// <summary> | 2959 | /// <summary> |
2956 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2960 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2957 | /// </summary> | 2961 | /// </summary> |
@@ -3684,6 +3688,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3684 | 3688 | ||
3685 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3689 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3686 | 3690 | ||
3691 | private void RaiseUpdateThrottles() | ||
3692 | { | ||
3693 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
3694 | } | ||
3695 | |||
3687 | /// <summary> | 3696 | /// <summary> |
3688 | /// This updates important decision making data about a child agent | 3697 | /// This updates important decision making data about a child agent |
3689 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3698 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3930,7 +3939,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3930 | 3939 | ||
3931 | PhysicsActor = scene.AddAvatar( | 3940 | PhysicsActor = scene.AddAvatar( |
3932 | LocalId, Firstname + "." + Lastname, pVec, | 3941 | LocalId, Firstname + "." + Lastname, pVec, |
3933 | Appearance.AvatarBoxSize, isFlying); | 3942 | Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); |
3934 | 3943 | ||
3935 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3944 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3936 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3945 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
@@ -3989,7 +3998,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
3989 | // m_lastColCount = coldata.Count; | 3998 | // m_lastColCount = coldata.Count; |
3990 | // } | 3999 | // } |
3991 | 4000 | ||
3992 | CollisionPlane = Vector4.UnitW; | 4001 | if (coldata.Count != 0) |
4002 | { | ||
4003 | /* | ||
4004 | switch (Animator.CurrentMovementAnimation) | ||
4005 | { | ||
4006 | case "STAND": | ||
4007 | case "WALK": | ||
4008 | case "RUN": | ||
4009 | case "CROUCH": | ||
4010 | case "CROUCHWALK": | ||
4011 | { | ||
4012 | */ | ||
4013 | ContactPoint lowest; | ||
4014 | lowest.SurfaceNormal = Vector3.Zero; | ||
4015 | lowest.Position = Vector3.Zero; | ||
4016 | lowest.Position.Z = float.MaxValue; | ||
4017 | |||
4018 | foreach (ContactPoint contact in coldata.Values) | ||
4019 | { | ||
4020 | |||
4021 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | ||
4022 | { | ||
4023 | lowest = contact; | ||
4024 | } | ||
4025 | } | ||
4026 | |||
4027 | if (lowest.Position.Z != float.MaxValue) | ||
4028 | { | ||
4029 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | ||
4030 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
4031 | } | ||
4032 | else | ||
4033 | CollisionPlane = Vector4.UnitW; | ||
4034 | /* | ||
4035 | } | ||
4036 | break; | ||
4037 | } | ||
4038 | */ | ||
4039 | } | ||
4040 | else | ||
4041 | CollisionPlane = Vector4.UnitW; | ||
4042 | |||
4043 | RaiseCollisionScriptEvents(coldata); | ||
3993 | 4044 | ||
3994 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 4045 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3995 | if (Invulnerable || GodLevel > 0) | 4046 | if (Invulnerable || GodLevel > 0) |
@@ -4891,6 +4942,93 @@ namespace OpenSim.Region.Framework.Scenes | |||
4891 | } | 4942 | } |
4892 | } | 4943 | } |
4893 | 4944 | ||
4945 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4946 | { | ||
4947 | try | ||
4948 | { | ||
4949 | List<uint> thisHitColliders = new List<uint>(); | ||
4950 | List<uint> endedColliders = new List<uint>(); | ||
4951 | List<uint> startedColliders = new List<uint>(); | ||
4952 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4953 | CollisionForSoundInfo soundinfo; | ||
4954 | ContactPoint curcontact; | ||
4955 | |||
4956 | if (coldata.Count == 0) | ||
4957 | { | ||
4958 | if (m_lastColliders.Count == 0) | ||
4959 | return; // nothing to do | ||
4960 | |||
4961 | foreach (uint localID in m_lastColliders) | ||
4962 | { | ||
4963 | endedColliders.Add(localID); | ||
4964 | } | ||
4965 | m_lastColliders.Clear(); | ||
4966 | } | ||
4967 | |||
4968 | else | ||
4969 | { | ||
4970 | foreach (uint id in coldata.Keys) | ||
4971 | { | ||
4972 | thisHitColliders.Add(id); | ||
4973 | if (!m_lastColliders.Contains(id)) | ||
4974 | { | ||
4975 | startedColliders.Add(id); | ||
4976 | curcontact = coldata[id]; | ||
4977 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4978 | { | ||
4979 | soundinfo = new CollisionForSoundInfo(); | ||
4980 | soundinfo.colliderID = id; | ||
4981 | soundinfo.position = curcontact.Position; | ||
4982 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4983 | soundinfolist.Add(soundinfo); | ||
4984 | } | ||
4985 | } | ||
4986 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4987 | } | ||
4988 | |||
4989 | // calculate things that ended colliding | ||
4990 | foreach (uint localID in m_lastColliders) | ||
4991 | { | ||
4992 | if (!thisHitColliders.Contains(localID)) | ||
4993 | { | ||
4994 | endedColliders.Add(localID); | ||
4995 | } | ||
4996 | } | ||
4997 | //add the items that started colliding this time to the last colliders list. | ||
4998 | foreach (uint localID in startedColliders) | ||
4999 | { | ||
5000 | m_lastColliders.Add(localID); | ||
5001 | } | ||
5002 | // remove things that ended colliding from the last colliders list | ||
5003 | foreach (uint localID in endedColliders) | ||
5004 | { | ||
5005 | m_lastColliders.Remove(localID); | ||
5006 | } | ||
5007 | |||
5008 | if (soundinfolist.Count > 0) | ||
5009 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
5010 | } | ||
5011 | |||
5012 | foreach (SceneObjectGroup att in GetAttachments()) | ||
5013 | { | ||
5014 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
5015 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
5016 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
5017 | |||
5018 | if (startedColliders.Contains(0)) | ||
5019 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
5020 | if (m_lastColliders.Contains(0)) | ||
5021 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
5022 | if (endedColliders.Contains(0)) | ||
5023 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
5024 | } | ||
5025 | } | ||
5026 | finally | ||
5027 | { | ||
5028 | m_collisionEventFlag = false; | ||
5029 | } | ||
5030 | } | ||
5031 | |||
4894 | private void TeleportFlagsDebug() { | 5032 | private void TeleportFlagsDebug() { |
4895 | 5033 | ||
4896 | // Some temporary debugging help to show all the TeleportFlags we have... | 5034 | // Some temporary debugging help to show all the TeleportFlags we have... |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index f07dee9..5372360 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -375,11 +375,21 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
375 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); | 375 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); |
376 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); | 376 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); |
377 | 377 | ||
378 | m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); | ||
379 | m_SOPXmlProcessors.Add("Force", ProcessForce); | ||
380 | m_SOPXmlProcessors.Add("Torque", ProcessTorque); | ||
381 | m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); | ||
382 | |||
383 | |||
384 | m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); | ||
385 | |||
378 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); | 386 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); |
379 | m_SOPXmlProcessors.Add("Density", ProcessDensity); | 387 | m_SOPXmlProcessors.Add("Density", ProcessDensity); |
380 | m_SOPXmlProcessors.Add("Friction", ProcessFriction); | 388 | m_SOPXmlProcessors.Add("Friction", ProcessFriction); |
381 | m_SOPXmlProcessors.Add("Bounce", ProcessBounce); | 389 | m_SOPXmlProcessors.Add("Bounce", ProcessBounce); |
382 | m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); | 390 | m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); |
391 | m_SOPXmlProcessors.Add("CameraEyeOffset", ProcessCameraEyeOffset); | ||
392 | m_SOPXmlProcessors.Add("CameraAtOffset", ProcessCameraAtOffset); | ||
383 | 393 | ||
384 | #endregion | 394 | #endregion |
385 | 395 | ||
@@ -408,7 +418,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
408 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); | 418 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); |
409 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); | 419 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); |
410 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); | 420 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); |
411 | 421 | ||
412 | #endregion | 422 | #endregion |
413 | 423 | ||
414 | #region ShapeXmlProcessors initialization | 424 | #region ShapeXmlProcessors initialization |
@@ -634,6 +644,33 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
634 | obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); | 644 | obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); |
635 | } | 645 | } |
636 | 646 | ||
647 | private static void ProcessCameraEyeOffset(SceneObjectPart obj, XmlTextReader reader) | ||
648 | { | ||
649 | obj.SetCameraEyeOffset(Util.ReadVector(reader, "CameraEyeOffset")); | ||
650 | } | ||
651 | |||
652 | private static void ProcessCameraAtOffset(SceneObjectPart obj, XmlTextReader reader) | ||
653 | { | ||
654 | obj.SetCameraAtOffset(Util.ReadVector(reader, "CameraAtOffset")); | ||
655 | } | ||
656 | |||
657 | private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) | ||
658 | { | ||
659 | SOPVehicle vehicle = SOPVehicle.FromXml2(reader); | ||
660 | |||
661 | if (vehicle == null) | ||
662 | { | ||
663 | obj.VehicleParams = null; | ||
664 | m_log.DebugFormat( | ||
665 | "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.", | ||
666 | obj.Name, obj.UUID); | ||
667 | } | ||
668 | else | ||
669 | { | ||
670 | obj.VehicleParams = vehicle; | ||
671 | } | ||
672 | } | ||
673 | |||
637 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) | 674 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) |
638 | { | 675 | { |
639 | List<string> errorNodeNames; | 676 | List<string> errorNodeNames; |
@@ -808,6 +845,25 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
808 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); | 845 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); |
809 | } | 846 | } |
810 | 847 | ||
848 | private static void ProcessBuoyancy(SceneObjectPart obj, XmlTextReader reader) | ||
849 | { | ||
850 | obj.Buoyancy = (float)reader.ReadElementContentAsFloat("Buoyancy", String.Empty); | ||
851 | } | ||
852 | |||
853 | private static void ProcessForce(SceneObjectPart obj, XmlTextReader reader) | ||
854 | { | ||
855 | obj.Force = Util.ReadVector(reader, "Force"); | ||
856 | } | ||
857 | private static void ProcessTorque(SceneObjectPart obj, XmlTextReader reader) | ||
858 | { | ||
859 | obj.Torque = Util.ReadVector(reader, "Torque"); | ||
860 | } | ||
861 | |||
862 | private static void ProcessVolumeDetectActive(SceneObjectPart obj, XmlTextReader reader) | ||
863 | { | ||
864 | obj.VolumeDetectActive = Util.ReadBoolean(reader); | ||
865 | } | ||
866 | |||
811 | #endregion | 867 | #endregion |
812 | 868 | ||
813 | #region TaskInventoryXmlProcessors | 869 | #region TaskInventoryXmlProcessors |
@@ -1203,7 +1259,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1203 | 1259 | ||
1204 | if (sog.RootPart.KeyframeMotion != null) | 1260 | if (sog.RootPart.KeyframeMotion != null) |
1205 | { | 1261 | { |
1206 | Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); | 1262 | Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); |
1207 | 1263 | ||
1208 | writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); | 1264 | writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); |
1209 | writer.WriteBase64(data, 0, data.Length); | 1265 | writer.WriteBase64(data, 0, data.Length); |
@@ -1318,6 +1374,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1318 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); | 1374 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); |
1319 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); | 1375 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); |
1320 | 1376 | ||
1377 | writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); | ||
1378 | |||
1379 | WriteVector(writer, "Force", sop.Force); | ||
1380 | WriteVector(writer, "Torque", sop.Torque); | ||
1381 | |||
1382 | writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); | ||
1383 | |||
1384 | if (sop.VehicleParams != null) | ||
1385 | sop.VehicleParams.ToXml2(writer); | ||
1386 | |||
1321 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) | 1387 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) |
1322 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); | 1388 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); |
1323 | if (sop.Density != 1000.0f) | 1389 | if (sop.Density != 1000.0f) |
@@ -1328,6 +1394,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1328 | writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); | 1394 | writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); |
1329 | if (sop.GravityModifier != 1.0f) | 1395 | if (sop.GravityModifier != 1.0f) |
1330 | writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); | 1396 | writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); |
1397 | WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); | ||
1398 | WriteVector(writer, "CameraAtOffset", sop.GetCameraAtOffset()); | ||
1331 | 1399 | ||
1332 | writer.WriteEndElement(); | 1400 | writer.WriteEndElement(); |
1333 | } | 1401 | } |
@@ -1554,12 +1622,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1554 | { | 1622 | { |
1555 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); | 1623 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); |
1556 | 1624 | ||
1557 | if (reader.IsEmptyElement) | ||
1558 | { | ||
1559 | reader.Read(); | ||
1560 | return tinv; | ||
1561 | } | ||
1562 | |||
1563 | reader.ReadStartElement(name, String.Empty); | 1625 | reader.ReadStartElement(name, String.Empty); |
1564 | 1626 | ||
1565 | while (reader.Name == "TaskInventoryItem") | 1627 | while (reader.Name == "TaskInventoryItem") |
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 95f9caf..bf32251 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |||
@@ -175,7 +175,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
175 | 175 | ||
176 | // saved last reported value so there is something available for llGetRegionFPS | 176 | // saved last reported value so there is something available for llGetRegionFPS |
177 | private float lastReportedSimFPS; | 177 | private float lastReportedSimFPS; |
178 | private float[] lastReportedSimStats = new float[22]; | 178 | private float[] lastReportedSimStats = new float[23]; |
179 | private float m_pfps; | 179 | private float m_pfps; |
180 | 180 | ||
181 | /// <summary> | 181 | /// <summary> |
@@ -189,12 +189,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
189 | private int m_objectUpdates; | 189 | private int m_objectUpdates; |
190 | 190 | ||
191 | private int m_frameMS; | 191 | private int m_frameMS; |
192 | private int m_spareMS; | 192 | |
193 | private int m_netMS; | 193 | private int m_netMS; |
194 | private int m_agentMS; | 194 | private int m_agentMS; |
195 | private int m_physicsMS; | 195 | private int m_physicsMS; |
196 | private int m_imageMS; | 196 | private int m_imageMS; |
197 | private int m_otherMS; | 197 | private int m_otherMS; |
198 | private int m_sleeptimeMS; | ||
198 | 199 | ||
199 | //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. | 200 | //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. |
200 | //Ckrinke private int m_scriptMS = 0; | 201 | //Ckrinke private int m_scriptMS = 0; |
@@ -292,7 +293,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
292 | if (!m_scene.Active) | 293 | if (!m_scene.Active) |
293 | return; | 294 | return; |
294 | 295 | ||
295 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; | 296 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; |
296 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); | 297 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); |
297 | 298 | ||
298 | // Know what's not thread safe in Mono... modifying timers. | 299 | // Know what's not thread safe in Mono... modifying timers. |
@@ -330,6 +331,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
330 | physfps = 0; | 331 | physfps = 0; |
331 | 332 | ||
332 | #endregion | 333 | #endregion |
334 | float factor = 1 / m_statsUpdateFactor; | ||
335 | |||
336 | if (reportedFPS <= 0) | ||
337 | reportedFPS = 1; | ||
338 | |||
339 | float perframe = 1.0f / (float)reportedFPS; | ||
340 | |||
341 | float TotalFrameTime = m_frameMS * perframe; | ||
342 | |||
343 | float targetframetime = 1100.0f / (float)m_nominalReportedFps; | ||
344 | |||
345 | float sparetime; | ||
346 | float sleeptime; | ||
347 | |||
348 | if (TotalFrameTime > targetframetime) | ||
349 | { | ||
350 | sparetime = 0; | ||
351 | sleeptime = 0; | ||
352 | } | ||
353 | else | ||
354 | { | ||
355 | sparetime = m_frameMS - m_physicsMS - m_agentMS; | ||
356 | sparetime *= perframe; | ||
357 | if (sparetime < 0) | ||
358 | sparetime = 0; | ||
359 | else if (sparetime > TotalFrameTime) | ||
360 | sparetime = TotalFrameTime; | ||
361 | sleeptime = m_sleeptimeMS * perframe; | ||
362 | } | ||
333 | 363 | ||
334 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); | 364 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); |
335 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); | 365 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); |
@@ -341,25 +371,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
341 | // so that stat numbers are always consistent. | 371 | // so that stat numbers are always consistent. |
342 | CheckStatSanity(); | 372 | CheckStatSanity(); |
343 | 373 | ||
344 | //Our time dilation is 0.91 when we're running a full speed, | 374 | // other MS is actually simulation time |
345 | // therefore to make sure we get an appropriate range, | 375 | // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; |
346 | // we have to factor in our error. (0.10f * statsUpdateFactor) | 376 | // m_imageMS m_netMS are not included in m_frameMS |
347 | // multiplies the fix for the error times the amount of times it'll occur a second | ||
348 | // / 10 divides the value by the number of times the sim heartbeat runs (10fps) | ||
349 | // Then we divide the whole amount by the amount of seconds pass in between stats updates. | ||
350 | |||
351 | // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change | ||
352 | // values to X-per-second values. | ||
353 | 377 | ||
354 | uint thisFrame = m_scene.Frame; | 378 | m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; |
355 | float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; | 379 | if (m_otherMS < 0) |
356 | m_lastUpdateFrame = thisFrame; | 380 | m_otherMS = 0; |
357 | 381 | ||
358 | // Avoid div-by-zero if somehow we've not updated any frames. | 382 | for (int i = 0; i < 23; i++) |
359 | if (framesUpdated == 0) | ||
360 | framesUpdated = 1; | ||
361 | |||
362 | for (int i = 0; i < 22; i++) | ||
363 | { | 383 | { |
364 | sb[i] = new SimStatsPacket.StatBlock(); | 384 | sb[i] = new SimStatsPacket.StatBlock(); |
365 | } | 385 | } |
@@ -389,19 +409,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
389 | sb[7].StatValue = m_activePrim; | 409 | sb[7].StatValue = m_activePrim; |
390 | 410 | ||
391 | sb[8].StatID = (uint)Stats.FrameMS; | 411 | sb[8].StatID = (uint)Stats.FrameMS; |
392 | sb[8].StatValue = m_frameMS / framesUpdated; | 412 | sb[8].StatValue = TotalFrameTime; |
393 | 413 | ||
394 | sb[9].StatID = (uint)Stats.NetMS; | 414 | sb[9].StatID = (uint)Stats.NetMS; |
395 | sb[9].StatValue = m_netMS / framesUpdated; | 415 | sb[9].StatValue = m_netMS * perframe; |
396 | 416 | ||
397 | sb[10].StatID = (uint)Stats.PhysicsMS; | 417 | sb[10].StatID = (uint)Stats.PhysicsMS; |
398 | sb[10].StatValue = m_physicsMS / framesUpdated; | 418 | sb[10].StatValue = m_physicsMS * perframe; |
399 | 419 | ||
400 | sb[11].StatID = (uint)Stats.ImageMS ; | 420 | sb[11].StatID = (uint)Stats.ImageMS ; |
401 | sb[11].StatValue = m_imageMS / framesUpdated; | 421 | sb[11].StatValue = m_imageMS * perframe; |
402 | 422 | ||
403 | sb[12].StatID = (uint)Stats.OtherMS; | 423 | sb[12].StatID = (uint)Stats.OtherMS; |
404 | sb[12].StatValue = m_otherMS / framesUpdated; | 424 | sb[12].StatValue = m_otherMS * perframe; |
405 | 425 | ||
406 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; | 426 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; |
407 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); | 427 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); |
@@ -413,7 +433,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
413 | sb[15].StatValue = m_unAckedBytes; | 433 | sb[15].StatValue = m_unAckedBytes; |
414 | 434 | ||
415 | sb[16].StatID = (uint)Stats.AgentMS; | 435 | sb[16].StatID = (uint)Stats.AgentMS; |
416 | sb[16].StatValue = m_agentMS / framesUpdated; | 436 | sb[16].StatValue = m_agentMS * perframe; |
417 | 437 | ||
418 | sb[17].StatID = (uint)Stats.PendingDownloads; | 438 | sb[17].StatID = (uint)Stats.PendingDownloads; |
419 | sb[17].StatValue = m_pendingDownloads; | 439 | sb[17].StatValue = m_pendingDownloads; |
@@ -428,7 +448,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
428 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; | 448 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; |
429 | 449 | ||
430 | sb[21].StatID = (uint)Stats.SimSpareMs; | 450 | sb[21].StatID = (uint)Stats.SimSpareMs; |
431 | sb[21].StatValue = m_spareMS / framesUpdated; | 451 | sb[21].StatValue = sparetime; |
452 | |||
453 | sb[22].StatID = (uint)Stats.SimSleepMs; | ||
454 | sb[22].StatValue = sleeptime; | ||
432 | 455 | ||
433 | for (int i = 0; i < 22; i++) | 456 | for (int i = 0; i < 22; i++) |
434 | { | 457 | { |
@@ -447,28 +470,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
447 | } | 470 | } |
448 | 471 | ||
449 | // Extra statistics that aren't currently sent to clients | 472 | // Extra statistics that aren't currently sent to clients |
450 | lock (m_lastReportedExtraSimStats) | 473 | if (m_scene.PhysicsScene != null) |
451 | { | 474 | { |
452 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; | 475 | lock (m_lastReportedExtraSimStats) |
453 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
454 | |||
455 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
456 | |||
457 | if (physicsStats != null) | ||
458 | { | 476 | { |
459 | foreach (KeyValuePair<string, float> tuple in physicsStats) | 477 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; |
478 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
479 | |||
480 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
481 | |||
482 | if (physicsStats != null) | ||
460 | { | 483 | { |
461 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second | 484 | foreach (KeyValuePair<string, float> tuple in physicsStats) |
462 | // Need to change things so that stats source can indicate whether they are per second or | 485 | { |
463 | // per frame. | 486 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second |
464 | if (tuple.Key.EndsWith("MS")) | 487 | // Need to change things so that stats source can indicate whether they are per second or |
465 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; | 488 | // per frame. |
466 | else | 489 | if (tuple.Key.EndsWith("MS")) |
467 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | 490 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; |
491 | else | ||
492 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | ||
493 | } | ||
468 | } | 494 | } |
469 | } | 495 | } |
470 | } | 496 | } |
471 | 497 | ||
498 | // LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor; | ||
472 | ResetValues(); | 499 | ResetValues(); |
473 | } | 500 | } |
474 | } | 501 | } |
@@ -491,7 +518,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
491 | m_physicsMS = 0; | 518 | m_physicsMS = 0; |
492 | m_imageMS = 0; | 519 | m_imageMS = 0; |
493 | m_otherMS = 0; | 520 | m_otherMS = 0; |
494 | m_spareMS = 0; | 521 | // m_spareMS = 0; |
522 | m_sleeptimeMS = 0; | ||
495 | 523 | ||
496 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. | 524 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. |
497 | //Ckrinke m_scriptMS = 0; | 525 | //Ckrinke m_scriptMS = 0; |
@@ -575,11 +603,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
575 | SlowFramesStat.Value++; | 603 | SlowFramesStat.Value++; |
576 | } | 604 | } |
577 | 605 | ||
578 | public void AddSpareMS(int ms) | ||
579 | { | ||
580 | m_spareMS += ms; | ||
581 | } | ||
582 | |||
583 | public void addNetMS(int ms) | 606 | public void addNetMS(int ms) |
584 | { | 607 | { |
585 | m_netMS += ms; | 608 | m_netMS += ms; |
@@ -605,6 +628,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
605 | m_otherMS += ms; | 628 | m_otherMS += ms; |
606 | } | 629 | } |
607 | 630 | ||
631 | public void addSleepMS(int ms) | ||
632 | { | ||
633 | m_sleeptimeMS += ms; | ||
634 | } | ||
635 | |||
608 | public void AddPendingDownloads(int count) | 636 | public void AddPendingDownloads(int count) |
609 | { | 637 | { |
610 | m_pendingDownloads += count; | 638 | m_pendingDownloads += count; |
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index c0ca48e..b6e0a97 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs | |||
@@ -131,7 +131,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
131 | 131 | ||
132 | public double this[int x, int y] | 132 | public double this[int x, int y] |
133 | { | 133 | { |
134 | get { return map[x, y]; } | 134 | get |
135 | { | ||
136 | if (x < 0) x = 0; | ||
137 | if (y < 0) y = 0; | ||
138 | if (x >= (int)Constants.RegionSize) x = (int)Constants.RegionSize - 1; | ||
139 | if (y >= (int)Constants.RegionSize) y = (int)Constants.RegionSize - 1; | ||
140 | |||
141 | return map[x, y]; | ||
142 | } | ||
135 | set | 143 | set |
136 | { | 144 | { |
137 | // Will "fix" terrain hole problems. Although not fantastically. | 145 | // Will "fix" terrain hole problems. Although not fantastically. |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index 5b5fb92..95b30d5 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs | |||
@@ -83,8 +83,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
83 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 83 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
84 | 84 | ||
85 | TestScene scene = new SceneHelpers().SetupScene(); | 85 | TestScene scene = new SceneHelpers().SetupScene(); |
86 | SceneHelpers.SetupSceneModules(scene, new PermissionsModule()); | 86 | IConfigSource configSource = new IniConfigSource(); |
87 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, userId).ControllingClient; | 87 | IConfig config = configSource.AddConfig("Startup"); |
88 | config.Set("serverside_object_permissions", true); | ||
89 | SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new DefaultPermissionsModule() }); | ||
90 | IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; | ||
88 | 91 | ||
89 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | 92 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. |
90 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | 93 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; |
@@ -106,9 +109,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
106 | 109 | ||
107 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | 110 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); |
108 | Assert.That(retrievedPart2, Is.Null); | 111 | Assert.That(retrievedPart2, Is.Null); |
109 | |||
110 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(1)); | ||
111 | Assert.That(client.ReceivedKills[0], Is.EqualTo(soLocalId)); | ||
112 | } | 112 | } |
113 | 113 | ||
114 | /// <summary> | 114 | /// <summary> |
@@ -135,7 +135,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
135 | SceneHelpers.SetupSceneModules(sceneB, config, etmB); | 135 | SceneHelpers.SetupSceneModules(sceneB, config, etmB); |
136 | 136 | ||
137 | // We need this for derez | 137 | // We need this for derez |
138 | SceneHelpers.SetupSceneModules(sceneA, new PermissionsModule()); | 138 | //SceneHelpers.SetupSceneModules(sceneA, new PermissionsModule()); |
139 | 139 | ||
140 | UserAccount uaA = UserAccountHelpers.CreateUserWithInventory(sceneA, "Andy", "AAA", 0x1, ""); | 140 | UserAccount uaA = UserAccountHelpers.CreateUserWithInventory(sceneA, "Andy", "AAA", 0x1, ""); |
141 | UserAccount uaB = UserAccountHelpers.CreateUserWithInventory(sceneA, "Brian", "BBB", 0x2, ""); | 141 | UserAccount uaB = UserAccountHelpers.CreateUserWithInventory(sceneA, "Brian", "BBB", 0x2, ""); |
@@ -155,12 +155,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
155 | uint soLocalId = so.LocalId; | 155 | uint soLocalId = so.LocalId; |
156 | 156 | ||
157 | sceneA.DeleteSceneObject(so, false); | 157 | sceneA.DeleteSceneObject(so, false); |
158 | |||
159 | Assert.That(clientA.ReceivedKills.Count, Is.EqualTo(1)); | ||
160 | Assert.That(clientA.ReceivedKills[0], Is.EqualTo(soLocalId)); | ||
161 | |||
162 | Assert.That(childClientsB[0].ReceivedKills.Count, Is.EqualTo(1)); | ||
163 | Assert.That(childClientsB[0].ReceivedKills[0], Is.EqualTo(soLocalId)); | ||
164 | } | 158 | } |
165 | 159 | ||
166 | /// <summary> | 160 | /// <summary> |
@@ -179,7 +173,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
179 | UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); | 173 | UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); |
180 | 174 | ||
181 | TestScene scene = new SceneHelpers().SetupScene(); | 175 | TestScene scene = new SceneHelpers().SetupScene(); |
182 | SceneHelpers.SetupSceneModules(scene, new PermissionsModule()); | 176 | IConfigSource configSource = new IniConfigSource(); |
177 | IConfig config = configSource.AddConfig("Startup"); | ||
178 | config.Set("serverside_object_permissions", true); | ||
179 | SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new DefaultPermissionsModule() }); | ||
183 | IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; | 180 | IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; |
184 | 181 | ||
185 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | 182 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. |
@@ -262,4 +259,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
262 | // Assert.That(retrievedPart, Is.Null); | 259 | // Assert.That(retrievedPart, Is.Null); |
263 | } | 260 | } |
264 | } | 261 | } |
265 | } \ No newline at end of file | 262 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index c264433..1182c96 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs | |||
@@ -62,6 +62,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
62 | Assert.That(g1Post.RootPart.Scale.X, Is.EqualTo(2)); | 62 | Assert.That(g1Post.RootPart.Scale.X, Is.EqualTo(2)); |
63 | Assert.That(g1Post.RootPart.Scale.Y, Is.EqualTo(3)); | 63 | Assert.That(g1Post.RootPart.Scale.Y, Is.EqualTo(3)); |
64 | Assert.That(g1Post.RootPart.Scale.Z, Is.EqualTo(4)); | 64 | Assert.That(g1Post.RootPart.Scale.Z, Is.EqualTo(4)); |
65 | |||
66 | Assert.That(g1Post.RootPart.UndoCount, Is.EqualTo(1)); | ||
65 | } | 67 | } |
66 | 68 | ||
67 | /// <summary> | 69 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs deleted file mode 100644 index 4883ae7..0000000 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs +++ /dev/null | |||
@@ -1,184 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using NUnit.Framework; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Communications; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Tests.Common; | ||
36 | using OpenSim.Tests.Common.Mock; | ||
37 | |||
38 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Tests for undo/redo | ||
42 | /// </summary> | ||
43 | public class SceneObjectUndoRedoTests : OpenSimTestCase | ||
44 | { | ||
45 | [Test] | ||
46 | public void TestUndoRedoResizeSceneObject() | ||
47 | { | ||
48 | TestHelpers.InMethod(); | ||
49 | // TestHelpers.EnableLogging(); | ||
50 | |||
51 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
52 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
53 | |||
54 | Scene scene = new SceneHelpers().SetupScene(); | ||
55 | scene.MaxUndoCount = 20; | ||
56 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
57 | |||
58 | // TODO: It happens to be the case that we are not storing undo states for SOPs which are not yet in a SOG, | ||
59 | // which is the way that AddSceneObject() sets up the object (i.e. it creates the SOP first). However, | ||
60 | // this is somewhat by chance. Really, we shouldn't be storing undo states at all if the object is not | ||
61 | // in a scene. | ||
62 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
63 | |||
64 | g1.GroupResize(firstSize); | ||
65 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
66 | |||
67 | g1.GroupResize(secondSize); | ||
68 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2)); | ||
69 | |||
70 | g1.RootPart.Undo(); | ||
71 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
72 | Assert.That(g1.GroupScale, Is.EqualTo(firstSize)); | ||
73 | |||
74 | g1.RootPart.Redo(); | ||
75 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2)); | ||
76 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
77 | } | ||
78 | |||
79 | [Test] | ||
80 | public void TestUndoLimit() | ||
81 | { | ||
82 | TestHelpers.InMethod(); | ||
83 | |||
84 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
85 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
86 | Vector3 thirdSize = new Vector3(8, 9, 10); | ||
87 | Vector3 fourthSize = new Vector3(11, 12, 13); | ||
88 | |||
89 | Scene scene = new SceneHelpers().SetupScene(); | ||
90 | scene.MaxUndoCount = 2; | ||
91 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
92 | |||
93 | g1.GroupResize(firstSize); | ||
94 | g1.GroupResize(secondSize); | ||
95 | g1.GroupResize(thirdSize); | ||
96 | g1.GroupResize(fourthSize); | ||
97 | |||
98 | g1.RootPart.Undo(); | ||
99 | g1.RootPart.Undo(); | ||
100 | g1.RootPart.Undo(); | ||
101 | |||
102 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
103 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
104 | } | ||
105 | |||
106 | [Test] | ||
107 | public void TestNoUndoOnObjectsNotInScene() | ||
108 | { | ||
109 | TestHelpers.InMethod(); | ||
110 | |||
111 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
112 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
113 | // Vector3 thirdSize = new Vector3(8, 9, 10); | ||
114 | // Vector3 fourthSize = new Vector3(11, 12, 13); | ||
115 | |||
116 | Scene scene = new SceneHelpers().SetupScene(); | ||
117 | scene.MaxUndoCount = 20; | ||
118 | SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); | ||
119 | |||
120 | g1.GroupResize(firstSize); | ||
121 | g1.GroupResize(secondSize); | ||
122 | |||
123 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
124 | |||
125 | g1.RootPart.Undo(); | ||
126 | |||
127 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
128 | } | ||
129 | |||
130 | [Test] | ||
131 | public void TestUndoBeyondAvailable() | ||
132 | { | ||
133 | TestHelpers.InMethod(); | ||
134 | |||
135 | Vector3 newSize = new Vector3(2, 3, 4); | ||
136 | |||
137 | Scene scene = new SceneHelpers().SetupScene(); | ||
138 | scene.MaxUndoCount = 20; | ||
139 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
140 | Vector3 originalSize = g1.GroupScale; | ||
141 | |||
142 | g1.RootPart.Undo(); | ||
143 | |||
144 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
145 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
146 | |||
147 | g1.GroupResize(newSize); | ||
148 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
149 | Assert.That(g1.GroupScale, Is.EqualTo(newSize)); | ||
150 | |||
151 | g1.RootPart.Undo(); | ||
152 | g1.RootPart.Undo(); | ||
153 | |||
154 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
155 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
156 | } | ||
157 | |||
158 | [Test] | ||
159 | public void TestRedoBeyondAvailable() | ||
160 | { | ||
161 | TestHelpers.InMethod(); | ||
162 | |||
163 | Vector3 newSize = new Vector3(2, 3, 4); | ||
164 | |||
165 | Scene scene = new SceneHelpers().SetupScene(); | ||
166 | scene.MaxUndoCount = 20; | ||
167 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
168 | Vector3 originalSize = g1.GroupScale; | ||
169 | |||
170 | g1.RootPart.Redo(); | ||
171 | |||
172 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
173 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
174 | |||
175 | g1.GroupResize(newSize); | ||
176 | g1.RootPart.Undo(); | ||
177 | g1.RootPart.Redo(); | ||
178 | g1.RootPart.Redo(); | ||
179 | |||
180 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
181 | Assert.That(g1.GroupScale, Is.EqualTo(newSize)); | ||
182 | } | ||
183 | } | ||
184 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index 2b79271..e7a1fe0 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs | |||
@@ -44,7 +44,7 @@ using OpenSim.Tests.Common.Mock; | |||
44 | namespace OpenSim.Region.Framework.Scenes.Tests | 44 | namespace OpenSim.Region.Framework.Scenes.Tests |
45 | { | 45 | { |
46 | [TestFixture] | 46 | [TestFixture] |
47 | public class SceneObjectUserGroupTests : OpenSimTestCase | 47 | public class SceneObjectUserGroupTests |
48 | { | 48 | { |
49 | /// <summary> | 49 | /// <summary> |
50 | /// Test share with group object functionality | 50 | /// Test share with group object functionality |
@@ -54,6 +54,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
54 | public void TestShareWithGroup() | 54 | public void TestShareWithGroup() |
55 | { | 55 | { |
56 | TestHelpers.InMethod(); | 56 | TestHelpers.InMethod(); |
57 | // log4net.Config.XmlConfigurator.Configure(); | ||
57 | 58 | ||
58 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 59 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
59 | 60 | ||
@@ -70,7 +71,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
70 | 71 | ||
71 | SceneHelpers.SetupSceneModules( | 72 | SceneHelpers.SetupSceneModules( |
72 | scene, configSource, new object[] | 73 | scene, configSource, new object[] |
73 | { new PermissionsModule(), | 74 | { new DefaultPermissionsModule(), |
74 | new GroupsModule(), | 75 | new GroupsModule(), |
75 | new MockGroupsServicesConnector() }); | 76 | new MockGroupsServicesConnector() }); |
76 | 77 | ||
@@ -81,4 +82,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
81 | groupsModule.CreateGroup(client, "group1", "To boldly go", true, UUID.Zero, 5, true, true, true); | 82 | groupsModule.CreateGroup(client, "group1", "To boldly go", true, UUID.Zero, 5, true, true, true); |
82 | } | 83 | } |
83 | } | 84 | } |
84 | } \ No newline at end of file | 85 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs index 4fdfc74..9fa0a71 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs | |||
@@ -75,14 +75,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
75 | SceneHelpers.SetupSceneModules(scene, capsMod); | 75 | SceneHelpers.SetupSceneModules(scene, capsMod); |
76 | 76 | ||
77 | ScenePresence sp = SceneHelpers.AddChildScenePresence(scene, spUuid); | 77 | ScenePresence sp = SceneHelpers.AddChildScenePresence(scene, spUuid); |
78 | Assert.That(capsMod.GetCapsForUser(spUuid), Is.Not.Null); | 78 | //Assert.That(capsMod.GetCapsForUser(spUuid), Is.Not.Null); |
79 | 79 | ||
80 | // TODO: Need to add tests for other ICapabiltiesModule methods. | 80 | // TODO: Need to add tests for other ICapabiltiesModule methods. |
81 | 81 | ||
82 | // scene.IncomingCloseAgent(sp.UUID, false); | ||
83 | // //Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null); | ||
82 | scene.CloseAgent(sp.UUID, false); | 84 | scene.CloseAgent(sp.UUID, false); |
83 | Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null); | 85 | // Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null); |
84 | 86 | ||
85 | // TODO: Need to add tests for other ICapabiltiesModule methods. | 87 | // TODO: Need to add tests for other ICapabiltiesModule methods. |
86 | } | 88 | } |
87 | } | 89 | } |
88 | } \ No newline at end of file | 90 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs index cf211a1..b806a97 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs | |||
@@ -192,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
192 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny | 192 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny |
193 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default | 193 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default |
194 | // IsAdministrator if no permissions module is present is true. | 194 | // IsAdministrator if no permissions module is present is true. |
195 | SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new PermissionsModule(), etmB); | 195 | // SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new PermissionsModule(), etmB); |
196 | 196 | ||
197 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); | 197 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); |
198 | TestClient tc = new TestClient(acd, sceneA); | 198 | TestClient tc = new TestClient(acd, sceneA); |
@@ -246,4 +246,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
246 | Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True); | 246 | Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | } \ No newline at end of file | 249 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index 8c25dbc..fff542b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |||
@@ -282,7 +282,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
282 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny | 282 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny |
283 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default | 283 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default |
284 | // IsAdministrator if no permissions module is present is true. | 284 | // IsAdministrator if no permissions module is present is true. |
285 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB }); | 285 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new DefaultPermissionsModule(), etmB }); |
286 | 286 | ||
287 | // Shared scene modules | 287 | // Shared scene modules |
288 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); | 288 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); |
@@ -447,7 +447,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
447 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny | 447 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny |
448 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default | 448 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default |
449 | // IsAdministrator if no permissions module is present is true. | 449 | // IsAdministrator if no permissions module is present is true. |
450 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB }); | 450 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new DefaultPermissionsModule(), etmB }); |
451 | 451 | ||
452 | // Shared scene modules | 452 | // Shared scene modules |
453 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); | 453 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); |
@@ -660,4 +660,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
660 | // TestHelpers.DisableLogging(); | 660 | // TestHelpers.DisableLogging(); |
661 | } | 661 | } |
662 | } | 662 | } |
663 | } \ No newline at end of file | 663 | } |
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 860172c..7bbf1bd 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs | |||
@@ -27,202 +27,307 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | ||
30 | using log4net; | 31 | using log4net; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
33 | 35 | ||
34 | namespace OpenSim.Region.Framework.Scenes | 36 | namespace OpenSim.Region.Framework.Scenes |
35 | { | 37 | { |
36 | public class UndoState | 38 | public class UndoState |
37 | { | 39 | { |
38 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | const int UNDOEXPIRESECONDS = 300; // undo expire time (nice to have it came from a ini later) |
39 | |||
40 | public Vector3 Position = Vector3.Zero; | ||
41 | public Vector3 Scale = Vector3.Zero; | ||
42 | public Quaternion Rotation = Quaternion.Identity; | ||
43 | |||
44 | /// <summary> | ||
45 | /// Is this undo state for an entire group? | ||
46 | /// </summary> | ||
47 | public bool ForGroup; | ||
48 | 41 | ||
42 | public ObjectChangeData data; | ||
43 | public DateTime creationtime; | ||
49 | /// <summary> | 44 | /// <summary> |
50 | /// Constructor. | 45 | /// Constructor. |
51 | /// </summary> | 46 | /// </summary> |
52 | /// <param name="part"></param> | 47 | /// <param name="part"></param> |
53 | /// <param name="forGroup">True if the undo is for an entire group</param> | 48 | /// <param name="change">bit field with what is changed</param> |
54 | public UndoState(SceneObjectPart part, bool forGroup) | 49 | /// |
50 | public UndoState(SceneObjectPart part, ObjectChangeType change) | ||
55 | { | 51 | { |
56 | if (part.ParentID == 0) | 52 | data = new ObjectChangeData(); |
57 | { | 53 | data.change = change; |
58 | ForGroup = forGroup; | 54 | creationtime = DateTime.UtcNow; |
59 | |||
60 | // if (ForGroup) | ||
61 | Position = part.ParentGroup.AbsolutePosition; | ||
62 | // else | ||
63 | // Position = part.OffsetPosition; | ||
64 | |||
65 | // m_log.DebugFormat( | ||
66 | // "[UNDO STATE]: Storing undo position {0} for root part", Position); | ||
67 | 55 | ||
68 | Rotation = part.RotationOffset; | 56 | if (part.ParentGroup.RootPart == part) |
69 | 57 | { | |
70 | // m_log.DebugFormat( | 58 | if ((change & ObjectChangeType.Position) != 0) |
71 | // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); | 59 | data.position = part.ParentGroup.AbsolutePosition; |
72 | 60 | if ((change & ObjectChangeType.Rotation) != 0) | |
73 | Scale = part.Shape.Scale; | 61 | data.rotation = part.RotationOffset; |
74 | 62 | if ((change & ObjectChangeType.Scale) != 0) | |
75 | // m_log.DebugFormat( | 63 | data.scale = part.Shape.Scale; |
76 | // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); | ||
77 | } | 64 | } |
78 | else | 65 | else |
79 | { | 66 | { |
80 | Position = part.OffsetPosition; | 67 | if ((change & ObjectChangeType.Position) != 0) |
81 | // m_log.DebugFormat( | 68 | data.position = part.OffsetPosition; |
82 | // "[UNDO STATE]: Storing undo position {0} for child part", Position); | 69 | if ((change & ObjectChangeType.Rotation) != 0) |
70 | data.rotation = part.RotationOffset; | ||
71 | if ((change & ObjectChangeType.Scale) != 0) | ||
72 | data.scale = part.Shape.Scale; | ||
73 | } | ||
74 | } | ||
75 | /// <summary> | ||
76 | /// check if undo or redo is too old | ||
77 | /// </summary> | ||
83 | 78 | ||
84 | Rotation = part.RotationOffset; | 79 | public bool checkExpire() |
85 | // m_log.DebugFormat( | 80 | { |
86 | // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); | 81 | TimeSpan t = DateTime.UtcNow - creationtime; |
82 | if (t.Seconds > UNDOEXPIRESECONDS) | ||
83 | return true; | ||
84 | return false; | ||
85 | } | ||
87 | 86 | ||
88 | Scale = part.Shape.Scale; | 87 | /// <summary> |
89 | // m_log.DebugFormat( | 88 | /// updates undo or redo creation time to now |
90 | // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); | 89 | /// </summary> |
91 | } | 90 | public void updateExpire() |
91 | { | ||
92 | creationtime = DateTime.UtcNow; | ||
92 | } | 93 | } |
93 | 94 | ||
94 | /// <summary> | 95 | /// <summary> |
95 | /// Compare the relevant state in the given part to this state. | 96 | /// Compare the relevant state in the given part to this state. |
96 | /// </summary> | 97 | /// </summary> |
97 | /// <param name="part"></param> | 98 | /// <param name="part"></param> |
98 | /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns> | 99 | /// <returns>true what fiels and related data are equal, False otherwise.</returns> |
99 | public bool Compare(SceneObjectPart part) | 100 | /// |
101 | public bool Compare(SceneObjectPart part, ObjectChangeType change) | ||
100 | { | 102 | { |
103 | if (data.change != change) // if diferent targets, then they are diferent | ||
104 | return false; | ||
105 | |||
101 | if (part != null) | 106 | if (part != null) |
102 | { | 107 | { |
103 | if (part.ParentID == 0) | 108 | if (part.ParentID == 0) |
104 | return | 109 | { |
105 | Position == part.ParentGroup.AbsolutePosition | 110 | if ((change & ObjectChangeType.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition) |
106 | && Rotation == part.RotationOffset | 111 | return false; |
107 | && Scale == part.Shape.Scale; | 112 | } |
108 | else | 113 | else |
109 | return | 114 | { |
110 | Position == part.OffsetPosition | 115 | if ((change & ObjectChangeType.Position) != 0 && data.position != part.OffsetPosition) |
111 | && Rotation == part.RotationOffset | 116 | return false; |
112 | && Scale == part.Shape.Scale; | 117 | } |
113 | } | 118 | |
119 | if ((change & ObjectChangeType.Rotation) != 0 && data.rotation != part.RotationOffset) | ||
120 | return false; | ||
121 | if ((change & ObjectChangeType.Rotation) != 0 && data.scale == part.Shape.Scale) | ||
122 | return false; | ||
123 | return true; | ||
114 | 124 | ||
125 | } | ||
115 | return false; | 126 | return false; |
116 | } | 127 | } |
117 | 128 | ||
118 | public void PlaybackState(SceneObjectPart part) | 129 | /// <summary> |
130 | /// executes the undo or redo to a part or its group | ||
131 | /// </summary> | ||
132 | /// <param name="part"></param> | ||
133 | /// | ||
134 | |||
135 | public void PlayState(SceneObjectPart part) | ||
119 | { | 136 | { |
120 | part.Undoing = true; | 137 | part.Undoing = true; |
121 | 138 | ||
122 | if (part.ParentID == 0) | 139 | SceneObjectGroup grp = part.ParentGroup; |
123 | { | ||
124 | // m_log.DebugFormat( | ||
125 | // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", | ||
126 | // Position, part.Name, part.LocalId); | ||
127 | 140 | ||
128 | if (Position != Vector3.Zero) | 141 | if (grp != null) |
129 | { | 142 | { |
130 | if (ForGroup) | 143 | grp.doChangeObject(part, data); |
131 | part.ParentGroup.AbsolutePosition = Position; | 144 | } |
132 | else | 145 | part.Undoing = false; |
133 | part.ParentGroup.UpdateRootPosition(Position); | 146 | } |
134 | } | 147 | } |
135 | 148 | ||
136 | // m_log.DebugFormat( | 149 | public class UndoRedoState |
137 | // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", | 150 | { |
138 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | 151 | int size; |
152 | public LinkedList<UndoState> m_redo = new LinkedList<UndoState>(); | ||
153 | public LinkedList<UndoState> m_undo = new LinkedList<UndoState>(); | ||
139 | 154 | ||
140 | if (ForGroup) | 155 | /// <summary> |
141 | part.UpdateRotation(Rotation); | 156 | /// creates a new UndoRedoState with default states memory size |
142 | else | 157 | /// </summary> |
143 | part.ParentGroup.UpdateRootRotation(Rotation); | ||
144 | 158 | ||
145 | if (Scale != Vector3.Zero) | 159 | public UndoRedoState() |
146 | { | 160 | { |
147 | // m_log.DebugFormat( | 161 | size = 5; |
148 | // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", | 162 | } |
149 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | ||
150 | 163 | ||
151 | if (ForGroup) | 164 | /// <summary> |
152 | part.ParentGroup.GroupResize(Scale); | 165 | /// creates a new UndoRedoState with states memory having indicated size |
153 | else | 166 | /// </summary> |
154 | part.Resize(Scale); | 167 | /// <param name="size"></param> |
155 | } | ||
156 | 168 | ||
157 | part.ParentGroup.ScheduleGroupForTerseUpdate(); | 169 | public UndoRedoState(int _size) |
158 | } | 170 | { |
171 | if (_size < 3) | ||
172 | size = 3; | ||
159 | else | 173 | else |
160 | { | 174 | size = _size; |
161 | // Note: Updating these properties on sop automatically schedules an update if needed | 175 | } |
162 | if (Position != Vector3.Zero) | ||
163 | { | ||
164 | // m_log.DebugFormat( | ||
165 | // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", | ||
166 | // part.OffsetPosition, Position, part.Name, part.LocalId); | ||
167 | 176 | ||
168 | part.OffsetPosition = Position; | 177 | /// <summary> |
169 | } | 178 | /// returns number of undo entries in memory |
179 | /// </summary> | ||
170 | 180 | ||
171 | // m_log.DebugFormat( | 181 | public int Count |
172 | // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", | 182 | { |
173 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | 183 | get { return m_undo.Count; } |
184 | } | ||
174 | 185 | ||
175 | part.UpdateRotation(Rotation); | 186 | /// <summary> |
187 | /// clears all undo and redo entries | ||
188 | /// </summary> | ||
176 | 189 | ||
177 | if (Scale != Vector3.Zero) | 190 | public void Clear() |
191 | { | ||
192 | m_undo.Clear(); | ||
193 | m_redo.Clear(); | ||
194 | } | ||
195 | |||
196 | /// <summary> | ||
197 | /// adds a new state undo to part or its group, with changes indicated by what bits | ||
198 | /// </summary> | ||
199 | /// <param name="part"></param> | ||
200 | /// <param name="change">bit field with what is changed</param> | ||
201 | |||
202 | public void StoreUndo(SceneObjectPart part, ObjectChangeType change) | ||
203 | { | ||
204 | lock (m_undo) | ||
205 | { | ||
206 | UndoState last; | ||
207 | |||
208 | if (m_redo.Count > 0) // last code seems to clear redo on every new undo | ||
178 | { | 209 | { |
179 | // m_log.DebugFormat( | 210 | m_redo.Clear(); |
180 | // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", | 211 | } |
181 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | ||
182 | 212 | ||
183 | part.Resize(Scale); | 213 | if (m_undo.Count > 0) |
214 | { | ||
215 | // check expired entry | ||
216 | last = m_undo.First.Value; | ||
217 | if (last != null && last.checkExpire()) | ||
218 | m_undo.Clear(); | ||
219 | else | ||
220 | { | ||
221 | // see if we actually have a change | ||
222 | if (last != null) | ||
223 | { | ||
224 | if (last.Compare(part, change)) | ||
225 | return; | ||
226 | } | ||
227 | } | ||
184 | } | 228 | } |
185 | } | ||
186 | 229 | ||
187 | part.Undoing = false; | 230 | // limite size |
231 | while (m_undo.Count >= size) | ||
232 | m_undo.RemoveLast(); | ||
233 | |||
234 | UndoState nUndo = new UndoState(part, change); | ||
235 | m_undo.AddFirst(nUndo); | ||
236 | } | ||
188 | } | 237 | } |
189 | 238 | ||
190 | public void PlayfwdState(SceneObjectPart part) | 239 | /// <summary> |
191 | { | 240 | /// executes last state undo to part or its group |
192 | part.Undoing = true; | 241 | /// current state is pushed into redo |
242 | /// </summary> | ||
243 | /// <param name="part"></param> | ||
193 | 244 | ||
194 | if (part.ParentID == 0) | 245 | public void Undo(SceneObjectPart part) |
246 | { | ||
247 | lock (m_undo) | ||
195 | { | 248 | { |
196 | if (Position != Vector3.Zero) | 249 | UndoState nUndo; |
197 | part.ParentGroup.AbsolutePosition = Position; | ||
198 | |||
199 | if (Rotation != Quaternion.Identity) | ||
200 | part.UpdateRotation(Rotation); | ||
201 | 250 | ||
202 | if (Scale != Vector3.Zero) | 251 | // expire redo |
252 | if (m_redo.Count > 0) | ||
203 | { | 253 | { |
204 | if (ForGroup) | 254 | nUndo = m_redo.First.Value; |
205 | part.ParentGroup.GroupResize(Scale); | 255 | if (nUndo != null && nUndo.checkExpire()) |
206 | else | 256 | m_redo.Clear(); |
207 | part.Resize(Scale); | ||
208 | } | 257 | } |
209 | 258 | ||
210 | part.ParentGroup.ScheduleGroupForTerseUpdate(); | 259 | if (m_undo.Count > 0) |
260 | { | ||
261 | UndoState goback = m_undo.First.Value; | ||
262 | // check expired | ||
263 | if (goback != null && goback.checkExpire()) | ||
264 | { | ||
265 | m_undo.Clear(); | ||
266 | return; | ||
267 | } | ||
268 | |||
269 | if (goback != null) | ||
270 | { | ||
271 | m_undo.RemoveFirst(); | ||
272 | |||
273 | // redo limite size | ||
274 | while (m_redo.Count >= size) | ||
275 | m_redo.RemoveLast(); | ||
276 | |||
277 | nUndo = new UndoState(part, goback.data.change); // new value in part should it be full goback copy? | ||
278 | m_redo.AddFirst(nUndo); | ||
279 | |||
280 | goback.PlayState(part); | ||
281 | } | ||
282 | } | ||
211 | } | 283 | } |
212 | else | 284 | } |
285 | |||
286 | /// <summary> | ||
287 | /// executes last state redo to part or its group | ||
288 | /// current state is pushed into undo | ||
289 | /// </summary> | ||
290 | /// <param name="part"></param> | ||
291 | |||
292 | public void Redo(SceneObjectPart part) | ||
293 | { | ||
294 | lock (m_undo) | ||
213 | { | 295 | { |
214 | // Note: Updating these properties on sop automatically schedules an update if needed | 296 | UndoState nUndo; |
215 | if (Position != Vector3.Zero) | ||
216 | part.OffsetPosition = Position; | ||
217 | 297 | ||
218 | if (Rotation != Quaternion.Identity) | 298 | // expire undo |
219 | part.UpdateRotation(Rotation); | 299 | if (m_undo.Count > 0) |
300 | { | ||
301 | nUndo = m_undo.First.Value; | ||
302 | if (nUndo != null && nUndo.checkExpire()) | ||
303 | m_undo.Clear(); | ||
304 | } | ||
220 | 305 | ||
221 | if (Scale != Vector3.Zero) | 306 | if (m_redo.Count > 0) |
222 | part.Resize(Scale); | 307 | { |
308 | UndoState gofwd = m_redo.First.Value; | ||
309 | // check expired | ||
310 | if (gofwd != null && gofwd.checkExpire()) | ||
311 | { | ||
312 | m_redo.Clear(); | ||
313 | return; | ||
314 | } | ||
315 | |||
316 | if (gofwd != null) | ||
317 | { | ||
318 | m_redo.RemoveFirst(); | ||
319 | |||
320 | // limite undo size | ||
321 | while (m_undo.Count >= size) | ||
322 | m_undo.RemoveLast(); | ||
323 | |||
324 | nUndo = new UndoState(part, gofwd.data.change); // new value in part should it be full gofwd copy? | ||
325 | m_undo.AddFirst(nUndo); | ||
326 | |||
327 | gofwd.PlayState(part); | ||
328 | } | ||
329 | } | ||
223 | } | 330 | } |
224 | |||
225 | part.Undoing = false; | ||
226 | } | 331 | } |
227 | } | 332 | } |
228 | 333 | ||
@@ -247,4 +352,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
247 | m_terrainModule.UndoTerrain(m_terrainChannel); | 352 | m_terrainModule.UndoTerrain(m_terrainChannel); |
248 | } | 353 | } |
249 | } | 354 | } |
250 | } \ No newline at end of file | 355 | } |
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 3e074b9..d8309d8 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -85,10 +85,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
85 | /// <param name="assetUuids">The assets gathered</param> | 85 | /// <param name="assetUuids">The assets gathered</param> |
86 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) | 86 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) |
87 | { | 87 | { |
88 | // avoid infinite loops | ||
89 | if (assetUuids.ContainsKey(assetUuid)) | ||
90 | return; | ||
91 | |||
92 | try | 88 | try |
93 | { | 89 | { |
94 | assetUuids[assetUuid] = assetType; | 90 | assetUuids[assetUuid] = assetType; |