diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
26 files changed, 7221 insertions, 2186 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index bb33f07..9458079 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -79,13 +79,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
79 | m_scenePresence = sp; | 79 | m_scenePresence = sp; |
80 | CurrentMovementAnimation = "CROUCH"; | 80 | CurrentMovementAnimation = "CROUCH"; |
81 | } | 81 | } |
82 | 82 | ||
83 | public void AddAnimation(UUID animID, UUID objectID) | 83 | public void AddAnimation(UUID animID, UUID objectID) |
84 | { | 84 | { |
85 | if (m_scenePresence.IsChildAgent) | 85 | if (m_scenePresence.IsChildAgent) |
86 | return; | 86 | return; |
87 | 87 | ||
88 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); | 88 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); |
89 | 89 | ||
90 | if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) | 90 | if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) |
91 | SendAnimPack(); | 91 | SendAnimPack(); |
@@ -117,6 +117,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
117 | SendAnimPack(); | 117 | SendAnimPack(); |
118 | } | 118 | } |
119 | 119 | ||
120 | public void avnChangeAnim(UUID animID, bool addRemove, bool sendPack) | ||
121 | { | ||
122 | if (m_scenePresence.IsChildAgent) | ||
123 | return; | ||
124 | |||
125 | if (animID != UUID.Zero) | ||
126 | { | ||
127 | if (addRemove) | ||
128 | m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero); | ||
129 | else | ||
130 | m_animations.Remove(animID); | ||
131 | } | ||
132 | if(sendPack) | ||
133 | SendAnimPack(); | ||
134 | } | ||
135 | |||
120 | // Called from scripts | 136 | // Called from scripts |
121 | public void RemoveAnimation(string name) | 137 | public void RemoveAnimation(string name) |
122 | { | 138 | { |
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 4c49b71..e2414eb 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> |
@@ -1393,6 +1397,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1393 | } | 1397 | } |
1394 | } | 1398 | } |
1395 | } | 1399 | } |
1400 | public void TriggerTerrainUpdate() | ||
1401 | { | ||
1402 | OnTerrainUpdateDelegate handlerTerrainUpdate = OnTerrainUpdate; | ||
1403 | if (handlerTerrainUpdate != null) | ||
1404 | { | ||
1405 | foreach (OnTerrainUpdateDelegate d in handlerTerrainUpdate.GetInvocationList()) | ||
1406 | { | ||
1407 | try | ||
1408 | { | ||
1409 | d(); | ||
1410 | } | ||
1411 | catch (Exception e) | ||
1412 | { | ||
1413 | m_log.ErrorFormat( | ||
1414 | "[EVENT MANAGER]: Delegate for TriggerTerrainUpdate failed - continuing. {0} {1}", | ||
1415 | e.Message, e.StackTrace); | ||
1416 | } | ||
1417 | } | ||
1418 | } | ||
1419 | } | ||
1396 | 1420 | ||
1397 | public void TriggerTerrainTick() | 1421 | public void TriggerTerrainTick() |
1398 | { | 1422 | { |
@@ -1683,6 +1707,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1683 | m_log.ErrorFormat( | 1707 | m_log.ErrorFormat( |
1684 | "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", | 1708 | "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", |
1685 | e.Message, e.StackTrace); | 1709 | e.Message, e.StackTrace); |
1710 | m_log.ErrorFormat(Environment.StackTrace); | ||
1686 | } | 1711 | } |
1687 | } | 1712 | } |
1688 | } | 1713 | } |
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs new file mode 100644 index 0000000..edf2bef --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | |||
@@ -0,0 +1,695 @@ | |||
1 | // Proprietary code of Avination Virtual Limited | ||
2 | // (c) 2012 Melanie Thielker | ||
3 | // | ||
4 | |||
5 | using System; | ||
6 | using System.Timers; | ||
7 | using System.Collections; | ||
8 | using System.Collections.Generic; | ||
9 | using System.IO; | ||
10 | using System.Diagnostics; | ||
11 | using System.Reflection; | ||
12 | using System.Threading; | ||
13 | using OpenMetaverse; | ||
14 | using OpenSim.Framework; | ||
15 | using OpenSim.Region.Framework.Interfaces; | ||
16 | using OpenSim.Region.Physics.Manager; | ||
17 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
18 | using System.Runtime.Serialization.Formatters.Binary; | ||
19 | using System.Runtime.Serialization; | ||
20 | using Timer = System.Timers.Timer; | ||
21 | using log4net; | ||
22 | |||
23 | namespace OpenSim.Region.Framework.Scenes | ||
24 | { | ||
25 | [Serializable] | ||
26 | public class KeyframeMotion | ||
27 | { | ||
28 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
29 | |||
30 | public enum PlayMode : int | ||
31 | { | ||
32 | Forward = 0, | ||
33 | Reverse = 1, | ||
34 | Loop = 2, | ||
35 | PingPong = 3 | ||
36 | }; | ||
37 | |||
38 | [Flags] | ||
39 | public enum DataFormat : int | ||
40 | { | ||
41 | Translation = 2, | ||
42 | Rotation = 1 | ||
43 | } | ||
44 | |||
45 | [Serializable] | ||
46 | public struct Keyframe | ||
47 | { | ||
48 | public Vector3? Position; | ||
49 | public Quaternion? Rotation; | ||
50 | public Quaternion StartRotation; | ||
51 | public int TimeMS; | ||
52 | public int TimeTotal; | ||
53 | public Vector3 AngularVelocity; | ||
54 | }; | ||
55 | |||
56 | private Vector3 m_serializedPosition; | ||
57 | private Vector3 m_basePosition; | ||
58 | private Quaternion m_baseRotation; | ||
59 | |||
60 | private Keyframe m_currentFrame; | ||
61 | |||
62 | private List<Keyframe> m_frames = new List<Keyframe>(); | ||
63 | |||
64 | private Keyframe[] m_keyframes; | ||
65 | |||
66 | [NonSerialized()] | ||
67 | protected Timer m_timer = null; | ||
68 | |||
69 | // timer lock | ||
70 | [NonSerialized()] | ||
71 | private object m_onTimerLock; | ||
72 | |||
73 | // timer overrun detect | ||
74 | // prevents overlap or timer events threads frozen on the lock | ||
75 | [NonSerialized()] | ||
76 | private bool m_inOnTimer; | ||
77 | |||
78 | // skip timer events. | ||
79 | //timer.stop doesn't assure there aren't event threads still being fired | ||
80 | [NonSerialized()] | ||
81 | private bool m_timerStopped; | ||
82 | |||
83 | [NonSerialized()] | ||
84 | private bool m_isCrossing; | ||
85 | |||
86 | [NonSerialized()] | ||
87 | private bool m_waitingCrossing; | ||
88 | |||
89 | // retry position for cross fail | ||
90 | [NonSerialized()] | ||
91 | private Vector3 m_nextPosition; | ||
92 | |||
93 | [NonSerialized()] | ||
94 | private SceneObjectGroup m_group; | ||
95 | |||
96 | private PlayMode m_mode = PlayMode.Forward; | ||
97 | private DataFormat m_data = DataFormat.Translation | DataFormat.Rotation; | ||
98 | |||
99 | private bool m_running = false; | ||
100 | [NonSerialized()] | ||
101 | private bool m_selected = false; | ||
102 | |||
103 | private int m_iterations = 0; | ||
104 | |||
105 | private const double timerInterval = 50.0; | ||
106 | |||
107 | public DataFormat Data | ||
108 | { | ||
109 | get { return m_data; } | ||
110 | } | ||
111 | |||
112 | public bool Selected | ||
113 | { | ||
114 | set | ||
115 | { | ||
116 | if (m_group != null) | ||
117 | { | ||
118 | if (!value) | ||
119 | { | ||
120 | // Once we're let go, recompute positions | ||
121 | if (m_selected) | ||
122 | UpdateSceneObject(m_group); | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | // Save selection position in case we get moved | ||
127 | if (!m_selected) | ||
128 | { | ||
129 | StopTimer(); | ||
130 | m_serializedPosition = m_group.AbsolutePosition; | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | m_isCrossing = false; | ||
135 | m_waitingCrossing = false; | ||
136 | m_selected = value; | ||
137 | } | ||
138 | } | ||
139 | |||
140 | private void StartTimer() | ||
141 | { | ||
142 | if (m_timer == null) | ||
143 | return; | ||
144 | m_timerStopped = false; | ||
145 | m_timer.Start(); | ||
146 | } | ||
147 | |||
148 | private void StopTimer() | ||
149 | { | ||
150 | if (m_timer == null || m_timerStopped) | ||
151 | return; | ||
152 | m_timerStopped = true; | ||
153 | m_timer.Stop(); | ||
154 | } | ||
155 | |||
156 | private void RemoveTimer() | ||
157 | { | ||
158 | if (m_timer == null) | ||
159 | return; | ||
160 | m_timerStopped = true; | ||
161 | m_timer.Stop(); | ||
162 | m_timer.Elapsed -= OnTimer; | ||
163 | m_timer = null; | ||
164 | } | ||
165 | |||
166 | |||
167 | public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) | ||
168 | { | ||
169 | KeyframeMotion newMotion = null; | ||
170 | |||
171 | try | ||
172 | { | ||
173 | MemoryStream ms = new MemoryStream(data); | ||
174 | BinaryFormatter fmt = new BinaryFormatter(); | ||
175 | |||
176 | newMotion = (KeyframeMotion)fmt.Deserialize(ms); | ||
177 | |||
178 | newMotion.m_group = grp; | ||
179 | |||
180 | if (grp != null && grp.IsSelected) | ||
181 | newMotion.m_selected = true; | ||
182 | |||
183 | newMotion.m_onTimerLock = new object(); | ||
184 | newMotion.m_timerStopped = false; | ||
185 | newMotion.m_inOnTimer = false; | ||
186 | newMotion.m_isCrossing = false; | ||
187 | newMotion.m_waitingCrossing = false; | ||
188 | } | ||
189 | catch | ||
190 | { | ||
191 | newMotion = null; | ||
192 | } | ||
193 | |||
194 | return newMotion; | ||
195 | } | ||
196 | |||
197 | public void UpdateSceneObject(SceneObjectGroup grp) | ||
198 | { | ||
199 | // lock (m_onTimerLock) | ||
200 | { | ||
201 | m_isCrossing = false; | ||
202 | m_waitingCrossing = false; | ||
203 | StopTimer(); | ||
204 | |||
205 | if (grp == null) | ||
206 | return; | ||
207 | |||
208 | m_group = grp; | ||
209 | Vector3 grppos = grp.AbsolutePosition; | ||
210 | Vector3 offset = grppos - m_serializedPosition; | ||
211 | // avoid doing it more than once | ||
212 | // current this will happen draging a prim to other region | ||
213 | m_serializedPosition = grppos; | ||
214 | |||
215 | m_basePosition += offset; | ||
216 | m_currentFrame.Position += offset; | ||
217 | |||
218 | m_nextPosition += offset; | ||
219 | |||
220 | for (int i = 0; i < m_frames.Count; i++) | ||
221 | { | ||
222 | Keyframe k = m_frames[i]; | ||
223 | k.Position += offset; | ||
224 | m_frames[i]=k; | ||
225 | } | ||
226 | |||
227 | if (m_running) | ||
228 | Start(); | ||
229 | } | ||
230 | } | ||
231 | |||
232 | public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data) | ||
233 | { | ||
234 | m_mode = mode; | ||
235 | m_data = data; | ||
236 | |||
237 | m_group = grp; | ||
238 | if (grp != null) | ||
239 | { | ||
240 | m_basePosition = grp.AbsolutePosition; | ||
241 | m_baseRotation = grp.GroupRotation; | ||
242 | } | ||
243 | |||
244 | m_onTimerLock = new object(); | ||
245 | m_timerStopped = true; | ||
246 | m_inOnTimer = false; | ||
247 | m_isCrossing = false; | ||
248 | m_waitingCrossing = false; | ||
249 | } | ||
250 | |||
251 | public void SetKeyframes(Keyframe[] frames) | ||
252 | { | ||
253 | m_keyframes = frames; | ||
254 | } | ||
255 | |||
256 | public KeyframeMotion Copy(SceneObjectGroup newgrp) | ||
257 | { | ||
258 | StopTimer(); | ||
259 | |||
260 | KeyframeMotion newmotion = new KeyframeMotion(null, m_mode, m_data); | ||
261 | |||
262 | newmotion.m_group = newgrp; | ||
263 | |||
264 | if (m_keyframes != null) | ||
265 | { | ||
266 | newmotion.m_keyframes = new Keyframe[m_keyframes.Length]; | ||
267 | m_keyframes.CopyTo(newmotion.m_keyframes, 0); | ||
268 | } | ||
269 | |||
270 | newmotion.m_frames = new List<Keyframe>(m_frames); | ||
271 | |||
272 | newmotion.m_basePosition = m_basePosition; | ||
273 | newmotion.m_baseRotation = m_baseRotation; | ||
274 | |||
275 | if (m_selected) | ||
276 | newmotion.m_serializedPosition = m_serializedPosition; | ||
277 | else | ||
278 | { | ||
279 | if (m_group != null) | ||
280 | newmotion.m_serializedPosition = m_group.AbsolutePosition; | ||
281 | else | ||
282 | newmotion.m_serializedPosition = m_serializedPosition; | ||
283 | } | ||
284 | |||
285 | newmotion.m_currentFrame = m_currentFrame; | ||
286 | |||
287 | newmotion.m_iterations = m_iterations; | ||
288 | newmotion.m_running = m_running; | ||
289 | |||
290 | if (m_running && !m_waitingCrossing) | ||
291 | StartTimer(); | ||
292 | |||
293 | return newmotion; | ||
294 | } | ||
295 | |||
296 | public void Delete() | ||
297 | { | ||
298 | m_running = false; | ||
299 | RemoveTimer(); | ||
300 | m_isCrossing = false; | ||
301 | m_waitingCrossing = false; | ||
302 | m_frames.Clear(); | ||
303 | m_keyframes = null; | ||
304 | } | ||
305 | |||
306 | public void Start() | ||
307 | { | ||
308 | m_isCrossing = false; | ||
309 | m_waitingCrossing = false; | ||
310 | if (m_keyframes != null && m_group != null && m_keyframes.Length > 0) | ||
311 | { | ||
312 | if (m_timer == null) | ||
313 | { | ||
314 | m_timer = new Timer(); | ||
315 | m_timer.Interval = timerInterval; | ||
316 | m_timer.AutoReset = true; | ||
317 | m_timer.Elapsed += OnTimer; | ||
318 | } | ||
319 | else | ||
320 | { | ||
321 | StopTimer(); | ||
322 | m_timer.Interval = timerInterval; | ||
323 | } | ||
324 | |||
325 | m_inOnTimer = false; | ||
326 | StartTimer(); | ||
327 | m_running = true; | ||
328 | } | ||
329 | else | ||
330 | { | ||
331 | m_running = false; | ||
332 | RemoveTimer(); | ||
333 | } | ||
334 | } | ||
335 | |||
336 | public void Stop() | ||
337 | { | ||
338 | m_running = false; | ||
339 | m_isCrossing = false; | ||
340 | m_waitingCrossing = false; | ||
341 | |||
342 | RemoveTimer(); | ||
343 | |||
344 | m_basePosition = m_group.AbsolutePosition; | ||
345 | m_baseRotation = m_group.GroupRotation; | ||
346 | |||
347 | m_group.RootPart.Velocity = Vector3.Zero; | ||
348 | m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); | ||
349 | m_group.SendGroupRootTerseUpdate(); | ||
350 | |||
351 | m_frames.Clear(); | ||
352 | } | ||
353 | |||
354 | public void Pause() | ||
355 | { | ||
356 | m_running = false; | ||
357 | RemoveTimer(); | ||
358 | |||
359 | m_group.RootPart.Velocity = Vector3.Zero; | ||
360 | m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); | ||
361 | m_group.SendGroupRootTerseUpdate(); | ||
362 | } | ||
363 | |||
364 | private void GetNextList() | ||
365 | { | ||
366 | m_frames.Clear(); | ||
367 | Vector3 pos = m_basePosition; | ||
368 | Quaternion rot = m_baseRotation; | ||
369 | |||
370 | if (m_mode == PlayMode.Loop || m_mode == PlayMode.PingPong || m_iterations == 0) | ||
371 | { | ||
372 | int direction = 1; | ||
373 | if (m_mode == PlayMode.Reverse || ((m_mode == PlayMode.PingPong) && ((m_iterations & 1) != 0))) | ||
374 | direction = -1; | ||
375 | |||
376 | int start = 0; | ||
377 | int end = m_keyframes.Length; | ||
378 | // if (m_mode == PlayMode.PingPong && m_keyframes.Length > 1) | ||
379 | // end = m_keyframes.Length - 1; | ||
380 | |||
381 | if (direction < 0) | ||
382 | { | ||
383 | start = m_keyframes.Length - 1; | ||
384 | end = -1; | ||
385 | // if (m_mode == PlayMode.PingPong && m_keyframes.Length > 1) | ||
386 | // end = 0; | ||
387 | } | ||
388 | |||
389 | for (int i = start; i != end ; i += direction) | ||
390 | { | ||
391 | Keyframe k = m_keyframes[i]; | ||
392 | |||
393 | if (k.Position.HasValue) | ||
394 | { | ||
395 | k.Position = (k.Position * direction); | ||
396 | // k.Velocity = (Vector3)k.Position / (k.TimeMS / 1000.0f); | ||
397 | k.Position += pos; | ||
398 | } | ||
399 | else | ||
400 | { | ||
401 | k.Position = pos; | ||
402 | // k.Velocity = Vector3.Zero; | ||
403 | } | ||
404 | |||
405 | k.StartRotation = rot; | ||
406 | if (k.Rotation.HasValue) | ||
407 | { | ||
408 | if (direction == -1) | ||
409 | k.Rotation = Quaternion.Conjugate((Quaternion)k.Rotation); | ||
410 | k.Rotation = rot * k.Rotation; | ||
411 | } | ||
412 | else | ||
413 | { | ||
414 | k.Rotation = rot; | ||
415 | } | ||
416 | |||
417 | /* ang vel not in use for now | ||
418 | |||
419 | float angle = 0; | ||
420 | |||
421 | float aa = k.StartRotation.X * k.StartRotation.X + k.StartRotation.Y * k.StartRotation.Y + k.StartRotation.Z * k.StartRotation.Z + k.StartRotation.W * k.StartRotation.W; | ||
422 | float bb = ((Quaternion)k.Rotation).X * ((Quaternion)k.Rotation).X + ((Quaternion)k.Rotation).Y * ((Quaternion)k.Rotation).Y + ((Quaternion)k.Rotation).Z * ((Quaternion)k.Rotation).Z + ((Quaternion)k.Rotation).W * ((Quaternion)k.Rotation).W; | ||
423 | float aa_bb = aa * bb; | ||
424 | |||
425 | if (aa_bb == 0) | ||
426 | { | ||
427 | angle = 0; | ||
428 | } | ||
429 | else | ||
430 | { | ||
431 | float ab = k.StartRotation.X * ((Quaternion)k.Rotation).X + | ||
432 | k.StartRotation.Y * ((Quaternion)k.Rotation).Y + | ||
433 | k.StartRotation.Z * ((Quaternion)k.Rotation).Z + | ||
434 | k.StartRotation.W * ((Quaternion)k.Rotation).W; | ||
435 | float q = (ab * ab) / aa_bb; | ||
436 | |||
437 | if (q > 1.0f) | ||
438 | { | ||
439 | angle = 0; | ||
440 | } | ||
441 | else | ||
442 | { | ||
443 | angle = (float)Math.Acos(2 * q - 1); | ||
444 | } | ||
445 | } | ||
446 | |||
447 | k.AngularVelocity = (new Vector3(0, 0, 1) * (Quaternion)k.Rotation) * (angle / (k.TimeMS / 1000)); | ||
448 | */ | ||
449 | k.TimeTotal = k.TimeMS; | ||
450 | |||
451 | m_frames.Add(k); | ||
452 | |||
453 | pos = (Vector3)k.Position; | ||
454 | rot = (Quaternion)k.Rotation; | ||
455 | } | ||
456 | |||
457 | m_basePosition = pos; | ||
458 | m_baseRotation = rot; | ||
459 | |||
460 | m_iterations++; | ||
461 | } | ||
462 | } | ||
463 | |||
464 | protected void OnTimer(object sender, ElapsedEventArgs e) | ||
465 | { | ||
466 | if (m_timerStopped) // trap events still in air even after a timer.stop | ||
467 | return; | ||
468 | |||
469 | if (m_inOnTimer) // don't let overruns to happen | ||
470 | { | ||
471 | m_log.Warn("[KeyFrame]: timer overrun"); | ||
472 | return; | ||
473 | } | ||
474 | |||
475 | if (m_group == null) | ||
476 | return; | ||
477 | |||
478 | lock (m_onTimerLock) | ||
479 | { | ||
480 | |||
481 | m_inOnTimer = true; | ||
482 | |||
483 | bool update = false; | ||
484 | |||
485 | try | ||
486 | { | ||
487 | if (m_selected) | ||
488 | { | ||
489 | if (m_group.RootPart.Velocity != Vector3.Zero) | ||
490 | { | ||
491 | m_group.RootPart.Velocity = Vector3.Zero; | ||
492 | m_group.SendGroupRootTerseUpdate(); | ||
493 | } | ||
494 | m_inOnTimer = false; | ||
495 | return; | ||
496 | } | ||
497 | |||
498 | if (m_isCrossing) | ||
499 | { | ||
500 | // if crossing and timer running then cross failed | ||
501 | // wait some time then | ||
502 | // retry to set the position that evtually caused the outbound | ||
503 | // if still outside region this will call startCrossing below | ||
504 | m_isCrossing = false; | ||
505 | m_group.AbsolutePosition = m_nextPosition; | ||
506 | if (!m_isCrossing) | ||
507 | { | ||
508 | StopTimer(); | ||
509 | m_timer.Interval = timerInterval; | ||
510 | StartTimer(); | ||
511 | } | ||
512 | m_inOnTimer = false; | ||
513 | return; | ||
514 | } | ||
515 | |||
516 | if (m_frames.Count == 0) | ||
517 | { | ||
518 | GetNextList(); | ||
519 | |||
520 | if (m_frames.Count == 0) | ||
521 | { | ||
522 | Stop(); | ||
523 | m_inOnTimer = false; | ||
524 | return; | ||
525 | } | ||
526 | |||
527 | m_currentFrame = m_frames[0]; | ||
528 | m_currentFrame.TimeMS += (int)timerInterval; | ||
529 | |||
530 | //force a update on a keyframe transition | ||
531 | update = true; | ||
532 | } | ||
533 | |||
534 | m_currentFrame.TimeMS -= (int)timerInterval; | ||
535 | |||
536 | // Do the frame processing | ||
537 | double steps = (double)m_currentFrame.TimeMS / timerInterval; | ||
538 | |||
539 | if (steps <= 0.0) | ||
540 | { | ||
541 | m_group.RootPart.Velocity = Vector3.Zero; | ||
542 | m_group.RootPart.UpdateAngularVelocity(Vector3.Zero); | ||
543 | |||
544 | m_nextPosition = (Vector3)m_currentFrame.Position; | ||
545 | m_group.AbsolutePosition = m_nextPosition; | ||
546 | |||
547 | m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); | ||
548 | |||
549 | m_frames.RemoveAt(0); | ||
550 | if (m_frames.Count > 0) | ||
551 | m_currentFrame = m_frames[0]; | ||
552 | |||
553 | update = true; | ||
554 | } | ||
555 | else | ||
556 | { | ||
557 | float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; | ||
558 | |||
559 | Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition; | ||
560 | Vector3 motionThisFrame = v / (float)steps; | ||
561 | v = v * 1000 / m_currentFrame.TimeMS; | ||
562 | |||
563 | if (Vector3.Mag(motionThisFrame) >= 0.05f) | ||
564 | { | ||
565 | // m_group.AbsolutePosition += motionThisFrame; | ||
566 | m_nextPosition = m_group.AbsolutePosition + motionThisFrame; | ||
567 | m_group.AbsolutePosition = m_nextPosition; | ||
568 | |||
569 | m_group.RootPart.Velocity = v; | ||
570 | update = true; | ||
571 | } | ||
572 | |||
573 | if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation) | ||
574 | { | ||
575 | Quaternion current = m_group.GroupRotation; | ||
576 | |||
577 | Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); | ||
578 | step.Normalize(); | ||
579 | /* use simpler change detection | ||
580 | * float angle = 0; | ||
581 | |||
582 | float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; | ||
583 | float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; | ||
584 | float aa_bb = aa * bb; | ||
585 | |||
586 | if (aa_bb == 0) | ||
587 | { | ||
588 | angle = 0; | ||
589 | } | ||
590 | else | ||
591 | { | ||
592 | float ab = current.X * step.X + | ||
593 | current.Y * step.Y + | ||
594 | current.Z * step.Z + | ||
595 | current.W * step.W; | ||
596 | float q = (ab * ab) / aa_bb; | ||
597 | |||
598 | if (q > 1.0f) | ||
599 | { | ||
600 | angle = 0; | ||
601 | } | ||
602 | else | ||
603 | { | ||
604 | angle = (float)Math.Acos(2 * q - 1); | ||
605 | } | ||
606 | } | ||
607 | |||
608 | if (angle > 0.01f) | ||
609 | */ | ||
610 | if(Math.Abs(step.X - current.X) > 0.001f | ||
611 | || Math.Abs(step.Y - current.Y) > 0.001f | ||
612 | || Math.Abs(step.Z - current.Z) > 0.001f) | ||
613 | // assuming w is a dependente var | ||
614 | |||
615 | { | ||
616 | m_group.UpdateGroupRotationR(step); | ||
617 | //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); | ||
618 | update = true; | ||
619 | } | ||
620 | } | ||
621 | } | ||
622 | |||
623 | if (update) | ||
624 | m_group.SendGroupRootTerseUpdate(); | ||
625 | |||
626 | } | ||
627 | catch ( Exception ex) | ||
628 | { | ||
629 | // still happening sometimes | ||
630 | // lets try to see where | ||
631 | m_log.Warn("[KeyFrame]: timer overrun" + ex.Message); | ||
632 | } | ||
633 | |||
634 | finally | ||
635 | { | ||
636 | // make sure we do not let this frozen | ||
637 | m_inOnTimer = false; | ||
638 | } | ||
639 | } | ||
640 | } | ||
641 | |||
642 | public Byte[] Serialize() | ||
643 | { | ||
644 | StopTimer(); | ||
645 | MemoryStream ms = new MemoryStream(); | ||
646 | |||
647 | BinaryFormatter fmt = new BinaryFormatter(); | ||
648 | SceneObjectGroup tmp = m_group; | ||
649 | m_group = null; | ||
650 | if (!m_selected && tmp != null) | ||
651 | m_serializedPosition = tmp.AbsolutePosition; | ||
652 | fmt.Serialize(ms, this); | ||
653 | m_group = tmp; | ||
654 | if (m_running && !m_waitingCrossing) | ||
655 | StartTimer(); | ||
656 | |||
657 | return ms.ToArray(); | ||
658 | } | ||
659 | |||
660 | public void StartCrossingCheck() | ||
661 | { | ||
662 | // timer will be restart by crossingFailure | ||
663 | // or never since crossing worked and this | ||
664 | // should be deleted | ||
665 | StopTimer(); | ||
666 | |||
667 | m_isCrossing = true; | ||
668 | m_waitingCrossing = true; | ||
669 | |||
670 | // to remove / retune to smoth crossings | ||
671 | if (m_group.RootPart.Velocity != Vector3.Zero) | ||
672 | { | ||
673 | m_group.RootPart.Velocity = Vector3.Zero; | ||
674 | m_group.SendGroupRootTerseUpdate(); | ||
675 | } | ||
676 | } | ||
677 | |||
678 | public void CrossingFailure() | ||
679 | { | ||
680 | m_waitingCrossing = false; | ||
681 | |||
682 | if (m_group != null) | ||
683 | { | ||
684 | m_group.RootPart.Velocity = Vector3.Zero; | ||
685 | m_group.SendGroupRootTerseUpdate(); | ||
686 | |||
687 | if (m_running && m_timer != null) | ||
688 | { | ||
689 | m_timer.Interval = 60000; | ||
690 | StartTimer(); | ||
691 | } | ||
692 | } | ||
693 | } | ||
694 | } | ||
695 | } | ||
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 b23ddb4..6208a57 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -101,12 +101,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
101 | engine.StartProcessing(); | 101 | engine.StartProcessing(); |
102 | } | 102 | } |
103 | 103 | ||
104 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) | 104 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item, uint cost) |
105 | { | 105 | { |
106 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); | 106 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); |
107 | if (money != null) | 107 | if (money != null) |
108 | { | 108 | { |
109 | money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload"); | 109 | money.ApplyUploadCharge(agentID, (int)cost, "Asset upload"); |
110 | } | 110 | } |
111 | 111 | ||
112 | AddInventoryItem(item); | 112 | AddInventoryItem(item); |
@@ -169,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
169 | return false; | 169 | return false; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | if (InventoryService.AddItem(item)) | 173 | if (InventoryService.AddItem(item)) |
174 | { | 174 | { |
175 | int userlevel = 0; | 175 | int userlevel = 0; |
@@ -324,8 +324,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
324 | 324 | ||
325 | // Update item with new asset | 325 | // Update item with new asset |
326 | item.AssetID = asset.FullID; | 326 | item.AssetID = asset.FullID; |
327 | if (group.UpdateInventoryItem(item)) | 327 | group.UpdateInventoryItem(item); |
328 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
329 | 328 | ||
330 | part.SendPropertiesToClient(remoteClient); | 329 | part.SendPropertiesToClient(remoteClient); |
331 | 330 | ||
@@ -336,12 +335,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
336 | { | 335 | { |
337 | // Needs to determine which engine was running it and use that | 336 | // Needs to determine which engine was running it and use that |
338 | // | 337 | // |
339 | part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); | 338 | errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 1); |
340 | errors = part.Inventory.GetScriptErrors(item.ItemID); | ||
341 | } | ||
342 | else | ||
343 | { | ||
344 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
345 | } | 339 | } |
346 | 340 | ||
347 | // Tell anyone managing scripts that a script has been reloaded/changed | 341 | // Tell anyone managing scripts that a script has been reloaded/changed |
@@ -409,6 +403,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
409 | 403 | ||
410 | if (UUID.Zero == transactionID) | 404 | if (UUID.Zero == transactionID) |
411 | { | 405 | { |
406 | item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); | ||
412 | item.Name = itemUpd.Name; | 407 | item.Name = itemUpd.Name; |
413 | item.Description = itemUpd.Description; | 408 | item.Description = itemUpd.Description; |
414 | 409 | ||
@@ -795,6 +790,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
795 | return; | 790 | return; |
796 | } | 791 | } |
797 | 792 | ||
793 | if (newName == null) newName = item.Name; | ||
794 | |||
798 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 795 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
799 | 796 | ||
800 | if (asset != null) | 797 | if (asset != null) |
@@ -855,6 +852,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
855 | } | 852 | } |
856 | 853 | ||
857 | /// <summary> | 854 | /// <summary> |
855 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
856 | /// </summary> | ||
857 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
858 | { | ||
859 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
860 | foreach (InventoryItemBase b in items) | ||
861 | { | ||
862 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
863 | InventoryItemBase n = InventoryService.GetItem(b); | ||
864 | n.Folder = destfolder; | ||
865 | moveitems.Add(n); | ||
866 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
867 | } | ||
868 | |||
869 | MoveInventoryItem(remoteClient, moveitems); | ||
870 | } | ||
871 | |||
872 | /// <summary> | ||
858 | /// Move an item within the agent's inventory. | 873 | /// Move an item within the agent's inventory. |
859 | /// </summary> | 874 | /// </summary> |
860 | /// <param name="remoteClient"></param> | 875 | /// <param name="remoteClient"></param> |
@@ -889,11 +904,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
889 | public void CreateNewInventoryItem( | 904 | public void CreateNewInventoryItem( |
890 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 905 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
891 | string name, string description, uint flags, uint callbackID, | 906 | string name, string description, uint flags, uint callbackID, |
892 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) | 907 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate, UUID transationID) |
893 | { | 908 | { |
894 | CreateNewInventoryItem( | 909 | CreateNewInventoryItem( |
895 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, | 910 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, |
896 | (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate); | 911 | (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate, transationID); |
912 | } | ||
913 | |||
914 | |||
915 | private void CreateNewInventoryItem( | ||
916 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | ||
917 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | ||
918 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | ||
919 | { | ||
920 | CreateNewInventoryItem(remoteClient, creatorID, creatorData, folderID, | ||
921 | name, description, flags, callbackID, asset, invType, | ||
922 | baseMask, currentMask, everyoneMask, nextOwnerMask, groupMask, creationDate, UUID.Zero); | ||
897 | } | 923 | } |
898 | 924 | ||
899 | /// <summary> | 925 | /// <summary> |
@@ -918,7 +944,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
918 | private void CreateNewInventoryItem( | 944 | private void CreateNewInventoryItem( |
919 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 945 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
920 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | 946 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, |
921 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | 947 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate,UUID transationID) |
922 | { | 948 | { |
923 | InventoryItemBase item = new InventoryItemBase(); | 949 | InventoryItemBase item = new InventoryItemBase(); |
924 | item.Owner = remoteClient.AgentId; | 950 | item.Owner = remoteClient.AgentId; |
@@ -941,7 +967,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
941 | 967 | ||
942 | if (AddInventoryItem(item)) | 968 | if (AddInventoryItem(item)) |
943 | { | 969 | { |
944 | remoteClient.SendInventoryItemCreateUpdate(item, callbackID); | 970 | remoteClient.SendInventoryItemCreateUpdate(item, transationID, callbackID); |
945 | } | 971 | } |
946 | else | 972 | else |
947 | { | 973 | { |
@@ -1216,6 +1242,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1216 | { | 1242 | { |
1217 | SceneObjectPart part = GetSceneObjectPart(primLocalId); | 1243 | SceneObjectPart part = GetSceneObjectPart(primLocalId); |
1218 | 1244 | ||
1245 | // Can't move a null item | ||
1246 | if (itemId == UUID.Zero) | ||
1247 | return; | ||
1248 | |||
1219 | if (null == part) | 1249 | if (null == part) |
1220 | { | 1250 | { |
1221 | m_log.WarnFormat( | 1251 | m_log.WarnFormat( |
@@ -1320,21 +1350,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1320 | return; | 1350 | return; |
1321 | } | 1351 | } |
1322 | 1352 | ||
1323 | if (part.OwnerID != destPart.OwnerID) | 1353 | // Can't transfer this |
1354 | // | ||
1355 | if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1356 | return; | ||
1357 | |||
1358 | bool overrideNoMod = false; | ||
1359 | if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) | ||
1360 | overrideNoMod = true; | ||
1361 | |||
1362 | if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1324 | { | 1363 | { |
1325 | // Source must have transfer permissions | 1364 | // object cannot copy items to an object owned by a different owner |
1326 | if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | 1365 | // unless llAllowInventoryDrop has been called |
1327 | return; | ||
1328 | 1366 | ||
1329 | // Object cannot copy items to an object owned by a different owner | 1367 | return; |
1330 | // unless llAllowInventoryDrop has been called on the destination | ||
1331 | if ((destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1332 | return; | ||
1333 | } | 1368 | } |
1334 | 1369 | ||
1335 | // must have both move and modify permission to put an item in an object | 1370 | // must have both move and modify permission to put an item in an object |
1336 | if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) | 1371 | if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) |
1372 | { | ||
1337 | return; | 1373 | return; |
1374 | } | ||
1338 | 1375 | ||
1339 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); | 1376 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); |
1340 | 1377 | ||
@@ -1390,6 +1427,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1390 | 1427 | ||
1391 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1428 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1392 | { | 1429 | { |
1430 | SceneObjectPart destPart = GetSceneObjectPart(destID); | ||
1431 | if (destPart != null) // Move into a prim | ||
1432 | { | ||
1433 | foreach(UUID itemID in items) | ||
1434 | MoveTaskInventoryItem(destID, host, itemID); | ||
1435 | return destID; // Prim folder ID == prim ID | ||
1436 | } | ||
1437 | |||
1393 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1438 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1394 | 1439 | ||
1395 | UUID newFolderID = UUID.Random(); | 1440 | UUID newFolderID = UUID.Random(); |
@@ -1572,12 +1617,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1572 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( | 1617 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( |
1573 | remoteClient, part, transactionID, currentItem); | 1618 | remoteClient, part, transactionID, currentItem); |
1574 | 1619 | ||
1575 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | 1620 | // if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) |
1576 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | 1621 | // remoteClient.SendAgentAlertMessage("Notecard saved", false); |
1577 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | 1622 | // else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) |
1578 | remoteClient.SendAgentAlertMessage("Script saved", false); | 1623 | // remoteClient.SendAgentAlertMessage("Script saved", false); |
1579 | else | 1624 | // else |
1580 | remoteClient.SendAgentAlertMessage("Item saved", false); | 1625 | // remoteClient.SendAgentAlertMessage("Item saved", false); |
1581 | } | 1626 | } |
1582 | 1627 | ||
1583 | // Base ALWAYS has move | 1628 | // Base ALWAYS has move |
@@ -1760,7 +1805,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1760 | } | 1805 | } |
1761 | 1806 | ||
1762 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1807 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1763 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1808 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), |
1764 | agentID); | 1809 | agentID); |
1765 | AssetService.Store(asset); | 1810 | AssetService.Store(asset); |
1766 | 1811 | ||
@@ -1916,23 +1961,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1916 | // build a list of eligible objects | 1961 | // build a list of eligible objects |
1917 | List<uint> deleteIDs = new List<uint>(); | 1962 | List<uint> deleteIDs = new List<uint>(); |
1918 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 1963 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
1919 | 1964 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
1920 | // Start with true for both, then remove the flags if objects | ||
1921 | // that we can't derez are part of the selection | ||
1922 | bool permissionToTake = true; | ||
1923 | bool permissionToTakeCopy = true; | ||
1924 | bool permissionToDelete = true; | ||
1925 | 1965 | ||
1926 | foreach (uint localID in localIDs) | 1966 | foreach (uint localID in localIDs) |
1927 | { | 1967 | { |
1968 | // Start with true for both, then remove the flags if objects | ||
1969 | // that we can't derez are part of the selection | ||
1970 | bool permissionToTake = true; | ||
1971 | bool permissionToTakeCopy = true; | ||
1972 | bool permissionToDelete = true; | ||
1973 | |||
1928 | // Invalid id | 1974 | // Invalid id |
1929 | SceneObjectPart part = GetSceneObjectPart(localID); | 1975 | SceneObjectPart part = GetSceneObjectPart(localID); |
1930 | if (part == null) | 1976 | if (part == null) |
1977 | { | ||
1978 | //Client still thinks the object exists, kill it | ||
1979 | deleteIDs.Add(localID); | ||
1931 | continue; | 1980 | continue; |
1981 | } | ||
1932 | 1982 | ||
1933 | // Already deleted by someone else | 1983 | // Already deleted by someone else |
1934 | if (part.ParentGroup.IsDeleted) | 1984 | if (part.ParentGroup.IsDeleted) |
1985 | { | ||
1986 | //Client still thinks the object exists, kill it | ||
1987 | deleteIDs.Add(localID); | ||
1935 | continue; | 1988 | continue; |
1989 | } | ||
1936 | 1990 | ||
1937 | // Can't delete child prims | 1991 | // Can't delete child prims |
1938 | if (part != part.ParentGroup.RootPart) | 1992 | if (part != part.ParentGroup.RootPart) |
@@ -1940,8 +1994,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1940 | 1994 | ||
1941 | SceneObjectGroup grp = part.ParentGroup; | 1995 | SceneObjectGroup grp = part.ParentGroup; |
1942 | 1996 | ||
1943 | deleteIDs.Add(localID); | 1997 | // If child prims have invalid perms, fix them |
1944 | deleteGroups.Add(grp); | 1998 | grp.AdjustChildPrimPermissions(); |
1945 | 1999 | ||
1946 | // If child prims have invalid perms, fix them | 2000 | // If child prims have invalid perms, fix them |
1947 | grp.AdjustChildPrimPermissions(); | 2001 | grp.AdjustChildPrimPermissions(); |
@@ -1962,81 +2016,193 @@ namespace OpenSim.Region.Framework.Scenes | |||
1962 | } | 2016 | } |
1963 | else | 2017 | else |
1964 | { | 2018 | { |
1965 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 2019 | if (action == DeRezAction.TakeCopy) |
2020 | { | ||
2021 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
2022 | permissionToTakeCopy = false; | ||
2023 | } | ||
2024 | else | ||
2025 | { | ||
1966 | permissionToTakeCopy = false; | 2026 | permissionToTakeCopy = false; |
1967 | 2027 | } | |
1968 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 2028 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
1969 | permissionToTake = false; | 2029 | permissionToTake = false; |
1970 | 2030 | ||
1971 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 2031 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
1972 | permissionToDelete = false; | 2032 | permissionToDelete = false; |
1973 | } | 2033 | } |
1974 | } | ||
1975 | 2034 | ||
1976 | // Handle god perms | 2035 | // Handle god perms |
1977 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 2036 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
1978 | { | 2037 | { |
1979 | permissionToTake = true; | 2038 | permissionToTake = true; |
1980 | permissionToTakeCopy = true; | 2039 | permissionToTakeCopy = true; |
1981 | permissionToDelete = true; | 2040 | permissionToDelete = true; |
1982 | } | 2041 | } |
1983 | 2042 | ||
1984 | // If we're re-saving, we don't even want to delete | 2043 | // If we're re-saving, we don't even want to delete |
1985 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | 2044 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
1986 | permissionToDelete = false; | 2045 | permissionToDelete = false; |
1987 | 2046 | ||
1988 | // if we want to take a copy, we also don't want to delete | 2047 | // if we want to take a copy, we also don't want to delete |
1989 | // Note: after this point, the permissionToTakeCopy flag | 2048 | // Note: after this point, the permissionToTakeCopy flag |
1990 | // becomes irrelevant. It already includes the permissionToTake | 2049 | // becomes irrelevant. It already includes the permissionToTake |
1991 | // permission and after excluding no copy items here, we can | 2050 | // permission and after excluding no copy items here, we can |
1992 | // just use that. | 2051 | // just use that. |
1993 | if (action == DeRezAction.TakeCopy) | 2052 | if (action == DeRezAction.TakeCopy) |
1994 | { | 2053 | { |
1995 | // If we don't have permission, stop right here | 2054 | // If we don't have permission, stop right here |
1996 | if (!permissionToTakeCopy) | 2055 | if (!permissionToTakeCopy) |
1997 | return; | 2056 | return; |
1998 | 2057 | ||
1999 | permissionToTake = true; | 2058 | permissionToTake = true; |
2000 | // Don't delete | 2059 | // Don't delete |
2001 | permissionToDelete = false; | 2060 | permissionToDelete = false; |
2002 | } | 2061 | } |
2003 | 2062 | ||
2004 | if (action == DeRezAction.Return) | 2063 | if (action == DeRezAction.Return) |
2005 | { | ||
2006 | if (remoteClient != null) | ||
2007 | { | 2064 | { |
2008 | if (Permissions.CanReturnObjects( | 2065 | if (remoteClient != null) |
2009 | null, | ||
2010 | remoteClient.AgentId, | ||
2011 | deleteGroups)) | ||
2012 | { | 2066 | { |
2013 | permissionToTake = true; | 2067 | if (Permissions.CanReturnObjects( |
2014 | permissionToDelete = true; | 2068 | null, |
2015 | 2069 | remoteClient.AgentId, | |
2016 | foreach (SceneObjectGroup g in deleteGroups) | 2070 | new List<SceneObjectGroup>() {grp})) |
2017 | { | 2071 | { |
2018 | AddReturn(g.OwnerID == g.GroupID ? g.LastOwnerID : g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 2072 | permissionToTake = true; |
2073 | permissionToDelete = true; | ||
2074 | |||
2075 | AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
2019 | } | 2076 | } |
2020 | } | 2077 | } |
2078 | else // Auto return passes through here with null agent | ||
2079 | { | ||
2080 | permissionToTake = true; | ||
2081 | permissionToDelete = true; | ||
2082 | } | ||
2021 | } | 2083 | } |
2022 | else // Auto return passes through here with null agent | 2084 | |
2085 | if (permissionToTake && (!permissionToDelete)) | ||
2086 | takeGroups.Add(grp); | ||
2087 | |||
2088 | if (permissionToDelete) | ||
2023 | { | 2089 | { |
2024 | permissionToTake = true; | 2090 | if (permissionToTake) |
2025 | permissionToDelete = true; | 2091 | deleteGroups.Add(grp); |
2092 | deleteIDs.Add(grp.LocalId); | ||
2026 | } | 2093 | } |
2027 | } | 2094 | } |
2028 | 2095 | ||
2029 | if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) | 2096 | SendKillObject(deleteIDs); |
2097 | |||
2098 | if (deleteGroups.Count > 0) | ||
2030 | { | 2099 | { |
2100 | foreach (SceneObjectGroup g in deleteGroups) | ||
2101 | deleteIDs.Remove(g.LocalId); | ||
2102 | |||
2031 | m_asyncSceneObjectDeleter.DeleteToInventory( | 2103 | m_asyncSceneObjectDeleter.DeleteToInventory( |
2032 | action, destinationID, deleteGroups, remoteClient, | 2104 | action, destinationID, deleteGroups, remoteClient, |
2033 | permissionToDelete); | 2105 | true); |
2106 | } | ||
2107 | if (takeGroups.Count > 0) | ||
2108 | { | ||
2109 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
2110 | action, destinationID, takeGroups, remoteClient, | ||
2111 | false); | ||
2034 | } | 2112 | } |
2035 | else if (permissionToDelete) | 2113 | if (deleteIDs.Count > 0) |
2036 | { | 2114 | { |
2037 | foreach (SceneObjectGroup g in deleteGroups) | 2115 | foreach (SceneObjectGroup g in deleteGroups) |
2038 | DeleteSceneObject(g, false); | 2116 | DeleteSceneObject(g, true); |
2117 | } | ||
2118 | } | ||
2119 | |||
2120 | public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) | ||
2121 | { | ||
2122 | itemID = UUID.Zero; | ||
2123 | if (grp != null) | ||
2124 | { | ||
2125 | Vector3 inventoryStoredPosition = new Vector3 | ||
2126 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
2127 | ? 250 | ||
2128 | : grp.AbsolutePosition.X) | ||
2129 | , | ||
2130 | (grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
2131 | ? 250 | ||
2132 | : grp.AbsolutePosition.X, | ||
2133 | grp.AbsolutePosition.Z); | ||
2134 | |||
2135 | Vector3 originalPosition = grp.AbsolutePosition; | ||
2136 | |||
2137 | grp.AbsolutePosition = inventoryStoredPosition; | ||
2138 | |||
2139 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
2140 | |||
2141 | grp.AbsolutePosition = originalPosition; | ||
2142 | |||
2143 | AssetBase asset = CreateAsset( | ||
2144 | grp.GetPartName(grp.LocalId), | ||
2145 | grp.GetPartDescription(grp.LocalId), | ||
2146 | (sbyte)AssetType.Object, | ||
2147 | Utils.StringToBytes(sceneObjectXml), | ||
2148 | remoteClient.AgentId); | ||
2149 | AssetService.Store(asset); | ||
2150 | |||
2151 | InventoryItemBase item = new InventoryItemBase(); | ||
2152 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
2153 | item.CreatorData = grp.RootPart.CreatorData; | ||
2154 | item.Owner = remoteClient.AgentId; | ||
2155 | item.ID = UUID.Random(); | ||
2156 | item.AssetID = asset.FullID; | ||
2157 | item.Description = asset.Description; | ||
2158 | item.Name = asset.Name; | ||
2159 | item.AssetType = asset.Type; | ||
2160 | item.InvType = (int)InventoryType.Object; | ||
2161 | |||
2162 | InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
2163 | if (folder != null) | ||
2164 | item.Folder = folder.ID; | ||
2165 | else // oopsies | ||
2166 | item.Folder = UUID.Zero; | ||
2167 | |||
2168 | // Set up base perms properly | ||
2169 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
2170 | permsBase &= grp.RootPart.BaseMask; | ||
2171 | permsBase |= (uint)PermissionMask.Move; | ||
2172 | |||
2173 | // Make sure we don't lock it | ||
2174 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
2175 | |||
2176 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
2177 | { | ||
2178 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2179 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2180 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2181 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
2182 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
2183 | } | ||
2184 | else | ||
2185 | { | ||
2186 | item.BasePermissions = permsBase; | ||
2187 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; | ||
2188 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2189 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; | ||
2190 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; | ||
2191 | } | ||
2192 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
2193 | |||
2194 | // sets itemID so client can show item as 'attached' in inventory | ||
2195 | grp.FromItemID = item.ID; | ||
2196 | |||
2197 | if (AddInventoryItem(item)) | ||
2198 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
2199 | else | ||
2200 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
2201 | |||
2202 | itemID = item.ID; | ||
2203 | return item.AssetID; | ||
2039 | } | 2204 | } |
2205 | return UUID.Zero; | ||
2040 | } | 2206 | } |
2041 | 2207 | ||
2042 | /// <summary> | 2208 | /// <summary> |
@@ -2166,6 +2332,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2166 | 2332 | ||
2167 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2333 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2168 | { | 2334 | { |
2335 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2336 | return; | ||
2337 | |||
2169 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2338 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2170 | if (part == null) | 2339 | if (part == null) |
2171 | return; | 2340 | return; |
@@ -2222,7 +2391,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2222 | } | 2391 | } |
2223 | else | 2392 | else |
2224 | { | 2393 | { |
2225 | if (!Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) | 2394 | if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId) |
2395 | continue; | ||
2396 | |||
2397 | if (!Permissions.CanTransferObject(sog.UUID, groupID)) | ||
2226 | continue; | 2398 | continue; |
2227 | 2399 | ||
2228 | if (sog.GroupID != groupID) | 2400 | if (sog.GroupID != groupID) |
@@ -2334,6 +2506,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2334 | } | 2506 | } |
2335 | 2507 | ||
2336 | m_sceneGraph.LinkObjects(root, children); | 2508 | m_sceneGraph.LinkObjects(root, children); |
2509 | |||
2510 | ScenePresence sp; | ||
2511 | if (TryGetScenePresence(agentId, out sp)) | ||
2512 | { | ||
2513 | root.SendPropertiesToClient(sp.ControllingClient); | ||
2514 | } | ||
2337 | } | 2515 | } |
2338 | 2516 | ||
2339 | private string PermissionString(uint permissions) | 2517 | private string PermissionString(uint permissions) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index df43271..ce6415a 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, |
@@ -412,6 +438,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
412 | ); | 438 | ); |
413 | } | 439 | } |
414 | 440 | ||
441 | private class DescendentsRequestData | ||
442 | { | ||
443 | public IClientAPI RemoteClient; | ||
444 | public UUID FolderID; | ||
445 | public UUID OwnerID; | ||
446 | public bool FetchFolders; | ||
447 | public bool FetchItems; | ||
448 | public int SortOrder; | ||
449 | } | ||
450 | |||
451 | private Queue<DescendentsRequestData> m_descendentsRequestQueue = new Queue<DescendentsRequestData>(); | ||
452 | private Object m_descendentsRequestLock = new Object(); | ||
453 | private bool m_descendentsRequestProcessing = false; | ||
454 | |||
415 | /// <summary> | 455 | /// <summary> |
416 | /// Tell the client about the various child items and folders contained in the requested folder. | 456 | /// Tell the client about the various child items and folders contained in the requested folder. |
417 | /// </summary> | 457 | /// </summary> |
@@ -448,17 +488,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
448 | } | 488 | } |
449 | } | 489 | } |
450 | 490 | ||
451 | // We're going to send the reply async, because there may be | 491 | lock (m_descendentsRequestLock) |
452 | // an enormous quantity of packets -- basically the entire inventory! | 492 | { |
453 | // We don't want to block the client thread while all that is happening. | 493 | if (!m_descendentsRequestProcessing) |
454 | SendInventoryDelegate d = SendInventoryAsync; | 494 | { |
455 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | 495 | m_descendentsRequestProcessing = true; |
496 | |||
497 | // We're going to send the reply async, because there may be | ||
498 | // an enormous quantity of packets -- basically the entire inventory! | ||
499 | // We don't want to block the client thread while all that is happening. | ||
500 | SendInventoryDelegate d = SendInventoryAsync; | ||
501 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | ||
502 | |||
503 | return; | ||
504 | } | ||
505 | |||
506 | DescendentsRequestData req = new DescendentsRequestData(); | ||
507 | req.RemoteClient = remoteClient; | ||
508 | req.FolderID = folderID; | ||
509 | req.OwnerID = ownerID; | ||
510 | req.FetchFolders = fetchFolders; | ||
511 | req.FetchItems = fetchItems; | ||
512 | req.SortOrder = sortOrder; | ||
513 | |||
514 | m_descendentsRequestQueue.Enqueue(req); | ||
515 | } | ||
456 | } | 516 | } |
457 | 517 | ||
458 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); | 518 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); |
459 | 519 | ||
460 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) | 520 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) |
461 | { | 521 | { |
522 | Thread.Sleep(20); | ||
462 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); | 523 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); |
463 | } | 524 | } |
464 | 525 | ||
@@ -466,6 +527,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
466 | { | 527 | { |
467 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; | 528 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; |
468 | d.EndInvoke(iar); | 529 | d.EndInvoke(iar); |
530 | |||
531 | lock (m_descendentsRequestLock) | ||
532 | { | ||
533 | if (m_descendentsRequestQueue.Count > 0) | ||
534 | { | ||
535 | DescendentsRequestData req = m_descendentsRequestQueue.Dequeue(); | ||
536 | |||
537 | d = SendInventoryAsync; | ||
538 | d.BeginInvoke(req.RemoteClient, req.FolderID, req.OwnerID, req.FetchFolders, req.FetchItems, req.SortOrder, SendInventoryComplete, d); | ||
539 | |||
540 | return; | ||
541 | } | ||
542 | |||
543 | m_descendentsRequestProcessing = false; | ||
544 | } | ||
469 | } | 545 | } |
470 | 546 | ||
471 | /// <summary> | 547 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 69c1027..4282b46 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -156,8 +156,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
156 | // TODO: need to figure out how allow client agents but deny | 156 | // TODO: need to figure out how allow client agents but deny |
157 | // root agents when ACL denies access to root agent | 157 | // root agents when ACL denies access to root agent |
158 | public bool m_strictAccessControl = true; | 158 | public bool m_strictAccessControl = true; |
159 | 159 | public bool m_seeIntoBannedRegion = false; | |
160 | public int MaxUndoCount { get; set; } | 160 | public int MaxUndoCount = 5; |
161 | 161 | ||
162 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 162 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
163 | public bool LoginLock = false; | 163 | public bool LoginLock = false; |
@@ -173,12 +173,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
173 | 173 | ||
174 | protected int m_splitRegionID; | 174 | protected int m_splitRegionID; |
175 | protected Timer m_restartWaitTimer = new Timer(); | 175 | protected Timer m_restartWaitTimer = new Timer(); |
176 | protected Timer m_timerWatchdog = new Timer(); | ||
176 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 177 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
177 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 178 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
178 | protected string m_simulatorVersion = "OpenSimulator Server"; | 179 | protected string m_simulatorVersion = "OpenSimulator Server"; |
179 | protected ModuleLoader m_moduleLoader; | 180 | protected ModuleLoader m_moduleLoader; |
180 | protected AgentCircuitManager m_authenticateHandler; | 181 | protected AgentCircuitManager m_authenticateHandler; |
181 | protected SceneCommunicationService m_sceneGridService; | 182 | protected SceneCommunicationService m_sceneGridService; |
183 | protected ISnmpModule m_snmpService = null; | ||
182 | 184 | ||
183 | protected ISimulationDataService m_SimulationDataService; | 185 | protected ISimulationDataService m_SimulationDataService; |
184 | protected IEstateDataService m_EstateDataService; | 186 | protected IEstateDataService m_EstateDataService; |
@@ -241,8 +243,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
241 | private int m_update_presences = 1; // Update scene presence movements | 243 | private int m_update_presences = 1; // Update scene presence movements |
242 | private int m_update_events = 1; | 244 | private int m_update_events = 1; |
243 | private int m_update_backup = 200; | 245 | private int m_update_backup = 200; |
244 | private int m_update_terrain = 50; | 246 | private int m_update_terrain = 1000; |
245 | // private int m_update_land = 1; | 247 | private int m_update_land = 10; |
246 | private int m_update_coarse_locations = 50; | 248 | private int m_update_coarse_locations = 50; |
247 | 249 | ||
248 | private int agentMS; | 250 | private int agentMS; |
@@ -255,13 +257,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
255 | private int backupMS; | 257 | private int backupMS; |
256 | private int terrainMS; | 258 | private int terrainMS; |
257 | private int landMS; | 259 | private int landMS; |
258 | private int spareMS; | ||
259 | 260 | ||
260 | /// <summary> | 261 | /// <summary> |
261 | /// Tick at which the last frame was processed. | 262 | /// Tick at which the last frame was processed. |
262 | /// </summary> | 263 | /// </summary> |
263 | private int m_lastFrameTick; | 264 | private int m_lastFrameTick; |
264 | 265 | ||
266 | public bool CombineRegions = false; | ||
265 | /// <summary> | 267 | /// <summary> |
266 | /// Tick at which the last maintenance run occurred. | 268 | /// Tick at which the last maintenance run occurred. |
267 | /// </summary> | 269 | /// </summary> |
@@ -292,6 +294,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
292 | /// </summary> | 294 | /// </summary> |
293 | private int m_LastLogin; | 295 | private int m_LastLogin; |
294 | 296 | ||
297 | private int m_lastIncoming; | ||
298 | private int m_lastOutgoing; | ||
299 | private int m_hbRestarts = 0; | ||
300 | |||
301 | |||
295 | /// <summary> | 302 | /// <summary> |
296 | /// Thread that runs the scene loop. | 303 | /// Thread that runs the scene loop. |
297 | /// </summary> | 304 | /// </summary> |
@@ -332,7 +339,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
332 | private volatile bool m_active; | 339 | private volatile bool m_active; |
333 | 340 | ||
334 | // private int m_lastUpdate; | 341 | // private int m_lastUpdate; |
335 | // private bool m_firstHeartbeat = true; | 342 | private bool m_firstHeartbeat = true; |
336 | 343 | ||
337 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 344 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
338 | private bool m_reprioritizationEnabled = true; | 345 | private bool m_reprioritizationEnabled = true; |
@@ -377,6 +384,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
377 | get { return m_sceneGridService; } | 384 | get { return m_sceneGridService; } |
378 | } | 385 | } |
379 | 386 | ||
387 | public ISnmpModule SnmpService | ||
388 | { | ||
389 | get | ||
390 | { | ||
391 | if (m_snmpService == null) | ||
392 | { | ||
393 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
394 | } | ||
395 | |||
396 | return m_snmpService; | ||
397 | } | ||
398 | } | ||
399 | |||
380 | public ISimulationDataService SimulationDataService | 400 | public ISimulationDataService SimulationDataService |
381 | { | 401 | { |
382 | get | 402 | get |
@@ -676,6 +696,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
676 | m_SimulationDataService = simDataService; | 696 | m_SimulationDataService = simDataService; |
677 | m_EstateDataService = estateDataService; | 697 | m_EstateDataService = estateDataService; |
678 | m_regionHandle = RegionInfo.RegionHandle; | 698 | m_regionHandle = RegionInfo.RegionHandle; |
699 | m_lastIncoming = 0; | ||
700 | m_lastOutgoing = 0; | ||
679 | 701 | ||
680 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 702 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
681 | m_asyncSceneObjectDeleter.Enabled = true; | 703 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -758,132 +780,141 @@ namespace OpenSim.Region.Framework.Scenes | |||
758 | 780 | ||
759 | // Region config overrides global config | 781 | // Region config overrides global config |
760 | // | 782 | // |
761 | if (m_config.Configs["Startup"] != null) | 783 | try |
762 | { | 784 | { |
763 | IConfig startupConfig = m_config.Configs["Startup"]; | 785 | if (m_config.Configs["Startup"] != null) |
764 | |||
765 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | ||
766 | |||
767 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | ||
768 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); | ||
769 | if (!m_useBackup) | ||
770 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | ||
771 | |||
772 | //Animation states | ||
773 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | ||
774 | |||
775 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); | ||
776 | |||
777 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | ||
778 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | ||
779 | |||
780 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); | ||
781 | if (RegionInfo.NonphysPrimMin > 0) | ||
782 | { | 786 | { |
783 | m_minNonphys = RegionInfo.NonphysPrimMin; | 787 | IConfig startupConfig = m_config.Configs["Startup"]; |
784 | } | ||
785 | 788 | ||
786 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 789 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); |
787 | if (RegionInfo.NonphysPrimMax > 0) | ||
788 | { | ||
789 | m_maxNonphys = RegionInfo.NonphysPrimMax; | ||
790 | } | ||
791 | 790 | ||
792 | m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); | 791 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
793 | if (RegionInfo.PhysPrimMin > 0) | 792 | m_useBackup = startupConfig.GetBoolean("UseSceneBackup", m_useBackup); |
794 | { | 793 | if (!m_useBackup) |
795 | m_minPhys = RegionInfo.PhysPrimMin; | 794 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
796 | } | 795 | |
796 | //Animation states | ||
797 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | ||
797 | 798 | ||
798 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 799 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
799 | if (RegionInfo.PhysPrimMax > 0) | 800 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
800 | { | ||
801 | m_maxPhys = RegionInfo.PhysPrimMax; | ||
802 | } | ||
803 | 801 | ||
804 | // Here, if clamping is requested in either global or | 802 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); |
805 | // local config, it will be used | 803 | if (RegionInfo.NonphysPrimMin > 0) |
806 | // | 804 | { |
807 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | 805 | m_minNonphys = RegionInfo.NonphysPrimMin; |
808 | if (RegionInfo.ClampPrimSize) | 806 | } |
809 | { | ||
810 | m_clampPrimSize = true; | ||
811 | } | ||
812 | 807 | ||
813 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | 808 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
814 | if (RegionInfo.LinksetCapacity > 0) | 809 | if (RegionInfo.NonphysPrimMax > 0) |
815 | { | 810 | { |
816 | m_linksetCapacity = RegionInfo.LinksetCapacity; | 811 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
817 | } | 812 | } |
818 | 813 | ||
819 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | 814 | m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys); |
820 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 815 | if (RegionInfo.PhysPrimMin > 0) |
821 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 816 | { |
822 | m_dontPersistBefore = | 817 | m_minPhys = RegionInfo.PhysPrimMin; |
823 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | 818 | } |
824 | m_dontPersistBefore *= 10000000; | ||
825 | m_persistAfter = | ||
826 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
827 | m_persistAfter *= 10000000; | ||
828 | 819 | ||
829 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 820 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
830 | 821 | ||
831 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | 822 | if (RegionInfo.PhysPrimMax > 0) |
832 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | 823 | { |
824 | m_maxPhys = RegionInfo.PhysPrimMax; | ||
825 | } | ||
833 | 826 | ||
834 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 827 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); |
828 | if (RegionInfo.LinksetCapacity > 0) | ||
829 | { | ||
830 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
831 | } | ||
835 | 832 | ||
836 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 833 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); |
837 | if (m_generateMaptiles) | 834 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); |
838 | { | 835 | |
839 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); | 836 | // Here, if clamping is requested in either global or |
840 | if (maptileRefresh != 0) | 837 | // local config, it will be used |
838 | // | ||
839 | m_clampPrimSize = startupConfig.GetBoolean("ClampPrimSize", m_clampPrimSize); | ||
840 | if (RegionInfo.ClampPrimSize) | ||
841 | { | 841 | { |
842 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | 842 | m_clampPrimSize = true; |
843 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
844 | m_mapGenerationTimer.AutoReset = true; | ||
845 | m_mapGenerationTimer.Start(); | ||
846 | } | 843 | } |
847 | } | ||
848 | else | ||
849 | { | ||
850 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
851 | UUID tileID; | ||
852 | 844 | ||
853 | if (UUID.TryParse(tile, out tileID)) | 845 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
846 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | ||
847 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | ||
848 | m_dontPersistBefore = | ||
849 | startupConfig.GetLong("MinimumTimeBeforePersistenceConsidered", DEFAULT_MIN_TIME_FOR_PERSISTENCE); | ||
850 | m_dontPersistBefore *= 10000000; | ||
851 | m_persistAfter = | ||
852 | startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE); | ||
853 | m_persistAfter *= 10000000; | ||
854 | |||
855 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | ||
856 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
857 | |||
858 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | ||
859 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
860 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
861 | |||
862 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | ||
863 | if (m_generateMaptiles) | ||
854 | { | 864 | { |
855 | RegionInfo.RegionSettings.TerrainImageID = tileID; | 865 | int maptileRefresh = startupConfig.GetInt("MaptileRefresh", 0); |
866 | if (maptileRefresh != 0) | ||
867 | { | ||
868 | m_mapGenerationTimer.Interval = maptileRefresh * 1000; | ||
869 | m_mapGenerationTimer.Elapsed += RegenerateMaptileAndReregister; | ||
870 | m_mapGenerationTimer.AutoReset = true; | ||
871 | m_mapGenerationTimer.Start(); | ||
872 | } | ||
856 | } | 873 | } |
857 | } | 874 | else |
875 | { | ||
876 | string tile = startupConfig.GetString("MaptileStaticUUID", UUID.Zero.ToString()); | ||
877 | UUID tileID; | ||
858 | 878 | ||
859 | string grant = startupConfig.GetString("AllowedClients", String.Empty); | 879 | if (UUID.TryParse(tile, out tileID)) |
860 | if (grant.Length > 0) | 880 | { |
861 | { | 881 | RegionInfo.RegionSettings.TerrainImageID = tileID; |
862 | foreach (string viewer in grant.Split('|')) | 882 | } |
883 | } | ||
884 | |||
885 | string grant = startupConfig.GetString("AllowedClients", String.Empty); | ||
886 | if (grant.Length > 0) | ||
863 | { | 887 | { |
864 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 888 | foreach (string viewer in grant.Split(',')) |
889 | { | ||
890 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | ||
891 | } | ||
865 | } | 892 | } |
866 | } | ||
867 | 893 | ||
868 | grant = startupConfig.GetString("BannedClients", String.Empty); | 894 | grant = startupConfig.GetString("BannedClients", String.Empty); |
869 | if (grant.Length > 0) | 895 | if (grant.Length > 0) |
870 | { | ||
871 | foreach (string viewer in grant.Split('|')) | ||
872 | { | 896 | { |
873 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 897 | foreach (string viewer in grant.Split(',')) |
898 | { | ||
899 | m_BannedViewers.Add(viewer.Trim().ToLower()); | ||
900 | } | ||
874 | } | 901 | } |
875 | } | ||
876 | 902 | ||
877 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); | 903 | MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); |
878 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); | 904 | m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); |
879 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); | 905 | m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); |
880 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); | 906 | m_update_entitymovement = startupConfig.GetInt( "UpdateEntityMovementEveryNFrames", m_update_entitymovement); |
881 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); | 907 | m_update_events = startupConfig.GetInt( "UpdateEventsEveryNFrames", m_update_events); |
882 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); | 908 | m_update_objects = startupConfig.GetInt( "UpdateObjectsEveryNFrames", m_update_objects); |
883 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); | 909 | m_update_physics = startupConfig.GetInt( "UpdatePhysicsEveryNFrames", m_update_physics); |
884 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); | 910 | m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); |
885 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | 911 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); |
886 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | 912 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); |
913 | } | ||
914 | } | ||
915 | catch (Exception e) | ||
916 | { | ||
917 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); | ||
887 | } | 918 | } |
888 | 919 | ||
889 | // FIXME: Ultimately this should be in a module. | 920 | // FIXME: Ultimately this should be in a module. |
@@ -928,6 +959,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
928 | StatsReporter = new SimStatsReporter(this); | 959 | StatsReporter = new SimStatsReporter(this); |
929 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 960 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
930 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 961 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
962 | |||
963 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | ||
931 | } | 964 | } |
932 | 965 | ||
933 | public Scene(RegionInfo regInfo) : base(regInfo) | 966 | public Scene(RegionInfo regInfo) : base(regInfo) |
@@ -1348,7 +1381,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1348 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1381 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1349 | if (m_heartbeatThread != null) | 1382 | if (m_heartbeatThread != null) |
1350 | { | 1383 | { |
1384 | m_hbRestarts++; | ||
1385 | if(m_hbRestarts > 10) | ||
1386 | Environment.Exit(1); | ||
1387 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1388 | |||
1389 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1390 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1391 | //proc.EnableRaisingEvents=false; | ||
1392 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1393 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1394 | //proc.Start(); | ||
1395 | //proc.WaitForExit(); | ||
1396 | //Thread.Sleep(1000); | ||
1397 | //Environment.Exit(1); | ||
1351 | m_heartbeatThread.Abort(); | 1398 | m_heartbeatThread.Abort(); |
1399 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1352 | m_heartbeatThread = null; | 1400 | m_heartbeatThread = null; |
1353 | } | 1401 | } |
1354 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1402 | // m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1495,16 +1543,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1495 | endFrame = Frame + frames; | 1543 | endFrame = Frame + frames; |
1496 | 1544 | ||
1497 | float physicsFPS = 0f; | 1545 | float physicsFPS = 0f; |
1498 | int previousFrameTick, tmpMS; | 1546 | int tmpMS; |
1499 | int maintc = Util.EnvironmentTickCount(); | 1547 | int previousFrameTick; |
1548 | int maintc; | ||
1549 | int sleepMS; | ||
1550 | int framestart; | ||
1500 | 1551 | ||
1501 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) | 1552 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) |
1502 | { | 1553 | { |
1554 | framestart = Util.EnvironmentTickCount(); | ||
1503 | ++Frame; | 1555 | ++Frame; |
1504 | 1556 | ||
1505 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1557 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1506 | 1558 | ||
1507 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; | 1559 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
1508 | 1560 | ||
1509 | try | 1561 | try |
1510 | { | 1562 | { |
@@ -1556,6 +1608,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1556 | m_sceneGraph.UpdatePresences(); | 1608 | m_sceneGraph.UpdatePresences(); |
1557 | 1609 | ||
1558 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); | 1610 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1611 | |||
1559 | 1612 | ||
1560 | // Delete temp-on-rez stuff | 1613 | // Delete temp-on-rez stuff |
1561 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | 1614 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) |
@@ -1637,34 +1690,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1637 | 1690 | ||
1638 | Watchdog.UpdateThread(); | 1691 | Watchdog.UpdateThread(); |
1639 | 1692 | ||
1693 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1694 | |||
1695 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1696 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1697 | StatsReporter.AddFPS(1); | ||
1698 | |||
1699 | StatsReporter.addAgentMS(agentMS); | ||
1700 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1701 | StatsReporter.addOtherMS(otherMS); | ||
1702 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1703 | |||
1640 | previousFrameTick = m_lastFrameTick; | 1704 | previousFrameTick = m_lastFrameTick; |
1641 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1705 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1642 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1706 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1643 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1707 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1644 | 1708 | ||
1709 | m_firstHeartbeat = false; | ||
1710 | |||
1711 | sleepMS = Util.EnvironmentTickCount(); | ||
1712 | |||
1645 | if (tmpMS > 0) | 1713 | if (tmpMS > 0) |
1646 | { | ||
1647 | Thread.Sleep(tmpMS); | 1714 | Thread.Sleep(tmpMS); |
1648 | spareMS += tmpMS; | ||
1649 | } | ||
1650 | |||
1651 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | ||
1652 | maintc = Util.EnvironmentTickCount(); | ||
1653 | 1715 | ||
1654 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1716 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); |
1717 | frameMS = Util.EnvironmentTickCountSubtract(framestart); | ||
1718 | StatsReporter.addSleepMS(sleepMS); | ||
1719 | StatsReporter.addFrameMS(frameMS); | ||
1655 | 1720 | ||
1656 | // if (Frame%m_update_avatars == 0) | 1721 | // if (Frame%m_update_avatars == 0) |
1657 | // UpdateInWorldTime(); | 1722 | // UpdateInWorldTime(); |
1658 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1659 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1660 | StatsReporter.AddFPS(1); | ||
1661 | 1723 | ||
1662 | StatsReporter.addFrameMS(frameMS); | ||
1663 | StatsReporter.addAgentMS(agentMS); | ||
1664 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1665 | StatsReporter.addOtherMS(otherMS); | ||
1666 | StatsReporter.AddSpareMS(spareMS); | ||
1667 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1668 | 1724 | ||
1669 | // Optionally warn if a frame takes double the amount of time that it should. | 1725 | // Optionally warn if a frame takes double the amount of time that it should. |
1670 | if (DebugUpdates | 1726 | if (DebugUpdates |
@@ -1782,7 +1838,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1782 | msg.fromAgentName = "Server"; | 1838 | msg.fromAgentName = "Server"; |
1783 | msg.dialog = (byte)19; // Object msg | 1839 | msg.dialog = (byte)19; // Object msg |
1784 | msg.fromGroup = false; | 1840 | msg.fromGroup = false; |
1785 | msg.offline = (byte)0; | 1841 | msg.offline = (byte)1; |
1786 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1842 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1787 | msg.Position = Vector3.Zero; | 1843 | msg.Position = Vector3.Zero; |
1788 | msg.RegionID = RegionInfo.RegionID.Guid; | 1844 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -2004,6 +2060,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2004 | EventManager.TriggerPrimsLoaded(this); | 2060 | EventManager.TriggerPrimsLoaded(this); |
2005 | } | 2061 | } |
2006 | 2062 | ||
2063 | public bool SuportsRayCastFiltered() | ||
2064 | { | ||
2065 | if (PhysicsScene == null) | ||
2066 | return false; | ||
2067 | return PhysicsScene.SuportsRaycastWorldFiltered(); | ||
2068 | } | ||
2069 | |||
2070 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | ||
2071 | { | ||
2072 | if (PhysicsScene == null) | ||
2073 | return null; | ||
2074 | return PhysicsScene.RaycastWorld(position, direction, length, Count,filter); | ||
2075 | } | ||
2007 | 2076 | ||
2008 | /// <summary> | 2077 | /// <summary> |
2009 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. | 2078 | /// Gets a new rez location based on the raycast and the size of the object that is being rezzed. |
@@ -2020,14 +2089,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2020 | /// <returns></returns> | 2089 | /// <returns></returns> |
2021 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 2090 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
2022 | { | 2091 | { |
2092 | |||
2093 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
2094 | Vector3 wpos = Vector3.Zero; | ||
2095 | // Check for water surface intersection from above | ||
2096 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
2097 | { | ||
2098 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
2099 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
2100 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
2101 | wpos.Z = wheight; | ||
2102 | } | ||
2103 | |||
2023 | Vector3 pos = Vector3.Zero; | 2104 | Vector3 pos = Vector3.Zero; |
2024 | if (RayEndIsIntersection == (byte)1) | 2105 | if (RayEndIsIntersection == (byte)1) |
2025 | { | 2106 | { |
2026 | pos = RayEnd; | 2107 | pos = RayEnd; |
2027 | return pos; | ||
2028 | } | 2108 | } |
2029 | 2109 | else if (RayTargetID != UUID.Zero) | |
2030 | if (RayTargetID != UUID.Zero) | ||
2031 | { | 2110 | { |
2032 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 2111 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
2033 | 2112 | ||
@@ -2049,7 +2128,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2049 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 2128 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
2050 | 2129 | ||
2051 | // Un-comment out the following line to Get Raytrace results printed to the console. | 2130 | // Un-comment out the following line to Get Raytrace results printed to the console. |
2052 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 2131 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
2053 | float ScaleOffset = 0.5f; | 2132 | float ScaleOffset = 0.5f; |
2054 | 2133 | ||
2055 | // If we hit something | 2134 | // If we hit something |
@@ -2072,13 +2151,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2072 | //pos.Z -= 0.25F; | 2151 | //pos.Z -= 0.25F; |
2073 | 2152 | ||
2074 | } | 2153 | } |
2075 | |||
2076 | return pos; | ||
2077 | } | 2154 | } |
2078 | else | 2155 | else |
2079 | { | 2156 | { |
2080 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2157 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
2081 | |||
2082 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2158 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
2083 | 2159 | ||
2084 | // Un-comment the following line to print the raytrace results to the console. | 2160 | // Un-comment the following line to print the raytrace results to the console. |
@@ -2087,13 +2163,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2087 | if (ei.HitTF) | 2163 | if (ei.HitTF) |
2088 | { | 2164 | { |
2089 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2165 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
2090 | } else | 2166 | } |
2167 | else | ||
2091 | { | 2168 | { |
2092 | // fall back to our stupid functionality | 2169 | // fall back to our stupid functionality |
2093 | pos = RayEnd; | 2170 | pos = RayEnd; |
2094 | } | 2171 | } |
2095 | |||
2096 | return pos; | ||
2097 | } | 2172 | } |
2098 | } | 2173 | } |
2099 | else | 2174 | else |
@@ -2104,8 +2179,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2104 | //increase height so its above the ground. | 2179 | //increase height so its above the ground. |
2105 | //should be getting the normal of the ground at the rez point and using that? | 2180 | //should be getting the normal of the ground at the rez point and using that? |
2106 | pos.Z += scale.Z / 2f; | 2181 | pos.Z += scale.Z / 2f; |
2107 | return pos; | 2182 | // return pos; |
2108 | } | 2183 | } |
2184 | |||
2185 | // check against posible water intercept | ||
2186 | if (wpos.Z > pos.Z) pos = wpos; | ||
2187 | return pos; | ||
2109 | } | 2188 | } |
2110 | 2189 | ||
2111 | 2190 | ||
@@ -2196,12 +2275,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2196 | { | 2275 | { |
2197 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) | 2276 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) |
2198 | { | 2277 | { |
2278 | sceneObject.IsDeleted = false; | ||
2199 | EventManager.TriggerObjectAddedToScene(sceneObject); | 2279 | EventManager.TriggerObjectAddedToScene(sceneObject); |
2200 | return true; | 2280 | return true; |
2201 | } | 2281 | } |
2202 | 2282 | ||
2203 | return false; | 2283 | return false; |
2204 | |||
2205 | } | 2284 | } |
2206 | 2285 | ||
2207 | /// <summary> | 2286 | /// <summary> |
@@ -2293,6 +2372,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2293 | /// </summary> | 2372 | /// </summary> |
2294 | public void DeleteAllSceneObjects() | 2373 | public void DeleteAllSceneObjects() |
2295 | { | 2374 | { |
2375 | DeleteAllSceneObjects(false); | ||
2376 | } | ||
2377 | |||
2378 | /// <summary> | ||
2379 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2380 | /// </summary> | ||
2381 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2382 | { | ||
2383 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2296 | lock (Entities) | 2384 | lock (Entities) |
2297 | { | 2385 | { |
2298 | EntityBase[] entities = Entities.GetEntities(); | 2386 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2301,11 +2389,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2301 | if (e is SceneObjectGroup) | 2389 | if (e is SceneObjectGroup) |
2302 | { | 2390 | { |
2303 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2391 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2304 | if (!sog.IsAttachment) | 2392 | if (sog != null && !sog.IsAttachment) |
2305 | DeleteSceneObject((SceneObjectGroup)e, false); | 2393 | { |
2394 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2395 | { | ||
2396 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2397 | } | ||
2398 | else | ||
2399 | { | ||
2400 | toReturn.Add((SceneObjectGroup)e); | ||
2401 | } | ||
2402 | } | ||
2306 | } | 2403 | } |
2307 | } | 2404 | } |
2308 | } | 2405 | } |
2406 | if (toReturn.Count > 0) | ||
2407 | { | ||
2408 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2409 | } | ||
2309 | } | 2410 | } |
2310 | 2411 | ||
2311 | /// <summary> | 2412 | /// <summary> |
@@ -2340,6 +2441,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2340 | 2441 | ||
2341 | foreach (SceneObjectPart part in partList) | 2442 | foreach (SceneObjectPart part in partList) |
2342 | { | 2443 | { |
2444 | if (part.KeyframeMotion != null) | ||
2445 | { | ||
2446 | part.KeyframeMotion.Delete(); | ||
2447 | part.KeyframeMotion = null; | ||
2448 | } | ||
2449 | |||
2343 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) | 2450 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) |
2344 | { | 2451 | { |
2345 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? | 2452 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? |
@@ -2357,6 +2464,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2357 | } | 2464 | } |
2358 | 2465 | ||
2359 | group.DeleteGroupFromScene(silent); | 2466 | group.DeleteGroupFromScene(silent); |
2467 | if (!silent) | ||
2468 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2360 | 2469 | ||
2361 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2470 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2362 | } | 2471 | } |
@@ -2647,7 +2756,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2647 | // If the user is banned, we won't let any of their objects | 2756 | // If the user is banned, we won't let any of their objects |
2648 | // enter. Period. | 2757 | // enter. Period. |
2649 | // | 2758 | // |
2650 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2759 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2651 | { | 2760 | { |
2652 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2761 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2653 | return false; | 2762 | return false; |
@@ -2655,6 +2764,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2655 | 2764 | ||
2656 | if (newPosition != Vector3.Zero) | 2765 | if (newPosition != Vector3.Zero) |
2657 | newObject.RootPart.GroupPosition = newPosition; | 2766 | newObject.RootPart.GroupPosition = newPosition; |
2767 | if (newObject.RootPart.KeyframeMotion != null) | ||
2768 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2658 | 2769 | ||
2659 | if (!AddSceneObject(newObject)) | 2770 | if (!AddSceneObject(newObject)) |
2660 | { | 2771 | { |
@@ -2699,6 +2810,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2699 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2810 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2700 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2811 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2701 | { | 2812 | { |
2813 | if (sceneObject.OwnerID == UUID.Zero) | ||
2814 | { | ||
2815 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2816 | return false; | ||
2817 | } | ||
2818 | |||
2819 | // If the user is banned, we won't let any of their objects | ||
2820 | // enter. Period. | ||
2821 | // | ||
2822 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2823 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2824 | { | ||
2825 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2826 | |||
2827 | return false; | ||
2828 | } | ||
2829 | |||
2702 | // Force allocation of new LocalId | 2830 | // Force allocation of new LocalId |
2703 | // | 2831 | // |
2704 | SceneObjectPart[] parts = sceneObject.Parts; | 2832 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2732,16 +2860,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2732 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2860 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2733 | 2861 | ||
2734 | if (AttachmentsModule != null) | 2862 | if (AttachmentsModule != null) |
2735 | AttachmentsModule.AttachObject(sp, grp, 0, false, false); | 2863 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, false); |
2736 | } | 2864 | } |
2737 | else | 2865 | else |
2738 | { | 2866 | { |
2867 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2739 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2868 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2740 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2869 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2741 | } | 2870 | } |
2871 | if (sceneObject.OwnerID == UUID.Zero) | ||
2872 | { | ||
2873 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2874 | return false; | ||
2875 | } | ||
2742 | } | 2876 | } |
2743 | else | 2877 | else |
2744 | { | 2878 | { |
2879 | if (sceneObject.OwnerID == UUID.Zero) | ||
2880 | { | ||
2881 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2882 | return false; | ||
2883 | } | ||
2745 | AddRestoredSceneObject(sceneObject, true, false); | 2884 | AddRestoredSceneObject(sceneObject, true, false); |
2746 | } | 2885 | } |
2747 | 2886 | ||
@@ -2758,6 +2897,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2758 | return 2; // StateSource.PrimCrossing | 2897 | return 2; // StateSource.PrimCrossing |
2759 | } | 2898 | } |
2760 | 2899 | ||
2900 | public int GetUserFlags(UUID user) | ||
2901 | { | ||
2902 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2903 | /* | ||
2904 | ScenePresence sp; | ||
2905 | if (TryGetScenePresence(user, out sp)) | ||
2906 | { | ||
2907 | return sp.UserFlags; | ||
2908 | } | ||
2909 | else | ||
2910 | { | ||
2911 | */ | ||
2912 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2913 | if (uac == null) | ||
2914 | return 0; | ||
2915 | return uac.UserFlags; | ||
2916 | //} | ||
2917 | } | ||
2761 | #endregion | 2918 | #endregion |
2762 | 2919 | ||
2763 | #region Add/Remove Avatar Methods | 2920 | #region Add/Remove Avatar Methods |
@@ -2790,7 +2947,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2790 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2947 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2791 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2948 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2792 | 2949 | ||
2793 | // CheckHeartbeat(); | 2950 | CheckHeartbeat(); |
2794 | 2951 | ||
2795 | sp = GetScenePresence(client.AgentId); | 2952 | sp = GetScenePresence(client.AgentId); |
2796 | 2953 | ||
@@ -2934,19 +3091,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2934 | // and the scene presence and the client, if they exist | 3091 | // and the scene presence and the client, if they exist |
2935 | try | 3092 | try |
2936 | { | 3093 | { |
2937 | // We need to wait for the client to make UDP contact first. | 3094 | ScenePresence sp = GetScenePresence(agentID); |
2938 | // It's the UDP contact that creates the scene presence | 3095 | |
2939 | ScenePresence sp = WaitGetScenePresence(agentID); | ||
2940 | if (sp != null) | 3096 | if (sp != null) |
2941 | { | 3097 | { |
2942 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 3098 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2943 | |||
2944 | sp.ControllingClient.Close(); | 3099 | sp.ControllingClient.Close(); |
2945 | } | 3100 | } |
2946 | else | 3101 | |
2947 | { | ||
2948 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2949 | } | ||
2950 | // BANG! SLASH! | 3102 | // BANG! SLASH! |
2951 | m_authenticateHandler.RemoveCircuit(agentID); | 3103 | m_authenticateHandler.RemoveCircuit(agentID); |
2952 | 3104 | ||
@@ -2991,6 +3143,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2991 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3143 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2992 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3144 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2993 | 3145 | ||
3146 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3147 | |||
2994 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3148 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2995 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3149 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2996 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3150 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3047,6 +3201,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3047 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3201 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
3048 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3202 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
3049 | client.OnCopyInventoryItem += CopyInventoryItem; | 3203 | client.OnCopyInventoryItem += CopyInventoryItem; |
3204 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
3050 | client.OnMoveInventoryItem += MoveInventoryItem; | 3205 | client.OnMoveInventoryItem += MoveInventoryItem; |
3051 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3206 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
3052 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3207 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3118,6 +3273,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3118 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3273 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
3119 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3274 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
3120 | 3275 | ||
3276 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3277 | |||
3121 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3278 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3122 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3279 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3123 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3280 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3220,7 +3377,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3220 | /// </summary> | 3377 | /// </summary> |
3221 | /// <param name="agentId">The avatar's Unique ID</param> | 3378 | /// <param name="agentId">The avatar's Unique ID</param> |
3222 | /// <param name="client">The IClientAPI for the client</param> | 3379 | /// <param name="client">The IClientAPI for the client</param> |
3223 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3380 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3224 | { | 3381 | { |
3225 | if (EntityTransferModule != null) | 3382 | if (EntityTransferModule != null) |
3226 | { | 3383 | { |
@@ -3231,6 +3388,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3231 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3388 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3232 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3389 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3233 | } | 3390 | } |
3391 | return false; | ||
3234 | } | 3392 | } |
3235 | 3393 | ||
3236 | /// <summary> | 3394 | /// <summary> |
@@ -3340,6 +3498,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3340 | /// <param name="flags"></param> | 3498 | /// <param name="flags"></param> |
3341 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3499 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3342 | { | 3500 | { |
3501 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3502 | ScenePresence presence; | ||
3503 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3504 | { | ||
3505 | if (presence.Appearance != null) | ||
3506 | { | ||
3507 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3508 | } | ||
3509 | } | ||
3510 | |||
3343 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3511 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3344 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3512 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3345 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3513 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3477,6 +3645,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3477 | // It's possible for child agents to have transactions if changes are being made cross-border. | 3645 | // It's possible for child agents to have transactions if changes are being made cross-border. |
3478 | if (AgentTransactionsModule != null) | 3646 | if (AgentTransactionsModule != null) |
3479 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3647 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3648 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3480 | } | 3649 | } |
3481 | catch (Exception e) | 3650 | catch (Exception e) |
3482 | { | 3651 | { |
@@ -3669,38 +3838,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3669 | agent.firstname, agent.lastname, agent.Viewer); | 3838 | agent.firstname, agent.lastname, agent.Viewer); |
3670 | reason = "Access denied, your viewer is banned by the region owner"; | 3839 | reason = "Access denied, your viewer is banned by the region owner"; |
3671 | return false; | 3840 | return false; |
3672 | } | 3841 | } |
3842 | |||
3673 | 3843 | ||
3674 | ILandObject land; | 3844 | ScenePresence sp = GetScenePresence(agent.AgentID); |
3845 | |||
3846 | if (sp != null && !sp.IsChildAgent) | ||
3847 | { | ||
3848 | // We have a zombie from a crashed session. | ||
3849 | // Or the same user is trying to be root twice here, won't work. | ||
3850 | // Kill it. | ||
3851 | m_log.WarnFormat( | ||
3852 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", | ||
3853 | sp.Name, sp.UUID, RegionInfo.RegionName); | ||
3854 | |||
3855 | sp.ControllingClient.Close(true, true); | ||
3856 | sp = null; | ||
3857 | } | ||
3675 | 3858 | ||
3676 | lock (agent) | 3859 | lock (agent) |
3677 | { | 3860 | { |
3678 | ScenePresence sp = GetScenePresence(agent.AgentID); | ||
3679 | |||
3680 | if (sp != null && !sp.IsChildAgent) | ||
3681 | { | ||
3682 | // We have a zombie from a crashed session. | ||
3683 | // Or the same user is trying to be root twice here, won't work. | ||
3684 | // Kill it. | ||
3685 | m_log.WarnFormat( | ||
3686 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", | ||
3687 | sp.Name, sp.UUID, RegionInfo.RegionName); | ||
3688 | |||
3689 | sp.ControllingClient.Close(true); | ||
3690 | sp = null; | ||
3691 | } | ||
3692 | |||
3693 | land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3694 | |||
3695 | //On login test land permisions | 3861 | //On login test land permisions |
3696 | if (vialogin) | 3862 | if (vialogin) |
3697 | { | 3863 | { |
3698 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3864 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3865 | if (cache != null) | ||
3866 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3867 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3699 | { | 3868 | { |
3869 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3700 | return false; | 3870 | return false; |
3701 | } | 3871 | } |
3702 | } | 3872 | } |
3703 | 3873 | ||
3704 | if (sp == null) // We don't have an [child] agent here already | 3874 | if (sp == null) // We don't have an [child] agent here already |
3705 | { | 3875 | { |
3706 | if (requirePresenceLookup) | 3876 | if (requirePresenceLookup) |
@@ -3709,34 +3879,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
3709 | { | 3879 | { |
3710 | if (!VerifyUserPresence(agent, out reason)) | 3880 | if (!VerifyUserPresence(agent, out reason)) |
3711 | return false; | 3881 | return false; |
3712 | } | 3882 | } catch (Exception e) |
3713 | catch (Exception e) | ||
3714 | { | 3883 | { |
3715 | m_log.ErrorFormat( | 3884 | m_log.ErrorFormat( |
3716 | "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); | 3885 | "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); |
3717 | |||
3718 | return false; | 3886 | return false; |
3719 | } | 3887 | } |
3720 | } | 3888 | } |
3721 | 3889 | ||
3722 | try | 3890 | try |
3723 | { | 3891 | { |
3724 | if (!AuthorizeUser(agent, out reason)) | 3892 | // Always check estate if this is a login. Always |
3725 | return false; | 3893 | // check if banned regions are to be blacked out. |
3894 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3895 | { | ||
3896 | if (!AuthorizeUser(agent, out reason)) | ||
3897 | return false; | ||
3898 | } | ||
3726 | } | 3899 | } |
3727 | catch (Exception e) | 3900 | catch (Exception e) |
3728 | { | 3901 | { |
3729 | m_log.ErrorFormat( | 3902 | m_log.ErrorFormat( |
3730 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3903 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
3731 | |||
3732 | return false; | 3904 | return false; |
3733 | } | 3905 | } |
3734 | 3906 | ||
3735 | m_log.InfoFormat( | 3907 | m_log.InfoFormat( |
3736 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", | 3908 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", |
3737 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, | 3909 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, |
3738 | agent.AgentID, agent.circuitcode); | 3910 | agent.AgentID, agent.circuitcode); |
3739 | 3911 | ||
3740 | if (CapsModule != null) | 3912 | if (CapsModule != null) |
3741 | { | 3913 | { |
3742 | CapsModule.SetAgentCapsSeeds(agent); | 3914 | CapsModule.SetAgentCapsSeeds(agent); |
@@ -3748,15 +3920,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3748 | // Let the SP know how we got here. This has a lot of interesting | 3920 | // Let the SP know how we got here. This has a lot of interesting |
3749 | // uses down the line. | 3921 | // uses down the line. |
3750 | sp.TeleportFlags = (TPFlags)teleportFlags; | 3922 | sp.TeleportFlags = (TPFlags)teleportFlags; |
3751 | 3923 | ||
3752 | if (sp.IsChildAgent) | 3924 | if (sp.IsChildAgent) |
3753 | { | 3925 | { |
3754 | m_log.DebugFormat( | 3926 | m_log.DebugFormat( |
3755 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", | 3927 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", |
3756 | agent.AgentID, RegionInfo.RegionName); | 3928 | agent.AgentID, RegionInfo.RegionName); |
3757 | 3929 | ||
3758 | sp.AdjustKnownSeeds(); | 3930 | sp.AdjustKnownSeeds(); |
3759 | 3931 | ||
3760 | if (CapsModule != null) | 3932 | if (CapsModule != null) |
3761 | CapsModule.SetAgentCapsSeeds(agent); | 3933 | CapsModule.SetAgentCapsSeeds(agent); |
3762 | } | 3934 | } |
@@ -3858,6 +4030,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3858 | } | 4030 | } |
3859 | 4031 | ||
3860 | // Honor parcel landing type and position. | 4032 | // Honor parcel landing type and position. |
4033 | /* | ||
4034 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3861 | if (land != null) | 4035 | if (land != null) |
3862 | { | 4036 | { |
3863 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 4037 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3865,25 +4039,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
3865 | agent.startpos = land.LandData.UserLocation; | 4039 | agent.startpos = land.LandData.UserLocation; |
3866 | } | 4040 | } |
3867 | } | 4041 | } |
4042 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3868 | } | 4043 | } |
3869 | 4044 | ||
3870 | return true; | 4045 | return true; |
3871 | } | 4046 | } |
3872 | 4047 | ||
3873 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 4048 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3874 | { | 4049 | { |
3875 | bool banned = land.IsBannedFromLand(agent.AgentID); | 4050 | if (posX < 0) |
3876 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 4051 | posX = 0; |
4052 | else if (posX >= 256) | ||
4053 | posX = 255.999f; | ||
4054 | if (posY < 0) | ||
4055 | posY = 0; | ||
4056 | else if (posY >= 256) | ||
4057 | posY = 255.999f; | ||
4058 | |||
4059 | reason = String.Empty; | ||
4060 | if (Permissions.IsGod(agentID)) | ||
4061 | return true; | ||
4062 | |||
4063 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
4064 | if (land == null) | ||
4065 | return false; | ||
4066 | |||
4067 | bool banned = land.IsBannedFromLand(agentID); | ||
4068 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3877 | 4069 | ||
3878 | if (banned || restricted) | 4070 | if (banned || restricted) |
3879 | { | 4071 | { |
3880 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 4072 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3881 | if (nearestParcel != null) | 4073 | if (nearestParcel != null) |
3882 | { | 4074 | { |
3883 | //Move agent to nearest allowed | 4075 | //Move agent to nearest allowed |
3884 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 4076 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3885 | agent.startpos.X = newPosition.X; | 4077 | posX = newPosition.X; |
3886 | agent.startpos.Y = newPosition.Y; | 4078 | posY = newPosition.Y; |
3887 | } | 4079 | } |
3888 | else | 4080 | else |
3889 | { | 4081 | { |
@@ -3945,7 +4137,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3945 | 4137 | ||
3946 | if (!m_strictAccessControl) return true; | 4138 | if (!m_strictAccessControl) return true; |
3947 | if (Permissions.IsGod(agent.AgentID)) return true; | 4139 | if (Permissions.IsGod(agent.AgentID)) return true; |
3948 | 4140 | ||
3949 | if (AuthorizationService != null) | 4141 | if (AuthorizationService != null) |
3950 | { | 4142 | { |
3951 | if (!AuthorizationService.IsAuthorizedForRegion( | 4143 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3960,7 +4152,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3960 | 4152 | ||
3961 | if (RegionInfo.EstateSettings != null) | 4153 | if (RegionInfo.EstateSettings != null) |
3962 | { | 4154 | { |
3963 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 4155 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
3964 | { | 4156 | { |
3965 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 4157 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3966 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 4158 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -4150,6 +4342,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4150 | 4342 | ||
4151 | // XPTO: if this agent is not allowed here as root, always return false | 4343 | // XPTO: if this agent is not allowed here as root, always return false |
4152 | 4344 | ||
4345 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4346 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4347 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4348 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4349 | { | ||
4350 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4351 | return false; | ||
4352 | } | ||
4353 | |||
4153 | // TODO: This check should probably be in QueryAccess(). | 4354 | // TODO: This check should probably be in QueryAccess(). |
4154 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4355 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4155 | if (nearestParcel == null) | 4356 | if (nearestParcel == null) |
@@ -4214,7 +4415,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4214 | /// <param name='agentID'></param> | 4415 | /// <param name='agentID'></param> |
4215 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 4416 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4216 | { | 4417 | { |
4217 | int ntimes = 10; | 4418 | int ntimes = 30; |
4218 | ScenePresence sp = null; | 4419 | ScenePresence sp = null; |
4219 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 4420 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4220 | Thread.Sleep(1000); | 4421 | Thread.Sleep(1000); |
@@ -4244,6 +4445,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4244 | return false; | 4445 | return false; |
4245 | } | 4446 | } |
4246 | 4447 | ||
4448 | public bool IncomingCloseAgent(UUID agentID) | ||
4449 | { | ||
4450 | return IncomingCloseAgent(agentID, false); | ||
4451 | } | ||
4452 | |||
4453 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4454 | { | ||
4455 | return IncomingCloseAgent(agentID, true); | ||
4456 | } | ||
4457 | |||
4247 | /// <summary> | 4458 | /// <summary> |
4248 | /// Tell a single agent to disconnect from the region. | 4459 | /// Tell a single agent to disconnect from the region. |
4249 | /// </summary> | 4460 | /// </summary> |
@@ -4259,7 +4470,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4259 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); | 4470 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); |
4260 | if (presence != null) | 4471 | if (presence != null) |
4261 | { | 4472 | { |
4262 | presence.ControllingClient.Close(force); | 4473 | presence.ControllingClient.Close(force, force); |
4263 | return true; | 4474 | return true; |
4264 | } | 4475 | } |
4265 | 4476 | ||
@@ -4919,35 +5130,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4919 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 5130 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4920 | } | 5131 | } |
4921 | 5132 | ||
4922 | public int GetHealth() | 5133 | public int GetHealth(out int flags, out string message) |
4923 | { | 5134 | { |
4924 | // Returns: | 5135 | // Returns: |
4925 | // 1 = sim is up and accepting http requests. The heartbeat has | 5136 | // 1 = sim is up and accepting http requests. The heartbeat has |
4926 | // stopped and the sim is probably locked up, but a remote | 5137 | // stopped and the sim is probably locked up, but a remote |
4927 | // admin restart may succeed | 5138 | // admin restart may succeed |
4928 | // | 5139 | // |
4929 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 5140 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4930 | // usable for people within and logins _may_ work | 5141 | // usable for people within |
4931 | // | 5142 | // |
4932 | // 3 = We have seen a new user enter within the past 4 minutes | 5143 | // 3 = Sim is up and one packet thread is running. Sim is |
5144 | // unstable and will not accept new logins | ||
5145 | // | ||
5146 | // 4 = Sim is up and both packet threads are running. Sim is | ||
5147 | // likely usable | ||
5148 | // | ||
5149 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4933 | // which can be seen as positive confirmation of sim health | 5150 | // which can be seen as positive confirmation of sim health |
4934 | // | 5151 | // |
5152 | |||
5153 | flags = 0; | ||
5154 | message = String.Empty; | ||
5155 | |||
5156 | CheckHeartbeat(); | ||
5157 | |||
5158 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
5159 | { | ||
5160 | // We're still starting | ||
5161 | // 0 means "in startup", it can't happen another way, since | ||
5162 | // to get here, we must be able to accept http connections | ||
5163 | return 0; | ||
5164 | } | ||
5165 | |||
4935 | int health=1; // Start at 1, means we're up | 5166 | int health=1; // Start at 1, means we're up |
4936 | 5167 | ||
4937 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5168 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4938 | health += 1; | 5169 | { |
5170 | health+=1; | ||
5171 | flags |= 1; | ||
5172 | } | ||
5173 | |||
5174 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
5175 | { | ||
5176 | health+=1; | ||
5177 | flags |= 2; | ||
5178 | } | ||
5179 | |||
5180 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
5181 | { | ||
5182 | health+=1; | ||
5183 | flags |= 4; | ||
5184 | } | ||
4939 | else | 5185 | else |
5186 | { | ||
5187 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
5188 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
5189 | proc.EnableRaisingEvents=false; | ||
5190 | proc.StartInfo.FileName = "/bin/kill"; | ||
5191 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
5192 | proc.Start(); | ||
5193 | proc.WaitForExit(); | ||
5194 | Thread.Sleep(1000); | ||
5195 | Environment.Exit(1); | ||
5196 | } | ||
5197 | |||
5198 | if (flags != 7) | ||
4940 | return health; | 5199 | return health; |
4941 | 5200 | ||
4942 | // A login in the last 4 mins? We can't be doing too badly | 5201 | // A login in the last 4 mins? We can't be doing too badly |
4943 | // | 5202 | // |
4944 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 5203 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4945 | health++; | 5204 | health++; |
4946 | else | 5205 | else |
4947 | return health; | 5206 | return health; |
4948 | 5207 | ||
4949 | // CheckHeartbeat(); | ||
4950 | |||
4951 | return health; | 5208 | return health; |
4952 | } | 5209 | } |
4953 | 5210 | ||
@@ -5035,7 +5292,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5035 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5292 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
5036 | if (wasUsingPhysics) | 5293 | if (wasUsingPhysics) |
5037 | { | 5294 | { |
5038 | 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 | 5295 | 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 |
5039 | } | 5296 | } |
5040 | } | 5297 | } |
5041 | 5298 | ||
@@ -5134,14 +5391,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5134 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5391 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
5135 | } | 5392 | } |
5136 | 5393 | ||
5137 | // private void CheckHeartbeat() | 5394 | private void CheckHeartbeat() |
5138 | // { | 5395 | { |
5139 | // if (m_firstHeartbeat) | 5396 | if (m_firstHeartbeat) |
5140 | // return; | 5397 | return; |
5141 | // | 5398 | |
5142 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5399 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
5143 | // StartTimer(); | 5400 | Start(); |
5144 | // } | 5401 | } |
5145 | 5402 | ||
5146 | public override ISceneObject DeserializeObject(string representation) | 5403 | public override ISceneObject DeserializeObject(string representation) |
5147 | { | 5404 | { |
@@ -5153,9 +5410,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5153 | get { return m_allowScriptCrossings; } | 5410 | get { return m_allowScriptCrossings; } |
5154 | } | 5411 | } |
5155 | 5412 | ||
5156 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5413 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
5157 | { | 5414 | { |
5158 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5415 | return GetNearestAllowedPosition(avatar, null); |
5416 | } | ||
5417 | |||
5418 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
5419 | { | ||
5420 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); | ||
5159 | 5421 | ||
5160 | if (nearestParcel != null) | 5422 | if (nearestParcel != null) |
5161 | { | 5423 | { |
@@ -5164,10 +5426,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5164 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5426 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
5165 | if (nearestPoint != null) | 5427 | if (nearestPoint != null) |
5166 | { | 5428 | { |
5167 | // m_log.DebugFormat( | 5429 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
5168 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
5169 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
5170 | |||
5171 | return nearestPoint.Value; | 5430 | return nearestPoint.Value; |
5172 | } | 5431 | } |
5173 | 5432 | ||
@@ -5177,17 +5436,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
5177 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5436 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
5178 | if (nearestPoint != null) | 5437 | if (nearestPoint != null) |
5179 | { | 5438 | { |
5180 | // m_log.DebugFormat( | 5439 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
5181 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
5182 | |||
5183 | return nearestPoint.Value; | 5440 | return nearestPoint.Value; |
5184 | } | 5441 | } |
5185 | 5442 | ||
5186 | //Ultimate backup if we have no idea where they are | 5443 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
5187 | // m_log.DebugFormat( | 5444 | if (dest != excludeParcel) |
5188 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5445 | { |
5446 | // Ultimate backup if we have no idea where they are and | ||
5447 | // the last allowed position was in another parcel | ||
5448 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5449 | return avatar.lastKnownAllowedPosition; | ||
5450 | } | ||
5189 | 5451 | ||
5190 | return avatar.lastKnownAllowedPosition; | 5452 | // else fall through to region edge |
5191 | } | 5453 | } |
5192 | 5454 | ||
5193 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5455 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -5221,13 +5483,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
5221 | 5483 | ||
5222 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5484 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
5223 | { | 5485 | { |
5486 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5487 | } | ||
5488 | |||
5489 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5490 | { | ||
5224 | List<ILandObject> all = AllParcels(); | 5491 | List<ILandObject> all = AllParcels(); |
5225 | float minParcelDistance = float.MaxValue; | 5492 | float minParcelDistance = float.MaxValue; |
5226 | ILandObject nearestParcel = null; | 5493 | ILandObject nearestParcel = null; |
5227 | 5494 | ||
5228 | foreach (var parcel in all) | 5495 | foreach (var parcel in all) |
5229 | { | 5496 | { |
5230 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5497 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
5231 | { | 5498 | { |
5232 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5499 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
5233 | if (parcelDistance < minParcelDistance) | 5500 | if (parcelDistance < minParcelDistance) |
@@ -5469,7 +5736,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5469 | mapModule.GenerateMaptile(); | 5736 | mapModule.GenerateMaptile(); |
5470 | } | 5737 | } |
5471 | 5738 | ||
5472 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5739 | // public void CleanDroppedAttachments() |
5740 | // { | ||
5741 | // List<SceneObjectGroup> objectsToDelete = | ||
5742 | // new List<SceneObjectGroup>(); | ||
5743 | // | ||
5744 | // lock (m_cleaningAttachments) | ||
5745 | // { | ||
5746 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5747 | // { | ||
5748 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5749 | // { | ||
5750 | // UUID agentID = grp.OwnerID; | ||
5751 | // if (agentID == UUID.Zero) | ||
5752 | // { | ||
5753 | // objectsToDelete.Add(grp); | ||
5754 | // return; | ||
5755 | // } | ||
5756 | // | ||
5757 | // ScenePresence sp = GetScenePresence(agentID); | ||
5758 | // if (sp == null) | ||
5759 | // { | ||
5760 | // objectsToDelete.Add(grp); | ||
5761 | // return; | ||
5762 | // } | ||
5763 | // } | ||
5764 | // }); | ||
5765 | // } | ||
5766 | // | ||
5767 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5768 | // { | ||
5769 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5770 | // DeleteSceneObject(grp, true); | ||
5771 | // } | ||
5772 | // } | ||
5773 | |||
5774 | public void ThreadAlive(int threadCode) | ||
5775 | { | ||
5776 | switch(threadCode) | ||
5777 | { | ||
5778 | case 1: // Incoming | ||
5779 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5780 | break; | ||
5781 | case 2: // Incoming | ||
5782 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5783 | break; | ||
5784 | } | ||
5785 | } | ||
5786 | |||
5787 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5473 | { | 5788 | { |
5474 | RegenerateMaptile(); | 5789 | RegenerateMaptile(); |
5475 | 5790 | ||
@@ -5497,6 +5812,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5497 | /// <returns></returns> | 5812 | /// <returns></returns> |
5498 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5813 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5499 | { | 5814 | { |
5815 | reason = "You are banned from the region"; | ||
5816 | |||
5500 | if (EntityTransferModule.IsInTransit(agentID)) | 5817 | if (EntityTransferModule.IsInTransit(agentID)) |
5501 | { | 5818 | { |
5502 | reason = "Agent is still in transit from this region"; | 5819 | reason = "Agent is still in transit from this region"; |
@@ -5508,6 +5825,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5508 | return false; | 5825 | return false; |
5509 | } | 5826 | } |
5510 | 5827 | ||
5828 | if (Permissions.IsGod(agentID)) | ||
5829 | { | ||
5830 | reason = String.Empty; | ||
5831 | return true; | ||
5832 | } | ||
5833 | |||
5511 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5834 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5512 | // However, the long term fix is to make sure root agent count is always accurate. | 5835 | // However, the long term fix is to make sure root agent count is always accurate. |
5513 | m_sceneGraph.RecalculateStats(); | 5836 | m_sceneGraph.RecalculateStats(); |
@@ -5528,6 +5851,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5528 | } | 5851 | } |
5529 | } | 5852 | } |
5530 | 5853 | ||
5854 | ScenePresence presence = GetScenePresence(agentID); | ||
5855 | IClientAPI client = null; | ||
5856 | AgentCircuitData aCircuit = null; | ||
5857 | |||
5858 | if (presence != null) | ||
5859 | { | ||
5860 | client = presence.ControllingClient; | ||
5861 | if (client != null) | ||
5862 | aCircuit = client.RequestClientInfo(); | ||
5863 | } | ||
5864 | |||
5865 | // We may be called before there is a presence or a client. | ||
5866 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5867 | if (client == null) | ||
5868 | { | ||
5869 | aCircuit = new AgentCircuitData(); | ||
5870 | aCircuit.AgentID = agentID; | ||
5871 | aCircuit.firstname = String.Empty; | ||
5872 | aCircuit.lastname = String.Empty; | ||
5873 | } | ||
5874 | |||
5875 | try | ||
5876 | { | ||
5877 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5878 | { | ||
5879 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5880 | return false; | ||
5881 | } | ||
5882 | } | ||
5883 | catch (Exception e) | ||
5884 | { | ||
5885 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5886 | return false; | ||
5887 | } | ||
5888 | |||
5531 | if (position == Vector3.Zero) // Teleport | 5889 | if (position == Vector3.Zero) // Teleport |
5532 | { | 5890 | { |
5533 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5891 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5556,13 +5914,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5556 | } | 5914 | } |
5557 | } | 5915 | } |
5558 | } | 5916 | } |
5917 | |||
5918 | float posX = 128.0f; | ||
5919 | float posY = 128.0f; | ||
5920 | |||
5921 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5922 | { | ||
5923 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5924 | return false; | ||
5925 | } | ||
5926 | } | ||
5927 | else // Walking | ||
5928 | { | ||
5929 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5930 | if (land == null) | ||
5931 | return false; | ||
5932 | |||
5933 | bool banned = land.IsBannedFromLand(agentID); | ||
5934 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5935 | |||
5936 | if (banned || restricted) | ||
5937 | return false; | ||
5559 | } | 5938 | } |
5560 | 5939 | ||
5561 | reason = String.Empty; | 5940 | reason = String.Empty; |
5562 | return true; | 5941 | return true; |
5563 | } | 5942 | } |
5564 | 5943 | ||
5565 | /// <summary> | 5944 | public void StartTimerWatchdog() |
5945 | { | ||
5946 | m_timerWatchdog.Interval = 1000; | ||
5947 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5948 | m_timerWatchdog.AutoReset = true; | ||
5949 | m_timerWatchdog.Start(); | ||
5950 | } | ||
5951 | |||
5952 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5953 | { | ||
5954 | CheckHeartbeat(); | ||
5955 | } | ||
5956 | |||
5566 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5957 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5567 | /// autopilot that moves an avatar to a sit target!. | 5958 | /// autopilot that moves an avatar to a sit target!. |
5568 | /// </summary> | 5959 | /// </summary> |
@@ -5641,6 +6032,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5641 | return m_SpawnPoint - 1; | 6032 | return m_SpawnPoint - 1; |
5642 | } | 6033 | } |
5643 | 6034 | ||
6035 | private void HandleGcCollect(string module, string[] args) | ||
6036 | { | ||
6037 | GC.Collect(); | ||
6038 | } | ||
6039 | |||
5644 | // Wrappers to get physics modules retrieve assets. Has to be done this way | 6040 | // Wrappers to get physics modules retrieve assets. Has to be done this way |
5645 | // because we can't assign the asset service to physics directly - at the | 6041 | // because we can't assign the asset service to physics directly - at the |
5646 | // time physics are instantiated it's not registered but it will be by | 6042 | // time physics are instantiated it's not registered but it will be by |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index b87a38a..7c8bd88 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -149,7 +149,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
149 | 149 | ||
150 | protected ulong m_regionHandle; | 150 | protected ulong m_regionHandle; |
151 | protected string m_regionName; | 151 | protected string m_regionName; |
152 | protected RegionInfo m_regInfo; | ||
153 | 152 | ||
154 | public ITerrainChannel Heightmap; | 153 | public ITerrainChannel Heightmap; |
155 | 154 | ||
@@ -174,6 +173,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
174 | get { return m_permissions; } | 173 | get { return m_permissions; } |
175 | } | 174 | } |
176 | 175 | ||
176 | protected string m_datastore; | ||
177 | |||
177 | /* Used by the loadbalancer plugin on GForge */ | 178 | /* Used by the loadbalancer plugin on GForge */ |
178 | protected RegionStatus m_regStatus; | 179 | protected RegionStatus m_regStatus; |
179 | public RegionStatus RegionStatus | 180 | public RegionStatus RegionStatus |
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 305f8a4..775a4c2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -194,10 +194,13 @@ 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) | 203 | protected void SendCloseChildAgentAsync(UUID agentID, ulong regionHandle) |
201 | { | 204 | { |
202 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. | 205 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. |
203 | 206 | ||
@@ -206,30 +209,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
206 | Utils.LongToUInts(regionHandle, out x, out y); | 209 | Utils.LongToUInts(regionHandle, out x, out y); |
207 | 210 | ||
208 | GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); | 211 | GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); |
212 | m_scene.SimulationService.CloseChildAgent(destination, agentID); | ||
213 | } | ||
209 | 214 | ||
210 | m_log.DebugFormat( | 215 | private void SendCloseChildAgentCompleted(IAsyncResult iar) |
211 | "[SCENE COMMUNICATION SERVICE]: Sending close agent ID {0} to {1}", agentID, destination.RegionName); | 216 | { |
212 | 217 | SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate)iar.AsyncState; | |
213 | m_scene.SimulationService.CloseAgent(destination, agentID); | 218 | icon.EndInvoke(iar); |
214 | } | 219 | } |
215 | 220 | ||
216 | /// <summary> | ||
217 | /// Closes a child agents in a collection of regions. Does so asynchronously | ||
218 | /// so that the caller doesn't wait. | ||
219 | /// </summary> | ||
220 | /// <param name="agentID"></param> | ||
221 | /// <param name="regionslst"></param> | ||
222 | public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst) | 221 | public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst) |
223 | { | 222 | { |
224 | foreach (ulong handle in regionslst) | 223 | foreach (ulong handle in regionslst) |
225 | { | 224 | { |
226 | SendCloseChildAgent(agentID, handle); | 225 | SendCloseChildAgentDelegate d = SendCloseChildAgentAsync; |
226 | d.BeginInvoke(agentID, handle, | ||
227 | SendCloseChildAgentCompleted, | ||
228 | d); | ||
227 | } | 229 | } |
228 | } | 230 | } |
229 | 231 | ||
230 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) | 232 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) |
231 | { | 233 | { |
232 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); | 234 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); |
233 | } | 235 | } |
234 | } | 236 | } |
235 | } \ No newline at end of file | 237 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a4383fd..e599e90 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) |
@@ -592,7 +662,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
592 | 662 | ||
593 | Entities[presence.UUID] = presence; | 663 | Entities[presence.UUID] = presence; |
594 | 664 | ||
595 | lock (m_presenceLock) | 665 | m_scenePresencesLock.EnterWriteLock(); |
666 | try | ||
596 | { | 667 | { |
597 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 668 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
598 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 669 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -616,6 +687,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
616 | m_scenePresenceMap = newmap; | 687 | m_scenePresenceMap = newmap; |
617 | m_scenePresenceArray = newlist; | 688 | m_scenePresenceArray = newlist; |
618 | } | 689 | } |
690 | finally | ||
691 | { | ||
692 | m_scenePresencesLock.ExitWriteLock(); | ||
693 | } | ||
619 | } | 694 | } |
620 | 695 | ||
621 | /// <summary> | 696 | /// <summary> |
@@ -630,7 +705,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
630 | agentID); | 705 | agentID); |
631 | } | 706 | } |
632 | 707 | ||
633 | lock (m_presenceLock) | 708 | m_scenePresencesLock.EnterWriteLock(); |
709 | try | ||
634 | { | 710 | { |
635 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 711 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
636 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 712 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -652,6 +728,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
652 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); | 728 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); |
653 | } | 729 | } |
654 | } | 730 | } |
731 | finally | ||
732 | { | ||
733 | m_scenePresencesLock.ExitWriteLock(); | ||
734 | } | ||
655 | } | 735 | } |
656 | 736 | ||
657 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) | 737 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) |
@@ -1205,6 +1285,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
1205 | 1285 | ||
1206 | #region Client Event handlers | 1286 | #region Client Event handlers |
1207 | 1287 | ||
1288 | protected internal void ClientChangeObject(uint localID, object odata, IClientAPI remoteClient) | ||
1289 | { | ||
1290 | SceneObjectPart part = GetSceneObjectPart(localID); | ||
1291 | ObjectChangeData data = (ObjectChangeData)odata; | ||
1292 | |||
1293 | if (part != null) | ||
1294 | { | ||
1295 | SceneObjectGroup grp = part.ParentGroup; | ||
1296 | if (grp != null) | ||
1297 | { | ||
1298 | if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) | ||
1299 | { | ||
1300 | // These two are exceptions SL makes in the interpretation | ||
1301 | // of the change flags. Must check them here because otherwise | ||
1302 | // the group flag (see below) would be lost | ||
1303 | if (data.change == ObjectChangeType.groupS) | ||
1304 | data.change = ObjectChangeType.primS; | ||
1305 | if (data.change == ObjectChangeType.groupPS) | ||
1306 | data.change = ObjectChangeType.primPS; | ||
1307 | part.StoreUndoState(data.change); // lets test only saving what we changed | ||
1308 | grp.doChangeObject(part, (ObjectChangeData)data); | ||
1309 | } | ||
1310 | else | ||
1311 | { | ||
1312 | // Is this any kind of group operation? | ||
1313 | if ((data.change & ObjectChangeType.Group) != 0) | ||
1314 | { | ||
1315 | // Is a move and/or rotation requested? | ||
1316 | if ((data.change & (ObjectChangeType.Position | ObjectChangeType.Rotation)) != 0) | ||
1317 | { | ||
1318 | // Are we allowed to move it? | ||
1319 | if (m_parentScene.Permissions.CanMoveObject(grp.UUID, remoteClient.AgentId)) | ||
1320 | { | ||
1321 | // Strip all but move and rotation from request | ||
1322 | data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation); | ||
1323 | |||
1324 | part.StoreUndoState(data.change); | ||
1325 | grp.doChangeObject(part, (ObjectChangeData)data); | ||
1326 | } | ||
1327 | } | ||
1328 | } | ||
1329 | } | ||
1330 | } | ||
1331 | } | ||
1332 | } | ||
1333 | |||
1208 | /// <summary> | 1334 | /// <summary> |
1209 | /// Update the scale of an individual prim. | 1335 | /// Update the scale of an individual prim. |
1210 | /// </summary> | 1336 | /// </summary> |
@@ -1219,7 +1345,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1219 | { | 1345 | { |
1220 | if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) | 1346 | if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) |
1221 | { | 1347 | { |
1348 | bool physbuild = false; | ||
1349 | if (part.ParentGroup.RootPart.PhysActor != null) | ||
1350 | { | ||
1351 | part.ParentGroup.RootPart.PhysActor.Building = true; | ||
1352 | physbuild = true; | ||
1353 | } | ||
1354 | |||
1222 | part.Resize(scale); | 1355 | part.Resize(scale); |
1356 | |||
1357 | if (physbuild) | ||
1358 | part.ParentGroup.RootPart.PhysActor.Building = false; | ||
1223 | } | 1359 | } |
1224 | } | 1360 | } |
1225 | } | 1361 | } |
@@ -1231,7 +1367,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1231 | { | 1367 | { |
1232 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) | 1368 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) |
1233 | { | 1369 | { |
1370 | bool physbuild = false; | ||
1371 | if (group.RootPart.PhysActor != null) | ||
1372 | { | ||
1373 | group.RootPart.PhysActor.Building = true; | ||
1374 | physbuild = true; | ||
1375 | } | ||
1376 | |||
1234 | group.GroupResize(scale); | 1377 | group.GroupResize(scale); |
1378 | |||
1379 | if (physbuild) | ||
1380 | group.RootPart.PhysActor.Building = false; | ||
1235 | } | 1381 | } |
1236 | } | 1382 | } |
1237 | } | 1383 | } |
@@ -1359,8 +1505,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1359 | { | 1505 | { |
1360 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) | 1506 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) |
1361 | { | 1507 | { |
1362 | if (m_parentScene.AttachmentsModule != null) | 1508 | // Set the new attachment point data in the object |
1363 | m_parentScene.AttachmentsModule.UpdateAttachmentPosition(group, pos); | 1509 | byte attachmentPoint = group.GetAttachmentPoint(); |
1510 | group.UpdateGroupPosition(pos); | ||
1511 | group.IsAttachment = false; | ||
1512 | group.AbsolutePosition = group.RootPart.AttachedPos; | ||
1513 | group.AttachmentPoint = attachmentPoint; | ||
1514 | group.HasGroupChanged = true; | ||
1364 | } | 1515 | } |
1365 | else | 1516 | else |
1366 | { | 1517 | { |
@@ -1408,7 +1559,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1408 | /// <param name="SetPhantom"></param> | 1559 | /// <param name="SetPhantom"></param> |
1409 | /// <param name="remoteClient"></param> | 1560 | /// <param name="remoteClient"></param> |
1410 | protected internal void UpdatePrimFlags( | 1561 | protected internal void UpdatePrimFlags( |
1411 | uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, IClientAPI remoteClient) | 1562 | uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, ExtraPhysicsData PhysData, IClientAPI remoteClient) |
1412 | { | 1563 | { |
1413 | SceneObjectGroup group = GetGroupByPrim(localID); | 1564 | SceneObjectGroup group = GetGroupByPrim(localID); |
1414 | if (group != null) | 1565 | if (group != null) |
@@ -1416,7 +1567,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1416 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) | 1567 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) |
1417 | { | 1568 | { |
1418 | // VolumeDetect can't be set via UI and will always be off when a change is made there | 1569 | // VolumeDetect can't be set via UI and will always be off when a change is made there |
1419 | group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, false); | 1570 | // now only change volume dtc if phantom off |
1571 | |||
1572 | if (PhysData.PhysShapeType == PhysShapeType.invalid) // check for extraPhysics data | ||
1573 | { | ||
1574 | bool vdtc; | ||
1575 | if (SetPhantom) // if phantom keep volumedtc | ||
1576 | vdtc = group.RootPart.VolumeDetectActive; | ||
1577 | else // else turn it off | ||
1578 | vdtc = false; | ||
1579 | |||
1580 | group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, vdtc); | ||
1581 | } | ||
1582 | else | ||
1583 | { | ||
1584 | SceneObjectPart part = GetSceneObjectPart(localID); | ||
1585 | if (part != null) | ||
1586 | { | ||
1587 | part.UpdateExtraPhysics(PhysData); | ||
1588 | if (part.UpdatePhysRequired) | ||
1589 | remoteClient.SendPartPhysicsProprieties(part); | ||
1590 | } | ||
1591 | } | ||
1420 | } | 1592 | } |
1421 | } | 1593 | } |
1422 | } | 1594 | } |
@@ -1560,6 +1732,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1560 | { | 1732 | { |
1561 | part.Material = Convert.ToByte(material); | 1733 | part.Material = Convert.ToByte(material); |
1562 | group.HasGroupChanged = true; | 1734 | group.HasGroupChanged = true; |
1735 | remoteClient.SendPartPhysicsProprieties(part); | ||
1563 | } | 1736 | } |
1564 | } | 1737 | } |
1565 | } | 1738 | } |
@@ -1624,6 +1797,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1624 | /// <param name="childPrims"></param> | 1797 | /// <param name="childPrims"></param> |
1625 | protected internal void LinkObjects(SceneObjectPart root, List<SceneObjectPart> children) | 1798 | protected internal void LinkObjects(SceneObjectPart root, List<SceneObjectPart> children) |
1626 | { | 1799 | { |
1800 | if (root.KeyframeMotion != null) | ||
1801 | { | ||
1802 | root.KeyframeMotion.Stop(); | ||
1803 | root.KeyframeMotion = null; | ||
1804 | } | ||
1805 | |||
1627 | SceneObjectGroup parentGroup = root.ParentGroup; | 1806 | SceneObjectGroup parentGroup = root.ParentGroup; |
1628 | if (parentGroup == null) return; | 1807 | if (parentGroup == null) return; |
1629 | 1808 | ||
@@ -1632,8 +1811,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1632 | return; | 1811 | return; |
1633 | 1812 | ||
1634 | Monitor.Enter(m_updateLock); | 1813 | Monitor.Enter(m_updateLock); |
1814 | |||
1635 | try | 1815 | try |
1636 | { | 1816 | { |
1817 | |||
1637 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); | 1818 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); |
1638 | 1819 | ||
1639 | // We do this in reverse to get the link order of the prims correct | 1820 | // We do this in reverse to get the link order of the prims correct |
@@ -1648,9 +1829,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1648 | // Make sure no child prim is set for sale | 1829 | // Make sure no child prim is set for sale |
1649 | // So that, on delink, no prims are unwittingly | 1830 | // So that, on delink, no prims are unwittingly |
1650 | // left for sale and sold off | 1831 | // left for sale and sold off |
1651 | child.RootPart.ObjectSaleType = 0; | 1832 | |
1652 | child.RootPart.SalePrice = 10; | 1833 | if (child != null) |
1653 | childGroups.Add(child); | 1834 | { |
1835 | child.RootPart.ObjectSaleType = 0; | ||
1836 | child.RootPart.SalePrice = 10; | ||
1837 | childGroups.Add(child); | ||
1838 | } | ||
1654 | } | 1839 | } |
1655 | 1840 | ||
1656 | foreach (SceneObjectGroup child in childGroups) | 1841 | foreach (SceneObjectGroup child in childGroups) |
@@ -1679,6 +1864,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1679 | } | 1864 | } |
1680 | finally | 1865 | finally |
1681 | { | 1866 | { |
1867 | lock (SceneObjectGroupsByLocalPartID) | ||
1868 | { | ||
1869 | foreach (SceneObjectPart part in parentGroup.Parts) | ||
1870 | SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; | ||
1871 | } | ||
1872 | |||
1873 | parentGroup.AdjustChildPrimPermissions(); | ||
1874 | parentGroup.HasGroupChanged = true; | ||
1875 | parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); | ||
1876 | parentGroup.ScheduleGroupForFullUpdate(); | ||
1682 | Monitor.Exit(m_updateLock); | 1877 | Monitor.Exit(m_updateLock); |
1683 | } | 1878 | } |
1684 | } | 1879 | } |
@@ -1701,6 +1896,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1701 | { | 1896 | { |
1702 | if (part != null) | 1897 | if (part != null) |
1703 | { | 1898 | { |
1899 | if (part.KeyframeMotion != null) | ||
1900 | { | ||
1901 | part.KeyframeMotion.Stop(); | ||
1902 | part.KeyframeMotion = null; | ||
1903 | } | ||
1704 | if (part.ParentGroup.PrimCount != 1) // Skip single | 1904 | if (part.ParentGroup.PrimCount != 1) // Skip single |
1705 | { | 1905 | { |
1706 | if (part.LinkNum < 2) // Root | 1906 | if (part.LinkNum < 2) // Root |
@@ -1715,21 +1915,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
1715 | 1915 | ||
1716 | SceneObjectGroup group = part.ParentGroup; | 1916 | SceneObjectGroup group = part.ParentGroup; |
1717 | if (!affectedGroups.Contains(group)) | 1917 | if (!affectedGroups.Contains(group)) |
1918 | { | ||
1718 | affectedGroups.Add(group); | 1919 | affectedGroups.Add(group); |
1920 | } | ||
1719 | } | 1921 | } |
1720 | } | 1922 | } |
1721 | } | 1923 | } |
1722 | 1924 | ||
1723 | foreach (SceneObjectPart child in childParts) | 1925 | if (childParts.Count > 0) |
1724 | { | 1926 | { |
1725 | // Unlink all child parts from their groups | 1927 | foreach (SceneObjectPart child in childParts) |
1726 | // | 1928 | { |
1727 | child.ParentGroup.DelinkFromGroup(child, true); | 1929 | // Unlink all child parts from their groups |
1728 | 1930 | // | |
1729 | // These are not in affected groups and will not be | 1931 | child.ParentGroup.DelinkFromGroup(child, true); |
1730 | // handled further. Do the honors here. | 1932 | child.ParentGroup.HasGroupChanged = true; |
1731 | child.ParentGroup.HasGroupChanged = true; | 1933 | child.ParentGroup.ScheduleGroupForFullUpdate(); |
1732 | child.ParentGroup.ScheduleGroupForFullUpdate(); | 1934 | } |
1733 | } | 1935 | } |
1734 | 1936 | ||
1735 | foreach (SceneObjectPart root in rootParts) | 1937 | foreach (SceneObjectPart root in rootParts) |
@@ -1743,52 +1945,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1743 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); | 1945 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); |
1744 | int numChildren = newSet.Count; | 1946 | int numChildren = newSet.Count; |
1745 | 1947 | ||
1948 | if (numChildren == 1) | ||
1949 | break; | ||
1950 | |||
1746 | // If there are prims left in a link set, but the root is | 1951 | // If there are prims left in a link set, but the root is |
1747 | // slated for unlink, we need to do this | 1952 | // slated for unlink, we need to do this |
1953 | // Unlink the remaining set | ||
1748 | // | 1954 | // |
1749 | if (numChildren != 1) | 1955 | bool sendEventsToRemainder = true; |
1750 | { | 1956 | if (numChildren > 1) |
1751 | // Unlink the remaining set | 1957 | sendEventsToRemainder = false; |
1752 | // | ||
1753 | bool sendEventsToRemainder = true; | ||
1754 | if (numChildren > 1) | ||
1755 | sendEventsToRemainder = false; | ||
1756 | 1958 | ||
1757 | foreach (SceneObjectPart p in newSet) | 1959 | foreach (SceneObjectPart p in newSet) |
1960 | { | ||
1961 | if (p != group.RootPart) | ||
1758 | { | 1962 | { |
1759 | if (p != group.RootPart) | 1963 | group.DelinkFromGroup(p, sendEventsToRemainder); |
1760 | group.DelinkFromGroup(p, sendEventsToRemainder); | 1964 | if (numChildren > 2) |
1965 | { | ||
1966 | } | ||
1967 | else | ||
1968 | { | ||
1969 | p.ParentGroup.HasGroupChanged = true; | ||
1970 | p.ParentGroup.ScheduleGroupForFullUpdate(); | ||
1971 | } | ||
1761 | } | 1972 | } |
1973 | } | ||
1974 | |||
1975 | // If there is more than one prim remaining, we | ||
1976 | // need to re-link | ||
1977 | // | ||
1978 | if (numChildren > 2) | ||
1979 | { | ||
1980 | // Remove old root | ||
1981 | // | ||
1982 | if (newSet.Contains(root)) | ||
1983 | newSet.Remove(root); | ||
1762 | 1984 | ||
1763 | // If there is more than one prim remaining, we | 1985 | // Preserve link ordering |
1764 | // need to re-link | ||
1765 | // | 1986 | // |
1766 | if (numChildren > 2) | 1987 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) |
1767 | { | 1988 | { |
1768 | // Remove old root | 1989 | return a.LinkNum.CompareTo(b.LinkNum); |
1769 | // | 1990 | }); |
1770 | if (newSet.Contains(root)) | ||
1771 | newSet.Remove(root); | ||
1772 | |||
1773 | // Preserve link ordering | ||
1774 | // | ||
1775 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) | ||
1776 | { | ||
1777 | return a.LinkNum.CompareTo(b.LinkNum); | ||
1778 | }); | ||
1779 | 1991 | ||
1780 | // Determine new root | 1992 | // Determine new root |
1781 | // | 1993 | // |
1782 | SceneObjectPart newRoot = newSet[0]; | 1994 | SceneObjectPart newRoot = newSet[0]; |
1783 | newSet.RemoveAt(0); | 1995 | newSet.RemoveAt(0); |
1784 | 1996 | ||
1785 | foreach (SceneObjectPart newChild in newSet) | 1997 | foreach (SceneObjectPart newChild in newSet) |
1786 | newChild.ClearUpdateSchedule(); | 1998 | newChild.ClearUpdateSchedule(); |
1787 | 1999 | ||
1788 | LinkObjects(newRoot, newSet); | 2000 | LinkObjects(newRoot, newSet); |
1789 | if (!affectedGroups.Contains(newRoot.ParentGroup)) | 2001 | if (!affectedGroups.Contains(newRoot.ParentGroup)) |
1790 | affectedGroups.Add(newRoot.ParentGroup); | 2002 | affectedGroups.Add(newRoot.ParentGroup); |
1791 | } | ||
1792 | } | 2003 | } |
1793 | } | 2004 | } |
1794 | 2005 | ||
@@ -1796,6 +2007,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1796 | // | 2007 | // |
1797 | foreach (SceneObjectGroup g in affectedGroups) | 2008 | foreach (SceneObjectGroup g in affectedGroups) |
1798 | { | 2009 | { |
2010 | // Child prims that have been unlinked and deleted will | ||
2011 | // return unless the root is deleted. This will remove them | ||
2012 | // from the database. They will be rewritten immediately, | ||
2013 | // minus the rows for the unlinked child prims. | ||
2014 | g.AdjustChildPrimPermissions(); | ||
2015 | m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); | ||
1799 | g.TriggerScriptChangedEvent(Changed.LINK); | 2016 | g.TriggerScriptChangedEvent(Changed.LINK); |
1800 | g.HasGroupChanged = true; // Persist | 2017 | g.HasGroupChanged = true; // Persist |
1801 | g.ScheduleGroupForFullUpdate(); | 2018 | g.ScheduleGroupForFullUpdate(); |
@@ -1869,108 +2086,96 @@ namespace OpenSim.Region.Framework.Scenes | |||
1869 | /// <param name="GroupID"></param> | 2086 | /// <param name="GroupID"></param> |
1870 | /// <param name="rot"></param> | 2087 | /// <param name="rot"></param> |
1871 | /// <returns>null if duplication fails, otherwise the duplicated object</returns> | 2088 | /// <returns>null if duplication fails, otherwise the duplicated object</returns> |
1872 | public SceneObjectGroup DuplicateObject( | 2089 | /// <summary> |
1873 | uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) | 2090 | public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) |
1874 | { | 2091 | { |
1875 | Monitor.Enter(m_updateLock); | 2092 | // m_log.DebugFormat( |
2093 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | ||
2094 | // originalPrimID, offset, AgentID); | ||
1876 | 2095 | ||
1877 | try | 2096 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); |
2097 | if (original != null) | ||
1878 | { | 2098 | { |
1879 | // m_log.DebugFormat( | 2099 | if (m_parentScene.Permissions.CanDuplicateObject( |
1880 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | 2100 | original.PrimCount, original.UUID, AgentID, original.AbsolutePosition)) |
1881 | // originalPrimID, offset, AgentID); | ||
1882 | |||
1883 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); | ||
1884 | if (original == null) | ||
1885 | { | 2101 | { |
1886 | m_log.WarnFormat( | 2102 | SceneObjectGroup copy = original.Copy(true); |
1887 | "[SCENEGRAPH]: Attempt to duplicate nonexistant prim id {0} by {1}", originalPrimID, AgentID); | 2103 | copy.AbsolutePosition = copy.AbsolutePosition + offset; |
1888 | 2104 | ||
1889 | return null; | 2105 | if (original.OwnerID != AgentID) |
1890 | } | 2106 | { |
2107 | copy.SetOwnerId(AgentID); | ||
2108 | copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); | ||
1891 | 2109 | ||
1892 | if (!m_parentScene.Permissions.CanDuplicateObject( | 2110 | SceneObjectPart[] partList = copy.Parts; |
1893 | original.PrimCount, original.UUID, AgentID, original.AbsolutePosition)) | ||
1894 | return null; | ||
1895 | 2111 | ||
1896 | SceneObjectGroup copy = original.Copy(true); | 2112 | if (m_parentScene.Permissions.PropagatePermissions()) |
1897 | copy.AbsolutePosition = copy.AbsolutePosition + offset; | 2113 | { |
2114 | foreach (SceneObjectPart child in partList) | ||
2115 | { | ||
2116 | child.Inventory.ChangeInventoryOwner(AgentID); | ||
2117 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
2118 | child.ApplyNextOwnerPermissions(); | ||
2119 | } | ||
2120 | } | ||
2121 | } | ||
1898 | 2122 | ||
1899 | if (original.OwnerID != AgentID) | 2123 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() |
1900 | { | 2124 | Entities.Add(copy); |
1901 | copy.SetOwnerId(AgentID); | ||
1902 | copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); | ||
1903 | 2125 | ||
1904 | SceneObjectPart[] partList = copy.Parts; | 2126 | lock (SceneObjectGroupsByFullID) |
2127 | SceneObjectGroupsByFullID[copy.UUID] = copy; | ||
1905 | 2128 | ||
1906 | if (m_parentScene.Permissions.PropagatePermissions()) | 2129 | SceneObjectPart[] children = copy.Parts; |
2130 | |||
2131 | lock (SceneObjectGroupsByFullPartID) | ||
1907 | { | 2132 | { |
1908 | foreach (SceneObjectPart child in partList) | 2133 | SceneObjectGroupsByFullPartID[copy.UUID] = copy; |
1909 | { | 2134 | foreach (SceneObjectPart part in children) |
1910 | child.Inventory.ChangeInventoryOwner(AgentID); | 2135 | SceneObjectGroupsByFullPartID[part.UUID] = copy; |
1911 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
1912 | child.ApplyNextOwnerPermissions(); | ||
1913 | } | ||
1914 | } | 2136 | } |
1915 | 2137 | ||
1916 | copy.RootPart.ObjectSaleType = 0; | 2138 | lock (SceneObjectGroupsByLocalPartID) |
1917 | copy.RootPart.SalePrice = 10; | 2139 | { |
1918 | } | 2140 | SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; |
2141 | foreach (SceneObjectPart part in children) | ||
2142 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; | ||
2143 | } | ||
2144 | // PROBABLE END OF FIXME | ||
1919 | 2145 | ||
1920 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() | 2146 | // Since we copy from a source group that is in selected |
1921 | Entities.Add(copy); | 2147 | // state, but the copy is shown deselected in the viewer, |
1922 | 2148 | // We need to clear the selection flag here, else that | |
1923 | lock (SceneObjectGroupsByFullID) | 2149 | // prim never gets persisted at all. The client doesn't |
1924 | SceneObjectGroupsByFullID[copy.UUID] = copy; | 2150 | // think it's selected, so it will never send a deselect... |
1925 | 2151 | copy.IsSelected = false; | |
1926 | SceneObjectPart[] children = copy.Parts; | 2152 | |
1927 | 2153 | m_numPrim += copy.Parts.Length; | |
1928 | lock (SceneObjectGroupsByFullPartID) | 2154 | |
1929 | { | 2155 | if (rot != Quaternion.Identity) |
1930 | SceneObjectGroupsByFullPartID[copy.UUID] = copy; | 2156 | { |
1931 | foreach (SceneObjectPart part in children) | 2157 | copy.UpdateGroupRotationR(rot); |
1932 | SceneObjectGroupsByFullPartID[part.UUID] = copy; | 2158 | } |
1933 | } | ||
1934 | |||
1935 | lock (SceneObjectGroupsByLocalPartID) | ||
1936 | { | ||
1937 | SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; | ||
1938 | foreach (SceneObjectPart part in children) | ||
1939 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; | ||
1940 | } | ||
1941 | // PROBABLE END OF FIXME | ||
1942 | |||
1943 | // Since we copy from a source group that is in selected | ||
1944 | // state, but the copy is shown deselected in the viewer, | ||
1945 | // We need to clear the selection flag here, else that | ||
1946 | // prim never gets persisted at all. The client doesn't | ||
1947 | // think it's selected, so it will never send a deselect... | ||
1948 | copy.IsSelected = false; | ||
1949 | |||
1950 | m_numPrim += copy.Parts.Length; | ||
1951 | |||
1952 | if (rot != Quaternion.Identity) | ||
1953 | { | ||
1954 | copy.UpdateGroupRotationR(rot); | ||
1955 | } | ||
1956 | 2159 | ||
1957 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); | 2160 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); |
1958 | copy.HasGroupChanged = true; | 2161 | copy.HasGroupChanged = true; |
1959 | copy.ScheduleGroupForFullUpdate(); | 2162 | copy.ScheduleGroupForFullUpdate(); |
1960 | copy.ResumeScripts(); | 2163 | copy.ResumeScripts(); |
1961 | 2164 | ||
1962 | // required for physics to update it's position | 2165 | // required for physics to update it's position |
1963 | copy.AbsolutePosition = copy.AbsolutePosition; | 2166 | copy.AbsolutePosition = copy.AbsolutePosition; |
1964 | 2167 | ||
1965 | return copy; | 2168 | return copy; |
2169 | } | ||
1966 | } | 2170 | } |
1967 | finally | 2171 | else |
1968 | { | 2172 | { |
1969 | Monitor.Exit(m_updateLock); | 2173 | m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); |
1970 | } | 2174 | } |
2175 | |||
2176 | return null; | ||
1971 | } | 2177 | } |
1972 | 2178 | ||
1973 | /// <summary> | ||
1974 | /// Calculates the distance between two Vector3s | 2179 | /// Calculates the distance between two Vector3s |
1975 | /// </summary> | 2180 | /// </summary> |
1976 | /// <param name="v1"></param> | 2181 | /// <param name="v1"></param> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index cb5b2ba..dba3a61 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -99,12 +99,12 @@ 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 | private Scene m_currentScene = null; | 103 | private Scene m_currentScene = null; |
104 | 104 | ||
105 | public List<Scene> Scenes | 105 | public List<Scene> Scenes |
106 | { | 106 | { |
107 | get { return new List<Scene>(m_localScenes); } | 107 | get { return new List<Scene>(m_localScenes.FindAll(delegate(Scene s) { return true; })); } |
108 | } | 108 | } |
109 | 109 | ||
110 | public Scene CurrentScene | 110 | public Scene CurrentScene |
@@ -118,13 +118,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
118 | { | 118 | { |
119 | if (m_currentScene == null) | 119 | if (m_currentScene == null) |
120 | { | 120 | { |
121 | lock (m_localScenes) | 121 | List<Scene> sceneList = Scenes; |
122 | { | 122 | if (sceneList.Count == 0) |
123 | if (m_localScenes.Count > 0) | 123 | return null; |
124 | return m_localScenes[0]; | 124 | return sceneList[0]; |
125 | else | ||
126 | return null; | ||
127 | } | ||
128 | } | 125 | } |
129 | else | 126 | else |
130 | { | 127 | { |
@@ -136,7 +133,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
136 | public SceneManager() | 133 | public SceneManager() |
137 | { | 134 | { |
138 | m_instance = this; | 135 | m_instance = this; |
139 | m_localScenes = new List<Scene>(); | 136 | m_localScenes = new DoubleDictionary<UUID, string, Scene>(); |
140 | } | 137 | } |
141 | 138 | ||
142 | public void Close() | 139 | public void Close() |
@@ -144,20 +141,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
144 | // collect known shared modules in sharedModules | 141 | // collect known shared modules in sharedModules |
145 | Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>(); | 142 | Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>(); |
146 | 143 | ||
147 | lock (m_localScenes) | 144 | List<Scene> sceneList = Scenes; |
145 | for (int i = 0; i < sceneList.Count; i++) | ||
148 | { | 146 | { |
149 | for (int i = 0; i < m_localScenes.Count; i++) | 147 | // extract known shared modules from scene |
148 | foreach (string k in sceneList[i].Modules.Keys) | ||
150 | { | 149 | { |
151 | // extract known shared modules from scene | 150 | if (sceneList[i].Modules[k].IsSharedModule && |
152 | foreach (string k in m_localScenes[i].Modules.Keys) | 151 | !sharedModules.ContainsKey(k)) |
153 | { | 152 | sharedModules[k] = sceneList[i].Modules[k]; |
154 | if (m_localScenes[i].Modules[k].IsSharedModule && | ||
155 | !sharedModules.ContainsKey(k)) | ||
156 | sharedModules[k] = m_localScenes[i].Modules[k]; | ||
157 | } | ||
158 | // close scene/region | ||
159 | m_localScenes[i].Close(); | ||
160 | } | 153 | } |
154 | // close scene/region | ||
155 | sceneList[i].Close(); | ||
161 | } | 156 | } |
162 | 157 | ||
163 | // all regions/scenes are now closed, we can now safely | 158 | // all regions/scenes are now closed, we can now safely |
@@ -166,29 +161,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
166 | { | 161 | { |
167 | mod.Close(); | 162 | mod.Close(); |
168 | } | 163 | } |
164 | |||
165 | m_localScenes.Clear(); | ||
169 | } | 166 | } |
170 | 167 | ||
171 | public void Close(Scene cscene) | 168 | public void Close(Scene cscene) |
172 | { | 169 | { |
173 | lock (m_localScenes) | 170 | if (!m_localScenes.ContainsKey(cscene.RegionInfo.RegionID)) |
174 | { | 171 | return; |
175 | if (m_localScenes.Contains(cscene)) | 172 | cscene.Close(); |
176 | { | ||
177 | for (int i = 0; i < m_localScenes.Count; i++) | ||
178 | { | ||
179 | if (m_localScenes[i].Equals(cscene)) | ||
180 | { | ||
181 | m_localScenes[i].Close(); | ||
182 | } | ||
183 | } | ||
184 | } | ||
185 | } | ||
186 | } | 173 | } |
187 | 174 | ||
188 | public void Add(Scene scene) | 175 | public void Add(Scene scene) |
189 | { | 176 | { |
190 | lock (m_localScenes) | 177 | lock (m_localScenes) |
191 | m_localScenes.Add(scene); | 178 | m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene); |
192 | 179 | ||
193 | scene.OnRestart += HandleRestart; | 180 | scene.OnRestart += HandleRestart; |
194 | scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange; | 181 | scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange; |
@@ -200,23 +187,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
200 | int RegionSceneElement = -1; | 187 | int RegionSceneElement = -1; |
201 | 188 | ||
202 | lock (m_localScenes) | 189 | lock (m_localScenes) |
203 | { | 190 | m_localScenes.Remove(rdata.RegionID); |
204 | for (int i = 0; i < m_localScenes.Count; i++) | ||
205 | { | ||
206 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) | ||
207 | { | ||
208 | RegionSceneElement = i; | ||
209 | } | ||
210 | } | ||
211 | |||
212 | // Now we make sure the region is no longer known about by the SceneManager | ||
213 | // Prevents duplicates. | ||
214 | |||
215 | if (RegionSceneElement >= 0) | ||
216 | { | ||
217 | m_localScenes.RemoveAt(RegionSceneElement); | ||
218 | } | ||
219 | } | ||
220 | 191 | ||
221 | // Send signal to main that we're restarting this sim. | 192 | // Send signal to main that we're restarting this sim. |
222 | OnRestartSim(rdata); | 193 | OnRestartSim(rdata); |
@@ -225,39 +196,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
225 | private void HandleRegionReadyStatusChange(IScene scene) | 196 | private void HandleRegionReadyStatusChange(IScene scene) |
226 | { | 197 | { |
227 | lock (m_localScenes) | 198 | lock (m_localScenes) |
228 | AllRegionsReady = m_localScenes.TrueForAll(s => s.Ready); | 199 | AllRegionsReady = m_localScenes.FindAll(s => !s.Ready).Count == 0; |
229 | } | 200 | } |
230 | 201 | ||
231 | public void SendSimOnlineNotification(ulong regionHandle) | 202 | public void SendSimOnlineNotification(ulong regionHandle) |
232 | { | 203 | { |
233 | RegionInfo Result = null; | 204 | RegionInfo Result = null; |
234 | 205 | ||
235 | lock (m_localScenes) | 206 | Scene s = m_localScenes.FindValue(delegate(Scene x) |
236 | { | ||
237 | for (int i = 0; i < m_localScenes.Count; i++) | ||
238 | { | ||
239 | if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) | ||
240 | { | 207 | { |
241 | // Inform other regions to tell their avatar about me | 208 | if (x.RegionInfo.RegionHandle == regionHandle) |
242 | Result = m_localScenes[i].RegionInfo; | 209 | return true; |
243 | } | 210 | return false; |
244 | } | 211 | }); |
245 | 212 | ||
246 | if (Result != null) | 213 | if (s != null) |
214 | { | ||
215 | List<Scene> sceneList = Scenes; | ||
216 | |||
217 | for (int i = 0; i < sceneList.Count; i++) | ||
247 | { | 218 | { |
248 | for (int i = 0; i < m_localScenes.Count; i++) | 219 | if (sceneList[i]!= s) |
249 | { | 220 | { |
250 | if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) | 221 | // Inform other regions to tell their avatar about me |
251 | { | 222 | //sceneList[i].OtherRegionUp(Result); |
252 | // Inform other regions to tell their avatar about me | ||
253 | //m_localScenes[i].OtherRegionUp(Result); | ||
254 | } | ||
255 | } | 223 | } |
256 | } | 224 | } |
257 | else | 225 | } |
258 | { | 226 | else |
259 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); | 227 | { |
260 | } | 228 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); |
261 | } | 229 | } |
262 | } | 230 | } |
263 | 231 | ||
@@ -361,8 +329,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
361 | { | 329 | { |
362 | if (m_currentScene == null) | 330 | if (m_currentScene == null) |
363 | { | 331 | { |
364 | lock (m_localScenes) | 332 | List<Scene> sceneList = Scenes; |
365 | m_localScenes.ForEach(func); | 333 | sceneList.ForEach(func); |
366 | } | 334 | } |
367 | else | 335 | else |
368 | { | 336 | { |
@@ -391,16 +359,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
391 | } | 359 | } |
392 | else | 360 | else |
393 | { | 361 | { |
394 | lock (m_localScenes) | 362 | Scene s; |
363 | |||
364 | if (m_localScenes.TryGetValue(regionName, out s)) | ||
395 | { | 365 | { |
396 | foreach (Scene scene in m_localScenes) | 366 | m_currentScene = s; |
397 | { | 367 | return true; |
398 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) | ||
399 | { | ||
400 | m_currentScene = scene; | ||
401 | return true; | ||
402 | } | ||
403 | } | ||
404 | } | 368 | } |
405 | 369 | ||
406 | return false; | 370 | return false; |
@@ -409,18 +373,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
409 | 373 | ||
410 | public bool TrySetCurrentScene(UUID regionID) | 374 | public bool TrySetCurrentScene(UUID regionID) |
411 | { | 375 | { |
412 | m_log.Debug("Searching for Region: '" + regionID + "'"); | 376 | // m_log.Debug("Searching for Region: '" + regionID + "'"); |
413 | 377 | ||
414 | lock (m_localScenes) | 378 | Scene s; |
379 | |||
380 | if (m_localScenes.TryGetValue(regionID, out s)) | ||
415 | { | 381 | { |
416 | foreach (Scene scene in m_localScenes) | 382 | m_currentScene = s; |
417 | { | 383 | return true; |
418 | if (scene.RegionInfo.RegionID == regionID) | ||
419 | { | ||
420 | m_currentScene = scene; | ||
421 | return true; | ||
422 | } | ||
423 | } | ||
424 | } | 384 | } |
425 | 385 | ||
426 | return false; | 386 | return false; |
@@ -428,52 +388,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
428 | 388 | ||
429 | public bool TryGetScene(string regionName, out Scene scene) | 389 | public bool TryGetScene(string regionName, out Scene scene) |
430 | { | 390 | { |
431 | lock (m_localScenes) | 391 | return m_localScenes.TryGetValue(regionName, out scene); |
432 | { | ||
433 | foreach (Scene mscene in m_localScenes) | ||
434 | { | ||
435 | if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) | ||
436 | { | ||
437 | scene = mscene; | ||
438 | return true; | ||
439 | } | ||
440 | } | ||
441 | } | ||
442 | |||
443 | scene = null; | ||
444 | return false; | ||
445 | } | 392 | } |
446 | 393 | ||
447 | public bool TryGetScene(UUID regionID, out Scene scene) | 394 | public bool TryGetScene(UUID regionID, out Scene scene) |
448 | { | 395 | { |
449 | lock (m_localScenes) | 396 | return m_localScenes.TryGetValue(regionID, out scene); |
450 | { | ||
451 | foreach (Scene mscene in m_localScenes) | ||
452 | { | ||
453 | if (mscene.RegionInfo.RegionID == regionID) | ||
454 | { | ||
455 | scene = mscene; | ||
456 | return true; | ||
457 | } | ||
458 | } | ||
459 | } | ||
460 | |||
461 | scene = null; | ||
462 | return false; | ||
463 | } | 397 | } |
464 | 398 | ||
465 | public bool TryGetScene(uint locX, uint locY, out Scene scene) | 399 | public bool TryGetScene(uint locX, uint locY, out Scene scene) |
466 | { | 400 | { |
467 | lock (m_localScenes) | 401 | List<Scene> sceneList = Scenes; |
402 | foreach (Scene mscene in sceneList) | ||
468 | { | 403 | { |
469 | foreach (Scene mscene in m_localScenes) | 404 | if (mscene.RegionInfo.RegionLocX == locX && |
405 | mscene.RegionInfo.RegionLocY == locY) | ||
470 | { | 406 | { |
471 | if (mscene.RegionInfo.RegionLocX == locX && | 407 | scene = mscene; |
472 | mscene.RegionInfo.RegionLocY == locY) | 408 | return true; |
473 | { | ||
474 | scene = mscene; | ||
475 | return true; | ||
476 | } | ||
477 | } | 409 | } |
478 | } | 410 | } |
479 | 411 | ||
@@ -483,16 +415,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
483 | 415 | ||
484 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) | 416 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) |
485 | { | 417 | { |
486 | lock (m_localScenes) | 418 | List<Scene> sceneList = Scenes; |
419 | foreach (Scene mscene in sceneList) | ||
487 | { | 420 | { |
488 | foreach (Scene mscene in m_localScenes) | 421 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && |
422 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | ||
489 | { | 423 | { |
490 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && | 424 | scene = mscene; |
491 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | 425 | return true; |
492 | { | ||
493 | scene = mscene; | ||
494 | return true; | ||
495 | } | ||
496 | } | 426 | } |
497 | } | 427 | } |
498 | 428 | ||
@@ -557,15 +487,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
557 | 487 | ||
558 | public RegionInfo GetRegionInfo(UUID regionID) | 488 | public RegionInfo GetRegionInfo(UUID regionID) |
559 | { | 489 | { |
560 | lock (m_localScenes) | 490 | Scene s; |
491 | if (m_localScenes.TryGetValue(regionID, out s)) | ||
561 | { | 492 | { |
562 | foreach (Scene scene in m_localScenes) | 493 | return s.RegionInfo; |
563 | { | ||
564 | if (scene.RegionInfo.RegionID == regionID) | ||
565 | { | ||
566 | return scene.RegionInfo; | ||
567 | } | ||
568 | } | ||
569 | } | 494 | } |
570 | 495 | ||
571 | return null; | 496 | return null; |
@@ -583,14 +508,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
583 | 508 | ||
584 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) | 509 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) |
585 | { | 510 | { |
586 | lock (m_localScenes) | 511 | List<Scene> sceneList = Scenes; |
512 | foreach (Scene scene in sceneList) | ||
587 | { | 513 | { |
588 | foreach (Scene scene in m_localScenes) | 514 | if (scene.TryGetScenePresence(avatarId, out avatar)) |
589 | { | 515 | { |
590 | if (scene.TryGetScenePresence(avatarId, out avatar)) | 516 | return true; |
591 | { | ||
592 | return true; | ||
593 | } | ||
594 | } | 517 | } |
595 | } | 518 | } |
596 | 519 | ||
@@ -600,15 +523,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
600 | 523 | ||
601 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) | 524 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) |
602 | { | 525 | { |
603 | lock (m_localScenes) | 526 | List<Scene> sceneList = Scenes; |
527 | foreach (Scene scene in sceneList) | ||
604 | { | 528 | { |
605 | foreach (Scene scene in m_localScenes) | 529 | avatar = scene.GetScenePresence(avatarId); |
606 | { | ||
607 | avatar = scene.GetScenePresence(avatarId); | ||
608 | 530 | ||
609 | if (avatar != null && !avatar.IsChildAgent) | 531 | if (avatar != null && !avatar.IsChildAgent) |
610 | return true; | 532 | return true; |
611 | } | ||
612 | } | 533 | } |
613 | 534 | ||
614 | avatar = null; | 535 | avatar = null; |
@@ -618,21 +539,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
618 | public void CloseScene(Scene scene) | 539 | public void CloseScene(Scene scene) |
619 | { | 540 | { |
620 | lock (m_localScenes) | 541 | lock (m_localScenes) |
621 | m_localScenes.Remove(scene); | 542 | m_localScenes.Remove(scene.RegionInfo.RegionID); |
622 | 543 | ||
623 | scene.Close(); | 544 | scene.Close(); |
624 | } | 545 | } |
625 | 546 | ||
626 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 547 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
627 | { | 548 | { |
628 | lock (m_localScenes) | 549 | List<Scene> sceneList = Scenes; |
550 | foreach (Scene scene in sceneList) | ||
629 | { | 551 | { |
630 | foreach (Scene scene in m_localScenes) | 552 | if (scene.TryGetAvatarByName(avatarName, out avatar)) |
631 | { | 553 | { |
632 | if (scene.TryGetAvatarByName(avatarName, out avatar)) | 554 | return true; |
633 | { | ||
634 | return true; | ||
635 | } | ||
636 | } | 555 | } |
637 | } | 556 | } |
638 | 557 | ||
@@ -642,14 +561,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
642 | 561 | ||
643 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) | 562 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) |
644 | { | 563 | { |
645 | lock (m_localScenes) | 564 | List<Scene> sceneList = Scenes; |
565 | foreach (Scene scene in sceneList) | ||
646 | { | 566 | { |
647 | foreach (Scene scene in m_localScenes) | 567 | sp = scene.GetScenePresence(firstName, lastName); |
648 | { | 568 | if (sp != null && !sp.IsChildAgent) |
649 | sp = scene.GetScenePresence(firstName, lastName); | 569 | return true; |
650 | if (sp != null && !sp.IsChildAgent) | ||
651 | return true; | ||
652 | } | ||
653 | } | 570 | } |
654 | 571 | ||
655 | sp = null; | 572 | sp = null; |
@@ -658,8 +575,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
658 | 575 | ||
659 | public void ForEachScene(Action<Scene> action) | 576 | public void ForEachScene(Action<Scene> action) |
660 | { | 577 | { |
661 | lock (m_localScenes) | 578 | List<Scene> sceneList = Scenes; |
662 | m_localScenes.ForEach(action); | 579 | sceneList.ForEach(action); |
663 | } | 580 | } |
664 | } | 581 | } |
665 | } | 582 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index ddf5da0..26524fb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -81,10 +81,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
81 | /// <summary> | 81 | /// <summary> |
82 | /// Stop and remove the scripts contained in all the prims in this group | 82 | /// Stop and remove the scripts contained in all the prims in this group |
83 | /// </summary> | 83 | /// </summary> |
84 | /// <param name="sceneObjectBeingDeleted"> | ||
85 | /// Should be true if these scripts are being removed because the scene | ||
86 | /// object is being deleted. This will prevent spurious updates to the client. | ||
87 | /// </param> | ||
88 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 84 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
89 | { | 85 | { |
90 | SceneObjectPart[] parts = m_parts.GetArray(); | 86 | SceneObjectPart[] parts = m_parts.GetArray(); |
@@ -247,6 +243,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
247 | 243 | ||
248 | public uint GetEffectivePermissions() | 244 | public uint GetEffectivePermissions() |
249 | { | 245 | { |
246 | return GetEffectivePermissions(false); | ||
247 | } | ||
248 | |||
249 | public uint GetEffectivePermissions(bool useBase) | ||
250 | { | ||
250 | uint perms=(uint)(PermissionMask.Modify | | 251 | uint perms=(uint)(PermissionMask.Modify | |
251 | PermissionMask.Copy | | 252 | PermissionMask.Copy | |
252 | PermissionMask.Move | | 253 | PermissionMask.Move | |
@@ -258,7 +259,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
258 | for (int i = 0; i < parts.Length; i++) | 259 | for (int i = 0; i < parts.Length; i++) |
259 | { | 260 | { |
260 | SceneObjectPart part = parts[i]; | 261 | SceneObjectPart part = parts[i]; |
261 | ownerMask &= part.OwnerMask; | 262 | if (useBase) |
263 | ownerMask &= part.BaseMask; | ||
264 | else | ||
265 | ownerMask &= part.OwnerMask; | ||
262 | perms &= part.Inventory.MaskEffectivePermissions(); | 266 | perms &= part.Inventory.MaskEffectivePermissions(); |
263 | } | 267 | } |
264 | 268 | ||
@@ -400,6 +404,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
400 | 404 | ||
401 | public void ResumeScripts() | 405 | public void ResumeScripts() |
402 | { | 406 | { |
407 | if (m_scene.RegionInfo.RegionSettings.DisableScripts) | ||
408 | return; | ||
409 | |||
403 | SceneObjectPart[] parts = m_parts.GetArray(); | 410 | SceneObjectPart[] parts = m_parts.GetArray(); |
404 | for (int i = 0; i < parts.Length; i++) | 411 | for (int i = 0; i < parts.Length; i++) |
405 | parts[i].Inventory.ResumeScripts(); | 412 | parts[i].Inventory.ResumeScripts(); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1fa6a75..74d2629 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; |
@@ -43,6 +44,7 @@ using OpenSim.Region.Framework.Scenes.Serialization; | |||
43 | 44 | ||
44 | namespace OpenSim.Region.Framework.Scenes | 45 | namespace OpenSim.Region.Framework.Scenes |
45 | { | 46 | { |
47 | |||
46 | [Flags] | 48 | [Flags] |
47 | public enum scriptEvents | 49 | public enum scriptEvents |
48 | { | 50 | { |
@@ -106,8 +108,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
106 | /// since the group's last persistent backup | 108 | /// since the group's last persistent backup |
107 | /// </summary> | 109 | /// </summary> |
108 | private bool m_hasGroupChanged = false; | 110 | private bool m_hasGroupChanged = false; |
109 | private long timeFirstChanged; | 111 | private long timeFirstChanged = 0; |
110 | private long timeLastChanged; | 112 | private long timeLastChanged = 0; |
113 | private long m_maxPersistTime = 0; | ||
114 | private long m_minPersistTime = 0; | ||
115 | private Random m_rand; | ||
116 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); | ||
111 | 117 | ||
112 | /// <summary> | 118 | /// <summary> |
113 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage | 119 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage |
@@ -124,9 +130,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
124 | { | 130 | { |
125 | if (value) | 131 | if (value) |
126 | { | 132 | { |
133 | if (m_isBackedUp) | ||
134 | { | ||
135 | m_scene.SceneGraph.FireChangeBackup(this); | ||
136 | } | ||
127 | timeLastChanged = DateTime.Now.Ticks; | 137 | timeLastChanged = DateTime.Now.Ticks; |
128 | if (!m_hasGroupChanged) | 138 | if (!m_hasGroupChanged) |
129 | timeFirstChanged = DateTime.Now.Ticks; | 139 | timeFirstChanged = DateTime.Now.Ticks; |
140 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | ||
141 | { | ||
142 | if (m_rand == null) | ||
143 | { | ||
144 | byte[] val = new byte[16]; | ||
145 | m_rootPart.UUID.ToBytes(val, 0); | ||
146 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
147 | } | ||
148 | |||
149 | if (m_scene.GetRootAgentCount() == 0) | ||
150 | { | ||
151 | //If the region is empty, this change has been made by an automated process | ||
152 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
153 | |||
154 | float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
155 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); | ||
156 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
161 | //but add a random factor so we stagger the object persistance a little | ||
162 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
163 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
164 | } | ||
165 | } | ||
130 | } | 166 | } |
131 | m_hasGroupChanged = value; | 167 | m_hasGroupChanged = value; |
132 | 168 | ||
@@ -141,7 +177,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
141 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since | 177 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since |
142 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. | 178 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. |
143 | /// </summary> | 179 | /// </summary> |
144 | public bool HasGroupChangedDueToDelink { get; private set; } | 180 | public bool HasGroupChangedDueToDelink { get; set; } |
145 | 181 | ||
146 | private bool isTimeToPersist() | 182 | private bool isTimeToPersist() |
147 | { | 183 | { |
@@ -151,8 +187,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
151 | return false; | 187 | return false; |
152 | if (m_scene.ShuttingDown) | 188 | if (m_scene.ShuttingDown) |
153 | return true; | 189 | return true; |
190 | |||
191 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
192 | { | ||
193 | m_maxPersistTime = m_scene.m_persistAfter; | ||
194 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
195 | } | ||
196 | |||
154 | long currentTime = DateTime.Now.Ticks; | 197 | long currentTime = DateTime.Now.Ticks; |
155 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 198 | |
199 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
200 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
201 | |||
202 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
156 | return true; | 203 | return true; |
157 | return false; | 204 | return false; |
158 | } | 205 | } |
@@ -260,6 +307,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
260 | 307 | ||
261 | private bool m_isBackedUp; | 308 | private bool m_isBackedUp; |
262 | 309 | ||
310 | public bool IsBackedUp | ||
311 | { | ||
312 | get { return m_isBackedUp; } | ||
313 | } | ||
314 | |||
263 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); | 315 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); |
264 | 316 | ||
265 | protected ulong m_regionHandle; | 317 | protected ulong m_regionHandle; |
@@ -271,10 +323,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
271 | 323 | ||
272 | private bool m_scriptListens_atTarget; | 324 | private bool m_scriptListens_atTarget; |
273 | private bool m_scriptListens_notAtTarget; | 325 | private bool m_scriptListens_notAtTarget; |
274 | |||
275 | private bool m_scriptListens_atRotTarget; | 326 | private bool m_scriptListens_atRotTarget; |
276 | private bool m_scriptListens_notAtRotTarget; | 327 | private bool m_scriptListens_notAtRotTarget; |
277 | 328 | ||
329 | public bool m_dupeInProgress = false; | ||
278 | internal Dictionary<UUID, string> m_savedScriptState; | 330 | internal Dictionary<UUID, string> m_savedScriptState; |
279 | 331 | ||
280 | #region Properties | 332 | #region Properties |
@@ -311,6 +363,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
311 | get { return m_parts.Count; } | 363 | get { return m_parts.Count; } |
312 | } | 364 | } |
313 | 365 | ||
366 | // protected Quaternion m_rotation = Quaternion.Identity; | ||
367 | // | ||
368 | // public virtual Quaternion Rotation | ||
369 | // { | ||
370 | // get { return m_rotation; } | ||
371 | // set { | ||
372 | // m_rotation = value; | ||
373 | // } | ||
374 | // } | ||
375 | |||
314 | public Quaternion GroupRotation | 376 | public Quaternion GroupRotation |
315 | { | 377 | { |
316 | get { return m_rootPart.RotationOffset; } | 378 | get { return m_rootPart.RotationOffset; } |
@@ -417,7 +479,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
417 | { | 479 | { |
418 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); | 480 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); |
419 | } | 481 | } |
420 | 482 | ||
483 | |||
484 | |||
485 | private struct avtocrossInfo | ||
486 | { | ||
487 | public ScenePresence av; | ||
488 | public uint ParentID; | ||
489 | } | ||
490 | |||
421 | /// <summary> | 491 | /// <summary> |
422 | /// The absolute position of this scene object in the scene | 492 | /// The absolute position of this scene object in the scene |
423 | /// </summary> | 493 | /// </summary> |
@@ -430,14 +500,136 @@ namespace OpenSim.Region.Framework.Scenes | |||
430 | 500 | ||
431 | if (Scene != null) | 501 | if (Scene != null) |
432 | { | 502 | { |
433 | if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) | 503 | // if ((Scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || Scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) |
434 | || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) | 504 | // || Scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || Scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) |
505 | // && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) | ||
506 | if ((Scene.TestBorderCross(val, Cardinals.E) || Scene.TestBorderCross(val, Cardinals.W) | ||
507 | || Scene.TestBorderCross(val, Cardinals.N) || Scene.TestBorderCross(val, Cardinals.S)) | ||
435 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) | 508 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) |
436 | { | 509 | { |
437 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | 510 | IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
511 | uint x = 0; | ||
512 | uint y = 0; | ||
513 | string version = String.Empty; | ||
514 | Vector3 newpos = Vector3.Zero; | ||
515 | OpenSim.Services.Interfaces.GridRegion destination = null; | ||
516 | |||
517 | if (m_rootPart.KeyframeMotion != null) | ||
518 | m_rootPart.KeyframeMotion.StartCrossingCheck(); | ||
519 | |||
520 | bool canCross = true; | ||
521 | foreach (ScenePresence av in m_linkedAvatars) | ||
522 | { | ||
523 | // We need to cross these agents. First, let's find | ||
524 | // out if any of them can't cross for some reason. | ||
525 | // We have to deny the crossing entirely if any | ||
526 | // of them are banned. Alternatively, we could | ||
527 | // unsit banned agents.... | ||
528 | |||
529 | |||
530 | // We set the avatar position as being the object | ||
531 | // position to get the region to send to | ||
532 | if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) | ||
533 | { | ||
534 | canCross = false; | ||
535 | break; | ||
536 | } | ||
537 | |||
538 | m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); | ||
539 | } | ||
540 | |||
541 | if (canCross) | ||
542 | { | ||
543 | // We unparent the SP quietly so that it won't | ||
544 | // be made to stand up | ||
545 | |||
546 | List<avtocrossInfo> avsToCross = new List<avtocrossInfo>(); | ||
547 | |||
548 | foreach (ScenePresence av in m_linkedAvatars) | ||
549 | { | ||
550 | avtocrossInfo avinfo = new avtocrossInfo(); | ||
551 | SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); | ||
552 | if (parentPart != null) | ||
553 | av.ParentUUID = parentPart.UUID; | ||
554 | |||
555 | avinfo.av = av; | ||
556 | avinfo.ParentID = av.ParentID; | ||
557 | avsToCross.Add(avinfo); | ||
558 | |||
559 | av.ParentID = 0; | ||
560 | } | ||
561 | |||
562 | // m_linkedAvatars.Clear(); | ||
563 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | ||
564 | |||
565 | // Normalize | ||
566 | if (val.X >= Constants.RegionSize) | ||
567 | val.X -= Constants.RegionSize; | ||
568 | if (val.Y >= Constants.RegionSize) | ||
569 | val.Y -= Constants.RegionSize; | ||
570 | if (val.X < 0) | ||
571 | val.X += Constants.RegionSize; | ||
572 | if (val.Y < 0) | ||
573 | val.Y += Constants.RegionSize; | ||
574 | |||
575 | // If it's deleted, crossing was successful | ||
576 | if (IsDeleted) | ||
577 | { | ||
578 | // foreach (ScenePresence av in m_linkedAvatars) | ||
579 | foreach (avtocrossInfo avinfo in avsToCross) | ||
580 | { | ||
581 | ScenePresence av = avinfo.av; | ||
582 | if (!av.IsInTransit) // just in case... | ||
583 | { | ||
584 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); | ||
585 | |||
586 | av.IsInTransit = true; | ||
587 | |||
588 | CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; | ||
589 | d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); | ||
590 | } | ||
591 | else | ||
592 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); | ||
593 | } | ||
594 | avsToCross.Clear(); | ||
595 | return; | ||
596 | } | ||
597 | else // cross failed, put avas back ?? | ||
598 | { | ||
599 | foreach (avtocrossInfo avinfo in avsToCross) | ||
600 | { | ||
601 | ScenePresence av = avinfo.av; | ||
602 | av.ParentUUID = UUID.Zero; | ||
603 | av.ParentID = avinfo.ParentID; | ||
604 | // m_linkedAvatars.Add(av); | ||
605 | } | ||
606 | } | ||
607 | avsToCross.Clear(); | ||
608 | |||
609 | } | ||
610 | else | ||
611 | { | ||
612 | if (m_rootPart.KeyframeMotion != null) | ||
613 | m_rootPart.KeyframeMotion.CrossingFailure(); | ||
614 | |||
615 | if (RootPart.PhysActor != null) | ||
616 | { | ||
617 | RootPart.PhysActor.CrossingFailure(); | ||
618 | } | ||
619 | } | ||
620 | Vector3 oldp = AbsolutePosition; | ||
621 | val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
622 | val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
623 | val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f); | ||
438 | } | 624 | } |
439 | } | 625 | } |
440 | 626 | ||
627 | /* don't see the need but worse don't see where is restored to false if things stay in | ||
628 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
629 | { | ||
630 | part.IgnoreUndoUpdate = true; | ||
631 | } | ||
632 | */ | ||
441 | if (RootPart.GetStatusSandbox()) | 633 | if (RootPart.GetStatusSandbox()) |
442 | { | 634 | { |
443 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) | 635 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) |
@@ -455,9 +647,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
455 | // Restuff the new GroupPosition into each SOP of the linkset. | 647 | // Restuff the new GroupPosition into each SOP of the linkset. |
456 | // This has the affect of resetting and tainting the physics actors. | 648 | // This has the affect of resetting and tainting the physics actors. |
457 | SceneObjectPart[] parts = m_parts.GetArray(); | 649 | SceneObjectPart[] parts = m_parts.GetArray(); |
458 | for (int i = 0; i < parts.Length; i++) | 650 | bool triggerScriptEvent = m_rootPart.GroupPosition != val; |
459 | parts[i].GroupPosition = val; | 651 | if (m_dupeInProgress) |
652 | triggerScriptEvent = false; | ||
653 | foreach (SceneObjectPart part in parts) | ||
654 | { | ||
655 | part.GroupPosition = val; | ||
656 | if (triggerScriptEvent) | ||
657 | part.TriggerScriptChangedEvent(Changed.POSITION); | ||
658 | } | ||
460 | 659 | ||
660 | /* | ||
661 | This seems not needed and should not be needed: | ||
662 | sp absolute position depends on sit part absolute position fixed above. | ||
663 | sp ParentPosition is not used anywhere. | ||
664 | Since presence is sitting, viewer considers it 'linked' to root prim, so it will move/rotate it | ||
665 | Sending a extra packet with avatar position is not only bandwidth waste, but may cause jitter in viewers due to UPD nature. | ||
666 | |||
667 | if (!m_dupeInProgress) | ||
668 | { | ||
669 | foreach (ScenePresence av in m_linkedAvatars) | ||
670 | { | ||
671 | SceneObjectPart p = m_scene.GetSceneObjectPart(av.ParentID); | ||
672 | if (p != null && m_parts.TryGetValue(p.UUID, out p)) | ||
673 | { | ||
674 | Vector3 offset = p.GetWorldPosition() - av.ParentPosition; | ||
675 | av.AbsolutePosition += offset; | ||
676 | // av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition | ||
677 | av.SendAvatarDataToAllAgents(); | ||
678 | } | ||
679 | } | ||
680 | } | ||
681 | */ | ||
461 | //if (m_rootPart.PhysActor != null) | 682 | //if (m_rootPart.PhysActor != null) |
462 | //{ | 683 | //{ |
463 | //m_rootPart.PhysActor.Position = | 684 | //m_rootPart.PhysActor.Position = |
@@ -471,6 +692,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
471 | } | 692 | } |
472 | } | 693 | } |
473 | 694 | ||
695 | public override Vector3 Velocity | ||
696 | { | ||
697 | get { return RootPart.Velocity; } | ||
698 | set { RootPart.Velocity = value; } | ||
699 | } | ||
700 | |||
701 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) | ||
702 | { | ||
703 | CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; | ||
704 | ScenePresence agent = icon.EndInvoke(iar); | ||
705 | |||
706 | //// If the cross was successful, this agent is a child agent | ||
707 | if (agent.IsChildAgent) | ||
708 | { | ||
709 | if (agent.ParentUUID != UUID.Zero) | ||
710 | { | ||
711 | agent.ParentPart = null; | ||
712 | // agent.ParentPosition = Vector3.Zero; | ||
713 | // agent.ParentUUID = UUID.Zero; | ||
714 | } | ||
715 | } | ||
716 | |||
717 | agent.ParentUUID = UUID.Zero; | ||
718 | |||
719 | // agent.Reset(); | ||
720 | // else // Not successful | ||
721 | // agent.RestoreInCurrentScene(); | ||
722 | |||
723 | // In any case | ||
724 | agent.IsInTransit = false; | ||
725 | |||
726 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | ||
727 | } | ||
728 | |||
474 | public override uint LocalId | 729 | public override uint LocalId |
475 | { | 730 | { |
476 | get { return m_rootPart.LocalId; } | 731 | get { return m_rootPart.LocalId; } |
@@ -541,6 +796,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
541 | m_isSelected = value; | 796 | m_isSelected = value; |
542 | // Tell physics engine that group is selected | 797 | // Tell physics engine that group is selected |
543 | 798 | ||
799 | // this is not right | ||
800 | // but ode engines should only really need to know about root part | ||
801 | // so they can put entire object simulation on hold and not colliding | ||
802 | // keep as was for now | ||
803 | |||
544 | PhysicsActor pa = m_rootPart.PhysActor; | 804 | PhysicsActor pa = m_rootPart.PhysActor; |
545 | if (pa != null) | 805 | if (pa != null) |
546 | { | 806 | { |
@@ -557,6 +817,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
557 | childPa.Selected = value; | 817 | childPa.Selected = value; |
558 | } | 818 | } |
559 | } | 819 | } |
820 | if (RootPart.KeyframeMotion != null) | ||
821 | RootPart.KeyframeMotion.Selected = value; | ||
822 | } | ||
823 | } | ||
824 | |||
825 | public void PartSelectChanged(bool partSelect) | ||
826 | { | ||
827 | // any part selected makes group selected | ||
828 | if (m_isSelected == partSelect) | ||
829 | return; | ||
830 | |||
831 | if (partSelect) | ||
832 | { | ||
833 | IsSelected = partSelect; | ||
834 | // if (!IsAttachment) | ||
835 | // ScheduleGroupForFullUpdate(); | ||
836 | } | ||
837 | else | ||
838 | { | ||
839 | // bad bad bad 2 heavy for large linksets | ||
840 | // since viewer does send lot of (un)selects | ||
841 | // this needs to be replaced by a specific list or count ? | ||
842 | // but that will require extra code in several places | ||
843 | |||
844 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
845 | for (int i = 0; i < parts.Length; i++) | ||
846 | { | ||
847 | SceneObjectPart part = parts[i]; | ||
848 | if (part.IsSelected) | ||
849 | return; | ||
850 | } | ||
851 | IsSelected = partSelect; | ||
852 | if (!IsAttachment) | ||
853 | { | ||
854 | ScheduleGroupForFullUpdate(); | ||
855 | } | ||
560 | } | 856 | } |
561 | } | 857 | } |
562 | 858 | ||
@@ -642,6 +938,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
642 | /// </summary> | 938 | /// </summary> |
643 | public SceneObjectGroup() | 939 | public SceneObjectGroup() |
644 | { | 940 | { |
941 | |||
645 | } | 942 | } |
646 | 943 | ||
647 | /// <summary> | 944 | /// <summary> |
@@ -659,8 +956,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
659 | /// Constructor. This object is added to the scene later via AttachToScene() | 956 | /// Constructor. This object is added to the scene later via AttachToScene() |
660 | /// </summary> | 957 | /// </summary> |
661 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 958 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
662 | :this(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)) | 959 | { |
663 | { | 960 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
664 | } | 961 | } |
665 | 962 | ||
666 | /// <summary> | 963 | /// <summary> |
@@ -695,6 +992,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
695 | /// </summary> | 992 | /// </summary> |
696 | public virtual void AttachToBackup() | 993 | public virtual void AttachToBackup() |
697 | { | 994 | { |
995 | if (IsAttachment) return; | ||
996 | m_scene.SceneGraph.FireAttachToBackup(this); | ||
997 | |||
698 | if (InSceneBackup) | 998 | if (InSceneBackup) |
699 | { | 999 | { |
700 | //m_log.DebugFormat( | 1000 | //m_log.DebugFormat( |
@@ -737,6 +1037,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
737 | 1037 | ||
738 | ApplyPhysics(); | 1038 | ApplyPhysics(); |
739 | 1039 | ||
1040 | if (RootPart.PhysActor != null) | ||
1041 | RootPart.Force = RootPart.Force; | ||
1042 | if (RootPart.PhysActor != null) | ||
1043 | RootPart.Torque = RootPart.Torque; | ||
1044 | if (RootPart.PhysActor != null) | ||
1045 | RootPart.Buoyancy = RootPart.Buoyancy; | ||
1046 | |||
740 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | 1047 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
741 | // for the same object with very different properties. The caller must schedule the update. | 1048 | // for the same object with very different properties. The caller must schedule the update. |
742 | //ScheduleGroupForFullUpdate(); | 1049 | //ScheduleGroupForFullUpdate(); |
@@ -752,6 +1059,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
752 | EntityIntersection result = new EntityIntersection(); | 1059 | EntityIntersection result = new EntityIntersection(); |
753 | 1060 | ||
754 | SceneObjectPart[] parts = m_parts.GetArray(); | 1061 | SceneObjectPart[] parts = m_parts.GetArray(); |
1062 | |||
1063 | // Find closest hit here | ||
1064 | float idist = float.MaxValue; | ||
1065 | |||
755 | for (int i = 0; i < parts.Length; i++) | 1066 | for (int i = 0; i < parts.Length; i++) |
756 | { | 1067 | { |
757 | SceneObjectPart part = parts[i]; | 1068 | SceneObjectPart part = parts[i]; |
@@ -766,11 +1077,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
766 | 1077 | ||
767 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); | 1078 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); |
768 | 1079 | ||
769 | // This may need to be updated to the maximum draw distance possible.. | ||
770 | // We might (and probably will) be checking for prim creation from other sims | ||
771 | // when the camera crosses the border. | ||
772 | float idist = Constants.RegionSize; | ||
773 | |||
774 | if (inter.HitTF) | 1080 | if (inter.HitTF) |
775 | { | 1081 | { |
776 | // We need to find the closest prim to return to the testcaller along the ray | 1082 | // We need to find the closest prim to return to the testcaller along the ray |
@@ -781,10 +1087,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
781 | result.obj = part; | 1087 | result.obj = part; |
782 | result.normal = inter.normal; | 1088 | result.normal = inter.normal; |
783 | result.distance = inter.distance; | 1089 | result.distance = inter.distance; |
1090 | |||
1091 | idist = inter.distance; | ||
784 | } | 1092 | } |
785 | } | 1093 | } |
786 | } | 1094 | } |
787 | |||
788 | return result; | 1095 | return result; |
789 | } | 1096 | } |
790 | 1097 | ||
@@ -796,25 +1103,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
796 | /// <returns></returns> | 1103 | /// <returns></returns> |
797 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) | 1104 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) |
798 | { | 1105 | { |
799 | maxX = -256f; | 1106 | maxX = float.MinValue; |
800 | maxY = -256f; | 1107 | maxY = float.MinValue; |
801 | maxZ = -256f; | 1108 | maxZ = float.MinValue; |
802 | minX = 256f; | 1109 | minX = float.MaxValue; |
803 | minY = 256f; | 1110 | minY = float.MaxValue; |
804 | minZ = 8192f; | 1111 | minZ = float.MaxValue; |
805 | 1112 | ||
806 | SceneObjectPart[] parts = m_parts.GetArray(); | 1113 | SceneObjectPart[] parts = m_parts.GetArray(); |
807 | for (int i = 0; i < parts.Length; i++) | 1114 | foreach (SceneObjectPart part in parts) |
808 | { | 1115 | { |
809 | SceneObjectPart part = parts[i]; | ||
810 | |||
811 | Vector3 worldPos = part.GetWorldPosition(); | 1116 | Vector3 worldPos = part.GetWorldPosition(); |
812 | Vector3 offset = worldPos - AbsolutePosition; | 1117 | Vector3 offset = worldPos - AbsolutePosition; |
813 | Quaternion worldRot; | 1118 | Quaternion worldRot; |
814 | if (part.ParentID == 0) | 1119 | if (part.ParentID == 0) |
1120 | { | ||
815 | worldRot = part.RotationOffset; | 1121 | worldRot = part.RotationOffset; |
1122 | } | ||
816 | else | 1123 | else |
1124 | { | ||
817 | worldRot = part.GetWorldRotation(); | 1125 | worldRot = part.GetWorldRotation(); |
1126 | } | ||
818 | 1127 | ||
819 | Vector3 frontTopLeft; | 1128 | Vector3 frontTopLeft; |
820 | Vector3 frontTopRight; | 1129 | Vector3 frontTopRight; |
@@ -826,6 +1135,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
826 | Vector3 backBottomLeft; | 1135 | Vector3 backBottomLeft; |
827 | Vector3 backBottomRight; | 1136 | Vector3 backBottomRight; |
828 | 1137 | ||
1138 | // Vector3[] corners = new Vector3[8]; | ||
1139 | |||
829 | Vector3 orig = Vector3.Zero; | 1140 | Vector3 orig = Vector3.Zero; |
830 | 1141 | ||
831 | frontTopLeft.X = orig.X - (part.Scale.X / 2); | 1142 | frontTopLeft.X = orig.X - (part.Scale.X / 2); |
@@ -860,6 +1171,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
860 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); | 1171 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); |
861 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); | 1172 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); |
862 | 1173 | ||
1174 | |||
1175 | |||
1176 | //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1177 | //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1178 | //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1179 | //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1180 | //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1181 | //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1182 | //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1183 | //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1184 | |||
1185 | //for (int i = 0; i < 8; i++) | ||
1186 | //{ | ||
1187 | // corners[i] = corners[i] * worldRot; | ||
1188 | // corners[i] += offset; | ||
1189 | |||
1190 | // if (corners[i].X > maxX) | ||
1191 | // maxX = corners[i].X; | ||
1192 | // if (corners[i].X < minX) | ||
1193 | // minX = corners[i].X; | ||
1194 | |||
1195 | // if (corners[i].Y > maxY) | ||
1196 | // maxY = corners[i].Y; | ||
1197 | // if (corners[i].Y < minY) | ||
1198 | // minY = corners[i].Y; | ||
1199 | |||
1200 | // if (corners[i].Z > maxZ) | ||
1201 | // maxZ = corners[i].Y; | ||
1202 | // if (corners[i].Z < minZ) | ||
1203 | // minZ = corners[i].Z; | ||
1204 | //} | ||
1205 | |||
863 | frontTopLeft = frontTopLeft * worldRot; | 1206 | frontTopLeft = frontTopLeft * worldRot; |
864 | frontTopRight = frontTopRight * worldRot; | 1207 | frontTopRight = frontTopRight * worldRot; |
865 | frontBottomLeft = frontBottomLeft * worldRot; | 1208 | frontBottomLeft = frontBottomLeft * worldRot; |
@@ -881,6 +1224,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
881 | backTopLeft += offset; | 1224 | backTopLeft += offset; |
882 | backTopRight += offset; | 1225 | backTopRight += offset; |
883 | 1226 | ||
1227 | //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1228 | //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1229 | //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1230 | //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1231 | //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1232 | //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1233 | //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1234 | //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1235 | |||
884 | if (frontTopRight.X > maxX) | 1236 | if (frontTopRight.X > maxX) |
885 | maxX = frontTopRight.X; | 1237 | maxX = frontTopRight.X; |
886 | if (frontTopLeft.X > maxX) | 1238 | if (frontTopLeft.X > maxX) |
@@ -1024,17 +1376,118 @@ namespace OpenSim.Region.Framework.Scenes | |||
1024 | 1376 | ||
1025 | #endregion | 1377 | #endregion |
1026 | 1378 | ||
1379 | public void GetResourcesCosts(SceneObjectPart apart, | ||
1380 | out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost) | ||
1381 | { | ||
1382 | // this information may need to be cached | ||
1383 | |||
1384 | float cost; | ||
1385 | float tmpcost; | ||
1386 | |||
1387 | bool ComplexCost = false; | ||
1388 | |||
1389 | SceneObjectPart p; | ||
1390 | SceneObjectPart[] parts; | ||
1391 | |||
1392 | lock (m_parts) | ||
1393 | { | ||
1394 | parts = m_parts.GetArray(); | ||
1395 | } | ||
1396 | |||
1397 | int nparts = parts.Length; | ||
1398 | |||
1399 | |||
1400 | for (int i = 0; i < nparts; i++) | ||
1401 | { | ||
1402 | p = parts[i]; | ||
1403 | |||
1404 | if (p.UsesComplexCost) | ||
1405 | { | ||
1406 | ComplexCost = true; | ||
1407 | break; | ||
1408 | } | ||
1409 | } | ||
1410 | |||
1411 | if (ComplexCost) | ||
1412 | { | ||
1413 | linksetResCost = 0; | ||
1414 | linksetPhysCost = 0; | ||
1415 | partCost = 0; | ||
1416 | partPhysCost = 0; | ||
1417 | |||
1418 | for (int i = 0; i < nparts; i++) | ||
1419 | { | ||
1420 | p = parts[i]; | ||
1421 | |||
1422 | cost = p.StreamingCost; | ||
1423 | tmpcost = p.SimulationCost; | ||
1424 | if (tmpcost > cost) | ||
1425 | cost = tmpcost; | ||
1426 | tmpcost = p.PhysicsCost; | ||
1427 | if (tmpcost > cost) | ||
1428 | cost = tmpcost; | ||
1429 | |||
1430 | linksetPhysCost += tmpcost; | ||
1431 | linksetResCost += cost; | ||
1432 | |||
1433 | if (p == apart) | ||
1434 | { | ||
1435 | partCost = cost; | ||
1436 | partPhysCost = tmpcost; | ||
1437 | } | ||
1438 | } | ||
1439 | } | ||
1440 | else | ||
1441 | { | ||
1442 | partPhysCost = 1.0f; | ||
1443 | partCost = 1.0f; | ||
1444 | linksetResCost = (float)nparts; | ||
1445 | linksetPhysCost = linksetResCost; | ||
1446 | } | ||
1447 | } | ||
1448 | |||
1449 | public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost) | ||
1450 | { | ||
1451 | SceneObjectPart p; | ||
1452 | SceneObjectPart[] parts; | ||
1453 | |||
1454 | lock (m_parts) | ||
1455 | { | ||
1456 | parts = m_parts.GetArray(); | ||
1457 | } | ||
1458 | |||
1459 | int nparts = parts.Length; | ||
1460 | |||
1461 | PhysCost = 0; | ||
1462 | StreamCost = 0; | ||
1463 | SimulCost = 0; | ||
1464 | |||
1465 | for (int i = 0; i < nparts; i++) | ||
1466 | { | ||
1467 | p = parts[i]; | ||
1468 | |||
1469 | StreamCost += p.StreamingCost; | ||
1470 | SimulCost += p.SimulationCost; | ||
1471 | PhysCost += p.PhysicsCost; | ||
1472 | } | ||
1473 | } | ||
1474 | |||
1027 | public void SaveScriptedState(XmlTextWriter writer) | 1475 | public void SaveScriptedState(XmlTextWriter writer) |
1028 | { | 1476 | { |
1477 | SaveScriptedState(writer, false); | ||
1478 | } | ||
1479 | |||
1480 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1481 | { | ||
1029 | XmlDocument doc = new XmlDocument(); | 1482 | XmlDocument doc = new XmlDocument(); |
1030 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1483 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
1031 | 1484 | ||
1032 | SceneObjectPart[] parts = m_parts.GetArray(); | 1485 | SceneObjectPart[] parts = m_parts.GetArray(); |
1033 | for (int i = 0; i < parts.Length; i++) | 1486 | for (int i = 0; i < parts.Length; i++) |
1034 | { | 1487 | { |
1035 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(); | 1488 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(oldIDs); |
1036 | foreach (KeyValuePair<UUID, string> kvp in pstates) | 1489 | foreach (KeyValuePair<UUID, string> kvp in pstates) |
1037 | states.Add(kvp.Key, kvp.Value); | 1490 | states[kvp.Key] = kvp.Value; |
1038 | } | 1491 | } |
1039 | 1492 | ||
1040 | if (states.Count > 0) | 1493 | if (states.Count > 0) |
@@ -1054,6 +1507,169 @@ namespace OpenSim.Region.Framework.Scenes | |||
1054 | } | 1507 | } |
1055 | 1508 | ||
1056 | /// <summary> | 1509 | /// <summary> |
1510 | /// Add the avatar to this linkset (avatar is sat). | ||
1511 | /// </summary> | ||
1512 | /// <param name="agentID"></param> | ||
1513 | public void AddAvatar(UUID agentID) | ||
1514 | { | ||
1515 | ScenePresence presence; | ||
1516 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1517 | { | ||
1518 | if (!m_linkedAvatars.Contains(presence)) | ||
1519 | { | ||
1520 | m_linkedAvatars.Add(presence); | ||
1521 | } | ||
1522 | } | ||
1523 | } | ||
1524 | |||
1525 | /// <summary> | ||
1526 | /// Delete the avatar from this linkset (avatar is unsat). | ||
1527 | /// </summary> | ||
1528 | /// <param name="agentID"></param> | ||
1529 | public void DeleteAvatar(UUID agentID) | ||
1530 | { | ||
1531 | ScenePresence presence; | ||
1532 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1533 | { | ||
1534 | if (m_linkedAvatars.Contains(presence)) | ||
1535 | { | ||
1536 | m_linkedAvatars.Remove(presence); | ||
1537 | } | ||
1538 | } | ||
1539 | } | ||
1540 | |||
1541 | /// <summary> | ||
1542 | /// Returns the list of linked presences (avatars sat on this group) | ||
1543 | /// </summary> | ||
1544 | /// <param name="agentID"></param> | ||
1545 | public List<ScenePresence> GetLinkedAvatars() | ||
1546 | { | ||
1547 | return m_linkedAvatars; | ||
1548 | } | ||
1549 | |||
1550 | /// <summary> | ||
1551 | /// Attach this scene object to the given avatar. | ||
1552 | /// </summary> | ||
1553 | /// <param name="agentID"></param> | ||
1554 | /// <param name="attachmentpoint"></param> | ||
1555 | /// <param name="AttachOffset"></param> | ||
1556 | private void AttachToAgent( | ||
1557 | ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | ||
1558 | { | ||
1559 | if (avatar != null) | ||
1560 | { | ||
1561 | // don't attach attachments to child agents | ||
1562 | if (avatar.IsChildAgent) return; | ||
1563 | |||
1564 | // Remove from database and parcel prim count | ||
1565 | m_scene.DeleteFromStorage(so.UUID); | ||
1566 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1567 | |||
1568 | so.AttachedAvatar = avatar.UUID; | ||
1569 | |||
1570 | if (so.RootPart.PhysActor != null) | ||
1571 | { | ||
1572 | m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); | ||
1573 | so.RootPart.PhysActor = null; | ||
1574 | } | ||
1575 | |||
1576 | so.AbsolutePosition = attachOffset; | ||
1577 | so.RootPart.AttachedPos = attachOffset; | ||
1578 | so.IsAttachment = true; | ||
1579 | so.RootPart.SetParentLocalId(avatar.LocalId); | ||
1580 | so.AttachmentPoint = attachmentpoint; | ||
1581 | |||
1582 | avatar.AddAttachment(this); | ||
1583 | |||
1584 | if (!silent) | ||
1585 | { | ||
1586 | // Killing it here will cause the client to deselect it | ||
1587 | // It then reappears on the avatar, deselected | ||
1588 | // through the full update below | ||
1589 | // | ||
1590 | if (IsSelected) | ||
1591 | { | ||
1592 | m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId }); | ||
1593 | } | ||
1594 | |||
1595 | IsSelected = false; // fudge.... | ||
1596 | ScheduleGroupForFullUpdate(); | ||
1597 | } | ||
1598 | } | ||
1599 | else | ||
1600 | { | ||
1601 | m_log.WarnFormat( | ||
1602 | "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", | ||
1603 | UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName); | ||
1604 | } | ||
1605 | } | ||
1606 | |||
1607 | public byte GetAttachmentPoint() | ||
1608 | { | ||
1609 | return m_rootPart.Shape.State; | ||
1610 | } | ||
1611 | |||
1612 | public void DetachToGround() | ||
1613 | { | ||
1614 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1615 | if (avatar == null) | ||
1616 | return; | ||
1617 | |||
1618 | avatar.RemoveAttachment(this); | ||
1619 | |||
1620 | Vector3 detachedpos = new Vector3(127f,127f,127f); | ||
1621 | if (avatar == null) | ||
1622 | return; | ||
1623 | |||
1624 | detachedpos = avatar.AbsolutePosition; | ||
1625 | FromItemID = UUID.Zero; | ||
1626 | |||
1627 | AbsolutePosition = detachedpos; | ||
1628 | AttachedAvatar = UUID.Zero; | ||
1629 | |||
1630 | //SceneObjectPart[] parts = m_parts.GetArray(); | ||
1631 | //for (int i = 0; i < parts.Length; i++) | ||
1632 | // parts[i].AttachedAvatar = UUID.Zero; | ||
1633 | |||
1634 | m_rootPart.SetParentLocalId(0); | ||
1635 | AttachmentPoint = (byte)0; | ||
1636 | // must check if buildind should be true or false here | ||
1637 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false); | ||
1638 | HasGroupChanged = true; | ||
1639 | RootPart.Rezzed = DateTime.Now; | ||
1640 | RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
1641 | AttachToBackup(); | ||
1642 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1643 | m_rootPart.ScheduleFullUpdate(); | ||
1644 | m_rootPart.ClearUndoState(); | ||
1645 | } | ||
1646 | |||
1647 | public void DetachToInventoryPrep() | ||
1648 | { | ||
1649 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1650 | //Vector3 detachedpos = new Vector3(127f, 127f, 127f); | ||
1651 | if (avatar != null) | ||
1652 | { | ||
1653 | //detachedpos = avatar.AbsolutePosition; | ||
1654 | avatar.RemoveAttachment(this); | ||
1655 | } | ||
1656 | |||
1657 | AttachedAvatar = UUID.Zero; | ||
1658 | |||
1659 | /*SceneObjectPart[] parts = m_parts.GetArray(); | ||
1660 | for (int i = 0; i < parts.Length; i++) | ||
1661 | parts[i].AttachedAvatar = UUID.Zero;*/ | ||
1662 | |||
1663 | m_rootPart.SetParentLocalId(0); | ||
1664 | //m_rootPart.SetAttachmentPoint((byte)0); | ||
1665 | IsAttachment = false; | ||
1666 | AbsolutePosition = m_rootPart.AttachedPos; | ||
1667 | //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); | ||
1668 | //AttachToBackup(); | ||
1669 | //m_rootPart.ScheduleFullUpdate(); | ||
1670 | } | ||
1671 | |||
1672 | /// <summary> | ||
1057 | /// | 1673 | /// |
1058 | /// </summary> | 1674 | /// </summary> |
1059 | /// <param name="part"></param> | 1675 | /// <param name="part"></param> |
@@ -1093,7 +1709,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1093 | public void AddPart(SceneObjectPart part) | 1709 | public void AddPart(SceneObjectPart part) |
1094 | { | 1710 | { |
1095 | part.SetParent(this); | 1711 | part.SetParent(this); |
1096 | part.LinkNum = m_parts.Add(part.UUID, part); | 1712 | m_parts.Add(part.UUID, part); |
1713 | |||
1714 | part.LinkNum = m_parts.Count; | ||
1715 | |||
1097 | if (part.LinkNum == 2) | 1716 | if (part.LinkNum == 2) |
1098 | RootPart.LinkNum = 1; | 1717 | RootPart.LinkNum = 1; |
1099 | } | 1718 | } |
@@ -1119,6 +1738,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1119 | parts[i].UUID = UUID.Random(); | 1738 | parts[i].UUID = UUID.Random(); |
1120 | } | 1739 | } |
1121 | 1740 | ||
1741 | // helper provided for parts. | ||
1742 | public int GetSceneMaxUndo() | ||
1743 | { | ||
1744 | if (m_scene != null) | ||
1745 | return m_scene.MaxUndoCount; | ||
1746 | return 5; | ||
1747 | } | ||
1748 | |||
1122 | // justincc: I don't believe this hack is needed any longer, especially since the physics | 1749 | // justincc: I don't believe this hack is needed any longer, especially since the physics |
1123 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false | 1750 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false |
1124 | // this method was preventing proper reload of scene objects. | 1751 | // this method was preventing proper reload of scene objects. |
@@ -1176,7 +1803,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1176 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", | 1803 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", |
1177 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); | 1804 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); |
1178 | 1805 | ||
1179 | part.StoreUndoState(); | 1806 | // part.StoreUndoState(); |
1180 | part.OnGrab(offsetPos, remoteClient); | 1807 | part.OnGrab(offsetPos, remoteClient); |
1181 | } | 1808 | } |
1182 | 1809 | ||
@@ -1196,6 +1823,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1196 | /// <param name="silent">If true then deletion is not broadcast to clients</param> | 1823 | /// <param name="silent">If true then deletion is not broadcast to clients</param> |
1197 | public void DeleteGroupFromScene(bool silent) | 1824 | public void DeleteGroupFromScene(bool silent) |
1198 | { | 1825 | { |
1826 | // We need to keep track of this state in case this group is still queued for backup. | ||
1827 | IsDeleted = true; | ||
1828 | |||
1829 | DetachFromBackup(); | ||
1830 | |||
1199 | SceneObjectPart[] parts = m_parts.GetArray(); | 1831 | SceneObjectPart[] parts = m_parts.GetArray(); |
1200 | for (int i = 0; i < parts.Length; i++) | 1832 | for (int i = 0; i < parts.Length; i++) |
1201 | { | 1833 | { |
@@ -1219,6 +1851,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1219 | } | 1851 | } |
1220 | }); | 1852 | }); |
1221 | } | 1853 | } |
1854 | |||
1222 | } | 1855 | } |
1223 | 1856 | ||
1224 | public void AddScriptLPS(int count) | 1857 | public void AddScriptLPS(int count) |
@@ -1288,28 +1921,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1288 | /// </summary> | 1921 | /// </summary> |
1289 | public void ApplyPhysics() | 1922 | public void ApplyPhysics() |
1290 | { | 1923 | { |
1291 | // Apply physics to the root prim | ||
1292 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); | ||
1293 | |||
1294 | // Apply physics to child prims | ||
1295 | SceneObjectPart[] parts = m_parts.GetArray(); | 1924 | SceneObjectPart[] parts = m_parts.GetArray(); |
1296 | if (parts.Length > 1) | 1925 | if (parts.Length > 1) |
1297 | { | 1926 | { |
1927 | ResetChildPrimPhysicsPositions(); | ||
1928 | |||
1929 | // Apply physics to the root prim | ||
1930 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true); | ||
1931 | |||
1932 | |||
1298 | for (int i = 0; i < parts.Length; i++) | 1933 | for (int i = 0; i < parts.Length; i++) |
1299 | { | 1934 | { |
1300 | SceneObjectPart part = parts[i]; | 1935 | SceneObjectPart part = parts[i]; |
1301 | if (part.LocalId != m_rootPart.LocalId) | 1936 | if (part.LocalId != m_rootPart.LocalId) |
1302 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); | 1937 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, true); |
1303 | } | 1938 | } |
1304 | |||
1305 | // Hack to get the physics scene geometries in the right spot | 1939 | // Hack to get the physics scene geometries in the right spot |
1306 | ResetChildPrimPhysicsPositions(); | 1940 | // ResetChildPrimPhysicsPositions(); |
1941 | if (m_rootPart.PhysActor != null) | ||
1942 | { | ||
1943 | m_rootPart.PhysActor.Building = false; | ||
1944 | } | ||
1945 | } | ||
1946 | else | ||
1947 | { | ||
1948 | // Apply physics to the root prim | ||
1949 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); | ||
1307 | } | 1950 | } |
1308 | } | 1951 | } |
1309 | 1952 | ||
1310 | public void SetOwnerId(UUID userId) | 1953 | public void SetOwnerId(UUID userId) |
1311 | { | 1954 | { |
1312 | ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); | 1955 | ForEachPart(delegate(SceneObjectPart part) |
1956 | { | ||
1957 | |||
1958 | part.OwnerID = userId; | ||
1959 | |||
1960 | }); | ||
1313 | } | 1961 | } |
1314 | 1962 | ||
1315 | public void ForEachPart(Action<SceneObjectPart> whatToDo) | 1963 | public void ForEachPart(Action<SceneObjectPart> whatToDo) |
@@ -1341,11 +1989,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1341 | return; | 1989 | return; |
1342 | } | 1990 | } |
1343 | 1991 | ||
1992 | if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | ||
1993 | return; | ||
1994 | |||
1344 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let | 1995 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let |
1345 | // any exception propogate upwards. | 1996 | // any exception propogate upwards. |
1346 | try | 1997 | try |
1347 | { | 1998 | { |
1348 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart | 1999 | if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart |
2000 | !m_scene.LoginsEnabled || // We're starting up or doing maintenance, don't mess with things | ||
2001 | m_scene.LoadingPrims) // Land may not be valid yet | ||
2002 | |||
1349 | { | 2003 | { |
1350 | ILandObject parcel = m_scene.LandChannel.GetLandObject( | 2004 | ILandObject parcel = m_scene.LandChannel.GetLandObject( |
1351 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); | 2005 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); |
@@ -1372,6 +2026,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1372 | } | 2026 | } |
1373 | } | 2027 | } |
1374 | } | 2028 | } |
2029 | |||
1375 | } | 2030 | } |
1376 | 2031 | ||
1377 | if (m_scene.UseBackup && HasGroupChanged) | 2032 | if (m_scene.UseBackup && HasGroupChanged) |
@@ -1379,10 +2034,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1379 | // don't backup while it's selected or you're asking for changes mid stream. | 2034 | // don't backup while it's selected or you're asking for changes mid stream. |
1380 | if (isTimeToPersist() || forcedBackup) | 2035 | if (isTimeToPersist() || forcedBackup) |
1381 | { | 2036 | { |
2037 | if (m_rootPart.PhysActor != null && | ||
2038 | (!m_rootPart.PhysActor.IsPhysical)) | ||
2039 | { | ||
2040 | // Possible ghost prim | ||
2041 | if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) | ||
2042 | { | ||
2043 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
2044 | { | ||
2045 | // Re-set physics actor positions and | ||
2046 | // orientations | ||
2047 | part.GroupPosition = m_rootPart.GroupPosition; | ||
2048 | } | ||
2049 | } | ||
2050 | } | ||
1382 | // m_log.DebugFormat( | 2051 | // m_log.DebugFormat( |
1383 | // "[SCENE]: Storing {0}, {1} in {2}", | 2052 | // "[SCENE]: Storing {0}, {1} in {2}", |
1384 | // Name, UUID, m_scene.RegionInfo.RegionName); | 2053 | // Name, UUID, m_scene.RegionInfo.RegionName); |
1385 | 2054 | ||
2055 | if (RootPart.Shape.PCode == 9 && RootPart.Shape.State != 0) | ||
2056 | { | ||
2057 | RootPart.Shape.State = 0; | ||
2058 | ScheduleGroupForFullUpdate(); | ||
2059 | } | ||
2060 | |||
1386 | SceneObjectGroup backup_group = Copy(false); | 2061 | SceneObjectGroup backup_group = Copy(false); |
1387 | backup_group.RootPart.Velocity = RootPart.Velocity; | 2062 | backup_group.RootPart.Velocity = RootPart.Velocity; |
1388 | backup_group.RootPart.Acceleration = RootPart.Acceleration; | 2063 | backup_group.RootPart.Acceleration = RootPart.Acceleration; |
@@ -1392,6 +2067,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1392 | HasGroupChangedDueToDelink = false; | 2067 | HasGroupChangedDueToDelink = false; |
1393 | 2068 | ||
1394 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); | 2069 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); |
2070 | /* | ||
2071 | backup_group.ForEachPart(delegate(SceneObjectPart part) | ||
2072 | { | ||
2073 | if (part.KeyframeMotion != null) | ||
2074 | { | ||
2075 | part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); | ||
2076 | // part.KeyframeMotion.UpdateSceneObject(this); | ||
2077 | } | ||
2078 | }); | ||
2079 | */ | ||
1395 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); | 2080 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); |
1396 | 2081 | ||
1397 | backup_group.ForEachPart(delegate(SceneObjectPart part) | 2082 | backup_group.ForEachPart(delegate(SceneObjectPart part) |
@@ -1448,10 +2133,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1448 | /// <returns></returns> | 2133 | /// <returns></returns> |
1449 | public SceneObjectGroup Copy(bool userExposed) | 2134 | public SceneObjectGroup Copy(bool userExposed) |
1450 | { | 2135 | { |
2136 | m_dupeInProgress = true; | ||
1451 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); | 2137 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); |
1452 | dupe.m_isBackedUp = false; | 2138 | dupe.m_isBackedUp = false; |
1453 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); | 2139 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); |
1454 | 2140 | ||
2141 | // new group as no sitting avatars | ||
2142 | dupe.m_linkedAvatars = new List<ScenePresence>(); | ||
2143 | |||
1455 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of | 2144 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of |
1456 | // attachments do not bordercross while they're being duplicated. This is hacktastic! | 2145 | // attachments do not bordercross while they're being duplicated. This is hacktastic! |
1457 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! | 2146 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! |
@@ -1462,7 +2151,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1462 | // This is only necessary when userExposed is false! | 2151 | // This is only necessary when userExposed is false! |
1463 | 2152 | ||
1464 | bool previousAttachmentStatus = dupe.IsAttachment; | 2153 | bool previousAttachmentStatus = dupe.IsAttachment; |
1465 | 2154 | ||
1466 | if (!userExposed) | 2155 | if (!userExposed) |
1467 | dupe.IsAttachment = true; | 2156 | dupe.IsAttachment = true; |
1468 | 2157 | ||
@@ -1475,16 +2164,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1475 | 2164 | ||
1476 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); | 2165 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); |
1477 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; | 2166 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; |
2167 | |||
1478 | 2168 | ||
1479 | if (userExposed) | 2169 | if (userExposed) |
1480 | dupe.m_rootPart.TrimPermissions(); | 2170 | dupe.m_rootPart.TrimPermissions(); |
1481 | 2171 | ||
1482 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); | 2172 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); |
1483 | 2173 | ||
1484 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | 2174 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) |
1485 | { | 2175 | { |
1486 | return p1.LinkNum.CompareTo(p2.LinkNum); | 2176 | return p1.LinkNum.CompareTo(p2.LinkNum); |
1487 | } | 2177 | } |
1488 | ); | 2178 | ); |
1489 | 2179 | ||
1490 | foreach (SceneObjectPart part in partList) | 2180 | foreach (SceneObjectPart part in partList) |
@@ -1494,41 +2184,56 @@ namespace OpenSim.Region.Framework.Scenes | |||
1494 | { | 2184 | { |
1495 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); | 2185 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); |
1496 | newPart.LinkNum = part.LinkNum; | 2186 | newPart.LinkNum = part.LinkNum; |
1497 | } | 2187 | if (userExposed) |
2188 | newPart.ParentID = dupe.m_rootPart.LocalId; | ||
2189 | } | ||
1498 | else | 2190 | else |
1499 | { | 2191 | { |
1500 | newPart = dupe.m_rootPart; | 2192 | newPart = dupe.m_rootPart; |
1501 | } | 2193 | } |
2194 | /* | ||
2195 | bool isphys = ((newPart.Flags & PrimFlags.Physics) != 0); | ||
2196 | bool isphan = ((newPart.Flags & PrimFlags.Phantom) != 0); | ||
1502 | 2197 | ||
1503 | // Need to duplicate the physics actor as well | 2198 | // Need to duplicate the physics actor as well |
1504 | PhysicsActor originalPartPa = part.PhysActor; | 2199 | if (userExposed && (isphys || !isphan || newPart.VolumeDetectActive)) |
1505 | if (originalPartPa != null && userExposed) | ||
1506 | { | 2200 | { |
1507 | PrimitiveBaseShape pbs = newPart.Shape; | 2201 | PrimitiveBaseShape pbs = newPart.Shape; |
1508 | |||
1509 | newPart.PhysActor | 2202 | newPart.PhysActor |
1510 | = m_scene.PhysicsScene.AddPrimShape( | 2203 | = m_scene.PhysicsScene.AddPrimShape( |
1511 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), | 2204 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), |
1512 | pbs, | 2205 | pbs, |
1513 | newPart.AbsolutePosition, | 2206 | newPart.AbsolutePosition, |
1514 | newPart.Scale, | 2207 | newPart.Scale, |
1515 | newPart.RotationOffset, | 2208 | newPart.GetWorldRotation(), |
1516 | originalPartPa.IsPhysical, | 2209 | isphys, |
2210 | isphan, | ||
1517 | newPart.LocalId); | 2211 | newPart.LocalId); |
1518 | 2212 | ||
1519 | newPart.DoPhysicsPropertyUpdate(originalPartPa.IsPhysical, true); | 2213 | newPart.DoPhysicsPropertyUpdate(isphys, true); |
1520 | } | 2214 | */ |
2215 | if (userExposed) | ||
2216 | newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true); | ||
2217 | // } | ||
2218 | // copy keyframemotion | ||
2219 | if (part.KeyframeMotion != null) | ||
2220 | newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); | ||
1521 | } | 2221 | } |
1522 | 2222 | ||
1523 | if (userExposed) | 2223 | if (userExposed) |
1524 | { | 2224 | { |
1525 | dupe.UpdateParentIDs(); | 2225 | // done above dupe.UpdateParentIDs(); |
2226 | |||
2227 | if (dupe.m_rootPart.PhysActor != null) | ||
2228 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building | ||
2229 | |||
1526 | dupe.HasGroupChanged = true; | 2230 | dupe.HasGroupChanged = true; |
1527 | dupe.AttachToBackup(); | 2231 | dupe.AttachToBackup(); |
1528 | 2232 | ||
1529 | ScheduleGroupForFullUpdate(); | 2233 | ScheduleGroupForFullUpdate(); |
1530 | } | 2234 | } |
1531 | 2235 | ||
2236 | m_dupeInProgress = false; | ||
1532 | return dupe; | 2237 | return dupe; |
1533 | } | 2238 | } |
1534 | 2239 | ||
@@ -1540,11 +2245,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1540 | /// <param name="cGroupID"></param> | 2245 | /// <param name="cGroupID"></param> |
1541 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2246 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1542 | { | 2247 | { |
1543 | SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); | 2248 | // SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); |
2249 | // give newpart a new local ID lettng old part keep same | ||
2250 | SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed); | ||
2251 | newpart.LocalId = m_scene.AllocateLocalId(); | ||
2252 | |||
2253 | SetRootPart(newpart); | ||
2254 | if (userExposed) | ||
2255 | RootPart.Velocity = Vector3.Zero; // In case source is moving | ||
1544 | } | 2256 | } |
1545 | 2257 | ||
1546 | public void ScriptSetPhysicsStatus(bool usePhysics) | 2258 | public void ScriptSetPhysicsStatus(bool usePhysics) |
1547 | { | 2259 | { |
2260 | if (usePhysics) | ||
2261 | { | ||
2262 | if (RootPart.KeyframeMotion != null) | ||
2263 | RootPart.KeyframeMotion.Stop(); | ||
2264 | RootPart.KeyframeMotion = null; | ||
2265 | } | ||
1548 | UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 2266 | UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); |
1549 | } | 2267 | } |
1550 | 2268 | ||
@@ -1592,13 +2310,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1592 | 2310 | ||
1593 | if (pa != null) | 2311 | if (pa != null) |
1594 | { | 2312 | { |
1595 | pa.AddForce(impulse, true); | 2313 | // false to be applied as a impulse |
2314 | pa.AddForce(impulse, false); | ||
1596 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2315 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1597 | } | 2316 | } |
1598 | } | 2317 | } |
1599 | } | 2318 | } |
1600 | 2319 | ||
1601 | public void applyAngularImpulse(Vector3 impulse) | 2320 | public void ApplyAngularImpulse(Vector3 impulse) |
1602 | { | 2321 | { |
1603 | PhysicsActor pa = RootPart.PhysActor; | 2322 | PhysicsActor pa = RootPart.PhysActor; |
1604 | 2323 | ||
@@ -1606,21 +2325,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1606 | { | 2325 | { |
1607 | if (!IsAttachment) | 2326 | if (!IsAttachment) |
1608 | { | 2327 | { |
1609 | pa.AddAngularForce(impulse, true); | 2328 | // false to be applied as a impulse |
1610 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2329 | pa.AddAngularForce(impulse, false); |
1611 | } | ||
1612 | } | ||
1613 | } | ||
1614 | |||
1615 | public void setAngularImpulse(Vector3 impulse) | ||
1616 | { | ||
1617 | PhysicsActor pa = RootPart.PhysActor; | ||
1618 | |||
1619 | if (pa != null) | ||
1620 | { | ||
1621 | if (!IsAttachment) | ||
1622 | { | ||
1623 | pa.Torque = impulse; | ||
1624 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2330 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1625 | } | 2331 | } |
1626 | } | 2332 | } |
@@ -1628,20 +2334,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1628 | 2334 | ||
1629 | public Vector3 GetTorque() | 2335 | public Vector3 GetTorque() |
1630 | { | 2336 | { |
1631 | PhysicsActor pa = RootPart.PhysActor; | 2337 | return RootPart.Torque; |
1632 | |||
1633 | if (pa != null) | ||
1634 | { | ||
1635 | if (!IsAttachment) | ||
1636 | { | ||
1637 | Vector3 torque = pa.Torque; | ||
1638 | return torque; | ||
1639 | } | ||
1640 | } | ||
1641 | |||
1642 | return Vector3.Zero; | ||
1643 | } | 2338 | } |
1644 | 2339 | ||
2340 | // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object | ||
1645 | public void moveToTarget(Vector3 target, float tau) | 2341 | public void moveToTarget(Vector3 target, float tau) |
1646 | { | 2342 | { |
1647 | if (IsAttachment) | 2343 | if (IsAttachment) |
@@ -1673,6 +2369,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
1673 | pa.PIDActive = false; | 2369 | pa.PIDActive = false; |
1674 | } | 2370 | } |
1675 | 2371 | ||
2372 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2373 | { | ||
2374 | SceneObjectPart rootpart = m_rootPart; | ||
2375 | if (rootpart != null) | ||
2376 | { | ||
2377 | if (IsAttachment) | ||
2378 | { | ||
2379 | /* | ||
2380 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
2381 | if (avatar != null) | ||
2382 | { | ||
2383 | Rotate the Av? | ||
2384 | } */ | ||
2385 | } | ||
2386 | else | ||
2387 | { | ||
2388 | if (rootpart.PhysActor != null) | ||
2389 | { // APID must be implemented in your physics system for this to function. | ||
2390 | rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); | ||
2391 | rootpart.PhysActor.APIDStrength = strength; | ||
2392 | rootpart.PhysActor.APIDDamping = damping; | ||
2393 | rootpart.PhysActor.APIDActive = true; | ||
2394 | } | ||
2395 | } | ||
2396 | } | ||
2397 | } | ||
2398 | |||
2399 | public void stopLookAt() | ||
2400 | { | ||
2401 | SceneObjectPart rootpart = m_rootPart; | ||
2402 | if (rootpart != null) | ||
2403 | { | ||
2404 | if (rootpart.PhysActor != null) | ||
2405 | { // APID must be implemented in your physics system for this to function. | ||
2406 | rootpart.PhysActor.APIDActive = false; | ||
2407 | } | ||
2408 | } | ||
2409 | |||
2410 | } | ||
2411 | |||
1676 | /// <summary> | 2412 | /// <summary> |
1677 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. | 2413 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. |
1678 | /// </summary> | 2414 | /// </summary> |
@@ -1689,7 +2425,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1689 | { | 2425 | { |
1690 | pa.PIDHoverHeight = height; | 2426 | pa.PIDHoverHeight = height; |
1691 | pa.PIDHoverType = hoverType; | 2427 | pa.PIDHoverType = hoverType; |
1692 | pa.PIDTau = tau; | 2428 | pa.PIDHoverTau = tau; |
1693 | pa.PIDHoverActive = true; | 2429 | pa.PIDHoverActive = true; |
1694 | } | 2430 | } |
1695 | else | 2431 | else |
@@ -1729,7 +2465,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1729 | /// <param name="cGroupID"></param> | 2465 | /// <param name="cGroupID"></param> |
1730 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2466 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1731 | { | 2467 | { |
1732 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | 2468 | // give new ID to the new part, letting old keep original |
2469 | // SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | ||
2470 | SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); | ||
2471 | newPart.LocalId = m_scene.AllocateLocalId(); | ||
2472 | newPart.SetParent(this); | ||
2473 | |||
1733 | AddPart(newPart); | 2474 | AddPart(newPart); |
1734 | 2475 | ||
1735 | SetPartAsNonRoot(newPart); | 2476 | SetPartAsNonRoot(newPart); |
@@ -1868,11 +2609,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1868 | /// Immediately send a full update for this scene object. | 2609 | /// Immediately send a full update for this scene object. |
1869 | /// </summary> | 2610 | /// </summary> |
1870 | public void SendGroupFullUpdate() | 2611 | public void SendGroupFullUpdate() |
1871 | { | 2612 | { |
1872 | if (IsDeleted) | 2613 | if (IsDeleted) |
1873 | return; | 2614 | return; |
1874 | 2615 | ||
1875 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); | 2616 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); |
1876 | 2617 | ||
1877 | RootPart.SendFullUpdateToAllClients(); | 2618 | RootPart.SendFullUpdateToAllClients(); |
1878 | 2619 | ||
@@ -2028,6 +2769,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2028 | // 'linkPart' == the root of the group being linked into this group | 2769 | // 'linkPart' == the root of the group being linked into this group |
2029 | SceneObjectPart linkPart = objectGroup.m_rootPart; | 2770 | SceneObjectPart linkPart = objectGroup.m_rootPart; |
2030 | 2771 | ||
2772 | if (m_rootPart.PhysActor != null) | ||
2773 | m_rootPart.PhysActor.Building = true; | ||
2774 | if (linkPart.PhysActor != null) | ||
2775 | linkPart.PhysActor.Building = true; | ||
2776 | |||
2031 | // physics flags from group to be applied to linked parts | 2777 | // physics flags from group to be applied to linked parts |
2032 | bool grpusephys = UsesPhysics; | 2778 | bool grpusephys = UsesPhysics; |
2033 | bool grptemporary = IsTemporary; | 2779 | bool grptemporary = IsTemporary; |
@@ -2053,12 +2799,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2053 | Vector3 axPos = linkPart.OffsetPosition; | 2799 | Vector3 axPos = linkPart.OffsetPosition; |
2054 | // Rotate the linking root SOP's position to be relative to the new root prim | 2800 | // Rotate the linking root SOP's position to be relative to the new root prim |
2055 | Quaternion parentRot = m_rootPart.RotationOffset; | 2801 | Quaternion parentRot = m_rootPart.RotationOffset; |
2056 | axPos *= Quaternion.Inverse(parentRot); | 2802 | axPos *= Quaternion.Conjugate(parentRot); |
2057 | linkPart.OffsetPosition = axPos; | 2803 | linkPart.OffsetPosition = axPos; |
2058 | 2804 | ||
2059 | // Make the linking root SOP's rotation relative to the new root prim | 2805 | // Make the linking root SOP's rotation relative to the new root prim |
2060 | Quaternion oldRot = linkPart.RotationOffset; | 2806 | Quaternion oldRot = linkPart.RotationOffset; |
2061 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 2807 | Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; |
2062 | linkPart.RotationOffset = newRot; | 2808 | linkPart.RotationOffset = newRot; |
2063 | 2809 | ||
2064 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. | 2810 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. |
@@ -2092,7 +2838,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2092 | linkPart.CreateSelected = true; | 2838 | linkPart.CreateSelected = true; |
2093 | 2839 | ||
2094 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now | 2840 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now |
2095 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive); | 2841 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); |
2096 | 2842 | ||
2097 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 2843 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2098 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2844 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2102,6 +2848,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2102 | } | 2848 | } |
2103 | 2849 | ||
2104 | linkPart.LinkNum = linkNum++; | 2850 | linkPart.LinkNum = linkNum++; |
2851 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2105 | 2852 | ||
2106 | // Get a list of the SOP's in the old group in order of their linknum's. | 2853 | // Get a list of the SOP's in the old group in order of their linknum's. |
2107 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2854 | SceneObjectPart[] ogParts = objectGroup.Parts; |
@@ -2120,7 +2867,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2120 | 2867 | ||
2121 | // Update the physics flags for the newly added SOP | 2868 | // Update the physics flags for the newly added SOP |
2122 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) | 2869 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) |
2123 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive); | 2870 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); |
2124 | 2871 | ||
2125 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 2872 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2126 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2873 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2138,7 +2885,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2138 | objectGroup.IsDeleted = true; | 2885 | objectGroup.IsDeleted = true; |
2139 | 2886 | ||
2140 | objectGroup.m_parts.Clear(); | 2887 | objectGroup.m_parts.Clear(); |
2141 | 2888 | ||
2142 | // Can't do this yet since backup still makes use of the root part without any synchronization | 2889 | // Can't do this yet since backup still makes use of the root part without any synchronization |
2143 | // objectGroup.m_rootPart = null; | 2890 | // objectGroup.m_rootPart = null; |
2144 | 2891 | ||
@@ -2152,6 +2899,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2152 | // unmoved prims! | 2899 | // unmoved prims! |
2153 | ResetChildPrimPhysicsPositions(); | 2900 | ResetChildPrimPhysicsPositions(); |
2154 | 2901 | ||
2902 | if (m_rootPart.PhysActor != null) | ||
2903 | m_rootPart.PhysActor.Building = false; | ||
2904 | |||
2155 | //HasGroupChanged = true; | 2905 | //HasGroupChanged = true; |
2156 | //ScheduleGroupForFullUpdate(); | 2906 | //ScheduleGroupForFullUpdate(); |
2157 | } | 2907 | } |
@@ -2219,7 +2969,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2219 | // m_log.DebugFormat( | 2969 | // m_log.DebugFormat( |
2220 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", | 2970 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", |
2221 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); | 2971 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); |
2222 | 2972 | ||
2973 | if (m_rootPart.PhysActor != null) | ||
2974 | m_rootPart.PhysActor.Building = true; | ||
2975 | |||
2223 | linkPart.ClearUndoState(); | 2976 | linkPart.ClearUndoState(); |
2224 | 2977 | ||
2225 | Vector3 worldPos = linkPart.GetWorldPosition(); | 2978 | Vector3 worldPos = linkPart.GetWorldPosition(); |
@@ -2290,6 +3043,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2290 | 3043 | ||
2291 | // When we delete a group, we currently have to force persist to the database if the object id has changed | 3044 | // When we delete a group, we currently have to force persist to the database if the object id has changed |
2292 | // (since delete works by deleting all rows which have a given object id) | 3045 | // (since delete works by deleting all rows which have a given object id) |
3046 | |||
3047 | // this is as it seems to be in sl now | ||
3048 | if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none) | ||
3049 | linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now | ||
3050 | |||
3051 | if (m_rootPart.PhysActor != null) | ||
3052 | m_rootPart.PhysActor.Building = false; | ||
3053 | |||
2293 | objectGroup.HasGroupChangedDueToDelink = true; | 3054 | objectGroup.HasGroupChangedDueToDelink = true; |
2294 | 3055 | ||
2295 | return objectGroup; | 3056 | return objectGroup; |
@@ -2301,6 +3062,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2301 | /// <param name="objectGroup"></param> | 3062 | /// <param name="objectGroup"></param> |
2302 | public virtual void DetachFromBackup() | 3063 | public virtual void DetachFromBackup() |
2303 | { | 3064 | { |
3065 | if (m_scene != null) | ||
3066 | m_scene.SceneGraph.FireDetachFromBackup(this); | ||
2304 | if (m_isBackedUp && Scene != null) | 3067 | if (m_isBackedUp && Scene != null) |
2305 | m_scene.EventManager.OnBackup -= ProcessBackup; | 3068 | m_scene.EventManager.OnBackup -= ProcessBackup; |
2306 | 3069 | ||
@@ -2321,7 +3084,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2321 | Vector3 axPos = part.OffsetPosition; | 3084 | Vector3 axPos = part.OffsetPosition; |
2322 | axPos *= parentRot; | 3085 | axPos *= parentRot; |
2323 | part.OffsetPosition = axPos; | 3086 | part.OffsetPosition = axPos; |
2324 | part.GroupPosition = oldGroupPosition + part.OffsetPosition; | 3087 | Vector3 newPos = oldGroupPosition + part.OffsetPosition; |
3088 | part.GroupPosition = newPos; | ||
2325 | part.OffsetPosition = Vector3.Zero; | 3089 | part.OffsetPosition = Vector3.Zero; |
2326 | 3090 | ||
2327 | // Compution our rotation to be not relative to the old parent | 3091 | // Compution our rotation to be not relative to the old parent |
@@ -2336,7 +3100,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2336 | part.LinkNum = linkNum; | 3100 | part.LinkNum = linkNum; |
2337 | 3101 | ||
2338 | // Compute the new position of this SOP relative to the group position | 3102 | // Compute the new position of this SOP relative to the group position |
2339 | part.OffsetPosition = part.GroupPosition - AbsolutePosition; | 3103 | part.OffsetPosition = newPos - AbsolutePosition; |
2340 | 3104 | ||
2341 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. | 3105 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. |
2342 | // It would have the affect of setting the physics engine position multiple | 3106 | // It would have the affect of setting the physics engine position multiple |
@@ -2346,18 +3110,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2346 | // Rotate the relative position by the rotation of the group | 3110 | // Rotate the relative position by the rotation of the group |
2347 | Quaternion rootRotation = m_rootPart.RotationOffset; | 3111 | Quaternion rootRotation = m_rootPart.RotationOffset; |
2348 | Vector3 pos = part.OffsetPosition; | 3112 | Vector3 pos = part.OffsetPosition; |
2349 | pos *= Quaternion.Inverse(rootRotation); | 3113 | pos *= Quaternion.Conjugate(rootRotation); |
2350 | part.OffsetPosition = pos; | 3114 | part.OffsetPosition = pos; |
2351 | 3115 | ||
2352 | // Compute the SOP's rotation relative to the rotation of the group. | 3116 | // Compute the SOP's rotation relative to the rotation of the group. |
2353 | parentRot = m_rootPart.RotationOffset; | 3117 | parentRot = m_rootPart.RotationOffset; |
2354 | oldRot = part.RotationOffset; | 3118 | oldRot = part.RotationOffset; |
2355 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 3119 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
2356 | part.RotationOffset = newRot; | 3120 | part.RotationOffset = newRot; |
2357 | 3121 | ||
2358 | // Since this SOP's state has changed, push those changes into the physics engine | 3122 | // Since this SOP's state has changed, push those changes into the physics engine |
2359 | // and the simulator. | 3123 | // and the simulator. |
2360 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 3124 | // done on caller |
3125 | // part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2361 | } | 3126 | } |
2362 | 3127 | ||
2363 | /// <summary> | 3128 | /// <summary> |
@@ -2379,10 +3144,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2379 | { | 3144 | { |
2380 | if (!m_rootPart.BlockGrab) | 3145 | if (!m_rootPart.BlockGrab) |
2381 | { | 3146 | { |
2382 | Vector3 llmoveforce = pos - AbsolutePosition; | 3147 | /* Vector3 llmoveforce = pos - AbsolutePosition; |
2383 | Vector3 grabforce = llmoveforce; | 3148 | Vector3 grabforce = llmoveforce; |
2384 | grabforce = (grabforce / 10) * pa.Mass; | 3149 | grabforce = (grabforce / 10) * pa.Mass; |
2385 | pa.AddForce(grabforce, true); | 3150 | */ |
3151 | // empirically convert distance diference to a impulse | ||
3152 | Vector3 grabforce = pos - AbsolutePosition; | ||
3153 | grabforce = grabforce * (pa.Mass/ 10.0f); | ||
3154 | pa.AddForce(grabforce, false); | ||
2386 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 3155 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
2387 | } | 3156 | } |
2388 | } | 3157 | } |
@@ -2578,6 +3347,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2578 | /// <param name="SetVolumeDetect"></param> | 3347 | /// <param name="SetVolumeDetect"></param> |
2579 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) | 3348 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) |
2580 | { | 3349 | { |
3350 | HasGroupChanged = true; | ||
3351 | |||
2581 | SceneObjectPart selectionPart = GetPart(localID); | 3352 | SceneObjectPart selectionPart = GetPart(localID); |
2582 | 3353 | ||
2583 | if (SetTemporary && Scene != null) | 3354 | if (SetTemporary && Scene != null) |
@@ -2608,8 +3379,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2608 | } | 3379 | } |
2609 | } | 3380 | } |
2610 | 3381 | ||
2611 | for (int i = 0; i < parts.Length; i++) | 3382 | if (parts.Length > 1) |
2612 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); | 3383 | { |
3384 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3385 | |||
3386 | for (int i = 0; i < parts.Length; i++) | ||
3387 | { | ||
3388 | |||
3389 | if (parts[i].UUID != m_rootPart.UUID) | ||
3390 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3391 | } | ||
3392 | |||
3393 | if (m_rootPart.PhysActor != null) | ||
3394 | m_rootPart.PhysActor.Building = false; | ||
3395 | } | ||
3396 | else | ||
3397 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); | ||
2613 | } | 3398 | } |
2614 | } | 3399 | } |
2615 | 3400 | ||
@@ -2622,6 +3407,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2622 | } | 3407 | } |
2623 | } | 3408 | } |
2624 | 3409 | ||
3410 | |||
3411 | |||
3412 | /// <summary> | ||
3413 | /// Gets the number of parts | ||
3414 | /// </summary> | ||
3415 | /// <returns></returns> | ||
3416 | public int GetPartCount() | ||
3417 | { | ||
3418 | return Parts.Count(); | ||
3419 | } | ||
3420 | |||
2625 | /// <summary> | 3421 | /// <summary> |
2626 | /// Update the texture entry for this part | 3422 | /// Update the texture entry for this part |
2627 | /// </summary> | 3423 | /// </summary> |
@@ -2638,11 +3434,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2638 | 3434 | ||
2639 | public void AdjustChildPrimPermissions() | 3435 | public void AdjustChildPrimPermissions() |
2640 | { | 3436 | { |
3437 | uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits | ||
3438 | uint foldedPerms = RootPart.OwnerMask & 3; | ||
3439 | |||
2641 | ForEachPart(part => | 3440 | ForEachPart(part => |
2642 | { | 3441 | { |
3442 | newOwnerMask &= part.BaseMask; | ||
2643 | if (part != RootPart) | 3443 | if (part != RootPart) |
2644 | part.ClonePermissions(RootPart); | 3444 | part.ClonePermissions(RootPart); |
2645 | }); | 3445 | }); |
3446 | |||
3447 | RootPart.OwnerMask = newOwnerMask | foldedPerms; | ||
3448 | RootPart.ScheduleFullUpdate(); | ||
2646 | } | 3449 | } |
2647 | 3450 | ||
2648 | public void UpdatePermissions(UUID AgentID, byte field, uint localID, | 3451 | public void UpdatePermissions(UUID AgentID, byte field, uint localID, |
@@ -2650,8 +3453,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2650 | { | 3453 | { |
2651 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); | 3454 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); |
2652 | 3455 | ||
3456 | bool god = Scene.Permissions.IsGod(AgentID); | ||
3457 | |||
3458 | if (field == 1 && god) | ||
3459 | { | ||
3460 | ForEachPart(part => | ||
3461 | { | ||
3462 | part.BaseMask = RootPart.BaseMask; | ||
3463 | }); | ||
3464 | } | ||
3465 | |||
2653 | AdjustChildPrimPermissions(); | 3466 | AdjustChildPrimPermissions(); |
2654 | 3467 | ||
3468 | if (field == 1 && god) // Base mask was set. Update all child part inventories | ||
3469 | { | ||
3470 | foreach (SceneObjectPart part in Parts) | ||
3471 | part.Inventory.ApplyGodPermissions(RootPart.BaseMask); | ||
3472 | } | ||
3473 | |||
2655 | HasGroupChanged = true; | 3474 | HasGroupChanged = true; |
2656 | 3475 | ||
2657 | // Send the group's properties to all clients once all parts are updated | 3476 | // Send the group's properties to all clients once all parts are updated |
@@ -2697,8 +3516,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2697 | 3516 | ||
2698 | PhysicsActor pa = m_rootPart.PhysActor; | 3517 | PhysicsActor pa = m_rootPart.PhysActor; |
2699 | 3518 | ||
2700 | RootPart.StoreUndoState(true); | ||
2701 | |||
2702 | if (Scene != null) | 3519 | if (Scene != null) |
2703 | { | 3520 | { |
2704 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); | 3521 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); |
@@ -2726,7 +3543,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2726 | SceneObjectPart obPart = parts[i]; | 3543 | SceneObjectPart obPart = parts[i]; |
2727 | if (obPart.UUID != m_rootPart.UUID) | 3544 | if (obPart.UUID != m_rootPart.UUID) |
2728 | { | 3545 | { |
2729 | // obPart.IgnoreUndoUpdate = true; | ||
2730 | Vector3 oldSize = new Vector3(obPart.Scale); | 3546 | Vector3 oldSize = new Vector3(obPart.Scale); |
2731 | 3547 | ||
2732 | float f = 1.0f; | 3548 | float f = 1.0f; |
@@ -2838,8 +3654,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2838 | z *= a; | 3654 | z *= a; |
2839 | } | 3655 | } |
2840 | } | 3656 | } |
2841 | |||
2842 | // obPart.IgnoreUndoUpdate = false; | ||
2843 | } | 3657 | } |
2844 | } | 3658 | } |
2845 | } | 3659 | } |
@@ -2849,9 +3663,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2849 | prevScale.Y *= y; | 3663 | prevScale.Y *= y; |
2850 | prevScale.Z *= z; | 3664 | prevScale.Z *= z; |
2851 | 3665 | ||
2852 | // RootPart.IgnoreUndoUpdate = true; | ||
2853 | RootPart.Resize(prevScale); | 3666 | RootPart.Resize(prevScale); |
2854 | // RootPart.IgnoreUndoUpdate = false; | ||
2855 | 3667 | ||
2856 | for (int i = 0; i < parts.Length; i++) | 3668 | for (int i = 0; i < parts.Length; i++) |
2857 | { | 3669 | { |
@@ -2859,8 +3671,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2859 | 3671 | ||
2860 | if (obPart.UUID != m_rootPart.UUID) | 3672 | if (obPart.UUID != m_rootPart.UUID) |
2861 | { | 3673 | { |
2862 | obPart.IgnoreUndoUpdate = true; | ||
2863 | |||
2864 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); | 3674 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); |
2865 | currentpos.X *= x; | 3675 | currentpos.X *= x; |
2866 | currentpos.Y *= y; | 3676 | currentpos.Y *= y; |
@@ -2873,16 +3683,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2873 | 3683 | ||
2874 | obPart.Resize(newSize); | 3684 | obPart.Resize(newSize); |
2875 | obPart.UpdateOffSet(currentpos); | 3685 | obPart.UpdateOffSet(currentpos); |
2876 | |||
2877 | obPart.IgnoreUndoUpdate = false; | ||
2878 | } | 3686 | } |
2879 | 3687 | ||
2880 | // obPart.IgnoreUndoUpdate = false; | 3688 | HasGroupChanged = true; |
2881 | // obPart.StoreUndoState(); | 3689 | m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); |
3690 | ScheduleGroupForTerseUpdate(); | ||
2882 | } | 3691 | } |
2883 | |||
2884 | // m_log.DebugFormat( | ||
2885 | // "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); | ||
2886 | } | 3692 | } |
2887 | 3693 | ||
2888 | #endregion | 3694 | #endregion |
@@ -2895,14 +3701,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2895 | /// <param name="pos"></param> | 3701 | /// <param name="pos"></param> |
2896 | public void UpdateGroupPosition(Vector3 pos) | 3702 | public void UpdateGroupPosition(Vector3 pos) |
2897 | { | 3703 | { |
2898 | // m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); | ||
2899 | |||
2900 | RootPart.StoreUndoState(true); | ||
2901 | |||
2902 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2903 | // for (int i = 0; i < parts.Length; i++) | ||
2904 | // parts[i].StoreUndoState(); | ||
2905 | |||
2906 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 3704 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
2907 | { | 3705 | { |
2908 | if (IsAttachment) | 3706 | if (IsAttachment) |
@@ -2935,21 +3733,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2935 | /// </summary> | 3733 | /// </summary> |
2936 | /// <param name="pos"></param> | 3734 | /// <param name="pos"></param> |
2937 | /// <param name="localID"></param> | 3735 | /// <param name="localID"></param> |
3736 | /// | ||
3737 | |||
2938 | public void UpdateSinglePosition(Vector3 pos, uint localID) | 3738 | public void UpdateSinglePosition(Vector3 pos, uint localID) |
2939 | { | 3739 | { |
2940 | SceneObjectPart part = GetPart(localID); | 3740 | SceneObjectPart part = GetPart(localID); |
2941 | 3741 | ||
2942 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2943 | // for (int i = 0; i < parts.Length; i++) | ||
2944 | // parts[i].StoreUndoState(); | ||
2945 | |||
2946 | if (part != null) | 3742 | if (part != null) |
2947 | { | 3743 | { |
2948 | // m_log.DebugFormat( | 3744 | // unlock parts position change |
2949 | // "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); | 3745 | if (m_rootPart.PhysActor != null) |
2950 | 3746 | m_rootPart.PhysActor.Building = true; | |
2951 | part.StoreUndoState(false); | ||
2952 | part.IgnoreUndoUpdate = true; | ||
2953 | 3747 | ||
2954 | if (part.UUID == m_rootPart.UUID) | 3748 | if (part.UUID == m_rootPart.UUID) |
2955 | { | 3749 | { |
@@ -2960,8 +3754,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2960 | part.UpdateOffSet(pos); | 3754 | part.UpdateOffSet(pos); |
2961 | } | 3755 | } |
2962 | 3756 | ||
3757 | if (m_rootPart.PhysActor != null) | ||
3758 | m_rootPart.PhysActor.Building = false; | ||
3759 | |||
2963 | HasGroupChanged = true; | 3760 | HasGroupChanged = true; |
2964 | part.IgnoreUndoUpdate = false; | ||
2965 | } | 3761 | } |
2966 | } | 3762 | } |
2967 | 3763 | ||
@@ -2971,13 +3767,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2971 | /// <param name="pos"></param> | 3767 | /// <param name="pos"></param> |
2972 | public void UpdateRootPosition(Vector3 pos) | 3768 | public void UpdateRootPosition(Vector3 pos) |
2973 | { | 3769 | { |
2974 | // m_log.DebugFormat( | 3770 | // needs to be called with phys building true |
2975 | // "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); | ||
2976 | |||
2977 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2978 | // for (int i = 0; i < parts.Length; i++) | ||
2979 | // parts[i].StoreUndoState(); | ||
2980 | |||
2981 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); | 3771 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); |
2982 | Vector3 oldPos = | 3772 | Vector3 oldPos = |
2983 | new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, | 3773 | new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, |
@@ -3000,7 +3790,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3000 | AbsolutePosition = newPos; | 3790 | AbsolutePosition = newPos; |
3001 | 3791 | ||
3002 | HasGroupChanged = true; | 3792 | HasGroupChanged = true; |
3003 | ScheduleGroupForTerseUpdate(); | 3793 | if (m_rootPart.Undoing) |
3794 | { | ||
3795 | ScheduleGroupForFullUpdate(); | ||
3796 | } | ||
3797 | else | ||
3798 | { | ||
3799 | ScheduleGroupForTerseUpdate(); | ||
3800 | } | ||
3004 | } | 3801 | } |
3005 | 3802 | ||
3006 | #endregion | 3803 | #endregion |
@@ -3013,24 +3810,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3013 | /// <param name="rot"></param> | 3810 | /// <param name="rot"></param> |
3014 | public void UpdateGroupRotationR(Quaternion rot) | 3811 | public void UpdateGroupRotationR(Quaternion rot) |
3015 | { | 3812 | { |
3016 | // m_log.DebugFormat( | ||
3017 | // "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); | ||
3018 | |||
3019 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3020 | // for (int i = 0; i < parts.Length; i++) | ||
3021 | // parts[i].StoreUndoState(); | ||
3022 | |||
3023 | m_rootPart.StoreUndoState(true); | ||
3024 | |||
3025 | m_rootPart.UpdateRotation(rot); | 3813 | m_rootPart.UpdateRotation(rot); |
3026 | 3814 | ||
3815 | /* this is done by rootpart RotationOffset set called by UpdateRotation | ||
3027 | PhysicsActor actor = m_rootPart.PhysActor; | 3816 | PhysicsActor actor = m_rootPart.PhysActor; |
3028 | if (actor != null) | 3817 | if (actor != null) |
3029 | { | 3818 | { |
3030 | actor.Orientation = m_rootPart.RotationOffset; | 3819 | actor.Orientation = m_rootPart.RotationOffset; |
3031 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); | 3820 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
3032 | } | 3821 | } |
3033 | 3822 | */ | |
3034 | HasGroupChanged = true; | 3823 | HasGroupChanged = true; |
3035 | ScheduleGroupForTerseUpdate(); | 3824 | ScheduleGroupForTerseUpdate(); |
3036 | } | 3825 | } |
@@ -3042,16 +3831,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3042 | /// <param name="rot"></param> | 3831 | /// <param name="rot"></param> |
3043 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) | 3832 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) |
3044 | { | 3833 | { |
3045 | // m_log.DebugFormat( | ||
3046 | // "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); | ||
3047 | |||
3048 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3049 | // for (int i = 0; i < parts.Length; i++) | ||
3050 | // parts[i].StoreUndoState(); | ||
3051 | |||
3052 | RootPart.StoreUndoState(true); | ||
3053 | RootPart.IgnoreUndoUpdate = true; | ||
3054 | |||
3055 | m_rootPart.UpdateRotation(rot); | 3834 | m_rootPart.UpdateRotation(rot); |
3056 | 3835 | ||
3057 | PhysicsActor actor = m_rootPart.PhysActor; | 3836 | PhysicsActor actor = m_rootPart.PhysActor; |
@@ -3070,8 +3849,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3070 | 3849 | ||
3071 | HasGroupChanged = true; | 3850 | HasGroupChanged = true; |
3072 | ScheduleGroupForTerseUpdate(); | 3851 | ScheduleGroupForTerseUpdate(); |
3073 | |||
3074 | RootPart.IgnoreUndoUpdate = false; | ||
3075 | } | 3852 | } |
3076 | 3853 | ||
3077 | /// <summary> | 3854 | /// <summary> |
@@ -3084,13 +3861,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3084 | SceneObjectPart part = GetPart(localID); | 3861 | SceneObjectPart part = GetPart(localID); |
3085 | 3862 | ||
3086 | SceneObjectPart[] parts = m_parts.GetArray(); | 3863 | SceneObjectPart[] parts = m_parts.GetArray(); |
3087 | for (int i = 0; i < parts.Length; i++) | ||
3088 | parts[i].StoreUndoState(); | ||
3089 | 3864 | ||
3090 | if (part != null) | 3865 | if (part != null) |
3091 | { | 3866 | { |
3092 | // m_log.DebugFormat( | 3867 | if (m_rootPart.PhysActor != null) |
3093 | // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); | 3868 | m_rootPart.PhysActor.Building = true; |
3094 | 3869 | ||
3095 | if (part.UUID == m_rootPart.UUID) | 3870 | if (part.UUID == m_rootPart.UUID) |
3096 | { | 3871 | { |
@@ -3100,6 +3875,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3100 | { | 3875 | { |
3101 | part.UpdateRotation(rot); | 3876 | part.UpdateRotation(rot); |
3102 | } | 3877 | } |
3878 | |||
3879 | if (m_rootPart.PhysActor != null) | ||
3880 | m_rootPart.PhysActor.Building = false; | ||
3103 | } | 3881 | } |
3104 | } | 3882 | } |
3105 | 3883 | ||
@@ -3113,12 +3891,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3113 | SceneObjectPart part = GetPart(localID); | 3891 | SceneObjectPart part = GetPart(localID); |
3114 | if (part != null) | 3892 | if (part != null) |
3115 | { | 3893 | { |
3116 | // m_log.DebugFormat( | 3894 | if (m_rootPart.PhysActor != null) |
3117 | // "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", | 3895 | m_rootPart.PhysActor.Building = true; |
3118 | // part.Name, part.LocalId, rot); | ||
3119 | |||
3120 | part.StoreUndoState(); | ||
3121 | part.IgnoreUndoUpdate = true; | ||
3122 | 3896 | ||
3123 | if (part.UUID == m_rootPart.UUID) | 3897 | if (part.UUID == m_rootPart.UUID) |
3124 | { | 3898 | { |
@@ -3131,7 +3905,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3131 | part.OffsetPosition = pos; | 3905 | part.OffsetPosition = pos; |
3132 | } | 3906 | } |
3133 | 3907 | ||
3134 | part.IgnoreUndoUpdate = false; | 3908 | if (m_rootPart.PhysActor != null) |
3909 | m_rootPart.PhysActor.Building = false; | ||
3135 | } | 3910 | } |
3136 | } | 3911 | } |
3137 | 3912 | ||
@@ -3141,15 +3916,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3141 | /// <param name="rot"></param> | 3916 | /// <param name="rot"></param> |
3142 | public void UpdateRootRotation(Quaternion rot) | 3917 | public void UpdateRootRotation(Quaternion rot) |
3143 | { | 3918 | { |
3144 | // m_log.DebugFormat( | 3919 | // needs to be called with phys building true |
3145 | // "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", | ||
3146 | // Name, LocalId, rot); | ||
3147 | |||
3148 | Quaternion axRot = rot; | 3920 | Quaternion axRot = rot; |
3149 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 3921 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
3150 | 3922 | ||
3151 | m_rootPart.StoreUndoState(); | 3923 | //Don't use UpdateRotation because it schedules an update prematurely |
3152 | m_rootPart.UpdateRotation(rot); | 3924 | m_rootPart.RotationOffset = rot; |
3153 | 3925 | ||
3154 | PhysicsActor pa = m_rootPart.PhysActor; | 3926 | PhysicsActor pa = m_rootPart.PhysActor; |
3155 | 3927 | ||
@@ -3165,35 +3937,145 @@ namespace OpenSim.Region.Framework.Scenes | |||
3165 | SceneObjectPart prim = parts[i]; | 3937 | SceneObjectPart prim = parts[i]; |
3166 | if (prim.UUID != m_rootPart.UUID) | 3938 | if (prim.UUID != m_rootPart.UUID) |
3167 | { | 3939 | { |
3168 | prim.IgnoreUndoUpdate = true; | 3940 | Quaternion NewRot = oldParentRot * prim.RotationOffset; |
3941 | NewRot = Quaternion.Inverse(axRot) * NewRot; | ||
3942 | prim.RotationOffset = NewRot; | ||
3943 | |||
3169 | Vector3 axPos = prim.OffsetPosition; | 3944 | Vector3 axPos = prim.OffsetPosition; |
3945 | |||
3170 | axPos *= oldParentRot; | 3946 | axPos *= oldParentRot; |
3171 | axPos *= Quaternion.Inverse(axRot); | 3947 | axPos *= Quaternion.Inverse(axRot); |
3172 | prim.OffsetPosition = axPos; | 3948 | prim.OffsetPosition = axPos; |
3173 | Quaternion primsRot = prim.RotationOffset; | 3949 | } |
3174 | Quaternion newRot = oldParentRot * primsRot; | 3950 | } |
3175 | newRot = Quaternion.Inverse(axRot) * newRot; | 3951 | |
3176 | prim.RotationOffset = newRot; | 3952 | HasGroupChanged = true; |
3177 | prim.ScheduleTerseUpdate(); | 3953 | ScheduleGroupForFullUpdate(); |
3178 | prim.IgnoreUndoUpdate = false; | 3954 | } |
3179 | } | ||
3180 | } | ||
3181 | |||
3182 | // for (int i = 0; i < parts.Length; i++) | ||
3183 | // { | ||
3184 | // SceneObjectPart childpart = parts[i]; | ||
3185 | // if (childpart != m_rootPart) | ||
3186 | // { | ||
3187 | //// childpart.IgnoreUndoUpdate = false; | ||
3188 | //// childpart.StoreUndoState(); | ||
3189 | // } | ||
3190 | // } | ||
3191 | 3955 | ||
3192 | m_rootPart.ScheduleTerseUpdate(); | 3956 | private enum updatetype :int |
3957 | { | ||
3958 | none = 0, | ||
3959 | partterse = 1, | ||
3960 | partfull = 2, | ||
3961 | groupterse = 3, | ||
3962 | groupfull = 4 | ||
3963 | } | ||
3193 | 3964 | ||
3194 | // m_log.DebugFormat( | 3965 | public void doChangeObject(SceneObjectPart part, ObjectChangeData data) |
3195 | // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", | 3966 | { |
3196 | // Name, LocalId, rot); | 3967 | // TODO this still as excessive *.Schedule*Update()s |
3968 | |||
3969 | if (part != null && part.ParentGroup != null) | ||
3970 | { | ||
3971 | ObjectChangeType change = data.change; | ||
3972 | bool togroup = ((change & ObjectChangeType.Group) != 0); | ||
3973 | // bool uniform = ((what & ObjectChangeType.UniformScale) != 0); not in use | ||
3974 | |||
3975 | SceneObjectGroup group = part.ParentGroup; | ||
3976 | PhysicsActor pha = group.RootPart.PhysActor; | ||
3977 | |||
3978 | updatetype updateType = updatetype.none; | ||
3979 | |||
3980 | if (togroup) | ||
3981 | { | ||
3982 | // related to group | ||
3983 | if ((change & (ObjectChangeType.Rotation | ObjectChangeType.Position)) != 0) | ||
3984 | { | ||
3985 | if ((change & ObjectChangeType.Rotation) != 0) | ||
3986 | { | ||
3987 | group.RootPart.UpdateRotation(data.rotation); | ||
3988 | updateType = updatetype.none; | ||
3989 | } | ||
3990 | if ((change & ObjectChangeType.Position) != 0) | ||
3991 | { | ||
3992 | if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) | ||
3993 | UpdateGroupPosition(data.position); | ||
3994 | updateType = updatetype.groupterse; | ||
3995 | } | ||
3996 | else | ||
3997 | // ugly rotation update of all parts | ||
3998 | { | ||
3999 | group.ResetChildPrimPhysicsPositions(); | ||
4000 | } | ||
4001 | |||
4002 | } | ||
4003 | if ((change & ObjectChangeType.Scale) != 0) | ||
4004 | { | ||
4005 | if (pha != null) | ||
4006 | pha.Building = true; | ||
4007 | |||
4008 | group.GroupResize(data.scale); | ||
4009 | updateType = updatetype.none; | ||
4010 | |||
4011 | if (pha != null) | ||
4012 | pha.Building = false; | ||
4013 | } | ||
4014 | } | ||
4015 | else | ||
4016 | { | ||
4017 | // related to single prim in a link-set ( ie group) | ||
4018 | if (pha != null) | ||
4019 | pha.Building = true; | ||
4020 | |||
4021 | // root part is special | ||
4022 | // parts offset positions or rotations need to change also | ||
4023 | |||
4024 | if (part == group.RootPart) | ||
4025 | { | ||
4026 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4027 | group.UpdateRootRotation(data.rotation); | ||
4028 | if ((change & ObjectChangeType.Position) != 0) | ||
4029 | group.UpdateRootPosition(data.position); | ||
4030 | if ((change & ObjectChangeType.Scale) != 0) | ||
4031 | part.Resize(data.scale); | ||
4032 | } | ||
4033 | else | ||
4034 | { | ||
4035 | if ((change & ObjectChangeType.Position) != 0) | ||
4036 | { | ||
4037 | part.OffsetPosition = data.position; | ||
4038 | updateType = updatetype.partterse; | ||
4039 | } | ||
4040 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4041 | { | ||
4042 | part.UpdateRotation(data.rotation); | ||
4043 | updateType = updatetype.none; | ||
4044 | } | ||
4045 | if ((change & ObjectChangeType.Scale) != 0) | ||
4046 | { | ||
4047 | part.Resize(data.scale); | ||
4048 | updateType = updatetype.none; | ||
4049 | } | ||
4050 | } | ||
4051 | |||
4052 | if (pha != null) | ||
4053 | pha.Building = false; | ||
4054 | } | ||
4055 | |||
4056 | if (updateType != updatetype.none) | ||
4057 | { | ||
4058 | group.HasGroupChanged = true; | ||
4059 | |||
4060 | switch (updateType) | ||
4061 | { | ||
4062 | case updatetype.partterse: | ||
4063 | part.ScheduleTerseUpdate(); | ||
4064 | break; | ||
4065 | case updatetype.partfull: | ||
4066 | part.ScheduleFullUpdate(); | ||
4067 | break; | ||
4068 | case updatetype.groupterse: | ||
4069 | group.ScheduleGroupForTerseUpdate(); | ||
4070 | break; | ||
4071 | case updatetype.groupfull: | ||
4072 | group.ScheduleGroupForFullUpdate(); | ||
4073 | break; | ||
4074 | default: | ||
4075 | break; | ||
4076 | } | ||
4077 | } | ||
4078 | } | ||
3197 | } | 4079 | } |
3198 | 4080 | ||
3199 | #endregion | 4081 | #endregion |
@@ -3292,10 +4174,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3292 | scriptPosTarget target = m_targets[idx]; | 4174 | scriptPosTarget target = m_targets[idx]; |
3293 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) | 4175 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) |
3294 | { | 4176 | { |
4177 | at_target = true; | ||
4178 | |||
3295 | // trigger at_target | 4179 | // trigger at_target |
3296 | if (m_scriptListens_atTarget) | 4180 | if (m_scriptListens_atTarget) |
3297 | { | 4181 | { |
3298 | at_target = true; | ||
3299 | scriptPosTarget att = new scriptPosTarget(); | 4182 | scriptPosTarget att = new scriptPosTarget(); |
3300 | att.targetPos = target.targetPos; | 4183 | att.targetPos = target.targetPos; |
3301 | att.tolerance = target.tolerance; | 4184 | att.tolerance = target.tolerance; |
@@ -3413,11 +4296,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
3413 | } | 4296 | } |
3414 | } | 4297 | } |
3415 | } | 4298 | } |
3416 | 4299 | ||
4300 | public Vector3 GetGeometricCenter() | ||
4301 | { | ||
4302 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
4303 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
4304 | // ignoring tortured prims details since sl also seems to ignore | ||
4305 | // so no real use in doing it on physics | ||
4306 | |||
4307 | Vector3 gc = Vector3.Zero; | ||
4308 | |||
4309 | int nparts = m_parts.Count; | ||
4310 | if (nparts <= 1) | ||
4311 | return gc; | ||
4312 | |||
4313 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4314 | nparts = parts.Length; // just in case it changed | ||
4315 | if (nparts <= 1) | ||
4316 | return gc; | ||
4317 | |||
4318 | Quaternion parentRot = RootPart.RotationOffset; | ||
4319 | Vector3 pPos; | ||
4320 | |||
4321 | // average all parts positions | ||
4322 | for (int i = 0; i < nparts; i++) | ||
4323 | { | ||
4324 | // do it directly | ||
4325 | // gc += parts[i].GetWorldPosition(); | ||
4326 | if (parts[i] != RootPart) | ||
4327 | { | ||
4328 | pPos = parts[i].OffsetPosition; | ||
4329 | gc += pPos; | ||
4330 | } | ||
4331 | |||
4332 | } | ||
4333 | gc /= nparts; | ||
4334 | |||
4335 | // relative to root: | ||
4336 | // gc -= AbsolutePosition; | ||
4337 | return gc; | ||
4338 | } | ||
4339 | |||
3417 | public float GetMass() | 4340 | public float GetMass() |
3418 | { | 4341 | { |
3419 | float retmass = 0f; | 4342 | float retmass = 0f; |
3420 | |||
3421 | SceneObjectPart[] parts = m_parts.GetArray(); | 4343 | SceneObjectPart[] parts = m_parts.GetArray(); |
3422 | for (int i = 0; i < parts.Length; i++) | 4344 | for (int i = 0; i < parts.Length; i++) |
3423 | retmass += parts[i].GetMass(); | 4345 | retmass += parts[i].GetMass(); |
@@ -3425,6 +4347,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3425 | return retmass; | 4347 | return retmass; |
3426 | } | 4348 | } |
3427 | 4349 | ||
4350 | // center of mass of full object | ||
4351 | public Vector3 GetCenterOfMass() | ||
4352 | { | ||
4353 | PhysicsActor pa = RootPart.PhysActor; | ||
4354 | |||
4355 | if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null) | ||
4356 | { | ||
4357 | // physics knows better about center of mass of physical prims | ||
4358 | Vector3 tmp = pa.CenterOfMass; | ||
4359 | return tmp; | ||
4360 | } | ||
4361 | |||
4362 | Vector3 Ptot = Vector3.Zero; | ||
4363 | float totmass = 0f; | ||
4364 | float m; | ||
4365 | |||
4366 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4367 | for (int i = 0; i < parts.Length; i++) | ||
4368 | { | ||
4369 | m = parts[i].GetMass(); | ||
4370 | Ptot += parts[i].GetPartCenterOfMass() * m; | ||
4371 | totmass += m; | ||
4372 | } | ||
4373 | |||
4374 | if (totmass == 0) | ||
4375 | totmass = 0; | ||
4376 | else | ||
4377 | totmass = 1 / totmass; | ||
4378 | Ptot *= totmass; | ||
4379 | |||
4380 | return Ptot; | ||
4381 | } | ||
4382 | |||
3428 | /// <summary> | 4383 | /// <summary> |
3429 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that | 4384 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that |
3430 | /// the physics engine can use it. | 4385 | /// the physics engine can use it. |
@@ -3593,6 +4548,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3593 | FromItemID = uuid; | 4548 | FromItemID = uuid; |
3594 | } | 4549 | } |
3595 | 4550 | ||
4551 | public void ResetOwnerChangeFlag() | ||
4552 | { | ||
4553 | ForEachPart(delegate(SceneObjectPart part) | ||
4554 | { | ||
4555 | part.ResetOwnerChangeFlag(); | ||
4556 | }); | ||
4557 | } | ||
4558 | |||
3596 | #endregion | 4559 | #endregion |
3597 | } | 4560 | } |
3598 | } | 4561 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f79ac96..5714fdd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -62,7 +62,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
62 | TELEPORT = 512, | 62 | TELEPORT = 512, |
63 | REGION_RESTART = 1024, | 63 | REGION_RESTART = 1024, |
64 | MEDIA = 2048, | 64 | MEDIA = 2048, |
65 | ANIMATION = 16384 | 65 | ANIMATION = 16384, |
66 | POSITION = 32768 | ||
66 | } | 67 | } |
67 | 68 | ||
68 | // I don't really know where to put this except here. | 69 | // I don't really know where to put this except here. |
@@ -121,7 +122,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
121 | /// Denote all sides of the prim | 122 | /// Denote all sides of the prim |
122 | /// </value> | 123 | /// </value> |
123 | public const int ALL_SIDES = -1; | 124 | public const int ALL_SIDES = -1; |
124 | 125 | ||
126 | private const scriptEvents PhysicsNeededSubsEvents = ( | ||
127 | scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | | ||
128 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
129 | ); | ||
130 | private const scriptEvents PhyscicsPhantonSubsEvents = ( | ||
131 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
132 | ); | ||
133 | private const scriptEvents PhyscicsVolumeDtcSubsEvents = ( | ||
134 | scriptEvents.collision_start | scriptEvents.collision_end | ||
135 | ); | ||
136 | |||
125 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 137 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
126 | 138 | ||
127 | /// <value> | 139 | /// <value> |
@@ -191,12 +203,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
191 | 203 | ||
192 | public double SoundRadius; | 204 | public double SoundRadius; |
193 | 205 | ||
206 | |||
194 | public uint TimeStampFull; | 207 | public uint TimeStampFull; |
195 | 208 | ||
196 | public uint TimeStampLastActivity; // Will be used for AutoReturn | 209 | public uint TimeStampLastActivity; // Will be used for AutoReturn |
197 | 210 | ||
198 | public uint TimeStampTerse; | 211 | public uint TimeStampTerse; |
199 | 212 | ||
213 | // The following two are to hold the attachment data | ||
214 | // while an object is inworld | ||
215 | [XmlIgnore] | ||
216 | public byte AttachPoint = 0; | ||
217 | |||
218 | [XmlIgnore] | ||
219 | public Vector3 AttachOffset = Vector3.Zero; | ||
220 | |||
221 | [XmlIgnore] | ||
222 | public Quaternion AttachRotation = Quaternion.Identity; | ||
223 | |||
224 | [XmlIgnore] | ||
200 | public int STATUS_ROTATE_X; | 225 | public int STATUS_ROTATE_X; |
201 | 226 | ||
202 | public int STATUS_ROTATE_Y; | 227 | public int STATUS_ROTATE_Y; |
@@ -223,8 +248,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
223 | 248 | ||
224 | public Vector3 RotationAxis = Vector3.One; | 249 | public Vector3 RotationAxis = Vector3.One; |
225 | 250 | ||
226 | public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this | 251 | public bool VolumeDetectActive; |
227 | // Certainly this must be a persistant setting finally | ||
228 | 252 | ||
229 | public bool IsWaitingForFirstSpinUpdatePacket; | 253 | public bool IsWaitingForFirstSpinUpdatePacket; |
230 | 254 | ||
@@ -264,10 +288,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
264 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; | 288 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; |
265 | private Vector3 m_sitTargetPosition; | 289 | private Vector3 m_sitTargetPosition; |
266 | private string m_sitAnimation = "SIT"; | 290 | private string m_sitAnimation = "SIT"; |
291 | private bool m_occupied; // KF if any av is sitting on this prim | ||
267 | private string m_text = String.Empty; | 292 | private string m_text = String.Empty; |
268 | private string m_touchName = String.Empty; | 293 | private string m_touchName = String.Empty; |
269 | private readonly List<UndoState> m_undo = new List<UndoState>(5); | 294 | private UndoRedoState m_UndoRedo = null; |
270 | private readonly List<UndoState> m_redo = new List<UndoState>(5); | ||
271 | 295 | ||
272 | private bool m_passTouches = false; | 296 | private bool m_passTouches = false; |
273 | private bool m_passCollisions = false; | 297 | private bool m_passCollisions = false; |
@@ -296,7 +320,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
296 | protected Vector3 m_lastAcceleration; | 320 | protected Vector3 m_lastAcceleration; |
297 | protected Vector3 m_lastAngularVelocity; | 321 | protected Vector3 m_lastAngularVelocity; |
298 | protected int m_lastTerseSent; | 322 | protected int m_lastTerseSent; |
299 | 323 | protected float m_buoyancy = 0.0f; | |
324 | protected Vector3 m_force; | ||
325 | protected Vector3 m_torque; | ||
326 | |||
327 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; | ||
328 | protected float m_density = 1000.0f; // in kg/m^3 | ||
329 | protected float m_gravitymod = 1.0f; | ||
330 | protected float m_friction = 0.6f; // wood | ||
331 | protected float m_bounce = 0.5f; // wood | ||
332 | |||
333 | |||
334 | protected bool m_isSelected = false; | ||
335 | |||
300 | /// <summary> | 336 | /// <summary> |
301 | /// Stores media texture data | 337 | /// Stores media texture data |
302 | /// </summary> | 338 | /// </summary> |
@@ -308,10 +344,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
308 | private Vector3 m_cameraAtOffset; | 344 | private Vector3 m_cameraAtOffset; |
309 | private bool m_forceMouselook; | 345 | private bool m_forceMouselook; |
310 | 346 | ||
311 | // TODO: Collision sound should have default. | 347 | |
348 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
349 | private sbyte m_collisionSoundType; | ||
312 | private UUID m_collisionSound; | 350 | private UUID m_collisionSound; |
313 | private float m_collisionSoundVolume; | 351 | private float m_collisionSoundVolume; |
314 | 352 | ||
353 | private int LastColSoundSentTime; | ||
354 | |||
355 | |||
356 | private SOPVehicle m_vehicleParams = null; | ||
357 | |||
358 | private KeyframeMotion m_keyframeMotion = null; | ||
359 | |||
360 | public KeyframeMotion KeyframeMotion | ||
361 | { | ||
362 | get; set; | ||
363 | } | ||
364 | |||
365 | |||
315 | #endregion Fields | 366 | #endregion Fields |
316 | 367 | ||
317 | // ~SceneObjectPart() | 368 | // ~SceneObjectPart() |
@@ -340,6 +391,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
340 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 391 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
341 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log | 392 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log |
342 | m_inventory = new SceneObjectPartInventory(this); | 393 | m_inventory = new SceneObjectPartInventory(this); |
394 | LastColSoundSentTime = Util.EnvironmentTickCount(); | ||
343 | } | 395 | } |
344 | 396 | ||
345 | /// <summary> | 397 | /// <summary> |
@@ -354,7 +406,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
354 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, | 406 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, |
355 | Quaternion rotationOffset, Vector3 offsetPosition) : this() | 407 | Quaternion rotationOffset, Vector3 offsetPosition) : this() |
356 | { | 408 | { |
357 | m_name = "Primitive"; | 409 | m_name = "Object"; |
358 | 410 | ||
359 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); | 411 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); |
360 | LastOwnerID = CreatorID = OwnerID = ownerID; | 412 | LastOwnerID = CreatorID = OwnerID = ownerID; |
@@ -393,7 +445,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
393 | private uint _ownerMask = (uint)PermissionMask.All; | 445 | private uint _ownerMask = (uint)PermissionMask.All; |
394 | private uint _groupMask = (uint)PermissionMask.None; | 446 | private uint _groupMask = (uint)PermissionMask.None; |
395 | private uint _everyoneMask = (uint)PermissionMask.None; | 447 | private uint _everyoneMask = (uint)PermissionMask.None; |
396 | private uint _nextOwnerMask = (uint)PermissionMask.All; | 448 | private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); |
397 | private PrimFlags _flags = PrimFlags.None; | 449 | private PrimFlags _flags = PrimFlags.None; |
398 | private DateTime m_expires; | 450 | private DateTime m_expires; |
399 | private DateTime m_rezzed; | 451 | private DateTime m_rezzed; |
@@ -487,12 +539,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
487 | } | 539 | } |
488 | 540 | ||
489 | /// <value> | 541 | /// <value> |
490 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 542 | /// Get the inventory list |
491 | /// </value> | 543 | /// </value> |
492 | public TaskInventoryDictionary TaskInventory | 544 | public TaskInventoryDictionary TaskInventory |
493 | { | 545 | { |
494 | get { return m_inventory.Items; } | 546 | get { |
495 | set { m_inventory.Items = value; } | 547 | return m_inventory.Items; |
548 | } | ||
549 | set { | ||
550 | m_inventory.Items = value; | ||
551 | } | ||
496 | } | 552 | } |
497 | 553 | ||
498 | /// <summary> | 554 | /// <summary> |
@@ -542,20 +598,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
542 | } | 598 | } |
543 | } | 599 | } |
544 | 600 | ||
545 | public byte Material | ||
546 | { | ||
547 | get { return (byte) m_material; } | ||
548 | set | ||
549 | { | ||
550 | m_material = (Material)value; | ||
551 | |||
552 | PhysicsActor pa = PhysActor; | ||
553 | |||
554 | if (pa != null) | ||
555 | pa.SetMaterial((int)value); | ||
556 | } | ||
557 | } | ||
558 | |||
559 | [XmlIgnore] | 601 | [XmlIgnore] |
560 | public bool PassTouches | 602 | public bool PassTouches |
561 | { | 603 | { |
@@ -581,6 +623,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
581 | } | 623 | } |
582 | } | 624 | } |
583 | 625 | ||
626 | public bool IsSelected | ||
627 | { | ||
628 | get { return m_isSelected; } | ||
629 | set | ||
630 | { | ||
631 | m_isSelected = value; | ||
632 | if (ParentGroup != null) | ||
633 | ParentGroup.PartSelectChanged(value); | ||
634 | } | ||
635 | } | ||
636 | |||
637 | |||
584 | public Dictionary<int, string> CollisionFilter | 638 | public Dictionary<int, string> CollisionFilter |
585 | { | 639 | { |
586 | get { return m_CollisionFilter; } | 640 | get { return m_CollisionFilter; } |
@@ -649,14 +703,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
649 | set { m_LoopSoundSlavePrims = value; } | 703 | set { m_LoopSoundSlavePrims = value; } |
650 | } | 704 | } |
651 | 705 | ||
652 | |||
653 | public Byte[] TextureAnimation | 706 | public Byte[] TextureAnimation |
654 | { | 707 | { |
655 | get { return m_TextureAnimation; } | 708 | get { return m_TextureAnimation; } |
656 | set { m_TextureAnimation = value; } | 709 | set { m_TextureAnimation = value; } |
657 | } | 710 | } |
658 | 711 | ||
659 | |||
660 | public Byte[] ParticleSystem | 712 | public Byte[] ParticleSystem |
661 | { | 713 | { |
662 | get { return m_particleSystem; } | 714 | get { return m_particleSystem; } |
@@ -693,9 +745,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
693 | { | 745 | { |
694 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 746 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
695 | PhysicsActor actor = PhysActor; | 747 | PhysicsActor actor = PhysActor; |
696 | // If physical and the root prim of a linkset, the position of the group is what physics thinks. | 748 | if (ParentID == 0) |
697 | if (actor != null && ParentID == 0) | 749 | { |
698 | m_groupPosition = actor.Position; | 750 | if (actor != null) |
751 | m_groupPosition = actor.Position; | ||
752 | return m_groupPosition; | ||
753 | } | ||
699 | 754 | ||
700 | // If I'm an attachment, my position is reported as the position of who I'm attached to | 755 | // If I'm an attachment, my position is reported as the position of who I'm attached to |
701 | if (ParentGroup.IsAttachment) | 756 | if (ParentGroup.IsAttachment) |
@@ -705,14 +760,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
705 | return sp.AbsolutePosition; | 760 | return sp.AbsolutePosition; |
706 | } | 761 | } |
707 | 762 | ||
763 | // use root prim's group position. Physics may have updated it | ||
764 | if (ParentGroup.RootPart != this) | ||
765 | m_groupPosition = ParentGroup.RootPart.GroupPosition; | ||
708 | return m_groupPosition; | 766 | return m_groupPosition; |
709 | } | 767 | } |
710 | set | 768 | set |
711 | { | 769 | { |
712 | m_groupPosition = value; | 770 | m_groupPosition = value; |
713 | |||
714 | PhysicsActor actor = PhysActor; | 771 | PhysicsActor actor = PhysActor; |
715 | if (actor != null) | 772 | if (actor != null && ParentGroup.Scene.PhysicsScene != null) |
716 | { | 773 | { |
717 | try | 774 | try |
718 | { | 775 | { |
@@ -736,16 +793,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
736 | m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e); | 793 | m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e); |
737 | } | 794 | } |
738 | } | 795 | } |
739 | |||
740 | // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too | ||
741 | if (SitTargetAvatar != UUID.Zero) | ||
742 | { | ||
743 | ScenePresence avatar; | ||
744 | if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar)) | ||
745 | { | ||
746 | avatar.ParentPosition = GetWorldPosition(); | ||
747 | } | ||
748 | } | ||
749 | } | 796 | } |
750 | } | 797 | } |
751 | 798 | ||
@@ -754,7 +801,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
754 | get { return m_offsetPosition; } | 801 | get { return m_offsetPosition; } |
755 | set | 802 | set |
756 | { | 803 | { |
757 | // StoreUndoState(); | 804 | Vector3 oldpos = m_offsetPosition; |
758 | m_offsetPosition = value; | 805 | m_offsetPosition = value; |
759 | 806 | ||
760 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 807 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
@@ -769,7 +816,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
769 | if (ParentGroup.Scene != null) | 816 | if (ParentGroup.Scene != null) |
770 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 817 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
771 | } | 818 | } |
819 | |||
820 | if (!m_parentGroup.m_dupeInProgress) | ||
821 | { | ||
822 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); | ||
823 | foreach (ScenePresence av in avs) | ||
824 | { | ||
825 | if (av.ParentID == m_localId) | ||
826 | { | ||
827 | Vector3 offset = (m_offsetPosition - oldpos); | ||
828 | av.AbsolutePosition += offset; | ||
829 | av.SendAvatarDataToAllAgents(); | ||
830 | } | ||
831 | } | ||
832 | } | ||
772 | } | 833 | } |
834 | TriggerScriptChangedEvent(Changed.POSITION); | ||
773 | } | 835 | } |
774 | } | 836 | } |
775 | 837 | ||
@@ -820,7 +882,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
820 | 882 | ||
821 | set | 883 | set |
822 | { | 884 | { |
823 | StoreUndoState(); | 885 | // StoreUndoState(); |
824 | m_rotationOffset = value; | 886 | m_rotationOffset = value; |
825 | 887 | ||
826 | PhysicsActor actor = PhysActor; | 888 | PhysicsActor actor = PhysActor; |
@@ -908,19 +970,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
908 | get | 970 | get |
909 | { | 971 | { |
910 | PhysicsActor actor = PhysActor; | 972 | PhysicsActor actor = PhysActor; |
911 | if ((actor != null) && actor.IsPhysical) | 973 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this) |
912 | { | 974 | { |
913 | m_angularVelocity = actor.RotationalVelocity; | 975 | m_angularVelocity = actor.RotationalVelocity; |
914 | } | 976 | } |
915 | return m_angularVelocity; | 977 | return m_angularVelocity; |
916 | } | 978 | } |
917 | set { m_angularVelocity = value; } | 979 | set |
980 | { | ||
981 | m_angularVelocity = value; | ||
982 | PhysicsActor actor = PhysActor; | ||
983 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this && VehicleType == (int)Vehicle.TYPE_NONE) | ||
984 | { | ||
985 | actor.RotationalVelocity = m_angularVelocity; | ||
986 | } | ||
987 | } | ||
918 | } | 988 | } |
919 | 989 | ||
920 | /// <summary></summary> | 990 | /// <summary></summary> |
921 | public Vector3 Acceleration | 991 | public Vector3 Acceleration |
922 | { | 992 | { |
923 | get { return m_acceleration; } | 993 | get |
994 | { | ||
995 | PhysicsActor actor = PhysActor; | ||
996 | if (actor != null) | ||
997 | { | ||
998 | m_acceleration = actor.Acceleration; | ||
999 | } | ||
1000 | return m_acceleration; | ||
1001 | } | ||
1002 | |||
924 | set { m_acceleration = value; } | 1003 | set { m_acceleration = value; } |
925 | } | 1004 | } |
926 | 1005 | ||
@@ -988,7 +1067,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
988 | public PrimitiveBaseShape Shape | 1067 | public PrimitiveBaseShape Shape |
989 | { | 1068 | { |
990 | get { return m_shape; } | 1069 | get { return m_shape; } |
991 | set { m_shape = value;} | 1070 | set |
1071 | { | ||
1072 | m_shape = value; | ||
1073 | } | ||
992 | } | 1074 | } |
993 | 1075 | ||
994 | /// <summary> | 1076 | /// <summary> |
@@ -1001,7 +1083,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1001 | { | 1083 | { |
1002 | if (m_shape != null) | 1084 | if (m_shape != null) |
1003 | { | 1085 | { |
1004 | StoreUndoState(); | ||
1005 | 1086 | ||
1006 | m_shape.Scale = value; | 1087 | m_shape.Scale = value; |
1007 | 1088 | ||
@@ -1028,6 +1109,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1028 | } | 1109 | } |
1029 | 1110 | ||
1030 | public UpdateRequired UpdateFlag { get; set; } | 1111 | public UpdateRequired UpdateFlag { get; set; } |
1112 | public bool UpdatePhysRequired { get; set; } | ||
1031 | 1113 | ||
1032 | /// <summary> | 1114 | /// <summary> |
1033 | /// Used for media on a prim. | 1115 | /// Used for media on a prim. |
@@ -1068,10 +1150,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1068 | { | 1150 | { |
1069 | get | 1151 | get |
1070 | { | 1152 | { |
1071 | if (ParentGroup.IsAttachment) | 1153 | return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); |
1072 | return GroupPosition; | ||
1073 | |||
1074 | return m_offsetPosition + m_groupPosition; | ||
1075 | } | 1154 | } |
1076 | } | 1155 | } |
1077 | 1156 | ||
@@ -1249,6 +1328,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1249 | _flags = value; | 1328 | _flags = value; |
1250 | } | 1329 | } |
1251 | } | 1330 | } |
1331 | |||
1332 | [XmlIgnore] | ||
1333 | public bool IsOccupied // KF If an av is sittingon this prim | ||
1334 | { | ||
1335 | get { return m_occupied; } | ||
1336 | set { m_occupied = value; } | ||
1337 | } | ||
1252 | 1338 | ||
1253 | /// <summary> | 1339 | /// <summary> |
1254 | /// 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 | 1340 | /// 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 |
@@ -1299,12 +1385,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1299 | set { m_sitAnimation = value; } | 1385 | set { m_sitAnimation = value; } |
1300 | } | 1386 | } |
1301 | 1387 | ||
1388 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); | ||
1389 | |||
1390 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
1391 | // runtime thing.. do not persist | ||
1392 | [XmlIgnore] | ||
1393 | public sbyte CollisionSoundType | ||
1394 | { | ||
1395 | get | ||
1396 | { | ||
1397 | return m_collisionSoundType; | ||
1398 | } | ||
1399 | set | ||
1400 | { | ||
1401 | m_collisionSoundType = value; | ||
1402 | if (value == -1) | ||
1403 | m_collisionSound = invalidCollisionSoundUUID; | ||
1404 | else if (value == 0) | ||
1405 | m_collisionSound = UUID.Zero; | ||
1406 | } | ||
1407 | } | ||
1408 | |||
1302 | public UUID CollisionSound | 1409 | public UUID CollisionSound |
1303 | { | 1410 | { |
1304 | get { return m_collisionSound; } | 1411 | get { return m_collisionSound; } |
1305 | set | 1412 | set |
1306 | { | 1413 | { |
1307 | m_collisionSound = value; | 1414 | m_collisionSound = value; |
1415 | |||
1416 | if (value == invalidCollisionSoundUUID) | ||
1417 | m_collisionSoundType = -1; | ||
1418 | else if (value == UUID.Zero) | ||
1419 | m_collisionSoundType = 0; | ||
1420 | else | ||
1421 | m_collisionSoundType = 1; | ||
1422 | |||
1308 | aggregateScriptEvents(); | 1423 | aggregateScriptEvents(); |
1309 | } | 1424 | } |
1310 | } | 1425 | } |
@@ -1315,6 +1430,324 @@ namespace OpenSim.Region.Framework.Scenes | |||
1315 | set { m_collisionSoundVolume = value; } | 1430 | set { m_collisionSoundVolume = value; } |
1316 | } | 1431 | } |
1317 | 1432 | ||
1433 | public float Buoyancy | ||
1434 | { | ||
1435 | get | ||
1436 | { | ||
1437 | if (ParentGroup.RootPart == this) | ||
1438 | return m_buoyancy; | ||
1439 | |||
1440 | return ParentGroup.RootPart.Buoyancy; | ||
1441 | } | ||
1442 | set | ||
1443 | { | ||
1444 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1445 | { | ||
1446 | ParentGroup.RootPart.Buoyancy = value; | ||
1447 | return; | ||
1448 | } | ||
1449 | m_buoyancy = value; | ||
1450 | if (PhysActor != null) | ||
1451 | PhysActor.Buoyancy = value; | ||
1452 | } | ||
1453 | } | ||
1454 | |||
1455 | public Vector3 Force | ||
1456 | { | ||
1457 | get | ||
1458 | { | ||
1459 | if (ParentGroup.RootPart == this) | ||
1460 | return m_force; | ||
1461 | |||
1462 | return ParentGroup.RootPart.Force; | ||
1463 | } | ||
1464 | |||
1465 | set | ||
1466 | { | ||
1467 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1468 | { | ||
1469 | ParentGroup.RootPart.Force = value; | ||
1470 | return; | ||
1471 | } | ||
1472 | m_force = value; | ||
1473 | if (PhysActor != null) | ||
1474 | PhysActor.Force = value; | ||
1475 | } | ||
1476 | } | ||
1477 | |||
1478 | public Vector3 Torque | ||
1479 | { | ||
1480 | get | ||
1481 | { | ||
1482 | if (ParentGroup.RootPart == this) | ||
1483 | return m_torque; | ||
1484 | |||
1485 | return ParentGroup.RootPart.Torque; | ||
1486 | } | ||
1487 | |||
1488 | set | ||
1489 | { | ||
1490 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1491 | { | ||
1492 | ParentGroup.RootPart.Torque = value; | ||
1493 | return; | ||
1494 | } | ||
1495 | m_torque = value; | ||
1496 | if (PhysActor != null) | ||
1497 | PhysActor.Torque = value; | ||
1498 | } | ||
1499 | } | ||
1500 | |||
1501 | public byte Material | ||
1502 | { | ||
1503 | get { return (byte)m_material; } | ||
1504 | set | ||
1505 | { | ||
1506 | if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial) | ||
1507 | { | ||
1508 | bool update = false; | ||
1509 | |||
1510 | if (m_material != (Material)value) | ||
1511 | { | ||
1512 | update = true; | ||
1513 | m_material = (Material)value; | ||
1514 | } | ||
1515 | |||
1516 | if (m_friction != SOPMaterialData.friction(m_material)) | ||
1517 | { | ||
1518 | update = true; | ||
1519 | m_friction = SOPMaterialData.friction(m_material); | ||
1520 | } | ||
1521 | |||
1522 | if (m_bounce != SOPMaterialData.bounce(m_material)) | ||
1523 | { | ||
1524 | update = true; | ||
1525 | m_bounce = SOPMaterialData.bounce(m_material); | ||
1526 | } | ||
1527 | |||
1528 | if (update) | ||
1529 | { | ||
1530 | if (PhysActor != null) | ||
1531 | { | ||
1532 | PhysActor.SetMaterial((int)value); | ||
1533 | } | ||
1534 | if(ParentGroup != null) | ||
1535 | ParentGroup.HasGroupChanged = true; | ||
1536 | ScheduleFullUpdateIfNone(); | ||
1537 | UpdatePhysRequired = true; | ||
1538 | } | ||
1539 | } | ||
1540 | } | ||
1541 | } | ||
1542 | |||
1543 | // not a propriety to move to methods place later | ||
1544 | private bool HasMesh() | ||
1545 | { | ||
1546 | if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) | ||
1547 | return true; | ||
1548 | return false; | ||
1549 | } | ||
1550 | |||
1551 | // not a propriety to move to methods place later | ||
1552 | public byte DefaultPhysicsShapeType() | ||
1553 | { | ||
1554 | byte type; | ||
1555 | |||
1556 | if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) | ||
1557 | type = (byte)PhysShapeType.convex; | ||
1558 | else | ||
1559 | type = (byte)PhysShapeType.prim; | ||
1560 | |||
1561 | return type; | ||
1562 | } | ||
1563 | |||
1564 | [XmlIgnore] | ||
1565 | public bool UsesComplexCost | ||
1566 | { | ||
1567 | get | ||
1568 | { | ||
1569 | byte pst = PhysicsShapeType; | ||
1570 | if(pst == (byte) PhysShapeType.none || pst == (byte) PhysShapeType.convex || HasMesh()) | ||
1571 | return true; | ||
1572 | return false; | ||
1573 | } | ||
1574 | } | ||
1575 | |||
1576 | [XmlIgnore] | ||
1577 | public float PhysicsCost | ||
1578 | { | ||
1579 | get | ||
1580 | { | ||
1581 | if(PhysicsShapeType == (byte)PhysShapeType.none) | ||
1582 | return 0; | ||
1583 | |||
1584 | float cost = 0.1f; | ||
1585 | if (PhysActor != null) | ||
1586 | cost = PhysActor.PhysicsCost; | ||
1587 | else | ||
1588 | cost = 0.1f; | ||
1589 | |||
1590 | if ((Flags & PrimFlags.Physics) != 0) | ||
1591 | cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 | ||
1592 | return cost; | ||
1593 | } | ||
1594 | } | ||
1595 | |||
1596 | [XmlIgnore] | ||
1597 | public float StreamingCost | ||
1598 | { | ||
1599 | get | ||
1600 | { | ||
1601 | float cost; | ||
1602 | if (PhysActor != null) | ||
1603 | cost = PhysActor.StreamCost; | ||
1604 | else | ||
1605 | cost = 1.0f; | ||
1606 | return 1.0f; | ||
1607 | } | ||
1608 | } | ||
1609 | |||
1610 | [XmlIgnore] | ||
1611 | public float SimulationCost | ||
1612 | { | ||
1613 | get | ||
1614 | { | ||
1615 | // ignoring scripts. Don't like considering them for this | ||
1616 | if((Flags & PrimFlags.Physics) != 0) | ||
1617 | return 1.0f; | ||
1618 | |||
1619 | return 0.5f; | ||
1620 | } | ||
1621 | } | ||
1622 | |||
1623 | public byte PhysicsShapeType | ||
1624 | { | ||
1625 | get { return m_physicsShapeType; } | ||
1626 | set | ||
1627 | { | ||
1628 | byte oldv = m_physicsShapeType; | ||
1629 | |||
1630 | if (value >= 0 && value <= (byte)PhysShapeType.convex) | ||
1631 | { | ||
1632 | if (value == (byte)PhysShapeType.none && ParentGroup != null && ParentGroup.RootPart == this) | ||
1633 | m_physicsShapeType = DefaultPhysicsShapeType(); | ||
1634 | else | ||
1635 | m_physicsShapeType = value; | ||
1636 | } | ||
1637 | else | ||
1638 | m_physicsShapeType = DefaultPhysicsShapeType(); | ||
1639 | |||
1640 | if (m_physicsShapeType != oldv && ParentGroup != null) | ||
1641 | { | ||
1642 | if (m_physicsShapeType == (byte)PhysShapeType.none) | ||
1643 | { | ||
1644 | if (PhysActor != null) | ||
1645 | { | ||
1646 | Velocity = new Vector3(0, 0, 0); | ||
1647 | Acceleration = new Vector3(0, 0, 0); | ||
1648 | if (ParentGroup.RootPart == this) | ||
1649 | AngularVelocity = new Vector3(0, 0, 0); | ||
1650 | ParentGroup.Scene.RemovePhysicalPrim(1); | ||
1651 | RemoveFromPhysics(); | ||
1652 | } | ||
1653 | } | ||
1654 | else if (PhysActor == null) | ||
1655 | { | ||
1656 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); | ||
1657 | UpdatePhysicsSubscribedEvents(); | ||
1658 | } | ||
1659 | else | ||
1660 | { | ||
1661 | PhysActor.PhysicsShapeType = m_physicsShapeType; | ||
1662 | // if (Shape.SculptEntry) | ||
1663 | // CheckSculptAndLoad(); | ||
1664 | } | ||
1665 | |||
1666 | if (ParentGroup != null) | ||
1667 | ParentGroup.HasGroupChanged = true; | ||
1668 | } | ||
1669 | |||
1670 | if (m_physicsShapeType != value) | ||
1671 | { | ||
1672 | UpdatePhysRequired = true; | ||
1673 | } | ||
1674 | } | ||
1675 | } | ||
1676 | |||
1677 | public float Density // in kg/m^3 | ||
1678 | { | ||
1679 | get { return m_density; } | ||
1680 | set | ||
1681 | { | ||
1682 | if (value >=1 && value <= 22587.0) | ||
1683 | { | ||
1684 | m_density = value; | ||
1685 | UpdatePhysRequired = true; | ||
1686 | } | ||
1687 | |||
1688 | ScheduleFullUpdateIfNone(); | ||
1689 | |||
1690 | if (ParentGroup != null) | ||
1691 | ParentGroup.HasGroupChanged = true; | ||
1692 | } | ||
1693 | } | ||
1694 | |||
1695 | public float GravityModifier | ||
1696 | { | ||
1697 | get { return m_gravitymod; } | ||
1698 | set | ||
1699 | { | ||
1700 | if( value >= -1 && value <=28.0f) | ||
1701 | { | ||
1702 | m_gravitymod = value; | ||
1703 | UpdatePhysRequired = true; | ||
1704 | } | ||
1705 | |||
1706 | ScheduleFullUpdateIfNone(); | ||
1707 | |||
1708 | if (ParentGroup != null) | ||
1709 | ParentGroup.HasGroupChanged = true; | ||
1710 | |||
1711 | } | ||
1712 | } | ||
1713 | |||
1714 | public float Friction | ||
1715 | { | ||
1716 | get { return m_friction; } | ||
1717 | set | ||
1718 | { | ||
1719 | if (value >= 0 && value <= 255.0f) | ||
1720 | { | ||
1721 | m_friction = value; | ||
1722 | UpdatePhysRequired = true; | ||
1723 | } | ||
1724 | |||
1725 | ScheduleFullUpdateIfNone(); | ||
1726 | |||
1727 | if (ParentGroup != null) | ||
1728 | ParentGroup.HasGroupChanged = true; | ||
1729 | } | ||
1730 | } | ||
1731 | |||
1732 | public float Bounciness | ||
1733 | { | ||
1734 | get { return m_bounce; } | ||
1735 | set | ||
1736 | { | ||
1737 | if (value >= 0 && value <= 1.0f) | ||
1738 | { | ||
1739 | m_bounce = value; | ||
1740 | UpdatePhysRequired = true; | ||
1741 | } | ||
1742 | |||
1743 | ScheduleFullUpdateIfNone(); | ||
1744 | |||
1745 | if (ParentGroup != null) | ||
1746 | ParentGroup.HasGroupChanged = true; | ||
1747 | } | ||
1748 | } | ||
1749 | |||
1750 | |||
1318 | #endregion Public Properties with only Get | 1751 | #endregion Public Properties with only Get |
1319 | 1752 | ||
1320 | private uint ApplyMask(uint val, bool set, uint mask) | 1753 | private uint ApplyMask(uint val, bool set, uint mask) |
@@ -1460,6 +1893,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1460 | } | 1893 | } |
1461 | } | 1894 | } |
1462 | 1895 | ||
1896 | // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future | ||
1897 | public void SetVelocity(Vector3 pVel, bool localGlobalTF) | ||
1898 | { | ||
1899 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
1900 | return; | ||
1901 | |||
1902 | if (ParentGroup.IsAttachment) | ||
1903 | return; // don't work on attachments (for now ??) | ||
1904 | |||
1905 | SceneObjectPart root = ParentGroup.RootPart; | ||
1906 | |||
1907 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
1908 | return; | ||
1909 | |||
1910 | PhysicsActor pa = root.PhysActor; | ||
1911 | |||
1912 | if (pa == null || !pa.IsPhysical) | ||
1913 | return; | ||
1914 | |||
1915 | if (localGlobalTF) | ||
1916 | { | ||
1917 | pVel = pVel * GetWorldRotation(); | ||
1918 | } | ||
1919 | |||
1920 | ParentGroup.Velocity = pVel; | ||
1921 | } | ||
1922 | |||
1923 | // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future | ||
1924 | public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF) | ||
1925 | { | ||
1926 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
1927 | return; | ||
1928 | |||
1929 | if (ParentGroup.IsAttachment) | ||
1930 | return; // don't work on attachments (for now ??) | ||
1931 | |||
1932 | SceneObjectPart root = ParentGroup.RootPart; | ||
1933 | |||
1934 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
1935 | return; | ||
1936 | |||
1937 | PhysicsActor pa = root.PhysActor; | ||
1938 | |||
1939 | if (pa == null || !pa.IsPhysical) | ||
1940 | return; | ||
1941 | |||
1942 | if (localGlobalTF) | ||
1943 | { | ||
1944 | pAngVel = pAngVel * GetWorldRotation(); | ||
1945 | } | ||
1946 | |||
1947 | root.AngularVelocity = pAngVel; | ||
1948 | } | ||
1949 | |||
1950 | |||
1463 | /// <summary> | 1951 | /// <summary> |
1464 | /// hook to the physics scene to apply angular impulse | 1952 | /// hook to the physics scene to apply angular impulse |
1465 | /// This is sent up to the group, which then finds the root prim | 1953 | /// This is sent up to the group, which then finds the root prim |
@@ -1480,7 +1968,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1480 | impulse = newimpulse; | 1968 | impulse = newimpulse; |
1481 | } | 1969 | } |
1482 | 1970 | ||
1483 | ParentGroup.applyAngularImpulse(impulse); | 1971 | ParentGroup.ApplyAngularImpulse(impulse); |
1484 | } | 1972 | } |
1485 | 1973 | ||
1486 | /// <summary> | 1974 | /// <summary> |
@@ -1490,20 +1978,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1490 | /// </summary> | 1978 | /// </summary> |
1491 | /// <param name="impulsei">Vector force</param> | 1979 | /// <param name="impulsei">Vector force</param> |
1492 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | 1980 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> |
1493 | public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) | 1981 | |
1982 | // this is actualy Set Torque.. keeping naming so not to edit lslapi also | ||
1983 | public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF) | ||
1494 | { | 1984 | { |
1495 | Vector3 impulse = impulsei; | 1985 | Vector3 torque = torquei; |
1496 | 1986 | ||
1497 | if (localGlobalTF) | 1987 | if (localGlobalTF) |
1498 | { | 1988 | { |
1989 | /* | ||
1499 | Quaternion grot = GetWorldRotation(); | 1990 | Quaternion grot = GetWorldRotation(); |
1500 | Quaternion AXgrot = grot; | 1991 | Quaternion AXgrot = grot; |
1501 | Vector3 AXimpulsei = impulsei; | 1992 | Vector3 AXimpulsei = impulsei; |
1502 | Vector3 newimpulse = AXimpulsei * AXgrot; | 1993 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1503 | impulse = newimpulse; | 1994 | */ |
1995 | torque *= GetWorldRotation(); | ||
1504 | } | 1996 | } |
1505 | 1997 | ||
1506 | ParentGroup.setAngularImpulse(impulse); | 1998 | Torque = torque; |
1507 | } | 1999 | } |
1508 | 2000 | ||
1509 | /// <summary> | 2001 | /// <summary> |
@@ -1511,17 +2003,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
1511 | /// </summary> | 2003 | /// </summary> |
1512 | /// <param name="rootObjectFlags"></param> | 2004 | /// <param name="rootObjectFlags"></param> |
1513 | /// <param name="VolumeDetectActive"></param> | 2005 | /// <param name="VolumeDetectActive"></param> |
1514 | public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) | 2006 | /// <param name="building"></param> |
2007 | |||
2008 | public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building) | ||
1515 | { | 2009 | { |
2010 | VolumeDetectActive = _VolumeDetectActive; | ||
2011 | |||
1516 | if (!ParentGroup.Scene.CollidablePrims) | 2012 | if (!ParentGroup.Scene.CollidablePrims) |
1517 | return; | 2013 | return; |
1518 | 2014 | ||
1519 | // m_log.DebugFormat( | 2015 | if (PhysicsShapeType == (byte)PhysShapeType.none) |
1520 | // "[SCENE OBJECT PART]: Applying physics to {0} {1}, m_physicalPrim {2}", | 2016 | return; |
1521 | // Name, LocalId, UUID, m_physicalPrim); | ||
1522 | 2017 | ||
1523 | bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; | 2018 | bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0; |
1524 | bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; | 2019 | bool isPhantom = (_ObjectFlags & (uint)PrimFlags.Phantom) != 0; |
2020 | |||
2021 | if (_VolumeDetectActive) | ||
2022 | isPhantom = true; | ||
1525 | 2023 | ||
1526 | if (IsJoint()) | 2024 | if (IsJoint()) |
1527 | { | 2025 | { |
@@ -1529,22 +2027,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1529 | } | 2027 | } |
1530 | else | 2028 | else |
1531 | { | 2029 | { |
1532 | // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored | 2030 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment |
1533 | if (VolumeDetectActive) | 2031 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) |
1534 | isPhantom = false; | ||
1535 | |||
1536 | // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition | ||
1537 | // or flexible | ||
1538 | if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
1539 | { | 2032 | { |
1540 | // Added clarification.. since A rigid body is an object that you can kick around, etc. | 2033 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); |
1541 | bool rigidBody = isPhysical && !isPhantom; | 2034 | UpdatePhysicsSubscribedEvents(); // not sure if appliable here |
1542 | |||
1543 | PhysicsActor pa = AddToPhysics(rigidBody); | ||
1544 | |||
1545 | if (pa != null) | ||
1546 | pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0); | ||
1547 | } | 2035 | } |
2036 | else | ||
2037 | PhysActor = null; // just to be sure | ||
1548 | } | 2038 | } |
1549 | } | 2039 | } |
1550 | 2040 | ||
@@ -1596,6 +2086,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1596 | dupe.Category = Category; | 2086 | dupe.Category = Category; |
1597 | dupe.m_rezzed = m_rezzed; | 2087 | dupe.m_rezzed = m_rezzed; |
1598 | 2088 | ||
2089 | dupe.m_UndoRedo = null; | ||
2090 | dupe.m_isSelected = false; | ||
2091 | |||
2092 | dupe.IgnoreUndoUpdate = false; | ||
2093 | dupe.Undoing = false; | ||
2094 | |||
1599 | dupe.m_inventory = new SceneObjectPartInventory(dupe); | 2095 | dupe.m_inventory = new SceneObjectPartInventory(dupe); |
1600 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); | 2096 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); |
1601 | 2097 | ||
@@ -1611,6 +2107,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1611 | 2107 | ||
1612 | // Move afterwards ResetIDs as it clears the localID | 2108 | // Move afterwards ResetIDs as it clears the localID |
1613 | dupe.LocalId = localID; | 2109 | dupe.LocalId = localID; |
2110 | |||
1614 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. | 2111 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. |
1615 | dupe.LastOwnerID = OwnerID; | 2112 | dupe.LastOwnerID = OwnerID; |
1616 | 2113 | ||
@@ -1618,6 +2115,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1618 | Array.Copy(Shape.ExtraParams, extraP, extraP.Length); | 2115 | Array.Copy(Shape.ExtraParams, extraP, extraP.Length); |
1619 | dupe.Shape.ExtraParams = extraP; | 2116 | dupe.Shape.ExtraParams = extraP; |
1620 | 2117 | ||
2118 | // safeguard actual copy is done in sog.copy | ||
2119 | dupe.KeyframeMotion = null; | ||
2120 | |||
1621 | if (userExposed) | 2121 | if (userExposed) |
1622 | { | 2122 | { |
1623 | /* | 2123 | /* |
@@ -1629,8 +2129,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1629 | */ | 2129 | */ |
1630 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); | 2130 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); |
1631 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); | 2131 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); |
2132 | // dupe.UpdatePhysicsSubscribedEvents(); // not sure... | ||
1632 | } | 2133 | } |
1633 | 2134 | ||
2135 | if (dupe.PhysActor != null) | ||
2136 | dupe.PhysActor.LocalID = localID; | ||
2137 | |||
1634 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); | 2138 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); |
1635 | 2139 | ||
1636 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); | 2140 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); |
@@ -1649,10 +2153,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1649 | { | 2153 | { |
1650 | if (asset != null) | 2154 | if (asset != null) |
1651 | SculptTextureCallback(asset); | 2155 | SculptTextureCallback(asset); |
1652 | else | 2156 | // else |
1653 | m_log.WarnFormat( | 2157 | // m_log.WarnFormat( |
1654 | "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", | 2158 | // "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", |
1655 | Name, UUID, id); | 2159 | // Name, UUID, id); |
1656 | } | 2160 | } |
1657 | */ | 2161 | */ |
1658 | /// <summary> | 2162 | /// <summary> |
@@ -1751,6 +2255,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1751 | 2255 | ||
1752 | /// <summary> | 2256 | /// <summary> |
1753 | /// Do a physics propery update for this part. | 2257 | /// Do a physics propery update for this part. |
2258 | /// now also updates phantom and volume detector | ||
1754 | /// </summary> | 2259 | /// </summary> |
1755 | /// <param name="UsePhysics"></param> | 2260 | /// <param name="UsePhysics"></param> |
1756 | /// <param name="isNew"></param> | 2261 | /// <param name="isNew"></param> |
@@ -1776,61 +2281,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
1776 | { | 2281 | { |
1777 | if (pa.IsPhysical) // implies UsePhysics==false for this block | 2282 | if (pa.IsPhysical) // implies UsePhysics==false for this block |
1778 | { | 2283 | { |
1779 | if (!isNew) | 2284 | if (!isNew) // implies UsePhysics==false for this block |
2285 | { | ||
1780 | ParentGroup.Scene.RemovePhysicalPrim(1); | 2286 | ParentGroup.Scene.RemovePhysicalPrim(1); |
1781 | 2287 | ||
1782 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | 2288 | Velocity = new Vector3(0, 0, 0); |
1783 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | 2289 | Acceleration = new Vector3(0, 0, 0); |
1784 | pa.delink(); | 2290 | if (ParentGroup.RootPart == this) |
2291 | AngularVelocity = new Vector3(0, 0, 0); | ||
1785 | 2292 | ||
1786 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) | 2293 | if (pa.Phantom && !VolumeDetectActive) |
1787 | { | 2294 | { |
1788 | // destroy all joints connected to this now deactivated body | 2295 | RemoveFromPhysics(); |
1789 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | 2296 | return; |
1790 | } | 2297 | } |
1791 | 2298 | ||
1792 | // stop client-side interpolation of all joint proxy objects that have just been deleted | 2299 | pa.IsPhysical = UsePhysics; |
1793 | // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback, | 2300 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; |
1794 | // which stops client-side interpolation of deactivated joint proxy objects. | 2301 | pa.OnOutOfBounds -= PhysicsOutOfBounds; |
2302 | pa.delink(); | ||
2303 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | ||
2304 | { | ||
2305 | // destroy all joints connected to this now deactivated body | ||
2306 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | ||
2307 | } | ||
2308 | } | ||
1795 | } | 2309 | } |
1796 | 2310 | ||
1797 | if (!UsePhysics && !isNew) | 2311 | if (pa.IsPhysical != UsePhysics) |
1798 | { | 2312 | pa.IsPhysical = UsePhysics; |
1799 | // reset velocity to 0 on physics switch-off. Without that, the client thinks the | ||
1800 | // prim still has velocity and continues to interpolate its position along the old | ||
1801 | // velocity-vector. | ||
1802 | Velocity = new Vector3(0, 0, 0); | ||
1803 | Acceleration = new Vector3(0, 0, 0); | ||
1804 | AngularVelocity = new Vector3(0, 0, 0); | ||
1805 | //RotationalVelocity = new Vector3(0, 0, 0); | ||
1806 | } | ||
1807 | 2313 | ||
1808 | pa.IsPhysical = UsePhysics; | 2314 | if (UsePhysics) |
2315 | { | ||
2316 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
2317 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2318 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2319 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
1809 | 2320 | ||
1810 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. | 2321 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
1811 | //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 2322 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; |
1812 | /// that's not wholesome. Had to make Scene public | ||
1813 | //PhysActor = null; | ||
1814 | 2323 | ||
1815 | if ((Flags & PrimFlags.Phantom) == 0) | 2324 | if (ParentID != 0 && ParentID != LocalId) |
1816 | { | ||
1817 | if (UsePhysics) | ||
1818 | { | 2325 | { |
1819 | ParentGroup.Scene.AddPhysicalPrim(1); | 2326 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; |
1820 | 2327 | ||
1821 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | 2328 | if (parentPa != null) |
1822 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
1823 | if (ParentID != 0 && ParentID != LocalId) | ||
1824 | { | 2329 | { |
1825 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | 2330 | pa.link(parentPa); |
1826 | |||
1827 | if (parentPa != null) | ||
1828 | { | ||
1829 | pa.link(parentPa); | ||
1830 | } | ||
1831 | } | 2331 | } |
1832 | } | 2332 | } |
1833 | } | 2333 | } |
2334 | } | ||
2335 | |||
2336 | bool phan = ((Flags & PrimFlags.Phantom) != 0); | ||
2337 | if (pa.Phantom != phan) | ||
2338 | pa.Phantom = phan; | ||
2339 | |||
2340 | // some engines dont' have this check still | ||
2341 | // if (VolumeDetectActive != pa.IsVolumeDtc) | ||
2342 | { | ||
2343 | if (VolumeDetectActive) | ||
2344 | pa.SetVolumeDetect(1); | ||
2345 | else | ||
2346 | pa.SetVolumeDetect(0); | ||
1834 | } | 2347 | } |
1835 | 2348 | ||
1836 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the | 2349 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the |
@@ -1949,12 +2462,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1949 | 2462 | ||
1950 | public Vector3 GetGeometricCenter() | 2463 | public Vector3 GetGeometricCenter() |
1951 | { | 2464 | { |
1952 | PhysicsActor pa = PhysActor; | 2465 | // this is not real geometric center but a average of positions relative to root prim acording to |
1953 | 2466 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | |
1954 | if (pa != null) | 2467 | // ignoring tortured prims details since sl also seems to ignore |
1955 | return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); | 2468 | // so no real use in doing it on physics |
1956 | else | 2469 | if (ParentGroup.IsDeleted) |
1957 | return new Vector3(0, 0, 0); | 2470 | return new Vector3(0, 0, 0); |
2471 | |||
2472 | return ParentGroup.GetGeometricCenter(); | ||
2473 | |||
2474 | /* | ||
2475 | PhysicsActor pa = PhysActor; | ||
2476 | |||
2477 | if (pa != null) | ||
2478 | { | ||
2479 | Vector3 vtmp = pa.CenterOfMass; | ||
2480 | return vtmp; | ||
2481 | } | ||
2482 | else | ||
2483 | return new Vector3(0, 0, 0); | ||
2484 | */ | ||
1958 | } | 2485 | } |
1959 | 2486 | ||
1960 | public float GetMass() | 2487 | public float GetMass() |
@@ -1967,14 +2494,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1967 | return 0; | 2494 | return 0; |
1968 | } | 2495 | } |
1969 | 2496 | ||
1970 | public Vector3 GetForce() | 2497 | public Vector3 GetCenterOfMass() |
2498 | { | ||
2499 | if (ParentGroup.RootPart == this) | ||
2500 | { | ||
2501 | if (ParentGroup.IsDeleted) | ||
2502 | return AbsolutePosition; | ||
2503 | return ParentGroup.GetCenterOfMass(); | ||
2504 | } | ||
2505 | |||
2506 | PhysicsActor pa = PhysActor; | ||
2507 | |||
2508 | if (pa != null) | ||
2509 | { | ||
2510 | Vector3 tmp = pa.CenterOfMass; | ||
2511 | return tmp; | ||
2512 | } | ||
2513 | else | ||
2514 | return AbsolutePosition; | ||
2515 | } | ||
2516 | |||
2517 | public Vector3 GetPartCenterOfMass() | ||
1971 | { | 2518 | { |
1972 | PhysicsActor pa = PhysActor; | 2519 | PhysicsActor pa = PhysActor; |
1973 | 2520 | ||
1974 | if (pa != null) | 2521 | if (pa != null) |
1975 | return pa.Force; | 2522 | { |
2523 | Vector3 tmp = pa.CenterOfMass; | ||
2524 | return tmp; | ||
2525 | } | ||
1976 | else | 2526 | else |
1977 | return Vector3.Zero; | 2527 | return AbsolutePosition; |
2528 | } | ||
2529 | |||
2530 | |||
2531 | public Vector3 GetForce() | ||
2532 | { | ||
2533 | return Force; | ||
1978 | } | 2534 | } |
1979 | 2535 | ||
1980 | /// <summary> | 2536 | /// <summary> |
@@ -2189,15 +2745,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2189 | 2745 | ||
2190 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) | 2746 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) |
2191 | { | 2747 | { |
2192 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) | 2748 | bool sendToRoot = true; |
2193 | { | 2749 | |
2194 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | 2750 | ColliderArgs LandCollidingMessage = new ColliderArgs(); |
2195 | List<DetectedObject> colliding = new List<DetectedObject>(); | 2751 | List<DetectedObject> colliding = new List<DetectedObject>(); |
2196 | 2752 | ||
2197 | colliding.Add(CreateDetObjectForGround()); | 2753 | colliding.Add(CreateDetObjectForGround()); |
2198 | LandCollidingMessage.Colliders = colliding; | 2754 | LandCollidingMessage.Colliders = colliding; |
2199 | 2755 | ||
2756 | if (Inventory.ContainsScripts()) | ||
2757 | { | ||
2758 | if (!PassCollisions) | ||
2759 | sendToRoot = false; | ||
2760 | } | ||
2761 | if ((ScriptEvents & ev) != 0) | ||
2200 | notify(LocalId, LandCollidingMessage); | 2762 | notify(LocalId, LandCollidingMessage); |
2763 | |||
2764 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot) | ||
2765 | { | ||
2766 | notify(ParentGroup.RootPart.LocalId, LandCollidingMessage); | ||
2201 | } | 2767 | } |
2202 | } | 2768 | } |
2203 | 2769 | ||
@@ -2213,57 +2779,120 @@ namespace OpenSim.Region.Framework.Scenes | |||
2213 | List<uint> endedColliders = new List<uint>(); | 2779 | List<uint> endedColliders = new List<uint>(); |
2214 | List<uint> startedColliders = new List<uint>(); | 2780 | List<uint> startedColliders = new List<uint>(); |
2215 | 2781 | ||
2216 | // calculate things that started colliding this time | 2782 | if (collissionswith.Count == 0) |
2217 | // and build up list of colliders this time | ||
2218 | foreach (uint localid in collissionswith.Keys) | ||
2219 | { | 2783 | { |
2220 | thisHitColliders.Add(localid); | 2784 | if (m_lastColliders.Count == 0) |
2221 | if (!m_lastColliders.Contains(localid)) | 2785 | return; // nothing to do |
2222 | startedColliders.Add(localid); | ||
2223 | } | ||
2224 | 2786 | ||
2225 | // calculate things that ended colliding | 2787 | foreach (uint localID in m_lastColliders) |
2226 | foreach (uint localID in m_lastColliders) | 2788 | { |
2227 | { | ||
2228 | if (!thisHitColliders.Contains(localID)) | ||
2229 | endedColliders.Add(localID); | 2789 | endedColliders.Add(localID); |
2790 | } | ||
2791 | m_lastColliders.Clear(); | ||
2230 | } | 2792 | } |
2231 | 2793 | ||
2232 | //add the items that started colliding this time to the last colliders list. | 2794 | else |
2233 | foreach (uint localID in startedColliders) | 2795 | { |
2234 | m_lastColliders.Add(localID); | 2796 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); |
2235 | 2797 | ||
2236 | // remove things that ended colliding from the last colliders list | 2798 | // calculate things that started colliding this time |
2237 | foreach (uint localID in endedColliders) | 2799 | // and build up list of colliders this time |
2238 | m_lastColliders.Remove(localID); | 2800 | if (!VolumeDetectActive && CollisionSoundType >= 0) |
2801 | { | ||
2802 | CollisionForSoundInfo soundinfo; | ||
2803 | ContactPoint curcontact; | ||
2239 | 2804 | ||
2240 | // play the sound. | 2805 | foreach (uint id in collissionswith.Keys) |
2241 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) | 2806 | { |
2242 | { | 2807 | thisHitColliders.Add(id); |
2243 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | 2808 | if (!m_lastColliders.Contains(id)) |
2244 | if (soundModule != null) | 2809 | { |
2810 | startedColliders.Add(id); | ||
2811 | |||
2812 | curcontact = collissionswith[id]; | ||
2813 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
2814 | { | ||
2815 | soundinfo = new CollisionForSoundInfo(); | ||
2816 | soundinfo.colliderID = id; | ||
2817 | soundinfo.position = curcontact.Position; | ||
2818 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2819 | soundinfolist.Add(soundinfo); | ||
2820 | } | ||
2821 | } | ||
2822 | } | ||
2823 | } | ||
2824 | else | ||
2825 | { | ||
2826 | foreach (uint id in collissionswith.Keys) | ||
2827 | { | ||
2828 | thisHitColliders.Add(id); | ||
2829 | if (!m_lastColliders.Contains(id)) | ||
2830 | startedColliders.Add(id); | ||
2831 | } | ||
2832 | } | ||
2833 | |||
2834 | // calculate things that ended colliding | ||
2835 | foreach (uint localID in m_lastColliders) | ||
2245 | { | 2836 | { |
2246 | soundModule.SendSound(UUID, CollisionSound, | 2837 | if (!thisHitColliders.Contains(localID)) |
2247 | CollisionSoundVolume, true, (byte)0, 0, false, | 2838 | endedColliders.Add(localID); |
2248 | false); | ||
2249 | } | 2839 | } |
2840 | |||
2841 | //add the items that started colliding this time to the last colliders list. | ||
2842 | foreach (uint localID in startedColliders) | ||
2843 | m_lastColliders.Add(localID); | ||
2844 | |||
2845 | // remove things that ended colliding from the last colliders list | ||
2846 | foreach (uint localID in endedColliders) | ||
2847 | m_lastColliders.Remove(localID); | ||
2848 | |||
2849 | // play sounds. | ||
2850 | if (soundinfolist.Count > 0) | ||
2851 | CollisionSounds.PartCollisionSound(this, soundinfolist); | ||
2250 | } | 2852 | } |
2251 | 2853 | ||
2252 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2854 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2253 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2855 | if (!VolumeDetectActive) |
2856 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | ||
2254 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2857 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2255 | 2858 | ||
2256 | if (startedColliders.Contains(0)) | 2859 | if (startedColliders.Contains(0)) |
2257 | { | 2860 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); |
2258 | if (m_lastColliders.Contains(0)) | 2861 | if (m_lastColliders.Contains(0)) |
2259 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); | 2862 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); |
2260 | else | ||
2261 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); | ||
2262 | } | ||
2263 | if (endedColliders.Contains(0)) | 2863 | if (endedColliders.Contains(0)) |
2264 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); | 2864 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); |
2265 | } | 2865 | } |
2266 | 2866 | ||
2867 | // The Collision sounds code calls this | ||
2868 | public void SendCollisionSound(UUID soundID, double volume, Vector3 position) | ||
2869 | { | ||
2870 | if (soundID == UUID.Zero) | ||
2871 | return; | ||
2872 | |||
2873 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | ||
2874 | if (soundModule == null) | ||
2875 | return; | ||
2876 | |||
2877 | if (volume > 1) | ||
2878 | volume = 1; | ||
2879 | if (volume < 0) | ||
2880 | volume = 0; | ||
2881 | |||
2882 | int now = Util.EnvironmentTickCount(); | ||
2883 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) | ||
2884 | return; | ||
2885 | |||
2886 | LastColSoundSentTime = now; | ||
2887 | |||
2888 | UUID ownerID = OwnerID; | ||
2889 | UUID objectID = ParentGroup.RootPart.UUID; | ||
2890 | UUID parentID = ParentGroup.UUID; | ||
2891 | ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; | ||
2892 | |||
2893 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 ); | ||
2894 | } | ||
2895 | |||
2267 | public void PhysicsOutOfBounds(Vector3 pos) | 2896 | public void PhysicsOutOfBounds(Vector3 pos) |
2268 | { | 2897 | { |
2269 | m_log.Error("[PHYSICS]: Physical Object went out of bounds."); | 2898 | m_log.Error("[PHYSICS]: Physical Object went out of bounds."); |
@@ -2282,9 +2911,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2282 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | 2911 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); |
2283 | 2912 | ||
2284 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | 2913 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) |
2285 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | 2914 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) |
2286 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | 2915 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) |
2287 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) | 2916 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) |
2288 | { | 2917 | { |
2289 | ParentGroup.AbsolutePosition = newpos; | 2918 | ParentGroup.AbsolutePosition = newpos; |
2290 | return; | 2919 | return; |
@@ -2411,6 +3040,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2411 | APIDTarget = Quaternion.Identity; | 3040 | APIDTarget = Quaternion.Identity; |
2412 | } | 3041 | } |
2413 | 3042 | ||
3043 | |||
3044 | |||
3045 | public void ScheduleFullUpdateIfNone() | ||
3046 | { | ||
3047 | if (ParentGroup == null) | ||
3048 | return; | ||
3049 | |||
3050 | // ??? ParentGroup.HasGroupChanged = true; | ||
3051 | |||
3052 | if (UpdateFlag != UpdateRequired.FULL) | ||
3053 | ScheduleFullUpdate(); | ||
3054 | } | ||
3055 | |||
2414 | /// <summary> | 3056 | /// <summary> |
2415 | /// Schedules this prim for a full update | 3057 | /// Schedules this prim for a full update |
2416 | /// </summary> | 3058 | /// </summary> |
@@ -2614,8 +3256,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2614 | { | 3256 | { |
2615 | const float ROTATION_TOLERANCE = 0.01f; | 3257 | const float ROTATION_TOLERANCE = 0.01f; |
2616 | const float VELOCITY_TOLERANCE = 0.001f; | 3258 | const float VELOCITY_TOLERANCE = 0.001f; |
2617 | const float POSITION_TOLERANCE = 0.05f; | 3259 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
2618 | const int TIME_MS_TOLERANCE = 3000; | 3260 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
2619 | 3261 | ||
2620 | switch (UpdateFlag) | 3262 | switch (UpdateFlag) |
2621 | { | 3263 | { |
@@ -2657,6 +3299,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2657 | /// </summary> | 3299 | /// </summary> |
2658 | public void SendTerseUpdateToAllClients() | 3300 | public void SendTerseUpdateToAllClients() |
2659 | { | 3301 | { |
3302 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3303 | return; | ||
3304 | |||
2660 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | 3305 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) |
2661 | { | 3306 | { |
2662 | SendTerseUpdateToClient(client); | 3307 | SendTerseUpdateToClient(client); |
@@ -2680,10 +3325,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2680 | 3325 | ||
2681 | public void SetBuoyancy(float fvalue) | 3326 | public void SetBuoyancy(float fvalue) |
2682 | { | 3327 | { |
2683 | PhysicsActor pa = PhysActor; | 3328 | Buoyancy = fvalue; |
2684 | 3329 | /* | |
2685 | if (pa != null) | 3330 | if (PhysActor != null) |
2686 | pa.Buoyancy = fvalue; | 3331 | { |
3332 | PhysActor.Buoyancy = fvalue; | ||
3333 | } | ||
3334 | */ | ||
2687 | } | 3335 | } |
2688 | 3336 | ||
2689 | public void SetDieAtEdge(bool p) | 3337 | public void SetDieAtEdge(bool p) |
@@ -2699,47 +3347,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2699 | PhysicsActor pa = PhysActor; | 3347 | PhysicsActor pa = PhysActor; |
2700 | 3348 | ||
2701 | if (pa != null) | 3349 | if (pa != null) |
2702 | pa.FloatOnWater = floatYN == 1; | 3350 | pa.FloatOnWater = (floatYN == 1); |
2703 | } | 3351 | } |
2704 | 3352 | ||
2705 | public void SetForce(Vector3 force) | 3353 | public void SetForce(Vector3 force) |
2706 | { | 3354 | { |
2707 | PhysicsActor pa = PhysActor; | 3355 | Force = force; |
3356 | } | ||
2708 | 3357 | ||
2709 | if (pa != null) | 3358 | public SOPVehicle VehicleParams |
2710 | pa.Force = force; | 3359 | { |
3360 | get | ||
3361 | { | ||
3362 | return m_vehicleParams; | ||
3363 | } | ||
3364 | set | ||
3365 | { | ||
3366 | m_vehicleParams = value; | ||
3367 | } | ||
3368 | } | ||
3369 | |||
3370 | |||
3371 | public int VehicleType | ||
3372 | { | ||
3373 | get | ||
3374 | { | ||
3375 | if (m_vehicleParams == null) | ||
3376 | return (int)Vehicle.TYPE_NONE; | ||
3377 | else | ||
3378 | return (int)m_vehicleParams.Type; | ||
3379 | } | ||
3380 | set | ||
3381 | { | ||
3382 | SetVehicleType(value); | ||
3383 | } | ||
2711 | } | 3384 | } |
2712 | 3385 | ||
2713 | public void SetVehicleType(int type) | 3386 | public void SetVehicleType(int type) |
2714 | { | 3387 | { |
2715 | PhysicsActor pa = PhysActor; | 3388 | m_vehicleParams = null; |
3389 | |||
3390 | if (type == (int)Vehicle.TYPE_NONE) | ||
3391 | { | ||
3392 | if (_parentID ==0 && PhysActor != null) | ||
3393 | PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; | ||
3394 | return; | ||
3395 | } | ||
3396 | m_vehicleParams = new SOPVehicle(); | ||
3397 | m_vehicleParams.ProcessTypeChange((Vehicle)type); | ||
3398 | { | ||
3399 | if (_parentID ==0 && PhysActor != null) | ||
3400 | PhysActor.VehicleType = type; | ||
3401 | return; | ||
3402 | } | ||
3403 | } | ||
2716 | 3404 | ||
2717 | if (pa != null) | 3405 | public void SetVehicleFlags(int param, bool remove) |
2718 | pa.VehicleType = type; | 3406 | { |
3407 | if (m_vehicleParams == null) | ||
3408 | return; | ||
3409 | |||
3410 | m_vehicleParams.ProcessVehicleFlags(param, remove); | ||
3411 | |||
3412 | if (_parentID ==0 && PhysActor != null) | ||
3413 | { | ||
3414 | PhysActor.VehicleFlags(param, remove); | ||
3415 | } | ||
2719 | } | 3416 | } |
2720 | 3417 | ||
2721 | public void SetVehicleFloatParam(int param, float value) | 3418 | public void SetVehicleFloatParam(int param, float value) |
2722 | { | 3419 | { |
2723 | PhysicsActor pa = PhysActor; | 3420 | if (m_vehicleParams == null) |
3421 | return; | ||
2724 | 3422 | ||
2725 | if (pa != null) | 3423 | m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value); |
2726 | pa.VehicleFloatParam(param, value); | 3424 | |
3425 | if (_parentID == 0 && PhysActor != null) | ||
3426 | { | ||
3427 | PhysActor.VehicleFloatParam(param, value); | ||
3428 | } | ||
2727 | } | 3429 | } |
2728 | 3430 | ||
2729 | public void SetVehicleVectorParam(int param, Vector3 value) | 3431 | public void SetVehicleVectorParam(int param, Vector3 value) |
2730 | { | 3432 | { |
2731 | PhysicsActor pa = PhysActor; | 3433 | if (m_vehicleParams == null) |
3434 | return; | ||
2732 | 3435 | ||
2733 | if (pa != null) | 3436 | m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value); |
2734 | pa.VehicleVectorParam(param, value); | 3437 | |
3438 | if (_parentID == 0 && PhysActor != null) | ||
3439 | { | ||
3440 | PhysActor.VehicleVectorParam(param, value); | ||
3441 | } | ||
2735 | } | 3442 | } |
2736 | 3443 | ||
2737 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 3444 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
2738 | { | 3445 | { |
2739 | PhysicsActor pa = PhysActor; | 3446 | if (m_vehicleParams == null) |
3447 | return; | ||
2740 | 3448 | ||
2741 | if (pa != null) | 3449 | m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation); |
2742 | pa.VehicleRotationParam(param, rotation); | 3450 | |
3451 | if (_parentID == 0 && PhysActor != null) | ||
3452 | { | ||
3453 | PhysActor.VehicleRotationParam(param, rotation); | ||
3454 | } | ||
2743 | } | 3455 | } |
2744 | 3456 | ||
2745 | /// <summary> | 3457 | /// <summary> |
@@ -2940,14 +3652,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2940 | hasProfileCut = hasDimple; // is it the same thing? | 3652 | hasProfileCut = hasDimple; // is it the same thing? |
2941 | } | 3653 | } |
2942 | 3654 | ||
2943 | public void SetVehicleFlags(int param, bool remove) | ||
2944 | { | ||
2945 | PhysicsActor pa = PhysActor; | ||
2946 | |||
2947 | if (pa != null) | ||
2948 | pa.VehicleFlags(param, remove); | ||
2949 | } | ||
2950 | |||
2951 | public void SetGroup(UUID groupID, IClientAPI client) | 3655 | public void SetGroup(UUID groupID, IClientAPI client) |
2952 | { | 3656 | { |
2953 | // Scene.AddNewPrims() calls with client == null so can't use this. | 3657 | // Scene.AddNewPrims() calls with client == null so can't use this. |
@@ -3051,67 +3755,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3051 | //ParentGroup.ScheduleGroupForFullUpdate(); | 3755 | //ParentGroup.ScheduleGroupForFullUpdate(); |
3052 | } | 3756 | } |
3053 | 3757 | ||
3054 | public void StoreUndoState() | 3758 | public void StoreUndoState(ObjectChangeType change) |
3055 | { | ||
3056 | StoreUndoState(false); | ||
3057 | } | ||
3058 | |||
3059 | public void StoreUndoState(bool forGroup) | ||
3060 | { | 3759 | { |
3061 | if (ParentGroup == null || ParentGroup.Scene == null) | 3760 | if (m_UndoRedo == null) |
3062 | return; | 3761 | m_UndoRedo = new UndoRedoState(5); |
3063 | |||
3064 | if (Undoing) | ||
3065 | { | ||
3066 | // m_log.DebugFormat( | ||
3067 | // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); | ||
3068 | return; | ||
3069 | } | ||
3070 | |||
3071 | if (IgnoreUndoUpdate) | ||
3072 | { | ||
3073 | // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); | ||
3074 | return; | ||
3075 | } | ||
3076 | 3762 | ||
3077 | lock (m_undo) | 3763 | lock (m_UndoRedo) |
3078 | { | 3764 | { |
3079 | if (m_undo.Count > 0) | 3765 | if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended |
3080 | { | 3766 | { |
3081 | UndoState last = m_undo[m_undo.Count - 1]; | 3767 | m_UndoRedo.StoreUndo(this, change); |
3082 | if (last != null) | ||
3083 | { | ||
3084 | // TODO: May need to fix for group comparison | ||
3085 | if (last.Compare(this)) | ||
3086 | { | ||
3087 | // m_log.DebugFormat( | ||
3088 | // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", | ||
3089 | // Name, LocalId, m_undo.Count); | ||
3090 | |||
3091 | return; | ||
3092 | } | ||
3093 | } | ||
3094 | } | ||
3095 | |||
3096 | // m_log.DebugFormat( | ||
3097 | // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", | ||
3098 | // Name, LocalId, forGroup, m_undo.Count); | ||
3099 | |||
3100 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3101 | { | ||
3102 | UndoState nUndo = new UndoState(this, forGroup); | ||
3103 | |||
3104 | m_undo.Add(nUndo); | ||
3105 | |||
3106 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3107 | m_undo.RemoveAt(0); | ||
3108 | |||
3109 | if (m_redo.Count > 0) | ||
3110 | m_redo.Clear(); | ||
3111 | |||
3112 | // m_log.DebugFormat( | ||
3113 | // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", | ||
3114 | // Name, LocalId, forGroup, m_undo.Count); | ||
3115 | } | 3768 | } |
3116 | } | 3769 | } |
3117 | } | 3770 | } |
@@ -3123,88 +3776,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
3123 | { | 3776 | { |
3124 | get | 3777 | get |
3125 | { | 3778 | { |
3126 | lock (m_undo) | 3779 | if (m_UndoRedo == null) |
3127 | return m_undo.Count; | 3780 | return 0; |
3781 | return m_UndoRedo.Count; | ||
3128 | } | 3782 | } |
3129 | } | 3783 | } |
3130 | 3784 | ||
3131 | public void Undo() | 3785 | public void Undo() |
3132 | { | 3786 | { |
3133 | lock (m_undo) | 3787 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3134 | { | 3788 | return; |
3135 | // m_log.DebugFormat( | ||
3136 | // "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}", | ||
3137 | // Name, LocalId, m_undo.Count); | ||
3138 | |||
3139 | if (m_undo.Count > 0) | ||
3140 | { | ||
3141 | UndoState goback = m_undo[m_undo.Count - 1]; | ||
3142 | m_undo.RemoveAt(m_undo.Count - 1); | ||
3143 | |||
3144 | UndoState nUndo = null; | ||
3145 | |||
3146 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3147 | { | ||
3148 | nUndo = new UndoState(this, goback.ForGroup); | ||
3149 | } | ||
3150 | |||
3151 | goback.PlaybackState(this); | ||
3152 | |||
3153 | if (nUndo != null) | ||
3154 | { | ||
3155 | m_redo.Add(nUndo); | ||
3156 | |||
3157 | if (m_redo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3158 | m_redo.RemoveAt(0); | ||
3159 | } | ||
3160 | } | ||
3161 | 3789 | ||
3162 | // m_log.DebugFormat( | 3790 | lock (m_UndoRedo) |
3163 | // "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", | 3791 | { |
3164 | // Name, LocalId, m_undo.Count); | 3792 | Undoing = true; |
3793 | m_UndoRedo.Undo(this); | ||
3794 | Undoing = false; | ||
3165 | } | 3795 | } |
3166 | } | 3796 | } |
3167 | 3797 | ||
3168 | public void Redo() | 3798 | public void Redo() |
3169 | { | 3799 | { |
3170 | lock (m_undo) | 3800 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3171 | { | 3801 | return; |
3172 | // m_log.DebugFormat( | ||
3173 | // "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}", | ||
3174 | // Name, LocalId, m_redo.Count); | ||
3175 | |||
3176 | if (m_redo.Count > 0) | ||
3177 | { | ||
3178 | UndoState gofwd = m_redo[m_redo.Count - 1]; | ||
3179 | m_redo.RemoveAt(m_redo.Count - 1); | ||
3180 | |||
3181 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3182 | { | ||
3183 | UndoState nUndo = new UndoState(this, gofwd.ForGroup); | ||
3184 | |||
3185 | m_undo.Add(nUndo); | ||
3186 | |||
3187 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3188 | m_undo.RemoveAt(0); | ||
3189 | } | ||
3190 | |||
3191 | gofwd.PlayfwdState(this); | ||
3192 | 3802 | ||
3193 | // m_log.DebugFormat( | 3803 | lock (m_UndoRedo) |
3194 | // "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", | 3804 | { |
3195 | // Name, LocalId, m_redo.Count); | 3805 | Undoing = true; |
3196 | } | 3806 | m_UndoRedo.Redo(this); |
3807 | Undoing = false; | ||
3197 | } | 3808 | } |
3198 | } | 3809 | } |
3199 | 3810 | ||
3200 | public void ClearUndoState() | 3811 | public void ClearUndoState() |
3201 | { | 3812 | { |
3202 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); | 3813 | if (m_UndoRedo == null || Undoing) |
3814 | return; | ||
3203 | 3815 | ||
3204 | lock (m_undo) | 3816 | lock (m_UndoRedo) |
3205 | { | 3817 | { |
3206 | m_undo.Clear(); | 3818 | m_UndoRedo.Clear(); |
3207 | m_redo.Clear(); | ||
3208 | } | 3819 | } |
3209 | } | 3820 | } |
3210 | 3821 | ||
@@ -3754,7 +4365,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3754 | if (god) | 4365 | if (god) |
3755 | { | 4366 | { |
3756 | BaseMask = ApplyMask(BaseMask, set, mask); | 4367 | BaseMask = ApplyMask(BaseMask, set, mask); |
3757 | Inventory.ApplyGodPermissions(_baseMask); | 4368 | Inventory.ApplyGodPermissions(BaseMask); |
3758 | } | 4369 | } |
3759 | 4370 | ||
3760 | break; | 4371 | break; |
@@ -3773,7 +4384,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3773 | case 16: | 4384 | case 16: |
3774 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & | 4385 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & |
3775 | baseMask; | 4386 | baseMask; |
3776 | // Prevent the client from creating no mod, no copy | 4387 | // Prevent the client from creating no copy, no transfer |
3777 | // objects | 4388 | // objects |
3778 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) | 4389 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) |
3779 | NextOwnerMask |= (uint)PermissionMask.Transfer; | 4390 | NextOwnerMask |= (uint)PermissionMask.Transfer; |
@@ -3791,20 +4402,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3791 | { | 4402 | { |
3792 | bool update = false; | 4403 | bool update = false; |
3793 | 4404 | ||
3794 | if (BaseMask != source.BaseMask || | 4405 | uint prevOwnerMask = OwnerMask; |
3795 | OwnerMask != source.OwnerMask || | 4406 | uint prevGroupMask = GroupMask; |
3796 | GroupMask != source.GroupMask || | 4407 | uint prevEveryoneMask = EveryoneMask; |
3797 | EveryoneMask != source.EveryoneMask || | 4408 | uint prevNextOwnerMask = NextOwnerMask; |
3798 | NextOwnerMask != source.NextOwnerMask) | ||
3799 | update = true; | ||
3800 | 4409 | ||
3801 | BaseMask = source.BaseMask; | 4410 | OwnerMask = source.OwnerMask & BaseMask; |
3802 | OwnerMask = source.OwnerMask; | 4411 | GroupMask = source.GroupMask & BaseMask; |
3803 | GroupMask = source.GroupMask; | 4412 | EveryoneMask = source.EveryoneMask & BaseMask; |
3804 | EveryoneMask = source.EveryoneMask; | 4413 | NextOwnerMask = source.NextOwnerMask & BaseMask; |
3805 | NextOwnerMask = source.NextOwnerMask; | ||
3806 | 4414 | ||
3807 | if (update) | 4415 | if (OwnerMask != prevOwnerMask || |
4416 | GroupMask != prevGroupMask || | ||
4417 | EveryoneMask != prevEveryoneMask || | ||
4418 | NextOwnerMask != prevNextOwnerMask) | ||
3808 | SendFullUpdateToAllClients(); | 4419 | SendFullUpdateToAllClients(); |
3809 | } | 4420 | } |
3810 | 4421 | ||
@@ -3855,6 +4466,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3855 | } | 4466 | } |
3856 | } | 4467 | } |
3857 | 4468 | ||
4469 | |||
4470 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) | ||
4471 | { | ||
4472 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) | ||
4473 | return; | ||
4474 | |||
4475 | if (PhysicsShapeType != (byte)physdata.PhysShapeType) | ||
4476 | { | ||
4477 | PhysicsShapeType = (byte)physdata.PhysShapeType; | ||
4478 | |||
4479 | } | ||
4480 | |||
4481 | if(Density != physdata.Density) | ||
4482 | Density = physdata.Density; | ||
4483 | if(GravityModifier != physdata.GravitationModifier) | ||
4484 | GravityModifier = physdata.GravitationModifier; | ||
4485 | if(Friction != physdata.Friction) | ||
4486 | Friction = physdata.Friction; | ||
4487 | if(Bounciness != physdata.Bounce) | ||
4488 | Bounciness = physdata.Bounce; | ||
4489 | } | ||
3858 | /// <summary> | 4490 | /// <summary> |
3859 | /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. | 4491 | /// Update the flags on this prim. This covers properties such as phantom, physics and temporary. |
3860 | /// </summary> | 4492 | /// </summary> |
@@ -3862,7 +4494,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3862 | /// <param name="SetTemporary"></param> | 4494 | /// <param name="SetTemporary"></param> |
3863 | /// <param name="SetPhantom"></param> | 4495 | /// <param name="SetPhantom"></param> |
3864 | /// <param name="SetVD"></param> | 4496 | /// <param name="SetVD"></param> |
3865 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) | 4497 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) |
3866 | { | 4498 | { |
3867 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); | 4499 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); |
3868 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); | 4500 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); |
@@ -3872,213 +4504,230 @@ namespace OpenSim.Region.Framework.Scenes | |||
3872 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) | 4504 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) |
3873 | return; | 4505 | return; |
3874 | 4506 | ||
3875 | PhysicsActor pa = PhysActor; | 4507 | VolumeDetectActive = SetVD; |
3876 | |||
3877 | // Special cases for VD. VD can only be called from a script | ||
3878 | // and can't be combined with changes to other states. So we can rely | ||
3879 | // that... | ||
3880 | // ... if VD is changed, all others are not. | ||
3881 | // ... if one of the others is changed, VD is not. | ||
3882 | if (SetVD) // VD is active, special logic applies | ||
3883 | { | ||
3884 | // State machine logic for VolumeDetect | ||
3885 | // More logic below | ||
3886 | bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; | ||
3887 | |||
3888 | if (phanReset) // Phantom changes from on to off switch VD off too | ||
3889 | { | ||
3890 | SetVD = false; // Switch it of for the course of this routine | ||
3891 | VolumeDetectActive = false; // and also permanently | ||
3892 | |||
3893 | if (pa != null) | ||
3894 | pa.SetVolumeDetect(0); // Let physics know about it too | ||
3895 | } | ||
3896 | else | ||
3897 | { | ||
3898 | // If volumedetect is active we don't want phantom to be applied. | ||
3899 | // If this is a new call to VD out of the state "phantom" | ||
3900 | // this will also cause the prim to be visible to physics | ||
3901 | SetPhantom = false; | ||
3902 | } | ||
3903 | } | ||
3904 | 4508 | ||
3905 | if (UsePhysics && IsJoint()) | 4509 | // volume detector implies phantom |
3906 | { | 4510 | if (VolumeDetectActive) |
3907 | SetPhantom = true; | 4511 | SetPhantom = true; |
3908 | } | ||
3909 | 4512 | ||
3910 | if (UsePhysics) | 4513 | if (UsePhysics) |
3911 | { | ||
3912 | AddFlag(PrimFlags.Physics); | 4514 | AddFlag(PrimFlags.Physics); |
3913 | if (!wasUsingPhysics) | ||
3914 | { | ||
3915 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
3916 | } | ||
3917 | } | ||
3918 | else | 4515 | else |
3919 | { | ||
3920 | RemFlag(PrimFlags.Physics); | 4516 | RemFlag(PrimFlags.Physics); |
3921 | if (wasUsingPhysics) | ||
3922 | { | ||
3923 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
3924 | } | ||
3925 | } | ||
3926 | 4517 | ||
3927 | if (SetPhantom | 4518 | if (SetPhantom) |
3928 | || ParentGroup.IsAttachment | ||
3929 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints | ||
3930 | { | ||
3931 | AddFlag(PrimFlags.Phantom); | 4519 | AddFlag(PrimFlags.Phantom); |
3932 | 4520 | else | |
3933 | if (PhysActor != null) | ||
3934 | { | ||
3935 | RemoveFromPhysics(); | ||
3936 | pa = null; | ||
3937 | } | ||
3938 | } | ||
3939 | else // Not phantom | ||
3940 | { | ||
3941 | RemFlag(PrimFlags.Phantom); | 4521 | RemFlag(PrimFlags.Phantom); |
3942 | 4522 | ||
3943 | if (ParentGroup.Scene == null) | 4523 | if (SetTemporary) |
3944 | return; | 4524 | AddFlag(PrimFlags.TemporaryOnRez); |
4525 | else | ||
4526 | RemFlag(PrimFlags.TemporaryOnRez); | ||
3945 | 4527 | ||
3946 | if (ParentGroup.Scene.CollidablePrims && pa == null) | ||
3947 | { | ||
3948 | pa = AddToPhysics(UsePhysics); | ||
3949 | 4528 | ||
3950 | if (pa != null) | 4529 | if (ParentGroup.Scene == null) |
3951 | { | 4530 | return; |
3952 | pa.SetMaterial(Material); | 4531 | |
3953 | DoPhysicsPropertyUpdate(UsePhysics, true); | 4532 | PhysicsActor pa = PhysActor; |
3954 | |||
3955 | if ( | ||
3956 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
3957 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
3958 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
3959 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
3960 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
3961 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
3962 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
3963 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
3964 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
3965 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
3966 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
3967 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
3968 | (CollisionSound != UUID.Zero) | ||
3969 | ) | ||
3970 | { | ||
3971 | pa.OnCollisionUpdate += PhysicsCollision; | ||
3972 | pa.SubscribeEvents(1000); | ||
3973 | } | ||
3974 | } | ||
3975 | } | ||
3976 | else // it already has a physical representation | ||
3977 | { | ||
3978 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim | ||
3979 | } | ||
3980 | } | ||
3981 | 4533 | ||
3982 | if (SetVD) | 4534 | if (pa != null && building && pa.Building != building) |
4535 | pa.Building = building; | ||
4536 | |||
4537 | if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none | ||
4538 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
3983 | { | 4539 | { |
3984 | // If the above logic worked (this is urgent candidate to unit tests!) | ||
3985 | // we now have a physicsactor. | ||
3986 | // Defensive programming calls for a check here. | ||
3987 | // Better would be throwing an exception that could be catched by a unit test as the internal | ||
3988 | // logic should make sure, this Physactor is always here. | ||
3989 | if (pa != null) | 4540 | if (pa != null) |
3990 | { | 4541 | { |
3991 | pa.SetVolumeDetect(1); | 4542 | if(wasUsingPhysics) |
3992 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 4543 | ParentGroup.Scene.RemovePhysicalPrim(1); |
3993 | VolumeDetectActive = true; | 4544 | RemoveFromPhysics(); |
3994 | } | 4545 | } |
4546 | |||
4547 | Velocity = new Vector3(0, 0, 0); | ||
4548 | Acceleration = new Vector3(0, 0, 0); | ||
4549 | if (ParentGroup.RootPart == this) | ||
4550 | AngularVelocity = new Vector3(0, 0, 0); | ||
3995 | } | 4551 | } |
3996 | else | 4552 | else |
3997 | { | 4553 | { |
3998 | // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like | 4554 | if (ParentGroup.Scene.CollidablePrims) |
3999 | // (mumbles, well, at least if you have infinte CPU powers :-)) | 4555 | { |
4000 | if (pa != null) | 4556 | if (pa == null) |
4001 | pa.SetVolumeDetect(0); | 4557 | { |
4558 | AddToPhysics(UsePhysics, SetPhantom, building, false); | ||
4559 | pa = PhysActor; | ||
4560 | /* | ||
4561 | if (pa != null) | ||
4562 | { | ||
4563 | if ( | ||
4564 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4565 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4566 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4567 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4568 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4569 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4570 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4571 | ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4572 | (CollisionSound != UUID.Zero) | ||
4573 | ) | ||
4574 | { | ||
4575 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4576 | pa.SubscribeEvents(1000); | ||
4577 | } | ||
4578 | } | ||
4579 | */ | ||
4580 | } | ||
4581 | else // it already has a physical representation | ||
4582 | { | ||
4583 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. | ||
4584 | /* moved into DoPhysicsPropertyUpdate | ||
4585 | if(VolumeDetectActive) | ||
4586 | pa.SetVolumeDetect(1); | ||
4587 | else | ||
4588 | pa.SetVolumeDetect(0); | ||
4589 | */ | ||
4002 | 4590 | ||
4003 | VolumeDetectActive = false; | 4591 | if (pa.Building != building) |
4004 | } | 4592 | pa.Building = building; |
4593 | } | ||
4005 | 4594 | ||
4006 | if (SetTemporary) | 4595 | UpdatePhysicsSubscribedEvents(); |
4007 | { | 4596 | } |
4008 | AddFlag(PrimFlags.TemporaryOnRez); | 4597 | } |
4009 | } | ||
4010 | else | ||
4011 | { | ||
4012 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4013 | } | ||
4014 | 4598 | ||
4015 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | 4599 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); |
4016 | 4600 | ||
4601 | // and last in case we have a new actor and not building | ||
4602 | |||
4017 | if (ParentGroup != null) | 4603 | if (ParentGroup != null) |
4018 | { | 4604 | { |
4019 | ParentGroup.HasGroupChanged = true; | 4605 | ParentGroup.HasGroupChanged = true; |
4020 | ScheduleFullUpdate(); | 4606 | ScheduleFullUpdate(); |
4021 | } | 4607 | } |
4022 | 4608 | ||
4023 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); | 4609 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); |
4024 | } | 4610 | } |
4025 | 4611 | ||
4026 | /// <summary> | 4612 | /// <summary> |
4027 | /// Adds this part to the physics scene. | 4613 | /// Adds this part to the physics scene. |
4614 | /// and sets the PhysActor property | ||
4028 | /// </summary> | 4615 | /// </summary> |
4029 | /// <remarks>This method also sets the PhysActor property.</remarks> | 4616 | /// <param name="isPhysical">Add this prim as physical.</param> |
4030 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | 4617 | /// <param name="isPhantom">Add this prim as phantom.</param> |
4031 | /// <returns> | 4618 | /// <param name="building">tells physics to delay full construction of object</param> |
4032 | /// The physics actor. null if there was a failure. | 4619 | /// <param name="applyDynamics">applies velocities, force and torque</param> |
4033 | /// </returns> | 4620 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) |
4034 | private PhysicsActor AddToPhysics(bool rigidBody) | 4621 | { |
4035 | { | ||
4036 | PhysicsActor pa; | 4622 | PhysicsActor pa; |
4037 | 4623 | ||
4624 | Vector3 velocity = Velocity; | ||
4625 | Vector3 rotationalVelocity = AngularVelocity;; | ||
4626 | |||
4038 | try | 4627 | try |
4039 | { | 4628 | { |
4040 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | 4629 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( |
4041 | string.Format("{0}/{1}", Name, UUID), | 4630 | string.Format("{0}/{1}", Name, UUID), |
4042 | Shape, | 4631 | Shape, |
4043 | AbsolutePosition, | 4632 | AbsolutePosition, |
4044 | Scale, | 4633 | Scale, |
4045 | RotationOffset, | 4634 | GetWorldRotation(), |
4046 | rigidBody, | 4635 | isPhysical, |
4047 | m_localId); | 4636 | isPhantom, |
4637 | PhysicsShapeType, | ||
4638 | m_localId); | ||
4048 | } | 4639 | } |
4049 | catch | 4640 | catch (Exception ex) |
4050 | { | 4641 | { |
4051 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); | 4642 | m_log.ErrorFormat("[SCENE]: AddToPhysics object {0} failed: {1}", m_uuid, ex.Message); |
4052 | pa = null; | 4643 | pa = null; |
4053 | } | 4644 | } |
4054 | 4645 | ||
4055 | // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical | ||
4056 | // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor | ||
4057 | // being set. | ||
4058 | PhysActor = pa; | ||
4059 | |||
4060 | // Basic Physics can also return null as well as an exception catch. | ||
4061 | if (pa != null) | 4646 | if (pa != null) |
4062 | { | 4647 | { |
4063 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | 4648 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info |
4064 | pa.SetMaterial(Material); | 4649 | pa.SetMaterial(Material); |
4065 | DoPhysicsPropertyUpdate(rigidBody, true); | 4650 | |
4651 | if (VolumeDetectActive) // change if not the default only | ||
4652 | pa.SetVolumeDetect(1); | ||
4653 | |||
4654 | if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) | ||
4655 | m_vehicleParams.SetVehicle(pa); | ||
4656 | |||
4657 | // we are going to tell rest of code about physics so better have this here | ||
4658 | PhysActor = pa; | ||
4659 | |||
4660 | // DoPhysicsPropertyUpdate(isPhysical, true); | ||
4661 | // lets expand it here just with what it really needs to do | ||
4662 | |||
4663 | if (isPhysical) | ||
4664 | { | ||
4665 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
4666 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
4667 | ParentGroup.RootPart.KeyframeMotion = null; | ||
4668 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
4669 | |||
4670 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | ||
4671 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
4672 | |||
4673 | if (ParentID != 0 && ParentID != LocalId) | ||
4674 | { | ||
4675 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | ||
4676 | |||
4677 | if (parentPa != null) | ||
4678 | { | ||
4679 | pa.link(parentPa); | ||
4680 | } | ||
4681 | } | ||
4682 | } | ||
4683 | |||
4684 | if (applyDynamics) | ||
4685 | // do independent of isphysical so parameters get setted (at least some) | ||
4686 | { | ||
4687 | Velocity = velocity; | ||
4688 | AngularVelocity = rotationalVelocity; | ||
4689 | // pa.Velocity = velocity; | ||
4690 | pa.RotationalVelocity = rotationalVelocity; | ||
4691 | |||
4692 | // if not vehicle and root part apply force and torque | ||
4693 | if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE) | ||
4694 | && LocalId == ParentGroup.RootPart.LocalId) | ||
4695 | { | ||
4696 | pa.Force = Force; | ||
4697 | pa.Torque = Torque; | ||
4698 | } | ||
4699 | } | ||
4700 | |||
4701 | // if (Shape.SculptEntry) | ||
4702 | // CheckSculptAndLoad(); | ||
4703 | // else | ||
4704 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
4705 | |||
4706 | if (!building) | ||
4707 | pa.Building = false; | ||
4066 | } | 4708 | } |
4067 | 4709 | ||
4068 | return pa; | 4710 | PhysActor = pa; |
4069 | } | 4711 | } |
4070 | 4712 | ||
4071 | /// <summary> | 4713 | /// <summary> |
4072 | /// This removes the part from the physics scene. | 4714 | /// This removes the part from the physics scene. |
4073 | /// </summary> | 4715 | /// </summary> |
4074 | /// <remarks> | 4716 | /// <remarks> |
4075 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 4717 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |
4076 | /// representation for collision detection. Rather, this would be used in situations such as making a prim | 4718 | /// representation for collision detection. |
4077 | /// phantom. | ||
4078 | /// </remarks> | 4719 | /// </remarks> |
4079 | public void RemoveFromPhysics() | 4720 | public void RemoveFromPhysics() |
4080 | { | 4721 | { |
4081 | ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 4722 | PhysicsActor pa = PhysActor; |
4723 | if (pa != null) | ||
4724 | { | ||
4725 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4726 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | ||
4727 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | ||
4728 | |||
4729 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | ||
4730 | } | ||
4082 | PhysActor = null; | 4731 | PhysActor = null; |
4083 | } | 4732 | } |
4084 | 4733 | ||
@@ -4210,6 +4859,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4210 | { | 4859 | { |
4211 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); | 4860 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); |
4212 | 4861 | ||
4862 | return; | ||
4863 | |||
4213 | if (ParentGroup.IsDeleted) | 4864 | if (ParentGroup.IsDeleted) |
4214 | return; | 4865 | return; |
4215 | 4866 | ||
@@ -4290,6 +4941,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
4290 | ScheduleFullUpdate(); | 4941 | ScheduleFullUpdate(); |
4291 | } | 4942 | } |
4292 | 4943 | ||
4944 | |||
4945 | private void UpdatePhysicsSubscribedEvents() | ||
4946 | { | ||
4947 | PhysicsActor pa = PhysActor; | ||
4948 | if (pa == null) | ||
4949 | return; | ||
4950 | |||
4951 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4952 | |||
4953 | bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0)); | ||
4954 | |||
4955 | scriptEvents CombinedEvents = AggregateScriptEvents; | ||
4956 | |||
4957 | // merge with root part | ||
4958 | if (ParentGroup != null && ParentGroup.RootPart != null) | ||
4959 | CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents; | ||
4960 | |||
4961 | // submit to this part case | ||
4962 | if (VolumeDetectActive) | ||
4963 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | ||
4964 | else if ((Flags & PrimFlags.Phantom) != 0) | ||
4965 | CombinedEvents &= PhyscicsPhantonSubsEvents; | ||
4966 | else | ||
4967 | CombinedEvents &= PhysicsNeededSubsEvents; | ||
4968 | |||
4969 | if (hassound || CombinedEvents != 0) | ||
4970 | { | ||
4971 | // subscribe to physics updates. | ||
4972 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4973 | pa.SubscribeEvents(50); // 20 reports per second | ||
4974 | } | ||
4975 | else | ||
4976 | { | ||
4977 | pa.UnSubscribeEvents(); | ||
4978 | } | ||
4979 | } | ||
4980 | |||
4981 | |||
4293 | public void aggregateScriptEvents() | 4982 | public void aggregateScriptEvents() |
4294 | { | 4983 | { |
4295 | if (ParentGroup == null || ParentGroup.RootPart == null) | 4984 | if (ParentGroup == null || ParentGroup.RootPart == null) |
@@ -4326,40 +5015,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
4326 | { | 5015 | { |
4327 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 5016 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4328 | } | 5017 | } |
4329 | 5018 | /* | |
4330 | PhysicsActor pa = PhysActor; | 5019 | PhysicsActor pa = PhysActor; |
4331 | 5020 | if (pa != null) | |
4332 | if ( | ||
4333 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4334 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4335 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4336 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4337 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4338 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4339 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4340 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4341 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4342 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4343 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4344 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4345 | (CollisionSound != UUID.Zero) | ||
4346 | ) | ||
4347 | { | 5021 | { |
4348 | // subscribe to physics updates. | 5022 | if ( |
4349 | if (pa != null) | 5023 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || |
5024 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
5025 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
5026 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
5027 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
5028 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
5029 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | ||
5030 | ) | ||
4350 | { | 5031 | { |
5032 | // subscribe to physics updates. | ||
4351 | pa.OnCollisionUpdate += PhysicsCollision; | 5033 | pa.OnCollisionUpdate += PhysicsCollision; |
4352 | pa.SubscribeEvents(1000); | 5034 | pa.SubscribeEvents(1000); |
4353 | } | 5035 | } |
4354 | } | 5036 | else |
4355 | else | ||
4356 | { | ||
4357 | if (pa != null) | ||
4358 | { | 5037 | { |
4359 | pa.UnSubscribeEvents(); | 5038 | pa.UnSubscribeEvents(); |
4360 | pa.OnCollisionUpdate -= PhysicsCollision; | 5039 | pa.OnCollisionUpdate -= PhysicsCollision; |
4361 | } | 5040 | } |
4362 | } | 5041 | } |
5042 | */ | ||
5043 | UpdatePhysicsSubscribedEvents(); | ||
4363 | 5044 | ||
4364 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 5045 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4365 | //{ | 5046 | //{ |
@@ -4490,6 +5171,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4490 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 5171 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4491 | } | 5172 | } |
4492 | 5173 | ||
5174 | public void ResetOwnerChangeFlag() | ||
5175 | { | ||
5176 | List<UUID> inv = Inventory.GetInventoryList(); | ||
5177 | |||
5178 | foreach (UUID itemID in inv) | ||
5179 | { | ||
5180 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
5181 | item.OwnerChanged = false; | ||
5182 | Inventory.UpdateInventoryItem(item, false, false); | ||
5183 | } | ||
5184 | } | ||
5185 | |||
4493 | /// <summary> | 5186 | /// <summary> |
4494 | /// Record an avatar sitting on this part. | 5187 | /// Record an avatar sitting on this part. |
4495 | /// </summary> | 5188 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index bdb0446..f41e329 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -48,6 +48,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
48 | private string m_inventoryFileName = String.Empty; | 48 | private string m_inventoryFileName = String.Empty; |
49 | private byte[] m_inventoryFileData = new byte[0]; | 49 | private byte[] m_inventoryFileData = new byte[0]; |
50 | private uint m_inventoryFileNameSerial = 0; | 50 | private uint m_inventoryFileNameSerial = 0; |
51 | private bool m_inventoryPrivileged = false; | ||
52 | |||
53 | private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); | ||
51 | 54 | ||
52 | /// <value> | 55 | /// <value> |
53 | /// The part to which the inventory belongs. | 56 | /// The part to which the inventory belongs. |
@@ -84,7 +87,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
84 | /// </value> | 87 | /// </value> |
85 | protected internal TaskInventoryDictionary Items | 88 | protected internal TaskInventoryDictionary Items |
86 | { | 89 | { |
87 | get { return m_items; } | 90 | get { |
91 | return m_items; | ||
92 | } | ||
88 | set | 93 | set |
89 | { | 94 | { |
90 | m_items = value; | 95 | m_items = value; |
@@ -133,38 +138,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
133 | public void ResetInventoryIDs() | 138 | public void ResetInventoryIDs() |
134 | { | 139 | { |
135 | if (null == m_part) | 140 | if (null == m_part) |
136 | return; | 141 | m_items.LockItemsForWrite(true); |
137 | 142 | ||
138 | lock (m_items) | 143 | if (Items.Count == 0) |
139 | { | 144 | { |
140 | if (0 == m_items.Count) | 145 | m_items.LockItemsForWrite(false); |
141 | return; | 146 | return; |
147 | } | ||
142 | 148 | ||
143 | IList<TaskInventoryItem> items = GetInventoryItems(); | 149 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
144 | m_items.Clear(); | 150 | Items.Clear(); |
145 | 151 | ||
146 | foreach (TaskInventoryItem item in items) | 152 | foreach (TaskInventoryItem item in items) |
147 | { | 153 | { |
148 | item.ResetIDs(m_part.UUID); | 154 | item.ResetIDs(m_part.UUID); |
149 | m_items.Add(item.ItemID, item); | 155 | Items.Add(item.ItemID, item); |
150 | } | ||
151 | } | 156 | } |
157 | m_items.LockItemsForWrite(false); | ||
152 | } | 158 | } |
153 | 159 | ||
154 | public void ResetObjectID() | 160 | public void ResetObjectID() |
155 | { | 161 | { |
156 | lock (Items) | 162 | m_items.LockItemsForWrite(true); |
163 | |||
164 | if (Items.Count == 0) | ||
157 | { | 165 | { |
158 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 166 | m_items.LockItemsForWrite(false); |
159 | Items.Clear(); | 167 | return; |
160 | |||
161 | foreach (TaskInventoryItem item in items) | ||
162 | { | ||
163 | item.ParentPartID = m_part.UUID; | ||
164 | item.ParentID = m_part.UUID; | ||
165 | Items.Add(item.ItemID, item); | ||
166 | } | ||
167 | } | 168 | } |
169 | |||
170 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
171 | Items.Clear(); | ||
172 | |||
173 | foreach (TaskInventoryItem item in items) | ||
174 | { | ||
175 | item.ParentPartID = m_part.UUID; | ||
176 | item.ParentID = m_part.UUID; | ||
177 | Items.Add(item.ItemID, item); | ||
178 | } | ||
179 | m_items.LockItemsForWrite(false); | ||
168 | } | 180 | } |
169 | 181 | ||
170 | /// <summary> | 182 | /// <summary> |
@@ -173,17 +185,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
173 | /// <param name="ownerId"></param> | 185 | /// <param name="ownerId"></param> |
174 | public void ChangeInventoryOwner(UUID ownerId) | 186 | public void ChangeInventoryOwner(UUID ownerId) |
175 | { | 187 | { |
176 | lock (Items) | 188 | List<TaskInventoryItem> items = GetInventoryItems(); |
177 | { | ||
178 | if (0 == Items.Count) | ||
179 | { | ||
180 | return; | ||
181 | } | ||
182 | } | ||
183 | 189 | ||
190 | if (items.Count == 0) | ||
191 | return; | ||
192 | |||
193 | m_items.LockItemsForWrite(true); | ||
184 | HasInventoryChanged = true; | 194 | HasInventoryChanged = true; |
185 | m_part.ParentGroup.HasGroupChanged = true; | 195 | m_part.ParentGroup.HasGroupChanged = true; |
186 | List<TaskInventoryItem> items = GetInventoryItems(); | ||
187 | foreach (TaskInventoryItem item in items) | 196 | foreach (TaskInventoryItem item in items) |
188 | { | 197 | { |
189 | if (ownerId != item.OwnerID) | 198 | if (ownerId != item.OwnerID) |
@@ -194,6 +203,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
194 | item.PermsGranter = UUID.Zero; | 203 | item.PermsGranter = UUID.Zero; |
195 | item.OwnerChanged = true; | 204 | item.OwnerChanged = true; |
196 | } | 205 | } |
206 | m_items.LockItemsForWrite(false); | ||
197 | } | 207 | } |
198 | 208 | ||
199 | /// <summary> | 209 | /// <summary> |
@@ -202,12 +212,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
202 | /// <param name="groupID"></param> | 212 | /// <param name="groupID"></param> |
203 | public void ChangeInventoryGroup(UUID groupID) | 213 | public void ChangeInventoryGroup(UUID groupID) |
204 | { | 214 | { |
205 | lock (Items) | 215 | m_items.LockItemsForWrite(true); |
216 | if (0 == Items.Count) | ||
206 | { | 217 | { |
207 | if (0 == Items.Count) | 218 | m_items.LockItemsForWrite(false); |
208 | { | 219 | return; |
209 | return; | ||
210 | } | ||
211 | } | 220 | } |
212 | 221 | ||
213 | // Don't let this set the HasGroupChanged flag for attachments | 222 | // Don't let this set the HasGroupChanged flag for attachments |
@@ -219,12 +228,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
219 | m_part.ParentGroup.HasGroupChanged = true; | 228 | m_part.ParentGroup.HasGroupChanged = true; |
220 | } | 229 | } |
221 | 230 | ||
222 | List<TaskInventoryItem> items = GetInventoryItems(); | 231 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
223 | foreach (TaskInventoryItem item in items) | 232 | foreach (TaskInventoryItem item in items) |
224 | { | 233 | { |
225 | if (groupID != item.GroupID) | 234 | if (groupID != item.GroupID) |
235 | { | ||
226 | item.GroupID = groupID; | 236 | item.GroupID = groupID; |
237 | } | ||
227 | } | 238 | } |
239 | m_items.LockItemsForWrite(false); | ||
228 | } | 240 | } |
229 | 241 | ||
230 | private void QueryScriptStates() | 242 | private void QueryScriptStates() |
@@ -236,25 +248,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
236 | if (engines == null) // No engine at all | 248 | if (engines == null) // No engine at all |
237 | return; | 249 | return; |
238 | 250 | ||
239 | lock (Items) | 251 | Items.LockItemsForRead(true); |
252 | foreach (TaskInventoryItem item in Items.Values) | ||
240 | { | 253 | { |
241 | foreach (TaskInventoryItem item in Items.Values) | 254 | if (item.InvType == (int)InventoryType.LSL) |
242 | { | 255 | { |
243 | if (item.InvType == (int)InventoryType.LSL) | 256 | foreach (IScriptModule e in engines) |
244 | { | 257 | { |
245 | foreach (IScriptModule e in engines) | 258 | bool running; |
246 | { | ||
247 | bool running; | ||
248 | 259 | ||
249 | if (e.HasScript(item.ItemID, out running)) | 260 | if (e.HasScript(item.ItemID, out running)) |
250 | { | 261 | { |
251 | item.ScriptRunning = running; | 262 | item.ScriptRunning = running; |
252 | break; | 263 | break; |
253 | } | ||
254 | } | 264 | } |
255 | } | 265 | } |
256 | } | 266 | } |
257 | } | 267 | } |
268 | |||
269 | Items.LockItemsForRead(false); | ||
258 | } | 270 | } |
259 | 271 | ||
260 | public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 272 | public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
@@ -299,7 +311,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
299 | { | 311 | { |
300 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | 312 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
301 | foreach (TaskInventoryItem item in scripts) | 313 | foreach (TaskInventoryItem item in scripts) |
314 | { | ||
302 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | 315 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
316 | m_part.RemoveScriptEvents(item.ItemID); | ||
317 | } | ||
303 | } | 318 | } |
304 | 319 | ||
305 | /// <summary> | 320 | /// <summary> |
@@ -321,7 +336,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
321 | // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 336 | // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
322 | 337 | ||
323 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) | 338 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) |
339 | { | ||
340 | StoreScriptError(item.ItemID, "no permission"); | ||
324 | return false; | 341 | return false; |
342 | } | ||
325 | 343 | ||
326 | m_part.AddFlag(PrimFlags.Scripted); | 344 | m_part.AddFlag(PrimFlags.Scripted); |
327 | 345 | ||
@@ -331,14 +349,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
331 | if (stateSource == 2 && // Prim crossing | 349 | if (stateSource == 2 && // Prim crossing |
332 | m_part.ParentGroup.Scene.m_trustBinaries) | 350 | m_part.ParentGroup.Scene.m_trustBinaries) |
333 | { | 351 | { |
334 | lock (m_items) | 352 | m_items.LockItemsForWrite(true); |
335 | { | 353 | m_items[item.ItemID].PermsMask = 0; |
336 | m_items[item.ItemID].PermsMask = 0; | 354 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
337 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 355 | m_items.LockItemsForWrite(false); |
338 | } | ||
339 | |||
340 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 356 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
341 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 357 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
358 | StoreScriptErrors(item.ItemID, null); | ||
342 | m_part.ParentGroup.AddActiveScriptCount(1); | 359 | m_part.ParentGroup.AddActiveScriptCount(1); |
343 | m_part.ScheduleFullUpdate(); | 360 | m_part.ScheduleFullUpdate(); |
344 | return true; | 361 | return true; |
@@ -347,6 +364,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
347 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); | 364 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
348 | if (null == asset) | 365 | if (null == asset) |
349 | { | 366 | { |
367 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | ||
368 | StoreScriptError(item.ItemID, msg); | ||
350 | m_log.ErrorFormat( | 369 | m_log.ErrorFormat( |
351 | "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", | 370 | "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
352 | item.Name, item.ItemID, m_part.AbsolutePosition, | 371 | item.Name, item.ItemID, m_part.AbsolutePosition, |
@@ -359,16 +378,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
359 | if (m_part.ParentGroup.m_savedScriptState != null) | 378 | if (m_part.ParentGroup.m_savedScriptState != null) |
360 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); | 379 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); |
361 | 380 | ||
362 | lock (m_items) | 381 | m_items.LockItemsForWrite(true); |
363 | { | 382 | |
364 | m_items[item.ItemID].OldItemID = item.OldItemID; | 383 | m_items[item.ItemID].OldItemID = item.OldItemID; |
365 | m_items[item.ItemID].PermsMask = 0; | 384 | m_items[item.ItemID].PermsMask = 0; |
366 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 385 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
367 | } | ||
368 | 386 | ||
387 | m_items.LockItemsForWrite(false); | ||
388 | |||
369 | string script = Utils.BytesToString(asset.Data); | 389 | string script = Utils.BytesToString(asset.Data); |
370 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 390 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
371 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 391 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
392 | StoreScriptErrors(item.ItemID, null); | ||
372 | if (!item.ScriptRunning) | 393 | if (!item.ScriptRunning) |
373 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript( | 394 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript( |
374 | m_part.LocalId, item.ItemID); | 395 | m_part.LocalId, item.ItemID); |
@@ -441,22 +462,149 @@ namespace OpenSim.Region.Framework.Scenes | |||
441 | return stateID; | 462 | return stateID; |
442 | } | 463 | } |
443 | 464 | ||
465 | /// <summary> | ||
466 | /// Start a script which is in this prim's inventory. | ||
467 | /// Some processing may occur in the background, but this routine returns asap. | ||
468 | /// </summary> | ||
469 | /// <param name="itemId"> | ||
470 | /// A <see cref="UUID"/> | ||
471 | /// </param> | ||
444 | public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 472 | public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
445 | { | 473 | { |
446 | TaskInventoryItem item = GetInventoryItem(itemId); | 474 | lock (m_scriptErrors) |
447 | if (item != null) | 475 | { |
476 | // Indicate to CreateScriptInstanceInternal() we don't want it to wait for completion | ||
477 | m_scriptErrors.Remove(itemId); | ||
478 | } | ||
479 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
480 | return true; | ||
481 | } | ||
482 | |||
483 | private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
484 | { | ||
485 | m_items.LockItemsForRead(true); | ||
486 | if (m_items.ContainsKey(itemId)) | ||
448 | { | 487 | { |
449 | return CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | 488 | if (m_items.ContainsKey(itemId)) |
489 | { | ||
490 | m_items.LockItemsForRead(false); | ||
491 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | ||
492 | } | ||
493 | else | ||
494 | { | ||
495 | m_items.LockItemsForRead(false); | ||
496 | string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, | ||
497 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
498 | StoreScriptError(itemId, msg); | ||
499 | m_log.ErrorFormat( | ||
500 | "[PRIM INVENTORY]: " + | ||
501 | "Couldn't start script with ID {0} since it {1}", itemId, msg); | ||
502 | } | ||
450 | } | 503 | } |
451 | else | 504 | else |
452 | { | 505 | { |
506 | m_items.LockItemsForRead(false); | ||
507 | string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); | ||
508 | StoreScriptError(itemId, msg); | ||
453 | m_log.ErrorFormat( | 509 | m_log.ErrorFormat( |
454 | "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 510 | "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", |
455 | itemId, m_part.Name, m_part.UUID, | 511 | itemId, m_part.Name, m_part.UUID, |
456 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 512 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
513 | } | ||
514 | |||
515 | } | ||
457 | 516 | ||
458 | return false; | 517 | /// <summary> |
518 | /// Start a script which is in this prim's inventory and return any compilation error messages. | ||
519 | /// </summary> | ||
520 | /// <param name="itemId"> | ||
521 | /// A <see cref="UUID"/> | ||
522 | /// </param> | ||
523 | public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
524 | { | ||
525 | ArrayList errors; | ||
526 | |||
527 | // Indicate to CreateScriptInstanceInternal() we want it to | ||
528 | // post any compilation/loading error messages | ||
529 | lock (m_scriptErrors) | ||
530 | { | ||
531 | m_scriptErrors[itemId] = null; | ||
459 | } | 532 | } |
533 | |||
534 | // Perform compilation/loading | ||
535 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
536 | |||
537 | // Wait for and retrieve any errors | ||
538 | lock (m_scriptErrors) | ||
539 | { | ||
540 | while ((errors = m_scriptErrors[itemId]) == null) | ||
541 | { | ||
542 | if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000)) | ||
543 | { | ||
544 | m_log.ErrorFormat( | ||
545 | "[PRIM INVENTORY]: " + | ||
546 | "timedout waiting for script {0} errors", itemId); | ||
547 | errors = m_scriptErrors[itemId]; | ||
548 | if (errors == null) | ||
549 | { | ||
550 | errors = new ArrayList(1); | ||
551 | errors.Add("timedout waiting for errors"); | ||
552 | } | ||
553 | break; | ||
554 | } | ||
555 | } | ||
556 | m_scriptErrors.Remove(itemId); | ||
557 | } | ||
558 | return errors; | ||
559 | } | ||
560 | |||
561 | // Signal to CreateScriptInstanceEr() that compilation/loading is complete | ||
562 | private void StoreScriptErrors(UUID itemId, ArrayList errors) | ||
563 | { | ||
564 | lock (m_scriptErrors) | ||
565 | { | ||
566 | // If compilation/loading initiated via CreateScriptInstance(), | ||
567 | // it does not want the errors, so just get out | ||
568 | if (!m_scriptErrors.ContainsKey(itemId)) | ||
569 | { | ||
570 | return; | ||
571 | } | ||
572 | |||
573 | // Initiated via CreateScriptInstanceEr(), if we know what the | ||
574 | // errors are, save them and wake CreateScriptInstanceEr(). | ||
575 | if (errors != null) | ||
576 | { | ||
577 | m_scriptErrors[itemId] = errors; | ||
578 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
579 | return; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | // Initiated via CreateScriptInstanceEr() but we don't know what | ||
584 | // the errors are yet, so retrieve them from the script engine. | ||
585 | // This may involve some waiting internal to GetScriptErrors(). | ||
586 | errors = GetScriptErrors(itemId); | ||
587 | |||
588 | // Get a default non-null value to indicate success. | ||
589 | if (errors == null) | ||
590 | { | ||
591 | errors = new ArrayList(); | ||
592 | } | ||
593 | |||
594 | // Post to CreateScriptInstanceEr() and wake it up | ||
595 | lock (m_scriptErrors) | ||
596 | { | ||
597 | m_scriptErrors[itemId] = errors; | ||
598 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
599 | } | ||
600 | } | ||
601 | |||
602 | // Like StoreScriptErrors(), but just posts a single string message | ||
603 | private void StoreScriptError(UUID itemId, string message) | ||
604 | { | ||
605 | ArrayList errors = new ArrayList(1); | ||
606 | errors.Add(message); | ||
607 | StoreScriptErrors(itemId, errors); | ||
460 | } | 608 | } |
461 | 609 | ||
462 | /// <summary> | 610 | /// <summary> |
@@ -469,15 +617,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
469 | /// </param> | 617 | /// </param> |
470 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) | 618 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) |
471 | { | 619 | { |
472 | bool scriptPresent = false; | 620 | if (m_items.ContainsKey(itemId)) |
473 | |||
474 | lock (m_items) | ||
475 | { | ||
476 | if (m_items.ContainsKey(itemId)) | ||
477 | scriptPresent = true; | ||
478 | } | ||
479 | |||
480 | if (scriptPresent) | ||
481 | { | 621 | { |
482 | if (!sceneObjectBeingDeleted) | 622 | if (!sceneObjectBeingDeleted) |
483 | m_part.RemoveScriptEvents(itemId); | 623 | m_part.RemoveScriptEvents(itemId); |
@@ -547,14 +687,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
547 | /// <returns></returns> | 687 | /// <returns></returns> |
548 | private bool InventoryContainsName(string name) | 688 | private bool InventoryContainsName(string name) |
549 | { | 689 | { |
550 | lock (m_items) | 690 | m_items.LockItemsForRead(true); |
691 | foreach (TaskInventoryItem item in m_items.Values) | ||
551 | { | 692 | { |
552 | foreach (TaskInventoryItem item in m_items.Values) | 693 | if (item.Name == name) |
553 | { | 694 | { |
554 | if (item.Name == name) | 695 | m_items.LockItemsForRead(false); |
555 | return true; | 696 | return true; |
556 | } | 697 | } |
557 | } | 698 | } |
699 | m_items.LockItemsForRead(false); | ||
558 | return false; | 700 | return false; |
559 | } | 701 | } |
560 | 702 | ||
@@ -596,8 +738,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
596 | /// <param name="item"></param> | 738 | /// <param name="item"></param> |
597 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 739 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
598 | { | 740 | { |
599 | List<TaskInventoryItem> il = GetInventoryItems(); | 741 | m_items.LockItemsForRead(true); |
600 | 742 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | |
743 | m_items.LockItemsForRead(false); | ||
601 | foreach (TaskInventoryItem i in il) | 744 | foreach (TaskInventoryItem i in il) |
602 | { | 745 | { |
603 | if (i.Name == item.Name) | 746 | if (i.Name == item.Name) |
@@ -635,14 +778,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
635 | item.Name = name; | 778 | item.Name = name; |
636 | item.GroupID = m_part.GroupID; | 779 | item.GroupID = m_part.GroupID; |
637 | 780 | ||
638 | lock (m_items) | 781 | m_items.LockItemsForWrite(true); |
639 | m_items.Add(item.ItemID, item); | 782 | m_items.Add(item.ItemID, item); |
640 | 783 | m_items.LockItemsForWrite(false); | |
641 | if (allowedDrop) | 784 | if (allowedDrop) |
642 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 785 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
643 | else | 786 | else |
644 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 787 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
645 | 788 | ||
646 | m_inventorySerial++; | 789 | m_inventorySerial++; |
647 | //m_inventorySerial += 2; | 790 | //m_inventorySerial += 2; |
648 | HasInventoryChanged = true; | 791 | HasInventoryChanged = true; |
@@ -658,15 +801,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
658 | /// <param name="items"></param> | 801 | /// <param name="items"></param> |
659 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 802 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
660 | { | 803 | { |
661 | lock (m_items) | 804 | m_items.LockItemsForWrite(true); |
805 | foreach (TaskInventoryItem item in items) | ||
662 | { | 806 | { |
663 | foreach (TaskInventoryItem item in items) | 807 | m_items.Add(item.ItemID, item); |
664 | { | 808 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
665 | m_items.Add(item.ItemID, item); | ||
666 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
667 | } | ||
668 | m_inventorySerial++; | ||
669 | } | 809 | } |
810 | m_items.LockItemsForWrite(false); | ||
811 | |||
812 | m_inventorySerial++; | ||
670 | } | 813 | } |
671 | 814 | ||
672 | /// <summary> | 815 | /// <summary> |
@@ -677,23 +820,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
677 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 820 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
678 | { | 821 | { |
679 | TaskInventoryItem item; | 822 | TaskInventoryItem item; |
680 | 823 | m_items.LockItemsForRead(true); | |
681 | lock (m_items) | 824 | m_items.TryGetValue(itemId, out item); |
682 | m_items.TryGetValue(itemId, out item); | 825 | m_items.LockItemsForRead(false); |
683 | |||
684 | return item; | 826 | return item; |
685 | } | 827 | } |
686 | 828 | ||
687 | public TaskInventoryItem GetInventoryItem(string name) | 829 | public TaskInventoryItem GetInventoryItem(string name) |
688 | { | 830 | { |
689 | lock (m_items) | 831 | m_items.LockItemsForRead(true); |
832 | foreach (TaskInventoryItem item in m_items.Values) | ||
690 | { | 833 | { |
691 | foreach (TaskInventoryItem item in m_items.Values) | 834 | if (item.Name == name) |
692 | { | 835 | { |
693 | if (item.Name == name) | 836 | m_items.LockItemsForRead(false); |
694 | return item; | 837 | return item; |
695 | } | 838 | } |
696 | } | 839 | } |
840 | m_items.LockItemsForRead(false); | ||
697 | 841 | ||
698 | return null; | 842 | return null; |
699 | } | 843 | } |
@@ -702,15 +846,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
702 | { | 846 | { |
703 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 847 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
704 | 848 | ||
705 | lock (m_items) | 849 | m_items.LockItemsForRead(true); |
850 | |||
851 | foreach (TaskInventoryItem item in m_items.Values) | ||
706 | { | 852 | { |
707 | foreach (TaskInventoryItem item in m_items.Values) | 853 | if (item.Name == name) |
708 | { | 854 | items.Add(item); |
709 | if (item.Name == name) | ||
710 | items.Add(item); | ||
711 | } | ||
712 | } | 855 | } |
713 | 856 | ||
857 | m_items.LockItemsForRead(false); | ||
858 | |||
714 | return items; | 859 | return items; |
715 | } | 860 | } |
716 | 861 | ||
@@ -729,6 +874,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
729 | string xmlData = Utils.BytesToString(rezAsset.Data); | 874 | string xmlData = Utils.BytesToString(rezAsset.Data); |
730 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 875 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
731 | 876 | ||
877 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
878 | group.RootPart.AttachOffset = group.AbsolutePosition; | ||
879 | group.RootPart.AttachRotation = group.GroupRotation; | ||
880 | |||
732 | group.ResetIDs(); | 881 | group.ResetIDs(); |
733 | 882 | ||
734 | SceneObjectPart rootPart = group.GetPart(group.UUID); | 883 | SceneObjectPart rootPart = group.GetPart(group.UUID); |
@@ -803,8 +952,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
803 | 952 | ||
804 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) | 953 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) |
805 | { | 954 | { |
806 | TaskInventoryItem it = GetInventoryItem(item.ItemID); | 955 | m_items.LockItemsForWrite(true); |
807 | if (it != null) | 956 | |
957 | if (m_items.ContainsKey(item.ItemID)) | ||
808 | { | 958 | { |
809 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); | 959 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); |
810 | 960 | ||
@@ -817,14 +967,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
817 | item.GroupID = m_part.GroupID; | 967 | item.GroupID = m_part.GroupID; |
818 | 968 | ||
819 | if (item.AssetID == UUID.Zero) | 969 | if (item.AssetID == UUID.Zero) |
820 | item.AssetID = it.AssetID; | 970 | item.AssetID = m_items[item.ItemID].AssetID; |
821 | 971 | ||
822 | lock (m_items) | 972 | m_items[item.ItemID] = item; |
823 | { | 973 | m_inventorySerial++; |
824 | m_items[item.ItemID] = item; | ||
825 | m_inventorySerial++; | ||
826 | } | ||
827 | |||
828 | if (fireScriptEvents) | 974 | if (fireScriptEvents) |
829 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 975 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
830 | 976 | ||
@@ -833,7 +979,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
833 | HasInventoryChanged = true; | 979 | HasInventoryChanged = true; |
834 | m_part.ParentGroup.HasGroupChanged = true; | 980 | m_part.ParentGroup.HasGroupChanged = true; |
835 | } | 981 | } |
836 | 982 | m_items.LockItemsForWrite(false); | |
837 | return true; | 983 | return true; |
838 | } | 984 | } |
839 | else | 985 | else |
@@ -844,8 +990,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
844 | item.ItemID, m_part.Name, m_part.UUID, | 990 | item.ItemID, m_part.Name, m_part.UUID, |
845 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 991 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
846 | } | 992 | } |
847 | return false; | 993 | m_items.LockItemsForWrite(false); |
848 | 994 | ||
995 | return false; | ||
849 | } | 996 | } |
850 | 997 | ||
851 | /// <summary> | 998 | /// <summary> |
@@ -856,43 +1003,59 @@ namespace OpenSim.Region.Framework.Scenes | |||
856 | /// in this prim's inventory.</returns> | 1003 | /// in this prim's inventory.</returns> |
857 | public int RemoveInventoryItem(UUID itemID) | 1004 | public int RemoveInventoryItem(UUID itemID) |
858 | { | 1005 | { |
859 | TaskInventoryItem item = GetInventoryItem(itemID); | 1006 | m_items.LockItemsForRead(true); |
860 | if (item != null) | 1007 | |
1008 | if (m_items.ContainsKey(itemID)) | ||
861 | { | 1009 | { |
862 | int type = m_items[itemID].InvType; | 1010 | int type = m_items[itemID].InvType; |
1011 | m_items.LockItemsForRead(false); | ||
863 | if (type == 10) // Script | 1012 | if (type == 10) // Script |
864 | { | 1013 | { |
865 | m_part.RemoveScriptEvents(itemID); | ||
866 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 1014 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
867 | } | 1015 | } |
1016 | m_items.LockItemsForWrite(true); | ||
868 | m_items.Remove(itemID); | 1017 | m_items.Remove(itemID); |
1018 | m_items.LockItemsForWrite(false); | ||
869 | m_inventorySerial++; | 1019 | m_inventorySerial++; |
870 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 1020 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
871 | 1021 | ||
872 | HasInventoryChanged = true; | 1022 | HasInventoryChanged = true; |
873 | m_part.ParentGroup.HasGroupChanged = true; | 1023 | m_part.ParentGroup.HasGroupChanged = true; |
874 | 1024 | ||
875 | if (!ContainsScripts()) | 1025 | int scriptcount = 0; |
1026 | m_items.LockItemsForRead(true); | ||
1027 | foreach (TaskInventoryItem item in m_items.Values) | ||
1028 | { | ||
1029 | if (item.Type == 10) | ||
1030 | { | ||
1031 | scriptcount++; | ||
1032 | } | ||
1033 | } | ||
1034 | m_items.LockItemsForRead(false); | ||
1035 | |||
1036 | |||
1037 | if (scriptcount <= 0) | ||
1038 | { | ||
876 | m_part.RemFlag(PrimFlags.Scripted); | 1039 | m_part.RemFlag(PrimFlags.Scripted); |
1040 | } | ||
877 | 1041 | ||
878 | m_part.ScheduleFullUpdate(); | 1042 | m_part.ScheduleFullUpdate(); |
879 | 1043 | ||
880 | return type; | 1044 | return type; |
881 | |||
882 | } | 1045 | } |
883 | else | 1046 | else |
884 | { | 1047 | { |
1048 | m_items.LockItemsForRead(false); | ||
885 | m_log.ErrorFormat( | 1049 | m_log.ErrorFormat( |
886 | "[PRIM INVENTORY]: " + | 1050 | "[PRIM INVENTORY]: " + |
887 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 1051 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", |
888 | itemID, m_part.Name, m_part.UUID, | 1052 | itemID, m_part.Name, m_part.UUID); |
889 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
890 | } | 1053 | } |
891 | 1054 | ||
892 | return -1; | 1055 | return -1; |
893 | } | 1056 | } |
894 | 1057 | ||
895 | private bool CreateInventoryFile() | 1058 | private bool CreateInventoryFileName() |
896 | { | 1059 | { |
897 | // m_log.DebugFormat( | 1060 | // m_log.DebugFormat( |
898 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", | 1061 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", |
@@ -901,70 +1064,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
901 | if (m_inventoryFileName == String.Empty || | 1064 | if (m_inventoryFileName == String.Empty || |
902 | m_inventoryFileNameSerial < m_inventorySerial) | 1065 | m_inventoryFileNameSerial < m_inventorySerial) |
903 | { | 1066 | { |
904 | // Something changed, we need to create a new file | ||
905 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; | 1067 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; |
906 | m_inventoryFileNameSerial = m_inventorySerial; | 1068 | m_inventoryFileNameSerial = m_inventorySerial; |
907 | 1069 | ||
908 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | ||
909 | |||
910 | lock (m_items) | ||
911 | { | ||
912 | foreach (TaskInventoryItem item in m_items.Values) | ||
913 | { | ||
914 | // m_log.DebugFormat( | ||
915 | // "[PRIM INVENTORY]: Adding item {0} {1} for serial {2} on prim {3} {4} {5}", | ||
916 | // item.Name, item.ItemID, m_inventorySerial, m_part.Name, m_part.UUID, m_part.LocalId); | ||
917 | |||
918 | UUID ownerID = item.OwnerID; | ||
919 | uint everyoneMask = 0; | ||
920 | uint baseMask = item.BasePermissions; | ||
921 | uint ownerMask = item.CurrentPermissions; | ||
922 | uint groupMask = item.GroupPermissions; | ||
923 | |||
924 | invString.AddItemStart(); | ||
925 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | ||
926 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
927 | |||
928 | invString.AddPermissionsStart(); | ||
929 | |||
930 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | ||
931 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
932 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
933 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
934 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
935 | |||
936 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
937 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
938 | |||
939 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | ||
940 | |||
941 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | ||
942 | invString.AddSectionEnd(); | ||
943 | |||
944 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | ||
945 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | ||
946 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | ||
947 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
948 | |||
949 | invString.AddSaleStart(); | ||
950 | invString.AddNameValueLine("sale_type", "not"); | ||
951 | invString.AddNameValueLine("sale_price", "0"); | ||
952 | invString.AddSectionEnd(); | ||
953 | |||
954 | invString.AddNameValueLine("name", item.Name + "|"); | ||
955 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
956 | |||
957 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | ||
958 | invString.AddSectionEnd(); | ||
959 | } | ||
960 | } | ||
961 | |||
962 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | ||
963 | |||
964 | return true; | 1070 | return true; |
965 | } | 1071 | } |
966 | 1072 | ||
967 | // No need to recreate, the existing file is fine | ||
968 | return false; | 1073 | return false; |
969 | } | 1074 | } |
970 | 1075 | ||
@@ -974,43 +1079,110 @@ namespace OpenSim.Region.Framework.Scenes | |||
974 | /// <param name="xferManager"></param> | 1079 | /// <param name="xferManager"></param> |
975 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) | 1080 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) |
976 | { | 1081 | { |
977 | lock (m_items) | 1082 | bool changed = CreateInventoryFileName(); |
978 | { | ||
979 | // Don't send a inventory xfer name if there are no items. Doing so causes viewer 3 to crash when rezzing | ||
980 | // a new script if any previous deletion has left the prim inventory empty. | ||
981 | if (m_items.Count == 0) // No inventory | ||
982 | { | ||
983 | // m_log.DebugFormat( | ||
984 | // "[PRIM INVENTORY]: Not sending inventory data for part {0} {1} {2} for {3} since no items", | ||
985 | // m_part.Name, m_part.LocalId, m_part.UUID, client.Name); | ||
986 | 1083 | ||
987 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | 1084 | bool includeAssets = false; |
988 | return; | 1085 | if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) |
989 | } | 1086 | includeAssets = true; |
990 | 1087 | ||
991 | CreateInventoryFile(); | 1088 | if (m_inventoryPrivileged != includeAssets) |
1089 | changed = true; | ||
1090 | |||
1091 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | ||
1092 | |||
1093 | Items.LockItemsForRead(true); | ||
1094 | |||
1095 | if (m_inventorySerial == 0) // No inventory | ||
1096 | { | ||
1097 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1098 | Items.LockItemsForRead(false); | ||
1099 | return; | ||
1100 | } | ||
1101 | |||
1102 | if (m_items.Count == 0) // No inventory | ||
1103 | { | ||
1104 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1105 | Items.LockItemsForRead(false); | ||
1106 | return; | ||
1107 | } | ||
992 | 1108 | ||
993 | // In principle, we should only do the rest if the inventory changed; | 1109 | if (!changed) |
994 | // by sending m_inventorySerial to the client, it ought to know | 1110 | { |
995 | // that nothing changed and that it doesn't need to request the file. | ||
996 | // Unfortunately, it doesn't look like the client optimizes this; | ||
997 | // the client seems to always come back and request the Xfer, | ||
998 | // no matter what value m_inventorySerial has. | ||
999 | // FIXME: Could probably be > 0 here rather than > 2 | ||
1000 | if (m_inventoryFileData.Length > 2) | 1111 | if (m_inventoryFileData.Length > 2) |
1001 | { | 1112 | { |
1002 | // Add the file for Xfer | 1113 | xferManager.AddNewFile(m_inventoryFileName, |
1003 | // m_log.DebugFormat( | 1114 | m_inventoryFileData); |
1004 | // "[PRIM INVENTORY]: Adding inventory file {0} (length {1}) for transfer on {2} {3} {4}", | 1115 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, |
1005 | // m_inventoryFileName, m_inventoryFileData.Length, m_part.Name, m_part.UUID, m_part.LocalId); | 1116 | Util.StringToBytes256(m_inventoryFileName)); |
1006 | 1117 | ||
1007 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | 1118 | Items.LockItemsForRead(false); |
1119 | return; | ||
1008 | } | 1120 | } |
1009 | |||
1010 | // Tell the client we're ready to Xfer the file | ||
1011 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
1012 | Util.StringToBytes256(m_inventoryFileName)); | ||
1013 | } | 1121 | } |
1122 | |||
1123 | m_inventoryPrivileged = includeAssets; | ||
1124 | |||
1125 | foreach (TaskInventoryItem item in m_items.Values) | ||
1126 | { | ||
1127 | UUID ownerID = item.OwnerID; | ||
1128 | uint everyoneMask = 0; | ||
1129 | uint baseMask = item.BasePermissions; | ||
1130 | uint ownerMask = item.CurrentPermissions; | ||
1131 | uint groupMask = item.GroupPermissions; | ||
1132 | |||
1133 | invString.AddItemStart(); | ||
1134 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | ||
1135 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
1136 | |||
1137 | invString.AddPermissionsStart(); | ||
1138 | |||
1139 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | ||
1140 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
1141 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
1142 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
1143 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
1144 | |||
1145 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
1146 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
1147 | |||
1148 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | ||
1149 | |||
1150 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | ||
1151 | invString.AddSectionEnd(); | ||
1152 | |||
1153 | if (includeAssets) | ||
1154 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | ||
1155 | else | ||
1156 | invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); | ||
1157 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | ||
1158 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | ||
1159 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
1160 | |||
1161 | invString.AddSaleStart(); | ||
1162 | invString.AddNameValueLine("sale_type", "not"); | ||
1163 | invString.AddNameValueLine("sale_price", "0"); | ||
1164 | invString.AddSectionEnd(); | ||
1165 | |||
1166 | invString.AddNameValueLine("name", item.Name + "|"); | ||
1167 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
1168 | |||
1169 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | ||
1170 | invString.AddSectionEnd(); | ||
1171 | } | ||
1172 | |||
1173 | Items.LockItemsForRead(false); | ||
1174 | |||
1175 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | ||
1176 | |||
1177 | if (m_inventoryFileData.Length > 2) | ||
1178 | { | ||
1179 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | ||
1180 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
1181 | Util.StringToBytes256(m_inventoryFileName)); | ||
1182 | return; | ||
1183 | } | ||
1184 | |||
1185 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1014 | } | 1186 | } |
1015 | 1187 | ||
1016 | /// <summary> | 1188 | /// <summary> |
@@ -1019,13 +1191,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1019 | /// <param name="datastore"></param> | 1191 | /// <param name="datastore"></param> |
1020 | public void ProcessInventoryBackup(ISimulationDataService datastore) | 1192 | public void ProcessInventoryBackup(ISimulationDataService datastore) |
1021 | { | 1193 | { |
1022 | if (HasInventoryChanged) | 1194 | // Removed this because linking will cause an immediate delete of the new |
1023 | { | 1195 | // child prim from the database and the subsequent storing of the prim sees |
1024 | HasInventoryChanged = false; | 1196 | // the inventory of it as unchanged and doesn't store it at all. The overhead |
1025 | List<TaskInventoryItem> items = GetInventoryItems(); | 1197 | // of storing prim inventory needlessly is much less than the aggravation |
1026 | datastore.StorePrimInventory(m_part.UUID, items); | 1198 | // of prim inventory loss. |
1199 | // if (HasInventoryChanged) | ||
1200 | // { | ||
1201 | Items.LockItemsForRead(true); | ||
1202 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | ||
1203 | Items.LockItemsForRead(false); | ||
1027 | 1204 | ||
1028 | } | 1205 | HasInventoryChanged = false; |
1206 | // } | ||
1029 | } | 1207 | } |
1030 | 1208 | ||
1031 | public class InventoryStringBuilder | 1209 | public class InventoryStringBuilder |
@@ -1091,87 +1269,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
1091 | { | 1269 | { |
1092 | uint mask=0x7fffffff; | 1270 | uint mask=0x7fffffff; |
1093 | 1271 | ||
1094 | lock (m_items) | 1272 | foreach (TaskInventoryItem item in m_items.Values) |
1095 | { | 1273 | { |
1096 | foreach (TaskInventoryItem item in m_items.Values) | 1274 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) |
1275 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1276 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1277 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1278 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1279 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1280 | |||
1281 | if (item.InvType == (int)InventoryType.Object) | ||
1097 | { | 1282 | { |
1098 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | 1283 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1099 | mask &= ~((uint)PermissionMask.Copy >> 13); | 1284 | mask &= ~((uint)PermissionMask.Copy >> 13); |
1100 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | 1285 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1101 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1286 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
1102 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | 1287 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1103 | mask &= ~((uint)PermissionMask.Modify >> 13); | 1288 | mask &= ~((uint)PermissionMask.Modify >> 13); |
1104 | |||
1105 | if (item.InvType != (int)InventoryType.Object) | ||
1106 | { | ||
1107 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | ||
1108 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1109 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1110 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1111 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1112 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1113 | } | ||
1114 | else | ||
1115 | { | ||
1116 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1117 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1118 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1119 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1120 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1121 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1122 | } | ||
1123 | |||
1124 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1125 | mask &= ~(uint)PermissionMask.Copy; | ||
1126 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1127 | mask &= ~(uint)PermissionMask.Transfer; | ||
1128 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1129 | mask &= ~(uint)PermissionMask.Modify; | ||
1130 | } | 1289 | } |
1290 | |||
1291 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1292 | mask &= ~(uint)PermissionMask.Copy; | ||
1293 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1294 | mask &= ~(uint)PermissionMask.Transfer; | ||
1295 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1296 | mask &= ~(uint)PermissionMask.Modify; | ||
1131 | } | 1297 | } |
1132 | |||
1133 | return mask; | 1298 | return mask; |
1134 | } | 1299 | } |
1135 | 1300 | ||
1136 | public void ApplyNextOwnerPermissions() | 1301 | public void ApplyNextOwnerPermissions() |
1137 | { | 1302 | { |
1138 | lock (m_items) | 1303 | foreach (TaskInventoryItem item in m_items.Values) |
1139 | { | 1304 | { |
1140 | foreach (TaskInventoryItem item in m_items.Values) | 1305 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) |
1141 | { | 1306 | { |
1142 | // m_log.DebugFormat ( | 1307 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1143 | // "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", | 1308 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |
1144 | // item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); | 1309 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1145 | 1310 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | |
1146 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) | 1311 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1147 | { | 1312 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
1148 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1149 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | ||
1150 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1151 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | ||
1152 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1153 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | ||
1154 | } | ||
1155 | |||
1156 | item.CurrentPermissions &= item.NextPermissions; | ||
1157 | item.BasePermissions &= item.NextPermissions; | ||
1158 | item.EveryonePermissions &= item.NextPermissions; | ||
1159 | item.OwnerChanged = true; | ||
1160 | item.PermsMask = 0; | ||
1161 | item.PermsGranter = UUID.Zero; | ||
1162 | } | 1313 | } |
1314 | item.CurrentPermissions &= item.NextPermissions; | ||
1315 | item.BasePermissions &= item.NextPermissions; | ||
1316 | item.EveryonePermissions &= item.NextPermissions; | ||
1317 | item.OwnerChanged = true; | ||
1318 | item.PermsMask = 0; | ||
1319 | item.PermsGranter = UUID.Zero; | ||
1163 | } | 1320 | } |
1164 | } | 1321 | } |
1165 | 1322 | ||
1166 | public void ApplyGodPermissions(uint perms) | 1323 | public void ApplyGodPermissions(uint perms) |
1167 | { | 1324 | { |
1168 | lock (m_items) | 1325 | foreach (TaskInventoryItem item in m_items.Values) |
1169 | { | 1326 | { |
1170 | foreach (TaskInventoryItem item in m_items.Values) | 1327 | item.CurrentPermissions = perms; |
1171 | { | 1328 | item.BasePermissions = perms; |
1172 | item.CurrentPermissions = perms; | ||
1173 | item.BasePermissions = perms; | ||
1174 | } | ||
1175 | } | 1329 | } |
1176 | 1330 | ||
1177 | m_inventorySerial++; | 1331 | m_inventorySerial++; |
@@ -1184,14 +1338,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1184 | /// <returns></returns> | 1338 | /// <returns></returns> |
1185 | public bool ContainsScripts() | 1339 | public bool ContainsScripts() |
1186 | { | 1340 | { |
1187 | lock (m_items) | 1341 | foreach (TaskInventoryItem item in m_items.Values) |
1188 | { | 1342 | { |
1189 | foreach (TaskInventoryItem item in m_items.Values) | 1343 | if (item.InvType == (int)InventoryType.LSL) |
1190 | { | 1344 | { |
1191 | if (item.InvType == (int)InventoryType.LSL) | 1345 | return true; |
1192 | { | ||
1193 | return true; | ||
1194 | } | ||
1195 | } | 1346 | } |
1196 | } | 1347 | } |
1197 | 1348 | ||
@@ -1205,17 +1356,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1205 | public int ScriptCount() | 1356 | public int ScriptCount() |
1206 | { | 1357 | { |
1207 | int count = 0; | 1358 | int count = 0; |
1208 | lock (m_items) | 1359 | Items.LockItemsForRead(true); |
1360 | foreach (TaskInventoryItem item in m_items.Values) | ||
1209 | { | 1361 | { |
1210 | foreach (TaskInventoryItem item in m_items.Values) | 1362 | if (item.InvType == (int)InventoryType.LSL) |
1211 | { | 1363 | { |
1212 | if (item.InvType == (int)InventoryType.LSL) | 1364 | count++; |
1213 | { | ||
1214 | count++; | ||
1215 | } | ||
1216 | } | 1365 | } |
1217 | } | 1366 | } |
1218 | 1367 | Items.LockItemsForRead(false); | |
1219 | return count; | 1368 | return count; |
1220 | } | 1369 | } |
1221 | /// <summary> | 1370 | /// <summary> |
@@ -1251,11 +1400,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1251 | { | 1400 | { |
1252 | List<UUID> ret = new List<UUID>(); | 1401 | List<UUID> ret = new List<UUID>(); |
1253 | 1402 | ||
1254 | lock (m_items) | 1403 | foreach (TaskInventoryItem item in m_items.Values) |
1255 | { | 1404 | ret.Add(item.ItemID); |
1256 | foreach (TaskInventoryItem item in m_items.Values) | ||
1257 | ret.Add(item.ItemID); | ||
1258 | } | ||
1259 | 1405 | ||
1260 | return ret; | 1406 | return ret; |
1261 | } | 1407 | } |
@@ -1264,8 +1410,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1264 | { | 1410 | { |
1265 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1411 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1266 | 1412 | ||
1267 | lock (m_items) | 1413 | Items.LockItemsForRead(true); |
1268 | ret = new List<TaskInventoryItem>(m_items.Values); | 1414 | ret = new List<TaskInventoryItem>(m_items.Values); |
1415 | Items.LockItemsForRead(false); | ||
1269 | 1416 | ||
1270 | return ret; | 1417 | return ret; |
1271 | } | 1418 | } |
@@ -1274,18 +1421,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1274 | { | 1421 | { |
1275 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1422 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1276 | 1423 | ||
1277 | lock (m_items) | 1424 | Items.LockItemsForRead(true); |
1278 | { | 1425 | |
1279 | foreach (TaskInventoryItem item in m_items.Values) | 1426 | foreach (TaskInventoryItem item in m_items.Values) |
1280 | if (item.InvType == (int)type) | 1427 | if (item.InvType == (int)type) |
1281 | ret.Add(item); | 1428 | ret.Add(item); |
1282 | } | 1429 | |
1430 | Items.LockItemsForRead(false); | ||
1283 | 1431 | ||
1284 | return ret; | 1432 | return ret; |
1285 | } | 1433 | } |
1286 | 1434 | ||
1287 | public Dictionary<UUID, string> GetScriptStates() | 1435 | public Dictionary<UUID, string> GetScriptStates() |
1288 | { | 1436 | { |
1437 | return GetScriptStates(false); | ||
1438 | } | ||
1439 | |||
1440 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1441 | { | ||
1289 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1442 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
1290 | 1443 | ||
1291 | if (m_part.ParentGroup.Scene == null) // Group not in a scene | 1444 | if (m_part.ParentGroup.Scene == null) // Group not in a scene |
@@ -1311,14 +1464,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1311 | string n = e.GetXMLState(item.ItemID); | 1464 | string n = e.GetXMLState(item.ItemID); |
1312 | if (n != String.Empty) | 1465 | if (n != String.Empty) |
1313 | { | 1466 | { |
1314 | if (!ret.ContainsKey(item.ItemID)) | 1467 | if (oldIDs) |
1315 | ret[item.ItemID] = n; | 1468 | { |
1469 | if (!ret.ContainsKey(item.OldItemID)) | ||
1470 | ret[item.OldItemID] = n; | ||
1471 | } | ||
1472 | else | ||
1473 | { | ||
1474 | if (!ret.ContainsKey(item.ItemID)) | ||
1475 | ret[item.ItemID] = n; | ||
1476 | } | ||
1316 | break; | 1477 | break; |
1317 | } | 1478 | } |
1318 | } | 1479 | } |
1319 | } | 1480 | } |
1320 | } | 1481 | } |
1321 | |||
1322 | return ret; | 1482 | return ret; |
1323 | } | 1483 | } |
1324 | 1484 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 71e322d..f9c7935 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -63,6 +63,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
63 | 63 | ||
64 | struct ScriptControllers | 64 | struct ScriptControllers |
65 | { | 65 | { |
66 | public UUID objectID; | ||
66 | public UUID itemID; | 67 | public UUID itemID; |
67 | public ScriptControlled ignoreControls; | 68 | public ScriptControlled ignoreControls; |
68 | public ScriptControlled eventControls; | 69 | public ScriptControlled eventControls; |
@@ -99,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
99 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 100 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
100 | /// issue #1716 | 101 | /// issue #1716 |
101 | /// </summary> | 102 | /// </summary> |
102 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | 103 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); |
103 | 104 | ||
104 | /// <summary> | 105 | /// <summary> |
105 | /// Movement updates for agents in neighboring regions are sent directly to clients. | 106 | /// Movement updates for agents in neighboring regions are sent directly to clients. |
@@ -171,6 +172,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
171 | // private int m_lastColCount = -1; //KF: Look for Collision chnages | 172 | // private int m_lastColCount = -1; //KF: Look for Collision chnages |
172 | // private int m_updateCount = 0; //KF: Update Anims for a while | 173 | // private int m_updateCount = 0; //KF: Update Anims for a while |
173 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 174 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
175 | private List<uint> m_lastColliders = new List<uint>(); | ||
174 | 176 | ||
175 | private TeleportFlags m_teleportFlags; | 177 | private TeleportFlags m_teleportFlags; |
176 | public TeleportFlags TeleportFlags | 178 | public TeleportFlags TeleportFlags |
@@ -232,6 +234,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
232 | //private int m_moveToPositionStateStatus; | 234 | //private int m_moveToPositionStateStatus; |
233 | //***************************************************** | 235 | //***************************************************** |
234 | 236 | ||
237 | private bool m_collisionEventFlag = false; | ||
238 | private object m_collisionEventLock = new Object(); | ||
239 | |||
240 | private int m_movementAnimationUpdateCounter = 0; | ||
241 | |||
242 | private Vector3 m_prevSitOffset; | ||
243 | |||
235 | protected AvatarAppearance m_appearance; | 244 | protected AvatarAppearance m_appearance; |
236 | 245 | ||
237 | public AvatarAppearance Appearance | 246 | public AvatarAppearance Appearance |
@@ -426,7 +435,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
426 | get { return (IClientCore)ControllingClient; } | 435 | get { return (IClientCore)ControllingClient; } |
427 | } | 436 | } |
428 | 437 | ||
429 | public Vector3 ParentPosition { get; set; } | 438 | // public Vector3 ParentPosition { get; set; } |
430 | 439 | ||
431 | /// <summary> | 440 | /// <summary> |
432 | /// Position of this avatar relative to the region the avatar is in | 441 | /// Position of this avatar relative to the region the avatar is in |
@@ -484,7 +493,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
484 | if (ParentID == 0) | 493 | if (ParentID == 0) |
485 | { | 494 | { |
486 | m_pos = value; | 495 | m_pos = value; |
487 | ParentPosition = Vector3.Zero; | 496 | // ParentPosition = Vector3.Zero; |
488 | } | 497 | } |
489 | 498 | ||
490 | //m_log.DebugFormat( | 499 | //m_log.DebugFormat( |
@@ -573,6 +582,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
573 | /// </summary> | 582 | /// </summary> |
574 | public uint ParentID { get; set; } | 583 | public uint ParentID { get; set; } |
575 | 584 | ||
585 | public UUID ParentUUID | ||
586 | { | ||
587 | get { return m_parentUUID; } | ||
588 | set { m_parentUUID = value; } | ||
589 | } | ||
590 | private UUID m_parentUUID = UUID.Zero; | ||
591 | |||
576 | /// <summary> | 592 | /// <summary> |
577 | /// Are we sitting on an object? | 593 | /// Are we sitting on an object? |
578 | /// </summary> | 594 | /// </summary> |
@@ -739,6 +755,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
739 | Appearance = appearance; | 755 | Appearance = appearance; |
740 | } | 756 | } |
741 | 757 | ||
758 | private void RegionHeartbeatEnd(Scene scene) | ||
759 | { | ||
760 | if (IsChildAgent) | ||
761 | return; | ||
762 | |||
763 | m_movementAnimationUpdateCounter ++; | ||
764 | if (m_movementAnimationUpdateCounter >= 2) | ||
765 | { | ||
766 | m_movementAnimationUpdateCounter = 0; | ||
767 | if (Animator != null) | ||
768 | { | ||
769 | // If the parentID == 0 we are not sitting | ||
770 | // if !SitGournd then we are not sitting on the ground | ||
771 | // Fairly straightforward, now here comes the twist | ||
772 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
773 | // be sat on an object that isn't there yet. Should | ||
774 | // be treated as if sat. | ||
775 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
776 | Animator.UpdateMovementAnimations(); | ||
777 | } | ||
778 | else | ||
779 | { | ||
780 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
781 | } | ||
782 | } | ||
783 | } | ||
784 | |||
742 | public void RegisterToEvents() | 785 | public void RegisterToEvents() |
743 | { | 786 | { |
744 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 787 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -748,6 +791,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
748 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 791 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
749 | ControllingClient.OnStartAnim += HandleStartAnim; | 792 | ControllingClient.OnStartAnim += HandleStartAnim; |
750 | ControllingClient.OnStopAnim += HandleStopAnim; | 793 | ControllingClient.OnStopAnim += HandleStopAnim; |
794 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
751 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 795 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
752 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 796 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
753 | 797 | ||
@@ -808,10 +852,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
808 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 852 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
809 | Name, m_scene.RegionInfo.RegionName); | 853 | Name, m_scene.RegionInfo.RegionName); |
810 | 854 | ||
811 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
812 | |||
813 | bool wasChild = IsChildAgent; | 855 | bool wasChild = IsChildAgent; |
814 | IsChildAgent = false; | 856 | |
857 | if (ParentUUID != UUID.Zero) | ||
858 | { | ||
859 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
860 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
861 | if (part == null) | ||
862 | { | ||
863 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
864 | } | ||
865 | else | ||
866 | { | ||
867 | part.ParentGroup.AddAvatar(UUID); | ||
868 | if (part.SitTargetPosition != Vector3.Zero) | ||
869 | part.SitTargetAvatar = UUID; | ||
870 | // ParentPosition = part.GetWorldPosition(); | ||
871 | ParentID = part.LocalId; | ||
872 | ParentPart = part; | ||
873 | m_pos = m_prevSitOffset; | ||
874 | // pos = ParentPosition; | ||
875 | pos = part.GetWorldPosition(); | ||
876 | } | ||
877 | ParentUUID = UUID.Zero; | ||
878 | |||
879 | IsChildAgent = false; | ||
880 | |||
881 | // Animator.TrySetMovementAnimation("SIT"); | ||
882 | } | ||
883 | else | ||
884 | { | ||
885 | IsChildAgent = false; | ||
886 | } | ||
887 | |||
815 | 888 | ||
816 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 889 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
817 | if (gm != null) | 890 | if (gm != null) |
@@ -821,62 +894,72 @@ namespace OpenSim.Region.Framework.Scenes | |||
821 | 894 | ||
822 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 895 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
823 | 896 | ||
824 | // Moved this from SendInitialData to ensure that Appearance is initialized | 897 | if (ParentID == 0) |
825 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | ||
826 | // related to the handling of attachments | ||
827 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
828 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
829 | { | 898 | { |
830 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 899 | // Moved this from SendInitialData to ensure that Appearance is initialized |
831 | pos.X = crossedBorder.BorderLine.Z - 1; | 900 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
832 | } | 901 | // related to the handling of attachments |
902 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
903 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
904 | { | ||
905 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
906 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
907 | } | ||
833 | 908 | ||
834 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | 909 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
835 | { | 910 | { |
836 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 911 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
837 | pos.Y = crossedBorder.BorderLine.Z - 1; | 912 | pos.Y = crossedBorder.BorderLine.Z - 1; |
838 | } | 913 | } |
839 | 914 | ||
840 | CheckAndAdjustLandingPoint(ref pos); | 915 | CheckAndAdjustLandingPoint(ref pos); |
841 | 916 | ||
842 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 917 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
843 | { | 918 | { |
844 | m_log.WarnFormat( | 919 | m_log.WarnFormat( |
845 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 920 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
846 | pos, Name, UUID); | 921 | pos, Name, UUID); |
847 | 922 | ||
848 | if (pos.X < 0f) pos.X = 0f; | 923 | if (pos.X < 0f) pos.X = 0f; |
849 | if (pos.Y < 0f) pos.Y = 0f; | 924 | if (pos.Y < 0f) pos.Y = 0f; |
850 | if (pos.Z < 0f) pos.Z = 0f; | 925 | if (pos.Z < 0f) pos.Z = 0f; |
851 | } | 926 | } |
852 | 927 | ||
853 | float localAVHeight = 1.56f; | 928 | float localAVHeight = 1.56f; |
854 | if (Appearance.AvatarHeight > 0) | 929 | if (Appearance.AvatarHeight > 0) |
855 | localAVHeight = Appearance.AvatarHeight; | 930 | localAVHeight = Appearance.AvatarHeight; |
856 | 931 | ||
857 | float posZLimit = 0; | 932 | float posZLimit = 0; |
858 | 933 | ||
859 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 934 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
860 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 935 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
861 | 936 | ||
862 | float newPosZ = posZLimit + localAVHeight / 2; | 937 | float newPosZ = posZLimit + localAVHeight / 2; |
863 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 938 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
864 | { | 939 | { |
865 | pos.Z = newPosZ; | 940 | pos.Z = newPosZ; |
866 | } | 941 | } |
867 | AbsolutePosition = pos; | 942 | AbsolutePosition = pos; |
868 | 943 | ||
869 | AddToPhysicalScene(isFlying); | 944 | if (m_teleportFlags == TeleportFlags.Default) |
945 | { | ||
946 | Vector3 vel = Velocity; | ||
947 | AddToPhysicalScene(isFlying); | ||
948 | if (PhysicsActor != null) | ||
949 | PhysicsActor.SetMomentum(vel); | ||
950 | } | ||
951 | else | ||
952 | AddToPhysicalScene(isFlying); | ||
870 | 953 | ||
871 | if (ForceFly) | 954 | if (ForceFly) |
872 | { | 955 | { |
873 | Flying = true; | 956 | Flying = true; |
874 | } | 957 | } |
875 | else if (FlyDisabled) | 958 | else if (FlyDisabled) |
876 | { | 959 | { |
877 | Flying = false; | 960 | Flying = false; |
961 | } | ||
878 | } | 962 | } |
879 | |||
880 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 963 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
881 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 964 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
882 | // elsewhere anyway | 965 | // elsewhere anyway |
@@ -896,14 +979,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
896 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | 979 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); |
897 | 980 | ||
898 | // Resume scripts | 981 | // Resume scripts |
899 | foreach (SceneObjectGroup sog in m_attachments) | 982 | Util.FireAndForget(delegate(object x) { |
900 | { | 983 | foreach (SceneObjectGroup sog in m_attachments) |
901 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 984 | { |
902 | sog.ResumeScripts(); | 985 | sog.ScheduleGroupForFullUpdate(); |
903 | } | 986 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
987 | sog.ResumeScripts(); | ||
988 | } | ||
989 | }); | ||
904 | } | 990 | } |
905 | } | 991 | } |
906 | 992 | ||
993 | SendAvatarDataToAllAgents(); | ||
994 | |||
907 | // send the animations of the other presences to me | 995 | // send the animations of the other presences to me |
908 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 996 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
909 | { | 997 | { |
@@ -914,9 +1002,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
914 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1002 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
915 | // stall on the border crossing since the existing child agent will still have the last movement | 1003 | // stall on the border crossing since the existing child agent will still have the last movement |
916 | // recorded, which stops the input from being processed. | 1004 | // recorded, which stops the input from being processed. |
1005 | |||
917 | MovementFlag = 0; | 1006 | MovementFlag = 0; |
918 | 1007 | ||
919 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1008 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1009 | |||
1010 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
920 | } | 1011 | } |
921 | 1012 | ||
922 | public int GetStateSource() | 1013 | public int GetStateSource() |
@@ -944,12 +1035,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
944 | /// </remarks> | 1035 | /// </remarks> |
945 | public void MakeChildAgent() | 1036 | public void MakeChildAgent() |
946 | { | 1037 | { |
1038 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1039 | |||
947 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1040 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
948 | 1041 | ||
949 | // Reset these so that teleporting in and walking out isn't seen | 1042 | // Reset these so that teleporting in and walking out isn't seen |
950 | // as teleporting back | 1043 | // as teleporting back |
951 | TeleportFlags = TeleportFlags.Default; | 1044 | TeleportFlags = TeleportFlags.Default; |
952 | 1045 | ||
1046 | MovementFlag = 0; | ||
1047 | |||
953 | // It looks like Animator is set to null somewhere, and MakeChild | 1048 | // It looks like Animator is set to null somewhere, and MakeChild |
954 | // is called after that. Probably in aborted teleports. | 1049 | // is called after that. Probably in aborted teleports. |
955 | if (Animator == null) | 1050 | if (Animator == null) |
@@ -957,6 +1052,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
957 | else | 1052 | else |
958 | Animator.ResetAnimations(); | 1053 | Animator.ResetAnimations(); |
959 | 1054 | ||
1055 | |||
960 | // m_log.DebugFormat( | 1056 | // m_log.DebugFormat( |
961 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1057 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
962 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1058 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -968,6 +1064,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
968 | IsChildAgent = true; | 1064 | IsChildAgent = true; |
969 | m_scene.SwapRootAgentCount(true); | 1065 | m_scene.SwapRootAgentCount(true); |
970 | RemoveFromPhysicalScene(); | 1066 | RemoveFromPhysicalScene(); |
1067 | ParentID = 0; // Child agents can't be sitting | ||
971 | 1068 | ||
972 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1069 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
973 | 1070 | ||
@@ -983,9 +1080,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
983 | { | 1080 | { |
984 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1081 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
985 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1082 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
986 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
987 | PhysicsActor.UnSubscribeEvents(); | ||
988 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1083 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1084 | PhysicsActor.UnSubscribeEvents(); | ||
1085 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
989 | PhysicsActor = null; | 1086 | PhysicsActor = null; |
990 | } | 1087 | } |
991 | // else | 1088 | // else |
@@ -1002,7 +1099,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1002 | /// <param name="pos"></param> | 1099 | /// <param name="pos"></param> |
1003 | public void Teleport(Vector3 pos) | 1100 | public void Teleport(Vector3 pos) |
1004 | { | 1101 | { |
1005 | TeleportWithMomentum(pos, null); | 1102 | TeleportWithMomentum(pos, Vector3.Zero); |
1006 | } | 1103 | } |
1007 | 1104 | ||
1008 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1105 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1026,6 +1123,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1026 | SendTerseUpdateToAllClients(); | 1123 | SendTerseUpdateToAllClients(); |
1027 | } | 1124 | } |
1028 | 1125 | ||
1126 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1127 | { | ||
1128 | CheckLandingPoint(ref newpos); | ||
1129 | AbsolutePosition = newpos; | ||
1130 | |||
1131 | if (newvel.HasValue) | ||
1132 | { | ||
1133 | if ((Vector3)newvel == Vector3.Zero) | ||
1134 | { | ||
1135 | if (PhysicsActor != null) | ||
1136 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1137 | m_velocity = Vector3.Zero; | ||
1138 | } | ||
1139 | else | ||
1140 | { | ||
1141 | if (PhysicsActor != null) | ||
1142 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1143 | m_velocity = (Vector3)newvel; | ||
1144 | |||
1145 | if (rotateToVelXY) | ||
1146 | { | ||
1147 | Vector3 lookAt = (Vector3)newvel; | ||
1148 | lookAt.Z = 0; | ||
1149 | lookAt.Normalize(); | ||
1150 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1151 | return; | ||
1152 | } | ||
1153 | } | ||
1154 | } | ||
1155 | |||
1156 | SendTerseUpdateToAllClients(); | ||
1157 | } | ||
1158 | |||
1159 | |||
1160 | |||
1029 | public void StopFlying() | 1161 | public void StopFlying() |
1030 | { | 1162 | { |
1031 | ControllingClient.StopFlying(this); | 1163 | ControllingClient.StopFlying(this); |
@@ -1135,7 +1267,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1135 | 1267 | ||
1136 | Vector3 look = Velocity; | 1268 | Vector3 look = Velocity; |
1137 | 1269 | ||
1138 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1270 | // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1271 | if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) | ||
1139 | { | 1272 | { |
1140 | look = new Vector3(0.99f, 0.042f, 0); | 1273 | look = new Vector3(0.99f, 0.042f, 0); |
1141 | } | 1274 | } |
@@ -1185,13 +1318,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1185 | // Create child agents in neighbouring regions | 1318 | // Create child agents in neighbouring regions |
1186 | if (openChildAgents && !IsChildAgent) | 1319 | if (openChildAgents && !IsChildAgent) |
1187 | { | 1320 | { |
1321 | |||
1188 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1322 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1189 | if (m_agentTransfer != null) | 1323 | if (m_agentTransfer != null) |
1190 | Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); | 1324 | m_agentTransfer.EnableChildAgents(this); |
1191 | 1325 | ||
1192 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1326 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1193 | if (friendsModule != null) | 1327 | if (friendsModule != null) |
1194 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1328 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1329 | |||
1195 | } | 1330 | } |
1196 | 1331 | ||
1197 | // m_log.DebugFormat( | 1332 | // m_log.DebugFormat( |
@@ -1341,8 +1476,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1341 | { | 1476 | { |
1342 | if (m_followCamAuto) | 1477 | if (m_followCamAuto) |
1343 | { | 1478 | { |
1344 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1479 | // Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1345 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1480 | // m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); |
1481 | |||
1482 | Vector3 posAdjusted = AbsolutePosition + HEAD_ADJUSTMENT; | ||
1483 | Vector3 distTocam = CameraPosition - posAdjusted; | ||
1484 | float distTocamlen = distTocam.Length(); | ||
1485 | if (distTocamlen > 0) | ||
1486 | { | ||
1487 | distTocam *= 1.0f / distTocamlen; | ||
1488 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, distTocam, distTocamlen + 0.3f, RayCastCameraCallback); | ||
1489 | } | ||
1490 | |||
1346 | } | 1491 | } |
1347 | } | 1492 | } |
1348 | 1493 | ||
@@ -1781,12 +1926,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1781 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 1926 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1782 | 1927 | ||
1783 | SitGround = false; | 1928 | SitGround = false; |
1929 | |||
1930 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1784 | if (PhysicsActor == null) | 1931 | if (PhysicsActor == null) |
1785 | AddToPhysicalScene(false); | 1932 | AddToPhysicalScene(false); |
1933 | */ | ||
1786 | 1934 | ||
1787 | if (ParentID != 0) | 1935 | if (ParentID != 0) |
1788 | { | 1936 | { |
1789 | SceneObjectPart part = ParentPart; | 1937 | SceneObjectPart part = ParentPart; |
1938 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
1939 | |||
1790 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1940 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1791 | if (taskIDict != null) | 1941 | if (taskIDict != null) |
1792 | { | 1942 | { |
@@ -1802,14 +1952,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1802 | } | 1952 | } |
1803 | } | 1953 | } |
1804 | 1954 | ||
1805 | ParentPosition = part.GetWorldPosition(); | 1955 | part.ParentGroup.DeleteAvatar(UUID); |
1956 | // ParentPosition = part.GetWorldPosition(); | ||
1806 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1957 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1807 | 1958 | ||
1808 | m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 1959 | // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
1809 | ParentPosition = Vector3.Zero; | 1960 | // ParentPosition = Vector3.Zero; |
1961 | m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
1962 | if (part.SitTargetAvatar == UUID) | ||
1963 | m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; | ||
1810 | 1964 | ||
1811 | ParentID = 0; | 1965 | ParentID = 0; |
1812 | ParentPart = null; | 1966 | ParentPart = null; |
1967 | |||
1968 | if (PhysicsActor == null) | ||
1969 | AddToPhysicalScene(false); | ||
1970 | |||
1813 | SendAvatarDataToAllAgents(); | 1971 | SendAvatarDataToAllAgents(); |
1814 | m_requestedSitTargetID = 0; | 1972 | m_requestedSitTargetID = 0; |
1815 | 1973 | ||
@@ -1819,6 +1977,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1819 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1977 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1820 | } | 1978 | } |
1821 | 1979 | ||
1980 | else if (PhysicsActor == null) | ||
1981 | AddToPhysicalScene(false); | ||
1982 | |||
1822 | Animator.TrySetMovementAnimation("STAND"); | 1983 | Animator.TrySetMovementAnimation("STAND"); |
1823 | } | 1984 | } |
1824 | 1985 | ||
@@ -1870,7 +2031,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1870 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 2031 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1871 | 2032 | ||
1872 | if (PhysicsActor != null) | 2033 | if (PhysicsActor != null) |
1873 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2034 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
1874 | 2035 | ||
1875 | bool canSit = false; | 2036 | bool canSit = false; |
1876 | Vector3 pos = part.AbsolutePosition + offset; | 2037 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -1919,7 +2080,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1919 | forceMouselook = part.GetForceMouselook(); | 2080 | forceMouselook = part.GetForceMouselook(); |
1920 | 2081 | ||
1921 | ControllingClient.SendSitResponse( | 2082 | ControllingClient.SendSitResponse( |
1922 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2083 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
1923 | 2084 | ||
1924 | m_requestedSitTargetUUID = targetID; | 2085 | m_requestedSitTargetUUID = targetID; |
1925 | 2086 | ||
@@ -1933,6 +2094,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1933 | 2094 | ||
1934 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2095 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
1935 | { | 2096 | { |
2097 | if (IsChildAgent) | ||
2098 | return; | ||
2099 | |||
1936 | if (ParentID != 0) | 2100 | if (ParentID != 0) |
1937 | { | 2101 | { |
1938 | StandUp(); | 2102 | StandUp(); |
@@ -2210,14 +2374,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2210 | 2374 | ||
2211 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2375 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2212 | 2376 | ||
2213 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2377 | double x, y, z, m; |
2378 | |||
2379 | Quaternion r = sitTargetOrient; | ||
2380 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2381 | |||
2382 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2383 | { | ||
2384 | m = 1.0 / Math.Sqrt(m); | ||
2385 | r.X *= (float)m; | ||
2386 | r.Y *= (float)m; | ||
2387 | r.Z *= (float)m; | ||
2388 | r.W *= (float)m; | ||
2389 | } | ||
2390 | |||
2391 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2392 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2393 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2394 | |||
2395 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2396 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2397 | |||
2398 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2399 | |||
2400 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2214 | Rotation = sitTargetOrient; | 2401 | Rotation = sitTargetOrient; |
2215 | ParentPosition = part.AbsolutePosition; | 2402 | // ParentPosition = part.AbsolutePosition; |
2403 | part.ParentGroup.AddAvatar(UUID); | ||
2216 | } | 2404 | } |
2217 | else | 2405 | else |
2218 | { | 2406 | { |
2219 | m_pos -= part.AbsolutePosition; | 2407 | m_pos -= part.AbsolutePosition; |
2220 | ParentPosition = part.AbsolutePosition; | 2408 | // ParentPosition = part.AbsolutePosition; |
2409 | part.ParentGroup.AddAvatar(UUID); | ||
2221 | 2410 | ||
2222 | // m_log.DebugFormat( | 2411 | // m_log.DebugFormat( |
2223 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2412 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2262,6 +2451,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2262 | Animator.RemoveAnimation(animID); | 2451 | Animator.RemoveAnimation(animID); |
2263 | } | 2452 | } |
2264 | 2453 | ||
2454 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2455 | { | ||
2456 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2457 | } | ||
2458 | |||
2459 | |||
2460 | |||
2265 | /// <summary> | 2461 | /// <summary> |
2266 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2462 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2267 | /// </summary> | 2463 | /// </summary> |
@@ -2315,14 +2511,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2315 | direc.Z *= 2.6f; | 2511 | direc.Z *= 2.6f; |
2316 | 2512 | ||
2317 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2513 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2318 | Animator.TrySetMovementAnimation("PREJUMP"); | 2514 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2319 | Animator.TrySetMovementAnimation("JUMP"); | 2515 | // Animator.TrySetMovementAnimation("JUMP"); |
2320 | } | 2516 | } |
2321 | } | 2517 | } |
2322 | } | 2518 | } |
2323 | 2519 | ||
2324 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2520 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2325 | m_forceToApply = direc; | 2521 | m_forceToApply = direc; |
2522 | Animator.UpdateMovementAnimations(); | ||
2326 | } | 2523 | } |
2327 | 2524 | ||
2328 | #endregion | 2525 | #endregion |
@@ -2714,8 +2911,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2714 | 2911 | ||
2715 | // If we don't have a PhysActor, we can't cross anyway | 2912 | // If we don't have a PhysActor, we can't cross anyway |
2716 | // Also don't do this while sat, sitting avatars cross with the | 2913 | // Also don't do this while sat, sitting avatars cross with the |
2717 | // object they sit on. | 2914 | // object they sit on. ParentUUID denoted a pending sit, don't |
2718 | if (ParentID != 0 || PhysicsActor == null) | 2915 | // interfere with it. |
2916 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
2719 | return; | 2917 | return; |
2720 | 2918 | ||
2721 | if (!IsInTransit) | 2919 | if (!IsInTransit) |
@@ -3056,6 +3254,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3056 | cAgent.AlwaysRun = SetAlwaysRun; | 3254 | cAgent.AlwaysRun = SetAlwaysRun; |
3057 | 3255 | ||
3058 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3256 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3257 | |||
3258 | cAgent.ParentPart = ParentUUID; | ||
3259 | cAgent.SitOffset = m_pos; | ||
3059 | 3260 | ||
3060 | lock (scriptedcontrols) | 3261 | lock (scriptedcontrols) |
3061 | { | 3262 | { |
@@ -3064,7 +3265,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3064 | 3265 | ||
3065 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3266 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3066 | { | 3267 | { |
3067 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3268 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3068 | } | 3269 | } |
3069 | cAgent.Controllers = controls; | 3270 | cAgent.Controllers = controls; |
3070 | } | 3271 | } |
@@ -3097,6 +3298,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3097 | CameraAtAxis = cAgent.AtAxis; | 3298 | CameraAtAxis = cAgent.AtAxis; |
3098 | CameraLeftAxis = cAgent.LeftAxis; | 3299 | CameraLeftAxis = cAgent.LeftAxis; |
3099 | CameraUpAxis = cAgent.UpAxis; | 3300 | CameraUpAxis = cAgent.UpAxis; |
3301 | ParentUUID = cAgent.ParentPart; | ||
3302 | m_prevSitOffset = cAgent.SitOffset; | ||
3100 | 3303 | ||
3101 | // When we get to the point of re-computing neighbors everytime this | 3304 | // When we get to the point of re-computing neighbors everytime this |
3102 | // changes, then start using the agent's drawdistance rather than the | 3305 | // changes, then start using the agent's drawdistance rather than the |
@@ -3134,6 +3337,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3134 | foreach (ControllerData c in cAgent.Controllers) | 3337 | foreach (ControllerData c in cAgent.Controllers) |
3135 | { | 3338 | { |
3136 | ScriptControllers sc = new ScriptControllers(); | 3339 | ScriptControllers sc = new ScriptControllers(); |
3340 | sc.objectID = c.ObjectID; | ||
3137 | sc.itemID = c.ItemID; | 3341 | sc.itemID = c.ItemID; |
3138 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3342 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3139 | sc.eventControls = (ScriptControlled)c.EventControls; | 3343 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3214,7 +3418,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3214 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3418 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3215 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3419 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3216 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3420 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3217 | PhysicsActor.SubscribeEvents(500); | 3421 | PhysicsActor.SubscribeEvents(100); |
3218 | PhysicsActor.LocalID = LocalId; | 3422 | PhysicsActor.LocalID = LocalId; |
3219 | } | 3423 | } |
3220 | 3424 | ||
@@ -3241,7 +3445,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3241 | /// <param name="e"></param> | 3445 | /// <param name="e"></param> |
3242 | public void PhysicsCollisionUpdate(EventArgs e) | 3446 | public void PhysicsCollisionUpdate(EventArgs e) |
3243 | { | 3447 | { |
3244 | if (IsChildAgent) | 3448 | if (IsChildAgent || Animator == null) |
3245 | return; | 3449 | return; |
3246 | 3450 | ||
3247 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3451 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
@@ -3296,6 +3500,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3296 | } | 3500 | } |
3297 | } | 3501 | } |
3298 | 3502 | ||
3503 | RaiseCollisionScriptEvents(coldata); | ||
3504 | |||
3299 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3505 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3300 | if (Invulnerable || GodLevel > 0) | 3506 | if (Invulnerable || GodLevel > 0) |
3301 | return; | 3507 | return; |
@@ -3393,6 +3599,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3393 | // m_reprioritizationTimer.Dispose(); | 3599 | // m_reprioritizationTimer.Dispose(); |
3394 | 3600 | ||
3395 | RemoveFromPhysicalScene(); | 3601 | RemoveFromPhysicalScene(); |
3602 | |||
3603 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
3604 | |||
3605 | // if (Animator != null) | ||
3606 | // Animator.Close(); | ||
3607 | Animator = null; | ||
3608 | |||
3396 | } | 3609 | } |
3397 | 3610 | ||
3398 | public void AddAttachment(SceneObjectGroup gobj) | 3611 | public void AddAttachment(SceneObjectGroup gobj) |
@@ -3626,10 +3839,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3626 | 3839 | ||
3627 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 3840 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3628 | { | 3841 | { |
3842 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
3843 | if (p == null) | ||
3844 | return; | ||
3845 | |||
3846 | ControllingClient.SendTakeControls(controls, false, false); | ||
3847 | ControllingClient.SendTakeControls(controls, true, false); | ||
3848 | |||
3629 | ScriptControllers obj = new ScriptControllers(); | 3849 | ScriptControllers obj = new ScriptControllers(); |
3630 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 3850 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3631 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 3851 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3632 | 3852 | ||
3853 | obj.objectID = p.ParentGroup.UUID; | ||
3633 | obj.itemID = Script_item_UUID; | 3854 | obj.itemID = Script_item_UUID; |
3634 | if (pass_on == 0 && accept == 0) | 3855 | if (pass_on == 0 && accept == 0) |
3635 | { | 3856 | { |
@@ -3678,6 +3899,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3678 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 3899 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3679 | } | 3900 | } |
3680 | 3901 | ||
3902 | private void UnRegisterSeatControls(UUID obj) | ||
3903 | { | ||
3904 | List<UUID> takers = new List<UUID>(); | ||
3905 | |||
3906 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
3907 | { | ||
3908 | if (c.objectID == obj) | ||
3909 | takers.Add(c.itemID); | ||
3910 | } | ||
3911 | foreach (UUID t in takers) | ||
3912 | { | ||
3913 | UnRegisterControlEventsToScript(0, t); | ||
3914 | } | ||
3915 | } | ||
3916 | |||
3681 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 3917 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3682 | { | 3918 | { |
3683 | ScriptControllers takecontrols; | 3919 | ScriptControllers takecontrols; |
@@ -3996,6 +4232,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3996 | 4232 | ||
3997 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4233 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
3998 | { | 4234 | { |
4235 | string reason; | ||
4236 | |||
4237 | // Honor bans | ||
4238 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4239 | return; | ||
4240 | |||
3999 | SceneObjectGroup telehub = null; | 4241 | SceneObjectGroup telehub = null; |
4000 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4242 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
4001 | { | 4243 | { |
@@ -4035,11 +4277,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4035 | pos = land.LandData.UserLocation; | 4277 | pos = land.LandData.UserLocation; |
4036 | } | 4278 | } |
4037 | } | 4279 | } |
4038 | 4280 | ||
4039 | land.SendLandUpdateToClient(ControllingClient); | 4281 | land.SendLandUpdateToClient(ControllingClient); |
4040 | } | 4282 | } |
4041 | } | 4283 | } |
4042 | 4284 | ||
4285 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4286 | { | ||
4287 | DetectedObject detobj = new DetectedObject(); | ||
4288 | detobj.keyUUID = obj.UUID; | ||
4289 | detobj.nameStr = obj.Name; | ||
4290 | detobj.ownerUUID = obj.OwnerID; | ||
4291 | detobj.posVector = obj.AbsolutePosition; | ||
4292 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4293 | detobj.velVector = obj.Velocity; | ||
4294 | detobj.colliderType = 0; | ||
4295 | detobj.groupUUID = obj.GroupID; | ||
4296 | |||
4297 | return detobj; | ||
4298 | } | ||
4299 | |||
4300 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4301 | { | ||
4302 | DetectedObject detobj = new DetectedObject(); | ||
4303 | detobj.keyUUID = av.UUID; | ||
4304 | detobj.nameStr = av.ControllingClient.Name; | ||
4305 | detobj.ownerUUID = av.UUID; | ||
4306 | detobj.posVector = av.AbsolutePosition; | ||
4307 | detobj.rotQuat = av.Rotation; | ||
4308 | detobj.velVector = av.Velocity; | ||
4309 | detobj.colliderType = 0; | ||
4310 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4311 | |||
4312 | return detobj; | ||
4313 | } | ||
4314 | |||
4315 | private DetectedObject CreateDetObjectForGround() | ||
4316 | { | ||
4317 | DetectedObject detobj = new DetectedObject(); | ||
4318 | detobj.keyUUID = UUID.Zero; | ||
4319 | detobj.nameStr = ""; | ||
4320 | detobj.ownerUUID = UUID.Zero; | ||
4321 | detobj.posVector = AbsolutePosition; | ||
4322 | detobj.rotQuat = Quaternion.Identity; | ||
4323 | detobj.velVector = Vector3.Zero; | ||
4324 | detobj.colliderType = 0; | ||
4325 | detobj.groupUUID = UUID.Zero; | ||
4326 | |||
4327 | return detobj; | ||
4328 | } | ||
4329 | |||
4330 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4331 | { | ||
4332 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4333 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4334 | foreach (uint localId in colliders) | ||
4335 | { | ||
4336 | if (localId == 0) | ||
4337 | continue; | ||
4338 | |||
4339 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4340 | if (obj != null) | ||
4341 | { | ||
4342 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4343 | colliding.Add(CreateDetObject(obj)); | ||
4344 | } | ||
4345 | else | ||
4346 | { | ||
4347 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4348 | if (av != null && (!av.IsChildAgent)) | ||
4349 | { | ||
4350 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4351 | colliding.Add(CreateDetObject(av)); | ||
4352 | } | ||
4353 | } | ||
4354 | } | ||
4355 | |||
4356 | colliderArgs.Colliders = colliding; | ||
4357 | |||
4358 | return colliderArgs; | ||
4359 | } | ||
4360 | |||
4361 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4362 | |||
4363 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4364 | { | ||
4365 | ColliderArgs CollidingMessage; | ||
4366 | |||
4367 | if (colliders.Count > 0) | ||
4368 | { | ||
4369 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4370 | { | ||
4371 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4372 | |||
4373 | if (CollidingMessage.Colliders.Count > 0) | ||
4374 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4375 | } | ||
4376 | } | ||
4377 | } | ||
4378 | |||
4379 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4380 | { | ||
4381 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4382 | { | ||
4383 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4384 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4385 | |||
4386 | colliding.Add(CreateDetObjectForGround()); | ||
4387 | LandCollidingMessage.Colliders = colliding; | ||
4388 | |||
4389 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4390 | } | ||
4391 | } | ||
4392 | |||
4393 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4394 | { | ||
4395 | try | ||
4396 | { | ||
4397 | List<uint> thisHitColliders = new List<uint>(); | ||
4398 | List<uint> endedColliders = new List<uint>(); | ||
4399 | List<uint> startedColliders = new List<uint>(); | ||
4400 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4401 | CollisionForSoundInfo soundinfo; | ||
4402 | ContactPoint curcontact; | ||
4403 | |||
4404 | if (coldata.Count == 0) | ||
4405 | { | ||
4406 | if (m_lastColliders.Count == 0) | ||
4407 | return; // nothing to do | ||
4408 | |||
4409 | foreach (uint localID in m_lastColliders) | ||
4410 | { | ||
4411 | endedColliders.Add(localID); | ||
4412 | } | ||
4413 | m_lastColliders.Clear(); | ||
4414 | } | ||
4415 | |||
4416 | else | ||
4417 | { | ||
4418 | foreach (uint id in coldata.Keys) | ||
4419 | { | ||
4420 | thisHitColliders.Add(id); | ||
4421 | if (!m_lastColliders.Contains(id)) | ||
4422 | { | ||
4423 | startedColliders.Add(id); | ||
4424 | curcontact = coldata[id]; | ||
4425 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4426 | { | ||
4427 | soundinfo = new CollisionForSoundInfo(); | ||
4428 | soundinfo.colliderID = id; | ||
4429 | soundinfo.position = curcontact.Position; | ||
4430 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4431 | soundinfolist.Add(soundinfo); | ||
4432 | } | ||
4433 | } | ||
4434 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4435 | } | ||
4436 | |||
4437 | // calculate things that ended colliding | ||
4438 | foreach (uint localID in m_lastColliders) | ||
4439 | { | ||
4440 | if (!thisHitColliders.Contains(localID)) | ||
4441 | { | ||
4442 | endedColliders.Add(localID); | ||
4443 | } | ||
4444 | } | ||
4445 | //add the items that started colliding this time to the last colliders list. | ||
4446 | foreach (uint localID in startedColliders) | ||
4447 | { | ||
4448 | m_lastColliders.Add(localID); | ||
4449 | } | ||
4450 | // remove things that ended colliding from the last colliders list | ||
4451 | foreach (uint localID in endedColliders) | ||
4452 | { | ||
4453 | m_lastColliders.Remove(localID); | ||
4454 | } | ||
4455 | |||
4456 | if (soundinfolist.Count > 0) | ||
4457 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4458 | } | ||
4459 | |||
4460 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4461 | { | ||
4462 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4463 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4464 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4465 | |||
4466 | if (startedColliders.Contains(0)) | ||
4467 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4468 | if (m_lastColliders.Contains(0)) | ||
4469 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4470 | if (endedColliders.Contains(0)) | ||
4471 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4472 | } | ||
4473 | } | ||
4474 | finally | ||
4475 | { | ||
4476 | m_collisionEventFlag = false; | ||
4477 | } | ||
4478 | } | ||
4479 | |||
4043 | private void TeleportFlagsDebug() { | 4480 | private void TeleportFlagsDebug() { |
4044 | 4481 | ||
4045 | // Some temporary debugging help to show all the TeleportFlags we have... | 4482 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4064,6 +4501,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4064 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4501 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4065 | 4502 | ||
4066 | } | 4503 | } |
4067 | |||
4068 | } | 4504 | } |
4069 | } | 4505 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 2d4c60a..123c158 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -262,6 +262,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
262 | sr.Close(); | 262 | sr.Close(); |
263 | } | 263 | } |
264 | 264 | ||
265 | XmlNodeList keymotion = doc.GetElementsByTagName("KeyframeMotion"); | ||
266 | if (keymotion.Count > 0) | ||
267 | sceneObject.RootPart.KeyframeMotion = KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(keymotion[0].InnerText)); | ||
268 | else | ||
269 | sceneObject.RootPart.KeyframeMotion = null; | ||
270 | |||
265 | // Script state may, or may not, exist. Not having any, is NOT | 271 | // Script state may, or may not, exist. Not having any, is NOT |
266 | // ever a problem. | 272 | // ever a problem. |
267 | sceneObject.LoadScriptState(doc); | 273 | sceneObject.LoadScriptState(doc); |
@@ -366,6 +372,23 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
366 | m_SOPXmlProcessors.Add("PayPrice2", ProcessPayPrice2); | 372 | m_SOPXmlProcessors.Add("PayPrice2", ProcessPayPrice2); |
367 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); | 373 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); |
368 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); | 374 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); |
375 | |||
376 | m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); | ||
377 | m_SOPXmlProcessors.Add("Force", ProcessForce); | ||
378 | m_SOPXmlProcessors.Add("Torque", ProcessTorque); | ||
379 | m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); | ||
380 | |||
381 | |||
382 | m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); | ||
383 | |||
384 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); | ||
385 | m_SOPXmlProcessors.Add("Density", ProcessDensity); | ||
386 | m_SOPXmlProcessors.Add("Friction", ProcessFriction); | ||
387 | m_SOPXmlProcessors.Add("Bounce", ProcessBounce); | ||
388 | m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); | ||
389 | m_SOPXmlProcessors.Add("CameraEyeOffset", ProcessCameraEyeOffset); | ||
390 | m_SOPXmlProcessors.Add("CameraAtOffset", ProcessCameraAtOffset); | ||
391 | |||
369 | #endregion | 392 | #endregion |
370 | 393 | ||
371 | #region TaskInventoryXmlProcessors initialization | 394 | #region TaskInventoryXmlProcessors initialization |
@@ -393,7 +416,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
393 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); | 416 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); |
394 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); | 417 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); |
395 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); | 418 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); |
396 | 419 | ||
397 | #endregion | 420 | #endregion |
398 | 421 | ||
399 | #region ShapeXmlProcessors initialization | 422 | #region ShapeXmlProcessors initialization |
@@ -593,6 +616,58 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
593 | obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); | 616 | obj.ClickAction = (byte)reader.ReadElementContentAsInt("ClickAction", String.Empty); |
594 | } | 617 | } |
595 | 618 | ||
619 | private static void ProcessPhysicsShapeType(SceneObjectPart obj, XmlTextReader reader) | ||
620 | { | ||
621 | obj.PhysicsShapeType = (byte)reader.ReadElementContentAsInt("PhysicsShapeType", String.Empty); | ||
622 | } | ||
623 | |||
624 | private static void ProcessDensity(SceneObjectPart obj, XmlTextReader reader) | ||
625 | { | ||
626 | obj.Density = reader.ReadElementContentAsFloat("Density", String.Empty); | ||
627 | } | ||
628 | |||
629 | private static void ProcessFriction(SceneObjectPart obj, XmlTextReader reader) | ||
630 | { | ||
631 | obj.Friction = reader.ReadElementContentAsFloat("Friction", String.Empty); | ||
632 | } | ||
633 | |||
634 | private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader) | ||
635 | { | ||
636 | obj.Bounciness = reader.ReadElementContentAsFloat("Bounce", String.Empty); | ||
637 | } | ||
638 | |||
639 | private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader) | ||
640 | { | ||
641 | obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); | ||
642 | } | ||
643 | |||
644 | private static void ProcessCameraEyeOffset(SceneObjectPart obj, XmlTextReader reader) | ||
645 | { | ||
646 | obj.SetCameraEyeOffset(Util.ReadVector(reader, "CameraEyeOffset")); | ||
647 | } | ||
648 | |||
649 | private static void ProcessCameraAtOffset(SceneObjectPart obj, XmlTextReader reader) | ||
650 | { | ||
651 | obj.SetCameraAtOffset(Util.ReadVector(reader, "CameraAtOffset")); | ||
652 | } | ||
653 | |||
654 | private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) | ||
655 | { | ||
656 | SOPVehicle vehicle = SOPVehicle.FromXml2(reader); | ||
657 | |||
658 | if (vehicle == null) | ||
659 | { | ||
660 | obj.VehicleParams = null; | ||
661 | m_log.DebugFormat( | ||
662 | "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.", | ||
663 | obj.Name, obj.UUID); | ||
664 | } | ||
665 | else | ||
666 | { | ||
667 | obj.VehicleParams = vehicle; | ||
668 | } | ||
669 | } | ||
670 | |||
596 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) | 671 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) |
597 | { | 672 | { |
598 | List<string> errorNodeNames; | 673 | List<string> errorNodeNames; |
@@ -757,6 +832,25 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
757 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); | 832 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); |
758 | } | 833 | } |
759 | 834 | ||
835 | private static void ProcessBuoyancy(SceneObjectPart obj, XmlTextReader reader) | ||
836 | { | ||
837 | obj.Buoyancy = (float)reader.ReadElementContentAsFloat("Buoyancy", String.Empty); | ||
838 | } | ||
839 | |||
840 | private static void ProcessForce(SceneObjectPart obj, XmlTextReader reader) | ||
841 | { | ||
842 | obj.Force = Util.ReadVector(reader, "Force"); | ||
843 | } | ||
844 | private static void ProcessTorque(SceneObjectPart obj, XmlTextReader reader) | ||
845 | { | ||
846 | obj.Torque = Util.ReadVector(reader, "Torque"); | ||
847 | } | ||
848 | |||
849 | private static void ProcessVolumeDetectActive(SceneObjectPart obj, XmlTextReader reader) | ||
850 | { | ||
851 | obj.VolumeDetectActive = Util.ReadBoolean(reader); | ||
852 | } | ||
853 | |||
760 | #endregion | 854 | #endregion |
761 | 855 | ||
762 | #region TaskInventoryXmlProcessors | 856 | #region TaskInventoryXmlProcessors |
@@ -1144,6 +1238,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1144 | }); | 1238 | }); |
1145 | 1239 | ||
1146 | writer.WriteEndElement(); | 1240 | writer.WriteEndElement(); |
1241 | |||
1242 | if (sog.RootPart.KeyframeMotion != null) | ||
1243 | { | ||
1244 | Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); | ||
1245 | |||
1246 | writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); | ||
1247 | writer.WriteBase64(data, 0, data.Length); | ||
1248 | writer.WriteEndElement(); | ||
1249 | } | ||
1250 | |||
1147 | writer.WriteEndElement(); | 1251 | writer.WriteEndElement(); |
1148 | } | 1252 | } |
1149 | 1253 | ||
@@ -1243,6 +1347,29 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1243 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); | 1347 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); |
1244 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); | 1348 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); |
1245 | 1349 | ||
1350 | writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); | ||
1351 | |||
1352 | WriteVector(writer, "Force", sop.Force); | ||
1353 | WriteVector(writer, "Torque", sop.Torque); | ||
1354 | |||
1355 | writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); | ||
1356 | |||
1357 | if (sop.VehicleParams != null) | ||
1358 | sop.VehicleParams.ToXml2(writer); | ||
1359 | |||
1360 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) | ||
1361 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); | ||
1362 | if (sop.Density != 1000.0f) | ||
1363 | writer.WriteElementString("Density", sop.Density.ToString().ToLower()); | ||
1364 | if (sop.Friction != 0.6f) | ||
1365 | writer.WriteElementString("Friction", sop.Friction.ToString().ToLower()); | ||
1366 | if (sop.Bounciness != 0.5f) | ||
1367 | writer.WriteElementString("Bounce", sop.Bounciness.ToString().ToLower()); | ||
1368 | if (sop.GravityModifier != 1.0f) | ||
1369 | writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); | ||
1370 | WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); | ||
1371 | WriteVector(writer, "CameraAtOffset", sop.GetCameraAtOffset()); | ||
1372 | |||
1246 | writer.WriteEndElement(); | 1373 | writer.WriteEndElement(); |
1247 | } | 1374 | } |
1248 | 1375 | ||
@@ -1467,12 +1594,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1467 | { | 1594 | { |
1468 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); | 1595 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); |
1469 | 1596 | ||
1470 | if (reader.IsEmptyElement) | ||
1471 | { | ||
1472 | reader.Read(); | ||
1473 | return tinv; | ||
1474 | } | ||
1475 | |||
1476 | reader.ReadStartElement(name, String.Empty); | 1597 | reader.ReadStartElement(name, String.Empty); |
1477 | 1598 | ||
1478 | while (reader.Name == "TaskInventoryItem") | 1599 | while (reader.Name == "TaskInventoryItem") |
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index b9d615e..5398ab9 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; |
@@ -289,7 +290,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
289 | 290 | ||
290 | private void statsHeartBeat(object sender, EventArgs e) | 291 | private void statsHeartBeat(object sender, EventArgs e) |
291 | { | 292 | { |
292 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; | 293 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; |
293 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); | 294 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); |
294 | 295 | ||
295 | // Know what's not thread safe in Mono... modifying timers. | 296 | // Know what's not thread safe in Mono... modifying timers. |
@@ -327,6 +328,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
327 | physfps = 0; | 328 | physfps = 0; |
328 | 329 | ||
329 | #endregion | 330 | #endregion |
331 | float factor = 1 / m_statsUpdateFactor; | ||
332 | |||
333 | if (reportedFPS <= 0) | ||
334 | reportedFPS = 1; | ||
335 | |||
336 | float perframe = 1.0f / (float)reportedFPS; | ||
337 | |||
338 | float TotalFrameTime = m_frameMS * perframe; | ||
339 | |||
340 | float targetframetime = 1100.0f / (float)m_nominalReportedFps; | ||
341 | |||
342 | float sparetime; | ||
343 | float sleeptime; | ||
344 | |||
345 | if (TotalFrameTime > targetframetime) | ||
346 | { | ||
347 | sparetime = 0; | ||
348 | sleeptime = 0; | ||
349 | } | ||
350 | else | ||
351 | { | ||
352 | sparetime = m_frameMS - m_physicsMS - m_agentMS; | ||
353 | sparetime *= perframe; | ||
354 | if (sparetime < 0) | ||
355 | sparetime = 0; | ||
356 | else if (sparetime > TotalFrameTime) | ||
357 | sparetime = TotalFrameTime; | ||
358 | sleeptime = m_sleeptimeMS * perframe; | ||
359 | } | ||
330 | 360 | ||
331 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); | 361 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); |
332 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); | 362 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); |
@@ -338,25 +368,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
338 | // so that stat numbers are always consistent. | 368 | // so that stat numbers are always consistent. |
339 | CheckStatSanity(); | 369 | CheckStatSanity(); |
340 | 370 | ||
341 | //Our time dilation is 0.91 when we're running a full speed, | 371 | // other MS is actually simulation time |
342 | // therefore to make sure we get an appropriate range, | 372 | // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; |
343 | // we have to factor in our error. (0.10f * statsUpdateFactor) | 373 | // m_imageMS m_netMS are not included in m_frameMS |
344 | // multiplies the fix for the error times the amount of times it'll occur a second | ||
345 | // / 10 divides the value by the number of times the sim heartbeat runs (10fps) | ||
346 | // Then we divide the whole amount by the amount of seconds pass in between stats updates. | ||
347 | |||
348 | // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change | ||
349 | // values to X-per-second values. | ||
350 | 374 | ||
351 | uint thisFrame = m_scene.Frame; | 375 | m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; |
352 | float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; | 376 | if (m_otherMS < 0) |
353 | m_lastUpdateFrame = thisFrame; | 377 | m_otherMS = 0; |
354 | 378 | ||
355 | // Avoid div-by-zero if somehow we've not updated any frames. | 379 | for (int i = 0; i < 23; i++) |
356 | if (framesUpdated == 0) | ||
357 | framesUpdated = 1; | ||
358 | |||
359 | for (int i = 0; i < 22; i++) | ||
360 | { | 380 | { |
361 | sb[i] = new SimStatsPacket.StatBlock(); | 381 | sb[i] = new SimStatsPacket.StatBlock(); |
362 | } | 382 | } |
@@ -386,19 +406,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
386 | sb[7].StatValue = m_activePrim; | 406 | sb[7].StatValue = m_activePrim; |
387 | 407 | ||
388 | sb[8].StatID = (uint)Stats.FrameMS; | 408 | sb[8].StatID = (uint)Stats.FrameMS; |
389 | sb[8].StatValue = m_frameMS / framesUpdated; | 409 | sb[8].StatValue = TotalFrameTime; |
390 | 410 | ||
391 | sb[9].StatID = (uint)Stats.NetMS; | 411 | sb[9].StatID = (uint)Stats.NetMS; |
392 | sb[9].StatValue = m_netMS / framesUpdated; | 412 | sb[9].StatValue = m_netMS * perframe; |
393 | 413 | ||
394 | sb[10].StatID = (uint)Stats.PhysicsMS; | 414 | sb[10].StatID = (uint)Stats.PhysicsMS; |
395 | sb[10].StatValue = m_physicsMS / framesUpdated; | 415 | sb[10].StatValue = m_physicsMS * perframe; |
396 | 416 | ||
397 | sb[11].StatID = (uint)Stats.ImageMS ; | 417 | sb[11].StatID = (uint)Stats.ImageMS ; |
398 | sb[11].StatValue = m_imageMS / framesUpdated; | 418 | sb[11].StatValue = m_imageMS * perframe; |
399 | 419 | ||
400 | sb[12].StatID = (uint)Stats.OtherMS; | 420 | sb[12].StatID = (uint)Stats.OtherMS; |
401 | sb[12].StatValue = m_otherMS / framesUpdated; | 421 | sb[12].StatValue = m_otherMS * perframe; |
402 | 422 | ||
403 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; | 423 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; |
404 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); | 424 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); |
@@ -410,7 +430,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
410 | sb[15].StatValue = m_unAckedBytes; | 430 | sb[15].StatValue = m_unAckedBytes; |
411 | 431 | ||
412 | sb[16].StatID = (uint)Stats.AgentMS; | 432 | sb[16].StatID = (uint)Stats.AgentMS; |
413 | sb[16].StatValue = m_agentMS / framesUpdated; | 433 | sb[16].StatValue = m_agentMS * perframe; |
414 | 434 | ||
415 | sb[17].StatID = (uint)Stats.PendingDownloads; | 435 | sb[17].StatID = (uint)Stats.PendingDownloads; |
416 | sb[17].StatValue = m_pendingDownloads; | 436 | sb[17].StatValue = m_pendingDownloads; |
@@ -425,7 +445,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
425 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; | 445 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; |
426 | 446 | ||
427 | sb[21].StatID = (uint)Stats.SimSpareMs; | 447 | sb[21].StatID = (uint)Stats.SimSpareMs; |
428 | sb[21].StatValue = m_spareMS / framesUpdated; | 448 | sb[21].StatValue = sparetime; |
449 | |||
450 | sb[22].StatID = (uint)Stats.SimSleepMs; | ||
451 | sb[22].StatValue = sleeptime; | ||
429 | 452 | ||
430 | for (int i = 0; i < 22; i++) | 453 | for (int i = 0; i < 22; i++) |
431 | { | 454 | { |
@@ -444,28 +467,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
444 | } | 467 | } |
445 | 468 | ||
446 | // Extra statistics that aren't currently sent to clients | 469 | // Extra statistics that aren't currently sent to clients |
447 | lock (m_lastReportedExtraSimStats) | 470 | if (m_scene.PhysicsScene != null) |
448 | { | 471 | { |
449 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; | 472 | lock (m_lastReportedExtraSimStats) |
450 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
451 | |||
452 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
453 | |||
454 | if (physicsStats != null) | ||
455 | { | 473 | { |
456 | foreach (KeyValuePair<string, float> tuple in physicsStats) | 474 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; |
475 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
476 | |||
477 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
478 | |||
479 | if (physicsStats != null) | ||
457 | { | 480 | { |
458 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second | 481 | foreach (KeyValuePair<string, float> tuple in physicsStats) |
459 | // Need to change things so that stats source can indicate whether they are per second or | 482 | { |
460 | // per frame. | 483 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second |
461 | if (tuple.Key.EndsWith("MS")) | 484 | // Need to change things so that stats source can indicate whether they are per second or |
462 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; | 485 | // per frame. |
463 | else | 486 | if (tuple.Key.EndsWith("MS")) |
464 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | 487 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; |
488 | else | ||
489 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | ||
490 | } | ||
465 | } | 491 | } |
466 | } | 492 | } |
467 | } | 493 | } |
468 | 494 | ||
495 | // LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor; | ||
469 | ResetValues(); | 496 | ResetValues(); |
470 | } | 497 | } |
471 | } | 498 | } |
@@ -488,7 +515,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
488 | m_physicsMS = 0; | 515 | m_physicsMS = 0; |
489 | m_imageMS = 0; | 516 | m_imageMS = 0; |
490 | m_otherMS = 0; | 517 | m_otherMS = 0; |
491 | m_spareMS = 0; | 518 | // m_spareMS = 0; |
519 | m_sleeptimeMS = 0; | ||
492 | 520 | ||
493 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. | 521 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. |
494 | //Ckrinke m_scriptMS = 0; | 522 | //Ckrinke m_scriptMS = 0; |
@@ -572,11 +600,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
572 | SlowFramesStat.Value++; | 600 | SlowFramesStat.Value++; |
573 | } | 601 | } |
574 | 602 | ||
575 | public void AddSpareMS(int ms) | ||
576 | { | ||
577 | m_spareMS += ms; | ||
578 | } | ||
579 | |||
580 | public void addNetMS(int ms) | 603 | public void addNetMS(int ms) |
581 | { | 604 | { |
582 | m_netMS += ms; | 605 | m_netMS += ms; |
@@ -602,6 +625,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
602 | m_otherMS += ms; | 625 | m_otherMS += ms; |
603 | } | 626 | } |
604 | 627 | ||
628 | public void addSleepMS(int ms) | ||
629 | { | ||
630 | m_sleeptimeMS += ms; | ||
631 | } | ||
632 | |||
605 | public void AddPendingDownloads(int count) | 633 | public void AddPendingDownloads(int count) |
606 | { | 634 | { |
607 | m_pendingDownloads += count; | 635 | m_pendingDownloads += count; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index 89647d6..e931859 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 96973de..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/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 e238d01..2279e62 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -84,10 +84,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
84 | /// <param name="assetUuids">The assets gathered</param> | 84 | /// <param name="assetUuids">The assets gathered</param> |
85 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) | 85 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) |
86 | { | 86 | { |
87 | // avoid infinite loops | ||
88 | if (assetUuids.ContainsKey(assetUuid)) | ||
89 | return; | ||
90 | |||
91 | try | 87 | try |
92 | { | 88 | { |
93 | assetUuids[assetUuid] = assetType; | 89 | assetUuids[assetUuid] = assetType; |