diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
27 files changed, 6299 insertions, 2281 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 3b5a5bd..5529a25 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 39d7512..6e8eb91 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/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 c4b07a5..4337b5a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -102,12 +102,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
102 | engine.StartProcessing(); | 102 | engine.StartProcessing(); |
103 | } | 103 | } |
104 | 104 | ||
105 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) | 105 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item, uint cost) |
106 | { | 106 | { |
107 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); | 107 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); |
108 | if (money != null) | 108 | if (money != null) |
109 | { | 109 | { |
110 | money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload"); | 110 | money.ApplyUploadCharge(agentID, (int)cost, "Asset upload"); |
111 | } | 111 | } |
112 | 112 | ||
113 | AddInventoryItem(item); | 113 | AddInventoryItem(item); |
@@ -170,7 +170,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
170 | return false; | 170 | return false; |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | if (InventoryService.AddItem(item)) | 174 | if (InventoryService.AddItem(item)) |
175 | { | 175 | { |
176 | int userlevel = 0; | 176 | int userlevel = 0; |
@@ -325,8 +325,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
325 | 325 | ||
326 | // Update item with new asset | 326 | // Update item with new asset |
327 | item.AssetID = asset.FullID; | 327 | item.AssetID = asset.FullID; |
328 | if (group.UpdateInventoryItem(item)) | 328 | group.UpdateInventoryItem(item); |
329 | remoteClient.SendAlertMessage("Script saved"); | ||
330 | 329 | ||
331 | part.SendPropertiesToClient(remoteClient); | 330 | part.SendPropertiesToClient(remoteClient); |
332 | 331 | ||
@@ -337,12 +336,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
337 | { | 336 | { |
338 | // Needs to determine which engine was running it and use that | 337 | // Needs to determine which engine was running it and use that |
339 | // | 338 | // |
340 | part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); | 339 | errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 1); |
341 | errors = part.Inventory.GetScriptErrors(item.ItemID); | ||
342 | } | ||
343 | else | ||
344 | { | ||
345 | remoteClient.SendAlertMessage("Script saved"); | ||
346 | } | 340 | } |
347 | 341 | ||
348 | // Tell anyone managing scripts that a script has been reloaded/changed | 342 | // Tell anyone managing scripts that a script has been reloaded/changed |
@@ -408,6 +402,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
408 | if (item.Owner != remoteClient.AgentId) | 402 | if (item.Owner != remoteClient.AgentId) |
409 | return; | 403 | return; |
410 | 404 | ||
405 | item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); | ||
411 | item.Name = itemUpd.Name; | 406 | item.Name = itemUpd.Name; |
412 | item.Description = itemUpd.Description; | 407 | item.Description = itemUpd.Description; |
413 | 408 | ||
@@ -853,6 +848,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
853 | return; | 848 | return; |
854 | } | 849 | } |
855 | 850 | ||
851 | if (newName == null) newName = item.Name; | ||
852 | |||
856 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 853 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
857 | 854 | ||
858 | if (asset != null) | 855 | if (asset != null) |
@@ -913,6 +910,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
913 | } | 910 | } |
914 | 911 | ||
915 | /// <summary> | 912 | /// <summary> |
913 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
914 | /// </summary> | ||
915 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
916 | { | ||
917 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
918 | foreach (InventoryItemBase b in items) | ||
919 | { | ||
920 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
921 | InventoryItemBase n = InventoryService.GetItem(b); | ||
922 | n.Folder = destfolder; | ||
923 | moveitems.Add(n); | ||
924 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
925 | } | ||
926 | |||
927 | MoveInventoryItem(remoteClient, moveitems); | ||
928 | } | ||
929 | |||
930 | /// <summary> | ||
916 | /// Move an item within the agent's inventory. | 931 | /// Move an item within the agent's inventory. |
917 | /// </summary> | 932 | /// </summary> |
918 | /// <param name="remoteClient"></param> | 933 | /// <param name="remoteClient"></param> |
@@ -947,11 +962,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
947 | public void CreateNewInventoryItem( | 962 | public void CreateNewInventoryItem( |
948 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 963 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
949 | string name, string description, uint flags, uint callbackID, | 964 | string name, string description, uint flags, uint callbackID, |
950 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) | 965 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate, UUID transationID) |
951 | { | 966 | { |
952 | CreateNewInventoryItem( | 967 | CreateNewInventoryItem( |
953 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, | 968 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, |
954 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate); | 969 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate, transationID); |
970 | } | ||
971 | |||
972 | |||
973 | private void CreateNewInventoryItem( | ||
974 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | ||
975 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | ||
976 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | ||
977 | { | ||
978 | CreateNewInventoryItem(remoteClient, creatorID, creatorData, folderID, | ||
979 | name, description, flags, callbackID, asset, invType, | ||
980 | baseMask, currentMask, everyoneMask, nextOwnerMask, groupMask, creationDate, UUID.Zero); | ||
955 | } | 981 | } |
956 | 982 | ||
957 | /// <summary> | 983 | /// <summary> |
@@ -976,7 +1002,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
976 | private void CreateNewInventoryItem( | 1002 | private void CreateNewInventoryItem( |
977 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 1003 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
978 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | 1004 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, |
979 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | 1005 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate,UUID transationID) |
980 | { | 1006 | { |
981 | InventoryItemBase item = new InventoryItemBase(); | 1007 | InventoryItemBase item = new InventoryItemBase(); |
982 | item.Owner = remoteClient.AgentId; | 1008 | item.Owner = remoteClient.AgentId; |
@@ -999,7 +1025,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
999 | 1025 | ||
1000 | if (AddInventoryItem(item)) | 1026 | if (AddInventoryItem(item)) |
1001 | { | 1027 | { |
1002 | remoteClient.SendInventoryItemCreateUpdate(item, callbackID); | 1028 | remoteClient.SendInventoryItemCreateUpdate(item, transationID, callbackID); |
1003 | } | 1029 | } |
1004 | else | 1030 | else |
1005 | { | 1031 | { |
@@ -1274,6 +1300,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1274 | { | 1300 | { |
1275 | SceneObjectPart part = GetSceneObjectPart(primLocalId); | 1301 | SceneObjectPart part = GetSceneObjectPart(primLocalId); |
1276 | 1302 | ||
1303 | // Can't move a null item | ||
1304 | if (itemId == UUID.Zero) | ||
1305 | return; | ||
1306 | |||
1277 | if (null == part) | 1307 | if (null == part) |
1278 | { | 1308 | { |
1279 | m_log.WarnFormat( | 1309 | m_log.WarnFormat( |
@@ -1378,21 +1408,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1378 | return; | 1408 | return; |
1379 | } | 1409 | } |
1380 | 1410 | ||
1381 | if (part.OwnerID != destPart.OwnerID) | 1411 | // Can't transfer this |
1412 | // | ||
1413 | if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1414 | return; | ||
1415 | |||
1416 | bool overrideNoMod = false; | ||
1417 | if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) | ||
1418 | overrideNoMod = true; | ||
1419 | |||
1420 | if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1382 | { | 1421 | { |
1383 | // Source must have transfer permissions | 1422 | // object cannot copy items to an object owned by a different owner |
1384 | if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | 1423 | // unless llAllowInventoryDrop has been called |
1385 | return; | ||
1386 | 1424 | ||
1387 | // Object cannot copy items to an object owned by a different owner | 1425 | return; |
1388 | // unless llAllowInventoryDrop has been called on the destination | ||
1389 | if ((destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1390 | return; | ||
1391 | } | 1426 | } |
1392 | 1427 | ||
1393 | // must have both move and modify permission to put an item in an object | 1428 | // must have both move and modify permission to put an item in an object |
1394 | if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) | 1429 | if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) |
1430 | { | ||
1395 | return; | 1431 | return; |
1432 | } | ||
1396 | 1433 | ||
1397 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); | 1434 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); |
1398 | 1435 | ||
@@ -1448,6 +1485,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1448 | 1485 | ||
1449 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1486 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1450 | { | 1487 | { |
1488 | SceneObjectPart destPart = GetSceneObjectPart(destID); | ||
1489 | if (destPart != null) // Move into a prim | ||
1490 | { | ||
1491 | foreach(UUID itemID in items) | ||
1492 | MoveTaskInventoryItem(destID, host, itemID); | ||
1493 | return destID; // Prim folder ID == prim ID | ||
1494 | } | ||
1495 | |||
1451 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1496 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1452 | 1497 | ||
1453 | UUID newFolderID = UUID.Random(); | 1498 | UUID newFolderID = UUID.Random(); |
@@ -1630,12 +1675,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1630 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( | 1675 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( |
1631 | remoteClient, part, transactionID, currentItem); | 1676 | remoteClient, part, transactionID, currentItem); |
1632 | 1677 | ||
1633 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | 1678 | // if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) |
1634 | remoteClient.SendAlertMessage("Notecard saved"); | 1679 | // remoteClient.SendAgentAlertMessage("Notecard saved", false); |
1635 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | 1680 | // else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) |
1636 | remoteClient.SendAlertMessage("Script saved"); | 1681 | // remoteClient.SendAgentAlertMessage("Script saved", false); |
1637 | else | 1682 | // else |
1638 | remoteClient.SendAlertMessage("Item saved"); | 1683 | // remoteClient.SendAgentAlertMessage("Item saved", false); |
1639 | } | 1684 | } |
1640 | 1685 | ||
1641 | // Base ALWAYS has move | 1686 | // Base ALWAYS has move |
@@ -2005,23 +2050,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
2005 | // build a list of eligible objects | 2050 | // build a list of eligible objects |
2006 | List<uint> deleteIDs = new List<uint>(); | 2051 | List<uint> deleteIDs = new List<uint>(); |
2007 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 2052 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
2008 | 2053 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
2009 | // Start with true for both, then remove the flags if objects | ||
2010 | // that we can't derez are part of the selection | ||
2011 | bool permissionToTake = true; | ||
2012 | bool permissionToTakeCopy = true; | ||
2013 | bool permissionToDelete = true; | ||
2014 | 2054 | ||
2015 | foreach (uint localID in localIDs) | 2055 | foreach (uint localID in localIDs) |
2016 | { | 2056 | { |
2057 | // Start with true for both, then remove the flags if objects | ||
2058 | // that we can't derez are part of the selection | ||
2059 | bool permissionToTake = true; | ||
2060 | bool permissionToTakeCopy = true; | ||
2061 | bool permissionToDelete = true; | ||
2062 | |||
2017 | // Invalid id | 2063 | // Invalid id |
2018 | SceneObjectPart part = GetSceneObjectPart(localID); | 2064 | SceneObjectPart part = GetSceneObjectPart(localID); |
2019 | if (part == null) | 2065 | if (part == null) |
2066 | { | ||
2067 | //Client still thinks the object exists, kill it | ||
2068 | deleteIDs.Add(localID); | ||
2020 | continue; | 2069 | continue; |
2070 | } | ||
2021 | 2071 | ||
2022 | // Already deleted by someone else | 2072 | // Already deleted by someone else |
2023 | if (part.ParentGroup.IsDeleted) | 2073 | if (part.ParentGroup.IsDeleted) |
2074 | { | ||
2075 | //Client still thinks the object exists, kill it | ||
2076 | deleteIDs.Add(localID); | ||
2024 | continue; | 2077 | continue; |
2078 | } | ||
2025 | 2079 | ||
2026 | // Can't delete child prims | 2080 | // Can't delete child prims |
2027 | if (part != part.ParentGroup.RootPart) | 2081 | if (part != part.ParentGroup.RootPart) |
@@ -2029,8 +2083,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2029 | 2083 | ||
2030 | SceneObjectGroup grp = part.ParentGroup; | 2084 | SceneObjectGroup grp = part.ParentGroup; |
2031 | 2085 | ||
2032 | deleteIDs.Add(localID); | 2086 | // If child prims have invalid perms, fix them |
2033 | deleteGroups.Add(grp); | 2087 | grp.AdjustChildPrimPermissions(); |
2034 | 2088 | ||
2035 | // If child prims have invalid perms, fix them | 2089 | // If child prims have invalid perms, fix them |
2036 | grp.AdjustChildPrimPermissions(); | 2090 | grp.AdjustChildPrimPermissions(); |
@@ -2051,86 +2105,198 @@ namespace OpenSim.Region.Framework.Scenes | |||
2051 | } | 2105 | } |
2052 | else | 2106 | else |
2053 | { | 2107 | { |
2054 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 2108 | if (action == DeRezAction.TakeCopy) |
2109 | { | ||
2110 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
2111 | permissionToTakeCopy = false; | ||
2112 | } | ||
2113 | else | ||
2114 | { | ||
2055 | permissionToTakeCopy = false; | 2115 | permissionToTakeCopy = false; |
2056 | 2116 | } | |
2057 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 2117 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
2058 | permissionToTake = false; | 2118 | permissionToTake = false; |
2059 | 2119 | ||
2060 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 2120 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
2061 | permissionToDelete = false; | 2121 | permissionToDelete = false; |
2062 | } | 2122 | } |
2063 | } | ||
2064 | 2123 | ||
2065 | // Handle god perms | 2124 | // Handle god perms |
2066 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 2125 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
2067 | { | ||
2068 | permissionToTake = true; | ||
2069 | permissionToTakeCopy = true; | ||
2070 | permissionToDelete = true; | ||
2071 | } | ||
2072 | |||
2073 | // If we're re-saving, we don't even want to delete | ||
2074 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | ||
2075 | permissionToDelete = false; | ||
2076 | |||
2077 | // if we want to take a copy, we also don't want to delete | ||
2078 | // Note: after this point, the permissionToTakeCopy flag | ||
2079 | // becomes irrelevant. It already includes the permissionToTake | ||
2080 | // permission and after excluding no copy items here, we can | ||
2081 | // just use that. | ||
2082 | if (action == DeRezAction.TakeCopy) | ||
2083 | { | ||
2084 | // If we don't have permission, stop right here | ||
2085 | if (!permissionToTakeCopy) | ||
2086 | { | 2126 | { |
2087 | remoteClient.SendAlertMessage("You don't have permission to take the object"); | 2127 | permissionToTake = true; |
2088 | return; | 2128 | permissionToTakeCopy = true; |
2129 | permissionToDelete = true; | ||
2089 | } | 2130 | } |
2090 | 2131 | ||
2091 | permissionToTake = true; | 2132 | // If we're re-saving, we don't even want to delete |
2092 | // Don't delete | 2133 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
2093 | permissionToDelete = false; | 2134 | permissionToDelete = false; |
2094 | } | ||
2095 | 2135 | ||
2096 | if (action == DeRezAction.Return) | 2136 | // if we want to take a copy, we also don't want to delete |
2097 | { | 2137 | // Note: after this point, the permissionToTakeCopy flag |
2098 | if (remoteClient != null) | 2138 | // becomes irrelevant. It already includes the permissionToTake |
2139 | // permission and after excluding no copy items here, we can | ||
2140 | // just use that. | ||
2141 | if (action == DeRezAction.TakeCopy) | ||
2099 | { | 2142 | { |
2100 | if (Permissions.CanReturnObjects( | 2143 | // If we don't have permission, stop right here |
2101 | null, | 2144 | if (!permissionToTakeCopy) |
2102 | remoteClient.AgentId, | ||
2103 | deleteGroups)) | ||
2104 | { | 2145 | { |
2105 | permissionToTake = true; | 2146 | remoteClient.SendAlertMessage("You don't have permission to take the object"); |
2106 | permissionToDelete = true; | 2147 | return; |
2148 | } | ||
2107 | 2149 | ||
2108 | foreach (SceneObjectGroup g in deleteGroups) | 2150 | permissionToTake = true; |
2151 | // Don't delete | ||
2152 | permissionToDelete = false; | ||
2153 | } | ||
2154 | |||
2155 | if (action == DeRezAction.Return) | ||
2156 | { | ||
2157 | if (remoteClient != null) | ||
2158 | { | ||
2159 | if (Permissions.CanReturnObjects( | ||
2160 | null, | ||
2161 | remoteClient.AgentId, | ||
2162 | new List<SceneObjectGroup>() {grp})) | ||
2109 | { | 2163 | { |
2110 | AddReturn(g.OwnerID == g.GroupID ? g.LastOwnerID : g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 2164 | permissionToTake = true; |
2165 | permissionToDelete = true; | ||
2166 | |||
2167 | AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
2111 | } | 2168 | } |
2112 | } | 2169 | } |
2170 | else // Auto return passes through here with null agent | ||
2171 | { | ||
2172 | permissionToTake = true; | ||
2173 | permissionToDelete = true; | ||
2174 | } | ||
2113 | } | 2175 | } |
2114 | else // Auto return passes through here with null agent | 2176 | |
2177 | if (permissionToTake && (!permissionToDelete)) | ||
2178 | takeGroups.Add(grp); | ||
2179 | |||
2180 | if (permissionToDelete) | ||
2115 | { | 2181 | { |
2116 | permissionToTake = true; | 2182 | if (permissionToTake) |
2117 | permissionToDelete = true; | 2183 | deleteGroups.Add(grp); |
2184 | deleteIDs.Add(grp.LocalId); | ||
2118 | } | 2185 | } |
2119 | } | 2186 | } |
2120 | 2187 | ||
2121 | if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) | 2188 | SendKillObject(deleteIDs); |
2189 | |||
2190 | if (deleteGroups.Count > 0) | ||
2122 | { | 2191 | { |
2192 | foreach (SceneObjectGroup g in deleteGroups) | ||
2193 | deleteIDs.Remove(g.LocalId); | ||
2194 | |||
2123 | m_asyncSceneObjectDeleter.DeleteToInventory( | 2195 | m_asyncSceneObjectDeleter.DeleteToInventory( |
2124 | action, destinationID, deleteGroups, remoteClient, | 2196 | action, destinationID, deleteGroups, remoteClient, |
2125 | permissionToDelete); | 2197 | true); |
2198 | } | ||
2199 | if (takeGroups.Count > 0) | ||
2200 | { | ||
2201 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
2202 | action, destinationID, takeGroups, remoteClient, | ||
2203 | false); | ||
2126 | } | 2204 | } |
2127 | else if (permissionToDelete) | 2205 | if (deleteIDs.Count > 0) |
2128 | { | 2206 | { |
2129 | foreach (SceneObjectGroup g in deleteGroups) | 2207 | foreach (SceneObjectGroup g in deleteGroups) |
2130 | DeleteSceneObject(g, false); | 2208 | DeleteSceneObject(g, true); |
2131 | } | 2209 | } |
2132 | } | 2210 | } |
2133 | 2211 | ||
2212 | public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) | ||
2213 | { | ||
2214 | itemID = UUID.Zero; | ||
2215 | if (grp != null) | ||
2216 | { | ||
2217 | Vector3 inventoryStoredPosition = new Vector3 | ||
2218 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
2219 | ? 250 | ||
2220 | : grp.AbsolutePosition.X) | ||
2221 | , | ||
2222 | (grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
2223 | ? 250 | ||
2224 | : grp.AbsolutePosition.X, | ||
2225 | grp.AbsolutePosition.Z); | ||
2226 | |||
2227 | Vector3 originalPosition = grp.AbsolutePosition; | ||
2228 | |||
2229 | grp.AbsolutePosition = inventoryStoredPosition; | ||
2230 | |||
2231 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
2232 | |||
2233 | grp.AbsolutePosition = originalPosition; | ||
2234 | |||
2235 | AssetBase asset = CreateAsset( | ||
2236 | grp.GetPartName(grp.LocalId), | ||
2237 | grp.GetPartDescription(grp.LocalId), | ||
2238 | (sbyte)AssetType.Object, | ||
2239 | Utils.StringToBytes(sceneObjectXml), | ||
2240 | remoteClient.AgentId); | ||
2241 | AssetService.Store(asset); | ||
2242 | |||
2243 | InventoryItemBase item = new InventoryItemBase(); | ||
2244 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
2245 | item.CreatorData = grp.RootPart.CreatorData; | ||
2246 | item.Owner = remoteClient.AgentId; | ||
2247 | item.ID = UUID.Random(); | ||
2248 | item.AssetID = asset.FullID; | ||
2249 | item.Description = asset.Description; | ||
2250 | item.Name = asset.Name; | ||
2251 | item.AssetType = asset.Type; | ||
2252 | item.InvType = (int)InventoryType.Object; | ||
2253 | |||
2254 | InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
2255 | if (folder != null) | ||
2256 | item.Folder = folder.ID; | ||
2257 | else // oopsies | ||
2258 | item.Folder = UUID.Zero; | ||
2259 | |||
2260 | // Set up base perms properly | ||
2261 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
2262 | permsBase &= grp.RootPart.BaseMask; | ||
2263 | permsBase |= (uint)PermissionMask.Move; | ||
2264 | |||
2265 | // Make sure we don't lock it | ||
2266 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
2267 | |||
2268 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
2269 | { | ||
2270 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2271 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2272 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2273 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
2274 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
2275 | } | ||
2276 | else | ||
2277 | { | ||
2278 | item.BasePermissions = permsBase; | ||
2279 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; | ||
2280 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2281 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; | ||
2282 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; | ||
2283 | } | ||
2284 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
2285 | |||
2286 | // sets itemID so client can show item as 'attached' in inventory | ||
2287 | grp.FromItemID = item.ID; | ||
2288 | |||
2289 | if (AddInventoryItem(item)) | ||
2290 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
2291 | else | ||
2292 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
2293 | |||
2294 | itemID = item.ID; | ||
2295 | return item.AssetID; | ||
2296 | } | ||
2297 | return UUID.Zero; | ||
2298 | } | ||
2299 | |||
2134 | /// <summary> | 2300 | /// <summary> |
2135 | /// Event Handler Rez an object into a scene | 2301 | /// Event Handler Rez an object into a scene |
2136 | /// Calls the non-void event handler | 2302 | /// Calls the non-void event handler |
@@ -2258,6 +2424,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2258 | 2424 | ||
2259 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2425 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2260 | { | 2426 | { |
2427 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2428 | return; | ||
2429 | |||
2261 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2430 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2262 | if (part == null) | 2431 | if (part == null) |
2263 | return; | 2432 | return; |
@@ -2314,7 +2483,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2314 | } | 2483 | } |
2315 | else | 2484 | else |
2316 | { | 2485 | { |
2317 | if (!Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) | 2486 | if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId) |
2487 | continue; | ||
2488 | |||
2489 | if (!Permissions.CanTransferObject(sog.UUID, groupID)) | ||
2318 | continue; | 2490 | continue; |
2319 | 2491 | ||
2320 | if (sog.GroupID != groupID) | 2492 | if (sog.GroupID != groupID) |
@@ -2426,6 +2598,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2426 | } | 2598 | } |
2427 | 2599 | ||
2428 | m_sceneGraph.LinkObjects(root, children); | 2600 | m_sceneGraph.LinkObjects(root, children); |
2601 | |||
2602 | ScenePresence sp; | ||
2603 | if (TryGetScenePresence(agentId, out sp)) | ||
2604 | { | ||
2605 | root.SendPropertiesToClient(sp.ControllingClient); | ||
2606 | } | ||
2429 | } | 2607 | } |
2430 | 2608 | ||
2431 | private string PermissionString(uint permissions) | 2609 | private string PermissionString(uint permissions) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 998c19e..421cb08 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 |
@@ -250,7 +258,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
250 | // handled by group, but by prim. Legacy cruft. | 258 | // handled by group, but by prim. Legacy cruft. |
251 | // TODO: Make selection flagging per prim! | 259 | // TODO: Make selection flagging per prim! |
252 | // | 260 | // |
253 | part.ParentGroup.IsSelected = false; | 261 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) |
262 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
263 | part.ParentGroup.IsSelected = false; | ||
254 | 264 | ||
255 | if (part.ParentGroup.IsAttachment) | 265 | if (part.ParentGroup.IsAttachment) |
256 | isAttachment = true; | 266 | isAttachment = true; |
@@ -270,6 +280,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
270 | part.UUID, remoteClient.AgentId)) | 280 | part.UUID, remoteClient.AgentId)) |
271 | EventManager.TriggerParcelPrimCountTainted(); | 281 | EventManager.TriggerParcelPrimCountTainted(); |
272 | } | 282 | } |
283 | */ | ||
284 | |||
285 | bool oldgprSelect = part.ParentGroup.IsSelected; | ||
286 | |||
287 | // This is wrong, wrong, wrong. Selection should not be | ||
288 | // handled by group, but by prim. Legacy cruft. | ||
289 | // TODO: Make selection flagging per prim! | ||
290 | // | ||
291 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) | ||
292 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
293 | { | ||
294 | part.IsSelected = false; | ||
295 | if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) | ||
296 | EventManager.TriggerParcelPrimCountTainted(); | ||
297 | } | ||
298 | |||
273 | } | 299 | } |
274 | 300 | ||
275 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, | 301 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, |
@@ -424,12 +450,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
424 | } | 450 | } |
425 | }); | 451 | }); |
426 | } | 452 | } |
427 | 453 | ||
428 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) | 454 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) |
429 | { | 455 | { |
430 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; | 456 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; |
431 | } | 457 | } |
432 | 458 | ||
459 | private class DescendentsRequestData | ||
460 | { | ||
461 | public IClientAPI RemoteClient; | ||
462 | public UUID FolderID; | ||
463 | public UUID OwnerID; | ||
464 | public bool FetchFolders; | ||
465 | public bool FetchItems; | ||
466 | public int SortOrder; | ||
467 | } | ||
468 | |||
469 | private Queue<DescendentsRequestData> m_descendentsRequestQueue = new Queue<DescendentsRequestData>(); | ||
470 | private Object m_descendentsRequestLock = new Object(); | ||
471 | private bool m_descendentsRequestProcessing = false; | ||
472 | |||
433 | /// <summary> | 473 | /// <summary> |
434 | /// Tell the client about the various child items and folders contained in the requested folder. | 474 | /// Tell the client about the various child items and folders contained in the requested folder. |
435 | /// </summary> | 475 | /// </summary> |
@@ -466,17 +506,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
466 | } | 506 | } |
467 | } | 507 | } |
468 | 508 | ||
469 | // We're going to send the reply async, because there may be | 509 | lock (m_descendentsRequestLock) |
470 | // an enormous quantity of packets -- basically the entire inventory! | 510 | { |
471 | // We don't want to block the client thread while all that is happening. | 511 | if (!m_descendentsRequestProcessing) |
472 | SendInventoryDelegate d = SendInventoryAsync; | 512 | { |
473 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | 513 | m_descendentsRequestProcessing = true; |
514 | |||
515 | // We're going to send the reply async, because there may be | ||
516 | // an enormous quantity of packets -- basically the entire inventory! | ||
517 | // We don't want to block the client thread while all that is happening. | ||
518 | SendInventoryDelegate d = SendInventoryAsync; | ||
519 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | ||
520 | |||
521 | return; | ||
522 | } | ||
523 | |||
524 | DescendentsRequestData req = new DescendentsRequestData(); | ||
525 | req.RemoteClient = remoteClient; | ||
526 | req.FolderID = folderID; | ||
527 | req.OwnerID = ownerID; | ||
528 | req.FetchFolders = fetchFolders; | ||
529 | req.FetchItems = fetchItems; | ||
530 | req.SortOrder = sortOrder; | ||
531 | |||
532 | m_descendentsRequestQueue.Enqueue(req); | ||
533 | } | ||
474 | } | 534 | } |
475 | 535 | ||
476 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); | 536 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); |
477 | 537 | ||
478 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) | 538 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) |
479 | { | 539 | { |
540 | Thread.Sleep(20); | ||
480 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); | 541 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); |
481 | } | 542 | } |
482 | 543 | ||
@@ -484,6 +545,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
484 | { | 545 | { |
485 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; | 546 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; |
486 | d.EndInvoke(iar); | 547 | d.EndInvoke(iar); |
548 | |||
549 | lock (m_descendentsRequestLock) | ||
550 | { | ||
551 | if (m_descendentsRequestQueue.Count > 0) | ||
552 | { | ||
553 | DescendentsRequestData req = m_descendentsRequestQueue.Dequeue(); | ||
554 | |||
555 | d = SendInventoryAsync; | ||
556 | d.BeginInvoke(req.RemoteClient, req.FolderID, req.OwnerID, req.FetchFolders, req.FetchItems, req.SortOrder, SendInventoryComplete, d); | ||
557 | |||
558 | return; | ||
559 | } | ||
560 | |||
561 | m_descendentsRequestProcessing = false; | ||
562 | } | ||
487 | } | 563 | } |
488 | 564 | ||
489 | /// <summary> | 565 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e00206f..18e7eb8 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 |
@@ -740,6 +760,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
740 | m_SimulationDataService = simDataService; | 760 | m_SimulationDataService = simDataService; |
741 | m_EstateDataService = estateDataService; | 761 | m_EstateDataService = estateDataService; |
742 | m_regionHandle = RegionInfo.RegionHandle; | 762 | m_regionHandle = RegionInfo.RegionHandle; |
763 | m_lastIncoming = 0; | ||
764 | m_lastOutgoing = 0; | ||
743 | 765 | ||
744 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 766 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
745 | m_asyncSceneObjectDeleter.Enabled = true; | 767 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -833,7 +855,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
833 | 855 | ||
834 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | 856 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); |
835 | 857 | ||
836 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | 858 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
837 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); | 859 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); |
838 | if (!UseBackup) | 860 | if (!UseBackup) |
839 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 861 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
@@ -841,13 +863,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
841 | //Animation states | 863 | //Animation states |
842 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 864 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
843 | 865 | ||
844 | SeeIntoRegion = startupConfig.GetBoolean("see_into_region", true); | ||
845 | 866 | ||
846 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); | 867 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); |
847 | 868 | ||
848 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | 869 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
849 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | 870 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
850 | |||
851 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); | 871 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); |
852 | if (RegionInfo.NonphysPrimMin > 0) | 872 | if (RegionInfo.NonphysPrimMin > 0) |
853 | { | 873 | { |
@@ -867,11 +887,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
867 | } | 887 | } |
868 | 888 | ||
869 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 889 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
890 | |||
870 | if (RegionInfo.PhysPrimMax > 0) | 891 | if (RegionInfo.PhysPrimMax > 0) |
871 | { | 892 | { |
872 | m_maxPhys = RegionInfo.PhysPrimMax; | 893 | m_maxPhys = RegionInfo.PhysPrimMax; |
873 | } | 894 | } |
874 | 895 | ||
896 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | ||
897 | if (RegionInfo.LinksetCapacity > 0) | ||
898 | { | ||
899 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
900 | } | ||
901 | |||
902 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
903 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
904 | |||
875 | // Here, if clamping is requested in either global or | 905 | // Here, if clamping is requested in either global or |
876 | // local config, it will be used | 906 | // local config, it will be used |
877 | // | 907 | // |
@@ -881,13 +911,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
881 | m_clampPrimSize = true; | 911 | m_clampPrimSize = true; |
882 | } | 912 | } |
883 | 913 | ||
884 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | 914 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
885 | if (RegionInfo.LinksetCapacity > 0) | ||
886 | { | ||
887 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
888 | } | ||
889 | |||
890 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | ||
891 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 915 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
892 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 916 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
893 | m_dontPersistBefore = | 917 | m_dontPersistBefore = |
@@ -898,11 +922,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
898 | m_persistAfter *= 10000000; | 922 | m_persistAfter *= 10000000; |
899 | 923 | ||
900 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 924 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
901 | 925 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | |
902 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
903 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
904 | 926 | ||
905 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 927 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
928 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
929 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
906 | 930 | ||
907 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; | 931 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; |
908 | 932 | ||
@@ -947,7 +971,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
947 | 971 | ||
948 | if (grant.Length > 0) | 972 | if (grant.Length > 0) |
949 | { | 973 | { |
950 | foreach (string viewer in grant.Split('|')) | 974 | foreach (string viewer in grant.Split(',')) |
951 | { | 975 | { |
952 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 976 | m_AllowedViewers.Add(viewer.Trim().ToLower()); |
953 | } | 977 | } |
@@ -959,7 +983,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
959 | 983 | ||
960 | if (grant.Length > 0) | 984 | if (grant.Length > 0) |
961 | { | 985 | { |
962 | foreach (string viewer in grant.Split('|')) | 986 | foreach (string viewer in grant.Split(',')) |
963 | { | 987 | { |
964 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 988 | m_BannedViewers.Add(viewer.Trim().ToLower()); |
965 | } | 989 | } |
@@ -1019,6 +1043,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1019 | StatsReporter = new SimStatsReporter(this); | 1043 | StatsReporter = new SimStatsReporter(this); |
1020 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1044 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
1021 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1045 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1046 | |||
1047 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | ||
1022 | } | 1048 | } |
1023 | 1049 | ||
1024 | public Scene(RegionInfo regInfo) : base(regInfo) | 1050 | public Scene(RegionInfo regInfo) : base(regInfo) |
@@ -1314,8 +1340,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1314 | // Stop all client threads. | 1340 | // Stop all client threads. |
1315 | ForEachScenePresence(delegate(ScenePresence avatar) { IncomingCloseAgent(avatar.UUID, false); }); | 1341 | ForEachScenePresence(delegate(ScenePresence avatar) { IncomingCloseAgent(avatar.UUID, false); }); |
1316 | 1342 | ||
1317 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1343 | m_log.Debug("[SCENE]: TriggerSceneShuttingDown"); |
1318 | EventManager.TriggerSceneShuttingDown(this); | 1344 | EventManager.TriggerSceneShuttingDown(this); |
1345 | |||
1346 | m_log.Debug("[SCENE]: Persisting changed objects"); | ||
1347 | |||
1319 | Backup(false); | 1348 | Backup(false); |
1320 | m_sceneGraph.Close(); | 1349 | m_sceneGraph.Close(); |
1321 | 1350 | ||
@@ -1329,6 +1358,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1329 | // attempt to reference a null or disposed physics scene. | 1358 | // attempt to reference a null or disposed physics scene. |
1330 | if (PhysicsScene != null) | 1359 | if (PhysicsScene != null) |
1331 | { | 1360 | { |
1361 | m_log.Debug("[SCENE]: Dispose Physics"); | ||
1332 | PhysicsScene phys = PhysicsScene; | 1362 | PhysicsScene phys = PhysicsScene; |
1333 | // remove the physics engine from both Scene and SceneGraph | 1363 | // remove the physics engine from both Scene and SceneGraph |
1334 | PhysicsScene = null; | 1364 | PhysicsScene = null; |
@@ -1359,11 +1389,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1359 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1389 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1360 | if (m_heartbeatThread != null) | 1390 | if (m_heartbeatThread != null) |
1361 | { | 1391 | { |
1392 | m_hbRestarts++; | ||
1393 | if(m_hbRestarts > 10) | ||
1394 | Environment.Exit(1); | ||
1395 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1396 | |||
1397 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1398 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1399 | //proc.EnableRaisingEvents=false; | ||
1400 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1401 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1402 | //proc.Start(); | ||
1403 | //proc.WaitForExit(); | ||
1404 | //Thread.Sleep(1000); | ||
1405 | //Environment.Exit(1); | ||
1362 | m_heartbeatThread.Abort(); | 1406 | m_heartbeatThread.Abort(); |
1407 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1363 | m_heartbeatThread = null; | 1408 | m_heartbeatThread = null; |
1364 | } | 1409 | } |
1365 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1410 | // m_lastUpdate = Util.EnvironmentTickCount(); |
1366 | 1411 | ||
1412 | // m_sceneGraph.PreparePhysicsSimulation(); | ||
1413 | |||
1414 | |||
1367 | m_heartbeatThread | 1415 | m_heartbeatThread |
1368 | = Watchdog.StartThread( | 1416 | = Watchdog.StartThread( |
1369 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); | 1417 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); |
@@ -1508,16 +1556,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1508 | endFrame = Frame + frames; | 1556 | endFrame = Frame + frames; |
1509 | 1557 | ||
1510 | float physicsFPS = 0f; | 1558 | float physicsFPS = 0f; |
1511 | int previousFrameTick, tmpMS; | 1559 | int tmpMS; |
1512 | int maintc = Util.EnvironmentTickCount(); | 1560 | int previousFrameTick; |
1561 | int maintc; | ||
1562 | int sleepMS; | ||
1563 | int framestart; | ||
1513 | 1564 | ||
1514 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) | 1565 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) |
1515 | { | 1566 | { |
1567 | framestart = Util.EnvironmentTickCount(); | ||
1516 | ++Frame; | 1568 | ++Frame; |
1517 | 1569 | ||
1518 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1570 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1519 | 1571 | ||
1520 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; | 1572 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
1521 | 1573 | ||
1522 | try | 1574 | try |
1523 | { | 1575 | { |
@@ -1571,6 +1623,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1571 | m_sceneGraph.UpdatePresences(); | 1623 | m_sceneGraph.UpdatePresences(); |
1572 | 1624 | ||
1573 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); | 1625 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1626 | |||
1574 | 1627 | ||
1575 | // Delete temp-on-rez stuff | 1628 | // Delete temp-on-rez stuff |
1576 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | 1629 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) |
@@ -1652,34 +1705,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1652 | 1705 | ||
1653 | Watchdog.UpdateThread(); | 1706 | Watchdog.UpdateThread(); |
1654 | 1707 | ||
1708 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1709 | |||
1710 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1711 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1712 | StatsReporter.AddFPS(1); | ||
1713 | |||
1714 | StatsReporter.addAgentMS(agentMS); | ||
1715 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1716 | StatsReporter.addOtherMS(otherMS); | ||
1717 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1718 | |||
1655 | previousFrameTick = m_lastFrameTick; | 1719 | previousFrameTick = m_lastFrameTick; |
1656 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1720 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1657 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1721 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1658 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1722 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1659 | 1723 | ||
1724 | m_firstHeartbeat = false; | ||
1725 | |||
1726 | sleepMS = Util.EnvironmentTickCount(); | ||
1727 | |||
1660 | if (tmpMS > 0) | 1728 | if (tmpMS > 0) |
1661 | { | ||
1662 | Thread.Sleep(tmpMS); | 1729 | Thread.Sleep(tmpMS); |
1663 | spareMS += tmpMS; | ||
1664 | } | ||
1665 | 1730 | ||
1666 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | 1731 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); |
1667 | maintc = Util.EnvironmentTickCount(); | 1732 | frameMS = Util.EnvironmentTickCountSubtract(framestart); |
1668 | 1733 | StatsReporter.addSleepMS(sleepMS); | |
1669 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1734 | StatsReporter.addFrameMS(frameMS); |
1670 | 1735 | ||
1671 | // if (Frame%m_update_avatars == 0) | 1736 | // if (Frame%m_update_avatars == 0) |
1672 | // UpdateInWorldTime(); | 1737 | // UpdateInWorldTime(); |
1673 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1674 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1675 | StatsReporter.AddFPS(1); | ||
1676 | 1738 | ||
1677 | StatsReporter.addFrameMS(frameMS); | ||
1678 | StatsReporter.addAgentMS(agentMS); | ||
1679 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1680 | StatsReporter.addOtherMS(otherMS); | ||
1681 | StatsReporter.AddSpareMS(spareMS); | ||
1682 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1683 | 1739 | ||
1684 | // Optionally warn if a frame takes double the amount of time that it should. | 1740 | // Optionally warn if a frame takes double the amount of time that it should. |
1685 | if (DebugUpdates | 1741 | if (DebugUpdates |
@@ -1696,7 +1752,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1696 | public void AddGroupTarget(SceneObjectGroup grp) | 1752 | public void AddGroupTarget(SceneObjectGroup grp) |
1697 | { | 1753 | { |
1698 | lock (m_groupsWithTargets) | 1754 | lock (m_groupsWithTargets) |
1699 | m_groupsWithTargets[grp.UUID] = grp; | 1755 | m_groupsWithTargets[grp.UUID] = 0; |
1700 | } | 1756 | } |
1701 | 1757 | ||
1702 | public void RemoveGroupTarget(SceneObjectGroup grp) | 1758 | public void RemoveGroupTarget(SceneObjectGroup grp) |
@@ -1707,18 +1763,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1707 | 1763 | ||
1708 | private void CheckAtTargets() | 1764 | private void CheckAtTargets() |
1709 | { | 1765 | { |
1710 | List<SceneObjectGroup> objs = null; | 1766 | List<UUID> objs = null; |
1711 | 1767 | ||
1712 | lock (m_groupsWithTargets) | 1768 | lock (m_groupsWithTargets) |
1713 | { | 1769 | { |
1714 | if (m_groupsWithTargets.Count != 0) | 1770 | if (m_groupsWithTargets.Count != 0) |
1715 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); | 1771 | objs = new List<UUID>(m_groupsWithTargets.Keys); |
1716 | } | 1772 | } |
1717 | 1773 | ||
1718 | if (objs != null) | 1774 | if (objs != null) |
1719 | { | 1775 | { |
1720 | foreach (SceneObjectGroup entry in objs) | 1776 | foreach (UUID entry in objs) |
1721 | entry.checkAtTargets(); | 1777 | { |
1778 | SceneObjectGroup grp = GetSceneObjectGroup(entry); | ||
1779 | if (grp == null) | ||
1780 | m_groupsWithTargets.Remove(entry); | ||
1781 | else | ||
1782 | grp.checkAtTargets(); | ||
1783 | } | ||
1722 | } | 1784 | } |
1723 | } | 1785 | } |
1724 | 1786 | ||
@@ -1797,7 +1859,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1797 | msg.fromAgentName = "Server"; | 1859 | msg.fromAgentName = "Server"; |
1798 | msg.dialog = (byte)19; // Object msg | 1860 | msg.dialog = (byte)19; // Object msg |
1799 | msg.fromGroup = false; | 1861 | msg.fromGroup = false; |
1800 | msg.offline = (byte)0; | 1862 | msg.offline = (byte)1; |
1801 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1863 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1802 | msg.Position = Vector3.Zero; | 1864 | msg.Position = Vector3.Zero; |
1803 | msg.RegionID = RegionInfo.RegionID.Guid; | 1865 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -2026,7 +2088,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2026 | return PhysicsScene.SupportsRaycastWorldFiltered(); | 2088 | return PhysicsScene.SupportsRaycastWorldFiltered(); |
2027 | } | 2089 | } |
2028 | 2090 | ||
2029 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | 2091 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) |
2030 | { | 2092 | { |
2031 | if (PhysicsScene == null) | 2093 | if (PhysicsScene == null) |
2032 | return null; | 2094 | return null; |
@@ -2048,14 +2110,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2048 | /// <returns></returns> | 2110 | /// <returns></returns> |
2049 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 2111 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
2050 | { | 2112 | { |
2113 | |||
2114 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
2115 | Vector3 wpos = Vector3.Zero; | ||
2116 | // Check for water surface intersection from above | ||
2117 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
2118 | { | ||
2119 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
2120 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
2121 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
2122 | wpos.Z = wheight; | ||
2123 | } | ||
2124 | |||
2051 | Vector3 pos = Vector3.Zero; | 2125 | Vector3 pos = Vector3.Zero; |
2052 | if (RayEndIsIntersection == (byte)1) | 2126 | if (RayEndIsIntersection == (byte)1) |
2053 | { | 2127 | { |
2054 | pos = RayEnd; | 2128 | pos = RayEnd; |
2055 | return pos; | ||
2056 | } | 2129 | } |
2057 | 2130 | else if (RayTargetID != UUID.Zero) | |
2058 | if (RayTargetID != UUID.Zero) | ||
2059 | { | 2131 | { |
2060 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 2132 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
2061 | 2133 | ||
@@ -2077,7 +2149,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2077 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 2149 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
2078 | 2150 | ||
2079 | // Un-comment out the following line to Get Raytrace results printed to the console. | 2151 | // Un-comment out the following line to Get Raytrace results printed to the console. |
2080 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 2152 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
2081 | float ScaleOffset = 0.5f; | 2153 | float ScaleOffset = 0.5f; |
2082 | 2154 | ||
2083 | // If we hit something | 2155 | // If we hit something |
@@ -2100,13 +2172,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2100 | //pos.Z -= 0.25F; | 2172 | //pos.Z -= 0.25F; |
2101 | 2173 | ||
2102 | } | 2174 | } |
2103 | |||
2104 | return pos; | ||
2105 | } | 2175 | } |
2106 | else | 2176 | else |
2107 | { | 2177 | { |
2108 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2178 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
2109 | |||
2110 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2179 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
2111 | 2180 | ||
2112 | // Un-comment the following line to print the raytrace results to the console. | 2181 | // Un-comment the following line to print the raytrace results to the console. |
@@ -2115,13 +2184,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2115 | if (ei.HitTF) | 2184 | if (ei.HitTF) |
2116 | { | 2185 | { |
2117 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2186 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
2118 | } else | 2187 | } |
2188 | else | ||
2119 | { | 2189 | { |
2120 | // fall back to our stupid functionality | 2190 | // fall back to our stupid functionality |
2121 | pos = RayEnd; | 2191 | pos = RayEnd; |
2122 | } | 2192 | } |
2123 | |||
2124 | return pos; | ||
2125 | } | 2193 | } |
2126 | } | 2194 | } |
2127 | else | 2195 | else |
@@ -2132,8 +2200,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2132 | //increase height so its above the ground. | 2200 | //increase height so its above the ground. |
2133 | //should be getting the normal of the ground at the rez point and using that? | 2201 | //should be getting the normal of the ground at the rez point and using that? |
2134 | pos.Z += scale.Z / 2f; | 2202 | pos.Z += scale.Z / 2f; |
2135 | return pos; | 2203 | // return pos; |
2136 | } | 2204 | } |
2205 | |||
2206 | // check against posible water intercept | ||
2207 | if (wpos.Z > pos.Z) pos = wpos; | ||
2208 | return pos; | ||
2137 | } | 2209 | } |
2138 | 2210 | ||
2139 | 2211 | ||
@@ -2224,12 +2296,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2224 | { | 2296 | { |
2225 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) | 2297 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) |
2226 | { | 2298 | { |
2299 | sceneObject.IsDeleted = false; | ||
2227 | EventManager.TriggerObjectAddedToScene(sceneObject); | 2300 | EventManager.TriggerObjectAddedToScene(sceneObject); |
2228 | return true; | 2301 | return true; |
2229 | } | 2302 | } |
2230 | 2303 | ||
2231 | return false; | 2304 | return false; |
2232 | |||
2233 | } | 2305 | } |
2234 | 2306 | ||
2235 | /// <summary> | 2307 | /// <summary> |
@@ -2321,6 +2393,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2321 | /// </summary> | 2393 | /// </summary> |
2322 | public void DeleteAllSceneObjects() | 2394 | public void DeleteAllSceneObjects() |
2323 | { | 2395 | { |
2396 | DeleteAllSceneObjects(false); | ||
2397 | } | ||
2398 | |||
2399 | /// <summary> | ||
2400 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2401 | /// </summary> | ||
2402 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2403 | { | ||
2404 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2324 | lock (Entities) | 2405 | lock (Entities) |
2325 | { | 2406 | { |
2326 | EntityBase[] entities = Entities.GetEntities(); | 2407 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2329,11 +2410,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2329 | if (e is SceneObjectGroup) | 2410 | if (e is SceneObjectGroup) |
2330 | { | 2411 | { |
2331 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2412 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2332 | if (!sog.IsAttachment) | 2413 | if (sog != null && !sog.IsAttachment) |
2333 | DeleteSceneObject((SceneObjectGroup)e, false); | 2414 | { |
2415 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2416 | { | ||
2417 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2418 | } | ||
2419 | else | ||
2420 | { | ||
2421 | toReturn.Add((SceneObjectGroup)e); | ||
2422 | } | ||
2423 | } | ||
2334 | } | 2424 | } |
2335 | } | 2425 | } |
2336 | } | 2426 | } |
2427 | if (toReturn.Count > 0) | ||
2428 | { | ||
2429 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2430 | } | ||
2337 | } | 2431 | } |
2338 | 2432 | ||
2339 | /// <summary> | 2433 | /// <summary> |
@@ -2364,6 +2458,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2364 | else | 2458 | else |
2365 | group.StopScriptInstances(); | 2459 | group.StopScriptInstances(); |
2366 | 2460 | ||
2461 | List<UUID> avatars = group.GetSittingAvatars(); | ||
2462 | foreach (UUID av in avatars) | ||
2463 | { | ||
2464 | ScenePresence p = GetScenePresence(av); | ||
2465 | if (p != null) | ||
2466 | p.StandUp(); | ||
2467 | } | ||
2468 | |||
2367 | SceneObjectPart[] partList = group.Parts; | 2469 | SceneObjectPart[] partList = group.Parts; |
2368 | 2470 | ||
2369 | foreach (SceneObjectPart part in partList) | 2471 | foreach (SceneObjectPart part in partList) |
@@ -2391,6 +2493,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2391 | } | 2493 | } |
2392 | 2494 | ||
2393 | group.DeleteGroupFromScene(silent); | 2495 | group.DeleteGroupFromScene(silent); |
2496 | if (!silent) | ||
2497 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2394 | 2498 | ||
2395 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2499 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2396 | } | 2500 | } |
@@ -2680,7 +2784,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2680 | // If the user is banned, we won't let any of their objects | 2784 | // If the user is banned, we won't let any of their objects |
2681 | // enter. Period. | 2785 | // enter. Period. |
2682 | // | 2786 | // |
2683 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2787 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2684 | { | 2788 | { |
2685 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2789 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2686 | return false; | 2790 | return false; |
@@ -2735,6 +2839,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2735 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2839 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2736 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2840 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2737 | { | 2841 | { |
2842 | if (sceneObject.OwnerID == UUID.Zero) | ||
2843 | { | ||
2844 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2845 | return false; | ||
2846 | } | ||
2847 | |||
2848 | // If the user is banned, we won't let any of their objects | ||
2849 | // enter. Period. | ||
2850 | // | ||
2851 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2852 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2853 | { | ||
2854 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2855 | |||
2856 | return false; | ||
2857 | } | ||
2858 | |||
2738 | // Force allocation of new LocalId | 2859 | // Force allocation of new LocalId |
2739 | // | 2860 | // |
2740 | SceneObjectPart[] parts = sceneObject.Parts; | 2861 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2771,16 +2892,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2771 | // information that this is due to a teleport/border cross rather than an ordinary attachment. | 2892 | // information that this is due to a teleport/border cross rather than an ordinary attachment. |
2772 | // We currently do this in Scene.MakeRootAgent() instead. | 2893 | // We currently do this in Scene.MakeRootAgent() instead. |
2773 | if (AttachmentsModule != null) | 2894 | if (AttachmentsModule != null) |
2774 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); | 2895 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true); |
2775 | } | 2896 | } |
2776 | else | 2897 | else |
2777 | { | 2898 | { |
2899 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2778 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2900 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2779 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2901 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2780 | } | 2902 | } |
2903 | if (sceneObject.OwnerID == UUID.Zero) | ||
2904 | { | ||
2905 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2906 | return false; | ||
2907 | } | ||
2781 | } | 2908 | } |
2782 | else | 2909 | else |
2783 | { | 2910 | { |
2911 | if (sceneObject.OwnerID == UUID.Zero) | ||
2912 | { | ||
2913 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2914 | return false; | ||
2915 | } | ||
2784 | AddRestoredSceneObject(sceneObject, true, false); | 2916 | AddRestoredSceneObject(sceneObject, true, false); |
2785 | } | 2917 | } |
2786 | 2918 | ||
@@ -2797,6 +2929,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2797 | return 2; // StateSource.PrimCrossing | 2929 | return 2; // StateSource.PrimCrossing |
2798 | } | 2930 | } |
2799 | 2931 | ||
2932 | public int GetUserFlags(UUID user) | ||
2933 | { | ||
2934 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2935 | /* | ||
2936 | ScenePresence sp; | ||
2937 | if (TryGetScenePresence(user, out sp)) | ||
2938 | { | ||
2939 | return sp.UserFlags; | ||
2940 | } | ||
2941 | else | ||
2942 | { | ||
2943 | */ | ||
2944 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2945 | if (uac == null) | ||
2946 | return 0; | ||
2947 | return uac.UserFlags; | ||
2948 | //} | ||
2949 | } | ||
2800 | #endregion | 2950 | #endregion |
2801 | 2951 | ||
2802 | #region Add/Remove Avatar Methods | 2952 | #region Add/Remove Avatar Methods |
@@ -2830,7 +2980,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2830 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2980 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2831 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2981 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2832 | 2982 | ||
2833 | // CheckHeartbeat(); | 2983 | CheckHeartbeat(); |
2834 | 2984 | ||
2835 | sp = GetScenePresence(client.AgentId); | 2985 | sp = GetScenePresence(client.AgentId); |
2836 | 2986 | ||
@@ -2848,6 +2998,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2848 | SubscribeToClientEvents(client); | 2998 | SubscribeToClientEvents(client); |
2849 | 2999 | ||
2850 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); | 3000 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); |
3001 | InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46); | ||
3002 | if (cof == null) | ||
3003 | sp.COF = UUID.Zero; | ||
3004 | else | ||
3005 | sp.COF = cof.ID; | ||
3006 | |||
3007 | m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF); | ||
2851 | m_eventManager.TriggerOnNewPresence(sp); | 3008 | m_eventManager.TriggerOnNewPresence(sp); |
2852 | 3009 | ||
2853 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; | 3010 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; |
@@ -2965,19 +3122,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2965 | // and the scene presence and the client, if they exist | 3122 | // and the scene presence and the client, if they exist |
2966 | try | 3123 | try |
2967 | { | 3124 | { |
2968 | // We need to wait for the client to make UDP contact first. | 3125 | ScenePresence sp = GetScenePresence(agentID); |
2969 | // It's the UDP contact that creates the scene presence | 3126 | |
2970 | ScenePresence sp = WaitGetScenePresence(agentID); | ||
2971 | if (sp != null) | 3127 | if (sp != null) |
2972 | { | 3128 | { |
2973 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 3129 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2974 | 3130 | ||
2975 | IncomingCloseAgent(sp.UUID, false); | 3131 | IncomingCloseAgent(sp.UUID, false); |
2976 | } | 3132 | } |
2977 | else | 3133 | |
2978 | { | ||
2979 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2980 | } | ||
2981 | // BANG! SLASH! | 3134 | // BANG! SLASH! |
2982 | m_authenticateHandler.RemoveCircuit(agentID); | 3135 | m_authenticateHandler.RemoveCircuit(agentID); |
2983 | 3136 | ||
@@ -3022,6 +3175,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3022 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3175 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
3023 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3176 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
3024 | 3177 | ||
3178 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3179 | |||
3025 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3180 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3026 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3181 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3027 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3182 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3078,6 +3233,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3078 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3233 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
3079 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3234 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
3080 | client.OnCopyInventoryItem += CopyInventoryItem; | 3235 | client.OnCopyInventoryItem += CopyInventoryItem; |
3236 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
3081 | client.OnMoveInventoryItem += MoveInventoryItem; | 3237 | client.OnMoveInventoryItem += MoveInventoryItem; |
3082 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3238 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
3083 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3239 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3147,6 +3303,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3147 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3303 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
3148 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3304 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
3149 | 3305 | ||
3306 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3307 | |||
3150 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3308 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3151 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3309 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3152 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3310 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3458,7 +3616,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3458 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop | 3616 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop |
3459 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI | 3617 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI |
3460 | if (closeChildAgents && CapsModule != null) | 3618 | if (closeChildAgents && CapsModule != null) |
3461 | CapsModule.RemoveCaps(agentID); | 3619 | CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode); |
3462 | 3620 | ||
3463 | if (closeChildAgents && !isChildAgent) | 3621 | if (closeChildAgents && !isChildAgent) |
3464 | { | 3622 | { |
@@ -3491,6 +3649,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3491 | // It's possible for child agents to have transactions if changes are being made cross-border. | 3649 | // It's possible for child agents to have transactions if changes are being made cross-border. |
3492 | if (AgentTransactionsModule != null) | 3650 | if (AgentTransactionsModule != null) |
3493 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3651 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3652 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3494 | } | 3653 | } |
3495 | catch (Exception e) | 3654 | catch (Exception e) |
3496 | { | 3655 | { |
@@ -3798,13 +3957,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3798 | // On login test land permisions | 3957 | // On login test land permisions |
3799 | if (vialogin) | 3958 | if (vialogin) |
3800 | { | 3959 | { |
3960 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); | ||
3961 | if (cache != null) | ||
3962 | cache.Remove(acd.firstname + " " + acd.lastname); | ||
3801 | if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y)) | 3963 | if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y)) |
3802 | { | 3964 | { |
3803 | m_authenticateHandler.RemoveCircuit(acd.circuitcode); | 3965 | m_authenticateHandler.RemoveCircuit(acd.circuitcode); |
3804 | return false; | 3966 | return false; |
3805 | } | 3967 | } |
3806 | } | 3968 | } |
3807 | 3969 | ||
3808 | if (sp == null) // We don't have an [child] agent here already | 3970 | if (sp == null) // We don't have an [child] agent here already |
3809 | { | 3971 | { |
3810 | if (requirePresenceLookup) | 3972 | if (requirePresenceLookup) |
@@ -3826,7 +3988,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3826 | return false; | 3988 | return false; |
3827 | } | 3989 | } |
3828 | } | 3990 | } |
3829 | 3991 | ||
3830 | try | 3992 | try |
3831 | { | 3993 | { |
3832 | if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason)) | 3994 | if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason)) |
@@ -3843,7 +4005,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3843 | m_authenticateHandler.RemoveCircuit(acd.circuitcode); | 4005 | m_authenticateHandler.RemoveCircuit(acd.circuitcode); |
3844 | return false; | 4006 | return false; |
3845 | } | 4007 | } |
3846 | 4008 | ||
3847 | m_log.InfoFormat( | 4009 | m_log.InfoFormat( |
3848 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", | 4010 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", |
3849 | Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname, | 4011 | Name, (acd.child ? "child" : "root"), acd.firstname, acd.lastname, |
@@ -3852,7 +4014,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3852 | if (CapsModule != null) | 4014 | if (CapsModule != null) |
3853 | { | 4015 | { |
3854 | CapsModule.SetAgentCapsSeeds(acd); | 4016 | CapsModule.SetAgentCapsSeeds(acd); |
3855 | CapsModule.CreateCaps(acd.AgentID); | 4017 | CapsModule.CreateCaps(acd.AgentID, acd.circuitcode); |
3856 | } | 4018 | } |
3857 | } | 4019 | } |
3858 | else | 4020 | else |
@@ -3885,7 +4047,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3885 | if (CapsModule != null) | 4047 | if (CapsModule != null) |
3886 | { | 4048 | { |
3887 | CapsModule.SetAgentCapsSeeds(acd); | 4049 | CapsModule.SetAgentCapsSeeds(acd); |
3888 | CapsModule.CreateCaps(acd.AgentID); | 4050 | CapsModule.CreateCaps(acd.AgentID, acd.circuitcode); |
3889 | } | 4051 | } |
3890 | } | 4052 | } |
3891 | } | 4053 | } |
@@ -3896,6 +4058,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3896 | CacheUserName(null, acd); | 4058 | CacheUserName(null, acd); |
3897 | } | 4059 | } |
3898 | 4060 | ||
4061 | if (CapsModule != null) | ||
4062 | { | ||
4063 | CapsModule.ActivateCaps(acd.circuitcode); | ||
4064 | } | ||
4065 | |||
3899 | if (vialogin) | 4066 | if (vialogin) |
3900 | { | 4067 | { |
3901 | // CleanDroppedAttachments(); | 4068 | // CleanDroppedAttachments(); |
@@ -3987,6 +4154,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3987 | } | 4154 | } |
3988 | 4155 | ||
3989 | // Honor parcel landing type and position. | 4156 | // Honor parcel landing type and position. |
4157 | /* | ||
4158 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3990 | if (land != null) | 4159 | if (land != null) |
3991 | { | 4160 | { |
3992 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 4161 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3994,6 +4163,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3994 | acd.startpos = land.LandData.UserLocation; | 4163 | acd.startpos = land.LandData.UserLocation; |
3995 | } | 4164 | } |
3996 | } | 4165 | } |
4166 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3997 | } | 4167 | } |
3998 | 4168 | ||
3999 | return true; | 4169 | return true; |
@@ -4091,7 +4261,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4091 | 4261 | ||
4092 | if (!m_strictAccessControl) return true; | 4262 | if (!m_strictAccessControl) return true; |
4093 | if (Permissions.IsGod(agent.AgentID)) return true; | 4263 | if (Permissions.IsGod(agent.AgentID)) return true; |
4094 | 4264 | ||
4095 | if (AuthorizationService != null) | 4265 | if (AuthorizationService != null) |
4096 | { | 4266 | { |
4097 | if (!AuthorizationService.IsAuthorizedForRegion( | 4267 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -4112,7 +4282,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4112 | { | 4282 | { |
4113 | if (RegionInfo.EstateSettings != null) | 4283 | if (RegionInfo.EstateSettings != null) |
4114 | { | 4284 | { |
4115 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 4285 | int flags = GetUserFlags(agent.AgentID); |
4286 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, flags)) | ||
4116 | { | 4287 | { |
4117 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 4288 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
4118 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 4289 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -4301,6 +4472,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4301 | m_log.DebugFormat( | 4472 | m_log.DebugFormat( |
4302 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); | 4473 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); |
4303 | 4474 | ||
4475 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4476 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4477 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4478 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4479 | { | ||
4480 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4481 | return false; | ||
4482 | } | ||
4483 | |||
4304 | // TODO: This check should probably be in QueryAccess(). | 4484 | // TODO: This check should probably be in QueryAccess(). |
4305 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4485 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4306 | if (nearestParcel == null) | 4486 | if (nearestParcel == null) |
@@ -4396,7 +4576,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4396 | /// <param name='agentID'></param> | 4576 | /// <param name='agentID'></param> |
4397 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 4577 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4398 | { | 4578 | { |
4399 | int ntimes = 20; | 4579 | int ntimes = 30; |
4400 | ScenePresence sp = null; | 4580 | ScenePresence sp = null; |
4401 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 4581 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4402 | Thread.Sleep(1000); | 4582 | Thread.Sleep(1000); |
@@ -4458,6 +4638,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4458 | return false; | 4638 | return false; |
4459 | } | 4639 | } |
4460 | 4640 | ||
4641 | public bool IncomingCloseAgent(UUID agentID) | ||
4642 | { | ||
4643 | return IncomingCloseAgent(agentID, false); | ||
4644 | } | ||
4645 | |||
4646 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4647 | { | ||
4648 | return IncomingCloseAgent(agentID, true); | ||
4649 | } | ||
4650 | |||
4461 | /// <summary> | 4651 | /// <summary> |
4462 | /// Tell a single agent to prepare to close. | 4652 | /// Tell a single agent to prepare to close. |
4463 | /// </summary> | 4653 | /// </summary> |
@@ -4556,7 +4746,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4556 | 4746 | ||
4557 | if (sp != null) | 4747 | if (sp != null) |
4558 | { | 4748 | { |
4559 | sp.ControllingClient.Close(force); | 4749 | sp.ControllingClient.Close(force, force); |
4560 | return true; | 4750 | return true; |
4561 | } | 4751 | } |
4562 | 4752 | ||
@@ -5174,7 +5364,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5174 | { | 5364 | { |
5175 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 5365 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
5176 | { | 5366 | { |
5177 | if (grp.RootPart.Expires <= DateTime.Now) | 5367 | if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now) |
5178 | DeleteSceneObject(grp, false); | 5368 | DeleteSceneObject(grp, false); |
5179 | } | 5369 | } |
5180 | } | 5370 | } |
@@ -5188,35 +5378,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
5188 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 5378 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
5189 | } | 5379 | } |
5190 | 5380 | ||
5191 | public int GetHealth() | 5381 | public int GetHealth(out int flags, out string message) |
5192 | { | 5382 | { |
5193 | // Returns: | 5383 | // Returns: |
5194 | // 1 = sim is up and accepting http requests. The heartbeat has | 5384 | // 1 = sim is up and accepting http requests. The heartbeat has |
5195 | // stopped and the sim is probably locked up, but a remote | 5385 | // stopped and the sim is probably locked up, but a remote |
5196 | // admin restart may succeed | 5386 | // admin restart may succeed |
5197 | // | 5387 | // |
5198 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 5388 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
5199 | // usable for people within and logins _may_ work | 5389 | // usable for people within |
5390 | // | ||
5391 | // 3 = Sim is up and one packet thread is running. Sim is | ||
5392 | // unstable and will not accept new logins | ||
5200 | // | 5393 | // |
5201 | // 3 = We have seen a new user enter within the past 4 minutes | 5394 | // 4 = Sim is up and both packet threads are running. Sim is |
5395 | // likely usable | ||
5396 | // | ||
5397 | // 5 = We have seen a new user enter within the past 4 minutes | ||
5202 | // which can be seen as positive confirmation of sim health | 5398 | // which can be seen as positive confirmation of sim health |
5203 | // | 5399 | // |
5400 | |||
5401 | flags = 0; | ||
5402 | message = String.Empty; | ||
5403 | |||
5404 | CheckHeartbeat(); | ||
5405 | |||
5406 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
5407 | { | ||
5408 | // We're still starting | ||
5409 | // 0 means "in startup", it can't happen another way, since | ||
5410 | // to get here, we must be able to accept http connections | ||
5411 | return 0; | ||
5412 | } | ||
5413 | |||
5204 | int health=1; // Start at 1, means we're up | 5414 | int health=1; // Start at 1, means we're up |
5205 | 5415 | ||
5206 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5416 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
5207 | health += 1; | 5417 | { |
5418 | health+=1; | ||
5419 | flags |= 1; | ||
5420 | } | ||
5421 | |||
5422 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
5423 | { | ||
5424 | health+=1; | ||
5425 | flags |= 2; | ||
5426 | } | ||
5427 | |||
5428 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
5429 | { | ||
5430 | health+=1; | ||
5431 | flags |= 4; | ||
5432 | } | ||
5208 | else | 5433 | else |
5434 | { | ||
5435 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
5436 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
5437 | proc.EnableRaisingEvents=false; | ||
5438 | proc.StartInfo.FileName = "/bin/kill"; | ||
5439 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
5440 | proc.Start(); | ||
5441 | proc.WaitForExit(); | ||
5442 | Thread.Sleep(1000); | ||
5443 | Environment.Exit(1); | ||
5444 | } | ||
5445 | |||
5446 | if (flags != 7) | ||
5209 | return health; | 5447 | return health; |
5210 | 5448 | ||
5211 | // A login in the last 4 mins? We can't be doing too badly | 5449 | // A login in the last 4 mins? We can't be doing too badly |
5212 | // | 5450 | // |
5213 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 5451 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
5214 | health++; | 5452 | health++; |
5215 | else | 5453 | else |
5216 | return health; | 5454 | return health; |
5217 | 5455 | ||
5218 | // CheckHeartbeat(); | ||
5219 | |||
5220 | return health; | 5456 | return health; |
5221 | } | 5457 | } |
5222 | 5458 | ||
@@ -5304,7 +5540,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5304 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5540 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
5305 | if (wasUsingPhysics) | 5541 | if (wasUsingPhysics) |
5306 | { | 5542 | { |
5307 | 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 | 5543 | 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 |
5308 | } | 5544 | } |
5309 | } | 5545 | } |
5310 | 5546 | ||
@@ -5403,14 +5639,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5403 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5639 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
5404 | } | 5640 | } |
5405 | 5641 | ||
5406 | // private void CheckHeartbeat() | 5642 | private void CheckHeartbeat() |
5407 | // { | 5643 | { |
5408 | // if (m_firstHeartbeat) | 5644 | if (m_firstHeartbeat) |
5409 | // return; | 5645 | return; |
5410 | // | 5646 | |
5411 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5647 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
5412 | // StartTimer(); | 5648 | Start(); |
5413 | // } | 5649 | } |
5414 | 5650 | ||
5415 | public override ISceneObject DeserializeObject(string representation) | 5651 | public override ISceneObject DeserializeObject(string representation) |
5416 | { | 5652 | { |
@@ -5468,7 +5704,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5468 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); | 5704 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); |
5469 | 5705 | ||
5470 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); | 5706 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); |
5471 | 5707 | ||
5472 | return nearestRegionEdgePoint; | 5708 | return nearestRegionEdgePoint; |
5473 | } | 5709 | } |
5474 | 5710 | ||
@@ -5722,7 +5958,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5722 | mapModule.GenerateMaptile(); | 5958 | mapModule.GenerateMaptile(); |
5723 | } | 5959 | } |
5724 | 5960 | ||
5725 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5961 | // public void CleanDroppedAttachments() |
5962 | // { | ||
5963 | // List<SceneObjectGroup> objectsToDelete = | ||
5964 | // new List<SceneObjectGroup>(); | ||
5965 | // | ||
5966 | // lock (m_cleaningAttachments) | ||
5967 | // { | ||
5968 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5969 | // { | ||
5970 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5971 | // { | ||
5972 | // UUID agentID = grp.OwnerID; | ||
5973 | // if (agentID == UUID.Zero) | ||
5974 | // { | ||
5975 | // objectsToDelete.Add(grp); | ||
5976 | // return; | ||
5977 | // } | ||
5978 | // | ||
5979 | // ScenePresence sp = GetScenePresence(agentID); | ||
5980 | // if (sp == null) | ||
5981 | // { | ||
5982 | // objectsToDelete.Add(grp); | ||
5983 | // return; | ||
5984 | // } | ||
5985 | // } | ||
5986 | // }); | ||
5987 | // } | ||
5988 | // | ||
5989 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5990 | // { | ||
5991 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5992 | // DeleteSceneObject(grp, true); | ||
5993 | // } | ||
5994 | // } | ||
5995 | |||
5996 | public void ThreadAlive(int threadCode) | ||
5997 | { | ||
5998 | switch(threadCode) | ||
5999 | { | ||
6000 | case 1: // Incoming | ||
6001 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
6002 | break; | ||
6003 | case 2: // Incoming | ||
6004 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
6005 | break; | ||
6006 | } | ||
6007 | } | ||
6008 | |||
6009 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5726 | { | 6010 | { |
5727 | RegenerateMaptile(); | 6011 | RegenerateMaptile(); |
5728 | 6012 | ||
@@ -5873,7 +6157,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
5873 | return true; | 6157 | return true; |
5874 | } | 6158 | } |
5875 | 6159 | ||
5876 | /// <summary> | 6160 | public void StartTimerWatchdog() |
6161 | { | ||
6162 | m_timerWatchdog.Interval = 1000; | ||
6163 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
6164 | m_timerWatchdog.AutoReset = true; | ||
6165 | m_timerWatchdog.Start(); | ||
6166 | } | ||
6167 | |||
6168 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
6169 | { | ||
6170 | CheckHeartbeat(); | ||
6171 | } | ||
6172 | |||
5877 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 6173 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5878 | /// autopilot that moves an avatar to a sit target!. | 6174 | /// autopilot that moves an avatar to a sit target!. |
5879 | /// </summary> | 6175 | /// </summary> |
@@ -5952,6 +6248,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5952 | return m_SpawnPoint - 1; | 6248 | return m_SpawnPoint - 1; |
5953 | } | 6249 | } |
5954 | 6250 | ||
6251 | private void HandleGcCollect(string module, string[] args) | ||
6252 | { | ||
6253 | GC.Collect(); | ||
6254 | } | ||
6255 | |||
5955 | /// <summary> | 6256 | /// <summary> |
5956 | /// Wrappers to get physics modules retrieve assets. | 6257 | /// Wrappers to get physics modules retrieve assets. |
5957 | /// </summary> | 6258 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 5252b96..1dac676 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -143,7 +143,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
143 | 143 | ||
144 | protected ulong m_regionHandle; | 144 | protected ulong m_regionHandle; |
145 | protected string m_regionName; | 145 | protected string m_regionName; |
146 | protected RegionInfo m_regInfo; | ||
147 | 146 | ||
148 | public ITerrainChannel Heightmap; | 147 | public ITerrainChannel Heightmap; |
149 | 148 | ||
@@ -168,6 +167,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
168 | get { return m_permissions; } | 167 | get { return m_permissions; } |
169 | } | 168 | } |
170 | 169 | ||
170 | protected string m_datastore; | ||
171 | |||
171 | /* Used by the loadbalancer plugin on GForge */ | 172 | /* Used by the loadbalancer plugin on GForge */ |
172 | protected RegionStatus m_regStatus; | 173 | protected RegionStatus m_regStatus; |
173 | public RegionStatus RegionStatus | 174 | 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 0a5bfd2..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> |
@@ -519,12 +589,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
519 | 589 | ||
520 | protected internal void AddPhysicalPrim(int number) | 590 | protected internal void AddPhysicalPrim(int number) |
521 | { | 591 | { |
522 | m_physicalPrim++; | 592 | m_physicalPrim += number; |
523 | } | 593 | } |
524 | 594 | ||
525 | protected internal void RemovePhysicalPrim(int number) | 595 | protected internal void RemovePhysicalPrim(int number) |
526 | { | 596 | { |
527 | m_physicalPrim--; | 597 | m_physicalPrim -= number; |
528 | } | 598 | } |
529 | 599 | ||
530 | protected internal void AddToScriptLPS(int number) | 600 | protected internal void AddToScriptLPS(int number) |
@@ -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 4b4e4ba..9e3d875 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,12 @@ 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; | ||
126 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); | ||
121 | 127 | ||
122 | /// <summary> | 128 | /// <summary> |
123 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage | 129 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage |
@@ -134,9 +140,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
134 | { | 140 | { |
135 | if (value) | 141 | if (value) |
136 | { | 142 | { |
143 | |||
144 | if (m_isBackedUp) | ||
145 | { | ||
146 | m_scene.SceneGraph.FireChangeBackup(this); | ||
147 | } | ||
137 | timeLastChanged = DateTime.Now.Ticks; | 148 | timeLastChanged = DateTime.Now.Ticks; |
138 | if (!m_hasGroupChanged) | 149 | if (!m_hasGroupChanged) |
139 | 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 | } | ||
140 | } | 181 | } |
141 | m_hasGroupChanged = value; | 182 | m_hasGroupChanged = value; |
142 | 183 | ||
@@ -151,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
151 | /// 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 |
152 | /// 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. |
153 | /// </summary> | 194 | /// </summary> |
154 | public bool HasGroupChangedDueToDelink { get; private set; } | 195 | public bool HasGroupChangedDueToDelink { get; set; } |
155 | 196 | ||
156 | private bool isTimeToPersist() | 197 | private bool isTimeToPersist() |
157 | { | 198 | { |
@@ -161,8 +202,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
161 | return false; | 202 | return false; |
162 | if (m_scene.ShuttingDown) | 203 | if (m_scene.ShuttingDown) |
163 | 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 | |||
164 | long currentTime = DateTime.Now.Ticks; | 212 | long currentTime = DateTime.Now.Ticks; |
165 | 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) | ||
166 | return true; | 218 | return true; |
167 | return false; | 219 | return false; |
168 | } | 220 | } |
@@ -220,6 +272,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
220 | { | 272 | { |
221 | AttachmentPoint = 0; | 273 | AttachmentPoint = 0; |
222 | 274 | ||
275 | // Don't zap trees | ||
276 | if (RootPart.Shape.PCode == (byte)PCode.Tree || | ||
277 | RootPart.Shape.PCode == (byte)PCode.NewTree) | ||
278 | return; | ||
279 | |||
223 | // 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 |
224 | // 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 |
225 | // 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. |
@@ -265,26 +322,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | get { return RootPart.VolumeDetectActive; } | 322 | get { return RootPart.VolumeDetectActive; } |
266 | } | 323 | } |
267 | 324 | ||
268 | private Vector3 lastPhysGroupPos; | ||
269 | private Quaternion lastPhysGroupRot; | ||
270 | |||
271 | private bool m_isBackedUp; | 325 | private bool m_isBackedUp; |
272 | 326 | ||
327 | public bool IsBackedUp | ||
328 | { | ||
329 | get { return m_isBackedUp; } | ||
330 | } | ||
331 | |||
273 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); | 332 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); |
274 | 333 | ||
275 | protected ulong m_regionHandle; | 334 | protected ulong m_regionHandle; |
276 | protected SceneObjectPart m_rootPart; | 335 | protected SceneObjectPart m_rootPart; |
277 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); | 336 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); |
278 | 337 | ||
279 | private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); | 338 | private SortedDictionary<uint, scriptPosTarget> m_targets = new SortedDictionary<uint, scriptPosTarget>(); |
280 | 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 | } | ||
281 | 350 | ||
282 | private bool m_scriptListens_atTarget; | 351 | private bool m_scriptListens_atTarget; |
283 | private bool m_scriptListens_notAtTarget; | 352 | private bool m_scriptListens_notAtTarget; |
284 | |||
285 | private bool m_scriptListens_atRotTarget; | 353 | private bool m_scriptListens_atRotTarget; |
286 | private bool m_scriptListens_notAtRotTarget; | 354 | private bool m_scriptListens_notAtRotTarget; |
287 | 355 | ||
356 | public bool m_dupeInProgress = false; | ||
288 | internal Dictionary<UUID, string> m_savedScriptState; | 357 | internal Dictionary<UUID, string> m_savedScriptState; |
289 | 358 | ||
290 | #region Properties | 359 | #region Properties |
@@ -321,6 +390,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
321 | get { return m_parts.Count; } | 390 | get { return m_parts.Count; } |
322 | } | 391 | } |
323 | 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 | |||
324 | public Quaternion GroupRotation | 403 | public Quaternion GroupRotation |
325 | { | 404 | { |
326 | get { return m_rootPart.RotationOffset; } | 405 | get { return m_rootPart.RotationOffset; } |
@@ -427,7 +506,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
427 | { | 506 | { |
428 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); | 507 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); |
429 | } | 508 | } |
430 | 509 | ||
510 | |||
511 | |||
512 | private struct avtocrossInfo | ||
513 | { | ||
514 | public ScenePresence av; | ||
515 | public uint ParentID; | ||
516 | } | ||
517 | |||
431 | /// <summary> | 518 | /// <summary> |
432 | /// The absolute position of this scene object in the scene | 519 | /// The absolute position of this scene object in the scene |
433 | /// </summary> | 520 | /// </summary> |
@@ -455,13 +542,129 @@ namespace OpenSim.Region.Framework.Scenes | |||
455 | || Scene.TestBorderCross(val, Cardinals.S)) | 542 | || Scene.TestBorderCross(val, Cardinals.S)) |
456 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) | 543 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) |
457 | { | 544 | { |
545 | IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | ||
546 | uint x = 0; | ||
547 | uint y = 0; | ||
548 | string version = String.Empty; | ||
549 | Vector3 newpos = Vector3.Zero; | ||
550 | OpenSim.Services.Interfaces.GridRegion destination = null; | ||
551 | |||
458 | if (m_rootPart.KeyframeMotion != null) | 552 | if (m_rootPart.KeyframeMotion != null) |
459 | m_rootPart.KeyframeMotion.StartCrossingCheck(); | 553 | m_rootPart.KeyframeMotion.StartCrossingCheck(); |
460 | 554 | ||
461 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | 555 | bool canCross = true; |
556 | foreach (ScenePresence av in m_linkedAvatars) | ||
557 | { | ||
558 | // We need to cross these agents. First, let's find | ||
559 | // out if any of them can't cross for some reason. | ||
560 | // We have to deny the crossing entirely if any | ||
561 | // of them are banned. Alternatively, we could | ||
562 | // unsit banned agents.... | ||
563 | |||
564 | |||
565 | // We set the avatar position as being the object | ||
566 | // position to get the region to send to | ||
567 | if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) | ||
568 | { | ||
569 | canCross = false; | ||
570 | break; | ||
571 | } | ||
572 | |||
573 | m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); | ||
574 | } | ||
575 | |||
576 | if (canCross) | ||
577 | { | ||
578 | // We unparent the SP quietly so that it won't | ||
579 | // be made to stand up | ||
580 | |||
581 | List<avtocrossInfo> avsToCross = new List<avtocrossInfo>(); | ||
582 | |||
583 | foreach (ScenePresence av in m_linkedAvatars) | ||
584 | { | ||
585 | avtocrossInfo avinfo = new avtocrossInfo(); | ||
586 | SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); | ||
587 | if (parentPart != null) | ||
588 | av.ParentUUID = parentPart.UUID; | ||
589 | |||
590 | avinfo.av = av; | ||
591 | avinfo.ParentID = av.ParentID; | ||
592 | avsToCross.Add(avinfo); | ||
593 | |||
594 | av.ParentID = 0; | ||
595 | } | ||
596 | |||
597 | // m_linkedAvatars.Clear(); | ||
598 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | ||
599 | |||
600 | // Normalize | ||
601 | if (val.X >= Constants.RegionSize) | ||
602 | val.X -= Constants.RegionSize; | ||
603 | if (val.Y >= Constants.RegionSize) | ||
604 | val.Y -= Constants.RegionSize; | ||
605 | if (val.X < 0) | ||
606 | val.X += Constants.RegionSize; | ||
607 | if (val.Y < 0) | ||
608 | val.Y += Constants.RegionSize; | ||
609 | |||
610 | // If it's deleted, crossing was successful | ||
611 | if (IsDeleted) | ||
612 | { | ||
613 | // foreach (ScenePresence av in m_linkedAvatars) | ||
614 | foreach (avtocrossInfo avinfo in avsToCross) | ||
615 | { | ||
616 | ScenePresence av = avinfo.av; | ||
617 | if (!av.IsInTransit) // just in case... | ||
618 | { | ||
619 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); | ||
620 | |||
621 | av.IsInTransit = true; | ||
622 | |||
623 | CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; | ||
624 | d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); | ||
625 | } | ||
626 | else | ||
627 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); | ||
628 | } | ||
629 | avsToCross.Clear(); | ||
630 | return; | ||
631 | } | ||
632 | else // cross failed, put avas back ?? | ||
633 | { | ||
634 | foreach (avtocrossInfo avinfo in avsToCross) | ||
635 | { | ||
636 | ScenePresence av = avinfo.av; | ||
637 | av.ParentUUID = UUID.Zero; | ||
638 | av.ParentID = avinfo.ParentID; | ||
639 | // m_linkedAvatars.Add(av); | ||
640 | } | ||
641 | } | ||
642 | avsToCross.Clear(); | ||
643 | |||
644 | } | ||
645 | else | ||
646 | { | ||
647 | if (m_rootPart.KeyframeMotion != null) | ||
648 | m_rootPart.KeyframeMotion.CrossingFailure(); | ||
649 | |||
650 | if (RootPart.PhysActor != null) | ||
651 | { | ||
652 | RootPart.PhysActor.CrossingFailure(); | ||
653 | } | ||
654 | } | ||
655 | Vector3 oldp = AbsolutePosition; | ||
656 | val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
657 | val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
658 | val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f); | ||
462 | } | 659 | } |
463 | } | 660 | } |
464 | 661 | ||
662 | /* don't see the need but worse don't see where is restored to false if things stay in | ||
663 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
664 | { | ||
665 | part.IgnoreUndoUpdate = true; | ||
666 | } | ||
667 | */ | ||
465 | if (RootPart.GetStatusSandbox()) | 668 | if (RootPart.GetStatusSandbox()) |
466 | { | 669 | { |
467 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) | 670 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) |
@@ -479,9 +682,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
479 | // Restuff the new GroupPosition into each SOP of the linkset. | 682 | // Restuff the new GroupPosition into each SOP of the linkset. |
480 | // This has the affect of resetting and tainting the physics actors. | 683 | // This has the affect of resetting and tainting the physics actors. |
481 | SceneObjectPart[] parts = m_parts.GetArray(); | 684 | SceneObjectPart[] parts = m_parts.GetArray(); |
482 | for (int i = 0; i < parts.Length; i++) | 685 | bool triggerScriptEvent = m_rootPart.GroupPosition != val; |
483 | parts[i].GroupPosition = val; | 686 | if (m_dupeInProgress) |
687 | triggerScriptEvent = false; | ||
688 | foreach (SceneObjectPart part in parts) | ||
689 | { | ||
690 | part.GroupPosition = val; | ||
691 | if (triggerScriptEvent) | ||
692 | part.TriggerScriptChangedEvent(Changed.POSITION); | ||
693 | } | ||
484 | 694 | ||
695 | /* | ||
696 | This seems not needed and should not be needed: | ||
697 | sp absolute position depends on sit part absolute position fixed above. | ||
698 | sp ParentPosition is not used anywhere. | ||
699 | Since presence is sitting, viewer considers it 'linked' to root prim, so it will move/rotate it | ||
700 | Sending a extra packet with avatar position is not only bandwidth waste, but may cause jitter in viewers due to UPD nature. | ||
701 | |||
702 | if (!m_dupeInProgress) | ||
703 | { | ||
704 | foreach (ScenePresence av in m_linkedAvatars) | ||
705 | { | ||
706 | SceneObjectPart p = m_scene.GetSceneObjectPart(av.ParentID); | ||
707 | if (p != null && m_parts.TryGetValue(p.UUID, out p)) | ||
708 | { | ||
709 | Vector3 offset = p.GetWorldPosition() - av.ParentPosition; | ||
710 | av.AbsolutePosition += offset; | ||
711 | // av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition | ||
712 | av.SendAvatarDataToAllAgents(); | ||
713 | } | ||
714 | } | ||
715 | } | ||
716 | */ | ||
485 | //if (m_rootPart.PhysActor != null) | 717 | //if (m_rootPart.PhysActor != null) |
486 | //{ | 718 | //{ |
487 | //m_rootPart.PhysActor.Position = | 719 | //m_rootPart.PhysActor.Position = |
@@ -495,6 +727,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
495 | } | 727 | } |
496 | } | 728 | } |
497 | 729 | ||
730 | public override Vector3 Velocity | ||
731 | { | ||
732 | get { return RootPart.Velocity; } | ||
733 | set { RootPart.Velocity = value; } | ||
734 | } | ||
735 | |||
736 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) | ||
737 | { | ||
738 | CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; | ||
739 | ScenePresence agent = icon.EndInvoke(iar); | ||
740 | |||
741 | //// If the cross was successful, this agent is a child agent | ||
742 | if (agent.IsChildAgent) | ||
743 | { | ||
744 | if (agent.ParentUUID != UUID.Zero) | ||
745 | { | ||
746 | agent.ParentPart = null; | ||
747 | // agent.ParentPosition = Vector3.Zero; | ||
748 | // agent.ParentUUID = UUID.Zero; | ||
749 | } | ||
750 | } | ||
751 | |||
752 | agent.ParentUUID = UUID.Zero; | ||
753 | |||
754 | // agent.Reset(); | ||
755 | // else // Not successful | ||
756 | // agent.RestoreInCurrentScene(); | ||
757 | |||
758 | // In any case | ||
759 | agent.IsInTransit = false; | ||
760 | |||
761 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | ||
762 | } | ||
763 | |||
498 | public override uint LocalId | 764 | public override uint LocalId |
499 | { | 765 | { |
500 | get { return m_rootPart.LocalId; } | 766 | get { return m_rootPart.LocalId; } |
@@ -565,6 +831,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
565 | m_isSelected = value; | 831 | m_isSelected = value; |
566 | // Tell physics engine that group is selected | 832 | // Tell physics engine that group is selected |
567 | 833 | ||
834 | // this is not right | ||
835 | // but ode engines should only really need to know about root part | ||
836 | // so they can put entire object simulation on hold and not colliding | ||
837 | // keep as was for now | ||
838 | |||
568 | PhysicsActor pa = m_rootPart.PhysActor; | 839 | PhysicsActor pa = m_rootPart.PhysActor; |
569 | if (pa != null) | 840 | if (pa != null) |
570 | { | 841 | { |
@@ -586,6 +857,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
586 | } | 857 | } |
587 | } | 858 | } |
588 | 859 | ||
860 | public void PartSelectChanged(bool partSelect) | ||
861 | { | ||
862 | // any part selected makes group selected | ||
863 | if (m_isSelected == partSelect) | ||
864 | return; | ||
865 | |||
866 | if (partSelect) | ||
867 | { | ||
868 | IsSelected = partSelect; | ||
869 | // if (!IsAttachment) | ||
870 | // ScheduleGroupForFullUpdate(); | ||
871 | } | ||
872 | else | ||
873 | { | ||
874 | // bad bad bad 2 heavy for large linksets | ||
875 | // since viewer does send lot of (un)selects | ||
876 | // this needs to be replaced by a specific list or count ? | ||
877 | // but that will require extra code in several places | ||
878 | |||
879 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
880 | for (int i = 0; i < parts.Length; i++) | ||
881 | { | ||
882 | SceneObjectPart part = parts[i]; | ||
883 | if (part.IsSelected) | ||
884 | return; | ||
885 | } | ||
886 | IsSelected = partSelect; | ||
887 | if (!IsAttachment) | ||
888 | { | ||
889 | ScheduleGroupForFullUpdate(); | ||
890 | } | ||
891 | } | ||
892 | } | ||
893 | |||
589 | private SceneObjectPart m_PlaySoundMasterPrim = null; | 894 | private SceneObjectPart m_PlaySoundMasterPrim = null; |
590 | public SceneObjectPart PlaySoundMasterPrim | 895 | public SceneObjectPart PlaySoundMasterPrim |
591 | { | 896 | { |
@@ -680,6 +985,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
680 | /// </summary> | 985 | /// </summary> |
681 | public SceneObjectGroup() | 986 | public SceneObjectGroup() |
682 | { | 987 | { |
988 | |||
683 | } | 989 | } |
684 | 990 | ||
685 | /// <summary> | 991 | /// <summary> |
@@ -697,8 +1003,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
697 | /// Constructor. This object is added to the scene later via AttachToScene() | 1003 | /// Constructor. This object is added to the scene later via AttachToScene() |
698 | /// </summary> | 1004 | /// </summary> |
699 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 1005 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
700 | :this(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)) | 1006 | { |
701 | { | 1007 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
702 | } | 1008 | } |
703 | 1009 | ||
704 | /// <summary> | 1010 | /// <summary> |
@@ -733,6 +1039,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
733 | /// </summary> | 1039 | /// </summary> |
734 | public virtual void AttachToBackup() | 1040 | public virtual void AttachToBackup() |
735 | { | 1041 | { |
1042 | if (IsAttachment) return; | ||
1043 | m_scene.SceneGraph.FireAttachToBackup(this); | ||
1044 | |||
736 | if (InSceneBackup) | 1045 | if (InSceneBackup) |
737 | { | 1046 | { |
738 | //m_log.DebugFormat( | 1047 | //m_log.DebugFormat( |
@@ -780,6 +1089,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
780 | 1089 | ||
781 | ApplyPhysics(); | 1090 | ApplyPhysics(); |
782 | 1091 | ||
1092 | if (RootPart.PhysActor != null) | ||
1093 | RootPart.Force = RootPart.Force; | ||
1094 | if (RootPart.PhysActor != null) | ||
1095 | RootPart.Torque = RootPart.Torque; | ||
1096 | if (RootPart.PhysActor != null) | ||
1097 | RootPart.Buoyancy = RootPart.Buoyancy; | ||
1098 | |||
783 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | 1099 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
784 | // for the same object with very different properties. The caller must schedule the update. | 1100 | // for the same object with very different properties. The caller must schedule the update. |
785 | //ScheduleGroupForFullUpdate(); | 1101 | //ScheduleGroupForFullUpdate(); |
@@ -795,6 +1111,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
795 | EntityIntersection result = new EntityIntersection(); | 1111 | EntityIntersection result = new EntityIntersection(); |
796 | 1112 | ||
797 | SceneObjectPart[] parts = m_parts.GetArray(); | 1113 | SceneObjectPart[] parts = m_parts.GetArray(); |
1114 | |||
1115 | // Find closest hit here | ||
1116 | float idist = float.MaxValue; | ||
1117 | |||
798 | for (int i = 0; i < parts.Length; i++) | 1118 | for (int i = 0; i < parts.Length; i++) |
799 | { | 1119 | { |
800 | SceneObjectPart part = parts[i]; | 1120 | SceneObjectPart part = parts[i]; |
@@ -809,11 +1129,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
809 | 1129 | ||
810 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); | 1130 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); |
811 | 1131 | ||
812 | // This may need to be updated to the maximum draw distance possible.. | ||
813 | // We might (and probably will) be checking for prim creation from other sims | ||
814 | // when the camera crosses the border. | ||
815 | float idist = Constants.RegionSize; | ||
816 | |||
817 | if (inter.HitTF) | 1132 | if (inter.HitTF) |
818 | { | 1133 | { |
819 | // We need to find the closest prim to return to the testcaller along the ray | 1134 | // We need to find the closest prim to return to the testcaller along the ray |
@@ -824,10 +1139,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
824 | result.obj = part; | 1139 | result.obj = part; |
825 | result.normal = inter.normal; | 1140 | result.normal = inter.normal; |
826 | result.distance = inter.distance; | 1141 | result.distance = inter.distance; |
1142 | |||
1143 | idist = inter.distance; | ||
827 | } | 1144 | } |
828 | } | 1145 | } |
829 | } | 1146 | } |
830 | |||
831 | return result; | 1147 | return result; |
832 | } | 1148 | } |
833 | 1149 | ||
@@ -839,25 +1155,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
839 | /// <returns></returns> | 1155 | /// <returns></returns> |
840 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) | 1156 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) |
841 | { | 1157 | { |
842 | maxX = -256f; | 1158 | maxX = float.MinValue; |
843 | maxY = -256f; | 1159 | maxY = float.MinValue; |
844 | maxZ = -256f; | 1160 | maxZ = float.MinValue; |
845 | minX = 256f; | 1161 | minX = float.MaxValue; |
846 | minY = 256f; | 1162 | minY = float.MaxValue; |
847 | minZ = 8192f; | 1163 | minZ = float.MaxValue; |
848 | 1164 | ||
849 | SceneObjectPart[] parts = m_parts.GetArray(); | 1165 | SceneObjectPart[] parts = m_parts.GetArray(); |
850 | for (int i = 0; i < parts.Length; i++) | 1166 | foreach (SceneObjectPart part in parts) |
851 | { | 1167 | { |
852 | SceneObjectPart part = parts[i]; | ||
853 | |||
854 | Vector3 worldPos = part.GetWorldPosition(); | 1168 | Vector3 worldPos = part.GetWorldPosition(); |
855 | Vector3 offset = worldPos - AbsolutePosition; | 1169 | Vector3 offset = worldPos - AbsolutePosition; |
856 | Quaternion worldRot; | 1170 | Quaternion worldRot; |
857 | if (part.ParentID == 0) | 1171 | if (part.ParentID == 0) |
1172 | { | ||
858 | worldRot = part.RotationOffset; | 1173 | worldRot = part.RotationOffset; |
1174 | } | ||
859 | else | 1175 | else |
1176 | { | ||
860 | worldRot = part.GetWorldRotation(); | 1177 | worldRot = part.GetWorldRotation(); |
1178 | } | ||
861 | 1179 | ||
862 | Vector3 frontTopLeft; | 1180 | Vector3 frontTopLeft; |
863 | Vector3 frontTopRight; | 1181 | Vector3 frontTopRight; |
@@ -869,6 +1187,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
869 | Vector3 backBottomLeft; | 1187 | Vector3 backBottomLeft; |
870 | Vector3 backBottomRight; | 1188 | Vector3 backBottomRight; |
871 | 1189 | ||
1190 | // Vector3[] corners = new Vector3[8]; | ||
1191 | |||
872 | Vector3 orig = Vector3.Zero; | 1192 | Vector3 orig = Vector3.Zero; |
873 | 1193 | ||
874 | frontTopLeft.X = orig.X - (part.Scale.X / 2); | 1194 | frontTopLeft.X = orig.X - (part.Scale.X / 2); |
@@ -903,6 +1223,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
903 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); | 1223 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); |
904 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); | 1224 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); |
905 | 1225 | ||
1226 | |||
1227 | |||
1228 | //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1229 | //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1230 | //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1231 | //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1232 | //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1233 | //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1234 | //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1235 | //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1236 | |||
1237 | //for (int i = 0; i < 8; i++) | ||
1238 | //{ | ||
1239 | // corners[i] = corners[i] * worldRot; | ||
1240 | // corners[i] += offset; | ||
1241 | |||
1242 | // if (corners[i].X > maxX) | ||
1243 | // maxX = corners[i].X; | ||
1244 | // if (corners[i].X < minX) | ||
1245 | // minX = corners[i].X; | ||
1246 | |||
1247 | // if (corners[i].Y > maxY) | ||
1248 | // maxY = corners[i].Y; | ||
1249 | // if (corners[i].Y < minY) | ||
1250 | // minY = corners[i].Y; | ||
1251 | |||
1252 | // if (corners[i].Z > maxZ) | ||
1253 | // maxZ = corners[i].Y; | ||
1254 | // if (corners[i].Z < minZ) | ||
1255 | // minZ = corners[i].Z; | ||
1256 | //} | ||
1257 | |||
906 | frontTopLeft = frontTopLeft * worldRot; | 1258 | frontTopLeft = frontTopLeft * worldRot; |
907 | frontTopRight = frontTopRight * worldRot; | 1259 | frontTopRight = frontTopRight * worldRot; |
908 | frontBottomLeft = frontBottomLeft * worldRot; | 1260 | frontBottomLeft = frontBottomLeft * worldRot; |
@@ -924,6 +1276,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
924 | backTopLeft += offset; | 1276 | backTopLeft += offset; |
925 | backTopRight += offset; | 1277 | backTopRight += offset; |
926 | 1278 | ||
1279 | //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1280 | //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1281 | //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1282 | //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1283 | //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1284 | //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1285 | //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1286 | //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1287 | |||
927 | if (frontTopRight.X > maxX) | 1288 | if (frontTopRight.X > maxX) |
928 | maxX = frontTopRight.X; | 1289 | maxX = frontTopRight.X; |
929 | if (frontTopLeft.X > maxX) | 1290 | if (frontTopLeft.X > maxX) |
@@ -1067,17 +1428,118 @@ namespace OpenSim.Region.Framework.Scenes | |||
1067 | 1428 | ||
1068 | #endregion | 1429 | #endregion |
1069 | 1430 | ||
1431 | public void GetResourcesCosts(SceneObjectPart apart, | ||
1432 | out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost) | ||
1433 | { | ||
1434 | // this information may need to be cached | ||
1435 | |||
1436 | float cost; | ||
1437 | float tmpcost; | ||
1438 | |||
1439 | bool ComplexCost = false; | ||
1440 | |||
1441 | SceneObjectPart p; | ||
1442 | SceneObjectPart[] parts; | ||
1443 | |||
1444 | lock (m_parts) | ||
1445 | { | ||
1446 | parts = m_parts.GetArray(); | ||
1447 | } | ||
1448 | |||
1449 | int nparts = parts.Length; | ||
1450 | |||
1451 | |||
1452 | for (int i = 0; i < nparts; i++) | ||
1453 | { | ||
1454 | p = parts[i]; | ||
1455 | |||
1456 | if (p.UsesComplexCost) | ||
1457 | { | ||
1458 | ComplexCost = true; | ||
1459 | break; | ||
1460 | } | ||
1461 | } | ||
1462 | |||
1463 | if (ComplexCost) | ||
1464 | { | ||
1465 | linksetResCost = 0; | ||
1466 | linksetPhysCost = 0; | ||
1467 | partCost = 0; | ||
1468 | partPhysCost = 0; | ||
1469 | |||
1470 | for (int i = 0; i < nparts; i++) | ||
1471 | { | ||
1472 | p = parts[i]; | ||
1473 | |||
1474 | cost = p.StreamingCost; | ||
1475 | tmpcost = p.SimulationCost; | ||
1476 | if (tmpcost > cost) | ||
1477 | cost = tmpcost; | ||
1478 | tmpcost = p.PhysicsCost; | ||
1479 | if (tmpcost > cost) | ||
1480 | cost = tmpcost; | ||
1481 | |||
1482 | linksetPhysCost += tmpcost; | ||
1483 | linksetResCost += cost; | ||
1484 | |||
1485 | if (p == apart) | ||
1486 | { | ||
1487 | partCost = cost; | ||
1488 | partPhysCost = tmpcost; | ||
1489 | } | ||
1490 | } | ||
1491 | } | ||
1492 | else | ||
1493 | { | ||
1494 | partPhysCost = 1.0f; | ||
1495 | partCost = 1.0f; | ||
1496 | linksetResCost = (float)nparts; | ||
1497 | linksetPhysCost = linksetResCost; | ||
1498 | } | ||
1499 | } | ||
1500 | |||
1501 | public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost) | ||
1502 | { | ||
1503 | SceneObjectPart p; | ||
1504 | SceneObjectPart[] parts; | ||
1505 | |||
1506 | lock (m_parts) | ||
1507 | { | ||
1508 | parts = m_parts.GetArray(); | ||
1509 | } | ||
1510 | |||
1511 | int nparts = parts.Length; | ||
1512 | |||
1513 | PhysCost = 0; | ||
1514 | StreamCost = 0; | ||
1515 | SimulCost = 0; | ||
1516 | |||
1517 | for (int i = 0; i < nparts; i++) | ||
1518 | { | ||
1519 | p = parts[i]; | ||
1520 | |||
1521 | StreamCost += p.StreamingCost; | ||
1522 | SimulCost += p.SimulationCost; | ||
1523 | PhysCost += p.PhysicsCost; | ||
1524 | } | ||
1525 | } | ||
1526 | |||
1070 | public void SaveScriptedState(XmlTextWriter writer) | 1527 | public void SaveScriptedState(XmlTextWriter writer) |
1071 | { | 1528 | { |
1529 | SaveScriptedState(writer, false); | ||
1530 | } | ||
1531 | |||
1532 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1533 | { | ||
1072 | XmlDocument doc = new XmlDocument(); | 1534 | XmlDocument doc = new XmlDocument(); |
1073 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1535 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
1074 | 1536 | ||
1075 | SceneObjectPart[] parts = m_parts.GetArray(); | 1537 | SceneObjectPart[] parts = m_parts.GetArray(); |
1076 | for (int i = 0; i < parts.Length; i++) | 1538 | for (int i = 0; i < parts.Length; i++) |
1077 | { | 1539 | { |
1078 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(); | 1540 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(oldIDs); |
1079 | foreach (KeyValuePair<UUID, string> kvp in pstates) | 1541 | foreach (KeyValuePair<UUID, string> kvp in pstates) |
1080 | states.Add(kvp.Key, kvp.Value); | 1542 | states[kvp.Key] = kvp.Value; |
1081 | } | 1543 | } |
1082 | 1544 | ||
1083 | if (states.Count > 0) | 1545 | if (states.Count > 0) |
@@ -1097,6 +1559,169 @@ namespace OpenSim.Region.Framework.Scenes | |||
1097 | } | 1559 | } |
1098 | 1560 | ||
1099 | /// <summary> | 1561 | /// <summary> |
1562 | /// Add the avatar to this linkset (avatar is sat). | ||
1563 | /// </summary> | ||
1564 | /// <param name="agentID"></param> | ||
1565 | public void AddAvatar(UUID agentID) | ||
1566 | { | ||
1567 | ScenePresence presence; | ||
1568 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1569 | { | ||
1570 | if (!m_linkedAvatars.Contains(presence)) | ||
1571 | { | ||
1572 | m_linkedAvatars.Add(presence); | ||
1573 | } | ||
1574 | } | ||
1575 | } | ||
1576 | |||
1577 | /// <summary> | ||
1578 | /// Delete the avatar from this linkset (avatar is unsat). | ||
1579 | /// </summary> | ||
1580 | /// <param name="agentID"></param> | ||
1581 | public void DeleteAvatar(UUID agentID) | ||
1582 | { | ||
1583 | ScenePresence presence; | ||
1584 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1585 | { | ||
1586 | if (m_linkedAvatars.Contains(presence)) | ||
1587 | { | ||
1588 | m_linkedAvatars.Remove(presence); | ||
1589 | } | ||
1590 | } | ||
1591 | } | ||
1592 | |||
1593 | /// <summary> | ||
1594 | /// Returns the list of linked presences (avatars sat on this group) | ||
1595 | /// </summary> | ||
1596 | /// <param name="agentID"></param> | ||
1597 | public List<ScenePresence> GetLinkedAvatars() | ||
1598 | { | ||
1599 | return m_linkedAvatars; | ||
1600 | } | ||
1601 | |||
1602 | /// <summary> | ||
1603 | /// Attach this scene object to the given avatar. | ||
1604 | /// </summary> | ||
1605 | /// <param name="agentID"></param> | ||
1606 | /// <param name="attachmentpoint"></param> | ||
1607 | /// <param name="AttachOffset"></param> | ||
1608 | private void AttachToAgent( | ||
1609 | ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | ||
1610 | { | ||
1611 | if (avatar != null) | ||
1612 | { | ||
1613 | // don't attach attachments to child agents | ||
1614 | if (avatar.IsChildAgent) return; | ||
1615 | |||
1616 | // Remove from database and parcel prim count | ||
1617 | m_scene.DeleteFromStorage(so.UUID); | ||
1618 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1619 | |||
1620 | so.AttachedAvatar = avatar.UUID; | ||
1621 | |||
1622 | if (so.RootPart.PhysActor != null) | ||
1623 | { | ||
1624 | m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); | ||
1625 | so.RootPart.PhysActor = null; | ||
1626 | } | ||
1627 | |||
1628 | so.AbsolutePosition = attachOffset; | ||
1629 | so.RootPart.AttachedPos = attachOffset; | ||
1630 | so.IsAttachment = true; | ||
1631 | so.RootPart.SetParentLocalId(avatar.LocalId); | ||
1632 | so.AttachmentPoint = attachmentpoint; | ||
1633 | |||
1634 | avatar.AddAttachment(this); | ||
1635 | |||
1636 | if (!silent) | ||
1637 | { | ||
1638 | // Killing it here will cause the client to deselect it | ||
1639 | // It then reappears on the avatar, deselected | ||
1640 | // through the full update below | ||
1641 | // | ||
1642 | if (IsSelected) | ||
1643 | { | ||
1644 | m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId }); | ||
1645 | } | ||
1646 | |||
1647 | IsSelected = false; // fudge.... | ||
1648 | ScheduleGroupForFullUpdate(); | ||
1649 | } | ||
1650 | } | ||
1651 | else | ||
1652 | { | ||
1653 | m_log.WarnFormat( | ||
1654 | "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", | ||
1655 | UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName); | ||
1656 | } | ||
1657 | } | ||
1658 | |||
1659 | public byte GetAttachmentPoint() | ||
1660 | { | ||
1661 | return m_rootPart.Shape.State; | ||
1662 | } | ||
1663 | |||
1664 | public void DetachToGround() | ||
1665 | { | ||
1666 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1667 | if (avatar == null) | ||
1668 | return; | ||
1669 | |||
1670 | avatar.RemoveAttachment(this); | ||
1671 | |||
1672 | Vector3 detachedpos = new Vector3(127f,127f,127f); | ||
1673 | if (avatar == null) | ||
1674 | return; | ||
1675 | |||
1676 | detachedpos = avatar.AbsolutePosition; | ||
1677 | FromItemID = UUID.Zero; | ||
1678 | |||
1679 | AbsolutePosition = detachedpos; | ||
1680 | AttachedAvatar = UUID.Zero; | ||
1681 | |||
1682 | //SceneObjectPart[] parts = m_parts.GetArray(); | ||
1683 | //for (int i = 0; i < parts.Length; i++) | ||
1684 | // parts[i].AttachedAvatar = UUID.Zero; | ||
1685 | |||
1686 | m_rootPart.SetParentLocalId(0); | ||
1687 | AttachmentPoint = (byte)0; | ||
1688 | // must check if buildind should be true or false here | ||
1689 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false); | ||
1690 | HasGroupChanged = true; | ||
1691 | RootPart.Rezzed = DateTime.Now; | ||
1692 | RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
1693 | AttachToBackup(); | ||
1694 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1695 | m_rootPart.ScheduleFullUpdate(); | ||
1696 | m_rootPart.ClearUndoState(); | ||
1697 | } | ||
1698 | |||
1699 | public void DetachToInventoryPrep() | ||
1700 | { | ||
1701 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1702 | //Vector3 detachedpos = new Vector3(127f, 127f, 127f); | ||
1703 | if (avatar != null) | ||
1704 | { | ||
1705 | //detachedpos = avatar.AbsolutePosition; | ||
1706 | avatar.RemoveAttachment(this); | ||
1707 | } | ||
1708 | |||
1709 | AttachedAvatar = UUID.Zero; | ||
1710 | |||
1711 | /*SceneObjectPart[] parts = m_parts.GetArray(); | ||
1712 | for (int i = 0; i < parts.Length; i++) | ||
1713 | parts[i].AttachedAvatar = UUID.Zero;*/ | ||
1714 | |||
1715 | m_rootPart.SetParentLocalId(0); | ||
1716 | //m_rootPart.SetAttachmentPoint((byte)0); | ||
1717 | IsAttachment = false; | ||
1718 | AbsolutePosition = m_rootPart.AttachedPos; | ||
1719 | //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); | ||
1720 | //AttachToBackup(); | ||
1721 | //m_rootPart.ScheduleFullUpdate(); | ||
1722 | } | ||
1723 | |||
1724 | /// <summary> | ||
1100 | /// | 1725 | /// |
1101 | /// </summary> | 1726 | /// </summary> |
1102 | /// <param name="part"></param> | 1727 | /// <param name="part"></param> |
@@ -1136,7 +1761,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1136 | public void AddPart(SceneObjectPart part) | 1761 | public void AddPart(SceneObjectPart part) |
1137 | { | 1762 | { |
1138 | part.SetParent(this); | 1763 | part.SetParent(this); |
1139 | part.LinkNum = m_parts.Add(part.UUID, part); | 1764 | m_parts.Add(part.UUID, part); |
1765 | |||
1766 | part.LinkNum = m_parts.Count; | ||
1767 | |||
1140 | if (part.LinkNum == 2) | 1768 | if (part.LinkNum == 2) |
1141 | RootPart.LinkNum = 1; | 1769 | RootPart.LinkNum = 1; |
1142 | } | 1770 | } |
@@ -1162,6 +1790,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1162 | parts[i].UUID = UUID.Random(); | 1790 | parts[i].UUID = UUID.Random(); |
1163 | } | 1791 | } |
1164 | 1792 | ||
1793 | // helper provided for parts. | ||
1794 | public int GetSceneMaxUndo() | ||
1795 | { | ||
1796 | if (m_scene != null) | ||
1797 | return m_scene.MaxUndoCount; | ||
1798 | return 5; | ||
1799 | } | ||
1800 | |||
1165 | // justincc: I don't believe this hack is needed any longer, especially since the physics | 1801 | // justincc: I don't believe this hack is needed any longer, especially since the physics |
1166 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false | 1802 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false |
1167 | // this method was preventing proper reload of scene objects. | 1803 | // this method was preventing proper reload of scene objects. |
@@ -1219,7 +1855,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1219 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", | 1855 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", |
1220 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); | 1856 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); |
1221 | 1857 | ||
1222 | part.StoreUndoState(); | 1858 | // part.StoreUndoState(); |
1223 | part.OnGrab(offsetPos, remoteClient); | 1859 | part.OnGrab(offsetPos, remoteClient); |
1224 | } | 1860 | } |
1225 | 1861 | ||
@@ -1239,6 +1875,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1239 | /// <param name="silent">If true then deletion is not broadcast to clients</param> | 1875 | /// <param name="silent">If true then deletion is not broadcast to clients</param> |
1240 | public void DeleteGroupFromScene(bool silent) | 1876 | public void DeleteGroupFromScene(bool silent) |
1241 | { | 1877 | { |
1878 | // We need to keep track of this state in case this group is still queued for backup. | ||
1879 | IsDeleted = true; | ||
1880 | |||
1881 | DetachFromBackup(); | ||
1882 | |||
1242 | SceneObjectPart[] parts = m_parts.GetArray(); | 1883 | SceneObjectPart[] parts = m_parts.GetArray(); |
1243 | for (int i = 0; i < parts.Length; i++) | 1884 | for (int i = 0; i < parts.Length; i++) |
1244 | { | 1885 | { |
@@ -1262,6 +1903,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1262 | } | 1903 | } |
1263 | }); | 1904 | }); |
1264 | } | 1905 | } |
1906 | |||
1265 | } | 1907 | } |
1266 | 1908 | ||
1267 | public void AddScriptLPS(int count) | 1909 | public void AddScriptLPS(int count) |
@@ -1331,28 +1973,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1331 | /// </summary> | 1973 | /// </summary> |
1332 | public void ApplyPhysics() | 1974 | public void ApplyPhysics() |
1333 | { | 1975 | { |
1334 | // Apply physics to the root prim | ||
1335 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); | ||
1336 | |||
1337 | // Apply physics to child prims | ||
1338 | SceneObjectPart[] parts = m_parts.GetArray(); | 1976 | SceneObjectPart[] parts = m_parts.GetArray(); |
1339 | if (parts.Length > 1) | 1977 | if (parts.Length > 1) |
1340 | { | 1978 | { |
1979 | ResetChildPrimPhysicsPositions(); | ||
1980 | |||
1981 | // Apply physics to the root prim | ||
1982 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true); | ||
1983 | |||
1984 | |||
1341 | for (int i = 0; i < parts.Length; i++) | 1985 | for (int i = 0; i < parts.Length; i++) |
1342 | { | 1986 | { |
1343 | SceneObjectPart part = parts[i]; | 1987 | SceneObjectPart part = parts[i]; |
1344 | if (part.LocalId != m_rootPart.LocalId) | 1988 | if (part.LocalId != m_rootPart.LocalId) |
1345 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); | 1989 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, true); |
1346 | } | 1990 | } |
1347 | |||
1348 | // Hack to get the physics scene geometries in the right spot | 1991 | // Hack to get the physics scene geometries in the right spot |
1349 | ResetChildPrimPhysicsPositions(); | 1992 | // ResetChildPrimPhysicsPositions(); |
1993 | if (m_rootPart.PhysActor != null) | ||
1994 | { | ||
1995 | m_rootPart.PhysActor.Building = false; | ||
1996 | } | ||
1997 | } | ||
1998 | else | ||
1999 | { | ||
2000 | // Apply physics to the root prim | ||
2001 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); | ||
1350 | } | 2002 | } |
1351 | } | 2003 | } |
1352 | 2004 | ||
1353 | public void SetOwnerId(UUID userId) | 2005 | public void SetOwnerId(UUID userId) |
1354 | { | 2006 | { |
1355 | ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); | 2007 | ForEachPart(delegate(SceneObjectPart part) |
2008 | { | ||
2009 | |||
2010 | part.OwnerID = userId; | ||
2011 | |||
2012 | }); | ||
1356 | } | 2013 | } |
1357 | 2014 | ||
1358 | public void ForEachPart(Action<SceneObjectPart> whatToDo) | 2015 | public void ForEachPart(Action<SceneObjectPart> whatToDo) |
@@ -1384,11 +2041,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1384 | return; | 2041 | return; |
1385 | } | 2042 | } |
1386 | 2043 | ||
2044 | if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | ||
2045 | return; | ||
2046 | |||
1387 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let | 2047 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let |
1388 | // any exception propogate upwards. | 2048 | // any exception propogate upwards. |
1389 | try | 2049 | try |
1390 | { | 2050 | { |
1391 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart | 2051 | if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart |
2052 | !m_scene.LoginsEnabled || // We're starting up or doing maintenance, don't mess with things | ||
2053 | m_scene.LoadingPrims) // Land may not be valid yet | ||
2054 | |||
1392 | { | 2055 | { |
1393 | ILandObject parcel = m_scene.LandChannel.GetLandObject( | 2056 | ILandObject parcel = m_scene.LandChannel.GetLandObject( |
1394 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); | 2057 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); |
@@ -1415,6 +2078,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1415 | } | 2078 | } |
1416 | } | 2079 | } |
1417 | } | 2080 | } |
2081 | |||
1418 | } | 2082 | } |
1419 | 2083 | ||
1420 | if (m_scene.UseBackup && HasGroupChanged) | 2084 | if (m_scene.UseBackup && HasGroupChanged) |
@@ -1422,10 +2086,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1422 | // don't backup while it's selected or you're asking for changes mid stream. | 2086 | // don't backup while it's selected or you're asking for changes mid stream. |
1423 | if (isTimeToPersist() || forcedBackup) | 2087 | if (isTimeToPersist() || forcedBackup) |
1424 | { | 2088 | { |
2089 | if (m_rootPart.PhysActor != null && | ||
2090 | (!m_rootPart.PhysActor.IsPhysical)) | ||
2091 | { | ||
2092 | // Possible ghost prim | ||
2093 | if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) | ||
2094 | { | ||
2095 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
2096 | { | ||
2097 | // Re-set physics actor positions and | ||
2098 | // orientations | ||
2099 | part.GroupPosition = m_rootPart.GroupPosition; | ||
2100 | } | ||
2101 | } | ||
2102 | } | ||
1425 | // m_log.DebugFormat( | 2103 | // m_log.DebugFormat( |
1426 | // "[SCENE]: Storing {0}, {1} in {2}", | 2104 | // "[SCENE]: Storing {0}, {1} in {2}", |
1427 | // Name, UUID, m_scene.RegionInfo.RegionName); | 2105 | // Name, UUID, m_scene.RegionInfo.RegionName); |
1428 | 2106 | ||
2107 | if (RootPart.Shape.PCode == 9 && RootPart.Shape.State != 0) | ||
2108 | { | ||
2109 | RootPart.Shape.State = 0; | ||
2110 | ScheduleGroupForFullUpdate(); | ||
2111 | } | ||
2112 | |||
1429 | SceneObjectGroup backup_group = Copy(false); | 2113 | SceneObjectGroup backup_group = Copy(false); |
1430 | backup_group.RootPart.Velocity = RootPart.Velocity; | 2114 | backup_group.RootPart.Velocity = RootPart.Velocity; |
1431 | backup_group.RootPart.Acceleration = RootPart.Acceleration; | 2115 | backup_group.RootPart.Acceleration = RootPart.Acceleration; |
@@ -1435,6 +2119,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1435 | HasGroupChangedDueToDelink = false; | 2119 | HasGroupChangedDueToDelink = false; |
1436 | 2120 | ||
1437 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); | 2121 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); |
2122 | /* | ||
2123 | backup_group.ForEachPart(delegate(SceneObjectPart part) | ||
2124 | { | ||
2125 | if (part.KeyframeMotion != null) | ||
2126 | { | ||
2127 | part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); | ||
2128 | // part.KeyframeMotion.UpdateSceneObject(this); | ||
2129 | } | ||
2130 | }); | ||
2131 | */ | ||
1438 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); | 2132 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); |
1439 | 2133 | ||
1440 | backup_group.ForEachPart(delegate(SceneObjectPart part) | 2134 | backup_group.ForEachPart(delegate(SceneObjectPart part) |
@@ -1491,10 +2185,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1491 | /// <returns></returns> | 2185 | /// <returns></returns> |
1492 | public SceneObjectGroup Copy(bool userExposed) | 2186 | public SceneObjectGroup Copy(bool userExposed) |
1493 | { | 2187 | { |
2188 | m_dupeInProgress = true; | ||
1494 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); | 2189 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); |
1495 | dupe.m_isBackedUp = false; | 2190 | dupe.m_isBackedUp = false; |
1496 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); | 2191 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); |
1497 | 2192 | ||
2193 | // new group as no sitting avatars | ||
2194 | dupe.m_linkedAvatars = new List<ScenePresence>(); | ||
2195 | |||
1498 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of | 2196 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of |
1499 | // attachments do not bordercross while they're being duplicated. This is hacktastic! | 2197 | // attachments do not bordercross while they're being duplicated. This is hacktastic! |
1500 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! | 2198 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! |
@@ -1505,7 +2203,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1505 | // This is only necessary when userExposed is false! | 2203 | // This is only necessary when userExposed is false! |
1506 | 2204 | ||
1507 | bool previousAttachmentStatus = dupe.IsAttachment; | 2205 | bool previousAttachmentStatus = dupe.IsAttachment; |
1508 | 2206 | ||
1509 | if (!userExposed) | 2207 | if (!userExposed) |
1510 | dupe.IsAttachment = true; | 2208 | dupe.IsAttachment = true; |
1511 | 2209 | ||
@@ -1518,16 +2216,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1518 | 2216 | ||
1519 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); | 2217 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); |
1520 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; | 2218 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; |
2219 | |||
1521 | 2220 | ||
1522 | if (userExposed) | 2221 | if (userExposed) |
1523 | dupe.m_rootPart.TrimPermissions(); | 2222 | dupe.m_rootPart.TrimPermissions(); |
1524 | 2223 | ||
1525 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); | 2224 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); |
1526 | 2225 | ||
1527 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | 2226 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) |
1528 | { | 2227 | { |
1529 | return p1.LinkNum.CompareTo(p2.LinkNum); | 2228 | return p1.LinkNum.CompareTo(p2.LinkNum); |
1530 | } | 2229 | } |
1531 | ); | 2230 | ); |
1532 | 2231 | ||
1533 | foreach (SceneObjectPart part in partList) | 2232 | foreach (SceneObjectPart part in partList) |
@@ -1537,43 +2236,56 @@ namespace OpenSim.Region.Framework.Scenes | |||
1537 | { | 2236 | { |
1538 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); | 2237 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); |
1539 | newPart.LinkNum = part.LinkNum; | 2238 | newPart.LinkNum = part.LinkNum; |
1540 | } | 2239 | if (userExposed) |
2240 | newPart.ParentID = dupe.m_rootPart.LocalId; | ||
2241 | } | ||
1541 | else | 2242 | else |
1542 | { | 2243 | { |
1543 | newPart = dupe.m_rootPart; | 2244 | newPart = dupe.m_rootPart; |
1544 | } | 2245 | } |
2246 | /* | ||
2247 | bool isphys = ((newPart.Flags & PrimFlags.Physics) != 0); | ||
2248 | bool isphan = ((newPart.Flags & PrimFlags.Phantom) != 0); | ||
1545 | 2249 | ||
1546 | // Need to duplicate the physics actor as well | 2250 | // Need to duplicate the physics actor as well |
1547 | PhysicsActor originalPartPa = part.PhysActor; | 2251 | if (userExposed && (isphys || !isphan || newPart.VolumeDetectActive)) |
1548 | if (originalPartPa != null && userExposed) | ||
1549 | { | 2252 | { |
1550 | PrimitiveBaseShape pbs = newPart.Shape; | 2253 | PrimitiveBaseShape pbs = newPart.Shape; |
1551 | |||
1552 | newPart.PhysActor | 2254 | newPart.PhysActor |
1553 | = m_scene.PhysicsScene.AddPrimShape( | 2255 | = m_scene.PhysicsScene.AddPrimShape( |
1554 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), | 2256 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), |
1555 | pbs, | 2257 | pbs, |
1556 | newPart.AbsolutePosition, | 2258 | newPart.AbsolutePosition, |
1557 | newPart.Scale, | 2259 | newPart.Scale, |
1558 | newPart.RotationOffset, | 2260 | newPart.GetWorldRotation(), |
1559 | originalPartPa.IsPhysical, | 2261 | isphys, |
2262 | isphan, | ||
1560 | newPart.LocalId); | 2263 | newPart.LocalId); |
1561 | 2264 | ||
1562 | newPart.DoPhysicsPropertyUpdate(originalPartPa.IsPhysical, true); | 2265 | newPart.DoPhysicsPropertyUpdate(isphys, true); |
1563 | } | 2266 | */ |
2267 | if (userExposed) | ||
2268 | newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true); | ||
2269 | // } | ||
2270 | // copy keyframemotion | ||
1564 | if (part.KeyframeMotion != null) | 2271 | if (part.KeyframeMotion != null) |
1565 | newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); | 2272 | newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); |
1566 | } | 2273 | } |
1567 | 2274 | ||
1568 | if (userExposed) | 2275 | if (userExposed) |
1569 | { | 2276 | { |
1570 | dupe.UpdateParentIDs(); | 2277 | // done above dupe.UpdateParentIDs(); |
2278 | |||
2279 | if (dupe.m_rootPart.PhysActor != null) | ||
2280 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building | ||
2281 | |||
1571 | dupe.HasGroupChanged = true; | 2282 | dupe.HasGroupChanged = true; |
1572 | dupe.AttachToBackup(); | 2283 | dupe.AttachToBackup(); |
1573 | 2284 | ||
1574 | ScheduleGroupForFullUpdate(); | 2285 | ScheduleGroupForFullUpdate(); |
1575 | } | 2286 | } |
1576 | 2287 | ||
2288 | m_dupeInProgress = false; | ||
1577 | return dupe; | 2289 | return dupe; |
1578 | } | 2290 | } |
1579 | 2291 | ||
@@ -1585,7 +2297,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1585 | /// <param name="cGroupID"></param> | 2297 | /// <param name="cGroupID"></param> |
1586 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2298 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1587 | { | 2299 | { |
1588 | SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); | 2300 | // SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); |
2301 | // give newpart a new local ID lettng old part keep same | ||
2302 | SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed); | ||
2303 | newpart.LocalId = m_scene.AllocateLocalId(); | ||
2304 | |||
2305 | SetRootPart(newpart); | ||
2306 | if (userExposed) | ||
2307 | RootPart.Velocity = Vector3.Zero; // In case source is moving | ||
1589 | } | 2308 | } |
1590 | 2309 | ||
1591 | public void ScriptSetPhysicsStatus(bool usePhysics) | 2310 | public void ScriptSetPhysicsStatus(bool usePhysics) |
@@ -1643,27 +2362,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1643 | 2362 | ||
1644 | if (pa != null) | 2363 | if (pa != null) |
1645 | { | 2364 | { |
1646 | pa.AddForce(impulse, true); | 2365 | // false to be applied as a impulse |
1647 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2366 | pa.AddForce(impulse, false); |
1648 | } | ||
1649 | } | ||
1650 | } | ||
1651 | |||
1652 | public void applyAngularImpulse(Vector3 impulse) | ||
1653 | { | ||
1654 | PhysicsActor pa = RootPart.PhysActor; | ||
1655 | |||
1656 | if (pa != null) | ||
1657 | { | ||
1658 | if (!IsAttachment) | ||
1659 | { | ||
1660 | pa.AddAngularForce(impulse, true); | ||
1661 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2367 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1662 | } | 2368 | } |
1663 | } | 2369 | } |
1664 | } | 2370 | } |
1665 | 2371 | ||
1666 | public void setAngularImpulse(Vector3 impulse) | 2372 | public void ApplyAngularImpulse(Vector3 impulse) |
1667 | { | 2373 | { |
1668 | PhysicsActor pa = RootPart.PhysActor; | 2374 | PhysicsActor pa = RootPart.PhysActor; |
1669 | 2375 | ||
@@ -1671,7 +2377,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1671 | { | 2377 | { |
1672 | if (!IsAttachment) | 2378 | if (!IsAttachment) |
1673 | { | 2379 | { |
1674 | pa.Torque = impulse; | 2380 | // false to be applied as a impulse |
2381 | pa.AddAngularForce(impulse, false); | ||
1675 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2382 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1676 | } | 2383 | } |
1677 | } | 2384 | } |
@@ -1679,20 +2386,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1679 | 2386 | ||
1680 | public Vector3 GetTorque() | 2387 | public Vector3 GetTorque() |
1681 | { | 2388 | { |
1682 | PhysicsActor pa = RootPart.PhysActor; | 2389 | return RootPart.Torque; |
1683 | |||
1684 | if (pa != null) | ||
1685 | { | ||
1686 | if (!IsAttachment) | ||
1687 | { | ||
1688 | Vector3 torque = pa.Torque; | ||
1689 | return torque; | ||
1690 | } | ||
1691 | } | ||
1692 | |||
1693 | return Vector3.Zero; | ||
1694 | } | 2390 | } |
1695 | 2391 | ||
2392 | // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object | ||
1696 | public void moveToTarget(Vector3 target, float tau) | 2393 | public void moveToTarget(Vector3 target, float tau) |
1697 | { | 2394 | { |
1698 | if (IsAttachment) | 2395 | if (IsAttachment) |
@@ -1722,8 +2419,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
1722 | 2419 | ||
1723 | if (pa != null) | 2420 | if (pa != null) |
1724 | pa.PIDActive = false; | 2421 | pa.PIDActive = false; |
2422 | |||
2423 | RootPart.ScheduleTerseUpdate(); // send a stop information | ||
2424 | } | ||
2425 | |||
2426 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2427 | { | ||
2428 | SceneObjectPart rootpart = m_rootPart; | ||
2429 | if (rootpart != null) | ||
2430 | { | ||
2431 | if (IsAttachment) | ||
2432 | { | ||
2433 | /* | ||
2434 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
2435 | if (avatar != null) | ||
2436 | { | ||
2437 | Rotate the Av? | ||
2438 | } */ | ||
2439 | } | ||
2440 | else | ||
2441 | { | ||
2442 | if (rootpart.PhysActor != null) | ||
2443 | { // APID must be implemented in your physics system for this to function. | ||
2444 | rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); | ||
2445 | rootpart.PhysActor.APIDStrength = strength; | ||
2446 | rootpart.PhysActor.APIDDamping = damping; | ||
2447 | rootpart.PhysActor.APIDActive = true; | ||
2448 | } | ||
2449 | } | ||
2450 | } | ||
1725 | } | 2451 | } |
2452 | |||
2453 | public void stopLookAt() | ||
2454 | { | ||
2455 | SceneObjectPart rootpart = m_rootPart; | ||
2456 | if (rootpart != null) | ||
2457 | { | ||
2458 | if (rootpart.PhysActor != null) | ||
2459 | { // APID must be implemented in your physics system for this to function. | ||
2460 | rootpart.PhysActor.APIDActive = false; | ||
2461 | } | ||
2462 | } | ||
1726 | 2463 | ||
2464 | } | ||
2465 | |||
1727 | /// <summary> | 2466 | /// <summary> |
1728 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. | 2467 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. |
1729 | /// </summary> | 2468 | /// </summary> |
@@ -1740,7 +2479,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1740 | { | 2479 | { |
1741 | pa.PIDHoverHeight = height; | 2480 | pa.PIDHoverHeight = height; |
1742 | pa.PIDHoverType = hoverType; | 2481 | pa.PIDHoverType = hoverType; |
1743 | pa.PIDTau = tau; | 2482 | pa.PIDHoverTau = tau; |
1744 | pa.PIDHoverActive = true; | 2483 | pa.PIDHoverActive = true; |
1745 | } | 2484 | } |
1746 | else | 2485 | else |
@@ -1780,7 +2519,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1780 | /// <param name="cGroupID"></param> | 2519 | /// <param name="cGroupID"></param> |
1781 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2520 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1782 | { | 2521 | { |
1783 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | 2522 | // give new ID to the new part, letting old keep original |
2523 | // SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | ||
2524 | SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); | ||
2525 | newPart.LocalId = m_scene.AllocateLocalId(); | ||
2526 | newPart.SetParent(this); | ||
2527 | |||
1784 | AddPart(newPart); | 2528 | AddPart(newPart); |
1785 | 2529 | ||
1786 | SetPartAsNonRoot(newPart); | 2530 | SetPartAsNonRoot(newPart); |
@@ -1830,6 +2574,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1830 | 2574 | ||
1831 | #endregion | 2575 | #endregion |
1832 | 2576 | ||
2577 | |||
1833 | public override void Update() | 2578 | public override void Update() |
1834 | { | 2579 | { |
1835 | // Check that the group was not deleted before the scheduled update | 2580 | // Check that the group was not deleted before the scheduled update |
@@ -1848,19 +2593,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1848 | // check to see if the physical position or rotation warrant an update. | 2593 | // check to see if the physical position or rotation warrant an update. |
1849 | if (m_rootPart.UpdateFlag == UpdateRequired.NONE) | 2594 | if (m_rootPart.UpdateFlag == UpdateRequired.NONE) |
1850 | { | 2595 | { |
1851 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); | 2596 | // rootpart SendScheduledUpdates will check if a update is needed |
1852 | 2597 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | |
1853 | if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) | ||
1854 | { | ||
1855 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | ||
1856 | lastPhysGroupPos = AbsolutePosition; | ||
1857 | } | ||
1858 | |||
1859 | if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) | ||
1860 | { | ||
1861 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | ||
1862 | lastPhysGroupRot = GroupRotation; | ||
1863 | } | ||
1864 | } | 2598 | } |
1865 | 2599 | ||
1866 | SceneObjectPart[] parts = m_parts.GetArray(); | 2600 | SceneObjectPart[] parts = m_parts.GetArray(); |
@@ -1919,11 +2653,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1919 | /// Immediately send a full update for this scene object. | 2653 | /// Immediately send a full update for this scene object. |
1920 | /// </summary> | 2654 | /// </summary> |
1921 | public void SendGroupFullUpdate() | 2655 | public void SendGroupFullUpdate() |
1922 | { | 2656 | { |
1923 | if (IsDeleted) | 2657 | if (IsDeleted) |
1924 | return; | 2658 | return; |
1925 | 2659 | ||
1926 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); | 2660 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); |
1927 | 2661 | ||
1928 | RootPart.SendFullUpdateToAllClients(); | 2662 | RootPart.SendFullUpdateToAllClients(); |
1929 | 2663 | ||
@@ -2079,6 +2813,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2079 | // 'linkPart' == the root of the group being linked into this group | 2813 | // 'linkPart' == the root of the group being linked into this group |
2080 | SceneObjectPart linkPart = objectGroup.m_rootPart; | 2814 | SceneObjectPart linkPart = objectGroup.m_rootPart; |
2081 | 2815 | ||
2816 | if (m_rootPart.PhysActor != null) | ||
2817 | m_rootPart.PhysActor.Building = true; | ||
2818 | if (linkPart.PhysActor != null) | ||
2819 | linkPart.PhysActor.Building = true; | ||
2820 | |||
2082 | // physics flags from group to be applied to linked parts | 2821 | // physics flags from group to be applied to linked parts |
2083 | bool grpusephys = UsesPhysics; | 2822 | bool grpusephys = UsesPhysics; |
2084 | bool grptemporary = IsTemporary; | 2823 | bool grptemporary = IsTemporary; |
@@ -2104,12 +2843,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2104 | Vector3 axPos = linkPart.OffsetPosition; | 2843 | Vector3 axPos = linkPart.OffsetPosition; |
2105 | // Rotate the linking root SOP's position to be relative to the new root prim | 2844 | // Rotate the linking root SOP's position to be relative to the new root prim |
2106 | Quaternion parentRot = m_rootPart.RotationOffset; | 2845 | Quaternion parentRot = m_rootPart.RotationOffset; |
2107 | axPos *= Quaternion.Inverse(parentRot); | 2846 | axPos *= Quaternion.Conjugate(parentRot); |
2108 | linkPart.OffsetPosition = axPos; | 2847 | linkPart.OffsetPosition = axPos; |
2109 | 2848 | ||
2110 | // Make the linking root SOP's rotation relative to the new root prim | 2849 | // Make the linking root SOP's rotation relative to the new root prim |
2111 | Quaternion oldRot = linkPart.RotationOffset; | 2850 | Quaternion oldRot = linkPart.RotationOffset; |
2112 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 2851 | Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; |
2113 | linkPart.RotationOffset = newRot; | 2852 | linkPart.RotationOffset = newRot; |
2114 | 2853 | ||
2115 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. | 2854 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. |
@@ -2143,7 +2882,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2143 | linkPart.CreateSelected = true; | 2882 | linkPart.CreateSelected = true; |
2144 | 2883 | ||
2145 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now | 2884 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now |
2146 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive); | 2885 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); |
2147 | 2886 | ||
2148 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 2887 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2149 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2888 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2153,6 +2892,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2153 | } | 2892 | } |
2154 | 2893 | ||
2155 | linkPart.LinkNum = linkNum++; | 2894 | linkPart.LinkNum = linkNum++; |
2895 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2156 | 2896 | ||
2157 | // Get a list of the SOP's in the old group in order of their linknum's. | 2897 | // Get a list of the SOP's in the old group in order of their linknum's. |
2158 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2898 | SceneObjectPart[] ogParts = objectGroup.Parts; |
@@ -2171,7 +2911,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2171 | 2911 | ||
2172 | // Update the physics flags for the newly added SOP | 2912 | // Update the physics flags for the newly added SOP |
2173 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) | 2913 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) |
2174 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive); | 2914 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); |
2175 | 2915 | ||
2176 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 2916 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2177 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2917 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2189,7 +2929,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2189 | objectGroup.IsDeleted = true; | 2929 | objectGroup.IsDeleted = true; |
2190 | 2930 | ||
2191 | objectGroup.m_parts.Clear(); | 2931 | objectGroup.m_parts.Clear(); |
2192 | 2932 | ||
2193 | // Can't do this yet since backup still makes use of the root part without any synchronization | 2933 | // Can't do this yet since backup still makes use of the root part without any synchronization |
2194 | // objectGroup.m_rootPart = null; | 2934 | // objectGroup.m_rootPart = null; |
2195 | 2935 | ||
@@ -2203,6 +2943,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2203 | // unmoved prims! | 2943 | // unmoved prims! |
2204 | ResetChildPrimPhysicsPositions(); | 2944 | ResetChildPrimPhysicsPositions(); |
2205 | 2945 | ||
2946 | if (m_rootPart.PhysActor != null) | ||
2947 | m_rootPart.PhysActor.Building = false; | ||
2948 | |||
2206 | //HasGroupChanged = true; | 2949 | //HasGroupChanged = true; |
2207 | //ScheduleGroupForFullUpdate(); | 2950 | //ScheduleGroupForFullUpdate(); |
2208 | } | 2951 | } |
@@ -2270,7 +3013,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2270 | // m_log.DebugFormat( | 3013 | // m_log.DebugFormat( |
2271 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", | 3014 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", |
2272 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); | 3015 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); |
2273 | 3016 | ||
3017 | if (m_rootPart.PhysActor != null) | ||
3018 | m_rootPart.PhysActor.Building = true; | ||
3019 | |||
2274 | linkPart.ClearUndoState(); | 3020 | linkPart.ClearUndoState(); |
2275 | 3021 | ||
2276 | Vector3 worldPos = linkPart.GetWorldPosition(); | 3022 | Vector3 worldPos = linkPart.GetWorldPosition(); |
@@ -2341,6 +3087,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2341 | 3087 | ||
2342 | // When we delete a group, we currently have to force persist to the database if the object id has changed | 3088 | // When we delete a group, we currently have to force persist to the database if the object id has changed |
2343 | // (since delete works by deleting all rows which have a given object id) | 3089 | // (since delete works by deleting all rows which have a given object id) |
3090 | |||
3091 | // this is as it seems to be in sl now | ||
3092 | if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none) | ||
3093 | linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now | ||
3094 | |||
3095 | if (m_rootPart.PhysActor != null) | ||
3096 | m_rootPart.PhysActor.Building = false; | ||
3097 | |||
2344 | objectGroup.HasGroupChangedDueToDelink = true; | 3098 | objectGroup.HasGroupChangedDueToDelink = true; |
2345 | 3099 | ||
2346 | return objectGroup; | 3100 | return objectGroup; |
@@ -2352,6 +3106,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2352 | /// <param name="objectGroup"></param> | 3106 | /// <param name="objectGroup"></param> |
2353 | public virtual void DetachFromBackup() | 3107 | public virtual void DetachFromBackup() |
2354 | { | 3108 | { |
3109 | if (m_scene != null) | ||
3110 | m_scene.SceneGraph.FireDetachFromBackup(this); | ||
2355 | if (m_isBackedUp && Scene != null) | 3111 | if (m_isBackedUp && Scene != null) |
2356 | m_scene.EventManager.OnBackup -= ProcessBackup; | 3112 | m_scene.EventManager.OnBackup -= ProcessBackup; |
2357 | 3113 | ||
@@ -2372,7 +3128,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2372 | Vector3 axPos = part.OffsetPosition; | 3128 | Vector3 axPos = part.OffsetPosition; |
2373 | axPos *= parentRot; | 3129 | axPos *= parentRot; |
2374 | part.OffsetPosition = axPos; | 3130 | part.OffsetPosition = axPos; |
2375 | part.GroupPosition = oldGroupPosition + part.OffsetPosition; | 3131 | Vector3 newPos = oldGroupPosition + part.OffsetPosition; |
3132 | part.GroupPosition = newPos; | ||
2376 | part.OffsetPosition = Vector3.Zero; | 3133 | part.OffsetPosition = Vector3.Zero; |
2377 | 3134 | ||
2378 | // Compution our rotation to be not relative to the old parent | 3135 | // Compution our rotation to be not relative to the old parent |
@@ -2387,7 +3144,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2387 | part.LinkNum = linkNum; | 3144 | part.LinkNum = linkNum; |
2388 | 3145 | ||
2389 | // Compute the new position of this SOP relative to the group position | 3146 | // Compute the new position of this SOP relative to the group position |
2390 | part.OffsetPosition = part.GroupPosition - AbsolutePosition; | 3147 | part.OffsetPosition = newPos - AbsolutePosition; |
2391 | 3148 | ||
2392 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. | 3149 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. |
2393 | // It would have the affect of setting the physics engine position multiple | 3150 | // It would have the affect of setting the physics engine position multiple |
@@ -2397,18 +3154,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2397 | // Rotate the relative position by the rotation of the group | 3154 | // Rotate the relative position by the rotation of the group |
2398 | Quaternion rootRotation = m_rootPart.RotationOffset; | 3155 | Quaternion rootRotation = m_rootPart.RotationOffset; |
2399 | Vector3 pos = part.OffsetPosition; | 3156 | Vector3 pos = part.OffsetPosition; |
2400 | pos *= Quaternion.Inverse(rootRotation); | 3157 | pos *= Quaternion.Conjugate(rootRotation); |
2401 | part.OffsetPosition = pos; | 3158 | part.OffsetPosition = pos; |
2402 | 3159 | ||
2403 | // Compute the SOP's rotation relative to the rotation of the group. | 3160 | // Compute the SOP's rotation relative to the rotation of the group. |
2404 | parentRot = m_rootPart.RotationOffset; | 3161 | parentRot = m_rootPart.RotationOffset; |
2405 | oldRot = part.RotationOffset; | 3162 | oldRot = part.RotationOffset; |
2406 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 3163 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
2407 | part.RotationOffset = newRot; | 3164 | part.RotationOffset = newRot; |
2408 | 3165 | ||
2409 | // Since this SOP's state has changed, push those changes into the physics engine | 3166 | // Since this SOP's state has changed, push those changes into the physics engine |
2410 | // and the simulator. | 3167 | // and the simulator. |
2411 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 3168 | // done on caller |
3169 | // part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2412 | } | 3170 | } |
2413 | 3171 | ||
2414 | /// <summary> | 3172 | /// <summary> |
@@ -2430,10 +3188,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2430 | { | 3188 | { |
2431 | if (!m_rootPart.BlockGrab) | 3189 | if (!m_rootPart.BlockGrab) |
2432 | { | 3190 | { |
2433 | Vector3 llmoveforce = pos - AbsolutePosition; | 3191 | /* Vector3 llmoveforce = pos - AbsolutePosition; |
2434 | Vector3 grabforce = llmoveforce; | 3192 | Vector3 grabforce = llmoveforce; |
2435 | grabforce = (grabforce / 10) * pa.Mass; | 3193 | grabforce = (grabforce / 10) * pa.Mass; |
2436 | pa.AddForce(grabforce, true); | 3194 | */ |
3195 | // empirically convert distance diference to a impulse | ||
3196 | Vector3 grabforce = pos - AbsolutePosition; | ||
3197 | grabforce = grabforce * (pa.Mass/ 10.0f); | ||
3198 | pa.AddForce(grabforce, false); | ||
2437 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 3199 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
2438 | } | 3200 | } |
2439 | } | 3201 | } |
@@ -2629,6 +3391,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2629 | /// <param name="SetVolumeDetect"></param> | 3391 | /// <param name="SetVolumeDetect"></param> |
2630 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) | 3392 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) |
2631 | { | 3393 | { |
3394 | HasGroupChanged = true; | ||
3395 | |||
2632 | SceneObjectPart selectionPart = GetPart(localID); | 3396 | SceneObjectPart selectionPart = GetPart(localID); |
2633 | 3397 | ||
2634 | if (SetTemporary && Scene != null) | 3398 | if (SetTemporary && Scene != null) |
@@ -2659,8 +3423,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2659 | } | 3423 | } |
2660 | } | 3424 | } |
2661 | 3425 | ||
2662 | for (int i = 0; i < parts.Length; i++) | 3426 | if (parts.Length > 1) |
2663 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); | 3427 | { |
3428 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3429 | |||
3430 | for (int i = 0; i < parts.Length; i++) | ||
3431 | { | ||
3432 | |||
3433 | if (parts[i].UUID != m_rootPart.UUID) | ||
3434 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3435 | } | ||
3436 | |||
3437 | if (m_rootPart.PhysActor != null) | ||
3438 | m_rootPart.PhysActor.Building = false; | ||
3439 | } | ||
3440 | else | ||
3441 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); | ||
2664 | } | 3442 | } |
2665 | } | 3443 | } |
2666 | 3444 | ||
@@ -2673,6 +3451,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2673 | } | 3451 | } |
2674 | } | 3452 | } |
2675 | 3453 | ||
3454 | |||
3455 | |||
3456 | /// <summary> | ||
3457 | /// Gets the number of parts | ||
3458 | /// </summary> | ||
3459 | /// <returns></returns> | ||
3460 | public int GetPartCount() | ||
3461 | { | ||
3462 | return Parts.Count(); | ||
3463 | } | ||
3464 | |||
2676 | /// <summary> | 3465 | /// <summary> |
2677 | /// Update the texture entry for this part | 3466 | /// Update the texture entry for this part |
2678 | /// </summary> | 3467 | /// </summary> |
@@ -2710,8 +3499,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2710 | { | 3499 | { |
2711 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); | 3500 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); |
2712 | 3501 | ||
3502 | bool god = Scene.Permissions.IsGod(AgentID); | ||
3503 | |||
3504 | if (field == 1 && god) | ||
3505 | { | ||
3506 | ForEachPart(part => | ||
3507 | { | ||
3508 | part.BaseMask = RootPart.BaseMask; | ||
3509 | }); | ||
3510 | } | ||
3511 | |||
2713 | AdjustChildPrimPermissions(); | 3512 | AdjustChildPrimPermissions(); |
2714 | 3513 | ||
3514 | if (field == 1 && god) // Base mask was set. Update all child part inventories | ||
3515 | { | ||
3516 | foreach (SceneObjectPart part in Parts) | ||
3517 | part.Inventory.ApplyGodPermissions(RootPart.BaseMask); | ||
3518 | } | ||
3519 | |||
2715 | HasGroupChanged = true; | 3520 | HasGroupChanged = true; |
2716 | 3521 | ||
2717 | // Send the group's properties to all clients once all parts are updated | 3522 | // Send the group's properties to all clients once all parts are updated |
@@ -2757,8 +3562,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2757 | 3562 | ||
2758 | PhysicsActor pa = m_rootPart.PhysActor; | 3563 | PhysicsActor pa = m_rootPart.PhysActor; |
2759 | 3564 | ||
2760 | RootPart.StoreUndoState(true); | ||
2761 | |||
2762 | if (Scene != null) | 3565 | if (Scene != null) |
2763 | { | 3566 | { |
2764 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); | 3567 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); |
@@ -2786,7 +3589,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2786 | SceneObjectPart obPart = parts[i]; | 3589 | SceneObjectPart obPart = parts[i]; |
2787 | if (obPart.UUID != m_rootPart.UUID) | 3590 | if (obPart.UUID != m_rootPart.UUID) |
2788 | { | 3591 | { |
2789 | // obPart.IgnoreUndoUpdate = true; | ||
2790 | Vector3 oldSize = new Vector3(obPart.Scale); | 3592 | Vector3 oldSize = new Vector3(obPart.Scale); |
2791 | 3593 | ||
2792 | float f = 1.0f; | 3594 | float f = 1.0f; |
@@ -2898,8 +3700,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2898 | z *= a; | 3700 | z *= a; |
2899 | } | 3701 | } |
2900 | } | 3702 | } |
2901 | |||
2902 | // obPart.IgnoreUndoUpdate = false; | ||
2903 | } | 3703 | } |
2904 | } | 3704 | } |
2905 | } | 3705 | } |
@@ -2909,9 +3709,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2909 | prevScale.Y *= y; | 3709 | prevScale.Y *= y; |
2910 | prevScale.Z *= z; | 3710 | prevScale.Z *= z; |
2911 | 3711 | ||
2912 | // RootPart.IgnoreUndoUpdate = true; | ||
2913 | RootPart.Resize(prevScale); | 3712 | RootPart.Resize(prevScale); |
2914 | // RootPart.IgnoreUndoUpdate = false; | ||
2915 | 3713 | ||
2916 | for (int i = 0; i < parts.Length; i++) | 3714 | for (int i = 0; i < parts.Length; i++) |
2917 | { | 3715 | { |
@@ -2919,8 +3717,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2919 | 3717 | ||
2920 | if (obPart.UUID != m_rootPart.UUID) | 3718 | if (obPart.UUID != m_rootPart.UUID) |
2921 | { | 3719 | { |
2922 | obPart.IgnoreUndoUpdate = true; | ||
2923 | |||
2924 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); | 3720 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); |
2925 | currentpos.X *= x; | 3721 | currentpos.X *= x; |
2926 | currentpos.Y *= y; | 3722 | currentpos.Y *= y; |
@@ -2933,16 +3729,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2933 | 3729 | ||
2934 | obPart.Resize(newSize); | 3730 | obPart.Resize(newSize); |
2935 | obPart.UpdateOffSet(currentpos); | 3731 | obPart.UpdateOffSet(currentpos); |
2936 | |||
2937 | obPart.IgnoreUndoUpdate = false; | ||
2938 | } | 3732 | } |
2939 | 3733 | ||
2940 | // obPart.IgnoreUndoUpdate = false; | 3734 | HasGroupChanged = true; |
2941 | // obPart.StoreUndoState(); | 3735 | m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); |
3736 | ScheduleGroupForTerseUpdate(); | ||
2942 | } | 3737 | } |
2943 | |||
2944 | // m_log.DebugFormat( | ||
2945 | // "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); | ||
2946 | } | 3738 | } |
2947 | 3739 | ||
2948 | #endregion | 3740 | #endregion |
@@ -2955,14 +3747,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2955 | /// <param name="pos"></param> | 3747 | /// <param name="pos"></param> |
2956 | public void UpdateGroupPosition(Vector3 pos) | 3748 | public void UpdateGroupPosition(Vector3 pos) |
2957 | { | 3749 | { |
2958 | // m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); | ||
2959 | |||
2960 | RootPart.StoreUndoState(true); | ||
2961 | |||
2962 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2963 | // for (int i = 0; i < parts.Length; i++) | ||
2964 | // parts[i].StoreUndoState(); | ||
2965 | |||
2966 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 3750 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
2967 | { | 3751 | { |
2968 | if (IsAttachment) | 3752 | if (IsAttachment) |
@@ -2995,21 +3779,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2995 | /// </summary> | 3779 | /// </summary> |
2996 | /// <param name="pos"></param> | 3780 | /// <param name="pos"></param> |
2997 | /// <param name="localID"></param> | 3781 | /// <param name="localID"></param> |
3782 | /// | ||
3783 | |||
2998 | public void UpdateSinglePosition(Vector3 pos, uint localID) | 3784 | public void UpdateSinglePosition(Vector3 pos, uint localID) |
2999 | { | 3785 | { |
3000 | SceneObjectPart part = GetPart(localID); | 3786 | SceneObjectPart part = GetPart(localID); |
3001 | 3787 | ||
3002 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3003 | // for (int i = 0; i < parts.Length; i++) | ||
3004 | // parts[i].StoreUndoState(); | ||
3005 | |||
3006 | if (part != null) | 3788 | if (part != null) |
3007 | { | 3789 | { |
3008 | // m_log.DebugFormat( | 3790 | // unlock parts position change |
3009 | // "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); | 3791 | if (m_rootPart.PhysActor != null) |
3010 | 3792 | m_rootPart.PhysActor.Building = true; | |
3011 | part.StoreUndoState(false); | ||
3012 | part.IgnoreUndoUpdate = true; | ||
3013 | 3793 | ||
3014 | if (part.UUID == m_rootPart.UUID) | 3794 | if (part.UUID == m_rootPart.UUID) |
3015 | { | 3795 | { |
@@ -3020,8 +3800,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3020 | part.UpdateOffSet(pos); | 3800 | part.UpdateOffSet(pos); |
3021 | } | 3801 | } |
3022 | 3802 | ||
3803 | if (m_rootPart.PhysActor != null) | ||
3804 | m_rootPart.PhysActor.Building = false; | ||
3805 | |||
3023 | HasGroupChanged = true; | 3806 | HasGroupChanged = true; |
3024 | part.IgnoreUndoUpdate = false; | ||
3025 | } | 3807 | } |
3026 | } | 3808 | } |
3027 | 3809 | ||
@@ -3031,13 +3813,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3031 | /// <param name="newPos"></param> | 3813 | /// <param name="newPos"></param> |
3032 | public void UpdateRootPosition(Vector3 newPos) | 3814 | public void UpdateRootPosition(Vector3 newPos) |
3033 | { | 3815 | { |
3034 | // m_log.DebugFormat( | 3816 | // needs to be called with phys building true |
3035 | // "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); | ||
3036 | |||
3037 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3038 | // for (int i = 0; i < parts.Length; i++) | ||
3039 | // parts[i].StoreUndoState(); | ||
3040 | |||
3041 | Vector3 oldPos; | 3817 | Vector3 oldPos; |
3042 | 3818 | ||
3043 | // FIXME: This improves the situation where editing just the root prim of an attached object would send | 3819 | // FIXME: This improves the situation where editing just the root prim of an attached object would send |
@@ -3063,7 +3839,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3063 | AbsolutePosition = newPos; | 3839 | AbsolutePosition = newPos; |
3064 | 3840 | ||
3065 | HasGroupChanged = true; | 3841 | HasGroupChanged = true; |
3066 | ScheduleGroupForTerseUpdate(); | 3842 | if (m_rootPart.Undoing) |
3843 | { | ||
3844 | ScheduleGroupForFullUpdate(); | ||
3845 | } | ||
3846 | else | ||
3847 | { | ||
3848 | ScheduleGroupForTerseUpdate(); | ||
3849 | } | ||
3067 | } | 3850 | } |
3068 | 3851 | ||
3069 | #endregion | 3852 | #endregion |
@@ -3076,24 +3859,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3076 | /// <param name="rot"></param> | 3859 | /// <param name="rot"></param> |
3077 | public void UpdateGroupRotationR(Quaternion rot) | 3860 | public void UpdateGroupRotationR(Quaternion rot) |
3078 | { | 3861 | { |
3079 | // m_log.DebugFormat( | ||
3080 | // "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); | ||
3081 | |||
3082 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3083 | // for (int i = 0; i < parts.Length; i++) | ||
3084 | // parts[i].StoreUndoState(); | ||
3085 | |||
3086 | m_rootPart.StoreUndoState(true); | ||
3087 | |||
3088 | m_rootPart.UpdateRotation(rot); | 3862 | m_rootPart.UpdateRotation(rot); |
3089 | 3863 | ||
3864 | /* this is done by rootpart RotationOffset set called by UpdateRotation | ||
3090 | PhysicsActor actor = m_rootPart.PhysActor; | 3865 | PhysicsActor actor = m_rootPart.PhysActor; |
3091 | if (actor != null) | 3866 | if (actor != null) |
3092 | { | 3867 | { |
3093 | actor.Orientation = m_rootPart.RotationOffset; | 3868 | actor.Orientation = m_rootPart.RotationOffset; |
3094 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); | 3869 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
3095 | } | 3870 | } |
3096 | 3871 | */ | |
3097 | HasGroupChanged = true; | 3872 | HasGroupChanged = true; |
3098 | ScheduleGroupForTerseUpdate(); | 3873 | ScheduleGroupForTerseUpdate(); |
3099 | } | 3874 | } |
@@ -3105,16 +3880,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3105 | /// <param name="rot"></param> | 3880 | /// <param name="rot"></param> |
3106 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) | 3881 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) |
3107 | { | 3882 | { |
3108 | // m_log.DebugFormat( | ||
3109 | // "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); | ||
3110 | |||
3111 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3112 | // for (int i = 0; i < parts.Length; i++) | ||
3113 | // parts[i].StoreUndoState(); | ||
3114 | |||
3115 | RootPart.StoreUndoState(true); | ||
3116 | RootPart.IgnoreUndoUpdate = true; | ||
3117 | |||
3118 | m_rootPart.UpdateRotation(rot); | 3883 | m_rootPart.UpdateRotation(rot); |
3119 | 3884 | ||
3120 | PhysicsActor actor = m_rootPart.PhysActor; | 3885 | PhysicsActor actor = m_rootPart.PhysActor; |
@@ -3133,8 +3898,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3133 | 3898 | ||
3134 | HasGroupChanged = true; | 3899 | HasGroupChanged = true; |
3135 | ScheduleGroupForTerseUpdate(); | 3900 | ScheduleGroupForTerseUpdate(); |
3136 | |||
3137 | RootPart.IgnoreUndoUpdate = false; | ||
3138 | } | 3901 | } |
3139 | 3902 | ||
3140 | /// <summary> | 3903 | /// <summary> |
@@ -3147,13 +3910,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3147 | SceneObjectPart part = GetPart(localID); | 3910 | SceneObjectPart part = GetPart(localID); |
3148 | 3911 | ||
3149 | SceneObjectPart[] parts = m_parts.GetArray(); | 3912 | SceneObjectPart[] parts = m_parts.GetArray(); |
3150 | for (int i = 0; i < parts.Length; i++) | ||
3151 | parts[i].StoreUndoState(); | ||
3152 | 3913 | ||
3153 | if (part != null) | 3914 | if (part != null) |
3154 | { | 3915 | { |
3155 | // m_log.DebugFormat( | 3916 | if (m_rootPart.PhysActor != null) |
3156 | // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); | 3917 | m_rootPart.PhysActor.Building = true; |
3157 | 3918 | ||
3158 | if (part.UUID == m_rootPart.UUID) | 3919 | if (part.UUID == m_rootPart.UUID) |
3159 | { | 3920 | { |
@@ -3163,6 +3924,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3163 | { | 3924 | { |
3164 | part.UpdateRotation(rot); | 3925 | part.UpdateRotation(rot); |
3165 | } | 3926 | } |
3927 | |||
3928 | if (m_rootPart.PhysActor != null) | ||
3929 | m_rootPart.PhysActor.Building = false; | ||
3166 | } | 3930 | } |
3167 | } | 3931 | } |
3168 | 3932 | ||
@@ -3176,12 +3940,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3176 | SceneObjectPart part = GetPart(localID); | 3940 | SceneObjectPart part = GetPart(localID); |
3177 | if (part != null) | 3941 | if (part != null) |
3178 | { | 3942 | { |
3179 | // m_log.DebugFormat( | 3943 | if (m_rootPart.PhysActor != null) |
3180 | // "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", | 3944 | m_rootPart.PhysActor.Building = true; |
3181 | // part.Name, part.LocalId, rot); | ||
3182 | |||
3183 | part.StoreUndoState(); | ||
3184 | part.IgnoreUndoUpdate = true; | ||
3185 | 3945 | ||
3186 | if (part.UUID == m_rootPart.UUID) | 3946 | if (part.UUID == m_rootPart.UUID) |
3187 | { | 3947 | { |
@@ -3194,7 +3954,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3194 | part.OffsetPosition = pos; | 3954 | part.OffsetPosition = pos; |
3195 | } | 3955 | } |
3196 | 3956 | ||
3197 | part.IgnoreUndoUpdate = false; | 3957 | if (m_rootPart.PhysActor != null) |
3958 | m_rootPart.PhysActor.Building = false; | ||
3198 | } | 3959 | } |
3199 | } | 3960 | } |
3200 | 3961 | ||
@@ -3204,15 +3965,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3204 | /// <param name="rot"></param> | 3965 | /// <param name="rot"></param> |
3205 | public void UpdateRootRotation(Quaternion rot) | 3966 | public void UpdateRootRotation(Quaternion rot) |
3206 | { | 3967 | { |
3207 | // m_log.DebugFormat( | 3968 | // needs to be called with phys building true |
3208 | // "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", | ||
3209 | // Name, LocalId, rot); | ||
3210 | |||
3211 | Quaternion axRot = rot; | 3969 | Quaternion axRot = rot; |
3212 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 3970 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
3213 | 3971 | ||
3214 | m_rootPart.StoreUndoState(); | 3972 | //Don't use UpdateRotation because it schedules an update prematurely |
3215 | m_rootPart.UpdateRotation(rot); | 3973 | m_rootPart.RotationOffset = rot; |
3216 | 3974 | ||
3217 | PhysicsActor pa = m_rootPart.PhysActor; | 3975 | PhysicsActor pa = m_rootPart.PhysActor; |
3218 | 3976 | ||
@@ -3228,35 +3986,145 @@ namespace OpenSim.Region.Framework.Scenes | |||
3228 | SceneObjectPart prim = parts[i]; | 3986 | SceneObjectPart prim = parts[i]; |
3229 | if (prim.UUID != m_rootPart.UUID) | 3987 | if (prim.UUID != m_rootPart.UUID) |
3230 | { | 3988 | { |
3231 | prim.IgnoreUndoUpdate = true; | 3989 | Quaternion NewRot = oldParentRot * prim.RotationOffset; |
3990 | NewRot = Quaternion.Inverse(axRot) * NewRot; | ||
3991 | prim.RotationOffset = NewRot; | ||
3992 | |||
3232 | Vector3 axPos = prim.OffsetPosition; | 3993 | Vector3 axPos = prim.OffsetPosition; |
3994 | |||
3233 | axPos *= oldParentRot; | 3995 | axPos *= oldParentRot; |
3234 | axPos *= Quaternion.Inverse(axRot); | 3996 | axPos *= Quaternion.Inverse(axRot); |
3235 | prim.OffsetPosition = axPos; | 3997 | prim.OffsetPosition = axPos; |
3236 | Quaternion primsRot = prim.RotationOffset; | 3998 | } |
3237 | Quaternion newRot = oldParentRot * primsRot; | 3999 | } |
3238 | newRot = Quaternion.Inverse(axRot) * newRot; | ||
3239 | prim.RotationOffset = newRot; | ||
3240 | prim.ScheduleTerseUpdate(); | ||
3241 | prim.IgnoreUndoUpdate = false; | ||
3242 | } | ||
3243 | } | ||
3244 | |||
3245 | // for (int i = 0; i < parts.Length; i++) | ||
3246 | // { | ||
3247 | // SceneObjectPart childpart = parts[i]; | ||
3248 | // if (childpart != m_rootPart) | ||
3249 | // { | ||
3250 | //// childpart.IgnoreUndoUpdate = false; | ||
3251 | //// childpart.StoreUndoState(); | ||
3252 | // } | ||
3253 | // } | ||
3254 | 4000 | ||
3255 | m_rootPart.ScheduleTerseUpdate(); | 4001 | HasGroupChanged = true; |
4002 | ScheduleGroupForFullUpdate(); | ||
4003 | } | ||
3256 | 4004 | ||
3257 | // m_log.DebugFormat( | 4005 | private enum updatetype :int |
3258 | // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", | 4006 | { |
3259 | // Name, LocalId, rot); | 4007 | none = 0, |
4008 | partterse = 1, | ||
4009 | partfull = 2, | ||
4010 | groupterse = 3, | ||
4011 | groupfull = 4 | ||
4012 | } | ||
4013 | |||
4014 | public void doChangeObject(SceneObjectPart part, ObjectChangeData data) | ||
4015 | { | ||
4016 | // TODO this still as excessive *.Schedule*Update()s | ||
4017 | |||
4018 | if (part != null && part.ParentGroup != null) | ||
4019 | { | ||
4020 | ObjectChangeType change = data.change; | ||
4021 | bool togroup = ((change & ObjectChangeType.Group) != 0); | ||
4022 | // bool uniform = ((what & ObjectChangeType.UniformScale) != 0); not in use | ||
4023 | |||
4024 | SceneObjectGroup group = part.ParentGroup; | ||
4025 | PhysicsActor pha = group.RootPart.PhysActor; | ||
4026 | |||
4027 | updatetype updateType = updatetype.none; | ||
4028 | |||
4029 | if (togroup) | ||
4030 | { | ||
4031 | // related to group | ||
4032 | if ((change & (ObjectChangeType.Rotation | ObjectChangeType.Position)) != 0) | ||
4033 | { | ||
4034 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4035 | { | ||
4036 | group.RootPart.UpdateRotation(data.rotation); | ||
4037 | updateType = updatetype.none; | ||
4038 | } | ||
4039 | if ((change & ObjectChangeType.Position) != 0) | ||
4040 | { | ||
4041 | if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) | ||
4042 | UpdateGroupPosition(data.position); | ||
4043 | updateType = updatetype.groupterse; | ||
4044 | } | ||
4045 | else | ||
4046 | // ugly rotation update of all parts | ||
4047 | { | ||
4048 | group.ResetChildPrimPhysicsPositions(); | ||
4049 | } | ||
4050 | |||
4051 | } | ||
4052 | if ((change & ObjectChangeType.Scale) != 0) | ||
4053 | { | ||
4054 | if (pha != null) | ||
4055 | pha.Building = true; | ||
4056 | |||
4057 | group.GroupResize(data.scale); | ||
4058 | updateType = updatetype.none; | ||
4059 | |||
4060 | if (pha != null) | ||
4061 | pha.Building = false; | ||
4062 | } | ||
4063 | } | ||
4064 | else | ||
4065 | { | ||
4066 | // related to single prim in a link-set ( ie group) | ||
4067 | if (pha != null) | ||
4068 | pha.Building = true; | ||
4069 | |||
4070 | // root part is special | ||
4071 | // parts offset positions or rotations need to change also | ||
4072 | |||
4073 | if (part == group.RootPart) | ||
4074 | { | ||
4075 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4076 | group.UpdateRootRotation(data.rotation); | ||
4077 | if ((change & ObjectChangeType.Position) != 0) | ||
4078 | group.UpdateRootPosition(data.position); | ||
4079 | if ((change & ObjectChangeType.Scale) != 0) | ||
4080 | part.Resize(data.scale); | ||
4081 | } | ||
4082 | else | ||
4083 | { | ||
4084 | if ((change & ObjectChangeType.Position) != 0) | ||
4085 | { | ||
4086 | part.OffsetPosition = data.position; | ||
4087 | updateType = updatetype.partterse; | ||
4088 | } | ||
4089 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4090 | { | ||
4091 | part.UpdateRotation(data.rotation); | ||
4092 | updateType = updatetype.none; | ||
4093 | } | ||
4094 | if ((change & ObjectChangeType.Scale) != 0) | ||
4095 | { | ||
4096 | part.Resize(data.scale); | ||
4097 | updateType = updatetype.none; | ||
4098 | } | ||
4099 | } | ||
4100 | |||
4101 | if (pha != null) | ||
4102 | pha.Building = false; | ||
4103 | } | ||
4104 | |||
4105 | if (updateType != updatetype.none) | ||
4106 | { | ||
4107 | group.HasGroupChanged = true; | ||
4108 | |||
4109 | switch (updateType) | ||
4110 | { | ||
4111 | case updatetype.partterse: | ||
4112 | part.ScheduleTerseUpdate(); | ||
4113 | break; | ||
4114 | case updatetype.partfull: | ||
4115 | part.ScheduleFullUpdate(); | ||
4116 | break; | ||
4117 | case updatetype.groupterse: | ||
4118 | group.ScheduleGroupForTerseUpdate(); | ||
4119 | break; | ||
4120 | case updatetype.groupfull: | ||
4121 | group.ScheduleGroupForFullUpdate(); | ||
4122 | break; | ||
4123 | default: | ||
4124 | break; | ||
4125 | } | ||
4126 | } | ||
4127 | } | ||
3260 | } | 4128 | } |
3261 | 4129 | ||
3262 | #endregion | 4130 | #endregion |
@@ -3297,6 +4165,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3297 | waypoint.handle = handle; | 4165 | waypoint.handle = handle; |
3298 | lock (m_rotTargets) | 4166 | lock (m_rotTargets) |
3299 | { | 4167 | { |
4168 | if (m_rotTargets.Count >= 8) | ||
4169 | m_rotTargets.Remove(m_rotTargets.ElementAt(0).Key); | ||
3300 | m_rotTargets.Add(handle, waypoint); | 4170 | m_rotTargets.Add(handle, waypoint); |
3301 | } | 4171 | } |
3302 | m_scene.AddGroupTarget(this); | 4172 | m_scene.AddGroupTarget(this); |
@@ -3322,6 +4192,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3322 | waypoint.handle = handle; | 4192 | waypoint.handle = handle; |
3323 | lock (m_targets) | 4193 | lock (m_targets) |
3324 | { | 4194 | { |
4195 | if (m_targets.Count >= 8) | ||
4196 | m_targets.Remove(m_targets.ElementAt(0).Key); | ||
3325 | m_targets.Add(handle, waypoint); | 4197 | m_targets.Add(handle, waypoint); |
3326 | } | 4198 | } |
3327 | m_scene.AddGroupTarget(this); | 4199 | m_scene.AddGroupTarget(this); |
@@ -3355,10 +4227,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3355 | scriptPosTarget target = m_targets[idx]; | 4227 | scriptPosTarget target = m_targets[idx]; |
3356 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) | 4228 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) |
3357 | { | 4229 | { |
4230 | at_target = true; | ||
4231 | |||
3358 | // trigger at_target | 4232 | // trigger at_target |
3359 | if (m_scriptListens_atTarget) | 4233 | if (m_scriptListens_atTarget) |
3360 | { | 4234 | { |
3361 | at_target = true; | ||
3362 | scriptPosTarget att = new scriptPosTarget(); | 4235 | scriptPosTarget att = new scriptPosTarget(); |
3363 | att.targetPos = target.targetPos; | 4236 | att.targetPos = target.targetPos; |
3364 | att.tolerance = target.tolerance; | 4237 | att.tolerance = target.tolerance; |
@@ -3476,11 +4349,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
3476 | } | 4349 | } |
3477 | } | 4350 | } |
3478 | } | 4351 | } |
3479 | 4352 | ||
4353 | public Vector3 GetGeometricCenter() | ||
4354 | { | ||
4355 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
4356 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
4357 | // ignoring tortured prims details since sl also seems to ignore | ||
4358 | // so no real use in doing it on physics | ||
4359 | |||
4360 | Vector3 gc = Vector3.Zero; | ||
4361 | |||
4362 | int nparts = m_parts.Count; | ||
4363 | if (nparts <= 1) | ||
4364 | return gc; | ||
4365 | |||
4366 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4367 | nparts = parts.Length; // just in case it changed | ||
4368 | if (nparts <= 1) | ||
4369 | return gc; | ||
4370 | |||
4371 | Quaternion parentRot = RootPart.RotationOffset; | ||
4372 | Vector3 pPos; | ||
4373 | |||
4374 | // average all parts positions | ||
4375 | for (int i = 0; i < nparts; i++) | ||
4376 | { | ||
4377 | // do it directly | ||
4378 | // gc += parts[i].GetWorldPosition(); | ||
4379 | if (parts[i] != RootPart) | ||
4380 | { | ||
4381 | pPos = parts[i].OffsetPosition; | ||
4382 | gc += pPos; | ||
4383 | } | ||
4384 | |||
4385 | } | ||
4386 | gc /= nparts; | ||
4387 | |||
4388 | // relative to root: | ||
4389 | // gc -= AbsolutePosition; | ||
4390 | return gc; | ||
4391 | } | ||
4392 | |||
3480 | public float GetMass() | 4393 | public float GetMass() |
3481 | { | 4394 | { |
3482 | float retmass = 0f; | 4395 | float retmass = 0f; |
3483 | |||
3484 | SceneObjectPart[] parts = m_parts.GetArray(); | 4396 | SceneObjectPart[] parts = m_parts.GetArray(); |
3485 | for (int i = 0; i < parts.Length; i++) | 4397 | for (int i = 0; i < parts.Length; i++) |
3486 | retmass += parts[i].GetMass(); | 4398 | retmass += parts[i].GetMass(); |
@@ -3488,6 +4400,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3488 | return retmass; | 4400 | return retmass; |
3489 | } | 4401 | } |
3490 | 4402 | ||
4403 | // center of mass of full object | ||
4404 | public Vector3 GetCenterOfMass() | ||
4405 | { | ||
4406 | PhysicsActor pa = RootPart.PhysActor; | ||
4407 | |||
4408 | if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null) | ||
4409 | { | ||
4410 | // physics knows better about center of mass of physical prims | ||
4411 | Vector3 tmp = pa.CenterOfMass; | ||
4412 | return tmp; | ||
4413 | } | ||
4414 | |||
4415 | Vector3 Ptot = Vector3.Zero; | ||
4416 | float totmass = 0f; | ||
4417 | float m; | ||
4418 | |||
4419 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4420 | for (int i = 0; i < parts.Length; i++) | ||
4421 | { | ||
4422 | m = parts[i].GetMass(); | ||
4423 | Ptot += parts[i].GetPartCenterOfMass() * m; | ||
4424 | totmass += m; | ||
4425 | } | ||
4426 | |||
4427 | if (totmass == 0) | ||
4428 | totmass = 0; | ||
4429 | else | ||
4430 | totmass = 1 / totmass; | ||
4431 | Ptot *= totmass; | ||
4432 | |||
4433 | return Ptot; | ||
4434 | } | ||
4435 | |||
3491 | /// <summary> | 4436 | /// <summary> |
3492 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that | 4437 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that |
3493 | /// the physics engine can use it. | 4438 | /// the physics engine can use it. |
@@ -3667,6 +4612,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3667 | FromItemID = uuid; | 4612 | FromItemID = uuid; |
3668 | } | 4613 | } |
3669 | 4614 | ||
4615 | public void ResetOwnerChangeFlag() | ||
4616 | { | ||
4617 | ForEachPart(delegate(SceneObjectPart part) | ||
4618 | { | ||
4619 | part.ResetOwnerChangeFlag(); | ||
4620 | }); | ||
4621 | } | ||
4622 | |||
3670 | #endregion | 4623 | #endregion |
3671 | } | 4624 | } |
3672 | } | 4625 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c9ff4f3..cf03d7c 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 | { |
@@ -789,16 +832,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
789 | m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e); | 832 | m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e); |
790 | } | 833 | } |
791 | } | 834 | } |
792 | |||
793 | // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too | ||
794 | if (SitTargetAvatar != UUID.Zero) | ||
795 | { | ||
796 | ScenePresence avatar; | ||
797 | if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar)) | ||
798 | { | ||
799 | avatar.ParentPosition = GetWorldPosition(); | ||
800 | } | ||
801 | } | ||
802 | } | 835 | } |
803 | } | 836 | } |
804 | 837 | ||
@@ -807,7 +840,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
807 | get { return m_offsetPosition; } | 840 | get { return m_offsetPosition; } |
808 | set | 841 | set |
809 | { | 842 | { |
810 | // StoreUndoState(); | 843 | Vector3 oldpos = m_offsetPosition; |
811 | m_offsetPosition = value; | 844 | m_offsetPosition = value; |
812 | 845 | ||
813 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 846 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
@@ -819,10 +852,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
819 | actor.Orientation = GetWorldRotation(); | 852 | actor.Orientation = GetWorldRotation(); |
820 | 853 | ||
821 | // Tell the physics engines that this prim changed. | 854 | // Tell the physics engines that this prim changed. |
822 | if (ParentGroup.Scene != null) | 855 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene != null) |
823 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 856 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
824 | } | 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 | } | ||
825 | } | 872 | } |
873 | TriggerScriptChangedEvent(Changed.POSITION); | ||
826 | } | 874 | } |
827 | } | 875 | } |
828 | 876 | ||
@@ -873,7 +921,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
873 | 921 | ||
874 | set | 922 | set |
875 | { | 923 | { |
876 | StoreUndoState(); | 924 | // StoreUndoState(); |
877 | m_rotationOffset = value; | 925 | m_rotationOffset = value; |
878 | 926 | ||
879 | PhysicsActor actor = PhysActor; | 927 | PhysicsActor actor = PhysActor; |
@@ -961,19 +1009,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
961 | get | 1009 | get |
962 | { | 1010 | { |
963 | PhysicsActor actor = PhysActor; | 1011 | PhysicsActor actor = PhysActor; |
964 | if ((actor != null) && actor.IsPhysical) | 1012 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this) |
965 | { | 1013 | { |
966 | m_angularVelocity = actor.RotationalVelocity; | 1014 | m_angularVelocity = actor.RotationalVelocity; |
967 | } | 1015 | } |
968 | return m_angularVelocity; | 1016 | return m_angularVelocity; |
969 | } | 1017 | } |
970 | 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 | } | ||
971 | } | 1027 | } |
972 | 1028 | ||
973 | /// <summary></summary> | 1029 | /// <summary></summary> |
974 | public Vector3 Acceleration | 1030 | public Vector3 Acceleration |
975 | { | 1031 | { |
976 | 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 | |||
977 | set { m_acceleration = value; } | 1042 | set { m_acceleration = value; } |
978 | } | 1043 | } |
979 | 1044 | ||
@@ -1041,7 +1106,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1041 | public PrimitiveBaseShape Shape | 1106 | public PrimitiveBaseShape Shape |
1042 | { | 1107 | { |
1043 | get { return m_shape; } | 1108 | get { return m_shape; } |
1044 | set { m_shape = value;} | 1109 | set |
1110 | { | ||
1111 | m_shape = value; | ||
1112 | } | ||
1045 | } | 1113 | } |
1046 | 1114 | ||
1047 | /// <summary> | 1115 | /// <summary> |
@@ -1054,7 +1122,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1054 | { | 1122 | { |
1055 | if (m_shape != null) | 1123 | if (m_shape != null) |
1056 | { | 1124 | { |
1057 | StoreUndoState(); | ||
1058 | 1125 | ||
1059 | m_shape.Scale = value; | 1126 | m_shape.Scale = value; |
1060 | 1127 | ||
@@ -1122,10 +1189,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1122 | { | 1189 | { |
1123 | get | 1190 | get |
1124 | { | 1191 | { |
1125 | if (ParentGroup.IsAttachment) | 1192 | return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); |
1126 | return GroupPosition; | ||
1127 | |||
1128 | return m_offsetPosition + m_groupPosition; | ||
1129 | } | 1193 | } |
1130 | } | 1194 | } |
1131 | 1195 | ||
@@ -1294,6 +1358,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1294 | _flags = value; | 1358 | _flags = value; |
1295 | } | 1359 | } |
1296 | } | 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 | } | ||
1297 | 1368 | ||
1298 | /// <summary> | 1369 | /// <summary> |
1299 | /// 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 |
@@ -1344,12 +1415,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1344 | set { m_sitAnimation = value; } | 1415 | set { m_sitAnimation = value; } |
1345 | } | 1416 | } |
1346 | 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 | |||
1347 | public UUID CollisionSound | 1439 | public UUID CollisionSound |
1348 | { | 1440 | { |
1349 | get { return m_collisionSound; } | 1441 | get { return m_collisionSound; } |
1350 | set | 1442 | set |
1351 | { | 1443 | { |
1352 | 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 | |||
1353 | aggregateScriptEvents(); | 1453 | aggregateScriptEvents(); |
1354 | } | 1454 | } |
1355 | } | 1455 | } |
@@ -1360,6 +1460,125 @@ namespace OpenSim.Region.Framework.Scenes | |||
1360 | set { m_collisionSoundVolume = value; } | 1460 | set { m_collisionSoundVolume = value; } |
1361 | } | 1461 | } |
1362 | 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 | ||
1363 | public byte DefaultPhysicsShapeType() | 1582 | public byte DefaultPhysicsShapeType() |
1364 | { | 1583 | { |
1365 | byte type; | 1584 | byte type; |
@@ -1372,6 +1591,65 @@ namespace OpenSim.Region.Framework.Scenes | |||
1372 | return type; | 1591 | return type; |
1373 | } | 1592 | } |
1374 | 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 | |||
1375 | public byte PhysicsShapeType | 1653 | public byte PhysicsShapeType |
1376 | { | 1654 | { |
1377 | get { return m_physicsShapeType; } | 1655 | get { return m_physicsShapeType; } |
@@ -1405,11 +1683,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1405 | } | 1683 | } |
1406 | else if (PhysActor == null) | 1684 | else if (PhysActor == null) |
1407 | { | 1685 | { |
1408 | ApplyPhysics((uint)Flags, VolumeDetectActive); | 1686 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); |
1687 | UpdatePhysicsSubscribedEvents(); | ||
1409 | } | 1688 | } |
1410 | else | 1689 | else |
1411 | { | 1690 | { |
1412 | PhysActor.PhysicsShapeType = m_physicsShapeType; | 1691 | PhysActor.PhysicsShapeType = m_physicsShapeType; |
1692 | // if (Shape.SculptEntry) | ||
1693 | // CheckSculptAndLoad(); | ||
1413 | } | 1694 | } |
1414 | 1695 | ||
1415 | if (ParentGroup != null) | 1696 | if (ParentGroup != null) |
@@ -1511,6 +1792,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1511 | } | 1792 | } |
1512 | } | 1793 | } |
1513 | 1794 | ||
1795 | |||
1514 | #endregion Public Properties with only Get | 1796 | #endregion Public Properties with only Get |
1515 | 1797 | ||
1516 | private uint ApplyMask(uint val, bool set, uint mask) | 1798 | private uint ApplyMask(uint val, bool set, uint mask) |
@@ -1656,6 +1938,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1656 | } | 1938 | } |
1657 | } | 1939 | } |
1658 | 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 | |||
1659 | /// <summary> | 1996 | /// <summary> |
1660 | /// hook to the physics scene to apply angular impulse | 1997 | /// hook to the physics scene to apply angular impulse |
1661 | /// 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 |
@@ -1676,7 +2013,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1676 | impulse = newimpulse; | 2013 | impulse = newimpulse; |
1677 | } | 2014 | } |
1678 | 2015 | ||
1679 | ParentGroup.applyAngularImpulse(impulse); | 2016 | ParentGroup.ApplyAngularImpulse(impulse); |
1680 | } | 2017 | } |
1681 | 2018 | ||
1682 | /// <summary> | 2019 | /// <summary> |
@@ -1686,20 +2023,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1686 | /// </summary> | 2023 | /// </summary> |
1687 | /// <param name="impulsei">Vector force</param> | 2024 | /// <param name="impulsei">Vector force</param> |
1688 | /// <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> |
1689 | 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) | ||
1690 | { | 2029 | { |
1691 | Vector3 impulse = impulsei; | 2030 | Vector3 torque = torquei; |
1692 | 2031 | ||
1693 | if (localGlobalTF) | 2032 | if (localGlobalTF) |
1694 | { | 2033 | { |
2034 | /* | ||
1695 | Quaternion grot = GetWorldRotation(); | 2035 | Quaternion grot = GetWorldRotation(); |
1696 | Quaternion AXgrot = grot; | 2036 | Quaternion AXgrot = grot; |
1697 | Vector3 AXimpulsei = impulsei; | 2037 | Vector3 AXimpulsei = impulsei; |
1698 | Vector3 newimpulse = AXimpulsei * AXgrot; | 2038 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1699 | impulse = newimpulse; | 2039 | */ |
2040 | torque *= GetWorldRotation(); | ||
1700 | } | 2041 | } |
1701 | 2042 | ||
1702 | ParentGroup.setAngularImpulse(impulse); | 2043 | Torque = torque; |
1703 | } | 2044 | } |
1704 | 2045 | ||
1705 | /// <summary> | 2046 | /// <summary> |
@@ -1707,7 +2048,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1707 | /// </summary> | 2048 | /// </summary> |
1708 | /// <param name="rootObjectFlags"></param> | 2049 | /// <param name="rootObjectFlags"></param> |
1709 | /// <param name="VolumeDetectActive"></param> | 2050 | /// <param name="VolumeDetectActive"></param> |
1710 | public void ApplyPhysics(uint rootObjectFlags, bool _VolumeDetectActive) | 2051 | /// <param name="building"></param> |
2052 | |||
2053 | public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building) | ||
1711 | { | 2054 | { |
1712 | VolumeDetectActive = _VolumeDetectActive; | 2055 | VolumeDetectActive = _VolumeDetectActive; |
1713 | 2056 | ||
@@ -1717,8 +2060,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1717 | if (PhysicsShapeType == (byte)PhysShapeType.none) | 2060 | if (PhysicsShapeType == (byte)PhysShapeType.none) |
1718 | return; | 2061 | return; |
1719 | 2062 | ||
1720 | bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; | 2063 | bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0; |
1721 | bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; | 2064 | bool isPhantom = (_ObjectFlags & (uint)PrimFlags.Phantom) != 0; |
1722 | 2065 | ||
1723 | if (_VolumeDetectActive) | 2066 | if (_VolumeDetectActive) |
1724 | isPhantom = true; | 2067 | isPhantom = true; |
@@ -1732,7 +2075,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1732 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment | 2075 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment |
1733 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) | 2076 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) |
1734 | { | 2077 | { |
1735 | AddToPhysics(isPhysical, isPhantom, isPhysical); | 2078 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); |
2079 | UpdatePhysicsSubscribedEvents(); // not sure if appliable here | ||
1736 | } | 2080 | } |
1737 | else | 2081 | else |
1738 | PhysActor = null; // just to be sure | 2082 | PhysActor = null; // just to be sure |
@@ -1787,6 +2131,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1787 | dupe.Category = Category; | 2131 | dupe.Category = Category; |
1788 | dupe.m_rezzed = m_rezzed; | 2132 | dupe.m_rezzed = m_rezzed; |
1789 | 2133 | ||
2134 | dupe.m_UndoRedo = null; | ||
2135 | dupe.m_isSelected = false; | ||
2136 | |||
2137 | dupe.IgnoreUndoUpdate = false; | ||
2138 | dupe.Undoing = false; | ||
2139 | |||
1790 | dupe.m_inventory = new SceneObjectPartInventory(dupe); | 2140 | dupe.m_inventory = new SceneObjectPartInventory(dupe); |
1791 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); | 2141 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); |
1792 | 2142 | ||
@@ -1802,6 +2152,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1802 | 2152 | ||
1803 | // Move afterwards ResetIDs as it clears the localID | 2153 | // Move afterwards ResetIDs as it clears the localID |
1804 | dupe.LocalId = localID; | 2154 | dupe.LocalId = localID; |
2155 | |||
1805 | // 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. |
1806 | dupe.LastOwnerID = OwnerID; | 2157 | dupe.LastOwnerID = OwnerID; |
1807 | 2158 | ||
@@ -1826,8 +2177,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1826 | */ | 2177 | */ |
1827 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); | 2178 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); |
1828 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); | 2179 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); |
2180 | // dupe.UpdatePhysicsSubscribedEvents(); // not sure... | ||
1829 | } | 2181 | } |
1830 | 2182 | ||
2183 | if (dupe.PhysActor != null) | ||
2184 | dupe.PhysActor.LocalID = localID; | ||
2185 | |||
1831 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); | 2186 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); |
1832 | 2187 | ||
1833 | // 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); |
@@ -1846,10 +2201,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1846 | { | 2201 | { |
1847 | if (asset != null) | 2202 | if (asset != null) |
1848 | SculptTextureCallback(asset); | 2203 | SculptTextureCallback(asset); |
1849 | else | 2204 | // else |
1850 | m_log.WarnFormat( | 2205 | // m_log.WarnFormat( |
1851 | "[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", |
1852 | Name, UUID, id); | 2207 | // Name, UUID, id); |
1853 | } | 2208 | } |
1854 | */ | 2209 | */ |
1855 | /// <summary> | 2210 | /// <summary> |
@@ -1948,6 +2303,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1948 | 2303 | ||
1949 | /// <summary> | 2304 | /// <summary> |
1950 | /// 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 | ||
1951 | /// </summary> | 2307 | /// </summary> |
1952 | /// <param name="UsePhysics"></param> | 2308 | /// <param name="UsePhysics"></param> |
1953 | /// <param name="isNew"></param> | 2309 | /// <param name="isNew"></param> |
@@ -1973,64 +2329,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
1973 | { | 2329 | { |
1974 | if (pa.IsPhysical) // implies UsePhysics==false for this block | 2330 | if (pa.IsPhysical) // implies UsePhysics==false for this block |
1975 | { | 2331 | { |
1976 | if (!isNew) | 2332 | if (!isNew) // implies UsePhysics==false for this block |
2333 | { | ||
1977 | ParentGroup.Scene.RemovePhysicalPrim(1); | 2334 | ParentGroup.Scene.RemovePhysicalPrim(1); |
1978 | 2335 | ||
1979 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | 2336 | Velocity = new Vector3(0, 0, 0); |
1980 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | 2337 | Acceleration = new Vector3(0, 0, 0); |
1981 | pa.delink(); | 2338 | if (ParentGroup.RootPart == this) |
2339 | AngularVelocity = new Vector3(0, 0, 0); | ||
1982 | 2340 | ||
1983 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) | 2341 | if (pa.Phantom && !VolumeDetectActive) |
1984 | { | 2342 | { |
1985 | // destroy all joints connected to this now deactivated body | 2343 | RemoveFromPhysics(); |
1986 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | 2344 | return; |
1987 | } | 2345 | } |
1988 | 2346 | ||
1989 | // stop client-side interpolation of all joint proxy objects that have just been deleted | 2347 | pa.IsPhysical = UsePhysics; |
1990 | // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback, | 2348 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; |
1991 | // 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 | } | ||
1992 | } | 2357 | } |
1993 | 2358 | ||
1994 | if (!UsePhysics && !isNew) | 2359 | if (pa.IsPhysical != UsePhysics) |
1995 | { | 2360 | pa.IsPhysical = UsePhysics; |
1996 | // reset velocity to 0 on physics switch-off. Without that, the client thinks the | ||
1997 | // prim still has velocity and continues to interpolate its position along the old | ||
1998 | // velocity-vector. | ||
1999 | Velocity = new Vector3(0, 0, 0); | ||
2000 | Acceleration = new Vector3(0, 0, 0); | ||
2001 | AngularVelocity = new Vector3(0, 0, 0); | ||
2002 | //RotationalVelocity = new Vector3(0, 0, 0); | ||
2003 | } | ||
2004 | 2361 | ||
2005 | 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); | ||
2006 | 2368 | ||
2007 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. | 2369 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
2008 | //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 2370 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; |
2009 | /// that's not wholesome. Had to make Scene public | ||
2010 | //PhysActor = null; | ||
2011 | 2371 | ||
2012 | if ((Flags & PrimFlags.Phantom) == 0) | 2372 | if (ParentID != 0 && ParentID != LocalId) |
2013 | { | ||
2014 | if (UsePhysics) | ||
2015 | { | 2373 | { |
2016 | if (ParentGroup.RootPart.KeyframeMotion != null) | 2374 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; |
2017 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2018 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2019 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
2020 | |||
2021 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | ||
2022 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
2023 | if (ParentID != 0 && ParentID != LocalId) | ||
2024 | { | ||
2025 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | ||
2026 | 2375 | ||
2027 | if (parentPa != null) | 2376 | if (parentPa != null) |
2028 | { | 2377 | { |
2029 | pa.link(parentPa); | 2378 | pa.link(parentPa); |
2030 | } | ||
2031 | } | 2379 | } |
2032 | } | 2380 | } |
2033 | } | 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); | ||
2034 | } | 2395 | } |
2035 | 2396 | ||
2036 | // 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 |
@@ -2149,42 +2510,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
2149 | 2510 | ||
2150 | public Vector3 GetGeometricCenter() | 2511 | public Vector3 GetGeometricCenter() |
2151 | { | 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 | { | ||
2152 | PhysicsActor pa = PhysActor; | 2525 | PhysicsActor pa = PhysActor; |
2153 | 2526 | ||
2154 | if (pa != null) | 2527 | if (pa != null) |
2155 | return pa.GeometricCenter; | 2528 | return pa.Mass; |
2156 | else | 2529 | else |
2157 | return Vector3.Zero; | 2530 | return 0; |
2158 | } | 2531 | } |
2159 | 2532 | ||
2160 | public Vector3 GetCenterOfMass() | 2533 | public Vector3 GetCenterOfMass() |
2161 | { | 2534 | { |
2535 | if (ParentGroup.RootPart == this) | ||
2536 | { | ||
2537 | if (ParentGroup.IsDeleted) | ||
2538 | return AbsolutePosition; | ||
2539 | return ParentGroup.GetCenterOfMass(); | ||
2540 | } | ||
2541 | |||
2162 | PhysicsActor pa = PhysActor; | 2542 | PhysicsActor pa = PhysActor; |
2163 | 2543 | ||
2164 | if (pa != null) | 2544 | if (pa != null) |
2165 | return pa.CenterOfMass; | 2545 | { |
2546 | Vector3 tmp = pa.CenterOfMass; | ||
2547 | return tmp; | ||
2548 | } | ||
2166 | else | 2549 | else |
2167 | return Vector3.Zero; | 2550 | return AbsolutePosition; |
2168 | } | 2551 | } |
2169 | 2552 | ||
2170 | public float GetMass() | 2553 | public Vector3 GetPartCenterOfMass() |
2171 | { | 2554 | { |
2172 | PhysicsActor pa = PhysActor; | 2555 | PhysicsActor pa = PhysActor; |
2173 | 2556 | ||
2174 | if (pa != null) | 2557 | if (pa != null) |
2175 | return pa.Mass; | 2558 | { |
2559 | Vector3 tmp = pa.CenterOfMass; | ||
2560 | return tmp; | ||
2561 | } | ||
2176 | else | 2562 | else |
2177 | return 0; | 2563 | return AbsolutePosition; |
2178 | } | 2564 | } |
2179 | 2565 | ||
2566 | |||
2180 | public Vector3 GetForce() | 2567 | public Vector3 GetForce() |
2181 | { | 2568 | { |
2182 | PhysicsActor pa = PhysActor; | 2569 | return Force; |
2183 | |||
2184 | if (pa != null) | ||
2185 | return pa.Force; | ||
2186 | else | ||
2187 | return Vector3.Zero; | ||
2188 | } | 2570 | } |
2189 | 2571 | ||
2190 | /// <summary> | 2572 | /// <summary> |
@@ -2399,15 +2781,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2399 | 2781 | ||
2400 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) | 2782 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) |
2401 | { | 2783 | { |
2402 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) | 2784 | bool sendToRoot = true; |
2403 | { | 2785 | |
2404 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | 2786 | ColliderArgs LandCollidingMessage = new ColliderArgs(); |
2405 | List<DetectedObject> colliding = new List<DetectedObject>(); | 2787 | List<DetectedObject> colliding = new List<DetectedObject>(); |
2406 | 2788 | ||
2407 | colliding.Add(CreateDetObjectForGround()); | 2789 | colliding.Add(CreateDetObjectForGround()); |
2408 | LandCollidingMessage.Colliders = colliding; | 2790 | LandCollidingMessage.Colliders = colliding; |
2409 | 2791 | ||
2792 | if (Inventory.ContainsScripts()) | ||
2793 | { | ||
2794 | if (!PassCollisions) | ||
2795 | sendToRoot = false; | ||
2796 | } | ||
2797 | if ((ScriptEvents & ev) != 0) | ||
2410 | notify(LocalId, LandCollidingMessage); | 2798 | notify(LocalId, LandCollidingMessage); |
2799 | |||
2800 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot) | ||
2801 | { | ||
2802 | notify(ParentGroup.RootPart.LocalId, LandCollidingMessage); | ||
2411 | } | 2803 | } |
2412 | } | 2804 | } |
2413 | 2805 | ||
@@ -2423,57 +2815,120 @@ namespace OpenSim.Region.Framework.Scenes | |||
2423 | List<uint> endedColliders = new List<uint>(); | 2815 | List<uint> endedColliders = new List<uint>(); |
2424 | List<uint> startedColliders = new List<uint>(); | 2816 | List<uint> startedColliders = new List<uint>(); |
2425 | 2817 | ||
2426 | // calculate things that started colliding this time | 2818 | if (collissionswith.Count == 0) |
2427 | // and build up list of colliders this time | ||
2428 | foreach (uint localid in collissionswith.Keys) | ||
2429 | { | 2819 | { |
2430 | thisHitColliders.Add(localid); | 2820 | if (m_lastColliders.Count == 0) |
2431 | if (!m_lastColliders.Contains(localid)) | 2821 | return; // nothing to do |
2432 | startedColliders.Add(localid); | ||
2433 | } | ||
2434 | 2822 | ||
2435 | // calculate things that ended colliding | 2823 | foreach (uint localID in m_lastColliders) |
2436 | foreach (uint localID in m_lastColliders) | 2824 | { |
2437 | { | ||
2438 | if (!thisHitColliders.Contains(localID)) | ||
2439 | endedColliders.Add(localID); | 2825 | endedColliders.Add(localID); |
2826 | } | ||
2827 | m_lastColliders.Clear(); | ||
2440 | } | 2828 | } |
2441 | 2829 | ||
2442 | //add the items that started colliding this time to the last colliders list. | 2830 | else |
2443 | foreach (uint localID in startedColliders) | 2831 | { |
2444 | 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; | ||
2445 | 2840 | ||
2446 | // remove things that ended colliding from the last colliders list | 2841 | foreach (uint id in collissionswith.Keys) |
2447 | foreach (uint localID in endedColliders) | 2842 | { |
2448 | m_lastColliders.Remove(localID); | 2843 | thisHitColliders.Add(id); |
2844 | if (!m_lastColliders.Contains(id)) | ||
2845 | { | ||
2846 | startedColliders.Add(id); | ||
2449 | 2847 | ||
2450 | // play the sound. | 2848 | curcontact = collissionswith[id]; |
2451 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) | 2849 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) |
2452 | { | 2850 | { |
2453 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | 2851 | soundinfo = new CollisionForSoundInfo(); |
2454 | 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 | ||
2455 | { | 2861 | { |
2456 | soundModule.SendSound(UUID, CollisionSound, | 2862 | foreach (uint id in collissionswith.Keys) |
2457 | CollisionSoundVolume, true, 0, 0, false, | 2863 | { |
2458 | false); | 2864 | thisHitColliders.Add(id); |
2865 | if (!m_lastColliders.Contains(id)) | ||
2866 | startedColliders.Add(id); | ||
2867 | } | ||
2459 | } | 2868 | } |
2869 | |||
2870 | // calculate things that ended colliding | ||
2871 | foreach (uint localID in m_lastColliders) | ||
2872 | { | ||
2873 | if (!thisHitColliders.Contains(localID)) | ||
2874 | endedColliders.Add(localID); | ||
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); | ||
2460 | } | 2888 | } |
2461 | 2889 | ||
2462 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2890 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2463 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2891 | if (!VolumeDetectActive) |
2892 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | ||
2464 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2893 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2465 | 2894 | ||
2466 | if (startedColliders.Contains(0)) | 2895 | if (startedColliders.Contains(0)) |
2467 | { | 2896 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); |
2468 | if (m_lastColliders.Contains(0)) | 2897 | if (m_lastColliders.Contains(0)) |
2469 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); | 2898 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); |
2470 | else | ||
2471 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); | ||
2472 | } | ||
2473 | if (endedColliders.Contains(0)) | 2899 | if (endedColliders.Contains(0)) |
2474 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); | 2900 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); |
2475 | } | 2901 | } |
2476 | 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 | |||
2477 | public void PhysicsOutOfBounds(Vector3 pos) | 2932 | public void PhysicsOutOfBounds(Vector3 pos) |
2478 | { | 2933 | { |
2479 | // 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. |
@@ -2495,9 +2950,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2495 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | 2950 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); |
2496 | 2951 | ||
2497 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | 2952 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) |
2498 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | 2953 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) |
2499 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | 2954 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) |
2500 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) | 2955 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) |
2501 | { | 2956 | { |
2502 | ParentGroup.AbsolutePosition = newpos; | 2957 | ParentGroup.AbsolutePosition = newpos; |
2503 | return; | 2958 | return; |
@@ -2782,6 +3237,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2782 | if (ParentGroup == null) | 3237 | if (ParentGroup == null) |
2783 | return; | 3238 | return; |
2784 | 3239 | ||
3240 | // Update the "last" values | ||
3241 | m_lastPosition = OffsetPosition; | ||
3242 | m_lastRotation = RotationOffset; | ||
3243 | m_lastVelocity = Velocity; | ||
3244 | m_lastAcceleration = Acceleration; | ||
3245 | m_lastAngularVelocity = AngularVelocity; | ||
3246 | m_lastUpdateSentTime = Environment.TickCount; | ||
3247 | |||
2785 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 3248 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2786 | { | 3249 | { |
2787 | SendFullUpdate(avatar.ControllingClient); | 3250 | SendFullUpdate(avatar.ControllingClient); |
@@ -2840,8 +3303,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2840 | { | 3303 | { |
2841 | const float ROTATION_TOLERANCE = 0.01f; | 3304 | const float ROTATION_TOLERANCE = 0.01f; |
2842 | const float VELOCITY_TOLERANCE = 0.001f; | 3305 | const float VELOCITY_TOLERANCE = 0.001f; |
2843 | const float POSITION_TOLERANCE = 0.05f; | 3306 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
2844 | const int TIME_MS_TOLERANCE = 3000; | 3307 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
2845 | 3308 | ||
2846 | switch (UpdateFlag) | 3309 | switch (UpdateFlag) |
2847 | { | 3310 | { |
@@ -2855,17 +3318,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2855 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || | 3318 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || |
2856 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || | 3319 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || |
2857 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 3320 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
2858 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 3321 | Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) |
2859 | { | 3322 | { |
2860 | SendTerseUpdateToAllClients(); | 3323 | SendTerseUpdateToAllClients(); |
2861 | 3324 | ||
2862 | // Update the "last" values | ||
2863 | m_lastPosition = OffsetPosition; | ||
2864 | m_lastRotation = RotationOffset; | ||
2865 | m_lastVelocity = Velocity; | ||
2866 | m_lastAcceleration = Acceleration; | ||
2867 | m_lastAngularVelocity = AngularVelocity; | ||
2868 | m_lastTerseSent = Environment.TickCount; | ||
2869 | } | 3325 | } |
2870 | break; | 3326 | break; |
2871 | } | 3327 | } |
@@ -2883,6 +3339,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2883 | /// </summary> | 3339 | /// </summary> |
2884 | public void SendTerseUpdateToAllClients() | 3340 | public void SendTerseUpdateToAllClients() |
2885 | { | 3341 | { |
3342 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3343 | return; | ||
3344 | |||
3345 | // Update the "last" values | ||
3346 | m_lastPosition = OffsetPosition; | ||
3347 | m_lastRotation = RotationOffset; | ||
3348 | m_lastVelocity = Velocity; | ||
3349 | m_lastAcceleration = Acceleration; | ||
3350 | m_lastAngularVelocity = AngularVelocity; | ||
3351 | m_lastUpdateSentTime = Environment.TickCount; | ||
3352 | |||
2886 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | 3353 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) |
2887 | { | 3354 | { |
2888 | SendTerseUpdateToClient(client); | 3355 | SendTerseUpdateToClient(client); |
@@ -2906,10 +3373,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2906 | 3373 | ||
2907 | public void SetBuoyancy(float fvalue) | 3374 | public void SetBuoyancy(float fvalue) |
2908 | { | 3375 | { |
2909 | PhysicsActor pa = PhysActor; | 3376 | Buoyancy = fvalue; |
2910 | 3377 | /* | |
2911 | if (pa != null) | 3378 | if (PhysActor != null) |
2912 | pa.Buoyancy = fvalue; | 3379 | { |
3380 | PhysActor.Buoyancy = fvalue; | ||
3381 | } | ||
3382 | */ | ||
2913 | } | 3383 | } |
2914 | 3384 | ||
2915 | public void SetDieAtEdge(bool p) | 3385 | public void SetDieAtEdge(bool p) |
@@ -2925,47 +3395,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2925 | PhysicsActor pa = PhysActor; | 3395 | PhysicsActor pa = PhysActor; |
2926 | 3396 | ||
2927 | if (pa != null) | 3397 | if (pa != null) |
2928 | pa.FloatOnWater = floatYN == 1; | 3398 | pa.FloatOnWater = (floatYN == 1); |
2929 | } | 3399 | } |
2930 | 3400 | ||
2931 | public void SetForce(Vector3 force) | 3401 | public void SetForce(Vector3 force) |
2932 | { | 3402 | { |
2933 | PhysicsActor pa = PhysActor; | 3403 | Force = force; |
3404 | } | ||
2934 | 3405 | ||
2935 | if (pa != null) | 3406 | public SOPVehicle VehicleParams |
2936 | pa.Force = force; | 3407 | { |
3408 | get | ||
3409 | { | ||
3410 | return m_vehicleParams; | ||
3411 | } | ||
3412 | set | ||
3413 | { | ||
3414 | m_vehicleParams = value; | ||
3415 | } | ||
3416 | } | ||
3417 | |||
3418 | |||
3419 | public int VehicleType | ||
3420 | { | ||
3421 | get | ||
3422 | { | ||
3423 | if (m_vehicleParams == null) | ||
3424 | return (int)Vehicle.TYPE_NONE; | ||
3425 | else | ||
3426 | return (int)m_vehicleParams.Type; | ||
3427 | } | ||
3428 | set | ||
3429 | { | ||
3430 | SetVehicleType(value); | ||
3431 | } | ||
2937 | } | 3432 | } |
2938 | 3433 | ||
2939 | public void SetVehicleType(int type) | 3434 | public void SetVehicleType(int type) |
2940 | { | 3435 | { |
2941 | PhysicsActor pa = PhysActor; | 3436 | m_vehicleParams = null; |
3437 | |||
3438 | if (type == (int)Vehicle.TYPE_NONE) | ||
3439 | { | ||
3440 | if (_parentID ==0 && PhysActor != null) | ||
3441 | PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; | ||
3442 | return; | ||
3443 | } | ||
3444 | m_vehicleParams = new SOPVehicle(); | ||
3445 | m_vehicleParams.ProcessTypeChange((Vehicle)type); | ||
3446 | { | ||
3447 | if (_parentID ==0 && PhysActor != null) | ||
3448 | PhysActor.VehicleType = type; | ||
3449 | return; | ||
3450 | } | ||
3451 | } | ||
2942 | 3452 | ||
2943 | if (pa != null) | 3453 | public void SetVehicleFlags(int param, bool remove) |
2944 | pa.VehicleType = type; | 3454 | { |
3455 | if (m_vehicleParams == null) | ||
3456 | return; | ||
3457 | |||
3458 | m_vehicleParams.ProcessVehicleFlags(param, remove); | ||
3459 | |||
3460 | if (_parentID ==0 && PhysActor != null) | ||
3461 | { | ||
3462 | PhysActor.VehicleFlags(param, remove); | ||
3463 | } | ||
2945 | } | 3464 | } |
2946 | 3465 | ||
2947 | public void SetVehicleFloatParam(int param, float value) | 3466 | public void SetVehicleFloatParam(int param, float value) |
2948 | { | 3467 | { |
2949 | PhysicsActor pa = PhysActor; | 3468 | if (m_vehicleParams == null) |
3469 | return; | ||
2950 | 3470 | ||
2951 | if (pa != null) | 3471 | m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value); |
2952 | pa.VehicleFloatParam(param, value); | 3472 | |
3473 | if (_parentID == 0 && PhysActor != null) | ||
3474 | { | ||
3475 | PhysActor.VehicleFloatParam(param, value); | ||
3476 | } | ||
2953 | } | 3477 | } |
2954 | 3478 | ||
2955 | public void SetVehicleVectorParam(int param, Vector3 value) | 3479 | public void SetVehicleVectorParam(int param, Vector3 value) |
2956 | { | 3480 | { |
2957 | PhysicsActor pa = PhysActor; | 3481 | if (m_vehicleParams == null) |
3482 | return; | ||
2958 | 3483 | ||
2959 | if (pa != null) | 3484 | m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value); |
2960 | pa.VehicleVectorParam(param, value); | 3485 | |
3486 | if (_parentID == 0 && PhysActor != null) | ||
3487 | { | ||
3488 | PhysActor.VehicleVectorParam(param, value); | ||
3489 | } | ||
2961 | } | 3490 | } |
2962 | 3491 | ||
2963 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 3492 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
2964 | { | 3493 | { |
2965 | PhysicsActor pa = PhysActor; | 3494 | if (m_vehicleParams == null) |
3495 | return; | ||
2966 | 3496 | ||
2967 | if (pa != null) | 3497 | m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation); |
2968 | pa.VehicleRotationParam(param, rotation); | 3498 | |
3499 | if (_parentID == 0 && PhysActor != null) | ||
3500 | { | ||
3501 | PhysActor.VehicleRotationParam(param, rotation); | ||
3502 | } | ||
2969 | } | 3503 | } |
2970 | 3504 | ||
2971 | /// <summary> | 3505 | /// <summary> |
@@ -3166,14 +3700,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3166 | hasProfileCut = hasDimple; // is it the same thing? | 3700 | hasProfileCut = hasDimple; // is it the same thing? |
3167 | } | 3701 | } |
3168 | 3702 | ||
3169 | public void SetVehicleFlags(int param, bool remove) | ||
3170 | { | ||
3171 | PhysicsActor pa = PhysActor; | ||
3172 | |||
3173 | if (pa != null) | ||
3174 | pa.VehicleFlags(param, remove); | ||
3175 | } | ||
3176 | |||
3177 | public void SetGroup(UUID groupID, IClientAPI client) | 3703 | public void SetGroup(UUID groupID, IClientAPI client) |
3178 | { | 3704 | { |
3179 | // Scene.AddNewPrims() calls with client == null so can't use this. | 3705 | // Scene.AddNewPrims() calls with client == null so can't use this. |
@@ -3277,71 +3803,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3277 | { | 3803 | { |
3278 | ParentGroup.stopMoveToTarget(); | 3804 | ParentGroup.stopMoveToTarget(); |
3279 | 3805 | ||
3280 | ParentGroup.ScheduleGroupForTerseUpdate(); | 3806 | // ParentGroup.ScheduleGroupForTerseUpdate(); |
3281 | //ParentGroup.ScheduleGroupForFullUpdate(); | 3807 | //ParentGroup.ScheduleGroupForFullUpdate(); |
3282 | } | 3808 | } |
3283 | 3809 | ||
3284 | public void StoreUndoState() | 3810 | public void StoreUndoState(ObjectChangeType change) |
3285 | { | 3811 | { |
3286 | StoreUndoState(false); | 3812 | if (m_UndoRedo == null) |
3287 | } | 3813 | m_UndoRedo = new UndoRedoState(5); |
3288 | |||
3289 | public void StoreUndoState(bool forGroup) | ||
3290 | { | ||
3291 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3292 | return; | ||
3293 | |||
3294 | if (Undoing) | ||
3295 | { | ||
3296 | // m_log.DebugFormat( | ||
3297 | // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); | ||
3298 | return; | ||
3299 | } | ||
3300 | |||
3301 | if (IgnoreUndoUpdate) | ||
3302 | { | ||
3303 | // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); | ||
3304 | return; | ||
3305 | } | ||
3306 | 3814 | ||
3307 | lock (m_undo) | 3815 | lock (m_UndoRedo) |
3308 | { | 3816 | { |
3309 | if (m_undo.Count > 0) | 3817 | if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended |
3310 | { | 3818 | { |
3311 | UndoState last = m_undo[m_undo.Count - 1]; | 3819 | m_UndoRedo.StoreUndo(this, change); |
3312 | if (last != null) | ||
3313 | { | ||
3314 | // TODO: May need to fix for group comparison | ||
3315 | if (last.Compare(this)) | ||
3316 | { | ||
3317 | // m_log.DebugFormat( | ||
3318 | // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", | ||
3319 | // Name, LocalId, m_undo.Count); | ||
3320 | |||
3321 | return; | ||
3322 | } | ||
3323 | } | ||
3324 | } | ||
3325 | |||
3326 | // m_log.DebugFormat( | ||
3327 | // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", | ||
3328 | // Name, LocalId, forGroup, m_undo.Count); | ||
3329 | |||
3330 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3331 | { | ||
3332 | UndoState nUndo = new UndoState(this, forGroup); | ||
3333 | |||
3334 | m_undo.Add(nUndo); | ||
3335 | |||
3336 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3337 | m_undo.RemoveAt(0); | ||
3338 | |||
3339 | if (m_redo.Count > 0) | ||
3340 | m_redo.Clear(); | ||
3341 | |||
3342 | // m_log.DebugFormat( | ||
3343 | // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", | ||
3344 | // Name, LocalId, forGroup, m_undo.Count); | ||
3345 | } | 3820 | } |
3346 | } | 3821 | } |
3347 | } | 3822 | } |
@@ -3353,88 +3828,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
3353 | { | 3828 | { |
3354 | get | 3829 | get |
3355 | { | 3830 | { |
3356 | lock (m_undo) | 3831 | if (m_UndoRedo == null) |
3357 | return m_undo.Count; | 3832 | return 0; |
3833 | return m_UndoRedo.Count; | ||
3358 | } | 3834 | } |
3359 | } | 3835 | } |
3360 | 3836 | ||
3361 | public void Undo() | 3837 | public void Undo() |
3362 | { | 3838 | { |
3363 | lock (m_undo) | 3839 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3364 | { | 3840 | return; |
3365 | // m_log.DebugFormat( | ||
3366 | // "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}", | ||
3367 | // Name, LocalId, m_undo.Count); | ||
3368 | |||
3369 | if (m_undo.Count > 0) | ||
3370 | { | ||
3371 | UndoState goback = m_undo[m_undo.Count - 1]; | ||
3372 | m_undo.RemoveAt(m_undo.Count - 1); | ||
3373 | |||
3374 | UndoState nUndo = null; | ||
3375 | |||
3376 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3377 | { | ||
3378 | nUndo = new UndoState(this, goback.ForGroup); | ||
3379 | } | ||
3380 | |||
3381 | goback.PlaybackState(this); | ||
3382 | |||
3383 | if (nUndo != null) | ||
3384 | { | ||
3385 | m_redo.Add(nUndo); | ||
3386 | |||
3387 | if (m_redo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3388 | m_redo.RemoveAt(0); | ||
3389 | } | ||
3390 | } | ||
3391 | 3841 | ||
3392 | // m_log.DebugFormat( | 3842 | lock (m_UndoRedo) |
3393 | // "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", | 3843 | { |
3394 | // Name, LocalId, m_undo.Count); | 3844 | Undoing = true; |
3845 | m_UndoRedo.Undo(this); | ||
3846 | Undoing = false; | ||
3395 | } | 3847 | } |
3396 | } | 3848 | } |
3397 | 3849 | ||
3398 | public void Redo() | 3850 | public void Redo() |
3399 | { | 3851 | { |
3400 | lock (m_undo) | 3852 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3401 | { | 3853 | return; |
3402 | // m_log.DebugFormat( | ||
3403 | // "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}", | ||
3404 | // Name, LocalId, m_redo.Count); | ||
3405 | |||
3406 | if (m_redo.Count > 0) | ||
3407 | { | ||
3408 | UndoState gofwd = m_redo[m_redo.Count - 1]; | ||
3409 | m_redo.RemoveAt(m_redo.Count - 1); | ||
3410 | |||
3411 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3412 | { | ||
3413 | UndoState nUndo = new UndoState(this, gofwd.ForGroup); | ||
3414 | |||
3415 | m_undo.Add(nUndo); | ||
3416 | |||
3417 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3418 | m_undo.RemoveAt(0); | ||
3419 | } | ||
3420 | |||
3421 | gofwd.PlayfwdState(this); | ||
3422 | 3854 | ||
3423 | // m_log.DebugFormat( | 3855 | lock (m_UndoRedo) |
3424 | // "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", | 3856 | { |
3425 | // Name, LocalId, m_redo.Count); | 3857 | Undoing = true; |
3426 | } | 3858 | m_UndoRedo.Redo(this); |
3859 | Undoing = false; | ||
3427 | } | 3860 | } |
3428 | } | 3861 | } |
3429 | 3862 | ||
3430 | public void ClearUndoState() | 3863 | public void ClearUndoState() |
3431 | { | 3864 | { |
3432 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); | 3865 | if (m_UndoRedo == null || Undoing) |
3866 | return; | ||
3433 | 3867 | ||
3434 | lock (m_undo) | 3868 | lock (m_UndoRedo) |
3435 | { | 3869 | { |
3436 | m_undo.Clear(); | 3870 | m_UndoRedo.Clear(); |
3437 | m_redo.Clear(); | ||
3438 | } | 3871 | } |
3439 | } | 3872 | } |
3440 | 3873 | ||
@@ -3986,7 +4419,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3986 | if (god) | 4419 | if (god) |
3987 | { | 4420 | { |
3988 | BaseMask = ApplyMask(BaseMask, set, mask); | 4421 | BaseMask = ApplyMask(BaseMask, set, mask); |
3989 | Inventory.ApplyGodPermissions(_baseMask); | 4422 | Inventory.ApplyGodPermissions(BaseMask); |
3990 | } | 4423 | } |
3991 | 4424 | ||
3992 | break; | 4425 | break; |
@@ -4017,7 +4450,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4017 | } | 4450 | } |
4018 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & | 4451 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & |
4019 | baseMask; | 4452 | baseMask; |
4020 | // Prevent the client from creating no mod, no copy | 4453 | // Prevent the client from creating no copy, no transfer |
4021 | // objects | 4454 | // objects |
4022 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) | 4455 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) |
4023 | NextOwnerMask |= (uint)PermissionMask.Transfer; | 4456 | NextOwnerMask |= (uint)PermissionMask.Transfer; |
@@ -4035,20 +4468,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4035 | { | 4468 | { |
4036 | bool update = false; | 4469 | bool update = false; |
4037 | 4470 | ||
4038 | if (BaseMask != source.BaseMask || | 4471 | uint prevOwnerMask = OwnerMask; |
4039 | OwnerMask != source.OwnerMask || | 4472 | uint prevGroupMask = GroupMask; |
4040 | GroupMask != source.GroupMask || | 4473 | uint prevEveryoneMask = EveryoneMask; |
4041 | EveryoneMask != source.EveryoneMask || | 4474 | uint prevNextOwnerMask = NextOwnerMask; |
4042 | NextOwnerMask != source.NextOwnerMask) | ||
4043 | update = true; | ||
4044 | 4475 | ||
4045 | BaseMask = source.BaseMask; | 4476 | OwnerMask = source.OwnerMask & BaseMask; |
4046 | OwnerMask = source.OwnerMask; | 4477 | GroupMask = source.GroupMask & BaseMask; |
4047 | GroupMask = source.GroupMask; | 4478 | EveryoneMask = source.EveryoneMask & BaseMask; |
4048 | EveryoneMask = source.EveryoneMask; | 4479 | NextOwnerMask = source.NextOwnerMask & BaseMask; |
4049 | NextOwnerMask = source.NextOwnerMask; | ||
4050 | 4480 | ||
4051 | if (update) | 4481 | if (OwnerMask != prevOwnerMask || |
4482 | GroupMask != prevGroupMask || | ||
4483 | EveryoneMask != prevEveryoneMask || | ||
4484 | NextOwnerMask != prevNextOwnerMask) | ||
4052 | SendFullUpdateToAllClients(); | 4485 | SendFullUpdateToAllClients(); |
4053 | } | 4486 | } |
4054 | 4487 | ||
@@ -4099,6 +4532,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4099 | } | 4532 | } |
4100 | } | 4533 | } |
4101 | 4534 | ||
4535 | |||
4102 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) | 4536 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) |
4103 | { | 4537 | { |
4104 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) | 4538 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) |
@@ -4126,7 +4560,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4126 | /// <param name="SetTemporary"></param> | 4560 | /// <param name="SetTemporary"></param> |
4127 | /// <param name="SetPhantom"></param> | 4561 | /// <param name="SetPhantom"></param> |
4128 | /// <param name="SetVD"></param> | 4562 | /// <param name="SetVD"></param> |
4129 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) | 4563 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) |
4130 | { | 4564 | { |
4131 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); | 4565 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); |
4132 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); | 4566 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); |
@@ -4136,97 +4570,103 @@ namespace OpenSim.Region.Framework.Scenes | |||
4136 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) | 4570 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) |
4137 | return; | 4571 | return; |
4138 | 4572 | ||
4139 | PhysicsActor pa = PhysActor; | 4573 | VolumeDetectActive = SetVD; |
4140 | |||
4141 | // Special cases for VD. VD can only be called from a script | ||
4142 | // and can't be combined with changes to other states. So we can rely | ||
4143 | // that... | ||
4144 | // ... if VD is changed, all others are not. | ||
4145 | // ... if one of the others is changed, VD is not. | ||
4146 | if (SetVD) // VD is active, special logic applies | ||
4147 | { | ||
4148 | // State machine logic for VolumeDetect | ||
4149 | // More logic below | ||
4150 | bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; | ||
4151 | 4574 | ||
4152 | if (phanReset) // Phantom changes from on to off switch VD off too | 4575 | // volume detector implies phantom |
4153 | { | 4576 | if (VolumeDetectActive) |
4154 | SetVD = false; // Switch it of for the course of this routine | ||
4155 | VolumeDetectActive = false; // and also permanently | ||
4156 | |||
4157 | if (pa != null) | ||
4158 | pa.SetVolumeDetect(0); // Let physics know about it too | ||
4159 | } | ||
4160 | else | ||
4161 | { | ||
4162 | // If volumedetect is active we don't want phantom to be applied. | ||
4163 | // If this is a new call to VD out of the state "phantom" | ||
4164 | // this will also cause the prim to be visible to physics | ||
4165 | SetPhantom = false; | ||
4166 | } | ||
4167 | } | ||
4168 | |||
4169 | if (UsePhysics && IsJoint()) | ||
4170 | { | ||
4171 | SetPhantom = true; | 4577 | SetPhantom = true; |
4172 | } | ||
4173 | 4578 | ||
4174 | if (UsePhysics) | 4579 | if (UsePhysics) |
4175 | { | ||
4176 | AddFlag(PrimFlags.Physics); | 4580 | AddFlag(PrimFlags.Physics); |
4177 | if (!wasUsingPhysics) | ||
4178 | { | ||
4179 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4180 | } | ||
4181 | } | ||
4182 | else | 4581 | else |
4183 | { | ||
4184 | RemFlag(PrimFlags.Physics); | 4582 | RemFlag(PrimFlags.Physics); |
4185 | if (wasUsingPhysics) | ||
4186 | { | ||
4187 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4188 | } | ||
4189 | } | ||
4190 | 4583 | ||
4191 | if (SetPhantom | 4584 | if (SetPhantom) |
4192 | || ParentGroup.IsAttachment | ||
4193 | || PhysicsShapeType == (byte)PhysShapeType.none | ||
4194 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints | ||
4195 | { | ||
4196 | AddFlag(PrimFlags.Phantom); | 4585 | AddFlag(PrimFlags.Phantom); |
4586 | else | ||
4587 | RemFlag(PrimFlags.Phantom); | ||
4197 | 4588 | ||
4198 | if (PhysActor != null) | 4589 | if (SetTemporary) |
4590 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4591 | else | ||
4592 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4593 | |||
4594 | |||
4595 | if (ParentGroup.Scene == null) | ||
4596 | return; | ||
4597 | |||
4598 | PhysicsActor pa = PhysActor; | ||
4599 | |||
4600 | if (pa != null && building && pa.Building != building) | ||
4601 | pa.Building = building; | ||
4602 | |||
4603 | if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none | ||
4604 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
4605 | { | ||
4606 | if (pa != null) | ||
4199 | { | 4607 | { |
4608 | if(wasUsingPhysics) | ||
4609 | ParentGroup.Scene.RemovePhysicalPrim(1); | ||
4200 | RemoveFromPhysics(); | 4610 | RemoveFromPhysics(); |
4201 | pa = null; | ||
4202 | } | 4611 | } |
4612 | |||
4613 | Velocity = new Vector3(0, 0, 0); | ||
4614 | Acceleration = new Vector3(0, 0, 0); | ||
4615 | if (ParentGroup.RootPart == this) | ||
4616 | AngularVelocity = new Vector3(0, 0, 0); | ||
4203 | } | 4617 | } |
4204 | else // Not phantom | 4618 | |
4619 | else | ||
4205 | { | 4620 | { |
4206 | RemFlag(PrimFlags.Phantom); | 4621 | if (ParentGroup.Scene.CollidablePrims) |
4207 | |||
4208 | if (ParentGroup.Scene == null) | ||
4209 | return; | ||
4210 | |||
4211 | if (ParentGroup.Scene.CollidablePrims && pa == null) | ||
4212 | { | 4622 | { |
4213 | AddToPhysics(UsePhysics, SetPhantom, false); | 4623 | if (pa == null) |
4214 | pa = PhysActor; | 4624 | { |
4215 | 4625 | AddToPhysics(UsePhysics, SetPhantom, building, false); | |
4216 | if (pa != null) | 4626 | pa = PhysActor; |
4627 | /* | ||
4628 | if (pa != null) | ||
4629 | { | ||
4630 | if ( | ||
4631 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4632 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4633 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4634 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4635 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4636 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4637 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4638 | ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4639 | (CollisionSound != UUID.Zero) | ||
4640 | ) | ||
4641 | { | ||
4642 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4643 | pa.SubscribeEvents(1000); | ||
4644 | } | ||
4645 | } | ||
4646 | */ | ||
4647 | if (pa != null) | ||
4648 | { | ||
4649 | pa.SetMaterial(Material); | ||
4650 | DoPhysicsPropertyUpdate(UsePhysics, true); | ||
4651 | } | ||
4652 | } | ||
4653 | else // it already has a physical representation | ||
4217 | { | 4654 | { |
4218 | pa.SetMaterial(Material); | 4655 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. |
4219 | DoPhysicsPropertyUpdate(UsePhysics, true); | 4656 | /* moved into DoPhysicsPropertyUpdate |
4657 | if(VolumeDetectActive) | ||
4658 | pa.SetVolumeDetect(1); | ||
4659 | else | ||
4660 | pa.SetVolumeDetect(0); | ||
4661 | */ | ||
4220 | 4662 | ||
4221 | SubscribeForCollisionEvents(); | 4663 | if (pa.Building != building) |
4664 | pa.Building = building; | ||
4222 | } | 4665 | } |
4223 | } | ||
4224 | else // it already has a physical representation | ||
4225 | { | ||
4226 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim | ||
4227 | } | ||
4228 | } | ||
4229 | 4666 | ||
4667 | UpdatePhysicsSubscribedEvents(); | ||
4668 | } | ||
4669 | } | ||
4230 | if (SetVD) | 4670 | if (SetVD) |
4231 | { | 4671 | { |
4232 | // If the above logic worked (this is urgent candidate to unit tests!) | 4672 | // If the above logic worked (this is urgent candidate to unit tests!) |
@@ -4240,6 +4680,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4240 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 4680 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active |
4241 | VolumeDetectActive = true; | 4681 | VolumeDetectActive = true; |
4242 | } | 4682 | } |
4683 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | ||
4243 | } | 4684 | } |
4244 | else if (SetVD != wasVD) | 4685 | else if (SetVD != wasVD) |
4245 | { | 4686 | { |
@@ -4251,105 +4692,51 @@ namespace OpenSim.Region.Framework.Scenes | |||
4251 | RemFlag(PrimFlags.Phantom); | 4692 | RemFlag(PrimFlags.Phantom); |
4252 | VolumeDetectActive = false; | 4693 | VolumeDetectActive = false; |
4253 | } | 4694 | } |
4254 | 4695 | // and last in case we have a new actor and not building | |
4255 | if (SetTemporary) | ||
4256 | { | ||
4257 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4258 | } | ||
4259 | else | ||
4260 | { | ||
4261 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4262 | } | ||
4263 | |||
4264 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | ||
4265 | 4696 | ||
4266 | if (ParentGroup != null) | 4697 | if (ParentGroup != null) |
4267 | { | 4698 | { |
4268 | ParentGroup.HasGroupChanged = true; | 4699 | ParentGroup.HasGroupChanged = true; |
4269 | ScheduleFullUpdate(); | 4700 | ScheduleFullUpdate(); |
4270 | } | 4701 | } |
4271 | 4702 | ||
4272 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); | 4703 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); |
4273 | } | 4704 | } |
4274 | 4705 | ||
4275 | /// <summary> | 4706 | /// <summary> |
4276 | /// Subscribe for physics collision events if needed for scripts and sounds | ||
4277 | /// </summary> | ||
4278 | public void SubscribeForCollisionEvents() | ||
4279 | { | ||
4280 | PhysicsActor pa = PhysActor; | ||
4281 | |||
4282 | if (pa != null) | ||
4283 | { | ||
4284 | if ( | ||
4285 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4286 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4287 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4288 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4289 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4290 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4291 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4292 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4293 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4294 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4295 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4296 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4297 | (CollisionSound != UUID.Zero) | ||
4298 | ) | ||
4299 | { | ||
4300 | if (!pa.SubscribedEvents()) | ||
4301 | { | ||
4302 | // If not already subscribed for event, set up for a collision event. | ||
4303 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4304 | pa.SubscribeEvents(1000); | ||
4305 | } | ||
4306 | } | ||
4307 | else | ||
4308 | { | ||
4309 | // There is no need to be subscribed to collisions so, if subscribed, remove subscription | ||
4310 | if (pa.SubscribedEvents()) | ||
4311 | { | ||
4312 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4313 | pa.UnSubscribeEvents(); | ||
4314 | } | ||
4315 | } | ||
4316 | } | ||
4317 | } | ||
4318 | |||
4319 | /// <summary> | ||
4320 | /// Adds this part to the physics scene. | 4707 | /// Adds this part to the physics scene. |
4708 | /// and sets the PhysActor property | ||
4321 | /// </summary> | 4709 | /// </summary> |
4322 | /// <remarks>This method also sets the PhysActor property.</remarks> | 4710 | /// <param name="isPhysical">Add this prim as physical.</param> |
4323 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | 4711 | /// <param name="isPhantom">Add this prim as phantom.</param> |
4324 | /// <returns> | 4712 | /// <param name="building">tells physics to delay full construction of object</param> |
4325 | /// The physics actor. null if there was a failure. | 4713 | /// <param name="applyDynamics">applies velocities, force and torque</param> |
4326 | /// </returns> | 4714 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) |
4327 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool applyDynamics) | 4715 | { |
4328 | { | ||
4329 | PhysicsActor pa; | 4716 | PhysicsActor pa; |
4330 | 4717 | ||
4331 | Vector3 velocity = Velocity; | 4718 | Vector3 velocity = Velocity; |
4332 | Vector3 rotationalVelocity = AngularVelocity;; | 4719 | Vector3 rotationalVelocity = AngularVelocity;; |
4333 | 4720 | ||
4334 | try | 4721 | try |
4335 | { | 4722 | { |
4336 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | 4723 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( |
4337 | string.Format("{0}/{1}", Name, UUID), | 4724 | string.Format("{0}/{1}", Name, UUID), |
4338 | Shape, | 4725 | Shape, |
4339 | AbsolutePosition, | 4726 | AbsolutePosition, |
4340 | Scale, | 4727 | Scale, |
4341 | GetWorldRotation(), | 4728 | GetWorldRotation(), |
4342 | isPhysical, | 4729 | isPhysical, |
4343 | isPhantom, | 4730 | isPhantom, |
4344 | PhysicsShapeType, | 4731 | PhysicsShapeType, |
4345 | m_localId); | 4732 | m_localId); |
4346 | } | 4733 | } |
4347 | catch (Exception e) | 4734 | catch (Exception e) |
4348 | { | 4735 | { |
4349 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); | 4736 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); |
4350 | pa = null; | 4737 | pa = null; |
4351 | } | 4738 | } |
4352 | 4739 | ||
4353 | if (pa != null) | 4740 | if (pa != null) |
4354 | { | 4741 | { |
4355 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | 4742 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info |
@@ -4362,9 +4749,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4362 | 4749 | ||
4363 | if (VolumeDetectActive) // change if not the default only | 4750 | if (VolumeDetectActive) // change if not the default only |
4364 | pa.SetVolumeDetect(1); | 4751 | pa.SetVolumeDetect(1); |
4752 | |||
4753 | if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) | ||
4754 | m_vehicleParams.SetVehicle(pa); | ||
4755 | |||
4365 | // we are going to tell rest of code about physics so better have this here | 4756 | // we are going to tell rest of code about physics so better have this here |
4366 | PhysActor = pa; | 4757 | PhysActor = pa; |
4367 | 4758 | ||
4759 | // DoPhysicsPropertyUpdate(isPhysical, true); | ||
4760 | // lets expand it here just with what it really needs to do | ||
4761 | |||
4368 | if (isPhysical) | 4762 | if (isPhysical) |
4369 | { | 4763 | { |
4370 | if (ParentGroup.RootPart.KeyframeMotion != null) | 4764 | if (ParentGroup.RootPart.KeyframeMotion != null) |
@@ -4386,19 +4780,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
4386 | } | 4780 | } |
4387 | } | 4781 | } |
4388 | 4782 | ||
4389 | if (applyDynamics) | 4783 | if (applyDynamics) |
4390 | // do independent of isphysical so parameters get setted (at least some) | 4784 | // do independent of isphysical so parameters get setted (at least some) |
4391 | { | 4785 | { |
4392 | Velocity = velocity; | 4786 | Velocity = velocity; |
4393 | AngularVelocity = rotationalVelocity; | 4787 | AngularVelocity = rotationalVelocity; |
4394 | // pa.Velocity = velocity; | 4788 | // pa.Velocity = velocity; |
4395 | pa.RotationalVelocity = rotationalVelocity; | 4789 | pa.RotationalVelocity = rotationalVelocity; |
4790 | |||
4791 | // if not vehicle and root part apply force and torque | ||
4792 | if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE) | ||
4793 | && LocalId == ParentGroup.RootPart.LocalId) | ||
4794 | { | ||
4795 | pa.Force = Force; | ||
4796 | pa.Torque = Torque; | ||
4797 | } | ||
4396 | } | 4798 | } |
4397 | 4799 | ||
4398 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 4800 | // if (Shape.SculptEntry) |
4801 | // CheckSculptAndLoad(); | ||
4802 | // else | ||
4803 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
4804 | |||
4805 | if (!building) | ||
4806 | pa.Building = false; | ||
4399 | } | 4807 | } |
4400 | 4808 | ||
4401 | PhysActor = pa; | 4809 | PhysActor = pa; |
4810 | |||
4402 | ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); | 4811 | ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); |
4403 | } | 4812 | } |
4404 | 4813 | ||
@@ -4407,14 +4816,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
4407 | /// </summary> | 4816 | /// </summary> |
4408 | /// <remarks> | 4817 | /// <remarks> |
4409 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 4818 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |
4410 | /// representation for collision detection. Rather, this would be used in situations such as making a prim | 4819 | /// representation for collision detection. |
4411 | /// phantom. | ||
4412 | /// </remarks> | 4820 | /// </remarks> |
4413 | public void RemoveFromPhysics() | 4821 | public void RemoveFromPhysics() |
4414 | { | 4822 | { |
4415 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | 4823 | PhysicsActor pa = PhysActor; |
4416 | if (ParentGroup.Scene.PhysicsScene != null) | 4824 | if (pa != null) |
4417 | ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 4825 | { |
4826 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4827 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | ||
4828 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | ||
4829 | |||
4830 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | ||
4831 | |||
4832 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | ||
4833 | } | ||
4418 | PhysActor = null; | 4834 | PhysActor = null; |
4419 | } | 4835 | } |
4420 | 4836 | ||
@@ -4546,6 +4962,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4546 | { | 4962 | { |
4547 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); | 4963 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); |
4548 | 4964 | ||
4965 | return; | ||
4966 | |||
4549 | if (ParentGroup.IsDeleted) | 4967 | if (ParentGroup.IsDeleted) |
4550 | return; | 4968 | return; |
4551 | 4969 | ||
@@ -4669,6 +5087,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
4669 | } | 5087 | } |
4670 | } | 5088 | } |
4671 | 5089 | ||
5090 | |||
5091 | private void UpdatePhysicsSubscribedEvents() | ||
5092 | { | ||
5093 | PhysicsActor pa = PhysActor; | ||
5094 | if (pa == null) | ||
5095 | return; | ||
5096 | |||
5097 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5098 | |||
5099 | bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0)); | ||
5100 | |||
5101 | scriptEvents CombinedEvents = AggregateScriptEvents; | ||
5102 | |||
5103 | // merge with root part | ||
5104 | if (ParentGroup != null && ParentGroup.RootPart != null) | ||
5105 | CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents; | ||
5106 | |||
5107 | // submit to this part case | ||
5108 | if (VolumeDetectActive) | ||
5109 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | ||
5110 | else if ((Flags & PrimFlags.Phantom) != 0) | ||
5111 | CombinedEvents &= PhyscicsPhantonSubsEvents; | ||
5112 | else | ||
5113 | CombinedEvents &= PhysicsNeededSubsEvents; | ||
5114 | |||
5115 | if (hassound || CombinedEvents != 0) | ||
5116 | { | ||
5117 | // subscribe to physics updates. | ||
5118 | pa.OnCollisionUpdate += PhysicsCollision; | ||
5119 | pa.SubscribeEvents(50); // 20 reports per second | ||
5120 | } | ||
5121 | else | ||
5122 | { | ||
5123 | pa.UnSubscribeEvents(); | ||
5124 | } | ||
5125 | } | ||
5126 | |||
5127 | |||
4672 | public void aggregateScriptEvents() | 5128 | public void aggregateScriptEvents() |
4673 | { | 5129 | { |
4674 | if (ParentGroup == null || ParentGroup.RootPart == null) | 5130 | if (ParentGroup == null || ParentGroup.RootPart == null) |
@@ -4705,8 +5161,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
4705 | { | 5161 | { |
4706 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 5162 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4707 | } | 5163 | } |
4708 | 5164 | /* | |
4709 | SubscribeForCollisionEvents(); | 5165 | PhysicsActor pa = PhysActor; |
5166 | if (pa != null) | ||
5167 | { | ||
5168 | if ( | ||
5169 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
5170 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
5171 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
5172 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
5173 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
5174 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
5175 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | ||
5176 | ) | ||
5177 | { | ||
5178 | // subscribe to physics updates. | ||
5179 | pa.OnCollisionUpdate += PhysicsCollision; | ||
5180 | pa.SubscribeEvents(1000); | ||
5181 | } | ||
5182 | else | ||
5183 | { | ||
5184 | pa.UnSubscribeEvents(); | ||
5185 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5186 | } | ||
5187 | } | ||
5188 | */ | ||
5189 | UpdatePhysicsSubscribedEvents(); | ||
4710 | 5190 | ||
4711 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 5191 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4712 | //{ | 5192 | //{ |
@@ -4840,6 +5320,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4840 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 5320 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4841 | } | 5321 | } |
4842 | 5322 | ||
5323 | public void ResetOwnerChangeFlag() | ||
5324 | { | ||
5325 | List<UUID> inv = Inventory.GetInventoryList(); | ||
5326 | |||
5327 | foreach (UUID itemID in inv) | ||
5328 | { | ||
5329 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
5330 | item.OwnerChanged = false; | ||
5331 | Inventory.UpdateInventoryItem(item, false, false); | ||
5332 | } | ||
5333 | } | ||
5334 | |||
4843 | /// <summary> | 5335 | /// <summary> |
4844 | /// Record an avatar sitting on this part. | 5336 | /// Record an avatar sitting on this part. |
4845 | /// </summary> | 5337 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 3f223a3..3be0623 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 | ||
@@ -749,6 +897,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
749 | string xmlData = Utils.BytesToString(rezAsset.Data); | 897 | string xmlData = Utils.BytesToString(rezAsset.Data); |
750 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 898 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
751 | 899 | ||
900 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
901 | group.RootPart.AttachOffset = group.AbsolutePosition; | ||
902 | group.RootPart.AttachRotation = group.GroupRotation; | ||
903 | |||
752 | group.ResetIDs(); | 904 | group.ResetIDs(); |
753 | 905 | ||
754 | SceneObjectPart rootPart = group.GetPart(group.UUID); | 906 | SceneObjectPart rootPart = group.GetPart(group.UUID); |
@@ -823,8 +975,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
823 | 975 | ||
824 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) | 976 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) |
825 | { | 977 | { |
826 | TaskInventoryItem it = GetInventoryItem(item.ItemID); | 978 | m_items.LockItemsForWrite(true); |
827 | if (it != null) | 979 | |
980 | if (m_items.ContainsKey(item.ItemID)) | ||
828 | { | 981 | { |
829 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); | 982 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); |
830 | 983 | ||
@@ -837,14 +990,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
837 | item.GroupID = m_part.GroupID; | 990 | item.GroupID = m_part.GroupID; |
838 | 991 | ||
839 | if (item.AssetID == UUID.Zero) | 992 | if (item.AssetID == UUID.Zero) |
840 | item.AssetID = it.AssetID; | 993 | item.AssetID = m_items[item.ItemID].AssetID; |
841 | 994 | ||
842 | lock (m_items) | 995 | m_items[item.ItemID] = item; |
843 | { | 996 | m_inventorySerial++; |
844 | m_items[item.ItemID] = item; | ||
845 | m_inventorySerial++; | ||
846 | } | ||
847 | |||
848 | if (fireScriptEvents) | 997 | if (fireScriptEvents) |
849 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 998 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
850 | 999 | ||
@@ -853,7 +1002,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
853 | HasInventoryChanged = true; | 1002 | HasInventoryChanged = true; |
854 | m_part.ParentGroup.HasGroupChanged = true; | 1003 | m_part.ParentGroup.HasGroupChanged = true; |
855 | } | 1004 | } |
856 | 1005 | m_items.LockItemsForWrite(false); | |
857 | return true; | 1006 | return true; |
858 | } | 1007 | } |
859 | else | 1008 | else |
@@ -864,8 +1013,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
864 | item.ItemID, m_part.Name, m_part.UUID, | 1013 | item.ItemID, m_part.Name, m_part.UUID, |
865 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 1014 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
866 | } | 1015 | } |
867 | return false; | 1016 | m_items.LockItemsForWrite(false); |
868 | 1017 | ||
1018 | return false; | ||
869 | } | 1019 | } |
870 | 1020 | ||
871 | /// <summary> | 1021 | /// <summary> |
@@ -876,43 +1026,59 @@ namespace OpenSim.Region.Framework.Scenes | |||
876 | /// in this prim's inventory.</returns> | 1026 | /// in this prim's inventory.</returns> |
877 | public int RemoveInventoryItem(UUID itemID) | 1027 | public int RemoveInventoryItem(UUID itemID) |
878 | { | 1028 | { |
879 | TaskInventoryItem item = GetInventoryItem(itemID); | 1029 | m_items.LockItemsForRead(true); |
880 | if (item != null) | 1030 | |
1031 | if (m_items.ContainsKey(itemID)) | ||
881 | { | 1032 | { |
882 | int type = m_items[itemID].InvType; | 1033 | int type = m_items[itemID].InvType; |
1034 | m_items.LockItemsForRead(false); | ||
883 | if (type == 10) // Script | 1035 | if (type == 10) // Script |
884 | { | 1036 | { |
885 | m_part.RemoveScriptEvents(itemID); | ||
886 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 1037 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
887 | } | 1038 | } |
1039 | m_items.LockItemsForWrite(true); | ||
888 | m_items.Remove(itemID); | 1040 | m_items.Remove(itemID); |
1041 | m_items.LockItemsForWrite(false); | ||
889 | m_inventorySerial++; | 1042 | m_inventorySerial++; |
890 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 1043 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
891 | 1044 | ||
892 | HasInventoryChanged = true; | 1045 | HasInventoryChanged = true; |
893 | m_part.ParentGroup.HasGroupChanged = true; | 1046 | m_part.ParentGroup.HasGroupChanged = true; |
894 | 1047 | ||
895 | if (!ContainsScripts()) | 1048 | int scriptcount = 0; |
1049 | m_items.LockItemsForRead(true); | ||
1050 | foreach (TaskInventoryItem item in m_items.Values) | ||
1051 | { | ||
1052 | if (item.Type == 10) | ||
1053 | { | ||
1054 | scriptcount++; | ||
1055 | } | ||
1056 | } | ||
1057 | m_items.LockItemsForRead(false); | ||
1058 | |||
1059 | |||
1060 | if (scriptcount <= 0) | ||
1061 | { | ||
896 | m_part.RemFlag(PrimFlags.Scripted); | 1062 | m_part.RemFlag(PrimFlags.Scripted); |
1063 | } | ||
897 | 1064 | ||
898 | m_part.ScheduleFullUpdate(); | 1065 | m_part.ScheduleFullUpdate(); |
899 | 1066 | ||
900 | return type; | 1067 | return type; |
901 | |||
902 | } | 1068 | } |
903 | else | 1069 | else |
904 | { | 1070 | { |
1071 | m_items.LockItemsForRead(false); | ||
905 | m_log.ErrorFormat( | 1072 | m_log.ErrorFormat( |
906 | "[PRIM INVENTORY]: " + | 1073 | "[PRIM INVENTORY]: " + |
907 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 1074 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", |
908 | itemID, m_part.Name, m_part.UUID, | 1075 | itemID, m_part.Name, m_part.UUID); |
909 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
910 | } | 1076 | } |
911 | 1077 | ||
912 | return -1; | 1078 | return -1; |
913 | } | 1079 | } |
914 | 1080 | ||
915 | private bool CreateInventoryFile() | 1081 | private bool CreateInventoryFileName() |
916 | { | 1082 | { |
917 | // m_log.DebugFormat( | 1083 | // m_log.DebugFormat( |
918 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", | 1084 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", |
@@ -921,70 +1087,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
921 | if (m_inventoryFileName == String.Empty || | 1087 | if (m_inventoryFileName == String.Empty || |
922 | m_inventoryFileNameSerial < m_inventorySerial) | 1088 | m_inventoryFileNameSerial < m_inventorySerial) |
923 | { | 1089 | { |
924 | // Something changed, we need to create a new file | ||
925 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; | 1090 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; |
926 | m_inventoryFileNameSerial = m_inventorySerial; | 1091 | m_inventoryFileNameSerial = m_inventorySerial; |
927 | 1092 | ||
928 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | ||
929 | |||
930 | lock (m_items) | ||
931 | { | ||
932 | foreach (TaskInventoryItem item in m_items.Values) | ||
933 | { | ||
934 | // m_log.DebugFormat( | ||
935 | // "[PRIM INVENTORY]: Adding item {0} {1} for serial {2} on prim {3} {4} {5}", | ||
936 | // item.Name, item.ItemID, m_inventorySerial, m_part.Name, m_part.UUID, m_part.LocalId); | ||
937 | |||
938 | UUID ownerID = item.OwnerID; | ||
939 | uint everyoneMask = 0; | ||
940 | uint baseMask = item.BasePermissions; | ||
941 | uint ownerMask = item.CurrentPermissions; | ||
942 | uint groupMask = item.GroupPermissions; | ||
943 | |||
944 | invString.AddItemStart(); | ||
945 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | ||
946 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
947 | |||
948 | invString.AddPermissionsStart(); | ||
949 | |||
950 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | ||
951 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
952 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
953 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
954 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
955 | |||
956 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
957 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
958 | |||
959 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | ||
960 | |||
961 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | ||
962 | invString.AddSectionEnd(); | ||
963 | |||
964 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | ||
965 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | ||
966 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | ||
967 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
968 | |||
969 | invString.AddSaleStart(); | ||
970 | invString.AddNameValueLine("sale_type", "not"); | ||
971 | invString.AddNameValueLine("sale_price", "0"); | ||
972 | invString.AddSectionEnd(); | ||
973 | |||
974 | invString.AddNameValueLine("name", item.Name + "|"); | ||
975 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
976 | |||
977 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | ||
978 | invString.AddSectionEnd(); | ||
979 | } | ||
980 | } | ||
981 | |||
982 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | ||
983 | |||
984 | return true; | 1093 | return true; |
985 | } | 1094 | } |
986 | 1095 | ||
987 | // No need to recreate, the existing file is fine | ||
988 | return false; | 1096 | return false; |
989 | } | 1097 | } |
990 | 1098 | ||
@@ -994,43 +1102,110 @@ namespace OpenSim.Region.Framework.Scenes | |||
994 | /// <param name="xferManager"></param> | 1102 | /// <param name="xferManager"></param> |
995 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) | 1103 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) |
996 | { | 1104 | { |
997 | lock (m_items) | 1105 | bool changed = CreateInventoryFileName(); |
998 | { | ||
999 | // Don't send a inventory xfer name if there are no items. Doing so causes viewer 3 to crash when rezzing | ||
1000 | // a new script if any previous deletion has left the prim inventory empty. | ||
1001 | if (m_items.Count == 0) // No inventory | ||
1002 | { | ||
1003 | // m_log.DebugFormat( | ||
1004 | // "[PRIM INVENTORY]: Not sending inventory data for part {0} {1} {2} for {3} since no items", | ||
1005 | // m_part.Name, m_part.LocalId, m_part.UUID, client.Name); | ||
1006 | 1106 | ||
1007 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | 1107 | bool includeAssets = false; |
1008 | return; | 1108 | if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) |
1009 | } | 1109 | includeAssets = true; |
1110 | |||
1111 | if (m_inventoryPrivileged != includeAssets) | ||
1112 | changed = true; | ||
1113 | |||
1114 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | ||
1115 | |||
1116 | Items.LockItemsForRead(true); | ||
1117 | |||
1118 | if (m_inventorySerial == 0) // No inventory | ||
1119 | { | ||
1120 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1121 | Items.LockItemsForRead(false); | ||
1122 | return; | ||
1123 | } | ||
1010 | 1124 | ||
1011 | CreateInventoryFile(); | 1125 | if (m_items.Count == 0) // No inventory |
1126 | { | ||
1127 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1128 | Items.LockItemsForRead(false); | ||
1129 | return; | ||
1130 | } | ||
1012 | 1131 | ||
1013 | // In principle, we should only do the rest if the inventory changed; | 1132 | if (!changed) |
1014 | // by sending m_inventorySerial to the client, it ought to know | 1133 | { |
1015 | // that nothing changed and that it doesn't need to request the file. | ||
1016 | // Unfortunately, it doesn't look like the client optimizes this; | ||
1017 | // the client seems to always come back and request the Xfer, | ||
1018 | // no matter what value m_inventorySerial has. | ||
1019 | // FIXME: Could probably be > 0 here rather than > 2 | ||
1020 | if (m_inventoryFileData.Length > 2) | 1134 | if (m_inventoryFileData.Length > 2) |
1021 | { | 1135 | { |
1022 | // Add the file for Xfer | 1136 | xferManager.AddNewFile(m_inventoryFileName, |
1023 | // m_log.DebugFormat( | 1137 | m_inventoryFileData); |
1024 | // "[PRIM INVENTORY]: Adding inventory file {0} (length {1}) for transfer on {2} {3} {4}", | 1138 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, |
1025 | // m_inventoryFileName, m_inventoryFileData.Length, m_part.Name, m_part.UUID, m_part.LocalId); | 1139 | Util.StringToBytes256(m_inventoryFileName)); |
1026 | 1140 | ||
1027 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | 1141 | Items.LockItemsForRead(false); |
1142 | return; | ||
1028 | } | 1143 | } |
1029 | |||
1030 | // Tell the client we're ready to Xfer the file | ||
1031 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
1032 | Util.StringToBytes256(m_inventoryFileName)); | ||
1033 | } | 1144 | } |
1145 | |||
1146 | m_inventoryPrivileged = includeAssets; | ||
1147 | |||
1148 | foreach (TaskInventoryItem item in m_items.Values) | ||
1149 | { | ||
1150 | UUID ownerID = item.OwnerID; | ||
1151 | uint everyoneMask = 0; | ||
1152 | uint baseMask = item.BasePermissions; | ||
1153 | uint ownerMask = item.CurrentPermissions; | ||
1154 | uint groupMask = item.GroupPermissions; | ||
1155 | |||
1156 | invString.AddItemStart(); | ||
1157 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | ||
1158 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
1159 | |||
1160 | invString.AddPermissionsStart(); | ||
1161 | |||
1162 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | ||
1163 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
1164 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
1165 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
1166 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
1167 | |||
1168 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
1169 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
1170 | |||
1171 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | ||
1172 | |||
1173 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | ||
1174 | invString.AddSectionEnd(); | ||
1175 | |||
1176 | if (includeAssets) | ||
1177 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | ||
1178 | else | ||
1179 | invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); | ||
1180 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | ||
1181 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | ||
1182 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
1183 | |||
1184 | invString.AddSaleStart(); | ||
1185 | invString.AddNameValueLine("sale_type", "not"); | ||
1186 | invString.AddNameValueLine("sale_price", "0"); | ||
1187 | invString.AddSectionEnd(); | ||
1188 | |||
1189 | invString.AddNameValueLine("name", item.Name + "|"); | ||
1190 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
1191 | |||
1192 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | ||
1193 | invString.AddSectionEnd(); | ||
1194 | } | ||
1195 | |||
1196 | Items.LockItemsForRead(false); | ||
1197 | |||
1198 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | ||
1199 | |||
1200 | if (m_inventoryFileData.Length > 2) | ||
1201 | { | ||
1202 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | ||
1203 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
1204 | Util.StringToBytes256(m_inventoryFileName)); | ||
1205 | return; | ||
1206 | } | ||
1207 | |||
1208 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1034 | } | 1209 | } |
1035 | 1210 | ||
1036 | /// <summary> | 1211 | /// <summary> |
@@ -1039,13 +1214,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1039 | /// <param name="datastore"></param> | 1214 | /// <param name="datastore"></param> |
1040 | public void ProcessInventoryBackup(ISimulationDataService datastore) | 1215 | public void ProcessInventoryBackup(ISimulationDataService datastore) |
1041 | { | 1216 | { |
1042 | if (HasInventoryChanged) | 1217 | // Removed this because linking will cause an immediate delete of the new |
1043 | { | 1218 | // child prim from the database and the subsequent storing of the prim sees |
1044 | HasInventoryChanged = false; | 1219 | // the inventory of it as unchanged and doesn't store it at all. The overhead |
1045 | List<TaskInventoryItem> items = GetInventoryItems(); | 1220 | // of storing prim inventory needlessly is much less than the aggravation |
1046 | datastore.StorePrimInventory(m_part.UUID, items); | 1221 | // of prim inventory loss. |
1222 | // if (HasInventoryChanged) | ||
1223 | // { | ||
1224 | Items.LockItemsForRead(true); | ||
1225 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | ||
1226 | Items.LockItemsForRead(false); | ||
1047 | 1227 | ||
1048 | } | 1228 | HasInventoryChanged = false; |
1229 | // } | ||
1049 | } | 1230 | } |
1050 | 1231 | ||
1051 | public class InventoryStringBuilder | 1232 | public class InventoryStringBuilder |
@@ -1111,87 +1292,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
1111 | { | 1292 | { |
1112 | uint mask=0x7fffffff; | 1293 | uint mask=0x7fffffff; |
1113 | 1294 | ||
1114 | lock (m_items) | 1295 | foreach (TaskInventoryItem item in m_items.Values) |
1115 | { | 1296 | { |
1116 | foreach (TaskInventoryItem item in m_items.Values) | 1297 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) |
1298 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1299 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1300 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1301 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1302 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1303 | |||
1304 | if (item.InvType == (int)InventoryType.Object) | ||
1117 | { | 1305 | { |
1118 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | 1306 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1119 | mask &= ~((uint)PermissionMask.Copy >> 13); | 1307 | mask &= ~((uint)PermissionMask.Copy >> 13); |
1120 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | 1308 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1121 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1309 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
1122 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | 1310 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1123 | mask &= ~((uint)PermissionMask.Modify >> 13); | 1311 | mask &= ~((uint)PermissionMask.Modify >> 13); |
1124 | |||
1125 | if (item.InvType != (int)InventoryType.Object) | ||
1126 | { | ||
1127 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | ||
1128 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1129 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1130 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1131 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1132 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1133 | } | ||
1134 | else | ||
1135 | { | ||
1136 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1137 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1138 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1139 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1140 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1141 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1142 | } | ||
1143 | |||
1144 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1145 | mask &= ~(uint)PermissionMask.Copy; | ||
1146 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1147 | mask &= ~(uint)PermissionMask.Transfer; | ||
1148 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1149 | mask &= ~(uint)PermissionMask.Modify; | ||
1150 | } | 1312 | } |
1313 | |||
1314 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1315 | mask &= ~(uint)PermissionMask.Copy; | ||
1316 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1317 | mask &= ~(uint)PermissionMask.Transfer; | ||
1318 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1319 | mask &= ~(uint)PermissionMask.Modify; | ||
1151 | } | 1320 | } |
1152 | |||
1153 | return mask; | 1321 | return mask; |
1154 | } | 1322 | } |
1155 | 1323 | ||
1156 | public void ApplyNextOwnerPermissions() | 1324 | public void ApplyNextOwnerPermissions() |
1157 | { | 1325 | { |
1158 | lock (m_items) | 1326 | foreach (TaskInventoryItem item in m_items.Values) |
1159 | { | 1327 | { |
1160 | foreach (TaskInventoryItem item in m_items.Values) | 1328 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) |
1161 | { | 1329 | { |
1162 | // m_log.DebugFormat ( | 1330 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1163 | // "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", | 1331 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |
1164 | // item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); | 1332 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1165 | 1333 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | |
1166 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) | 1334 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1167 | { | 1335 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
1168 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1169 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | ||
1170 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1171 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | ||
1172 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1173 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | ||
1174 | } | ||
1175 | |||
1176 | item.CurrentPermissions &= item.NextPermissions; | ||
1177 | item.BasePermissions &= item.NextPermissions; | ||
1178 | item.EveryonePermissions &= item.NextPermissions; | ||
1179 | item.OwnerChanged = true; | ||
1180 | item.PermsMask = 0; | ||
1181 | item.PermsGranter = UUID.Zero; | ||
1182 | } | 1336 | } |
1337 | item.CurrentPermissions &= item.NextPermissions; | ||
1338 | item.BasePermissions &= item.NextPermissions; | ||
1339 | item.EveryonePermissions &= item.NextPermissions; | ||
1340 | item.OwnerChanged = true; | ||
1341 | item.PermsMask = 0; | ||
1342 | item.PermsGranter = UUID.Zero; | ||
1183 | } | 1343 | } |
1184 | } | 1344 | } |
1185 | 1345 | ||
1186 | public void ApplyGodPermissions(uint perms) | 1346 | public void ApplyGodPermissions(uint perms) |
1187 | { | 1347 | { |
1188 | lock (m_items) | 1348 | foreach (TaskInventoryItem item in m_items.Values) |
1189 | { | 1349 | { |
1190 | foreach (TaskInventoryItem item in m_items.Values) | 1350 | item.CurrentPermissions = perms; |
1191 | { | 1351 | item.BasePermissions = perms; |
1192 | item.CurrentPermissions = perms; | ||
1193 | item.BasePermissions = perms; | ||
1194 | } | ||
1195 | } | 1352 | } |
1196 | 1353 | ||
1197 | m_inventorySerial++; | 1354 | m_inventorySerial++; |
@@ -1204,14 +1361,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1204 | /// <returns></returns> | 1361 | /// <returns></returns> |
1205 | public bool ContainsScripts() | 1362 | public bool ContainsScripts() |
1206 | { | 1363 | { |
1207 | lock (m_items) | 1364 | foreach (TaskInventoryItem item in m_items.Values) |
1208 | { | 1365 | { |
1209 | foreach (TaskInventoryItem item in m_items.Values) | 1366 | if (item.InvType == (int)InventoryType.LSL) |
1210 | { | 1367 | { |
1211 | if (item.InvType == (int)InventoryType.LSL) | 1368 | return true; |
1212 | { | ||
1213 | return true; | ||
1214 | } | ||
1215 | } | 1369 | } |
1216 | } | 1370 | } |
1217 | 1371 | ||
@@ -1225,17 +1379,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1225 | public int ScriptCount() | 1379 | public int ScriptCount() |
1226 | { | 1380 | { |
1227 | int count = 0; | 1381 | int count = 0; |
1228 | lock (m_items) | 1382 | Items.LockItemsForRead(true); |
1383 | foreach (TaskInventoryItem item in m_items.Values) | ||
1229 | { | 1384 | { |
1230 | foreach (TaskInventoryItem item in m_items.Values) | 1385 | if (item.InvType == (int)InventoryType.LSL) |
1231 | { | 1386 | { |
1232 | if (item.InvType == (int)InventoryType.LSL) | 1387 | count++; |
1233 | { | ||
1234 | count++; | ||
1235 | } | ||
1236 | } | 1388 | } |
1237 | } | 1389 | } |
1238 | 1390 | Items.LockItemsForRead(false); | |
1239 | return count; | 1391 | return count; |
1240 | } | 1392 | } |
1241 | /// <summary> | 1393 | /// <summary> |
@@ -1271,11 +1423,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1271 | { | 1423 | { |
1272 | List<UUID> ret = new List<UUID>(); | 1424 | List<UUID> ret = new List<UUID>(); |
1273 | 1425 | ||
1274 | lock (m_items) | 1426 | foreach (TaskInventoryItem item in m_items.Values) |
1275 | { | 1427 | ret.Add(item.ItemID); |
1276 | foreach (TaskInventoryItem item in m_items.Values) | ||
1277 | ret.Add(item.ItemID); | ||
1278 | } | ||
1279 | 1428 | ||
1280 | return ret; | 1429 | return ret; |
1281 | } | 1430 | } |
@@ -1284,8 +1433,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1284 | { | 1433 | { |
1285 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1434 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1286 | 1435 | ||
1287 | lock (m_items) | 1436 | Items.LockItemsForRead(true); |
1288 | ret = new List<TaskInventoryItem>(m_items.Values); | 1437 | ret = new List<TaskInventoryItem>(m_items.Values); |
1438 | Items.LockItemsForRead(false); | ||
1289 | 1439 | ||
1290 | return ret; | 1440 | return ret; |
1291 | } | 1441 | } |
@@ -1294,18 +1444,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1294 | { | 1444 | { |
1295 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1445 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1296 | 1446 | ||
1297 | lock (m_items) | 1447 | Items.LockItemsForRead(true); |
1298 | { | 1448 | |
1299 | foreach (TaskInventoryItem item in m_items.Values) | 1449 | foreach (TaskInventoryItem item in m_items.Values) |
1300 | if (item.InvType == (int)type) | 1450 | if (item.InvType == (int)type) |
1301 | ret.Add(item); | 1451 | ret.Add(item); |
1302 | } | 1452 | |
1453 | Items.LockItemsForRead(false); | ||
1303 | 1454 | ||
1304 | return ret; | 1455 | return ret; |
1305 | } | 1456 | } |
1306 | 1457 | ||
1307 | public Dictionary<UUID, string> GetScriptStates() | 1458 | public Dictionary<UUID, string> GetScriptStates() |
1308 | { | 1459 | { |
1460 | return GetScriptStates(false); | ||
1461 | } | ||
1462 | |||
1463 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1464 | { | ||
1309 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1465 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
1310 | 1466 | ||
1311 | if (m_part.ParentGroup.Scene == null) // Group not in a scene | 1467 | if (m_part.ParentGroup.Scene == null) // Group not in a scene |
@@ -1331,14 +1487,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1331 | string n = e.GetXMLState(item.ItemID); | 1487 | string n = e.GetXMLState(item.ItemID); |
1332 | if (n != String.Empty) | 1488 | if (n != String.Empty) |
1333 | { | 1489 | { |
1334 | if (!ret.ContainsKey(item.ItemID)) | 1490 | if (oldIDs) |
1335 | ret[item.ItemID] = n; | 1491 | { |
1492 | if (!ret.ContainsKey(item.OldItemID)) | ||
1493 | ret[item.OldItemID] = n; | ||
1494 | } | ||
1495 | else | ||
1496 | { | ||
1497 | if (!ret.ContainsKey(item.ItemID)) | ||
1498 | ret[item.ItemID] = n; | ||
1499 | } | ||
1336 | break; | 1500 | break; |
1337 | } | 1501 | } |
1338 | } | 1502 | } |
1339 | } | 1503 | } |
1340 | } | 1504 | } |
1341 | |||
1342 | return ret; | 1505 | return ret; |
1343 | } | 1506 | } |
1344 | 1507 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b4e8f09..88ecda2 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -65,6 +65,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
65 | 65 | ||
66 | struct ScriptControllers | 66 | struct ScriptControllers |
67 | { | 67 | { |
68 | public UUID objectID; | ||
68 | public UUID itemID; | 69 | public UUID itemID; |
69 | public ScriptControlled ignoreControls; | 70 | public ScriptControlled ignoreControls; |
70 | public ScriptControlled eventControls; | 71 | public ScriptControlled eventControls; |
@@ -120,7 +121,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
120 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 121 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
121 | /// issue #1716 | 122 | /// issue #1716 |
122 | /// </summary> | 123 | /// </summary> |
123 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | 124 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); |
124 | 125 | ||
125 | /// <summary> | 126 | /// <summary> |
126 | /// Movement updates for agents in neighboring regions are sent directly to clients. | 127 | /// Movement updates for agents in neighboring regions are sent directly to clients. |
@@ -142,8 +143,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
142 | /// <remarks> | 143 | /// <remarks> |
143 | /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is | 144 | /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is |
144 | /// necessary. | 145 | /// necessary. |
145 | /// NOTE: To avoid deadlocks, do not lock m_attachments and then perform other tasks under that lock. Take a copy | ||
146 | /// of the list and act on that instead. | ||
147 | /// </remarks> | 146 | /// </remarks> |
148 | private List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); | 147 | private List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); |
149 | 148 | ||
@@ -162,6 +161,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
162 | private Vector3 m_lastPosition; | 161 | private Vector3 m_lastPosition; |
163 | private Quaternion m_lastRotation; | 162 | private Quaternion m_lastRotation; |
164 | private Vector3 m_lastVelocity; | 163 | private Vector3 m_lastVelocity; |
164 | private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); | ||
165 | |||
166 | private bool m_followCamAuto = false; | ||
167 | |||
165 | 168 | ||
166 | private Vector3? m_forceToApply; | 169 | private Vector3? m_forceToApply; |
167 | private int m_userFlags; | 170 | private int m_userFlags; |
@@ -194,6 +197,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
194 | // private int m_lastColCount = -1; //KF: Look for Collision chnages | 197 | // private int m_lastColCount = -1; //KF: Look for Collision chnages |
195 | // private int m_updateCount = 0; //KF: Update Anims for a while | 198 | // private int m_updateCount = 0; //KF: Update Anims for a while |
196 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 199 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
200 | private List<uint> m_lastColliders = new List<uint>(); | ||
197 | 201 | ||
198 | private TeleportFlags m_teleportFlags; | 202 | private TeleportFlags m_teleportFlags; |
199 | public TeleportFlags TeleportFlags | 203 | public TeleportFlags TeleportFlags |
@@ -249,8 +253,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
249 | /// </summary> | 253 | /// </summary> |
250 | public bool LandAtTarget { get; private set; } | 254 | public bool LandAtTarget { get; private set; } |
251 | 255 | ||
252 | private bool m_followCamAuto; | ||
253 | |||
254 | private int m_movementUpdateCount; | 256 | private int m_movementUpdateCount; |
255 | private const int NumMovementsBetweenRayCast = 5; | 257 | private const int NumMovementsBetweenRayCast = 5; |
256 | 258 | ||
@@ -258,6 +260,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
258 | //private int m_moveToPositionStateStatus; | 260 | //private int m_moveToPositionStateStatus; |
259 | //***************************************************** | 261 | //***************************************************** |
260 | 262 | ||
263 | private bool m_collisionEventFlag = false; | ||
264 | private object m_collisionEventLock = new Object(); | ||
265 | |||
266 | private int m_movementAnimationUpdateCounter = 0; | ||
267 | |||
268 | private Vector3 m_prevSitOffset; | ||
269 | |||
261 | protected AvatarAppearance m_appearance; | 270 | protected AvatarAppearance m_appearance; |
262 | 271 | ||
263 | public AvatarAppearance Appearance | 272 | public AvatarAppearance Appearance |
@@ -386,6 +395,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
386 | /// </summary> | 395 | /// </summary> |
387 | protected Vector3 m_lastCameraPosition; | 396 | protected Vector3 m_lastCameraPosition; |
388 | 397 | ||
398 | private Vector4 m_lastCameraCollisionPlane = new Vector4(0f, 0f, 0f, 1); | ||
399 | private bool m_doingCamRayCast = false; | ||
400 | |||
389 | public Vector3 CameraPosition { get; set; } | 401 | public Vector3 CameraPosition { get; set; } |
390 | 402 | ||
391 | public Quaternion CameraRotation | 403 | public Quaternion CameraRotation |
@@ -466,7 +478,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
466 | get { return (IClientCore)ControllingClient; } | 478 | get { return (IClientCore)ControllingClient; } |
467 | } | 479 | } |
468 | 480 | ||
469 | public Vector3 ParentPosition { get; set; } | 481 | public UUID COF { get; set; } |
482 | |||
483 | // public Vector3 ParentPosition { get; set; } | ||
470 | 484 | ||
471 | /// <summary> | 485 | /// <summary> |
472 | /// Position of this avatar relative to the region the avatar is in | 486 | /// Position of this avatar relative to the region the avatar is in |
@@ -527,7 +541,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
527 | if (ParentID == 0) | 541 | if (ParentID == 0) |
528 | { | 542 | { |
529 | m_pos = value; | 543 | m_pos = value; |
530 | ParentPosition = Vector3.Zero; | 544 | // ParentPosition = Vector3.Zero; |
531 | } | 545 | } |
532 | 546 | ||
533 | //m_log.DebugFormat( | 547 | //m_log.DebugFormat( |
@@ -596,7 +610,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
596 | // Scene.RegionInfo.RegionName, Name, m_velocity); | 610 | // Scene.RegionInfo.RegionName, Name, m_velocity); |
597 | } | 611 | } |
598 | } | 612 | } |
613 | /* | ||
614 | public override Vector3 AngularVelocity | ||
615 | { | ||
616 | get | ||
617 | { | ||
618 | if (PhysicsActor != null) | ||
619 | { | ||
620 | m_rotationalvelocity = PhysicsActor.RotationalVelocity; | ||
599 | 621 | ||
622 | // m_log.DebugFormat( | ||
623 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", | ||
624 | // m_velocity, Name, Scene.RegionInfo.RegionName); | ||
625 | } | ||
626 | |||
627 | return m_rotationalvelocity; | ||
628 | } | ||
629 | } | ||
630 | */ | ||
600 | private Quaternion m_bodyRot = Quaternion.Identity; | 631 | private Quaternion m_bodyRot = Quaternion.Identity; |
601 | 632 | ||
602 | /// <summary> | 633 | /// <summary> |
@@ -619,8 +650,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
619 | m_bodyRot = value; | 650 | m_bodyRot = value; |
620 | 651 | ||
621 | if (PhysicsActor != null) | 652 | if (PhysicsActor != null) |
622 | PhysicsActor.Orientation = m_bodyRot; | 653 | { |
623 | 654 | try | |
655 | { | ||
656 | PhysicsActor.Orientation = m_bodyRot; | ||
657 | } | ||
658 | catch (Exception e) | ||
659 | { | ||
660 | m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); | ||
661 | } | ||
662 | } | ||
624 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | 663 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); |
625 | } | 664 | } |
626 | } | 665 | } |
@@ -634,12 +673,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
634 | } | 673 | } |
635 | 674 | ||
636 | public bool IsChildAgent { get; set; } | 675 | public bool IsChildAgent { get; set; } |
676 | public bool IsLoggingIn { get; set; } | ||
637 | 677 | ||
638 | /// <summary> | 678 | /// <summary> |
639 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. | 679 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. |
640 | /// </summary> | 680 | /// </summary> |
641 | public uint ParentID { get; set; } | 681 | public uint ParentID { get; set; } |
642 | 682 | ||
683 | public UUID ParentUUID | ||
684 | { | ||
685 | get { return m_parentUUID; } | ||
686 | set { m_parentUUID = value; } | ||
687 | } | ||
688 | private UUID m_parentUUID = UUID.Zero; | ||
689 | |||
643 | /// <summary> | 690 | /// <summary> |
644 | /// Are we sitting on an object? | 691 | /// Are we sitting on an object? |
645 | /// </summary> | 692 | /// </summary> |
@@ -789,6 +836,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
789 | AttachmentsSyncLock = new Object(); | 836 | AttachmentsSyncLock = new Object(); |
790 | AllowMovement = true; | 837 | AllowMovement = true; |
791 | IsChildAgent = true; | 838 | IsChildAgent = true; |
839 | IsLoggingIn = false; | ||
792 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; | 840 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; |
793 | Animator = new ScenePresenceAnimator(this); | 841 | Animator = new ScenePresenceAnimator(this); |
794 | PresenceType = type; | 842 | PresenceType = type; |
@@ -834,6 +882,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
834 | m_stateMachine = new ScenePresenceStateMachine(this); | 882 | m_stateMachine = new ScenePresenceStateMachine(this); |
835 | } | 883 | } |
836 | 884 | ||
885 | private void RegionHeartbeatEnd(Scene scene) | ||
886 | { | ||
887 | if (IsChildAgent) | ||
888 | return; | ||
889 | |||
890 | m_movementAnimationUpdateCounter ++; | ||
891 | if (m_movementAnimationUpdateCounter >= 2) | ||
892 | { | ||
893 | m_movementAnimationUpdateCounter = 0; | ||
894 | if (Animator != null) | ||
895 | { | ||
896 | // If the parentID == 0 we are not sitting | ||
897 | // if !SitGournd then we are not sitting on the ground | ||
898 | // Fairly straightforward, now here comes the twist | ||
899 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
900 | // be sat on an object that isn't there yet. Should | ||
901 | // be treated as if sat. | ||
902 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
903 | Animator.UpdateMovementAnimations(); | ||
904 | } | ||
905 | else | ||
906 | { | ||
907 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
908 | } | ||
909 | } | ||
910 | } | ||
911 | |||
837 | public void RegisterToEvents() | 912 | public void RegisterToEvents() |
838 | { | 913 | { |
839 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 914 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -844,8 +919,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
844 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 919 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
845 | ControllingClient.OnStartAnim += HandleStartAnim; | 920 | ControllingClient.OnStartAnim += HandleStartAnim; |
846 | ControllingClient.OnStopAnim += HandleStopAnim; | 921 | ControllingClient.OnStopAnim += HandleStopAnim; |
922 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
847 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 923 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
848 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 924 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
925 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
849 | 926 | ||
850 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 927 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
851 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 928 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -904,6 +981,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
904 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 981 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
905 | Name, m_scene.RegionInfo.RegionName); | 982 | Name, m_scene.RegionInfo.RegionName); |
906 | 983 | ||
984 | if (ParentUUID != UUID.Zero) | ||
985 | { | ||
986 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
987 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
988 | if (part == null) | ||
989 | { | ||
990 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
991 | } | ||
992 | else | ||
993 | { | ||
994 | part.ParentGroup.AddAvatar(UUID); | ||
995 | if (part.SitTargetPosition != Vector3.Zero) | ||
996 | part.SitTargetAvatar = UUID; | ||
997 | // ParentPosition = part.GetWorldPosition(); | ||
998 | ParentID = part.LocalId; | ||
999 | ParentPart = part; | ||
1000 | m_pos = m_prevSitOffset; | ||
1001 | // pos = ParentPosition; | ||
1002 | pos = part.GetWorldPosition(); | ||
1003 | } | ||
1004 | ParentUUID = UUID.Zero; | ||
1005 | |||
1006 | IsChildAgent = false; | ||
1007 | |||
1008 | // Animator.TrySetMovementAnimation("SIT"); | ||
1009 | } | ||
1010 | else | ||
1011 | { | ||
1012 | IsChildAgent = false; | ||
1013 | IsLoggingIn = false; | ||
1014 | } | ||
1015 | |||
907 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | 1016 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); |
908 | 1017 | ||
909 | IsChildAgent = false; | 1018 | IsChildAgent = false; |
@@ -921,70 +1030,106 @@ namespace OpenSim.Region.Framework.Scenes | |||
921 | 1030 | ||
922 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 1031 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
923 | 1032 | ||
924 | // Moved this from SendInitialData to ensure that Appearance is initialized | 1033 | UUID groupUUID = UUID.Zero; |
925 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | 1034 | string GroupName = string.Empty; |
926 | // related to the handling of attachments | 1035 | ulong groupPowers = 0; |
927 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
928 | 1036 | ||
929 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | 1037 | // ---------------------------------- |
1038 | // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status | ||
1039 | try | ||
930 | { | 1040 | { |
931 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 1041 | if (gm != null) |
932 | pos.X = crossedBorder.BorderLine.Z - 1; | 1042 | { |
1043 | groupUUID = ControllingClient.ActiveGroupId; | ||
1044 | GroupRecord record = gm.GetGroupRecord(groupUUID); | ||
1045 | if (record != null) | ||
1046 | GroupName = record.GroupName; | ||
1047 | GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); | ||
1048 | if (groupMembershipData != null) | ||
1049 | groupPowers = groupMembershipData.GroupPowers; | ||
1050 | } | ||
1051 | ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, | ||
1052 | Grouptitle); | ||
933 | } | 1053 | } |
934 | 1054 | catch (Exception e) | |
935 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | ||
936 | { | 1055 | { |
937 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 1056 | m_log.Debug("[AGENTUPDATE]: " + e.ToString()); |
938 | pos.Y = crossedBorder.BorderLine.Z - 1; | ||
939 | } | 1057 | } |
1058 | // ------------------------------------ | ||
940 | 1059 | ||
941 | CheckAndAdjustLandingPoint(ref pos); | 1060 | if (ParentID == 0) |
942 | |||
943 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | ||
944 | { | 1061 | { |
945 | m_log.WarnFormat( | 1062 | // Moved this from SendInitialData to ensure that Appearance is initialized |
946 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 1063 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
947 | pos, Name, UUID); | 1064 | // related to the handling of attachments |
1065 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
1066 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
1067 | { | ||
1068 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
1069 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
1070 | } | ||
948 | 1071 | ||
949 | if (pos.X < 0f) pos.X = 0f; | 1072 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
950 | if (pos.Y < 0f) pos.Y = 0f; | 1073 | { |
951 | if (pos.Z < 0f) pos.Z = 0f; | 1074 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
952 | } | 1075 | pos.Y = crossedBorder.BorderLine.Z - 1; |
1076 | } | ||
953 | 1077 | ||
954 | float localAVHeight = 1.56f; | 1078 | CheckAndAdjustLandingPoint(ref pos); |
955 | if (Appearance.AvatarHeight > 0) | ||
956 | localAVHeight = Appearance.AvatarHeight; | ||
957 | 1079 | ||
958 | float posZLimit = 0; | 1080 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
1081 | { | ||
1082 | m_log.WarnFormat( | ||
1083 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | ||
1084 | pos, Name, UUID); | ||
959 | 1085 | ||
960 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 1086 | if (pos.X < 0f) pos.X = 0f; |
961 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 1087 | if (pos.Y < 0f) pos.Y = 0f; |
962 | 1088 | if (pos.Z < 0f) pos.Z = 0f; | |
963 | float newPosZ = posZLimit + localAVHeight / 2; | 1089 | } |
964 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
965 | { | ||
966 | pos.Z = newPosZ; | ||
967 | } | ||
968 | AbsolutePosition = pos; | ||
969 | 1090 | ||
970 | AddToPhysicalScene(isFlying); | 1091 | float localAVHeight = 1.56f; |
1092 | if (Appearance.AvatarHeight > 0) | ||
1093 | localAVHeight = Appearance.AvatarHeight; | ||
971 | 1094 | ||
972 | // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a | 1095 | float posZLimit = 0; |
973 | // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it | ||
974 | // since it requires a physics actor to be present. If it is left any later, then physics appears to reset | ||
975 | // the value to a negative position which does not trigger the border cross. | ||
976 | // This may not be the best location for this. | ||
977 | CheckForBorderCrossing(); | ||
978 | 1096 | ||
979 | if (ForceFly) | 1097 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
980 | { | 1098 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
981 | Flying = true; | 1099 | |
982 | } | 1100 | float newPosZ = posZLimit + localAVHeight / 2; |
983 | else if (FlyDisabled) | 1101 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
984 | { | 1102 | { |
985 | Flying = false; | 1103 | pos.Z = newPosZ; |
986 | } | 1104 | } |
1105 | AbsolutePosition = pos; | ||
1106 | |||
1107 | if (m_teleportFlags == TeleportFlags.Default) | ||
1108 | { | ||
1109 | Vector3 vel = Velocity; | ||
1110 | AddToPhysicalScene(isFlying); | ||
1111 | if (PhysicsActor != null) | ||
1112 | PhysicsActor.SetMomentum(vel); | ||
1113 | } | ||
1114 | else | ||
1115 | AddToPhysicalScene(isFlying); | ||
1116 | |||
1117 | // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a | ||
1118 | // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it | ||
1119 | // since it requires a physics actor to be present. If it is left any later, then physics appears to reset | ||
1120 | // the value to a negative position which does not trigger the border cross. | ||
1121 | // This may not be the best location for this. | ||
1122 | CheckForBorderCrossing(); | ||
987 | 1123 | ||
1124 | if (ForceFly) | ||
1125 | { | ||
1126 | Flying = true; | ||
1127 | } | ||
1128 | else if (FlyDisabled) | ||
1129 | { | ||
1130 | Flying = false; | ||
1131 | } | ||
1132 | } | ||
988 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 1133 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
989 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 1134 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
990 | // elsewhere anyway | 1135 | // elsewhere anyway |
@@ -1016,31 +1161,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1016 | // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently | 1161 | // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently |
1017 | // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are | 1162 | // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are |
1018 | // not transporting the required data. | 1163 | // not transporting the required data. |
1019 | // | 1164 | lock (m_attachments) |
1020 | // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of | ||
1021 | // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here | ||
1022 | // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status. | ||
1023 | // | ||
1024 | // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts(). | ||
1025 | // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing | ||
1026 | // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the | ||
1027 | // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine. | ||
1028 | List<SceneObjectGroup> attachments = GetAttachments(); | ||
1029 | |||
1030 | if (attachments.Count > 0) | ||
1031 | { | 1165 | { |
1032 | m_log.DebugFormat( | 1166 | if (HasAttachments()) |
1033 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | ||
1034 | |||
1035 | // Resume scripts | ||
1036 | foreach (SceneObjectGroup sog in attachments) | ||
1037 | { | 1167 | { |
1038 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 1168 | m_log.DebugFormat( |
1039 | sog.ResumeScripts(); | 1169 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); |
1170 | |||
1171 | // Resume scripts | ||
1172 | Util.FireAndForget(delegate(object x) { | ||
1173 | foreach (SceneObjectGroup sog in m_attachments) | ||
1174 | { | ||
1175 | sog.ScheduleGroupForFullUpdate(); | ||
1176 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | ||
1177 | sog.ResumeScripts(); | ||
1178 | } | ||
1179 | }); | ||
1040 | } | 1180 | } |
1041 | } | 1181 | } |
1042 | } | 1182 | } |
1043 | 1183 | ||
1184 | SendAvatarDataToAllAgents(); | ||
1185 | |||
1044 | // send the animations of the other presences to me | 1186 | // send the animations of the other presences to me |
1045 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 1187 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
1046 | { | 1188 | { |
@@ -1051,6 +1193,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1051 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1193 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
1052 | // stall on the border crossing since the existing child agent will still have the last movement | 1194 | // stall on the border crossing since the existing child agent will still have the last movement |
1053 | // recorded, which stops the input from being processed. | 1195 | // recorded, which stops the input from being processed. |
1196 | |||
1054 | MovementFlag = 0; | 1197 | MovementFlag = 0; |
1055 | 1198 | ||
1056 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1199 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
@@ -1082,12 +1225,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1082 | /// </remarks> | 1225 | /// </remarks> |
1083 | public void MakeChildAgent() | 1226 | public void MakeChildAgent() |
1084 | { | 1227 | { |
1228 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1229 | |||
1085 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1230 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
1086 | 1231 | ||
1087 | // Reset these so that teleporting in and walking out isn't seen | 1232 | // Reset these so that teleporting in and walking out isn't seen |
1088 | // as teleporting back | 1233 | // as teleporting back |
1089 | TeleportFlags = TeleportFlags.Default; | 1234 | TeleportFlags = TeleportFlags.Default; |
1090 | 1235 | ||
1236 | MovementFlag = 0; | ||
1237 | |||
1091 | // It looks like Animator is set to null somewhere, and MakeChild | 1238 | // It looks like Animator is set to null somewhere, and MakeChild |
1092 | // is called after that. Probably in aborted teleports. | 1239 | // is called after that. Probably in aborted teleports. |
1093 | if (Animator == null) | 1240 | if (Animator == null) |
@@ -1095,6 +1242,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1095 | else | 1242 | else |
1096 | Animator.ResetAnimations(); | 1243 | Animator.ResetAnimations(); |
1097 | 1244 | ||
1245 | |||
1098 | // m_log.DebugFormat( | 1246 | // m_log.DebugFormat( |
1099 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1247 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
1100 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1248 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -1106,6 +1254,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1106 | IsChildAgent = true; | 1254 | IsChildAgent = true; |
1107 | m_scene.SwapRootAgentCount(true); | 1255 | m_scene.SwapRootAgentCount(true); |
1108 | RemoveFromPhysicalScene(); | 1256 | RemoveFromPhysicalScene(); |
1257 | ParentID = 0; // Child agents can't be sitting | ||
1109 | 1258 | ||
1110 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1259 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
1111 | 1260 | ||
@@ -1121,9 +1270,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1121 | { | 1270 | { |
1122 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1271 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
1123 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1272 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
1124 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1125 | PhysicsActor.UnSubscribeEvents(); | ||
1126 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1273 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1274 | PhysicsActor.UnSubscribeEvents(); | ||
1275 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1127 | PhysicsActor = null; | 1276 | PhysicsActor = null; |
1128 | } | 1277 | } |
1129 | // else | 1278 | // else |
@@ -1140,7 +1289,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1140 | /// <param name="pos"></param> | 1289 | /// <param name="pos"></param> |
1141 | public void Teleport(Vector3 pos) | 1290 | public void Teleport(Vector3 pos) |
1142 | { | 1291 | { |
1143 | TeleportWithMomentum(pos, null); | 1292 | TeleportWithMomentum(pos, Vector3.Zero); |
1144 | } | 1293 | } |
1145 | 1294 | ||
1146 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1295 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1164,6 +1313,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1164 | SendTerseUpdateToAllClients(); | 1313 | SendTerseUpdateToAllClients(); |
1165 | } | 1314 | } |
1166 | 1315 | ||
1316 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1317 | { | ||
1318 | CheckLandingPoint(ref newpos); | ||
1319 | AbsolutePosition = newpos; | ||
1320 | |||
1321 | if (newvel.HasValue) | ||
1322 | { | ||
1323 | if ((Vector3)newvel == Vector3.Zero) | ||
1324 | { | ||
1325 | if (PhysicsActor != null) | ||
1326 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1327 | m_velocity = Vector3.Zero; | ||
1328 | } | ||
1329 | else | ||
1330 | { | ||
1331 | if (PhysicsActor != null) | ||
1332 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1333 | m_velocity = (Vector3)newvel; | ||
1334 | |||
1335 | if (rotateToVelXY) | ||
1336 | { | ||
1337 | Vector3 lookAt = (Vector3)newvel; | ||
1338 | lookAt.Z = 0; | ||
1339 | lookAt.Normalize(); | ||
1340 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1341 | return; | ||
1342 | } | ||
1343 | } | ||
1344 | } | ||
1345 | |||
1346 | SendTerseUpdateToAllClients(); | ||
1347 | } | ||
1348 | |||
1349 | |||
1350 | |||
1167 | public void StopFlying() | 1351 | public void StopFlying() |
1168 | { | 1352 | { |
1169 | Vector3 pos = AbsolutePosition; | 1353 | Vector3 pos = AbsolutePosition; |
@@ -1352,6 +1536,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1352 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); | 1536 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); |
1353 | } | 1537 | } |
1354 | 1538 | ||
1539 | public void SetSize(Vector3 size, float feetoffset) | ||
1540 | { | ||
1541 | if (PhysicsActor != null && !IsChildAgent) | ||
1542 | PhysicsActor.setAvatarSize(size, feetoffset); | ||
1543 | |||
1544 | } | ||
1545 | |||
1355 | private bool WaitForUpdateAgent(IClientAPI client) | 1546 | private bool WaitForUpdateAgent(IClientAPI client) |
1356 | { | 1547 | { |
1357 | // Before UpdateAgent, m_originRegionID is UUID.Zero; after, it's non-Zero | 1548 | // Before UpdateAgent, m_originRegionID is UUID.Zero; after, it's non-Zero |
@@ -1400,7 +1591,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1400 | 1591 | ||
1401 | Vector3 look = Velocity; | 1592 | Vector3 look = Velocity; |
1402 | 1593 | ||
1403 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1594 | // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1595 | if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) | ||
1404 | { | 1596 | { |
1405 | look = new Vector3(0.99f, 0.042f, 0); | 1597 | look = new Vector3(0.99f, 0.042f, 0); |
1406 | } | 1598 | } |
@@ -1458,11 +1650,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1458 | { | 1650 | { |
1459 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1651 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1460 | if (m_agentTransfer != null) | 1652 | if (m_agentTransfer != null) |
1461 | Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); | 1653 | m_agentTransfer.EnableChildAgents(this); |
1462 | 1654 | ||
1463 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1655 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1464 | if (friendsModule != null) | 1656 | if (friendsModule != null) |
1465 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1657 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1658 | |||
1466 | } | 1659 | } |
1467 | 1660 | ||
1468 | // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region | 1661 | // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region |
@@ -1488,36 +1681,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
1488 | /// <param name="collisionPoint"></param> | 1681 | /// <param name="collisionPoint"></param> |
1489 | /// <param name="localid"></param> | 1682 | /// <param name="localid"></param> |
1490 | /// <param name="distance"></param> | 1683 | /// <param name="distance"></param> |
1684 | /// | ||
1685 | |||
1686 | private void UpdateCameraCollisionPlane(Vector4 plane) | ||
1687 | { | ||
1688 | if (m_lastCameraCollisionPlane != plane) | ||
1689 | { | ||
1690 | m_lastCameraCollisionPlane = plane; | ||
1691 | ControllingClient.SendCameraConstraint(plane); | ||
1692 | } | ||
1693 | } | ||
1694 | |||
1491 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) | 1695 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) |
1492 | { | 1696 | { |
1493 | const float POSITION_TOLERANCE = 0.02f; | 1697 | const float POSITION_TOLERANCE = 0.02f; |
1494 | const float VELOCITY_TOLERANCE = 0.02f; | ||
1495 | const float ROTATION_TOLERANCE = 0.02f; | 1698 | const float ROTATION_TOLERANCE = 0.02f; |
1496 | 1699 | ||
1497 | if (m_followCamAuto) | 1700 | m_doingCamRayCast = false; |
1701 | if (hitYN && localid != LocalId) | ||
1498 | { | 1702 | { |
1499 | if (hitYN) | 1703 | SceneObjectGroup group = m_scene.GetGroupByPrim(localid); |
1704 | bool IsPrim = group != null; | ||
1705 | if (IsPrim) | ||
1500 | { | 1706 | { |
1501 | CameraConstraintActive = true; | 1707 | SceneObjectPart part = group.GetPart(localid); |
1502 | //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); | 1708 | if (part != null && !part.VolumeDetectActive) |
1503 | 1709 | { | |
1504 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); | 1710 | CameraConstraintActive = true; |
1505 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); | 1711 | pNormal.X = (float) Math.Round(pNormal.X, 2); |
1712 | pNormal.Y = (float) Math.Round(pNormal.Y, 2); | ||
1713 | pNormal.Z = (float) Math.Round(pNormal.Z, 2); | ||
1714 | pNormal.Normalize(); | ||
1715 | collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); | ||
1716 | collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); | ||
1717 | collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); | ||
1718 | |||
1719 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, | ||
1720 | Vector3.Dot(collisionPoint, pNormal)); | ||
1721 | UpdateCameraCollisionPlane(plane); | ||
1722 | } | ||
1506 | } | 1723 | } |
1507 | else | 1724 | else |
1508 | { | 1725 | { |
1509 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 1726 | CameraConstraintActive = true; |
1510 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 1727 | pNormal.X = (float) Math.Round(pNormal.X, 2); |
1511 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | 1728 | pNormal.Y = (float) Math.Round(pNormal.Y, 2); |
1512 | { | 1729 | pNormal.Z = (float) Math.Round(pNormal.Z, 2); |
1513 | if (CameraConstraintActive) | 1730 | pNormal.Normalize(); |
1514 | { | 1731 | collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); |
1515 | ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); | 1732 | collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); |
1516 | CameraConstraintActive = false; | 1733 | collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); |
1517 | } | 1734 | |
1518 | } | 1735 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, |
1736 | Vector3.Dot(collisionPoint, pNormal)); | ||
1737 | UpdateCameraCollisionPlane(plane); | ||
1519 | } | 1738 | } |
1520 | } | 1739 | } |
1740 | else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | ||
1741 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | ||
1742 | { | ||
1743 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... | ||
1744 | UpdateCameraCollisionPlane(plane); | ||
1745 | CameraConstraintActive = false; | ||
1746 | } | ||
1521 | } | 1747 | } |
1522 | 1748 | ||
1523 | /// <summary> | 1749 | /// <summary> |
@@ -1591,6 +1817,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1591 | StandUp(); | 1817 | StandUp(); |
1592 | } | 1818 | } |
1593 | 1819 | ||
1820 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | ||
1821 | // this exclude checks may not be complete | ||
1822 | |||
1823 | if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast()) | ||
1824 | { | ||
1825 | if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0) | ||
1826 | { | ||
1827 | Vector3 posAdjusted = AbsolutePosition; | ||
1828 | // posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; | ||
1829 | posAdjusted.Z += 1.0f; // viewer current camera focus point | ||
1830 | Vector3 tocam = CameraPosition - posAdjusted; | ||
1831 | tocam.X = (float)Math.Round(tocam.X, 1); | ||
1832 | tocam.Y = (float)Math.Round(tocam.Y, 1); | ||
1833 | tocam.Z = (float)Math.Round(tocam.Z, 1); | ||
1834 | |||
1835 | float distTocamlen = tocam.Length(); | ||
1836 | if (distTocamlen > 0.3f) | ||
1837 | { | ||
1838 | tocam *= (1.0f / distTocamlen); | ||
1839 | posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); | ||
1840 | posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); | ||
1841 | posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); | ||
1842 | |||
1843 | m_doingCamRayCast = true; | ||
1844 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); | ||
1845 | } | ||
1846 | } | ||
1847 | else if (CameraConstraintActive && (m_mouseLook || ParentID != 0)) | ||
1848 | { | ||
1849 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... | ||
1850 | UpdateCameraCollisionPlane(plane); | ||
1851 | CameraConstraintActive = false; | ||
1852 | } | ||
1853 | } | ||
1854 | |||
1594 | uint flagsForScripts = (uint)flags; | 1855 | uint flagsForScripts = (uint)flags; |
1595 | flags = RemoveIgnoredControls(flags, IgnoredControls); | 1856 | flags = RemoveIgnoredControls(flags, IgnoredControls); |
1596 | 1857 | ||
@@ -2126,7 +2387,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2126 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); | 2387 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); |
2127 | 2388 | ||
2128 | MovingToTarget = false; | 2389 | MovingToTarget = false; |
2129 | MoveToPositionTarget = Vector3.Zero; | 2390 | // MoveToPositionTarget = Vector3.Zero; |
2391 | m_forceToApply = null; // cancel possible last action | ||
2130 | 2392 | ||
2131 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct | 2393 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct |
2132 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. | 2394 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. |
@@ -2144,12 +2406,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2144 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 2406 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
2145 | 2407 | ||
2146 | SitGround = false; | 2408 | SitGround = false; |
2409 | |||
2410 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
2147 | if (PhysicsActor == null) | 2411 | if (PhysicsActor == null) |
2148 | AddToPhysicalScene(false); | 2412 | AddToPhysicalScene(false); |
2413 | */ | ||
2149 | 2414 | ||
2150 | if (ParentID != 0) | 2415 | if (ParentID != 0) |
2151 | { | 2416 | { |
2152 | SceneObjectPart part = ParentPart; | 2417 | SceneObjectPart part = ParentPart; |
2418 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
2419 | |||
2153 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 2420 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
2154 | if (taskIDict != null) | 2421 | if (taskIDict != null) |
2155 | { | 2422 | { |
@@ -2165,14 +2432,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2165 | } | 2432 | } |
2166 | } | 2433 | } |
2167 | 2434 | ||
2168 | ParentPosition = part.GetWorldPosition(); | 2435 | part.ParentGroup.DeleteAvatar(UUID); |
2436 | // ParentPosition = part.GetWorldPosition(); | ||
2169 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 2437 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
2170 | 2438 | ||
2171 | m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 2439 | // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
2172 | ParentPosition = Vector3.Zero; | 2440 | // ParentPosition = Vector3.Zero; |
2441 | m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
2442 | if (part.SitTargetAvatar == UUID) | ||
2443 | m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; | ||
2173 | 2444 | ||
2174 | ParentID = 0; | 2445 | ParentID = 0; |
2175 | ParentPart = null; | 2446 | ParentPart = null; |
2447 | |||
2448 | if (PhysicsActor == null) | ||
2449 | AddToPhysicalScene(false); | ||
2450 | |||
2176 | SendAvatarDataToAllAgents(); | 2451 | SendAvatarDataToAllAgents(); |
2177 | m_requestedSitTargetID = 0; | 2452 | m_requestedSitTargetID = 0; |
2178 | 2453 | ||
@@ -2182,6 +2457,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2182 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 2457 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
2183 | } | 2458 | } |
2184 | 2459 | ||
2460 | else if (PhysicsActor == null) | ||
2461 | AddToPhysicalScene(false); | ||
2462 | |||
2185 | Animator.TrySetMovementAnimation("STAND"); | 2463 | Animator.TrySetMovementAnimation("STAND"); |
2186 | TriggerScenePresenceUpdated(); | 2464 | TriggerScenePresenceUpdated(); |
2187 | } | 2465 | } |
@@ -2230,11 +2508,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2230 | if (part == null) | 2508 | if (part == null) |
2231 | return; | 2509 | return; |
2232 | 2510 | ||
2233 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | ||
2234 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | ||
2235 | |||
2236 | if (PhysicsActor != null) | 2511 | if (PhysicsActor != null) |
2237 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2512 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
2238 | 2513 | ||
2239 | bool canSit = false; | 2514 | bool canSit = false; |
2240 | Vector3 pos = part.AbsolutePosition + offset; | 2515 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -2251,31 +2526,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
2251 | } | 2526 | } |
2252 | else | 2527 | else |
2253 | { | 2528 | { |
2529 | if (PhysicsSit(part,offset)) // physics engine | ||
2530 | return; | ||
2531 | |||
2254 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 2532 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) |
2255 | { | 2533 | { |
2256 | // m_log.DebugFormat( | ||
2257 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", | ||
2258 | // Name, part.Name, part.LocalId); | ||
2259 | 2534 | ||
2260 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 2535 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
2261 | canSit = true; | 2536 | canSit = true; |
2262 | } | 2537 | } |
2263 | // else | ||
2264 | // { | ||
2265 | // m_log.DebugFormat( | ||
2266 | // "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m", | ||
2267 | // Name, part.Name, part.LocalId); | ||
2268 | // } | ||
2269 | } | 2538 | } |
2270 | 2539 | ||
2271 | if (canSit) | 2540 | if (canSit) |
2272 | { | 2541 | { |
2542 | |||
2273 | if (PhysicsActor != null) | 2543 | if (PhysicsActor != null) |
2274 | { | 2544 | { |
2275 | // We can remove the physicsActor until they stand up. | 2545 | // We can remove the physicsActor until they stand up. |
2276 | RemoveFromPhysicalScene(); | 2546 | RemoveFromPhysicalScene(); |
2277 | } | 2547 | } |
2278 | 2548 | ||
2549 | if (MovingToTarget) | ||
2550 | ResetMoveToTarget(); | ||
2551 | |||
2552 | Velocity = Vector3.Zero; | ||
2553 | |||
2279 | part.AddSittingAvatar(UUID); | 2554 | part.AddSittingAvatar(UUID); |
2280 | 2555 | ||
2281 | cameraAtOffset = part.GetCameraAtOffset(); | 2556 | cameraAtOffset = part.GetCameraAtOffset(); |
@@ -2315,14 +2590,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2315 | m_requestedSitTargetID = part.LocalId; | 2590 | m_requestedSitTargetID = part.LocalId; |
2316 | m_requestedSitTargetUUID = part.UUID; | 2591 | m_requestedSitTargetUUID = part.UUID; |
2317 | 2592 | ||
2318 | // m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | ||
2319 | |||
2320 | if (m_scene.PhysicsScene.SupportsRayCast()) | ||
2321 | { | ||
2322 | //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); | ||
2323 | //SitRayCastAvatarPosition(part); | ||
2324 | //return; | ||
2325 | } | ||
2326 | } | 2593 | } |
2327 | else | 2594 | else |
2328 | { | 2595 | { |
@@ -2332,197 +2599,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2332 | SendSitResponse(targetID, offset, Quaternion.Identity); | 2599 | SendSitResponse(targetID, offset, Quaternion.Identity); |
2333 | } | 2600 | } |
2334 | 2601 | ||
2335 | /* | 2602 | // returns false if does not suport so older sit can be tried |
2336 | public void SitRayCastAvatarPosition(SceneObjectPart part) | 2603 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) |
2337 | { | 2604 | { |
2338 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2605 | if (part == null || part.ParentGroup.IsAttachment) |
2339 | Vector3 StartRayCastPosition = AbsolutePosition; | ||
2340 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2341 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2342 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); | ||
2343 | } | ||
2344 | |||
2345 | public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | ||
2346 | { | ||
2347 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2348 | if (part != null) | ||
2349 | { | ||
2350 | if (hitYN) | ||
2351 | { | ||
2352 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2353 | { | ||
2354 | SitRaycastFindEdge(collisionPoint, normal); | ||
2355 | m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2356 | } | ||
2357 | else | ||
2358 | { | ||
2359 | SitRayCastAvatarPositionCameraZ(part); | ||
2360 | } | ||
2361 | } | ||
2362 | else | ||
2363 | { | ||
2364 | SitRayCastAvatarPositionCameraZ(part); | ||
2365 | } | ||
2366 | } | ||
2367 | else | ||
2368 | { | 2606 | { |
2369 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2607 | return true; |
2370 | m_requestedSitTargetUUID = UUID.Zero; | ||
2371 | m_requestedSitTargetID = 0; | ||
2372 | m_requestedSitOffset = Vector3.Zero; | ||
2373 | } | 2608 | } |
2374 | 2609 | ||
2375 | } | 2610 | if ( m_scene.PhysicsScene == null) |
2376 | 2611 | return false; | |
2377 | public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) | ||
2378 | { | ||
2379 | // Next, try to raycast from the camera Z position | ||
2380 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2381 | Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; | ||
2382 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2383 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2384 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); | ||
2385 | } | ||
2386 | 2612 | ||
2387 | public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2613 | if (part.PhysActor == null) |
2388 | { | ||
2389 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2390 | if (part != null) | ||
2391 | { | 2614 | { |
2392 | if (hitYN) | 2615 | // none physcis shape |
2393 | { | 2616 | if (part.PhysicsShapeType == (byte)PhysicsShapeType.None) |
2394 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | 2617 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2395 | { | ||
2396 | SitRaycastFindEdge(collisionPoint, normal); | ||
2397 | m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2398 | } | ||
2399 | else | ||
2400 | { | ||
2401 | SitRayCastCameraPosition(part); | ||
2402 | } | ||
2403 | } | ||
2404 | else | 2618 | else |
2405 | { | 2619 | { // non physical phantom TODO |
2406 | SitRayCastCameraPosition(part); | 2620 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2621 | return false; | ||
2407 | } | 2622 | } |
2408 | } | 2623 | return true; |
2409 | else | ||
2410 | { | ||
2411 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2412 | m_requestedSitTargetUUID = UUID.Zero; | ||
2413 | m_requestedSitTargetID = 0; | ||
2414 | m_requestedSitOffset = Vector3.Zero; | ||
2415 | } | 2624 | } |
2416 | 2625 | ||
2417 | } | ||
2418 | 2626 | ||
2419 | public void SitRayCastCameraPosition(SceneObjectPart part) | 2627 | // not doing autopilot |
2420 | { | 2628 | m_requestedSitTargetID = 0; |
2421 | // Next, try to raycast from the camera position | ||
2422 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2423 | Vector3 StartRayCastPosition = CameraPosition; | ||
2424 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2425 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2426 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); | ||
2427 | } | ||
2428 | 2629 | ||
2429 | public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2630 | if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) |
2430 | { | 2631 | return true; |
2431 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2432 | if (part != null) | ||
2433 | { | ||
2434 | if (hitYN) | ||
2435 | { | ||
2436 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2437 | { | ||
2438 | SitRaycastFindEdge(collisionPoint, normal); | ||
2439 | m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2440 | } | ||
2441 | else | ||
2442 | { | ||
2443 | SitRayHorizontal(part); | ||
2444 | } | ||
2445 | } | ||
2446 | else | ||
2447 | { | ||
2448 | SitRayHorizontal(part); | ||
2449 | } | ||
2450 | } | ||
2451 | else | ||
2452 | { | ||
2453 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2454 | m_requestedSitTargetUUID = UUID.Zero; | ||
2455 | m_requestedSitTargetID = 0; | ||
2456 | m_requestedSitOffset = Vector3.Zero; | ||
2457 | } | ||
2458 | 2632 | ||
2633 | return false; | ||
2459 | } | 2634 | } |
2460 | 2635 | ||
2461 | public void SitRayHorizontal(SceneObjectPart part) | 2636 | |
2637 | private bool CanEnterLandPosition(Vector3 testPos) | ||
2462 | { | 2638 | { |
2463 | // Next, try to raycast from the avatar position to fwd | 2639 | ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y); |
2464 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2640 | |
2465 | Vector3 StartRayCastPosition = CameraPosition; | 2641 | if (land == null || land.LandData.Name == "NO_LAND") |
2466 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2642 | return true; |
2467 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2643 | |
2468 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); | 2644 | return land.CanBeOnThisLand(UUID,testPos.Z); |
2469 | } | 2645 | } |
2470 | 2646 | ||
2471 | public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2647 | // status |
2648 | // < 0 ignore | ||
2649 | // 0 bad sit spot | ||
2650 | public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) | ||
2472 | { | 2651 | { |
2473 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2652 | if (status < 0) |
2474 | if (part != null) | 2653 | return; |
2654 | |||
2655 | if (status == 0) | ||
2475 | { | 2656 | { |
2476 | if (hitYN) | 2657 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2477 | { | 2658 | return; |
2478 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2479 | { | ||
2480 | SitRaycastFindEdge(collisionPoint, normal); | ||
2481 | m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2482 | // Next, try to raycast from the camera position | ||
2483 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2484 | Vector3 StartRayCastPosition = CameraPosition; | ||
2485 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2486 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2487 | //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); | ||
2488 | } | ||
2489 | else | ||
2490 | { | ||
2491 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2492 | m_requestedSitTargetUUID = UUID.Zero; | ||
2493 | m_requestedSitTargetID = 0; | ||
2494 | m_requestedSitOffset = Vector3.Zero; | ||
2495 | } | ||
2496 | } | ||
2497 | else | ||
2498 | { | ||
2499 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2500 | m_requestedSitTargetUUID = UUID.Zero; | ||
2501 | m_requestedSitTargetID = 0; | ||
2502 | m_requestedSitOffset = Vector3.Zero; | ||
2503 | } | ||
2504 | } | 2659 | } |
2505 | else | 2660 | |
2661 | SceneObjectPart part = m_scene.GetSceneObjectPart(partID); | ||
2662 | if (part == null) | ||
2663 | return; | ||
2664 | |||
2665 | Vector3 targetPos = part.GetWorldPosition() + offset * part.GetWorldRotation(); | ||
2666 | if(!CanEnterLandPosition(targetPos)) | ||
2506 | { | 2667 | { |
2507 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2668 | ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot"); |
2508 | m_requestedSitTargetUUID = UUID.Zero; | 2669 | return; |
2509 | m_requestedSitTargetID = 0; | ||
2510 | m_requestedSitOffset = Vector3.Zero; | ||
2511 | } | 2670 | } |
2512 | 2671 | ||
2513 | } | 2672 | RemoveFromPhysicalScene(); |
2514 | 2673 | ||
2515 | private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) | 2674 | if (MovingToTarget) |
2516 | { | 2675 | ResetMoveToTarget(); |
2517 | int i = 0; | ||
2518 | //throw new NotImplementedException(); | ||
2519 | //m_requestedSitTargetUUID = UUID.Zero; | ||
2520 | //m_requestedSitTargetID = 0; | ||
2521 | //m_requestedSitOffset = Vector3.Zero; | ||
2522 | 2676 | ||
2523 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); | 2677 | Velocity = Vector3.Zero; |
2678 | |||
2679 | part.AddSittingAvatar(UUID); | ||
2680 | |||
2681 | Vector3 cameraAtOffset = part.GetCameraAtOffset(); | ||
2682 | Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2683 | bool forceMouselook = part.GetForceMouselook(); | ||
2684 | |||
2685 | ControllingClient.SendSitResponse( | ||
2686 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2687 | |||
2688 | // not using autopilot | ||
2689 | |||
2690 | Rotation = Orientation; | ||
2691 | m_pos = offset; | ||
2692 | |||
2693 | m_requestedSitTargetID = 0; | ||
2694 | part.ParentGroup.AddAvatar(UUID); | ||
2695 | |||
2696 | ParentPart = part; | ||
2697 | ParentID = part.LocalId; | ||
2698 | if(status == 3) | ||
2699 | Animator.TrySetMovementAnimation("SIT_GROUND"); | ||
2700 | else | ||
2701 | Animator.TrySetMovementAnimation("SIT"); | ||
2702 | SendAvatarDataToAllAgents(); | ||
2703 | |||
2704 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | ||
2524 | } | 2705 | } |
2525 | */ | 2706 | |
2526 | 2707 | ||
2527 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2708 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2528 | { | 2709 | { |
@@ -2542,6 +2723,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2542 | return; | 2723 | return; |
2543 | } | 2724 | } |
2544 | 2725 | ||
2726 | |||
2545 | if (part.SitTargetAvatar == UUID) | 2727 | if (part.SitTargetAvatar == UUID) |
2546 | { | 2728 | { |
2547 | Vector3 sitTargetPos = part.SitTargetPosition; | 2729 | Vector3 sitTargetPos = part.SitTargetPosition; |
@@ -2556,14 +2738,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2556 | 2738 | ||
2557 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2739 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2558 | 2740 | ||
2559 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2741 | double x, y, z, m; |
2742 | |||
2743 | Quaternion r = sitTargetOrient; | ||
2744 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2745 | |||
2746 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2747 | { | ||
2748 | m = 1.0 / Math.Sqrt(m); | ||
2749 | r.X *= (float)m; | ||
2750 | r.Y *= (float)m; | ||
2751 | r.Z *= (float)m; | ||
2752 | r.W *= (float)m; | ||
2753 | } | ||
2754 | |||
2755 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2756 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2757 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2758 | |||
2759 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2760 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2761 | |||
2762 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2763 | |||
2764 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2560 | Rotation = sitTargetOrient; | 2765 | Rotation = sitTargetOrient; |
2561 | ParentPosition = part.AbsolutePosition; | 2766 | // ParentPosition = part.AbsolutePosition; |
2767 | part.ParentGroup.AddAvatar(UUID); | ||
2562 | } | 2768 | } |
2563 | else | 2769 | else |
2564 | { | 2770 | { |
2565 | m_pos -= part.AbsolutePosition; | 2771 | m_pos -= part.AbsolutePosition; |
2566 | ParentPosition = part.AbsolutePosition; | 2772 | // ParentPosition = part.AbsolutePosition; |
2773 | part.ParentGroup.AddAvatar(UUID); | ||
2567 | 2774 | ||
2568 | // m_log.DebugFormat( | 2775 | // m_log.DebugFormat( |
2569 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2776 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2621,6 +2828,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2621 | TriggerScenePresenceUpdated(); | 2828 | TriggerScenePresenceUpdated(); |
2622 | } | 2829 | } |
2623 | 2830 | ||
2831 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2832 | { | ||
2833 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2834 | } | ||
2835 | |||
2836 | |||
2837 | |||
2624 | /// <summary> | 2838 | /// <summary> |
2625 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2839 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2626 | /// </summary> | 2840 | /// </summary> |
@@ -2677,8 +2891,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2677 | direc.Z *= 2.6f; | 2891 | direc.Z *= 2.6f; |
2678 | 2892 | ||
2679 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2893 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2680 | Animator.TrySetMovementAnimation("PREJUMP"); | 2894 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2681 | Animator.TrySetMovementAnimation("JUMP"); | 2895 | // Animator.TrySetMovementAnimation("JUMP"); |
2682 | } | 2896 | } |
2683 | } | 2897 | } |
2684 | } | 2898 | } |
@@ -2687,6 +2901,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2687 | 2901 | ||
2688 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2902 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2689 | m_forceToApply = direc; | 2903 | m_forceToApply = direc; |
2904 | Animator.UpdateMovementAnimations(); | ||
2690 | } | 2905 | } |
2691 | 2906 | ||
2692 | #endregion | 2907 | #endregion |
@@ -2704,16 +2919,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2704 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | 2919 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to |
2705 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | 2920 | // grab the latest PhysicsActor velocity, whereas m_velocity is often |
2706 | // storing a requested force instead of an actual traveling velocity | 2921 | // storing a requested force instead of an actual traveling velocity |
2922 | if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn) | ||
2923 | SendAvatarDataToAllAgents(); | ||
2707 | 2924 | ||
2708 | // Throw away duplicate or insignificant updates | 2925 | if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2709 | if ( | 2926 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2710 | // If the velocity has become zero, send it no matter what. | 2927 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2711 | (Velocity != m_lastVelocity && Velocity == Vector3.Zero) | ||
2712 | // otherwise, if things have changed reasonably, send the update | ||
2713 | || (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) | ||
2714 | || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) | ||
2715 | || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))) | ||
2716 | |||
2717 | { | 2928 | { |
2718 | SendTerseUpdateToAllClients(); | 2929 | SendTerseUpdateToAllClients(); |
2719 | 2930 | ||
@@ -2872,9 +3083,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2872 | // again here... this comes after the cached appearance check because the avatars | 3083 | // again here... this comes after the cached appearance check because the avatars |
2873 | // appearance goes into the avatar update packet | 3084 | // appearance goes into the avatar update packet |
2874 | SendAvatarDataToAllAgents(); | 3085 | SendAvatarDataToAllAgents(); |
2875 | 3086 | SendAppearanceToAgent(this); | |
2876 | // This invocation always shows up in the viewer logs as an error. | ||
2877 | // SendAppearanceToAgent(this); | ||
2878 | 3087 | ||
2879 | // If we are using the the cached appearance then send it out to everyone | 3088 | // If we are using the the cached appearance then send it out to everyone |
2880 | if (cachedappearance) | 3089 | if (cachedappearance) |
@@ -2905,6 +3114,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2905 | return; | 3114 | return; |
2906 | } | 3115 | } |
2907 | 3116 | ||
3117 | m_lastSize = Appearance.AvatarSize; | ||
3118 | |||
2908 | int count = 0; | 3119 | int count = 0; |
2909 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 3120 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
2910 | { | 3121 | { |
@@ -3012,6 +3223,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3012 | 3223 | ||
3013 | avatar.ControllingClient.SendAppearance( | 3224 | avatar.ControllingClient.SendAppearance( |
3014 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); | 3225 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); |
3226 | |||
3227 | |||
3015 | } | 3228 | } |
3016 | 3229 | ||
3017 | #endregion | 3230 | #endregion |
@@ -3085,8 +3298,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3085 | 3298 | ||
3086 | // If we don't have a PhysActor, we can't cross anyway | 3299 | // If we don't have a PhysActor, we can't cross anyway |
3087 | // Also don't do this while sat, sitting avatars cross with the | 3300 | // Also don't do this while sat, sitting avatars cross with the |
3088 | // object they sit on. | 3301 | // object they sit on. ParentUUID denoted a pending sit, don't |
3089 | if (ParentID != 0 || PhysicsActor == null) | 3302 | // interfere with it. |
3303 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
3090 | return; | 3304 | return; |
3091 | 3305 | ||
3092 | if (!IsInTransit) | 3306 | if (!IsInTransit) |
@@ -3348,6 +3562,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3348 | } | 3562 | } |
3349 | 3563 | ||
3350 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3564 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3565 | private void RaiseUpdateThrottles() | ||
3566 | { | ||
3567 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
3568 | } | ||
3351 | /// <summary> | 3569 | /// <summary> |
3352 | /// This updates important decision making data about a child agent | 3570 | /// This updates important decision making data about a child agent |
3353 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3571 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3429,6 +3647,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3429 | cAgent.AlwaysRun = SetAlwaysRun; | 3647 | cAgent.AlwaysRun = SetAlwaysRun; |
3430 | 3648 | ||
3431 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3649 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3650 | |||
3651 | cAgent.ParentPart = ParentUUID; | ||
3652 | cAgent.SitOffset = m_pos; | ||
3432 | 3653 | ||
3433 | lock (scriptedcontrols) | 3654 | lock (scriptedcontrols) |
3434 | { | 3655 | { |
@@ -3437,7 +3658,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3437 | 3658 | ||
3438 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3659 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3439 | { | 3660 | { |
3440 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3661 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3441 | } | 3662 | } |
3442 | cAgent.Controllers = controls; | 3663 | cAgent.Controllers = controls; |
3443 | } | 3664 | } |
@@ -3470,6 +3691,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3470 | CameraAtAxis = cAgent.AtAxis; | 3691 | CameraAtAxis = cAgent.AtAxis; |
3471 | CameraLeftAxis = cAgent.LeftAxis; | 3692 | CameraLeftAxis = cAgent.LeftAxis; |
3472 | CameraUpAxis = cAgent.UpAxis; | 3693 | CameraUpAxis = cAgent.UpAxis; |
3694 | ParentUUID = cAgent.ParentPart; | ||
3695 | m_prevSitOffset = cAgent.SitOffset; | ||
3473 | 3696 | ||
3474 | // When we get to the point of re-computing neighbors everytime this | 3697 | // When we get to the point of re-computing neighbors everytime this |
3475 | // changes, then start using the agent's drawdistance rather than the | 3698 | // changes, then start using the agent's drawdistance rather than the |
@@ -3507,6 +3730,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3507 | foreach (ControllerData c in cAgent.Controllers) | 3730 | foreach (ControllerData c in cAgent.Controllers) |
3508 | { | 3731 | { |
3509 | ScriptControllers sc = new ScriptControllers(); | 3732 | ScriptControllers sc = new ScriptControllers(); |
3733 | sc.objectID = c.ObjectID; | ||
3510 | sc.itemID = c.ItemID; | 3734 | sc.itemID = c.ItemID; |
3511 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3735 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3512 | sc.eventControls = (ScriptControlled)c.EventControls; | 3736 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3574,20 +3798,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3574 | } | 3798 | } |
3575 | 3799 | ||
3576 | if (Appearance.AvatarHeight == 0) | 3800 | if (Appearance.AvatarHeight == 0) |
3577 | Appearance.SetHeight(); | 3801 | // Appearance.SetHeight(); |
3802 | Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
3578 | 3803 | ||
3579 | PhysicsScene scene = m_scene.PhysicsScene; | 3804 | PhysicsScene scene = m_scene.PhysicsScene; |
3580 | 3805 | ||
3581 | Vector3 pVec = AbsolutePosition; | 3806 | Vector3 pVec = AbsolutePosition; |
3582 | 3807 | ||
3808 | /* | ||
3583 | PhysicsActor = scene.AddAvatar( | 3809 | PhysicsActor = scene.AddAvatar( |
3584 | LocalId, Firstname + "." + Lastname, pVec, | 3810 | LocalId, Firstname + "." + Lastname, pVec, |
3585 | new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); | 3811 | new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); |
3812 | */ | ||
3813 | |||
3814 | PhysicsActor = scene.AddAvatar( | ||
3815 | LocalId, Firstname + "." + Lastname, pVec, | ||
3816 | Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); | ||
3586 | 3817 | ||
3587 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3818 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3588 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3819 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3589 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3820 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3590 | PhysicsActor.SubscribeEvents(500); | 3821 | PhysicsActor.SubscribeEvents(100); |
3591 | PhysicsActor.LocalID = LocalId; | 3822 | PhysicsActor.LocalID = LocalId; |
3592 | } | 3823 | } |
3593 | 3824 | ||
@@ -3601,6 +3832,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3601 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); | 3832 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); |
3602 | } | 3833 | } |
3603 | 3834 | ||
3835 | |||
3604 | /// <summary> | 3836 | /// <summary> |
3605 | /// Event called by the physics plugin to tell the avatar about a collision. | 3837 | /// Event called by the physics plugin to tell the avatar about a collision. |
3606 | /// </summary> | 3838 | /// </summary> |
@@ -3614,7 +3846,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3614 | /// <param name="e"></param> | 3846 | /// <param name="e"></param> |
3615 | public void PhysicsCollisionUpdate(EventArgs e) | 3847 | public void PhysicsCollisionUpdate(EventArgs e) |
3616 | { | 3848 | { |
3617 | if (IsChildAgent) | 3849 | if (IsChildAgent || Animator == null) |
3618 | return; | 3850 | return; |
3619 | 3851 | ||
3620 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3852 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
@@ -3631,7 +3863,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3631 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3863 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3632 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3864 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3633 | 3865 | ||
3634 | CollisionPlane = Vector4.UnitW; | ||
3635 | 3866 | ||
3636 | // // No collisions at all means we may be flying. Update always | 3867 | // // No collisions at all means we may be flying. Update always |
3637 | // // to make falling work | 3868 | // // to make falling work |
@@ -3643,6 +3874,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3643 | 3874 | ||
3644 | if (coldata.Count != 0) | 3875 | if (coldata.Count != 0) |
3645 | { | 3876 | { |
3877 | /* | ||
3646 | switch (Animator.CurrentMovementAnimation) | 3878 | switch (Animator.CurrentMovementAnimation) |
3647 | { | 3879 | { |
3648 | case "STAND": | 3880 | case "STAND": |
@@ -3651,24 +3883,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
3651 | case "CROUCH": | 3883 | case "CROUCH": |
3652 | case "CROUCHWALK": | 3884 | case "CROUCHWALK": |
3653 | { | 3885 | { |
3886 | */ | ||
3654 | ContactPoint lowest; | 3887 | ContactPoint lowest; |
3655 | lowest.SurfaceNormal = Vector3.Zero; | 3888 | lowest.SurfaceNormal = Vector3.Zero; |
3656 | lowest.Position = Vector3.Zero; | 3889 | lowest.Position = Vector3.Zero; |
3657 | lowest.Position.Z = Single.NaN; | 3890 | lowest.Position.Z = float.MaxValue; |
3658 | 3891 | ||
3659 | foreach (ContactPoint contact in coldata.Values) | 3892 | foreach (ContactPoint contact in coldata.Values) |
3660 | { | 3893 | { |
3661 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) | 3894 | |
3895 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | ||
3662 | { | 3896 | { |
3663 | lowest = contact; | 3897 | lowest = contact; |
3664 | } | 3898 | } |
3665 | } | 3899 | } |
3666 | 3900 | ||
3667 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | 3901 | if (lowest.Position.Z != float.MaxValue) |
3902 | { | ||
3903 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | ||
3904 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
3905 | } | ||
3906 | else | ||
3907 | CollisionPlane = Vector4.UnitW; | ||
3908 | /* | ||
3668 | } | 3909 | } |
3669 | break; | 3910 | break; |
3670 | } | 3911 | } |
3912 | */ | ||
3671 | } | 3913 | } |
3914 | else | ||
3915 | CollisionPlane = Vector4.UnitW; | ||
3916 | |||
3917 | RaiseCollisionScriptEvents(coldata); | ||
3672 | 3918 | ||
3673 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3919 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3674 | if (Invulnerable || GodLevel > 0) | 3920 | if (Invulnerable || GodLevel > 0) |
@@ -3767,6 +4013,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3767 | // m_reprioritizationTimer.Dispose(); | 4013 | // m_reprioritizationTimer.Dispose(); |
3768 | 4014 | ||
3769 | RemoveFromPhysicalScene(); | 4015 | RemoveFromPhysicalScene(); |
4016 | |||
4017 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
4018 | |||
4019 | // if (Animator != null) | ||
4020 | // Animator.Close(); | ||
4021 | Animator = null; | ||
3770 | 4022 | ||
3771 | LifecycleState = ScenePresenceState.Removed; | 4023 | LifecycleState = ScenePresenceState.Removed; |
3772 | } | 4024 | } |
@@ -4002,10 +4254,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4002 | 4254 | ||
4003 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 4255 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
4004 | { | 4256 | { |
4257 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
4258 | if (p == null) | ||
4259 | return; | ||
4260 | |||
4261 | ControllingClient.SendTakeControls(controls, false, false); | ||
4262 | ControllingClient.SendTakeControls(controls, true, false); | ||
4263 | |||
4005 | ScriptControllers obj = new ScriptControllers(); | 4264 | ScriptControllers obj = new ScriptControllers(); |
4006 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 4265 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
4007 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 4266 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
4008 | 4267 | ||
4268 | obj.objectID = p.ParentGroup.UUID; | ||
4009 | obj.itemID = Script_item_UUID; | 4269 | obj.itemID = Script_item_UUID; |
4010 | if (pass_on == 0 && accept == 0) | 4270 | if (pass_on == 0 && accept == 0) |
4011 | { | 4271 | { |
@@ -4054,6 +4314,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
4054 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 4314 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
4055 | } | 4315 | } |
4056 | 4316 | ||
4317 | private void UnRegisterSeatControls(UUID obj) | ||
4318 | { | ||
4319 | List<UUID> takers = new List<UUID>(); | ||
4320 | |||
4321 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
4322 | { | ||
4323 | if (c.objectID == obj) | ||
4324 | takers.Add(c.itemID); | ||
4325 | } | ||
4326 | foreach (UUID t in takers) | ||
4327 | { | ||
4328 | UnRegisterControlEventsToScript(0, t); | ||
4329 | } | ||
4330 | } | ||
4331 | |||
4057 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 4332 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
4058 | { | 4333 | { |
4059 | ScriptControllers takecontrols; | 4334 | ScriptControllers takecontrols; |
@@ -4383,6 +4658,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4383 | 4658 | ||
4384 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4659 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
4385 | { | 4660 | { |
4661 | string reason; | ||
4662 | |||
4663 | // Honor bans | ||
4664 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4665 | return; | ||
4666 | |||
4386 | SceneObjectGroup telehub = null; | 4667 | SceneObjectGroup telehub = null; |
4387 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4668 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
4388 | { | 4669 | { |
@@ -4422,11 +4703,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4422 | pos = land.LandData.UserLocation; | 4703 | pos = land.LandData.UserLocation; |
4423 | } | 4704 | } |
4424 | } | 4705 | } |
4425 | 4706 | ||
4426 | land.SendLandUpdateToClient(ControllingClient); | 4707 | land.SendLandUpdateToClient(ControllingClient); |
4427 | } | 4708 | } |
4428 | } | 4709 | } |
4429 | 4710 | ||
4711 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4712 | { | ||
4713 | DetectedObject detobj = new DetectedObject(); | ||
4714 | detobj.keyUUID = obj.UUID; | ||
4715 | detobj.nameStr = obj.Name; | ||
4716 | detobj.ownerUUID = obj.OwnerID; | ||
4717 | detobj.posVector = obj.AbsolutePosition; | ||
4718 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4719 | detobj.velVector = obj.Velocity; | ||
4720 | detobj.colliderType = 0; | ||
4721 | detobj.groupUUID = obj.GroupID; | ||
4722 | |||
4723 | return detobj; | ||
4724 | } | ||
4725 | |||
4726 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4727 | { | ||
4728 | DetectedObject detobj = new DetectedObject(); | ||
4729 | detobj.keyUUID = av.UUID; | ||
4730 | detobj.nameStr = av.ControllingClient.Name; | ||
4731 | detobj.ownerUUID = av.UUID; | ||
4732 | detobj.posVector = av.AbsolutePosition; | ||
4733 | detobj.rotQuat = av.Rotation; | ||
4734 | detobj.velVector = av.Velocity; | ||
4735 | detobj.colliderType = 0; | ||
4736 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4737 | |||
4738 | return detobj; | ||
4739 | } | ||
4740 | |||
4741 | private DetectedObject CreateDetObjectForGround() | ||
4742 | { | ||
4743 | DetectedObject detobj = new DetectedObject(); | ||
4744 | detobj.keyUUID = UUID.Zero; | ||
4745 | detobj.nameStr = ""; | ||
4746 | detobj.ownerUUID = UUID.Zero; | ||
4747 | detobj.posVector = AbsolutePosition; | ||
4748 | detobj.rotQuat = Quaternion.Identity; | ||
4749 | detobj.velVector = Vector3.Zero; | ||
4750 | detobj.colliderType = 0; | ||
4751 | detobj.groupUUID = UUID.Zero; | ||
4752 | |||
4753 | return detobj; | ||
4754 | } | ||
4755 | |||
4756 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4757 | { | ||
4758 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4759 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4760 | foreach (uint localId in colliders) | ||
4761 | { | ||
4762 | if (localId == 0) | ||
4763 | continue; | ||
4764 | |||
4765 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4766 | if (obj != null) | ||
4767 | { | ||
4768 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4769 | colliding.Add(CreateDetObject(obj)); | ||
4770 | } | ||
4771 | else | ||
4772 | { | ||
4773 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4774 | if (av != null && (!av.IsChildAgent)) | ||
4775 | { | ||
4776 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4777 | colliding.Add(CreateDetObject(av)); | ||
4778 | } | ||
4779 | } | ||
4780 | } | ||
4781 | |||
4782 | colliderArgs.Colliders = colliding; | ||
4783 | |||
4784 | return colliderArgs; | ||
4785 | } | ||
4786 | |||
4787 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4788 | |||
4789 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4790 | { | ||
4791 | ColliderArgs CollidingMessage; | ||
4792 | |||
4793 | if (colliders.Count > 0) | ||
4794 | { | ||
4795 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4796 | { | ||
4797 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4798 | |||
4799 | if (CollidingMessage.Colliders.Count > 0) | ||
4800 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4801 | } | ||
4802 | } | ||
4803 | } | ||
4804 | |||
4805 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4806 | { | ||
4807 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4808 | { | ||
4809 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4810 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4811 | |||
4812 | colliding.Add(CreateDetObjectForGround()); | ||
4813 | LandCollidingMessage.Colliders = colliding; | ||
4814 | |||
4815 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4816 | } | ||
4817 | } | ||
4818 | |||
4819 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4820 | { | ||
4821 | try | ||
4822 | { | ||
4823 | List<uint> thisHitColliders = new List<uint>(); | ||
4824 | List<uint> endedColliders = new List<uint>(); | ||
4825 | List<uint> startedColliders = new List<uint>(); | ||
4826 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4827 | CollisionForSoundInfo soundinfo; | ||
4828 | ContactPoint curcontact; | ||
4829 | |||
4830 | if (coldata.Count == 0) | ||
4831 | { | ||
4832 | if (m_lastColliders.Count == 0) | ||
4833 | return; // nothing to do | ||
4834 | |||
4835 | foreach (uint localID in m_lastColliders) | ||
4836 | { | ||
4837 | endedColliders.Add(localID); | ||
4838 | } | ||
4839 | m_lastColliders.Clear(); | ||
4840 | } | ||
4841 | |||
4842 | else | ||
4843 | { | ||
4844 | foreach (uint id in coldata.Keys) | ||
4845 | { | ||
4846 | thisHitColliders.Add(id); | ||
4847 | if (!m_lastColliders.Contains(id)) | ||
4848 | { | ||
4849 | startedColliders.Add(id); | ||
4850 | curcontact = coldata[id]; | ||
4851 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4852 | { | ||
4853 | soundinfo = new CollisionForSoundInfo(); | ||
4854 | soundinfo.colliderID = id; | ||
4855 | soundinfo.position = curcontact.Position; | ||
4856 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4857 | soundinfolist.Add(soundinfo); | ||
4858 | } | ||
4859 | } | ||
4860 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4861 | } | ||
4862 | |||
4863 | // calculate things that ended colliding | ||
4864 | foreach (uint localID in m_lastColliders) | ||
4865 | { | ||
4866 | if (!thisHitColliders.Contains(localID)) | ||
4867 | { | ||
4868 | endedColliders.Add(localID); | ||
4869 | } | ||
4870 | } | ||
4871 | //add the items that started colliding this time to the last colliders list. | ||
4872 | foreach (uint localID in startedColliders) | ||
4873 | { | ||
4874 | m_lastColliders.Add(localID); | ||
4875 | } | ||
4876 | // remove things that ended colliding from the last colliders list | ||
4877 | foreach (uint localID in endedColliders) | ||
4878 | { | ||
4879 | m_lastColliders.Remove(localID); | ||
4880 | } | ||
4881 | |||
4882 | if (soundinfolist.Count > 0) | ||
4883 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4884 | } | ||
4885 | |||
4886 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4887 | { | ||
4888 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4889 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4890 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4891 | |||
4892 | if (startedColliders.Contains(0)) | ||
4893 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4894 | if (m_lastColliders.Contains(0)) | ||
4895 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4896 | if (endedColliders.Contains(0)) | ||
4897 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4898 | } | ||
4899 | } | ||
4900 | finally | ||
4901 | { | ||
4902 | m_collisionEventFlag = false; | ||
4903 | } | ||
4904 | } | ||
4905 | |||
4430 | private void TeleportFlagsDebug() { | 4906 | private void TeleportFlagsDebug() { |
4431 | 4907 | ||
4432 | // Some temporary debugging help to show all the TeleportFlags we have... | 4908 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4451,6 +4927,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4451 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4927 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4452 | 4928 | ||
4453 | } | 4929 | } |
4454 | |||
4455 | } | 4930 | } |
4456 | } | 4931 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 945745e..68918d3 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -374,11 +374,21 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
374 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); | 374 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); |
375 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); | 375 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); |
376 | 376 | ||
377 | m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); | ||
378 | m_SOPXmlProcessors.Add("Force", ProcessForce); | ||
379 | m_SOPXmlProcessors.Add("Torque", ProcessTorque); | ||
380 | m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); | ||
381 | |||
382 | |||
383 | m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); | ||
384 | |||
377 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); | 385 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); |
378 | m_SOPXmlProcessors.Add("Density", ProcessDensity); | 386 | m_SOPXmlProcessors.Add("Density", ProcessDensity); |
379 | m_SOPXmlProcessors.Add("Friction", ProcessFriction); | 387 | m_SOPXmlProcessors.Add("Friction", ProcessFriction); |
380 | m_SOPXmlProcessors.Add("Bounce", ProcessBounce); | 388 | m_SOPXmlProcessors.Add("Bounce", ProcessBounce); |
381 | m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); | 389 | m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); |
390 | m_SOPXmlProcessors.Add("CameraEyeOffset", ProcessCameraEyeOffset); | ||
391 | m_SOPXmlProcessors.Add("CameraAtOffset", ProcessCameraAtOffset); | ||
382 | 392 | ||
383 | #endregion | 393 | #endregion |
384 | 394 | ||
@@ -407,7 +417,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
407 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); | 417 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); |
408 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); | 418 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); |
409 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); | 419 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); |
410 | 420 | ||
411 | #endregion | 421 | #endregion |
412 | 422 | ||
413 | #region ShapeXmlProcessors initialization | 423 | #region ShapeXmlProcessors initialization |
@@ -632,6 +642,33 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
632 | obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); | 642 | obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); |
633 | } | 643 | } |
634 | 644 | ||
645 | private static void ProcessCameraEyeOffset(SceneObjectPart obj, XmlTextReader reader) | ||
646 | { | ||
647 | obj.SetCameraEyeOffset(Util.ReadVector(reader, "CameraEyeOffset")); | ||
648 | } | ||
649 | |||
650 | private static void ProcessCameraAtOffset(SceneObjectPart obj, XmlTextReader reader) | ||
651 | { | ||
652 | obj.SetCameraAtOffset(Util.ReadVector(reader, "CameraAtOffset")); | ||
653 | } | ||
654 | |||
655 | private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) | ||
656 | { | ||
657 | SOPVehicle vehicle = SOPVehicle.FromXml2(reader); | ||
658 | |||
659 | if (vehicle == null) | ||
660 | { | ||
661 | obj.VehicleParams = null; | ||
662 | m_log.DebugFormat( | ||
663 | "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.", | ||
664 | obj.Name, obj.UUID); | ||
665 | } | ||
666 | else | ||
667 | { | ||
668 | obj.VehicleParams = vehicle; | ||
669 | } | ||
670 | } | ||
671 | |||
635 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) | 672 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) |
636 | { | 673 | { |
637 | List<string> errorNodeNames; | 674 | List<string> errorNodeNames; |
@@ -801,6 +838,25 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
801 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); | 838 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); |
802 | } | 839 | } |
803 | 840 | ||
841 | private static void ProcessBuoyancy(SceneObjectPart obj, XmlTextReader reader) | ||
842 | { | ||
843 | obj.Buoyancy = (float)reader.ReadElementContentAsFloat("Buoyancy", String.Empty); | ||
844 | } | ||
845 | |||
846 | private static void ProcessForce(SceneObjectPart obj, XmlTextReader reader) | ||
847 | { | ||
848 | obj.Force = Util.ReadVector(reader, "Force"); | ||
849 | } | ||
850 | private static void ProcessTorque(SceneObjectPart obj, XmlTextReader reader) | ||
851 | { | ||
852 | obj.Torque = Util.ReadVector(reader, "Torque"); | ||
853 | } | ||
854 | |||
855 | private static void ProcessVolumeDetectActive(SceneObjectPart obj, XmlTextReader reader) | ||
856 | { | ||
857 | obj.VolumeDetectActive = Util.ReadBoolean(reader); | ||
858 | } | ||
859 | |||
804 | #endregion | 860 | #endregion |
805 | 861 | ||
806 | #region TaskInventoryXmlProcessors | 862 | #region TaskInventoryXmlProcessors |
@@ -1191,7 +1247,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1191 | 1247 | ||
1192 | if (sog.RootPart.KeyframeMotion != null) | 1248 | if (sog.RootPart.KeyframeMotion != null) |
1193 | { | 1249 | { |
1194 | Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); | 1250 | Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); |
1195 | 1251 | ||
1196 | writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); | 1252 | writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); |
1197 | writer.WriteBase64(data, 0, data.Length); | 1253 | writer.WriteBase64(data, 0, data.Length); |
@@ -1305,6 +1361,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1305 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); | 1361 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); |
1306 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); | 1362 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); |
1307 | 1363 | ||
1364 | writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); | ||
1365 | |||
1366 | WriteVector(writer, "Force", sop.Force); | ||
1367 | WriteVector(writer, "Torque", sop.Torque); | ||
1368 | |||
1369 | writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); | ||
1370 | |||
1371 | if (sop.VehicleParams != null) | ||
1372 | sop.VehicleParams.ToXml2(writer); | ||
1373 | |||
1308 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) | 1374 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) |
1309 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); | 1375 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); |
1310 | if (sop.Density != 1000.0f) | 1376 | if (sop.Density != 1000.0f) |
@@ -1315,6 +1381,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1315 | writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); | 1381 | writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); |
1316 | if (sop.GravityModifier != 1.0f) | 1382 | if (sop.GravityModifier != 1.0f) |
1317 | writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); | 1383 | writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); |
1384 | WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); | ||
1385 | WriteVector(writer, "CameraAtOffset", sop.GetCameraAtOffset()); | ||
1318 | 1386 | ||
1319 | writer.WriteEndElement(); | 1387 | writer.WriteEndElement(); |
1320 | } | 1388 | } |
@@ -1540,12 +1608,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1540 | { | 1608 | { |
1541 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); | 1609 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); |
1542 | 1610 | ||
1543 | if (reader.IsEmptyElement) | ||
1544 | { | ||
1545 | reader.Read(); | ||
1546 | return tinv; | ||
1547 | } | ||
1548 | |||
1549 | reader.ReadStartElement(name, String.Empty); | 1611 | reader.ReadStartElement(name, String.Empty); |
1550 | 1612 | ||
1551 | while (reader.Name == "TaskInventoryItem") | 1613 | 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/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..c7eaff9 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 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs index b6fb730..4ae7a8e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs | |||
@@ -75,14 +75,14 @@ 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); | 82 | scene.IncomingCloseAgent(sp.UUID, false); |
83 | Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null); | 83 | //Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null); |
84 | 84 | ||
85 | // TODO: Need to add tests for other ICapabiltiesModule methods. | 85 | // TODO: Need to add tests for other ICapabiltiesModule methods. |
86 | } | 86 | } |
87 | } | 87 | } |
88 | } \ No newline at end of file | 88 | } |
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 8f69ce3..e60a025 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; |