diff options
Diffstat (limited to 'OpenSim/Region/Framework')
21 files changed, 2462 insertions, 862 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 de4c5fb..702a1e2 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 9db2e41..e060c05 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; |
@@ -716,6 +720,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
716 | } | 720 | } |
717 | } | 721 | } |
718 | } | 722 | } |
723 | public void TriggerTerrainUpdate() | ||
724 | { | ||
725 | OnTerrainUpdateDelegate handlerTerrainUpdate = OnTerrainUpdate; | ||
726 | if (handlerTerrainUpdate != null) | ||
727 | { | ||
728 | foreach (OnTerrainUpdateDelegate d in handlerTerrainUpdate.GetInvocationList()) | ||
729 | { | ||
730 | try | ||
731 | { | ||
732 | d(); | ||
733 | } | ||
734 | catch (Exception e) | ||
735 | { | ||
736 | m_log.ErrorFormat( | ||
737 | "[EVENT MANAGER]: Delegate for TriggerTerrainUpdate failed - continuing. {0} {1}", | ||
738 | e.Message, e.StackTrace); | ||
739 | } | ||
740 | } | ||
741 | } | ||
742 | } | ||
719 | 743 | ||
720 | public void TriggerTerrainTick() | 744 | public void TriggerTerrainTick() |
721 | { | 745 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index de3c360..8cd0160 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs | |||
@@ -211,12 +211,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
211 | 211 | ||
212 | if (entity is SceneObjectPart) | 212 | if (entity is SceneObjectPart) |
213 | { | 213 | { |
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) | 214 | if (((SceneObjectPart)entity).ParentGroup.RootPart.IsAttachment) |
215 | { | ||
219 | priority = 1.0; | 216 | priority = 1.0; |
217 | } | ||
218 | else | ||
219 | { | ||
220 | PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; | ||
221 | if (physActor == null || !physActor.IsPhysical) | ||
222 | priority += 100; | ||
223 | } | ||
224 | |||
225 | if (((SceneObjectPart)entity).ParentGroup.RootPart != (SceneObjectPart)entity) | ||
226 | priority +=1; | ||
220 | } | 227 | } |
221 | return priority; | 228 | return priority; |
222 | } | 229 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 01edf51..59731f7 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 | { |
@@ -913,8 +928,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
913 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) | 928 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) |
914 | { | 929 | { |
915 | SceneObjectPart part = GetSceneObjectPart(localID); | 930 | SceneObjectPart part = GetSceneObjectPart(localID); |
916 | SceneObjectGroup group = part.ParentGroup; | 931 | SceneObjectGroup group = null; |
917 | if (group != null) | 932 | if (part != null) |
933 | { | ||
934 | group = part.ParentGroup; | ||
935 | } | ||
936 | if (part != null && group != null) | ||
918 | { | 937 | { |
919 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) | 938 | if (!Permissions.CanEditObjectInventory(part.UUID, remoteClient.AgentId)) |
920 | return; | 939 | return; |
@@ -1489,7 +1508,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1489 | return; | 1508 | return; |
1490 | 1509 | ||
1491 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, | 1510 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1492 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | 1511 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n\n touch_start(integer num)\n {\n }\n}"), |
1493 | remoteClient.AgentId); | 1512 | remoteClient.AgentId); |
1494 | AssetService.Store(asset); | 1513 | AssetService.Store(asset); |
1495 | 1514 | ||
@@ -1684,11 +1703,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1684 | // Invalid id | 1703 | // Invalid id |
1685 | SceneObjectPart part = GetSceneObjectPart(localID); | 1704 | SceneObjectPart part = GetSceneObjectPart(localID); |
1686 | if (part == null) | 1705 | if (part == null) |
1706 | { | ||
1707 | //Client still thinks the object exists, kill it | ||
1708 | SendKillObject(localID); | ||
1687 | continue; | 1709 | continue; |
1710 | } | ||
1688 | 1711 | ||
1689 | // Already deleted by someone else | 1712 | // Already deleted by someone else |
1690 | if (part.ParentGroup == null || part.ParentGroup.IsDeleted) | 1713 | if (part.ParentGroup == null || part.ParentGroup.IsDeleted) |
1714 | { | ||
1715 | //Client still thinks the object exists, kill it | ||
1716 | SendKillObject(localID); | ||
1691 | continue; | 1717 | continue; |
1718 | } | ||
1692 | 1719 | ||
1693 | // Can't delete child prims | 1720 | // Can't delete child prims |
1694 | if (part != part.ParentGroup.RootPart) | 1721 | if (part != part.ParentGroup.RootPart) |
@@ -1715,15 +1742,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1715 | } | 1742 | } |
1716 | else | 1743 | else |
1717 | { | 1744 | { |
1718 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 1745 | if (action == DeRezAction.TakeCopy) |
1746 | { | ||
1747 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
1748 | permissionToTakeCopy = false; | ||
1749 | } | ||
1750 | else | ||
1751 | { | ||
1719 | permissionToTakeCopy = false; | 1752 | permissionToTakeCopy = false; |
1753 | } | ||
1720 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 1754 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
1721 | permissionToTake = false; | 1755 | permissionToTake = false; |
1722 | 1756 | ||
1723 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 1757 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
1724 | permissionToDelete = false; | 1758 | permissionToDelete = false; |
1725 | } | 1759 | } |
1726 | |||
1727 | } | 1760 | } |
1728 | 1761 | ||
1729 | // Handle god perms | 1762 | // Handle god perms |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 93f684c..644fbb0 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 | ||
@@ -608,6 +623,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
608 | 623 | ||
609 | // Load region settings | 624 | // Load region settings |
610 | m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); | 625 | m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); |
626 | m_regInfo.WindlightSettings = m_storageManager.DataStore.LoadRegionWindlightSettings(m_regInfo.RegionID); | ||
627 | |||
611 | if (m_storageManager.EstateDataStore != null) | 628 | if (m_storageManager.EstateDataStore != null) |
612 | { | 629 | { |
613 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); | 630 | m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); |
@@ -710,7 +727,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
710 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 727 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
711 | // TODO: Change default to true once the feature is supported | 728 | // TODO: Change default to true once the feature is supported |
712 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); | 729 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); |
713 | 730 | m_usePreJump = true; // Above line fails!? | |
714 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 731 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
715 | if (RegionInfo.NonphysPrimMax > 0) | 732 | if (RegionInfo.NonphysPrimMax > 0) |
716 | { | 733 | { |
@@ -752,6 +769,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
752 | } | 769 | } |
753 | 770 | ||
754 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 771 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
772 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
755 | 773 | ||
756 | #region BinaryStats | 774 | #region BinaryStats |
757 | 775 | ||
@@ -1024,6 +1042,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1024 | /// <param name="seconds">float indicating duration before restart.</param> | 1042 | /// <param name="seconds">float indicating duration before restart.</param> |
1025 | public virtual void Restart(float seconds) | 1043 | public virtual void Restart(float seconds) |
1026 | { | 1044 | { |
1045 | Restart(seconds, true); | ||
1046 | } | ||
1047 | |||
1048 | /// <summary> | ||
1049 | /// Given float seconds, this will restart the region. showDialog will optionally alert the users. | ||
1050 | /// </summary> | ||
1051 | /// <param name="seconds">float indicating duration before restart.</param> | ||
1052 | public virtual void Restart(float seconds, bool showDialog) | ||
1053 | { | ||
1027 | // notifications are done in 15 second increments | 1054 | // notifications are done in 15 second increments |
1028 | // so .. if the number of seconds is less then 15 seconds, it's not really a restart request | 1055 | // so .. if the number of seconds is less then 15 seconds, it's not really a restart request |
1029 | // It's a 'Cancel restart' request. | 1056 | // It's a 'Cancel restart' request. |
@@ -1044,8 +1071,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1044 | m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); | 1071 | m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); |
1045 | m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); | 1072 | m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); |
1046 | m_restartTimer.Start(); | 1073 | m_restartTimer.Start(); |
1047 | m_dialogModule.SendNotificationToUsersInRegion( | 1074 | if (showDialog) |
1075 | { | ||
1076 | m_dialogModule.SendNotificationToUsersInRegion( | ||
1048 | UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0))); | 1077 | UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0))); |
1078 | } | ||
1049 | } | 1079 | } |
1050 | } | 1080 | } |
1051 | 1081 | ||
@@ -1403,16 +1433,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1403 | // Check if any objects have reached their targets | 1433 | // Check if any objects have reached their targets |
1404 | CheckAtTargets(); | 1434 | CheckAtTargets(); |
1405 | 1435 | ||
1406 | // Update SceneObjectGroups that have scheduled themselves for updates | ||
1407 | // Objects queue their updates onto all scene presences | ||
1408 | if (m_frame % m_update_objects == 0) | ||
1409 | m_sceneGraph.UpdateObjectGroups(); | ||
1410 | |||
1411 | // Run through all ScenePresences looking for updates | 1436 | // Run through all ScenePresences looking for updates |
1412 | // Presence updates and queued object updates for each presence are sent to clients | 1437 | // Presence updates and queued object updates for each presence are sent to clients |
1413 | if (m_frame % m_update_presences == 0) | 1438 | if (m_frame % m_update_presences == 0) |
1414 | m_sceneGraph.UpdatePresences(); | 1439 | m_sceneGraph.UpdatePresences(); |
1415 | 1440 | ||
1441 | // Update SceneObjectGroups that have scheduled themselves for updates | ||
1442 | // Objects queue their updates onto all scene presences | ||
1443 | if (m_frame % m_update_objects == 0) | ||
1444 | m_sceneGraph.UpdateObjectGroups(); | ||
1445 | |||
1416 | if (m_frame % m_update_coarse_locations == 0) | 1446 | if (m_frame % m_update_coarse_locations == 0) |
1417 | { | 1447 | { |
1418 | List<Vector3> coarseLocations; | 1448 | List<Vector3> coarseLocations; |
@@ -1741,6 +1771,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1741 | public void StoreWindlightProfile(RegionLightShareData wl) | 1771 | public void StoreWindlightProfile(RegionLightShareData wl) |
1742 | { | 1772 | { |
1743 | m_regInfo.WindlightSettings = wl; | 1773 | m_regInfo.WindlightSettings = wl; |
1774 | wl.Save(); | ||
1744 | m_storageManager.DataStore.StoreRegionWindlightSettings(wl); | 1775 | m_storageManager.DataStore.StoreRegionWindlightSettings(wl); |
1745 | m_eventManager.TriggerOnSaveNewWindlightProfile(); | 1776 | m_eventManager.TriggerOnSaveNewWindlightProfile(); |
1746 | } | 1777 | } |
@@ -1921,14 +1952,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1921 | /// <returns></returns> | 1952 | /// <returns></returns> |
1922 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1953 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1923 | { | 1954 | { |
1955 | |||
1956 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1957 | Vector3 wpos = Vector3.Zero; | ||
1958 | // Check for water surface intersection from above | ||
1959 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1960 | { | ||
1961 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1962 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1963 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1964 | wpos.Z = wheight; | ||
1965 | } | ||
1966 | |||
1924 | Vector3 pos = Vector3.Zero; | 1967 | Vector3 pos = Vector3.Zero; |
1925 | if (RayEndIsIntersection == (byte)1) | 1968 | if (RayEndIsIntersection == (byte)1) |
1926 | { | 1969 | { |
1927 | pos = RayEnd; | 1970 | pos = RayEnd; |
1928 | return pos; | ||
1929 | } | 1971 | } |
1930 | 1972 | else if (RayTargetID != UUID.Zero) | |
1931 | if (RayTargetID != UUID.Zero) | ||
1932 | { | 1973 | { |
1933 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1974 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1934 | 1975 | ||
@@ -1950,7 +1991,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1950 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1991 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1951 | 1992 | ||
1952 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1993 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1953 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1994 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1954 | float ScaleOffset = 0.5f; | 1995 | float ScaleOffset = 0.5f; |
1955 | 1996 | ||
1956 | // If we hit something | 1997 | // If we hit something |
@@ -1973,13 +2014,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1973 | //pos.Z -= 0.25F; | 2014 | //pos.Z -= 0.25F; |
1974 | 2015 | ||
1975 | } | 2016 | } |
1976 | |||
1977 | return pos; | ||
1978 | } | 2017 | } |
1979 | else | 2018 | else |
1980 | { | 2019 | { |
1981 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2020 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1982 | |||
1983 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2021 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1984 | 2022 | ||
1985 | // Un-comment the following line to print the raytrace results to the console. | 2023 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1988,13 +2026,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1988 | if (ei.HitTF) | 2026 | if (ei.HitTF) |
1989 | { | 2027 | { |
1990 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2028 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1991 | } else | 2029 | } |
2030 | else | ||
1992 | { | 2031 | { |
1993 | // fall back to our stupid functionality | 2032 | // fall back to our stupid functionality |
1994 | pos = RayEnd; | 2033 | pos = RayEnd; |
1995 | } | 2034 | } |
1996 | |||
1997 | return pos; | ||
1998 | } | 2035 | } |
1999 | } | 2036 | } |
2000 | else | 2037 | else |
@@ -2005,8 +2042,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2005 | //increase height so its above the ground. | 2042 | //increase height so its above the ground. |
2006 | //should be getting the normal of the ground at the rez point and using that? | 2043 | //should be getting the normal of the ground at the rez point and using that? |
2007 | pos.Z += scale.Z / 2f; | 2044 | pos.Z += scale.Z / 2f; |
2008 | return pos; | 2045 | // return pos; |
2009 | } | 2046 | } |
2047 | |||
2048 | // check against posible water intercept | ||
2049 | if (wpos.Z > pos.Z) pos = wpos; | ||
2050 | return pos; | ||
2010 | } | 2051 | } |
2011 | 2052 | ||
2012 | 2053 | ||
@@ -2139,13 +2180,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2139 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) | 2180 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
2140 | { | 2181 | { |
2141 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); | 2182 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); |
2142 | } | 2183 | } |
2143 | 2184 | ||
2144 | /// <summary> | 2185 | /// <summary> |
2145 | /// Delete every object from the scene. This does not include attachments worn by avatars. | 2186 | /// Delete every object from the scene. This does not include attachments worn by avatars. |
2146 | /// </summary> | 2187 | /// </summary> |
2147 | public void DeleteAllSceneObjects() | 2188 | public void DeleteAllSceneObjects() |
2148 | { | 2189 | { |
2190 | DeleteAllSceneObjects(false); | ||
2191 | } | ||
2192 | |||
2193 | /// <summary> | ||
2194 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2195 | /// </summary> | ||
2196 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2197 | { | ||
2198 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2149 | lock (Entities) | 2199 | lock (Entities) |
2150 | { | 2200 | { |
2151 | ICollection<EntityBase> entities = new List<EntityBase>(Entities); | 2201 | ICollection<EntityBase> entities = new List<EntityBase>(Entities); |
@@ -2155,11 +2205,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2155 | if (e is SceneObjectGroup) | 2205 | if (e is SceneObjectGroup) |
2156 | { | 2206 | { |
2157 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2207 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2158 | if (!sog.IsAttachment) | 2208 | if (sog != null && !sog.IsAttachment) |
2159 | DeleteSceneObject((SceneObjectGroup)e, false); | 2209 | { |
2210 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2211 | { | ||
2212 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2213 | } | ||
2214 | else | ||
2215 | { | ||
2216 | toReturn.Add((SceneObjectGroup)e); | ||
2217 | } | ||
2218 | } | ||
2160 | } | 2219 | } |
2161 | } | 2220 | } |
2162 | } | 2221 | } |
2222 | if (toReturn.Count > 0) | ||
2223 | { | ||
2224 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2225 | } | ||
2163 | } | 2226 | } |
2164 | 2227 | ||
2165 | /// <summary> | 2228 | /// <summary> |
@@ -3146,6 +3209,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3146 | /// <param name="flags"></param> | 3209 | /// <param name="flags"></param> |
3147 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3210 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3148 | { | 3211 | { |
3212 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3213 | ScenePresence presence; | ||
3214 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3215 | { | ||
3216 | if (presence.Appearance != null) | ||
3217 | { | ||
3218 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3219 | } | ||
3220 | } | ||
3221 | |||
3149 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3222 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3150 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3223 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3151 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3224 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3533,6 +3606,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3533 | } | 3606 | } |
3534 | } | 3607 | } |
3535 | // Honor parcel landing type and position. | 3608 | // Honor parcel landing type and position. |
3609 | /* | ||
3610 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3536 | if (land != null) | 3611 | if (land != null) |
3537 | { | 3612 | { |
3538 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3613 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3540,6 +3615,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3540 | agent.startpos = land.LandData.UserLocation; | 3615 | agent.startpos = land.LandData.UserLocation; |
3541 | } | 3616 | } |
3542 | } | 3617 | } |
3618 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3543 | } | 3619 | } |
3544 | 3620 | ||
3545 | return true; | 3621 | return true; |
@@ -3902,12 +3978,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3902 | return false; | 3978 | return false; |
3903 | } | 3979 | } |
3904 | 3980 | ||
3981 | public bool IncomingCloseAgent(UUID agentID) | ||
3982 | { | ||
3983 | return IncomingCloseAgent(agentID, false); | ||
3984 | } | ||
3985 | |||
3986 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3987 | { | ||
3988 | return IncomingCloseAgent(agentID, true); | ||
3989 | } | ||
3990 | |||
3905 | /// <summary> | 3991 | /// <summary> |
3906 | /// Tell a single agent to disconnect from the region. | 3992 | /// Tell a single agent to disconnect from the region. |
3907 | /// </summary> | 3993 | /// </summary> |
3908 | /// <param name="regionHandle"></param> | ||
3909 | /// <param name="agentID"></param> | 3994 | /// <param name="agentID"></param> |
3910 | public bool IncomingCloseAgent(UUID agentID) | 3995 | /// <param name="childOnly"></param> |
3996 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3911 | { | 3997 | { |
3912 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3998 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3913 | 3999 | ||
@@ -3919,7 +4005,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3919 | { | 4005 | { |
3920 | m_sceneGraph.removeUserCount(false); | 4006 | m_sceneGraph.removeUserCount(false); |
3921 | } | 4007 | } |
3922 | else | 4008 | else if (!childOnly) |
3923 | { | 4009 | { |
3924 | m_sceneGraph.removeUserCount(true); | 4010 | m_sceneGraph.removeUserCount(true); |
3925 | } | 4011 | } |
@@ -3935,9 +4021,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3935 | } | 4021 | } |
3936 | else | 4022 | else |
3937 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4023 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4024 | presence.ControllingClient.Close(false); | ||
4025 | } | ||
4026 | else if (!childOnly) | ||
4027 | { | ||
4028 | presence.ControllingClient.Close(true); | ||
3938 | } | 4029 | } |
3939 | |||
3940 | presence.ControllingClient.Close(); | ||
3941 | return true; | 4030 | return true; |
3942 | } | 4031 | } |
3943 | 4032 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index c675322..a9ecde8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -274,7 +274,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
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 f47450f..c0ec5df 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 | { |
@@ -264,6 +278,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
264 | protected internal bool AddRestoredSceneObject( | 278 | protected internal bool AddRestoredSceneObject( |
265 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 279 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
266 | { | 280 | { |
281 | if (!m_parentScene.CombineRegions) | ||
282 | { | ||
283 | // KF: Check for out-of-region, move inside and make static. | ||
284 | Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, | ||
285 | sceneObject.RootPart.GroupPosition.Y, | ||
286 | sceneObject.RootPart.GroupPosition.Z); | ||
287 | 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 || | ||
288 | npos.X > Constants.RegionSize || | ||
289 | npos.Y > Constants.RegionSize)) | ||
290 | { | ||
291 | if (npos.X < 0.0) npos.X = 1.0f; | ||
292 | if (npos.Y < 0.0) npos.Y = 1.0f; | ||
293 | if (npos.Z < 0.0) npos.Z = 0.0f; | ||
294 | if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; | ||
295 | if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; | ||
296 | |||
297 | foreach (SceneObjectPart part in sceneObject.Children.Values) | ||
298 | { | ||
299 | part.GroupPosition = npos; | ||
300 | } | ||
301 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
302 | sceneObject.RootPart.AngularVelocity = Vector3.Zero; | ||
303 | sceneObject.RootPart.Acceleration = Vector3.Zero; | ||
304 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
305 | } | ||
306 | } | ||
307 | |||
267 | if (!alreadyPersisted) | 308 | if (!alreadyPersisted) |
268 | { | 309 | { |
269 | sceneObject.ForceInventoryPersistence(); | 310 | sceneObject.ForceInventoryPersistence(); |
@@ -354,10 +395,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
354 | m_numPrim += sceneObject.Children.Count; | 395 | m_numPrim += sceneObject.Children.Count; |
355 | 396 | ||
356 | if (attachToBackup) | 397 | if (attachToBackup) |
398 | { | ||
357 | sceneObject.AttachToBackup(); | 399 | sceneObject.AttachToBackup(); |
400 | } | ||
358 | 401 | ||
359 | if (OnObjectCreate != null) | 402 | if (OnObjectCreate != null) |
403 | { | ||
360 | OnObjectCreate(sceneObject); | 404 | OnObjectCreate(sceneObject); |
405 | } | ||
361 | 406 | ||
362 | lock (m_dictionary_lock) | 407 | lock (m_dictionary_lock) |
363 | { | 408 | { |
@@ -424,6 +469,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
424 | } | 469 | } |
425 | } | 470 | } |
426 | 471 | ||
472 | public void FireAttachToBackup(SceneObjectGroup obj) | ||
473 | { | ||
474 | if (OnAttachToBackup != null) | ||
475 | { | ||
476 | OnAttachToBackup(obj); | ||
477 | } | ||
478 | } | ||
479 | |||
480 | public void FireDetachFromBackup(SceneObjectGroup obj) | ||
481 | { | ||
482 | if (OnDetachFromBackup != null) | ||
483 | { | ||
484 | OnDetachFromBackup(obj); | ||
485 | } | ||
486 | } | ||
487 | |||
488 | public void FireChangeBackup(SceneObjectGroup obj) | ||
489 | { | ||
490 | if (OnChangeBackup != null) | ||
491 | { | ||
492 | OnChangeBackup(obj); | ||
493 | } | ||
494 | } | ||
495 | |||
427 | /// <summary> | 496 | /// <summary> |
428 | /// Process all pending updates | 497 | /// Process all pending updates |
429 | /// </summary> | 498 | /// </summary> |
@@ -560,7 +629,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
560 | 629 | ||
561 | Entities[presence.UUID] = presence; | 630 | Entities[presence.UUID] = presence; |
562 | 631 | ||
563 | lock (m_presenceLock) | 632 | m_scenePresencesLock.EnterWriteLock(); |
633 | try | ||
564 | { | 634 | { |
565 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 635 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
566 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 636 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -584,6 +654,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
584 | m_scenePresenceMap = newmap; | 654 | m_scenePresenceMap = newmap; |
585 | m_scenePresenceArray = newlist; | 655 | m_scenePresenceArray = newlist; |
586 | } | 656 | } |
657 | finally | ||
658 | { | ||
659 | m_scenePresencesLock.ExitWriteLock(); | ||
660 | } | ||
587 | } | 661 | } |
588 | 662 | ||
589 | /// <summary> | 663 | /// <summary> |
@@ -598,7 +672,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
598 | agentID); | 672 | agentID); |
599 | } | 673 | } |
600 | 674 | ||
601 | lock (m_presenceLock) | 675 | m_scenePresencesLock.EnterWriteLock(); |
676 | try | ||
602 | { | 677 | { |
603 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 678 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
604 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 679 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -620,6 +695,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); | 695 | m_log.WarnFormat("[SCENE]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); |
621 | } | 696 | } |
622 | } | 697 | } |
698 | finally | ||
699 | { | ||
700 | m_scenePresencesLock.ExitWriteLock(); | ||
701 | } | ||
623 | } | 702 | } |
624 | 703 | ||
625 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) | 704 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) |
@@ -1497,10 +1576,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1497 | /// <param name="childPrims"></param> | 1576 | /// <param name="childPrims"></param> |
1498 | protected internal void LinkObjects(SceneObjectPart root, List<SceneObjectPart> children) | 1577 | protected internal void LinkObjects(SceneObjectPart root, List<SceneObjectPart> children) |
1499 | { | 1578 | { |
1579 | SceneObjectGroup parentGroup = root.ParentGroup; | ||
1580 | if (parentGroup == null) return; | ||
1500 | Monitor.Enter(m_updateLock); | 1581 | Monitor.Enter(m_updateLock); |
1582 | |||
1501 | try | 1583 | try |
1502 | { | 1584 | { |
1503 | SceneObjectGroup parentGroup = root.ParentGroup; | 1585 | parentGroup.areUpdatesSuspended = true; |
1504 | 1586 | ||
1505 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); | 1587 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); |
1506 | if (parentGroup != null) | 1588 | if (parentGroup != null) |
@@ -1539,12 +1621,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1539 | // occur on link to invoke this elsewhere (such as object selection) | 1621 | // occur on link to invoke this elsewhere (such as object selection) |
1540 | parentGroup.RootPart.CreateSelected = true; | 1622 | parentGroup.RootPart.CreateSelected = true; |
1541 | parentGroup.TriggerScriptChangedEvent(Changed.LINK); | 1623 | parentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1542 | parentGroup.HasGroupChanged = true; | ||
1543 | parentGroup.ScheduleGroupForFullUpdate(); | ||
1544 | |||
1545 | } | 1624 | } |
1546 | finally | 1625 | finally |
1547 | { | 1626 | { |
1627 | parentGroup.areUpdatesSuspended = false; | ||
1628 | parentGroup.HasGroupChanged = true; | ||
1629 | parentGroup.ScheduleGroupForFullUpdate(); | ||
1548 | Monitor.Exit(m_updateLock); | 1630 | Monitor.Exit(m_updateLock); |
1549 | } | 1631 | } |
1550 | } | 1632 | } |
@@ -1581,11 +1663,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1581 | } | 1663 | } |
1582 | } | 1664 | } |
1583 | 1665 | ||
1584 | foreach (SceneObjectPart child in childParts) | 1666 | if (childParts.Count > 0) |
1585 | { | 1667 | { |
1586 | // Unlink all child parts from their groups | 1668 | try |
1587 | // | 1669 | { |
1588 | child.ParentGroup.DelinkFromGroup(child, true); | 1670 | childParts[0].ParentGroup.areUpdatesSuspended = true; |
1671 | foreach (SceneObjectPart child in childParts) | ||
1672 | { | ||
1673 | // Unlink all child parts from their groups | ||
1674 | // | ||
1675 | child.ParentGroup.DelinkFromGroup(child, true); | ||
1676 | } | ||
1677 | } | ||
1678 | finally | ||
1679 | { | ||
1680 | childParts[0].ParentGroup.areUpdatesSuspended = false; | ||
1681 | } | ||
1589 | } | 1682 | } |
1590 | 1683 | ||
1591 | foreach (SceneObjectPart root in rootParts) | 1684 | foreach (SceneObjectPart root in rootParts) |
@@ -1609,10 +1702,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1609 | if (numChildren > 1) | 1702 | if (numChildren > 1) |
1610 | sendEventsToRemainder = false; | 1703 | sendEventsToRemainder = false; |
1611 | 1704 | ||
1612 | foreach (SceneObjectPart p in newSet) | 1705 | if (newSet.Count > 0) |
1613 | { | 1706 | { |
1614 | if (p != group.RootPart) | 1707 | try |
1615 | group.DelinkFromGroup(p, sendEventsToRemainder); | 1708 | { |
1709 | newSet[0].ParentGroup.areUpdatesSuspended = true; | ||
1710 | foreach (SceneObjectPart p in newSet) | ||
1711 | { | ||
1712 | if (p != group.RootPart) | ||
1713 | group.DelinkFromGroup(p, sendEventsToRemainder); | ||
1714 | } | ||
1715 | } | ||
1716 | finally | ||
1717 | { | ||
1718 | newSet[0].ParentGroup.areUpdatesSuspended = false; | ||
1719 | } | ||
1616 | } | 1720 | } |
1617 | 1721 | ||
1618 | // If there is more than one prim remaining, we | 1722 | // 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 17275d0..dbf493c 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -104,8 +104,104 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | /// since the group's last persistent backup | 104 | /// since the group's last persistent backup |
105 | /// </summary> | 105 | /// </summary> |
106 | private bool m_hasGroupChanged = false; | 106 | private bool m_hasGroupChanged = false; |
107 | private long timeFirstChanged; | 107 | private long timeFirstChanged = 0; |
108 | private long timeLastChanged; | 108 | private long timeLastChanged = 0; |
109 | private long m_maxPersistTime = 0; | ||
110 | private long m_minPersistTime = 0; | ||
111 | private Random m_rand; | ||
112 | private bool m_suspendUpdates; | ||
113 | private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); | ||
114 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); | ||
115 | |||
116 | public bool areUpdatesSuspended | ||
117 | { | ||
118 | get | ||
119 | { | ||
120 | return m_suspendUpdates; | ||
121 | } | ||
122 | set | ||
123 | { | ||
124 | m_suspendUpdates = value; | ||
125 | if (!value) | ||
126 | { | ||
127 | QueueForUpdateCheck(); | ||
128 | } | ||
129 | } | ||
130 | } | ||
131 | |||
132 | public void lockPartsForRead(bool locked) | ||
133 | { | ||
134 | if (locked) | ||
135 | { | ||
136 | if (m_partsLock.RecursiveReadCount > 0) | ||
137 | { | ||
138 | 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."); | ||
139 | try | ||
140 | { | ||
141 | m_partsLock.ExitReadLock(); | ||
142 | } | ||
143 | catch { } // Ignore errors, to allow resync | ||
144 | } | ||
145 | if (m_partsLock.RecursiveWriteCount > 0) | ||
146 | { | ||
147 | 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."); | ||
148 | try | ||
149 | { | ||
150 | m_partsLock.ExitWriteLock(); | ||
151 | } | ||
152 | catch { } | ||
153 | |||
154 | } | ||
155 | |||
156 | while (!m_partsLock.TryEnterReadLock(60000)) | ||
157 | { | ||
158 | 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."); | ||
159 | if (m_partsLock.IsWriteLockHeld) | ||
160 | { | ||
161 | m_partsLock = new System.Threading.ReaderWriterLockSlim(); | ||
162 | } | ||
163 | } | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | if (m_partsLock.RecursiveReadCount > 0) | ||
168 | { | ||
169 | m_partsLock.ExitReadLock(); | ||
170 | } | ||
171 | } | ||
172 | } | ||
173 | public void lockPartsForWrite(bool locked) | ||
174 | { | ||
175 | if (locked) | ||
176 | { | ||
177 | if (m_partsLock.RecursiveReadCount > 0) | ||
178 | { | ||
179 | 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."); | ||
180 | m_partsLock.ExitReadLock(); | ||
181 | } | ||
182 | if (m_partsLock.RecursiveWriteCount > 0) | ||
183 | { | ||
184 | m_log.Error("[SceneObjectGroup.m_parts] Recursive write lock requested. This should not happen and means something needs to be fixed."); | ||
185 | m_partsLock.ExitWriteLock(); | ||
186 | } | ||
187 | |||
188 | while (!m_partsLock.TryEnterWriteLock(60000)) | ||
189 | { | ||
190 | 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."); | ||
191 | if (m_partsLock.IsWriteLockHeld) | ||
192 | { | ||
193 | m_partsLock = new System.Threading.ReaderWriterLockSlim(); | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | if (m_partsLock.RecursiveWriteCount > 0) | ||
200 | { | ||
201 | m_partsLock.ExitWriteLock(); | ||
202 | } | ||
203 | } | ||
204 | } | ||
109 | 205 | ||
110 | public bool HasGroupChanged | 206 | public bool HasGroupChanged |
111 | { | 207 | { |
@@ -113,9 +209,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
113 | { | 209 | { |
114 | if (value) | 210 | if (value) |
115 | { | 211 | { |
212 | if (m_isBackedUp) | ||
213 | { | ||
214 | m_scene.SceneGraph.FireChangeBackup(this); | ||
215 | } | ||
116 | timeLastChanged = DateTime.Now.Ticks; | 216 | timeLastChanged = DateTime.Now.Ticks; |
117 | if (!m_hasGroupChanged) | 217 | if (!m_hasGroupChanged) |
118 | timeFirstChanged = DateTime.Now.Ticks; | 218 | timeFirstChanged = DateTime.Now.Ticks; |
219 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | ||
220 | { | ||
221 | if (m_rand == null) | ||
222 | { | ||
223 | byte[] val = new byte[16]; | ||
224 | m_rootPart.UUID.ToBytes(val, 0); | ||
225 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
226 | } | ||
227 | |||
228 | if (m_scene.GetRootAgentCount() == 0) | ||
229 | { | ||
230 | //If the region is empty, this change has been made by an automated process | ||
231 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
232 | |||
233 | float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
234 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); | ||
235 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); | ||
236 | } | ||
237 | else | ||
238 | { | ||
239 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
240 | //but add a random factor so we stagger the object persistance a little | ||
241 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
242 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
243 | } | ||
244 | } | ||
119 | } | 245 | } |
120 | m_hasGroupChanged = value; | 246 | m_hasGroupChanged = value; |
121 | } | 247 | } |
@@ -131,8 +257,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
131 | return false; | 257 | return false; |
132 | if (m_scene.ShuttingDown) | 258 | if (m_scene.ShuttingDown) |
133 | return true; | 259 | return true; |
260 | |||
261 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
262 | { | ||
263 | m_maxPersistTime = m_scene.m_persistAfter; | ||
264 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
265 | } | ||
266 | |||
134 | long currentTime = DateTime.Now.Ticks; | 267 | long currentTime = DateTime.Now.Ticks; |
135 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 268 | |
269 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
270 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
271 | |||
272 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
136 | return true; | 273 | return true; |
137 | return false; | 274 | return false; |
138 | } | 275 | } |
@@ -221,7 +358,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
221 | public virtual Quaternion Rotation | 358 | public virtual Quaternion Rotation |
222 | { | 359 | { |
223 | get { return m_rotation; } | 360 | get { return m_rotation; } |
224 | set { m_rotation = value; } | 361 | set { |
362 | lockPartsForRead(true); | ||
363 | try | ||
364 | { | ||
365 | foreach(SceneObjectPart p in m_parts.Values) | ||
366 | { | ||
367 | p.StoreUndoState(UndoType.STATE_GROUP_ROTATION); | ||
368 | } | ||
369 | } | ||
370 | finally | ||
371 | { | ||
372 | lockPartsForRead(false); | ||
373 | } | ||
374 | m_rotation = value; | ||
375 | } | ||
225 | } | 376 | } |
226 | 377 | ||
227 | public Quaternion GroupRotation | 378 | public Quaternion GroupRotation |
@@ -258,13 +409,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
258 | set | 409 | set |
259 | { | 410 | { |
260 | m_regionHandle = value; | 411 | m_regionHandle = value; |
261 | lock (m_parts) | 412 | lockPartsForRead(true); |
262 | { | 413 | { |
263 | foreach (SceneObjectPart part in m_parts.Values) | 414 | foreach (SceneObjectPart part in m_parts.Values) |
264 | { | 415 | { |
416 | |||
265 | part.RegionHandle = m_regionHandle; | 417 | part.RegionHandle = m_regionHandle; |
418 | |||
266 | } | 419 | } |
267 | } | 420 | } |
421 | lockPartsForRead(false); | ||
268 | } | 422 | } |
269 | } | 423 | } |
270 | 424 | ||
@@ -298,6 +452,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
298 | { | 452 | { |
299 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | 453 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); |
300 | } | 454 | } |
455 | |||
456 | lockPartsForRead(true); | ||
457 | foreach (SceneObjectPart part in m_parts.Values) | ||
458 | { | ||
459 | part.IgnoreUndoUpdate = true; | ||
460 | } | ||
301 | if (RootPart.GetStatusSandbox()) | 461 | if (RootPart.GetStatusSandbox()) |
302 | { | 462 | { |
303 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) | 463 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) |
@@ -305,16 +465,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
305 | RootPart.ScriptSetPhysicsStatus(false); | 465 | RootPart.ScriptSetPhysicsStatus(false); |
306 | Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), | 466 | Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), |
307 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); | 467 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); |
468 | lockPartsForRead(false); | ||
308 | return; | 469 | return; |
309 | } | 470 | } |
310 | } | 471 | } |
311 | lock (m_parts) | 472 | foreach (SceneObjectPart part in m_parts.Values) |
312 | { | 473 | { |
313 | foreach (SceneObjectPart part in m_parts.Values) | 474 | part.IgnoreUndoUpdate = false; |
314 | { | 475 | part.StoreUndoState(UndoType.STATE_GROUP_POSITION); |
315 | part.GroupPosition = val; | 476 | part.GroupPosition = val; |
316 | } | ||
317 | } | 477 | } |
478 | lockPartsForRead(false); | ||
318 | 479 | ||
319 | //if (m_rootPart.PhysActor != null) | 480 | //if (m_rootPart.PhysActor != null) |
320 | //{ | 481 | //{ |
@@ -457,6 +618,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
457 | /// </summary> | 618 | /// </summary> |
458 | public SceneObjectGroup() | 619 | public SceneObjectGroup() |
459 | { | 620 | { |
621 | |||
460 | } | 622 | } |
461 | 623 | ||
462 | /// <summary> | 624 | /// <summary> |
@@ -473,7 +635,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
473 | /// Constructor. This object is added to the scene later via AttachToScene() | 635 | /// Constructor. This object is added to the scene later via AttachToScene() |
474 | /// </summary> | 636 | /// </summary> |
475 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 637 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
476 | { | 638 | { |
477 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); | 639 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
478 | } | 640 | } |
479 | 641 | ||
@@ -504,13 +666,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
504 | 666 | ||
505 | public void SetFromItemID(UUID AssetId) | 667 | public void SetFromItemID(UUID AssetId) |
506 | { | 668 | { |
507 | lock (m_parts) | 669 | lockPartsForRead(true); |
508 | { | 670 | { |
509 | foreach (SceneObjectPart part in m_parts.Values) | 671 | foreach (SceneObjectPart part in m_parts.Values) |
510 | { | 672 | { |
673 | |||
511 | part.FromItemID = AssetId; | 674 | part.FromItemID = AssetId; |
675 | |||
512 | } | 676 | } |
513 | } | 677 | } |
678 | lockPartsForRead(false); | ||
514 | } | 679 | } |
515 | 680 | ||
516 | public UUID GetFromItemID() | 681 | public UUID GetFromItemID() |
@@ -523,6 +688,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
523 | /// </summary> | 688 | /// </summary> |
524 | public virtual void AttachToBackup() | 689 | public virtual void AttachToBackup() |
525 | { | 690 | { |
691 | if (IsAttachment) return; | ||
692 | m_scene.SceneGraph.FireAttachToBackup(this); | ||
693 | |||
526 | if (InSceneBackup) | 694 | if (InSceneBackup) |
527 | { | 695 | { |
528 | //m_log.DebugFormat( | 696 | //m_log.DebugFormat( |
@@ -579,7 +747,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
579 | Vector3 maxScale = Vector3.Zero; | 747 | Vector3 maxScale = Vector3.Zero; |
580 | Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); | 748 | Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); |
581 | 749 | ||
582 | lock (m_parts) | 750 | lockPartsForRead(true); |
583 | { | 751 | { |
584 | foreach (SceneObjectPart part in m_parts.Values) | 752 | foreach (SceneObjectPart part in m_parts.Values) |
585 | { | 753 | { |
@@ -593,8 +761,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
593 | maxScale.X = (partscale.X + partoffset.X > maxScale.X) ? partscale.X + partoffset.X : maxScale.X; | 761 | 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; | 762 | 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; | 763 | maxScale.Z = (partscale.Z + partoffset.Z > maxScale.Z) ? partscale.Z + partoffset.Z : maxScale.Z; |
764 | |||
596 | } | 765 | } |
597 | } | 766 | } |
767 | lockPartsForRead(false); | ||
768 | |||
598 | finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; | 769 | finalScale.X = (minScale.X > maxScale.X) ? minScale.X : maxScale.X; |
599 | finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; | 770 | finalScale.Y = (minScale.Y > maxScale.Y) ? minScale.Y : maxScale.Y; |
600 | finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; | 771 | finalScale.Z = (minScale.Z > maxScale.Z) ? minScale.Z : maxScale.Z; |
@@ -610,10 +781,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
610 | 781 | ||
611 | EntityIntersection result = new EntityIntersection(); | 782 | EntityIntersection result = new EntityIntersection(); |
612 | 783 | ||
613 | lock (m_parts) | 784 | lockPartsForRead(true); |
614 | { | 785 | { |
615 | foreach (SceneObjectPart part in m_parts.Values) | 786 | foreach (SceneObjectPart part in m_parts.Values) |
616 | { | 787 | { |
788 | |||
617 | // Temporary commented to stop compiler warning | 789 | // Temporary commented to stop compiler warning |
618 | //Vector3 partPosition = | 790 | //Vector3 partPosition = |
619 | // new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); | 791 | // new Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); |
@@ -641,8 +813,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
641 | result.distance = inter.distance; | 813 | result.distance = inter.distance; |
642 | } | 814 | } |
643 | } | 815 | } |
816 | |||
644 | } | 817 | } |
645 | } | 818 | } |
819 | lockPartsForRead(false); | ||
646 | return result; | 820 | return result; |
647 | } | 821 | } |
648 | 822 | ||
@@ -661,10 +835,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
661 | minY = 256f; | 835 | minY = 256f; |
662 | minZ = 8192f; | 836 | minZ = 8192f; |
663 | 837 | ||
664 | lock(m_parts); | 838 | lockPartsForRead(true); |
665 | { | 839 | { |
666 | foreach (SceneObjectPart part in m_parts.Values) | 840 | foreach (SceneObjectPart part in m_parts.Values) |
667 | { | 841 | { |
842 | |||
668 | Vector3 worldPos = part.GetWorldPosition(); | 843 | Vector3 worldPos = part.GetWorldPosition(); |
669 | Vector3 offset = worldPos - AbsolutePosition; | 844 | Vector3 offset = worldPos - AbsolutePosition; |
670 | Quaternion worldRot; | 845 | Quaternion worldRot; |
@@ -723,6 +898,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
723 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); | 898 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); |
724 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); | 899 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); |
725 | 900 | ||
901 | |||
902 | |||
726 | //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | 903 | //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); | 904 | //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); | 905 | //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); |
@@ -894,6 +1071,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
894 | minZ = backBottomLeft.Z; | 1071 | minZ = backBottomLeft.Z; |
895 | } | 1072 | } |
896 | } | 1073 | } |
1074 | lockPartsForRead(false); | ||
897 | } | 1075 | } |
898 | 1076 | ||
899 | public Vector3 GetAxisAlignedBoundingBox(out float offsetHeight) | 1077 | public Vector3 GetAxisAlignedBoundingBox(out float offsetHeight) |
@@ -929,21 +1107,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
929 | 1107 | ||
930 | public void SaveScriptedState(XmlTextWriter writer) | 1108 | public void SaveScriptedState(XmlTextWriter writer) |
931 | { | 1109 | { |
1110 | SaveScriptedState(writer, false); | ||
1111 | } | ||
1112 | |||
1113 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1114 | { | ||
932 | XmlDocument doc = new XmlDocument(); | 1115 | XmlDocument doc = new XmlDocument(); |
933 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1116 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
934 | 1117 | ||
935 | // Capture script state while holding the lock | 1118 | // Capture script state while holding the lock |
936 | lock (m_parts) | 1119 | lockPartsForRead(true); |
937 | { | 1120 | { |
938 | foreach (SceneObjectPart part in m_parts.Values) | 1121 | foreach (SceneObjectPart part in m_parts.Values) |
939 | { | 1122 | { |
940 | Dictionary<UUID,string> pstates = part.Inventory.GetScriptStates(); | 1123 | |
1124 | Dictionary<UUID,string> pstates = part.Inventory.GetScriptStates(oldIDs); | ||
941 | foreach (UUID itemid in pstates.Keys) | 1125 | foreach (UUID itemid in pstates.Keys) |
942 | { | 1126 | { |
943 | states.Add(itemid, pstates[itemid]); | 1127 | states.Add(itemid, pstates[itemid]); |
944 | } | 1128 | } |
1129 | |||
945 | } | 1130 | } |
946 | } | 1131 | } |
1132 | lockPartsForRead(false); | ||
947 | 1133 | ||
948 | if (states.Count > 0) | 1134 | if (states.Count > 0) |
949 | { | 1135 | { |
@@ -962,6 +1148,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
962 | } | 1148 | } |
963 | 1149 | ||
964 | /// <summary> | 1150 | /// <summary> |
1151 | /// Add the avatar to this linkset (avatar is sat). | ||
1152 | /// </summary> | ||
1153 | /// <param name="agentID"></param> | ||
1154 | public void AddAvatar(UUID agentID) | ||
1155 | { | ||
1156 | ScenePresence presence; | ||
1157 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1158 | { | ||
1159 | if (!m_linkedAvatars.Contains(presence)) | ||
1160 | { | ||
1161 | m_linkedAvatars.Add(presence); | ||
1162 | } | ||
1163 | } | ||
1164 | } | ||
1165 | |||
1166 | /// <summary> | ||
1167 | /// Delete the avatar from this linkset (avatar is unsat). | ||
1168 | /// </summary> | ||
1169 | /// <param name="agentID"></param> | ||
1170 | public void DeleteAvatar(UUID agentID) | ||
1171 | { | ||
1172 | ScenePresence presence; | ||
1173 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1174 | { | ||
1175 | if (m_linkedAvatars.Contains(presence)) | ||
1176 | { | ||
1177 | m_linkedAvatars.Remove(presence); | ||
1178 | } | ||
1179 | } | ||
1180 | } | ||
1181 | |||
1182 | /// <summary> | ||
1183 | /// Returns the list of linked presences (avatars sat on this group) | ||
1184 | /// </summary> | ||
1185 | /// <param name="agentID"></param> | ||
1186 | public List<ScenePresence> GetLinkedAvatars() | ||
1187 | { | ||
1188 | return m_linkedAvatars; | ||
1189 | } | ||
1190 | |||
1191 | /// <summary> | ||
965 | /// Attach this scene object to the given avatar. | 1192 | /// Attach this scene object to the given avatar. |
966 | /// </summary> | 1193 | /// </summary> |
967 | /// <param name="agentID"></param> | 1194 | /// <param name="agentID"></param> |
@@ -1112,13 +1339,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1112 | 1339 | ||
1113 | public override void UpdateMovement() | 1340 | public override void UpdateMovement() |
1114 | { | 1341 | { |
1115 | lock (m_parts) | 1342 | lockPartsForRead(true); |
1116 | { | 1343 | { |
1117 | foreach (SceneObjectPart part in m_parts.Values) | 1344 | foreach (SceneObjectPart part in m_parts.Values) |
1118 | { | 1345 | { |
1346 | |||
1119 | part.UpdateMovement(); | 1347 | part.UpdateMovement(); |
1348 | |||
1120 | } | 1349 | } |
1121 | } | 1350 | } |
1351 | lockPartsForRead(false); | ||
1122 | } | 1352 | } |
1123 | 1353 | ||
1124 | public ushort GetTimeDilation() | 1354 | public ushort GetTimeDilation() |
@@ -1162,7 +1392,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1162 | /// <param name="part"></param> | 1392 | /// <param name="part"></param> |
1163 | public void AddPart(SceneObjectPart part) | 1393 | public void AddPart(SceneObjectPart part) |
1164 | { | 1394 | { |
1165 | lock (m_parts) | 1395 | lockPartsForWrite(true); |
1166 | { | 1396 | { |
1167 | part.SetParent(this); | 1397 | part.SetParent(this); |
1168 | m_parts.Add(part.UUID, part); | 1398 | m_parts.Add(part.UUID, part); |
@@ -1172,6 +1402,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1172 | if (part.LinkNum == 2 && RootPart != null) | 1402 | if (part.LinkNum == 2 && RootPart != null) |
1173 | RootPart.LinkNum = 1; | 1403 | RootPart.LinkNum = 1; |
1174 | } | 1404 | } |
1405 | lockPartsForWrite(false); | ||
1175 | } | 1406 | } |
1176 | 1407 | ||
1177 | /// <summary> | 1408 | /// <summary> |
@@ -1179,28 +1410,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
1179 | /// </summary> | 1410 | /// </summary> |
1180 | private void UpdateParentIDs() | 1411 | private void UpdateParentIDs() |
1181 | { | 1412 | { |
1182 | lock (m_parts) | 1413 | lockPartsForRead(true); |
1183 | { | 1414 | { |
1184 | foreach (SceneObjectPart part in m_parts.Values) | 1415 | foreach (SceneObjectPart part in m_parts.Values) |
1185 | { | 1416 | { |
1417 | |||
1186 | if (part.UUID != m_rootPart.UUID) | 1418 | if (part.UUID != m_rootPart.UUID) |
1187 | { | 1419 | { |
1188 | part.ParentID = m_rootPart.LocalId; | 1420 | part.ParentID = m_rootPart.LocalId; |
1189 | } | 1421 | } |
1422 | |||
1190 | } | 1423 | } |
1191 | } | 1424 | } |
1425 | lockPartsForRead(false); | ||
1192 | } | 1426 | } |
1193 | 1427 | ||
1194 | public void RegenerateFullIDs() | 1428 | public void RegenerateFullIDs() |
1195 | { | 1429 | { |
1196 | lock (m_parts) | 1430 | lockPartsForRead(true); |
1197 | { | 1431 | { |
1198 | foreach (SceneObjectPart part in m_parts.Values) | 1432 | foreach (SceneObjectPart part in m_parts.Values) |
1199 | { | 1433 | { |
1434 | |||
1200 | part.UUID = UUID.Random(); | 1435 | part.UUID = UUID.Random(); |
1201 | 1436 | ||
1202 | } | 1437 | } |
1203 | } | 1438 | } |
1439 | lockPartsForRead(false); | ||
1204 | } | 1440 | } |
1205 | 1441 | ||
1206 | // helper provided for parts. | 1442 | // helper provided for parts. |
@@ -1261,7 +1497,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1261 | 1497 | ||
1262 | public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) | 1498 | public virtual void OnGrabPart(SceneObjectPart part, Vector3 offsetPos, IClientAPI remoteClient) |
1263 | { | 1499 | { |
1264 | part.StoreUndoState(); | 1500 | part.StoreUndoState(UndoType.STATE_PRIM_ALL); |
1265 | part.OnGrab(offsetPos, remoteClient); | 1501 | part.OnGrab(offsetPos, remoteClient); |
1266 | } | 1502 | } |
1267 | 1503 | ||
@@ -1281,27 +1517,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1281 | 1517 | ||
1282 | DetachFromBackup(); | 1518 | DetachFromBackup(); |
1283 | 1519 | ||
1284 | lock (m_parts) | 1520 | lockPartsForRead(true); |
1521 | List<SceneObjectPart> values = new List<SceneObjectPart>(m_parts.Values); | ||
1522 | lockPartsForRead(false); | ||
1523 | |||
1524 | foreach (SceneObjectPart part in values) | ||
1285 | { | 1525 | { |
1286 | foreach (SceneObjectPart part in m_parts.Values) | ||
1287 | { | ||
1288 | // part.Inventory.RemoveScriptInstances(); | 1526 | // part.Inventory.RemoveScriptInstances(); |
1289 | Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 1527 | |
1528 | Scene.ForEachScenePresence(delegate (ScenePresence sp) | ||
1529 | { | ||
1530 | if (sp.ParentID == LocalId) | ||
1290 | { | 1531 | { |
1291 | if (avatar.ParentID == LocalId) | 1532 | sp.StandUp(); |
1292 | { | 1533 | } |
1293 | avatar.StandUp(); | ||
1294 | } | ||
1295 | 1534 | ||
1296 | if (!silent) | 1535 | if (!silent) |
1297 | { | 1536 | { |
1298 | part.UpdateFlag = 0; | 1537 | part.UpdateFlag = 0; |
1299 | if (part == m_rootPart) | 1538 | if (part == m_rootPart) |
1300 | avatar.ControllingClient.SendKillObject(m_regionHandle, part.LocalId); | 1539 | sp.ControllingClient.SendKillObject(m_regionHandle, part.LocalId); |
1301 | } | 1540 | } |
1302 | }); | 1541 | }); |
1303 | } | 1542 | |
1304 | } | 1543 | } |
1544 | |||
1545 | |||
1305 | } | 1546 | } |
1306 | 1547 | ||
1307 | public void AddScriptLPS(int count) | 1548 | public void AddScriptLPS(int count) |
@@ -1326,17 +1567,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1326 | 1567 | ||
1327 | scriptEvents aggregateScriptEvents=0; | 1568 | scriptEvents aggregateScriptEvents=0; |
1328 | 1569 | ||
1329 | lock (m_parts) | 1570 | lockPartsForRead(true); |
1330 | { | 1571 | { |
1331 | foreach (SceneObjectPart part in m_parts.Values) | 1572 | foreach (SceneObjectPart part in m_parts.Values) |
1332 | { | 1573 | { |
1574 | |||
1333 | if (part == null) | 1575 | if (part == null) |
1334 | continue; | 1576 | continue; |
1335 | if (part != RootPart) | 1577 | if (part != RootPart) |
1336 | part.ObjectFlags = objectflagupdate; | 1578 | part.ObjectFlags = objectflagupdate; |
1337 | aggregateScriptEvents |= part.AggregateScriptEvents; | 1579 | aggregateScriptEvents |= part.AggregateScriptEvents; |
1580 | |||
1338 | } | 1581 | } |
1339 | } | 1582 | } |
1583 | lockPartsForRead(false); | ||
1340 | 1584 | ||
1341 | m_scriptListens_atTarget = ((aggregateScriptEvents & scriptEvents.at_target) != 0); | 1585 | m_scriptListens_atTarget = ((aggregateScriptEvents & scriptEvents.at_target) != 0); |
1342 | m_scriptListens_notAtTarget = ((aggregateScriptEvents & scriptEvents.not_at_target) != 0); | 1586 | m_scriptListens_notAtTarget = ((aggregateScriptEvents & scriptEvents.not_at_target) != 0); |
@@ -1378,42 +1622,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
1378 | /// <param name="m_physicalPrim"></param> | 1622 | /// <param name="m_physicalPrim"></param> |
1379 | public void ApplyPhysics(bool m_physicalPrim) | 1623 | public void ApplyPhysics(bool m_physicalPrim) |
1380 | { | 1624 | { |
1381 | lock (m_parts) | 1625 | lockPartsForRead(true); |
1626 | |||
1627 | if (m_parts.Count > 1) | ||
1382 | { | 1628 | { |
1383 | if (m_parts.Count > 1) | 1629 | List<SceneObjectPart> values = new List<SceneObjectPart>(m_parts.Values); |
1630 | lockPartsForRead(false); | ||
1631 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); | ||
1632 | foreach (SceneObjectPart part in values) | ||
1384 | { | 1633 | { |
1385 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); | 1634 | |
1386 | foreach (SceneObjectPart part in m_parts.Values) | 1635 | if (part.LocalId != m_rootPart.LocalId) |
1387 | { | 1636 | { |
1388 | if (part.LocalId != m_rootPart.LocalId) | 1637 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, m_physicalPrim); |
1389 | { | ||
1390 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, m_physicalPrim); | ||
1391 | } | ||
1392 | } | 1638 | } |
1393 | 1639 | ||
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 | } | 1640 | } |
1641 | // Hack to get the physics scene geometries in the right spot | ||
1642 | ResetChildPrimPhysicsPositions(); | ||
1643 | } | ||
1644 | else | ||
1645 | { | ||
1646 | lockPartsForRead(false); | ||
1647 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_physicalPrim); | ||
1401 | } | 1648 | } |
1402 | } | 1649 | } |
1403 | 1650 | ||
1404 | public void SetOwnerId(UUID userId) | 1651 | public void SetOwnerId(UUID userId) |
1405 | { | 1652 | { |
1406 | ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); | 1653 | ForEachPart(delegate(SceneObjectPart part) |
1654 | { | ||
1655 | |||
1656 | part.OwnerID = userId; | ||
1657 | |||
1658 | }); | ||
1407 | } | 1659 | } |
1408 | 1660 | ||
1409 | public void ForEachPart(Action<SceneObjectPart> whatToDo) | 1661 | public void ForEachPart(Action<SceneObjectPart> whatToDo) |
1410 | { | 1662 | { |
1411 | lock (m_parts) | 1663 | lockPartsForRead(true); |
1664 | List<SceneObjectPart> values = new List<SceneObjectPart>(m_parts.Values); | ||
1665 | lockPartsForRead(false); | ||
1666 | foreach (SceneObjectPart part in values) | ||
1412 | { | 1667 | { |
1413 | foreach (SceneObjectPart part in m_parts.Values) | 1668 | |
1414 | { | 1669 | whatToDo(part); |
1415 | whatToDo(part); | 1670 | |
1416 | } | ||
1417 | } | 1671 | } |
1418 | } | 1672 | } |
1419 | 1673 | ||
@@ -1436,7 +1690,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1436 | 1690 | ||
1437 | try | 1691 | try |
1438 | { | 1692 | { |
1439 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart | 1693 | if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart |
1694 | m_scene.LoginsDisabled || // We're starting up or doing maintenance, don't mess with things | ||
1695 | m_scene.LoadingPrims) // Land may not be valid yet | ||
1696 | |||
1440 | { | 1697 | { |
1441 | ILandObject parcel = m_scene.LandChannel.GetLandObject( | 1698 | ILandObject parcel = m_scene.LandChannel.GetLandObject( |
1442 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); | 1699 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); |
@@ -1511,15 +1768,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1511 | RootPart.SendFullUpdate( | 1768 | RootPart.SendFullUpdate( |
1512 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); | 1769 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); |
1513 | 1770 | ||
1514 | lock (m_parts) | 1771 | lockPartsForRead(true); |
1515 | { | 1772 | { |
1516 | foreach (SceneObjectPart part in m_parts.Values) | 1773 | foreach (SceneObjectPart part in m_parts.Values) |
1517 | { | 1774 | { |
1775 | |||
1518 | if (part != RootPart) | 1776 | if (part != RootPart) |
1519 | part.SendFullUpdate( | 1777 | part.SendFullUpdate( |
1520 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); | 1778 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); |
1521 | } | 1779 | } |
1522 | } | 1780 | } |
1781 | lockPartsForRead(false); | ||
1523 | } | 1782 | } |
1524 | 1783 | ||
1525 | #region Copying | 1784 | #region Copying |
@@ -1580,10 +1839,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1580 | 1839 | ||
1581 | List<SceneObjectPart> partList; | 1840 | List<SceneObjectPart> partList; |
1582 | 1841 | ||
1583 | lock (m_parts) | 1842 | lockPartsForRead(true); |
1584 | { | 1843 | |
1585 | partList = new List<SceneObjectPart>(m_parts.Values); | 1844 | partList = new List<SceneObjectPart>(m_parts.Values); |
1586 | } | 1845 | |
1846 | lockPartsForRead(false); | ||
1587 | 1847 | ||
1588 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | 1848 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) |
1589 | { | 1849 | { |
@@ -1800,13 +2060,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
1800 | } | 2060 | } |
1801 | } | 2061 | } |
1802 | 2062 | ||
2063 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2064 | { | ||
2065 | SceneObjectPart rootpart = m_rootPart; | ||
2066 | if (rootpart != null) | ||
2067 | { | ||
2068 | if (IsAttachment) | ||
2069 | { | ||
2070 | /* | ||
2071 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
2072 | if (avatar != null) | ||
2073 | { | ||
2074 | Rotate the Av? | ||
2075 | } */ | ||
2076 | } | ||
2077 | else | ||
2078 | { | ||
2079 | if (rootpart.PhysActor != null) | ||
2080 | { // APID must be implemented in your physics system for this to function. | ||
2081 | rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); | ||
2082 | rootpart.PhysActor.APIDStrength = strength; | ||
2083 | rootpart.PhysActor.APIDDamping = damping; | ||
2084 | rootpart.PhysActor.APIDActive = true; | ||
2085 | } | ||
2086 | } | ||
2087 | } | ||
2088 | } | ||
2089 | |||
1803 | public void stopLookAt() | 2090 | public void stopLookAt() |
1804 | { | 2091 | { |
1805 | SceneObjectPart rootpart = m_rootPart; | 2092 | SceneObjectPart rootpart = m_rootPart; |
1806 | if (rootpart != null) | 2093 | if (rootpart != null) |
1807 | { | 2094 | { |
1808 | if (rootpart.PhysActor != null) | 2095 | if (rootpart.PhysActor != null) |
1809 | { | 2096 | { // APID must be implemented in your physics system for this to function. |
1810 | rootpart.PhysActor.APIDActive = false; | 2097 | rootpart.PhysActor.APIDActive = false; |
1811 | } | 2098 | } |
1812 | } | 2099 | } |
@@ -1874,10 +2161,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1874 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | 2161 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); |
1875 | newPart.SetParent(this); | 2162 | newPart.SetParent(this); |
1876 | 2163 | ||
1877 | lock (m_parts) | 2164 | lockPartsForWrite(true); |
1878 | { | 2165 | { |
1879 | m_parts.Add(newPart.UUID, newPart); | 2166 | m_parts.Add(newPart.UUID, newPart); |
1880 | } | 2167 | } |
2168 | lockPartsForWrite(false); | ||
1881 | 2169 | ||
1882 | SetPartAsNonRoot(newPart); | 2170 | SetPartAsNonRoot(newPart); |
1883 | 2171 | ||
@@ -1940,7 +2228,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1940 | //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 2228 | //if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
1941 | // return; | 2229 | // return; |
1942 | 2230 | ||
1943 | lock (m_parts) | 2231 | lockPartsForRead(true); |
1944 | { | 2232 | { |
1945 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); | 2233 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); |
1946 | 2234 | ||
@@ -1960,9 +2248,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1960 | { | 2248 | { |
1961 | if (!IsSelected) | 2249 | if (!IsSelected) |
1962 | part.UpdateLookAt(); | 2250 | part.UpdateLookAt(); |
2251 | |||
1963 | part.SendScheduledUpdates(); | 2252 | part.SendScheduledUpdates(); |
2253 | |||
1964 | } | 2254 | } |
1965 | } | 2255 | } |
2256 | lockPartsForRead(false); | ||
1966 | } | 2257 | } |
1967 | 2258 | ||
1968 | public void ScheduleFullUpdateToAvatar(ScenePresence presence) | 2259 | public void ScheduleFullUpdateToAvatar(ScenePresence presence) |
@@ -1971,27 +2262,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1971 | 2262 | ||
1972 | RootPart.AddFullUpdateToAvatar(presence); | 2263 | RootPart.AddFullUpdateToAvatar(presence); |
1973 | 2264 | ||
1974 | lock (m_parts) | 2265 | lockPartsForRead(true); |
1975 | { | 2266 | { |
1976 | foreach (SceneObjectPart part in m_parts.Values) | 2267 | foreach (SceneObjectPart part in m_parts.Values) |
1977 | { | 2268 | { |
2269 | |||
1978 | if (part != RootPart) | 2270 | if (part != RootPart) |
1979 | part.AddFullUpdateToAvatar(presence); | 2271 | part.AddFullUpdateToAvatar(presence); |
2272 | |||
1980 | } | 2273 | } |
1981 | } | 2274 | } |
2275 | lockPartsForRead(false); | ||
1982 | } | 2276 | } |
1983 | 2277 | ||
1984 | public void ScheduleTerseUpdateToAvatar(ScenePresence presence) | 2278 | public void ScheduleTerseUpdateToAvatar(ScenePresence presence) |
1985 | { | 2279 | { |
1986 | // m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); | 2280 | lockPartsForRead(true); |
1987 | 2281 | ||
1988 | lock (m_parts) | 2282 | foreach (SceneObjectPart part in m_parts.Values) |
1989 | { | 2283 | { |
1990 | foreach (SceneObjectPart part in m_parts.Values) | 2284 | part.AddTerseUpdateToAvatar(presence); |
1991 | { | ||
1992 | part.AddTerseUpdateToAvatar(presence); | ||
1993 | } | ||
1994 | } | 2285 | } |
2286 | |||
2287 | lockPartsForRead(false); | ||
1995 | } | 2288 | } |
1996 | 2289 | ||
1997 | /// <summary> | 2290 | /// <summary> |
@@ -1999,20 +2292,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
1999 | /// </summary> | 2292 | /// </summary> |
2000 | public void ScheduleGroupForFullUpdate() | 2293 | public void ScheduleGroupForFullUpdate() |
2001 | { | 2294 | { |
2002 | if (IsAttachment) | 2295 | //if (IsAttachment) |
2003 | m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); | 2296 | // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, LocalId); |
2004 | 2297 | ||
2005 | checkAtTargets(); | 2298 | checkAtTargets(); |
2006 | RootPart.ScheduleFullUpdate(); | 2299 | RootPart.ScheduleFullUpdate(); |
2007 | 2300 | ||
2008 | lock (m_parts) | 2301 | lockPartsForRead(true); |
2009 | { | 2302 | { |
2010 | foreach (SceneObjectPart part in m_parts.Values) | 2303 | foreach (SceneObjectPart part in m_parts.Values) |
2011 | { | 2304 | { |
2305 | |||
2012 | if (part != RootPart) | 2306 | if (part != RootPart) |
2013 | part.ScheduleFullUpdate(); | 2307 | part.ScheduleFullUpdate(); |
2308 | |||
2014 | } | 2309 | } |
2015 | } | 2310 | } |
2311 | lockPartsForRead(false); | ||
2016 | } | 2312 | } |
2017 | 2313 | ||
2018 | /// <summary> | 2314 | /// <summary> |
@@ -2020,37 +2316,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
2020 | /// </summary> | 2316 | /// </summary> |
2021 | public void ScheduleGroupForTerseUpdate() | 2317 | public void ScheduleGroupForTerseUpdate() |
2022 | { | 2318 | { |
2023 | // m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); | 2319 | lockPartsForRead(true); |
2024 | 2320 | foreach (SceneObjectPart part in m_parts.Values) | |
2025 | lock (m_parts) | ||
2026 | { | 2321 | { |
2027 | foreach (SceneObjectPart part in m_parts.Values) | 2322 | part.ScheduleTerseUpdate(); |
2028 | { | ||
2029 | part.ScheduleTerseUpdate(); | ||
2030 | } | ||
2031 | } | 2323 | } |
2324 | |||
2325 | lockPartsForRead(false); | ||
2032 | } | 2326 | } |
2033 | 2327 | ||
2034 | /// <summary> | 2328 | /// <summary> |
2035 | /// Immediately send a full update for this scene object. | 2329 | /// Immediately send a full update for this scene object. |
2036 | /// </summary> | 2330 | /// </summary> |
2037 | public void SendGroupFullUpdate() | 2331 | public void SendGroupFullUpdate() |
2038 | { | 2332 | { |
2039 | if (IsDeleted) | 2333 | if (IsDeleted) |
2040 | return; | 2334 | return; |
2041 | 2335 | ||
2042 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); | 2336 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); |
2043 | 2337 | ||
2044 | RootPart.SendFullUpdateToAllClients(); | 2338 | RootPart.SendFullUpdateToAllClients(); |
2045 | 2339 | ||
2046 | lock (m_parts) | 2340 | lockPartsForRead(true); |
2047 | { | 2341 | { |
2048 | foreach (SceneObjectPart part in m_parts.Values) | 2342 | foreach (SceneObjectPart part in m_parts.Values) |
2049 | { | 2343 | { |
2344 | |||
2050 | if (part != RootPart) | 2345 | if (part != RootPart) |
2051 | part.SendFullUpdateToAllClients(); | 2346 | part.SendFullUpdateToAllClients(); |
2347 | |||
2052 | } | 2348 | } |
2053 | } | 2349 | } |
2350 | lockPartsForRead(false); | ||
2054 | } | 2351 | } |
2055 | 2352 | ||
2056 | /// <summary> | 2353 | /// <summary> |
@@ -2082,14 +2379,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2082 | { | 2379 | { |
2083 | if (IsDeleted) | 2380 | if (IsDeleted) |
2084 | return; | 2381 | return; |
2085 | 2382 | ||
2086 | lock (m_parts) | 2383 | lockPartsForRead(true); |
2087 | { | 2384 | { |
2088 | foreach (SceneObjectPart part in m_parts.Values) | 2385 | foreach (SceneObjectPart part in m_parts.Values) |
2089 | { | 2386 | { |
2090 | part.SendTerseUpdateToAllClients(); | 2387 | part.SendTerseUpdateToAllClients(); |
2091 | } | 2388 | } |
2092 | } | 2389 | } |
2390 | lockPartsForRead(false); | ||
2093 | } | 2391 | } |
2094 | 2392 | ||
2095 | #endregion | 2393 | #endregion |
@@ -2103,16 +2401,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2103 | /// <returns>null if no child part with that linknum or child part</returns> | 2401 | /// <returns>null if no child part with that linknum or child part</returns> |
2104 | public SceneObjectPart GetLinkNumPart(int linknum) | 2402 | public SceneObjectPart GetLinkNumPart(int linknum) |
2105 | { | 2403 | { |
2106 | lock (m_parts) | 2404 | lockPartsForRead(true); |
2107 | { | 2405 | { |
2108 | foreach (SceneObjectPart part in m_parts.Values) | 2406 | foreach (SceneObjectPart part in m_parts.Values) |
2109 | { | 2407 | { |
2110 | if (part.LinkNum == linknum) | 2408 | if (part.LinkNum == linknum) |
2111 | { | 2409 | { |
2410 | lockPartsForRead(false); | ||
2112 | return part; | 2411 | return part; |
2113 | } | 2412 | } |
2114 | } | 2413 | } |
2115 | } | 2414 | } |
2415 | lockPartsForRead(false); | ||
2116 | 2416 | ||
2117 | return null; | 2417 | return null; |
2118 | } | 2418 | } |
@@ -2140,17 +2440,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2140 | public SceneObjectPart GetChildPart(uint localID) | 2440 | public SceneObjectPart GetChildPart(uint localID) |
2141 | { | 2441 | { |
2142 | //m_log.DebugFormat("Entered looking for {0}", localID); | 2442 | //m_log.DebugFormat("Entered looking for {0}", localID); |
2143 | lock (m_parts) | 2443 | lockPartsForRead(true); |
2144 | { | 2444 | { |
2145 | foreach (SceneObjectPart part in m_parts.Values) | 2445 | foreach (SceneObjectPart part in m_parts.Values) |
2146 | { | 2446 | { |
2147 | //m_log.DebugFormat("Found {0}", part.LocalId); | 2447 | //m_log.DebugFormat("Found {0}", part.LocalId); |
2148 | if (part.LocalId == localID) | 2448 | if (part.LocalId == localID) |
2149 | { | 2449 | { |
2450 | lockPartsForRead(false); | ||
2150 | return part; | 2451 | return part; |
2151 | } | 2452 | } |
2152 | } | 2453 | } |
2153 | } | 2454 | } |
2455 | lockPartsForRead(false); | ||
2154 | 2456 | ||
2155 | return null; | 2457 | return null; |
2156 | } | 2458 | } |
@@ -2180,17 +2482,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2180 | public bool HasChildPrim(uint localID) | 2482 | public bool HasChildPrim(uint localID) |
2181 | { | 2483 | { |
2182 | //m_log.DebugFormat("Entered HasChildPrim looking for {0}", localID); | 2484 | //m_log.DebugFormat("Entered HasChildPrim looking for {0}", localID); |
2183 | lock (m_parts) | 2485 | lockPartsForRead(true); |
2184 | { | 2486 | { |
2185 | foreach (SceneObjectPart part in m_parts.Values) | 2487 | foreach (SceneObjectPart part in m_parts.Values) |
2186 | { | 2488 | { |
2187 | //m_log.DebugFormat("Found {0}", part.LocalId); | 2489 | //m_log.DebugFormat("Found {0}", part.LocalId); |
2188 | if (part.LocalId == localID) | 2490 | if (part.LocalId == localID) |
2189 | { | 2491 | { |
2492 | lockPartsForRead(false); | ||
2190 | return true; | 2493 | return true; |
2191 | } | 2494 | } |
2192 | } | 2495 | } |
2193 | } | 2496 | } |
2497 | lockPartsForRead(false); | ||
2194 | 2498 | ||
2195 | return false; | 2499 | return false; |
2196 | } | 2500 | } |
@@ -2240,53 +2544,57 @@ namespace OpenSim.Region.Framework.Scenes | |||
2240 | if (m_rootPart.LinkNum == 0) | 2544 | if (m_rootPart.LinkNum == 0) |
2241 | m_rootPart.LinkNum = 1; | 2545 | m_rootPart.LinkNum = 1; |
2242 | 2546 | ||
2243 | lock (m_parts) | 2547 | lockPartsForWrite(true); |
2244 | { | 2548 | |
2245 | m_parts.Add(linkPart.UUID, linkPart); | 2549 | m_parts.Add(linkPart.UUID, linkPart); |
2246 | 2550 | ||
2247 | // Insert in terms of link numbers, the new links | 2551 | lockPartsForWrite(false); |
2248 | // before the current ones (with the exception of | 2552 | |
2249 | // the root prim. Shuffle the old ones up | 2553 | // Insert in terms of link numbers, the new links |
2250 | foreach (KeyValuePair<UUID, SceneObjectPart> kvp in m_parts) | 2554 | // before the current ones (with the exception of |
2555 | // the root prim. Shuffle the old ones up | ||
2556 | lockPartsForRead(true); | ||
2557 | foreach (KeyValuePair<UUID, SceneObjectPart> kvp in m_parts) | ||
2558 | { | ||
2559 | if (kvp.Value.LinkNum != 1) | ||
2251 | { | 2560 | { |
2252 | if (kvp.Value.LinkNum != 1) | 2561 | // Don't update root prim link number |
2253 | { | 2562 | kvp.Value.LinkNum += objectGroup.PrimCount; |
2254 | // Don't update root prim link number | ||
2255 | kvp.Value.LinkNum += objectGroup.PrimCount; | ||
2256 | } | ||
2257 | } | 2563 | } |
2564 | } | ||
2565 | lockPartsForRead(false); | ||
2258 | 2566 | ||
2259 | linkPart.LinkNum = 2; | 2567 | linkPart.LinkNum = 2; |
2260 | 2568 | ||
2261 | linkPart.SetParent(this); | 2569 | linkPart.SetParent(this); |
2262 | linkPart.CreateSelected = true; | 2570 | linkPart.CreateSelected = true; |
2263 | 2571 | ||
2264 | //if (linkPart.PhysActor != null) | 2572 | //if (linkPart.PhysActor != null) |
2265 | //{ | 2573 | //{ |
2266 | // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); | 2574 | // m_scene.PhysicsScene.RemovePrim(linkPart.PhysActor); |
2267 | 2575 | ||
2268 | //linkPart.PhysActor = null; | 2576 | //linkPart.PhysActor = null; |
2269 | //} | 2577 | //} |
2270 | 2578 | ||
2271 | //TODO: rest of parts | 2579 | //TODO: rest of parts |
2272 | int linkNum = 3; | 2580 | int linkNum = 3; |
2273 | foreach (SceneObjectPart part in objectGroup.Children.Values) | 2581 | foreach (SceneObjectPart part in objectGroup.Children.Values) |
2582 | { | ||
2583 | if (part.UUID != objectGroup.m_rootPart.UUID) | ||
2274 | { | 2584 | { |
2275 | if (part.UUID != objectGroup.m_rootPart.UUID) | 2585 | LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); |
2276 | { | ||
2277 | LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); | ||
2278 | } | ||
2279 | part.ClearUndoState(); | ||
2280 | } | 2586 | } |
2587 | part.ClearUndoState(); | ||
2281 | } | 2588 | } |
2282 | 2589 | ||
2283 | m_scene.UnlinkSceneObject(objectGroup.UUID, true); | 2590 | m_scene.UnlinkSceneObject(objectGroup.UUID, true); |
2284 | objectGroup.m_isDeleted = true; | 2591 | objectGroup.m_isDeleted = true; |
2592 | |||
2593 | objectGroup.lockPartsForWrite(true); | ||
2285 | 2594 | ||
2286 | lock (objectGroup.m_parts) | 2595 | objectGroup.m_parts.Clear(); |
2287 | { | 2596 | |
2288 | objectGroup.m_parts.Clear(); | 2597 | objectGroup.lockPartsForWrite(false); |
2289 | } | ||
2290 | 2598 | ||
2291 | // Can't do this yet since backup still makes use of the root part without any synchronization | 2599 | // Can't do this yet since backup still makes use of the root part without any synchronization |
2292 | // objectGroup.m_rootPart = null; | 2600 | // objectGroup.m_rootPart = null; |
@@ -2356,11 +2664,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2356 | Quaternion worldRot = linkPart.GetWorldRotation(); | 2664 | Quaternion worldRot = linkPart.GetWorldRotation(); |
2357 | 2665 | ||
2358 | // Remove the part from this object | 2666 | // Remove the part from this object |
2359 | lock (m_parts) | 2667 | lockPartsForWrite(true); |
2360 | { | 2668 | { |
2361 | m_parts.Remove(linkPart.UUID); | 2669 | m_parts.Remove(linkPart.UUID); |
2362 | } | 2670 | } |
2363 | 2671 | lockPartsForWrite(false); | |
2672 | lockPartsForRead(true); | ||
2364 | if (m_parts.Count == 1 && RootPart != null) //Single prim is left | 2673 | if (m_parts.Count == 1 && RootPart != null) //Single prim is left |
2365 | RootPart.LinkNum = 0; | 2674 | RootPart.LinkNum = 0; |
2366 | else | 2675 | else |
@@ -2371,6 +2680,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2371 | p.LinkNum--; | 2680 | p.LinkNum--; |
2372 | } | 2681 | } |
2373 | } | 2682 | } |
2683 | lockPartsForRead(false); | ||
2374 | 2684 | ||
2375 | linkPart.ParentID = 0; | 2685 | linkPart.ParentID = 0; |
2376 | linkPart.LinkNum = 0; | 2686 | linkPart.LinkNum = 0; |
@@ -2414,6 +2724,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2414 | /// <param name="objectGroup"></param> | 2724 | /// <param name="objectGroup"></param> |
2415 | public virtual void DetachFromBackup() | 2725 | public virtual void DetachFromBackup() |
2416 | { | 2726 | { |
2727 | m_scene.SceneGraph.FireDetachFromBackup(this); | ||
2728 | |||
2417 | if (m_isBackedUp) | 2729 | if (m_isBackedUp) |
2418 | m_scene.EventManager.OnBackup -= ProcessBackup; | 2730 | m_scene.EventManager.OnBackup -= ProcessBackup; |
2419 | 2731 | ||
@@ -2692,9 +3004,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2692 | 3004 | ||
2693 | if (selectionPart != null) | 3005 | if (selectionPart != null) |
2694 | { | 3006 | { |
2695 | lock (m_parts) | 3007 | lockPartsForRead(true); |
3008 | List<SceneObjectPart> parts = new List<SceneObjectPart>(m_parts.Values); | ||
3009 | lockPartsForRead(false); | ||
3010 | foreach (SceneObjectPart part in parts) | ||
2696 | { | 3011 | { |
2697 | foreach (SceneObjectPart part in m_parts.Values) | 3012 | if (part.Scale.X > 10.0 || part.Scale.Y > 10.0 || part.Scale.Z > 10.0) |
2698 | { | 3013 | { |
2699 | if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax || | 3014 | if (part.Scale.X > m_scene.RegionInfo.PhysPrimMax || |
2700 | part.Scale.Y > m_scene.RegionInfo.PhysPrimMax || | 3015 | part.Scale.Y > m_scene.RegionInfo.PhysPrimMax || |
@@ -2704,12 +3019,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2704 | break; | 3019 | break; |
2705 | } | 3020 | } |
2706 | } | 3021 | } |
3022 | } | ||
2707 | 3023 | ||
2708 | foreach (SceneObjectPart part in m_parts.Values) | 3024 | foreach (SceneObjectPart part in parts) |
2709 | { | 3025 | { |
2710 | part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 3026 | part.UpdatePrimFlags(UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); |
2711 | } | ||
2712 | } | 3027 | } |
3028 | |||
2713 | } | 3029 | } |
2714 | } | 3030 | } |
2715 | 3031 | ||
@@ -2722,6 +3038,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2722 | } | 3038 | } |
2723 | } | 3039 | } |
2724 | 3040 | ||
3041 | |||
3042 | |||
3043 | /// <summary> | ||
3044 | /// Gets the number of parts | ||
3045 | /// </summary> | ||
3046 | /// <returns></returns> | ||
3047 | public int GetPartCount() | ||
3048 | { | ||
3049 | return Children.Count; | ||
3050 | } | ||
3051 | |||
2725 | /// <summary> | 3052 | /// <summary> |
2726 | /// Get the parts of this scene object | 3053 | /// Get the parts of this scene object |
2727 | /// </summary> | 3054 | /// </summary> |
@@ -2795,11 +3122,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2795 | scale.Y = m_scene.m_maxNonphys; | 3122 | scale.Y = m_scene.m_maxNonphys; |
2796 | if (scale.Z > m_scene.m_maxNonphys) | 3123 | if (scale.Z > m_scene.m_maxNonphys) |
2797 | scale.Z = m_scene.m_maxNonphys; | 3124 | scale.Z = m_scene.m_maxNonphys; |
2798 | |||
2799 | SceneObjectPart part = GetChildPart(localID); | 3125 | SceneObjectPart part = GetChildPart(localID); |
2800 | if (part != null) | 3126 | if (part != null) |
2801 | { | 3127 | { |
2802 | part.Resize(scale); | ||
2803 | if (part.PhysActor != null) | 3128 | if (part.PhysActor != null) |
2804 | { | 3129 | { |
2805 | if (part.PhysActor.IsPhysical) | 3130 | if (part.PhysActor.IsPhysical) |
@@ -2814,7 +3139,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2814 | part.PhysActor.Size = scale; | 3139 | part.PhysActor.Size = scale; |
2815 | m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); | 3140 | m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); |
2816 | } | 3141 | } |
2817 | //if (part.UUID != m_rootPart.UUID) | 3142 | part.Resize(scale); |
2818 | 3143 | ||
2819 | HasGroupChanged = true; | 3144 | HasGroupChanged = true; |
2820 | ScheduleGroupForFullUpdate(); | 3145 | ScheduleGroupForFullUpdate(); |
@@ -2836,7 +3161,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2836 | SceneObjectPart part = GetChildPart(localID); | 3161 | SceneObjectPart part = GetChildPart(localID); |
2837 | if (part != null) | 3162 | if (part != null) |
2838 | { | 3163 | { |
2839 | part.IgnoreUndoUpdate = true; | ||
2840 | if (scale.X > m_scene.m_maxNonphys) | 3164 | if (scale.X > m_scene.m_maxNonphys) |
2841 | scale.X = m_scene.m_maxNonphys; | 3165 | scale.X = m_scene.m_maxNonphys; |
2842 | if (scale.Y > m_scene.m_maxNonphys) | 3166 | if (scale.Y > m_scene.m_maxNonphys) |
@@ -2856,94 +3180,100 @@ namespace OpenSim.Region.Framework.Scenes | |||
2856 | float y = (scale.Y / part.Scale.Y); | 3180 | float y = (scale.Y / part.Scale.Y); |
2857 | float z = (scale.Z / part.Scale.Z); | 3181 | float z = (scale.Z / part.Scale.Z); |
2858 | 3182 | ||
2859 | lock (m_parts) | 3183 | lockPartsForRead(true); |
3184 | if (x > 1.0f || y > 1.0f || z > 1.0f) | ||
2860 | { | 3185 | { |
2861 | if (x > 1.0f || y > 1.0f || z > 1.0f) | 3186 | foreach (SceneObjectPart obPart in m_parts.Values) |
2862 | { | 3187 | { |
2863 | foreach (SceneObjectPart obPart in m_parts.Values) | 3188 | if (obPart.UUID != m_rootPart.UUID) |
2864 | { | 3189 | { |
2865 | if (obPart.UUID != m_rootPart.UUID) | 3190 | Vector3 oldSize = new Vector3(obPart.Scale); |
2866 | { | 3191 | obPart.IgnoreUndoUpdate = true; |
2867 | obPart.IgnoreUndoUpdate = true; | ||
2868 | Vector3 oldSize = new Vector3(obPart.Scale); | ||
2869 | 3192 | ||
2870 | float f = 1.0f; | 3193 | float f = 1.0f; |
2871 | float a = 1.0f; | 3194 | float a = 1.0f; |
2872 | 3195 | ||
2873 | if (part.PhysActor != null && part.PhysActor.IsPhysical) | 3196 | if (part.PhysActor != null && part.PhysActor.IsPhysical) |
3197 | { | ||
3198 | if (oldSize.X*x > m_scene.m_maxPhys) | ||
2874 | { | 3199 | { |
2875 | if (oldSize.X*x > m_scene.m_maxPhys) | 3200 | f = m_scene.m_maxPhys / oldSize.X; |
2876 | { | 3201 | a = f / x; |
2877 | f = m_scene.m_maxPhys / oldSize.X; | 3202 | x *= a; |
2878 | a = f / x; | 3203 | y *= a; |
2879 | x *= a; | 3204 | z *= a; |
2880 | y *= a; | ||
2881 | z *= a; | ||
2882 | } | ||
2883 | if (oldSize.Y*y > m_scene.m_maxPhys) | ||
2884 | { | ||
2885 | f = m_scene.m_maxPhys / oldSize.Y; | ||
2886 | a = f / y; | ||
2887 | x *= a; | ||
2888 | y *= a; | ||
2889 | z *= a; | ||
2890 | } | ||
2891 | if (oldSize.Z*z > m_scene.m_maxPhys) | ||
2892 | { | ||
2893 | f = m_scene.m_maxPhys / oldSize.Z; | ||
2894 | a = f / z; | ||
2895 | x *= a; | ||
2896 | y *= a; | ||
2897 | z *= a; | ||
2898 | } | ||
2899 | } | 3205 | } |
2900 | else | 3206 | if (oldSize.Y*y > m_scene.m_maxPhys) |
3207 | { | ||
3208 | f = m_scene.m_maxPhys / oldSize.Y; | ||
3209 | a = f / y; | ||
3210 | x *= a; | ||
3211 | y *= a; | ||
3212 | z *= a; | ||
3213 | } | ||
3214 | if (oldSize.Z*z > m_scene.m_maxPhys) | ||
3215 | { | ||
3216 | f = m_scene.m_maxPhys / oldSize.Z; | ||
3217 | a = f / z; | ||
3218 | x *= a; | ||
3219 | y *= a; | ||
3220 | z *= a; | ||
3221 | } | ||
3222 | } | ||
3223 | else | ||
3224 | { | ||
3225 | if (oldSize.X*x > m_scene.m_maxNonphys) | ||
3226 | { | ||
3227 | f = m_scene.m_maxNonphys / oldSize.X; | ||
3228 | a = f / x; | ||
3229 | x *= a; | ||
3230 | y *= a; | ||
3231 | z *= a; | ||
3232 | } | ||
3233 | if (oldSize.Y*y > m_scene.m_maxNonphys) | ||
3234 | { | ||
3235 | f = m_scene.m_maxNonphys / oldSize.Y; | ||
3236 | a = f / y; | ||
3237 | x *= a; | ||
3238 | y *= a; | ||
3239 | z *= a; | ||
3240 | } | ||
3241 | if (oldSize.Z*z > m_scene.m_maxNonphys) | ||
2901 | { | 3242 | { |
2902 | if (oldSize.X*x > m_scene.m_maxNonphys) | 3243 | f = m_scene.m_maxNonphys / oldSize.Z; |
2903 | { | 3244 | a = f / z; |
2904 | f = m_scene.m_maxNonphys / oldSize.X; | 3245 | x *= a; |
2905 | a = f / x; | 3246 | y *= a; |
2906 | x *= a; | 3247 | z *= a; |
2907 | y *= a; | ||
2908 | z *= a; | ||
2909 | } | ||
2910 | if (oldSize.Y*y > m_scene.m_maxNonphys) | ||
2911 | { | ||
2912 | f = m_scene.m_maxNonphys / oldSize.Y; | ||
2913 | a = f / y; | ||
2914 | x *= a; | ||
2915 | y *= a; | ||
2916 | z *= a; | ||
2917 | } | ||
2918 | if (oldSize.Z*z > m_scene.m_maxNonphys) | ||
2919 | { | ||
2920 | f = m_scene.m_maxNonphys / oldSize.Z; | ||
2921 | a = f / z; | ||
2922 | x *= a; | ||
2923 | y *= a; | ||
2924 | z *= a; | ||
2925 | } | ||
2926 | } | 3248 | } |
2927 | obPart.IgnoreUndoUpdate = false; | 3249 | |
2928 | obPart.StoreUndoState(); | ||
2929 | } | 3250 | } |
2930 | } | 3251 | } |
2931 | } | 3252 | } |
2932 | } | 3253 | } |
3254 | lockPartsForRead(false); | ||
2933 | 3255 | ||
2934 | Vector3 prevScale = part.Scale; | 3256 | Vector3 prevScale = part.Scale; |
2935 | prevScale.X *= x; | 3257 | prevScale.X *= x; |
2936 | prevScale.Y *= y; | 3258 | prevScale.Y *= y; |
2937 | prevScale.Z *= z; | 3259 | prevScale.Z *= z;; |
3260 | |||
3261 | part.IgnoreUndoUpdate = false; | ||
3262 | part.StoreUndoState(UndoType.STATE_GROUP_SCALE); | ||
3263 | part.IgnoreUndoUpdate = true; | ||
2938 | part.Resize(prevScale); | 3264 | part.Resize(prevScale); |
3265 | part.IgnoreUndoUpdate = false; | ||
2939 | 3266 | ||
2940 | lock (m_parts) | 3267 | lockPartsForRead(true); |
2941 | { | 3268 | { |
2942 | foreach (SceneObjectPart obPart in m_parts.Values) | 3269 | foreach (SceneObjectPart obPart in m_parts.Values) |
2943 | { | 3270 | { |
2944 | obPart.IgnoreUndoUpdate = true; | ||
2945 | if (obPart.UUID != m_rootPart.UUID) | 3271 | if (obPart.UUID != m_rootPart.UUID) |
2946 | { | 3272 | { |
3273 | obPart.IgnoreUndoUpdate = false; | ||
3274 | obPart.StoreUndoState(UndoType.STATE_GROUP_SCALE); | ||
3275 | obPart.IgnoreUndoUpdate = true; | ||
3276 | |||
2947 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); | 3277 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); |
2948 | currentpos.X *= x; | 3278 | currentpos.X *= x; |
2949 | currentpos.Y *= y; | 3279 | currentpos.Y *= y; |
@@ -2956,9 +3286,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2956 | obPart.UpdateOffSet(currentpos); | 3286 | obPart.UpdateOffSet(currentpos); |
2957 | } | 3287 | } |
2958 | obPart.IgnoreUndoUpdate = false; | 3288 | obPart.IgnoreUndoUpdate = false; |
2959 | obPart.StoreUndoState(); | ||
2960 | } | 3289 | } |
2961 | } | 3290 | } |
3291 | lockPartsForRead(false); | ||
2962 | 3292 | ||
2963 | if (part.PhysActor != null) | 3293 | if (part.PhysActor != null) |
2964 | { | 3294 | { |
@@ -2967,7 +3297,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2967 | } | 3297 | } |
2968 | 3298 | ||
2969 | part.IgnoreUndoUpdate = false; | 3299 | part.IgnoreUndoUpdate = false; |
2970 | part.StoreUndoState(); | ||
2971 | HasGroupChanged = true; | 3300 | HasGroupChanged = true; |
2972 | ScheduleGroupForTerseUpdate(); | 3301 | ScheduleGroupForTerseUpdate(); |
2973 | } | 3302 | } |
@@ -2983,14 +3312,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2983 | /// <param name="pos"></param> | 3312 | /// <param name="pos"></param> |
2984 | public void UpdateGroupPosition(Vector3 pos) | 3313 | public void UpdateGroupPosition(Vector3 pos) |
2985 | { | 3314 | { |
2986 | foreach (SceneObjectPart part in Children.Values) | ||
2987 | { | ||
2988 | part.StoreUndoState(); | ||
2989 | } | ||
2990 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 3315 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
2991 | { | 3316 | { |
2992 | if (IsAttachment) | 3317 | if (IsAttachment) |
2993 | { | 3318 | { |
3319 | m_rootPart.StoreUndoState(UndoType.STATE_GROUP_POSITION); | ||
2994 | m_rootPart.AttachedPos = pos; | 3320 | m_rootPart.AttachedPos = pos; |
2995 | } | 3321 | } |
2996 | if (RootPart.GetStatusSandbox()) | 3322 | if (RootPart.GetStatusSandbox()) |
@@ -3023,7 +3349,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3023 | SceneObjectPart part = GetChildPart(localID); | 3349 | SceneObjectPart part = GetChildPart(localID); |
3024 | foreach (SceneObjectPart parts in Children.Values) | 3350 | foreach (SceneObjectPart parts in Children.Values) |
3025 | { | 3351 | { |
3026 | parts.StoreUndoState(); | 3352 | parts.StoreUndoState(UndoType.STATE_PRIM_POSITION); |
3027 | } | 3353 | } |
3028 | if (part != null) | 3354 | if (part != null) |
3029 | { | 3355 | { |
@@ -3048,7 +3374,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3048 | { | 3374 | { |
3049 | foreach (SceneObjectPart part in Children.Values) | 3375 | foreach (SceneObjectPart part in Children.Values) |
3050 | { | 3376 | { |
3051 | part.StoreUndoState(); | 3377 | part.StoreUndoState(UndoType.STATE_PRIM_POSITION); |
3052 | } | 3378 | } |
3053 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); | 3379 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); |
3054 | Vector3 oldPos = | 3380 | Vector3 oldPos = |
@@ -3061,7 +3387,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3061 | axDiff *= Quaternion.Inverse(partRotation); | 3387 | axDiff *= Quaternion.Inverse(partRotation); |
3062 | diff = axDiff; | 3388 | diff = axDiff; |
3063 | 3389 | ||
3064 | lock (m_parts) | 3390 | lockPartsForRead(true); |
3065 | { | 3391 | { |
3066 | foreach (SceneObjectPart obPart in m_parts.Values) | 3392 | foreach (SceneObjectPart obPart in m_parts.Values) |
3067 | { | 3393 | { |
@@ -3071,11 +3397,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
3071 | } | 3397 | } |
3072 | } | 3398 | } |
3073 | } | 3399 | } |
3400 | lockPartsForRead(false); | ||
3074 | 3401 | ||
3075 | AbsolutePosition = newPos; | 3402 | //We have to set undoing here because otherwise an undo state will be saved |
3403 | if (!m_rootPart.Undoing) | ||
3404 | { | ||
3405 | m_rootPart.Undoing = true; | ||
3406 | AbsolutePosition = newPos; | ||
3407 | m_rootPart.Undoing = false; | ||
3408 | } | ||
3409 | else | ||
3410 | { | ||
3411 | AbsolutePosition = newPos; | ||
3412 | } | ||
3076 | 3413 | ||
3077 | HasGroupChanged = true; | 3414 | HasGroupChanged = true; |
3078 | ScheduleGroupForTerseUpdate(); | 3415 | if (m_rootPart.Undoing) |
3416 | { | ||
3417 | ScheduleGroupForFullUpdate(); | ||
3418 | } | ||
3419 | else | ||
3420 | { | ||
3421 | ScheduleGroupForTerseUpdate(); | ||
3422 | } | ||
3079 | } | 3423 | } |
3080 | 3424 | ||
3081 | public void OffsetForNewRegion(Vector3 offset) | 3425 | public void OffsetForNewRegion(Vector3 offset) |
@@ -3095,7 +3439,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3095 | { | 3439 | { |
3096 | foreach (SceneObjectPart parts in Children.Values) | 3440 | foreach (SceneObjectPart parts in Children.Values) |
3097 | { | 3441 | { |
3098 | parts.StoreUndoState(); | 3442 | parts.StoreUndoState(UndoType.STATE_GROUP_ROTATION); |
3099 | } | 3443 | } |
3100 | m_rootPart.UpdateRotation(rot); | 3444 | m_rootPart.UpdateRotation(rot); |
3101 | 3445 | ||
@@ -3119,7 +3463,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3119 | { | 3463 | { |
3120 | foreach (SceneObjectPart parts in Children.Values) | 3464 | foreach (SceneObjectPart parts in Children.Values) |
3121 | { | 3465 | { |
3122 | parts.StoreUndoState(); | 3466 | parts.StoreUndoState(UndoType.STATE_GROUP_ROTATION); |
3123 | } | 3467 | } |
3124 | m_rootPart.UpdateRotation(rot); | 3468 | m_rootPart.UpdateRotation(rot); |
3125 | 3469 | ||
@@ -3146,7 +3490,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3146 | SceneObjectPart part = GetChildPart(localID); | 3490 | SceneObjectPart part = GetChildPart(localID); |
3147 | foreach (SceneObjectPart parts in Children.Values) | 3491 | foreach (SceneObjectPart parts in Children.Values) |
3148 | { | 3492 | { |
3149 | parts.StoreUndoState(); | 3493 | parts.StoreUndoState(UndoType.STATE_PRIM_ROTATION); |
3150 | } | 3494 | } |
3151 | if (part != null) | 3495 | if (part != null) |
3152 | { | 3496 | { |
@@ -3174,15 +3518,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3174 | if (part.UUID == m_rootPart.UUID) | 3518 | if (part.UUID == m_rootPart.UUID) |
3175 | { | 3519 | { |
3176 | UpdateRootRotation(rot); | 3520 | UpdateRootRotation(rot); |
3177 | AbsolutePosition = pos; | 3521 | if (!m_rootPart.Undoing) |
3522 | { | ||
3523 | m_rootPart.Undoing = true; | ||
3524 | AbsolutePosition = pos; | ||
3525 | m_rootPart.Undoing = false; | ||
3526 | } | ||
3527 | else | ||
3528 | { | ||
3529 | AbsolutePosition = pos; | ||
3530 | } | ||
3178 | } | 3531 | } |
3179 | else | 3532 | else |
3180 | { | 3533 | { |
3534 | part.StoreUndoState(UndoType.STATE_PRIM_ROTATION); | ||
3181 | part.IgnoreUndoUpdate = true; | 3535 | part.IgnoreUndoUpdate = true; |
3182 | part.UpdateRotation(rot); | 3536 | part.UpdateRotation(rot); |
3183 | part.OffsetPosition = pos; | 3537 | part.OffsetPosition = pos; |
3184 | part.IgnoreUndoUpdate = false; | 3538 | part.IgnoreUndoUpdate = false; |
3185 | part.StoreUndoState(); | ||
3186 | } | 3539 | } |
3187 | } | 3540 | } |
3188 | } | 3541 | } |
@@ -3196,7 +3549,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3196 | Quaternion axRot = rot; | 3549 | Quaternion axRot = rot; |
3197 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 3550 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
3198 | 3551 | ||
3199 | m_rootPart.StoreUndoState(); | 3552 | m_rootPart.StoreUndoState(UndoType.STATE_PRIM_ROTATION); |
3553 | bool cancelUndo = false; | ||
3554 | if (!m_rootPart.Undoing) | ||
3555 | { | ||
3556 | m_rootPart.Undoing = true; | ||
3557 | cancelUndo = true; | ||
3558 | } | ||
3200 | m_rootPart.UpdateRotation(rot); | 3559 | m_rootPart.UpdateRotation(rot); |
3201 | if (m_rootPart.PhysActor != null) | 3560 | if (m_rootPart.PhysActor != null) |
3202 | { | 3561 | { |
@@ -3204,33 +3563,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
3204 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 3563 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); |
3205 | } | 3564 | } |
3206 | 3565 | ||
3207 | lock (m_parts) | 3566 | lockPartsForRead(true); |
3567 | |||
3568 | foreach (SceneObjectPart prim in m_parts.Values) | ||
3208 | { | 3569 | { |
3209 | foreach (SceneObjectPart prim in m_parts.Values) | 3570 | if (prim.UUID != m_rootPart.UUID) |
3210 | { | 3571 | { |
3211 | if (prim.UUID != m_rootPart.UUID) | 3572 | prim.IgnoreUndoUpdate = true; |
3212 | { | 3573 | Vector3 axPos = prim.OffsetPosition; |
3213 | prim.IgnoreUndoUpdate = true; | 3574 | axPos *= oldParentRot; |
3214 | Vector3 axPos = prim.OffsetPosition; | 3575 | axPos *= Quaternion.Inverse(axRot); |
3215 | axPos *= oldParentRot; | 3576 | prim.OffsetPosition = axPos; |
3216 | axPos *= Quaternion.Inverse(axRot); | 3577 | Quaternion primsRot = prim.RotationOffset; |
3217 | prim.OffsetPosition = axPos; | 3578 | Quaternion newRot = primsRot * oldParentRot; |
3218 | Quaternion primsRot = prim.RotationOffset; | 3579 | newRot *= Quaternion.Inverse(axRot); |
3219 | Quaternion newRot = primsRot * oldParentRot; | 3580 | prim.RotationOffset = newRot; |
3220 | newRot *= Quaternion.Inverse(axRot); | 3581 | prim.ScheduleTerseUpdate(); |
3221 | prim.RotationOffset = newRot; | 3582 | prim.IgnoreUndoUpdate = false; |
3222 | prim.ScheduleTerseUpdate(); | ||
3223 | } | ||
3224 | } | 3583 | } |
3225 | } | 3584 | } |
3226 | foreach (SceneObjectPart childpart in Children.Values) | 3585 | if (cancelUndo == true) |
3227 | { | 3586 | { |
3228 | if (childpart != m_rootPart) | 3587 | m_rootPart.Undoing = false; |
3229 | { | ||
3230 | childpart.IgnoreUndoUpdate = false; | ||
3231 | childpart.StoreUndoState(); | ||
3232 | } | ||
3233 | } | 3588 | } |
3589 | lockPartsForRead(false); | ||
3590 | |||
3234 | m_rootPart.ScheduleTerseUpdate(); | 3591 | m_rootPart.ScheduleTerseUpdate(); |
3235 | } | 3592 | } |
3236 | 3593 | ||
@@ -3352,7 +3709,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3352 | if (atTargets.Count > 0) | 3709 | if (atTargets.Count > 0) |
3353 | { | 3710 | { |
3354 | uint[] localids = new uint[0]; | 3711 | uint[] localids = new uint[0]; |
3355 | lock (m_parts) | 3712 | lockPartsForRead(true); |
3356 | { | 3713 | { |
3357 | localids = new uint[m_parts.Count]; | 3714 | localids = new uint[m_parts.Count]; |
3358 | int cntr = 0; | 3715 | int cntr = 0; |
@@ -3362,6 +3719,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3362 | cntr++; | 3719 | cntr++; |
3363 | } | 3720 | } |
3364 | } | 3721 | } |
3722 | lockPartsForRead(false); | ||
3365 | 3723 | ||
3366 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3724 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3367 | { | 3725 | { |
@@ -3380,7 +3738,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3380 | { | 3738 | { |
3381 | //trigger not_at_target | 3739 | //trigger not_at_target |
3382 | uint[] localids = new uint[0]; | 3740 | uint[] localids = new uint[0]; |
3383 | lock (m_parts) | 3741 | lockPartsForRead(true); |
3384 | { | 3742 | { |
3385 | localids = new uint[m_parts.Count]; | 3743 | localids = new uint[m_parts.Count]; |
3386 | int cntr = 0; | 3744 | int cntr = 0; |
@@ -3390,7 +3748,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3390 | cntr++; | 3748 | cntr++; |
3391 | } | 3749 | } |
3392 | } | 3750 | } |
3393 | 3751 | lockPartsForRead(false); | |
3752 | |||
3394 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3753 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3395 | { | 3754 | { |
3396 | m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]); | 3755 | m_scene.EventManager.TriggerNotAtTargetEvent(localids[ctr]); |
@@ -3431,7 +3790,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3431 | if (atRotTargets.Count > 0) | 3790 | if (atRotTargets.Count > 0) |
3432 | { | 3791 | { |
3433 | uint[] localids = new uint[0]; | 3792 | uint[] localids = new uint[0]; |
3434 | lock (m_parts) | 3793 | lockPartsForRead(true); |
3794 | try | ||
3435 | { | 3795 | { |
3436 | localids = new uint[m_parts.Count]; | 3796 | localids = new uint[m_parts.Count]; |
3437 | int cntr = 0; | 3797 | int cntr = 0; |
@@ -3441,6 +3801,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3441 | cntr++; | 3801 | cntr++; |
3442 | } | 3802 | } |
3443 | } | 3803 | } |
3804 | finally | ||
3805 | { | ||
3806 | lockPartsForRead(false); | ||
3807 | } | ||
3444 | 3808 | ||
3445 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3809 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3446 | { | 3810 | { |
@@ -3459,7 +3823,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3459 | { | 3823 | { |
3460 | //trigger not_at_target | 3824 | //trigger not_at_target |
3461 | uint[] localids = new uint[0]; | 3825 | uint[] localids = new uint[0]; |
3462 | lock (m_parts) | 3826 | lockPartsForRead(true); |
3827 | try | ||
3463 | { | 3828 | { |
3464 | localids = new uint[m_parts.Count]; | 3829 | localids = new uint[m_parts.Count]; |
3465 | int cntr = 0; | 3830 | int cntr = 0; |
@@ -3469,6 +3834,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3469 | cntr++; | 3834 | cntr++; |
3470 | } | 3835 | } |
3471 | } | 3836 | } |
3837 | finally | ||
3838 | { | ||
3839 | lockPartsForRead(false); | ||
3840 | } | ||
3472 | 3841 | ||
3473 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3842 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3474 | { | 3843 | { |
@@ -3482,19 +3851,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3482 | public float GetMass() | 3851 | public float GetMass() |
3483 | { | 3852 | { |
3484 | float retmass = 0f; | 3853 | float retmass = 0f; |
3485 | lock (m_parts) | 3854 | lockPartsForRead(true); |
3486 | { | 3855 | { |
3487 | foreach (SceneObjectPart part in m_parts.Values) | 3856 | foreach (SceneObjectPart part in m_parts.Values) |
3488 | { | 3857 | { |
3489 | retmass += part.GetMass(); | 3858 | retmass += part.GetMass(); |
3490 | } | 3859 | } |
3491 | } | 3860 | } |
3861 | lockPartsForRead(false); | ||
3492 | return retmass; | 3862 | return retmass; |
3493 | } | 3863 | } |
3494 | 3864 | ||
3495 | public void CheckSculptAndLoad() | 3865 | public void CheckSculptAndLoad() |
3496 | { | 3866 | { |
3497 | lock (m_parts) | 3867 | lockPartsForRead(true); |
3498 | { | 3868 | { |
3499 | if (!IsDeleted) | 3869 | if (!IsDeleted) |
3500 | { | 3870 | { |
@@ -3519,6 +3889,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3519 | } | 3889 | } |
3520 | } | 3890 | } |
3521 | } | 3891 | } |
3892 | lockPartsForRead(false); | ||
3522 | } | 3893 | } |
3523 | 3894 | ||
3524 | protected void AssetReceived(string id, Object sender, AssetBase asset) | 3895 | protected void AssetReceived(string id, Object sender, AssetBase asset) |
@@ -3539,7 +3910,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3539 | /// <param name="client"></param> | 3910 | /// <param name="client"></param> |
3540 | public void SetGroup(UUID GroupID, IClientAPI client) | 3911 | public void SetGroup(UUID GroupID, IClientAPI client) |
3541 | { | 3912 | { |
3542 | lock (m_parts) | 3913 | lockPartsForRead(true); |
3543 | { | 3914 | { |
3544 | foreach (SceneObjectPart part in m_parts.Values) | 3915 | foreach (SceneObjectPart part in m_parts.Values) |
3545 | { | 3916 | { |
@@ -3549,6 +3920,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3549 | 3920 | ||
3550 | HasGroupChanged = true; | 3921 | HasGroupChanged = true; |
3551 | } | 3922 | } |
3923 | lockPartsForRead(false); | ||
3552 | 3924 | ||
3553 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | 3925 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
3554 | // for the same object with very different properties. The caller must schedule the update. | 3926 | // for the same object with very different properties. The caller must schedule the update. |
@@ -3570,11 +3942,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3570 | 3942 | ||
3571 | public void SetAttachmentPoint(byte point) | 3943 | public void SetAttachmentPoint(byte point) |
3572 | { | 3944 | { |
3573 | lock (m_parts) | 3945 | lockPartsForRead(true); |
3574 | { | 3946 | { |
3575 | foreach (SceneObjectPart part in m_parts.Values) | 3947 | foreach (SceneObjectPart part in m_parts.Values) |
3576 | part.SetAttachmentPoint(point); | 3948 | part.SetAttachmentPoint(point); |
3577 | } | 3949 | } |
3950 | lockPartsForRead(false); | ||
3578 | } | 3951 | } |
3579 | 3952 | ||
3580 | #region ISceneObject | 3953 | #region ISceneObject |
@@ -3608,6 +3981,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3608 | SetFromItemID(uuid); | 3981 | SetFromItemID(uuid); |
3609 | } | 3982 | } |
3610 | 3983 | ||
3984 | public void ResetOwnerChangeFlag() | ||
3985 | { | ||
3986 | ForEachPart(delegate(SceneObjectPart part) | ||
3987 | { | ||
3988 | part.ResetOwnerChangeFlag(); | ||
3989 | }); | ||
3990 | } | ||
3991 | |||
3611 | #endregion | 3992 | #endregion |
3612 | } | 3993 | } |
3613 | } | 3994 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index e331bb0..032fbe8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -147,7 +147,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
147 | 147 | ||
148 | // TODO: This needs to be persisted in next XML version update! | 148 | // TODO: This needs to be persisted in next XML version update! |
149 | [XmlIgnore] | 149 | [XmlIgnore] |
150 | public readonly int[] PayPrice = {-2,-2,-2,-2,-2}; | 150 | public int[] PayPrice = {-2,-2,-2,-2,-2}; |
151 | [XmlIgnore] | 151 | [XmlIgnore] |
152 | public PhysicsActor PhysActor; | 152 | public PhysicsActor PhysActor; |
153 | 153 | ||
@@ -182,6 +182,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
182 | [XmlIgnore] | 182 | [XmlIgnore] |
183 | public UUID FromFolderID; | 183 | public UUID FromFolderID; |
184 | 184 | ||
185 | // The following two are to hold the attachment data | ||
186 | // while an object is inworld | ||
187 | [XmlIgnore] | ||
188 | public byte AttachPoint = 0; | ||
189 | |||
190 | [XmlIgnore] | ||
191 | public Vector3 AttachOffset = Vector3.Zero; | ||
192 | |||
185 | [XmlIgnore] | 193 | [XmlIgnore] |
186 | public int STATUS_ROTATE_X; | 194 | public int STATUS_ROTATE_X; |
187 | 195 | ||
@@ -277,6 +285,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
277 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; | 285 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; |
278 | private Vector3 m_sitTargetPosition; | 286 | private Vector3 m_sitTargetPosition; |
279 | private string m_sitAnimation = "SIT"; | 287 | private string m_sitAnimation = "SIT"; |
288 | private bool m_occupied; // KF if any av is sitting on this prim | ||
280 | private string m_text = String.Empty; | 289 | private string m_text = String.Empty; |
281 | private string m_touchName = String.Empty; | 290 | private string m_touchName = String.Empty; |
282 | private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5); | 291 | private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5); |
@@ -360,7 +369,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
360 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, | 369 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, |
361 | Quaternion rotationOffset, Vector3 offsetPosition) | 370 | Quaternion rotationOffset, Vector3 offsetPosition) |
362 | { | 371 | { |
363 | m_name = "Primitive"; | 372 | m_name = "Object"; |
364 | 373 | ||
365 | Rezzed = DateTime.UtcNow; | 374 | Rezzed = DateTime.UtcNow; |
366 | _creationDate = (int)Utils.DateTimeToUnixTime(Rezzed); | 375 | _creationDate = (int)Utils.DateTimeToUnixTime(Rezzed); |
@@ -456,12 +465,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
456 | } | 465 | } |
457 | 466 | ||
458 | /// <value> | 467 | /// <value> |
459 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 468 | /// Get the inventory list |
460 | /// </value> | 469 | /// </value> |
461 | public TaskInventoryDictionary TaskInventory | 470 | public TaskInventoryDictionary TaskInventory |
462 | { | 471 | { |
463 | get { return m_inventory.Items; } | 472 | get { |
464 | set { m_inventory.Items = value; } | 473 | return m_inventory.Items; |
474 | } | ||
475 | set { | ||
476 | m_inventory.Items = value; | ||
477 | } | ||
465 | } | 478 | } |
466 | 479 | ||
467 | public uint ObjectFlags | 480 | public uint ObjectFlags |
@@ -590,14 +603,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
590 | set { m_LoopSoundSlavePrims = value; } | 603 | set { m_LoopSoundSlavePrims = value; } |
591 | } | 604 | } |
592 | 605 | ||
593 | [XmlIgnore] | ||
594 | public Byte[] TextureAnimation | 606 | public Byte[] TextureAnimation |
595 | { | 607 | { |
596 | get { return m_TextureAnimation; } | 608 | get { return m_TextureAnimation; } |
597 | set { m_TextureAnimation = value; } | 609 | set { m_TextureAnimation = value; } |
598 | } | 610 | } |
599 | 611 | ||
600 | [XmlIgnore] | ||
601 | public Byte[] ParticleSystem | 612 | public Byte[] ParticleSystem |
602 | { | 613 | { |
603 | get { return m_particleSystem; } | 614 | get { return m_particleSystem; } |
@@ -651,7 +662,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
651 | set | 662 | set |
652 | { | 663 | { |
653 | m_groupPosition = value; | 664 | m_groupPosition = value; |
654 | |||
655 | PhysicsActor actor = PhysActor; | 665 | PhysicsActor actor = PhysActor; |
656 | if (actor != null) | 666 | if (actor != null) |
657 | { | 667 | { |
@@ -698,7 +708,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
698 | get { return m_offsetPosition; } | 708 | get { return m_offsetPosition; } |
699 | set | 709 | set |
700 | { | 710 | { |
701 | StoreUndoState(); | 711 | StoreUndoState(UndoType.STATE_PRIM_POSITION); |
702 | m_offsetPosition = value; | 712 | m_offsetPosition = value; |
703 | 713 | ||
704 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 714 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
@@ -712,6 +722,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
712 | // Tell the physics engines that this prim changed. | 722 | // Tell the physics engines that this prim changed. |
713 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 723 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
714 | } | 724 | } |
725 | |||
726 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); | ||
727 | foreach (ScenePresence av in avs) | ||
728 | { | ||
729 | av.SendFullUpdateToAllClients(); | ||
730 | } | ||
715 | } | 731 | } |
716 | } | 732 | } |
717 | } | 733 | } |
@@ -754,7 +770,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
754 | 770 | ||
755 | set | 771 | set |
756 | { | 772 | { |
757 | StoreUndoState(); | 773 | StoreUndoState(UndoType.STATE_PRIM_ROTATION); |
758 | m_rotationOffset = value; | 774 | m_rotationOffset = value; |
759 | 775 | ||
760 | PhysicsActor actor = PhysActor; | 776 | PhysicsActor actor = PhysActor; |
@@ -838,7 +854,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
838 | /// <summary></summary> | 854 | /// <summary></summary> |
839 | public Vector3 Acceleration | 855 | public Vector3 Acceleration |
840 | { | 856 | { |
841 | get { return m_acceleration; } | 857 | get |
858 | { | ||
859 | PhysicsActor actor = PhysActor; | ||
860 | if (actor != null) | ||
861 | { | ||
862 | m_acceleration = actor.Acceleration; | ||
863 | } | ||
864 | return m_acceleration; | ||
865 | } | ||
866 | |||
842 | set { m_acceleration = value; } | 867 | set { m_acceleration = value; } |
843 | } | 868 | } |
844 | 869 | ||
@@ -865,7 +890,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
865 | set | 890 | set |
866 | { | 891 | { |
867 | m_color = value; | 892 | m_color = value; |
868 | TriggerScriptChangedEvent(Changed.COLOR); | ||
869 | 893 | ||
870 | /* ScheduleFullUpdate() need not be called b/c after | 894 | /* ScheduleFullUpdate() need not be called b/c after |
871 | * setting the color, the text will be set, so then | 895 | * setting the color, the text will be set, so then |
@@ -944,7 +968,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
944 | get { return m_shape.Scale; } | 968 | get { return m_shape.Scale; } |
945 | set | 969 | set |
946 | { | 970 | { |
947 | StoreUndoState(); | 971 | StoreUndoState(UndoType.STATE_PRIM_SCALE); |
948 | if (m_shape != null) | 972 | if (m_shape != null) |
949 | { | 973 | { |
950 | m_shape.Scale = value; | 974 | m_shape.Scale = value; |
@@ -989,7 +1013,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
989 | if (IsAttachment) | 1013 | if (IsAttachment) |
990 | return GroupPosition; | 1014 | return GroupPosition; |
991 | 1015 | ||
992 | return m_offsetPosition + m_groupPosition; } | 1016 | // return m_offsetPosition + m_groupPosition; } |
1017 | return m_groupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset) ; } //KF: Rotation was ignored! | ||
993 | } | 1018 | } |
994 | 1019 | ||
995 | public SceneObjectGroup ParentGroup | 1020 | public SceneObjectGroup ParentGroup |
@@ -1140,6 +1165,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1140 | get { return _flags; } | 1165 | get { return _flags; } |
1141 | set { _flags = value; } | 1166 | set { _flags = value; } |
1142 | } | 1167 | } |
1168 | |||
1169 | [XmlIgnore] | ||
1170 | public bool IsOccupied // KF If an av is sittingon this prim | ||
1171 | { | ||
1172 | get { return m_occupied; } | ||
1173 | set { m_occupied = value; } | ||
1174 | } | ||
1143 | 1175 | ||
1144 | [XmlIgnore] | 1176 | [XmlIgnore] |
1145 | public UUID SitTargetAvatar | 1177 | public UUID SitTargetAvatar |
@@ -1215,14 +1247,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1215 | } | 1247 | } |
1216 | } | 1248 | } |
1217 | 1249 | ||
1218 | /// <summary> | ||
1219 | /// Clear all pending updates of parts to clients | ||
1220 | /// </summary> | ||
1221 | private void ClearUpdateSchedule() | ||
1222 | { | ||
1223 | m_updateFlag = 0; | ||
1224 | } | ||
1225 | |||
1226 | private void SendObjectPropertiesToClient(UUID AgentID) | 1250 | private void SendObjectPropertiesToClient(UUID AgentID) |
1227 | { | 1251 | { |
1228 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 1252 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) |
@@ -1473,14 +1497,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1473 | // or flexible | 1497 | // or flexible |
1474 | if (!isPhantom && !IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible)) | 1498 | if (!isPhantom && !IsAttachment && !(Shape.PathCurve == (byte) Extrusion.Flexible)) |
1475 | { | 1499 | { |
1476 | PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( | 1500 | try |
1477 | Name, | 1501 | { |
1478 | Shape, | 1502 | PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape( |
1479 | AbsolutePosition, | 1503 | Name, |
1480 | Scale, | 1504 | Shape, |
1481 | RotationOffset, | 1505 | AbsolutePosition, |
1482 | RigidBody); | 1506 | Scale, |
1483 | 1507 | RotationOffset, | |
1508 | RigidBody); | ||
1509 | } | ||
1510 | catch | ||
1511 | { | ||
1512 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom.", m_uuid); | ||
1513 | PhysActor = null; | ||
1514 | } | ||
1484 | // Basic Physics returns null.. joy joy joy. | 1515 | // Basic Physics returns null.. joy joy joy. |
1485 | if (PhysActor != null) | 1516 | if (PhysActor != null) |
1486 | { | 1517 | { |
@@ -1508,7 +1539,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1508 | { | 1539 | { |
1509 | m_redo.Clear(); | 1540 | m_redo.Clear(); |
1510 | } | 1541 | } |
1511 | StoreUndoState(); | 1542 | StoreUndoState(UndoType.STATE_ALL); |
1512 | } | 1543 | } |
1513 | 1544 | ||
1514 | public byte ConvertScriptUintToByte(uint indata) | 1545 | public byte ConvertScriptUintToByte(uint indata) |
@@ -1611,7 +1642,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1611 | PrimitiveBaseShape shape = PrimitiveBaseShape.Create(); | 1642 | PrimitiveBaseShape shape = PrimitiveBaseShape.Create(); |
1612 | part.Shape = shape; | 1643 | part.Shape = shape; |
1613 | 1644 | ||
1614 | part.Name = "Primitive"; | 1645 | part.Name = "Object"; |
1615 | part._ownerID = UUID.Random(); | 1646 | part._ownerID = UUID.Random(); |
1616 | 1647 | ||
1617 | return part; | 1648 | return part; |
@@ -1734,7 +1765,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1734 | // which stops client-side interpolation of deactivated joint proxy objects. | 1765 | // which stops client-side interpolation of deactivated joint proxy objects. |
1735 | } | 1766 | } |
1736 | 1767 | ||
1737 | if (!UsePhysics && !isNew) | 1768 | if (!UsePhysics) |
1738 | { | 1769 | { |
1739 | // reset velocity to 0 on physics switch-off. Without that, the client thinks the | 1770 | // reset velocity to 0 on physics switch-off. Without that, the client thinks the |
1740 | // prim still has velocity and continues to interpolate its position along the old | 1771 | // prim still has velocity and continues to interpolate its position along the old |
@@ -1969,12 +2000,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1969 | public Vector3 GetWorldPosition() | 2000 | public Vector3 GetWorldPosition() |
1970 | { | 2001 | { |
1971 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; | 2002 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; |
1972 | |||
1973 | Vector3 axPos = OffsetPosition; | 2003 | Vector3 axPos = OffsetPosition; |
1974 | |||
1975 | axPos *= parentRot; | 2004 | axPos *= parentRot; |
1976 | Vector3 translationOffsetPosition = axPos; | 2005 | Vector3 translationOffsetPosition = axPos; |
1977 | return GroupPosition + translationOffsetPosition; | 2006 | if(_parentID == 0) |
2007 | { | ||
2008 | return GroupPosition; | ||
2009 | } | ||
2010 | else | ||
2011 | { | ||
2012 | return ParentGroup.AbsolutePosition + translationOffsetPosition; //KF: Fix child prim position | ||
2013 | } | ||
1978 | } | 2014 | } |
1979 | 2015 | ||
1980 | /// <summary> | 2016 | /// <summary> |
@@ -1985,7 +2021,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1985 | { | 2021 | { |
1986 | Quaternion newRot; | 2022 | Quaternion newRot; |
1987 | 2023 | ||
1988 | if (this.LinkNum == 0) | 2024 | if (this.LinkNum < 2) //KF Single or root prim |
1989 | { | 2025 | { |
1990 | newRot = RotationOffset; | 2026 | newRot = RotationOffset; |
1991 | } | 2027 | } |
@@ -2631,17 +2667,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2631 | //Trys to fetch sound id from prim's inventory. | 2667 | //Trys to fetch sound id from prim's inventory. |
2632 | //Prim's inventory doesn't support non script items yet | 2668 | //Prim's inventory doesn't support non script items yet |
2633 | 2669 | ||
2634 | lock (TaskInventory) | 2670 | TaskInventory.LockItemsForRead(true); |
2671 | |||
2672 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
2635 | { | 2673 | { |
2636 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 2674 | if (item.Value.Name == sound) |
2637 | { | 2675 | { |
2638 | if (item.Value.Name == sound) | 2676 | soundID = item.Value.ItemID; |
2639 | { | 2677 | break; |
2640 | soundID = item.Value.ItemID; | ||
2641 | break; | ||
2642 | } | ||
2643 | } | 2678 | } |
2644 | } | 2679 | } |
2680 | |||
2681 | TaskInventory.LockItemsForRead(false); | ||
2645 | } | 2682 | } |
2646 | 2683 | ||
2647 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp) | 2684 | m_parentGroup.Scene.ForEachScenePresence(delegate(ScenePresence sp) |
@@ -2701,7 +2738,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2701 | /// <param name="scale"></param> | 2738 | /// <param name="scale"></param> |
2702 | public void Resize(Vector3 scale) | 2739 | public void Resize(Vector3 scale) |
2703 | { | 2740 | { |
2704 | StoreUndoState(); | 2741 | StoreUndoState(UndoType.STATE_PRIM_SCALE); |
2705 | m_shape.Scale = scale; | 2742 | m_shape.Scale = scale; |
2706 | 2743 | ||
2707 | ParentGroup.HasGroupChanged = true; | 2744 | ParentGroup.HasGroupChanged = true; |
@@ -2710,38 +2747,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2710 | 2747 | ||
2711 | public void RotLookAt(Quaternion target, float strength, float damping) | 2748 | public void RotLookAt(Quaternion target, float strength, float damping) |
2712 | { | 2749 | { |
2713 | rotLookAt(target, strength, damping); | 2750 | m_parentGroup.rotLookAt(target, strength, damping); // This calls method in SceneObjectGroup. |
2714 | } | ||
2715 | |||
2716 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2717 | { | ||
2718 | if (IsAttachment) | ||
2719 | { | ||
2720 | /* | ||
2721 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
2722 | if (avatar != null) | ||
2723 | { | ||
2724 | Rotate the Av? | ||
2725 | } */ | ||
2726 | } | ||
2727 | else | ||
2728 | { | ||
2729 | APIDDamp = damping; | ||
2730 | APIDStrength = strength; | ||
2731 | APIDTarget = target; | ||
2732 | } | ||
2733 | } | ||
2734 | |||
2735 | public void startLookAt(Quaternion rot, float damp, float strength) | ||
2736 | { | ||
2737 | APIDDamp = damp; | ||
2738 | APIDStrength = strength; | ||
2739 | APIDTarget = rot; | ||
2740 | } | ||
2741 | |||
2742 | public void stopLookAt() | ||
2743 | { | ||
2744 | APIDTarget = Quaternion.Identity; | ||
2745 | } | 2751 | } |
2746 | 2752 | ||
2747 | /// <summary> | 2753 | /// <summary> |
@@ -2753,7 +2759,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2753 | 2759 | ||
2754 | if (m_parentGroup != null) | 2760 | if (m_parentGroup != null) |
2755 | { | 2761 | { |
2756 | m_parentGroup.QueueForUpdateCheck(); | 2762 | if (!m_parentGroup.areUpdatesSuspended) |
2763 | { | ||
2764 | m_parentGroup.QueueForUpdateCheck(); | ||
2765 | } | ||
2757 | } | 2766 | } |
2758 | 2767 | ||
2759 | int timeNow = Util.UnixTimeSinceEpoch(); | 2768 | int timeNow = Util.UnixTimeSinceEpoch(); |
@@ -2970,8 +2979,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2970 | { | 2979 | { |
2971 | const float ROTATION_TOLERANCE = 0.01f; | 2980 | const float ROTATION_TOLERANCE = 0.01f; |
2972 | const float VELOCITY_TOLERANCE = 0.001f; | 2981 | const float VELOCITY_TOLERANCE = 0.001f; |
2973 | const float POSITION_TOLERANCE = 0.05f; | 2982 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
2974 | const int TIME_MS_TOLERANCE = 3000; | 2983 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
2975 | 2984 | ||
2976 | if (m_updateFlag == 1) | 2985 | if (m_updateFlag == 1) |
2977 | { | 2986 | { |
@@ -2985,7 +2994,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2985 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 2994 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) |
2986 | { | 2995 | { |
2987 | AddTerseUpdateToAllAvatars(); | 2996 | AddTerseUpdateToAllAvatars(); |
2988 | ClearUpdateSchedule(); | 2997 | |
2989 | 2998 | ||
2990 | // This causes the Scene to 'poll' physical objects every couple of frames | 2999 | // This causes the Scene to 'poll' physical objects every couple of frames |
2991 | // bad, so it's been replaced by an event driven method. | 3000 | // bad, so it's been replaced by an event driven method. |
@@ -3003,16 +3012,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3003 | m_lastAngularVelocity = AngularVelocity; | 3012 | m_lastAngularVelocity = AngularVelocity; |
3004 | m_lastTerseSent = Environment.TickCount; | 3013 | m_lastTerseSent = Environment.TickCount; |
3005 | } | 3014 | } |
3015 | //Moved this outside of the if clause so updates don't get blocked.. *sigh* | ||
3016 | m_updateFlag = 0; //Why were we calling a function to do this? Inefficient! *screams* | ||
3006 | } | 3017 | } |
3007 | else | 3018 | else |
3008 | { | 3019 | { |
3009 | if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes | 3020 | if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes |
3010 | { | 3021 | { |
3011 | AddFullUpdateToAllAvatars(); | 3022 | AddFullUpdateToAllAvatars(); |
3012 | ClearUpdateSchedule(); | 3023 | m_updateFlag = 0; //Same here |
3013 | } | 3024 | } |
3014 | } | 3025 | } |
3015 | ClearUpdateSchedule(); | 3026 | m_updateFlag = 0; |
3016 | } | 3027 | } |
3017 | 3028 | ||
3018 | /// <summary> | 3029 | /// <summary> |
@@ -3039,17 +3050,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3039 | if (!UUID.TryParse(sound, out soundID)) | 3050 | if (!UUID.TryParse(sound, out soundID)) |
3040 | { | 3051 | { |
3041 | // search sound file from inventory | 3052 | // search sound file from inventory |
3042 | lock (TaskInventory) | 3053 | TaskInventory.LockItemsForRead(true); |
3054 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
3043 | { | 3055 | { |
3044 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 3056 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) |
3045 | { | 3057 | { |
3046 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) | 3058 | soundID = item.Value.ItemID; |
3047 | { | 3059 | break; |
3048 | soundID = item.Value.ItemID; | ||
3049 | break; | ||
3050 | } | ||
3051 | } | 3060 | } |
3052 | } | 3061 | } |
3062 | TaskInventory.LockItemsForRead(false); | ||
3053 | } | 3063 | } |
3054 | 3064 | ||
3055 | if (soundID == UUID.Zero) | 3065 | if (soundID == UUID.Zero) |
@@ -3484,7 +3494,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3484 | 3494 | ||
3485 | public void StopLookAt() | 3495 | public void StopLookAt() |
3486 | { | 3496 | { |
3487 | m_parentGroup.stopLookAt(); | 3497 | m_parentGroup.stopLookAt(); // This calls method in SceneObjectGroup. |
3488 | 3498 | ||
3489 | m_parentGroup.ScheduleGroupForTerseUpdate(); | 3499 | m_parentGroup.ScheduleGroupForTerseUpdate(); |
3490 | } | 3500 | } |
@@ -3511,10 +3521,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3511 | m_parentGroup.ScheduleGroupForTerseUpdate(); | 3521 | m_parentGroup.ScheduleGroupForTerseUpdate(); |
3512 | //m_parentGroup.ScheduleGroupForFullUpdate(); | 3522 | //m_parentGroup.ScheduleGroupForFullUpdate(); |
3513 | } | 3523 | } |
3514 | 3524 | public void StoreUndoState(UndoType type) | |
3515 | public void StoreUndoState() | ||
3516 | { | 3525 | { |
3517 | if (!Undoing) | 3526 | if (!Undoing && (m_parentGroup == null || m_parentGroup.RootPart == null || !m_parentGroup.RootPart.Undoing)) |
3518 | { | 3527 | { |
3519 | if (!IgnoreUndoUpdate) | 3528 | if (!IgnoreUndoUpdate) |
3520 | { | 3529 | { |
@@ -3525,17 +3534,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
3525 | if (m_undo.Count > 0) | 3534 | if (m_undo.Count > 0) |
3526 | { | 3535 | { |
3527 | UndoState last = m_undo.Peek(); | 3536 | UndoState last = m_undo.Peek(); |
3528 | if (last != null) | 3537 | |
3529 | { | ||
3530 | if (last.Compare(this)) | ||
3531 | return; | ||
3532 | } | ||
3533 | } | 3538 | } |
3534 | 3539 | ||
3535 | if (m_parentGroup.GetSceneMaxUndo() > 0) | 3540 | if (m_parentGroup.GetSceneMaxUndo() > 0) |
3536 | { | 3541 | { |
3537 | UndoState nUndo = new UndoState(this); | 3542 | UndoState lastUndo = m_undo.Peek(); |
3543 | |||
3544 | UndoState nUndo = new UndoState(this, type); | ||
3538 | 3545 | ||
3546 | if (lastUndo != null) | ||
3547 | { | ||
3548 | TimeSpan ts = DateTime.Now.Subtract(lastUndo.LastUpdated); | ||
3549 | if (ts.TotalMilliseconds < 500) | ||
3550 | { | ||
3551 | //Delete the last entry since it was less than 500 milliseconds ago | ||
3552 | nUndo.Merge(lastUndo); | ||
3553 | m_undo.Pop(); | ||
3554 | } | ||
3555 | } | ||
3539 | m_undo.Push(nUndo); | 3556 | m_undo.Push(nUndo); |
3540 | } | 3557 | } |
3541 | 3558 | ||
@@ -4012,11 +4029,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
4012 | if (m_undo.Count > 0) | 4029 | if (m_undo.Count > 0) |
4013 | { | 4030 | { |
4014 | UndoState nUndo = null; | 4031 | UndoState nUndo = null; |
4032 | UndoState goback = m_undo.Pop(); | ||
4015 | if (m_parentGroup.GetSceneMaxUndo() > 0) | 4033 | if (m_parentGroup.GetSceneMaxUndo() > 0) |
4016 | { | 4034 | { |
4017 | nUndo = new UndoState(this); | 4035 | nUndo = new UndoState(this, goback.Type); |
4018 | } | 4036 | } |
4019 | UndoState goback = m_undo.Pop(); | 4037 | |
4038 | |||
4020 | if (goback != null) | 4039 | if (goback != null) |
4021 | { | 4040 | { |
4022 | goback.PlaybackState(this); | 4041 | goback.PlaybackState(this); |
@@ -4031,13 +4050,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
4031 | { | 4050 | { |
4032 | lock (m_redo) | 4051 | lock (m_redo) |
4033 | { | 4052 | { |
4053 | UndoState gofwd = m_redo.Pop(); | ||
4034 | if (m_parentGroup.GetSceneMaxUndo() > 0) | 4054 | if (m_parentGroup.GetSceneMaxUndo() > 0) |
4035 | { | 4055 | { |
4036 | UndoState nUndo = new UndoState(this); | 4056 | UndoState nUndo = new UndoState(this, gofwd.Type); |
4037 | 4057 | ||
4038 | m_undo.Push(nUndo); | 4058 | m_undo.Push(nUndo); |
4039 | } | 4059 | } |
4040 | UndoState gofwd = m_redo.Pop(); | ||
4041 | if (gofwd != null) | 4060 | if (gofwd != null) |
4042 | gofwd.PlayfwdState(this); | 4061 | gofwd.PlayfwdState(this); |
4043 | } | 4062 | } |
@@ -4485,8 +4504,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4485 | { | 4504 | { |
4486 | m_shape.TextureEntry = textureEntry; | 4505 | m_shape.TextureEntry = textureEntry; |
4487 | TriggerScriptChangedEvent(Changed.TEXTURE); | 4506 | TriggerScriptChangedEvent(Changed.TEXTURE); |
4488 | 4507 | m_updateFlag = 1; | |
4489 | ParentGroup.HasGroupChanged = true; | 4508 | ParentGroup.HasGroupChanged = true; |
4509 | |||
4490 | //This is madness.. | 4510 | //This is madness.. |
4491 | //ParentGroup.ScheduleGroupForFullUpdate(); | 4511 | //ParentGroup.ScheduleGroupForFullUpdate(); |
4492 | //This is sparta | 4512 | //This is sparta |
@@ -4731,5 +4751,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
4731 | Color color = Color; | 4751 | Color color = Color; |
4732 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 4752 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4733 | } | 4753 | } |
4754 | |||
4755 | public void ResetOwnerChangeFlag() | ||
4756 | { | ||
4757 | List<UUID> inv = Inventory.GetInventoryList(); | ||
4758 | |||
4759 | foreach (UUID itemID in inv) | ||
4760 | { | ||
4761 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
4762 | item.OwnerChanged = false; | ||
4763 | Inventory.UpdateInventoryItem(item); | ||
4764 | } | ||
4765 | } | ||
4734 | } | 4766 | } |
4735 | } | 4767 | } |
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 1e8ce22..1fc4a81 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 |
@@ -668,7 +721,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
668 | CreateSceneViewer(); | 721 | CreateSceneViewer(); |
669 | m_animator = new ScenePresenceAnimator(this); | 722 | m_animator = new ScenePresenceAnimator(this); |
670 | } | 723 | } |
671 | 724 | ||
672 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() | 725 | private ScenePresence(IClientAPI client, Scene world, RegionInfo reginfo) : this() |
673 | { | 726 | { |
674 | m_rootRegionHandle = reginfo.RegionHandle; | 727 | m_rootRegionHandle = reginfo.RegionHandle; |
@@ -700,16 +753,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
700 | m_reprioritization_timer.AutoReset = false; | 753 | m_reprioritization_timer.AutoReset = false; |
701 | 754 | ||
702 | AdjustKnownSeeds(); | 755 | AdjustKnownSeeds(); |
703 | |||
704 | // TODO: I think, this won't send anything, as we are still a child here... | ||
705 | Animator.TrySetMovementAnimation("STAND"); | 756 | Animator.TrySetMovementAnimation("STAND"); |
706 | |||
707 | // we created a new ScenePresence (a new child agent) in a fresh region. | 757 | // we created a new ScenePresence (a new child agent) in a fresh region. |
708 | // Request info about all the (root) agents in this region | 758 | // 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) | 759 | // Note: This won't send data *to* other clients in that region (children don't send) |
710 | SendInitialFullUpdateToAllClients(); | 760 | SendInitialFullUpdateToAllClients(); |
711 | |||
712 | RegisterToEvents(); | 761 | RegisterToEvents(); |
762 | if (m_controllingClient != null) | ||
763 | { | ||
764 | m_controllingClient.ProcessPendingPackets(); | ||
765 | } | ||
713 | SetDirectionVectors(); | 766 | SetDirectionVectors(); |
714 | } | 767 | } |
715 | 768 | ||
@@ -759,25 +812,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
759 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT | 812 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT |
760 | Dir_Vectors[4] = Vector3.UnitZ; //UP | 813 | Dir_Vectors[4] = Vector3.UnitZ; //UP |
761 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN | 814 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN |
762 | Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | 815 | Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE |
763 | Dir_Vectors[6] = Vector3.UnitX*2; //FORWARD | 816 | Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE |
764 | Dir_Vectors[7] = -Vector3.UnitX; //BACK | 817 | Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE |
818 | Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE | ||
819 | Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | ||
765 | } | 820 | } |
766 | 821 | ||
767 | private Vector3[] GetWalkDirectionVectors() | 822 | private Vector3[] GetWalkDirectionVectors() |
768 | { | 823 | { |
769 | Vector3[] vector = new Vector3[9]; | 824 | Vector3[] vector = new Vector3[11]; |
770 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD | 825 | 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 | 826 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK |
772 | vector[2] = Vector3.UnitY; //LEFT | 827 | vector[2] = Vector3.UnitY; //LEFT |
773 | vector[3] = -Vector3.UnitY; //RIGHT | 828 | vector[3] = -Vector3.UnitY; //RIGHT |
774 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP | 829 | 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 | 830 | 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 | 831 | 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 | 832 | 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 | 833 | vector[8] = Vector3.UnitY; //LEFT_NUDGE |
834 | vector[9] = -Vector3.UnitY; //RIGHT_NUDGE | ||
835 | vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE | ||
779 | return vector; | 836 | return vector; |
780 | } | 837 | } |
838 | |||
839 | private bool[] GetDirectionIsNudge() | ||
840 | { | ||
841 | bool[] isNudge = new bool[11]; | ||
842 | isNudge[0] = false; //FORWARD | ||
843 | isNudge[1] = false; //BACK | ||
844 | isNudge[2] = false; //LEFT | ||
845 | isNudge[3] = false; //RIGHT | ||
846 | isNudge[4] = false; //UP | ||
847 | isNudge[5] = false; //DOWN | ||
848 | isNudge[6] = true; //FORWARD_NUDGE | ||
849 | isNudge[7] = true; //BACK_NUDGE | ||
850 | isNudge[8] = true; //LEFT_NUDGE | ||
851 | isNudge[9] = true; //RIGHT_NUDGE | ||
852 | isNudge[10] = true; //DOWN_Nudge | ||
853 | return isNudge; | ||
854 | } | ||
855 | |||
781 | 856 | ||
782 | #endregion | 857 | #endregion |
783 | 858 | ||
@@ -820,7 +895,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
820 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 895 | m_grouptitle = gm.GetGroupTitle(m_uuid); |
821 | 896 | ||
822 | m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; | 897 | m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; |
823 | |||
824 | m_scene.SetRootAgentScene(m_uuid); | 898 | m_scene.SetRootAgentScene(m_uuid); |
825 | 899 | ||
826 | // Moved this from SendInitialData to ensure that m_appearance is initialized | 900 | // Moved this from SendInitialData to ensure that m_appearance is initialized |
@@ -839,6 +913,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
839 | pos.Y = crossedBorder.BorderLine.Z - 1; | 913 | pos.Y = crossedBorder.BorderLine.Z - 1; |
840 | } | 914 | } |
841 | 915 | ||
916 | //If they're TP'ing in or logging in, we haven't had time to add any known child regions yet. | ||
917 | //This has the unfortunate consequence that if somebody is TP'ing who is already a child agent, | ||
918 | //they'll bypass the landing point. But I can't think of any decent way of fixing this. | ||
919 | if (KnownChildRegionHandles.Count == 0) | ||
920 | { | ||
921 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
922 | if (land != null) | ||
923 | { | ||
924 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. | ||
925 | 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) | ||
926 | { | ||
927 | pos = land.LandData.UserLocation; | ||
928 | } | ||
929 | } | ||
930 | } | ||
931 | |||
932 | if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) | ||
933 | { | ||
934 | Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); | ||
935 | |||
936 | if (pos.X < 0) | ||
937 | { | ||
938 | emergencyPos.X = (int)Constants.RegionSize + pos.X; | ||
939 | if (!(pos.Y < 0)) | ||
940 | emergencyPos.Y = pos.Y; | ||
941 | if (!(pos.Z < 0)) | ||
942 | emergencyPos.Z = pos.Z; | ||
943 | } | ||
944 | if (pos.Y < 0) | ||
945 | { | ||
946 | emergencyPos.Y = (int)Constants.RegionSize + pos.Y; | ||
947 | if (!(pos.X < 0)) | ||
948 | emergencyPos.X = pos.X; | ||
949 | if (!(pos.Z < 0)) | ||
950 | emergencyPos.Z = pos.Z; | ||
951 | } | ||
952 | if (pos.Z < 0) | ||
953 | { | ||
954 | emergencyPos.Z = 128; | ||
955 | if (!(pos.Y < 0)) | ||
956 | emergencyPos.Y = pos.Y; | ||
957 | if (!(pos.X < 0)) | ||
958 | emergencyPos.X = pos.X; | ||
959 | } | ||
960 | } | ||
961 | |||
842 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 962 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
843 | { | 963 | { |
844 | m_log.WarnFormat( | 964 | m_log.WarnFormat( |
@@ -971,9 +1091,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
971 | public void Teleport(Vector3 pos) | 1091 | public void Teleport(Vector3 pos) |
972 | { | 1092 | { |
973 | bool isFlying = false; | 1093 | bool isFlying = false; |
1094 | |||
974 | if (m_physicsActor != null) | 1095 | if (m_physicsActor != null) |
975 | isFlying = m_physicsActor.Flying; | 1096 | isFlying = m_physicsActor.Flying; |
976 | 1097 | ||
977 | RemoveFromPhysicalScene(); | 1098 | RemoveFromPhysicalScene(); |
978 | Velocity = Vector3.Zero; | 1099 | Velocity = Vector3.Zero; |
979 | AbsolutePosition = pos; | 1100 | AbsolutePosition = pos; |
@@ -985,6 +1106,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
985 | } | 1106 | } |
986 | 1107 | ||
987 | SendTerseUpdateToAllClients(); | 1108 | SendTerseUpdateToAllClients(); |
1109 | |||
988 | } | 1110 | } |
989 | 1111 | ||
990 | public void TeleportWithMomentum(Vector3 pos) | 1112 | public void TeleportWithMomentum(Vector3 pos) |
@@ -1098,7 +1220,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1098 | pos.Z = ground + 1.5f; | 1220 | pos.Z = ground + 1.5f; |
1099 | AbsolutePosition = pos; | 1221 | AbsolutePosition = pos; |
1100 | } | 1222 | } |
1101 | |||
1102 | m_isChildAgent = false; | 1223 | m_isChildAgent = false; |
1103 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1224 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1104 | MakeRootAgent(AbsolutePosition, m_flying); | 1225 | MakeRootAgent(AbsolutePosition, m_flying); |
@@ -1197,6 +1318,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1197 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); | 1318 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); |
1198 | 1319 | ||
1199 | m_pos = m_LastFinitePos; | 1320 | m_pos = m_LastFinitePos; |
1321 | |||
1200 | if (!m_pos.IsFinite()) | 1322 | if (!m_pos.IsFinite()) |
1201 | { | 1323 | { |
1202 | m_pos.X = 127f; | 1324 | m_pos.X = 127f; |
@@ -1263,7 +1385,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1263 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); | 1385 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); |
1264 | } | 1386 | } |
1265 | } | 1387 | } |
1266 | |||
1267 | lock (scriptedcontrols) | 1388 | lock (scriptedcontrols) |
1268 | { | 1389 | { |
1269 | if (scriptedcontrols.Count > 0) | 1390 | if (scriptedcontrols.Count > 0) |
@@ -1278,6 +1399,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1278 | 1399 | ||
1279 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1400 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1280 | { | 1401 | { |
1402 | m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. | ||
1403 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | ||
1404 | |||
1281 | // TODO: This doesn't prevent the user from walking yet. | 1405 | // TODO: This doesn't prevent the user from walking yet. |
1282 | // Setting parent ID would fix this, if we knew what value | 1406 | // Setting parent ID would fix this, if we knew what value |
1283 | // to use. Or we could add a m_isSitting variable. | 1407 | // to use. Or we could add a m_isSitting variable. |
@@ -1332,6 +1456,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1332 | update_rotation = true; | 1456 | update_rotation = true; |
1333 | } | 1457 | } |
1334 | 1458 | ||
1459 | //guilty until proven innocent.. | ||
1460 | bool Nudging = true; | ||
1461 | //Basically, if there is at least one non-nudge control then we don't need | ||
1462 | //to worry about stopping the avatar | ||
1463 | |||
1335 | if (m_parentID == 0) | 1464 | if (m_parentID == 0) |
1336 | { | 1465 | { |
1337 | bool bAllowUpdateMoveToPosition = false; | 1466 | bool bAllowUpdateMoveToPosition = false; |
@@ -1346,9 +1475,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1346 | else | 1475 | else |
1347 | dirVectors = Dir_Vectors; | 1476 | dirVectors = Dir_Vectors; |
1348 | 1477 | ||
1349 | // The fact that m_movementflag is a byte needs to be fixed | 1478 | bool[] isNudge = GetDirectionIsNudge(); |
1350 | // it really should be a uint | 1479 | |
1351 | uint nudgehack = 250; | 1480 | |
1481 | |||
1482 | |||
1483 | |||
1352 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | 1484 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) |
1353 | { | 1485 | { |
1354 | if (((uint)flags & (uint)DCF) != 0) | 1486 | if (((uint)flags & (uint)DCF) != 0) |
@@ -1358,40 +1490,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1358 | try | 1490 | try |
1359 | { | 1491 | { |
1360 | agent_control_v3 += dirVectors[i]; | 1492 | agent_control_v3 += dirVectors[i]; |
1361 | //m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]); | 1493 | if (isNudge[i] == false) |
1494 | { | ||
1495 | Nudging = false; | ||
1496 | } | ||
1362 | } | 1497 | } |
1363 | catch (IndexOutOfRangeException) | 1498 | catch (IndexOutOfRangeException) |
1364 | { | 1499 | { |
1365 | // Why did I get this? | 1500 | // Why did I get this? |
1366 | } | 1501 | } |
1367 | 1502 | ||
1368 | if ((m_movementflag & (byte)(uint)DCF) == 0) | 1503 | if ((m_movementflag & (uint)DCF) == 0) |
1369 | { | 1504 | { |
1370 | if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1371 | { | ||
1372 | m_movementflag |= (byte)nudgehack; | ||
1373 | } | ||
1374 | m_movementflag += (byte)(uint)DCF; | 1505 | m_movementflag += (byte)(uint)DCF; |
1375 | update_movementflag = true; | 1506 | update_movementflag = true; |
1376 | } | 1507 | } |
1377 | } | 1508 | } |
1378 | else | 1509 | else |
1379 | { | 1510 | { |
1380 | if ((m_movementflag & (byte)(uint)DCF) != 0 || | 1511 | if ((m_movementflag & (uint)DCF) != 0) |
1381 | ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1382 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | ||
1383 | ) // This or is for Nudge forward | ||
1384 | { | 1512 | { |
1385 | m_movementflag -= ((byte)(uint)DCF); | 1513 | m_movementflag -= (byte)(uint)DCF; |
1386 | |||
1387 | update_movementflag = true; | 1514 | update_movementflag = true; |
1388 | /* | ||
1389 | if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE) | ||
1390 | && ((m_movementflag & (byte)nudgehack) == nudgehack)) | ||
1391 | { | ||
1392 | m_log.Debug("Removed Hack flag"); | ||
1393 | } | ||
1394 | */ | ||
1395 | } | 1515 | } |
1396 | else | 1516 | else |
1397 | { | 1517 | { |
@@ -1400,7 +1520,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1400 | } | 1520 | } |
1401 | i++; | 1521 | i++; |
1402 | } | 1522 | } |
1403 | |||
1404 | //Paupaw:Do Proper PID for Autopilot here | 1523 | //Paupaw:Do Proper PID for Autopilot here |
1405 | if (bResetMoveToPosition) | 1524 | if (bResetMoveToPosition) |
1406 | { | 1525 | { |
@@ -1435,6 +1554,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1435 | // Ignore z component of vector | 1554 | // Ignore z component of vector |
1436 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1555 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1437 | LocalVectorToTarget2D.Normalize(); | 1556 | LocalVectorToTarget2D.Normalize(); |
1557 | |||
1558 | //We're not nudging | ||
1559 | Nudging = false; | ||
1438 | agent_control_v3 += LocalVectorToTarget2D; | 1560 | agent_control_v3 += LocalVectorToTarget2D; |
1439 | 1561 | ||
1440 | // update avatar movement flags. the avatar coordinate system is as follows: | 1562 | // update avatar movement flags. the avatar coordinate system is as follows: |
@@ -1523,13 +1645,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1523 | // m_log.DebugFormat( | 1645 | // m_log.DebugFormat( |
1524 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); | 1646 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); |
1525 | 1647 | ||
1526 | AddNewMovement(agent_control_v3, q); | 1648 | AddNewMovement(agent_control_v3, q, Nudging); |
1527 | 1649 | ||
1528 | 1650 | ||
1529 | } | 1651 | } |
1530 | } | 1652 | } |
1531 | 1653 | ||
1532 | if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0) && !SitGround) | 1654 | if (update_movementflag && !SitGround) |
1533 | Animator.UpdateMovementAnimations(); | 1655 | Animator.UpdateMovementAnimations(); |
1534 | 1656 | ||
1535 | m_scene.EventManager.TriggerOnClientMovement(this); | 1657 | m_scene.EventManager.TriggerOnClientMovement(this); |
@@ -1544,7 +1666,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1544 | m_sitAtAutoTarget = false; | 1666 | m_sitAtAutoTarget = false; |
1545 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; | 1667 | PrimitiveBaseShape proxy = PrimitiveBaseShape.Default; |
1546 | //proxy.PCode = (byte)PCode.ParticleSystem; | 1668 | //proxy.PCode = (byte)PCode.ParticleSystem; |
1547 | |||
1548 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); | 1669 | proxyObjectGroup = new SceneObjectGroup(UUID, Pos, Rotation, proxy); |
1549 | proxyObjectGroup.AttachToScene(m_scene); | 1670 | proxyObjectGroup.AttachToScene(m_scene); |
1550 | 1671 | ||
@@ -1586,7 +1707,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1586 | } | 1707 | } |
1587 | m_moveToPositionInProgress = true; | 1708 | m_moveToPositionInProgress = true; |
1588 | m_moveToPositionTarget = new Vector3(locx, locy, locz); | 1709 | m_moveToPositionTarget = new Vector3(locx, locy, locz); |
1589 | } | 1710 | } |
1590 | catch (Exception ex) | 1711 | catch (Exception ex) |
1591 | { | 1712 | { |
1592 | //Why did I get this error? | 1713 | //Why did I get this error? |
@@ -1608,7 +1729,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1608 | Velocity = Vector3.Zero; | 1729 | Velocity = Vector3.Zero; |
1609 | SendFullUpdateToAllClients(); | 1730 | SendFullUpdateToAllClients(); |
1610 | 1731 | ||
1611 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1732 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? |
1612 | } | 1733 | } |
1613 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | 1734 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); |
1614 | m_requestedSitTargetUUID = UUID.Zero; | 1735 | m_requestedSitTargetUUID = UUID.Zero; |
@@ -1645,50 +1766,84 @@ namespace OpenSim.Region.Framework.Scenes | |||
1645 | 1766 | ||
1646 | if (m_parentID != 0) | 1767 | if (m_parentID != 0) |
1647 | { | 1768 | { |
1648 | m_log.Debug("StandupCode Executed"); | 1769 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_requestedSitTargetID); |
1649 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | ||
1650 | if (part != null) | 1770 | if (part != null) |
1651 | { | 1771 | { |
1772 | part.TaskInventory.LockItemsForRead(true); | ||
1652 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1773 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1653 | if (taskIDict != null) | 1774 | if (taskIDict != null) |
1654 | { | 1775 | { |
1655 | lock (taskIDict) | 1776 | foreach (UUID taskID in taskIDict.Keys) |
1656 | { | 1777 | { |
1657 | foreach (UUID taskID in taskIDict.Keys) | 1778 | UnRegisterControlEventsToScript(LocalId, taskID); |
1658 | { | 1779 | taskIDict[taskID].PermsMask &= ~( |
1659 | UnRegisterControlEventsToScript(LocalId, taskID); | 1780 | 2048 | //PERMISSION_CONTROL_CAMERA |
1660 | taskIDict[taskID].PermsMask &= ~( | 1781 | 4); // PERMISSION_TAKE_CONTROLS |
1661 | 2048 | //PERMISSION_CONTROL_CAMERA | ||
1662 | 4); // PERMISSION_TAKE_CONTROLS | ||
1663 | } | ||
1664 | } | 1782 | } |
1665 | |||
1666 | } | 1783 | } |
1784 | part.TaskInventory.LockItemsForRead(false); | ||
1667 | // Reset sit target. | 1785 | // Reset sit target. |
1668 | if (part.GetAvatarOnSitTarget() == UUID) | 1786 | if (part.GetAvatarOnSitTarget() == UUID) |
1669 | part.SetAvatarOnSitTarget(UUID.Zero); | 1787 | part.SetAvatarOnSitTarget(UUID.Zero); |
1670 | |||
1671 | m_parentPosition = part.GetWorldPosition(); | 1788 | m_parentPosition = part.GetWorldPosition(); |
1672 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 1789 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1673 | } | 1790 | } |
1791 | // part.GetWorldRotation() is the rotation of the object being sat on | ||
1792 | // Rotation is the sittiing Av's rotation | ||
1793 | |||
1794 | Quaternion partRot; | ||
1795 | // if (part.LinkNum == 1) | ||
1796 | // { // Root prim of linkset | ||
1797 | // partRot = part.ParentGroup.RootPart.RotationOffset; | ||
1798 | // } | ||
1799 | // else | ||
1800 | // { // single or child prim | ||
1801 | |||
1802 | // } | ||
1803 | if (part == null) //CW: Part may be gone. llDie() for example. | ||
1804 | { | ||
1805 | partRot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1806 | } | ||
1807 | else | ||
1808 | { | ||
1809 | partRot = part.GetWorldRotation(); | ||
1810 | } | ||
1811 | |||
1812 | Quaternion partIRot = Quaternion.Inverse(partRot); | ||
1813 | |||
1814 | Quaternion avatarRot = Quaternion.Inverse(Quaternion.Inverse(Rotation) * partIRot); // world or. of the av | ||
1815 | Vector3 avStandUp = new Vector3(1.0f, 0f, 0f) * avatarRot; // 1M infront of av | ||
1674 | 1816 | ||
1817 | |||
1675 | if (m_physicsActor == null) | 1818 | if (m_physicsActor == null) |
1676 | { | 1819 | { |
1677 | AddToPhysicalScene(false); | 1820 | AddToPhysicalScene(false); |
1678 | } | 1821 | } |
1679 | 1822 | //CW: If the part isn't null then we can set the current position | |
1680 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); | 1823 | if (part != null) |
1681 | m_parentPosition = Vector3.Zero; | 1824 | { |
1682 | 1825 | Vector3 avWorldStandUp = avStandUp + part.GetWorldPosition() + ((m_pos - part.OffsetPosition) * partRot); // + av sit offset! | |
1683 | m_parentID = 0; | 1826 | AbsolutePosition = avWorldStandUp; //KF: Fix stand up. |
1827 | part.IsOccupied = false; | ||
1828 | part.ParentGroup.DeleteAvatar(ControllingClient.AgentId); | ||
1829 | } | ||
1830 | else | ||
1831 | { | ||
1832 | //CW: Since the part doesn't exist, a coarse standup position isn't an issue | ||
1833 | AbsolutePosition = m_lastWorldPosition; | ||
1834 | } | ||
1835 | |||
1836 | m_parentPosition = Vector3.Zero; | ||
1837 | m_parentID = 0; | ||
1838 | m_offsetRotation = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
1684 | SendFullUpdateToAllClients(); | 1839 | SendFullUpdateToAllClients(); |
1685 | m_requestedSitTargetID = 0; | 1840 | m_requestedSitTargetID = 0; |
1841 | |||
1686 | if ((m_physicsActor != null) && (m_avHeight > 0)) | 1842 | if ((m_physicsActor != null) && (m_avHeight > 0)) |
1687 | { | 1843 | { |
1688 | SetHeight(m_avHeight); | 1844 | SetHeight(m_avHeight); |
1689 | } | 1845 | } |
1690 | } | 1846 | } |
1691 | |||
1692 | Animator.TrySetMovementAnimation("STAND"); | 1847 | Animator.TrySetMovementAnimation("STAND"); |
1693 | } | 1848 | } |
1694 | 1849 | ||
@@ -1719,13 +1874,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1719 | Vector3 avSitOffSet = part.SitTargetPosition; | 1874 | Vector3 avSitOffSet = part.SitTargetPosition; |
1720 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1875 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1721 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1876 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1722 | 1877 | bool SitTargetOccupied = (avOnTargetAlready != UUID.Zero); | |
1723 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1878 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1724 | bool SitTargetisSet = | 1879 | if (SitTargetisSet && !SitTargetOccupied) |
1725 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && | ||
1726 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); | ||
1727 | |||
1728 | if (SitTargetisSet && SitTargetUnOccupied) | ||
1729 | { | 1880 | { |
1730 | //switch the target to this prim | 1881 | //switch the target to this prim |
1731 | return part; | 1882 | return part; |
@@ -1739,84 +1890,162 @@ namespace OpenSim.Region.Framework.Scenes | |||
1739 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) | 1890 | private void SendSitResponse(IClientAPI remoteClient, UUID targetID, Vector3 offset, Quaternion pSitOrientation) |
1740 | { | 1891 | { |
1741 | bool autopilot = true; | 1892 | bool autopilot = true; |
1893 | Vector3 autopilotTarget = new Vector3(); | ||
1894 | Quaternion sitOrientation = Quaternion.Identity; | ||
1742 | Vector3 pos = new Vector3(); | 1895 | Vector3 pos = new Vector3(); |
1743 | Quaternion sitOrientation = pSitOrientation; | ||
1744 | Vector3 cameraEyeOffset = Vector3.Zero; | 1896 | Vector3 cameraEyeOffset = Vector3.Zero; |
1745 | Vector3 cameraAtOffset = Vector3.Zero; | 1897 | Vector3 cameraAtOffset = Vector3.Zero; |
1746 | bool forceMouselook = false; | 1898 | bool forceMouselook = false; |
1747 | 1899 | ||
1748 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); | 1900 | //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); |
1749 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); | 1901 | SceneObjectPart part = FindNextAvailableSitTarget(targetID); |
1750 | if (part != null) | 1902 | if (part == null) return; |
1751 | { | 1903 | |
1752 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1904 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
1753 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 1905 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1754 | 1906 | ||
1755 | // Is a sit target available? | 1907 | // part is the prim to sit on |
1756 | Vector3 avSitOffSet = part.SitTargetPosition; | 1908 | // offset is the world-ref vector distance from that prim center to the click-spot |
1757 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1909 | // UUID is the UUID of the Avatar doing the clicking |
1758 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1910 | |
1759 | 1911 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | |
1760 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1912 | |
1761 | bool SitTargetisSet = | 1913 | // Is a sit target available? |
1762 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && | 1914 | Vector3 avSitOffSet = part.SitTargetPosition; |
1763 | ( | 1915 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1764 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 1f // Valid Zero Rotation quaternion | 1916 | |
1765 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point | 1917 | bool SitTargetisSet = (Vector3.Zero != avSitOffSet); //NB Latest SL Spec shows Sit Rotation setting is ignored. |
1766 | || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion | 1918 | // Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); |
1767 | ) | 1919 | Quaternion partRot; |
1768 | )); | 1920 | // if (part.LinkNum == 1) |
1769 | 1921 | // { // Root prim of linkset | |
1770 | if (SitTargetisSet && SitTargetUnOccupied) | 1922 | // partRot = part.ParentGroup.RootPart.RotationOffset; |
1771 | { | 1923 | // } |
1772 | part.SetAvatarOnSitTarget(UUID); | 1924 | // else |
1773 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 1925 | // { // single or child prim |
1774 | sitOrientation = avSitOrientation; | 1926 | partRot = part.GetWorldRotation(); |
1775 | autopilot = false; | 1927 | // } |
1776 | } | 1928 | Quaternion partIRot = Quaternion.Inverse(partRot); |
1777 | 1929 | //Console.WriteLine("SendSitResponse offset=" + offset + " Occup=" + part.IsOccupied + " TargSet=" + SitTargetisSet); | |
1778 | pos = part.AbsolutePosition + offset; | 1930 | // Sit analysis rewritten by KF 091125 |
1779 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | 1931 | if (SitTargetisSet) // scipted sit |
1780 | //{ | 1932 | { |
1781 | // offset = pos; | 1933 | if (!part.IsOccupied) |
1782 | //autopilot = false; | 1934 | { |
1783 | //} | 1935 | //Console.WriteLine("Scripted, unoccupied"); |
1784 | if (m_physicsActor != null) | 1936 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it |
1785 | { | 1937 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one |
1786 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | 1938 | |
1787 | // We can remove the physicsActor until they stand up. | 1939 | Quaternion nrot = avSitOrientation; |
1788 | m_sitAvatarHeight = m_physicsActor.Size.Z; | 1940 | if (!part.IsRoot) |
1789 | |||
1790 | if (autopilot) | ||
1791 | { | 1941 | { |
1792 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) | 1942 | nrot = nrot * part.RotationOffset; |
1793 | { | ||
1794 | autopilot = false; | ||
1795 | |||
1796 | RemoveFromPhysicalScene(); | ||
1797 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | ||
1798 | } | ||
1799 | } | 1943 | } |
1800 | else | 1944 | sitOrientation = nrot; // Change rotatione to the scripted one |
1945 | OffsetRotation = nrot; | ||
1946 | autopilot = false; // Jump direct to scripted llSitPos() | ||
1947 | } | ||
1948 | else | ||
1949 | { | ||
1950 | //Console.WriteLine("Scripted, occupied"); | ||
1951 | return; | ||
1952 | } | ||
1953 | } | ||
1954 | else // Not Scripted | ||
1955 | { | ||
1956 | if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) | ||
1957 | { | ||
1958 | // large prim & offset, ignore if other Avs sitting | ||
1959 | // offset.Z -= 0.05f; | ||
1960 | m_avUnscriptedSitPos = offset * partIRot; // (non-zero) sit where clicked | ||
1961 | autopilotTarget = part.AbsolutePosition + offset; // World location of clicked point | ||
1962 | |||
1963 | //Console.WriteLine(" offset ={0}", offset); | ||
1964 | //Console.WriteLine(" UnscriptedSitPos={0}", m_avUnscriptedSitPos); | ||
1965 | //Console.WriteLine(" autopilotTarget={0}", autopilotTarget); | ||
1966 | |||
1967 | } | ||
1968 | else // small offset | ||
1969 | { | ||
1970 | //Console.WriteLine("Small offset"); | ||
1971 | if (!part.IsOccupied) | ||
1972 | { | ||
1973 | m_avUnscriptedSitPos = Vector3.Zero; // Zero = Sit on prim center | ||
1974 | autopilotTarget = part.AbsolutePosition; | ||
1975 | //Console.WriteLine("UsSmall autopilotTarget={0}", autopilotTarget); | ||
1976 | } | ||
1977 | else return; // occupied small | ||
1978 | } // end large/small | ||
1979 | } // end Scripted/not | ||
1980 | cameraAtOffset = part.GetCameraAtOffset(); | ||
1981 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
1982 | forceMouselook = part.GetForceMouselook(); | ||
1983 | if(cameraAtOffset == Vector3.Zero) cameraAtOffset = new Vector3(0f, 0f, 0.1f); // | ||
1984 | if(cameraEyeOffset == Vector3.Zero) cameraEyeOffset = new Vector3(0f, 0f, 0.1f); // | ||
1985 | |||
1986 | if (m_physicsActor != null) | ||
1987 | { | ||
1988 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | ||
1989 | // We can remove the physicsActor until they stand up. | ||
1990 | m_sitAvatarHeight = m_physicsActor.Size.Z; | ||
1991 | if (autopilot) | ||
1992 | { // its not a scripted sit | ||
1993 | // if (Util.GetDistanceTo(AbsolutePosition, autopilotTarget) < 4.5) | ||
1994 | if( (Math.Abs(AbsolutePosition.X - autopilotTarget.X) < 2.0f) && (Math.Abs(AbsolutePosition.Y - autopilotTarget.Y) < 2.0f) ) | ||
1801 | { | 1995 | { |
1996 | autopilot = false; // close enough | ||
1997 | m_lastWorldPosition = m_pos; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
1998 | Not using the part's position because returning the AV to the last known standing | ||
1999 | position is likely to be more friendly, isn't it? */ | ||
1802 | RemoveFromPhysicalScene(); | 2000 | RemoveFromPhysicalScene(); |
1803 | } | 2001 | AbsolutePosition = autopilotTarget + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to over sit target |
2002 | } // else the autopilot will get us close | ||
2003 | } | ||
2004 | else | ||
2005 | { // its a scripted sit | ||
2006 | m_lastWorldPosition = part.AbsolutePosition; /* CW - This give us a position to return the avatar to if the part is killed before standup. | ||
2007 | I *am* using the part's position this time because we have no real idea how far away | ||
2008 | the avatar is from the sit target. */ | ||
2009 | RemoveFromPhysicalScene(); | ||
1804 | } | 2010 | } |
1805 | |||
1806 | cameraAtOffset = part.GetCameraAtOffset(); | ||
1807 | cameraEyeOffset = part.GetCameraEyeOffset(); | ||
1808 | forceMouselook = part.GetForceMouselook(); | ||
1809 | } | 2011 | } |
1810 | 2012 | else return; // physactor is null! | |
1811 | ControllingClient.SendSitResponse(targetID, offset, sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2013 | |
1812 | m_requestedSitTargetUUID = targetID; | 2014 | Vector3 offsetr; // = offset * partIRot; |
2015 | // KF: In a linkset, offsetr needs to be relative to the group root! 091208 | ||
2016 | // offsetr = (part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + (offset * partIRot); | ||
2017 | // if (part.LinkNum < 2) 091216 All this was necessary because of the GetWorldRotation error. | ||
2018 | // { // Single, or Root prim of linkset, target is ClickOffset * RootRot | ||
2019 | //offsetr = offset * partIRot; | ||
2020 | // | ||
2021 | // else | ||
2022 | // { // Child prim, offset is (ChildOffset * RootRot) + (ClickOffset * ChildRot) | ||
2023 | // offsetr = //(part.OffsetPosition * Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset)) + | ||
2024 | // (offset * partRot); | ||
2025 | // } | ||
2026 | |||
2027 | //Console.WriteLine(" "); | ||
2028 | //Console.WriteLine("link number ={0}", part.LinkNum); | ||
2029 | //Console.WriteLine("Prim offset ={0}", part.OffsetPosition ); | ||
2030 | //Console.WriteLine("Root Rotate ={0}", part.ParentGroup.RootPart.RotationOffset); | ||
2031 | //Console.WriteLine("Click offst ={0}", offset); | ||
2032 | //Console.WriteLine("Prim Rotate ={0}", part.GetWorldRotation()); | ||
2033 | //Console.WriteLine("offsetr ={0}", offsetr); | ||
2034 | //Console.WriteLine("Camera At ={0}", cameraAtOffset); | ||
2035 | //Console.WriteLine("Camera Eye ={0}", cameraEyeOffset); | ||
2036 | |||
2037 | //NOTE: SendSitResponse should be relative to the GROUP *NOT* THE PRIM if we're sitting on a child | ||
2038 | ControllingClient.SendSitResponse(part.ParentGroup.UUID, ((offset * part.RotationOffset) + part.OffsetPosition), sitOrientation, autopilot, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2039 | |||
2040 | m_requestedSitTargetUUID = part.UUID; //KF: Correct autopilot target | ||
1813 | // This calls HandleAgentSit twice, once from here, and the client calls | 2041 | // This calls HandleAgentSit twice, once from here, and the client calls |
1814 | // HandleAgentSit itself after it gets to the location | 2042 | // HandleAgentSit itself after it gets to the location |
1815 | // It doesn't get to the location until we've moved them there though | 2043 | // It doesn't get to the location until we've moved them there though |
1816 | // which happens in HandleAgentSit :P | 2044 | // which happens in HandleAgentSit :P |
1817 | m_autopilotMoving = autopilot; | 2045 | m_autopilotMoving = autopilot; |
1818 | m_autoPilotTarget = pos; | 2046 | m_autoPilotTarget = autopilotTarget; |
1819 | m_sitAtAutoTarget = autopilot; | 2047 | m_sitAtAutoTarget = autopilot; |
2048 | m_initialSitTarget = autopilotTarget; | ||
1820 | if (!autopilot) | 2049 | if (!autopilot) |
1821 | HandleAgentSit(remoteClient, UUID); | 2050 | HandleAgentSit(remoteClient, UUID); |
1822 | } | 2051 | } |
@@ -2111,47 +2340,126 @@ namespace OpenSim.Region.Framework.Scenes | |||
2111 | { | 2340 | { |
2112 | if (part != null) | 2341 | if (part != null) |
2113 | { | 2342 | { |
2343 | //Console.WriteLine("Link #{0}, Rot {1}", part.LinkNum, part.GetWorldRotation()); | ||
2114 | if (part.GetAvatarOnSitTarget() == UUID) | 2344 | if (part.GetAvatarOnSitTarget() == UUID) |
2115 | { | 2345 | { |
2346 | //Console.WriteLine("Scripted Sit"); | ||
2347 | // Scripted sit | ||
2116 | Vector3 sitTargetPos = part.SitTargetPosition; | 2348 | Vector3 sitTargetPos = part.SitTargetPosition; |
2117 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 2349 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
2118 | |||
2119 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | ||
2120 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | ||
2121 | |||
2122 | //Quaternion result = (sitTargetOrient * vq) * nq; | ||
2123 | |||
2124 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 2350 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
2125 | m_pos += SIT_TARGET_ADJUSTMENT; | 2351 | m_pos += SIT_TARGET_ADJUSTMENT; |
2352 | if (!part.IsRoot) | ||
2353 | { | ||
2354 | m_pos *= part.RotationOffset; | ||
2355 | } | ||
2126 | m_bodyRot = sitTargetOrient; | 2356 | m_bodyRot = sitTargetOrient; |
2127 | //Rotation = sitTargetOrient; | ||
2128 | m_parentPosition = part.AbsolutePosition; | 2357 | m_parentPosition = part.AbsolutePosition; |
2129 | 2358 | part.IsOccupied = true; | |
2130 | //SendTerseUpdateToAllClients(); | 2359 | part.ParentGroup.AddAvatar(agentID); |
2360 | Console.WriteLine("Scripted Sit ofset {0}", m_pos); | ||
2131 | } | 2361 | } |
2132 | else | 2362 | else |
2133 | { | 2363 | { |
2134 | m_pos -= part.AbsolutePosition; | 2364 | // if m_avUnscriptedSitPos is zero then Av sits above center |
2365 | // Else Av sits at m_avUnscriptedSitPos | ||
2366 | |||
2367 | // Non-scripted sit by Kitto Flora 21Nov09 | ||
2368 | // Calculate angle of line from prim to Av | ||
2369 | Quaternion partIRot; | ||
2370 | // if (part.LinkNum == 1) | ||
2371 | // { // Root prim of linkset | ||
2372 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2373 | // } | ||
2374 | // else | ||
2375 | // { // single or child prim | ||
2376 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2377 | // } | ||
2378 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; | ||
2379 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); | ||
2380 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); | ||
2381 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | ||
2382 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | ||
2383 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | ||
2384 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | ||
2385 | // Av sits at world euler <0,0, z>, translated by part rotation | ||
2386 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | ||
2387 | |||
2135 | m_parentPosition = part.AbsolutePosition; | 2388 | m_parentPosition = part.AbsolutePosition; |
2136 | } | 2389 | part.IsOccupied = true; |
2390 | part.ParentGroup.AddAvatar(agentID); | ||
2391 | m_pos = new Vector3(0f, 0f, 0.05f) + // corrections to get Sit Animation | ||
2392 | (new Vector3(0.0f, 0f, 0.61f) * partIRot) + // located on center | ||
2393 | (new Vector3(0.34f, 0f, 0.0f) * m_bodyRot) + | ||
2394 | m_avUnscriptedSitPos; // adds click offset, if any | ||
2395 | //Set up raytrace to find top surface of prim | ||
2396 | Vector3 size = part.Scale; | ||
2397 | float mag = 2.0f; // 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | ||
2398 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | ||
2399 | Vector3 down = new Vector3(0f, 0f, -1f); | ||
2400 | //Console.WriteLine("st={0} do={1} ma={2}", start, down, mag); | ||
2401 | m_scene.PhysicsScene.RaycastWorld( | ||
2402 | start, // Vector3 position, | ||
2403 | down, // Vector3 direction, | ||
2404 | mag, // float length, | ||
2405 | SitAltitudeCallback); // retMethod | ||
2406 | } // end scripted/not | ||
2137 | } | 2407 | } |
2138 | else | 2408 | else // no Av |
2139 | { | 2409 | { |
2140 | return; | 2410 | return; |
2141 | } | 2411 | } |
2142 | } | 2412 | } |
2143 | m_parentID = m_requestedSitTargetID; | 2413 | |
2414 | //We want our offsets to reference the root prim, not the child we may have sat on | ||
2415 | if (!part.IsRoot) | ||
2416 | { | ||
2417 | m_parentID = part.ParentGroup.RootPart.LocalId; | ||
2418 | m_pos += part.OffsetPosition; | ||
2419 | } | ||
2420 | else | ||
2421 | { | ||
2422 | m_parentID = m_requestedSitTargetID; | ||
2423 | } | ||
2144 | 2424 | ||
2145 | Velocity = Vector3.Zero; | 2425 | Velocity = Vector3.Zero; |
2146 | RemoveFromPhysicalScene(); | 2426 | RemoveFromPhysicalScene(); |
2147 | 2427 | ||
2148 | Animator.TrySetMovementAnimation(sitAnimation); | 2428 | Animator.TrySetMovementAnimation(sitAnimation); |
2149 | SendFullUpdateToAllClients(); | 2429 | SendFullUpdateToAllClients(); |
2150 | // This may seem stupid, but Our Full updates don't send avatar rotation :P | ||
2151 | // So we're also sending a terse update (which has avatar rotation) | ||
2152 | // [Update] We do now. | ||
2153 | //SendTerseUpdateToAllClients(); | ||
2154 | } | 2430 | } |
2431 | |||
2432 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal) | ||
2433 | { | ||
2434 | // KF: 091202 There appears to be a bug in Prim Edit Size - the process sometimes make a prim that RayTrace no longer | ||
2435 | // sees. Take/re-rez, or sim restart corrects the condition. Result of bug is incorrect sit height. | ||
2436 | if(hitYN) | ||
2437 | { | ||
2438 | // m_pos = Av offset from prim center to make look like on center | ||
2439 | // m_parentPosition = Actual center pos of prim | ||
2440 | // collisionPoint = spot on prim where we want to sit | ||
2441 | // collisionPoint.Z = global sit surface height | ||
2442 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | ||
2443 | Quaternion partIRot; | ||
2444 | // if (part.LinkNum == 1) | ||
2445 | /// { // Root prim of linkset | ||
2446 | // partIRot = Quaternion.Inverse(part.ParentGroup.RootPart.RotationOffset); | ||
2447 | // } | ||
2448 | // else | ||
2449 | // { // single or child prim | ||
2450 | partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
2451 | // } | ||
2452 | if (m_initialSitTarget != null) | ||
2453 | { | ||
2454 | float offZ = collisionPoint.Z - m_initialSitTarget.Z; | ||
2455 | Vector3 offset = new Vector3(0.0f, 0.0f, offZ) * partIRot; // Altitude correction | ||
2456 | //Console.WriteLine("sitPoint={0}, offset={1}", sitPoint, offset); | ||
2457 | m_pos += offset; | ||
2458 | // ControllingClient.SendClearFollowCamProperties(part.UUID); | ||
2459 | } | ||
2460 | |||
2461 | } | ||
2462 | } // End SitAltitudeCallback KF. | ||
2155 | 2463 | ||
2156 | /// <summary> | 2464 | /// <summary> |
2157 | /// Event handler for the 'Always run' setting on the client | 2465 | /// Event handler for the 'Always run' setting on the client |
@@ -2181,7 +2489,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2181 | /// </summary> | 2489 | /// </summary> |
2182 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 2490 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
2183 | /// <param name="rotation">The direction in which this avatar should now face. | 2491 | /// <param name="rotation">The direction in which this avatar should now face. |
2184 | public void AddNewMovement(Vector3 vec, Quaternion rotation) | 2492 | public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) |
2185 | { | 2493 | { |
2186 | if (m_isChildAgent) | 2494 | if (m_isChildAgent) |
2187 | { | 2495 | { |
@@ -2222,10 +2530,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2222 | Rotation = rotation; | 2530 | Rotation = rotation; |
2223 | Vector3 direc = vec * rotation; | 2531 | Vector3 direc = vec * rotation; |
2224 | direc.Normalize(); | 2532 | direc.Normalize(); |
2533 | PhysicsActor actor = m_physicsActor; | ||
2534 | if ((vec.Z == 0f) && !actor.Flying) direc.Z = 0f; // Prevent camera WASD up. | ||
2225 | 2535 | ||
2226 | direc *= 0.03f * 128f * m_speedModifier; | 2536 | direc *= 0.03f * 128f * m_speedModifier; |
2227 | 2537 | ||
2228 | PhysicsActor actor = m_physicsActor; | ||
2229 | if (actor != null) | 2538 | if (actor != null) |
2230 | { | 2539 | { |
2231 | if (actor.Flying) | 2540 | if (actor.Flying) |
@@ -2247,18 +2556,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2247 | { | 2556 | { |
2248 | if (direc.Z > 2.0f) | 2557 | if (direc.Z > 2.0f) |
2249 | { | 2558 | { |
2250 | direc.Z *= 3.0f; | 2559 | if(m_animator.m_animTickJump == -1) |
2251 | 2560 | { | |
2252 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2561 | direc.Z *= 3.0f; // jump |
2253 | Animator.TrySetMovementAnimation("PREJUMP"); | 2562 | } |
2254 | Animator.TrySetMovementAnimation("JUMP"); | 2563 | else |
2564 | { | ||
2565 | direc.Z *= 0.1f; // prejump | ||
2566 | } | ||
2567 | /* Animations are controlled via GetMovementAnimation() in ScenePresenceAnimator.cs | ||
2568 | Animator.TrySetMovementAnimation("PREJUMP"); | ||
2569 | Animator.TrySetMovementAnimation("JUMP"); | ||
2570 | */ | ||
2255 | } | 2571 | } |
2256 | } | 2572 | } |
2257 | } | 2573 | } |
2258 | 2574 | ||
2259 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2575 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2260 | m_forceToApply = direc; | 2576 | m_forceToApply = direc; |
2261 | 2577 | m_isNudging = Nudging; | |
2262 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); | 2578 | m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS)); |
2263 | } | 2579 | } |
2264 | 2580 | ||
@@ -2273,7 +2589,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2273 | const float POSITION_TOLERANCE = 0.05f; | 2589 | const float POSITION_TOLERANCE = 0.05f; |
2274 | //const int TIME_MS_TOLERANCE = 3000; | 2590 | //const int TIME_MS_TOLERANCE = 3000; |
2275 | 2591 | ||
2276 | SendPrimUpdates(); | 2592 | |
2277 | 2593 | ||
2278 | if (m_isChildAgent == false) | 2594 | if (m_isChildAgent == false) |
2279 | { | 2595 | { |
@@ -2303,6 +2619,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2303 | CheckForBorderCrossing(); | 2619 | CheckForBorderCrossing(); |
2304 | CheckForSignificantMovement(); // sends update to the modules. | 2620 | CheckForSignificantMovement(); // sends update to the modules. |
2305 | } | 2621 | } |
2622 | |||
2623 | //Sending prim updates AFTER the avatar terse updates are sent | ||
2624 | SendPrimUpdates(); | ||
2306 | } | 2625 | } |
2307 | 2626 | ||
2308 | #endregion | 2627 | #endregion |
@@ -3087,6 +3406,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3087 | m_callbackURI = cAgent.CallbackURI; | 3406 | m_callbackURI = cAgent.CallbackURI; |
3088 | 3407 | ||
3089 | m_pos = cAgent.Position; | 3408 | m_pos = cAgent.Position; |
3409 | |||
3090 | m_velocity = cAgent.Velocity; | 3410 | m_velocity = cAgent.Velocity; |
3091 | m_CameraCenter = cAgent.Center; | 3411 | m_CameraCenter = cAgent.Center; |
3092 | //m_avHeight = cAgent.Size.Z; | 3412 | //m_avHeight = cAgent.Size.Z; |
@@ -3197,14 +3517,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
3197 | { | 3517 | { |
3198 | if (m_forceToApply.HasValue) | 3518 | if (m_forceToApply.HasValue) |
3199 | { | 3519 | { |
3200 | Vector3 force = m_forceToApply.Value; | ||
3201 | 3520 | ||
3521 | Vector3 force = m_forceToApply.Value; | ||
3202 | m_updateflag = true; | 3522 | m_updateflag = true; |
3203 | // movementvector = force; | ||
3204 | Velocity = force; | 3523 | Velocity = force; |
3205 | 3524 | ||
3206 | m_forceToApply = null; | 3525 | m_forceToApply = null; |
3207 | } | 3526 | } |
3527 | else | ||
3528 | { | ||
3529 | if (m_isNudging) | ||
3530 | { | ||
3531 | Vector3 force = Vector3.Zero; | ||
3532 | |||
3533 | m_updateflag = true; | ||
3534 | Velocity = force; | ||
3535 | m_isNudging = false; | ||
3536 | m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" | ||
3537 | } | ||
3538 | } | ||
3208 | } | 3539 | } |
3209 | 3540 | ||
3210 | public override void SetText(string text, Vector3 color, double alpha) | 3541 | public override void SetText(string text, Vector3 color, double alpha) |
@@ -3255,18 +3586,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
3255 | { | 3586 | { |
3256 | if (e == null) | 3587 | if (e == null) |
3257 | return; | 3588 | return; |
3258 | 3589 | ||
3259 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3590 | // 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 | 3591 | // as of this comment the interval is set in AddToPhysicalScene |
3262 | if (Animator!=null) | 3592 | if (Animator!=null) |
3263 | Animator.UpdateMovementAnimations(); | 3593 | { |
3594 | if (m_updateCount > 0) //KF: DO NOT call UpdateMovementAnimations outside of the m_updateCount wrapper, | ||
3595 | { // else its will lock out other animation changes, like ground sit. | ||
3596 | Animator.UpdateMovementAnimations(); | ||
3597 | m_updateCount--; | ||
3598 | } | ||
3599 | } | ||
3264 | 3600 | ||
3265 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3601 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3266 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3602 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3267 | 3603 | ||
3268 | CollisionPlane = Vector4.UnitW; | 3604 | CollisionPlane = Vector4.UnitW; |
3269 | 3605 | ||
3606 | if (m_lastColCount != coldata.Count) | ||
3607 | { | ||
3608 | m_updateCount = UPDATE_COUNT; | ||
3609 | m_lastColCount = coldata.Count; | ||
3610 | } | ||
3611 | |||
3270 | if (coldata.Count != 0 && Animator != null) | 3612 | if (coldata.Count != 0 && Animator != null) |
3271 | { | 3613 | { |
3272 | switch (Animator.CurrentMovementAnimation) | 3614 | switch (Animator.CurrentMovementAnimation) |
@@ -3296,6 +3638,148 @@ namespace OpenSim.Region.Framework.Scenes | |||
3296 | } | 3638 | } |
3297 | } | 3639 | } |
3298 | 3640 | ||
3641 | List<uint> thisHitColliders = new List<uint>(); | ||
3642 | List<uint> endedColliders = new List<uint>(); | ||
3643 | List<uint> startedColliders = new List<uint>(); | ||
3644 | |||
3645 | foreach (uint localid in coldata.Keys) | ||
3646 | { | ||
3647 | thisHitColliders.Add(localid); | ||
3648 | if (!m_lastColliders.Contains(localid)) | ||
3649 | { | ||
3650 | startedColliders.Add(localid); | ||
3651 | } | ||
3652 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3653 | } | ||
3654 | |||
3655 | // calculate things that ended colliding | ||
3656 | foreach (uint localID in m_lastColliders) | ||
3657 | { | ||
3658 | if (!thisHitColliders.Contains(localID)) | ||
3659 | { | ||
3660 | endedColliders.Add(localID); | ||
3661 | } | ||
3662 | } | ||
3663 | //add the items that started colliding this time to the last colliders list. | ||
3664 | foreach (uint localID in startedColliders) | ||
3665 | { | ||
3666 | m_lastColliders.Add(localID); | ||
3667 | } | ||
3668 | // remove things that ended colliding from the last colliders list | ||
3669 | foreach (uint localID in endedColliders) | ||
3670 | { | ||
3671 | m_lastColliders.Remove(localID); | ||
3672 | } | ||
3673 | |||
3674 | // do event notification | ||
3675 | if (startedColliders.Count > 0) | ||
3676 | { | ||
3677 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3678 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3679 | foreach (uint localId in startedColliders) | ||
3680 | { | ||
3681 | if (localId == 0) | ||
3682 | continue; | ||
3683 | |||
3684 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3685 | string data = ""; | ||
3686 | if (obj != null) | ||
3687 | { | ||
3688 | DetectedObject detobj = new DetectedObject(); | ||
3689 | detobj.keyUUID = obj.UUID; | ||
3690 | detobj.nameStr = obj.Name; | ||
3691 | detobj.ownerUUID = obj.OwnerID; | ||
3692 | detobj.posVector = obj.AbsolutePosition; | ||
3693 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3694 | detobj.velVector = obj.Velocity; | ||
3695 | detobj.colliderType = 0; | ||
3696 | detobj.groupUUID = obj.GroupID; | ||
3697 | colliding.Add(detobj); | ||
3698 | } | ||
3699 | } | ||
3700 | |||
3701 | if (colliding.Count > 0) | ||
3702 | { | ||
3703 | StartCollidingMessage.Colliders = colliding; | ||
3704 | |||
3705 | foreach (SceneObjectGroup att in Attachments) | ||
3706 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3707 | } | ||
3708 | } | ||
3709 | |||
3710 | if (endedColliders.Count > 0) | ||
3711 | { | ||
3712 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3713 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3714 | foreach (uint localId in endedColliders) | ||
3715 | { | ||
3716 | if (localId == 0) | ||
3717 | continue; | ||
3718 | |||
3719 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3720 | string data = ""; | ||
3721 | if (obj != null) | ||
3722 | { | ||
3723 | DetectedObject detobj = new DetectedObject(); | ||
3724 | detobj.keyUUID = obj.UUID; | ||
3725 | detobj.nameStr = obj.Name; | ||
3726 | detobj.ownerUUID = obj.OwnerID; | ||
3727 | detobj.posVector = obj.AbsolutePosition; | ||
3728 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3729 | detobj.velVector = obj.Velocity; | ||
3730 | detobj.colliderType = 0; | ||
3731 | detobj.groupUUID = obj.GroupID; | ||
3732 | colliding.Add(detobj); | ||
3733 | } | ||
3734 | } | ||
3735 | |||
3736 | if (colliding.Count > 0) | ||
3737 | { | ||
3738 | EndCollidingMessage.Colliders = colliding; | ||
3739 | |||
3740 | foreach (SceneObjectGroup att in Attachments) | ||
3741 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
3742 | } | ||
3743 | } | ||
3744 | |||
3745 | if (thisHitColliders.Count > 0) | ||
3746 | { | ||
3747 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
3748 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3749 | foreach (uint localId in thisHitColliders) | ||
3750 | { | ||
3751 | if (localId == 0) | ||
3752 | continue; | ||
3753 | |||
3754 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3755 | string data = ""; | ||
3756 | if (obj != null) | ||
3757 | { | ||
3758 | DetectedObject detobj = new DetectedObject(); | ||
3759 | detobj.keyUUID = obj.UUID; | ||
3760 | detobj.nameStr = obj.Name; | ||
3761 | detobj.ownerUUID = obj.OwnerID; | ||
3762 | detobj.posVector = obj.AbsolutePosition; | ||
3763 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3764 | detobj.velVector = obj.Velocity; | ||
3765 | detobj.colliderType = 0; | ||
3766 | detobj.groupUUID = obj.GroupID; | ||
3767 | colliding.Add(detobj); | ||
3768 | } | ||
3769 | } | ||
3770 | |||
3771 | if (colliding.Count > 0) | ||
3772 | { | ||
3773 | CollidingMessage.Colliders = colliding; | ||
3774 | |||
3775 | lock (m_attachments) | ||
3776 | { | ||
3777 | foreach (SceneObjectGroup att in m_attachments) | ||
3778 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
3779 | } | ||
3780 | } | ||
3781 | } | ||
3782 | |||
3299 | if (m_invulnerable) | 3783 | if (m_invulnerable) |
3300 | return; | 3784 | return; |
3301 | 3785 | ||
@@ -3470,7 +3954,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3470 | m_scene = scene; | 3954 | m_scene = scene; |
3471 | 3955 | ||
3472 | RegisterToEvents(); | 3956 | RegisterToEvents(); |
3473 | 3957 | if (m_controllingClient != null) | |
3958 | { | ||
3959 | m_controllingClient.ProcessPendingPackets(); | ||
3960 | } | ||
3474 | /* | 3961 | /* |
3475 | AbsolutePosition = client.StartPos; | 3962 | AbsolutePosition = client.StartPos; |
3476 | 3963 | ||
@@ -3700,6 +4187,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3700 | return; | 4187 | return; |
3701 | } | 4188 | } |
3702 | 4189 | ||
4190 | XmlDocument doc = new XmlDocument(); | ||
4191 | string stateData = String.Empty; | ||
4192 | |||
4193 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
4194 | if (attServ != null) | ||
4195 | { | ||
4196 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
4197 | stateData = attServ.Get(ControllingClient.AgentId.ToString()); | ||
4198 | if (stateData != String.Empty) | ||
4199 | { | ||
4200 | try | ||
4201 | { | ||
4202 | doc.LoadXml(stateData); | ||
4203 | } | ||
4204 | catch { } | ||
4205 | } | ||
4206 | } | ||
4207 | |||
4208 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
4209 | |||
4210 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
4211 | if (nodes.Count > 0) | ||
4212 | { | ||
4213 | foreach (XmlNode n in nodes) | ||
4214 | { | ||
4215 | XmlElement elem = (XmlElement)n; | ||
4216 | string itemID = elem.GetAttribute("ItemID"); | ||
4217 | string xml = elem.InnerXml; | ||
4218 | |||
4219 | itemData[new UUID(itemID)] = xml; | ||
4220 | } | ||
4221 | } | ||
4222 | |||
3703 | List<int> attPoints = m_appearance.GetAttachedPoints(); | 4223 | List<int> attPoints = m_appearance.GetAttachedPoints(); |
3704 | foreach (int p in attPoints) | 4224 | foreach (int p in attPoints) |
3705 | { | 4225 | { |
@@ -3719,9 +4239,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3719 | 4239 | ||
3720 | try | 4240 | try |
3721 | { | 4241 | { |
3722 | // Rez from inventory | 4242 | string xmlData; |
3723 | UUID asset | 4243 | XmlDocument d = new XmlDocument(); |
3724 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p); | 4244 | UUID asset; |
4245 | if (itemData.TryGetValue(itemID, out xmlData)) | ||
4246 | { | ||
4247 | d.LoadXml(xmlData); | ||
4248 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", itemID); | ||
4249 | |||
4250 | // Rez from inventory | ||
4251 | asset | ||
4252 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, d); | ||
4253 | |||
4254 | } | ||
4255 | else | ||
4256 | { | ||
4257 | // Rez from inventory (with a null doc to let | ||
4258 | // CHANGED_OWNER happen) | ||
4259 | asset | ||
4260 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p, true, null); | ||
4261 | } | ||
3725 | 4262 | ||
3726 | m_log.InfoFormat( | 4263 | m_log.InfoFormat( |
3727 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | 4264 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", |
@@ -3758,5 +4295,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3758 | m_reprioritization_called = false; | 4295 | m_reprioritization_called = false; |
3759 | } | 4296 | } |
3760 | } | 4297 | } |
4298 | |||
4299 | private Vector3 Quat2Euler(Quaternion rot){ | ||
4300 | float x = Utils.RAD_TO_DEG * (float)Math.Atan2((double)((2.0f * rot.X * rot.W) - (2.0f * rot.Y * rot.Z)) , | ||
4301 | (double)(1 - (2.0f * rot.X * rot.X) - (2.0f * rot.Z * rot.Z))); | ||
4302 | float y = Utils.RAD_TO_DEG * (float)Math.Asin ((double)((2.0f * rot.X * rot.Y) + (2.0f * rot.Z * rot.W))); | ||
4303 | float z = Utils.RAD_TO_DEG * (float)Math.Atan2(((double)(2.0f * rot.Y * rot.W) - (2.0f * rot.X * rot.Z)) , | ||
4304 | (double)(1 - (2.0f * rot.Y * rot.Y) - (2.0f * rot.Z * rot.Z))); | ||
4305 | return(new Vector3(x,y,z)); | ||
4306 | } | ||
4307 | |||
4308 | |||
3761 | } | 4309 | } |
3762 | } | 4310 | } |
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 | |||