diff options
Diffstat (limited to 'OpenSim/Region/Framework')
43 files changed, 7412 insertions, 2393 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 620ec22..d781eae 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; |
@@ -83,7 +84,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
83 | /// <param name="AttachmentPt"></param> | 84 | /// <param name="AttachmentPt"></param> |
84 | /// <param name="silent"></param> | 85 | /// <param name="silent"></param> |
85 | /// <returns>true if the object was successfully attached, false otherwise</returns> | 86 | /// <returns>true if the object was successfully attached, false otherwise</returns> |
86 | bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool temp); | 87 | bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool useAttachmentInfo, bool temp); |
87 | 88 | ||
88 | /// <summary> | 89 | /// <summary> |
89 | /// Rez an attachment from user inventory and change inventory status to match. | 90 | /// Rez an attachment from user inventory and change inventory status to match. |
@@ -92,7 +93,11 @@ namespace OpenSim.Region.Framework.Interfaces | |||
92 | /// <param name="itemID"></param> | 93 | /// <param name="itemID"></param> |
93 | /// <param name="AttachmentPt"></param> | 94 | /// <param name="AttachmentPt"></param> |
94 | /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> | 95 | /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> |
95 | SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt); | 96 | ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt); |
97 | |||
98 | // Same as above, but also load script states from a separate doc | ||
99 | ISceneEntity RezSingleAttachmentFromInventory( | ||
100 | IScenePresence presence, UUID itemID, uint AttachmentPt, XmlDocument doc); | ||
96 | 101 | ||
97 | /// <summary> | 102 | /// <summary> |
98 | /// Rez multiple attachments from a user's inventory | 103 | /// Rez multiple attachments from a user's inventory |
@@ -124,7 +129,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
124 | /// <param name="grp">The attachment to detach.</param> | 129 | /// <param name="grp">The attachment to detach.</param> |
125 | void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup grp); | 130 | void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup grp); |
126 | 131 | ||
127 | /// <summary> | ||
128 | /// Update the position of an attachment. | 132 | /// Update the position of an attachment. |
129 | /// </summary> | 133 | /// </summary> |
130 | /// <param name="sog"></param> | 134 | /// <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/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 69be83e..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,29 +52,10 @@ 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> | 55 | bool TeleportHome(UUID id, IClientAPI client); |
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 | 56 | ||
70 | /// <summary> | 57 | void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, |
71 | /// Teleports the agent for the given client to their home destination. | 58 | Vector3 position, Vector3 lookAt, uint teleportFlags); |
72 | /// </summary> | ||
73 | /// <param name='id'></param> | ||
74 | /// <param name='client'></param> | ||
75 | void TeleportHome(UUID id, IClientAPI client); | ||
76 | 59 | ||
77 | /// <summary> | 60 | /// <summary> |
78 | /// Show whether the given agent is being teleported. | 61 | /// Show whether the given agent is being teleported. |
@@ -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/IEstateModule.cs b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs index 1983984..292efa4 100644 --- a/OpenSim/Region/Framework/Interfaces/IEstateModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEstateModule.cs | |||
@@ -45,6 +45,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
45 | /// Tell all clients about the current state of the region (terrain textures, water height, etc.). | 45 | /// Tell all clients about the current state of the region (terrain textures, water height, etc.). |
46 | /// </summary> | 46 | /// </summary> |
47 | void sendRegionHandshakeToAll(); | 47 | void sendRegionHandshakeToAll(); |
48 | void TriggerEstateInfoChange(); | ||
48 | 49 | ||
49 | /// <summary> | 50 | /// <summary> |
50 | /// Fires the OnRegionInfoChange event. | 51 | /// Fires the OnRegionInfoChange event. |
diff --git a/OpenSim/Region/Framework/Interfaces/IEventQueue.cs b/OpenSim/Region/Framework/Interfaces/IEventQueue.cs index bfa5d17..5512642 100644 --- a/OpenSim/Region/Framework/Interfaces/IEventQueue.cs +++ b/OpenSim/Region/Framework/Interfaces/IEventQueue.cs | |||
@@ -59,5 +59,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
59 | void GroupMembership(AgentGroupDataUpdatePacket groupUpdate, UUID avatarID); | 59 | void GroupMembership(AgentGroupDataUpdatePacket groupUpdate, UUID avatarID); |
60 | OSD ScriptRunningEvent(UUID objectID, UUID itemID, bool running, bool mono); | 60 | OSD ScriptRunningEvent(UUID objectID, UUID itemID, bool running, bool mono); |
61 | OSD BuildEvent(string eventName, OSD eventBody); | 61 | OSD BuildEvent(string eventName, OSD eventBody); |
62 | void partPhysicsProperties(uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID); | ||
63 | |||
62 | } | 64 | } |
63 | } | 65 | } |
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 e92a087..65c279e 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}", |
@@ -134,6 +135,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
134 | SendAnimPack(); | 135 | SendAnimPack(); |
135 | } | 136 | } |
136 | 137 | ||
138 | public void avnChangeAnim(UUID animID, bool addRemove, bool sendPack) | ||
139 | { | ||
140 | if (m_scenePresence.IsChildAgent) | ||
141 | return; | ||
142 | |||
143 | if (animID != UUID.Zero) | ||
144 | { | ||
145 | if (addRemove) | ||
146 | m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero); | ||
147 | else | ||
148 | m_animations.Remove(animID, true); | ||
149 | } | ||
150 | if(sendPack) | ||
151 | SendAnimPack(); | ||
152 | } | ||
153 | |||
137 | // Called from scripts | 154 | // Called from scripts |
138 | public void RemoveAnimation(string name) | 155 | public void RemoveAnimation(string name) |
139 | { | 156 | { |
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 9ee1520..052a05e 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 | ||
@@ -829,6 +830,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
829 | public event ParcelPrimCountTainted OnParcelPrimCountTainted; | 830 | public event ParcelPrimCountTainted OnParcelPrimCountTainted; |
830 | public event GetScriptRunning OnGetScriptRunning; | 831 | public event GetScriptRunning OnGetScriptRunning; |
831 | 832 | ||
833 | public delegate void ThrottleUpdate(ScenePresence scenePresence); | ||
834 | |||
835 | public event ThrottleUpdate OnThrottleUpdate; | ||
836 | |||
832 | /// <summary> | 837 | /// <summary> |
833 | /// RegisterCapsEvent is called by Scene after the Caps object | 838 | /// RegisterCapsEvent is called by Scene after the Caps object |
834 | /// has been instantiated and before it is return to the | 839 | /// has been instantiated and before it is return to the |
@@ -1410,6 +1415,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1410 | } | 1415 | } |
1411 | } | 1416 | } |
1412 | } | 1417 | } |
1418 | public void TriggerTerrainUpdate() | ||
1419 | { | ||
1420 | OnTerrainUpdateDelegate handlerTerrainUpdate = OnTerrainUpdate; | ||
1421 | if (handlerTerrainUpdate != null) | ||
1422 | { | ||
1423 | foreach (OnTerrainUpdateDelegate d in handlerTerrainUpdate.GetInvocationList()) | ||
1424 | { | ||
1425 | try | ||
1426 | { | ||
1427 | d(); | ||
1428 | } | ||
1429 | catch (Exception e) | ||
1430 | { | ||
1431 | m_log.ErrorFormat( | ||
1432 | "[EVENT MANAGER]: Delegate for TriggerTerrainUpdate failed - continuing. {0} {1}", | ||
1433 | e.Message, e.StackTrace); | ||
1434 | } | ||
1435 | } | ||
1436 | } | ||
1437 | } | ||
1413 | 1438 | ||
1414 | public void TriggerTerrainTick() | 1439 | public void TriggerTerrainTick() |
1415 | { | 1440 | { |
@@ -1700,6 +1725,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1700 | m_log.ErrorFormat( | 1725 | m_log.ErrorFormat( |
1701 | "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", | 1726 | "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", |
1702 | e.Message, e.StackTrace); | 1727 | e.Message, e.StackTrace); |
1728 | m_log.ErrorFormat(Environment.StackTrace); | ||
1703 | } | 1729 | } |
1704 | } | 1730 | } |
1705 | } | 1731 | } |
@@ -2978,6 +3004,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2978 | { | 3004 | { |
2979 | foreach (Action<Scene> d in handler.GetInvocationList()) | 3005 | foreach (Action<Scene> d in handler.GetInvocationList()) |
2980 | { | 3006 | { |
3007 | m_log.InfoFormat("[EVENT MANAGER]: TriggerSceneShuttingDown invoque {0}", d.Method.Name.ToString()); | ||
2981 | try | 3008 | try |
2982 | { | 3009 | { |
2983 | d(s); | 3010 | d(s); |
@@ -2990,6 +3017,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2990 | } | 3017 | } |
2991 | } | 3018 | } |
2992 | } | 3019 | } |
3020 | m_log.Info("[EVENT MANAGER]: TriggerSceneShuttingDown done"); | ||
2993 | } | 3021 | } |
2994 | 3022 | ||
2995 | public void TriggerOnRegionStarted(Scene scene) | 3023 | public void TriggerOnRegionStarted(Scene scene) |
@@ -3159,5 +3187,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3159 | } | 3187 | } |
3160 | } | 3188 | } |
3161 | } | 3189 | } |
3190 | |||
3191 | public void TriggerThrottleUpdate(ScenePresence scenePresence) | ||
3192 | { | ||
3193 | ThrottleUpdate handler = OnThrottleUpdate; | ||
3194 | if (handler != null) | ||
3195 | { | ||
3196 | handler(scenePresence); | ||
3197 | } | ||
3198 | } | ||
3162 | } | 3199 | } |
3163 | } | 3200 | } |
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs new file mode 100644 index 0000000..5a1fd13 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | |||
@@ -0,0 +1,710 @@ | |||
1 | // Proprietary code of Avination Virtual Limited | ||
2 | // (c) 2012 Melanie Thielker | ||
3 | // | ||
4 | |||
5 | using System; | ||
6 | using System.Timers; | ||
7 | using System.Collections; | ||
8 | using System.Collections.Generic; | ||
9 | using System.IO; | ||
10 | using System.Diagnostics; | ||
11 | using System.Reflection; | ||
12 | using System.Threading; | ||
13 | using OpenMetaverse; | ||
14 | using OpenSim.Framework; | ||
15 | using OpenSim.Region.Framework.Interfaces; | ||
16 | using OpenSim.Region.Physics.Manager; | ||
17 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
18 | using System.Runtime.Serialization.Formatters.Binary; | ||
19 | using System.Runtime.Serialization; | ||
20 | using Timer = System.Timers.Timer; | ||
21 | using log4net; | ||
22 | |||
23 | namespace OpenSim.Region.Framework.Scenes | ||
24 | { | ||
25 | public static class KeyframeTimer | ||
26 | { | ||
27 | private static Timer m_timer; | ||
28 | private static Dictionary<KeyframeMotion, object> m_motions = new Dictionary<KeyframeMotion, object>(); | ||
29 | private static object m_lockObject = new object(); | ||
30 | private static object m_timerLock = new object(); | ||
31 | public const double timerInterval = 50.0; | ||
32 | |||
33 | static KeyframeTimer() | ||
34 | { | ||
35 | m_timer = new Timer(); | ||
36 | m_timer.Interval = timerInterval; | ||
37 | m_timer.AutoReset = true; | ||
38 | m_timer.Elapsed += OnTimer; | ||
39 | |||
40 | m_timer.Start(); | ||
41 | } | ||
42 | |||
43 | private static void OnTimer(object sender, ElapsedEventArgs ea) | ||
44 | { | ||
45 | if (!Monitor.TryEnter(m_timerLock)) | ||
46 | return; | ||
47 | |||
48 | try | ||
49 | { | ||
50 | List<KeyframeMotion> motions; | ||
51 | |||
52 | lock (m_lockObject) | ||
53 | { | ||
54 | motions = new List<KeyframeMotion>(m_motions.Keys); | ||
55 | } | ||
56 | |||
57 | foreach (KeyframeMotion m in motions) | ||
58 | { | ||
59 | try | ||
60 | { | ||
61 | m.OnTimer(); | ||
62 | } | ||
63 | catch (Exception inner) | ||
64 | { | ||
65 | // Don't stop processing | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | catch (Exception e) | ||
70 | { | ||
71 | // Keep running no matter what | ||
72 | } | ||
73 | finally | ||
74 | { | ||
75 | Monitor.Exit(m_timerLock); | ||
76 | } | ||
77 | } | ||
78 | |||
79 | public static void Add(KeyframeMotion motion) | ||
80 | { | ||
81 | lock (m_lockObject) | ||
82 | { | ||
83 | m_motions[motion] = null; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | public static void Remove(KeyframeMotion motion) | ||
88 | { | ||
89 | lock (m_lockObject) | ||
90 | { | ||
91 | m_motions.Remove(motion); | ||
92 | } | ||
93 | } | ||
94 | } | ||
95 | |||
96 | [Serializable] | ||
97 | public class KeyframeMotion | ||
98 | { | ||
99 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
100 | |||
101 | public enum PlayMode : int | ||
102 | { | ||
103 | Forward = 0, | ||
104 | Reverse = 1, | ||
105 | Loop = 2, | ||
106 | PingPong = 3 | ||
107 | }; | ||
108 | |||
109 | [Flags] | ||
110 | public enum DataFormat : int | ||
111 | { | ||
112 | Translation = 2, | ||
113 | Rotation = 1 | ||
114 | } | ||
115 | |||
116 | [Serializable] | ||
117 | public struct Keyframe | ||
118 | { | ||
119 | public Vector3? Position; | ||
120 | public Quaternion? Rotation; | ||
121 | public Quaternion StartRotation; | ||
122 | public int TimeMS; | ||
123 | public int TimeTotal; | ||
124 | public Vector3 AngularVelocity; | ||
125 | }; | ||
126 | |||
127 | private Vector3 m_serializedPosition; | ||
128 | private Vector3 m_basePosition; | ||
129 | private Quaternion m_baseRotation; | ||
130 | |||
131 | private Keyframe m_currentFrame; | ||
132 | |||
133 | private List<Keyframe> m_frames = new List<Keyframe>(); | ||
134 | |||
135 | private Keyframe[] m_keyframes; | ||
136 | |||
137 | // skip timer events. | ||
138 | //timer.stop doesn't assure there aren't event threads still being fired | ||
139 | [NonSerialized()] | ||
140 | private bool m_timerStopped; | ||
141 | |||
142 | [NonSerialized()] | ||
143 | private bool m_isCrossing; | ||
144 | |||
145 | [NonSerialized()] | ||
146 | private bool m_waitingCrossing; | ||
147 | |||
148 | // retry position for cross fail | ||
149 | [NonSerialized()] | ||
150 | private Vector3 m_nextPosition; | ||
151 | |||
152 | [NonSerialized()] | ||
153 | private SceneObjectGroup m_group; | ||
154 | |||
155 | private PlayMode m_mode = PlayMode.Forward; | ||
156 | private DataFormat m_data = DataFormat.Translation | DataFormat.Rotation; | ||
157 | |||
158 | private bool m_running = false; | ||
159 | [NonSerialized()] | ||
160 | private bool m_selected = false; | ||
161 | |||
162 | private int m_iterations = 0; | ||
163 | |||
164 | private int m_skipLoops = 0; | ||
165 | |||
166 | public DataFormat Data | ||
167 | { | ||
168 | get { return m_data; } | ||
169 | } | ||
170 | |||
171 | public bool Selected | ||
172 | { | ||
173 | set | ||
174 | { | ||
175 | if (m_group != null) | ||
176 | { | ||
177 | if (!value) | ||
178 | { | ||
179 | // Once we're let go, recompute positions | ||
180 | if (m_selected) | ||
181 | UpdateSceneObject(m_group); | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | // Save selection position in case we get moved | ||
186 | if (!m_selected) | ||
187 | { | ||
188 | StopTimer(); | ||
189 | m_serializedPosition = m_group.AbsolutePosition; | ||
190 | } | ||
191 | } | ||
192 | } | ||
193 | m_isCrossing = false; | ||
194 | m_waitingCrossing = false; | ||
195 | m_selected = value; | ||
196 | } | ||
197 | } | ||
198 | |||
199 | private void StartTimer() | ||
200 | { | ||
201 | KeyframeTimer.Add(this); | ||
202 | m_timerStopped = false; | ||
203 | } | ||
204 | |||
205 | private void StopTimer() | ||
206 | { | ||
207 | m_timerStopped = true; | ||
208 | KeyframeTimer.Remove(this); | ||
209 | } | ||
210 | |||
211 | public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) | ||
212 | { | ||
213 | KeyframeMotion newMotion = null; | ||
214 | |||
215 | try | ||
216 | { | ||
217 | MemoryStream ms = new MemoryStream(data); | ||
218 | BinaryFormatter fmt = new BinaryFormatter(); | ||
219 | |||
220 | newMotion = (KeyframeMotion)fmt.Deserialize(ms); | ||
221 | |||
222 | newMotion.m_group = grp; | ||
223 | |||
224 | if (grp != null && grp.IsSelected) | ||
225 | newMotion.m_selected = true; | ||
226 | |||
227 | newMotion.m_timerStopped = false; | ||
228 | newMotion.m_isCrossing = false; | ||
229 | newMotion.m_waitingCrossing = false; | ||
230 | } | ||
231 | catch | ||
232 | { | ||
233 | newMotion = null; | ||
234 | } | ||
235 | |||
236 | return newMotion; | ||
237 | } | ||
238 | |||
239 | public void UpdateSceneObject(SceneObjectGroup grp) | ||
240 | { | ||
241 | m_isCrossing = false; | ||
242 | m_waitingCrossing = false; | ||
243 | StopTimer(); | ||
244 | |||
245 | if (grp == null) | ||
246 | return; | ||
247 | |||
248 | m_group = grp; | ||
249 | Vector3 grppos = grp.AbsolutePosition; | ||
250 | Vector3 offset = grppos - m_serializedPosition; | ||
251 | // avoid doing it more than once | ||
252 | // current this will happen draging a prim to other region | ||
253 | m_serializedPosition = grppos; | ||
254 | |||
255 | m_basePosition += offset; | ||
256 | m_currentFrame.Position += offset; | ||
257 | |||
258 | m_nextPosition += offset; | ||
259 | |||
260 | for (int i = 0; i < m_frames.Count; i++) | ||
261 | { | ||
262 | Keyframe k = m_frames[i]; | ||
263 | k.Position += offset; | ||
264 | m_frames[i]=k; | ||
265 | } | ||
266 | |||
267 | if (m_running) | ||
268 | Start(); | ||
269 | } | ||
270 | |||
271 | public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data) | ||
272 | { | ||
273 | m_mode = mode; | ||
274 | m_data = data; | ||
275 | |||
276 | m_group = grp; | ||
277 | if (grp != null) | ||
278 | { | ||
279 | m_basePosition = grp.AbsolutePosition; | ||
280 | m_baseRotation = grp.GroupRotation; | ||
281 | } | ||
282 | |||
283 | m_timerStopped = true; | ||
284 | m_isCrossing = false; | ||
285 | m_waitingCrossing = false; | ||
286 | } | ||
287 | |||
288 | public void SetKeyframes(Keyframe[] frames) | ||
289 | { | ||
290 | m_keyframes = frames; | ||
291 | } | ||
292 | |||
293 | public KeyframeMotion Copy(SceneObjectGroup newgrp) | ||
294 | { | ||
295 | StopTimer(); | ||
296 | |||
297 | KeyframeMotion newmotion = new KeyframeMotion(null, m_mode, m_data); | ||
298 | |||
299 | newmotion.m_group = newgrp; | ||
300 | |||
301 | if (m_keyframes != null) | ||
302 | { | ||
303 | newmotion.m_keyframes = new Keyframe[m_keyframes.Length]; | ||
304 | m_keyframes.CopyTo(newmotion.m_keyframes, 0); | ||
305 | } | ||
306 | |||
307 | newmotion.m_frames = new List<Keyframe>(m_frames); | ||
308 | |||
309 | newmotion.m_basePosition = m_basePosition; | ||
310 | newmotion.m_baseRotation = m_baseRotation; | ||
311 | |||
312 | if (m_selected) | ||
313 | newmotion.m_serializedPosition = m_serializedPosition; | ||
314 | else | ||
315 | { | ||
316 | if (m_group != null) | ||
317 | newmotion.m_serializedPosition = m_group.AbsolutePosition; | ||
318 | else | ||
319 | newmotion.m_serializedPosition = m_serializedPosition; | ||
320 | } | ||
321 | |||
322 | newmotion.m_currentFrame = m_currentFrame; | ||
323 | |||
324 | newmotion.m_iterations = m_iterations; | ||
325 | newmotion.m_running = m_running; | ||
326 | |||
327 | if (m_running && !m_waitingCrossing) | ||
328 | StartTimer(); | ||
329 | |||
330 | return newmotion; | ||
331 | } | ||
332 | |||
333 | public void Delete() | ||
334 | { | ||
335 | m_running = false; | ||
336 | StopTimer(); | ||
337 | m_isCrossing = false; | ||
338 | m_waitingCrossing = false; | ||
339 | m_frames.Clear(); | ||
340 | m_keyframes = null; | ||
341 | } | ||
342 | |||
343 | public void Start() | ||
344 | { | ||
345 | m_isCrossing = false; | ||
346 | m_waitingCrossing = false; | ||
347 | if (m_keyframes != null && m_group != null && m_keyframes.Length > 0) | ||
348 | { | ||
349 | StartTimer(); | ||
350 | m_running = true; | ||
351 | } | ||
352 | else | ||
353 | { | ||
354 | m_running = false; | ||
355 | StopTimer(); | ||
356 | } | ||
357 | } | ||
358 | |||
359 | public void Stop() | ||
360 | { | ||
361 | m_running = false; | ||
362 | m_isCrossing = false; | ||
363 | m_waitingCrossing = false; | ||
364 | |||
365 | StopTimer(); | ||
366 | |||
367 | m_basePosition = m_group.AbsolutePosition; | ||
368 | m_baseRotation = m_group.GroupRotation; | ||
369 | |||
370 | m_group.RootPart.Velocity = Vector3.Zero; | ||
371 | m_group.RootPart.AngularVelocity = Vector3.Zero; | ||
372 | m_group.SendGroupRootTerseUpdate(); | ||
373 | // m_group.RootPart.ScheduleTerseUpdate(); | ||
374 | m_frames.Clear(); | ||
375 | } | ||
376 | |||
377 | public void Pause() | ||
378 | { | ||
379 | m_running = false; | ||
380 | StopTimer(); | ||
381 | |||
382 | m_group.RootPart.Velocity = Vector3.Zero; | ||
383 | m_group.RootPart.AngularVelocity = Vector3.Zero; | ||
384 | m_group.SendGroupRootTerseUpdate(); | ||
385 | // m_group.RootPart.ScheduleTerseUpdate(); | ||
386 | |||
387 | } | ||
388 | |||
389 | private void GetNextList() | ||
390 | { | ||
391 | m_frames.Clear(); | ||
392 | Vector3 pos = m_basePosition; | ||
393 | Quaternion rot = m_baseRotation; | ||
394 | |||
395 | if (m_mode == PlayMode.Loop || m_mode == PlayMode.PingPong || m_iterations == 0) | ||
396 | { | ||
397 | int direction = 1; | ||
398 | if (m_mode == PlayMode.Reverse || ((m_mode == PlayMode.PingPong) && ((m_iterations & 1) != 0))) | ||
399 | direction = -1; | ||
400 | |||
401 | int start = 0; | ||
402 | int end = m_keyframes.Length; | ||
403 | |||
404 | if (direction < 0) | ||
405 | { | ||
406 | start = m_keyframes.Length - 1; | ||
407 | end = -1; | ||
408 | } | ||
409 | |||
410 | for (int i = start; i != end ; i += direction) | ||
411 | { | ||
412 | Keyframe k = m_keyframes[i]; | ||
413 | |||
414 | if (k.Position.HasValue) | ||
415 | { | ||
416 | k.Position = (k.Position * direction); | ||
417 | // k.Velocity = (Vector3)k.Position / (k.TimeMS / 1000.0f); | ||
418 | k.Position += pos; | ||
419 | } | ||
420 | else | ||
421 | { | ||
422 | k.Position = pos; | ||
423 | // k.Velocity = Vector3.Zero; | ||
424 | } | ||
425 | |||
426 | k.StartRotation = rot; | ||
427 | if (k.Rotation.HasValue) | ||
428 | { | ||
429 | if (direction == -1) | ||
430 | k.Rotation = Quaternion.Conjugate((Quaternion)k.Rotation); | ||
431 | k.Rotation = rot * k.Rotation; | ||
432 | } | ||
433 | else | ||
434 | { | ||
435 | k.Rotation = rot; | ||
436 | } | ||
437 | |||
438 | /* ang vel not in use for now | ||
439 | |||
440 | float angle = 0; | ||
441 | |||
442 | float aa = k.StartRotation.X * k.StartRotation.X + k.StartRotation.Y * k.StartRotation.Y + k.StartRotation.Z * k.StartRotation.Z + k.StartRotation.W * k.StartRotation.W; | ||
443 | float bb = ((Quaternion)k.Rotation).X * ((Quaternion)k.Rotation).X + ((Quaternion)k.Rotation).Y * ((Quaternion)k.Rotation).Y + ((Quaternion)k.Rotation).Z * ((Quaternion)k.Rotation).Z + ((Quaternion)k.Rotation).W * ((Quaternion)k.Rotation).W; | ||
444 | float aa_bb = aa * bb; | ||
445 | |||
446 | if (aa_bb == 0) | ||
447 | { | ||
448 | angle = 0; | ||
449 | } | ||
450 | else | ||
451 | { | ||
452 | float ab = k.StartRotation.X * ((Quaternion)k.Rotation).X + | ||
453 | k.StartRotation.Y * ((Quaternion)k.Rotation).Y + | ||
454 | k.StartRotation.Z * ((Quaternion)k.Rotation).Z + | ||
455 | k.StartRotation.W * ((Quaternion)k.Rotation).W; | ||
456 | float q = (ab * ab) / aa_bb; | ||
457 | |||
458 | if (q > 1.0f) | ||
459 | { | ||
460 | angle = 0; | ||
461 | } | ||
462 | else | ||
463 | { | ||
464 | angle = (float)Math.Acos(2 * q - 1); | ||
465 | } | ||
466 | } | ||
467 | |||
468 | k.AngularVelocity = (new Vector3(0, 0, 1) * (Quaternion)k.Rotation) * (angle / (k.TimeMS / 1000)); | ||
469 | */ | ||
470 | k.TimeTotal = k.TimeMS; | ||
471 | |||
472 | m_frames.Add(k); | ||
473 | |||
474 | pos = (Vector3)k.Position; | ||
475 | rot = (Quaternion)k.Rotation; | ||
476 | } | ||
477 | |||
478 | m_basePosition = pos; | ||
479 | m_baseRotation = rot; | ||
480 | |||
481 | m_iterations++; | ||
482 | } | ||
483 | } | ||
484 | |||
485 | public void OnTimer() | ||
486 | { | ||
487 | if (m_skipLoops > 0) | ||
488 | { | ||
489 | m_skipLoops--; | ||
490 | return; | ||
491 | } | ||
492 | |||
493 | if (m_timerStopped) // trap events still in air even after a timer.stop | ||
494 | return; | ||
495 | |||
496 | if (m_group == null) | ||
497 | return; | ||
498 | |||
499 | bool update = false; | ||
500 | |||
501 | if (m_selected) | ||
502 | { | ||
503 | if (m_group.RootPart.Velocity != Vector3.Zero) | ||
504 | { | ||
505 | m_group.RootPart.Velocity = Vector3.Zero; | ||
506 | m_group.SendGroupRootTerseUpdate(); | ||
507 | |||
508 | } | ||
509 | return; | ||
510 | } | ||
511 | |||
512 | if (m_isCrossing) | ||
513 | { | ||
514 | // if crossing and timer running then cross failed | ||
515 | // wait some time then | ||
516 | // retry to set the position that evtually caused the outbound | ||
517 | // if still outside region this will call startCrossing below | ||
518 | m_isCrossing = false; | ||
519 | m_group.AbsolutePosition = m_nextPosition; | ||
520 | if (!m_isCrossing) | ||
521 | { | ||
522 | StopTimer(); | ||
523 | StartTimer(); | ||
524 | } | ||
525 | return; | ||
526 | } | ||
527 | |||
528 | if (m_frames.Count == 0) | ||
529 | { | ||
530 | GetNextList(); | ||
531 | |||
532 | if (m_frames.Count == 0) | ||
533 | { | ||
534 | Stop(); | ||
535 | Scene scene = m_group.Scene; | ||
536 | |||
537 | IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>(); | ||
538 | foreach (IScriptModule m in scriptModules) | ||
539 | { | ||
540 | if (m == null) | ||
541 | continue; | ||
542 | m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]); | ||
543 | } | ||
544 | |||
545 | return; | ||
546 | } | ||
547 | |||
548 | m_currentFrame = m_frames[0]; | ||
549 | m_currentFrame.TimeMS += (int)KeyframeTimer.timerInterval; | ||
550 | |||
551 | //force a update on a keyframe transition | ||
552 | update = true; | ||
553 | } | ||
554 | |||
555 | m_currentFrame.TimeMS -= (int)KeyframeTimer.timerInterval; | ||
556 | |||
557 | // Do the frame processing | ||
558 | double steps = (double)m_currentFrame.TimeMS / KeyframeTimer.timerInterval; | ||
559 | |||
560 | if (steps <= 0.0) | ||
561 | { | ||
562 | m_group.RootPart.Velocity = Vector3.Zero; | ||
563 | m_group.RootPart.AngularVelocity = Vector3.Zero; | ||
564 | |||
565 | m_nextPosition = (Vector3)m_currentFrame.Position; | ||
566 | m_group.AbsolutePosition = m_nextPosition; | ||
567 | |||
568 | // we are sending imediate updates, no doing force a extra terseUpdate | ||
569 | // m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); | ||
570 | |||
571 | m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; | ||
572 | m_frames.RemoveAt(0); | ||
573 | if (m_frames.Count > 0) | ||
574 | m_currentFrame = m_frames[0]; | ||
575 | |||
576 | update = true; | ||
577 | } | ||
578 | else | ||
579 | { | ||
580 | float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal; | ||
581 | |||
582 | Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition; | ||
583 | Vector3 motionThisFrame = v / (float)steps; | ||
584 | v = v * 1000 / m_currentFrame.TimeMS; | ||
585 | |||
586 | if (Vector3.Mag(motionThisFrame) >= 0.05f) | ||
587 | { | ||
588 | // m_group.AbsolutePosition += motionThisFrame; | ||
589 | m_nextPosition = m_group.AbsolutePosition + motionThisFrame; | ||
590 | m_group.AbsolutePosition = m_nextPosition; | ||
591 | |||
592 | m_group.RootPart.Velocity = v; | ||
593 | update = true; | ||
594 | } | ||
595 | |||
596 | if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation) | ||
597 | { | ||
598 | Quaternion current = m_group.GroupRotation; | ||
599 | |||
600 | Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete); | ||
601 | step.Normalize(); | ||
602 | /* use simpler change detection | ||
603 | * float angle = 0; | ||
604 | |||
605 | float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; | ||
606 | float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; | ||
607 | float aa_bb = aa * bb; | ||
608 | |||
609 | if (aa_bb == 0) | ||
610 | { | ||
611 | angle = 0; | ||
612 | } | ||
613 | else | ||
614 | { | ||
615 | float ab = current.X * step.X + | ||
616 | current.Y * step.Y + | ||
617 | current.Z * step.Z + | ||
618 | current.W * step.W; | ||
619 | float q = (ab * ab) / aa_bb; | ||
620 | |||
621 | if (q > 1.0f) | ||
622 | { | ||
623 | angle = 0; | ||
624 | } | ||
625 | else | ||
626 | { | ||
627 | angle = (float)Math.Acos(2 * q - 1); | ||
628 | } | ||
629 | } | ||
630 | |||
631 | if (angle > 0.01f) | ||
632 | */ | ||
633 | if(Math.Abs(step.X - current.X) > 0.001f | ||
634 | || Math.Abs(step.Y - current.Y) > 0.001f | ||
635 | || Math.Abs(step.Z - current.Z) > 0.001f) | ||
636 | // assuming w is a dependente var | ||
637 | |||
638 | { | ||
639 | // m_group.UpdateGroupRotationR(step); | ||
640 | m_group.RootPart.RotationOffset = step; | ||
641 | |||
642 | //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); | ||
643 | update = true; | ||
644 | } | ||
645 | } | ||
646 | } | ||
647 | |||
648 | if (update) | ||
649 | { | ||
650 | m_group.SendGroupRootTerseUpdate(); | ||
651 | } | ||
652 | } | ||
653 | |||
654 | public Byte[] Serialize() | ||
655 | { | ||
656 | StopTimer(); | ||
657 | MemoryStream ms = new MemoryStream(); | ||
658 | |||
659 | BinaryFormatter fmt = new BinaryFormatter(); | ||
660 | SceneObjectGroup tmp = m_group; | ||
661 | m_group = null; | ||
662 | if (!m_selected && tmp != null) | ||
663 | m_serializedPosition = tmp.AbsolutePosition; | ||
664 | fmt.Serialize(ms, this); | ||
665 | m_group = tmp; | ||
666 | if (m_running && !m_waitingCrossing) | ||
667 | StartTimer(); | ||
668 | |||
669 | return ms.ToArray(); | ||
670 | } | ||
671 | |||
672 | public void StartCrossingCheck() | ||
673 | { | ||
674 | // timer will be restart by crossingFailure | ||
675 | // or never since crossing worked and this | ||
676 | // should be deleted | ||
677 | StopTimer(); | ||
678 | |||
679 | m_isCrossing = true; | ||
680 | m_waitingCrossing = true; | ||
681 | |||
682 | // to remove / retune to smoth crossings | ||
683 | if (m_group.RootPart.Velocity != Vector3.Zero) | ||
684 | { | ||
685 | m_group.RootPart.Velocity = Vector3.Zero; | ||
686 | m_group.SendGroupRootTerseUpdate(); | ||
687 | // m_group.RootPart.ScheduleTerseUpdate(); | ||
688 | } | ||
689 | } | ||
690 | |||
691 | public void CrossingFailure() | ||
692 | { | ||
693 | m_waitingCrossing = false; | ||
694 | |||
695 | if (m_group != null) | ||
696 | { | ||
697 | m_group.RootPart.Velocity = Vector3.Zero; | ||
698 | m_group.SendGroupRootTerseUpdate(); | ||
699 | // m_group.RootPart.ScheduleTerseUpdate(); | ||
700 | |||
701 | if (m_running) | ||
702 | { | ||
703 | StopTimer(); | ||
704 | m_skipLoops = 1200; // 60 seconds | ||
705 | StartTimer(); | ||
706 | } | ||
707 | } | ||
708 | } | ||
709 | } | ||
710 | } | ||
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 6808017..a9e1fc2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -101,12 +101,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
101 | engine.StartProcessing(); | 101 | engine.StartProcessing(); |
102 | } | 102 | } |
103 | 103 | ||
104 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) | 104 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item, uint cost) |
105 | { | 105 | { |
106 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); | 106 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); |
107 | if (money != null) | 107 | if (money != null) |
108 | { | 108 | { |
109 | money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload"); | 109 | money.ApplyUploadCharge(agentID, (int)cost, "Asset upload"); |
110 | } | 110 | } |
111 | 111 | ||
112 | AddInventoryItem(item); | 112 | AddInventoryItem(item); |
@@ -169,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
169 | return false; | 169 | return false; |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | if (InventoryService.AddItem(item)) | 173 | if (InventoryService.AddItem(item)) |
174 | { | 174 | { |
175 | int userlevel = 0; | 175 | int userlevel = 0; |
@@ -324,8 +324,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
324 | 324 | ||
325 | // Update item with new asset | 325 | // Update item with new asset |
326 | item.AssetID = asset.FullID; | 326 | item.AssetID = asset.FullID; |
327 | if (group.UpdateInventoryItem(item)) | 327 | group.UpdateInventoryItem(item); |
328 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
329 | 328 | ||
330 | part.SendPropertiesToClient(remoteClient); | 329 | part.SendPropertiesToClient(remoteClient); |
331 | 330 | ||
@@ -336,12 +335,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
336 | { | 335 | { |
337 | // Needs to determine which engine was running it and use that | 336 | // Needs to determine which engine was running it and use that |
338 | // | 337 | // |
339 | part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); | 338 | errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 1); |
340 | errors = part.Inventory.GetScriptErrors(item.ItemID); | ||
341 | } | ||
342 | else | ||
343 | { | ||
344 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
345 | } | 339 | } |
346 | 340 | ||
347 | // Tell anyone managing scripts that a script has been reloaded/changed | 341 | // Tell anyone managing scripts that a script has been reloaded/changed |
@@ -407,6 +401,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
407 | if (item.Owner != remoteClient.AgentId) | 401 | if (item.Owner != remoteClient.AgentId) |
408 | return; | 402 | return; |
409 | 403 | ||
404 | item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); | ||
410 | item.Name = itemUpd.Name; | 405 | item.Name = itemUpd.Name; |
411 | item.Description = itemUpd.Description; | 406 | item.Description = itemUpd.Description; |
412 | 407 | ||
@@ -794,6 +789,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
794 | return; | 789 | return; |
795 | } | 790 | } |
796 | 791 | ||
792 | if (newName == null) newName = item.Name; | ||
793 | |||
797 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | 794 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); |
798 | 795 | ||
799 | if (asset != null) | 796 | if (asset != null) |
@@ -854,6 +851,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
854 | } | 851 | } |
855 | 852 | ||
856 | /// <summary> | 853 | /// <summary> |
854 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
855 | /// </summary> | ||
856 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
857 | { | ||
858 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
859 | foreach (InventoryItemBase b in items) | ||
860 | { | ||
861 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
862 | InventoryItemBase n = InventoryService.GetItem(b); | ||
863 | n.Folder = destfolder; | ||
864 | moveitems.Add(n); | ||
865 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
866 | } | ||
867 | |||
868 | MoveInventoryItem(remoteClient, moveitems); | ||
869 | } | ||
870 | |||
871 | /// <summary> | ||
857 | /// Move an item within the agent's inventory. | 872 | /// Move an item within the agent's inventory. |
858 | /// </summary> | 873 | /// </summary> |
859 | /// <param name="remoteClient"></param> | 874 | /// <param name="remoteClient"></param> |
@@ -888,11 +903,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
888 | public void CreateNewInventoryItem( | 903 | public void CreateNewInventoryItem( |
889 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 904 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
890 | string name, string description, uint flags, uint callbackID, | 905 | string name, string description, uint flags, uint callbackID, |
891 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) | 906 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate, UUID transationID) |
892 | { | 907 | { |
893 | CreateNewInventoryItem( | 908 | CreateNewInventoryItem( |
894 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, | 909 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, |
895 | (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate); | 910 | (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate, transationID); |
911 | } | ||
912 | |||
913 | |||
914 | private void CreateNewInventoryItem( | ||
915 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | ||
916 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | ||
917 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | ||
918 | { | ||
919 | CreateNewInventoryItem(remoteClient, creatorID, creatorData, folderID, | ||
920 | name, description, flags, callbackID, asset, invType, | ||
921 | baseMask, currentMask, everyoneMask, nextOwnerMask, groupMask, creationDate, UUID.Zero); | ||
896 | } | 922 | } |
897 | 923 | ||
898 | /// <summary> | 924 | /// <summary> |
@@ -917,7 +943,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
917 | private void CreateNewInventoryItem( | 943 | private void CreateNewInventoryItem( |
918 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 944 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
919 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | 945 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, |
920 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | 946 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate,UUID transationID) |
921 | { | 947 | { |
922 | InventoryItemBase item = new InventoryItemBase(); | 948 | InventoryItemBase item = new InventoryItemBase(); |
923 | item.Owner = remoteClient.AgentId; | 949 | item.Owner = remoteClient.AgentId; |
@@ -940,7 +966,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
940 | 966 | ||
941 | if (AddInventoryItem(item)) | 967 | if (AddInventoryItem(item)) |
942 | { | 968 | { |
943 | remoteClient.SendInventoryItemCreateUpdate(item, callbackID); | 969 | remoteClient.SendInventoryItemCreateUpdate(item, transationID, callbackID); |
944 | } | 970 | } |
945 | else | 971 | else |
946 | { | 972 | { |
@@ -1215,6 +1241,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1215 | { | 1241 | { |
1216 | SceneObjectPart part = GetSceneObjectPart(primLocalId); | 1242 | SceneObjectPart part = GetSceneObjectPart(primLocalId); |
1217 | 1243 | ||
1244 | // Can't move a null item | ||
1245 | if (itemId == UUID.Zero) | ||
1246 | return; | ||
1247 | |||
1218 | if (null == part) | 1248 | if (null == part) |
1219 | { | 1249 | { |
1220 | m_log.WarnFormat( | 1250 | m_log.WarnFormat( |
@@ -1319,21 +1349,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1319 | return; | 1349 | return; |
1320 | } | 1350 | } |
1321 | 1351 | ||
1322 | if (part.OwnerID != destPart.OwnerID) | 1352 | // Can't transfer this |
1353 | // | ||
1354 | if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1355 | return; | ||
1356 | |||
1357 | bool overrideNoMod = false; | ||
1358 | if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) | ||
1359 | overrideNoMod = true; | ||
1360 | |||
1361 | if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1323 | { | 1362 | { |
1324 | // Source must have transfer permissions | 1363 | // object cannot copy items to an object owned by a different owner |
1325 | if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | 1364 | // unless llAllowInventoryDrop has been called |
1326 | return; | ||
1327 | 1365 | ||
1328 | // Object cannot copy items to an object owned by a different owner | 1366 | return; |
1329 | // unless llAllowInventoryDrop has been called on the destination | ||
1330 | if ((destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1331 | return; | ||
1332 | } | 1367 | } |
1333 | 1368 | ||
1334 | // must have both move and modify permission to put an item in an object | 1369 | // must have both move and modify permission to put an item in an object |
1335 | if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) | 1370 | if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) |
1371 | { | ||
1336 | return; | 1372 | return; |
1373 | } | ||
1337 | 1374 | ||
1338 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); | 1375 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); |
1339 | 1376 | ||
@@ -1389,6 +1426,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1389 | 1426 | ||
1390 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1427 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1391 | { | 1428 | { |
1429 | SceneObjectPart destPart = GetSceneObjectPart(destID); | ||
1430 | if (destPart != null) // Move into a prim | ||
1431 | { | ||
1432 | foreach(UUID itemID in items) | ||
1433 | MoveTaskInventoryItem(destID, host, itemID); | ||
1434 | return destID; // Prim folder ID == prim ID | ||
1435 | } | ||
1436 | |||
1392 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1437 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1393 | 1438 | ||
1394 | UUID newFolderID = UUID.Random(); | 1439 | UUID newFolderID = UUID.Random(); |
@@ -1571,12 +1616,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1571 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( | 1616 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( |
1572 | remoteClient, part, transactionID, currentItem); | 1617 | remoteClient, part, transactionID, currentItem); |
1573 | 1618 | ||
1574 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | 1619 | // if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) |
1575 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | 1620 | // remoteClient.SendAgentAlertMessage("Notecard saved", false); |
1576 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | 1621 | // else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) |
1577 | remoteClient.SendAgentAlertMessage("Script saved", false); | 1622 | // remoteClient.SendAgentAlertMessage("Script saved", false); |
1578 | else | 1623 | // else |
1579 | remoteClient.SendAgentAlertMessage("Item saved", false); | 1624 | // remoteClient.SendAgentAlertMessage("Item saved", false); |
1580 | } | 1625 | } |
1581 | 1626 | ||
1582 | // Base ALWAYS has move | 1627 | // Base ALWAYS has move |
@@ -1946,23 +1991,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1946 | // build a list of eligible objects | 1991 | // build a list of eligible objects |
1947 | List<uint> deleteIDs = new List<uint>(); | 1992 | List<uint> deleteIDs = new List<uint>(); |
1948 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 1993 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
1949 | 1994 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
1950 | // Start with true for both, then remove the flags if objects | ||
1951 | // that we can't derez are part of the selection | ||
1952 | bool permissionToTake = true; | ||
1953 | bool permissionToTakeCopy = true; | ||
1954 | bool permissionToDelete = true; | ||
1955 | 1995 | ||
1956 | foreach (uint localID in localIDs) | 1996 | foreach (uint localID in localIDs) |
1957 | { | 1997 | { |
1998 | // Start with true for both, then remove the flags if objects | ||
1999 | // that we can't derez are part of the selection | ||
2000 | bool permissionToTake = true; | ||
2001 | bool permissionToTakeCopy = true; | ||
2002 | bool permissionToDelete = true; | ||
2003 | |||
1958 | // Invalid id | 2004 | // Invalid id |
1959 | SceneObjectPart part = GetSceneObjectPart(localID); | 2005 | SceneObjectPart part = GetSceneObjectPart(localID); |
1960 | if (part == null) | 2006 | if (part == null) |
2007 | { | ||
2008 | //Client still thinks the object exists, kill it | ||
2009 | deleteIDs.Add(localID); | ||
1961 | continue; | 2010 | continue; |
2011 | } | ||
1962 | 2012 | ||
1963 | // Already deleted by someone else | 2013 | // Already deleted by someone else |
1964 | if (part.ParentGroup.IsDeleted) | 2014 | if (part.ParentGroup.IsDeleted) |
2015 | { | ||
2016 | //Client still thinks the object exists, kill it | ||
2017 | deleteIDs.Add(localID); | ||
1965 | continue; | 2018 | continue; |
2019 | } | ||
1966 | 2020 | ||
1967 | // Can't delete child prims | 2021 | // Can't delete child prims |
1968 | if (part != part.ParentGroup.RootPart) | 2022 | if (part != part.ParentGroup.RootPart) |
@@ -1970,8 +2024,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1970 | 2024 | ||
1971 | SceneObjectGroup grp = part.ParentGroup; | 2025 | SceneObjectGroup grp = part.ParentGroup; |
1972 | 2026 | ||
1973 | deleteIDs.Add(localID); | 2027 | // If child prims have invalid perms, fix them |
1974 | deleteGroups.Add(grp); | 2028 | grp.AdjustChildPrimPermissions(); |
1975 | 2029 | ||
1976 | // If child prims have invalid perms, fix them | 2030 | // If child prims have invalid perms, fix them |
1977 | grp.AdjustChildPrimPermissions(); | 2031 | grp.AdjustChildPrimPermissions(); |
@@ -1992,81 +2046,193 @@ namespace OpenSim.Region.Framework.Scenes | |||
1992 | } | 2046 | } |
1993 | else | 2047 | else |
1994 | { | 2048 | { |
1995 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 2049 | if (action == DeRezAction.TakeCopy) |
2050 | { | ||
2051 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
2052 | permissionToTakeCopy = false; | ||
2053 | } | ||
2054 | else | ||
2055 | { | ||
1996 | permissionToTakeCopy = false; | 2056 | permissionToTakeCopy = false; |
1997 | 2057 | } | |
1998 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 2058 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
1999 | permissionToTake = false; | 2059 | permissionToTake = false; |
2000 | 2060 | ||
2001 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 2061 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
2002 | permissionToDelete = false; | 2062 | permissionToDelete = false; |
2003 | } | 2063 | } |
2004 | } | ||
2005 | 2064 | ||
2006 | // Handle god perms | 2065 | // Handle god perms |
2007 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | 2066 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
2008 | { | 2067 | { |
2009 | permissionToTake = true; | 2068 | permissionToTake = true; |
2010 | permissionToTakeCopy = true; | 2069 | permissionToTakeCopy = true; |
2011 | permissionToDelete = true; | 2070 | permissionToDelete = true; |
2012 | } | 2071 | } |
2013 | 2072 | ||
2014 | // If we're re-saving, we don't even want to delete | 2073 | // If we're re-saving, we don't even want to delete |
2015 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | 2074 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
2016 | permissionToDelete = false; | 2075 | permissionToDelete = false; |
2017 | 2076 | ||
2018 | // if we want to take a copy, we also don't want to delete | 2077 | // if we want to take a copy, we also don't want to delete |
2019 | // Note: after this point, the permissionToTakeCopy flag | 2078 | // Note: after this point, the permissionToTakeCopy flag |
2020 | // becomes irrelevant. It already includes the permissionToTake | 2079 | // becomes irrelevant. It already includes the permissionToTake |
2021 | // permission and after excluding no copy items here, we can | 2080 | // permission and after excluding no copy items here, we can |
2022 | // just use that. | 2081 | // just use that. |
2023 | if (action == DeRezAction.TakeCopy) | 2082 | if (action == DeRezAction.TakeCopy) |
2024 | { | 2083 | { |
2025 | // If we don't have permission, stop right here | 2084 | // If we don't have permission, stop right here |
2026 | if (!permissionToTakeCopy) | 2085 | if (!permissionToTakeCopy) |
2027 | return; | 2086 | return; |
2028 | 2087 | ||
2029 | permissionToTake = true; | 2088 | permissionToTake = true; |
2030 | // Don't delete | 2089 | // Don't delete |
2031 | permissionToDelete = false; | 2090 | permissionToDelete = false; |
2032 | } | 2091 | } |
2033 | 2092 | ||
2034 | if (action == DeRezAction.Return) | 2093 | if (action == DeRezAction.Return) |
2035 | { | ||
2036 | if (remoteClient != null) | ||
2037 | { | 2094 | { |
2038 | if (Permissions.CanReturnObjects( | 2095 | if (remoteClient != null) |
2039 | null, | ||
2040 | remoteClient.AgentId, | ||
2041 | deleteGroups)) | ||
2042 | { | 2096 | { |
2043 | permissionToTake = true; | 2097 | if (Permissions.CanReturnObjects( |
2044 | permissionToDelete = true; | 2098 | null, |
2045 | 2099 | remoteClient.AgentId, | |
2046 | foreach (SceneObjectGroup g in deleteGroups) | 2100 | new List<SceneObjectGroup>() {grp})) |
2047 | { | 2101 | { |
2048 | AddReturn(g.OwnerID == g.GroupID ? g.LastOwnerID : g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 2102 | permissionToTake = true; |
2103 | permissionToDelete = true; | ||
2104 | |||
2105 | AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
2049 | } | 2106 | } |
2050 | } | 2107 | } |
2108 | else // Auto return passes through here with null agent | ||
2109 | { | ||
2110 | permissionToTake = true; | ||
2111 | permissionToDelete = true; | ||
2112 | } | ||
2051 | } | 2113 | } |
2052 | else // Auto return passes through here with null agent | 2114 | |
2115 | if (permissionToTake && (!permissionToDelete)) | ||
2116 | takeGroups.Add(grp); | ||
2117 | |||
2118 | if (permissionToDelete) | ||
2053 | { | 2119 | { |
2054 | permissionToTake = true; | 2120 | if (permissionToTake) |
2055 | permissionToDelete = true; | 2121 | deleteGroups.Add(grp); |
2122 | deleteIDs.Add(grp.LocalId); | ||
2056 | } | 2123 | } |
2057 | } | 2124 | } |
2058 | 2125 | ||
2059 | if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) | 2126 | SendKillObject(deleteIDs); |
2127 | |||
2128 | if (deleteGroups.Count > 0) | ||
2060 | { | 2129 | { |
2130 | foreach (SceneObjectGroup g in deleteGroups) | ||
2131 | deleteIDs.Remove(g.LocalId); | ||
2132 | |||
2061 | m_asyncSceneObjectDeleter.DeleteToInventory( | 2133 | m_asyncSceneObjectDeleter.DeleteToInventory( |
2062 | action, destinationID, deleteGroups, remoteClient, | 2134 | action, destinationID, deleteGroups, remoteClient, |
2063 | permissionToDelete); | 2135 | true); |
2136 | } | ||
2137 | if (takeGroups.Count > 0) | ||
2138 | { | ||
2139 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
2140 | action, destinationID, takeGroups, remoteClient, | ||
2141 | false); | ||
2064 | } | 2142 | } |
2065 | else if (permissionToDelete) | 2143 | if (deleteIDs.Count > 0) |
2066 | { | 2144 | { |
2067 | foreach (SceneObjectGroup g in deleteGroups) | 2145 | foreach (SceneObjectGroup g in deleteGroups) |
2068 | DeleteSceneObject(g, false); | 2146 | DeleteSceneObject(g, true); |
2147 | } | ||
2148 | } | ||
2149 | |||
2150 | public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) | ||
2151 | { | ||
2152 | itemID = UUID.Zero; | ||
2153 | if (grp != null) | ||
2154 | { | ||
2155 | Vector3 inventoryStoredPosition = new Vector3 | ||
2156 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
2157 | ? 250 | ||
2158 | : grp.AbsolutePosition.X) | ||
2159 | , | ||
2160 | (grp.AbsolutePosition.X > (int)Constants.RegionSize) | ||
2161 | ? 250 | ||
2162 | : grp.AbsolutePosition.X, | ||
2163 | grp.AbsolutePosition.Z); | ||
2164 | |||
2165 | Vector3 originalPosition = grp.AbsolutePosition; | ||
2166 | |||
2167 | grp.AbsolutePosition = inventoryStoredPosition; | ||
2168 | |||
2169 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
2170 | |||
2171 | grp.AbsolutePosition = originalPosition; | ||
2172 | |||
2173 | AssetBase asset = CreateAsset( | ||
2174 | grp.GetPartName(grp.LocalId), | ||
2175 | grp.GetPartDescription(grp.LocalId), | ||
2176 | (sbyte)AssetType.Object, | ||
2177 | Utils.StringToBytes(sceneObjectXml), | ||
2178 | remoteClient.AgentId); | ||
2179 | AssetService.Store(asset); | ||
2180 | |||
2181 | InventoryItemBase item = new InventoryItemBase(); | ||
2182 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
2183 | item.CreatorData = grp.RootPart.CreatorData; | ||
2184 | item.Owner = remoteClient.AgentId; | ||
2185 | item.ID = UUID.Random(); | ||
2186 | item.AssetID = asset.FullID; | ||
2187 | item.Description = asset.Description; | ||
2188 | item.Name = asset.Name; | ||
2189 | item.AssetType = asset.Type; | ||
2190 | item.InvType = (int)InventoryType.Object; | ||
2191 | |||
2192 | InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
2193 | if (folder != null) | ||
2194 | item.Folder = folder.ID; | ||
2195 | else // oopsies | ||
2196 | item.Folder = UUID.Zero; | ||
2197 | |||
2198 | // Set up base perms properly | ||
2199 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
2200 | permsBase &= grp.RootPart.BaseMask; | ||
2201 | permsBase |= (uint)PermissionMask.Move; | ||
2202 | |||
2203 | // Make sure we don't lock it | ||
2204 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
2205 | |||
2206 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
2207 | { | ||
2208 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2209 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2210 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2211 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
2212 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
2213 | } | ||
2214 | else | ||
2215 | { | ||
2216 | item.BasePermissions = permsBase; | ||
2217 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; | ||
2218 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2219 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; | ||
2220 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; | ||
2221 | } | ||
2222 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
2223 | |||
2224 | // sets itemID so client can show item as 'attached' in inventory | ||
2225 | grp.FromItemID = item.ID; | ||
2226 | |||
2227 | if (AddInventoryItem(item)) | ||
2228 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
2229 | else | ||
2230 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
2231 | |||
2232 | itemID = item.ID; | ||
2233 | return item.AssetID; | ||
2069 | } | 2234 | } |
2235 | return UUID.Zero; | ||
2070 | } | 2236 | } |
2071 | 2237 | ||
2072 | /// <summary> | 2238 | /// <summary> |
@@ -2196,6 +2362,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2196 | 2362 | ||
2197 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2363 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2198 | { | 2364 | { |
2365 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2366 | return; | ||
2367 | |||
2199 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2368 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2200 | if (part == null) | 2369 | if (part == null) |
2201 | return; | 2370 | return; |
@@ -2252,7 +2421,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2252 | } | 2421 | } |
2253 | else | 2422 | else |
2254 | { | 2423 | { |
2255 | if (!Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) | 2424 | if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId) |
2425 | continue; | ||
2426 | |||
2427 | if (!Permissions.CanTransferObject(sog.UUID, groupID)) | ||
2256 | continue; | 2428 | continue; |
2257 | 2429 | ||
2258 | if (sog.GroupID != groupID) | 2430 | if (sog.GroupID != groupID) |
@@ -2364,6 +2536,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2364 | } | 2536 | } |
2365 | 2537 | ||
2366 | m_sceneGraph.LinkObjects(root, children); | 2538 | m_sceneGraph.LinkObjects(root, children); |
2539 | |||
2540 | ScenePresence sp; | ||
2541 | if (TryGetScenePresence(agentId, out sp)) | ||
2542 | { | ||
2543 | root.SendPropertiesToClient(sp.ControllingClient); | ||
2544 | } | ||
2367 | } | 2545 | } |
2368 | 2546 | ||
2369 | private string PermissionString(uint permissions) | 2547 | 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 de3978c..ce055d3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -226,8 +226,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
226 | // TODO: need to figure out how allow client agents but deny | 226 | // TODO: need to figure out how allow client agents but deny |
227 | // root agents when ACL denies access to root agent | 227 | // root agents when ACL denies access to root agent |
228 | public bool m_strictAccessControl = true; | 228 | public bool m_strictAccessControl = true; |
229 | 229 | public bool m_seeIntoBannedRegion = false; | |
230 | public int MaxUndoCount { get; set; } | 230 | public int MaxUndoCount = 5; |
231 | 231 | ||
232 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 232 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
233 | public bool LoginLock = false; | 233 | public bool LoginLock = false; |
@@ -243,11 +243,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
243 | 243 | ||
244 | protected int m_splitRegionID; | 244 | protected int m_splitRegionID; |
245 | protected Timer m_restartWaitTimer = new Timer(); | 245 | protected Timer m_restartWaitTimer = new Timer(); |
246 | protected Timer m_timerWatchdog = new Timer(); | ||
246 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 247 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
247 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 248 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
248 | protected string m_simulatorVersion = "OpenSimulator Server"; | 249 | protected string m_simulatorVersion = "OpenSimulator Server"; |
249 | protected AgentCircuitManager m_authenticateHandler; | 250 | protected AgentCircuitManager m_authenticateHandler; |
250 | protected SceneCommunicationService m_sceneGridService; | 251 | protected SceneCommunicationService m_sceneGridService; |
252 | protected ISnmpModule m_snmpService = null; | ||
251 | 253 | ||
252 | protected ISimulationDataService m_SimulationDataService; | 254 | protected ISimulationDataService m_SimulationDataService; |
253 | protected IEstateDataService m_EstateDataService; | 255 | protected IEstateDataService m_EstateDataService; |
@@ -310,8 +312,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
310 | private int m_update_presences = 1; // Update scene presence movements | 312 | private int m_update_presences = 1; // Update scene presence movements |
311 | private int m_update_events = 1; | 313 | private int m_update_events = 1; |
312 | private int m_update_backup = 200; | 314 | private int m_update_backup = 200; |
313 | private int m_update_terrain = 50; | 315 | private int m_update_terrain = 1000; |
314 | // private int m_update_land = 1; | 316 | private int m_update_land = 10; |
315 | private int m_update_coarse_locations = 50; | 317 | private int m_update_coarse_locations = 50; |
316 | 318 | ||
317 | private int agentMS; | 319 | private int agentMS; |
@@ -324,13 +326,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
324 | private int backupMS; | 326 | private int backupMS; |
325 | private int terrainMS; | 327 | private int terrainMS; |
326 | private int landMS; | 328 | private int landMS; |
327 | private int spareMS; | ||
328 | 329 | ||
329 | /// <summary> | 330 | /// <summary> |
330 | /// Tick at which the last frame was processed. | 331 | /// Tick at which the last frame was processed. |
331 | /// </summary> | 332 | /// </summary> |
332 | private int m_lastFrameTick; | 333 | private int m_lastFrameTick; |
333 | 334 | ||
335 | public bool CombineRegions = false; | ||
334 | /// <summary> | 336 | /// <summary> |
335 | /// Tick at which the last maintenance run occurred. | 337 | /// Tick at which the last maintenance run occurred. |
336 | /// </summary> | 338 | /// </summary> |
@@ -350,7 +352,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
350 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 352 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
351 | private volatile bool m_backingup; | 353 | private volatile bool m_backingup; |
352 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 354 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
353 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); | 355 | private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); |
354 | 356 | ||
355 | private string m_defaultScriptEngine; | 357 | private string m_defaultScriptEngine; |
356 | 358 | ||
@@ -359,6 +361,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
359 | /// </summary> | 361 | /// </summary> |
360 | private int m_LastLogin; | 362 | private int m_LastLogin; |
361 | 363 | ||
364 | private int m_lastIncoming; | ||
365 | private int m_lastOutgoing; | ||
366 | private int m_hbRestarts = 0; | ||
367 | |||
368 | |||
362 | /// <summary> | 369 | /// <summary> |
363 | /// Thread that runs the scene loop. | 370 | /// Thread that runs the scene loop. |
364 | /// </summary> | 371 | /// </summary> |
@@ -399,7 +406,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
399 | private volatile bool m_active; | 406 | private volatile bool m_active; |
400 | 407 | ||
401 | // private int m_lastUpdate; | 408 | // private int m_lastUpdate; |
402 | // private bool m_firstHeartbeat = true; | 409 | private bool m_firstHeartbeat = true; |
403 | 410 | ||
404 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | 411 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; |
405 | private bool m_reprioritizationEnabled = true; | 412 | private bool m_reprioritizationEnabled = true; |
@@ -443,6 +450,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
443 | get { return m_sceneGridService; } | 450 | get { return m_sceneGridService; } |
444 | } | 451 | } |
445 | 452 | ||
453 | public ISnmpModule SnmpService | ||
454 | { | ||
455 | get | ||
456 | { | ||
457 | if (m_snmpService == null) | ||
458 | { | ||
459 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
460 | } | ||
461 | |||
462 | return m_snmpService; | ||
463 | } | ||
464 | } | ||
465 | |||
446 | public ISimulationDataService SimulationDataService | 466 | public ISimulationDataService SimulationDataService |
447 | { | 467 | { |
448 | get | 468 | get |
@@ -735,6 +755,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
735 | m_SimulationDataService = simDataService; | 755 | m_SimulationDataService = simDataService; |
736 | m_EstateDataService = estateDataService; | 756 | m_EstateDataService = estateDataService; |
737 | m_regionHandle = RegionInfo.RegionHandle; | 757 | m_regionHandle = RegionInfo.RegionHandle; |
758 | m_lastIncoming = 0; | ||
759 | m_lastOutgoing = 0; | ||
738 | 760 | ||
739 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 761 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
740 | m_asyncSceneObjectDeleter.Enabled = true; | 762 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -828,7 +850,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
828 | 850 | ||
829 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | 851 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); |
830 | 852 | ||
831 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | 853 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance",m_defaultDrawDistance); |
832 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); | 854 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); |
833 | if (!UseBackup) | 855 | if (!UseBackup) |
834 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 856 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
@@ -836,10 +858,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
836 | //Animation states | 858 | //Animation states |
837 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 859 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
838 | 860 | ||
839 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); | 861 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
840 | 862 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); | |
841 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | ||
842 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | ||
843 | 863 | ||
844 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); | 864 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); |
845 | if (RegionInfo.NonphysPrimMin > 0) | 865 | if (RegionInfo.NonphysPrimMin > 0) |
@@ -860,11 +880,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
860 | } | 880 | } |
861 | 881 | ||
862 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 882 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
883 | |||
863 | if (RegionInfo.PhysPrimMax > 0) | 884 | if (RegionInfo.PhysPrimMax > 0) |
864 | { | 885 | { |
865 | m_maxPhys = RegionInfo.PhysPrimMax; | 886 | m_maxPhys = RegionInfo.PhysPrimMax; |
866 | } | 887 | } |
867 | 888 | ||
889 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | ||
890 | if (RegionInfo.LinksetCapacity > 0) | ||
891 | { | ||
892 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
893 | } | ||
894 | |||
895 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
896 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
897 | |||
868 | // Here, if clamping is requested in either global or | 898 | // Here, if clamping is requested in either global or |
869 | // local config, it will be used | 899 | // local config, it will be used |
870 | // | 900 | // |
@@ -874,13 +904,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
874 | m_clampPrimSize = true; | 904 | m_clampPrimSize = true; |
875 | } | 905 | } |
876 | 906 | ||
877 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | 907 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
878 | if (RegionInfo.LinksetCapacity > 0) | ||
879 | { | ||
880 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
881 | } | ||
882 | |||
883 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | ||
884 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 908 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
885 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 909 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
886 | m_dontPersistBefore = | 910 | m_dontPersistBefore = |
@@ -891,11 +915,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
891 | m_persistAfter *= 10000000; | 915 | m_persistAfter *= 10000000; |
892 | 916 | ||
893 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 917 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
894 | 918 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | |
895 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
896 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
897 | 919 | ||
898 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 920 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
921 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
922 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
899 | 923 | ||
900 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 924 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
901 | if (m_generateMaptiles) | 925 | if (m_generateMaptiles) |
@@ -928,7 +952,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
928 | string grant = startupConfig.GetString("AllowedClients", String.Empty); | 952 | string grant = startupConfig.GetString("AllowedClients", String.Empty); |
929 | if (grant.Length > 0) | 953 | if (grant.Length > 0) |
930 | { | 954 | { |
931 | foreach (string viewer in grant.Split('|')) | 955 | foreach (string viewer in grant.Split(',')) |
932 | { | 956 | { |
933 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 957 | m_AllowedViewers.Add(viewer.Trim().ToLower()); |
934 | } | 958 | } |
@@ -937,7 +961,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
937 | grant = startupConfig.GetString("BannedClients", String.Empty); | 961 | grant = startupConfig.GetString("BannedClients", String.Empty); |
938 | if (grant.Length > 0) | 962 | if (grant.Length > 0) |
939 | { | 963 | { |
940 | foreach (string viewer in grant.Split('|')) | 964 | foreach (string viewer in grant.Split(',')) |
941 | { | 965 | { |
942 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 966 | m_BannedViewers.Add(viewer.Trim().ToLower()); |
943 | } | 967 | } |
@@ -997,6 +1021,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
997 | StatsReporter = new SimStatsReporter(this); | 1021 | StatsReporter = new SimStatsReporter(this); |
998 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1022 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
999 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1023 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1024 | |||
1025 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | ||
1000 | } | 1026 | } |
1001 | 1027 | ||
1002 | public Scene(RegionInfo regInfo) : base(regInfo) | 1028 | public Scene(RegionInfo regInfo) : base(regInfo) |
@@ -1292,8 +1318,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1292 | // Stop all client threads. | 1318 | // Stop all client threads. |
1293 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); | 1319 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); |
1294 | 1320 | ||
1295 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1321 | m_log.Debug("[SCENE]: TriggerSceneShuttingDown"); |
1296 | EventManager.TriggerSceneShuttingDown(this); | 1322 | EventManager.TriggerSceneShuttingDown(this); |
1323 | |||
1324 | m_log.Debug("[SCENE]: Persisting changed objects"); | ||
1325 | |||
1297 | Backup(false); | 1326 | Backup(false); |
1298 | m_sceneGraph.Close(); | 1327 | m_sceneGraph.Close(); |
1299 | 1328 | ||
@@ -1307,6 +1336,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1307 | // attempt to reference a null or disposed physics scene. | 1336 | // attempt to reference a null or disposed physics scene. |
1308 | if (PhysicsScene != null) | 1337 | if (PhysicsScene != null) |
1309 | { | 1338 | { |
1339 | m_log.Debug("[SCENE]: Dispose Physics"); | ||
1310 | PhysicsScene phys = PhysicsScene; | 1340 | PhysicsScene phys = PhysicsScene; |
1311 | // remove the physics engine from both Scene and SceneGraph | 1341 | // remove the physics engine from both Scene and SceneGraph |
1312 | PhysicsScene = null; | 1342 | PhysicsScene = null; |
@@ -1329,11 +1359,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1329 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1359 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1330 | if (m_heartbeatThread != null) | 1360 | if (m_heartbeatThread != null) |
1331 | { | 1361 | { |
1362 | m_hbRestarts++; | ||
1363 | if(m_hbRestarts > 10) | ||
1364 | Environment.Exit(1); | ||
1365 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1366 | |||
1367 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1368 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1369 | //proc.EnableRaisingEvents=false; | ||
1370 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1371 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1372 | //proc.Start(); | ||
1373 | //proc.WaitForExit(); | ||
1374 | //Thread.Sleep(1000); | ||
1375 | //Environment.Exit(1); | ||
1332 | m_heartbeatThread.Abort(); | 1376 | m_heartbeatThread.Abort(); |
1377 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1333 | m_heartbeatThread = null; | 1378 | m_heartbeatThread = null; |
1334 | } | 1379 | } |
1335 | // m_lastUpdate = Util.EnvironmentTickCount(); | 1380 | // m_lastUpdate = Util.EnvironmentTickCount(); |
1336 | 1381 | ||
1382 | // m_sceneGraph.PreparePhysicsSimulation(); | ||
1383 | |||
1384 | |||
1337 | m_heartbeatThread | 1385 | m_heartbeatThread |
1338 | = Watchdog.StartThread( | 1386 | = Watchdog.StartThread( |
1339 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); | 1387 | Heartbeat, string.Format("Heartbeat ({0})", RegionInfo.RegionName), ThreadPriority.Normal, false, false); |
@@ -1476,16 +1524,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1476 | endFrame = Frame + frames; | 1524 | endFrame = Frame + frames; |
1477 | 1525 | ||
1478 | float physicsFPS = 0f; | 1526 | float physicsFPS = 0f; |
1479 | int previousFrameTick, tmpMS; | 1527 | int tmpMS; |
1480 | int maintc = Util.EnvironmentTickCount(); | 1528 | int previousFrameTick; |
1529 | int maintc; | ||
1530 | int sleepMS; | ||
1531 | int framestart; | ||
1481 | 1532 | ||
1482 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) | 1533 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) |
1483 | { | 1534 | { |
1535 | framestart = Util.EnvironmentTickCount(); | ||
1484 | ++Frame; | 1536 | ++Frame; |
1485 | 1537 | ||
1486 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1538 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1487 | 1539 | ||
1488 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; | 1540 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; |
1489 | 1541 | ||
1490 | try | 1542 | try |
1491 | { | 1543 | { |
@@ -1537,6 +1589,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1537 | m_sceneGraph.UpdatePresences(); | 1589 | m_sceneGraph.UpdatePresences(); |
1538 | 1590 | ||
1539 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); | 1591 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1592 | |||
1540 | 1593 | ||
1541 | // Delete temp-on-rez stuff | 1594 | // Delete temp-on-rez stuff |
1542 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | 1595 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) |
@@ -1618,34 +1671,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
1618 | 1671 | ||
1619 | Watchdog.UpdateThread(); | 1672 | Watchdog.UpdateThread(); |
1620 | 1673 | ||
1674 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1675 | |||
1676 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1677 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1678 | StatsReporter.AddFPS(1); | ||
1679 | |||
1680 | StatsReporter.addAgentMS(agentMS); | ||
1681 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1682 | StatsReporter.addOtherMS(otherMS); | ||
1683 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1684 | |||
1621 | previousFrameTick = m_lastFrameTick; | 1685 | previousFrameTick = m_lastFrameTick; |
1622 | m_lastFrameTick = Util.EnvironmentTickCount(); | 1686 | m_lastFrameTick = Util.EnvironmentTickCount(); |
1623 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); | 1687 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); |
1624 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | 1688 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; |
1625 | 1689 | ||
1690 | m_firstHeartbeat = false; | ||
1691 | |||
1692 | sleepMS = Util.EnvironmentTickCount(); | ||
1693 | |||
1626 | if (tmpMS > 0) | 1694 | if (tmpMS > 0) |
1627 | { | ||
1628 | Thread.Sleep(tmpMS); | 1695 | Thread.Sleep(tmpMS); |
1629 | spareMS += tmpMS; | ||
1630 | } | ||
1631 | |||
1632 | frameMS = Util.EnvironmentTickCountSubtract(maintc); | ||
1633 | maintc = Util.EnvironmentTickCount(); | ||
1634 | 1696 | ||
1635 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1697 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); |
1698 | frameMS = Util.EnvironmentTickCountSubtract(framestart); | ||
1699 | StatsReporter.addSleepMS(sleepMS); | ||
1700 | StatsReporter.addFrameMS(frameMS); | ||
1636 | 1701 | ||
1637 | // if (Frame%m_update_avatars == 0) | 1702 | // if (Frame%m_update_avatars == 0) |
1638 | // UpdateInWorldTime(); | 1703 | // UpdateInWorldTime(); |
1639 | StatsReporter.AddPhysicsFPS(physicsFPS); | ||
1640 | StatsReporter.AddTimeDilation(TimeDilation); | ||
1641 | StatsReporter.AddFPS(1); | ||
1642 | 1704 | ||
1643 | StatsReporter.addFrameMS(frameMS); | ||
1644 | StatsReporter.addAgentMS(agentMS); | ||
1645 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
1646 | StatsReporter.addOtherMS(otherMS); | ||
1647 | StatsReporter.AddSpareMS(spareMS); | ||
1648 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
1649 | 1705 | ||
1650 | // Optionally warn if a frame takes double the amount of time that it should. | 1706 | // Optionally warn if a frame takes double the amount of time that it should. |
1651 | if (DebugUpdates | 1707 | if (DebugUpdates |
@@ -1662,7 +1718,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1662 | public void AddGroupTarget(SceneObjectGroup grp) | 1718 | public void AddGroupTarget(SceneObjectGroup grp) |
1663 | { | 1719 | { |
1664 | lock (m_groupsWithTargets) | 1720 | lock (m_groupsWithTargets) |
1665 | m_groupsWithTargets[grp.UUID] = grp; | 1721 | m_groupsWithTargets[grp.UUID] = 0; |
1666 | } | 1722 | } |
1667 | 1723 | ||
1668 | public void RemoveGroupTarget(SceneObjectGroup grp) | 1724 | public void RemoveGroupTarget(SceneObjectGroup grp) |
@@ -1673,18 +1729,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1673 | 1729 | ||
1674 | private void CheckAtTargets() | 1730 | private void CheckAtTargets() |
1675 | { | 1731 | { |
1676 | List<SceneObjectGroup> objs = null; | 1732 | List<UUID> objs = null; |
1677 | 1733 | ||
1678 | lock (m_groupsWithTargets) | 1734 | lock (m_groupsWithTargets) |
1679 | { | 1735 | { |
1680 | if (m_groupsWithTargets.Count != 0) | 1736 | if (m_groupsWithTargets.Count != 0) |
1681 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); | 1737 | objs = new List<UUID>(m_groupsWithTargets.Keys); |
1682 | } | 1738 | } |
1683 | 1739 | ||
1684 | if (objs != null) | 1740 | if (objs != null) |
1685 | { | 1741 | { |
1686 | foreach (SceneObjectGroup entry in objs) | 1742 | foreach (UUID entry in objs) |
1687 | entry.checkAtTargets(); | 1743 | { |
1744 | SceneObjectGroup grp = GetSceneObjectGroup(entry); | ||
1745 | if (grp == null) | ||
1746 | m_groupsWithTargets.Remove(entry); | ||
1747 | else | ||
1748 | grp.checkAtTargets(); | ||
1749 | } | ||
1688 | } | 1750 | } |
1689 | } | 1751 | } |
1690 | 1752 | ||
@@ -1763,7 +1825,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1763 | msg.fromAgentName = "Server"; | 1825 | msg.fromAgentName = "Server"; |
1764 | msg.dialog = (byte)19; // Object msg | 1826 | msg.dialog = (byte)19; // Object msg |
1765 | msg.fromGroup = false; | 1827 | msg.fromGroup = false; |
1766 | msg.offline = (byte)0; | 1828 | msg.offline = (byte)1; |
1767 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1829 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1768 | msg.Position = Vector3.Zero; | 1830 | msg.Position = Vector3.Zero; |
1769 | msg.RegionID = RegionInfo.RegionID.Guid; | 1831 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1992,7 +2054,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1992 | return PhysicsScene.SupportsRaycastWorldFiltered(); | 2054 | return PhysicsScene.SupportsRaycastWorldFiltered(); |
1993 | } | 2055 | } |
1994 | 2056 | ||
1995 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | 2057 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) |
1996 | { | 2058 | { |
1997 | if (PhysicsScene == null) | 2059 | if (PhysicsScene == null) |
1998 | return null; | 2060 | return null; |
@@ -2014,14 +2076,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2014 | /// <returns></returns> | 2076 | /// <returns></returns> |
2015 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 2077 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
2016 | { | 2078 | { |
2079 | |||
2080 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
2081 | Vector3 wpos = Vector3.Zero; | ||
2082 | // Check for water surface intersection from above | ||
2083 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
2084 | { | ||
2085 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
2086 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
2087 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
2088 | wpos.Z = wheight; | ||
2089 | } | ||
2090 | |||
2017 | Vector3 pos = Vector3.Zero; | 2091 | Vector3 pos = Vector3.Zero; |
2018 | if (RayEndIsIntersection == (byte)1) | 2092 | if (RayEndIsIntersection == (byte)1) |
2019 | { | 2093 | { |
2020 | pos = RayEnd; | 2094 | pos = RayEnd; |
2021 | return pos; | ||
2022 | } | 2095 | } |
2023 | 2096 | else if (RayTargetID != UUID.Zero) | |
2024 | if (RayTargetID != UUID.Zero) | ||
2025 | { | 2097 | { |
2026 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 2098 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
2027 | 2099 | ||
@@ -2043,7 +2115,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2043 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 2115 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
2044 | 2116 | ||
2045 | // Un-comment out the following line to Get Raytrace results printed to the console. | 2117 | // Un-comment out the following line to Get Raytrace results printed to the console. |
2046 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 2118 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
2047 | float ScaleOffset = 0.5f; | 2119 | float ScaleOffset = 0.5f; |
2048 | 2120 | ||
2049 | // If we hit something | 2121 | // If we hit something |
@@ -2066,13 +2138,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2066 | //pos.Z -= 0.25F; | 2138 | //pos.Z -= 0.25F; |
2067 | 2139 | ||
2068 | } | 2140 | } |
2069 | |||
2070 | return pos; | ||
2071 | } | 2141 | } |
2072 | else | 2142 | else |
2073 | { | 2143 | { |
2074 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2144 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
2075 | |||
2076 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2145 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
2077 | 2146 | ||
2078 | // Un-comment the following line to print the raytrace results to the console. | 2147 | // Un-comment the following line to print the raytrace results to the console. |
@@ -2081,13 +2150,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2081 | if (ei.HitTF) | 2150 | if (ei.HitTF) |
2082 | { | 2151 | { |
2083 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 2152 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
2084 | } else | 2153 | } |
2154 | else | ||
2085 | { | 2155 | { |
2086 | // fall back to our stupid functionality | 2156 | // fall back to our stupid functionality |
2087 | pos = RayEnd; | 2157 | pos = RayEnd; |
2088 | } | 2158 | } |
2089 | |||
2090 | return pos; | ||
2091 | } | 2159 | } |
2092 | } | 2160 | } |
2093 | else | 2161 | else |
@@ -2098,8 +2166,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2098 | //increase height so its above the ground. | 2166 | //increase height so its above the ground. |
2099 | //should be getting the normal of the ground at the rez point and using that? | 2167 | //should be getting the normal of the ground at the rez point and using that? |
2100 | pos.Z += scale.Z / 2f; | 2168 | pos.Z += scale.Z / 2f; |
2101 | return pos; | 2169 | // return pos; |
2102 | } | 2170 | } |
2171 | |||
2172 | // check against posible water intercept | ||
2173 | if (wpos.Z > pos.Z) pos = wpos; | ||
2174 | return pos; | ||
2103 | } | 2175 | } |
2104 | 2176 | ||
2105 | 2177 | ||
@@ -2190,12 +2262,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2190 | { | 2262 | { |
2191 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) | 2263 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) |
2192 | { | 2264 | { |
2265 | sceneObject.IsDeleted = false; | ||
2193 | EventManager.TriggerObjectAddedToScene(sceneObject); | 2266 | EventManager.TriggerObjectAddedToScene(sceneObject); |
2194 | return true; | 2267 | return true; |
2195 | } | 2268 | } |
2196 | 2269 | ||
2197 | return false; | 2270 | return false; |
2198 | |||
2199 | } | 2271 | } |
2200 | 2272 | ||
2201 | /// <summary> | 2273 | /// <summary> |
@@ -2287,6 +2359,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2287 | /// </summary> | 2359 | /// </summary> |
2288 | public void DeleteAllSceneObjects() | 2360 | public void DeleteAllSceneObjects() |
2289 | { | 2361 | { |
2362 | DeleteAllSceneObjects(false); | ||
2363 | } | ||
2364 | |||
2365 | /// <summary> | ||
2366 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2367 | /// </summary> | ||
2368 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2369 | { | ||
2370 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2290 | lock (Entities) | 2371 | lock (Entities) |
2291 | { | 2372 | { |
2292 | EntityBase[] entities = Entities.GetEntities(); | 2373 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2295,11 +2376,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2295 | if (e is SceneObjectGroup) | 2376 | if (e is SceneObjectGroup) |
2296 | { | 2377 | { |
2297 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2378 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2298 | if (!sog.IsAttachment) | 2379 | if (sog != null && !sog.IsAttachment) |
2299 | DeleteSceneObject((SceneObjectGroup)e, false); | 2380 | { |
2381 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2382 | { | ||
2383 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2384 | } | ||
2385 | else | ||
2386 | { | ||
2387 | toReturn.Add((SceneObjectGroup)e); | ||
2388 | } | ||
2389 | } | ||
2300 | } | 2390 | } |
2301 | } | 2391 | } |
2302 | } | 2392 | } |
2393 | if (toReturn.Count > 0) | ||
2394 | { | ||
2395 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2396 | } | ||
2303 | } | 2397 | } |
2304 | 2398 | ||
2305 | /// <summary> | 2399 | /// <summary> |
@@ -2334,6 +2428,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2334 | 2428 | ||
2335 | foreach (SceneObjectPart part in partList) | 2429 | foreach (SceneObjectPart part in partList) |
2336 | { | 2430 | { |
2431 | if (part.KeyframeMotion != null) | ||
2432 | { | ||
2433 | part.KeyframeMotion.Delete(); | ||
2434 | part.KeyframeMotion = null; | ||
2435 | } | ||
2436 | |||
2337 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) | 2437 | if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0)) |
2338 | { | 2438 | { |
2339 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? | 2439 | PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed? |
@@ -2351,6 +2451,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2351 | } | 2451 | } |
2352 | 2452 | ||
2353 | group.DeleteGroupFromScene(silent); | 2453 | group.DeleteGroupFromScene(silent); |
2454 | if (!silent) | ||
2455 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2354 | 2456 | ||
2355 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2457 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2356 | } | 2458 | } |
@@ -2641,7 +2743,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2641 | // If the user is banned, we won't let any of their objects | 2743 | // If the user is banned, we won't let any of their objects |
2642 | // enter. Period. | 2744 | // enter. Period. |
2643 | // | 2745 | // |
2644 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID)) | 2746 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) |
2645 | { | 2747 | { |
2646 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | 2748 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); |
2647 | return false; | 2749 | return false; |
@@ -2649,6 +2751,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2649 | 2751 | ||
2650 | if (newPosition != Vector3.Zero) | 2752 | if (newPosition != Vector3.Zero) |
2651 | newObject.RootPart.GroupPosition = newPosition; | 2753 | newObject.RootPart.GroupPosition = newPosition; |
2754 | if (newObject.RootPart.KeyframeMotion != null) | ||
2755 | newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
2652 | 2756 | ||
2653 | if (!AddSceneObject(newObject)) | 2757 | if (!AddSceneObject(newObject)) |
2654 | { | 2758 | { |
@@ -2693,6 +2797,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2693 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2797 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2694 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2798 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2695 | { | 2799 | { |
2800 | if (sceneObject.OwnerID == UUID.Zero) | ||
2801 | { | ||
2802 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2803 | return false; | ||
2804 | } | ||
2805 | |||
2806 | // If the user is banned, we won't let any of their objects | ||
2807 | // enter. Period. | ||
2808 | // | ||
2809 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
2810 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2811 | { | ||
2812 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
2813 | |||
2814 | return false; | ||
2815 | } | ||
2816 | |||
2696 | // Force allocation of new LocalId | 2817 | // Force allocation of new LocalId |
2697 | // | 2818 | // |
2698 | SceneObjectPart[] parts = sceneObject.Parts; | 2819 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2726,16 +2847,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2726 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2847 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2727 | 2848 | ||
2728 | if (AttachmentsModule != null) | 2849 | if (AttachmentsModule != null) |
2729 | AttachmentsModule.AttachObject(sp, grp, 0, false, false); | 2850 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, false); |
2730 | } | 2851 | } |
2731 | else | 2852 | else |
2732 | { | 2853 | { |
2854 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2733 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2855 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2734 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2856 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2735 | } | 2857 | } |
2858 | if (sceneObject.OwnerID == UUID.Zero) | ||
2859 | { | ||
2860 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2861 | return false; | ||
2862 | } | ||
2736 | } | 2863 | } |
2737 | else | 2864 | else |
2738 | { | 2865 | { |
2866 | if (sceneObject.OwnerID == UUID.Zero) | ||
2867 | { | ||
2868 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2869 | return false; | ||
2870 | } | ||
2739 | AddRestoredSceneObject(sceneObject, true, false); | 2871 | AddRestoredSceneObject(sceneObject, true, false); |
2740 | } | 2872 | } |
2741 | 2873 | ||
@@ -2752,6 +2884,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2752 | return 2; // StateSource.PrimCrossing | 2884 | return 2; // StateSource.PrimCrossing |
2753 | } | 2885 | } |
2754 | 2886 | ||
2887 | public int GetUserFlags(UUID user) | ||
2888 | { | ||
2889 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2890 | /* | ||
2891 | ScenePresence sp; | ||
2892 | if (TryGetScenePresence(user, out sp)) | ||
2893 | { | ||
2894 | return sp.UserFlags; | ||
2895 | } | ||
2896 | else | ||
2897 | { | ||
2898 | */ | ||
2899 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2900 | if (uac == null) | ||
2901 | return 0; | ||
2902 | return uac.UserFlags; | ||
2903 | //} | ||
2904 | } | ||
2755 | #endregion | 2905 | #endregion |
2756 | 2906 | ||
2757 | #region Add/Remove Avatar Methods | 2907 | #region Add/Remove Avatar Methods |
@@ -2784,7 +2934,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2784 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 2934 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2785 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2935 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2786 | 2936 | ||
2787 | // CheckHeartbeat(); | 2937 | CheckHeartbeat(); |
2788 | 2938 | ||
2789 | sp = GetScenePresence(client.AgentId); | 2939 | sp = GetScenePresence(client.AgentId); |
2790 | 2940 | ||
@@ -2815,6 +2965,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2815 | // start the scripts again (since this is done in RezAttachments()). | 2965 | // start the scripts again (since this is done in RezAttachments()). |
2816 | // XXX: This is convoluted. | 2966 | // XXX: This is convoluted. |
2817 | sp.IsChildAgent = false; | 2967 | sp.IsChildAgent = false; |
2968 | sp.IsLoggingIn = true; | ||
2818 | 2969 | ||
2819 | if (AttachmentsModule != null) | 2970 | if (AttachmentsModule != null) |
2820 | Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); | 2971 | Util.FireAndForget(delegate(object o) { AttachmentsModule.RezAttachments(sp); }); |
@@ -2928,19 +3079,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2928 | // and the scene presence and the client, if they exist | 3079 | // and the scene presence and the client, if they exist |
2929 | try | 3080 | try |
2930 | { | 3081 | { |
2931 | // We need to wait for the client to make UDP contact first. | 3082 | ScenePresence sp = GetScenePresence(agentID); |
2932 | // It's the UDP contact that creates the scene presence | 3083 | |
2933 | ScenePresence sp = WaitGetScenePresence(agentID); | ||
2934 | if (sp != null) | 3084 | if (sp != null) |
2935 | { | 3085 | { |
2936 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 3086 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2937 | |||
2938 | sp.ControllingClient.Close(); | 3087 | sp.ControllingClient.Close(); |
2939 | } | 3088 | } |
2940 | else | 3089 | |
2941 | { | ||
2942 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2943 | } | ||
2944 | // BANG! SLASH! | 3090 | // BANG! SLASH! |
2945 | m_authenticateHandler.RemoveCircuit(agentID); | 3091 | m_authenticateHandler.RemoveCircuit(agentID); |
2946 | 3092 | ||
@@ -2985,6 +3131,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2985 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3131 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
2986 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3132 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
2987 | 3133 | ||
3134 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3135 | |||
2988 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3136 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2989 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3137 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
2990 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3138 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3041,6 +3189,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3041 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3189 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
3042 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3190 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
3043 | client.OnCopyInventoryItem += CopyInventoryItem; | 3191 | client.OnCopyInventoryItem += CopyInventoryItem; |
3192 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
3044 | client.OnMoveInventoryItem += MoveInventoryItem; | 3193 | client.OnMoveInventoryItem += MoveInventoryItem; |
3045 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3194 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
3046 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3195 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3112,6 +3261,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3112 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3261 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
3113 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3262 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
3114 | 3263 | ||
3264 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3265 | |||
3115 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3266 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3116 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3267 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3117 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3268 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3214,7 +3365,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3214 | /// </summary> | 3365 | /// </summary> |
3215 | /// <param name="agentId">The avatar's Unique ID</param> | 3366 | /// <param name="agentId">The avatar's Unique ID</param> |
3216 | /// <param name="client">The IClientAPI for the client</param> | 3367 | /// <param name="client">The IClientAPI for the client</param> |
3217 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3368 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3218 | { | 3369 | { |
3219 | if (EntityTransferModule != null) | 3370 | if (EntityTransferModule != null) |
3220 | { | 3371 | { |
@@ -3225,6 +3376,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3225 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3376 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3226 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3377 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3227 | } | 3378 | } |
3379 | return false; | ||
3228 | } | 3380 | } |
3229 | 3381 | ||
3230 | /// <summary> | 3382 | /// <summary> |
@@ -3334,6 +3486,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3334 | /// <param name="flags"></param> | 3486 | /// <param name="flags"></param> |
3335 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3487 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3336 | { | 3488 | { |
3489 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3490 | ScenePresence presence; | ||
3491 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3492 | { | ||
3493 | if (presence.Appearance != null) | ||
3494 | { | ||
3495 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3496 | } | ||
3497 | } | ||
3498 | |||
3337 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3499 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3338 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3500 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3339 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3501 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3471,6 +3633,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3471 | // It's possible for child agents to have transactions if changes are being made cross-border. | 3633 | // It's possible for child agents to have transactions if changes are being made cross-border. |
3472 | if (AgentTransactionsModule != null) | 3634 | if (AgentTransactionsModule != null) |
3473 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 3635 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
3636 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3474 | } | 3637 | } |
3475 | catch (Exception e) | 3638 | catch (Exception e) |
3476 | { | 3639 | { |
@@ -3663,38 +3826,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3663 | agent.firstname, agent.lastname, agent.Viewer); | 3826 | agent.firstname, agent.lastname, agent.Viewer); |
3664 | reason = "Access denied, your viewer is banned by the region owner"; | 3827 | reason = "Access denied, your viewer is banned by the region owner"; |
3665 | return false; | 3828 | return false; |
3666 | } | 3829 | } |
3830 | |||
3831 | |||
3832 | ScenePresence sp = GetScenePresence(agent.AgentID); | ||
3833 | |||
3834 | if (sp != null && !sp.IsChildAgent) | ||
3835 | { | ||
3836 | // We have a zombie from a crashed session. | ||
3837 | // Or the same user is trying to be root twice here, won't work. | ||
3838 | // Kill it. | ||
3839 | m_log.WarnFormat( | ||
3840 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", | ||
3841 | sp.Name, sp.UUID, RegionInfo.RegionName); | ||
3667 | 3842 | ||
3668 | ILandObject land; | 3843 | sp.ControllingClient.Close(true, true); |
3844 | sp = null; | ||
3845 | } | ||
3669 | 3846 | ||
3670 | lock (agent) | 3847 | lock (agent) |
3671 | { | 3848 | { |
3672 | ScenePresence sp = GetScenePresence(agent.AgentID); | ||
3673 | |||
3674 | if (sp != null && !sp.IsChildAgent) | ||
3675 | { | ||
3676 | // We have a zombie from a crashed session. | ||
3677 | // Or the same user is trying to be root twice here, won't work. | ||
3678 | // Kill it. | ||
3679 | m_log.WarnFormat( | ||
3680 | "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", | ||
3681 | sp.Name, sp.UUID, RegionInfo.RegionName); | ||
3682 | |||
3683 | sp.ControllingClient.Close(true); | ||
3684 | sp = null; | ||
3685 | } | ||
3686 | |||
3687 | land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3688 | |||
3689 | //On login test land permisions | 3849 | //On login test land permisions |
3690 | if (vialogin) | 3850 | if (vialogin) |
3691 | { | 3851 | { |
3692 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3852 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3853 | if (cache != null) | ||
3854 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3855 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3693 | { | 3856 | { |
3857 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3694 | return false; | 3858 | return false; |
3695 | } | 3859 | } |
3696 | } | 3860 | } |
3697 | 3861 | ||
3698 | if (sp == null) // We don't have an [child] agent here already | 3862 | if (sp == null) // We don't have an [child] agent here already |
3699 | { | 3863 | { |
3700 | if (requirePresenceLookup) | 3864 | if (requirePresenceLookup) |
@@ -3703,34 +3867,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
3703 | { | 3867 | { |
3704 | if (!VerifyUserPresence(agent, out reason)) | 3868 | if (!VerifyUserPresence(agent, out reason)) |
3705 | return false; | 3869 | return false; |
3706 | } | 3870 | } catch (Exception e) |
3707 | catch (Exception e) | ||
3708 | { | 3871 | { |
3709 | m_log.ErrorFormat( | 3872 | m_log.ErrorFormat( |
3710 | "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); | 3873 | "[SCENE]: Exception verifying presence {0}{1}", e.Message, e.StackTrace); |
3711 | |||
3712 | return false; | 3874 | return false; |
3713 | } | 3875 | } |
3714 | } | 3876 | } |
3715 | 3877 | ||
3716 | try | 3878 | try |
3717 | { | 3879 | { |
3718 | if (!AuthorizeUser(agent, out reason)) | 3880 | // Always check estate if this is a login. Always |
3719 | return false; | 3881 | // check if banned regions are to be blacked out. |
3882 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3883 | { | ||
3884 | if (!AuthorizeUser(agent, out reason)) | ||
3885 | return false; | ||
3886 | } | ||
3720 | } | 3887 | } |
3721 | catch (Exception e) | 3888 | catch (Exception e) |
3722 | { | 3889 | { |
3723 | m_log.ErrorFormat( | 3890 | m_log.ErrorFormat( |
3724 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); | 3891 | "[SCENE]: Exception authorizing user {0}{1}", e.Message, e.StackTrace); |
3725 | |||
3726 | return false; | 3892 | return false; |
3727 | } | 3893 | } |
3728 | 3894 | ||
3729 | m_log.InfoFormat( | 3895 | m_log.InfoFormat( |
3730 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", | 3896 | "[SCENE]: Region {0} authenticated and authorized incoming {1} agent {2} {3} {4} (circuit code {5})", |
3731 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, | 3897 | RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname, |
3732 | agent.AgentID, agent.circuitcode); | 3898 | agent.AgentID, agent.circuitcode); |
3733 | 3899 | ||
3734 | if (CapsModule != null) | 3900 | if (CapsModule != null) |
3735 | { | 3901 | { |
3736 | CapsModule.SetAgentCapsSeeds(agent); | 3902 | CapsModule.SetAgentCapsSeeds(agent); |
@@ -3742,15 +3908,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3742 | // Let the SP know how we got here. This has a lot of interesting | 3908 | // Let the SP know how we got here. This has a lot of interesting |
3743 | // uses down the line. | 3909 | // uses down the line. |
3744 | sp.TeleportFlags = (TPFlags)teleportFlags; | 3910 | sp.TeleportFlags = (TPFlags)teleportFlags; |
3745 | 3911 | ||
3746 | if (sp.IsChildAgent) | 3912 | if (sp.IsChildAgent) |
3747 | { | 3913 | { |
3748 | m_log.DebugFormat( | 3914 | m_log.DebugFormat( |
3749 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", | 3915 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", |
3750 | agent.AgentID, RegionInfo.RegionName); | 3916 | agent.AgentID, RegionInfo.RegionName); |
3751 | 3917 | ||
3752 | sp.AdjustKnownSeeds(); | 3918 | sp.AdjustKnownSeeds(); |
3753 | 3919 | ||
3754 | if (CapsModule != null) | 3920 | if (CapsModule != null) |
3755 | CapsModule.SetAgentCapsSeeds(agent); | 3921 | CapsModule.SetAgentCapsSeeds(agent); |
3756 | } | 3922 | } |
@@ -3852,6 +4018,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3852 | } | 4018 | } |
3853 | 4019 | ||
3854 | // Honor parcel landing type and position. | 4020 | // Honor parcel landing type and position. |
4021 | /* | ||
4022 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3855 | if (land != null) | 4023 | if (land != null) |
3856 | { | 4024 | { |
3857 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 4025 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3859,25 +4027,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
3859 | agent.startpos = land.LandData.UserLocation; | 4027 | agent.startpos = land.LandData.UserLocation; |
3860 | } | 4028 | } |
3861 | } | 4029 | } |
4030 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3862 | } | 4031 | } |
3863 | 4032 | ||
3864 | return true; | 4033 | return true; |
3865 | } | 4034 | } |
3866 | 4035 | ||
3867 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 4036 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3868 | { | 4037 | { |
3869 | bool banned = land.IsBannedFromLand(agent.AgentID); | 4038 | if (posX < 0) |
3870 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 4039 | posX = 0; |
4040 | else if (posX >= 256) | ||
4041 | posX = 255.999f; | ||
4042 | if (posY < 0) | ||
4043 | posY = 0; | ||
4044 | else if (posY >= 256) | ||
4045 | posY = 255.999f; | ||
4046 | |||
4047 | reason = String.Empty; | ||
4048 | if (Permissions.IsGod(agentID)) | ||
4049 | return true; | ||
4050 | |||
4051 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
4052 | if (land == null) | ||
4053 | return false; | ||
4054 | |||
4055 | bool banned = land.IsBannedFromLand(agentID); | ||
4056 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3871 | 4057 | ||
3872 | if (banned || restricted) | 4058 | if (banned || restricted) |
3873 | { | 4059 | { |
3874 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 4060 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3875 | if (nearestParcel != null) | 4061 | if (nearestParcel != null) |
3876 | { | 4062 | { |
3877 | //Move agent to nearest allowed | 4063 | //Move agent to nearest allowed |
3878 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 4064 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3879 | agent.startpos.X = newPosition.X; | 4065 | posX = newPosition.X; |
3880 | agent.startpos.Y = newPosition.Y; | 4066 | posY = newPosition.Y; |
3881 | } | 4067 | } |
3882 | else | 4068 | else |
3883 | { | 4069 | { |
@@ -3939,7 +4125,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3939 | 4125 | ||
3940 | if (!m_strictAccessControl) return true; | 4126 | if (!m_strictAccessControl) return true; |
3941 | if (Permissions.IsGod(agent.AgentID)) return true; | 4127 | if (Permissions.IsGod(agent.AgentID)) return true; |
3942 | 4128 | ||
3943 | if (AuthorizationService != null) | 4129 | if (AuthorizationService != null) |
3944 | { | 4130 | { |
3945 | if (!AuthorizationService.IsAuthorizedForRegion( | 4131 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3954,7 +4140,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3954 | 4140 | ||
3955 | if (RegionInfo.EstateSettings != null) | 4141 | if (RegionInfo.EstateSettings != null) |
3956 | { | 4142 | { |
3957 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 4143 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, 0)) |
3958 | { | 4144 | { |
3959 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 4145 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3960 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 4146 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -4144,6 +4330,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4144 | 4330 | ||
4145 | // XPTO: if this agent is not allowed here as root, always return false | 4331 | // XPTO: if this agent is not allowed here as root, always return false |
4146 | 4332 | ||
4333 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4334 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4335 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4336 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4337 | { | ||
4338 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4339 | return false; | ||
4340 | } | ||
4341 | |||
4147 | // TODO: This check should probably be in QueryAccess(). | 4342 | // TODO: This check should probably be in QueryAccess(). |
4148 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4343 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
4149 | if (nearestParcel == null) | 4344 | if (nearestParcel == null) |
@@ -4208,7 +4403,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4208 | /// <param name='agentID'></param> | 4403 | /// <param name='agentID'></param> |
4209 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 4404 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4210 | { | 4405 | { |
4211 | int ntimes = 10; | 4406 | int ntimes = 30; |
4212 | ScenePresence sp = null; | 4407 | ScenePresence sp = null; |
4213 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 4408 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4214 | Thread.Sleep(1000); | 4409 | Thread.Sleep(1000); |
@@ -4238,6 +4433,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4238 | return false; | 4433 | return false; |
4239 | } | 4434 | } |
4240 | 4435 | ||
4436 | public bool IncomingCloseAgent(UUID agentID) | ||
4437 | { | ||
4438 | return IncomingCloseAgent(agentID, false); | ||
4439 | } | ||
4440 | |||
4441 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4442 | { | ||
4443 | return IncomingCloseAgent(agentID, true); | ||
4444 | } | ||
4445 | |||
4241 | /// <summary> | 4446 | /// <summary> |
4242 | /// Tell a single agent to disconnect from the region. | 4447 | /// Tell a single agent to disconnect from the region. |
4243 | /// </summary> | 4448 | /// </summary> |
@@ -4253,7 +4458,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4253 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); | 4458 | ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); |
4254 | if (presence != null) | 4459 | if (presence != null) |
4255 | { | 4460 | { |
4256 | presence.ControllingClient.Close(force); | 4461 | presence.ControllingClient.Close(force, force); |
4257 | return true; | 4462 | return true; |
4258 | } | 4463 | } |
4259 | 4464 | ||
@@ -4886,7 +5091,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4886 | { | 5091 | { |
4887 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 5092 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
4888 | { | 5093 | { |
4889 | if (grp.RootPart.Expires <= DateTime.Now) | 5094 | if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now) |
4890 | DeleteSceneObject(grp, false); | 5095 | DeleteSceneObject(grp, false); |
4891 | } | 5096 | } |
4892 | } | 5097 | } |
@@ -4900,35 +5105,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
4900 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 5105 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
4901 | } | 5106 | } |
4902 | 5107 | ||
4903 | public int GetHealth() | 5108 | public int GetHealth(out int flags, out string message) |
4904 | { | 5109 | { |
4905 | // Returns: | 5110 | // Returns: |
4906 | // 1 = sim is up and accepting http requests. The heartbeat has | 5111 | // 1 = sim is up and accepting http requests. The heartbeat has |
4907 | // stopped and the sim is probably locked up, but a remote | 5112 | // stopped and the sim is probably locked up, but a remote |
4908 | // admin restart may succeed | 5113 | // admin restart may succeed |
4909 | // | 5114 | // |
4910 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 5115 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4911 | // usable for people within and logins _may_ work | 5116 | // usable for people within |
5117 | // | ||
5118 | // 3 = Sim is up and one packet thread is running. Sim is | ||
5119 | // unstable and will not accept new logins | ||
5120 | // | ||
5121 | // 4 = Sim is up and both packet threads are running. Sim is | ||
5122 | // likely usable | ||
4912 | // | 5123 | // |
4913 | // 3 = We have seen a new user enter within the past 4 minutes | 5124 | // 5 = We have seen a new user enter within the past 4 minutes |
4914 | // which can be seen as positive confirmation of sim health | 5125 | // which can be seen as positive confirmation of sim health |
4915 | // | 5126 | // |
5127 | |||
5128 | flags = 0; | ||
5129 | message = String.Empty; | ||
5130 | |||
5131 | CheckHeartbeat(); | ||
5132 | |||
5133 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
5134 | { | ||
5135 | // We're still starting | ||
5136 | // 0 means "in startup", it can't happen another way, since | ||
5137 | // to get here, we must be able to accept http connections | ||
5138 | return 0; | ||
5139 | } | ||
5140 | |||
4916 | int health=1; // Start at 1, means we're up | 5141 | int health=1; // Start at 1, means we're up |
4917 | 5142 | ||
4918 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5143 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
4919 | health += 1; | 5144 | { |
5145 | health+=1; | ||
5146 | flags |= 1; | ||
5147 | } | ||
5148 | |||
5149 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
5150 | { | ||
5151 | health+=1; | ||
5152 | flags |= 2; | ||
5153 | } | ||
5154 | |||
5155 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
5156 | { | ||
5157 | health+=1; | ||
5158 | flags |= 4; | ||
5159 | } | ||
4920 | else | 5160 | else |
5161 | { | ||
5162 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
5163 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
5164 | proc.EnableRaisingEvents=false; | ||
5165 | proc.StartInfo.FileName = "/bin/kill"; | ||
5166 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
5167 | proc.Start(); | ||
5168 | proc.WaitForExit(); | ||
5169 | Thread.Sleep(1000); | ||
5170 | Environment.Exit(1); | ||
5171 | } | ||
5172 | |||
5173 | if (flags != 7) | ||
4921 | return health; | 5174 | return health; |
4922 | 5175 | ||
4923 | // A login in the last 4 mins? We can't be doing too badly | 5176 | // A login in the last 4 mins? We can't be doing too badly |
4924 | // | 5177 | // |
4925 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 5178 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4926 | health++; | 5179 | health++; |
4927 | else | 5180 | else |
4928 | return health; | 5181 | return health; |
4929 | 5182 | ||
4930 | // CheckHeartbeat(); | ||
4931 | |||
4932 | return health; | 5183 | return health; |
4933 | } | 5184 | } |
4934 | 5185 | ||
@@ -5016,7 +5267,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5016 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 5267 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
5017 | if (wasUsingPhysics) | 5268 | if (wasUsingPhysics) |
5018 | { | 5269 | { |
5019 | 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 | 5270 | 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 |
5020 | } | 5271 | } |
5021 | } | 5272 | } |
5022 | 5273 | ||
@@ -5115,14 +5366,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5115 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 5366 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
5116 | } | 5367 | } |
5117 | 5368 | ||
5118 | // private void CheckHeartbeat() | 5369 | private void CheckHeartbeat() |
5119 | // { | 5370 | { |
5120 | // if (m_firstHeartbeat) | 5371 | if (m_firstHeartbeat) |
5121 | // return; | 5372 | return; |
5122 | // | 5373 | |
5123 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 5374 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
5124 | // StartTimer(); | 5375 | Start(); |
5125 | // } | 5376 | } |
5126 | 5377 | ||
5127 | public override ISceneObject DeserializeObject(string representation) | 5378 | public override ISceneObject DeserializeObject(string representation) |
5128 | { | 5379 | { |
@@ -5134,9 +5385,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5134 | get { return m_allowScriptCrossings; } | 5385 | get { return m_allowScriptCrossings; } |
5135 | } | 5386 | } |
5136 | 5387 | ||
5137 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 5388 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
5138 | { | 5389 | { |
5139 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 5390 | return GetNearestAllowedPosition(avatar, null); |
5391 | } | ||
5392 | |||
5393 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
5394 | { | ||
5395 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); | ||
5140 | 5396 | ||
5141 | if (nearestParcel != null) | 5397 | if (nearestParcel != null) |
5142 | { | 5398 | { |
@@ -5145,10 +5401,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5145 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5401 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
5146 | if (nearestPoint != null) | 5402 | if (nearestPoint != null) |
5147 | { | 5403 | { |
5148 | // m_log.DebugFormat( | 5404 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
5149 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
5150 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
5151 | |||
5152 | return nearestPoint.Value; | 5405 | return nearestPoint.Value; |
5153 | } | 5406 | } |
5154 | 5407 | ||
@@ -5158,17 +5411,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
5158 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 5411 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
5159 | if (nearestPoint != null) | 5412 | if (nearestPoint != null) |
5160 | { | 5413 | { |
5161 | // m_log.DebugFormat( | 5414 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
5162 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
5163 | |||
5164 | return nearestPoint.Value; | 5415 | return nearestPoint.Value; |
5165 | } | 5416 | } |
5166 | 5417 | ||
5167 | //Ultimate backup if we have no idea where they are | 5418 | ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); |
5168 | // m_log.DebugFormat( | 5419 | if (dest != excludeParcel) |
5169 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | 5420 | { |
5421 | // Ultimate backup if we have no idea where they are and | ||
5422 | // the last allowed position was in another parcel | ||
5423 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
5424 | return avatar.lastKnownAllowedPosition; | ||
5425 | } | ||
5170 | 5426 | ||
5171 | return avatar.lastKnownAllowedPosition; | 5427 | // else fall through to region edge |
5172 | } | 5428 | } |
5173 | 5429 | ||
5174 | //Go to the edge, this happens in teleporting to a region with no available parcels | 5430 | //Go to the edge, this happens in teleporting to a region with no available parcels |
@@ -5202,13 +5458,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
5202 | 5458 | ||
5203 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 5459 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
5204 | { | 5460 | { |
5461 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
5462 | } | ||
5463 | |||
5464 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
5465 | { | ||
5205 | List<ILandObject> all = AllParcels(); | 5466 | List<ILandObject> all = AllParcels(); |
5206 | float minParcelDistance = float.MaxValue; | 5467 | float minParcelDistance = float.MaxValue; |
5207 | ILandObject nearestParcel = null; | 5468 | ILandObject nearestParcel = null; |
5208 | 5469 | ||
5209 | foreach (var parcel in all) | 5470 | foreach (var parcel in all) |
5210 | { | 5471 | { |
5211 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 5472 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
5212 | { | 5473 | { |
5213 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 5474 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
5214 | if (parcelDistance < minParcelDistance) | 5475 | if (parcelDistance < minParcelDistance) |
@@ -5424,7 +5685,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5424 | mapModule.GenerateMaptile(); | 5685 | mapModule.GenerateMaptile(); |
5425 | } | 5686 | } |
5426 | 5687 | ||
5427 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5688 | // public void CleanDroppedAttachments() |
5689 | // { | ||
5690 | // List<SceneObjectGroup> objectsToDelete = | ||
5691 | // new List<SceneObjectGroup>(); | ||
5692 | // | ||
5693 | // lock (m_cleaningAttachments) | ||
5694 | // { | ||
5695 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5696 | // { | ||
5697 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5698 | // { | ||
5699 | // UUID agentID = grp.OwnerID; | ||
5700 | // if (agentID == UUID.Zero) | ||
5701 | // { | ||
5702 | // objectsToDelete.Add(grp); | ||
5703 | // return; | ||
5704 | // } | ||
5705 | // | ||
5706 | // ScenePresence sp = GetScenePresence(agentID); | ||
5707 | // if (sp == null) | ||
5708 | // { | ||
5709 | // objectsToDelete.Add(grp); | ||
5710 | // return; | ||
5711 | // } | ||
5712 | // } | ||
5713 | // }); | ||
5714 | // } | ||
5715 | // | ||
5716 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5717 | // { | ||
5718 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5719 | // DeleteSceneObject(grp, true); | ||
5720 | // } | ||
5721 | // } | ||
5722 | |||
5723 | public void ThreadAlive(int threadCode) | ||
5724 | { | ||
5725 | switch(threadCode) | ||
5726 | { | ||
5727 | case 1: // Incoming | ||
5728 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5729 | break; | ||
5730 | case 2: // Incoming | ||
5731 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5732 | break; | ||
5733 | } | ||
5734 | } | ||
5735 | |||
5736 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5428 | { | 5737 | { |
5429 | RegenerateMaptile(); | 5738 | RegenerateMaptile(); |
5430 | 5739 | ||
@@ -5452,6 +5761,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
5452 | /// <returns></returns> | 5761 | /// <returns></returns> |
5453 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5762 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5454 | { | 5763 | { |
5764 | reason = "You are banned from the region"; | ||
5765 | |||
5455 | if (EntityTransferModule.IsInTransit(agentID)) | 5766 | if (EntityTransferModule.IsInTransit(agentID)) |
5456 | { | 5767 | { |
5457 | reason = "Agent is still in transit from this region"; | 5768 | reason = "Agent is still in transit from this region"; |
@@ -5463,6 +5774,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
5463 | return false; | 5774 | return false; |
5464 | } | 5775 | } |
5465 | 5776 | ||
5777 | if (Permissions.IsGod(agentID)) | ||
5778 | { | ||
5779 | reason = String.Empty; | ||
5780 | return true; | ||
5781 | } | ||
5782 | |||
5466 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 5783 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5467 | // However, the long term fix is to make sure root agent count is always accurate. | 5784 | // However, the long term fix is to make sure root agent count is always accurate. |
5468 | m_sceneGraph.RecalculateStats(); | 5785 | m_sceneGraph.RecalculateStats(); |
@@ -5483,6 +5800,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5483 | } | 5800 | } |
5484 | } | 5801 | } |
5485 | 5802 | ||
5803 | ScenePresence presence = GetScenePresence(agentID); | ||
5804 | IClientAPI client = null; | ||
5805 | AgentCircuitData aCircuit = null; | ||
5806 | |||
5807 | if (presence != null) | ||
5808 | { | ||
5809 | client = presence.ControllingClient; | ||
5810 | if (client != null) | ||
5811 | aCircuit = client.RequestClientInfo(); | ||
5812 | } | ||
5813 | |||
5814 | // We may be called before there is a presence or a client. | ||
5815 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5816 | if (client == null) | ||
5817 | { | ||
5818 | aCircuit = new AgentCircuitData(); | ||
5819 | aCircuit.AgentID = agentID; | ||
5820 | aCircuit.firstname = String.Empty; | ||
5821 | aCircuit.lastname = String.Empty; | ||
5822 | } | ||
5823 | |||
5824 | try | ||
5825 | { | ||
5826 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5827 | { | ||
5828 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5829 | return false; | ||
5830 | } | ||
5831 | } | ||
5832 | catch (Exception e) | ||
5833 | { | ||
5834 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5835 | return false; | ||
5836 | } | ||
5837 | |||
5486 | if (position == Vector3.Zero) // Teleport | 5838 | if (position == Vector3.Zero) // Teleport |
5487 | { | 5839 | { |
5488 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5840 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5511,13 +5863,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5511 | } | 5863 | } |
5512 | } | 5864 | } |
5513 | } | 5865 | } |
5866 | |||
5867 | float posX = 128.0f; | ||
5868 | float posY = 128.0f; | ||
5869 | |||
5870 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5871 | { | ||
5872 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5873 | return false; | ||
5874 | } | ||
5875 | } | ||
5876 | else // Walking | ||
5877 | { | ||
5878 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5879 | if (land == null) | ||
5880 | return false; | ||
5881 | |||
5882 | bool banned = land.IsBannedFromLand(agentID); | ||
5883 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5884 | |||
5885 | if (banned || restricted) | ||
5886 | return false; | ||
5514 | } | 5887 | } |
5515 | 5888 | ||
5516 | reason = String.Empty; | 5889 | reason = String.Empty; |
5517 | return true; | 5890 | return true; |
5518 | } | 5891 | } |
5519 | 5892 | ||
5520 | /// <summary> | 5893 | public void StartTimerWatchdog() |
5894 | { | ||
5895 | m_timerWatchdog.Interval = 1000; | ||
5896 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5897 | m_timerWatchdog.AutoReset = true; | ||
5898 | m_timerWatchdog.Start(); | ||
5899 | } | ||
5900 | |||
5901 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5902 | { | ||
5903 | CheckHeartbeat(); | ||
5904 | } | ||
5905 | |||
5521 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5906 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5522 | /// autopilot that moves an avatar to a sit target!. | 5907 | /// autopilot that moves an avatar to a sit target!. |
5523 | /// </summary> | 5908 | /// </summary> |
@@ -5596,6 +5981,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5596 | return m_SpawnPoint - 1; | 5981 | return m_SpawnPoint - 1; |
5597 | } | 5982 | } |
5598 | 5983 | ||
5984 | private void HandleGcCollect(string module, string[] args) | ||
5985 | { | ||
5986 | GC.Collect(); | ||
5987 | } | ||
5988 | |||
5599 | /// <summary> | 5989 | /// <summary> |
5600 | /// Wrappers to get physics modules retrieve assets. | 5990 | /// Wrappers to get physics modules retrieve assets. |
5601 | /// </summary> | 5991 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index d3e968e..74c9582 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 305f8a4..775a4c2 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -194,10 +194,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | public delegate void SendCloseChildAgentDelegate(UUID agentID, ulong regionHandle); | ||
198 | |||
197 | /// <summary> | 199 | /// <summary> |
198 | /// Closes a child agent on a given region | 200 | /// This Closes child agents on neighboring regions |
201 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | ||
199 | /// </summary> | 202 | /// </summary> |
200 | protected void SendCloseChildAgent(UUID agentID, ulong regionHandle) | 203 | protected void SendCloseChildAgentAsync(UUID agentID, ulong regionHandle) |
201 | { | 204 | { |
202 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. | 205 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. |
203 | 206 | ||
@@ -206,30 +209,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
206 | Utils.LongToUInts(regionHandle, out x, out y); | 209 | Utils.LongToUInts(regionHandle, out x, out y); |
207 | 210 | ||
208 | GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); | 211 | GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); |
212 | m_scene.SimulationService.CloseChildAgent(destination, agentID); | ||
213 | } | ||
209 | 214 | ||
210 | m_log.DebugFormat( | 215 | private void SendCloseChildAgentCompleted(IAsyncResult iar) |
211 | "[SCENE COMMUNICATION SERVICE]: Sending close agent ID {0} to {1}", agentID, destination.RegionName); | 216 | { |
212 | 217 | SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate)iar.AsyncState; | |
213 | m_scene.SimulationService.CloseAgent(destination, agentID); | 218 | icon.EndInvoke(iar); |
214 | } | 219 | } |
215 | 220 | ||
216 | /// <summary> | ||
217 | /// Closes a child agents in a collection of regions. Does so asynchronously | ||
218 | /// so that the caller doesn't wait. | ||
219 | /// </summary> | ||
220 | /// <param name="agentID"></param> | ||
221 | /// <param name="regionslst"></param> | ||
222 | public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst) | 221 | public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst) |
223 | { | 222 | { |
224 | foreach (ulong handle in regionslst) | 223 | foreach (ulong handle in regionslst) |
225 | { | 224 | { |
226 | SendCloseChildAgent(agentID, handle); | 225 | SendCloseChildAgentDelegate d = SendCloseChildAgentAsync; |
226 | d.BeginInvoke(agentID, handle, | ||
227 | SendCloseChildAgentCompleted, | ||
228 | d); | ||
227 | } | 229 | } |
228 | } | 230 | } |
229 | 231 | ||
230 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) | 232 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) |
231 | { | 233 | { |
232 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); | 234 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); |
233 | } | 235 | } |
234 | } | 236 | } |
235 | } \ No newline at end of file | 237 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a4383fd..e599e90 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -41,6 +41,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
41 | { | 41 | { |
42 | public delegate void PhysicsCrash(); | 42 | public delegate void PhysicsCrash(); |
43 | 43 | ||
44 | public delegate void AttachToBackupDelegate(SceneObjectGroup sog); | ||
45 | |||
46 | public delegate void DetachFromBackupDelegate(SceneObjectGroup sog); | ||
47 | |||
48 | public delegate void ChangedBackupDelegate(SceneObjectGroup sog); | ||
49 | |||
44 | /// <summary> | 50 | /// <summary> |
45 | /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components | 51 | /// This class used to be called InnerScene and may not yet truly be a SceneGraph. The non scene graph components |
46 | /// should be migrated out over time. | 52 | /// should be migrated out over time. |
@@ -54,11 +60,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
54 | protected internal event PhysicsCrash UnRecoverableError; | 60 | protected internal event PhysicsCrash UnRecoverableError; |
55 | private PhysicsCrash handlerPhysicsCrash = null; | 61 | private PhysicsCrash handlerPhysicsCrash = null; |
56 | 62 | ||
63 | public event AttachToBackupDelegate OnAttachToBackup; | ||
64 | public event DetachFromBackupDelegate OnDetachFromBackup; | ||
65 | public event ChangedBackupDelegate OnChangeBackup; | ||
66 | |||
57 | #endregion | 67 | #endregion |
58 | 68 | ||
59 | #region Fields | 69 | #region Fields |
60 | 70 | ||
61 | protected object m_presenceLock = new object(); | 71 | protected OpenMetaverse.ReaderWriterLockSlim m_scenePresencesLock = new OpenMetaverse.ReaderWriterLockSlim(); |
62 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); | 72 | protected Dictionary<UUID, ScenePresence> m_scenePresenceMap = new Dictionary<UUID, ScenePresence>(); |
63 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); | 73 | protected List<ScenePresence> m_scenePresenceArray = new List<ScenePresence>(); |
64 | 74 | ||
@@ -127,13 +137,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
127 | 137 | ||
128 | protected internal void Close() | 138 | protected internal void Close() |
129 | { | 139 | { |
130 | lock (m_presenceLock) | 140 | m_scenePresencesLock.EnterWriteLock(); |
141 | try | ||
131 | { | 142 | { |
132 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); | 143 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); |
133 | List<ScenePresence> newlist = new List<ScenePresence>(); | 144 | List<ScenePresence> newlist = new List<ScenePresence>(); |
134 | m_scenePresenceMap = newmap; | 145 | m_scenePresenceMap = newmap; |
135 | m_scenePresenceArray = newlist; | 146 | m_scenePresenceArray = newlist; |
136 | } | 147 | } |
148 | finally | ||
149 | { | ||
150 | m_scenePresencesLock.ExitWriteLock(); | ||
151 | } | ||
137 | 152 | ||
138 | lock (SceneObjectGroupsByFullID) | 153 | lock (SceneObjectGroupsByFullID) |
139 | SceneObjectGroupsByFullID.Clear(); | 154 | SceneObjectGroupsByFullID.Clear(); |
@@ -254,6 +269,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
254 | protected internal bool AddRestoredSceneObject( | 269 | protected internal bool AddRestoredSceneObject( |
255 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 270 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
256 | { | 271 | { |
272 | if (!m_parentScene.CombineRegions) | ||
273 | { | ||
274 | // KF: Check for out-of-region, move inside and make static. | ||
275 | Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, | ||
276 | sceneObject.RootPart.GroupPosition.Y, | ||
277 | sceneObject.RootPart.GroupPosition.Z); | ||
278 | if (!(((sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim) && (sceneObject.RootPart.Shape.State != 0))) && (npos.X < 0.0 || npos.Y < 0.0 || npos.Z < 0.0 || | ||
279 | npos.X > Constants.RegionSize || | ||
280 | npos.Y > Constants.RegionSize)) | ||
281 | { | ||
282 | if (npos.X < 0.0) npos.X = 1.0f; | ||
283 | if (npos.Y < 0.0) npos.Y = 1.0f; | ||
284 | if (npos.Z < 0.0) npos.Z = 0.0f; | ||
285 | if (npos.X > Constants.RegionSize) npos.X = Constants.RegionSize - 1.0f; | ||
286 | if (npos.Y > Constants.RegionSize) npos.Y = Constants.RegionSize - 1.0f; | ||
287 | |||
288 | foreach (SceneObjectPart part in sceneObject.Parts) | ||
289 | { | ||
290 | part.GroupPosition = npos; | ||
291 | } | ||
292 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
293 | sceneObject.RootPart.AngularVelocity = Vector3.Zero; | ||
294 | sceneObject.RootPart.Acceleration = Vector3.Zero; | ||
295 | sceneObject.RootPart.Velocity = Vector3.Zero; | ||
296 | } | ||
297 | } | ||
298 | |||
257 | if (attachToBackup && (!alreadyPersisted)) | 299 | if (attachToBackup && (!alreadyPersisted)) |
258 | { | 300 | { |
259 | sceneObject.ForceInventoryPersistence(); | 301 | sceneObject.ForceInventoryPersistence(); |
@@ -317,9 +359,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
317 | if (pa != null && pa.IsPhysical && vel != Vector3.Zero) | 359 | if (pa != null && pa.IsPhysical && vel != Vector3.Zero) |
318 | { | 360 | { |
319 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); | 361 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); |
320 | sceneObject.Velocity = vel; | ||
321 | } | 362 | } |
322 | 363 | ||
323 | return true; | 364 | return true; |
324 | } | 365 | } |
325 | 366 | ||
@@ -344,6 +385,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
344 | /// </returns> | 385 | /// </returns> |
345 | protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) | 386 | protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
346 | { | 387 | { |
388 | if (sceneObject == null) | ||
389 | { | ||
390 | m_log.ErrorFormat("[SCENEGRAPH]: Tried to add null scene object"); | ||
391 | return false; | ||
392 | } | ||
347 | if (sceneObject.UUID == UUID.Zero) | 393 | if (sceneObject.UUID == UUID.Zero) |
348 | { | 394 | { |
349 | m_log.ErrorFormat( | 395 | m_log.ErrorFormat( |
@@ -475,6 +521,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
475 | m_updateList[obj.UUID] = obj; | 521 | m_updateList[obj.UUID] = obj; |
476 | } | 522 | } |
477 | 523 | ||
524 | public void FireAttachToBackup(SceneObjectGroup obj) | ||
525 | { | ||
526 | if (OnAttachToBackup != null) | ||
527 | { | ||
528 | OnAttachToBackup(obj); | ||
529 | } | ||
530 | } | ||
531 | |||
532 | public void FireDetachFromBackup(SceneObjectGroup obj) | ||
533 | { | ||
534 | if (OnDetachFromBackup != null) | ||
535 | { | ||
536 | OnDetachFromBackup(obj); | ||
537 | } | ||
538 | } | ||
539 | |||
540 | public void FireChangeBackup(SceneObjectGroup obj) | ||
541 | { | ||
542 | if (OnChangeBackup != null) | ||
543 | { | ||
544 | OnChangeBackup(obj); | ||
545 | } | ||
546 | } | ||
547 | |||
478 | /// <summary> | 548 | /// <summary> |
479 | /// Process all pending updates | 549 | /// Process all pending updates |
480 | /// </summary> | 550 | /// </summary> |
@@ -519,12 +589,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
519 | 589 | ||
520 | protected internal void AddPhysicalPrim(int number) | 590 | protected internal void AddPhysicalPrim(int number) |
521 | { | 591 | { |
522 | m_physicalPrim++; | 592 | m_physicalPrim += number; |
523 | } | 593 | } |
524 | 594 | ||
525 | protected internal void RemovePhysicalPrim(int number) | 595 | protected internal void RemovePhysicalPrim(int number) |
526 | { | 596 | { |
527 | m_physicalPrim--; | 597 | m_physicalPrim -= number; |
528 | } | 598 | } |
529 | 599 | ||
530 | protected internal void AddToScriptLPS(int number) | 600 | protected internal void AddToScriptLPS(int number) |
@@ -592,7 +662,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
592 | 662 | ||
593 | Entities[presence.UUID] = presence; | 663 | Entities[presence.UUID] = presence; |
594 | 664 | ||
595 | lock (m_presenceLock) | 665 | m_scenePresencesLock.EnterWriteLock(); |
666 | try | ||
596 | { | 667 | { |
597 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 668 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
598 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 669 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -616,6 +687,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
616 | m_scenePresenceMap = newmap; | 687 | m_scenePresenceMap = newmap; |
617 | m_scenePresenceArray = newlist; | 688 | m_scenePresenceArray = newlist; |
618 | } | 689 | } |
690 | finally | ||
691 | { | ||
692 | m_scenePresencesLock.ExitWriteLock(); | ||
693 | } | ||
619 | } | 694 | } |
620 | 695 | ||
621 | /// <summary> | 696 | /// <summary> |
@@ -630,7 +705,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
630 | agentID); | 705 | agentID); |
631 | } | 706 | } |
632 | 707 | ||
633 | lock (m_presenceLock) | 708 | m_scenePresencesLock.EnterWriteLock(); |
709 | try | ||
634 | { | 710 | { |
635 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 711 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
636 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 712 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -652,6 +728,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
652 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); | 728 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); |
653 | } | 729 | } |
654 | } | 730 | } |
731 | finally | ||
732 | { | ||
733 | m_scenePresencesLock.ExitWriteLock(); | ||
734 | } | ||
655 | } | 735 | } |
656 | 736 | ||
657 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) | 737 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) |
@@ -1205,6 +1285,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
1205 | 1285 | ||
1206 | #region Client Event handlers | 1286 | #region Client Event handlers |
1207 | 1287 | ||
1288 | protected internal void ClientChangeObject(uint localID, object odata, IClientAPI remoteClient) | ||
1289 | { | ||
1290 | SceneObjectPart part = GetSceneObjectPart(localID); | ||
1291 | ObjectChangeData data = (ObjectChangeData)odata; | ||
1292 | |||
1293 | if (part != null) | ||
1294 | { | ||
1295 | SceneObjectGroup grp = part.ParentGroup; | ||
1296 | if (grp != null) | ||
1297 | { | ||
1298 | if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) | ||
1299 | { | ||
1300 | // These two are exceptions SL makes in the interpretation | ||
1301 | // of the change flags. Must check them here because otherwise | ||
1302 | // the group flag (see below) would be lost | ||
1303 | if (data.change == ObjectChangeType.groupS) | ||
1304 | data.change = ObjectChangeType.primS; | ||
1305 | if (data.change == ObjectChangeType.groupPS) | ||
1306 | data.change = ObjectChangeType.primPS; | ||
1307 | part.StoreUndoState(data.change); // lets test only saving what we changed | ||
1308 | grp.doChangeObject(part, (ObjectChangeData)data); | ||
1309 | } | ||
1310 | else | ||
1311 | { | ||
1312 | // Is this any kind of group operation? | ||
1313 | if ((data.change & ObjectChangeType.Group) != 0) | ||
1314 | { | ||
1315 | // Is a move and/or rotation requested? | ||
1316 | if ((data.change & (ObjectChangeType.Position | ObjectChangeType.Rotation)) != 0) | ||
1317 | { | ||
1318 | // Are we allowed to move it? | ||
1319 | if (m_parentScene.Permissions.CanMoveObject(grp.UUID, remoteClient.AgentId)) | ||
1320 | { | ||
1321 | // Strip all but move and rotation from request | ||
1322 | data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation); | ||
1323 | |||
1324 | part.StoreUndoState(data.change); | ||
1325 | grp.doChangeObject(part, (ObjectChangeData)data); | ||
1326 | } | ||
1327 | } | ||
1328 | } | ||
1329 | } | ||
1330 | } | ||
1331 | } | ||
1332 | } | ||
1333 | |||
1208 | /// <summary> | 1334 | /// <summary> |
1209 | /// Update the scale of an individual prim. | 1335 | /// Update the scale of an individual prim. |
1210 | /// </summary> | 1336 | /// </summary> |
@@ -1219,7 +1345,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1219 | { | 1345 | { |
1220 | if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) | 1346 | if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) |
1221 | { | 1347 | { |
1348 | bool physbuild = false; | ||
1349 | if (part.ParentGroup.RootPart.PhysActor != null) | ||
1350 | { | ||
1351 | part.ParentGroup.RootPart.PhysActor.Building = true; | ||
1352 | physbuild = true; | ||
1353 | } | ||
1354 | |||
1222 | part.Resize(scale); | 1355 | part.Resize(scale); |
1356 | |||
1357 | if (physbuild) | ||
1358 | part.ParentGroup.RootPart.PhysActor.Building = false; | ||
1223 | } | 1359 | } |
1224 | } | 1360 | } |
1225 | } | 1361 | } |
@@ -1231,7 +1367,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1231 | { | 1367 | { |
1232 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) | 1368 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) |
1233 | { | 1369 | { |
1370 | bool physbuild = false; | ||
1371 | if (group.RootPart.PhysActor != null) | ||
1372 | { | ||
1373 | group.RootPart.PhysActor.Building = true; | ||
1374 | physbuild = true; | ||
1375 | } | ||
1376 | |||
1234 | group.GroupResize(scale); | 1377 | group.GroupResize(scale); |
1378 | |||
1379 | if (physbuild) | ||
1380 | group.RootPart.PhysActor.Building = false; | ||
1235 | } | 1381 | } |
1236 | } | 1382 | } |
1237 | } | 1383 | } |
@@ -1359,8 +1505,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1359 | { | 1505 | { |
1360 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) | 1506 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) |
1361 | { | 1507 | { |
1362 | if (m_parentScene.AttachmentsModule != null) | 1508 | // Set the new attachment point data in the object |
1363 | m_parentScene.AttachmentsModule.UpdateAttachmentPosition(group, pos); | 1509 | byte attachmentPoint = group.GetAttachmentPoint(); |
1510 | group.UpdateGroupPosition(pos); | ||
1511 | group.IsAttachment = false; | ||
1512 | group.AbsolutePosition = group.RootPart.AttachedPos; | ||
1513 | group.AttachmentPoint = attachmentPoint; | ||
1514 | group.HasGroupChanged = true; | ||
1364 | } | 1515 | } |
1365 | else | 1516 | else |
1366 | { | 1517 | { |
@@ -1408,7 +1559,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1408 | /// <param name="SetPhantom"></param> | 1559 | /// <param name="SetPhantom"></param> |
1409 | /// <param name="remoteClient"></param> | 1560 | /// <param name="remoteClient"></param> |
1410 | protected internal void UpdatePrimFlags( | 1561 | protected internal void UpdatePrimFlags( |
1411 | uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, IClientAPI remoteClient) | 1562 | uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, ExtraPhysicsData PhysData, IClientAPI remoteClient) |
1412 | { | 1563 | { |
1413 | SceneObjectGroup group = GetGroupByPrim(localID); | 1564 | SceneObjectGroup group = GetGroupByPrim(localID); |
1414 | if (group != null) | 1565 | if (group != null) |
@@ -1416,7 +1567,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1416 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) | 1567 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) |
1417 | { | 1568 | { |
1418 | // VolumeDetect can't be set via UI and will always be off when a change is made there | 1569 | // VolumeDetect can't be set via UI and will always be off when a change is made there |
1419 | group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, false); | 1570 | // now only change volume dtc if phantom off |
1571 | |||
1572 | if (PhysData.PhysShapeType == PhysShapeType.invalid) // check for extraPhysics data | ||
1573 | { | ||
1574 | bool vdtc; | ||
1575 | if (SetPhantom) // if phantom keep volumedtc | ||
1576 | vdtc = group.RootPart.VolumeDetectActive; | ||
1577 | else // else turn it off | ||
1578 | vdtc = false; | ||
1579 | |||
1580 | group.UpdatePrimFlags(localID, UsePhysics, SetTemporary, SetPhantom, vdtc); | ||
1581 | } | ||
1582 | else | ||
1583 | { | ||
1584 | SceneObjectPart part = GetSceneObjectPart(localID); | ||
1585 | if (part != null) | ||
1586 | { | ||
1587 | part.UpdateExtraPhysics(PhysData); | ||
1588 | if (part.UpdatePhysRequired) | ||
1589 | remoteClient.SendPartPhysicsProprieties(part); | ||
1590 | } | ||
1591 | } | ||
1420 | } | 1592 | } |
1421 | } | 1593 | } |
1422 | } | 1594 | } |
@@ -1560,6 +1732,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1560 | { | 1732 | { |
1561 | part.Material = Convert.ToByte(material); | 1733 | part.Material = Convert.ToByte(material); |
1562 | group.HasGroupChanged = true; | 1734 | group.HasGroupChanged = true; |
1735 | remoteClient.SendPartPhysicsProprieties(part); | ||
1563 | } | 1736 | } |
1564 | } | 1737 | } |
1565 | } | 1738 | } |
@@ -1624,6 +1797,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1624 | /// <param name="childPrims"></param> | 1797 | /// <param name="childPrims"></param> |
1625 | protected internal void LinkObjects(SceneObjectPart root, List<SceneObjectPart> children) | 1798 | protected internal void LinkObjects(SceneObjectPart root, List<SceneObjectPart> children) |
1626 | { | 1799 | { |
1800 | if (root.KeyframeMotion != null) | ||
1801 | { | ||
1802 | root.KeyframeMotion.Stop(); | ||
1803 | root.KeyframeMotion = null; | ||
1804 | } | ||
1805 | |||
1627 | SceneObjectGroup parentGroup = root.ParentGroup; | 1806 | SceneObjectGroup parentGroup = root.ParentGroup; |
1628 | if (parentGroup == null) return; | 1807 | if (parentGroup == null) return; |
1629 | 1808 | ||
@@ -1632,8 +1811,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1632 | return; | 1811 | return; |
1633 | 1812 | ||
1634 | Monitor.Enter(m_updateLock); | 1813 | Monitor.Enter(m_updateLock); |
1814 | |||
1635 | try | 1815 | try |
1636 | { | 1816 | { |
1817 | |||
1637 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); | 1818 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); |
1638 | 1819 | ||
1639 | // We do this in reverse to get the link order of the prims correct | 1820 | // We do this in reverse to get the link order of the prims correct |
@@ -1648,9 +1829,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1648 | // Make sure no child prim is set for sale | 1829 | // Make sure no child prim is set for sale |
1649 | // So that, on delink, no prims are unwittingly | 1830 | // So that, on delink, no prims are unwittingly |
1650 | // left for sale and sold off | 1831 | // left for sale and sold off |
1651 | child.RootPart.ObjectSaleType = 0; | 1832 | |
1652 | child.RootPart.SalePrice = 10; | 1833 | if (child != null) |
1653 | childGroups.Add(child); | 1834 | { |
1835 | child.RootPart.ObjectSaleType = 0; | ||
1836 | child.RootPart.SalePrice = 10; | ||
1837 | childGroups.Add(child); | ||
1838 | } | ||
1654 | } | 1839 | } |
1655 | 1840 | ||
1656 | foreach (SceneObjectGroup child in childGroups) | 1841 | foreach (SceneObjectGroup child in childGroups) |
@@ -1679,6 +1864,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1679 | } | 1864 | } |
1680 | finally | 1865 | finally |
1681 | { | 1866 | { |
1867 | lock (SceneObjectGroupsByLocalPartID) | ||
1868 | { | ||
1869 | foreach (SceneObjectPart part in parentGroup.Parts) | ||
1870 | SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; | ||
1871 | } | ||
1872 | |||
1873 | parentGroup.AdjustChildPrimPermissions(); | ||
1874 | parentGroup.HasGroupChanged = true; | ||
1875 | parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); | ||
1876 | parentGroup.ScheduleGroupForFullUpdate(); | ||
1682 | Monitor.Exit(m_updateLock); | 1877 | Monitor.Exit(m_updateLock); |
1683 | } | 1878 | } |
1684 | } | 1879 | } |
@@ -1701,6 +1896,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1701 | { | 1896 | { |
1702 | if (part != null) | 1897 | if (part != null) |
1703 | { | 1898 | { |
1899 | if (part.KeyframeMotion != null) | ||
1900 | { | ||
1901 | part.KeyframeMotion.Stop(); | ||
1902 | part.KeyframeMotion = null; | ||
1903 | } | ||
1704 | if (part.ParentGroup.PrimCount != 1) // Skip single | 1904 | if (part.ParentGroup.PrimCount != 1) // Skip single |
1705 | { | 1905 | { |
1706 | if (part.LinkNum < 2) // Root | 1906 | if (part.LinkNum < 2) // Root |
@@ -1715,21 +1915,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
1715 | 1915 | ||
1716 | SceneObjectGroup group = part.ParentGroup; | 1916 | SceneObjectGroup group = part.ParentGroup; |
1717 | if (!affectedGroups.Contains(group)) | 1917 | if (!affectedGroups.Contains(group)) |
1918 | { | ||
1718 | affectedGroups.Add(group); | 1919 | affectedGroups.Add(group); |
1920 | } | ||
1719 | } | 1921 | } |
1720 | } | 1922 | } |
1721 | } | 1923 | } |
1722 | 1924 | ||
1723 | foreach (SceneObjectPart child in childParts) | 1925 | if (childParts.Count > 0) |
1724 | { | 1926 | { |
1725 | // Unlink all child parts from their groups | 1927 | foreach (SceneObjectPart child in childParts) |
1726 | // | 1928 | { |
1727 | child.ParentGroup.DelinkFromGroup(child, true); | 1929 | // Unlink all child parts from their groups |
1728 | 1930 | // | |
1729 | // These are not in affected groups and will not be | 1931 | child.ParentGroup.DelinkFromGroup(child, true); |
1730 | // handled further. Do the honors here. | 1932 | child.ParentGroup.HasGroupChanged = true; |
1731 | child.ParentGroup.HasGroupChanged = true; | 1933 | child.ParentGroup.ScheduleGroupForFullUpdate(); |
1732 | child.ParentGroup.ScheduleGroupForFullUpdate(); | 1934 | } |
1733 | } | 1935 | } |
1734 | 1936 | ||
1735 | foreach (SceneObjectPart root in rootParts) | 1937 | foreach (SceneObjectPart root in rootParts) |
@@ -1743,52 +1945,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1743 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); | 1945 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); |
1744 | int numChildren = newSet.Count; | 1946 | int numChildren = newSet.Count; |
1745 | 1947 | ||
1948 | if (numChildren == 1) | ||
1949 | break; | ||
1950 | |||
1746 | // If there are prims left in a link set, but the root is | 1951 | // If there are prims left in a link set, but the root is |
1747 | // slated for unlink, we need to do this | 1952 | // slated for unlink, we need to do this |
1953 | // Unlink the remaining set | ||
1748 | // | 1954 | // |
1749 | if (numChildren != 1) | 1955 | bool sendEventsToRemainder = true; |
1750 | { | 1956 | if (numChildren > 1) |
1751 | // Unlink the remaining set | 1957 | sendEventsToRemainder = false; |
1752 | // | ||
1753 | bool sendEventsToRemainder = true; | ||
1754 | if (numChildren > 1) | ||
1755 | sendEventsToRemainder = false; | ||
1756 | 1958 | ||
1757 | foreach (SceneObjectPart p in newSet) | 1959 | foreach (SceneObjectPart p in newSet) |
1960 | { | ||
1961 | if (p != group.RootPart) | ||
1758 | { | 1962 | { |
1759 | if (p != group.RootPart) | 1963 | group.DelinkFromGroup(p, sendEventsToRemainder); |
1760 | group.DelinkFromGroup(p, sendEventsToRemainder); | 1964 | if (numChildren > 2) |
1965 | { | ||
1966 | } | ||
1967 | else | ||
1968 | { | ||
1969 | p.ParentGroup.HasGroupChanged = true; | ||
1970 | p.ParentGroup.ScheduleGroupForFullUpdate(); | ||
1971 | } | ||
1761 | } | 1972 | } |
1973 | } | ||
1974 | |||
1975 | // If there is more than one prim remaining, we | ||
1976 | // need to re-link | ||
1977 | // | ||
1978 | if (numChildren > 2) | ||
1979 | { | ||
1980 | // Remove old root | ||
1981 | // | ||
1982 | if (newSet.Contains(root)) | ||
1983 | newSet.Remove(root); | ||
1762 | 1984 | ||
1763 | // If there is more than one prim remaining, we | 1985 | // Preserve link ordering |
1764 | // need to re-link | ||
1765 | // | 1986 | // |
1766 | if (numChildren > 2) | 1987 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) |
1767 | { | 1988 | { |
1768 | // Remove old root | 1989 | return a.LinkNum.CompareTo(b.LinkNum); |
1769 | // | 1990 | }); |
1770 | if (newSet.Contains(root)) | ||
1771 | newSet.Remove(root); | ||
1772 | |||
1773 | // Preserve link ordering | ||
1774 | // | ||
1775 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) | ||
1776 | { | ||
1777 | return a.LinkNum.CompareTo(b.LinkNum); | ||
1778 | }); | ||
1779 | 1991 | ||
1780 | // Determine new root | 1992 | // Determine new root |
1781 | // | 1993 | // |
1782 | SceneObjectPart newRoot = newSet[0]; | 1994 | SceneObjectPart newRoot = newSet[0]; |
1783 | newSet.RemoveAt(0); | 1995 | newSet.RemoveAt(0); |
1784 | 1996 | ||
1785 | foreach (SceneObjectPart newChild in newSet) | 1997 | foreach (SceneObjectPart newChild in newSet) |
1786 | newChild.ClearUpdateSchedule(); | 1998 | newChild.ClearUpdateSchedule(); |
1787 | 1999 | ||
1788 | LinkObjects(newRoot, newSet); | 2000 | LinkObjects(newRoot, newSet); |
1789 | if (!affectedGroups.Contains(newRoot.ParentGroup)) | 2001 | if (!affectedGroups.Contains(newRoot.ParentGroup)) |
1790 | affectedGroups.Add(newRoot.ParentGroup); | 2002 | affectedGroups.Add(newRoot.ParentGroup); |
1791 | } | ||
1792 | } | 2003 | } |
1793 | } | 2004 | } |
1794 | 2005 | ||
@@ -1796,6 +2007,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1796 | // | 2007 | // |
1797 | foreach (SceneObjectGroup g in affectedGroups) | 2008 | foreach (SceneObjectGroup g in affectedGroups) |
1798 | { | 2009 | { |
2010 | // Child prims that have been unlinked and deleted will | ||
2011 | // return unless the root is deleted. This will remove them | ||
2012 | // from the database. They will be rewritten immediately, | ||
2013 | // minus the rows for the unlinked child prims. | ||
2014 | g.AdjustChildPrimPermissions(); | ||
2015 | m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); | ||
1799 | g.TriggerScriptChangedEvent(Changed.LINK); | 2016 | g.TriggerScriptChangedEvent(Changed.LINK); |
1800 | g.HasGroupChanged = true; // Persist | 2017 | g.HasGroupChanged = true; // Persist |
1801 | g.ScheduleGroupForFullUpdate(); | 2018 | g.ScheduleGroupForFullUpdate(); |
@@ -1869,108 +2086,96 @@ namespace OpenSim.Region.Framework.Scenes | |||
1869 | /// <param name="GroupID"></param> | 2086 | /// <param name="GroupID"></param> |
1870 | /// <param name="rot"></param> | 2087 | /// <param name="rot"></param> |
1871 | /// <returns>null if duplication fails, otherwise the duplicated object</returns> | 2088 | /// <returns>null if duplication fails, otherwise the duplicated object</returns> |
1872 | public SceneObjectGroup DuplicateObject( | 2089 | /// <summary> |
1873 | uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) | 2090 | public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) |
1874 | { | 2091 | { |
1875 | Monitor.Enter(m_updateLock); | 2092 | // m_log.DebugFormat( |
2093 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | ||
2094 | // originalPrimID, offset, AgentID); | ||
1876 | 2095 | ||
1877 | try | 2096 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); |
2097 | if (original != null) | ||
1878 | { | 2098 | { |
1879 | // m_log.DebugFormat( | 2099 | if (m_parentScene.Permissions.CanDuplicateObject( |
1880 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | 2100 | original.PrimCount, original.UUID, AgentID, original.AbsolutePosition)) |
1881 | // originalPrimID, offset, AgentID); | ||
1882 | |||
1883 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); | ||
1884 | if (original == null) | ||
1885 | { | 2101 | { |
1886 | m_log.WarnFormat( | 2102 | SceneObjectGroup copy = original.Copy(true); |
1887 | "[SCENEGRAPH]: Attempt to duplicate nonexistant prim id {0} by {1}", originalPrimID, AgentID); | 2103 | copy.AbsolutePosition = copy.AbsolutePosition + offset; |
1888 | 2104 | ||
1889 | return null; | 2105 | if (original.OwnerID != AgentID) |
1890 | } | 2106 | { |
2107 | copy.SetOwnerId(AgentID); | ||
2108 | copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); | ||
1891 | 2109 | ||
1892 | if (!m_parentScene.Permissions.CanDuplicateObject( | 2110 | SceneObjectPart[] partList = copy.Parts; |
1893 | original.PrimCount, original.UUID, AgentID, original.AbsolutePosition)) | ||
1894 | return null; | ||
1895 | 2111 | ||
1896 | SceneObjectGroup copy = original.Copy(true); | 2112 | if (m_parentScene.Permissions.PropagatePermissions()) |
1897 | copy.AbsolutePosition = copy.AbsolutePosition + offset; | 2113 | { |
2114 | foreach (SceneObjectPart child in partList) | ||
2115 | { | ||
2116 | child.Inventory.ChangeInventoryOwner(AgentID); | ||
2117 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
2118 | child.ApplyNextOwnerPermissions(); | ||
2119 | } | ||
2120 | } | ||
2121 | } | ||
1898 | 2122 | ||
1899 | if (original.OwnerID != AgentID) | 2123 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() |
1900 | { | 2124 | Entities.Add(copy); |
1901 | copy.SetOwnerId(AgentID); | ||
1902 | copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); | ||
1903 | 2125 | ||
1904 | SceneObjectPart[] partList = copy.Parts; | 2126 | lock (SceneObjectGroupsByFullID) |
2127 | SceneObjectGroupsByFullID[copy.UUID] = copy; | ||
1905 | 2128 | ||
1906 | if (m_parentScene.Permissions.PropagatePermissions()) | 2129 | SceneObjectPart[] children = copy.Parts; |
2130 | |||
2131 | lock (SceneObjectGroupsByFullPartID) | ||
1907 | { | 2132 | { |
1908 | foreach (SceneObjectPart child in partList) | 2133 | SceneObjectGroupsByFullPartID[copy.UUID] = copy; |
1909 | { | 2134 | foreach (SceneObjectPart part in children) |
1910 | child.Inventory.ChangeInventoryOwner(AgentID); | 2135 | SceneObjectGroupsByFullPartID[part.UUID] = copy; |
1911 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
1912 | child.ApplyNextOwnerPermissions(); | ||
1913 | } | ||
1914 | } | 2136 | } |
1915 | 2137 | ||
1916 | copy.RootPart.ObjectSaleType = 0; | 2138 | lock (SceneObjectGroupsByLocalPartID) |
1917 | copy.RootPart.SalePrice = 10; | 2139 | { |
1918 | } | 2140 | SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; |
2141 | foreach (SceneObjectPart part in children) | ||
2142 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; | ||
2143 | } | ||
2144 | // PROBABLE END OF FIXME | ||
1919 | 2145 | ||
1920 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() | 2146 | // Since we copy from a source group that is in selected |
1921 | Entities.Add(copy); | 2147 | // state, but the copy is shown deselected in the viewer, |
1922 | 2148 | // We need to clear the selection flag here, else that | |
1923 | lock (SceneObjectGroupsByFullID) | 2149 | // prim never gets persisted at all. The client doesn't |
1924 | SceneObjectGroupsByFullID[copy.UUID] = copy; | 2150 | // think it's selected, so it will never send a deselect... |
1925 | 2151 | copy.IsSelected = false; | |
1926 | SceneObjectPart[] children = copy.Parts; | 2152 | |
1927 | 2153 | m_numPrim += copy.Parts.Length; | |
1928 | lock (SceneObjectGroupsByFullPartID) | 2154 | |
1929 | { | 2155 | if (rot != Quaternion.Identity) |
1930 | SceneObjectGroupsByFullPartID[copy.UUID] = copy; | 2156 | { |
1931 | foreach (SceneObjectPart part in children) | 2157 | copy.UpdateGroupRotationR(rot); |
1932 | SceneObjectGroupsByFullPartID[part.UUID] = copy; | 2158 | } |
1933 | } | ||
1934 | |||
1935 | lock (SceneObjectGroupsByLocalPartID) | ||
1936 | { | ||
1937 | SceneObjectGroupsByLocalPartID[copy.LocalId] = copy; | ||
1938 | foreach (SceneObjectPart part in children) | ||
1939 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; | ||
1940 | } | ||
1941 | // PROBABLE END OF FIXME | ||
1942 | |||
1943 | // Since we copy from a source group that is in selected | ||
1944 | // state, but the copy is shown deselected in the viewer, | ||
1945 | // We need to clear the selection flag here, else that | ||
1946 | // prim never gets persisted at all. The client doesn't | ||
1947 | // think it's selected, so it will never send a deselect... | ||
1948 | copy.IsSelected = false; | ||
1949 | |||
1950 | m_numPrim += copy.Parts.Length; | ||
1951 | |||
1952 | if (rot != Quaternion.Identity) | ||
1953 | { | ||
1954 | copy.UpdateGroupRotationR(rot); | ||
1955 | } | ||
1956 | 2159 | ||
1957 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); | 2160 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); |
1958 | copy.HasGroupChanged = true; | 2161 | copy.HasGroupChanged = true; |
1959 | copy.ScheduleGroupForFullUpdate(); | 2162 | copy.ScheduleGroupForFullUpdate(); |
1960 | copy.ResumeScripts(); | 2163 | copy.ResumeScripts(); |
1961 | 2164 | ||
1962 | // required for physics to update it's position | 2165 | // required for physics to update it's position |
1963 | copy.AbsolutePosition = copy.AbsolutePosition; | 2166 | copy.AbsolutePosition = copy.AbsolutePosition; |
1964 | 2167 | ||
1965 | return copy; | 2168 | return copy; |
2169 | } | ||
1966 | } | 2170 | } |
1967 | finally | 2171 | else |
1968 | { | 2172 | { |
1969 | Monitor.Exit(m_updateLock); | 2173 | m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); |
1970 | } | 2174 | } |
2175 | |||
2176 | return null; | ||
1971 | } | 2177 | } |
1972 | 2178 | ||
1973 | /// <summary> | ||
1974 | /// Calculates the distance between two Vector3s | 2179 | /// Calculates the distance between two Vector3s |
1975 | /// </summary> | 2180 | /// </summary> |
1976 | /// <param name="v1"></param> | 2181 | /// <param name="v1"></param> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 1e2e973..0e0b6c3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -99,11 +99,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | private readonly List<Scene> m_localScenes = new List<Scene>(); | 102 | private readonly DoubleDictionary<UUID, string, Scene> m_localScenes = new DoubleDictionary<UUID, string, Scene>(); |
103 | private Scene m_currentScene = null; | ||
103 | 104 | ||
104 | public List<Scene> Scenes | 105 | public List<Scene> Scenes |
105 | { | 106 | { |
106 | get { return new List<Scene>(m_localScenes); } | 107 | get { return new List<Scene>(m_localScenes.FindAll(delegate(Scene s) { return true; })); } |
107 | } | 108 | } |
108 | 109 | ||
109 | /// <summary> | 110 | /// <summary> |
@@ -120,13 +121,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
120 | { | 121 | { |
121 | if (CurrentScene == null) | 122 | if (CurrentScene == null) |
122 | { | 123 | { |
123 | lock (m_localScenes) | 124 | List<Scene> sceneList = Scenes; |
124 | { | 125 | if (sceneList.Count == 0) |
125 | if (m_localScenes.Count > 0) | 126 | return null; |
126 | return m_localScenes[0]; | 127 | return sceneList[0]; |
127 | else | ||
128 | return null; | ||
129 | } | ||
130 | } | 128 | } |
131 | else | 129 | else |
132 | { | 130 | { |
@@ -138,41 +136,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
138 | public SceneManager() | 136 | public SceneManager() |
139 | { | 137 | { |
140 | m_instance = this; | 138 | m_instance = this; |
141 | m_localScenes = new List<Scene>(); | 139 | m_localScenes = new DoubleDictionary<UUID, string, Scene>(); |
142 | } | 140 | } |
143 | 141 | ||
144 | public void Close() | 142 | public void Close() |
145 | { | 143 | { |
144 | List<Scene> localScenes = null; | ||
145 | |||
146 | lock (m_localScenes) | 146 | lock (m_localScenes) |
147 | { | 147 | { |
148 | for (int i = 0; i < m_localScenes.Count; i++) | 148 | localScenes = Scenes; |
149 | { | 149 | } |
150 | m_localScenes[i].Close(); | 150 | |
151 | } | 151 | for (int i = 0; i < localScenes.Count; i++) |
152 | { | ||
153 | localScenes[i].Close(); | ||
152 | } | 154 | } |
153 | } | 155 | } |
154 | 156 | ||
155 | public void Close(Scene cscene) | 157 | public void Close(Scene cscene) |
156 | { | 158 | { |
157 | lock (m_localScenes) | 159 | if (!m_localScenes.ContainsKey(cscene.RegionInfo.RegionID)) |
158 | { | 160 | return; |
159 | if (m_localScenes.Contains(cscene)) | 161 | 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 | } | 162 | } |
171 | 163 | ||
172 | public void Add(Scene scene) | 164 | public void Add(Scene scene) |
173 | { | 165 | { |
174 | lock (m_localScenes) | 166 | lock (m_localScenes) |
175 | m_localScenes.Add(scene); | 167 | m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene); |
176 | 168 | ||
177 | scene.OnRestart += HandleRestart; | 169 | scene.OnRestart += HandleRestart; |
178 | scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange; | 170 | scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange; |
@@ -184,15 +176,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
184 | 176 | ||
185 | lock (m_localScenes) | 177 | lock (m_localScenes) |
186 | { | 178 | { |
187 | for (int i = 0; i < m_localScenes.Count; i++) | 179 | m_localScenes.TryGetValue(rdata.RegionID, out restartedScene); |
188 | { | 180 | 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 | } | 181 | } |
197 | 182 | ||
198 | // If the currently selected scene has been restarted, then we can't reselect here since we the scene | 183 | // If the currently selected scene has been restarted, then we can't reselect here since we the scene |
@@ -207,39 +192,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
207 | private void HandleRegionReadyStatusChange(IScene scene) | 192 | private void HandleRegionReadyStatusChange(IScene scene) |
208 | { | 193 | { |
209 | lock (m_localScenes) | 194 | lock (m_localScenes) |
210 | AllRegionsReady = m_localScenes.TrueForAll(s => s.Ready); | 195 | AllRegionsReady = m_localScenes.FindAll(s => !s.Ready).Count == 0; |
211 | } | 196 | } |
212 | 197 | ||
213 | public void SendSimOnlineNotification(ulong regionHandle) | 198 | public void SendSimOnlineNotification(ulong regionHandle) |
214 | { | 199 | { |
215 | RegionInfo Result = null; | 200 | RegionInfo Result = null; |
216 | 201 | ||
217 | lock (m_localScenes) | 202 | 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 | { | 203 | { |
223 | // Inform other regions to tell their avatar about me | 204 | if (x.RegionInfo.RegionHandle == regionHandle) |
224 | Result = m_localScenes[i].RegionInfo; | 205 | return true; |
225 | } | 206 | return false; |
226 | } | 207 | }); |
208 | |||
209 | if (s != null) | ||
210 | { | ||
211 | List<Scene> sceneList = Scenes; | ||
227 | 212 | ||
228 | if (Result != null) | 213 | for (int i = 0; i < sceneList.Count; i++) |
229 | { | 214 | { |
230 | for (int i = 0; i < m_localScenes.Count; i++) | 215 | if (sceneList[i]!= s) |
231 | { | 216 | { |
232 | if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) | 217 | // Inform other regions to tell their avatar about me |
233 | { | 218 | //sceneList[i].OtherRegionUp(Result); |
234 | // Inform other regions to tell their avatar about me | ||
235 | //m_localScenes[i].OtherRegionUp(Result); | ||
236 | } | ||
237 | } | 219 | } |
238 | } | 220 | } |
239 | else | 221 | } |
240 | { | 222 | else |
241 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); | 223 | { |
242 | } | 224 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); |
243 | } | 225 | } |
244 | } | 226 | } |
245 | 227 | ||
@@ -343,8 +325,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
343 | { | 325 | { |
344 | if (CurrentScene == null) | 326 | if (CurrentScene == null) |
345 | { | 327 | { |
346 | lock (m_localScenes) | 328 | List<Scene> sceneList = Scenes; |
347 | m_localScenes.ForEach(func); | 329 | sceneList.ForEach(func); |
348 | } | 330 | } |
349 | else | 331 | else |
350 | { | 332 | { |
@@ -373,16 +355,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
373 | } | 355 | } |
374 | else | 356 | else |
375 | { | 357 | { |
376 | lock (m_localScenes) | 358 | Scene s; |
359 | |||
360 | if (m_localScenes.TryGetValue(regionName, out s)) | ||
377 | { | 361 | { |
378 | foreach (Scene scene in m_localScenes) | 362 | m_currentScene = s; |
379 | { | 363 | return true; |
380 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) | ||
381 | { | ||
382 | CurrentScene = scene; | ||
383 | return true; | ||
384 | } | ||
385 | } | ||
386 | } | 364 | } |
387 | 365 | ||
388 | return false; | 366 | return false; |
@@ -391,18 +369,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
391 | 369 | ||
392 | public bool TrySetCurrentScene(UUID regionID) | 370 | public bool TrySetCurrentScene(UUID regionID) |
393 | { | 371 | { |
394 | m_log.Debug("Searching for Region: '" + regionID + "'"); | 372 | // m_log.Debug("Searching for Region: '" + regionID + "'"); |
395 | 373 | ||
396 | lock (m_localScenes) | 374 | Scene s; |
375 | |||
376 | if (m_localScenes.TryGetValue(regionID, out s)) | ||
397 | { | 377 | { |
398 | foreach (Scene scene in m_localScenes) | 378 | m_currentScene = s; |
399 | { | 379 | return true; |
400 | if (scene.RegionInfo.RegionID == regionID) | ||
401 | { | ||
402 | CurrentScene = scene; | ||
403 | return true; | ||
404 | } | ||
405 | } | ||
406 | } | 380 | } |
407 | 381 | ||
408 | return false; | 382 | return false; |
@@ -410,52 +384,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
410 | 384 | ||
411 | public bool TryGetScene(string regionName, out Scene scene) | 385 | public bool TryGetScene(string regionName, out Scene scene) |
412 | { | 386 | { |
413 | lock (m_localScenes) | 387 | return m_localScenes.TryGetValue(regionName, out scene); |
414 | { | ||
415 | foreach (Scene mscene in m_localScenes) | ||
416 | { | ||
417 | if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) | ||
418 | { | ||
419 | scene = mscene; | ||
420 | return true; | ||
421 | } | ||
422 | } | ||
423 | } | ||
424 | |||
425 | scene = null; | ||
426 | return false; | ||
427 | } | 388 | } |
428 | 389 | ||
429 | public bool TryGetScene(UUID regionID, out Scene scene) | 390 | public bool TryGetScene(UUID regionID, out Scene scene) |
430 | { | 391 | { |
431 | lock (m_localScenes) | 392 | return m_localScenes.TryGetValue(regionID, out scene); |
432 | { | ||
433 | foreach (Scene mscene in m_localScenes) | ||
434 | { | ||
435 | if (mscene.RegionInfo.RegionID == regionID) | ||
436 | { | ||
437 | scene = mscene; | ||
438 | return true; | ||
439 | } | ||
440 | } | ||
441 | } | ||
442 | |||
443 | scene = null; | ||
444 | return false; | ||
445 | } | 393 | } |
446 | 394 | ||
447 | public bool TryGetScene(uint locX, uint locY, out Scene scene) | 395 | public bool TryGetScene(uint locX, uint locY, out Scene scene) |
448 | { | 396 | { |
449 | lock (m_localScenes) | 397 | List<Scene> sceneList = Scenes; |
398 | foreach (Scene mscene in sceneList) | ||
450 | { | 399 | { |
451 | foreach (Scene mscene in m_localScenes) | 400 | if (mscene.RegionInfo.RegionLocX == locX && |
401 | mscene.RegionInfo.RegionLocY == locY) | ||
452 | { | 402 | { |
453 | if (mscene.RegionInfo.RegionLocX == locX && | 403 | scene = mscene; |
454 | mscene.RegionInfo.RegionLocY == locY) | 404 | return true; |
455 | { | ||
456 | scene = mscene; | ||
457 | return true; | ||
458 | } | ||
459 | } | 405 | } |
460 | } | 406 | } |
461 | 407 | ||
@@ -465,16 +411,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
465 | 411 | ||
466 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) | 412 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) |
467 | { | 413 | { |
468 | lock (m_localScenes) | 414 | List<Scene> sceneList = Scenes; |
415 | foreach (Scene mscene in sceneList) | ||
469 | { | 416 | { |
470 | foreach (Scene mscene in m_localScenes) | 417 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && |
418 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | ||
471 | { | 419 | { |
472 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && | 420 | scene = mscene; |
473 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | 421 | return true; |
474 | { | ||
475 | scene = mscene; | ||
476 | return true; | ||
477 | } | ||
478 | } | 422 | } |
479 | } | 423 | } |
480 | 424 | ||
@@ -539,15 +483,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
539 | 483 | ||
540 | public RegionInfo GetRegionInfo(UUID regionID) | 484 | public RegionInfo GetRegionInfo(UUID regionID) |
541 | { | 485 | { |
542 | lock (m_localScenes) | 486 | Scene s; |
487 | if (m_localScenes.TryGetValue(regionID, out s)) | ||
543 | { | 488 | { |
544 | foreach (Scene scene in m_localScenes) | 489 | return s.RegionInfo; |
545 | { | ||
546 | if (scene.RegionInfo.RegionID == regionID) | ||
547 | { | ||
548 | return scene.RegionInfo; | ||
549 | } | ||
550 | } | ||
551 | } | 490 | } |
552 | 491 | ||
553 | return null; | 492 | return null; |
@@ -565,14 +504,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
565 | 504 | ||
566 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) | 505 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) |
567 | { | 506 | { |
568 | lock (m_localScenes) | 507 | List<Scene> sceneList = Scenes; |
508 | foreach (Scene scene in sceneList) | ||
569 | { | 509 | { |
570 | foreach (Scene scene in m_localScenes) | 510 | if (scene.TryGetScenePresence(avatarId, out avatar)) |
571 | { | 511 | { |
572 | if (scene.TryGetScenePresence(avatarId, out avatar)) | 512 | return true; |
573 | { | ||
574 | return true; | ||
575 | } | ||
576 | } | 513 | } |
577 | } | 514 | } |
578 | 515 | ||
@@ -582,15 +519,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
582 | 519 | ||
583 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) | 520 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) |
584 | { | 521 | { |
585 | lock (m_localScenes) | 522 | List<Scene> sceneList = Scenes; |
523 | foreach (Scene scene in sceneList) | ||
586 | { | 524 | { |
587 | foreach (Scene scene in m_localScenes) | 525 | avatar = scene.GetScenePresence(avatarId); |
588 | { | ||
589 | avatar = scene.GetScenePresence(avatarId); | ||
590 | 526 | ||
591 | if (avatar != null && !avatar.IsChildAgent) | 527 | if (avatar != null && !avatar.IsChildAgent) |
592 | return true; | 528 | return true; |
593 | } | ||
594 | } | 529 | } |
595 | 530 | ||
596 | avatar = null; | 531 | avatar = null; |
@@ -600,21 +535,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
600 | public void CloseScene(Scene scene) | 535 | public void CloseScene(Scene scene) |
601 | { | 536 | { |
602 | lock (m_localScenes) | 537 | lock (m_localScenes) |
603 | m_localScenes.Remove(scene); | 538 | m_localScenes.Remove(scene.RegionInfo.RegionID); |
604 | 539 | ||
605 | scene.Close(); | 540 | scene.Close(); |
606 | } | 541 | } |
607 | 542 | ||
608 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 543 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
609 | { | 544 | { |
610 | lock (m_localScenes) | 545 | List<Scene> sceneList = Scenes; |
546 | foreach (Scene scene in sceneList) | ||
611 | { | 547 | { |
612 | foreach (Scene scene in m_localScenes) | 548 | if (scene.TryGetAvatarByName(avatarName, out avatar)) |
613 | { | 549 | { |
614 | if (scene.TryGetAvatarByName(avatarName, out avatar)) | 550 | return true; |
615 | { | ||
616 | return true; | ||
617 | } | ||
618 | } | 551 | } |
619 | } | 552 | } |
620 | 553 | ||
@@ -624,14 +557,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
624 | 557 | ||
625 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) | 558 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) |
626 | { | 559 | { |
627 | lock (m_localScenes) | 560 | List<Scene> sceneList = Scenes; |
561 | foreach (Scene scene in sceneList) | ||
628 | { | 562 | { |
629 | foreach (Scene scene in m_localScenes) | 563 | sp = scene.GetScenePresence(firstName, lastName); |
630 | { | 564 | if (sp != null && !sp.IsChildAgent) |
631 | sp = scene.GetScenePresence(firstName, lastName); | 565 | return true; |
632 | if (sp != null && !sp.IsChildAgent) | ||
633 | return true; | ||
634 | } | ||
635 | } | 566 | } |
636 | 567 | ||
637 | sp = null; | 568 | sp = null; |
@@ -640,8 +571,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
640 | 571 | ||
641 | public void ForEachScene(Action<Scene> action) | 572 | public void ForEachScene(Action<Scene> action) |
642 | { | 573 | { |
643 | lock (m_localScenes) | 574 | List<Scene> sceneList = Scenes; |
644 | m_localScenes.ForEach(action); | 575 | sceneList.ForEach(action); |
645 | } | 576 | } |
646 | } | 577 | } |
647 | } | 578 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index ddf5da0..26524fb 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -81,10 +81,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
81 | /// <summary> | 81 | /// <summary> |
82 | /// Stop and remove the scripts contained in all the prims in this group | 82 | /// Stop and remove the scripts contained in all the prims in this group |
83 | /// </summary> | 83 | /// </summary> |
84 | /// <param name="sceneObjectBeingDeleted"> | ||
85 | /// Should be true if these scripts are being removed because the scene | ||
86 | /// object is being deleted. This will prevent spurious updates to the client. | ||
87 | /// </param> | ||
88 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 84 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
89 | { | 85 | { |
90 | SceneObjectPart[] parts = m_parts.GetArray(); | 86 | SceneObjectPart[] parts = m_parts.GetArray(); |
@@ -247,6 +243,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
247 | 243 | ||
248 | public uint GetEffectivePermissions() | 244 | public uint GetEffectivePermissions() |
249 | { | 245 | { |
246 | return GetEffectivePermissions(false); | ||
247 | } | ||
248 | |||
249 | public uint GetEffectivePermissions(bool useBase) | ||
250 | { | ||
250 | uint perms=(uint)(PermissionMask.Modify | | 251 | uint perms=(uint)(PermissionMask.Modify | |
251 | PermissionMask.Copy | | 252 | PermissionMask.Copy | |
252 | PermissionMask.Move | | 253 | PermissionMask.Move | |
@@ -258,7 +259,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
258 | for (int i = 0; i < parts.Length; i++) | 259 | for (int i = 0; i < parts.Length; i++) |
259 | { | 260 | { |
260 | SceneObjectPart part = parts[i]; | 261 | SceneObjectPart part = parts[i]; |
261 | ownerMask &= part.OwnerMask; | 262 | if (useBase) |
263 | ownerMask &= part.BaseMask; | ||
264 | else | ||
265 | ownerMask &= part.OwnerMask; | ||
262 | perms &= part.Inventory.MaskEffectivePermissions(); | 266 | perms &= part.Inventory.MaskEffectivePermissions(); |
263 | } | 267 | } |
264 | 268 | ||
@@ -400,6 +404,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
400 | 404 | ||
401 | public void ResumeScripts() | 405 | public void ResumeScripts() |
402 | { | 406 | { |
407 | if (m_scene.RegionInfo.RegionSettings.DisableScripts) | ||
408 | return; | ||
409 | |||
403 | SceneObjectPart[] parts = m_parts.GetArray(); | 410 | SceneObjectPart[] parts = m_parts.GetArray(); |
404 | for (int i = 0; i < parts.Length; i++) | 411 | for (int i = 0; i < parts.Length; i++) |
405 | parts[i].Inventory.ResumeScripts(); | 412 | parts[i].Inventory.ResumeScripts(); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 15795e5..0f5d116 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -24,12 +24,13 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.ComponentModel; | 29 | using System.ComponentModel; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Drawing; | 31 | using System.Drawing; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Diagnostics; | ||
33 | using System.Linq; | 34 | using System.Linq; |
34 | using System.Threading; | 35 | using System.Threading; |
35 | using System.Xml; | 36 | using System.Xml; |
@@ -43,6 +44,7 @@ using OpenSim.Region.Framework.Scenes.Serialization; | |||
43 | 44 | ||
44 | namespace OpenSim.Region.Framework.Scenes | 45 | namespace OpenSim.Region.Framework.Scenes |
45 | { | 46 | { |
47 | |||
46 | [Flags] | 48 | [Flags] |
47 | public enum scriptEvents | 49 | public enum scriptEvents |
48 | { | 50 | { |
@@ -77,14 +79,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
77 | object_rez = 4194304 | 79 | object_rez = 4194304 |
78 | } | 80 | } |
79 | 81 | ||
80 | struct scriptPosTarget | 82 | public struct scriptPosTarget |
81 | { | 83 | { |
82 | public Vector3 targetPos; | 84 | public Vector3 targetPos; |
83 | public float tolerance; | 85 | public float tolerance; |
84 | public uint handle; | 86 | public uint handle; |
85 | } | 87 | } |
86 | 88 | ||
87 | struct scriptRotTarget | 89 | public struct scriptRotTarget |
88 | { | 90 | { |
89 | public Quaternion targetRot; | 91 | public Quaternion targetRot; |
90 | public float tolerance; | 92 | public float tolerance; |
@@ -115,8 +117,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
115 | /// since the group's last persistent backup | 117 | /// since the group's last persistent backup |
116 | /// </summary> | 118 | /// </summary> |
117 | private bool m_hasGroupChanged = false; | 119 | private bool m_hasGroupChanged = false; |
118 | private long timeFirstChanged; | 120 | private long timeFirstChanged = 0; |
119 | private long timeLastChanged; | 121 | private long timeLastChanged = 0; |
122 | private long m_maxPersistTime = 0; | ||
123 | private long m_minPersistTime = 0; | ||
124 | // private Random m_rand; | ||
125 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); | ||
120 | 126 | ||
121 | /// <summary> | 127 | /// <summary> |
122 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage | 128 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage |
@@ -133,9 +139,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
133 | { | 139 | { |
134 | if (value) | 140 | if (value) |
135 | { | 141 | { |
142 | |||
143 | if (m_isBackedUp) | ||
144 | { | ||
145 | m_scene.SceneGraph.FireChangeBackup(this); | ||
146 | } | ||
136 | timeLastChanged = DateTime.Now.Ticks; | 147 | timeLastChanged = DateTime.Now.Ticks; |
137 | if (!m_hasGroupChanged) | 148 | if (!m_hasGroupChanged) |
138 | timeFirstChanged = DateTime.Now.Ticks; | 149 | timeFirstChanged = DateTime.Now.Ticks; |
150 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | ||
151 | { | ||
152 | /* | ||
153 | if (m_rand == null) | ||
154 | { | ||
155 | byte[] val = new byte[16]; | ||
156 | m_rootPart.UUID.ToBytes(val, 0); | ||
157 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
158 | } | ||
159 | */ | ||
160 | if (m_scene.GetRootAgentCount() == 0) | ||
161 | { | ||
162 | //If the region is empty, this change has been made by an automated process | ||
163 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
164 | |||
165 | // float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
166 | float factor = 2.0f; | ||
167 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); | ||
168 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); | ||
169 | } | ||
170 | else | ||
171 | { | ||
172 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
173 | //but add a random factor so we stagger the object persistance a little | ||
174 | // m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
175 | // m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
176 | m_maxPersistTime = m_scene.m_persistAfter; | ||
177 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
178 | } | ||
179 | } | ||
139 | } | 180 | } |
140 | m_hasGroupChanged = value; | 181 | m_hasGroupChanged = value; |
141 | 182 | ||
@@ -150,7 +191,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
150 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since | 191 | /// Has the group changed due to an unlink operation? We record this in order to optimize deletion, since |
151 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. | 192 | /// an unlinked group currently has to be persisted to the database before we can perform an unlink operation. |
152 | /// </summary> | 193 | /// </summary> |
153 | public bool HasGroupChangedDueToDelink { get; private set; } | 194 | public bool HasGroupChangedDueToDelink { get; set; } |
154 | 195 | ||
155 | private bool isTimeToPersist() | 196 | private bool isTimeToPersist() |
156 | { | 197 | { |
@@ -160,8 +201,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
160 | return false; | 201 | return false; |
161 | if (m_scene.ShuttingDown) | 202 | if (m_scene.ShuttingDown) |
162 | return true; | 203 | return true; |
204 | |||
205 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
206 | { | ||
207 | m_maxPersistTime = m_scene.m_persistAfter; | ||
208 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
209 | } | ||
210 | |||
163 | long currentTime = DateTime.Now.Ticks; | 211 | long currentTime = DateTime.Now.Ticks; |
164 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 212 | |
213 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
214 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
215 | |||
216 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
165 | return true; | 217 | return true; |
166 | return false; | 218 | return false; |
167 | } | 219 | } |
@@ -264,26 +316,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
264 | get { return RootPart.VolumeDetectActive; } | 316 | get { return RootPart.VolumeDetectActive; } |
265 | } | 317 | } |
266 | 318 | ||
267 | private Vector3 lastPhysGroupPos; | ||
268 | private Quaternion lastPhysGroupRot; | ||
269 | |||
270 | private bool m_isBackedUp; | 319 | private bool m_isBackedUp; |
271 | 320 | ||
321 | public bool IsBackedUp | ||
322 | { | ||
323 | get { return m_isBackedUp; } | ||
324 | } | ||
325 | |||
272 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); | 326 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); |
273 | 327 | ||
274 | protected ulong m_regionHandle; | 328 | protected ulong m_regionHandle; |
275 | protected SceneObjectPart m_rootPart; | 329 | protected SceneObjectPart m_rootPart; |
276 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); | 330 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); |
277 | 331 | ||
278 | private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); | 332 | private SortedDictionary<uint, scriptPosTarget> m_targets = new SortedDictionary<uint, scriptPosTarget>(); |
279 | private Dictionary<uint, scriptRotTarget> m_rotTargets = new Dictionary<uint, scriptRotTarget>(); | 333 | private SortedDictionary<uint, scriptRotTarget> m_rotTargets = new SortedDictionary<uint, scriptRotTarget>(); |
334 | |||
335 | public SortedDictionary<uint, scriptPosTarget> AtTargets | ||
336 | { | ||
337 | get { return m_targets; } | ||
338 | } | ||
339 | |||
340 | public SortedDictionary<uint, scriptRotTarget> RotTargets | ||
341 | { | ||
342 | get { return m_rotTargets; } | ||
343 | } | ||
280 | 344 | ||
281 | private bool m_scriptListens_atTarget; | 345 | private bool m_scriptListens_atTarget; |
282 | private bool m_scriptListens_notAtTarget; | 346 | private bool m_scriptListens_notAtTarget; |
283 | |||
284 | private bool m_scriptListens_atRotTarget; | 347 | private bool m_scriptListens_atRotTarget; |
285 | private bool m_scriptListens_notAtRotTarget; | 348 | private bool m_scriptListens_notAtRotTarget; |
286 | 349 | ||
350 | public bool m_dupeInProgress = false; | ||
287 | internal Dictionary<UUID, string> m_savedScriptState; | 351 | internal Dictionary<UUID, string> m_savedScriptState; |
288 | 352 | ||
289 | #region Properties | 353 | #region Properties |
@@ -320,6 +384,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
320 | get { return m_parts.Count; } | 384 | get { return m_parts.Count; } |
321 | } | 385 | } |
322 | 386 | ||
387 | // protected Quaternion m_rotation = Quaternion.Identity; | ||
388 | // | ||
389 | // public virtual Quaternion Rotation | ||
390 | // { | ||
391 | // get { return m_rotation; } | ||
392 | // set { | ||
393 | // m_rotation = value; | ||
394 | // } | ||
395 | // } | ||
396 | |||
323 | public Quaternion GroupRotation | 397 | public Quaternion GroupRotation |
324 | { | 398 | { |
325 | get { return m_rootPart.RotationOffset; } | 399 | get { return m_rootPart.RotationOffset; } |
@@ -426,7 +500,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
426 | { | 500 | { |
427 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); | 501 | return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); |
428 | } | 502 | } |
429 | 503 | ||
504 | |||
505 | |||
506 | private struct avtocrossInfo | ||
507 | { | ||
508 | public ScenePresence av; | ||
509 | public uint ParentID; | ||
510 | } | ||
511 | |||
430 | /// <summary> | 512 | /// <summary> |
431 | /// The absolute position of this scene object in the scene | 513 | /// The absolute position of this scene object in the scene |
432 | /// </summary> | 514 | /// </summary> |
@@ -454,10 +536,129 @@ namespace OpenSim.Region.Framework.Scenes | |||
454 | || Scene.TestBorderCross(val, Cardinals.S)) | 536 | || Scene.TestBorderCross(val, Cardinals.S)) |
455 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) | 537 | && !IsAttachmentCheckFull() && (!Scene.LoadingPrims)) |
456 | { | 538 | { |
457 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | 539 | IEntityTransferModule entityTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
540 | uint x = 0; | ||
541 | uint y = 0; | ||
542 | string version = String.Empty; | ||
543 | Vector3 newpos = Vector3.Zero; | ||
544 | OpenSim.Services.Interfaces.GridRegion destination = null; | ||
545 | |||
546 | if (m_rootPart.KeyframeMotion != null) | ||
547 | m_rootPart.KeyframeMotion.StartCrossingCheck(); | ||
548 | |||
549 | bool canCross = true; | ||
550 | foreach (ScenePresence av in m_linkedAvatars) | ||
551 | { | ||
552 | // We need to cross these agents. First, let's find | ||
553 | // out if any of them can't cross for some reason. | ||
554 | // We have to deny the crossing entirely if any | ||
555 | // of them are banned. Alternatively, we could | ||
556 | // unsit banned agents.... | ||
557 | |||
558 | |||
559 | // We set the avatar position as being the object | ||
560 | // position to get the region to send to | ||
561 | if ((destination = entityTransfer.GetDestination(m_scene, av.UUID, val, out x, out y, out version, out newpos)) == null) | ||
562 | { | ||
563 | canCross = false; | ||
564 | break; | ||
565 | } | ||
566 | |||
567 | m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); | ||
568 | } | ||
569 | |||
570 | if (canCross) | ||
571 | { | ||
572 | // We unparent the SP quietly so that it won't | ||
573 | // be made to stand up | ||
574 | |||
575 | List<avtocrossInfo> avsToCross = new List<avtocrossInfo>(); | ||
576 | |||
577 | foreach (ScenePresence av in m_linkedAvatars) | ||
578 | { | ||
579 | avtocrossInfo avinfo = new avtocrossInfo(); | ||
580 | SceneObjectPart parentPart = m_scene.GetSceneObjectPart(av.ParentID); | ||
581 | if (parentPart != null) | ||
582 | av.ParentUUID = parentPart.UUID; | ||
583 | |||
584 | avinfo.av = av; | ||
585 | avinfo.ParentID = av.ParentID; | ||
586 | avsToCross.Add(avinfo); | ||
587 | |||
588 | av.ParentID = 0; | ||
589 | } | ||
590 | |||
591 | // m_linkedAvatars.Clear(); | ||
592 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | ||
593 | |||
594 | // Normalize | ||
595 | if (val.X >= Constants.RegionSize) | ||
596 | val.X -= Constants.RegionSize; | ||
597 | if (val.Y >= Constants.RegionSize) | ||
598 | val.Y -= Constants.RegionSize; | ||
599 | if (val.X < 0) | ||
600 | val.X += Constants.RegionSize; | ||
601 | if (val.Y < 0) | ||
602 | val.Y += Constants.RegionSize; | ||
603 | |||
604 | // If it's deleted, crossing was successful | ||
605 | if (IsDeleted) | ||
606 | { | ||
607 | // foreach (ScenePresence av in m_linkedAvatars) | ||
608 | foreach (avtocrossInfo avinfo in avsToCross) | ||
609 | { | ||
610 | ScenePresence av = avinfo.av; | ||
611 | if (!av.IsInTransit) // just in case... | ||
612 | { | ||
613 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); | ||
614 | |||
615 | av.IsInTransit = true; | ||
616 | |||
617 | CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; | ||
618 | d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); | ||
619 | } | ||
620 | else | ||
621 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar alreasy in transit {0} to {1}", av.Name, val); | ||
622 | } | ||
623 | avsToCross.Clear(); | ||
624 | return; | ||
625 | } | ||
626 | else // cross failed, put avas back ?? | ||
627 | { | ||
628 | foreach (avtocrossInfo avinfo in avsToCross) | ||
629 | { | ||
630 | ScenePresence av = avinfo.av; | ||
631 | av.ParentUUID = UUID.Zero; | ||
632 | av.ParentID = avinfo.ParentID; | ||
633 | // m_linkedAvatars.Add(av); | ||
634 | } | ||
635 | } | ||
636 | avsToCross.Clear(); | ||
637 | |||
638 | } | ||
639 | else | ||
640 | { | ||
641 | if (m_rootPart.KeyframeMotion != null) | ||
642 | m_rootPart.KeyframeMotion.CrossingFailure(); | ||
643 | |||
644 | if (RootPart.PhysActor != null) | ||
645 | { | ||
646 | RootPart.PhysActor.CrossingFailure(); | ||
647 | } | ||
648 | } | ||
649 | Vector3 oldp = AbsolutePosition; | ||
650 | val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
651 | val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f); | ||
652 | val.Z = Util.Clamp<float>(oldp.Z, 0.5f, 4096.0f); | ||
458 | } | 653 | } |
459 | } | 654 | } |
460 | 655 | ||
656 | /* don't see the need but worse don't see where is restored to false if things stay in | ||
657 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
658 | { | ||
659 | part.IgnoreUndoUpdate = true; | ||
660 | } | ||
661 | */ | ||
461 | if (RootPart.GetStatusSandbox()) | 662 | if (RootPart.GetStatusSandbox()) |
462 | { | 663 | { |
463 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) | 664 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) |
@@ -475,9 +676,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
475 | // Restuff the new GroupPosition into each SOP of the linkset. | 676 | // Restuff the new GroupPosition into each SOP of the linkset. |
476 | // This has the affect of resetting and tainting the physics actors. | 677 | // This has the affect of resetting and tainting the physics actors. |
477 | SceneObjectPart[] parts = m_parts.GetArray(); | 678 | SceneObjectPart[] parts = m_parts.GetArray(); |
478 | for (int i = 0; i < parts.Length; i++) | 679 | bool triggerScriptEvent = m_rootPart.GroupPosition != val; |
479 | parts[i].GroupPosition = val; | 680 | if (m_dupeInProgress) |
681 | triggerScriptEvent = false; | ||
682 | foreach (SceneObjectPart part in parts) | ||
683 | { | ||
684 | part.GroupPosition = val; | ||
685 | if (triggerScriptEvent) | ||
686 | part.TriggerScriptChangedEvent(Changed.POSITION); | ||
687 | } | ||
480 | 688 | ||
689 | /* | ||
690 | This seems not needed and should not be needed: | ||
691 | sp absolute position depends on sit part absolute position fixed above. | ||
692 | sp ParentPosition is not used anywhere. | ||
693 | Since presence is sitting, viewer considers it 'linked' to root prim, so it will move/rotate it | ||
694 | Sending a extra packet with avatar position is not only bandwidth waste, but may cause jitter in viewers due to UPD nature. | ||
695 | |||
696 | if (!m_dupeInProgress) | ||
697 | { | ||
698 | foreach (ScenePresence av in m_linkedAvatars) | ||
699 | { | ||
700 | SceneObjectPart p = m_scene.GetSceneObjectPart(av.ParentID); | ||
701 | if (p != null && m_parts.TryGetValue(p.UUID, out p)) | ||
702 | { | ||
703 | Vector3 offset = p.GetWorldPosition() - av.ParentPosition; | ||
704 | av.AbsolutePosition += offset; | ||
705 | // av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition | ||
706 | av.SendAvatarDataToAllAgents(); | ||
707 | } | ||
708 | } | ||
709 | } | ||
710 | */ | ||
481 | //if (m_rootPart.PhysActor != null) | 711 | //if (m_rootPart.PhysActor != null) |
482 | //{ | 712 | //{ |
483 | //m_rootPart.PhysActor.Position = | 713 | //m_rootPart.PhysActor.Position = |
@@ -491,6 +721,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
491 | } | 721 | } |
492 | } | 722 | } |
493 | 723 | ||
724 | public override Vector3 Velocity | ||
725 | { | ||
726 | get { return RootPart.Velocity; } | ||
727 | set { RootPart.Velocity = value; } | ||
728 | } | ||
729 | |||
730 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) | ||
731 | { | ||
732 | CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; | ||
733 | ScenePresence agent = icon.EndInvoke(iar); | ||
734 | |||
735 | //// If the cross was successful, this agent is a child agent | ||
736 | if (agent.IsChildAgent) | ||
737 | { | ||
738 | if (agent.ParentUUID != UUID.Zero) | ||
739 | { | ||
740 | agent.ParentPart = null; | ||
741 | // agent.ParentPosition = Vector3.Zero; | ||
742 | // agent.ParentUUID = UUID.Zero; | ||
743 | } | ||
744 | } | ||
745 | |||
746 | agent.ParentUUID = UUID.Zero; | ||
747 | |||
748 | // agent.Reset(); | ||
749 | // else // Not successful | ||
750 | // agent.RestoreInCurrentScene(); | ||
751 | |||
752 | // In any case | ||
753 | agent.IsInTransit = false; | ||
754 | |||
755 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | ||
756 | } | ||
757 | |||
494 | public override uint LocalId | 758 | public override uint LocalId |
495 | { | 759 | { |
496 | get { return m_rootPart.LocalId; } | 760 | get { return m_rootPart.LocalId; } |
@@ -561,6 +825,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
561 | m_isSelected = value; | 825 | m_isSelected = value; |
562 | // Tell physics engine that group is selected | 826 | // Tell physics engine that group is selected |
563 | 827 | ||
828 | // this is not right | ||
829 | // but ode engines should only really need to know about root part | ||
830 | // so they can put entire object simulation on hold and not colliding | ||
831 | // keep as was for now | ||
832 | |||
564 | PhysicsActor pa = m_rootPart.PhysActor; | 833 | PhysicsActor pa = m_rootPart.PhysActor; |
565 | if (pa != null) | 834 | if (pa != null) |
566 | { | 835 | { |
@@ -577,6 +846,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
577 | childPa.Selected = value; | 846 | childPa.Selected = value; |
578 | } | 847 | } |
579 | } | 848 | } |
849 | if (RootPart.KeyframeMotion != null) | ||
850 | RootPart.KeyframeMotion.Selected = value; | ||
851 | } | ||
852 | } | ||
853 | |||
854 | public void PartSelectChanged(bool partSelect) | ||
855 | { | ||
856 | // any part selected makes group selected | ||
857 | if (m_isSelected == partSelect) | ||
858 | return; | ||
859 | |||
860 | if (partSelect) | ||
861 | { | ||
862 | IsSelected = partSelect; | ||
863 | // if (!IsAttachment) | ||
864 | // ScheduleGroupForFullUpdate(); | ||
865 | } | ||
866 | else | ||
867 | { | ||
868 | // bad bad bad 2 heavy for large linksets | ||
869 | // since viewer does send lot of (un)selects | ||
870 | // this needs to be replaced by a specific list or count ? | ||
871 | // but that will require extra code in several places | ||
872 | |||
873 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
874 | for (int i = 0; i < parts.Length; i++) | ||
875 | { | ||
876 | SceneObjectPart part = parts[i]; | ||
877 | if (part.IsSelected) | ||
878 | return; | ||
879 | } | ||
880 | IsSelected = partSelect; | ||
881 | if (!IsAttachment) | ||
882 | { | ||
883 | ScheduleGroupForFullUpdate(); | ||
884 | } | ||
580 | } | 885 | } |
581 | } | 886 | } |
582 | 887 | ||
@@ -674,6 +979,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
674 | /// </summary> | 979 | /// </summary> |
675 | public SceneObjectGroup() | 980 | public SceneObjectGroup() |
676 | { | 981 | { |
982 | |||
677 | } | 983 | } |
678 | 984 | ||
679 | /// <summary> | 985 | /// <summary> |
@@ -691,8 +997,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
691 | /// Constructor. This object is added to the scene later via AttachToScene() | 997 | /// Constructor. This object is added to the scene later via AttachToScene() |
692 | /// </summary> | 998 | /// </summary> |
693 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 999 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
694 | :this(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)) | 1000 | { |
695 | { | 1001 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
696 | } | 1002 | } |
697 | 1003 | ||
698 | /// <summary> | 1004 | /// <summary> |
@@ -727,6 +1033,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
727 | /// </summary> | 1033 | /// </summary> |
728 | public virtual void AttachToBackup() | 1034 | public virtual void AttachToBackup() |
729 | { | 1035 | { |
1036 | if (IsAttachment) return; | ||
1037 | m_scene.SceneGraph.FireAttachToBackup(this); | ||
1038 | |||
730 | if (InSceneBackup) | 1039 | if (InSceneBackup) |
731 | { | 1040 | { |
732 | //m_log.DebugFormat( | 1041 | //m_log.DebugFormat( |
@@ -769,6 +1078,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
769 | 1078 | ||
770 | ApplyPhysics(); | 1079 | ApplyPhysics(); |
771 | 1080 | ||
1081 | if (RootPart.PhysActor != null) | ||
1082 | RootPart.Force = RootPart.Force; | ||
1083 | if (RootPart.PhysActor != null) | ||
1084 | RootPart.Torque = RootPart.Torque; | ||
1085 | if (RootPart.PhysActor != null) | ||
1086 | RootPart.Buoyancy = RootPart.Buoyancy; | ||
1087 | |||
772 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | 1088 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
773 | // for the same object with very different properties. The caller must schedule the update. | 1089 | // for the same object with very different properties. The caller must schedule the update. |
774 | //ScheduleGroupForFullUpdate(); | 1090 | //ScheduleGroupForFullUpdate(); |
@@ -784,6 +1100,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
784 | EntityIntersection result = new EntityIntersection(); | 1100 | EntityIntersection result = new EntityIntersection(); |
785 | 1101 | ||
786 | SceneObjectPart[] parts = m_parts.GetArray(); | 1102 | SceneObjectPart[] parts = m_parts.GetArray(); |
1103 | |||
1104 | // Find closest hit here | ||
1105 | float idist = float.MaxValue; | ||
1106 | |||
787 | for (int i = 0; i < parts.Length; i++) | 1107 | for (int i = 0; i < parts.Length; i++) |
788 | { | 1108 | { |
789 | SceneObjectPart part = parts[i]; | 1109 | SceneObjectPart part = parts[i]; |
@@ -798,11 +1118,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
798 | 1118 | ||
799 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); | 1119 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); |
800 | 1120 | ||
801 | // This may need to be updated to the maximum draw distance possible.. | ||
802 | // We might (and probably will) be checking for prim creation from other sims | ||
803 | // when the camera crosses the border. | ||
804 | float idist = Constants.RegionSize; | ||
805 | |||
806 | if (inter.HitTF) | 1121 | if (inter.HitTF) |
807 | { | 1122 | { |
808 | // We need to find the closest prim to return to the testcaller along the ray | 1123 | // We need to find the closest prim to return to the testcaller along the ray |
@@ -813,10 +1128,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
813 | result.obj = part; | 1128 | result.obj = part; |
814 | result.normal = inter.normal; | 1129 | result.normal = inter.normal; |
815 | result.distance = inter.distance; | 1130 | result.distance = inter.distance; |
1131 | |||
1132 | idist = inter.distance; | ||
816 | } | 1133 | } |
817 | } | 1134 | } |
818 | } | 1135 | } |
819 | |||
820 | return result; | 1136 | return result; |
821 | } | 1137 | } |
822 | 1138 | ||
@@ -828,25 +1144,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
828 | /// <returns></returns> | 1144 | /// <returns></returns> |
829 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) | 1145 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) |
830 | { | 1146 | { |
831 | maxX = -256f; | 1147 | maxX = float.MinValue; |
832 | maxY = -256f; | 1148 | maxY = float.MinValue; |
833 | maxZ = -256f; | 1149 | maxZ = float.MinValue; |
834 | minX = 256f; | 1150 | minX = float.MaxValue; |
835 | minY = 256f; | 1151 | minY = float.MaxValue; |
836 | minZ = 8192f; | 1152 | minZ = float.MaxValue; |
837 | 1153 | ||
838 | SceneObjectPart[] parts = m_parts.GetArray(); | 1154 | SceneObjectPart[] parts = m_parts.GetArray(); |
839 | for (int i = 0; i < parts.Length; i++) | 1155 | foreach (SceneObjectPart part in parts) |
840 | { | 1156 | { |
841 | SceneObjectPart part = parts[i]; | ||
842 | |||
843 | Vector3 worldPos = part.GetWorldPosition(); | 1157 | Vector3 worldPos = part.GetWorldPosition(); |
844 | Vector3 offset = worldPos - AbsolutePosition; | 1158 | Vector3 offset = worldPos - AbsolutePosition; |
845 | Quaternion worldRot; | 1159 | Quaternion worldRot; |
846 | if (part.ParentID == 0) | 1160 | if (part.ParentID == 0) |
1161 | { | ||
847 | worldRot = part.RotationOffset; | 1162 | worldRot = part.RotationOffset; |
1163 | } | ||
848 | else | 1164 | else |
1165 | { | ||
849 | worldRot = part.GetWorldRotation(); | 1166 | worldRot = part.GetWorldRotation(); |
1167 | } | ||
850 | 1168 | ||
851 | Vector3 frontTopLeft; | 1169 | Vector3 frontTopLeft; |
852 | Vector3 frontTopRight; | 1170 | Vector3 frontTopRight; |
@@ -858,6 +1176,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
858 | Vector3 backBottomLeft; | 1176 | Vector3 backBottomLeft; |
859 | Vector3 backBottomRight; | 1177 | Vector3 backBottomRight; |
860 | 1178 | ||
1179 | // Vector3[] corners = new Vector3[8]; | ||
1180 | |||
861 | Vector3 orig = Vector3.Zero; | 1181 | Vector3 orig = Vector3.Zero; |
862 | 1182 | ||
863 | frontTopLeft.X = orig.X - (part.Scale.X / 2); | 1183 | frontTopLeft.X = orig.X - (part.Scale.X / 2); |
@@ -892,6 +1212,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
892 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); | 1212 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); |
893 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); | 1213 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); |
894 | 1214 | ||
1215 | |||
1216 | |||
1217 | //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1218 | //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1219 | //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1220 | //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1221 | //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1222 | //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1223 | //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1224 | //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1225 | |||
1226 | //for (int i = 0; i < 8; i++) | ||
1227 | //{ | ||
1228 | // corners[i] = corners[i] * worldRot; | ||
1229 | // corners[i] += offset; | ||
1230 | |||
1231 | // if (corners[i].X > maxX) | ||
1232 | // maxX = corners[i].X; | ||
1233 | // if (corners[i].X < minX) | ||
1234 | // minX = corners[i].X; | ||
1235 | |||
1236 | // if (corners[i].Y > maxY) | ||
1237 | // maxY = corners[i].Y; | ||
1238 | // if (corners[i].Y < minY) | ||
1239 | // minY = corners[i].Y; | ||
1240 | |||
1241 | // if (corners[i].Z > maxZ) | ||
1242 | // maxZ = corners[i].Y; | ||
1243 | // if (corners[i].Z < minZ) | ||
1244 | // minZ = corners[i].Z; | ||
1245 | //} | ||
1246 | |||
895 | frontTopLeft = frontTopLeft * worldRot; | 1247 | frontTopLeft = frontTopLeft * worldRot; |
896 | frontTopRight = frontTopRight * worldRot; | 1248 | frontTopRight = frontTopRight * worldRot; |
897 | frontBottomLeft = frontBottomLeft * worldRot; | 1249 | frontBottomLeft = frontBottomLeft * worldRot; |
@@ -913,6 +1265,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
913 | backTopLeft += offset; | 1265 | backTopLeft += offset; |
914 | backTopRight += offset; | 1266 | backTopRight += offset; |
915 | 1267 | ||
1268 | //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1269 | //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1270 | //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1271 | //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1272 | //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1273 | //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1274 | //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1275 | //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1276 | |||
916 | if (frontTopRight.X > maxX) | 1277 | if (frontTopRight.X > maxX) |
917 | maxX = frontTopRight.X; | 1278 | maxX = frontTopRight.X; |
918 | if (frontTopLeft.X > maxX) | 1279 | if (frontTopLeft.X > maxX) |
@@ -1056,17 +1417,118 @@ namespace OpenSim.Region.Framework.Scenes | |||
1056 | 1417 | ||
1057 | #endregion | 1418 | #endregion |
1058 | 1419 | ||
1420 | public void GetResourcesCosts(SceneObjectPart apart, | ||
1421 | out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost) | ||
1422 | { | ||
1423 | // this information may need to be cached | ||
1424 | |||
1425 | float cost; | ||
1426 | float tmpcost; | ||
1427 | |||
1428 | bool ComplexCost = false; | ||
1429 | |||
1430 | SceneObjectPart p; | ||
1431 | SceneObjectPart[] parts; | ||
1432 | |||
1433 | lock (m_parts) | ||
1434 | { | ||
1435 | parts = m_parts.GetArray(); | ||
1436 | } | ||
1437 | |||
1438 | int nparts = parts.Length; | ||
1439 | |||
1440 | |||
1441 | for (int i = 0; i < nparts; i++) | ||
1442 | { | ||
1443 | p = parts[i]; | ||
1444 | |||
1445 | if (p.UsesComplexCost) | ||
1446 | { | ||
1447 | ComplexCost = true; | ||
1448 | break; | ||
1449 | } | ||
1450 | } | ||
1451 | |||
1452 | if (ComplexCost) | ||
1453 | { | ||
1454 | linksetResCost = 0; | ||
1455 | linksetPhysCost = 0; | ||
1456 | partCost = 0; | ||
1457 | partPhysCost = 0; | ||
1458 | |||
1459 | for (int i = 0; i < nparts; i++) | ||
1460 | { | ||
1461 | p = parts[i]; | ||
1462 | |||
1463 | cost = p.StreamingCost; | ||
1464 | tmpcost = p.SimulationCost; | ||
1465 | if (tmpcost > cost) | ||
1466 | cost = tmpcost; | ||
1467 | tmpcost = p.PhysicsCost; | ||
1468 | if (tmpcost > cost) | ||
1469 | cost = tmpcost; | ||
1470 | |||
1471 | linksetPhysCost += tmpcost; | ||
1472 | linksetResCost += cost; | ||
1473 | |||
1474 | if (p == apart) | ||
1475 | { | ||
1476 | partCost = cost; | ||
1477 | partPhysCost = tmpcost; | ||
1478 | } | ||
1479 | } | ||
1480 | } | ||
1481 | else | ||
1482 | { | ||
1483 | partPhysCost = 1.0f; | ||
1484 | partCost = 1.0f; | ||
1485 | linksetResCost = (float)nparts; | ||
1486 | linksetPhysCost = linksetResCost; | ||
1487 | } | ||
1488 | } | ||
1489 | |||
1490 | public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost) | ||
1491 | { | ||
1492 | SceneObjectPart p; | ||
1493 | SceneObjectPart[] parts; | ||
1494 | |||
1495 | lock (m_parts) | ||
1496 | { | ||
1497 | parts = m_parts.GetArray(); | ||
1498 | } | ||
1499 | |||
1500 | int nparts = parts.Length; | ||
1501 | |||
1502 | PhysCost = 0; | ||
1503 | StreamCost = 0; | ||
1504 | SimulCost = 0; | ||
1505 | |||
1506 | for (int i = 0; i < nparts; i++) | ||
1507 | { | ||
1508 | p = parts[i]; | ||
1509 | |||
1510 | StreamCost += p.StreamingCost; | ||
1511 | SimulCost += p.SimulationCost; | ||
1512 | PhysCost += p.PhysicsCost; | ||
1513 | } | ||
1514 | } | ||
1515 | |||
1059 | public void SaveScriptedState(XmlTextWriter writer) | 1516 | public void SaveScriptedState(XmlTextWriter writer) |
1060 | { | 1517 | { |
1518 | SaveScriptedState(writer, false); | ||
1519 | } | ||
1520 | |||
1521 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1522 | { | ||
1061 | XmlDocument doc = new XmlDocument(); | 1523 | XmlDocument doc = new XmlDocument(); |
1062 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1524 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
1063 | 1525 | ||
1064 | SceneObjectPart[] parts = m_parts.GetArray(); | 1526 | SceneObjectPart[] parts = m_parts.GetArray(); |
1065 | for (int i = 0; i < parts.Length; i++) | 1527 | for (int i = 0; i < parts.Length; i++) |
1066 | { | 1528 | { |
1067 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(); | 1529 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(oldIDs); |
1068 | foreach (KeyValuePair<UUID, string> kvp in pstates) | 1530 | foreach (KeyValuePair<UUID, string> kvp in pstates) |
1069 | states.Add(kvp.Key, kvp.Value); | 1531 | states[kvp.Key] = kvp.Value; |
1070 | } | 1532 | } |
1071 | 1533 | ||
1072 | if (states.Count > 0) | 1534 | if (states.Count > 0) |
@@ -1086,6 +1548,169 @@ namespace OpenSim.Region.Framework.Scenes | |||
1086 | } | 1548 | } |
1087 | 1549 | ||
1088 | /// <summary> | 1550 | /// <summary> |
1551 | /// Add the avatar to this linkset (avatar is sat). | ||
1552 | /// </summary> | ||
1553 | /// <param name="agentID"></param> | ||
1554 | public void AddAvatar(UUID agentID) | ||
1555 | { | ||
1556 | ScenePresence presence; | ||
1557 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1558 | { | ||
1559 | if (!m_linkedAvatars.Contains(presence)) | ||
1560 | { | ||
1561 | m_linkedAvatars.Add(presence); | ||
1562 | } | ||
1563 | } | ||
1564 | } | ||
1565 | |||
1566 | /// <summary> | ||
1567 | /// Delete the avatar from this linkset (avatar is unsat). | ||
1568 | /// </summary> | ||
1569 | /// <param name="agentID"></param> | ||
1570 | public void DeleteAvatar(UUID agentID) | ||
1571 | { | ||
1572 | ScenePresence presence; | ||
1573 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1574 | { | ||
1575 | if (m_linkedAvatars.Contains(presence)) | ||
1576 | { | ||
1577 | m_linkedAvatars.Remove(presence); | ||
1578 | } | ||
1579 | } | ||
1580 | } | ||
1581 | |||
1582 | /// <summary> | ||
1583 | /// Returns the list of linked presences (avatars sat on this group) | ||
1584 | /// </summary> | ||
1585 | /// <param name="agentID"></param> | ||
1586 | public List<ScenePresence> GetLinkedAvatars() | ||
1587 | { | ||
1588 | return m_linkedAvatars; | ||
1589 | } | ||
1590 | |||
1591 | /// <summary> | ||
1592 | /// Attach this scene object to the given avatar. | ||
1593 | /// </summary> | ||
1594 | /// <param name="agentID"></param> | ||
1595 | /// <param name="attachmentpoint"></param> | ||
1596 | /// <param name="AttachOffset"></param> | ||
1597 | private void AttachToAgent( | ||
1598 | ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | ||
1599 | { | ||
1600 | if (avatar != null) | ||
1601 | { | ||
1602 | // don't attach attachments to child agents | ||
1603 | if (avatar.IsChildAgent) return; | ||
1604 | |||
1605 | // Remove from database and parcel prim count | ||
1606 | m_scene.DeleteFromStorage(so.UUID); | ||
1607 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1608 | |||
1609 | so.AttachedAvatar = avatar.UUID; | ||
1610 | |||
1611 | if (so.RootPart.PhysActor != null) | ||
1612 | { | ||
1613 | m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); | ||
1614 | so.RootPart.PhysActor = null; | ||
1615 | } | ||
1616 | |||
1617 | so.AbsolutePosition = attachOffset; | ||
1618 | so.RootPart.AttachedPos = attachOffset; | ||
1619 | so.IsAttachment = true; | ||
1620 | so.RootPart.SetParentLocalId(avatar.LocalId); | ||
1621 | so.AttachmentPoint = attachmentpoint; | ||
1622 | |||
1623 | avatar.AddAttachment(this); | ||
1624 | |||
1625 | if (!silent) | ||
1626 | { | ||
1627 | // Killing it here will cause the client to deselect it | ||
1628 | // It then reappears on the avatar, deselected | ||
1629 | // through the full update below | ||
1630 | // | ||
1631 | if (IsSelected) | ||
1632 | { | ||
1633 | m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId }); | ||
1634 | } | ||
1635 | |||
1636 | IsSelected = false; // fudge.... | ||
1637 | ScheduleGroupForFullUpdate(); | ||
1638 | } | ||
1639 | } | ||
1640 | else | ||
1641 | { | ||
1642 | m_log.WarnFormat( | ||
1643 | "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", | ||
1644 | UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName); | ||
1645 | } | ||
1646 | } | ||
1647 | |||
1648 | public byte GetAttachmentPoint() | ||
1649 | { | ||
1650 | return m_rootPart.Shape.State; | ||
1651 | } | ||
1652 | |||
1653 | public void DetachToGround() | ||
1654 | { | ||
1655 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1656 | if (avatar == null) | ||
1657 | return; | ||
1658 | |||
1659 | avatar.RemoveAttachment(this); | ||
1660 | |||
1661 | Vector3 detachedpos = new Vector3(127f,127f,127f); | ||
1662 | if (avatar == null) | ||
1663 | return; | ||
1664 | |||
1665 | detachedpos = avatar.AbsolutePosition; | ||
1666 | FromItemID = UUID.Zero; | ||
1667 | |||
1668 | AbsolutePosition = detachedpos; | ||
1669 | AttachedAvatar = UUID.Zero; | ||
1670 | |||
1671 | //SceneObjectPart[] parts = m_parts.GetArray(); | ||
1672 | //for (int i = 0; i < parts.Length; i++) | ||
1673 | // parts[i].AttachedAvatar = UUID.Zero; | ||
1674 | |||
1675 | m_rootPart.SetParentLocalId(0); | ||
1676 | AttachmentPoint = (byte)0; | ||
1677 | // must check if buildind should be true or false here | ||
1678 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false); | ||
1679 | HasGroupChanged = true; | ||
1680 | RootPart.Rezzed = DateTime.Now; | ||
1681 | RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
1682 | AttachToBackup(); | ||
1683 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1684 | m_rootPart.ScheduleFullUpdate(); | ||
1685 | m_rootPart.ClearUndoState(); | ||
1686 | } | ||
1687 | |||
1688 | public void DetachToInventoryPrep() | ||
1689 | { | ||
1690 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1691 | //Vector3 detachedpos = new Vector3(127f, 127f, 127f); | ||
1692 | if (avatar != null) | ||
1693 | { | ||
1694 | //detachedpos = avatar.AbsolutePosition; | ||
1695 | avatar.RemoveAttachment(this); | ||
1696 | } | ||
1697 | |||
1698 | AttachedAvatar = UUID.Zero; | ||
1699 | |||
1700 | /*SceneObjectPart[] parts = m_parts.GetArray(); | ||
1701 | for (int i = 0; i < parts.Length; i++) | ||
1702 | parts[i].AttachedAvatar = UUID.Zero;*/ | ||
1703 | |||
1704 | m_rootPart.SetParentLocalId(0); | ||
1705 | //m_rootPart.SetAttachmentPoint((byte)0); | ||
1706 | IsAttachment = false; | ||
1707 | AbsolutePosition = m_rootPart.AttachedPos; | ||
1708 | //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); | ||
1709 | //AttachToBackup(); | ||
1710 | //m_rootPart.ScheduleFullUpdate(); | ||
1711 | } | ||
1712 | |||
1713 | /// <summary> | ||
1089 | /// | 1714 | /// |
1090 | /// </summary> | 1715 | /// </summary> |
1091 | /// <param name="part"></param> | 1716 | /// <param name="part"></param> |
@@ -1125,7 +1750,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1125 | public void AddPart(SceneObjectPart part) | 1750 | public void AddPart(SceneObjectPart part) |
1126 | { | 1751 | { |
1127 | part.SetParent(this); | 1752 | part.SetParent(this); |
1128 | part.LinkNum = m_parts.Add(part.UUID, part); | 1753 | m_parts.Add(part.UUID, part); |
1754 | |||
1755 | part.LinkNum = m_parts.Count; | ||
1756 | |||
1129 | if (part.LinkNum == 2) | 1757 | if (part.LinkNum == 2) |
1130 | RootPart.LinkNum = 1; | 1758 | RootPart.LinkNum = 1; |
1131 | } | 1759 | } |
@@ -1151,6 +1779,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1151 | parts[i].UUID = UUID.Random(); | 1779 | parts[i].UUID = UUID.Random(); |
1152 | } | 1780 | } |
1153 | 1781 | ||
1782 | // helper provided for parts. | ||
1783 | public int GetSceneMaxUndo() | ||
1784 | { | ||
1785 | if (m_scene != null) | ||
1786 | return m_scene.MaxUndoCount; | ||
1787 | return 5; | ||
1788 | } | ||
1789 | |||
1154 | // justincc: I don't believe this hack is needed any longer, especially since the physics | 1790 | // justincc: I don't believe this hack is needed any longer, especially since the physics |
1155 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false | 1791 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false |
1156 | // this method was preventing proper reload of scene objects. | 1792 | // this method was preventing proper reload of scene objects. |
@@ -1208,7 +1844,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1208 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", | 1844 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", |
1209 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); | 1845 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); |
1210 | 1846 | ||
1211 | part.StoreUndoState(); | 1847 | // part.StoreUndoState(); |
1212 | part.OnGrab(offsetPos, remoteClient); | 1848 | part.OnGrab(offsetPos, remoteClient); |
1213 | } | 1849 | } |
1214 | 1850 | ||
@@ -1228,6 +1864,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1228 | /// <param name="silent">If true then deletion is not broadcast to clients</param> | 1864 | /// <param name="silent">If true then deletion is not broadcast to clients</param> |
1229 | public void DeleteGroupFromScene(bool silent) | 1865 | public void DeleteGroupFromScene(bool silent) |
1230 | { | 1866 | { |
1867 | // We need to keep track of this state in case this group is still queued for backup. | ||
1868 | IsDeleted = true; | ||
1869 | |||
1870 | DetachFromBackup(); | ||
1871 | |||
1231 | SceneObjectPart[] parts = m_parts.GetArray(); | 1872 | SceneObjectPart[] parts = m_parts.GetArray(); |
1232 | for (int i = 0; i < parts.Length; i++) | 1873 | for (int i = 0; i < parts.Length; i++) |
1233 | { | 1874 | { |
@@ -1251,6 +1892,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1251 | } | 1892 | } |
1252 | }); | 1893 | }); |
1253 | } | 1894 | } |
1895 | |||
1254 | } | 1896 | } |
1255 | 1897 | ||
1256 | public void AddScriptLPS(int count) | 1898 | public void AddScriptLPS(int count) |
@@ -1320,28 +1962,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1320 | /// </summary> | 1962 | /// </summary> |
1321 | public void ApplyPhysics() | 1963 | public void ApplyPhysics() |
1322 | { | 1964 | { |
1323 | // Apply physics to the root prim | ||
1324 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); | ||
1325 | |||
1326 | // Apply physics to child prims | ||
1327 | SceneObjectPart[] parts = m_parts.GetArray(); | 1965 | SceneObjectPart[] parts = m_parts.GetArray(); |
1328 | if (parts.Length > 1) | 1966 | if (parts.Length > 1) |
1329 | { | 1967 | { |
1968 | ResetChildPrimPhysicsPositions(); | ||
1969 | |||
1970 | // Apply physics to the root prim | ||
1971 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true); | ||
1972 | |||
1973 | |||
1330 | for (int i = 0; i < parts.Length; i++) | 1974 | for (int i = 0; i < parts.Length; i++) |
1331 | { | 1975 | { |
1332 | SceneObjectPart part = parts[i]; | 1976 | SceneObjectPart part = parts[i]; |
1333 | if (part.LocalId != m_rootPart.LocalId) | 1977 | if (part.LocalId != m_rootPart.LocalId) |
1334 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); | 1978 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, true); |
1335 | } | 1979 | } |
1336 | |||
1337 | // Hack to get the physics scene geometries in the right spot | 1980 | // Hack to get the physics scene geometries in the right spot |
1338 | ResetChildPrimPhysicsPositions(); | 1981 | // ResetChildPrimPhysicsPositions(); |
1982 | if (m_rootPart.PhysActor != null) | ||
1983 | { | ||
1984 | m_rootPart.PhysActor.Building = false; | ||
1985 | } | ||
1986 | } | ||
1987 | else | ||
1988 | { | ||
1989 | // Apply physics to the root prim | ||
1990 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); | ||
1339 | } | 1991 | } |
1340 | } | 1992 | } |
1341 | 1993 | ||
1342 | public void SetOwnerId(UUID userId) | 1994 | public void SetOwnerId(UUID userId) |
1343 | { | 1995 | { |
1344 | ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); | 1996 | ForEachPart(delegate(SceneObjectPart part) |
1997 | { | ||
1998 | |||
1999 | part.OwnerID = userId; | ||
2000 | |||
2001 | }); | ||
1345 | } | 2002 | } |
1346 | 2003 | ||
1347 | public void ForEachPart(Action<SceneObjectPart> whatToDo) | 2004 | public void ForEachPart(Action<SceneObjectPart> whatToDo) |
@@ -1373,11 +2030,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1373 | return; | 2030 | return; |
1374 | } | 2031 | } |
1375 | 2032 | ||
2033 | if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | ||
2034 | return; | ||
2035 | |||
1376 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let | 2036 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let |
1377 | // any exception propogate upwards. | 2037 | // any exception propogate upwards. |
1378 | try | 2038 | try |
1379 | { | 2039 | { |
1380 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart | 2040 | if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart |
2041 | !m_scene.LoginsEnabled || // We're starting up or doing maintenance, don't mess with things | ||
2042 | m_scene.LoadingPrims) // Land may not be valid yet | ||
2043 | |||
1381 | { | 2044 | { |
1382 | ILandObject parcel = m_scene.LandChannel.GetLandObject( | 2045 | ILandObject parcel = m_scene.LandChannel.GetLandObject( |
1383 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); | 2046 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); |
@@ -1404,6 +2067,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1404 | } | 2067 | } |
1405 | } | 2068 | } |
1406 | } | 2069 | } |
2070 | |||
1407 | } | 2071 | } |
1408 | 2072 | ||
1409 | if (m_scene.UseBackup && HasGroupChanged) | 2073 | if (m_scene.UseBackup && HasGroupChanged) |
@@ -1411,10 +2075,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
1411 | // don't backup while it's selected or you're asking for changes mid stream. | 2075 | // don't backup while it's selected or you're asking for changes mid stream. |
1412 | if (isTimeToPersist() || forcedBackup) | 2076 | if (isTimeToPersist() || forcedBackup) |
1413 | { | 2077 | { |
2078 | if (m_rootPart.PhysActor != null && | ||
2079 | (!m_rootPart.PhysActor.IsPhysical)) | ||
2080 | { | ||
2081 | // Possible ghost prim | ||
2082 | if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) | ||
2083 | { | ||
2084 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
2085 | { | ||
2086 | // Re-set physics actor positions and | ||
2087 | // orientations | ||
2088 | part.GroupPosition = m_rootPart.GroupPosition; | ||
2089 | } | ||
2090 | } | ||
2091 | } | ||
1414 | // m_log.DebugFormat( | 2092 | // m_log.DebugFormat( |
1415 | // "[SCENE]: Storing {0}, {1} in {2}", | 2093 | // "[SCENE]: Storing {0}, {1} in {2}", |
1416 | // Name, UUID, m_scene.RegionInfo.RegionName); | 2094 | // Name, UUID, m_scene.RegionInfo.RegionName); |
1417 | 2095 | ||
2096 | if (RootPart.Shape.PCode == 9 && RootPart.Shape.State != 0) | ||
2097 | { | ||
2098 | RootPart.Shape.State = 0; | ||
2099 | ScheduleGroupForFullUpdate(); | ||
2100 | } | ||
2101 | |||
1418 | SceneObjectGroup backup_group = Copy(false); | 2102 | SceneObjectGroup backup_group = Copy(false); |
1419 | backup_group.RootPart.Velocity = RootPart.Velocity; | 2103 | backup_group.RootPart.Velocity = RootPart.Velocity; |
1420 | backup_group.RootPart.Acceleration = RootPart.Acceleration; | 2104 | backup_group.RootPart.Acceleration = RootPart.Acceleration; |
@@ -1424,6 +2108,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1424 | HasGroupChangedDueToDelink = false; | 2108 | HasGroupChangedDueToDelink = false; |
1425 | 2109 | ||
1426 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); | 2110 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); |
2111 | /* | ||
2112 | backup_group.ForEachPart(delegate(SceneObjectPart part) | ||
2113 | { | ||
2114 | if (part.KeyframeMotion != null) | ||
2115 | { | ||
2116 | part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize()); | ||
2117 | // part.KeyframeMotion.UpdateSceneObject(this); | ||
2118 | } | ||
2119 | }); | ||
2120 | */ | ||
1427 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); | 2121 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); |
1428 | 2122 | ||
1429 | backup_group.ForEachPart(delegate(SceneObjectPart part) | 2123 | backup_group.ForEachPart(delegate(SceneObjectPart part) |
@@ -1480,10 +2174,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1480 | /// <returns></returns> | 2174 | /// <returns></returns> |
1481 | public SceneObjectGroup Copy(bool userExposed) | 2175 | public SceneObjectGroup Copy(bool userExposed) |
1482 | { | 2176 | { |
2177 | m_dupeInProgress = true; | ||
1483 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); | 2178 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); |
1484 | dupe.m_isBackedUp = false; | 2179 | dupe.m_isBackedUp = false; |
1485 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); | 2180 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); |
1486 | 2181 | ||
2182 | // new group as no sitting avatars | ||
2183 | dupe.m_linkedAvatars = new List<ScenePresence>(); | ||
2184 | |||
1487 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of | 2185 | // Warning, The following code related to previousAttachmentStatus is needed so that clones of |
1488 | // attachments do not bordercross while they're being duplicated. This is hacktastic! | 2186 | // attachments do not bordercross while they're being duplicated. This is hacktastic! |
1489 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! | 2187 | // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region! |
@@ -1494,7 +2192,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1494 | // This is only necessary when userExposed is false! | 2192 | // This is only necessary when userExposed is false! |
1495 | 2193 | ||
1496 | bool previousAttachmentStatus = dupe.IsAttachment; | 2194 | bool previousAttachmentStatus = dupe.IsAttachment; |
1497 | 2195 | ||
1498 | if (!userExposed) | 2196 | if (!userExposed) |
1499 | dupe.IsAttachment = true; | 2197 | dupe.IsAttachment = true; |
1500 | 2198 | ||
@@ -1507,16 +2205,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1507 | 2205 | ||
1508 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); | 2206 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); |
1509 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; | 2207 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; |
2208 | |||
1510 | 2209 | ||
1511 | if (userExposed) | 2210 | if (userExposed) |
1512 | dupe.m_rootPart.TrimPermissions(); | 2211 | dupe.m_rootPart.TrimPermissions(); |
1513 | 2212 | ||
1514 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); | 2213 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); |
1515 | 2214 | ||
1516 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | 2215 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) |
1517 | { | 2216 | { |
1518 | return p1.LinkNum.CompareTo(p2.LinkNum); | 2217 | return p1.LinkNum.CompareTo(p2.LinkNum); |
1519 | } | 2218 | } |
1520 | ); | 2219 | ); |
1521 | 2220 | ||
1522 | foreach (SceneObjectPart part in partList) | 2221 | foreach (SceneObjectPart part in partList) |
@@ -1526,41 +2225,56 @@ namespace OpenSim.Region.Framework.Scenes | |||
1526 | { | 2225 | { |
1527 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); | 2226 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); |
1528 | newPart.LinkNum = part.LinkNum; | 2227 | newPart.LinkNum = part.LinkNum; |
1529 | } | 2228 | if (userExposed) |
2229 | newPart.ParentID = dupe.m_rootPart.LocalId; | ||
2230 | } | ||
1530 | else | 2231 | else |
1531 | { | 2232 | { |
1532 | newPart = dupe.m_rootPart; | 2233 | newPart = dupe.m_rootPart; |
1533 | } | 2234 | } |
2235 | /* | ||
2236 | bool isphys = ((newPart.Flags & PrimFlags.Physics) != 0); | ||
2237 | bool isphan = ((newPart.Flags & PrimFlags.Phantom) != 0); | ||
1534 | 2238 | ||
1535 | // Need to duplicate the physics actor as well | 2239 | // Need to duplicate the physics actor as well |
1536 | PhysicsActor originalPartPa = part.PhysActor; | 2240 | if (userExposed && (isphys || !isphan || newPart.VolumeDetectActive)) |
1537 | if (originalPartPa != null && userExposed) | ||
1538 | { | 2241 | { |
1539 | PrimitiveBaseShape pbs = newPart.Shape; | 2242 | PrimitiveBaseShape pbs = newPart.Shape; |
1540 | |||
1541 | newPart.PhysActor | 2243 | newPart.PhysActor |
1542 | = m_scene.PhysicsScene.AddPrimShape( | 2244 | = m_scene.PhysicsScene.AddPrimShape( |
1543 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), | 2245 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), |
1544 | pbs, | 2246 | pbs, |
1545 | newPart.AbsolutePosition, | 2247 | newPart.AbsolutePosition, |
1546 | newPart.Scale, | 2248 | newPart.Scale, |
1547 | newPart.RotationOffset, | 2249 | newPart.GetWorldRotation(), |
1548 | originalPartPa.IsPhysical, | 2250 | isphys, |
2251 | isphan, | ||
1549 | newPart.LocalId); | 2252 | newPart.LocalId); |
1550 | 2253 | ||
1551 | newPart.DoPhysicsPropertyUpdate(originalPartPa.IsPhysical, true); | 2254 | newPart.DoPhysicsPropertyUpdate(isphys, true); |
1552 | } | 2255 | */ |
2256 | if (userExposed) | ||
2257 | newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true); | ||
2258 | // } | ||
2259 | // copy keyframemotion | ||
2260 | if (part.KeyframeMotion != null) | ||
2261 | newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); | ||
1553 | } | 2262 | } |
1554 | 2263 | ||
1555 | if (userExposed) | 2264 | if (userExposed) |
1556 | { | 2265 | { |
1557 | dupe.UpdateParentIDs(); | 2266 | // done above dupe.UpdateParentIDs(); |
2267 | |||
2268 | if (dupe.m_rootPart.PhysActor != null) | ||
2269 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building | ||
2270 | |||
1558 | dupe.HasGroupChanged = true; | 2271 | dupe.HasGroupChanged = true; |
1559 | dupe.AttachToBackup(); | 2272 | dupe.AttachToBackup(); |
1560 | 2273 | ||
1561 | ScheduleGroupForFullUpdate(); | 2274 | ScheduleGroupForFullUpdate(); |
1562 | } | 2275 | } |
1563 | 2276 | ||
2277 | m_dupeInProgress = false; | ||
1564 | return dupe; | 2278 | return dupe; |
1565 | } | 2279 | } |
1566 | 2280 | ||
@@ -1572,11 +2286,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1572 | /// <param name="cGroupID"></param> | 2286 | /// <param name="cGroupID"></param> |
1573 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2287 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1574 | { | 2288 | { |
1575 | SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); | 2289 | // SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); |
2290 | // give newpart a new local ID lettng old part keep same | ||
2291 | SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed); | ||
2292 | newpart.LocalId = m_scene.AllocateLocalId(); | ||
2293 | |||
2294 | SetRootPart(newpart); | ||
2295 | if (userExposed) | ||
2296 | RootPart.Velocity = Vector3.Zero; // In case source is moving | ||
1576 | } | 2297 | } |
1577 | 2298 | ||
1578 | public void ScriptSetPhysicsStatus(bool usePhysics) | 2299 | public void ScriptSetPhysicsStatus(bool usePhysics) |
1579 | { | 2300 | { |
2301 | if (usePhysics) | ||
2302 | { | ||
2303 | if (RootPart.KeyframeMotion != null) | ||
2304 | RootPart.KeyframeMotion.Stop(); | ||
2305 | RootPart.KeyframeMotion = null; | ||
2306 | } | ||
1580 | UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 2307 | UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); |
1581 | } | 2308 | } |
1582 | 2309 | ||
@@ -1624,13 +2351,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1624 | 2351 | ||
1625 | if (pa != null) | 2352 | if (pa != null) |
1626 | { | 2353 | { |
1627 | pa.AddForce(impulse, true); | 2354 | // false to be applied as a impulse |
2355 | pa.AddForce(impulse, false); | ||
1628 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2356 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1629 | } | 2357 | } |
1630 | } | 2358 | } |
1631 | } | 2359 | } |
1632 | 2360 | ||
1633 | public void applyAngularImpulse(Vector3 impulse) | 2361 | public void ApplyAngularImpulse(Vector3 impulse) |
1634 | { | 2362 | { |
1635 | PhysicsActor pa = RootPart.PhysActor; | 2363 | PhysicsActor pa = RootPart.PhysActor; |
1636 | 2364 | ||
@@ -1638,21 +2366,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1638 | { | 2366 | { |
1639 | if (!IsAttachment) | 2367 | if (!IsAttachment) |
1640 | { | 2368 | { |
1641 | pa.AddAngularForce(impulse, true); | 2369 | // false to be applied as a impulse |
1642 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2370 | pa.AddAngularForce(impulse, false); |
1643 | } | ||
1644 | } | ||
1645 | } | ||
1646 | |||
1647 | public void setAngularImpulse(Vector3 impulse) | ||
1648 | { | ||
1649 | PhysicsActor pa = RootPart.PhysActor; | ||
1650 | |||
1651 | if (pa != null) | ||
1652 | { | ||
1653 | if (!IsAttachment) | ||
1654 | { | ||
1655 | pa.Torque = impulse; | ||
1656 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2371 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1657 | } | 2372 | } |
1658 | } | 2373 | } |
@@ -1660,20 +2375,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1660 | 2375 | ||
1661 | public Vector3 GetTorque() | 2376 | public Vector3 GetTorque() |
1662 | { | 2377 | { |
1663 | PhysicsActor pa = RootPart.PhysActor; | 2378 | return RootPart.Torque; |
1664 | |||
1665 | if (pa != null) | ||
1666 | { | ||
1667 | if (!IsAttachment) | ||
1668 | { | ||
1669 | Vector3 torque = pa.Torque; | ||
1670 | return torque; | ||
1671 | } | ||
1672 | } | ||
1673 | |||
1674 | return Vector3.Zero; | ||
1675 | } | 2379 | } |
1676 | 2380 | ||
2381 | // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object | ||
1677 | public void moveToTarget(Vector3 target, float tau) | 2382 | public void moveToTarget(Vector3 target, float tau) |
1678 | { | 2383 | { |
1679 | if (IsAttachment) | 2384 | if (IsAttachment) |
@@ -1703,8 +2408,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
1703 | 2408 | ||
1704 | if (pa != null) | 2409 | if (pa != null) |
1705 | pa.PIDActive = false; | 2410 | pa.PIDActive = false; |
2411 | |||
2412 | RootPart.ScheduleTerseUpdate(); // send a stop information | ||
1706 | } | 2413 | } |
1707 | 2414 | ||
2415 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2416 | { | ||
2417 | SceneObjectPart rootpart = m_rootPart; | ||
2418 | if (rootpart != null) | ||
2419 | { | ||
2420 | if (IsAttachment) | ||
2421 | { | ||
2422 | /* | ||
2423 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
2424 | if (avatar != null) | ||
2425 | { | ||
2426 | Rotate the Av? | ||
2427 | } */ | ||
2428 | } | ||
2429 | else | ||
2430 | { | ||
2431 | if (rootpart.PhysActor != null) | ||
2432 | { // APID must be implemented in your physics system for this to function. | ||
2433 | rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); | ||
2434 | rootpart.PhysActor.APIDStrength = strength; | ||
2435 | rootpart.PhysActor.APIDDamping = damping; | ||
2436 | rootpart.PhysActor.APIDActive = true; | ||
2437 | } | ||
2438 | } | ||
2439 | } | ||
2440 | } | ||
2441 | |||
2442 | public void stopLookAt() | ||
2443 | { | ||
2444 | SceneObjectPart rootpart = m_rootPart; | ||
2445 | if (rootpart != null) | ||
2446 | { | ||
2447 | if (rootpart.PhysActor != null) | ||
2448 | { // APID must be implemented in your physics system for this to function. | ||
2449 | rootpart.PhysActor.APIDActive = false; | ||
2450 | } | ||
2451 | } | ||
2452 | |||
2453 | } | ||
2454 | |||
1708 | /// <summary> | 2455 | /// <summary> |
1709 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. | 2456 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. |
1710 | /// </summary> | 2457 | /// </summary> |
@@ -1721,7 +2468,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1721 | { | 2468 | { |
1722 | pa.PIDHoverHeight = height; | 2469 | pa.PIDHoverHeight = height; |
1723 | pa.PIDHoverType = hoverType; | 2470 | pa.PIDHoverType = hoverType; |
1724 | pa.PIDTau = tau; | 2471 | pa.PIDHoverTau = tau; |
1725 | pa.PIDHoverActive = true; | 2472 | pa.PIDHoverActive = true; |
1726 | } | 2473 | } |
1727 | else | 2474 | else |
@@ -1761,7 +2508,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1761 | /// <param name="cGroupID"></param> | 2508 | /// <param name="cGroupID"></param> |
1762 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2509 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1763 | { | 2510 | { |
1764 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | 2511 | // give new ID to the new part, letting old keep original |
2512 | // SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | ||
2513 | SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); | ||
2514 | newPart.LocalId = m_scene.AllocateLocalId(); | ||
2515 | newPart.SetParent(this); | ||
2516 | |||
1765 | AddPart(newPart); | 2517 | AddPart(newPart); |
1766 | 2518 | ||
1767 | SetPartAsNonRoot(newPart); | 2519 | SetPartAsNonRoot(newPart); |
@@ -1811,6 +2563,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1811 | 2563 | ||
1812 | #endregion | 2564 | #endregion |
1813 | 2565 | ||
2566 | |||
1814 | public override void Update() | 2567 | public override void Update() |
1815 | { | 2568 | { |
1816 | // Check that the group was not deleted before the scheduled update | 2569 | // Check that the group was not deleted before the scheduled update |
@@ -1829,19 +2582,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1829 | // check to see if the physical position or rotation warrant an update. | 2582 | // check to see if the physical position or rotation warrant an update. |
1830 | if (m_rootPart.UpdateFlag == UpdateRequired.NONE) | 2583 | if (m_rootPart.UpdateFlag == UpdateRequired.NONE) |
1831 | { | 2584 | { |
1832 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); | 2585 | // rootpart SendScheduledUpdates will check if a update is needed |
1833 | 2586 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | |
1834 | if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) | ||
1835 | { | ||
1836 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | ||
1837 | lastPhysGroupPos = AbsolutePosition; | ||
1838 | } | ||
1839 | |||
1840 | if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) | ||
1841 | { | ||
1842 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | ||
1843 | lastPhysGroupRot = GroupRotation; | ||
1844 | } | ||
1845 | } | 2587 | } |
1846 | 2588 | ||
1847 | SceneObjectPart[] parts = m_parts.GetArray(); | 2589 | SceneObjectPart[] parts = m_parts.GetArray(); |
@@ -1900,11 +2642,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1900 | /// Immediately send a full update for this scene object. | 2642 | /// Immediately send a full update for this scene object. |
1901 | /// </summary> | 2643 | /// </summary> |
1902 | public void SendGroupFullUpdate() | 2644 | public void SendGroupFullUpdate() |
1903 | { | 2645 | { |
1904 | if (IsDeleted) | 2646 | if (IsDeleted) |
1905 | return; | 2647 | return; |
1906 | 2648 | ||
1907 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); | 2649 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); |
1908 | 2650 | ||
1909 | RootPart.SendFullUpdateToAllClients(); | 2651 | RootPart.SendFullUpdateToAllClients(); |
1910 | 2652 | ||
@@ -2060,6 +2802,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2060 | // 'linkPart' == the root of the group being linked into this group | 2802 | // 'linkPart' == the root of the group being linked into this group |
2061 | SceneObjectPart linkPart = objectGroup.m_rootPart; | 2803 | SceneObjectPart linkPart = objectGroup.m_rootPart; |
2062 | 2804 | ||
2805 | if (m_rootPart.PhysActor != null) | ||
2806 | m_rootPart.PhysActor.Building = true; | ||
2807 | if (linkPart.PhysActor != null) | ||
2808 | linkPart.PhysActor.Building = true; | ||
2809 | |||
2063 | // physics flags from group to be applied to linked parts | 2810 | // physics flags from group to be applied to linked parts |
2064 | bool grpusephys = UsesPhysics; | 2811 | bool grpusephys = UsesPhysics; |
2065 | bool grptemporary = IsTemporary; | 2812 | bool grptemporary = IsTemporary; |
@@ -2085,12 +2832,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2085 | Vector3 axPos = linkPart.OffsetPosition; | 2832 | Vector3 axPos = linkPart.OffsetPosition; |
2086 | // Rotate the linking root SOP's position to be relative to the new root prim | 2833 | // Rotate the linking root SOP's position to be relative to the new root prim |
2087 | Quaternion parentRot = m_rootPart.RotationOffset; | 2834 | Quaternion parentRot = m_rootPart.RotationOffset; |
2088 | axPos *= Quaternion.Inverse(parentRot); | 2835 | axPos *= Quaternion.Conjugate(parentRot); |
2089 | linkPart.OffsetPosition = axPos; | 2836 | linkPart.OffsetPosition = axPos; |
2090 | 2837 | ||
2091 | // Make the linking root SOP's rotation relative to the new root prim | 2838 | // Make the linking root SOP's rotation relative to the new root prim |
2092 | Quaternion oldRot = linkPart.RotationOffset; | 2839 | Quaternion oldRot = linkPart.RotationOffset; |
2093 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 2840 | Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; |
2094 | linkPart.RotationOffset = newRot; | 2841 | linkPart.RotationOffset = newRot; |
2095 | 2842 | ||
2096 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. | 2843 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. |
@@ -2124,7 +2871,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2124 | linkPart.CreateSelected = true; | 2871 | linkPart.CreateSelected = true; |
2125 | 2872 | ||
2126 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now | 2873 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now |
2127 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive); | 2874 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); |
2128 | 2875 | ||
2129 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 2876 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2130 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2877 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2134,6 +2881,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2134 | } | 2881 | } |
2135 | 2882 | ||
2136 | linkPart.LinkNum = linkNum++; | 2883 | linkPart.LinkNum = linkNum++; |
2884 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2137 | 2885 | ||
2138 | // Get a list of the SOP's in the old group in order of their linknum's. | 2886 | // Get a list of the SOP's in the old group in order of their linknum's. |
2139 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2887 | SceneObjectPart[] ogParts = objectGroup.Parts; |
@@ -2152,7 +2900,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2152 | 2900 | ||
2153 | // Update the physics flags for the newly added SOP | 2901 | // Update the physics flags for the newly added SOP |
2154 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) | 2902 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) |
2155 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive); | 2903 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); |
2156 | 2904 | ||
2157 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 2905 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2158 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2906 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2170,7 +2918,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2170 | objectGroup.IsDeleted = true; | 2918 | objectGroup.IsDeleted = true; |
2171 | 2919 | ||
2172 | objectGroup.m_parts.Clear(); | 2920 | objectGroup.m_parts.Clear(); |
2173 | 2921 | ||
2174 | // Can't do this yet since backup still makes use of the root part without any synchronization | 2922 | // Can't do this yet since backup still makes use of the root part without any synchronization |
2175 | // objectGroup.m_rootPart = null; | 2923 | // objectGroup.m_rootPart = null; |
2176 | 2924 | ||
@@ -2184,6 +2932,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2184 | // unmoved prims! | 2932 | // unmoved prims! |
2185 | ResetChildPrimPhysicsPositions(); | 2933 | ResetChildPrimPhysicsPositions(); |
2186 | 2934 | ||
2935 | if (m_rootPart.PhysActor != null) | ||
2936 | m_rootPart.PhysActor.Building = false; | ||
2937 | |||
2187 | //HasGroupChanged = true; | 2938 | //HasGroupChanged = true; |
2188 | //ScheduleGroupForFullUpdate(); | 2939 | //ScheduleGroupForFullUpdate(); |
2189 | } | 2940 | } |
@@ -2251,7 +3002,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2251 | // m_log.DebugFormat( | 3002 | // m_log.DebugFormat( |
2252 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", | 3003 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", |
2253 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); | 3004 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); |
2254 | 3005 | ||
3006 | if (m_rootPart.PhysActor != null) | ||
3007 | m_rootPart.PhysActor.Building = true; | ||
3008 | |||
2255 | linkPart.ClearUndoState(); | 3009 | linkPart.ClearUndoState(); |
2256 | 3010 | ||
2257 | Vector3 worldPos = linkPart.GetWorldPosition(); | 3011 | Vector3 worldPos = linkPart.GetWorldPosition(); |
@@ -2322,6 +3076,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2322 | 3076 | ||
2323 | // When we delete a group, we currently have to force persist to the database if the object id has changed | 3077 | // When we delete a group, we currently have to force persist to the database if the object id has changed |
2324 | // (since delete works by deleting all rows which have a given object id) | 3078 | // (since delete works by deleting all rows which have a given object id) |
3079 | |||
3080 | // this is as it seems to be in sl now | ||
3081 | if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none) | ||
3082 | linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now | ||
3083 | |||
3084 | if (m_rootPart.PhysActor != null) | ||
3085 | m_rootPart.PhysActor.Building = false; | ||
3086 | |||
2325 | objectGroup.HasGroupChangedDueToDelink = true; | 3087 | objectGroup.HasGroupChangedDueToDelink = true; |
2326 | 3088 | ||
2327 | return objectGroup; | 3089 | return objectGroup; |
@@ -2333,6 +3095,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2333 | /// <param name="objectGroup"></param> | 3095 | /// <param name="objectGroup"></param> |
2334 | public virtual void DetachFromBackup() | 3096 | public virtual void DetachFromBackup() |
2335 | { | 3097 | { |
3098 | if (m_scene != null) | ||
3099 | m_scene.SceneGraph.FireDetachFromBackup(this); | ||
2336 | if (m_isBackedUp && Scene != null) | 3100 | if (m_isBackedUp && Scene != null) |
2337 | m_scene.EventManager.OnBackup -= ProcessBackup; | 3101 | m_scene.EventManager.OnBackup -= ProcessBackup; |
2338 | 3102 | ||
@@ -2353,7 +3117,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2353 | Vector3 axPos = part.OffsetPosition; | 3117 | Vector3 axPos = part.OffsetPosition; |
2354 | axPos *= parentRot; | 3118 | axPos *= parentRot; |
2355 | part.OffsetPosition = axPos; | 3119 | part.OffsetPosition = axPos; |
2356 | part.GroupPosition = oldGroupPosition + part.OffsetPosition; | 3120 | Vector3 newPos = oldGroupPosition + part.OffsetPosition; |
3121 | part.GroupPosition = newPos; | ||
2357 | part.OffsetPosition = Vector3.Zero; | 3122 | part.OffsetPosition = Vector3.Zero; |
2358 | 3123 | ||
2359 | // Compution our rotation to be not relative to the old parent | 3124 | // Compution our rotation to be not relative to the old parent |
@@ -2368,7 +3133,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2368 | part.LinkNum = linkNum; | 3133 | part.LinkNum = linkNum; |
2369 | 3134 | ||
2370 | // Compute the new position of this SOP relative to the group position | 3135 | // Compute the new position of this SOP relative to the group position |
2371 | part.OffsetPosition = part.GroupPosition - AbsolutePosition; | 3136 | part.OffsetPosition = newPos - AbsolutePosition; |
2372 | 3137 | ||
2373 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. | 3138 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. |
2374 | // It would have the affect of setting the physics engine position multiple | 3139 | // It would have the affect of setting the physics engine position multiple |
@@ -2378,18 +3143,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2378 | // Rotate the relative position by the rotation of the group | 3143 | // Rotate the relative position by the rotation of the group |
2379 | Quaternion rootRotation = m_rootPart.RotationOffset; | 3144 | Quaternion rootRotation = m_rootPart.RotationOffset; |
2380 | Vector3 pos = part.OffsetPosition; | 3145 | Vector3 pos = part.OffsetPosition; |
2381 | pos *= Quaternion.Inverse(rootRotation); | 3146 | pos *= Quaternion.Conjugate(rootRotation); |
2382 | part.OffsetPosition = pos; | 3147 | part.OffsetPosition = pos; |
2383 | 3148 | ||
2384 | // Compute the SOP's rotation relative to the rotation of the group. | 3149 | // Compute the SOP's rotation relative to the rotation of the group. |
2385 | parentRot = m_rootPart.RotationOffset; | 3150 | parentRot = m_rootPart.RotationOffset; |
2386 | oldRot = part.RotationOffset; | 3151 | oldRot = part.RotationOffset; |
2387 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 3152 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
2388 | part.RotationOffset = newRot; | 3153 | part.RotationOffset = newRot; |
2389 | 3154 | ||
2390 | // Since this SOP's state has changed, push those changes into the physics engine | 3155 | // Since this SOP's state has changed, push those changes into the physics engine |
2391 | // and the simulator. | 3156 | // and the simulator. |
2392 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 3157 | // done on caller |
3158 | // part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2393 | } | 3159 | } |
2394 | 3160 | ||
2395 | /// <summary> | 3161 | /// <summary> |
@@ -2411,10 +3177,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2411 | { | 3177 | { |
2412 | if (!m_rootPart.BlockGrab) | 3178 | if (!m_rootPart.BlockGrab) |
2413 | { | 3179 | { |
2414 | Vector3 llmoveforce = pos - AbsolutePosition; | 3180 | /* Vector3 llmoveforce = pos - AbsolutePosition; |
2415 | Vector3 grabforce = llmoveforce; | 3181 | Vector3 grabforce = llmoveforce; |
2416 | grabforce = (grabforce / 10) * pa.Mass; | 3182 | grabforce = (grabforce / 10) * pa.Mass; |
2417 | pa.AddForce(grabforce, true); | 3183 | */ |
3184 | // empirically convert distance diference to a impulse | ||
3185 | Vector3 grabforce = pos - AbsolutePosition; | ||
3186 | grabforce = grabforce * (pa.Mass/ 10.0f); | ||
3187 | pa.AddForce(grabforce, false); | ||
2418 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 3188 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
2419 | } | 3189 | } |
2420 | } | 3190 | } |
@@ -2610,6 +3380,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2610 | /// <param name="SetVolumeDetect"></param> | 3380 | /// <param name="SetVolumeDetect"></param> |
2611 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) | 3381 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) |
2612 | { | 3382 | { |
3383 | HasGroupChanged = true; | ||
3384 | |||
2613 | SceneObjectPart selectionPart = GetPart(localID); | 3385 | SceneObjectPart selectionPart = GetPart(localID); |
2614 | 3386 | ||
2615 | if (SetTemporary && Scene != null) | 3387 | if (SetTemporary && Scene != null) |
@@ -2640,8 +3412,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2640 | } | 3412 | } |
2641 | } | 3413 | } |
2642 | 3414 | ||
2643 | for (int i = 0; i < parts.Length; i++) | 3415 | if (parts.Length > 1) |
2644 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); | 3416 | { |
3417 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3418 | |||
3419 | for (int i = 0; i < parts.Length; i++) | ||
3420 | { | ||
3421 | |||
3422 | if (parts[i].UUID != m_rootPart.UUID) | ||
3423 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3424 | } | ||
3425 | |||
3426 | if (m_rootPart.PhysActor != null) | ||
3427 | m_rootPart.PhysActor.Building = false; | ||
3428 | } | ||
3429 | else | ||
3430 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); | ||
2645 | } | 3431 | } |
2646 | } | 3432 | } |
2647 | 3433 | ||
@@ -2654,6 +3440,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2654 | } | 3440 | } |
2655 | } | 3441 | } |
2656 | 3442 | ||
3443 | |||
3444 | |||
3445 | /// <summary> | ||
3446 | /// Gets the number of parts | ||
3447 | /// </summary> | ||
3448 | /// <returns></returns> | ||
3449 | public int GetPartCount() | ||
3450 | { | ||
3451 | return Parts.Count(); | ||
3452 | } | ||
3453 | |||
2657 | /// <summary> | 3454 | /// <summary> |
2658 | /// Update the texture entry for this part | 3455 | /// Update the texture entry for this part |
2659 | /// </summary> | 3456 | /// </summary> |
@@ -2670,11 +3467,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
2670 | 3467 | ||
2671 | public void AdjustChildPrimPermissions() | 3468 | public void AdjustChildPrimPermissions() |
2672 | { | 3469 | { |
3470 | uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits | ||
3471 | uint foldedPerms = RootPart.OwnerMask & 3; | ||
3472 | |||
2673 | ForEachPart(part => | 3473 | ForEachPart(part => |
2674 | { | 3474 | { |
3475 | newOwnerMask &= part.BaseMask; | ||
2675 | if (part != RootPart) | 3476 | if (part != RootPart) |
2676 | part.ClonePermissions(RootPart); | 3477 | part.ClonePermissions(RootPart); |
2677 | }); | 3478 | }); |
3479 | |||
3480 | uint lockMask = ~(uint)PermissionMask.Move; | ||
3481 | uint lockBit = RootPart.OwnerMask & (uint)PermissionMask.Move; | ||
3482 | RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask); | ||
3483 | RootPart.ScheduleFullUpdate(); | ||
2678 | } | 3484 | } |
2679 | 3485 | ||
2680 | public void UpdatePermissions(UUID AgentID, byte field, uint localID, | 3486 | public void UpdatePermissions(UUID AgentID, byte field, uint localID, |
@@ -2682,8 +3488,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2682 | { | 3488 | { |
2683 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); | 3489 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); |
2684 | 3490 | ||
3491 | bool god = Scene.Permissions.IsGod(AgentID); | ||
3492 | |||
3493 | if (field == 1 && god) | ||
3494 | { | ||
3495 | ForEachPart(part => | ||
3496 | { | ||
3497 | part.BaseMask = RootPart.BaseMask; | ||
3498 | }); | ||
3499 | } | ||
3500 | |||
2685 | AdjustChildPrimPermissions(); | 3501 | AdjustChildPrimPermissions(); |
2686 | 3502 | ||
3503 | if (field == 1 && god) // Base mask was set. Update all child part inventories | ||
3504 | { | ||
3505 | foreach (SceneObjectPart part in Parts) | ||
3506 | part.Inventory.ApplyGodPermissions(RootPart.BaseMask); | ||
3507 | } | ||
3508 | |||
2687 | HasGroupChanged = true; | 3509 | HasGroupChanged = true; |
2688 | 3510 | ||
2689 | // Send the group's properties to all clients once all parts are updated | 3511 | // Send the group's properties to all clients once all parts are updated |
@@ -2729,8 +3551,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2729 | 3551 | ||
2730 | PhysicsActor pa = m_rootPart.PhysActor; | 3552 | PhysicsActor pa = m_rootPart.PhysActor; |
2731 | 3553 | ||
2732 | RootPart.StoreUndoState(true); | ||
2733 | |||
2734 | if (Scene != null) | 3554 | if (Scene != null) |
2735 | { | 3555 | { |
2736 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); | 3556 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); |
@@ -2758,7 +3578,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2758 | SceneObjectPart obPart = parts[i]; | 3578 | SceneObjectPart obPart = parts[i]; |
2759 | if (obPart.UUID != m_rootPart.UUID) | 3579 | if (obPart.UUID != m_rootPart.UUID) |
2760 | { | 3580 | { |
2761 | // obPart.IgnoreUndoUpdate = true; | ||
2762 | Vector3 oldSize = new Vector3(obPart.Scale); | 3581 | Vector3 oldSize = new Vector3(obPart.Scale); |
2763 | 3582 | ||
2764 | float f = 1.0f; | 3583 | float f = 1.0f; |
@@ -2870,8 +3689,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2870 | z *= a; | 3689 | z *= a; |
2871 | } | 3690 | } |
2872 | } | 3691 | } |
2873 | |||
2874 | // obPart.IgnoreUndoUpdate = false; | ||
2875 | } | 3692 | } |
2876 | } | 3693 | } |
2877 | } | 3694 | } |
@@ -2881,9 +3698,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2881 | prevScale.Y *= y; | 3698 | prevScale.Y *= y; |
2882 | prevScale.Z *= z; | 3699 | prevScale.Z *= z; |
2883 | 3700 | ||
2884 | // RootPart.IgnoreUndoUpdate = true; | ||
2885 | RootPart.Resize(prevScale); | 3701 | RootPart.Resize(prevScale); |
2886 | // RootPart.IgnoreUndoUpdate = false; | ||
2887 | 3702 | ||
2888 | for (int i = 0; i < parts.Length; i++) | 3703 | for (int i = 0; i < parts.Length; i++) |
2889 | { | 3704 | { |
@@ -2891,8 +3706,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2891 | 3706 | ||
2892 | if (obPart.UUID != m_rootPart.UUID) | 3707 | if (obPart.UUID != m_rootPart.UUID) |
2893 | { | 3708 | { |
2894 | obPart.IgnoreUndoUpdate = true; | ||
2895 | |||
2896 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); | 3709 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); |
2897 | currentpos.X *= x; | 3710 | currentpos.X *= x; |
2898 | currentpos.Y *= y; | 3711 | currentpos.Y *= y; |
@@ -2905,16 +3718,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2905 | 3718 | ||
2906 | obPart.Resize(newSize); | 3719 | obPart.Resize(newSize); |
2907 | obPart.UpdateOffSet(currentpos); | 3720 | obPart.UpdateOffSet(currentpos); |
2908 | |||
2909 | obPart.IgnoreUndoUpdate = false; | ||
2910 | } | 3721 | } |
2911 | 3722 | ||
2912 | // obPart.IgnoreUndoUpdate = false; | 3723 | HasGroupChanged = true; |
2913 | // obPart.StoreUndoState(); | 3724 | m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); |
3725 | ScheduleGroupForTerseUpdate(); | ||
2914 | } | 3726 | } |
2915 | |||
2916 | // m_log.DebugFormat( | ||
2917 | // "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); | ||
2918 | } | 3727 | } |
2919 | 3728 | ||
2920 | #endregion | 3729 | #endregion |
@@ -2927,14 +3736,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2927 | /// <param name="pos"></param> | 3736 | /// <param name="pos"></param> |
2928 | public void UpdateGroupPosition(Vector3 pos) | 3737 | public void UpdateGroupPosition(Vector3 pos) |
2929 | { | 3738 | { |
2930 | // m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); | ||
2931 | |||
2932 | RootPart.StoreUndoState(true); | ||
2933 | |||
2934 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2935 | // for (int i = 0; i < parts.Length; i++) | ||
2936 | // parts[i].StoreUndoState(); | ||
2937 | |||
2938 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 3739 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
2939 | { | 3740 | { |
2940 | if (IsAttachment) | 3741 | if (IsAttachment) |
@@ -2967,21 +3768,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2967 | /// </summary> | 3768 | /// </summary> |
2968 | /// <param name="pos"></param> | 3769 | /// <param name="pos"></param> |
2969 | /// <param name="localID"></param> | 3770 | /// <param name="localID"></param> |
3771 | /// | ||
3772 | |||
2970 | public void UpdateSinglePosition(Vector3 pos, uint localID) | 3773 | public void UpdateSinglePosition(Vector3 pos, uint localID) |
2971 | { | 3774 | { |
2972 | SceneObjectPart part = GetPart(localID); | 3775 | SceneObjectPart part = GetPart(localID); |
2973 | 3776 | ||
2974 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
2975 | // for (int i = 0; i < parts.Length; i++) | ||
2976 | // parts[i].StoreUndoState(); | ||
2977 | |||
2978 | if (part != null) | 3777 | if (part != null) |
2979 | { | 3778 | { |
2980 | // m_log.DebugFormat( | 3779 | // unlock parts position change |
2981 | // "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); | 3780 | if (m_rootPart.PhysActor != null) |
2982 | 3781 | m_rootPart.PhysActor.Building = true; | |
2983 | part.StoreUndoState(false); | ||
2984 | part.IgnoreUndoUpdate = true; | ||
2985 | 3782 | ||
2986 | if (part.UUID == m_rootPart.UUID) | 3783 | if (part.UUID == m_rootPart.UUID) |
2987 | { | 3784 | { |
@@ -2992,8 +3789,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2992 | part.UpdateOffSet(pos); | 3789 | part.UpdateOffSet(pos); |
2993 | } | 3790 | } |
2994 | 3791 | ||
3792 | if (m_rootPart.PhysActor != null) | ||
3793 | m_rootPart.PhysActor.Building = false; | ||
3794 | |||
2995 | HasGroupChanged = true; | 3795 | HasGroupChanged = true; |
2996 | part.IgnoreUndoUpdate = false; | ||
2997 | } | 3796 | } |
2998 | } | 3797 | } |
2999 | 3798 | ||
@@ -3003,13 +3802,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3003 | /// <param name="pos"></param> | 3802 | /// <param name="pos"></param> |
3004 | public void UpdateRootPosition(Vector3 pos) | 3803 | public void UpdateRootPosition(Vector3 pos) |
3005 | { | 3804 | { |
3006 | // m_log.DebugFormat( | 3805 | // needs to be called with phys building true |
3007 | // "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); | ||
3008 | |||
3009 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3010 | // for (int i = 0; i < parts.Length; i++) | ||
3011 | // parts[i].StoreUndoState(); | ||
3012 | |||
3013 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); | 3806 | Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); |
3014 | Vector3 oldPos = | 3807 | Vector3 oldPos = |
3015 | new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, | 3808 | new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, |
@@ -3032,7 +3825,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3032 | AbsolutePosition = newPos; | 3825 | AbsolutePosition = newPos; |
3033 | 3826 | ||
3034 | HasGroupChanged = true; | 3827 | HasGroupChanged = true; |
3035 | ScheduleGroupForTerseUpdate(); | 3828 | if (m_rootPart.Undoing) |
3829 | { | ||
3830 | ScheduleGroupForFullUpdate(); | ||
3831 | } | ||
3832 | else | ||
3833 | { | ||
3834 | ScheduleGroupForTerseUpdate(); | ||
3835 | } | ||
3036 | } | 3836 | } |
3037 | 3837 | ||
3038 | #endregion | 3838 | #endregion |
@@ -3045,24 +3845,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3045 | /// <param name="rot"></param> | 3845 | /// <param name="rot"></param> |
3046 | public void UpdateGroupRotationR(Quaternion rot) | 3846 | public void UpdateGroupRotationR(Quaternion rot) |
3047 | { | 3847 | { |
3048 | // m_log.DebugFormat( | ||
3049 | // "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); | ||
3050 | |||
3051 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3052 | // for (int i = 0; i < parts.Length; i++) | ||
3053 | // parts[i].StoreUndoState(); | ||
3054 | |||
3055 | m_rootPart.StoreUndoState(true); | ||
3056 | |||
3057 | m_rootPart.UpdateRotation(rot); | 3848 | m_rootPart.UpdateRotation(rot); |
3058 | 3849 | ||
3850 | /* this is done by rootpart RotationOffset set called by UpdateRotation | ||
3059 | PhysicsActor actor = m_rootPart.PhysActor; | 3851 | PhysicsActor actor = m_rootPart.PhysActor; |
3060 | if (actor != null) | 3852 | if (actor != null) |
3061 | { | 3853 | { |
3062 | actor.Orientation = m_rootPart.RotationOffset; | 3854 | actor.Orientation = m_rootPart.RotationOffset; |
3063 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); | 3855 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
3064 | } | 3856 | } |
3065 | 3857 | */ | |
3066 | HasGroupChanged = true; | 3858 | HasGroupChanged = true; |
3067 | ScheduleGroupForTerseUpdate(); | 3859 | ScheduleGroupForTerseUpdate(); |
3068 | } | 3860 | } |
@@ -3074,16 +3866,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3074 | /// <param name="rot"></param> | 3866 | /// <param name="rot"></param> |
3075 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) | 3867 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) |
3076 | { | 3868 | { |
3077 | // m_log.DebugFormat( | ||
3078 | // "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); | ||
3079 | |||
3080 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3081 | // for (int i = 0; i < parts.Length; i++) | ||
3082 | // parts[i].StoreUndoState(); | ||
3083 | |||
3084 | RootPart.StoreUndoState(true); | ||
3085 | RootPart.IgnoreUndoUpdate = true; | ||
3086 | |||
3087 | m_rootPart.UpdateRotation(rot); | 3869 | m_rootPart.UpdateRotation(rot); |
3088 | 3870 | ||
3089 | PhysicsActor actor = m_rootPart.PhysActor; | 3871 | PhysicsActor actor = m_rootPart.PhysActor; |
@@ -3102,8 +3884,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3102 | 3884 | ||
3103 | HasGroupChanged = true; | 3885 | HasGroupChanged = true; |
3104 | ScheduleGroupForTerseUpdate(); | 3886 | ScheduleGroupForTerseUpdate(); |
3105 | |||
3106 | RootPart.IgnoreUndoUpdate = false; | ||
3107 | } | 3887 | } |
3108 | 3888 | ||
3109 | /// <summary> | 3889 | /// <summary> |
@@ -3116,13 +3896,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3116 | SceneObjectPart part = GetPart(localID); | 3896 | SceneObjectPart part = GetPart(localID); |
3117 | 3897 | ||
3118 | SceneObjectPart[] parts = m_parts.GetArray(); | 3898 | SceneObjectPart[] parts = m_parts.GetArray(); |
3119 | for (int i = 0; i < parts.Length; i++) | ||
3120 | parts[i].StoreUndoState(); | ||
3121 | 3899 | ||
3122 | if (part != null) | 3900 | if (part != null) |
3123 | { | 3901 | { |
3124 | // m_log.DebugFormat( | 3902 | if (m_rootPart.PhysActor != null) |
3125 | // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); | 3903 | m_rootPart.PhysActor.Building = true; |
3126 | 3904 | ||
3127 | if (part.UUID == m_rootPart.UUID) | 3905 | if (part.UUID == m_rootPart.UUID) |
3128 | { | 3906 | { |
@@ -3132,6 +3910,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3132 | { | 3910 | { |
3133 | part.UpdateRotation(rot); | 3911 | part.UpdateRotation(rot); |
3134 | } | 3912 | } |
3913 | |||
3914 | if (m_rootPart.PhysActor != null) | ||
3915 | m_rootPart.PhysActor.Building = false; | ||
3135 | } | 3916 | } |
3136 | } | 3917 | } |
3137 | 3918 | ||
@@ -3145,12 +3926,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3145 | SceneObjectPart part = GetPart(localID); | 3926 | SceneObjectPart part = GetPart(localID); |
3146 | if (part != null) | 3927 | if (part != null) |
3147 | { | 3928 | { |
3148 | // m_log.DebugFormat( | 3929 | if (m_rootPart.PhysActor != null) |
3149 | // "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", | 3930 | m_rootPart.PhysActor.Building = true; |
3150 | // part.Name, part.LocalId, rot); | ||
3151 | |||
3152 | part.StoreUndoState(); | ||
3153 | part.IgnoreUndoUpdate = true; | ||
3154 | 3931 | ||
3155 | if (part.UUID == m_rootPart.UUID) | 3932 | if (part.UUID == m_rootPart.UUID) |
3156 | { | 3933 | { |
@@ -3163,7 +3940,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3163 | part.OffsetPosition = pos; | 3940 | part.OffsetPosition = pos; |
3164 | } | 3941 | } |
3165 | 3942 | ||
3166 | part.IgnoreUndoUpdate = false; | 3943 | if (m_rootPart.PhysActor != null) |
3944 | m_rootPart.PhysActor.Building = false; | ||
3167 | } | 3945 | } |
3168 | } | 3946 | } |
3169 | 3947 | ||
@@ -3173,15 +3951,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3173 | /// <param name="rot"></param> | 3951 | /// <param name="rot"></param> |
3174 | public void UpdateRootRotation(Quaternion rot) | 3952 | public void UpdateRootRotation(Quaternion rot) |
3175 | { | 3953 | { |
3176 | // m_log.DebugFormat( | 3954 | // needs to be called with phys building true |
3177 | // "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", | ||
3178 | // Name, LocalId, rot); | ||
3179 | |||
3180 | Quaternion axRot = rot; | 3955 | Quaternion axRot = rot; |
3181 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 3956 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
3182 | 3957 | ||
3183 | m_rootPart.StoreUndoState(); | 3958 | //Don't use UpdateRotation because it schedules an update prematurely |
3184 | m_rootPart.UpdateRotation(rot); | 3959 | m_rootPart.RotationOffset = rot; |
3185 | 3960 | ||
3186 | PhysicsActor pa = m_rootPart.PhysActor; | 3961 | PhysicsActor pa = m_rootPart.PhysActor; |
3187 | 3962 | ||
@@ -3197,35 +3972,145 @@ namespace OpenSim.Region.Framework.Scenes | |||
3197 | SceneObjectPart prim = parts[i]; | 3972 | SceneObjectPart prim = parts[i]; |
3198 | if (prim.UUID != m_rootPart.UUID) | 3973 | if (prim.UUID != m_rootPart.UUID) |
3199 | { | 3974 | { |
3200 | prim.IgnoreUndoUpdate = true; | 3975 | Quaternion NewRot = oldParentRot * prim.RotationOffset; |
3976 | NewRot = Quaternion.Inverse(axRot) * NewRot; | ||
3977 | prim.RotationOffset = NewRot; | ||
3978 | |||
3201 | Vector3 axPos = prim.OffsetPosition; | 3979 | Vector3 axPos = prim.OffsetPosition; |
3980 | |||
3202 | axPos *= oldParentRot; | 3981 | axPos *= oldParentRot; |
3203 | axPos *= Quaternion.Inverse(axRot); | 3982 | axPos *= Quaternion.Inverse(axRot); |
3204 | prim.OffsetPosition = axPos; | 3983 | prim.OffsetPosition = axPos; |
3205 | Quaternion primsRot = prim.RotationOffset; | 3984 | } |
3206 | Quaternion newRot = oldParentRot * primsRot; | 3985 | } |
3207 | newRot = Quaternion.Inverse(axRot) * newRot; | ||
3208 | prim.RotationOffset = newRot; | ||
3209 | prim.ScheduleTerseUpdate(); | ||
3210 | prim.IgnoreUndoUpdate = false; | ||
3211 | } | ||
3212 | } | ||
3213 | |||
3214 | // for (int i = 0; i < parts.Length; i++) | ||
3215 | // { | ||
3216 | // SceneObjectPart childpart = parts[i]; | ||
3217 | // if (childpart != m_rootPart) | ||
3218 | // { | ||
3219 | //// childpart.IgnoreUndoUpdate = false; | ||
3220 | //// childpart.StoreUndoState(); | ||
3221 | // } | ||
3222 | // } | ||
3223 | 3986 | ||
3224 | m_rootPart.ScheduleTerseUpdate(); | 3987 | HasGroupChanged = true; |
3988 | ScheduleGroupForFullUpdate(); | ||
3989 | } | ||
3225 | 3990 | ||
3226 | // m_log.DebugFormat( | 3991 | private enum updatetype :int |
3227 | // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", | 3992 | { |
3228 | // Name, LocalId, rot); | 3993 | none = 0, |
3994 | partterse = 1, | ||
3995 | partfull = 2, | ||
3996 | groupterse = 3, | ||
3997 | groupfull = 4 | ||
3998 | } | ||
3999 | |||
4000 | public void doChangeObject(SceneObjectPart part, ObjectChangeData data) | ||
4001 | { | ||
4002 | // TODO this still as excessive *.Schedule*Update()s | ||
4003 | |||
4004 | if (part != null && part.ParentGroup != null) | ||
4005 | { | ||
4006 | ObjectChangeType change = data.change; | ||
4007 | bool togroup = ((change & ObjectChangeType.Group) != 0); | ||
4008 | // bool uniform = ((what & ObjectChangeType.UniformScale) != 0); not in use | ||
4009 | |||
4010 | SceneObjectGroup group = part.ParentGroup; | ||
4011 | PhysicsActor pha = group.RootPart.PhysActor; | ||
4012 | |||
4013 | updatetype updateType = updatetype.none; | ||
4014 | |||
4015 | if (togroup) | ||
4016 | { | ||
4017 | // related to group | ||
4018 | if ((change & (ObjectChangeType.Rotation | ObjectChangeType.Position)) != 0) | ||
4019 | { | ||
4020 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4021 | { | ||
4022 | group.RootPart.UpdateRotation(data.rotation); | ||
4023 | updateType = updatetype.none; | ||
4024 | } | ||
4025 | if ((change & ObjectChangeType.Position) != 0) | ||
4026 | { | ||
4027 | if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) | ||
4028 | UpdateGroupPosition(data.position); | ||
4029 | updateType = updatetype.groupterse; | ||
4030 | } | ||
4031 | else | ||
4032 | // ugly rotation update of all parts | ||
4033 | { | ||
4034 | group.ResetChildPrimPhysicsPositions(); | ||
4035 | } | ||
4036 | |||
4037 | } | ||
4038 | if ((change & ObjectChangeType.Scale) != 0) | ||
4039 | { | ||
4040 | if (pha != null) | ||
4041 | pha.Building = true; | ||
4042 | |||
4043 | group.GroupResize(data.scale); | ||
4044 | updateType = updatetype.none; | ||
4045 | |||
4046 | if (pha != null) | ||
4047 | pha.Building = false; | ||
4048 | } | ||
4049 | } | ||
4050 | else | ||
4051 | { | ||
4052 | // related to single prim in a link-set ( ie group) | ||
4053 | if (pha != null) | ||
4054 | pha.Building = true; | ||
4055 | |||
4056 | // root part is special | ||
4057 | // parts offset positions or rotations need to change also | ||
4058 | |||
4059 | if (part == group.RootPart) | ||
4060 | { | ||
4061 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4062 | group.UpdateRootRotation(data.rotation); | ||
4063 | if ((change & ObjectChangeType.Position) != 0) | ||
4064 | group.UpdateRootPosition(data.position); | ||
4065 | if ((change & ObjectChangeType.Scale) != 0) | ||
4066 | part.Resize(data.scale); | ||
4067 | } | ||
4068 | else | ||
4069 | { | ||
4070 | if ((change & ObjectChangeType.Position) != 0) | ||
4071 | { | ||
4072 | part.OffsetPosition = data.position; | ||
4073 | updateType = updatetype.partterse; | ||
4074 | } | ||
4075 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4076 | { | ||
4077 | part.UpdateRotation(data.rotation); | ||
4078 | updateType = updatetype.none; | ||
4079 | } | ||
4080 | if ((change & ObjectChangeType.Scale) != 0) | ||
4081 | { | ||
4082 | part.Resize(data.scale); | ||
4083 | updateType = updatetype.none; | ||
4084 | } | ||
4085 | } | ||
4086 | |||
4087 | if (pha != null) | ||
4088 | pha.Building = false; | ||
4089 | } | ||
4090 | |||
4091 | if (updateType != updatetype.none) | ||
4092 | { | ||
4093 | group.HasGroupChanged = true; | ||
4094 | |||
4095 | switch (updateType) | ||
4096 | { | ||
4097 | case updatetype.partterse: | ||
4098 | part.ScheduleTerseUpdate(); | ||
4099 | break; | ||
4100 | case updatetype.partfull: | ||
4101 | part.ScheduleFullUpdate(); | ||
4102 | break; | ||
4103 | case updatetype.groupterse: | ||
4104 | group.ScheduleGroupForTerseUpdate(); | ||
4105 | break; | ||
4106 | case updatetype.groupfull: | ||
4107 | group.ScheduleGroupForFullUpdate(); | ||
4108 | break; | ||
4109 | default: | ||
4110 | break; | ||
4111 | } | ||
4112 | } | ||
4113 | } | ||
3229 | } | 4114 | } |
3230 | 4115 | ||
3231 | #endregion | 4116 | #endregion |
@@ -3266,6 +4151,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3266 | waypoint.handle = handle; | 4151 | waypoint.handle = handle; |
3267 | lock (m_rotTargets) | 4152 | lock (m_rotTargets) |
3268 | { | 4153 | { |
4154 | if (m_rotTargets.Count >= 8) | ||
4155 | m_rotTargets.Remove(m_rotTargets.ElementAt(0).Key); | ||
3269 | m_rotTargets.Add(handle, waypoint); | 4156 | m_rotTargets.Add(handle, waypoint); |
3270 | } | 4157 | } |
3271 | m_scene.AddGroupTarget(this); | 4158 | m_scene.AddGroupTarget(this); |
@@ -3291,6 +4178,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3291 | waypoint.handle = handle; | 4178 | waypoint.handle = handle; |
3292 | lock (m_targets) | 4179 | lock (m_targets) |
3293 | { | 4180 | { |
4181 | if (m_targets.Count >= 8) | ||
4182 | m_targets.Remove(m_targets.ElementAt(0).Key); | ||
3294 | m_targets.Add(handle, waypoint); | 4183 | m_targets.Add(handle, waypoint); |
3295 | } | 4184 | } |
3296 | m_scene.AddGroupTarget(this); | 4185 | m_scene.AddGroupTarget(this); |
@@ -3324,10 +4213,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3324 | scriptPosTarget target = m_targets[idx]; | 4213 | scriptPosTarget target = m_targets[idx]; |
3325 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) | 4214 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) |
3326 | { | 4215 | { |
4216 | at_target = true; | ||
4217 | |||
3327 | // trigger at_target | 4218 | // trigger at_target |
3328 | if (m_scriptListens_atTarget) | 4219 | if (m_scriptListens_atTarget) |
3329 | { | 4220 | { |
3330 | at_target = true; | ||
3331 | scriptPosTarget att = new scriptPosTarget(); | 4221 | scriptPosTarget att = new scriptPosTarget(); |
3332 | att.targetPos = target.targetPos; | 4222 | att.targetPos = target.targetPos; |
3333 | att.tolerance = target.tolerance; | 4223 | att.tolerance = target.tolerance; |
@@ -3445,11 +4335,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
3445 | } | 4335 | } |
3446 | } | 4336 | } |
3447 | } | 4337 | } |
3448 | 4338 | ||
4339 | public Vector3 GetGeometricCenter() | ||
4340 | { | ||
4341 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
4342 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
4343 | // ignoring tortured prims details since sl also seems to ignore | ||
4344 | // so no real use in doing it on physics | ||
4345 | |||
4346 | Vector3 gc = Vector3.Zero; | ||
4347 | |||
4348 | int nparts = m_parts.Count; | ||
4349 | if (nparts <= 1) | ||
4350 | return gc; | ||
4351 | |||
4352 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4353 | nparts = parts.Length; // just in case it changed | ||
4354 | if (nparts <= 1) | ||
4355 | return gc; | ||
4356 | |||
4357 | Quaternion parentRot = RootPart.RotationOffset; | ||
4358 | Vector3 pPos; | ||
4359 | |||
4360 | // average all parts positions | ||
4361 | for (int i = 0; i < nparts; i++) | ||
4362 | { | ||
4363 | // do it directly | ||
4364 | // gc += parts[i].GetWorldPosition(); | ||
4365 | if (parts[i] != RootPart) | ||
4366 | { | ||
4367 | pPos = parts[i].OffsetPosition; | ||
4368 | gc += pPos; | ||
4369 | } | ||
4370 | |||
4371 | } | ||
4372 | gc /= nparts; | ||
4373 | |||
4374 | // relative to root: | ||
4375 | // gc -= AbsolutePosition; | ||
4376 | return gc; | ||
4377 | } | ||
4378 | |||
3449 | public float GetMass() | 4379 | public float GetMass() |
3450 | { | 4380 | { |
3451 | float retmass = 0f; | 4381 | float retmass = 0f; |
3452 | |||
3453 | SceneObjectPart[] parts = m_parts.GetArray(); | 4382 | SceneObjectPart[] parts = m_parts.GetArray(); |
3454 | for (int i = 0; i < parts.Length; i++) | 4383 | for (int i = 0; i < parts.Length; i++) |
3455 | retmass += parts[i].GetMass(); | 4384 | retmass += parts[i].GetMass(); |
@@ -3457,6 +4386,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3457 | return retmass; | 4386 | return retmass; |
3458 | } | 4387 | } |
3459 | 4388 | ||
4389 | // center of mass of full object | ||
4390 | public Vector3 GetCenterOfMass() | ||
4391 | { | ||
4392 | PhysicsActor pa = RootPart.PhysActor; | ||
4393 | |||
4394 | if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null) | ||
4395 | { | ||
4396 | // physics knows better about center of mass of physical prims | ||
4397 | Vector3 tmp = pa.CenterOfMass; | ||
4398 | return tmp; | ||
4399 | } | ||
4400 | |||
4401 | Vector3 Ptot = Vector3.Zero; | ||
4402 | float totmass = 0f; | ||
4403 | float m; | ||
4404 | |||
4405 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4406 | for (int i = 0; i < parts.Length; i++) | ||
4407 | { | ||
4408 | m = parts[i].GetMass(); | ||
4409 | Ptot += parts[i].GetPartCenterOfMass() * m; | ||
4410 | totmass += m; | ||
4411 | } | ||
4412 | |||
4413 | if (totmass == 0) | ||
4414 | totmass = 0; | ||
4415 | else | ||
4416 | totmass = 1 / totmass; | ||
4417 | Ptot *= totmass; | ||
4418 | |||
4419 | return Ptot; | ||
4420 | } | ||
4421 | |||
3460 | /// <summary> | 4422 | /// <summary> |
3461 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that | 4423 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that |
3462 | /// the physics engine can use it. | 4424 | /// the physics engine can use it. |
@@ -3636,6 +4598,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3636 | FromItemID = uuid; | 4598 | FromItemID = uuid; |
3637 | } | 4599 | } |
3638 | 4600 | ||
4601 | public void ResetOwnerChangeFlag() | ||
4602 | { | ||
4603 | ForEachPart(delegate(SceneObjectPart part) | ||
4604 | { | ||
4605 | part.ResetOwnerChangeFlag(); | ||
4606 | }); | ||
4607 | } | ||
4608 | |||
3639 | #endregion | 4609 | #endregion |
3640 | } | 4610 | } |
3641 | } | 4611 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b00f388..415a82b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -63,7 +63,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
63 | TELEPORT = 512, | 63 | TELEPORT = 512, |
64 | REGION_RESTART = 1024, | 64 | REGION_RESTART = 1024, |
65 | MEDIA = 2048, | 65 | MEDIA = 2048, |
66 | ANIMATION = 16384 | 66 | ANIMATION = 16384, |
67 | POSITION = 32768 | ||
67 | } | 68 | } |
68 | 69 | ||
69 | // I don't really know where to put this except here. | 70 | // I don't really know where to put this except here. |
@@ -122,7 +123,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
122 | /// Denote all sides of the prim | 123 | /// Denote all sides of the prim |
123 | /// </value> | 124 | /// </value> |
124 | public const int ALL_SIDES = -1; | 125 | public const int ALL_SIDES = -1; |
125 | 126 | ||
127 | private const scriptEvents PhysicsNeededSubsEvents = ( | ||
128 | scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | | ||
129 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
130 | ); | ||
131 | private const scriptEvents PhyscicsPhantonSubsEvents = ( | ||
132 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
133 | ); | ||
134 | private const scriptEvents PhyscicsVolumeDtcSubsEvents = ( | ||
135 | scriptEvents.collision_start | scriptEvents.collision_end | ||
136 | ); | ||
137 | |||
126 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 138 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
127 | 139 | ||
128 | /// <summary> | 140 | /// <summary> |
@@ -138,7 +150,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
138 | /// </remarks> | 150 | /// </remarks> |
139 | public bool IsRoot | 151 | public bool IsRoot |
140 | { | 152 | { |
141 | get { return ParentGroup.RootPart == this; } | 153 | get { return Object.ReferenceEquals(ParentGroup.RootPart, this); } |
142 | } | 154 | } |
143 | 155 | ||
144 | /// <summary> | 156 | /// <summary> |
@@ -197,12 +209,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
197 | 209 | ||
198 | public double SoundRadius; | 210 | public double SoundRadius; |
199 | 211 | ||
212 | |||
200 | public uint TimeStampFull; | 213 | public uint TimeStampFull; |
201 | 214 | ||
202 | public uint TimeStampLastActivity; // Will be used for AutoReturn | 215 | public uint TimeStampLastActivity; // Will be used for AutoReturn |
203 | 216 | ||
204 | public uint TimeStampTerse; | 217 | public uint TimeStampTerse; |
205 | 218 | ||
219 | // The following two are to hold the attachment data | ||
220 | // while an object is inworld | ||
221 | [XmlIgnore] | ||
222 | public byte AttachPoint = 0; | ||
223 | |||
224 | [XmlIgnore] | ||
225 | public Vector3 AttachOffset = Vector3.Zero; | ||
226 | |||
227 | [XmlIgnore] | ||
228 | public Quaternion AttachRotation = Quaternion.Identity; | ||
229 | |||
230 | [XmlIgnore] | ||
206 | public int STATUS_ROTATE_X; | 231 | public int STATUS_ROTATE_X; |
207 | 232 | ||
208 | public int STATUS_ROTATE_Y; | 233 | public int STATUS_ROTATE_Y; |
@@ -229,8 +254,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
229 | 254 | ||
230 | public Vector3 RotationAxis = Vector3.One; | 255 | public Vector3 RotationAxis = Vector3.One; |
231 | 256 | ||
232 | public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this | 257 | public bool VolumeDetectActive; |
233 | // Certainly this must be a persistant setting finally | ||
234 | 258 | ||
235 | public bool IsWaitingForFirstSpinUpdatePacket; | 259 | public bool IsWaitingForFirstSpinUpdatePacket; |
236 | 260 | ||
@@ -270,10 +294,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
270 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; | 294 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; |
271 | private Vector3 m_sitTargetPosition; | 295 | private Vector3 m_sitTargetPosition; |
272 | private string m_sitAnimation = "SIT"; | 296 | private string m_sitAnimation = "SIT"; |
297 | private bool m_occupied; // KF if any av is sitting on this prim | ||
273 | private string m_text = String.Empty; | 298 | private string m_text = String.Empty; |
274 | private string m_touchName = String.Empty; | 299 | private string m_touchName = String.Empty; |
275 | private readonly List<UndoState> m_undo = new List<UndoState>(5); | 300 | private UndoRedoState m_UndoRedo = null; |
276 | private readonly List<UndoState> m_redo = new List<UndoState>(5); | ||
277 | 301 | ||
278 | private bool m_passTouches = false; | 302 | private bool m_passTouches = false; |
279 | private bool m_passCollisions = false; | 303 | private bool m_passCollisions = false; |
@@ -301,15 +325,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
301 | protected Vector3 m_lastVelocity; | 325 | protected Vector3 m_lastVelocity; |
302 | protected Vector3 m_lastAcceleration; | 326 | protected Vector3 m_lastAcceleration; |
303 | protected Vector3 m_lastAngularVelocity; | 327 | protected Vector3 m_lastAngularVelocity; |
304 | protected int m_lastTerseSent; | 328 | protected int m_lastUpdateSentTime; |
329 | protected float m_buoyancy = 0.0f; | ||
330 | protected Vector3 m_force; | ||
331 | protected Vector3 m_torque; | ||
305 | 332 | ||
306 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; | 333 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; |
307 | // TODO: Implement these | 334 | protected float m_density = 1000.0f; // in kg/m^3 |
308 | //protected float m_density = 1000.0f; // in kg/m^3 | 335 | protected float m_gravitymod = 1.0f; |
309 | //protected float m_gravitymod = 1.0f; | 336 | protected float m_friction = 0.6f; // wood |
310 | //protected float m_friction = 0.6f; // wood | 337 | protected float m_bounce = 0.5f; // wood |
311 | //protected float m_bounce = 0.5f; // wood | 338 | |
312 | 339 | ||
340 | protected bool m_isSelected = false; | ||
341 | |||
313 | /// <summary> | 342 | /// <summary> |
314 | /// Stores media texture data | 343 | /// Stores media texture data |
315 | /// </summary> | 344 | /// </summary> |
@@ -321,10 +350,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
321 | private Vector3 m_cameraAtOffset; | 350 | private Vector3 m_cameraAtOffset; |
322 | private bool m_forceMouselook; | 351 | private bool m_forceMouselook; |
323 | 352 | ||
324 | // TODO: Collision sound should have default. | 353 | |
354 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
355 | private sbyte m_collisionSoundType; | ||
325 | private UUID m_collisionSound; | 356 | private UUID m_collisionSound; |
326 | private float m_collisionSoundVolume; | 357 | private float m_collisionSoundVolume; |
327 | 358 | ||
359 | private int LastColSoundSentTime; | ||
360 | |||
361 | |||
362 | private SOPVehicle m_vehicleParams = null; | ||
363 | |||
364 | private KeyframeMotion m_keyframeMotion = null; | ||
365 | |||
366 | public KeyframeMotion KeyframeMotion | ||
367 | { | ||
368 | get; set; | ||
369 | } | ||
370 | |||
371 | |||
328 | #endregion Fields | 372 | #endregion Fields |
329 | 373 | ||
330 | // ~SceneObjectPart() | 374 | // ~SceneObjectPart() |
@@ -354,6 +398,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
354 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 398 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
355 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log | 399 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log |
356 | m_inventory = new SceneObjectPartInventory(this); | 400 | m_inventory = new SceneObjectPartInventory(this); |
401 | LastColSoundSentTime = Util.EnvironmentTickCount(); | ||
357 | } | 402 | } |
358 | 403 | ||
359 | /// <summary> | 404 | /// <summary> |
@@ -368,7 +413,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
368 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, | 413 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, |
369 | Quaternion rotationOffset, Vector3 offsetPosition) : this() | 414 | Quaternion rotationOffset, Vector3 offsetPosition) : this() |
370 | { | 415 | { |
371 | m_name = "Primitive"; | 416 | m_name = "Object"; |
372 | 417 | ||
373 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); | 418 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); |
374 | LastOwnerID = CreatorID = OwnerID = ownerID; | 419 | LastOwnerID = CreatorID = OwnerID = ownerID; |
@@ -407,7 +452,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
407 | private uint _ownerMask = (uint)PermissionMask.All; | 452 | private uint _ownerMask = (uint)PermissionMask.All; |
408 | private uint _groupMask = (uint)PermissionMask.None; | 453 | private uint _groupMask = (uint)PermissionMask.None; |
409 | private uint _everyoneMask = (uint)PermissionMask.None; | 454 | private uint _everyoneMask = (uint)PermissionMask.None; |
410 | private uint _nextOwnerMask = (uint)PermissionMask.All; | 455 | private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); |
411 | private PrimFlags _flags = PrimFlags.None; | 456 | private PrimFlags _flags = PrimFlags.None; |
412 | private DateTime m_expires; | 457 | private DateTime m_expires; |
413 | private DateTime m_rezzed; | 458 | private DateTime m_rezzed; |
@@ -501,12 +546,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
501 | } | 546 | } |
502 | 547 | ||
503 | /// <value> | 548 | /// <value> |
504 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 549 | /// Get the inventory list |
505 | /// </value> | 550 | /// </value> |
506 | public TaskInventoryDictionary TaskInventory | 551 | public TaskInventoryDictionary TaskInventory |
507 | { | 552 | { |
508 | get { return m_inventory.Items; } | 553 | get { |
509 | set { m_inventory.Items = value; } | 554 | return m_inventory.Items; |
555 | } | ||
556 | set { | ||
557 | m_inventory.Items = value; | ||
558 | } | ||
510 | } | 559 | } |
511 | 560 | ||
512 | /// <summary> | 561 | /// <summary> |
@@ -556,20 +605,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
556 | } | 605 | } |
557 | } | 606 | } |
558 | 607 | ||
559 | public byte Material | ||
560 | { | ||
561 | get { return (byte) m_material; } | ||
562 | set | ||
563 | { | ||
564 | m_material = (Material)value; | ||
565 | |||
566 | PhysicsActor pa = PhysActor; | ||
567 | |||
568 | if (pa != null) | ||
569 | pa.SetMaterial((int)value); | ||
570 | } | ||
571 | } | ||
572 | |||
573 | [XmlIgnore] | 608 | [XmlIgnore] |
574 | public bool PassTouches | 609 | public bool PassTouches |
575 | { | 610 | { |
@@ -595,6 +630,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
595 | } | 630 | } |
596 | } | 631 | } |
597 | 632 | ||
633 | public bool IsSelected | ||
634 | { | ||
635 | get { return m_isSelected; } | ||
636 | set | ||
637 | { | ||
638 | m_isSelected = value; | ||
639 | if (ParentGroup != null) | ||
640 | ParentGroup.PartSelectChanged(value); | ||
641 | } | ||
642 | } | ||
643 | |||
644 | |||
598 | public Dictionary<int, string> CollisionFilter | 645 | public Dictionary<int, string> CollisionFilter |
599 | { | 646 | { |
600 | get { return m_CollisionFilter; } | 647 | get { return m_CollisionFilter; } |
@@ -663,14 +710,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
663 | set { m_LoopSoundSlavePrims = value; } | 710 | set { m_LoopSoundSlavePrims = value; } |
664 | } | 711 | } |
665 | 712 | ||
666 | |||
667 | public Byte[] TextureAnimation | 713 | public Byte[] TextureAnimation |
668 | { | 714 | { |
669 | get { return m_TextureAnimation; } | 715 | get { return m_TextureAnimation; } |
670 | set { m_TextureAnimation = value; } | 716 | set { m_TextureAnimation = value; } |
671 | } | 717 | } |
672 | 718 | ||
673 | |||
674 | public Byte[] ParticleSystem | 719 | public Byte[] ParticleSystem |
675 | { | 720 | { |
676 | get { return m_particleSystem; } | 721 | get { return m_particleSystem; } |
@@ -707,9 +752,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
707 | { | 752 | { |
708 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 753 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
709 | PhysicsActor actor = PhysActor; | 754 | PhysicsActor actor = PhysActor; |
710 | // If physical and the root prim of a linkset, the position of the group is what physics thinks. | 755 | if (ParentID == 0) |
711 | if (actor != null && ParentID == 0) | 756 | { |
712 | m_groupPosition = actor.Position; | 757 | if (actor != null) |
758 | m_groupPosition = actor.Position; | ||
759 | return m_groupPosition; | ||
760 | } | ||
713 | 761 | ||
714 | // If I'm an attachment, my position is reported as the position of who I'm attached to | 762 | // If I'm an attachment, my position is reported as the position of who I'm attached to |
715 | if (ParentGroup.IsAttachment) | 763 | if (ParentGroup.IsAttachment) |
@@ -719,14 +767,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
719 | return sp.AbsolutePosition; | 767 | return sp.AbsolutePosition; |
720 | } | 768 | } |
721 | 769 | ||
770 | // use root prim's group position. Physics may have updated it | ||
771 | if (ParentGroup.RootPart != this) | ||
772 | m_groupPosition = ParentGroup.RootPart.GroupPosition; | ||
722 | return m_groupPosition; | 773 | return m_groupPosition; |
723 | } | 774 | } |
724 | set | 775 | set |
725 | { | 776 | { |
726 | m_groupPosition = value; | 777 | m_groupPosition = value; |
727 | |||
728 | PhysicsActor actor = PhysActor; | 778 | PhysicsActor actor = PhysActor; |
729 | if (actor != null) | 779 | if (actor != null && ParentGroup.Scene.PhysicsScene != null) |
730 | { | 780 | { |
731 | try | 781 | try |
732 | { | 782 | { |
@@ -750,16 +800,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
750 | m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e); | 800 | m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e); |
751 | } | 801 | } |
752 | } | 802 | } |
753 | |||
754 | // TODO if we decide to do sitting in a more SL compatible way (multiple avatars per prim), this has to be fixed, too | ||
755 | if (SitTargetAvatar != UUID.Zero) | ||
756 | { | ||
757 | ScenePresence avatar; | ||
758 | if (ParentGroup.Scene.TryGetScenePresence(SitTargetAvatar, out avatar)) | ||
759 | { | ||
760 | avatar.ParentPosition = GetWorldPosition(); | ||
761 | } | ||
762 | } | ||
763 | } | 803 | } |
764 | } | 804 | } |
765 | 805 | ||
@@ -768,7 +808,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
768 | get { return m_offsetPosition; } | 808 | get { return m_offsetPosition; } |
769 | set | 809 | set |
770 | { | 810 | { |
771 | // StoreUndoState(); | 811 | Vector3 oldpos = m_offsetPosition; |
772 | m_offsetPosition = value; | 812 | m_offsetPosition = value; |
773 | 813 | ||
774 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 814 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
@@ -780,10 +820,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
780 | actor.Orientation = GetWorldRotation(); | 820 | actor.Orientation = GetWorldRotation(); |
781 | 821 | ||
782 | // Tell the physics engines that this prim changed. | 822 | // Tell the physics engines that this prim changed. |
783 | if (ParentGroup.Scene != null) | 823 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene != null) |
784 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 824 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
785 | } | 825 | } |
826 | |||
827 | if (!m_parentGroup.m_dupeInProgress) | ||
828 | { | ||
829 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); | ||
830 | foreach (ScenePresence av in avs) | ||
831 | { | ||
832 | if (av.ParentID == m_localId) | ||
833 | { | ||
834 | Vector3 offset = (m_offsetPosition - oldpos); | ||
835 | av.AbsolutePosition += offset; | ||
836 | av.SendAvatarDataToAllAgents(); | ||
837 | } | ||
838 | } | ||
839 | } | ||
786 | } | 840 | } |
841 | TriggerScriptChangedEvent(Changed.POSITION); | ||
787 | } | 842 | } |
788 | } | 843 | } |
789 | 844 | ||
@@ -834,7 +889,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
834 | 889 | ||
835 | set | 890 | set |
836 | { | 891 | { |
837 | StoreUndoState(); | 892 | // StoreUndoState(); |
838 | m_rotationOffset = value; | 893 | m_rotationOffset = value; |
839 | 894 | ||
840 | PhysicsActor actor = PhysActor; | 895 | PhysicsActor actor = PhysActor; |
@@ -922,19 +977,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
922 | get | 977 | get |
923 | { | 978 | { |
924 | PhysicsActor actor = PhysActor; | 979 | PhysicsActor actor = PhysActor; |
925 | if ((actor != null) && actor.IsPhysical) | 980 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this) |
926 | { | 981 | { |
927 | m_angularVelocity = actor.RotationalVelocity; | 982 | m_angularVelocity = actor.RotationalVelocity; |
928 | } | 983 | } |
929 | return m_angularVelocity; | 984 | return m_angularVelocity; |
930 | } | 985 | } |
931 | set { m_angularVelocity = value; } | 986 | set |
987 | { | ||
988 | m_angularVelocity = value; | ||
989 | PhysicsActor actor = PhysActor; | ||
990 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this && VehicleType == (int)Vehicle.TYPE_NONE) | ||
991 | { | ||
992 | actor.RotationalVelocity = m_angularVelocity; | ||
993 | } | ||
994 | } | ||
932 | } | 995 | } |
933 | 996 | ||
934 | /// <summary></summary> | 997 | /// <summary></summary> |
935 | public Vector3 Acceleration | 998 | public Vector3 Acceleration |
936 | { | 999 | { |
937 | get { return m_acceleration; } | 1000 | get |
1001 | { | ||
1002 | PhysicsActor actor = PhysActor; | ||
1003 | if (actor != null) | ||
1004 | { | ||
1005 | m_acceleration = actor.Acceleration; | ||
1006 | } | ||
1007 | return m_acceleration; | ||
1008 | } | ||
1009 | |||
938 | set { m_acceleration = value; } | 1010 | set { m_acceleration = value; } |
939 | } | 1011 | } |
940 | 1012 | ||
@@ -1002,7 +1074,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1002 | public PrimitiveBaseShape Shape | 1074 | public PrimitiveBaseShape Shape |
1003 | { | 1075 | { |
1004 | get { return m_shape; } | 1076 | get { return m_shape; } |
1005 | set { m_shape = value;} | 1077 | set |
1078 | { | ||
1079 | m_shape = value; | ||
1080 | } | ||
1006 | } | 1081 | } |
1007 | 1082 | ||
1008 | /// <summary> | 1083 | /// <summary> |
@@ -1015,7 +1090,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1015 | { | 1090 | { |
1016 | if (m_shape != null) | 1091 | if (m_shape != null) |
1017 | { | 1092 | { |
1018 | StoreUndoState(); | ||
1019 | 1093 | ||
1020 | m_shape.Scale = value; | 1094 | m_shape.Scale = value; |
1021 | 1095 | ||
@@ -1042,6 +1116,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1042 | } | 1116 | } |
1043 | 1117 | ||
1044 | public UpdateRequired UpdateFlag { get; set; } | 1118 | public UpdateRequired UpdateFlag { get; set; } |
1119 | public bool UpdatePhysRequired { get; set; } | ||
1045 | 1120 | ||
1046 | /// <summary> | 1121 | /// <summary> |
1047 | /// Used for media on a prim. | 1122 | /// Used for media on a prim. |
@@ -1082,10 +1157,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1082 | { | 1157 | { |
1083 | get | 1158 | get |
1084 | { | 1159 | { |
1085 | if (ParentGroup.IsAttachment) | 1160 | return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); |
1086 | return GroupPosition; | ||
1087 | |||
1088 | return m_offsetPosition + m_groupPosition; | ||
1089 | } | 1161 | } |
1090 | } | 1162 | } |
1091 | 1163 | ||
@@ -1263,6 +1335,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1263 | _flags = value; | 1335 | _flags = value; |
1264 | } | 1336 | } |
1265 | } | 1337 | } |
1338 | |||
1339 | [XmlIgnore] | ||
1340 | public bool IsOccupied // KF If an av is sittingon this prim | ||
1341 | { | ||
1342 | get { return m_occupied; } | ||
1343 | set { m_occupied = value; } | ||
1344 | } | ||
1266 | 1345 | ||
1267 | /// <summary> | 1346 | /// <summary> |
1268 | /// 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 | 1347 | /// 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 |
@@ -1313,12 +1392,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1313 | set { m_sitAnimation = value; } | 1392 | set { m_sitAnimation = value; } |
1314 | } | 1393 | } |
1315 | 1394 | ||
1395 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); | ||
1396 | |||
1397 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
1398 | // runtime thing.. do not persist | ||
1399 | [XmlIgnore] | ||
1400 | public sbyte CollisionSoundType | ||
1401 | { | ||
1402 | get | ||
1403 | { | ||
1404 | return m_collisionSoundType; | ||
1405 | } | ||
1406 | set | ||
1407 | { | ||
1408 | m_collisionSoundType = value; | ||
1409 | if (value == -1) | ||
1410 | m_collisionSound = invalidCollisionSoundUUID; | ||
1411 | else if (value == 0) | ||
1412 | m_collisionSound = UUID.Zero; | ||
1413 | } | ||
1414 | } | ||
1415 | |||
1316 | public UUID CollisionSound | 1416 | public UUID CollisionSound |
1317 | { | 1417 | { |
1318 | get { return m_collisionSound; } | 1418 | get { return m_collisionSound; } |
1319 | set | 1419 | set |
1320 | { | 1420 | { |
1321 | m_collisionSound = value; | 1421 | m_collisionSound = value; |
1422 | |||
1423 | if (value == invalidCollisionSoundUUID) | ||
1424 | m_collisionSoundType = -1; | ||
1425 | else if (value == UUID.Zero) | ||
1426 | m_collisionSoundType = 0; | ||
1427 | else | ||
1428 | m_collisionSoundType = 1; | ||
1429 | |||
1322 | aggregateScriptEvents(); | 1430 | aggregateScriptEvents(); |
1323 | } | 1431 | } |
1324 | } | 1432 | } |
@@ -1329,6 +1437,125 @@ namespace OpenSim.Region.Framework.Scenes | |||
1329 | set { m_collisionSoundVolume = value; } | 1437 | set { m_collisionSoundVolume = value; } |
1330 | } | 1438 | } |
1331 | 1439 | ||
1440 | public float Buoyancy | ||
1441 | { | ||
1442 | get | ||
1443 | { | ||
1444 | if (ParentGroup.RootPart == this) | ||
1445 | return m_buoyancy; | ||
1446 | |||
1447 | return ParentGroup.RootPart.Buoyancy; | ||
1448 | } | ||
1449 | set | ||
1450 | { | ||
1451 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1452 | { | ||
1453 | ParentGroup.RootPart.Buoyancy = value; | ||
1454 | return; | ||
1455 | } | ||
1456 | m_buoyancy = value; | ||
1457 | if (PhysActor != null) | ||
1458 | PhysActor.Buoyancy = value; | ||
1459 | } | ||
1460 | } | ||
1461 | |||
1462 | public Vector3 Force | ||
1463 | { | ||
1464 | get | ||
1465 | { | ||
1466 | if (ParentGroup.RootPart == this) | ||
1467 | return m_force; | ||
1468 | |||
1469 | return ParentGroup.RootPart.Force; | ||
1470 | } | ||
1471 | |||
1472 | set | ||
1473 | { | ||
1474 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1475 | { | ||
1476 | ParentGroup.RootPart.Force = value; | ||
1477 | return; | ||
1478 | } | ||
1479 | m_force = value; | ||
1480 | if (PhysActor != null) | ||
1481 | PhysActor.Force = value; | ||
1482 | } | ||
1483 | } | ||
1484 | |||
1485 | public Vector3 Torque | ||
1486 | { | ||
1487 | get | ||
1488 | { | ||
1489 | if (ParentGroup.RootPart == this) | ||
1490 | return m_torque; | ||
1491 | |||
1492 | return ParentGroup.RootPart.Torque; | ||
1493 | } | ||
1494 | |||
1495 | set | ||
1496 | { | ||
1497 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1498 | { | ||
1499 | ParentGroup.RootPart.Torque = value; | ||
1500 | return; | ||
1501 | } | ||
1502 | m_torque = value; | ||
1503 | if (PhysActor != null) | ||
1504 | PhysActor.Torque = value; | ||
1505 | } | ||
1506 | } | ||
1507 | |||
1508 | public byte Material | ||
1509 | { | ||
1510 | get { return (byte)m_material; } | ||
1511 | set | ||
1512 | { | ||
1513 | if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial) | ||
1514 | { | ||
1515 | bool update = false; | ||
1516 | |||
1517 | if (m_material != (Material)value) | ||
1518 | { | ||
1519 | update = true; | ||
1520 | m_material = (Material)value; | ||
1521 | } | ||
1522 | |||
1523 | if (m_friction != SOPMaterialData.friction(m_material)) | ||
1524 | { | ||
1525 | update = true; | ||
1526 | m_friction = SOPMaterialData.friction(m_material); | ||
1527 | } | ||
1528 | |||
1529 | if (m_bounce != SOPMaterialData.bounce(m_material)) | ||
1530 | { | ||
1531 | update = true; | ||
1532 | m_bounce = SOPMaterialData.bounce(m_material); | ||
1533 | } | ||
1534 | |||
1535 | if (update) | ||
1536 | { | ||
1537 | if (PhysActor != null) | ||
1538 | { | ||
1539 | PhysActor.SetMaterial((int)value); | ||
1540 | } | ||
1541 | if(ParentGroup != null) | ||
1542 | ParentGroup.HasGroupChanged = true; | ||
1543 | ScheduleFullUpdateIfNone(); | ||
1544 | UpdatePhysRequired = true; | ||
1545 | } | ||
1546 | } | ||
1547 | } | ||
1548 | } | ||
1549 | |||
1550 | // not a propriety to move to methods place later | ||
1551 | private bool HasMesh() | ||
1552 | { | ||
1553 | if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) | ||
1554 | return true; | ||
1555 | return false; | ||
1556 | } | ||
1557 | |||
1558 | // not a propriety to move to methods place later | ||
1332 | public byte DefaultPhysicsShapeType() | 1559 | public byte DefaultPhysicsShapeType() |
1333 | { | 1560 | { |
1334 | byte type; | 1561 | byte type; |
@@ -1341,6 +1568,65 @@ namespace OpenSim.Region.Framework.Scenes | |||
1341 | return type; | 1568 | return type; |
1342 | } | 1569 | } |
1343 | 1570 | ||
1571 | [XmlIgnore] | ||
1572 | public bool UsesComplexCost | ||
1573 | { | ||
1574 | get | ||
1575 | { | ||
1576 | byte pst = PhysicsShapeType; | ||
1577 | if(pst == (byte) PhysShapeType.none || pst == (byte) PhysShapeType.convex || HasMesh()) | ||
1578 | return true; | ||
1579 | return false; | ||
1580 | } | ||
1581 | } | ||
1582 | |||
1583 | [XmlIgnore] | ||
1584 | public float PhysicsCost | ||
1585 | { | ||
1586 | get | ||
1587 | { | ||
1588 | if(PhysicsShapeType == (byte)PhysShapeType.none) | ||
1589 | return 0; | ||
1590 | |||
1591 | float cost = 0.1f; | ||
1592 | if (PhysActor != null) | ||
1593 | cost = PhysActor.PhysicsCost; | ||
1594 | else | ||
1595 | cost = 0.1f; | ||
1596 | |||
1597 | if ((Flags & PrimFlags.Physics) != 0) | ||
1598 | cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 | ||
1599 | return cost; | ||
1600 | } | ||
1601 | } | ||
1602 | |||
1603 | [XmlIgnore] | ||
1604 | public float StreamingCost | ||
1605 | { | ||
1606 | get | ||
1607 | { | ||
1608 | float cost; | ||
1609 | if (PhysActor != null) | ||
1610 | cost = PhysActor.StreamCost; | ||
1611 | else | ||
1612 | cost = 1.0f; | ||
1613 | return 1.0f; | ||
1614 | } | ||
1615 | } | ||
1616 | |||
1617 | [XmlIgnore] | ||
1618 | public float SimulationCost | ||
1619 | { | ||
1620 | get | ||
1621 | { | ||
1622 | // ignoring scripts. Don't like considering them for this | ||
1623 | if((Flags & PrimFlags.Physics) != 0) | ||
1624 | return 1.0f; | ||
1625 | |||
1626 | return 0.5f; | ||
1627 | } | ||
1628 | } | ||
1629 | |||
1344 | public byte PhysicsShapeType | 1630 | public byte PhysicsShapeType |
1345 | { | 1631 | { |
1346 | get { return m_physicsShapeType; } | 1632 | get { return m_physicsShapeType; } |
@@ -1374,23 +1660,100 @@ namespace OpenSim.Region.Framework.Scenes | |||
1374 | } | 1660 | } |
1375 | else if (PhysActor == null) | 1661 | else if (PhysActor == null) |
1376 | { | 1662 | { |
1377 | ApplyPhysics((uint)Flags, VolumeDetectActive); | 1663 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); |
1664 | UpdatePhysicsSubscribedEvents(); | ||
1378 | } | 1665 | } |
1379 | else | 1666 | else |
1380 | { | 1667 | { |
1381 | // TODO: Update physics actor | 1668 | PhysActor.PhysicsShapeType = m_physicsShapeType; |
1669 | // if (Shape.SculptEntry) | ||
1670 | // CheckSculptAndLoad(); | ||
1382 | } | 1671 | } |
1383 | 1672 | ||
1384 | if (ParentGroup != null) | 1673 | if (ParentGroup != null) |
1385 | ParentGroup.HasGroupChanged = true; | 1674 | ParentGroup.HasGroupChanged = true; |
1386 | } | 1675 | } |
1676 | |||
1677 | if (m_physicsShapeType != value) | ||
1678 | { | ||
1679 | UpdatePhysRequired = true; | ||
1680 | } | ||
1681 | } | ||
1682 | } | ||
1683 | |||
1684 | public float Density // in kg/m^3 | ||
1685 | { | ||
1686 | get { return m_density; } | ||
1687 | set | ||
1688 | { | ||
1689 | if (value >=1 && value <= 22587.0) | ||
1690 | { | ||
1691 | m_density = value; | ||
1692 | UpdatePhysRequired = true; | ||
1693 | } | ||
1694 | |||
1695 | ScheduleFullUpdateIfNone(); | ||
1696 | |||
1697 | if (ParentGroup != null) | ||
1698 | ParentGroup.HasGroupChanged = true; | ||
1699 | } | ||
1700 | } | ||
1701 | |||
1702 | public float GravityModifier | ||
1703 | { | ||
1704 | get { return m_gravitymod; } | ||
1705 | set | ||
1706 | { | ||
1707 | if( value >= -1 && value <=28.0f) | ||
1708 | { | ||
1709 | m_gravitymod = value; | ||
1710 | UpdatePhysRequired = true; | ||
1711 | } | ||
1712 | |||
1713 | ScheduleFullUpdateIfNone(); | ||
1714 | |||
1715 | if (ParentGroup != null) | ||
1716 | ParentGroup.HasGroupChanged = true; | ||
1717 | |||
1718 | } | ||
1719 | } | ||
1720 | |||
1721 | public float Friction | ||
1722 | { | ||
1723 | get { return m_friction; } | ||
1724 | set | ||
1725 | { | ||
1726 | if (value >= 0 && value <= 255.0f) | ||
1727 | { | ||
1728 | m_friction = value; | ||
1729 | UpdatePhysRequired = true; | ||
1730 | } | ||
1731 | |||
1732 | ScheduleFullUpdateIfNone(); | ||
1733 | |||
1734 | if (ParentGroup != null) | ||
1735 | ParentGroup.HasGroupChanged = true; | ||
1736 | } | ||
1737 | } | ||
1738 | |||
1739 | public float Restitution | ||
1740 | { | ||
1741 | get { return m_bounce; } | ||
1742 | set | ||
1743 | { | ||
1744 | if (value >= 0 && value <= 1.0f) | ||
1745 | { | ||
1746 | m_bounce = value; | ||
1747 | UpdatePhysRequired = true; | ||
1748 | } | ||
1749 | |||
1750 | ScheduleFullUpdateIfNone(); | ||
1751 | |||
1752 | if (ParentGroup != null) | ||
1753 | ParentGroup.HasGroupChanged = true; | ||
1387 | } | 1754 | } |
1388 | } | 1755 | } |
1389 | 1756 | ||
1390 | public float Density { get; set; } | ||
1391 | public float GravityModifier { get; set; } | ||
1392 | public float Friction { get; set; } | ||
1393 | public float Restitution { get; set; } | ||
1394 | 1757 | ||
1395 | #endregion Public Properties with only Get | 1758 | #endregion Public Properties with only Get |
1396 | 1759 | ||
@@ -1537,6 +1900,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1537 | } | 1900 | } |
1538 | } | 1901 | } |
1539 | 1902 | ||
1903 | // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future | ||
1904 | public void SetVelocity(Vector3 pVel, bool localGlobalTF) | ||
1905 | { | ||
1906 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
1907 | return; | ||
1908 | |||
1909 | if (ParentGroup.IsAttachment) | ||
1910 | return; // don't work on attachments (for now ??) | ||
1911 | |||
1912 | SceneObjectPart root = ParentGroup.RootPart; | ||
1913 | |||
1914 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
1915 | return; | ||
1916 | |||
1917 | PhysicsActor pa = root.PhysActor; | ||
1918 | |||
1919 | if (pa == null || !pa.IsPhysical) | ||
1920 | return; | ||
1921 | |||
1922 | if (localGlobalTF) | ||
1923 | { | ||
1924 | pVel = pVel * GetWorldRotation(); | ||
1925 | } | ||
1926 | |||
1927 | ParentGroup.Velocity = pVel; | ||
1928 | } | ||
1929 | |||
1930 | // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future | ||
1931 | public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF) | ||
1932 | { | ||
1933 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
1934 | return; | ||
1935 | |||
1936 | if (ParentGroup.IsAttachment) | ||
1937 | return; // don't work on attachments (for now ??) | ||
1938 | |||
1939 | SceneObjectPart root = ParentGroup.RootPart; | ||
1940 | |||
1941 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
1942 | return; | ||
1943 | |||
1944 | PhysicsActor pa = root.PhysActor; | ||
1945 | |||
1946 | if (pa == null || !pa.IsPhysical) | ||
1947 | return; | ||
1948 | |||
1949 | if (localGlobalTF) | ||
1950 | { | ||
1951 | pAngVel = pAngVel * GetWorldRotation(); | ||
1952 | } | ||
1953 | |||
1954 | root.AngularVelocity = pAngVel; | ||
1955 | } | ||
1956 | |||
1957 | |||
1540 | /// <summary> | 1958 | /// <summary> |
1541 | /// hook to the physics scene to apply angular impulse | 1959 | /// hook to the physics scene to apply angular impulse |
1542 | /// This is sent up to the group, which then finds the root prim | 1960 | /// This is sent up to the group, which then finds the root prim |
@@ -1557,7 +1975,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1557 | impulse = newimpulse; | 1975 | impulse = newimpulse; |
1558 | } | 1976 | } |
1559 | 1977 | ||
1560 | ParentGroup.applyAngularImpulse(impulse); | 1978 | ParentGroup.ApplyAngularImpulse(impulse); |
1561 | } | 1979 | } |
1562 | 1980 | ||
1563 | /// <summary> | 1981 | /// <summary> |
@@ -1567,20 +1985,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1567 | /// </summary> | 1985 | /// </summary> |
1568 | /// <param name="impulsei">Vector force</param> | 1986 | /// <param name="impulsei">Vector force</param> |
1569 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | 1987 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> |
1570 | public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) | 1988 | |
1989 | // this is actualy Set Torque.. keeping naming so not to edit lslapi also | ||
1990 | public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF) | ||
1571 | { | 1991 | { |
1572 | Vector3 impulse = impulsei; | 1992 | Vector3 torque = torquei; |
1573 | 1993 | ||
1574 | if (localGlobalTF) | 1994 | if (localGlobalTF) |
1575 | { | 1995 | { |
1996 | /* | ||
1576 | Quaternion grot = GetWorldRotation(); | 1997 | Quaternion grot = GetWorldRotation(); |
1577 | Quaternion AXgrot = grot; | 1998 | Quaternion AXgrot = grot; |
1578 | Vector3 AXimpulsei = impulsei; | 1999 | Vector3 AXimpulsei = impulsei; |
1579 | Vector3 newimpulse = AXimpulsei * AXgrot; | 2000 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1580 | impulse = newimpulse; | 2001 | */ |
2002 | torque *= GetWorldRotation(); | ||
1581 | } | 2003 | } |
1582 | 2004 | ||
1583 | ParentGroup.setAngularImpulse(impulse); | 2005 | Torque = torque; |
1584 | } | 2006 | } |
1585 | 2007 | ||
1586 | /// <summary> | 2008 | /// <summary> |
@@ -1588,16 +2010,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
1588 | /// </summary> | 2010 | /// </summary> |
1589 | /// <param name="rootObjectFlags"></param> | 2011 | /// <param name="rootObjectFlags"></param> |
1590 | /// <param name="VolumeDetectActive"></param> | 2012 | /// <param name="VolumeDetectActive"></param> |
1591 | public void ApplyPhysics(uint rootObjectFlags, bool VolumeDetectActive) | 2013 | /// <param name="building"></param> |
2014 | |||
2015 | public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building) | ||
1592 | { | 2016 | { |
2017 | VolumeDetectActive = _VolumeDetectActive; | ||
2018 | |||
1593 | if (!ParentGroup.Scene.CollidablePrims) | 2019 | if (!ParentGroup.Scene.CollidablePrims) |
1594 | return; | 2020 | return; |
1595 | 2021 | ||
1596 | if (PhysicsShapeType == (byte)PhysShapeType.none) | 2022 | if (PhysicsShapeType == (byte)PhysShapeType.none) |
1597 | return; | 2023 | return; |
1598 | 2024 | ||
1599 | bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; | 2025 | bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0; |
1600 | bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; | 2026 | bool isPhantom = (_ObjectFlags & (uint)PrimFlags.Phantom) != 0; |
2027 | |||
2028 | if (_VolumeDetectActive) | ||
2029 | isPhantom = true; | ||
1601 | 2030 | ||
1602 | if (IsJoint()) | 2031 | if (IsJoint()) |
1603 | { | 2032 | { |
@@ -1605,22 +2034,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1605 | } | 2034 | } |
1606 | else | 2035 | else |
1607 | { | 2036 | { |
1608 | // Special case for VolumeDetection: If VolumeDetection is set, the phantom flag is locally ignored | 2037 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment |
1609 | if (VolumeDetectActive) | 2038 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) |
1610 | isPhantom = false; | ||
1611 | |||
1612 | // The only time the physics scene shouldn't know about the prim is if it's phantom or an attachment, which is phantom by definition | ||
1613 | // or flexible | ||
1614 | if (!isPhantom && !ParentGroup.IsAttachment && !(Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
1615 | { | 2039 | { |
1616 | // Added clarification.. since A rigid body is an object that you can kick around, etc. | 2040 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); |
1617 | bool rigidBody = isPhysical && !isPhantom; | 2041 | UpdatePhysicsSubscribedEvents(); // not sure if appliable here |
1618 | |||
1619 | PhysicsActor pa = AddToPhysics(rigidBody); | ||
1620 | |||
1621 | if (pa != null) | ||
1622 | pa.SetVolumeDetect(VolumeDetectActive ? 1 : 0); | ||
1623 | } | 2042 | } |
2043 | else | ||
2044 | PhysActor = null; // just to be sure | ||
1624 | } | 2045 | } |
1625 | } | 2046 | } |
1626 | 2047 | ||
@@ -1672,6 +2093,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1672 | dupe.Category = Category; | 2093 | dupe.Category = Category; |
1673 | dupe.m_rezzed = m_rezzed; | 2094 | dupe.m_rezzed = m_rezzed; |
1674 | 2095 | ||
2096 | dupe.m_UndoRedo = null; | ||
2097 | dupe.m_isSelected = false; | ||
2098 | |||
2099 | dupe.IgnoreUndoUpdate = false; | ||
2100 | dupe.Undoing = false; | ||
2101 | |||
1675 | dupe.m_inventory = new SceneObjectPartInventory(dupe); | 2102 | dupe.m_inventory = new SceneObjectPartInventory(dupe); |
1676 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); | 2103 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); |
1677 | 2104 | ||
@@ -1687,6 +2114,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1687 | 2114 | ||
1688 | // Move afterwards ResetIDs as it clears the localID | 2115 | // Move afterwards ResetIDs as it clears the localID |
1689 | dupe.LocalId = localID; | 2116 | dupe.LocalId = localID; |
2117 | |||
1690 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. | 2118 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. |
1691 | dupe.LastOwnerID = OwnerID; | 2119 | dupe.LastOwnerID = OwnerID; |
1692 | 2120 | ||
@@ -1694,6 +2122,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1694 | Array.Copy(Shape.ExtraParams, extraP, extraP.Length); | 2122 | Array.Copy(Shape.ExtraParams, extraP, extraP.Length); |
1695 | dupe.Shape.ExtraParams = extraP; | 2123 | dupe.Shape.ExtraParams = extraP; |
1696 | 2124 | ||
2125 | // safeguard actual copy is done in sog.copy | ||
2126 | dupe.KeyframeMotion = null; | ||
2127 | |||
1697 | dupe.DynAttrs.CopyFrom(DynAttrs); | 2128 | dupe.DynAttrs.CopyFrom(DynAttrs); |
1698 | 2129 | ||
1699 | if (userExposed) | 2130 | if (userExposed) |
@@ -1707,8 +2138,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1707 | */ | 2138 | */ |
1708 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); | 2139 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); |
1709 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); | 2140 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); |
2141 | // dupe.UpdatePhysicsSubscribedEvents(); // not sure... | ||
1710 | } | 2142 | } |
1711 | 2143 | ||
2144 | if (dupe.PhysActor != null) | ||
2145 | dupe.PhysActor.LocalID = localID; | ||
2146 | |||
1712 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); | 2147 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); |
1713 | 2148 | ||
1714 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); | 2149 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); |
@@ -1727,10 +2162,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1727 | { | 2162 | { |
1728 | if (asset != null) | 2163 | if (asset != null) |
1729 | SculptTextureCallback(asset); | 2164 | SculptTextureCallback(asset); |
1730 | else | 2165 | // else |
1731 | m_log.WarnFormat( | 2166 | // m_log.WarnFormat( |
1732 | "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", | 2167 | // "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", |
1733 | Name, UUID, id); | 2168 | // Name, UUID, id); |
1734 | } | 2169 | } |
1735 | */ | 2170 | */ |
1736 | /// <summary> | 2171 | /// <summary> |
@@ -1829,6 +2264,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1829 | 2264 | ||
1830 | /// <summary> | 2265 | /// <summary> |
1831 | /// Do a physics propery update for this part. | 2266 | /// Do a physics propery update for this part. |
2267 | /// now also updates phantom and volume detector | ||
1832 | /// </summary> | 2268 | /// </summary> |
1833 | /// <param name="UsePhysics"></param> | 2269 | /// <param name="UsePhysics"></param> |
1834 | /// <param name="isNew"></param> | 2270 | /// <param name="isNew"></param> |
@@ -1854,61 +2290,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
1854 | { | 2290 | { |
1855 | if (pa.IsPhysical) // implies UsePhysics==false for this block | 2291 | if (pa.IsPhysical) // implies UsePhysics==false for this block |
1856 | { | 2292 | { |
1857 | if (!isNew) | 2293 | if (!isNew) // implies UsePhysics==false for this block |
2294 | { | ||
1858 | ParentGroup.Scene.RemovePhysicalPrim(1); | 2295 | ParentGroup.Scene.RemovePhysicalPrim(1); |
1859 | 2296 | ||
1860 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | 2297 | Velocity = new Vector3(0, 0, 0); |
1861 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | 2298 | Acceleration = new Vector3(0, 0, 0); |
1862 | pa.delink(); | 2299 | if (ParentGroup.RootPart == this) |
2300 | AngularVelocity = new Vector3(0, 0, 0); | ||
1863 | 2301 | ||
1864 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) | 2302 | if (pa.Phantom && !VolumeDetectActive) |
1865 | { | 2303 | { |
1866 | // destroy all joints connected to this now deactivated body | 2304 | RemoveFromPhysics(); |
1867 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | 2305 | return; |
1868 | } | 2306 | } |
1869 | 2307 | ||
1870 | // stop client-side interpolation of all joint proxy objects that have just been deleted | 2308 | pa.IsPhysical = UsePhysics; |
1871 | // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback, | 2309 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; |
1872 | // which stops client-side interpolation of deactivated joint proxy objects. | 2310 | pa.OnOutOfBounds -= PhysicsOutOfBounds; |
2311 | pa.delink(); | ||
2312 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | ||
2313 | { | ||
2314 | // destroy all joints connected to this now deactivated body | ||
2315 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | ||
2316 | } | ||
2317 | } | ||
1873 | } | 2318 | } |
1874 | 2319 | ||
1875 | if (!UsePhysics && !isNew) | 2320 | if (pa.IsPhysical != UsePhysics) |
1876 | { | 2321 | pa.IsPhysical = UsePhysics; |
1877 | // reset velocity to 0 on physics switch-off. Without that, the client thinks the | ||
1878 | // prim still has velocity and continues to interpolate its position along the old | ||
1879 | // velocity-vector. | ||
1880 | Velocity = new Vector3(0, 0, 0); | ||
1881 | Acceleration = new Vector3(0, 0, 0); | ||
1882 | AngularVelocity = new Vector3(0, 0, 0); | ||
1883 | //RotationalVelocity = new Vector3(0, 0, 0); | ||
1884 | } | ||
1885 | 2322 | ||
1886 | pa.IsPhysical = UsePhysics; | 2323 | if (UsePhysics) |
2324 | { | ||
2325 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
2326 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2327 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2328 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
1887 | 2329 | ||
1888 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. | 2330 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
1889 | //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 2331 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; |
1890 | /// that's not wholesome. Had to make Scene public | ||
1891 | //PhysActor = null; | ||
1892 | 2332 | ||
1893 | if ((Flags & PrimFlags.Phantom) == 0) | 2333 | if (ParentID != 0 && ParentID != LocalId) |
1894 | { | ||
1895 | if (UsePhysics) | ||
1896 | { | 2334 | { |
1897 | ParentGroup.Scene.AddPhysicalPrim(1); | 2335 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; |
1898 | 2336 | ||
1899 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | 2337 | if (parentPa != null) |
1900 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
1901 | if (ParentID != 0 && ParentID != LocalId) | ||
1902 | { | 2338 | { |
1903 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | 2339 | pa.link(parentPa); |
1904 | |||
1905 | if (parentPa != null) | ||
1906 | { | ||
1907 | pa.link(parentPa); | ||
1908 | } | ||
1909 | } | 2340 | } |
1910 | } | 2341 | } |
1911 | } | 2342 | } |
2343 | } | ||
2344 | |||
2345 | bool phan = ((Flags & PrimFlags.Phantom) != 0); | ||
2346 | if (pa.Phantom != phan) | ||
2347 | pa.Phantom = phan; | ||
2348 | |||
2349 | // some engines dont' have this check still | ||
2350 | // if (VolumeDetectActive != pa.IsVolumeDtc) | ||
2351 | { | ||
2352 | if (VolumeDetectActive) | ||
2353 | pa.SetVolumeDetect(1); | ||
2354 | else | ||
2355 | pa.SetVolumeDetect(0); | ||
1912 | } | 2356 | } |
1913 | 2357 | ||
1914 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the | 2358 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the |
@@ -2027,42 +2471,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
2027 | 2471 | ||
2028 | public Vector3 GetGeometricCenter() | 2472 | public Vector3 GetGeometricCenter() |
2029 | { | 2473 | { |
2474 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
2475 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
2476 | // ignoring tortured prims details since sl also seems to ignore | ||
2477 | // so no real use in doing it on physics | ||
2478 | if (ParentGroup.IsDeleted) | ||
2479 | return new Vector3(0, 0, 0); | ||
2480 | |||
2481 | return ParentGroup.GetGeometricCenter(); | ||
2482 | } | ||
2483 | |||
2484 | public float GetMass() | ||
2485 | { | ||
2030 | PhysicsActor pa = PhysActor; | 2486 | PhysicsActor pa = PhysActor; |
2031 | 2487 | ||
2032 | if (pa != null) | 2488 | if (pa != null) |
2033 | return new Vector3(pa.GeometricCenter.X, pa.GeometricCenter.Y, pa.GeometricCenter.Z); | 2489 | return pa.Mass; |
2034 | else | 2490 | else |
2035 | return new Vector3(0, 0, 0); | 2491 | return 0; |
2036 | } | 2492 | } |
2037 | 2493 | ||
2038 | public Vector3 GetCenterOfMass() | 2494 | public Vector3 GetCenterOfMass() |
2039 | { | 2495 | { |
2496 | if (ParentGroup.RootPart == this) | ||
2497 | { | ||
2498 | if (ParentGroup.IsDeleted) | ||
2499 | return AbsolutePosition; | ||
2500 | return ParentGroup.GetCenterOfMass(); | ||
2501 | } | ||
2502 | |||
2040 | PhysicsActor pa = PhysActor; | 2503 | PhysicsActor pa = PhysActor; |
2041 | 2504 | ||
2042 | if (pa != null) | 2505 | if (pa != null) |
2043 | return new Vector3(pa.CenterOfMass.X, pa.CenterOfMass.Y, pa.CenterOfMass.Z); | 2506 | { |
2507 | Vector3 tmp = pa.CenterOfMass; | ||
2508 | return tmp; | ||
2509 | } | ||
2044 | else | 2510 | else |
2045 | return new Vector3(0, 0, 0); | 2511 | return AbsolutePosition; |
2046 | } | 2512 | } |
2047 | 2513 | ||
2048 | public float GetMass() | 2514 | public Vector3 GetPartCenterOfMass() |
2049 | { | 2515 | { |
2050 | PhysicsActor pa = PhysActor; | 2516 | PhysicsActor pa = PhysActor; |
2051 | 2517 | ||
2052 | if (pa != null) | 2518 | if (pa != null) |
2053 | return pa.Mass; | 2519 | { |
2520 | Vector3 tmp = pa.CenterOfMass; | ||
2521 | return tmp; | ||
2522 | } | ||
2054 | else | 2523 | else |
2055 | return 0; | 2524 | return AbsolutePosition; |
2056 | } | 2525 | } |
2057 | 2526 | ||
2527 | |||
2058 | public Vector3 GetForce() | 2528 | public Vector3 GetForce() |
2059 | { | 2529 | { |
2060 | PhysicsActor pa = PhysActor; | 2530 | return Force; |
2061 | |||
2062 | if (pa != null) | ||
2063 | return pa.Force; | ||
2064 | else | ||
2065 | return Vector3.Zero; | ||
2066 | } | 2531 | } |
2067 | 2532 | ||
2068 | /// <summary> | 2533 | /// <summary> |
@@ -2277,15 +2742,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2277 | 2742 | ||
2278 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) | 2743 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) |
2279 | { | 2744 | { |
2280 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) | 2745 | bool sendToRoot = true; |
2281 | { | 2746 | |
2282 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | 2747 | ColliderArgs LandCollidingMessage = new ColliderArgs(); |
2283 | List<DetectedObject> colliding = new List<DetectedObject>(); | 2748 | List<DetectedObject> colliding = new List<DetectedObject>(); |
2284 | 2749 | ||
2285 | colliding.Add(CreateDetObjectForGround()); | 2750 | colliding.Add(CreateDetObjectForGround()); |
2286 | LandCollidingMessage.Colliders = colliding; | 2751 | LandCollidingMessage.Colliders = colliding; |
2287 | 2752 | ||
2753 | if (Inventory.ContainsScripts()) | ||
2754 | { | ||
2755 | if (!PassCollisions) | ||
2756 | sendToRoot = false; | ||
2757 | } | ||
2758 | if ((ScriptEvents & ev) != 0) | ||
2288 | notify(LocalId, LandCollidingMessage); | 2759 | notify(LocalId, LandCollidingMessage); |
2760 | |||
2761 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot) | ||
2762 | { | ||
2763 | notify(ParentGroup.RootPart.LocalId, LandCollidingMessage); | ||
2289 | } | 2764 | } |
2290 | } | 2765 | } |
2291 | 2766 | ||
@@ -2301,57 +2776,120 @@ namespace OpenSim.Region.Framework.Scenes | |||
2301 | List<uint> endedColliders = new List<uint>(); | 2776 | List<uint> endedColliders = new List<uint>(); |
2302 | List<uint> startedColliders = new List<uint>(); | 2777 | List<uint> startedColliders = new List<uint>(); |
2303 | 2778 | ||
2304 | // calculate things that started colliding this time | 2779 | if (collissionswith.Count == 0) |
2305 | // and build up list of colliders this time | ||
2306 | foreach (uint localid in collissionswith.Keys) | ||
2307 | { | 2780 | { |
2308 | thisHitColliders.Add(localid); | 2781 | if (m_lastColliders.Count == 0) |
2309 | if (!m_lastColliders.Contains(localid)) | 2782 | return; // nothing to do |
2310 | startedColliders.Add(localid); | ||
2311 | } | ||
2312 | 2783 | ||
2313 | // calculate things that ended colliding | 2784 | foreach (uint localID in m_lastColliders) |
2314 | foreach (uint localID in m_lastColliders) | 2785 | { |
2315 | { | ||
2316 | if (!thisHitColliders.Contains(localID)) | ||
2317 | endedColliders.Add(localID); | 2786 | endedColliders.Add(localID); |
2787 | } | ||
2788 | m_lastColliders.Clear(); | ||
2318 | } | 2789 | } |
2319 | 2790 | ||
2320 | //add the items that started colliding this time to the last colliders list. | 2791 | else |
2321 | foreach (uint localID in startedColliders) | 2792 | { |
2322 | m_lastColliders.Add(localID); | 2793 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); |
2323 | 2794 | ||
2324 | // remove things that ended colliding from the last colliders list | 2795 | // calculate things that started colliding this time |
2325 | foreach (uint localID in endedColliders) | 2796 | // and build up list of colliders this time |
2326 | m_lastColliders.Remove(localID); | 2797 | if (!VolumeDetectActive && CollisionSoundType >= 0) |
2798 | { | ||
2799 | CollisionForSoundInfo soundinfo; | ||
2800 | ContactPoint curcontact; | ||
2327 | 2801 | ||
2328 | // play the sound. | 2802 | foreach (uint id in collissionswith.Keys) |
2329 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) | 2803 | { |
2330 | { | 2804 | thisHitColliders.Add(id); |
2331 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | 2805 | if (!m_lastColliders.Contains(id)) |
2332 | if (soundModule != null) | 2806 | { |
2807 | startedColliders.Add(id); | ||
2808 | |||
2809 | curcontact = collissionswith[id]; | ||
2810 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
2811 | { | ||
2812 | soundinfo = new CollisionForSoundInfo(); | ||
2813 | soundinfo.colliderID = id; | ||
2814 | soundinfo.position = curcontact.Position; | ||
2815 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2816 | soundinfolist.Add(soundinfo); | ||
2817 | } | ||
2818 | } | ||
2819 | } | ||
2820 | } | ||
2821 | else | ||
2333 | { | 2822 | { |
2334 | soundModule.SendSound(UUID, CollisionSound, | 2823 | foreach (uint id in collissionswith.Keys) |
2335 | CollisionSoundVolume, true, (byte)0, 0, false, | 2824 | { |
2336 | false); | 2825 | thisHitColliders.Add(id); |
2826 | if (!m_lastColliders.Contains(id)) | ||
2827 | startedColliders.Add(id); | ||
2828 | } | ||
2829 | } | ||
2830 | |||
2831 | // calculate things that ended colliding | ||
2832 | foreach (uint localID in m_lastColliders) | ||
2833 | { | ||
2834 | if (!thisHitColliders.Contains(localID)) | ||
2835 | endedColliders.Add(localID); | ||
2337 | } | 2836 | } |
2837 | |||
2838 | //add the items that started colliding this time to the last colliders list. | ||
2839 | foreach (uint localID in startedColliders) | ||
2840 | m_lastColliders.Add(localID); | ||
2841 | |||
2842 | // remove things that ended colliding from the last colliders list | ||
2843 | foreach (uint localID in endedColliders) | ||
2844 | m_lastColliders.Remove(localID); | ||
2845 | |||
2846 | // play sounds. | ||
2847 | if (soundinfolist.Count > 0) | ||
2848 | CollisionSounds.PartCollisionSound(this, soundinfolist); | ||
2338 | } | 2849 | } |
2339 | 2850 | ||
2340 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2851 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2341 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2852 | if (!VolumeDetectActive) |
2853 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | ||
2342 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2854 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2343 | 2855 | ||
2344 | if (startedColliders.Contains(0)) | 2856 | if (startedColliders.Contains(0)) |
2345 | { | 2857 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); |
2346 | if (m_lastColliders.Contains(0)) | 2858 | if (m_lastColliders.Contains(0)) |
2347 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); | 2859 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); |
2348 | else | ||
2349 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); | ||
2350 | } | ||
2351 | if (endedColliders.Contains(0)) | 2860 | if (endedColliders.Contains(0)) |
2352 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); | 2861 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); |
2353 | } | 2862 | } |
2354 | 2863 | ||
2864 | // The Collision sounds code calls this | ||
2865 | public void SendCollisionSound(UUID soundID, double volume, Vector3 position) | ||
2866 | { | ||
2867 | if (soundID == UUID.Zero) | ||
2868 | return; | ||
2869 | |||
2870 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | ||
2871 | if (soundModule == null) | ||
2872 | return; | ||
2873 | |||
2874 | if (volume > 1) | ||
2875 | volume = 1; | ||
2876 | if (volume < 0) | ||
2877 | volume = 0; | ||
2878 | |||
2879 | int now = Util.EnvironmentTickCount(); | ||
2880 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) | ||
2881 | return; | ||
2882 | |||
2883 | LastColSoundSentTime = now; | ||
2884 | |||
2885 | UUID ownerID = OwnerID; | ||
2886 | UUID objectID = ParentGroup.RootPart.UUID; | ||
2887 | UUID parentID = ParentGroup.UUID; | ||
2888 | ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; | ||
2889 | |||
2890 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 ); | ||
2891 | } | ||
2892 | |||
2355 | public void PhysicsOutOfBounds(Vector3 pos) | 2893 | public void PhysicsOutOfBounds(Vector3 pos) |
2356 | { | 2894 | { |
2357 | // Note: This is only being called on the root prim at this time. | 2895 | // Note: This is only being called on the root prim at this time. |
@@ -2373,9 +2911,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2373 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | 2911 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); |
2374 | 2912 | ||
2375 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) | 2913 | if (ParentGroup.Scene.TestBorderCross(newpos, Cardinals.N) |
2376 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) | 2914 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.S) |
2377 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) | 2915 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.E) |
2378 | | ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) | 2916 | || ParentGroup.Scene.TestBorderCross(newpos, Cardinals.W)) |
2379 | { | 2917 | { |
2380 | ParentGroup.AbsolutePosition = newpos; | 2918 | ParentGroup.AbsolutePosition = newpos; |
2381 | return; | 2919 | return; |
@@ -2502,6 +3040,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2502 | APIDTarget = Quaternion.Identity; | 3040 | APIDTarget = Quaternion.Identity; |
2503 | } | 3041 | } |
2504 | 3042 | ||
3043 | |||
3044 | |||
3045 | public void ScheduleFullUpdateIfNone() | ||
3046 | { | ||
3047 | if (ParentGroup == null) | ||
3048 | return; | ||
3049 | |||
3050 | // ??? ParentGroup.HasGroupChanged = true; | ||
3051 | |||
3052 | if (UpdateFlag != UpdateRequired.FULL) | ||
3053 | ScheduleFullUpdate(); | ||
3054 | } | ||
3055 | |||
2505 | /// <summary> | 3056 | /// <summary> |
2506 | /// Schedules this prim for a full update | 3057 | /// Schedules this prim for a full update |
2507 | /// </summary> | 3058 | /// </summary> |
@@ -2647,6 +3198,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2647 | if (ParentGroup == null) | 3198 | if (ParentGroup == null) |
2648 | return; | 3199 | return; |
2649 | 3200 | ||
3201 | // Update the "last" values | ||
3202 | m_lastPosition = OffsetPosition; | ||
3203 | m_lastRotation = RotationOffset; | ||
3204 | m_lastVelocity = Velocity; | ||
3205 | m_lastAcceleration = Acceleration; | ||
3206 | m_lastAngularVelocity = AngularVelocity; | ||
3207 | m_lastUpdateSentTime = Environment.TickCount; | ||
3208 | |||
2650 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 3209 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2651 | { | 3210 | { |
2652 | SendFullUpdate(avatar.ControllingClient); | 3211 | SendFullUpdate(avatar.ControllingClient); |
@@ -2705,8 +3264,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2705 | { | 3264 | { |
2706 | const float ROTATION_TOLERANCE = 0.01f; | 3265 | const float ROTATION_TOLERANCE = 0.01f; |
2707 | const float VELOCITY_TOLERANCE = 0.001f; | 3266 | const float VELOCITY_TOLERANCE = 0.001f; |
2708 | const float POSITION_TOLERANCE = 0.05f; | 3267 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
2709 | const int TIME_MS_TOLERANCE = 3000; | 3268 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
2710 | 3269 | ||
2711 | switch (UpdateFlag) | 3270 | switch (UpdateFlag) |
2712 | { | 3271 | { |
@@ -2720,17 +3279,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2720 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || | 3279 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || |
2721 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || | 3280 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || |
2722 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 3281 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
2723 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 3282 | Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) |
2724 | { | 3283 | { |
2725 | SendTerseUpdateToAllClients(); | 3284 | SendTerseUpdateToAllClients(); |
2726 | 3285 | ||
2727 | // Update the "last" values | ||
2728 | m_lastPosition = OffsetPosition; | ||
2729 | m_lastRotation = RotationOffset; | ||
2730 | m_lastVelocity = Velocity; | ||
2731 | m_lastAcceleration = Acceleration; | ||
2732 | m_lastAngularVelocity = AngularVelocity; | ||
2733 | m_lastTerseSent = Environment.TickCount; | ||
2734 | } | 3286 | } |
2735 | break; | 3287 | break; |
2736 | } | 3288 | } |
@@ -2748,6 +3300,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2748 | /// </summary> | 3300 | /// </summary> |
2749 | public void SendTerseUpdateToAllClients() | 3301 | public void SendTerseUpdateToAllClients() |
2750 | { | 3302 | { |
3303 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3304 | return; | ||
3305 | |||
3306 | // Update the "last" values | ||
3307 | m_lastPosition = OffsetPosition; | ||
3308 | m_lastRotation = RotationOffset; | ||
3309 | m_lastVelocity = Velocity; | ||
3310 | m_lastAcceleration = Acceleration; | ||
3311 | m_lastAngularVelocity = AngularVelocity; | ||
3312 | m_lastUpdateSentTime = Environment.TickCount; | ||
3313 | |||
2751 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | 3314 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) |
2752 | { | 3315 | { |
2753 | SendTerseUpdateToClient(client); | 3316 | SendTerseUpdateToClient(client); |
@@ -2771,10 +3334,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2771 | 3334 | ||
2772 | public void SetBuoyancy(float fvalue) | 3335 | public void SetBuoyancy(float fvalue) |
2773 | { | 3336 | { |
2774 | PhysicsActor pa = PhysActor; | 3337 | Buoyancy = fvalue; |
2775 | 3338 | /* | |
2776 | if (pa != null) | 3339 | if (PhysActor != null) |
2777 | pa.Buoyancy = fvalue; | 3340 | { |
3341 | PhysActor.Buoyancy = fvalue; | ||
3342 | } | ||
3343 | */ | ||
2778 | } | 3344 | } |
2779 | 3345 | ||
2780 | public void SetDieAtEdge(bool p) | 3346 | public void SetDieAtEdge(bool p) |
@@ -2790,47 +3356,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2790 | PhysicsActor pa = PhysActor; | 3356 | PhysicsActor pa = PhysActor; |
2791 | 3357 | ||
2792 | if (pa != null) | 3358 | if (pa != null) |
2793 | pa.FloatOnWater = floatYN == 1; | 3359 | pa.FloatOnWater = (floatYN == 1); |
2794 | } | 3360 | } |
2795 | 3361 | ||
2796 | public void SetForce(Vector3 force) | 3362 | public void SetForce(Vector3 force) |
2797 | { | 3363 | { |
2798 | PhysicsActor pa = PhysActor; | 3364 | Force = force; |
3365 | } | ||
2799 | 3366 | ||
2800 | if (pa != null) | 3367 | public SOPVehicle VehicleParams |
2801 | pa.Force = force; | 3368 | { |
3369 | get | ||
3370 | { | ||
3371 | return m_vehicleParams; | ||
3372 | } | ||
3373 | set | ||
3374 | { | ||
3375 | m_vehicleParams = value; | ||
3376 | } | ||
3377 | } | ||
3378 | |||
3379 | |||
3380 | public int VehicleType | ||
3381 | { | ||
3382 | get | ||
3383 | { | ||
3384 | if (m_vehicleParams == null) | ||
3385 | return (int)Vehicle.TYPE_NONE; | ||
3386 | else | ||
3387 | return (int)m_vehicleParams.Type; | ||
3388 | } | ||
3389 | set | ||
3390 | { | ||
3391 | SetVehicleType(value); | ||
3392 | } | ||
2802 | } | 3393 | } |
2803 | 3394 | ||
2804 | public void SetVehicleType(int type) | 3395 | public void SetVehicleType(int type) |
2805 | { | 3396 | { |
2806 | PhysicsActor pa = PhysActor; | 3397 | m_vehicleParams = null; |
3398 | |||
3399 | if (type == (int)Vehicle.TYPE_NONE) | ||
3400 | { | ||
3401 | if (_parentID ==0 && PhysActor != null) | ||
3402 | PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; | ||
3403 | return; | ||
3404 | } | ||
3405 | m_vehicleParams = new SOPVehicle(); | ||
3406 | m_vehicleParams.ProcessTypeChange((Vehicle)type); | ||
3407 | { | ||
3408 | if (_parentID ==0 && PhysActor != null) | ||
3409 | PhysActor.VehicleType = type; | ||
3410 | return; | ||
3411 | } | ||
3412 | } | ||
2807 | 3413 | ||
2808 | if (pa != null) | 3414 | public void SetVehicleFlags(int param, bool remove) |
2809 | pa.VehicleType = type; | 3415 | { |
3416 | if (m_vehicleParams == null) | ||
3417 | return; | ||
3418 | |||
3419 | m_vehicleParams.ProcessVehicleFlags(param, remove); | ||
3420 | |||
3421 | if (_parentID ==0 && PhysActor != null) | ||
3422 | { | ||
3423 | PhysActor.VehicleFlags(param, remove); | ||
3424 | } | ||
2810 | } | 3425 | } |
2811 | 3426 | ||
2812 | public void SetVehicleFloatParam(int param, float value) | 3427 | public void SetVehicleFloatParam(int param, float value) |
2813 | { | 3428 | { |
2814 | PhysicsActor pa = PhysActor; | 3429 | if (m_vehicleParams == null) |
3430 | return; | ||
2815 | 3431 | ||
2816 | if (pa != null) | 3432 | m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value); |
2817 | pa.VehicleFloatParam(param, value); | 3433 | |
3434 | if (_parentID == 0 && PhysActor != null) | ||
3435 | { | ||
3436 | PhysActor.VehicleFloatParam(param, value); | ||
3437 | } | ||
2818 | } | 3438 | } |
2819 | 3439 | ||
2820 | public void SetVehicleVectorParam(int param, Vector3 value) | 3440 | public void SetVehicleVectorParam(int param, Vector3 value) |
2821 | { | 3441 | { |
2822 | PhysicsActor pa = PhysActor; | 3442 | if (m_vehicleParams == null) |
3443 | return; | ||
2823 | 3444 | ||
2824 | if (pa != null) | 3445 | m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value); |
2825 | pa.VehicleVectorParam(param, value); | 3446 | |
3447 | if (_parentID == 0 && PhysActor != null) | ||
3448 | { | ||
3449 | PhysActor.VehicleVectorParam(param, value); | ||
3450 | } | ||
2826 | } | 3451 | } |
2827 | 3452 | ||
2828 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 3453 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
2829 | { | 3454 | { |
2830 | PhysicsActor pa = PhysActor; | 3455 | if (m_vehicleParams == null) |
3456 | return; | ||
2831 | 3457 | ||
2832 | if (pa != null) | 3458 | m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation); |
2833 | pa.VehicleRotationParam(param, rotation); | 3459 | |
3460 | if (_parentID == 0 && PhysActor != null) | ||
3461 | { | ||
3462 | PhysActor.VehicleRotationParam(param, rotation); | ||
3463 | } | ||
2834 | } | 3464 | } |
2835 | 3465 | ||
2836 | /// <summary> | 3466 | /// <summary> |
@@ -3031,14 +3661,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3031 | hasProfileCut = hasDimple; // is it the same thing? | 3661 | hasProfileCut = hasDimple; // is it the same thing? |
3032 | } | 3662 | } |
3033 | 3663 | ||
3034 | public void SetVehicleFlags(int param, bool remove) | ||
3035 | { | ||
3036 | PhysicsActor pa = PhysActor; | ||
3037 | |||
3038 | if (pa != null) | ||
3039 | pa.VehicleFlags(param, remove); | ||
3040 | } | ||
3041 | |||
3042 | public void SetGroup(UUID groupID, IClientAPI client) | 3664 | public void SetGroup(UUID groupID, IClientAPI client) |
3043 | { | 3665 | { |
3044 | // Scene.AddNewPrims() calls with client == null so can't use this. | 3666 | // Scene.AddNewPrims() calls with client == null so can't use this. |
@@ -3138,71 +3760,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3138 | { | 3760 | { |
3139 | ParentGroup.stopMoveToTarget(); | 3761 | ParentGroup.stopMoveToTarget(); |
3140 | 3762 | ||
3141 | ParentGroup.ScheduleGroupForTerseUpdate(); | 3763 | // ParentGroup.ScheduleGroupForTerseUpdate(); |
3142 | //ParentGroup.ScheduleGroupForFullUpdate(); | 3764 | //ParentGroup.ScheduleGroupForFullUpdate(); |
3143 | } | 3765 | } |
3144 | 3766 | ||
3145 | public void StoreUndoState() | 3767 | public void StoreUndoState(ObjectChangeType change) |
3146 | { | ||
3147 | StoreUndoState(false); | ||
3148 | } | ||
3149 | |||
3150 | public void StoreUndoState(bool forGroup) | ||
3151 | { | 3768 | { |
3152 | if (ParentGroup == null || ParentGroup.Scene == null) | 3769 | if (m_UndoRedo == null) |
3153 | return; | 3770 | m_UndoRedo = new UndoRedoState(5); |
3154 | 3771 | ||
3155 | if (Undoing) | 3772 | lock (m_UndoRedo) |
3156 | { | 3773 | { |
3157 | // m_log.DebugFormat( | 3774 | if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended |
3158 | // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); | ||
3159 | return; | ||
3160 | } | ||
3161 | |||
3162 | if (IgnoreUndoUpdate) | ||
3163 | { | ||
3164 | // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); | ||
3165 | return; | ||
3166 | } | ||
3167 | |||
3168 | lock (m_undo) | ||
3169 | { | ||
3170 | if (m_undo.Count > 0) | ||
3171 | { | 3775 | { |
3172 | UndoState last = m_undo[m_undo.Count - 1]; | 3776 | m_UndoRedo.StoreUndo(this, change); |
3173 | if (last != null) | ||
3174 | { | ||
3175 | // TODO: May need to fix for group comparison | ||
3176 | if (last.Compare(this)) | ||
3177 | { | ||
3178 | // m_log.DebugFormat( | ||
3179 | // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", | ||
3180 | // Name, LocalId, m_undo.Count); | ||
3181 | |||
3182 | return; | ||
3183 | } | ||
3184 | } | ||
3185 | } | ||
3186 | |||
3187 | // m_log.DebugFormat( | ||
3188 | // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", | ||
3189 | // Name, LocalId, forGroup, m_undo.Count); | ||
3190 | |||
3191 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3192 | { | ||
3193 | UndoState nUndo = new UndoState(this, forGroup); | ||
3194 | |||
3195 | m_undo.Add(nUndo); | ||
3196 | |||
3197 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3198 | m_undo.RemoveAt(0); | ||
3199 | |||
3200 | if (m_redo.Count > 0) | ||
3201 | m_redo.Clear(); | ||
3202 | |||
3203 | // m_log.DebugFormat( | ||
3204 | // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", | ||
3205 | // Name, LocalId, forGroup, m_undo.Count); | ||
3206 | } | 3777 | } |
3207 | } | 3778 | } |
3208 | } | 3779 | } |
@@ -3214,88 +3785,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
3214 | { | 3785 | { |
3215 | get | 3786 | get |
3216 | { | 3787 | { |
3217 | lock (m_undo) | 3788 | if (m_UndoRedo == null) |
3218 | return m_undo.Count; | 3789 | return 0; |
3790 | return m_UndoRedo.Count; | ||
3219 | } | 3791 | } |
3220 | } | 3792 | } |
3221 | 3793 | ||
3222 | public void Undo() | 3794 | public void Undo() |
3223 | { | 3795 | { |
3224 | lock (m_undo) | 3796 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3225 | { | 3797 | return; |
3226 | // m_log.DebugFormat( | ||
3227 | // "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}", | ||
3228 | // Name, LocalId, m_undo.Count); | ||
3229 | |||
3230 | if (m_undo.Count > 0) | ||
3231 | { | ||
3232 | UndoState goback = m_undo[m_undo.Count - 1]; | ||
3233 | m_undo.RemoveAt(m_undo.Count - 1); | ||
3234 | |||
3235 | UndoState nUndo = null; | ||
3236 | |||
3237 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3238 | { | ||
3239 | nUndo = new UndoState(this, goback.ForGroup); | ||
3240 | } | ||
3241 | |||
3242 | goback.PlaybackState(this); | ||
3243 | |||
3244 | if (nUndo != null) | ||
3245 | { | ||
3246 | m_redo.Add(nUndo); | ||
3247 | |||
3248 | if (m_redo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3249 | m_redo.RemoveAt(0); | ||
3250 | } | ||
3251 | } | ||
3252 | 3798 | ||
3253 | // m_log.DebugFormat( | 3799 | lock (m_UndoRedo) |
3254 | // "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", | 3800 | { |
3255 | // Name, LocalId, m_undo.Count); | 3801 | Undoing = true; |
3802 | m_UndoRedo.Undo(this); | ||
3803 | Undoing = false; | ||
3256 | } | 3804 | } |
3257 | } | 3805 | } |
3258 | 3806 | ||
3259 | public void Redo() | 3807 | public void Redo() |
3260 | { | 3808 | { |
3261 | lock (m_undo) | 3809 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3262 | { | 3810 | return; |
3263 | // m_log.DebugFormat( | ||
3264 | // "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}", | ||
3265 | // Name, LocalId, m_redo.Count); | ||
3266 | |||
3267 | if (m_redo.Count > 0) | ||
3268 | { | ||
3269 | UndoState gofwd = m_redo[m_redo.Count - 1]; | ||
3270 | m_redo.RemoveAt(m_redo.Count - 1); | ||
3271 | |||
3272 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3273 | { | ||
3274 | UndoState nUndo = new UndoState(this, gofwd.ForGroup); | ||
3275 | |||
3276 | m_undo.Add(nUndo); | ||
3277 | |||
3278 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3279 | m_undo.RemoveAt(0); | ||
3280 | } | ||
3281 | |||
3282 | gofwd.PlayfwdState(this); | ||
3283 | 3811 | ||
3284 | // m_log.DebugFormat( | 3812 | lock (m_UndoRedo) |
3285 | // "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", | 3813 | { |
3286 | // Name, LocalId, m_redo.Count); | 3814 | Undoing = true; |
3287 | } | 3815 | m_UndoRedo.Redo(this); |
3816 | Undoing = false; | ||
3288 | } | 3817 | } |
3289 | } | 3818 | } |
3290 | 3819 | ||
3291 | public void ClearUndoState() | 3820 | public void ClearUndoState() |
3292 | { | 3821 | { |
3293 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); | 3822 | if (m_UndoRedo == null || Undoing) |
3823 | return; | ||
3294 | 3824 | ||
3295 | lock (m_undo) | 3825 | lock (m_UndoRedo) |
3296 | { | 3826 | { |
3297 | m_undo.Clear(); | 3827 | m_UndoRedo.Clear(); |
3298 | m_redo.Clear(); | ||
3299 | } | 3828 | } |
3300 | } | 3829 | } |
3301 | 3830 | ||
@@ -3846,7 +4375,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3846 | if (god) | 4375 | if (god) |
3847 | { | 4376 | { |
3848 | BaseMask = ApplyMask(BaseMask, set, mask); | 4377 | BaseMask = ApplyMask(BaseMask, set, mask); |
3849 | Inventory.ApplyGodPermissions(_baseMask); | 4378 | Inventory.ApplyGodPermissions(BaseMask); |
3850 | } | 4379 | } |
3851 | 4380 | ||
3852 | break; | 4381 | break; |
@@ -3865,7 +4394,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3865 | case 16: | 4394 | case 16: |
3866 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & | 4395 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & |
3867 | baseMask; | 4396 | baseMask; |
3868 | // Prevent the client from creating no mod, no copy | 4397 | // Prevent the client from creating no copy, no transfer |
3869 | // objects | 4398 | // objects |
3870 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) | 4399 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) |
3871 | NextOwnerMask |= (uint)PermissionMask.Transfer; | 4400 | NextOwnerMask |= (uint)PermissionMask.Transfer; |
@@ -3883,20 +4412,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3883 | { | 4412 | { |
3884 | bool update = false; | 4413 | bool update = false; |
3885 | 4414 | ||
3886 | if (BaseMask != source.BaseMask || | 4415 | uint prevOwnerMask = OwnerMask; |
3887 | OwnerMask != source.OwnerMask || | 4416 | uint prevGroupMask = GroupMask; |
3888 | GroupMask != source.GroupMask || | 4417 | uint prevEveryoneMask = EveryoneMask; |
3889 | EveryoneMask != source.EveryoneMask || | 4418 | uint prevNextOwnerMask = NextOwnerMask; |
3890 | NextOwnerMask != source.NextOwnerMask) | ||
3891 | update = true; | ||
3892 | 4419 | ||
3893 | BaseMask = source.BaseMask; | 4420 | OwnerMask = source.OwnerMask & BaseMask; |
3894 | OwnerMask = source.OwnerMask; | 4421 | GroupMask = source.GroupMask & BaseMask; |
3895 | GroupMask = source.GroupMask; | 4422 | EveryoneMask = source.EveryoneMask & BaseMask; |
3896 | EveryoneMask = source.EveryoneMask; | 4423 | NextOwnerMask = source.NextOwnerMask & BaseMask; |
3897 | NextOwnerMask = source.NextOwnerMask; | ||
3898 | 4424 | ||
3899 | if (update) | 4425 | if (OwnerMask != prevOwnerMask || |
4426 | GroupMask != prevGroupMask || | ||
4427 | EveryoneMask != prevEveryoneMask || | ||
4428 | NextOwnerMask != prevNextOwnerMask) | ||
3900 | SendFullUpdateToAllClients(); | 4429 | SendFullUpdateToAllClients(); |
3901 | } | 4430 | } |
3902 | 4431 | ||
@@ -3947,6 +4476,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3947 | } | 4476 | } |
3948 | } | 4477 | } |
3949 | 4478 | ||
4479 | |||
3950 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) | 4480 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) |
3951 | { | 4481 | { |
3952 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) | 4482 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) |
@@ -3974,7 +4504,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3974 | /// <param name="SetTemporary"></param> | 4504 | /// <param name="SetTemporary"></param> |
3975 | /// <param name="SetPhantom"></param> | 4505 | /// <param name="SetPhantom"></param> |
3976 | /// <param name="SetVD"></param> | 4506 | /// <param name="SetVD"></param> |
3977 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) | 4507 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) |
3978 | { | 4508 | { |
3979 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); | 4509 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); |
3980 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); | 4510 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); |
@@ -3984,215 +4514,230 @@ namespace OpenSim.Region.Framework.Scenes | |||
3984 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) | 4514 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) |
3985 | return; | 4515 | return; |
3986 | 4516 | ||
3987 | PhysicsActor pa = PhysActor; | 4517 | VolumeDetectActive = SetVD; |
3988 | |||
3989 | // Special cases for VD. VD can only be called from a script | ||
3990 | // and can't be combined with changes to other states. So we can rely | ||
3991 | // that... | ||
3992 | // ... if VD is changed, all others are not. | ||
3993 | // ... if one of the others is changed, VD is not. | ||
3994 | if (SetVD) // VD is active, special logic applies | ||
3995 | { | ||
3996 | // State machine logic for VolumeDetect | ||
3997 | // More logic below | ||
3998 | bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; | ||
3999 | |||
4000 | if (phanReset) // Phantom changes from on to off switch VD off too | ||
4001 | { | ||
4002 | SetVD = false; // Switch it of for the course of this routine | ||
4003 | VolumeDetectActive = false; // and also permanently | ||
4004 | |||
4005 | if (pa != null) | ||
4006 | pa.SetVolumeDetect(0); // Let physics know about it too | ||
4007 | } | ||
4008 | else | ||
4009 | { | ||
4010 | // If volumedetect is active we don't want phantom to be applied. | ||
4011 | // If this is a new call to VD out of the state "phantom" | ||
4012 | // this will also cause the prim to be visible to physics | ||
4013 | SetPhantom = false; | ||
4014 | } | ||
4015 | } | ||
4016 | 4518 | ||
4017 | if (UsePhysics && IsJoint()) | 4519 | // volume detector implies phantom |
4018 | { | 4520 | if (VolumeDetectActive) |
4019 | SetPhantom = true; | 4521 | SetPhantom = true; |
4020 | } | ||
4021 | 4522 | ||
4022 | if (UsePhysics) | 4523 | if (UsePhysics) |
4023 | { | ||
4024 | AddFlag(PrimFlags.Physics); | 4524 | AddFlag(PrimFlags.Physics); |
4025 | if (!wasUsingPhysics) | ||
4026 | { | ||
4027 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4028 | } | ||
4029 | } | ||
4030 | else | 4525 | else |
4031 | { | ||
4032 | RemFlag(PrimFlags.Physics); | 4526 | RemFlag(PrimFlags.Physics); |
4033 | if (wasUsingPhysics) | ||
4034 | { | ||
4035 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4036 | } | ||
4037 | } | ||
4038 | 4527 | ||
4039 | if (SetPhantom | 4528 | if (SetPhantom) |
4040 | || ParentGroup.IsAttachment | ||
4041 | || PhysicsShapeType == (byte)PhysShapeType.none | ||
4042 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints | ||
4043 | { | ||
4044 | AddFlag(PrimFlags.Phantom); | 4529 | AddFlag(PrimFlags.Phantom); |
4045 | 4530 | else | |
4046 | if (PhysActor != null) | ||
4047 | { | ||
4048 | RemoveFromPhysics(); | ||
4049 | pa = null; | ||
4050 | } | ||
4051 | } | ||
4052 | else // Not phantom | ||
4053 | { | ||
4054 | RemFlag(PrimFlags.Phantom); | 4531 | RemFlag(PrimFlags.Phantom); |
4055 | 4532 | ||
4056 | if (ParentGroup.Scene == null) | 4533 | if (SetTemporary) |
4057 | return; | 4534 | AddFlag(PrimFlags.TemporaryOnRez); |
4535 | else | ||
4536 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4058 | 4537 | ||
4059 | if (ParentGroup.Scene.CollidablePrims && pa == null) | ||
4060 | { | ||
4061 | pa = AddToPhysics(UsePhysics); | ||
4062 | 4538 | ||
4063 | if (pa != null) | 4539 | if (ParentGroup.Scene == null) |
4064 | { | 4540 | return; |
4065 | pa.SetMaterial(Material); | ||
4066 | DoPhysicsPropertyUpdate(UsePhysics, true); | ||
4067 | |||
4068 | if ( | ||
4069 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4070 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4071 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4072 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4073 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4074 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4075 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4076 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4077 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4078 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4079 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4080 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4081 | (CollisionSound != UUID.Zero) | ||
4082 | ) | ||
4083 | { | ||
4084 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4085 | pa.SubscribeEvents(1000); | ||
4086 | } | ||
4087 | } | ||
4088 | } | ||
4089 | else // it already has a physical representation | ||
4090 | { | ||
4091 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim | ||
4092 | } | ||
4093 | } | ||
4094 | 4541 | ||
4095 | if (SetVD) | 4542 | PhysicsActor pa = PhysActor; |
4543 | |||
4544 | if (pa != null && building && pa.Building != building) | ||
4545 | pa.Building = building; | ||
4546 | |||
4547 | if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none | ||
4548 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
4096 | { | 4549 | { |
4097 | // If the above logic worked (this is urgent candidate to unit tests!) | ||
4098 | // we now have a physicsactor. | ||
4099 | // Defensive programming calls for a check here. | ||
4100 | // Better would be throwing an exception that could be catched by a unit test as the internal | ||
4101 | // logic should make sure, this Physactor is always here. | ||
4102 | if (pa != null) | 4550 | if (pa != null) |
4103 | { | 4551 | { |
4104 | pa.SetVolumeDetect(1); | 4552 | if(wasUsingPhysics) |
4105 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 4553 | ParentGroup.Scene.RemovePhysicalPrim(1); |
4106 | VolumeDetectActive = true; | 4554 | RemoveFromPhysics(); |
4107 | } | 4555 | } |
4556 | |||
4557 | Velocity = new Vector3(0, 0, 0); | ||
4558 | Acceleration = new Vector3(0, 0, 0); | ||
4559 | if (ParentGroup.RootPart == this) | ||
4560 | AngularVelocity = new Vector3(0, 0, 0); | ||
4108 | } | 4561 | } |
4109 | else if (SetVD != wasVD) | 4562 | else if (SetVD != wasVD) |
4110 | { | 4563 | { |
4111 | // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like | 4564 | if (ParentGroup.Scene.CollidablePrims) |
4112 | // (mumbles, well, at least if you have infinte CPU powers :-)) | 4565 | { |
4113 | if (pa != null) | 4566 | if (pa == null) |
4114 | pa.SetVolumeDetect(0); | 4567 | { |
4568 | AddToPhysics(UsePhysics, SetPhantom, building, false); | ||
4569 | pa = PhysActor; | ||
4570 | /* | ||
4571 | if (pa != null) | ||
4572 | { | ||
4573 | if ( | ||
4574 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4575 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4576 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4577 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4578 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4579 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4580 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4581 | ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4582 | (CollisionSound != UUID.Zero) | ||
4583 | ) | ||
4584 | { | ||
4585 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4586 | pa.SubscribeEvents(1000); | ||
4587 | } | ||
4588 | } | ||
4589 | */ | ||
4590 | } | ||
4591 | else // it already has a physical representation | ||
4592 | { | ||
4593 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. | ||
4594 | /* moved into DoPhysicsPropertyUpdate | ||
4595 | if(VolumeDetectActive) | ||
4596 | pa.SetVolumeDetect(1); | ||
4597 | else | ||
4598 | pa.SetVolumeDetect(0); | ||
4599 | */ | ||
4115 | 4600 | ||
4116 | RemFlag(PrimFlags.Phantom); | 4601 | if (pa.Building != building) |
4117 | VolumeDetectActive = false; | 4602 | pa.Building = building; |
4118 | } | 4603 | } |
4119 | 4604 | ||
4120 | if (SetTemporary) | 4605 | UpdatePhysicsSubscribedEvents(); |
4121 | { | 4606 | } |
4122 | AddFlag(PrimFlags.TemporaryOnRez); | 4607 | } |
4123 | } | ||
4124 | else | ||
4125 | { | ||
4126 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4127 | } | ||
4128 | 4608 | ||
4129 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | 4609 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); |
4130 | 4610 | ||
4611 | // and last in case we have a new actor and not building | ||
4612 | |||
4131 | if (ParentGroup != null) | 4613 | if (ParentGroup != null) |
4132 | { | 4614 | { |
4133 | ParentGroup.HasGroupChanged = true; | 4615 | ParentGroup.HasGroupChanged = true; |
4134 | ScheduleFullUpdate(); | 4616 | ScheduleFullUpdate(); |
4135 | } | 4617 | } |
4136 | 4618 | ||
4137 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); | 4619 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); |
4138 | } | 4620 | } |
4139 | 4621 | ||
4140 | /// <summary> | 4622 | /// <summary> |
4141 | /// Adds this part to the physics scene. | 4623 | /// Adds this part to the physics scene. |
4624 | /// and sets the PhysActor property | ||
4142 | /// </summary> | 4625 | /// </summary> |
4143 | /// <remarks>This method also sets the PhysActor property.</remarks> | 4626 | /// <param name="isPhysical">Add this prim as physical.</param> |
4144 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | 4627 | /// <param name="isPhantom">Add this prim as phantom.</param> |
4145 | /// <returns> | 4628 | /// <param name="building">tells physics to delay full construction of object</param> |
4146 | /// The physics actor. null if there was a failure. | 4629 | /// <param name="applyDynamics">applies velocities, force and torque</param> |
4147 | /// </returns> | 4630 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) |
4148 | private PhysicsActor AddToPhysics(bool rigidBody) | 4631 | { |
4149 | { | ||
4150 | PhysicsActor pa; | 4632 | PhysicsActor pa; |
4151 | 4633 | ||
4634 | Vector3 velocity = Velocity; | ||
4635 | Vector3 rotationalVelocity = AngularVelocity;; | ||
4636 | |||
4152 | try | 4637 | try |
4153 | { | 4638 | { |
4154 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | 4639 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( |
4155 | string.Format("{0}/{1}", Name, UUID), | 4640 | string.Format("{0}/{1}", Name, UUID), |
4156 | Shape, | 4641 | Shape, |
4157 | AbsolutePosition, | 4642 | AbsolutePosition, |
4158 | Scale, | 4643 | Scale, |
4159 | RotationOffset, | 4644 | GetWorldRotation(), |
4160 | rigidBody, | 4645 | isPhysical, |
4161 | m_localId); | 4646 | isPhantom, |
4647 | PhysicsShapeType, | ||
4648 | m_localId); | ||
4162 | } | 4649 | } |
4163 | catch (Exception e) | 4650 | catch (Exception e) |
4164 | { | 4651 | { |
4165 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); | 4652 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); |
4166 | pa = null; | 4653 | pa = null; |
4167 | } | 4654 | } |
4168 | 4655 | ||
4169 | // FIXME: Ideally we wouldn't set the property here to reduce situations where threads changing physical | ||
4170 | // properties can stop on each other. However, DoPhysicsPropertyUpdate() currently relies on PhysActor | ||
4171 | // being set. | ||
4172 | PhysActor = pa; | ||
4173 | |||
4174 | // Basic Physics can also return null as well as an exception catch. | ||
4175 | if (pa != null) | 4656 | if (pa != null) |
4176 | { | 4657 | { |
4177 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | 4658 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info |
4178 | pa.SetMaterial(Material); | 4659 | pa.SetMaterial(Material); |
4179 | DoPhysicsPropertyUpdate(rigidBody, true); | 4660 | |
4661 | if (VolumeDetectActive) // change if not the default only | ||
4662 | pa.SetVolumeDetect(1); | ||
4663 | |||
4664 | if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) | ||
4665 | m_vehicleParams.SetVehicle(pa); | ||
4666 | |||
4667 | // we are going to tell rest of code about physics so better have this here | ||
4668 | PhysActor = pa; | ||
4669 | |||
4670 | // DoPhysicsPropertyUpdate(isPhysical, true); | ||
4671 | // lets expand it here just with what it really needs to do | ||
4672 | |||
4673 | if (isPhysical) | ||
4674 | { | ||
4675 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
4676 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
4677 | ParentGroup.RootPart.KeyframeMotion = null; | ||
4678 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
4679 | |||
4680 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | ||
4681 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
4682 | |||
4683 | if (ParentID != 0 && ParentID != LocalId) | ||
4684 | { | ||
4685 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | ||
4686 | |||
4687 | if (parentPa != null) | ||
4688 | { | ||
4689 | pa.link(parentPa); | ||
4690 | } | ||
4691 | } | ||
4692 | } | ||
4693 | |||
4694 | if (applyDynamics) | ||
4695 | // do independent of isphysical so parameters get setted (at least some) | ||
4696 | { | ||
4697 | Velocity = velocity; | ||
4698 | AngularVelocity = rotationalVelocity; | ||
4699 | // pa.Velocity = velocity; | ||
4700 | pa.RotationalVelocity = rotationalVelocity; | ||
4701 | |||
4702 | // if not vehicle and root part apply force and torque | ||
4703 | if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE) | ||
4704 | && LocalId == ParentGroup.RootPart.LocalId) | ||
4705 | { | ||
4706 | pa.Force = Force; | ||
4707 | pa.Torque = Torque; | ||
4708 | } | ||
4709 | } | ||
4710 | |||
4711 | // if (Shape.SculptEntry) | ||
4712 | // CheckSculptAndLoad(); | ||
4713 | // else | ||
4714 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
4715 | |||
4716 | if (!building) | ||
4717 | pa.Building = false; | ||
4180 | } | 4718 | } |
4181 | 4719 | ||
4182 | return pa; | 4720 | PhysActor = pa; |
4183 | } | 4721 | } |
4184 | 4722 | ||
4185 | /// <summary> | 4723 | /// <summary> |
4186 | /// This removes the part from the physics scene. | 4724 | /// This removes the part from the physics scene. |
4187 | /// </summary> | 4725 | /// </summary> |
4188 | /// <remarks> | 4726 | /// <remarks> |
4189 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 4727 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |
4190 | /// representation for collision detection. Rather, this would be used in situations such as making a prim | 4728 | /// representation for collision detection. |
4191 | /// phantom. | ||
4192 | /// </remarks> | 4729 | /// </remarks> |
4193 | public void RemoveFromPhysics() | 4730 | public void RemoveFromPhysics() |
4194 | { | 4731 | { |
4195 | ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 4732 | PhysicsActor pa = PhysActor; |
4733 | if (pa != null) | ||
4734 | { | ||
4735 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4736 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | ||
4737 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | ||
4738 | |||
4739 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | ||
4740 | } | ||
4196 | PhysActor = null; | 4741 | PhysActor = null; |
4197 | } | 4742 | } |
4198 | 4743 | ||
@@ -4324,6 +4869,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4324 | { | 4869 | { |
4325 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); | 4870 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); |
4326 | 4871 | ||
4872 | return; | ||
4873 | |||
4327 | if (ParentGroup.IsDeleted) | 4874 | if (ParentGroup.IsDeleted) |
4328 | return; | 4875 | return; |
4329 | 4876 | ||
@@ -4404,6 +4951,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
4404 | ScheduleFullUpdate(); | 4951 | ScheduleFullUpdate(); |
4405 | } | 4952 | } |
4406 | 4953 | ||
4954 | |||
4955 | private void UpdatePhysicsSubscribedEvents() | ||
4956 | { | ||
4957 | PhysicsActor pa = PhysActor; | ||
4958 | if (pa == null) | ||
4959 | return; | ||
4960 | |||
4961 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4962 | |||
4963 | bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0)); | ||
4964 | |||
4965 | scriptEvents CombinedEvents = AggregateScriptEvents; | ||
4966 | |||
4967 | // merge with root part | ||
4968 | if (ParentGroup != null && ParentGroup.RootPart != null) | ||
4969 | CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents; | ||
4970 | |||
4971 | // submit to this part case | ||
4972 | if (VolumeDetectActive) | ||
4973 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | ||
4974 | else if ((Flags & PrimFlags.Phantom) != 0) | ||
4975 | CombinedEvents &= PhyscicsPhantonSubsEvents; | ||
4976 | else | ||
4977 | CombinedEvents &= PhysicsNeededSubsEvents; | ||
4978 | |||
4979 | if (hassound || CombinedEvents != 0) | ||
4980 | { | ||
4981 | // subscribe to physics updates. | ||
4982 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4983 | pa.SubscribeEvents(50); // 20 reports per second | ||
4984 | } | ||
4985 | else | ||
4986 | { | ||
4987 | pa.UnSubscribeEvents(); | ||
4988 | } | ||
4989 | } | ||
4990 | |||
4991 | |||
4407 | public void aggregateScriptEvents() | 4992 | public void aggregateScriptEvents() |
4408 | { | 4993 | { |
4409 | if (ParentGroup == null || ParentGroup.RootPart == null) | 4994 | if (ParentGroup == null || ParentGroup.RootPart == null) |
@@ -4440,40 +5025,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
4440 | { | 5025 | { |
4441 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 5026 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4442 | } | 5027 | } |
4443 | 5028 | /* | |
4444 | PhysicsActor pa = PhysActor; | 5029 | PhysicsActor pa = PhysActor; |
4445 | 5030 | if (pa != null) | |
4446 | if ( | ||
4447 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4448 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4449 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4450 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4451 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4452 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4453 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4454 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4455 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4456 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4457 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4458 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4459 | (CollisionSound != UUID.Zero) | ||
4460 | ) | ||
4461 | { | 5031 | { |
4462 | // subscribe to physics updates. | 5032 | if ( |
4463 | if (pa != null) | 5033 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || |
5034 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
5035 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
5036 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
5037 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
5038 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
5039 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | ||
5040 | ) | ||
4464 | { | 5041 | { |
5042 | // subscribe to physics updates. | ||
4465 | pa.OnCollisionUpdate += PhysicsCollision; | 5043 | pa.OnCollisionUpdate += PhysicsCollision; |
4466 | pa.SubscribeEvents(1000); | 5044 | pa.SubscribeEvents(1000); |
4467 | } | 5045 | } |
4468 | } | 5046 | else |
4469 | else | ||
4470 | { | ||
4471 | if (pa != null) | ||
4472 | { | 5047 | { |
4473 | pa.UnSubscribeEvents(); | 5048 | pa.UnSubscribeEvents(); |
4474 | pa.OnCollisionUpdate -= PhysicsCollision; | 5049 | pa.OnCollisionUpdate -= PhysicsCollision; |
4475 | } | 5050 | } |
4476 | } | 5051 | } |
5052 | */ | ||
5053 | UpdatePhysicsSubscribedEvents(); | ||
4477 | 5054 | ||
4478 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 5055 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4479 | //{ | 5056 | //{ |
@@ -4604,6 +5181,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4604 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 5181 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4605 | } | 5182 | } |
4606 | 5183 | ||
5184 | public void ResetOwnerChangeFlag() | ||
5185 | { | ||
5186 | List<UUID> inv = Inventory.GetInventoryList(); | ||
5187 | |||
5188 | foreach (UUID itemID in inv) | ||
5189 | { | ||
5190 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
5191 | item.OwnerChanged = false; | ||
5192 | Inventory.UpdateInventoryItem(item, false, false); | ||
5193 | } | ||
5194 | } | ||
5195 | |||
4607 | /// <summary> | 5196 | /// <summary> |
4608 | /// Record an avatar sitting on this part. | 5197 | /// Record an avatar sitting on this part. |
4609 | /// </summary> | 5198 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index db723fa..3a9a146 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -48,6 +48,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
48 | private string m_inventoryFileName = String.Empty; | 48 | private string m_inventoryFileName = String.Empty; |
49 | private byte[] m_inventoryFileData = new byte[0]; | 49 | private byte[] m_inventoryFileData = new byte[0]; |
50 | private uint m_inventoryFileNameSerial = 0; | 50 | private uint m_inventoryFileNameSerial = 0; |
51 | private bool m_inventoryPrivileged = false; | ||
52 | |||
53 | private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); | ||
51 | 54 | ||
52 | /// <value> | 55 | /// <value> |
53 | /// The part to which the inventory belongs. | 56 | /// The part to which the inventory belongs. |
@@ -84,7 +87,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
84 | /// </value> | 87 | /// </value> |
85 | protected internal TaskInventoryDictionary Items | 88 | protected internal TaskInventoryDictionary Items |
86 | { | 89 | { |
87 | get { return m_items; } | 90 | get { |
91 | return m_items; | ||
92 | } | ||
88 | set | 93 | set |
89 | { | 94 | { |
90 | m_items = value; | 95 | m_items = value; |
@@ -133,38 +138,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
133 | public void ResetInventoryIDs() | 138 | public void ResetInventoryIDs() |
134 | { | 139 | { |
135 | if (null == m_part) | 140 | if (null == m_part) |
136 | return; | 141 | m_items.LockItemsForWrite(true); |
137 | 142 | ||
138 | lock (m_items) | 143 | if (Items.Count == 0) |
139 | { | 144 | { |
140 | if (0 == m_items.Count) | 145 | m_items.LockItemsForWrite(false); |
141 | return; | 146 | return; |
147 | } | ||
142 | 148 | ||
143 | IList<TaskInventoryItem> items = GetInventoryItems(); | 149 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
144 | m_items.Clear(); | 150 | Items.Clear(); |
145 | 151 | ||
146 | foreach (TaskInventoryItem item in items) | 152 | foreach (TaskInventoryItem item in items) |
147 | { | 153 | { |
148 | item.ResetIDs(m_part.UUID); | 154 | item.ResetIDs(m_part.UUID); |
149 | m_items.Add(item.ItemID, item); | 155 | Items.Add(item.ItemID, item); |
150 | } | ||
151 | } | 156 | } |
157 | m_items.LockItemsForWrite(false); | ||
152 | } | 158 | } |
153 | 159 | ||
154 | public void ResetObjectID() | 160 | public void ResetObjectID() |
155 | { | 161 | { |
156 | lock (Items) | 162 | m_items.LockItemsForWrite(true); |
163 | |||
164 | if (Items.Count == 0) | ||
157 | { | 165 | { |
158 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 166 | m_items.LockItemsForWrite(false); |
159 | Items.Clear(); | 167 | return; |
160 | |||
161 | foreach (TaskInventoryItem item in items) | ||
162 | { | ||
163 | item.ParentPartID = m_part.UUID; | ||
164 | item.ParentID = m_part.UUID; | ||
165 | Items.Add(item.ItemID, item); | ||
166 | } | ||
167 | } | 168 | } |
169 | |||
170 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
171 | Items.Clear(); | ||
172 | |||
173 | foreach (TaskInventoryItem item in items) | ||
174 | { | ||
175 | item.ParentPartID = m_part.UUID; | ||
176 | item.ParentID = m_part.UUID; | ||
177 | Items.Add(item.ItemID, item); | ||
178 | } | ||
179 | m_items.LockItemsForWrite(false); | ||
168 | } | 180 | } |
169 | 181 | ||
170 | /// <summary> | 182 | /// <summary> |
@@ -173,17 +185,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
173 | /// <param name="ownerId"></param> | 185 | /// <param name="ownerId"></param> |
174 | public void ChangeInventoryOwner(UUID ownerId) | 186 | public void ChangeInventoryOwner(UUID ownerId) |
175 | { | 187 | { |
176 | lock (Items) | 188 | List<TaskInventoryItem> items = GetInventoryItems(); |
177 | { | 189 | |
178 | if (0 == Items.Count) | 190 | if (items.Count == 0) |
179 | { | 191 | return; |
180 | return; | ||
181 | } | ||
182 | } | ||
183 | 192 | ||
193 | m_items.LockItemsForWrite(true); | ||
184 | HasInventoryChanged = true; | 194 | HasInventoryChanged = true; |
185 | m_part.ParentGroup.HasGroupChanged = true; | 195 | m_part.ParentGroup.HasGroupChanged = true; |
186 | List<TaskInventoryItem> items = GetInventoryItems(); | ||
187 | foreach (TaskInventoryItem item in items) | 196 | foreach (TaskInventoryItem item in items) |
188 | { | 197 | { |
189 | if (ownerId != item.OwnerID) | 198 | if (ownerId != item.OwnerID) |
@@ -194,6 +203,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
194 | item.PermsGranter = UUID.Zero; | 203 | item.PermsGranter = UUID.Zero; |
195 | item.OwnerChanged = true; | 204 | item.OwnerChanged = true; |
196 | } | 205 | } |
206 | m_items.LockItemsForWrite(false); | ||
197 | } | 207 | } |
198 | 208 | ||
199 | /// <summary> | 209 | /// <summary> |
@@ -202,12 +212,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
202 | /// <param name="groupID"></param> | 212 | /// <param name="groupID"></param> |
203 | public void ChangeInventoryGroup(UUID groupID) | 213 | public void ChangeInventoryGroup(UUID groupID) |
204 | { | 214 | { |
205 | lock (Items) | 215 | m_items.LockItemsForWrite(true); |
216 | if (0 == Items.Count) | ||
206 | { | 217 | { |
207 | if (0 == Items.Count) | 218 | m_items.LockItemsForWrite(false); |
208 | { | 219 | return; |
209 | return; | ||
210 | } | ||
211 | } | 220 | } |
212 | 221 | ||
213 | // Don't let this set the HasGroupChanged flag for attachments | 222 | // Don't let this set the HasGroupChanged flag for attachments |
@@ -219,12 +228,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
219 | m_part.ParentGroup.HasGroupChanged = true; | 228 | m_part.ParentGroup.HasGroupChanged = true; |
220 | } | 229 | } |
221 | 230 | ||
222 | List<TaskInventoryItem> items = GetInventoryItems(); | 231 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
223 | foreach (TaskInventoryItem item in items) | 232 | foreach (TaskInventoryItem item in items) |
224 | { | 233 | { |
225 | if (groupID != item.GroupID) | 234 | if (groupID != item.GroupID) |
235 | { | ||
226 | item.GroupID = groupID; | 236 | item.GroupID = groupID; |
237 | } | ||
227 | } | 238 | } |
239 | m_items.LockItemsForWrite(false); | ||
228 | } | 240 | } |
229 | 241 | ||
230 | private void QueryScriptStates() | 242 | private void QueryScriptStates() |
@@ -232,15 +244,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
232 | if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) | 244 | if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) |
233 | return; | 245 | return; |
234 | 246 | ||
235 | lock (Items) | 247 | Items.LockItemsForRead(true); |
248 | foreach (TaskInventoryItem item in Items.Values) | ||
236 | { | 249 | { |
237 | foreach (TaskInventoryItem item in Items.Values) | 250 | if (item.InvType == (int)InventoryType.LSL) |
238 | { | 251 | { |
239 | bool running; | 252 | bool running; |
240 | if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running)) | 253 | if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running)) |
241 | item.ScriptRunning = running; | 254 | item.ScriptRunning = running; |
242 | } | 255 | } |
243 | } | 256 | } |
257 | |||
258 | Items.LockItemsForRead(false); | ||
244 | } | 259 | } |
245 | 260 | ||
246 | public bool TryGetScriptInstanceRunning(UUID itemId, out bool running) | 261 | public bool TryGetScriptInstanceRunning(UUID itemId, out bool running) |
@@ -317,7 +332,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
317 | { | 332 | { |
318 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | 333 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
319 | foreach (TaskInventoryItem item in scripts) | 334 | foreach (TaskInventoryItem item in scripts) |
335 | { | ||
320 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | 336 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
337 | m_part.RemoveScriptEvents(item.ItemID); | ||
338 | } | ||
321 | } | 339 | } |
322 | 340 | ||
323 | /// <summary> | 341 | /// <summary> |
@@ -339,7 +357,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
339 | // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 357 | // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
340 | 358 | ||
341 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) | 359 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) |
360 | { | ||
361 | StoreScriptError(item.ItemID, "no permission"); | ||
342 | return false; | 362 | return false; |
363 | } | ||
343 | 364 | ||
344 | m_part.AddFlag(PrimFlags.Scripted); | 365 | m_part.AddFlag(PrimFlags.Scripted); |
345 | 366 | ||
@@ -349,14 +370,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
349 | if (stateSource == 2 && // Prim crossing | 370 | if (stateSource == 2 && // Prim crossing |
350 | m_part.ParentGroup.Scene.m_trustBinaries) | 371 | m_part.ParentGroup.Scene.m_trustBinaries) |
351 | { | 372 | { |
352 | lock (m_items) | 373 | m_items.LockItemsForWrite(true); |
353 | { | 374 | m_items[item.ItemID].PermsMask = 0; |
354 | m_items[item.ItemID].PermsMask = 0; | 375 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
355 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 376 | m_items.LockItemsForWrite(false); |
356 | } | ||
357 | |||
358 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 377 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
359 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 378 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
379 | StoreScriptErrors(item.ItemID, null); | ||
360 | m_part.ParentGroup.AddActiveScriptCount(1); | 380 | m_part.ParentGroup.AddActiveScriptCount(1); |
361 | m_part.ScheduleFullUpdate(); | 381 | m_part.ScheduleFullUpdate(); |
362 | return true; | 382 | return true; |
@@ -365,6 +385,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
365 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); | 385 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
366 | if (null == asset) | 386 | if (null == asset) |
367 | { | 387 | { |
388 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | ||
389 | StoreScriptError(item.ItemID, msg); | ||
368 | m_log.ErrorFormat( | 390 | m_log.ErrorFormat( |
369 | "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", | 391 | "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
370 | item.Name, item.ItemID, m_part.AbsolutePosition, | 392 | item.Name, item.ItemID, m_part.AbsolutePosition, |
@@ -377,16 +399,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
377 | if (m_part.ParentGroup.m_savedScriptState != null) | 399 | if (m_part.ParentGroup.m_savedScriptState != null) |
378 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); | 400 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); |
379 | 401 | ||
380 | lock (m_items) | 402 | m_items.LockItemsForWrite(true); |
381 | { | 403 | |
382 | m_items[item.ItemID].OldItemID = item.OldItemID; | 404 | m_items[item.ItemID].OldItemID = item.OldItemID; |
383 | m_items[item.ItemID].PermsMask = 0; | 405 | m_items[item.ItemID].PermsMask = 0; |
384 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 406 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
385 | } | ||
386 | 407 | ||
408 | m_items.LockItemsForWrite(false); | ||
409 | |||
387 | string script = Utils.BytesToString(asset.Data); | 410 | string script = Utils.BytesToString(asset.Data); |
388 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 411 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
389 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 412 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
413 | StoreScriptErrors(item.ItemID, null); | ||
390 | if (!item.ScriptRunning) | 414 | if (!item.ScriptRunning) |
391 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript( | 415 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript( |
392 | m_part.LocalId, item.ItemID); | 416 | m_part.LocalId, item.ItemID); |
@@ -459,22 +483,149 @@ namespace OpenSim.Region.Framework.Scenes | |||
459 | return stateID; | 483 | return stateID; |
460 | } | 484 | } |
461 | 485 | ||
486 | /// <summary> | ||
487 | /// Start a script which is in this prim's inventory. | ||
488 | /// Some processing may occur in the background, but this routine returns asap. | ||
489 | /// </summary> | ||
490 | /// <param name="itemId"> | ||
491 | /// A <see cref="UUID"/> | ||
492 | /// </param> | ||
462 | public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 493 | public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
463 | { | 494 | { |
464 | TaskInventoryItem item = GetInventoryItem(itemId); | 495 | lock (m_scriptErrors) |
465 | if (item != null) | ||
466 | { | 496 | { |
467 | return CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | 497 | // Indicate to CreateScriptInstanceInternal() we don't want it to wait for completion |
498 | m_scriptErrors.Remove(itemId); | ||
499 | } | ||
500 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
501 | return true; | ||
502 | } | ||
503 | |||
504 | private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
505 | { | ||
506 | m_items.LockItemsForRead(true); | ||
507 | if (m_items.ContainsKey(itemId)) | ||
508 | { | ||
509 | if (m_items.ContainsKey(itemId)) | ||
510 | { | ||
511 | m_items.LockItemsForRead(false); | ||
512 | CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource); | ||
513 | } | ||
514 | else | ||
515 | { | ||
516 | m_items.LockItemsForRead(false); | ||
517 | string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, | ||
518 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
519 | StoreScriptError(itemId, msg); | ||
520 | m_log.ErrorFormat( | ||
521 | "[PRIM INVENTORY]: " + | ||
522 | "Couldn't start script with ID {0} since it {1}", itemId, msg); | ||
523 | } | ||
468 | } | 524 | } |
469 | else | 525 | else |
470 | { | 526 | { |
527 | m_items.LockItemsForRead(false); | ||
528 | string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID); | ||
529 | StoreScriptError(itemId, msg); | ||
471 | m_log.ErrorFormat( | 530 | m_log.ErrorFormat( |
472 | "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 531 | "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", |
473 | itemId, m_part.Name, m_part.UUID, | 532 | itemId, m_part.Name, m_part.UUID, |
474 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 533 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
534 | } | ||
535 | |||
536 | } | ||
475 | 537 | ||
476 | return false; | 538 | /// <summary> |
539 | /// Start a script which is in this prim's inventory and return any compilation error messages. | ||
540 | /// </summary> | ||
541 | /// <param name="itemId"> | ||
542 | /// A <see cref="UUID"/> | ||
543 | /// </param> | ||
544 | public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
545 | { | ||
546 | ArrayList errors; | ||
547 | |||
548 | // Indicate to CreateScriptInstanceInternal() we want it to | ||
549 | // post any compilation/loading error messages | ||
550 | lock (m_scriptErrors) | ||
551 | { | ||
552 | m_scriptErrors[itemId] = null; | ||
553 | } | ||
554 | |||
555 | // Perform compilation/loading | ||
556 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
557 | |||
558 | // Wait for and retrieve any errors | ||
559 | lock (m_scriptErrors) | ||
560 | { | ||
561 | while ((errors = m_scriptErrors[itemId]) == null) | ||
562 | { | ||
563 | if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000)) | ||
564 | { | ||
565 | m_log.ErrorFormat( | ||
566 | "[PRIM INVENTORY]: " + | ||
567 | "timedout waiting for script {0} errors", itemId); | ||
568 | errors = m_scriptErrors[itemId]; | ||
569 | if (errors == null) | ||
570 | { | ||
571 | errors = new ArrayList(1); | ||
572 | errors.Add("timedout waiting for errors"); | ||
573 | } | ||
574 | break; | ||
575 | } | ||
576 | } | ||
577 | m_scriptErrors.Remove(itemId); | ||
477 | } | 578 | } |
579 | return errors; | ||
580 | } | ||
581 | |||
582 | // Signal to CreateScriptInstanceEr() that compilation/loading is complete | ||
583 | private void StoreScriptErrors(UUID itemId, ArrayList errors) | ||
584 | { | ||
585 | lock (m_scriptErrors) | ||
586 | { | ||
587 | // If compilation/loading initiated via CreateScriptInstance(), | ||
588 | // it does not want the errors, so just get out | ||
589 | if (!m_scriptErrors.ContainsKey(itemId)) | ||
590 | { | ||
591 | return; | ||
592 | } | ||
593 | |||
594 | // Initiated via CreateScriptInstanceEr(), if we know what the | ||
595 | // errors are, save them and wake CreateScriptInstanceEr(). | ||
596 | if (errors != null) | ||
597 | { | ||
598 | m_scriptErrors[itemId] = errors; | ||
599 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
600 | return; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | // Initiated via CreateScriptInstanceEr() but we don't know what | ||
605 | // the errors are yet, so retrieve them from the script engine. | ||
606 | // This may involve some waiting internal to GetScriptErrors(). | ||
607 | errors = GetScriptErrors(itemId); | ||
608 | |||
609 | // Get a default non-null value to indicate success. | ||
610 | if (errors == null) | ||
611 | { | ||
612 | errors = new ArrayList(); | ||
613 | } | ||
614 | |||
615 | // Post to CreateScriptInstanceEr() and wake it up | ||
616 | lock (m_scriptErrors) | ||
617 | { | ||
618 | m_scriptErrors[itemId] = errors; | ||
619 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
620 | } | ||
621 | } | ||
622 | |||
623 | // Like StoreScriptErrors(), but just posts a single string message | ||
624 | private void StoreScriptError(UUID itemId, string message) | ||
625 | { | ||
626 | ArrayList errors = new ArrayList(1); | ||
627 | errors.Add(message); | ||
628 | StoreScriptErrors(itemId, errors); | ||
478 | } | 629 | } |
479 | 630 | ||
480 | /// <summary> | 631 | /// <summary> |
@@ -487,15 +638,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
487 | /// </param> | 638 | /// </param> |
488 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) | 639 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) |
489 | { | 640 | { |
490 | bool scriptPresent = false; | 641 | if (m_items.ContainsKey(itemId)) |
491 | |||
492 | lock (m_items) | ||
493 | { | ||
494 | if (m_items.ContainsKey(itemId)) | ||
495 | scriptPresent = true; | ||
496 | } | ||
497 | |||
498 | if (scriptPresent) | ||
499 | { | 642 | { |
500 | if (!sceneObjectBeingDeleted) | 643 | if (!sceneObjectBeingDeleted) |
501 | m_part.RemoveScriptEvents(itemId); | 644 | m_part.RemoveScriptEvents(itemId); |
@@ -565,14 +708,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
565 | /// <returns></returns> | 708 | /// <returns></returns> |
566 | private bool InventoryContainsName(string name) | 709 | private bool InventoryContainsName(string name) |
567 | { | 710 | { |
568 | lock (m_items) | 711 | m_items.LockItemsForRead(true); |
712 | foreach (TaskInventoryItem item in m_items.Values) | ||
569 | { | 713 | { |
570 | foreach (TaskInventoryItem item in m_items.Values) | 714 | if (item.Name == name) |
571 | { | 715 | { |
572 | if (item.Name == name) | 716 | m_items.LockItemsForRead(false); |
573 | return true; | 717 | return true; |
574 | } | 718 | } |
575 | } | 719 | } |
720 | m_items.LockItemsForRead(false); | ||
576 | return false; | 721 | return false; |
577 | } | 722 | } |
578 | 723 | ||
@@ -614,8 +759,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
614 | /// <param name="item"></param> | 759 | /// <param name="item"></param> |
615 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 760 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
616 | { | 761 | { |
617 | List<TaskInventoryItem> il = GetInventoryItems(); | 762 | m_items.LockItemsForRead(true); |
618 | 763 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | |
764 | m_items.LockItemsForRead(false); | ||
619 | foreach (TaskInventoryItem i in il) | 765 | foreach (TaskInventoryItem i in il) |
620 | { | 766 | { |
621 | if (i.Name == item.Name) | 767 | if (i.Name == item.Name) |
@@ -653,14 +799,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
653 | item.Name = name; | 799 | item.Name = name; |
654 | item.GroupID = m_part.GroupID; | 800 | item.GroupID = m_part.GroupID; |
655 | 801 | ||
656 | lock (m_items) | 802 | m_items.LockItemsForWrite(true); |
657 | m_items.Add(item.ItemID, item); | 803 | m_items.Add(item.ItemID, item); |
658 | 804 | m_items.LockItemsForWrite(false); | |
659 | if (allowedDrop) | 805 | if (allowedDrop) |
660 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 806 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
661 | else | 807 | else |
662 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 808 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
663 | 809 | ||
664 | m_inventorySerial++; | 810 | m_inventorySerial++; |
665 | //m_inventorySerial += 2; | 811 | //m_inventorySerial += 2; |
666 | HasInventoryChanged = true; | 812 | HasInventoryChanged = true; |
@@ -676,15 +822,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
676 | /// <param name="items"></param> | 822 | /// <param name="items"></param> |
677 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 823 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
678 | { | 824 | { |
679 | lock (m_items) | 825 | m_items.LockItemsForWrite(true); |
826 | foreach (TaskInventoryItem item in items) | ||
680 | { | 827 | { |
681 | foreach (TaskInventoryItem item in items) | 828 | m_items.Add(item.ItemID, item); |
682 | { | 829 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
683 | m_items.Add(item.ItemID, item); | ||
684 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
685 | } | ||
686 | m_inventorySerial++; | ||
687 | } | 830 | } |
831 | m_items.LockItemsForWrite(false); | ||
832 | |||
833 | m_inventorySerial++; | ||
688 | } | 834 | } |
689 | 835 | ||
690 | /// <summary> | 836 | /// <summary> |
@@ -695,23 +841,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
695 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 841 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
696 | { | 842 | { |
697 | TaskInventoryItem item; | 843 | TaskInventoryItem item; |
698 | 844 | m_items.LockItemsForRead(true); | |
699 | lock (m_items) | 845 | m_items.TryGetValue(itemId, out item); |
700 | m_items.TryGetValue(itemId, out item); | 846 | m_items.LockItemsForRead(false); |
701 | |||
702 | return item; | 847 | return item; |
703 | } | 848 | } |
704 | 849 | ||
705 | public TaskInventoryItem GetInventoryItem(string name) | 850 | public TaskInventoryItem GetInventoryItem(string name) |
706 | { | 851 | { |
707 | lock (m_items) | 852 | m_items.LockItemsForRead(true); |
853 | foreach (TaskInventoryItem item in m_items.Values) | ||
708 | { | 854 | { |
709 | foreach (TaskInventoryItem item in m_items.Values) | 855 | if (item.Name == name) |
710 | { | 856 | { |
711 | if (item.Name == name) | 857 | m_items.LockItemsForRead(false); |
712 | return item; | 858 | return item; |
713 | } | 859 | } |
714 | } | 860 | } |
861 | m_items.LockItemsForRead(false); | ||
715 | 862 | ||
716 | return null; | 863 | return null; |
717 | } | 864 | } |
@@ -720,15 +867,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
720 | { | 867 | { |
721 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 868 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
722 | 869 | ||
723 | lock (m_items) | 870 | m_items.LockItemsForRead(true); |
871 | |||
872 | foreach (TaskInventoryItem item in m_items.Values) | ||
724 | { | 873 | { |
725 | foreach (TaskInventoryItem item in m_items.Values) | 874 | if (item.Name == name) |
726 | { | 875 | items.Add(item); |
727 | if (item.Name == name) | ||
728 | items.Add(item); | ||
729 | } | ||
730 | } | 876 | } |
731 | 877 | ||
878 | m_items.LockItemsForRead(false); | ||
879 | |||
732 | return items; | 880 | return items; |
733 | } | 881 | } |
734 | 882 | ||
@@ -747,6 +895,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
747 | string xmlData = Utils.BytesToString(rezAsset.Data); | 895 | string xmlData = Utils.BytesToString(rezAsset.Data); |
748 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | 896 | SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); |
749 | 897 | ||
898 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
899 | group.RootPart.AttachOffset = group.AbsolutePosition; | ||
900 | group.RootPart.AttachRotation = group.GroupRotation; | ||
901 | |||
750 | group.ResetIDs(); | 902 | group.ResetIDs(); |
751 | 903 | ||
752 | SceneObjectPart rootPart = group.GetPart(group.UUID); | 904 | SceneObjectPart rootPart = group.GetPart(group.UUID); |
@@ -821,8 +973,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
821 | 973 | ||
822 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) | 974 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) |
823 | { | 975 | { |
824 | TaskInventoryItem it = GetInventoryItem(item.ItemID); | 976 | m_items.LockItemsForWrite(true); |
825 | if (it != null) | 977 | |
978 | if (m_items.ContainsKey(item.ItemID)) | ||
826 | { | 979 | { |
827 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); | 980 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); |
828 | 981 | ||
@@ -835,14 +988,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
835 | item.GroupID = m_part.GroupID; | 988 | item.GroupID = m_part.GroupID; |
836 | 989 | ||
837 | if (item.AssetID == UUID.Zero) | 990 | if (item.AssetID == UUID.Zero) |
838 | item.AssetID = it.AssetID; | 991 | item.AssetID = m_items[item.ItemID].AssetID; |
839 | 992 | ||
840 | lock (m_items) | 993 | m_items[item.ItemID] = item; |
841 | { | 994 | m_inventorySerial++; |
842 | m_items[item.ItemID] = item; | ||
843 | m_inventorySerial++; | ||
844 | } | ||
845 | |||
846 | if (fireScriptEvents) | 995 | if (fireScriptEvents) |
847 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 996 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
848 | 997 | ||
@@ -851,7 +1000,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
851 | HasInventoryChanged = true; | 1000 | HasInventoryChanged = true; |
852 | m_part.ParentGroup.HasGroupChanged = true; | 1001 | m_part.ParentGroup.HasGroupChanged = true; |
853 | } | 1002 | } |
854 | 1003 | m_items.LockItemsForWrite(false); | |
855 | return true; | 1004 | return true; |
856 | } | 1005 | } |
857 | else | 1006 | else |
@@ -862,8 +1011,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
862 | item.ItemID, m_part.Name, m_part.UUID, | 1011 | item.ItemID, m_part.Name, m_part.UUID, |
863 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 1012 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
864 | } | 1013 | } |
865 | return false; | 1014 | m_items.LockItemsForWrite(false); |
866 | 1015 | ||
1016 | return false; | ||
867 | } | 1017 | } |
868 | 1018 | ||
869 | /// <summary> | 1019 | /// <summary> |
@@ -874,43 +1024,59 @@ namespace OpenSim.Region.Framework.Scenes | |||
874 | /// in this prim's inventory.</returns> | 1024 | /// in this prim's inventory.</returns> |
875 | public int RemoveInventoryItem(UUID itemID) | 1025 | public int RemoveInventoryItem(UUID itemID) |
876 | { | 1026 | { |
877 | TaskInventoryItem item = GetInventoryItem(itemID); | 1027 | m_items.LockItemsForRead(true); |
878 | if (item != null) | 1028 | |
1029 | if (m_items.ContainsKey(itemID)) | ||
879 | { | 1030 | { |
880 | int type = m_items[itemID].InvType; | 1031 | int type = m_items[itemID].InvType; |
1032 | m_items.LockItemsForRead(false); | ||
881 | if (type == 10) // Script | 1033 | if (type == 10) // Script |
882 | { | 1034 | { |
883 | m_part.RemoveScriptEvents(itemID); | ||
884 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | 1035 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); |
885 | } | 1036 | } |
1037 | m_items.LockItemsForWrite(true); | ||
886 | m_items.Remove(itemID); | 1038 | m_items.Remove(itemID); |
1039 | m_items.LockItemsForWrite(false); | ||
887 | m_inventorySerial++; | 1040 | m_inventorySerial++; |
888 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 1041 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
889 | 1042 | ||
890 | HasInventoryChanged = true; | 1043 | HasInventoryChanged = true; |
891 | m_part.ParentGroup.HasGroupChanged = true; | 1044 | m_part.ParentGroup.HasGroupChanged = true; |
892 | 1045 | ||
893 | if (!ContainsScripts()) | 1046 | int scriptcount = 0; |
1047 | m_items.LockItemsForRead(true); | ||
1048 | foreach (TaskInventoryItem item in m_items.Values) | ||
1049 | { | ||
1050 | if (item.Type == 10) | ||
1051 | { | ||
1052 | scriptcount++; | ||
1053 | } | ||
1054 | } | ||
1055 | m_items.LockItemsForRead(false); | ||
1056 | |||
1057 | |||
1058 | if (scriptcount <= 0) | ||
1059 | { | ||
894 | m_part.RemFlag(PrimFlags.Scripted); | 1060 | m_part.RemFlag(PrimFlags.Scripted); |
1061 | } | ||
895 | 1062 | ||
896 | m_part.ScheduleFullUpdate(); | 1063 | m_part.ScheduleFullUpdate(); |
897 | 1064 | ||
898 | return type; | 1065 | return type; |
899 | |||
900 | } | 1066 | } |
901 | else | 1067 | else |
902 | { | 1068 | { |
1069 | m_items.LockItemsForRead(false); | ||
903 | m_log.ErrorFormat( | 1070 | m_log.ErrorFormat( |
904 | "[PRIM INVENTORY]: " + | 1071 | "[PRIM INVENTORY]: " + |
905 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 1072 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", |
906 | itemID, m_part.Name, m_part.UUID, | 1073 | itemID, m_part.Name, m_part.UUID); |
907 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
908 | } | 1074 | } |
909 | 1075 | ||
910 | return -1; | 1076 | return -1; |
911 | } | 1077 | } |
912 | 1078 | ||
913 | private bool CreateInventoryFile() | 1079 | private bool CreateInventoryFileName() |
914 | { | 1080 | { |
915 | // m_log.DebugFormat( | 1081 | // m_log.DebugFormat( |
916 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", | 1082 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", |
@@ -919,70 +1085,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
919 | if (m_inventoryFileName == String.Empty || | 1085 | if (m_inventoryFileName == String.Empty || |
920 | m_inventoryFileNameSerial < m_inventorySerial) | 1086 | m_inventoryFileNameSerial < m_inventorySerial) |
921 | { | 1087 | { |
922 | // Something changed, we need to create a new file | ||
923 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; | 1088 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; |
924 | m_inventoryFileNameSerial = m_inventorySerial; | 1089 | m_inventoryFileNameSerial = m_inventorySerial; |
925 | 1090 | ||
926 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | ||
927 | |||
928 | lock (m_items) | ||
929 | { | ||
930 | foreach (TaskInventoryItem item in m_items.Values) | ||
931 | { | ||
932 | // m_log.DebugFormat( | ||
933 | // "[PRIM INVENTORY]: Adding item {0} {1} for serial {2} on prim {3} {4} {5}", | ||
934 | // item.Name, item.ItemID, m_inventorySerial, m_part.Name, m_part.UUID, m_part.LocalId); | ||
935 | |||
936 | UUID ownerID = item.OwnerID; | ||
937 | uint everyoneMask = 0; | ||
938 | uint baseMask = item.BasePermissions; | ||
939 | uint ownerMask = item.CurrentPermissions; | ||
940 | uint groupMask = item.GroupPermissions; | ||
941 | |||
942 | invString.AddItemStart(); | ||
943 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | ||
944 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
945 | |||
946 | invString.AddPermissionsStart(); | ||
947 | |||
948 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | ||
949 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
950 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
951 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
952 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
953 | |||
954 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
955 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
956 | |||
957 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | ||
958 | |||
959 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | ||
960 | invString.AddSectionEnd(); | ||
961 | |||
962 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | ||
963 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | ||
964 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | ||
965 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
966 | |||
967 | invString.AddSaleStart(); | ||
968 | invString.AddNameValueLine("sale_type", "not"); | ||
969 | invString.AddNameValueLine("sale_price", "0"); | ||
970 | invString.AddSectionEnd(); | ||
971 | |||
972 | invString.AddNameValueLine("name", item.Name + "|"); | ||
973 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
974 | |||
975 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | ||
976 | invString.AddSectionEnd(); | ||
977 | } | ||
978 | } | ||
979 | |||
980 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | ||
981 | |||
982 | return true; | 1091 | return true; |
983 | } | 1092 | } |
984 | 1093 | ||
985 | // No need to recreate, the existing file is fine | ||
986 | return false; | 1094 | return false; |
987 | } | 1095 | } |
988 | 1096 | ||
@@ -992,43 +1100,110 @@ namespace OpenSim.Region.Framework.Scenes | |||
992 | /// <param name="xferManager"></param> | 1100 | /// <param name="xferManager"></param> |
993 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) | 1101 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) |
994 | { | 1102 | { |
995 | lock (m_items) | 1103 | bool changed = CreateInventoryFileName(); |
996 | { | ||
997 | // Don't send a inventory xfer name if there are no items. Doing so causes viewer 3 to crash when rezzing | ||
998 | // a new script if any previous deletion has left the prim inventory empty. | ||
999 | if (m_items.Count == 0) // No inventory | ||
1000 | { | ||
1001 | // m_log.DebugFormat( | ||
1002 | // "[PRIM INVENTORY]: Not sending inventory data for part {0} {1} {2} for {3} since no items", | ||
1003 | // m_part.Name, m_part.LocalId, m_part.UUID, client.Name); | ||
1004 | 1104 | ||
1005 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | 1105 | bool includeAssets = false; |
1006 | return; | 1106 | if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) |
1007 | } | 1107 | includeAssets = true; |
1108 | |||
1109 | if (m_inventoryPrivileged != includeAssets) | ||
1110 | changed = true; | ||
1111 | |||
1112 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | ||
1113 | |||
1114 | Items.LockItemsForRead(true); | ||
1115 | |||
1116 | if (m_inventorySerial == 0) // No inventory | ||
1117 | { | ||
1118 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1119 | Items.LockItemsForRead(false); | ||
1120 | return; | ||
1121 | } | ||
1008 | 1122 | ||
1009 | CreateInventoryFile(); | 1123 | if (m_items.Count == 0) // No inventory |
1124 | { | ||
1125 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1126 | Items.LockItemsForRead(false); | ||
1127 | return; | ||
1128 | } | ||
1010 | 1129 | ||
1011 | // In principle, we should only do the rest if the inventory changed; | 1130 | if (!changed) |
1012 | // by sending m_inventorySerial to the client, it ought to know | 1131 | { |
1013 | // that nothing changed and that it doesn't need to request the file. | ||
1014 | // Unfortunately, it doesn't look like the client optimizes this; | ||
1015 | // the client seems to always come back and request the Xfer, | ||
1016 | // no matter what value m_inventorySerial has. | ||
1017 | // FIXME: Could probably be > 0 here rather than > 2 | ||
1018 | if (m_inventoryFileData.Length > 2) | 1132 | if (m_inventoryFileData.Length > 2) |
1019 | { | 1133 | { |
1020 | // Add the file for Xfer | 1134 | xferManager.AddNewFile(m_inventoryFileName, |
1021 | // m_log.DebugFormat( | 1135 | m_inventoryFileData); |
1022 | // "[PRIM INVENTORY]: Adding inventory file {0} (length {1}) for transfer on {2} {3} {4}", | 1136 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, |
1023 | // m_inventoryFileName, m_inventoryFileData.Length, m_part.Name, m_part.UUID, m_part.LocalId); | 1137 | Util.StringToBytes256(m_inventoryFileName)); |
1024 | 1138 | ||
1025 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | 1139 | Items.LockItemsForRead(false); |
1140 | return; | ||
1026 | } | 1141 | } |
1027 | |||
1028 | // Tell the client we're ready to Xfer the file | ||
1029 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
1030 | Util.StringToBytes256(m_inventoryFileName)); | ||
1031 | } | 1142 | } |
1143 | |||
1144 | m_inventoryPrivileged = includeAssets; | ||
1145 | |||
1146 | foreach (TaskInventoryItem item in m_items.Values) | ||
1147 | { | ||
1148 | UUID ownerID = item.OwnerID; | ||
1149 | uint everyoneMask = 0; | ||
1150 | uint baseMask = item.BasePermissions; | ||
1151 | uint ownerMask = item.CurrentPermissions; | ||
1152 | uint groupMask = item.GroupPermissions; | ||
1153 | |||
1154 | invString.AddItemStart(); | ||
1155 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | ||
1156 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
1157 | |||
1158 | invString.AddPermissionsStart(); | ||
1159 | |||
1160 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | ||
1161 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
1162 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
1163 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
1164 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
1165 | |||
1166 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
1167 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
1168 | |||
1169 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | ||
1170 | |||
1171 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | ||
1172 | invString.AddSectionEnd(); | ||
1173 | |||
1174 | if (includeAssets) | ||
1175 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | ||
1176 | else | ||
1177 | invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); | ||
1178 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | ||
1179 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | ||
1180 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
1181 | |||
1182 | invString.AddSaleStart(); | ||
1183 | invString.AddNameValueLine("sale_type", "not"); | ||
1184 | invString.AddNameValueLine("sale_price", "0"); | ||
1185 | invString.AddSectionEnd(); | ||
1186 | |||
1187 | invString.AddNameValueLine("name", item.Name + "|"); | ||
1188 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
1189 | |||
1190 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | ||
1191 | invString.AddSectionEnd(); | ||
1192 | } | ||
1193 | |||
1194 | Items.LockItemsForRead(false); | ||
1195 | |||
1196 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | ||
1197 | |||
1198 | if (m_inventoryFileData.Length > 2) | ||
1199 | { | ||
1200 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | ||
1201 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
1202 | Util.StringToBytes256(m_inventoryFileName)); | ||
1203 | return; | ||
1204 | } | ||
1205 | |||
1206 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1032 | } | 1207 | } |
1033 | 1208 | ||
1034 | /// <summary> | 1209 | /// <summary> |
@@ -1037,13 +1212,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1037 | /// <param name="datastore"></param> | 1212 | /// <param name="datastore"></param> |
1038 | public void ProcessInventoryBackup(ISimulationDataService datastore) | 1213 | public void ProcessInventoryBackup(ISimulationDataService datastore) |
1039 | { | 1214 | { |
1040 | if (HasInventoryChanged) | 1215 | // Removed this because linking will cause an immediate delete of the new |
1041 | { | 1216 | // child prim from the database and the subsequent storing of the prim sees |
1042 | HasInventoryChanged = false; | 1217 | // the inventory of it as unchanged and doesn't store it at all. The overhead |
1043 | List<TaskInventoryItem> items = GetInventoryItems(); | 1218 | // of storing prim inventory needlessly is much less than the aggravation |
1044 | datastore.StorePrimInventory(m_part.UUID, items); | 1219 | // of prim inventory loss. |
1220 | // if (HasInventoryChanged) | ||
1221 | // { | ||
1222 | Items.LockItemsForRead(true); | ||
1223 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | ||
1224 | Items.LockItemsForRead(false); | ||
1045 | 1225 | ||
1046 | } | 1226 | HasInventoryChanged = false; |
1227 | // } | ||
1047 | } | 1228 | } |
1048 | 1229 | ||
1049 | public class InventoryStringBuilder | 1230 | public class InventoryStringBuilder |
@@ -1109,87 +1290,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
1109 | { | 1290 | { |
1110 | uint mask=0x7fffffff; | 1291 | uint mask=0x7fffffff; |
1111 | 1292 | ||
1112 | lock (m_items) | 1293 | foreach (TaskInventoryItem item in m_items.Values) |
1113 | { | 1294 | { |
1114 | foreach (TaskInventoryItem item in m_items.Values) | 1295 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) |
1296 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1297 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1298 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1299 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1300 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1301 | |||
1302 | if (item.InvType == (int)InventoryType.Object) | ||
1115 | { | 1303 | { |
1116 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | 1304 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1117 | mask &= ~((uint)PermissionMask.Copy >> 13); | 1305 | mask &= ~((uint)PermissionMask.Copy >> 13); |
1118 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | 1306 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1119 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1307 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
1120 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | 1308 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1121 | mask &= ~((uint)PermissionMask.Modify >> 13); | 1309 | mask &= ~((uint)PermissionMask.Modify >> 13); |
1122 | |||
1123 | if (item.InvType != (int)InventoryType.Object) | ||
1124 | { | ||
1125 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | ||
1126 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1127 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1128 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1129 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1130 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1131 | } | ||
1132 | else | ||
1133 | { | ||
1134 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1135 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1136 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1137 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1138 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1139 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1140 | } | ||
1141 | |||
1142 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1143 | mask &= ~(uint)PermissionMask.Copy; | ||
1144 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1145 | mask &= ~(uint)PermissionMask.Transfer; | ||
1146 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1147 | mask &= ~(uint)PermissionMask.Modify; | ||
1148 | } | 1310 | } |
1311 | |||
1312 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1313 | mask &= ~(uint)PermissionMask.Copy; | ||
1314 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1315 | mask &= ~(uint)PermissionMask.Transfer; | ||
1316 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1317 | mask &= ~(uint)PermissionMask.Modify; | ||
1149 | } | 1318 | } |
1150 | |||
1151 | return mask; | 1319 | return mask; |
1152 | } | 1320 | } |
1153 | 1321 | ||
1154 | public void ApplyNextOwnerPermissions() | 1322 | public void ApplyNextOwnerPermissions() |
1155 | { | 1323 | { |
1156 | lock (m_items) | 1324 | foreach (TaskInventoryItem item in m_items.Values) |
1157 | { | 1325 | { |
1158 | foreach (TaskInventoryItem item in m_items.Values) | 1326 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) |
1159 | { | 1327 | { |
1160 | // m_log.DebugFormat ( | 1328 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1161 | // "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", | 1329 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |
1162 | // item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); | 1330 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1163 | 1331 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | |
1164 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) | 1332 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1165 | { | 1333 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
1166 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) | ||
1167 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; | ||
1168 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) | ||
1169 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | ||
1170 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) | ||
1171 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; | ||
1172 | } | ||
1173 | |||
1174 | item.CurrentPermissions &= item.NextPermissions; | ||
1175 | item.BasePermissions &= item.NextPermissions; | ||
1176 | item.EveryonePermissions &= item.NextPermissions; | ||
1177 | item.OwnerChanged = true; | ||
1178 | item.PermsMask = 0; | ||
1179 | item.PermsGranter = UUID.Zero; | ||
1180 | } | 1334 | } |
1335 | item.CurrentPermissions &= item.NextPermissions; | ||
1336 | item.BasePermissions &= item.NextPermissions; | ||
1337 | item.EveryonePermissions &= item.NextPermissions; | ||
1338 | item.OwnerChanged = true; | ||
1339 | item.PermsMask = 0; | ||
1340 | item.PermsGranter = UUID.Zero; | ||
1181 | } | 1341 | } |
1182 | } | 1342 | } |
1183 | 1343 | ||
1184 | public void ApplyGodPermissions(uint perms) | 1344 | public void ApplyGodPermissions(uint perms) |
1185 | { | 1345 | { |
1186 | lock (m_items) | 1346 | foreach (TaskInventoryItem item in m_items.Values) |
1187 | { | 1347 | { |
1188 | foreach (TaskInventoryItem item in m_items.Values) | 1348 | item.CurrentPermissions = perms; |
1189 | { | 1349 | item.BasePermissions = perms; |
1190 | item.CurrentPermissions = perms; | ||
1191 | item.BasePermissions = perms; | ||
1192 | } | ||
1193 | } | 1350 | } |
1194 | 1351 | ||
1195 | m_inventorySerial++; | 1352 | m_inventorySerial++; |
@@ -1202,14 +1359,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1202 | /// <returns></returns> | 1359 | /// <returns></returns> |
1203 | public bool ContainsScripts() | 1360 | public bool ContainsScripts() |
1204 | { | 1361 | { |
1205 | lock (m_items) | 1362 | foreach (TaskInventoryItem item in m_items.Values) |
1206 | { | 1363 | { |
1207 | foreach (TaskInventoryItem item in m_items.Values) | 1364 | if (item.InvType == (int)InventoryType.LSL) |
1208 | { | 1365 | { |
1209 | if (item.InvType == (int)InventoryType.LSL) | 1366 | return true; |
1210 | { | ||
1211 | return true; | ||
1212 | } | ||
1213 | } | 1367 | } |
1214 | } | 1368 | } |
1215 | 1369 | ||
@@ -1223,17 +1377,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1223 | public int ScriptCount() | 1377 | public int ScriptCount() |
1224 | { | 1378 | { |
1225 | int count = 0; | 1379 | int count = 0; |
1226 | lock (m_items) | 1380 | Items.LockItemsForRead(true); |
1381 | foreach (TaskInventoryItem item in m_items.Values) | ||
1227 | { | 1382 | { |
1228 | foreach (TaskInventoryItem item in m_items.Values) | 1383 | if (item.InvType == (int)InventoryType.LSL) |
1229 | { | 1384 | { |
1230 | if (item.InvType == (int)InventoryType.LSL) | 1385 | count++; |
1231 | { | ||
1232 | count++; | ||
1233 | } | ||
1234 | } | 1386 | } |
1235 | } | 1387 | } |
1236 | 1388 | Items.LockItemsForRead(false); | |
1237 | return count; | 1389 | return count; |
1238 | } | 1390 | } |
1239 | /// <summary> | 1391 | /// <summary> |
@@ -1269,11 +1421,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1269 | { | 1421 | { |
1270 | List<UUID> ret = new List<UUID>(); | 1422 | List<UUID> ret = new List<UUID>(); |
1271 | 1423 | ||
1272 | lock (m_items) | 1424 | foreach (TaskInventoryItem item in m_items.Values) |
1273 | { | 1425 | ret.Add(item.ItemID); |
1274 | foreach (TaskInventoryItem item in m_items.Values) | ||
1275 | ret.Add(item.ItemID); | ||
1276 | } | ||
1277 | 1426 | ||
1278 | return ret; | 1427 | return ret; |
1279 | } | 1428 | } |
@@ -1282,8 +1431,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1282 | { | 1431 | { |
1283 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1432 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1284 | 1433 | ||
1285 | lock (m_items) | 1434 | Items.LockItemsForRead(true); |
1286 | ret = new List<TaskInventoryItem>(m_items.Values); | 1435 | ret = new List<TaskInventoryItem>(m_items.Values); |
1436 | Items.LockItemsForRead(false); | ||
1287 | 1437 | ||
1288 | return ret; | 1438 | return ret; |
1289 | } | 1439 | } |
@@ -1292,18 +1442,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1292 | { | 1442 | { |
1293 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1443 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1294 | 1444 | ||
1295 | lock (m_items) | 1445 | Items.LockItemsForRead(true); |
1296 | { | 1446 | |
1297 | foreach (TaskInventoryItem item in m_items.Values) | 1447 | foreach (TaskInventoryItem item in m_items.Values) |
1298 | if (item.InvType == (int)type) | 1448 | if (item.InvType == (int)type) |
1299 | ret.Add(item); | 1449 | ret.Add(item); |
1300 | } | 1450 | |
1451 | Items.LockItemsForRead(false); | ||
1301 | 1452 | ||
1302 | return ret; | 1453 | return ret; |
1303 | } | 1454 | } |
1304 | 1455 | ||
1305 | public Dictionary<UUID, string> GetScriptStates() | 1456 | public Dictionary<UUID, string> GetScriptStates() |
1306 | { | 1457 | { |
1458 | return GetScriptStates(false); | ||
1459 | } | ||
1460 | |||
1461 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1462 | { | ||
1307 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1463 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
1308 | 1464 | ||
1309 | if (m_part.ParentGroup.Scene == null) // Group not in a scene | 1465 | if (m_part.ParentGroup.Scene == null) // Group not in a scene |
@@ -1329,14 +1485,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1329 | string n = e.GetXMLState(item.ItemID); | 1485 | string n = e.GetXMLState(item.ItemID); |
1330 | if (n != String.Empty) | 1486 | if (n != String.Empty) |
1331 | { | 1487 | { |
1332 | if (!ret.ContainsKey(item.ItemID)) | 1488 | if (oldIDs) |
1333 | ret[item.ItemID] = n; | 1489 | { |
1490 | if (!ret.ContainsKey(item.OldItemID)) | ||
1491 | ret[item.OldItemID] = n; | ||
1492 | } | ||
1493 | else | ||
1494 | { | ||
1495 | if (!ret.ContainsKey(item.ItemID)) | ||
1496 | ret[item.ItemID] = n; | ||
1497 | } | ||
1334 | break; | 1498 | break; |
1335 | } | 1499 | } |
1336 | } | 1500 | } |
1337 | } | 1501 | } |
1338 | } | 1502 | } |
1339 | |||
1340 | return ret; | 1503 | return ret; |
1341 | } | 1504 | } |
1342 | 1505 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6e41774..c352465 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. |
@@ -139,6 +140,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
139 | private Vector3 m_lastPosition; | 140 | private Vector3 m_lastPosition; |
140 | private Quaternion m_lastRotation; | 141 | private Quaternion m_lastRotation; |
141 | private Vector3 m_lastVelocity; | 142 | private Vector3 m_lastVelocity; |
143 | private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); | ||
144 | |||
142 | 145 | ||
143 | private Vector3? m_forceToApply; | 146 | private Vector3? m_forceToApply; |
144 | private int m_userFlags; | 147 | private int m_userFlags; |
@@ -171,6 +174,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
171 | // private int m_lastColCount = -1; //KF: Look for Collision chnages | 174 | // private int m_lastColCount = -1; //KF: Look for Collision chnages |
172 | // private int m_updateCount = 0; //KF: Update Anims for a while | 175 | // private int m_updateCount = 0; //KF: Update Anims for a while |
173 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 176 | // private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
177 | private List<uint> m_lastColliders = new List<uint>(); | ||
174 | 178 | ||
175 | private TeleportFlags m_teleportFlags; | 179 | private TeleportFlags m_teleportFlags; |
176 | public TeleportFlags TeleportFlags | 180 | public TeleportFlags TeleportFlags |
@@ -226,8 +230,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
226 | /// </summary> | 230 | /// </summary> |
227 | public bool LandAtTarget { get; private set; } | 231 | public bool LandAtTarget { get; private set; } |
228 | 232 | ||
229 | private bool m_followCamAuto; | ||
230 | |||
231 | private int m_movementUpdateCount; | 233 | private int m_movementUpdateCount; |
232 | private const int NumMovementsBetweenRayCast = 5; | 234 | private const int NumMovementsBetweenRayCast = 5; |
233 | 235 | ||
@@ -235,6 +237,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
235 | //private int m_moveToPositionStateStatus; | 237 | //private int m_moveToPositionStateStatus; |
236 | //***************************************************** | 238 | //***************************************************** |
237 | 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 | |||
238 | protected AvatarAppearance m_appearance; | 247 | protected AvatarAppearance m_appearance; |
239 | 248 | ||
240 | public AvatarAppearance Appearance | 249 | public AvatarAppearance Appearance |
@@ -349,6 +358,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
349 | /// </summary> | 358 | /// </summary> |
350 | protected Vector3 m_lastCameraPosition; | 359 | protected Vector3 m_lastCameraPosition; |
351 | 360 | ||
361 | private Vector4 m_lastCameraCollisionPlane = new Vector4(0f, 0f, 0f, 1); | ||
362 | private bool m_doingCamRayCast = false; | ||
363 | |||
352 | public Vector3 CameraPosition { get; set; } | 364 | public Vector3 CameraPosition { get; set; } |
353 | 365 | ||
354 | public Quaternion CameraRotation | 366 | public Quaternion CameraRotation |
@@ -429,7 +441,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
429 | get { return (IClientCore)ControllingClient; } | 441 | get { return (IClientCore)ControllingClient; } |
430 | } | 442 | } |
431 | 443 | ||
432 | public Vector3 ParentPosition { get; set; } | 444 | // public Vector3 ParentPosition { get; set; } |
433 | 445 | ||
434 | /// <summary> | 446 | /// <summary> |
435 | /// Position of this avatar relative to the region the avatar is in | 447 | /// Position of this avatar relative to the region the avatar is in |
@@ -487,7 +499,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
487 | if (ParentID == 0) | 499 | if (ParentID == 0) |
488 | { | 500 | { |
489 | m_pos = value; | 501 | m_pos = value; |
490 | ParentPosition = Vector3.Zero; | 502 | // ParentPosition = Vector3.Zero; |
491 | } | 503 | } |
492 | 504 | ||
493 | //m_log.DebugFormat( | 505 | //m_log.DebugFormat( |
@@ -556,7 +568,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
556 | // Scene.RegionInfo.RegionName, Name, m_velocity); | 568 | // Scene.RegionInfo.RegionName, Name, m_velocity); |
557 | } | 569 | } |
558 | } | 570 | } |
571 | /* | ||
572 | public override Vector3 AngularVelocity | ||
573 | { | ||
574 | get | ||
575 | { | ||
576 | if (PhysicsActor != null) | ||
577 | { | ||
578 | m_rotationalvelocity = PhysicsActor.RotationalVelocity; | ||
579 | |||
580 | // m_log.DebugFormat( | ||
581 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", | ||
582 | // m_velocity, Name, Scene.RegionInfo.RegionName); | ||
583 | } | ||
559 | 584 | ||
585 | return m_rotationalvelocity; | ||
586 | } | ||
587 | } | ||
588 | */ | ||
560 | private Quaternion m_bodyRot = Quaternion.Identity; | 589 | private Quaternion m_bodyRot = Quaternion.Identity; |
561 | 590 | ||
562 | public Quaternion Rotation | 591 | public Quaternion Rotation |
@@ -567,7 +596,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
567 | m_bodyRot = value; | 596 | m_bodyRot = value; |
568 | if (PhysicsActor != null) | 597 | if (PhysicsActor != null) |
569 | { | 598 | { |
570 | PhysicsActor.Orientation = m_bodyRot; | 599 | try |
600 | { | ||
601 | PhysicsActor.Orientation = m_bodyRot; | ||
602 | } | ||
603 | catch (Exception e) | ||
604 | { | ||
605 | m_log.Error("[SCENE PRESENCE]: Orientation " + e.Message); | ||
606 | } | ||
571 | } | 607 | } |
572 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); | 608 | // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); |
573 | } | 609 | } |
@@ -582,12 +618,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
582 | } | 618 | } |
583 | 619 | ||
584 | public bool IsChildAgent { get; set; } | 620 | public bool IsChildAgent { get; set; } |
621 | public bool IsLoggingIn { get; set; } | ||
585 | 622 | ||
586 | /// <summary> | 623 | /// <summary> |
587 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. | 624 | /// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero. |
588 | /// </summary> | 625 | /// </summary> |
589 | public uint ParentID { get; set; } | 626 | public uint ParentID { get; set; } |
590 | 627 | ||
628 | public UUID ParentUUID | ||
629 | { | ||
630 | get { return m_parentUUID; } | ||
631 | set { m_parentUUID = value; } | ||
632 | } | ||
633 | private UUID m_parentUUID = UUID.Zero; | ||
634 | |||
591 | /// <summary> | 635 | /// <summary> |
592 | /// Are we sitting on an object? | 636 | /// Are we sitting on an object? |
593 | /// </summary> | 637 | /// </summary> |
@@ -713,6 +757,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
713 | AttachmentsSyncLock = new Object(); | 757 | AttachmentsSyncLock = new Object(); |
714 | AllowMovement = true; | 758 | AllowMovement = true; |
715 | IsChildAgent = true; | 759 | IsChildAgent = true; |
760 | IsLoggingIn = false; | ||
716 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; | 761 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; |
717 | Animator = new ScenePresenceAnimator(this); | 762 | Animator = new ScenePresenceAnimator(this); |
718 | PresenceType = type; | 763 | PresenceType = type; |
@@ -756,6 +801,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
756 | Appearance = appearance; | 801 | Appearance = appearance; |
757 | } | 802 | } |
758 | 803 | ||
804 | private void RegionHeartbeatEnd(Scene scene) | ||
805 | { | ||
806 | if (IsChildAgent) | ||
807 | return; | ||
808 | |||
809 | m_movementAnimationUpdateCounter ++; | ||
810 | if (m_movementAnimationUpdateCounter >= 2) | ||
811 | { | ||
812 | m_movementAnimationUpdateCounter = 0; | ||
813 | if (Animator != null) | ||
814 | { | ||
815 | // If the parentID == 0 we are not sitting | ||
816 | // if !SitGournd then we are not sitting on the ground | ||
817 | // Fairly straightforward, now here comes the twist | ||
818 | // if ParentUUID is NOT UUID.Zero, we are looking to | ||
819 | // be sat on an object that isn't there yet. Should | ||
820 | // be treated as if sat. | ||
821 | if(ParentID == 0 && !SitGround && ParentUUID == UUID.Zero) // skip it if sitting | ||
822 | Animator.UpdateMovementAnimations(); | ||
823 | } | ||
824 | else | ||
825 | { | ||
826 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
827 | } | ||
828 | } | ||
829 | } | ||
830 | |||
759 | public void RegisterToEvents() | 831 | public void RegisterToEvents() |
760 | { | 832 | { |
761 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; | 833 | ControllingClient.OnCompleteMovementToRegion += CompleteMovement; |
@@ -765,8 +837,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
765 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 837 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
766 | ControllingClient.OnStartAnim += HandleStartAnim; | 838 | ControllingClient.OnStartAnim += HandleStartAnim; |
767 | ControllingClient.OnStopAnim += HandleStopAnim; | 839 | ControllingClient.OnStopAnim += HandleStopAnim; |
840 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
768 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 841 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
769 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 842 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
843 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
770 | 844 | ||
771 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 845 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
772 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 846 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -825,10 +899,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
825 | "[SCENE]: Upgrading child to root agent for {0} in {1}", | 899 | "[SCENE]: Upgrading child to root agent for {0} in {1}", |
826 | Name, m_scene.RegionInfo.RegionName); | 900 | Name, m_scene.RegionInfo.RegionName); |
827 | 901 | ||
828 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | ||
829 | |||
830 | bool wasChild = IsChildAgent; | 902 | bool wasChild = IsChildAgent; |
831 | IsChildAgent = false; | 903 | |
904 | if (ParentUUID != UUID.Zero) | ||
905 | { | ||
906 | m_log.DebugFormat("[SCENE PRESENCE]: Sitting avatar back on prim {0}", ParentUUID); | ||
907 | SceneObjectPart part = m_scene.GetSceneObjectPart(ParentUUID); | ||
908 | if (part == null) | ||
909 | { | ||
910 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | ||
911 | } | ||
912 | else | ||
913 | { | ||
914 | part.ParentGroup.AddAvatar(UUID); | ||
915 | if (part.SitTargetPosition != Vector3.Zero) | ||
916 | part.SitTargetAvatar = UUID; | ||
917 | // ParentPosition = part.GetWorldPosition(); | ||
918 | ParentID = part.LocalId; | ||
919 | ParentPart = part; | ||
920 | m_pos = m_prevSitOffset; | ||
921 | // pos = ParentPosition; | ||
922 | pos = part.GetWorldPosition(); | ||
923 | } | ||
924 | ParentUUID = UUID.Zero; | ||
925 | |||
926 | IsChildAgent = false; | ||
927 | |||
928 | // Animator.TrySetMovementAnimation("SIT"); | ||
929 | } | ||
930 | else | ||
931 | { | ||
932 | IsChildAgent = false; | ||
933 | IsLoggingIn = false; | ||
934 | } | ||
935 | |||
832 | 936 | ||
833 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 937 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
834 | if (gm != null) | 938 | if (gm != null) |
@@ -838,62 +942,99 @@ namespace OpenSim.Region.Framework.Scenes | |||
838 | 942 | ||
839 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 943 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
840 | 944 | ||
841 | // Moved this from SendInitialData to ensure that Appearance is initialized | 945 | UUID groupUUID = UUID.Zero; |
842 | // before the inventory is processed in MakeRootAgent. This fixes a race condition | 946 | string GroupName = string.Empty; |
843 | // related to the handling of attachments | 947 | ulong groupPowers = 0; |
844 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | 948 | |
845 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | 949 | // ---------------------------------- |
950 | // Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status | ||
951 | try | ||
846 | { | 952 | { |
847 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | 953 | if (gm != null) |
848 | pos.X = crossedBorder.BorderLine.Z - 1; | 954 | { |
955 | groupUUID = ControllingClient.ActiveGroupId; | ||
956 | GroupRecord record = gm.GetGroupRecord(groupUUID); | ||
957 | if (record != null) | ||
958 | GroupName = record.GroupName; | ||
959 | GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid); | ||
960 | if (groupMembershipData != null) | ||
961 | groupPowers = groupMembershipData.GroupPowers; | ||
962 | } | ||
963 | ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName, | ||
964 | Grouptitle); | ||
849 | } | 965 | } |
850 | 966 | catch (Exception e) | |
851 | if (m_scene.TestBorderCross(pos, Cardinals.N)) | ||
852 | { | 967 | { |
853 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); | 968 | m_log.Debug("[AGENTUPDATE]: " + e.ToString()); |
854 | pos.Y = crossedBorder.BorderLine.Z - 1; | ||
855 | } | 969 | } |
970 | // ------------------------------------ | ||
856 | 971 | ||
857 | CheckAndAdjustLandingPoint(ref pos); | 972 | if (ParentID == 0) |
858 | |||
859 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | ||
860 | { | 973 | { |
861 | m_log.WarnFormat( | 974 | // Moved this from SendInitialData to ensure that Appearance is initialized |
862 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | 975 | // before the inventory is processed in MakeRootAgent. This fixes a race condition |
863 | pos, Name, UUID); | 976 | // related to the handling of attachments |
977 | //m_scene.GetAvatarAppearance(ControllingClient, out Appearance); | ||
978 | if (m_scene.TestBorderCross(pos, Cardinals.E)) | ||
979 | { | ||
980 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.E); | ||
981 | pos.X = crossedBorder.BorderLine.Z - 1; | ||
982 | } | ||
864 | 983 | ||
865 | if (pos.X < 0f) pos.X = 0f; | 984 | if (m_scene.TestBorderCross(pos, Cardinals.N)) |
866 | if (pos.Y < 0f) pos.Y = 0f; | 985 | { |
867 | if (pos.Z < 0f) pos.Z = 0f; | 986 | Border crossedBorder = m_scene.GetCrossedBorder(pos, Cardinals.N); |
868 | } | 987 | pos.Y = crossedBorder.BorderLine.Z - 1; |
988 | } | ||
869 | 989 | ||
870 | float localAVHeight = 1.56f; | 990 | CheckAndAdjustLandingPoint(ref pos); |
871 | if (Appearance.AvatarHeight > 0) | ||
872 | localAVHeight = Appearance.AvatarHeight; | ||
873 | 991 | ||
874 | float posZLimit = 0; | 992 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
993 | { | ||
994 | m_log.WarnFormat( | ||
995 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", | ||
996 | pos, Name, UUID); | ||
875 | 997 | ||
876 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | 998 | if (pos.X < 0f) pos.X = 0f; |
877 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 999 | if (pos.Y < 0f) pos.Y = 0f; |
878 | 1000 | if (pos.Z < 0f) pos.Z = 0f; | |
879 | float newPosZ = posZLimit + localAVHeight / 2; | 1001 | } |
880 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
881 | { | ||
882 | pos.Z = newPosZ; | ||
883 | } | ||
884 | AbsolutePosition = pos; | ||
885 | 1002 | ||
886 | AddToPhysicalScene(isFlying); | 1003 | float localAVHeight = 1.56f; |
1004 | if (Appearance.AvatarHeight > 0) | ||
1005 | localAVHeight = Appearance.AvatarHeight; | ||
887 | 1006 | ||
888 | if (ForceFly) | 1007 | float posZLimit = 0; |
889 | { | ||
890 | Flying = true; | ||
891 | } | ||
892 | else if (FlyDisabled) | ||
893 | { | ||
894 | Flying = false; | ||
895 | } | ||
896 | 1008 | ||
1009 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) | ||
1010 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | ||
1011 | |||
1012 | float newPosZ = posZLimit + localAVHeight / 2; | ||
1013 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
1014 | { | ||
1015 | pos.Z = newPosZ; | ||
1016 | } | ||
1017 | AbsolutePosition = pos; | ||
1018 | |||
1019 | if (m_teleportFlags == TeleportFlags.Default) | ||
1020 | { | ||
1021 | Vector3 vel = Velocity; | ||
1022 | AddToPhysicalScene(isFlying); | ||
1023 | if (PhysicsActor != null) | ||
1024 | PhysicsActor.SetMomentum(vel); | ||
1025 | } | ||
1026 | else | ||
1027 | AddToPhysicalScene(isFlying); | ||
1028 | |||
1029 | if (ForceFly) | ||
1030 | { | ||
1031 | Flying = true; | ||
1032 | } | ||
1033 | else if (FlyDisabled) | ||
1034 | { | ||
1035 | Flying = false; | ||
1036 | } | ||
1037 | } | ||
897 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 1038 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
898 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent | 1039 | // avatar to return to the standing position in mid-air. On login it looks like this is being sent |
899 | // elsewhere anyway | 1040 | // elsewhere anyway |
@@ -913,14 +1054,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
913 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | 1054 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); |
914 | 1055 | ||
915 | // Resume scripts | 1056 | // Resume scripts |
916 | foreach (SceneObjectGroup sog in m_attachments) | 1057 | Util.FireAndForget(delegate(object x) { |
917 | { | 1058 | foreach (SceneObjectGroup sog in m_attachments) |
918 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | 1059 | { |
919 | sog.ResumeScripts(); | 1060 | sog.ScheduleGroupForFullUpdate(); |
920 | } | 1061 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); |
1062 | sog.ResumeScripts(); | ||
1063 | } | ||
1064 | }); | ||
921 | } | 1065 | } |
922 | } | 1066 | } |
923 | 1067 | ||
1068 | SendAvatarDataToAllAgents(); | ||
1069 | |||
924 | // send the animations of the other presences to me | 1070 | // send the animations of the other presences to me |
925 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) | 1071 | m_scene.ForEachRootScenePresence(delegate(ScenePresence presence) |
926 | { | 1072 | { |
@@ -931,9 +1077,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
931 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1077 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
932 | // stall on the border crossing since the existing child agent will still have the last movement | 1078 | // stall on the border crossing since the existing child agent will still have the last movement |
933 | // recorded, which stops the input from being processed. | 1079 | // recorded, which stops the input from being processed. |
1080 | |||
934 | MovementFlag = 0; | 1081 | MovementFlag = 0; |
935 | 1082 | ||
936 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1083 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1084 | |||
1085 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
937 | } | 1086 | } |
938 | 1087 | ||
939 | public int GetStateSource() | 1088 | public int GetStateSource() |
@@ -961,12 +1110,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
961 | /// </remarks> | 1110 | /// </remarks> |
962 | public void MakeChildAgent() | 1111 | public void MakeChildAgent() |
963 | { | 1112 | { |
1113 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
1114 | |||
964 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1115 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); |
965 | 1116 | ||
966 | // Reset these so that teleporting in and walking out isn't seen | 1117 | // Reset these so that teleporting in and walking out isn't seen |
967 | // as teleporting back | 1118 | // as teleporting back |
968 | TeleportFlags = TeleportFlags.Default; | 1119 | TeleportFlags = TeleportFlags.Default; |
969 | 1120 | ||
1121 | MovementFlag = 0; | ||
1122 | |||
970 | // It looks like Animator is set to null somewhere, and MakeChild | 1123 | // It looks like Animator is set to null somewhere, and MakeChild |
971 | // is called after that. Probably in aborted teleports. | 1124 | // is called after that. Probably in aborted teleports. |
972 | if (Animator == null) | 1125 | if (Animator == null) |
@@ -974,6 +1127,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
974 | else | 1127 | else |
975 | Animator.ResetAnimations(); | 1128 | Animator.ResetAnimations(); |
976 | 1129 | ||
1130 | |||
977 | // m_log.DebugFormat( | 1131 | // m_log.DebugFormat( |
978 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1132 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
979 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1133 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -985,6 +1139,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
985 | IsChildAgent = true; | 1139 | IsChildAgent = true; |
986 | m_scene.SwapRootAgentCount(true); | 1140 | m_scene.SwapRootAgentCount(true); |
987 | RemoveFromPhysicalScene(); | 1141 | RemoveFromPhysicalScene(); |
1142 | ParentID = 0; // Child agents can't be sitting | ||
988 | 1143 | ||
989 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1144 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
990 | 1145 | ||
@@ -1000,9 +1155,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1000 | { | 1155 | { |
1001 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; | 1156 | // PhysicsActor.OnRequestTerseUpdate -= SendTerseUpdateToAllClients; |
1002 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; | 1157 | PhysicsActor.OnOutOfBounds -= OutOfBoundsCall; |
1003 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1004 | PhysicsActor.UnSubscribeEvents(); | ||
1005 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; | 1158 | PhysicsActor.OnCollisionUpdate -= PhysicsCollisionUpdate; |
1159 | PhysicsActor.UnSubscribeEvents(); | ||
1160 | m_scene.PhysicsScene.RemoveAvatar(PhysicsActor); | ||
1006 | PhysicsActor = null; | 1161 | PhysicsActor = null; |
1007 | } | 1162 | } |
1008 | // else | 1163 | // else |
@@ -1019,7 +1174,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1019 | /// <param name="pos"></param> | 1174 | /// <param name="pos"></param> |
1020 | public void Teleport(Vector3 pos) | 1175 | public void Teleport(Vector3 pos) |
1021 | { | 1176 | { |
1022 | TeleportWithMomentum(pos, null); | 1177 | TeleportWithMomentum(pos, Vector3.Zero); |
1023 | } | 1178 | } |
1024 | 1179 | ||
1025 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1180 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1043,6 +1198,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1043 | SendTerseUpdateToAllClients(); | 1198 | SendTerseUpdateToAllClients(); |
1044 | } | 1199 | } |
1045 | 1200 | ||
1201 | public void avnLocalTeleport(Vector3 newpos, Vector3? newvel, bool rotateToVelXY) | ||
1202 | { | ||
1203 | CheckLandingPoint(ref newpos); | ||
1204 | AbsolutePosition = newpos; | ||
1205 | |||
1206 | if (newvel.HasValue) | ||
1207 | { | ||
1208 | if ((Vector3)newvel == Vector3.Zero) | ||
1209 | { | ||
1210 | if (PhysicsActor != null) | ||
1211 | PhysicsActor.SetMomentum(Vector3.Zero); | ||
1212 | m_velocity = Vector3.Zero; | ||
1213 | } | ||
1214 | else | ||
1215 | { | ||
1216 | if (PhysicsActor != null) | ||
1217 | PhysicsActor.SetMomentum((Vector3)newvel); | ||
1218 | m_velocity = (Vector3)newvel; | ||
1219 | |||
1220 | if (rotateToVelXY) | ||
1221 | { | ||
1222 | Vector3 lookAt = (Vector3)newvel; | ||
1223 | lookAt.Z = 0; | ||
1224 | lookAt.Normalize(); | ||
1225 | ControllingClient.SendLocalTeleport(newpos, lookAt, (uint)TeleportFlags.ViaLocation); | ||
1226 | return; | ||
1227 | } | ||
1228 | } | ||
1229 | } | ||
1230 | |||
1231 | SendTerseUpdateToAllClients(); | ||
1232 | } | ||
1233 | |||
1234 | |||
1235 | |||
1046 | public void StopFlying() | 1236 | public void StopFlying() |
1047 | { | 1237 | { |
1048 | ControllingClient.StopFlying(this); | 1238 | ControllingClient.StopFlying(this); |
@@ -1212,6 +1402,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1212 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); | 1402 | PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); |
1213 | } | 1403 | } |
1214 | 1404 | ||
1405 | public void SetSize(Vector3 size, float feetoffset) | ||
1406 | { | ||
1407 | if (PhysicsActor != null && !IsChildAgent) | ||
1408 | PhysicsActor.setAvatarSize(size, feetoffset); | ||
1409 | |||
1410 | } | ||
1411 | |||
1215 | /// <summary> | 1412 | /// <summary> |
1216 | /// Complete Avatar's movement into the region. | 1413 | /// Complete Avatar's movement into the region. |
1217 | /// </summary> | 1414 | /// </summary> |
@@ -1231,7 +1428,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1231 | 1428 | ||
1232 | Vector3 look = Velocity; | 1429 | Vector3 look = Velocity; |
1233 | 1430 | ||
1234 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1431 | // if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1432 | if ((Math.Abs(look.X) < 0.1) && (Math.Abs(look.Y) < 0.1) && (Math.Abs(look.Z) < 0.1)) | ||
1235 | { | 1433 | { |
1236 | look = new Vector3(0.99f, 0.042f, 0); | 1434 | look = new Vector3(0.99f, 0.042f, 0); |
1237 | } | 1435 | } |
@@ -1281,13 +1479,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1281 | // Create child agents in neighbouring regions | 1479 | // Create child agents in neighbouring regions |
1282 | if (openChildAgents && !IsChildAgent) | 1480 | if (openChildAgents && !IsChildAgent) |
1283 | { | 1481 | { |
1482 | |||
1284 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | 1483 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
1285 | if (m_agentTransfer != null) | 1484 | if (m_agentTransfer != null) |
1286 | Util.FireAndForget(delegate { m_agentTransfer.EnableChildAgents(this); }); | 1485 | m_agentTransfer.EnableChildAgents(this); |
1287 | 1486 | ||
1288 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 1487 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
1289 | if (friendsModule != null) | 1488 | if (friendsModule != null) |
1290 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 1489 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); |
1490 | |||
1291 | } | 1491 | } |
1292 | 1492 | ||
1293 | // m_log.DebugFormat( | 1493 | // m_log.DebugFormat( |
@@ -1303,35 +1503,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1303 | /// <param name="collisionPoint"></param> | 1503 | /// <param name="collisionPoint"></param> |
1304 | /// <param name="localid"></param> | 1504 | /// <param name="localid"></param> |
1305 | /// <param name="distance"></param> | 1505 | /// <param name="distance"></param> |
1506 | /// | ||
1507 | |||
1508 | private void UpdateCameraCollisionPlane(Vector4 plane) | ||
1509 | { | ||
1510 | if (m_lastCameraCollisionPlane != plane) | ||
1511 | { | ||
1512 | m_lastCameraCollisionPlane = plane; | ||
1513 | ControllingClient.SendCameraConstraint(plane); | ||
1514 | } | ||
1515 | } | ||
1516 | |||
1306 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) | 1517 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal) |
1307 | { | 1518 | { |
1308 | const float POSITION_TOLERANCE = 0.02f; | 1519 | const float POSITION_TOLERANCE = 0.02f; |
1309 | const float VELOCITY_TOLERANCE = 0.02f; | ||
1310 | const float ROTATION_TOLERANCE = 0.02f; | 1520 | const float ROTATION_TOLERANCE = 0.02f; |
1311 | 1521 | ||
1312 | if (m_followCamAuto) | 1522 | m_doingCamRayCast = false; |
1523 | if (hitYN && localid != LocalId) | ||
1313 | { | 1524 | { |
1314 | if (hitYN) | 1525 | CameraConstraintActive = true; |
1315 | { | 1526 | pNormal.X = (float)Math.Round(pNormal.X, 2); |
1316 | CameraConstraintActive = true; | 1527 | pNormal.Y = (float)Math.Round(pNormal.Y, 2); |
1317 | //m_log.DebugFormat("[RAYCASTRESULT]: {0}, {1}, {2}, {3}", hitYN, collisionPoint, localid, distance); | 1528 | pNormal.Z = (float)Math.Round(pNormal.Z, 2); |
1318 | 1529 | pNormal.Normalize(); | |
1319 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); | 1530 | collisionPoint.X = (float)Math.Round(collisionPoint.X, 1); |
1320 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); | 1531 | collisionPoint.Y = (float)Math.Round(collisionPoint.Y, 1); |
1321 | } | 1532 | collisionPoint.Z = (float)Math.Round(collisionPoint.Z, 1); |
1322 | else | 1533 | |
1323 | { | 1534 | Vector4 plane = new Vector4(pNormal.X, pNormal.Y, pNormal.Z, Vector3.Dot(collisionPoint, pNormal)); |
1324 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 1535 | UpdateCameraCollisionPlane(plane); |
1325 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 1536 | } |
1326 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) | 1537 | else if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
1327 | { | 1538 | !Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) |
1328 | if (CameraConstraintActive) | 1539 | { |
1329 | { | 1540 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -9000f); // not right... |
1330 | ControllingClient.SendCameraConstraint(new Vector4(0f, 0.5f, 0.9f, -3000f)); | 1541 | UpdateCameraCollisionPlane(plane); |
1331 | CameraConstraintActive = false; | 1542 | CameraConstraintActive = false; |
1332 | } | ||
1333 | } | ||
1334 | } | ||
1335 | } | 1543 | } |
1336 | } | 1544 | } |
1337 | 1545 | ||
@@ -1406,12 +1614,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1406 | // DrawDistance = agentData.Far; | 1614 | // DrawDistance = agentData.Far; |
1407 | DrawDistance = Scene.DefaultDrawDistance; | 1615 | DrawDistance = Scene.DefaultDrawDistance; |
1408 | 1616 | ||
1409 | // Check if Client has camera in 'follow cam' or 'build' mode. | ||
1410 | Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); | ||
1411 | |||
1412 | m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) | ||
1413 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; | ||
1414 | |||
1415 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | 1617 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; |
1416 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; | 1618 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; |
1417 | 1619 | ||
@@ -1431,14 +1633,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
1431 | StandUp(); | 1633 | StandUp(); |
1432 | } | 1634 | } |
1433 | 1635 | ||
1434 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); | ||
1435 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | 1636 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view |
1436 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) | 1637 | // this exclude checks may not be complete |
1638 | |||
1639 | if (m_movementUpdateCount % NumMovementsBetweenRayCast == 0 && m_scene.PhysicsScene.SupportsRayCast()) | ||
1437 | { | 1640 | { |
1438 | if (m_followCamAuto) | 1641 | if (!m_doingCamRayCast && !m_mouseLook && ParentID == 0) |
1642 | { | ||
1643 | Vector3 posAdjusted = AbsolutePosition; | ||
1644 | // posAdjusted.Z += 0.5f * Appearance.AvatarSize.Z - 0.5f; | ||
1645 | posAdjusted.Z += 1.0f; // viewer current camera focus point | ||
1646 | Vector3 tocam = CameraPosition - posAdjusted; | ||
1647 | tocam.X = (float)Math.Round(tocam.X, 1); | ||
1648 | tocam.Y = (float)Math.Round(tocam.Y, 1); | ||
1649 | tocam.Z = (float)Math.Round(tocam.Z, 1); | ||
1650 | |||
1651 | float distTocamlen = tocam.Length(); | ||
1652 | if (distTocamlen > 0.3f) | ||
1653 | { | ||
1654 | tocam *= (1.0f / distTocamlen); | ||
1655 | posAdjusted.X = (float)Math.Round(posAdjusted.X, 1); | ||
1656 | posAdjusted.Y = (float)Math.Round(posAdjusted.Y, 1); | ||
1657 | posAdjusted.Z = (float)Math.Round(posAdjusted.Z, 1); | ||
1658 | |||
1659 | m_doingCamRayCast = true; | ||
1660 | m_scene.PhysicsScene.RaycastWorld(posAdjusted, tocam, distTocamlen + 1.0f, RayCastCameraCallback); | ||
1661 | } | ||
1662 | } | ||
1663 | else if (CameraConstraintActive && (m_mouseLook || ParentID != 0)) | ||
1439 | { | 1664 | { |
1440 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; | 1665 | Vector4 plane = new Vector4(0.9f, 0.0f, 0.361f, -10000f); // not right... |
1441 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); | 1666 | UpdateCameraCollisionPlane(plane); |
1667 | CameraConstraintActive = false; | ||
1442 | } | 1668 | } |
1443 | } | 1669 | } |
1444 | 1670 | ||
@@ -1903,7 +2129,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1903 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); | 2129 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); |
1904 | 2130 | ||
1905 | MovingToTarget = false; | 2131 | MovingToTarget = false; |
1906 | MoveToPositionTarget = Vector3.Zero; | 2132 | // MoveToPositionTarget = Vector3.Zero; |
2133 | m_forceToApply = null; // cancel possible last action | ||
1907 | 2134 | ||
1908 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct | 2135 | // We need to reset the control flag as the ScenePresenceAnimator uses this to determine the correct |
1909 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. | 2136 | // resting animation (e.g. hover or stand). NPCs don't have a client that will quickly reset this flag. |
@@ -1921,12 +2148,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1921 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); | 2148 | // m_log.DebugFormat("[SCENE PRESENCE]: StandUp() for {0}", Name); |
1922 | 2149 | ||
1923 | SitGround = false; | 2150 | SitGround = false; |
2151 | |||
2152 | /* move this down so avatar gets physical in the new position and not where it is siting | ||
1924 | if (PhysicsActor == null) | 2153 | if (PhysicsActor == null) |
1925 | AddToPhysicalScene(false); | 2154 | AddToPhysicalScene(false); |
2155 | */ | ||
1926 | 2156 | ||
1927 | if (ParentID != 0) | 2157 | if (ParentID != 0) |
1928 | { | 2158 | { |
1929 | SceneObjectPart part = ParentPart; | 2159 | SceneObjectPart part = ParentPart; |
2160 | UnRegisterSeatControls(part.ParentGroup.UUID); | ||
2161 | |||
1930 | TaskInventoryDictionary taskIDict = part.TaskInventory; | 2162 | TaskInventoryDictionary taskIDict = part.TaskInventory; |
1931 | if (taskIDict != null) | 2163 | if (taskIDict != null) |
1932 | { | 2164 | { |
@@ -1942,14 +2174,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1942 | } | 2174 | } |
1943 | } | 2175 | } |
1944 | 2176 | ||
1945 | ParentPosition = part.GetWorldPosition(); | 2177 | part.ParentGroup.DeleteAvatar(UUID); |
2178 | // ParentPosition = part.GetWorldPosition(); | ||
1946 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 2179 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
1947 | 2180 | ||
1948 | m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 2181 | // m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
1949 | ParentPosition = Vector3.Zero; | 2182 | // ParentPosition = Vector3.Zero; |
2183 | m_pos = part.AbsolutePosition + (m_pos * part.GetWorldRotation()) + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | ||
2184 | if (part.SitTargetAvatar == UUID) | ||
2185 | m_bodyRot = part.GetWorldRotation() * part.SitTargetOrientation; | ||
1950 | 2186 | ||
1951 | ParentID = 0; | 2187 | ParentID = 0; |
1952 | ParentPart = null; | 2188 | ParentPart = null; |
2189 | |||
2190 | if (PhysicsActor == null) | ||
2191 | AddToPhysicalScene(false); | ||
2192 | |||
1953 | SendAvatarDataToAllAgents(); | 2193 | SendAvatarDataToAllAgents(); |
1954 | m_requestedSitTargetID = 0; | 2194 | m_requestedSitTargetID = 0; |
1955 | 2195 | ||
@@ -1959,6 +2199,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1959 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 2199 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
1960 | } | 2200 | } |
1961 | 2201 | ||
2202 | else if (PhysicsActor == null) | ||
2203 | AddToPhysicalScene(false); | ||
2204 | |||
1962 | Animator.TrySetMovementAnimation("STAND"); | 2205 | Animator.TrySetMovementAnimation("STAND"); |
1963 | } | 2206 | } |
1964 | 2207 | ||
@@ -2006,11 +2249,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2006 | if (part == null) | 2249 | if (part == null) |
2007 | return; | 2250 | return; |
2008 | 2251 | ||
2009 | // TODO: determine position to sit at based on scene geometry; don't trust offset from client | ||
2010 | // see http://wiki.secondlife.com/wiki/User:Andrew_Linden/Office_Hours/2007_11_06 for details on how LL does it | ||
2011 | |||
2012 | if (PhysicsActor != null) | 2252 | if (PhysicsActor != null) |
2013 | m_sitAvatarHeight = PhysicsActor.Size.Z; | 2253 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
2014 | 2254 | ||
2015 | bool canSit = false; | 2255 | bool canSit = false; |
2016 | Vector3 pos = part.AbsolutePosition + offset; | 2256 | Vector3 pos = part.AbsolutePosition + offset; |
@@ -2027,31 +2267,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
2027 | } | 2267 | } |
2028 | else | 2268 | else |
2029 | { | 2269 | { |
2270 | if (PhysicsSit(part,offset)) // physics engine | ||
2271 | return; | ||
2272 | |||
2030 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) | 2273 | if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) |
2031 | { | 2274 | { |
2032 | // m_log.DebugFormat( | ||
2033 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", | ||
2034 | // Name, part.Name, part.LocalId); | ||
2035 | 2275 | ||
2036 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); | 2276 | AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); |
2037 | canSit = true; | 2277 | canSit = true; |
2038 | } | 2278 | } |
2039 | // else | ||
2040 | // { | ||
2041 | // m_log.DebugFormat( | ||
2042 | // "[SCENE PRESENCE]: Ignoring sit request of {0} on {1} {2} because sit target is unset and outside 10m", | ||
2043 | // Name, part.Name, part.LocalId); | ||
2044 | // } | ||
2045 | } | 2279 | } |
2046 | 2280 | ||
2047 | if (canSit) | 2281 | if (canSit) |
2048 | { | 2282 | { |
2283 | |||
2049 | if (PhysicsActor != null) | 2284 | if (PhysicsActor != null) |
2050 | { | 2285 | { |
2051 | // We can remove the physicsActor until they stand up. | 2286 | // We can remove the physicsActor until they stand up. |
2052 | RemoveFromPhysicalScene(); | 2287 | RemoveFromPhysicalScene(); |
2053 | } | 2288 | } |
2054 | 2289 | ||
2290 | if (MovingToTarget) | ||
2291 | ResetMoveToTarget(); | ||
2292 | |||
2293 | Velocity = Vector3.Zero; | ||
2294 | |||
2055 | part.AddSittingAvatar(UUID); | 2295 | part.AddSittingAvatar(UUID); |
2056 | 2296 | ||
2057 | cameraAtOffset = part.GetCameraAtOffset(); | 2297 | cameraAtOffset = part.GetCameraAtOffset(); |
@@ -2059,7 +2299,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2059 | forceMouselook = part.GetForceMouselook(); | 2299 | forceMouselook = part.GetForceMouselook(); |
2060 | 2300 | ||
2061 | ControllingClient.SendSitResponse( | 2301 | ControllingClient.SendSitResponse( |
2062 | targetID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 2302 | part.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
2063 | 2303 | ||
2064 | m_requestedSitTargetUUID = targetID; | 2304 | m_requestedSitTargetUUID = targetID; |
2065 | 2305 | ||
@@ -2073,6 +2313,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2073 | 2313 | ||
2074 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) | 2314 | public void HandleAgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset) |
2075 | { | 2315 | { |
2316 | if (IsChildAgent) | ||
2317 | return; | ||
2318 | |||
2076 | if (ParentID != 0) | 2319 | if (ParentID != 0) |
2077 | { | 2320 | { |
2078 | if (ParentPart.UUID == targetID) | 2321 | if (ParentPart.UUID == targetID) |
@@ -2088,14 +2331,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2088 | m_requestedSitTargetID = part.LocalId; | 2331 | m_requestedSitTargetID = part.LocalId; |
2089 | m_requestedSitTargetUUID = targetID; | 2332 | m_requestedSitTargetUUID = targetID; |
2090 | 2333 | ||
2091 | // m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset); | ||
2092 | |||
2093 | if (m_scene.PhysicsScene.SupportsRayCast()) | ||
2094 | { | ||
2095 | //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback()); | ||
2096 | //SitRayCastAvatarPosition(part); | ||
2097 | //return; | ||
2098 | } | ||
2099 | } | 2334 | } |
2100 | else | 2335 | else |
2101 | { | 2336 | { |
@@ -2105,197 +2340,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2105 | SendSitResponse(targetID, offset, Quaternion.Identity); | 2340 | SendSitResponse(targetID, offset, Quaternion.Identity); |
2106 | } | 2341 | } |
2107 | 2342 | ||
2108 | /* | 2343 | // returns false if does not suport so older sit can be tried |
2109 | public void SitRayCastAvatarPosition(SceneObjectPart part) | 2344 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) |
2110 | { | 2345 | { |
2111 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2346 | if (part == null || part.ParentGroup.IsAttachment) |
2112 | Vector3 StartRayCastPosition = AbsolutePosition; | ||
2113 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2114 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2115 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); | ||
2116 | } | ||
2117 | |||
2118 | public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | ||
2119 | { | ||
2120 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2121 | if (part != null) | ||
2122 | { | ||
2123 | if (hitYN) | ||
2124 | { | ||
2125 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2126 | { | ||
2127 | SitRaycastFindEdge(collisionPoint, normal); | ||
2128 | m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2129 | } | ||
2130 | else | ||
2131 | { | ||
2132 | SitRayCastAvatarPositionCameraZ(part); | ||
2133 | } | ||
2134 | } | ||
2135 | else | ||
2136 | { | ||
2137 | SitRayCastAvatarPositionCameraZ(part); | ||
2138 | } | ||
2139 | } | ||
2140 | else | ||
2141 | { | 2347 | { |
2142 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2348 | return true; |
2143 | m_requestedSitTargetUUID = UUID.Zero; | ||
2144 | m_requestedSitTargetID = 0; | ||
2145 | m_requestedSitOffset = Vector3.Zero; | ||
2146 | } | 2349 | } |
2147 | 2350 | ||
2148 | } | 2351 | if ( m_scene.PhysicsScene == null) |
2149 | 2352 | return false; | |
2150 | public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) | ||
2151 | { | ||
2152 | // Next, try to raycast from the camera Z position | ||
2153 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2154 | Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; | ||
2155 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2156 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2157 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); | ||
2158 | } | ||
2159 | 2353 | ||
2160 | public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2354 | if (part.PhysActor == null) |
2161 | { | ||
2162 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2163 | if (part != null) | ||
2164 | { | 2355 | { |
2165 | if (hitYN) | 2356 | // none physcis shape |
2166 | { | 2357 | if (part.PhysicsShapeType == (byte)PhysicsShapeType.None) |
2167 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | 2358 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2168 | { | ||
2169 | SitRaycastFindEdge(collisionPoint, normal); | ||
2170 | m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2171 | } | ||
2172 | else | ||
2173 | { | ||
2174 | SitRayCastCameraPosition(part); | ||
2175 | } | ||
2176 | } | ||
2177 | else | 2359 | else |
2178 | { | 2360 | { // non physical phantom TODO |
2179 | SitRayCastCameraPosition(part); | 2361 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2362 | return false; | ||
2180 | } | 2363 | } |
2181 | } | 2364 | return true; |
2182 | else | ||
2183 | { | ||
2184 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2185 | m_requestedSitTargetUUID = UUID.Zero; | ||
2186 | m_requestedSitTargetID = 0; | ||
2187 | m_requestedSitOffset = Vector3.Zero; | ||
2188 | } | 2365 | } |
2189 | 2366 | ||
2190 | } | ||
2191 | 2367 | ||
2192 | public void SitRayCastCameraPosition(SceneObjectPart part) | 2368 | // not doing autopilot |
2193 | { | 2369 | m_requestedSitTargetID = 0; |
2194 | // Next, try to raycast from the camera position | ||
2195 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2196 | Vector3 StartRayCastPosition = CameraPosition; | ||
2197 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2198 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2199 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); | ||
2200 | } | ||
2201 | 2370 | ||
2202 | public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2371 | if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) |
2203 | { | 2372 | return true; |
2204 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | ||
2205 | if (part != null) | ||
2206 | { | ||
2207 | if (hitYN) | ||
2208 | { | ||
2209 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2210 | { | ||
2211 | SitRaycastFindEdge(collisionPoint, normal); | ||
2212 | m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2213 | } | ||
2214 | else | ||
2215 | { | ||
2216 | SitRayHorizontal(part); | ||
2217 | } | ||
2218 | } | ||
2219 | else | ||
2220 | { | ||
2221 | SitRayHorizontal(part); | ||
2222 | } | ||
2223 | } | ||
2224 | else | ||
2225 | { | ||
2226 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | ||
2227 | m_requestedSitTargetUUID = UUID.Zero; | ||
2228 | m_requestedSitTargetID = 0; | ||
2229 | m_requestedSitOffset = Vector3.Zero; | ||
2230 | } | ||
2231 | 2373 | ||
2374 | return false; | ||
2232 | } | 2375 | } |
2233 | 2376 | ||
2234 | public void SitRayHorizontal(SceneObjectPart part) | 2377 | |
2378 | private bool CanEnterLandPosition(Vector3 testPos) | ||
2235 | { | 2379 | { |
2236 | // Next, try to raycast from the avatar position to fwd | 2380 | ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y); |
2237 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | 2381 | |
2238 | Vector3 StartRayCastPosition = CameraPosition; | 2382 | if (land == null || land.LandData.Name == "NO_LAND") |
2239 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | 2383 | return true; |
2240 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | 2384 | |
2241 | m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); | 2385 | return land.CanBeOnThisLand(UUID,testPos.Z); |
2242 | } | 2386 | } |
2243 | 2387 | ||
2244 | public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) | 2388 | // status |
2389 | // < 0 ignore | ||
2390 | // 0 bad sit spot | ||
2391 | public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) | ||
2245 | { | 2392 | { |
2246 | SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); | 2393 | if (status < 0) |
2247 | if (part != null) | 2394 | return; |
2395 | |||
2396 | if (status == 0) | ||
2248 | { | 2397 | { |
2249 | if (hitYN) | 2398 | ControllingClient.SendAlertMessage(" There is no suitable surface to sit on, try another spot."); |
2250 | { | 2399 | return; |
2251 | if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) | ||
2252 | { | ||
2253 | SitRaycastFindEdge(collisionPoint, normal); | ||
2254 | m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); | ||
2255 | // Next, try to raycast from the camera position | ||
2256 | Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; | ||
2257 | Vector3 StartRayCastPosition = CameraPosition; | ||
2258 | Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); | ||
2259 | float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); | ||
2260 | //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); | ||
2261 | } | ||
2262 | else | ||
2263 | { | ||
2264 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2265 | m_requestedSitTargetUUID = UUID.Zero; | ||
2266 | m_requestedSitTargetID = 0; | ||
2267 | m_requestedSitOffset = Vector3.Zero; | ||
2268 | } | ||
2269 | } | ||
2270 | else | ||
2271 | { | ||
2272 | ControllingClient.SendAlertMessage("Sit position not accessable."); | ||
2273 | m_requestedSitTargetUUID = UUID.Zero; | ||
2274 | m_requestedSitTargetID = 0; | ||
2275 | m_requestedSitOffset = Vector3.Zero; | ||
2276 | } | ||
2277 | } | 2400 | } |
2278 | else | 2401 | |
2402 | SceneObjectPart part = m_scene.GetSceneObjectPart(partID); | ||
2403 | if (part == null) | ||
2404 | return; | ||
2405 | |||
2406 | Vector3 targetPos = part.GetWorldPosition() + offset * part.GetWorldRotation(); | ||
2407 | if(!CanEnterLandPosition(targetPos)) | ||
2279 | { | 2408 | { |
2280 | ControllingClient.SendAlertMessage("Sit position no longer exists"); | 2409 | ControllingClient.SendAlertMessage(" Sit position on restricted land, try another spot"); |
2281 | m_requestedSitTargetUUID = UUID.Zero; | 2410 | return; |
2282 | m_requestedSitTargetID = 0; | ||
2283 | m_requestedSitOffset = Vector3.Zero; | ||
2284 | } | 2411 | } |
2285 | 2412 | ||
2286 | } | 2413 | RemoveFromPhysicalScene(); |
2287 | 2414 | ||
2288 | private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) | 2415 | if (MovingToTarget) |
2289 | { | 2416 | ResetMoveToTarget(); |
2290 | int i = 0; | 2417 | |
2291 | //throw new NotImplementedException(); | 2418 | Velocity = Vector3.Zero; |
2292 | //m_requestedSitTargetUUID = UUID.Zero; | 2419 | |
2293 | //m_requestedSitTargetID = 0; | 2420 | part.AddSittingAvatar(UUID); |
2294 | //m_requestedSitOffset = Vector3.Zero; | ||
2295 | 2421 | ||
2296 | SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); | 2422 | Vector3 cameraAtOffset = part.GetCameraAtOffset(); |
2423 | Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); | ||
2424 | bool forceMouselook = part.GetForceMouselook(); | ||
2425 | |||
2426 | ControllingClient.SendSitResponse( | ||
2427 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
2428 | |||
2429 | // not using autopilot | ||
2430 | |||
2431 | Rotation = Orientation; | ||
2432 | m_pos = offset; | ||
2433 | |||
2434 | m_requestedSitTargetID = 0; | ||
2435 | part.ParentGroup.AddAvatar(UUID); | ||
2436 | |||
2437 | ParentPart = part; | ||
2438 | ParentID = part.LocalId; | ||
2439 | if(status == 3) | ||
2440 | Animator.TrySetMovementAnimation("SIT_GROUND"); | ||
2441 | else | ||
2442 | Animator.TrySetMovementAnimation("SIT"); | ||
2443 | SendAvatarDataToAllAgents(); | ||
2444 | |||
2445 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | ||
2297 | } | 2446 | } |
2298 | */ | 2447 | |
2299 | 2448 | ||
2300 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) | 2449 | public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) |
2301 | { | 2450 | { |
@@ -2312,6 +2461,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2312 | return; | 2461 | return; |
2313 | } | 2462 | } |
2314 | 2463 | ||
2464 | |||
2315 | if (part.SitTargetAvatar == UUID) | 2465 | if (part.SitTargetAvatar == UUID) |
2316 | { | 2466 | { |
2317 | Vector3 sitTargetPos = part.SitTargetPosition; | 2467 | Vector3 sitTargetPos = part.SitTargetPosition; |
@@ -2326,14 +2476,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2326 | 2476 | ||
2327 | //Quaternion result = (sitTargetOrient * vq) * nq; | 2477 | //Quaternion result = (sitTargetOrient * vq) * nq; |
2328 | 2478 | ||
2329 | m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT; | 2479 | double x, y, z, m; |
2480 | |||
2481 | Quaternion r = sitTargetOrient; | ||
2482 | m = r.X * r.X + r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2483 | |||
2484 | if (Math.Abs(1.0 - m) > 0.000001) | ||
2485 | { | ||
2486 | m = 1.0 / Math.Sqrt(m); | ||
2487 | r.X *= (float)m; | ||
2488 | r.Y *= (float)m; | ||
2489 | r.Z *= (float)m; | ||
2490 | r.W *= (float)m; | ||
2491 | } | ||
2492 | |||
2493 | x = 2 * (r.X * r.Z + r.Y * r.W); | ||
2494 | y = 2 * (-r.X * r.W + r.Y * r.Z); | ||
2495 | z = -r.X * r.X - r.Y * r.Y + r.Z * r.Z + r.W * r.W; | ||
2496 | |||
2497 | Vector3 up = new Vector3((float)x, (float)y, (float)z); | ||
2498 | Vector3 sitOffset = up * Appearance.AvatarHeight * 0.02638f; | ||
2499 | |||
2500 | m_pos = sitTargetPos + sitOffset + SIT_TARGET_ADJUSTMENT; | ||
2501 | |||
2502 | // m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; | ||
2330 | Rotation = sitTargetOrient; | 2503 | Rotation = sitTargetOrient; |
2331 | ParentPosition = part.AbsolutePosition; | 2504 | // ParentPosition = part.AbsolutePosition; |
2505 | part.ParentGroup.AddAvatar(UUID); | ||
2332 | } | 2506 | } |
2333 | else | 2507 | else |
2334 | { | 2508 | { |
2335 | m_pos -= part.AbsolutePosition; | 2509 | m_pos -= part.AbsolutePosition; |
2336 | ParentPosition = part.AbsolutePosition; | 2510 | // ParentPosition = part.AbsolutePosition; |
2511 | part.ParentGroup.AddAvatar(UUID); | ||
2337 | 2512 | ||
2338 | // m_log.DebugFormat( | 2513 | // m_log.DebugFormat( |
2339 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", | 2514 | // "[SCENE PRESENCE]: Sitting {0} at position {1} ({2} + {3}) on part {4} {5} without sit target", |
@@ -2384,6 +2559,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2384 | Animator.RemoveAnimation(animID, false); | 2559 | Animator.RemoveAnimation(animID, false); |
2385 | } | 2560 | } |
2386 | 2561 | ||
2562 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2563 | { | ||
2564 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2565 | } | ||
2566 | |||
2567 | |||
2568 | |||
2387 | /// <summary> | 2569 | /// <summary> |
2388 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2570 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2389 | /// </summary> | 2571 | /// </summary> |
@@ -2437,14 +2619,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2437 | direc.Z *= 2.6f; | 2619 | direc.Z *= 2.6f; |
2438 | 2620 | ||
2439 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2621 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2440 | Animator.TrySetMovementAnimation("PREJUMP"); | 2622 | // Animator.TrySetMovementAnimation("PREJUMP"); |
2441 | Animator.TrySetMovementAnimation("JUMP"); | 2623 | // Animator.TrySetMovementAnimation("JUMP"); |
2442 | } | 2624 | } |
2443 | } | 2625 | } |
2444 | } | 2626 | } |
2445 | 2627 | ||
2446 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | 2628 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2447 | m_forceToApply = direc; | 2629 | m_forceToApply = direc; |
2630 | Animator.UpdateMovementAnimations(); | ||
2448 | } | 2631 | } |
2449 | 2632 | ||
2450 | #endregion | 2633 | #endregion |
@@ -2462,16 +2645,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2462 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | 2645 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to |
2463 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | 2646 | // grab the latest PhysicsActor velocity, whereas m_velocity is often |
2464 | // storing a requested force instead of an actual traveling velocity | 2647 | // storing a requested force instead of an actual traveling velocity |
2648 | if (Appearance.AvatarSize != m_lastSize && !IsLoggingIn) | ||
2649 | SendAvatarDataToAllAgents(); | ||
2465 | 2650 | ||
2466 | // Throw away duplicate or insignificant updates | 2651 | if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2467 | if ( | 2652 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2468 | // If the velocity has become zero, send it no matter what. | 2653 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2469 | (Velocity != m_lastVelocity && Velocity == Vector3.Zero) | ||
2470 | // otherwise, if things have changed reasonably, send the update | ||
2471 | || (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) | ||
2472 | || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) | ||
2473 | || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE))) | ||
2474 | |||
2475 | { | 2654 | { |
2476 | SendTerseUpdateToAllClients(); | 2655 | SendTerseUpdateToAllClients(); |
2477 | 2656 | ||
@@ -2660,6 +2839,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2660 | return; | 2839 | return; |
2661 | } | 2840 | } |
2662 | 2841 | ||
2842 | m_lastSize = Appearance.AvatarSize; | ||
2843 | |||
2663 | int count = 0; | 2844 | int count = 0; |
2664 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 2845 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
2665 | { | 2846 | { |
@@ -2767,6 +2948,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2767 | 2948 | ||
2768 | avatar.ControllingClient.SendAppearance( | 2949 | avatar.ControllingClient.SendAppearance( |
2769 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); | 2950 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); |
2951 | |||
2952 | |||
2770 | } | 2953 | } |
2771 | 2954 | ||
2772 | #endregion | 2955 | #endregion |
@@ -2841,8 +3024,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2841 | 3024 | ||
2842 | // If we don't have a PhysActor, we can't cross anyway | 3025 | // If we don't have a PhysActor, we can't cross anyway |
2843 | // Also don't do this while sat, sitting avatars cross with the | 3026 | // Also don't do this while sat, sitting avatars cross with the |
2844 | // object they sit on. | 3027 | // object they sit on. ParentUUID denoted a pending sit, don't |
2845 | if (ParentID != 0 || PhysicsActor == null) | 3028 | // interfere with it. |
3029 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | ||
2846 | return; | 3030 | return; |
2847 | 3031 | ||
2848 | if (!IsInTransit) | 3032 | if (!IsInTransit) |
@@ -3103,6 +3287,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3103 | } | 3287 | } |
3104 | 3288 | ||
3105 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3289 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3290 | private void RaiseUpdateThrottles() | ||
3291 | { | ||
3292 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
3293 | } | ||
3106 | /// <summary> | 3294 | /// <summary> |
3107 | /// This updates important decision making data about a child agent | 3295 | /// This updates important decision making data about a child agent |
3108 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3296 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3183,6 +3371,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3183 | cAgent.AlwaysRun = SetAlwaysRun; | 3371 | cAgent.AlwaysRun = SetAlwaysRun; |
3184 | 3372 | ||
3185 | cAgent.Appearance = new AvatarAppearance(Appearance); | 3373 | cAgent.Appearance = new AvatarAppearance(Appearance); |
3374 | |||
3375 | cAgent.ParentPart = ParentUUID; | ||
3376 | cAgent.SitOffset = m_pos; | ||
3186 | 3377 | ||
3187 | lock (scriptedcontrols) | 3378 | lock (scriptedcontrols) |
3188 | { | 3379 | { |
@@ -3191,7 +3382,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3191 | 3382 | ||
3192 | foreach (ScriptControllers c in scriptedcontrols.Values) | 3383 | foreach (ScriptControllers c in scriptedcontrols.Values) |
3193 | { | 3384 | { |
3194 | controls[i++] = new ControllerData(c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); | 3385 | controls[i++] = new ControllerData(c.objectID, c.itemID, (uint)c.ignoreControls, (uint)c.eventControls); |
3195 | } | 3386 | } |
3196 | cAgent.Controllers = controls; | 3387 | cAgent.Controllers = controls; |
3197 | } | 3388 | } |
@@ -3224,6 +3415,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3224 | CameraAtAxis = cAgent.AtAxis; | 3415 | CameraAtAxis = cAgent.AtAxis; |
3225 | CameraLeftAxis = cAgent.LeftAxis; | 3416 | CameraLeftAxis = cAgent.LeftAxis; |
3226 | CameraUpAxis = cAgent.UpAxis; | 3417 | CameraUpAxis = cAgent.UpAxis; |
3418 | ParentUUID = cAgent.ParentPart; | ||
3419 | m_prevSitOffset = cAgent.SitOffset; | ||
3227 | 3420 | ||
3228 | // When we get to the point of re-computing neighbors everytime this | 3421 | // When we get to the point of re-computing neighbors everytime this |
3229 | // changes, then start using the agent's drawdistance rather than the | 3422 | // changes, then start using the agent's drawdistance rather than the |
@@ -3261,6 +3454,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3261 | foreach (ControllerData c in cAgent.Controllers) | 3454 | foreach (ControllerData c in cAgent.Controllers) |
3262 | { | 3455 | { |
3263 | ScriptControllers sc = new ScriptControllers(); | 3456 | ScriptControllers sc = new ScriptControllers(); |
3457 | sc.objectID = c.ObjectID; | ||
3264 | sc.itemID = c.ItemID; | 3458 | sc.itemID = c.ItemID; |
3265 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; | 3459 | sc.ignoreControls = (ScriptControlled)c.IgnoreControls; |
3266 | sc.eventControls = (ScriptControlled)c.EventControls; | 3460 | sc.eventControls = (ScriptControlled)c.EventControls; |
@@ -3328,20 +3522,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3328 | } | 3522 | } |
3329 | 3523 | ||
3330 | if (Appearance.AvatarHeight == 0) | 3524 | if (Appearance.AvatarHeight == 0) |
3331 | Appearance.SetHeight(); | 3525 | // Appearance.SetHeight(); |
3526 | Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); | ||
3332 | 3527 | ||
3333 | PhysicsScene scene = m_scene.PhysicsScene; | 3528 | PhysicsScene scene = m_scene.PhysicsScene; |
3334 | 3529 | ||
3335 | Vector3 pVec = AbsolutePosition; | 3530 | Vector3 pVec = AbsolutePosition; |
3336 | 3531 | ||
3532 | /* | ||
3337 | PhysicsActor = scene.AddAvatar( | 3533 | PhysicsActor = scene.AddAvatar( |
3338 | LocalId, Firstname + "." + Lastname, pVec, | 3534 | LocalId, Firstname + "." + Lastname, pVec, |
3339 | new Vector3(0f, 0f, Appearance.AvatarHeight), isFlying); | 3535 | new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); |
3536 | */ | ||
3537 | |||
3538 | PhysicsActor = scene.AddAvatar( | ||
3539 | LocalId, Firstname + "." + Lastname, pVec, | ||
3540 | Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); | ||
3340 | 3541 | ||
3341 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3542 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3342 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3543 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
3343 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong | 3544 | PhysicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong |
3344 | PhysicsActor.SubscribeEvents(500); | 3545 | PhysicsActor.SubscribeEvents(100); |
3345 | PhysicsActor.LocalID = LocalId; | 3546 | PhysicsActor.LocalID = LocalId; |
3346 | } | 3547 | } |
3347 | 3548 | ||
@@ -3355,6 +3556,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3355 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); | 3556 | ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); |
3356 | } | 3557 | } |
3357 | 3558 | ||
3559 | |||
3358 | /// <summary> | 3560 | /// <summary> |
3359 | /// Event called by the physics plugin to tell the avatar about a collision. | 3561 | /// Event called by the physics plugin to tell the avatar about a collision. |
3360 | /// </summary> | 3562 | /// </summary> |
@@ -3368,7 +3570,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3368 | /// <param name="e"></param> | 3570 | /// <param name="e"></param> |
3369 | public void PhysicsCollisionUpdate(EventArgs e) | 3571 | public void PhysicsCollisionUpdate(EventArgs e) |
3370 | { | 3572 | { |
3371 | if (IsChildAgent) | 3573 | if (IsChildAgent || Animator == null) |
3372 | return; | 3574 | return; |
3373 | 3575 | ||
3374 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 3576 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
@@ -3384,7 +3586,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3384 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3586 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
3385 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 3587 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
3386 | 3588 | ||
3387 | CollisionPlane = Vector4.UnitW; | ||
3388 | 3589 | ||
3389 | // // No collisions at all means we may be flying. Update always | 3590 | // // No collisions at all means we may be flying. Update always |
3390 | // // to make falling work | 3591 | // // to make falling work |
@@ -3396,6 +3597,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3396 | 3597 | ||
3397 | if (coldata.Count != 0) | 3598 | if (coldata.Count != 0) |
3398 | { | 3599 | { |
3600 | /* | ||
3399 | switch (Animator.CurrentMovementAnimation) | 3601 | switch (Animator.CurrentMovementAnimation) |
3400 | { | 3602 | { |
3401 | case "STAND": | 3603 | case "STAND": |
@@ -3404,24 +3606,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
3404 | case "CROUCH": | 3606 | case "CROUCH": |
3405 | case "CROUCHWALK": | 3607 | case "CROUCHWALK": |
3406 | { | 3608 | { |
3609 | */ | ||
3407 | ContactPoint lowest; | 3610 | ContactPoint lowest; |
3408 | lowest.SurfaceNormal = Vector3.Zero; | 3611 | lowest.SurfaceNormal = Vector3.Zero; |
3409 | lowest.Position = Vector3.Zero; | 3612 | lowest.Position = Vector3.Zero; |
3410 | lowest.Position.Z = Single.NaN; | 3613 | lowest.Position.Z = float.MaxValue; |
3411 | 3614 | ||
3412 | foreach (ContactPoint contact in coldata.Values) | 3615 | foreach (ContactPoint contact in coldata.Values) |
3413 | { | 3616 | { |
3414 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) | 3617 | |
3618 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | ||
3415 | { | 3619 | { |
3416 | lowest = contact; | 3620 | lowest = contact; |
3417 | } | 3621 | } |
3418 | } | 3622 | } |
3419 | 3623 | ||
3420 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | 3624 | if (lowest.Position.Z != float.MaxValue) |
3625 | { | ||
3626 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | ||
3627 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
3628 | } | ||
3629 | else | ||
3630 | CollisionPlane = Vector4.UnitW; | ||
3631 | /* | ||
3421 | } | 3632 | } |
3422 | break; | 3633 | break; |
3423 | } | 3634 | } |
3635 | */ | ||
3424 | } | 3636 | } |
3637 | else | ||
3638 | CollisionPlane = Vector4.UnitW; | ||
3639 | |||
3640 | RaiseCollisionScriptEvents(coldata); | ||
3425 | 3641 | ||
3426 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 3642 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3427 | if (Invulnerable || GodLevel > 0) | 3643 | if (Invulnerable || GodLevel > 0) |
@@ -3520,6 +3736,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3520 | // m_reprioritizationTimer.Dispose(); | 3736 | // m_reprioritizationTimer.Dispose(); |
3521 | 3737 | ||
3522 | RemoveFromPhysicalScene(); | 3738 | RemoveFromPhysicalScene(); |
3739 | |||
3740 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | ||
3741 | |||
3742 | // if (Animator != null) | ||
3743 | // Animator.Close(); | ||
3744 | Animator = null; | ||
3745 | |||
3523 | } | 3746 | } |
3524 | 3747 | ||
3525 | public void AddAttachment(SceneObjectGroup gobj) | 3748 | public void AddAttachment(SceneObjectGroup gobj) |
@@ -3753,10 +3976,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3753 | 3976 | ||
3754 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) | 3977 | public void RegisterControlEventsToScript(int controls, int accept, int pass_on, uint Obj_localID, UUID Script_item_UUID) |
3755 | { | 3978 | { |
3979 | SceneObjectPart p = m_scene.GetSceneObjectPart(Obj_localID); | ||
3980 | if (p == null) | ||
3981 | return; | ||
3982 | |||
3983 | ControllingClient.SendTakeControls(controls, false, false); | ||
3984 | ControllingClient.SendTakeControls(controls, true, false); | ||
3985 | |||
3756 | ScriptControllers obj = new ScriptControllers(); | 3986 | ScriptControllers obj = new ScriptControllers(); |
3757 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; | 3987 | obj.ignoreControls = ScriptControlled.CONTROL_ZERO; |
3758 | obj.eventControls = ScriptControlled.CONTROL_ZERO; | 3988 | obj.eventControls = ScriptControlled.CONTROL_ZERO; |
3759 | 3989 | ||
3990 | obj.objectID = p.ParentGroup.UUID; | ||
3760 | obj.itemID = Script_item_UUID; | 3991 | obj.itemID = Script_item_UUID; |
3761 | if (pass_on == 0 && accept == 0) | 3992 | if (pass_on == 0 && accept == 0) |
3762 | { | 3993 | { |
@@ -3805,6 +4036,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3805 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 4036 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
3806 | } | 4037 | } |
3807 | 4038 | ||
4039 | private void UnRegisterSeatControls(UUID obj) | ||
4040 | { | ||
4041 | List<UUID> takers = new List<UUID>(); | ||
4042 | |||
4043 | foreach (ScriptControllers c in scriptedcontrols.Values) | ||
4044 | { | ||
4045 | if (c.objectID == obj) | ||
4046 | takers.Add(c.itemID); | ||
4047 | } | ||
4048 | foreach (UUID t in takers) | ||
4049 | { | ||
4050 | UnRegisterControlEventsToScript(0, t); | ||
4051 | } | ||
4052 | } | ||
4053 | |||
3808 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 4054 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3809 | { | 4055 | { |
3810 | ScriptControllers takecontrols; | 4056 | ScriptControllers takecontrols; |
@@ -4123,6 +4369,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4123 | 4369 | ||
4124 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | 4370 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) |
4125 | { | 4371 | { |
4372 | string reason; | ||
4373 | |||
4374 | // Honor bans | ||
4375 | if (!m_scene.TestLandRestrictions(UUID, out reason, ref pos.X, ref pos.Y)) | ||
4376 | return; | ||
4377 | |||
4126 | SceneObjectGroup telehub = null; | 4378 | SceneObjectGroup telehub = null; |
4127 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) | 4379 | if (m_scene.RegionInfo.RegionSettings.TelehubObject != UUID.Zero && (telehub = m_scene.GetSceneObjectGroup(m_scene.RegionInfo.RegionSettings.TelehubObject)) != null) |
4128 | { | 4380 | { |
@@ -4162,11 +4414,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
4162 | pos = land.LandData.UserLocation; | 4414 | pos = land.LandData.UserLocation; |
4163 | } | 4415 | } |
4164 | } | 4416 | } |
4165 | 4417 | ||
4166 | land.SendLandUpdateToClient(ControllingClient); | 4418 | land.SendLandUpdateToClient(ControllingClient); |
4167 | } | 4419 | } |
4168 | } | 4420 | } |
4169 | 4421 | ||
4422 | private DetectedObject CreateDetObject(SceneObjectPart obj) | ||
4423 | { | ||
4424 | DetectedObject detobj = new DetectedObject(); | ||
4425 | detobj.keyUUID = obj.UUID; | ||
4426 | detobj.nameStr = obj.Name; | ||
4427 | detobj.ownerUUID = obj.OwnerID; | ||
4428 | detobj.posVector = obj.AbsolutePosition; | ||
4429 | detobj.rotQuat = obj.GetWorldRotation(); | ||
4430 | detobj.velVector = obj.Velocity; | ||
4431 | detobj.colliderType = 0; | ||
4432 | detobj.groupUUID = obj.GroupID; | ||
4433 | |||
4434 | return detobj; | ||
4435 | } | ||
4436 | |||
4437 | private DetectedObject CreateDetObject(ScenePresence av) | ||
4438 | { | ||
4439 | DetectedObject detobj = new DetectedObject(); | ||
4440 | detobj.keyUUID = av.UUID; | ||
4441 | detobj.nameStr = av.ControllingClient.Name; | ||
4442 | detobj.ownerUUID = av.UUID; | ||
4443 | detobj.posVector = av.AbsolutePosition; | ||
4444 | detobj.rotQuat = av.Rotation; | ||
4445 | detobj.velVector = av.Velocity; | ||
4446 | detobj.colliderType = 0; | ||
4447 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | ||
4448 | |||
4449 | return detobj; | ||
4450 | } | ||
4451 | |||
4452 | private DetectedObject CreateDetObjectForGround() | ||
4453 | { | ||
4454 | DetectedObject detobj = new DetectedObject(); | ||
4455 | detobj.keyUUID = UUID.Zero; | ||
4456 | detobj.nameStr = ""; | ||
4457 | detobj.ownerUUID = UUID.Zero; | ||
4458 | detobj.posVector = AbsolutePosition; | ||
4459 | detobj.rotQuat = Quaternion.Identity; | ||
4460 | detobj.velVector = Vector3.Zero; | ||
4461 | detobj.colliderType = 0; | ||
4462 | detobj.groupUUID = UUID.Zero; | ||
4463 | |||
4464 | return detobj; | ||
4465 | } | ||
4466 | |||
4467 | private ColliderArgs CreateColliderArgs(SceneObjectPart dest, List<uint> colliders) | ||
4468 | { | ||
4469 | ColliderArgs colliderArgs = new ColliderArgs(); | ||
4470 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4471 | foreach (uint localId in colliders) | ||
4472 | { | ||
4473 | if (localId == 0) | ||
4474 | continue; | ||
4475 | |||
4476 | SceneObjectPart obj = m_scene.GetSceneObjectPart(localId); | ||
4477 | if (obj != null) | ||
4478 | { | ||
4479 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | ||
4480 | colliding.Add(CreateDetObject(obj)); | ||
4481 | } | ||
4482 | else | ||
4483 | { | ||
4484 | ScenePresence av = m_scene.GetScenePresence(localId); | ||
4485 | if (av != null && (!av.IsChildAgent)) | ||
4486 | { | ||
4487 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | ||
4488 | colliding.Add(CreateDetObject(av)); | ||
4489 | } | ||
4490 | } | ||
4491 | } | ||
4492 | |||
4493 | colliderArgs.Colliders = colliding; | ||
4494 | |||
4495 | return colliderArgs; | ||
4496 | } | ||
4497 | |||
4498 | private delegate void ScriptCollidingNotification(uint localID, ColliderArgs message); | ||
4499 | |||
4500 | private void SendCollisionEvent(SceneObjectGroup dest, scriptEvents ev, List<uint> colliders, ScriptCollidingNotification notify) | ||
4501 | { | ||
4502 | ColliderArgs CollidingMessage; | ||
4503 | |||
4504 | if (colliders.Count > 0) | ||
4505 | { | ||
4506 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4507 | { | ||
4508 | CollidingMessage = CreateColliderArgs(dest.RootPart, colliders); | ||
4509 | |||
4510 | if (CollidingMessage.Colliders.Count > 0) | ||
4511 | notify(dest.RootPart.LocalId, CollidingMessage); | ||
4512 | } | ||
4513 | } | ||
4514 | } | ||
4515 | |||
4516 | private void SendLandCollisionEvent(SceneObjectGroup dest, scriptEvents ev, ScriptCollidingNotification notify) | ||
4517 | { | ||
4518 | if ((dest.RootPart.ScriptEvents & ev) != 0) | ||
4519 | { | ||
4520 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
4521 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
4522 | |||
4523 | colliding.Add(CreateDetObjectForGround()); | ||
4524 | LandCollidingMessage.Colliders = colliding; | ||
4525 | |||
4526 | notify(dest.RootPart.LocalId, LandCollidingMessage); | ||
4527 | } | ||
4528 | } | ||
4529 | |||
4530 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4531 | { | ||
4532 | try | ||
4533 | { | ||
4534 | List<uint> thisHitColliders = new List<uint>(); | ||
4535 | List<uint> endedColliders = new List<uint>(); | ||
4536 | List<uint> startedColliders = new List<uint>(); | ||
4537 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4538 | CollisionForSoundInfo soundinfo; | ||
4539 | ContactPoint curcontact; | ||
4540 | |||
4541 | if (coldata.Count == 0) | ||
4542 | { | ||
4543 | if (m_lastColliders.Count == 0) | ||
4544 | return; // nothing to do | ||
4545 | |||
4546 | foreach (uint localID in m_lastColliders) | ||
4547 | { | ||
4548 | endedColliders.Add(localID); | ||
4549 | } | ||
4550 | m_lastColliders.Clear(); | ||
4551 | } | ||
4552 | |||
4553 | else | ||
4554 | { | ||
4555 | foreach (uint id in coldata.Keys) | ||
4556 | { | ||
4557 | thisHitColliders.Add(id); | ||
4558 | if (!m_lastColliders.Contains(id)) | ||
4559 | { | ||
4560 | startedColliders.Add(id); | ||
4561 | curcontact = coldata[id]; | ||
4562 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4563 | { | ||
4564 | soundinfo = new CollisionForSoundInfo(); | ||
4565 | soundinfo.colliderID = id; | ||
4566 | soundinfo.position = curcontact.Position; | ||
4567 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4568 | soundinfolist.Add(soundinfo); | ||
4569 | } | ||
4570 | } | ||
4571 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4572 | } | ||
4573 | |||
4574 | // calculate things that ended colliding | ||
4575 | foreach (uint localID in m_lastColliders) | ||
4576 | { | ||
4577 | if (!thisHitColliders.Contains(localID)) | ||
4578 | { | ||
4579 | endedColliders.Add(localID); | ||
4580 | } | ||
4581 | } | ||
4582 | //add the items that started colliding this time to the last colliders list. | ||
4583 | foreach (uint localID in startedColliders) | ||
4584 | { | ||
4585 | m_lastColliders.Add(localID); | ||
4586 | } | ||
4587 | // remove things that ended colliding from the last colliders list | ||
4588 | foreach (uint localID in endedColliders) | ||
4589 | { | ||
4590 | m_lastColliders.Remove(localID); | ||
4591 | } | ||
4592 | |||
4593 | if (soundinfolist.Count > 0) | ||
4594 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
4595 | } | ||
4596 | |||
4597 | foreach (SceneObjectGroup att in GetAttachments()) | ||
4598 | { | ||
4599 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
4600 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
4601 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
4602 | |||
4603 | if (startedColliders.Contains(0)) | ||
4604 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
4605 | if (m_lastColliders.Contains(0)) | ||
4606 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
4607 | if (endedColliders.Contains(0)) | ||
4608 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
4609 | } | ||
4610 | } | ||
4611 | finally | ||
4612 | { | ||
4613 | m_collisionEventFlag = false; | ||
4614 | } | ||
4615 | } | ||
4616 | |||
4170 | private void TeleportFlagsDebug() { | 4617 | private void TeleportFlagsDebug() { |
4171 | 4618 | ||
4172 | // Some temporary debugging help to show all the TeleportFlags we have... | 4619 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -4191,6 +4638,5 @@ namespace OpenSim.Region.Framework.Scenes | |||
4191 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 4638 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
4192 | 4639 | ||
4193 | } | 4640 | } |
4194 | |||
4195 | } | 4641 | } |
4196 | } | 4642 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 39420a6..ce4fb40 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -262,6 +262,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
262 | sr.Close(); | 262 | sr.Close(); |
263 | } | 263 | } |
264 | 264 | ||
265 | XmlNodeList keymotion = doc.GetElementsByTagName("KeyframeMotion"); | ||
266 | if (keymotion.Count > 0) | ||
267 | sceneObject.RootPart.KeyframeMotion = KeyframeMotion.FromData(sceneObject, Convert.FromBase64String(keymotion[0].InnerText)); | ||
268 | else | ||
269 | sceneObject.RootPart.KeyframeMotion = null; | ||
270 | |||
265 | // Script state may, or may not, exist. Not having any, is NOT | 271 | // Script state may, or may not, exist. Not having any, is NOT |
266 | // ever a problem. | 272 | // ever a problem. |
267 | sceneObject.LoadScriptState(doc); | 273 | sceneObject.LoadScriptState(doc); |
@@ -368,11 +374,21 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
368 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); | 374 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); |
369 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); | 375 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); |
370 | 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 | |||
371 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); | 385 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); |
372 | m_SOPXmlProcessors.Add("Density", ProcessDensity); | 386 | m_SOPXmlProcessors.Add("Density", ProcessDensity); |
373 | m_SOPXmlProcessors.Add("Friction", ProcessFriction); | 387 | m_SOPXmlProcessors.Add("Friction", ProcessFriction); |
374 | m_SOPXmlProcessors.Add("Bounce", ProcessBounce); | 388 | m_SOPXmlProcessors.Add("Bounce", ProcessBounce); |
375 | m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); | 389 | m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); |
390 | m_SOPXmlProcessors.Add("CameraEyeOffset", ProcessCameraEyeOffset); | ||
391 | m_SOPXmlProcessors.Add("CameraAtOffset", ProcessCameraAtOffset); | ||
376 | 392 | ||
377 | #endregion | 393 | #endregion |
378 | 394 | ||
@@ -401,7 +417,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
401 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); | 417 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); |
402 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); | 418 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); |
403 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); | 419 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); |
404 | 420 | ||
405 | #endregion | 421 | #endregion |
406 | 422 | ||
407 | #region ShapeXmlProcessors initialization | 423 | #region ShapeXmlProcessors initialization |
@@ -626,6 +642,33 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
626 | obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); | 642 | obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); |
627 | } | 643 | } |
628 | 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 | |||
629 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) | 672 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) |
630 | { | 673 | { |
631 | List<string> errorNodeNames; | 674 | List<string> errorNodeNames; |
@@ -795,6 +838,25 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
795 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); | 838 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); |
796 | } | 839 | } |
797 | 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 | |||
798 | #endregion | 860 | #endregion |
799 | 861 | ||
800 | #region TaskInventoryXmlProcessors | 862 | #region TaskInventoryXmlProcessors |
@@ -1182,6 +1244,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1182 | }); | 1244 | }); |
1183 | 1245 | ||
1184 | writer.WriteEndElement(); | 1246 | writer.WriteEndElement(); |
1247 | |||
1248 | if (sog.RootPart.KeyframeMotion != null) | ||
1249 | { | ||
1250 | Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); | ||
1251 | |||
1252 | writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); | ||
1253 | writer.WriteBase64(data, 0, data.Length); | ||
1254 | writer.WriteEndElement(); | ||
1255 | } | ||
1256 | |||
1185 | writer.WriteEndElement(); | 1257 | writer.WriteEndElement(); |
1186 | } | 1258 | } |
1187 | 1259 | ||
@@ -1289,6 +1361,16 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1289 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); | 1361 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); |
1290 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); | 1362 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); |
1291 | 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 | |||
1292 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) | 1374 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) |
1293 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); | 1375 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); |
1294 | if (sop.Density != 1000.0f) | 1376 | if (sop.Density != 1000.0f) |
@@ -1299,6 +1381,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1299 | writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); | 1381 | writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); |
1300 | if (sop.GravityModifier != 1.0f) | 1382 | if (sop.GravityModifier != 1.0f) |
1301 | 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()); | ||
1302 | 1386 | ||
1303 | writer.WriteEndElement(); | 1387 | writer.WriteEndElement(); |
1304 | } | 1388 | } |
@@ -1524,12 +1608,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1524 | { | 1608 | { |
1525 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); | 1609 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); |
1526 | 1610 | ||
1527 | if (reader.IsEmptyElement) | ||
1528 | { | ||
1529 | reader.Read(); | ||
1530 | return tinv; | ||
1531 | } | ||
1532 | |||
1533 | reader.ReadStartElement(name, String.Empty); | 1611 | reader.ReadStartElement(name, String.Empty); |
1534 | 1612 | ||
1535 | 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 b9d615e..5398ab9 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |||
@@ -175,7 +175,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
175 | 175 | ||
176 | // saved last reported value so there is something available for llGetRegionFPS | 176 | // saved last reported value so there is something available for llGetRegionFPS |
177 | private float lastReportedSimFPS; | 177 | private float lastReportedSimFPS; |
178 | private float[] lastReportedSimStats = new float[22]; | 178 | private float[] lastReportedSimStats = new float[23]; |
179 | private float m_pfps; | 179 | private float m_pfps; |
180 | 180 | ||
181 | /// <summary> | 181 | /// <summary> |
@@ -189,12 +189,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
189 | private int m_objectUpdates; | 189 | private int m_objectUpdates; |
190 | 190 | ||
191 | private int m_frameMS; | 191 | private int m_frameMS; |
192 | private int m_spareMS; | 192 | |
193 | private int m_netMS; | 193 | private int m_netMS; |
194 | private int m_agentMS; | 194 | private int m_agentMS; |
195 | private int m_physicsMS; | 195 | private int m_physicsMS; |
196 | private int m_imageMS; | 196 | private int m_imageMS; |
197 | private int m_otherMS; | 197 | private int m_otherMS; |
198 | private int m_sleeptimeMS; | ||
198 | 199 | ||
199 | //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. | 200 | //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. |
200 | //Ckrinke private int m_scriptMS = 0; | 201 | //Ckrinke private int m_scriptMS = 0; |
@@ -289,7 +290,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
289 | 290 | ||
290 | private void statsHeartBeat(object sender, EventArgs e) | 291 | private void statsHeartBeat(object sender, EventArgs e) |
291 | { | 292 | { |
292 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; | 293 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; |
293 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); | 294 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); |
294 | 295 | ||
295 | // Know what's not thread safe in Mono... modifying timers. | 296 | // Know what's not thread safe in Mono... modifying timers. |
@@ -327,6 +328,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
327 | physfps = 0; | 328 | physfps = 0; |
328 | 329 | ||
329 | #endregion | 330 | #endregion |
331 | float factor = 1 / m_statsUpdateFactor; | ||
332 | |||
333 | if (reportedFPS <= 0) | ||
334 | reportedFPS = 1; | ||
335 | |||
336 | float perframe = 1.0f / (float)reportedFPS; | ||
337 | |||
338 | float TotalFrameTime = m_frameMS * perframe; | ||
339 | |||
340 | float targetframetime = 1100.0f / (float)m_nominalReportedFps; | ||
341 | |||
342 | float sparetime; | ||
343 | float sleeptime; | ||
344 | |||
345 | if (TotalFrameTime > targetframetime) | ||
346 | { | ||
347 | sparetime = 0; | ||
348 | sleeptime = 0; | ||
349 | } | ||
350 | else | ||
351 | { | ||
352 | sparetime = m_frameMS - m_physicsMS - m_agentMS; | ||
353 | sparetime *= perframe; | ||
354 | if (sparetime < 0) | ||
355 | sparetime = 0; | ||
356 | else if (sparetime > TotalFrameTime) | ||
357 | sparetime = TotalFrameTime; | ||
358 | sleeptime = m_sleeptimeMS * perframe; | ||
359 | } | ||
330 | 360 | ||
331 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); | 361 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); |
332 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); | 362 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); |
@@ -338,25 +368,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
338 | // so that stat numbers are always consistent. | 368 | // so that stat numbers are always consistent. |
339 | CheckStatSanity(); | 369 | CheckStatSanity(); |
340 | 370 | ||
341 | //Our time dilation is 0.91 when we're running a full speed, | 371 | // other MS is actually simulation time |
342 | // therefore to make sure we get an appropriate range, | 372 | // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; |
343 | // we have to factor in our error. (0.10f * statsUpdateFactor) | 373 | // m_imageMS m_netMS are not included in m_frameMS |
344 | // multiplies the fix for the error times the amount of times it'll occur a second | ||
345 | // / 10 divides the value by the number of times the sim heartbeat runs (10fps) | ||
346 | // Then we divide the whole amount by the amount of seconds pass in between stats updates. | ||
347 | |||
348 | // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change | ||
349 | // values to X-per-second values. | ||
350 | 374 | ||
351 | uint thisFrame = m_scene.Frame; | 375 | m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; |
352 | float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; | 376 | if (m_otherMS < 0) |
353 | m_lastUpdateFrame = thisFrame; | 377 | m_otherMS = 0; |
354 | 378 | ||
355 | // Avoid div-by-zero if somehow we've not updated any frames. | 379 | for (int i = 0; i < 23; i++) |
356 | if (framesUpdated == 0) | ||
357 | framesUpdated = 1; | ||
358 | |||
359 | for (int i = 0; i < 22; i++) | ||
360 | { | 380 | { |
361 | sb[i] = new SimStatsPacket.StatBlock(); | 381 | sb[i] = new SimStatsPacket.StatBlock(); |
362 | } | 382 | } |
@@ -386,19 +406,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
386 | sb[7].StatValue = m_activePrim; | 406 | sb[7].StatValue = m_activePrim; |
387 | 407 | ||
388 | sb[8].StatID = (uint)Stats.FrameMS; | 408 | sb[8].StatID = (uint)Stats.FrameMS; |
389 | sb[8].StatValue = m_frameMS / framesUpdated; | 409 | sb[8].StatValue = TotalFrameTime; |
390 | 410 | ||
391 | sb[9].StatID = (uint)Stats.NetMS; | 411 | sb[9].StatID = (uint)Stats.NetMS; |
392 | sb[9].StatValue = m_netMS / framesUpdated; | 412 | sb[9].StatValue = m_netMS * perframe; |
393 | 413 | ||
394 | sb[10].StatID = (uint)Stats.PhysicsMS; | 414 | sb[10].StatID = (uint)Stats.PhysicsMS; |
395 | sb[10].StatValue = m_physicsMS / framesUpdated; | 415 | sb[10].StatValue = m_physicsMS * perframe; |
396 | 416 | ||
397 | sb[11].StatID = (uint)Stats.ImageMS ; | 417 | sb[11].StatID = (uint)Stats.ImageMS ; |
398 | sb[11].StatValue = m_imageMS / framesUpdated; | 418 | sb[11].StatValue = m_imageMS * perframe; |
399 | 419 | ||
400 | sb[12].StatID = (uint)Stats.OtherMS; | 420 | sb[12].StatID = (uint)Stats.OtherMS; |
401 | sb[12].StatValue = m_otherMS / framesUpdated; | 421 | sb[12].StatValue = m_otherMS * perframe; |
402 | 422 | ||
403 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; | 423 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; |
404 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); | 424 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); |
@@ -410,7 +430,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
410 | sb[15].StatValue = m_unAckedBytes; | 430 | sb[15].StatValue = m_unAckedBytes; |
411 | 431 | ||
412 | sb[16].StatID = (uint)Stats.AgentMS; | 432 | sb[16].StatID = (uint)Stats.AgentMS; |
413 | sb[16].StatValue = m_agentMS / framesUpdated; | 433 | sb[16].StatValue = m_agentMS * perframe; |
414 | 434 | ||
415 | sb[17].StatID = (uint)Stats.PendingDownloads; | 435 | sb[17].StatID = (uint)Stats.PendingDownloads; |
416 | sb[17].StatValue = m_pendingDownloads; | 436 | sb[17].StatValue = m_pendingDownloads; |
@@ -425,7 +445,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
425 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; | 445 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; |
426 | 446 | ||
427 | sb[21].StatID = (uint)Stats.SimSpareMs; | 447 | sb[21].StatID = (uint)Stats.SimSpareMs; |
428 | sb[21].StatValue = m_spareMS / framesUpdated; | 448 | sb[21].StatValue = sparetime; |
449 | |||
450 | sb[22].StatID = (uint)Stats.SimSleepMs; | ||
451 | sb[22].StatValue = sleeptime; | ||
429 | 452 | ||
430 | for (int i = 0; i < 22; i++) | 453 | for (int i = 0; i < 22; i++) |
431 | { | 454 | { |
@@ -444,28 +467,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
444 | } | 467 | } |
445 | 468 | ||
446 | // Extra statistics that aren't currently sent to clients | 469 | // Extra statistics that aren't currently sent to clients |
447 | lock (m_lastReportedExtraSimStats) | 470 | if (m_scene.PhysicsScene != null) |
448 | { | 471 | { |
449 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; | 472 | lock (m_lastReportedExtraSimStats) |
450 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
451 | |||
452 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
453 | |||
454 | if (physicsStats != null) | ||
455 | { | 473 | { |
456 | foreach (KeyValuePair<string, float> tuple in physicsStats) | 474 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; |
475 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
476 | |||
477 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
478 | |||
479 | if (physicsStats != null) | ||
457 | { | 480 | { |
458 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second | 481 | foreach (KeyValuePair<string, float> tuple in physicsStats) |
459 | // Need to change things so that stats source can indicate whether they are per second or | 482 | { |
460 | // per frame. | 483 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second |
461 | if (tuple.Key.EndsWith("MS")) | 484 | // Need to change things so that stats source can indicate whether they are per second or |
462 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; | 485 | // per frame. |
463 | else | 486 | if (tuple.Key.EndsWith("MS")) |
464 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | 487 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; |
488 | else | ||
489 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | ||
490 | } | ||
465 | } | 491 | } |
466 | } | 492 | } |
467 | } | 493 | } |
468 | 494 | ||
495 | // LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor; | ||
469 | ResetValues(); | 496 | ResetValues(); |
470 | } | 497 | } |
471 | } | 498 | } |
@@ -488,7 +515,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
488 | m_physicsMS = 0; | 515 | m_physicsMS = 0; |
489 | m_imageMS = 0; | 516 | m_imageMS = 0; |
490 | m_otherMS = 0; | 517 | m_otherMS = 0; |
491 | m_spareMS = 0; | 518 | // m_spareMS = 0; |
519 | m_sleeptimeMS = 0; | ||
492 | 520 | ||
493 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. | 521 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. |
494 | //Ckrinke m_scriptMS = 0; | 522 | //Ckrinke m_scriptMS = 0; |
@@ -572,11 +600,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
572 | SlowFramesStat.Value++; | 600 | SlowFramesStat.Value++; |
573 | } | 601 | } |
574 | 602 | ||
575 | public void AddSpareMS(int ms) | ||
576 | { | ||
577 | m_spareMS += ms; | ||
578 | } | ||
579 | |||
580 | public void addNetMS(int ms) | 603 | public void addNetMS(int ms) |
581 | { | 604 | { |
582 | m_netMS += ms; | 605 | m_netMS += ms; |
@@ -602,6 +625,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
602 | m_otherMS += ms; | 625 | m_otherMS += ms; |
603 | } | 626 | } |
604 | 627 | ||
628 | public void addSleepMS(int ms) | ||
629 | { | ||
630 | m_sleeptimeMS += ms; | ||
631 | } | ||
632 | |||
605 | public void AddPendingDownloads(int count) | 633 | public void AddPendingDownloads(int count) |
606 | { | 634 | { |
607 | m_pendingDownloads += count; | 635 | m_pendingDownloads += count; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index 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 96973de..0000000 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs +++ /dev/null | |||
@@ -1,184 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using NUnit.Framework; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Communications; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Tests.Common; | ||
36 | using OpenSim.Tests.Common.Mock; | ||
37 | |||
38 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
39 | { | ||
40 | /// <summary> | ||
41 | /// Tests for undo/redo | ||
42 | /// </summary> | ||
43 | public class SceneObjectUndoRedoTests : OpenSimTestCase | ||
44 | { | ||
45 | [Test] | ||
46 | public void TestUndoRedoResizeSceneObject() | ||
47 | { | ||
48 | TestHelpers.InMethod(); | ||
49 | // TestHelpers.EnableLogging(); | ||
50 | |||
51 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
52 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
53 | |||
54 | Scene scene = new SceneHelpers().SetupScene(); | ||
55 | scene.MaxUndoCount = 20; | ||
56 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
57 | |||
58 | // TODO: It happens to be the case that we are not storing undo states for SOPs which are not yet in a SOG, | ||
59 | // which is the way that AddSceneObject() sets up the object (i.e. it creates the SOP first). However, | ||
60 | // this is somewhat by chance. Really, we shouldn't be storing undo states at all if the object is not | ||
61 | // in a scene. | ||
62 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
63 | |||
64 | g1.GroupResize(firstSize); | ||
65 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
66 | |||
67 | g1.GroupResize(secondSize); | ||
68 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2)); | ||
69 | |||
70 | g1.RootPart.Undo(); | ||
71 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
72 | Assert.That(g1.GroupScale, Is.EqualTo(firstSize)); | ||
73 | |||
74 | g1.RootPart.Redo(); | ||
75 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2)); | ||
76 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
77 | } | ||
78 | |||
79 | [Test] | ||
80 | public void TestUndoLimit() | ||
81 | { | ||
82 | TestHelpers.InMethod(); | ||
83 | |||
84 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
85 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
86 | Vector3 thirdSize = new Vector3(8, 9, 10); | ||
87 | Vector3 fourthSize = new Vector3(11, 12, 13); | ||
88 | |||
89 | Scene scene = new SceneHelpers().SetupScene(); | ||
90 | scene.MaxUndoCount = 2; | ||
91 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
92 | |||
93 | g1.GroupResize(firstSize); | ||
94 | g1.GroupResize(secondSize); | ||
95 | g1.GroupResize(thirdSize); | ||
96 | g1.GroupResize(fourthSize); | ||
97 | |||
98 | g1.RootPart.Undo(); | ||
99 | g1.RootPart.Undo(); | ||
100 | g1.RootPart.Undo(); | ||
101 | |||
102 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
103 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
104 | } | ||
105 | |||
106 | [Test] | ||
107 | public void TestNoUndoOnObjectsNotInScene() | ||
108 | { | ||
109 | TestHelpers.InMethod(); | ||
110 | |||
111 | Vector3 firstSize = new Vector3(2, 3, 4); | ||
112 | Vector3 secondSize = new Vector3(5, 6, 7); | ||
113 | Vector3 thirdSize = new Vector3(8, 9, 10); | ||
114 | Vector3 fourthSize = new Vector3(11, 12, 13); | ||
115 | |||
116 | Scene scene = new SceneHelpers().SetupScene(); | ||
117 | scene.MaxUndoCount = 20; | ||
118 | SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); | ||
119 | |||
120 | g1.GroupResize(firstSize); | ||
121 | g1.GroupResize(secondSize); | ||
122 | |||
123 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
124 | |||
125 | g1.RootPart.Undo(); | ||
126 | |||
127 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); | ||
128 | } | ||
129 | |||
130 | [Test] | ||
131 | public void TestUndoBeyondAvailable() | ||
132 | { | ||
133 | TestHelpers.InMethod(); | ||
134 | |||
135 | Vector3 newSize = new Vector3(2, 3, 4); | ||
136 | |||
137 | Scene scene = new SceneHelpers().SetupScene(); | ||
138 | scene.MaxUndoCount = 20; | ||
139 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
140 | Vector3 originalSize = g1.GroupScale; | ||
141 | |||
142 | g1.RootPart.Undo(); | ||
143 | |||
144 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
145 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
146 | |||
147 | g1.GroupResize(newSize); | ||
148 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
149 | Assert.That(g1.GroupScale, Is.EqualTo(newSize)); | ||
150 | |||
151 | g1.RootPart.Undo(); | ||
152 | g1.RootPart.Undo(); | ||
153 | |||
154 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
155 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
156 | } | ||
157 | |||
158 | [Test] | ||
159 | public void TestRedoBeyondAvailable() | ||
160 | { | ||
161 | TestHelpers.InMethod(); | ||
162 | |||
163 | Vector3 newSize = new Vector3(2, 3, 4); | ||
164 | |||
165 | Scene scene = new SceneHelpers().SetupScene(); | ||
166 | scene.MaxUndoCount = 20; | ||
167 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); | ||
168 | Vector3 originalSize = g1.GroupScale; | ||
169 | |||
170 | g1.RootPart.Redo(); | ||
171 | |||
172 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); | ||
173 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); | ||
174 | |||
175 | g1.GroupResize(newSize); | ||
176 | g1.RootPart.Undo(); | ||
177 | g1.RootPart.Redo(); | ||
178 | g1.RootPart.Redo(); | ||
179 | |||
180 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); | ||
181 | Assert.That(g1.GroupScale, Is.EqualTo(newSize)); | ||
182 | } | ||
183 | } | ||
184 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index 2b79271..c7eaff9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs | |||
@@ -44,7 +44,7 @@ using OpenSim.Tests.Common.Mock; | |||
44 | namespace OpenSim.Region.Framework.Scenes.Tests | 44 | namespace OpenSim.Region.Framework.Scenes.Tests |
45 | { | 45 | { |
46 | [TestFixture] | 46 | [TestFixture] |
47 | public class SceneObjectUserGroupTests : OpenSimTestCase | 47 | public class SceneObjectUserGroupTests |
48 | { | 48 | { |
49 | /// <summary> | 49 | /// <summary> |
50 | /// Test share with group object functionality | 50 | /// Test share with group object functionality |
@@ -54,6 +54,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
54 | public void TestShareWithGroup() | 54 | public void TestShareWithGroup() |
55 | { | 55 | { |
56 | TestHelpers.InMethod(); | 56 | TestHelpers.InMethod(); |
57 | // log4net.Config.XmlConfigurator.Configure(); | ||
57 | 58 | ||
58 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 59 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
59 | 60 | ||
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs index 860172c..7bbf1bd 100644 --- a/OpenSim/Region/Framework/Scenes/UndoState.cs +++ b/OpenSim/Region/Framework/Scenes/UndoState.cs | |||
@@ -27,202 +27,307 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | ||
30 | using log4net; | 31 | using log4net; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
33 | 35 | ||
34 | namespace OpenSim.Region.Framework.Scenes | 36 | namespace OpenSim.Region.Framework.Scenes |
35 | { | 37 | { |
36 | public class UndoState | 38 | public class UndoState |
37 | { | 39 | { |
38 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 40 | const int UNDOEXPIRESECONDS = 300; // undo expire time (nice to have it came from a ini later) |
39 | |||
40 | public Vector3 Position = Vector3.Zero; | ||
41 | public Vector3 Scale = Vector3.Zero; | ||
42 | public Quaternion Rotation = Quaternion.Identity; | ||
43 | |||
44 | /// <summary> | ||
45 | /// Is this undo state for an entire group? | ||
46 | /// </summary> | ||
47 | public bool ForGroup; | ||
48 | 41 | ||
42 | public ObjectChangeData data; | ||
43 | public DateTime creationtime; | ||
49 | /// <summary> | 44 | /// <summary> |
50 | /// Constructor. | 45 | /// Constructor. |
51 | /// </summary> | 46 | /// </summary> |
52 | /// <param name="part"></param> | 47 | /// <param name="part"></param> |
53 | /// <param name="forGroup">True if the undo is for an entire group</param> | 48 | /// <param name="change">bit field with what is changed</param> |
54 | public UndoState(SceneObjectPart part, bool forGroup) | 49 | /// |
50 | public UndoState(SceneObjectPart part, ObjectChangeType change) | ||
55 | { | 51 | { |
56 | if (part.ParentID == 0) | 52 | data = new ObjectChangeData(); |
57 | { | 53 | data.change = change; |
58 | ForGroup = forGroup; | 54 | creationtime = DateTime.UtcNow; |
59 | |||
60 | // if (ForGroup) | ||
61 | Position = part.ParentGroup.AbsolutePosition; | ||
62 | // else | ||
63 | // Position = part.OffsetPosition; | ||
64 | |||
65 | // m_log.DebugFormat( | ||
66 | // "[UNDO STATE]: Storing undo position {0} for root part", Position); | ||
67 | 55 | ||
68 | Rotation = part.RotationOffset; | 56 | if (part.ParentGroup.RootPart == part) |
69 | 57 | { | |
70 | // m_log.DebugFormat( | 58 | if ((change & ObjectChangeType.Position) != 0) |
71 | // "[UNDO STATE]: Storing undo rotation {0} for root part", Rotation); | 59 | data.position = part.ParentGroup.AbsolutePosition; |
72 | 60 | if ((change & ObjectChangeType.Rotation) != 0) | |
73 | Scale = part.Shape.Scale; | 61 | data.rotation = part.RotationOffset; |
74 | 62 | if ((change & ObjectChangeType.Scale) != 0) | |
75 | // m_log.DebugFormat( | 63 | data.scale = part.Shape.Scale; |
76 | // "[UNDO STATE]: Storing undo scale {0} for root part", Scale); | ||
77 | } | 64 | } |
78 | else | 65 | else |
79 | { | 66 | { |
80 | Position = part.OffsetPosition; | 67 | if ((change & ObjectChangeType.Position) != 0) |
81 | // m_log.DebugFormat( | 68 | data.position = part.OffsetPosition; |
82 | // "[UNDO STATE]: Storing undo position {0} for child part", Position); | 69 | if ((change & ObjectChangeType.Rotation) != 0) |
70 | data.rotation = part.RotationOffset; | ||
71 | if ((change & ObjectChangeType.Scale) != 0) | ||
72 | data.scale = part.Shape.Scale; | ||
73 | } | ||
74 | } | ||
75 | /// <summary> | ||
76 | /// check if undo or redo is too old | ||
77 | /// </summary> | ||
83 | 78 | ||
84 | Rotation = part.RotationOffset; | 79 | public bool checkExpire() |
85 | // m_log.DebugFormat( | 80 | { |
86 | // "[UNDO STATE]: Storing undo rotation {0} for child part", Rotation); | 81 | TimeSpan t = DateTime.UtcNow - creationtime; |
82 | if (t.Seconds > UNDOEXPIRESECONDS) | ||
83 | return true; | ||
84 | return false; | ||
85 | } | ||
87 | 86 | ||
88 | Scale = part.Shape.Scale; | 87 | /// <summary> |
89 | // m_log.DebugFormat( | 88 | /// updates undo or redo creation time to now |
90 | // "[UNDO STATE]: Storing undo scale {0} for child part", Scale); | 89 | /// </summary> |
91 | } | 90 | public void updateExpire() |
91 | { | ||
92 | creationtime = DateTime.UtcNow; | ||
92 | } | 93 | } |
93 | 94 | ||
94 | /// <summary> | 95 | /// <summary> |
95 | /// Compare the relevant state in the given part to this state. | 96 | /// Compare the relevant state in the given part to this state. |
96 | /// </summary> | 97 | /// </summary> |
97 | /// <param name="part"></param> | 98 | /// <param name="part"></param> |
98 | /// <returns>true if both the part's position, rotation and scale match those in this undo state. False otherwise.</returns> | 99 | /// <returns>true what fiels and related data are equal, False otherwise.</returns> |
99 | public bool Compare(SceneObjectPart part) | 100 | /// |
101 | public bool Compare(SceneObjectPart part, ObjectChangeType change) | ||
100 | { | 102 | { |
103 | if (data.change != change) // if diferent targets, then they are diferent | ||
104 | return false; | ||
105 | |||
101 | if (part != null) | 106 | if (part != null) |
102 | { | 107 | { |
103 | if (part.ParentID == 0) | 108 | if (part.ParentID == 0) |
104 | return | 109 | { |
105 | Position == part.ParentGroup.AbsolutePosition | 110 | if ((change & ObjectChangeType.Position) != 0 && data.position != part.ParentGroup.AbsolutePosition) |
106 | && Rotation == part.RotationOffset | 111 | return false; |
107 | && Scale == part.Shape.Scale; | 112 | } |
108 | else | 113 | else |
109 | return | 114 | { |
110 | Position == part.OffsetPosition | 115 | if ((change & ObjectChangeType.Position) != 0 && data.position != part.OffsetPosition) |
111 | && Rotation == part.RotationOffset | 116 | return false; |
112 | && Scale == part.Shape.Scale; | 117 | } |
113 | } | 118 | |
119 | if ((change & ObjectChangeType.Rotation) != 0 && data.rotation != part.RotationOffset) | ||
120 | return false; | ||
121 | if ((change & ObjectChangeType.Rotation) != 0 && data.scale == part.Shape.Scale) | ||
122 | return false; | ||
123 | return true; | ||
114 | 124 | ||
125 | } | ||
115 | return false; | 126 | return false; |
116 | } | 127 | } |
117 | 128 | ||
118 | public void PlaybackState(SceneObjectPart part) | 129 | /// <summary> |
130 | /// executes the undo or redo to a part or its group | ||
131 | /// </summary> | ||
132 | /// <param name="part"></param> | ||
133 | /// | ||
134 | |||
135 | public void PlayState(SceneObjectPart part) | ||
119 | { | 136 | { |
120 | part.Undoing = true; | 137 | part.Undoing = true; |
121 | 138 | ||
122 | if (part.ParentID == 0) | 139 | SceneObjectGroup grp = part.ParentGroup; |
123 | { | ||
124 | // m_log.DebugFormat( | ||
125 | // "[UNDO STATE]: Undoing position to {0} for root part {1} {2}", | ||
126 | // Position, part.Name, part.LocalId); | ||
127 | 140 | ||
128 | if (Position != Vector3.Zero) | 141 | if (grp != null) |
129 | { | 142 | { |
130 | if (ForGroup) | 143 | grp.doChangeObject(part, data); |
131 | part.ParentGroup.AbsolutePosition = Position; | 144 | } |
132 | else | 145 | part.Undoing = false; |
133 | part.ParentGroup.UpdateRootPosition(Position); | 146 | } |
134 | } | 147 | } |
135 | 148 | ||
136 | // m_log.DebugFormat( | 149 | public class UndoRedoState |
137 | // "[UNDO STATE]: Undoing rotation {0} to {1} for root part {2} {3}", | 150 | { |
138 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | 151 | int size; |
152 | public LinkedList<UndoState> m_redo = new LinkedList<UndoState>(); | ||
153 | public LinkedList<UndoState> m_undo = new LinkedList<UndoState>(); | ||
139 | 154 | ||
140 | if (ForGroup) | 155 | /// <summary> |
141 | part.UpdateRotation(Rotation); | 156 | /// creates a new UndoRedoState with default states memory size |
142 | else | 157 | /// </summary> |
143 | part.ParentGroup.UpdateRootRotation(Rotation); | ||
144 | 158 | ||
145 | if (Scale != Vector3.Zero) | 159 | public UndoRedoState() |
146 | { | 160 | { |
147 | // m_log.DebugFormat( | 161 | size = 5; |
148 | // "[UNDO STATE]: Undoing scale {0} to {1} for root part {2} {3}", | 162 | } |
149 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | ||
150 | 163 | ||
151 | if (ForGroup) | 164 | /// <summary> |
152 | part.ParentGroup.GroupResize(Scale); | 165 | /// creates a new UndoRedoState with states memory having indicated size |
153 | else | 166 | /// </summary> |
154 | part.Resize(Scale); | 167 | /// <param name="size"></param> |
155 | } | ||
156 | 168 | ||
157 | part.ParentGroup.ScheduleGroupForTerseUpdate(); | 169 | public UndoRedoState(int _size) |
158 | } | 170 | { |
171 | if (_size < 3) | ||
172 | size = 3; | ||
159 | else | 173 | else |
160 | { | 174 | size = _size; |
161 | // Note: Updating these properties on sop automatically schedules an update if needed | 175 | } |
162 | if (Position != Vector3.Zero) | ||
163 | { | ||
164 | // m_log.DebugFormat( | ||
165 | // "[UNDO STATE]: Undoing position {0} to {1} for child part {2} {3}", | ||
166 | // part.OffsetPosition, Position, part.Name, part.LocalId); | ||
167 | 176 | ||
168 | part.OffsetPosition = Position; | 177 | /// <summary> |
169 | } | 178 | /// returns number of undo entries in memory |
179 | /// </summary> | ||
170 | 180 | ||
171 | // m_log.DebugFormat( | 181 | public int Count |
172 | // "[UNDO STATE]: Undoing rotation {0} to {1} for child part {2} {3}", | 182 | { |
173 | // part.RotationOffset, Rotation, part.Name, part.LocalId); | 183 | get { return m_undo.Count; } |
184 | } | ||
174 | 185 | ||
175 | part.UpdateRotation(Rotation); | 186 | /// <summary> |
187 | /// clears all undo and redo entries | ||
188 | /// </summary> | ||
176 | 189 | ||
177 | if (Scale != Vector3.Zero) | 190 | public void Clear() |
191 | { | ||
192 | m_undo.Clear(); | ||
193 | m_redo.Clear(); | ||
194 | } | ||
195 | |||
196 | /// <summary> | ||
197 | /// adds a new state undo to part or its group, with changes indicated by what bits | ||
198 | /// </summary> | ||
199 | /// <param name="part"></param> | ||
200 | /// <param name="change">bit field with what is changed</param> | ||
201 | |||
202 | public void StoreUndo(SceneObjectPart part, ObjectChangeType change) | ||
203 | { | ||
204 | lock (m_undo) | ||
205 | { | ||
206 | UndoState last; | ||
207 | |||
208 | if (m_redo.Count > 0) // last code seems to clear redo on every new undo | ||
178 | { | 209 | { |
179 | // m_log.DebugFormat( | 210 | m_redo.Clear(); |
180 | // "[UNDO STATE]: Undoing scale {0} to {1} for child part {2} {3}", | 211 | } |
181 | // part.Shape.Scale, Scale, part.Name, part.LocalId); | ||
182 | 212 | ||
183 | part.Resize(Scale); | 213 | if (m_undo.Count > 0) |
214 | { | ||
215 | // check expired entry | ||
216 | last = m_undo.First.Value; | ||
217 | if (last != null && last.checkExpire()) | ||
218 | m_undo.Clear(); | ||
219 | else | ||
220 | { | ||
221 | // see if we actually have a change | ||
222 | if (last != null) | ||
223 | { | ||
224 | if (last.Compare(part, change)) | ||
225 | return; | ||
226 | } | ||
227 | } | ||
184 | } | 228 | } |
185 | } | ||
186 | 229 | ||
187 | part.Undoing = false; | 230 | // limite size |
231 | while (m_undo.Count >= size) | ||
232 | m_undo.RemoveLast(); | ||
233 | |||
234 | UndoState nUndo = new UndoState(part, change); | ||
235 | m_undo.AddFirst(nUndo); | ||
236 | } | ||
188 | } | 237 | } |
189 | 238 | ||
190 | public void PlayfwdState(SceneObjectPart part) | 239 | /// <summary> |
191 | { | 240 | /// executes last state undo to part or its group |
192 | part.Undoing = true; | 241 | /// current state is pushed into redo |
242 | /// </summary> | ||
243 | /// <param name="part"></param> | ||
193 | 244 | ||
194 | if (part.ParentID == 0) | 245 | public void Undo(SceneObjectPart part) |
246 | { | ||
247 | lock (m_undo) | ||
195 | { | 248 | { |
196 | if (Position != Vector3.Zero) | 249 | UndoState nUndo; |
197 | part.ParentGroup.AbsolutePosition = Position; | ||
198 | |||
199 | if (Rotation != Quaternion.Identity) | ||
200 | part.UpdateRotation(Rotation); | ||
201 | 250 | ||
202 | if (Scale != Vector3.Zero) | 251 | // expire redo |
252 | if (m_redo.Count > 0) | ||
203 | { | 253 | { |
204 | if (ForGroup) | 254 | nUndo = m_redo.First.Value; |
205 | part.ParentGroup.GroupResize(Scale); | 255 | if (nUndo != null && nUndo.checkExpire()) |
206 | else | 256 | m_redo.Clear(); |
207 | part.Resize(Scale); | ||
208 | } | 257 | } |
209 | 258 | ||
210 | part.ParentGroup.ScheduleGroupForTerseUpdate(); | 259 | if (m_undo.Count > 0) |
260 | { | ||
261 | UndoState goback = m_undo.First.Value; | ||
262 | // check expired | ||
263 | if (goback != null && goback.checkExpire()) | ||
264 | { | ||
265 | m_undo.Clear(); | ||
266 | return; | ||
267 | } | ||
268 | |||
269 | if (goback != null) | ||
270 | { | ||
271 | m_undo.RemoveFirst(); | ||
272 | |||
273 | // redo limite size | ||
274 | while (m_redo.Count >= size) | ||
275 | m_redo.RemoveLast(); | ||
276 | |||
277 | nUndo = new UndoState(part, goback.data.change); // new value in part should it be full goback copy? | ||
278 | m_redo.AddFirst(nUndo); | ||
279 | |||
280 | goback.PlayState(part); | ||
281 | } | ||
282 | } | ||
211 | } | 283 | } |
212 | else | 284 | } |
285 | |||
286 | /// <summary> | ||
287 | /// executes last state redo to part or its group | ||
288 | /// current state is pushed into undo | ||
289 | /// </summary> | ||
290 | /// <param name="part"></param> | ||
291 | |||
292 | public void Redo(SceneObjectPart part) | ||
293 | { | ||
294 | lock (m_undo) | ||
213 | { | 295 | { |
214 | // Note: Updating these properties on sop automatically schedules an update if needed | 296 | UndoState nUndo; |
215 | if (Position != Vector3.Zero) | ||
216 | part.OffsetPosition = Position; | ||
217 | 297 | ||
218 | if (Rotation != Quaternion.Identity) | 298 | // expire undo |
219 | part.UpdateRotation(Rotation); | 299 | if (m_undo.Count > 0) |
300 | { | ||
301 | nUndo = m_undo.First.Value; | ||
302 | if (nUndo != null && nUndo.checkExpire()) | ||
303 | m_undo.Clear(); | ||
304 | } | ||
220 | 305 | ||
221 | if (Scale != Vector3.Zero) | 306 | if (m_redo.Count > 0) |
222 | part.Resize(Scale); | 307 | { |
308 | UndoState gofwd = m_redo.First.Value; | ||
309 | // check expired | ||
310 | if (gofwd != null && gofwd.checkExpire()) | ||
311 | { | ||
312 | m_redo.Clear(); | ||
313 | return; | ||
314 | } | ||
315 | |||
316 | if (gofwd != null) | ||
317 | { | ||
318 | m_redo.RemoveFirst(); | ||
319 | |||
320 | // limite undo size | ||
321 | while (m_undo.Count >= size) | ||
322 | m_undo.RemoveLast(); | ||
323 | |||
324 | nUndo = new UndoState(part, gofwd.data.change); // new value in part should it be full gofwd copy? | ||
325 | m_undo.AddFirst(nUndo); | ||
326 | |||
327 | gofwd.PlayState(part); | ||
328 | } | ||
329 | } | ||
223 | } | 330 | } |
224 | |||
225 | part.Undoing = false; | ||
226 | } | 331 | } |
227 | } | 332 | } |
228 | 333 | ||
@@ -247,4 +352,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
247 | m_terrainModule.UndoTerrain(m_terrainChannel); | 352 | m_terrainModule.UndoTerrain(m_terrainChannel); |
248 | } | 353 | } |
249 | } | 354 | } |
250 | } \ No newline at end of file | 355 | } |
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index ad33607..b09ae39 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -84,10 +84,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
84 | /// <param name="assetUuids">The assets gathered</param> | 84 | /// <param name="assetUuids">The assets gathered</param> |
85 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) | 85 | public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) |
86 | { | 86 | { |
87 | // avoid infinite loops | ||
88 | if (assetUuids.ContainsKey(assetUuid)) | ||
89 | return; | ||
90 | |||
91 | try | 87 | try |
92 | { | 88 | { |
93 | assetUuids[assetUuid] = assetType; | 89 | assetUuids[assetUuid] = assetType; |