diff options
Diffstat (limited to 'OpenSim/Region/Framework')
21 files changed, 2694 insertions, 970 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 2af2548..9fe6d96 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml; | ||
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenMetaverse.Packets; | 31 | using OpenMetaverse.Packets; |
31 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
@@ -82,6 +83,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
82 | UUID RezSingleAttachmentFromInventory( | 83 | UUID RezSingleAttachmentFromInventory( |
83 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus); | 84 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus); |
84 | 85 | ||
86 | // Same as above, but also load script states from a separate doc | ||
87 | UUID RezSingleAttachmentFromInventory( | ||
88 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc); | ||
89 | |||
85 | /// <summary> | 90 | /// <summary> |
86 | /// Rez multiple attachments from a user's inventory | 91 | /// Rez multiple attachments from a user's inventory |
87 | /// </summary> | 92 | /// </summary> |
@@ -132,4 +137,4 @@ namespace OpenSim.Region.Framework.Interfaces | |||
132 | /// </param> | 137 | /// </param> |
133 | void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient); | 138 | void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient); |
134 | } | 139 | } |
135 | } \ No newline at end of file | 140 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IDwellModule.cs b/OpenSim/Region/Framework/Interfaces/IDwellModule.cs new file mode 100644 index 0000000..db50439 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IDwellModule.cs | |||
@@ -0,0 +1,37 @@ | |||
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 OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | |||
31 | namespace OpenSim.Region.Framework.Interfaces | ||
32 | { | ||
33 | public interface IDwellModule | ||
34 | { | ||
35 | int GetDwell(UUID parcelID); | ||
36 | } | ||
37 | } | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index fd43923..1e2f60b 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -105,6 +105,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
105 | /// <param name="stateSource"></param> | 105 | /// <param name="stateSource"></param> |
106 | void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); | 106 | void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); |
107 | 107 | ||
108 | ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); | ||
109 | |||
108 | /// <summary> | 110 | /// <summary> |
109 | /// Stop a script which is in this prim's inventory. | 111 | /// Stop a script which is in this prim's inventory. |
110 | /// </summary> | 112 | /// </summary> |
@@ -214,5 +216,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
214 | /// A <see cref="Dictionary`2"/> | 216 | /// A <see cref="Dictionary`2"/> |
215 | /// </returns> | 217 | /// </returns> |
216 | Dictionary<UUID, string> GetScriptStates(); | 218 | Dictionary<UUID, string> GetScriptStates(); |
219 | Dictionary<UUID, string> GetScriptStates(bool oldIDs); | ||
217 | } | 220 | } |
218 | } | 221 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs index 2d6287f..67a500f 100644 --- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs | |||
@@ -68,6 +68,14 @@ namespace OpenSim.Region.Framework.Interfaces | |||
68 | bool SendReleaseAgent(ulong regionHandle, UUID id, string uri); | 68 | bool SendReleaseAgent(ulong regionHandle, UUID id, string uri); |
69 | 69 | ||
70 | /// <summary> | 70 | /// <summary> |
71 | /// Close chid agent. | ||
72 | /// </summary> | ||
73 | /// <param name="regionHandle"></param> | ||
74 | /// <param name="id"></param> | ||
75 | /// <returns></returns> | ||
76 | bool SendCloseChildAgent(ulong regionHandle, UUID id); | ||
77 | |||
78 | /// <summary> | ||
71 | /// Close agent. | 79 | /// Close agent. |
72 | /// </summary> | 80 | /// </summary> |
73 | /// <param name="regionHandle"></param> | 81 | /// <param name="regionHandle"></param> |
diff --git a/OpenSim/Region/Framework/Interfaces/ISnmpModule.cs b/OpenSim/Region/Framework/Interfaces/ISnmpModule.cs new file mode 100644 index 0000000..e01f649 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/ISnmpModule.cs | |||
@@ -0,0 +1,27 @@ | |||
1 | /////////////////////////////////////////////////////////////////// | ||
2 | // | ||
3 | // (c) Careminster LImited, Melanie Thielker and the Meta7 Team | ||
4 | // | ||
5 | // This file is not open source. All rights reserved | ||
6 | // Mod 2 | ||
7 | |||
8 | using OpenSim.Region.Framework.Scenes; | ||
9 | |||
10 | public interface ISnmpModule | ||
11 | { | ||
12 | void Trap(int code, string Message, Scene scene); | ||
13 | void Critical(string Message, Scene scene); | ||
14 | void Warning(string Message, Scene scene); | ||
15 | void Major(string Message, Scene scene); | ||
16 | void ColdStart(int step , Scene scene); | ||
17 | void Shutdown(int step , Scene scene); | ||
18 | // | ||
19 | // Node Start/stop events | ||
20 | // | ||
21 | void LinkUp(Scene scene); | ||
22 | void LinkDown(Scene scene); | ||
23 | void BootInfo(string data, Scene scene); | ||
24 | void trapDebug(string Module,string data, Scene scene); | ||
25 | void trapXMRE(int data, string Message, Scene scene); | ||
26 | |||
27 | } | ||
diff --git a/OpenSim/Region/Framework/ModuleLoader.cs b/OpenSim/Region/Framework/ModuleLoader.cs index 23be9c2..69ba2042 100644 --- a/OpenSim/Region/Framework/ModuleLoader.cs +++ b/OpenSim/Region/Framework/ModuleLoader.cs | |||
@@ -226,7 +226,8 @@ namespace OpenSim.Region.Framework | |||
226 | "[MODULES]: Could not load types for [{0}]. Exception {1}", pluginAssembly.FullName, e); | 226 | "[MODULES]: Could not load types for [{0}]. Exception {1}", pluginAssembly.FullName, e); |
227 | 227 | ||
228 | // justincc: Right now this is fatal to really get the user's attention | 228 | // justincc: Right now this is fatal to really get the user's attention |
229 | throw e; | 229 | // TomMeta: WTF? No, how about we /don't/ throw a fatal exception when there's no need to? |
230 | //throw e; | ||
230 | } | 231 | } |
231 | } | 232 | } |
232 | 233 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index a90e0f3..b847d87 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -53,10 +53,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
53 | { | 53 | { |
54 | get { return m_movementAnimation; } | 54 | get { return m_movementAnimation; } |
55 | } | 55 | } |
56 | protected string m_movementAnimation = "DEFAULT"; | 56 | // protected string m_movementAnimation = "DEFAULT"; //KF: 'DEFAULT' does not exist! |
57 | 57 | protected string m_movementAnimation = "CROUCH"; //KF: CROUCH ensures reliable Av Anim. init. | |
58 | private int m_animTickFall; | 58 | private int m_animTickFall; |
59 | private int m_animTickJump; | 59 | // private int m_animTickJump; |
60 | public int m_animTickJump; // ScenePresence has to see this to control +Z force | ||
60 | 61 | ||
61 | /// <value> | 62 | /// <value> |
62 | /// The scene presence that this animator applies to | 63 | /// The scene presence that this animator applies to |
@@ -123,8 +124,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
123 | /// </summary> | 124 | /// </summary> |
124 | public void TrySetMovementAnimation(string anim) | 125 | public void TrySetMovementAnimation(string anim) |
125 | { | 126 | { |
126 | //m_log.DebugFormat("Updating movement animation to {0}", anim); | ||
127 | |||
128 | if (!m_scenePresence.IsChildAgent) | 127 | if (!m_scenePresence.IsChildAgent) |
129 | { | 128 | { |
130 | if (m_animations.TrySetDefaultAnimation( | 129 | if (m_animations.TrySetDefaultAnimation( |
@@ -146,10 +145,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
146 | const float PREJUMP_DELAY = 0.25f; | 145 | const float PREJUMP_DELAY = 0.25f; |
147 | 146 | ||
148 | #region Inputs | 147 | #region Inputs |
149 | if (m_scenePresence.SitGround) | 148 | |
150 | { | ||
151 | return "SIT_GROUND_CONSTRAINED"; | ||
152 | } | ||
153 | AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; | 149 | AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; |
154 | PhysicsActor actor = m_scenePresence.PhysicsActor; | 150 | PhysicsActor actor = m_scenePresence.PhysicsActor; |
155 | 151 | ||
@@ -159,11 +155,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
159 | Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); | 155 | Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); |
160 | 156 | ||
161 | // Check control flags | 157 | // Check control flags |
162 | bool heldForward = | 158 | bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS); |
163 | (((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) || ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS)); | 159 | bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); |
164 | bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG; | 160 | bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); |
165 | bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS; | 161 | bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG); |
166 | bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG; | ||
167 | //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; | 162 | //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; |
168 | //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; | 163 | //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; |
169 | bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; | 164 | bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; |
@@ -266,7 +261,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
266 | m_animTickJump = Environment.TickCount; | 261 | m_animTickJump = Environment.TickCount; |
267 | return "PREJUMP"; | 262 | return "PREJUMP"; |
268 | } | 263 | } |
269 | else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 1000.0f) | 264 | else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 800.0f) |
270 | { | 265 | { |
271 | // Start actual jump | 266 | // Start actual jump |
272 | if (m_animTickJump == -1) | 267 | if (m_animTickJump == -1) |
@@ -316,7 +311,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
316 | public void UpdateMovementAnimations() | 311 | public void UpdateMovementAnimations() |
317 | { | 312 | { |
318 | m_movementAnimation = GetMovementAnimation(); | 313 | m_movementAnimation = GetMovementAnimation(); |
319 | |||
320 | if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) | 314 | if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) |
321 | { | 315 | { |
322 | // This was the previous behavior before PREJUMP | 316 | // This was the previous behavior before PREJUMP |
diff --git a/OpenSim/Region/Framework/Scenes/EntityManager.cs b/OpenSim/Region/Framework/Scenes/EntityManager.cs index 099fcce..c246e32 100644 --- a/OpenSim/Region/Framework/Scenes/EntityManager.cs +++ b/OpenSim/Region/Framework/Scenes/EntityManager.cs | |||
@@ -40,7 +40,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
40 | private readonly Dictionary<UUID,EntityBase> m_eb_uuid = new Dictionary<UUID, EntityBase>(); | 40 | private readonly Dictionary<UUID,EntityBase> m_eb_uuid = new Dictionary<UUID, EntityBase>(); |
41 | private readonly Dictionary<uint, EntityBase> m_eb_localID = new Dictionary<uint, EntityBase>(); | 41 | private readonly Dictionary<uint, EntityBase> m_eb_localID = new Dictionary<uint, EntityBase>(); |
42 | //private readonly Dictionary<UUID, ScenePresence> m_pres_uuid = new Dictionary<UUID, ScenePresence>(); | 42 | //private readonly Dictionary<UUID, ScenePresence> m_pres_uuid = new Dictionary<UUID, ScenePresence>(); |
43 | private readonly Object m_lock = new Object(); | 43 | private System.Threading.ReaderWriterLockSlim m_lock = new System.Threading.ReaderWriterLockSlim(); |
44 | 44 | ||
45 | [Obsolete("Use Add() instead.")] | 45 | [Obsolete("Use Add() instead.")] |
46 | public void Add(UUID id, EntityBase eb) | 46 | public void Add(UUID id, EntityBase eb) |
@@ -50,7 +50,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
50 | 50 | ||
51 | public void Add(EntityBase entity) | 51 | public void Add(EntityBase entity) |
52 | { | 52 | { |
53 | lock (m_lock) | 53 | m_lock.EnterWriteLock(); |
54 | try | ||
54 | { | 55 | { |
55 | try | 56 | try |
56 | { | 57 | { |
@@ -62,11 +63,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
62 | m_log.ErrorFormat("Add Entity failed: {0}", e.Message); | 63 | m_log.ErrorFormat("Add Entity failed: {0}", e.Message); |
63 | } | 64 | } |
64 | } | 65 | } |
66 | finally | ||
67 | { | ||
68 | m_lock.ExitWriteLock(); | ||
69 | } | ||
65 | } | 70 | } |
66 | 71 | ||
67 | public void InsertOrReplace(EntityBase entity) | 72 | public void InsertOrReplace(EntityBase entity) |
68 | { | 73 | { |
69 | lock (m_lock) | 74 | m_lock.EnterWriteLock(); |
75 | try | ||
70 | { | 76 | { |
71 | try | 77 | try |
72 | { | 78 | { |
@@ -78,15 +84,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
78 | m_log.ErrorFormat("Insert or Replace Entity failed: {0}", e.Message); | 84 | m_log.ErrorFormat("Insert or Replace Entity failed: {0}", e.Message); |
79 | } | 85 | } |
80 | } | 86 | } |
87 | finally | ||
88 | { | ||
89 | m_lock.ExitWriteLock(); | ||
90 | } | ||
81 | } | 91 | } |
82 | 92 | ||
83 | public void Clear() | 93 | public void Clear() |
84 | { | 94 | { |
85 | lock (m_lock) | 95 | m_lock.EnterWriteLock(); |
96 | try | ||
86 | { | 97 | { |
87 | m_eb_uuid.Clear(); | 98 | m_eb_uuid.Clear(); |
88 | m_eb_localID.Clear(); | 99 | m_eb_localID.Clear(); |
89 | } | 100 | } |
101 | finally | ||
102 | { | ||
103 | m_lock.ExitWriteLock(); | ||
104 | } | ||
90 | } | 105 | } |
91 | 106 | ||
92 | public int Count | 107 | public int Count |
@@ -123,7 +138,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
123 | 138 | ||
124 | public bool Remove(uint localID) | 139 | public bool Remove(uint localID) |
125 | { | 140 | { |
126 | lock (m_lock) | 141 | m_lock.EnterWriteLock(); |
142 | try | ||
127 | { | 143 | { |
128 | try | 144 | try |
129 | { | 145 | { |
@@ -141,11 +157,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
141 | return false; | 157 | return false; |
142 | } | 158 | } |
143 | } | 159 | } |
160 | finally | ||
161 | { | ||
162 | m_lock.ExitWriteLock(); | ||
163 | } | ||
144 | } | 164 | } |
145 | 165 | ||
146 | public bool Remove(UUID id) | 166 | public bool Remove(UUID id) |
147 | { | 167 | { |
148 | lock (m_lock) | 168 | m_lock.EnterWriteLock(); |
169 | try | ||
149 | { | 170 | { |
150 | try | 171 | try |
151 | { | 172 | { |
@@ -163,13 +184,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
163 | return false; | 184 | return false; |
164 | } | 185 | } |
165 | } | 186 | } |
187 | finally | ||
188 | { | ||
189 | m_lock.ExitWriteLock(); | ||
190 | } | ||
166 | } | 191 | } |
167 | 192 | ||
168 | public List<EntityBase> GetAllByType<T>() | 193 | public List<EntityBase> GetAllByType<T>() |
169 | { | 194 | { |
170 | List<EntityBase> tmp = new List<EntityBase>(); | 195 | List<EntityBase> tmp = new List<EntityBase>(); |
171 | 196 | ||
172 | lock (m_lock) | 197 | m_lock.EnterReadLock(); |
198 | try | ||
173 | { | 199 | { |
174 | try | 200 | try |
175 | { | 201 | { |
@@ -187,23 +213,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
187 | tmp = null; | 213 | tmp = null; |
188 | } | 214 | } |
189 | } | 215 | } |
216 | finally | ||
217 | { | ||
218 | m_lock.ExitReadLock(); | ||
219 | } | ||
190 | 220 | ||
191 | return tmp; | 221 | return tmp; |
192 | } | 222 | } |
193 | 223 | ||
194 | public List<EntityBase> GetEntities() | 224 | public List<EntityBase> GetEntities() |
195 | { | 225 | { |
196 | lock (m_lock) | 226 | m_lock.EnterReadLock(); |
227 | try | ||
197 | { | 228 | { |
198 | return new List<EntityBase>(m_eb_uuid.Values); | 229 | return new List<EntityBase>(m_eb_uuid.Values); |
199 | } | 230 | } |
231 | finally | ||
232 | { | ||
233 | m_lock.ExitReadLock(); | ||
234 | } | ||
200 | } | 235 | } |
201 | 236 | ||
202 | public EntityBase this[UUID id] | 237 | public EntityBase this[UUID id] |
203 | { | 238 | { |
204 | get | 239 | get |
205 | { | 240 | { |
206 | lock (m_lock) | 241 | m_lock.EnterReadLock(); |
242 | try | ||
207 | { | 243 | { |
208 | EntityBase entity; | 244 | EntityBase entity; |
209 | if (m_eb_uuid.TryGetValue(id, out entity)) | 245 | if (m_eb_uuid.TryGetValue(id, out entity)) |
@@ -211,6 +247,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
211 | else | 247 | else |
212 | return null; | 248 | return null; |
213 | } | 249 | } |
250 | finally | ||
251 | { | ||
252 | m_lock.ExitReadLock(); | ||
253 | } | ||
214 | } | 254 | } |
215 | set | 255 | set |
216 | { | 256 | { |
@@ -222,7 +262,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
222 | { | 262 | { |
223 | get | 263 | get |
224 | { | 264 | { |
225 | lock (m_lock) | 265 | m_lock.EnterReadLock(); |
266 | try | ||
226 | { | 267 | { |
227 | EntityBase entity; | 268 | EntityBase entity; |
228 | if (m_eb_localID.TryGetValue(localID, out entity)) | 269 | if (m_eb_localID.TryGetValue(localID, out entity)) |
@@ -230,6 +271,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
230 | else | 271 | else |
231 | return null; | 272 | return null; |
232 | } | 273 | } |
274 | finally | ||
275 | { | ||
276 | m_lock.ExitReadLock(); | ||
277 | } | ||
233 | } | 278 | } |
234 | set | 279 | set |
235 | { | 280 | { |
@@ -239,18 +284,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
239 | 284 | ||
240 | public bool TryGetValue(UUID key, out EntityBase obj) | 285 | public bool TryGetValue(UUID key, out EntityBase obj) |
241 | { | 286 | { |
242 | lock (m_lock) | 287 | m_lock.EnterReadLock(); |
288 | try | ||
243 | { | 289 | { |
244 | return m_eb_uuid.TryGetValue(key, out obj); | 290 | return m_eb_uuid.TryGetValue(key, out obj); |
245 | } | 291 | } |
292 | finally | ||
293 | { | ||
294 | m_lock.ExitReadLock(); | ||
295 | } | ||
246 | } | 296 | } |
247 | 297 | ||
248 | public bool TryGetValue(uint key, out EntityBase obj) | 298 | public bool TryGetValue(uint key, out EntityBase obj) |
249 | { | 299 | { |
250 | lock (m_lock) | 300 | m_lock.EnterReadLock(); |
301 | try | ||
251 | { | 302 | { |
252 | return m_eb_localID.TryGetValue(key, out obj); | 303 | return m_eb_localID.TryGetValue(key, out obj); |
253 | } | 304 | } |
305 | finally | ||
306 | { | ||
307 | m_lock.ExitReadLock(); | ||
308 | } | ||
254 | } | 309 | } |
255 | 310 | ||
256 | /// <summary> | 311 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 0ae3146..52e6e92 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -55,8 +55,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
55 | 55 | ||
56 | public delegate void OnTerrainTickDelegate(); | 56 | public delegate void OnTerrainTickDelegate(); |
57 | 57 | ||
58 | public delegate void OnTerrainUpdateDelegate(); | ||
59 | |||
58 | public event OnTerrainTickDelegate OnTerrainTick; | 60 | public event OnTerrainTickDelegate OnTerrainTick; |
59 | 61 | ||
62 | public event OnTerrainUpdateDelegate OnTerrainUpdate; | ||
63 | |||
60 | public delegate void OnBackupDelegate(IRegionDataStore datastore, bool forceBackup); | 64 | public delegate void OnBackupDelegate(IRegionDataStore datastore, bool forceBackup); |
61 | 65 | ||
62 | public event OnBackupDelegate OnBackup; | 66 | public event OnBackupDelegate OnBackup; |
@@ -744,6 +748,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
744 | } | 748 | } |
745 | } | 749 | } |
746 | } | 750 | } |
751 | public void TriggerTerrainUpdate() | ||
752 | { | ||
753 | OnTerrainUpdateDelegate handlerTerrainUpdate = OnTerrainUpdate; | ||
754 | if (handlerTerrainUpdate != null) | ||
755 | { | ||
756 | foreach (OnTerrainUpdateDelegate d in handlerTerrainUpdate.GetInvocationList()) | ||
757 | { | ||
758 | try | ||
759 | { | ||
760 | d(); | ||
761 | } | ||
762 | catch (Exception e) | ||
763 | { | ||
764 | m_log.ErrorFormat( | ||
765 | "[EVENT MANAGER]: Delegate for TriggerTerrainUpdate failed - continuing. {0} {1}", | ||
766 | e.Message, e.StackTrace); | ||
767 | } | ||
768 | } | ||
769 | } | ||
770 | } | ||
747 | 771 | ||
748 | public void TriggerTerrainTick() | 772 | public void TriggerTerrainTick() |
749 | { | 773 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index de3c360..145f9ed 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs | |||
@@ -134,6 +134,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
134 | 134 | ||
135 | private double GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity) | 135 | private double GetPriorityByFrontBack(IClientAPI client, ISceneEntity entity) |
136 | { | 136 | { |
137 | if (entity == null) return double.NaN; | ||
137 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); | 138 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); |
138 | if (presence != null) | 139 | if (presence != null) |
139 | { | 140 | { |
@@ -144,7 +145,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
144 | // Use group position for child prims | 145 | // Use group position for child prims |
145 | Vector3 entityPos = entity.AbsolutePosition; | 146 | Vector3 entityPos = entity.AbsolutePosition; |
146 | if (entity is SceneObjectPart) | 147 | if (entity is SceneObjectPart) |
147 | entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition; | 148 | { |
149 | SceneObjectGroup group = m_scene.GetGroupByPrim(entity.LocalId); | ||
150 | if (group == null) | ||
151 | { | ||
152 | entityPos = entity.AbsolutePosition; | ||
153 | } | ||
154 | else | ||
155 | { | ||
156 | entityPos = group.AbsolutePosition; | ||
157 | } | ||
158 | } | ||
148 | else | 159 | else |
149 | entityPos = entity.AbsolutePosition; | 160 | entityPos = entity.AbsolutePosition; |
150 | 161 | ||
@@ -186,9 +197,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
186 | return 0.0; | 197 | return 0.0; |
187 | 198 | ||
188 | // Use group position for child prims | 199 | // Use group position for child prims |
189 | Vector3 entityPos = entity.AbsolutePosition; | 200 | Vector3 entityPos; |
190 | if (entity is SceneObjectPart) | 201 | if (entity is SceneObjectPart) |
191 | entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition; | 202 | entityPos = ((SceneObjectPart)entity).ParentGroup.AbsolutePosition; |
192 | else | 203 | else |
193 | entityPos = entity.AbsolutePosition; | 204 | entityPos = entity.AbsolutePosition; |
194 | 205 | ||
@@ -211,12 +222,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
211 | 222 | ||
212 | if (entity is SceneObjectPart) | 223 | if (entity is SceneObjectPart) |
213 | { | 224 | { |
214 | PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; | ||
215 | if (physActor == null || !physActor.IsPhysical) | ||
216 | priority += 100; | ||
217 | |||
218 | if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) | 225 | if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) |
226 | { | ||
219 | priority = 1.0; | 227 | priority = 1.0; |
228 | } | ||
229 | else | ||
230 | { | ||
231 | PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; | ||
232 | if (physActor == null || !physActor.IsPhysical) | ||
233 | priority += 100; | ||
234 | } | ||
235 | |||
236 | if (((SceneObjectPart)entity).ParentGroup.RootPart != (SceneObjectPart)entity) | ||
237 | priority +=1; | ||
220 | } | 238 | } |
221 | return priority; | 239 | return priority; |
222 | } | 240 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 4d84018..ab18c93 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -94,6 +94,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
94 | 94 | ||
95 | public void AddInventoryItem(UUID AgentID, InventoryItemBase item) | 95 | public void AddInventoryItem(UUID AgentID, InventoryItemBase item) |
96 | { | 96 | { |
97 | InventoryFolderBase folder; | ||
98 | |||
99 | if (item.Folder == UUID.Zero) | ||
100 | { | ||
101 | folder = InventoryService.GetFolderForType(AgentID, (AssetType)item.AssetType); | ||
102 | if (folder == null) | ||
103 | { | ||
104 | folder = InventoryService.GetRootFolder(AgentID); | ||
105 | |||
106 | if (folder == null) | ||
107 | return; | ||
108 | } | ||
109 | |||
110 | item.Folder = folder.ID; | ||
111 | } | ||
112 | |||
97 | if (InventoryService.AddItem(item)) | 113 | if (InventoryService.AddItem(item)) |
98 | { | 114 | { |
99 | int userlevel = 0; | 115 | int userlevel = 0; |
@@ -214,8 +230,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
214 | { | 230 | { |
215 | // Needs to determine which engine was running it and use that | 231 | // Needs to determine which engine was running it and use that |
216 | // | 232 | // |
217 | part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); | 233 | errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 0); |
218 | errors = part.Inventory.GetScriptErrors(item.ItemID); | ||
219 | } | 234 | } |
220 | else | 235 | else |
221 | { | 236 | { |
@@ -633,6 +648,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
633 | return; | 648 | return; |
634 | } | 649 | } |
635 | 650 | ||
651 | if (newName == null) newName = item.Name; | ||
652 | |||
636 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 653 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
637 | 654 | ||
638 | if (asset != null) | 655 | if (asset != null) |
@@ -680,6 +697,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
680 | } | 697 | } |
681 | 698 | ||
682 | /// <summary> | 699 | /// <summary> |
700 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
701 | /// </summary> | ||
702 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
703 | { | ||
704 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
705 | foreach (InventoryItemBase b in items) | ||
706 | { | ||
707 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
708 | InventoryItemBase n = InventoryService.GetItem(b); | ||
709 | n.Folder = destfolder; | ||
710 | moveitems.Add(n); | ||
711 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
712 | } | ||
713 | |||
714 | MoveInventoryItem(remoteClient, moveitems); | ||
715 | } | ||
716 | |||
717 | /// <summary> | ||
683 | /// Move an item within the agent's inventory. | 718 | /// Move an item within the agent's inventory. |
684 | /// </summary> | 719 | /// </summary> |
685 | /// <param name="remoteClient"></param> | 720 | /// <param name="remoteClient"></param> |
@@ -914,8 +949,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
914 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) | 949 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) |
915 | { | 950 | { |
916 | SceneObjectPart part = GetSceneObjectPart(localID); | 951 | SceneObjectPart part = GetSceneObjectPart(localID); |
917 | SceneObjectGroup group = part.ParentGroup; | 952 | SceneObjectGroup group = null; |
918 | if (group != null) | 953 | if (part != null) |
954 | { | ||
955 | group = part.ParentGroup; | ||
956 | } | ||
957 | if (part != null && group != null) | ||
919 | { | 958 | { |
920 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | 959 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) |
921 | return; | 960 | return; |
@@ -1490,7 +1529,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1490 | return; | 1529 | return; |
1491 | 1530 | ||
1492 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1531 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1493 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1532 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), |
1494 | remoteClient.AgentId); | 1533 | remoteClient.AgentId); |
1495 | AssetService.Store(asset); | 1534 | AssetService.Store(asset); |
1496 | 1535 | ||
@@ -1685,11 +1724,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1685 | // Invalid id | 1724 | // Invalid id |
1686 | SceneObjectPart part = GetSceneObjectPart(localID); | 1725 | SceneObjectPart part = GetSceneObjectPart(localID); |
1687 | if (part == null) | 1726 | if (part == null) |
1727 | { | ||
1728 | //Client still thinks the object exists, kill it | ||
1729 | SendKillObject(localID); | ||
1688 | continue; | 1730 | continue; |
1731 | } | ||
1689 | 1732 | ||
1690 | // Already deleted by someone else | 1733 | // Already deleted by someone else |
1691 | if (part.ParentGroup == null || part.ParentGroup.IsDeleted) | 1734 | if (part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1735 | { | ||
1736 | //Client still thinks the object exists, kill it | ||
1737 | SendKillObject(localID); | ||
1692 | continue; | 1738 | continue; |
1739 | } | ||
1693 | 1740 | ||
1694 | // Can't delete child prims | 1741 | // Can't delete child prims |
1695 | if (part != part.ParentGroup.RootPart) | 1742 | if (part != part.ParentGroup.RootPart) |
@@ -1716,15 +1763,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1716 | } | 1763 | } |
1717 | else | 1764 | else |
1718 | { | 1765 | { |
1719 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 1766 | if (action == DeRezAction.TakeCopy) |
1767 | { | ||
1768 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
1769 | permissionToTakeCopy = false; | ||
1770 | } | ||
1771 | else | ||
1772 | { | ||
1720 | permissionToTakeCopy = false; | 1773 | permissionToTakeCopy = false; |
1774 | } | ||
1721 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 1775 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
1722 | permissionToTake = false; | 1776 | permissionToTake = false; |
1723 | 1777 | ||
1724 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 1778 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
1725 | permissionToDelete = false; | 1779 | permissionToDelete = false; |
1726 | } | 1780 | } |
1727 | |||
1728 | } | 1781 | } |
1729 | 1782 | ||
1730 | // Handle god perms | 1783 | // Handle god perms |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 18705a8..73472a9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -137,6 +137,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
137 | protected SceneCommunicationService m_sceneGridService; | 137 | protected SceneCommunicationService m_sceneGridService; |
138 | public bool LoginsDisabled = true; | 138 | public bool LoginsDisabled = true; |
139 | public bool LoadingPrims = false; | 139 | public bool LoadingPrims = false; |
140 | public bool CombineRegions = false; | ||
140 | 141 | ||
141 | public new float TimeDilation | 142 | public new float TimeDilation |
142 | { | 143 | { |
@@ -150,6 +151,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
150 | 151 | ||
151 | public IXfer XferManager; | 152 | public IXfer XferManager; |
152 | 153 | ||
154 | protected ISnmpModule m_snmpService = null; | ||
155 | public ISnmpModule SnmpService | ||
156 | { | ||
157 | get | ||
158 | { | ||
159 | if (m_snmpService == null) | ||
160 | { | ||
161 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
162 | } | ||
163 | |||
164 | return m_snmpService; | ||
165 | } | ||
166 | } | ||
167 | |||
153 | protected IAssetService m_AssetService; | 168 | protected IAssetService m_AssetService; |
154 | protected IAuthorizationService m_AuthorizationService; | 169 | protected IAuthorizationService m_AuthorizationService; |
155 | 170 | ||
@@ -541,6 +556,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
541 | 556 | ||
542 | // Load region settings | 557 | // Load region settings |
543 | m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); | 558 | m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); |
559 | m_regInfo.WindlightSettings = m_storageManager.DataStore.LoadRegionWindlightSettings(m_regInfo.RegionID); | ||
560 | |||
544 | if (m_storageManager.EstateDataStore != null) | 561 | if (m_storageManager.EstateDataStore != null) |
545 | { | 562 | { |
546 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); | 563 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); |
@@ -603,9 +620,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
603 | //Animation states | 620 | //Animation states |
604 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 621 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
605 | // TODO: Change default to true once the feature is supported | 622 | // TODO: Change default to true once the feature is supported |
606 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); | 623 | m_usePreJump = startupConfig.GetBoolean("enableprejump", true); |
607 | |||
608 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 624 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
625 | |||
626 | m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); | ||
609 | if (RegionInfo.NonphysPrimMax > 0) | 627 | if (RegionInfo.NonphysPrimMax > 0) |
610 | { | 628 | { |
611 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 629 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -646,6 +664,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
646 | } | 664 | } |
647 | 665 | ||
648 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 666 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
667 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
649 | } | 668 | } |
650 | catch | 669 | catch |
651 | { | 670 | { |
@@ -886,6 +905,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
886 | /// <param name="seconds">float indicating duration before restart.</param> | 905 | /// <param name="seconds">float indicating duration before restart.</param> |
887 | public virtual void Restart(float seconds) | 906 | public virtual void Restart(float seconds) |
888 | { | 907 | { |
908 | Restart(seconds, true); | ||
909 | } | ||
910 | |||
911 | /// <summary> | ||
912 | /// Given float seconds, this will restart the region. showDialog will optionally alert the users. | ||
913 | /// </summary> | ||
914 | /// <param name="seconds">float indicating duration before restart.</param> | ||
915 | public virtual void Restart(float seconds, bool showDialog) | ||
916 | { | ||
889 | // notifications are done in 15 second increments | 917 | // notifications are done in 15 second increments |
890 | // so .. if the number of seconds is less then 15 seconds, it's not really a restart request | 918 | // so .. if the number of seconds is less then 15 seconds, it's not really a restart request |
891 | // It's a 'Cancel restart' request. | 919 | // It's a 'Cancel restart' request. |
@@ -906,8 +934,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
906 | m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); | 934 | m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); |
907 | m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); | 935 | m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); |
908 | m_restartTimer.Start(); | 936 | m_restartTimer.Start(); |
909 | m_dialogModule.SendNotificationToUsersInRegion( | 937 | if (showDialog) |
938 | { | ||
939 | m_dialogModule.SendNotificationToUsersInRegion( | ||
910 | UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0))); | 940 | UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0))); |
941 | } | ||
911 | } | 942 | } |
912 | } | 943 | } |
913 | 944 | ||
@@ -1265,16 +1296,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1265 | // Check if any objects have reached their targets | 1296 | // Check if any objects have reached their targets |
1266 | CheckAtTargets(); | 1297 | CheckAtTargets(); |
1267 | 1298 | ||
1268 | // Update SceneObjectGroups that have scheduled themselves for updates | ||
1269 | // Objects queue their updates onto all scene presences | ||
1270 | if (m_frame % m_update_objects == 0) | ||
1271 | m_sceneGraph.UpdateObjectGroups(); | ||
1272 | |||
1273 | // Run through all ScenePresences looking for updates | 1299 | // Run through all ScenePresences looking for updates |
1274 | // Presence updates and queued object updates for each presence are sent to clients | 1300 | // Presence updates and queued object updates for each presence are sent to clients |
1275 | if (m_frame % m_update_presences == 0) | 1301 | if (m_frame % m_update_presences == 0) |
1276 | m_sceneGraph.UpdatePresences(); | 1302 | m_sceneGraph.UpdatePresences(); |
1277 | 1303 | ||
1304 | // Update SceneObjectGroups that have scheduled themselves for updates | ||
1305 | // Objects queue their updates onto all scene presences | ||
1306 | if (m_frame % m_update_objects == 0) | ||
1307 | m_sceneGraph.UpdateObjectGroups(); | ||
1308 | |||
1278 | if (m_frame % m_update_coarse_locations == 0) | 1309 | if (m_frame % m_update_coarse_locations == 0) |
1279 | { | 1310 | { |
1280 | List<Vector3> coarseLocations; | 1311 | List<Vector3> coarseLocations; |
@@ -1603,6 +1634,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1603 | public void StoreWindlightProfile(RegionLightShareData wl) | 1634 | public void StoreWindlightProfile(RegionLightShareData wl) |
1604 | { | 1635 | { |
1605 | m_regInfo.WindlightSettings = wl; | 1636 | m_regInfo.WindlightSettings = wl; |
1637 | wl.Save(); | ||
1606 | m_storageManager.DataStore.StoreRegionWindlightSettings(wl); | 1638 | m_storageManager.DataStore.StoreRegionWindlightSettings(wl); |
1607 | m_eventManager.TriggerOnSaveNewWindlightProfile(); | 1639 | m_eventManager.TriggerOnSaveNewWindlightProfile(); |
1608 | } | 1640 | } |
@@ -1758,14 +1790,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1758 | /// <returns></returns> | 1790 | /// <returns></returns> |
1759 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1791 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1760 | { | 1792 | { |
1793 | |||
1794 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1795 | Vector3 wpos = Vector3.Zero; | ||
1796 | // Check for water surface intersection from above | ||
1797 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1798 | { | ||
1799 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1800 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1801 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1802 | wpos.Z = wheight; | ||
1803 | } | ||
1804 | |||
1761 | Vector3 pos = Vector3.Zero; | 1805 | Vector3 pos = Vector3.Zero; |
1762 | if (RayEndIsIntersection == (byte)1) | 1806 | if (RayEndIsIntersection == (byte)1) |
1763 | { | 1807 | { |
1764 | pos = RayEnd; | 1808 | pos = RayEnd; |
1765 | return pos; | ||
1766 | } | 1809 | } |
1767 | 1810 | else if (RayTargetID != UUID.Zero) | |
1768 | if (RayTargetID != UUID.Zero) | ||
1769 | { | 1811 | { |
1770 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1812 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1771 | 1813 | ||
@@ -1787,7 +1829,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1787 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1829 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1788 | 1830 | ||
1789 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1831 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1790 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1832 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1791 | float ScaleOffset = 0.5f; | 1833 | float ScaleOffset = 0.5f; |
1792 | 1834 | ||
1793 | // If we hit something | 1835 | // If we hit something |
@@ -1810,13 +1852,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1810 | //pos.Z -= 0.25F; | 1852 | //pos.Z -= 0.25F; |
1811 | 1853 | ||
1812 | } | 1854 | } |
1813 | |||
1814 | return pos; | ||
1815 | } | 1855 | } |
1816 | else | 1856 | else |
1817 | { | 1857 | { |
1818 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1858 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1819 | |||
1820 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1859 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1821 | 1860 | ||
1822 | // Un-comment the following line to print the raytrace results to the console. | 1861 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1825,13 +1864,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1825 | if (ei.HitTF) | 1864 | if (ei.HitTF) |
1826 | { | 1865 | { |
1827 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1866 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1828 | } else | 1867 | } |
1868 | else | ||
1829 | { | 1869 | { |
1830 | // fall back to our stupid functionality | 1870 | // fall back to our stupid functionality |
1831 | pos = RayEnd; | 1871 | pos = RayEnd; |
1832 | } | 1872 | } |
1833 | |||
1834 | return pos; | ||
1835 | } | 1873 | } |
1836 | } | 1874 | } |
1837 | else | 1875 | else |
@@ -1842,8 +1880,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1842 | //increase height so its above the ground. | 1880 | //increase height so its above the ground. |
1843 | //should be getting the normal of the ground at the rez point and using that? | 1881 | //should be getting the normal of the ground at the rez point and using that? |
1844 | pos.Z += scale.Z / 2f; | 1882 | pos.Z += scale.Z / 2f; |
1845 | return pos; | 1883 | // return pos; |
1846 | } | 1884 | } |
1885 | |||
1886 | // check against posible water intercept | ||
1887 | if (wpos.Z > pos.Z) pos = wpos; | ||
1888 | return pos; | ||
1847 | } | 1889 | } |
1848 | 1890 | ||
1849 | 1891 | ||
@@ -1976,13 +2018,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1976 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) | 2018 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
1977 | { | 2019 | { |
1978 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); | 2020 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); |
1979 | } | 2021 | } |
1980 | 2022 | ||
1981 | /// <summary> | 2023 | /// <summary> |
1982 | /// Delete every object from the scene. This does not include attachments worn by avatars. | 2024 | /// Delete every object from the scene. This does not include attachments worn by avatars. |
1983 | /// </summary> | 2025 | /// </summary> |
1984 | public void DeleteAllSceneObjects() | 2026 | public void DeleteAllSceneObjects() |
1985 | { | 2027 | { |
2028 | DeleteAllSceneObjects(false); | ||
2029 | } | ||
2030 | |||
2031 | /// <summary> | ||
2032 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2033 | /// </summary> | ||
2034 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2035 | { | ||
2036 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1986 | lock (Entities) | 2037 | lock (Entities) |
1987 | { | 2038 | { |
1988 | ICollection<EntityBase> entities = new List<EntityBase>(Entities); | 2039 | ICollection<EntityBase> entities = new List<EntityBase>(Entities); |
@@ -1992,11 +2043,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1992 | if (e is SceneObjectGroup) | 2043 | if (e is SceneObjectGroup) |
1993 | { | 2044 | { |
1994 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2045 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1995 | if (!sog.IsAttachment) | 2046 | if (sog != null && !sog.IsAttachment) |
1996 | DeleteSceneObject((SceneObjectGroup)e, false); | 2047 | { |
2048 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2049 | { | ||
2050 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2051 | } | ||
2052 | else | ||
2053 | { | ||
2054 | toReturn.Add((SceneObjectGroup)e); | ||
2055 | } | ||
2056 | } | ||
1997 | } | 2057 | } |
1998 | } | 2058 | } |
1999 | } | 2059 | } |
2060 | if (toReturn.Count > 0) | ||
2061 | { | ||
2062 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2063 | } | ||
2000 | } | 2064 | } |
2001 | 2065 | ||
2002 | /// <summary> | 2066 | /// <summary> |
@@ -2364,6 +2428,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2364 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2428 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2365 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2429 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2366 | { | 2430 | { |
2431 | if (sceneObject.OwnerID == UUID.Zero) | ||
2432 | { | ||
2433 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2434 | return false; | ||
2435 | } | ||
2436 | |||
2367 | // If the user is banned, we won't let any of their objects | 2437 | // If the user is banned, we won't let any of their objects |
2368 | // enter. Period. | 2438 | // enter. Period. |
2369 | // | 2439 | // |
@@ -2413,15 +2483,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2413 | if (AttachmentsModule != null) | 2483 | if (AttachmentsModule != null) |
2414 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); | 2484 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); |
2415 | 2485 | ||
2486 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); | ||
2416 | } | 2487 | } |
2417 | else | 2488 | else |
2418 | { | 2489 | { |
2490 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2419 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2491 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2420 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2492 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2421 | } | 2493 | } |
2494 | if (sceneObject.OwnerID == UUID.Zero) | ||
2495 | { | ||
2496 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2497 | return false; | ||
2498 | } | ||
2422 | } | 2499 | } |
2423 | else | 2500 | else |
2424 | { | 2501 | { |
2502 | if (sceneObject.OwnerID == UUID.Zero) | ||
2503 | { | ||
2504 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2505 | return false; | ||
2506 | } | ||
2425 | AddRestoredSceneObject(sceneObject, true, false); | 2507 | AddRestoredSceneObject(sceneObject, true, false); |
2426 | 2508 | ||
2427 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2509 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2694,6 +2776,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2694 | client.OnFetchInventory += HandleFetchInventory; | 2776 | client.OnFetchInventory += HandleFetchInventory; |
2695 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2777 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2696 | client.OnCopyInventoryItem += CopyInventoryItem; | 2778 | client.OnCopyInventoryItem += CopyInventoryItem; |
2779 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2697 | client.OnMoveInventoryItem += MoveInventoryItem; | 2780 | client.OnMoveInventoryItem += MoveInventoryItem; |
2698 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2781 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2699 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2782 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2979,6 +3062,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2979 | /// <param name="flags"></param> | 3062 | /// <param name="flags"></param> |
2980 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3063 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
2981 | { | 3064 | { |
3065 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3066 | ScenePresence presence; | ||
3067 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3068 | { | ||
3069 | if (presence.Appearance != null) | ||
3070 | { | ||
3071 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3072 | } | ||
3073 | } | ||
3074 | |||
2982 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3075 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
2983 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3076 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
2984 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3077 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3073,7 +3166,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3073 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3166 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3074 | 3167 | ||
3075 | } | 3168 | } |
3169 | m_log.Debug("[Scene] Beginning ClientClosed"); | ||
3076 | m_eventManager.TriggerClientClosed(agentID, this); | 3170 | m_eventManager.TriggerClientClosed(agentID, this); |
3171 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3077 | } | 3172 | } |
3078 | catch (NullReferenceException) | 3173 | catch (NullReferenceException) |
3079 | { | 3174 | { |
@@ -3081,7 +3176,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3081 | // Avatar is already disposed :/ | 3176 | // Avatar is already disposed :/ |
3082 | } | 3177 | } |
3083 | 3178 | ||
3179 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3084 | m_eventManager.TriggerOnRemovePresence(agentID); | 3180 | m_eventManager.TriggerOnRemovePresence(agentID); |
3181 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3085 | ForEachClient( | 3182 | ForEachClient( |
3086 | delegate(IClientAPI client) | 3183 | delegate(IClientAPI client) |
3087 | { | 3184 | { |
@@ -3097,8 +3194,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3097 | } | 3194 | } |
3098 | 3195 | ||
3099 | // Remove the avatar from the scene | 3196 | // Remove the avatar from the scene |
3197 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3100 | m_sceneGraph.RemoveScenePresence(agentID); | 3198 | m_sceneGraph.RemoveScenePresence(agentID); |
3199 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3101 | m_clientManager.Remove(agentID); | 3200 | m_clientManager.Remove(agentID); |
3201 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3102 | 3202 | ||
3103 | try | 3203 | try |
3104 | { | 3204 | { |
@@ -3112,9 +3212,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3112 | { | 3212 | { |
3113 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3213 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3114 | } | 3214 | } |
3115 | 3215 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3116 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3216 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3117 | 3217 | m_log.Debug("[Scene] The avatar has left the building"); | |
3118 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3218 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3119 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3219 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3120 | } | 3220 | } |
@@ -3253,6 +3353,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3253 | { | 3353 | { |
3254 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3354 | if (land != null && !TestLandRestrictions(agent, land, out reason)) |
3255 | { | 3355 | { |
3356 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3256 | return false; | 3357 | return false; |
3257 | } | 3358 | } |
3258 | } | 3359 | } |
@@ -3366,6 +3467,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3366 | } | 3467 | } |
3367 | } | 3468 | } |
3368 | // Honor parcel landing type and position. | 3469 | // Honor parcel landing type and position. |
3470 | /* | ||
3471 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3369 | if (land != null) | 3472 | if (land != null) |
3370 | { | 3473 | { |
3371 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3474 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3373,6 +3476,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3373 | agent.startpos = land.LandData.UserLocation; | 3476 | agent.startpos = land.LandData.UserLocation; |
3374 | } | 3477 | } |
3375 | } | 3478 | } |
3479 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3376 | } | 3480 | } |
3377 | 3481 | ||
3378 | return true; | 3482 | return true; |
@@ -3735,12 +3839,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3735 | return false; | 3839 | return false; |
3736 | } | 3840 | } |
3737 | 3841 | ||
3842 | public bool IncomingCloseAgent(UUID agentID) | ||
3843 | { | ||
3844 | return IncomingCloseAgent(agentID, false); | ||
3845 | } | ||
3846 | |||
3847 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3848 | { | ||
3849 | return IncomingCloseAgent(agentID, true); | ||
3850 | } | ||
3851 | |||
3738 | /// <summary> | 3852 | /// <summary> |
3739 | /// Tell a single agent to disconnect from the region. | 3853 | /// Tell a single agent to disconnect from the region. |
3740 | /// </summary> | 3854 | /// </summary> |
3741 | /// <param name="regionHandle"></param> | ||
3742 | /// <param name="agentID"></param> | 3855 | /// <param name="agentID"></param> |
3743 | public bool IncomingCloseAgent(UUID agentID) | 3856 | /// <param name="childOnly"></param> |
3857 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3744 | { | 3858 | { |
3745 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3859 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3746 | 3860 | ||
@@ -3752,7 +3866,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3752 | { | 3866 | { |
3753 | m_sceneGraph.removeUserCount(false); | 3867 | m_sceneGraph.removeUserCount(false); |
3754 | } | 3868 | } |
3755 | else | 3869 | else if (!childOnly) |
3756 | { | 3870 | { |
3757 | m_sceneGraph.removeUserCount(true); | 3871 | m_sceneGraph.removeUserCount(true); |
3758 | } | 3872 | } |
@@ -3768,9 +3882,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3768 | } | 3882 | } |
3769 | else | 3883 | else |
3770 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3884 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3885 | presence.ControllingClient.Close(false); | ||
3886 | } | ||
3887 | else if (!childOnly) | ||
3888 | { | ||
3889 | presence.ControllingClient.Close(true); | ||
3771 | } | 3890 | } |
3772 | |||
3773 | presence.ControllingClient.Close(); | ||
3774 | return true; | 3891 | return true; |
3775 | } | 3892 | } |
3776 | 3893 | ||
@@ -4879,4 +4996,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
4879 | return offsets.ToArray(); | 4996 | return offsets.ToArray(); |
4880 | } | 4997 | } |
4881 | } | 4998 | } |
4882 | } \ No newline at end of file | 4999 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index c675322..59e4037 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -168,7 +168,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
168 | 168 | ||
169 | if (neighbour != null) | 169 | if (neighbour != null) |
170 | { | 170 | { |
171 | m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize); | 171 | // m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize); |
172 | m_scene.EventManager.TriggerOnRegionUp(neighbour); | 172 | m_scene.EventManager.TriggerOnRegionUp(neighbour); |
173 | } | 173 | } |
174 | else | 174 | else |
@@ -183,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
183 | //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); | 183 | //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); |
184 | 184 | ||
185 | List<GridRegion> neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); | 185 | List<GridRegion> neighbours = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID); |
186 | m_log.DebugFormat("[INTERGRID]: Informing {0} neighbours that this region is up", neighbours.Count); | 186 | //m_log.DebugFormat("[INTERGRID]: Informing {0} neighbours that this region is up", neighbours.Count); |
187 | foreach (GridRegion n in neighbours) | 187 | foreach (GridRegion n in neighbours) |
188 | { | 188 | { |
189 | InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; | 189 | InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync; |
@@ -267,14 +267,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
267 | protected void SendCloseChildAgentAsync(UUID agentID, ulong regionHandle) | 267 | protected void SendCloseChildAgentAsync(UUID agentID, ulong regionHandle) |
268 | { | 268 | { |
269 | 269 | ||
270 | m_log.Debug("[INTERGRID]: Sending close agent to " + regionHandle); | 270 | //m_log.Debug("[INTERGRID]: Sending close agent to " + regionHandle); |
271 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. | 271 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. |
272 | 272 | ||
273 | //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); | 273 | //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); |
274 | uint x = 0, y = 0; | 274 | uint x = 0, y = 0; |
275 | Utils.LongToUInts(regionHandle, out x, out y); | 275 | Utils.LongToUInts(regionHandle, out x, out y); |
276 | GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | 276 | GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); |
277 | m_scene.SimulationService.CloseAgent(destination, agentID); | 277 | m_scene.SimulationService.CloseChildAgent(destination, agentID); |
278 | } | 278 | } |
279 | 279 | ||
280 | private void SendCloseChildAgentCompleted(IAsyncResult iar) | 280 | private void SendCloseChildAgentCompleted(IAsyncResult iar) |
@@ -293,7 +293,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
293 | d); | 293 | d); |
294 | } | 294 | } |
295 | } | 295 | } |
296 | 296 | ||
297 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) | 297 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) |
298 | { | 298 | { |
299 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); | 299 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 9f38a99..94ec534 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -43,6 +43,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
43 | 43 | ||
44 | public delegate void ObjectDuplicateDelegate(EntityBase original, EntityBase clone); | 44 | public delegate void ObjectDuplicateDelegate(EntityBase original, EntityBase clone); |
45 | 45 | ||
46 | public delegate void AttachToBackupDelegate(SceneObjectGroup sog); | ||
47 | |||
48 | public delegate void DetachFromBackupDelegate(SceneObjectGroup sog); | ||
49 | |||
50 | public delegate void ChangedBackupDelegate(SceneObjectGroup sog); | ||
51 | |||
46 | public delegate void ObjectCreateDelegate(EntityBase obj); | 52 | public delegate void ObjectCreateDelegate(EntityBase obj); |
47 | 53 | ||
48 | public delegate void ObjectDeleteDelegate(EntityBase obj); | 54 | public delegate void ObjectDeleteDelegate(EntityBase obj); |
@@ -61,6 +67,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
61 | private PhysicsCrash handlerPhysicsCrash = null; | 67 | private PhysicsCrash handlerPhysicsCrash = null; |
62 | 68 | ||
63 | public event ObjectDuplicateDelegate OnObjectDuplicate; | 69 | public event ObjectDuplicateDelegate OnObjectDuplicate; |
70 | public event AttachToBackupDelegate OnAttachToBackup; | ||
71 | public event DetachFromBackupDelegate OnDetachFromBackup; | ||
72 | public event ChangedBackupDelegate OnChangeBackup; | ||
64 | public event ObjectCreateDelegate OnObjectCreate; | 73 | public event ObjectCreateDelegate OnObjectCreate; |
65 | public event ObjectDeleteDelegate OnObjectRemove; | 74 | public event ObjectDeleteDelegate OnObjectRemove; |
66 | 75 | ||
@@ -68,7 +77,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
68 | 77 | ||
69 | #region Fields | 78 | #region Fields |
70 | 79 | ||
71 | protected object m_presenceLock = new object(); | 80 | protected OpenMetaverse.ReaderWriterLockSlim m_scenePresencesLock = new OpenMetaverse.ReaderWriterLockSlim(); |
72 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); | 81 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); |
73 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); | 82 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); |
74 | 83 | ||
@@ -128,13 +137,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
128 | 137 | ||
129 | protected internal void Close() | 138 | protected internal void Close() |
130 | { | 139 | { |
131 | lock (m_presenceLock) | 140 | m_scenePresencesLock.EnterWriteLock(); |
141 | try | ||
132 | { | 142 | { |
133 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); | 143 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); |
134 | List<ScenePresence> newlist = new List<ScenePresence>(); | 144 | List<ScenePresence> newlist = new List<ScenePresence>(); |
135 | m_scenePresenceMap = newmap; | 145 | m_scenePresenceMap = newmap; |
136 | m_scenePresenceArray = newlist; | 146 | m_scenePresenceArray = newlist; |
137 | } | 147 | } |
148 | finally | ||
149 | { | ||
150 | m_scenePresencesLock.ExitWriteLock(); | ||
151 | } | ||
138 | 152 | ||
139 | lock (m_dictionary_lock) | 153 | lock (m_dictionary_lock) |
140 | { | 154 | { |
@@ -214,27 +228,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
214 | if (sp.IsChildAgent) | 228 | if (sp.IsChildAgent) |
215 | return; | 229 | return; |
216 | 230 | ||
217 | if (sp.ParentID != 0) | 231 | coarseLocations.Add(sp.AbsolutePosition); |
218 | { | 232 | avatarUUIDs.Add(sp.UUID); |
219 | // sitting avatar | ||
220 | SceneObjectPart sop = m_parentScene.GetSceneObjectPart(sp.ParentID); | ||
221 | if (sop != null) | ||
222 | { | ||
223 | coarseLocations.Add(sop.AbsolutePosition + sp.AbsolutePosition); | ||
224 | avatarUUIDs.Add(sp.UUID); | ||
225 | } | ||
226 | else | ||
227 | { | ||
228 | // we can't find the parent.. ! arg! | ||
229 | coarseLocations.Add(sp.AbsolutePosition); | ||
230 | avatarUUIDs.Add(sp.UUID); | ||
231 | } | ||
232 | } | ||
233 | else | ||
234 | { | ||
235 | coarseLocations.Add(sp.AbsolutePosition); | ||
236 | avatarUUIDs.Add(sp.UUID); | ||
237 | } | ||
238 | } | 233 | } |
239 | } | 234 | } |
240 | 235 | ||
@@ -264,6 +259,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
264 | protected internal bool AddRestoredSceneObject( | 259 | protected internal bool AddRestoredSceneObject( |
265 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 260 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
266 | { | 261 | { |
262 | if (!m_parentScene.CombineRegions) | ||
263 | { | ||
264 | // KF: Check for out-of-region, move inside and make static. | ||
265 | Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, | ||
266 | sceneObject.RootPart.GroupPosition.Y, | ||
267 | sceneObject.RootPart.GroupPosition.Z); | ||
268 | 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 || | ||
269 | npos.X > Constants.RegionSize || | ||
270 | npos.Y > Constants.RegionSize)) | ||
271 | { | ||
272 | if (npos.X < 0.0) npos.X = 1.0f; | ||
273 | if (npos.Y < 0.0) npos.Y = 1.0f; | ||
274 | if (npos.Z < 0.0) npos.Z = 0.0f; | ||
275 | if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; | ||
276 | if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; | ||
277 | |||
278 | foreach (SceneObjectPart part in sceneObject.Children.Values) | ||
279 | { | ||
280 | part.GroupPosition = npos; | ||
281 | } | ||
282 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
283 | sceneObject.RootPart.AngularVelocity = Vector3.Zero; | ||
284 | sceneObject.RootPart.Acceleration = Vector3.Zero; | ||
285 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
286 | } | ||
287 | } | ||
288 | |||
267 | if (!alreadyPersisted) | 289 | if (!alreadyPersisted) |
268 | { | 290 | { |
269 | sceneObject.ForceInventoryPersistence(); | 291 | sceneObject.ForceInventoryPersistence(); |
@@ -354,10 +376,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
354 | m_numPrim += sceneObject.Children.Count; | 376 | m_numPrim += sceneObject.Children.Count; |
355 | 377 | ||
356 | if (attachToBackup) | 378 | if (attachToBackup) |
379 | { | ||
357 | sceneObject.AttachToBackup(); | 380 | sceneObject.AttachToBackup(); |
381 | } | ||
358 | 382 | ||
359 | if (OnObjectCreate != null) | 383 | if (OnObjectCreate != null) |
384 | { | ||
360 | OnObjectCreate(sceneObject); | 385 | OnObjectCreate(sceneObject); |
386 | } | ||
361 | 387 | ||
362 | lock (m_dictionary_lock) | 388 | lock (m_dictionary_lock) |
363 | { | 389 | { |
@@ -424,6 +450,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
424 | } | 450 | } |
425 | } | 451 | } |
426 | 452 | ||
453 | public void FireAttachToBackup(SceneObjectGroup obj) | ||
454 | { | ||
455 | if (OnAttachToBackup != null) | ||
456 | { | ||
457 | OnAttachToBackup(obj); | ||
458 | } | ||
459 | } | ||
460 | |||
461 | public void FireDetachFromBackup(SceneObjectGroup obj) | ||
462 | { | ||
463 | if (OnDetachFromBackup != null) | ||
464 | { | ||
465 | OnDetachFromBackup(obj); | ||
466 | } | ||
467 | } | ||
468 | |||
469 | public void FireChangeBackup(SceneObjectGroup obj) | ||
470 | { | ||
471 | if (OnChangeBackup != null) | ||
472 | { | ||
473 | OnChangeBackup(obj); | ||
474 | } | ||
475 | } | ||
476 | |||
427 | /// <summary> | 477 | /// <summary> |
428 | /// Process all pending updates | 478 | /// Process all pending updates |
429 | /// </summary> | 479 | /// </summary> |
@@ -560,7 +610,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
560 | 610 | ||
561 | Entities[presence.UUID] = presence; | 611 | Entities[presence.UUID] = presence; |
562 | 612 | ||
563 | lock (m_presenceLock) | 613 | m_scenePresencesLock.EnterWriteLock(); |
614 | try | ||
564 | { | 615 | { |
565 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 616 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
566 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 617 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -584,6 +635,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
584 | m_scenePresenceMap = newmap; | 635 | m_scenePresenceMap = newmap; |
585 | m_scenePresenceArray = newlist; | 636 | m_scenePresenceArray = newlist; |
586 | } | 637 | } |
638 | finally | ||
639 | { | ||
640 | m_scenePresencesLock.ExitWriteLock(); | ||
641 | } | ||
587 | } | 642 | } |
588 | 643 | ||
589 | /// <summary> | 644 | /// <summary> |
@@ -598,7 +653,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
598 | agentID); | 653 | agentID); |
599 | } | 654 | } |
600 | 655 | ||
601 | lock (m_presenceLock) | 656 | m_scenePresencesLock.EnterWriteLock(); |
657 | try | ||
602 | { | 658 | { |
603 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 659 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
604 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 660 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -620,6 +676,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
620 | m_log.WarnFormat("[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); | 676 | m_log.WarnFormat("[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); |
621 | } | 677 | } |
622 | } | 678 | } |
679 | finally | ||
680 | { | ||
681 | m_scenePresencesLock.ExitWriteLock(); | ||
682 | } | ||
623 | } | 683 | } |
624 | 684 | ||
625 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) | 685 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) |
@@ -1497,10 +1557,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1497 | /// <param name="childPrims"></param> | 1557 | /// <param name="childPrims"></param> |
1498 | protected internal void LinkObjects(SceneObjectPart root, List<SceneObjectPart> children) | 1558 | protected internal void LinkObjects(SceneObjectPart root, List<SceneObjectPart> children) |
1499 | { | 1559 | { |
1560 | SceneObjectGroup parentGroup = root.ParentGroup; | ||
1561 | if (parentGroup == null) return; | ||
1500 | Monitor.Enter(m_updateLock); | 1562 | Monitor.Enter(m_updateLock); |
1563 | |||
1501 | try | 1564 | try |
1502 | { | 1565 | { |
1503 | SceneObjectGroup parentGroup = root.ParentGroup; | 1566 | parentGroup.areUpdatesSuspended = true; |
1504 | 1567 | ||
1505 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); | 1568 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); |
1506 | if (parentGroup != null) | 1569 | if (parentGroup != null) |
@@ -1539,12 +1602,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1539 | // occur on link to invoke this elsewhere (such as object selection) | 1602 | // occur on link to invoke this elsewhere (such as object selection) |
1540 | parentGroup.RootPart.CreateSelected = true; | 1603 | parentGroup.RootPart.CreateSelected = true; |
1541 | parentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1604 | parentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1542 | parentGroup.HasGroupChanged = true; | ||
1543 | parentGroup.ScheduleGroupForFullUpdate(); | ||
1544 | |||
1545 | } | 1605 | } |
1546 | finally | 1606 | finally |
1547 | { | 1607 | { |
1608 | parentGroup.areUpdatesSuspended = false; | ||
1609 | parentGroup.HasGroupChanged = true; | ||
1610 | parentGroup.ScheduleGroupForFullUpdate(); | ||
1548 | Monitor.Exit(m_updateLock); | 1611 | Monitor.Exit(m_updateLock); |
1549 | } | 1612 | } |
1550 | } | 1613 | } |
@@ -1581,11 +1644,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1581 | } | 1644 | } |
1582 | } | 1645 | } |
1583 | 1646 | ||
1584 | foreach (SceneObjectPart child in childParts) | 1647 | if (childParts.Count > 0) |
1585 | { | 1648 | { |
1586 | // Unlink all child parts from their groups | 1649 | try |
1587 | // | 1650 | { |
1588 | child.ParentGroup.DelinkFromGroup(child, true); | 1651 | childParts[0].ParentGroup.areUpdatesSuspended = true; |
1652 | foreach (SceneObjectPart child in childParts) | ||
1653 | { | ||
1654 | // Unlink all child parts from their groups | ||
1655 | // | ||
1656 | child.ParentGroup.DelinkFromGroup(child, true); | ||
1657 | } | ||
1658 | } | ||
1659 | finally | ||
1660 | { | ||
1661 | childParts[0].ParentGroup.areUpdatesSuspended = false; | ||
1662 | } | ||
1589 | } | 1663 | } |
1590 | 1664 | ||
1591 | foreach (SceneObjectPart root in rootParts) | 1665 | foreach (SceneObjectPart root in rootParts) |
@@ -1609,10 +1683,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1609 | if (numChildren > 1) | 1683 | if (numChildren > 1) |
1610 | sendEventsToRemainder = false; | 1684 | sendEventsToRemainder = false; |
1611 | 1685 | ||
1612 | foreach (SceneObjectPart p in newSet) | 1686 | if (newSet.Count > 0) |
1613 | { | 1687 | { |
1614 | if (p != group.RootPart) | 1688 | try |
1615 | group.DelinkFromGroup(p, sendEventsToRemainder); | 1689 | { |
1690 | newSet[0].ParentGroup.areUpdatesSuspended = true; | ||
1691 | foreach (SceneObjectPart p in newSet) | ||
1692 | { | ||
1693 | if (p != group.RootPart) | ||
1694 | group.DelinkFromGroup(p, sendEventsToRemainder); | ||
1695 | } | ||
1696 | } | ||
1697 | finally | ||
1698 | { | ||
1699 | newSet[0].ParentGroup.areUpdatesSuspended = false; | ||
1700 | } | ||
1616 | } | 1701 | } |
1617 | 1702 | ||
1618 | // If there is more than one prim remaining, we | 1703 | // If there is more than one prim remaining, we |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 9a01a28..abb4de6 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -46,12 +46,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
46 | /// </summary> | 46 | /// </summary> |
47 | public void ForceInventoryPersistence() | 47 | public void ForceInventoryPersistence() |
48 | { | 48 | { |
49 | lock (m_parts) | 49 | lockPartsForRead(true); |
50 | List<SceneObjectPart> values = new List<SceneObjectPart>(m_parts.Values); | ||
51 | lockPartsForRead(false); | ||
52 | foreach (SceneObjectPart part in values) | ||
50 | { | 53 | { |
51 | foreach (SceneObjectPart part in m_parts.Values) | 54 | part.Inventory.ForceInventoryPersistence(); |
52 | { | ||
53 | part.Inventory.ForceInventoryPersistence(); | ||
54 | } | ||
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
@@ -74,19 +74,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
74 | /// <summary> | 74 | /// <summary> |
75 | /// Stop the scripts contained in all the prims in this group | 75 | /// Stop the scripts contained in all the prims in this group |
76 | /// </summary> | 76 | /// </summary> |
77 | /// <param name="sceneObjectBeingDeleted"> | ||
78 | /// Should be true if these scripts are being removed because the scene | ||
79 | /// object is being deleted. This will prevent spurious updates to the client. | ||
80 | /// </param> | ||
81 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 77 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
82 | { | 78 | { |
83 | lock (m_parts) | 79 | lockPartsForRead(true); |
80 | List<SceneObjectPart> values = new List<SceneObjectPart>(m_parts.Values); | ||
81 | lockPartsForRead(false); | ||
82 | |||
83 | foreach (SceneObjectPart part in values) | ||
84 | { | 84 | { |
85 | foreach (SceneObjectPart part in m_parts.Values) | 85 | part.Inventory.RemoveScriptInstances(sceneObjectBeingDeleted); |
86 | { | ||
87 | part.Inventory.RemoveScriptInstances(sceneObjectBeingDeleted); | ||
88 | } | ||
89 | } | 86 | } |
87 | |||
90 | } | 88 | } |
91 | 89 | ||
92 | /// <summary> | 90 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 117f869..9b66fad 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Drawing; | 30 | using System.Drawing; |
31 | using System.IO; | 31 | using System.IO; |
32 | using System.Diagnostics; | ||
32 | using System.Threading; | 33 | using System.Threading; |
33 | using System.Xml; | 34 | using System.Xml; |
34 | using System.Xml.Serialization; | 35 | using System.Xml.Serialization; |
@@ -104,8 +105,113 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | /// since the group's last persistent backup | 105 | /// since the group's last persistent backup |
105 | /// </summary> | 106 | /// </summary> |
106 | private bool m_hasGroupChanged = false; | 107 | private bool m_hasGroupChanged = false; |
107 | private long timeFirstChanged; | 108 | private long timeFirstChanged = 0; |
108 | private long timeLastChanged; | 109 | private long timeLastChanged = 0; |
110 | private long m_maxPersistTime = 0; | ||
111 | private long m_minPersistTime = 0; | ||
112 | private Random m_rand; | ||
113 | private bool m_suspendUpdates; | ||
114 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); | ||
115 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); | ||
116 | |||
117 | public bool areUpdatesSuspended | ||
118 | { | ||
119 | get | ||
120 | { | ||
121 | return m_suspendUpdates; | ||
122 | } | ||
123 | set | ||
124 | { | ||
125 | m_suspendUpdates = value; | ||
126 | if (!value) | ||
127 | { | ||
128 | QueueForUpdateCheck(); | ||
129 | } | ||
130 | } | ||
131 | } | ||
132 | |||
133 | public void lockPartsForRead(bool locked) | ||
134 | { | ||
135 | if (locked) | ||
136 | { | ||
137 | if (m_partsLock.RecursiveReadCount > 0) | ||
138 | { | ||
139 | m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
140 | try | ||
141 | { | ||
142 | StackTrace stackTrace = new StackTrace(); // get call stack | ||
143 | StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames) | ||
144 | |||
145 | // write call stack method names | ||
146 | foreach (StackFrame stackFrame in stackFrames) | ||
147 | { | ||
148 | m_log.Error("[SceneObjectGroup.m_parts] "+(stackFrame.GetMethod().Name)); // write method name | ||
149 | } | ||
150 | |||
151 | m_partsLock.ExitReadLock(); | ||
152 | } | ||
153 | catch { } // Ignore errors, to allow resync | ||
154 | } | ||
155 | if (m_partsLock.RecursiveWriteCount > 0) | ||
156 | { | ||
157 | m_log.Error("[SceneObjectGroup.m_parts] Recursive read lock requested (write lock exists on this thread). This should not happen and means something needs to be fixed."); | ||
158 | try | ||
159 | { | ||
160 | m_partsLock.ExitWriteLock(); | ||
161 | } | ||
162 | catch { } | ||
163 | |||
164 | } | ||
165 | |||
166 | while (!m_partsLock.TryEnterReadLock(60000)) | ||
167 | { | ||
168 | m_log.Error("[SceneObjectGroup.m_parts] Thread lock detected while trying to aquire READ lock of m_parts in SceneObjectGroup. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
169 | if (m_partsLock.IsWriteLockHeld) | ||
170 | { | ||
171 | m_partsLock = new System.Threading.ReaderWriterLockSlim(); | ||
172 | } | ||
173 | } | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | if (m_partsLock.RecursiveReadCount > 0) | ||
178 | { | ||
179 | m_partsLock.ExitReadLock(); | ||
180 | } | ||
181 | } | ||
182 | } | ||
183 | public void lockPartsForWrite(bool locked) | ||
184 | { | ||
185 | if (locked) | ||
186 | { | ||
187 | if (m_partsLock.RecursiveReadCount > 0) | ||
188 | { | ||
189 | m_log.Error("[SceneObjectGroup.m_parts] Recursive write lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue."); | ||
190 | m_partsLock.ExitReadLock(); | ||
191 | } | ||
192 | if (m_partsLock.RecursiveWriteCount > 0) | ||
193 | { | ||
194 | m_log.Error("[SceneObjectGroup.m_parts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
195 | m_partsLock.ExitWriteLock(); | ||
196 | } | ||
197 | |||
198 | while (!m_partsLock.TryEnterWriteLock(60000)) | ||
199 | { | ||
200 | m_log.Error("[SceneObjectGroup.m_parts] Thread lock detected while trying to aquire WRITE lock of m_scripts in XEngine. I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed."); | ||
201 | if (m_partsLock.IsWriteLockHeld) | ||
202 | { | ||
203 | m_partsLock = new System.Threading.ReaderWriterLockSlim(); | ||
204 | } | ||
205 | } | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | if (m_partsLock.RecursiveWriteCount > 0) | ||
210 | { | ||
211 | m_partsLock.ExitWriteLock(); | ||
212 | } | ||
213 | } | ||
214 | } | ||
109 | 215 | ||
110 | public bool HasGroupChanged | 216 | public bool HasGroupChanged |
111 | { | 217 | { |
@@ -113,9 +219,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
113 | { | 219 | { |
114 | if (value) | 220 | if (value) |
115 | { | 221 | { |
222 | if (m_isBackedUp) | ||
223 | { | ||
224 | m_scene.SceneGraph.FireChangeBackup(this); | ||
225 | } | ||
116 | timeLastChanged = DateTime.Now.Ticks; | 226 | timeLastChanged = DateTime.Now.Ticks; |
117 | if (!m_hasGroupChanged) | 227 | if (!m_hasGroupChanged) |
118 | timeFirstChanged = DateTime.Now.Ticks; | 228 | timeFirstChanged = DateTime.Now.Ticks; |
229 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | ||
230 | { | ||
231 | if (m_rand == null) | ||
232 | { | ||
233 | byte[] val = new byte[16]; | ||
234 | m_rootPart.UUID.ToBytes(val, 0); | ||
235 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
236 | } | ||
237 | |||
238 | if (m_scene.GetRootAgentCount() == 0) | ||
239 | { | ||
240 | //If the region is empty, this change has been made by an automated process | ||
241 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
242 | |||
243 | float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
244 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); | ||
245 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); | ||
246 | } | ||
247 | else | ||
248 | { | ||
249 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
250 | //but add a random factor so we stagger the object persistance a little | ||
251 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
252 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
253 | } | ||
254 | } | ||
119 | } | 255 | } |
120 | m_hasGroupChanged = value; | 256 | m_hasGroupChanged = value; |
121 | } | 257 | } |
@@ -131,8 +267,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
131 | return false; | 267 | return false; |
132 | if (m_scene.ShuttingDown) | 268 | if (m_scene.ShuttingDown) |
133 | return true; | 269 | return true; |
270 | |||
271 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
272 | { | ||
273 | m_maxPersistTime = m_scene.m_persistAfter; | ||
274 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
275 | } | ||
276 | |||
134 | long currentTime = DateTime.Now.Ticks; | 277 | long currentTime = DateTime.Now.Ticks; |
135 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 278 | |
279 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
280 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
281 | |||
282 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
136 | return true; | 283 | return true; |
137 | return false; | 284 | return false; |
138 | } | 285 | } |
@@ -181,7 +328,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
181 | 328 | ||
182 | private bool m_scriptListens_atRotTarget = false; | 329 | private bool m_scriptListens_atRotTarget = false; |
183 | private bool m_scriptListens_notAtRotTarget = false; | 330 | private bool m_scriptListens_notAtRotTarget = false; |
184 | 331 | public bool m_dupeInProgress = false; | |
185 | internal Dictionary<UUID, string> m_savedScriptState = null; | 332 | internal Dictionary<UUID, string> m_savedScriptState = null; |
186 | 333 | ||
187 | #region Properties | 334 | #region Properties |
@@ -221,7 +368,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
221 | public virtual Quaternion Rotation | 368 | public virtual Quaternion Rotation |
222 | { | 369 | { |
223 | get { return m_rotation; } | 370 | get { return m_rotation; } |
224 | set { m_rotation = value; } | 371 | set { |
372 | lockPartsForRead(true); | ||
373 | try | ||
374 | { | ||
375 | foreach(SceneObjectPart p in m_parts.Values) | ||
376 | { | ||
377 | p.StoreUndoState(UndoType.STATE_GROUP_ROTATION); | ||
378 | } | ||
379 | } | ||
380 | finally | ||
381 | { | ||
382 | lockPartsForRead(false); | ||
383 | } | ||
384 | m_rotation = value; | ||
385 | } | ||
225 | } | 386 | } |
226 | 387 | ||
227 | public Quaternion GroupRotation | 388 | public Quaternion GroupRotation |
@@ -258,13 +419,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
258 | set | 419 | set |
259 | { | 420 | { |
260 | m_regionHandle = value; | 421 | m_regionHandle = value; |
261 | lock (m_parts) | 422 | lockPartsForRead(true); |
262 | { | 423 | { |
263 | foreach (SceneObjectPart part in m_parts.Values) | 424 | foreach (SceneObjectPart part in m_parts.Values) |
264 | { | 425 | { |
426 | |||
265 | part.RegionHandle = m_regionHandle; | 427 | part.RegionHandle = m_regionHandle; |
428 | |||
266 | } | 429 | } |
267 | } | 430 | } |
431 | lockPartsForRead(false); | ||
268 | } | 432 | } |
269 | } | 433 | } |
270 | 434 | ||
@@ -298,6 +462,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
298 | { | 462 | { |
299 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | 463 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); |
300 | } | 464 | } |
465 | |||
466 | lockPartsForRead(true); | ||
467 | foreach (SceneObjectPart part in m_parts.Values) | ||
468 | { | ||
469 | part.IgnoreUndoUpdate = true; | ||
470 | } | ||
301 | if (RootPart.GetStatusSandbox()) | 471 | if (RootPart.GetStatusSandbox()) |
302 | { | 472 | { |
303 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) | 473 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) |
@@ -305,14 +475,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
305 | RootPart.ScriptSetPhysicsStatus(false); | 475 | RootPart.ScriptSetPhysicsStatus(false); |
306 | Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), | 476 | Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), |
307 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); | 477 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); |
478 | lockPartsForRead(false); | ||
308 | return; | 479 | return; |
309 | } | 480 | } |
310 | } | 481 | } |
311 | lock (m_parts) | 482 | List<SceneObjectPart> parts = new List<SceneObjectPart>(m_parts.Values); |
483 | lockPartsForRead(false); | ||
484 | foreach (SceneObjectPart part in parts) | ||
312 | { | 485 | { |
313 | foreach (SceneObjectPart part in m_parts.Values) | 486 | part.IgnoreUndoUpdate = false; |
487 | part.StoreUndoState(UndoType.STATE_GROUP_POSITION); | ||
488 | part.GroupPosition = val; | ||
489 | if (!m_dupeInProgress) | ||
490 | { | ||
491 | part.TriggerScriptChangedEvent(Changed.POSITION); | ||
492 | } | ||
493 | } | ||
494 | if (!m_dupeInProgress) | ||
495 | { | ||
496 | foreach (ScenePresence av in m_linkedAvatars) | ||
314 | { | 497 | { |
315 | part.GroupPosition = val; | 498 | Vector3 offset = m_parts[av.LinkedPrim].GetWorldPosition() - av.ParentPosition; |
499 | av.AbsolutePosition += offset; | ||
500 | av.ParentPosition = m_parts[av.LinkedPrim].GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition | ||
501 | av.SendFullUpdateToAllClients(); | ||
316 | } | 502 | } |
317 | } | 503 | } |
318 | 504 | ||
@@ -457,6 +643,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
457 | /// </summary> | 643 | /// </summary> |
458 | public SceneObjectGroup() | 644 | public SceneObjectGroup() |
459 | { | 645 | { |
646 | |||
460 | } | 647 | } |
461 | 648 | ||
462 | /// <summary> | 649 | /// <summary> |
@@ -473,7 +660,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
473 | /// Constructor. This object is added to the scene later via AttachToScene() | 660 | /// Constructor. This object is added to the scene later via AttachToScene() |
474 | /// </summary> | 661 | /// </summary> |
475 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 662 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
476 | { | 663 | { |
477 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); | 664 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
478 | } | 665 | } |
479 | 666 | ||
@@ -504,13 +691,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
504 | 691 | ||
505 | public void SetFromItemID(UUID AssetId) | 692 | public void SetFromItemID(UUID AssetId) |
506 | { | 693 | { |
507 | lock (m_parts) | 694 | lockPartsForRead(true); |
508 | { | 695 | { |
509 | foreach (SceneObjectPart part in m_parts.Values) | 696 | foreach (SceneObjectPart part in m_parts.Values) |
510 | { | 697 | { |
698 | |||
511 | part.FromItemID = AssetId; | 699 | part.FromItemID = AssetId; |
700 | |||
512 | } | 701 | } |
513 | } | 702 | } |
703 | lockPartsForRead(false); | ||
514 | } | 704 | } |
515 | 705 | ||
516 | public UUID GetFromItemID() | 706 | public UUID GetFromItemID() |
@@ -523,6 +713,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
523 | /// </summary> | 713 | /// </summary> |
524 | public virtual void AttachToBackup() | 714 | public virtual void AttachToBackup() |
525 | { | 715 | { |
716 | if (IsAttachment) return; | ||
717 | m_scene.SceneGraph.FireAttachToBackup(this); | ||
718 | |||
526 | if (InSceneBackup) | 719 | if (InSceneBackup) |
527 | { | 720 | { |
528 | //m_log.DebugFormat( | 721 | //m_log.DebugFormat( |
@@ -579,7 +772,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
579 | Vector3 maxScale = Vector3.Zero; | 772 | Vector3 maxScale = Vector3.Zero; |
580 | Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); | 773 | Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); |
581 | 774 | ||
582 | lock (m_parts) | 775 | lockPartsForRead(true); |
583 | { | 776 | { |
584 | foreach (SceneObjectPart part in m_parts.Values) | 777 | foreach (SceneObjectPart part in m_parts.Values) |
585 | { | 778 | { |
@@ -593,8 +786,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
593 | maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; | 786 | maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; |
594 | maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y; | 787 | maxScale.Y = (partscale.Y + partoffset.Y > maxScale.Y) ? partscale.Y + partoffset.Y : maxScale.Y; |
595 | maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; | 788 | maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; |
789 | |||
596 | } | 790 | } |
597 | } | 791 | } |
792 | lockPartsForRead(false); | ||
793 | |||
598 | finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; | 794 | finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; |
599 | finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; | 795 | finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; |
600 | finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; | 796 | finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; |
@@ -610,10 +806,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
610 | 806 | ||
611 | EntityIntersection result = new EntityIntersection(); | 807 | EntityIntersection result = new EntityIntersection(); |
612 | 808 | ||
613 | lock (m_parts) | 809 | lockPartsForRead(true); |
614 | { | 810 | { |
615 | foreach (SceneObjectPart part in m_parts.Values) | 811 | foreach (SceneObjectPart part in m_parts.Values) |
616 | { | 812 | { |
813 | |||
617 | // Temporary commented to stop compiler warning | 814 | // Temporary commented to stop compiler warning |
618 | //Vector3 partPosition = | 815 | //Vector3 partPosition = |
619 | // new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); | 816 | // new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); |
@@ -641,8 +838,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
641 | result.distance = inter.distance; | 838 | result.distance = inter.distance; |
642 | } | 839 | } |
643 | } | 840 | } |
841 | |||
644 | } | 842 | } |
645 | } | 843 | } |
844 | lockPartsForRead(false); | ||
646 | return result; | 845 | return result; |
647 | } | 846 | } |
648 | 847 | ||
@@ -661,10 +860,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
661 | minY = 256f; | 860 | minY = 256f; |
662 | minZ = 8192f; | 861 | minZ = 8192f; |
663 | 862 | ||
664 | lock(m_parts); | 863 | lockPartsForRead(true); |
665 | { | 864 | { |
666 | foreach (SceneObjectPart part in m_parts.Values) | 865 | foreach (SceneObjectPart part in m_parts.Values) |
667 | { | 866 | { |
867 | |||
668 | Vector3 worldPos = part.GetWorldPosition(); | 868 | Vector3 worldPos = part.GetWorldPosition(); |
669 | Vector3 offset = worldPos - AbsolutePosition; | 869 | Vector3 offset = worldPos - AbsolutePosition; |
670 | Quaternion worldRot; | 870 | Quaternion worldRot; |
@@ -723,6 +923,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
723 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); | 923 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); |
724 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); | 924 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); |
725 | 925 | ||
926 | |||
927 | |||
726 | //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | 928 | //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); |
727 | //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | 929 | //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); |
728 | //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | 930 | //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); |
@@ -894,6 +1096,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
894 | minZ = backBottomLeft.Z; | 1096 | minZ = backBottomLeft.Z; |
895 | } | 1097 | } |
896 | } | 1098 | } |
1099 | lockPartsForRead(false); | ||
897 | } | 1100 | } |
898 | 1101 | ||
899 | public Vector3 GetAxisAlignedBoundingBox(out float offsetHeight) | 1102 | public Vector3 GetAxisAlignedBoundingBox(out float offsetHeight) |
@@ -929,21 +1132,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
929 | 1132 | ||
930 | public void SaveScriptedState(XmlTextWriter writer) | 1133 | public void SaveScriptedState(XmlTextWriter writer) |
931 | { | 1134 | { |
1135 | SaveScriptedState(writer, false); | ||
1136 | } | ||
1137 | |||
1138 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1139 | { | ||
932 | XmlDocument doc = new XmlDocument(); | 1140 | XmlDocument doc = new XmlDocument(); |
933 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1141 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
934 | 1142 | ||
935 | // Capture script state while holding the lock | 1143 | // Capture script state while holding the lock |
936 | lock (m_parts) | 1144 | lockPartsForRead(true); |
937 | { | 1145 | { |
938 | foreach (SceneObjectPart part in m_parts.Values) | 1146 | foreach (SceneObjectPart part in m_parts.Values) |
939 | { | 1147 | { |
940 | Dictionary<UUID,string> pstates = part.Inventory.GetScriptStates(); | 1148 | |
1149 | Dictionary<UUID,string> pstates = part.Inventory.GetScriptStates(oldIDs); | ||
941 | foreach (UUID itemid in pstates.Keys) | 1150 | foreach (UUID itemid in pstates.Keys) |
942 | { | 1151 | { |
943 | states.Add(itemid, pstates[itemid]); | 1152 | states.Add(itemid, pstates[itemid]); |
944 | } | 1153 | } |
1154 | |||
945 | } | 1155 | } |
946 | } | 1156 | } |
1157 | lockPartsForRead(false); | ||
947 | 1158 | ||
948 | if (states.Count > 0) | 1159 | if (states.Count > 0) |
949 | { | 1160 | { |
@@ -962,6 +1173,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
962 | } | 1173 | } |
963 | 1174 | ||
964 | /// <summary> | 1175 | /// <summary> |
1176 | /// Add the avatar to this linkset (avatar is sat). | ||
1177 | /// </summary> | ||
1178 | /// <param name="agentID"></param> | ||
1179 | public void AddAvatar(UUID agentID) | ||
1180 | { | ||
1181 | ScenePresence presence; | ||
1182 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1183 | { | ||
1184 | if (!m_linkedAvatars.Contains(presence)) | ||
1185 | { | ||
1186 | m_linkedAvatars.Add(presence); | ||
1187 | } | ||
1188 | } | ||
1189 | } | ||
1190 | |||
1191 | /// <summary> | ||
1192 | /// Delete the avatar from this linkset (avatar is unsat). | ||
1193 | /// </summary> | ||
1194 | /// <param name="agentID"></param> | ||
1195 | public void DeleteAvatar(UUID agentID) | ||
1196 | { | ||
1197 | ScenePresence presence; | ||
1198 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1199 | { | ||
1200 | if (m_linkedAvatars.Contains(presence)) | ||
1201 | { | ||
1202 | m_linkedAvatars.Remove(presence); | ||
1203 | } | ||
1204 | } | ||
1205 | } | ||
1206 | |||
1207 | /// <summary> | ||
1208 | /// Returns the list of linked presences (avatars sat on this group) | ||
1209 | /// </summary> | ||
1210 | /// <param name="agentID"></param> | ||
1211 | public List<ScenePresence> GetLinkedAvatars() | ||
1212 | { | ||
1213 | return m_linkedAvatars; | ||
1214 | } | ||
1215 | |||
1216 | /// <summary> | ||
965 | /// Attach this scene object to the given avatar. | 1217 | /// Attach this scene object to the given avatar. |
966 | /// </summary> | 1218 | /// </summary> |
967 | /// <param name="agentID"></param> | 1219 | /// <param name="agentID"></param> |
@@ -1112,13 +1364,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1112 | 1364 | ||
1113 | public override void UpdateMovement() | 1365 | public override void UpdateMovement() |
1114 | { | 1366 | { |
1115 | lock (m_parts) | 1367 | lockPartsForRead(true); |
1116 | { | 1368 | { |
1117 | foreach (SceneObjectPart part in m_parts.Values) | 1369 | foreach (SceneObjectPart part in m_parts.Values) |
1118 | { | 1370 | { |
1371 | |||
1119 | part.UpdateMovement(); | 1372 | part.UpdateMovement(); |
1373 | |||
1120 | } | 1374 | } |
1121 | } | 1375 | } |
1376 | lockPartsForRead(false); | ||
1122 | } | 1377 | } |
1123 | 1378 | ||
1124 | public ushort GetTimeDilation() | 1379 | public ushort GetTimeDilation() |
@@ -1162,7 +1417,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1162 | /// <param name="part"></param> | 1417 | /// <param name="part"></param> |
1163 | public void AddPart(SceneObjectPart part) | 1418 | public void AddPart(SceneObjectPart part) |
1164 | { | 1419 | { |
1165 | lock (m_parts) | 1420 | lockPartsForWrite(true); |
1166 | { | 1421 | { |
1167 | part.SetParent(this); | 1422 | part.SetParent(this); |
1168 | m_parts.Add(part.UUID, part); | 1423 | m_parts.Add(part.UUID, part); |
@@ -1172,6 +1427,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1172 | if (part.LinkNum == 2 && RootPart != null) | 1427 | if (part.LinkNum == 2 && RootPart != null) |
1173 | RootPart.LinkNum = 1; | 1428 | RootPart.LinkNum = 1; |
1174 | } | 1429 | } |
1430 | lockPartsForWrite(false); | ||
1175 | } | 1431 | } |
1176 | 1432 | ||
1177 | /// <summary> | 1433 | /// <summary> |
@@ -1179,28 +1435,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
1179 | /// </summary> | 1435 | /// </summary> |
1180 | private void UpdateParentIDs() | 1436 | private void UpdateParentIDs() |
1181 | { | 1437 | { |
1182 | lock (m_parts) | 1438 | lockPartsForRead(true); |
1183 | { | 1439 | { |
1184 | foreach (SceneObjectPart part in m_parts.Values) | 1440 | foreach (SceneObjectPart part in m_parts.Values) |
1185 | { | 1441 | { |
1442 | |||
1186 | if (part.UUID != m_rootPart.UUID) | 1443 | if (part.UUID != m_rootPart.UUID) |
1187 | { | 1444 | { |
1188 | part.ParentID = m_rootPart.LocalId; | 1445 | part.ParentID = m_rootPart.LocalId; |
1189 | } | 1446 | } |
1447 | |||
1190 | } | 1448 | } |
1191 | } | 1449 | } |
1450 | lockPartsForRead(false); | ||
1192 | } | 1451 | } |
1193 | 1452 | ||
1194 | public void RegenerateFullIDs() | 1453 | public void RegenerateFullIDs() |
1195 | { | 1454 | { |
1196 | lock (m_parts) | 1455 | lockPartsForRead(true); |
1197 | { | 1456 | { |
1198 | foreach (SceneObjectPart part in m_parts.Values) | 1457 | foreach (SceneObjectPart part in m_parts.Values) |
1199 | { | 1458 | { |
1459 | |||
1200 | part.UUID = UUID.Random(); | 1460 | part.UUID = UUID.Random(); |
1201 | 1461 | ||
1202 | } | 1462 | } |
1203 | } | 1463 | } |
1464 | lockPartsForRead(false); | ||
1204 | } | 1465 | } |
1205 | 1466 | ||
1206 | // helper provided for parts. | 1467 | // helper provided for parts. |
@@ -1261,7 +1522,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1261 | 1522 | ||
1262 | public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) | 1523 | public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) |
1263 | { | 1524 | { |
1264 | part.StoreUndoState(); | 1525 | part.StoreUndoState(UndoType.STATE_PRIM_ALL); |
1265 | part.OnGrab(offsetPos, remoteClient); | 1526 | part.OnGrab(offsetPos, remoteClient); |
1266 | } | 1527 | } |
1267 | 1528 | ||
@@ -1281,27 +1542,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1281 | 1542 | ||
1282 | DetachFromBackup(); | 1543 | DetachFromBackup(); |
1283 | 1544 | ||
1284 | lock (m_parts) | 1545 | lockPartsForRead(true); |
1546 | List<SceneObjectPart> values = new List<SceneObjectPart>(m_parts.Values); | ||
1547 | lockPartsForRead(false); | ||
1548 | |||
1549 | foreach (SceneObjectPart part in values) | ||
1285 | { | 1550 | { |
1286 | foreach (SceneObjectPart part in m_parts.Values) | ||
1287 | { | ||
1288 | // part.Inventory.RemoveScriptInstances(); | 1551 | // part.Inventory.RemoveScriptInstances(); |
1289 | Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 1552 | |
1553 | Scene.ForEachScenePresence(delegate (ScenePresence sp) | ||
1554 | { | ||
1555 | if (sp.ParentID == LocalId) | ||
1290 | { | 1556 | { |
1291 | if (avatar.ParentID == LocalId) | 1557 | sp.StandUp(); |
1292 | { | 1558 | } |
1293 | avatar.StandUp(); | ||
1294 | } | ||
1295 | 1559 | ||
1296 | if (!silent) | 1560 | if (!silent) |
1297 | { | 1561 | { |
1298 | part.UpdateFlag = 0; | 1562 | part.UpdateFlag = 0; |
1299 | if (part == m_rootPart) | 1563 | if (part == m_rootPart) |
1300 | avatar.ControllingClient.SendKillObject(m_regionHandle, part.LocalId); | 1564 | sp.ControllingClient.SendKillObject(m_regionHandle, part.LocalId); |
1301 | } | 1565 | } |
1302 | }); | 1566 | }); |
1303 | } | 1567 | |
1304 | } | 1568 | } |
1569 | |||
1570 | |||
1305 | } | 1571 | } |
1306 | 1572 | ||
1307 | public void AddScriptLPS(int count) | 1573 | public void AddScriptLPS(int count) |
@@ -1326,17 +1592,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1326 | 1592 | ||
1327 | scriptEvents aggregateScriptEvents = 0; | 1593 | scriptEvents aggregateScriptEvents = 0; |
1328 | 1594 | ||
1329 | lock (m_parts) | 1595 | lockPartsForRead(true); |
1330 | { | 1596 | { |
1331 | foreach (SceneObjectPart part in m_parts.Values) | 1597 | foreach (SceneObjectPart part in m_parts.Values) |
1332 | { | 1598 | { |
1599 | |||
1333 | if (part == null) | 1600 | if (part == null) |
1334 | continue; | 1601 | continue; |
1335 | if (part != RootPart) | 1602 | if (part != RootPart) |
1336 | part.Flags = objectflagupdate; | 1603 | part.Flags = objectflagupdate; |
1337 | aggregateScriptEvents |= part.AggregateScriptEvents; | 1604 | aggregateScriptEvents |= part.AggregateScriptEvents; |
1605 | |||
1338 | } | 1606 | } |
1339 | } | 1607 | } |
1608 | lockPartsForRead(false); | ||
1340 | 1609 | ||
1341 | m_scriptListens_atTarget = ((aggregateScriptEvents & scriptEvents.at_target) != 0); | 1610 | m_scriptListens_atTarget = ((aggregateScriptEvents & scriptEvents.at_target) != 0); |
1342 | m_scriptListens_notAtTarget = ((aggregateScriptEvents & scriptEvents.not_at_target) != 0); | 1611 | m_scriptListens_notAtTarget = ((aggregateScriptEvents & scriptEvents.not_at_target) != 0); |
@@ -1378,42 +1647,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
1378 | /// <param name="m_physicalPrim"></param> | 1647 | /// <param name="m_physicalPrim"></param> |
1379 | public void ApplyPhysics(bool m_physicalPrim) | 1648 | public void ApplyPhysics(bool m_physicalPrim) |
1380 | { | 1649 | { |
1381 | lock (m_parts) | 1650 | lockPartsForRead(true); |
1651 | |||
1652 | if (m_parts.Count > 1) | ||
1382 | { | 1653 | { |
1383 | if (m_parts.Count > 1) | 1654 | List<SceneObjectPart> values = new List<SceneObjectPart>(m_parts.Values); |
1655 | lockPartsForRead(false); | ||
1656 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); | ||
1657 | foreach (SceneObjectPart part in values) | ||
1384 | { | 1658 | { |
1385 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); | 1659 | |
1386 | foreach (SceneObjectPart part in m_parts.Values) | 1660 | if (part.LocalId != m_rootPart.LocalId) |
1387 | { | 1661 | { |
1388 | if (part.LocalId != m_rootPart.LocalId) | 1662 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, m_physicalPrim); |
1389 | { | ||
1390 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, m_physicalPrim); | ||
1391 | } | ||
1392 | } | 1663 | } |
1393 | 1664 | ||
1394 | // Hack to get the physics scene geometries in the right spot | ||
1395 | ResetChildPrimPhysicsPositions(); | ||
1396 | } | ||
1397 | else | ||
1398 | { | ||
1399 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); | ||
1400 | } | 1665 | } |
1666 | // Hack to get the physics scene geometries in the right spot | ||
1667 | ResetChildPrimPhysicsPositions(); | ||
1668 | } | ||
1669 | else | ||
1670 | { | ||
1671 | lockPartsForRead(false); | ||
1672 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); | ||
1401 | } | 1673 | } |
1402 | } | 1674 | } |
1403 | 1675 | ||
1404 | public void SetOwnerId(UUID userId) | 1676 | public void SetOwnerId(UUID userId) |
1405 | { | 1677 | { |
1406 | ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); | 1678 | ForEachPart(delegate(SceneObjectPart part) |
1679 | { | ||
1680 | |||
1681 | part.OwnerID = userId; | ||
1682 | |||
1683 | }); | ||
1407 | } | 1684 | } |
1408 | 1685 | ||
1409 | public void ForEachPart(Action<SceneObjectPart> whatToDo) | 1686 | public void ForEachPart(Action<SceneObjectPart> whatToDo) |
1410 | { | 1687 | { |
1411 | lock (m_parts) | 1688 | lockPartsForRead(true); |
1689 | List<SceneObjectPart> values = new List<SceneObjectPart>(m_parts.Values); | ||
1690 | lockPartsForRead(false); | ||
1691 | foreach (SceneObjectPart part in values) | ||
1412 | { | 1692 | { |
1413 | foreach (SceneObjectPart part in m_parts.Values) | 1693 | |
1414 | { | 1694 | whatToDo(part); |
1415 | whatToDo(part); | 1695 | |
1416 | } | ||
1417 | } | 1696 | } |
1418 | } | 1697 | } |
1419 | 1698 | ||
@@ -1436,7 +1715,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1436 | 1715 | ||
1437 | try | 1716 | try |
1438 | { | 1717 | { |
1439 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart | 1718 | if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart |
1719 | m_scene.LoginsDisabled || // We're starting up or doing maintenance, don't mess with things | ||
1720 | m_scene.LoadingPrims) // Land may not be valid yet | ||
1721 | |||
1440 | { | 1722 | { |
1441 | ILandObject parcel = m_scene.LandChannel.GetLandObject( | 1723 | ILandObject parcel = m_scene.LandChannel.GetLandObject( |
1442 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); | 1724 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); |
@@ -1468,9 +1750,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1468 | // don't backup while it's selected or you're asking for changes mid stream. | 1750 | // don't backup while it's selected or you're asking for changes mid stream. |
1469 | if ((isTimeToPersist()) || (forcedBackup)) | 1751 | if ((isTimeToPersist()) || (forcedBackup)) |
1470 | { | 1752 | { |
1471 | m_log.DebugFormat( | 1753 | // m_log.DebugFormat( |
1472 | "[SCENE]: Storing {0}, {1} in {2}", | 1754 | // "[SCENE]: Storing {0}, {1} in {2}", |
1473 | Name, UUID, m_scene.RegionInfo.RegionName); | 1755 | // Name, UUID, m_scene.RegionInfo.RegionName); |
1474 | 1756 | ||
1475 | SceneObjectGroup backup_group = Copy(false); | 1757 | SceneObjectGroup backup_group = Copy(false); |
1476 | backup_group.RootPart.Velocity = RootPart.Velocity; | 1758 | backup_group.RootPart.Velocity = RootPart.Velocity; |
@@ -1512,15 +1794,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1512 | RootPart.SendFullUpdate( | 1794 | RootPart.SendFullUpdate( |
1513 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); | 1795 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); |
1514 | 1796 | ||
1515 | lock (m_parts) | 1797 | lockPartsForRead(true); |
1516 | { | 1798 | { |
1517 | foreach (SceneObjectPart part in m_parts.Values) | 1799 | foreach (SceneObjectPart part in m_parts.Values) |
1518 | { | 1800 | { |
1801 | |||
1519 | if (part != RootPart) | 1802 | if (part != RootPart) |
1520 | part.SendFullUpdate( | 1803 | part.SendFullUpdate( |
1521 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); | 1804 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); |
1522 | } | 1805 | } |
1523 | } | 1806 | } |
1807 | lockPartsForRead(false); | ||
1524 | } | 1808 | } |
1525 | 1809 | ||
1526 | #region Copying | 1810 | #region Copying |
@@ -1532,86 +1816,114 @@ namespace OpenSim.Region.Framework.Scenes | |||
1532 | /// <returns></returns> | 1816 | /// <returns></returns> |
1533 | public SceneObjectGroup Copy(bool userExposed) | 1817 | public SceneObjectGroup Copy(bool userExposed) |
1534 | { | 1818 | { |
1535 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); | 1819 | SceneObjectGroup dupe; |
1536 | dupe.m_isBackedUp = false; | 1820 | try |
1537 | dupe.m_parts = new Dictionary<UUID, SceneObjectPart>(); | 1821 | { |
1822 | m_dupeInProgress = true; | ||
1823 | dupe = (SceneObjectGroup)MemberwiseClone(); | ||
1824 | dupe.m_isBackedUp = false; | ||
1825 | dupe.m_parts = new Dictionary<UUID, SceneObjectPart>(); | ||
1538 | 1826 | ||
1539 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of | 1827 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of |
1540 | // attachments do not bordercross while they're being duplicated. This is hacktastic! | 1828 | // attachments do not bordercross while they're being duplicated. This is hacktastic! |
1541 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! | 1829 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! |
1542 | // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state | 1830 | // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state |
1543 | // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, | 1831 | // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, |
1544 | // then restore it's attachment state | 1832 | // then restore it's attachment state |
1545 | 1833 | ||
1546 | // This is only necessary when userExposed is false! | 1834 | // This is only necessary when userExposed is false! |
1547 | 1835 | ||
1548 | bool previousAttachmentStatus = dupe.RootPart.IsAttachment; | 1836 | bool previousAttachmentStatus = dupe.RootPart.IsAttachment; |
1549 | |||
1550 | if (!userExposed) | ||
1551 | dupe.RootPart.IsAttachment = true; | ||
1552 | 1837 | ||
1553 | dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); | 1838 | if (!userExposed) |
1839 | dupe.RootPart.IsAttachment = true; | ||
1554 | 1840 | ||
1555 | if (!userExposed) | 1841 | dupe.AbsolutePosition = new Vector3(AbsolutePosition.X, AbsolutePosition.Y, AbsolutePosition.Z); |
1556 | { | ||
1557 | dupe.RootPart.IsAttachment = previousAttachmentStatus; | ||
1558 | } | ||
1559 | 1842 | ||
1560 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); | 1843 | if (!userExposed) |
1561 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; | 1844 | { |
1845 | dupe.RootPart.IsAttachment = previousAttachmentStatus; | ||
1846 | } | ||
1562 | 1847 | ||
1563 | if (userExposed) | 1848 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); |
1564 | dupe.m_rootPart.TrimPermissions(); | 1849 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; |
1565 | 1850 | ||
1566 | List<SceneObjectPart> partList; | 1851 | if (userExposed) |
1852 | dupe.m_rootPart.TrimPermissions(); | ||
1567 | 1853 | ||
1568 | lock (m_parts) | 1854 | /// may need to create a new Physics actor. |
1569 | { | 1855 | if (dupe.RootPart.PhysActor != null && userExposed) |
1570 | partList = new List<SceneObjectPart>(m_parts.Values); | ||
1571 | } | ||
1572 | |||
1573 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | ||
1574 | { | 1856 | { |
1575 | return p1.LinkNum.CompareTo(p2.LinkNum); | 1857 | PrimitiveBaseShape pbs = dupe.RootPart.Shape; |
1858 | |||
1859 | dupe.RootPart.PhysActor = m_scene.PhysicsScene.AddPrimShape( | ||
1860 | dupe.RootPart.Name, | ||
1861 | pbs, | ||
1862 | dupe.RootPart.AbsolutePosition, | ||
1863 | dupe.RootPart.Scale, | ||
1864 | dupe.RootPart.RotationOffset, | ||
1865 | dupe.RootPart.PhysActor.IsPhysical); | ||
1866 | |||
1867 | dupe.RootPart.PhysActor.LocalID = dupe.RootPart.LocalId; | ||
1868 | dupe.RootPart.DoPhysicsPropertyUpdate(dupe.RootPart.PhysActor.IsPhysical, true); | ||
1576 | } | 1869 | } |
1577 | ); | ||
1578 | 1870 | ||
1579 | foreach (SceneObjectPart part in partList) | 1871 | lockPartsForRead(true); |
1580 | { | 1872 | |
1581 | if (part.UUID != m_rootPart.UUID) | 1873 | List<SceneObjectPart> partList; |
1874 | |||
1875 | partList = new List<SceneObjectPart>(m_parts.Values); | ||
1876 | |||
1877 | lockPartsForRead(false); | ||
1878 | |||
1879 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | ||
1880 | { | ||
1881 | return p1.LinkNum.CompareTo(p2.LinkNum); | ||
1882 | } | ||
1883 | ); | ||
1884 | |||
1885 | foreach (SceneObjectPart part in partList) | ||
1582 | { | 1886 | { |
1583 | SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); | 1887 | if (part.UUID != m_rootPart.UUID) |
1584 | newPart.LinkNum = part.LinkNum; | 1888 | { |
1585 | } | 1889 | SceneObjectPart newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); |
1890 | |||
1891 | newPart.LinkNum = part.LinkNum; | ||
1892 | } | ||
1893 | |||
1894 | // Need to duplicate the physics actor as well | ||
1895 | if (part.PhysActor != null && userExposed) | ||
1896 | { | ||
1897 | PrimitiveBaseShape pbs = part.Shape; | ||
1898 | |||
1899 | part.PhysActor | ||
1900 | = m_scene.PhysicsScene.AddPrimShape( | ||
1901 | part.Name, | ||
1902 | pbs, | ||
1903 | part.AbsolutePosition, | ||
1904 | part.Scale, | ||
1905 | part.RotationOffset, | ||
1906 | part.PhysActor.IsPhysical); | ||
1907 | |||
1908 | part.PhysActor.LocalID = part.LocalId; | ||
1909 | part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); | ||
1910 | } | ||
1586 | 1911 | ||
1587 | // Need to duplicate the physics actor as well | 1912 | } |
1588 | if (part.PhysActor != null && userExposed) | 1913 | if (userExposed) |
1589 | { | 1914 | { |
1590 | PrimitiveBaseShape pbs = part.Shape; | 1915 | dupe.UpdateParentIDs(); |
1591 | 1916 | dupe.HasGroupChanged = true; | |
1592 | part.PhysActor | 1917 | dupe.AttachToBackup(); |
1593 | = m_scene.PhysicsScene.AddPrimShape( | 1918 | |
1594 | part.Name, | 1919 | ScheduleGroupForFullUpdate(); |
1595 | pbs, | 1920 | } |
1596 | part.AbsolutePosition, | 1921 | |
1597 | part.Scale, | ||
1598 | part.RotationOffset, | ||
1599 | part.PhysActor.IsPhysical); | ||
1600 | |||
1601 | part.PhysActor.LocalID = part.LocalId; | ||
1602 | part.DoPhysicsPropertyUpdate(part.PhysActor.IsPhysical, true); | ||
1603 | } | ||
1604 | } | 1922 | } |
1605 | 1923 | finally | |
1606 | if (userExposed) | ||
1607 | { | 1924 | { |
1608 | dupe.UpdateParentIDs(); | 1925 | m_dupeInProgress = false; |
1609 | dupe.HasGroupChanged = true; | ||
1610 | dupe.AttachToBackup(); | ||
1611 | |||
1612 | ScheduleGroupForFullUpdate(); | ||
1613 | } | 1926 | } |
1614 | |||
1615 | return dupe; | 1927 | return dupe; |
1616 | } | 1928 | } |
1617 | 1929 | ||
@@ -1802,13 +2114,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
1802 | } | 2114 | } |
1803 | } | 2115 | } |
1804 | 2116 | ||
2117 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2118 | { | ||
2119 | SceneObjectPart rootpart = m_rootPart; | ||
2120 | if (rootpart != null) | ||
2121 | { | ||
2122 | if (IsAttachment) | ||
2123 | { | ||
2124 | /* | ||
2125 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
2126 | if (avatar != null) | ||
2127 | { | ||
2128 | Rotate the Av? | ||
2129 | } */ | ||
2130 | } | ||
2131 | else | ||
2132 | { | ||
2133 | if (rootpart.PhysActor != null) | ||
2134 | { // APID must be implemented in your physics system for this to function. | ||
2135 | rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); | ||
2136 | rootpart.PhysActor.APIDStrength = strength; | ||
2137 | rootpart.PhysActor.APIDDamping = damping; | ||
2138 | rootpart.PhysActor.APIDActive = true; | ||
2139 | } | ||
2140 | } | ||
2141 | } | ||
2142 | } | ||
2143 | |||
1805 | public void stopLookAt() | 2144 | public void stopLookAt() |
1806 | { | 2145 | { |
1807 | SceneObjectPart rootpart = m_rootPart; | 2146 | SceneObjectPart rootpart = m_rootPart; |
1808 | if (rootpart != null) | 2147 | if (rootpart != null) |
1809 | { | 2148 | { |
1810 | if (rootpart.PhysActor != null) | 2149 | if (rootpart.PhysActor != null) |
1811 | { | 2150 | { // APID must be implemented in your physics system for this to function. |
1812 | rootpart.PhysActor.APIDActive = false; | 2151 | rootpart.PhysActor.APIDActive = false; |
1813 | } | 2152 | } |
1814 | } | 2153 | } |
@@ -1876,10 +2215,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1876 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | 2215 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); |
1877 | newPart.SetParent(this); | 2216 | newPart.SetParent(this); |
1878 | 2217 | ||
1879 | lock (m_parts) | 2218 | lockPartsForWrite(true); |
1880 | { | 2219 | { |
1881 | m_parts.Add(newPart.UUID, newPart); | 2220 | m_parts.Add(newPart.UUID, newPart); |
1882 | } | 2221 | } |
2222 | lockPartsForWrite(false); | ||
1883 | 2223 | ||
1884 | SetPartAsNonRoot(newPart); | 2224 | SetPartAsNonRoot(newPart); |
1885 | 2225 | ||
@@ -1942,7 +2282,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1942 | //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 2282 | //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
1943 | // return; | 2283 | // return; |
1944 | 2284 | ||
1945 | lock (m_parts) | 2285 | lockPartsForRead(true); |
1946 | { | 2286 | { |
1947 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); | 2287 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); |
1948 | 2288 | ||
@@ -1962,9 +2302,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1962 | { | 2302 | { |
1963 | if (!IsSelected) | 2303 | if (!IsSelected) |
1964 | part.UpdateLookAt(); | 2304 | part.UpdateLookAt(); |
2305 | |||
1965 | part.SendScheduledUpdates(); | 2306 | part.SendScheduledUpdates(); |
2307 | |||
1966 | } | 2308 | } |
1967 | } | 2309 | } |
2310 | lockPartsForRead(false); | ||
1968 | } | 2311 | } |
1969 | 2312 | ||
1970 | public void ScheduleFullUpdateToAvatar(ScenePresence presence) | 2313 | public void ScheduleFullUpdateToAvatar(ScenePresence presence) |
@@ -1973,27 +2316,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1973 | 2316 | ||
1974 | RootPart.AddFullUpdateToAvatar(presence); | 2317 | RootPart.AddFullUpdateToAvatar(presence); |
1975 | 2318 | ||
1976 | lock (m_parts) | 2319 | lockPartsForRead(true); |
1977 | { | 2320 | { |
1978 | foreach (SceneObjectPart part in m_parts.Values) | 2321 | foreach (SceneObjectPart part in m_parts.Values) |
1979 | { | 2322 | { |
2323 | |||
1980 | if (part != RootPart) | 2324 | if (part != RootPart) |
1981 | part.AddFullUpdateToAvatar(presence); | 2325 | part.AddFullUpdateToAvatar(presence); |
2326 | |||
1982 | } | 2327 | } |
1983 | } | 2328 | } |
2329 | lockPartsForRead(false); | ||
1984 | } | 2330 | } |
1985 | 2331 | ||
1986 | public void ScheduleTerseUpdateToAvatar(ScenePresence presence) | 2332 | public void ScheduleTerseUpdateToAvatar(ScenePresence presence) |
1987 | { | 2333 | { |
1988 | // m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); | 2334 | lockPartsForRead(true); |
1989 | 2335 | ||
1990 | lock (m_parts) | 2336 | foreach (SceneObjectPart part in m_parts.Values) |
1991 | { | 2337 | { |
1992 | foreach (SceneObjectPart part in m_parts.Values) | 2338 | part.AddTerseUpdateToAvatar(presence); |
1993 | { | ||
1994 | part.AddTerseUpdateToAvatar(presence); | ||
1995 | } | ||
1996 | } | 2339 | } |
2340 | |||
2341 | lockPartsForRead(false); | ||
1997 | } | 2342 | } |
1998 | 2343 | ||
1999 | /// <summary> | 2344 | /// <summary> |
@@ -2007,14 +2352,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2007 | checkAtTargets(); | 2352 | checkAtTargets(); |
2008 | RootPart.ScheduleFullUpdate(); | 2353 | RootPart.ScheduleFullUpdate(); |
2009 | 2354 | ||
2010 | lock (m_parts) | 2355 | lockPartsForRead(true); |
2011 | { | 2356 | { |
2012 | foreach (SceneObjectPart part in m_parts.Values) | 2357 | foreach (SceneObjectPart part in m_parts.Values) |
2013 | { | 2358 | { |
2359 | |||
2014 | if (part != RootPart) | 2360 | if (part != RootPart) |
2015 | part.ScheduleFullUpdate(); | 2361 | part.ScheduleFullUpdate(); |
2362 | |||
2016 | } | 2363 | } |
2017 | } | 2364 | } |
2365 | lockPartsForRead(false); | ||
2018 | } | 2366 | } |
2019 | 2367 | ||
2020 | /// <summary> | 2368 | /// <summary> |
@@ -2022,37 +2370,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
2022 | /// </summary> | 2370 | /// </summary> |
2023 | public void ScheduleGroupForTerseUpdate() | 2371 | public void ScheduleGroupForTerseUpdate() |
2024 | { | 2372 | { |
2025 | // m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); | 2373 | lockPartsForRead(true); |
2026 | 2374 | foreach (SceneObjectPart part in m_parts.Values) | |
2027 | lock (m_parts) | ||
2028 | { | 2375 | { |
2029 | foreach (SceneObjectPart part in m_parts.Values) | 2376 | part.ScheduleTerseUpdate(); |
2030 | { | ||
2031 | part.ScheduleTerseUpdate(); | ||
2032 | } | ||
2033 | } | 2377 | } |
2378 | |||
2379 | lockPartsForRead(false); | ||
2034 | } | 2380 | } |
2035 | 2381 | ||
2036 | /// <summary> | 2382 | /// <summary> |
2037 | /// Immediately send a full update for this scene object. | 2383 | /// Immediately send a full update for this scene object. |
2038 | /// </summary> | 2384 | /// </summary> |
2039 | public void SendGroupFullUpdate() | 2385 | public void SendGroupFullUpdate() |
2040 | { | 2386 | { |
2041 | if (IsDeleted) | 2387 | if (IsDeleted) |
2042 | return; | 2388 | return; |
2043 | 2389 | ||
2044 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); | 2390 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); |
2045 | 2391 | ||
2046 | RootPart.SendFullUpdateToAllClients(); | 2392 | RootPart.SendFullUpdateToAllClients(); |
2047 | 2393 | ||
2048 | lock (m_parts) | 2394 | lockPartsForRead(true); |
2049 | { | 2395 | { |
2050 | foreach (SceneObjectPart part in m_parts.Values) | 2396 | foreach (SceneObjectPart part in m_parts.Values) |
2051 | { | 2397 | { |
2398 | |||
2052 | if (part != RootPart) | 2399 | if (part != RootPart) |
2053 | part.SendFullUpdateToAllClients(); | 2400 | part.SendFullUpdateToAllClients(); |
2401 | |||
2054 | } | 2402 | } |
2055 | } | 2403 | } |
2404 | lockPartsForRead(false); | ||
2056 | } | 2405 | } |
2057 | 2406 | ||
2058 | /// <summary> | 2407 | /// <summary> |
@@ -2084,14 +2433,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2084 | { | 2433 | { |
2085 | if (IsDeleted) | 2434 | if (IsDeleted) |
2086 | return; | 2435 | return; |
2087 | 2436 | ||
2088 | lock (m_parts) | 2437 | lockPartsForRead(true); |
2089 | { | 2438 | { |
2090 | foreach (SceneObjectPart part in m_parts.Values) | 2439 | foreach (SceneObjectPart part in m_parts.Values) |
2091 | { | 2440 | { |
2092 | part.SendTerseUpdateToAllClients(); | 2441 | part.SendTerseUpdateToAllClients(); |
2093 | } | 2442 | } |
2094 | } | 2443 | } |
2444 | lockPartsForRead(false); | ||
2095 | } | 2445 | } |
2096 | 2446 | ||
2097 | #endregion | 2447 | #endregion |
@@ -2105,16 +2455,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2105 | /// <returns>null if no child part with that linknum or child part</returns> | 2455 | /// <returns>null if no child part with that linknum or child part</returns> |
2106 | public SceneObjectPart GetLinkNumPart(int linknum) | 2456 | public SceneObjectPart GetLinkNumPart(int linknum) |
2107 | { | 2457 | { |
2108 | lock (m_parts) | 2458 | lockPartsForRead(true); |
2109 | { | 2459 | { |
2110 | foreach (SceneObjectPart part in m_parts.Values) | 2460 | foreach (SceneObjectPart part in m_parts.Values) |
2111 | { | 2461 | { |
2112 | if (part.LinkNum == linknum) | 2462 | if (part.LinkNum == linknum) |
2113 | { | 2463 | { |
2464 | lockPartsForRead(false); | ||
2114 | return part; | 2465 | return part; |
2115 | } | 2466 | } |
2116 | } | 2467 | } |
2117 | } | 2468 | } |
2469 | lockPartsForRead(false); | ||
2118 | 2470 | ||
2119 | return null; | 2471 | return null; |
2120 | } | 2472 | } |
@@ -2142,17 +2494,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2142 | public SceneObjectPart GetChildPart(uint localID) | 2494 | public SceneObjectPart GetChildPart(uint localID) |
2143 | { | 2495 | { |
2144 | //m_log.DebugFormat("Entered looking for {0}", localID); | 2496 | //m_log.DebugFormat("Entered looking for {0}", localID); |
2145 | lock (m_parts) | 2497 | lockPartsForRead(true); |
2146 | { | 2498 | { |
2147 | foreach (SceneObjectPart part in m_parts.Values) | 2499 | foreach (SceneObjectPart part in m_parts.Values) |
2148 | { | 2500 | { |
2149 | //m_log.DebugFormat("Found {0}", part.LocalId); | 2501 | //m_log.DebugFormat("Found {0}", part.LocalId); |
2150 | if (part.LocalId == localID) | 2502 | if (part.LocalId == localID) |
2151 | { | 2503 | { |
2504 | lockPartsForRead(false); | ||
2152 | return part; | 2505 | return part; |
2153 | } | 2506 | } |
2154 | } | 2507 | } |
2155 | } | 2508 | } |
2509 | lockPartsForRead(false); | ||
2156 | 2510 | ||
2157 | return null; | 2511 | return null; |
2158 | } | 2512 | } |
@@ -2182,17 +2536,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2182 | public bool HasChildPrim(uint localID) | 2536 | public bool HasChildPrim(uint localID) |
2183 | { | 2537 | { |
2184 | //m_log.DebugFormat("Entered HasChildPrim looking for {0}", localID); | 2538 | //m_log.DebugFormat("Entered HasChildPrim looking for {0}", localID); |
2185 | lock (m_parts) | 2539 | lockPartsForRead(true); |
2186 | { | 2540 | { |
2187 | foreach (SceneObjectPart part in m_parts.Values) | 2541 | foreach (SceneObjectPart part in m_parts.Values) |
2188 | { | 2542 | { |
2189 | //m_log.DebugFormat("Found {0}", part.LocalId); | 2543 | //m_log.DebugFormat("Found {0}", part.LocalId); |
2190 | if (part.LocalId == localID) | 2544 | if (part.LocalId == localID) |
2191 | { | 2545 | { |
2546 | lockPartsForRead(false); | ||
2192 | return true; | 2547 | return true; |
2193 | } | 2548 | } |
2194 | } | 2549 | } |
2195 | } | 2550 | } |
2551 | lockPartsForRead(false); | ||
2196 | 2552 | ||
2197 | return false; | 2553 | return false; |
2198 | } | 2554 | } |
@@ -2242,53 +2598,57 @@ namespace OpenSim.Region.Framework.Scenes | |||
2242 | if (m_rootPart.LinkNum == 0) | 2598 | if (m_rootPart.LinkNum == 0) |
2243 | m_rootPart.LinkNum = 1; | 2599 | m_rootPart.LinkNum = 1; |
2244 | 2600 | ||
2245 | lock (m_parts) | 2601 | lockPartsForWrite(true); |
2246 | { | 2602 | |
2247 | m_parts.Add(linkPart.UUID, linkPart); | 2603 | m_parts.Add(linkPart.UUID, linkPart); |
2604 | |||
2605 | lockPartsForWrite(false); | ||
2248 | 2606 | ||
2249 | // Insert in terms of link numbers, the new links | 2607 | // Insert in terms of link numbers, the new links |
2250 | // before the current ones (with the exception of | 2608 | // before the current ones (with the exception of |
2251 | // the root prim. Shuffle the old ones up | 2609 | // the root prim. Shuffle the old ones up |
2252 | foreach (KeyValuePair<UUID, SceneObjectPart> kvp in m_parts) | 2610 | lockPartsForRead(true); |
2611 | foreach (KeyValuePair<UUID, SceneObjectPart> kvp in m_parts) | ||
2612 | { | ||
2613 | if (kvp.Value.LinkNum != 1) | ||
2253 | { | 2614 | { |
2254 | if (kvp.Value.LinkNum != 1) | 2615 | // Don't update root prim link number |
2255 | { | 2616 | kvp.Value.LinkNum += objectGroup.PrimCount; |
2256 | // Don't update root prim link number | ||
2257 | kvp.Value.LinkNum += objectGroup.PrimCount; | ||
2258 | } | ||
2259 | } | 2617 | } |
2618 | } | ||
2619 | lockPartsForRead(false); | ||
2260 | 2620 | ||
2261 | linkPart.LinkNum = 2; | 2621 | linkPart.LinkNum = 2; |
2262 | 2622 | ||
2263 | linkPart.SetParent(this); | 2623 | linkPart.SetParent(this); |
2264 | linkPart.CreateSelected = true; | 2624 | linkPart.CreateSelected = true; |
2265 | 2625 | ||
2266 | //if (linkPart.PhysActor != null) | 2626 | //if (linkPart.PhysActor != null) |
2267 | //{ | 2627 | //{ |
2268 | // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); | 2628 | // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); |
2269 | 2629 | ||
2270 | //linkPart.PhysActor = null; | 2630 | //linkPart.PhysActor = null; |
2271 | //} | 2631 | //} |
2272 | 2632 | ||
2273 | //TODO: rest of parts | 2633 | //TODO: rest of parts |
2274 | int linkNum = 3; | 2634 | int linkNum = 3; |
2275 | foreach (SceneObjectPart part in objectGroup.Children.Values) | 2635 | foreach (SceneObjectPart part in objectGroup.Children.Values) |
2636 | { | ||
2637 | if (part.UUID != objectGroup.m_rootPart.UUID) | ||
2276 | { | 2638 | { |
2277 | if (part.UUID != objectGroup.m_rootPart.UUID) | 2639 | LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); |
2278 | { | ||
2279 | LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); | ||
2280 | } | ||
2281 | part.ClearUndoState(); | ||
2282 | } | 2640 | } |
2641 | part.ClearUndoState(); | ||
2283 | } | 2642 | } |
2284 | 2643 | ||
2285 | m_scene.UnlinkSceneObject(objectGroup.UUID, true); | 2644 | m_scene.UnlinkSceneObject(objectGroup.UUID, true); |
2286 | objectGroup.m_isDeleted = true; | 2645 | objectGroup.m_isDeleted = true; |
2646 | |||
2647 | objectGroup.lockPartsForWrite(true); | ||
2287 | 2648 | ||
2288 | lock (objectGroup.m_parts) | 2649 | objectGroup.m_parts.Clear(); |
2289 | { | 2650 | |
2290 | objectGroup.m_parts.Clear(); | 2651 | objectGroup.lockPartsForWrite(false); |
2291 | } | ||
2292 | 2652 | ||
2293 | // Can't do this yet since backup still makes use of the root part without any synchronization | 2653 | // Can't do this yet since backup still makes use of the root part without any synchronization |
2294 | // objectGroup.m_rootPart = null; | 2654 | // objectGroup.m_rootPart = null; |
@@ -2358,11 +2718,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2358 | Quaternion worldRot = linkPart.GetWorldRotation(); | 2718 | Quaternion worldRot = linkPart.GetWorldRotation(); |
2359 | 2719 | ||
2360 | // Remove the part from this object | 2720 | // Remove the part from this object |
2361 | lock (m_parts) | 2721 | lockPartsForWrite(true); |
2362 | { | 2722 | { |
2363 | m_parts.Remove(linkPart.UUID); | 2723 | m_parts.Remove(linkPart.UUID); |
2364 | } | 2724 | } |
2365 | 2725 | lockPartsForWrite(false); | |
2726 | lockPartsForRead(true); | ||
2366 | if (m_parts.Count == 1 && RootPart != null) //Single prim is left | 2727 | if (m_parts.Count == 1 && RootPart != null) //Single prim is left |
2367 | RootPart.LinkNum = 0; | 2728 | RootPart.LinkNum = 0; |
2368 | else | 2729 | else |
@@ -2373,6 +2734,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2373 | p.LinkNum--; | 2734 | p.LinkNum--; |
2374 | } | 2735 | } |
2375 | } | 2736 | } |
2737 | lockPartsForRead(false); | ||
2376 | 2738 | ||
2377 | linkPart.ParentID = 0; | 2739 | linkPart.ParentID = 0; |
2378 | linkPart.LinkNum = 0; | 2740 | linkPart.LinkNum = 0; |
@@ -2416,6 +2778,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2416 | /// <param name="objectGroup"></param> | 2778 | /// <param name="objectGroup"></param> |
2417 | public virtual void DetachFromBackup() | 2779 | public virtual void DetachFromBackup() |
2418 | { | 2780 | { |
2781 | m_scene.SceneGraph.FireDetachFromBackup(this); | ||
2782 | |||
2419 | if (m_isBackedUp) | 2783 | if (m_isBackedUp) |
2420 | m_scene.EventManager.OnBackup -= ProcessBackup; | 2784 | m_scene.EventManager.OnBackup -= ProcessBackup; |
2421 | 2785 | ||
@@ -2694,9 +3058,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2694 | 3058 | ||
2695 | if (selectionPart != null) | 3059 | if (selectionPart != null) |
2696 | { | 3060 | { |
2697 | lock (m_parts) | 3061 | lockPartsForRead(true); |
3062 | List<SceneObjectPart> parts = new List<SceneObjectPart>(m_parts.Values); | ||
3063 | lockPartsForRead(false); | ||
3064 | foreach (SceneObjectPart part in parts) | ||
2698 | { | 3065 | { |
2699 | foreach (SceneObjectPart part in m_parts.Values) | 3066 | if (part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0) |
2700 | { | 3067 | { |
2701 | if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax || | 3068 | if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax || |
2702 | part.Scale.Y > m_scene.RegionInfo.PhysPrimMax || | 3069 | part.Scale.Y > m_scene.RegionInfo.PhysPrimMax || |
@@ -2706,12 +3073,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2706 | break; | 3073 | break; |
2707 | } | 3074 | } |
2708 | } | 3075 | } |
3076 | } | ||
2709 | 3077 | ||
2710 | foreach (SceneObjectPart part in m_parts.Values) | 3078 | foreach (SceneObjectPart part in parts) |
2711 | { | 3079 | { |
2712 | part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 3080 | part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); |
2713 | } | ||
2714 | } | 3081 | } |
3082 | |||
2715 | } | 3083 | } |
2716 | } | 3084 | } |
2717 | 3085 | ||
@@ -2724,6 +3092,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2724 | } | 3092 | } |
2725 | } | 3093 | } |
2726 | 3094 | ||
3095 | |||
3096 | |||
3097 | /// <summary> | ||
3098 | /// Gets the number of parts | ||
3099 | /// </summary> | ||
3100 | /// <returns></returns> | ||
3101 | public int GetPartCount() | ||
3102 | { | ||
3103 | return Children.Count; | ||
3104 | } | ||
3105 | |||
2727 | /// <summary> | 3106 | /// <summary> |
2728 | /// Get the parts of this scene object | 3107 | /// Get the parts of this scene object |
2729 | /// </summary> | 3108 | /// </summary> |
@@ -2797,11 +3176,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2797 | scale.Y = m_scene.m_maxNonphys; | 3176 | scale.Y = m_scene.m_maxNonphys; |
2798 | if (scale.Z > m_scene.m_maxNonphys) | 3177 | if (scale.Z > m_scene.m_maxNonphys) |
2799 | scale.Z = m_scene.m_maxNonphys; | 3178 | scale.Z = m_scene.m_maxNonphys; |
2800 | |||
2801 | SceneObjectPart part = GetChildPart(localID); | 3179 | SceneObjectPart part = GetChildPart(localID); |
2802 | if (part != null) | 3180 | if (part != null) |
2803 | { | 3181 | { |
2804 | part.Resize(scale); | ||
2805 | if (part.PhysActor != null) | 3182 | if (part.PhysActor != null) |
2806 | { | 3183 | { |
2807 | if (part.PhysActor.IsPhysical) | 3184 | if (part.PhysActor.IsPhysical) |
@@ -2816,7 +3193,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2816 | part.PhysActor.Size = scale; | 3193 | part.PhysActor.Size = scale; |
2817 | m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); | 3194 | m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); |
2818 | } | 3195 | } |
2819 | //if (part.UUID != m_rootPart.UUID) | 3196 | part.Resize(scale); |
2820 | 3197 | ||
2821 | HasGroupChanged = true; | 3198 | HasGroupChanged = true; |
2822 | ScheduleGroupForFullUpdate(); | 3199 | ScheduleGroupForFullUpdate(); |
@@ -2838,7 +3215,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2838 | SceneObjectPart part = GetChildPart(localID); | 3215 | SceneObjectPart part = GetChildPart(localID); |
2839 | if (part != null) | 3216 | if (part != null) |
2840 | { | 3217 | { |
2841 | part.IgnoreUndoUpdate = true; | ||
2842 | if (scale.X > m_scene.m_maxNonphys) | 3218 | if (scale.X > m_scene.m_maxNonphys) |
2843 | scale.X = m_scene.m_maxNonphys; | 3219 | scale.X = m_scene.m_maxNonphys; |
2844 | if (scale.Y > m_scene.m_maxNonphys) | 3220 | if (scale.Y > m_scene.m_maxNonphys) |
@@ -2858,94 +3234,100 @@ namespace OpenSim.Region.Framework.Scenes | |||
2858 | float y = (scale.Y / part.Scale.Y); | 3234 | float y = (scale.Y / part.Scale.Y); |
2859 | float z = (scale.Z / part.Scale.Z); | 3235 | float z = (scale.Z / part.Scale.Z); |
2860 | 3236 | ||
2861 | lock (m_parts) | 3237 | lockPartsForRead(true); |
3238 | if (x > 1.0f || y > 1.0f || z > 1.0f) | ||
2862 | { | 3239 | { |
2863 | if (x > 1.0f || y > 1.0f || z > 1.0f) | 3240 | foreach (SceneObjectPart obPart in m_parts.Values) |
2864 | { | 3241 | { |
2865 | foreach (SceneObjectPart obPart in m_parts.Values) | 3242 | if (obPart.UUID != m_rootPart.UUID) |
2866 | { | 3243 | { |
2867 | if (obPart.UUID != m_rootPart.UUID) | 3244 | Vector3 oldSize = new Vector3(obPart.Scale); |
2868 | { | 3245 | obPart.IgnoreUndoUpdate = true; |
2869 | obPart.IgnoreUndoUpdate = true; | ||
2870 | Vector3 oldSize = new Vector3(obPart.Scale); | ||
2871 | 3246 | ||
2872 | float f = 1.0f; | 3247 | float f = 1.0f; |
2873 | float a = 1.0f; | 3248 | float a = 1.0f; |
2874 | 3249 | ||
2875 | if (part.PhysActor != null && part.PhysActor.IsPhysical) | 3250 | if (part.PhysActor != null && part.PhysActor.IsPhysical) |
3251 | { | ||
3252 | if (oldSize.X*x > m_scene.m_maxPhys) | ||
2876 | { | 3253 | { |
2877 | if (oldSize.X*x > m_scene.m_maxPhys) | 3254 | f = m_scene.m_maxPhys / oldSize.X; |
2878 | { | 3255 | a = f / x; |
2879 | f = m_scene.m_maxPhys / oldSize.X; | 3256 | x *= a; |
2880 | a = f / x; | 3257 | y *= a; |
2881 | x *= a; | 3258 | z *= a; |
2882 | y *= a; | ||
2883 | z *= a; | ||
2884 | } | ||
2885 | if (oldSize.Y*y > m_scene.m_maxPhys) | ||
2886 | { | ||
2887 | f = m_scene.m_maxPhys / oldSize.Y; | ||
2888 | a = f / y; | ||
2889 | x *= a; | ||
2890 | y *= a; | ||
2891 | z *= a; | ||
2892 | } | ||
2893 | if (oldSize.Z*z > m_scene.m_maxPhys) | ||
2894 | { | ||
2895 | f = m_scene.m_maxPhys / oldSize.Z; | ||
2896 | a = f / z; | ||
2897 | x *= a; | ||
2898 | y *= a; | ||
2899 | z *= a; | ||
2900 | } | ||
2901 | } | 3259 | } |
2902 | else | 3260 | if (oldSize.Y*y > m_scene.m_maxPhys) |
3261 | { | ||
3262 | f = m_scene.m_maxPhys / oldSize.Y; | ||
3263 | a = f / y; | ||
3264 | x *= a; | ||
3265 | y *= a; | ||
3266 | z *= a; | ||
3267 | } | ||
3268 | if (oldSize.Z*z > m_scene.m_maxPhys) | ||
3269 | { | ||
3270 | f = m_scene.m_maxPhys / oldSize.Z; | ||
3271 | a = f / z; | ||
3272 | x *= a; | ||
3273 | y *= a; | ||
3274 | z *= a; | ||
3275 | } | ||
3276 | } | ||
3277 | else | ||
3278 | { | ||
3279 | if (oldSize.X*x > m_scene.m_maxNonphys) | ||
3280 | { | ||
3281 | f = m_scene.m_maxNonphys / oldSize.X; | ||
3282 | a = f / x; | ||
3283 | x *= a; | ||
3284 | y *= a; | ||
3285 | z *= a; | ||
3286 | } | ||
3287 | if (oldSize.Y*y > m_scene.m_maxNonphys) | ||
2903 | { | 3288 | { |
2904 | if (oldSize.X*x > m_scene.m_maxNonphys) | 3289 | f = m_scene.m_maxNonphys / oldSize.Y; |
2905 | { | 3290 | a = f / y; |
2906 | f = m_scene.m_maxNonphys / oldSize.X; | 3291 | x *= a; |
2907 | a = f / x; | 3292 | y *= a; |
2908 | x *= a; | 3293 | z *= a; |
2909 | y *= a; | ||
2910 | z *= a; | ||
2911 | } | ||
2912 | if (oldSize.Y*y > m_scene.m_maxNonphys) | ||
2913 | { | ||
2914 | f = m_scene.m_maxNonphys / oldSize.Y; | ||
2915 | a = f / y; | ||
2916 | x *= a; | ||
2917 | y *= a; | ||
2918 | z *= a; | ||
2919 | } | ||
2920 | if (oldSize.Z*z > m_scene.m_maxNonphys) | ||
2921 | { | ||
2922 | f = m_scene.m_maxNonphys / oldSize.Z; | ||
2923 | a = f / z; | ||
2924 | x *= a; | ||
2925 | y *= a; | ||
2926 | z *= a; | ||
2927 | } | ||
2928 | } | 3294 | } |
2929 | obPart.IgnoreUndoUpdate = false; | 3295 | if (oldSize.Z*z > m_scene.m_maxNonphys) |
2930 | obPart.StoreUndoState(); | 3296 | { |
3297 | f = m_scene.m_maxNonphys / oldSize.Z; | ||
3298 | a = f / z; | ||
3299 | x *= a; | ||
3300 | y *= a; | ||
3301 | z *= a; | ||
3302 | } | ||
3303 | |||
2931 | } | 3304 | } |
2932 | } | 3305 | } |
2933 | } | 3306 | } |
2934 | } | 3307 | } |
3308 | lockPartsForRead(false); | ||
2935 | 3309 | ||
2936 | Vector3 prevScale = part.Scale; | 3310 | Vector3 prevScale = part.Scale; |
2937 | prevScale.X *= x; | 3311 | prevScale.X *= x; |
2938 | prevScale.Y *= y; | 3312 | prevScale.Y *= y; |
2939 | prevScale.Z *= z; | 3313 | prevScale.Z *= z;; |
3314 | |||
3315 | part.IgnoreUndoUpdate = false; | ||
3316 | part.StoreUndoState(UndoType.STATE_GROUP_SCALE); | ||
3317 | part.IgnoreUndoUpdate = true; | ||
2940 | part.Resize(prevScale); | 3318 | part.Resize(prevScale); |
3319 | part.IgnoreUndoUpdate = false; | ||
2941 | 3320 | ||
2942 | lock (m_parts) | 3321 | lockPartsForRead(true); |
2943 | { | 3322 | { |
2944 | foreach (SceneObjectPart obPart in m_parts.Values) | 3323 | foreach (SceneObjectPart obPart in m_parts.Values) |
2945 | { | 3324 | { |
2946 | obPart.IgnoreUndoUpdate = true; | ||
2947 | if (obPart.UUID != m_rootPart.UUID) | 3325 | if (obPart.UUID != m_rootPart.UUID) |
2948 | { | 3326 | { |
3327 | obPart.IgnoreUndoUpdate = false; | ||
3328 | obPart.StoreUndoState(UndoType.STATE_GROUP_SCALE); | ||
3329 | obPart.IgnoreUndoUpdate = true; | ||
3330 | |||
2949 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); | 3331 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); |
2950 | currentpos.X *= x; | 3332 | currentpos.X *= x; |
2951 | currentpos.Y *= y; | 3333 | currentpos.Y *= y; |
@@ -2958,9 +3340,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2958 | obPart.UpdateOffSet(currentpos); | 3340 | obPart.UpdateOffSet(currentpos); |
2959 | } | 3341 | } |
2960 | obPart.IgnoreUndoUpdate = false; | 3342 | obPart.IgnoreUndoUpdate = false; |
2961 | obPart.StoreUndoState(); | ||
2962 | } | 3343 | } |
2963 | } | 3344 | } |
3345 | lockPartsForRead(false); | ||
2964 | 3346 | ||
2965 | if (part.PhysActor != null) | 3347 | if (part.PhysActor != null) |
2966 | { | 3348 | { |
@@ -2969,7 +3351,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2969 | } | 3351 | } |
2970 | 3352 | ||
2971 | part.IgnoreUndoUpdate = false; | 3353 | part.IgnoreUndoUpdate = false; |
2972 | part.StoreUndoState(); | ||
2973 | HasGroupChanged = true; | 3354 | HasGroupChanged = true; |
2974 | ScheduleGroupForTerseUpdate(); | 3355 | ScheduleGroupForTerseUpdate(); |
2975 | } | 3356 | } |
@@ -2985,14 +3366,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2985 | /// <param name="pos"></param> | 3366 | /// <param name="pos"></param> |
2986 | public void UpdateGroupPosition(Vector3 pos) | 3367 | public void UpdateGroupPosition(Vector3 pos) |
2987 | { | 3368 | { |
2988 | foreach (SceneObjectPart part in Children.Values) | ||
2989 | { | ||
2990 | part.StoreUndoState(); | ||
2991 | } | ||
2992 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 3369 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
2993 | { | 3370 | { |
2994 | if (IsAttachment) | 3371 | if (IsAttachment) |
2995 | { | 3372 | { |
3373 | m_rootPart.StoreUndoState(UndoType.STATE_GROUP_POSITION); | ||
2996 | m_rootPart.AttachedPos = pos; | 3374 | m_rootPart.AttachedPos = pos; |
2997 | } | 3375 | } |
2998 | if (RootPart.GetStatusSandbox()) | 3376 | if (RootPart.GetStatusSandbox()) |
@@ -3025,7 +3403,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3025 | SceneObjectPart part = GetChildPart(localID); | 3403 | SceneObjectPart part = GetChildPart(localID); |
3026 | foreach (SceneObjectPart parts in Children.Values) | 3404 | foreach (SceneObjectPart parts in Children.Values) |
3027 | { | 3405 | { |
3028 | parts.StoreUndoState(); | 3406 | parts.StoreUndoState(UndoType.STATE_PRIM_POSITION); |
3029 | } | 3407 | } |
3030 | if (part != null) | 3408 | if (part != null) |
3031 | { | 3409 | { |
@@ -3050,7 +3428,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3050 | { | 3428 | { |
3051 | foreach (SceneObjectPart part in Children.Values) | 3429 | foreach (SceneObjectPart part in Children.Values) |
3052 | { | 3430 | { |
3053 | part.StoreUndoState(); | 3431 | part.StoreUndoState(UndoType.STATE_PRIM_POSITION); |
3054 | } | 3432 | } |
3055 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); | 3433 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); |
3056 | Vector3 oldPos = | 3434 | Vector3 oldPos = |
@@ -3063,7 +3441,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3063 | axDiff *= Quaternion.Inverse(partRotation); | 3441 | axDiff *= Quaternion.Inverse(partRotation); |
3064 | diff = axDiff; | 3442 | diff = axDiff; |
3065 | 3443 | ||
3066 | lock (m_parts) | 3444 | lockPartsForRead(true); |
3067 | { | 3445 | { |
3068 | foreach (SceneObjectPart obPart in m_parts.Values) | 3446 | foreach (SceneObjectPart obPart in m_parts.Values) |
3069 | { | 3447 | { |
@@ -3073,11 +3451,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
3073 | } | 3451 | } |
3074 | } | 3452 | } |
3075 | } | 3453 | } |
3454 | lockPartsForRead(false); | ||
3076 | 3455 | ||
3077 | AbsolutePosition = newPos; | 3456 | //We have to set undoing here because otherwise an undo state will be saved |
3457 | if (!m_rootPart.Undoing) | ||
3458 | { | ||
3459 | m_rootPart.Undoing = true; | ||
3460 | AbsolutePosition = newPos; | ||
3461 | m_rootPart.Undoing = false; | ||
3462 | } | ||
3463 | else | ||
3464 | { | ||
3465 | AbsolutePosition = newPos; | ||
3466 | } | ||
3078 | 3467 | ||
3079 | HasGroupChanged = true; | 3468 | HasGroupChanged = true; |
3080 | ScheduleGroupForTerseUpdate(); | 3469 | if (m_rootPart.Undoing) |
3470 | { | ||
3471 | ScheduleGroupForFullUpdate(); | ||
3472 | } | ||
3473 | else | ||
3474 | { | ||
3475 | ScheduleGroupForTerseUpdate(); | ||
3476 | } | ||
3081 | } | 3477 | } |
3082 | 3478 | ||
3083 | public void OffsetForNewRegion(Vector3 offset) | 3479 | public void OffsetForNewRegion(Vector3 offset) |
@@ -3097,7 +3493,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3097 | { | 3493 | { |
3098 | foreach (SceneObjectPart parts in Children.Values) | 3494 | foreach (SceneObjectPart parts in Children.Values) |
3099 | { | 3495 | { |
3100 | parts.StoreUndoState(); | 3496 | parts.StoreUndoState(UndoType.STATE_GROUP_ROTATION); |
3101 | } | 3497 | } |
3102 | m_rootPart.UpdateRotation(rot); | 3498 | m_rootPart.UpdateRotation(rot); |
3103 | 3499 | ||
@@ -3121,7 +3517,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3121 | { | 3517 | { |
3122 | foreach (SceneObjectPart parts in Children.Values) | 3518 | foreach (SceneObjectPart parts in Children.Values) |
3123 | { | 3519 | { |
3124 | parts.StoreUndoState(); | 3520 | parts.StoreUndoState(UndoType.STATE_GROUP_ROTATION); |
3125 | } | 3521 | } |
3126 | m_rootPart.UpdateRotation(rot); | 3522 | m_rootPart.UpdateRotation(rot); |
3127 | 3523 | ||
@@ -3148,7 +3544,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3148 | SceneObjectPart part = GetChildPart(localID); | 3544 | SceneObjectPart part = GetChildPart(localID); |
3149 | foreach (SceneObjectPart parts in Children.Values) | 3545 | foreach (SceneObjectPart parts in Children.Values) |
3150 | { | 3546 | { |
3151 | parts.StoreUndoState(); | 3547 | parts.StoreUndoState(UndoType.STATE_PRIM_ROTATION); |
3152 | } | 3548 | } |
3153 | if (part != null) | 3549 | if (part != null) |
3154 | { | 3550 | { |
@@ -3176,15 +3572,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3176 | if (part.UUID == m_rootPart.UUID) | 3572 | if (part.UUID == m_rootPart.UUID) |
3177 | { | 3573 | { |
3178 | UpdateRootRotation(rot); | 3574 | UpdateRootRotation(rot); |
3179 | AbsolutePosition = pos; | 3575 | if (!m_rootPart.Undoing) |
3576 | { | ||
3577 | m_rootPart.Undoing = true; | ||
3578 | AbsolutePosition = pos; | ||
3579 | m_rootPart.Undoing = false; | ||
3580 | } | ||
3581 | else | ||
3582 | { | ||
3583 | AbsolutePosition = pos; | ||
3584 | } | ||
3180 | } | 3585 | } |
3181 | else | 3586 | else |
3182 | { | 3587 | { |
3588 | part.StoreUndoState(UndoType.STATE_PRIM_ROTATION); | ||
3183 | part.IgnoreUndoUpdate = true; | 3589 | part.IgnoreUndoUpdate = true; |
3184 | part.UpdateRotation(rot); | 3590 | part.UpdateRotation(rot); |
3185 | part.OffsetPosition = pos; | 3591 | part.OffsetPosition = pos; |
3186 | part.IgnoreUndoUpdate = false; | 3592 | part.IgnoreUndoUpdate = false; |
3187 | part.StoreUndoState(); | ||
3188 | } | 3593 | } |
3189 | } | 3594 | } |
3190 | } | 3595 | } |
@@ -3198,7 +3603,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3198 | Quaternion axRot = rot; | 3603 | Quaternion axRot = rot; |
3199 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 3604 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
3200 | 3605 | ||
3201 | m_rootPart.StoreUndoState(); | 3606 | m_rootPart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); |
3607 | bool cancelUndo = false; | ||
3608 | if (!m_rootPart.Undoing) | ||
3609 | { | ||
3610 | m_rootPart.Undoing = true; | ||
3611 | cancelUndo = true; | ||
3612 | } | ||
3202 | m_rootPart.UpdateRotation(rot); | 3613 | m_rootPart.UpdateRotation(rot); |
3203 | if (m_rootPart.PhysActor != null) | 3614 | if (m_rootPart.PhysActor != null) |
3204 | { | 3615 | { |
@@ -3206,33 +3617,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
3206 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 3617 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); |
3207 | } | 3618 | } |
3208 | 3619 | ||
3209 | lock (m_parts) | 3620 | lockPartsForRead(true); |
3621 | |||
3622 | foreach (SceneObjectPart prim in m_parts.Values) | ||
3210 | { | 3623 | { |
3211 | foreach (SceneObjectPart prim in m_parts.Values) | 3624 | if (prim.UUID != m_rootPart.UUID) |
3212 | { | 3625 | { |
3213 | if (prim.UUID != m_rootPart.UUID) | 3626 | prim.IgnoreUndoUpdate = true; |
3214 | { | 3627 | Vector3 axPos = prim.OffsetPosition; |
3215 | prim.IgnoreUndoUpdate = true; | 3628 | axPos *= oldParentRot; |
3216 | Vector3 axPos = prim.OffsetPosition; | 3629 | axPos *= Quaternion.Inverse(axRot); |
3217 | axPos *= oldParentRot; | 3630 | prim.OffsetPosition = axPos; |
3218 | axPos *= Quaternion.Inverse(axRot); | 3631 | Quaternion primsRot = prim.RotationOffset; |
3219 | prim.OffsetPosition = axPos; | 3632 | Quaternion newRot = primsRot * oldParentRot; |
3220 | Quaternion primsRot = prim.RotationOffset; | 3633 | newRot *= Quaternion.Inverse(axRot); |
3221 | Quaternion newRot = primsRot * oldParentRot; | 3634 | prim.RotationOffset = newRot; |
3222 | newRot *= Quaternion.Inverse(axRot); | 3635 | prim.ScheduleTerseUpdate(); |
3223 | prim.RotationOffset = newRot; | 3636 | prim.IgnoreUndoUpdate = false; |
3224 | prim.ScheduleTerseUpdate(); | ||
3225 | } | ||
3226 | } | 3637 | } |
3227 | } | 3638 | } |
3228 | foreach (SceneObjectPart childpart in Children.Values) | 3639 | if (cancelUndo == true) |
3229 | { | 3640 | { |
3230 | if (childpart != m_rootPart) | 3641 | m_rootPart.Undoing = false; |
3231 | { | ||
3232 | childpart.IgnoreUndoUpdate = false; | ||
3233 | childpart.StoreUndoState(); | ||
3234 | } | ||
3235 | } | 3642 | } |
3643 | lockPartsForRead(false); | ||
3644 | |||
3236 | m_rootPart.ScheduleTerseUpdate(); | 3645 | m_rootPart.ScheduleTerseUpdate(); |
3237 | } | 3646 | } |
3238 | 3647 | ||
@@ -3354,7 +3763,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3354 | if (atTargets.Count > 0) | 3763 | if (atTargets.Count > 0) |
3355 | { | 3764 | { |
3356 | uint[] localids = new uint[0]; | 3765 | uint[] localids = new uint[0]; |
3357 | lock (m_parts) | 3766 | lockPartsForRead(true); |
3358 | { | 3767 | { |
3359 | localids = new uint[m_parts.Count]; | 3768 | localids = new uint[m_parts.Count]; |
3360 | int cntr = 0; | 3769 | int cntr = 0; |
@@ -3364,6 +3773,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3364 | cntr++; | 3773 | cntr++; |
3365 | } | 3774 | } |
3366 | } | 3775 | } |
3776 | lockPartsForRead(false); | ||
3367 | 3777 | ||
3368 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3778 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3369 | { | 3779 | { |
@@ -3382,7 +3792,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3382 | { | 3792 | { |
3383 | //trigger not_at_target | 3793 | //trigger not_at_target |
3384 | uint[] localids = new uint[0]; | 3794 | uint[] localids = new uint[0]; |
3385 | lock (m_parts) | 3795 | lockPartsForRead(true); |
3386 | { | 3796 | { |
3387 | localids = new uint[m_parts.Count]; | 3797 | localids = new uint[m_parts.Count]; |
3388 | int cntr = 0; | 3798 | int cntr = 0; |
@@ -3392,7 +3802,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3392 | cntr++; | 3802 | cntr++; |
3393 | } | 3803 | } |
3394 | } | 3804 | } |
3395 | 3805 | lockPartsForRead(false); | |
3806 | |||
3396 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3807 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3397 | { | 3808 | { |
3398 | m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]); | 3809 | m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]); |
@@ -3433,7 +3844,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3433 | if (atRotTargets.Count > 0) | 3844 | if (atRotTargets.Count > 0) |
3434 | { | 3845 | { |
3435 | uint[] localids = new uint[0]; | 3846 | uint[] localids = new uint[0]; |
3436 | lock (m_parts) | 3847 | lockPartsForRead(true); |
3848 | try | ||
3437 | { | 3849 | { |
3438 | localids = new uint[m_parts.Count]; | 3850 | localids = new uint[m_parts.Count]; |
3439 | int cntr = 0; | 3851 | int cntr = 0; |
@@ -3443,6 +3855,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3443 | cntr++; | 3855 | cntr++; |
3444 | } | 3856 | } |
3445 | } | 3857 | } |
3858 | finally | ||
3859 | { | ||
3860 | lockPartsForRead(false); | ||
3861 | } | ||
3446 | 3862 | ||
3447 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3863 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3448 | { | 3864 | { |
@@ -3461,7 +3877,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3461 | { | 3877 | { |
3462 | //trigger not_at_target | 3878 | //trigger not_at_target |
3463 | uint[] localids = new uint[0]; | 3879 | uint[] localids = new uint[0]; |
3464 | lock (m_parts) | 3880 | lockPartsForRead(true); |
3881 | try | ||
3465 | { | 3882 | { |
3466 | localids = new uint[m_parts.Count]; | 3883 | localids = new uint[m_parts.Count]; |
3467 | int cntr = 0; | 3884 | int cntr = 0; |
@@ -3471,6 +3888,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3471 | cntr++; | 3888 | cntr++; |
3472 | } | 3889 | } |
3473 | } | 3890 | } |
3891 | finally | ||
3892 | { | ||
3893 | lockPartsForRead(false); | ||
3894 | } | ||
3474 | 3895 | ||
3475 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3896 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3476 | { | 3897 | { |
@@ -3484,19 +3905,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3484 | public float GetMass() | 3905 | public float GetMass() |
3485 | { | 3906 | { |
3486 | float retmass = 0f; | 3907 | float retmass = 0f; |
3487 | lock (m_parts) | 3908 | lockPartsForRead(true); |
3488 | { | 3909 | { |
3489 | foreach (SceneObjectPart part in m_parts.Values) | 3910 | foreach (SceneObjectPart part in m_parts.Values) |
3490 | { | 3911 | { |
3491 | retmass += part.GetMass(); | 3912 | retmass += part.GetMass(); |
3492 | } | 3913 | } |
3493 | } | 3914 | } |
3915 | lockPartsForRead(false); | ||
3494 | return retmass; | 3916 | return retmass; |
3495 | } | 3917 | } |
3496 | 3918 | ||
3497 | public void CheckSculptAndLoad() | 3919 | public void CheckSculptAndLoad() |
3498 | { | 3920 | { |
3499 | lock (m_parts) | 3921 | lockPartsForRead(true); |
3500 | { | 3922 | { |
3501 | if (!IsDeleted) | 3923 | if (!IsDeleted) |
3502 | { | 3924 | { |
@@ -3521,6 +3943,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3521 | } | 3943 | } |
3522 | } | 3944 | } |
3523 | } | 3945 | } |
3946 | lockPartsForRead(false); | ||
3524 | } | 3947 | } |
3525 | 3948 | ||
3526 | protected void AssetReceived(string id, Object sender, AssetBase asset) | 3949 | protected void AssetReceived(string id, Object sender, AssetBase asset) |
@@ -3541,7 +3964,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3541 | /// <param name="client"></param> | 3964 | /// <param name="client"></param> |
3542 | public void SetGroup(UUID GroupID, IClientAPI client) | 3965 | public void SetGroup(UUID GroupID, IClientAPI client) |
3543 | { | 3966 | { |
3544 | lock (m_parts) | 3967 | lockPartsForRead(true); |
3545 | { | 3968 | { |
3546 | foreach (SceneObjectPart part in m_parts.Values) | 3969 | foreach (SceneObjectPart part in m_parts.Values) |
3547 | { | 3970 | { |
@@ -3551,6 +3974,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3551 | 3974 | ||
3552 | HasGroupChanged = true; | 3975 | HasGroupChanged = true; |
3553 | } | 3976 | } |
3977 | lockPartsForRead(false); | ||
3554 | 3978 | ||
3555 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | 3979 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
3556 | // for the same object with very different properties. The caller must schedule the update. | 3980 | // for the same object with very different properties. The caller must schedule the update. |
@@ -3572,11 +3996,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3572 | 3996 | ||
3573 | public void SetAttachmentPoint(byte point) | 3997 | public void SetAttachmentPoint(byte point) |
3574 | { | 3998 | { |
3575 | lock (m_parts) | 3999 | lockPartsForRead(true); |
3576 | { | 4000 | { |
3577 | foreach (SceneObjectPart part in m_parts.Values) | 4001 | foreach (SceneObjectPart part in m_parts.Values) |
3578 | part.SetAttachmentPoint(point); | 4002 | part.SetAttachmentPoint(point); |
3579 | } | 4003 | } |
4004 | lockPartsForRead(false); | ||
3580 | } | 4005 | } |
3581 | 4006 | ||
3582 | #region ISceneObject | 4007 | #region ISceneObject |
@@ -3610,6 +4035,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3610 | SetFromItemID(uuid); | 4035 | SetFromItemID(uuid); |
3611 | } | 4036 | } |
3612 | 4037 | ||
4038 | public void ResetOwnerChangeFlag() | ||
4039 | { | ||
4040 | ForEachPart(delegate(SceneObjectPart part) | ||
4041 | { | ||
4042 | part.ResetOwnerChangeFlag(); | ||
4043 | }); | ||
4044 | } | ||
4045 | |||
3613 | #endregion | 4046 | #endregion |
3614 | } | 4047 | } |
3615 | } | 4048 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2ad4223..9e52b00 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -60,7 +60,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
60 | TELEPORT = 512, | 60 | TELEPORT = 512, |
61 | REGION_RESTART = 1024, | 61 | REGION_RESTART = 1024, |
62 | MEDIA = 2048, | 62 | MEDIA = 2048, |
63 | ANIMATION = 16384 | 63 | ANIMATION = 16384, |
64 | POSITION = 32768 | ||
64 | } | 65 | } |
65 | 66 | ||
66 | // I don't really know where to put this except here. | 67 | // I don't really know where to put this except here. |
@@ -149,8 +150,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
149 | 150 | ||
150 | // TODO: This needs to be persisted in next XML version update! | 151 | // TODO: This needs to be persisted in next XML version update! |
151 | [XmlIgnore] | 152 | [XmlIgnore] |
152 | public readonly int[] PayPrice = {-2,-2,-2,-2,-2}; | 153 | public int[] PayPrice = {-2,-2,-2,-2,-2}; |
153 | 154 | ||
154 | [XmlIgnore] | 155 | [XmlIgnore] |
155 | public PhysicsActor PhysActor | 156 | public PhysicsActor PhysActor |
156 | { | 157 | { |
@@ -193,6 +194,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
193 | [XmlIgnore] | 194 | [XmlIgnore] |
194 | public UUID FromFolderID; | 195 | public UUID FromFolderID; |
195 | 196 | ||
197 | // The following two are to hold the attachment data | ||
198 | // while an object is inworld | ||
199 | [XmlIgnore] | ||
200 | public byte AttachPoint = 0; | ||
201 | |||
202 | [XmlIgnore] | ||
203 | public Vector3 AttachOffset = Vector3.Zero; | ||
204 | |||
196 | [XmlIgnore] | 205 | [XmlIgnore] |
197 | public int STATUS_ROTATE_X; | 206 | public int STATUS_ROTATE_X; |
198 | 207 | ||
@@ -288,6 +297,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
288 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; | 297 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; |
289 | private Vector3 m_sitTargetPosition; | 298 | private Vector3 m_sitTargetPosition; |
290 | private string m_sitAnimation = "SIT"; | 299 | private string m_sitAnimation = "SIT"; |
300 | private bool m_occupied; // KF if any av is sitting on this prim | ||
291 | private string m_text = String.Empty; | 301 | private string m_text = String.Empty; |
292 | private string m_touchName = String.Empty; | 302 | private string m_touchName = String.Empty; |
293 | private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5); | 303 | private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5); |
@@ -377,7 +387,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
377 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, | 387 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, |
378 | Quaternion rotationOffset, Vector3 offsetPosition) | 388 | Quaternion rotationOffset, Vector3 offsetPosition) |
379 | { | 389 | { |
380 | m_name = "Primitive"; | 390 | m_name = "Object"; |
381 | 391 | ||
382 | Rezzed = DateTime.UtcNow; | 392 | Rezzed = DateTime.UtcNow; |
383 | _creationDate = (int)Utils.DateTimeToUnixTime(Rezzed); | 393 | _creationDate = (int)Utils.DateTimeToUnixTime(Rezzed); |
@@ -473,12 +483,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
473 | } | 483 | } |
474 | 484 | ||
475 | /// <value> | 485 | /// <value> |
476 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 486 | /// Get the inventory list |
477 | /// </value> | 487 | /// </value> |
478 | public TaskInventoryDictionary TaskInventory | 488 | public TaskInventoryDictionary TaskInventory |
479 | { | 489 | { |
480 | get { return m_inventory.Items; } | 490 | get { |
481 | set { m_inventory.Items = value; } | 491 | return m_inventory.Items; |
492 | } | ||
493 | set { | ||
494 | m_inventory.Items = value; | ||
495 | } | ||
482 | } | 496 | } |
483 | 497 | ||
484 | /// <summary> | 498 | /// <summary> |
@@ -611,14 +625,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
611 | set { m_LoopSoundSlavePrims = value; } | 625 | set { m_LoopSoundSlavePrims = value; } |
612 | } | 626 | } |
613 | 627 | ||
614 | [XmlIgnore] | ||
615 | public Byte[] TextureAnimation | 628 | public Byte[] TextureAnimation |
616 | { | 629 | { |
617 | get { return m_TextureAnimation; } | 630 | get { return m_TextureAnimation; } |
618 | set { m_TextureAnimation = value; } | 631 | set { m_TextureAnimation = value; } |
619 | } | 632 | } |
620 | 633 | ||
621 | [XmlIgnore] | ||
622 | public Byte[] ParticleSystem | 634 | public Byte[] ParticleSystem |
623 | { | 635 | { |
624 | get { return m_particleSystem; } | 636 | get { return m_particleSystem; } |
@@ -672,7 +684,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
672 | set | 684 | set |
673 | { | 685 | { |
674 | m_groupPosition = value; | 686 | m_groupPosition = value; |
675 | |||
676 | PhysicsActor actor = PhysActor; | 687 | PhysicsActor actor = PhysActor; |
677 | if (actor != null) | 688 | if (actor != null) |
678 | { | 689 | { |
@@ -692,25 +703,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
692 | 703 | ||
693 | // Tell the physics engines that this prim changed. | 704 | // Tell the physics engines that this prim changed. |
694 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 705 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
706 | |||
695 | } | 707 | } |
696 | catch (Exception e) | 708 | catch (Exception e) |
697 | { | 709 | { |
698 | m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); | 710 | m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); |
699 | } | 711 | } |
700 | } | 712 | } |
701 | |||
702 | // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too | ||
703 | if (m_sitTargetAvatar != UUID.Zero) | ||
704 | { | ||
705 | if (m_parentGroup != null) // TODO can there be a SOP without a SOG? | ||
706 | { | ||
707 | ScenePresence avatar; | ||
708 | if (m_parentGroup.Scene.TryGetScenePresence(m_sitTargetAvatar, out avatar)) | ||
709 | { | ||
710 | avatar.ParentPosition = GetWorldPosition(); | ||
711 | } | ||
712 | } | ||
713 | } | ||
714 | } | 713 | } |
715 | } | 714 | } |
716 | 715 | ||
@@ -719,7 +718,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
719 | get { return m_offsetPosition; } | 718 | get { return m_offsetPosition; } |
720 | set | 719 | set |
721 | { | 720 | { |
722 | StoreUndoState(); | 721 | Vector3 oldpos = m_offsetPosition; |
722 | StoreUndoState(UndoType.STATE_PRIM_POSITION); | ||
723 | m_offsetPosition = value; | 723 | m_offsetPosition = value; |
724 | 724 | ||
725 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 725 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
@@ -733,7 +733,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
733 | // Tell the physics engines that this prim changed. | 733 | // Tell the physics engines that this prim changed. |
734 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 734 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
735 | } | 735 | } |
736 | |||
737 | if (!m_parentGroup.m_dupeInProgress) | ||
738 | { | ||
739 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); | ||
740 | foreach (ScenePresence av in avs) | ||
741 | { | ||
742 | if (av.LinkedPrim == m_uuid) | ||
743 | { | ||
744 | Vector3 offset = (m_offsetPosition - oldpos); | ||
745 | av.OffsetPosition += offset; | ||
746 | av.SendFullUpdateToAllClients(); | ||
747 | } | ||
748 | } | ||
749 | } | ||
736 | } | 750 | } |
751 | TriggerScriptChangedEvent(Changed.POSITION); | ||
737 | } | 752 | } |
738 | } | 753 | } |
739 | 754 | ||
@@ -775,7 +790,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
775 | 790 | ||
776 | set | 791 | set |
777 | { | 792 | { |
778 | StoreUndoState(); | 793 | StoreUndoState(UndoType.STATE_PRIM_ROTATION); |
779 | m_rotationOffset = value; | 794 | m_rotationOffset = value; |
780 | 795 | ||
781 | PhysicsActor actor = PhysActor; | 796 | PhysicsActor actor = PhysActor; |
@@ -859,7 +874,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
859 | /// <summary></summary> | 874 | /// <summary></summary> |
860 | public Vector3 Acceleration | 875 | public Vector3 Acceleration |
861 | { | 876 | { |
862 | get { return m_acceleration; } | 877 | get |
878 | { | ||
879 | PhysicsActor actor = PhysActor; | ||
880 | if (actor != null) | ||
881 | { | ||
882 | m_acceleration = actor.Acceleration; | ||
883 | } | ||
884 | return m_acceleration; | ||
885 | } | ||
886 | |||
863 | set { m_acceleration = value; } | 887 | set { m_acceleration = value; } |
864 | } | 888 | } |
865 | 889 | ||
@@ -964,7 +988,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
964 | get { return m_shape.Scale; } | 988 | get { return m_shape.Scale; } |
965 | set | 989 | set |
966 | { | 990 | { |
967 | StoreUndoState(); | 991 | StoreUndoState(UndoType.STATE_PRIM_SCALE); |
968 | if (m_shape != null) | 992 | if (m_shape != null) |
969 | { | 993 | { |
970 | m_shape.Scale = value; | 994 | m_shape.Scale = value; |
@@ -1034,7 +1058,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1034 | if (IsAttachment) | 1058 | if (IsAttachment) |
1035 | return GroupPosition; | 1059 | return GroupPosition; |
1036 | 1060 | ||
1037 | return m_offsetPosition + m_groupPosition; } | 1061 | // return m_offsetPosition + m_groupPosition; } |
1062 | return m_groupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset) ; } //KF: Rotation was ignored! | ||
1038 | } | 1063 | } |
1039 | 1064 | ||
1040 | public SceneObjectGroup ParentGroup | 1065 | public SceneObjectGroup ParentGroup |
@@ -1193,6 +1218,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1193 | _flags = value; | 1218 | _flags = value; |
1194 | } | 1219 | } |
1195 | } | 1220 | } |
1221 | |||
1222 | [XmlIgnore] | ||
1223 | public bool IsOccupied // KF If an av is sittingon this prim | ||
1224 | { | ||
1225 | get { return m_occupied; } | ||
1226 | set { m_occupied = value; } | ||
1227 | } | ||
1196 | 1228 | ||
1197 | [XmlIgnore] | 1229 | [XmlIgnore] |
1198 | public UUID SitTargetAvatar | 1230 | public UUID SitTargetAvatar |
@@ -1268,14 +1300,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1268 | } | 1300 | } |
1269 | } | 1301 | } |
1270 | 1302 | ||
1271 | /// <summary> | ||
1272 | /// Clear all pending updates of parts to clients | ||
1273 | /// </summary> | ||
1274 | private void ClearUpdateSchedule() | ||
1275 | { | ||
1276 | m_updateFlag = 0; | ||
1277 | } | ||
1278 | |||
1279 | private void SendObjectPropertiesToClient(UUID AgentID) | 1303 | private void SendObjectPropertiesToClient(UUID AgentID) |
1280 | { | 1304 | { |
1281 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 1305 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) |
@@ -1526,14 +1550,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1526 | // or flexible | 1550 | // or flexible |
1527 | if (!isPhantom && !IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible)) | 1551 | if (!isPhantom && !IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible)) |
1528 | { | 1552 | { |
1529 | PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( | 1553 | try |
1530 | Name, | 1554 | { |
1531 | Shape, | 1555 | PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( |
1532 | AbsolutePosition, | 1556 | Name, |
1533 | Scale, | 1557 | Shape, |
1534 | RotationOffset, | 1558 | AbsolutePosition, |
1535 | RigidBody); | 1559 | Scale, |
1536 | 1560 | RotationOffset, | |
1561 | RigidBody); | ||
1562 | } | ||
1563 | catch | ||
1564 | { | ||
1565 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); | ||
1566 | PhysActor = null; | ||
1567 | } | ||
1537 | // Basic Physics returns null.. joy joy joy. | 1568 | // Basic Physics returns null.. joy joy joy. |
1538 | if (PhysActor != null) | 1569 | if (PhysActor != null) |
1539 | { | 1570 | { |
@@ -1561,7 +1592,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1561 | { | 1592 | { |
1562 | m_redo.Clear(); | 1593 | m_redo.Clear(); |
1563 | } | 1594 | } |
1564 | StoreUndoState(); | 1595 | StoreUndoState(UndoType.STATE_ALL); |
1565 | } | 1596 | } |
1566 | 1597 | ||
1567 | public byte ConvertScriptUintToByte(uint indata) | 1598 | public byte ConvertScriptUintToByte(uint indata) |
@@ -1673,7 +1704,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1673 | PrimitiveBaseShape shape = PrimitiveBaseShape.Create(); | 1704 | PrimitiveBaseShape shape = PrimitiveBaseShape.Create(); |
1674 | part.Shape = shape; | 1705 | part.Shape = shape; |
1675 | 1706 | ||
1676 | part.Name = "Primitive"; | 1707 | part.Name = "Object"; |
1677 | part._ownerID = UUID.Random(); | 1708 | part._ownerID = UUID.Random(); |
1678 | 1709 | ||
1679 | return part; | 1710 | return part; |
@@ -2033,12 +2064,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2033 | public Vector3 GetWorldPosition() | 2064 | public Vector3 GetWorldPosition() |
2034 | { | 2065 | { |
2035 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; | 2066 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; |
2036 | |||
2037 | Vector3 axPos = OffsetPosition; | 2067 | Vector3 axPos = OffsetPosition; |
2038 | |||
2039 | axPos *= parentRot; | 2068 | axPos *= parentRot; |
2040 | Vector3 translationOffsetPosition = axPos; | 2069 | Vector3 translationOffsetPosition = axPos; |
2041 | return GroupPosition + translationOffsetPosition; | 2070 | if(_parentID == 0) |
2071 | { | ||
2072 | return GroupPosition; | ||
2073 | } | ||
2074 | else | ||
2075 | { | ||
2076 | return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position | ||
2077 | } | ||
2042 | } | 2078 | } |
2043 | 2079 | ||
2044 | /// <summary> | 2080 | /// <summary> |
@@ -2049,7 +2085,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2049 | { | 2085 | { |
2050 | Quaternion newRot; | 2086 | Quaternion newRot; |
2051 | 2087 | ||
2052 | if (this.LinkNum == 0) | 2088 | if (this.LinkNum < 2) //KF Single or root prim |
2053 | { | 2089 | { |
2054 | newRot = RotationOffset; | 2090 | newRot = RotationOffset; |
2055 | } | 2091 | } |
@@ -2695,17 +2731,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2695 | //Trys to fetch sound id from prim's inventory. | 2731 | //Trys to fetch sound id from prim's inventory. |
2696 | //Prim's inventory doesn't support non script items yet | 2732 | //Prim's inventory doesn't support non script items yet |
2697 | 2733 | ||
2698 | lock (TaskInventory) | 2734 | TaskInventory.LockItemsForRead(true); |
2735 | |||
2736 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
2699 | { | 2737 | { |
2700 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 2738 | if (item.Value.Name == sound) |
2701 | { | 2739 | { |
2702 | if (item.Value.Name == sound) | 2740 | soundID = item.Value.ItemID; |
2703 | { | 2741 | break; |
2704 | soundID = item.Value.ItemID; | ||
2705 | break; | ||
2706 | } | ||
2707 | } | 2742 | } |
2708 | } | 2743 | } |
2744 | |||
2745 | TaskInventory.LockItemsForRead(false); | ||
2709 | } | 2746 | } |
2710 | 2747 | ||
2711 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp) | 2748 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp) |
@@ -2765,7 +2802,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2765 | /// <param name="scale"></param> | 2802 | /// <param name="scale"></param> |
2766 | public void Resize(Vector3 scale) | 2803 | public void Resize(Vector3 scale) |
2767 | { | 2804 | { |
2768 | StoreUndoState(); | 2805 | StoreUndoState(UndoType.STATE_PRIM_SCALE); |
2769 | m_shape.Scale = scale; | 2806 | m_shape.Scale = scale; |
2770 | 2807 | ||
2771 | ParentGroup.HasGroupChanged = true; | 2808 | ParentGroup.HasGroupChanged = true; |
@@ -2774,38 +2811,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2774 | 2811 | ||
2775 | public void RotLookAt(Quaternion target, float strength, float damping) | 2812 | public void RotLookAt(Quaternion target, float strength, float damping) |
2776 | { | 2813 | { |
2777 | rotLookAt(target, strength, damping); | 2814 | m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup. |
2778 | } | ||
2779 | |||
2780 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2781 | { | ||
2782 | if (IsAttachment) | ||
2783 | { | ||
2784 | /* | ||
2785 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
2786 | if (avatar != null) | ||
2787 | { | ||
2788 | Rotate the Av? | ||
2789 | } */ | ||
2790 | } | ||
2791 | else | ||
2792 | { | ||
2793 | APIDDamp = damping; | ||
2794 | APIDStrength = strength; | ||
2795 | APIDTarget = target; | ||
2796 | } | ||
2797 | } | ||
2798 | |||
2799 | public void startLookAt(Quaternion rot, float damp, float strength) | ||
2800 | { | ||
2801 | APIDDamp = damp; | ||
2802 | APIDStrength = strength; | ||
2803 | APIDTarget = rot; | ||
2804 | } | ||
2805 | |||
2806 | public void stopLookAt() | ||
2807 | { | ||
2808 | APIDTarget = Quaternion.Identity; | ||
2809 | } | 2815 | } |
2810 | 2816 | ||
2811 | /// <summary> | 2817 | /// <summary> |
@@ -2817,7 +2823,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2817 | 2823 | ||
2818 | if (m_parentGroup != null) | 2824 | if (m_parentGroup != null) |
2819 | { | 2825 | { |
2820 | m_parentGroup.QueueForUpdateCheck(); | 2826 | if (!m_parentGroup.areUpdatesSuspended) |
2827 | { | ||
2828 | m_parentGroup.QueueForUpdateCheck(); | ||
2829 | } | ||
2821 | } | 2830 | } |
2822 | 2831 | ||
2823 | int timeNow = Util.UnixTimeSinceEpoch(); | 2832 | int timeNow = Util.UnixTimeSinceEpoch(); |
@@ -3034,8 +3043,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3034 | { | 3043 | { |
3035 | const float ROTATION_TOLERANCE = 0.01f; | 3044 | const float ROTATION_TOLERANCE = 0.01f; |
3036 | const float VELOCITY_TOLERANCE = 0.001f; | 3045 | const float VELOCITY_TOLERANCE = 0.001f; |
3037 | const float POSITION_TOLERANCE = 0.05f; | 3046 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
3038 | const int TIME_MS_TOLERANCE = 3000; | 3047 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
3039 | 3048 | ||
3040 | if (m_updateFlag == 1) | 3049 | if (m_updateFlag == 1) |
3041 | { | 3050 | { |
@@ -3049,7 +3058,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3049 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 3058 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) |
3050 | { | 3059 | { |
3051 | AddTerseUpdateToAllAvatars(); | 3060 | AddTerseUpdateToAllAvatars(); |
3052 | ClearUpdateSchedule(); | 3061 | |
3053 | 3062 | ||
3054 | // This causes the Scene to 'poll' physical objects every couple of frames | 3063 | // This causes the Scene to 'poll' physical objects every couple of frames |
3055 | // bad, so it's been replaced by an event driven method. | 3064 | // bad, so it's been replaced by an event driven method. |
@@ -3067,16 +3076,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3067 | m_lastAngularVelocity = AngularVelocity; | 3076 | m_lastAngularVelocity = AngularVelocity; |
3068 | m_lastTerseSent = Environment.TickCount; | 3077 | m_lastTerseSent = Environment.TickCount; |
3069 | } | 3078 | } |
3079 | //Moved this outside of the if clause so updates don't get blocked.. *sigh* | ||
3080 | m_updateFlag = 0; //Why were we calling a function to do this? Inefficient! *screams* | ||
3070 | } | 3081 | } |
3071 | else | 3082 | else |
3072 | { | 3083 | { |
3073 | if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes | 3084 | if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes |
3074 | { | 3085 | { |
3075 | AddFullUpdateToAllAvatars(); | 3086 | AddFullUpdateToAllAvatars(); |
3076 | ClearUpdateSchedule(); | 3087 | m_updateFlag = 0; //Same here |
3077 | } | 3088 | } |
3078 | } | 3089 | } |
3079 | ClearUpdateSchedule(); | 3090 | m_updateFlag = 0; |
3080 | } | 3091 | } |
3081 | 3092 | ||
3082 | /// <summary> | 3093 | /// <summary> |
@@ -3096,6 +3107,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3096 | UUID ownerID = _ownerID; | 3107 | UUID ownerID = _ownerID; |
3097 | UUID objectID = UUID; | 3108 | UUID objectID = UUID; |
3098 | UUID parentID = GetRootPartUUID(); | 3109 | UUID parentID = GetRootPartUUID(); |
3110 | |||
3111 | if (ParentGroup.IsAttachment && ParentGroup.RootPart.Shape.State > 30) | ||
3112 | { | ||
3113 | // Use the avatar as the parent for HUDs, since the prims | ||
3114 | // are not sent to other avatars | ||
3115 | objectID = _ownerID; | ||
3116 | parentID = _ownerID; | ||
3117 | } | ||
3118 | |||
3099 | UUID soundID = UUID.Zero; | 3119 | UUID soundID = UUID.Zero; |
3100 | Vector3 position = AbsolutePosition; // region local | 3120 | Vector3 position = AbsolutePosition; // region local |
3101 | ulong regionHandle = m_parentGroup.Scene.RegionInfo.RegionHandle; | 3121 | ulong regionHandle = m_parentGroup.Scene.RegionInfo.RegionHandle; |
@@ -3103,17 +3123,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3103 | if (!UUID.TryParse(sound, out soundID)) | 3123 | if (!UUID.TryParse(sound, out soundID)) |
3104 | { | 3124 | { |
3105 | // search sound file from inventory | 3125 | // search sound file from inventory |
3106 | lock (TaskInventory) | 3126 | TaskInventory.LockItemsForRead(true); |
3127 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
3107 | { | 3128 | { |
3108 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 3129 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) |
3109 | { | 3130 | { |
3110 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) | 3131 | soundID = item.Value.ItemID; |
3111 | { | 3132 | break; |
3112 | soundID = item.Value.ItemID; | ||
3113 | break; | ||
3114 | } | ||
3115 | } | 3133 | } |
3116 | } | 3134 | } |
3135 | TaskInventory.LockItemsForRead(false); | ||
3117 | } | 3136 | } |
3118 | 3137 | ||
3119 | if (soundID == UUID.Zero) | 3138 | if (soundID == UUID.Zero) |
@@ -3550,7 +3569,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3550 | 3569 | ||
3551 | public void StopLookAt() | 3570 | public void StopLookAt() |
3552 | { | 3571 | { |
3553 | m_parentGroup.stopLookAt(); | 3572 | m_parentGroup.stopLookAt(); // This calls method in SceneObjectGroup. |
3554 | 3573 | ||
3555 | m_parentGroup.ScheduleGroupForTerseUpdate(); | 3574 | m_parentGroup.ScheduleGroupForTerseUpdate(); |
3556 | } | 3575 | } |
@@ -3577,10 +3596,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3577 | m_parentGroup.ScheduleGroupForTerseUpdate(); | 3596 | m_parentGroup.ScheduleGroupForTerseUpdate(); |
3578 | //m_parentGroup.ScheduleGroupForFullUpdate(); | 3597 | //m_parentGroup.ScheduleGroupForFullUpdate(); |
3579 | } | 3598 | } |
3580 | 3599 | public void StoreUndoState(UndoType type) | |
3581 | public void StoreUndoState() | ||
3582 | { | 3600 | { |
3583 | if (!Undoing) | 3601 | if (!Undoing && (m_parentGroup == null || m_parentGroup.RootPart == null || !m_parentGroup.RootPart.Undoing)) |
3584 | { | 3602 | { |
3585 | if (!IgnoreUndoUpdate) | 3603 | if (!IgnoreUndoUpdate) |
3586 | { | 3604 | { |
@@ -3591,17 +3609,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
3591 | if (m_undo.Count > 0) | 3609 | if (m_undo.Count > 0) |
3592 | { | 3610 | { |
3593 | UndoState last = m_undo.Peek(); | 3611 | UndoState last = m_undo.Peek(); |
3594 | if (last != null) | 3612 | |
3595 | { | ||
3596 | if (last.Compare(this)) | ||
3597 | return; | ||
3598 | } | ||
3599 | } | 3613 | } |
3600 | 3614 | ||
3601 | if (m_parentGroup.GetSceneMaxUndo() > 0) | 3615 | if (m_parentGroup.GetSceneMaxUndo() > 0) |
3602 | { | 3616 | { |
3603 | UndoState nUndo = new UndoState(this); | 3617 | UndoState lastUndo = m_undo.Peek(); |
3618 | |||
3619 | UndoState nUndo = new UndoState(this, type); | ||
3604 | 3620 | ||
3621 | if (lastUndo != null) | ||
3622 | { | ||
3623 | TimeSpan ts = DateTime.Now.Subtract(lastUndo.LastUpdated); | ||
3624 | if (ts.TotalMilliseconds < 500) | ||
3625 | { | ||
3626 | //Delete the last entry since it was less than 500 milliseconds ago | ||
3627 | nUndo.Merge(lastUndo); | ||
3628 | m_undo.Pop(); | ||
3629 | } | ||
3630 | } | ||
3605 | m_undo.Push(nUndo); | 3631 | m_undo.Push(nUndo); |
3606 | } | 3632 | } |
3607 | 3633 | ||
@@ -4078,11 +4104,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
4078 | if (m_undo.Count > 0) | 4104 | if (m_undo.Count > 0) |
4079 | { | 4105 | { |
4080 | UndoState nUndo = null; | 4106 | UndoState nUndo = null; |
4107 | UndoState goback = m_undo.Pop(); | ||
4081 | if (m_parentGroup.GetSceneMaxUndo() > 0) | 4108 | if (m_parentGroup.GetSceneMaxUndo() > 0) |
4082 | { | 4109 | { |
4083 | nUndo = new UndoState(this); | 4110 | nUndo = new UndoState(this, goback.Type); |
4084 | } | 4111 | } |
4085 | UndoState goback = m_undo.Pop(); | 4112 | |
4113 | |||
4086 | if (goback != null) | 4114 | if (goback != null) |
4087 | { | 4115 | { |
4088 | goback.PlaybackState(this); | 4116 | goback.PlaybackState(this); |
@@ -4097,13 +4125,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
4097 | { | 4125 | { |
4098 | lock (m_redo) | 4126 | lock (m_redo) |
4099 | { | 4127 | { |
4128 | UndoState gofwd = m_redo.Pop(); | ||
4100 | if (m_parentGroup.GetSceneMaxUndo() > 0) | 4129 | if (m_parentGroup.GetSceneMaxUndo() > 0) |
4101 | { | 4130 | { |
4102 | UndoState nUndo = new UndoState(this); | 4131 | UndoState nUndo = new UndoState(this, gofwd.Type); |
4103 | 4132 | ||
4104 | m_undo.Push(nUndo); | 4133 | m_undo.Push(nUndo); |
4105 | } | 4134 | } |
4106 | UndoState gofwd = m_redo.Pop(); | ||
4107 | if (gofwd != null) | 4135 | if (gofwd != null) |
4108 | gofwd.PlayfwdState(this); | 4136 | gofwd.PlayfwdState(this); |
4109 | } | 4137 | } |
@@ -4551,8 +4579,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4551 | { | 4579 | { |
4552 | m_shape.TextureEntry = textureEntry; | 4580 | m_shape.TextureEntry = textureEntry; |
4553 | TriggerScriptChangedEvent(Changed.TEXTURE); | 4581 | TriggerScriptChangedEvent(Changed.TEXTURE); |
4554 | 4582 | m_updateFlag = 1; | |
4555 | ParentGroup.HasGroupChanged = true; | 4583 | ParentGroup.HasGroupChanged = true; |
4584 | |||
4556 | //This is madness.. | 4585 | //This is madness.. |
4557 | //ParentGroup.ScheduleGroupForFullUpdate(); | 4586 | //ParentGroup.ScheduleGroupForFullUpdate(); |
4558 | //This is sparta | 4587 | //This is sparta |
@@ -4797,5 +4826,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
4797 | Color color = Color; | 4826 | Color color = Color; |
4798 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 4827 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4799 | } | 4828 | } |
4829 | |||
4830 | public void ResetOwnerChangeFlag() | ||
4831 | { | ||
4832 | List<UUID> inv = Inventory.GetInventoryList(); | ||
4833 | |||
4834 | foreach (UUID itemID in inv) | ||
4835 | { | ||
4836 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
4837 | item.OwnerChanged = false; | ||
4838 | Inventory.UpdateInventoryItem(item); | ||
4839 | } | ||
4840 | } | ||
4800 | } | 4841 | } |
4801 | } | 4842 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 4ae53a2..8b4f0ed 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -46,6 +46,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
46 | 46 | ||
47 | private string m_inventoryFileName = String.Empty; | 47 | private string m_inventoryFileName = String.Empty; |
48 | private int m_inventoryFileNameSerial = 0; | 48 | private int m_inventoryFileNameSerial = 0; |
49 | |||
50 | private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); | ||
49 | 51 | ||
50 | /// <value> | 52 | /// <value> |
51 | /// The part to which the inventory belongs. | 53 | /// The part to which the inventory belongs. |
@@ -82,7 +84,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
82 | /// </value> | 84 | /// </value> |
83 | protected internal TaskInventoryDictionary Items | 85 | protected internal TaskInventoryDictionary Items |
84 | { | 86 | { |
85 | get { return m_items; } | 87 | get { |
88 | return m_items; | ||
89 | } | ||
86 | set | 90 | set |
87 | { | 91 | { |
88 | m_items = value; | 92 | m_items = value; |
@@ -118,22 +122,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
118 | /// <param name="linkNum">Link number for the part</param> | 122 | /// <param name="linkNum">Link number for the part</param> |
119 | public void ResetInventoryIDs() | 123 | public void ResetInventoryIDs() |
120 | { | 124 | { |
121 | lock (m_items) | 125 | m_items.LockItemsForWrite(true); |
126 | |||
127 | if (0 == Items.Count) | ||
122 | { | 128 | { |
123 | if (0 == m_items.Count) | 129 | m_items.LockItemsForWrite(false); |
124 | return; | 130 | return; |
131 | } | ||
125 | 132 | ||
126 | HasInventoryChanged = true; | 133 | HasInventoryChanged = true; |
127 | m_part.ParentGroup.HasGroupChanged = true; | 134 | m_part.ParentGroup.HasGroupChanged = true; |
128 | IList<TaskInventoryItem> items = GetInventoryItems(); | 135 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
129 | m_items.Clear(); | 136 | Items.Clear(); |
130 | 137 | ||
131 | foreach (TaskInventoryItem item in items) | 138 | foreach (TaskInventoryItem item in items) |
132 | { | 139 | { |
133 | item.ResetIDs(m_part.UUID); | 140 | item.ResetIDs(m_part.UUID); |
134 | m_items.Add(item.ItemID, item); | 141 | Items.Add(item.ItemID, item); |
135 | } | ||
136 | } | 142 | } |
143 | m_items.LockItemsForWrite(false); | ||
137 | } | 144 | } |
138 | 145 | ||
139 | /// <summary> | 146 | /// <summary> |
@@ -142,12 +149,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
142 | /// <param name="ownerId"></param> | 149 | /// <param name="ownerId"></param> |
143 | public void ChangeInventoryOwner(UUID ownerId) | 150 | public void ChangeInventoryOwner(UUID ownerId) |
144 | { | 151 | { |
145 | lock (Items) | 152 | m_items.LockItemsForWrite(true); |
153 | if (0 == Items.Count) | ||
146 | { | 154 | { |
147 | if (0 == Items.Count) | 155 | m_items.LockItemsForWrite(false); |
148 | { | 156 | return; |
149 | return; | ||
150 | } | ||
151 | } | 157 | } |
152 | 158 | ||
153 | HasInventoryChanged = true; | 159 | HasInventoryChanged = true; |
@@ -161,6 +167,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
161 | item.OwnerID = ownerId; | 167 | item.OwnerID = ownerId; |
162 | } | 168 | } |
163 | } | 169 | } |
170 | m_items.LockItemsForWrite(false); | ||
164 | } | 171 | } |
165 | 172 | ||
166 | /// <summary> | 173 | /// <summary> |
@@ -169,22 +176,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
169 | /// <param name="groupID"></param> | 176 | /// <param name="groupID"></param> |
170 | public void ChangeInventoryGroup(UUID groupID) | 177 | public void ChangeInventoryGroup(UUID groupID) |
171 | { | 178 | { |
172 | lock (Items) | 179 | m_items.LockItemsForWrite(true); |
180 | if (0 == Items.Count) | ||
173 | { | 181 | { |
174 | if (0 == Items.Count) | 182 | m_items.LockItemsForWrite(false); |
175 | { | 183 | return; |
176 | return; | ||
177 | } | ||
178 | } | 184 | } |
179 | 185 | ||
180 | HasInventoryChanged = true; | 186 | HasInventoryChanged = true; |
181 | m_part.ParentGroup.HasGroupChanged = true; | 187 | m_part.ParentGroup.HasGroupChanged = true; |
182 | List<TaskInventoryItem> items = GetInventoryItems(); | 188 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
183 | foreach (TaskInventoryItem item in items) | 189 | foreach (TaskInventoryItem item in items) |
184 | { | 190 | { |
185 | if (groupID != item.GroupID) | 191 | if (groupID != item.GroupID) |
192 | { | ||
186 | item.GroupID = groupID; | 193 | item.GroupID = groupID; |
194 | } | ||
187 | } | 195 | } |
196 | m_items.LockItemsForWrite(false); | ||
188 | } | 197 | } |
189 | 198 | ||
190 | /// <summary> | 199 | /// <summary> |
@@ -192,9 +201,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
192 | /// </summary> | 201 | /// </summary> |
193 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 202 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
194 | { | 203 | { |
195 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 204 | Items.LockItemsForRead(true); |
196 | foreach (TaskInventoryItem item in scripts) | 205 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
197 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | 206 | Items.LockItemsForRead(false); |
207 | foreach (TaskInventoryItem item in items) | ||
208 | { | ||
209 | if ((int)InventoryType.LSL == item.InvType) | ||
210 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | ||
211 | } | ||
198 | } | 212 | } |
199 | 213 | ||
200 | public ArrayList GetScriptErrors(UUID itemID) | 214 | public ArrayList GetScriptErrors(UUID itemID) |
@@ -227,9 +241,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
227 | /// </param> | 241 | /// </param> |
228 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 242 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
229 | { | 243 | { |
230 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 244 | Items.LockItemsForRead(true); |
231 | foreach (TaskInventoryItem item in scripts) | 245 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
232 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | 246 | Items.LockItemsForRead(false); |
247 | |||
248 | foreach (TaskInventoryItem item in items) | ||
249 | { | ||
250 | if ((int)InventoryType.LSL == item.InvType) | ||
251 | { | ||
252 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | ||
253 | m_part.RemoveScriptEvents(item.ItemID); | ||
254 | } | ||
255 | } | ||
233 | } | 256 | } |
234 | 257 | ||
235 | /// <summary> | 258 | /// <summary> |
@@ -245,7 +268,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
245 | // item.Name, item.ItemID, Name, UUID); | 268 | // item.Name, item.ItemID, Name, UUID); |
246 | 269 | ||
247 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) | 270 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) |
271 | { | ||
272 | StoreScriptError(item.ItemID, "no permission"); | ||
248 | return; | 273 | return; |
274 | } | ||
249 | 275 | ||
250 | m_part.AddFlag(PrimFlags.Scripted); | 276 | m_part.AddFlag(PrimFlags.Scripted); |
251 | 277 | ||
@@ -254,14 +280,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
254 | if (stateSource == 1 && // Prim crossing | 280 | if (stateSource == 1 && // Prim crossing |
255 | m_part.ParentGroup.Scene.m_trustBinaries) | 281 | m_part.ParentGroup.Scene.m_trustBinaries) |
256 | { | 282 | { |
257 | lock (m_items) | 283 | m_items.LockItemsForWrite(true); |
258 | { | 284 | m_items[item.ItemID].PermsMask = 0; |
259 | m_items[item.ItemID].PermsMask = 0; | 285 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
260 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 286 | m_items.LockItemsForWrite(false); |
261 | } | ||
262 | |||
263 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 287 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
264 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 288 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
289 | StoreScriptErrors(item.ItemID, null); | ||
265 | m_part.ParentGroup.AddActiveScriptCount(1); | 290 | m_part.ParentGroup.AddActiveScriptCount(1); |
266 | m_part.ScheduleFullUpdate(); | 291 | m_part.ScheduleFullUpdate(); |
267 | return; | 292 | return; |
@@ -270,6 +295,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
270 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); | 295 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
271 | if (null == asset) | 296 | if (null == asset) |
272 | { | 297 | { |
298 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | ||
299 | StoreScriptError(item.ItemID, msg); | ||
273 | m_log.ErrorFormat( | 300 | m_log.ErrorFormat( |
274 | "[PRIM INVENTORY]: " + | 301 | "[PRIM INVENTORY]: " + |
275 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", | 302 | "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
@@ -281,15 +308,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
281 | if (m_part.ParentGroup.m_savedScriptState != null) | 308 | if (m_part.ParentGroup.m_savedScriptState != null) |
282 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 309 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
283 | 310 | ||
284 | lock (m_items) | 311 | m_items.LockItemsForWrite(true); |
285 | { | 312 | |
286 | m_items[item.ItemID].PermsMask = 0; | 313 | m_items[item.ItemID].PermsMask = 0; |
287 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 314 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
288 | } | 315 | |
316 | m_items.LockItemsForWrite(false); | ||
289 | 317 | ||
290 | string script = Utils.BytesToString(asset.Data); | 318 | string script = Utils.BytesToString(asset.Data); |
291 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 319 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
292 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 320 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
321 | StoreScriptErrors(item.ItemID, null); | ||
293 | m_part.ParentGroup.AddActiveScriptCount(1); | 322 | m_part.ParentGroup.AddActiveScriptCount(1); |
294 | m_part.ScheduleFullUpdate(); | 323 | m_part.ScheduleFullUpdate(); |
295 | } | 324 | } |
@@ -353,21 +382,145 @@ namespace OpenSim.Region.Framework.Scenes | |||
353 | 382 | ||
354 | /// <summary> | 383 | /// <summary> |
355 | /// Start a script which is in this prim's inventory. | 384 | /// Start a script which is in this prim's inventory. |
385 | /// Some processing may occur in the background, but this routine returns asap. | ||
356 | /// </summary> | 386 | /// </summary> |
357 | /// <param name="itemId"> | 387 | /// <param name="itemId"> |
358 | /// A <see cref="UUID"/> | 388 | /// A <see cref="UUID"/> |
359 | /// </param> | 389 | /// </param> |
360 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 390 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
361 | { | 391 | { |
362 | TaskInventoryItem item = GetInventoryItem(itemId); | 392 | lock (m_scriptErrors) |
363 | if (item != null) | 393 | { |
364 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | 394 | // Indicate to CreateScriptInstanceInternal() we don't want it to wait for completion |
395 | m_scriptErrors.Remove(itemId); | ||
396 | } | ||
397 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
398 | } | ||
399 | |||
400 | private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
401 | { | ||
402 | m_items.LockItemsForRead(true); | ||
403 | if (m_items.ContainsKey(itemId)) | ||
404 | { | ||
405 | if (m_items.ContainsKey(itemId)) | ||
406 | { | ||
407 | m_items.LockItemsForRead(false); | ||
408 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | ||
409 | } | ||
410 | else | ||
411 | { | ||
412 | m_items.LockItemsForRead(false); | ||
413 | string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, | ||
414 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
415 | StoreScriptError(itemId, msg); | ||
416 | m_log.ErrorFormat( | ||
417 | "[PRIM INVENTORY]: " + | ||
418 | "Couldn't start script with ID {0} since it {1}", itemId, msg); | ||
419 | } | ||
420 | } | ||
365 | else | 421 | else |
422 | { | ||
423 | m_items.LockItemsForRead(false); | ||
424 | string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); | ||
425 | StoreScriptError(itemId, msg); | ||
366 | m_log.ErrorFormat( | 426 | m_log.ErrorFormat( |
367 | "[PRIM INVENTORY]: " + | 427 | "[PRIM INVENTORY]: " + |
368 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 428 | "Couldn't start script with ID {0} since it {1}", itemId, msg); |
369 | itemId, m_part.Name, m_part.UUID, | 429 | } |
370 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 430 | |
431 | } | ||
432 | |||
433 | /// <summary> | ||
434 | /// Start a script which is in this prim's inventory and return any compilation error messages. | ||
435 | /// </summary> | ||
436 | /// <param name="itemId"> | ||
437 | /// A <see cref="UUID"/> | ||
438 | /// </param> | ||
439 | public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
440 | { | ||
441 | ArrayList errors; | ||
442 | |||
443 | // Indicate to CreateScriptInstanceInternal() we want it to | ||
444 | // post any compilation/loading error messages | ||
445 | lock (m_scriptErrors) | ||
446 | { | ||
447 | m_scriptErrors[itemId] = null; | ||
448 | } | ||
449 | |||
450 | // Perform compilation/loading | ||
451 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
452 | |||
453 | // Wait for and retrieve any errors | ||
454 | lock (m_scriptErrors) | ||
455 | { | ||
456 | while ((errors = m_scriptErrors[itemId]) == null) | ||
457 | { | ||
458 | if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000)) | ||
459 | { | ||
460 | m_log.ErrorFormat( | ||
461 | "[PRIM INVENTORY]: " + | ||
462 | "timedout waiting for script {0} errors", itemId); | ||
463 | errors = m_scriptErrors[itemId]; | ||
464 | if (errors == null) | ||
465 | { | ||
466 | errors = new ArrayList(1); | ||
467 | errors.Add("timedout waiting for errors"); | ||
468 | } | ||
469 | break; | ||
470 | } | ||
471 | } | ||
472 | m_scriptErrors.Remove(itemId); | ||
473 | } | ||
474 | return errors; | ||
475 | } | ||
476 | |||
477 | // Signal to CreateScriptInstanceEr() that compilation/loading is complete | ||
478 | private void StoreScriptErrors(UUID itemId, ArrayList errors) | ||
479 | { | ||
480 | lock (m_scriptErrors) | ||
481 | { | ||
482 | // If compilation/loading initiated via CreateScriptInstance(), | ||
483 | // it does not want the errors, so just get out | ||
484 | if (!m_scriptErrors.ContainsKey(itemId)) | ||
485 | { | ||
486 | return; | ||
487 | } | ||
488 | |||
489 | // Initiated via CreateScriptInstanceEr(), if we know what the | ||
490 | // errors are, save them and wake CreateScriptInstanceEr(). | ||
491 | if (errors != null) | ||
492 | { | ||
493 | m_scriptErrors[itemId] = errors; | ||
494 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
495 | return; | ||
496 | } | ||
497 | } | ||
498 | |||
499 | // Initiated via CreateScriptInstanceEr() but we don't know what | ||
500 | // the errors are yet, so retrieve them from the script engine. | ||
501 | // This may involve some waiting internal to GetScriptErrors(). | ||
502 | errors = GetScriptErrors(itemId); | ||
503 | |||
504 | // Get a default non-null value to indicate success. | ||
505 | if (errors == null) | ||
506 | { | ||
507 | errors = new ArrayList(); | ||
508 | } | ||
509 | |||
510 | // Post to CreateScriptInstanceEr() and wake it up | ||
511 | lock (m_scriptErrors) | ||
512 | { | ||
513 | m_scriptErrors[itemId] = errors; | ||
514 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
515 | } | ||
516 | } | ||
517 | |||
518 | // Like StoreScriptErrors(), but just posts a single string message | ||
519 | private void StoreScriptError(UUID itemId, string message) | ||
520 | { | ||
521 | ArrayList errors = new ArrayList(1); | ||
522 | errors.Add(message); | ||
523 | StoreScriptErrors(itemId, errors); | ||
371 | } | 524 | } |
372 | 525 | ||
373 | /// <summary> | 526 | /// <summary> |
@@ -380,15 +533,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
380 | /// </param> | 533 | /// </param> |
381 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) | 534 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) |
382 | { | 535 | { |
383 | bool scriptPresent = false; | 536 | if (m_items.ContainsKey(itemId)) |
384 | |||
385 | lock (m_items) | ||
386 | { | ||
387 | if (m_items.ContainsKey(itemId)) | ||
388 | scriptPresent = true; | ||
389 | } | ||
390 | |||
391 | if (scriptPresent) | ||
392 | { | 537 | { |
393 | if (!sceneObjectBeingDeleted) | 538 | if (!sceneObjectBeingDeleted) |
394 | m_part.RemoveScriptEvents(itemId); | 539 | m_part.RemoveScriptEvents(itemId); |
@@ -413,14 +558,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
413 | /// <returns></returns> | 558 | /// <returns></returns> |
414 | private bool InventoryContainsName(string name) | 559 | private bool InventoryContainsName(string name) |
415 | { | 560 | { |
416 | lock (m_items) | 561 | m_items.LockItemsForRead(true); |
562 | foreach (TaskInventoryItem item in m_items.Values) | ||
417 | { | 563 | { |
418 | foreach (TaskInventoryItem item in m_items.Values) | 564 | if (item.Name == name) |
419 | { | 565 | { |
420 | if (item.Name == name) | 566 | m_items.LockItemsForRead(false); |
421 | return true; | 567 | return true; |
422 | } | 568 | } |
423 | } | 569 | } |
570 | m_items.LockItemsForRead(false); | ||
424 | return false; | 571 | return false; |
425 | } | 572 | } |
426 | 573 | ||
@@ -462,8 +609,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
462 | /// <param name="item"></param> | 609 | /// <param name="item"></param> |
463 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 610 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
464 | { | 611 | { |
465 | List<TaskInventoryItem> il = GetInventoryItems(); | 612 | m_items.LockItemsForRead(true); |
466 | 613 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | |
614 | m_items.LockItemsForRead(false); | ||
467 | foreach (TaskInventoryItem i in il) | 615 | foreach (TaskInventoryItem i in il) |
468 | { | 616 | { |
469 | if (i.Name == item.Name) | 617 | if (i.Name == item.Name) |
@@ -501,14 +649,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
501 | item.Name = name; | 649 | item.Name = name; |
502 | item.GroupID = m_part.GroupID; | 650 | item.GroupID = m_part.GroupID; |
503 | 651 | ||
504 | lock (m_items) | 652 | m_items.LockItemsForWrite(true); |
505 | m_items.Add(item.ItemID, item); | 653 | m_items.Add(item.ItemID, item); |
506 | 654 | m_items.LockItemsForWrite(false); | |
507 | if (allowedDrop) | 655 | if (allowedDrop) |
508 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 656 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
509 | else | 657 | else |
510 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 658 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
511 | 659 | ||
512 | m_inventorySerial++; | 660 | m_inventorySerial++; |
513 | //m_inventorySerial += 2; | 661 | //m_inventorySerial += 2; |
514 | HasInventoryChanged = true; | 662 | HasInventoryChanged = true; |
@@ -524,15 +672,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
524 | /// <param name="items"></param> | 672 | /// <param name="items"></param> |
525 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 673 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
526 | { | 674 | { |
527 | lock (m_items) | 675 | m_items.LockItemsForWrite(true); |
676 | foreach (TaskInventoryItem item in items) | ||
528 | { | 677 | { |
529 | foreach (TaskInventoryItem item in items) | 678 | m_items.Add(item.ItemID, item); |
530 | { | 679 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
531 | m_items.Add(item.ItemID, item); | ||
532 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
533 | } | ||
534 | m_inventorySerial++; | ||
535 | } | 680 | } |
681 | m_items.LockItemsForWrite(false); | ||
682 | |||
683 | m_inventorySerial++; | ||
536 | } | 684 | } |
537 | 685 | ||
538 | /// <summary> | 686 | /// <summary> |
@@ -543,10 +691,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
543 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 691 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
544 | { | 692 | { |
545 | TaskInventoryItem item; | 693 | TaskInventoryItem item; |
546 | 694 | m_items.LockItemsForRead(true); | |
547 | lock (m_items) | 695 | m_items.TryGetValue(itemId, out item); |
548 | m_items.TryGetValue(itemId, out item); | 696 | m_items.LockItemsForRead(false); |
549 | |||
550 | return item; | 697 | return item; |
551 | } | 698 | } |
552 | 699 | ||
@@ -562,15 +709,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
562 | { | 709 | { |
563 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 710 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
564 | 711 | ||
565 | lock (m_items) | 712 | m_items.LockItemsForRead(true); |
713 | |||
714 | foreach (TaskInventoryItem item in m_items.Values) | ||
566 | { | 715 | { |
567 | foreach (TaskInventoryItem item in m_items.Values) | 716 | if (item.Name == name) |
568 | { | 717 | items.Add(item); |
569 | if (item.Name == name) | ||
570 | items.Add(item); | ||
571 | } | ||
572 | } | 718 | } |
573 | 719 | ||
720 | m_items.LockItemsForRead(false); | ||
721 | |||
574 | return items; | 722 | return items; |
575 | } | 723 | } |
576 | 724 | ||
@@ -587,8 +735,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
587 | 735 | ||
588 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) | 736 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents) |
589 | { | 737 | { |
590 | TaskInventoryItem it = GetInventoryItem(item.ItemID); | 738 | m_items.LockItemsForWrite(true); |
591 | if (it != null) | 739 | |
740 | if (m_items.ContainsKey(item.ItemID)) | ||
592 | { | 741 | { |
593 | item.ParentID = m_part.UUID; | 742 | item.ParentID = m_part.UUID; |
594 | item.ParentPartID = m_part.UUID; | 743 | item.ParentPartID = m_part.UUID; |
@@ -600,19 +749,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
600 | item.GroupID = m_part.GroupID; | 749 | item.GroupID = m_part.GroupID; |
601 | 750 | ||
602 | if (item.AssetID == UUID.Zero) | 751 | if (item.AssetID == UUID.Zero) |
603 | item.AssetID = it.AssetID; | 752 | item.AssetID = m_items[item.ItemID].AssetID; |
604 | |||
605 | lock (m_items) | ||
606 | { | ||
607 | m_items[item.ItemID] = item; | ||
608 | m_inventorySerial++; | ||
609 | } | ||
610 | 753 | ||
754 | m_items[item.ItemID] = item; | ||
755 | m_inventorySerial++; | ||
611 | if (fireScriptEvents) | 756 | if (fireScriptEvents) |
612 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 757 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
613 | |||
614 | HasInventoryChanged = true; | 758 | HasInventoryChanged = true; |
615 | m_part.ParentGroup.HasGroupChanged = true; | 759 | m_part.ParentGroup.HasGroupChanged = true; |
760 | m_items.LockItemsForWrite(false); | ||
616 | return true; | 761 | return true; |
617 | } | 762 | } |
618 | else | 763 | else |
@@ -623,8 +768,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
623 | item.ItemID, m_part.Name, m_part.UUID, | 768 | item.ItemID, m_part.Name, m_part.UUID, |
624 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 769 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
625 | } | 770 | } |
626 | return false; | 771 | m_items.LockItemsForWrite(false); |
627 | 772 | ||
773 | return false; | ||
628 | } | 774 | } |
629 | 775 | ||
630 | /// <summary> | 776 | /// <summary> |
@@ -635,37 +781,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
635 | /// in this prim's inventory.</returns> | 781 | /// in this prim's inventory.</returns> |
636 | public int RemoveInventoryItem(UUID itemID) | 782 | public int RemoveInventoryItem(UUID itemID) |
637 | { | 783 | { |
638 | TaskInventoryItem item = GetInventoryItem(itemID); | 784 | m_items.LockItemsForRead(true); |
639 | if (item != null) | 785 | |
786 | if (m_items.ContainsKey(itemID)) | ||
640 | { | 787 | { |
641 | int type = m_items[itemID].InvType; | 788 | int type = m_items[itemID].InvType; |
789 | m_items.LockItemsForRead(false); | ||
642 | if (type == 10) // Script | 790 | if (type == 10) // Script |
643 | { | 791 | { |
644 | m_part.RemoveScriptEvents(itemID); | ||
645 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 792 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
646 | } | 793 | } |
794 | m_items.LockItemsForWrite(true); | ||
647 | m_items.Remove(itemID); | 795 | m_items.Remove(itemID); |
796 | m_items.LockItemsForWrite(false); | ||
648 | m_inventorySerial++; | 797 | m_inventorySerial++; |
649 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 798 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
650 | 799 | ||
651 | HasInventoryChanged = true; | 800 | HasInventoryChanged = true; |
652 | m_part.ParentGroup.HasGroupChanged = true; | 801 | m_part.ParentGroup.HasGroupChanged = true; |
653 | 802 | ||
654 | if (!ContainsScripts()) | 803 | int scriptcount = 0; |
804 | m_items.LockItemsForRead(true); | ||
805 | foreach (TaskInventoryItem item in m_items.Values) | ||
806 | { | ||
807 | if (item.Type == 10) | ||
808 | { | ||
809 | scriptcount++; | ||
810 | } | ||
811 | } | ||
812 | m_items.LockItemsForRead(false); | ||
813 | |||
814 | |||
815 | if (scriptcount <= 0) | ||
816 | { | ||
655 | m_part.RemFlag(PrimFlags.Scripted); | 817 | m_part.RemFlag(PrimFlags.Scripted); |
818 | } | ||
656 | 819 | ||
657 | m_part.ScheduleFullUpdate(); | 820 | m_part.ScheduleFullUpdate(); |
658 | 821 | ||
659 | return type; | 822 | return type; |
660 | |||
661 | } | 823 | } |
662 | else | 824 | else |
663 | { | 825 | { |
826 | m_items.LockItemsForRead(false); | ||
664 | m_log.ErrorFormat( | 827 | m_log.ErrorFormat( |
665 | "[PRIM INVENTORY]: " + | 828 | "[PRIM INVENTORY]: " + |
666 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 829 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", |
667 | itemID, m_part.Name, m_part.UUID, | 830 | itemID, m_part.Name, m_part.UUID); |
668 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
669 | } | 831 | } |
670 | 832 | ||
671 | return -1; | 833 | return -1; |
@@ -719,8 +881,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
719 | // isn't available (such as drag from prim inventory to agent inventory) | 881 | // isn't available (such as drag from prim inventory to agent inventory) |
720 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 882 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
721 | 883 | ||
722 | List<TaskInventoryItem> items = GetInventoryItems(); | 884 | m_items.LockItemsForRead(true); |
723 | foreach (TaskInventoryItem item in items) | 885 | |
886 | foreach (TaskInventoryItem item in m_items.Values) | ||
724 | { | 887 | { |
725 | UUID ownerID = item.OwnerID; | 888 | UUID ownerID = item.OwnerID; |
726 | uint everyoneMask = 0; | 889 | uint everyoneMask = 0; |
@@ -764,6 +927,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
764 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | 927 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); |
765 | invString.AddSectionEnd(); | 928 | invString.AddSectionEnd(); |
766 | } | 929 | } |
930 | int count = m_items.Count; | ||
931 | m_items.LockItemsForRead(false); | ||
767 | 932 | ||
768 | fileData = Utils.StringToBytes(invString.BuildString); | 933 | fileData = Utils.StringToBytes(invString.BuildString); |
769 | 934 | ||
@@ -784,10 +949,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
784 | { | 949 | { |
785 | if (HasInventoryChanged) | 950 | if (HasInventoryChanged) |
786 | { | 951 | { |
787 | HasInventoryChanged = false; | 952 | Items.LockItemsForRead(true); |
788 | List<TaskInventoryItem> items = GetInventoryItems(); | 953 | datastore.StorePrimInventory(m_part.UUID, Items.Values); |
789 | datastore.StorePrimInventory(m_part.UUID, items); | 954 | Items.LockItemsForRead(false); |
790 | 955 | ||
956 | HasInventoryChanged = false; | ||
791 | } | 957 | } |
792 | } | 958 | } |
793 | 959 | ||
@@ -854,89 +1020,75 @@ namespace OpenSim.Region.Framework.Scenes | |||
854 | { | 1020 | { |
855 | uint mask=0x7fffffff; | 1021 | uint mask=0x7fffffff; |
856 | 1022 | ||
857 | lock (m_items) | 1023 | foreach (TaskInventoryItem item in m_items.Values) |
858 | { | 1024 | { |
859 | foreach (TaskInventoryItem item in m_items.Values) | 1025 | if (item.InvType != (int)InventoryType.Object) |
860 | { | 1026 | { |
861 | if (item.InvType != (int)InventoryType.Object) | 1027 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) |
862 | { | 1028 | mask &= ~((uint)PermissionMask.Copy >> 13); |
863 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | 1029 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) |
864 | mask &= ~((uint)PermissionMask.Copy >> 13); | 1030 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
865 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | 1031 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) |
866 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1032 | mask &= ~((uint)PermissionMask.Modify >> 13); |
867 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
868 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
869 | } | ||
870 | else | ||
871 | { | ||
872 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
873 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
874 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
875 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
876 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
877 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
878 | } | ||
879 | |||
880 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
881 | mask &= ~(uint)PermissionMask.Copy; | ||
882 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
883 | mask &= ~(uint)PermissionMask.Transfer; | ||
884 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
885 | mask &= ~(uint)PermissionMask.Modify; | ||
886 | } | 1033 | } |
1034 | else | ||
1035 | { | ||
1036 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1037 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1038 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1039 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1040 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1041 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1042 | } | ||
1043 | |||
1044 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1045 | mask &= ~(uint)PermissionMask.Copy; | ||
1046 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1047 | mask &= ~(uint)PermissionMask.Transfer; | ||
1048 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1049 | mask &= ~(uint)PermissionMask.Modify; | ||
887 | } | 1050 | } |
888 | |||
889 | return mask; | 1051 | return mask; |
890 | } | 1052 | } |
891 | 1053 | ||
892 | public void ApplyNextOwnerPermissions() | 1054 | public void ApplyNextOwnerPermissions() |
893 | { | 1055 | { |
894 | lock (m_items) | 1056 | foreach (TaskInventoryItem item in m_items.Values) |
895 | { | 1057 | { |
896 | foreach (TaskInventoryItem item in m_items.Values) | 1058 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) |
897 | { | 1059 | { |
898 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) | 1060 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
899 | { | 1061 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |
900 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | 1062 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
901 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | 1063 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; |
902 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | 1064 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
903 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | 1065 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
904 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
905 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | ||
906 | } | ||
907 | item.CurrentPermissions &= item.NextPermissions; | ||
908 | item.BasePermissions &= item.NextPermissions; | ||
909 | item.EveryonePermissions &= item.NextPermissions; | ||
910 | item.OwnerChanged = true; | ||
911 | } | 1066 | } |
1067 | item.OwnerChanged = true; | ||
1068 | item.CurrentPermissions &= item.NextPermissions; | ||
1069 | item.BasePermissions &= item.NextPermissions; | ||
1070 | item.EveryonePermissions &= item.NextPermissions; | ||
912 | } | 1071 | } |
913 | } | 1072 | } |
914 | 1073 | ||
915 | public void ApplyGodPermissions(uint perms) | 1074 | public void ApplyGodPermissions(uint perms) |
916 | { | 1075 | { |
917 | lock (m_items) | 1076 | foreach (TaskInventoryItem item in m_items.Values) |
918 | { | 1077 | { |
919 | foreach (TaskInventoryItem item in m_items.Values) | 1078 | item.CurrentPermissions = perms; |
920 | { | 1079 | item.BasePermissions = perms; |
921 | item.CurrentPermissions = perms; | ||
922 | item.BasePermissions = perms; | ||
923 | } | ||
924 | } | 1080 | } |
925 | } | 1081 | } |
926 | 1082 | ||
927 | public bool ContainsScripts() | 1083 | public bool ContainsScripts() |
928 | { | 1084 | { |
929 | lock (m_items) | 1085 | foreach (TaskInventoryItem item in m_items.Values) |
930 | { | 1086 | { |
931 | foreach (TaskInventoryItem item in m_items.Values) | 1087 | if (item.InvType == (int)InventoryType.LSL) |
932 | { | 1088 | { |
933 | if (item.InvType == (int)InventoryType.LSL) | 1089 | return true; |
934 | { | ||
935 | return true; | ||
936 | } | ||
937 | } | 1090 | } |
938 | } | 1091 | } |
939 | |||
940 | return false; | 1092 | return false; |
941 | } | 1093 | } |
942 | 1094 | ||
@@ -944,11 +1096,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
944 | { | 1096 | { |
945 | List<UUID> ret = new List<UUID>(); | 1097 | List<UUID> ret = new List<UUID>(); |
946 | 1098 | ||
947 | lock (m_items) | 1099 | foreach (TaskInventoryItem item in m_items.Values) |
948 | { | 1100 | ret.Add(item.ItemID); |
949 | foreach (TaskInventoryItem item in m_items.Values) | ||
950 | ret.Add(item.ItemID); | ||
951 | } | ||
952 | 1101 | ||
953 | return ret; | 1102 | return ret; |
954 | } | 1103 | } |
@@ -979,31 +1128,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
979 | 1128 | ||
980 | public Dictionary<UUID, string> GetScriptStates() | 1129 | public Dictionary<UUID, string> GetScriptStates() |
981 | { | 1130 | { |
1131 | return GetScriptStates(false); | ||
1132 | } | ||
1133 | |||
1134 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1135 | { | ||
982 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | 1136 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); |
983 | 1137 | ||
984 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1138 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
985 | if (engines == null) // No engine at all | 1139 | if (engines == null) // No engine at all |
986 | return ret; | 1140 | return ret; |
987 | 1141 | ||
988 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | 1142 | foreach (TaskInventoryItem item in m_items.Values) |
989 | |||
990 | foreach (TaskInventoryItem item in scripts) | ||
991 | { | 1143 | { |
992 | foreach (IScriptModule e in engines) | 1144 | if (item.InvType == (int)InventoryType.LSL) |
993 | { | 1145 | { |
994 | if (e != null) | 1146 | foreach (IScriptModule e in engines) |
995 | { | 1147 | { |
996 | string n = e.GetXMLState(item.ItemID); | 1148 | if (e != null) |
997 | if (n != String.Empty) | ||
998 | { | 1149 | { |
999 | if (!ret.ContainsKey(item.ItemID)) | 1150 | string n = e.GetXMLState(item.ItemID); |
1000 | ret[item.ItemID] = n; | 1151 | if (n != String.Empty) |
1001 | break; | 1152 | { |
1153 | if (oldIDs) | ||
1154 | { | ||
1155 | if (!ret.ContainsKey(item.OldItemID)) | ||
1156 | ret[item.OldItemID] = n; | ||
1157 | } | ||
1158 | else | ||
1159 | { | ||
1160 | if (!ret.ContainsKey(item.ItemID)) | ||
1161 | ret[item.ItemID] = n; | ||
1162 | } | ||
1163 | break; | ||
1164 | } | ||
1002 | } | 1165 | } |
1003 | } | 1166 | } |
1004 | } | 1167 | } |
1005 | } | 1168 | } |
1006 | |||
1007 | return ret; | 1169 | return ret; |
1008 | } | 1170 | } |
1009 | 1171 | ||
@@ -1013,21 +1175,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
1013 | if (engines == null) | 1175 | if (engines == null) |
1014 | return; | 1176 | return; |
1015 | 1177 | ||
1016 | List<TaskInventoryItem> scripts = GetInventoryScripts(); | ||
1017 | 1178 | ||
1018 | foreach (TaskInventoryItem item in scripts) | 1179 | Items.LockItemsForRead(true); |
1180 | |||
1181 | foreach (TaskInventoryItem item in m_items.Values) | ||
1019 | { | 1182 | { |
1020 | foreach (IScriptModule engine in engines) | 1183 | if (item.InvType == (int)InventoryType.LSL) |
1021 | { | 1184 | { |
1022 | if (engine != null) | 1185 | foreach (IScriptModule engine in engines) |
1023 | { | 1186 | { |
1024 | if (item.OwnerChanged) | 1187 | if (engine != null) |
1025 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); | 1188 | { |
1026 | item.OwnerChanged = false; | 1189 | if (item.OwnerChanged) |
1027 | engine.ResumeScript(item.ItemID); | 1190 | engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER }); |
1191 | item.OwnerChanged = false; | ||
1192 | engine.ResumeScript(item.ItemID); | ||
1193 | } | ||
1028 | } | 1194 | } |
1029 | } | 1195 | } |
1030 | } | 1196 | } |
1197 | |||
1198 | Items.LockItemsForRead(false); | ||
1031 | } | 1199 | } |
1032 | 1200 | ||
1033 | } | 1201 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 08c6e27..02e60f8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Timers; | 32 | using System.Timers; |
@@ -72,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
72 | // { | 73 | // { |
73 | // m_log.Debug("[ScenePresence] Destructor called"); | 74 | // m_log.Debug("[ScenePresence] Destructor called"); |
74 | // } | 75 | // } |
75 | 76 | ||
76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 77 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
77 | 78 | ||
78 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; | 79 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; |
@@ -88,7 +89,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
88 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 89 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
89 | /// issue #1716 | 90 | /// issue #1716 |
90 | /// </summary> | 91 | /// </summary> |
91 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); | 92 | // private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); |
93 | // Value revised by KF 091121 by comparison with SL. | ||
94 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | ||
92 | 95 | ||
93 | public UUID currentParcelUUID = UUID.Zero; | 96 | public UUID currentParcelUUID = UUID.Zero; |
94 | 97 | ||
@@ -122,8 +125,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
122 | public Vector3 lastKnownAllowedPosition; | 125 | public Vector3 lastKnownAllowedPosition; |
123 | public bool sentMessageAboutRestrictedParcelFlyingDown; | 126 | public bool sentMessageAboutRestrictedParcelFlyingDown; |
124 | public Vector4 CollisionPlane = Vector4.UnitW; | 127 | public Vector4 CollisionPlane = Vector4.UnitW; |
125 | 128 | ||
129 | private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation | ||
130 | private Vector3 m_avUnscriptedSitPos; // for non-scripted prims | ||
126 | private Vector3 m_lastPosition; | 131 | private Vector3 m_lastPosition; |
132 | private Vector3 m_lastWorldPosition; | ||
127 | private Quaternion m_lastRotation; | 133 | private Quaternion m_lastRotation; |
128 | private Vector3 m_lastVelocity; | 134 | private Vector3 m_lastVelocity; |
129 | //private int m_lastTerseSent; | 135 | //private int m_lastTerseSent; |
@@ -156,7 +162,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
156 | private int m_perfMonMS; | 162 | private int m_perfMonMS; |
157 | 163 | ||
158 | private bool m_setAlwaysRun; | 164 | private bool m_setAlwaysRun; |
159 | |||
160 | private bool m_forceFly; | 165 | private bool m_forceFly; |
161 | private bool m_flyDisabled; | 166 | private bool m_flyDisabled; |
162 | 167 | ||
@@ -180,7 +185,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
180 | protected RegionInfo m_regionInfo; | 185 | protected RegionInfo m_regionInfo; |
181 | protected ulong crossingFromRegion; | 186 | protected ulong crossingFromRegion; |
182 | 187 | ||
183 | private readonly Vector3[] Dir_Vectors = new Vector3[9]; | 188 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; |
189 | private bool m_isNudging = false; | ||
184 | 190 | ||
185 | // Position of agent's camera in world (region cordinates) | 191 | // Position of agent's camera in world (region cordinates) |
186 | protected Vector3 m_CameraCenter; | 192 | protected Vector3 m_CameraCenter; |
@@ -205,17 +211,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
205 | private bool m_autopilotMoving; | 211 | private bool m_autopilotMoving; |
206 | private Vector3 m_autoPilotTarget; | 212 | private Vector3 m_autoPilotTarget; |
207 | private bool m_sitAtAutoTarget; | 213 | private bool m_sitAtAutoTarget; |
214 | private Vector3 m_initialSitTarget = Vector3.Zero; //KF: First estimate of where to sit | ||
208 | 215 | ||
209 | private string m_nextSitAnimation = String.Empty; | 216 | private string m_nextSitAnimation = String.Empty; |
210 | 217 | ||
211 | //PauPaw:Proper PID Controler for autopilot************ | 218 | //PauPaw:Proper PID Controler for autopilot************ |
212 | private bool m_moveToPositionInProgress; | 219 | private bool m_moveToPositionInProgress; |
213 | private Vector3 m_moveToPositionTarget; | 220 | private Vector3 m_moveToPositionTarget; |
221 | private Quaternion m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
214 | 222 | ||
215 | private bool m_followCamAuto; | 223 | private bool m_followCamAuto; |
216 | 224 | ||
217 | private int m_movementUpdateCount; | 225 | private int m_movementUpdateCount; |
226 | private int m_lastColCount = -1; //KF: Look for Collision chnages | ||
227 | private int m_updateCount = 0; //KF: Update Anims for a while | ||
228 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | ||
218 | private const int NumMovementsBetweenRayCast = 5; | 229 | private const int NumMovementsBetweenRayCast = 5; |
230 | private List<uint> m_lastColliders = new List<uint>(); | ||
219 | 231 | ||
220 | private bool CameraConstraintActive; | 232 | private bool CameraConstraintActive; |
221 | //private int m_moveToPositionStateStatus; | 233 | //private int m_moveToPositionStateStatus; |
@@ -242,7 +254,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
242 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, | 254 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, |
243 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | 255 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, |
244 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, | 256 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, |
245 | DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, | 257 | DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, |
258 | DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, | ||
259 | DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, | ||
246 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 260 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG |
247 | } | 261 | } |
248 | 262 | ||
@@ -449,9 +463,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
449 | get | 463 | get |
450 | { | 464 | { |
451 | PhysicsActor actor = m_physicsActor; | 465 | PhysicsActor actor = m_physicsActor; |
452 | if (actor != null) | 466 | // if (actor != null) |
467 | if ((actor != null) && (m_parentID == 0)) // KF Do NOT update m_pos here if Av is sitting! | ||
453 | m_pos = actor.Position; | 468 | m_pos = actor.Position; |
454 | 469 | ||
470 | // If we're sitting, we need to update our position | ||
471 | if (m_parentID != 0) | ||
472 | { | ||
473 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | ||
474 | if (part != null) | ||
475 | m_parentPosition = part.AbsolutePosition; | ||
476 | } | ||
477 | |||
455 | return m_parentPosition + m_pos; | 478 | return m_parentPosition + m_pos; |
456 | } | 479 | } |
457 | set | 480 | set |
@@ -470,7 +493,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
470 | } | 493 | } |
471 | } | 494 | } |
472 | 495 | ||
473 | m_pos = value; | 496 | if (m_parentID == 0) // KF Do NOT update m_pos here if Av is sitting! |
497 | m_pos = value; | ||
474 | m_parentPosition = Vector3.Zero; | 498 | m_parentPosition = Vector3.Zero; |
475 | } | 499 | } |
476 | } | 500 | } |
@@ -514,10 +538,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
514 | } | 538 | } |
515 | } | 539 | } |
516 | 540 | ||
541 | public Quaternion OffsetRotation | ||
542 | { | ||
543 | get { return m_offsetRotation; } | ||
544 | set { m_offsetRotation = value; } | ||
545 | } | ||
546 | |||
517 | public Quaternion Rotation | 547 | public Quaternion Rotation |
518 | { | 548 | { |
519 | get { return m_bodyRot; } | 549 | get { |
520 | set { m_bodyRot = value; } | 550 | if (m_parentID != 0) |
551 | { | ||
552 | if (m_offsetRotation != null) | ||
553 | { | ||
554 | return m_offsetRotation; | ||
555 | } | ||
556 | else | ||
557 | { | ||
558 | return new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
559 | } | ||
560 | |||
561 | } | ||
562 | else | ||
563 | { | ||
564 | return m_bodyRot; | ||
565 | } | ||
566 | } | ||
567 | set { | ||
568 | m_bodyRot = value; | ||
569 | if (m_parentID != 0) | ||
570 | { | ||
571 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
572 | } | ||
573 | } | ||
521 | } | 574 | } |
522 | 575 | ||
523 | public Quaternion PreviousRotation | 576 | public Quaternion PreviousRotation |
@@ -542,11 +595,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
542 | 595 | ||
543 | private uint m_parentID; | 596 | private uint m_parentID; |
544 | 597 | ||
598 | |||
599 | private UUID m_linkedPrim; | ||
600 | |||
545 | public uint ParentID | 601 | public uint ParentID |
546 | { | 602 | { |
547 | get { return m_parentID; } | 603 | get { return m_parentID; } |
548 | set { m_parentID = value; } | 604 | set { m_parentID = value; } |
549 | } | 605 | } |
606 | |||
607 | public UUID LinkedPrim | ||
608 | { | ||
609 | get { return m_linkedPrim; } | ||
610 | set { m_linkedPrim = value; } | ||
611 | } | ||
612 | |||
550 | public float Health | 613 | public float Health |
551 | { | 614 | { |
552 | get { return m_health; } | 615 | get { return m_health; } |
@@ -668,7 +731,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
668 | CreateSceneViewer(); | 731 | CreateSceneViewer(); |
669 | m_animator = new ScenePresenceAnimator(this); | 732 | m_animator = new ScenePresenceAnimator(this); |
670 | } | 733 | } |
671 | 734 | ||
672 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() | 735 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() |
673 | { | 736 | { |
674 | m_rootRegionHandle = reginfo.RegionHandle; | 737 | m_rootRegionHandle = reginfo.RegionHandle; |
@@ -700,16 +763,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
700 | m_reprioritization_timer.AutoReset = false; | 763 | m_reprioritization_timer.AutoReset = false; |
701 | 764 | ||
702 | AdjustKnownSeeds(); | 765 | AdjustKnownSeeds(); |
703 | |||
704 | // TODO: I think, this won't send anything, as we are still a child here... | ||
705 | Animator.TrySetMovementAnimation("STAND"); | 766 | Animator.TrySetMovementAnimation("STAND"); |
706 | |||
707 | // we created a new ScenePresence (a new child agent) in a fresh region. | 767 | // we created a new ScenePresence (a new child agent) in a fresh region. |
708 | // Request info about all the (root) agents in this region | 768 | // Request info about all the (root) agents in this region |
709 | // Note: This won't send data *to* other clients in that region (children don't send) | 769 | // Note: This won't send data *to* other clients in that region (children don't send) |
710 | SendInitialFullUpdateToAllClients(); | 770 | SendInitialFullUpdateToAllClients(); |
711 | |||
712 | RegisterToEvents(); | 771 | RegisterToEvents(); |
772 | if (m_controllingClient != null) | ||
773 | { | ||
774 | m_controllingClient.ProcessPendingPackets(); | ||
775 | } | ||
713 | SetDirectionVectors(); | 776 | SetDirectionVectors(); |
714 | } | 777 | } |
715 | 778 | ||
@@ -759,25 +822,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
759 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT | 822 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT |
760 | Dir_Vectors[4] = Vector3.UnitZ; //UP | 823 | Dir_Vectors[4] = Vector3.UnitZ; //UP |
761 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN | 824 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN |
762 | Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | 825 | Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE |
763 | Dir_Vectors[6] = Vector3.UnitX*2; //FORWARD | 826 | Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE |
764 | Dir_Vectors[7] = -Vector3.UnitX; //BACK | 827 | Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE |
828 | Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE | ||
829 | Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | ||
765 | } | 830 | } |
766 | 831 | ||
767 | private Vector3[] GetWalkDirectionVectors() | 832 | private Vector3[] GetWalkDirectionVectors() |
768 | { | 833 | { |
769 | Vector3[] vector = new Vector3[9]; | 834 | Vector3[] vector = new Vector3[11]; |
770 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD | 835 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD |
771 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK | 836 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK |
772 | vector[2] = Vector3.UnitY; //LEFT | 837 | vector[2] = Vector3.UnitY; //LEFT |
773 | vector[3] = -Vector3.UnitY; //RIGHT | 838 | vector[3] = -Vector3.UnitY; //RIGHT |
774 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP | 839 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP |
775 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN | 840 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN |
776 | vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge | 841 | vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE |
777 | vector[6] = (new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z) * 2); //FORWARD Nudge | 842 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE |
778 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK Nudge | 843 | vector[8] = Vector3.UnitY; //LEFT_NUDGE |
844 | vector[9] = -Vector3.UnitY; //RIGHT_NUDGE | ||
845 | vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE | ||
779 | return vector; | 846 | return vector; |
780 | } | 847 | } |
848 | |||
849 | private bool[] GetDirectionIsNudge() | ||
850 | { | ||
851 | bool[] isNudge = new bool[11]; | ||
852 | isNudge[0] = false; //FORWARD | ||
853 | isNudge[1] = false; //BACK | ||
854 | isNudge[2] = false; //LEFT | ||
855 | isNudge[3] = false; //RIGHT | ||
856 | isNudge[4] = false; //UP | ||
857 | isNudge[5] = false; //DOWN | ||
858 | isNudge[6] = true; //FORWARD_NUDGE | ||
859 | isNudge[7] = true; //BACK_NUDGE | ||
860 | isNudge[8] = true; //LEFT_NUDGE | ||
861 | isNudge[9] = true; //RIGHT_NUDGE | ||
862 | isNudge[10] = true; //DOWN_Nudge | ||
863 | return isNudge; | ||
864 | } | ||
865 | |||
781 | 866 | ||
782 | #endregion | 867 | #endregion |
783 | 868 | ||
@@ -839,6 +924,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
839 | pos.Y = crossedBorder.BorderLine.Z - 1; | 924 | pos.Y = crossedBorder.BorderLine.Z - 1; |
840 | } | 925 | } |
841 | 926 | ||
927 | //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. | ||
928 | //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, | ||
929 | //they'll bypass the landing point. But I can't think of any decent way of fixing this. | ||
930 | if (KnownChildRegionHandles.Count == 0) | ||
931 | { | ||
932 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
933 | if (land != null) | ||
934 | { | ||
935 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. | ||
936 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && UserLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) | ||
937 | { | ||
938 | pos = land.LandData.UserLocation; | ||
939 | } | ||
940 | } | ||
941 | } | ||
942 | |||
943 | if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) | ||
944 | { | ||
945 | Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); | ||
946 | |||
947 | if (pos.X < 0) | ||
948 | { | ||
949 | emergencyPos.X = (int)Constants.RegionSize + pos.X; | ||
950 | if (!(pos.Y < 0)) | ||
951 | emergencyPos.Y = pos.Y; | ||
952 | if (!(pos.Z < 0)) | ||
953 | emergencyPos.Z = pos.Z; | ||
954 | } | ||
955 | if (pos.Y < 0) | ||
956 | { | ||
957 | emergencyPos.Y = (int)Constants.RegionSize + pos.Y; | ||
958 | if (!(pos.X < 0)) | ||
959 | emergencyPos.X = pos.X; | ||
960 | if (!(pos.Z < 0)) | ||
961 | emergencyPos.Z = pos.Z; | ||
962 | } | ||
963 | if (pos.Z < 0) | ||
964 | { | ||
965 | emergencyPos.Z = 128; | ||
966 | if (!(pos.Y < 0)) | ||
967 | emergencyPos.Y = pos.Y; | ||
968 | if (!(pos.X < 0)) | ||
969 | emergencyPos.X = pos.X; | ||
970 | } | ||
971 | } | ||
972 | |||
842 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 973 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
843 | { | 974 | { |
844 | m_log.WarnFormat( | 975 | m_log.WarnFormat( |
@@ -960,12 +1091,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
960 | { | 1091 | { |
961 | if (PhysicsActor != null) | 1092 | if (PhysicsActor != null) |
962 | { | 1093 | { |
963 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1094 | try |
964 | m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1095 | { |
965 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | 1096 | m_physicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
966 | m_physicsActor.UnSubscribeEvents(); | 1097 | m_physicsActor.OnOutOfBounds -= OutOfBoundsCall; |
967 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1098 | m_physicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
968 | PhysicsActor = null; | 1099 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); |
1100 | m_physicsActor.UnSubscribeEvents(); | ||
1101 | PhysicsActor = null; | ||
1102 | } | ||
1103 | catch | ||
1104 | { } | ||
969 | } | 1105 | } |
970 | } | 1106 | } |
971 | 1107 | ||
@@ -976,9 +1112,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
976 | public void Teleport(Vector3 pos) | 1112 | public void Teleport(Vector3 pos) |
977 | { | 1113 | { |
978 | bool isFlying = false; | 1114 | bool isFlying = false; |
1115 | |||
979 | if (m_physicsActor != null) | 1116 | if (m_physicsActor != null) |
980 | isFlying = m_physicsActor.Flying; | 1117 | isFlying = m_physicsActor.Flying; |
981 | 1118 | ||
982 | RemoveFromPhysicalScene(); | 1119 | RemoveFromPhysicalScene(); |
983 | Velocity = Vector3.Zero; | 1120 | Velocity = Vector3.Zero; |
984 | AbsolutePosition = pos; | 1121 | AbsolutePosition = pos; |
@@ -990,6 +1127,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
990 | } | 1127 | } |
991 | 1128 | ||
992 | SendTerseUpdateToAllClients(); | 1129 | SendTerseUpdateToAllClients(); |
1130 | |||
993 | } | 1131 | } |
994 | 1132 | ||
995 | public void TeleportWithMomentum(Vector3 pos) | 1133 | public void TeleportWithMomentum(Vector3 pos) |
@@ -1103,7 +1241,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1103 | pos.Z = ground + 1.5f; | 1241 | pos.Z = ground + 1.5f; |
1104 | AbsolutePosition = pos; | 1242 | AbsolutePosition = pos; |
1105 | } | 1243 | } |
1106 | |||
1107 | m_isChildAgent = false; | 1244 | m_isChildAgent = false; |
1108 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1245 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1109 | MakeRootAgent(AbsolutePosition, m_flying); | 1246 | MakeRootAgent(AbsolutePosition, m_flying); |
@@ -1202,6 +1339,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1202 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); | 1339 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); |
1203 | 1340 | ||
1204 | m_pos = m_LastFinitePos; | 1341 | m_pos = m_LastFinitePos; |
1342 | |||
1205 | if (!m_pos.IsFinite()) | 1343 | if (!m_pos.IsFinite()) |
1206 | { | 1344 | { |
1207 | m_pos.X = 127f; | 1345 | m_pos.X = 127f; |
@@ -1268,7 +1406,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1268 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); | 1406 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); |
1269 | } | 1407 | } |
1270 | } | 1408 | } |
1271 | |||
1272 | lock (scriptedcontrols) | 1409 | lock (scriptedcontrols) |
1273 | { | 1410 | { |
1274 | if (scriptedcontrols.Count > 0) | 1411 | if (scriptedcontrols.Count > 0) |
@@ -1283,6 +1420,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1283 | 1420 | ||
1284 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1421 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1285 | { | 1422 | { |
1423 | m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. | ||
1424 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | ||
1425 | |||
1286 | // TODO: This doesn't prevent the user from walking yet. | 1426 | // TODO: This doesn't prevent the user from walking yet. |
1287 | // Setting parent ID would fix this, if we knew what value | 1427 | // Setting parent ID would fix this, if we knew what value |
1288 | // to use. Or we could add a m_isSitting variable. | 1428 | // to use. Or we could add a m_isSitting variable. |
@@ -1337,6 +1477,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1337 | update_rotation = true; | 1477 | update_rotation = true; |
1338 | } | 1478 | } |
1339 | 1479 | ||
1480 | //guilty until proven innocent.. | ||
1481 | bool Nudging = true; | ||
1482 | //Basically, if there is at least one non-nudge control then we don't need | ||
1483 | //to worry about stopping the avatar | ||
1484 | |||
1340 | if (m_parentID == 0) | 1485 | if (m_parentID == 0) |
1341 | { | 1486 | { |
1342 | bool bAllowUpdateMoveToPosition = false; | 1487 | bool bAllowUpdateMoveToPosition = false; |
@@ -1351,9 +1496,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1351 | else | 1496 | else |
1352 | dirVectors = Dir_Vectors; | 1497 | dirVectors = Dir_Vectors; |
1353 | 1498 | ||
1354 | // The fact that m_movementflag is a byte needs to be fixed | 1499 | bool[] isNudge = GetDirectionIsNudge(); |
1355 | // it really should be a uint | 1500 | |
1356 | uint nudgehack = 250; | 1501 | |
1502 | |||
1503 | |||
1504 | |||
1357 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | 1505 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) |
1358 | { | 1506 | { |
1359 | if (((uint)flags & (uint)DCF) != 0) | 1507 | if (((uint)flags & (uint)DCF) != 0) |
@@ -1363,40 +1511,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1363 | try | 1511 | try |
1364 | { | 1512 | { |
1365 | agent_control_v3 += dirVectors[i]; | 1513 | agent_control_v3 += dirVectors[i]; |
1366 | //m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]); | 1514 | if (isNudge[i] == false) |
1515 | { | ||
1516 | Nudging = false; | ||
1517 | } | ||
1367 | } | 1518 | } |
1368 | catch (IndexOutOfRangeException) | 1519 | catch (IndexOutOfRangeException) |
1369 | { | 1520 | { |
1370 | // Why did I get this? | 1521 | // Why did I get this? |
1371 | } | 1522 | } |
1372 | 1523 | ||
1373 | if ((m_movementflag & (byte)(uint)DCF) == 0) | 1524 | if ((m_movementflag & (uint)DCF) == 0) |
1374 | { | 1525 | { |
1375 | if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1376 | { | ||
1377 | m_movementflag |= (byte)nudgehack; | ||
1378 | } | ||
1379 | m_movementflag += (byte)(uint)DCF; | 1526 | m_movementflag += (byte)(uint)DCF; |
1380 | update_movementflag = true; | 1527 | update_movementflag = true; |
1381 | } | 1528 | } |
1382 | } | 1529 | } |
1383 | else | 1530 | else |
1384 | { | 1531 | { |
1385 | if ((m_movementflag & (byte)(uint)DCF) != 0 || | 1532 | if ((m_movementflag & (uint)DCF) != 0) |
1386 | ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1387 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | ||
1388 | ) // This or is for Nudge forward | ||
1389 | { | 1533 | { |
1390 | m_movementflag -= ((byte)(uint)DCF); | 1534 | m_movementflag -= (byte)(uint)DCF; |
1391 | |||
1392 | update_movementflag = true; | 1535 | update_movementflag = true; |
1393 | /* | ||
1394 | if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1395 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | ||
1396 | { | ||
1397 | m_log.Debug("Removed Hack flag"); | ||
1398 | } | ||
1399 | */ | ||
1400 | } | 1536 | } |
1401 | else | 1537 | else |
1402 | { | 1538 | { |
@@ -1405,7 +1541,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1405 | } | 1541 | } |
1406 | i++; | 1542 | i++; |
1407 | } | 1543 | } |
1408 | |||
1409 | //Paupaw:Do Proper PID for Autopilot here | 1544 | //Paupaw:Do Proper PID for Autopilot here |
1410 | if (bResetMoveToPosition) | 1545 | if (bResetMoveToPosition) |
1411 | { | 1546 | { |
@@ -1440,6 +1575,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1440 | // Ignore z component of vector | 1575 | // Ignore z component of vector |
1441 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1576 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1442 | LocalVectorToTarget2D.Normalize(); | 1577 | LocalVectorToTarget2D.Normalize(); |
1578 | |||
1579 | //We're not nudging | ||
1580 | Nudging = false; | ||
1443 | agent_control_v3 += LocalVectorToTarget2D; | 1581 | agent_control_v3 += LocalVectorToTarget2D; |
1444 | 1582 | ||
1445 | // update avatar movement flags. the avatar coordinate system is as follows: | 1583 | // update avatar movement flags. the avatar coordinate system is as follows: |
@@ -1528,13 +1666,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1528 | // m_log.DebugFormat( | 1666 | // m_log.DebugFormat( |
1529 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); | 1667 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); |
1530 | 1668 | ||
1531 | AddNewMovement(agent_control_v3, q); | 1669 | AddNewMovement(agent_control_v3, q, Nudging); |
1532 | 1670 | ||
1533 | 1671 | ||
1534 | } | 1672 | } |
1535 | } | 1673 | } |
1536 | 1674 | ||
1537 | if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0) && !SitGround) | 1675 | if (update_movementflag && !SitGround) |
1538 | Animator.UpdateMovementAnimations(); | 1676 | Animator.UpdateMovementAnimations(); |
1539 | 1677 | ||
1540 | m_scene.EventManager.TriggerOnClientMovement(this); | 1678 | m_scene.EventManager.TriggerOnClientMovement(this); |
@@ -1549,7 +1687,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1549 | m_sitAtAutoTarget = false; | 1687 | m_sitAtAutoTarget = false; |
1550 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; | 1688 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; |
1551 | //proxy.PCode = (byte)PCode.ParticleSystem; | 1689 | //proxy.PCode = (byte)PCode.ParticleSystem; |
1552 | |||
1553 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); | 1690 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); |
1554 | proxyObjectGroup.AttachToScene(m_scene); | 1691 | proxyObjectGroup.AttachToScene(m_scene); |
1555 | 1692 | ||
@@ -1591,7 +1728,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1591 | } | 1728 | } |
1592 | m_moveToPositionInProgress = true; | 1729 | m_moveToPositionInProgress = true; |
1593 | m_moveToPositionTarget = new Vector3(locx, locy, locz); | 1730 | m_moveToPositionTarget = new Vector3(locx, locy, locz); |
1594 | } | 1731 | } |
1595 | catch (Exception ex) | 1732 | catch (Exception ex) |
1596 | { | 1733 | { |
1597 | //Why did I get this error? | 1734 | //Why did I get this error? |
@@ -1613,7 +1750,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1613 | Velocity = Vector3.Zero; | 1750 | Velocity = Vector3.Zero; |
1614 | SendFullUpdateToAllClients(); | 1751 | SendFullUpdateToAllClients(); |
1615 | 1752 | ||
1616 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1753 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? |
1617 | } | 1754 | } |
1618 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | 1755 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); |
1619 | m_requestedSitTargetUUID = UUID.Zero; | 1756 | m_requestedSitTargetUUID = UUID.Zero; |
@@ -1650,50 +1787,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
1650 | 1787 | ||
1651 | if (m_parentID != 0) | 1788 | if (m_parentID != 0) |
1652 | { | 1789 | { |
1653 | m_log.Debug("StandupCode Executed"); | 1790 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); |
1654 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | ||
1655 | if (part != null) | 1791 | if (part != null) |
1656 | { | 1792 | { |
1793 | part.TaskInventory.LockItemsForRead(true); | ||
1657 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1794 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1658 | if (taskIDict != null) | 1795 | if (taskIDict != null) |
1659 | { | 1796 | { |
1660 | lock (taskIDict) | 1797 | foreach (UUID taskID in taskIDict.Keys) |
1661 | { | 1798 | { |
1662 | foreach (UUID taskID in taskIDict.Keys) | 1799 | UnRegisterControlEventsToScript(LocalId, taskID); |
1663 | { | 1800 | taskIDict[taskID].PermsMask &= ~( |
1664 | UnRegisterControlEventsToScript(LocalId, taskID); | 1801 | 2048 | //PERMISSION_CONTROL_CAMERA |
1665 | taskIDict[taskID].PermsMask &= ~( | 1802 | 4); // PERMISSION_TAKE_CONTROLS |
1666 | 2048 | //PERMISSION_CONTROL_CAMERA | ||
1667 | 4); // PERMISSION_TAKE_CONTROLS | ||
1668 | } | ||
1669 | } | 1803 | } |
1670 | |||
1671 | } | 1804 | } |
1805 | part.TaskInventory.LockItemsForRead(false); | ||
1672 | // Reset sit target. | 1806 | // Reset sit target. |
1673 | if (part.GetAvatarOnSitTarget() == UUID) | 1807 | if (part.GetAvatarOnSitTarget() == UUID) |
1674 | part.SetAvatarOnSitTarget(UUID.Zero); | 1808 | part.SetAvatarOnSitTarget(UUID.Zero); |
1675 | |||
1676 | m_parentPosition = part.GetWorldPosition(); | 1809 | m_parentPosition = part.GetWorldPosition(); |
1677 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1810 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1678 | } | 1811 | } |
1812 | // part.GetWorldRotation() is the rotation of the object being sat on | ||
1813 | // Rotation is the sittiing Av's rotation | ||
1814 | |||
1815 | Quaternion partRot; | ||
1816 | // if (part.LinkNum == 1) | ||
1817 | // { // Root prim of linkset | ||
1818 | // partRot = part.ParentGroup.RootPart.RotationOffset; | ||
1819 | // } | ||
1820 | // else | ||
1821 | // { // single or child prim | ||
1822 | |||
1823 | // } | ||
1824 | if (part == null) //CW: Part may be gone. llDie() for example. | ||
1825 | { | ||
1826 | partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1827 | } | ||
1828 | else | ||
1829 | { | ||
1830 | partRot = part.GetWorldRotation(); | ||
1831 | } | ||
1832 | |||
1833 | Quaternion partIRot = Quaternion.Inverse(partRot); | ||
1834 | |||
1835 | Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av | ||
1836 | Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av | ||
1679 | 1837 | ||
1838 | |||
1680 | if (m_physicsActor == null) | 1839 | if (m_physicsActor == null) |
1681 | { | 1840 | { |
1682 | AddToPhysicalScene(false); | 1841 | AddToPhysicalScene(false); |
1683 | } | 1842 | } |
1684 | 1843 | //CW: If the part isn't null then we can set the current position | |
1685 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); | 1844 | if (part != null) |
1686 | m_parentPosition = Vector3.Zero; | 1845 | { |
1687 | 1846 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! | |
1688 | m_parentID = 0; | 1847 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. |
1848 | part.IsOccupied = false; | ||
1849 | part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); | ||
1850 | } | ||
1851 | else | ||
1852 | { | ||
1853 | //CW: Since the part doesn't exist, a coarse standup position isn't an issue | ||
1854 | AbsolutePosition = m_lastWorldPosition; | ||
1855 | } | ||
1856 | |||
1857 | m_parentPosition = Vector3.Zero; | ||
1858 | m_parentID = 0; | ||
1859 | m_linkedPrim = UUID.Zero; | ||
1860 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1689 | SendFullUpdateToAllClients(); | 1861 | SendFullUpdateToAllClients(); |
1690 | m_requestedSitTargetID = 0; | 1862 | m_requestedSitTargetID = 0; |
1863 | |||
1691 | if ((m_physicsActor != null) && (m_avHeight > 0)) | 1864 | if ((m_physicsActor != null) && (m_avHeight > 0)) |
1692 | { | 1865 | { |
1693 | SetHeight(m_avHeight); | 1866 | SetHeight(m_avHeight); |
1694 | } | 1867 | } |
1695 | } | 1868 | } |
1696 | |||
1697 | Animator.TrySetMovementAnimation("STAND"); | 1869 | Animator.TrySetMovementAnimation("STAND"); |
1698 | } | 1870 | } |
1699 | 1871 | ||
@@ -1724,13 +1896,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1724 | Vector3 avSitOffSet = part.SitTargetPosition; | 1896 | Vector3 avSitOffSet = part.SitTargetPosition; |
1725 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1897 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1726 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1898 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1727 | 1899 | bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); | |
1728 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1900 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1729 | bool SitTargetisSet = | 1901 | if (SitTargetisSet && !SitTargetOccupied) |
1730 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && | ||
1731 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); | ||
1732 | |||
1733 | if (SitTargetisSet && SitTargetUnOccupied) | ||
1734 | { | 1902 | { |
1735 | //switch the target to this prim | 1903 | //switch the target to this prim |
1736 | return part; | 1904 | return part; |
@@ -1744,84 +1912,164 @@ namespace OpenSim.Region.Framework.Scenes | |||
1744 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) | 1912 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) |
1745 | { | 1913 | { |
1746 | bool autopilot = true; | 1914 | bool autopilot = true; |
1915 | Vector3 autopilotTarget = new Vector3(); | ||
1916 | Quaternion sitOrientation = Quaternion.Identity; | ||
1747 | Vector3 pos = new Vector3(); | 1917 | Vector3 pos = new Vector3(); |
1748 | Quaternion sitOrientation = pSitOrientation; | ||
1749 | Vector3 cameraEyeOffset = Vector3.Zero; | 1918 | Vector3 cameraEyeOffset = Vector3.Zero; |
1750 | Vector3 cameraAtOffset = Vector3.Zero; | 1919 | Vector3 cameraAtOffset = Vector3.Zero; |
1751 | bool forceMouselook = false; | 1920 | bool forceMouselook = false; |
1752 | 1921 | ||
1753 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 1922 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
1754 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 1923 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
1755 | if (part != null) | 1924 | if (part == null) return; |
1756 | { | 1925 | |
1757 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1926 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
1758 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 1927 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1759 | 1928 | ||
1760 | // Is a sit target available? | 1929 | // part is the prim to sit on |
1761 | Vector3 avSitOffSet = part.SitTargetPosition; | 1930 | // offset is the world-ref vector distance from that prim center to the click-spot |
1762 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1931 | // UUID is the UUID of the Avatar doing the clicking |
1763 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1932 | |
1764 | 1933 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | |
1765 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1934 | |
1766 | bool SitTargetisSet = | 1935 | // Is a sit target available? |
1767 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && | 1936 | Vector3 avSitOffSet = part.SitTargetPosition; |
1768 | ( | 1937 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1769 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 1f // Valid Zero Rotation quaternion | 1938 | |
1770 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point | 1939 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1771 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion | 1940 | // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); |
1772 | ) | 1941 | Quaternion partRot; |
1773 | )); | 1942 | // if (part.LinkNum == 1) |
1774 | 1943 | // { // Root prim of linkset | |
1775 | if (SitTargetisSet && SitTargetUnOccupied) | 1944 | // partRot = part.ParentGroup.RootPart.RotationOffset; |
1776 | { | 1945 | // } |
1777 | part.SetAvatarOnSitTarget(UUID); | 1946 | // else |
1778 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 1947 | // { // single or child prim |
1779 | sitOrientation = avSitOrientation; | 1948 | partRot = part.GetWorldRotation(); |
1780 | autopilot = false; | 1949 | // } |
1781 | } | 1950 | Quaternion partIRot = Quaternion.Inverse(partRot); |
1782 | 1951 | //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); | |
1783 | pos = part.AbsolutePosition + offset; | 1952 | // Sit analysis rewritten by KF 091125 |
1784 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | 1953 | if (SitTargetisSet) // scipted sit |
1785 | //{ | 1954 | { |
1786 | // offset = pos; | 1955 | if (!part.IsOccupied) |
1787 | //autopilot = false; | 1956 | { |
1788 | //} | 1957 | //Console.WriteLine("Scripted, unoccupied"); |
1789 | if (m_physicsActor != null) | 1958 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it |
1790 | { | 1959 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one |
1791 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | 1960 | |
1792 | // We can remove the physicsActor until they stand up. | 1961 | Quaternion nrot = avSitOrientation; |
1793 | m_sitAvatarHeight = m_physicsActor.Size.Z; | 1962 | if (!part.IsRoot) |
1794 | |||
1795 | if (autopilot) | ||
1796 | { | 1963 | { |
1797 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) | 1964 | nrot = part.RotationOffset * avSitOrientation; |
1798 | { | ||
1799 | autopilot = false; | ||
1800 | |||
1801 | RemoveFromPhysicalScene(); | ||
1802 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | ||
1803 | } | ||
1804 | } | 1965 | } |
1805 | else | 1966 | sitOrientation = nrot; // Change rotatione to the scripted one |
1967 | OffsetRotation = nrot; | ||
1968 | autopilot = false; // Jump direct to scripted llSitPos() | ||
1969 | } | ||
1970 | else | ||
1971 | { | ||
1972 | //Console.WriteLine("Scripted, occupied"); | ||
1973 | return; | ||
1974 | } | ||
1975 | } | ||
1976 | else // Not Scripted | ||
1977 | { | ||
1978 | if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) | ||
1979 | { | ||
1980 | // large prim & offset, ignore if other Avs sitting | ||
1981 | // offset.Z -= 0.05f; | ||
1982 | m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked | ||
1983 | autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point | ||
1984 | |||
1985 | //Console.WriteLine(" offset ={0}", offset); | ||
1986 | //Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); | ||
1987 | //Console.WriteLine(" autopilotTarget={0}", autopilotTarget); | ||
1988 | |||
1989 | } | ||
1990 | else // small offset | ||
1991 | { | ||
1992 | //Console.WriteLine("Small offset"); | ||
1993 | if (!part.IsOccupied) | ||
1994 | { | ||
1995 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center | ||
1996 | autopilotTarget = part.AbsolutePosition; | ||
1997 | //Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); | ||
1998 | } | ||
1999 | else return; // occupied small | ||
2000 | } // end large/small | ||
2001 | } // end Scripted/not | ||
2002 | cameraAtOffset = part.GetCameraAtOffset(); | ||
2003 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2004 | forceMouselook = part.GetForceMouselook(); | ||
2005 | if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // | ||
2006 | if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // | ||
2007 | |||
2008 | if (m_physicsActor != null) | ||
2009 | { | ||
2010 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | ||
2011 | // We can remove the physicsActor until they stand up. | ||
2012 | m_sitAvatarHeight = m_physicsActor.Size.Z; | ||
2013 | if (autopilot) | ||
2014 | { // its not a scripted sit | ||
2015 | // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) | ||
2016 | if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 256.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 256.0f) ) | ||
1806 | { | 2017 | { |
2018 | autopilot = false; // close enough | ||
2019 | m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
2020 | Not using the part's position because returning the AV to the last known standing | ||
2021 | position is likely to be more friendly, isn't it? */ | ||
1807 | RemoveFromPhysicalScene(); | 2022 | RemoveFromPhysicalScene(); |
1808 | } | 2023 | Velocity = Vector3.Zero; |
2024 | AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target | ||
2025 | } // else the autopilot will get us close | ||
2026 | } | ||
2027 | else | ||
2028 | { // its a scripted sit | ||
2029 | m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
2030 | I *am* using the part's position this time because we have no real idea how far away | ||
2031 | the avatar is from the sit target. */ | ||
2032 | RemoveFromPhysicalScene(); | ||
2033 | Velocity = Vector3.Zero; | ||
1809 | } | 2034 | } |
1810 | |||
1811 | cameraAtOffset = part.GetCameraAtOffset(); | ||
1812 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
1813 | forceMouselook = part.GetForceMouselook(); | ||
1814 | } | 2035 | } |
1815 | 2036 | else return; // physactor is null! | |
1816 | ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2037 | |
1817 | m_requestedSitTargetUUID = targetID; | 2038 | Vector3 offsetr; // = offset * partIRot; |
2039 | // KF: In a linkset, offsetr needs to be relative to the group root! 091208 | ||
2040 | // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); | ||
2041 | // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. | ||
2042 | // { // Single, or Root prim of linkset, target is ClickOffset * RootRot | ||
2043 | //offsetr = offset * partIRot; | ||
2044 | // | ||
2045 | // else | ||
2046 | // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) | ||
2047 | // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + | ||
2048 | // (offset * partRot); | ||
2049 | // } | ||
2050 | |||
2051 | //Console.WriteLine(" "); | ||
2052 | //Console.WriteLine("link number ={0}", part.LinkNum); | ||
2053 | //Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); | ||
2054 | //Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); | ||
2055 | //Console.WriteLine("Click offst ={0}", offset); | ||
2056 | //Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); | ||
2057 | //Console.WriteLine("offsetr ={0}", offsetr); | ||
2058 | //Console.WriteLine("Camera At ={0}", cameraAtOffset); | ||
2059 | //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); | ||
2060 | |||
2061 | //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child | ||
2062 | ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2063 | |||
2064 | m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target | ||
1818 | // This calls HandleAgentSit twice, once from here, and the client calls | 2065 | // This calls HandleAgentSit twice, once from here, and the client calls |
1819 | // HandleAgentSit itself after it gets to the location | 2066 | // HandleAgentSit itself after it gets to the location |
1820 | // It doesn't get to the location until we've moved them there though | 2067 | // It doesn't get to the location until we've moved them there though |
1821 | // which happens in HandleAgentSit :P | 2068 | // which happens in HandleAgentSit :P |
1822 | m_autopilotMoving = autopilot; | 2069 | m_autopilotMoving = autopilot; |
1823 | m_autoPilotTarget = pos; | 2070 | m_autoPilotTarget = autopilotTarget; |
1824 | m_sitAtAutoTarget = autopilot; | 2071 | m_sitAtAutoTarget = autopilot; |
2072 | m_initialSitTarget = autopilotTarget; | ||
1825 | if (!autopilot) | 2073 | if (!autopilot) |
1826 | HandleAgentSit(remoteClient, UUID); | 2074 | HandleAgentSit(remoteClient, UUID); |
1827 | } | 2075 | } |
@@ -2116,47 +2364,130 @@ namespace OpenSim.Region.Framework.Scenes | |||
2116 | { | 2364 | { |
2117 | if (part != null) | 2365 | if (part != null) |
2118 | { | 2366 | { |
2367 | //Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); | ||
2119 | if (part.GetAvatarOnSitTarget() == UUID) | 2368 | if (part.GetAvatarOnSitTarget() == UUID) |
2120 | { | 2369 | { |
2370 | //Console.WriteLine("Scripted Sit"); | ||
2371 | // Scripted sit | ||
2121 | Vector3 sitTargetPos = part.SitTargetPosition; | 2372 | Vector3 sitTargetPos = part.SitTargetPosition; |
2122 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 2373 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
2123 | |||
2124 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | ||
2125 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | ||
2126 | |||
2127 | //Quaternion result = (sitTargetOrient * vq) * nq; | ||
2128 | |||
2129 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 2374 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
2130 | m_pos += SIT_TARGET_ADJUSTMENT; | 2375 | m_pos += SIT_TARGET_ADJUSTMENT; |
2376 | if (!part.IsRoot) | ||
2377 | { | ||
2378 | m_pos *= part.RotationOffset; | ||
2379 | } | ||
2131 | m_bodyRot = sitTargetOrient; | 2380 | m_bodyRot = sitTargetOrient; |
2132 | //Rotation = sitTargetOrient; | ||
2133 | m_parentPosition = part.AbsolutePosition; | 2381 | m_parentPosition = part.AbsolutePosition; |
2134 | 2382 | part.IsOccupied = true; | |
2135 | //SendTerseUpdateToAllClients(); | 2383 | part.ParentGroup.AddAvatar(agentID); |
2136 | } | 2384 | } |
2137 | else | 2385 | else |
2138 | { | 2386 | { |
2139 | m_pos -= part.AbsolutePosition; | 2387 | // if m_avUnscriptedSitPos is zero then Av sits above center |
2388 | // Else Av sits at m_avUnscriptedSitPos | ||
2389 | |||
2390 | // Non-scripted sit by Kitto Flora 21Nov09 | ||
2391 | // Calculate angle of line from prim to Av | ||
2392 | Quaternion partIRot; | ||
2393 | // if (part.LinkNum == 1) | ||
2394 | // { // Root prim of linkset | ||
2395 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2396 | // } | ||
2397 | // else | ||
2398 | // { // single or child prim | ||
2399 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2400 | // } | ||
2401 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; | ||
2402 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); | ||
2403 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); | ||
2404 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | ||
2405 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | ||
2406 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | ||
2407 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | ||
2408 | // Av sits at world euler <0,0, z>, translated by part rotation | ||
2409 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | ||
2410 | |||
2140 | m_parentPosition = part.AbsolutePosition; | 2411 | m_parentPosition = part.AbsolutePosition; |
2141 | } | 2412 | part.IsOccupied = true; |
2413 | part.ParentGroup.AddAvatar(agentID); | ||
2414 | m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation | ||
2415 | (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center | ||
2416 | (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + | ||
2417 | m_avUnscriptedSitPos; // adds click offset, if any | ||
2418 | //Set up raytrace to find top surface of prim | ||
2419 | Vector3 size = part.Scale; | ||
2420 | float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | ||
2421 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | ||
2422 | Vector3 down = new Vector3(0f, 0f, -1f); | ||
2423 | //Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); | ||
2424 | m_scene.PhysicsScene.RaycastWorld( | ||
2425 | start, // Vector3 position, | ||
2426 | down, // Vector3 direction, | ||
2427 | mag, // float length, | ||
2428 | SitAltitudeCallback); // retMethod | ||
2429 | } // end scripted/not | ||
2142 | } | 2430 | } |
2143 | else | 2431 | else // no Av |
2144 | { | 2432 | { |
2145 | return; | 2433 | return; |
2146 | } | 2434 | } |
2147 | } | 2435 | } |
2148 | m_parentID = m_requestedSitTargetID; | ||
2149 | 2436 | ||
2437 | //We want our offsets to reference the root prim, not the child we may have sat on | ||
2438 | if (!part.IsRoot) | ||
2439 | { | ||
2440 | m_parentID = part.ParentGroup.RootPart.LocalId; | ||
2441 | m_pos += part.OffsetPosition; | ||
2442 | } | ||
2443 | else | ||
2444 | { | ||
2445 | m_parentID = m_requestedSitTargetID; | ||
2446 | } | ||
2447 | |||
2448 | m_linkedPrim = part.UUID; | ||
2449 | if (part.GetAvatarOnSitTarget() != UUID) | ||
2450 | { | ||
2451 | m_offsetRotation = m_offsetRotation / part.RotationOffset; | ||
2452 | } | ||
2150 | Velocity = Vector3.Zero; | 2453 | Velocity = Vector3.Zero; |
2151 | RemoveFromPhysicalScene(); | 2454 | RemoveFromPhysicalScene(); |
2152 | |||
2153 | Animator.TrySetMovementAnimation(sitAnimation); | 2455 | Animator.TrySetMovementAnimation(sitAnimation); |
2154 | SendFullUpdateToAllClients(); | 2456 | SendFullUpdateToAllClients(); |
2155 | // This may seem stupid, but Our Full updates don't send avatar rotation :P | 2457 | SendTerseUpdateToAllClients(); |
2156 | // So we're also sending a terse update (which has avatar rotation) | ||
2157 | // [Update] We do now. | ||
2158 | //SendTerseUpdateToAllClients(); | ||
2159 | } | 2458 | } |
2459 | |||
2460 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) | ||
2461 | { | ||
2462 | // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer | ||
2463 | // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. | ||
2464 | if(hitYN) | ||
2465 | { | ||
2466 | // m_pos = Av offset from prim center to make look like on center | ||
2467 | // m_parentPosition = Actual center pos of prim | ||
2468 | // collisionPoint = spot on prim where we want to sit | ||
2469 | // collisionPoint.Z = global sit surface height | ||
2470 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | ||
2471 | Quaternion partIRot; | ||
2472 | // if (part.LinkNum == 1) | ||
2473 | /// { // Root prim of linkset | ||
2474 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2475 | // } | ||
2476 | // else | ||
2477 | // { // single or child prim | ||
2478 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2479 | // } | ||
2480 | if (m_initialSitTarget != null) | ||
2481 | { | ||
2482 | float offZ = collisionPoint.Z - m_initialSitTarget.Z; | ||
2483 | Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction | ||
2484 | //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); | ||
2485 | m_pos += offset; | ||
2486 | // ControllingClient.SendClearFollowCamProperties(part.UUID); | ||
2487 | } | ||
2488 | |||
2489 | } | ||
2490 | } // End SitAltitudeCallback KF. | ||
2160 | 2491 | ||
2161 | /// <summary> | 2492 | /// <summary> |
2162 | /// Event handler for the 'Always run' setting on the client | 2493 | /// Event handler for the 'Always run' setting on the client |
@@ -2186,7 +2517,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2186 | /// </summary> | 2517 | /// </summary> |
2187 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 2518 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
2188 | /// <param name="rotation">The direction in which this avatar should now face. | 2519 | /// <param name="rotation">The direction in which this avatar should now face. |
2189 | public void AddNewMovement(Vector3 vec, Quaternion rotation) | 2520 | public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) |
2190 | { | 2521 | { |
2191 | if (m_isChildAgent) | 2522 | if (m_isChildAgent) |
2192 | { | 2523 | { |
@@ -2227,10 +2558,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2227 | Rotation = rotation; | 2558 | Rotation = rotation; |
2228 | Vector3 direc = vec * rotation; | 2559 | Vector3 direc = vec * rotation; |
2229 | direc.Normalize(); | 2560 | direc.Normalize(); |
2561 | PhysicsActor actor = m_physicsActor; | ||
2562 | if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. | ||
2230 | 2563 | ||
2231 | direc *= 0.03f * 128f * m_speedModifier; | 2564 | direc *= 0.03f * 128f * m_speedModifier; |
2232 | 2565 | ||
2233 | PhysicsActor actor = m_physicsActor; | ||
2234 | if (actor != null) | 2566 | if (actor != null) |
2235 | { | 2567 | { |
2236 | if (actor.Flying) | 2568 | if (actor.Flying) |
@@ -2252,18 +2584,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2252 | { | 2584 | { |
2253 | if (direc.Z > 2.0f) | 2585 | if (direc.Z > 2.0f) |
2254 | { | 2586 | { |
2255 | direc.Z *= 3.0f; | 2587 | if(m_animator.m_animTickJump == -1) |
2256 | 2588 | { | |
2257 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2589 | direc.Z *= 3.0f; // jump |
2258 | Animator.TrySetMovementAnimation("PREJUMP"); | 2590 | } |
2259 | Animator.TrySetMovementAnimation("JUMP"); | 2591 | else |
2592 | { | ||
2593 | direc.Z *= 0.1f; // prejump | ||
2594 | } | ||
2595 | /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs | ||
2596 | Animator.TrySetMovementAnimation("PREJUMP"); | ||
2597 | Animator.TrySetMovementAnimation("JUMP"); | ||
2598 | */ | ||
2260 | } | 2599 | } |
2261 | } | 2600 | } |
2262 | } | 2601 | } |
2263 | 2602 | ||
2264 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2603 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2265 | m_forceToApply = direc; | 2604 | m_forceToApply = direc; |
2266 | 2605 | m_isNudging = Nudging; | |
2267 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2606 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2268 | } | 2607 | } |
2269 | 2608 | ||
@@ -2278,7 +2617,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2278 | const float POSITION_TOLERANCE = 0.05f; | 2617 | const float POSITION_TOLERANCE = 0.05f; |
2279 | //const int TIME_MS_TOLERANCE = 3000; | 2618 | //const int TIME_MS_TOLERANCE = 3000; |
2280 | 2619 | ||
2281 | SendPrimUpdates(); | 2620 | |
2282 | 2621 | ||
2283 | if (m_isChildAgent == false) | 2622 | if (m_isChildAgent == false) |
2284 | { | 2623 | { |
@@ -2308,6 +2647,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2308 | CheckForBorderCrossing(); | 2647 | CheckForBorderCrossing(); |
2309 | CheckForSignificantMovement(); // sends update to the modules. | 2648 | CheckForSignificantMovement(); // sends update to the modules. |
2310 | } | 2649 | } |
2650 | |||
2651 | //Sending prim updates AFTER the avatar terse updates are sent | ||
2652 | SendPrimUpdates(); | ||
2311 | } | 2653 | } |
2312 | 2654 | ||
2313 | #endregion | 2655 | #endregion |
@@ -3092,6 +3434,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3092 | m_callbackURI = cAgent.CallbackURI; | 3434 | m_callbackURI = cAgent.CallbackURI; |
3093 | 3435 | ||
3094 | m_pos = cAgent.Position; | 3436 | m_pos = cAgent.Position; |
3437 | |||
3095 | m_velocity = cAgent.Velocity; | 3438 | m_velocity = cAgent.Velocity; |
3096 | m_CameraCenter = cAgent.Center; | 3439 | m_CameraCenter = cAgent.Center; |
3097 | //m_avHeight = cAgent.Size.Z; | 3440 | //m_avHeight = cAgent.Size.Z; |
@@ -3202,14 +3545,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
3202 | { | 3545 | { |
3203 | if (m_forceToApply.HasValue) | 3546 | if (m_forceToApply.HasValue) |
3204 | { | 3547 | { |
3205 | Vector3 force = m_forceToApply.Value; | ||
3206 | 3548 | ||
3549 | Vector3 force = m_forceToApply.Value; | ||
3207 | m_updateflag = true; | 3550 | m_updateflag = true; |
3208 | // movementvector = force; | ||
3209 | Velocity = force; | 3551 | Velocity = force; |
3210 | 3552 | ||
3211 | m_forceToApply = null; | 3553 | m_forceToApply = null; |
3212 | } | 3554 | } |
3555 | else | ||
3556 | { | ||
3557 | if (m_isNudging) | ||
3558 | { | ||
3559 | Vector3 force = Vector3.Zero; | ||
3560 | |||
3561 | m_updateflag = true; | ||
3562 | Velocity = force; | ||
3563 | m_isNudging = false; | ||
3564 | m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" | ||
3565 | } | ||
3566 | } | ||
3213 | } | 3567 | } |
3214 | 3568 | ||
3215 | /// <summary> | 3569 | /// <summary> |
@@ -3255,18 +3609,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
3255 | { | 3609 | { |
3256 | if (e == null) | 3610 | if (e == null) |
3257 | return; | 3611 | return; |
3258 | 3612 | ||
3259 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3613 | // The Physics Scene will send (spam!) updates every 500 ms grep: m_physicsActor.SubscribeEvents( |
3260 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( | ||
3261 | // as of this comment the interval is set in AddToPhysicalScene | 3614 | // as of this comment the interval is set in AddToPhysicalScene |
3262 | if (Animator!=null) | 3615 | if (Animator!=null) |
3263 | Animator.UpdateMovementAnimations(); | 3616 | { |
3617 | if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, | ||
3618 | { // else its will lock out other animation changes, like ground sit. | ||
3619 | Animator.UpdateMovementAnimations(); | ||
3620 | m_updateCount--; | ||
3621 | } | ||
3622 | } | ||
3264 | 3623 | ||
3265 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3624 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3266 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3625 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3267 | 3626 | ||
3268 | CollisionPlane = Vector4.UnitW; | 3627 | CollisionPlane = Vector4.UnitW; |
3269 | 3628 | ||
3629 | if (m_lastColCount != coldata.Count) | ||
3630 | { | ||
3631 | m_updateCount = UPDATE_COUNT; | ||
3632 | m_lastColCount = coldata.Count; | ||
3633 | } | ||
3634 | |||
3270 | if (coldata.Count != 0 && Animator != null) | 3635 | if (coldata.Count != 0 && Animator != null) |
3271 | { | 3636 | { |
3272 | switch (Animator.CurrentMovementAnimation) | 3637 | switch (Animator.CurrentMovementAnimation) |
@@ -3296,6 +3661,148 @@ namespace OpenSim.Region.Framework.Scenes | |||
3296 | } | 3661 | } |
3297 | } | 3662 | } |
3298 | 3663 | ||
3664 | List<uint> thisHitColliders = new List<uint>(); | ||
3665 | List<uint> endedColliders = new List<uint>(); | ||
3666 | List<uint> startedColliders = new List<uint>(); | ||
3667 | |||
3668 | foreach (uint localid in coldata.Keys) | ||
3669 | { | ||
3670 | thisHitColliders.Add(localid); | ||
3671 | if (!m_lastColliders.Contains(localid)) | ||
3672 | { | ||
3673 | startedColliders.Add(localid); | ||
3674 | } | ||
3675 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3676 | } | ||
3677 | |||
3678 | // calculate things that ended colliding | ||
3679 | foreach (uint localID in m_lastColliders) | ||
3680 | { | ||
3681 | if (!thisHitColliders.Contains(localID)) | ||
3682 | { | ||
3683 | endedColliders.Add(localID); | ||
3684 | } | ||
3685 | } | ||
3686 | //add the items that started colliding this time to the last colliders list. | ||
3687 | foreach (uint localID in startedColliders) | ||
3688 | { | ||
3689 | m_lastColliders.Add(localID); | ||
3690 | } | ||
3691 | // remove things that ended colliding from the last colliders list | ||
3692 | foreach (uint localID in endedColliders) | ||
3693 | { | ||
3694 | m_lastColliders.Remove(localID); | ||
3695 | } | ||
3696 | |||
3697 | // do event notification | ||
3698 | if (startedColliders.Count > 0) | ||
3699 | { | ||
3700 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3701 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3702 | foreach (uint localId in startedColliders) | ||
3703 | { | ||
3704 | if (localId == 0) | ||
3705 | continue; | ||
3706 | |||
3707 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3708 | string data = ""; | ||
3709 | if (obj != null) | ||
3710 | { | ||
3711 | DetectedObject detobj = new DetectedObject(); | ||
3712 | detobj.keyUUID = obj.UUID; | ||
3713 | detobj.nameStr = obj.Name; | ||
3714 | detobj.ownerUUID = obj.OwnerID; | ||
3715 | detobj.posVector = obj.AbsolutePosition; | ||
3716 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3717 | detobj.velVector = obj.Velocity; | ||
3718 | detobj.colliderType = 0; | ||
3719 | detobj.groupUUID = obj.GroupID; | ||
3720 | colliding.Add(detobj); | ||
3721 | } | ||
3722 | } | ||
3723 | |||
3724 | if (colliding.Count > 0) | ||
3725 | { | ||
3726 | StartCollidingMessage.Colliders = colliding; | ||
3727 | |||
3728 | foreach (SceneObjectGroup att in Attachments) | ||
3729 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3730 | } | ||
3731 | } | ||
3732 | |||
3733 | if (endedColliders.Count > 0) | ||
3734 | { | ||
3735 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3736 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3737 | foreach (uint localId in endedColliders) | ||
3738 | { | ||
3739 | if (localId == 0) | ||
3740 | continue; | ||
3741 | |||
3742 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3743 | string data = ""; | ||
3744 | if (obj != null) | ||
3745 | { | ||
3746 | DetectedObject detobj = new DetectedObject(); | ||
3747 | detobj.keyUUID = obj.UUID; | ||
3748 | detobj.nameStr = obj.Name; | ||
3749 | detobj.ownerUUID = obj.OwnerID; | ||
3750 | detobj.posVector = obj.AbsolutePosition; | ||
3751 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3752 | detobj.velVector = obj.Velocity; | ||
3753 | detobj.colliderType = 0; | ||
3754 | detobj.groupUUID = obj.GroupID; | ||
3755 | colliding.Add(detobj); | ||
3756 | } | ||
3757 | } | ||
3758 | |||
3759 | if (colliding.Count > 0) | ||
3760 | { | ||
3761 | EndCollidingMessage.Colliders = colliding; | ||
3762 | |||
3763 | foreach (SceneObjectGroup att in Attachments) | ||
3764 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
3765 | } | ||
3766 | } | ||
3767 | |||
3768 | if (thisHitColliders.Count > 0) | ||
3769 | { | ||
3770 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
3771 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3772 | foreach (uint localId in thisHitColliders) | ||
3773 | { | ||
3774 | if (localId == 0) | ||
3775 | continue; | ||
3776 | |||
3777 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3778 | string data = ""; | ||
3779 | if (obj != null) | ||
3780 | { | ||
3781 | DetectedObject detobj = new DetectedObject(); | ||
3782 | detobj.keyUUID = obj.UUID; | ||
3783 | detobj.nameStr = obj.Name; | ||
3784 | detobj.ownerUUID = obj.OwnerID; | ||
3785 | detobj.posVector = obj.AbsolutePosition; | ||
3786 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3787 | detobj.velVector = obj.Velocity; | ||
3788 | detobj.colliderType = 0; | ||
3789 | detobj.groupUUID = obj.GroupID; | ||
3790 | colliding.Add(detobj); | ||
3791 | } | ||
3792 | } | ||
3793 | |||
3794 | if (colliding.Count > 0) | ||
3795 | { | ||
3796 | CollidingMessage.Colliders = colliding; | ||
3797 | |||
3798 | lock (m_attachments) | ||
3799 | { | ||
3800 | foreach (SceneObjectGroup att in m_attachments) | ||
3801 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
3802 | } | ||
3803 | } | ||
3804 | } | ||
3805 | |||
3299 | if (m_invulnerable) | 3806 | if (m_invulnerable) |
3300 | return; | 3807 | return; |
3301 | 3808 | ||
@@ -3470,7 +3977,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3470 | m_scene = scene; | 3977 | m_scene = scene; |
3471 | 3978 | ||
3472 | RegisterToEvents(); | 3979 | RegisterToEvents(); |
3473 | 3980 | if (m_controllingClient != null) | |
3981 | { | ||
3982 | m_controllingClient.ProcessPendingPackets(); | ||
3983 | } | ||
3474 | /* | 3984 | /* |
3475 | AbsolutePosition = client.StartPos; | 3985 | AbsolutePosition = client.StartPos; |
3476 | 3986 | ||
@@ -3700,6 +4210,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3700 | return; | 4210 | return; |
3701 | } | 4211 | } |
3702 | 4212 | ||
4213 | XmlDocument doc = new XmlDocument(); | ||
4214 | string stateData = String.Empty; | ||
4215 | |||
4216 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
4217 | if (attServ != null) | ||
4218 | { | ||
4219 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
4220 | stateData = attServ.Get(ControllingClient.AgentId.ToString()); | ||
4221 | if (stateData != String.Empty) | ||
4222 | { | ||
4223 | try | ||
4224 | { | ||
4225 | doc.LoadXml(stateData); | ||
4226 | } | ||
4227 | catch { } | ||
4228 | } | ||
4229 | } | ||
4230 | |||
4231 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
4232 | |||
4233 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
4234 | if (nodes.Count > 0) | ||
4235 | { | ||
4236 | foreach (XmlNode n in nodes) | ||
4237 | { | ||
4238 | XmlElement elem = (XmlElement)n; | ||
4239 | string itemID = elem.GetAttribute("ItemID"); | ||
4240 | string xml = elem.InnerXml; | ||
4241 | |||
4242 | itemData[new UUID(itemID)] = xml; | ||
4243 | } | ||
4244 | } | ||
4245 | |||
3703 | List<int> attPoints = m_appearance.GetAttachedPoints(); | 4246 | List<int> attPoints = m_appearance.GetAttachedPoints(); |
3704 | foreach (int p in attPoints) | 4247 | foreach (int p in attPoints) |
3705 | { | 4248 | { |
@@ -3719,9 +4262,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3719 | 4262 | ||
3720 | try | 4263 | try |
3721 | { | 4264 | { |
3722 | // Rez from inventory | 4265 | string xmlData; |
3723 | UUID asset | 4266 | XmlDocument d = new XmlDocument(); |
3724 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p); | 4267 | UUID asset; |
4268 | if (itemData.TryGetValue(itemID, out xmlData)) | ||
4269 | { | ||
4270 | d.LoadXml(xmlData); | ||
4271 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); | ||
4272 | |||
4273 | // Rez from inventory | ||
4274 | asset | ||
4275 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); | ||
4276 | |||
4277 | } | ||
4278 | else | ||
4279 | { | ||
4280 | // Rez from inventory (with a null doc to let | ||
4281 | // CHANGED_OWNER happen) | ||
4282 | asset | ||
4283 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); | ||
4284 | } | ||
3725 | 4285 | ||
3726 | m_log.InfoFormat( | 4286 | m_log.InfoFormat( |
3727 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | 4287 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", |
@@ -3758,5 +4318,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3758 | m_reprioritization_called = false; | 4318 | m_reprioritization_called = false; |
3759 | } | 4319 | } |
3760 | } | 4320 | } |
4321 | |||
4322 | private Vector3 Quat2Euler(Quaternion rot){ | ||
4323 | float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , | ||
4324 | (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); | ||
4325 | float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); | ||
4326 | float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , | ||
4327 | (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); | ||
4328 | return(new Vector3(x,y,z)); | ||
4329 | } | ||
4330 | |||
4331 | |||
3761 | } | 4332 | } |
3762 | } | 4333 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 5bdaa17..77e477f 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -105,7 +105,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
105 | sceneObject.AddPart(part); | 105 | sceneObject.AddPart(part); |
106 | part.LinkNum = linkNum; | 106 | part.LinkNum = linkNum; |
107 | part.TrimPermissions(); | 107 | part.TrimPermissions(); |
108 | part.StoreUndoState(); | 108 | part.StoreUndoState(UndoType.STATE_ALL); |
109 | reader.Close(); | 109 | reader.Close(); |
110 | sr.Close(); | 110 | sr.Close(); |
111 | } | 111 | } |
@@ -231,7 +231,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
231 | if (originalLinkNum != 0) | 231 | if (originalLinkNum != 0) |
232 | part.LinkNum = originalLinkNum; | 232 | part.LinkNum = originalLinkNum; |
233 | 233 | ||
234 | part.StoreUndoState(); | 234 | part.StoreUndoState(UndoType.STATE_ALL); |
235 | reader.Close(); | 235 | reader.Close(); |
236 | sr.Close(); | 236 | sr.Close(); |
237 | } | 237 | } |
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 55e407e..f71b507 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs | |||
@@ -27,48 +27,125 @@ | |||
27 | 27 | ||
28 | using OpenMetaverse; | 28 | using OpenMetaverse; |
29 | using OpenSim.Region.Framework.Interfaces; | 29 | using OpenSim.Region.Framework.Interfaces; |
30 | using System; | ||
30 | 31 | ||
31 | namespace OpenSim.Region.Framework.Scenes | 32 | namespace OpenSim.Region.Framework.Scenes |
32 | { | 33 | { |
34 | [Flags] | ||
35 | public enum UndoType | ||
36 | { | ||
37 | STATE_PRIM_POSITION = 1, | ||
38 | STATE_PRIM_ROTATION = 2, | ||
39 | STATE_PRIM_SCALE = 4, | ||
40 | STATE_PRIM_ALL = 7, | ||
41 | STATE_GROUP_POSITION = 8, | ||
42 | STATE_GROUP_ROTATION = 16, | ||
43 | STATE_GROUP_SCALE = 32, | ||
44 | STATE_GROUP_ALL = 56, | ||
45 | STATE_ALL = 63 | ||
46 | } | ||
47 | |||
33 | public class UndoState | 48 | public class UndoState |
34 | { | 49 | { |
35 | public Vector3 Position = Vector3.Zero; | 50 | public Vector3 Position = Vector3.Zero; |
36 | public Vector3 Scale = Vector3.Zero; | 51 | public Vector3 Scale = Vector3.Zero; |
37 | public Quaternion Rotation = Quaternion.Identity; | 52 | public Quaternion Rotation = Quaternion.Identity; |
53 | public Vector3 GroupPosition = Vector3.Zero; | ||
54 | public Quaternion GroupRotation = Quaternion.Identity; | ||
55 | public Vector3 GroupScale = Vector3.Zero; | ||
56 | public DateTime LastUpdated = DateTime.Now; | ||
57 | public UndoType Type; | ||
38 | 58 | ||
39 | public UndoState(SceneObjectPart part) | 59 | public UndoState(SceneObjectPart part, UndoType type) |
40 | { | 60 | { |
61 | Type = type; | ||
41 | if (part != null) | 62 | if (part != null) |
42 | { | 63 | { |
43 | if (part.ParentID == 0) | 64 | if (part.ParentID == 0) |
44 | { | 65 | { |
45 | Position = part.ParentGroup.AbsolutePosition; | 66 | GroupScale = part.ParentGroup.RootPart.Shape.Scale; |
67 | |||
68 | //FUBAR WARNING: Do NOT get the group's absoluteposition here | ||
69 | //or you'll experience a loop and/or a stack issue | ||
70 | GroupPosition = part.ParentGroup.RootPart.AbsolutePosition; | ||
71 | GroupRotation = part.ParentGroup.GroupRotation; | ||
72 | Position = part.ParentGroup.RootPart.AbsolutePosition; | ||
46 | Rotation = part.RotationOffset; | 73 | Rotation = part.RotationOffset; |
47 | Scale = part.Shape.Scale; | 74 | Scale = part.Shape.Scale; |
75 | LastUpdated = DateTime.Now; | ||
48 | } | 76 | } |
49 | else | 77 | else |
50 | { | 78 | { |
79 | GroupScale = part.Shape.Scale; | ||
80 | |||
81 | //FUBAR WARNING: Do NOT get the group's absoluteposition here | ||
82 | //or you'll experience a loop and/or a stack issue | ||
83 | GroupPosition = part.ParentGroup.RootPart.AbsolutePosition; | ||
84 | GroupRotation = part.ParentGroup.Rotation; | ||
51 | Position = part.OffsetPosition; | 85 | Position = part.OffsetPosition; |
52 | Rotation = part.RotationOffset; | 86 | Rotation = part.RotationOffset; |
53 | Scale = part.Shape.Scale; | 87 | Scale = part.Shape.Scale; |
88 | LastUpdated = DateTime.Now; | ||
54 | } | 89 | } |
55 | } | 90 | } |
56 | } | 91 | } |
57 | 92 | public void Merge(UndoState last) | |
93 | { | ||
94 | if ((Type & UndoType.STATE_GROUP_POSITION) == 0 || ((last.Type & UndoType.STATE_GROUP_POSITION) >= (Type & UndoType.STATE_GROUP_POSITION))) | ||
95 | { | ||
96 | GroupPosition = last.GroupPosition; | ||
97 | Position = last.Position; | ||
98 | } | ||
99 | if ((Type & UndoType.STATE_GROUP_SCALE) == 0 || ((last.Type & UndoType.STATE_GROUP_SCALE) >= (Type & UndoType.STATE_GROUP_SCALE))) | ||
100 | { | ||
101 | GroupScale = last.GroupScale; | ||
102 | Scale = last.Scale; | ||
103 | } | ||
104 | if ((Type & UndoType.STATE_GROUP_ROTATION) == 0 || ((last.Type & UndoType.STATE_GROUP_ROTATION) >= (Type & UndoType.STATE_GROUP_ROTATION))) | ||
105 | { | ||
106 | GroupRotation = last.GroupRotation; | ||
107 | Rotation = last.Rotation; | ||
108 | } | ||
109 | if ((Type & UndoType.STATE_PRIM_POSITION) == 0 || ((last.Type & UndoType.STATE_PRIM_POSITION) >= (Type & UndoType.STATE_PRIM_POSITION))) | ||
110 | { | ||
111 | Position = last.Position; | ||
112 | } | ||
113 | if ((Type & UndoType.STATE_PRIM_SCALE) == 0 || ((last.Type & UndoType.STATE_PRIM_SCALE) >= (Type & UndoType.STATE_PRIM_SCALE))) | ||
114 | { | ||
115 | Scale = last.Scale; | ||
116 | } | ||
117 | if ((Type & UndoType.STATE_PRIM_ROTATION) == 0 || ((last.Type & UndoType.STATE_PRIM_ROTATION) >= (Type & UndoType.STATE_PRIM_ROTATION))) | ||
118 | { | ||
119 | Rotation = last.Rotation; | ||
120 | } | ||
121 | Type = Type | last.Type; | ||
122 | } | ||
123 | public bool Compare(UndoState undo) | ||
124 | { | ||
125 | if (undo == null || Position == null) return false; | ||
126 | if (undo.Position == Position && undo.Rotation == Rotation && undo.Scale == Scale && undo.GroupPosition == GroupPosition && undo.GroupScale == GroupScale && undo.GroupRotation == GroupRotation) | ||
127 | { | ||
128 | return true; | ||
129 | } | ||
130 | else | ||
131 | { | ||
132 | return false; | ||
133 | } | ||
134 | } | ||
58 | public bool Compare(SceneObjectPart part) | 135 | public bool Compare(SceneObjectPart part) |
59 | { | 136 | { |
60 | if (part != null) | 137 | if (part != null) |
61 | { | 138 | { |
62 | if (part.ParentID == 0) | 139 | if (part.ParentID == 0) |
63 | { | 140 | { |
64 | if (Position == part.ParentGroup.AbsolutePosition && Rotation == part.ParentGroup.Rotation) | 141 | if (Position == part.ParentGroup.RootPart.AbsolutePosition && Rotation == part.ParentGroup.Rotation && GroupPosition == part.ParentGroup.RootPart.AbsolutePosition && part.ParentGroup.Rotation == GroupRotation && part.Shape.Scale == GroupScale) |
65 | return true; | 142 | return true; |
66 | else | 143 | else |
67 | return false; | 144 | return false; |
68 | } | 145 | } |
69 | else | 146 | else |
70 | { | 147 | { |
71 | if (Position == part.OffsetPosition && Rotation == part.RotationOffset && Scale == part.Shape.Scale) | 148 | if (Position == part.OffsetPosition && Rotation == part.RotationOffset && Scale == part.Shape.Scale && GroupPosition == part.ParentGroup.RootPart.AbsolutePosition && part.ParentGroup.Rotation == GroupRotation && part.Shape.Scale == GroupScale) |
72 | return true; | 149 | return true; |
73 | else | 150 | else |
74 | return false; | 151 | return false; |
@@ -78,62 +155,70 @@ namespace OpenSim.Region.Framework.Scenes | |||
78 | return false; | 155 | return false; |
79 | } | 156 | } |
80 | 157 | ||
81 | public void PlaybackState(SceneObjectPart part) | 158 | private void RestoreState(SceneObjectPart part) |
82 | { | 159 | { |
160 | bool GroupChange = false; | ||
161 | if ((Type & UndoType.STATE_GROUP_POSITION) != 0 | ||
162 | || (Type & UndoType.STATE_GROUP_ROTATION) != 0 | ||
163 | || (Type & UndoType.STATE_GROUP_SCALE) != 0) | ||
164 | { | ||
165 | GroupChange = true; | ||
166 | } | ||
167 | |||
83 | if (part != null) | 168 | if (part != null) |
84 | { | 169 | { |
85 | part.Undoing = true; | 170 | part.Undoing = true; |
86 | 171 | ||
87 | if (part.ParentID == 0) | 172 | if (part.ParentID == 0 && GroupChange == false) |
88 | { | 173 | { |
89 | if (Position != Vector3.Zero) | 174 | if (Position != Vector3.Zero) |
90 | part.ParentGroup.AbsolutePosition = Position; | 175 | |
91 | part.RotationOffset = Rotation; | 176 | part.ParentGroup.UpdateSinglePosition(Position, part.LocalId); |
177 | part.ParentGroup.UpdateSingleRotation(Rotation, part.LocalId); | ||
92 | if (Scale != Vector3.Zero) | 178 | if (Scale != Vector3.Zero) |
93 | part.Resize(Scale); | 179 | part.Resize(Scale); |
94 | part.ParentGroup.ScheduleGroupForTerseUpdate(); | 180 | part.ParentGroup.ScheduleGroupForTerseUpdate(); |
95 | } | 181 | } |
96 | else | 182 | else |
97 | { | 183 | { |
98 | if (Position != Vector3.Zero) | 184 | if (GroupChange) |
99 | part.OffsetPosition = Position; | 185 | { |
100 | part.UpdateRotation(Rotation); | 186 | part.ParentGroup.RootPart.Undoing = true; |
101 | if (Scale != Vector3.Zero) | 187 | if (GroupPosition != Vector3.Zero) |
102 | part.Resize(Scale); part.ScheduleTerseUpdate(); | 188 | { |
189 | //Calculate the scale... | ||
190 | Vector3 gs = part.Shape.Scale; | ||
191 | float scale = GroupScale.Z / gs.Z; | ||
192 | |||
193 | //Scale first since it can affect our position | ||
194 | part.ParentGroup.GroupResize(gs * scale, part.LocalId); | ||
195 | part.ParentGroup.AbsolutePosition = GroupPosition; | ||
196 | part.ParentGroup.UpdateGroupRotationR(GroupRotation); | ||
197 | |||
198 | } | ||
199 | part.ParentGroup.RootPart.Undoing = false; | ||
200 | } | ||
201 | else | ||
202 | { | ||
203 | if (Position != Vector3.Zero) //We can use this for all the updates since all are set | ||
204 | { | ||
205 | part.OffsetPosition = Position; | ||
206 | part.UpdateRotation(Rotation); | ||
207 | part.Resize(Scale); part.ScheduleTerseUpdate(); | ||
208 | } | ||
209 | } | ||
103 | } | 210 | } |
104 | part.Undoing = false; | 211 | part.Undoing = false; |
105 | 212 | ||
106 | } | 213 | } |
107 | } | 214 | } |
215 | public void PlaybackState(SceneObjectPart part) | ||
216 | { | ||
217 | RestoreState(part); | ||
218 | } | ||
108 | public void PlayfwdState(SceneObjectPart part) | 219 | public void PlayfwdState(SceneObjectPart part) |
109 | { | 220 | { |
110 | if (part != null) | 221 | RestoreState(part); |
111 | { | ||
112 | part.Undoing = true; | ||
113 | |||
114 | if (part.ParentID == 0) | ||
115 | { | ||
116 | if (Position != Vector3.Zero) | ||
117 | part.ParentGroup.AbsolutePosition = Position; | ||
118 | if (Rotation != Quaternion.Identity) | ||
119 | part.UpdateRotation(Rotation); | ||
120 | if (Scale != Vector3.Zero) | ||
121 | part.Resize(Scale); | ||
122 | part.ParentGroup.ScheduleGroupForTerseUpdate(); | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | if (Position != Vector3.Zero) | ||
127 | part.OffsetPosition = Position; | ||
128 | if (Rotation != Quaternion.Identity) | ||
129 | part.UpdateRotation(Rotation); | ||
130 | if (Scale != Vector3.Zero) | ||
131 | part.Resize(Scale); | ||
132 | part.ScheduleTerseUpdate(); | ||
133 | } | ||
134 | part.Undoing = false; | ||
135 | |||
136 | } | ||
137 | } | 222 | } |
138 | } | 223 | } |
139 | public class LandUndoState | 224 | public class LandUndoState |
@@ -161,3 +246,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
161 | } | 246 | } |
162 | } | 247 | } |
163 | } | 248 | } |
249 | |||