diff options
Diffstat (limited to 'OpenSim/Region/Framework')
45 files changed, 6480 insertions, 2354 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs b/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs index 0cc8fb6..e0aad2b 100644 --- a/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs +++ b/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs | |||
@@ -36,7 +36,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
36 | void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, | 36 | void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, |
37 | InventoryItemBase item); | 37 | InventoryItemBase item); |
38 | 38 | ||
39 | void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, | 39 | bool HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, |
40 | uint callbackID, string description, string name, sbyte invType, | 40 | uint callbackID, string description, string name, sbyte invType, |
41 | sbyte type, byte wearableType, uint nextOwnerMask); | 41 | sbyte type, byte wearableType, uint nextOwnerMask); |
42 | 42 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index d9901bd..3c1247f 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 System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using OpenMetaverse; | 31 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
@@ -89,7 +90,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
89 | /// <param name="addToInventory">If true then add object to user inventory</param> | 90 | /// <param name="addToInventory">If true then add object to user inventory</param> |
90 | /// <param name="append">Append to attachment point rather than replace.</param> | 91 | /// <param name="append">Append to attachment point rather than replace.</param> |
91 | /// <returns>true if the object was successfully attached, false otherwise</returns> | 92 | /// <returns>true if the object was successfully attached, false otherwise</returns> |
92 | bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool addToInventory, bool append); | 93 | bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool useAttachmentInfo, bool addToInventory, bool append); |
93 | 94 | ||
94 | /// <summary> | 95 | /// <summary> |
95 | /// Rez an attachment from user inventory and change inventory status to match. | 96 | /// Rez an attachment from user inventory and change inventory status to match. |
@@ -98,7 +99,11 @@ namespace OpenSim.Region.Framework.Interfaces | |||
98 | /// <param name="itemID"></param> | 99 | /// <param name="itemID"></param> |
99 | /// <param name="AttachmentPt"></param> | 100 | /// <param name="AttachmentPt"></param> |
100 | /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> | 101 | /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> |
101 | SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt); | 102 | ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt); |
103 | |||
104 | // Same as above, but also load script states from a separate doc | ||
105 | ISceneEntity RezSingleAttachmentFromInventory( | ||
106 | IScenePresence presence, UUID itemID, uint AttachmentPt, XmlDocument doc); | ||
102 | 107 | ||
103 | /// <summary> | 108 | /// <summary> |
104 | /// Rez multiple attachments from a user's inventory | 109 | /// Rez multiple attachments from a user's inventory |
@@ -130,7 +135,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
130 | /// <param name="grp">The attachment to detach.</param> | 135 | /// <param name="grp">The attachment to detach.</param> |
131 | void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup grp); | 136 | void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup grp); |
132 | 137 | ||
133 | /// <summary> | ||
134 | /// Update the position of an attachment. | 138 | /// Update the position of an attachment. |
135 | /// </summary> | 139 | /// </summary> |
136 | /// <param name="sog"></param> | 140 | /// <param name="sog"></param> |
diff --git a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs index 34aca33..d25c930 100644 --- a/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAvatarFactoryModule.cs | |||
@@ -35,8 +35,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
35 | 35 | ||
36 | public interface IAvatarFactoryModule | 36 | public interface IAvatarFactoryModule |
37 | { | 37 | { |
38 | void SetAppearance(IScenePresence sp, AvatarAppearance appearance); | 38 | void SetAppearance(IScenePresence sp, AvatarAppearance appearance, WearableCacheItem[] cacheItems); |
39 | void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams); | 39 | void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, WearableCacheItem[] cacheItems); |
40 | 40 | ||
41 | /// <summary> | 41 | /// <summary> |
42 | /// Send the appearance of an avatar to others in the scene. | 42 | /// Send the appearance of an avatar to others in the scene. |
@@ -52,6 +52,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
52 | /// <returns>An empty list if this agent has no baked textures (e.g. because it's a child agent)</returns> | 52 | /// <returns>An empty list if this agent has no baked textures (e.g. because it's a child agent)</returns> |
53 | Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId); | 53 | Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId); |
54 | 54 | ||
55 | |||
56 | WearableCacheItem[] GetCachedItems(UUID agentId); | ||
55 | /// <summary> | 57 | /// <summary> |
56 | /// Save the baked textures for the given agent permanently in the asset database. | 58 | /// Save the baked textures for the given agent permanently in the asset database. |
57 | /// </summary> | 59 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs new file mode 100644 index 0000000..21ed44f --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs | |||
@@ -0,0 +1,19 @@ | |||
1 | //////////////////////////////////////////////////////////////// | ||
2 | // | ||
3 | // (c) 2009, 2010 Careminster Limited and Melanie Thielker | ||
4 | // | ||
5 | // All rights reserved | ||
6 | // | ||
7 | using System; | ||
8 | using Nini.Config; | ||
9 | using OpenSim.Framework; | ||
10 | using OpenMetaverse; | ||
11 | |||
12 | namespace OpenSim.Services.Interfaces | ||
13 | { | ||
14 | public interface IBakedTextureModule | ||
15 | { | ||
16 | WearableCacheItem[] Get(UUID id); | ||
17 | void Store(UUID id, WearableCacheItem[] data); | ||
18 | } | ||
19 | } | ||
diff --git a/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs b/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs index 522c82d..30d404e 100644 --- a/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs | |||
@@ -40,19 +40,19 @@ namespace OpenSim.Region.Framework.Interfaces | |||
40 | /// </summary> | 40 | /// </summary> |
41 | /// <param name="agentId"></param> | 41 | /// <param name="agentId"></param> |
42 | /// <param name="capsObjectPath"></param> | 42 | /// <param name="capsObjectPath"></param> |
43 | void CreateCaps(UUID agentId); | 43 | void CreateCaps(UUID agentId, uint circuitCode); |
44 | 44 | ||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Remove the caps handler for a given agent. | 46 | /// Remove the caps handler for a given agent. |
47 | /// </summary> | 47 | /// </summary> |
48 | /// <param name="agentId"></param> | 48 | /// <param name="agentId"></param> |
49 | void RemoveCaps(UUID agentId); | 49 | void RemoveCaps(UUID agentId, uint circuitCode); |
50 | 50 | ||
51 | /// <summary> | 51 | /// <summary> |
52 | /// Will return null if the agent doesn't have a caps handler registered | 52 | /// Will return null if the agent doesn't have a caps handler registered |
53 | /// </summary> | 53 | /// </summary> |
54 | /// <param name="agentId"></param> | 54 | /// <param name="agentId"></param> |
55 | Caps GetCapsForUser(UUID agentId); | 55 | Caps GetCapsForUser(uint circuitCode); |
56 | 56 | ||
57 | void SetAgentCapsSeeds(AgentCircuitData agent); | 57 | void SetAgentCapsSeeds(AgentCircuitData agent); |
58 | 58 | ||
@@ -65,5 +65,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
65 | void DropChildSeed(UUID agentID, ulong handle); | 65 | void DropChildSeed(UUID agentID, ulong handle); |
66 | 66 | ||
67 | string GetCapsPath(UUID agentId); | 67 | string GetCapsPath(UUID agentId); |
68 | |||
69 | void ActivateCaps(uint circuitCode); | ||
68 | } | 70 | } |
69 | } | 71 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicFloaterModule.cs b/OpenSim/Region/Framework/Interfaces/IDynamicFloaterModule.cs new file mode 100644 index 0000000..7684ce3 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IDynamicFloaterModule.cs | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections.Generic; | ||
29 | using OpenMetaverse; | ||
30 | using OpenSim.Framework; | ||
31 | using OpenSim.Region.Framework.Scenes; | ||
32 | |||
33 | namespace OpenSim.Region.Framework.Interfaces | ||
34 | { | ||
35 | public delegate bool HandlerDelegate(IClientAPI client, FloaterData data, string[] msg); | ||
36 | |||
37 | public abstract class FloaterData | ||
38 | { | ||
39 | public abstract int Channel { get; } | ||
40 | public abstract string FloaterName { get; set; } | ||
41 | public virtual string XmlName { get; set; } | ||
42 | public virtual string XmlText { get; set; } | ||
43 | public virtual HandlerDelegate Handler { get; set; } | ||
44 | } | ||
45 | |||
46 | |||
47 | public interface IDynamicFloaterModule | ||
48 | { | ||
49 | void DoUserFloater(UUID agentID, FloaterData dialogData, string configuration); | ||
50 | void FloaterControl(ScenePresence sp, FloaterData d, string msg); | ||
51 | } | ||
52 | } | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs b/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs index 08b71e4..4d000b6 100644 --- a/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs | |||
@@ -43,6 +43,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
43 | public enum UserMode : int | 43 | public enum UserMode : int |
44 | { | 44 | { |
45 | Normal = 0, | 45 | Normal = 0, |
46 | RegionManager = 2, | ||
46 | God = 3 | 47 | God = 3 |
47 | } | 48 | } |
48 | 49 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 150193d..8028d87 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -133,6 +133,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
133 | /// </returns> | 133 | /// </returns> |
134 | bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); | 134 | bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); |
135 | 135 | ||
136 | ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); | ||
137 | |||
136 | /// <summary> | 138 | /// <summary> |
137 | /// Stop and remove a script which is in this prim's inventory from the scene. | 139 | /// Stop and remove a script which is in this prim's inventory from the scene. |
138 | /// </summary> | 140 | /// </summary> |
@@ -316,5 +318,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
316 | /// A <see cref="Dictionary`2"/> | 318 | /// A <see cref="Dictionary`2"/> |
317 | /// </returns> | 319 | /// </returns> |
318 | Dictionary<UUID, string> GetScriptStates(); | 320 | Dictionary<UUID, string> GetScriptStates(); |
321 | Dictionary<UUID, string> GetScriptStates(bool oldIDs); | ||
319 | } | 322 | } |
320 | } | 323 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs index 1c43a25..1949a90 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs | |||
@@ -35,6 +35,8 @@ using OpenSim.Region.Framework.Scenes; | |||
35 | 35 | ||
36 | namespace OpenSim.Region.Framework.Interfaces | 36 | namespace OpenSim.Region.Framework.Interfaces |
37 | { | 37 | { |
38 | public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version); | ||
39 | |||
38 | public interface IEntityTransferModule | 40 | public interface IEntityTransferModule |
39 | { | 41 | { |
40 | /// <summary> | 42 | /// <summary> |
@@ -50,30 +52,11 @@ namespace OpenSim.Region.Framework.Interfaces | |||
50 | /// <param name='teleportFlags'></param> | 52 | /// <param name='teleportFlags'></param> |
51 | void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags); | 53 | void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags); |
52 | 54 | ||
53 | /// <summary> | ||
54 | /// Teleport an agent directly to a given region without checking whether the region should be subsituted. | ||
55 | /// </summary> | ||
56 | /// <remarks> | ||
57 | /// Please use Teleport() instead unless you know exactly what you're doing. | ||
58 | /// Do not use for same region teleports. | ||
59 | /// </remarks> | ||
60 | /// <param name='sp'></param> | ||
61 | /// <param name='reg'></param> | ||
62 | /// <param name='finalDestination'>/param> | ||
63 | /// <param name='position'></param> | ||
64 | /// <param name='lookAt'></param> | ||
65 | /// <param name='teleportFlags'></param> | ||
66 | void DoTeleport( | ||
67 | ScenePresence sp, GridRegion reg, GridRegion finalDestination, | ||
68 | Vector3 position, Vector3 lookAt, uint teleportFlags); | ||
69 | |||
70 | /// <summary> | ||
71 | /// Teleports the agent for the given client to their home destination. | ||
72 | /// </summary> | ||
73 | /// <param name='id'></param> | ||
74 | /// <param name='client'></param> | ||
75 | bool TeleportHome(UUID id, IClientAPI client); | 55 | bool TeleportHome(UUID id, IClientAPI client); |
76 | 56 | ||
57 | void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, | ||
58 | Vector3 position, Vector3 lookAt, uint teleportFlags); | ||
59 | |||
77 | /// <summary> | 60 | /// <summary> |
78 | /// Show whether the given agent is being teleported. | 61 | /// Show whether the given agent is being teleported. |
79 | /// </summary> | 62 | /// </summary> |
@@ -89,7 +72,12 @@ namespace OpenSim.Region.Framework.Interfaces | |||
89 | 72 | ||
90 | void EnableChildAgent(ScenePresence agent, GridRegion region); | 73 | void EnableChildAgent(ScenePresence agent, GridRegion region); |
91 | 74 | ||
75 | GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out uint xDest, out uint yDest, out string version, out Vector3 newpos); | ||
76 | |||
92 | void Cross(SceneObjectGroup sog, Vector3 position, bool silent); | 77 | void Cross(SceneObjectGroup sog, Vector3 position, bool silent); |
78 | |||
79 | ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version); | ||
80 | |||
93 | } | 81 | } |
94 | 82 | ||
95 | public interface IUserAgentVerificationModule | 83 | public interface IUserAgentVerificationModule |
diff --git a/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs b/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs index 113dcd7..eb6c5ac 100644 --- a/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs +++ b/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs | |||
@@ -45,13 +45,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
45 | { | 45 | { |
46 | UUID MakeHttpRequest(string url, string parameters, string body); | 46 | UUID MakeHttpRequest(string url, string parameters, string body); |
47 | UUID StartHttpRequest(uint localID, UUID itemID, string url, List<string> parameters, Dictionary<string, string> headers, string body); | 47 | UUID StartHttpRequest(uint localID, UUID itemID, string url, List<string> parameters, Dictionary<string, string> headers, string body); |
48 | 48 | void StopHttpRequest(uint m_localID, UUID m_itemID); | |
49 | /// <summary> | ||
50 | /// Stop and remove all http requests for the given script. | ||
51 | /// </summary> | ||
52 | /// <param name='id'></param> | ||
53 | void StopHttpRequestsForScript(UUID id); | ||
54 | |||
55 | IServiceRequest GetNextCompletedRequest(); | 49 | IServiceRequest GetNextCompletedRequest(); |
56 | void RemoveCompletedRequest(UUID id); | 50 | void RemoveCompletedRequest(UUID id); |
57 | } | 51 | } |
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/IRegionConsole.cs b/OpenSim/Region/Framework/Interfaces/IRegionConsole.cs index 4d261d6..5d5ce34 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionConsole.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionConsole.cs | |||
@@ -30,8 +30,12 @@ using OpenSim.Framework; | |||
30 | 30 | ||
31 | namespace OpenSim.Region.Framework.Interfaces | 31 | namespace OpenSim.Region.Framework.Interfaces |
32 | { | 32 | { |
33 | public delegate void ConsoleMessage(UUID toAgentID, string message); | ||
34 | |||
33 | public interface IRegionConsole | 35 | public interface IRegionConsole |
34 | { | 36 | { |
37 | event ConsoleMessage OnConsoleMessage; | ||
38 | |||
35 | bool RunCommand(string command, UUID invokerID); | 39 | bool RunCommand(string command, UUID invokerID); |
36 | void SendConsoleOutput(UUID agentID, string message); | 40 | void SendConsoleOutput(UUID agentID, string message); |
37 | void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn); | 41 | void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn); |
diff --git a/OpenSim/Region/Framework/Interfaces/IRestartModule.cs b/OpenSim/Region/Framework/Interfaces/IRestartModule.cs index c68550f..9b25beb 100644 --- a/OpenSim/Region/Framework/Interfaces/IRestartModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRestartModule.cs | |||
@@ -35,5 +35,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
35 | TimeSpan TimeUntilRestart { get; } | 35 | TimeSpan TimeUntilRestart { get; } |
36 | void ScheduleRestart(UUID initiator, string message, int[] alerts, bool notice); | 36 | void ScheduleRestart(UUID initiator, string message, int[] alerts, bool notice); |
37 | void AbortRestart(string message); | 37 | void AbortRestart(string message); |
38 | void DelayRestart(int seconds, string message); | ||
38 | } | 39 | } |
39 | } | 40 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/ISearchModule.cs b/OpenSim/Region/Framework/Interfaces/ISearchModule.cs index 64bf72c..d56d188 100644 --- a/OpenSim/Region/Framework/Interfaces/ISearchModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISearchModule.cs | |||
@@ -31,6 +31,6 @@ namespace OpenSim.Framework | |||
31 | { | 31 | { |
32 | public interface ISearchModule | 32 | public interface ISearchModule |
33 | { | 33 | { |
34 | 34 | void Refresh(); | |
35 | } | 35 | } |
36 | } | 36 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs index 085b5ca..3e97a7a 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs | |||
@@ -116,6 +116,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
116 | /// <param name="regionUUID">the region UUID</param> | 116 | /// <param name="regionUUID">the region UUID</param> |
117 | void RemoveRegionEnvironmentSettings(UUID regionUUID); | 117 | void RemoveRegionEnvironmentSettings(UUID regionUUID); |
118 | 118 | ||
119 | UUID[] GetObjectIDs(UUID regionID); | ||
120 | |||
119 | void SaveExtra(UUID regionID, string name, string value); | 121 | void SaveExtra(UUID regionID, string name, string value); |
120 | 122 | ||
121 | void RemoveExtra(UUID regionID, string name); | 123 | void RemoveExtra(UUID regionID, string name); |
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs index 3787ca0..17bd48b 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs | |||
@@ -106,6 +106,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
106 | RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID); | 106 | RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID); |
107 | void StoreRegionWindlightSettings(RegionLightShareData wl); | 107 | void StoreRegionWindlightSettings(RegionLightShareData wl); |
108 | void RemoveRegionWindlightSettings(UUID regionID); | 108 | void RemoveRegionWindlightSettings(UUID regionID); |
109 | UUID[] GetObjectIDs(UUID regionID); | ||
109 | 110 | ||
110 | /// <summary> | 111 | /// <summary> |
111 | /// Load Environment settings from region storage | 112 | /// Load Environment settings from region storage |
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/Interfaces/IUserAccountCacheModule.cs b/OpenSim/Region/Framework/Interfaces/IUserAccountCacheModule.cs new file mode 100644 index 0000000..d1a4d8e --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IUserAccountCacheModule.cs | |||
@@ -0,0 +1,13 @@ | |||
1 | /////////////////////////////////////////////////////////////////// | ||
2 | // | ||
3 | // (c) Careminster Limited, Melanie Thielker and the Meta7 Team | ||
4 | // | ||
5 | // This file is not open source. All rights reserved | ||
6 | // | ||
7 | |||
8 | using OpenSim.Region.Framework.Scenes; | ||
9 | |||
10 | public interface IUserAccountCacheModule | ||
11 | { | ||
12 | void Remove(string name); | ||
13 | } | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index d76a0d7..20e0199 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs | |||
@@ -127,7 +127,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
127 | /// <param name='msg'> | 127 | /// <param name='msg'> |
128 | /// Message. | 128 | /// Message. |
129 | /// </param> | 129 | /// </param> |
130 | void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg); | 130 | bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error); |
131 | 131 | ||
132 | /// <summary> | 132 | /// <summary> |
133 | /// Are there any listen events ready to be dispatched? | 133 | /// Are there any listen events ready to be dispatched? |
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index a701a79..eb70eee 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -80,12 +80,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
80 | m_scenePresence = sp; | 80 | m_scenePresence = sp; |
81 | CurrentMovementAnimation = "CROUCH"; | 81 | CurrentMovementAnimation = "CROUCH"; |
82 | } | 82 | } |
83 | 83 | ||
84 | public void AddAnimation(UUID animID, UUID objectID) | 84 | public void AddAnimation(UUID animID, UUID objectID) |
85 | { | 85 | { |
86 | if (m_scenePresence.IsChildAgent) | 86 | if (m_scenePresence.IsChildAgent) |
87 | return; | 87 | return; |
88 | 88 | ||
89 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); | ||
89 | if (m_scenePresence.Scene.DebugAnimations) | 90 | if (m_scenePresence.Scene.DebugAnimations) |
90 | m_log.DebugFormat( | 91 | m_log.DebugFormat( |
91 | "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", | 92 | "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", |
@@ -138,6 +139,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
138 | } | 139 | } |
139 | } | 140 | } |
140 | 141 | ||
142 | public void avnChangeAnim(UUID animID, bool addRemove, bool sendPack) | ||
143 | { | ||
144 | if (m_scenePresence.IsChildAgent) | ||
145 | return; | ||
146 | |||
147 | if (animID != UUID.Zero) | ||
148 | { | ||
149 | if (addRemove) | ||
150 | m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero); | ||
151 | else | ||
152 | m_animations.Remove(animID, true); | ||
153 | } | ||
154 | if(sendPack) | ||
155 | SendAnimPack(); | ||
156 | } | ||
157 | |||
141 | // Called from scripts | 158 | // Called from scripts |
142 | public void RemoveAnimation(string name) | 159 | public void RemoveAnimation(string name) |
143 | { | 160 | { |
diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs new file mode 100644 index 0000000..075724e --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs | |||
@@ -0,0 +1,304 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | // Ubit 2012 | ||
28 | |||
29 | using System; | ||
30 | using System.Reflection; | ||
31 | using System.Collections.Generic; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using log4net; | ||
35 | |||
36 | namespace OpenSim.Region.Framework.Scenes | ||
37 | { | ||
38 | public struct CollisionForSoundInfo | ||
39 | { | ||
40 | public uint colliderID; | ||
41 | public Vector3 position; | ||
42 | public float relativeVel; | ||
43 | } | ||
44 | |||
45 | public static class CollisionSounds | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | private const int MaxMaterials = 7; | ||
50 | // part part | ||
51 | |||
52 | private static UUID snd_StoneStone = new UUID("be7295c0-a158-11e1-b3dd-0800200c9a66"); | ||
53 | private static UUID snd_StoneMetal = new UUID("be7295c0-a158-11e1-b3dd-0800201c9a66"); | ||
54 | private static UUID snd_StoneGlass = new UUID("be7295c0-a158-11e1-b3dd-0800202c9a66"); | ||
55 | private static UUID snd_StoneWood = new UUID("be7295c0-a158-11e1-b3dd-0800203c9a66"); | ||
56 | private static UUID snd_StoneFlesh = new UUID("be7295c0-a158-11e1-b3dd-0800204c9a66"); | ||
57 | private static UUID snd_StonePlastic = new UUID("be7295c0-a158-11e1-b3dd-0800205c9a66"); | ||
58 | private static UUID snd_StoneRubber = new UUID("be7295c0-a158-11e1-b3dd-0800206c9a66"); | ||
59 | |||
60 | private static UUID snd_MetalMetal = new UUID("be7295c0-a158-11e1-b3dd-0801201c9a66"); | ||
61 | private static UUID snd_MetalGlass = new UUID("be7295c0-a158-11e1-b3dd-0801202c9a66"); | ||
62 | private static UUID snd_MetalWood = new UUID("be7295c0-a158-11e1-b3dd-0801203c9a66"); | ||
63 | private static UUID snd_MetalFlesh = new UUID("be7295c0-a158-11e1-b3dd-0801204c9a66"); | ||
64 | private static UUID snd_MetalPlastic = new UUID("be7295c0-a158-11e1-b3dd-0801205c9a66"); | ||
65 | private static UUID snd_MetalRubber = new UUID("be7295c0-a158-11e1-b3dd-0801206c9a66"); | ||
66 | |||
67 | private static UUID snd_GlassGlass = new UUID("be7295c0-a158-11e1-b3dd-0802202c9a66"); | ||
68 | private static UUID snd_GlassWood = new UUID("be7295c0-a158-11e1-b3dd-0802203c9a66"); | ||
69 | private static UUID snd_GlassFlesh = new UUID("be7295c0-a158-11e1-b3dd-0802204c9a66"); | ||
70 | private static UUID snd_GlassPlastic = new UUID("be7295c0-a158-11e1-b3dd-0802205c9a66"); | ||
71 | private static UUID snd_GlassRubber = new UUID("be7295c0-a158-11e1-b3dd-0802206c9a66"); | ||
72 | |||
73 | private static UUID snd_WoodWood = new UUID("be7295c0-a158-11e1-b3dd-0803203c9a66"); | ||
74 | private static UUID snd_WoodFlesh = new UUID("be7295c0-a158-11e1-b3dd-0803204c9a66"); | ||
75 | private static UUID snd_WoodPlastic = new UUID("be7295c0-a158-11e1-b3dd-0803205c9a66"); | ||
76 | private static UUID snd_WoodRubber = new UUID("be7295c0-a158-11e1-b3dd-0803206c9a66"); | ||
77 | |||
78 | private static UUID snd_FleshFlesh = new UUID("be7295c0-a158-11e1-b3dd-0804204c9a66"); | ||
79 | private static UUID snd_FleshPlastic = new UUID("be7295c0-a158-11e1-b3dd-0804205c9a66"); | ||
80 | private static UUID snd_FleshRubber = new UUID("be7295c0-a158-11e1-b3dd-0804206c9a66"); | ||
81 | |||
82 | private static UUID snd_PlasticPlastic = new UUID("be7295c0-a158-11e1-b3dd-0805205c9a66"); | ||
83 | private static UUID snd_PlasticRubber = new UUID("be7295c0-a158-11e1-b3dd-0805206c9a66"); | ||
84 | |||
85 | private static UUID snd_RubberRubber = new UUID("be7295c0-a158-11e1-b3dd-0806206c9a66"); | ||
86 | |||
87 | // terrain part | ||
88 | private static UUID snd_TerrainStone = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
89 | private static UUID snd_TerrainMetal = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
90 | private static UUID snd_TerrainGlass = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
91 | private static UUID snd_TerrainWood = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
92 | private static UUID snd_TerrainFlesh = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
93 | private static UUID snd_TerrainPlastic = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
94 | private static UUID snd_TerrainRubber = new UUID("be7295c0-a158-11e1-b3dd-0807200c9a66"); | ||
95 | |||
96 | public static UUID[] m_TerrainPart = { | ||
97 | snd_TerrainStone, | ||
98 | snd_TerrainMetal, | ||
99 | snd_TerrainGlass, | ||
100 | snd_TerrainWood, | ||
101 | snd_TerrainFlesh, | ||
102 | snd_TerrainPlastic, | ||
103 | snd_TerrainRubber | ||
104 | }; | ||
105 | |||
106 | // simetric sounds | ||
107 | public static UUID[] m_PartPart = { | ||
108 | snd_StoneStone, snd_StoneMetal, snd_StoneGlass, snd_StoneWood, snd_StoneFlesh, snd_StonePlastic, snd_StoneRubber, | ||
109 | snd_StoneMetal, snd_MetalMetal, snd_MetalGlass, snd_MetalWood, snd_MetalFlesh, snd_MetalPlastic, snd_MetalRubber, | ||
110 | snd_StoneGlass, snd_MetalGlass, snd_GlassGlass, snd_GlassWood, snd_GlassFlesh, snd_GlassPlastic, snd_GlassRubber, | ||
111 | snd_StoneWood, snd_MetalWood, snd_GlassWood, snd_WoodWood, snd_WoodFlesh, snd_WoodPlastic, snd_WoodRubber, | ||
112 | snd_StoneFlesh, snd_MetalFlesh, snd_GlassFlesh, snd_WoodFlesh, snd_FleshFlesh, snd_FleshPlastic, snd_FleshRubber, | ||
113 | snd_StonePlastic, snd_MetalPlastic, snd_GlassPlastic, snd_WoodPlastic, snd_FleshPlastic, snd_PlasticPlastic, snd_PlasticRubber, | ||
114 | snd_StoneRubber, snd_MetalRubber, snd_GlassRubber, snd_WoodRubber, snd_FleshRubber, snd_PlasticRubber, snd_RubberRubber | ||
115 | }; | ||
116 | |||
117 | public static void PartCollisionSound(SceneObjectPart part, List<CollisionForSoundInfo> collidersinfolist) | ||
118 | { | ||
119 | if (collidersinfolist.Count == 0 || part == null) | ||
120 | return; | ||
121 | |||
122 | if (part.VolumeDetectActive || (part.Flags & PrimFlags.Physics) == 0) | ||
123 | return; | ||
124 | |||
125 | if (part.ParentGroup == null) | ||
126 | return; | ||
127 | |||
128 | if (part.CollisionSoundType < 0) | ||
129 | return; | ||
130 | |||
131 | float volume = 0.0f; | ||
132 | bool HaveSound = false; | ||
133 | |||
134 | UUID soundID = part.CollisionSound; | ||
135 | |||
136 | if (part.CollisionSoundType > 0) | ||
137 | { | ||
138 | // soundID = part.CollisionSound; | ||
139 | volume = part.CollisionSoundVolume; | ||
140 | if (volume == 0.0f) | ||
141 | return; | ||
142 | HaveSound = true; | ||
143 | } | ||
144 | |||
145 | bool doneownsound = false; | ||
146 | |||
147 | int thisMaterial = (int)part.Material; | ||
148 | if (thisMaterial >= MaxMaterials) | ||
149 | thisMaterial = 3; | ||
150 | int thisMatScaled = thisMaterial * MaxMaterials; | ||
151 | |||
152 | CollisionForSoundInfo colInfo; | ||
153 | uint id; | ||
154 | |||
155 | for(int i = 0; i< collidersinfolist.Count; i++) | ||
156 | { | ||
157 | colInfo = collidersinfolist[i]; | ||
158 | |||
159 | id = colInfo.colliderID; | ||
160 | if (id == 0) // terrain collision | ||
161 | { | ||
162 | if (!doneownsound) | ||
163 | { | ||
164 | if (!HaveSound) | ||
165 | { | ||
166 | volume = Math.Abs(colInfo.relativeVel); | ||
167 | if (volume < 0.2f) | ||
168 | continue; | ||
169 | |||
170 | volume *= volume * .0625f; // 4m/s == full volume | ||
171 | if (volume > 1.0f) | ||
172 | volume = 1.0f; | ||
173 | |||
174 | soundID = m_TerrainPart[thisMaterial]; | ||
175 | } | ||
176 | part.SendCollisionSound(soundID, volume, colInfo.position); | ||
177 | doneownsound = true; | ||
178 | } | ||
179 | continue; | ||
180 | } | ||
181 | |||
182 | SceneObjectPart otherPart = part.ParentGroup.Scene.GetSceneObjectPart(id); | ||
183 | if (otherPart != null) | ||
184 | { | ||
185 | if (otherPart.CollisionSoundType < 0 || otherPart.VolumeDetectActive) | ||
186 | continue; | ||
187 | |||
188 | if (!HaveSound) | ||
189 | { | ||
190 | if (otherPart.CollisionSoundType > 0) | ||
191 | { | ||
192 | soundID = otherPart.CollisionSound; | ||
193 | volume = otherPart.CollisionSoundVolume; | ||
194 | if (volume == 0.0f) | ||
195 | continue; | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | volume = Math.Abs(colInfo.relativeVel); | ||
200 | if (volume < 0.2f) | ||
201 | continue; | ||
202 | |||
203 | volume *= volume * .0625f; // 4m/s == full volume | ||
204 | if (volume > 1.0f) | ||
205 | volume = 1.0f; | ||
206 | |||
207 | int otherMaterial = (int)otherPart.Material; | ||
208 | if (otherMaterial >= MaxMaterials) | ||
209 | otherMaterial = 3; | ||
210 | |||
211 | soundID = m_PartPart[thisMatScaled + otherMaterial]; | ||
212 | } | ||
213 | } | ||
214 | |||
215 | if (doneownsound) | ||
216 | otherPart.SendCollisionSound(soundID, volume, colInfo.position); | ||
217 | else | ||
218 | { | ||
219 | part.SendCollisionSound(soundID, volume, colInfo.position); | ||
220 | doneownsound = true; | ||
221 | } | ||
222 | } | ||
223 | } | ||
224 | } | ||
225 | |||
226 | public static void AvatarCollisionSound(ScenePresence av, List<CollisionForSoundInfo> collidersinfolist) | ||
227 | { | ||
228 | if (collidersinfolist.Count == 0 || av == null) | ||
229 | return; | ||
230 | |||
231 | UUID soundID; | ||
232 | int otherMaterial; | ||
233 | |||
234 | int thisMaterial = 4; // flesh | ||
235 | |||
236 | int thisMatScaled = thisMaterial * MaxMaterials; | ||
237 | |||
238 | // bool doneownsound = false; | ||
239 | |||
240 | CollisionForSoundInfo colInfo; | ||
241 | uint id; | ||
242 | float volume; | ||
243 | |||
244 | for(int i = 0; i< collidersinfolist.Count; i++) | ||
245 | { | ||
246 | colInfo = collidersinfolist[i]; | ||
247 | |||
248 | id = colInfo.colliderID; | ||
249 | |||
250 | if (id == 0) // no terrain collision sounds for now | ||
251 | { | ||
252 | continue; | ||
253 | // volume = Math.Abs(colInfo.relativeVel); | ||
254 | // if (volume < 0.2f) | ||
255 | // continue; | ||
256 | |||
257 | } | ||
258 | |||
259 | SceneObjectPart otherPart = av.Scene.GetSceneObjectPart(id); | ||
260 | if (otherPart != null) | ||
261 | { | ||
262 | if (otherPart.CollisionSoundType < 0) | ||
263 | continue; | ||
264 | if (otherPart.CollisionSoundType > 0 && otherPart.CollisionSoundVolume > 0f) | ||
265 | otherPart.SendCollisionSound(otherPart.CollisionSound, otherPart.CollisionSoundVolume, colInfo.position); | ||
266 | else | ||
267 | { | ||
268 | volume = Math.Abs(colInfo.relativeVel); | ||
269 | // Most noral collisions (running into walls, stairs) | ||
270 | // should never be heard. | ||
271 | if (volume < 3.2f) | ||
272 | continue; | ||
273 | // m_log.DebugFormat("Collision speed was {0}", volume); | ||
274 | |||
275 | // Cap to 0.2 times volume because climbing stairs should not be noisy | ||
276 | // Also changed scaling | ||
277 | volume *= volume * .0125f; // 4m/s == volume 0.2 | ||
278 | if (volume > 0.2f) | ||
279 | volume = 0.2f; | ||
280 | otherMaterial = (int)otherPart.Material; | ||
281 | if (otherMaterial >= MaxMaterials) | ||
282 | otherMaterial = 3; | ||
283 | |||
284 | soundID = m_PartPart[thisMatScaled + otherMaterial]; | ||
285 | otherPart.SendCollisionSound(soundID, volume, colInfo.position); | ||
286 | } | ||
287 | continue; | ||
288 | } | ||
289 | /* | ||
290 | else if (!doneownsound) | ||
291 | { | ||
292 | ScenePresence otherav = av.Scene.GetScenePresence(Id); | ||
293 | if (otherav != null && (!otherav.IsChildAgent)) | ||
294 | { | ||
295 | soundID = snd_FleshFlesh; | ||
296 | av.SendCollisionSound(soundID, 1.0); | ||
297 | doneownsound = true; | ||
298 | } | ||
299 | } | ||
300 | */ | ||
301 | } | ||
302 | } | ||
303 | } | ||
304 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index a246319..4fec44f 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -90,6 +90,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
90 | /// </remarks> | 90 | /// </remarks> |
91 | public event OnTerrainTickDelegate OnTerrainTick; | 91 | public event OnTerrainTickDelegate OnTerrainTick; |
92 | 92 | ||
93 | public delegate void OnTerrainUpdateDelegate(); | ||
94 | |||
95 | public event OnTerrainUpdateDelegate OnTerrainUpdate; | ||
96 | |||
93 | public delegate void OnBackupDelegate(ISimulationDataService datastore, bool forceBackup); | 97 | public delegate void OnBackupDelegate(ISimulationDataService datastore, bool forceBackup); |
94 | 98 | ||
95 | /// <summary> | 99 | /// <summary> |
@@ -339,8 +343,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
339 | /// in <see cref="Scene.SetScriptRunning"/> | 343 | /// in <see cref="Scene.SetScriptRunning"/> |
340 | /// via <see cref="OpenSim.Framework.IClientAPI.OnSetScriptRunning"/>, | 344 | /// via <see cref="OpenSim.Framework.IClientAPI.OnSetScriptRunning"/>, |
341 | /// via <see cref="OpenSim.Region.ClientStack.LindenUDP.HandleSetScriptRunning"/> | 345 | /// via <see cref="OpenSim.Region.ClientStack.LindenUDP.HandleSetScriptRunning"/> |
342 | /// XXX: This is only triggered when it is the client that starts the script, not in other situations where | ||
343 | /// a script is started, unlike OnStopScript! | ||
344 | /// </remarks> | 346 | /// </remarks> |
345 | public event StartScript OnStartScript; | 347 | public event StartScript OnStartScript; |
346 | 348 | ||
@@ -354,7 +356,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
354 | /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>, | 356 | /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>, |
355 | /// <see cref="SceneObjectPartInventory.StopScriptInstance"/>, | 357 | /// <see cref="SceneObjectPartInventory.StopScriptInstance"/>, |
356 | /// <see cref="Scene.SetScriptRunning"/> | 358 | /// <see cref="Scene.SetScriptRunning"/> |
357 | /// XXX: This is triggered when a sciprt is stopped for any reason, unlike OnStartScript! | ||
358 | /// </remarks> | 359 | /// </remarks> |
359 | public event StopScript OnStopScript; | 360 | public event StopScript OnStopScript; |
360 | 361 | ||
@@ -842,6 +843,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
842 | public event ParcelPrimCountTainted OnParcelPrimCountTainted; | 843 | public event ParcelPrimCountTainted OnParcelPrimCountTainted; |
843 | public event GetScriptRunning OnGetScriptRunning; | 844 | public event GetScriptRunning OnGetScriptRunning; |
844 | 845 | ||
846 | public delegate void ThrottleUpdate(ScenePresence scenePresence); | ||
847 | |||
848 | public event ThrottleUpdate OnThrottleUpdate; | ||
849 | |||
845 | /// <summary> | 850 | /// <summary> |
846 | /// RegisterCapsEvent is called by Scene after the Caps object | 851 | /// RegisterCapsEvent is called by Scene after the Caps object |
847 | /// has been instantiated and before it is return to the | 852 | /// has been instantiated and before it is return to the |
@@ -1425,6 +1430,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1425 | } | 1430 | } |
1426 | } | 1431 | } |
1427 | } | 1432 | } |
1433 | public void TriggerTerrainUpdate() | ||
1434 | { | ||
1435 | OnTerrainUpdateDelegate handlerTerrainUpdate = OnTerrainUpdate; | ||
1436 | if (handlerTerrainUpdate != null) | ||
1437 | { | ||
1438 | foreach (OnTerrainUpdateDelegate d in handlerTerrainUpdate.GetInvocationList()) | ||
1439 | { | ||
1440 | try | ||
1441 | { | ||
1442 | d(); | ||
1443 | } | ||
1444 | catch (Exception e) | ||
1445 | { | ||
1446 | m_log.ErrorFormat( | ||
1447 | "[EVENT MANAGER]: Delegate for TriggerTerrainUpdate failed - continuing. {0} {1}", | ||
1448 | e.Message, e.StackTrace); | ||
1449 | } | ||
1450 | } | ||
1451 | } | ||
1452 | } | ||
1428 | 1453 | ||
1429 | public void TriggerTerrainTick() | 1454 | public void TriggerTerrainTick() |
1430 | { | 1455 | { |
@@ -1757,6 +1782,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1757 | m_log.ErrorFormat( | 1782 | m_log.ErrorFormat( |
1758 | "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", | 1783 | "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", |
1759 | e.Message, e.StackTrace); | 1784 | e.Message, e.StackTrace); |
1785 | m_log.ErrorFormat(Environment.StackTrace); | ||
1760 | } | 1786 | } |
1761 | } | 1787 | } |
1762 | } | 1788 | } |
@@ -3035,6 +3061,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3035 | { | 3061 | { |
3036 | foreach (Action<Scene> d in handler.GetInvocationList()) | 3062 | foreach (Action<Scene> d in handler.GetInvocationList()) |
3037 | { | 3063 | { |
3064 | m_log.InfoFormat("[EVENT MANAGER]: TriggerSceneShuttingDown invoque {0}", d.Method.Name.ToString()); | ||
3038 | try | 3065 | try |
3039 | { | 3066 | { |
3040 | d(s); | 3067 | d(s); |
@@ -3047,6 +3074,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3047 | } | 3074 | } |
3048 | } | 3075 | } |
3049 | } | 3076 | } |
3077 | m_log.Info("[EVENT MANAGER]: TriggerSceneShuttingDown done"); | ||
3050 | } | 3078 | } |
3051 | 3079 | ||
3052 | public void TriggerOnRegionStarted(Scene scene) | 3080 | public void TriggerOnRegionStarted(Scene scene) |
@@ -3237,5 +3265,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3237 | } | 3265 | } |
3238 | } | 3266 | } |
3239 | } | 3267 | } |
3268 | |||
3269 | public void TriggerThrottleUpdate(ScenePresence scenePresence) | ||
3270 | { | ||
3271 | ThrottleUpdate handler = OnThrottleUpdate; | ||
3272 | if (handler != null) | ||
3273 | { | ||
3274 | handler(scenePresence); | ||
3275 | } | ||
3276 | } | ||
3240 | } | 3277 | } |
3241 | } | 3278 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 1b10e3c..ddae073 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs | |||
@@ -157,7 +157,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
157 | 157 | ||
158 | private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) | 158 | private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) |
159 | { | 159 | { |
160 | uint pqueue = ComputeDistancePriority(client,entity,true); | 160 | uint pqueue = ComputeDistancePriority(client,entity,false); |
161 | 161 | ||
162 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); | 162 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); |
163 | if (presence != null) | 163 | if (presence != null) |
@@ -212,9 +212,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
212 | } | 212 | } |
213 | 213 | ||
214 | // Use the camera position for local agents and avatar position for remote agents | 214 | // Use the camera position for local agents and avatar position for remote agents |
215 | Vector3 presencePos = (presence.IsChildAgent) ? | 215 | // Why would I want that? They could be camming but I still see them at the |
216 | presence.AbsolutePosition : | 216 | // avatar position, so why should I update them as if they were at their |
217 | presence.CameraPosition; | 217 | // camera positions? Makes no sense! |
218 | // TODO: Fix this mess | ||
219 | //Vector3 presencePos = (presence.IsChildAgent) ? | ||
220 | // presence.AbsolutePosition : | ||
221 | // presence.CameraPosition; | ||
222 | |||
223 | Vector3 presencePos = presence.AbsolutePosition; | ||
218 | 224 | ||
219 | // Compute the distance... | 225 | // Compute the distance... |
220 | double distance = Vector3.Distance(presencePos, entityPos); | 226 | double distance = Vector3.Distance(presencePos, entityPos); |
@@ -226,7 +232,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
226 | 232 | ||
227 | for (int i = 0; i < queues - 1; i++) | 233 | for (int i = 0; i < queues - 1; i++) |
228 | { | 234 | { |
229 | if (distance < 10 * Math.Pow(2.0,i)) | 235 | if (distance < 30 * Math.Pow(2.0,i)) |
230 | break; | 236 | break; |
231 | pqueue++; | 237 | pqueue++; |
232 | } | 238 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SOPMaterial.cs b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs new file mode 100644 index 0000000..10ac37c --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/SOPMaterial.cs | |||
@@ -0,0 +1,95 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | |||
33 | namespace OpenSim.Region.Framework.Scenes | ||
34 | { | ||
35 | public static class SOPMaterialData | ||
36 | { | ||
37 | public enum SopMaterial : int // redundante and not in use for now | ||
38 | { | ||
39 | Stone = 0, | ||
40 | Metal = 1, | ||
41 | Glass = 2, | ||
42 | Wood = 3, | ||
43 | Flesh = 4, | ||
44 | Plastic = 5, | ||
45 | Rubber = 6, | ||
46 | light = 7 // compatibility with old viewers | ||
47 | } | ||
48 | |||
49 | private struct MaterialData | ||
50 | { | ||
51 | public float friction; | ||
52 | public float bounce; | ||
53 | public MaterialData(float f, float b) | ||
54 | { | ||
55 | friction = f; | ||
56 | bounce = b; | ||
57 | } | ||
58 | } | ||
59 | |||
60 | private static MaterialData[] m_materialdata = { | ||
61 | new MaterialData(0.8f,0.4f), // Stone | ||
62 | new MaterialData(0.3f,0.4f), // Metal | ||
63 | new MaterialData(0.2f,0.7f), // Glass | ||
64 | new MaterialData(0.6f,0.5f), // Wood | ||
65 | new MaterialData(0.9f,0.3f), // Flesh | ||
66 | new MaterialData(0.4f,0.7f), // Plastic | ||
67 | new MaterialData(0.9f,0.95f), // Rubber | ||
68 | new MaterialData(0.0f,0.0f) // light ?? | ||
69 | }; | ||
70 | |||
71 | public static Material MaxMaterial | ||
72 | { | ||
73 | get { return (Material)(m_materialdata.Length - 1); } | ||
74 | } | ||
75 | |||
76 | public static float friction(Material material) | ||
77 | { | ||
78 | int indx = (int)material; | ||
79 | if (indx < m_materialdata.Length) | ||
80 | return (m_materialdata[indx].friction); | ||
81 | else | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | public static float bounce(Material material) | ||
86 | { | ||
87 | int indx = (int)material; | ||
88 | if (indx < m_materialdata.Length) | ||
89 | return (m_materialdata[indx].bounce); | ||
90 | else | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | } | ||
95 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs new file mode 100644 index 0000000..9cb901a --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs | |||
@@ -0,0 +1,791 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Physics.Manager; | ||
33 | using System.Text; | ||
34 | using System.IO; | ||
35 | using System.Xml; | ||
36 | using OpenSim.Framework.Serialization; | ||
37 | using OpenSim.Framework.Serialization.External; | ||
38 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
39 | |||
40 | namespace OpenSim.Region.Framework.Scenes | ||
41 | { | ||
42 | public class SOPVehicle | ||
43 | { | ||
44 | public VehicleData vd; | ||
45 | |||
46 | public Vehicle Type | ||
47 | { | ||
48 | get { return vd.m_type; } | ||
49 | } | ||
50 | |||
51 | public SOPVehicle() | ||
52 | { | ||
53 | vd = new VehicleData(); | ||
54 | ProcessTypeChange(Vehicle.TYPE_NONE); // is needed? | ||
55 | } | ||
56 | |||
57 | public void ProcessFloatVehicleParam(Vehicle pParam, float pValue) | ||
58 | { | ||
59 | float len; | ||
60 | float timestep = 0.01f; | ||
61 | switch (pParam) | ||
62 | { | ||
63 | case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: | ||
64 | if (pValue < 0f) pValue = 0f; | ||
65 | if (pValue > 1f) pValue = 1f; | ||
66 | vd.m_angularDeflectionEfficiency = pValue; | ||
67 | break; | ||
68 | case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: | ||
69 | if (pValue < timestep) pValue = timestep; | ||
70 | vd.m_angularDeflectionTimescale = pValue; | ||
71 | break; | ||
72 | case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: | ||
73 | if (pValue < timestep) pValue = timestep; | ||
74 | else if (pValue > 120) pValue = 120; | ||
75 | vd.m_angularMotorDecayTimescale = pValue; | ||
76 | break; | ||
77 | case Vehicle.ANGULAR_MOTOR_TIMESCALE: | ||
78 | if (pValue < timestep) pValue = timestep; | ||
79 | vd.m_angularMotorTimescale = pValue; | ||
80 | break; | ||
81 | case Vehicle.BANKING_EFFICIENCY: | ||
82 | if (pValue < -1f) pValue = -1f; | ||
83 | if (pValue > 1f) pValue = 1f; | ||
84 | vd.m_bankingEfficiency = pValue; | ||
85 | break; | ||
86 | case Vehicle.BANKING_MIX: | ||
87 | if (pValue < 0f) pValue = 0f; | ||
88 | if (pValue > 1f) pValue = 1f; | ||
89 | vd.m_bankingMix = pValue; | ||
90 | break; | ||
91 | case Vehicle.BANKING_TIMESCALE: | ||
92 | if (pValue < timestep) pValue = timestep; | ||
93 | vd.m_bankingTimescale = pValue; | ||
94 | break; | ||
95 | case Vehicle.BUOYANCY: | ||
96 | if (pValue < -1f) pValue = -1f; | ||
97 | if (pValue > 1f) pValue = 1f; | ||
98 | vd.m_VehicleBuoyancy = pValue; | ||
99 | break; | ||
100 | case Vehicle.HOVER_EFFICIENCY: | ||
101 | if (pValue < 0f) pValue = 0f; | ||
102 | if (pValue > 1f) pValue = 1f; | ||
103 | vd.m_VhoverEfficiency = pValue; | ||
104 | break; | ||
105 | case Vehicle.HOVER_HEIGHT: | ||
106 | vd.m_VhoverHeight = pValue; | ||
107 | break; | ||
108 | case Vehicle.HOVER_TIMESCALE: | ||
109 | if (pValue < timestep) pValue = timestep; | ||
110 | vd.m_VhoverTimescale = pValue; | ||
111 | break; | ||
112 | case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: | ||
113 | if (pValue < 0f) pValue = 0f; | ||
114 | if (pValue > 1f) pValue = 1f; | ||
115 | vd.m_linearDeflectionEfficiency = pValue; | ||
116 | break; | ||
117 | case Vehicle.LINEAR_DEFLECTION_TIMESCALE: | ||
118 | if (pValue < timestep) pValue = timestep; | ||
119 | vd.m_linearDeflectionTimescale = pValue; | ||
120 | break; | ||
121 | case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: | ||
122 | if (pValue < timestep) pValue = timestep; | ||
123 | else if (pValue > 120) pValue = 120; | ||
124 | vd.m_linearMotorDecayTimescale = pValue; | ||
125 | break; | ||
126 | case Vehicle.LINEAR_MOTOR_TIMESCALE: | ||
127 | if (pValue < timestep) pValue = timestep; | ||
128 | vd.m_linearMotorTimescale = pValue; | ||
129 | break; | ||
130 | case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: | ||
131 | if (pValue < 0f) pValue = 0f; | ||
132 | if (pValue > 1f) pValue = 1f; | ||
133 | vd.m_verticalAttractionEfficiency = pValue; | ||
134 | break; | ||
135 | case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: | ||
136 | if (pValue < timestep) pValue = timestep; | ||
137 | vd.m_verticalAttractionTimescale = pValue; | ||
138 | break; | ||
139 | |||
140 | // These are vector properties but the engine lets you use a single float value to | ||
141 | // set all of the components to the same value | ||
142 | case Vehicle.ANGULAR_FRICTION_TIMESCALE: | ||
143 | if (pValue < timestep) pValue = timestep; | ||
144 | vd.m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue); | ||
145 | break; | ||
146 | case Vehicle.ANGULAR_MOTOR_DIRECTION: | ||
147 | vd.m_angularMotorDirection = new Vector3(pValue, pValue, pValue); | ||
148 | len = vd.m_angularMotorDirection.Length(); | ||
149 | if (len > 12.566f) | ||
150 | vd.m_angularMotorDirection *= (12.566f / len); | ||
151 | break; | ||
152 | case Vehicle.LINEAR_FRICTION_TIMESCALE: | ||
153 | if (pValue < timestep) pValue = timestep; | ||
154 | vd.m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); | ||
155 | break; | ||
156 | case Vehicle.LINEAR_MOTOR_DIRECTION: | ||
157 | vd.m_linearMotorDirection = new Vector3(pValue, pValue, pValue); | ||
158 | len = vd.m_linearMotorDirection.Length(); | ||
159 | if (len > 30.0f) | ||
160 | vd.m_linearMotorDirection *= (30.0f / len); | ||
161 | break; | ||
162 | case Vehicle.LINEAR_MOTOR_OFFSET: | ||
163 | vd.m_linearMotorOffset = new Vector3(pValue, pValue, pValue); | ||
164 | len = vd.m_linearMotorOffset.Length(); | ||
165 | if (len > 100.0f) | ||
166 | vd.m_linearMotorOffset *= (100.0f / len); | ||
167 | break; | ||
168 | } | ||
169 | }//end ProcessFloatVehicleParam | ||
170 | |||
171 | public void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue) | ||
172 | { | ||
173 | float len; | ||
174 | float timestep = 0.01f; | ||
175 | switch (pParam) | ||
176 | { | ||
177 | case Vehicle.ANGULAR_FRICTION_TIMESCALE: | ||
178 | if (pValue.X < timestep) pValue.X = timestep; | ||
179 | if (pValue.Y < timestep) pValue.Y = timestep; | ||
180 | if (pValue.Z < timestep) pValue.Z = timestep; | ||
181 | |||
182 | vd.m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
183 | break; | ||
184 | case Vehicle.ANGULAR_MOTOR_DIRECTION: | ||
185 | vd.m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
186 | // Limit requested angular speed to 2 rps= 4 pi rads/sec | ||
187 | len = vd.m_angularMotorDirection.Length(); | ||
188 | if (len > 12.566f) | ||
189 | vd.m_angularMotorDirection *= (12.566f / len); | ||
190 | break; | ||
191 | case Vehicle.LINEAR_FRICTION_TIMESCALE: | ||
192 | if (pValue.X < timestep) pValue.X = timestep; | ||
193 | if (pValue.Y < timestep) pValue.Y = timestep; | ||
194 | if (pValue.Z < timestep) pValue.Z = timestep; | ||
195 | vd.m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
196 | break; | ||
197 | case Vehicle.LINEAR_MOTOR_DIRECTION: | ||
198 | vd.m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
199 | len = vd.m_linearMotorDirection.Length(); | ||
200 | if (len > 30.0f) | ||
201 | vd.m_linearMotorDirection *= (30.0f / len); | ||
202 | break; | ||
203 | case Vehicle.LINEAR_MOTOR_OFFSET: | ||
204 | vd.m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
205 | len = vd.m_linearMotorOffset.Length(); | ||
206 | if (len > 100.0f) | ||
207 | vd.m_linearMotorOffset *= (100.0f / len); | ||
208 | break; | ||
209 | } | ||
210 | }//end ProcessVectorVehicleParam | ||
211 | |||
212 | public void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) | ||
213 | { | ||
214 | switch (pParam) | ||
215 | { | ||
216 | case Vehicle.REFERENCE_FRAME: | ||
217 | vd.m_referenceFrame = pValue; | ||
218 | break; | ||
219 | } | ||
220 | }//end ProcessRotationVehicleParam | ||
221 | |||
222 | public void ProcessVehicleFlags(int pParam, bool remove) | ||
223 | { | ||
224 | if (remove) | ||
225 | { | ||
226 | vd.m_flags &= ~((VehicleFlag)pParam); | ||
227 | } | ||
228 | else | ||
229 | { | ||
230 | vd.m_flags |= (VehicleFlag)pParam; | ||
231 | } | ||
232 | }//end ProcessVehicleFlags | ||
233 | |||
234 | public void ProcessTypeChange(Vehicle pType) | ||
235 | { | ||
236 | vd.m_linearMotorDirection = Vector3.Zero; | ||
237 | vd.m_angularMotorDirection = Vector3.Zero; | ||
238 | vd.m_linearMotorOffset = Vector3.Zero; | ||
239 | vd.m_referenceFrame = Quaternion.Identity; | ||
240 | |||
241 | // Set Defaults For Type | ||
242 | vd.m_type = pType; | ||
243 | switch (pType) | ||
244 | { | ||
245 | case Vehicle.TYPE_NONE: | ||
246 | vd.m_linearFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
247 | vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
248 | vd.m_linearMotorTimescale = 1000; | ||
249 | vd.m_linearMotorDecayTimescale = 120; | ||
250 | vd.m_angularMotorTimescale = 1000; | ||
251 | vd.m_angularMotorDecayTimescale = 1000; | ||
252 | vd.m_VhoverHeight = 0; | ||
253 | vd.m_VhoverEfficiency = 1; | ||
254 | vd.m_VhoverTimescale = 1000; | ||
255 | vd.m_VehicleBuoyancy = 0; | ||
256 | vd.m_linearDeflectionEfficiency = 0; | ||
257 | vd.m_linearDeflectionTimescale = 1000; | ||
258 | vd.m_angularDeflectionEfficiency = 0; | ||
259 | vd.m_angularDeflectionTimescale = 1000; | ||
260 | vd.m_bankingEfficiency = 0; | ||
261 | vd.m_bankingMix = 1; | ||
262 | vd.m_bankingTimescale = 1000; | ||
263 | vd.m_verticalAttractionEfficiency = 0; | ||
264 | vd.m_verticalAttractionTimescale = 1000; | ||
265 | |||
266 | vd.m_flags = (VehicleFlag)0; | ||
267 | break; | ||
268 | |||
269 | case Vehicle.TYPE_SLED: | ||
270 | vd.m_linearFrictionTimescale = new Vector3(30, 1, 1000); | ||
271 | vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
272 | vd.m_linearMotorTimescale = 1000; | ||
273 | vd.m_linearMotorDecayTimescale = 120; | ||
274 | vd.m_angularMotorTimescale = 1000; | ||
275 | vd.m_angularMotorDecayTimescale = 120; | ||
276 | vd.m_VhoverHeight = 0; | ||
277 | vd.m_VhoverEfficiency = 1; | ||
278 | vd.m_VhoverTimescale = 10; | ||
279 | vd.m_VehicleBuoyancy = 0; | ||
280 | vd.m_linearDeflectionEfficiency = 1; | ||
281 | vd.m_linearDeflectionTimescale = 1; | ||
282 | vd.m_angularDeflectionEfficiency = 0; | ||
283 | vd.m_angularDeflectionTimescale = 1000; | ||
284 | vd.m_bankingEfficiency = 0; | ||
285 | vd.m_bankingMix = 1; | ||
286 | vd.m_bankingTimescale = 10; | ||
287 | vd.m_flags &= | ||
288 | ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | ||
289 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); | ||
290 | vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); | ||
291 | break; | ||
292 | case Vehicle.TYPE_CAR: | ||
293 | vd.m_linearFrictionTimescale = new Vector3(100, 2, 1000); | ||
294 | vd.m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
295 | vd.m_linearMotorTimescale = 1; | ||
296 | vd.m_linearMotorDecayTimescale = 60; | ||
297 | vd.m_angularMotorTimescale = 1; | ||
298 | vd.m_angularMotorDecayTimescale = 0.8f; | ||
299 | vd.m_VhoverHeight = 0; | ||
300 | vd.m_VhoverEfficiency = 0; | ||
301 | vd.m_VhoverTimescale = 1000; | ||
302 | vd.m_VehicleBuoyancy = 0; | ||
303 | vd.m_linearDeflectionEfficiency = 1; | ||
304 | vd.m_linearDeflectionTimescale = 2; | ||
305 | vd.m_angularDeflectionEfficiency = 0; | ||
306 | vd.m_angularDeflectionTimescale = 10; | ||
307 | vd.m_verticalAttractionEfficiency = 1f; | ||
308 | vd.m_verticalAttractionTimescale = 10f; | ||
309 | vd.m_bankingEfficiency = -0.2f; | ||
310 | vd.m_bankingMix = 1; | ||
311 | vd.m_bankingTimescale = 1; | ||
312 | vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); | ||
313 | vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | | ||
314 | VehicleFlag.LIMIT_MOTOR_UP | VehicleFlag.HOVER_UP_ONLY); | ||
315 | break; | ||
316 | case Vehicle.TYPE_BOAT: | ||
317 | vd.m_linearFrictionTimescale = new Vector3(10, 3, 2); | ||
318 | vd.m_angularFrictionTimescale = new Vector3(10, 10, 10); | ||
319 | vd.m_linearMotorTimescale = 5; | ||
320 | vd.m_linearMotorDecayTimescale = 60; | ||
321 | vd.m_angularMotorTimescale = 4; | ||
322 | vd.m_angularMotorDecayTimescale = 4; | ||
323 | vd.m_VhoverHeight = 0; | ||
324 | vd.m_VhoverEfficiency = 0.5f; | ||
325 | vd.m_VhoverTimescale = 2; | ||
326 | vd.m_VehicleBuoyancy = 1; | ||
327 | vd.m_linearDeflectionEfficiency = 0.5f; | ||
328 | vd.m_linearDeflectionTimescale = 3; | ||
329 | vd.m_angularDeflectionEfficiency = 0.5f; | ||
330 | vd.m_angularDeflectionTimescale = 5; | ||
331 | vd.m_verticalAttractionEfficiency = 0.5f; | ||
332 | vd.m_verticalAttractionTimescale = 5f; | ||
333 | vd.m_bankingEfficiency = -0.3f; | ||
334 | vd.m_bankingMix = 0.8f; | ||
335 | vd.m_bankingTimescale = 1; | ||
336 | vd.m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | | ||
337 | VehicleFlag.HOVER_GLOBAL_HEIGHT | | ||
338 | VehicleFlag.HOVER_UP_ONLY | | ||
339 | VehicleFlag.LIMIT_ROLL_ONLY); | ||
340 | vd.m_flags |= (VehicleFlag.NO_DEFLECTION_UP | | ||
341 | VehicleFlag.LIMIT_MOTOR_UP | | ||
342 | VehicleFlag.HOVER_WATER_ONLY); | ||
343 | break; | ||
344 | case Vehicle.TYPE_AIRPLANE: | ||
345 | vd.m_linearFrictionTimescale = new Vector3(200, 10, 5); | ||
346 | vd.m_angularFrictionTimescale = new Vector3(20, 20, 20); | ||
347 | vd.m_linearMotorTimescale = 2; | ||
348 | vd.m_linearMotorDecayTimescale = 60; | ||
349 | vd.m_angularMotorTimescale = 4; | ||
350 | vd.m_angularMotorDecayTimescale = 8; | ||
351 | vd.m_VhoverHeight = 0; | ||
352 | vd.m_VhoverEfficiency = 0.5f; | ||
353 | vd.m_VhoverTimescale = 1000; | ||
354 | vd.m_VehicleBuoyancy = 0; | ||
355 | vd.m_linearDeflectionEfficiency = 0.5f; | ||
356 | vd.m_linearDeflectionTimescale = 0.5f; | ||
357 | vd.m_angularDeflectionEfficiency = 1; | ||
358 | vd.m_angularDeflectionTimescale = 2; | ||
359 | vd.m_verticalAttractionEfficiency = 0.9f; | ||
360 | vd.m_verticalAttractionTimescale = 2f; | ||
361 | vd.m_bankingEfficiency = 1; | ||
362 | vd.m_bankingMix = 0.7f; | ||
363 | vd.m_bankingTimescale = 2; | ||
364 | vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | | ||
365 | VehicleFlag.HOVER_TERRAIN_ONLY | | ||
366 | VehicleFlag.HOVER_GLOBAL_HEIGHT | | ||
367 | VehicleFlag.HOVER_UP_ONLY | | ||
368 | VehicleFlag.NO_DEFLECTION_UP | | ||
369 | VehicleFlag.LIMIT_MOTOR_UP); | ||
370 | vd.m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); | ||
371 | break; | ||
372 | case Vehicle.TYPE_BALLOON: | ||
373 | vd.m_linearFrictionTimescale = new Vector3(5, 5, 5); | ||
374 | vd.m_angularFrictionTimescale = new Vector3(10, 10, 10); | ||
375 | vd.m_linearMotorTimescale = 5; | ||
376 | vd.m_linearMotorDecayTimescale = 60; | ||
377 | vd.m_angularMotorTimescale = 6; | ||
378 | vd.m_angularMotorDecayTimescale = 10; | ||
379 | vd.m_VhoverHeight = 5; | ||
380 | vd.m_VhoverEfficiency = 0.8f; | ||
381 | vd.m_VhoverTimescale = 10; | ||
382 | vd.m_VehicleBuoyancy = 1; | ||
383 | vd.m_linearDeflectionEfficiency = 0; | ||
384 | vd.m_linearDeflectionTimescale = 5; | ||
385 | vd.m_angularDeflectionEfficiency = 0; | ||
386 | vd.m_angularDeflectionTimescale = 5; | ||
387 | vd.m_verticalAttractionEfficiency = 0f; | ||
388 | vd.m_verticalAttractionTimescale = 1000f; | ||
389 | vd.m_bankingEfficiency = 0; | ||
390 | vd.m_bankingMix = 0.7f; | ||
391 | vd.m_bankingTimescale = 5; | ||
392 | vd.m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | | ||
393 | VehicleFlag.HOVER_TERRAIN_ONLY | | ||
394 | VehicleFlag.HOVER_UP_ONLY | | ||
395 | VehicleFlag.NO_DEFLECTION_UP | | ||
396 | VehicleFlag.LIMIT_MOTOR_UP); | ||
397 | vd.m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY | | ||
398 | VehicleFlag.HOVER_GLOBAL_HEIGHT); | ||
399 | break; | ||
400 | } | ||
401 | } | ||
402 | public void SetVehicle(PhysicsActor ph) | ||
403 | { | ||
404 | if (ph == null) | ||
405 | return; | ||
406 | ph.SetVehicle(vd); | ||
407 | } | ||
408 | |||
409 | private XmlTextWriter writer; | ||
410 | |||
411 | private void XWint(string name, int i) | ||
412 | { | ||
413 | writer.WriteElementString(name, i.ToString()); | ||
414 | } | ||
415 | |||
416 | private void XWfloat(string name, float f) | ||
417 | { | ||
418 | writer.WriteElementString(name, f.ToString(Utils.EnUsCulture)); | ||
419 | } | ||
420 | |||
421 | private void XWVector(string name, Vector3 vec) | ||
422 | { | ||
423 | writer.WriteStartElement(name); | ||
424 | writer.WriteElementString("X", vec.X.ToString(Utils.EnUsCulture)); | ||
425 | writer.WriteElementString("Y", vec.Y.ToString(Utils.EnUsCulture)); | ||
426 | writer.WriteElementString("Z", vec.Z.ToString(Utils.EnUsCulture)); | ||
427 | writer.WriteEndElement(); | ||
428 | } | ||
429 | |||
430 | private void XWQuat(string name, Quaternion quat) | ||
431 | { | ||
432 | writer.WriteStartElement(name); | ||
433 | writer.WriteElementString("X", quat.X.ToString(Utils.EnUsCulture)); | ||
434 | writer.WriteElementString("Y", quat.Y.ToString(Utils.EnUsCulture)); | ||
435 | writer.WriteElementString("Z", quat.Z.ToString(Utils.EnUsCulture)); | ||
436 | writer.WriteElementString("W", quat.W.ToString(Utils.EnUsCulture)); | ||
437 | writer.WriteEndElement(); | ||
438 | } | ||
439 | |||
440 | public void ToXml2(XmlTextWriter twriter) | ||
441 | { | ||
442 | writer = twriter; | ||
443 | writer.WriteStartElement("Vehicle"); | ||
444 | |||
445 | XWint("TYPE", (int)vd.m_type); | ||
446 | XWint("FLAGS", (int)vd.m_flags); | ||
447 | |||
448 | // Linear properties | ||
449 | XWVector("LMDIR", vd.m_linearMotorDirection); | ||
450 | XWVector("LMFTIME", vd.m_linearFrictionTimescale); | ||
451 | XWfloat("LMDTIME", vd.m_linearMotorDecayTimescale); | ||
452 | XWfloat("LMTIME", vd.m_linearMotorTimescale); | ||
453 | XWVector("LMOFF", vd.m_linearMotorOffset); | ||
454 | |||
455 | //Angular properties | ||
456 | XWVector("AMDIR", vd.m_angularMotorDirection); | ||
457 | XWfloat("AMTIME", vd.m_angularMotorTimescale); | ||
458 | XWfloat("AMDTIME", vd.m_angularMotorDecayTimescale); | ||
459 | XWVector("AMFTIME", vd.m_angularFrictionTimescale); | ||
460 | |||
461 | //Deflection properties | ||
462 | XWfloat("ADEFF", vd.m_angularDeflectionEfficiency); | ||
463 | XWfloat("ADTIME", vd.m_angularDeflectionTimescale); | ||
464 | XWfloat("LDEFF", vd.m_linearDeflectionEfficiency); | ||
465 | XWfloat("LDTIME", vd.m_linearDeflectionTimescale); | ||
466 | |||
467 | //Banking properties | ||
468 | XWfloat("BEFF", vd.m_bankingEfficiency); | ||
469 | XWfloat("BMIX", vd.m_bankingMix); | ||
470 | XWfloat("BTIME", vd.m_bankingTimescale); | ||
471 | |||
472 | //Hover and Buoyancy properties | ||
473 | XWfloat("HHEI", vd.m_VhoverHeight); | ||
474 | XWfloat("HEFF", vd.m_VhoverEfficiency); | ||
475 | XWfloat("HTIME", vd.m_VhoverTimescale); | ||
476 | XWfloat("VBUO", vd.m_VehicleBuoyancy); | ||
477 | |||
478 | //Attractor properties | ||
479 | XWfloat("VAEFF", vd.m_verticalAttractionEfficiency); | ||
480 | XWfloat("VATIME", vd.m_verticalAttractionTimescale); | ||
481 | |||
482 | XWQuat("REF_FRAME", vd.m_referenceFrame); | ||
483 | |||
484 | writer.WriteEndElement(); | ||
485 | writer = null; | ||
486 | } | ||
487 | |||
488 | |||
489 | |||
490 | XmlTextReader reader; | ||
491 | |||
492 | private int XRint() | ||
493 | { | ||
494 | return reader.ReadElementContentAsInt(); | ||
495 | } | ||
496 | |||
497 | private float XRfloat() | ||
498 | { | ||
499 | return reader.ReadElementContentAsFloat(); | ||
500 | } | ||
501 | |||
502 | public Vector3 XRvector() | ||
503 | { | ||
504 | Vector3 vec; | ||
505 | reader.ReadStartElement(); | ||
506 | vec.X = reader.ReadElementContentAsFloat(); | ||
507 | vec.Y = reader.ReadElementContentAsFloat(); | ||
508 | vec.Z = reader.ReadElementContentAsFloat(); | ||
509 | reader.ReadEndElement(); | ||
510 | return vec; | ||
511 | } | ||
512 | |||
513 | public Quaternion XRquat() | ||
514 | { | ||
515 | Quaternion q; | ||
516 | reader.ReadStartElement(); | ||
517 | q.X = reader.ReadElementContentAsFloat(); | ||
518 | q.Y = reader.ReadElementContentAsFloat(); | ||
519 | q.Z = reader.ReadElementContentAsFloat(); | ||
520 | q.W = reader.ReadElementContentAsFloat(); | ||
521 | reader.ReadEndElement(); | ||
522 | return q; | ||
523 | } | ||
524 | |||
525 | public static bool EReadProcessors( | ||
526 | Dictionary<string, Action> processors, | ||
527 | XmlTextReader xtr) | ||
528 | { | ||
529 | bool errors = false; | ||
530 | |||
531 | string nodeName = string.Empty; | ||
532 | while (xtr.NodeType != XmlNodeType.EndElement) | ||
533 | { | ||
534 | nodeName = xtr.Name; | ||
535 | |||
536 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Processing: {0}", nodeName); | ||
537 | |||
538 | Action p = null; | ||
539 | if (processors.TryGetValue(xtr.Name, out p)) | ||
540 | { | ||
541 | // m_log.DebugFormat("[ExternalRepresentationUtils]: Found {0} processor, nodeName); | ||
542 | |||
543 | try | ||
544 | { | ||
545 | p(); | ||
546 | } | ||
547 | catch (Exception e) | ||
548 | { | ||
549 | errors = true; | ||
550 | if (xtr.NodeType == XmlNodeType.EndElement) | ||
551 | xtr.Read(); | ||
552 | } | ||
553 | } | ||
554 | else | ||
555 | { | ||
556 | // m_log.DebugFormat("[LandDataSerializer]: caught unknown element {0}", nodeName); | ||
557 | xtr.ReadOuterXml(); // ignore | ||
558 | } | ||
559 | } | ||
560 | |||
561 | return errors; | ||
562 | } | ||
563 | |||
564 | |||
565 | public string ToXml2() | ||
566 | { | ||
567 | MemoryStream ms = new MemoryStream(512); | ||
568 | UTF8Encoding enc = new UTF8Encoding(); | ||
569 | XmlTextWriter xwriter = new XmlTextWriter(ms, enc); | ||
570 | ToXml2(xwriter); | ||
571 | xwriter.Flush(); | ||
572 | string s = ms.GetStreamString(); | ||
573 | xwriter.Close(); | ||
574 | return s; | ||
575 | } | ||
576 | |||
577 | public static SOPVehicle FromXml2(string text) | ||
578 | { | ||
579 | if (text == String.Empty) | ||
580 | return null; | ||
581 | |||
582 | UTF8Encoding enc = new UTF8Encoding(); | ||
583 | MemoryStream ms = new MemoryStream(enc.GetBytes(text)); | ||
584 | XmlTextReader xreader = new XmlTextReader(ms); | ||
585 | |||
586 | SOPVehicle v = new SOPVehicle(); | ||
587 | bool error; | ||
588 | |||
589 | v.FromXml2(xreader, out error); | ||
590 | |||
591 | xreader.Close(); | ||
592 | |||
593 | if (error) | ||
594 | { | ||
595 | v = null; | ||
596 | return null; | ||
597 | } | ||
598 | return v; | ||
599 | } | ||
600 | |||
601 | public static SOPVehicle FromXml2(XmlTextReader reader) | ||
602 | { | ||
603 | SOPVehicle vehicle = new SOPVehicle(); | ||
604 | |||
605 | bool errors = false; | ||
606 | |||
607 | vehicle.FromXml2(reader, out errors); | ||
608 | if (errors) | ||
609 | return null; | ||
610 | |||
611 | return vehicle; | ||
612 | } | ||
613 | |||
614 | private void FromXml2(XmlTextReader _reader, out bool errors) | ||
615 | { | ||
616 | errors = false; | ||
617 | reader = _reader; | ||
618 | |||
619 | Dictionary<string, Action> m_VehicleXmlProcessors | ||
620 | = new Dictionary<string, Action>(); | ||
621 | |||
622 | m_VehicleXmlProcessors.Add("TYPE", ProcessXR_type); | ||
623 | m_VehicleXmlProcessors.Add("FLAGS", ProcessXR_flags); | ||
624 | |||
625 | // Linear properties | ||
626 | m_VehicleXmlProcessors.Add("LMDIR", ProcessXR_linearMotorDirection); | ||
627 | m_VehicleXmlProcessors.Add("LMFTIME", ProcessXR_linearFrictionTimescale); | ||
628 | m_VehicleXmlProcessors.Add("LMDTIME", ProcessXR_linearMotorDecayTimescale); | ||
629 | m_VehicleXmlProcessors.Add("LMTIME", ProcessXR_linearMotorTimescale); | ||
630 | m_VehicleXmlProcessors.Add("LMOFF", ProcessXR_linearMotorOffset); | ||
631 | |||
632 | //Angular properties | ||
633 | m_VehicleXmlProcessors.Add("AMDIR", ProcessXR_angularMotorDirection); | ||
634 | m_VehicleXmlProcessors.Add("AMTIME", ProcessXR_angularMotorTimescale); | ||
635 | m_VehicleXmlProcessors.Add("AMDTIME", ProcessXR_angularMotorDecayTimescale); | ||
636 | m_VehicleXmlProcessors.Add("AMFTIME", ProcessXR_angularFrictionTimescale); | ||
637 | |||
638 | //Deflection properties | ||
639 | m_VehicleXmlProcessors.Add("ADEFF", ProcessXR_angularDeflectionEfficiency); | ||
640 | m_VehicleXmlProcessors.Add("ADTIME", ProcessXR_angularDeflectionTimescale); | ||
641 | m_VehicleXmlProcessors.Add("LDEFF", ProcessXR_linearDeflectionEfficiency); | ||
642 | m_VehicleXmlProcessors.Add("LDTIME", ProcessXR_linearDeflectionTimescale); | ||
643 | |||
644 | //Banking properties | ||
645 | m_VehicleXmlProcessors.Add("BEFF", ProcessXR_bankingEfficiency); | ||
646 | m_VehicleXmlProcessors.Add("BMIX", ProcessXR_bankingMix); | ||
647 | m_VehicleXmlProcessors.Add("BTIME", ProcessXR_bankingTimescale); | ||
648 | |||
649 | //Hover and Buoyancy properties | ||
650 | m_VehicleXmlProcessors.Add("HHEI", ProcessXR_VhoverHeight); | ||
651 | m_VehicleXmlProcessors.Add("HEFF", ProcessXR_VhoverEfficiency); | ||
652 | m_VehicleXmlProcessors.Add("HTIME", ProcessXR_VhoverTimescale); | ||
653 | |||
654 | m_VehicleXmlProcessors.Add("VBUO", ProcessXR_VehicleBuoyancy); | ||
655 | |||
656 | //Attractor properties | ||
657 | m_VehicleXmlProcessors.Add("VAEFF", ProcessXR_verticalAttractionEfficiency); | ||
658 | m_VehicleXmlProcessors.Add("VATIME", ProcessXR_verticalAttractionTimescale); | ||
659 | |||
660 | m_VehicleXmlProcessors.Add("REF_FRAME", ProcessXR_referenceFrame); | ||
661 | |||
662 | vd = new VehicleData(); | ||
663 | |||
664 | reader.ReadStartElement("Vehicle", String.Empty); | ||
665 | |||
666 | errors = EReadProcessors( | ||
667 | m_VehicleXmlProcessors, | ||
668 | reader); | ||
669 | |||
670 | reader.ReadEndElement(); | ||
671 | reader = null; | ||
672 | } | ||
673 | |||
674 | private void ProcessXR_type() | ||
675 | { | ||
676 | vd.m_type = (Vehicle)XRint(); | ||
677 | } | ||
678 | private void ProcessXR_flags() | ||
679 | { | ||
680 | vd.m_flags = (VehicleFlag)XRint(); | ||
681 | } | ||
682 | // Linear properties | ||
683 | private void ProcessXR_linearMotorDirection() | ||
684 | { | ||
685 | vd.m_linearMotorDirection = XRvector(); | ||
686 | } | ||
687 | |||
688 | private void ProcessXR_linearFrictionTimescale() | ||
689 | { | ||
690 | vd.m_linearFrictionTimescale = XRvector(); | ||
691 | } | ||
692 | |||
693 | private void ProcessXR_linearMotorDecayTimescale() | ||
694 | { | ||
695 | vd.m_linearMotorDecayTimescale = XRfloat(); | ||
696 | } | ||
697 | private void ProcessXR_linearMotorTimescale() | ||
698 | { | ||
699 | vd.m_linearMotorTimescale = XRfloat(); | ||
700 | } | ||
701 | private void ProcessXR_linearMotorOffset() | ||
702 | { | ||
703 | vd.m_linearMotorOffset = XRvector(); | ||
704 | } | ||
705 | |||
706 | |||
707 | //Angular properties | ||
708 | private void ProcessXR_angularMotorDirection() | ||
709 | { | ||
710 | vd.m_angularMotorDirection = XRvector(); | ||
711 | } | ||
712 | private void ProcessXR_angularMotorTimescale() | ||
713 | { | ||
714 | vd.m_angularMotorTimescale = XRfloat(); | ||
715 | } | ||
716 | private void ProcessXR_angularMotorDecayTimescale() | ||
717 | { | ||
718 | vd.m_angularMotorDecayTimescale = XRfloat(); | ||
719 | } | ||
720 | private void ProcessXR_angularFrictionTimescale() | ||
721 | { | ||
722 | vd.m_angularFrictionTimescale = XRvector(); | ||
723 | } | ||
724 | |||
725 | //Deflection properties | ||
726 | private void ProcessXR_angularDeflectionEfficiency() | ||
727 | { | ||
728 | vd.m_angularDeflectionEfficiency = XRfloat(); | ||
729 | } | ||
730 | private void ProcessXR_angularDeflectionTimescale() | ||
731 | { | ||
732 | vd.m_angularDeflectionTimescale = XRfloat(); | ||
733 | } | ||
734 | private void ProcessXR_linearDeflectionEfficiency() | ||
735 | { | ||
736 | vd.m_linearDeflectionEfficiency = XRfloat(); | ||
737 | } | ||
738 | private void ProcessXR_linearDeflectionTimescale() | ||
739 | { | ||
740 | vd.m_linearDeflectionTimescale = XRfloat(); | ||
741 | } | ||
742 | |||
743 | //Banking properties | ||
744 | private void ProcessXR_bankingEfficiency() | ||
745 | { | ||
746 | vd.m_bankingEfficiency = XRfloat(); | ||
747 | } | ||
748 | private void ProcessXR_bankingMix() | ||
749 | { | ||
750 | vd.m_bankingMix = XRfloat(); | ||
751 | } | ||
752 | private void ProcessXR_bankingTimescale() | ||
753 | { | ||
754 | vd.m_bankingTimescale = XRfloat(); | ||
755 | } | ||
756 | |||
757 | //Hover and Buoyancy properties | ||
758 | private void ProcessXR_VhoverHeight() | ||
759 | { | ||
760 | vd.m_VhoverHeight = XRfloat(); | ||
761 | } | ||
762 | private void ProcessXR_VhoverEfficiency() | ||
763 | { | ||
764 | vd.m_VhoverEfficiency = XRfloat(); | ||
765 | } | ||
766 | private void ProcessXR_VhoverTimescale() | ||
767 | { | ||
768 | vd.m_VhoverTimescale = XRfloat(); | ||
769 | } | ||
770 | |||
771 | private void ProcessXR_VehicleBuoyancy() | ||
772 | { | ||
773 | vd.m_VehicleBuoyancy = XRfloat(); | ||
774 | } | ||
775 | |||
776 | //Attractor properties | ||
777 | private void ProcessXR_verticalAttractionEfficiency() | ||
778 | { | ||
779 | vd.m_verticalAttractionEfficiency = XRfloat(); | ||
780 | } | ||
781 | private void ProcessXR_verticalAttractionTimescale() | ||
782 | { | ||
783 | vd.m_verticalAttractionTimescale = XRfloat(); | ||
784 | } | ||
785 | |||
786 | private void ProcessXR_referenceFrame() | ||
787 | { | ||
788 | vd.m_referenceFrame = XRquat(); | ||
789 | } | ||
790 | } | ||
791 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 6c79b13..70018c8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -102,12 +102,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
102 | engine.StartProcessing(); | 102 | engine.StartProcessing(); |
103 | } | 103 | } |
104 | 104 | ||
105 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) | 105 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item, uint cost) |
106 | { | 106 | { |
107 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); | 107 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); |
108 | if (money != null) | 108 | if (money != null) |
109 | { | 109 | { |
110 | money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload"); | 110 | money.ApplyUploadCharge(agentID, (int)cost, "Asset upload"); |
111 | } | 111 | } |
112 | 112 | ||
113 | AddInventoryItem(item); | 113 | AddInventoryItem(item); |
@@ -170,7 +170,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
170 | return false; | 170 | return false; |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | if (InventoryService.AddItem(item)) | 174 | if (InventoryService.AddItem(item)) |
175 | { | 175 | { |
176 | int userlevel = 0; | 176 | int userlevel = 0; |
@@ -325,8 +325,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
325 | 325 | ||
326 | // Update item with new asset | 326 | // Update item with new asset |
327 | item.AssetID = asset.FullID; | 327 | item.AssetID = asset.FullID; |
328 | if (group.UpdateInventoryItem(item)) | 328 | group.UpdateInventoryItem(item); |
329 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
330 | 329 | ||
331 | part.SendPropertiesToClient(remoteClient); | 330 | part.SendPropertiesToClient(remoteClient); |
332 | 331 | ||
@@ -337,12 +336,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
337 | { | 336 | { |
338 | // Needs to determine which engine was running it and use that | 337 | // Needs to determine which engine was running it and use that |
339 | // | 338 | // |
340 | part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); | 339 | errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 1); |
341 | errors = part.Inventory.GetScriptErrors(item.ItemID); | ||
342 | } | ||
343 | else | ||
344 | { | ||
345 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
346 | } | 340 | } |
347 | 341 | ||
348 | // Tell anyone managing scripts that a script has been reloaded/changed | 342 | // Tell anyone managing scripts that a script has been reloaded/changed |
@@ -408,6 +402,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
408 | if (item.Owner != remoteClient.AgentId) | 402 | if (item.Owner != remoteClient.AgentId) |
409 | return; | 403 | return; |
410 | 404 | ||
405 | item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); | ||
411 | item.Name = itemUpd.Name; | 406 | item.Name = itemUpd.Name; |
412 | item.Description = itemUpd.Description; | 407 | item.Description = itemUpd.Description; |
413 | 408 | ||
@@ -838,6 +833,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
838 | return; | 833 | return; |
839 | } | 834 | } |
840 | 835 | ||
836 | if (newName == null) newName = item.Name; | ||
837 | |||
841 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 838 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
842 | 839 | ||
843 | if (asset != null) | 840 | if (asset != null) |
@@ -898,6 +895,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
898 | } | 895 | } |
899 | 896 | ||
900 | /// <summary> | 897 | /// <summary> |
898 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
899 | /// </summary> | ||
900 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
901 | { | ||
902 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
903 | foreach (InventoryItemBase b in items) | ||
904 | { | ||
905 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
906 | InventoryItemBase n = InventoryService.GetItem(b); | ||
907 | n.Folder = destfolder; | ||
908 | moveitems.Add(n); | ||
909 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
910 | } | ||
911 | |||
912 | MoveInventoryItem(remoteClient, moveitems); | ||
913 | } | ||
914 | |||
915 | /// <summary> | ||
901 | /// Move an item within the agent's inventory. | 916 | /// Move an item within the agent's inventory. |
902 | /// </summary> | 917 | /// </summary> |
903 | /// <param name="remoteClient"></param> | 918 | /// <param name="remoteClient"></param> |
@@ -932,11 +947,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
932 | public void CreateNewInventoryItem( | 947 | public void CreateNewInventoryItem( |
933 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 948 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
934 | string name, string description, uint flags, uint callbackID, | 949 | string name, string description, uint flags, uint callbackID, |
935 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) | 950 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate, UUID transationID) |
936 | { | 951 | { |
937 | CreateNewInventoryItem( | 952 | CreateNewInventoryItem( |
938 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, | 953 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, |
939 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate); | 954 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate, transationID); |
955 | } | ||
956 | |||
957 | |||
958 | private void CreateNewInventoryItem( | ||
959 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | ||
960 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | ||
961 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | ||
962 | { | ||
963 | CreateNewInventoryItem(remoteClient, creatorID, creatorData, folderID, | ||
964 | name, description, flags, callbackID, asset, invType, | ||
965 | baseMask, currentMask, everyoneMask, nextOwnerMask, groupMask, creationDate, UUID.Zero); | ||
940 | } | 966 | } |
941 | 967 | ||
942 | /// <summary> | 968 | /// <summary> |
@@ -961,7 +987,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
961 | private void CreateNewInventoryItem( | 987 | private void CreateNewInventoryItem( |
962 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 988 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
963 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | 989 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, |
964 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | 990 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate,UUID transationID) |
965 | { | 991 | { |
966 | InventoryItemBase item = new InventoryItemBase(); | 992 | InventoryItemBase item = new InventoryItemBase(); |
967 | item.Owner = remoteClient.AgentId; | 993 | item.Owner = remoteClient.AgentId; |
@@ -984,7 +1010,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
984 | 1010 | ||
985 | if (AddInventoryItem(item)) | 1011 | if (AddInventoryItem(item)) |
986 | { | 1012 | { |
987 | remoteClient.SendInventoryItemCreateUpdate(item, callbackID); | 1013 | remoteClient.SendInventoryItemCreateUpdate(item, transationID, callbackID); |
988 | } | 1014 | } |
989 | else | 1015 | else |
990 | { | 1016 | { |
@@ -1259,6 +1285,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1259 | { | 1285 | { |
1260 | SceneObjectPart part = GetSceneObjectPart(primLocalId); | 1286 | SceneObjectPart part = GetSceneObjectPart(primLocalId); |
1261 | 1287 | ||
1288 | // Can't move a null item | ||
1289 | if (itemId == UUID.Zero) | ||
1290 | return; | ||
1291 | |||
1262 | if (null == part) | 1292 | if (null == part) |
1263 | { | 1293 | { |
1264 | m_log.WarnFormat( | 1294 | m_log.WarnFormat( |
@@ -1363,21 +1393,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1363 | return; | 1393 | return; |
1364 | } | 1394 | } |
1365 | 1395 | ||
1366 | if (part.OwnerID != destPart.OwnerID) | 1396 | // Can't transfer this |
1397 | // | ||
1398 | if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1399 | return; | ||
1400 | |||
1401 | bool overrideNoMod = false; | ||
1402 | if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) | ||
1403 | overrideNoMod = true; | ||
1404 | |||
1405 | if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1367 | { | 1406 | { |
1368 | // Source must have transfer permissions | 1407 | // object cannot copy items to an object owned by a different owner |
1369 | if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | 1408 | // unless llAllowInventoryDrop has been called |
1370 | return; | ||
1371 | 1409 | ||
1372 | // Object cannot copy items to an object owned by a different owner | 1410 | return; |
1373 | // unless llAllowInventoryDrop has been called on the destination | ||
1374 | if ((destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1375 | return; | ||
1376 | } | 1411 | } |
1377 | 1412 | ||
1378 | // must have both move and modify permission to put an item in an object | 1413 | // must have both move and modify permission to put an item in an object |
1379 | if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) | 1414 | if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) |
1415 | { | ||
1380 | return; | 1416 | return; |
1417 | } | ||
1381 | 1418 | ||
1382 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); | 1419 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); |
1383 | 1420 | ||
@@ -1433,6 +1470,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1433 | 1470 | ||
1434 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1471 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1435 | { | 1472 | { |
1473 | SceneObjectPart destPart = GetSceneObjectPart(destID); | ||
1474 | if (destPart != null) // Move into a prim | ||
1475 | { | ||
1476 | foreach(UUID itemID in items) | ||
1477 | MoveTaskInventoryItem(destID, host, itemID); | ||
1478 | return destID; // Prim folder ID == prim ID | ||
1479 | } | ||
1480 | |||
1436 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1481 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1437 | 1482 | ||
1438 | UUID newFolderID = UUID.Random(); | 1483 | UUID newFolderID = UUID.Random(); |
@@ -1615,12 +1660,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1615 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( | 1660 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( |
1616 | remoteClient, part, transactionID, currentItem); | 1661 | remoteClient, part, transactionID, currentItem); |
1617 | 1662 | ||
1618 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | 1663 | // if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) |
1619 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | 1664 | // remoteClient.SendAgentAlertMessage("Notecard saved", false); |
1620 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | 1665 | // else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) |
1621 | remoteClient.SendAgentAlertMessage("Script saved", false); | 1666 | // remoteClient.SendAgentAlertMessage("Script saved", false); |
1622 | else | 1667 | // else |
1623 | remoteClient.SendAgentAlertMessage("Item saved", false); | 1668 | // remoteClient.SendAgentAlertMessage("Item saved", false); |
1624 | } | 1669 | } |
1625 | 1670 | ||
1626 | // Base ALWAYS has move | 1671 | // Base ALWAYS has move |
@@ -1990,23 +2035,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1990 | // build a list of eligible objects | 2035 | // build a list of eligible objects |
1991 | List<uint> deleteIDs = new List<uint>(); | 2036 | List<uint> deleteIDs = new List<uint>(); |
1992 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 2037 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
1993 | 2038 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
1994 | // Start with true for both, then remove the flags if objects | ||
1995 | // that we can't derez are part of the selection | ||
1996 | bool permissionToTake = true; | ||
1997 | bool permissionToTakeCopy = true; | ||
1998 | bool permissionToDelete = true; | ||
1999 | 2039 | ||
2000 | foreach (uint localID in localIDs) | 2040 | foreach (uint localID in localIDs) |
2001 | { | 2041 | { |
2042 | // Start with true for both, then remove the flags if objects | ||
2043 | // that we can't derez are part of the selection | ||
2044 | bool permissionToTake = true; | ||
2045 | bool permissionToTakeCopy = true; | ||
2046 | bool permissionToDelete = true; | ||
2047 | |||
2002 | // Invalid id | 2048 | // Invalid id |
2003 | SceneObjectPart part = GetSceneObjectPart(localID); | 2049 | SceneObjectPart part = GetSceneObjectPart(localID); |
2004 | if (part == null) | 2050 | if (part == null) |
2051 | { | ||
2052 | //Client still thinks the object exists, kill it | ||
2053 | deleteIDs.Add(localID); | ||
2005 | continue; | 2054 | continue; |
2055 | } | ||
2006 | 2056 | ||
2007 | // Already deleted by someone else | 2057 | // Already deleted by someone else |
2008 | if (part.ParentGroup.IsDeleted) | 2058 | if (part.ParentGroup.IsDeleted) |
2059 | { | ||
2060 | //Client still thinks the object exists, kill it | ||
2061 | deleteIDs.Add(localID); | ||
2009 | continue; | 2062 | continue; |
2063 | } | ||
2010 | 2064 | ||
2011 | // Can't delete child prims | 2065 | // Can't delete child prims |
2012 | if (part != part.ParentGroup.RootPart) | 2066 | if (part != part.ParentGroup.RootPart) |
@@ -2014,8 +2068,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2014 | 2068 | ||
2015 | SceneObjectGroup grp = part.ParentGroup; | 2069 | SceneObjectGroup grp = part.ParentGroup; |
2016 | 2070 | ||
2017 | deleteIDs.Add(localID); | 2071 | // If child prims have invalid perms, fix them |
2018 | deleteGroups.Add(grp); | 2072 | grp.AdjustChildPrimPermissions(); |
2019 | 2073 | ||
2020 | // If child prims have invalid perms, fix them | 2074 | // If child prims have invalid perms, fix them |
2021 | grp.AdjustChildPrimPermissions(); | 2075 | grp.AdjustChildPrimPermissions(); |
@@ -2036,81 +2090,193 @@ namespace OpenSim.Region.Framework.Scenes | |||
2036 | } | 2090 | } |
2037 | else | 2091 | else |
2038 | { | 2092 | { |
2039 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 2093 | if (action == DeRezAction.TakeCopy) |
2094 | { | ||
2095 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
2096 | permissionToTakeCopy = false; | ||
2097 | } | ||
2098 | else | ||
2099 | { | ||
2040 | permissionToTakeCopy = false; | 2100 | permissionToTakeCopy = false; |
2041 | 2101 | } | |
2042 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 2102 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
2043 | permissionToTake = false; | 2103 | permissionToTake = false; |
2044 | 2104 | ||
2045 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 2105 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
2046 | permissionToDelete = false; | 2106 | permissionToDelete = false; |
2047 | } | 2107 | } |
2048 | } | ||
2049 | 2108 | ||
2050 | // Handle god perms | 2109 | // Handle god perms |
2051 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 2110 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
2052 | { | 2111 | { |
2053 | permissionToTake = true; | 2112 | permissionToTake = true; |
2054 | permissionToTakeCopy = true; | 2113 | permissionToTakeCopy = true; |
2055 | permissionToDelete = true; | 2114 | permissionToDelete = true; |
2056 | } | 2115 | } |
2057 | 2116 | ||
2058 | // If we're re-saving, we don't even want to delete | 2117 | // If we're re-saving, we don't even want to delete |
2059 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | 2118 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
2060 | permissionToDelete = false; | 2119 | permissionToDelete = false; |
2061 | 2120 | ||
2062 | // if we want to take a copy, we also don't want to delete | 2121 | // if we want to take a copy, we also don't want to delete |
2063 | // Note: after this point, the permissionToTakeCopy flag | 2122 | // Note: after this point, the permissionToTakeCopy flag |
2064 | // becomes irrelevant. It already includes the permissionToTake | 2123 | // becomes irrelevant. It already includes the permissionToTake |
2065 | // permission and after excluding no copy items here, we can | 2124 | // permission and after excluding no copy items here, we can |
2066 | // just use that. | 2125 | // just use that. |
2067 | if (action == DeRezAction.TakeCopy) | 2126 | if (action == DeRezAction.TakeCopy) |
2068 | { | 2127 | { |
2069 | // If we don't have permission, stop right here | 2128 | // If we don't have permission, stop right here |
2070 | if (!permissionToTakeCopy) | 2129 | if (!permissionToTakeCopy) |
2071 | return; | 2130 | return; |
2072 | 2131 | ||
2073 | permissionToTake = true; | 2132 | permissionToTake = true; |
2074 | // Don't delete | 2133 | // Don't delete |
2075 | permissionToDelete = false; | 2134 | permissionToDelete = false; |
2076 | } | 2135 | } |
2077 | 2136 | ||
2078 | if (action == DeRezAction.Return) | 2137 | if (action == DeRezAction.Return) |
2079 | { | ||
2080 | if (remoteClient != null) | ||
2081 | { | 2138 | { |
2082 | if (Permissions.CanReturnObjects( | 2139 | if (remoteClient != null) |
2083 | null, | ||
2084 | remoteClient.AgentId, | ||
2085 | deleteGroups)) | ||
2086 | { | 2140 | { |
2087 | permissionToTake = true; | 2141 | if (Permissions.CanReturnObjects( |
2088 | permissionToDelete = true; | 2142 | null, |
2089 | 2143 | remoteClient.AgentId, | |
2090 | foreach (SceneObjectGroup g in deleteGroups) | 2144 | new List<SceneObjectGroup>() {grp})) |
2091 | { | 2145 | { |
2092 | AddReturn(g.OwnerID == g.GroupID ? g.LastOwnerID : g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 2146 | permissionToTake = true; |
2147 | permissionToDelete = true; | ||
2148 | |||
2149 | AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
2093 | } | 2150 | } |
2094 | } | 2151 | } |
2152 | else // Auto return passes through here with null agent | ||
2153 | { | ||
2154 | permissionToTake = true; | ||
2155 | permissionToDelete = true; | ||
2156 | } | ||
2095 | } | 2157 | } |
2096 | else // Auto return passes through here with null agent | 2158 | |
2159 | if (permissionToTake && (!permissionToDelete)) | ||
2160 | takeGroups.Add(grp); | ||
2161 | |||
2162 | if (permissionToDelete) | ||
2097 | { | 2163 | { |
2098 | permissionToTake = true; | 2164 | if (permissionToTake) |
2099 | permissionToDelete = true; | 2165 | deleteGroups.Add(grp); |
2166 | deleteIDs.Add(grp.LocalId); | ||
2100 | } | 2167 | } |
2101 | } | 2168 | } |
2102 | 2169 | ||
2103 | if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) | 2170 | SendKillObject(deleteIDs); |
2171 | |||
2172 | if (deleteGroups.Count > 0) | ||
2104 | { | 2173 | { |
2174 | foreach (SceneObjectGroup g in deleteGroups) | ||
2175 | deleteIDs.Remove(g.LocalId); | ||
2176 | |||
2105 | m_asyncSceneObjectDeleter.DeleteToInventory( | 2177 | m_asyncSceneObjectDeleter.DeleteToInventory( |
2106 | action, destinationID, deleteGroups, remoteClient, | 2178 | action, destinationID, deleteGroups, remoteClient, |
2107 | permissionToDelete); | 2179 | true); |
2180 | } | ||
2181 | if (takeGroups.Count > 0) | ||
2182 | { | ||
2183 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
2184 | action, destinationID, takeGroups, remoteClient, | ||
2185 | false); | ||
2108 | } | 2186 | } |
2109 | else if (permissionToDelete) | 2187 | if (deleteIDs.Count > 0) |
2110 | { | 2188 | { |
2111 | foreach (SceneObjectGroup g in deleteGroups) | 2189 | foreach (SceneObjectGroup g in deleteGroups) |
2112 | DeleteSceneObject(g, false); | 2190 | DeleteSceneObject(g, true); |
2191 | } | ||
2192 | } | ||
2193 | |||
2194 | public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) | ||
2195 | { | ||
2196 | itemID = UUID.Zero; | ||
2197 | if (grp != null) | ||
2198 | { | ||
2199 | Vector3 inventoryStoredPosition = new Vector3 | ||
2200 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
2201 | ? 250 | ||
2202 | : grp.AbsolutePosition.X) | ||
2203 | , | ||
2204 | (grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
2205 | ? 250 | ||
2206 | : grp.AbsolutePosition.X, | ||
2207 | grp.AbsolutePosition.Z); | ||
2208 | |||
2209 | Vector3 originalPosition = grp.AbsolutePosition; | ||
2210 | |||
2211 | grp.AbsolutePosition = inventoryStoredPosition; | ||
2212 | |||
2213 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
2214 | |||
2215 | grp.AbsolutePosition = originalPosition; | ||
2216 | |||
2217 | AssetBase asset = CreateAsset( | ||
2218 | grp.GetPartName(grp.LocalId), | ||
2219 | grp.GetPartDescription(grp.LocalId), | ||
2220 | (sbyte)AssetType.Object, | ||
2221 | Utils.StringToBytes(sceneObjectXml), | ||
2222 | remoteClient.AgentId); | ||
2223 | AssetService.Store(asset); | ||
2224 | |||
2225 | InventoryItemBase item = new InventoryItemBase(); | ||
2226 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
2227 | item.CreatorData = grp.RootPart.CreatorData; | ||
2228 | item.Owner = remoteClient.AgentId; | ||
2229 | item.ID = UUID.Random(); | ||
2230 | item.AssetID = asset.FullID; | ||
2231 | item.Description = asset.Description; | ||
2232 | item.Name = asset.Name; | ||
2233 | item.AssetType = asset.Type; | ||
2234 | item.InvType = (int)InventoryType.Object; | ||
2235 | |||
2236 | InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
2237 | if (folder != null) | ||
2238 | item.Folder = folder.ID; | ||
2239 | else // oopsies | ||
2240 | item.Folder = UUID.Zero; | ||
2241 | |||
2242 | // Set up base perms properly | ||
2243 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
2244 | permsBase &= grp.RootPart.BaseMask; | ||
2245 | permsBase |= (uint)PermissionMask.Move; | ||
2246 | |||
2247 | // Make sure we don't lock it | ||
2248 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
2249 | |||
2250 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
2251 | { | ||
2252 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2253 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2254 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2255 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
2256 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
2257 | } | ||
2258 | else | ||
2259 | { | ||
2260 | item.BasePermissions = permsBase; | ||
2261 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; | ||
2262 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2263 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; | ||
2264 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; | ||
2265 | } | ||
2266 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
2267 | |||
2268 | // sets itemID so client can show item as 'attached' in inventory | ||
2269 | grp.FromItemID = item.ID; | ||
2270 | |||
2271 | if (AddInventoryItem(item)) | ||
2272 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
2273 | else | ||
2274 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
2275 | |||
2276 | itemID = item.ID; | ||
2277 | return item.AssetID; | ||
2113 | } | 2278 | } |
2279 | return UUID.Zero; | ||
2114 | } | 2280 | } |
2115 | 2281 | ||
2116 | /// <summary> | 2282 | /// <summary> |
@@ -2240,6 +2406,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2240 | 2406 | ||
2241 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2407 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2242 | { | 2408 | { |
2409 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2410 | return; | ||
2411 | |||
2243 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2412 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2244 | if (part == null) | 2413 | if (part == null) |
2245 | return; | 2414 | return; |
@@ -2296,7 +2465,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2296 | } | 2465 | } |
2297 | else | 2466 | else |
2298 | { | 2467 | { |
2299 | if (!Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) | 2468 | if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId) |
2469 | continue; | ||
2470 | |||
2471 | if (!Permissions.CanTransferObject(sog.UUID, groupID)) | ||
2300 | continue; | 2472 | continue; |
2301 | 2473 | ||
2302 | if (sog.GroupID != groupID) | 2474 | if (sog.GroupID != groupID) |
@@ -2408,6 +2580,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2408 | } | 2580 | } |
2409 | 2581 | ||
2410 | m_sceneGraph.LinkObjects(root, children); | 2582 | m_sceneGraph.LinkObjects(root, children); |
2583 | |||
2584 | ScenePresence sp; | ||
2585 | if (TryGetScenePresence(agentId, out sp)) | ||
2586 | { | ||
2587 | root.SendPropertiesToClient(sp.ControllingClient); | ||
2588 | } | ||
2411 | } | 2589 | } |
2412 | 2590 | ||
2413 | private string PermissionString(uint permissions) | 2591 | private string PermissionString(uint permissions) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index df43271..ce6415a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
50 | /// <param name='targetID'></param> | 50 | /// <param name='targetID'></param> |
51 | /// <param name='fromAgent'></param> | 51 | /// <param name='fromAgent'></param> |
52 | /// <param name='broadcast'></param> | 52 | /// <param name='broadcast'></param> |
53 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 53 | public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
54 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) | 54 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) |
55 | { | 55 | { |
56 | OSChatMessage args = new OSChatMessage(); | 56 | OSChatMessage args = new OSChatMessage(); |
@@ -61,6 +61,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
61 | args.Position = fromPos; | 61 | args.Position = fromPos; |
62 | args.SenderUUID = fromID; | 62 | args.SenderUUID = fromID; |
63 | args.Scene = this; | 63 | args.Scene = this; |
64 | args.Destination = targetID; | ||
64 | 65 | ||
65 | if (fromAgent) | 66 | if (fromAgent) |
66 | { | 67 | { |
@@ -75,7 +76,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
75 | } | 76 | } |
76 | 77 | ||
77 | args.From = fromName; | 78 | args.From = fromName; |
78 | args.TargetUUID = targetID; | 79 | //args. |
79 | 80 | ||
80 | // m_log.DebugFormat( | 81 | // m_log.DebugFormat( |
81 | // "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}", | 82 | // "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}", |
@@ -86,7 +87,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
86 | else | 87 | else |
87 | EventManager.TriggerOnChatFromWorld(this, args); | 88 | EventManager.TriggerOnChatFromWorld(this, args); |
88 | } | 89 | } |
89 | 90 | ||
90 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 91 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
91 | UUID fromID, bool fromAgent, bool broadcast) | 92 | UUID fromID, bool fromAgent, bool broadcast) |
92 | { | 93 | { |
@@ -130,19 +131,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
130 | { | 131 | { |
131 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); | 132 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); |
132 | } | 133 | } |
133 | /// <summary> | ||
134 | /// | ||
135 | /// </summary> | ||
136 | /// <param name="message"></param> | ||
137 | /// <param name="type"></param> | ||
138 | /// <param name="fromPos"></param> | ||
139 | /// <param name="fromName"></param> | ||
140 | /// <param name="fromAgentID"></param> | ||
141 | /// <param name="targetID"></param> | ||
142 | public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent) | ||
143 | { | ||
144 | SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false); | ||
145 | } | ||
146 | 134 | ||
147 | /// <summary> | 135 | /// <summary> |
148 | /// Invoked when the client requests a prim. | 136 | /// Invoked when the client requests a prim. |
@@ -164,27 +152,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
164 | /// <param name="remoteClient"></param> | 152 | /// <param name="remoteClient"></param> |
165 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) | 153 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) |
166 | { | 154 | { |
155 | /* | ||
156 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | ||
157 | |||
158 | if (null == part) | ||
159 | return; | ||
160 | |||
161 | if (part.IsRoot) | ||
162 | { | ||
163 | SceneObjectGroup sog = part.ParentGroup; | ||
164 | sog.SendPropertiesToClient(remoteClient); | ||
165 | |||
166 | // A prim is only tainted if it's allowed to be edited by the person clicking it. | ||
167 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) | ||
168 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) | ||
169 | { | ||
170 | sog.IsSelected = true; | ||
171 | EventManager.TriggerParcelPrimCountTainted(); | ||
172 | } | ||
173 | } | ||
174 | else | ||
175 | { | ||
176 | part.SendPropertiesToClient(remoteClient); | ||
177 | } | ||
178 | */ | ||
167 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | 179 | SceneObjectPart part = GetSceneObjectPart(primLocalID); |
168 | 180 | ||
169 | if (null == part) | 181 | if (null == part) |
170 | return; | 182 | return; |
171 | 183 | ||
172 | if (part.IsRoot) | 184 | SceneObjectGroup sog = part.ParentGroup; |
173 | { | 185 | if (sog == null) |
174 | SceneObjectGroup sog = part.ParentGroup; | 186 | return; |
175 | sog.SendPropertiesToClient(remoteClient); | ||
176 | sog.IsSelected = true; | ||
177 | 187 | ||
178 | // A prim is only tainted if it's allowed to be edited by the person clicking it. | 188 | part.SendPropertiesToClient(remoteClient); |
179 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) | 189 | |
180 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) | 190 | // A prim is only tainted if it's allowed to be edited by the person clicking it. |
181 | { | 191 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) |
182 | EventManager.TriggerParcelPrimCountTainted(); | 192 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) |
183 | } | ||
184 | } | ||
185 | else | ||
186 | { | 193 | { |
187 | part.SendPropertiesToClient(remoteClient); | 194 | part.IsSelected = true; |
195 | EventManager.TriggerParcelPrimCountTainted(); | ||
188 | } | 196 | } |
189 | } | 197 | } |
190 | 198 | ||
@@ -237,7 +245,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
237 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | 245 | SceneObjectPart part = GetSceneObjectPart(primLocalID); |
238 | if (part == null) | 246 | if (part == null) |
239 | return; | 247 | return; |
240 | 248 | /* | |
241 | // A deselect packet contains all the local prims being deselected. However, since selection is still | 249 | // A deselect packet contains all the local prims being deselected. However, since selection is still |
242 | // group based we only want the root prim to trigger a full update - otherwise on objects with many prims | 250 | // group based we only want the root prim to trigger a full update - otherwise on objects with many prims |
243 | // we end up sending many duplicate ObjectUpdates | 251 | // we end up sending many duplicate ObjectUpdates |
@@ -250,7 +258,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
250 | // handled by group, but by prim. Legacy cruft. | 258 | // handled by group, but by prim. Legacy cruft. |
251 | // TODO: Make selection flagging per prim! | 259 | // TODO: Make selection flagging per prim! |
252 | // | 260 | // |
253 | part.ParentGroup.IsSelected = false; | 261 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) |
262 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
263 | part.ParentGroup.IsSelected = false; | ||
254 | 264 | ||
255 | if (part.ParentGroup.IsAttachment) | 265 | if (part.ParentGroup.IsAttachment) |
256 | isAttachment = true; | 266 | isAttachment = true; |
@@ -270,6 +280,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
270 | part.UUID, remoteClient.AgentId)) | 280 | part.UUID, remoteClient.AgentId)) |
271 | EventManager.TriggerParcelPrimCountTainted(); | 281 | EventManager.TriggerParcelPrimCountTainted(); |
272 | } | 282 | } |
283 | */ | ||
284 | |||
285 | bool oldgprSelect = part.ParentGroup.IsSelected; | ||
286 | |||
287 | // This is wrong, wrong, wrong. Selection should not be | ||
288 | // handled by group, but by prim. Legacy cruft. | ||
289 | // TODO: Make selection flagging per prim! | ||
290 | // | ||
291 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) | ||
292 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
293 | { | ||
294 | part.IsSelected = false; | ||
295 | if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) | ||
296 | EventManager.TriggerParcelPrimCountTainted(); | ||
297 | } | ||
298 | |||
273 | } | 299 | } |
274 | 300 | ||
275 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, | 301 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, |
@@ -412,6 +438,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
412 | ); | 438 | ); |
413 | } | 439 | } |
414 | 440 | ||
441 | private class DescendentsRequestData | ||
442 | { | ||
443 | public IClientAPI RemoteClient; | ||
444 | public UUID FolderID; | ||
445 | public UUID OwnerID; | ||
446 | public bool FetchFolders; | ||
447 | public bool FetchItems; | ||
448 | public int SortOrder; | ||
449 | } | ||
450 | |||
451 | private Queue<DescendentsRequestData> m_descendentsRequestQueue = new Queue<DescendentsRequestData>(); | ||
452 | private Object m_descendentsRequestLock = new Object(); | ||
453 | private bool m_descendentsRequestProcessing = false; | ||
454 | |||
415 | /// <summary> | 455 | /// <summary> |
416 | /// Tell the client about the various child items and folders contained in the requested folder. | 456 | /// Tell the client about the various child items and folders contained in the requested folder. |
417 | /// </summary> | 457 | /// </summary> |
@@ -448,17 +488,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
448 | } | 488 | } |
449 | } | 489 | } |
450 | 490 | ||
451 | // We're going to send the reply async, because there may be | 491 | lock (m_descendentsRequestLock) |
452 | // an enormous quantity of packets -- basically the entire inventory! | 492 | { |
453 | // We don't want to block the client thread while all that is happening. | 493 | if (!m_descendentsRequestProcessing) |
454 | SendInventoryDelegate d = SendInventoryAsync; | 494 | { |
455 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | 495 | m_descendentsRequestProcessing = true; |
496 | |||
497 | // We're going to send the reply async, because there may be | ||
498 | // an enormous quantity of packets -- basically the entire inventory! | ||
499 | // We don't want to block the client thread while all that is happening. | ||
500 | SendInventoryDelegate d = SendInventoryAsync; | ||
501 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | ||
502 | |||
503 | return; | ||
504 | } | ||
505 | |||
506 | DescendentsRequestData req = new DescendentsRequestData(); | ||
507 | req.RemoteClient = remoteClient; | ||
508 | req.FolderID = folderID; | ||
509 | req.OwnerID = ownerID; | ||
510 | req.FetchFolders = fetchFolders; | ||
511 | req.FetchItems = fetchItems; | ||
512 | req.SortOrder = sortOrder; | ||
513 | |||
514 | m_descendentsRequestQueue.Enqueue(req); | ||
515 | } | ||
456 | } | 516 | } |
457 | 517 | ||
458 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); | 518 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); |
459 | 519 | ||
460 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) | 520 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) |
461 | { | 521 | { |
522 | Thread.Sleep(20); | ||
462 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); | 523 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); |
463 | } | 524 | } |
464 | 525 | ||
@@ -466,6 +527,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
466 | { | 527 | { |
467 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; | 528 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; |
468 | d.EndInvoke(iar); | 529 | d.EndInvoke(iar); |
530 | |||
531 | lock (m_descendentsRequestLock) | ||
532 | { | ||
533 | if (m_descendentsRequestQueue.Count > 0) | ||
534 | { | ||
535 | DescendentsRequestData req = m_descendentsRequestQueue.Dequeue(); | ||
536 | |||
537 | d = SendInventoryAsync; | ||
538 | d.BeginInvoke(req.RemoteClient, req.FolderID, req.OwnerID, req.FetchFolders, req.FetchItems, req.SortOrder, SendInventoryComplete, d); | ||
539 | |||
540 | return; | ||
541 | } | ||
542 | |||
543 | m_descendentsRequestProcessing = false; | ||
544 | } | ||
469 | } | 545 | } |
470 | 546 | ||
471 | /// <summary> | 547 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a9f8a85..436a544 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -227,8 +227,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
227 | // TODO: need to figure out how allow client agents but deny | 227 | // TODO: need to figure out how allow client agents but deny |
228 | // root agents when ACL denies access to root agent | 228 | // root agents when ACL denies access to root agent |
229 | public bool m_strictAccessControl = true; | 229 | public bool m_strictAccessControl = true; |
230 | 230 | public bool m_seeIntoBannedRegion = false; | |
231 | public int MaxUndoCount { get; set; } | 231 | public int MaxUndoCount = 5; |
232 | 232 | ||
233 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 233 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
234 | public bool LoginLock = false; | 234 | public bool LoginLock = false; |
@@ -244,11 +244,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
244 | 244 | ||
245 | protected int m_splitRegionID; | 245 | protected int m_splitRegionID; |
246 | protected Timer m_restartWaitTimer = new Timer(); | 246 | protected Timer m_restartWaitTimer = new Timer(); |
247 | protected Timer m_timerWatchdog = new Timer(); | ||
247 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 248 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
248 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 249 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
249 | protected string m_simulatorVersion = "OpenSimulator Server"; | 250 | protected string m_simulatorVersion = "OpenSimulator Server"; |
250 | protected AgentCircuitManager m_authenticateHandler; | 251 | protected AgentCircuitManager m_authenticateHandler; |
251 | protected SceneCommunicationService m_sceneGridService; | 252 | protected SceneCommunicationService m_sceneGridService; |
253 | protected ISnmpModule m_snmpService = null; | ||
252 | 254 | ||
253 | protected ISimulationDataService m_SimulationDataService; | 255 | protected ISimulationDataService m_SimulationDataService; |
254 | protected IEstateDataService m_EstateDataService; | 256 | protected IEstateDataService m_EstateDataService; |
@@ -311,8 +313,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
311 | private int m_update_presences = 1; // Update scene presence movements | 313 | private int m_update_presences = 1; // Update scene presence movements |
312 | private int m_update_events = 1; | 314 | private int m_update_events = 1; |
313 | private int m_update_backup = 200; | 315 | private int m_update_backup = 200; |
314 | private int m_update_terrain = 50; | 316 | private int m_update_terrain = 1000; |
315 | // private int m_update_land = 1; | 317 | private int m_update_land = 10; |
316 | private int m_update_coarse_locations = 50; | 318 | private int m_update_coarse_locations = 50; |
317 | 319 | ||
318 | private int agentMS; | 320 | private int agentMS; |
@@ -325,13 +327,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
325 | private int backupMS; | 327 | private int backupMS; |
326 | private int terrainMS; | 328 | private int terrainMS; |
327 | private int landMS; | 329 | private int landMS; |
328 | private int spareMS; | ||
329 | 330 | ||
330 | /// <summary> | 331 | /// <summary> |
331 | /// Tick at which the last frame was processed. | 332 | /// Tick at which the last frame was processed. |
332 | /// </summary> | 333 | /// </summary> |
333 | private int m_lastFrameTick; | 334 | private int m_lastFrameTick; |
334 | 335 | ||
336 | public bool CombineRegions = false; | ||
335 | /// <summary> | 337 | /// <summary> |
336 | /// Tick at which the last maintenance run occurred. | 338 | /// Tick at which the last maintenance run occurred. |
337 | /// </summary> | 339 | /// </summary> |
@@ -351,7 +353,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
351 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 353 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
352 | private volatile bool m_backingup; | 354 | private volatile bool m_backingup; |
353 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 355 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
354 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); | 356 | private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); |
355 | 357 | ||
356 | private string m_defaultScriptEngine; | 358 | private string m_defaultScriptEngine; |
357 | 359 | ||
@@ -360,6 +362,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
360 | /// </summary> | 362 | /// </summary> |
361 | private int m_LastLogin; | 363 | private int m_LastLogin; |
362 | 364 | ||
365 | private int m_lastIncoming; | ||
366 | private int m_lastOutgoing; | ||
367 | private int m_hbRestarts = 0; | ||
368 | |||
369 | |||
363 | /// <summary> | 370 | /// <summary> |
364 | /// Thread that runs the scene loop. | 371 | /// Thread that runs the scene loop. |
365 | /// </summary> | 372 | /// </summary> |
@@ -402,7 +409,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
402 | private volatile bool m_active; | 409 | private volatile bool m_active; |
403 | 410 | ||
404 | // private int m_lastUpdate; | 411 | // private int m_lastUpdate; |
405 | // private bool m_firstHeartbeat = true; | 412 | private bool m_firstHeartbeat = true; |
406 | 413 | ||
407 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 414 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
408 | private bool m_reprioritizationEnabled = true; | 415 | private bool m_reprioritizationEnabled = true; |
@@ -446,6 +453,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
446 | get { return m_sceneGridService; } | 453 | get { return m_sceneGridService; } |
447 | } | 454 | } |
448 | 455 | ||
456 | public ISnmpModule SnmpService | ||
457 | { | ||
458 | get | ||
459 | { | ||
460 | if (m_snmpService == null) | ||
461 | { | ||
462 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
463 | } | ||
464 | |||
465 | return m_snmpService; | ||
466 | } | ||
467 | } | ||
468 | |||
449 | public ISimulationDataService SimulationDataService | 469 | public ISimulationDataService SimulationDataService |
450 | { | 470 | { |
451 | get | 471 | get |
@@ -738,6 +758,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
738 | m_SimulationDataService = simDataService; | 758 | m_SimulationDataService = simDataService; |
739 | m_EstateDataService = estateDataService; | 759 | m_EstateDataService = estateDataService; |
740 | m_regionHandle = RegionInfo.RegionHandle; | 760 | m_regionHandle = RegionInfo.RegionHandle; |
761 | m_lastIncoming = 0; | ||
762 | m_lastOutgoing = 0; | ||
741 | 763 | ||
742 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 764 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
743 | m_asyncSceneObjectDeleter.Enabled = true; | 765 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -831,7 +853,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
831 | 853 | ||
832 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | 854 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); |
833 | 855 | ||
834 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | 856 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
835 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); | 857 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); |
836 | if (!UseBackup) | 858 | if (!UseBackup) |
837 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 859 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
@@ -839,10 +861,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
839 | //Animation states | 861 | //Animation states |
840 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 862 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
841 | 863 | ||
842 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); | 864 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
843 | 865 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); | |
844 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | ||
845 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | ||
846 | 866 | ||
847 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); | 867 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); |
848 | if (RegionInfo.NonphysPrimMin > 0) | 868 | if (RegionInfo.NonphysPrimMin > 0) |
@@ -863,11 +883,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
863 | } | 883 | } |
864 | 884 | ||
865 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 885 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
886 | |||
866 | if (RegionInfo.PhysPrimMax > 0) | 887 | if (RegionInfo.PhysPrimMax > 0) |
867 | { | 888 | { |
868 | m_maxPhys = RegionInfo.PhysPrimMax; | 889 | m_maxPhys = RegionInfo.PhysPrimMax; |
869 | } | 890 | } |
870 | 891 | ||
892 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | ||
893 | if (RegionInfo.LinksetCapacity > 0) | ||
894 | { | ||
895 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
896 | } | ||
897 | |||
898 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
899 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
900 | |||
871 | // Here, if clamping is requested in either global or | 901 | // Here, if clamping is requested in either global or |
872 | // local config, it will be used | 902 | // local config, it will be used |
873 | // | 903 | // |
@@ -877,13 +907,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
877 | m_clampPrimSize = true; | 907 | m_clampPrimSize = true; |
878 | } | 908 | } |
879 | 909 | ||
880 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | 910 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
881 | if (RegionInfo.LinksetCapacity > 0) | ||
882 | { | ||
883 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
884 | } | ||
885 | |||
886 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | ||
887 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 911 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
888 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 912 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
889 | m_dontPersistBefore = | 913 | m_dontPersistBefore = |
@@ -894,11 +918,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
894 | m_persistAfter *= 10000000; | 918 | m_persistAfter *= 10000000; |
895 | 919 | ||
896 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 920 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
897 | 921 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | |
898 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
899 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
900 | 922 | ||
901 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 923 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
924 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
925 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
902 | 926 | ||
903 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; | 927 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; |
904 | 928 | ||
@@ -943,7 +967,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
943 | 967 | ||
944 | if (grant.Length > 0) | 968 | if (grant.Length > 0) |
945 | { | 969 | { |
946 | foreach (string viewer in grant.Split('|')) | 970 | foreach (string viewer in grant.Split(',')) |
947 | { | 971 | { |
948 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 972 | m_AllowedViewers.Add(viewer.Trim().ToLower()); |
949 | } | 973 | } |
@@ -955,7 +979,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
955 | 979 | ||
956 | if (grant.Length > 0) | 980 | if (grant.Length > 0) |
957 | { | 981 | { |
958 | foreach (string viewer in grant.Split('|')) | 982 | foreach (string viewer in grant.Split(',')) |
959 | { | 983 | { |
960 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 984 | m_BannedViewers.Add(viewer.Trim().ToLower()); |
961 | } | 985 | } |
@@ -1015,6 +1039,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1015 | StatsReporter = new SimStatsReporter(this); | 1039 | StatsReporter = new SimStatsReporter(this); |
1016 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1040 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
1017 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1041 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1042 | |||
1043 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | ||
1018 | } | 1044 | } |
1019 | 1045 | ||
1020 | public Scene(RegionInfo regInfo) : base(regInfo) | 1046 | public Scene(RegionInfo regInfo) : base(regInfo) |
@@ -1310,8 +1336,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1310 | // Stop all client threads. | 1336 | // Stop all client threads. |
1311 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); | 1337 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); |
1312 | 1338 | ||
1313 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1339 | m_log.Debug("[SCENE]: TriggerSceneShuttingDown"); |
1314 | EventManager.TriggerSceneShuttingDown(this); | 1340 | EventManager.TriggerSceneShuttingDown(this); |
1341 | |||
1342 | m_log.Debug("[SCENE]: Persisting changed objects"); | ||
1343 | |||
1315 | Backup(false); | 1344 | Backup(false); |
1316 | m_sceneGraph.Close(); | 1345 | m_sceneGraph.Close(); |
1317 | 1346 | ||
@@ -1325,6 +1354,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1325 | // attempt to reference a null or disposed physics scene. | 1354 | // attempt to reference a null or disposed physics scene. |
1326 | if (PhysicsScene != null) | 1355 | if (PhysicsScene != null) |
1327 | { | 1356 | { |
1357 | m_log.Debug("[SCENE]: Dispose Physics"); | ||
1328 | PhysicsScene phys = PhysicsScene; | 1358 | PhysicsScene phys = PhysicsScene; |
1329 | // remove the physics engine from both Scene and SceneGraph | 1359 | // remove the physics engine from both Scene and SceneGraph |
1330 | PhysicsScene = null; | 1360 | PhysicsScene = null; |
@@ -1355,11 +1385,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1355 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1385 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1356 | if (m_heartbeatThread != null) | 1386 | if (m_heartbeatThread != null) |
1357 | { | 1387 | { |
1388 | m_hbRestarts++; | ||
1389 | if(m_hbRestarts > 10) | ||
1390 | Environment.Exit(1); | ||
1391 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1392 | |||
1393 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1394 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1395 | //proc.EnableRaisingEvents=false; | ||
1396 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1397 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1398 | //proc.Start(); | ||
1399 | //proc.WaitForExit(); | ||
1400 | //Thread.Sleep(1000); | ||
1401 | //Environment.Exit(1); | ||
1358 | m_heartbeatThread.Abort(); | 1402 | m_heartbeatThread.Abort(); |
1403 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1359 | m_heartbeatThread = null; | 1404 | m_heartbeatThread = null; |
1360 | } | 1405 | } |
1361 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1406 | // m_lastUpdate = Util.EnvironmentTickCount(); |
1362 | 1407 | ||
1408 | // m_sceneGraph.PreparePhysicsSimulation(); | ||
1409 | |||
1410 | |||
1363 | m_heartbeatThread | 1411 | m_heartbeatThread |
1364 | = Watchdog.StartThread( | 1412 | = Watchdog.StartThread( |
1365 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); | 1413 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); |
@@ -1504,16 +1552,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1504 | endFrame = Frame + frames; | 1552 | endFrame = Frame + frames; |
1505 | 1553 | ||
1506 | float physicsFPS = 0f; | 1554 | float physicsFPS = 0f; |
1507 | int previousFrameTick, tmpMS; | 1555 | int tmpMS; |
1508 | int maintc = Util.EnvironmentTickCount(); | 1556 | int previousFrameTick; |
1557 | int maintc; | ||
1558 | int sleepMS; | ||
1559 | int framestart; | ||
1509 | 1560 | ||
1510 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) | 1561 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) |
1511 | { | 1562 | { |
1563 | framestart = Util.EnvironmentTickCount(); | ||
1512 | ++Frame; | 1564 | ++Frame; |
1513 | 1565 | ||
1514 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1566 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1515 | 1567 | ||
1516 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; | 1568 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
1517 | 1569 | ||
1518 | try | 1570 | try |
1519 | { | 1571 | { |
@@ -1567,6 +1619,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1567 | m_sceneGraph.UpdatePresences(); | 1619 | m_sceneGraph.UpdatePresences(); |
1568 | 1620 | ||
1569 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); | 1621 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1622 | |||
1570 | 1623 | ||
1571 | // Delete temp-on-rez stuff | 1624 | // Delete temp-on-rez stuff |
1572 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | 1625 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) |
@@ -1648,34 +1701,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1648 | 1701 | ||
1649 | Watchdog.UpdateThread(); | 1702 | Watchdog.UpdateThread(); |
1650 | 1703 | ||
1704 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1705 | |||
1706 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1707 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1708 | StatsReporter.AddFPS(1); | ||
1709 | |||
1710 | StatsReporter.addAgentMS(agentMS); | ||
1711 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1712 | StatsReporter.addOtherMS(otherMS); | ||
1713 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1714 | |||
1651 | previousFrameTick = m_lastFrameTick; | 1715 | previousFrameTick = m_lastFrameTick; |
1652 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1716 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1653 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1717 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1654 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1718 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1655 | 1719 | ||
1720 | m_firstHeartbeat = false; | ||
1721 | |||
1722 | sleepMS = Util.EnvironmentTickCount(); | ||
1723 | |||
1656 | if (tmpMS > 0) | 1724 | if (tmpMS > 0) |
1657 | { | ||
1658 | Thread.Sleep(tmpMS); | 1725 | Thread.Sleep(tmpMS); |
1659 | spareMS += tmpMS; | ||
1660 | } | ||
1661 | 1726 | ||
1662 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | 1727 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); |
1663 | maintc = Util.EnvironmentTickCount(); | 1728 | frameMS = Util.EnvironmentTickCountSubtract(framestart); |
1664 | 1729 | StatsReporter.addSleepMS(sleepMS); | |
1665 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1730 | StatsReporter.addFrameMS(frameMS); |
1666 | 1731 | ||
1667 | // if (Frame%m_update_avatars == 0) | 1732 | // if (Frame%m_update_avatars == 0) |
1668 | // UpdateInWorldTime(); | 1733 | // UpdateInWorldTime(); |
1669 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1670 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1671 | StatsReporter.AddFPS(1); | ||
1672 | 1734 | ||
1673 | StatsReporter.addFrameMS(frameMS); | ||
1674 | StatsReporter.addAgentMS(agentMS); | ||
1675 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1676 | StatsReporter.addOtherMS(otherMS); | ||
1677 | StatsReporter.AddSpareMS(spareMS); | ||
1678 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1679 | 1735 | ||
1680 | // Optionally warn if a frame takes double the amount of time that it should. | 1736 | // Optionally warn if a frame takes double the amount of time that it should. |
1681 | if (DebugUpdates | 1737 | if (DebugUpdates |
@@ -1692,7 +1748,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1692 | public void AddGroupTarget(SceneObjectGroup grp) | 1748 | public void AddGroupTarget(SceneObjectGroup grp) |
1693 | { | 1749 | { |
1694 | lock (m_groupsWithTargets) | 1750 | lock (m_groupsWithTargets) |
1695 | m_groupsWithTargets[grp.UUID] = grp; | 1751 | m_groupsWithTargets[grp.UUID] = 0; |
1696 | } | 1752 | } |
1697 | 1753 | ||
1698 | public void RemoveGroupTarget(SceneObjectGroup grp) | 1754 | public void RemoveGroupTarget(SceneObjectGroup grp) |
@@ -1703,18 +1759,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1703 | 1759 | ||
1704 | private void CheckAtTargets() | 1760 | private void CheckAtTargets() |
1705 | { | 1761 | { |
1706 | List<SceneObjectGroup> objs = null; | 1762 | List<UUID> objs = null; |
1707 | 1763 | ||
1708 | lock (m_groupsWithTargets) | 1764 | lock (m_groupsWithTargets) |
1709 | { | 1765 | { |
1710 | if (m_groupsWithTargets.Count != 0) | 1766 | if (m_groupsWithTargets.Count != 0) |
1711 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); | 1767 | objs = new List<UUID>(m_groupsWithTargets.Keys); |
1712 | } | 1768 | } |
1713 | 1769 | ||
1714 | if (objs != null) | 1770 | if (objs != null) |
1715 | { | 1771 | { |
1716 | foreach (SceneObjectGroup entry in objs) | 1772 | foreach (UUID entry in objs) |
1717 | entry.checkAtTargets(); | 1773 | { |
1774 | SceneObjectGroup grp = GetSceneObjectGroup(entry); | ||
1775 | if (grp == null) | ||
1776 | m_groupsWithTargets.Remove(entry); | ||
1777 | else | ||
1778 | grp.checkAtTargets(); | ||
1779 | } | ||
1718 | } | 1780 | } |
1719 | } | 1781 | } |
1720 | 1782 | ||
@@ -1793,7 +1855,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1793 | msg.fromAgentName = "Server"; | 1855 | msg.fromAgentName = "Server"; |
1794 | msg.dialog = (byte)19; // Object msg | 1856 | msg.dialog = (byte)19; // Object msg |
1795 | msg.fromGroup = false; | 1857 | msg.fromGroup = false; |
1796 | msg.offline = (byte)0; | 1858 | msg.offline = (byte)1; |
1797 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1859 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1798 | msg.Position = Vector3.Zero; | 1860 | msg.Position = Vector3.Zero; |
1799 | msg.RegionID = RegionInfo.RegionID.Guid; | 1861 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -2022,7 +2084,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2022 | return PhysicsScene.SupportsRaycastWorldFiltered(); | 2084 | return PhysicsScene.SupportsRaycastWorldFiltered(); |
2023 | } | 2085 | } |
2024 | 2086 | ||
2025 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | 2087 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) |
2026 | { | 2088 | { |
2027 | if (PhysicsScene == null) | 2089 | if (PhysicsScene == null) |
2028 | return null; | 2090 | return null; |
@@ -2044,14 +2106,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2044 | /// <returns></returns> | 2106 | /// <returns></returns> |
2045 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 2107 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
2046 | { | 2108 | { |
2109 | |||
2110 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
2111 | Vector3 wpos = Vector3.Zero; | ||
2112 | // Check for water surface intersection from above | ||
2113 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
2114 | { | ||
2115 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
2116 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
2117 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
2118 | wpos.Z = wheight; | ||
2119 | } | ||
2120 | |||
2047 | Vector3 pos = Vector3.Zero; | 2121 | Vector3 pos = Vector3.Zero; |
2048 | if (RayEndIsIntersection == (byte)1) | 2122 | if (RayEndIsIntersection == (byte)1) |
2049 | { | 2123 | { |
2050 | pos = RayEnd; | 2124 | pos = RayEnd; |
2051 | return pos; | ||
2052 | } | 2125 | } |
2053 | 2126 | else if (RayTargetID != UUID.Zero) | |
2054 | if (RayTargetID != UUID.Zero) | ||
2055 | { | 2127 | { |
2056 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 2128 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
2057 | 2129 | ||
@@ -2073,7 +2145,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2073 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 2145 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
2074 | 2146 | ||
2075 | // Un-comment out the following line to Get Raytrace results printed to the console. | 2147 | // Un-comment out the following line to Get Raytrace results printed to the console. |
2076 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 2148 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
2077 | float ScaleOffset = 0.5f; | 2149 | float ScaleOffset = 0.5f; |
2078 | 2150 | ||
2079 | // If we hit something | 2151 | // If we hit something |
@@ -2096,13 +2168,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2096 | //pos.Z -= 0.25F; | 2168 | //pos.Z -= 0.25F; |
2097 | 2169 | ||
2098 | } | 2170 | } |
2099 | |||
2100 | return pos; | ||
2101 | } | 2171 | } |
2102 | else | 2172 | else |
2103 | { | 2173 | { |
2104 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2174 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
2105 | |||
2106 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2175 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
2107 | 2176 | ||
2108 | // Un-comment the following line to print the raytrace results to the console. | 2177 | // Un-comment the following line to print the raytrace results to the console. |
@@ -2111,13 +2180,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2111 | if (ei.HitTF) | 2180 | if (ei.HitTF) |
2112 | { | 2181 | { |
2113 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2182 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
2114 | } else | 2183 | } |
2184 | else | ||
2115 | { | 2185 | { |
2116 | // fall back to our stupid functionality | 2186 | // fall back to our stupid functionality |
2117 | pos = RayEnd; | 2187 | pos = RayEnd; |
2118 | } | 2188 | } |
2119 | |||
2120 | return pos; | ||
2121 | } | 2189 | } |
2122 | } | 2190 | } |
2123 | else | 2191 | else |
@@ -2128,8 +2196,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2128 | //increase height so its above the ground. | 2196 | //increase height so its above the ground. |
2129 | //should be getting the normal of the ground at the rez point and using that? | 2197 | //should be getting the normal of the ground at the rez point and using that? |
2130 | pos.Z += scale.Z / 2f; | 2198 | pos.Z += scale.Z / 2f; |
2131 | return pos; | 2199 | // return pos; |
2132 | } | 2200 | } |
2201 | |||
2202 | // check against posible water intercept | ||
2203 | if (wpos.Z > pos.Z) pos = wpos; | ||
2204 | return pos; | ||
2133 | } | 2205 | } |
2134 | 2206 | ||
2135 | 2207 | ||
@@ -2220,12 +2292,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2220 | { | 2292 | { |
2221 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) | 2293 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) |
2222 | { | 2294 | { |
2295 | sceneObject.IsDeleted = false; | ||
2223 | EventManager.TriggerObjectAddedToScene(sceneObject); | 2296 | EventManager.TriggerObjectAddedToScene(sceneObject); |
2224 | return true; | 2297 | return true; |
2225 | } | 2298 | } |
2226 | 2299 | ||
2227 | return false; | 2300 | return false; |
2228 | |||
2229 | } | 2301 | } |
2230 | 2302 | ||
2231 | /// <summary> | 2303 | /// <summary> |
@@ -2317,6 +2389,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2317 | /// </summary> | 2389 | /// </summary> |
2318 | public void DeleteAllSceneObjects() | 2390 | public void DeleteAllSceneObjects() |
2319 | { | 2391 | { |
2392 | DeleteAllSceneObjects(false); | ||
2393 | } | ||
2394 | |||
2395 | /// <summary> | ||
2396 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2397 | /// </summary> | ||
2398 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2399 | { | ||
2400 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2320 | lock (Entities) | 2401 | lock (Entities) |
2321 | { | 2402 | { |
2322 | EntityBase[] entities = Entities.GetEntities(); | 2403 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2325,11 +2406,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2325 | if (e is SceneObjectGroup) | 2406 | if (e is SceneObjectGroup) |
2326 | { | 2407 | { |
2327 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2408 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2328 | if (!sog.IsAttachment) | 2409 | if (sog != null && !sog.IsAttachment) |
2329 | DeleteSceneObject((SceneObjectGroup)e, false); | 2410 | { |
2411 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2412 | { | ||
2413 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2414 | } | ||
2415 | else | ||
2416 | { | ||
2417 | toReturn.Add((SceneObjectGroup)e); | ||
2418 | } | ||
2419 | } | ||
2330 | } | 2420 | } |
2331 | } | 2421 | } |
2332 | } | 2422 | } |
2423 | if (toReturn.Count > 0) | ||
2424 | { | ||
2425 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2426 | } | ||
2333 | } | 2427 | } |
2334 | 2428 | ||
2335 | /// <summary> | 2429 | /// <summary> |
@@ -2360,6 +2454,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2360 | else | 2454 | else |
2361 | group.StopScriptInstances(); | 2455 | group.StopScriptInstances(); |
2362 | 2456 | ||
2457 | List<UUID> avatars = group.GetSittingAvatars(); | ||
2458 | foreach (UUID av in avatars) | ||
2459 | { | ||
2460 | ScenePresence p = GetScenePresence(av); | ||
2461 | if (p != null) | ||
2462 | p.StandUp(); | ||
2463 | } | ||
2464 | |||
2363 | SceneObjectPart[] partList = group.Parts; | 2465 | SceneObjectPart[] partList = group.Parts; |
2364 | 2466 | ||
2365 | foreach (SceneObjectPart part in partList) | 2467 | foreach (SceneObjectPart part in partList) |
@@ -2387,6 +2489,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2387 | } | 2489 | } |
2388 | 2490 | ||
2389 | group.DeleteGroupFromScene(silent); | 2491 | group.DeleteGroupFromScene(silent); |
2492 | if (!silent) | ||
2493 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2390 | 2494 | ||
2391 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2495 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2392 | } | 2496 | } |
@@ -2676,7 +2780,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2676 | // If the user is banned, we won't let any of their objects | 2780 | // If the user is banned, we won't let any of their objects |
2677 | // enter. Period. | 2781 | // enter. Period. |
2678 | // | 2782 | // |
2679 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2783 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2680 | { | 2784 | { |
2681 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2785 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2682 | return false; | 2786 | return false; |
@@ -2731,6 +2835,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2731 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2835 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2732 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2836 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2733 | { | 2837 | { |
2838 | if (sceneObject.OwnerID == UUID.Zero) | ||
2839 | { | ||
2840 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2841 | return false; | ||
2842 | } | ||
2843 | |||
2844 | // If the user is banned, we won't let any of their objects | ||
2845 | // enter. Period. | ||
2846 | // | ||
2847 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2848 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2849 | { | ||
2850 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2851 | |||
2852 | return false; | ||
2853 | } | ||
2854 | |||
2734 | // Force allocation of new LocalId | 2855 | // Force allocation of new LocalId |
2735 | // | 2856 | // |
2736 | SceneObjectPart[] parts = sceneObject.Parts; | 2857 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2767,16 +2888,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2767 | // information that this is due to a teleport/border cross rather than an ordinary attachment. | 2888 | // information that this is due to a teleport/border cross rather than an ordinary attachment. |
2768 | // We currently do this in Scene.MakeRootAgent() instead. | 2889 | // We currently do this in Scene.MakeRootAgent() instead. |
2769 | if (AttachmentsModule != null) | 2890 | if (AttachmentsModule != null) |
2770 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); | 2891 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true); |
2771 | } | 2892 | } |
2772 | else | 2893 | else |
2773 | { | 2894 | { |
2895 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2774 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2896 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2775 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2897 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2776 | } | 2898 | } |
2899 | if (sceneObject.OwnerID == UUID.Zero) | ||
2900 | { | ||
2901 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2902 | return false; | ||
2903 | } | ||
2777 | } | 2904 | } |
2778 | else | 2905 | else |
2779 | { | 2906 | { |
2907 | if (sceneObject.OwnerID == UUID.Zero) | ||
2908 | { | ||
2909 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2910 | return false; | ||
2911 | } | ||
2780 | AddRestoredSceneObject(sceneObject, true, false); | 2912 | AddRestoredSceneObject(sceneObject, true, false); |
2781 | } | 2913 | } |
2782 | 2914 | ||
@@ -2793,6 +2925,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2793 | return 2; // StateSource.PrimCrossing | 2925 | return 2; // StateSource.PrimCrossing |
2794 | } | 2926 | } |
2795 | 2927 | ||
2928 | public int GetUserFlags(UUID user) | ||
2929 | { | ||
2930 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2931 | /* | ||
2932 | ScenePresence sp; | ||
2933 | if (TryGetScenePresence(user, out sp)) | ||
2934 | { | ||
2935 | return sp.UserFlags; | ||
2936 | } | ||
2937 | else | ||
2938 | { | ||
2939 | */ | ||
2940 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2941 | if (uac == null) | ||
2942 | return 0; | ||
2943 | return uac.UserFlags; | ||
2944 | //} | ||
2945 | } | ||
2796 | #endregion | 2946 | #endregion |
2797 | 2947 | ||
2798 | #region Add/Remove Avatar Methods | 2948 | #region Add/Remove Avatar Methods |
@@ -2825,7 +2975,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2825 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2975 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2826 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2976 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2827 | 2977 | ||
2828 | // CheckHeartbeat(); | 2978 | CheckHeartbeat(); |
2829 | 2979 | ||
2830 | sp = GetScenePresence(client.AgentId); | 2980 | sp = GetScenePresence(client.AgentId); |
2831 | 2981 | ||
@@ -2843,6 +2993,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2843 | SubscribeToClientEvents(client); | 2993 | SubscribeToClientEvents(client); |
2844 | 2994 | ||
2845 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); | 2995 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); |
2996 | InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46); | ||
2997 | if (cof == null) | ||
2998 | sp.COF = UUID.Zero; | ||
2999 | else | ||
3000 | sp.COF = cof.ID; | ||
3001 | |||
3002 | m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF); | ||
2846 | m_eventManager.TriggerOnNewPresence(sp); | 3003 | m_eventManager.TriggerOnNewPresence(sp); |
2847 | 3004 | ||
2848 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; | 3005 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; |
@@ -2957,19 +3114,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2957 | // and the scene presence and the client, if they exist | 3114 | // and the scene presence and the client, if they exist |
2958 | try | 3115 | try |
2959 | { | 3116 | { |
2960 | // We need to wait for the client to make UDP contact first. | 3117 | ScenePresence sp = GetScenePresence(agentID); |
2961 | // It's the UDP contact that creates the scene presence | 3118 | |
2962 | ScenePresence sp = WaitGetScenePresence(agentID); | ||
2963 | if (sp != null) | 3119 | if (sp != null) |
2964 | { | 3120 | { |
2965 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 3121 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2966 | |||
2967 | sp.ControllingClient.Close(); | 3122 | sp.ControllingClient.Close(); |
2968 | } | 3123 | } |
2969 | else | 3124 | |
2970 | { | ||
2971 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2972 | } | ||
2973 | // BANG! SLASH! | 3125 | // BANG! SLASH! |
2974 | m_authenticateHandler.RemoveCircuit(agentID); | 3126 | m_authenticateHandler.RemoveCircuit(agentID); |
2975 | 3127 | ||
@@ -3014,6 +3166,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3014 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3166 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
3015 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3167 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
3016 | 3168 | ||
3169 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3170 | |||
3017 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3171 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3018 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3172 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3019 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3173 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3070,6 +3224,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3070 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3224 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
3071 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3225 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
3072 | client.OnCopyInventoryItem += CopyInventoryItem; | 3226 | client.OnCopyInventoryItem += CopyInventoryItem; |
3227 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
3073 | client.OnMoveInventoryItem += MoveInventoryItem; | 3228 | client.OnMoveInventoryItem += MoveInventoryItem; |
3074 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3229 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
3075 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3230 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3140,6 +3295,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3140 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3295 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
3141 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3296 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
3142 | 3297 | ||
3298 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3299 | |||
3143 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3300 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3144 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3301 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3145 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3302 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3446,7 +3603,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3446 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop | 3603 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop |
3447 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI | 3604 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI |
3448 | if (closeChildAgents && CapsModule != null) | 3605 | if (closeChildAgents && CapsModule != null) |
3449 | CapsModule.RemoveCaps(agentID); | 3606 | CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode); |
3450 | 3607 | ||
3451 | if (closeChildAgents && !isChildAgent) | 3608 | if (closeChildAgents && !isChildAgent) |
3452 | { | 3609 | { |
@@ -3479,6 +3636,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3479 | // It's possible for child agents to have transactions if changes are being made cross-border. | 3636 | // It's possible for child agents to have transactions if changes are being made cross-border. |
3480 | if (AgentTransactionsModule != null) | 3637 | if (AgentTransactionsModule != null) |
3481 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3638 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3639 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3482 | } | 3640 | } |
3483 | catch (Exception e) | 3641 | catch (Exception e) |
3484 | { | 3642 | { |
@@ -3672,15 +3830,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3672 | agent.firstname, agent.lastname, agent.Viewer); | 3830 | agent.firstname, agent.lastname, agent.Viewer); |
3673 | reason = "Access denied, your viewer is banned by the region owner"; | 3831 | reason = "Access denied, your viewer is banned by the region owner"; |
3674 | return false; | 3832 | return false; |
3675 | } | 3833 | } |
3676 | 3834 | ||
3677 | ILandObject land; | 3835 | ScenePresence sp = GetScenePresence(agent.AgentID); |
3678 | 3836 | ||
3679 | lock (agent) | 3837 | // If we have noo presence here or if that presence is a zombie root |
3838 | // presence that will be kicled, we need a new CAPS object. | ||
3839 | if (sp == null || (sp != null && !sp.IsChildAgent)) | ||
3680 | { | 3840 | { |
3681 | ScenePresence sp = GetScenePresence(agent.AgentID); | 3841 | if (CapsModule != null) |
3682 | 3842 | { | |
3683 | if (sp != null && !sp.IsChildAgent) | 3843 | lock (agent) |
3844 | { | ||
3845 | CapsModule.SetAgentCapsSeeds(agent); | ||
3846 | CapsModule.CreateCaps(agent.AgentID, agent.circuitcode); | ||
3847 | } | ||
3848 | } | ||
3849 | } | ||
3850 | |||
3851 | if (sp != null) | ||
3852 | { | ||
3853 | if (!sp.IsChildAgent) | ||
3684 | { | 3854 | { |
3685 | // We have a zombie from a crashed session. | 3855 | // We have a zombie from a crashed session. |
3686 | // Or the same user is trying to be root twice here, won't work. | 3856 | // Or the same user is trying to be root twice here, won't work. |
@@ -3688,29 +3858,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3688 | m_log.WarnFormat( | 3858 | m_log.WarnFormat( |
3689 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", | 3859 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", |
3690 | sp.Name, sp.UUID, RegionInfo.RegionName); | 3860 | sp.Name, sp.UUID, RegionInfo.RegionName); |
3691 | 3861 | ||
3692 | sp.ControllingClient.Close(true); | 3862 | sp.ControllingClient.Close(true, true); |
3693 | sp = null; | 3863 | sp = null; |
3694 | } | 3864 | } |
3865 | } | ||
3695 | 3866 | ||
3867 | lock (agent) | ||
3868 | { | ||
3696 | // Optimistic: add or update the circuit data with the new agent circuit data and teleport flags. | 3869 | // Optimistic: add or update the circuit data with the new agent circuit data and teleport flags. |
3697 | // We need the circuit data here for some of the subsequent checks. (groups, for example) | 3870 | // We need the circuit data here for some of the subsequent checks. (groups, for example) |
3698 | // If the checks fail, we remove the circuit. | 3871 | // If the checks fail, we remove the circuit. |
3699 | agent.teleportFlags = teleportFlags; | 3872 | agent.teleportFlags = teleportFlags; |
3700 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | 3873 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); |
3701 | 3874 | ||
3702 | land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3703 | |||
3704 | // On login test land permisions | 3875 | // On login test land permisions |
3705 | if (vialogin) | 3876 | if (vialogin) |
3706 | { | 3877 | { |
3707 | if (land != null && !TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | 3878 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3879 | if (cache != null) | ||
3880 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3881 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3708 | { | 3882 | { |
3883 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3709 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); | 3884 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); |
3710 | return false; | 3885 | return false; |
3711 | } | 3886 | } |
3712 | } | 3887 | } |
3713 | 3888 | ||
3714 | if (sp == null) // We don't have an [child] agent here already | 3889 | if (sp == null) // We don't have an [child] agent here already |
3715 | { | 3890 | { |
3716 | if (requirePresenceLookup) | 3891 | if (requirePresenceLookup) |
@@ -3732,13 +3907,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3732 | return false; | 3907 | return false; |
3733 | } | 3908 | } |
3734 | } | 3909 | } |
3735 | 3910 | ||
3736 | try | 3911 | try |
3737 | { | 3912 | { |
3738 | if (!AuthorizeUser(agent, out reason)) | 3913 | // Always check estate if this is a login. Always |
3914 | // check if banned regions are to be blacked out. | ||
3915 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3739 | { | 3916 | { |
3740 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); | 3917 | if (!AuthorizeUser(agent, out reason)) |
3741 | return false; | 3918 | { |
3919 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); | ||
3920 | return false; | ||
3921 | } | ||
3742 | } | 3922 | } |
3743 | } | 3923 | } |
3744 | catch (Exception e) | 3924 | catch (Exception e) |
@@ -3749,32 +3929,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3749 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); | 3929 | m_authenticateHandler.RemoveCircuit(agent.circuitcode); |
3750 | return false; | 3930 | return false; |
3751 | } | 3931 | } |
3752 | 3932 | ||
3753 | m_log.InfoFormat( | 3933 | m_log.InfoFormat( |
3754 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", | 3934 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", |
3755 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, | 3935 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, |
3756 | agent.AgentID, agent.circuitcode); | 3936 | agent.AgentID, agent.circuitcode); |
3757 | 3937 | ||
3758 | if (CapsModule != null) | ||
3759 | { | ||
3760 | CapsModule.SetAgentCapsSeeds(agent); | ||
3761 | CapsModule.CreateCaps(agent.AgentID); | ||
3762 | } | ||
3763 | } | 3938 | } |
3764 | else | 3939 | else |
3765 | { | 3940 | { |
3766 | // Let the SP know how we got here. This has a lot of interesting | 3941 | // Let the SP know how we got here. This has a lot of interesting |
3767 | // uses down the line. | 3942 | // uses down the line. |
3768 | sp.TeleportFlags = (TPFlags)teleportFlags; | 3943 | sp.TeleportFlags = (TPFlags)teleportFlags; |
3769 | 3944 | ||
3770 | if (sp.IsChildAgent) | 3945 | if (sp.IsChildAgent) |
3771 | { | 3946 | { |
3772 | m_log.DebugFormat( | 3947 | m_log.DebugFormat( |
3773 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", | 3948 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", |
3774 | agent.AgentID, RegionInfo.RegionName); | 3949 | agent.AgentID, RegionInfo.RegionName); |
3775 | 3950 | ||
3776 | sp.AdjustKnownSeeds(); | 3951 | sp.AdjustKnownSeeds(); |
3777 | 3952 | ||
3778 | if (CapsModule != null) | 3953 | if (CapsModule != null) |
3779 | CapsModule.SetAgentCapsSeeds(agent); | 3954 | CapsModule.SetAgentCapsSeeds(agent); |
3780 | } | 3955 | } |
@@ -3786,6 +3961,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3786 | CacheUserName(null, agent); | 3961 | CacheUserName(null, agent); |
3787 | } | 3962 | } |
3788 | 3963 | ||
3964 | if (CapsModule != null) | ||
3965 | { | ||
3966 | CapsModule.ActivateCaps(agent.circuitcode); | ||
3967 | } | ||
3968 | |||
3789 | if (vialogin) | 3969 | if (vialogin) |
3790 | { | 3970 | { |
3791 | // CleanDroppedAttachments(); | 3971 | // CleanDroppedAttachments(); |
@@ -3877,6 +4057,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3877 | } | 4057 | } |
3878 | 4058 | ||
3879 | // Honor parcel landing type and position. | 4059 | // Honor parcel landing type and position. |
4060 | /* | ||
4061 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3880 | if (land != null) | 4062 | if (land != null) |
3881 | { | 4063 | { |
3882 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 4064 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3884,6 +4066,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3884 | agent.startpos = land.LandData.UserLocation; | 4066 | agent.startpos = land.LandData.UserLocation; |
3885 | } | 4067 | } |
3886 | } | 4068 | } |
4069 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3887 | } | 4070 | } |
3888 | 4071 | ||
3889 | return true; | 4072 | return true; |
@@ -3981,7 +4164,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3981 | 4164 | ||
3982 | if (!m_strictAccessControl) return true; | 4165 | if (!m_strictAccessControl) return true; |
3983 | if (Permissions.IsGod(agent.AgentID)) return true; | 4166 | if (Permissions.IsGod(agent.AgentID)) return true; |
3984 | 4167 | ||
3985 | if (AuthorizationService != null) | 4168 | if (AuthorizationService != null) |
3986 | { | 4169 | { |
3987 | if (!AuthorizationService.IsAuthorizedForRegion( | 4170 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3996,7 +4179,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3996 | 4179 | ||
3997 | if (RegionInfo.EstateSettings != null) | 4180 | if (RegionInfo.EstateSettings != null) |
3998 | { | 4181 | { |
3999 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 4182 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
4000 | { | 4183 | { |
4001 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 4184 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
4002 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 4185 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -4184,6 +4367,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4184 | m_log.DebugFormat( | 4367 | m_log.DebugFormat( |
4185 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); | 4368 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); |
4186 | 4369 | ||
4370 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4371 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4372 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4373 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4374 | { | ||
4375 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4376 | return false; | ||
4377 | } | ||
4378 | |||
4187 | // TODO: This check should probably be in QueryAccess(). | 4379 | // TODO: This check should probably be in QueryAccess(). |
4188 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4380 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4189 | if (nearestParcel == null) | 4381 | if (nearestParcel == null) |
@@ -4248,7 +4440,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4248 | /// <param name='agentID'></param> | 4440 | /// <param name='agentID'></param> |
4249 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 4441 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4250 | { | 4442 | { |
4251 | int ntimes = 10; | 4443 | int ntimes = 30; |
4252 | ScenePresence sp = null; | 4444 | ScenePresence sp = null; |
4253 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 4445 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4254 | Thread.Sleep(1000); | 4446 | Thread.Sleep(1000); |
@@ -4278,6 +4470,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4278 | return false; | 4470 | return false; |
4279 | } | 4471 | } |
4280 | 4472 | ||
4473 | public bool IncomingCloseAgent(UUID agentID) | ||
4474 | { | ||
4475 | return IncomingCloseAgent(agentID, false); | ||
4476 | } | ||
4477 | |||
4478 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4479 | { | ||
4480 | return IncomingCloseAgent(agentID, true); | ||
4481 | } | ||
4482 | |||
4281 | /// <summary> | 4483 | /// <summary> |
4282 | /// Tell a single agent to disconnect from the region. | 4484 | /// Tell a single agent to disconnect from the region. |
4283 | /// </summary> | 4485 | /// </summary> |
@@ -4293,7 +4495,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4293 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); | 4495 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); |
4294 | if (presence != null) | 4496 | if (presence != null) |
4295 | { | 4497 | { |
4296 | presence.ControllingClient.Close(force); | 4498 | presence.ControllingClient.Close(force, force); |
4297 | return true; | 4499 | return true; |
4298 | } | 4500 | } |
4299 | 4501 | ||
@@ -4926,7 +5128,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4926 | { | 5128 | { |
4927 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 5129 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
4928 | { | 5130 | { |
4929 | if (grp.RootPart.Expires <= DateTime.Now) | 5131 | if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now) |
4930 | DeleteSceneObject(grp, false); | 5132 | DeleteSceneObject(grp, false); |
4931 | } | 5133 | } |
4932 | } | 5134 | } |
@@ -4940,35 +5142,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4940 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 5142 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4941 | } | 5143 | } |
4942 | 5144 | ||
4943 | public int GetHealth() | 5145 | public int GetHealth(out int flags, out string message) |
4944 | { | 5146 | { |
4945 | // Returns: | 5147 | // Returns: |
4946 | // 1 = sim is up and accepting http requests. The heartbeat has | 5148 | // 1 = sim is up and accepting http requests. The heartbeat has |
4947 | // stopped and the sim is probably locked up, but a remote | 5149 | // stopped and the sim is probably locked up, but a remote |
4948 | // admin restart may succeed | 5150 | // admin restart may succeed |
4949 | // | 5151 | // |
4950 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 5152 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4951 | // usable for people within and logins _may_ work | 5153 | // usable for people within |
5154 | // | ||
5155 | // 3 = Sim is up and one packet thread is running. Sim is | ||
5156 | // unstable and will not accept new logins | ||
4952 | // | 5157 | // |
4953 | // 3 = We have seen a new user enter within the past 4 minutes | 5158 | // 4 = Sim is up and both packet threads are running. Sim is |
5159 | // likely usable | ||
5160 | // | ||
5161 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4954 | // which can be seen as positive confirmation of sim health | 5162 | // which can be seen as positive confirmation of sim health |
4955 | // | 5163 | // |
5164 | |||
5165 | flags = 0; | ||
5166 | message = String.Empty; | ||
5167 | |||
5168 | CheckHeartbeat(); | ||
5169 | |||
5170 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
5171 | { | ||
5172 | // We're still starting | ||
5173 | // 0 means "in startup", it can't happen another way, since | ||
5174 | // to get here, we must be able to accept http connections | ||
5175 | return 0; | ||
5176 | } | ||
5177 | |||
4956 | int health=1; // Start at 1, means we're up | 5178 | int health=1; // Start at 1, means we're up |
4957 | 5179 | ||
4958 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5180 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4959 | health += 1; | 5181 | { |
5182 | health+=1; | ||
5183 | flags |= 1; | ||
5184 | } | ||
5185 | |||
5186 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
5187 | { | ||
5188 | health+=1; | ||
5189 | flags |= 2; | ||
5190 | } | ||
5191 | |||
5192 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
5193 | { | ||
5194 | health+=1; | ||
5195 | flags |= 4; | ||
5196 | } | ||
4960 | else | 5197 | else |
5198 | { | ||
5199 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
5200 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
5201 | proc.EnableRaisingEvents=false; | ||
5202 | proc.StartInfo.FileName = "/bin/kill"; | ||
5203 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
5204 | proc.Start(); | ||
5205 | proc.WaitForExit(); | ||
5206 | Thread.Sleep(1000); | ||
5207 | Environment.Exit(1); | ||
5208 | } | ||
5209 | |||
5210 | if (flags != 7) | ||
4961 | return health; | 5211 | return health; |
4962 | 5212 | ||
4963 | // A login in the last 4 mins? We can't be doing too badly | 5213 | // A login in the last 4 mins? We can't be doing too badly |
4964 | // | 5214 | // |
4965 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 5215 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4966 | health++; | 5216 | health++; |
4967 | else | 5217 | else |
4968 | return health; | 5218 | return health; |
4969 | 5219 | ||
4970 | // CheckHeartbeat(); | ||
4971 | |||
4972 | return health; | 5220 | return health; |
4973 | } | 5221 | } |
4974 | 5222 | ||
@@ -5056,7 +5304,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5056 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5304 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
5057 | if (wasUsingPhysics) | 5305 | if (wasUsingPhysics) |
5058 | { | 5306 | { |
5059 | jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock | 5307 | jointProxyObject.UpdatePrimFlags(false, false, true, false,false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock |
5060 | } | 5308 | } |
5061 | } | 5309 | } |
5062 | 5310 | ||
@@ -5155,14 +5403,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5155 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5403 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
5156 | } | 5404 | } |
5157 | 5405 | ||
5158 | // private void CheckHeartbeat() | 5406 | private void CheckHeartbeat() |
5159 | // { | 5407 | { |
5160 | // if (m_firstHeartbeat) | 5408 | if (m_firstHeartbeat) |
5161 | // return; | 5409 | return; |
5162 | // | 5410 | |
5163 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5411 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
5164 | // StartTimer(); | 5412 | Start(); |
5165 | // } | 5413 | } |
5166 | 5414 | ||
5167 | public override ISceneObject DeserializeObject(string representation) | 5415 | public override ISceneObject DeserializeObject(string representation) |
5168 | { | 5416 | { |
@@ -5220,7 +5468,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5220 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); | 5468 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); |
5221 | 5469 | ||
5222 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); | 5470 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); |
5223 | 5471 | ||
5224 | return nearestRegionEdgePoint; | 5472 | return nearestRegionEdgePoint; |
5225 | } | 5473 | } |
5226 | 5474 | ||
@@ -5474,7 +5722,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5474 | mapModule.GenerateMaptile(); | 5722 | mapModule.GenerateMaptile(); |
5475 | } | 5723 | } |
5476 | 5724 | ||
5477 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5725 | // public void CleanDroppedAttachments() |
5726 | // { | ||
5727 | // List<SceneObjectGroup> objectsToDelete = | ||
5728 | // new List<SceneObjectGroup>(); | ||
5729 | // | ||
5730 | // lock (m_cleaningAttachments) | ||
5731 | // { | ||
5732 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5733 | // { | ||
5734 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5735 | // { | ||
5736 | // UUID agentID = grp.OwnerID; | ||
5737 | // if (agentID == UUID.Zero) | ||
5738 | // { | ||
5739 | // objectsToDelete.Add(grp); | ||
5740 | // return; | ||
5741 | // } | ||
5742 | // | ||
5743 | // ScenePresence sp = GetScenePresence(agentID); | ||
5744 | // if (sp == null) | ||
5745 | // { | ||
5746 | // objectsToDelete.Add(grp); | ||
5747 | // return; | ||
5748 | // } | ||
5749 | // } | ||
5750 | // }); | ||
5751 | // } | ||
5752 | // | ||
5753 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5754 | // { | ||
5755 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5756 | // DeleteSceneObject(grp, true); | ||
5757 | // } | ||
5758 | // } | ||
5759 | |||
5760 | public void ThreadAlive(int threadCode) | ||
5761 | { | ||
5762 | switch(threadCode) | ||
5763 | { | ||
5764 | case 1: // Incoming | ||
5765 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5766 | break; | ||
5767 | case 2: // Incoming | ||
5768 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5769 | break; | ||
5770 | } | ||
5771 | } | ||
5772 | |||
5773 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5478 | { | 5774 | { |
5479 | RegenerateMaptile(); | 5775 | RegenerateMaptile(); |
5480 | 5776 | ||
@@ -5636,7 +5932,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
5636 | return true; | 5932 | return true; |
5637 | } | 5933 | } |
5638 | 5934 | ||
5639 | /// <summary> | 5935 | public void StartTimerWatchdog() |
5936 | { | ||
5937 | m_timerWatchdog.Interval = 1000; | ||
5938 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5939 | m_timerWatchdog.AutoReset = true; | ||
5940 | m_timerWatchdog.Start(); | ||
5941 | } | ||
5942 | |||
5943 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5944 | { | ||
5945 | CheckHeartbeat(); | ||
5946 | } | ||
5947 | |||
5640 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5948 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5641 | /// autopilot that moves an avatar to a sit target!. | 5949 | /// autopilot that moves an avatar to a sit target!. |
5642 | /// </summary> | 5950 | /// </summary> |
@@ -5715,6 +6023,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5715 | return m_SpawnPoint - 1; | 6023 | return m_SpawnPoint - 1; |
5716 | } | 6024 | } |
5717 | 6025 | ||
6026 | private void HandleGcCollect(string module, string[] args) | ||
6027 | { | ||
6028 | GC.Collect(); | ||
6029 | } | ||
6030 | |||
5718 | /// <summary> | 6031 | /// <summary> |
5719 | /// Wrappers to get physics modules retrieve assets. | 6032 | /// Wrappers to get physics modules retrieve assets. |
5720 | /// </summary> | 6033 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index d2097ea..4eef162 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -143,7 +143,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
143 | 143 | ||
144 | protected ulong m_regionHandle; | 144 | protected ulong m_regionHandle; |
145 | protected string m_regionName; | 145 | protected string m_regionName; |
146 | protected RegionInfo m_regInfo; | ||
147 | 146 | ||
148 | public ITerrainChannel Heightmap; | 147 | public ITerrainChannel Heightmap; |
149 | 148 | ||
@@ -168,6 +167,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
168 | get { return m_permissions; } | 167 | get { return m_permissions; } |
169 | } | 168 | } |
170 | 169 | ||
170 | protected string m_datastore; | ||
171 | |||
171 | /* Used by the loadbalancer plugin on GForge */ | 172 | /* Used by the loadbalancer plugin on GForge */ |
172 | protected RegionStatus m_regStatus; | 173 | protected RegionStatus m_regStatus; |
173 | public RegionStatus RegionStatus | 174 | public RegionStatus RegionStatus |
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 8238e23..df61dde 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -194,10 +194,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | public delegate void SendCloseChildAgentDelegate(UUID agentID, ulong regionHandle); | ||
198 | |||
197 | /// <summary> | 199 | /// <summary> |
198 | /// Closes a child agent on a given region | 200 | /// This Closes child agents on neighboring regions |
201 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | ||
199 | /// </summary> | 202 | /// </summary> |
200 | protected void SendCloseChildAgent(UUID agentID, ulong regionHandle) | 203 | protected void SendCloseChildAgentAsync(UUID agentID, ulong regionHandle) |
201 | { | 204 | { |
202 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. | 205 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. |
203 | 206 | ||
@@ -206,33 +209,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
206 | Utils.LongToUInts(regionHandle, out x, out y); | 209 | Utils.LongToUInts(regionHandle, out x, out y); |
207 | 210 | ||
208 | GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); | 211 | GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); |
212 | m_scene.SimulationService.CloseChildAgent(destination, agentID); | ||
213 | } | ||
209 | 214 | ||
210 | m_log.DebugFormat( | 215 | private void SendCloseChildAgentCompleted(IAsyncResult iar) |
211 | "[SCENE COMMUNICATION SERVICE]: Sending close agent ID {0} to {1}", agentID, destination.RegionName); | 216 | { |
212 | 217 | SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate)iar.AsyncState; | |
213 | m_scene.SimulationService.CloseAgent(destination, agentID); | 218 | icon.EndInvoke(iar); |
214 | } | 219 | } |
215 | 220 | ||
216 | /// <summary> | ||
217 | /// Closes a child agents in a collection of regions. Does so asynchronously | ||
218 | /// so that the caller doesn't wait. | ||
219 | /// </summary> | ||
220 | /// <param name="agentID"></param> | ||
221 | /// <param name="regionslst"></param> | ||
222 | public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst) | 221 | public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst) |
223 | { | 222 | { |
224 | foreach (ulong handle in regionslst) | 223 | foreach (ulong handle in regionslst) |
225 | { | 224 | { |
226 | // We must take a copy here since handle is acts like a reference when used in an iterator. | ||
227 | // This leads to race conditions if directly passed to SendCloseChildAgent with more than one neighbour region. | ||
228 | ulong handleCopy = handle; | 225 | ulong handleCopy = handle; |
229 | Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy); }); | 226 | SendCloseChildAgentDelegate d = SendCloseChildAgentAsync; |
227 | d.BeginInvoke(agentID, handleCopy, | ||
228 | SendCloseChildAgentCompleted, | ||
229 | d); | ||
230 | } | 230 | } |
231 | } | 231 | } |
232 | 232 | ||
233 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) | 233 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) |
234 | { | 234 | { |
235 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); | 235 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } \ No newline at end of file | 238 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index bb7ae7f..e599e90 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -41,6 +41,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
41 | { | 41 | { |
42 | public delegate void PhysicsCrash(); | 42 | public delegate void PhysicsCrash(); |
43 | 43 | ||
44 | public delegate void AttachToBackupDelegate(SceneObjectGroup sog); | ||
45 | |||
46 | public delegate void DetachFromBackupDelegate(SceneObjectGroup sog); | ||
47 | |||
48 | public delegate void ChangedBackupDelegate(SceneObjectGroup sog); | ||
49 | |||
44 | /// <summary> | 50 | /// <summary> |
45 | /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components | 51 | /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components |
46 | /// should be migrated out over time. | 52 | /// should be migrated out over time. |
@@ -54,11 +60,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
54 | protected internal event PhysicsCrash UnRecoverableError; | 60 | protected internal event PhysicsCrash UnRecoverableError; |
55 | private PhysicsCrash handlerPhysicsCrash = null; | 61 | private PhysicsCrash handlerPhysicsCrash = null; |
56 | 62 | ||
63 | public event AttachToBackupDelegate OnAttachToBackup; | ||
64 | public event DetachFromBackupDelegate OnDetachFromBackup; | ||
65 | public event ChangedBackupDelegate OnChangeBackup; | ||
66 | |||
57 | #endregion | 67 | #endregion |
58 | 68 | ||
59 | #region Fields | 69 | #region Fields |
60 | 70 | ||
61 | protected object m_presenceLock = new object(); | 71 | protected OpenMetaverse.ReaderWriterLockSlim m_scenePresencesLock = new OpenMetaverse.ReaderWriterLockSlim(); |
62 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); | 72 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); |
63 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); | 73 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); |
64 | 74 | ||
@@ -127,13 +137,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
127 | 137 | ||
128 | protected internal void Close() | 138 | protected internal void Close() |
129 | { | 139 | { |
130 | lock (m_presenceLock) | 140 | m_scenePresencesLock.EnterWriteLock(); |
141 | try | ||
131 | { | 142 | { |
132 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); | 143 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); |
133 | List<ScenePresence> newlist = new List<ScenePresence>(); | 144 | List<ScenePresence> newlist = new List<ScenePresence>(); |
134 | m_scenePresenceMap = newmap; | 145 | m_scenePresenceMap = newmap; |
135 | m_scenePresenceArray = newlist; | 146 | m_scenePresenceArray = newlist; |
136 | } | 147 | } |
148 | finally | ||
149 | { | ||
150 | m_scenePresencesLock.ExitWriteLock(); | ||
151 | } | ||
137 | 152 | ||
138 | lock (SceneObjectGroupsByFullID) | 153 | lock (SceneObjectGroupsByFullID) |
139 | SceneObjectGroupsByFullID.Clear(); | 154 | SceneObjectGroupsByFullID.Clear(); |
@@ -254,6 +269,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
254 | protected internal bool AddRestoredSceneObject( | 269 | protected internal bool AddRestoredSceneObject( |
255 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 270 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
256 | { | 271 | { |
272 | if (!m_parentScene.CombineRegions) | ||
273 | { | ||
274 | // KF: Check for out-of-region, move inside and make static. | ||
275 | Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, | ||
276 | sceneObject.RootPart.GroupPosition.Y, | ||
277 | sceneObject.RootPart.GroupPosition.Z); | ||
278 | if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || | ||
279 | npos.X > Constants.RegionSize || | ||
280 | npos.Y > Constants.RegionSize)) | ||
281 | { | ||
282 | if (npos.X < 0.0) npos.X = 1.0f; | ||
283 | if (npos.Y < 0.0) npos.Y = 1.0f; | ||
284 | if (npos.Z < 0.0) npos.Z = 0.0f; | ||
285 | if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; | ||
286 | if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; | ||
287 | |||
288 | foreach (SceneObjectPart part in sceneObject.Parts) | ||
289 | { | ||
290 | part.GroupPosition = npos; | ||
291 | } | ||
292 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
293 | sceneObject.RootPart.AngularVelocity = Vector3.Zero; | ||
294 | sceneObject.RootPart.Acceleration = Vector3.Zero; | ||
295 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
296 | } | ||
297 | } | ||
298 | |||
257 | if (attachToBackup && (!alreadyPersisted)) | 299 | if (attachToBackup && (!alreadyPersisted)) |
258 | { | 300 | { |
259 | sceneObject.ForceInventoryPersistence(); | 301 | sceneObject.ForceInventoryPersistence(); |
@@ -317,9 +359,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
317 | if (pa != null && pa.IsPhysical && vel != Vector3.Zero) | 359 | if (pa != null && pa.IsPhysical && vel != Vector3.Zero) |
318 | { | 360 | { |
319 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); | 361 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); |
320 | sceneObject.Velocity = vel; | ||
321 | } | 362 | } |
322 | 363 | ||
323 | return true; | 364 | return true; |
324 | } | 365 | } |
325 | 366 | ||
@@ -344,6 +385,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
344 | /// </returns> | 385 | /// </returns> |
345 | protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) | 386 | protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
346 | { | 387 | { |
388 | if (sceneObject == null) | ||
389 | { | ||
390 | m_log.ErrorFormat("[SCENEGRAPH]: Tried to add null scene object"); | ||
391 | return false; | ||
392 | } | ||
347 | if (sceneObject.UUID == UUID.Zero) | 393 | if (sceneObject.UUID == UUID.Zero) |
348 | { | 394 | { |
349 | m_log.ErrorFormat( | 395 | m_log.ErrorFormat( |
@@ -475,6 +521,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
475 | m_updateList[obj.UUID] = obj; | 521 | m_updateList[obj.UUID] = obj; |
476 | } | 522 | } |
477 | 523 | ||
524 | public void FireAttachToBackup(SceneObjectGroup obj) | ||
525 | { | ||
526 | if (OnAttachToBackup != null) | ||
527 | { | ||
528 | OnAttachToBackup(obj); | ||
529 | } | ||
530 | } | ||
531 | |||
532 | public void FireDetachFromBackup(SceneObjectGroup obj) | ||
533 | { | ||
534 | if (OnDetachFromBackup != null) | ||
535 | { | ||
536 | OnDetachFromBackup(obj); | ||
537 | } | ||
538 | } | ||
539 | |||
540 | public void FireChangeBackup(SceneObjectGroup obj) | ||
541 | { | ||
542 | if (OnChangeBackup != null) | ||
543 | { | ||
544 | OnChangeBackup(obj); | ||
545 | } | ||
546 | } | ||
547 | |||
478 | /// <summary> | 548 | /// <summary> |
479 | /// Process all pending updates | 549 | /// Process all pending updates |
480 | /// </summary> | 550 | /// </summary> |
@@ -519,12 +589,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
519 | 589 | ||
520 | protected internal void AddPhysicalPrim(int number) | 590 | protected internal void AddPhysicalPrim(int number) |
521 | { | 591 | { |
522 | m_physicalPrim++; | 592 | m_physicalPrim += number; |
523 | } | 593 | } |
524 | 594 | ||
525 | protected internal void RemovePhysicalPrim(int number) | 595 | protected internal void RemovePhysicalPrim(int number) |
526 | { | 596 | { |
527 | m_physicalPrim--; | 597 | m_physicalPrim -= number; |
528 | } | 598 | } |
529 | 599 | ||
530 | protected internal void AddToScriptLPS(int number) | 600 | protected internal void AddToScriptLPS(int number) |
@@ -592,7 +662,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
592 | 662 | ||
593 | Entities[presence.UUID] = presence; | 663 | Entities[presence.UUID] = presence; |
594 | 664 | ||
595 | lock (m_presenceLock) | 665 | m_scenePresencesLock.EnterWriteLock(); |
666 | try | ||
596 | { | 667 | { |
597 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 668 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
598 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 669 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -616,6 +687,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
616 | m_scenePresenceMap = newmap; | 687 | m_scenePresenceMap = newmap; |
617 | m_scenePresenceArray = newlist; | 688 | m_scenePresenceArray = newlist; |
618 | } | 689 | } |
690 | finally | ||
691 | { | ||
692 | m_scenePresencesLock.ExitWriteLock(); | ||
693 | } | ||
619 | } | 694 | } |
620 | 695 | ||
621 | /// <summary> | 696 | /// <summary> |
@@ -630,7 +705,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
630 | agentID); | 705 | agentID); |
631 | } | 706 | } |
632 | 707 | ||
633 | lock (m_presenceLock) | 708 | m_scenePresencesLock.EnterWriteLock(); |
709 | try | ||
634 | { | 710 | { |
635 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 711 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
636 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 712 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -652,6 +728,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
652 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); | 728 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); |
653 | } | 729 | } |
654 | } | 730 | } |
731 | finally | ||
732 | { | ||
733 | m_scenePresencesLock.ExitWriteLock(); | ||
734 | } | ||
655 | } | 735 | } |
656 | 736 | ||
657 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) | 737 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) |
@@ -1205,6 +1285,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
1205 | 1285 | ||
1206 | #region Client Event handlers | 1286 | #region Client Event handlers |
1207 | 1287 | ||
1288 | protected internal void ClientChangeObject(uint localID, object odata, IClientAPI remoteClient) | ||
1289 | { | ||
1290 | SceneObjectPart part = GetSceneObjectPart(localID); | ||
1291 | ObjectChangeData data = (ObjectChangeData)odata; | ||
1292 | |||
1293 | if (part != null) | ||
1294 | { | ||
1295 | SceneObjectGroup grp = part.ParentGroup; | ||
1296 | if (grp != null) | ||
1297 | { | ||
1298 | if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) | ||
1299 | { | ||
1300 | // These two are exceptions SL makes in the interpretation | ||
1301 | // of the change flags. Must check them here because otherwise | ||
1302 | // the group flag (see below) would be lost | ||
1303 | if (data.change == ObjectChangeType.groupS) | ||
1304 | data.change = ObjectChangeType.primS; | ||
1305 | if (data.change == ObjectChangeType.groupPS) | ||
1306 | data.change = ObjectChangeType.primPS; | ||
1307 | part.StoreUndoState(data.change); // lets test only saving what we changed | ||
1308 | grp.doChangeObject(part, (ObjectChangeData)data); | ||
1309 | } | ||
1310 | else | ||
1311 | { | ||
1312 | // Is this any kind of group operation? | ||
1313 | if ((data.change & ObjectChangeType.Group) != 0) | ||
1314 | { | ||
1315 | // Is a move and/or rotation requested? | ||
1316 | if ((data.change & (ObjectChangeType.Position | ObjectChangeType.Rotation)) != 0) | ||
1317 | { | ||
1318 | // Are we allowed to move it? | ||
1319 | if (m_parentScene.Permissions.CanMoveObject(grp.UUID, remoteClient.AgentId)) | ||
1320 | { | ||
1321 | // Strip all but move and rotation from request | ||
1322 | data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation); | ||
1323 | |||
1324 | part.StoreUndoState(data.change); | ||
1325 | grp.doChangeObject(part, (ObjectChangeData)data); | ||
1326 | } | ||
1327 | } | ||
1328 | } | ||
1329 | } | ||
1330 | } | ||
1331 | } | ||
1332 | } | ||
1333 | |||
1208 | /// <summary> | 1334 | /// <summary> |
1209 | /// Update the scale of an individual prim. | 1335 | /// Update the scale of an individual prim. |
1210 | /// </summary> | 1336 | /// </summary> |
@@ -1219,7 +1345,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1219 | { | 1345 | { |
1220 | if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) | 1346 | if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) |
1221 | { | 1347 | { |
1348 | bool physbuild = false; | ||
1349 | if (part.ParentGroup.RootPart.PhysActor != null) | ||
1350 | { | ||
1351 | part.ParentGroup.RootPart.PhysActor.Building = true; | ||
1352 | physbuild = true; | ||
1353 | } | ||
1354 | |||
1222 | part.Resize(scale); | 1355 | part.Resize(scale); |
1356 | |||
1357 | if (physbuild) | ||
1358 | part.ParentGroup.RootPart.PhysActor.Building = false; | ||
1223 | } | 1359 | } |
1224 | } | 1360 | } |
1225 | } | 1361 | } |
@@ -1231,7 +1367,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1231 | { | 1367 | { |
1232 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) | 1368 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) |
1233 | { | 1369 | { |
1370 | bool physbuild = false; | ||
1371 | if (group.RootPart.PhysActor != null) | ||
1372 | { | ||
1373 | group.RootPart.PhysActor.Building = true; | ||
1374 | physbuild = true; | ||
1375 | } | ||
1376 | |||
1234 | group.GroupResize(scale); | 1377 | group.GroupResize(scale); |
1378 | |||
1379 | if (physbuild) | ||
1380 | group.RootPart.PhysActor.Building = false; | ||
1235 | } | 1381 | } |
1236 | } | 1382 | } |
1237 | } | 1383 | } |
@@ -1359,8 +1505,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1359 | { | 1505 | { |
1360 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) | 1506 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) |
1361 | { | 1507 | { |
1362 | if (m_parentScene.AttachmentsModule != null) | 1508 | // Set the new attachment point data in the object |
1363 | m_parentScene.AttachmentsModule.UpdateAttachmentPosition(group, pos); | 1509 | byte attachmentPoint = group.GetAttachmentPoint(); |
1510 | group.UpdateGroupPosition(pos); | ||
1511 | group.IsAttachment = false; | ||
1512 | group.AbsolutePosition = group.RootPart.AttachedPos; | ||
1513 | group.AttachmentPoint = attachmentPoint; | ||
1514 | group.HasGroupChanged = true; | ||
1364 | } | 1515 | } |
1365 | else | 1516 | else |
1366 | { | 1517 | { |
@@ -1581,6 +1732,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1581 | { | 1732 | { |
1582 | part.Material = Convert.ToByte(material); | 1733 | part.Material = Convert.ToByte(material); |
1583 | group.HasGroupChanged = true; | 1734 | group.HasGroupChanged = true; |
1735 | remoteClient.SendPartPhysicsProprieties(part); | ||
1584 | } | 1736 | } |
1585 | } | 1737 | } |
1586 | } | 1738 | } |
@@ -1659,8 +1811,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1659 | return; | 1811 | return; |
1660 | 1812 | ||
1661 | Monitor.Enter(m_updateLock); | 1813 | Monitor.Enter(m_updateLock); |
1814 | |||
1662 | try | 1815 | try |
1663 | { | 1816 | { |
1817 | |||
1664 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); | 1818 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); |
1665 | 1819 | ||
1666 | // We do this in reverse to get the link order of the prims correct | 1820 | // We do this in reverse to get the link order of the prims correct |
@@ -1675,9 +1829,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1675 | // Make sure no child prim is set for sale | 1829 | // Make sure no child prim is set for sale |
1676 | // So that, on delink, no prims are unwittingly | 1830 | // So that, on delink, no prims are unwittingly |
1677 | // left for sale and sold off | 1831 | // left for sale and sold off |
1678 | child.RootPart.ObjectSaleType = 0; | 1832 | |
1679 | child.RootPart.SalePrice = 10; | 1833 | if (child != null) |
1680 | childGroups.Add(child); | 1834 | { |
1835 | child.RootPart.ObjectSaleType = 0; | ||
1836 | child.RootPart.SalePrice = 10; | ||
1837 | childGroups.Add(child); | ||
1838 | } | ||
1681 | } | 1839 | } |
1682 | 1840 | ||
1683 | foreach (SceneObjectGroup child in childGroups) | 1841 | foreach (SceneObjectGroup child in childGroups) |
@@ -1706,6 +1864,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1706 | } | 1864 | } |
1707 | finally | 1865 | finally |
1708 | { | 1866 | { |
1867 | lock (SceneObjectGroupsByLocalPartID) | ||
1868 | { | ||
1869 | foreach (SceneObjectPart part in parentGroup.Parts) | ||
1870 | SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; | ||
1871 | } | ||
1872 | |||
1873 | parentGroup.AdjustChildPrimPermissions(); | ||
1874 | parentGroup.HasGroupChanged = true; | ||
1875 | parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); | ||
1876 | parentGroup.ScheduleGroupForFullUpdate(); | ||
1709 | Monitor.Exit(m_updateLock); | 1877 | Monitor.Exit(m_updateLock); |
1710 | } | 1878 | } |
1711 | } | 1879 | } |
@@ -1747,21 +1915,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
1747 | 1915 | ||
1748 | SceneObjectGroup group = part.ParentGroup; | 1916 | SceneObjectGroup group = part.ParentGroup; |
1749 | if (!affectedGroups.Contains(group)) | 1917 | if (!affectedGroups.Contains(group)) |
1918 | { | ||
1750 | affectedGroups.Add(group); | 1919 | affectedGroups.Add(group); |
1920 | } | ||
1751 | } | 1921 | } |
1752 | } | 1922 | } |
1753 | } | 1923 | } |
1754 | 1924 | ||
1755 | foreach (SceneObjectPart child in childParts) | 1925 | if (childParts.Count > 0) |
1756 | { | 1926 | { |
1757 | // Unlink all child parts from their groups | 1927 | foreach (SceneObjectPart child in childParts) |
1758 | // | 1928 | { |
1759 | child.ParentGroup.DelinkFromGroup(child, true); | 1929 | // Unlink all child parts from their groups |
1760 | 1930 | // | |
1761 | // These are not in affected groups and will not be | 1931 | child.ParentGroup.DelinkFromGroup(child, true); |
1762 | // handled further. Do the honors here. | 1932 | child.ParentGroup.HasGroupChanged = true; |
1763 | child.ParentGroup.HasGroupChanged = true; | 1933 | child.ParentGroup.ScheduleGroupForFullUpdate(); |
1764 | child.ParentGroup.ScheduleGroupForFullUpdate(); | 1934 | } |
1765 | } | 1935 | } |
1766 | 1936 | ||
1767 | foreach (SceneObjectPart root in rootParts) | 1937 | foreach (SceneObjectPart root in rootParts) |
@@ -1775,52 +1945,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1775 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); | 1945 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); |
1776 | int numChildren = newSet.Count; | 1946 | int numChildren = newSet.Count; |
1777 | 1947 | ||
1948 | if (numChildren == 1) | ||
1949 | break; | ||
1950 | |||
1778 | // If there are prims left in a link set, but the root is | 1951 | // If there are prims left in a link set, but the root is |
1779 | // slated for unlink, we need to do this | 1952 | // slated for unlink, we need to do this |
1953 | // Unlink the remaining set | ||
1780 | // | 1954 | // |
1781 | if (numChildren != 1) | 1955 | bool sendEventsToRemainder = true; |
1782 | { | 1956 | if (numChildren > 1) |
1783 | // Unlink the remaining set | 1957 | sendEventsToRemainder = false; |
1784 | // | ||
1785 | bool sendEventsToRemainder = true; | ||
1786 | if (numChildren > 1) | ||
1787 | sendEventsToRemainder = false; | ||
1788 | 1958 | ||
1789 | foreach (SceneObjectPart p in newSet) | 1959 | foreach (SceneObjectPart p in newSet) |
1960 | { | ||
1961 | if (p != group.RootPart) | ||
1790 | { | 1962 | { |
1791 | if (p != group.RootPart) | 1963 | group.DelinkFromGroup(p, sendEventsToRemainder); |
1792 | group.DelinkFromGroup(p, sendEventsToRemainder); | 1964 | if (numChildren > 2) |
1965 | { | ||
1966 | } | ||
1967 | else | ||
1968 | { | ||
1969 | p.ParentGroup.HasGroupChanged = true; | ||
1970 | p.ParentGroup.ScheduleGroupForFullUpdate(); | ||
1971 | } | ||
1793 | } | 1972 | } |
1973 | } | ||
1794 | 1974 | ||
1795 | // If there is more than one prim remaining, we | 1975 | // If there is more than one prim remaining, we |
1796 | // need to re-link | 1976 | // need to re-link |
1977 | // | ||
1978 | if (numChildren > 2) | ||
1979 | { | ||
1980 | // Remove old root | ||
1797 | // | 1981 | // |
1798 | if (numChildren > 2) | 1982 | if (newSet.Contains(root)) |
1983 | newSet.Remove(root); | ||
1984 | |||
1985 | // Preserve link ordering | ||
1986 | // | ||
1987 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) | ||
1799 | { | 1988 | { |
1800 | // Remove old root | 1989 | return a.LinkNum.CompareTo(b.LinkNum); |
1801 | // | 1990 | }); |
1802 | if (newSet.Contains(root)) | ||
1803 | newSet.Remove(root); | ||
1804 | |||
1805 | // Preserve link ordering | ||
1806 | // | ||
1807 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) | ||
1808 | { | ||
1809 | return a.LinkNum.CompareTo(b.LinkNum); | ||
1810 | }); | ||
1811 | 1991 | ||
1812 | // Determine new root | 1992 | // Determine new root |
1813 | // | 1993 | // |
1814 | SceneObjectPart newRoot = newSet[0]; | 1994 | SceneObjectPart newRoot = newSet[0]; |
1815 | newSet.RemoveAt(0); | 1995 | newSet.RemoveAt(0); |
1816 | 1996 | ||
1817 | foreach (SceneObjectPart newChild in newSet) | 1997 | foreach (SceneObjectPart newChild in newSet) |
1818 | newChild.ClearUpdateSchedule(); | 1998 | newChild.ClearUpdateSchedule(); |
1819 | 1999 | ||
1820 | LinkObjects(newRoot, newSet); | 2000 | LinkObjects(newRoot, newSet); |
1821 | if (!affectedGroups.Contains(newRoot.ParentGroup)) | 2001 | if (!affectedGroups.Contains(newRoot.ParentGroup)) |
1822 | affectedGroups.Add(newRoot.ParentGroup); | 2002 | affectedGroups.Add(newRoot.ParentGroup); |
1823 | } | ||
1824 | } | 2003 | } |
1825 | } | 2004 | } |
1826 | 2005 | ||
@@ -1828,6 +2007,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1828 | // | 2007 | // |
1829 | foreach (SceneObjectGroup g in affectedGroups) | 2008 | foreach (SceneObjectGroup g in affectedGroups) |
1830 | { | 2009 | { |
2010 | // Child prims that have been unlinked and deleted will | ||
2011 | // return unless the root is deleted. This will remove them | ||
2012 | // from the database. They will be rewritten immediately, | ||
2013 | // minus the rows for the unlinked child prims. | ||
2014 | g.AdjustChildPrimPermissions(); | ||
2015 | m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); | ||
1831 | g.TriggerScriptChangedEvent(Changed.LINK); | 2016 | g.TriggerScriptChangedEvent(Changed.LINK); |
1832 | g.HasGroupChanged = true; // Persist | 2017 | g.HasGroupChanged = true; // Persist |
1833 | g.ScheduleGroupForFullUpdate(); | 2018 | g.ScheduleGroupForFullUpdate(); |
@@ -1901,108 +2086,96 @@ namespace OpenSim.Region.Framework.Scenes | |||
1901 | /// <param name="GroupID"></param> | 2086 | /// <param name="GroupID"></param> |
1902 | /// <param name="rot"></param> | 2087 | /// <param name="rot"></param> |
1903 | /// <returns>null if duplication fails, otherwise the duplicated object</returns> | 2088 | /// <returns>null if duplication fails, otherwise the duplicated object</returns> |
1904 | public SceneObjectGroup DuplicateObject( | 2089 | /// <summary> |
1905 | uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) | 2090 | public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) |
1906 | { | 2091 | { |
1907 | Monitor.Enter(m_updateLock); | 2092 | // m_log.DebugFormat( |
2093 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | ||
2094 | // originalPrimID, offset, AgentID); | ||
1908 | 2095 | ||
1909 | try | 2096 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); |
2097 | if (original != null) | ||
1910 | { | 2098 | { |
1911 | // m_log.DebugFormat( | 2099 | if (m_parentScene.Permissions.CanDuplicateObject( |
1912 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | 2100 | original.PrimCount, original.UUID, AgentID, original.AbsolutePosition)) |
1913 | // originalPrimID, offset, AgentID); | ||
1914 | |||
1915 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); | ||
1916 | if (original == null) | ||
1917 | { | 2101 | { |
1918 | m_log.WarnFormat( | 2102 | SceneObjectGroup copy = original.Copy(true); |
1919 | "[SCENEGRAPH]: Attempt to duplicate nonexistant prim id {0} by {1}", originalPrimID, AgentID); | 2103 | copy.AbsolutePosition = copy.AbsolutePosition + offset; |
1920 | 2104 | ||
1921 | return null; | 2105 | if (original.OwnerID != AgentID) |
1922 | } | 2106 | { |
2107 | copy.SetOwnerId(AgentID); | ||
2108 | copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); | ||
1923 | 2109 | ||
1924 | if (!m_parentScene.Permissions.CanDuplicateObject( | 2110 | SceneObjectPart[] partList = copy.Parts; |
1925 | original.PrimCount, original.UUID, AgentID, original.AbsolutePosition)) | 2111 | |
1926 | return null; | 2112 | if (m_parentScene.Permissions.PropagatePermissions()) |
2113 | { | ||
2114 | foreach (SceneObjectPart child in partList) | ||
2115 | { | ||
2116 | child.Inventory.ChangeInventoryOwner(AgentID); | ||
2117 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
2118 | child.ApplyNextOwnerPermissions(); | ||
2119 | } | ||
2120 | } | ||
2121 | } | ||
1927 | 2122 | ||
1928 | SceneObjectGroup copy = original.Copy(true); | 2123 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() |
1929 | copy.AbsolutePosition = copy.AbsolutePosition + offset; | 2124 | Entities.Add(copy); |
1930 | 2125 | ||
1931 | if (original.OwnerID != AgentID) | 2126 | lock (SceneObjectGroupsByFullID) |
1932 | { | 2127 | SceneObjectGroupsByFullID[copy.UUID] = copy; |
1933 | copy.SetOwnerId(AgentID); | ||
1934 | copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); | ||
1935 | 2128 | ||
1936 | SceneObjectPart[] partList = copy.Parts; | 2129 | SceneObjectPart[] children = copy.Parts; |
1937 | 2130 | ||
1938 | if (m_parentScene.Permissions.PropagatePermissions()) | 2131 | lock (SceneObjectGroupsByFullPartID) |
1939 | { | 2132 | { |
1940 | foreach (SceneObjectPart child in partList) | 2133 | SceneObjectGroupsByFullPartID[copy.UUID] = copy; |
1941 | { | 2134 | foreach (SceneObjectPart part in children) |
1942 | child.Inventory.ChangeInventoryOwner(AgentID); | 2135 | SceneObjectGroupsByFullPartID[part.UUID] = copy; |
1943 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
1944 | child.ApplyNextOwnerPermissions(); | ||
1945 | } | ||
1946 | } | 2136 | } |
1947 | 2137 | ||
1948 | copy.RootPart.ObjectSaleType = 0; | 2138 | lock (SceneObjectGroupsByLocalPartID) |
1949 | copy.RootPart.SalePrice = 10; | 2139 | { |
1950 | } | 2140 | SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; |
2141 | foreach (SceneObjectPart part in children) | ||
2142 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; | ||
2143 | } | ||
2144 | // PROBABLE END OF FIXME | ||
1951 | 2145 | ||
1952 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() | 2146 | // Since we copy from a source group that is in selected |
1953 | Entities.Add(copy); | 2147 | // state, but the copy is shown deselected in the viewer, |
1954 | 2148 | // We need to clear the selection flag here, else that | |
1955 | lock (SceneObjectGroupsByFullID) | 2149 | // prim never gets persisted at all. The client doesn't |
1956 | SceneObjectGroupsByFullID[copy.UUID] = copy; | 2150 | // think it's selected, so it will never send a deselect... |
1957 | 2151 | copy.IsSelected = false; | |
1958 | SceneObjectPart[] children = copy.Parts; | 2152 | |
1959 | 2153 | m_numPrim += copy.Parts.Length; | |
1960 | lock (SceneObjectGroupsByFullPartID) | 2154 | |
1961 | { | 2155 | if (rot != Quaternion.Identity) |
1962 | SceneObjectGroupsByFullPartID[copy.UUID] = copy; | 2156 | { |
1963 | foreach (SceneObjectPart part in children) | 2157 | copy.UpdateGroupRotationR(rot); |
1964 | SceneObjectGroupsByFullPartID[part.UUID] = copy; | 2158 | } |
1965 | } | ||
1966 | |||
1967 | lock (SceneObjectGroupsByLocalPartID) | ||
1968 | { | ||
1969 | SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; | ||
1970 | foreach (SceneObjectPart part in children) | ||
1971 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; | ||
1972 | } | ||
1973 | // PROBABLE END OF FIXME | ||
1974 | |||
1975 | // Since we copy from a source group that is in selected | ||
1976 | // state, but the copy is shown deselected in the viewer, | ||
1977 | // We need to clear the selection flag here, else that | ||
1978 | // prim never gets persisted at all. The client doesn't | ||
1979 | // think it's selected, so it will never send a deselect... | ||
1980 | copy.IsSelected = false; | ||
1981 | |||
1982 | m_numPrim += copy.Parts.Length; | ||
1983 | |||
1984 | if (rot != Quaternion.Identity) | ||
1985 | { | ||
1986 | copy.UpdateGroupRotationR(rot); | ||
1987 | } | ||
1988 | 2159 | ||
1989 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); | 2160 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); |
1990 | copy.HasGroupChanged = true; | 2161 | copy.HasGroupChanged = true; |
1991 | copy.ScheduleGroupForFullUpdate(); | 2162 | copy.ScheduleGroupForFullUpdate(); |
1992 | copy.ResumeScripts(); | 2163 | copy.ResumeScripts(); |
1993 | 2164 | ||
1994 | // required for physics to update it's position | 2165 | // required for physics to update it's position |
1995 | copy.AbsolutePosition = copy.AbsolutePosition; | 2166 | copy.AbsolutePosition = copy.AbsolutePosition; |
1996 | 2167 | ||
1997 | return copy; | 2168 | return copy; |
2169 | } | ||
1998 | } | 2170 | } |
1999 | finally | 2171 | else |
2000 | { | 2172 | { |
2001 | Monitor.Exit(m_updateLock); | 2173 | m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); |
2002 | } | 2174 | } |
2175 | |||
2176 | return null; | ||
2003 | } | 2177 | } |
2004 | 2178 | ||
2005 | /// <summary> | ||
2006 | /// Calculates the distance between two Vector3s | 2179 | /// Calculates the distance between two Vector3s |
2007 | /// </summary> | 2180 | /// </summary> |
2008 | /// <param name="v1"></param> | 2181 | /// <param name="v1"></param> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 780bd01..c70342f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -99,11 +99,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | private readonly List<Scene> m_localScenes = new List<Scene>(); | 102 | private readonly DoubleDictionary<UUID, string, Scene> m_localScenes = new DoubleDictionary<UUID, string, Scene>(); |
103 | 103 | ||
104 | public List<Scene> Scenes | 104 | public List<Scene> Scenes |
105 | { | 105 | { |
106 | get { return new List<Scene>(m_localScenes); } | 106 | get { return new List<Scene>(m_localScenes.FindAll(delegate(Scene s) { return true; })); } |
107 | } | 107 | } |
108 | 108 | ||
109 | /// <summary> | 109 | /// <summary> |
@@ -120,13 +120,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
120 | { | 120 | { |
121 | if (CurrentScene == null) | 121 | if (CurrentScene == null) |
122 | { | 122 | { |
123 | lock (m_localScenes) | 123 | List<Scene> sceneList = Scenes; |
124 | { | 124 | if (sceneList.Count == 0) |
125 | if (m_localScenes.Count > 0) | 125 | return null; |
126 | return m_localScenes[0]; | 126 | return sceneList[0]; |
127 | else | ||
128 | return null; | ||
129 | } | ||
130 | } | 127 | } |
131 | else | 128 | else |
132 | { | 129 | { |
@@ -138,41 +135,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
138 | public SceneManager() | 135 | public SceneManager() |
139 | { | 136 | { |
140 | m_instance = this; | 137 | m_instance = this; |
141 | m_localScenes = new List<Scene>(); | 138 | m_localScenes = new DoubleDictionary<UUID, string, Scene>(); |
142 | } | 139 | } |
143 | 140 | ||
144 | public void Close() | 141 | public void Close() |
145 | { | 142 | { |
143 | List<Scene> localScenes = null; | ||
144 | |||
146 | lock (m_localScenes) | 145 | lock (m_localScenes) |
147 | { | 146 | { |
148 | for (int i = 0; i < m_localScenes.Count; i++) | 147 | localScenes = Scenes; |
149 | { | 148 | } |
150 | m_localScenes[i].Close(); | 149 | |
151 | } | 150 | for (int i = 0; i < localScenes.Count; i++) |
151 | { | ||
152 | localScenes[i].Close(); | ||
152 | } | 153 | } |
153 | } | 154 | } |
154 | 155 | ||
155 | public void Close(Scene cscene) | 156 | public void Close(Scene cscene) |
156 | { | 157 | { |
157 | lock (m_localScenes) | 158 | if (!m_localScenes.ContainsKey(cscene.RegionInfo.RegionID)) |
158 | { | 159 | return; |
159 | if (m_localScenes.Contains(cscene)) | 160 | cscene.Close(); |
160 | { | ||
161 | for (int i = 0; i < m_localScenes.Count; i++) | ||
162 | { | ||
163 | if (m_localScenes[i].Equals(cscene)) | ||
164 | { | ||
165 | m_localScenes[i].Close(); | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | } | 161 | } |
171 | 162 | ||
172 | public void Add(Scene scene) | 163 | public void Add(Scene scene) |
173 | { | 164 | { |
174 | lock (m_localScenes) | 165 | lock (m_localScenes) |
175 | m_localScenes.Add(scene); | 166 | m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene); |
176 | 167 | ||
177 | scene.OnRestart += HandleRestart; | 168 | scene.OnRestart += HandleRestart; |
178 | scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange; | 169 | scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange; |
@@ -184,15 +175,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
184 | 175 | ||
185 | lock (m_localScenes) | 176 | lock (m_localScenes) |
186 | { | 177 | { |
187 | for (int i = 0; i < m_localScenes.Count; i++) | 178 | m_localScenes.TryGetValue(rdata.RegionID, out restartedScene); |
188 | { | 179 | m_localScenes.Remove(rdata.RegionID); |
189 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) | ||
190 | { | ||
191 | restartedScene = m_localScenes[i]; | ||
192 | m_localScenes.RemoveAt(i); | ||
193 | break; | ||
194 | } | ||
195 | } | ||
196 | } | 180 | } |
197 | 181 | ||
198 | // If the currently selected scene has been restarted, then we can't reselect here since we the scene | 182 | // If the currently selected scene has been restarted, then we can't reselect here since we the scene |
@@ -207,39 +191,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
207 | private void HandleRegionReadyStatusChange(IScene scene) | 191 | private void HandleRegionReadyStatusChange(IScene scene) |
208 | { | 192 | { |
209 | lock (m_localScenes) | 193 | lock (m_localScenes) |
210 | AllRegionsReady = m_localScenes.TrueForAll(s => s.Ready); | 194 | AllRegionsReady = m_localScenes.FindAll(s => !s.Ready).Count == 0; |
211 | } | 195 | } |
212 | 196 | ||
213 | public void SendSimOnlineNotification(ulong regionHandle) | 197 | public void SendSimOnlineNotification(ulong regionHandle) |
214 | { | 198 | { |
215 | RegionInfo Result = null; | 199 | RegionInfo Result = null; |
216 | 200 | ||
217 | lock (m_localScenes) | 201 | Scene s = m_localScenes.FindValue(delegate(Scene x) |
218 | { | ||
219 | for (int i = 0; i < m_localScenes.Count; i++) | ||
220 | { | ||
221 | if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) | ||
222 | { | 202 | { |
223 | // Inform other regions to tell their avatar about me | 203 | if (x.RegionInfo.RegionHandle == regionHandle) |
224 | Result = m_localScenes[i].RegionInfo; | 204 | return true; |
225 | } | 205 | return false; |
226 | } | 206 | }); |
207 | |||
208 | if (s != null) | ||
209 | { | ||
210 | List<Scene> sceneList = Scenes; | ||
227 | 211 | ||
228 | if (Result != null) | 212 | for (int i = 0; i < sceneList.Count; i++) |
229 | { | 213 | { |
230 | for (int i = 0; i < m_localScenes.Count; i++) | 214 | if (sceneList[i]!= s) |
231 | { | 215 | { |
232 | if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) | 216 | // Inform other regions to tell their avatar about me |
233 | { | 217 | //sceneList[i].OtherRegionUp(Result); |
234 | // Inform other regions to tell their avatar about me | ||
235 | //m_localScenes[i].OtherRegionUp(Result); | ||
236 | } | ||
237 | } | 218 | } |
238 | } | 219 | } |
239 | else | 220 | } |
240 | { | 221 | else |
241 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); | 222 | { |
242 | } | 223 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); |
243 | } | 224 | } |
244 | } | 225 | } |
245 | 226 | ||
@@ -368,16 +349,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
368 | } | 349 | } |
369 | else | 350 | else |
370 | { | 351 | { |
371 | lock (m_localScenes) | 352 | Scene s; |
353 | |||
354 | if (m_localScenes.TryGetValue(regionName, out s)) | ||
372 | { | 355 | { |
373 | foreach (Scene scene in m_localScenes) | 356 | CurrentScene = s; |
374 | { | 357 | return true; |
375 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) | ||
376 | { | ||
377 | CurrentScene = scene; | ||
378 | return true; | ||
379 | } | ||
380 | } | ||
381 | } | 358 | } |
382 | 359 | ||
383 | return false; | 360 | return false; |
@@ -386,18 +363,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
386 | 363 | ||
387 | public bool TrySetCurrentScene(UUID regionID) | 364 | public bool TrySetCurrentScene(UUID regionID) |
388 | { | 365 | { |
389 | m_log.Debug("Searching for Region: '" + regionID + "'"); | 366 | // m_log.Debug("Searching for Region: '" + regionID + "'"); |
390 | 367 | ||
391 | lock (m_localScenes) | 368 | Scene s; |
369 | |||
370 | if (m_localScenes.TryGetValue(regionID, out s)) | ||
392 | { | 371 | { |
393 | foreach (Scene scene in m_localScenes) | 372 | CurrentScene = s; |
394 | { | 373 | return true; |
395 | if (scene.RegionInfo.RegionID == regionID) | ||
396 | { | ||
397 | CurrentScene = scene; | ||
398 | return true; | ||
399 | } | ||
400 | } | ||
401 | } | 374 | } |
402 | 375 | ||
403 | return false; | 376 | return false; |
@@ -405,52 +378,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
405 | 378 | ||
406 | public bool TryGetScene(string regionName, out Scene scene) | 379 | public bool TryGetScene(string regionName, out Scene scene) |
407 | { | 380 | { |
408 | lock (m_localScenes) | 381 | return m_localScenes.TryGetValue(regionName, out scene); |
409 | { | ||
410 | foreach (Scene mscene in m_localScenes) | ||
411 | { | ||
412 | if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) | ||
413 | { | ||
414 | scene = mscene; | ||
415 | return true; | ||
416 | } | ||
417 | } | ||
418 | } | ||
419 | |||
420 | scene = null; | ||
421 | return false; | ||
422 | } | 382 | } |
423 | 383 | ||
424 | public bool TryGetScene(UUID regionID, out Scene scene) | 384 | public bool TryGetScene(UUID regionID, out Scene scene) |
425 | { | 385 | { |
426 | lock (m_localScenes) | 386 | return m_localScenes.TryGetValue(regionID, out scene); |
427 | { | ||
428 | foreach (Scene mscene in m_localScenes) | ||
429 | { | ||
430 | if (mscene.RegionInfo.RegionID == regionID) | ||
431 | { | ||
432 | scene = mscene; | ||
433 | return true; | ||
434 | } | ||
435 | } | ||
436 | } | ||
437 | |||
438 | scene = null; | ||
439 | return false; | ||
440 | } | 387 | } |
441 | 388 | ||
442 | public bool TryGetScene(uint locX, uint locY, out Scene scene) | 389 | public bool TryGetScene(uint locX, uint locY, out Scene scene) |
443 | { | 390 | { |
444 | lock (m_localScenes) | 391 | List<Scene> sceneList = Scenes; |
392 | foreach (Scene mscene in sceneList) | ||
445 | { | 393 | { |
446 | foreach (Scene mscene in m_localScenes) | 394 | if (mscene.RegionInfo.RegionLocX == locX && |
395 | mscene.RegionInfo.RegionLocY == locY) | ||
447 | { | 396 | { |
448 | if (mscene.RegionInfo.RegionLocX == locX && | 397 | scene = mscene; |
449 | mscene.RegionInfo.RegionLocY == locY) | 398 | return true; |
450 | { | ||
451 | scene = mscene; | ||
452 | return true; | ||
453 | } | ||
454 | } | 399 | } |
455 | } | 400 | } |
456 | 401 | ||
@@ -460,16 +405,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
460 | 405 | ||
461 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) | 406 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) |
462 | { | 407 | { |
463 | lock (m_localScenes) | 408 | List<Scene> sceneList = Scenes; |
409 | foreach (Scene mscene in sceneList) | ||
464 | { | 410 | { |
465 | foreach (Scene mscene in m_localScenes) | 411 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && |
412 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | ||
466 | { | 413 | { |
467 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && | 414 | scene = mscene; |
468 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | 415 | return true; |
469 | { | ||
470 | scene = mscene; | ||
471 | return true; | ||
472 | } | ||
473 | } | 416 | } |
474 | } | 417 | } |
475 | 418 | ||
@@ -534,15 +477,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
534 | 477 | ||
535 | public RegionInfo GetRegionInfo(UUID regionID) | 478 | public RegionInfo GetRegionInfo(UUID regionID) |
536 | { | 479 | { |
537 | lock (m_localScenes) | 480 | Scene s; |
481 | if (m_localScenes.TryGetValue(regionID, out s)) | ||
538 | { | 482 | { |
539 | foreach (Scene scene in m_localScenes) | 483 | return s.RegionInfo; |
540 | { | ||
541 | if (scene.RegionInfo.RegionID == regionID) | ||
542 | { | ||
543 | return scene.RegionInfo; | ||
544 | } | ||
545 | } | ||
546 | } | 484 | } |
547 | 485 | ||
548 | return null; | 486 | return null; |
@@ -560,14 +498,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
560 | 498 | ||
561 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) | 499 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) |
562 | { | 500 | { |
563 | lock (m_localScenes) | 501 | List<Scene> sceneList = Scenes; |
502 | foreach (Scene scene in sceneList) | ||
564 | { | 503 | { |
565 | foreach (Scene scene in m_localScenes) | 504 | if (scene.TryGetScenePresence(avatarId, out avatar)) |
566 | { | 505 | { |
567 | if (scene.TryGetScenePresence(avatarId, out avatar)) | 506 | return true; |
568 | { | ||
569 | return true; | ||
570 | } | ||
571 | } | 507 | } |
572 | } | 508 | } |
573 | 509 | ||
@@ -577,15 +513,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
577 | 513 | ||
578 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) | 514 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) |
579 | { | 515 | { |
580 | lock (m_localScenes) | 516 | List<Scene> sceneList = Scenes; |
517 | foreach (Scene scene in sceneList) | ||
581 | { | 518 | { |
582 | foreach (Scene scene in m_localScenes) | 519 | avatar = scene.GetScenePresence(avatarId); |
583 | { | ||
584 | avatar = scene.GetScenePresence(avatarId); | ||
585 | 520 | ||
586 | if (avatar != null && !avatar.IsChildAgent) | 521 | if (avatar != null && !avatar.IsChildAgent) |
587 | return true; | 522 | return true; |
588 | } | ||
589 | } | 523 | } |
590 | 524 | ||
591 | avatar = null; | 525 | avatar = null; |
@@ -595,21 +529,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
595 | public void CloseScene(Scene scene) | 529 | public void CloseScene(Scene scene) |
596 | { | 530 | { |
597 | lock (m_localScenes) | 531 | lock (m_localScenes) |
598 | m_localScenes.Remove(scene); | 532 | m_localScenes.Remove(scene.RegionInfo.RegionID); |
599 | 533 | ||
600 | scene.Close(); | 534 | scene.Close(); |
601 | } | 535 | } |
602 | 536 | ||
603 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 537 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
604 | { | 538 | { |
605 | lock (m_localScenes) | 539 | List<Scene> sceneList = Scenes; |
540 | foreach (Scene scene in sceneList) | ||
606 | { | 541 | { |
607 | foreach (Scene scene in m_localScenes) | 542 | if (scene.TryGetAvatarByName(avatarName, out avatar)) |
608 | { | 543 | { |
609 | if (scene.TryGetAvatarByName(avatarName, out avatar)) | 544 | return true; |
610 | { | ||
611 | return true; | ||
612 | } | ||
613 | } | 545 | } |
614 | } | 546 | } |
615 | 547 | ||
@@ -619,14 +551,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
619 | 551 | ||
620 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) | 552 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) |
621 | { | 553 | { |
622 | lock (m_localScenes) | 554 | List<Scene> sceneList = Scenes; |
555 | foreach (Scene scene in sceneList) | ||
623 | { | 556 | { |
624 | foreach (Scene scene in m_localScenes) | 557 | sp = scene.GetScenePresence(firstName, lastName); |
625 | { | 558 | if (sp != null && !sp.IsChildAgent) |
626 | sp = scene.GetScenePresence(firstName, lastName); | 559 | return true; |
627 | if (sp != null && !sp.IsChildAgent) | ||
628 | return true; | ||
629 | } | ||
630 | } | 560 | } |
631 | 561 | ||
632 | sp = null; | 562 | sp = null; |
@@ -635,8 +565,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
635 | 565 | ||
636 | public void ForEachScene(Action<Scene> action) | 566 | public void ForEachScene(Action<Scene> action) |
637 | { | 567 | { |
638 | lock (m_localScenes) | 568 | List<Scene> sceneList = Scenes; |
639 | m_localScenes.ForEach(action); | 569 | sceneList.ForEach(action); |
640 | } | 570 | } |
641 | } | 571 | } |
642 | } | 572 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index dcb62f8..f8624e7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -82,10 +82,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
82 | /// <summary> | 82 | /// <summary> |
83 | /// Stop and remove the scripts contained in all the prims in this group | 83 | /// Stop and remove the scripts contained in all the prims in this group |
84 | /// </summary> | 84 | /// </summary> |
85 | /// <param name="sceneObjectBeingDeleted"> | ||
86 | /// Should be true if these scripts are being removed because the scene | ||
87 | /// object is being deleted. This will prevent spurious updates to the client. | ||
88 | /// </param> | ||
89 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 85 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
90 | { | 86 | { |
91 | SceneObjectPart[] parts = m_parts.GetArray(); | 87 | SceneObjectPart[] parts = m_parts.GetArray(); |
@@ -248,6 +244,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
248 | 244 | ||
249 | public uint GetEffectivePermissions() | 245 | public uint GetEffectivePermissions() |
250 | { | 246 | { |
247 | return GetEffectivePermissions(false); | ||
248 | } | ||
249 | |||
250 | public uint GetEffectivePermissions(bool useBase) | ||
251 | { | ||
251 | uint perms=(uint)(PermissionMask.Modify | | 252 | uint perms=(uint)(PermissionMask.Modify | |
252 | PermissionMask.Copy | | 253 | PermissionMask.Copy | |
253 | PermissionMask.Move | | 254 | PermissionMask.Move | |
@@ -259,7 +260,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
259 | for (int i = 0; i < parts.Length; i++) | 260 | for (int i = 0; i < parts.Length; i++) |
260 | { | 261 | { |
261 | SceneObjectPart part = parts[i]; | 262 | SceneObjectPart part = parts[i]; |
262 | ownerMask &= part.OwnerMask; | 263 | if (useBase) |
264 | ownerMask &= part.BaseMask; | ||
265 | else | ||
266 | ownerMask &= part.OwnerMask; | ||
263 | perms &= part.Inventory.MaskEffectivePermissions(); | 267 | perms &= part.Inventory.MaskEffectivePermissions(); |
264 | } | 268 | } |
265 | 269 | ||
@@ -401,6 +405,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
401 | 405 | ||
402 | public void ResumeScripts() | 406 | public void ResumeScripts() |
403 | { | 407 | { |
408 | if (m_scene.RegionInfo.RegionSettings.DisableScripts) | ||
409 | return; | ||
410 | |||
404 | SceneObjectPart[] parts = m_parts.GetArray(); | 411 | SceneObjectPart[] parts = m_parts.GetArray(); |
405 | for (int i = 0; i < parts.Length; i++) | 412 | for (int i = 0; i < parts.Length; i++) |
406 | parts[i].Inventory.ResumeScripts(); | 413 | parts[i].Inventory.ResumeScripts(); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index da80e4f..02a8935 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -24,12 +24,13 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.ComponentModel; | 29 | using System.ComponentModel; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Drawing; | 31 | using System.Drawing; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Diagnostics; | ||
33 | using System.Linq; | 34 | using System.Linq; |
34 | using System.Threading; | 35 | using System.Threading; |
35 | using System.Xml; | 36 | using System.Xml; |
@@ -44,6 +45,7 @@ using PermissionMask = OpenSim.Framework.PermissionMask; | |||
44 | 45 | ||
45 | namespace OpenSim.Region.Framework.Scenes | 46 | namespace OpenSim.Region.Framework.Scenes |
46 | { | 47 | { |
48 | |||
47 | [Flags] | 49 | [Flags] |
48 | public enum scriptEvents | 50 | public enum scriptEvents |
49 | { | 51 | { |
@@ -78,14 +80,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
78 | object_rez = 4194304 | 80 | object_rez = 4194304 |
79 | } | 81 | } |
80 | 82 | ||
81 | struct scriptPosTarget | 83 | public struct scriptPosTarget |
82 | { | 84 | { |
83 | public Vector3 targetPos; | 85 | public Vector3 targetPos; |
84 | public float tolerance; | 86 | public float tolerance; |
85 | public uint handle; | 87 | public uint handle; |
86 | } | 88 | } |
87 | 89 | ||
88 | struct scriptRotTarget | 90 | public struct scriptRotTarget |
89 | { | 91 | { |
90 | public Quaternion targetRot; | 92 | public Quaternion targetRot; |
91 | public float tolerance; | 93 | public float tolerance; |
@@ -116,8 +118,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
116 | /// since the group's last persistent backup | 118 | /// since the group's last persistent backup |
117 | /// </summary> | 119 | /// </summary> |
118 | private bool m_hasGroupChanged = false; | 120 | private bool m_hasGroupChanged = false; |
119 | private long timeFirstChanged; | 121 | private long timeFirstChanged = 0; |
120 | private long timeLastChanged; | 122 | private long timeLastChanged = 0; |
123 | private long m_maxPersistTime = 0; | ||
124 | private long m_minPersistTime = 0; | ||
125 | // private Random m_rand; | ||
126 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); | ||
121 | 127 | ||
122 | /// <summary> | 128 | /// <summary> |
123 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage | 129 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage |
@@ -134,9 +140,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
134 | { | 140 | { |
135 | if (value) | 141 | if (value) |
136 | { | 142 | { |
143 | |||
144 | if (m_isBackedUp) | ||
145 | { | ||
146 | m_scene.SceneGraph.FireChangeBackup(this); | ||
147 | } | ||
137 | timeLastChanged = DateTime.Now.Ticks; | 148 | timeLastChanged = DateTime.Now.Ticks; |
138 | if (!m_hasGroupChanged) | 149 | if (!m_hasGroupChanged) |
139 | timeFirstChanged = DateTime.Now.Ticks; | 150 | timeFirstChanged = DateTime.Now.Ticks; |
151 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | ||
152 | { | ||
153 | /* | ||
154 | if (m_rand == null) | ||
155 | { | ||
156 | byte[] val = new byte[16]; | ||
157 | m_rootPart.UUID.ToBytes(val, 0); | ||
158 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
159 | } | ||
160 | */ | ||
161 | if (m_scene.GetRootAgentCount() == 0) | ||
162 | { | ||
163 | //If the region is empty, this change has been made by an automated process | ||
164 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
165 | |||
166 | // float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
167 | float factor = 2.0f; | ||
168 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); | ||
169 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); | ||
170 | } | ||
171 | else | ||
172 | { | ||
173 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
174 | //but add a random factor so we stagger the object persistance a little | ||
175 | // m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
176 | // m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
177 | m_maxPersistTime = m_scene.m_persistAfter; | ||
178 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
179 | } | ||
180 | } | ||
140 | } | 181 | } |
141 | m_hasGroupChanged = value; | 182 | m_hasGroupChanged = value; |
142 | 183 | ||
@@ -151,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
151 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since | 192 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since |
152 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. | 193 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. |
153 | /// </summary> | 194 | /// </summary> |
154 | public bool HasGroupChangedDueToDelink { get; private set; } | 195 | public bool HasGroupChangedDueToDelink { get; set; } |
155 | 196 | ||
156 | private bool isTimeToPersist() | 197 | private bool isTimeToPersist() |
157 | { | 198 | { |
@@ -161,8 +202,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
161 | return false; | 202 | return false; |
162 | if (m_scene.ShuttingDown) | 203 | if (m_scene.ShuttingDown) |
163 | return true; | 204 | return true; |
205 | |||
206 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
207 | { | ||
208 | m_maxPersistTime = m_scene.m_persistAfter; | ||
209 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
210 | } | ||
211 | |||
164 | long currentTime = DateTime.Now.Ticks; | 212 | long currentTime = DateTime.Now.Ticks; |
165 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 213 | |
214 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
215 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
216 | |||
217 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
166 | return true; | 218 | return true; |
167 | return false; | 219 | return false; |
168 | } | 220 | } |
@@ -220,6 +272,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
220 | { | 272 | { |
221 | AttachmentPoint = 0; | 273 | AttachmentPoint = 0; |
222 | 274 | ||
275 | // Don't zap trees | ||
276 | if (RootPart.Shape.PCode == (byte)PCode.Tree || | ||
277 | RootPart.Shape.PCode == (byte)PCode.NewTree) | ||
278 | return; | ||
279 | |||
223 | // Even though we don't use child part state parameters for attachments any more, we still need to set | 280 | // Even though we don't use child part state parameters for attachments any more, we still need to set |
224 | // these to zero since having them non-zero in rezzed scene objects will crash some clients. Even if | 281 | // these to zero since having them non-zero in rezzed scene objects will crash some clients. Even if |
225 | // we store them correctly, scene objects that we receive from elsewhere might not. | 282 | // we store them correctly, scene objects that we receive from elsewhere might not. |
@@ -265,26 +322,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | get { return RootPart.VolumeDetectActive; } | 322 | get { return RootPart.VolumeDetectActive; } |
266 | } | 323 | } |
267 | 324 | ||
268 | private Vector3 lastPhysGroupPos; | ||
269 | private Quaternion lastPhysGroupRot; | ||
270 | |||
271 | private bool m_isBackedUp; | 325 | private bool m_isBackedUp; |
272 | 326 | ||
327 | public bool IsBackedUp | ||
328 | { | ||
329 | get { return m_isBackedUp; } | ||
330 | } | ||
331 | |||
273 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); | 332 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); |
274 | 333 | ||
275 | protected ulong m_regionHandle; | 334 | protected ulong m_regionHandle; |
276 | protected SceneObjectPart m_rootPart; | 335 | protected SceneObjectPart m_rootPart; |
277 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); | 336 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); |
278 | 337 | ||
279 | private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); | 338 | private SortedDictionary<uint, scriptPosTarget> m_targets = new SortedDictionary<uint, scriptPosTarget>(); |
280 | private Dictionary<uint, scriptRotTarget> m_rotTargets = new Dictionary<uint, scriptRotTarget>(); | 339 | private SortedDictionary<uint, scriptRotTarget> m_rotTargets = new SortedDictionary<uint, scriptRotTarget>(); |
340 | |||
341 | public SortedDictionary<uint, scriptPosTarget> AtTargets | ||
342 | { | ||
343 | get { return m_targets; } | ||
344 | } | ||
345 | |||
346 | public SortedDictionary<uint, scriptRotTarget> RotTargets | ||
347 | { | ||
348 | get { return m_rotTargets; } | ||
349 | } | ||
281 | 350 | ||
282 | private bool m_scriptListens_atTarget; | 351 | private bool m_scriptListens_atTarget; |
283 | private bool m_scriptListens_notAtTarget; | 352 | private bool m_scriptListens_notAtTarget; |
284 | |||
285 | private bool m_scriptListens_atRotTarget; | 353 | private bool m_scriptListens_atRotTarget; |
286 | private bool m_scriptListens_notAtRotTarget; | 354 | private bool m_scriptListens_notAtRotTarget; |
287 | 355 | ||
356 | public bool m_dupeInProgress = false; | ||
288 | internal Dictionary<UUID, string> m_savedScriptState; | 357 | internal Dictionary<UUID, string> m_savedScriptState; |
289 | 358 | ||
290 | #region Properties | 359 | #region Properties |
@@ -321,6 +390,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
321 | get { return m_parts.Count; } | 390 | get { return m_parts.Count; } |
322 | } | 391 | } |
323 | 392 | ||
393 | // protected Quaternion m_rotation = Quaternion.Identity; | ||
394 | // | ||
395 | // public virtual Quaternion Rotation | ||
396 | // { | ||
397 | // get { return m_rotation; } | ||
398 | // set { | ||
399 | // m_rotation = value; | ||
400 | // } | ||
401 | // } | ||
402 | |||
324 | public Quaternion GroupRotation | 403 | public Quaternion GroupRotation |
325 | { | 404 | { |
326 | get { return m_rootPart.RotationOffset; } | 405 | get { return m_rootPart.RotationOffset; } |
@@ -427,7 +506,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
427 | { | 506 | { |
428 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); | 507 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); |
429 | } | 508 | } |
430 | 509 | ||
510 | |||
511 | |||
512 | private struct avtocrossInfo | ||
513 | { | ||
514 | public ScenePresence av; | ||
515 | public uint ParentID; | ||
516 | } | ||
517 | |||
431 | /// <summary> | 518 | /// <summary> |
432 | /// The absolute position of this scene object in the scene | 519 | /// The absolute position of this scene object in the scene |
433 | /// </summary> | 520 | /// </summary> |
@@ -455,13 +542,129 @@ namespace OpenSim.Region.Framework.Scenes | |||
455 | || Scene.TestBorderCross(val, Cardinals.S)) | 542 | || Scene.TestBorderCross(val, Cardinals.S)) |
456 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) | 543 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) |
457 | { | 544 | { |
545 | IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | ||
546 | uint x = 0; | ||
547 | uint y = 0; | ||
548 | string version = String.Empty; | ||
549 | Vector3 newpos = Vector3.Zero; | ||
550 | OpenSim.Services.Interfaces.GridRegion destination = null; | ||
551 | |||
458 | if (m_rootPart.KeyframeMotion != null) | 552 | if (m_rootPart.KeyframeMotion != null) |
459 | m_rootPart.KeyframeMotion.StartCrossingCheck(); | 553 | m_rootPart.KeyframeMotion.StartCrossingCheck(); |
460 | 554 | ||
461 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | 555 | bool canCross = true; |
556 | foreach (ScenePresence av in m_linkedAvatars) | ||
557 | { | ||
558 | // We need to cross these agents. First, let's find | ||
559 | // out if any of them can't cross for some reason. | ||
560 | // We have to deny the crossing entirely if any | ||
561 | // of them are banned. Alternatively, we could | ||
562 | // unsit banned agents.... | ||
563 | |||
564 | |||
565 | // We set the avatar position as being the object | ||
566 | // position to get the region to send to | ||
567 | if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) | ||
568 | { | ||
569 | canCross = false; | ||
570 | break; | ||
571 | } | ||
572 | |||
573 | m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); | ||
574 | } | ||
575 | |||
576 | if (canCross) | ||
577 | { | ||
578 | // We unparent the SP quietly so that it won't | ||
579 | // be made to stand up | ||
580 | |||
581 | List<avtocrossInfo> avsToCross = new List<avtocrossInfo>(); | ||
582 | |||
583 | foreach (ScenePresence av in m_linkedAvatars) | ||
584 | { | ||
585 | avtocrossInfo avinfo = new avtocrossInfo(); | ||
586 | SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); | ||
587 | if (parentPart != null) | ||
588 | av.ParentUUID = parentPart.UUID; | ||
589 | |||
590 | avinfo.av = av; | ||
591 | avinfo.ParentID = av.ParentID; | ||
592 | avsToCross.Add(avinfo); | ||
593 | |||
594 | av.ParentID = 0; | ||
595 | } | ||
596 | |||
597 | // m_linkedAvatars.Clear(); | ||
598 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | ||
599 | |||
600 | // Normalize | ||
601 | if (val.X >= Constants.RegionSize) | ||
602 | val.X -= Constants.RegionSize; | ||
603 | if (val.Y >= Constants.RegionSize) | ||
604 | val.Y -= Constants.RegionSize; | ||
605 | if (val.X < 0) | ||
606 | val.X += Constants.RegionSize; | ||
607 | if (val.Y < 0) | ||
608 | val.Y += Constants.RegionSize; | ||
609 | |||
610 | // If it's deleted, crossing was successful | ||
611 | if (IsDeleted) | ||
612 | { | ||
613 | // foreach (ScenePresence av in m_linkedAvatars) | ||
614 | foreach (avtocrossInfo avinfo in avsToCross) | ||
615 | { | ||
616 | ScenePresence av = avinfo.av; | ||
617 | if (!av.IsInTransit) // just in case... | ||
618 | { | ||
619 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); | ||
620 | |||
621 | av.IsInTransit = true; | ||
622 | |||
623 | CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; | ||
624 | d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); | ||
625 | } | ||
626 | else | ||
627 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); | ||
628 | } | ||
629 | avsToCross.Clear(); | ||
630 | return; | ||
631 | } | ||
632 | else // cross failed, put avas back ?? | ||
633 | { | ||
634 | foreach (avtocrossInfo avinfo in avsToCross) | ||
635 | { | ||
636 | ScenePresence av = avinfo.av; | ||
637 | av.ParentUUID = UUID.Zero; | ||
638 | av.ParentID = avinfo.ParentID; | ||
639 | // m_linkedAvatars.Add(av); | ||
640 | } | ||
641 | } | ||
642 | avsToCross.Clear(); | ||
643 | |||
644 | } | ||
645 | else | ||
646 | { | ||
647 | if (m_rootPart.KeyframeMotion != null) | ||
648 | m_rootPart.KeyframeMotion.CrossingFailure(); | ||
649 | |||
650 | if (RootPart.PhysActor != null) | ||
651 | { | ||
652 | RootPart.PhysActor.CrossingFailure(); | ||
653 | } | ||
654 | } | ||
655 | Vector3 oldp = AbsolutePosition; | ||
656 | val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
657 | val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
658 | val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f); | ||
462 | } | 659 | } |
463 | } | 660 | } |
464 | 661 | ||
662 | /* don't see the need but worse don't see where is restored to false if things stay in | ||
663 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
664 | { | ||
665 | part.IgnoreUndoUpdate = true; | ||
666 | } | ||
667 | */ | ||
465 | if (RootPart.GetStatusSandbox()) | 668 | if (RootPart.GetStatusSandbox()) |
466 | { | 669 | { |
467 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) | 670 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) |
@@ -479,9 +682,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
479 | // Restuff the new GroupPosition into each SOP of the linkset. | 682 | // Restuff the new GroupPosition into each SOP of the linkset. |
480 | // This has the affect of resetting and tainting the physics actors. | 683 | // This has the affect of resetting and tainting the physics actors. |
481 | SceneObjectPart[] parts = m_parts.GetArray(); | 684 | SceneObjectPart[] parts = m_parts.GetArray(); |
482 | for (int i = 0; i < parts.Length; i++) | 685 | bool triggerScriptEvent = m_rootPart.GroupPosition != val; |
483 | parts[i].GroupPosition = val; | 686 | if (m_dupeInProgress) |
687 | triggerScriptEvent = false; | ||
688 | foreach (SceneObjectPart part in parts) | ||
689 | { | ||
690 | part.GroupPosition = val; | ||
691 | if (triggerScriptEvent) | ||
692 | part.TriggerScriptChangedEvent(Changed.POSITION); | ||
693 | } | ||
484 | 694 | ||
695 | /* | ||
696 | This seems not needed and should not be needed: | ||
697 | sp absolute position depends on sit part absolute position fixed above. | ||
698 | sp ParentPosition is not used anywhere. | ||
699 | Since presence is sitting, viewer considers it 'linked' to root prim, so it will move/rotate it | ||
700 | Sending a extra packet with avatar position is not only bandwidth waste, but may cause jitter in viewers due to UPD nature. | ||
701 | |||
702 | if (!m_dupeInProgress) | ||
703 | { | ||
704 | foreach (ScenePresence av in m_linkedAvatars) | ||
705 | { | ||
706 | SceneObjectPart p = m_scene.GetSceneObjectPart(av.ParentID); | ||
707 | if (p != null && m_parts.TryGetValue(p.UUID, out p)) | ||
708 | { | ||
709 | Vector3 offset = p.GetWorldPosition() - av.ParentPosition; | ||
710 | av.AbsolutePosition += offset; | ||
711 | // av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition | ||
712 | av.SendAvatarDataToAllAgents(); | ||
713 | } | ||
714 | } | ||
715 | } | ||
716 | */ | ||
485 | //if (m_rootPart.PhysActor != null) | 717 | //if (m_rootPart.PhysActor != null) |
486 | //{ | 718 | //{ |
487 | //m_rootPart.PhysActor.Position = | 719 | //m_rootPart.PhysActor.Position = |
@@ -495,6 +727,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
495 | } | 727 | } |
496 | } | 728 | } |
497 | 729 | ||
730 | public override Vector3 Velocity | ||
731 | { | ||
732 | get { return RootPart.Velocity; } | ||
733 | set { RootPart.Velocity = value; } | ||
734 | } | ||
735 | |||
736 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) | ||
737 | { | ||
738 | CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; | ||
739 | ScenePresence agent = icon.EndInvoke(iar); | ||
740 | |||
741 | //// If the cross was successful, this agent is a child agent | ||
742 | if (agent.IsChildAgent) | ||
743 | { | ||
744 | if (agent.ParentUUID != UUID.Zero) | ||
745 | { | ||
746 | agent.ParentPart = null; | ||
747 | // agent.ParentPosition = Vector3.Zero; | ||
748 | // agent.ParentUUID = UUID.Zero; | ||
749 | } | ||
750 | } | ||
751 | |||
752 | agent.ParentUUID = UUID.Zero; | ||
753 | |||
754 | // agent.Reset(); | ||
755 | // else // Not successful | ||
756 | // agent.RestoreInCurrentScene(); | ||
757 | |||
758 | // In any case | ||
759 | agent.IsInTransit = false; | ||
760 | |||
761 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | ||
762 | } | ||
763 | |||
498 | public override uint LocalId | 764 | public override uint LocalId |
499 | { | 765 | { |
500 | get { return m_rootPart.LocalId; } | 766 | get { return m_rootPart.LocalId; } |
@@ -565,6 +831,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
565 | m_isSelected = value; | 831 | m_isSelected = value; |
566 | // Tell physics engine that group is selected | 832 | // Tell physics engine that group is selected |
567 | 833 | ||
834 | // this is not right | ||
835 | // but ode engines should only really need to know about root part | ||
836 | // so they can put entire object simulation on hold and not colliding | ||
837 | // keep as was for now | ||
838 | |||
568 | PhysicsActor pa = m_rootPart.PhysActor; | 839 | PhysicsActor pa = m_rootPart.PhysActor; |
569 | if (pa != null) | 840 | if (pa != null) |
570 | { | 841 | { |
@@ -586,6 +857,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
586 | } | 857 | } |
587 | } | 858 | } |
588 | 859 | ||
860 | public void PartSelectChanged(bool partSelect) | ||
861 | { | ||
862 | // any part selected makes group selected | ||
863 | if (m_isSelected == partSelect) | ||
864 | return; | ||
865 | |||
866 | if (partSelect) | ||
867 | { | ||
868 | IsSelected = partSelect; | ||
869 | // if (!IsAttachment) | ||
870 | // ScheduleGroupForFullUpdate(); | ||
871 | } | ||
872 | else | ||
873 | { | ||
874 | // bad bad bad 2 heavy for large linksets | ||
875 | // since viewer does send lot of (un)selects | ||
876 | // this needs to be replaced by a specific list or count ? | ||
877 | // but that will require extra code in several places | ||
878 | |||
879 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
880 | for (int i = 0; i < parts.Length; i++) | ||
881 | { | ||
882 | SceneObjectPart part = parts[i]; | ||
883 | if (part.IsSelected) | ||
884 | return; | ||
885 | } | ||
886 | IsSelected = partSelect; | ||
887 | if (!IsAttachment) | ||
888 | { | ||
889 | ScheduleGroupForFullUpdate(); | ||
890 | } | ||
891 | } | ||
892 | } | ||
893 | |||
589 | private SceneObjectPart m_PlaySoundMasterPrim = null; | 894 | private SceneObjectPart m_PlaySoundMasterPrim = null; |
590 | public SceneObjectPart PlaySoundMasterPrim | 895 | public SceneObjectPart PlaySoundMasterPrim |
591 | { | 896 | { |
@@ -680,6 +985,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
680 | /// </summary> | 985 | /// </summary> |
681 | public SceneObjectGroup() | 986 | public SceneObjectGroup() |
682 | { | 987 | { |
988 | |||
683 | } | 989 | } |
684 | 990 | ||
685 | /// <summary> | 991 | /// <summary> |
@@ -697,8 +1003,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
697 | /// Constructor. This object is added to the scene later via AttachToScene() | 1003 | /// Constructor. This object is added to the scene later via AttachToScene() |
698 | /// </summary> | 1004 | /// </summary> |
699 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 1005 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
700 | :this(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)) | 1006 | { |
701 | { | 1007 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
702 | } | 1008 | } |
703 | 1009 | ||
704 | /// <summary> | 1010 | /// <summary> |
@@ -733,6 +1039,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
733 | /// </summary> | 1039 | /// </summary> |
734 | public virtual void AttachToBackup() | 1040 | public virtual void AttachToBackup() |
735 | { | 1041 | { |
1042 | if (IsAttachment) return; | ||
1043 | m_scene.SceneGraph.FireAttachToBackup(this); | ||
1044 | |||
736 | if (InSceneBackup) | 1045 | if (InSceneBackup) |
737 | { | 1046 | { |
738 | //m_log.DebugFormat( | 1047 | //m_log.DebugFormat( |
@@ -775,6 +1084,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
775 | 1084 | ||
776 | ApplyPhysics(); | 1085 | ApplyPhysics(); |
777 | 1086 | ||
1087 | if (RootPart.PhysActor != null) | ||
1088 | RootPart.Force = RootPart.Force; | ||
1089 | if (RootPart.PhysActor != null) | ||
1090 | RootPart.Torque = RootPart.Torque; | ||
1091 | if (RootPart.PhysActor != null) | ||
1092 | RootPart.Buoyancy = RootPart.Buoyancy; | ||
1093 | |||
778 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | 1094 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
779 | // for the same object with very different properties. The caller must schedule the update. | 1095 | // for the same object with very different properties. The caller must schedule the update. |
780 | //ScheduleGroupForFullUpdate(); | 1096 | //ScheduleGroupForFullUpdate(); |
@@ -790,6 +1106,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
790 | EntityIntersection result = new EntityIntersection(); | 1106 | EntityIntersection result = new EntityIntersection(); |
791 | 1107 | ||
792 | SceneObjectPart[] parts = m_parts.GetArray(); | 1108 | SceneObjectPart[] parts = m_parts.GetArray(); |
1109 | |||
1110 | // Find closest hit here | ||
1111 | float idist = float.MaxValue; | ||
1112 | |||
793 | for (int i = 0; i < parts.Length; i++) | 1113 | for (int i = 0; i < parts.Length; i++) |
794 | { | 1114 | { |
795 | SceneObjectPart part = parts[i]; | 1115 | SceneObjectPart part = parts[i]; |
@@ -804,11 +1124,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
804 | 1124 | ||
805 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); | 1125 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); |
806 | 1126 | ||
807 | // This may need to be updated to the maximum draw distance possible.. | ||
808 | // We might (and probably will) be checking for prim creation from other sims | ||
809 | // when the camera crosses the border. | ||
810 | float idist = Constants.RegionSize; | ||
811 | |||
812 | if (inter.HitTF) | 1127 | if (inter.HitTF) |
813 | { | 1128 | { |
814 | // We need to find the closest prim to return to the testcaller along the ray | 1129 | // We need to find the closest prim to return to the testcaller along the ray |
@@ -819,10 +1134,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
819 | result.obj = part; | 1134 | result.obj = part; |
820 | result.normal = inter.normal; | 1135 | result.normal = inter.normal; |
821 | result.distance = inter.distance; | 1136 | result.distance = inter.distance; |
1137 | |||
1138 | idist = inter.distance; | ||
822 | } | 1139 | } |
823 | } | 1140 | } |
824 | } | 1141 | } |
825 | |||
826 | return result; | 1142 | return result; |
827 | } | 1143 | } |
828 | 1144 | ||
@@ -834,25 +1150,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
834 | /// <returns></returns> | 1150 | /// <returns></returns> |
835 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) | 1151 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) |
836 | { | 1152 | { |
837 | maxX = -256f; | 1153 | maxX = float.MinValue; |
838 | maxY = -256f; | 1154 | maxY = float.MinValue; |
839 | maxZ = -256f; | 1155 | maxZ = float.MinValue; |
840 | minX = 256f; | 1156 | minX = float.MaxValue; |
841 | minY = 256f; | 1157 | minY = float.MaxValue; |
842 | minZ = 8192f; | 1158 | minZ = float.MaxValue; |
843 | 1159 | ||
844 | SceneObjectPart[] parts = m_parts.GetArray(); | 1160 | SceneObjectPart[] parts = m_parts.GetArray(); |
845 | for (int i = 0; i < parts.Length; i++) | 1161 | foreach (SceneObjectPart part in parts) |
846 | { | 1162 | { |
847 | SceneObjectPart part = parts[i]; | ||
848 | |||
849 | Vector3 worldPos = part.GetWorldPosition(); | 1163 | Vector3 worldPos = part.GetWorldPosition(); |
850 | Vector3 offset = worldPos - AbsolutePosition; | 1164 | Vector3 offset = worldPos - AbsolutePosition; |
851 | Quaternion worldRot; | 1165 | Quaternion worldRot; |
852 | if (part.ParentID == 0) | 1166 | if (part.ParentID == 0) |
1167 | { | ||
853 | worldRot = part.RotationOffset; | 1168 | worldRot = part.RotationOffset; |
1169 | } | ||
854 | else | 1170 | else |
1171 | { | ||
855 | worldRot = part.GetWorldRotation(); | 1172 | worldRot = part.GetWorldRotation(); |
1173 | } | ||
856 | 1174 | ||
857 | Vector3 frontTopLeft; | 1175 | Vector3 frontTopLeft; |
858 | Vector3 frontTopRight; | 1176 | Vector3 frontTopRight; |
@@ -864,6 +1182,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
864 | Vector3 backBottomLeft; | 1182 | Vector3 backBottomLeft; |
865 | Vector3 backBottomRight; | 1183 | Vector3 backBottomRight; |
866 | 1184 | ||
1185 | // Vector3[] corners = new Vector3[8]; | ||
1186 | |||
867 | Vector3 orig = Vector3.Zero; | 1187 | Vector3 orig = Vector3.Zero; |
868 | 1188 | ||
869 | frontTopLeft.X = orig.X - (part.Scale.X / 2); | 1189 | frontTopLeft.X = orig.X - (part.Scale.X / 2); |
@@ -898,6 +1218,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
898 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); | 1218 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); |
899 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); | 1219 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); |
900 | 1220 | ||
1221 | |||
1222 | |||
1223 | //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1224 | //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1225 | //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1226 | //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1227 | //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1228 | //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1229 | //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1230 | //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1231 | |||
1232 | //for (int i = 0; i < 8; i++) | ||
1233 | //{ | ||
1234 | // corners[i] = corners[i] * worldRot; | ||
1235 | // corners[i] += offset; | ||
1236 | |||
1237 | // if (corners[i].X > maxX) | ||
1238 | // maxX = corners[i].X; | ||
1239 | // if (corners[i].X < minX) | ||
1240 | // minX = corners[i].X; | ||
1241 | |||
1242 | // if (corners[i].Y > maxY) | ||
1243 | // maxY = corners[i].Y; | ||
1244 | // if (corners[i].Y < minY) | ||
1245 | // minY = corners[i].Y; | ||
1246 | |||
1247 | // if (corners[i].Z > maxZ) | ||
1248 | // maxZ = corners[i].Y; | ||
1249 | // if (corners[i].Z < minZ) | ||
1250 | // minZ = corners[i].Z; | ||
1251 | //} | ||
1252 | |||
901 | frontTopLeft = frontTopLeft * worldRot; | 1253 | frontTopLeft = frontTopLeft * worldRot; |
902 | frontTopRight = frontTopRight * worldRot; | 1254 | frontTopRight = frontTopRight * worldRot; |
903 | frontBottomLeft = frontBottomLeft * worldRot; | 1255 | frontBottomLeft = frontBottomLeft * worldRot; |
@@ -919,6 +1271,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
919 | backTopLeft += offset; | 1271 | backTopLeft += offset; |
920 | backTopRight += offset; | 1272 | backTopRight += offset; |
921 | 1273 | ||
1274 | //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1275 | //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1276 | //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1277 | //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1278 | //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1279 | //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1280 | //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1281 | //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1282 | |||
922 | if (frontTopRight.X > maxX) | 1283 | if (frontTopRight.X > maxX) |
923 | maxX = frontTopRight.X; | 1284 | maxX = frontTopRight.X; |
924 | if (frontTopLeft.X > maxX) | 1285 | if (frontTopLeft.X > maxX) |
@@ -1062,17 +1423,118 @@ namespace OpenSim.Region.Framework.Scenes | |||
1062 | 1423 | ||
1063 | #endregion | 1424 | #endregion |
1064 | 1425 | ||
1426 | public void GetResourcesCosts(SceneObjectPart apart, | ||
1427 | out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost) | ||
1428 | { | ||
1429 | // this information may need to be cached | ||
1430 | |||
1431 | float cost; | ||
1432 | float tmpcost; | ||
1433 | |||
1434 | bool ComplexCost = false; | ||
1435 | |||
1436 | SceneObjectPart p; | ||
1437 | SceneObjectPart[] parts; | ||
1438 | |||
1439 | lock (m_parts) | ||
1440 | { | ||
1441 | parts = m_parts.GetArray(); | ||
1442 | } | ||
1443 | |||
1444 | int nparts = parts.Length; | ||
1445 | |||
1446 | |||
1447 | for (int i = 0; i < nparts; i++) | ||
1448 | { | ||
1449 | p = parts[i]; | ||
1450 | |||
1451 | if (p.UsesComplexCost) | ||
1452 | { | ||
1453 | ComplexCost = true; | ||
1454 | break; | ||
1455 | } | ||
1456 | } | ||
1457 | |||
1458 | if (ComplexCost) | ||
1459 | { | ||
1460 | linksetResCost = 0; | ||
1461 | linksetPhysCost = 0; | ||
1462 | partCost = 0; | ||
1463 | partPhysCost = 0; | ||
1464 | |||
1465 | for (int i = 0; i < nparts; i++) | ||
1466 | { | ||
1467 | p = parts[i]; | ||
1468 | |||
1469 | cost = p.StreamingCost; | ||
1470 | tmpcost = p.SimulationCost; | ||
1471 | if (tmpcost > cost) | ||
1472 | cost = tmpcost; | ||
1473 | tmpcost = p.PhysicsCost; | ||
1474 | if (tmpcost > cost) | ||
1475 | cost = tmpcost; | ||
1476 | |||
1477 | linksetPhysCost += tmpcost; | ||
1478 | linksetResCost += cost; | ||
1479 | |||
1480 | if (p == apart) | ||
1481 | { | ||
1482 | partCost = cost; | ||
1483 | partPhysCost = tmpcost; | ||
1484 | } | ||
1485 | } | ||
1486 | } | ||
1487 | else | ||
1488 | { | ||
1489 | partPhysCost = 1.0f; | ||
1490 | partCost = 1.0f; | ||
1491 | linksetResCost = (float)nparts; | ||
1492 | linksetPhysCost = linksetResCost; | ||
1493 | } | ||
1494 | } | ||
1495 | |||
1496 | public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost) | ||
1497 | { | ||
1498 | SceneObjectPart p; | ||
1499 | SceneObjectPart[] parts; | ||
1500 | |||
1501 | lock (m_parts) | ||
1502 | { | ||
1503 | parts = m_parts.GetArray(); | ||
1504 | } | ||
1505 | |||
1506 | int nparts = parts.Length; | ||
1507 | |||
1508 | PhysCost = 0; | ||
1509 | StreamCost = 0; | ||
1510 | SimulCost = 0; | ||
1511 | |||
1512 | for (int i = 0; i < nparts; i++) | ||
1513 | { | ||
1514 | p = parts[i]; | ||
1515 | |||
1516 | StreamCost += p.StreamingCost; | ||
1517 | SimulCost += p.SimulationCost; | ||
1518 | PhysCost += p.PhysicsCost; | ||
1519 | } | ||
1520 | } | ||
1521 | |||
1065 | public void SaveScriptedState(XmlTextWriter writer) | 1522 | public void SaveScriptedState(XmlTextWriter writer) |
1066 | { | 1523 | { |
1524 | SaveScriptedState(writer, false); | ||
1525 | } | ||
1526 | |||
1527 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1528 | { | ||
1067 | XmlDocument doc = new XmlDocument(); | 1529 | XmlDocument doc = new XmlDocument(); |
1068 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1530 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
1069 | 1531 | ||
1070 | SceneObjectPart[] parts = m_parts.GetArray(); | 1532 | SceneObjectPart[] parts = m_parts.GetArray(); |
1071 | for (int i = 0; i < parts.Length; i++) | 1533 | for (int i = 0; i < parts.Length; i++) |
1072 | { | 1534 | { |
1073 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(); | 1535 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(oldIDs); |
1074 | foreach (KeyValuePair<UUID, string> kvp in pstates) | 1536 | foreach (KeyValuePair<UUID, string> kvp in pstates) |
1075 | states.Add(kvp.Key, kvp.Value); | 1537 | states[kvp.Key] = kvp.Value; |
1076 | } | 1538 | } |
1077 | 1539 | ||
1078 | if (states.Count > 0) | 1540 | if (states.Count > 0) |
@@ -1092,6 +1554,169 @@ namespace OpenSim.Region.Framework.Scenes | |||
1092 | } | 1554 | } |
1093 | 1555 | ||
1094 | /// <summary> | 1556 | /// <summary> |
1557 | /// Add the avatar to this linkset (avatar is sat). | ||
1558 | /// </summary> | ||
1559 | /// <param name="agentID"></param> | ||
1560 | public void AddAvatar(UUID agentID) | ||
1561 | { | ||
1562 | ScenePresence presence; | ||
1563 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1564 | { | ||
1565 | if (!m_linkedAvatars.Contains(presence)) | ||
1566 | { | ||
1567 | m_linkedAvatars.Add(presence); | ||
1568 | } | ||
1569 | } | ||
1570 | } | ||
1571 | |||
1572 | /// <summary> | ||
1573 | /// Delete the avatar from this linkset (avatar is unsat). | ||
1574 | /// </summary> | ||
1575 | /// <param name="agentID"></param> | ||
1576 | public void DeleteAvatar(UUID agentID) | ||
1577 | { | ||
1578 | ScenePresence presence; | ||
1579 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1580 | { | ||
1581 | if (m_linkedAvatars.Contains(presence)) | ||
1582 | { | ||
1583 | m_linkedAvatars.Remove(presence); | ||
1584 | } | ||
1585 | } | ||
1586 | } | ||
1587 | |||
1588 | /// <summary> | ||
1589 | /// Returns the list of linked presences (avatars sat on this group) | ||
1590 | /// </summary> | ||
1591 | /// <param name="agentID"></param> | ||
1592 | public List<ScenePresence> GetLinkedAvatars() | ||
1593 | { | ||
1594 | return m_linkedAvatars; | ||
1595 | } | ||
1596 | |||
1597 | /// <summary> | ||
1598 | /// Attach this scene object to the given avatar. | ||
1599 | /// </summary> | ||
1600 | /// <param name="agentID"></param> | ||
1601 | /// <param name="attachmentpoint"></param> | ||
1602 | /// <param name="AttachOffset"></param> | ||
1603 | private void AttachToAgent( | ||
1604 | ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | ||
1605 | { | ||
1606 | if (avatar != null) | ||
1607 | { | ||
1608 | // don't attach attachments to child agents | ||
1609 | if (avatar.IsChildAgent) return; | ||
1610 | |||
1611 | // Remove from database and parcel prim count | ||
1612 | m_scene.DeleteFromStorage(so.UUID); | ||
1613 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1614 | |||
1615 | so.AttachedAvatar = avatar.UUID; | ||
1616 | |||
1617 | if (so.RootPart.PhysActor != null) | ||
1618 | { | ||
1619 | m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); | ||
1620 | so.RootPart.PhysActor = null; | ||
1621 | } | ||
1622 | |||
1623 | so.AbsolutePosition = attachOffset; | ||
1624 | so.RootPart.AttachedPos = attachOffset; | ||
1625 | so.IsAttachment = true; | ||
1626 | so.RootPart.SetParentLocalId(avatar.LocalId); | ||
1627 | so.AttachmentPoint = attachmentpoint; | ||
1628 | |||
1629 | avatar.AddAttachment(this); | ||
1630 | |||
1631 | if (!silent) | ||
1632 | { | ||
1633 | // Killing it here will cause the client to deselect it | ||
1634 | // It then reappears on the avatar, deselected | ||
1635 | // through the full update below | ||
1636 | // | ||
1637 | if (IsSelected) | ||
1638 | { | ||
1639 | m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId }); | ||
1640 | } | ||
1641 | |||
1642 | IsSelected = false; // fudge.... | ||
1643 | ScheduleGroupForFullUpdate(); | ||
1644 | } | ||
1645 | } | ||
1646 | else | ||
1647 | { | ||
1648 | m_log.WarnFormat( | ||
1649 | "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", | ||
1650 | UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName); | ||
1651 | } | ||
1652 | } | ||
1653 | |||
1654 | public byte GetAttachmentPoint() | ||
1655 | { | ||
1656 | return m_rootPart.Shape.State; | ||
1657 | } | ||
1658 | |||
1659 | public void DetachToGround() | ||
1660 | { | ||
1661 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1662 | if (avatar == null) | ||
1663 | return; | ||
1664 | |||
1665 | avatar.RemoveAttachment(this); | ||
1666 | |||
1667 | Vector3 detachedpos = new Vector3(127f,127f,127f); | ||
1668 | if (avatar == null) | ||
1669 | return; | ||
1670 | |||
1671 | detachedpos = avatar.AbsolutePosition; | ||
1672 | FromItemID = UUID.Zero; | ||
1673 | |||
1674 | AbsolutePosition = detachedpos; | ||
1675 | AttachedAvatar = UUID.Zero; | ||
1676 | |||
1677 | //SceneObjectPart[] parts = m_parts.GetArray(); | ||
1678 | //for (int i = 0; i < parts.Length; i++) | ||
1679 | // parts[i].AttachedAvatar = UUID.Zero; | ||
1680 | |||
1681 | m_rootPart.SetParentLocalId(0); | ||
1682 | AttachmentPoint = (byte)0; | ||
1683 | // must check if buildind should be true or false here | ||
1684 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false); | ||
1685 | HasGroupChanged = true; | ||
1686 | RootPart.Rezzed = DateTime.Now; | ||
1687 | RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
1688 | AttachToBackup(); | ||
1689 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1690 | m_rootPart.ScheduleFullUpdate(); | ||
1691 | m_rootPart.ClearUndoState(); | ||
1692 | } | ||
1693 | |||
1694 | public void DetachToInventoryPrep() | ||
1695 | { | ||
1696 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1697 | //Vector3 detachedpos = new Vector3(127f, 127f, 127f); | ||
1698 | if (avatar != null) | ||
1699 | { | ||
1700 | //detachedpos = avatar.AbsolutePosition; | ||
1701 | avatar.RemoveAttachment(this); | ||
1702 | } | ||
1703 | |||
1704 | AttachedAvatar = UUID.Zero; | ||
1705 | |||
1706 | /*SceneObjectPart[] parts = m_parts.GetArray(); | ||
1707 | for (int i = 0; i < parts.Length; i++) | ||
1708 | parts[i].AttachedAvatar = UUID.Zero;*/ | ||
1709 | |||
1710 | m_rootPart.SetParentLocalId(0); | ||
1711 | //m_rootPart.SetAttachmentPoint((byte)0); | ||
1712 | IsAttachment = false; | ||
1713 | AbsolutePosition = m_rootPart.AttachedPos; | ||
1714 | //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); | ||
1715 | //AttachToBackup(); | ||
1716 | //m_rootPart.ScheduleFullUpdate(); | ||
1717 | } | ||
1718 | |||
1719 | /// <summary> | ||
1095 | /// | 1720 | /// |
1096 | /// </summary> | 1721 | /// </summary> |
1097 | /// <param name="part"></param> | 1722 | /// <param name="part"></param> |
@@ -1131,7 +1756,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1131 | public void AddPart(SceneObjectPart part) | 1756 | public void AddPart(SceneObjectPart part) |
1132 | { | 1757 | { |
1133 | part.SetParent(this); | 1758 | part.SetParent(this); |
1134 | part.LinkNum = m_parts.Add(part.UUID, part); | 1759 | m_parts.Add(part.UUID, part); |
1760 | |||
1761 | part.LinkNum = m_parts.Count; | ||
1762 | |||
1135 | if (part.LinkNum == 2) | 1763 | if (part.LinkNum == 2) |
1136 | RootPart.LinkNum = 1; | 1764 | RootPart.LinkNum = 1; |
1137 | } | 1765 | } |
@@ -1157,6 +1785,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1157 | parts[i].UUID = UUID.Random(); | 1785 | parts[i].UUID = UUID.Random(); |
1158 | } | 1786 | } |
1159 | 1787 | ||
1788 | // helper provided for parts. | ||
1789 | public int GetSceneMaxUndo() | ||
1790 | { | ||
1791 | if (m_scene != null) | ||
1792 | return m_scene.MaxUndoCount; | ||
1793 | return 5; | ||
1794 | } | ||
1795 | |||
1160 | // justincc: I don't believe this hack is needed any longer, especially since the physics | 1796 | // justincc: I don't believe this hack is needed any longer, especially since the physics |
1161 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false | 1797 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false |
1162 | // this method was preventing proper reload of scene objects. | 1798 | // this method was preventing proper reload of scene objects. |
@@ -1214,7 +1850,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1214 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", | 1850 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", |
1215 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); | 1851 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); |
1216 | 1852 | ||
1217 | part.StoreUndoState(); | 1853 | // part.StoreUndoState(); |
1218 | part.OnGrab(offsetPos, remoteClient); | 1854 | part.OnGrab(offsetPos, remoteClient); |
1219 | } | 1855 | } |
1220 | 1856 | ||
@@ -1234,6 +1870,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1234 | /// <param name="silent">If true then deletion is not broadcast to clients</param> | 1870 | /// <param name="silent">If true then deletion is not broadcast to clients</param> |
1235 | public void DeleteGroupFromScene(bool silent) | 1871 | public void DeleteGroupFromScene(bool silent) |
1236 | { | 1872 | { |
1873 | // We need to keep track of this state in case this group is still queued for backup. | ||
1874 | IsDeleted = true; | ||
1875 | |||
1876 | DetachFromBackup(); | ||
1877 | |||
1237 | SceneObjectPart[] parts = m_parts.GetArray(); | 1878 | SceneObjectPart[] parts = m_parts.GetArray(); |
1238 | for (int i = 0; i < parts.Length; i++) | 1879 | for (int i = 0; i < parts.Length; i++) |
1239 | { | 1880 | { |
@@ -1257,6 +1898,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1257 | } | 1898 | } |
1258 | }); | 1899 | }); |
1259 | } | 1900 | } |
1901 | |||
1260 | } | 1902 | } |
1261 | 1903 | ||
1262 | public void AddScriptLPS(int count) | 1904 | public void AddScriptLPS(int count) |
@@ -1326,28 +1968,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1326 | /// </summary> | 1968 | /// </summary> |
1327 | public void ApplyPhysics() | 1969 | public void ApplyPhysics() |
1328 | { | 1970 | { |
1329 | // Apply physics to the root prim | ||
1330 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); | ||
1331 | |||
1332 | // Apply physics to child prims | ||
1333 | SceneObjectPart[] parts = m_parts.GetArray(); | 1971 | SceneObjectPart[] parts = m_parts.GetArray(); |
1334 | if (parts.Length > 1) | 1972 | if (parts.Length > 1) |
1335 | { | 1973 | { |
1974 | ResetChildPrimPhysicsPositions(); | ||
1975 | |||
1976 | // Apply physics to the root prim | ||
1977 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true); | ||
1978 | |||
1979 | |||
1336 | for (int i = 0; i < parts.Length; i++) | 1980 | for (int i = 0; i < parts.Length; i++) |
1337 | { | 1981 | { |
1338 | SceneObjectPart part = parts[i]; | 1982 | SceneObjectPart part = parts[i]; |
1339 | if (part.LocalId != m_rootPart.LocalId) | 1983 | if (part.LocalId != m_rootPart.LocalId) |
1340 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); | 1984 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, true); |
1341 | } | 1985 | } |
1342 | |||
1343 | // Hack to get the physics scene geometries in the right spot | 1986 | // Hack to get the physics scene geometries in the right spot |
1344 | ResetChildPrimPhysicsPositions(); | 1987 | // ResetChildPrimPhysicsPositions(); |
1988 | if (m_rootPart.PhysActor != null) | ||
1989 | { | ||
1990 | m_rootPart.PhysActor.Building = false; | ||
1991 | } | ||
1992 | } | ||
1993 | else | ||
1994 | { | ||
1995 | // Apply physics to the root prim | ||
1996 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); | ||
1345 | } | 1997 | } |
1346 | } | 1998 | } |
1347 | 1999 | ||
1348 | public void SetOwnerId(UUID userId) | 2000 | public void SetOwnerId(UUID userId) |
1349 | { | 2001 | { |
1350 | ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); | 2002 | ForEachPart(delegate(SceneObjectPart part) |
2003 | { | ||
2004 | |||
2005 | part.OwnerID = userId; | ||
2006 | |||
2007 | }); | ||
1351 | } | 2008 | } |
1352 | 2009 | ||
1353 | public void ForEachPart(Action<SceneObjectPart> whatToDo) | 2010 | public void ForEachPart(Action<SceneObjectPart> whatToDo) |
@@ -1379,11 +2036,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1379 | return; | 2036 | return; |
1380 | } | 2037 | } |
1381 | 2038 | ||
2039 | if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | ||
2040 | return; | ||
2041 | |||
1382 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let | 2042 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let |
1383 | // any exception propogate upwards. | 2043 | // any exception propogate upwards. |
1384 | try | 2044 | try |
1385 | { | 2045 | { |
1386 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart | 2046 | if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart |
2047 | !m_scene.LoginsEnabled || // We're starting up or doing maintenance, don't mess with things | ||
2048 | m_scene.LoadingPrims) // Land may not be valid yet | ||
2049 | |||
1387 | { | 2050 | { |
1388 | ILandObject parcel = m_scene.LandChannel.GetLandObject( | 2051 | ILandObject parcel = m_scene.LandChannel.GetLandObject( |
1389 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); | 2052 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); |
@@ -1410,6 +2073,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1410 | } | 2073 | } |
1411 | } | 2074 | } |
1412 | } | 2075 | } |
2076 | |||
1413 | } | 2077 | } |
1414 | 2078 | ||
1415 | if (m_scene.UseBackup && HasGroupChanged) | 2079 | if (m_scene.UseBackup && HasGroupChanged) |
@@ -1417,10 +2081,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1417 | // don't backup while it's selected or you're asking for changes mid stream. | 2081 | // don't backup while it's selected or you're asking for changes mid stream. |
1418 | if (isTimeToPersist() || forcedBackup) | 2082 | if (isTimeToPersist() || forcedBackup) |
1419 | { | 2083 | { |
2084 | if (m_rootPart.PhysActor != null && | ||
2085 | (!m_rootPart.PhysActor.IsPhysical)) | ||
2086 | { | ||
2087 | // Possible ghost prim | ||
2088 | if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) | ||
2089 | { | ||
2090 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
2091 | { | ||
2092 | // Re-set physics actor positions and | ||
2093 | // orientations | ||
2094 | part.GroupPosition = m_rootPart.GroupPosition; | ||
2095 | } | ||
2096 | } | ||
2097 | } | ||
1420 | // m_log.DebugFormat( | 2098 | // m_log.DebugFormat( |
1421 | // "[SCENE]: Storing {0}, {1} in {2}", | 2099 | // "[SCENE]: Storing {0}, {1} in {2}", |
1422 | // Name, UUID, m_scene.RegionInfo.RegionName); | 2100 | // Name, UUID, m_scene.RegionInfo.RegionName); |
1423 | 2101 | ||
2102 | if (RootPart.Shape.PCode == 9 && RootPart.Shape.State != 0) | ||
2103 | { | ||
2104 | RootPart.Shape.State = 0; | ||
2105 | ScheduleGroupForFullUpdate(); | ||
2106 | } | ||
2107 | |||
1424 | SceneObjectGroup backup_group = Copy(false); | 2108 | SceneObjectGroup backup_group = Copy(false); |
1425 | backup_group.RootPart.Velocity = RootPart.Velocity; | 2109 | backup_group.RootPart.Velocity = RootPart.Velocity; |
1426 | backup_group.RootPart.Acceleration = RootPart.Acceleration; | 2110 | backup_group.RootPart.Acceleration = RootPart.Acceleration; |
@@ -1430,6 +2114,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1430 | HasGroupChangedDueToDelink = false; | 2114 | HasGroupChangedDueToDelink = false; |
1431 | 2115 | ||
1432 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); | 2116 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); |
2117 | /* | ||
2118 | backup_group.ForEachPart(delegate(SceneObjectPart part) | ||
2119 | { | ||
2120 | if (part.KeyframeMotion != null) | ||
2121 | { | ||
2122 | part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); | ||
2123 | // part.KeyframeMotion.UpdateSceneObject(this); | ||
2124 | } | ||
2125 | }); | ||
2126 | */ | ||
1433 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); | 2127 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); |
1434 | 2128 | ||
1435 | backup_group.ForEachPart(delegate(SceneObjectPart part) | 2129 | backup_group.ForEachPart(delegate(SceneObjectPart part) |
@@ -1486,10 +2180,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1486 | /// <returns></returns> | 2180 | /// <returns></returns> |
1487 | public SceneObjectGroup Copy(bool userExposed) | 2181 | public SceneObjectGroup Copy(bool userExposed) |
1488 | { | 2182 | { |
2183 | m_dupeInProgress = true; | ||
1489 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); | 2184 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); |
1490 | dupe.m_isBackedUp = false; | 2185 | dupe.m_isBackedUp = false; |
1491 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); | 2186 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); |
1492 | 2187 | ||
2188 | // new group as no sitting avatars | ||
2189 | dupe.m_linkedAvatars = new List<ScenePresence>(); | ||
2190 | |||
1493 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of | 2191 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of |
1494 | // attachments do not bordercross while they're being duplicated. This is hacktastic! | 2192 | // attachments do not bordercross while they're being duplicated. This is hacktastic! |
1495 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! | 2193 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! |
@@ -1500,7 +2198,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1500 | // This is only necessary when userExposed is false! | 2198 | // This is only necessary when userExposed is false! |
1501 | 2199 | ||
1502 | bool previousAttachmentStatus = dupe.IsAttachment; | 2200 | bool previousAttachmentStatus = dupe.IsAttachment; |
1503 | 2201 | ||
1504 | if (!userExposed) | 2202 | if (!userExposed) |
1505 | dupe.IsAttachment = true; | 2203 | dupe.IsAttachment = true; |
1506 | 2204 | ||
@@ -1513,16 +2211,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1513 | 2211 | ||
1514 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); | 2212 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); |
1515 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; | 2213 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; |
2214 | |||
1516 | 2215 | ||
1517 | if (userExposed) | 2216 | if (userExposed) |
1518 | dupe.m_rootPart.TrimPermissions(); | 2217 | dupe.m_rootPart.TrimPermissions(); |
1519 | 2218 | ||
1520 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); | 2219 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); |
1521 | 2220 | ||
1522 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | 2221 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) |
1523 | { | 2222 | { |
1524 | return p1.LinkNum.CompareTo(p2.LinkNum); | 2223 | return p1.LinkNum.CompareTo(p2.LinkNum); |
1525 | } | 2224 | } |
1526 | ); | 2225 | ); |
1527 | 2226 | ||
1528 | foreach (SceneObjectPart part in partList) | 2227 | foreach (SceneObjectPart part in partList) |
@@ -1532,43 +2231,56 @@ namespace OpenSim.Region.Framework.Scenes | |||
1532 | { | 2231 | { |
1533 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); | 2232 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); |
1534 | newPart.LinkNum = part.LinkNum; | 2233 | newPart.LinkNum = part.LinkNum; |
1535 | } | 2234 | if (userExposed) |
2235 | newPart.ParentID = dupe.m_rootPart.LocalId; | ||
2236 | } | ||
1536 | else | 2237 | else |
1537 | { | 2238 | { |
1538 | newPart = dupe.m_rootPart; | 2239 | newPart = dupe.m_rootPart; |
1539 | } | 2240 | } |
2241 | /* | ||
2242 | bool isphys = ((newPart.Flags & PrimFlags.Physics) != 0); | ||
2243 | bool isphan = ((newPart.Flags & PrimFlags.Phantom) != 0); | ||
1540 | 2244 | ||
1541 | // Need to duplicate the physics actor as well | 2245 | // Need to duplicate the physics actor as well |
1542 | PhysicsActor originalPartPa = part.PhysActor; | 2246 | if (userExposed && (isphys || !isphan || newPart.VolumeDetectActive)) |
1543 | if (originalPartPa != null && userExposed) | ||
1544 | { | 2247 | { |
1545 | PrimitiveBaseShape pbs = newPart.Shape; | 2248 | PrimitiveBaseShape pbs = newPart.Shape; |
1546 | |||
1547 | newPart.PhysActor | 2249 | newPart.PhysActor |
1548 | = m_scene.PhysicsScene.AddPrimShape( | 2250 | = m_scene.PhysicsScene.AddPrimShape( |
1549 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), | 2251 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), |
1550 | pbs, | 2252 | pbs, |
1551 | newPart.AbsolutePosition, | 2253 | newPart.AbsolutePosition, |
1552 | newPart.Scale, | 2254 | newPart.Scale, |
1553 | newPart.RotationOffset, | 2255 | newPart.GetWorldRotation(), |
1554 | originalPartPa.IsPhysical, | 2256 | isphys, |
2257 | isphan, | ||
1555 | newPart.LocalId); | 2258 | newPart.LocalId); |
1556 | 2259 | ||
1557 | newPart.DoPhysicsPropertyUpdate(originalPartPa.IsPhysical, true); | 2260 | newPart.DoPhysicsPropertyUpdate(isphys, true); |
1558 | } | 2261 | */ |
2262 | if (userExposed) | ||
2263 | newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true); | ||
2264 | // } | ||
2265 | // copy keyframemotion | ||
1559 | if (part.KeyframeMotion != null) | 2266 | if (part.KeyframeMotion != null) |
1560 | newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); | 2267 | newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); |
1561 | } | 2268 | } |
1562 | 2269 | ||
1563 | if (userExposed) | 2270 | if (userExposed) |
1564 | { | 2271 | { |
1565 | dupe.UpdateParentIDs(); | 2272 | // done above dupe.UpdateParentIDs(); |
2273 | |||
2274 | if (dupe.m_rootPart.PhysActor != null) | ||
2275 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building | ||
2276 | |||
1566 | dupe.HasGroupChanged = true; | 2277 | dupe.HasGroupChanged = true; |
1567 | dupe.AttachToBackup(); | 2278 | dupe.AttachToBackup(); |
1568 | 2279 | ||
1569 | ScheduleGroupForFullUpdate(); | 2280 | ScheduleGroupForFullUpdate(); |
1570 | } | 2281 | } |
1571 | 2282 | ||
2283 | m_dupeInProgress = false; | ||
1572 | return dupe; | 2284 | return dupe; |
1573 | } | 2285 | } |
1574 | 2286 | ||
@@ -1580,7 +2292,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1580 | /// <param name="cGroupID"></param> | 2292 | /// <param name="cGroupID"></param> |
1581 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2293 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1582 | { | 2294 | { |
1583 | SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); | 2295 | // SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); |
2296 | // give newpart a new local ID lettng old part keep same | ||
2297 | SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed); | ||
2298 | newpart.LocalId = m_scene.AllocateLocalId(); | ||
2299 | |||
2300 | SetRootPart(newpart); | ||
2301 | if (userExposed) | ||
2302 | RootPart.Velocity = Vector3.Zero; // In case source is moving | ||
1584 | } | 2303 | } |
1585 | 2304 | ||
1586 | public void ScriptSetPhysicsStatus(bool usePhysics) | 2305 | public void ScriptSetPhysicsStatus(bool usePhysics) |
@@ -1638,27 +2357,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1638 | 2357 | ||
1639 | if (pa != null) | 2358 | if (pa != null) |
1640 | { | 2359 | { |
1641 | pa.AddForce(impulse, true); | 2360 | // false to be applied as a impulse |
1642 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2361 | pa.AddForce(impulse, false); |
1643 | } | ||
1644 | } | ||
1645 | } | ||
1646 | |||
1647 | public void applyAngularImpulse(Vector3 impulse) | ||
1648 | { | ||
1649 | PhysicsActor pa = RootPart.PhysActor; | ||
1650 | |||
1651 | if (pa != null) | ||
1652 | { | ||
1653 | if (!IsAttachment) | ||
1654 | { | ||
1655 | pa.AddAngularForce(impulse, true); | ||
1656 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2362 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1657 | } | 2363 | } |
1658 | } | 2364 | } |
1659 | } | 2365 | } |
1660 | 2366 | ||
1661 | public void setAngularImpulse(Vector3 impulse) | 2367 | public void ApplyAngularImpulse(Vector3 impulse) |
1662 | { | 2368 | { |
1663 | PhysicsActor pa = RootPart.PhysActor; | 2369 | PhysicsActor pa = RootPart.PhysActor; |
1664 | 2370 | ||
@@ -1666,7 +2372,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1666 | { | 2372 | { |
1667 | if (!IsAttachment) | 2373 | if (!IsAttachment) |
1668 | { | 2374 | { |
1669 | pa.Torque = impulse; | 2375 | // false to be applied as a impulse |
2376 | pa.AddAngularForce(impulse, false); | ||
1670 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2377 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1671 | } | 2378 | } |
1672 | } | 2379 | } |
@@ -1674,20 +2381,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1674 | 2381 | ||
1675 | public Vector3 GetTorque() | 2382 | public Vector3 GetTorque() |
1676 | { | 2383 | { |
1677 | PhysicsActor pa = RootPart.PhysActor; | 2384 | return RootPart.Torque; |
1678 | |||
1679 | if (pa != null) | ||
1680 | { | ||
1681 | if (!IsAttachment) | ||
1682 | { | ||
1683 | Vector3 torque = pa.Torque; | ||
1684 | return torque; | ||
1685 | } | ||
1686 | } | ||
1687 | |||
1688 | return Vector3.Zero; | ||
1689 | } | 2385 | } |
1690 | 2386 | ||
2387 | // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object | ||
1691 | public void moveToTarget(Vector3 target, float tau) | 2388 | public void moveToTarget(Vector3 target, float tau) |
1692 | { | 2389 | { |
1693 | if (IsAttachment) | 2390 | if (IsAttachment) |
@@ -1717,8 +2414,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
1717 | 2414 | ||
1718 | if (pa != null) | 2415 | if (pa != null) |
1719 | pa.PIDActive = false; | 2416 | pa.PIDActive = false; |
2417 | |||
2418 | RootPart.ScheduleTerseUpdate(); // send a stop information | ||
2419 | } | ||
2420 | |||
2421 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2422 | { | ||
2423 | SceneObjectPart rootpart = m_rootPart; | ||
2424 | if (rootpart != null) | ||
2425 | { | ||
2426 | if (IsAttachment) | ||
2427 | { | ||
2428 | /* | ||
2429 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
2430 | if (avatar != null) | ||
2431 | { | ||
2432 | Rotate the Av? | ||
2433 | } */ | ||
2434 | } | ||
2435 | else | ||
2436 | { | ||
2437 | if (rootpart.PhysActor != null) | ||
2438 | { // APID must be implemented in your physics system for this to function. | ||
2439 | rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); | ||
2440 | rootpart.PhysActor.APIDStrength = strength; | ||
2441 | rootpart.PhysActor.APIDDamping = damping; | ||
2442 | rootpart.PhysActor.APIDActive = true; | ||
2443 | } | ||
2444 | } | ||
2445 | } | ||
1720 | } | 2446 | } |
2447 | |||
2448 | public void stopLookAt() | ||
2449 | { | ||
2450 | SceneObjectPart rootpart = m_rootPart; | ||
2451 | if (rootpart != null) | ||
2452 | { | ||
2453 | if (rootpart.PhysActor != null) | ||
2454 | { // APID must be implemented in your physics system for this to function. | ||
2455 | rootpart.PhysActor.APIDActive = false; | ||
2456 | } | ||
2457 | } | ||
1721 | 2458 | ||
2459 | } | ||
2460 | |||
1722 | /// <summary> | 2461 | /// <summary> |
1723 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. | 2462 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. |
1724 | /// </summary> | 2463 | /// </summary> |
@@ -1735,7 +2474,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1735 | { | 2474 | { |
1736 | pa.PIDHoverHeight = height; | 2475 | pa.PIDHoverHeight = height; |
1737 | pa.PIDHoverType = hoverType; | 2476 | pa.PIDHoverType = hoverType; |
1738 | pa.PIDTau = tau; | 2477 | pa.PIDHoverTau = tau; |
1739 | pa.PIDHoverActive = true; | 2478 | pa.PIDHoverActive = true; |
1740 | } | 2479 | } |
1741 | else | 2480 | else |
@@ -1775,7 +2514,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1775 | /// <param name="cGroupID"></param> | 2514 | /// <param name="cGroupID"></param> |
1776 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2515 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1777 | { | 2516 | { |
1778 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | 2517 | // give new ID to the new part, letting old keep original |
2518 | // SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | ||
2519 | SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); | ||
2520 | newPart.LocalId = m_scene.AllocateLocalId(); | ||
2521 | newPart.SetParent(this); | ||
2522 | |||
1779 | AddPart(newPart); | 2523 | AddPart(newPart); |
1780 | 2524 | ||
1781 | SetPartAsNonRoot(newPart); | 2525 | SetPartAsNonRoot(newPart); |
@@ -1825,6 +2569,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1825 | 2569 | ||
1826 | #endregion | 2570 | #endregion |
1827 | 2571 | ||
2572 | |||
1828 | public override void Update() | 2573 | public override void Update() |
1829 | { | 2574 | { |
1830 | // Check that the group was not deleted before the scheduled update | 2575 | // Check that the group was not deleted before the scheduled update |
@@ -1843,19 +2588,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1843 | // check to see if the physical position or rotation warrant an update. | 2588 | // check to see if the physical position or rotation warrant an update. |
1844 | if (m_rootPart.UpdateFlag == UpdateRequired.NONE) | 2589 | if (m_rootPart.UpdateFlag == UpdateRequired.NONE) |
1845 | { | 2590 | { |
1846 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); | 2591 | // rootpart SendScheduledUpdates will check if a update is needed |
1847 | 2592 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | |
1848 | if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) | ||
1849 | { | ||
1850 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | ||
1851 | lastPhysGroupPos = AbsolutePosition; | ||
1852 | } | ||
1853 | |||
1854 | if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) | ||
1855 | { | ||
1856 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | ||
1857 | lastPhysGroupRot = GroupRotation; | ||
1858 | } | ||
1859 | } | 2593 | } |
1860 | 2594 | ||
1861 | SceneObjectPart[] parts = m_parts.GetArray(); | 2595 | SceneObjectPart[] parts = m_parts.GetArray(); |
@@ -1914,11 +2648,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1914 | /// Immediately send a full update for this scene object. | 2648 | /// Immediately send a full update for this scene object. |
1915 | /// </summary> | 2649 | /// </summary> |
1916 | public void SendGroupFullUpdate() | 2650 | public void SendGroupFullUpdate() |
1917 | { | 2651 | { |
1918 | if (IsDeleted) | 2652 | if (IsDeleted) |
1919 | return; | 2653 | return; |
1920 | 2654 | ||
1921 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); | 2655 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); |
1922 | 2656 | ||
1923 | RootPart.SendFullUpdateToAllClients(); | 2657 | RootPart.SendFullUpdateToAllClients(); |
1924 | 2658 | ||
@@ -2074,6 +2808,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2074 | // 'linkPart' == the root of the group being linked into this group | 2808 | // 'linkPart' == the root of the group being linked into this group |
2075 | SceneObjectPart linkPart = objectGroup.m_rootPart; | 2809 | SceneObjectPart linkPart = objectGroup.m_rootPart; |
2076 | 2810 | ||
2811 | if (m_rootPart.PhysActor != null) | ||
2812 | m_rootPart.PhysActor.Building = true; | ||
2813 | if (linkPart.PhysActor != null) | ||
2814 | linkPart.PhysActor.Building = true; | ||
2815 | |||
2077 | // physics flags from group to be applied to linked parts | 2816 | // physics flags from group to be applied to linked parts |
2078 | bool grpusephys = UsesPhysics; | 2817 | bool grpusephys = UsesPhysics; |
2079 | bool grptemporary = IsTemporary; | 2818 | bool grptemporary = IsTemporary; |
@@ -2099,12 +2838,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2099 | Vector3 axPos = linkPart.OffsetPosition; | 2838 | Vector3 axPos = linkPart.OffsetPosition; |
2100 | // Rotate the linking root SOP's position to be relative to the new root prim | 2839 | // Rotate the linking root SOP's position to be relative to the new root prim |
2101 | Quaternion parentRot = m_rootPart.RotationOffset; | 2840 | Quaternion parentRot = m_rootPart.RotationOffset; |
2102 | axPos *= Quaternion.Inverse(parentRot); | 2841 | axPos *= Quaternion.Conjugate(parentRot); |
2103 | linkPart.OffsetPosition = axPos; | 2842 | linkPart.OffsetPosition = axPos; |
2104 | 2843 | ||
2105 | // Make the linking root SOP's rotation relative to the new root prim | 2844 | // Make the linking root SOP's rotation relative to the new root prim |
2106 | Quaternion oldRot = linkPart.RotationOffset; | 2845 | Quaternion oldRot = linkPart.RotationOffset; |
2107 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 2846 | Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; |
2108 | linkPart.RotationOffset = newRot; | 2847 | linkPart.RotationOffset = newRot; |
2109 | 2848 | ||
2110 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. | 2849 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. |
@@ -2138,7 +2877,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2138 | linkPart.CreateSelected = true; | 2877 | linkPart.CreateSelected = true; |
2139 | 2878 | ||
2140 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now | 2879 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now |
2141 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive); | 2880 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); |
2142 | 2881 | ||
2143 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 2882 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2144 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2883 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2148,6 +2887,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2148 | } | 2887 | } |
2149 | 2888 | ||
2150 | linkPart.LinkNum = linkNum++; | 2889 | linkPart.LinkNum = linkNum++; |
2890 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2151 | 2891 | ||
2152 | // Get a list of the SOP's in the old group in order of their linknum's. | 2892 | // Get a list of the SOP's in the old group in order of their linknum's. |
2153 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2893 | SceneObjectPart[] ogParts = objectGroup.Parts; |
@@ -2166,7 +2906,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2166 | 2906 | ||
2167 | // Update the physics flags for the newly added SOP | 2907 | // Update the physics flags for the newly added SOP |
2168 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) | 2908 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) |
2169 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive); | 2909 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); |
2170 | 2910 | ||
2171 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 2911 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2172 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2912 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2184,7 +2924,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2184 | objectGroup.IsDeleted = true; | 2924 | objectGroup.IsDeleted = true; |
2185 | 2925 | ||
2186 | objectGroup.m_parts.Clear(); | 2926 | objectGroup.m_parts.Clear(); |
2187 | 2927 | ||
2188 | // Can't do this yet since backup still makes use of the root part without any synchronization | 2928 | // Can't do this yet since backup still makes use of the root part without any synchronization |
2189 | // objectGroup.m_rootPart = null; | 2929 | // objectGroup.m_rootPart = null; |
2190 | 2930 | ||
@@ -2198,6 +2938,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2198 | // unmoved prims! | 2938 | // unmoved prims! |
2199 | ResetChildPrimPhysicsPositions(); | 2939 | ResetChildPrimPhysicsPositions(); |
2200 | 2940 | ||
2941 | if (m_rootPart.PhysActor != null) | ||
2942 | m_rootPart.PhysActor.Building = false; | ||
2943 | |||
2201 | //HasGroupChanged = true; | 2944 | //HasGroupChanged = true; |
2202 | //ScheduleGroupForFullUpdate(); | 2945 | //ScheduleGroupForFullUpdate(); |
2203 | } | 2946 | } |
@@ -2265,7 +3008,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2265 | // m_log.DebugFormat( | 3008 | // m_log.DebugFormat( |
2266 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", | 3009 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", |
2267 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); | 3010 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); |
2268 | 3011 | ||
3012 | if (m_rootPart.PhysActor != null) | ||
3013 | m_rootPart.PhysActor.Building = true; | ||
3014 | |||
2269 | linkPart.ClearUndoState(); | 3015 | linkPart.ClearUndoState(); |
2270 | 3016 | ||
2271 | Vector3 worldPos = linkPart.GetWorldPosition(); | 3017 | Vector3 worldPos = linkPart.GetWorldPosition(); |
@@ -2336,6 +3082,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2336 | 3082 | ||
2337 | // When we delete a group, we currently have to force persist to the database if the object id has changed | 3083 | // When we delete a group, we currently have to force persist to the database if the object id has changed |
2338 | // (since delete works by deleting all rows which have a given object id) | 3084 | // (since delete works by deleting all rows which have a given object id) |
3085 | |||
3086 | // this is as it seems to be in sl now | ||
3087 | if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none) | ||
3088 | linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now | ||
3089 | |||
3090 | if (m_rootPart.PhysActor != null) | ||
3091 | m_rootPart.PhysActor.Building = false; | ||
3092 | |||
2339 | objectGroup.HasGroupChangedDueToDelink = true; | 3093 | objectGroup.HasGroupChangedDueToDelink = true; |
2340 | 3094 | ||
2341 | return objectGroup; | 3095 | return objectGroup; |
@@ -2347,6 +3101,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2347 | /// <param name="objectGroup"></param> | 3101 | /// <param name="objectGroup"></param> |
2348 | public virtual void DetachFromBackup() | 3102 | public virtual void DetachFromBackup() |
2349 | { | 3103 | { |
3104 | if (m_scene != null) | ||
3105 | m_scene.SceneGraph.FireDetachFromBackup(this); | ||
2350 | if (m_isBackedUp && Scene != null) | 3106 | if (m_isBackedUp && Scene != null) |
2351 | m_scene.EventManager.OnBackup -= ProcessBackup; | 3107 | m_scene.EventManager.OnBackup -= ProcessBackup; |
2352 | 3108 | ||
@@ -2367,7 +3123,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2367 | Vector3 axPos = part.OffsetPosition; | 3123 | Vector3 axPos = part.OffsetPosition; |
2368 | axPos *= parentRot; | 3124 | axPos *= parentRot; |
2369 | part.OffsetPosition = axPos; | 3125 | part.OffsetPosition = axPos; |
2370 | part.GroupPosition = oldGroupPosition + part.OffsetPosition; | 3126 | Vector3 newPos = oldGroupPosition + part.OffsetPosition; |
3127 | part.GroupPosition = newPos; | ||
2371 | part.OffsetPosition = Vector3.Zero; | 3128 | part.OffsetPosition = Vector3.Zero; |
2372 | 3129 | ||
2373 | // Compution our rotation to be not relative to the old parent | 3130 | // Compution our rotation to be not relative to the old parent |
@@ -2382,7 +3139,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2382 | part.LinkNum = linkNum; | 3139 | part.LinkNum = linkNum; |
2383 | 3140 | ||
2384 | // Compute the new position of this SOP relative to the group position | 3141 | // Compute the new position of this SOP relative to the group position |
2385 | part.OffsetPosition = part.GroupPosition - AbsolutePosition; | 3142 | part.OffsetPosition = newPos - AbsolutePosition; |
2386 | 3143 | ||
2387 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. | 3144 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. |
2388 | // It would have the affect of setting the physics engine position multiple | 3145 | // It would have the affect of setting the physics engine position multiple |
@@ -2392,18 +3149,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2392 | // Rotate the relative position by the rotation of the group | 3149 | // Rotate the relative position by the rotation of the group |
2393 | Quaternion rootRotation = m_rootPart.RotationOffset; | 3150 | Quaternion rootRotation = m_rootPart.RotationOffset; |
2394 | Vector3 pos = part.OffsetPosition; | 3151 | Vector3 pos = part.OffsetPosition; |
2395 | pos *= Quaternion.Inverse(rootRotation); | 3152 | pos *= Quaternion.Conjugate(rootRotation); |
2396 | part.OffsetPosition = pos; | 3153 | part.OffsetPosition = pos; |
2397 | 3154 | ||
2398 | // Compute the SOP's rotation relative to the rotation of the group. | 3155 | // Compute the SOP's rotation relative to the rotation of the group. |
2399 | parentRot = m_rootPart.RotationOffset; | 3156 | parentRot = m_rootPart.RotationOffset; |
2400 | oldRot = part.RotationOffset; | 3157 | oldRot = part.RotationOffset; |
2401 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 3158 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
2402 | part.RotationOffset = newRot; | 3159 | part.RotationOffset = newRot; |
2403 | 3160 | ||
2404 | // Since this SOP's state has changed, push those changes into the physics engine | 3161 | // Since this SOP's state has changed, push those changes into the physics engine |
2405 | // and the simulator. | 3162 | // and the simulator. |
2406 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 3163 | // done on caller |
3164 | // part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2407 | } | 3165 | } |
2408 | 3166 | ||
2409 | /// <summary> | 3167 | /// <summary> |
@@ -2425,10 +3183,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2425 | { | 3183 | { |
2426 | if (!m_rootPart.BlockGrab) | 3184 | if (!m_rootPart.BlockGrab) |
2427 | { | 3185 | { |
2428 | Vector3 llmoveforce = pos - AbsolutePosition; | 3186 | /* Vector3 llmoveforce = pos - AbsolutePosition; |
2429 | Vector3 grabforce = llmoveforce; | 3187 | Vector3 grabforce = llmoveforce; |
2430 | grabforce = (grabforce / 10) * pa.Mass; | 3188 | grabforce = (grabforce / 10) * pa.Mass; |
2431 | pa.AddForce(grabforce, true); | 3189 | */ |
3190 | // empirically convert distance diference to a impulse | ||
3191 | Vector3 grabforce = pos - AbsolutePosition; | ||
3192 | grabforce = grabforce * (pa.Mass/ 10.0f); | ||
3193 | pa.AddForce(grabforce, false); | ||
2432 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 3194 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
2433 | } | 3195 | } |
2434 | } | 3196 | } |
@@ -2624,6 +3386,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2624 | /// <param name="SetVolumeDetect"></param> | 3386 | /// <param name="SetVolumeDetect"></param> |
2625 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) | 3387 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) |
2626 | { | 3388 | { |
3389 | HasGroupChanged = true; | ||
3390 | |||
2627 | SceneObjectPart selectionPart = GetPart(localID); | 3391 | SceneObjectPart selectionPart = GetPart(localID); |
2628 | 3392 | ||
2629 | if (SetTemporary && Scene != null) | 3393 | if (SetTemporary && Scene != null) |
@@ -2654,8 +3418,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2654 | } | 3418 | } |
2655 | } | 3419 | } |
2656 | 3420 | ||
2657 | for (int i = 0; i < parts.Length; i++) | 3421 | if (parts.Length > 1) |
2658 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); | 3422 | { |
3423 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3424 | |||
3425 | for (int i = 0; i < parts.Length; i++) | ||
3426 | { | ||
3427 | |||
3428 | if (parts[i].UUID != m_rootPart.UUID) | ||
3429 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3430 | } | ||
3431 | |||
3432 | if (m_rootPart.PhysActor != null) | ||
3433 | m_rootPart.PhysActor.Building = false; | ||
3434 | } | ||
3435 | else | ||
3436 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); | ||
2659 | } | 3437 | } |
2660 | } | 3438 | } |
2661 | 3439 | ||
@@ -2668,6 +3446,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2668 | } | 3446 | } |
2669 | } | 3447 | } |
2670 | 3448 | ||
3449 | |||
3450 | |||
3451 | /// <summary> | ||
3452 | /// Gets the number of parts | ||
3453 | /// </summary> | ||
3454 | /// <returns></returns> | ||
3455 | public int GetPartCount() | ||
3456 | { | ||
3457 | return Parts.Count(); | ||
3458 | } | ||
3459 | |||
2671 | /// <summary> | 3460 | /// <summary> |
2672 | /// Update the texture entry for this part | 3461 | /// Update the texture entry for this part |
2673 | /// </summary> | 3462 | /// </summary> |
@@ -2705,8 +3494,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2705 | { | 3494 | { |
2706 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); | 3495 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); |
2707 | 3496 | ||
3497 | bool god = Scene.Permissions.IsGod(AgentID); | ||
3498 | |||
3499 | if (field == 1 && god) | ||
3500 | { | ||
3501 | ForEachPart(part => | ||
3502 | { | ||
3503 | part.BaseMask = RootPart.BaseMask; | ||
3504 | }); | ||
3505 | } | ||
3506 | |||
2708 | AdjustChildPrimPermissions(); | 3507 | AdjustChildPrimPermissions(); |
2709 | 3508 | ||
3509 | if (field == 1 && god) // Base mask was set. Update all child part inventories | ||
3510 | { | ||
3511 | foreach (SceneObjectPart part in Parts) | ||
3512 | part.Inventory.ApplyGodPermissions(RootPart.BaseMask); | ||
3513 | } | ||
3514 | |||
2710 | HasGroupChanged = true; | 3515 | HasGroupChanged = true; |
2711 | 3516 | ||
2712 | // Send the group's properties to all clients once all parts are updated | 3517 | // Send the group's properties to all clients once all parts are updated |
@@ -2752,8 +3557,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2752 | 3557 | ||
2753 | PhysicsActor pa = m_rootPart.PhysActor; | 3558 | PhysicsActor pa = m_rootPart.PhysActor; |
2754 | 3559 | ||
2755 | RootPart.StoreUndoState(true); | ||
2756 | |||
2757 | if (Scene != null) | 3560 | if (Scene != null) |
2758 | { | 3561 | { |
2759 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); | 3562 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); |
@@ -2781,7 +3584,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2781 | SceneObjectPart obPart = parts[i]; | 3584 | SceneObjectPart obPart = parts[i]; |
2782 | if (obPart.UUID != m_rootPart.UUID) | 3585 | if (obPart.UUID != m_rootPart.UUID) |
2783 | { | 3586 | { |
2784 | // obPart.IgnoreUndoUpdate = true; | ||
2785 | Vector3 oldSize = new Vector3(obPart.Scale); | 3587 | Vector3 oldSize = new Vector3(obPart.Scale); |
2786 | 3588 | ||
2787 | float f = 1.0f; | 3589 | float f = 1.0f; |
@@ -2893,8 +3695,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2893 | z *= a; | 3695 | z *= a; |
2894 | } | 3696 | } |
2895 | } | 3697 | } |
2896 | |||
2897 | // obPart.IgnoreUndoUpdate = false; | ||
2898 | } | 3698 | } |
2899 | } | 3699 | } |
2900 | } | 3700 | } |
@@ -2904,9 +3704,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2904 | prevScale.Y *= y; | 3704 | prevScale.Y *= y; |
2905 | prevScale.Z *= z; | 3705 | prevScale.Z *= z; |
2906 | 3706 | ||
2907 | // RootPart.IgnoreUndoUpdate = true; | ||
2908 | RootPart.Resize(prevScale); | 3707 | RootPart.Resize(prevScale); |
2909 | // RootPart.IgnoreUndoUpdate = false; | ||
2910 | 3708 | ||
2911 | for (int i = 0; i < parts.Length; i++) | 3709 | for (int i = 0; i < parts.Length; i++) |
2912 | { | 3710 | { |
@@ -2914,8 +3712,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2914 | 3712 | ||
2915 | if (obPart.UUID != m_rootPart.UUID) | 3713 | if (obPart.UUID != m_rootPart.UUID) |
2916 | { | 3714 | { |
2917 | obPart.IgnoreUndoUpdate = true; | ||
2918 | |||
2919 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); | 3715 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); |
2920 | currentpos.X *= x; | 3716 | currentpos.X *= x; |
2921 | currentpos.Y *= y; | 3717 | currentpos.Y *= y; |
@@ -2928,16 +3724,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2928 | 3724 | ||
2929 | obPart.Resize(newSize); | 3725 | obPart.Resize(newSize); |
2930 | obPart.UpdateOffSet(currentpos); | 3726 | obPart.UpdateOffSet(currentpos); |
2931 | |||
2932 | obPart.IgnoreUndoUpdate = false; | ||
2933 | } | 3727 | } |
2934 | 3728 | ||
2935 | // obPart.IgnoreUndoUpdate = false; | 3729 | HasGroupChanged = true; |
2936 | // obPart.StoreUndoState(); | 3730 | m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); |
3731 | ScheduleGroupForTerseUpdate(); | ||
2937 | } | 3732 | } |
2938 | |||
2939 | // m_log.DebugFormat( | ||
2940 | // "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); | ||
2941 | } | 3733 | } |
2942 | 3734 | ||
2943 | #endregion | 3735 | #endregion |
@@ -2950,14 +3742,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2950 | /// <param name="pos"></param> | 3742 | /// <param name="pos"></param> |
2951 | public void UpdateGroupPosition(Vector3 pos) | 3743 | public void UpdateGroupPosition(Vector3 pos) |
2952 | { | 3744 | { |
2953 | // m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); | ||
2954 | |||
2955 | RootPart.StoreUndoState(true); | ||
2956 | |||
2957 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2958 | // for (int i = 0; i < parts.Length; i++) | ||
2959 | // parts[i].StoreUndoState(); | ||
2960 | |||
2961 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 3745 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
2962 | { | 3746 | { |
2963 | if (IsAttachment) | 3747 | if (IsAttachment) |
@@ -2990,21 +3774,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2990 | /// </summary> | 3774 | /// </summary> |
2991 | /// <param name="pos"></param> | 3775 | /// <param name="pos"></param> |
2992 | /// <param name="localID"></param> | 3776 | /// <param name="localID"></param> |
3777 | /// | ||
3778 | |||
2993 | public void UpdateSinglePosition(Vector3 pos, uint localID) | 3779 | public void UpdateSinglePosition(Vector3 pos, uint localID) |
2994 | { | 3780 | { |
2995 | SceneObjectPart part = GetPart(localID); | 3781 | SceneObjectPart part = GetPart(localID); |
2996 | 3782 | ||
2997 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2998 | // for (int i = 0; i < parts.Length; i++) | ||
2999 | // parts[i].StoreUndoState(); | ||
3000 | |||
3001 | if (part != null) | 3783 | if (part != null) |
3002 | { | 3784 | { |
3003 | // m_log.DebugFormat( | 3785 | // unlock parts position change |
3004 | // "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); | 3786 | if (m_rootPart.PhysActor != null) |
3005 | 3787 | m_rootPart.PhysActor.Building = true; | |
3006 | part.StoreUndoState(false); | ||
3007 | part.IgnoreUndoUpdate = true; | ||
3008 | 3788 | ||
3009 | if (part.UUID == m_rootPart.UUID) | 3789 | if (part.UUID == m_rootPart.UUID) |
3010 | { | 3790 | { |
@@ -3015,8 +3795,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3015 | part.UpdateOffSet(pos); | 3795 | part.UpdateOffSet(pos); |
3016 | } | 3796 | } |
3017 | 3797 | ||
3798 | if (m_rootPart.PhysActor != null) | ||
3799 | m_rootPart.PhysActor.Building = false; | ||
3800 | |||
3018 | HasGroupChanged = true; | 3801 | HasGroupChanged = true; |
3019 | part.IgnoreUndoUpdate = false; | ||
3020 | } | 3802 | } |
3021 | } | 3803 | } |
3022 | 3804 | ||
@@ -3026,13 +3808,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3026 | /// <param name="pos"></param> | 3808 | /// <param name="pos"></param> |
3027 | public void UpdateRootPosition(Vector3 pos) | 3809 | public void UpdateRootPosition(Vector3 pos) |
3028 | { | 3810 | { |
3029 | // m_log.DebugFormat( | 3811 | // needs to be called with phys building true |
3030 | // "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); | ||
3031 | |||
3032 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3033 | // for (int i = 0; i < parts.Length; i++) | ||
3034 | // parts[i].StoreUndoState(); | ||
3035 | |||
3036 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); | 3812 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); |
3037 | Vector3 oldPos = | 3813 | Vector3 oldPos = |
3038 | new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, | 3814 | new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, |
@@ -3055,7 +3831,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3055 | AbsolutePosition = newPos; | 3831 | AbsolutePosition = newPos; |
3056 | 3832 | ||
3057 | HasGroupChanged = true; | 3833 | HasGroupChanged = true; |
3058 | ScheduleGroupForTerseUpdate(); | 3834 | if (m_rootPart.Undoing) |
3835 | { | ||
3836 | ScheduleGroupForFullUpdate(); | ||
3837 | } | ||
3838 | else | ||
3839 | { | ||
3840 | ScheduleGroupForTerseUpdate(); | ||
3841 | } | ||
3059 | } | 3842 | } |
3060 | 3843 | ||
3061 | #endregion | 3844 | #endregion |
@@ -3068,24 +3851,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3068 | /// <param name="rot"></param> | 3851 | /// <param name="rot"></param> |
3069 | public void UpdateGroupRotationR(Quaternion rot) | 3852 | public void UpdateGroupRotationR(Quaternion rot) |
3070 | { | 3853 | { |
3071 | // m_log.DebugFormat( | ||
3072 | // "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); | ||
3073 | |||
3074 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3075 | // for (int i = 0; i < parts.Length; i++) | ||
3076 | // parts[i].StoreUndoState(); | ||
3077 | |||
3078 | m_rootPart.StoreUndoState(true); | ||
3079 | |||
3080 | m_rootPart.UpdateRotation(rot); | 3854 | m_rootPart.UpdateRotation(rot); |
3081 | 3855 | ||
3856 | /* this is done by rootpart RotationOffset set called by UpdateRotation | ||
3082 | PhysicsActor actor = m_rootPart.PhysActor; | 3857 | PhysicsActor actor = m_rootPart.PhysActor; |
3083 | if (actor != null) | 3858 | if (actor != null) |
3084 | { | 3859 | { |
3085 | actor.Orientation = m_rootPart.RotationOffset; | 3860 | actor.Orientation = m_rootPart.RotationOffset; |
3086 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); | 3861 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
3087 | } | 3862 | } |
3088 | 3863 | */ | |
3089 | HasGroupChanged = true; | 3864 | HasGroupChanged = true; |
3090 | ScheduleGroupForTerseUpdate(); | 3865 | ScheduleGroupForTerseUpdate(); |
3091 | } | 3866 | } |
@@ -3097,16 +3872,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3097 | /// <param name="rot"></param> | 3872 | /// <param name="rot"></param> |
3098 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) | 3873 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) |
3099 | { | 3874 | { |
3100 | // m_log.DebugFormat( | ||
3101 | // "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); | ||
3102 | |||
3103 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3104 | // for (int i = 0; i < parts.Length; i++) | ||
3105 | // parts[i].StoreUndoState(); | ||
3106 | |||
3107 | RootPart.StoreUndoState(true); | ||
3108 | RootPart.IgnoreUndoUpdate = true; | ||
3109 | |||
3110 | m_rootPart.UpdateRotation(rot); | 3875 | m_rootPart.UpdateRotation(rot); |
3111 | 3876 | ||
3112 | PhysicsActor actor = m_rootPart.PhysActor; | 3877 | PhysicsActor actor = m_rootPart.PhysActor; |
@@ -3125,8 +3890,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3125 | 3890 | ||
3126 | HasGroupChanged = true; | 3891 | HasGroupChanged = true; |
3127 | ScheduleGroupForTerseUpdate(); | 3892 | ScheduleGroupForTerseUpdate(); |
3128 | |||
3129 | RootPart.IgnoreUndoUpdate = false; | ||
3130 | } | 3893 | } |
3131 | 3894 | ||
3132 | /// <summary> | 3895 | /// <summary> |
@@ -3139,13 +3902,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3139 | SceneObjectPart part = GetPart(localID); | 3902 | SceneObjectPart part = GetPart(localID); |
3140 | 3903 | ||
3141 | SceneObjectPart[] parts = m_parts.GetArray(); | 3904 | SceneObjectPart[] parts = m_parts.GetArray(); |
3142 | for (int i = 0; i < parts.Length; i++) | ||
3143 | parts[i].StoreUndoState(); | ||
3144 | 3905 | ||
3145 | if (part != null) | 3906 | if (part != null) |
3146 | { | 3907 | { |
3147 | // m_log.DebugFormat( | 3908 | if (m_rootPart.PhysActor != null) |
3148 | // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); | 3909 | m_rootPart.PhysActor.Building = true; |
3149 | 3910 | ||
3150 | if (part.UUID == m_rootPart.UUID) | 3911 | if (part.UUID == m_rootPart.UUID) |
3151 | { | 3912 | { |
@@ -3155,6 +3916,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3155 | { | 3916 | { |
3156 | part.UpdateRotation(rot); | 3917 | part.UpdateRotation(rot); |
3157 | } | 3918 | } |
3919 | |||
3920 | if (m_rootPart.PhysActor != null) | ||
3921 | m_rootPart.PhysActor.Building = false; | ||
3158 | } | 3922 | } |
3159 | } | 3923 | } |
3160 | 3924 | ||
@@ -3168,12 +3932,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3168 | SceneObjectPart part = GetPart(localID); | 3932 | SceneObjectPart part = GetPart(localID); |
3169 | if (part != null) | 3933 | if (part != null) |
3170 | { | 3934 | { |
3171 | // m_log.DebugFormat( | 3935 | if (m_rootPart.PhysActor != null) |
3172 | // "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", | 3936 | m_rootPart.PhysActor.Building = true; |
3173 | // part.Name, part.LocalId, rot); | ||
3174 | |||
3175 | part.StoreUndoState(); | ||
3176 | part.IgnoreUndoUpdate = true; | ||
3177 | 3937 | ||
3178 | if (part.UUID == m_rootPart.UUID) | 3938 | if (part.UUID == m_rootPart.UUID) |
3179 | { | 3939 | { |
@@ -3186,7 +3946,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3186 | part.OffsetPosition = pos; | 3946 | part.OffsetPosition = pos; |
3187 | } | 3947 | } |
3188 | 3948 | ||
3189 | part.IgnoreUndoUpdate = false; | 3949 | if (m_rootPart.PhysActor != null) |
3950 | m_rootPart.PhysActor.Building = false; | ||
3190 | } | 3951 | } |
3191 | } | 3952 | } |
3192 | 3953 | ||
@@ -3196,15 +3957,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3196 | /// <param name="rot"></param> | 3957 | /// <param name="rot"></param> |
3197 | public void UpdateRootRotation(Quaternion rot) | 3958 | public void UpdateRootRotation(Quaternion rot) |
3198 | { | 3959 | { |
3199 | // m_log.DebugFormat( | 3960 | // needs to be called with phys building true |
3200 | // "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", | ||
3201 | // Name, LocalId, rot); | ||
3202 | |||
3203 | Quaternion axRot = rot; | 3961 | Quaternion axRot = rot; |
3204 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 3962 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
3205 | 3963 | ||
3206 | m_rootPart.StoreUndoState(); | 3964 | //Don't use UpdateRotation because it schedules an update prematurely |
3207 | m_rootPart.UpdateRotation(rot); | 3965 | m_rootPart.RotationOffset = rot; |
3208 | 3966 | ||
3209 | PhysicsActor pa = m_rootPart.PhysActor; | 3967 | PhysicsActor pa = m_rootPart.PhysActor; |
3210 | 3968 | ||
@@ -3220,35 +3978,145 @@ namespace OpenSim.Region.Framework.Scenes | |||
3220 | SceneObjectPart prim = parts[i]; | 3978 | SceneObjectPart prim = parts[i]; |
3221 | if (prim.UUID != m_rootPart.UUID) | 3979 | if (prim.UUID != m_rootPart.UUID) |
3222 | { | 3980 | { |
3223 | prim.IgnoreUndoUpdate = true; | 3981 | Quaternion NewRot = oldParentRot * prim.RotationOffset; |
3982 | NewRot = Quaternion.Inverse(axRot) * NewRot; | ||
3983 | prim.RotationOffset = NewRot; | ||
3984 | |||
3224 | Vector3 axPos = prim.OffsetPosition; | 3985 | Vector3 axPos = prim.OffsetPosition; |
3986 | |||
3225 | axPos *= oldParentRot; | 3987 | axPos *= oldParentRot; |
3226 | axPos *= Quaternion.Inverse(axRot); | 3988 | axPos *= Quaternion.Inverse(axRot); |
3227 | prim.OffsetPosition = axPos; | 3989 | prim.OffsetPosition = axPos; |
3228 | Quaternion primsRot = prim.RotationOffset; | 3990 | } |
3229 | Quaternion newRot = oldParentRot * primsRot; | 3991 | } |
3230 | newRot = Quaternion.Inverse(axRot) * newRot; | ||
3231 | prim.RotationOffset = newRot; | ||
3232 | prim.ScheduleTerseUpdate(); | ||
3233 | prim.IgnoreUndoUpdate = false; | ||
3234 | } | ||
3235 | } | ||
3236 | |||
3237 | // for (int i = 0; i < parts.Length; i++) | ||
3238 | // { | ||
3239 | // SceneObjectPart childpart = parts[i]; | ||
3240 | // if (childpart != m_rootPart) | ||
3241 | // { | ||
3242 | //// childpart.IgnoreUndoUpdate = false; | ||
3243 | //// childpart.StoreUndoState(); | ||
3244 | // } | ||
3245 | // } | ||
3246 | 3992 | ||
3247 | m_rootPart.ScheduleTerseUpdate(); | 3993 | HasGroupChanged = true; |
3994 | ScheduleGroupForFullUpdate(); | ||
3995 | } | ||
3248 | 3996 | ||
3249 | // m_log.DebugFormat( | 3997 | private enum updatetype :int |
3250 | // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", | 3998 | { |
3251 | // Name, LocalId, rot); | 3999 | none = 0, |
4000 | partterse = 1, | ||
4001 | partfull = 2, | ||
4002 | groupterse = 3, | ||
4003 | groupfull = 4 | ||
4004 | } | ||
4005 | |||
4006 | public void doChangeObject(SceneObjectPart part, ObjectChangeData data) | ||
4007 | { | ||
4008 | // TODO this still as excessive *.Schedule*Update()s | ||
4009 | |||
4010 | if (part != null && part.ParentGroup != null) | ||
4011 | { | ||
4012 | ObjectChangeType change = data.change; | ||
4013 | bool togroup = ((change & ObjectChangeType.Group) != 0); | ||
4014 | // bool uniform = ((what & ObjectChangeType.UniformScale) != 0); not in use | ||
4015 | |||
4016 | SceneObjectGroup group = part.ParentGroup; | ||
4017 | PhysicsActor pha = group.RootPart.PhysActor; | ||
4018 | |||
4019 | updatetype updateType = updatetype.none; | ||
4020 | |||
4021 | if (togroup) | ||
4022 | { | ||
4023 | // related to group | ||
4024 | if ((change & (ObjectChangeType.Rotation | ObjectChangeType.Position)) != 0) | ||
4025 | { | ||
4026 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4027 | { | ||
4028 | group.RootPart.UpdateRotation(data.rotation); | ||
4029 | updateType = updatetype.none; | ||
4030 | } | ||
4031 | if ((change & ObjectChangeType.Position) != 0) | ||
4032 | { | ||
4033 | if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) | ||
4034 | UpdateGroupPosition(data.position); | ||
4035 | updateType = updatetype.groupterse; | ||
4036 | } | ||
4037 | else | ||
4038 | // ugly rotation update of all parts | ||
4039 | { | ||
4040 | group.ResetChildPrimPhysicsPositions(); | ||
4041 | } | ||
4042 | |||
4043 | } | ||
4044 | if ((change & ObjectChangeType.Scale) != 0) | ||
4045 | { | ||
4046 | if (pha != null) | ||
4047 | pha.Building = true; | ||
4048 | |||
4049 | group.GroupResize(data.scale); | ||
4050 | updateType = updatetype.none; | ||
4051 | |||
4052 | if (pha != null) | ||
4053 | pha.Building = false; | ||
4054 | } | ||
4055 | } | ||
4056 | else | ||
4057 | { | ||
4058 | // related to single prim in a link-set ( ie group) | ||
4059 | if (pha != null) | ||
4060 | pha.Building = true; | ||
4061 | |||
4062 | // root part is special | ||
4063 | // parts offset positions or rotations need to change also | ||
4064 | |||
4065 | if (part == group.RootPart) | ||
4066 | { | ||
4067 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4068 | group.UpdateRootRotation(data.rotation); | ||
4069 | if ((change & ObjectChangeType.Position) != 0) | ||
4070 | group.UpdateRootPosition(data.position); | ||
4071 | if ((change & ObjectChangeType.Scale) != 0) | ||
4072 | part.Resize(data.scale); | ||
4073 | } | ||
4074 | else | ||
4075 | { | ||
4076 | if ((change & ObjectChangeType.Position) != 0) | ||
4077 | { | ||
4078 | part.OffsetPosition = data.position; | ||
4079 | updateType = updatetype.partterse; | ||
4080 | } | ||
4081 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4082 | { | ||
4083 | part.UpdateRotation(data.rotation); | ||
4084 | updateType = updatetype.none; | ||
4085 | } | ||
4086 | if ((change & ObjectChangeType.Scale) != 0) | ||
4087 | { | ||
4088 | part.Resize(data.scale); | ||
4089 | updateType = updatetype.none; | ||
4090 | } | ||
4091 | } | ||
4092 | |||
4093 | if (pha != null) | ||
4094 | pha.Building = false; | ||
4095 | } | ||
4096 | |||
4097 | if (updateType != updatetype.none) | ||
4098 | { | ||
4099 | group.HasGroupChanged = true; | ||
4100 | |||
4101 | switch (updateType) | ||
4102 | { | ||
4103 | case updatetype.partterse: | ||
4104 | part.ScheduleTerseUpdate(); | ||
4105 | break; | ||
4106 | case updatetype.partfull: | ||
4107 | part.ScheduleFullUpdate(); | ||
4108 | break; | ||
4109 | case updatetype.groupterse: | ||
4110 | group.ScheduleGroupForTerseUpdate(); | ||
4111 | break; | ||
4112 | case updatetype.groupfull: | ||
4113 | group.ScheduleGroupForFullUpdate(); | ||
4114 | break; | ||
4115 | default: | ||
4116 | break; | ||
4117 | } | ||
4118 | } | ||
4119 | } | ||
3252 | } | 4120 | } |
3253 | 4121 | ||
3254 | #endregion | 4122 | #endregion |
@@ -3289,6 +4157,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3289 | waypoint.handle = handle; | 4157 | waypoint.handle = handle; |
3290 | lock (m_rotTargets) | 4158 | lock (m_rotTargets) |
3291 | { | 4159 | { |
4160 | if (m_rotTargets.Count >= 8) | ||
4161 | m_rotTargets.Remove(m_rotTargets.ElementAt(0).Key); | ||
3292 | m_rotTargets.Add(handle, waypoint); | 4162 | m_rotTargets.Add(handle, waypoint); |
3293 | } | 4163 | } |
3294 | m_scene.AddGroupTarget(this); | 4164 | m_scene.AddGroupTarget(this); |
@@ -3314,6 +4184,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3314 | waypoint.handle = handle; | 4184 | waypoint.handle = handle; |
3315 | lock (m_targets) | 4185 | lock (m_targets) |
3316 | { | 4186 | { |
4187 | if (m_targets.Count >= 8) | ||
4188 | m_targets.Remove(m_targets.ElementAt(0).Key); | ||
3317 | m_targets.Add(handle, waypoint); | 4189 | m_targets.Add(handle, waypoint); |
3318 | } | 4190 | } |
3319 | m_scene.AddGroupTarget(this); | 4191 | m_scene.AddGroupTarget(this); |
@@ -3347,10 +4219,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3347 | scriptPosTarget target = m_targets[idx]; | 4219 | scriptPosTarget target = m_targets[idx]; |
3348 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) | 4220 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) |
3349 | { | 4221 | { |
4222 | at_target = true; | ||
4223 | |||
3350 | // trigger at_target | 4224 | // trigger at_target |
3351 | if (m_scriptListens_atTarget) | 4225 | if (m_scriptListens_atTarget) |
3352 | { | 4226 | { |
3353 | at_target = true; | ||
3354 | scriptPosTarget att = new scriptPosTarget(); | 4227 | scriptPosTarget att = new scriptPosTarget(); |
3355 | att.targetPos = target.targetPos; | 4228 | att.targetPos = target.targetPos; |
3356 | att.tolerance = target.tolerance; | 4229 | att.tolerance = target.tolerance; |
@@ -3468,11 +4341,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
3468 | } | 4341 | } |
3469 | } | 4342 | } |
3470 | } | 4343 | } |
3471 | 4344 | ||
4345 | public Vector3 GetGeometricCenter() | ||
4346 | { | ||
4347 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
4348 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
4349 | // ignoring tortured prims details since sl also seems to ignore | ||
4350 | // so no real use in doing it on physics | ||
4351 | |||
4352 | Vector3 gc = Vector3.Zero; | ||
4353 | |||
4354 | int nparts = m_parts.Count; | ||
4355 | if (nparts <= 1) | ||
4356 | return gc; | ||
4357 | |||
4358 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4359 | nparts = parts.Length; // just in case it changed | ||
4360 | if (nparts <= 1) | ||
4361 | return gc; | ||
4362 | |||
4363 | Quaternion parentRot = RootPart.RotationOffset; | ||
4364 | Vector3 pPos; | ||
4365 | |||
4366 | // average all parts positions | ||
4367 | for (int i = 0; i < nparts; i++) | ||
4368 | { | ||
4369 | // do it directly | ||
4370 | // gc += parts[i].GetWorldPosition(); | ||
4371 | if (parts[i] != RootPart) | ||
4372 | { | ||
4373 | pPos = parts[i].OffsetPosition; | ||
4374 | gc += pPos; | ||
4375 | } | ||
4376 | |||
4377 | } | ||
4378 | gc /= nparts; | ||
4379 | |||
4380 | // relative to root: | ||
4381 | // gc -= AbsolutePosition; | ||
4382 | return gc; | ||
4383 | } | ||
4384 | |||
3472 | public float GetMass() | 4385 | public float GetMass() |
3473 | { | 4386 | { |
3474 | float retmass = 0f; | 4387 | float retmass = 0f; |
3475 | |||
3476 | SceneObjectPart[] parts = m_parts.GetArray(); | 4388 | SceneObjectPart[] parts = m_parts.GetArray(); |
3477 | for (int i = 0; i < parts.Length; i++) | 4389 | for (int i = 0; i < parts.Length; i++) |
3478 | retmass += parts[i].GetMass(); | 4390 | retmass += parts[i].GetMass(); |
@@ -3480,6 +4392,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3480 | return retmass; | 4392 | return retmass; |
3481 | } | 4393 | } |
3482 | 4394 | ||
4395 | // center of mass of full object | ||
4396 | public Vector3 GetCenterOfMass() | ||
4397 | { | ||
4398 | PhysicsActor pa = RootPart.PhysActor; | ||
4399 | |||
4400 | if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null) | ||
4401 | { | ||
4402 | // physics knows better about center of mass of physical prims | ||
4403 | Vector3 tmp = pa.CenterOfMass; | ||
4404 | return tmp; | ||
4405 | } | ||
4406 | |||
4407 | Vector3 Ptot = Vector3.Zero; | ||
4408 | float totmass = 0f; | ||
4409 | float m; | ||
4410 | |||
4411 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4412 | for (int i = 0; i < parts.Length; i++) | ||
4413 | { | ||
4414 | m = parts[i].GetMass(); | ||
4415 | Ptot += parts[i].GetPartCenterOfMass() * m; | ||
4416 | totmass += m; | ||
4417 | } | ||
4418 | |||
4419 | if (totmass == 0) | ||
4420 | totmass = 0; | ||
4421 | else | ||
4422 | totmass = 1 / totmass; | ||
4423 | Ptot *= totmass; | ||
4424 | |||
4425 | return Ptot; | ||
4426 | } | ||
4427 | |||
3483 | /// <summary> | 4428 | /// <summary> |
3484 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that | 4429 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that |
3485 | /// the physics engine can use it. | 4430 | /// the physics engine can use it. |
@@ -3659,6 +4604,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3659 | FromItemID = uuid; | 4604 | FromItemID = uuid; |
3660 | } | 4605 | } |
3661 | 4606 | ||
4607 | public void ResetOwnerChangeFlag() | ||
4608 | { | ||
4609 | ForEachPart(delegate(SceneObjectPart part) | ||
4610 | { | ||
4611 | part.ResetOwnerChangeFlag(); | ||
4612 | }); | ||
4613 | } | ||
4614 | |||
3662 | #endregion | 4615 | #endregion |
3663 | } | 4616 | } |
3664 | } | 4617 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index ff3f738..8c6450d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -64,7 +64,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
64 | TELEPORT = 512, | 64 | TELEPORT = 512, |
65 | REGION_RESTART = 1024, | 65 | REGION_RESTART = 1024, |
66 | MEDIA = 2048, | 66 | MEDIA = 2048, |
67 | ANIMATION = 16384 | 67 | ANIMATION = 16384, |
68 | POSITION = 32768 | ||
68 | } | 69 | } |
69 | 70 | ||
70 | // I don't really know where to put this except here. | 71 | // I don't really know where to put this except here. |
@@ -123,7 +124,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
123 | /// Denote all sides of the prim | 124 | /// Denote all sides of the prim |
124 | /// </value> | 125 | /// </value> |
125 | public const int ALL_SIDES = -1; | 126 | public const int ALL_SIDES = -1; |
126 | 127 | ||
128 | private const scriptEvents PhysicsNeededSubsEvents = ( | ||
129 | scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | | ||
130 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
131 | ); | ||
132 | private const scriptEvents PhyscicsPhantonSubsEvents = ( | ||
133 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
134 | ); | ||
135 | private const scriptEvents PhyscicsVolumeDtcSubsEvents = ( | ||
136 | scriptEvents.collision_start | scriptEvents.collision_end | ||
137 | ); | ||
138 | |||
127 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 139 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
128 | 140 | ||
129 | /// <summary> | 141 | /// <summary> |
@@ -160,7 +172,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
160 | /// </remarks> | 172 | /// </remarks> |
161 | public bool IsRoot | 173 | public bool IsRoot |
162 | { | 174 | { |
163 | get { return ParentGroup.RootPart == this; } | 175 | get { return Object.ReferenceEquals(ParentGroup.RootPart, this); } |
164 | } | 176 | } |
165 | 177 | ||
166 | /// <summary> | 178 | /// <summary> |
@@ -233,6 +245,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
233 | 245 | ||
234 | public uint TimeStampTerse; | 246 | public uint TimeStampTerse; |
235 | 247 | ||
248 | // The following two are to hold the attachment data | ||
249 | // while an object is inworld | ||
250 | [XmlIgnore] | ||
251 | public byte AttachPoint = 0; | ||
252 | |||
253 | [XmlIgnore] | ||
254 | public Vector3 AttachOffset = Vector3.Zero; | ||
255 | |||
256 | [XmlIgnore] | ||
257 | public Quaternion AttachRotation = Quaternion.Identity; | ||
258 | |||
259 | [XmlIgnore] | ||
236 | public int STATUS_ROTATE_X; | 260 | public int STATUS_ROTATE_X; |
237 | 261 | ||
238 | public int STATUS_ROTATE_Y; | 262 | public int STATUS_ROTATE_Y; |
@@ -259,8 +283,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
259 | 283 | ||
260 | public Vector3 RotationAxis = Vector3.One; | 284 | public Vector3 RotationAxis = Vector3.One; |
261 | 285 | ||
262 | public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this | 286 | public bool VolumeDetectActive; |
263 | // Certainly this must be a persistant setting finally | ||
264 | 287 | ||
265 | public bool IsWaitingForFirstSpinUpdatePacket; | 288 | public bool IsWaitingForFirstSpinUpdatePacket; |
266 | 289 | ||
@@ -300,10 +323,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
300 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; | 323 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; |
301 | private Vector3 m_sitTargetPosition; | 324 | private Vector3 m_sitTargetPosition; |
302 | private string m_sitAnimation = "SIT"; | 325 | private string m_sitAnimation = "SIT"; |
326 | private bool m_occupied; // KF if any av is sitting on this prim | ||
303 | private string m_text = String.Empty; | 327 | private string m_text = String.Empty; |
304 | private string m_touchName = String.Empty; | 328 | private string m_touchName = String.Empty; |
305 | private readonly List<UndoState> m_undo = new List<UndoState>(5); | 329 | private UndoRedoState m_UndoRedo = null; |
306 | private readonly List<UndoState> m_redo = new List<UndoState>(5); | ||
307 | 330 | ||
308 | private bool m_passTouches = false; | 331 | private bool m_passTouches = false; |
309 | private bool m_passCollisions = false; | 332 | private bool m_passCollisions = false; |
@@ -331,14 +354,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
331 | protected Vector3 m_lastVelocity; | 354 | protected Vector3 m_lastVelocity; |
332 | protected Vector3 m_lastAcceleration; | 355 | protected Vector3 m_lastAcceleration; |
333 | protected Vector3 m_lastAngularVelocity; | 356 | protected Vector3 m_lastAngularVelocity; |
334 | protected int m_lastTerseSent; | 357 | protected int m_lastUpdateSentTime; |
358 | protected float m_buoyancy = 0.0f; | ||
359 | protected Vector3 m_force; | ||
360 | protected Vector3 m_torque; | ||
335 | 361 | ||
336 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; | 362 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; |
337 | protected float m_density = 1000.0f; // in kg/m^3 | 363 | protected float m_density = 1000.0f; // in kg/m^3 |
338 | protected float m_gravitymod = 1.0f; | 364 | protected float m_gravitymod = 1.0f; |
339 | protected float m_friction = 0.6f; // wood | 365 | protected float m_friction = 0.6f; // wood |
340 | protected float m_bounce = 0.5f; // wood | 366 | protected float m_bounce = 0.5f; // wood |
341 | 367 | ||
368 | |||
369 | protected bool m_isSelected = false; | ||
370 | |||
342 | /// <summary> | 371 | /// <summary> |
343 | /// Stores media texture data | 372 | /// Stores media texture data |
344 | /// </summary> | 373 | /// </summary> |
@@ -350,10 +379,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
350 | private Vector3 m_cameraAtOffset; | 379 | private Vector3 m_cameraAtOffset; |
351 | private bool m_forceMouselook; | 380 | private bool m_forceMouselook; |
352 | 381 | ||
353 | // TODO: Collision sound should have default. | 382 | |
383 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
384 | private sbyte m_collisionSoundType; | ||
354 | private UUID m_collisionSound; | 385 | private UUID m_collisionSound; |
355 | private float m_collisionSoundVolume; | 386 | private float m_collisionSoundVolume; |
356 | 387 | ||
388 | private int LastColSoundSentTime; | ||
389 | |||
390 | |||
391 | private SOPVehicle m_vehicleParams = null; | ||
392 | |||
357 | private KeyframeMotion m_keyframeMotion = null; | 393 | private KeyframeMotion m_keyframeMotion = null; |
358 | 394 | ||
359 | public KeyframeMotion KeyframeMotion | 395 | public KeyframeMotion KeyframeMotion |
@@ -361,6 +397,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
361 | get; set; | 397 | get; set; |
362 | } | 398 | } |
363 | 399 | ||
400 | |||
364 | #endregion Fields | 401 | #endregion Fields |
365 | 402 | ||
366 | // ~SceneObjectPart() | 403 | // ~SceneObjectPart() |
@@ -390,6 +427,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
390 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 427 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
391 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log | 428 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log |
392 | m_inventory = new SceneObjectPartInventory(this); | 429 | m_inventory = new SceneObjectPartInventory(this); |
430 | LastColSoundSentTime = Util.EnvironmentTickCount(); | ||
393 | } | 431 | } |
394 | 432 | ||
395 | /// <summary> | 433 | /// <summary> |
@@ -404,7 +442,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
404 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, | 442 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, |
405 | Quaternion rotationOffset, Vector3 offsetPosition) : this() | 443 | Quaternion rotationOffset, Vector3 offsetPosition) : this() |
406 | { | 444 | { |
407 | m_name = "Primitive"; | 445 | m_name = "Object"; |
408 | 446 | ||
409 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); | 447 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); |
410 | LastOwnerID = CreatorID = OwnerID = ownerID; | 448 | LastOwnerID = CreatorID = OwnerID = ownerID; |
@@ -443,7 +481,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
443 | private uint _ownerMask = (uint)(PermissionMask.All | PermissionMask.Export); | 481 | private uint _ownerMask = (uint)(PermissionMask.All | PermissionMask.Export); |
444 | private uint _groupMask = (uint)PermissionMask.None; | 482 | private uint _groupMask = (uint)PermissionMask.None; |
445 | private uint _everyoneMask = (uint)PermissionMask.None; | 483 | private uint _everyoneMask = (uint)PermissionMask.None; |
446 | private uint _nextOwnerMask = (uint)PermissionMask.All; | 484 | private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); |
447 | private PrimFlags _flags = PrimFlags.None; | 485 | private PrimFlags _flags = PrimFlags.None; |
448 | private DateTime m_expires; | 486 | private DateTime m_expires; |
449 | private DateTime m_rezzed; | 487 | private DateTime m_rezzed; |
@@ -537,12 +575,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
537 | } | 575 | } |
538 | 576 | ||
539 | /// <value> | 577 | /// <value> |
540 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 578 | /// Get the inventory list |
541 | /// </value> | 579 | /// </value> |
542 | public TaskInventoryDictionary TaskInventory | 580 | public TaskInventoryDictionary TaskInventory |
543 | { | 581 | { |
544 | get { return m_inventory.Items; } | 582 | get { |
545 | set { m_inventory.Items = value; } | 583 | return m_inventory.Items; |
584 | } | ||
585 | set { | ||
586 | m_inventory.Items = value; | ||
587 | } | ||
546 | } | 588 | } |
547 | 589 | ||
548 | /// <summary> | 590 | /// <summary> |
@@ -592,20 +634,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
592 | } | 634 | } |
593 | } | 635 | } |
594 | 636 | ||
595 | public byte Material | ||
596 | { | ||
597 | get { return (byte) m_material; } | ||
598 | set | ||
599 | { | ||
600 | m_material = (Material)value; | ||
601 | |||
602 | PhysicsActor pa = PhysActor; | ||
603 | |||
604 | if (pa != null) | ||
605 | pa.SetMaterial((int)value); | ||
606 | } | ||
607 | } | ||
608 | |||
609 | [XmlIgnore] | 637 | [XmlIgnore] |
610 | public bool PassTouches | 638 | public bool PassTouches |
611 | { | 639 | { |
@@ -631,6 +659,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
631 | } | 659 | } |
632 | } | 660 | } |
633 | 661 | ||
662 | public bool IsSelected | ||
663 | { | ||
664 | get { return m_isSelected; } | ||
665 | set | ||
666 | { | ||
667 | m_isSelected = value; | ||
668 | if (ParentGroup != null) | ||
669 | ParentGroup.PartSelectChanged(value); | ||
670 | } | ||
671 | } | ||
672 | |||
673 | |||
634 | public Dictionary<int, string> CollisionFilter | 674 | public Dictionary<int, string> CollisionFilter |
635 | { | 675 | { |
636 | get { return m_CollisionFilter; } | 676 | get { return m_CollisionFilter; } |
@@ -699,14 +739,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
699 | set { m_LoopSoundSlavePrims = value; } | 739 | set { m_LoopSoundSlavePrims = value; } |
700 | } | 740 | } |
701 | 741 | ||
702 | |||
703 | public Byte[] TextureAnimation | 742 | public Byte[] TextureAnimation |
704 | { | 743 | { |
705 | get { return m_TextureAnimation; } | 744 | get { return m_TextureAnimation; } |
706 | set { m_TextureAnimation = value; } | 745 | set { m_TextureAnimation = value; } |
707 | } | 746 | } |
708 | 747 | ||
709 | |||
710 | public Byte[] ParticleSystem | 748 | public Byte[] ParticleSystem |
711 | { | 749 | { |
712 | get { return m_particleSystem; } | 750 | get { return m_particleSystem; } |
@@ -743,9 +781,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
743 | { | 781 | { |
744 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 782 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
745 | PhysicsActor actor = PhysActor; | 783 | PhysicsActor actor = PhysActor; |
746 | // If physical and the root prim of a linkset, the position of the group is what physics thinks. | 784 | if (ParentID == 0) |
747 | if (actor != null && ParentID == 0) | 785 | { |
748 | m_groupPosition = actor.Position; | 786 | if (actor != null) |
787 | m_groupPosition = actor.Position; | ||
788 | return m_groupPosition; | ||
789 | } | ||
749 | 790 | ||
750 | // If I'm an attachment, my position is reported as the position of who I'm attached to | 791 | // If I'm an attachment, my position is reported as the position of who I'm attached to |
751 | if (ParentGroup.IsAttachment) | 792 | if (ParentGroup.IsAttachment) |
@@ -755,14 +796,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
755 | return sp.AbsolutePosition; | 796 | return sp.AbsolutePosition; |
756 | } | 797 | } |
757 | 798 | ||
799 | // use root prim's group position. Physics may have updated it | ||
800 | if (ParentGroup.RootPart != this) | ||
801 | m_groupPosition = ParentGroup.RootPart.GroupPosition; | ||
758 | return m_groupPosition; | 802 | return m_groupPosition; |
759 | } | 803 | } |
760 | set | 804 | set |
761 | { | 805 | { |
762 | m_groupPosition = value; | 806 | m_groupPosition = value; |
763 | |||
764 | PhysicsActor actor = PhysActor; | 807 | PhysicsActor actor = PhysActor; |
765 | if (actor != null) | 808 | if (actor != null && ParentGroup.Scene.PhysicsScene != null) |
766 | { | 809 | { |
767 | try | 810 | try |
768 | { | 811 | { |
@@ -786,16 +829,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
786 | m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e); | 829 | m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e); |
787 | } | 830 | } |
788 | } | 831 | } |
789 | |||
790 | // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too | ||
791 | if (SitTargetAvatar != UUID.Zero) | ||
792 | { | ||
793 | ScenePresence avatar; | ||
794 | if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar)) | ||
795 | { | ||
796 | avatar.ParentPosition = GetWorldPosition(); | ||
797 | } | ||
798 | } | ||
799 | } | 832 | } |
800 | } | 833 | } |
801 | 834 | ||
@@ -804,7 +837,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
804 | get { return m_offsetPosition; } | 837 | get { return m_offsetPosition; } |
805 | set | 838 | set |
806 | { | 839 | { |
807 | // StoreUndoState(); | 840 | Vector3 oldpos = m_offsetPosition; |
808 | m_offsetPosition = value; | 841 | m_offsetPosition = value; |
809 | 842 | ||
810 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 843 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
@@ -816,10 +849,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
816 | actor.Orientation = GetWorldRotation(); | 849 | actor.Orientation = GetWorldRotation(); |
817 | 850 | ||
818 | // Tell the physics engines that this prim changed. | 851 | // Tell the physics engines that this prim changed. |
819 | if (ParentGroup.Scene != null) | 852 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene != null) |
820 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 853 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
821 | } | 854 | } |
855 | |||
856 | if (!m_parentGroup.m_dupeInProgress) | ||
857 | { | ||
858 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); | ||
859 | foreach (ScenePresence av in avs) | ||
860 | { | ||
861 | if (av.ParentID == m_localId) | ||
862 | { | ||
863 | Vector3 offset = (m_offsetPosition - oldpos); | ||
864 | av.AbsolutePosition += offset; | ||
865 | av.SendAvatarDataToAllAgents(); | ||
866 | } | ||
867 | } | ||
868 | } | ||
822 | } | 869 | } |
870 | TriggerScriptChangedEvent(Changed.POSITION); | ||
823 | } | 871 | } |
824 | } | 872 | } |
825 | 873 | ||
@@ -870,7 +918,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
870 | 918 | ||
871 | set | 919 | set |
872 | { | 920 | { |
873 | StoreUndoState(); | 921 | // StoreUndoState(); |
874 | m_rotationOffset = value; | 922 | m_rotationOffset = value; |
875 | 923 | ||
876 | PhysicsActor actor = PhysActor; | 924 | PhysicsActor actor = PhysActor; |
@@ -958,19 +1006,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
958 | get | 1006 | get |
959 | { | 1007 | { |
960 | PhysicsActor actor = PhysActor; | 1008 | PhysicsActor actor = PhysActor; |
961 | if ((actor != null) && actor.IsPhysical) | 1009 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this) |
962 | { | 1010 | { |
963 | m_angularVelocity = actor.RotationalVelocity; | 1011 | m_angularVelocity = actor.RotationalVelocity; |
964 | } | 1012 | } |
965 | return m_angularVelocity; | 1013 | return m_angularVelocity; |
966 | } | 1014 | } |
967 | set { m_angularVelocity = value; } | 1015 | set |
1016 | { | ||
1017 | m_angularVelocity = value; | ||
1018 | PhysicsActor actor = PhysActor; | ||
1019 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this && VehicleType == (int)Vehicle.TYPE_NONE) | ||
1020 | { | ||
1021 | actor.RotationalVelocity = m_angularVelocity; | ||
1022 | } | ||
1023 | } | ||
968 | } | 1024 | } |
969 | 1025 | ||
970 | /// <summary></summary> | 1026 | /// <summary></summary> |
971 | public Vector3 Acceleration | 1027 | public Vector3 Acceleration |
972 | { | 1028 | { |
973 | get { return m_acceleration; } | 1029 | get |
1030 | { | ||
1031 | PhysicsActor actor = PhysActor; | ||
1032 | if (actor != null) | ||
1033 | { | ||
1034 | m_acceleration = actor.Acceleration; | ||
1035 | } | ||
1036 | return m_acceleration; | ||
1037 | } | ||
1038 | |||
974 | set { m_acceleration = value; } | 1039 | set { m_acceleration = value; } |
975 | } | 1040 | } |
976 | 1041 | ||
@@ -1038,7 +1103,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1038 | public PrimitiveBaseShape Shape | 1103 | public PrimitiveBaseShape Shape |
1039 | { | 1104 | { |
1040 | get { return m_shape; } | 1105 | get { return m_shape; } |
1041 | set { m_shape = value;} | 1106 | set |
1107 | { | ||
1108 | m_shape = value; | ||
1109 | } | ||
1042 | } | 1110 | } |
1043 | 1111 | ||
1044 | /// <summary> | 1112 | /// <summary> |
@@ -1051,7 +1119,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1051 | { | 1119 | { |
1052 | if (m_shape != null) | 1120 | if (m_shape != null) |
1053 | { | 1121 | { |
1054 | StoreUndoState(); | ||
1055 | 1122 | ||
1056 | m_shape.Scale = value; | 1123 | m_shape.Scale = value; |
1057 | 1124 | ||
@@ -1119,10 +1186,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1119 | { | 1186 | { |
1120 | get | 1187 | get |
1121 | { | 1188 | { |
1122 | if (ParentGroup.IsAttachment) | 1189 | return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); |
1123 | return GroupPosition; | ||
1124 | |||
1125 | return m_offsetPosition + m_groupPosition; | ||
1126 | } | 1190 | } |
1127 | } | 1191 | } |
1128 | 1192 | ||
@@ -1291,6 +1355,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1291 | _flags = value; | 1355 | _flags = value; |
1292 | } | 1356 | } |
1293 | } | 1357 | } |
1358 | |||
1359 | [XmlIgnore] | ||
1360 | public bool IsOccupied // KF If an av is sittingon this prim | ||
1361 | { | ||
1362 | get { return m_occupied; } | ||
1363 | set { m_occupied = value; } | ||
1364 | } | ||
1294 | 1365 | ||
1295 | /// <summary> | 1366 | /// <summary> |
1296 | /// ID of the avatar that is sat on us if we have a sit target. If there is no such avatar then is UUID.Zero | 1367 | /// ID of the avatar that is sat on us if we have a sit target. If there is no such avatar then is UUID.Zero |
@@ -1341,12 +1412,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1341 | set { m_sitAnimation = value; } | 1412 | set { m_sitAnimation = value; } |
1342 | } | 1413 | } |
1343 | 1414 | ||
1415 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); | ||
1416 | |||
1417 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
1418 | // runtime thing.. do not persist | ||
1419 | [XmlIgnore] | ||
1420 | public sbyte CollisionSoundType | ||
1421 | { | ||
1422 | get | ||
1423 | { | ||
1424 | return m_collisionSoundType; | ||
1425 | } | ||
1426 | set | ||
1427 | { | ||
1428 | m_collisionSoundType = value; | ||
1429 | if (value == -1) | ||
1430 | m_collisionSound = invalidCollisionSoundUUID; | ||
1431 | else if (value == 0) | ||
1432 | m_collisionSound = UUID.Zero; | ||
1433 | } | ||
1434 | } | ||
1435 | |||
1344 | public UUID CollisionSound | 1436 | public UUID CollisionSound |
1345 | { | 1437 | { |
1346 | get { return m_collisionSound; } | 1438 | get { return m_collisionSound; } |
1347 | set | 1439 | set |
1348 | { | 1440 | { |
1349 | m_collisionSound = value; | 1441 | m_collisionSound = value; |
1442 | |||
1443 | if (value == invalidCollisionSoundUUID) | ||
1444 | m_collisionSoundType = -1; | ||
1445 | else if (value == UUID.Zero) | ||
1446 | m_collisionSoundType = 0; | ||
1447 | else | ||
1448 | m_collisionSoundType = 1; | ||
1449 | |||
1350 | aggregateScriptEvents(); | 1450 | aggregateScriptEvents(); |
1351 | } | 1451 | } |
1352 | } | 1452 | } |
@@ -1357,6 +1457,125 @@ namespace OpenSim.Region.Framework.Scenes | |||
1357 | set { m_collisionSoundVolume = value; } | 1457 | set { m_collisionSoundVolume = value; } |
1358 | } | 1458 | } |
1359 | 1459 | ||
1460 | public float Buoyancy | ||
1461 | { | ||
1462 | get | ||
1463 | { | ||
1464 | if (ParentGroup.RootPart == this) | ||
1465 | return m_buoyancy; | ||
1466 | |||
1467 | return ParentGroup.RootPart.Buoyancy; | ||
1468 | } | ||
1469 | set | ||
1470 | { | ||
1471 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1472 | { | ||
1473 | ParentGroup.RootPart.Buoyancy = value; | ||
1474 | return; | ||
1475 | } | ||
1476 | m_buoyancy = value; | ||
1477 | if (PhysActor != null) | ||
1478 | PhysActor.Buoyancy = value; | ||
1479 | } | ||
1480 | } | ||
1481 | |||
1482 | public Vector3 Force | ||
1483 | { | ||
1484 | get | ||
1485 | { | ||
1486 | if (ParentGroup.RootPart == this) | ||
1487 | return m_force; | ||
1488 | |||
1489 | return ParentGroup.RootPart.Force; | ||
1490 | } | ||
1491 | |||
1492 | set | ||
1493 | { | ||
1494 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1495 | { | ||
1496 | ParentGroup.RootPart.Force = value; | ||
1497 | return; | ||
1498 | } | ||
1499 | m_force = value; | ||
1500 | if (PhysActor != null) | ||
1501 | PhysActor.Force = value; | ||
1502 | } | ||
1503 | } | ||
1504 | |||
1505 | public Vector3 Torque | ||
1506 | { | ||
1507 | get | ||
1508 | { | ||
1509 | if (ParentGroup.RootPart == this) | ||
1510 | return m_torque; | ||
1511 | |||
1512 | return ParentGroup.RootPart.Torque; | ||
1513 | } | ||
1514 | |||
1515 | set | ||
1516 | { | ||
1517 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1518 | { | ||
1519 | ParentGroup.RootPart.Torque = value; | ||
1520 | return; | ||
1521 | } | ||
1522 | m_torque = value; | ||
1523 | if (PhysActor != null) | ||
1524 | PhysActor.Torque = value; | ||
1525 | } | ||
1526 | } | ||
1527 | |||
1528 | public byte Material | ||
1529 | { | ||
1530 | get { return (byte)m_material; } | ||
1531 | set | ||
1532 | { | ||
1533 | if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial) | ||
1534 | { | ||
1535 | bool update = false; | ||
1536 | |||
1537 | if (m_material != (Material)value) | ||
1538 | { | ||
1539 | update = true; | ||
1540 | m_material = (Material)value; | ||
1541 | } | ||
1542 | |||
1543 | if (m_friction != SOPMaterialData.friction(m_material)) | ||
1544 | { | ||
1545 | update = true; | ||
1546 | m_friction = SOPMaterialData.friction(m_material); | ||
1547 | } | ||
1548 | |||
1549 | if (m_bounce != SOPMaterialData.bounce(m_material)) | ||
1550 | { | ||
1551 | update = true; | ||
1552 | m_bounce = SOPMaterialData.bounce(m_material); | ||
1553 | } | ||
1554 | |||
1555 | if (update) | ||
1556 | { | ||
1557 | if (PhysActor != null) | ||
1558 | { | ||
1559 | PhysActor.SetMaterial((int)value); | ||
1560 | } | ||
1561 | if(ParentGroup != null) | ||
1562 | ParentGroup.HasGroupChanged = true; | ||
1563 | ScheduleFullUpdateIfNone(); | ||
1564 | UpdatePhysRequired = true; | ||
1565 | } | ||
1566 | } | ||
1567 | } | ||
1568 | } | ||
1569 | |||
1570 | // not a propriety to move to methods place later | ||
1571 | private bool HasMesh() | ||
1572 | { | ||
1573 | if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) | ||
1574 | return true; | ||
1575 | return false; | ||
1576 | } | ||
1577 | |||
1578 | // not a propriety to move to methods place later | ||
1360 | public byte DefaultPhysicsShapeType() | 1579 | public byte DefaultPhysicsShapeType() |
1361 | { | 1580 | { |
1362 | byte type; | 1581 | byte type; |
@@ -1369,6 +1588,65 @@ namespace OpenSim.Region.Framework.Scenes | |||
1369 | return type; | 1588 | return type; |
1370 | } | 1589 | } |
1371 | 1590 | ||
1591 | [XmlIgnore] | ||
1592 | public bool UsesComplexCost | ||
1593 | { | ||
1594 | get | ||
1595 | { | ||
1596 | byte pst = PhysicsShapeType; | ||
1597 | if(pst == (byte) PhysShapeType.none || pst == (byte) PhysShapeType.convex || HasMesh()) | ||
1598 | return true; | ||
1599 | return false; | ||
1600 | } | ||
1601 | } | ||
1602 | |||
1603 | [XmlIgnore] | ||
1604 | public float PhysicsCost | ||
1605 | { | ||
1606 | get | ||
1607 | { | ||
1608 | if(PhysicsShapeType == (byte)PhysShapeType.none) | ||
1609 | return 0; | ||
1610 | |||
1611 | float cost = 0.1f; | ||
1612 | if (PhysActor != null) | ||
1613 | cost = PhysActor.PhysicsCost; | ||
1614 | else | ||
1615 | cost = 0.1f; | ||
1616 | |||
1617 | if ((Flags & PrimFlags.Physics) != 0) | ||
1618 | cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 | ||
1619 | return cost; | ||
1620 | } | ||
1621 | } | ||
1622 | |||
1623 | [XmlIgnore] | ||
1624 | public float StreamingCost | ||
1625 | { | ||
1626 | get | ||
1627 | { | ||
1628 | float cost; | ||
1629 | if (PhysActor != null) | ||
1630 | cost = PhysActor.StreamCost; | ||
1631 | else | ||
1632 | cost = 1.0f; | ||
1633 | return 1.0f; | ||
1634 | } | ||
1635 | } | ||
1636 | |||
1637 | [XmlIgnore] | ||
1638 | public float SimulationCost | ||
1639 | { | ||
1640 | get | ||
1641 | { | ||
1642 | // ignoring scripts. Don't like considering them for this | ||
1643 | if((Flags & PrimFlags.Physics) != 0) | ||
1644 | return 1.0f; | ||
1645 | |||
1646 | return 0.5f; | ||
1647 | } | ||
1648 | } | ||
1649 | |||
1372 | public byte PhysicsShapeType | 1650 | public byte PhysicsShapeType |
1373 | { | 1651 | { |
1374 | get { return m_physicsShapeType; } | 1652 | get { return m_physicsShapeType; } |
@@ -1402,11 +1680,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1402 | } | 1680 | } |
1403 | else if (PhysActor == null) | 1681 | else if (PhysActor == null) |
1404 | { | 1682 | { |
1405 | ApplyPhysics((uint)Flags, VolumeDetectActive); | 1683 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); |
1684 | UpdatePhysicsSubscribedEvents(); | ||
1406 | } | 1685 | } |
1407 | else | 1686 | else |
1408 | { | 1687 | { |
1409 | PhysActor.PhysicsShapeType = m_physicsShapeType; | 1688 | PhysActor.PhysicsShapeType = m_physicsShapeType; |
1689 | // if (Shape.SculptEntry) | ||
1690 | // CheckSculptAndLoad(); | ||
1410 | } | 1691 | } |
1411 | 1692 | ||
1412 | if (ParentGroup != null) | 1693 | if (ParentGroup != null) |
@@ -1508,6 +1789,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1508 | } | 1789 | } |
1509 | } | 1790 | } |
1510 | 1791 | ||
1792 | |||
1511 | #endregion Public Properties with only Get | 1793 | #endregion Public Properties with only Get |
1512 | 1794 | ||
1513 | private uint ApplyMask(uint val, bool set, uint mask) | 1795 | private uint ApplyMask(uint val, bool set, uint mask) |
@@ -1653,6 +1935,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1653 | } | 1935 | } |
1654 | } | 1936 | } |
1655 | 1937 | ||
1938 | // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future | ||
1939 | public void SetVelocity(Vector3 pVel, bool localGlobalTF) | ||
1940 | { | ||
1941 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
1942 | return; | ||
1943 | |||
1944 | if (ParentGroup.IsAttachment) | ||
1945 | return; // don't work on attachments (for now ??) | ||
1946 | |||
1947 | SceneObjectPart root = ParentGroup.RootPart; | ||
1948 | |||
1949 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
1950 | return; | ||
1951 | |||
1952 | PhysicsActor pa = root.PhysActor; | ||
1953 | |||
1954 | if (pa == null || !pa.IsPhysical) | ||
1955 | return; | ||
1956 | |||
1957 | if (localGlobalTF) | ||
1958 | { | ||
1959 | pVel = pVel * GetWorldRotation(); | ||
1960 | } | ||
1961 | |||
1962 | ParentGroup.Velocity = pVel; | ||
1963 | } | ||
1964 | |||
1965 | // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future | ||
1966 | public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF) | ||
1967 | { | ||
1968 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
1969 | return; | ||
1970 | |||
1971 | if (ParentGroup.IsAttachment) | ||
1972 | return; // don't work on attachments (for now ??) | ||
1973 | |||
1974 | SceneObjectPart root = ParentGroup.RootPart; | ||
1975 | |||
1976 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
1977 | return; | ||
1978 | |||
1979 | PhysicsActor pa = root.PhysActor; | ||
1980 | |||
1981 | if (pa == null || !pa.IsPhysical) | ||
1982 | return; | ||
1983 | |||
1984 | if (localGlobalTF) | ||
1985 | { | ||
1986 | pAngVel = pAngVel * GetWorldRotation(); | ||
1987 | } | ||
1988 | |||
1989 | root.AngularVelocity = pAngVel; | ||
1990 | } | ||
1991 | |||
1992 | |||
1656 | /// <summary> | 1993 | /// <summary> |
1657 | /// hook to the physics scene to apply angular impulse | 1994 | /// hook to the physics scene to apply angular impulse |
1658 | /// This is sent up to the group, which then finds the root prim | 1995 | /// This is sent up to the group, which then finds the root prim |
@@ -1673,7 +2010,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1673 | impulse = newimpulse; | 2010 | impulse = newimpulse; |
1674 | } | 2011 | } |
1675 | 2012 | ||
1676 | ParentGroup.applyAngularImpulse(impulse); | 2013 | ParentGroup.ApplyAngularImpulse(impulse); |
1677 | } | 2014 | } |
1678 | 2015 | ||
1679 | /// <summary> | 2016 | /// <summary> |
@@ -1683,20 +2020,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1683 | /// </summary> | 2020 | /// </summary> |
1684 | /// <param name="impulsei">Vector force</param> | 2021 | /// <param name="impulsei">Vector force</param> |
1685 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | 2022 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> |
1686 | public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) | 2023 | |
2024 | // this is actualy Set Torque.. keeping naming so not to edit lslapi also | ||
2025 | public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF) | ||
1687 | { | 2026 | { |
1688 | Vector3 impulse = impulsei; | 2027 | Vector3 torque = torquei; |
1689 | 2028 | ||
1690 | if (localGlobalTF) | 2029 | if (localGlobalTF) |
1691 | { | 2030 | { |
2031 | /* | ||
1692 | Quaternion grot = GetWorldRotation(); | 2032 | Quaternion grot = GetWorldRotation(); |
1693 | Quaternion AXgrot = grot; | 2033 | Quaternion AXgrot = grot; |
1694 | Vector3 AXimpulsei = impulsei; | 2034 | Vector3 AXimpulsei = impulsei; |
1695 | Vector3 newimpulse = AXimpulsei * AXgrot; | 2035 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1696 | impulse = newimpulse; | 2036 | */ |
2037 | torque *= GetWorldRotation(); | ||
1697 | } | 2038 | } |
1698 | 2039 | ||
1699 | ParentGroup.setAngularImpulse(impulse); | 2040 | Torque = torque; |
1700 | } | 2041 | } |
1701 | 2042 | ||
1702 | /// <summary> | 2043 | /// <summary> |
@@ -1704,7 +2045,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1704 | /// </summary> | 2045 | /// </summary> |
1705 | /// <param name="rootObjectFlags"></param> | 2046 | /// <param name="rootObjectFlags"></param> |
1706 | /// <param name="VolumeDetectActive"></param> | 2047 | /// <param name="VolumeDetectActive"></param> |
1707 | public void ApplyPhysics(uint rootObjectFlags, bool _VolumeDetectActive) | 2048 | /// <param name="building"></param> |
2049 | |||
2050 | public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building) | ||
1708 | { | 2051 | { |
1709 | VolumeDetectActive = _VolumeDetectActive; | 2052 | VolumeDetectActive = _VolumeDetectActive; |
1710 | 2053 | ||
@@ -1714,8 +2057,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1714 | if (PhysicsShapeType == (byte)PhysShapeType.none) | 2057 | if (PhysicsShapeType == (byte)PhysShapeType.none) |
1715 | return; | 2058 | return; |
1716 | 2059 | ||
1717 | bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; | 2060 | bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0; |
1718 | bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; | 2061 | bool isPhantom = (_ObjectFlags & (uint)PrimFlags.Phantom) != 0; |
1719 | 2062 | ||
1720 | if (_VolumeDetectActive) | 2063 | if (_VolumeDetectActive) |
1721 | isPhantom = true; | 2064 | isPhantom = true; |
@@ -1729,7 +2072,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1729 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment | 2072 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment |
1730 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) | 2073 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) |
1731 | { | 2074 | { |
1732 | AddToPhysics(isPhysical, isPhantom, isPhysical); | 2075 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); |
2076 | UpdatePhysicsSubscribedEvents(); // not sure if appliable here | ||
1733 | } | 2077 | } |
1734 | else | 2078 | else |
1735 | PhysActor = null; // just to be sure | 2079 | PhysActor = null; // just to be sure |
@@ -1784,6 +2128,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1784 | dupe.Category = Category; | 2128 | dupe.Category = Category; |
1785 | dupe.m_rezzed = m_rezzed; | 2129 | dupe.m_rezzed = m_rezzed; |
1786 | 2130 | ||
2131 | dupe.m_UndoRedo = null; | ||
2132 | dupe.m_isSelected = false; | ||
2133 | |||
2134 | dupe.IgnoreUndoUpdate = false; | ||
2135 | dupe.Undoing = false; | ||
2136 | |||
1787 | dupe.m_inventory = new SceneObjectPartInventory(dupe); | 2137 | dupe.m_inventory = new SceneObjectPartInventory(dupe); |
1788 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); | 2138 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); |
1789 | 2139 | ||
@@ -1799,6 +2149,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1799 | 2149 | ||
1800 | // Move afterwards ResetIDs as it clears the localID | 2150 | // Move afterwards ResetIDs as it clears the localID |
1801 | dupe.LocalId = localID; | 2151 | dupe.LocalId = localID; |
2152 | |||
1802 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. | 2153 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. |
1803 | dupe.LastOwnerID = OwnerID; | 2154 | dupe.LastOwnerID = OwnerID; |
1804 | 2155 | ||
@@ -1823,8 +2174,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1823 | */ | 2174 | */ |
1824 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); | 2175 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); |
1825 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); | 2176 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); |
2177 | // dupe.UpdatePhysicsSubscribedEvents(); // not sure... | ||
1826 | } | 2178 | } |
1827 | 2179 | ||
2180 | if (dupe.PhysActor != null) | ||
2181 | dupe.PhysActor.LocalID = localID; | ||
2182 | |||
1828 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); | 2183 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); |
1829 | 2184 | ||
1830 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); | 2185 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); |
@@ -1843,10 +2198,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1843 | { | 2198 | { |
1844 | if (asset != null) | 2199 | if (asset != null) |
1845 | SculptTextureCallback(asset); | 2200 | SculptTextureCallback(asset); |
1846 | else | 2201 | // else |
1847 | m_log.WarnFormat( | 2202 | // m_log.WarnFormat( |
1848 | "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", | 2203 | // "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", |
1849 | Name, UUID, id); | 2204 | // Name, UUID, id); |
1850 | } | 2205 | } |
1851 | */ | 2206 | */ |
1852 | /// <summary> | 2207 | /// <summary> |
@@ -1945,6 +2300,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1945 | 2300 | ||
1946 | /// <summary> | 2301 | /// <summary> |
1947 | /// Do a physics propery update for this part. | 2302 | /// Do a physics propery update for this part. |
2303 | /// now also updates phantom and volume detector | ||
1948 | /// </summary> | 2304 | /// </summary> |
1949 | /// <param name="UsePhysics"></param> | 2305 | /// <param name="UsePhysics"></param> |
1950 | /// <param name="isNew"></param> | 2306 | /// <param name="isNew"></param> |
@@ -1970,64 +2326,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
1970 | { | 2326 | { |
1971 | if (pa.IsPhysical) // implies UsePhysics==false for this block | 2327 | if (pa.IsPhysical) // implies UsePhysics==false for this block |
1972 | { | 2328 | { |
1973 | if (!isNew) | 2329 | if (!isNew) // implies UsePhysics==false for this block |
2330 | { | ||
1974 | ParentGroup.Scene.RemovePhysicalPrim(1); | 2331 | ParentGroup.Scene.RemovePhysicalPrim(1); |
1975 | 2332 | ||
1976 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | 2333 | Velocity = new Vector3(0, 0, 0); |
1977 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | 2334 | Acceleration = new Vector3(0, 0, 0); |
1978 | pa.delink(); | 2335 | if (ParentGroup.RootPart == this) |
2336 | AngularVelocity = new Vector3(0, 0, 0); | ||
1979 | 2337 | ||
1980 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) | 2338 | if (pa.Phantom && !VolumeDetectActive) |
1981 | { | 2339 | { |
1982 | // destroy all joints connected to this now deactivated body | 2340 | RemoveFromPhysics(); |
1983 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | 2341 | return; |
1984 | } | 2342 | } |
1985 | 2343 | ||
1986 | // stop client-side interpolation of all joint proxy objects that have just been deleted | 2344 | pa.IsPhysical = UsePhysics; |
1987 | // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback, | 2345 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; |
1988 | // which stops client-side interpolation of deactivated joint proxy objects. | 2346 | pa.OnOutOfBounds -= PhysicsOutOfBounds; |
2347 | pa.delink(); | ||
2348 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | ||
2349 | { | ||
2350 | // destroy all joints connected to this now deactivated body | ||
2351 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | ||
2352 | } | ||
2353 | } | ||
1989 | } | 2354 | } |
1990 | 2355 | ||
1991 | if (!UsePhysics && !isNew) | 2356 | if (pa.IsPhysical != UsePhysics) |
1992 | { | 2357 | pa.IsPhysical = UsePhysics; |
1993 | // reset velocity to 0 on physics switch-off. Without that, the client thinks the | ||
1994 | // prim still has velocity and continues to interpolate its position along the old | ||
1995 | // velocity-vector. | ||
1996 | Velocity = new Vector3(0, 0, 0); | ||
1997 | Acceleration = new Vector3(0, 0, 0); | ||
1998 | AngularVelocity = new Vector3(0, 0, 0); | ||
1999 | //RotationalVelocity = new Vector3(0, 0, 0); | ||
2000 | } | ||
2001 | 2358 | ||
2002 | pa.IsPhysical = UsePhysics; | 2359 | if (UsePhysics) |
2360 | { | ||
2361 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
2362 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2363 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2364 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
2003 | 2365 | ||
2004 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. | 2366 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
2005 | //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 2367 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; |
2006 | /// that's not wholesome. Had to make Scene public | ||
2007 | //PhysActor = null; | ||
2008 | 2368 | ||
2009 | if ((Flags & PrimFlags.Phantom) == 0) | 2369 | if (ParentID != 0 && ParentID != LocalId) |
2010 | { | ||
2011 | if (UsePhysics) | ||
2012 | { | 2370 | { |
2013 | if (ParentGroup.RootPart.KeyframeMotion != null) | 2371 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; |
2014 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2015 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2016 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
2017 | |||
2018 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | ||
2019 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
2020 | if (ParentID != 0 && ParentID != LocalId) | ||
2021 | { | ||
2022 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | ||
2023 | 2372 | ||
2024 | if (parentPa != null) | 2373 | if (parentPa != null) |
2025 | { | 2374 | { |
2026 | pa.link(parentPa); | 2375 | pa.link(parentPa); |
2027 | } | ||
2028 | } | 2376 | } |
2029 | } | 2377 | } |
2030 | } | 2378 | } |
2379 | } | ||
2380 | |||
2381 | bool phan = ((Flags & PrimFlags.Phantom) != 0); | ||
2382 | if (pa.Phantom != phan) | ||
2383 | pa.Phantom = phan; | ||
2384 | |||
2385 | // some engines dont' have this check still | ||
2386 | // if (VolumeDetectActive != pa.IsVolumeDtc) | ||
2387 | { | ||
2388 | if (VolumeDetectActive) | ||
2389 | pa.SetVolumeDetect(1); | ||
2390 | else | ||
2391 | pa.SetVolumeDetect(0); | ||
2031 | } | 2392 | } |
2032 | 2393 | ||
2033 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the | 2394 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the |
@@ -2146,42 +2507,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
2146 | 2507 | ||
2147 | public Vector3 GetGeometricCenter() | 2508 | public Vector3 GetGeometricCenter() |
2148 | { | 2509 | { |
2510 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
2511 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
2512 | // ignoring tortured prims details since sl also seems to ignore | ||
2513 | // so no real use in doing it on physics | ||
2514 | if (ParentGroup.IsDeleted) | ||
2515 | return new Vector3(0, 0, 0); | ||
2516 | |||
2517 | return ParentGroup.GetGeometricCenter(); | ||
2518 | } | ||
2519 | |||
2520 | public float GetMass() | ||
2521 | { | ||
2149 | PhysicsActor pa = PhysActor; | 2522 | PhysicsActor pa = PhysActor; |
2150 | 2523 | ||
2151 | if (pa != null) | 2524 | if (pa != null) |
2152 | return pa.GeometricCenter; | 2525 | return pa.Mass; |
2153 | else | 2526 | else |
2154 | return Vector3.Zero; | 2527 | return 0; |
2155 | } | 2528 | } |
2156 | 2529 | ||
2157 | public Vector3 GetCenterOfMass() | 2530 | public Vector3 GetCenterOfMass() |
2158 | { | 2531 | { |
2532 | if (ParentGroup.RootPart == this) | ||
2533 | { | ||
2534 | if (ParentGroup.IsDeleted) | ||
2535 | return AbsolutePosition; | ||
2536 | return ParentGroup.GetCenterOfMass(); | ||
2537 | } | ||
2538 | |||
2159 | PhysicsActor pa = PhysActor; | 2539 | PhysicsActor pa = PhysActor; |
2160 | 2540 | ||
2161 | if (pa != null) | 2541 | if (pa != null) |
2162 | return pa.CenterOfMass; | 2542 | { |
2543 | Vector3 tmp = pa.CenterOfMass; | ||
2544 | return tmp; | ||
2545 | } | ||
2163 | else | 2546 | else |
2164 | return Vector3.Zero; | 2547 | return AbsolutePosition; |
2165 | } | 2548 | } |
2166 | 2549 | ||
2167 | public float GetMass() | 2550 | public Vector3 GetPartCenterOfMass() |
2168 | { | 2551 | { |
2169 | PhysicsActor pa = PhysActor; | 2552 | PhysicsActor pa = PhysActor; |
2170 | 2553 | ||
2171 | if (pa != null) | 2554 | if (pa != null) |
2172 | return pa.Mass; | 2555 | { |
2556 | Vector3 tmp = pa.CenterOfMass; | ||
2557 | return tmp; | ||
2558 | } | ||
2173 | else | 2559 | else |
2174 | return 0; | 2560 | return AbsolutePosition; |
2175 | } | 2561 | } |
2176 | 2562 | ||
2563 | |||
2177 | public Vector3 GetForce() | 2564 | public Vector3 GetForce() |
2178 | { | 2565 | { |
2179 | PhysicsActor pa = PhysActor; | 2566 | return Force; |
2180 | |||
2181 | if (pa != null) | ||
2182 | return pa.Force; | ||
2183 | else | ||
2184 | return Vector3.Zero; | ||
2185 | } | 2567 | } |
2186 | 2568 | ||
2187 | /// <summary> | 2569 | /// <summary> |
@@ -2396,15 +2778,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2396 | 2778 | ||
2397 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) | 2779 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) |
2398 | { | 2780 | { |
2399 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) | 2781 | bool sendToRoot = true; |
2400 | { | ||
2401 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
2402 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2403 | |||
2404 | colliding.Add(CreateDetObjectForGround()); | ||
2405 | LandCollidingMessage.Colliders = colliding; | ||
2406 | 2782 | ||
2783 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
2784 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2785 | |||
2786 | colliding.Add(CreateDetObjectForGround()); | ||
2787 | LandCollidingMessage.Colliders = colliding; | ||
2788 | |||
2789 | if (Inventory.ContainsScripts()) | ||
2790 | { | ||
2791 | if (!PassCollisions) | ||
2792 | sendToRoot = false; | ||
2793 | } | ||
2794 | if ((ScriptEvents & ev) != 0) | ||
2407 | notify(LocalId, LandCollidingMessage); | 2795 | notify(LocalId, LandCollidingMessage); |
2796 | |||
2797 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot) | ||
2798 | { | ||
2799 | notify(ParentGroup.RootPart.LocalId, LandCollidingMessage); | ||
2408 | } | 2800 | } |
2409 | } | 2801 | } |
2410 | 2802 | ||
@@ -2420,57 +2812,120 @@ namespace OpenSim.Region.Framework.Scenes | |||
2420 | List<uint> endedColliders = new List<uint>(); | 2812 | List<uint> endedColliders = new List<uint>(); |
2421 | List<uint> startedColliders = new List<uint>(); | 2813 | List<uint> startedColliders = new List<uint>(); |
2422 | 2814 | ||
2423 | // calculate things that started colliding this time | 2815 | if (collissionswith.Count == 0) |
2424 | // and build up list of colliders this time | ||
2425 | foreach (uint localid in collissionswith.Keys) | ||
2426 | { | 2816 | { |
2427 | thisHitColliders.Add(localid); | 2817 | if (m_lastColliders.Count == 0) |
2428 | if (!m_lastColliders.Contains(localid)) | 2818 | return; // nothing to do |
2429 | startedColliders.Add(localid); | ||
2430 | } | ||
2431 | 2819 | ||
2432 | // calculate things that ended colliding | 2820 | foreach (uint localID in m_lastColliders) |
2433 | foreach (uint localID in m_lastColliders) | 2821 | { |
2434 | { | ||
2435 | if (!thisHitColliders.Contains(localID)) | ||
2436 | endedColliders.Add(localID); | 2822 | endedColliders.Add(localID); |
2823 | } | ||
2824 | m_lastColliders.Clear(); | ||
2437 | } | 2825 | } |
2438 | 2826 | ||
2439 | //add the items that started colliding this time to the last colliders list. | 2827 | else |
2440 | foreach (uint localID in startedColliders) | 2828 | { |
2441 | m_lastColliders.Add(localID); | 2829 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); |
2442 | 2830 | ||
2443 | // remove things that ended colliding from the last colliders list | 2831 | // calculate things that started colliding this time |
2444 | foreach (uint localID in endedColliders) | 2832 | // and build up list of colliders this time |
2445 | m_lastColliders.Remove(localID); | 2833 | if (!VolumeDetectActive && CollisionSoundType >= 0) |
2834 | { | ||
2835 | CollisionForSoundInfo soundinfo; | ||
2836 | ContactPoint curcontact; | ||
2446 | 2837 | ||
2447 | // play the sound. | 2838 | foreach (uint id in collissionswith.Keys) |
2448 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) | 2839 | { |
2449 | { | 2840 | thisHitColliders.Add(id); |
2450 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | 2841 | if (!m_lastColliders.Contains(id)) |
2451 | if (soundModule != null) | 2842 | { |
2843 | startedColliders.Add(id); | ||
2844 | |||
2845 | curcontact = collissionswith[id]; | ||
2846 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
2847 | { | ||
2848 | soundinfo = new CollisionForSoundInfo(); | ||
2849 | soundinfo.colliderID = id; | ||
2850 | soundinfo.position = curcontact.Position; | ||
2851 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2852 | soundinfolist.Add(soundinfo); | ||
2853 | } | ||
2854 | } | ||
2855 | } | ||
2856 | } | ||
2857 | else | ||
2858 | { | ||
2859 | foreach (uint id in collissionswith.Keys) | ||
2860 | { | ||
2861 | thisHitColliders.Add(id); | ||
2862 | if (!m_lastColliders.Contains(id)) | ||
2863 | startedColliders.Add(id); | ||
2864 | } | ||
2865 | } | ||
2866 | |||
2867 | // calculate things that ended colliding | ||
2868 | foreach (uint localID in m_lastColliders) | ||
2452 | { | 2869 | { |
2453 | soundModule.SendSound(UUID, CollisionSound, | 2870 | if (!thisHitColliders.Contains(localID)) |
2454 | CollisionSoundVolume, true, 0, 0, false, | 2871 | endedColliders.Add(localID); |
2455 | false); | ||
2456 | } | 2872 | } |
2873 | |||
2874 | //add the items that started colliding this time to the last colliders list. | ||
2875 | foreach (uint localID in startedColliders) | ||
2876 | m_lastColliders.Add(localID); | ||
2877 | |||
2878 | // remove things that ended colliding from the last colliders list | ||
2879 | foreach (uint localID in endedColliders) | ||
2880 | m_lastColliders.Remove(localID); | ||
2881 | |||
2882 | // play sounds. | ||
2883 | if (soundinfolist.Count > 0) | ||
2884 | CollisionSounds.PartCollisionSound(this, soundinfolist); | ||
2457 | } | 2885 | } |
2458 | 2886 | ||
2459 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2887 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2460 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2888 | if (!VolumeDetectActive) |
2889 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | ||
2461 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2890 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2462 | 2891 | ||
2463 | if (startedColliders.Contains(0)) | 2892 | if (startedColliders.Contains(0)) |
2464 | { | 2893 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); |
2465 | if (m_lastColliders.Contains(0)) | 2894 | if (m_lastColliders.Contains(0)) |
2466 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); | 2895 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); |
2467 | else | ||
2468 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); | ||
2469 | } | ||
2470 | if (endedColliders.Contains(0)) | 2896 | if (endedColliders.Contains(0)) |
2471 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); | 2897 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); |
2472 | } | 2898 | } |
2473 | 2899 | ||
2900 | // The Collision sounds code calls this | ||
2901 | public void SendCollisionSound(UUID soundID, double volume, Vector3 position) | ||
2902 | { | ||
2903 | if (soundID == UUID.Zero) | ||
2904 | return; | ||
2905 | |||
2906 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | ||
2907 | if (soundModule == null) | ||
2908 | return; | ||
2909 | |||
2910 | if (volume > 1) | ||
2911 | volume = 1; | ||
2912 | if (volume < 0) | ||
2913 | volume = 0; | ||
2914 | |||
2915 | int now = Util.EnvironmentTickCount(); | ||
2916 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) | ||
2917 | return; | ||
2918 | |||
2919 | LastColSoundSentTime = now; | ||
2920 | |||
2921 | UUID ownerID = OwnerID; | ||
2922 | UUID objectID = ParentGroup.RootPart.UUID; | ||
2923 | UUID parentID = ParentGroup.UUID; | ||
2924 | ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; | ||
2925 | |||
2926 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 ); | ||
2927 | } | ||
2928 | |||
2474 | public void PhysicsOutOfBounds(Vector3 pos) | 2929 | public void PhysicsOutOfBounds(Vector3 pos) |
2475 | { | 2930 | { |
2476 | // Note: This is only being called on the root prim at this time. | 2931 | // Note: This is only being called on the root prim at this time. |
@@ -2492,9 +2947,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2492 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | 2947 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); |
2493 | 2948 | ||
2494 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | 2949 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) |
2495 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | 2950 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) |
2496 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | 2951 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) |
2497 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) | 2952 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) |
2498 | { | 2953 | { |
2499 | ParentGroup.AbsolutePosition = newpos; | 2954 | ParentGroup.AbsolutePosition = newpos; |
2500 | return; | 2955 | return; |
@@ -2779,6 +3234,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2779 | if (ParentGroup == null) | 3234 | if (ParentGroup == null) |
2780 | return; | 3235 | return; |
2781 | 3236 | ||
3237 | // Update the "last" values | ||
3238 | m_lastPosition = OffsetPosition; | ||
3239 | m_lastRotation = RotationOffset; | ||
3240 | m_lastVelocity = Velocity; | ||
3241 | m_lastAcceleration = Acceleration; | ||
3242 | m_lastAngularVelocity = AngularVelocity; | ||
3243 | m_lastUpdateSentTime = Environment.TickCount; | ||
3244 | |||
2782 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 3245 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2783 | { | 3246 | { |
2784 | SendFullUpdate(avatar.ControllingClient); | 3247 | SendFullUpdate(avatar.ControllingClient); |
@@ -2837,8 +3300,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2837 | { | 3300 | { |
2838 | const float ROTATION_TOLERANCE = 0.01f; | 3301 | const float ROTATION_TOLERANCE = 0.01f; |
2839 | const float VELOCITY_TOLERANCE = 0.001f; | 3302 | const float VELOCITY_TOLERANCE = 0.001f; |
2840 | const float POSITION_TOLERANCE = 0.05f; | 3303 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
2841 | const int TIME_MS_TOLERANCE = 3000; | 3304 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
2842 | 3305 | ||
2843 | switch (UpdateFlag) | 3306 | switch (UpdateFlag) |
2844 | { | 3307 | { |
@@ -2852,17 +3315,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2852 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || | 3315 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || |
2853 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || | 3316 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || |
2854 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 3317 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
2855 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 3318 | Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) |
2856 | { | 3319 | { |
2857 | SendTerseUpdateToAllClients(); | 3320 | SendTerseUpdateToAllClients(); |
2858 | 3321 | ||
2859 | // Update the "last" values | ||
2860 | m_lastPosition = OffsetPosition; | ||
2861 | m_lastRotation = RotationOffset; | ||
2862 | m_lastVelocity = Velocity; | ||
2863 | m_lastAcceleration = Acceleration; | ||
2864 | m_lastAngularVelocity = AngularVelocity; | ||
2865 | m_lastTerseSent = Environment.TickCount; | ||
2866 | } | 3322 | } |
2867 | break; | 3323 | break; |
2868 | } | 3324 | } |
@@ -2880,6 +3336,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2880 | /// </summary> | 3336 | /// </summary> |
2881 | public void SendTerseUpdateToAllClients() | 3337 | public void SendTerseUpdateToAllClients() |
2882 | { | 3338 | { |
3339 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3340 | return; | ||
3341 | |||
3342 | // Update the "last" values | ||
3343 | m_lastPosition = OffsetPosition; | ||
3344 | m_lastRotation = RotationOffset; | ||
3345 | m_lastVelocity = Velocity; | ||
3346 | m_lastAcceleration = Acceleration; | ||
3347 | m_lastAngularVelocity = AngularVelocity; | ||
3348 | m_lastUpdateSentTime = Environment.TickCount; | ||
3349 | |||
2883 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | 3350 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) |
2884 | { | 3351 | { |
2885 | SendTerseUpdateToClient(client); | 3352 | SendTerseUpdateToClient(client); |
@@ -2903,10 +3370,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2903 | 3370 | ||
2904 | public void SetBuoyancy(float fvalue) | 3371 | public void SetBuoyancy(float fvalue) |
2905 | { | 3372 | { |
2906 | PhysicsActor pa = PhysActor; | 3373 | Buoyancy = fvalue; |
2907 | 3374 | /* | |
2908 | if (pa != null) | 3375 | if (PhysActor != null) |
2909 | pa.Buoyancy = fvalue; | 3376 | { |
3377 | PhysActor.Buoyancy = fvalue; | ||
3378 | } | ||
3379 | */ | ||
2910 | } | 3380 | } |
2911 | 3381 | ||
2912 | public void SetDieAtEdge(bool p) | 3382 | public void SetDieAtEdge(bool p) |
@@ -2922,47 +3392,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2922 | PhysicsActor pa = PhysActor; | 3392 | PhysicsActor pa = PhysActor; |
2923 | 3393 | ||
2924 | if (pa != null) | 3394 | if (pa != null) |
2925 | pa.FloatOnWater = floatYN == 1; | 3395 | pa.FloatOnWater = (floatYN == 1); |
2926 | } | 3396 | } |
2927 | 3397 | ||
2928 | public void SetForce(Vector3 force) | 3398 | public void SetForce(Vector3 force) |
2929 | { | 3399 | { |
2930 | PhysicsActor pa = PhysActor; | 3400 | Force = force; |
3401 | } | ||
2931 | 3402 | ||
2932 | if (pa != null) | 3403 | public SOPVehicle VehicleParams |
2933 | pa.Force = force; | 3404 | { |
3405 | get | ||
3406 | { | ||
3407 | return m_vehicleParams; | ||
3408 | } | ||
3409 | set | ||
3410 | { | ||
3411 | m_vehicleParams = value; | ||
3412 | } | ||
3413 | } | ||
3414 | |||
3415 | |||
3416 | public int VehicleType | ||
3417 | { | ||
3418 | get | ||
3419 | { | ||
3420 | if (m_vehicleParams == null) | ||
3421 | return (int)Vehicle.TYPE_NONE; | ||
3422 | else | ||
3423 | return (int)m_vehicleParams.Type; | ||
3424 | } | ||
3425 | set | ||
3426 | { | ||
3427 | SetVehicleType(value); | ||
3428 | } | ||
2934 | } | 3429 | } |
2935 | 3430 | ||
2936 | public void SetVehicleType(int type) | 3431 | public void SetVehicleType(int type) |
2937 | { | 3432 | { |
2938 | PhysicsActor pa = PhysActor; | 3433 | m_vehicleParams = null; |
3434 | |||
3435 | if (type == (int)Vehicle.TYPE_NONE) | ||
3436 | { | ||
3437 | if (_parentID ==0 && PhysActor != null) | ||
3438 | PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; | ||
3439 | return; | ||
3440 | } | ||
3441 | m_vehicleParams = new SOPVehicle(); | ||
3442 | m_vehicleParams.ProcessTypeChange((Vehicle)type); | ||
3443 | { | ||
3444 | if (_parentID ==0 && PhysActor != null) | ||
3445 | PhysActor.VehicleType = type; | ||
3446 | return; | ||
3447 | } | ||
3448 | } | ||
2939 | 3449 | ||
2940 | if (pa != null) | 3450 | public void SetVehicleFlags(int param, bool remove) |
2941 | pa.VehicleType = type; | 3451 | { |
3452 | if (m_vehicleParams == null) | ||
3453 | return; | ||
3454 | |||
3455 | m_vehicleParams.ProcessVehicleFlags(param, remove); | ||
3456 | |||
3457 | if (_parentID ==0 && PhysActor != null) | ||
3458 | { | ||
3459 | PhysActor.VehicleFlags(param, remove); | ||
3460 | } | ||
2942 | } | 3461 | } |
2943 | 3462 | ||
2944 | public void SetVehicleFloatParam(int param, float value) | 3463 | public void SetVehicleFloatParam(int param, float value) |
2945 | { | 3464 | { |
2946 | PhysicsActor pa = PhysActor; | 3465 | if (m_vehicleParams == null) |
3466 | return; | ||
2947 | 3467 | ||
2948 | if (pa != null) | 3468 | m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value); |
2949 | pa.VehicleFloatParam(param, value); | 3469 | |
3470 | if (_parentID == 0 && PhysActor != null) | ||
3471 | { | ||
3472 | PhysActor.VehicleFloatParam(param, value); | ||
3473 | } | ||
2950 | } | 3474 | } |
2951 | 3475 | ||
2952 | public void SetVehicleVectorParam(int param, Vector3 value) | 3476 | public void SetVehicleVectorParam(int param, Vector3 value) |
2953 | { | 3477 | { |
2954 | PhysicsActor pa = PhysActor; | 3478 | if (m_vehicleParams == null) |
3479 | return; | ||
2955 | 3480 | ||
2956 | if (pa != null) | 3481 | m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value); |
2957 | pa.VehicleVectorParam(param, value); | 3482 | |
3483 | if (_parentID == 0 && PhysActor != null) | ||
3484 | { | ||
3485 | PhysActor.VehicleVectorParam(param, value); | ||
3486 | } | ||
2958 | } | 3487 | } |
2959 | 3488 | ||
2960 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 3489 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
2961 | { | 3490 | { |
2962 | PhysicsActor pa = PhysActor; | 3491 | if (m_vehicleParams == null) |
3492 | return; | ||
2963 | 3493 | ||
2964 | if (pa != null) | 3494 | m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation); |
2965 | pa.VehicleRotationParam(param, rotation); | 3495 | |
3496 | if (_parentID == 0 && PhysActor != null) | ||
3497 | { | ||
3498 | PhysActor.VehicleRotationParam(param, rotation); | ||
3499 | } | ||
2966 | } | 3500 | } |
2967 | 3501 | ||
2968 | /// <summary> | 3502 | /// <summary> |
@@ -3163,14 +3697,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3163 | hasProfileCut = hasDimple; // is it the same thing? | 3697 | hasProfileCut = hasDimple; // is it the same thing? |
3164 | } | 3698 | } |
3165 | 3699 | ||
3166 | public void SetVehicleFlags(int param, bool remove) | ||
3167 | { | ||
3168 | PhysicsActor pa = PhysActor; | ||
3169 | |||
3170 | if (pa != null) | ||
3171 | pa.VehicleFlags(param, remove); | ||
3172 | } | ||
3173 | |||
3174 | public void SetGroup(UUID groupID, IClientAPI client) | 3700 | public void SetGroup(UUID groupID, IClientAPI client) |
3175 | { | 3701 | { |
3176 | // Scene.AddNewPrims() calls with client == null so can't use this. | 3702 | // Scene.AddNewPrims() calls with client == null so can't use this. |
@@ -3274,71 +3800,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3274 | { | 3800 | { |
3275 | ParentGroup.stopMoveToTarget(); | 3801 | ParentGroup.stopMoveToTarget(); |
3276 | 3802 | ||
3277 | ParentGroup.ScheduleGroupForTerseUpdate(); | 3803 | // ParentGroup.ScheduleGroupForTerseUpdate(); |
3278 | //ParentGroup.ScheduleGroupForFullUpdate(); | 3804 | //ParentGroup.ScheduleGroupForFullUpdate(); |
3279 | } | 3805 | } |
3280 | 3806 | ||
3281 | public void StoreUndoState() | 3807 | public void StoreUndoState(ObjectChangeType change) |
3282 | { | 3808 | { |
3283 | StoreUndoState(false); | 3809 | if (m_UndoRedo == null) |
3284 | } | 3810 | m_UndoRedo = new UndoRedoState(5); |
3285 | |||
3286 | public void StoreUndoState(bool forGroup) | ||
3287 | { | ||
3288 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3289 | return; | ||
3290 | |||
3291 | if (Undoing) | ||
3292 | { | ||
3293 | // m_log.DebugFormat( | ||
3294 | // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); | ||
3295 | return; | ||
3296 | } | ||
3297 | |||
3298 | if (IgnoreUndoUpdate) | ||
3299 | { | ||
3300 | // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); | ||
3301 | return; | ||
3302 | } | ||
3303 | 3811 | ||
3304 | lock (m_undo) | 3812 | lock (m_UndoRedo) |
3305 | { | 3813 | { |
3306 | if (m_undo.Count > 0) | 3814 | if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended |
3307 | { | 3815 | { |
3308 | UndoState last = m_undo[m_undo.Count - 1]; | 3816 | m_UndoRedo.StoreUndo(this, change); |
3309 | if (last != null) | ||
3310 | { | ||
3311 | // TODO: May need to fix for group comparison | ||
3312 | if (last.Compare(this)) | ||
3313 | { | ||
3314 | // m_log.DebugFormat( | ||
3315 | // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", | ||
3316 | // Name, LocalId, m_undo.Count); | ||
3317 | |||
3318 | return; | ||
3319 | } | ||
3320 | } | ||
3321 | } | ||
3322 | |||
3323 | // m_log.DebugFormat( | ||
3324 | // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", | ||
3325 | // Name, LocalId, forGroup, m_undo.Count); | ||
3326 | |||
3327 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3328 | { | ||
3329 | UndoState nUndo = new UndoState(this, forGroup); | ||
3330 | |||
3331 | m_undo.Add(nUndo); | ||
3332 | |||
3333 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3334 | m_undo.RemoveAt(0); | ||
3335 | |||
3336 | if (m_redo.Count > 0) | ||
3337 | m_redo.Clear(); | ||
3338 | |||
3339 | // m_log.DebugFormat( | ||
3340 | // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", | ||
3341 | // Name, LocalId, forGroup, m_undo.Count); | ||
3342 | } | 3817 | } |
3343 | } | 3818 | } |
3344 | } | 3819 | } |
@@ -3350,88 +3825,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
3350 | { | 3825 | { |
3351 | get | 3826 | get |
3352 | { | 3827 | { |
3353 | lock (m_undo) | 3828 | if (m_UndoRedo == null) |
3354 | return m_undo.Count; | 3829 | return 0; |
3830 | return m_UndoRedo.Count; | ||
3355 | } | 3831 | } |
3356 | } | 3832 | } |
3357 | 3833 | ||
3358 | public void Undo() | 3834 | public void Undo() |
3359 | { | 3835 | { |
3360 | lock (m_undo) | 3836 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3361 | { | 3837 | return; |
3362 | // m_log.DebugFormat( | ||
3363 | // "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}", | ||
3364 | // Name, LocalId, m_undo.Count); | ||
3365 | |||
3366 | if (m_undo.Count > 0) | ||
3367 | { | ||
3368 | UndoState goback = m_undo[m_undo.Count - 1]; | ||
3369 | m_undo.RemoveAt(m_undo.Count - 1); | ||
3370 | |||
3371 | UndoState nUndo = null; | ||
3372 | |||
3373 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3374 | { | ||
3375 | nUndo = new UndoState(this, goback.ForGroup); | ||
3376 | } | ||
3377 | |||
3378 | goback.PlaybackState(this); | ||
3379 | |||
3380 | if (nUndo != null) | ||
3381 | { | ||
3382 | m_redo.Add(nUndo); | ||
3383 | |||
3384 | if (m_redo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3385 | m_redo.RemoveAt(0); | ||
3386 | } | ||
3387 | } | ||
3388 | 3838 | ||
3389 | // m_log.DebugFormat( | 3839 | lock (m_UndoRedo) |
3390 | // "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", | 3840 | { |
3391 | // Name, LocalId, m_undo.Count); | 3841 | Undoing = true; |
3842 | m_UndoRedo.Undo(this); | ||
3843 | Undoing = false; | ||
3392 | } | 3844 | } |
3393 | } | 3845 | } |
3394 | 3846 | ||
3395 | public void Redo() | 3847 | public void Redo() |
3396 | { | 3848 | { |
3397 | lock (m_undo) | 3849 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3398 | { | 3850 | return; |
3399 | // m_log.DebugFormat( | ||
3400 | // "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}", | ||
3401 | // Name, LocalId, m_redo.Count); | ||
3402 | |||
3403 | if (m_redo.Count > 0) | ||
3404 | { | ||
3405 | UndoState gofwd = m_redo[m_redo.Count - 1]; | ||
3406 | m_redo.RemoveAt(m_redo.Count - 1); | ||
3407 | |||
3408 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3409 | { | ||
3410 | UndoState nUndo = new UndoState(this, gofwd.ForGroup); | ||
3411 | |||
3412 | m_undo.Add(nUndo); | ||
3413 | |||
3414 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3415 | m_undo.RemoveAt(0); | ||
3416 | } | ||
3417 | |||
3418 | gofwd.PlayfwdState(this); | ||
3419 | 3851 | ||
3420 | // m_log.DebugFormat( | 3852 | lock (m_UndoRedo) |
3421 | // "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", | 3853 | { |
3422 | // Name, LocalId, m_redo.Count); | 3854 | Undoing = true; |
3423 | } | 3855 | m_UndoRedo.Redo(this); |
3856 | Undoing = false; | ||
3424 | } | 3857 | } |
3425 | } | 3858 | } |
3426 | 3859 | ||
3427 | public void ClearUndoState() | 3860 | public void ClearUndoState() |
3428 | { | 3861 | { |
3429 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); | 3862 | if (m_UndoRedo == null || Undoing) |
3863 | return; | ||
3430 | 3864 | ||
3431 | lock (m_undo) | 3865 | lock (m_UndoRedo) |
3432 | { | 3866 | { |
3433 | m_undo.Clear(); | 3867 | m_UndoRedo.Clear(); |
3434 | m_redo.Clear(); | ||
3435 | } | 3868 | } |
3436 | } | 3869 | } |
3437 | 3870 | ||
@@ -3983,7 +4416,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3983 | if (god) | 4416 | if (god) |
3984 | { | 4417 | { |
3985 | BaseMask = ApplyMask(BaseMask, set, mask); | 4418 | BaseMask = ApplyMask(BaseMask, set, mask); |
3986 | Inventory.ApplyGodPermissions(_baseMask); | 4419 | Inventory.ApplyGodPermissions(BaseMask); |
3987 | } | 4420 | } |
3988 | 4421 | ||
3989 | break; | 4422 | break; |
@@ -4014,7 +4447,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4014 | } | 4447 | } |
4015 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & | 4448 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & |
4016 | baseMask; | 4449 | baseMask; |
4017 | // Prevent the client from creating no mod, no copy | 4450 | // Prevent the client from creating no copy, no transfer |
4018 | // objects | 4451 | // objects |
4019 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) | 4452 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) |
4020 | NextOwnerMask |= (uint)PermissionMask.Transfer; | 4453 | NextOwnerMask |= (uint)PermissionMask.Transfer; |
@@ -4032,20 +4465,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4032 | { | 4465 | { |
4033 | bool update = false; | 4466 | bool update = false; |
4034 | 4467 | ||
4035 | if (BaseMask != source.BaseMask || | 4468 | uint prevOwnerMask = OwnerMask; |
4036 | OwnerMask != source.OwnerMask || | 4469 | uint prevGroupMask = GroupMask; |
4037 | GroupMask != source.GroupMask || | 4470 | uint prevEveryoneMask = EveryoneMask; |
4038 | EveryoneMask != source.EveryoneMask || | 4471 | uint prevNextOwnerMask = NextOwnerMask; |
4039 | NextOwnerMask != source.NextOwnerMask) | ||
4040 | update = true; | ||
4041 | 4472 | ||
4042 | BaseMask = source.BaseMask; | 4473 | OwnerMask = source.OwnerMask & BaseMask; |
4043 | OwnerMask = source.OwnerMask; | 4474 | GroupMask = source.GroupMask & BaseMask; |
4044 | GroupMask = source.GroupMask; | 4475 | EveryoneMask = source.EveryoneMask & BaseMask; |
4045 | EveryoneMask = source.EveryoneMask; | 4476 | NextOwnerMask = source.NextOwnerMask & BaseMask; |
4046 | NextOwnerMask = source.NextOwnerMask; | ||
4047 | 4477 | ||
4048 | if (update) | 4478 | if (OwnerMask != prevOwnerMask || |
4479 | GroupMask != prevGroupMask || | ||
4480 | EveryoneMask != prevEveryoneMask || | ||
4481 | NextOwnerMask != prevNextOwnerMask) | ||
4049 | SendFullUpdateToAllClients(); | 4482 | SendFullUpdateToAllClients(); |
4050 | } | 4483 | } |
4051 | 4484 | ||
@@ -4096,6 +4529,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4096 | } | 4529 | } |
4097 | } | 4530 | } |
4098 | 4531 | ||
4532 | |||
4099 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) | 4533 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) |
4100 | { | 4534 | { |
4101 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) | 4535 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) |
@@ -4123,7 +4557,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4123 | /// <param name="SetTemporary"></param> | 4557 | /// <param name="SetTemporary"></param> |
4124 | /// <param name="SetPhantom"></param> | 4558 | /// <param name="SetPhantom"></param> |
4125 | /// <param name="SetVD"></param> | 4559 | /// <param name="SetVD"></param> |
4126 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) | 4560 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) |
4127 | { | 4561 | { |
4128 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); | 4562 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); |
4129 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); | 4563 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); |
@@ -4133,116 +4567,98 @@ namespace OpenSim.Region.Framework.Scenes | |||
4133 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) | 4567 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) |
4134 | return; | 4568 | return; |
4135 | 4569 | ||
4136 | PhysicsActor pa = PhysActor; | 4570 | VolumeDetectActive = SetVD; |
4137 | 4571 | ||
4138 | // Special cases for VD. VD can only be called from a script | 4572 | // volume detector implies phantom |
4139 | // and can't be combined with changes to other states. So we can rely | 4573 | if (VolumeDetectActive) |
4140 | // that... | ||
4141 | // ... if VD is changed, all others are not. | ||
4142 | // ... if one of the others is changed, VD is not. | ||
4143 | if (SetVD) // VD is active, special logic applies | ||
4144 | { | ||
4145 | // State machine logic for VolumeDetect | ||
4146 | // More logic below | ||
4147 | bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; | ||
4148 | |||
4149 | if (phanReset) // Phantom changes from on to off switch VD off too | ||
4150 | { | ||
4151 | SetVD = false; // Switch it of for the course of this routine | ||
4152 | VolumeDetectActive = false; // and also permanently | ||
4153 | |||
4154 | if (pa != null) | ||
4155 | pa.SetVolumeDetect(0); // Let physics know about it too | ||
4156 | } | ||
4157 | else | ||
4158 | { | ||
4159 | // If volumedetect is active we don't want phantom to be applied. | ||
4160 | // If this is a new call to VD out of the state "phantom" | ||
4161 | // this will also cause the prim to be visible to physics | ||
4162 | SetPhantom = false; | ||
4163 | } | ||
4164 | } | ||
4165 | |||
4166 | if (UsePhysics && IsJoint()) | ||
4167 | { | ||
4168 | SetPhantom = true; | 4574 | SetPhantom = true; |
4169 | } | ||
4170 | 4575 | ||
4171 | if (UsePhysics) | 4576 | if (UsePhysics) |
4172 | { | ||
4173 | AddFlag(PrimFlags.Physics); | 4577 | AddFlag(PrimFlags.Physics); |
4174 | if (!wasUsingPhysics) | ||
4175 | { | ||
4176 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4177 | } | ||
4178 | } | ||
4179 | else | 4578 | else |
4180 | { | ||
4181 | RemFlag(PrimFlags.Physics); | 4579 | RemFlag(PrimFlags.Physics); |
4182 | if (wasUsingPhysics) | ||
4183 | { | ||
4184 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4185 | } | ||
4186 | } | ||
4187 | 4580 | ||
4188 | if (SetPhantom | 4581 | if (SetPhantom) |
4189 | || ParentGroup.IsAttachment | ||
4190 | || PhysicsShapeType == (byte)PhysShapeType.none | ||
4191 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints | ||
4192 | { | ||
4193 | AddFlag(PrimFlags.Phantom); | 4582 | AddFlag(PrimFlags.Phantom); |
4583 | else | ||
4584 | RemFlag(PrimFlags.Phantom); | ||
4194 | 4585 | ||
4195 | if (PhysActor != null) | 4586 | if (SetTemporary) |
4587 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4588 | else | ||
4589 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4590 | |||
4591 | |||
4592 | if (ParentGroup.Scene == null) | ||
4593 | return; | ||
4594 | |||
4595 | PhysicsActor pa = PhysActor; | ||
4596 | |||
4597 | if (pa != null && building && pa.Building != building) | ||
4598 | pa.Building = building; | ||
4599 | |||
4600 | if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none | ||
4601 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
4602 | { | ||
4603 | if (pa != null) | ||
4196 | { | 4604 | { |
4605 | if(wasUsingPhysics) | ||
4606 | ParentGroup.Scene.RemovePhysicalPrim(1); | ||
4197 | RemoveFromPhysics(); | 4607 | RemoveFromPhysics(); |
4198 | pa = null; | ||
4199 | } | 4608 | } |
4609 | |||
4610 | Velocity = new Vector3(0, 0, 0); | ||
4611 | Acceleration = new Vector3(0, 0, 0); | ||
4612 | if (ParentGroup.RootPart == this) | ||
4613 | AngularVelocity = new Vector3(0, 0, 0); | ||
4200 | } | 4614 | } |
4201 | else // Not phantom | 4615 | |
4616 | else | ||
4202 | { | 4617 | { |
4203 | RemFlag(PrimFlags.Phantom); | 4618 | if (ParentGroup.Scene.CollidablePrims) |
4204 | |||
4205 | if (ParentGroup.Scene == null) | ||
4206 | return; | ||
4207 | |||
4208 | if (ParentGroup.Scene.CollidablePrims && pa == null) | ||
4209 | { | 4619 | { |
4210 | AddToPhysics(UsePhysics, SetPhantom, false); | 4620 | if (pa == null) |
4211 | pa = PhysActor; | ||
4212 | |||
4213 | |||
4214 | if (pa != null) | ||
4215 | { | 4621 | { |
4216 | pa.SetMaterial(Material); | 4622 | AddToPhysics(UsePhysics, SetPhantom, building, false); |
4217 | DoPhysicsPropertyUpdate(UsePhysics, true); | 4623 | pa = PhysActor; |
4218 | 4624 | /* | |
4219 | if ( | 4625 | if (pa != null) |
4220 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4221 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4222 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4223 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4224 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4225 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4226 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4227 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4228 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4229 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4230 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4231 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4232 | (CollisionSound != UUID.Zero) | ||
4233 | ) | ||
4234 | { | 4626 | { |
4235 | pa.OnCollisionUpdate += PhysicsCollision; | 4627 | if ( |
4236 | pa.SubscribeEvents(1000); | 4628 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || |
4629 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4630 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4631 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4632 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4633 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4634 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4635 | ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4636 | (CollisionSound != UUID.Zero) | ||
4637 | ) | ||
4638 | { | ||
4639 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4640 | pa.SubscribeEvents(1000); | ||
4641 | } | ||
4237 | } | 4642 | } |
4643 | */ | ||
4644 | } | ||
4645 | else // it already has a physical representation | ||
4646 | { | ||
4647 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. | ||
4648 | /* moved into DoPhysicsPropertyUpdate | ||
4649 | if(VolumeDetectActive) | ||
4650 | pa.SetVolumeDetect(1); | ||
4651 | else | ||
4652 | pa.SetVolumeDetect(0); | ||
4653 | */ | ||
4654 | |||
4655 | if (pa.Building != building) | ||
4656 | pa.Building = building; | ||
4238 | } | 4657 | } |
4239 | } | ||
4240 | else // it already has a physical representation | ||
4241 | { | ||
4242 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim | ||
4243 | } | ||
4244 | } | ||
4245 | 4658 | ||
4659 | UpdatePhysicsSubscribedEvents(); | ||
4660 | } | ||
4661 | } | ||
4246 | if (SetVD) | 4662 | if (SetVD) |
4247 | { | 4663 | { |
4248 | // If the above logic worked (this is urgent candidate to unit tests!) | 4664 | // If the above logic worked (this is urgent candidate to unit tests!) |
@@ -4256,6 +4672,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4256 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 4672 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active |
4257 | VolumeDetectActive = true; | 4673 | VolumeDetectActive = true; |
4258 | } | 4674 | } |
4675 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | ||
4259 | } | 4676 | } |
4260 | else if (SetVD != wasVD) | 4677 | else if (SetVD != wasVD) |
4261 | { | 4678 | { |
@@ -4267,61 +4684,51 @@ namespace OpenSim.Region.Framework.Scenes | |||
4267 | RemFlag(PrimFlags.Phantom); | 4684 | RemFlag(PrimFlags.Phantom); |
4268 | VolumeDetectActive = false; | 4685 | VolumeDetectActive = false; |
4269 | } | 4686 | } |
4270 | 4687 | // and last in case we have a new actor and not building | |
4271 | if (SetTemporary) | ||
4272 | { | ||
4273 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4274 | } | ||
4275 | else | ||
4276 | { | ||
4277 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4278 | } | ||
4279 | |||
4280 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | ||
4281 | 4688 | ||
4282 | if (ParentGroup != null) | 4689 | if (ParentGroup != null) |
4283 | { | 4690 | { |
4284 | ParentGroup.HasGroupChanged = true; | 4691 | ParentGroup.HasGroupChanged = true; |
4285 | ScheduleFullUpdate(); | 4692 | ScheduleFullUpdate(); |
4286 | } | 4693 | } |
4287 | 4694 | ||
4288 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); | 4695 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); |
4289 | } | 4696 | } |
4290 | 4697 | ||
4291 | /// <summary> | 4698 | /// <summary> |
4292 | /// Adds this part to the physics scene. | 4699 | /// Adds this part to the physics scene. |
4700 | /// and sets the PhysActor property | ||
4293 | /// </summary> | 4701 | /// </summary> |
4294 | /// <remarks>This method also sets the PhysActor property.</remarks> | 4702 | /// <param name="isPhysical">Add this prim as physical.</param> |
4295 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | 4703 | /// <param name="isPhantom">Add this prim as phantom.</param> |
4296 | /// <returns> | 4704 | /// <param name="building">tells physics to delay full construction of object</param> |
4297 | /// The physics actor. null if there was a failure. | 4705 | /// <param name="applyDynamics">applies velocities, force and torque</param> |
4298 | /// </returns> | 4706 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) |
4299 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool applyDynamics) | 4707 | { |
4300 | { | ||
4301 | PhysicsActor pa; | 4708 | PhysicsActor pa; |
4302 | 4709 | ||
4303 | Vector3 velocity = Velocity; | 4710 | Vector3 velocity = Velocity; |
4304 | Vector3 rotationalVelocity = AngularVelocity;; | 4711 | Vector3 rotationalVelocity = AngularVelocity;; |
4305 | 4712 | ||
4306 | try | 4713 | try |
4307 | { | 4714 | { |
4308 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | 4715 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( |
4309 | string.Format("{0}/{1}", Name, UUID), | 4716 | string.Format("{0}/{1}", Name, UUID), |
4310 | Shape, | 4717 | Shape, |
4311 | AbsolutePosition, | 4718 | AbsolutePosition, |
4312 | Scale, | 4719 | Scale, |
4313 | GetWorldRotation(), | 4720 | GetWorldRotation(), |
4314 | isPhysical, | 4721 | isPhysical, |
4315 | isPhantom, | 4722 | isPhantom, |
4316 | PhysicsShapeType, | 4723 | PhysicsShapeType, |
4317 | m_localId); | 4724 | m_localId); |
4318 | } | 4725 | } |
4319 | catch (Exception e) | 4726 | catch (Exception e) |
4320 | { | 4727 | { |
4321 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); | 4728 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); |
4322 | pa = null; | 4729 | pa = null; |
4323 | } | 4730 | } |
4324 | 4731 | ||
4325 | if (pa != null) | 4732 | if (pa != null) |
4326 | { | 4733 | { |
4327 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | 4734 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info |
@@ -4334,9 +4741,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4334 | 4741 | ||
4335 | if (VolumeDetectActive) // change if not the default only | 4742 | if (VolumeDetectActive) // change if not the default only |
4336 | pa.SetVolumeDetect(1); | 4743 | pa.SetVolumeDetect(1); |
4744 | |||
4745 | if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) | ||
4746 | m_vehicleParams.SetVehicle(pa); | ||
4747 | |||
4337 | // we are going to tell rest of code about physics so better have this here | 4748 | // we are going to tell rest of code about physics so better have this here |
4338 | PhysActor = pa; | 4749 | PhysActor = pa; |
4339 | 4750 | ||
4751 | // DoPhysicsPropertyUpdate(isPhysical, true); | ||
4752 | // lets expand it here just with what it really needs to do | ||
4753 | |||
4340 | if (isPhysical) | 4754 | if (isPhysical) |
4341 | { | 4755 | { |
4342 | if (ParentGroup.RootPart.KeyframeMotion != null) | 4756 | if (ParentGroup.RootPart.KeyframeMotion != null) |
@@ -4358,19 +4772,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
4358 | } | 4772 | } |
4359 | } | 4773 | } |
4360 | 4774 | ||
4361 | if (applyDynamics) | 4775 | if (applyDynamics) |
4362 | // do independent of isphysical so parameters get setted (at least some) | 4776 | // do independent of isphysical so parameters get setted (at least some) |
4363 | { | 4777 | { |
4364 | Velocity = velocity; | 4778 | Velocity = velocity; |
4365 | AngularVelocity = rotationalVelocity; | 4779 | AngularVelocity = rotationalVelocity; |
4366 | // pa.Velocity = velocity; | 4780 | // pa.Velocity = velocity; |
4367 | pa.RotationalVelocity = rotationalVelocity; | 4781 | pa.RotationalVelocity = rotationalVelocity; |
4782 | |||
4783 | // if not vehicle and root part apply force and torque | ||
4784 | if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE) | ||
4785 | && LocalId == ParentGroup.RootPart.LocalId) | ||
4786 | { | ||
4787 | pa.Force = Force; | ||
4788 | pa.Torque = Torque; | ||
4789 | } | ||
4368 | } | 4790 | } |
4369 | 4791 | ||
4370 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 4792 | // if (Shape.SculptEntry) |
4793 | // CheckSculptAndLoad(); | ||
4794 | // else | ||
4795 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
4796 | |||
4797 | if (!building) | ||
4798 | pa.Building = false; | ||
4371 | } | 4799 | } |
4372 | 4800 | ||
4373 | PhysActor = pa; | 4801 | PhysActor = pa; |
4802 | |||
4374 | ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); | 4803 | ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); |
4375 | } | 4804 | } |
4376 | 4805 | ||
@@ -4379,13 +4808,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
4379 | /// </summary> | 4808 | /// </summary> |
4380 | /// <remarks> | 4809 | /// <remarks> |
4381 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 4810 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |
4382 | /// representation for collision detection. Rather, this would be used in situations such as making a prim | 4811 | /// representation for collision detection. |
4383 | /// phantom. | ||
4384 | /// </remarks> | 4812 | /// </remarks> |
4385 | public void RemoveFromPhysics() | 4813 | public void RemoveFromPhysics() |
4386 | { | 4814 | { |
4387 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | 4815 | PhysicsActor pa = PhysActor; |
4388 | ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 4816 | if (pa != null) |
4817 | { | ||
4818 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4819 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | ||
4820 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | ||
4821 | |||
4822 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | ||
4823 | |||
4824 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | ||
4825 | } | ||
4389 | PhysActor = null; | 4826 | PhysActor = null; |
4390 | } | 4827 | } |
4391 | 4828 | ||
@@ -4517,6 +4954,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4517 | { | 4954 | { |
4518 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); | 4955 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); |
4519 | 4956 | ||
4957 | return; | ||
4958 | |||
4520 | if (ParentGroup.IsDeleted) | 4959 | if (ParentGroup.IsDeleted) |
4521 | return; | 4960 | return; |
4522 | 4961 | ||
@@ -4640,6 +5079,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
4640 | } | 5079 | } |
4641 | } | 5080 | } |
4642 | 5081 | ||
5082 | |||
5083 | private void UpdatePhysicsSubscribedEvents() | ||
5084 | { | ||
5085 | PhysicsActor pa = PhysActor; | ||
5086 | if (pa == null) | ||
5087 | return; | ||
5088 | |||
5089 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5090 | |||
5091 | bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0)); | ||
5092 | |||
5093 | scriptEvents CombinedEvents = AggregateScriptEvents; | ||
5094 | |||
5095 | // merge with root part | ||
5096 | if (ParentGroup != null && ParentGroup.RootPart != null) | ||
5097 | CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents; | ||
5098 | |||
5099 | // submit to this part case | ||
5100 | if (VolumeDetectActive) | ||
5101 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | ||
5102 | else if ((Flags & PrimFlags.Phantom) != 0) | ||
5103 | CombinedEvents &= PhyscicsPhantonSubsEvents; | ||
5104 | else | ||
5105 | CombinedEvents &= PhysicsNeededSubsEvents; | ||
5106 | |||
5107 | if (hassound || CombinedEvents != 0) | ||
5108 | { | ||
5109 | // subscribe to physics updates. | ||
5110 | pa.OnCollisionUpdate += PhysicsCollision; | ||
5111 | pa.SubscribeEvents(50); // 20 reports per second | ||
5112 | } | ||
5113 | else | ||
5114 | { | ||
5115 | pa.UnSubscribeEvents(); | ||
5116 | } | ||
5117 | } | ||
5118 | |||
5119 | |||
4643 | public void aggregateScriptEvents() | 5120 | public void aggregateScriptEvents() |
4644 | { | 5121 | { |
4645 | if (ParentGroup == null || ParentGroup.RootPart == null) | 5122 | if (ParentGroup == null || ParentGroup.RootPart == null) |
@@ -4676,40 +5153,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
4676 | { | 5153 | { |
4677 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 5154 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4678 | } | 5155 | } |
4679 | 5156 | /* | |
4680 | PhysicsActor pa = PhysActor; | 5157 | PhysicsActor pa = PhysActor; |
4681 | 5158 | if (pa != null) | |
4682 | if ( | ||
4683 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4684 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4685 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4686 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4687 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4688 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4689 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4690 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4691 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4692 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4693 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4694 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4695 | (CollisionSound != UUID.Zero) | ||
4696 | ) | ||
4697 | { | 5159 | { |
4698 | // subscribe to physics updates. | 5160 | if ( |
4699 | if (pa != null) | 5161 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || |
5162 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
5163 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
5164 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
5165 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
5166 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
5167 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | ||
5168 | ) | ||
4700 | { | 5169 | { |
5170 | // subscribe to physics updates. | ||
4701 | pa.OnCollisionUpdate += PhysicsCollision; | 5171 | pa.OnCollisionUpdate += PhysicsCollision; |
4702 | pa.SubscribeEvents(1000); | 5172 | pa.SubscribeEvents(1000); |
4703 | } | 5173 | } |
4704 | } | 5174 | else |
4705 | else | ||
4706 | { | ||
4707 | if (pa != null) | ||
4708 | { | 5175 | { |
4709 | pa.UnSubscribeEvents(); | 5176 | pa.UnSubscribeEvents(); |
4710 | pa.OnCollisionUpdate -= PhysicsCollision; | 5177 | pa.OnCollisionUpdate -= PhysicsCollision; |
4711 | } | 5178 | } |
4712 | } | 5179 | } |
5180 | */ | ||
5181 | UpdatePhysicsSubscribedEvents(); | ||
4713 | 5182 | ||
4714 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 5183 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4715 | //{ | 5184 | //{ |
@@ -4843,6 +5312,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4843 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 5312 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4844 | } | 5313 | } |
4845 | 5314 | ||
5315 | public void ResetOwnerChangeFlag() | ||
5316 | { | ||
5317 | List<UUID> inv = Inventory.GetInventoryList(); | ||
5318 | |||
5319 | foreach (UUID itemID in inv) | ||
5320 | { | ||
5321 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
5322 | item.OwnerChanged = false; | ||
5323 | Inventory.UpdateInventoryItem(item, false, false); | ||
5324 | } | ||
5325 | } | ||
5326 | |||
4846 | /// <summary> | 5327 | /// <summary> |
4847 | /// Record an avatar sitting on this part. | 5328 | /// Record an avatar sitting on this part. |
4848 | /// </summary> | 5329 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 7dba7c8..d04d87b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -49,6 +49,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
49 | private string m_inventoryFileName = String.Empty; | 49 | private string m_inventoryFileName = String.Empty; |
50 | private byte[] m_inventoryFileData = new byte[0]; | 50 | private byte[] m_inventoryFileData = new byte[0]; |
51 | private uint m_inventoryFileNameSerial = 0; | 51 | private uint m_inventoryFileNameSerial = 0; |
52 | private bool m_inventoryPrivileged = false; | ||
53 | |||
54 | private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); | ||
52 | 55 | ||
53 | /// <value> | 56 | /// <value> |
54 | /// The part to which the inventory belongs. | 57 | /// The part to which the inventory belongs. |
@@ -85,7 +88,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
85 | /// </value> | 88 | /// </value> |
86 | protected internal TaskInventoryDictionary Items | 89 | protected internal TaskInventoryDictionary Items |
87 | { | 90 | { |
88 | get { return m_items; } | 91 | get { |
92 | return m_items; | ||
93 | } | ||
89 | set | 94 | set |
90 | { | 95 | { |
91 | m_items = value; | 96 | m_items = value; |
@@ -134,38 +139,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
134 | public void ResetInventoryIDs() | 139 | public void ResetInventoryIDs() |
135 | { | 140 | { |
136 | if (null == m_part) | 141 | if (null == m_part) |
137 | return; | 142 | m_items.LockItemsForWrite(true); |
138 | 143 | ||
139 | lock (m_items) | 144 | if (Items.Count == 0) |
140 | { | 145 | { |
141 | if (0 == m_items.Count) | 146 | m_items.LockItemsForWrite(false); |
142 | return; | 147 | return; |
148 | } | ||
143 | 149 | ||
144 | IList<TaskInventoryItem> items = GetInventoryItems(); | 150 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
145 | m_items.Clear(); | 151 | Items.Clear(); |
146 | 152 | ||
147 | foreach (TaskInventoryItem item in items) | 153 | foreach (TaskInventoryItem item in items) |
148 | { | 154 | { |
149 | item.ResetIDs(m_part.UUID); | 155 | item.ResetIDs(m_part.UUID); |
150 | m_items.Add(item.ItemID, item); | 156 | Items.Add(item.ItemID, item); |
151 | } | ||
152 | } | 157 | } |
158 | m_items.LockItemsForWrite(false); | ||
153 | } | 159 | } |
154 | 160 | ||
155 | public void ResetObjectID() | 161 | public void ResetObjectID() |
156 | { | 162 | { |
157 | lock (Items) | 163 | m_items.LockItemsForWrite(true); |
164 | |||
165 | if (Items.Count == 0) | ||
158 | { | 166 | { |
159 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 167 | m_items.LockItemsForWrite(false); |
160 | Items.Clear(); | 168 | return; |
161 | |||
162 | foreach (TaskInventoryItem item in items) | ||
163 | { | ||
164 | item.ParentPartID = m_part.UUID; | ||
165 | item.ParentID = m_part.UUID; | ||
166 | Items.Add(item.ItemID, item); | ||
167 | } | ||
168 | } | 169 | } |
170 | |||
171 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
172 | Items.Clear(); | ||
173 | |||
174 | foreach (TaskInventoryItem item in items) | ||
175 | { | ||
176 | item.ParentPartID = m_part.UUID; | ||
177 | item.ParentID = m_part.UUID; | ||
178 | Items.Add(item.ItemID, item); | ||
179 | } | ||
180 | m_items.LockItemsForWrite(false); | ||
169 | } | 181 | } |
170 | 182 | ||
171 | /// <summary> | 183 | /// <summary> |
@@ -174,17 +186,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
174 | /// <param name="ownerId"></param> | 186 | /// <param name="ownerId"></param> |
175 | public void ChangeInventoryOwner(UUID ownerId) | 187 | public void ChangeInventoryOwner(UUID ownerId) |
176 | { | 188 | { |
177 | lock (Items) | 189 | List<TaskInventoryItem> items = GetInventoryItems(); |
178 | { | 190 | |
179 | if (0 == Items.Count) | 191 | if (items.Count == 0) |
180 | { | 192 | return; |
181 | return; | ||
182 | } | ||
183 | } | ||
184 | 193 | ||
194 | m_items.LockItemsForWrite(true); | ||
185 | HasInventoryChanged = true; | 195 | HasInventoryChanged = true; |
186 | m_part.ParentGroup.HasGroupChanged = true; | 196 | m_part.ParentGroup.HasGroupChanged = true; |
187 | List<TaskInventoryItem> items = GetInventoryItems(); | ||
188 | foreach (TaskInventoryItem item in items) | 197 | foreach (TaskInventoryItem item in items) |
189 | { | 198 | { |
190 | if (ownerId != item.OwnerID) | 199 | if (ownerId != item.OwnerID) |
@@ -195,6 +204,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
195 | item.PermsGranter = UUID.Zero; | 204 | item.PermsGranter = UUID.Zero; |
196 | item.OwnerChanged = true; | 205 | item.OwnerChanged = true; |
197 | } | 206 | } |
207 | m_items.LockItemsForWrite(false); | ||
198 | } | 208 | } |
199 | 209 | ||
200 | /// <summary> | 210 | /// <summary> |
@@ -203,12 +213,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
203 | /// <param name="groupID"></param> | 213 | /// <param name="groupID"></param> |
204 | public void ChangeInventoryGroup(UUID groupID) | 214 | public void ChangeInventoryGroup(UUID groupID) |
205 | { | 215 | { |
206 | lock (Items) | 216 | m_items.LockItemsForWrite(true); |
217 | if (0 == Items.Count) | ||
207 | { | 218 | { |
208 | if (0 == Items.Count) | 219 | m_items.LockItemsForWrite(false); |
209 | { | 220 | return; |
210 | return; | ||
211 | } | ||
212 | } | 221 | } |
213 | 222 | ||
214 | // Don't let this set the HasGroupChanged flag for attachments | 223 | // Don't let this set the HasGroupChanged flag for attachments |
@@ -220,12 +229,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
220 | m_part.ParentGroup.HasGroupChanged = true; | 229 | m_part.ParentGroup.HasGroupChanged = true; |
221 | } | 230 | } |
222 | 231 | ||
223 | List<TaskInventoryItem> items = GetInventoryItems(); | 232 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
224 | foreach (TaskInventoryItem item in items) | 233 | foreach (TaskInventoryItem item in items) |
225 | { | 234 | { |
226 | if (groupID != item.GroupID) | 235 | if (groupID != item.GroupID) |
236 | { | ||
227 | item.GroupID = groupID; | 237 | item.GroupID = groupID; |
238 | } | ||
228 | } | 239 | } |
240 | m_items.LockItemsForWrite(false); | ||
229 | } | 241 | } |
230 | 242 | ||
231 | private void QueryScriptStates() | 243 | private void QueryScriptStates() |
@@ -233,15 +245,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
233 | if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) | 245 | if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) |
234 | return; | 246 | return; |
235 | 247 | ||
236 | lock (Items) | 248 | Items.LockItemsForRead(true); |
249 | foreach (TaskInventoryItem item in Items.Values) | ||
237 | { | 250 | { |
238 | foreach (TaskInventoryItem item in Items.Values) | 251 | if (item.InvType == (int)InventoryType.LSL) |
239 | { | 252 | { |
240 | bool running; | 253 | bool running; |
241 | if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running)) | 254 | if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running)) |
242 | item.ScriptRunning = running; | 255 | item.ScriptRunning = running; |
243 | } | 256 | } |
244 | } | 257 | } |
258 | |||
259 | Items.LockItemsForRead(false); | ||
245 | } | 260 | } |
246 | 261 | ||
247 | public bool TryGetScriptInstanceRunning(UUID itemId, out bool running) | 262 | public bool TryGetScriptInstanceRunning(UUID itemId, out bool running) |
@@ -318,7 +333,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
318 | { | 333 | { |
319 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | 334 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
320 | foreach (TaskInventoryItem item in scripts) | 335 | foreach (TaskInventoryItem item in scripts) |
336 | { | ||
321 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | 337 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
338 | m_part.RemoveScriptEvents(item.ItemID); | ||
339 | } | ||
322 | } | 340 | } |
323 | 341 | ||
324 | /// <summary> | 342 | /// <summary> |
@@ -340,7 +358,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
340 | // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 358 | // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
341 | 359 | ||
342 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) | 360 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) |
361 | { | ||
362 | StoreScriptError(item.ItemID, "no permission"); | ||
343 | return false; | 363 | return false; |
364 | } | ||
344 | 365 | ||
345 | m_part.AddFlag(PrimFlags.Scripted); | 366 | m_part.AddFlag(PrimFlags.Scripted); |
346 | 367 | ||
@@ -350,14 +371,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
350 | if (stateSource == 2 && // Prim crossing | 371 | if (stateSource == 2 && // Prim crossing |
351 | m_part.ParentGroup.Scene.m_trustBinaries) | 372 | m_part.ParentGroup.Scene.m_trustBinaries) |
352 | { | 373 | { |
353 | lock (m_items) | 374 | m_items.LockItemsForWrite(true); |
354 | { | 375 | m_items[item.ItemID].PermsMask = 0; |
355 | m_items[item.ItemID].PermsMask = 0; | 376 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
356 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 377 | m_items.LockItemsForWrite(false); |
357 | } | ||
358 | |||
359 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 378 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
360 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 379 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
380 | StoreScriptErrors(item.ItemID, null); | ||
361 | m_part.ParentGroup.AddActiveScriptCount(1); | 381 | m_part.ParentGroup.AddActiveScriptCount(1); |
362 | m_part.ScheduleFullUpdate(); | 382 | m_part.ScheduleFullUpdate(); |
363 | return true; | 383 | return true; |
@@ -366,6 +386,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
366 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); | 386 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
367 | if (null == asset) | 387 | if (null == asset) |
368 | { | 388 | { |
389 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | ||
390 | StoreScriptError(item.ItemID, msg); | ||
369 | m_log.ErrorFormat( | 391 | m_log.ErrorFormat( |
370 | "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", | 392 | "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
371 | item.Name, item.ItemID, m_part.AbsolutePosition, | 393 | item.Name, item.ItemID, m_part.AbsolutePosition, |
@@ -378,16 +400,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
378 | if (m_part.ParentGroup.m_savedScriptState != null) | 400 | if (m_part.ParentGroup.m_savedScriptState != null) |
379 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); | 401 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); |
380 | 402 | ||
381 | lock (m_items) | 403 | m_items.LockItemsForWrite(true); |
382 | { | 404 | |
383 | m_items[item.ItemID].OldItemID = item.OldItemID; | 405 | m_items[item.ItemID].OldItemID = item.OldItemID; |
384 | m_items[item.ItemID].PermsMask = 0; | 406 | m_items[item.ItemID].PermsMask = 0; |
385 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 407 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
386 | } | ||
387 | 408 | ||
409 | m_items.LockItemsForWrite(false); | ||
410 | |||
388 | string script = Utils.BytesToString(asset.Data); | 411 | string script = Utils.BytesToString(asset.Data); |
389 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 412 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
390 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 413 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
414 | StoreScriptErrors(item.ItemID, null); | ||
391 | if (!item.ScriptRunning) | 415 | if (!item.ScriptRunning) |
392 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript( | 416 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript( |
393 | m_part.LocalId, item.ItemID); | 417 | m_part.LocalId, item.ItemID); |
@@ -460,22 +484,149 @@ namespace OpenSim.Region.Framework.Scenes | |||
460 | return stateID; | 484 | return stateID; |
461 | } | 485 | } |
462 | 486 | ||
487 | /// <summary> | ||
488 | /// Start a script which is in this prim's inventory. | ||
489 | /// Some processing may occur in the background, but this routine returns asap. | ||
490 | /// </summary> | ||
491 | /// <param name="itemId"> | ||
492 | /// A <see cref="UUID"/> | ||
493 | /// </param> | ||
463 | public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 494 | public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
464 | { | 495 | { |
465 | TaskInventoryItem item = GetInventoryItem(itemId); | 496 | lock (m_scriptErrors) |
466 | if (item != null) | ||
467 | { | 497 | { |
468 | return CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | 498 | // Indicate to CreateScriptInstanceInternal() we don't want it to wait for completion |
499 | m_scriptErrors.Remove(itemId); | ||
500 | } | ||
501 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
502 | return true; | ||
503 | } | ||
504 | |||
505 | private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
506 | { | ||
507 | m_items.LockItemsForRead(true); | ||
508 | if (m_items.ContainsKey(itemId)) | ||
509 | { | ||
510 | if (m_items.ContainsKey(itemId)) | ||
511 | { | ||
512 | m_items.LockItemsForRead(false); | ||
513 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | ||
514 | } | ||
515 | else | ||
516 | { | ||
517 | m_items.LockItemsForRead(false); | ||
518 | string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, | ||
519 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
520 | StoreScriptError(itemId, msg); | ||
521 | m_log.ErrorFormat( | ||
522 | "[PRIM INVENTORY]: " + | ||
523 | "Couldn't start script with ID {0} since it {1}", itemId, msg); | ||
524 | } | ||
469 | } | 525 | } |
470 | else | 526 | else |
471 | { | 527 | { |
528 | m_items.LockItemsForRead(false); | ||
529 | string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); | ||
530 | StoreScriptError(itemId, msg); | ||
472 | m_log.ErrorFormat( | 531 | m_log.ErrorFormat( |
473 | "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 532 | "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", |
474 | itemId, m_part.Name, m_part.UUID, | 533 | itemId, m_part.Name, m_part.UUID, |
475 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 534 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
535 | } | ||
536 | |||
537 | } | ||
476 | 538 | ||
477 | return false; | 539 | /// <summary> |
540 | /// Start a script which is in this prim's inventory and return any compilation error messages. | ||
541 | /// </summary> | ||
542 | /// <param name="itemId"> | ||
543 | /// A <see cref="UUID"/> | ||
544 | /// </param> | ||
545 | public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
546 | { | ||
547 | ArrayList errors; | ||
548 | |||
549 | // Indicate to CreateScriptInstanceInternal() we want it to | ||
550 | // post any compilation/loading error messages | ||
551 | lock (m_scriptErrors) | ||
552 | { | ||
553 | m_scriptErrors[itemId] = null; | ||
554 | } | ||
555 | |||
556 | // Perform compilation/loading | ||
557 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
558 | |||
559 | // Wait for and retrieve any errors | ||
560 | lock (m_scriptErrors) | ||
561 | { | ||
562 | while ((errors = m_scriptErrors[itemId]) == null) | ||
563 | { | ||
564 | if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000)) | ||
565 | { | ||
566 | m_log.ErrorFormat( | ||
567 | "[PRIM INVENTORY]: " + | ||
568 | "timedout waiting for script {0} errors", itemId); | ||
569 | errors = m_scriptErrors[itemId]; | ||
570 | if (errors == null) | ||
571 | { | ||
572 | errors = new ArrayList(1); | ||
573 | errors.Add("timedout waiting for errors"); | ||
574 | } | ||
575 | break; | ||
576 | } | ||
577 | } | ||
578 | m_scriptErrors.Remove(itemId); | ||
478 | } | 579 | } |
580 | return errors; | ||
581 | } | ||
582 | |||
583 | // Signal to CreateScriptInstanceEr() that compilation/loading is complete | ||
584 | private void StoreScriptErrors(UUID itemId, ArrayList errors) | ||
585 | { | ||
586 | lock (m_scriptErrors) | ||
587 | { | ||
588 | // If compilation/loading initiated via CreateScriptInstance(), | ||
589 | // it does not want the errors, so just get out | ||
590 | if (!m_scriptErrors.ContainsKey(itemId)) | ||
591 | { | ||
592 | return; | ||
593 | } | ||
594 | |||
595 | // Initiated via CreateScriptInstanceEr(), if we know what the | ||
596 | // errors are, save them and wake CreateScriptInstanceEr(). | ||
597 | if (errors != null) | ||
598 | { | ||
599 | m_scriptErrors[itemId] = errors; | ||
600 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
601 | return; | ||
602 | } | ||
603 | } | ||
604 | |||
605 | // Initiated via CreateScriptInstanceEr() but we don't know what | ||
606 | // the errors are yet, so retrieve them from the script engine. | ||
607 | // This may involve some waiting internal to GetScriptErrors(). | ||
608 | errors = GetScriptErrors(itemId); | ||
609 | |||
610 | // Get a default non-null value to indicate success. | ||
611 | if (errors == null) | ||
612 | { | ||
613 | errors = new ArrayList(); | ||
614 | } | ||
615 | |||
616 | // Post to CreateScriptInstanceEr() and wake it up | ||
617 | lock (m_scriptErrors) | ||
618 | { | ||
619 | m_scriptErrors[itemId] = errors; | ||
620 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
621 | } | ||
622 | } | ||
623 | |||
624 | // Like StoreScriptErrors(), but just posts a single string message | ||
625 | private void StoreScriptError(UUID itemId, string message) | ||
626 | { | ||
627 | ArrayList errors = new ArrayList(1); | ||
628 | errors.Add(message); | ||
629 | StoreScriptErrors(itemId, errors); | ||
479 | } | 630 | } |
480 | 631 | ||
481 | /// <summary> | 632 | /// <summary> |
@@ -488,15 +639,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
488 | /// </param> | 639 | /// </param> |
489 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) | 640 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) |
490 | { | 641 | { |
491 | bool scriptPresent = false; | 642 | if (m_items.ContainsKey(itemId)) |
492 | |||
493 | lock (m_items) | ||
494 | { | ||
495 | if (m_items.ContainsKey(itemId)) | ||
496 | scriptPresent = true; | ||
497 | } | ||
498 | |||
499 | if (scriptPresent) | ||
500 | { | 643 | { |
501 | if (!sceneObjectBeingDeleted) | 644 | if (!sceneObjectBeingDeleted) |
502 | m_part.RemoveScriptEvents(itemId); | 645 | m_part.RemoveScriptEvents(itemId); |
@@ -566,14 +709,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
566 | /// <returns></returns> | 709 | /// <returns></returns> |
567 | private bool InventoryContainsName(string name) | 710 | private bool InventoryContainsName(string name) |
568 | { | 711 | { |
569 | lock (m_items) | 712 | m_items.LockItemsForRead(true); |
713 | foreach (TaskInventoryItem item in m_items.Values) | ||
570 | { | 714 | { |
571 | foreach (TaskInventoryItem item in m_items.Values) | 715 | if (item.Name == name) |
572 | { | 716 | { |
573 | if (item.Name == name) | 717 | m_items.LockItemsForRead(false); |
574 | return true; | 718 | return true; |
575 | } | 719 | } |
576 | } | 720 | } |
721 | m_items.LockItemsForRead(false); | ||
577 | return false; | 722 | return false; |
578 | } | 723 | } |
579 | 724 | ||
@@ -615,8 +760,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
615 | /// <param name="item"></param> | 760 | /// <param name="item"></param> |
616 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 761 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
617 | { | 762 | { |
618 | List<TaskInventoryItem> il = GetInventoryItems(); | 763 | m_items.LockItemsForRead(true); |
619 | 764 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | |
765 | m_items.LockItemsForRead(false); | ||
620 | foreach (TaskInventoryItem i in il) | 766 | foreach (TaskInventoryItem i in il) |
621 | { | 767 | { |
622 | if (i.Name == item.Name) | 768 | if (i.Name == item.Name) |
@@ -654,14 +800,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
654 | item.Name = name; | 800 | item.Name = name; |
655 | item.GroupID = m_part.GroupID; | 801 | item.GroupID = m_part.GroupID; |
656 | 802 | ||
657 | lock (m_items) | 803 | m_items.LockItemsForWrite(true); |
658 | m_items.Add(item.ItemID, item); | 804 | m_items.Add(item.ItemID, item); |
659 | 805 | m_items.LockItemsForWrite(false); | |
660 | if (allowedDrop) | 806 | if (allowedDrop) |
661 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 807 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
662 | else | 808 | else |
663 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 809 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
664 | 810 | ||
665 | m_inventorySerial++; | 811 | m_inventorySerial++; |
666 | //m_inventorySerial += 2; | 812 | //m_inventorySerial += 2; |
667 | HasInventoryChanged = true; | 813 | HasInventoryChanged = true; |
@@ -677,15 +823,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
677 | /// <param name="items"></param> | 823 | /// <param name="items"></param> |
678 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 824 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
679 | { | 825 | { |
680 | lock (m_items) | 826 | m_items.LockItemsForWrite(true); |
827 | foreach (TaskInventoryItem item in items) | ||
681 | { | 828 | { |
682 | foreach (TaskInventoryItem item in items) | 829 | m_items.Add(item.ItemID, item); |
683 | { | 830 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
684 | m_items.Add(item.ItemID, item); | ||
685 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
686 | } | ||
687 | m_inventorySerial++; | ||
688 | } | 831 | } |
832 | m_items.LockItemsForWrite(false); | ||
833 | |||
834 | m_inventorySerial++; | ||
689 | } | 835 | } |
690 | 836 | ||
691 | /// <summary> | 837 | /// <summary> |
@@ -696,23 +842,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
696 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 842 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
697 | { | 843 | { |
698 | TaskInventoryItem item; | 844 | TaskInventoryItem item; |
699 | 845 | m_items.LockItemsForRead(true); | |
700 | lock (m_items) | 846 | m_items.TryGetValue(itemId, out item); |
701 | m_items.TryGetValue(itemId, out item); | 847 | m_items.LockItemsForRead(false); |
702 | |||
703 | return item; | 848 | return item; |
704 | } | 849 | } |
705 | 850 | ||
706 | public TaskInventoryItem GetInventoryItem(string name) | 851 | public TaskInventoryItem GetInventoryItem(string name) |
707 | { | 852 | { |
708 | lock (m_items) | 853 | m_items.LockItemsForRead(true); |
854 | foreach (TaskInventoryItem item in m_items.Values) | ||
709 | { | 855 | { |
710 | foreach (TaskInventoryItem item in m_items.Values) | 856 | if (item.Name == name) |
711 | { | 857 | { |
712 | if (item.Name == name) | 858 | m_items.LockItemsForRead(false); |
713 | return item; | 859 | return item; |
714 | } | 860 | } |
715 | } | 861 | } |
862 | m_items.LockItemsForRead(false); | ||
716 | 863 | ||
717 | return null; | 864 | return null; |
718 | } | 865 | } |
@@ -721,15 +868,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
721 | { | 868 | { |
722 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 869 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
723 | 870 | ||
724 | lock (m_items) | 871 | m_items.LockItemsForRead(true); |
872 | |||
873 | foreach (TaskInventoryItem item in m_items.Values) | ||
725 | { | 874 | { |
726 | foreach (TaskInventoryItem item in m_items.Values) | 875 | if (item.Name == name) |
727 | { | 876 | items.Add(item); |
728 | if (item.Name == name) | ||
729 | items.Add(item); | ||
730 | } | ||
731 | } | 877 | } |
732 | 878 | ||
879 | m_items.LockItemsForRead(false); | ||
880 | |||
733 | return items; | 881 | return items; |
734 | } | 882 | } |
735 | 883 | ||
@@ -748,6 +896,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
748 | string xmlData = Utils.BytesToString(rezAsset.Data); | 896 | string xmlData = Utils.BytesToString(rezAsset.Data); |
749 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 897 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
750 | 898 | ||
899 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
900 | group.RootPart.AttachOffset = group.AbsolutePosition; | ||
901 | group.RootPart.AttachRotation = group.GroupRotation; | ||
902 | |||
751 | group.ResetIDs(); | 903 | group.ResetIDs(); |
752 | 904 | ||
753 | SceneObjectPart rootPart = group.GetPart(group.UUID); | 905 | SceneObjectPart rootPart = group.GetPart(group.UUID); |
@@ -822,8 +974,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
822 | 974 | ||
823 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) | 975 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) |
824 | { | 976 | { |
825 | TaskInventoryItem it = GetInventoryItem(item.ItemID); | 977 | m_items.LockItemsForWrite(true); |
826 | if (it != null) | 978 | |
979 | if (m_items.ContainsKey(item.ItemID)) | ||
827 | { | 980 | { |
828 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); | 981 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); |
829 | 982 | ||
@@ -836,14 +989,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
836 | item.GroupID = m_part.GroupID; | 989 | item.GroupID = m_part.GroupID; |
837 | 990 | ||
838 | if (item.AssetID == UUID.Zero) | 991 | if (item.AssetID == UUID.Zero) |
839 | item.AssetID = it.AssetID; | 992 | item.AssetID = m_items[item.ItemID].AssetID; |
840 | 993 | ||
841 | lock (m_items) | 994 | m_items[item.ItemID] = item; |
842 | { | 995 | m_inventorySerial++; |
843 | m_items[item.ItemID] = item; | ||
844 | m_inventorySerial++; | ||
845 | } | ||
846 | |||
847 | if (fireScriptEvents) | 996 | if (fireScriptEvents) |
848 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 997 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
849 | 998 | ||
@@ -852,7 +1001,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
852 | HasInventoryChanged = true; | 1001 | HasInventoryChanged = true; |
853 | m_part.ParentGroup.HasGroupChanged = true; | 1002 | m_part.ParentGroup.HasGroupChanged = true; |
854 | } | 1003 | } |
855 | 1004 | m_items.LockItemsForWrite(false); | |
856 | return true; | 1005 | return true; |
857 | } | 1006 | } |
858 | else | 1007 | else |
@@ -863,8 +1012,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
863 | item.ItemID, m_part.Name, m_part.UUID, | 1012 | item.ItemID, m_part.Name, m_part.UUID, |
864 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 1013 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
865 | } | 1014 | } |
866 | return false; | 1015 | m_items.LockItemsForWrite(false); |
867 | 1016 | ||
1017 | return false; | ||
868 | } | 1018 | } |
869 | 1019 | ||
870 | /// <summary> | 1020 | /// <summary> |
@@ -875,43 +1025,59 @@ namespace OpenSim.Region.Framework.Scenes | |||
875 | /// in this prim's inventory.</returns> | 1025 | /// in this prim's inventory.</returns> |
876 | public int RemoveInventoryItem(UUID itemID) | 1026 | public int RemoveInventoryItem(UUID itemID) |
877 | { | 1027 | { |
878 | TaskInventoryItem item = GetInventoryItem(itemID); | 1028 | m_items.LockItemsForRead(true); |
879 | if (item != null) | 1029 | |
1030 | if (m_items.ContainsKey(itemID)) | ||
880 | { | 1031 | { |
881 | int type = m_items[itemID].InvType; | 1032 | int type = m_items[itemID].InvType; |
1033 | m_items.LockItemsForRead(false); | ||
882 | if (type == 10) // Script | 1034 | if (type == 10) // Script |
883 | { | 1035 | { |
884 | m_part.RemoveScriptEvents(itemID); | ||
885 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 1036 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
886 | } | 1037 | } |
1038 | m_items.LockItemsForWrite(true); | ||
887 | m_items.Remove(itemID); | 1039 | m_items.Remove(itemID); |
1040 | m_items.LockItemsForWrite(false); | ||
888 | m_inventorySerial++; | 1041 | m_inventorySerial++; |
889 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 1042 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
890 | 1043 | ||
891 | HasInventoryChanged = true; | 1044 | HasInventoryChanged = true; |
892 | m_part.ParentGroup.HasGroupChanged = true; | 1045 | m_part.ParentGroup.HasGroupChanged = true; |
893 | 1046 | ||
894 | if (!ContainsScripts()) | 1047 | int scriptcount = 0; |
1048 | m_items.LockItemsForRead(true); | ||
1049 | foreach (TaskInventoryItem item in m_items.Values) | ||
1050 | { | ||
1051 | if (item.Type == 10) | ||
1052 | { | ||
1053 | scriptcount++; | ||
1054 | } | ||
1055 | } | ||
1056 | m_items.LockItemsForRead(false); | ||
1057 | |||
1058 | |||
1059 | if (scriptcount <= 0) | ||
1060 | { | ||
895 | m_part.RemFlag(PrimFlags.Scripted); | 1061 | m_part.RemFlag(PrimFlags.Scripted); |
1062 | } | ||
896 | 1063 | ||
897 | m_part.ScheduleFullUpdate(); | 1064 | m_part.ScheduleFullUpdate(); |
898 | 1065 | ||
899 | return type; | 1066 | return type; |
900 | |||
901 | } | 1067 | } |
902 | else | 1068 | else |
903 | { | 1069 | { |
1070 | m_items.LockItemsForRead(false); | ||
904 | m_log.ErrorFormat( | 1071 | m_log.ErrorFormat( |
905 | "[PRIM INVENTORY]: " + | 1072 | "[PRIM INVENTORY]: " + |
906 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 1073 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", |
907 | itemID, m_part.Name, m_part.UUID, | 1074 | itemID, m_part.Name, m_part.UUID); |
908 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
909 | } | 1075 | } |
910 | 1076 | ||
911 | return -1; | 1077 | return -1; |
912 | } | 1078 | } |
913 | 1079 | ||
914 | private bool CreateInventoryFile() | 1080 | private bool CreateInventoryFileName() |
915 | { | 1081 | { |
916 | // m_log.DebugFormat( | 1082 | // m_log.DebugFormat( |
917 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", | 1083 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", |
@@ -920,70 +1086,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
920 | if (m_inventoryFileName == String.Empty || | 1086 | if (m_inventoryFileName == String.Empty || |
921 | m_inventoryFileNameSerial < m_inventorySerial) | 1087 | m_inventoryFileNameSerial < m_inventorySerial) |
922 | { | 1088 | { |
923 | // Something changed, we need to create a new file | ||
924 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; | 1089 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; |
925 | m_inventoryFileNameSerial = m_inventorySerial; | 1090 | m_inventoryFileNameSerial = m_inventorySerial; |
926 | 1091 | ||
927 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | ||
928 | |||
929 | lock (m_items) | ||
930 | { | ||
931 | foreach (TaskInventoryItem item in m_items.Values) | ||
932 | { | ||
933 | // m_log.DebugFormat( | ||
934 | // "[PRIM INVENTORY]: Adding item {0} {1} for serial {2} on prim {3} {4} {5}", | ||
935 | // item.Name, item.ItemID, m_inventorySerial, m_part.Name, m_part.UUID, m_part.LocalId); | ||
936 | |||
937 | UUID ownerID = item.OwnerID; | ||
938 | uint everyoneMask = 0; | ||
939 | uint baseMask = item.BasePermissions; | ||
940 | uint ownerMask = item.CurrentPermissions; | ||
941 | uint groupMask = item.GroupPermissions; | ||
942 | |||
943 | invString.AddItemStart(); | ||
944 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | ||
945 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
946 | |||
947 | invString.AddPermissionsStart(); | ||
948 | |||
949 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | ||
950 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
951 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
952 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
953 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
954 | |||
955 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
956 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
957 | |||
958 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | ||
959 | |||
960 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | ||
961 | invString.AddSectionEnd(); | ||
962 | |||
963 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | ||
964 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | ||
965 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | ||
966 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
967 | |||
968 | invString.AddSaleStart(); | ||
969 | invString.AddNameValueLine("sale_type", "not"); | ||
970 | invString.AddNameValueLine("sale_price", "0"); | ||
971 | invString.AddSectionEnd(); | ||
972 | |||
973 | invString.AddNameValueLine("name", item.Name + "|"); | ||
974 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
975 | |||
976 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | ||
977 | invString.AddSectionEnd(); | ||
978 | } | ||
979 | } | ||
980 | |||
981 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | ||
982 | |||
983 | return true; | 1092 | return true; |
984 | } | 1093 | } |
985 | 1094 | ||
986 | // No need to recreate, the existing file is fine | ||
987 | return false; | 1095 | return false; |
988 | } | 1096 | } |
989 | 1097 | ||
@@ -993,43 +1101,110 @@ namespace OpenSim.Region.Framework.Scenes | |||
993 | /// <param name="xferManager"></param> | 1101 | /// <param name="xferManager"></param> |
994 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) | 1102 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) |
995 | { | 1103 | { |
996 | lock (m_items) | 1104 | bool changed = CreateInventoryFileName(); |
997 | { | ||
998 | // Don't send a inventory xfer name if there are no items. Doing so causes viewer 3 to crash when rezzing | ||
999 | // a new script if any previous deletion has left the prim inventory empty. | ||
1000 | if (m_items.Count == 0) // No inventory | ||
1001 | { | ||
1002 | // m_log.DebugFormat( | ||
1003 | // "[PRIM INVENTORY]: Not sending inventory data for part {0} {1} {2} for {3} since no items", | ||
1004 | // m_part.Name, m_part.LocalId, m_part.UUID, client.Name); | ||
1005 | 1105 | ||
1006 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | 1106 | bool includeAssets = false; |
1007 | return; | 1107 | if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) |
1008 | } | 1108 | includeAssets = true; |
1109 | |||
1110 | if (m_inventoryPrivileged != includeAssets) | ||
1111 | changed = true; | ||
1112 | |||
1113 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | ||
1114 | |||
1115 | Items.LockItemsForRead(true); | ||
1116 | |||
1117 | if (m_inventorySerial == 0) // No inventory | ||
1118 | { | ||
1119 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1120 | Items.LockItemsForRead(false); | ||
1121 | return; | ||
1122 | } | ||
1009 | 1123 | ||
1010 | CreateInventoryFile(); | 1124 | if (m_items.Count == 0) // No inventory |
1125 | { | ||
1126 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1127 | Items.LockItemsForRead(false); | ||
1128 | return; | ||
1129 | } | ||
1011 | 1130 | ||
1012 | // In principle, we should only do the rest if the inventory changed; | 1131 | if (!changed) |
1013 | // by sending m_inventorySerial to the client, it ought to know | 1132 | { |
1014 | // that nothing changed and that it doesn't need to request the file. | ||
1015 | // Unfortunately, it doesn't look like the client optimizes this; | ||
1016 | // the client seems to always come back and request the Xfer, | ||
1017 | // no matter what value m_inventorySerial has. | ||
1018 | // FIXME: Could probably be > 0 here rather than > 2 | ||
1019 | if (m_inventoryFileData.Length > 2) | 1133 | if (m_inventoryFileData.Length > 2) |
1020 | { | 1134 | { |
1021 | // Add the file for Xfer | 1135 | xferManager.AddNewFile(m_inventoryFileName, |
1022 | // m_log.DebugFormat( | 1136 | m_inventoryFileData); |
1023 | // "[PRIM INVENTORY]: Adding inventory file {0} (length {1}) for transfer on {2} {3} {4}", | 1137 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, |
1024 | // m_inventoryFileName, m_inventoryFileData.Length, m_part.Name, m_part.UUID, m_part.LocalId); | 1138 | Util.StringToBytes256(m_inventoryFileName)); |
1025 | 1139 | ||
1026 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | 1140 | Items.LockItemsForRead(false); |
1141 | return; | ||
1027 | } | 1142 | } |
1028 | |||
1029 | // Tell the client we're ready to Xfer the file | ||
1030 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
1031 | Util.StringToBytes256(m_inventoryFileName)); | ||
1032 | } | 1143 | } |
1144 | |||
1145 | m_inventoryPrivileged = includeAssets; | ||
1146 | |||
1147 | foreach (TaskInventoryItem item in m_items.Values) | ||
1148 | { | ||
1149 | UUID ownerID = item.OwnerID; | ||
1150 | uint everyoneMask = 0; | ||
1151 | uint baseMask = item.BasePermissions; | ||
1152 | uint ownerMask = item.CurrentPermissions; | ||
1153 | uint groupMask = item.GroupPermissions; | ||
1154 | |||
1155 | invString.AddItemStart(); | ||
1156 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | ||
1157 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
1158 | |||
1159 | invString.AddPermissionsStart(); | ||
1160 | |||
1161 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | ||
1162 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
1163 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
1164 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
1165 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
1166 | |||
1167 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
1168 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
1169 | |||
1170 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | ||
1171 | |||
1172 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | ||
1173 | invString.AddSectionEnd(); | ||
1174 | |||
1175 | if (includeAssets) | ||
1176 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | ||
1177 | else | ||
1178 | invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); | ||
1179 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | ||
1180 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | ||
1181 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
1182 | |||
1183 | invString.AddSaleStart(); | ||
1184 | invString.AddNameValueLine("sale_type", "not"); | ||
1185 | invString.AddNameValueLine("sale_price", "0"); | ||
1186 | invString.AddSectionEnd(); | ||
1187 | |||
1188 | invString.AddNameValueLine("name", item.Name + "|"); | ||
1189 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
1190 | |||
1191 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | ||
1192 | invString.AddSectionEnd(); | ||
1193 | } | ||
1194 | |||
1195 | Items.LockItemsForRead(false); | ||
1196 | |||
1197 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | ||
1198 | |||
1199 | if (m_inventoryFileData.Length > 2) | ||
1200 | { | ||
1201 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | ||
1202 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
1203 | Util.StringToBytes256(m_inventoryFileName)); | ||
1204 | return; | ||
1205 | } | ||
1206 | |||
1207 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1033 | } | 1208 | } |
1034 | 1209 | ||
1035 | /// <summary> | 1210 | /// <summary> |
@@ -1038,13 +1213,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1038 | /// <param name="datastore"></param> | 1213 | /// <param name="datastore"></param> |
1039 | public void ProcessInventoryBackup(ISimulationDataService datastore) | 1214 | public void ProcessInventoryBackup(ISimulationDataService datastore) |
1040 | { | 1215 | { |
1041 | if (HasInventoryChanged) | 1216 | // Removed this because linking will cause an immediate delete of the new |
1042 | { | 1217 | // child prim from the database and the subsequent storing of the prim sees |
1043 | HasInventoryChanged = false; | 1218 | // the inventory of it as unchanged and doesn't store it at all. The overhead |
1044 | List<TaskInventoryItem> items = GetInventoryItems(); | 1219 | // of storing prim inventory needlessly is much less than the aggravation |
1045 | datastore.StorePrimInventory(m_part.UUID, items); | 1220 | // of prim inventory loss. |
1221 | // if (HasInventoryChanged) | ||
1222 | // { | ||
1223 | Items.LockItemsForRead(true); | ||
1224 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | ||
1225 | Items.LockItemsForRead(false); | ||
1046 | 1226 | ||
1047 | } | 1227 | HasInventoryChanged = false; |
1228 | // } | ||
1048 | } | 1229 | } |
1049 | 1230 | ||
1050 | public class InventoryStringBuilder | 1231 | public class InventoryStringBuilder |
@@ -1110,87 +1291,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
1110 | { | 1291 | { |
1111 | uint mask=0x7fffffff; | 1292 | uint mask=0x7fffffff; |
1112 | 1293 | ||
1113 | lock (m_items) | 1294 | foreach (TaskInventoryItem item in m_items.Values) |
1114 | { | 1295 | { |
1115 | foreach (TaskInventoryItem item in m_items.Values) | 1296 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) |
1297 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1298 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1299 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1300 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1301 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1302 | |||
1303 | if (item.InvType == (int)InventoryType.Object) | ||
1116 | { | 1304 | { |
1117 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | 1305 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1118 | mask &= ~((uint)PermissionMask.Copy >> 13); | 1306 | mask &= ~((uint)PermissionMask.Copy >> 13); |
1119 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | 1307 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1120 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1308 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
1121 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | 1309 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1122 | mask &= ~((uint)PermissionMask.Modify >> 13); | 1310 | mask &= ~((uint)PermissionMask.Modify >> 13); |
1123 | |||
1124 | if (item.InvType != (int)InventoryType.Object) | ||
1125 | { | ||
1126 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | ||
1127 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1128 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1129 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1130 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1131 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1132 | } | ||
1133 | else | ||
1134 | { | ||
1135 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1136 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1137 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1138 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1139 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1140 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1141 | } | ||
1142 | |||
1143 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1144 | mask &= ~(uint)PermissionMask.Copy; | ||
1145 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1146 | mask &= ~(uint)PermissionMask.Transfer; | ||
1147 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1148 | mask &= ~(uint)PermissionMask.Modify; | ||
1149 | } | 1311 | } |
1312 | |||
1313 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1314 | mask &= ~(uint)PermissionMask.Copy; | ||
1315 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1316 | mask &= ~(uint)PermissionMask.Transfer; | ||
1317 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1318 | mask &= ~(uint)PermissionMask.Modify; | ||
1150 | } | 1319 | } |
1151 | |||
1152 | return mask; | 1320 | return mask; |
1153 | } | 1321 | } |
1154 | 1322 | ||
1155 | public void ApplyNextOwnerPermissions() | 1323 | public void ApplyNextOwnerPermissions() |
1156 | { | 1324 | { |
1157 | lock (m_items) | 1325 | foreach (TaskInventoryItem item in m_items.Values) |
1158 | { | 1326 | { |
1159 | foreach (TaskInventoryItem item in m_items.Values) | 1327 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) |
1160 | { | 1328 | { |
1161 | // m_log.DebugFormat ( | 1329 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1162 | // "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", | 1330 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |
1163 | // item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); | 1331 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1164 | 1332 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | |
1165 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) | 1333 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1166 | { | 1334 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
1167 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1168 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | ||
1169 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1170 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | ||
1171 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1172 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | ||
1173 | } | ||
1174 | |||
1175 | item.CurrentPermissions &= item.NextPermissions; | ||
1176 | item.BasePermissions &= item.NextPermissions; | ||
1177 | item.EveryonePermissions &= item.NextPermissions; | ||
1178 | item.OwnerChanged = true; | ||
1179 | item.PermsMask = 0; | ||
1180 | item.PermsGranter = UUID.Zero; | ||
1181 | } | 1335 | } |
1336 | item.CurrentPermissions &= item.NextPermissions; | ||
1337 | item.BasePermissions &= item.NextPermissions; | ||
1338 | item.EveryonePermissions &= item.NextPermissions; | ||
1339 | item.OwnerChanged = true; | ||
1340 | item.PermsMask = 0; | ||
1341 | item.PermsGranter = UUID.Zero; | ||
1182 | } | 1342 | } |
1183 | } | 1343 | } |
1184 | 1344 | ||
1185 | public void ApplyGodPermissions(uint perms) | 1345 | public void ApplyGodPermissions(uint perms) |
1186 | { | 1346 | { |
1187 | lock (m_items) | 1347 | foreach (TaskInventoryItem item in m_items.Values) |
1188 | { | 1348 | { |
1189 | foreach (TaskInventoryItem item in m_items.Values) | 1349 | item.CurrentPermissions = perms; |
1190 | { | 1350 | item.BasePermissions = perms; |
1191 | item.CurrentPermissions = perms; | ||
1192 | item.BasePermissions = perms; | ||
1193 | } | ||
1194 | } | 1351 | } |
1195 | 1352 | ||
1196 | m_inventorySerial++; | 1353 | m_inventorySerial++; |
@@ -1203,14 +1360,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1203 | /// <returns></returns> | 1360 | /// <returns></returns> |
1204 | public bool ContainsScripts() | 1361 | public bool ContainsScripts() |
1205 | { | 1362 | { |
1206 | lock (m_items) | 1363 | foreach (TaskInventoryItem item in m_items.Values) |
1207 | { | 1364 | { |
1208 | foreach (TaskInventoryItem item in m_items.Values) | 1365 | if (item.InvType == (int)InventoryType.LSL) |
1209 | { | 1366 | { |
1210 | if (item.InvType == (int)InventoryType.LSL) | 1367 | return true; |
1211 | { | ||
1212 | return true; | ||
1213 | } | ||
1214 | } | 1368 | } |
1215 | } | 1369 | } |
1216 | 1370 | ||
@@ -1224,17 +1378,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1224 | public int ScriptCount() | 1378 | public int ScriptCount() |
1225 | { | 1379 | { |
1226 | int count = 0; | 1380 | int count = 0; |
1227 | lock (m_items) | 1381 | Items.LockItemsForRead(true); |
1382 | foreach (TaskInventoryItem item in m_items.Values) | ||
1228 | { | 1383 | { |
1229 | foreach (TaskInventoryItem item in m_items.Values) | 1384 | if (item.InvType == (int)InventoryType.LSL) |
1230 | { | 1385 | { |
1231 | if (item.InvType == (int)InventoryType.LSL) | 1386 | count++; |
1232 | { | ||
1233 | count++; | ||
1234 | } | ||
1235 | } | 1387 | } |
1236 | } | 1388 | } |
1237 | 1389 | Items.LockItemsForRead(false); | |
1238 | return count; | 1390 | return count; |
1239 | } | 1391 | } |
1240 | /// <summary> | 1392 | /// <summary> |
@@ -1270,11 +1422,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1270 | { | 1422 | { |
1271 | List<UUID> ret = new List<UUID>(); | 1423 | List<UUID> ret = new List<UUID>(); |
1272 | 1424 | ||
1273 | lock (m_items) | 1425 | foreach (TaskInventoryItem item in m_items.Values) |
1274 | { | 1426 | ret.Add(item.ItemID); |
1275 | foreach (TaskInventoryItem item in m_items.Values) | ||
1276 | ret.Add(item.ItemID); | ||
1277 | } | ||
1278 | 1427 | ||
1279 | return ret; | 1428 | return ret; |
1280 | } | 1429 | } |
@@ -1283,8 +1432,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1283 | { | 1432 | { |
1284 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1433 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1285 | 1434 | ||
1286 | lock (m_items) | 1435 | Items.LockItemsForRead(true); |
1287 | ret = new List<TaskInventoryItem>(m_items.Values); | 1436 | ret = new List<TaskInventoryItem>(m_items.Values); |
1437 | Items.LockItemsForRead(false); | ||
1288 | 1438 | ||
1289 | return ret; | 1439 | return ret; |
1290 | } | 1440 | } |
@@ -1293,18 +1443,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1293 | { | 1443 | { |
1294 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1444 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1295 | 1445 | ||
1296 | lock (m_items) | 1446 | Items.LockItemsForRead(true); |
1297 | { | 1447 | |
1298 | foreach (TaskInventoryItem item in m_items.Values) | 1448 | foreach (TaskInventoryItem item in m_items.Values) |
1299 | if (item.InvType == (int)type) | 1449 | if (item.InvType == (int)type) |
1300 | ret.Add(item); | 1450 | ret.Add(item); |
1301 | } | 1451 | |
1452 | Items.LockItemsForRead(false); | ||
1302 | 1453 | ||
1303 | return ret; | 1454 | return ret; |
1304 | } | 1455 | } |
1305 | 1456 | ||
1306 | public Dictionary<UUID, string> GetScriptStates() | 1457 | public Dictionary<UUID, string> GetScriptStates() |
1307 | { | 1458 | { |
1459 | return GetScriptStates(false); | ||
1460 | } | ||
1461 | |||
1462 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1463 | { | ||
1308 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1464 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
1309 | 1465 | ||
1310 | if (m_part.ParentGroup.Scene == null) // Group not in a scene | 1466 | if (m_part.ParentGroup.Scene == null) // Group not in a scene |
@@ -1330,14 +1486,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1330 | string n = e.GetXMLState(item.ItemID); | 1486 | string n = e.GetXMLState(item.ItemID); |
1331 | if (n != String.Empty) | 1487 | if (n != String.Empty) |
1332 | { | 1488 | { |
1333 | if (!ret.ContainsKey(item.ItemID)) | 1489 | if (oldIDs) |
1334 | ret[item.ItemID] = n; | 1490 | { |
1491 | if (!ret.ContainsKey(item.OldItemID)) | ||
1492 | ret[item.OldItemID] = n; | ||
1493 | } | ||
1494 | else | ||
1495 | { | ||
1496 | if (!ret.ContainsKey(item.ItemID)) | ||
1497 | ret[item.ItemID] = n; | ||
1498 | } | ||
1335 | break; | 1499 | break; |
1336 | } | 1500 | } |
1337 | } | 1501 | } |
1338 | } | 1502 | } |
1339 | } | 1503 | } |
1340 | |||
1341 | return ret; | 1504 | return ret; |
1342 | } | 1505 | } |
1343 | 1506 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index bab14dd..1859cb1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -63,6 +63,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
63 | 63 | ||
64 | struct ScriptControllers | 64 | struct ScriptControllers |
65 | { | 65 | { |
66 | public UUID objectID; | ||
66 | public UUID itemID; | 67 | public UUID itemID; |
67 | public ScriptControlled ignoreControls; | 68 | public ScriptControlled ignoreControls; |
68 | public ScriptControlled eventControls; | 69 | public ScriptControlled eventControls; |
@@ -99,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
99 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | 100 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis |
100 | /// issue #1716 | 101 | /// issue #1716 |
101 | /// </summary> | 102 | /// </summary> |
102 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.418f); | 103 | public static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.0f, 0.0f, 0.4f); |
103 | 104 | ||
104 | /// <summary> | 105 | /// <summary> |
105 | /// Movement updates for agents in neighboring regions are sent directly to clients. | 106 | /// Movement updates for agents in neighboring regions are sent directly to clients. |
@@ -121,8 +122,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
121 | /// <remarks> | 122 | /// <remarks> |
122 | /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is | 123 | /// TODO: For some reason, we effectively have a list both here and in Appearance. Need to work out if this is |
123 | /// necessary. | 124 | /// necessary. |
124 | /// NOTE: To avoid deadlocks, do not lock m_attachments and then perform other tasks under that lock. Take a copy | ||
125 | /// of the list and act on that instead. | ||
126 | /// </remarks> | 125 | /// </remarks> |
127 | private List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); | 126 | private List<SceneObjectGroup> m_attachments = new List<SceneObjectGroup>(); |
128 | 127 | ||
@@ -141,6 +140,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
141 | private Vector3 m_lastPosition; | 140 | private Vector3 m_lastPosition; |
142 | private Quaternion m_lastRotation; | 141 | private Quaternion m_lastRotation; |
143 | private Vector3 m_lastVelocity; | 142 | private Vector3 m_lastVelocity; |
143 | private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); | ||
144 | |||
144 | 145 | ||
145 | private Vector3? m_forceToApply; | 146 | private Vector3? m_forceToApply; |
146 | private int m_userFlags; | 147 | private int m_userFlags; |
@@ -173,6 +174,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
173 | // private int m_lastColCount = -1; //KF: Look for Collision chnages | 174 | // private int m_lastColCount = -1; //KF: Look for Collision chnages |
174 | // private int m_updateCount = 0; //KF: Update Anims for a while | 175 | // private int m_updateCount = 0; //KF: Update Anims for a while |
175 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 176 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
177 | private List<uint> m_lastColliders = new List<uint>(); | ||
176 | 178 | ||
177 | private TeleportFlags m_teleportFlags; | 179 | private TeleportFlags m_teleportFlags; |
178 | public TeleportFlags TeleportFlags | 180 | public TeleportFlags TeleportFlags |
@@ -228,8 +230,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
228 | /// </summary> | 230 | /// </summary> |
229 | public bool LandAtTarget { get; private set; } | 231 | public bool LandAtTarget { get; private set; } |
230 | 232 | ||
231 | private bool m_followCamAuto; | ||
232 | |||
233 | private int m_movementUpdateCount; | 233 | private int m_movementUpdateCount; |
234 | private const int NumMovementsBetweenRayCast = 5; | 234 | private const int NumMovementsBetweenRayCast = 5; |
235 | 235 | ||
@@ -237,6 +237,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
237 | //private int m_moveToPositionStateStatus; | 237 | //private int m_moveToPositionStateStatus; |
238 | //***************************************************** | 238 | //***************************************************** |
239 | 239 | ||
240 | private bool m_collisionEventFlag = false; | ||
241 | private object m_collisionEventLock = new Object(); | ||
242 | |||
243 | private int m_movementAnimationUpdateCounter = 0; | ||
244 | |||
245 | private Vector3 m_prevSitOffset; | ||
246 | |||
240 | protected AvatarAppearance m_appearance; | 247 | protected AvatarAppearance m_appearance; |
241 | 248 | ||
242 | public AvatarAppearance Appearance | 249 | public AvatarAppearance Appearance |
@@ -351,6 +358,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
351 | /// </summary> | 358 | /// </summary> |
352 | protected Vector3 m_lastCameraPosition; | 359 | protected Vector3 m_lastCameraPosition; |
353 | 360 | ||
361 | private Vector4 m_lastCameraCollisionPlane = new Vector4(0f, 0f, 0f, 1); | ||
362 | private bool m_doingCamRayCast = false; | ||
363 | |||
354 | public Vector3 CameraPosition { get; set; } | 364 | public Vector3 CameraPosition { get; set; } |
355 | 365 | ||
356 | public Quaternion CameraRotation | 366 | public Quaternion CameraRotation |
@@ -431,7 +441,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
431 | get { return (IClientCore)ControllingClient; } | 441 | get { return (IClientCore)ControllingClient; } |
432 | } | 442 | } |
433 | 443 | ||
434 | public Vector3 ParentPosition { get; set; } | 444 | public UUID COF { get; set; } |
445 | |||
446 | // public Vector3 ParentPosition { get; set; } | ||
435 | 447 | ||
436 | /// <summary> | 448 | /// <summary> |
437 | /// Position of this avatar relative to the region the avatar is in | 449 | /// Position of this avatar relative to the region the avatar is in |
@@ -492,7 +504,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
492 | if (ParentID == 0) | 504 | if (ParentID == 0) |
493 | { | 505 | { |
494 | m_pos = value; | 506 | m_pos = value; |
495 | ParentPosition = Vector3.Zero; | 507 | // ParentPosition = Vector3.Zero; |
496 | } | 508 | } |
497 | 509 | ||
498 | //m_log.DebugFormat( | 510 | //m_log.DebugFormat( |
@@ -561,7 +573,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
561 | // Scene.RegionInfo.RegionName, Name, m_velocity); | 573 | // Scene.RegionInfo.RegionName, Name, m_velocity); |
562 | } | 574 | } |
563 | } | 575 | } |
576 | /* | ||
577 | public override Vector3 AngularVelocity | ||
578 | { | ||
579 | get | ||
580 | { | ||
581 | if (PhysicsActor != null) | ||
582 | { | ||
583 | m_rotationalvelocity = PhysicsActor.RotationalVelocity; | ||
564 | 584 | ||
585 | // m_log.DebugFormat( | ||
586 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", | ||
587 | // m_velocity, Name, Scene.RegionInfo.RegionName); | ||
588 | } | ||
589 | |||
590 | return m_rotationalvelocity; | ||
591 | } | ||
592 | } | ||
593 | */ | ||
565 | private Quaternion m_bodyRot = Quaternion.Identity; | 594 | private Quaternion m_bodyRot = Quaternion.Identity; |
566 | 595 | ||
567 | /// <summary> | 596 | /// <summary> |
@@ -584,8 +613,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
584 | m_bodyRot = value; | 613 | m_bodyRot = value; |
585 | 614 | ||
586 | if (PhysicsActor != null) | 615 | if (PhysicsActor != null) |
587 | PhysicsActor.Orientation = m_bodyRot; | 616 | { |
588 | 617 | try | |
618 | { | ||
619 | PhysicsActor.Orientation = m_bodyRot; | ||
620 | } | ||
621 | catch (Exception e) | ||
622 | { | ||
623 | m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); | ||
624 | } | ||
625 | } | ||
589 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | 626 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); |
590 | } | 627 | } |
591 | } | 628 | } |
@@ -599,12 +636,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
599 | } | 636 | } |
600 | 637 | ||
601 | public bool IsChildAgent { get; set; } | 638 | public bool IsChildAgent { get; set; } |
639 | public bool IsLoggingIn { get; set; } | ||
602 | 640 | ||
603 | /// <summary> | 641 | /// <summary> |
604 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. | 642 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. |
605 | /// </summary> | 643 | /// </summary> |
606 | public uint ParentID { get; set; } | 644 | public uint ParentID { get; set; } |
607 | 645 | ||
646 | public UUID ParentUUID | ||
647 | { | ||
648 | get { return m_parentUUID; } | ||
649 | set { m_parentUUID = value; } | ||
650 | } | ||
651 | private UUID m_parentUUID = UUID.Zero; | ||
652 | |||
608 | /// <summary> | 653 | /// <summary> |
609 | /// Are we sitting on an object? | 654 | /// Are we sitting on an object? |
610 | /// </summary> | 655 | /// </summary> |
@@ -754,6 +799,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
754 | AttachmentsSyncLock = new Object(); | 799 | AttachmentsSyncLock = new Object(); |
755 | AllowMovement = true; | 800 | AllowMovement = true; |
756 | IsChildAgent = true; | 801 | IsChildAgent = true; |
802 | IsLoggingIn = false; | ||
757 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; | 803 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; |
758 | Animator = new ScenePresenceAnimator(this); | 804 | Animator = new ScenePresenceAnimator(this); |
759 | PresenceType = type; | 805 | PresenceType = type; |
@@ -797,6 +843,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
797 | Appearance = appearance; | 843 | Appearance = appearance; |
798 | } | 844 | } |
799 | 845 | ||
846 | private void RegionHeartbeatEnd(Scene scene) | ||
847 | { | ||
848 | if (IsChildAgent) | ||
849 | return; | ||
850 | |||
851 | m_movementAnimationUpdateCounter ++; | ||
852 | if (m_movementAnimationUpdateCounter >= 2) | ||
853 | { | ||
854 | m_movementAnimationUpdateCounter = 0; | ||
855 | if (Animator != null) | ||
856 | { | ||
857 | // If the parentID == 0 we are not sitting | ||
858 | // if !SitGournd then we are not sitting on the ground | ||
859 | // Fairly straightforward, now here comes the twist | ||
860 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
861 | // be sat on an object that isn't there yet. Should | ||
862 | // be treated as if sat. | ||
863 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
864 | Animator.UpdateMovementAnimations(); | ||
865 | } | ||
866 | else | ||
867 | { | ||
868 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
869 | } | ||
870 | } | ||
871 | } | ||
872 | |||
800 | public void RegisterToEvents() | 873 | public void RegisterToEvents() |
801 | { | 874 | { |
802 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 875 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -806,8 +879,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
806 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 879 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
807 | ControllingClient.OnStartAnim += HandleStartAnim; | 880 | ControllingClient.OnStartAnim += HandleStartAnim; |
808 | ControllingClient.OnStopAnim += HandleStopAnim; | 881 | ControllingClient.OnStopAnim += HandleStopAnim; |
882 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
809 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 883 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
810 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 884 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
885 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
811 | 886 | ||
812 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 887 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
813 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 888 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -866,6 +941,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
866 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 941 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
867 | Name, m_scene.RegionInfo.RegionName); | 942 | Name, m_scene.RegionInfo.RegionName); |
868 | 943 | ||
944 | if (ParentUUID != UUID.Zero) | ||
945 | { | ||
946 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
947 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
948 | if (part == null) | ||
949 | { | ||
950 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
951 | } | ||
952 | else | ||
953 | { | ||
954 | part.ParentGroup.AddAvatar(UUID); | ||
955 | if (part.SitTargetPosition != Vector3.Zero) | ||
956 | part.SitTargetAvatar = UUID; | ||
957 | // ParentPosition = part.GetWorldPosition(); | ||
958 | ParentID = part.LocalId; | ||
959 | ParentPart = part; | ||
960 | m_pos = m_prevSitOffset; | ||
961 | // pos = ParentPosition; | ||
962 | pos = part.GetWorldPosition(); | ||
963 | } | ||
964 | ParentUUID = UUID.Zero; | ||
965 | |||
966 | IsChildAgent = false; | ||
967 | |||
968 | // Animator.TrySetMovementAnimation("SIT"); | ||
969 | } | ||
970 | else | ||
971 | { | ||
972 | IsChildAgent = false; | ||
973 | IsLoggingIn = false; | ||
974 | } | ||
975 | |||
869 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | 976 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); |
870 | 977 | ||
871 | IsChildAgent = false; | 978 | IsChildAgent = false; |
@@ -878,70 +985,106 @@ namespace OpenSim.Region.Framework.Scenes | |||
878 | 985 | ||
879 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 986 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
880 | 987 | ||
881 | // Moved this from SendInitialData to ensure that Appearance is initialized | 988 | UUID groupUUID = UUID.Zero; |
882 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | 989 | string GroupName = string.Empty; |
883 | // related to the handling of attachments | 990 | ulong groupPowers = 0; |
884 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
885 | 991 | ||
886 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | 992 | // ---------------------------------- |
993 | // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status | ||
994 | try | ||
887 | { | 995 | { |
888 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 996 | if (gm != null) |
889 | pos.X = crossedBorder.BorderLine.Z - 1; | 997 | { |
998 | groupUUID = ControllingClient.ActiveGroupId; | ||
999 | GroupRecord record = gm.GetGroupRecord(groupUUID); | ||
1000 | if (record != null) | ||
1001 | GroupName = record.GroupName; | ||
1002 | GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); | ||
1003 | if (groupMembershipData != null) | ||
1004 | groupPowers = groupMembershipData.GroupPowers; | ||
1005 | } | ||
1006 | ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, | ||
1007 | Grouptitle); | ||
890 | } | 1008 | } |
891 | 1009 | catch (Exception e) | |
892 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | ||
893 | { | 1010 | { |
894 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 1011 | m_log.Debug("[AGENTUPDATE]: " + e.ToString()); |
895 | pos.Y = crossedBorder.BorderLine.Z - 1; | ||
896 | } | 1012 | } |
1013 | // ------------------------------------ | ||
897 | 1014 | ||
898 | CheckAndAdjustLandingPoint(ref pos); | 1015 | if (ParentID == 0) |
899 | |||
900 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | ||
901 | { | 1016 | { |
902 | m_log.WarnFormat( | 1017 | // Moved this from SendInitialData to ensure that Appearance is initialized |
903 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 1018 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
904 | pos, Name, UUID); | 1019 | // related to the handling of attachments |
1020 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
1021 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
1022 | { | ||
1023 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
1024 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
1025 | } | ||
905 | 1026 | ||
906 | if (pos.X < 0f) pos.X = 0f; | 1027 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
907 | if (pos.Y < 0f) pos.Y = 0f; | 1028 | { |
908 | if (pos.Z < 0f) pos.Z = 0f; | 1029 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
909 | } | 1030 | pos.Y = crossedBorder.BorderLine.Z - 1; |
1031 | } | ||
910 | 1032 | ||
911 | float localAVHeight = 1.56f; | 1033 | CheckAndAdjustLandingPoint(ref pos); |
912 | if (Appearance.AvatarHeight > 0) | ||
913 | localAVHeight = Appearance.AvatarHeight; | ||
914 | 1034 | ||
915 | float posZLimit = 0; | 1035 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
1036 | { | ||
1037 | m_log.WarnFormat( | ||
1038 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | ||
1039 | pos, Name, UUID); | ||
916 | 1040 | ||
917 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 1041 | if (pos.X < 0f) pos.X = 0f; |
918 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 1042 | if (pos.Y < 0f) pos.Y = 0f; |
919 | 1043 | if (pos.Z < 0f) pos.Z = 0f; | |
920 | float newPosZ = posZLimit + localAVHeight / 2; | 1044 | } |
921 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
922 | { | ||
923 | pos.Z = newPosZ; | ||
924 | } | ||
925 | AbsolutePosition = pos; | ||
926 | 1045 | ||
927 | AddToPhysicalScene(isFlying); | 1046 | float localAVHeight = 1.56f; |
1047 | if (Appearance.AvatarHeight > 0) | ||
1048 | localAVHeight = Appearance.AvatarHeight; | ||
928 | 1049 | ||
929 | // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a | 1050 | float posZLimit = 0; |
930 | // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it | ||
931 | // since it requires a physics actor to be present. If it is left any later, then physics appears to reset | ||
932 | // the value to a negative position which does not trigger the border cross. | ||
933 | // This may not be the best location for this. | ||
934 | CheckForBorderCrossing(); | ||
935 | 1051 | ||
936 | if (ForceFly) | 1052 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
937 | { | 1053 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
938 | Flying = true; | 1054 | |
939 | } | 1055 | float newPosZ = posZLimit + localAVHeight / 2; |
940 | else if (FlyDisabled) | 1056 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
941 | { | 1057 | { |
942 | Flying = false; | 1058 | pos.Z = newPosZ; |
943 | } | 1059 | } |
1060 | AbsolutePosition = pos; | ||
1061 | |||
1062 | if (m_teleportFlags == TeleportFlags.Default) | ||
1063 | { | ||
1064 | Vector3 vel = Velocity; | ||
1065 | AddToPhysicalScene(isFlying); | ||
1066 | if (PhysicsActor != null) | ||
1067 | PhysicsActor.SetMomentum(vel); | ||
1068 | } | ||
1069 | else | ||
1070 | AddToPhysicalScene(isFlying); | ||
944 | 1071 | ||
1072 | // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a | ||
1073 | // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it | ||
1074 | // since it requires a physics actor to be present. If it is left any later, then physics appears to reset | ||
1075 | // the value to a negative position which does not trigger the border cross. | ||
1076 | // This may not be the best location for this. | ||
1077 | CheckForBorderCrossing(); | ||
1078 | |||
1079 | if (ForceFly) | ||
1080 | { | ||
1081 | Flying = true; | ||
1082 | } | ||
1083 | else if (FlyDisabled) | ||
1084 | { | ||
1085 | Flying = false; | ||
1086 | } | ||
1087 | } | ||
945 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 1088 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
946 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 1089 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
947 | // elsewhere anyway | 1090 | // elsewhere anyway |
@@ -973,31 +1116,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
973 | // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently | 1116 | // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently |
974 | // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are | 1117 | // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are |
975 | // not transporting the required data. | 1118 | // not transporting the required data. |
976 | // | 1119 | lock (m_attachments) |
977 | // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of | ||
978 | // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here | ||
979 | // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status. | ||
980 | // | ||
981 | // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts(). | ||
982 | // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing | ||
983 | // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the | ||
984 | // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine. | ||
985 | List<SceneObjectGroup> attachments = GetAttachments(); | ||
986 | |||
987 | if (attachments.Count > 0) | ||
988 | { | 1120 | { |
989 | m_log.DebugFormat( | 1121 | if (HasAttachments()) |
990 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | ||
991 | |||
992 | // Resume scripts | ||
993 | foreach (SceneObjectGroup sog in attachments) | ||
994 | { | 1122 | { |
995 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 1123 | m_log.DebugFormat( |
996 | sog.ResumeScripts(); | 1124 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); |
1125 | |||
1126 | // Resume scripts | ||
1127 | Util.FireAndForget(delegate(object x) { | ||
1128 | foreach (SceneObjectGroup sog in m_attachments) | ||
1129 | { | ||
1130 | sog.ScheduleGroupForFullUpdate(); | ||
1131 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | ||
1132 | sog.ResumeScripts(); | ||
1133 | } | ||
1134 | }); | ||
997 | } | 1135 | } |
998 | } | 1136 | } |
999 | } | 1137 | } |
1000 | 1138 | ||
1139 | SendAvatarDataToAllAgents(); | ||
1140 | |||
1001 | // send the animations of the other presences to me | 1141 | // send the animations of the other presences to me |
1002 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 1142 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
1003 | { | 1143 | { |
@@ -1008,9 +1148,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1008 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1148 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
1009 | // stall on the border crossing since the existing child agent will still have the last movement | 1149 | // stall on the border crossing since the existing child agent will still have the last movement |
1010 | // recorded, which stops the input from being processed. | 1150 | // recorded, which stops the input from being processed. |
1151 | |||
1011 | MovementFlag = 0; | 1152 | MovementFlag = 0; |
1012 | 1153 | ||
1013 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1154 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1155 | |||
1156 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
1014 | } | 1157 | } |
1015 | 1158 | ||
1016 | public int GetStateSource() | 1159 | public int GetStateSource() |
@@ -1038,12 +1181,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1038 | /// </remarks> | 1181 | /// </remarks> |
1039 | public void MakeChildAgent() | 1182 | public void MakeChildAgent() |
1040 | { | 1183 | { |
1184 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1185 | |||
1041 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1186 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
1042 | 1187 | ||
1043 | // Reset these so that teleporting in and walking out isn't seen | 1188 | // Reset these so that teleporting in and walking out isn't seen |
1044 | // as teleporting back | 1189 | // as teleporting back |
1045 | TeleportFlags = TeleportFlags.Default; | 1190 | TeleportFlags = TeleportFlags.Default; |
1046 | 1191 | ||
1192 | MovementFlag = 0; | ||
1193 | |||
1047 | // It looks like Animator is set to null somewhere, and MakeChild | 1194 | // It looks like Animator is set to null somewhere, and MakeChild |
1048 | // is called after that. Probably in aborted teleports. | 1195 | // is called after that. Probably in aborted teleports. |
1049 | if (Animator == null) | 1196 | if (Animator == null) |
@@ -1051,6 +1198,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1051 | else | 1198 | else |
1052 | Animator.ResetAnimations(); | 1199 | Animator.ResetAnimations(); |
1053 | 1200 | ||
1201 | |||
1054 | // m_log.DebugFormat( | 1202 | // m_log.DebugFormat( |
1055 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1203 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
1056 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1204 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -1062,6 +1210,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1062 | IsChildAgent = true; | 1210 | IsChildAgent = true; |
1063 | m_scene.SwapRootAgentCount(true); | 1211 | m_scene.SwapRootAgentCount(true); |
1064 | RemoveFromPhysicalScene(); | 1212 | RemoveFromPhysicalScene(); |
1213 | ParentID = 0; // Child agents can't be sitting | ||
1065 | 1214 | ||
1066 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1215 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
1067 | 1216 | ||
@@ -1077,9 +1226,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1077 | { | 1226 | { |
1078 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1227 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
1079 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1228 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
1080 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1081 | PhysicsActor.UnSubscribeEvents(); | ||
1082 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1229 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1230 | PhysicsActor.UnSubscribeEvents(); | ||
1231 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1083 | PhysicsActor = null; | 1232 | PhysicsActor = null; |
1084 | } | 1233 | } |
1085 | // else | 1234 | // else |
@@ -1096,7 +1245,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1096 | /// <param name="pos"></param> | 1245 | /// <param name="pos"></param> |
1097 | public void Teleport(Vector3 pos) | 1246 | public void Teleport(Vector3 pos) |
1098 | { | 1247 | { |
1099 | TeleportWithMomentum(pos, null); | 1248 | TeleportWithMomentum(pos, Vector3.Zero); |
1100 | } | 1249 | } |
1101 | 1250 | ||
1102 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1251 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1120,6 +1269,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1120 | SendTerseUpdateToAllClients(); | 1269 | SendTerseUpdateToAllClients(); |
1121 | } | 1270 | } |
1122 | 1271 | ||
1272 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1273 | { | ||
1274 | CheckLandingPoint(ref newpos); | ||
1275 | AbsolutePosition = newpos; | ||
1276 | |||
1277 | if (newvel.HasValue) | ||
1278 | { | ||
1279 | if ((Vector3)newvel == Vector3.Zero) | ||
1280 | { | ||
1281 | if (PhysicsActor != null) | ||
1282 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1283 | m_velocity = Vector3.Zero; | ||
1284 | } | ||
1285 | else | ||
1286 | { | ||
1287 | if (PhysicsActor != null) | ||
1288 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1289 | m_velocity = (Vector3)newvel; | ||
1290 | |||
1291 | if (rotateToVelXY) | ||
1292 | { | ||
1293 | Vector3 lookAt = (Vector3)newvel; | ||
1294 | lookAt.Z = 0; | ||
1295 | lookAt.Normalize(); | ||
1296 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1297 | return; | ||
1298 | } | ||
1299 | } | ||
1300 | } | ||
1301 | |||
1302 | SendTerseUpdateToAllClients(); | ||
1303 | } | ||
1304 | |||
1305 | |||
1306 | |||
1123 | public void StopFlying() | 1307 | public void StopFlying() |
1124 | { | 1308 | { |
1125 | ControllingClient.StopFlying(this); | 1309 | ControllingClient.StopFlying(this); |
@@ -1289,6 +1473,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1289 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); | 1473 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); |
1290 | } | 1474 | } |
1291 | 1475 | ||
1476 | public void SetSize(Vector3 size, float feetoffset) | ||
1477 | { | ||
1478 | if (PhysicsActor != null && !IsChildAgent) | ||
1479 | PhysicsActor.setAvatarSize(size, feetoffset); | ||
1480 | |||
1481 | } | ||
1482 | |||
1292 | /// <summary> | 1483 | /// <summary> |
1293 | /// Complete Avatar's movement into the region. | 1484 | /// Complete Avatar's movement into the region. |
1294 | /// </summary> | 1485 | /// </summary> |
@@ -1308,7 +1499,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1308 | 1499 | ||
1309 | Vector3 look = Velocity; | 1500 | Vector3 look = Velocity; |
1310 | 1501 | ||
1311 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1502 | // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1503 | if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) | ||
1312 | { | 1504 | { |
1313 | look = new Vector3(0.99f, 0.042f, 0); | 1505 | look = new Vector3(0.99f, 0.042f, 0); |
1314 | } | 1506 | } |
@@ -1363,11 +1555,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1363 | 1555 | ||
1364 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1556 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1365 | if (m_agentTransfer != null) | 1557 | if (m_agentTransfer != null) |
1366 | Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); | 1558 | m_agentTransfer.EnableChildAgents(this); |
1367 | 1559 | ||
1368 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1560 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1369 | if (friendsModule != null) | 1561 | if (friendsModule != null) |
1370 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1562 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1563 | |||
1371 | } | 1564 | } |
1372 | 1565 | ||
1373 | // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region | 1566 | // XXX: If we force an update here, then multiple attachments do appear correctly on a destination region |
@@ -1392,36 +1585,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
1392 | /// <param name="collisionPoint"></param> | 1585 | /// <param name="collisionPoint"></param> |
1393 | /// <param name="localid"></param> | 1586 | /// <param name="localid"></param> |
1394 | /// <param name="distance"></param> | 1587 | /// <param name="distance"></param> |
1588 | /// | ||
1589 | |||
1590 | private void UpdateCameraCollisionPlane(Vector4 plane) | ||
1591 | { | ||
1592 | if (m_lastCameraCollisionPlane != plane) | ||
1593 | { | ||
1594 | m_lastCameraCollisionPlane = plane; | ||
1595 | ControllingClient.SendCameraConstraint(plane); | ||
1596 | } | ||
1597 | } | ||
1598 | |||
1395 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) | 1599 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) |
1396 | { | 1600 | { |
1397 | const float POSITION_TOLERANCE = 0.02f; | 1601 | const float POSITION_TOLERANCE = 0.02f; |
1398 | const float VELOCITY_TOLERANCE = 0.02f; | ||
1399 | const float ROTATION_TOLERANCE = 0.02f; | 1602 | const float ROTATION_TOLERANCE = 0.02f; |
1400 | 1603 | ||
1401 | if (m_followCamAuto) | 1604 | m_doingCamRayCast = false; |
1605 | if (hitYN && localid != LocalId) | ||
1402 | { | 1606 | { |
1403 | if (hitYN) | 1607 | SceneObjectGroup group = m_scene.GetGroupByPrim(localid); |
1608 | bool IsPrim = group != null; | ||
1609 | if (IsPrim) | ||
1404 | { | 1610 | { |
1405 | CameraConstraintActive = true; | 1611 | SceneObjectPart part = group.GetPart(localid); |
1406 | //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); | 1612 | if (part != null && !part.VolumeDetectActive) |
1407 | 1613 | { | |
1408 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); | 1614 | CameraConstraintActive = true; |
1409 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); | 1615 | pNormal.X = (float) Math.Round(pNormal.X, 2); |
1616 | pNormal.Y = (float) Math.Round(pNormal.Y, 2); | ||
1617 | pNormal.Z = (float) Math.Round(pNormal.Z, 2); | ||
1618 | pNormal.Normalize(); | ||
1619 | collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); | ||
1620 | collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); | ||
1621 | collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); | ||
1622 | |||
1623 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, | ||
1624 | Vector3.Dot(collisionPoint, pNormal)); | ||
1625 | UpdateCameraCollisionPlane(plane); | ||
1626 | } | ||
1410 | } | 1627 | } |
1411 | else | 1628 | else |
1412 | { | 1629 | { |
1413 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 1630 | CameraConstraintActive = true; |
1414 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 1631 | pNormal.X = (float) Math.Round(pNormal.X, 2); |
1415 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | 1632 | pNormal.Y = (float) Math.Round(pNormal.Y, 2); |
1416 | { | 1633 | pNormal.Z = (float) Math.Round(pNormal.Z, 2); |
1417 | if (CameraConstraintActive) | 1634 | pNormal.Normalize(); |
1418 | { | 1635 | collisionPoint.X = (float) Math.Round(collisionPoint.X, 1); |
1419 | ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); | 1636 | collisionPoint.Y = (float) Math.Round(collisionPoint.Y, 1); |
1420 | CameraConstraintActive = false; | 1637 | collisionPoint.Z = (float) Math.Round(collisionPoint.Z, 1); |
1421 | } | 1638 | |
1422 | } | 1639 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, |
1640 | Vector3.Dot(collisionPoint, pNormal)); | ||
1641 | UpdateCameraCollisionPlane(plane); | ||
1423 | } | 1642 | } |
1424 | } | 1643 | } |
1644 | else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | ||
1645 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | ||
1646 | { | ||
1647 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... | ||
1648 | UpdateCameraCollisionPlane(plane); | ||
1649 | CameraConstraintActive = false; | ||
1650 | } | ||
1425 | } | 1651 | } |
1426 | 1652 | ||
1427 | /// <summary> | 1653 | /// <summary> |
@@ -1495,12 +1721,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1495 | // DrawDistance = agentData.Far; | 1721 | // DrawDistance = agentData.Far; |
1496 | DrawDistance = Scene.DefaultDrawDistance; | 1722 | DrawDistance = Scene.DefaultDrawDistance; |
1497 | 1723 | ||
1498 | // Check if Client has camera in 'follow cam' or 'build' mode. | ||
1499 | Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); | ||
1500 | |||
1501 | m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) | ||
1502 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; | ||
1503 | |||
1504 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | 1724 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; |
1505 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; | 1725 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; |
1506 | 1726 | ||
@@ -1520,14 +1740,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
1520 | StandUp(); | 1740 | StandUp(); |
1521 | } | 1741 | } |
1522 | 1742 | ||
1523 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); | ||
1524 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | 1743 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view |
1525 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) | 1744 | // this exclude checks may not be complete |
1745 | |||
1746 | if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast()) | ||
1526 | { | 1747 | { |
1527 | if (m_followCamAuto) | 1748 | if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0) |
1528 | { | 1749 | { |
1529 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1750 | Vector3 posAdjusted = AbsolutePosition; |
1530 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1751 | // posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; |
1752 | posAdjusted.Z += 1.0f; // viewer current camera focus point | ||
1753 | Vector3 tocam = CameraPosition - posAdjusted; | ||
1754 | tocam.X = (float)Math.Round(tocam.X, 1); | ||
1755 | tocam.Y = (float)Math.Round(tocam.Y, 1); | ||
1756 | tocam.Z = (float)Math.Round(tocam.Z, 1); | ||
1757 | |||
1758 | float distTocamlen = tocam.Length(); | ||
1759 | if (distTocamlen > 0.3f) | ||
1760 | { | ||
1761 | tocam *= (1.0f / distTocamlen); | ||
1762 | posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); | ||
1763 | posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); | ||
1764 | posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); | ||
1765 | |||
1766 | m_doingCamRayCast = true; | ||
1767 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); | ||
1768 | } | ||
1769 | } | ||
1770 | else if (CameraConstraintActive && (m_mouseLook || ParentID != 0)) | ||
1771 | { | ||
1772 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... | ||
1773 | UpdateCameraCollisionPlane(plane); | ||
1774 | CameraConstraintActive = false; | ||
1531 | } | 1775 | } |
1532 | } | 1776 | } |
1533 | 1777 | ||
@@ -1992,7 +2236,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1992 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); | 2236 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); |
1993 | 2237 | ||
1994 | MovingToTarget = false; | 2238 | MovingToTarget = false; |
1995 | MoveToPositionTarget = Vector3.Zero; | 2239 | // MoveToPositionTarget = Vector3.Zero; |
2240 | m_forceToApply = null; // cancel possible last action | ||
1996 | 2241 | ||
1997 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct | 2242 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct |
1998 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. | 2243 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. |
@@ -2010,12 +2255,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2010 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 2255 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
2011 | 2256 | ||
2012 | SitGround = false; | 2257 | SitGround = false; |
2258 | |||
2259 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
2013 | if (PhysicsActor == null) | 2260 | if (PhysicsActor == null) |
2014 | AddToPhysicalScene(false); | 2261 | AddToPhysicalScene(false); |
2262 | */ | ||
2015 | 2263 | ||
2016 | if (ParentID != 0) | 2264 | if (ParentID != 0) |
2017 | { | 2265 | { |
2018 | SceneObjectPart part = ParentPart; | 2266 | SceneObjectPart part = ParentPart; |
2267 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
2268 | |||
2019 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 2269 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
2020 | if (taskIDict != null) | 2270 | if (taskIDict != null) |
2021 | { | 2271 | { |
@@ -2031,14 +2281,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2031 | } | 2281 | } |
2032 | } | 2282 | } |
2033 | 2283 | ||
2034 | ParentPosition = part.GetWorldPosition(); | 2284 | part.ParentGroup.DeleteAvatar(UUID); |
2285 | // ParentPosition = part.GetWorldPosition(); | ||
2035 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 2286 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
2036 | 2287 | ||
2037 | m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 2288 | // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
2038 | ParentPosition = Vector3.Zero; | 2289 | // ParentPosition = Vector3.Zero; |
2290 | m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
2291 | if (part.SitTargetAvatar == UUID) | ||
2292 | m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; | ||
2039 | 2293 | ||
2040 | ParentID = 0; | 2294 | ParentID = 0; |
2041 | ParentPart = null; | 2295 | ParentPart = null; |
2296 | |||
2297 | if (PhysicsActor == null) | ||
2298 | AddToPhysicalScene(false); | ||
2299 | |||
2042 | SendAvatarDataToAllAgents(); | 2300 | SendAvatarDataToAllAgents(); |
2043 | m_requestedSitTargetID = 0; | 2301 | m_requestedSitTargetID = 0; |
2044 | 2302 | ||
@@ -2048,6 +2306,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2048 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 2306 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
2049 | } | 2307 | } |
2050 | 2308 | ||
2309 | else if (PhysicsActor == null) | ||
2310 | AddToPhysicalScene(false); | ||
2311 | |||
2051 | Animator.TrySetMovementAnimation("STAND"); | 2312 | Animator.TrySetMovementAnimation("STAND"); |
2052 | TriggerScenePresenceUpdated(); | 2313 | TriggerScenePresenceUpdated(); |
2053 | } | 2314 | } |
@@ -2096,11 +2357,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2096 | if (part == null) | 2357 | if (part == null) |
2097 | return; | 2358 | return; |
2098 | 2359 | ||
2099 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | ||
2100 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | ||
2101 | |||
2102 | if (PhysicsActor != null) | 2360 | if (PhysicsActor != null) |
2103 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2361 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
2104 | 2362 | ||
2105 | bool canSit = false; | 2363 | bool canSit = false; |
2106 | Vector3 pos = part.AbsolutePosition + offset; | 2364 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -2117,31 +2375,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
2117 | } | 2375 | } |
2118 | else | 2376 | else |
2119 | { | 2377 | { |
2378 | if (PhysicsSit(part,offset)) // physics engine | ||
2379 | return; | ||
2380 | |||
2120 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 2381 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) |
2121 | { | 2382 | { |
2122 | // m_log.DebugFormat( | ||
2123 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", | ||
2124 | // Name, part.Name, part.LocalId); | ||
2125 | 2383 | ||
2126 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 2384 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
2127 | canSit = true; | 2385 | canSit = true; |
2128 | } | 2386 | } |
2129 | // else | ||
2130 | // { | ||
2131 | // m_log.DebugFormat( | ||
2132 | // "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m", | ||
2133 | // Name, part.Name, part.LocalId); | ||
2134 | // } | ||
2135 | } | 2387 | } |
2136 | 2388 | ||
2137 | if (canSit) | 2389 | if (canSit) |
2138 | { | 2390 | { |
2391 | |||
2139 | if (PhysicsActor != null) | 2392 | if (PhysicsActor != null) |
2140 | { | 2393 | { |
2141 | // We can remove the physicsActor until they stand up. | 2394 | // We can remove the physicsActor until they stand up. |
2142 | RemoveFromPhysicalScene(); | 2395 | RemoveFromPhysicalScene(); |
2143 | } | 2396 | } |
2144 | 2397 | ||
2398 | if (MovingToTarget) | ||
2399 | ResetMoveToTarget(); | ||
2400 | |||
2401 | Velocity = Vector3.Zero; | ||
2402 | |||
2145 | part.AddSittingAvatar(UUID); | 2403 | part.AddSittingAvatar(UUID); |
2146 | 2404 | ||
2147 | cameraAtOffset = part.GetCameraAtOffset(); | 2405 | cameraAtOffset = part.GetCameraAtOffset(); |
@@ -2163,6 +2421,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2163 | 2421 | ||
2164 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2422 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
2165 | { | 2423 | { |
2424 | if (IsChildAgent) | ||
2425 | return; | ||
2426 | |||
2166 | if (ParentID != 0) | 2427 | if (ParentID != 0) |
2167 | { | 2428 | { |
2168 | if (ParentPart.UUID == targetID) | 2429 | if (ParentPart.UUID == targetID) |
@@ -2178,14 +2439,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2178 | m_requestedSitTargetID = part.LocalId; | 2439 | m_requestedSitTargetID = part.LocalId; |
2179 | m_requestedSitTargetUUID = part.UUID; | 2440 | m_requestedSitTargetUUID = part.UUID; |
2180 | 2441 | ||
2181 | // m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | ||
2182 | |||
2183 | if (m_scene.PhysicsScene.SupportsRayCast()) | ||
2184 | { | ||
2185 | //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); | ||
2186 | //SitRayCastAvatarPosition(part); | ||
2187 | //return; | ||
2188 | } | ||
2189 | } | 2442 | } |
2190 | else | 2443 | else |
2191 | { | 2444 | { |
@@ -2195,197 +2448,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2195 | SendSitResponse(targetID, offset, Quaternion.Identity); | 2448 | SendSitResponse(targetID, offset, Quaternion.Identity); |
2196 | } | 2449 | } |
2197 | 2450 | ||
2198 | /* | 2451 | // returns false if does not suport so older sit can be tried |
2199 | public void SitRayCastAvatarPosition(SceneObjectPart part) | 2452 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) |
2200 | { | 2453 | { |
2201 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2454 | if (part == null || part.ParentGroup.IsAttachment) |
2202 | Vector3 StartRayCastPosition = AbsolutePosition; | ||
2203 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2204 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2205 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); | ||
2206 | } | ||
2207 | |||
2208 | public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | ||
2209 | { | ||
2210 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2211 | if (part != null) | ||
2212 | { | ||
2213 | if (hitYN) | ||
2214 | { | ||
2215 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2216 | { | ||
2217 | SitRaycastFindEdge(collisionPoint, normal); | ||
2218 | m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2219 | } | ||
2220 | else | ||
2221 | { | ||
2222 | SitRayCastAvatarPositionCameraZ(part); | ||
2223 | } | ||
2224 | } | ||
2225 | else | ||
2226 | { | ||
2227 | SitRayCastAvatarPositionCameraZ(part); | ||
2228 | } | ||
2229 | } | ||
2230 | else | ||
2231 | { | 2455 | { |
2232 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2456 | return true; |
2233 | m_requestedSitTargetUUID = UUID.Zero; | ||
2234 | m_requestedSitTargetID = 0; | ||
2235 | m_requestedSitOffset = Vector3.Zero; | ||
2236 | } | 2457 | } |
2237 | 2458 | ||
2238 | } | 2459 | if ( m_scene.PhysicsScene == null) |
2239 | 2460 | return false; | |
2240 | public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) | ||
2241 | { | ||
2242 | // Next, try to raycast from the camera Z position | ||
2243 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2244 | Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; | ||
2245 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2246 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2247 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); | ||
2248 | } | ||
2249 | 2461 | ||
2250 | public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2462 | if (part.PhysActor == null) |
2251 | { | ||
2252 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2253 | if (part != null) | ||
2254 | { | 2463 | { |
2255 | if (hitYN) | 2464 | // none physcis shape |
2256 | { | 2465 | if (part.PhysicsShapeType == (byte)PhysicsShapeType.None) |
2257 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | 2466 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2258 | { | ||
2259 | SitRaycastFindEdge(collisionPoint, normal); | ||
2260 | m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2261 | } | ||
2262 | else | ||
2263 | { | ||
2264 | SitRayCastCameraPosition(part); | ||
2265 | } | ||
2266 | } | ||
2267 | else | 2467 | else |
2268 | { | 2468 | { // non physical phantom TODO |
2269 | SitRayCastCameraPosition(part); | 2469 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2470 | return false; | ||
2270 | } | 2471 | } |
2271 | } | 2472 | return true; |
2272 | else | ||
2273 | { | ||
2274 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2275 | m_requestedSitTargetUUID = UUID.Zero; | ||
2276 | m_requestedSitTargetID = 0; | ||
2277 | m_requestedSitOffset = Vector3.Zero; | ||
2278 | } | 2473 | } |
2279 | 2474 | ||
2280 | } | ||
2281 | 2475 | ||
2282 | public void SitRayCastCameraPosition(SceneObjectPart part) | 2476 | // not doing autopilot |
2283 | { | 2477 | m_requestedSitTargetID = 0; |
2284 | // Next, try to raycast from the camera position | ||
2285 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2286 | Vector3 StartRayCastPosition = CameraPosition; | ||
2287 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2288 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2289 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); | ||
2290 | } | ||
2291 | 2478 | ||
2292 | public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2479 | if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) |
2293 | { | 2480 | return true; |
2294 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2295 | if (part != null) | ||
2296 | { | ||
2297 | if (hitYN) | ||
2298 | { | ||
2299 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2300 | { | ||
2301 | SitRaycastFindEdge(collisionPoint, normal); | ||
2302 | m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2303 | } | ||
2304 | else | ||
2305 | { | ||
2306 | SitRayHorizontal(part); | ||
2307 | } | ||
2308 | } | ||
2309 | else | ||
2310 | { | ||
2311 | SitRayHorizontal(part); | ||
2312 | } | ||
2313 | } | ||
2314 | else | ||
2315 | { | ||
2316 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2317 | m_requestedSitTargetUUID = UUID.Zero; | ||
2318 | m_requestedSitTargetID = 0; | ||
2319 | m_requestedSitOffset = Vector3.Zero; | ||
2320 | } | ||
2321 | 2481 | ||
2482 | return false; | ||
2322 | } | 2483 | } |
2323 | 2484 | ||
2324 | public void SitRayHorizontal(SceneObjectPart part) | 2485 | |
2486 | private bool CanEnterLandPosition(Vector3 testPos) | ||
2325 | { | 2487 | { |
2326 | // Next, try to raycast from the avatar position to fwd | 2488 | ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y); |
2327 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2489 | |
2328 | Vector3 StartRayCastPosition = CameraPosition; | 2490 | if (land == null || land.LandData.Name == "NO_LAND") |
2329 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2491 | return true; |
2330 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2492 | |
2331 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); | 2493 | return land.CanBeOnThisLand(UUID,testPos.Z); |
2332 | } | 2494 | } |
2333 | 2495 | ||
2334 | public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2496 | // status |
2497 | // < 0 ignore | ||
2498 | // 0 bad sit spot | ||
2499 | public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) | ||
2335 | { | 2500 | { |
2336 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2501 | if (status < 0) |
2337 | if (part != null) | 2502 | return; |
2503 | |||
2504 | if (status == 0) | ||
2338 | { | 2505 | { |
2339 | if (hitYN) | 2506 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2340 | { | 2507 | return; |
2341 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2342 | { | ||
2343 | SitRaycastFindEdge(collisionPoint, normal); | ||
2344 | m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2345 | // Next, try to raycast from the camera position | ||
2346 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2347 | Vector3 StartRayCastPosition = CameraPosition; | ||
2348 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2349 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2350 | //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); | ||
2351 | } | ||
2352 | else | ||
2353 | { | ||
2354 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2355 | m_requestedSitTargetUUID = UUID.Zero; | ||
2356 | m_requestedSitTargetID = 0; | ||
2357 | m_requestedSitOffset = Vector3.Zero; | ||
2358 | } | ||
2359 | } | ||
2360 | else | ||
2361 | { | ||
2362 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2363 | m_requestedSitTargetUUID = UUID.Zero; | ||
2364 | m_requestedSitTargetID = 0; | ||
2365 | m_requestedSitOffset = Vector3.Zero; | ||
2366 | } | ||
2367 | } | 2508 | } |
2368 | else | 2509 | |
2510 | SceneObjectPart part = m_scene.GetSceneObjectPart(partID); | ||
2511 | if (part == null) | ||
2512 | return; | ||
2513 | |||
2514 | Vector3 targetPos = part.GetWorldPosition() + offset * part.GetWorldRotation(); | ||
2515 | if(!CanEnterLandPosition(targetPos)) | ||
2369 | { | 2516 | { |
2370 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2517 | ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot"); |
2371 | m_requestedSitTargetUUID = UUID.Zero; | 2518 | return; |
2372 | m_requestedSitTargetID = 0; | ||
2373 | m_requestedSitOffset = Vector3.Zero; | ||
2374 | } | 2519 | } |
2375 | 2520 | ||
2376 | } | 2521 | RemoveFromPhysicalScene(); |
2377 | 2522 | ||
2378 | private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) | 2523 | if (MovingToTarget) |
2379 | { | 2524 | ResetMoveToTarget(); |
2380 | int i = 0; | 2525 | |
2381 | //throw new NotImplementedException(); | 2526 | Velocity = Vector3.Zero; |
2382 | //m_requestedSitTargetUUID = UUID.Zero; | ||
2383 | //m_requestedSitTargetID = 0; | ||
2384 | //m_requestedSitOffset = Vector3.Zero; | ||
2385 | 2527 | ||
2386 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); | 2528 | part.AddSittingAvatar(UUID); |
2529 | |||
2530 | Vector3 cameraAtOffset = part.GetCameraAtOffset(); | ||
2531 | Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2532 | bool forceMouselook = part.GetForceMouselook(); | ||
2533 | |||
2534 | ControllingClient.SendSitResponse( | ||
2535 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2536 | |||
2537 | // not using autopilot | ||
2538 | |||
2539 | Rotation = Orientation; | ||
2540 | m_pos = offset; | ||
2541 | |||
2542 | m_requestedSitTargetID = 0; | ||
2543 | part.ParentGroup.AddAvatar(UUID); | ||
2544 | |||
2545 | ParentPart = part; | ||
2546 | ParentID = part.LocalId; | ||
2547 | if(status == 3) | ||
2548 | Animator.TrySetMovementAnimation("SIT_GROUND"); | ||
2549 | else | ||
2550 | Animator.TrySetMovementAnimation("SIT"); | ||
2551 | SendAvatarDataToAllAgents(); | ||
2552 | |||
2553 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | ||
2387 | } | 2554 | } |
2388 | */ | 2555 | |
2389 | 2556 | ||
2390 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2557 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2391 | { | 2558 | { |
@@ -2402,6 +2569,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2402 | return; | 2569 | return; |
2403 | } | 2570 | } |
2404 | 2571 | ||
2572 | |||
2405 | if (part.SitTargetAvatar == UUID) | 2573 | if (part.SitTargetAvatar == UUID) |
2406 | { | 2574 | { |
2407 | Vector3 sitTargetPos = part.SitTargetPosition; | 2575 | Vector3 sitTargetPos = part.SitTargetPosition; |
@@ -2416,14 +2584,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2416 | 2584 | ||
2417 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2585 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2418 | 2586 | ||
2419 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2587 | double x, y, z, m; |
2588 | |||
2589 | Quaternion r = sitTargetOrient; | ||
2590 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2591 | |||
2592 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2593 | { | ||
2594 | m = 1.0 / Math.Sqrt(m); | ||
2595 | r.X *= (float)m; | ||
2596 | r.Y *= (float)m; | ||
2597 | r.Z *= (float)m; | ||
2598 | r.W *= (float)m; | ||
2599 | } | ||
2600 | |||
2601 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2602 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2603 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2604 | |||
2605 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2606 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2607 | |||
2608 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2609 | |||
2610 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2420 | Rotation = sitTargetOrient; | 2611 | Rotation = sitTargetOrient; |
2421 | ParentPosition = part.AbsolutePosition; | 2612 | // ParentPosition = part.AbsolutePosition; |
2613 | part.ParentGroup.AddAvatar(UUID); | ||
2422 | } | 2614 | } |
2423 | else | 2615 | else |
2424 | { | 2616 | { |
2425 | m_pos -= part.AbsolutePosition; | 2617 | m_pos -= part.AbsolutePosition; |
2426 | ParentPosition = part.AbsolutePosition; | 2618 | // ParentPosition = part.AbsolutePosition; |
2619 | part.ParentGroup.AddAvatar(UUID); | ||
2427 | 2620 | ||
2428 | // m_log.DebugFormat( | 2621 | // m_log.DebugFormat( |
2429 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2622 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2478,6 +2671,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2478 | TriggerScenePresenceUpdated(); | 2671 | TriggerScenePresenceUpdated(); |
2479 | } | 2672 | } |
2480 | 2673 | ||
2674 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2675 | { | ||
2676 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2677 | } | ||
2678 | |||
2679 | |||
2680 | |||
2481 | /// <summary> | 2681 | /// <summary> |
2482 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2682 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2483 | /// </summary> | 2683 | /// </summary> |
@@ -2534,8 +2734,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2534 | direc.Z *= 2.6f; | 2734 | direc.Z *= 2.6f; |
2535 | 2735 | ||
2536 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2736 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2537 | Animator.TrySetMovementAnimation("PREJUMP"); | 2737 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2538 | Animator.TrySetMovementAnimation("JUMP"); | 2738 | // Animator.TrySetMovementAnimation("JUMP"); |
2539 | } | 2739 | } |
2540 | } | 2740 | } |
2541 | } | 2741 | } |
@@ -2544,6 +2744,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2544 | 2744 | ||
2545 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2745 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2546 | m_forceToApply = direc; | 2746 | m_forceToApply = direc; |
2747 | Animator.UpdateMovementAnimations(); | ||
2547 | } | 2748 | } |
2548 | 2749 | ||
2549 | #endregion | 2750 | #endregion |
@@ -2561,16 +2762,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2561 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | 2762 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to |
2562 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | 2763 | // grab the latest PhysicsActor velocity, whereas m_velocity is often |
2563 | // storing a requested force instead of an actual traveling velocity | 2764 | // storing a requested force instead of an actual traveling velocity |
2765 | if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn) | ||
2766 | SendAvatarDataToAllAgents(); | ||
2564 | 2767 | ||
2565 | // Throw away duplicate or insignificant updates | 2768 | if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2566 | if ( | 2769 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2567 | // If the velocity has become zero, send it no matter what. | 2770 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2568 | (Velocity != m_lastVelocity && Velocity == Vector3.Zero) | ||
2569 | // otherwise, if things have changed reasonably, send the update | ||
2570 | || (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) | ||
2571 | || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) | ||
2572 | || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))) | ||
2573 | |||
2574 | { | 2771 | { |
2575 | SendTerseUpdateToAllClients(); | 2772 | SendTerseUpdateToAllClients(); |
2576 | 2773 | ||
@@ -2728,9 +2925,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2728 | // again here... this comes after the cached appearance check because the avatars | 2925 | // again here... this comes after the cached appearance check because the avatars |
2729 | // appearance goes into the avatar update packet | 2926 | // appearance goes into the avatar update packet |
2730 | SendAvatarDataToAllAgents(); | 2927 | SendAvatarDataToAllAgents(); |
2731 | 2928 | SendAppearanceToAgent(this); | |
2732 | // This invocation always shows up in the viewer logs as an error. | ||
2733 | // SendAppearanceToAgent(this); | ||
2734 | 2929 | ||
2735 | // If we are using the the cached appearance then send it out to everyone | 2930 | // If we are using the the cached appearance then send it out to everyone |
2736 | if (cachedappearance) | 2931 | if (cachedappearance) |
@@ -2761,6 +2956,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2761 | return; | 2956 | return; |
2762 | } | 2957 | } |
2763 | 2958 | ||
2959 | m_lastSize = Appearance.AvatarSize; | ||
2960 | |||
2764 | int count = 0; | 2961 | int count = 0; |
2765 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 2962 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
2766 | { | 2963 | { |
@@ -2868,6 +3065,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2868 | 3065 | ||
2869 | avatar.ControllingClient.SendAppearance( | 3066 | avatar.ControllingClient.SendAppearance( |
2870 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); | 3067 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); |
3068 | |||
3069 | |||
2871 | } | 3070 | } |
2872 | 3071 | ||
2873 | #endregion | 3072 | #endregion |
@@ -2942,8 +3141,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2942 | 3141 | ||
2943 | // If we don't have a PhysActor, we can't cross anyway | 3142 | // If we don't have a PhysActor, we can't cross anyway |
2944 | // Also don't do this while sat, sitting avatars cross with the | 3143 | // Also don't do this while sat, sitting avatars cross with the |
2945 | // object they sit on. | 3144 | // object they sit on. ParentUUID denoted a pending sit, don't |
2946 | if (ParentID != 0 || PhysicsActor == null) | 3145 | // interfere with it. |
3146 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
2947 | return; | 3147 | return; |
2948 | 3148 | ||
2949 | if (!IsInTransit) | 3149 | if (!IsInTransit) |
@@ -3206,6 +3406,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3206 | } | 3406 | } |
3207 | 3407 | ||
3208 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3408 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3409 | private void RaiseUpdateThrottles() | ||
3410 | { | ||
3411 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
3412 | } | ||
3209 | /// <summary> | 3413 | /// <summary> |
3210 | /// This updates important decision making data about a child agent | 3414 | /// This updates important decision making data about a child agent |
3211 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3415 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3286,6 +3490,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3286 | cAgent.AlwaysRun = SetAlwaysRun; | 3490 | cAgent.AlwaysRun = SetAlwaysRun; |
3287 | 3491 | ||
3288 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3492 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3493 | |||
3494 | cAgent.ParentPart = ParentUUID; | ||
3495 | cAgent.SitOffset = m_pos; | ||
3289 | 3496 | ||
3290 | lock (scriptedcontrols) | 3497 | lock (scriptedcontrols) |
3291 | { | 3498 | { |
@@ -3294,7 +3501,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3294 | 3501 | ||
3295 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3502 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3296 | { | 3503 | { |
3297 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3504 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3298 | } | 3505 | } |
3299 | cAgent.Controllers = controls; | 3506 | cAgent.Controllers = controls; |
3300 | } | 3507 | } |
@@ -3327,6 +3534,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3327 | CameraAtAxis = cAgent.AtAxis; | 3534 | CameraAtAxis = cAgent.AtAxis; |
3328 | CameraLeftAxis = cAgent.LeftAxis; | 3535 | CameraLeftAxis = cAgent.LeftAxis; |
3329 | CameraUpAxis = cAgent.UpAxis; | 3536 | CameraUpAxis = cAgent.UpAxis; |
3537 | ParentUUID = cAgent.ParentPart; | ||
3538 | m_prevSitOffset = cAgent.SitOffset; | ||
3330 | 3539 | ||
3331 | // When we get to the point of re-computing neighbors everytime this | 3540 | // When we get to the point of re-computing neighbors everytime this |
3332 | // changes, then start using the agent's drawdistance rather than the | 3541 | // changes, then start using the agent's drawdistance rather than the |
@@ -3364,6 +3573,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3364 | foreach (ControllerData c in cAgent.Controllers) | 3573 | foreach (ControllerData c in cAgent.Controllers) |
3365 | { | 3574 | { |
3366 | ScriptControllers sc = new ScriptControllers(); | 3575 | ScriptControllers sc = new ScriptControllers(); |
3576 | sc.objectID = c.ObjectID; | ||
3367 | sc.itemID = c.ItemID; | 3577 | sc.itemID = c.ItemID; |
3368 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3578 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3369 | sc.eventControls = (ScriptControlled)c.EventControls; | 3579 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3431,20 +3641,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3431 | } | 3641 | } |
3432 | 3642 | ||
3433 | if (Appearance.AvatarHeight == 0) | 3643 | if (Appearance.AvatarHeight == 0) |
3434 | Appearance.SetHeight(); | 3644 | // Appearance.SetHeight(); |
3645 | Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
3435 | 3646 | ||
3436 | PhysicsScene scene = m_scene.PhysicsScene; | 3647 | PhysicsScene scene = m_scene.PhysicsScene; |
3437 | 3648 | ||
3438 | Vector3 pVec = AbsolutePosition; | 3649 | Vector3 pVec = AbsolutePosition; |
3439 | 3650 | ||
3651 | /* | ||
3440 | PhysicsActor = scene.AddAvatar( | 3652 | PhysicsActor = scene.AddAvatar( |
3441 | LocalId, Firstname + "." + Lastname, pVec, | 3653 | LocalId, Firstname + "." + Lastname, pVec, |
3442 | new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); | 3654 | new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); |
3655 | */ | ||
3656 | |||
3657 | PhysicsActor = scene.AddAvatar( | ||
3658 | LocalId, Firstname + "." + Lastname, pVec, | ||
3659 | Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); | ||
3443 | 3660 | ||
3444 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3661 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3445 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3662 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3446 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3663 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3447 | PhysicsActor.SubscribeEvents(500); | 3664 | PhysicsActor.SubscribeEvents(100); |
3448 | PhysicsActor.LocalID = LocalId; | 3665 | PhysicsActor.LocalID = LocalId; |
3449 | } | 3666 | } |
3450 | 3667 | ||
@@ -3458,6 +3675,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3458 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); | 3675 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); |
3459 | } | 3676 | } |
3460 | 3677 | ||
3678 | |||
3461 | /// <summary> | 3679 | /// <summary> |
3462 | /// Event called by the physics plugin to tell the avatar about a collision. | 3680 | /// Event called by the physics plugin to tell the avatar about a collision. |
3463 | /// </summary> | 3681 | /// </summary> |
@@ -3471,7 +3689,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3471 | /// <param name="e"></param> | 3689 | /// <param name="e"></param> |
3472 | public void PhysicsCollisionUpdate(EventArgs e) | 3690 | public void PhysicsCollisionUpdate(EventArgs e) |
3473 | { | 3691 | { |
3474 | if (IsChildAgent) | 3692 | if (IsChildAgent || Animator == null) |
3475 | return; | 3693 | return; |
3476 | 3694 | ||
3477 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3695 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
@@ -3488,7 +3706,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3488 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3706 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3489 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3707 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3490 | 3708 | ||
3491 | CollisionPlane = Vector4.UnitW; | ||
3492 | 3709 | ||
3493 | // // No collisions at all means we may be flying. Update always | 3710 | // // No collisions at all means we may be flying. Update always |
3494 | // // to make falling work | 3711 | // // to make falling work |
@@ -3500,6 +3717,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3500 | 3717 | ||
3501 | if (coldata.Count != 0) | 3718 | if (coldata.Count != 0) |
3502 | { | 3719 | { |
3720 | /* | ||
3503 | switch (Animator.CurrentMovementAnimation) | 3721 | switch (Animator.CurrentMovementAnimation) |
3504 | { | 3722 | { |
3505 | case "STAND": | 3723 | case "STAND": |
@@ -3508,24 +3726,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
3508 | case "CROUCH": | 3726 | case "CROUCH": |
3509 | case "CROUCHWALK": | 3727 | case "CROUCHWALK": |
3510 | { | 3728 | { |
3729 | */ | ||
3511 | ContactPoint lowest; | 3730 | ContactPoint lowest; |
3512 | lowest.SurfaceNormal = Vector3.Zero; | 3731 | lowest.SurfaceNormal = Vector3.Zero; |
3513 | lowest.Position = Vector3.Zero; | 3732 | lowest.Position = Vector3.Zero; |
3514 | lowest.Position.Z = Single.NaN; | 3733 | lowest.Position.Z = float.MaxValue; |
3515 | 3734 | ||
3516 | foreach (ContactPoint contact in coldata.Values) | 3735 | foreach (ContactPoint contact in coldata.Values) |
3517 | { | 3736 | { |
3518 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) | 3737 | |
3738 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | ||
3519 | { | 3739 | { |
3520 | lowest = contact; | 3740 | lowest = contact; |
3521 | } | 3741 | } |
3522 | } | 3742 | } |
3523 | 3743 | ||
3524 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | 3744 | if (lowest.Position.Z != float.MaxValue) |
3745 | { | ||
3746 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | ||
3747 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
3748 | } | ||
3749 | else | ||
3750 | CollisionPlane = Vector4.UnitW; | ||
3751 | /* | ||
3525 | } | 3752 | } |
3526 | break; | 3753 | break; |
3527 | } | 3754 | } |
3755 | */ | ||
3528 | } | 3756 | } |
3757 | else | ||
3758 | CollisionPlane = Vector4.UnitW; | ||
3759 | |||
3760 | RaiseCollisionScriptEvents(coldata); | ||
3529 | 3761 | ||
3530 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3762 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3531 | if (Invulnerable || GodLevel > 0) | 3763 | if (Invulnerable || GodLevel > 0) |
@@ -3624,6 +3856,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3624 | // m_reprioritizationTimer.Dispose(); | 3856 | // m_reprioritizationTimer.Dispose(); |
3625 | 3857 | ||
3626 | RemoveFromPhysicalScene(); | 3858 | RemoveFromPhysicalScene(); |
3859 | |||
3860 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
3861 | |||
3862 | // if (Animator != null) | ||
3863 | // Animator.Close(); | ||
3864 | Animator = null; | ||
3865 | |||
3627 | } | 3866 | } |
3628 | 3867 | ||
3629 | public void AddAttachment(SceneObjectGroup gobj) | 3868 | public void AddAttachment(SceneObjectGroup gobj) |
@@ -3857,10 +4096,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3857 | 4096 | ||
3858 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 4097 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3859 | { | 4098 | { |
4099 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
4100 | if (p == null) | ||
4101 | return; | ||
4102 | |||
4103 | ControllingClient.SendTakeControls(controls, false, false); | ||
4104 | ControllingClient.SendTakeControls(controls, true, false); | ||
4105 | |||
3860 | ScriptControllers obj = new ScriptControllers(); | 4106 | ScriptControllers obj = new ScriptControllers(); |
3861 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 4107 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3862 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 4108 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3863 | 4109 | ||
4110 | obj.objectID = p.ParentGroup.UUID; | ||
3864 | obj.itemID = Script_item_UUID; | 4111 | obj.itemID = Script_item_UUID; |
3865 | if (pass_on == 0 && accept == 0) | 4112 | if (pass_on == 0 && accept == 0) |
3866 | { | 4113 | { |
@@ -3909,6 +4156,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3909 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 4156 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3910 | } | 4157 | } |
3911 | 4158 | ||
4159 | private void UnRegisterSeatControls(UUID obj) | ||
4160 | { | ||
4161 | List<UUID> takers = new List<UUID>(); | ||
4162 | |||
4163 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
4164 | { | ||
4165 | if (c.objectID == obj) | ||
4166 | takers.Add(c.itemID); | ||
4167 | } | ||
4168 | foreach (UUID t in takers) | ||
4169 | { | ||
4170 | UnRegisterControlEventsToScript(0, t); | ||
4171 | } | ||
4172 | } | ||
4173 | |||
3912 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 4174 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3913 | { | 4175 | { |
3914 | ScriptControllers takecontrols; | 4176 | ScriptControllers takecontrols; |
@@ -4238,6 +4500,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4238 | 4500 | ||
4239 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4501 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
4240 | { | 4502 | { |
4503 | string reason; | ||
4504 | |||
4505 | // Honor bans | ||
4506 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4507 | return; | ||
4508 | |||
4241 | SceneObjectGroup telehub = null; | 4509 | SceneObjectGroup telehub = null; |
4242 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4510 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
4243 | { | 4511 | { |
@@ -4277,11 +4545,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4277 | pos = land.LandData.UserLocation; | 4545 | pos = land.LandData.UserLocation; |
4278 | } | 4546 | } |
4279 | } | 4547 | } |
4280 | 4548 | ||
4281 | land.SendLandUpdateToClient(ControllingClient); | 4549 | land.SendLandUpdateToClient(ControllingClient); |
4282 | } | 4550 | } |
4283 | } | 4551 | } |
4284 | 4552 | ||
4553 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4554 | { | ||
4555 | DetectedObject detobj = new DetectedObject(); | ||
4556 | detobj.keyUUID = obj.UUID; | ||
4557 | detobj.nameStr = obj.Name; | ||
4558 | detobj.ownerUUID = obj.OwnerID; | ||
4559 | detobj.posVector = obj.AbsolutePosition; | ||
4560 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4561 | detobj.velVector = obj.Velocity; | ||
4562 | detobj.colliderType = 0; | ||
4563 | detobj.groupUUID = obj.GroupID; | ||
4564 | |||
4565 | return detobj; | ||
4566 | } | ||
4567 | |||
4568 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4569 | { | ||
4570 | DetectedObject detobj = new DetectedObject(); | ||
4571 | detobj.keyUUID = av.UUID; | ||
4572 | detobj.nameStr = av.ControllingClient.Name; | ||
4573 | detobj.ownerUUID = av.UUID; | ||
4574 | detobj.posVector = av.AbsolutePosition; | ||
4575 | detobj.rotQuat = av.Rotation; | ||
4576 | detobj.velVector = av.Velocity; | ||
4577 | detobj.colliderType = 0; | ||
4578 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4579 | |||
4580 | return detobj; | ||
4581 | } | ||
4582 | |||
4583 | private DetectedObject CreateDetObjectForGround() | ||
4584 | { | ||
4585 | DetectedObject detobj = new DetectedObject(); | ||
4586 | detobj.keyUUID = UUID.Zero; | ||
4587 | detobj.nameStr = ""; | ||
4588 | detobj.ownerUUID = UUID.Zero; | ||
4589 | detobj.posVector = AbsolutePosition; | ||
4590 | detobj.rotQuat = Quaternion.Identity; | ||
4591 | detobj.velVector = Vector3.Zero; | ||
4592 | detobj.colliderType = 0; | ||
4593 | detobj.groupUUID = UUID.Zero; | ||
4594 | |||
4595 | return detobj; | ||
4596 | } | ||
4597 | |||
4598 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4599 | { | ||
4600 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4601 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4602 | foreach (uint localId in colliders) | ||
4603 | { | ||
4604 | if (localId == 0) | ||
4605 | continue; | ||
4606 | |||
4607 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4608 | if (obj != null) | ||
4609 | { | ||
4610 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4611 | colliding.Add(CreateDetObject(obj)); | ||
4612 | } | ||
4613 | else | ||
4614 | { | ||
4615 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4616 | if (av != null && (!av.IsChildAgent)) | ||
4617 | { | ||
4618 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4619 | colliding.Add(CreateDetObject(av)); | ||
4620 | } | ||
4621 | } | ||
4622 | } | ||
4623 | |||
4624 | colliderArgs.Colliders = colliding; | ||
4625 | |||
4626 | return colliderArgs; | ||
4627 | } | ||
4628 | |||
4629 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4630 | |||
4631 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4632 | { | ||
4633 | ColliderArgs CollidingMessage; | ||
4634 | |||
4635 | if (colliders.Count > 0) | ||
4636 | { | ||
4637 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4638 | { | ||
4639 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4640 | |||
4641 | if (CollidingMessage.Colliders.Count > 0) | ||
4642 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4643 | } | ||
4644 | } | ||
4645 | } | ||
4646 | |||
4647 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4648 | { | ||
4649 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4650 | { | ||
4651 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4652 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4653 | |||
4654 | colliding.Add(CreateDetObjectForGround()); | ||
4655 | LandCollidingMessage.Colliders = colliding; | ||
4656 | |||
4657 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4658 | } | ||
4659 | } | ||
4660 | |||
4661 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4662 | { | ||
4663 | try | ||
4664 | { | ||
4665 | List<uint> thisHitColliders = new List<uint>(); | ||
4666 | List<uint> endedColliders = new List<uint>(); | ||
4667 | List<uint> startedColliders = new List<uint>(); | ||
4668 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4669 | CollisionForSoundInfo soundinfo; | ||
4670 | ContactPoint curcontact; | ||
4671 | |||
4672 | if (coldata.Count == 0) | ||
4673 | { | ||
4674 | if (m_lastColliders.Count == 0) | ||
4675 | return; // nothing to do | ||
4676 | |||
4677 | foreach (uint localID in m_lastColliders) | ||
4678 | { | ||
4679 | endedColliders.Add(localID); | ||
4680 | } | ||
4681 | m_lastColliders.Clear(); | ||
4682 | } | ||
4683 | |||
4684 | else | ||
4685 | { | ||
4686 | foreach (uint id in coldata.Keys) | ||
4687 | { | ||
4688 | thisHitColliders.Add(id); | ||
4689 | if (!m_lastColliders.Contains(id)) | ||
4690 | { | ||
4691 | startedColliders.Add(id); | ||
4692 | curcontact = coldata[id]; | ||
4693 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4694 | { | ||
4695 | soundinfo = new CollisionForSoundInfo(); | ||
4696 | soundinfo.colliderID = id; | ||
4697 | soundinfo.position = curcontact.Position; | ||
4698 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4699 | soundinfolist.Add(soundinfo); | ||
4700 | } | ||
4701 | } | ||
4702 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4703 | } | ||
4704 | |||
4705 | // calculate things that ended colliding | ||
4706 | foreach (uint localID in m_lastColliders) | ||
4707 | { | ||
4708 | if (!thisHitColliders.Contains(localID)) | ||
4709 | { | ||
4710 | endedColliders.Add(localID); | ||
4711 | } | ||
4712 | } | ||
4713 | //add the items that started colliding this time to the last colliders list. | ||
4714 | foreach (uint localID in startedColliders) | ||
4715 | { | ||
4716 | m_lastColliders.Add(localID); | ||
4717 | } | ||
4718 | // remove things that ended colliding from the last colliders list | ||
4719 | foreach (uint localID in endedColliders) | ||
4720 | { | ||
4721 | m_lastColliders.Remove(localID); | ||
4722 | } | ||
4723 | |||
4724 | if (soundinfolist.Count > 0) | ||
4725 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4726 | } | ||
4727 | |||
4728 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4729 | { | ||
4730 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4731 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4732 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4733 | |||
4734 | if (startedColliders.Contains(0)) | ||
4735 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4736 | if (m_lastColliders.Contains(0)) | ||
4737 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4738 | if (endedColliders.Contains(0)) | ||
4739 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4740 | } | ||
4741 | } | ||
4742 | finally | ||
4743 | { | ||
4744 | m_collisionEventFlag = false; | ||
4745 | } | ||
4746 | } | ||
4747 | |||
4285 | private void TeleportFlagsDebug() { | 4748 | private void TeleportFlagsDebug() { |
4286 | 4749 | ||
4287 | // Some temporary debugging help to show all the TeleportFlags we have... | 4750 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4306,6 +4769,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4306 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4769 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4307 | 4770 | ||
4308 | } | 4771 | } |
4309 | |||
4310 | } | 4772 | } |
4311 | } | 4773 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 3882b45..ce4fb40 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -374,11 +374,21 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
374 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); | 374 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); |
375 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); | 375 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); |
376 | 376 | ||
377 | m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); | ||
378 | m_SOPXmlProcessors.Add("Force", ProcessForce); | ||
379 | m_SOPXmlProcessors.Add("Torque", ProcessTorque); | ||
380 | m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); | ||
381 | |||
382 | |||
383 | m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); | ||
384 | |||
377 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); | 385 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); |
378 | m_SOPXmlProcessors.Add("Density", ProcessDensity); | 386 | m_SOPXmlProcessors.Add("Density", ProcessDensity); |
379 | m_SOPXmlProcessors.Add("Friction", ProcessFriction); | 387 | m_SOPXmlProcessors.Add("Friction", ProcessFriction); |
380 | m_SOPXmlProcessors.Add("Bounce", ProcessBounce); | 388 | m_SOPXmlProcessors.Add("Bounce", ProcessBounce); |
381 | m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); | 389 | m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); |
390 | m_SOPXmlProcessors.Add("CameraEyeOffset", ProcessCameraEyeOffset); | ||
391 | m_SOPXmlProcessors.Add("CameraAtOffset", ProcessCameraAtOffset); | ||
382 | 392 | ||
383 | #endregion | 393 | #endregion |
384 | 394 | ||
@@ -407,7 +417,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
407 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); | 417 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); |
408 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); | 418 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); |
409 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); | 419 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); |
410 | 420 | ||
411 | #endregion | 421 | #endregion |
412 | 422 | ||
413 | #region ShapeXmlProcessors initialization | 423 | #region ShapeXmlProcessors initialization |
@@ -632,6 +642,33 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
632 | obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); | 642 | obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); |
633 | } | 643 | } |
634 | 644 | ||
645 | private static void ProcessCameraEyeOffset(SceneObjectPart obj, XmlTextReader reader) | ||
646 | { | ||
647 | obj.SetCameraEyeOffset(Util.ReadVector(reader, "CameraEyeOffset")); | ||
648 | } | ||
649 | |||
650 | private static void ProcessCameraAtOffset(SceneObjectPart obj, XmlTextReader reader) | ||
651 | { | ||
652 | obj.SetCameraAtOffset(Util.ReadVector(reader, "CameraAtOffset")); | ||
653 | } | ||
654 | |||
655 | private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) | ||
656 | { | ||
657 | SOPVehicle vehicle = SOPVehicle.FromXml2(reader); | ||
658 | |||
659 | if (vehicle == null) | ||
660 | { | ||
661 | obj.VehicleParams = null; | ||
662 | m_log.DebugFormat( | ||
663 | "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.", | ||
664 | obj.Name, obj.UUID); | ||
665 | } | ||
666 | else | ||
667 | { | ||
668 | obj.VehicleParams = vehicle; | ||
669 | } | ||
670 | } | ||
671 | |||
635 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) | 672 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) |
636 | { | 673 | { |
637 | List<string> errorNodeNames; | 674 | List<string> errorNodeNames; |
@@ -801,6 +838,25 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
801 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); | 838 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); |
802 | } | 839 | } |
803 | 840 | ||
841 | private static void ProcessBuoyancy(SceneObjectPart obj, XmlTextReader reader) | ||
842 | { | ||
843 | obj.Buoyancy = (float)reader.ReadElementContentAsFloat("Buoyancy", String.Empty); | ||
844 | } | ||
845 | |||
846 | private static void ProcessForce(SceneObjectPart obj, XmlTextReader reader) | ||
847 | { | ||
848 | obj.Force = Util.ReadVector(reader, "Force"); | ||
849 | } | ||
850 | private static void ProcessTorque(SceneObjectPart obj, XmlTextReader reader) | ||
851 | { | ||
852 | obj.Torque = Util.ReadVector(reader, "Torque"); | ||
853 | } | ||
854 | |||
855 | private static void ProcessVolumeDetectActive(SceneObjectPart obj, XmlTextReader reader) | ||
856 | { | ||
857 | obj.VolumeDetectActive = Util.ReadBoolean(reader); | ||
858 | } | ||
859 | |||
804 | #endregion | 860 | #endregion |
805 | 861 | ||
806 | #region TaskInventoryXmlProcessors | 862 | #region TaskInventoryXmlProcessors |
@@ -1191,7 +1247,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1191 | 1247 | ||
1192 | if (sog.RootPart.KeyframeMotion != null) | 1248 | if (sog.RootPart.KeyframeMotion != null) |
1193 | { | 1249 | { |
1194 | Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); | 1250 | Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); |
1195 | 1251 | ||
1196 | writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); | 1252 | writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); |
1197 | writer.WriteBase64(data, 0, data.Length); | 1253 | writer.WriteBase64(data, 0, data.Length); |
@@ -1305,6 +1361,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1305 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); | 1361 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); |
1306 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); | 1362 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); |
1307 | 1363 | ||
1364 | writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); | ||
1365 | |||
1366 | WriteVector(writer, "Force", sop.Force); | ||
1367 | WriteVector(writer, "Torque", sop.Torque); | ||
1368 | |||
1369 | writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); | ||
1370 | |||
1371 | if (sop.VehicleParams != null) | ||
1372 | sop.VehicleParams.ToXml2(writer); | ||
1373 | |||
1308 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) | 1374 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) |
1309 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); | 1375 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); |
1310 | if (sop.Density != 1000.0f) | 1376 | if (sop.Density != 1000.0f) |
@@ -1315,6 +1381,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1315 | writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); | 1381 | writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); |
1316 | if (sop.GravityModifier != 1.0f) | 1382 | if (sop.GravityModifier != 1.0f) |
1317 | writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); | 1383 | writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); |
1384 | WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); | ||
1385 | WriteVector(writer, "CameraAtOffset", sop.GetCameraAtOffset()); | ||
1318 | 1386 | ||
1319 | writer.WriteEndElement(); | 1387 | writer.WriteEndElement(); |
1320 | } | 1388 | } |
@@ -1540,12 +1608,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1540 | { | 1608 | { |
1541 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); | 1609 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); |
1542 | 1610 | ||
1543 | if (reader.IsEmptyElement) | ||
1544 | { | ||
1545 | reader.Read(); | ||
1546 | return tinv; | ||
1547 | } | ||
1548 | |||
1549 | reader.ReadStartElement(name, String.Empty); | 1611 | reader.ReadStartElement(name, String.Empty); |
1550 | 1612 | ||
1551 | while (reader.Name == "TaskInventoryItem") | 1613 | while (reader.Name == "TaskInventoryItem") |
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 95f9caf..bf32251 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |||
@@ -175,7 +175,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
175 | 175 | ||
176 | // saved last reported value so there is something available for llGetRegionFPS | 176 | // saved last reported value so there is something available for llGetRegionFPS |
177 | private float lastReportedSimFPS; | 177 | private float lastReportedSimFPS; |
178 | private float[] lastReportedSimStats = new float[22]; | 178 | private float[] lastReportedSimStats = new float[23]; |
179 | private float m_pfps; | 179 | private float m_pfps; |
180 | 180 | ||
181 | /// <summary> | 181 | /// <summary> |
@@ -189,12 +189,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
189 | private int m_objectUpdates; | 189 | private int m_objectUpdates; |
190 | 190 | ||
191 | private int m_frameMS; | 191 | private int m_frameMS; |
192 | private int m_spareMS; | 192 | |
193 | private int m_netMS; | 193 | private int m_netMS; |
194 | private int m_agentMS; | 194 | private int m_agentMS; |
195 | private int m_physicsMS; | 195 | private int m_physicsMS; |
196 | private int m_imageMS; | 196 | private int m_imageMS; |
197 | private int m_otherMS; | 197 | private int m_otherMS; |
198 | private int m_sleeptimeMS; | ||
198 | 199 | ||
199 | //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. | 200 | //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. |
200 | //Ckrinke private int m_scriptMS = 0; | 201 | //Ckrinke private int m_scriptMS = 0; |
@@ -292,7 +293,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
292 | if (!m_scene.Active) | 293 | if (!m_scene.Active) |
293 | return; | 294 | return; |
294 | 295 | ||
295 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; | 296 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; |
296 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); | 297 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); |
297 | 298 | ||
298 | // Know what's not thread safe in Mono... modifying timers. | 299 | // Know what's not thread safe in Mono... modifying timers. |
@@ -330,6 +331,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
330 | physfps = 0; | 331 | physfps = 0; |
331 | 332 | ||
332 | #endregion | 333 | #endregion |
334 | float factor = 1 / m_statsUpdateFactor; | ||
335 | |||
336 | if (reportedFPS <= 0) | ||
337 | reportedFPS = 1; | ||
338 | |||
339 | float perframe = 1.0f / (float)reportedFPS; | ||
340 | |||
341 | float TotalFrameTime = m_frameMS * perframe; | ||
342 | |||
343 | float targetframetime = 1100.0f / (float)m_nominalReportedFps; | ||
344 | |||
345 | float sparetime; | ||
346 | float sleeptime; | ||
347 | |||
348 | if (TotalFrameTime > targetframetime) | ||
349 | { | ||
350 | sparetime = 0; | ||
351 | sleeptime = 0; | ||
352 | } | ||
353 | else | ||
354 | { | ||
355 | sparetime = m_frameMS - m_physicsMS - m_agentMS; | ||
356 | sparetime *= perframe; | ||
357 | if (sparetime < 0) | ||
358 | sparetime = 0; | ||
359 | else if (sparetime > TotalFrameTime) | ||
360 | sparetime = TotalFrameTime; | ||
361 | sleeptime = m_sleeptimeMS * perframe; | ||
362 | } | ||
333 | 363 | ||
334 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); | 364 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); |
335 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); | 365 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); |
@@ -341,25 +371,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
341 | // so that stat numbers are always consistent. | 371 | // so that stat numbers are always consistent. |
342 | CheckStatSanity(); | 372 | CheckStatSanity(); |
343 | 373 | ||
344 | //Our time dilation is 0.91 when we're running a full speed, | 374 | // other MS is actually simulation time |
345 | // therefore to make sure we get an appropriate range, | 375 | // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; |
346 | // we have to factor in our error. (0.10f * statsUpdateFactor) | 376 | // m_imageMS m_netMS are not included in m_frameMS |
347 | // multiplies the fix for the error times the amount of times it'll occur a second | ||
348 | // / 10 divides the value by the number of times the sim heartbeat runs (10fps) | ||
349 | // Then we divide the whole amount by the amount of seconds pass in between stats updates. | ||
350 | |||
351 | // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change | ||
352 | // values to X-per-second values. | ||
353 | 377 | ||
354 | uint thisFrame = m_scene.Frame; | 378 | m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; |
355 | float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; | 379 | if (m_otherMS < 0) |
356 | m_lastUpdateFrame = thisFrame; | 380 | m_otherMS = 0; |
357 | 381 | ||
358 | // Avoid div-by-zero if somehow we've not updated any frames. | 382 | for (int i = 0; i < 23; i++) |
359 | if (framesUpdated == 0) | ||
360 | framesUpdated = 1; | ||
361 | |||
362 | for (int i = 0; i < 22; i++) | ||
363 | { | 383 | { |
364 | sb[i] = new SimStatsPacket.StatBlock(); | 384 | sb[i] = new SimStatsPacket.StatBlock(); |
365 | } | 385 | } |
@@ -389,19 +409,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
389 | sb[7].StatValue = m_activePrim; | 409 | sb[7].StatValue = m_activePrim; |
390 | 410 | ||
391 | sb[8].StatID = (uint)Stats.FrameMS; | 411 | sb[8].StatID = (uint)Stats.FrameMS; |
392 | sb[8].StatValue = m_frameMS / framesUpdated; | 412 | sb[8].StatValue = TotalFrameTime; |
393 | 413 | ||
394 | sb[9].StatID = (uint)Stats.NetMS; | 414 | sb[9].StatID = (uint)Stats.NetMS; |
395 | sb[9].StatValue = m_netMS / framesUpdated; | 415 | sb[9].StatValue = m_netMS * perframe; |
396 | 416 | ||
397 | sb[10].StatID = (uint)Stats.PhysicsMS; | 417 | sb[10].StatID = (uint)Stats.PhysicsMS; |
398 | sb[10].StatValue = m_physicsMS / framesUpdated; | 418 | sb[10].StatValue = m_physicsMS * perframe; |
399 | 419 | ||
400 | sb[11].StatID = (uint)Stats.ImageMS ; | 420 | sb[11].StatID = (uint)Stats.ImageMS ; |
401 | sb[11].StatValue = m_imageMS / framesUpdated; | 421 | sb[11].StatValue = m_imageMS * perframe; |
402 | 422 | ||
403 | sb[12].StatID = (uint)Stats.OtherMS; | 423 | sb[12].StatID = (uint)Stats.OtherMS; |
404 | sb[12].StatValue = m_otherMS / framesUpdated; | 424 | sb[12].StatValue = m_otherMS * perframe; |
405 | 425 | ||
406 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; | 426 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; |
407 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); | 427 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); |
@@ -413,7 +433,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
413 | sb[15].StatValue = m_unAckedBytes; | 433 | sb[15].StatValue = m_unAckedBytes; |
414 | 434 | ||
415 | sb[16].StatID = (uint)Stats.AgentMS; | 435 | sb[16].StatID = (uint)Stats.AgentMS; |
416 | sb[16].StatValue = m_agentMS / framesUpdated; | 436 | sb[16].StatValue = m_agentMS * perframe; |
417 | 437 | ||
418 | sb[17].StatID = (uint)Stats.PendingDownloads; | 438 | sb[17].StatID = (uint)Stats.PendingDownloads; |
419 | sb[17].StatValue = m_pendingDownloads; | 439 | sb[17].StatValue = m_pendingDownloads; |
@@ -428,7 +448,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
428 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; | 448 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; |
429 | 449 | ||
430 | sb[21].StatID = (uint)Stats.SimSpareMs; | 450 | sb[21].StatID = (uint)Stats.SimSpareMs; |
431 | sb[21].StatValue = m_spareMS / framesUpdated; | 451 | sb[21].StatValue = sparetime; |
452 | |||
453 | sb[22].StatID = (uint)Stats.SimSleepMs; | ||
454 | sb[22].StatValue = sleeptime; | ||
432 | 455 | ||
433 | for (int i = 0; i < 22; i++) | 456 | for (int i = 0; i < 22; i++) |
434 | { | 457 | { |
@@ -447,28 +470,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
447 | } | 470 | } |
448 | 471 | ||
449 | // Extra statistics that aren't currently sent to clients | 472 | // Extra statistics that aren't currently sent to clients |
450 | lock (m_lastReportedExtraSimStats) | 473 | if (m_scene.PhysicsScene != null) |
451 | { | 474 | { |
452 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; | 475 | lock (m_lastReportedExtraSimStats) |
453 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
454 | |||
455 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
456 | |||
457 | if (physicsStats != null) | ||
458 | { | 476 | { |
459 | foreach (KeyValuePair<string, float> tuple in physicsStats) | 477 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; |
478 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
479 | |||
480 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
481 | |||
482 | if (physicsStats != null) | ||
460 | { | 483 | { |
461 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second | 484 | foreach (KeyValuePair<string, float> tuple in physicsStats) |
462 | // Need to change things so that stats source can indicate whether they are per second or | 485 | { |
463 | // per frame. | 486 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second |
464 | if (tuple.Key.EndsWith("MS")) | 487 | // Need to change things so that stats source can indicate whether they are per second or |
465 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; | 488 | // per frame. |
466 | else | 489 | if (tuple.Key.EndsWith("MS")) |
467 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | 490 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; |
491 | else | ||
492 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | ||
493 | } | ||
468 | } | 494 | } |
469 | } | 495 | } |
470 | } | 496 | } |
471 | 497 | ||
498 | // LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor; | ||
472 | ResetValues(); | 499 | ResetValues(); |
473 | } | 500 | } |
474 | } | 501 | } |
@@ -491,7 +518,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
491 | m_physicsMS = 0; | 518 | m_physicsMS = 0; |
492 | m_imageMS = 0; | 519 | m_imageMS = 0; |
493 | m_otherMS = 0; | 520 | m_otherMS = 0; |
494 | m_spareMS = 0; | 521 | // m_spareMS = 0; |
522 | m_sleeptimeMS = 0; | ||
495 | 523 | ||
496 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. | 524 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. |
497 | //Ckrinke m_scriptMS = 0; | 525 | //Ckrinke m_scriptMS = 0; |
@@ -575,11 +603,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
575 | SlowFramesStat.Value++; | 603 | SlowFramesStat.Value++; |
576 | } | 604 | } |
577 | 605 | ||
578 | public void AddSpareMS(int ms) | ||
579 | { | ||
580 | m_spareMS += ms; | ||
581 | } | ||
582 | |||
583 | public void addNetMS(int ms) | 606 | public void addNetMS(int ms) |
584 | { | 607 | { |
585 | m_netMS += ms; | 608 | m_netMS += ms; |
@@ -605,6 +628,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
605 | m_otherMS += ms; | 628 | m_otherMS += ms; |
606 | } | 629 | } |
607 | 630 | ||
631 | public void addSleepMS(int ms) | ||
632 | { | ||
633 | m_sleeptimeMS += ms; | ||
634 | } | ||
635 | |||
608 | public void AddPendingDownloads(int count) | 636 | public void AddPendingDownloads(int count) |
609 | { | 637 | { |
610 | m_pendingDownloads += count; | 638 | m_pendingDownloads += count; |
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index c0ca48e..b6e0a97 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs | |||
@@ -131,7 +131,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
131 | 131 | ||
132 | public double this[int x, int y] | 132 | public double this[int x, int y] |
133 | { | 133 | { |
134 | get { return map[x, y]; } | 134 | get |
135 | { | ||
136 | if (x < 0) x = 0; | ||
137 | if (y < 0) y = 0; | ||
138 | if (x >= (int)Constants.RegionSize) x = (int)Constants.RegionSize - 1; | ||
139 | if (y >= (int)Constants.RegionSize) y = (int)Constants.RegionSize - 1; | ||
140 | |||
141 | return map[x, y]; | ||
142 | } | ||
135 | set | 143 | set |
136 | { | 144 | { |
137 | // Will "fix" terrain hole problems. Although not fantastically. | 145 | // Will "fix" terrain hole problems. Although not fantastically. |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index c264433..1182c96 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs | |||
@@ -62,6 +62,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
62 | Assert.That(g1Post.RootPart.Scale.X, Is.EqualTo(2)); | 62 | Assert.That(g1Post.RootPart.Scale.X, Is.EqualTo(2)); |
63 | Assert.That(g1Post.RootPart.Scale.Y, Is.EqualTo(3)); | 63 | Assert.That(g1Post.RootPart.Scale.Y, Is.EqualTo(3)); |
64 | Assert.That(g1Post.RootPart.Scale.Z, Is.EqualTo(4)); | 64 | Assert.That(g1Post.RootPart.Scale.Z, Is.EqualTo(4)); |
65 | |||
66 | Assert.That(g1Post.RootPart.UndoCount, Is.EqualTo(1)); | ||
65 | } | 67 | } |
66 | 68 | ||
67 | /// <summary> | 69 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs deleted file mode 100644 index 4883ae7..0000000 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs +++ /dev/null | |||
@@ -1,184 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using NUnit.Framework; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Communications; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Tests.Common; | ||
36 | using OpenSim.Tests.Common.Mock; | ||
37 | |||
38 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Tests for undo/redo | ||
42 | /// </summary> | ||
43 | public class SceneObjectUndoRedoTests : OpenSimTestCase | ||
44 | { | ||
45 | [Test] | ||
46 | public void TestUndoRedoResizeSceneObject() | ||
47 | { | ||
48 | TestHelpers.InMethod(); | ||
49 | // TestHelpers.EnableLogging(); | ||
50 | |||
51 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
52 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
53 | |||
54 | Scene scene = new SceneHelpers().SetupScene(); | ||
55 | scene.MaxUndoCount = 20; | ||
56 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
57 | |||
58 | // TODO: It happens to be the case that we are not storing undo states for SOPs which are not yet in a SOG, | ||
59 | // which is the way that AddSceneObject() sets up the object (i.e. it creates the SOP first). However, | ||
60 | // this is somewhat by chance. Really, we shouldn't be storing undo states at all if the object is not | ||
61 | // in a scene. | ||
62 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
63 | |||
64 | g1.GroupResize(firstSize); | ||
65 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
66 | |||
67 | g1.GroupResize(secondSize); | ||
68 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2)); | ||
69 | |||
70 | g1.RootPart.Undo(); | ||
71 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
72 | Assert.That(g1.GroupScale, Is.EqualTo(firstSize)); | ||
73 | |||
74 | g1.RootPart.Redo(); | ||
75 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2)); | ||
76 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
77 | } | ||
78 | |||
79 | [Test] | ||
80 | public void TestUndoLimit() | ||
81 | { | ||
82 | TestHelpers.InMethod(); | ||
83 | |||
84 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
85 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
86 | Vector3 thirdSize = new Vector3(8, 9, 10); | ||
87 | Vector3 fourthSize = new Vector3(11, 12, 13); | ||
88 | |||
89 | Scene scene = new SceneHelpers().SetupScene(); | ||
90 | scene.MaxUndoCount = 2; | ||
91 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
92 | |||
93 | g1.GroupResize(firstSize); | ||
94 | g1.GroupResize(secondSize); | ||
95 | g1.GroupResize(thirdSize); | ||
96 | g1.GroupResize(fourthSize); | ||
97 | |||
98 | g1.RootPart.Undo(); | ||
99 | g1.RootPart.Undo(); | ||
100 | g1.RootPart.Undo(); | ||
101 | |||
102 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
103 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
104 | } | ||
105 | |||
106 | [Test] | ||
107 | public void TestNoUndoOnObjectsNotInScene() | ||
108 | { | ||
109 | TestHelpers.InMethod(); | ||
110 | |||
111 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
112 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
113 | // Vector3 thirdSize = new Vector3(8, 9, 10); | ||
114 | // Vector3 fourthSize = new Vector3(11, 12, 13); | ||
115 | |||
116 | Scene scene = new SceneHelpers().SetupScene(); | ||
117 | scene.MaxUndoCount = 20; | ||
118 | SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); | ||
119 | |||
120 | g1.GroupResize(firstSize); | ||
121 | g1.GroupResize(secondSize); | ||
122 | |||
123 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
124 | |||
125 | g1.RootPart.Undo(); | ||
126 | |||
127 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
128 | } | ||
129 | |||
130 | [Test] | ||
131 | public void TestUndoBeyondAvailable() | ||
132 | { | ||
133 | TestHelpers.InMethod(); | ||
134 | |||
135 | Vector3 newSize = new Vector3(2, 3, 4); | ||
136 | |||
137 | Scene scene = new SceneHelpers().SetupScene(); | ||
138 | scene.MaxUndoCount = 20; | ||
139 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
140 | Vector3 originalSize = g1.GroupScale; | ||
141 | |||
142 | g1.RootPart.Undo(); | ||
143 | |||
144 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
145 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
146 | |||
147 | g1.GroupResize(newSize); | ||
148 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
149 | Assert.That(g1.GroupScale, Is.EqualTo(newSize)); | ||
150 | |||
151 | g1.RootPart.Undo(); | ||
152 | g1.RootPart.Undo(); | ||
153 | |||
154 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
155 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
156 | } | ||
157 | |||
158 | [Test] | ||
159 | public void TestRedoBeyondAvailable() | ||
160 | { | ||
161 | TestHelpers.InMethod(); | ||
162 | |||
163 | Vector3 newSize = new Vector3(2, 3, 4); | ||
164 | |||
165 | Scene scene = new SceneHelpers().SetupScene(); | ||
166 | scene.MaxUndoCount = 20; | ||
167 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
168 | Vector3 originalSize = g1.GroupScale; | ||
169 | |||
170 | g1.RootPart.Redo(); | ||
171 | |||
172 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
173 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
174 | |||
175 | g1.GroupResize(newSize); | ||
176 | g1.RootPart.Undo(); | ||
177 | g1.RootPart.Redo(); | ||
178 | g1.RootPart.Redo(); | ||
179 | |||
180 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
181 | Assert.That(g1.GroupScale, Is.EqualTo(newSize)); | ||
182 | } | ||
183 | } | ||
184 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index 2b79271..c7eaff9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs | |||
@@ -44,7 +44,7 @@ using OpenSim.Tests.Common.Mock; | |||
44 | namespace OpenSim.Region.Framework.Scenes.Tests | 44 | namespace OpenSim.Region.Framework.Scenes.Tests |
45 | { | 45 | { |
46 | [TestFixture] | 46 | [TestFixture] |
47 | public class SceneObjectUserGroupTests : OpenSimTestCase | 47 | public class SceneObjectUserGroupTests |
48 | { | 48 | { |
49 | /// <summary> | 49 | /// <summary> |
50 | /// Test share with group object functionality | 50 | /// Test share with group object functionality |
@@ -54,6 +54,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
54 | public void TestShareWithGroup() | 54 | public void TestShareWithGroup() |
55 | { | 55 | { |
56 | TestHelpers.InMethod(); | 56 | TestHelpers.InMethod(); |
57 | // log4net.Config.XmlConfigurator.Configure(); | ||
57 | 58 | ||
58 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 59 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
59 | 60 | ||
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 860172c..7bbf1bd 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs | |||
@@ -27,202 +27,307 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | ||
30 | using log4net; | 31 | using log4net; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
33 | 35 | ||
34 | namespace OpenSim.Region.Framework.Scenes | 36 | namespace OpenSim.Region.Framework.Scenes |
35 | { | 37 | { |
36 | public class UndoState | 38 | public class UndoState |
37 | { | 39 | { |
38 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | const int UNDOEXPIRESECONDS = 300; // undo expire time (nice to have it came from a ini later) |
39 | |||
40 | public Vector3 Position = Vector3.Zero; | ||
41 | public Vector3 Scale = Vector3.Zero; | ||
42 | public Quaternion Rotation = Quaternion.Identity; | ||
43 | |||
44 | /// <summary> | ||
45 | /// Is this undo state for an entire group? | ||
46 | /// </summary> | ||
47 | public bool ForGroup; | ||
48 | 41 | ||
42 | public ObjectChangeData data; | ||
43 | public DateTime creationtime; | ||
49 | /// <summary> | 44 | /// <summary> |
50 | /// Constructor. | 45 | /// Constructor. |
51 | /// </summary> | 46 | /// </summary> |
52 | /// <param name="part"></param> | 47 | /// <param name="part"></param> |
53 | /// <param name="forGroup">True if the undo is for an entire group</param> | 48 | /// <param name="change">bit field with what is changed</param> |
54 | public UndoState(SceneObjectPart part, bool forGroup) | 49 | /// |
50 | public UndoState(SceneObjectPart part, ObjectChangeType change) | ||
55 | { | 51 | { |
56 | if (part.ParentID == 0) | 52 | data = new ObjectChangeData(); |
57 | { | 53 | data.change = change; |
58 | ForGroup = forGroup; | 54 | creationtime = DateTime.UtcNow; |
59 | |||
60 | // if (ForGroup) | ||
61 | Position = part.ParentGroup.AbsolutePosition; | ||
62 | // else | ||
63 | // Position = part.OffsetPosition; | ||
64 | |||
65 | // m_log.DebugFormat( | ||
66 | // "[UNDO STATE]: Storing undo position {0} for root part", Position); | ||
67 | 55 | ||
68 | Rotation = part.RotationOffset; | 56 | if (part.ParentGroup.RootPart == part) |
69 | 57 | { | |
70 | // m_log.DebugFormat( | 58 | if ((change & ObjectChangeType.Position) != 0) |
71 | // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); | 59 | data.position = part.ParentGroup.AbsolutePosition; |
72 | 60 | if ((change & ObjectChangeType.Rotation) != 0) | |
73 | Scale = part.Shape.Scale; | 61 | data.rotation = part.RotationOffset; |
74 | 62 | if ((change & ObjectChangeType.Scale) != 0) | |
75 | // m_log.DebugFormat( | 63 | data.scale = part.Shape.Scale; |
76 | // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); | ||
77 | } | 64 | } |
78 | else | 65 | else |
79 | { | 66 | { |
80 | Position = part.OffsetPosition; | 67 | if ((change & ObjectChangeType.Position) != 0) |
81 | // m_log.DebugFormat( | 68 | data.position = part.OffsetPosition; |
82 | // "[UNDO STATE]: Storing undo position {0} for child part", Position); | 69 | if ((change & ObjectChangeType.Rotation) != 0) |
70 | data.rotation = part.RotationOffset; | ||
71 | if ((change & ObjectChangeType.Scale) != 0) | ||
72 | data.scale = part.Shape.Scale; | ||
73 | } | ||
74 | } | ||
75 | /// <summary> | ||
76 | /// check if undo or redo is too old | ||
77 | /// </summary> | ||
83 | 78 | ||
84 | Rotation = part.RotationOffset; | 79 | public bool checkExpire() |
85 | // m_log.DebugFormat( | 80 | { |
86 | // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); | 81 | TimeSpan t = DateTime.UtcNow - creationtime; |
82 | if (t.Seconds > UNDOEXPIRESECONDS) | ||
83 | return true; | ||
84 | return false; | ||
85 | } | ||
87 | 86 | ||
88 | Scale = part.Shape.Scale; | 87 | /// <summary> |
89 | // m_log.DebugFormat( | 88 | /// updates undo or redo creation time to now |
90 | // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); | 89 | /// </summary> |
91 | } | 90 | public void updateExpire() |
91 | { | ||
92 | creationtime = DateTime.UtcNow; | ||
92 | } | 93 | } |
93 | 94 | ||
94 | /// <summary> | 95 | /// <summary> |
95 | /// Compare the relevant state in the given part to this state. | 96 | /// Compare the relevant state in the given part to this state. |
96 | /// </summary> | 97 | /// </summary> |
97 | /// <param name="part"></param> | 98 | /// <param name="part"></param> |
98 | /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns> | 99 | /// <returns>true what fiels and related data are equal, False otherwise.</returns> |
99 | public bool Compare(SceneObjectPart part) | 100 | /// |
101 | public bool Compare(SceneObjectPart part, ObjectChangeType change) | ||
100 | { | 102 | { |
103 | if (data.change != change) // if diferent targets, then they are diferent | ||
104 | return false; | ||
105 | |||
101 | if (part != null) | 106 | if (part != null) |
102 | { | 107 | { |
103 | if (part.ParentID == 0) | 108 | if (part.ParentID == 0) |
104 | return | 109 | { |
105 | Position == part.ParentGroup.AbsolutePosition | 110 | if ((change & ObjectChangeType.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition) |
106 | && Rotation == part.RotationOffset | 111 | return false; |
107 | && Scale == part.Shape.Scale; | 112 | } |
108 | else | 113 | else |
109 | return | 114 | { |
110 | Position == part.OffsetPosition | 115 | if ((change & ObjectChangeType.Position) != 0 && data.position != part.OffsetPosition) |
111 | && Rotation == part.RotationOffset | 116 | return false; |
112 | && Scale == part.Shape.Scale; | 117 | } |
113 | } | 118 | |
119 | if ((change & ObjectChangeType.Rotation) != 0 && data.rotation != part.RotationOffset) | ||
120 | return false; | ||
121 | if ((change & ObjectChangeType.Rotation) != 0 && data.scale == part.Shape.Scale) | ||
122 | return false; | ||
123 | return true; | ||
114 | 124 | ||
125 | } | ||
115 | return false; | 126 | return false; |
116 | } | 127 | } |
117 | 128 | ||
118 | public void PlaybackState(SceneObjectPart part) | 129 | /// <summary> |
130 | /// executes the undo or redo to a part or its group | ||
131 | /// </summary> | ||
132 | /// <param name="part"></param> | ||
133 | /// | ||
134 | |||
135 | public void PlayState(SceneObjectPart part) | ||
119 | { | 136 | { |
120 | part.Undoing = true; | 137 | part.Undoing = true; |
121 | 138 | ||
122 | if (part.ParentID == 0) | 139 | SceneObjectGroup grp = part.ParentGroup; |
123 | { | ||
124 | // m_log.DebugFormat( | ||
125 | // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", | ||
126 | // Position, part.Name, part.LocalId); | ||
127 | 140 | ||
128 | if (Position != Vector3.Zero) | 141 | if (grp != null) |
129 | { | 142 | { |
130 | if (ForGroup) | 143 | grp.doChangeObject(part, data); |
131 | part.ParentGroup.AbsolutePosition = Position; | 144 | } |
132 | else | 145 | part.Undoing = false; |
133 | part.ParentGroup.UpdateRootPosition(Position); | 146 | } |
134 | } | 147 | } |
135 | 148 | ||
136 | // m_log.DebugFormat( | 149 | public class UndoRedoState |
137 | // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", | 150 | { |
138 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | 151 | int size; |
152 | public LinkedList<UndoState> m_redo = new LinkedList<UndoState>(); | ||
153 | public LinkedList<UndoState> m_undo = new LinkedList<UndoState>(); | ||
139 | 154 | ||
140 | if (ForGroup) | 155 | /// <summary> |
141 | part.UpdateRotation(Rotation); | 156 | /// creates a new UndoRedoState with default states memory size |
142 | else | 157 | /// </summary> |
143 | part.ParentGroup.UpdateRootRotation(Rotation); | ||
144 | 158 | ||
145 | if (Scale != Vector3.Zero) | 159 | public UndoRedoState() |
146 | { | 160 | { |
147 | // m_log.DebugFormat( | 161 | size = 5; |
148 | // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", | 162 | } |
149 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | ||
150 | 163 | ||
151 | if (ForGroup) | 164 | /// <summary> |
152 | part.ParentGroup.GroupResize(Scale); | 165 | /// creates a new UndoRedoState with states memory having indicated size |
153 | else | 166 | /// </summary> |
154 | part.Resize(Scale); | 167 | /// <param name="size"></param> |
155 | } | ||
156 | 168 | ||
157 | part.ParentGroup.ScheduleGroupForTerseUpdate(); | 169 | public UndoRedoState(int _size) |
158 | } | 170 | { |
171 | if (_size < 3) | ||
172 | size = 3; | ||
159 | else | 173 | else |
160 | { | 174 | size = _size; |
161 | // Note: Updating these properties on sop automatically schedules an update if needed | 175 | } |
162 | if (Position != Vector3.Zero) | ||
163 | { | ||
164 | // m_log.DebugFormat( | ||
165 | // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", | ||
166 | // part.OffsetPosition, Position, part.Name, part.LocalId); | ||
167 | 176 | ||
168 | part.OffsetPosition = Position; | 177 | /// <summary> |
169 | } | 178 | /// returns number of undo entries in memory |
179 | /// </summary> | ||
170 | 180 | ||
171 | // m_log.DebugFormat( | 181 | public int Count |
172 | // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", | 182 | { |
173 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | 183 | get { return m_undo.Count; } |
184 | } | ||
174 | 185 | ||
175 | part.UpdateRotation(Rotation); | 186 | /// <summary> |
187 | /// clears all undo and redo entries | ||
188 | /// </summary> | ||
176 | 189 | ||
177 | if (Scale != Vector3.Zero) | 190 | public void Clear() |
191 | { | ||
192 | m_undo.Clear(); | ||
193 | m_redo.Clear(); | ||
194 | } | ||
195 | |||
196 | /// <summary> | ||
197 | /// adds a new state undo to part or its group, with changes indicated by what bits | ||
198 | /// </summary> | ||
199 | /// <param name="part"></param> | ||
200 | /// <param name="change">bit field with what is changed</param> | ||
201 | |||
202 | public void StoreUndo(SceneObjectPart part, ObjectChangeType change) | ||
203 | { | ||
204 | lock (m_undo) | ||
205 | { | ||
206 | UndoState last; | ||
207 | |||
208 | if (m_redo.Count > 0) // last code seems to clear redo on every new undo | ||
178 | { | 209 | { |
179 | // m_log.DebugFormat( | 210 | m_redo.Clear(); |
180 | // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", | 211 | } |
181 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | ||
182 | 212 | ||
183 | part.Resize(Scale); | 213 | if (m_undo.Count > 0) |
214 | { | ||
215 | // check expired entry | ||
216 | last = m_undo.First.Value; | ||
217 | if (last != null && last.checkExpire()) | ||
218 | m_undo.Clear(); | ||
219 | else | ||
220 | { | ||
221 | // see if we actually have a change | ||
222 | if (last != null) | ||
223 | { | ||
224 | if (last.Compare(part, change)) | ||
225 | return; | ||
226 | } | ||
227 | } | ||
184 | } | 228 | } |
185 | } | ||
186 | 229 | ||
187 | part.Undoing = false; | 230 | // limite size |
231 | while (m_undo.Count >= size) | ||
232 | m_undo.RemoveLast(); | ||
233 | |||
234 | UndoState nUndo = new UndoState(part, change); | ||
235 | m_undo.AddFirst(nUndo); | ||
236 | } | ||
188 | } | 237 | } |
189 | 238 | ||
190 | public void PlayfwdState(SceneObjectPart part) | 239 | /// <summary> |
191 | { | 240 | /// executes last state undo to part or its group |
192 | part.Undoing = true; | 241 | /// current state is pushed into redo |
242 | /// </summary> | ||
243 | /// <param name="part"></param> | ||
193 | 244 | ||
194 | if (part.ParentID == 0) | 245 | public void Undo(SceneObjectPart part) |
246 | { | ||
247 | lock (m_undo) | ||
195 | { | 248 | { |
196 | if (Position != Vector3.Zero) | 249 | UndoState nUndo; |
197 | part.ParentGroup.AbsolutePosition = Position; | ||
198 | |||
199 | if (Rotation != Quaternion.Identity) | ||
200 | part.UpdateRotation(Rotation); | ||
201 | 250 | ||
202 | if (Scale != Vector3.Zero) | 251 | // expire redo |
252 | if (m_redo.Count > 0) | ||
203 | { | 253 | { |
204 | if (ForGroup) | 254 | nUndo = m_redo.First.Value; |
205 | part.ParentGroup.GroupResize(Scale); | 255 | if (nUndo != null && nUndo.checkExpire()) |
206 | else | 256 | m_redo.Clear(); |
207 | part.Resize(Scale); | ||
208 | } | 257 | } |
209 | 258 | ||
210 | part.ParentGroup.ScheduleGroupForTerseUpdate(); | 259 | if (m_undo.Count > 0) |
260 | { | ||
261 | UndoState goback = m_undo.First.Value; | ||
262 | // check expired | ||
263 | if (goback != null && goback.checkExpire()) | ||
264 | { | ||
265 | m_undo.Clear(); | ||
266 | return; | ||
267 | } | ||
268 | |||
269 | if (goback != null) | ||
270 | { | ||
271 | m_undo.RemoveFirst(); | ||
272 | |||
273 | // redo limite size | ||
274 | while (m_redo.Count >= size) | ||
275 | m_redo.RemoveLast(); | ||
276 | |||
277 | nUndo = new UndoState(part, goback.data.change); // new value in part should it be full goback copy? | ||
278 | m_redo.AddFirst(nUndo); | ||
279 | |||
280 | goback.PlayState(part); | ||
281 | } | ||
282 | } | ||
211 | } | 283 | } |
212 | else | 284 | } |
285 | |||
286 | /// <summary> | ||
287 | /// executes last state redo to part or its group | ||
288 | /// current state is pushed into undo | ||
289 | /// </summary> | ||
290 | /// <param name="part"></param> | ||
291 | |||
292 | public void Redo(SceneObjectPart part) | ||
293 | { | ||
294 | lock (m_undo) | ||
213 | { | 295 | { |
214 | // Note: Updating these properties on sop automatically schedules an update if needed | 296 | UndoState nUndo; |
215 | if (Position != Vector3.Zero) | ||
216 | part.OffsetPosition = Position; | ||
217 | 297 | ||
218 | if (Rotation != Quaternion.Identity) | 298 | // expire undo |
219 | part.UpdateRotation(Rotation); | 299 | if (m_undo.Count > 0) |
300 | { | ||
301 | nUndo = m_undo.First.Value; | ||
302 | if (nUndo != null && nUndo.checkExpire()) | ||
303 | m_undo.Clear(); | ||
304 | } | ||
220 | 305 | ||
221 | if (Scale != Vector3.Zero) | 306 | if (m_redo.Count > 0) |
222 | part.Resize(Scale); | 307 | { |
308 | UndoState gofwd = m_redo.First.Value; | ||
309 | // check expired | ||
310 | if (gofwd != null && gofwd.checkExpire()) | ||
311 | { | ||
312 | m_redo.Clear(); | ||
313 | return; | ||
314 | } | ||
315 | |||
316 | if (gofwd != null) | ||
317 | { | ||
318 | m_redo.RemoveFirst(); | ||
319 | |||
320 | // limite undo size | ||
321 | while (m_undo.Count >= size) | ||
322 | m_undo.RemoveLast(); | ||
323 | |||
324 | nUndo = new UndoState(part, gofwd.data.change); // new value in part should it be full gofwd copy? | ||
325 | m_undo.AddFirst(nUndo); | ||
326 | |||
327 | gofwd.PlayState(part); | ||
328 | } | ||
329 | } | ||
223 | } | 330 | } |
224 | |||
225 | part.Undoing = false; | ||
226 | } | 331 | } |
227 | } | 332 | } |
228 | 333 | ||
@@ -247,4 +352,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
247 | m_terrainModule.UndoTerrain(m_terrainChannel); | 352 | m_terrainModule.UndoTerrain(m_terrainChannel); |
248 | } | 353 | } |
249 | } | 354 | } |
250 | } \ No newline at end of file | 355 | } |
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 0e83781..7b47275 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -85,10 +85,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
85 | /// <param name="assetUuids">The assets gathered</param> | 85 | /// <param name="assetUuids">The assets gathered</param> |
86 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) | 86 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) |
87 | { | 87 | { |
88 | // avoid infinite loops | ||
89 | if (assetUuids.ContainsKey(assetUuid)) | ||
90 | return; | ||
91 | |||
92 | try | 88 | try |
93 | { | 89 | { |
94 | assetUuids[assetUuid] = assetType; | 90 | assetUuids[assetUuid] = assetType; |