diff options
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | 23 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 80 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 39 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 70 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | 389 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 291 |
7 files changed, 563 insertions, 337 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index b37249d..b031f61 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -53,8 +53,8 @@ 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 | 60 | ||
@@ -123,17 +123,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
123 | /// </summary> | 123 | /// </summary> |
124 | public void TrySetMovementAnimation(string anim) | 124 | public void TrySetMovementAnimation(string anim) |
125 | { | 125 | { |
126 | //m_log.DebugFormat("Updating movement animation to {0}", anim); | 126 | //Console.WriteLine("Updating movement animation to {0}", anim); |
127 | 127 | ||
128 | if (!m_scenePresence.IsChildAgent) | 128 | if (!m_scenePresence.IsChildAgent) |
129 | { | 129 | { |
130 | if (m_animations.TrySetDefaultAnimation( | 130 | if (m_animations.TrySetDefaultAnimation( |
131 | anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero)) | 131 | anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero)) |
132 | { | 132 | { |
133 | //Console.WriteLine("TSMA {0} success.", anim); | ||
133 | // 16384 is CHANGED_ANIMATION | 134 | // 16384 is CHANGED_ANIMATION |
134 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 }); | 135 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { 16384 }); |
135 | SendAnimPack(); | 136 | SendAnimPack(); |
136 | } | 137 | } |
138 | else | ||
139 | { | ||
140 | //Console.WriteLine("TSMA {0} fail.", anim); | ||
141 | } | ||
137 | } | 142 | } |
138 | } | 143 | } |
139 | 144 | ||
@@ -156,10 +161,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
156 | Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); | 161 | Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); |
157 | 162 | ||
158 | // Check control flags | 163 | // Check control flags |
159 | bool heldForward = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; | 164 | 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); |
160 | bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG; | 165 | 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); |
161 | bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS; | 166 | 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); |
162 | bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG; | 167 | 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); |
163 | //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; | 168 | //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; |
164 | //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; | 169 | //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; |
165 | bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; | 170 | bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; |
@@ -312,7 +317,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
312 | public void UpdateMovementAnimations() | 317 | public void UpdateMovementAnimations() |
313 | { | 318 | { |
314 | m_movementAnimation = GetMovementAnimation(); | 319 | m_movementAnimation = GetMovementAnimation(); |
315 | 320 | //Console.WriteLine("UMA got {0}", m_movementAnimation); | |
316 | if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) | 321 | if (m_movementAnimation == "PREJUMP" && !m_scenePresence.Scene.m_usePreJump) |
317 | { | 322 | { |
318 | // This was the previous behavior before PREJUMP | 323 | // This was the previous behavior before PREJUMP |
@@ -444,4 +449,4 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
444 | SendAnimPack(animIDs, sequenceNums, objectIDs); | 449 | SendAnimPack(animIDs, sequenceNums, objectIDs); |
445 | } | 450 | } |
446 | } | 451 | } |
447 | } \ No newline at end of file | 452 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 66fb918..83208e9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -840,8 +840,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
840 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) | 840 | public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID) |
841 | { | 841 | { |
842 | SceneObjectPart part = GetSceneObjectPart(localID); | 842 | SceneObjectPart part = GetSceneObjectPart(localID); |
843 | SceneObjectGroup group = part.ParentGroup; | 843 | SceneObjectGroup group = null; |
844 | if (group != null) | 844 | if (part != null) |
845 | { | ||
846 | group = part.ParentGroup; | ||
847 | } | ||
848 | if (part != null && group != null) | ||
845 | { | 849 | { |
846 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); | 850 | TaskInventoryItem item = group.GetInventoryItem(localID, itemID); |
847 | if (item == null) | 851 | if (item == null) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a3f3d8f..f5a1e74 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -881,6 +881,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
881 | /// <param name="seconds">float indicating duration before restart.</param> | 881 | /// <param name="seconds">float indicating duration before restart.</param> |
882 | public virtual void Restart(float seconds) | 882 | public virtual void Restart(float seconds) |
883 | { | 883 | { |
884 | Restart(seconds, true); | ||
885 | } | ||
886 | |||
887 | /// <summary> | ||
888 | /// Given float seconds, this will restart the region. showDialog will optionally alert the users. | ||
889 | /// </summary> | ||
890 | /// <param name="seconds">float indicating duration before restart.</param> | ||
891 | public virtual void Restart(float seconds, bool showDialog) | ||
892 | { | ||
884 | // notifications are done in 15 second increments | 893 | // notifications are done in 15 second increments |
885 | // so .. if the number of seconds is less then 15 seconds, it's not really a restart request | 894 | // so .. if the number of seconds is less then 15 seconds, it's not really a restart request |
886 | // It's a 'Cancel restart' request. | 895 | // It's a 'Cancel restart' request. |
@@ -901,8 +910,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
901 | m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); | 910 | m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); |
902 | m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); | 911 | m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); |
903 | m_restartTimer.Start(); | 912 | m_restartTimer.Start(); |
904 | m_dialogModule.SendNotificationToUsersInRegion( | 913 | if (showDialog) |
905 | UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes"); | 914 | { |
915 | m_dialogModule.SendNotificationToUsersInRegion( | ||
916 | UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " + (seconds / 60).ToString() + " Minutes"); | ||
917 | } | ||
906 | } | 918 | } |
907 | } | 919 | } |
908 | 920 | ||
@@ -1159,8 +1171,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1159 | while (!shuttingdown) | 1171 | while (!shuttingdown) |
1160 | { | 1172 | { |
1161 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; | 1173 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; |
1162 | physicsFPS = 0f; | 1174 | physicsFPS = 0f; |
1163 | 1175 | ||
1164 | maintc = Util.EnvironmentTickCount(); | 1176 | maintc = Util.EnvironmentTickCount(); |
1165 | int tmpFrameMS = maintc; | 1177 | int tmpFrameMS = maintc; |
1166 | tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; | 1178 | tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
@@ -1173,24 +1185,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1173 | // Check if any objects have reached their targets | 1185 | // Check if any objects have reached their targets |
1174 | CheckAtTargets(); | 1186 | CheckAtTargets(); |
1175 | 1187 | ||
1176 | // Update SceneObjectGroups that have scheduled themselves for updates | ||
1177 | // Objects queue their updates onto all scene presences | ||
1178 | if (m_frame % m_update_objects == 0) | ||
1179 | m_sceneGraph.UpdateObjectGroups(); | ||
1180 | |||
1181 | // Run through all ScenePresences looking for updates | 1188 | // Run through all ScenePresences looking for updates |
1182 | // Presence updates and queued object updates for each presence are sent to clients | 1189 | // Presence updates and queued object updates for each presence are sent to clients |
1183 | if (m_frame % m_update_presences == 0) | 1190 | if (m_frame % m_update_presences == 0) |
1184 | m_sceneGraph.UpdatePresences(); | 1191 | m_sceneGraph.UpdatePresences(); |
1185 | 1192 | ||
1193 | // Update SceneObjectGroups that have scheduled themselves for updates | ||
1194 | // Objects queue their updates onto all scene presences | ||
1195 | if (m_frame % m_update_objects == 0) | ||
1196 | m_sceneGraph.UpdateObjectGroups(); | ||
1197 | |||
1186 | int tmpPhysicsMS2 = Util.EnvironmentTickCount(); | 1198 | int tmpPhysicsMS2 = Util.EnvironmentTickCount(); |
1187 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) | 1199 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) |
1188 | m_sceneGraph.UpdatePreparePhysics(); | 1200 | m_sceneGraph.UpdatePreparePhysics(); |
1189 | physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); | 1201 | physicsMS2 = Util.EnvironmentTickCountSubtract(tmpPhysicsMS2); |
1190 | 1202 | ||
1191 | if (m_frame % m_update_entitymovement == 0) | 1203 | if (m_frame % m_update_entitymovement == 0) |
1192 | m_sceneGraph.UpdateScenePresenceMovement(); | 1204 | m_sceneGraph.UpdateScenePresenceMovement(); |
1193 | 1205 | ||
1194 | int tmpPhysicsMS = Util.EnvironmentTickCount(); | 1206 | int tmpPhysicsMS = Util.EnvironmentTickCount(); |
1195 | if (m_frame % m_update_physics == 0) | 1207 | if (m_frame % m_update_physics == 0) |
1196 | { | 1208 | { |
@@ -1198,49 +1210,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
1198 | physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); | 1210 | physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); |
1199 | if (SynchronizeScene != null) | 1211 | if (SynchronizeScene != null) |
1200 | SynchronizeScene(this); | 1212 | SynchronizeScene(this); |
1201 | } | 1213 | } |
1202 | physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); | 1214 | physicsMS = Util.EnvironmentTickCountSubtract(tmpPhysicsMS); |
1203 | 1215 | ||
1204 | // Delete temp-on-rez stuff | 1216 | // Delete temp-on-rez stuff |
1205 | if (m_frame % m_update_backup == 0) | 1217 | if (m_frame % m_update_backup == 0) |
1206 | { | 1218 | { |
1207 | int tmpTempOnRezMS = Util.EnvironmentTickCount(); | 1219 | int tmpTempOnRezMS = Util.EnvironmentTickCount(); |
1208 | CleanTempObjects(); | 1220 | CleanTempObjects(); |
1209 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); | 1221 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpTempOnRezMS); |
1210 | } | 1222 | } |
1211 | 1223 | ||
1212 | if (RegionStatus != RegionStatus.SlaveScene) | 1224 | if (RegionStatus != RegionStatus.SlaveScene) |
1213 | { | 1225 | { |
1214 | if (m_frame % m_update_events == 0) | 1226 | if (m_frame % m_update_events == 0) |
1215 | { | 1227 | { |
1216 | int evMS = Util.EnvironmentTickCount(); | 1228 | int evMS = Util.EnvironmentTickCount(); |
1217 | UpdateEvents(); | 1229 | UpdateEvents(); |
1218 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1230 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1219 | } | 1231 | } |
1220 | 1232 | ||
1221 | if (m_frame % m_update_backup == 0) | 1233 | if (m_frame % m_update_backup == 0) |
1222 | { | 1234 | { |
1223 | int backMS = Util.EnvironmentTickCount(); | 1235 | int backMS = Util.EnvironmentTickCount(); |
1224 | UpdateStorageBackup(); | 1236 | UpdateStorageBackup(); |
1225 | backupMS = Util.EnvironmentTickCountSubtract(backMS); | 1237 | backupMS = Util.EnvironmentTickCountSubtract(backMS); |
1226 | } | 1238 | } |
1227 | 1239 | ||
1228 | if (m_frame % m_update_terrain == 0) | 1240 | if (m_frame % m_update_terrain == 0) |
1229 | { | 1241 | { |
1230 | int terMS = Util.EnvironmentTickCount(); | 1242 | int terMS = Util.EnvironmentTickCount(); |
1231 | UpdateTerrain(); | 1243 | UpdateTerrain(); |
1232 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | 1244 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1233 | } | 1245 | } |
1234 | 1246 | ||
1235 | if (m_frame % m_update_land == 0) | 1247 | if (m_frame % m_update_land == 0) |
1236 | { | 1248 | { |
1237 | int ldMS = Util.EnvironmentTickCount(); | 1249 | int ldMS = Util.EnvironmentTickCount(); |
1238 | UpdateLand(); | 1250 | UpdateLand(); |
1239 | landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1251 | landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1240 | } | 1252 | } |
1241 | 1253 | ||
1242 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1254 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); |
1243 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1255 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
1244 | lastCompletedFrame = Util.EnvironmentTickCount(); | 1256 | lastCompletedFrame = Util.EnvironmentTickCount(); |
1245 | 1257 | ||
1246 | // if (m_frame%m_update_avatars == 0) | 1258 | // if (m_frame%m_update_avatars == 0) |
@@ -1293,8 +1305,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1293 | finally | 1305 | finally |
1294 | { | 1306 | { |
1295 | m_lastupdate = DateTime.UtcNow; | 1307 | m_lastupdate = DateTime.UtcNow; |
1296 | } | 1308 | } |
1297 | 1309 | ||
1298 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1310 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1299 | maintc = (int)(m_timespan * 1000) - maintc; | 1311 | maintc = (int)(m_timespan * 1000) - maintc; |
1300 | 1312 | ||
@@ -2581,8 +2593,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2581 | sp.IsChildAgent = false; | 2593 | sp.IsChildAgent = false; |
2582 | Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); | 2594 | Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); |
2583 | } | 2595 | } |
2584 | } | 2596 | } |
2585 | 2597 | ||
2586 | m_LastLogin = Util.EnvironmentTickCount(); | 2598 | m_LastLogin = Util.EnvironmentTickCount(); |
2587 | EventManager.TriggerOnNewClient(client); | 2599 | EventManager.TriggerOnNewClient(client); |
2588 | } | 2600 | } |
@@ -4650,15 +4662,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4650 | // 3 = We have seen a new user enter within the past 4 minutes | 4662 | // 3 = We have seen a new user enter within the past 4 minutes |
4651 | // which can be seen as positive confirmation of sim health | 4663 | // which can be seen as positive confirmation of sim health |
4652 | // | 4664 | // |
4653 | int health=1; // Start at 1, means we're up | 4665 | int health=1; // Start at 1, means we're up |
4654 | 4666 | ||
4655 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4667 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) |
4656 | health+=1; | 4668 | health+=1; |
4657 | else | 4669 | else |
4658 | return health; | 4670 | return health; |
4659 | 4671 | ||
4660 | // A login in the last 4 mins? We can't be doing too badly | 4672 | // A login in the last 4 mins? We can't be doing too badly |
4661 | // | 4673 | // |
4662 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4674 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) |
4663 | health++; | 4675 | health++; |
4664 | else | 4676 | else |
@@ -4855,8 +4867,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4855 | private void CheckHeartbeat() | 4867 | private void CheckHeartbeat() |
4856 | { | 4868 | { |
4857 | if (m_firstHeartbeat) | 4869 | if (m_firstHeartbeat) |
4858 | return; | 4870 | return; |
4859 | 4871 | ||
4860 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4872 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) |
4861 | StartTimer(); | 4873 | StartTimer(); |
4862 | } | 4874 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 7359011..26a843e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -1735,6 +1735,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
1735 | } | 1735 | } |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
1739 | { | ||
1740 | SceneObjectPart rootpart = m_rootPart; | ||
1741 | if (rootpart != null) | ||
1742 | { | ||
1743 | if (IsAttachment) | ||
1744 | { | ||
1745 | /* | ||
1746 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
1747 | if (avatar != null) | ||
1748 | { | ||
1749 | Rotate the Av? | ||
1750 | } */ | ||
1751 | } | ||
1752 | else | ||
1753 | { | ||
1754 | if (rootpart.PhysActor != null) | ||
1755 | { | ||
1756 | rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); | ||
1757 | rootpart.PhysActor.APIDStrength = strength; | ||
1758 | rootpart.PhysActor.APIDDamping = damping; | ||
1759 | rootpart.PhysActor.APIDActive = true; | ||
1760 | } | ||
1761 | } | ||
1762 | } | ||
1763 | } | ||
1764 | public void stopLookAt() | ||
1765 | { | ||
1766 | SceneObjectPart rootpart = m_rootPart; | ||
1767 | if (rootpart != null) | ||
1768 | { | ||
1769 | if (rootpart.PhysActor != null) | ||
1770 | { | ||
1771 | rootpart.PhysActor.APIDActive = false; | ||
1772 | } | ||
1773 | } | ||
1774 | |||
1775 | } | ||
1776 | |||
1738 | /// <summary> | 1777 | /// <summary> |
1739 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. | 1778 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. |
1740 | /// </summary> | 1779 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b6916f2..19e3023 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -389,12 +389,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
389 | } | 389 | } |
390 | 390 | ||
391 | /// <value> | 391 | /// <value> |
392 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 392 | /// Get the inventory list |
393 | /// </value> | 393 | /// </value> |
394 | public TaskInventoryDictionary TaskInventory | 394 | public TaskInventoryDictionary TaskInventory |
395 | { | 395 | { |
396 | get { return m_inventory.Items; } | 396 | get { |
397 | set { m_inventory.Items = value; } | 397 | return m_inventory.Items; |
398 | } | ||
399 | set { | ||
400 | m_inventory.Items = value; | ||
401 | } | ||
398 | } | 402 | } |
399 | 403 | ||
400 | public uint ObjectFlags | 404 | public uint ObjectFlags |
@@ -1064,14 +1068,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1064 | } | 1068 | } |
1065 | } | 1069 | } |
1066 | 1070 | ||
1067 | /// <summary> | ||
1068 | /// Clear all pending updates of parts to clients | ||
1069 | /// </summary> | ||
1070 | private void ClearUpdateSchedule() | ||
1071 | { | ||
1072 | m_updateFlag = 0; | ||
1073 | } | ||
1074 | |||
1075 | private void SendObjectPropertiesToClient(UUID AgentID) | 1071 | private void SendObjectPropertiesToClient(UUID AgentID) |
1076 | { | 1072 | { |
1077 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); | 1073 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); |
@@ -2109,17 +2105,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2109 | //Trys to fetch sound id from prim's inventory. | 2105 | //Trys to fetch sound id from prim's inventory. |
2110 | //Prim's inventory doesn't support non script items yet | 2106 | //Prim's inventory doesn't support non script items yet |
2111 | 2107 | ||
2112 | lock (TaskInventory) | 2108 | TaskInventory.LockItemsForRead(true); |
2109 | |||
2110 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
2113 | { | 2111 | { |
2114 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 2112 | if (item.Value.Name == sound) |
2115 | { | 2113 | { |
2116 | if (item.Value.Name == sound) | 2114 | soundID = item.Value.ItemID; |
2117 | { | 2115 | break; |
2118 | soundID = item.Value.ItemID; | ||
2119 | break; | ||
2120 | } | ||
2121 | } | 2116 | } |
2122 | } | 2117 | } |
2118 | |||
2119 | TaskInventory.LockItemsForRead(false); | ||
2123 | } | 2120 | } |
2124 | 2121 | ||
2125 | List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); | 2122 | List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); |
@@ -2185,6 +2182,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2185 | ParentGroup.HasGroupChanged = true; | 2182 | ParentGroup.HasGroupChanged = true; |
2186 | ScheduleFullUpdate(); | 2183 | ScheduleFullUpdate(); |
2187 | } | 2184 | } |
2185 | |||
2186 | public void RotLookAt(Quaternion target, float strength, float damping) | ||
2187 | { | ||
2188 | m_parentGroup.rotLookAt(target, strength, damping); | ||
2189 | } | ||
2188 | 2190 | ||
2189 | /// <summary> | 2191 | /// <summary> |
2190 | /// Schedules this prim for a full update | 2192 | /// Schedules this prim for a full update |
@@ -2389,8 +2391,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2389 | { | 2391 | { |
2390 | const float ROTATION_TOLERANCE = 0.01f; | 2392 | const float ROTATION_TOLERANCE = 0.01f; |
2391 | const float VELOCITY_TOLERANCE = 0.001f; | 2393 | const float VELOCITY_TOLERANCE = 0.001f; |
2392 | const float POSITION_TOLERANCE = 0.05f; | 2394 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
2393 | const int TIME_MS_TOLERANCE = 3000; | 2395 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
2394 | 2396 | ||
2395 | if (m_updateFlag == 1) | 2397 | if (m_updateFlag == 1) |
2396 | { | 2398 | { |
@@ -2404,7 +2406,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2404 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 2406 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) |
2405 | { | 2407 | { |
2406 | AddTerseUpdateToAllAvatars(); | 2408 | AddTerseUpdateToAllAvatars(); |
2407 | ClearUpdateSchedule(); | 2409 | |
2408 | 2410 | ||
2409 | // This causes the Scene to 'poll' physical objects every couple of frames | 2411 | // This causes the Scene to 'poll' physical objects every couple of frames |
2410 | // bad, so it's been replaced by an event driven method. | 2412 | // bad, so it's been replaced by an event driven method. |
@@ -2422,16 +2424,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2422 | m_lastAngularVelocity = AngularVelocity; | 2424 | m_lastAngularVelocity = AngularVelocity; |
2423 | m_lastTerseSent = Environment.TickCount; | 2425 | m_lastTerseSent = Environment.TickCount; |
2424 | } | 2426 | } |
2427 | //Moved this outside of the if clause so updates don't get blocked.. *sigh* | ||
2428 | m_updateFlag = 0; //Why were we calling a function to do this? Inefficient! *screams* | ||
2425 | } | 2429 | } |
2426 | else | 2430 | else |
2427 | { | 2431 | { |
2428 | if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes | 2432 | if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes |
2429 | { | 2433 | { |
2430 | AddFullUpdateToAllAvatars(); | 2434 | AddFullUpdateToAllAvatars(); |
2431 | ClearUpdateSchedule(); | 2435 | m_updateFlag = 0; //Same here |
2432 | } | 2436 | } |
2433 | } | 2437 | } |
2434 | ClearUpdateSchedule(); | 2438 | m_updateFlag = 0; |
2435 | } | 2439 | } |
2436 | 2440 | ||
2437 | /// <summary> | 2441 | /// <summary> |
@@ -2458,17 +2462,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2458 | if (!UUID.TryParse(sound, out soundID)) | 2462 | if (!UUID.TryParse(sound, out soundID)) |
2459 | { | 2463 | { |
2460 | // search sound file from inventory | 2464 | // search sound file from inventory |
2461 | lock (TaskInventory) | 2465 | TaskInventory.LockItemsForRead(true); |
2466 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
2462 | { | 2467 | { |
2463 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | 2468 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) |
2464 | { | 2469 | { |
2465 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) | 2470 | soundID = item.Value.ItemID; |
2466 | { | 2471 | break; |
2467 | soundID = item.Value.ItemID; | ||
2468 | break; | ||
2469 | } | ||
2470 | } | 2472 | } |
2471 | } | 2473 | } |
2474 | TaskInventory.LockItemsForRead(false); | ||
2472 | } | 2475 | } |
2473 | 2476 | ||
2474 | if (soundID == UUID.Zero) | 2477 | if (soundID == UUID.Zero) |
@@ -2684,6 +2687,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2684 | SetText(text); | 2687 | SetText(text); |
2685 | } | 2688 | } |
2686 | 2689 | ||
2690 | public void StopLookAt() | ||
2691 | { | ||
2692 | m_parentGroup.stopLookAt(); | ||
2693 | |||
2694 | m_parentGroup.ScheduleGroupForTerseUpdate(); | ||
2695 | } | ||
2696 | |||
2687 | public void StopMoveToTarget() | 2697 | public void StopMoveToTarget() |
2688 | { | 2698 | { |
2689 | m_parentGroup.stopMoveToTarget(); | 2699 | m_parentGroup.stopMoveToTarget(); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 7a0d7b7..eca8588 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -80,7 +80,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
80 | /// </value> | 80 | /// </value> |
81 | protected internal TaskInventoryDictionary Items | 81 | protected internal TaskInventoryDictionary Items |
82 | { | 82 | { |
83 | get { return m_items; } | 83 | get { |
84 | return m_items; | ||
85 | } | ||
84 | set | 86 | set |
85 | { | 87 | { |
86 | m_items = value; | 88 | m_items = value; |
@@ -116,22 +118,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
116 | /// <param name="linkNum">Link number for the part</param> | 118 | /// <param name="linkNum">Link number for the part</param> |
117 | public void ResetInventoryIDs() | 119 | public void ResetInventoryIDs() |
118 | { | 120 | { |
119 | lock (Items) | 121 | m_items.LockItemsForWrite(true); |
122 | |||
123 | if (0 == Items.Count) | ||
120 | { | 124 | { |
121 | if (0 == Items.Count) | 125 | m_items.LockItemsForWrite(false); |
122 | return; | 126 | return; |
127 | } | ||
123 | 128 | ||
124 | HasInventoryChanged = true; | 129 | HasInventoryChanged = true; |
125 | m_part.ParentGroup.HasGroupChanged = true; | 130 | m_part.ParentGroup.HasGroupChanged = true; |
126 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 131 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
127 | Items.Clear(); | 132 | Items.Clear(); |
128 | 133 | ||
129 | foreach (TaskInventoryItem item in items) | 134 | foreach (TaskInventoryItem item in items) |
130 | { | 135 | { |
131 | item.ResetIDs(m_part.UUID); | 136 | item.ResetIDs(m_part.UUID); |
132 | Items.Add(item.ItemID, item); | 137 | Items.Add(item.ItemID, item); |
133 | } | ||
134 | } | 138 | } |
139 | m_items.LockItemsForWrite(false); | ||
135 | } | 140 | } |
136 | 141 | ||
137 | /// <summary> | 142 | /// <summary> |
@@ -140,25 +145,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
140 | /// <param name="ownerId"></param> | 145 | /// <param name="ownerId"></param> |
141 | public void ChangeInventoryOwner(UUID ownerId) | 146 | public void ChangeInventoryOwner(UUID ownerId) |
142 | { | 147 | { |
143 | lock (Items) | 148 | m_items.LockItemsForWrite(true); |
149 | if (0 == Items.Count) | ||
144 | { | 150 | { |
145 | if (0 == Items.Count) | 151 | m_items.LockItemsForWrite(false); |
146 | { | 152 | return; |
147 | return; | 153 | } |
148 | } | ||
149 | 154 | ||
150 | HasInventoryChanged = true; | 155 | HasInventoryChanged = true; |
151 | m_part.ParentGroup.HasGroupChanged = true; | 156 | m_part.ParentGroup.HasGroupChanged = true; |
152 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 157 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
153 | foreach (TaskInventoryItem item in items) | 158 | foreach (TaskInventoryItem item in items) |
159 | { | ||
160 | if (ownerId != item.OwnerID) | ||
154 | { | 161 | { |
155 | if (ownerId != item.OwnerID) | 162 | item.LastOwnerID = item.OwnerID; |
156 | { | 163 | item.OwnerID = ownerId; |
157 | item.LastOwnerID = item.OwnerID; | ||
158 | item.OwnerID = ownerId; | ||
159 | } | ||
160 | } | 164 | } |
161 | } | 165 | } |
166 | m_items.LockItemsForWrite(false); | ||
162 | } | 167 | } |
163 | 168 | ||
164 | /// <summary> | 169 | /// <summary> |
@@ -167,24 +172,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
167 | /// <param name="groupID"></param> | 172 | /// <param name="groupID"></param> |
168 | public void ChangeInventoryGroup(UUID groupID) | 173 | public void ChangeInventoryGroup(UUID groupID) |
169 | { | 174 | { |
170 | lock (Items) | 175 | m_items.LockItemsForWrite(true); |
176 | if (0 == Items.Count) | ||
171 | { | 177 | { |
172 | if (0 == Items.Count) | 178 | m_items.LockItemsForWrite(false); |
173 | { | 179 | return; |
174 | return; | 180 | } |
175 | } | ||
176 | 181 | ||
177 | HasInventoryChanged = true; | 182 | HasInventoryChanged = true; |
178 | m_part.ParentGroup.HasGroupChanged = true; | 183 | m_part.ParentGroup.HasGroupChanged = true; |
179 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 184 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
180 | foreach (TaskInventoryItem item in items) | 185 | foreach (TaskInventoryItem item in items) |
186 | { | ||
187 | if (groupID != item.GroupID) | ||
181 | { | 188 | { |
182 | if (groupID != item.GroupID) | 189 | item.GroupID = groupID; |
183 | { | ||
184 | item.GroupID = groupID; | ||
185 | } | ||
186 | } | 190 | } |
187 | } | 191 | } |
192 | m_items.LockItemsForWrite(false); | ||
188 | } | 193 | } |
189 | 194 | ||
190 | /// <summary> | 195 | /// <summary> |
@@ -192,14 +197,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
192 | /// </summary> | 197 | /// </summary> |
193 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 198 | public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
194 | { | 199 | { |
195 | lock (m_items) | 200 | Items.LockItemsForRead(true); |
201 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
202 | Items.LockItemsForRead(false); | ||
203 | foreach (TaskInventoryItem item in items) | ||
196 | { | 204 | { |
197 | foreach (TaskInventoryItem item in Items.Values) | 205 | if ((int)InventoryType.LSL == item.InvType) |
198 | { | 206 | { |
199 | if ((int)InventoryType.LSL == item.InvType) | 207 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
200 | { | ||
201 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | ||
202 | } | ||
203 | } | 208 | } |
204 | } | 209 | } |
205 | } | 210 | } |
@@ -209,17 +214,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
209 | /// </summary> | 214 | /// </summary> |
210 | public void RemoveScriptInstances() | 215 | public void RemoveScriptInstances() |
211 | { | 216 | { |
212 | lock (Items) | 217 | Items.LockItemsForRead(true); |
218 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
219 | Items.LockItemsForRead(false); | ||
220 | |||
221 | foreach (TaskInventoryItem item in items) | ||
213 | { | 222 | { |
214 | foreach (TaskInventoryItem item in Items.Values) | 223 | if ((int)InventoryType.LSL == item.InvType) |
215 | { | 224 | { |
216 | if ((int)InventoryType.LSL == item.InvType) | 225 | RemoveScriptInstance(item.ItemID); |
217 | { | 226 | m_part.RemoveScriptEvents(item.ItemID); |
218 | RemoveScriptInstance(item.ItemID); | ||
219 | m_part.RemoveScriptEvents(item.ItemID); | ||
220 | } | ||
221 | } | 227 | } |
222 | } | 228 | } |
229 | |||
230 | |||
223 | } | 231 | } |
224 | 232 | ||
225 | /// <summary> | 233 | /// <summary> |
@@ -244,8 +252,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
244 | if (stateSource == 1 && // Prim crossing | 252 | if (stateSource == 1 && // Prim crossing |
245 | m_part.ParentGroup.Scene.m_trustBinaries) | 253 | m_part.ParentGroup.Scene.m_trustBinaries) |
246 | { | 254 | { |
255 | m_items.LockItemsForWrite(true); | ||
247 | m_items[item.ItemID].PermsMask = 0; | 256 | m_items[item.ItemID].PermsMask = 0; |
248 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 257 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
258 | m_items.LockItemsForWrite(false); | ||
249 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 259 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
250 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 260 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
251 | m_part.ParentGroup.AddActiveScriptCount(1); | 261 | m_part.ParentGroup.AddActiveScriptCount(1); |
@@ -266,8 +276,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
266 | { | 276 | { |
267 | if (m_part.ParentGroup.m_savedScriptState != null) | 277 | if (m_part.ParentGroup.m_savedScriptState != null) |
268 | RestoreSavedScriptState(item.OldItemID, item.ItemID); | 278 | RestoreSavedScriptState(item.OldItemID, item.ItemID); |
279 | m_items.LockItemsForWrite(true); | ||
269 | m_items[item.ItemID].PermsMask = 0; | 280 | m_items[item.ItemID].PermsMask = 0; |
270 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 281 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
282 | m_items.LockItemsForWrite(false); | ||
271 | string script = Utils.BytesToString(asset.Data); | 283 | string script = Utils.BytesToString(asset.Data); |
272 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 284 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
273 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 285 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
@@ -302,20 +314,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
302 | /// </param> | 314 | /// </param> |
303 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 315 | public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
304 | { | 316 | { |
305 | lock (m_items) | 317 | m_items.LockItemsForRead(true); |
318 | if (m_items.ContainsKey(itemId)) | ||
306 | { | 319 | { |
307 | if (m_items.ContainsKey(itemId)) | 320 | TaskInventoryItem item = m_items[itemId]; |
308 | { | 321 | m_items.LockItemsForRead(false); |
309 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | 322 | CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); |
310 | } | ||
311 | else | ||
312 | { | ||
313 | m_log.ErrorFormat( | ||
314 | "[PRIM INVENTORY]: " + | ||
315 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", | ||
316 | itemId, m_part.Name, m_part.UUID); | ||
317 | } | ||
318 | } | 323 | } |
324 | else | ||
325 | { | ||
326 | m_items.LockItemsForRead(false); | ||
327 | m_log.ErrorFormat( | ||
328 | "[PRIM INVENTORY]: " + | ||
329 | "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", | ||
330 | itemId, m_part.Name, m_part.UUID); | ||
331 | } | ||
332 | |||
319 | } | 333 | } |
320 | 334 | ||
321 | /// <summary> | 335 | /// <summary> |
@@ -346,11 +360,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
346 | /// <returns></returns> | 360 | /// <returns></returns> |
347 | private bool InventoryContainsName(string name) | 361 | private bool InventoryContainsName(string name) |
348 | { | 362 | { |
349 | foreach (TaskInventoryItem item in Items.Values) | 363 | m_items.LockItemsForRead(true); |
364 | foreach (TaskInventoryItem item in m_items.Values) | ||
350 | { | 365 | { |
351 | if (item.Name == name) | 366 | if (item.Name == name) |
367 | { | ||
368 | m_items.LockItemsForRead(false); | ||
352 | return true; | 369 | return true; |
370 | } | ||
353 | } | 371 | } |
372 | m_items.LockItemsForRead(false); | ||
354 | return false; | 373 | return false; |
355 | } | 374 | } |
356 | 375 | ||
@@ -392,7 +411,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
392 | /// <param name="item"></param> | 411 | /// <param name="item"></param> |
393 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 412 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
394 | { | 413 | { |
414 | m_items.LockItemsForRead(true); | ||
395 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | 415 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); |
416 | m_items.LockItemsForRead(false); | ||
396 | foreach (TaskInventoryItem i in il) | 417 | foreach (TaskInventoryItem i in il) |
397 | { | 418 | { |
398 | if (i.Name == item.Name) | 419 | if (i.Name == item.Name) |
@@ -429,15 +450,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
429 | item.ParentPartID = m_part.UUID; | 450 | item.ParentPartID = m_part.UUID; |
430 | item.Name = name; | 451 | item.Name = name; |
431 | 452 | ||
432 | lock (m_items) | 453 | m_items.LockItemsForWrite(true); |
433 | { | 454 | m_items.Add(item.ItemID, item); |
434 | m_items.Add(item.ItemID, item); | 455 | m_items.LockItemsForWrite(false); |
435 | |||
436 | if (allowedDrop) | 456 | if (allowedDrop) |
437 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 457 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
438 | else | 458 | else |
439 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 459 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
440 | } | 460 | |
441 | 461 | ||
442 | m_inventorySerial++; | 462 | m_inventorySerial++; |
443 | //m_inventorySerial += 2; | 463 | //m_inventorySerial += 2; |
@@ -454,14 +474,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
454 | /// <param name="items"></param> | 474 | /// <param name="items"></param> |
455 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 475 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
456 | { | 476 | { |
457 | lock (m_items) | 477 | m_items.LockItemsForWrite(true); |
478 | foreach (TaskInventoryItem item in items) | ||
458 | { | 479 | { |
459 | foreach (TaskInventoryItem item in items) | 480 | m_items.Add(item.ItemID, item); |
460 | { | 481 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
461 | m_items.Add(item.ItemID, item); | ||
462 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
463 | } | ||
464 | } | 482 | } |
483 | m_items.LockItemsForWrite(false); | ||
465 | 484 | ||
466 | m_inventorySerial++; | 485 | m_inventorySerial++; |
467 | } | 486 | } |
@@ -474,8 +493,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
474 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 493 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
475 | { | 494 | { |
476 | TaskInventoryItem item; | 495 | TaskInventoryItem item; |
496 | m_items.LockItemsForRead(true); | ||
477 | m_items.TryGetValue(itemId, out item); | 497 | m_items.TryGetValue(itemId, out item); |
478 | 498 | m_items.LockItemsForRead(false); | |
479 | return item; | 499 | return item; |
480 | } | 500 | } |
481 | 501 | ||
@@ -487,45 +507,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
487 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> | 507 | /// <returns>false if the item did not exist, true if the update occurred successfully</returns> |
488 | public bool UpdateInventoryItem(TaskInventoryItem item) | 508 | public bool UpdateInventoryItem(TaskInventoryItem item) |
489 | { | 509 | { |
490 | lock (m_items) | 510 | m_items.LockItemsForWrite(true); |
511 | |||
512 | if (m_items.ContainsKey(item.ItemID)) | ||
491 | { | 513 | { |
492 | if (m_items.ContainsKey(item.ItemID)) | 514 | item.ParentID = m_part.UUID; |
515 | item.ParentPartID = m_part.UUID; | ||
516 | item.Flags = m_items[item.ItemID].Flags; | ||
517 | if (item.AssetID == UUID.Zero) | ||
493 | { | 518 | { |
494 | item.ParentID = m_part.UUID; | 519 | item.AssetID = m_items[item.ItemID].AssetID; |
495 | item.ParentPartID = m_part.UUID; | 520 | } |
496 | item.Flags = m_items[item.ItemID].Flags; | 521 | else if ((InventoryType)item.Type == InventoryType.Notecard) |
497 | if (item.AssetID == UUID.Zero) | 522 | { |
498 | { | 523 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); |
499 | item.AssetID = m_items[item.ItemID].AssetID; | ||
500 | } | ||
501 | else if ((InventoryType)item.Type == InventoryType.Notecard) | ||
502 | { | ||
503 | ScenePresence presence = m_part.ParentGroup.Scene.GetScenePresence(item.OwnerID); | ||
504 | 524 | ||
505 | if (presence != null) | 525 | if (presence != null) |
506 | { | 526 | { |
507 | presence.ControllingClient.SendAgentAlertMessage( | 527 | presence.ControllingClient.SendAgentAlertMessage( |
508 | "Notecard saved", false); | 528 | "Notecard saved", false); |
509 | } | ||
510 | } | 529 | } |
530 | } | ||
511 | 531 | ||
512 | m_items[item.ItemID] = item; | 532 | m_items[item.ItemID] = item; |
513 | m_inventorySerial++; | 533 | m_inventorySerial++; |
514 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 534 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
515 | |||
516 | HasInventoryChanged = true; | ||
517 | m_part.ParentGroup.HasGroupChanged = true; | ||
518 | 535 | ||
519 | return true; | 536 | HasInventoryChanged = true; |
520 | } | 537 | m_part.ParentGroup.HasGroupChanged = true; |
521 | else | 538 | m_items.LockItemsForWrite(false); |
522 | { | 539 | return true; |
523 | m_log.ErrorFormat( | 540 | } |
524 | "[PRIM INVENTORY]: " + | 541 | else |
525 | "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | 542 | { |
526 | item.ItemID, m_part.Name, m_part.UUID); | 543 | m_log.ErrorFormat( |
527 | } | 544 | "[PRIM INVENTORY]: " + |
545 | "Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | ||
546 | item.ItemID, m_part.Name, m_part.UUID); | ||
528 | } | 547 | } |
548 | m_items.LockItemsForWrite(false); | ||
529 | 549 | ||
530 | return false; | 550 | return false; |
531 | } | 551 | } |
@@ -538,51 +558,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
538 | /// in this prim's inventory.</returns> | 558 | /// in this prim's inventory.</returns> |
539 | public int RemoveInventoryItem(UUID itemID) | 559 | public int RemoveInventoryItem(UUID itemID) |
540 | { | 560 | { |
541 | lock (m_items) | 561 | m_items.LockItemsForRead(true); |
562 | |||
563 | if (m_items.ContainsKey(itemID)) | ||
542 | { | 564 | { |
543 | if (m_items.ContainsKey(itemID)) | 565 | int type = m_items[itemID].InvType; |
566 | m_items.LockItemsForRead(false); | ||
567 | if (type == 10) // Script | ||
544 | { | 568 | { |
545 | int type = m_items[itemID].InvType; | 569 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
546 | if (type == 10) // Script | 570 | } |
547 | { | 571 | m_items.LockItemsForWrite(true); |
548 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 572 | m_items.Remove(itemID); |
549 | } | 573 | m_items.LockItemsForWrite(false); |
550 | m_items.Remove(itemID); | 574 | m_inventorySerial++; |
551 | m_inventorySerial++; | 575 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
552 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
553 | |||
554 | HasInventoryChanged = true; | ||
555 | m_part.ParentGroup.HasGroupChanged = true; | ||
556 | 576 | ||
557 | int scriptcount = 0; | 577 | HasInventoryChanged = true; |
558 | lock (m_items) | 578 | m_part.ParentGroup.HasGroupChanged = true; |
559 | { | ||
560 | foreach (TaskInventoryItem item in m_items.Values) | ||
561 | { | ||
562 | if (item.Type == 10) | ||
563 | { | ||
564 | scriptcount++; | ||
565 | } | ||
566 | } | ||
567 | } | ||
568 | 579 | ||
569 | if (scriptcount <= 0) | 580 | int scriptcount = 0; |
581 | m_items.LockItemsForRead(true); | ||
582 | foreach (TaskInventoryItem item in m_items.Values) | ||
583 | { | ||
584 | if (item.Type == 10) | ||
570 | { | 585 | { |
571 | m_part.RemFlag(PrimFlags.Scripted); | 586 | scriptcount++; |
572 | } | 587 | } |
573 | |||
574 | m_part.ScheduleFullUpdate(); | ||
575 | |||
576 | return type; | ||
577 | } | 588 | } |
578 | else | 589 | m_items.LockItemsForRead(false); |
590 | |||
591 | |||
592 | if (scriptcount <= 0) | ||
579 | { | 593 | { |
580 | m_log.ErrorFormat( | 594 | m_part.RemFlag(PrimFlags.Scripted); |
581 | "[PRIM INVENTORY]: " + | ||
582 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | ||
583 | itemID, m_part.Name, m_part.UUID); | ||
584 | } | 595 | } |
596 | |||
597 | m_part.ScheduleFullUpdate(); | ||
598 | |||
599 | return type; | ||
600 | } | ||
601 | else | ||
602 | { | ||
603 | m_log.ErrorFormat( | ||
604 | "[PRIM INVENTORY]: " + | ||
605 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", | ||
606 | itemID, m_part.Name, m_part.UUID); | ||
585 | } | 607 | } |
608 | m_items.LockItemsForWrite(false); | ||
586 | 609 | ||
587 | return -1; | 610 | return -1; |
588 | } | 611 | } |
@@ -635,52 +658,53 @@ namespace OpenSim.Region.Framework.Scenes | |||
635 | // isn't available (such as drag from prim inventory to agent inventory) | 658 | // isn't available (such as drag from prim inventory to agent inventory) |
636 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 659 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
637 | 660 | ||
638 | lock (m_items) | 661 | m_items.LockItemsForRead(true); |
662 | |||
663 | foreach (TaskInventoryItem item in m_items.Values) | ||
639 | { | 664 | { |
640 | foreach (TaskInventoryItem item in m_items.Values) | 665 | UUID ownerID = item.OwnerID; |
641 | { | 666 | uint everyoneMask = 0; |
642 | UUID ownerID = item.OwnerID; | 667 | uint baseMask = item.BasePermissions; |
643 | uint everyoneMask = 0; | 668 | uint ownerMask = item.CurrentPermissions; |
644 | uint baseMask = item.BasePermissions; | ||
645 | uint ownerMask = item.CurrentPermissions; | ||
646 | 669 | ||
647 | invString.AddItemStart(); | 670 | invString.AddItemStart(); |
648 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 671 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
649 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | 672 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); |
650 | 673 | ||
651 | invString.AddPermissionsStart(); | 674 | invString.AddPermissionsStart(); |
652 | 675 | ||
653 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 676 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); |
654 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 677 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); |
655 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); | 678 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(0)); |
656 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | 679 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); |
657 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | 680 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); |
658 | 681 | ||
659 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | 682 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); |
660 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | 683 | invString.AddNameValueLine("owner_id", ownerID.ToString()); |
661 | 684 | ||
662 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | 685 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); |
663 | 686 | ||
664 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | 687 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); |
665 | invString.AddSectionEnd(); | 688 | invString.AddSectionEnd(); |
666 | 689 | ||
667 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | 690 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); |
668 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); | 691 | invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]); |
669 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); | 692 | invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]); |
670 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | 693 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); |
671 | 694 | ||
672 | invString.AddSaleStart(); | 695 | invString.AddSaleStart(); |
673 | invString.AddNameValueLine("sale_type", "not"); | 696 | invString.AddNameValueLine("sale_type", "not"); |
674 | invString.AddNameValueLine("sale_price", "0"); | 697 | invString.AddNameValueLine("sale_price", "0"); |
675 | invString.AddSectionEnd(); | 698 | invString.AddSectionEnd(); |
676 | 699 | ||
677 | invString.AddNameValueLine("name", item.Name + "|"); | 700 | invString.AddNameValueLine("name", item.Name + "|"); |
678 | invString.AddNameValueLine("desc", item.Description + "|"); | 701 | invString.AddNameValueLine("desc", item.Description + "|"); |
679 | 702 | ||
680 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | 703 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); |
681 | invString.AddSectionEnd(); | 704 | invString.AddSectionEnd(); |
682 | } | ||
683 | } | 705 | } |
706 | int count = m_items.Count; | ||
707 | m_items.LockItemsForRead(false); | ||
684 | 708 | ||
685 | fileData = Utils.StringToBytes(invString.BuildString); | 709 | fileData = Utils.StringToBytes(invString.BuildString); |
686 | 710 | ||
@@ -701,10 +725,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
701 | { | 725 | { |
702 | if (HasInventoryChanged) | 726 | if (HasInventoryChanged) |
703 | { | 727 | { |
704 | lock (Items) | 728 | Items.LockItemsForRead(true); |
705 | { | 729 | datastore.StorePrimInventory(m_part.UUID, Items.Values); |
706 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | 730 | Items.LockItemsForRead(false); |
707 | } | ||
708 | 731 | ||
709 | HasInventoryChanged = false; | 732 | HasInventoryChanged = false; |
710 | } | 733 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index bcad335..6812914 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -73,7 +73,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
73 | // { | 73 | // { |
74 | // m_log.Debug("[ScenePresence] Destructor called"); | 74 | // m_log.Debug("[ScenePresence] Destructor called"); |
75 | // } | 75 | // } |
76 | 76 | ||
77 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 77 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
78 | 78 | ||
79 | 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 }; |
@@ -89,7 +89,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
89 | /// 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 |
90 | /// issue #1716 | 90 | /// issue #1716 |
91 | /// </summary> | 91 | /// </summary> |
92 | 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); | ||
93 | 95 | ||
94 | public UUID currentParcelUUID = UUID.Zero; | 96 | public UUID currentParcelUUID = UUID.Zero; |
95 | 97 | ||
@@ -113,7 +115,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
113 | public Vector3 lastKnownAllowedPosition; | 115 | public Vector3 lastKnownAllowedPosition; |
114 | public bool sentMessageAboutRestrictedParcelFlyingDown; | 116 | public bool sentMessageAboutRestrictedParcelFlyingDown; |
115 | public Vector4 CollisionPlane = Vector4.UnitW; | 117 | public Vector4 CollisionPlane = Vector4.UnitW; |
116 | 118 | ||
119 | private Vector3 m_avInitialPos; // used to calculate unscripted sit rotation | ||
120 | private Vector3 m_avUnscriptedSitPos; // for non-scripted prims | ||
117 | private Vector3 m_lastPosition; | 121 | private Vector3 m_lastPosition; |
118 | private Quaternion m_lastRotation; | 122 | private Quaternion m_lastRotation; |
119 | private Vector3 m_lastVelocity; | 123 | private Vector3 m_lastVelocity; |
@@ -144,7 +148,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
144 | private int m_perfMonMS; | 148 | private int m_perfMonMS; |
145 | 149 | ||
146 | private bool m_setAlwaysRun; | 150 | private bool m_setAlwaysRun; |
147 | |||
148 | private bool m_forceFly; | 151 | private bool m_forceFly; |
149 | private bool m_flyDisabled; | 152 | private bool m_flyDisabled; |
150 | 153 | ||
@@ -168,7 +171,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
168 | protected RegionInfo m_regionInfo; | 171 | protected RegionInfo m_regionInfo; |
169 | protected ulong crossingFromRegion; | 172 | protected ulong crossingFromRegion; |
170 | 173 | ||
171 | private readonly Vector3[] Dir_Vectors = new Vector3[6]; | 174 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; |
175 | private bool m_isNudging = false; | ||
172 | 176 | ||
173 | // Position of agent's camera in world (region cordinates) | 177 | // Position of agent's camera in world (region cordinates) |
174 | protected Vector3 m_CameraCenter; | 178 | protected Vector3 m_CameraCenter; |
@@ -203,6 +207,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
203 | private bool m_followCamAuto; | 207 | private bool m_followCamAuto; |
204 | 208 | ||
205 | private int m_movementUpdateCount; | 209 | private int m_movementUpdateCount; |
210 | private int m_lastColCount = -1; //KF: Look for Collision chnages | ||
211 | private int m_updateCount = 0; //KF: Update Anims for a while | ||
212 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | ||
206 | 213 | ||
207 | private const int NumMovementsBetweenRayCast = 5; | 214 | private const int NumMovementsBetweenRayCast = 5; |
208 | 215 | ||
@@ -232,6 +239,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
232 | DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, | 239 | DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, |
233 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, | 240 | DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, |
234 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | 241 | DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, |
242 | DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS, | ||
243 | DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, | ||
244 | DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, | ||
245 | DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, | ||
235 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 246 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG |
236 | } | 247 | } |
237 | 248 | ||
@@ -658,9 +669,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
658 | 669 | ||
659 | AdjustKnownSeeds(); | 670 | AdjustKnownSeeds(); |
660 | 671 | ||
661 | // TODO: I think, this won't send anything, as we are still a child here... | 672 | Animator.TrySetMovementAnimation("STAND"); |
662 | Animator.TrySetMovementAnimation("STAND"); | ||
663 | |||
664 | // we created a new ScenePresence (a new child agent) in a fresh region. | 673 | // we created a new ScenePresence (a new child agent) in a fresh region. |
665 | // Request info about all the (root) agents in this region | 674 | // Request info about all the (root) agents in this region |
666 | // Note: This won't send data *to* other clients in that region (children don't send) | 675 | // Note: This won't send data *to* other clients in that region (children don't send) |
@@ -716,21 +725,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
716 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT | 725 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT |
717 | Dir_Vectors[4] = Vector3.UnitZ; //UP | 726 | Dir_Vectors[4] = Vector3.UnitZ; //UP |
718 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN | 727 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN |
719 | Dir_Vectors[5] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | 728 | Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE |
729 | Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE | ||
730 | Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE | ||
731 | Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE | ||
732 | Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | ||
720 | } | 733 | } |
721 | 734 | ||
722 | private Vector3[] GetWalkDirectionVectors() | 735 | private Vector3[] GetWalkDirectionVectors() |
723 | { | 736 | { |
724 | Vector3[] vector = new Vector3[6]; | 737 | Vector3[] vector = new Vector3[11]; |
725 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD | 738 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD |
726 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK | 739 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK |
727 | vector[2] = Vector3.UnitY; //LEFT | 740 | vector[2] = Vector3.UnitY; //LEFT |
728 | vector[3] = -Vector3.UnitY; //RIGHT | 741 | vector[3] = -Vector3.UnitY; //RIGHT |
729 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP | 742 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP |
730 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN | 743 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN |
731 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge | 744 | vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE |
745 | vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE | ||
746 | vector[8] = Vector3.UnitY; //LEFT_NUDGE | ||
747 | vector[9] = -Vector3.UnitY; //RIGHT_NUDGE | ||
748 | vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE | ||
732 | return vector; | 749 | return vector; |
733 | } | 750 | } |
751 | |||
752 | private bool[] GetDirectionIsNudge() | ||
753 | { | ||
754 | bool[] isNudge = new bool[11]; | ||
755 | isNudge[0] = false; //FORWARD | ||
756 | isNudge[1] = false; //BACK | ||
757 | isNudge[2] = false; //LEFT | ||
758 | isNudge[3] = false; //RIGHT | ||
759 | isNudge[4] = false; //UP | ||
760 | isNudge[5] = false; //DOWN | ||
761 | isNudge[6] = true; //FORWARD_NUDGE | ||
762 | isNudge[7] = true; //BACK_NUDGE | ||
763 | isNudge[8] = true; //LEFT_NUDGE | ||
764 | isNudge[9] = true; //RIGHT_NUDGE | ||
765 | isNudge[10] = true; //DOWN_Nudge | ||
766 | return isNudge; | ||
767 | } | ||
768 | |||
734 | 769 | ||
735 | #endregion | 770 | #endregion |
736 | 771 | ||
@@ -1018,7 +1053,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1018 | { | 1053 | { |
1019 | AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f)); | 1054 | AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f)); |
1020 | } | 1055 | } |
1021 | 1056 | ||
1057 | m_updateCount = UPDATE_COUNT; //KF: Trigger Anim updates to catch falling anim. | ||
1058 | |||
1022 | ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, | 1059 | ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, |
1023 | AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient))); | 1060 | AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient))); |
1024 | } | 1061 | } |
@@ -1253,7 +1290,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1253 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); | 1290 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); |
1254 | } | 1291 | } |
1255 | } | 1292 | } |
1256 | |||
1257 | lock (scriptedcontrols) | 1293 | lock (scriptedcontrols) |
1258 | { | 1294 | { |
1259 | if (scriptedcontrols.Count > 0) | 1295 | if (scriptedcontrols.Count > 0) |
@@ -1268,9 +1304,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1268 | 1304 | ||
1269 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1305 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1270 | { | 1306 | { |
1271 | // TODO: This doesn't prevent the user from walking yet. | 1307 | m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick. |
1272 | // Setting parent ID would fix this, if we knew what value | ||
1273 | // to use. Or we could add a m_isSitting variable. | ||
1274 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | 1308 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); |
1275 | } | 1309 | } |
1276 | 1310 | ||
@@ -1285,7 +1319,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1285 | { | 1319 | { |
1286 | return; | 1320 | return; |
1287 | } | 1321 | } |
1288 | |||
1289 | if (m_allowMovement) | 1322 | if (m_allowMovement) |
1290 | { | 1323 | { |
1291 | int i = 0; | 1324 | int i = 0; |
@@ -1313,6 +1346,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1313 | update_rotation = true; | 1346 | update_rotation = true; |
1314 | } | 1347 | } |
1315 | 1348 | ||
1349 | //guilty until proven innocent.. | ||
1350 | bool Nudging = true; | ||
1351 | //Basically, if there is at least one non-nudge control then we don't need | ||
1352 | //to worry about stopping the avatar | ||
1353 | |||
1316 | if (m_parentID == 0) | 1354 | if (m_parentID == 0) |
1317 | { | 1355 | { |
1318 | bool bAllowUpdateMoveToPosition = false; | 1356 | bool bAllowUpdateMoveToPosition = false; |
@@ -1327,6 +1365,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1327 | else | 1365 | else |
1328 | dirVectors = Dir_Vectors; | 1366 | dirVectors = Dir_Vectors; |
1329 | 1367 | ||
1368 | bool[] isNudge = GetDirectionIsNudge(); | ||
1369 | |||
1370 | |||
1371 | |||
1372 | |||
1373 | |||
1330 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | 1374 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) |
1331 | { | 1375 | { |
1332 | if (((uint)flags & (uint)DCF) != 0) | 1376 | if (((uint)flags & (uint)DCF) != 0) |
@@ -1336,6 +1380,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1336 | try | 1380 | try |
1337 | { | 1381 | { |
1338 | agent_control_v3 += dirVectors[i]; | 1382 | agent_control_v3 += dirVectors[i]; |
1383 | if (isNudge[i] == false) | ||
1384 | { | ||
1385 | Nudging = false; | ||
1386 | } | ||
1339 | } | 1387 | } |
1340 | catch (IndexOutOfRangeException) | 1388 | catch (IndexOutOfRangeException) |
1341 | { | 1389 | { |
@@ -1397,6 +1445,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1397 | // Ignore z component of vector | 1445 | // Ignore z component of vector |
1398 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 1446 | Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
1399 | LocalVectorToTarget2D.Normalize(); | 1447 | LocalVectorToTarget2D.Normalize(); |
1448 | |||
1449 | //We're not nudging | ||
1450 | Nudging = false; | ||
1400 | agent_control_v3 += LocalVectorToTarget2D; | 1451 | agent_control_v3 += LocalVectorToTarget2D; |
1401 | 1452 | ||
1402 | // update avatar movement flags. the avatar coordinate system is as follows: | 1453 | // update avatar movement flags. the avatar coordinate system is as follows: |
@@ -1479,7 +1530,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1479 | // m_log.DebugFormat( | 1530 | // m_log.DebugFormat( |
1480 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); | 1531 | // "In {0} adding velocity to {1} of {2}", m_scene.RegionInfo.RegionName, Name, agent_control_v3); |
1481 | 1532 | ||
1482 | AddNewMovement(agent_control_v3, q); | 1533 | AddNewMovement(agent_control_v3, q, Nudging); |
1483 | 1534 | ||
1484 | if (update_movementflag) | 1535 | if (update_movementflag) |
1485 | Animator.UpdateMovementAnimations(); | 1536 | Animator.UpdateMovementAnimations(); |
@@ -1562,7 +1613,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1562 | Velocity = Vector3.Zero; | 1613 | Velocity = Vector3.Zero; |
1563 | SendFullUpdateToAllClients(); | 1614 | SendFullUpdateToAllClients(); |
1564 | 1615 | ||
1565 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1616 | HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); //KF ?? |
1566 | } | 1617 | } |
1567 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); | 1618 | //ControllingClient.SendSitResponse(m_requestedSitTargetID, m_requestedSitOffset, Quaternion.Identity, false, Vector3.Zero, Vector3.Zero, false); |
1568 | m_requestedSitTargetUUID = UUID.Zero; | 1619 | m_requestedSitTargetUUID = UUID.Zero; |
@@ -1600,21 +1651,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1600 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); | 1651 | SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID); |
1601 | if (part != null) | 1652 | if (part != null) |
1602 | { | 1653 | { |
1654 | part.TaskInventory.LockItemsForRead(true); | ||
1603 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 1655 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1604 | if (taskIDict != null) | 1656 | if (taskIDict != null) |
1605 | { | 1657 | { |
1606 | lock (taskIDict) | 1658 | foreach (UUID taskID in taskIDict.Keys) |
1607 | { | 1659 | { |
1608 | foreach (UUID taskID in taskIDict.Keys) | 1660 | UnRegisterControlEventsToScript(LocalId, taskID); |
1609 | { | 1661 | taskIDict[taskID].PermsMask &= ~( |
1610 | UnRegisterControlEventsToScript(LocalId, taskID); | 1662 | 2048 | //PERMISSION_CONTROL_CAMERA |
1611 | taskIDict[taskID].PermsMask &= ~( | 1663 | 4); // PERMISSION_TAKE_CONTROLS |
1612 | 2048 | //PERMISSION_CONTROL_CAMERA | ||
1613 | 4); // PERMISSION_TAKE_CONTROLS | ||
1614 | } | ||
1615 | } | 1664 | } |
1616 | |||
1617 | } | 1665 | } |
1666 | part.TaskInventory.LockItemsForRead(false); | ||
1618 | // Reset sit target. | 1667 | // Reset sit target. |
1619 | if (part.GetAvatarOnSitTarget() == UUID) | 1668 | if (part.GetAvatarOnSitTarget() == UUID) |
1620 | part.SetAvatarOnSitTarget(UUID.Zero); | 1669 | part.SetAvatarOnSitTarget(UUID.Zero); |
@@ -1627,9 +1676,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1627 | { | 1676 | { |
1628 | AddToPhysicalScene(false); | 1677 | AddToPhysicalScene(false); |
1629 | } | 1678 | } |
1630 | |||
1631 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); | 1679 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); |
1632 | m_parentPosition = Vector3.Zero; | 1680 | m_parentPosition = Vector3.Zero; |
1681 | //Console.WriteLine("Stand Pos {0}", m_pos); | ||
1633 | 1682 | ||
1634 | m_parentID = 0; | 1683 | m_parentID = 0; |
1635 | SendFullUpdateToAllClients(); | 1684 | SendFullUpdateToAllClients(); |
@@ -1675,7 +1724,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1675 | bool SitTargetisSet = | 1724 | bool SitTargetisSet = |
1676 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && | 1725 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 1f && |
1677 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); | 1726 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f)); |
1678 | 1727 | // this test is probably failing | |
1679 | if (SitTargetisSet && SitTargetUnOccupied) | 1728 | if (SitTargetisSet && SitTargetUnOccupied) |
1680 | { | 1729 | { |
1681 | //switch the target to this prim | 1730 | //switch the target to this prim |
@@ -1702,31 +1751,58 @@ namespace OpenSim.Region.Framework.Scenes | |||
1702 | { | 1751 | { |
1703 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | 1752 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client |
1704 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | 1753 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it |
1705 | 1754 | ||
1755 | // part is the prim to sit on | ||
1756 | // offset is the vector distance from that prim center to the click-spot | ||
1757 | // UUID is the UUID of the Avatar doing the clicking | ||
1758 | |||
1759 | m_avInitialPos = AbsolutePosition; // saved to calculate unscripted sit rotation | ||
1760 | |||
1706 | // Is a sit target available? | 1761 | // Is a sit target available? |
1707 | Vector3 avSitOffSet = part.SitTargetPosition; | 1762 | Vector3 avSitOffSet = part.SitTargetPosition; |
1708 | Quaternion avSitOrientation = part.SitTargetOrientation; | 1763 | Quaternion avSitOrientation = part.SitTargetOrientation; |
1709 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); | 1764 | UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); |
1710 | 1765 | ||
1711 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); | 1766 | bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); |
1712 | bool SitTargetisSet = | 1767 | // bool SitTargetisSet = |
1713 | (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && | 1768 | // (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && |
1714 | avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); | 1769 | // avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); |
1715 | 1770 | ||
1716 | if (SitTargetisSet && SitTargetUnOccupied) | 1771 | bool SitTargetisSet = ((Vector3.Zero != avSitOffSet) || (Quaternion.Identity != avSitOrientation)); |
1717 | { | 1772 | |
1718 | part.SetAvatarOnSitTarget(UUID); | 1773 | //Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + |
1719 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); | 1774 | // " TargSet=" + SitTargetisSet); |
1720 | sitOrientation = avSitOrientation; | 1775 | // Sit analysis rewritten by KF 091125 |
1721 | autopilot = false; | 1776 | if (SitTargetisSet) // scipted sit |
1722 | } | 1777 | { |
1778 | if (SitTargetUnOccupied) | ||
1779 | { | ||
1780 | part.SetAvatarOnSitTarget(UUID); // set that Av will be on it | ||
1781 | offset = new Vector3(avSitOffSet.X, avSitOffSet.Y, avSitOffSet.Z); // change ofset to the scripted one | ||
1782 | sitOrientation = avSitOrientation; // Change rotatione to the scripted one | ||
1783 | autopilot = false; // Jump direct to scripted llSitPos() | ||
1784 | } | ||
1785 | else return; | ||
1786 | } | ||
1787 | else // Not Scripted | ||
1788 | { | ||
1789 | if ( (Math.Abs(offset.X) > 0.5f) || (Math.Abs(offset.Y) > 0.5f) ) // large prim | ||
1790 | { | ||
1791 | Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
1792 | m_avUnscriptedSitPos = offset * partIRot; // sit where clicked | ||
1793 | pos = part.AbsolutePosition + (offset * partIRot); | ||
1794 | } | ||
1795 | else // small prim | ||
1796 | { | ||
1797 | if (SitTargetUnOccupied) | ||
1798 | { | ||
1799 | m_avUnscriptedSitPos = Vector3.Zero; // Sit on unoccupied small prim center | ||
1800 | pos = part.AbsolutePosition; | ||
1801 | } | ||
1802 | else return; // occupied small | ||
1803 | } // end large/small | ||
1804 | } // end Scripted/not | ||
1723 | 1805 | ||
1724 | pos = part.AbsolutePosition + offset; | ||
1725 | //if (Math.Abs(part.AbsolutePosition.Z - AbsolutePosition.Z) > 1) | ||
1726 | //{ | ||
1727 | // offset = pos; | ||
1728 | //autopilot = false; | ||
1729 | //} | ||
1730 | if (m_physicsActor != null) | 1806 | if (m_physicsActor != null) |
1731 | { | 1807 | { |
1732 | // If we're not using the client autopilot, we're immediately warping the avatar to the location | 1808 | // If we're not using the client autopilot, we're immediately warping the avatar to the location |
@@ -1734,17 +1810,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1734 | m_sitAvatarHeight = m_physicsActor.Size.Z; | 1810 | m_sitAvatarHeight = m_physicsActor.Size.Z; |
1735 | 1811 | ||
1736 | if (autopilot) | 1812 | if (autopilot) |
1737 | { | 1813 | { // its not a scripted sit |
1738 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) | 1814 | if (Util.GetDistanceTo(AbsolutePosition, pos) < 4.5) |
1739 | { | 1815 | { |
1740 | autopilot = false; | 1816 | autopilot = false; // close enough |
1741 | 1817 | ||
1742 | RemoveFromPhysicalScene(); | 1818 | RemoveFromPhysicalScene(); |
1743 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 1819 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, (m_sitAvatarHeight / 2.0f)); // Warp av to Prim |
1744 | } | 1820 | } // else the autopilot will get us close |
1745 | } | 1821 | } |
1746 | else | 1822 | else |
1747 | { | 1823 | { // its a scripted sit |
1748 | RemoveFromPhysicalScene(); | 1824 | RemoveFromPhysicalScene(); |
1749 | } | 1825 | } |
1750 | } | 1826 | } |
@@ -1847,29 +1923,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
1847 | { | 1923 | { |
1848 | if (part.GetAvatarOnSitTarget() == UUID) | 1924 | if (part.GetAvatarOnSitTarget() == UUID) |
1849 | { | 1925 | { |
1926 | // Scripted sit | ||
1850 | Vector3 sitTargetPos = part.SitTargetPosition; | 1927 | Vector3 sitTargetPos = part.SitTargetPosition; |
1851 | Quaternion sitTargetOrient = part.SitTargetOrientation; | 1928 | Quaternion sitTargetOrient = part.SitTargetOrientation; |
1852 | |||
1853 | //Quaternion vq = new Quaternion(sitTargetPos.X, sitTargetPos.Y+0.2f, sitTargetPos.Z+0.2f, 0); | ||
1854 | //Quaternion nq = new Quaternion(-sitTargetOrient.X, -sitTargetOrient.Y, -sitTargetOrient.Z, sitTargetOrient.w); | ||
1855 | |||
1856 | //Quaternion result = (sitTargetOrient * vq) * nq; | ||
1857 | |||
1858 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 1929 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
1859 | m_pos += SIT_TARGET_ADJUSTMENT; | 1930 | m_pos += SIT_TARGET_ADJUSTMENT; |
1860 | m_bodyRot = sitTargetOrient; | 1931 | m_bodyRot = sitTargetOrient; |
1861 | //Rotation = sitTargetOrient; | ||
1862 | m_parentPosition = part.AbsolutePosition; | 1932 | m_parentPosition = part.AbsolutePosition; |
1863 | |||
1864 | //SendTerseUpdateToAllClients(); | ||
1865 | } | 1933 | } |
1866 | else | 1934 | else |
1867 | { | 1935 | { |
1868 | m_pos -= part.AbsolutePosition; | 1936 | // Non-scripted sit by Kitto Flora 21Nov09 |
1937 | // Calculate angle of line from prim to Av | ||
1938 | Vector3 sitTargetPos= part.AbsolutePosition + m_avUnscriptedSitPos; | ||
1939 | float y_diff = (m_avInitialPos.Y - sitTargetPos.Y); | ||
1940 | float x_diff = ( m_avInitialPos.X - sitTargetPos.X); | ||
1941 | if(Math.Abs(x_diff) < 0.001f) x_diff = 0.001f; // avoid div by 0 | ||
1942 | if(Math.Abs(y_diff) < 0.001f) y_diff = 0.001f; // avoid pol flip at 0 | ||
1943 | float sit_angle = (float)Math.Atan2( (double)y_diff, (double)x_diff); | ||
1944 | Quaternion partIRot = Quaternion.Inverse(part.GetWorldRotation()); | ||
1945 | // NOTE: when sitting m_ pos and m_bodyRot are *relative* to the prim location/rotation, not 'World'. | ||
1946 | // Av sits at world euler <0,0, z>, translated by part rotation | ||
1947 | m_bodyRot = partIRot * Quaternion.CreateFromEulers(0f, 0f, sit_angle); // sit at 0,0,inv-click | ||
1869 | m_parentPosition = part.AbsolutePosition; | 1948 | m_parentPosition = part.AbsolutePosition; |
1870 | } | 1949 | if(m_avUnscriptedSitPos != Vector3.Zero) |
1871 | } | 1950 | { // sit where clicked on big prim |
1872 | else | 1951 | m_pos = m_avUnscriptedSitPos + (new Vector3(0.0f, 0f, 0.625f) * partIRot); |
1952 | } | ||
1953 | else | ||
1954 | { // sit at center of small prim | ||
1955 | m_pos = new Vector3(0f, 0f, 0.05f) + | ||
1956 | (new Vector3(0.0f, 0f, 0.625f) * partIRot) + | ||
1957 | (new Vector3(0.25f, 0f, 0.0f) * m_bodyRot); | ||
1958 | //Set up raytrace to find top surface of prim | ||
1959 | Vector3 size = part.Scale; | ||
1960 | float mag = 0.1f + (float)Math.Sqrt((size.X * size.X) + (size.Y * size.Y) + (size.Z * size.Z)); | ||
1961 | Vector3 start = part.AbsolutePosition + new Vector3(0f, 0f, mag); | ||
1962 | Vector3 down = new Vector3(0f, 0f, -1f); | ||
1963 | m_scene.PhysicsScene.RaycastWorld( | ||
1964 | start, // Vector3 position, | ||
1965 | down, // Vector3 direction, | ||
1966 | mag, // float length, | ||
1967 | SitAltitudeCallback); // retMethod | ||
1968 | } // end small/big | ||
1969 | } // end scripted/not | ||
1970 | } | ||
1971 | else // no Av | ||
1873 | { | 1972 | { |
1874 | return; | 1973 | return; |
1875 | } | 1974 | } |
@@ -1881,11 +1980,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1881 | 1980 | ||
1882 | Animator.TrySetMovementAnimation(sitAnimation); | 1981 | Animator.TrySetMovementAnimation(sitAnimation); |
1883 | SendFullUpdateToAllClients(); | 1982 | SendFullUpdateToAllClients(); |
1884 | // This may seem stupid, but Our Full updates don't send avatar rotation :P | ||
1885 | // So we're also sending a terse update (which has avatar rotation) | ||
1886 | // [Update] We do now. | ||
1887 | //SendTerseUpdateToAllClients(); | ||
1888 | } | 1983 | } |
1984 | |||
1985 | public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) | ||
1986 | { | ||
1987 | if(hitYN) | ||
1988 | { | ||
1989 | // m_pos = Av offset from prim center to make look like on center | ||
1990 | // m_parentPosition = Actual center pos of prim | ||
1991 | // collisionPoint = spot on prim where we want to sit | ||
1992 | SceneObjectPart part = m_scene.GetSceneObjectPart(localid); | ||
1993 | Vector3 offset = (collisionPoint - m_parentPosition) * Quaternion.Inverse(part.RotationOffset); | ||
1994 | m_pos += offset; | ||
1995 | // Console.WriteLine("m_pos={0}, offset={1} newsit={2}", m_pos, offset, newsit); | ||
1996 | } | ||
1997 | } | ||
1889 | 1998 | ||
1890 | /// <summary> | 1999 | /// <summary> |
1891 | /// Event handler for the 'Always run' setting on the client | 2000 | /// Event handler for the 'Always run' setting on the client |
@@ -1915,7 +2024,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1915 | /// </summary> | 2024 | /// </summary> |
1916 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 2025 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
1917 | /// <param name="rotation">The direction in which this avatar should now face. | 2026 | /// <param name="rotation">The direction in which this avatar should now face. |
1918 | public void AddNewMovement(Vector3 vec, Quaternion rotation) | 2027 | public void AddNewMovement(Vector3 vec, Quaternion rotation, bool Nudging) |
1919 | { | 2028 | { |
1920 | if (m_isChildAgent) | 2029 | if (m_isChildAgent) |
1921 | { | 2030 | { |
@@ -1989,8 +2098,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1989 | 2098 | ||
1990 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2099 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
1991 | m_forceToApply = direc; | 2100 | m_forceToApply = direc; |
1992 | 2101 | m_isNudging = Nudging; | |
1993 | m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); | 2102 | m_scene.StatsReporter.AddAgentTime(EnvironmentTickCount() - m_perfMonMS); |
1994 | } | 2103 | } |
1995 | 2104 | ||
1996 | #endregion | 2105 | #endregion |
@@ -2004,7 +2113,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2004 | const float POSITION_TOLERANCE = 0.05f; | 2113 | const float POSITION_TOLERANCE = 0.05f; |
2005 | //const int TIME_MS_TOLERANCE = 3000; | 2114 | //const int TIME_MS_TOLERANCE = 3000; |
2006 | 2115 | ||
2007 | SendPrimUpdates(); | 2116 | |
2008 | 2117 | ||
2009 | if (m_newCoarseLocations) | 2118 | if (m_newCoarseLocations) |
2010 | { | 2119 | { |
@@ -2040,6 +2149,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2040 | CheckForBorderCrossing(); | 2149 | CheckForBorderCrossing(); |
2041 | CheckForSignificantMovement(); // sends update to the modules. | 2150 | CheckForSignificantMovement(); // sends update to the modules. |
2042 | } | 2151 | } |
2152 | |||
2153 | //Sending prim updates AFTER the avatar terse updates are sent | ||
2154 | SendPrimUpdates(); | ||
2043 | } | 2155 | } |
2044 | 2156 | ||
2045 | #endregion | 2157 | #endregion |
@@ -2893,14 +3005,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2893 | { | 3005 | { |
2894 | if (m_forceToApply.HasValue) | 3006 | if (m_forceToApply.HasValue) |
2895 | { | 3007 | { |
2896 | Vector3 force = m_forceToApply.Value; | ||
2897 | 3008 | ||
3009 | Vector3 force = m_forceToApply.Value; | ||
2898 | m_updateflag = true; | 3010 | m_updateflag = true; |
2899 | // movementvector = force; | ||
2900 | Velocity = force; | 3011 | Velocity = force; |
2901 | 3012 | ||
2902 | m_forceToApply = null; | 3013 | m_forceToApply = null; |
2903 | } | 3014 | } |
3015 | else | ||
3016 | { | ||
3017 | if (m_isNudging) | ||
3018 | { | ||
3019 | Vector3 force = Vector3.Zero; | ||
3020 | |||
3021 | m_updateflag = true; | ||
3022 | Velocity = force; | ||
3023 | m_isNudging = false; | ||
3024 | m_updateCount = UPDATE_COUNT; //KF: Update anims to pickup "STAND" | ||
3025 | } | ||
3026 | } | ||
2904 | } | 3027 | } |
2905 | 3028 | ||
2906 | public override void SetText(string text, Vector3 color, double alpha) | 3029 | public override void SetText(string text, Vector3 color, double alpha) |
@@ -2950,19 +3073,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
2950 | // Event called by the physics plugin to tell the avatar about a collision. | 3073 | // Event called by the physics plugin to tell the avatar about a collision. |
2951 | private void PhysicsCollisionUpdate(EventArgs e) | 3074 | private void PhysicsCollisionUpdate(EventArgs e) |
2952 | { | 3075 | { |
3076 | if (m_updateCount > 0) //KF: Update Anims for a short period. Many Anim | ||
3077 | { // changes are very asynchronous. | ||
3078 | Animator.UpdateMovementAnimations(); | ||
3079 | m_updateCount--; | ||
3080 | } | ||
3081 | |||
2953 | if (e == null) | 3082 | if (e == null) |
2954 | return; | 3083 | return; |
2955 | 3084 | ||
2956 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | ||
2957 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( | 3085 | // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( |
2958 | // as of this comment the interval is set in AddToPhysicalScene | 3086 | // as of this comment the interval is set in AddToPhysicalScene |
2959 | Animator.UpdateMovementAnimations(); | 3087 | |
2960 | |||
2961 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3088 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
2962 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3089 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
2963 | 3090 | ||
2964 | CollisionPlane = Vector4.UnitW; | 3091 | CollisionPlane = Vector4.UnitW; |
2965 | 3092 | ||
3093 | if (m_lastColCount != coldata.Count) | ||
3094 | { | ||
3095 | m_updateCount = 10; | ||
3096 | m_lastColCount = coldata.Count; | ||
3097 | } | ||
3098 | |||
2966 | if (coldata.Count != 0) | 3099 | if (coldata.Count != 0) |
2967 | { | 3100 | { |
2968 | switch (Animator.CurrentMovementAnimation) | 3101 | switch (Animator.CurrentMovementAnimation) |
@@ -3609,4 +3742,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
3609 | } | 3742 | } |
3610 | } | 3743 | } |
3611 | } | 3744 | } |
3612 | } \ No newline at end of file | 3745 | } |