diff options
Diffstat (limited to 'OpenSim/Region/Framework')
54 files changed, 10149 insertions, 2219 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs b/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs index 0cc8fb6..e0aad2b 100644 --- a/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs +++ b/OpenSim/Region/Framework/Interfaces/IAgentAssetTransactions.cs | |||
@@ -36,7 +36,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
36 | void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, | 36 | void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, |
37 | InventoryItemBase item); | 37 | InventoryItemBase item); |
38 | 38 | ||
39 | void HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, | 39 | bool HandleItemCreationFromTransaction(IClientAPI remoteClient, UUID transactionID, UUID folderID, |
40 | uint callbackID, string description, string name, sbyte invType, | 40 | uint callbackID, string description, string name, sbyte invType, |
41 | sbyte type, byte wearableType, uint nextOwnerMask); | 41 | sbyte type, byte wearableType, uint nextOwnerMask); |
42 | 42 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index d9901bd..3c1247f 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Xml; | ||
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using OpenMetaverse; | 31 | using OpenMetaverse; |
31 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
@@ -89,7 +90,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
89 | /// <param name="addToInventory">If true then add object to user inventory</param> | 90 | /// <param name="addToInventory">If true then add object to user inventory</param> |
90 | /// <param name="append">Append to attachment point rather than replace.</param> | 91 | /// <param name="append">Append to attachment point rather than replace.</param> |
91 | /// <returns>true if the object was successfully attached, false otherwise</returns> | 92 | /// <returns>true if the object was successfully attached, false otherwise</returns> |
92 | bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool addToInventory, bool append); | 93 | bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool useAttachmentInfo, bool addToInventory, bool append); |
93 | 94 | ||
94 | /// <summary> | 95 | /// <summary> |
95 | /// Rez an attachment from user inventory and change inventory status to match. | 96 | /// Rez an attachment from user inventory and change inventory status to match. |
@@ -98,7 +99,11 @@ namespace OpenSim.Region.Framework.Interfaces | |||
98 | /// <param name="itemID"></param> | 99 | /// <param name="itemID"></param> |
99 | /// <param name="AttachmentPt"></param> | 100 | /// <param name="AttachmentPt"></param> |
100 | /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> | 101 | /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> |
101 | SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt); | 102 | ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt); |
103 | |||
104 | // Same as above, but also load script states from a separate doc | ||
105 | ISceneEntity RezSingleAttachmentFromInventory( | ||
106 | IScenePresence presence, UUID itemID, uint AttachmentPt, XmlDocument doc); | ||
102 | 107 | ||
103 | /// <summary> | 108 | /// <summary> |
104 | /// Rez multiple attachments from a user's inventory | 109 | /// Rez multiple attachments from a user's inventory |
@@ -130,7 +135,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
130 | /// <param name="grp">The attachment to detach.</param> | 135 | /// <param name="grp">The attachment to detach.</param> |
131 | void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup grp); | 136 | void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup grp); |
132 | 137 | ||
133 | /// <summary> | ||
134 | /// Update the position of an attachment. | 138 | /// Update the position of an attachment. |
135 | /// </summary> | 139 | /// </summary> |
136 | /// <param name="sog"></param> | 140 | /// <param name="sog"></param> |
diff --git a/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs index b536a49..570d31c 100644 --- a/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs | |||
@@ -35,6 +35,7 @@ namespace OpenSim.Services.Interfaces | |||
35 | public interface IBakedTextureModule | 35 | public interface IBakedTextureModule |
36 | { | 36 | { |
37 | WearableCacheItem[] Get(UUID id); | 37 | WearableCacheItem[] Get(UUID id); |
38 | void Store(UUID id, WearableCacheItem[] data); | 38 | void Store(UUID id); |
39 | void UpdateMeshAvatar(UUID id); | ||
39 | } | 40 | } |
40 | } | 41 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs b/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs index 522c82d..30d404e 100644 --- a/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ICapabilitiesModule.cs | |||
@@ -40,19 +40,19 @@ namespace OpenSim.Region.Framework.Interfaces | |||
40 | /// </summary> | 40 | /// </summary> |
41 | /// <param name="agentId"></param> | 41 | /// <param name="agentId"></param> |
42 | /// <param name="capsObjectPath"></param> | 42 | /// <param name="capsObjectPath"></param> |
43 | void CreateCaps(UUID agentId); | 43 | void CreateCaps(UUID agentId, uint circuitCode); |
44 | 44 | ||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Remove the caps handler for a given agent. | 46 | /// Remove the caps handler for a given agent. |
47 | /// </summary> | 47 | /// </summary> |
48 | /// <param name="agentId"></param> | 48 | /// <param name="agentId"></param> |
49 | void RemoveCaps(UUID agentId); | 49 | void RemoveCaps(UUID agentId, uint circuitCode); |
50 | 50 | ||
51 | /// <summary> | 51 | /// <summary> |
52 | /// Will return null if the agent doesn't have a caps handler registered | 52 | /// Will return null if the agent doesn't have a caps handler registered |
53 | /// </summary> | 53 | /// </summary> |
54 | /// <param name="agentId"></param> | 54 | /// <param name="agentId"></param> |
55 | Caps GetCapsForUser(UUID agentId); | 55 | Caps GetCapsForUser(uint circuitCode); |
56 | 56 | ||
57 | void SetAgentCapsSeeds(AgentCircuitData agent); | 57 | void SetAgentCapsSeeds(AgentCircuitData agent); |
58 | 58 | ||
@@ -65,5 +65,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
65 | void DropChildSeed(UUID agentID, ulong handle); | 65 | void DropChildSeed(UUID agentID, ulong handle); |
66 | 66 | ||
67 | string GetCapsPath(UUID agentId); | 67 | string GetCapsPath(UUID agentId); |
68 | |||
69 | void ActivateCaps(uint circuitCode); | ||
68 | } | 70 | } |
69 | } | 71 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs b/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs index 08b71e4..4d000b6 100644 --- a/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IDynamicMenuModule.cs | |||
@@ -43,6 +43,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
43 | public enum UserMode : int | 43 | public enum UserMode : int |
44 | { | 44 | { |
45 | Normal = 0, | 45 | Normal = 0, |
46 | RegionManager = 2, | ||
46 | God = 3 | 47 | God = 3 |
47 | } | 48 | } |
48 | 49 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index 9ffda51..b85fd8b 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> |
@@ -244,7 +246,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
244 | /// <param name="objlist">The scene objects</param> | 246 | /// <param name="objlist">The scene objects</param> |
245 | /// <param name="veclist">Relative offsets for each object</param> | 247 | /// <param name="veclist">Relative offsets for each object</param> |
246 | /// <returns>true = success, false = the scene object asset couldn't be found</returns> | 248 | /// <returns>true = success, false = the scene object asset couldn't be found</returns> |
247 | bool GetRezReadySceneObjects(TaskInventoryItem item, out List<SceneObjectGroup> objlist, out List<Vector3> veclist); | 249 | bool GetRezReadySceneObjects(TaskInventoryItem item, out List<SceneObjectGroup> objlist, out List<Vector3> veclist, out Vector3 bbox, out float offsetHeight); |
248 | 250 | ||
249 | /// <summary> | 251 | /// <summary> |
250 | /// Update an existing inventory item. | 252 | /// Update an existing inventory item. |
@@ -318,5 +320,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
318 | /// A <see cref="Dictionary`2"/> | 320 | /// A <see cref="Dictionary`2"/> |
319 | /// </returns> | 321 | /// </returns> |
320 | Dictionary<UUID, string> GetScriptStates(); | 322 | Dictionary<UUID, string> GetScriptStates(); |
323 | Dictionary<UUID, string> GetScriptStates(bool oldIDs); | ||
321 | } | 324 | } |
322 | } | 325 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs index 1ebef90..50448b4 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs | |||
@@ -36,6 +36,7 @@ using OpenSim.Region.Framework.Scenes; | |||
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); | 38 | public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version); |
39 | public delegate ScenePresence CrossAsyncDelegate(ScenePresence agent, bool isFlying); | ||
39 | 40 | ||
40 | public interface IEntityTransferModule | 41 | public interface IEntityTransferModule |
41 | { | 42 | { |
@@ -92,10 +93,17 @@ namespace OpenSim.Region.Framework.Interfaces | |||
92 | 93 | ||
93 | void EnableChildAgent(ScenePresence agent, GridRegion region); | 94 | void EnableChildAgent(ScenePresence agent, GridRegion region); |
94 | 95 | ||
96 | <<<<<<< HEAD | ||
95 | GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version, | 97 | GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version, |
96 | out Vector3 newpos, out string reason); | 98 | out Vector3 newpos, out string reason); |
97 | 99 | ||
100 | ======= | ||
101 | GridRegion GetDestination(Scene scene, UUID agentID, Vector3 pos, out string version, out Vector3 newpos); | ||
102 | GridRegion GetObjectDestination(SceneObjectGroup grp, Vector3 targetPosition, out Vector3 newpos); | ||
103 | bool checkAgentAccessToRegion(ScenePresence agent, GridRegion destiny, Vector3 position, out string version, out string reason); | ||
104 | >>>>>>> avn/ubitvar | ||
98 | void Cross(SceneObjectGroup sog, Vector3 position, bool silent); | 105 | void Cross(SceneObjectGroup sog, Vector3 position, bool silent); |
106 | bool CrossPrimGroupIntoNewRegion(GridRegion destination, Vector3 newPosition, SceneObjectGroup grp, bool silent); | ||
99 | 107 | ||
100 | ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version); | 108 | ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, GridRegion neighbourRegion, bool isFlying, string version); |
101 | 109 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs b/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs index 124504c..2f9b222 100644 --- a/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs +++ b/OpenSim/Region/Framework/Interfaces/IHttpRequests.cs | |||
@@ -58,6 +58,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
58 | public interface IHttpRequestModule | 58 | public interface IHttpRequestModule |
59 | { | 59 | { |
60 | UUID MakeHttpRequest(string url, string parameters, string body); | 60 | UUID MakeHttpRequest(string url, string parameters, string body); |
61 | <<<<<<< HEAD | ||
61 | 62 | ||
62 | /// <summary> | 63 | /// <summary> |
63 | /// Starts the http request. | 64 | /// Starts the http request. |
@@ -87,6 +88,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
87 | /// <param name='id'></param> | 88 | /// <param name='id'></param> |
88 | void StopHttpRequestsForScript(UUID id); | 89 | void StopHttpRequestsForScript(UUID id); |
89 | 90 | ||
91 | ======= | ||
92 | UUID StartHttpRequest(uint localID, UUID itemID, string url, List<string> parameters, Dictionary<string, string> headers, string body); | ||
93 | void StopHttpRequest(uint m_localID, UUID m_itemID); | ||
94 | >>>>>>> avn/ubitvar | ||
90 | IServiceRequest GetNextCompletedRequest(); | 95 | IServiceRequest GetNextCompletedRequest(); |
91 | void RemoveCompletedRequest(UUID id); | 96 | void RemoveCompletedRequest(UUID id); |
92 | } | 97 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IMapImageUploadModule.cs b/OpenSim/Region/Framework/Interfaces/IMapImageUploadModule.cs index 6a7d4a1..eb79711 100644 --- a/OpenSim/Region/Framework/Interfaces/IMapImageUploadModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IMapImageUploadModule.cs | |||
@@ -25,13 +25,29 @@ | |||
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 | <<<<<<< HEAD | ||
28 | using System.Drawing; | 29 | using System.Drawing; |
29 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
31 | ======= | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using System.Drawing; | ||
35 | >>>>>>> avn/ubitvar | ||
30 | 36 | ||
31 | namespace OpenSim.Region.Framework.Interfaces | 37 | namespace OpenSim.Region.Framework.Interfaces |
32 | { | 38 | { |
33 | public interface IMapImageUploadModule | 39 | public interface IMapImageUploadModule |
34 | { | 40 | { |
41 | <<<<<<< HEAD | ||
42 | void UploadMapTile(IScene scene, Bitmap mapTile); | ||
43 | } | ||
44 | } | ||
45 | ======= | ||
46 | /// <summary> | ||
47 | /// Upload a new maptile | ||
48 | /// </summary> | ||
49 | void UploadMapTile(IScene scene); | ||
35 | void UploadMapTile(IScene scene, Bitmap mapTile); | 50 | void UploadMapTile(IScene scene, Bitmap mapTile); |
36 | } | 51 | } |
37 | } \ No newline at end of file | 52 | } |
53 | >>>>>>> avn/ubitvar | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs index 99bc87d..445342d 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IRegionArchiverModule.cs | |||
@@ -127,7 +127,12 @@ namespace OpenSim.Region.Framework.Interfaces | |||
127 | /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> | 127 | /// <param name="requestId">If supplied, this request Id is later returned in the saved event</param> |
128 | /// <param name="options"> | 128 | /// <param name="options"> |
129 | /// Dictionary of options. | 129 | /// Dictionary of options. |
130 | <<<<<<< HEAD | ||
130 | /// </param> | 131 | /// </param> |
131 | void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string,object> options); | 132 | void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string,object> options); |
133 | ======= | ||
134 | /// </param> | ||
135 | void DearchiveRegion(Stream loadStream, Guid requestId, Dictionary<string, object> options); | ||
136 | >>>>>>> avn/ubitvar | ||
132 | } | 137 | } |
133 | } | 138 | } |
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 8948f04..13358cb 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs | |||
@@ -125,6 +125,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
125 | /// <param name="regionUUID">the region UUID</param> | 125 | /// <param name="regionUUID">the region UUID</param> |
126 | void RemoveRegionEnvironmentSettings(UUID regionUUID); | 126 | void RemoveRegionEnvironmentSettings(UUID regionUUID); |
127 | 127 | ||
128 | UUID[] GetObjectIDs(UUID regionID); | ||
129 | |||
128 | void SaveExtra(UUID regionID, string name, string value); | 130 | void SaveExtra(UUID regionID, string name, string value); |
129 | 131 | ||
130 | void RemoveExtra(UUID regionID, string name); | 132 | void RemoveExtra(UUID regionID, string name); |
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs index 917b5d1..e09f775 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs | |||
@@ -115,6 +115,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
115 | RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID); | 115 | RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID); |
116 | void StoreRegionWindlightSettings(RegionLightShareData wl); | 116 | void StoreRegionWindlightSettings(RegionLightShareData wl); |
117 | void RemoveRegionWindlightSettings(UUID regionID); | 117 | void RemoveRegionWindlightSettings(UUID regionID); |
118 | UUID[] GetObjectIDs(UUID regionID); | ||
118 | 119 | ||
119 | /// <summary> | 120 | /// <summary> |
120 | /// Load Environment settings from region storage | 121 | /// 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/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 8372ddd..f7c6513 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs | |||
@@ -95,7 +95,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
95 | /// <param name="radius">Sound radius</param> | 95 | /// <param name="radius">Sound radius</param> |
96 | /// <param name="isMaster">Set object to sync master if true</param> | 96 | /// <param name="isMaster">Set object to sync master if true</param> |
97 | void LoopSound(UUID objectID, UUID soundID, double gain, | 97 | void LoopSound(UUID objectID, UUID soundID, double gain, |
98 | double radius, bool isMaster); | 98 | double radius, bool isMaster, bool isSlave); |
99 | 99 | ||
100 | /// <summary> | 100 | /// <summary> |
101 | /// Trigger or play an attached sound in this part's inventory. | 101 | /// Trigger or play an attached sound in this part's inventory. |
diff --git a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs index 28f797a..ff18519 100644 --- a/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ITerrainModule.cs | |||
@@ -28,6 +28,11 @@ using System.IO; | |||
28 | 28 | ||
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | 30 | ||
31 | <<<<<<< HEAD | ||
32 | ======= | ||
33 | using System.IO; | ||
34 | using OpenSim.Framework; | ||
35 | >>>>>>> avn/ubitvar | ||
31 | using OpenMetaverse; | 36 | using OpenMetaverse; |
32 | 37 | ||
33 | namespace OpenSim.Region.Framework.Interfaces | 38 | namespace OpenSim.Region.Framework.Interfaces |
@@ -43,7 +48,13 @@ namespace OpenSim.Region.Framework.Interfaces | |||
43 | /// Use this if you change terrain data outside of the terrain module (e.g. in osTerrainSetHeight) | 48 | /// Use this if you change terrain data outside of the terrain module (e.g. in osTerrainSetHeight) |
44 | /// </summary> | 49 | /// </summary> |
45 | void TaintTerrain(); | 50 | void TaintTerrain(); |
46 | 51 | ||
52 | /// <summary> | ||
53 | /// When a client initially connects, all the terrain must be pushed to the viewer. | ||
54 | /// This call causes all the terrain patches to be sent to the client. | ||
55 | /// </summary> | ||
56 | void PushTerrain(IClientAPI pClient); | ||
57 | |||
47 | /// <summary> | 58 | /// <summary> |
48 | /// When a client initially connects, all the terrain must be pushed to the viewer. | 59 | /// When a client initially connects, all the terrain must be pushed to the viewer. |
49 | /// This call causes all the terrain patches to be sent to the client. | 60 | /// This call causes all the terrain patches to be sent to the client. |
@@ -60,6 +71,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
60 | void LoadFromStream(string filename, Stream stream); | 71 | void LoadFromStream(string filename, Stream stream); |
61 | void LoadFromStream(string filename, Vector3 displacement, float radianRotation, Vector2 rotationDisplacement, Stream stream); | 72 | void LoadFromStream(string filename, Vector3 displacement, float radianRotation, Vector2 rotationDisplacement, Stream stream); |
62 | void LoadFromStream(string filename, System.Uri pathToTerrainHeightmap); | 73 | void LoadFromStream(string filename, System.Uri pathToTerrainHeightmap); |
74 | void LoadFromStream(string filename, Vector3 displacement, | ||
75 | float radianRotation, Vector2 rotationDisplacement, Stream stream); | ||
63 | /// <summary> | 76 | /// <summary> |
64 | /// Save a terrain to a stream. | 77 | /// Save a terrain to a stream. |
65 | /// </summary> | 78 | /// </summary> |
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/Interfaces/IWorldMapModule.cs b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs index 9c781e1..08dc3e3 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs | |||
@@ -37,6 +37,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
37 | /// </summary> | 37 | /// </summary> |
38 | void GenerateMaptile(); | 38 | void GenerateMaptile(); |
39 | List<MapBlockData> Map2BlockFromGridRegion(GridRegion r, uint flag); | 39 | List<MapBlockData> Map2BlockFromGridRegion(GridRegion r, uint flag); |
40 | <<<<<<< HEAD | ||
40 | MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag); | 41 | MapBlockData MapBlockFromGridRegion(GridRegion r, uint flag); |
42 | ======= | ||
43 | void MapBlockFromGridRegion(MapBlockData block, GridRegion r, uint flag); | ||
44 | >>>>>>> avn/ubitvar | ||
41 | } | 45 | } |
42 | } | 46 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs b/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs new file mode 100644 index 0000000..31fdb2c --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Animation/MovementAnimationOverrides.cs | |||
@@ -0,0 +1,101 @@ | |||
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.Xml; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using System.Timers; | ||
34 | using Timer = System.Timers.Timer; | ||
35 | using OpenMetaverse; | ||
36 | using log4net; | ||
37 | using Nini.Config; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Client; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Region.Framework.Scenes.Animation; | ||
42 | using OpenSim.Region.Framework.Scenes.Types; | ||
43 | using OpenSim.Region.Physics.Manager; | ||
44 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags; | ||
47 | |||
48 | namespace OpenSim.Region.Framework.Scenes | ||
49 | { | ||
50 | public class MovementAnimationOverrides | ||
51 | { | ||
52 | private static readonly ILog m_log = | ||
53 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | |||
55 | private Dictionary<string, UUID> m_overrides = new Dictionary<string, UUID>(); | ||
56 | public void SetOverride(string state, UUID animID) | ||
57 | { | ||
58 | if (animID == UUID.Zero) | ||
59 | { | ||
60 | if (state == "ALL") | ||
61 | m_overrides.Clear(); | ||
62 | else | ||
63 | m_overrides.Remove(state); | ||
64 | return; | ||
65 | } | ||
66 | |||
67 | m_log.DebugFormat("Setting override for {0} to {1}", state, animID); | ||
68 | |||
69 | lock (m_overrides) | ||
70 | m_overrides[state] = animID; | ||
71 | } | ||
72 | |||
73 | public UUID GetOverriddenAnimation(string state) | ||
74 | { | ||
75 | lock (m_overrides) | ||
76 | { | ||
77 | if (m_overrides.ContainsKey(state)) | ||
78 | return m_overrides[state]; | ||
79 | } | ||
80 | |||
81 | return UUID.Zero; | ||
82 | } | ||
83 | |||
84 | public Dictionary<string, UUID> CloneAOPairs() | ||
85 | { | ||
86 | lock (m_overrides) | ||
87 | { | ||
88 | return new Dictionary<string, UUID>(m_overrides); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | public void CopyAOPairsFrom(Dictionary<string, UUID> src) | ||
93 | { | ||
94 | lock (m_overrides) | ||
95 | { | ||
96 | m_overrides.Clear(); | ||
97 | m_overrides = new Dictionary<string, UUID>(src); | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index 5beee73..ade908d 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
48 | 48 | ||
49 | public AnimationSet Animations | 49 | public AnimationSet Animations |
50 | { | 50 | { |
51 | get { return m_animations; } | 51 | get { return m_animations; } |
52 | } | 52 | } |
53 | protected AnimationSet m_animations = new AnimationSet(); | 53 | protected AnimationSet m_animations = new AnimationSet(); |
54 | 54 | ||
@@ -56,39 +56,42 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
56 | /// The current movement animation | 56 | /// The current movement animation |
57 | /// </value> | 57 | /// </value> |
58 | public string CurrentMovementAnimation { get; private set; } | 58 | public string CurrentMovementAnimation { get; private set; } |
59 | 59 | ||
60 | private int m_animTickFall; | 60 | private int m_animTickFall; |
61 | public int m_animTickJump; // ScenePresence has to see this to control +Z force | 61 | private int m_animTickLand; |
62 | public bool m_jumping = false; | 62 | private int m_animTickJump; |
63 | public float m_jumpVelocity = 0f; | 63 | |
64 | // private int m_landing = 0; | 64 | public bool m_jumping = false; |
65 | |||
66 | // private int m_landing = 0; | ||
65 | 67 | ||
66 | /// <summary> | 68 | /// <summary> |
67 | /// Is the avatar falling? | 69 | /// Is the avatar falling? |
68 | /// </summary> | 70 | /// </summary> |
69 | public bool Falling { get; private set; } | 71 | public bool Falling { get; private set; } |
70 | 72 | ||
71 | private float m_fallHeight; | 73 | private float m_lastFallVelocity; |
72 | 74 | ||
73 | /// <value> | 75 | /// <value> |
74 | /// The scene presence that this animator applies to | 76 | /// The scene presence that this animator applies to |
75 | /// </value> | 77 | /// </value> |
76 | protected ScenePresence m_scenePresence; | 78 | protected ScenePresence m_scenePresence; |
77 | 79 | ||
78 | public ScenePresenceAnimator(ScenePresence sp) | 80 | public ScenePresenceAnimator(ScenePresence sp) |
79 | { | 81 | { |
80 | m_scenePresence = sp; | 82 | m_scenePresence = sp; |
81 | CurrentMovementAnimation = "CROUCH"; | 83 | CurrentMovementAnimation = "CROUCH"; |
82 | } | 84 | } |
83 | 85 | ||
84 | public void AddAnimation(UUID animID, UUID objectID) | 86 | public void AddAnimation(UUID animID, UUID objectID) |
85 | { | 87 | { |
86 | if (m_scenePresence.IsChildAgent) | 88 | if (m_scenePresence.IsChildAgent) |
87 | return; | 89 | return; |
88 | 90 | ||
91 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} for {1}", animID, m_scenePresence.Name); | ||
89 | if (m_scenePresence.Scene.DebugAnimations) | 92 | if (m_scenePresence.Scene.DebugAnimations) |
90 | m_log.DebugFormat( | 93 | m_log.DebugFormat( |
91 | "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", | 94 | "[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", |
92 | GetAnimName(animID), animID, m_scenePresence.Name); | 95 | GetAnimName(animID), animID, m_scenePresence.Name); |
93 | 96 | ||
94 | if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) | 97 | if (m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, objectID)) |
@@ -110,7 +113,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
110 | if (animID == UUID.Zero) | 113 | if (animID == UUID.Zero) |
111 | return; | 114 | return; |
112 | 115 | ||
113 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", animID, name, m_scenePresence.Name); | 116 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Adding animation {0} {1} for {2}", animID, name, m_scenePresence.Name); |
114 | 117 | ||
115 | AddAnimation(animID, objectID); | 118 | AddAnimation(animID, objectID); |
116 | } | 119 | } |
@@ -130,7 +133,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
130 | 133 | ||
131 | if (m_scenePresence.Scene.DebugAnimations) | 134 | if (m_scenePresence.Scene.DebugAnimations) |
132 | m_log.DebugFormat( | 135 | m_log.DebugFormat( |
133 | "[SCENE PRESENCE ANIMATOR]: Removing animation {0} {1} for {2}", | 136 | "[SCENE PRESENCE ANIMATOR]: Removing animation {0} {1} for {2}", |
134 | GetAnimName(animID), animID, m_scenePresence.Name); | 137 | GetAnimName(animID), animID, m_scenePresence.Name); |
135 | 138 | ||
136 | if (m_animations.Remove(animID, allowNoDefault)) | 139 | if (m_animations.Remove(animID, allowNoDefault)) |
@@ -140,6 +143,22 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
140 | } | 143 | } |
141 | } | 144 | } |
142 | 145 | ||
146 | public void avnChangeAnim(UUID animID, bool addRemove, bool sendPack) | ||
147 | { | ||
148 | if (m_scenePresence.IsChildAgent) | ||
149 | return; | ||
150 | |||
151 | if (animID != UUID.Zero) | ||
152 | { | ||
153 | if (addRemove) | ||
154 | m_animations.Add(animID, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, UUID.Zero); | ||
155 | else | ||
156 | m_animations.Remove(animID, false); | ||
157 | } | ||
158 | if (sendPack) | ||
159 | SendAnimPack(); | ||
160 | } | ||
161 | |||
143 | // Called from scripts | 162 | // Called from scripts |
144 | public void RemoveAnimation(string name) | 163 | public void RemoveAnimation(string name) |
145 | { | 164 | { |
@@ -164,12 +183,19 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
164 | 183 | ||
165 | m_animations.Clear(); | 184 | m_animations.Clear(); |
166 | } | 185 | } |
167 | 186 | ||
187 | |||
188 | UUID aoSitGndAnim = UUID.Zero; | ||
189 | |||
168 | /// <summary> | 190 | /// <summary> |
169 | /// The movement animation is reserved for "main" animations | 191 | /// The movement animation is reserved for "main" animations |
170 | /// that are mutually exclusive, e.g. flying and sitting. | 192 | /// that are mutually exclusive, e.g. flying and sitting. |
171 | /// </summary> | 193 | /// </summary> |
172 | /// <returns>'true' if the animation was updated</returns> | 194 | /// <returns>'true' if the animation was updated</returns> |
195 | /// | ||
196 | |||
197 | |||
198 | |||
173 | public bool TrySetMovementAnimation(string anim) | 199 | public bool TrySetMovementAnimation(string anim) |
174 | { | 200 | { |
175 | bool ret = false; | 201 | bool ret = false; |
@@ -179,17 +205,50 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
179 | // "[SCENE PRESENCE ANIMATOR]: Setting movement animation {0} for {1}", | 205 | // "[SCENE PRESENCE ANIMATOR]: Setting movement animation {0} for {1}", |
180 | // anim, m_scenePresence.Name); | 206 | // anim, m_scenePresence.Name); |
181 | 207 | ||
182 | if (m_animations.TrySetDefaultAnimation( | 208 | if (aoSitGndAnim != UUID.Zero) |
183 | anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) | 209 | { |
210 | avnChangeAnim(aoSitGndAnim, false, true); | ||
211 | aoSitGndAnim = UUID.Zero; | ||
212 | } | ||
213 | |||
214 | UUID overridenAnim = m_scenePresence.Overrides.GetOverriddenAnimation(anim); | ||
215 | if (overridenAnim != UUID.Zero) | ||
216 | { | ||
217 | if (anim == "SITGROUND") | ||
218 | { | ||
219 | UUID defsit = DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]; | ||
220 | if (defsit == UUID.Zero) | ||
221 | return false; | ||
222 | m_animations.SetDefaultAnimation(defsit, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID); | ||
223 | aoSitGndAnim = overridenAnim; | ||
224 | avnChangeAnim(overridenAnim, true, false); | ||
225 | } | ||
226 | else | ||
227 | { | ||
228 | m_animations.SetDefaultAnimation(overridenAnim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID); | ||
229 | } | ||
230 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION }); | ||
231 | SendAnimPack(); | ||
232 | ret = true; | ||
233 | } | ||
234 | else | ||
184 | { | 235 | { |
236 | // translate sit and sitground state animations | ||
237 | if (anim == "SIT" || anim == "SITGROUND") | ||
238 | anim = m_scenePresence.sitAnimation; | ||
239 | |||
240 | if (m_animations.TrySetDefaultAnimation( | ||
241 | anim, m_scenePresence.ControllingClient.NextAnimationSequenceNumber, m_scenePresence.UUID)) | ||
242 | { | ||
185 | // m_log.DebugFormat( | 243 | // m_log.DebugFormat( |
186 | // "[SCENE PRESENCE ANIMATOR]: Updating movement animation to {0} for {1}", | 244 | // "[SCENE PRESENCE ANIMATOR]: Updating movement animation to {0} for {1}", |
187 | // anim, m_scenePresence.Name); | 245 | // anim, m_scenePresence.Name); |
188 | 246 | ||
189 | // 16384 is CHANGED_ANIMATION | 247 | // 16384 is CHANGED_ANIMATION |
190 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION}); | 248 | m_scenePresence.SendScriptEventToAttachments("changed", new Object[] { (int)Changed.ANIMATION }); |
191 | SendAnimPack(); | 249 | SendAnimPack(); |
192 | ret = true; | 250 | ret = true; |
251 | } | ||
193 | } | 252 | } |
194 | } | 253 | } |
195 | else | 254 | else |
@@ -201,78 +260,119 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
201 | return ret; | 260 | return ret; |
202 | } | 261 | } |
203 | 262 | ||
263 | public enum motionControlStates : byte | ||
264 | { | ||
265 | sitted = 0, | ||
266 | flying, | ||
267 | falling, | ||
268 | jumping, | ||
269 | landing, | ||
270 | onsurface | ||
271 | } | ||
272 | |||
273 | public motionControlStates currentControlState = motionControlStates.onsurface; | ||
274 | |||
204 | /// <summary> | 275 | /// <summary> |
205 | /// This method determines the proper movement related animation | 276 | /// This method determines the proper movement related animation |
206 | /// </summary> | 277 | /// </summary> |
207 | private string DetermineMovementAnimation() | 278 | private string DetermineMovementAnimation() |
208 | { | 279 | { |
209 | const float FALL_DELAY = 800f; | 280 | const int FALL_DELAY = 800; |
210 | const float PREJUMP_DELAY = 200f; | 281 | const int PREJUMP_DELAY = 200; |
211 | const float JUMP_PERIOD = 800f; | 282 | const int JUMP_PERIOD = 800; |
212 | #region Inputs | 283 | #region Inputs |
213 | 284 | ||
285 | if (m_scenePresence.IsInTransit) | ||
286 | return CurrentMovementAnimation; | ||
287 | |||
288 | if (m_scenePresence.SitGround) | ||
289 | { | ||
290 | currentControlState = motionControlStates.sitted; | ||
291 | return "SITGROUND"; | ||
292 | } | ||
293 | if (m_scenePresence.ParentID != 0 || m_scenePresence.ParentUUID != UUID.Zero) | ||
294 | { | ||
295 | currentControlState = motionControlStates.sitted; | ||
296 | return "SIT"; | ||
297 | } | ||
298 | |||
214 | AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; | 299 | AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags; |
215 | PhysicsActor actor = m_scenePresence.PhysicsActor; | 300 | PhysicsActor actor = m_scenePresence.PhysicsActor; |
216 | 301 | ||
217 | // Create forward and left vectors from the current avatar rotation | 302 | const AgentManager.ControlFlags ANYXYMASK = ( |
218 | Matrix4 rotMatrix = Matrix4.CreateFromQuaternion(m_scenePresence.Rotation); | 303 | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | |
219 | Vector3 fwd = Vector3.Transform(Vector3.UnitX, rotMatrix); | 304 | AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG | |
220 | Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); | 305 | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS | |
306 | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | ||
307 | ); | ||
221 | 308 | ||
222 | // Check control flags | 309 | // Check control flags |
223 | bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS); | 310 | /* not in use |
224 | bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); | 311 | bool heldForward = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS)) != 0); |
225 | bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); | 312 | bool heldBack = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG)) != 0); |
226 | bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG); | 313 | bool heldLeft = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS)) != 0); |
314 | bool heldRight = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG)) != 0); | ||
315 | */ | ||
227 | bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; | 316 | bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; |
228 | bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; | 317 | bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; |
229 | bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; | 318 | // bool heldUp = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS)) != 0); |
230 | bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; | 319 | // excluded nudge up so it doesn't trigger jump state |
320 | bool heldUp = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_POS)) != 0); | ||
321 | bool heldDown = ((controlFlags & (AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG)) != 0); | ||
231 | //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; | 322 | //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; |
232 | //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK; | 323 | //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK; |
233 | if (heldForward || heldBack || heldLeft || heldRight || heldUp || heldDown) | 324 | |
325 | bool heldOnXY = ((controlFlags & ANYXYMASK) != 0); | ||
326 | if (heldOnXY || heldUp || heldDown) | ||
234 | { | 327 | { |
235 | heldTurnLeft = false; | 328 | heldTurnLeft = false; |
236 | heldTurnRight = false; | 329 | heldTurnRight = false; |
237 | } | 330 | } |
238 | 331 | ||
239 | // Direction in which the avatar is trying to move | ||
240 | Vector3 move = Vector3.Zero; | ||
241 | if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } | ||
242 | if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } | ||
243 | if (heldLeft) { move.X += left.X; move.Y += left.Y; } | ||
244 | if (heldRight) { move.X -= left.X; move.Y -= left.Y; } | ||
245 | if (heldUp) { move.Z += 1; } | ||
246 | if (heldDown) { move.Z -= 1; } | ||
247 | |||
248 | // Is the avatar trying to move? | ||
249 | // bool moving = (move != Vector3.Zero); | ||
250 | #endregion Inputs | 332 | #endregion Inputs |
251 | 333 | ||
334 | // no physics actor case | ||
335 | if (actor == null) | ||
336 | { | ||
337 | // well what to do? | ||
338 | |||
339 | currentControlState = motionControlStates.onsurface; | ||
340 | if (heldOnXY) | ||
341 | return "WALK"; | ||
342 | |||
343 | return "STAND"; | ||
344 | } | ||
345 | |||
252 | #region Flying | 346 | #region Flying |
253 | 347 | ||
254 | if (actor != null && actor.Flying) | 348 | bool isColliding = actor.IsColliding; |
349 | |||
350 | if (actor.Flying) | ||
255 | { | 351 | { |
256 | m_animTickFall = 0; | 352 | m_animTickFall = 0; |
257 | m_animTickJump = 0; | 353 | m_animTickJump = 0; |
258 | m_jumping = false; | 354 | m_jumping = false; |
259 | Falling = false; | 355 | Falling = false; |
260 | m_jumpVelocity = 0f; | ||
261 | actor.Selected = false; | ||
262 | m_fallHeight = actor.Position.Z; // save latest flying height | ||
263 | 356 | ||
264 | if (move.X != 0f || move.Y != 0f) | 357 | currentControlState = motionControlStates.flying; |
358 | |||
359 | if (heldOnXY) | ||
265 | { | 360 | { |
266 | return (m_scenePresence.Scene.m_useFlySlow ? "FLYSLOW" : "FLY"); | 361 | return (m_scenePresence.Scene.m_useFlySlow ? "FLYSLOW" : "FLY"); |
267 | } | 362 | } |
268 | else if (move.Z > 0f) | 363 | else if (heldUp) |
269 | { | 364 | { |
270 | return "HOVER_UP"; | 365 | return "HOVER_UP"; |
271 | } | 366 | } |
272 | else if (move.Z < 0f) | 367 | else if (heldDown) |
273 | { | 368 | { |
274 | if (actor != null && actor.IsColliding) | 369 | if (isColliding) |
370 | { | ||
371 | actor.Flying = false; | ||
372 | currentControlState = motionControlStates.landing; | ||
373 | m_animTickLand = Environment.TickCount; | ||
275 | return "LAND"; | 374 | return "LAND"; |
375 | } | ||
276 | else | 376 | else |
277 | return "HOVER_DOWN"; | 377 | return "HOVER_DOWN"; |
278 | } | 378 | } |
@@ -281,128 +381,142 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
281 | return "HOVER"; | 381 | return "HOVER"; |
282 | } | 382 | } |
283 | } | 383 | } |
384 | else | ||
385 | { | ||
386 | if (isColliding && currentControlState == motionControlStates.flying) | ||
387 | { | ||
388 | currentControlState = motionControlStates.landing; | ||
389 | m_animTickLand = Environment.TickCount; | ||
390 | return "LAND"; | ||
391 | } | ||
392 | } | ||
284 | 393 | ||
285 | #endregion Flying | 394 | #endregion Flying |
286 | 395 | ||
287 | #region Falling/Floating/Landing | 396 | #region Falling/Floating/Landing |
288 | 397 | ||
289 | if ((actor == null || !actor.IsColliding) && !m_jumping) | 398 | if (!isColliding && currentControlState != motionControlStates.jumping) |
290 | { | 399 | { |
291 | float fallElapsed = (float)(Environment.TickCount - m_animTickFall); | 400 | float fallVelocity = actor.Velocity.Z; |
292 | float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; | ||
293 | 401 | ||
294 | if (!m_jumping && (fallVelocity < -3.0f)) | 402 | if (fallVelocity < -2.5f) |
295 | Falling = true; | 403 | Falling = true; |
296 | 404 | ||
297 | if (m_animTickFall == 0 || (fallVelocity >= 0.0f)) | 405 | if (m_animTickFall == 0 || (fallVelocity >= -0.5f)) |
298 | { | 406 | { |
299 | // not falling yet, or going up | ||
300 | // reset start of fall time | ||
301 | m_animTickFall = Environment.TickCount; | 407 | m_animTickFall = Environment.TickCount; |
302 | } | 408 | } |
303 | else if (!m_jumping && (fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f) && (m_scenePresence.WasFlying)) | 409 | else |
304 | { | 410 | { |
305 | // Falling long enough to trigger the animation | 411 | int fallElapsed = (Environment.TickCount - m_animTickFall); |
306 | return "FALLDOWN"; | 412 | if ((fallElapsed > FALL_DELAY) && (fallVelocity < -3.0f)) |
413 | { | ||
414 | currentControlState = motionControlStates.falling; | ||
415 | m_lastFallVelocity = fallVelocity; | ||
416 | // Falling long enough to trigger the animation | ||
417 | return "FALLDOWN"; | ||
418 | } | ||
307 | } | 419 | } |
308 | 420 | ||
309 | // Check if the user has stopped walking just now | 421 | // Check if the user has stopped walking just now |
310 | if (CurrentMovementAnimation == "WALK" && (move == Vector3.Zero)) | 422 | if (CurrentMovementAnimation == "WALK" && !heldOnXY && !heldDown && !heldUp) |
311 | return "STAND"; | 423 | return "STAND"; |
312 | 424 | ||
313 | return CurrentMovementAnimation; | 425 | return CurrentMovementAnimation; |
314 | } | 426 | } |
315 | 427 | ||
316 | #endregion Falling/Floating/Landing | 428 | m_animTickFall = 0; |
317 | 429 | ||
430 | #endregion Falling/Floating/Landing | ||
318 | 431 | ||
319 | #region Jumping // section added for jumping... | 432 | #region Jumping // section added for jumping... |
320 | 433 | ||
321 | int jumptime; | 434 | if (isColliding && heldUp && currentControlState != motionControlStates.jumping) |
322 | jumptime = Environment.TickCount - m_animTickJump; | ||
323 | |||
324 | if ((move.Z > 0f) && (!m_jumping)) | ||
325 | { | 435 | { |
326 | // Start jumping, prejump | 436 | // Start jumping, prejump |
327 | m_animTickFall = 0; | 437 | currentControlState = motionControlStates.jumping; |
328 | m_jumping = true; | 438 | m_jumping = true; |
329 | Falling = false; | 439 | Falling = false; |
330 | actor.Selected = true; // borrowed for jumping flag | ||
331 | m_animTickJump = Environment.TickCount; | 440 | m_animTickJump = Environment.TickCount; |
332 | m_jumpVelocity = 0.35f; | ||
333 | return "PREJUMP"; | 441 | return "PREJUMP"; |
334 | } | 442 | } |
335 | 443 | ||
336 | if (m_jumping) | 444 | if (currentControlState == motionControlStates.jumping) |
337 | { | 445 | { |
446 | int jumptime = Environment.TickCount - m_animTickJump; | ||
338 | if ((jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) | 447 | if ((jumptime > (JUMP_PERIOD * 1.5f)) && actor.IsColliding) |
339 | { | 448 | { |
340 | // end jumping | 449 | // end jumping |
341 | m_jumping = false; | 450 | m_jumping = false; |
342 | Falling = false; | 451 | Falling = false; |
343 | actor.Selected = false; // borrowed for jumping flag | 452 | actor.Selected = false; // borrowed for jumping flag |
344 | m_jumpVelocity = 0f; | 453 | m_animTickLand = Environment.TickCount; |
345 | m_animTickFall = Environment.TickCount; | 454 | currentControlState = motionControlStates.landing; |
346 | return "LAND"; | 455 | return "LAND"; |
347 | } | 456 | } |
348 | else if (jumptime > JUMP_PERIOD) | 457 | else if (jumptime > JUMP_PERIOD) |
349 | { | 458 | { |
350 | // jump down | 459 | // jump down |
351 | m_jumpVelocity = 0f; | ||
352 | return "JUMP"; | 460 | return "JUMP"; |
353 | } | 461 | } |
354 | else if (jumptime > PREJUMP_DELAY) | 462 | else if (jumptime > PREJUMP_DELAY) |
355 | { | 463 | { |
356 | // jump up | 464 | // jump up |
357 | m_jumping = true; | 465 | m_jumping = true; |
358 | m_jumpVelocity = 10f; | ||
359 | return "JUMP"; | 466 | return "JUMP"; |
360 | } | 467 | } |
468 | return CurrentMovementAnimation; | ||
361 | } | 469 | } |
362 | 470 | ||
363 | #endregion Jumping | 471 | #endregion Jumping |
364 | 472 | ||
365 | #region Ground Movement | 473 | #region Ground Movement |
366 | 474 | ||
367 | if (CurrentMovementAnimation == "FALLDOWN") | 475 | if (currentControlState == motionControlStates.falling) |
368 | { | 476 | { |
369 | Falling = false; | 477 | Falling = false; |
370 | m_animTickFall = Environment.TickCount; | 478 | currentControlState = motionControlStates.landing; |
479 | m_animTickLand = Environment.TickCount; | ||
371 | // TODO: SOFT_LAND support | 480 | // TODO: SOFT_LAND support |
372 | float fallHeight = m_fallHeight - actor.Position.Z; | 481 | float fallVsq = m_lastFallVelocity * m_lastFallVelocity; |
373 | if (fallHeight > 15.0f) | 482 | if (fallVsq > 300f) // aprox 20*h |
374 | return "STANDUP"; | 483 | return "STANDUP"; |
375 | else if (fallHeight > 8.0f) | 484 | else if (fallVsq > 160f) |
376 | return "SOFT_LAND"; | 485 | return "SOFT_LAND"; |
377 | else | 486 | else |
378 | return "LAND"; | 487 | return "LAND"; |
379 | } | 488 | } |
380 | else if ((CurrentMovementAnimation == "LAND") || (CurrentMovementAnimation == "SOFT_LAND") || (CurrentMovementAnimation == "STANDUP")) | 489 | |
490 | |||
491 | if (currentControlState == motionControlStates.landing) | ||
381 | { | 492 | { |
382 | int landElapsed = Environment.TickCount - m_animTickFall; | 493 | Falling = false; |
494 | int landElapsed = Environment.TickCount - m_animTickLand; | ||
383 | int limit = 1000; | 495 | int limit = 1000; |
384 | if (CurrentMovementAnimation == "LAND") | 496 | if (CurrentMovementAnimation == "LAND") |
385 | limit = 350; | 497 | limit = 350; |
386 | // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client | 498 | // NB if the above is set too long a weird anim reset from some place prevents STAND from being sent to client |
387 | 499 | ||
388 | if ((m_animTickFall != 0) && (landElapsed <= limit)) | 500 | if ((m_animTickLand != 0) && (landElapsed <= limit)) |
389 | { | 501 | { |
390 | return CurrentMovementAnimation; | 502 | return CurrentMovementAnimation; |
391 | } | 503 | } |
392 | else | 504 | else |
393 | { | 505 | { |
394 | m_fallHeight = actor.Position.Z; // save latest flying height | 506 | currentControlState = motionControlStates.onsurface; |
507 | m_animTickLand = 0; | ||
395 | return "STAND"; | 508 | return "STAND"; |
396 | } | 509 | } |
397 | } | 510 | } |
398 | 511 | ||
399 | // next section moved outside paren. and realigned for jumping | 512 | // next section moved outside paren. and realigned for jumping |
400 | if (move.X != 0f || move.Y != 0f) | 513 | |
514 | if (heldOnXY) | ||
401 | { | 515 | { |
402 | m_fallHeight = actor.Position.Z; // save latest flying height | 516 | currentControlState = motionControlStates.onsurface; |
403 | Falling = false; | 517 | Falling = false; |
404 | // Walking / crouchwalking / running | 518 | // Walking / crouchwalking / running |
405 | if (move.Z < 0f) | 519 | if (heldDown) |
406 | { | 520 | { |
407 | return "CROUCHWALK"; | 521 | return "CROUCHWALK"; |
408 | } | 522 | } |
@@ -416,11 +530,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
416 | return "WALK"; | 530 | return "WALK"; |
417 | } | 531 | } |
418 | } | 532 | } |
419 | else if (!m_jumping) | 533 | else |
420 | { | 534 | { |
535 | currentControlState = motionControlStates.onsurface; | ||
421 | Falling = false; | 536 | Falling = false; |
422 | // Not walking | 537 | // Not walking |
423 | if (move.Z < 0) | 538 | if (heldDown) |
424 | return "CROUCH"; | 539 | return "CROUCH"; |
425 | else if (heldTurnLeft) | 540 | else if (heldTurnLeft) |
426 | return "TURNLEFT"; | 541 | return "TURNLEFT"; |
@@ -431,8 +546,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
431 | } | 546 | } |
432 | #endregion Ground Movement | 547 | #endregion Ground Movement |
433 | 548 | ||
434 | Falling = false; | ||
435 | |||
436 | return CurrentMovementAnimation; | 549 | return CurrentMovementAnimation; |
437 | } | 550 | } |
438 | 551 | ||
@@ -442,7 +555,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
442 | /// <returns>'true' if the animation was changed</returns> | 555 | /// <returns>'true' if the animation was changed</returns> |
443 | public bool UpdateMovementAnimations() | 556 | public bool UpdateMovementAnimations() |
444 | { | 557 | { |
445 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Updating movement animations for {0}", m_scenePresence.Name); | 558 | // m_log.DebugFormat("[SCENE PRESENCE ANIMATOR]: Updating movement animations for {0}", m_scenePresence.Name); |
446 | 559 | ||
447 | bool ret = false; | 560 | bool ret = false; |
448 | lock (m_animations) | 561 | lock (m_animations) |
@@ -450,7 +563,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
450 | string newMovementAnimation = DetermineMovementAnimation(); | 563 | string newMovementAnimation = DetermineMovementAnimation(); |
451 | if (CurrentMovementAnimation != newMovementAnimation) | 564 | if (CurrentMovementAnimation != newMovementAnimation) |
452 | { | 565 | { |
453 | CurrentMovementAnimation = DetermineMovementAnimation(); | 566 | CurrentMovementAnimation = newMovementAnimation; |
454 | 567 | ||
455 | // m_log.DebugFormat( | 568 | // m_log.DebugFormat( |
456 | // "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", | 569 | // "[SCENE PRESENCE ANIMATOR]: Determined animation {0} for {1} in UpdateMovementAnimations()", |
@@ -464,6 +577,24 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
464 | return ret; | 577 | return ret; |
465 | } | 578 | } |
466 | 579 | ||
580 | public bool ForceUpdateMovementAnimations() | ||
581 | { | ||
582 | lock (m_animations) | ||
583 | { | ||
584 | CurrentMovementAnimation = DetermineMovementAnimation(); | ||
585 | return TrySetMovementAnimation(CurrentMovementAnimation); | ||
586 | } | ||
587 | } | ||
588 | |||
589 | public bool SetMovementAnimations(string motionState) | ||
590 | { | ||
591 | lock (m_animations) | ||
592 | { | ||
593 | CurrentMovementAnimation = motionState; | ||
594 | return TrySetMovementAnimation(CurrentMovementAnimation); | ||
595 | } | ||
596 | } | ||
597 | |||
467 | public UUID[] GetAnimationArray() | 598 | public UUID[] GetAnimationArray() |
468 | { | 599 | { |
469 | UUID[] animIDs; | 600 | UUID[] animIDs; |
@@ -472,19 +603,19 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
472 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); | 603 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); |
473 | return animIDs; | 604 | return animIDs; |
474 | } | 605 | } |
475 | 606 | ||
476 | public BinBVHAnimation GenerateRandomAnimation() | 607 | public BinBVHAnimation GenerateRandomAnimation() |
477 | { | 608 | { |
478 | int rnditerations = 3; | 609 | int rnditerations = 3; |
479 | BinBVHAnimation anim = new BinBVHAnimation(); | 610 | BinBVHAnimation anim = new BinBVHAnimation(); |
480 | List<string> parts = new List<string>(); | 611 | List<string> parts = new List<string>(); |
481 | parts.Add("mPelvis");parts.Add("mHead");parts.Add("mTorso"); | 612 | parts.Add("mPelvis"); parts.Add("mHead"); parts.Add("mTorso"); |
482 | parts.Add("mHipLeft");parts.Add("mHipRight");parts.Add("mHipLeft");parts.Add("mKneeLeft"); | 613 | parts.Add("mHipLeft"); parts.Add("mHipRight"); parts.Add("mHipLeft"); parts.Add("mKneeLeft"); |
483 | parts.Add("mKneeRight");parts.Add("mCollarLeft");parts.Add("mCollarRight");parts.Add("mNeck"); | 614 | parts.Add("mKneeRight"); parts.Add("mCollarLeft"); parts.Add("mCollarRight"); parts.Add("mNeck"); |
484 | parts.Add("mElbowLeft");parts.Add("mElbowRight");parts.Add("mWristLeft");parts.Add("mWristRight"); | 615 | parts.Add("mElbowLeft"); parts.Add("mElbowRight"); parts.Add("mWristLeft"); parts.Add("mWristRight"); |
485 | parts.Add("mShoulderLeft");parts.Add("mShoulderRight");parts.Add("mAnkleLeft");parts.Add("mAnkleRight"); | 616 | parts.Add("mShoulderLeft"); parts.Add("mShoulderRight"); parts.Add("mAnkleLeft"); parts.Add("mAnkleRight"); |
486 | parts.Add("mEyeRight");parts.Add("mChest");parts.Add("mToeLeft");parts.Add("mToeRight"); | 617 | parts.Add("mEyeRight"); parts.Add("mChest"); parts.Add("mToeLeft"); parts.Add("mToeRight"); |
487 | parts.Add("mFootLeft");parts.Add("mFootRight");parts.Add("mEyeLeft"); | 618 | parts.Add("mFootLeft"); parts.Add("mFootRight"); parts.Add("mEyeLeft"); |
488 | anim.HandPose = 1; | 619 | anim.HandPose = 1; |
489 | anim.InPoint = 0; | 620 | anim.InPoint = 0; |
490 | anim.OutPoint = (rnditerations * .10f); | 621 | anim.OutPoint = (rnditerations * .10f); |
@@ -508,12 +639,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
508 | for (int i = 0; i < rnditerations; i++) | 639 | for (int i = 0; i < rnditerations; i++) |
509 | { | 640 | { |
510 | anim.Joints[j].rotationkeys[i] = new binBVHJointKey(); | 641 | anim.Joints[j].rotationkeys[i] = new binBVHJointKey(); |
511 | anim.Joints[j].rotationkeys[i].time = (i*.10f); | 642 | anim.Joints[j].rotationkeys[i].time = (i * .10f); |
512 | anim.Joints[j].rotationkeys[i].key_element.X = ((float) rnd.NextDouble()*2 - 1); | 643 | anim.Joints[j].rotationkeys[i].key_element.X = ((float)rnd.NextDouble() * 2 - 1); |
513 | anim.Joints[j].rotationkeys[i].key_element.Y = ((float) rnd.NextDouble()*2 - 1); | 644 | anim.Joints[j].rotationkeys[i].key_element.Y = ((float)rnd.NextDouble() * 2 - 1); |
514 | anim.Joints[j].rotationkeys[i].key_element.Z = ((float) rnd.NextDouble()*2 - 1); | 645 | anim.Joints[j].rotationkeys[i].key_element.Z = ((float)rnd.NextDouble() * 2 - 1); |
515 | anim.Joints[j].positionkeys[i] = new binBVHJointKey(); | 646 | anim.Joints[j].positionkeys[i] = new binBVHJointKey(); |
516 | anim.Joints[j].positionkeys[i].time = (i*.10f); | 647 | anim.Joints[j].positionkeys[i].time = (i * .10f); |
517 | anim.Joints[j].positionkeys[i].key_element.X = 0; | 648 | anim.Joints[j].positionkeys[i].key_element.X = 0; |
518 | anim.Joints[j].positionkeys[i].key_element.Y = 0; | 649 | anim.Joints[j].positionkeys[i].key_element.Y = 0; |
519 | anim.Joints[j].positionkeys[i].key_element.Z = 0; | 650 | anim.Joints[j].positionkeys[i].key_element.Z = 0; |
@@ -540,20 +671,17 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
540 | /// <param name="objectIDs"></param> | 671 | /// <param name="objectIDs"></param> |
541 | public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) | 672 | public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) |
542 | { | 673 | { |
543 | if (m_scenePresence.IsChildAgent) | 674 | m_scenePresence.SendAnimPack(animations, seqs, objectIDs); |
544 | return; | 675 | } |
545 | 676 | ||
546 | // m_log.DebugFormat( | 677 | public void GetArrays(out UUID[] animIDs, out int[] sequenceNums, out UUID[] objectIDs) |
547 | // "[SCENE PRESENCE ANIMATOR]: Sending anim pack with animations '{0}', sequence '{1}', uuids '{2}'", | 678 | { |
548 | // string.Join(",", Array.ConvertAll<UUID, string>(animations, a => a.ToString())), | 679 | animIDs = null; |
549 | // string.Join(",", Array.ConvertAll<int, string>(seqs, s => s.ToString())), | 680 | sequenceNums = null; |
550 | // string.Join(",", Array.ConvertAll<UUID, string>(objectIDs, o => o.ToString()))); | 681 | objectIDs = null; |
551 | 682 | ||
552 | m_scenePresence.Scene.ForEachClient( | 683 | if (m_animations != null) |
553 | delegate(IClientAPI client) | 684 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); |
554 | { | ||
555 | client.SendAnimations(animations, seqs, m_scenePresence.ControllingClient.AgentId, objectIDs); | ||
556 | }); | ||
557 | } | 685 | } |
558 | 686 | ||
559 | public void SendAnimPackToClient(IClientAPI client) | 687 | public void SendAnimPackToClient(IClientAPI client) |
@@ -575,7 +703,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
575 | public void SendAnimPack() | 703 | public void SendAnimPack() |
576 | { | 704 | { |
577 | //m_log.Debug("Sending animation pack to all"); | 705 | //m_log.Debug("Sending animation pack to all"); |
578 | 706 | ||
579 | if (m_scenePresence.IsChildAgent) | 707 | if (m_scenePresence.IsChildAgent) |
580 | return; | 708 | return; |
581 | 709 | ||
@@ -585,7 +713,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
585 | 713 | ||
586 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); | 714 | m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); |
587 | 715 | ||
588 | SendAnimPack(animIDs, sequenceNums, objectIDs); | 716 | // SendAnimPack(animIDs, sequenceNums, objectIDs); |
717 | m_scenePresence.SendAnimPack(animIDs, sequenceNums, objectIDs); | ||
589 | } | 718 | } |
590 | 719 | ||
591 | public string GetAnimName(UUID animId) | 720 | public string GetAnimName(UUID animId) |
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 d325240..22b8e4d 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -80,6 +80,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
80 | public event OnTerrainTaintedDelegate OnTerrainTainted; | 80 | public event OnTerrainTaintedDelegate OnTerrainTainted; |
81 | 81 | ||
82 | public delegate void OnTerrainTickDelegate(); | 82 | public delegate void OnTerrainTickDelegate(); |
83 | public delegate void OnTerrainCheckUpdatesDelegate(); | ||
83 | 84 | ||
84 | /// <summary> | 85 | /// <summary> |
85 | /// Triggered if the terrain has been edited | 86 | /// Triggered if the terrain has been edited |
@@ -89,6 +90,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
89 | /// but is used by core solely to update the physics engine. | 90 | /// but is used by core solely to update the physics engine. |
90 | /// </remarks> | 91 | /// </remarks> |
91 | public event OnTerrainTickDelegate OnTerrainTick; | 92 | public event OnTerrainTickDelegate OnTerrainTick; |
93 | public event OnTerrainCheckUpdatesDelegate OnTerrainCheckUpdates; | ||
94 | |||
95 | public delegate void OnTerrainUpdateDelegate(); | ||
96 | |||
97 | public event OnTerrainUpdateDelegate OnTerrainUpdate; | ||
92 | 98 | ||
93 | public delegate void OnBackupDelegate(ISimulationDataService datastore, bool forceBackup); | 99 | public delegate void OnBackupDelegate(ISimulationDataService datastore, bool forceBackup); |
94 | 100 | ||
@@ -339,8 +345,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
339 | /// in <see cref="Scene.SetScriptRunning"/> | 345 | /// in <see cref="Scene.SetScriptRunning"/> |
340 | /// via <see cref="OpenSim.Framework.IClientAPI.OnSetScriptRunning"/>, | 346 | /// via <see cref="OpenSim.Framework.IClientAPI.OnSetScriptRunning"/>, |
341 | /// via <see cref="OpenSim.Region.ClientStack.LindenUDP.HandleSetScriptRunning"/> | 347 | /// 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> | 348 | /// </remarks> |
345 | public event StartScript OnStartScript; | 349 | public event StartScript OnStartScript; |
346 | 350 | ||
@@ -354,7 +358,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
354 | /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>, | 358 | /// in <see cref="SceneObjectPartInventory.CreateScriptInstance"/>, |
355 | /// <see cref="SceneObjectPartInventory.StopScriptInstance"/>, | 359 | /// <see cref="SceneObjectPartInventory.StopScriptInstance"/>, |
356 | /// <see cref="Scene.SetScriptRunning"/> | 360 | /// <see cref="Scene.SetScriptRunning"/> |
357 | /// XXX: This is triggered when a sciprt is stopped for any reason, unlike OnStartScript! | ||
358 | /// </remarks> | 361 | /// </remarks> |
359 | public event StopScript OnStopScript; | 362 | public event StopScript OnStopScript; |
360 | 363 | ||
@@ -858,6 +861,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
858 | public event ParcelPrimCountTainted OnParcelPrimCountTainted; | 861 | public event ParcelPrimCountTainted OnParcelPrimCountTainted; |
859 | public event GetScriptRunning OnGetScriptRunning; | 862 | public event GetScriptRunning OnGetScriptRunning; |
860 | 863 | ||
864 | public delegate void ThrottleUpdate(ScenePresence scenePresence); | ||
865 | |||
866 | public event ThrottleUpdate OnThrottleUpdate; | ||
867 | |||
861 | /// <summary> | 868 | /// <summary> |
862 | /// RegisterCapsEvent is called by Scene after the Caps object | 869 | /// RegisterCapsEvent is called by Scene after the Caps object |
863 | /// has been instantiated and before it is return to the | 870 | /// has been instantiated and before it is return to the |
@@ -1377,7 +1384,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1377 | { | 1384 | { |
1378 | try | 1385 | try |
1379 | { | 1386 | { |
1387 | // m_log.ErrorFormat("[EVENT MANAGER]: OnRemovePresenceDelegate: {0}",d.Target.ToString()); | ||
1380 | d(agentId); | 1388 | d(agentId); |
1389 | // m_log.ErrorFormat("[EVENT MANAGER]: OnRemovePresenceDelegate done "); | ||
1381 | } | 1390 | } |
1382 | catch (Exception e) | 1391 | catch (Exception e) |
1383 | { | 1392 | { |
@@ -1451,6 +1460,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1451 | } | 1460 | } |
1452 | } | 1461 | } |
1453 | } | 1462 | } |
1463 | public void TriggerTerrainUpdate() | ||
1464 | { | ||
1465 | OnTerrainUpdateDelegate handlerTerrainUpdate = OnTerrainUpdate; | ||
1466 | if (handlerTerrainUpdate != null) | ||
1467 | { | ||
1468 | foreach (OnTerrainUpdateDelegate d in handlerTerrainUpdate.GetInvocationList()) | ||
1469 | { | ||
1470 | try | ||
1471 | { | ||
1472 | d(); | ||
1473 | } | ||
1474 | catch (Exception e) | ||
1475 | { | ||
1476 | m_log.ErrorFormat( | ||
1477 | "[EVENT MANAGER]: Delegate for TriggerTerrainUpdate failed - continuing. {0} {1}", | ||
1478 | e.Message, e.StackTrace); | ||
1479 | } | ||
1480 | } | ||
1481 | } | ||
1482 | } | ||
1454 | 1483 | ||
1455 | public void TriggerTerrainTick() | 1484 | public void TriggerTerrainTick() |
1456 | { | 1485 | { |
@@ -1473,6 +1502,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
1473 | } | 1502 | } |
1474 | } | 1503 | } |
1475 | 1504 | ||
1505 | public void TriggerTerrainCheckUpdates() | ||
1506 | { | ||
1507 | OnTerrainCheckUpdatesDelegate TerrainCheckUpdates = OnTerrainCheckUpdates; | ||
1508 | if (TerrainCheckUpdates != null) | ||
1509 | { | ||
1510 | foreach (OnTerrainCheckUpdatesDelegate d in TerrainCheckUpdates.GetInvocationList()) | ||
1511 | { | ||
1512 | try | ||
1513 | { | ||
1514 | d(); | ||
1515 | } | ||
1516 | catch (Exception e) | ||
1517 | { | ||
1518 | m_log.ErrorFormat( | ||
1519 | "[EVENT MANAGER]: Delegate for TerrainCheckUpdates failed - continuing. {0} {1}", | ||
1520 | e.Message, e.StackTrace); | ||
1521 | } | ||
1522 | } | ||
1523 | } | ||
1524 | } | ||
1525 | |||
1476 | public void TriggerTerrainTainted() | 1526 | public void TriggerTerrainTainted() |
1477 | { | 1527 | { |
1478 | OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted; | 1528 | OnTerrainTaintedDelegate handlerTerrainTainted = OnTerrainTainted; |
@@ -1808,6 +1858,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1808 | m_log.ErrorFormat( | 1858 | m_log.ErrorFormat( |
1809 | "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", | 1859 | "[EVENT MANAGER]: Delegate for TriggerRemoveScript failed - continuing. {0} {1}", |
1810 | e.Message, e.StackTrace); | 1860 | e.Message, e.StackTrace); |
1861 | m_log.ErrorFormat(Environment.StackTrace); | ||
1811 | } | 1862 | } |
1812 | } | 1863 | } |
1813 | } | 1864 | } |
@@ -2073,7 +2124,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2073 | { | 2124 | { |
2074 | try | 2125 | try |
2075 | { | 2126 | { |
2127 | // m_log.ErrorFormat("[EVENT MANAGER]: TriggerClientClosed: {0}", d.Target.ToString()); | ||
2076 | d(ClientID, scene); | 2128 | d(ClientID, scene); |
2129 | // m_log.ErrorFormat("[EVENT MANAGER]: TriggerClientClosed done "); | ||
2130 | |||
2077 | } | 2131 | } |
2078 | catch (Exception e) | 2132 | catch (Exception e) |
2079 | { | 2133 | { |
@@ -3107,6 +3161,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3107 | { | 3161 | { |
3108 | foreach (Action<Scene> d in handler.GetInvocationList()) | 3162 | foreach (Action<Scene> d in handler.GetInvocationList()) |
3109 | { | 3163 | { |
3164 | m_log.InfoFormat("[EVENT MANAGER]: TriggerSceneShuttingDown invoque {0}", d.Method.Name.ToString()); | ||
3110 | try | 3165 | try |
3111 | { | 3166 | { |
3112 | d(s); | 3167 | d(s); |
@@ -3119,6 +3174,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3119 | } | 3174 | } |
3120 | } | 3175 | } |
3121 | } | 3176 | } |
3177 | m_log.Info("[EVENT MANAGER]: TriggerSceneShuttingDown done"); | ||
3122 | } | 3178 | } |
3123 | 3179 | ||
3124 | public void TriggerOnRegionStarted(Scene scene) | 3180 | public void TriggerOnRegionStarted(Scene scene) |
@@ -3310,6 +3366,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3310 | } | 3366 | } |
3311 | } | 3367 | } |
3312 | 3368 | ||
3369 | public void TriggerThrottleUpdate(ScenePresence scenePresence) | ||
3370 | { | ||
3371 | ThrottleUpdate handler = OnThrottleUpdate; | ||
3372 | if (handler != null) | ||
3373 | { | ||
3374 | handler(scenePresence); | ||
3375 | } | ||
3376 | } | ||
3377 | |||
3313 | // public void TriggerGatherUuids(SceneObjectPart sop, IDictionary<UUID, AssetType> assetUuids) | 3378 | // public void TriggerGatherUuids(SceneObjectPart sop, IDictionary<UUID, AssetType> assetUuids) |
3314 | // { | 3379 | // { |
3315 | // GatherUuids handler = OnGatherUuids; | 3380 | // GatherUuids handler = OnGatherUuids; |
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs index 646403f..2b95a4c 100644 --- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs +++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs | |||
@@ -292,14 +292,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
292 | 292 | ||
293 | private void StartTimer() | 293 | private void StartTimer() |
294 | { | 294 | { |
295 | KeyframeTimer.Add(this); | 295 | lock (m_frames) |
296 | m_timerStopped = false; | 296 | { |
297 | KeyframeTimer.Add(this); | ||
298 | m_timerStopped = false; | ||
299 | } | ||
297 | } | 300 | } |
298 | 301 | ||
299 | private void StopTimer() | 302 | private void StopTimer() |
300 | { | 303 | { |
301 | m_timerStopped = true; | 304 | lock (m_frames) |
302 | KeyframeTimer.Remove(this); | 305 | m_timerStopped = true; |
303 | } | 306 | } |
304 | 307 | ||
305 | public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) | 308 | public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data) |
@@ -348,6 +351,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
348 | m_group = grp; | 351 | m_group = grp; |
349 | m_scene = grp.Scene; | 352 | m_scene = grp.Scene; |
350 | 353 | ||
354 | <<<<<<< HEAD | ||
351 | Vector3 grppos = grp.AbsolutePosition; | 355 | Vector3 grppos = grp.AbsolutePosition; |
352 | Vector3 offset = grppos - m_serializedPosition; | 356 | Vector3 offset = grppos - m_serializedPosition; |
353 | // avoid doing it more than once | 357 | // avoid doing it more than once |
@@ -366,6 +370,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
366 | k.StartPosition += offset; | 370 | k.StartPosition += offset; |
367 | k.Position += offset; | 371 | k.Position += offset; |
368 | m_frames[i]=k; | 372 | m_frames[i]=k; |
373 | ======= | ||
374 | lock (m_frames) | ||
375 | { | ||
376 | Vector3 grppos = grp.AbsolutePosition; | ||
377 | Vector3 offset = grppos - m_serializedPosition; | ||
378 | // avoid doing it more than once | ||
379 | // current this will happen draging a prim to other region | ||
380 | m_serializedPosition = grppos; | ||
381 | |||
382 | m_basePosition += offset; | ||
383 | m_currentFrame.Position += offset; | ||
384 | |||
385 | m_nextPosition += offset; | ||
386 | |||
387 | for (int i = 0; i < m_frames.Count; i++) | ||
388 | { | ||
389 | Keyframe k = m_frames[i]; | ||
390 | k.Position += offset; | ||
391 | m_frames[i] = k; | ||
392 | } | ||
393 | >>>>>>> avn/ubitvar | ||
369 | } | 394 | } |
370 | 395 | ||
371 | if (m_running) | 396 | if (m_running) |
@@ -410,25 +435,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
410 | m_keyframes.CopyTo(newmotion.m_keyframes, 0); | 435 | m_keyframes.CopyTo(newmotion.m_keyframes, 0); |
411 | } | 436 | } |
412 | 437 | ||
413 | newmotion.m_frames = new List<Keyframe>(m_frames); | 438 | lock (m_frames) |
439 | { | ||
440 | newmotion.m_frames = new List<Keyframe>(m_frames); | ||
414 | 441 | ||
415 | newmotion.m_basePosition = m_basePosition; | 442 | newmotion.m_basePosition = m_basePosition; |
416 | newmotion.m_baseRotation = m_baseRotation; | 443 | newmotion.m_baseRotation = m_baseRotation; |
417 | 444 | ||
418 | if (m_selected) | 445 | if (m_selected) |
419 | newmotion.m_serializedPosition = m_serializedPosition; | ||
420 | else | ||
421 | { | ||
422 | if (m_group != null) | ||
423 | newmotion.m_serializedPosition = m_group.AbsolutePosition; | ||
424 | else | ||
425 | newmotion.m_serializedPosition = m_serializedPosition; | 446 | newmotion.m_serializedPosition = m_serializedPosition; |
426 | } | 447 | else |
448 | { | ||
449 | if (m_group != null) | ||
450 | newmotion.m_serializedPosition = m_group.AbsolutePosition; | ||
451 | else | ||
452 | newmotion.m_serializedPosition = m_serializedPosition; | ||
453 | } | ||
427 | 454 | ||
428 | newmotion.m_currentFrame = m_currentFrame; | 455 | newmotion.m_currentFrame = m_currentFrame; |
429 | 456 | ||
430 | newmotion.m_iterations = m_iterations; | 457 | newmotion.m_iterations = m_iterations; |
431 | newmotion.m_running = m_running; | 458 | newmotion.m_running = m_running; |
459 | } | ||
432 | 460 | ||
433 | if (m_running && !m_waitingCrossing) | 461 | if (m_running && !m_waitingCrossing) |
434 | StartTimer(); | 462 | StartTimer(); |
@@ -458,19 +486,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
458 | } | 486 | } |
459 | else | 487 | else |
460 | { | 488 | { |
461 | m_running = false; | ||
462 | StopTimer(); | 489 | StopTimer(); |
490 | m_running = false; | ||
463 | } | 491 | } |
464 | } | 492 | } |
465 | 493 | ||
466 | public void Stop() | 494 | public void Stop() |
467 | { | 495 | { |
496 | StopTimer(); | ||
468 | m_running = false; | 497 | m_running = false; |
469 | m_isCrossing = false; | 498 | m_isCrossing = false; |
470 | m_waitingCrossing = false; | 499 | m_waitingCrossing = false; |
471 | 500 | ||
472 | StopTimer(); | ||
473 | |||
474 | m_basePosition = m_group.AbsolutePosition; | 501 | m_basePosition = m_group.AbsolutePosition; |
475 | m_baseRotation = m_group.GroupRotation; | 502 | m_baseRotation = m_group.GroupRotation; |
476 | 503 | ||
@@ -483,14 +510,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
483 | 510 | ||
484 | public void Pause() | 511 | public void Pause() |
485 | { | 512 | { |
486 | m_running = false; | ||
487 | StopTimer(); | 513 | StopTimer(); |
514 | m_running = false; | ||
488 | 515 | ||
489 | m_group.RootPart.Velocity = Vector3.Zero; | 516 | m_group.RootPart.Velocity = Vector3.Zero; |
490 | m_group.RootPart.AngularVelocity = Vector3.Zero; | 517 | m_group.RootPart.AngularVelocity = Vector3.Zero; |
491 | m_group.SendGroupRootTerseUpdate(); | 518 | m_group.SendGroupRootTerseUpdate(); |
492 | // m_group.RootPart.ScheduleTerseUpdate(); | 519 | // m_group.RootPart.ScheduleTerseUpdate(); |
520 | } | ||
493 | 521 | ||
522 | public void Suspend() | ||
523 | { | ||
524 | lock (m_frames) | ||
525 | { | ||
526 | if (m_timerStopped) | ||
527 | return; | ||
528 | m_timerStopped = true; | ||
529 | } | ||
530 | } | ||
531 | |||
532 | public void Resume() | ||
533 | { | ||
534 | lock (m_frames) | ||
535 | { | ||
536 | if (!m_timerStopped) | ||
537 | return; | ||
538 | if (m_running && !m_waitingCrossing) | ||
539 | StartTimer(); | ||
540 | } | ||
494 | } | 541 | } |
495 | 542 | ||
496 | private void GetNextList() | 543 | private void GetNextList() |
@@ -581,6 +628,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
581 | 628 | ||
582 | pos = (Vector3)k.Position; | 629 | pos = (Vector3)k.Position; |
583 | rot = (Quaternion)k.Rotation; | 630 | rot = (Quaternion)k.Rotation; |
631 | |||
584 | } | 632 | } |
585 | 633 | ||
586 | m_basePosition = pos; | 634 | m_basePosition = pos; |
@@ -592,15 +640,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
592 | 640 | ||
593 | public void OnTimer(double tickDuration) | 641 | public void OnTimer(double tickDuration) |
594 | { | 642 | { |
643 | if (!Monitor.TryEnter(m_frames)) | ||
644 | return; | ||
645 | if (m_timerStopped) | ||
646 | KeyframeTimer.Remove(this); | ||
647 | else | ||
648 | DoOnTimer(tickDuration); | ||
649 | Monitor.Exit(m_frames); | ||
650 | } | ||
651 | |||
652 | private void Done() | ||
653 | { | ||
654 | KeyframeTimer.Remove(this); | ||
655 | m_timerStopped = true; | ||
656 | m_running = false; | ||
657 | m_isCrossing = false; | ||
658 | m_waitingCrossing = false; | ||
659 | |||
660 | m_basePosition = m_group.AbsolutePosition; | ||
661 | m_baseRotation = m_group.GroupRotation; | ||
662 | |||
663 | m_group.RootPart.Velocity = Vector3.Zero; | ||
664 | m_group.RootPart.AngularVelocity = Vector3.Zero; | ||
665 | m_group.SendGroupRootTerseUpdate(); | ||
666 | // m_group.RootPart.ScheduleTerseUpdate(); | ||
667 | m_frames.Clear(); | ||
668 | } | ||
669 | |||
670 | private void DoOnTimer(double tickDuration) | ||
671 | { | ||
595 | if (m_skipLoops > 0) | 672 | if (m_skipLoops > 0) |
596 | { | 673 | { |
597 | m_skipLoops--; | 674 | m_skipLoops--; |
598 | return; | 675 | return; |
599 | } | 676 | } |
600 | 677 | ||
601 | if (m_timerStopped) // trap events still in air even after a timer.stop | ||
602 | return; | ||
603 | |||
604 | if (m_group == null) | 678 | if (m_group == null) |
605 | return; | 679 | return; |
606 | 680 | ||
@@ -612,7 +686,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
612 | { | 686 | { |
613 | m_group.RootPart.Velocity = Vector3.Zero; | 687 | m_group.RootPart.Velocity = Vector3.Zero; |
614 | m_group.SendGroupRootTerseUpdate(); | 688 | m_group.SendGroupRootTerseUpdate(); |
615 | |||
616 | } | 689 | } |
617 | return; | 690 | return; |
618 | } | 691 | } |
@@ -635,6 +708,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
635 | 708 | ||
636 | if (m_frames.Count == 0) | 709 | if (m_frames.Count == 0) |
637 | { | 710 | { |
711 | <<<<<<< HEAD | ||
638 | if (!m_running) return; | 712 | if (!m_running) return; |
639 | 713 | ||
640 | GetNextList(); | 714 | GetNextList(); |
@@ -656,11 +730,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
656 | 730 | ||
657 | return; | 731 | return; |
658 | } | 732 | } |
733 | ======= | ||
734 | lock (m_frames) | ||
735 | { | ||
736 | GetNextList(); | ||
659 | 737 | ||
660 | m_currentFrame = m_frames[0]; | 738 | if (m_frames.Count == 0) |
661 | m_currentFrame.TimeMS += (int)tickDuration; | 739 | { |
740 | Done(); | ||
741 | Scene scene = m_group.Scene; | ||
662 | 742 | ||
743 | IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>(); | ||
744 | foreach (IScriptModule m in scriptModules) | ||
745 | { | ||
746 | if (m == null) | ||
747 | continue; | ||
748 | m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]); | ||
749 | } | ||
750 | >>>>>>> avn/ubitvar | ||
751 | |||
752 | return; | ||
753 | } | ||
754 | |||
755 | m_currentFrame = m_frames[0]; | ||
756 | m_currentFrame.TimeMS += (int)tickDuration; | ||
757 | } | ||
663 | //force a update on a keyframe transition | 758 | //force a update on a keyframe transition |
759 | m_nextPosition = m_group.AbsolutePosition; | ||
664 | update = true; | 760 | update = true; |
665 | } | 761 | } |
666 | 762 | ||
@@ -681,9 +777,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
681 | // m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); | 777 | // m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation); |
682 | 778 | ||
683 | m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; | 779 | m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation; |
684 | m_frames.RemoveAt(0); | 780 | |
685 | if (m_frames.Count > 0) | 781 | lock (m_frames) |
686 | m_currentFrame = m_frames[0]; | 782 | { |
783 | m_frames.RemoveAt(0); | ||
784 | if (m_frames.Count > 0) | ||
785 | m_currentFrame = m_frames[0]; | ||
786 | } | ||
687 | 787 | ||
688 | update = true; | 788 | update = true; |
689 | } | 789 | } |
@@ -695,14 +795,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
695 | Vector3 positionThisStep = m_currentFrame.StartPosition + (m_currentFrame.Position.Value - m_currentFrame.StartPosition) * completed; | 795 | Vector3 positionThisStep = m_currentFrame.StartPosition + (m_currentFrame.Position.Value - m_currentFrame.StartPosition) * completed; |
696 | Vector3 motionThisStep = positionThisStep - m_group.AbsolutePosition; | 796 | Vector3 motionThisStep = positionThisStep - m_group.AbsolutePosition; |
697 | 797 | ||
798 | <<<<<<< HEAD | ||
698 | float mag = Vector3.Mag(motionThisStep); | 799 | float mag = Vector3.Mag(motionThisStep); |
699 | 800 | ||
700 | if ((mag >= 0.02f) || lastStep) | 801 | if ((mag >= 0.02f) || lastStep) |
701 | { | 802 | { |
702 | m_nextPosition = m_group.AbsolutePosition + motionThisStep; | 803 | m_nextPosition = m_group.AbsolutePosition + motionThisStep; |
703 | m_group.AbsolutePosition = m_nextPosition; | 804 | m_group.AbsolutePosition = m_nextPosition; |
805 | ======= | ||
806 | m_nextPosition = m_group.AbsolutePosition + motionThisFrame; | ||
807 | |||
808 | if (Vector3.Mag(motionThisFrame) >= 0.05f) | ||
809 | >>>>>>> avn/ubitvar | ||
704 | update = true; | 810 | update = true; |
705 | } | ||
706 | 811 | ||
707 | //int totalSteps = m_currentFrame.TimeTotal / (int)tickDuration; | 812 | //int totalSteps = m_currentFrame.TimeTotal / (int)tickDuration; |
708 | //m_log.DebugFormat("KeyframeMotion.OnTimer: step {0}/{1}, curPosition={2}, finalPosition={3}, motionThisStep={4} (scene {5})", | 813 | //m_log.DebugFormat("KeyframeMotion.OnTimer: step {0}/{1}, curPosition={2}, finalPosition={3}, motionThisStep={4} (scene {5})", |
@@ -714,6 +819,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
714 | 819 | ||
715 | Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, completed); | 820 | Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, completed); |
716 | step.Normalize(); | 821 | step.Normalize(); |
822 | <<<<<<< HEAD | ||
717 | /* use simpler change detection | 823 | /* use simpler change detection |
718 | * float angle = 0; | 824 | * float angle = 0; |
719 | 825 | ||
@@ -751,8 +857,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
751 | || lastStep) | 857 | || lastStep) |
752 | // assuming w is a dependente var | 858 | // assuming w is a dependente var |
753 | 859 | ||
860 | ======= | ||
861 | /* use simpler change detection | ||
862 | * float angle = 0; | ||
863 | |||
864 | float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W; | ||
865 | float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W; | ||
866 | float aa_bb = aa * bb; | ||
867 | |||
868 | if (aa_bb == 0) | ||
869 | { | ||
870 | angle = 0; | ||
871 | } | ||
872 | else | ||
873 | { | ||
874 | float ab = current.X * step.X + | ||
875 | current.Y * step.Y + | ||
876 | current.Z * step.Z + | ||
877 | current.W * step.W; | ||
878 | float q = (ab * ab) / aa_bb; | ||
879 | |||
880 | if (q > 1.0f) | ||
881 | { | ||
882 | angle = 0; | ||
883 | } | ||
884 | else | ||
885 | { | ||
886 | angle = (float)Math.Acos(2 * q - 1); | ||
887 | } | ||
888 | } | ||
889 | |||
890 | if (angle > 0.01f) | ||
891 | */ | ||
892 | if (Math.Abs(step.X - current.X) > 0.001f | ||
893 | || Math.Abs(step.Y - current.Y) > 0.001f | ||
894 | || Math.Abs(step.Z - current.Z) > 0.001f) | ||
895 | // assuming w is a dependente var | ||
896 | >>>>>>> avn/ubitvar | ||
754 | { | 897 | { |
755 | // m_group.UpdateGroupRotationR(step); | 898 | // m_group.UpdateGroupRotationR(step); |
756 | m_group.RootPart.RotationOffset = step; | 899 | m_group.RootPart.RotationOffset = step; |
757 | 900 | ||
758 | //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); | 901 | //m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2); |
@@ -763,18 +906,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
763 | 906 | ||
764 | if (update) | 907 | if (update) |
765 | { | 908 | { |
909 | m_group.AbsolutePosition = m_nextPosition; | ||
766 | m_group.SendGroupRootTerseUpdate(); | 910 | m_group.SendGroupRootTerseUpdate(); |
767 | } | 911 | } |
768 | } | 912 | } |
769 | 913 | ||
770 | public Byte[] Serialize() | 914 | public Byte[] Serialize() |
771 | { | 915 | { |
916 | bool timerWasStopped; | ||
917 | lock (m_frames) | ||
918 | { | ||
919 | timerWasStopped = m_timerStopped; | ||
920 | } | ||
772 | StopTimer(); | 921 | StopTimer(); |
773 | 922 | ||
774 | SceneObjectGroup tmp = m_group; | 923 | SceneObjectGroup tmp = m_group; |
775 | m_group = null; | 924 | m_group = null; |
776 | if (!m_selected && tmp != null) | 925 | if (!m_selected && tmp != null) |
777 | m_serializedPosition = tmp.AbsolutePosition; | 926 | m_serializedPosition = tmp.AbsolutePosition; |
927 | <<<<<<< HEAD | ||
928 | ======= | ||
929 | fmt.Serialize(ms, this); | ||
930 | m_group = tmp; | ||
931 | if (!timerWasStopped && m_running && !m_waitingCrossing) | ||
932 | StartTimer(); | ||
933 | >>>>>>> avn/ubitvar | ||
778 | 934 | ||
779 | using (MemoryStream ms = new MemoryStream()) | 935 | using (MemoryStream ms = new MemoryStream()) |
780 | { | 936 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 1b10e3c..c0405ad 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs | |||
@@ -91,6 +91,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
91 | return 0; | 91 | return 0; |
92 | 92 | ||
93 | uint priority; | 93 | uint priority; |
94 | |||
95 | |||
96 | // HACK | ||
97 | return GetPriorityByBestAvatarResponsiveness(client, entity); | ||
98 | |||
94 | 99 | ||
95 | switch (m_scene.UpdatePrioritizationScheme) | 100 | switch (m_scene.UpdatePrioritizationScheme) |
96 | { | 101 | { |
@@ -157,30 +162,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
157 | 162 | ||
158 | private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) | 163 | private uint GetPriorityByBestAvatarResponsiveness(IClientAPI client, ISceneEntity entity) |
159 | { | 164 | { |
160 | uint pqueue = ComputeDistancePriority(client,entity,true); | 165 | uint pqueue = 2; // keep compiler happy |
161 | 166 | ||
162 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); | 167 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); |
163 | if (presence != null) | 168 | if (presence != null) |
164 | { | 169 | { |
165 | if (!presence.IsChildAgent) | 170 | // All avatars other than our own go into pqueue 1 |
171 | if (entity is ScenePresence) | ||
172 | return 1; | ||
173 | |||
174 | if (entity is SceneObjectPart) | ||
166 | { | 175 | { |
167 | // All avatars other than our own go into pqueue 1 | 176 | // Attachments are high priority, |
168 | if (entity is ScenePresence) | 177 | if (((SceneObjectPart)entity).ParentGroup.IsAttachment) |
169 | return 1; | 178 | return 2; |
170 | 179 | ||
171 | if (entity is SceneObjectPart) | 180 | pqueue = ComputeDistancePriority(client, entity, false); |
172 | { | 181 | |
173 | // Attachments are high priority, | 182 | // Non physical prims are lower priority than physical prims |
174 | if (((SceneObjectPart)entity).ParentGroup.IsAttachment) | 183 | PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; |
175 | return 1; | 184 | if (physActor == null || !physActor.IsPhysical) |
176 | 185 | pqueue++; | |
177 | // Non physical prims are lower priority than physical prims | ||
178 | PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; | ||
179 | if (physActor == null || !physActor.IsPhysical) | ||
180 | pqueue++; | ||
181 | } | ||
182 | } | 186 | } |
183 | } | 187 | } |
188 | else | ||
189 | pqueue = ComputeDistancePriority(client, entity, false); | ||
184 | 190 | ||
185 | return pqueue; | 191 | return pqueue; |
186 | } | 192 | } |
@@ -212,25 +218,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
212 | } | 218 | } |
213 | 219 | ||
214 | // Use the camera position for local agents and avatar position for remote agents | 220 | // Use the camera position for local agents and avatar position for remote agents |
215 | Vector3 presencePos = (presence.IsChildAgent) ? | 221 | // Why would I want that? They could be camming but I still see them at the |
216 | presence.AbsolutePosition : | 222 | // avatar position, so why should I update them as if they were at their |
217 | presence.CameraPosition; | 223 | // camera positions? Makes no sense! |
224 | // TODO: Fix this mess | ||
225 | //Vector3 presencePos = (presence.IsChildAgent) ? | ||
226 | // presence.AbsolutePosition : | ||
227 | // presence.CameraPosition; | ||
228 | |||
229 | Vector3 presencePos = presence.AbsolutePosition; | ||
218 | 230 | ||
219 | // Compute the distance... | 231 | // Compute the distance... |
220 | double distance = Vector3.Distance(presencePos, entityPos); | 232 | double distance = Vector3.Distance(presencePos, entityPos); |
221 | 233 | ||
222 | // And convert the distance to a priority queue, this computation gives queues | 234 | // And convert the distance to a priority queue, this computation gives queues |
223 | // at 10, 20, 40, 80, 160, 320, 640, and 1280m | 235 | // at 10, 20, 40, 80, 160, 320, 640, and 1280m |
224 | uint pqueue = PriorityQueue.NumberOfImmediateQueues; | 236 | uint pqueue = PriorityQueue.NumberOfImmediateQueues + 1; // reserve attachments queue |
225 | uint queues = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues; | 237 | uint queues = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues; |
226 | 238 | /* | |
227 | for (int i = 0; i < queues - 1; i++) | 239 | for (int i = 0; i < queues - 1; i++) |
228 | { | 240 | { |
229 | if (distance < 10 * Math.Pow(2.0,i)) | 241 | if (distance < 30 * Math.Pow(2.0,i)) |
230 | break; | 242 | break; |
231 | pqueue++; | 243 | pqueue++; |
232 | } | 244 | } |
233 | 245 | */ | |
246 | if (distance > 10f) | ||
247 | { | ||
248 | float tmp = (float)Math.Log((double)distance) * 1.4426950408889634073599246810019f - 3.3219280948873623478703194294894f; | ||
249 | // for a map identical to original: | ||
250 | // now | ||
251 | // 1st constant is 1/(log(2)) (natural log) so we get log2(distance) | ||
252 | // 2st constant makes it be log2(distance/10) | ||
253 | pqueue += (uint)tmp; | ||
254 | if (pqueue > queues - 1) | ||
255 | pqueue = queues - 1; | ||
256 | } | ||
257 | |||
234 | // If this is a root agent, then determine front & back | 258 | // If this is a root agent, then determine front & back |
235 | // Bump up the priority queue (drop the priority) for any objects behind the avatar | 259 | // Bump up the priority queue (drop the priority) for any objects behind the avatar |
236 | if (useFrontBack && ! presence.IsChildAgent) | 260 | if (useFrontBack && ! presence.IsChildAgent) |
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 b838177..e289666 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -106,12 +106,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
106 | engine.StartProcessing(); | 106 | engine.StartProcessing(); |
107 | } | 107 | } |
108 | 108 | ||
109 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) | 109 | public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item, uint cost) |
110 | { | 110 | { |
111 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); | 111 | IMoneyModule money = RequestModuleInterface<IMoneyModule>(); |
112 | if (money != null) | 112 | if (money != null) |
113 | { | 113 | { |
114 | money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload"); | 114 | money.ApplyUploadCharge(agentID, (int)cost, "Asset upload"); |
115 | } | 115 | } |
116 | 116 | ||
117 | AddInventoryItem(item); | 117 | AddInventoryItem(item); |
@@ -182,7 +182,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
182 | return false; | 182 | return false; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | 185 | ||
186 | if (InventoryService.AddItem(item)) | 186 | if (InventoryService.AddItem(item)) |
187 | { | 187 | { |
188 | int userlevel = 0; | 188 | int userlevel = 0; |
@@ -338,8 +338,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
338 | 338 | ||
339 | // Update item with new asset | 339 | // Update item with new asset |
340 | item.AssetID = asset.FullID; | 340 | item.AssetID = asset.FullID; |
341 | if (group.UpdateInventoryItem(item)) | 341 | group.UpdateInventoryItem(item); |
342 | remoteClient.SendAlertMessage("Script saved"); | ||
343 | 342 | ||
344 | part.SendPropertiesToClient(remoteClient); | 343 | part.SendPropertiesToClient(remoteClient); |
345 | 344 | ||
@@ -350,12 +349,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
350 | { | 349 | { |
351 | // Needs to determine which engine was running it and use that | 350 | // Needs to determine which engine was running it and use that |
352 | // | 351 | // |
353 | part.Inventory.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0); | 352 | errors = part.Inventory.CreateScriptInstanceEr(item.ItemID, 0, false, DefaultScriptEngine, 1); |
354 | errors = part.Inventory.GetScriptErrors(item.ItemID); | ||
355 | } | ||
356 | else | ||
357 | { | ||
358 | remoteClient.SendAlertMessage("Script saved"); | ||
359 | } | 353 | } |
360 | 354 | ||
361 | // Tell anyone managing scripts that a script has been reloaded/changed | 355 | // Tell anyone managing scripts that a script has been reloaded/changed |
@@ -421,6 +415,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
421 | if (item.Owner != remoteClient.AgentId) | 415 | if (item.Owner != remoteClient.AgentId) |
422 | return; | 416 | return; |
423 | 417 | ||
418 | item.Flags = (item.Flags & ~(uint)255) | (itemUpd.Flags & (uint)255); | ||
424 | item.Name = itemUpd.Name; | 419 | item.Name = itemUpd.Name; |
425 | item.Description = itemUpd.Description; | 420 | item.Description = itemUpd.Description; |
426 | 421 | ||
@@ -886,8 +881,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
886 | return; | 881 | return; |
887 | } | 882 | } |
888 | 883 | ||
884 | <<<<<<< HEAD | ||
889 | if (newName == String.Empty) | 885 | if (newName == String.Empty) |
890 | newName = item.Name; | 886 | newName = item.Name; |
887 | ======= | ||
888 | if (newName == null) newName = item.Name; | ||
889 | |||
890 | AssetBase asset = AssetService.Get(item.AssetID.ToString()); | ||
891 | >>>>>>> avn/ubitvar | ||
891 | 892 | ||
892 | if (remoteClient.AgentId == oldAgentID | 893 | if (remoteClient.AgentId == oldAgentID |
893 | || (LibraryService != null | 894 | || (LibraryService != null |
@@ -929,6 +930,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
929 | } | 930 | } |
930 | 931 | ||
931 | /// <summary> | 932 | /// <summary> |
933 | /// Move an item within the agent's inventory, and leave a copy (used in making a new outfit) | ||
934 | /// </summary> | ||
935 | public void MoveInventoryItemsLeaveCopy(IClientAPI remoteClient, List<InventoryItemBase> items, UUID destfolder) | ||
936 | { | ||
937 | List<InventoryItemBase> moveitems = new List<InventoryItemBase>(); | ||
938 | foreach (InventoryItemBase b in items) | ||
939 | { | ||
940 | CopyInventoryItem(remoteClient, 0, remoteClient.AgentId, b.ID, b.Folder, null); | ||
941 | InventoryItemBase n = InventoryService.GetItem(b); | ||
942 | n.Folder = destfolder; | ||
943 | moveitems.Add(n); | ||
944 | remoteClient.SendInventoryItemCreateUpdate(n, 0); | ||
945 | } | ||
946 | |||
947 | MoveInventoryItem(remoteClient, moveitems); | ||
948 | } | ||
949 | |||
950 | /// <summary> | ||
932 | /// Move an item within the agent's inventory. | 951 | /// Move an item within the agent's inventory. |
933 | /// </summary> | 952 | /// </summary> |
934 | /// <param name="remoteClient"></param> | 953 | /// <param name="remoteClient"></param> |
@@ -963,12 +982,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
963 | public void CreateNewInventoryItem( | 982 | public void CreateNewInventoryItem( |
964 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 983 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
965 | string name, string description, uint flags, uint callbackID, | 984 | string name, string description, uint flags, uint callbackID, |
985 | <<<<<<< HEAD | ||
966 | UUID assetID, sbyte assetType, sbyte invType, uint nextOwnerMask, int creationDate) | 986 | UUID assetID, sbyte assetType, sbyte invType, uint nextOwnerMask, int creationDate) |
967 | { | 987 | { |
968 | CreateNewInventoryItem( | 988 | CreateNewInventoryItem( |
969 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, assetID, assetType, invType, | 989 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, assetID, assetType, invType, |
970 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, | 990 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, |
971 | creationDate, true); | 991 | creationDate, true); |
992 | ======= | ||
993 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate, UUID transationID) | ||
994 | { | ||
995 | CreateNewInventoryItem( | ||
996 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, | ||
997 | (uint)PermissionMask.All | (uint)PermissionMask.Export, (uint)PermissionMask.All | (uint)PermissionMask.Export, 0, nextOwnerMask, 0, creationDate, transationID); | ||
998 | } | ||
999 | |||
1000 | |||
1001 | private void CreateNewInventoryItem( | ||
1002 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | ||
1003 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | ||
1004 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | ||
1005 | { | ||
1006 | CreateNewInventoryItem(remoteClient, creatorID, creatorData, folderID, | ||
1007 | name, description, flags, callbackID, asset, invType, | ||
1008 | baseMask, currentMask, everyoneMask, nextOwnerMask, groupMask, creationDate, UUID.Zero); | ||
1009 | >>>>>>> avn/ubitvar | ||
972 | } | 1010 | } |
973 | 1011 | ||
974 | /// <summary> | 1012 | /// <summary> |
@@ -992,9 +1030,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
992 | /// <param name="creationDate">Unix timestamp at which this item was created.</param> | 1030 | /// <param name="creationDate">Unix timestamp at which this item was created.</param> |
993 | private void CreateNewInventoryItem( | 1031 | private void CreateNewInventoryItem( |
994 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | 1032 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
1033 | <<<<<<< HEAD | ||
995 | string name, string description, uint flags, uint callbackID, UUID assetID, sbyte assetType, sbyte invType, | 1034 | string name, string description, uint flags, uint callbackID, UUID assetID, sbyte assetType, sbyte invType, |
996 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate, | 1035 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate, |
997 | bool assetUpload) | 1036 | bool assetUpload) |
1037 | ======= | ||
1038 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | ||
1039 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate,UUID transationID) | ||
1040 | >>>>>>> avn/ubitvar | ||
998 | { | 1041 | { |
999 | InventoryItemBase item = new InventoryItemBase(); | 1042 | InventoryItemBase item = new InventoryItemBase(); |
1000 | item.Owner = remoteClient.AgentId; | 1043 | item.Owner = remoteClient.AgentId; |
@@ -1015,9 +1058,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1015 | item.BasePermissions = baseMask; | 1058 | item.BasePermissions = baseMask; |
1016 | item.CreationDate = creationDate; | 1059 | item.CreationDate = creationDate; |
1017 | 1060 | ||
1061 | <<<<<<< HEAD | ||
1018 | if (AddInventoryItem(item, assetUpload)) | 1062 | if (AddInventoryItem(item, assetUpload)) |
1063 | ======= | ||
1064 | // special AnimationSet case | ||
1065 | if (item.InvType == (int)CustomInventoryType.AnimationSet) | ||
1066 | AnimationSet.enforceItemPermitions(item,true); | ||
1067 | |||
1068 | if (AddInventoryItem(item)) | ||
1069 | >>>>>>> avn/ubitvar | ||
1019 | { | 1070 | { |
1020 | remoteClient.SendInventoryItemCreateUpdate(item, callbackID); | 1071 | remoteClient.SendInventoryItemCreateUpdate(item, transationID, callbackID); |
1021 | } | 1072 | } |
1022 | else | 1073 | else |
1023 | { | 1074 | { |
@@ -1233,6 +1284,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1233 | agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); | 1284 | agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); |
1234 | if (taskItem.InvType == (int)InventoryType.Object) | 1285 | if (taskItem.InvType == (int)InventoryType.Object) |
1235 | { | 1286 | { |
1287 | <<<<<<< HEAD | ||
1236 | // Bake the new base permissions from folded permissions | 1288 | // Bake the new base permissions from folded permissions |
1237 | // The folded perms are in the lowest 3 bits of the current perms | 1289 | // The folded perms are in the lowest 3 bits of the current perms |
1238 | // We use base permissions here to avoid baking the "Locked" status | 1290 | // We use base permissions here to avoid baking the "Locked" status |
@@ -1244,6 +1296,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1244 | agentItem.BasePermissions = perms | (uint)PermissionMask.Move; | 1296 | agentItem.BasePermissions = perms | (uint)PermissionMask.Move; |
1245 | // Newly given items cannot be "locked" on rez. Make sure by | 1297 | // Newly given items cannot be "locked" on rez. Make sure by |
1246 | // setting current equal to base. | 1298 | // setting current equal to base. |
1299 | ======= | ||
1300 | uint perms = taskItem.BasePermissions & taskItem.NextPermissions; | ||
1301 | PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms); | ||
1302 | // agentItem.BasePermissions = perms | (uint)PermissionMask.Move; | ||
1303 | // agentItem.CurrentPermissions = agentItem.BasePermissions; | ||
1304 | agentItem.BasePermissions = perms | (uint)PermissionMask.Move; | ||
1305 | >>>>>>> avn/ubitvar | ||
1247 | } | 1306 | } |
1248 | 1307 | ||
1249 | agentItem.CurrentPermissions = agentItem.BasePermissions; | 1308 | agentItem.CurrentPermissions = agentItem.BasePermissions; |
@@ -1327,6 +1386,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1327 | { | 1386 | { |
1328 | SceneObjectPart part = GetSceneObjectPart(primLocalId); | 1387 | SceneObjectPart part = GetSceneObjectPart(primLocalId); |
1329 | 1388 | ||
1389 | // Can't move a null item | ||
1390 | if (itemId == UUID.Zero) | ||
1391 | return; | ||
1392 | |||
1330 | if (null == part) | 1393 | if (null == part) |
1331 | { | 1394 | { |
1332 | m_log.WarnFormat( | 1395 | m_log.WarnFormat( |
@@ -1437,21 +1500,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1437 | return; | 1500 | return; |
1438 | } | 1501 | } |
1439 | 1502 | ||
1440 | if (part.OwnerID != destPart.OwnerID) | 1503 | // Can't transfer this |
1504 | // | ||
1505 | if (part.OwnerID != destPart.OwnerID && (srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1506 | return; | ||
1507 | |||
1508 | bool overrideNoMod = false; | ||
1509 | if ((part.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) != 0) | ||
1510 | overrideNoMod = true; | ||
1511 | |||
1512 | if (part.OwnerID != destPart.OwnerID && (destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1441 | { | 1513 | { |
1442 | // Source must have transfer permissions | 1514 | // object cannot copy items to an object owned by a different owner |
1443 | if ((srcTaskItem.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | 1515 | // unless llAllowInventoryDrop has been called |
1444 | return; | ||
1445 | 1516 | ||
1446 | // Object cannot copy items to an object owned by a different owner | 1517 | return; |
1447 | // unless llAllowInventoryDrop has been called on the destination | ||
1448 | if ((destPart.GetEffectiveObjectFlags() & (uint)PrimFlags.AllowInventoryDrop) == 0) | ||
1449 | return; | ||
1450 | } | 1518 | } |
1451 | 1519 | ||
1452 | // must have both move and modify permission to put an item in an object | 1520 | // must have both move and modify permission to put an item in an object |
1453 | if ((part.OwnerMask & ((uint)PermissionMask.Move | (uint)PermissionMask.Modify)) == 0) | 1521 | if (((part.OwnerMask & (uint)PermissionMask.Modify) == 0) && (!overrideNoMod)) |
1522 | { | ||
1454 | return; | 1523 | return; |
1524 | } | ||
1455 | 1525 | ||
1456 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); | 1526 | TaskInventoryItem destTaskItem = new TaskInventoryItem(); |
1457 | 1527 | ||
@@ -1507,10 +1577,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
1507 | 1577 | ||
1508 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) | 1578 | public UUID MoveTaskInventoryItems(UUID destID, string category, SceneObjectPart host, List<UUID> items) |
1509 | { | 1579 | { |
1580 | <<<<<<< HEAD | ||
1510 | ScenePresence avatar; | 1581 | ScenePresence avatar; |
1511 | IClientAPI remoteClient = null; | 1582 | IClientAPI remoteClient = null; |
1512 | if (TryGetScenePresence(destID, out avatar)) | 1583 | if (TryGetScenePresence(destID, out avatar)) |
1513 | remoteClient = avatar.ControllingClient; | 1584 | remoteClient = avatar.ControllingClient; |
1585 | ======= | ||
1586 | SceneObjectPart destPart = GetSceneObjectPart(destID); | ||
1587 | if (destPart != null) // Move into a prim | ||
1588 | { | ||
1589 | foreach(UUID itemID in items) | ||
1590 | MoveTaskInventoryItem(destID, host, itemID); | ||
1591 | return destID; // Prim folder ID == prim ID | ||
1592 | } | ||
1593 | >>>>>>> avn/ubitvar | ||
1514 | 1594 | ||
1515 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); | 1595 | InventoryFolderBase rootFolder = InventoryService.GetRootFolder(destID); |
1516 | 1596 | ||
@@ -1696,12 +1776,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1696 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( | 1776 | AgentTransactionsModule.HandleTaskItemUpdateFromTransaction( |
1697 | remoteClient, part, transactionID, currentItem); | 1777 | remoteClient, part, transactionID, currentItem); |
1698 | 1778 | ||
1699 | if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) | 1779 | // if ((InventoryType)itemInfo.InvType == InventoryType.Notecard) |
1700 | remoteClient.SendAlertMessage("Notecard saved"); | 1780 | // remoteClient.SendAgentAlertMessage("Notecard saved", false); |
1701 | else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) | 1781 | // else if ((InventoryType)itemInfo.InvType == InventoryType.LSL) |
1702 | remoteClient.SendAlertMessage("Script saved"); | 1782 | // remoteClient.SendAgentAlertMessage("Script saved", false); |
1703 | else | 1783 | // else |
1704 | remoteClient.SendAlertMessage("Item saved"); | 1784 | // remoteClient.SendAgentAlertMessage("Item saved", false); |
1705 | } | 1785 | } |
1706 | 1786 | ||
1707 | // Base ALWAYS has move | 1787 | // Base ALWAYS has move |
@@ -2075,23 +2155,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
2075 | // build a list of eligible objects | 2155 | // build a list of eligible objects |
2076 | List<uint> deleteIDs = new List<uint>(); | 2156 | List<uint> deleteIDs = new List<uint>(); |
2077 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); | 2157 | List<SceneObjectGroup> deleteGroups = new List<SceneObjectGroup>(); |
2078 | 2158 | List<SceneObjectGroup> takeGroups = new List<SceneObjectGroup>(); | |
2079 | // Start with true for both, then remove the flags if objects | ||
2080 | // that we can't derez are part of the selection | ||
2081 | bool permissionToTake = true; | ||
2082 | bool permissionToTakeCopy = true; | ||
2083 | bool permissionToDelete = true; | ||
2084 | 2159 | ||
2085 | foreach (uint localID in localIDs) | 2160 | foreach (uint localID in localIDs) |
2086 | { | 2161 | { |
2162 | // Start with true for both, then remove the flags if objects | ||
2163 | // that we can't derez are part of the selection | ||
2164 | bool permissionToTake = true; | ||
2165 | bool permissionToTakeCopy = true; | ||
2166 | bool permissionToDelete = true; | ||
2167 | |||
2087 | // Invalid id | 2168 | // Invalid id |
2088 | SceneObjectPart part = GetSceneObjectPart(localID); | 2169 | SceneObjectPart part = GetSceneObjectPart(localID); |
2089 | if (part == null) | 2170 | if (part == null) |
2171 | { | ||
2172 | //Client still thinks the object exists, kill it | ||
2173 | deleteIDs.Add(localID); | ||
2090 | continue; | 2174 | continue; |
2175 | } | ||
2091 | 2176 | ||
2092 | // Already deleted by someone else | 2177 | // Already deleted by someone else |
2093 | if (part.ParentGroup.IsDeleted) | 2178 | if (part.ParentGroup.IsDeleted) |
2179 | { | ||
2180 | //Client still thinks the object exists, kill it | ||
2181 | deleteIDs.Add(localID); | ||
2094 | continue; | 2182 | continue; |
2183 | } | ||
2095 | 2184 | ||
2096 | // Can't delete child prims | 2185 | // Can't delete child prims |
2097 | if (part != part.ParentGroup.RootPart) | 2186 | if (part != part.ParentGroup.RootPart) |
@@ -2099,9 +2188,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2099 | 2188 | ||
2100 | SceneObjectGroup grp = part.ParentGroup; | 2189 | SceneObjectGroup grp = part.ParentGroup; |
2101 | 2190 | ||
2102 | deleteIDs.Add(localID); | ||
2103 | deleteGroups.Add(grp); | ||
2104 | |||
2105 | // If child prims have invalid perms, fix them | 2191 | // If child prims have invalid perms, fix them |
2106 | grp.AdjustChildPrimPermissions(false); | 2192 | grp.AdjustChildPrimPermissions(false); |
2107 | 2193 | ||
@@ -2121,89 +2207,206 @@ namespace OpenSim.Region.Framework.Scenes | |||
2121 | } | 2207 | } |
2122 | else | 2208 | else |
2123 | { | 2209 | { |
2124 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | 2210 | if (action == DeRezAction.TakeCopy) |
2211 | { | ||
2212 | if (!Permissions.CanTakeCopyObject(grp.UUID, remoteClient.AgentId)) | ||
2213 | permissionToTakeCopy = false; | ||
2214 | } | ||
2215 | else | ||
2216 | { | ||
2125 | permissionToTakeCopy = false; | 2217 | permissionToTakeCopy = false; |
2126 | 2218 | } | |
2127 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) | 2219 | if (!Permissions.CanTakeObject(grp.UUID, remoteClient.AgentId)) |
2128 | permissionToTake = false; | 2220 | permissionToTake = false; |
2129 | 2221 | ||
2130 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) | 2222 | if (!Permissions.CanDeleteObject(grp.UUID, remoteClient.AgentId)) |
2131 | permissionToDelete = false; | 2223 | permissionToDelete = false; |
2132 | } | 2224 | } |
2133 | } | ||
2134 | |||
2135 | // Handle god perms | ||
2136 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) | ||
2137 | { | ||
2138 | permissionToTake = true; | ||
2139 | permissionToTakeCopy = true; | ||
2140 | permissionToDelete = true; | ||
2141 | } | ||
2142 | |||
2143 | // If we're re-saving, we don't even want to delete | ||
2144 | if (action == DeRezAction.SaveToExistingUserInventoryItem) | ||
2145 | permissionToDelete = false; | ||
2146 | 2225 | ||
2147 | // if we want to take a copy, we also don't want to delete | 2226 | // Handle god perms |
2148 | // Note: after this point, the permissionToTakeCopy flag | 2227 | if ((remoteClient != null) && Permissions.IsGod(remoteClient.AgentId)) |
2149 | // becomes irrelevant. It already includes the permissionToTake | ||
2150 | // permission and after excluding no copy items here, we can | ||
2151 | // just use that. | ||
2152 | if (action == DeRezAction.TakeCopy) | ||
2153 | { | ||
2154 | // If we don't have permission, stop right here | ||
2155 | if (!permissionToTakeCopy) | ||
2156 | { | 2228 | { |
2157 | remoteClient.SendAlertMessage("You don't have permission to take the object"); | 2229 | permissionToTake = true; |
2158 | return; | 2230 | permissionToTakeCopy = true; |
2231 | permissionToDelete = true; | ||
2159 | } | 2232 | } |
2160 | 2233 | ||
2161 | permissionToTake = true; | 2234 | // If we're re-saving, we don't even want to delete |
2162 | // Don't delete | 2235 | if (action == DeRezAction.SaveToExistingUserInventoryItem) |
2163 | permissionToDelete = false; | 2236 | permissionToDelete = false; |
2164 | } | ||
2165 | 2237 | ||
2166 | if (action == DeRezAction.Return) | 2238 | // if we want to take a copy, we also don't want to delete |
2167 | { | 2239 | // Note: after this point, the permissionToTakeCopy flag |
2168 | if (remoteClient != null) | 2240 | // becomes irrelevant. It already includes the permissionToTake |
2241 | // permission and after excluding no copy items here, we can | ||
2242 | // just use that. | ||
2243 | if (action == DeRezAction.TakeCopy) | ||
2169 | { | 2244 | { |
2170 | if (Permissions.CanReturnObjects( | 2245 | // If we don't have permission, stop right here |
2171 | null, | 2246 | if (!permissionToTakeCopy) |
2172 | remoteClient.AgentId, | ||
2173 | deleteGroups)) | ||
2174 | { | 2247 | { |
2175 | permissionToTake = true; | 2248 | remoteClient.SendAlertMessage("You don't have permission to take the object"); |
2176 | permissionToDelete = true; | 2249 | return; |
2250 | } | ||
2251 | |||
2252 | permissionToTake = true; | ||
2253 | // Don't delete | ||
2254 | permissionToDelete = false; | ||
2255 | } | ||
2177 | 2256 | ||
2178 | foreach (SceneObjectGroup g in deleteGroups) | 2257 | if (action == DeRezAction.Return) |
2258 | { | ||
2259 | if (remoteClient != null) | ||
2260 | { | ||
2261 | if (Permissions.CanReturnObjects( | ||
2262 | null, | ||
2263 | remoteClient.AgentId, | ||
2264 | new List<SceneObjectGroup>() {grp})) | ||
2179 | { | 2265 | { |
2180 | AddReturn(g.OwnerID == g.GroupID ? g.LastOwnerID : g.OwnerID, g.Name, g.AbsolutePosition, "parcel owner return"); | 2266 | permissionToTake = true; |
2267 | permissionToDelete = true; | ||
2268 | |||
2269 | AddReturn(grp.OwnerID == grp.GroupID ? grp.LastOwnerID : grp.OwnerID, grp.Name, grp.AbsolutePosition, "parcel owner return"); | ||
2181 | } | 2270 | } |
2182 | } | 2271 | } |
2272 | else // Auto return passes through here with null agent | ||
2273 | { | ||
2274 | permissionToTake = true; | ||
2275 | permissionToDelete = true; | ||
2276 | } | ||
2183 | } | 2277 | } |
2184 | else // Auto return passes through here with null agent | 2278 | |
2279 | if (permissionToTake && (!permissionToDelete)) | ||
2280 | takeGroups.Add(grp); | ||
2281 | |||
2282 | if (permissionToDelete) | ||
2185 | { | 2283 | { |
2186 | permissionToTake = true; | 2284 | if (permissionToTake) |
2187 | permissionToDelete = true; | 2285 | deleteGroups.Add(grp); |
2286 | deleteIDs.Add(grp.LocalId); | ||
2188 | } | 2287 | } |
2189 | } | 2288 | } |
2190 | 2289 | ||
2290 | <<<<<<< HEAD | ||
2191 | // OK, we're done with permissions. Let's check if any part of the code prevents the objects from being deleted | 2291 | // OK, we're done with permissions. Let's check if any part of the code prevents the objects from being deleted |
2192 | bool canDelete = EventManager.TriggerDeRezRequested(remoteClient, deleteGroups, action); | 2292 | bool canDelete = EventManager.TriggerDeRezRequested(remoteClient, deleteGroups, action); |
2193 | 2293 | ||
2194 | if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) | 2294 | if (permissionToTake && (action != DeRezAction.Delete || this.m_useTrashOnDelete)) |
2295 | ======= | ||
2296 | SendKillObject(deleteIDs); | ||
2297 | |||
2298 | if (deleteGroups.Count > 0) | ||
2299 | >>>>>>> avn/ubitvar | ||
2195 | { | 2300 | { |
2301 | foreach (SceneObjectGroup g in deleteGroups) | ||
2302 | deleteIDs.Remove(g.LocalId); | ||
2303 | |||
2196 | m_asyncSceneObjectDeleter.DeleteToInventory( | 2304 | m_asyncSceneObjectDeleter.DeleteToInventory( |
2197 | action, destinationID, deleteGroups, remoteClient, | 2305 | action, destinationID, deleteGroups, remoteClient, |
2306 | <<<<<<< HEAD | ||
2198 | permissionToDelete && canDelete); | 2307 | permissionToDelete && canDelete); |
2199 | } | 2308 | } |
2200 | else if (permissionToDelete && canDelete) | 2309 | else if (permissionToDelete && canDelete) |
2310 | ======= | ||
2311 | true); | ||
2312 | } | ||
2313 | if (takeGroups.Count > 0) | ||
2314 | { | ||
2315 | m_asyncSceneObjectDeleter.DeleteToInventory( | ||
2316 | action, destinationID, takeGroups, remoteClient, | ||
2317 | false); | ||
2318 | } | ||
2319 | if (deleteIDs.Count > 0) | ||
2320 | >>>>>>> avn/ubitvar | ||
2201 | { | 2321 | { |
2202 | foreach (SceneObjectGroup g in deleteGroups) | 2322 | foreach (SceneObjectGroup g in deleteGroups) |
2203 | DeleteSceneObject(g, false); | 2323 | DeleteSceneObject(g, true); |
2204 | } | 2324 | } |
2205 | } | 2325 | } |
2206 | 2326 | ||
2327 | public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) | ||
2328 | { | ||
2329 | itemID = UUID.Zero; | ||
2330 | if (grp != null) | ||
2331 | { | ||
2332 | Vector3 inventoryStoredPosition = new Vector3( | ||
2333 | Math.Min(grp.AbsolutePosition.X, RegionInfo.RegionSizeX - 6), | ||
2334 | Math.Min(grp.AbsolutePosition.Y, RegionInfo.RegionSizeY - 6), | ||
2335 | grp.AbsolutePosition.Z); | ||
2336 | |||
2337 | Vector3 originalPosition = grp.AbsolutePosition; | ||
2338 | |||
2339 | grp.AbsolutePosition = inventoryStoredPosition; | ||
2340 | |||
2341 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | ||
2342 | |||
2343 | grp.AbsolutePosition = originalPosition; | ||
2344 | |||
2345 | AssetBase asset = CreateAsset( | ||
2346 | grp.GetPartName(grp.LocalId), | ||
2347 | grp.GetPartDescription(grp.LocalId), | ||
2348 | (sbyte)AssetType.Object, | ||
2349 | Utils.StringToBytes(sceneObjectXml), | ||
2350 | remoteClient.AgentId); | ||
2351 | AssetService.Store(asset); | ||
2352 | |||
2353 | InventoryItemBase item = new InventoryItemBase(); | ||
2354 | item.CreatorId = grp.RootPart.CreatorID.ToString(); | ||
2355 | item.CreatorData = grp.RootPart.CreatorData; | ||
2356 | item.Owner = remoteClient.AgentId; | ||
2357 | item.ID = UUID.Random(); | ||
2358 | item.AssetID = asset.FullID; | ||
2359 | item.Description = asset.Description; | ||
2360 | item.Name = asset.Name; | ||
2361 | item.AssetType = asset.Type; | ||
2362 | item.InvType = (int)InventoryType.Object; | ||
2363 | |||
2364 | InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); | ||
2365 | if (folder != null) | ||
2366 | item.Folder = folder.ID; | ||
2367 | else // oopsies | ||
2368 | item.Folder = UUID.Zero; | ||
2369 | |||
2370 | // Set up base perms properly | ||
2371 | uint permsBase = (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify); | ||
2372 | permsBase &= grp.RootPart.BaseMask; | ||
2373 | permsBase |= (uint)PermissionMask.Move; | ||
2374 | |||
2375 | // Make sure we don't lock it | ||
2376 | grp.RootPart.NextOwnerMask |= (uint)PermissionMask.Move; | ||
2377 | |||
2378 | if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
2379 | { | ||
2380 | item.BasePermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2381 | item.CurrentPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2382 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2383 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; | ||
2384 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; | ||
2385 | } | ||
2386 | else | ||
2387 | { | ||
2388 | item.BasePermissions = permsBase; | ||
2389 | item.CurrentPermissions = permsBase & grp.RootPart.OwnerMask; | ||
2390 | item.NextPermissions = permsBase & grp.RootPart.NextOwnerMask; | ||
2391 | item.EveryOnePermissions = permsBase & grp.RootPart.EveryoneMask; | ||
2392 | item.GroupPermissions = permsBase & grp.RootPart.GroupMask; | ||
2393 | } | ||
2394 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
2395 | |||
2396 | // sets itemID so client can show item as 'attached' in inventory | ||
2397 | grp.FromItemID = item.ID; | ||
2398 | |||
2399 | if (AddInventoryItem(item)) | ||
2400 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
2401 | else | ||
2402 | m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); | ||
2403 | |||
2404 | itemID = item.ID; | ||
2405 | return item.AssetID; | ||
2406 | } | ||
2407 | return UUID.Zero; | ||
2408 | } | ||
2409 | |||
2207 | /// <summary> | 2410 | /// <summary> |
2208 | /// Returns the list of Scene Objects in an asset. | 2411 | /// Returns the list of Scene Objects in an asset. |
2209 | /// </summary> | 2412 | /// </summary> |
@@ -2232,10 +2435,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
2232 | 2435 | ||
2233 | string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(assetData)); | 2436 | string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(assetData)); |
2234 | 2437 | ||
2438 | <<<<<<< HEAD | ||
2235 | try | 2439 | try |
2440 | ======= | ||
2441 | if (e == null || attachment) // Single | ||
2442 | { | ||
2443 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
2444 | /* | ||
2445 | if (!attachment) | ||
2446 | { | ||
2447 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
2448 | g.RootPart.AttachedPos = g.AbsolutePosition; | ||
2449 | g.RootPart.AttachRotation = g.GroupRotation; | ||
2450 | if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && | ||
2451 | g.RootPart.Shape.PCode != (byte)PCode.Tree) | ||
2452 | g.RootPart.Shape.State = 0; | ||
2453 | } | ||
2454 | */ | ||
2455 | objlist.Add(g); | ||
2456 | veclist.Add(new Vector3(0, 0, 0)); | ||
2457 | bbox = g.GetAxisAlignedBoundingBox(out offsetHeight); | ||
2458 | return true; | ||
2459 | } | ||
2460 | else | ||
2461 | >>>>>>> avn/ubitvar | ||
2236 | { | 2462 | { |
2237 | using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) | 2463 | using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null)) |
2238 | { | 2464 | { |
2465 | <<<<<<< HEAD | ||
2239 | using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment })) | 2466 | using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment })) |
2240 | { | 2467 | { |
2241 | reader.Read(); | 2468 | reader.Read(); |
@@ -2299,6 +2526,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2299 | return false; | 2526 | return false; |
2300 | } | 2527 | } |
2301 | } | 2528 | } |
2529 | ======= | ||
2530 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); | ||
2531 | /* | ||
2532 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
2533 | g.RootPart.AttachedPos = g.AbsolutePosition; | ||
2534 | g.RootPart.AttachRotation = g.GroupRotation; | ||
2535 | if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && | ||
2536 | g.RootPart.Shape.PCode != (byte)PCode.Tree) | ||
2537 | g.RootPart.Shape.State = 0; | ||
2538 | */ | ||
2539 | objlist.Add(g); | ||
2540 | |||
2541 | XmlElement el = (XmlElement)n; | ||
2542 | string rawX = el.GetAttribute("offsetx"); | ||
2543 | string rawY = el.GetAttribute("offsety"); | ||
2544 | string rawZ = el.GetAttribute("offsetz"); | ||
2545 | |||
2546 | float x = Convert.ToSingle(rawX); | ||
2547 | float y = Convert.ToSingle(rawY); | ||
2548 | float z = Convert.ToSingle(rawZ); | ||
2549 | veclist.Add(new Vector3(x, y, z)); | ||
2550 | >>>>>>> avn/ubitvar | ||
2302 | } | 2551 | } |
2303 | } | 2552 | } |
2304 | catch (Exception e) | 2553 | catch (Exception e) |
@@ -2371,7 +2620,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2371 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | 2620 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, |
2372 | BypassRayCast, bRayEndIsIntersection, true, scale, false); | 2621 | BypassRayCast, bRayEndIsIntersection, true, scale, false); |
2373 | 2622 | ||
2374 | RezObject(part, item, pos, null, Vector3.Zero, 0); | 2623 | RezObject(part, item, pos, null, Vector3.Zero, 0, false); |
2375 | } | 2624 | } |
2376 | } | 2625 | } |
2377 | 2626 | ||
@@ -2387,15 +2636,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2387 | /// <param name="param"></param> | 2636 | /// <param name="param"></param> |
2388 | /// <returns>The SceneObjectGroup(s) rezzed, or null if rez was unsuccessful</returns> | 2637 | /// <returns>The SceneObjectGroup(s) rezzed, or null if rez was unsuccessful</returns> |
2389 | public virtual List<SceneObjectGroup> RezObject( | 2638 | public virtual List<SceneObjectGroup> RezObject( |
2390 | SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param) | 2639 | SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param, bool atRoot) |
2391 | { | 2640 | { |
2392 | if (null == item) | 2641 | if (null == item) |
2393 | return null; | 2642 | return null; |
2394 | 2643 | ||
2395 | List<SceneObjectGroup> objlist; | 2644 | List<SceneObjectGroup> objlist; |
2396 | List<Vector3> veclist; | 2645 | List<Vector3> veclist; |
2397 | 2646 | Vector3 bbox; | |
2398 | bool success = sourcePart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist); | 2647 | float offsetHeight; |
2648 | |||
2649 | bool success = sourcePart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist,out bbox, out offsetHeight); | ||
2650 | |||
2399 | if (!success) | 2651 | if (!success) |
2400 | return null; | 2652 | return null; |
2401 | 2653 | ||
@@ -2412,10 +2664,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
2412 | sourcePart.Inventory.RemoveInventoryItem(item.ItemID); | 2664 | sourcePart.Inventory.RemoveInventoryItem(item.ItemID); |
2413 | } | 2665 | } |
2414 | 2666 | ||
2667 | SceneObjectGroup sog; | ||
2668 | |||
2669 | bool fixrot = false; | ||
2670 | Quaternion netRot = Quaternion.Identity; | ||
2671 | |||
2672 | // position adjust | ||
2673 | if (totalPrims > 1) // nothing to do on a single prim | ||
2674 | { | ||
2675 | if (objlist.Count == 1) | ||
2676 | { | ||
2677 | // current object position is root position | ||
2678 | if(!atRoot) | ||
2679 | { | ||
2680 | sog = objlist[0]; | ||
2681 | Quaternion orot; | ||
2682 | if (rot == null) | ||
2683 | orot = sog.RootPart.GetWorldRotation(); | ||
2684 | else | ||
2685 | orot = rot.Value; | ||
2686 | // possible should be bbox, but geometric center looks better | ||
2687 | Vector3 off = sog.GetGeometricCenter(); | ||
2688 | // Vector3 off = bbox * 0.5f; | ||
2689 | off *= orot; | ||
2690 | pos -= off; | ||
2691 | } | ||
2692 | } | ||
2693 | else | ||
2694 | { | ||
2695 | //veclist[] are relative to bbox corner with min X,Y and Z | ||
2696 | // rez at root, and rot will be referenced to first object in list | ||
2697 | if (rot == null) | ||
2698 | { | ||
2699 | // use original rotations | ||
2700 | if (atRoot) | ||
2701 | pos -= veclist[0]; | ||
2702 | else | ||
2703 | pos -= bbox / 2; | ||
2704 | } | ||
2705 | else | ||
2706 | { | ||
2707 | fixrot = true; | ||
2708 | sog = objlist[0]; | ||
2709 | netRot = Quaternion.Conjugate(sog.RootPart.GetWorldRotation()); | ||
2710 | netRot = netRot * rot.Value; | ||
2711 | Vector3 off; | ||
2712 | if (atRoot) | ||
2713 | off = veclist[0]; | ||
2714 | else | ||
2715 | off = bbox / 2; | ||
2716 | off *= netRot; | ||
2717 | pos -= off; | ||
2718 | } | ||
2719 | } | ||
2720 | } | ||
2721 | |||
2415 | for (int i = 0; i < objlist.Count; i++) | 2722 | for (int i = 0; i < objlist.Count; i++) |
2416 | { | 2723 | { |
2417 | SceneObjectGroup group = objlist[i]; | 2724 | SceneObjectGroup group = objlist[i]; |
2418 | Vector3 curpos = pos + veclist[i]; | 2725 | Vector3 curpos; |
2726 | if(fixrot) | ||
2727 | curpos = pos + veclist[i] * netRot; | ||
2728 | else | ||
2729 | curpos = pos + veclist[i]; | ||
2419 | 2730 | ||
2420 | if (group.IsAttachment == false && group.RootPart.Shape.State != 0) | 2731 | if (group.IsAttachment == false && group.RootPart.Shape.State != 0) |
2421 | { | 2732 | { |
@@ -2424,7 +2735,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2424 | } | 2735 | } |
2425 | 2736 | ||
2426 | group.FromPartID = sourcePart.UUID; | 2737 | group.FromPartID = sourcePart.UUID; |
2427 | AddNewSceneObject(group, true, curpos, rot, vel); | 2738 | if( i == 0) |
2739 | AddNewSceneObject(group, true, curpos, rot, vel); | ||
2740 | else | ||
2741 | { | ||
2742 | Quaternion crot = objlist[i].RootPart.GetWorldRotation(); | ||
2743 | if (fixrot) | ||
2744 | { | ||
2745 | crot *= netRot; | ||
2746 | } | ||
2747 | AddNewSceneObject(group, true, curpos, crot, vel); | ||
2748 | } | ||
2428 | 2749 | ||
2429 | // We can only call this after adding the scene object, since the scene object references the scene | 2750 | // We can only call this after adding the scene object, since the scene object references the scene |
2430 | // to find out if scripts should be activated at all. | 2751 | // to find out if scripts should be activated at all. |
@@ -2455,6 +2776,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2455 | 2776 | ||
2456 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) | 2777 | public void SetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID, bool running) |
2457 | { | 2778 | { |
2779 | if (!Permissions.CanEditScript(itemID, objectID, controllingClient.AgentId)) | ||
2780 | return; | ||
2781 | |||
2458 | SceneObjectPart part = GetSceneObjectPart(objectID); | 2782 | SceneObjectPart part = GetSceneObjectPart(objectID); |
2459 | if (part == null) | 2783 | if (part == null) |
2460 | return; | 2784 | return; |
@@ -2511,7 +2835,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2511 | } | 2835 | } |
2512 | else | 2836 | else |
2513 | { | 2837 | { |
2514 | if (!Permissions.CanEditObject(sog.UUID, remoteClient.AgentId)) | 2838 | if (!Permissions.IsGod(remoteClient.AgentId) && sog.OwnerID != remoteClient.AgentId) |
2839 | continue; | ||
2840 | |||
2841 | if (!Permissions.CanTransferObject(sog.UUID, groupID)) | ||
2515 | continue; | 2842 | continue; |
2516 | 2843 | ||
2517 | if (sog.GroupID != groupID) | 2844 | if (sog.GroupID != groupID) |
@@ -2622,7 +2949,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2622 | return; | 2949 | return; |
2623 | } | 2950 | } |
2624 | 2951 | ||
2952 | bool oldUsePhysics = (root.Flags & PrimFlags.Physics) != 0; | ||
2625 | m_sceneGraph.LinkObjects(root, children); | 2953 | m_sceneGraph.LinkObjects(root, children); |
2954 | |||
2955 | ScenePresence sp; | ||
2956 | if (TryGetScenePresence(agentId, out sp)) | ||
2957 | { | ||
2958 | root.SendPropertiesToClient(sp.ControllingClient); | ||
2959 | if (oldUsePhysics && (root.Flags & PrimFlags.Physics) == 0) | ||
2960 | { | ||
2961 | sp.ControllingClient.SendAlertMessage("Object physics canceled"); | ||
2962 | } | ||
2963 | } | ||
2626 | } | 2964 | } |
2627 | 2965 | ||
2628 | private string PermissionString(uint permissions) | 2966 | private string PermissionString(uint permissions) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index ef2125b..3d9c028 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 | /// | 136 | /// |
@@ -179,27 +167,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
179 | /// <param name="remoteClient"></param> | 167 | /// <param name="remoteClient"></param> |
180 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) | 168 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) |
181 | { | 169 | { |
170 | /* | ||
171 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | ||
172 | |||
173 | if (null == part) | ||
174 | return; | ||
175 | |||
176 | if (part.IsRoot) | ||
177 | { | ||
178 | SceneObjectGroup sog = part.ParentGroup; | ||
179 | sog.SendPropertiesToClient(remoteClient); | ||
180 | |||
181 | // A prim is only tainted if it's allowed to be edited by the person clicking it. | ||
182 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) | ||
183 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) | ||
184 | { | ||
185 | sog.IsSelected = true; | ||
186 | EventManager.TriggerParcelPrimCountTainted(); | ||
187 | } | ||
188 | } | ||
189 | else | ||
190 | { | ||
191 | part.SendPropertiesToClient(remoteClient); | ||
192 | } | ||
193 | */ | ||
182 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | 194 | SceneObjectPart part = GetSceneObjectPart(primLocalID); |
183 | 195 | ||
184 | if (null == part) | 196 | if (null == part) |
185 | return; | 197 | return; |
186 | 198 | ||
187 | if (part.IsRoot) | 199 | SceneObjectGroup sog = part.ParentGroup; |
188 | { | 200 | if (sog == null) |
189 | SceneObjectGroup sog = part.ParentGroup; | 201 | return; |
190 | sog.SendPropertiesToClient(remoteClient); | ||
191 | sog.IsSelected = true; | ||
192 | 202 | ||
193 | // A prim is only tainted if it's allowed to be edited by the person clicking it. | 203 | part.SendPropertiesToClient(remoteClient); |
194 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) | 204 | |
195 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) | 205 | // A prim is only tainted if it's allowed to be edited by the person clicking it. |
196 | { | 206 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) |
197 | EventManager.TriggerParcelPrimCountTainted(); | 207 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) |
198 | } | ||
199 | } | ||
200 | else | ||
201 | { | 208 | { |
202 | part.SendPropertiesToClient(remoteClient); | 209 | part.IsSelected = true; |
210 | EventManager.TriggerParcelPrimCountTainted(); | ||
203 | } | 211 | } |
204 | } | 212 | } |
205 | 213 | ||
@@ -252,7 +260,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
252 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | 260 | SceneObjectPart part = GetSceneObjectPart(primLocalID); |
253 | if (part == null) | 261 | if (part == null) |
254 | return; | 262 | return; |
255 | 263 | /* | |
256 | // A deselect packet contains all the local prims being deselected. However, since selection is still | 264 | // A deselect packet contains all the local prims being deselected. However, since selection is still |
257 | // group based we only want the root prim to trigger a full update - otherwise on objects with many prims | 265 | // group based we only want the root prim to trigger a full update - otherwise on objects with many prims |
258 | // we end up sending many duplicate ObjectUpdates | 266 | // we end up sending many duplicate ObjectUpdates |
@@ -263,7 +271,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
263 | // handled by group, but by prim. Legacy cruft. | 271 | // handled by group, but by prim. Legacy cruft. |
264 | // TODO: Make selection flagging per prim! | 272 | // TODO: Make selection flagging per prim! |
265 | // | 273 | // |
266 | part.ParentGroup.IsSelected = false; | 274 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) |
275 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
276 | part.ParentGroup.IsSelected = false; | ||
267 | 277 | ||
268 | part.ParentGroup.ScheduleGroupForFullUpdate(); | 278 | part.ParentGroup.ScheduleGroupForFullUpdate(); |
269 | 279 | ||
@@ -280,6 +290,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
280 | part.UUID, remoteClient.AgentId)) | 290 | part.UUID, remoteClient.AgentId)) |
281 | EventManager.TriggerParcelPrimCountTainted(); | 291 | EventManager.TriggerParcelPrimCountTainted(); |
282 | } | 292 | } |
293 | */ | ||
294 | |||
295 | bool oldgprSelect = part.ParentGroup.IsSelected; | ||
296 | |||
297 | // This is wrong, wrong, wrong. Selection should not be | ||
298 | // handled by group, but by prim. Legacy cruft. | ||
299 | // TODO: Make selection flagging per prim! | ||
300 | // | ||
301 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) | ||
302 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
303 | { | ||
304 | part.IsSelected = false; | ||
305 | if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) | ||
306 | EventManager.TriggerParcelPrimCountTainted(); | ||
307 | } | ||
308 | |||
309 | // restore targetOmega | ||
310 | if (part.AngularVelocity != Vector3.Zero) | ||
311 | part.ScheduleTerseUpdate(); | ||
312 | |||
283 | } | 313 | } |
284 | 314 | ||
285 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, | 315 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, |
@@ -434,12 +464,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
434 | } | 464 | } |
435 | }); | 465 | }); |
436 | } | 466 | } |
437 | 467 | ||
438 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) | 468 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) |
439 | { | 469 | { |
440 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; | 470 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; |
441 | } | 471 | } |
442 | 472 | ||
473 | private class DescendentsRequestData | ||
474 | { | ||
475 | public IClientAPI RemoteClient; | ||
476 | public UUID FolderID; | ||
477 | public UUID OwnerID; | ||
478 | public bool FetchFolders; | ||
479 | public bool FetchItems; | ||
480 | public int SortOrder; | ||
481 | } | ||
482 | |||
483 | private Queue<DescendentsRequestData> m_descendentsRequestQueue = new Queue<DescendentsRequestData>(); | ||
484 | private Object m_descendentsRequestLock = new Object(); | ||
485 | private bool m_descendentsRequestProcessing = false; | ||
486 | |||
443 | /// <summary> | 487 | /// <summary> |
444 | /// Tell the client about the various child items and folders contained in the requested folder. | 488 | /// Tell the client about the various child items and folders contained in the requested folder. |
445 | /// </summary> | 489 | /// </summary> |
@@ -476,17 +520,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
476 | } | 520 | } |
477 | } | 521 | } |
478 | 522 | ||
479 | // We're going to send the reply async, because there may be | 523 | lock (m_descendentsRequestLock) |
480 | // an enormous quantity of packets -- basically the entire inventory! | 524 | { |
481 | // We don't want to block the client thread while all that is happening. | 525 | if (!m_descendentsRequestProcessing) |
482 | SendInventoryDelegate d = SendInventoryAsync; | 526 | { |
483 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | 527 | m_descendentsRequestProcessing = true; |
528 | |||
529 | // We're going to send the reply async, because there may be | ||
530 | // an enormous quantity of packets -- basically the entire inventory! | ||
531 | // We don't want to block the client thread while all that is happening. | ||
532 | SendInventoryDelegate d = SendInventoryAsync; | ||
533 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | ||
534 | |||
535 | return; | ||
536 | } | ||
537 | |||
538 | DescendentsRequestData req = new DescendentsRequestData(); | ||
539 | req.RemoteClient = remoteClient; | ||
540 | req.FolderID = folderID; | ||
541 | req.OwnerID = ownerID; | ||
542 | req.FetchFolders = fetchFolders; | ||
543 | req.FetchItems = fetchItems; | ||
544 | req.SortOrder = sortOrder; | ||
545 | |||
546 | m_descendentsRequestQueue.Enqueue(req); | ||
547 | } | ||
484 | } | 548 | } |
485 | 549 | ||
486 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); | 550 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); |
487 | 551 | ||
488 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) | 552 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) |
489 | { | 553 | { |
554 | <<<<<<< HEAD | ||
490 | try | 555 | try |
491 | { | 556 | { |
492 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); | 557 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); |
@@ -497,12 +562,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
497 | string.Format( | 562 | string.Format( |
498 | "[AGENT INVENTORY]: Error in SendInventoryAsync() for {0} with folder ID {1}. Exception ", e)); | 563 | "[AGENT INVENTORY]: Error in SendInventoryAsync() for {0} with folder ID {1}. Exception ", e)); |
499 | } | 564 | } |
565 | ======= | ||
566 | Thread.Sleep(20); | ||
567 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); | ||
568 | >>>>>>> avn/ubitvar | ||
500 | } | 569 | } |
501 | 570 | ||
502 | void SendInventoryComplete(IAsyncResult iar) | 571 | void SendInventoryComplete(IAsyncResult iar) |
503 | { | 572 | { |
504 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; | 573 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; |
505 | d.EndInvoke(iar); | 574 | d.EndInvoke(iar); |
575 | |||
576 | lock (m_descendentsRequestLock) | ||
577 | { | ||
578 | if (m_descendentsRequestQueue.Count > 0) | ||
579 | { | ||
580 | DescendentsRequestData req = m_descendentsRequestQueue.Dequeue(); | ||
581 | |||
582 | d = SendInventoryAsync; | ||
583 | d.BeginInvoke(req.RemoteClient, req.FolderID, req.OwnerID, req.FetchFolders, req.FetchItems, req.SortOrder, SendInventoryComplete, d); | ||
584 | |||
585 | return; | ||
586 | } | ||
587 | |||
588 | m_descendentsRequestProcessing = false; | ||
589 | } | ||
506 | } | 590 | } |
507 | 591 | ||
508 | /// <summary> | 592 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index 535d87a..4d90726 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | |||
@@ -70,7 +70,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
70 | public delegate bool IsGridGodHandler(UUID user, Scene requestFromScene); | 70 | public delegate bool IsGridGodHandler(UUID user, Scene requestFromScene); |
71 | public delegate bool IsAdministratorHandler(UUID user); | 71 | public delegate bool IsAdministratorHandler(UUID user); |
72 | public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); | 72 | public delegate bool EditParcelHandler(UUID user, ILandObject parcel, Scene scene); |
73 | public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene); | 73 | public delegate bool EditParcelPropertiesHandler(UUID user, ILandObject parcel, GroupPowers p, Scene scene, bool allowManager); |
74 | public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); | 74 | public delegate bool SellParcelHandler(UUID user, ILandObject parcel, Scene scene); |
75 | public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); | 75 | public delegate bool AbandonParcelHandler(UUID user, ILandObject parcel, Scene scene); |
76 | public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene); | 76 | public delegate bool ReclaimParcelHandler(UUID user, ILandObject parcel, Scene scene); |
@@ -763,7 +763,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
763 | 763 | ||
764 | #region EDIT PARCEL | 764 | #region EDIT PARCEL |
765 | 765 | ||
766 | public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p) | 766 | public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers p, bool allowManager) |
767 | { | 767 | { |
768 | EditParcelPropertiesHandler handler = OnEditParcelProperties; | 768 | EditParcelPropertiesHandler handler = OnEditParcelProperties; |
769 | if (handler != null) | 769 | if (handler != null) |
@@ -771,7 +771,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
771 | Delegate[] list = handler.GetInvocationList(); | 771 | Delegate[] list = handler.GetInvocationList(); |
772 | foreach (EditParcelPropertiesHandler h in list) | 772 | foreach (EditParcelPropertiesHandler h in list) |
773 | { | 773 | { |
774 | if (h(user, parcel, p, m_scene) == false) | 774 | if (h(user, parcel, p, m_scene, allowManager) == false) |
775 | return false; | 775 | return false; |
776 | } | 776 | } |
777 | } | 777 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fe99ae5..deb8d39 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -105,9 +105,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
105 | /// <summary> | 105 | /// <summary> |
106 | /// If false then physical objects are disabled, though collisions will continue as normal. | 106 | /// If false then physical objects are disabled, though collisions will continue as normal. |
107 | /// </summary> | 107 | /// </summary> |
108 | <<<<<<< HEAD | ||
108 | public bool PhysicsEnabled | 109 | public bool PhysicsEnabled |
109 | { | 110 | { |
110 | get | 111 | get |
112 | ======= | ||
113 | public bool PhysicsEnabled | ||
114 | { | ||
115 | get | ||
116 | >>>>>>> avn/ubitvar | ||
111 | { | 117 | { |
112 | return m_physicsEnabled; | 118 | return m_physicsEnabled; |
113 | } | 119 | } |
@@ -228,9 +234,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
228 | public bool m_allowScriptCrossings = true; | 234 | public bool m_allowScriptCrossings = true; |
229 | 235 | ||
230 | /// <summary> | 236 | /// <summary> |
237 | <<<<<<< HEAD | ||
231 | /// Can avatars cross from and to this region? | 238 | /// Can avatars cross from and to this region? |
232 | /// </summary> | 239 | /// </summary> |
233 | public bool AllowAvatarCrossing { get; set; } | 240 | public bool AllowAvatarCrossing { get; set; } |
241 | ======= | ||
242 | /// Max prims an Physical object will hold | ||
243 | /// </summary> | ||
244 | /// | ||
245 | public int m_linksetPhysCapacity = 0; | ||
246 | >>>>>>> avn/ubitvar | ||
234 | 247 | ||
235 | public bool m_useFlySlow; | 248 | public bool m_useFlySlow; |
236 | public bool m_useTrashOnDelete = true; | 249 | public bool m_useTrashOnDelete = true; |
@@ -281,14 +294,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
281 | } | 294 | } |
282 | } | 295 | } |
283 | 296 | ||
297 | protected float m_maxDrawDistance = 512.0f; | ||
298 | // protected float m_maxDrawDistance = 256.0f; | ||
299 | public float MaxDrawDistance | ||
300 | { | ||
301 | get { return m_maxDrawDistance; } | ||
302 | } | ||
303 | |||
284 | private List<string> m_AllowedViewers = new List<string>(); | 304 | private List<string> m_AllowedViewers = new List<string>(); |
285 | private List<string> m_BannedViewers = new List<string>(); | 305 | private List<string> m_BannedViewers = new List<string>(); |
286 | 306 | ||
287 | // TODO: need to figure out how allow client agents but deny | 307 | // TODO: need to figure out how allow client agents but deny |
288 | // root agents when ACL denies access to root agent | 308 | // root agents when ACL denies access to root agent |
289 | public bool m_strictAccessControl = true; | 309 | public bool m_strictAccessControl = true; |
290 | 310 | public bool m_seeIntoBannedRegion = false; | |
291 | public int MaxUndoCount { get; set; } | 311 | public int MaxUndoCount = 5; |
292 | 312 | ||
293 | public bool SeeIntoRegion { get; set; } | 313 | public bool SeeIntoRegion { get; set; } |
294 | 314 | ||
@@ -306,11 +326,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
306 | 326 | ||
307 | protected int m_splitRegionID; | 327 | protected int m_splitRegionID; |
308 | protected Timer m_restartWaitTimer = new Timer(); | 328 | protected Timer m_restartWaitTimer = new Timer(); |
329 | protected Timer m_timerWatchdog = new Timer(); | ||
309 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 330 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
310 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 331 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
311 | protected string m_simulatorVersion = "OpenSimulator Server"; | 332 | protected string m_simulatorVersion = "OpenSimulator Server"; |
312 | protected AgentCircuitManager m_authenticateHandler; | 333 | protected AgentCircuitManager m_authenticateHandler; |
313 | protected SceneCommunicationService m_sceneGridService; | 334 | protected SceneCommunicationService m_sceneGridService; |
335 | protected ISnmpModule m_snmpService = null; | ||
314 | 336 | ||
315 | protected ISimulationDataService m_SimulationDataService; | 337 | protected ISimulationDataService m_SimulationDataService; |
316 | protected IEstateDataService m_EstateDataService; | 338 | protected IEstateDataService m_EstateDataService; |
@@ -406,8 +428,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
406 | private int m_update_presences = 1; // Update scene presence movements | 428 | private int m_update_presences = 1; // Update scene presence movements |
407 | private int m_update_events = 1; | 429 | private int m_update_events = 1; |
408 | private int m_update_backup = 200; | 430 | private int m_update_backup = 200; |
431 | <<<<<<< HEAD | ||
409 | private int m_update_terrain = 50; | 432 | private int m_update_terrain = 50; |
410 | // private int m_update_land = 1; | 433 | // private int m_update_land = 1; |
434 | ======= | ||
435 | private int m_update_terrain = 1000; | ||
436 | private int m_update_land = 10; | ||
437 | >>>>>>> avn/ubitvar | ||
411 | private int m_update_coarse_locations = 50; | 438 | private int m_update_coarse_locations = 50; |
412 | private int m_update_temp_cleaning = 180; | 439 | private int m_update_temp_cleaning = 180; |
413 | 440 | ||
@@ -421,7 +448,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
421 | private int backupMS; | 448 | private int backupMS; |
422 | private int terrainMS; | 449 | private int terrainMS; |
423 | private int landMS; | 450 | private int landMS; |
424 | private int spareMS; | ||
425 | 451 | ||
426 | // A temporary configuration flag to enable using FireAndForget to process | 452 | // A temporary configuration flag to enable using FireAndForget to process |
427 | // collisions from the physics engine. There is a problem with collisions | 453 | // collisions from the physics engine. There is a problem with collisions |
@@ -439,6 +465,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
439 | /// </summary> | 465 | /// </summary> |
440 | private int m_lastFrameTick; | 466 | private int m_lastFrameTick; |
441 | 467 | ||
468 | public bool CombineRegions = false; | ||
442 | /// <summary> | 469 | /// <summary> |
443 | /// Tick at which the last maintenance run occurred. | 470 | /// Tick at which the last maintenance run occurred. |
444 | /// </summary> | 471 | /// </summary> |
@@ -470,7 +497,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
470 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing | 497 | private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing |
471 | private volatile bool m_backingup; | 498 | private volatile bool m_backingup; |
472 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); | 499 | private Dictionary<UUID, ReturnInfo> m_returns = new Dictionary<UUID, ReturnInfo>(); |
473 | private Dictionary<UUID, SceneObjectGroup> m_groupsWithTargets = new Dictionary<UUID, SceneObjectGroup>(); | 500 | private Dictionary<UUID, int> m_groupsWithTargets = new Dictionary<UUID, int>(); |
474 | 501 | ||
475 | private string m_defaultScriptEngine; | 502 | private string m_defaultScriptEngine; |
476 | 503 | ||
@@ -485,6 +512,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
485 | /// </summary> | 512 | /// </summary> |
486 | private int m_LastLogin; | 513 | private int m_LastLogin; |
487 | 514 | ||
515 | private int m_lastIncoming; | ||
516 | private int m_lastOutgoing; | ||
517 | private int m_hbRestarts = 0; | ||
518 | |||
519 | |||
488 | /// <summary> | 520 | /// <summary> |
489 | /// Thread that runs the scene loop. | 521 | /// Thread that runs the scene loop. |
490 | /// </summary> | 522 | /// </summary> |
@@ -527,11 +559,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
527 | } | 559 | } |
528 | private volatile bool m_active; | 560 | private volatile bool m_active; |
529 | 561 | ||
562 | <<<<<<< HEAD | ||
530 | /// <summary> | 563 | /// <summary> |
531 | /// If true then updates are running. This may be true for a short period after a scene is de-activated. | 564 | /// If true then updates are running. This may be true for a short period after a scene is de-activated. |
532 | /// </summary> | 565 | /// </summary> |
533 | public bool IsRunning { get { return m_isRunning; } } | 566 | public bool IsRunning { get { return m_isRunning; } } |
534 | private volatile bool m_isRunning; | 567 | private volatile bool m_isRunning; |
568 | ======= | ||
569 | // private int m_lastUpdate; | ||
570 | private bool m_firstHeartbeat = true; | ||
571 | |||
572 | private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; | ||
573 | private bool m_reprioritizationEnabled = true; | ||
574 | private double m_reprioritizationInterval = 5000.0; | ||
575 | private double m_rootReprioritizationDistance = 10.0; | ||
576 | private double m_childReprioritizationDistance = 20.0; | ||
577 | >>>>>>> avn/ubitvar | ||
535 | 578 | ||
536 | private Timer m_mapGenerationTimer = new Timer(); | 579 | private Timer m_mapGenerationTimer = new Timer(); |
537 | private bool m_generateMaptiles; | 580 | private bool m_generateMaptiles; |
@@ -564,6 +607,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
564 | get { return m_sceneGridService; } | 607 | get { return m_sceneGridService; } |
565 | } | 608 | } |
566 | 609 | ||
610 | public ISnmpModule SnmpService | ||
611 | { | ||
612 | get | ||
613 | { | ||
614 | if (m_snmpService == null) | ||
615 | { | ||
616 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
617 | } | ||
618 | |||
619 | return m_snmpService; | ||
620 | } | ||
621 | } | ||
622 | |||
567 | public ISimulationDataService SimulationDataService | 623 | public ISimulationDataService SimulationDataService |
568 | { | 624 | { |
569 | get | 625 | get |
@@ -868,6 +924,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
868 | m_sceneGridService = sceneGridService; | 924 | m_sceneGridService = sceneGridService; |
869 | m_SimulationDataService = simDataService; | 925 | m_SimulationDataService = simDataService; |
870 | m_EstateDataService = estateDataService; | 926 | m_EstateDataService = estateDataService; |
927 | <<<<<<< HEAD | ||
928 | ======= | ||
929 | m_regionHandle = RegionInfo.RegionHandle; | ||
930 | m_lastIncoming = 0; | ||
931 | m_lastOutgoing = 0; | ||
932 | >>>>>>> avn/ubitvar | ||
871 | 933 | ||
872 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 934 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
873 | m_asyncSceneObjectDeleter.Enabled = true; | 935 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -926,6 +988,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
926 | EventManager.OnLandObjectRemoved += | 988 | EventManager.OnLandObjectRemoved += |
927 | new EventManager.LandObjectRemoved(simDataService.RemoveLandObject); | 989 | new EventManager.LandObjectRemoved(simDataService.RemoveLandObject); |
928 | 990 | ||
991 | <<<<<<< HEAD | ||
992 | ======= | ||
993 | m_sceneGraph = new SceneGraph(this); | ||
994 | m_sceneGraph.PhysicsScene = physicsScene; | ||
995 | |||
996 | // If the scene graph has an Unrecoverable error, restart this sim. | ||
997 | // Currently the only thing that causes it to happen is two kinds of specific | ||
998 | // Physics based crashes. | ||
999 | // | ||
1000 | // Out of memory | ||
1001 | // Operating system has killed the plugin | ||
1002 | m_sceneGraph.UnRecoverableError | ||
1003 | += () => | ||
1004 | { | ||
1005 | m_log.ErrorFormat("[SCENE]: Restarting region {0} due to unrecoverable physics crash", Name); | ||
1006 | RestartNow(); | ||
1007 | }; | ||
1008 | |||
1009 | >>>>>>> avn/ubitvar | ||
929 | RegisterDefaultSceneEvents(); | 1010 | RegisterDefaultSceneEvents(); |
930 | 1011 | ||
931 | // XXX: Don't set the public property since we don't want to activate here. This needs to be handled | 1012 | // XXX: Don't set the public property since we don't want to activate here. This needs to be handled |
@@ -947,6 +1028,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
947 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); | 1028 | StartDisabled = startupConfig.GetBoolean("StartDisabled", false); |
948 | 1029 | ||
949 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); | 1030 | m_defaultDrawDistance = startupConfig.GetFloat("DefaultDrawDistance", m_defaultDrawDistance); |
1031 | m_defaultDrawDistance = startupConfig.GetFloat("MaxDrawDistance", m_maxDrawDistance); | ||
950 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); | 1032 | UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup); |
951 | if (!UseBackup) | 1033 | if (!UseBackup) |
952 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); | 1034 | m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName); |
@@ -958,9 +1040,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
958 | 1040 | ||
959 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); | 1041 | MaxUndoCount = startupConfig.GetInt("MaxPrimUndos", 20); |
960 | 1042 | ||
961 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", PhysicalPrims); | 1043 | PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); |
962 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", CollidablePrims); | 1044 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
963 | |||
964 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); | 1045 | m_minNonphys = startupConfig.GetFloat("NonPhysicalPrimMin", m_minNonphys); |
965 | if (RegionInfo.NonphysPrimMin > 0) | 1046 | if (RegionInfo.NonphysPrimMin > 0) |
966 | { | 1047 | { |
@@ -980,11 +1061,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
980 | } | 1061 | } |
981 | 1062 | ||
982 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); | 1063 | m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); |
1064 | |||
983 | if (RegionInfo.PhysPrimMax > 0) | 1065 | if (RegionInfo.PhysPrimMax > 0) |
984 | { | 1066 | { |
985 | m_maxPhys = RegionInfo.PhysPrimMax; | 1067 | m_maxPhys = RegionInfo.PhysPrimMax; |
986 | } | 1068 | } |
987 | 1069 | ||
1070 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | ||
1071 | if (RegionInfo.LinksetCapacity > 0) | ||
1072 | { | ||
1073 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
1074 | } | ||
1075 | |||
1076 | m_linksetPhysCapacity = startupConfig.GetInt("LinksetPhysPrims", m_linksetPhysCapacity); | ||
1077 | |||
1078 | |||
1079 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
1080 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
1081 | |||
988 | // Here, if clamping is requested in either global or | 1082 | // Here, if clamping is requested in either global or |
989 | // local config, it will be used | 1083 | // local config, it will be used |
990 | // | 1084 | // |
@@ -994,13 +1088,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
994 | m_clampPrimSize = true; | 1088 | m_clampPrimSize = true; |
995 | } | 1089 | } |
996 | 1090 | ||
997 | m_linksetCapacity = startupConfig.GetInt("LinksetPrims", m_linksetCapacity); | 1091 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete",m_useTrashOnDelete); |
998 | if (RegionInfo.LinksetCapacity > 0) | ||
999 | { | ||
1000 | m_linksetCapacity = RegionInfo.LinksetCapacity; | ||
1001 | } | ||
1002 | |||
1003 | m_useTrashOnDelete = startupConfig.GetBoolean("UseTrashOnDelete", m_useTrashOnDelete); | ||
1004 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); | 1092 | m_trustBinaries = startupConfig.GetBoolean("TrustBinaries", m_trustBinaries); |
1005 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); | 1093 | m_allowScriptCrossings = startupConfig.GetBoolean("AllowScriptCrossing", m_allowScriptCrossings); |
1006 | m_dontPersistBefore = | 1094 | m_dontPersistBefore = |
@@ -1011,11 +1099,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1011 | m_persistAfter *= 10000000; | 1099 | m_persistAfter *= 10000000; |
1012 | 1100 | ||
1013 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 1101 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
1014 | 1102 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | |
1015 | SpawnPointRouting = startupConfig.GetString("SpawnPointRouting", "closest"); | ||
1016 | TelehubAllowLandmarks = startupConfig.GetBoolean("TelehubAllowLandmark", false); | ||
1017 | 1103 | ||
1018 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 1104 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
1105 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
1106 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
1019 | 1107 | ||
1020 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; | 1108 | string[] possibleMapConfigSections = new string[] { "Map", "Startup" }; |
1021 | 1109 | ||
@@ -1061,7 +1149,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1061 | 1149 | ||
1062 | if (grant.Length > 0) | 1150 | if (grant.Length > 0) |
1063 | { | 1151 | { |
1064 | foreach (string viewer in grant.Split('|')) | 1152 | foreach (string viewer in grant.Split(',')) |
1065 | { | 1153 | { |
1066 | m_AllowedViewers.Add(viewer.Trim().ToLower()); | 1154 | m_AllowedViewers.Add(viewer.Trim().ToLower()); |
1067 | } | 1155 | } |
@@ -1073,7 +1161,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1073 | 1161 | ||
1074 | if (grant.Length > 0) | 1162 | if (grant.Length > 0) |
1075 | { | 1163 | { |
1076 | foreach (string viewer in grant.Split('|')) | 1164 | foreach (string viewer in grant.Split(',')) |
1077 | { | 1165 | { |
1078 | m_BannedViewers.Add(viewer.Trim().ToLower()); | 1166 | m_BannedViewers.Add(viewer.Trim().ToLower()); |
1079 | } | 1167 | } |
@@ -1191,6 +1279,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1191 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; | 1279 | StatsReporter.OnSendStatsResult += SendSimStatsPackets; |
1192 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; | 1280 | StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats; |
1193 | 1281 | ||
1282 | <<<<<<< HEAD | ||
1283 | ======= | ||
1284 | MainConsole.Instance.Commands.AddCommand("scene", false, "gc collect", "gc collect", "gc collect", "Cause the garbage collector to make a single pass", HandleGcCollect); | ||
1285 | >>>>>>> avn/ubitvar | ||
1194 | } | 1286 | } |
1195 | 1287 | ||
1196 | public Scene(RegionInfo regInfo, PhysicsScene physicsScene) | 1288 | public Scene(RegionInfo regInfo, PhysicsScene physicsScene) |
@@ -1214,13 +1306,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1214 | 1306 | ||
1215 | PhysicalPrims = true; | 1307 | PhysicalPrims = true; |
1216 | CollidablePrims = true; | 1308 | CollidablePrims = true; |
1217 | PhysicsEnabled = true; | 1309 | // this is done above acording to config |
1310 | // PhysicsEnabled = true; | ||
1218 | 1311 | ||
1219 | AllowAvatarCrossing = true; | 1312 | AllowAvatarCrossing = true; |
1220 | 1313 | ||
1221 | PeriodicBackup = true; | 1314 | PeriodicBackup = true; |
1222 | UseBackup = true; | 1315 | UseBackup = true; |
1223 | 1316 | ||
1317 | <<<<<<< HEAD | ||
1224 | IsReprioritizationEnabled = true; | 1318 | IsReprioritizationEnabled = true; |
1225 | UpdatePrioritizationScheme = UpdatePrioritizationSchemes.Time; | 1319 | UpdatePrioritizationScheme = UpdatePrioritizationSchemes.Time; |
1226 | ReprioritizationInterval = 5000; | 1320 | ReprioritizationInterval = 5000; |
@@ -1231,9 +1325,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1231 | RootReprioritizationDistance = 10.0; | 1325 | RootReprioritizationDistance = 10.0; |
1232 | ChildReprioritizationDistance = 20.0; | 1326 | ChildReprioritizationDistance = 20.0; |
1233 | 1327 | ||
1328 | ======= | ||
1329 | >>>>>>> avn/ubitvar | ||
1234 | m_eventManager = new EventManager(); | 1330 | m_eventManager = new EventManager(); |
1235 | 1331 | ||
1236 | m_permissions = new ScenePermissions(this); | 1332 | m_permissions = new ScenePermissions(this); |
1333 | |||
1237 | } | 1334 | } |
1238 | 1335 | ||
1239 | #endregion | 1336 | #endregion |
@@ -1279,6 +1376,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1279 | { | 1376 | { |
1280 | if (RegionInfo.RegionHandle != otherRegion.RegionHandle) | 1377 | if (RegionInfo.RegionHandle != otherRegion.RegionHandle) |
1281 | { | 1378 | { |
1379 | <<<<<<< HEAD | ||
1282 | //// If these are cast to INT because long + negative values + abs returns invalid data | 1380 | //// If these are cast to INT because long + negative values + abs returns invalid data |
1283 | //int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX); | 1381 | //int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX); |
1284 | //int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY); | 1382 | //int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY); |
@@ -1293,6 +1391,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1293 | // RegionInfo.RegionName, otherRegion.RegionName, newRegionX, newRegionY); | 1391 | // RegionInfo.RegionName, otherRegion.RegionName, newRegionX, newRegionY); |
1294 | 1392 | ||
1295 | if (!Util.IsOutsideView(dist, thisRegionX, newRegionX, thisRegionY, newRegionY)) | 1393 | if (!Util.IsOutsideView(dist, thisRegionX, newRegionX, thisRegionY, newRegionY)) |
1394 | ======= | ||
1395 | if (isNeighborRegion(otherRegion)) | ||
1396 | >>>>>>> avn/ubitvar | ||
1296 | { | 1397 | { |
1297 | // Let the grid service module know, so this can be cached | 1398 | // Let the grid service module know, so this can be cached |
1298 | m_eventManager.TriggerOnRegionUp(otherRegion); | 1399 | m_eventManager.TriggerOnRegionUp(otherRegion); |
@@ -1327,6 +1428,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1327 | } | 1428 | } |
1328 | } | 1429 | } |
1329 | 1430 | ||
1431 | public bool isNeighborRegion(GridRegion otherRegion) | ||
1432 | { | ||
1433 | int tmp = otherRegion.RegionLocX - (int)RegionInfo.WorldLocX; ; | ||
1434 | |||
1435 | if (tmp < -otherRegion.RegionSizeX && tmp > RegionInfo.RegionSizeX) | ||
1436 | return false; | ||
1437 | |||
1438 | tmp = otherRegion.RegionLocY - (int)RegionInfo.WorldLocY; | ||
1439 | |||
1440 | if (tmp < -otherRegion.RegionSizeY && tmp > RegionInfo.RegionSizeY) | ||
1441 | return false; | ||
1442 | |||
1443 | return true; | ||
1444 | } | ||
1445 | |||
1330 | public void AddNeighborRegion(RegionInfo region) | 1446 | public void AddNeighborRegion(RegionInfo region) |
1331 | { | 1447 | { |
1332 | lock (m_neighbours) | 1448 | lock (m_neighbours) |
@@ -1458,8 +1574,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1458 | // Stop all client threads. | 1574 | // Stop all client threads. |
1459 | ForEachScenePresence(delegate(ScenePresence avatar) { CloseAgent(avatar.UUID, false); }); | 1575 | ForEachScenePresence(delegate(ScenePresence avatar) { CloseAgent(avatar.UUID, false); }); |
1460 | 1576 | ||
1461 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1577 | m_log.Debug("[SCENE]: TriggerSceneShuttingDown"); |
1462 | EventManager.TriggerSceneShuttingDown(this); | 1578 | EventManager.TriggerSceneShuttingDown(this); |
1579 | |||
1580 | m_log.Debug("[SCENE]: Persisting changed objects"); | ||
1581 | |||
1463 | Backup(false); | 1582 | Backup(false); |
1464 | m_sceneGraph.Close(); | 1583 | m_sceneGraph.Close(); |
1465 | 1584 | ||
@@ -1473,6 +1592,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1473 | // attempt to reference a null or disposed physics scene. | 1592 | // attempt to reference a null or disposed physics scene. |
1474 | if (PhysicsScene != null) | 1593 | if (PhysicsScene != null) |
1475 | { | 1594 | { |
1595 | m_log.Debug("[SCENE]: Dispose Physics"); | ||
1476 | PhysicsScene phys = PhysicsScene; | 1596 | PhysicsScene phys = PhysicsScene; |
1477 | // remove the physics engine from both Scene and SceneGraph | 1597 | // remove the physics engine from both Scene and SceneGraph |
1478 | PhysicsScene = null; | 1598 | PhysicsScene = null; |
@@ -1504,10 +1624,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1504 | // m_log.DebugFormat("[SCENE]: Starting Heartbeat timer for {0}", RegionInfo.RegionName); | 1624 | // m_log.DebugFormat("[SCENE]: Starting Heartbeat timer for {0}", RegionInfo.RegionName); |
1505 | if (m_heartbeatThread != null) | 1625 | if (m_heartbeatThread != null) |
1506 | { | 1626 | { |
1627 | m_hbRestarts++; | ||
1628 | if(m_hbRestarts > 10) | ||
1629 | Environment.Exit(1); | ||
1630 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1631 | |||
1632 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1633 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1634 | //proc.EnableRaisingEvents=false; | ||
1635 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1636 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1637 | //proc.Start(); | ||
1638 | //proc.WaitForExit(); | ||
1639 | //Thread.Sleep(1000); | ||
1640 | //Environment.Exit(1); | ||
1507 | m_heartbeatThread.Abort(); | 1641 | m_heartbeatThread.Abort(); |
1642 | Watchdog.AbortThread(m_heartbeatThread.ManagedThreadId); | ||
1508 | m_heartbeatThread = null; | 1643 | m_heartbeatThread = null; |
1509 | } | 1644 | } |
1510 | 1645 | ||
1646 | // m_sceneGraph.PreparePhysicsSimulation(); | ||
1647 | |||
1648 | |||
1511 | m_heartbeatThread | 1649 | m_heartbeatThread |
1512 | = WorkManager.StartThread( | 1650 | = WorkManager.StartThread( |
1513 | Heartbeat, string.Format("Heartbeat-({0})", RegionInfo.RegionName.Replace(" ", "_")), ThreadPriority.Normal, false, false); | 1651 | Heartbeat, string.Format("Heartbeat-({0})", RegionInfo.RegionName.Replace(" ", "_")), ThreadPriority.Normal, false, false); |
@@ -1687,6 +1825,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1687 | endFrame = Frame + frames; | 1825 | endFrame = Frame + frames; |
1688 | 1826 | ||
1689 | float physicsFPS = 0f; | 1827 | float physicsFPS = 0f; |
1828 | <<<<<<< HEAD | ||
1690 | int previousFrameTick, tmpMS; | 1829 | int previousFrameTick, tmpMS; |
1691 | 1830 | ||
1692 | // These variables will be used to save the precise frame time using the | 1831 | // These variables will be used to save the precise frame time using the |
@@ -1703,22 +1842,42 @@ namespace OpenSim.Region.Framework.Scenes | |||
1703 | // Begin the stopwatch to keep track of the time that the frame | 1842 | // Begin the stopwatch to keep track of the time that the frame |
1704 | // started running to determine how long the frame took to complete | 1843 | // started running to determine how long the frame took to complete |
1705 | totalFrameStopwatch.Start(); | 1844 | totalFrameStopwatch.Start(); |
1845 | ======= | ||
1846 | int tmpMS; | ||
1847 | int previousFrameTick; | ||
1848 | int maintc; | ||
1849 | int sleepMS; | ||
1850 | int framestart; | ||
1851 | >>>>>>> avn/ubitvar | ||
1706 | 1852 | ||
1707 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) | 1853 | while (!m_shuttingDown && ((endFrame == null && Active) || Frame < endFrame)) |
1708 | { | 1854 | { |
1855 | framestart = Util.EnvironmentTickCount(); | ||
1709 | ++Frame; | 1856 | ++Frame; |
1710 | 1857 | ||
1711 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); | 1858 | // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); |
1712 | 1859 | ||
1860 | <<<<<<< HEAD | ||
1713 | agentMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; | 1861 | agentMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; |
1862 | ======= | ||
1863 | agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; | ||
1864 | >>>>>>> avn/ubitvar | ||
1714 | 1865 | ||
1715 | try | 1866 | try |
1716 | { | 1867 | { |
1717 | EventManager.TriggerRegionHeartbeatStart(this); | 1868 | EventManager.TriggerRegionHeartbeatStart(this); |
1718 | 1869 | ||
1719 | // Apply taints in terrain module to terrain in physics scene | 1870 | // Apply taints in terrain module to terrain in physics scene |
1871 | |||
1872 | tmpMS = Util.EnvironmentTickCount(); | ||
1873 | if (Frame % 4 == 0) | ||
1874 | { | ||
1875 | CheckTerrainUpdates(); | ||
1876 | } | ||
1877 | |||
1720 | if (Frame % m_update_terrain == 0) | 1878 | if (Frame % m_update_terrain == 0) |
1721 | { | 1879 | { |
1880 | <<<<<<< HEAD | ||
1722 | // At several points inside the code there was a need to | 1881 | // At several points inside the code there was a need to |
1723 | // create a more precise measurement of time elapsed. | 1882 | // create a more precise measurement of time elapsed. |
1724 | // This led to the addition of variables that have a | 1883 | // This led to the addition of variables that have a |
@@ -1749,6 +1908,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1749 | // feel right modifying the code to that degree at this | 1908 | // feel right modifying the code to that degree at this |
1750 | // point in time, the precise values all begin with the | 1909 | // point in time, the precise values all begin with the |
1751 | // keyword precise | 1910 | // keyword precise |
1911 | ======= | ||
1912 | UpdateTerrain(); | ||
1913 | } | ||
1914 | |||
1915 | terrainMS = Util.EnvironmentTickCountSubtract(tmpMS); | ||
1916 | >>>>>>> avn/ubitvar | ||
1752 | 1917 | ||
1753 | tmpMS = Util.EnvironmentTickCount(); | 1918 | tmpMS = Util.EnvironmentTickCount(); |
1754 | 1919 | ||
@@ -1816,6 +1981,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1816 | 1981 | ||
1817 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); | 1982 | agentMS += Util.EnvironmentTickCountSubtract(tmpMS); |
1818 | 1983 | ||
1984 | <<<<<<< HEAD | ||
1985 | ======= | ||
1986 | |||
1987 | // Delete temp-on-rez stuff | ||
1988 | if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) | ||
1989 | { | ||
1990 | tmpMS = Util.EnvironmentTickCount(); | ||
1991 | m_cleaningTemps = true; | ||
1992 | Util.FireAndForget(delegate { CleanTempObjects(); m_cleaningTemps = false; }); | ||
1993 | tempOnRezMS = Util.EnvironmentTickCountSubtract(tmpMS); | ||
1994 | } | ||
1995 | |||
1996 | >>>>>>> avn/ubitvar | ||
1819 | if (Frame % m_update_events == 0) | 1997 | if (Frame % m_update_events == 0) |
1820 | { | 1998 | { |
1821 | tmpMS = Util.EnvironmentTickCount(); | 1999 | tmpMS = Util.EnvironmentTickCount(); |
@@ -1891,6 +2069,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1891 | preciseSimFrameTime += | 2069 | preciseSimFrameTime += |
1892 | simFrameStopwatch.Elapsed.TotalMilliseconds; | 2070 | simFrameStopwatch.Elapsed.TotalMilliseconds; |
1893 | 2071 | ||
2072 | <<<<<<< HEAD | ||
1894 | if (!UpdateOnTimer) | 2073 | if (!UpdateOnTimer) |
1895 | { | 2074 | { |
1896 | Watchdog.UpdateThread(); | 2075 | Watchdog.UpdateThread(); |
@@ -1918,13 +2097,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
1918 | previousFrameTick = m_lastFrameTick; | 2097 | previousFrameTick = m_lastFrameTick; |
1919 | frameMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick); | 2098 | frameMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick); |
1920 | m_lastFrameTick = Util.EnvironmentTickCount(); | 2099 | m_lastFrameTick = Util.EnvironmentTickCount(); |
2100 | ======= | ||
2101 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | ||
1921 | 2102 | ||
1922 | // if (Frame%m_update_avatars == 0) | ||
1923 | // UpdateInWorldTime(); | ||
1924 | StatsReporter.AddPhysicsFPS(physicsFPS); | 2103 | StatsReporter.AddPhysicsFPS(physicsFPS); |
1925 | StatsReporter.AddTimeDilation(TimeDilation); | 2104 | StatsReporter.AddTimeDilation(TimeDilation); |
1926 | StatsReporter.AddFPS(1); | 2105 | StatsReporter.AddFPS(1); |
1927 | 2106 | ||
2107 | StatsReporter.addAgentMS(agentMS); | ||
2108 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | ||
2109 | StatsReporter.addOtherMS(otherMS); | ||
2110 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | ||
2111 | |||
2112 | previousFrameTick = m_lastFrameTick; | ||
2113 | m_lastFrameTick = Util.EnvironmentTickCount(); | ||
2114 | tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); | ||
2115 | tmpMS = (int)(MinFrameTime * 1000) - tmpMS; | ||
2116 | |||
2117 | m_firstHeartbeat = false; | ||
2118 | |||
2119 | sleepMS = Util.EnvironmentTickCount(); | ||
2120 | |||
2121 | if (tmpMS > 0) | ||
2122 | Thread.Sleep(tmpMS); | ||
2123 | |||
2124 | sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); | ||
2125 | frameMS = Util.EnvironmentTickCountSubtract(framestart); | ||
2126 | StatsReporter.addSleepMS(sleepMS); | ||
2127 | StatsReporter.addFrameMS(frameMS); | ||
2128 | >>>>>>> avn/ubitvar | ||
2129 | |||
2130 | // if (Frame%m_update_avatars == 0) | ||
2131 | // UpdateInWorldTime(); | ||
2132 | |||
2133 | <<<<<<< HEAD | ||
1928 | StatsReporter.addFrameMS(frameMS); | 2134 | StatsReporter.addFrameMS(frameMS); |
1929 | StatsReporter.addAgentMS(agentMS); | 2135 | StatsReporter.addAgentMS(agentMS); |
1930 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | 2136 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); |
@@ -1932,6 +2138,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1932 | StatsReporter.AddSpareMS(spareMS); | 2138 | StatsReporter.AddSpareMS(spareMS); |
1933 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | 2139 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); |
1934 | StatsReporter.AddScriptMS((int) GetAndResetScriptExecutionTime()); | 2140 | StatsReporter.AddScriptMS((int) GetAndResetScriptExecutionTime()); |
2141 | ======= | ||
2142 | >>>>>>> avn/ubitvar | ||
1935 | 2143 | ||
1936 | // Send the correct time values to the stats reporter for the | 2144 | // Send the correct time values to the stats reporter for the |
1937 | // frame times | 2145 | // frame times |
@@ -1982,7 +2190,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1982 | public void AddGroupTarget(SceneObjectGroup grp) | 2190 | public void AddGroupTarget(SceneObjectGroup grp) |
1983 | { | 2191 | { |
1984 | lock (m_groupsWithTargets) | 2192 | lock (m_groupsWithTargets) |
1985 | m_groupsWithTargets[grp.UUID] = grp; | 2193 | m_groupsWithTargets[grp.UUID] = 0; |
1986 | } | 2194 | } |
1987 | 2195 | ||
1988 | public void RemoveGroupTarget(SceneObjectGroup grp) | 2196 | public void RemoveGroupTarget(SceneObjectGroup grp) |
@@ -1993,18 +2201,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1993 | 2201 | ||
1994 | private void CheckAtTargets() | 2202 | private void CheckAtTargets() |
1995 | { | 2203 | { |
1996 | List<SceneObjectGroup> objs = null; | 2204 | List<UUID> objs = null; |
1997 | 2205 | ||
1998 | lock (m_groupsWithTargets) | 2206 | lock (m_groupsWithTargets) |
1999 | { | 2207 | { |
2000 | if (m_groupsWithTargets.Count != 0) | 2208 | if (m_groupsWithTargets.Count != 0) |
2001 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); | 2209 | objs = new List<UUID>(m_groupsWithTargets.Keys); |
2002 | } | 2210 | } |
2003 | 2211 | ||
2004 | if (objs != null) | 2212 | if (objs != null) |
2005 | { | 2213 | { |
2006 | foreach (SceneObjectGroup entry in objs) | 2214 | foreach (UUID entry in objs) |
2007 | entry.checkAtTargets(); | 2215 | { |
2216 | SceneObjectGroup grp = GetSceneObjectGroup(entry); | ||
2217 | if (grp == null) | ||
2218 | m_groupsWithTargets.Remove(entry); | ||
2219 | else | ||
2220 | grp.checkAtTargets(); | ||
2221 | } | ||
2008 | } | 2222 | } |
2009 | } | 2223 | } |
2010 | 2224 | ||
@@ -2028,6 +2242,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2028 | EventManager.TriggerTerrainTick(); | 2242 | EventManager.TriggerTerrainTick(); |
2029 | } | 2243 | } |
2030 | 2244 | ||
2245 | private void CheckTerrainUpdates() | ||
2246 | { | ||
2247 | EventManager.TriggerTerrainCheckUpdates(); | ||
2248 | } | ||
2249 | |||
2031 | /// <summary> | 2250 | /// <summary> |
2032 | /// Back up queued up changes | 2251 | /// Back up queued up changes |
2033 | /// </summary> | 2252 | /// </summary> |
@@ -2079,7 +2298,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2079 | msg.fromAgentName = "Server"; | 2298 | msg.fromAgentName = "Server"; |
2080 | msg.dialog = (byte)19; // Object msg | 2299 | msg.dialog = (byte)19; // Object msg |
2081 | msg.fromGroup = false; | 2300 | msg.fromGroup = false; |
2082 | msg.offline = (byte)0; | 2301 | msg.offline = (byte)1; |
2083 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 2302 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
2084 | msg.Position = Vector3.Zero; | 2303 | msg.Position = Vector3.Zero; |
2085 | msg.RegionID = RegionInfo.RegionID.Guid; | 2304 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -2315,7 +2534,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2315 | return PhysicsScene.SupportsRaycastWorldFiltered(); | 2534 | return PhysicsScene.SupportsRaycastWorldFiltered(); |
2316 | } | 2535 | } |
2317 | 2536 | ||
2318 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) | 2537 | public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter) |
2319 | { | 2538 | { |
2320 | if (PhysicsScene == null) | 2539 | if (PhysicsScene == null) |
2321 | return null; | 2540 | return null; |
@@ -2337,14 +2556,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2337 | /// <returns></returns> | 2556 | /// <returns></returns> |
2338 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 2557 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
2339 | { | 2558 | { |
2559 | |||
2560 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
2561 | Vector3 wpos = Vector3.Zero; | ||
2562 | // Check for water surface intersection from above | ||
2563 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
2564 | { | ||
2565 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
2566 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
2567 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
2568 | wpos.Z = wheight; | ||
2569 | } | ||
2570 | |||
2340 | Vector3 pos = Vector3.Zero; | 2571 | Vector3 pos = Vector3.Zero; |
2341 | if (RayEndIsIntersection == (byte)1) | 2572 | if (RayEndIsIntersection == (byte)1) |
2342 | { | 2573 | { |
2343 | pos = RayEnd; | 2574 | pos = RayEnd; |
2344 | return pos; | ||
2345 | } | 2575 | } |
2346 | 2576 | else if (RayTargetID != UUID.Zero) | |
2347 | if (RayTargetID != UUID.Zero) | ||
2348 | { | 2577 | { |
2349 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 2578 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
2350 | 2579 | ||
@@ -2389,13 +2618,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2389 | //pos.Z -= 0.25F; | 2618 | //pos.Z -= 0.25F; |
2390 | 2619 | ||
2391 | } | 2620 | } |
2392 | |||
2393 | return pos; | ||
2394 | } | 2621 | } |
2395 | else | 2622 | else |
2396 | { | 2623 | { |
2397 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 2624 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
2398 | |||
2399 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 2625 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
2400 | 2626 | ||
2401 | // Un-comment the following line to print the raytrace results to the console. | 2627 | // Un-comment the following line to print the raytrace results to the console. |
@@ -2403,15 +2629,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2403 | 2629 | ||
2404 | if (ei.HitTF) | 2630 | if (ei.HitTF) |
2405 | { | 2631 | { |
2632 | <<<<<<< HEAD | ||
2406 | pos = ei.ipoint; | 2633 | pos = ei.ipoint; |
2407 | } | 2634 | } |
2635 | ======= | ||
2636 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | ||
2637 | } | ||
2638 | >>>>>>> avn/ubitvar | ||
2408 | else | 2639 | else |
2409 | { | 2640 | { |
2410 | // fall back to our stupid functionality | 2641 | // fall back to our stupid functionality |
2411 | pos = RayEnd; | 2642 | pos = RayEnd; |
2412 | } | 2643 | } |
2413 | |||
2414 | return pos; | ||
2415 | } | 2644 | } |
2416 | } | 2645 | } |
2417 | else | 2646 | else |
@@ -2422,8 +2651,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2422 | //increase height so its above the ground. | 2651 | //increase height so its above the ground. |
2423 | //should be getting the normal of the ground at the rez point and using that? | 2652 | //should be getting the normal of the ground at the rez point and using that? |
2424 | pos.Z += scale.Z / 2f; | 2653 | pos.Z += scale.Z / 2f; |
2425 | return pos; | 2654 | // return pos; |
2426 | } | 2655 | } |
2656 | |||
2657 | // check against posible water intercept | ||
2658 | if (wpos.Z > pos.Z) pos = wpos; | ||
2659 | return pos; | ||
2427 | } | 2660 | } |
2428 | 2661 | ||
2429 | 2662 | ||
@@ -2514,12 +2747,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2514 | { | 2747 | { |
2515 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) | 2748 | if (m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates)) |
2516 | { | 2749 | { |
2750 | sceneObject.IsDeleted = false; | ||
2517 | EventManager.TriggerObjectAddedToScene(sceneObject); | 2751 | EventManager.TriggerObjectAddedToScene(sceneObject); |
2518 | return true; | 2752 | return true; |
2519 | } | 2753 | } |
2520 | 2754 | ||
2521 | return false; | 2755 | return false; |
2522 | |||
2523 | } | 2756 | } |
2524 | 2757 | ||
2525 | /// <summary> | 2758 | /// <summary> |
@@ -2611,6 +2844,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2611 | /// </summary> | 2844 | /// </summary> |
2612 | public void DeleteAllSceneObjects() | 2845 | public void DeleteAllSceneObjects() |
2613 | { | 2846 | { |
2847 | DeleteAllSceneObjects(false); | ||
2848 | } | ||
2849 | |||
2850 | /// <summary> | ||
2851 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2852 | /// </summary> | ||
2853 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2854 | { | ||
2855 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2614 | lock (Entities) | 2856 | lock (Entities) |
2615 | { | 2857 | { |
2616 | EntityBase[] entities = Entities.GetEntities(); | 2858 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2619,11 +2861,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2619 | if (e is SceneObjectGroup) | 2861 | if (e is SceneObjectGroup) |
2620 | { | 2862 | { |
2621 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2863 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2622 | if (!sog.IsAttachment) | 2864 | if (sog != null && !sog.IsAttachment) |
2623 | DeleteSceneObject((SceneObjectGroup)e, false); | 2865 | { |
2866 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2867 | { | ||
2868 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2869 | } | ||
2870 | else | ||
2871 | { | ||
2872 | toReturn.Add((SceneObjectGroup)e); | ||
2873 | } | ||
2874 | } | ||
2624 | } | 2875 | } |
2625 | } | 2876 | } |
2626 | } | 2877 | } |
2878 | if (toReturn.Count > 0) | ||
2879 | { | ||
2880 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2881 | } | ||
2627 | } | 2882 | } |
2628 | 2883 | ||
2629 | /// <summary> | 2884 | /// <summary> |
@@ -2654,6 +2909,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2654 | else | 2909 | else |
2655 | group.StopScriptInstances(); | 2910 | group.StopScriptInstances(); |
2656 | 2911 | ||
2912 | List<UUID> avatars = group.GetSittingAvatars(); | ||
2913 | foreach (UUID av in avatars) | ||
2914 | { | ||
2915 | ScenePresence p = GetScenePresence(av); | ||
2916 | if (p != null && p.ParentUUID == UUID.Zero) | ||
2917 | p.StandUp(); | ||
2918 | } | ||
2919 | |||
2657 | SceneObjectPart[] partList = group.Parts; | 2920 | SceneObjectPart[] partList = group.Parts; |
2658 | 2921 | ||
2659 | foreach (SceneObjectPart part in partList) | 2922 | foreach (SceneObjectPart part in partList) |
@@ -2681,6 +2944,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2681 | } | 2944 | } |
2682 | 2945 | ||
2683 | group.DeleteGroupFromScene(silent); | 2946 | group.DeleteGroupFromScene(silent); |
2947 | if (!silent) | ||
2948 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2684 | 2949 | ||
2685 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2950 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2686 | } | 2951 | } |
@@ -2717,6 +2982,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2717 | return false; | 2982 | return false; |
2718 | } | 2983 | } |
2719 | 2984 | ||
2985 | |||
2986 | public void updateScenePartGroup(SceneObjectPart part, SceneObjectGroup grp) | ||
2987 | { | ||
2988 | m_sceneGraph.updateScenePartGroup(part, grp); | ||
2989 | } | ||
2720 | /// <summary> | 2990 | /// <summary> |
2721 | /// Move the given scene object into a new region depending on which region its absolute position has moved | 2991 | /// Move the given scene object into a new region depending on which region its absolute position has moved |
2722 | /// into. | 2992 | /// into. |
@@ -2743,10 +3013,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
2743 | m_log.Warn("[SCENE]: exception when trying to remove the prim that crossed the border."); | 3013 | m_log.Warn("[SCENE]: exception when trying to remove the prim that crossed the border."); |
2744 | } | 3014 | } |
2745 | return; | 3015 | return; |
3016 | <<<<<<< HEAD | ||
3017 | ======= | ||
3018 | } | ||
3019 | |||
3020 | if (grp.RootPart.RETURN_AT_EDGE) | ||
3021 | { | ||
3022 | // We remove the object here | ||
3023 | try | ||
3024 | { | ||
3025 | List<SceneObjectGroup> objects = new List<SceneObjectGroup>(); | ||
3026 | objects.Add(grp); | ||
3027 | SceneObjectGroup[] objectsArray = objects.ToArray(); | ||
3028 | returnObjects(objectsArray, UUID.Zero); | ||
3029 | } | ||
3030 | catch (Exception) | ||
3031 | { | ||
3032 | m_log.Warn("[SCENE]: exception when trying to return the prim that crossed the border."); | ||
3033 | } | ||
3034 | return; | ||
3035 | } | ||
3036 | |||
3037 | if (EntityTransferModule != null) | ||
3038 | EntityTransferModule.Cross(grp, attemptedPosition, silent); | ||
3039 | } | ||
3040 | |||
3041 | // Simple test to see if a position is in the current region. | ||
3042 | // This test is mostly used to see if a region crossing is necessary. | ||
3043 | // Assuming the position is relative to the region so anything outside its bounds. | ||
3044 | // Return 'true' if position inside region. | ||
3045 | public bool PositionIsInCurrentRegion(Vector3 pos) | ||
3046 | { | ||
3047 | bool ret = false; | ||
3048 | int xx = (int)Math.Floor(pos.X); | ||
3049 | int yy = (int)Math.Floor(pos.Y); | ||
3050 | if (xx < 0 || yy < 0) | ||
3051 | return false; | ||
3052 | |||
3053 | IRegionCombinerModule regionCombinerModule = RequestModuleInterface<IRegionCombinerModule>(); | ||
3054 | if (regionCombinerModule == null) | ||
3055 | { | ||
3056 | // Regular region. Just check for region size | ||
3057 | if (xx < RegionInfo.RegionSizeX && yy < RegionInfo.RegionSizeY ) | ||
3058 | ret = true; | ||
3059 | >>>>>>> avn/ubitvar | ||
2746 | } | 3060 | } |
2747 | 3061 | ||
2748 | if (grp.RootPart.RETURN_AT_EDGE) | 3062 | if (grp.RootPart.RETURN_AT_EDGE) |
2749 | { | 3063 | { |
3064 | <<<<<<< HEAD | ||
2750 | // We remove the object here | 3065 | // We remove the object here |
2751 | try | 3066 | try |
2752 | { | 3067 | { |
@@ -2795,6 +3110,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2795 | 3110 | ||
2796 | } | 3111 | } |
2797 | 3112 | ||
3113 | ======= | ||
3114 | // We're in a mega-region so see if we are still in that larger region | ||
3115 | ret = regionCombinerModule.PositionIsInMegaregion(this.RegionInfo.RegionID, xx, yy); | ||
3116 | } | ||
3117 | |||
3118 | return ret; | ||
3119 | |||
3120 | } | ||
3121 | |||
3122 | >>>>>>> avn/ubitvar | ||
2798 | /// <summary> | 3123 | /// <summary> |
2799 | /// Called when objects or attachments cross the border, or teleport, between regions. | 3124 | /// Called when objects or attachments cross the border, or teleport, between regions. |
2800 | /// </summary> | 3125 | /// </summary> |
@@ -2816,8 +3141,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
2816 | return false; | 3141 | return false; |
2817 | } | 3142 | } |
2818 | 3143 | ||
3144 | <<<<<<< HEAD | ||
2819 | if (!EntityTransferModule.HandleIncomingSceneObject(newObject, newPosition)) | 3145 | if (!EntityTransferModule.HandleIncomingSceneObject(newObject, newPosition)) |
2820 | return false; | 3146 | return false; |
3147 | ======= | ||
3148 | // If the user is banned, we won't let any of their objects | ||
3149 | // enter. Period. | ||
3150 | // | ||
3151 | if (RegionInfo.EstateSettings.IsBanned(newObject.OwnerID, 36)) | ||
3152 | { | ||
3153 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", newObject.OwnerID); | ||
3154 | return false; | ||
3155 | } | ||
3156 | |||
3157 | if (newPosition != Vector3.Zero) | ||
3158 | newObject.RootPart.GroupPosition = newPosition; | ||
3159 | |||
3160 | if (!AddSceneObject(newObject)) | ||
3161 | { | ||
3162 | m_log.DebugFormat( | ||
3163 | "[INTERREGION]: Problem adding scene object {0} in {1} ", newObject.UUID, RegionInfo.RegionName); | ||
3164 | return false; | ||
3165 | } | ||
3166 | |||
3167 | if (!newObject.IsAttachment) | ||
3168 | { | ||
3169 | // FIXME: It would be better to never add the scene object at all rather than add it and then delete | ||
3170 | // it | ||
3171 | if (!Permissions.CanObjectEntry(newObject.UUID, true, newObject.AbsolutePosition)) | ||
3172 | { | ||
3173 | // Deny non attachments based on parcel settings | ||
3174 | // | ||
3175 | m_log.Info("[INTERREGION]: Denied prim crossing because of parcel settings"); | ||
3176 | |||
3177 | DeleteSceneObject(newObject, false); | ||
3178 | |||
3179 | return false; | ||
3180 | } | ||
3181 | |||
3182 | // For attachments, we need to wait until the agent is root | ||
3183 | // before we restart the scripts, or else some functions won't work. | ||
3184 | newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, GetStateSource(newObject)); | ||
3185 | newObject.ResumeScripts(); | ||
3186 | |||
3187 | // AddSceneObject already does this and doing it again messes | ||
3188 | // up region crossings, so don't. | ||
3189 | //if (newObject.RootPart.KeyframeMotion != null) | ||
3190 | // newObject.RootPart.KeyframeMotion.UpdateSceneObject(newObject); | ||
3191 | } | ||
3192 | >>>>>>> avn/ubitvar | ||
2821 | 3193 | ||
2822 | // Do this as late as possible so that listeners have full access to the incoming object | 3194 | // Do this as late as possible so that listeners have full access to the incoming object |
2823 | EventManager.TriggerOnIncomingSceneObject(newObject); | 3195 | EventManager.TriggerOnIncomingSceneObject(newObject); |
@@ -2834,6 +3206,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2834 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 3206 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2835 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 3207 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2836 | { | 3208 | { |
3209 | if (sceneObject.OwnerID == UUID.Zero) | ||
3210 | { | ||
3211 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
3212 | return false; | ||
3213 | } | ||
3214 | |||
3215 | // If the user is banned, we won't let any of their objects | ||
3216 | // enter. Period. | ||
3217 | // | ||
3218 | int flags = GetUserFlags(sceneObject.OwnerID); | ||
3219 | if (RegionInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
3220 | { | ||
3221 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | ||
3222 | |||
3223 | return false; | ||
3224 | } | ||
3225 | |||
2837 | // Force allocation of new LocalId | 3226 | // Force allocation of new LocalId |
2838 | // | 3227 | // |
2839 | SceneObjectPart[] parts = sceneObject.Parts; | 3228 | SceneObjectPart[] parts = sceneObject.Parts; |
@@ -2870,22 +3259,64 @@ namespace OpenSim.Region.Framework.Scenes | |||
2870 | // information that this is due to a teleport/border cross rather than an ordinary attachment. | 3259 | // information that this is due to a teleport/border cross rather than an ordinary attachment. |
2871 | // We currently do this in Scene.MakeRootAgent() instead. | 3260 | // We currently do this in Scene.MakeRootAgent() instead. |
2872 | if (AttachmentsModule != null) | 3261 | if (AttachmentsModule != null) |
2873 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, true); | 3262 | AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true); |
2874 | } | 3263 | } |
2875 | else | 3264 | else |
2876 | { | 3265 | { |
3266 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2877 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 3267 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2878 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 3268 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2879 | } | 3269 | } |
3270 | if (sceneObject.OwnerID == UUID.Zero) | ||
3271 | { | ||
3272 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
3273 | return false; | ||
3274 | } | ||
2880 | } | 3275 | } |
2881 | else | 3276 | else |
2882 | { | 3277 | { |
3278 | if (sceneObject.OwnerID == UUID.Zero) | ||
3279 | { | ||
3280 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
3281 | return false; | ||
3282 | } | ||
2883 | AddRestoredSceneObject(sceneObject, true, false); | 3283 | AddRestoredSceneObject(sceneObject, true, false); |
2884 | } | 3284 | } |
2885 | 3285 | ||
2886 | return true; | 3286 | return true; |
2887 | } | 3287 | } |
2888 | 3288 | ||
3289 | <<<<<<< HEAD | ||
3290 | ======= | ||
3291 | private int GetStateSource(SceneObjectGroup sog) | ||
3292 | { | ||
3293 | ScenePresence sp = GetScenePresence(sog.OwnerID); | ||
3294 | |||
3295 | if (sp != null) | ||
3296 | return sp.GetStateSource(); | ||
3297 | |||
3298 | return 2; // StateSource.PrimCrossing | ||
3299 | } | ||
3300 | |||
3301 | public int GetUserFlags(UUID user) | ||
3302 | { | ||
3303 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
3304 | /* | ||
3305 | ScenePresence sp; | ||
3306 | if (TryGetScenePresence(user, out sp)) | ||
3307 | { | ||
3308 | return sp.UserFlags; | ||
3309 | } | ||
3310 | else | ||
3311 | { | ||
3312 | */ | ||
3313 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
3314 | if (uac == null) | ||
3315 | return 0; | ||
3316 | return uac.UserFlags; | ||
3317 | //} | ||
3318 | } | ||
3319 | >>>>>>> avn/ubitvar | ||
2889 | #endregion | 3320 | #endregion |
2890 | 3321 | ||
2891 | #region Add/Remove Avatar Methods | 3322 | #region Add/Remove Avatar Methods |
@@ -2921,9 +3352,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2921 | vialogin | 3352 | vialogin |
2922 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 | 3353 | = (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0 |
2923 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 3354 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
3355 | <<<<<<< HEAD | ||
2924 | 3356 | ||
2925 | // CheckHeartbeat(); | 3357 | // CheckHeartbeat(); |
2926 | 3358 | ||
3359 | ======= | ||
3360 | |||
3361 | CheckHeartbeat(); | ||
3362 | |||
3363 | >>>>>>> avn/ubitvar | ||
2927 | sp = GetScenePresence(client.AgentId); | 3364 | sp = GetScenePresence(client.AgentId); |
2928 | 3365 | ||
2929 | // XXX: Not sure how good it is to add a new client if a scene presence already exists. Possibly this | 3366 | // XXX: Not sure how good it is to add a new client if a scene presence already exists. Possibly this |
@@ -2933,6 +3370,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2933 | if (sp == null) | 3370 | if (sp == null) |
2934 | { | 3371 | { |
2935 | m_log.DebugFormat( | 3372 | m_log.DebugFormat( |
3373 | <<<<<<< HEAD | ||
2936 | "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}", | 3374 | "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}", |
2937 | client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos); | 3375 | client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos); |
2938 | 3376 | ||
@@ -2954,6 +3392,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
2954 | m_eventManager.TriggerOnNewPresence(sp); | 3392 | m_eventManager.TriggerOnNewPresence(sp); |
2955 | 3393 | ||
2956 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; | 3394 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; |
3395 | ======= | ||
3396 | "[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}, tpflags: {4}", | ||
3397 | client.Name, client.AgentId, RegionInfo.RegionName, client.StartPos, | ||
3398 | ((TPFlags)aCircuit.teleportFlags).ToString()); | ||
3399 | |||
3400 | m_clientManager.Add(client); | ||
3401 | SubscribeToClientEvents(client); | ||
3402 | |||
3403 | sp = m_sceneGraph.CreateAndAddChildScenePresence(client, aCircuit.Appearance, type); | ||
3404 | |||
3405 | sp.TeleportFlags = (TPFlags)aCircuit.teleportFlags; | ||
3406 | |||
3407 | /* done in completMovement | ||
3408 | InventoryFolderBase cof = InventoryService.GetFolderForType(client.AgentId, (AssetType)46); | ||
3409 | if (cof == null) | ||
3410 | sp.COF = UUID.Zero; | ||
3411 | else | ||
3412 | sp.COF = cof.ID; | ||
3413 | |||
3414 | m_log.DebugFormat("[SCENE]: COF for {0} is {1}", client.AgentId, sp.COF); | ||
3415 | */ | ||
3416 | m_eventManager.TriggerOnNewPresence(sp); | ||
3417 | |||
3418 | >>>>>>> avn/ubitvar | ||
2957 | } | 3419 | } |
2958 | else | 3420 | else |
2959 | { | 3421 | { |
@@ -2992,6 +3454,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2992 | return sp; | 3454 | return sp; |
2993 | } | 3455 | } |
2994 | 3456 | ||
3457 | public string GetAgentHomeURI(UUID agentID) | ||
3458 | { | ||
3459 | AgentCircuitData circuit = AuthenticateHandler.GetAgentCircuitData(agentID); | ||
3460 | if (circuit != null && circuit.ServiceURLs != null && circuit.ServiceURLs.ContainsKey("HomeURI")) | ||
3461 | return circuit.ServiceURLs["HomeURI"].ToString(); | ||
3462 | else | ||
3463 | return null; | ||
3464 | } | ||
3465 | |||
2995 | /// <summary> | 3466 | /// <summary> |
2996 | /// Returns the Home URI of the agent, or null if unknown. | 3467 | /// Returns the Home URI of the agent, or null if unknown. |
2997 | /// </summary> | 3468 | /// </summary> |
@@ -3088,19 +3559,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3088 | // and the scene presence and the client, if they exist | 3559 | // and the scene presence and the client, if they exist |
3089 | try | 3560 | try |
3090 | { | 3561 | { |
3091 | // We need to wait for the client to make UDP contact first. | ||
3092 | // It's the UDP contact that creates the scene presence | ||
3093 | ScenePresence sp = WaitGetScenePresence(agentID); | 3562 | ScenePresence sp = WaitGetScenePresence(agentID); |
3563 | |||
3094 | if (sp != null) | 3564 | if (sp != null) |
3095 | { | 3565 | { |
3096 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 3566 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
3097 | 3567 | ||
3098 | CloseAgent(sp.UUID, false); | 3568 | CloseAgent(sp.UUID, false); |
3099 | } | 3569 | } |
3100 | else | 3570 | |
3101 | { | ||
3102 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
3103 | } | ||
3104 | // BANG! SLASH! | 3571 | // BANG! SLASH! |
3105 | m_authenticateHandler.RemoveCircuit(agentID); | 3572 | m_authenticateHandler.RemoveCircuit(agentID); |
3106 | 3573 | ||
@@ -3137,7 +3604,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3137 | 3604 | ||
3138 | public virtual void SubscribeToClientTerrainEvents(IClientAPI client) | 3605 | public virtual void SubscribeToClientTerrainEvents(IClientAPI client) |
3139 | { | 3606 | { |
3140 | client.OnRegionHandShakeReply += SendLayerData; | 3607 | // client.OnRegionHandShakeReply += SendLayerData; |
3141 | } | 3608 | } |
3142 | 3609 | ||
3143 | public virtual void SubscribeToClientPrimEvents(IClientAPI client) | 3610 | public virtual void SubscribeToClientPrimEvents(IClientAPI client) |
@@ -3145,6 +3612,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3145 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; | 3612 | client.OnUpdatePrimGroupPosition += m_sceneGraph.UpdatePrimGroupPosition; |
3146 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; | 3613 | client.OnUpdatePrimSinglePosition += m_sceneGraph.UpdatePrimSinglePosition; |
3147 | 3614 | ||
3615 | client.onClientChangeObject += m_sceneGraph.ClientChangeObject; | ||
3616 | |||
3148 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3617 | client.OnUpdatePrimGroupRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3149 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; | 3618 | client.OnUpdatePrimGroupMouseRotation += m_sceneGraph.UpdatePrimGroupRotation; |
3150 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; | 3619 | client.OnUpdatePrimSingleRotation += m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3201,6 +3670,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3201 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 3670 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
3202 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 3671 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
3203 | client.OnCopyInventoryItem += CopyInventoryItem; | 3672 | client.OnCopyInventoryItem += CopyInventoryItem; |
3673 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
3204 | client.OnMoveInventoryItem += MoveInventoryItem; | 3674 | client.OnMoveInventoryItem += MoveInventoryItem; |
3205 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 3675 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
3206 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 3676 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3262,7 +3732,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3262 | 3732 | ||
3263 | public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) | 3733 | public virtual void UnSubscribeToClientTerrainEvents(IClientAPI client) |
3264 | { | 3734 | { |
3265 | client.OnRegionHandShakeReply -= SendLayerData; | 3735 | // client.OnRegionHandShakeReply -= SendLayerData; |
3266 | } | 3736 | } |
3267 | 3737 | ||
3268 | public virtual void UnSubscribeToClientPrimEvents(IClientAPI client) | 3738 | public virtual void UnSubscribeToClientPrimEvents(IClientAPI client) |
@@ -3270,6 +3740,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3270 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; | 3740 | client.OnUpdatePrimGroupPosition -= m_sceneGraph.UpdatePrimGroupPosition; |
3271 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; | 3741 | client.OnUpdatePrimSinglePosition -= m_sceneGraph.UpdatePrimSinglePosition; |
3272 | 3742 | ||
3743 | client.onClientChangeObject -= m_sceneGraph.ClientChangeObject; | ||
3744 | |||
3273 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3745 | client.OnUpdatePrimGroupRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3274 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; | 3746 | client.OnUpdatePrimGroupMouseRotation -= m_sceneGraph.UpdatePrimGroupRotation; |
3275 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; | 3747 | client.OnUpdatePrimSingleRotation -= m_sceneGraph.UpdatePrimSingleRotation; |
@@ -3518,6 +3990,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3518 | /// <param name='closeChildAgents'> | 3990 | /// <param name='closeChildAgents'> |
3519 | /// Close the neighbour child agents associated with this client. | 3991 | /// Close the neighbour child agents associated with this client. |
3520 | /// </param> | 3992 | /// </param> |
3993 | /// | ||
3994 | |||
3995 | private object m_removeClientPrivLock = new Object(); | ||
3996 | |||
3521 | public void RemoveClient(UUID agentID, bool closeChildAgents) | 3997 | public void RemoveClient(UUID agentID, bool closeChildAgents) |
3522 | { | 3998 | { |
3523 | AgentCircuitData acd = m_authenticateHandler.GetAgentCircuitData(agentID); | 3999 | AgentCircuitData acd = m_authenticateHandler.GetAgentCircuitData(agentID); |
@@ -3534,8 +4010,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3534 | } | 4010 | } |
3535 | 4011 | ||
3536 | // TODO: Can we now remove this lock? | 4012 | // TODO: Can we now remove this lock? |
4013 | <<<<<<< HEAD | ||
3537 | lock (acd) | 4014 | lock (acd) |
3538 | { | 4015 | { |
4016 | ======= | ||
4017 | lock (m_removeClientPrivLock) | ||
4018 | { | ||
4019 | >>>>>>> avn/ubitvar | ||
3539 | bool isChildAgent = false; | 4020 | bool isChildAgent = false; |
3540 | 4021 | ||
3541 | ScenePresence avatar = GetScenePresence(agentID); | 4022 | ScenePresence avatar = GetScenePresence(agentID); |
@@ -3579,8 +4060,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3579 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop | 4060 | // TODO: We shouldn't use closeChildAgents here - it's being used by the NPC module to stop |
3580 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI | 4061 | // unnecessary operations. This should go away once NPCs have no accompanying IClientAPI |
3581 | if (closeChildAgents && CapsModule != null) | 4062 | if (closeChildAgents && CapsModule != null) |
4063 | <<<<<<< HEAD | ||
3582 | CapsModule.RemoveCaps(agentID); | 4064 | CapsModule.RemoveCaps(agentID); |
3583 | 4065 | ||
4066 | ======= | ||
4067 | CapsModule.RemoveCaps(agentID, avatar.ControllingClient.CircuitCode); | ||
4068 | |||
4069 | >>>>>>> avn/ubitvar | ||
3584 | if (closeChildAgents && !isChildAgent) | 4070 | if (closeChildAgents && !isChildAgent) |
3585 | { | 4071 | { |
3586 | List<ulong> regions = avatar.KnownRegionHandles; | 4072 | List<ulong> regions = avatar.KnownRegionHandles; |
@@ -3591,13 +4077,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3591 | } | 4077 | } |
3592 | 4078 | ||
3593 | m_eventManager.TriggerClientClosed(agentID, this); | 4079 | m_eventManager.TriggerClientClosed(agentID, this); |
4080 | // m_log.Debug("[Scene]TriggerClientClosed done"); | ||
3594 | m_eventManager.TriggerOnRemovePresence(agentID); | 4081 | m_eventManager.TriggerOnRemovePresence(agentID); |
4082 | <<<<<<< HEAD | ||
3595 | 4083 | ||
4084 | ======= | ||
4085 | // m_log.Debug("[Scene]TriggerOnRemovePresence done"); | ||
4086 | |||
4087 | >>>>>>> avn/ubitvar | ||
3596 | if (!isChildAgent) | 4088 | if (!isChildAgent) |
3597 | { | 4089 | { |
3598 | if (AttachmentsModule != null) | 4090 | if (AttachmentsModule != null) |
3599 | { | 4091 | { |
4092 | // m_log.Debug("[Scene]DeRezAttachments"); | ||
3600 | AttachmentsModule.DeRezAttachments(avatar); | 4093 | AttachmentsModule.DeRezAttachments(avatar); |
4094 | // m_log.Debug("[Scene]DeRezAttachments done"); | ||
3601 | } | 4095 | } |
3602 | 4096 | ||
3603 | ForEachClient( | 4097 | ForEachClient( |
@@ -3611,7 +4105,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3611 | 4105 | ||
3612 | // It's possible for child agents to have transactions if changes are being made cross-border. | 4106 | // It's possible for child agents to have transactions if changes are being made cross-border. |
3613 | if (AgentTransactionsModule != null) | 4107 | if (AgentTransactionsModule != null) |
4108 | { | ||
4109 | // m_log.Debug("[Scene]RemoveAgentAssetTransactions"); | ||
3614 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); | 4110 | AgentTransactionsModule.RemoveAgentAssetTransactions(agentID); |
4111 | } | ||
4112 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3615 | } | 4113 | } |
3616 | catch (Exception e) | 4114 | catch (Exception e) |
3617 | { | 4115 | { |
@@ -3730,7 +4228,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3730 | /// or other applications where a full grid/Hypergrid presence may not be required.</param> | 4228 | /// or other applications where a full grid/Hypergrid presence may not be required.</param> |
3731 | /// <returns>True if the region accepts this agent. False if it does not. False will | 4229 | /// <returns>True if the region accepts this agent. False if it does not. False will |
3732 | /// also return a reason.</returns> | 4230 | /// also return a reason.</returns> |
4231 | <<<<<<< HEAD | ||
3733 | public bool NewUserConnection(AgentCircuitData acd, uint teleportFlags, GridRegion source, out string reason, bool requirePresenceLookup) | 4232 | public bool NewUserConnection(AgentCircuitData acd, uint teleportFlags, GridRegion source, out string reason, bool requirePresenceLookup) |
4233 | ======= | ||
4234 | /// | ||
4235 | private object m_newUserConnLock = new object(); | ||
4236 | |||
4237 | public bool NewUserConnection(AgentCircuitData acd, uint teleportFlags, out string reason, bool requirePresenceLookup) | ||
4238 | >>>>>>> avn/ubitvar | ||
3734 | { | 4239 | { |
3735 | bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || | 4240 | bool vialogin = ((teleportFlags & (uint)TPFlags.ViaLogin) != 0 || |
3736 | (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0); | 4241 | (teleportFlags & (uint)TPFlags.ViaHGLogin) != 0); |
@@ -3763,6 +4268,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3763 | (source == null) ? "" : string.Format("From region {0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI == null) ? "" : " @ " + source.ServerURI) | 4268 | (source == null) ? "" : string.Format("From region {0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI == null) ? "" : " @ " + source.ServerURI) |
3764 | ); | 4269 | ); |
3765 | 4270 | ||
4271 | // m_log.DebugFormat("NewUserConnection stack {0}", Environment.StackTrace); | ||
4272 | |||
3766 | if (!LoginsEnabled) | 4273 | if (!LoginsEnabled) |
3767 | { | 4274 | { |
3768 | reason = "Logins Disabled"; | 4275 | reason = "Logins Disabled"; |
@@ -3890,7 +4397,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3890 | } | 4397 | } |
3891 | 4398 | ||
3892 | // TODO: can we remove this lock? | 4399 | // TODO: can we remove this lock? |
3893 | lock (acd) | 4400 | lock (m_newUserConnLock) |
3894 | { | 4401 | { |
3895 | if (sp != null && !sp.IsChildAgent) | 4402 | if (sp != null && !sp.IsChildAgent) |
3896 | { | 4403 | { |
@@ -3917,6 +4424,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3917 | // We need the circuit data here for some of the subsequent checks. (groups, for example) | 4424 | // We need the circuit data here for some of the subsequent checks. (groups, for example) |
3918 | // If the checks fail, we remove the circuit. | 4425 | // If the checks fail, we remove the circuit. |
3919 | acd.teleportFlags = teleportFlags; | 4426 | acd.teleportFlags = teleportFlags; |
4427 | |||
4428 | // Remove any preexisting circuit - we don't want duplicates | ||
4429 | // This is a stab at preventing avatar "ghosting" | ||
4430 | if (vialogin) | ||
4431 | m_authenticateHandler.RemoveCircuit(acd.AgentID); | ||
4432 | |||
3920 | m_authenticateHandler.AddNewCircuit(acd.circuitcode, acd); | 4433 | m_authenticateHandler.AddNewCircuit(acd.circuitcode, acd); |
3921 | 4434 | ||
3922 | land = LandChannel.GetLandObject(acd.startpos.X, acd.startpos.Y); | 4435 | land = LandChannel.GetLandObject(acd.startpos.X, acd.startpos.Y); |
@@ -3924,6 +4437,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3924 | // On login test land permisions | 4437 | // On login test land permisions |
3925 | if (vialogin) | 4438 | if (vialogin) |
3926 | { | 4439 | { |
4440 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); | ||
4441 | if (cache != null) | ||
4442 | cache.Remove(acd.firstname + " " + acd.lastname); | ||
3927 | if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y)) | 4443 | if (land != null && !TestLandRestrictions(acd.AgentID, out reason, ref acd.startpos.X, ref acd.startpos.Y)) |
3928 | { | 4444 | { |
3929 | m_authenticateHandler.RemoveCircuit(acd.circuitcode); | 4445 | m_authenticateHandler.RemoveCircuit(acd.circuitcode); |
@@ -3978,7 +4494,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3978 | if (CapsModule != null) | 4494 | if (CapsModule != null) |
3979 | { | 4495 | { |
3980 | CapsModule.SetAgentCapsSeeds(acd); | 4496 | CapsModule.SetAgentCapsSeeds(acd); |
3981 | CapsModule.CreateCaps(acd.AgentID); | 4497 | CapsModule.CreateCaps(acd.AgentID, acd.circuitcode); |
3982 | } | 4498 | } |
3983 | } | 4499 | } |
3984 | else | 4500 | else |
@@ -3991,15 +4507,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3991 | { | 4507 | { |
3992 | m_log.DebugFormat( | 4508 | m_log.DebugFormat( |
3993 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", | 4509 | "[SCENE]: Adjusting known seeds for existing agent {0} in {1}", |
4510 | <<<<<<< HEAD | ||
3994 | acd.AgentID, RegionInfo.RegionName); | 4511 | acd.AgentID, RegionInfo.RegionName); |
3995 | 4512 | ||
3996 | sp.AdjustKnownSeeds(); | 4513 | sp.AdjustKnownSeeds(); |
4514 | ======= | ||
4515 | acd.AgentID, RegionInfo.RegionName); | ||
4516 | >>>>>>> avn/ubitvar | ||
3997 | 4517 | ||
3998 | if (CapsModule != null) | 4518 | if (CapsModule != null) |
3999 | { | 4519 | { |
4000 | CapsModule.SetAgentCapsSeeds(acd); | 4520 | CapsModule.SetAgentCapsSeeds(acd); |
4001 | CapsModule.CreateCaps(acd.AgentID); | 4521 | CapsModule.CreateCaps(acd.AgentID, acd.circuitcode); |
4002 | } | 4522 | } |
4523 | |||
4524 | sp.AdjustKnownSeeds(); | ||
4003 | } | 4525 | } |
4004 | } | 4526 | } |
4005 | 4527 | ||
@@ -4009,6 +4531,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
4009 | CacheUserName(null, acd); | 4531 | CacheUserName(null, acd); |
4010 | } | 4532 | } |
4011 | 4533 | ||
4534 | if (CapsModule != null) | ||
4535 | { | ||
4536 | CapsModule.ActivateCaps(acd.circuitcode); | ||
4537 | } | ||
4538 | |||
4012 | if (vialogin) | 4539 | if (vialogin) |
4013 | { | 4540 | { |
4014 | // CleanDroppedAttachments(); | 4541 | // CleanDroppedAttachments(); |
@@ -4078,6 +4605,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4078 | } | 4605 | } |
4079 | 4606 | ||
4080 | // Honor parcel landing type and position. | 4607 | // Honor parcel landing type and position. |
4608 | /* | ||
4609 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
4081 | if (land != null) | 4610 | if (land != null) |
4082 | { | 4611 | { |
4083 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 4612 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -4092,6 +4621,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4092 | } | 4621 | } |
4093 | } | 4622 | } |
4094 | } | 4623 | } |
4624 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
4095 | } | 4625 | } |
4096 | 4626 | ||
4097 | return true; | 4627 | return true; |
@@ -4116,12 +4646,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
4116 | { | 4646 | { |
4117 | if (posX < 0) | 4647 | if (posX < 0) |
4118 | posX = 0; | 4648 | posX = 0; |
4649 | <<<<<<< HEAD | ||
4119 | else if (posX >= (float)RegionInfo.RegionSizeX) | 4650 | else if (posX >= (float)RegionInfo.RegionSizeX) |
4120 | posX = (float)RegionInfo.RegionSizeX - 0.001f; | 4651 | posX = (float)RegionInfo.RegionSizeX - 0.001f; |
4121 | if (posY < 0) | 4652 | if (posY < 0) |
4122 | posY = 0; | 4653 | posY = 0; |
4123 | else if (posY >= (float)RegionInfo.RegionSizeY) | 4654 | else if (posY >= (float)RegionInfo.RegionSizeY) |
4124 | posY = (float)RegionInfo.RegionSizeY - 0.001f; | 4655 | posY = (float)RegionInfo.RegionSizeY - 0.001f; |
4656 | ======= | ||
4657 | else if (posX >= RegionInfo.RegionSizeX) | ||
4658 | posX = RegionInfo.RegionSizeX - 0.5f; | ||
4659 | if (posY < 0) | ||
4660 | posY = 0; | ||
4661 | else if (posY >= RegionInfo.RegionSizeY) | ||
4662 | posY = RegionInfo.RegionSizeY - 0.5f; | ||
4663 | >>>>>>> avn/ubitvar | ||
4125 | 4664 | ||
4126 | reason = String.Empty; | 4665 | reason = String.Empty; |
4127 | if (Permissions.IsGod(agentID)) | 4666 | if (Permissions.IsGod(agentID)) |
@@ -4225,7 +4764,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4225 | { | 4764 | { |
4226 | if (RegionInfo.EstateSettings != null) | 4765 | if (RegionInfo.EstateSettings != null) |
4227 | { | 4766 | { |
4228 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID)) | 4767 | int flags = GetUserFlags(agent.AgentID); |
4768 | if (RegionInfo.EstateSettings.IsBanned(agent.AgentID, flags)) | ||
4229 | { | 4769 | { |
4230 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 4770 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
4231 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 4771 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -4414,6 +4954,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
4414 | m_log.DebugFormat( | 4954 | m_log.DebugFormat( |
4415 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); | 4955 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); |
4416 | 4956 | ||
4957 | if (!LoginsEnabled) | ||
4958 | { | ||
4959 | // reason = "Logins Disabled"; | ||
4960 | m_log.DebugFormat( | ||
4961 | "[SCENE]: update for {0} in {1} refused: Logins Disabled", cAgentData.AgentID, RegionInfo.RegionName); | ||
4962 | return false; | ||
4963 | } | ||
4964 | // We have to wait until the viewer contacts this region after receiving EAC. | ||
4965 | // That calls AddNewClient, which finally creates the ScenePresence | ||
4966 | int flags = GetUserFlags(cAgentData.AgentID); | ||
4967 | if (RegionInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
4968 | { | ||
4969 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
4970 | return false; | ||
4971 | } | ||
4972 | |||
4417 | // TODO: This check should probably be in QueryAccess(). | 4973 | // TODO: This check should probably be in QueryAccess(). |
4418 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, RegionInfo.RegionSizeX / 2, RegionInfo.RegionSizeY / 2); | 4974 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, RegionInfo.RegionSizeX / 2, RegionInfo.RegionSizeY / 2); |
4419 | if (nearestParcel == null) | 4975 | if (nearestParcel == null) |
@@ -4431,8 +4987,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4431 | // a UseCircuitCode packet which in turn calls AddNewAgent which finally creates the ScenePresence. | 4987 | // a UseCircuitCode packet which in turn calls AddNewAgent which finally creates the ScenePresence. |
4432 | ScenePresence sp = WaitGetScenePresence(cAgentData.AgentID); | 4988 | ScenePresence sp = WaitGetScenePresence(cAgentData.AgentID); |
4433 | 4989 | ||
4434 | if (sp != null) | 4990 | if (sp != null) |
4435 | { | 4991 | { |
4992 | if (!sp.IsChildAgent) | ||
4993 | { | ||
4994 | m_log.WarnFormat("[SCENE]: Ignoring a child update on a root agent {0} {1} in {2}", | ||
4995 | sp.Name, sp.UUID, Name); | ||
4996 | return false; | ||
4997 | } | ||
4436 | if (cAgentData.SessionID != sp.ControllingClient.SessionId) | 4998 | if (cAgentData.SessionID != sp.ControllingClient.SessionId) |
4437 | { | 4999 | { |
4438 | m_log.WarnFormat( | 5000 | m_log.WarnFormat( |
@@ -4517,7 +5079,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4517 | /// <param name='agentID'></param> | 5079 | /// <param name='agentID'></param> |
4518 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) | 5080 | protected virtual ScenePresence WaitGetScenePresence(UUID agentID) |
4519 | { | 5081 | { |
4520 | int ntimes = 20; | 5082 | int ntimes = 30; |
4521 | ScenePresence sp = null; | 5083 | ScenePresence sp = null; |
4522 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) | 5084 | while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0)) |
4523 | Thread.Sleep(1000); | 5085 | Thread.Sleep(1000); |
@@ -4567,6 +5129,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4567 | return false; | 5129 | return false; |
4568 | } | 5130 | } |
4569 | 5131 | ||
5132 | // public bool IncomingCloseAgent(UUID agentID) | ||
5133 | // { | ||
5134 | // return IncomingCloseAgent(agentID, false); | ||
5135 | // } | ||
5136 | |||
5137 | // public bool IncomingCloseChildAgent(UUID agentID) | ||
5138 | // { | ||
5139 | // return IncomingCloseAgent(agentID, true); | ||
5140 | // } | ||
5141 | |||
4570 | /// <summary> | 5142 | /// <summary> |
4571 | /// Tell a single client to prepare to close. | 5143 | /// Tell a single client to prepare to close. |
4572 | /// </summary> | 5144 | /// </summary> |
@@ -4629,6 +5201,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4629 | 5201 | ||
4630 | if (sp == null) | 5202 | if (sp == null) |
4631 | { | 5203 | { |
5204 | // If there is no scene presence, we may be handling a dead | ||
5205 | // client. These can keep an avatar from reentering a region | ||
5206 | // and since they don't get cleaned up they will stick | ||
5207 | // around until region restart. So, if there is no SP, | ||
5208 | // remove the client as well. | ||
5209 | IClientAPI client = null; | ||
5210 | if (m_clientManager.TryGetValue(agentID, out client)) | ||
5211 | { | ||
5212 | m_clientManager.Remove(agentID); | ||
5213 | if (CapsModule != null) | ||
5214 | CapsModule.RemoveCaps(agentID, 0); | ||
5215 | m_log.DebugFormat( "[SCENE]: Dead client for agent ID {0} was cleaned up in {1}", agentID, Name); | ||
5216 | return true; | ||
5217 | } | ||
4632 | m_log.DebugFormat( | 5218 | m_log.DebugFormat( |
4633 | "[SCENE]: Called CloseClient() with agent ID {0} but no such presence is in {1}", | 5219 | "[SCENE]: Called CloseClient() with agent ID {0} but no such presence is in {1}", |
4634 | agentID, Name); | 5220 | agentID, Name); |
@@ -4663,7 +5249,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4663 | sp.LifecycleState = ScenePresenceState.Removing; | 5249 | sp.LifecycleState = ScenePresenceState.Removing; |
4664 | } | 5250 | } |
4665 | 5251 | ||
5252 | <<<<<<< HEAD | ||
4666 | sp.ControllingClient.Close(force); | 5253 | sp.ControllingClient.Close(force); |
5254 | ======= | ||
5255 | if (sp != null) | ||
5256 | { | ||
5257 | sp.ControllingClient.Close(force, force); | ||
5258 | return true; | ||
5259 | } | ||
5260 | >>>>>>> avn/ubitvar | ||
4667 | 5261 | ||
4668 | return true; | 5262 | return true; |
4669 | } | 5263 | } |
@@ -4825,7 +5419,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
4825 | 5419 | ||
4826 | public LandData GetLandData(float x, float y) | 5420 | public LandData GetLandData(float x, float y) |
4827 | { | 5421 | { |
4828 | return LandChannel.GetLandObject(x, y).LandData; | 5422 | ILandObject parcel = LandChannel.GetLandObject(x, y); |
5423 | if (parcel == null) | ||
5424 | return null; | ||
5425 | return parcel.LandData; | ||
4829 | } | 5426 | } |
4830 | 5427 | ||
4831 | /// <summary> | 5428 | /// <summary> |
@@ -4841,7 +5438,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
4841 | public LandData GetLandData(uint x, uint y) | 5438 | public LandData GetLandData(uint x, uint y) |
4842 | { | 5439 | { |
4843 | m_log.DebugFormat("[SCENE]: returning land for {0},{1}", x, y); | 5440 | m_log.DebugFormat("[SCENE]: returning land for {0},{1}", x, y); |
4844 | return LandChannel.GetLandObject((int)x, (int)y).LandData; | 5441 | ILandObject parcel = LandChannel.GetLandObject((int)x, (int)y); |
5442 | if (parcel == null) | ||
5443 | return null; | ||
5444 | return parcel.LandData; | ||
4845 | } | 5445 | } |
4846 | 5446 | ||
4847 | #endregion | 5447 | #endregion |
@@ -5229,7 +5829,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5229 | { | 5829 | { |
5230 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | 5830 | if ((grp.RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) |
5231 | { | 5831 | { |
5232 | if (grp.RootPart.Expires <= DateTime.Now) | 5832 | if (grp.GetSittingAvatarsCount() == 0 && grp.RootPart.Expires <= DateTime.Now) |
5233 | DeleteSceneObject(grp, false); | 5833 | DeleteSceneObject(grp, false); |
5234 | } | 5834 | } |
5235 | } | 5835 | } |
@@ -5243,35 +5843,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
5243 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); | 5843 | SimulationDataService.RemoveObject(uuid, RegionInfo.RegionID); |
5244 | } | 5844 | } |
5245 | 5845 | ||
5246 | public int GetHealth() | 5846 | public int GetHealth(out int flags, out string message) |
5247 | { | 5847 | { |
5248 | // Returns: | 5848 | // Returns: |
5249 | // 1 = sim is up and accepting http requests. The heartbeat has | 5849 | // 1 = sim is up and accepting http requests. The heartbeat has |
5250 | // stopped and the sim is probably locked up, but a remote | 5850 | // stopped and the sim is probably locked up, but a remote |
5251 | // admin restart may succeed | 5851 | // admin restart may succeed |
5252 | // | 5852 | // |
5253 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 5853 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
5254 | // usable for people within and logins _may_ work | 5854 | // usable for people within |
5855 | // | ||
5856 | // 3 = Sim is up and one packet thread is running. Sim is | ||
5857 | // unstable and will not accept new logins | ||
5255 | // | 5858 | // |
5256 | // 3 = We have seen a new user enter within the past 4 minutes | 5859 | // 4 = Sim is up and both packet threads are running. Sim is |
5860 | // likely usable | ||
5861 | // | ||
5862 | // 5 = We have seen a new user enter within the past 4 minutes | ||
5257 | // which can be seen as positive confirmation of sim health | 5863 | // which can be seen as positive confirmation of sim health |
5258 | // | 5864 | // |
5865 | <<<<<<< HEAD | ||
5259 | int health = 1; // Start at 1, means we're up | 5866 | int health = 1; // Start at 1, means we're up |
5867 | ======= | ||
5868 | |||
5869 | flags = 0; | ||
5870 | message = String.Empty; | ||
5871 | |||
5872 | CheckHeartbeat(); | ||
5873 | |||
5874 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
5875 | { | ||
5876 | // We're still starting | ||
5877 | // 0 means "in startup", it can't happen another way, since | ||
5878 | // to get here, we must be able to accept http connections | ||
5879 | return 0; | ||
5880 | } | ||
5881 | |||
5882 | int health=1; // Start at 1, means we're up | ||
5883 | >>>>>>> avn/ubitvar | ||
5260 | 5884 | ||
5261 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) | 5885 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) < 1000) |
5262 | health += 1; | 5886 | { |
5887 | health+=1; | ||
5888 | flags |= 1; | ||
5889 | } | ||
5890 | |||
5891 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
5892 | { | ||
5893 | health+=1; | ||
5894 | flags |= 2; | ||
5895 | } | ||
5896 | |||
5897 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
5898 | { | ||
5899 | health+=1; | ||
5900 | flags |= 4; | ||
5901 | } | ||
5263 | else | 5902 | else |
5903 | { | ||
5904 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
5905 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
5906 | proc.EnableRaisingEvents=false; | ||
5907 | proc.StartInfo.FileName = "/bin/kill"; | ||
5908 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
5909 | proc.Start(); | ||
5910 | proc.WaitForExit(); | ||
5911 | Thread.Sleep(1000); | ||
5912 | Environment.Exit(1); | ||
5913 | } | ||
5914 | |||
5915 | if (flags != 7) | ||
5264 | return health; | 5916 | return health; |
5265 | 5917 | ||
5266 | // A login in the last 4 mins? We can't be doing too badly | 5918 | // A login in the last 4 mins? We can't be doing too badly |
5267 | // | 5919 | // |
5268 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 5920 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
5269 | health++; | 5921 | health++; |
5270 | else | 5922 | else |
5271 | return health; | 5923 | return health; |
5272 | 5924 | ||
5273 | // CheckHeartbeat(); | ||
5274 | |||
5275 | return health; | 5925 | return health; |
5276 | } | 5926 | } |
5277 | 5927 | ||
@@ -5359,7 +6009,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5359 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 6009 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
5360 | if (wasUsingPhysics) | 6010 | if (wasUsingPhysics) |
5361 | { | 6011 | { |
5362 | 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 | 6012 | 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 |
5363 | } | 6013 | } |
5364 | } | 6014 | } |
5365 | 6015 | ||
@@ -5462,14 +6112,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5462 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; | 6112 | return (((vsn.X * xdiff) + (vsn.Y * ydiff)) / (-1 * vsn.Z)) + p0.Z; |
5463 | } | 6113 | } |
5464 | 6114 | ||
5465 | // private void CheckHeartbeat() | 6115 | private void CheckHeartbeat() |
5466 | // { | 6116 | { |
5467 | // if (m_firstHeartbeat) | 6117 | if (m_firstHeartbeat) |
5468 | // return; | 6118 | return; |
5469 | // | 6119 | |
5470 | // if (Util.EnvironmentTickCountSubtract(m_lastFrameTick) > 2000) | 6120 | if ((Util.EnvironmentTickCountSubtract(m_lastFrameTick)) > 5000) |
5471 | // StartTimer(); | 6121 | Start(); |
5472 | // } | 6122 | } |
5473 | 6123 | ||
5474 | public override ISceneObject DeserializeObject(string representation) | 6124 | public override ISceneObject DeserializeObject(string representation) |
5475 | { | 6125 | { |
@@ -5526,8 +6176,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
5526 | //Go to the edge, this happens in teleporting to a region with no available parcels | 6176 | //Go to the edge, this happens in teleporting to a region with no available parcels |
5527 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); | 6177 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); |
5528 | 6178 | ||
6179 | <<<<<<< HEAD | ||
5529 | //m_log.Debug("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); | 6180 | //m_log.Debug("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); |
5530 | 6181 | ||
6182 | ======= | ||
6183 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); | ||
6184 | |||
6185 | >>>>>>> avn/ubitvar | ||
5531 | return nearestRegionEdgePoint; | 6186 | return nearestRegionEdgePoint; |
5532 | } | 6187 | } |
5533 | 6188 | ||
@@ -5783,7 +6438,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5783 | mapModule.GenerateMaptile(); | 6438 | mapModule.GenerateMaptile(); |
5784 | } | 6439 | } |
5785 | 6440 | ||
5786 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 6441 | // public void CleanDroppedAttachments() |
6442 | // { | ||
6443 | // List<SceneObjectGroup> objectsToDelete = | ||
6444 | // new List<SceneObjectGroup>(); | ||
6445 | // | ||
6446 | // lock (m_cleaningAttachments) | ||
6447 | // { | ||
6448 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
6449 | // { | ||
6450 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
6451 | // { | ||
6452 | // UUID agentID = grp.OwnerID; | ||
6453 | // if (agentID == UUID.Zero) | ||
6454 | // { | ||
6455 | // objectsToDelete.Add(grp); | ||
6456 | // return; | ||
6457 | // } | ||
6458 | // | ||
6459 | // ScenePresence sp = GetScenePresence(agentID); | ||
6460 | // if (sp == null) | ||
6461 | // { | ||
6462 | // objectsToDelete.Add(grp); | ||
6463 | // return; | ||
6464 | // } | ||
6465 | // } | ||
6466 | // }); | ||
6467 | // } | ||
6468 | // | ||
6469 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
6470 | // { | ||
6471 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
6472 | // DeleteSceneObject(grp, true); | ||
6473 | // } | ||
6474 | // } | ||
6475 | |||
6476 | public void ThreadAlive(int threadCode) | ||
6477 | { | ||
6478 | switch(threadCode) | ||
6479 | { | ||
6480 | case 1: // Incoming | ||
6481 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
6482 | break; | ||
6483 | case 2: // Incoming | ||
6484 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
6485 | break; | ||
6486 | } | ||
6487 | } | ||
6488 | |||
6489 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5787 | { | 6490 | { |
5788 | RegenerateMaptile(); | 6491 | RegenerateMaptile(); |
5789 | 6492 | ||
@@ -5810,7 +6513,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
5810 | /// <param name='position'></param> | 6513 | /// <param name='position'></param> |
5811 | /// <param name='reason'></param> | 6514 | /// <param name='reason'></param> |
5812 | /// <returns></returns> | 6515 | /// <returns></returns> |
6516 | <<<<<<< HEAD | ||
5813 | public bool QueryAccess(UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List<UUID> features, out string reason) | 6517 | public bool QueryAccess(UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List<UUID> features, out string reason) |
6518 | ======= | ||
6519 | public bool QueryAccess(UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, out string reason) | ||
6520 | >>>>>>> avn/ubitvar | ||
5814 | { | 6521 | { |
5815 | reason = string.Empty; | 6522 | reason = string.Empty; |
5816 | 6523 | ||
@@ -5820,8 +6527,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5820 | return true; | 6527 | return true; |
5821 | } | 6528 | } |
5822 | 6529 | ||
6530 | <<<<<<< HEAD | ||
5823 | if (!AllowAvatarCrossing && !viaTeleport) | 6531 | if (!AllowAvatarCrossing && !viaTeleport) |
5824 | return false; | 6532 | return false; |
6533 | ======= | ||
6534 | |||
6535 | // if (!AllowAvatarCrossing && !viaTeleport) | ||
6536 | // return false; | ||
6537 | >>>>>>> avn/ubitvar | ||
5825 | 6538 | ||
5826 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. | 6539 | // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. |
5827 | // However, the long term fix is to make sure root agent count is always accurate. | 6540 | // However, the long term fix is to make sure root agent count is always accurate. |
@@ -5949,7 +6662,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
5949 | return true; | 6662 | return true; |
5950 | } | 6663 | } |
5951 | 6664 | ||
5952 | /// <summary> | 6665 | public void StartTimerWatchdog() |
6666 | { | ||
6667 | m_timerWatchdog.Interval = 1000; | ||
6668 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
6669 | m_timerWatchdog.AutoReset = true; | ||
6670 | m_timerWatchdog.Start(); | ||
6671 | } | ||
6672 | |||
6673 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
6674 | { | ||
6675 | CheckHeartbeat(); | ||
6676 | } | ||
6677 | |||
5953 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 6678 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5954 | /// autopilot that moves an avatar to a sit target!. | 6679 | /// autopilot that moves an avatar to a sit target!. |
5955 | /// </summary> | 6680 | /// </summary> |
@@ -6028,6 +6753,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
6028 | return m_SpawnPoint - 1; | 6753 | return m_SpawnPoint - 1; |
6029 | } | 6754 | } |
6030 | 6755 | ||
6756 | private void HandleGcCollect(string module, string[] args) | ||
6757 | { | ||
6758 | GC.Collect(); | ||
6759 | } | ||
6760 | |||
6031 | /// <summary> | 6761 | /// <summary> |
6032 | /// Wrappers to get physics modules retrieve assets. | 6762 | /// Wrappers to get physics modules retrieve assets. |
6033 | /// </summary> | 6763 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 7ff3d40..c4671f0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -1,3 +1,4 @@ | |||
1 | <<<<<<< HEAD | ||
1 | /* | 2 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 3 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 4 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
@@ -634,3 +635,603 @@ namespace OpenSim.Region.Framework.Scenes | |||
634 | public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); | 635 | public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); |
635 | } | 636 | } |
636 | } | 637 | } |
638 | ======= | ||
639 | /* | ||
640 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
641 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
642 | * | ||
643 | * Redistribution and use in source and binary forms, with or without | ||
644 | * modification, are permitted provided that the following conditions are met: | ||
645 | * * Redistributions of source code must retain the above copyright | ||
646 | * notice, this list of conditions and the following disclaimer. | ||
647 | * * Redistributions in binary form must reproduce the above copyright | ||
648 | * notice, this list of conditions and the following disclaimer in the | ||
649 | * documentation and/or other materials provided with the distribution. | ||
650 | * * Neither the name of the OpenSimulator Project nor the | ||
651 | * names of its contributors may be used to endorse or promote products | ||
652 | * derived from this software without specific prior written permission. | ||
653 | * | ||
654 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
655 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
656 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
657 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
658 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
659 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
660 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
661 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
662 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
663 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
664 | */ | ||
665 | |||
666 | using System; | ||
667 | using System.Collections.Generic; | ||
668 | using System.Reflection; | ||
669 | using System.Threading; | ||
670 | using OpenMetaverse; | ||
671 | using log4net; | ||
672 | using Nini.Config; | ||
673 | using OpenSim.Framework; | ||
674 | using OpenSim.Framework.Console; | ||
675 | |||
676 | using OpenSim.Region.Framework.Interfaces; | ||
677 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
678 | |||
679 | namespace OpenSim.Region.Framework.Scenes | ||
680 | { | ||
681 | public abstract class SceneBase : IScene | ||
682 | { | ||
683 | protected static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
684 | protected static readonly string LogHeader = "[SCENE]"; | ||
685 | |||
686 | #region Events | ||
687 | |||
688 | public event restart OnRestart; | ||
689 | |||
690 | #endregion | ||
691 | |||
692 | #region Fields | ||
693 | |||
694 | public string Name { get { return RegionInfo.RegionName; } } | ||
695 | |||
696 | public IConfigSource Config | ||
697 | { | ||
698 | get { return GetConfig(); } | ||
699 | } | ||
700 | |||
701 | protected virtual IConfigSource GetConfig() | ||
702 | { | ||
703 | return null; | ||
704 | } | ||
705 | |||
706 | /// <value> | ||
707 | /// All the region modules attached to this scene. | ||
708 | /// </value> | ||
709 | public Dictionary<string, IRegionModuleBase> RegionModules | ||
710 | { | ||
711 | get { return m_regionModules; } | ||
712 | } | ||
713 | private Dictionary<string, IRegionModuleBase> m_regionModules = new Dictionary<string, IRegionModuleBase>(); | ||
714 | |||
715 | /// <value> | ||
716 | /// The module interfaces available from this scene. | ||
717 | /// </value> | ||
718 | protected Dictionary<Type, List<object>> ModuleInterfaces = new Dictionary<Type, List<object>>(); | ||
719 | |||
720 | protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>(); | ||
721 | |||
722 | /// <value> | ||
723 | /// The module commanders available from this scene | ||
724 | /// </value> | ||
725 | protected Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>(); | ||
726 | |||
727 | /// <value> | ||
728 | /// Registered classes that are capable of creating entities. | ||
729 | /// </value> | ||
730 | protected Dictionary<PCode, IEntityCreator> m_entityCreators = new Dictionary<PCode, IEntityCreator>(); | ||
731 | |||
732 | /// <summary> | ||
733 | /// The last allocated local prim id. When a new local id is requested, the next number in the sequence is | ||
734 | /// dispensed. | ||
735 | /// </summary> | ||
736 | protected uint m_lastAllocatedLocalId = 720000; | ||
737 | |||
738 | private readonly Mutex _primAllocateMutex = new Mutex(false); | ||
739 | |||
740 | protected readonly ClientManager m_clientManager = new ClientManager(); | ||
741 | |||
742 | public bool LoginsEnabled | ||
743 | { | ||
744 | get | ||
745 | { | ||
746 | return m_loginsEnabled; | ||
747 | } | ||
748 | |||
749 | set | ||
750 | { | ||
751 | if (m_loginsEnabled != value) | ||
752 | { | ||
753 | m_loginsEnabled = value; | ||
754 | EventManager.TriggerRegionLoginsStatusChange(this); | ||
755 | } | ||
756 | } | ||
757 | } | ||
758 | private bool m_loginsEnabled; | ||
759 | |||
760 | public bool Ready | ||
761 | { | ||
762 | get | ||
763 | { | ||
764 | return m_ready; | ||
765 | } | ||
766 | |||
767 | set | ||
768 | { | ||
769 | if (m_ready != value) | ||
770 | { | ||
771 | m_ready = value; | ||
772 | EventManager.TriggerRegionReadyStatusChange(this); | ||
773 | } | ||
774 | } | ||
775 | } | ||
776 | private bool m_ready; | ||
777 | |||
778 | public float TimeDilation | ||
779 | { | ||
780 | get { return 1.0f; } | ||
781 | } | ||
782 | |||
783 | protected ulong m_regionHandle; | ||
784 | protected string m_regionName; | ||
785 | |||
786 | public ITerrainChannel Heightmap; | ||
787 | |||
788 | /// <value> | ||
789 | /// Allows retrieval of land information for this scene. | ||
790 | /// </value> | ||
791 | public ILandChannel LandChannel; | ||
792 | |||
793 | /// <value> | ||
794 | /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules | ||
795 | /// to subscribe to scene events. | ||
796 | /// </value> | ||
797 | public EventManager EventManager | ||
798 | { | ||
799 | get { return m_eventManager; } | ||
800 | } | ||
801 | protected EventManager m_eventManager; | ||
802 | |||
803 | protected ScenePermissions m_permissions; | ||
804 | public ScenePermissions Permissions | ||
805 | { | ||
806 | get { return m_permissions; } | ||
807 | } | ||
808 | |||
809 | protected string m_datastore; | ||
810 | |||
811 | /* Used by the loadbalancer plugin on GForge */ | ||
812 | protected RegionStatus m_regStatus; | ||
813 | public RegionStatus RegionStatus | ||
814 | { | ||
815 | get { return m_regStatus; } | ||
816 | set { m_regStatus = value; } | ||
817 | } | ||
818 | |||
819 | #endregion | ||
820 | |||
821 | public SceneBase(RegionInfo regInfo) | ||
822 | { | ||
823 | RegionInfo = regInfo; | ||
824 | } | ||
825 | |||
826 | #region Update Methods | ||
827 | |||
828 | /// <summary> | ||
829 | /// Called to update the scene loop by a number of frames and until shutdown. | ||
830 | /// </summary> | ||
831 | /// <param name="frames"> | ||
832 | /// Number of frames to update. Exits on shutdown even if there are frames remaining. | ||
833 | /// If -1 then updates until shutdown. | ||
834 | /// </param> | ||
835 | public abstract void Update(int frames); | ||
836 | |||
837 | #endregion | ||
838 | |||
839 | #region Terrain Methods | ||
840 | |||
841 | /// <summary> | ||
842 | /// Loads the World heightmap | ||
843 | /// </summary> | ||
844 | public abstract void LoadWorldMap(); | ||
845 | |||
846 | /// <summary> | ||
847 | /// Send the region heightmap to the client | ||
848 | /// </summary> | ||
849 | /// <param name="RemoteClient">Client to send to</param> | ||
850 | public virtual void SendLayerData(IClientAPI RemoteClient) | ||
851 | { | ||
852 | // RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); | ||
853 | ITerrainModule terrModule = RequestModuleInterface<ITerrainModule>(); | ||
854 | if (terrModule != null) | ||
855 | { | ||
856 | terrModule.PushTerrain(RemoteClient); | ||
857 | } | ||
858 | } | ||
859 | |||
860 | #endregion | ||
861 | |||
862 | #region Add/Remove Agent/Avatar | ||
863 | |||
864 | public abstract ISceneAgent AddNewAgent(IClientAPI client, PresenceType type); | ||
865 | |||
866 | public abstract bool CloseAgent(UUID agentID, bool force); | ||
867 | |||
868 | public bool TryGetScenePresence(UUID agentID, out object scenePresence) | ||
869 | { | ||
870 | scenePresence = null; | ||
871 | ScenePresence sp = null; | ||
872 | if (TryGetScenePresence(agentID, out sp)) | ||
873 | { | ||
874 | scenePresence = sp; | ||
875 | return true; | ||
876 | } | ||
877 | |||
878 | return false; | ||
879 | } | ||
880 | |||
881 | /// <summary> | ||
882 | /// Try to get a scene presence from the scene | ||
883 | /// </summary> | ||
884 | /// <param name="agentID"></param> | ||
885 | /// <param name="scenePresence">null if there is no scene presence with the given agent id</param> | ||
886 | /// <returns>true if there was a scene presence with the given id, false otherwise.</returns> | ||
887 | public abstract bool TryGetScenePresence(UUID agentID, out ScenePresence scenePresence); | ||
888 | |||
889 | #endregion | ||
890 | |||
891 | /// <summary> | ||
892 | /// | ||
893 | /// </summary> | ||
894 | /// <returns></returns> | ||
895 | public virtual RegionInfo RegionInfo { get; private set; } | ||
896 | |||
897 | #region admin stuff | ||
898 | |||
899 | public abstract void OtherRegionUp(GridRegion otherRegion); | ||
900 | |||
901 | public virtual string GetSimulatorVersion() | ||
902 | { | ||
903 | return "OpenSimulator Server"; | ||
904 | } | ||
905 | |||
906 | #endregion | ||
907 | |||
908 | #region Shutdown | ||
909 | |||
910 | /// <summary> | ||
911 | /// Tidy before shutdown | ||
912 | /// </summary> | ||
913 | public virtual void Close() | ||
914 | { | ||
915 | try | ||
916 | { | ||
917 | EventManager.TriggerShutdown(); | ||
918 | } | ||
919 | catch (Exception e) | ||
920 | { | ||
921 | m_log.Error(string.Format("[SCENE]: SceneBase.cs: Close() - Failed with exception ", e)); | ||
922 | } | ||
923 | } | ||
924 | |||
925 | #endregion | ||
926 | |||
927 | /// <summary> | ||
928 | /// Returns a new unallocated local ID | ||
929 | /// </summary> | ||
930 | /// <returns>A brand new local ID</returns> | ||
931 | public uint AllocateLocalId() | ||
932 | { | ||
933 | uint myID; | ||
934 | |||
935 | _primAllocateMutex.WaitOne(); | ||
936 | myID = ++m_lastAllocatedLocalId; | ||
937 | _primAllocateMutex.ReleaseMutex(); | ||
938 | |||
939 | return myID; | ||
940 | } | ||
941 | |||
942 | public uint AllocatePresenceLocalId() | ||
943 | { | ||
944 | uint myID; | ||
945 | |||
946 | _primAllocateMutex.WaitOne(); | ||
947 | myID = ++m_lastAllocatedLocalId; | ||
948 | ++m_lastAllocatedLocalId; | ||
949 | _primAllocateMutex.ReleaseMutex(); | ||
950 | |||
951 | return myID; | ||
952 | } | ||
953 | |||
954 | #region Module Methods | ||
955 | |||
956 | /// <summary> | ||
957 | /// Add a region-module to this scene. TODO: This will replace AddModule in the future. | ||
958 | /// </summary> | ||
959 | /// <param name="name"></param> | ||
960 | /// <param name="module"></param> | ||
961 | public void AddRegionModule(string name, IRegionModuleBase module) | ||
962 | { | ||
963 | if (!RegionModules.ContainsKey(name)) | ||
964 | { | ||
965 | RegionModules.Add(name, module); | ||
966 | } | ||
967 | } | ||
968 | |||
969 | public void RemoveRegionModule(string name) | ||
970 | { | ||
971 | RegionModules.Remove(name); | ||
972 | } | ||
973 | |||
974 | /// <summary> | ||
975 | /// Register a module commander. | ||
976 | /// </summary> | ||
977 | /// <param name="commander"></param> | ||
978 | public void RegisterModuleCommander(ICommander commander) | ||
979 | { | ||
980 | lock (m_moduleCommanders) | ||
981 | { | ||
982 | m_moduleCommanders.Add(commander.Name, commander); | ||
983 | } | ||
984 | } | ||
985 | |||
986 | /// <summary> | ||
987 | /// Unregister a module commander and all its commands | ||
988 | /// </summary> | ||
989 | /// <param name="name"></param> | ||
990 | public void UnregisterModuleCommander(string name) | ||
991 | { | ||
992 | lock (m_moduleCommanders) | ||
993 | { | ||
994 | ICommander commander; | ||
995 | if (m_moduleCommanders.TryGetValue(name, out commander)) | ||
996 | m_moduleCommanders.Remove(name); | ||
997 | } | ||
998 | } | ||
999 | |||
1000 | /// <summary> | ||
1001 | /// Get a module commander | ||
1002 | /// </summary> | ||
1003 | /// <param name="name"></param> | ||
1004 | /// <returns>The module commander, null if no module commander with that name was found</returns> | ||
1005 | public ICommander GetCommander(string name) | ||
1006 | { | ||
1007 | lock (m_moduleCommanders) | ||
1008 | { | ||
1009 | if (m_moduleCommanders.ContainsKey(name)) | ||
1010 | return m_moduleCommanders[name]; | ||
1011 | } | ||
1012 | |||
1013 | return null; | ||
1014 | } | ||
1015 | |||
1016 | public Dictionary<string, ICommander> GetCommanders() | ||
1017 | { | ||
1018 | return m_moduleCommanders; | ||
1019 | } | ||
1020 | |||
1021 | /// <summary> | ||
1022 | /// Register an interface to a region module. This allows module methods to be called directly as | ||
1023 | /// well as via events. If there is already a module registered for this interface, it is not replaced | ||
1024 | /// (is this the best behaviour?) | ||
1025 | /// </summary> | ||
1026 | /// <param name="mod"></param> | ||
1027 | public void RegisterModuleInterface<M>(M mod) | ||
1028 | { | ||
1029 | // m_log.DebugFormat("[SCENE BASE]: Registering interface {0}", typeof(M)); | ||
1030 | |||
1031 | List<Object> l = null; | ||
1032 | if (!ModuleInterfaces.TryGetValue(typeof(M), out l)) | ||
1033 | { | ||
1034 | l = new List<Object>(); | ||
1035 | ModuleInterfaces.Add(typeof(M), l); | ||
1036 | } | ||
1037 | |||
1038 | if (l.Count > 0) | ||
1039 | return; | ||
1040 | |||
1041 | l.Add(mod); | ||
1042 | |||
1043 | if (mod is IEntityCreator) | ||
1044 | { | ||
1045 | IEntityCreator entityCreator = (IEntityCreator)mod; | ||
1046 | foreach (PCode pcode in entityCreator.CreationCapabilities) | ||
1047 | { | ||
1048 | m_entityCreators[pcode] = entityCreator; | ||
1049 | } | ||
1050 | } | ||
1051 | } | ||
1052 | |||
1053 | public void UnregisterModuleInterface<M>(M mod) | ||
1054 | { | ||
1055 | List<Object> l; | ||
1056 | if (ModuleInterfaces.TryGetValue(typeof(M), out l)) | ||
1057 | { | ||
1058 | if (l.Remove(mod)) | ||
1059 | { | ||
1060 | if (mod is IEntityCreator) | ||
1061 | { | ||
1062 | IEntityCreator entityCreator = (IEntityCreator)mod; | ||
1063 | foreach (PCode pcode in entityCreator.CreationCapabilities) | ||
1064 | { | ||
1065 | m_entityCreators[pcode] = null; | ||
1066 | } | ||
1067 | } | ||
1068 | } | ||
1069 | } | ||
1070 | } | ||
1071 | |||
1072 | public void StackModuleInterface<M>(M mod) | ||
1073 | { | ||
1074 | List<Object> l; | ||
1075 | if (ModuleInterfaces.ContainsKey(typeof(M))) | ||
1076 | l = ModuleInterfaces[typeof(M)]; | ||
1077 | else | ||
1078 | l = new List<Object>(); | ||
1079 | |||
1080 | if (l.Contains(mod)) | ||
1081 | return; | ||
1082 | |||
1083 | l.Add(mod); | ||
1084 | |||
1085 | if (mod is IEntityCreator) | ||
1086 | { | ||
1087 | IEntityCreator entityCreator = (IEntityCreator)mod; | ||
1088 | foreach (PCode pcode in entityCreator.CreationCapabilities) | ||
1089 | { | ||
1090 | m_entityCreators[pcode] = entityCreator; | ||
1091 | } | ||
1092 | } | ||
1093 | |||
1094 | ModuleInterfaces[typeof(M)] = l; | ||
1095 | } | ||
1096 | |||
1097 | /// <summary> | ||
1098 | /// For the given interface, retrieve the region module which implements it. | ||
1099 | /// </summary> | ||
1100 | /// <returns>null if there is no registered module implementing that interface</returns> | ||
1101 | public T RequestModuleInterface<T>() | ||
1102 | { | ||
1103 | if (ModuleInterfaces.ContainsKey(typeof(T)) && | ||
1104 | (ModuleInterfaces[typeof(T)].Count > 0)) | ||
1105 | return (T)ModuleInterfaces[typeof(T)][0]; | ||
1106 | else | ||
1107 | return default(T); | ||
1108 | } | ||
1109 | |||
1110 | /// <summary> | ||
1111 | /// For the given interface, retrieve an array of region modules that implement it. | ||
1112 | /// </summary> | ||
1113 | /// <returns>an empty array if there are no registered modules implementing that interface</returns> | ||
1114 | public T[] RequestModuleInterfaces<T>() | ||
1115 | { | ||
1116 | if (ModuleInterfaces.ContainsKey(typeof(T))) | ||
1117 | { | ||
1118 | List<T> ret = new List<T>(); | ||
1119 | |||
1120 | foreach (Object o in ModuleInterfaces[typeof(T)]) | ||
1121 | ret.Add((T)o); | ||
1122 | return ret.ToArray(); | ||
1123 | } | ||
1124 | else | ||
1125 | { | ||
1126 | return new T[] {}; | ||
1127 | } | ||
1128 | } | ||
1129 | |||
1130 | #endregion | ||
1131 | |||
1132 | /// <summary> | ||
1133 | /// Call this from a region module to add a command to the OpenSim console. | ||
1134 | /// </summary> | ||
1135 | /// <param name="mod"></param> | ||
1136 | /// <param name="command"></param> | ||
1137 | /// <param name="shorthelp"></param> | ||
1138 | /// <param name="longhelp"></param> | ||
1139 | /// <param name="callback"></param> | ||
1140 | public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) | ||
1141 | { | ||
1142 | AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); | ||
1143 | } | ||
1144 | |||
1145 | /// <summary> | ||
1146 | /// Call this from a region module to add a command to the OpenSim console. | ||
1147 | /// </summary> | ||
1148 | /// <param name="mod"> | ||
1149 | /// The use of IRegionModuleBase is a cheap trick to get a different method signature, | ||
1150 | /// though all new modules should be using interfaces descended from IRegionModuleBase anyway. | ||
1151 | /// </param> | ||
1152 | /// <param name="category"> | ||
1153 | /// Category of the command. This is the section under which it will appear when the user asks for help | ||
1154 | /// </param> | ||
1155 | /// <param name="command"></param> | ||
1156 | /// <param name="shorthelp"></param> | ||
1157 | /// <param name="longhelp"></param> | ||
1158 | /// <param name="callback"></param> | ||
1159 | public void AddCommand( | ||
1160 | string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) | ||
1161 | { | ||
1162 | AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); | ||
1163 | } | ||
1164 | |||
1165 | /// <summary> | ||
1166 | /// Call this from a region module to add a command to the OpenSim console. | ||
1167 | /// </summary> | ||
1168 | /// <param name="mod"></param> | ||
1169 | /// <param name="command"></param> | ||
1170 | /// <param name="shorthelp"></param> | ||
1171 | /// <param name="longhelp"></param> | ||
1172 | /// <param name="descriptivehelp"></param> | ||
1173 | /// <param name="callback"></param> | ||
1174 | public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) | ||
1175 | { | ||
1176 | string moduleName = ""; | ||
1177 | |||
1178 | if (module != null) | ||
1179 | moduleName = module.Name; | ||
1180 | |||
1181 | AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); | ||
1182 | } | ||
1183 | |||
1184 | /// <summary> | ||
1185 | /// Call this from a region module to add a command to the OpenSim console. | ||
1186 | /// </summary> | ||
1187 | /// <param name="category"> | ||
1188 | /// Category of the command. This is the section under which it will appear when the user asks for help | ||
1189 | /// </param> | ||
1190 | /// <param name="mod"></param> | ||
1191 | /// <param name="command"></param> | ||
1192 | /// <param name="shorthelp"></param> | ||
1193 | /// <param name="longhelp"></param> | ||
1194 | /// <param name="descriptivehelp"></param> | ||
1195 | /// <param name="callback"></param> | ||
1196 | public void AddCommand( | ||
1197 | string category, IRegionModuleBase module, string command, | ||
1198 | string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) | ||
1199 | { | ||
1200 | if (MainConsole.Instance == null) | ||
1201 | return; | ||
1202 | |||
1203 | bool shared = false; | ||
1204 | |||
1205 | if (module != null) | ||
1206 | shared = module is ISharedRegionModule; | ||
1207 | |||
1208 | MainConsole.Instance.Commands.AddCommand( | ||
1209 | category, shared, command, shorthelp, longhelp, descriptivehelp, callback); | ||
1210 | } | ||
1211 | |||
1212 | public virtual ISceneObject DeserializeObject(string representation) | ||
1213 | { | ||
1214 | return null; | ||
1215 | } | ||
1216 | |||
1217 | public virtual bool AllowScriptCrossings | ||
1218 | { | ||
1219 | get { return false; } | ||
1220 | } | ||
1221 | |||
1222 | public virtual void Start() | ||
1223 | { | ||
1224 | } | ||
1225 | |||
1226 | public void Restart() | ||
1227 | { | ||
1228 | // This has to be here to fire the event | ||
1229 | restart handlerPhysicsCrash = OnRestart; | ||
1230 | if (handlerPhysicsCrash != null) | ||
1231 | handlerPhysicsCrash(RegionInfo); | ||
1232 | } | ||
1233 | |||
1234 | public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); | ||
1235 | } | ||
1236 | } | ||
1237 | >>>>>>> avn/ubitvar | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index c8c8714..df7a72a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -219,8 +219,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
219 | } | 219 | } |
220 | } | 220 | } |
221 | 221 | ||
222 | public delegate void SendCloseChildAgentDelegate(UUID agentID, ulong regionHandle); | ||
223 | |||
222 | /// <summary> | 224 | /// <summary> |
223 | /// Closes a child agent on a given region | 225 | /// This Closes child agents on neighboring regions |
226 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | ||
224 | /// </summary> | 227 | /// </summary> |
225 | protected void SendCloseChildAgent(UUID agentID, ulong regionHandle, string auth_token) | 228 | protected void SendCloseChildAgent(UUID agentID, ulong regionHandle, string auth_token) |
226 | { | 229 | { |
@@ -248,7 +251,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
248 | { | 251 | { |
249 | foreach (ulong handle in regionslst) | 252 | foreach (ulong handle in regionslst) |
250 | { | 253 | { |
251 | // We must take a copy here since handle is acts like a reference when used in an iterator. | 254 | // We must take a copy here since handle acts like a reference when used in an iterator. |
252 | // This leads to race conditions if directly passed to SendCloseChildAgent with more than one neighbour region. | 255 | // This leads to race conditions if directly passed to SendCloseChildAgent with more than one neighbour region. |
253 | ulong handleCopy = handle; | 256 | ulong handleCopy = handle; |
254 | Util.FireAndForget( | 257 | Util.FireAndForget( |
@@ -257,10 +260,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
257 | "SceneCommunicationService.SendCloseChildAgentConnections"); | 260 | "SceneCommunicationService.SendCloseChildAgentConnections"); |
258 | } | 261 | } |
259 | } | 262 | } |
260 | 263 | ||
261 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) | 264 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) |
262 | { | 265 | { |
263 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); | 266 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); |
264 | } | 267 | } |
265 | } | 268 | } |
266 | } \ No newline at end of file | 269 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index c2e9b61..3f6a7f8 100755 --- 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 | ||
@@ -129,13 +139,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
129 | 139 | ||
130 | protected internal void Close() | 140 | protected internal void Close() |
131 | { | 141 | { |
132 | lock (m_presenceLock) | 142 | m_scenePresencesLock.EnterWriteLock(); |
143 | try | ||
133 | { | 144 | { |
134 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); | 145 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(); |
135 | List<ScenePresence> newlist = new List<ScenePresence>(); | 146 | List<ScenePresence> newlist = new List<ScenePresence>(); |
136 | m_scenePresenceMap = newmap; | 147 | m_scenePresenceMap = newmap; |
137 | m_scenePresenceArray = newlist; | 148 | m_scenePresenceArray = newlist; |
138 | } | 149 | } |
150 | finally | ||
151 | { | ||
152 | m_scenePresencesLock.ExitWriteLock(); | ||
153 | } | ||
139 | 154 | ||
140 | lock (SceneObjectGroupsByFullID) | 155 | lock (SceneObjectGroupsByFullID) |
141 | SceneObjectGroupsByFullID.Clear(); | 156 | SceneObjectGroupsByFullID.Clear(); |
@@ -256,13 +271,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
256 | protected internal bool AddRestoredSceneObject( | 271 | protected internal bool AddRestoredSceneObject( |
257 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 272 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
258 | { | 273 | { |
274 | if (!m_parentScene.CombineRegions) | ||
275 | { | ||
276 | // temporary checks to remove after varsize suport | ||
277 | float regionSizeX = m_parentScene.RegionInfo.RegionSizeX; | ||
278 | if (regionSizeX == 0) | ||
279 | regionSizeX = Constants.RegionSize; | ||
280 | float regionSizeY = m_parentScene.RegionInfo.RegionSizeY; | ||
281 | if (regionSizeY == 0) | ||
282 | regionSizeY = Constants.RegionSize; | ||
283 | |||
284 | // KF: Check for out-of-region, move inside and make static. | ||
285 | Vector3 npos = new Vector3(sceneObject.RootPart.GroupPosition.X, | ||
286 | sceneObject.RootPart.GroupPosition.Y, | ||
287 | sceneObject.RootPart.GroupPosition.Z); | ||
288 | 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 || | ||
289 | npos.X > regionSizeX || | ||
290 | npos.Y > regionSizeY)) | ||
291 | { | ||
292 | if (npos.X < 0.0) npos.X = 1.0f; | ||
293 | if (npos.Y < 0.0) npos.Y = 1.0f; | ||
294 | if (npos.Z < 0.0) npos.Z = 0.0f; | ||
295 | if (npos.X > regionSizeX) npos.X = regionSizeX - 1.0f; | ||
296 | if (npos.Y > regionSizeY) npos.Y = regionSizeY - 1.0f; | ||
297 | |||
298 | SceneObjectPart rootpart = sceneObject.RootPart; | ||
299 | rootpart.GroupPosition = npos; | ||
300 | |||
301 | foreach (SceneObjectPart part in sceneObject.Parts) | ||
302 | { | ||
303 | if (part == rootpart) | ||
304 | continue; | ||
305 | part.GroupPosition = npos; | ||
306 | } | ||
307 | rootpart.Velocity = Vector3.Zero; | ||
308 | rootpart.AngularVelocity = Vector3.Zero; | ||
309 | rootpart.Acceleration = Vector3.Zero; | ||
310 | } | ||
311 | } | ||
312 | |||
313 | bool ret = AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); | ||
314 | |||
259 | if (attachToBackup && (!alreadyPersisted)) | 315 | if (attachToBackup && (!alreadyPersisted)) |
260 | { | 316 | { |
261 | sceneObject.ForceInventoryPersistence(); | 317 | sceneObject.ForceInventoryPersistence(); |
262 | sceneObject.HasGroupChanged = true; | 318 | sceneObject.HasGroupChanged = true; |
263 | } | 319 | } |
264 | 320 | ||
265 | return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); | 321 | return ret; |
266 | } | 322 | } |
267 | 323 | ||
268 | /// <summary> | 324 | /// <summary> |
@@ -279,12 +335,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
279 | /// </returns> | 335 | /// </returns> |
280 | protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) | 336 | protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
281 | { | 337 | { |
282 | // Ensure that we persist this new scene object if it's not an | 338 | |
339 | bool ret = AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); | ||
340 | |||
341 | // Ensure that we persist this new scene object if it's not an | ||
283 | // attachment | 342 | // attachment |
343 | |||
284 | if (attachToBackup) | 344 | if (attachToBackup) |
285 | sceneObject.HasGroupChanged = true; | 345 | sceneObject.HasGroupChanged = true; |
286 | 346 | ||
287 | return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); | 347 | return ret; |
288 | } | 348 | } |
289 | 349 | ||
290 | /// <summary> | 350 | /// <summary> |
@@ -319,9 +379,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
319 | if (pa != null && pa.IsPhysical && vel != Vector3.Zero) | 379 | if (pa != null && pa.IsPhysical && vel != Vector3.Zero) |
320 | { | 380 | { |
321 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); | 381 | sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); |
322 | sceneObject.Velocity = vel; | ||
323 | } | 382 | } |
324 | 383 | ||
325 | return true; | 384 | return true; |
326 | } | 385 | } |
327 | 386 | ||
@@ -346,6 +405,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
346 | /// </returns> | 405 | /// </returns> |
347 | protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) | 406 | protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
348 | { | 407 | { |
408 | if (sceneObject == null) | ||
409 | { | ||
410 | m_log.ErrorFormat("[SCENEGRAPH]: Tried to add null scene object"); | ||
411 | return false; | ||
412 | } | ||
349 | if (sceneObject.UUID == UUID.Zero) | 413 | if (sceneObject.UUID == UUID.Zero) |
350 | { | 414 | { |
351 | m_log.ErrorFormat( | 415 | m_log.ErrorFormat( |
@@ -378,9 +442,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
378 | { | 442 | { |
379 | Vector3 scale = part.Shape.Scale; | 443 | Vector3 scale = part.Shape.Scale; |
380 | 444 | ||
381 | scale.X = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.X)); | 445 | scale.X = Util.Clamp(scale.X, m_parentScene.m_minNonphys, m_parentScene.m_maxNonphys); |
382 | scale.Y = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.Y)); | 446 | scale.Y = Util.Clamp(scale.Y, m_parentScene.m_minNonphys, m_parentScene.m_maxNonphys); |
383 | scale.Z = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.Z)); | 447 | scale.Z = Util.Clamp(scale.Z, m_parentScene.m_minNonphys, m_parentScene.m_maxNonphys); |
384 | 448 | ||
385 | part.Shape.Scale = scale; | 449 | part.Shape.Scale = scale; |
386 | } | 450 | } |
@@ -401,36 +465,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
401 | 465 | ||
402 | sceneObject.AttachToScene(m_parentScene); | 466 | sceneObject.AttachToScene(m_parentScene); |
403 | 467 | ||
404 | if (sendClientUpdates) | ||
405 | sceneObject.ScheduleGroupForFullUpdate(); | ||
406 | |||
407 | Entities.Add(sceneObject); | 468 | Entities.Add(sceneObject); |
408 | 469 | ||
409 | if (attachToBackup) | ||
410 | sceneObject.AttachToBackup(); | ||
411 | |||
412 | lock (SceneObjectGroupsByFullID) | 470 | lock (SceneObjectGroupsByFullID) |
413 | SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; | 471 | SceneObjectGroupsByFullID[sceneObject.UUID] = sceneObject; |
414 | 472 | ||
415 | lock (SceneObjectGroupsByFullPartID) | 473 | foreach (SceneObjectPart part in parts) |
416 | { | 474 | { |
417 | foreach (SceneObjectPart part in parts) | 475 | lock (SceneObjectGroupsByFullPartID) |
418 | SceneObjectGroupsByFullPartID[part.UUID] = sceneObject; | 476 | SceneObjectGroupsByFullPartID[part.UUID] = sceneObject; |
419 | } | ||
420 | |||
421 | lock (SceneObjectGroupsByLocalPartID) | ||
422 | { | ||
423 | // m_log.DebugFormat( | ||
424 | // "[SCENE GRAPH]: Adding scene object {0} {1} {2} to SceneObjectGroupsByLocalPartID in {3}", | ||
425 | // sceneObject.Name, sceneObject.UUID, sceneObject.LocalId, m_parentScene.RegionInfo.RegionName); | ||
426 | 477 | ||
427 | foreach (SceneObjectPart part in parts) | 478 | lock (SceneObjectGroupsByLocalPartID) |
428 | SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject; | 479 | SceneObjectGroupsByLocalPartID[part.LocalId] = sceneObject; |
429 | } | 480 | } |
430 | 481 | ||
482 | if (sendClientUpdates) | ||
483 | sceneObject.ScheduleGroupForFullUpdate(); | ||
484 | |||
485 | if (attachToBackup) | ||
486 | sceneObject.AttachToBackup(); | ||
487 | |||
431 | return true; | 488 | return true; |
432 | } | 489 | } |
433 | 490 | ||
491 | public void updateScenePartGroup(SceneObjectPart part, SceneObjectGroup grp) | ||
492 | { | ||
493 | // no tests, caller has responsability... | ||
494 | lock (SceneObjectGroupsByFullPartID) | ||
495 | SceneObjectGroupsByFullPartID[part.UUID] = grp; | ||
496 | |||
497 | lock (SceneObjectGroupsByLocalPartID) | ||
498 | SceneObjectGroupsByLocalPartID[part.LocalId] = grp; | ||
499 | } | ||
500 | |||
434 | /// <summary> | 501 | /// <summary> |
435 | /// Delete an object from the scene | 502 | /// Delete an object from the scene |
436 | /// </summary> | 503 | /// </summary> |
@@ -471,25 +538,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
471 | if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) | 538 | if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics) |
472 | RemovePhysicalPrim(grp.PrimCount); | 539 | RemovePhysicalPrim(grp.PrimCount); |
473 | } | 540 | } |
474 | 541 | ||
542 | bool ret = Entities.Remove(uuid); | ||
543 | |||
475 | lock (SceneObjectGroupsByFullID) | 544 | lock (SceneObjectGroupsByFullID) |
476 | SceneObjectGroupsByFullID.Remove(grp.UUID); | 545 | SceneObjectGroupsByFullID.Remove(grp.UUID); |
477 | 546 | ||
478 | lock (SceneObjectGroupsByFullPartID) | 547 | SceneObjectPart[] parts = grp.Parts; |
548 | for (int i = 0; i < parts.Length; i++) | ||
479 | { | 549 | { |
480 | SceneObjectPart[] parts = grp.Parts; | 550 | lock (SceneObjectGroupsByFullPartID) |
481 | for (int i = 0; i < parts.Length; i++) | ||
482 | SceneObjectGroupsByFullPartID.Remove(parts[i].UUID); | 551 | SceneObjectGroupsByFullPartID.Remove(parts[i].UUID); |
483 | } | ||
484 | 552 | ||
485 | lock (SceneObjectGroupsByLocalPartID) | 553 | lock (SceneObjectGroupsByLocalPartID) |
486 | { | ||
487 | SceneObjectPart[] parts = grp.Parts; | ||
488 | for (int i = 0; i < parts.Length; i++) | ||
489 | SceneObjectGroupsByLocalPartID.Remove(parts[i].LocalId); | 554 | SceneObjectGroupsByLocalPartID.Remove(parts[i].LocalId); |
490 | } | 555 | } |
491 | 556 | ||
492 | return Entities.Remove(uuid); | 557 | return ret; |
493 | } | 558 | } |
494 | 559 | ||
495 | /// <summary> | 560 | /// <summary> |
@@ -504,6 +569,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
504 | m_updateList[obj.UUID] = obj; | 569 | m_updateList[obj.UUID] = obj; |
505 | } | 570 | } |
506 | 571 | ||
572 | public void FireAttachToBackup(SceneObjectGroup obj) | ||
573 | { | ||
574 | if (OnAttachToBackup != null) | ||
575 | { | ||
576 | OnAttachToBackup(obj); | ||
577 | } | ||
578 | } | ||
579 | |||
580 | public void FireDetachFromBackup(SceneObjectGroup obj) | ||
581 | { | ||
582 | if (OnDetachFromBackup != null) | ||
583 | { | ||
584 | OnDetachFromBackup(obj); | ||
585 | } | ||
586 | } | ||
587 | |||
588 | public void FireChangeBackup(SceneObjectGroup obj) | ||
589 | { | ||
590 | if (OnChangeBackup != null) | ||
591 | { | ||
592 | OnChangeBackup(obj); | ||
593 | } | ||
594 | } | ||
595 | |||
507 | /// <summary> | 596 | /// <summary> |
508 | /// Process all pending updates | 597 | /// Process all pending updates |
509 | /// </summary> | 598 | /// </summary> |
@@ -595,7 +684,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
595 | 684 | ||
596 | Entities[presence.UUID] = presence; | 685 | Entities[presence.UUID] = presence; |
597 | 686 | ||
598 | lock (m_presenceLock) | 687 | m_scenePresencesLock.EnterWriteLock(); |
688 | try | ||
599 | { | 689 | { |
600 | m_numChildAgents++; | 690 | m_numChildAgents++; |
601 | 691 | ||
@@ -621,6 +711,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
621 | m_scenePresenceMap = newmap; | 711 | m_scenePresenceMap = newmap; |
622 | m_scenePresenceArray = newlist; | 712 | m_scenePresenceArray = newlist; |
623 | } | 713 | } |
714 | finally | ||
715 | { | ||
716 | m_scenePresencesLock.ExitWriteLock(); | ||
717 | } | ||
624 | 718 | ||
625 | return presence; | 719 | return presence; |
626 | } | 720 | } |
@@ -637,7 +731,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
637 | agentID); | 731 | agentID); |
638 | } | 732 | } |
639 | 733 | ||
640 | lock (m_presenceLock) | 734 | m_scenePresencesLock.EnterWriteLock(); |
735 | try | ||
641 | { | 736 | { |
642 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); | 737 | Dictionary<UUID, ScenePresence> newmap = new Dictionary<UUID, ScenePresence>(m_scenePresenceMap); |
643 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); | 738 | List<ScenePresence> newlist = new List<ScenePresence>(m_scenePresenceArray); |
@@ -659,6 +754,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
659 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); | 754 | m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); |
660 | } | 755 | } |
661 | } | 756 | } |
757 | finally | ||
758 | { | ||
759 | m_scenePresencesLock.ExitWriteLock(); | ||
760 | } | ||
662 | } | 761 | } |
663 | 762 | ||
664 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) | 763 | protected internal void SwapRootChildAgent(bool direction_RC_CR_T_F) |
@@ -887,7 +986,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
887 | m_log.WarnFormat( | 986 | m_log.WarnFormat( |
888 | "[SCENE GRAPH]: Found scene object {0} {1} {2} via SceneObjectGroupsByLocalPartID index but it doesn't contain part with local id {3}. Removing from entry from index in {4}.", | 987 | "[SCENE GRAPH]: Found scene object {0} {1} {2} via SceneObjectGroupsByLocalPartID index but it doesn't contain part with local id {3}. Removing from entry from index in {4}.", |
889 | sog.Name, sog.UUID, sog.LocalId, localID, m_parentScene.RegionInfo.RegionName); | 988 | sog.Name, sog.UUID, sog.LocalId, localID, m_parentScene.RegionInfo.RegionName); |
890 | 989 | m_log.WarnFormat("stack: {0}", Environment.StackTrace); | |
891 | SceneObjectGroupsByLocalPartID.Remove(localID); | 990 | SceneObjectGroupsByLocalPartID.Remove(localID); |
892 | } | 991 | } |
893 | } | 992 | } |
@@ -1223,6 +1322,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
1223 | 1322 | ||
1224 | #region Client Event handlers | 1323 | #region Client Event handlers |
1225 | 1324 | ||
1325 | protected internal void ClientChangeObject(uint localID, object odata, IClientAPI remoteClient) | ||
1326 | { | ||
1327 | SceneObjectPart part = GetSceneObjectPart(localID); | ||
1328 | ObjectChangeData data = (ObjectChangeData)odata; | ||
1329 | |||
1330 | if (part != null) | ||
1331 | { | ||
1332 | SceneObjectGroup grp = part.ParentGroup; | ||
1333 | if (grp != null) | ||
1334 | { | ||
1335 | if (m_parentScene.Permissions.CanEditObject(grp.UUID, remoteClient.AgentId)) | ||
1336 | { | ||
1337 | // These two are exceptions SL makes in the interpretation | ||
1338 | // of the change flags. Must check them here because otherwise | ||
1339 | // the group flag (see below) would be lost | ||
1340 | if (data.change == ObjectChangeType.groupS) | ||
1341 | data.change = ObjectChangeType.primS; | ||
1342 | if (data.change == ObjectChangeType.groupPS) | ||
1343 | data.change = ObjectChangeType.primPS; | ||
1344 | part.StoreUndoState(data.change); // lets test only saving what we changed | ||
1345 | grp.doChangeObject(part, (ObjectChangeData)data); | ||
1346 | } | ||
1347 | else | ||
1348 | { | ||
1349 | // Is this any kind of group operation? | ||
1350 | if ((data.change & ObjectChangeType.Group) != 0) | ||
1351 | { | ||
1352 | // Is a move and/or rotation requested? | ||
1353 | if ((data.change & (ObjectChangeType.Position | ObjectChangeType.Rotation)) != 0) | ||
1354 | { | ||
1355 | // Are we allowed to move it? | ||
1356 | if (m_parentScene.Permissions.CanMoveObject(grp.UUID, remoteClient.AgentId)) | ||
1357 | { | ||
1358 | // Strip all but move and rotation from request | ||
1359 | data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation); | ||
1360 | |||
1361 | part.StoreUndoState(data.change); | ||
1362 | grp.doChangeObject(part, (ObjectChangeData)data); | ||
1363 | } | ||
1364 | } | ||
1365 | } | ||
1366 | } | ||
1367 | } | ||
1368 | } | ||
1369 | } | ||
1370 | |||
1226 | /// <summary> | 1371 | /// <summary> |
1227 | /// Update the scale of an individual prim. | 1372 | /// Update the scale of an individual prim. |
1228 | /// </summary> | 1373 | /// </summary> |
@@ -1237,7 +1382,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1237 | { | 1382 | { |
1238 | if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) | 1383 | if (m_parentScene.Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId)) |
1239 | { | 1384 | { |
1385 | bool physbuild = false; | ||
1386 | if (part.ParentGroup.RootPart.PhysActor != null) | ||
1387 | { | ||
1388 | part.ParentGroup.RootPart.PhysActor.Building = true; | ||
1389 | physbuild = true; | ||
1390 | } | ||
1391 | |||
1240 | part.Resize(scale); | 1392 | part.Resize(scale); |
1393 | |||
1394 | if (physbuild) | ||
1395 | part.ParentGroup.RootPart.PhysActor.Building = false; | ||
1241 | } | 1396 | } |
1242 | } | 1397 | } |
1243 | } | 1398 | } |
@@ -1249,7 +1404,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1249 | { | 1404 | { |
1250 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) | 1405 | if (m_parentScene.Permissions.CanEditObject(group.UUID, remoteClient.AgentId)) |
1251 | { | 1406 | { |
1407 | bool physbuild = false; | ||
1408 | if (group.RootPart.PhysActor != null) | ||
1409 | { | ||
1410 | group.RootPart.PhysActor.Building = true; | ||
1411 | physbuild = true; | ||
1412 | } | ||
1413 | |||
1252 | group.GroupResize(scale); | 1414 | group.GroupResize(scale); |
1415 | |||
1416 | if (physbuild) | ||
1417 | group.RootPart.PhysActor.Building = false; | ||
1253 | } | 1418 | } |
1254 | } | 1419 | } |
1255 | } | 1420 | } |
@@ -1388,8 +1553,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1388 | { | 1553 | { |
1389 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) | 1554 | if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) |
1390 | { | 1555 | { |
1391 | if (m_parentScene.AttachmentsModule != null) | 1556 | // Set the new attachment point data in the object |
1392 | m_parentScene.AttachmentsModule.UpdateAttachmentPosition(group, pos); | 1557 | byte attachmentPoint = group.GetAttachmentPoint(); |
1558 | group.UpdateGroupPosition(pos); | ||
1559 | group.IsAttachment = false; | ||
1560 | group.AbsolutePosition = group.RootPart.AttachedPos; | ||
1561 | group.AttachmentPoint = attachmentPoint; | ||
1562 | group.HasGroupChanged = true; | ||
1393 | } | 1563 | } |
1394 | else | 1564 | else |
1395 | { | 1565 | { |
@@ -1447,6 +1617,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1447 | // VolumeDetect can't be set via UI and will always be off when a change is made there | 1617 | // VolumeDetect can't be set via UI and will always be off when a change is made there |
1448 | // now only change volume dtc if phantom off | 1618 | // now only change volume dtc if phantom off |
1449 | 1619 | ||
1620 | bool wantedPhys = UsePhysics; | ||
1450 | if (PhysData.PhysShapeType == PhysShapeType.invalid) // check for extraPhysics data | 1621 | if (PhysData.PhysShapeType == PhysShapeType.invalid) // check for extraPhysics data |
1451 | { | 1622 | { |
1452 | bool vdtc; | 1623 | bool vdtc; |
@@ -1463,10 +1634,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1463 | if (part != null) | 1634 | if (part != null) |
1464 | { | 1635 | { |
1465 | part.UpdateExtraPhysics(PhysData); | 1636 | part.UpdateExtraPhysics(PhysData); |
1466 | if (part.UpdatePhysRequired) | 1637 | if (part.UpdatePhysRequired && remoteClient != null) |
1467 | remoteClient.SendPartPhysicsProprieties(part); | 1638 | remoteClient.SendPartPhysicsProprieties(part); |
1468 | } | 1639 | } |
1469 | } | 1640 | } |
1641 | |||
1642 | if (wantedPhys != group.UsesPhysics && remoteClient != null) | ||
1643 | { | ||
1644 | remoteClient.SendAlertMessage("Object physics canceled because exceeds the limit of " + | ||
1645 | m_parentScene.m_linksetPhysCapacity + " physical prims with shape type not set to None"); | ||
1646 | group.RootPart.ScheduleFullUpdate(); | ||
1647 | } | ||
1470 | } | 1648 | } |
1471 | } | 1649 | } |
1472 | } | 1650 | } |
@@ -1611,6 +1789,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1611 | { | 1789 | { |
1612 | part.Material = Convert.ToByte(material); | 1790 | part.Material = Convert.ToByte(material); |
1613 | group.HasGroupChanged = true; | 1791 | group.HasGroupChanged = true; |
1792 | remoteClient.SendPartPhysicsProprieties(part); | ||
1614 | } | 1793 | } |
1615 | } | 1794 | } |
1616 | } | 1795 | } |
@@ -1689,12 +1868,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1689 | return; | 1868 | return; |
1690 | 1869 | ||
1691 | Monitor.Enter(m_updateLock); | 1870 | Monitor.Enter(m_updateLock); |
1871 | |||
1692 | try | 1872 | try |
1693 | { | 1873 | { |
1874 | |||
1694 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); | 1875 | List<SceneObjectGroup> childGroups = new List<SceneObjectGroup>(); |
1695 | 1876 | ||
1696 | // We do this in reverse to get the link order of the prims correct | 1877 | // We do this in reverse to get the link order of the prims correct |
1697 | for (int i = 0 ; i < children.Count ; i++) | 1878 | for (int i = 0; i < children.Count; i++) |
1698 | { | 1879 | { |
1699 | SceneObjectGroup child = children[i].ParentGroup; | 1880 | SceneObjectGroup child = children[i].ParentGroup; |
1700 | 1881 | ||
@@ -1705,9 +1886,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1705 | // Make sure no child prim is set for sale | 1886 | // Make sure no child prim is set for sale |
1706 | // So that, on delink, no prims are unwittingly | 1887 | // So that, on delink, no prims are unwittingly |
1707 | // left for sale and sold off | 1888 | // left for sale and sold off |
1708 | child.RootPart.ObjectSaleType = 0; | 1889 | |
1709 | child.RootPart.SalePrice = 10; | 1890 | if (child != null) |
1710 | childGroups.Add(child); | 1891 | { |
1892 | child.RootPart.ObjectSaleType = 0; | ||
1893 | child.RootPart.SalePrice = 10; | ||
1894 | childGroups.Add(child); | ||
1895 | } | ||
1711 | } | 1896 | } |
1712 | 1897 | ||
1713 | foreach (SceneObjectGroup child in childGroups) | 1898 | foreach (SceneObjectGroup child in childGroups) |
@@ -1736,6 +1921,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1736 | } | 1921 | } |
1737 | finally | 1922 | finally |
1738 | { | 1923 | { |
1924 | /* | ||
1925 | lock (SceneObjectGroupsByLocalPartID) | ||
1926 | { | ||
1927 | foreach (SceneObjectPart part in parentGroup.Parts) | ||
1928 | SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; | ||
1929 | } | ||
1930 | */ | ||
1931 | parentGroup.AdjustChildPrimPermissions(); | ||
1932 | parentGroup.HasGroupChanged = true; | ||
1933 | parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); | ||
1934 | parentGroup.ScheduleGroupForFullUpdate(); | ||
1739 | Monitor.Exit(m_updateLock); | 1935 | Monitor.Exit(m_updateLock); |
1740 | } | 1936 | } |
1741 | } | 1937 | } |
@@ -1777,21 +1973,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
1777 | 1973 | ||
1778 | SceneObjectGroup group = part.ParentGroup; | 1974 | SceneObjectGroup group = part.ParentGroup; |
1779 | if (!affectedGroups.Contains(group)) | 1975 | if (!affectedGroups.Contains(group)) |
1976 | { | ||
1780 | affectedGroups.Add(group); | 1977 | affectedGroups.Add(group); |
1978 | } | ||
1781 | } | 1979 | } |
1782 | } | 1980 | } |
1783 | } | 1981 | } |
1784 | 1982 | ||
1785 | foreach (SceneObjectPart child in childParts) | 1983 | if (childParts.Count > 0) |
1786 | { | 1984 | { |
1787 | // Unlink all child parts from their groups | 1985 | foreach (SceneObjectPart child in childParts) |
1788 | // | 1986 | { |
1789 | child.ParentGroup.DelinkFromGroup(child, true); | 1987 | // Unlink all child parts from their groups |
1790 | 1988 | // | |
1791 | // These are not in affected groups and will not be | 1989 | child.ParentGroup.DelinkFromGroup(child, true); |
1792 | // handled further. Do the honors here. | 1990 | child.ParentGroup.HasGroupChanged = true; |
1793 | child.ParentGroup.HasGroupChanged = true; | 1991 | child.ParentGroup.ScheduleGroupForFullUpdate(); |
1794 | child.ParentGroup.ScheduleGroupForFullUpdate(); | 1992 | } |
1795 | } | 1993 | } |
1796 | 1994 | ||
1797 | foreach (SceneObjectPart root in rootParts) | 1995 | foreach (SceneObjectPart root in rootParts) |
@@ -1805,52 +2003,58 @@ namespace OpenSim.Region.Framework.Scenes | |||
1805 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); | 2003 | List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Parts); |
1806 | int numChildren = newSet.Count; | 2004 | int numChildren = newSet.Count; |
1807 | 2005 | ||
2006 | if (numChildren == 1) | ||
2007 | break; | ||
2008 | |||
1808 | // If there are prims left in a link set, but the root is | 2009 | // If there are prims left in a link set, but the root is |
1809 | // slated for unlink, we need to do this | 2010 | // slated for unlink, we need to do this |
2011 | // Unlink the remaining set | ||
1810 | // | 2012 | // |
1811 | if (numChildren != 1) | 2013 | bool sendEventsToRemainder = false; |
1812 | { | 2014 | if (numChildren == 2) // only one child prim no re-link needed |
1813 | // Unlink the remaining set | 2015 | sendEventsToRemainder = true; |
1814 | // | ||
1815 | bool sendEventsToRemainder = true; | ||
1816 | if (numChildren > 1) | ||
1817 | sendEventsToRemainder = false; | ||
1818 | 2016 | ||
1819 | foreach (SceneObjectPart p in newSet) | 2017 | foreach (SceneObjectPart p in newSet) |
2018 | { | ||
2019 | if (p != group.RootPart) | ||
1820 | { | 2020 | { |
1821 | if (p != group.RootPart) | 2021 | group.DelinkFromGroup(p, sendEventsToRemainder); |
1822 | group.DelinkFromGroup(p, sendEventsToRemainder); | 2022 | if (sendEventsToRemainder) // finish single child prim now |
2023 | { | ||
2024 | p.ParentGroup.HasGroupChanged = true; | ||
2025 | p.ParentGroup.ScheduleGroupForFullUpdate(); | ||
2026 | } | ||
1823 | } | 2027 | } |
2028 | } | ||
1824 | 2029 | ||
1825 | // If there is more than one prim remaining, we | 2030 | // If there is more than one prim remaining, we |
1826 | // need to re-link | 2031 | // need to re-link |
2032 | // | ||
2033 | if (numChildren > 2) | ||
2034 | { | ||
2035 | // Remove old root | ||
1827 | // | 2036 | // |
1828 | if (numChildren > 2) | 2037 | if (newSet.Contains(root)) |
2038 | newSet.Remove(root); | ||
2039 | |||
2040 | // Preserve link ordering | ||
2041 | // | ||
2042 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) | ||
1829 | { | 2043 | { |
1830 | // Remove old root | 2044 | return a.LinkNum.CompareTo(b.LinkNum); |
1831 | // | 2045 | }); |
1832 | if (newSet.Contains(root)) | ||
1833 | newSet.Remove(root); | ||
1834 | |||
1835 | // Preserve link ordering | ||
1836 | // | ||
1837 | newSet.Sort(delegate (SceneObjectPart a, SceneObjectPart b) | ||
1838 | { | ||
1839 | return a.LinkNum.CompareTo(b.LinkNum); | ||
1840 | }); | ||
1841 | 2046 | ||
1842 | // Determine new root | 2047 | // Determine new root |
1843 | // | 2048 | // |
1844 | SceneObjectPart newRoot = newSet[0]; | 2049 | SceneObjectPart newRoot = newSet[0]; |
1845 | newSet.RemoveAt(0); | 2050 | newSet.RemoveAt(0); |
1846 | 2051 | ||
1847 | foreach (SceneObjectPart newChild in newSet) | 2052 | foreach (SceneObjectPart newChild in newSet) |
1848 | newChild.ClearUpdateSchedule(); | 2053 | newChild.ClearUpdateSchedule(); |
1849 | 2054 | ||
1850 | LinkObjects(newRoot, newSet); | 2055 | LinkObjects(newRoot, newSet); |
1851 | if (!affectedGroups.Contains(newRoot.ParentGroup)) | 2056 | // if (!affectedGroups.Contains(newRoot.ParentGroup)) |
1852 | affectedGroups.Add(newRoot.ParentGroup); | 2057 | // affectedGroups.Add(newRoot.ParentGroup); |
1853 | } | ||
1854 | } | 2058 | } |
1855 | } | 2059 | } |
1856 | 2060 | ||
@@ -1858,6 +2062,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1858 | // | 2062 | // |
1859 | foreach (SceneObjectGroup g in affectedGroups) | 2063 | foreach (SceneObjectGroup g in affectedGroups) |
1860 | { | 2064 | { |
2065 | // Child prims that have been unlinked and deleted will | ||
2066 | // return unless the root is deleted. This will remove them | ||
2067 | // from the database. They will be rewritten immediately, | ||
2068 | // minus the rows for the unlinked child prims. | ||
2069 | g.AdjustChildPrimPermissions(); | ||
2070 | m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); | ||
1861 | g.TriggerScriptChangedEvent(Changed.LINK); | 2071 | g.TriggerScriptChangedEvent(Changed.LINK); |
1862 | g.HasGroupChanged = true; // Persist | 2072 | g.HasGroupChanged = true; // Persist |
1863 | g.ScheduleGroupForFullUpdate(); | 2073 | g.ScheduleGroupForFullUpdate(); |
@@ -1931,54 +2141,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
1931 | /// <param name="GroupID"></param> | 2141 | /// <param name="GroupID"></param> |
1932 | /// <param name="rot"></param> | 2142 | /// <param name="rot"></param> |
1933 | /// <returns>null if duplication fails, otherwise the duplicated object</returns> | 2143 | /// <returns>null if duplication fails, otherwise the duplicated object</returns> |
1934 | public SceneObjectGroup DuplicateObject( | 2144 | /// <summary> |
1935 | uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) | 2145 | public SceneObjectGroup DuplicateObject(uint originalPrimID, Vector3 offset, uint flags, UUID AgentID, UUID GroupID, Quaternion rot) |
1936 | { | 2146 | { |
1937 | Monitor.Enter(m_updateLock); | 2147 | // m_log.DebugFormat( |
2148 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | ||
2149 | // originalPrimID, offset, AgentID); | ||
1938 | 2150 | ||
1939 | try | 2151 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); |
2152 | if (original != null) | ||
1940 | { | 2153 | { |
1941 | // m_log.DebugFormat( | 2154 | if (m_parentScene.Permissions.CanDuplicateObject( |
1942 | // "[SCENE]: Duplication of object {0} at offset {1} requested by agent {2}", | 2155 | original.PrimCount, original.UUID, AgentID, original.AbsolutePosition)) |
1943 | // originalPrimID, offset, AgentID); | ||
1944 | |||
1945 | SceneObjectGroup original = GetGroupByPrim(originalPrimID); | ||
1946 | if (original == null) | ||
1947 | { | 2156 | { |
2157 | <<<<<<< HEAD | ||
1948 | m_log.WarnFormat( | 2158 | m_log.WarnFormat( |
1949 | "[SCENEGRAPH]: Attempt to duplicate nonexistent prim id {0} by {1}", originalPrimID, AgentID); | 2159 | "[SCENEGRAPH]: Attempt to duplicate nonexistent prim id {0} by {1}", originalPrimID, AgentID); |
2160 | ======= | ||
2161 | SceneObjectGroup copy = original.Copy(true); | ||
2162 | copy.AbsolutePosition = copy.AbsolutePosition + offset; | ||
2163 | >>>>>>> avn/ubitvar | ||
1950 | 2164 | ||
1951 | return null; | 2165 | if (original.OwnerID != AgentID) |
1952 | } | 2166 | { |
2167 | copy.SetOwnerId(AgentID); | ||
2168 | copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); | ||
1953 | 2169 | ||
1954 | if (!m_parentScene.Permissions.CanDuplicateObject( | 2170 | SceneObjectPart[] partList = copy.Parts; |
1955 | original.PrimCount, original.UUID, AgentID, original.AbsolutePosition)) | ||
1956 | return null; | ||
1957 | 2171 | ||
1958 | SceneObjectGroup copy = original.Copy(true); | 2172 | if (m_parentScene.Permissions.PropagatePermissions()) |
1959 | copy.AbsolutePosition = copy.AbsolutePosition + offset; | 2173 | { |
2174 | foreach (SceneObjectPart child in partList) | ||
2175 | { | ||
2176 | child.Inventory.ChangeInventoryOwner(AgentID); | ||
2177 | child.TriggerScriptChangedEvent(Changed.OWNER); | ||
2178 | child.ApplyNextOwnerPermissions(); | ||
2179 | } | ||
2180 | } | ||
2181 | } | ||
1960 | 2182 | ||
1961 | if (original.OwnerID != AgentID) | 2183 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() |
1962 | { | 2184 | Entities.Add(copy); |
1963 | copy.SetOwnerId(AgentID); | ||
1964 | copy.SetRootPartOwner(copy.RootPart, AgentID, GroupID); | ||
1965 | 2185 | ||
1966 | SceneObjectPart[] partList = copy.Parts; | 2186 | lock (SceneObjectGroupsByFullID) |
2187 | SceneObjectGroupsByFullID[copy.UUID] = copy; | ||
1967 | 2188 | ||
1968 | if (m_parentScene.Permissions.PropagatePermissions()) | 2189 | SceneObjectPart[] parts = copy.Parts; |
2190 | foreach (SceneObjectPart part in parts) | ||
1969 | { | 2191 | { |
1970 | foreach (SceneObjectPart child in partList) | 2192 | lock (SceneObjectGroupsByFullPartID) |
1971 | { | 2193 | SceneObjectGroupsByFullPartID[part.UUID] = copy; |
1972 | child.Inventory.ChangeInventoryOwner(AgentID); | 2194 | lock (SceneObjectGroupsByLocalPartID) |
1973 | child.TriggerScriptChangedEvent(Changed.OWNER); | 2195 | SceneObjectGroupsByLocalPartID[part.LocalId] = copy; |
1974 | child.ApplyNextOwnerPermissions(); | ||
1975 | } | ||
1976 | } | 2196 | } |
1977 | 2197 | ||
1978 | copy.RootPart.ObjectSaleType = 0; | 2198 | // PROBABLE END OF FIXME |
1979 | copy.RootPart.SalePrice = 10; | ||
1980 | } | ||
1981 | 2199 | ||
2200 | <<<<<<< HEAD | ||
1982 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() | 2201 | // FIXME: This section needs to be refactored so that it just calls AddSceneObject() |
1983 | Entities.Add(copy); | 2202 | Entities.Add(copy); |
1984 | 2203 | ||
@@ -2027,24 +2246,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
2027 | { | 2246 | { |
2028 | copy.UpdateGroupRotationR(rot); | 2247 | copy.UpdateGroupRotationR(rot); |
2029 | } | 2248 | } |
2249 | ======= | ||
2250 | // Since we copy from a source group that is in selected | ||
2251 | // state, but the copy is shown deselected in the viewer, | ||
2252 | // We need to clear the selection flag here, else that | ||
2253 | // prim never gets persisted at all. The client doesn't | ||
2254 | // think it's selected, so it will never send a deselect... | ||
2255 | copy.IsSelected = false; | ||
2256 | >>>>>>> avn/ubitvar | ||
2257 | |||
2258 | m_numPrim += copy.Parts.Length; | ||
2259 | |||
2260 | if (rot != Quaternion.Identity) | ||
2261 | { | ||
2262 | copy.UpdateGroupRotationR(rot); | ||
2263 | } | ||
2030 | 2264 | ||
2031 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); | 2265 | copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 1); |
2032 | copy.HasGroupChanged = true; | 2266 | copy.HasGroupChanged = true; |
2033 | copy.ScheduleGroupForFullUpdate(); | 2267 | copy.ScheduleGroupForFullUpdate(); |
2034 | copy.ResumeScripts(); | 2268 | copy.ResumeScripts(); |
2035 | 2269 | ||
2036 | // required for physics to update it's position | 2270 | // required for physics to update it's position |
2037 | copy.AbsolutePosition = copy.AbsolutePosition; | 2271 | copy.AbsolutePosition = copy.AbsolutePosition; |
2038 | 2272 | ||
2039 | return copy; | 2273 | return copy; |
2274 | } | ||
2040 | } | 2275 | } |
2041 | finally | 2276 | else |
2042 | { | 2277 | { |
2043 | Monitor.Exit(m_updateLock); | 2278 | m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); |
2044 | } | 2279 | } |
2280 | |||
2281 | return null; | ||
2045 | } | 2282 | } |
2046 | 2283 | ||
2047 | /// <summary> | ||
2048 | /// Calculates the distance between two Vector3s | 2284 | /// Calculates the distance between two Vector3s |
2049 | /// </summary> | 2285 | /// </summary> |
2050 | /// <param name="v1"></param> | 2286 | /// <param name="v1"></param> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index 28f7896..c5c083a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -99,11 +99,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
99 | } | 99 | } |
100 | } | 100 | } |
101 | 101 | ||
102 | private readonly List<Scene> m_localScenes = new List<Scene>(); | 102 | private readonly DoubleDictionary<UUID, string, Scene> m_localScenes = new DoubleDictionary<UUID, string, Scene>(); |
103 | 103 | ||
104 | public List<Scene> Scenes | 104 | public List<Scene> Scenes |
105 | { | 105 | { |
106 | get { return new List<Scene>(m_localScenes); } | 106 | get { return new List<Scene>(m_localScenes.FindAll(delegate(Scene s) { return true; })); } |
107 | } | 107 | } |
108 | 108 | ||
109 | /// <summary> | 109 | /// <summary> |
@@ -120,13 +120,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
120 | { | 120 | { |
121 | if (CurrentScene == null) | 121 | if (CurrentScene == null) |
122 | { | 122 | { |
123 | lock (m_localScenes) | 123 | List<Scene> sceneList = Scenes; |
124 | { | 124 | if (sceneList.Count == 0) |
125 | if (m_localScenes.Count > 0) | 125 | return null; |
126 | return m_localScenes[0]; | 126 | return sceneList[0]; |
127 | else | ||
128 | return null; | ||
129 | } | ||
130 | } | 127 | } |
131 | else | 128 | else |
132 | { | 129 | { |
@@ -138,41 +135,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
138 | public SceneManager() | 135 | public SceneManager() |
139 | { | 136 | { |
140 | m_instance = this; | 137 | m_instance = this; |
141 | m_localScenes = new List<Scene>(); | 138 | m_localScenes = new DoubleDictionary<UUID, string, Scene>(); |
142 | } | 139 | } |
143 | 140 | ||
144 | public void Close() | 141 | public void Close() |
145 | { | 142 | { |
143 | List<Scene> localScenes = null; | ||
144 | |||
146 | lock (m_localScenes) | 145 | lock (m_localScenes) |
147 | { | 146 | { |
148 | for (int i = 0; i < m_localScenes.Count; i++) | 147 | localScenes = Scenes; |
149 | { | 148 | } |
150 | m_localScenes[i].Close(); | 149 | |
151 | } | 150 | for (int i = 0; i < localScenes.Count; i++) |
151 | { | ||
152 | localScenes[i].Close(); | ||
152 | } | 153 | } |
153 | } | 154 | } |
154 | 155 | ||
155 | public void Close(Scene cscene) | 156 | public void Close(Scene cscene) |
156 | { | 157 | { |
157 | lock (m_localScenes) | 158 | if (!m_localScenes.ContainsKey(cscene.RegionInfo.RegionID)) |
158 | { | 159 | return; |
159 | if (m_localScenes.Contains(cscene)) | 160 | cscene.Close(); |
160 | { | ||
161 | for (int i = 0; i < m_localScenes.Count; i++) | ||
162 | { | ||
163 | if (m_localScenes[i].Equals(cscene)) | ||
164 | { | ||
165 | m_localScenes[i].Close(); | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | } | ||
170 | } | 161 | } |
171 | 162 | ||
172 | public void Add(Scene scene) | 163 | public void Add(Scene scene) |
173 | { | 164 | { |
174 | lock (m_localScenes) | 165 | lock (m_localScenes) |
175 | m_localScenes.Add(scene); | 166 | m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene); |
176 | 167 | ||
177 | scene.OnRestart += HandleRestart; | 168 | scene.OnRestart += HandleRestart; |
178 | scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange; | 169 | scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange; |
@@ -184,15 +175,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
184 | 175 | ||
185 | lock (m_localScenes) | 176 | lock (m_localScenes) |
186 | { | 177 | { |
187 | for (int i = 0; i < m_localScenes.Count; i++) | 178 | m_localScenes.TryGetValue(rdata.RegionID, out restartedScene); |
188 | { | 179 | m_localScenes.Remove(rdata.RegionID); |
189 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) | ||
190 | { | ||
191 | restartedScene = m_localScenes[i]; | ||
192 | m_localScenes.RemoveAt(i); | ||
193 | break; | ||
194 | } | ||
195 | } | ||
196 | } | 180 | } |
197 | 181 | ||
198 | // If the currently selected scene has been restarted, then we can't reselect here since we the scene | 182 | // If the currently selected scene has been restarted, then we can't reselect here since we the scene |
@@ -207,39 +191,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
207 | private void HandleRegionReadyStatusChange(IScene scene) | 191 | private void HandleRegionReadyStatusChange(IScene scene) |
208 | { | 192 | { |
209 | lock (m_localScenes) | 193 | lock (m_localScenes) |
210 | AllRegionsReady = m_localScenes.TrueForAll(s => s.Ready); | 194 | AllRegionsReady = m_localScenes.FindAll(s => !s.Ready).Count == 0; |
211 | } | 195 | } |
212 | 196 | ||
213 | public void SendSimOnlineNotification(ulong regionHandle) | 197 | public void SendSimOnlineNotification(ulong regionHandle) |
214 | { | 198 | { |
215 | RegionInfo Result = null; | 199 | RegionInfo Result = null; |
216 | 200 | ||
217 | lock (m_localScenes) | 201 | Scene s = m_localScenes.FindValue(delegate(Scene x) |
218 | { | ||
219 | for (int i = 0; i < m_localScenes.Count; i++) | ||
220 | { | ||
221 | if (m_localScenes[i].RegionInfo.RegionHandle == regionHandle) | ||
222 | { | 202 | { |
223 | // Inform other regions to tell their avatar about me | 203 | if (x.RegionInfo.RegionHandle == regionHandle) |
224 | Result = m_localScenes[i].RegionInfo; | 204 | return true; |
225 | } | 205 | return false; |
226 | } | 206 | }); |
207 | |||
208 | if (s != null) | ||
209 | { | ||
210 | List<Scene> sceneList = Scenes; | ||
227 | 211 | ||
228 | if (Result != null) | 212 | for (int i = 0; i < sceneList.Count; i++) |
229 | { | 213 | { |
230 | for (int i = 0; i < m_localScenes.Count; i++) | 214 | if (sceneList[i]!= s) |
231 | { | 215 | { |
232 | if (m_localScenes[i].RegionInfo.RegionHandle != regionHandle) | 216 | // Inform other regions to tell their avatar about me |
233 | { | 217 | //sceneList[i].OtherRegionUp(Result); |
234 | // Inform other regions to tell their avatar about me | ||
235 | //m_localScenes[i].OtherRegionUp(Result); | ||
236 | } | ||
237 | } | 218 | } |
238 | } | 219 | } |
239 | else | 220 | } |
240 | { | 221 | else |
241 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); | 222 | { |
242 | } | 223 | m_log.Error("[REGION]: Unable to notify Other regions of this Region coming up"); |
243 | } | 224 | } |
244 | } | 225 | } |
245 | 226 | ||
@@ -368,16 +349,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
368 | } | 349 | } |
369 | else | 350 | else |
370 | { | 351 | { |
371 | lock (m_localScenes) | 352 | Scene s; |
353 | |||
354 | if (m_localScenes.TryGetValue(regionName, out s)) | ||
372 | { | 355 | { |
373 | foreach (Scene scene in m_localScenes) | 356 | CurrentScene = s; |
374 | { | 357 | return true; |
375 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) | ||
376 | { | ||
377 | CurrentScene = scene; | ||
378 | return true; | ||
379 | } | ||
380 | } | ||
381 | } | 358 | } |
382 | 359 | ||
383 | return false; | 360 | return false; |
@@ -386,18 +363,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
386 | 363 | ||
387 | public bool TrySetCurrentScene(UUID regionID) | 364 | public bool TrySetCurrentScene(UUID regionID) |
388 | { | 365 | { |
389 | m_log.Debug("Searching for Region: '" + regionID + "'"); | 366 | // m_log.Debug("Searching for Region: '" + regionID + "'"); |
390 | 367 | ||
391 | lock (m_localScenes) | 368 | Scene s; |
369 | |||
370 | if (m_localScenes.TryGetValue(regionID, out s)) | ||
392 | { | 371 | { |
393 | foreach (Scene scene in m_localScenes) | 372 | CurrentScene = s; |
394 | { | 373 | return true; |
395 | if (scene.RegionInfo.RegionID == regionID) | ||
396 | { | ||
397 | CurrentScene = scene; | ||
398 | return true; | ||
399 | } | ||
400 | } | ||
401 | } | 374 | } |
402 | 375 | ||
403 | return false; | 376 | return false; |
@@ -405,52 +378,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
405 | 378 | ||
406 | public bool TryGetScene(string regionName, out Scene scene) | 379 | public bool TryGetScene(string regionName, out Scene scene) |
407 | { | 380 | { |
408 | lock (m_localScenes) | 381 | return m_localScenes.TryGetValue(regionName, out scene); |
409 | { | ||
410 | foreach (Scene mscene in m_localScenes) | ||
411 | { | ||
412 | if (String.Compare(mscene.RegionInfo.RegionName, regionName, true) == 0) | ||
413 | { | ||
414 | scene = mscene; | ||
415 | return true; | ||
416 | } | ||
417 | } | ||
418 | } | ||
419 | |||
420 | scene = null; | ||
421 | return false; | ||
422 | } | 382 | } |
423 | 383 | ||
424 | public bool TryGetScene(UUID regionID, out Scene scene) | 384 | public bool TryGetScene(UUID regionID, out Scene scene) |
425 | { | 385 | { |
426 | lock (m_localScenes) | 386 | return m_localScenes.TryGetValue(regionID, out scene); |
427 | { | ||
428 | foreach (Scene mscene in m_localScenes) | ||
429 | { | ||
430 | if (mscene.RegionInfo.RegionID == regionID) | ||
431 | { | ||
432 | scene = mscene; | ||
433 | return true; | ||
434 | } | ||
435 | } | ||
436 | } | ||
437 | |||
438 | scene = null; | ||
439 | return false; | ||
440 | } | 387 | } |
441 | 388 | ||
442 | public bool TryGetScene(uint locX, uint locY, out Scene scene) | 389 | public bool TryGetScene(uint locX, uint locY, out Scene scene) |
443 | { | 390 | { |
444 | lock (m_localScenes) | 391 | List<Scene> sceneList = Scenes; |
392 | foreach (Scene mscene in sceneList) | ||
445 | { | 393 | { |
446 | foreach (Scene mscene in m_localScenes) | 394 | if (mscene.RegionInfo.RegionLocX == locX && |
395 | mscene.RegionInfo.RegionLocY == locY) | ||
447 | { | 396 | { |
448 | if (mscene.RegionInfo.RegionLocX == locX && | 397 | scene = mscene; |
449 | mscene.RegionInfo.RegionLocY == locY) | 398 | return true; |
450 | { | ||
451 | scene = mscene; | ||
452 | return true; | ||
453 | } | ||
454 | } | 399 | } |
455 | } | 400 | } |
456 | 401 | ||
@@ -460,16 +405,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
460 | 405 | ||
461 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) | 406 | public bool TryGetScene(IPEndPoint ipEndPoint, out Scene scene) |
462 | { | 407 | { |
463 | lock (m_localScenes) | 408 | List<Scene> sceneList = Scenes; |
409 | foreach (Scene mscene in sceneList) | ||
464 | { | 410 | { |
465 | foreach (Scene mscene in m_localScenes) | 411 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && |
412 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | ||
466 | { | 413 | { |
467 | if ((mscene.RegionInfo.InternalEndPoint.Equals(ipEndPoint.Address)) && | 414 | scene = mscene; |
468 | (mscene.RegionInfo.InternalEndPoint.Port == ipEndPoint.Port)) | 415 | return true; |
469 | { | ||
470 | scene = mscene; | ||
471 | return true; | ||
472 | } | ||
473 | } | 416 | } |
474 | } | 417 | } |
475 | 418 | ||
@@ -511,15 +454,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
511 | 454 | ||
512 | public RegionInfo GetRegionInfo(UUID regionID) | 455 | public RegionInfo GetRegionInfo(UUID regionID) |
513 | { | 456 | { |
514 | lock (m_localScenes) | 457 | Scene s; |
458 | if (m_localScenes.TryGetValue(regionID, out s)) | ||
515 | { | 459 | { |
516 | foreach (Scene scene in m_localScenes) | 460 | return s.RegionInfo; |
517 | { | ||
518 | if (scene.RegionInfo.RegionID == regionID) | ||
519 | { | ||
520 | return scene.RegionInfo; | ||
521 | } | ||
522 | } | ||
523 | } | 461 | } |
524 | 462 | ||
525 | return null; | 463 | return null; |
@@ -537,14 +475,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
537 | 475 | ||
538 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) | 476 | public bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) |
539 | { | 477 | { |
540 | lock (m_localScenes) | 478 | List<Scene> sceneList = Scenes; |
479 | foreach (Scene scene in sceneList) | ||
541 | { | 480 | { |
542 | foreach (Scene scene in m_localScenes) | 481 | if (scene.TryGetScenePresence(avatarId, out avatar)) |
543 | { | 482 | { |
544 | if (scene.TryGetScenePresence(avatarId, out avatar)) | 483 | return true; |
545 | { | ||
546 | return true; | ||
547 | } | ||
548 | } | 484 | } |
549 | } | 485 | } |
550 | 486 | ||
@@ -554,15 +490,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
554 | 490 | ||
555 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) | 491 | public bool TryGetRootScenePresence(UUID avatarId, out ScenePresence avatar) |
556 | { | 492 | { |
557 | lock (m_localScenes) | 493 | List<Scene> sceneList = Scenes; |
494 | foreach (Scene scene in sceneList) | ||
558 | { | 495 | { |
559 | foreach (Scene scene in m_localScenes) | 496 | avatar = scene.GetScenePresence(avatarId); |
560 | { | ||
561 | avatar = scene.GetScenePresence(avatarId); | ||
562 | 497 | ||
563 | if (avatar != null && !avatar.IsChildAgent) | 498 | if (avatar != null && !avatar.IsChildAgent) |
564 | return true; | 499 | return true; |
565 | } | ||
566 | } | 500 | } |
567 | 501 | ||
568 | avatar = null; | 502 | avatar = null; |
@@ -572,21 +506,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
572 | public void CloseScene(Scene scene) | 506 | public void CloseScene(Scene scene) |
573 | { | 507 | { |
574 | lock (m_localScenes) | 508 | lock (m_localScenes) |
575 | m_localScenes.Remove(scene); | 509 | m_localScenes.Remove(scene.RegionInfo.RegionID); |
576 | 510 | ||
577 | scene.Close(); | 511 | scene.Close(); |
578 | } | 512 | } |
579 | 513 | ||
580 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) | 514 | public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) |
581 | { | 515 | { |
582 | lock (m_localScenes) | 516 | List<Scene> sceneList = Scenes; |
517 | foreach (Scene scene in sceneList) | ||
583 | { | 518 | { |
584 | foreach (Scene scene in m_localScenes) | 519 | if (scene.TryGetAvatarByName(avatarName, out avatar)) |
585 | { | 520 | { |
586 | if (scene.TryGetAvatarByName(avatarName, out avatar)) | 521 | return true; |
587 | { | ||
588 | return true; | ||
589 | } | ||
590 | } | 522 | } |
591 | } | 523 | } |
592 | 524 | ||
@@ -596,14 +528,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
596 | 528 | ||
597 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) | 529 | public bool TryGetRootScenePresenceByName(string firstName, string lastName, out ScenePresence sp) |
598 | { | 530 | { |
599 | lock (m_localScenes) | 531 | List<Scene> sceneList = Scenes; |
532 | foreach (Scene scene in sceneList) | ||
600 | { | 533 | { |
601 | foreach (Scene scene in m_localScenes) | 534 | sp = scene.GetScenePresence(firstName, lastName); |
602 | { | 535 | if (sp != null && !sp.IsChildAgent) |
603 | sp = scene.GetScenePresence(firstName, lastName); | 536 | return true; |
604 | if (sp != null && !sp.IsChildAgent) | ||
605 | return true; | ||
606 | } | ||
607 | } | 537 | } |
608 | 538 | ||
609 | sp = null; | 539 | sp = null; |
@@ -612,8 +542,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
612 | 542 | ||
613 | public void ForEachScene(Action<Scene> action) | 543 | public void ForEachScene(Action<Scene> action) |
614 | { | 544 | { |
615 | lock (m_localScenes) | 545 | List<Scene> sceneList = Scenes; |
616 | m_localScenes.ForEach(action); | 546 | sceneList.ForEach(action); |
617 | } | 547 | } |
618 | } | 548 | } |
619 | } | 549 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs index 81cef5b..79de6c0 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs | |||
@@ -88,10 +88,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
88 | /// <summary> | 88 | /// <summary> |
89 | /// Stop and remove the scripts contained in all the prims in this group | 89 | /// Stop and remove the scripts contained in all the prims in this group |
90 | /// </summary> | 90 | /// </summary> |
91 | /// <param name="sceneObjectBeingDeleted"> | ||
92 | /// Should be true if these scripts are being removed because the scene | ||
93 | /// object is being deleted. This will prevent spurious updates to the client. | ||
94 | /// </param> | ||
95 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) | 91 | public void RemoveScriptInstances(bool sceneObjectBeingDeleted) |
96 | { | 92 | { |
97 | SceneObjectPart[] parts = m_parts.GetArray(); | 93 | SceneObjectPart[] parts = m_parts.GetArray(); |
@@ -254,6 +250,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
254 | 250 | ||
255 | public uint GetEffectivePermissions() | 251 | public uint GetEffectivePermissions() |
256 | { | 252 | { |
253 | return GetEffectivePermissions(false); | ||
254 | } | ||
255 | |||
256 | public uint GetEffectivePermissions(bool useBase) | ||
257 | { | ||
257 | uint perms=(uint)(PermissionMask.Modify | | 258 | uint perms=(uint)(PermissionMask.Modify | |
258 | PermissionMask.Copy | | 259 | PermissionMask.Copy | |
259 | PermissionMask.Move | | 260 | PermissionMask.Move | |
@@ -265,8 +266,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | for (int i = 0; i < parts.Length; i++) | 266 | for (int i = 0; i < parts.Length; i++) |
266 | { | 267 | { |
267 | SceneObjectPart part = parts[i]; | 268 | SceneObjectPart part = parts[i]; |
269 | <<<<<<< HEAD | ||
268 | // m_log.DebugFormat("[SCENE OBJECT GROUP INVENTORY]: Effective perms of {0} are {1}", part.Name, (OpenMetaverse.PermissionMask)part.OwnerMask); | 270 | // m_log.DebugFormat("[SCENE OBJECT GROUP INVENTORY]: Effective perms of {0} are {1}", part.Name, (OpenMetaverse.PermissionMask)part.OwnerMask); |
269 | ownerMask &= part.OwnerMask; | 271 | ownerMask &= part.OwnerMask; |
272 | ======= | ||
273 | if (useBase) | ||
274 | ownerMask &= part.BaseMask; | ||
275 | else | ||
276 | ownerMask &= part.OwnerMask; | ||
277 | >>>>>>> avn/ubitvar | ||
270 | perms &= part.Inventory.MaskEffectivePermissions(); | 278 | perms &= part.Inventory.MaskEffectivePermissions(); |
271 | } | 279 | } |
272 | 280 | ||
@@ -408,6 +416,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
408 | 416 | ||
409 | public void ResumeScripts() | 417 | public void ResumeScripts() |
410 | { | 418 | { |
419 | if (m_scene.RegionInfo.RegionSettings.DisableScripts) | ||
420 | return; | ||
421 | |||
411 | SceneObjectPart[] parts = m_parts.GetArray(); | 422 | SceneObjectPart[] parts = m_parts.GetArray(); |
412 | for (int i = 0; i < parts.Length; i++) | 423 | for (int i = 0; i < parts.Length; i++) |
413 | parts[i].Inventory.ResumeScripts(); | 424 | parts[i].Inventory.ResumeScripts(); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 866a43c..a703377 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -24,12 +24,13 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.ComponentModel; | 29 | using System.ComponentModel; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Drawing; | 31 | using System.Drawing; |
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Diagnostics; | ||
33 | using System.Linq; | 34 | using System.Linq; |
34 | using System.Threading; | 35 | using System.Threading; |
35 | using System.Xml; | 36 | using System.Xml; |
@@ -44,6 +45,7 @@ using PermissionMask = OpenSim.Framework.PermissionMask; | |||
44 | 45 | ||
45 | namespace OpenSim.Region.Framework.Scenes | 46 | namespace OpenSim.Region.Framework.Scenes |
46 | { | 47 | { |
48 | |||
47 | [Flags] | 49 | [Flags] |
48 | public enum scriptEvents | 50 | public enum scriptEvents |
49 | { | 51 | { |
@@ -79,14 +81,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
79 | object_rez = 4194304 | 81 | object_rez = 4194304 |
80 | } | 82 | } |
81 | 83 | ||
82 | struct scriptPosTarget | 84 | public struct scriptPosTarget |
83 | { | 85 | { |
84 | public Vector3 targetPos; | 86 | public Vector3 targetPos; |
85 | public float tolerance; | 87 | public float tolerance; |
86 | public uint handle; | 88 | public uint handle; |
87 | } | 89 | } |
88 | 90 | ||
89 | struct scriptRotTarget | 91 | public struct scriptRotTarget |
90 | { | 92 | { |
91 | public Quaternion targetRot; | 93 | public Quaternion targetRot; |
92 | public float tolerance; | 94 | public float tolerance; |
@@ -120,8 +122,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
120 | /// since the group's last persistent backup | 122 | /// since the group's last persistent backup |
121 | /// </summary> | 123 | /// </summary> |
122 | private bool m_hasGroupChanged = false; | 124 | private bool m_hasGroupChanged = false; |
125 | <<<<<<< HEAD | ||
123 | private long timeFirstChanged; | 126 | private long timeFirstChanged; |
124 | private long timeLastChanged; | 127 | private long timeLastChanged; |
128 | ======= | ||
129 | private long timeFirstChanged = 0; | ||
130 | private long timeLastChanged = 0; | ||
131 | private long m_maxPersistTime = 0; | ||
132 | private long m_minPersistTime = 0; | ||
133 | // private Random m_rand; | ||
134 | private List<ScenePresence> m_linkedAvatars = new List<ScenePresence>(); | ||
135 | >>>>>>> avn/ubitvar | ||
125 | 136 | ||
126 | /// <summary> | 137 | /// <summary> |
127 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage | 138 | /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage |
@@ -138,9 +149,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
138 | { | 149 | { |
139 | if (value) | 150 | if (value) |
140 | { | 151 | { |
152 | |||
153 | if (m_isBackedUp) | ||
154 | { | ||
155 | m_scene.SceneGraph.FireChangeBackup(this); | ||
156 | } | ||
141 | timeLastChanged = DateTime.Now.Ticks; | 157 | timeLastChanged = DateTime.Now.Ticks; |
142 | if (!m_hasGroupChanged) | 158 | if (!m_hasGroupChanged) |
143 | timeFirstChanged = DateTime.Now.Ticks; | 159 | timeFirstChanged = DateTime.Now.Ticks; |
160 | if (m_rootPart != null && m_rootPart.UUID != null && m_scene != null) | ||
161 | { | ||
162 | /* | ||
163 | if (m_rand == null) | ||
164 | { | ||
165 | byte[] val = new byte[16]; | ||
166 | m_rootPart.UUID.ToBytes(val, 0); | ||
167 | m_rand = new Random(BitConverter.ToInt32(val, 0)); | ||
168 | } | ||
169 | */ | ||
170 | if (m_scene.GetRootAgentCount() == 0) | ||
171 | { | ||
172 | //If the region is empty, this change has been made by an automated process | ||
173 | //and thus we delay the persist time by a random amount between 1.5 and 2.5. | ||
174 | |||
175 | // float factor = 1.5f + (float)(m_rand.NextDouble()); | ||
176 | float factor = 2.0f; | ||
177 | m_maxPersistTime = (long)((float)m_scene.m_persistAfter * factor); | ||
178 | m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * factor); | ||
179 | } | ||
180 | else | ||
181 | { | ||
182 | //If the region is not empty, we want to obey the minimum and maximum persist times | ||
183 | //but add a random factor so we stagger the object persistance a little | ||
184 | // m_maxPersistTime = (long)((float)m_scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5 | ||
185 | // m_minPersistTime = (long)((float)m_scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0 | ||
186 | m_maxPersistTime = m_scene.m_persistAfter; | ||
187 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
188 | } | ||
189 | } | ||
144 | } | 190 | } |
145 | m_hasGroupChanged = value; | 191 | m_hasGroupChanged = value; |
146 | 192 | ||
@@ -159,6 +205,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
159 | /// the prims in the database still use the old SceneGroupID. That's a problem if the group | 205 | /// the prims in the database still use the old SceneGroupID. That's a problem if the group |
160 | /// is deleted, because we delete groups by searching for prims by their SceneGroupID. | 206 | /// is deleted, because we delete groups by searching for prims by their SceneGroupID. |
161 | /// </summary> | 207 | /// </summary> |
208 | <<<<<<< HEAD | ||
162 | public bool GroupContainsForeignPrims | 209 | public bool GroupContainsForeignPrims |
163 | { | 210 | { |
164 | private set | 211 | private set |
@@ -171,6 +218,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
171 | get { return m_groupContainsForeignPrims; } | 218 | get { return m_groupContainsForeignPrims; } |
172 | } | 219 | } |
173 | 220 | ||
221 | ======= | ||
222 | public bool HasGroupChangedDueToDelink { get; set; } | ||
223 | >>>>>>> avn/ubitvar | ||
174 | 224 | ||
175 | private bool isTimeToPersist() | 225 | private bool isTimeToPersist() |
176 | { | 226 | { |
@@ -180,8 +230,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
180 | return false; | 230 | return false; |
181 | if (m_scene.ShuttingDown) | 231 | if (m_scene.ShuttingDown) |
182 | return true; | 232 | return true; |
233 | |||
234 | if (m_minPersistTime == 0 || m_maxPersistTime == 0) | ||
235 | { | ||
236 | m_maxPersistTime = m_scene.m_persistAfter; | ||
237 | m_minPersistTime = m_scene.m_dontPersistBefore; | ||
238 | } | ||
239 | |||
183 | long currentTime = DateTime.Now.Ticks; | 240 | long currentTime = DateTime.Now.Ticks; |
184 | if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) | 241 | |
242 | if (timeLastChanged == 0) timeLastChanged = currentTime; | ||
243 | if (timeFirstChanged == 0) timeFirstChanged = currentTime; | ||
244 | |||
245 | if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime) | ||
185 | return true; | 246 | return true; |
186 | return false; | 247 | return false; |
187 | } | 248 | } |
@@ -239,6 +300,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
239 | { | 300 | { |
240 | AttachmentPoint = 0; | 301 | AttachmentPoint = 0; |
241 | 302 | ||
303 | // Don't zap trees | ||
304 | if (RootPart.Shape.PCode == (byte)PCode.Tree || | ||
305 | RootPart.Shape.PCode == (byte)PCode.NewTree) | ||
306 | return; | ||
307 | |||
242 | // Even though we don't use child part state parameters for attachments any more, we still need to set | 308 | // Even though we don't use child part state parameters for attachments any more, we still need to set |
243 | // these to zero since having them non-zero in rezzed scene objects will crash some clients. Even if | 309 | // these to zero since having them non-zero in rezzed scene objects will crash some clients. Even if |
244 | // we store them correctly, scene objects that we receive from elsewhere might not. | 310 | // we store them correctly, scene objects that we receive from elsewhere might not. |
@@ -284,6 +350,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
284 | get { return RootPart.VolumeDetectActive; } | 350 | get { return RootPart.VolumeDetectActive; } |
285 | } | 351 | } |
286 | 352 | ||
353 | <<<<<<< HEAD | ||
287 | private Vector3 lastPhysGroupPos; | 354 | private Vector3 lastPhysGroupPos; |
288 | private Quaternion lastPhysGroupRot; | 355 | private Quaternion lastPhysGroupRot; |
289 | 356 | ||
@@ -291,6 +358,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
291 | /// Is this entity set to be saved in persistent storage? | 358 | /// Is this entity set to be saved in persistent storage? |
292 | /// </summary> | 359 | /// </summary> |
293 | public bool Backup { get; private set; } | 360 | public bool Backup { get; private set; } |
361 | ======= | ||
362 | private bool m_isBackedUp; | ||
363 | >>>>>>> avn/ubitvar | ||
364 | |||
365 | public bool IsBackedUp | ||
366 | { | ||
367 | get { return m_isBackedUp; } | ||
368 | } | ||
294 | 369 | ||
295 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); | 370 | protected MapAndArray<UUID, SceneObjectPart> m_parts = new MapAndArray<UUID, SceneObjectPart>(); |
296 | 371 | ||
@@ -298,15 +373,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
298 | protected SceneObjectPart m_rootPart; | 373 | protected SceneObjectPart m_rootPart; |
299 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); | 374 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); |
300 | 375 | ||
301 | private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); | 376 | private SortedDictionary<uint, scriptPosTarget> m_targets = new SortedDictionary<uint, scriptPosTarget>(); |
302 | private Dictionary<uint, scriptRotTarget> m_rotTargets = new Dictionary<uint, scriptRotTarget>(); | 377 | private SortedDictionary<uint, scriptRotTarget> m_rotTargets = new SortedDictionary<uint, scriptRotTarget>(); |
378 | |||
379 | public SortedDictionary<uint, scriptPosTarget> AtTargets | ||
380 | { | ||
381 | get { return m_targets; } | ||
382 | } | ||
383 | |||
384 | public SortedDictionary<uint, scriptRotTarget> RotTargets | ||
385 | { | ||
386 | get { return m_rotTargets; } | ||
387 | } | ||
303 | 388 | ||
304 | private bool m_scriptListens_atTarget; | 389 | private bool m_scriptListens_atTarget; |
305 | private bool m_scriptListens_notAtTarget; | 390 | private bool m_scriptListens_notAtTarget; |
306 | |||
307 | private bool m_scriptListens_atRotTarget; | 391 | private bool m_scriptListens_atRotTarget; |
308 | private bool m_scriptListens_notAtRotTarget; | 392 | private bool m_scriptListens_notAtRotTarget; |
309 | 393 | ||
394 | public bool m_dupeInProgress = false; | ||
310 | internal Dictionary<UUID, string> m_savedScriptState; | 395 | internal Dictionary<UUID, string> m_savedScriptState; |
311 | 396 | ||
312 | #region Properties | 397 | #region Properties |
@@ -343,6 +428,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
343 | get { return m_parts.Count; } | 428 | get { return m_parts.Count; } |
344 | } | 429 | } |
345 | 430 | ||
431 | // protected Quaternion m_rotation = Quaternion.Identity; | ||
432 | // | ||
433 | // public virtual Quaternion Rotation | ||
434 | // { | ||
435 | // get { return m_rotation; } | ||
436 | // set { | ||
437 | // m_rotation = value; | ||
438 | // } | ||
439 | // } | ||
440 | |||
346 | public Quaternion GroupRotation | 441 | public Quaternion GroupRotation |
347 | { | 442 | { |
348 | get { return m_rootPart.RotationOffset; } | 443 | get { return m_rootPart.RotationOffset; } |
@@ -456,6 +551,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
456 | public uint ParentID; | 551 | public uint ParentID; |
457 | } | 552 | } |
458 | 553 | ||
554 | |||
555 | public bool inTransit = false; | ||
556 | public delegate SceneObjectGroup SOGCrossDelegate(SceneObjectGroup sog,Vector3 pos); | ||
557 | |||
459 | /// <summary> | 558 | /// <summary> |
460 | /// The absolute position of this scene object in the scene | 559 | /// The absolute position of this scene object in the scene |
461 | /// </summary> | 560 | /// </summary> |
@@ -465,9 +564,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
465 | set | 564 | set |
466 | { | 565 | { |
467 | Vector3 val = value; | 566 | Vector3 val = value; |
468 | 567 | if (Scene != null | |
469 | if (Scene != null) | 568 | && !Scene.PositionIsInCurrentRegion(val) |
569 | && !IsAttachmentCheckFull() | ||
570 | && !Scene.LoadingPrims | ||
571 | ) | ||
470 | { | 572 | { |
573 | <<<<<<< HEAD | ||
471 | if ( | 574 | if ( |
472 | !Scene.PositionIsInCurrentRegion(val) | 575 | !Scene.PositionIsInCurrentRegion(val) |
473 | && !IsAttachmentCheckFull() | 576 | && !IsAttachmentCheckFull() |
@@ -600,7 +703,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
600 | val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)m_scene.RegionInfo.RegionSizeX - 0.5f); | 703 | val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)m_scene.RegionInfo.RegionSizeX - 0.5f); |
601 | val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)m_scene.RegionInfo.RegionSizeY - 0.5f); | 704 | val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)m_scene.RegionInfo.RegionSizeY - 0.5f); |
602 | val.Z = Util.Clamp<float>(oldp.Z, 0.5f, Constants.RegionHeight); | 705 | val.Z = Util.Clamp<float>(oldp.Z, 0.5f, Constants.RegionHeight); |
706 | ======= | ||
707 | if (!inTransit) | ||
708 | { | ||
709 | inTransit = true; | ||
710 | SOGCrossDelegate d = CrossAsync; | ||
711 | d.BeginInvoke(this, val, CrossAsyncCompleted, d); | ||
712 | >>>>>>> avn/ubitvar | ||
603 | } | 713 | } |
714 | return; | ||
604 | } | 715 | } |
605 | 716 | ||
606 | if (RootPart.GetStatusSandbox()) | 717 | if (RootPart.GetStatusSandbox()) |
@@ -608,38 +719,235 @@ namespace OpenSim.Region.Framework.Scenes | |||
608 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) | 719 | if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10) |
609 | { | 720 | { |
610 | RootPart.ScriptSetPhysicsStatus(false); | 721 | RootPart.ScriptSetPhysicsStatus(false); |
611 | 722 | ||
612 | if (Scene != null) | 723 | if (Scene != null) |
613 | Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), | 724 | Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), |
614 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); | 725 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); |
615 | 726 | ||
616 | return; | 727 | return; |
617 | } | 728 | } |
618 | } | 729 | } |
619 | 730 | ||
620 | // Restuff the new GroupPosition into each SOP of the linkset. | 731 | bool triggerScriptEvent = m_rootPart.GroupPosition != val; |
621 | // This has the affect of resetting and tainting the physics actors. | 732 | if (m_dupeInProgress || IsDeleted) |
733 | triggerScriptEvent = false; | ||
734 | |||
735 | m_rootPart.GroupPosition = val; | ||
736 | |||
737 | // Restuff the new GroupPosition into each child SOP of the linkset. | ||
738 | // this is needed because physics may not have linksets but just loose SOPs in world | ||
739 | |||
622 | SceneObjectPart[] parts = m_parts.GetArray(); | 740 | SceneObjectPart[] parts = m_parts.GetArray(); |
623 | for (int i = 0; i < parts.Length; i++) | ||
624 | parts[i].GroupPosition = val; | ||
625 | 741 | ||
626 | //if (m_rootPart.PhysActor != null) | 742 | foreach (SceneObjectPart part in parts) |
627 | //{ | 743 | { |
628 | //m_rootPart.PhysActor.Position = | 744 | if (part != m_rootPart) |
629 | //new PhysicsVector(m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y, | 745 | part.GroupPosition = val; |
630 | //m_rootPart.GroupPosition.Z); | 746 | } |
631 | //m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 747 | |
632 | //} | 748 | foreach (ScenePresence av in m_linkedAvatars) |
633 | 749 | { | |
750 | av.sitSOGmoved(); | ||
751 | } | ||
752 | |||
753 | |||
754 | // now that position is changed tell it to scripts | ||
755 | if (triggerScriptEvent) | ||
756 | { | ||
757 | foreach (SceneObjectPart part in parts) | ||
758 | { | ||
759 | part.TriggerScriptChangedEvent(Changed.POSITION); | ||
760 | } | ||
761 | } | ||
762 | |||
634 | if (Scene != null) | 763 | if (Scene != null) |
635 | Scene.EventManager.TriggerParcelPrimCountTainted(); | 764 | Scene.EventManager.TriggerParcelPrimCountTainted(); |
765 | |||
636 | } | 766 | } |
637 | } | 767 | } |
638 | 768 | ||
639 | public override Vector3 Velocity | 769 | public SceneObjectGroup CrossAsync(SceneObjectGroup sog, Vector3 val) |
640 | { | 770 | { |
641 | get { return RootPart.Velocity; } | 771 | Scene sogScene = sog.m_scene; |
642 | set { RootPart.Velocity = value; } | 772 | IEntityTransferModule entityTransfer = sogScene.RequestModuleInterface<IEntityTransferModule>(); |
773 | |||
774 | Vector3 newpos = Vector3.Zero; | ||
775 | OpenSim.Services.Interfaces.GridRegion destination = null; | ||
776 | |||
777 | if (sog.RootPart.DIE_AT_EDGE) | ||
778 | { | ||
779 | try | ||
780 | { | ||
781 | sogScene.DeleteSceneObject(sog, false); | ||
782 | } | ||
783 | catch (Exception) | ||
784 | { | ||
785 | m_log.Warn("[SCENE]: exception when trying to remove the prim that crossed the border."); | ||
786 | } | ||
787 | return sog; | ||
788 | } | ||
789 | |||
790 | if (sog.RootPart.RETURN_AT_EDGE) | ||
791 | { | ||
792 | // We remove the object here | ||
793 | try | ||
794 | { | ||
795 | List<uint> localIDs = new List<uint>(); | ||
796 | localIDs.Add(sog.RootPart.LocalId); | ||
797 | sogScene.AddReturn(sog.OwnerID, sog.Name, sog.AbsolutePosition, | ||
798 | "Returned at region cross"); | ||
799 | sogScene.DeRezObjects(null, localIDs, UUID.Zero, DeRezAction.Return, UUID.Zero); | ||
800 | } | ||
801 | catch (Exception) | ||
802 | { | ||
803 | m_log.Warn("[SCENE]: exception when trying to return the prim that crossed the border."); | ||
804 | } | ||
805 | return sog; | ||
806 | } | ||
807 | |||
808 | if (sog.m_rootPart.KeyframeMotion != null) | ||
809 | sog.m_rootPart.KeyframeMotion.StartCrossingCheck(); | ||
810 | |||
811 | if (entityTransfer == null) | ||
812 | return sog; | ||
813 | |||
814 | destination = entityTransfer.GetObjectDestination(sog, val, out newpos); | ||
815 | if (destination == null) | ||
816 | return sog; | ||
817 | |||
818 | if (sog.m_linkedAvatars.Count == 0) | ||
819 | { | ||
820 | entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true); | ||
821 | return sog; | ||
822 | } | ||
823 | |||
824 | string reason = String.Empty; | ||
825 | string version = String.Empty; | ||
826 | |||
827 | foreach (ScenePresence av in sog.m_linkedAvatars) | ||
828 | { | ||
829 | // We need to cross these agents. First, let's find | ||
830 | // out if any of them can't cross for some reason. | ||
831 | // We have to deny the crossing entirely if any | ||
832 | // of them are banned. Alternatively, we could | ||
833 | // unsit banned agents.... | ||
834 | |||
835 | // We set the avatar position as being the object | ||
836 | // position to get the region to send to | ||
837 | if(!entityTransfer.checkAgentAccessToRegion(av, destination, newpos, out version, out reason)) | ||
838 | { | ||
839 | return sog; | ||
840 | } | ||
841 | m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName); | ||
842 | } | ||
843 | |||
844 | // We unparent the SP quietly so that it won't | ||
845 | // be made to stand up | ||
846 | |||
847 | List<avtocrossInfo> avsToCross = new List<avtocrossInfo>(); | ||
848 | |||
849 | foreach (ScenePresence av in sog.m_linkedAvatars) | ||
850 | { | ||
851 | avtocrossInfo avinfo = new avtocrossInfo(); | ||
852 | SceneObjectPart parentPart = sogScene.GetSceneObjectPart(av.ParentID); | ||
853 | if (parentPart != null) | ||
854 | av.ParentUUID = parentPart.UUID; | ||
855 | |||
856 | avinfo.av = av; | ||
857 | avinfo.ParentID = av.ParentID; | ||
858 | avsToCross.Add(avinfo); | ||
859 | |||
860 | av.PrevSitOffset = av.OffsetPosition; | ||
861 | av.ParentID = 0; | ||
862 | } | ||
863 | |||
864 | if (entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true)) | ||
865 | { | ||
866 | foreach (avtocrossInfo avinfo in avsToCross) | ||
867 | { | ||
868 | ScenePresence av = avinfo.av; | ||
869 | if (!av.IsInTransit) // just in case... | ||
870 | { | ||
871 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val); | ||
872 | |||
873 | av.IsInTransit = true; | ||
874 | |||
875 | // CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync; | ||
876 | // d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d); | ||
877 | entityTransfer.CrossAgentToNewRegionAsync(av, newpos, destination, av.Flying, version); | ||
878 | if(av.IsChildAgent) | ||
879 | { | ||
880 | if (av.ParentUUID != UUID.Zero) | ||
881 | { | ||
882 | av.ClearControls(); | ||
883 | av.ParentPart = null; | ||
884 | } | ||
885 | } | ||
886 | av.ParentUUID = UUID.Zero; | ||
887 | // In any case | ||
888 | av.IsInTransit = false; | ||
889 | |||
890 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", av.Firstname, av.Lastname); | ||
891 | } | ||
892 | else | ||
893 | m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar already in transit {0} to {1}", av.Name, val); | ||
894 | } | ||
895 | avsToCross.Clear(); | ||
896 | return sog; | ||
897 | } | ||
898 | else // cross failed, put avas back ?? | ||
899 | { | ||
900 | foreach (avtocrossInfo avinfo in avsToCross) | ||
901 | { | ||
902 | ScenePresence av = avinfo.av; | ||
903 | av.ParentUUID = UUID.Zero; | ||
904 | av.ParentID = avinfo.ParentID; | ||
905 | } | ||
906 | } | ||
907 | avsToCross.Clear(); | ||
908 | |||
909 | return sog; | ||
910 | } | ||
911 | |||
912 | public void CrossAsyncCompleted(IAsyncResult iar) | ||
913 | { | ||
914 | SOGCrossDelegate icon = (SOGCrossDelegate)iar.AsyncState; | ||
915 | SceneObjectGroup sog = icon.EndInvoke(iar); | ||
916 | |||
917 | if (!sog.IsDeleted) | ||
918 | { | ||
919 | SceneObjectPart rootp = sog.m_rootPart; | ||
920 | Vector3 oldp = rootp.GroupPosition; | ||
921 | oldp.X = Util.Clamp<float>(oldp.X, 0.5f, sog.m_scene.RegionInfo.RegionSizeX - 0.5f); | ||
922 | oldp.Y = Util.Clamp<float>(oldp.Y, 0.5f, sog.m_scene.RegionInfo.RegionSizeY - 0.5f); | ||
923 | rootp.GroupPosition = oldp; | ||
924 | |||
925 | SceneObjectPart[] parts = sog.m_parts.GetArray(); | ||
926 | |||
927 | foreach (SceneObjectPart part in parts) | ||
928 | { | ||
929 | if (part != rootp) | ||
930 | part.GroupPosition = oldp; | ||
931 | } | ||
932 | |||
933 | foreach (ScenePresence av in sog.m_linkedAvatars) | ||
934 | { | ||
935 | av.sitSOGmoved(); | ||
936 | } | ||
937 | |||
938 | sog.Velocity = Vector3.Zero; | ||
939 | |||
940 | if (sog.m_rootPart.KeyframeMotion != null) | ||
941 | sog.m_rootPart.KeyframeMotion.CrossingFailure(); | ||
942 | |||
943 | if (sog.RootPart.PhysActor != null) | ||
944 | { | ||
945 | sog.RootPart.PhysActor.CrossingFailure(); | ||
946 | } | ||
947 | |||
948 | sog.inTransit = false; | ||
949 | sog.ScheduleGroupForFullUpdate(); | ||
950 | } | ||
643 | } | 951 | } |
644 | 952 | ||
645 | private void CrossAgentToNewRegionCompleted(ScenePresence agent) | 953 | private void CrossAgentToNewRegionCompleted(ScenePresence agent) |
@@ -649,6 +957,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
649 | { | 957 | { |
650 | if (agent.ParentUUID != UUID.Zero) | 958 | if (agent.ParentUUID != UUID.Zero) |
651 | { | 959 | { |
960 | agent.HandleForceReleaseControls(agent.ControllingClient,agent.UUID); | ||
652 | agent.ParentPart = null; | 961 | agent.ParentPart = null; |
653 | // agent.ParentPosition = Vector3.Zero; | 962 | // agent.ParentPosition = Vector3.Zero; |
654 | // agent.ParentUUID = UUID.Zero; | 963 | // agent.ParentUUID = UUID.Zero; |
@@ -666,6 +975,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
666 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | 975 | m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); |
667 | } | 976 | } |
668 | 977 | ||
978 | public override Vector3 Velocity | ||
979 | { | ||
980 | get { return RootPart.Velocity; } | ||
981 | set { RootPart.Velocity = value; } | ||
982 | } | ||
983 | |||
669 | public override uint LocalId | 984 | public override uint LocalId |
670 | { | 985 | { |
671 | get { return m_rootPart.LocalId; } | 986 | get { return m_rootPart.LocalId; } |
@@ -740,6 +1055,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
740 | m_isSelected = value; | 1055 | m_isSelected = value; |
741 | // Tell physics engine that group is selected | 1056 | // Tell physics engine that group is selected |
742 | 1057 | ||
1058 | // this is not right | ||
1059 | // but ode engines should only really need to know about root part | ||
1060 | // so they can put entire object simulation on hold and not colliding | ||
1061 | // keep as was for now | ||
1062 | |||
743 | PhysicsActor pa = m_rootPart.PhysActor; | 1063 | PhysicsActor pa = m_rootPart.PhysActor; |
744 | if (pa != null) | 1064 | if (pa != null) |
745 | { | 1065 | { |
@@ -761,13 +1081,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
761 | } | 1081 | } |
762 | } | 1082 | } |
763 | 1083 | ||
1084 | public void PartSelectChanged(bool partSelect) | ||
1085 | { | ||
1086 | // any part selected makes group selected | ||
1087 | if (m_isSelected == partSelect) | ||
1088 | return; | ||
1089 | |||
1090 | if (partSelect) | ||
1091 | { | ||
1092 | IsSelected = partSelect; | ||
1093 | // if (!IsAttachment) | ||
1094 | // ScheduleGroupForFullUpdate(); | ||
1095 | } | ||
1096 | else | ||
1097 | { | ||
1098 | // bad bad bad 2 heavy for large linksets | ||
1099 | // since viewer does send lot of (un)selects | ||
1100 | // this needs to be replaced by a specific list or count ? | ||
1101 | // but that will require extra code in several places | ||
1102 | |||
1103 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
1104 | for (int i = 0; i < parts.Length; i++) | ||
1105 | { | ||
1106 | SceneObjectPart part = parts[i]; | ||
1107 | if (part.IsSelected) | ||
1108 | return; | ||
1109 | } | ||
1110 | IsSelected = partSelect; | ||
1111 | // if (!IsAttachment) | ||
1112 | // { | ||
1113 | // ScheduleGroupForFullUpdate(); | ||
1114 | // } | ||
1115 | } | ||
1116 | } | ||
1117 | // PlaySoundMasterPrim no longer in use to remove | ||
764 | private SceneObjectPart m_PlaySoundMasterPrim = null; | 1118 | private SceneObjectPart m_PlaySoundMasterPrim = null; |
765 | public SceneObjectPart PlaySoundMasterPrim | 1119 | public SceneObjectPart PlaySoundMasterPrim |
766 | { | 1120 | { |
767 | get { return m_PlaySoundMasterPrim; } | 1121 | get { return m_PlaySoundMasterPrim; } |
768 | set { m_PlaySoundMasterPrim = value; } | 1122 | set { m_PlaySoundMasterPrim = value; } |
769 | } | 1123 | } |
770 | 1124 | // PlaySoundSlavePrims no longer in use to remove | |
771 | private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); | 1125 | private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); |
772 | public List<SceneObjectPart> PlaySoundSlavePrims | 1126 | public List<SceneObjectPart> PlaySoundSlavePrims |
773 | { | 1127 | { |
@@ -775,6 +1129,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
775 | set { m_PlaySoundSlavePrims = value; } | 1129 | set { m_PlaySoundSlavePrims = value; } |
776 | } | 1130 | } |
777 | 1131 | ||
1132 | // LoopSoundMasterPrim no longer in use to remove | ||
778 | private SceneObjectPart m_LoopSoundMasterPrim = null; | 1133 | private SceneObjectPart m_LoopSoundMasterPrim = null; |
779 | public SceneObjectPart LoopSoundMasterPrim | 1134 | public SceneObjectPart LoopSoundMasterPrim |
780 | { | 1135 | { |
@@ -782,6 +1137,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
782 | set { m_LoopSoundMasterPrim = value; } | 1137 | set { m_LoopSoundMasterPrim = value; } |
783 | } | 1138 | } |
784 | 1139 | ||
1140 | // m_LoopSoundSlavePrims no longer in use to remove | ||
785 | private List<SceneObjectPart> m_LoopSoundSlavePrims = new List<SceneObjectPart>(); | 1141 | private List<SceneObjectPart> m_LoopSoundSlavePrims = new List<SceneObjectPart>(); |
786 | public List<SceneObjectPart> LoopSoundSlavePrims | 1142 | public List<SceneObjectPart> LoopSoundSlavePrims |
787 | { | 1143 | { |
@@ -861,6 +1217,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
861 | /// </summary> | 1217 | /// </summary> |
862 | public SceneObjectGroup() | 1218 | public SceneObjectGroup() |
863 | { | 1219 | { |
1220 | |||
864 | } | 1221 | } |
865 | 1222 | ||
866 | /// <summary> | 1223 | /// <summary> |
@@ -878,8 +1235,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
878 | /// Constructor. This object is added to the scene later via AttachToScene() | 1235 | /// Constructor. This object is added to the scene later via AttachToScene() |
879 | /// </summary> | 1236 | /// </summary> |
880 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) | 1237 | public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) |
881 | :this(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)) | 1238 | { |
882 | { | 1239 | SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); |
883 | } | 1240 | } |
884 | 1241 | ||
885 | /// <summary> | 1242 | /// <summary> |
@@ -954,7 +1311,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
954 | /// </summary> | 1311 | /// </summary> |
955 | public virtual void AttachToBackup() | 1312 | public virtual void AttachToBackup() |
956 | { | 1313 | { |
1314 | <<<<<<< HEAD | ||
957 | if (CanBeBackedUp) | 1315 | if (CanBeBackedUp) |
1316 | ======= | ||
1317 | if (IsAttachment) return; | ||
1318 | m_scene.SceneGraph.FireAttachToBackup(this); | ||
1319 | |||
1320 | if (InSceneBackup) | ||
1321 | >>>>>>> avn/ubitvar | ||
958 | { | 1322 | { |
959 | // m_log.DebugFormat( | 1323 | // m_log.DebugFormat( |
960 | // "[SCENE OBJECT GROUP]: Attaching object {0} {1} to scene presistence sweep", Name, UUID); | 1324 | // "[SCENE OBJECT GROUP]: Attaching object {0} {1} to scene presistence sweep", Name, UUID); |
@@ -1001,6 +1365,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1001 | 1365 | ||
1002 | ApplyPhysics(); | 1366 | ApplyPhysics(); |
1003 | 1367 | ||
1368 | if (RootPart.PhysActor != null) | ||
1369 | RootPart.Force = RootPart.Force; | ||
1370 | if (RootPart.PhysActor != null) | ||
1371 | RootPart.Torque = RootPart.Torque; | ||
1372 | if (RootPart.PhysActor != null) | ||
1373 | RootPart.Buoyancy = RootPart.Buoyancy; | ||
1374 | |||
1004 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | 1375 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
1005 | // for the same object with very different properties. The caller must schedule the update. | 1376 | // for the same object with very different properties. The caller must schedule the update. |
1006 | //ScheduleGroupForFullUpdate(); | 1377 | //ScheduleGroupForFullUpdate(); |
@@ -1016,6 +1387,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1016 | EntityIntersection result = new EntityIntersection(); | 1387 | EntityIntersection result = new EntityIntersection(); |
1017 | 1388 | ||
1018 | SceneObjectPart[] parts = m_parts.GetArray(); | 1389 | SceneObjectPart[] parts = m_parts.GetArray(); |
1390 | |||
1391 | // Find closest hit here | ||
1392 | float idist = float.MaxValue; | ||
1393 | |||
1019 | for (int i = 0; i < parts.Length; i++) | 1394 | for (int i = 0; i < parts.Length; i++) |
1020 | { | 1395 | { |
1021 | SceneObjectPart part = parts[i]; | 1396 | SceneObjectPart part = parts[i]; |
@@ -1030,11 +1405,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1030 | 1405 | ||
1031 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); | 1406 | EntityIntersection inter = part.TestIntersectionOBB(hRay, parentrotation, frontFacesOnly, faceCenters); |
1032 | 1407 | ||
1033 | // This may need to be updated to the maximum draw distance possible.. | ||
1034 | // We might (and probably will) be checking for prim creation from other sims | ||
1035 | // when the camera crosses the border. | ||
1036 | float idist = Constants.RegionSize; | ||
1037 | |||
1038 | if (inter.HitTF) | 1408 | if (inter.HitTF) |
1039 | { | 1409 | { |
1040 | // We need to find the closest prim to return to the testcaller along the ray | 1410 | // We need to find the closest prim to return to the testcaller along the ray |
@@ -1045,10 +1415,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1045 | result.obj = part; | 1415 | result.obj = part; |
1046 | result.normal = inter.normal; | 1416 | result.normal = inter.normal; |
1047 | result.distance = inter.distance; | 1417 | result.distance = inter.distance; |
1418 | |||
1419 | idist = inter.distance; | ||
1048 | } | 1420 | } |
1049 | } | 1421 | } |
1050 | } | 1422 | } |
1051 | |||
1052 | return result; | 1423 | return result; |
1053 | } | 1424 | } |
1054 | 1425 | ||
@@ -1060,25 +1431,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
1060 | /// <returns></returns> | 1431 | /// <returns></returns> |
1061 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) | 1432 | public void GetAxisAlignedBoundingBoxRaw(out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) |
1062 | { | 1433 | { |
1434 | <<<<<<< HEAD | ||
1063 | maxX = -256f; | 1435 | maxX = -256f; |
1064 | maxY = -256f; | 1436 | maxY = -256f; |
1065 | maxZ = -256f; | 1437 | maxZ = -256f; |
1066 | minX = 10000f; | 1438 | minX = 10000f; |
1067 | minY = 10000f; | 1439 | minY = 10000f; |
1068 | minZ = 10000f; | 1440 | minZ = 10000f; |
1441 | ======= | ||
1442 | maxX = float.MinValue; | ||
1443 | maxY = float.MinValue; | ||
1444 | maxZ = float.MinValue; | ||
1445 | minX = float.MaxValue; | ||
1446 | minY = float.MaxValue; | ||
1447 | minZ = float.MaxValue; | ||
1448 | >>>>>>> avn/ubitvar | ||
1069 | 1449 | ||
1070 | SceneObjectPart[] parts = m_parts.GetArray(); | 1450 | SceneObjectPart[] parts = m_parts.GetArray(); |
1071 | for (int i = 0; i < parts.Length; i++) | 1451 | foreach (SceneObjectPart part in parts) |
1072 | { | 1452 | { |
1073 | SceneObjectPart part = parts[i]; | ||
1074 | |||
1075 | Vector3 worldPos = part.GetWorldPosition(); | 1453 | Vector3 worldPos = part.GetWorldPosition(); |
1076 | Vector3 offset = worldPos - AbsolutePosition; | 1454 | Vector3 offset = worldPos - AbsolutePosition; |
1077 | Quaternion worldRot; | 1455 | Quaternion worldRot; |
1078 | if (part.ParentID == 0) | 1456 | if (part.ParentID == 0) |
1457 | { | ||
1079 | worldRot = part.RotationOffset; | 1458 | worldRot = part.RotationOffset; |
1459 | } | ||
1080 | else | 1460 | else |
1461 | { | ||
1081 | worldRot = part.GetWorldRotation(); | 1462 | worldRot = part.GetWorldRotation(); |
1463 | } | ||
1082 | 1464 | ||
1083 | Vector3 frontTopLeft; | 1465 | Vector3 frontTopLeft; |
1084 | Vector3 frontTopRight; | 1466 | Vector3 frontTopRight; |
@@ -1090,6 +1472,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1090 | Vector3 backBottomLeft; | 1472 | Vector3 backBottomLeft; |
1091 | Vector3 backBottomRight; | 1473 | Vector3 backBottomRight; |
1092 | 1474 | ||
1475 | // Vector3[] corners = new Vector3[8]; | ||
1476 | |||
1093 | Vector3 orig = Vector3.Zero; | 1477 | Vector3 orig = Vector3.Zero; |
1094 | 1478 | ||
1095 | frontTopLeft.X = orig.X - (part.Scale.X / 2); | 1479 | frontTopLeft.X = orig.X - (part.Scale.X / 2); |
@@ -1124,6 +1508,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
1124 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); | 1508 | backBottomRight.Y = orig.Y + (part.Scale.Y / 2); |
1125 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); | 1509 | backBottomRight.Z = orig.Z - (part.Scale.Z / 2); |
1126 | 1510 | ||
1511 | |||
1512 | |||
1513 | //m_log.InfoFormat("pre corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1514 | //m_log.InfoFormat("pre corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1515 | //m_log.InfoFormat("pre corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1516 | //m_log.InfoFormat("pre corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1517 | //m_log.InfoFormat("pre corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1518 | //m_log.InfoFormat("pre corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1519 | //m_log.InfoFormat("pre corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1520 | //m_log.InfoFormat("pre corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1521 | |||
1522 | //for (int i = 0; i < 8; i++) | ||
1523 | //{ | ||
1524 | // corners[i] = corners[i] * worldRot; | ||
1525 | // corners[i] += offset; | ||
1526 | |||
1527 | // if (corners[i].X > maxX) | ||
1528 | // maxX = corners[i].X; | ||
1529 | // if (corners[i].X < minX) | ||
1530 | // minX = corners[i].X; | ||
1531 | |||
1532 | // if (corners[i].Y > maxY) | ||
1533 | // maxY = corners[i].Y; | ||
1534 | // if (corners[i].Y < minY) | ||
1535 | // minY = corners[i].Y; | ||
1536 | |||
1537 | // if (corners[i].Z > maxZ) | ||
1538 | // maxZ = corners[i].Y; | ||
1539 | // if (corners[i].Z < minZ) | ||
1540 | // minZ = corners[i].Z; | ||
1541 | //} | ||
1542 | |||
1127 | frontTopLeft = frontTopLeft * worldRot; | 1543 | frontTopLeft = frontTopLeft * worldRot; |
1128 | frontTopRight = frontTopRight * worldRot; | 1544 | frontTopRight = frontTopRight * worldRot; |
1129 | frontBottomLeft = frontBottomLeft * worldRot; | 1545 | frontBottomLeft = frontBottomLeft * worldRot; |
@@ -1145,6 +1561,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1145 | backTopLeft += offset; | 1561 | backTopLeft += offset; |
1146 | backTopRight += offset; | 1562 | backTopRight += offset; |
1147 | 1563 | ||
1564 | //m_log.InfoFormat("corner 1 is {0} {1} {2}", frontTopLeft.X, frontTopLeft.Y, frontTopLeft.Z); | ||
1565 | //m_log.InfoFormat("corner 2 is {0} {1} {2}", frontTopRight.X, frontTopRight.Y, frontTopRight.Z); | ||
1566 | //m_log.InfoFormat("corner 3 is {0} {1} {2}", frontBottomRight.X, frontBottomRight.Y, frontBottomRight.Z); | ||
1567 | //m_log.InfoFormat("corner 4 is {0} {1} {2}", frontBottomLeft.X, frontBottomLeft.Y, frontBottomLeft.Z); | ||
1568 | //m_log.InfoFormat("corner 5 is {0} {1} {2}", backTopLeft.X, backTopLeft.Y, backTopLeft.Z); | ||
1569 | //m_log.InfoFormat("corner 6 is {0} {1} {2}", backTopRight.X, backTopRight.Y, backTopRight.Z); | ||
1570 | //m_log.InfoFormat("corner 7 is {0} {1} {2}", backBottomRight.X, backBottomRight.Y, backBottomRight.Z); | ||
1571 | //m_log.InfoFormat("corner 8 is {0} {1} {2}", backBottomLeft.X, backBottomLeft.Y, backBottomLeft.Z); | ||
1572 | |||
1148 | if (frontTopRight.X > maxX) | 1573 | if (frontTopRight.X > maxX) |
1149 | maxX = frontTopRight.X; | 1574 | maxX = frontTopRight.X; |
1150 | if (frontTopLeft.X > maxX) | 1575 | if (frontTopLeft.X > maxX) |
@@ -1288,17 +1713,118 @@ namespace OpenSim.Region.Framework.Scenes | |||
1288 | 1713 | ||
1289 | #endregion | 1714 | #endregion |
1290 | 1715 | ||
1716 | public void GetResourcesCosts(SceneObjectPart apart, | ||
1717 | out float linksetResCost, out float linksetPhysCost, out float partCost, out float partPhysCost) | ||
1718 | { | ||
1719 | // this information may need to be cached | ||
1720 | |||
1721 | float cost; | ||
1722 | float tmpcost; | ||
1723 | |||
1724 | bool ComplexCost = false; | ||
1725 | |||
1726 | SceneObjectPart p; | ||
1727 | SceneObjectPart[] parts; | ||
1728 | |||
1729 | lock (m_parts) | ||
1730 | { | ||
1731 | parts = m_parts.GetArray(); | ||
1732 | } | ||
1733 | |||
1734 | int nparts = parts.Length; | ||
1735 | |||
1736 | |||
1737 | for (int i = 0; i < nparts; i++) | ||
1738 | { | ||
1739 | p = parts[i]; | ||
1740 | |||
1741 | if (p.UsesComplexCost) | ||
1742 | { | ||
1743 | ComplexCost = true; | ||
1744 | break; | ||
1745 | } | ||
1746 | } | ||
1747 | |||
1748 | if (ComplexCost) | ||
1749 | { | ||
1750 | linksetResCost = 0; | ||
1751 | linksetPhysCost = 0; | ||
1752 | partCost = 0; | ||
1753 | partPhysCost = 0; | ||
1754 | |||
1755 | for (int i = 0; i < nparts; i++) | ||
1756 | { | ||
1757 | p = parts[i]; | ||
1758 | |||
1759 | cost = p.StreamingCost; | ||
1760 | tmpcost = p.SimulationCost; | ||
1761 | if (tmpcost > cost) | ||
1762 | cost = tmpcost; | ||
1763 | tmpcost = p.PhysicsCost; | ||
1764 | if (tmpcost > cost) | ||
1765 | cost = tmpcost; | ||
1766 | |||
1767 | linksetPhysCost += tmpcost; | ||
1768 | linksetResCost += cost; | ||
1769 | |||
1770 | if (p == apart) | ||
1771 | { | ||
1772 | partCost = cost; | ||
1773 | partPhysCost = tmpcost; | ||
1774 | } | ||
1775 | } | ||
1776 | } | ||
1777 | else | ||
1778 | { | ||
1779 | partPhysCost = 1.0f; | ||
1780 | partCost = 1.0f; | ||
1781 | linksetResCost = (float)nparts; | ||
1782 | linksetPhysCost = linksetResCost; | ||
1783 | } | ||
1784 | } | ||
1785 | |||
1786 | public void GetSelectedCosts(out float PhysCost, out float StreamCost, out float SimulCost) | ||
1787 | { | ||
1788 | SceneObjectPart p; | ||
1789 | SceneObjectPart[] parts; | ||
1790 | |||
1791 | lock (m_parts) | ||
1792 | { | ||
1793 | parts = m_parts.GetArray(); | ||
1794 | } | ||
1795 | |||
1796 | int nparts = parts.Length; | ||
1797 | |||
1798 | PhysCost = 0; | ||
1799 | StreamCost = 0; | ||
1800 | SimulCost = 0; | ||
1801 | |||
1802 | for (int i = 0; i < nparts; i++) | ||
1803 | { | ||
1804 | p = parts[i]; | ||
1805 | |||
1806 | StreamCost += p.StreamingCost; | ||
1807 | SimulCost += p.SimulationCost; | ||
1808 | PhysCost += p.PhysicsCost; | ||
1809 | } | ||
1810 | } | ||
1811 | |||
1291 | public void SaveScriptedState(XmlTextWriter writer) | 1812 | public void SaveScriptedState(XmlTextWriter writer) |
1292 | { | 1813 | { |
1814 | SaveScriptedState(writer, false); | ||
1815 | } | ||
1816 | |||
1817 | public void SaveScriptedState(XmlTextWriter writer, bool oldIDs) | ||
1818 | { | ||
1293 | XmlDocument doc = new XmlDocument(); | 1819 | XmlDocument doc = new XmlDocument(); |
1294 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); | 1820 | Dictionary<UUID,string> states = new Dictionary<UUID,string>(); |
1295 | 1821 | ||
1296 | SceneObjectPart[] parts = m_parts.GetArray(); | 1822 | SceneObjectPart[] parts = m_parts.GetArray(); |
1297 | for (int i = 0; i < parts.Length; i++) | 1823 | for (int i = 0; i < parts.Length; i++) |
1298 | { | 1824 | { |
1299 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(); | 1825 | Dictionary<UUID, string> pstates = parts[i].Inventory.GetScriptStates(oldIDs); |
1300 | foreach (KeyValuePair<UUID, string> kvp in pstates) | 1826 | foreach (KeyValuePair<UUID, string> kvp in pstates) |
1301 | states.Add(kvp.Key, kvp.Value); | 1827 | states[kvp.Key] = kvp.Value; |
1302 | } | 1828 | } |
1303 | 1829 | ||
1304 | if (states.Count > 0) | 1830 | if (states.Count > 0) |
@@ -1317,6 +1843,183 @@ namespace OpenSim.Region.Framework.Scenes | |||
1317 | } | 1843 | } |
1318 | } | 1844 | } |
1319 | 1845 | ||
1846 | <<<<<<< HEAD | ||
1847 | |||
1848 | /// <summary> | ||
1849 | /// | ||
1850 | /// </summary> | ||
1851 | /// <param name="part"></param> | ||
1852 | private void SetPartAsNonRoot(SceneObjectPart part) | ||
1853 | { | ||
1854 | part.ParentID = m_rootPart.LocalId; | ||
1855 | part.ClearUndoState(); | ||
1856 | ======= | ||
1857 | /// <summary> | ||
1858 | /// Add the avatar to this linkset (avatar is sat). | ||
1859 | /// </summary> | ||
1860 | /// <param name="agentID"></param> | ||
1861 | public void AddAvatar(UUID agentID) | ||
1862 | { | ||
1863 | ScenePresence presence; | ||
1864 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1865 | { | ||
1866 | if (!m_linkedAvatars.Contains(presence)) | ||
1867 | { | ||
1868 | m_linkedAvatars.Add(presence); | ||
1869 | } | ||
1870 | } | ||
1871 | } | ||
1872 | |||
1873 | /// <summary> | ||
1874 | /// Delete the avatar from this linkset (avatar is unsat). | ||
1875 | /// </summary> | ||
1876 | /// <param name="agentID"></param> | ||
1877 | public void DeleteAvatar(UUID agentID) | ||
1878 | { | ||
1879 | ScenePresence presence; | ||
1880 | if (m_scene.TryGetScenePresence(agentID, out presence)) | ||
1881 | { | ||
1882 | if (m_linkedAvatars.Contains(presence)) | ||
1883 | { | ||
1884 | m_linkedAvatars.Remove(presence); | ||
1885 | } | ||
1886 | } | ||
1887 | } | ||
1888 | |||
1889 | /// <summary> | ||
1890 | /// Returns the list of linked presences (avatars sat on this group) | ||
1891 | /// </summary> | ||
1892 | /// <param name="agentID"></param> | ||
1893 | public List<ScenePresence> GetLinkedAvatars() | ||
1894 | { | ||
1895 | return m_linkedAvatars; | ||
1896 | >>>>>>> avn/ubitvar | ||
1897 | } | ||
1898 | |||
1899 | /// <summary> | ||
1900 | /// Attach this scene object to the given avatar. | ||
1901 | /// </summary> | ||
1902 | /// <param name="agentID"></param> | ||
1903 | /// <param name="attachmentpoint"></param> | ||
1904 | /// <param name="AttachOffset"></param> | ||
1905 | private void AttachToAgent( | ||
1906 | ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | ||
1907 | { | ||
1908 | if (avatar != null) | ||
1909 | { | ||
1910 | // don't attach attachments to child agents | ||
1911 | if (avatar.IsChildAgent) return; | ||
1912 | |||
1913 | // Remove from database and parcel prim count | ||
1914 | m_scene.DeleteFromStorage(so.UUID); | ||
1915 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1916 | |||
1917 | so.AttachedAvatar = avatar.UUID; | ||
1918 | |||
1919 | if (so.RootPart.PhysActor != null) | ||
1920 | { | ||
1921 | m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor); | ||
1922 | so.RootPart.PhysActor = null; | ||
1923 | } | ||
1924 | |||
1925 | so.AbsolutePosition = attachOffset; | ||
1926 | so.RootPart.AttachedPos = attachOffset; | ||
1927 | so.IsAttachment = true; | ||
1928 | so.RootPart.SetParentLocalId(avatar.LocalId); | ||
1929 | so.AttachmentPoint = attachmentpoint; | ||
1930 | |||
1931 | avatar.AddAttachment(this); | ||
1932 | |||
1933 | if (!silent) | ||
1934 | { | ||
1935 | // Killing it here will cause the client to deselect it | ||
1936 | // It then reappears on the avatar, deselected | ||
1937 | // through the full update below | ||
1938 | // | ||
1939 | if (IsSelected) | ||
1940 | { | ||
1941 | m_scene.SendKillObject(new List<uint> { m_rootPart.LocalId }); | ||
1942 | } | ||
1943 | |||
1944 | IsSelected = false; // fudge.... | ||
1945 | ScheduleGroupForFullUpdate(); | ||
1946 | } | ||
1947 | } | ||
1948 | else | ||
1949 | { | ||
1950 | m_log.WarnFormat( | ||
1951 | "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", | ||
1952 | UUID, avatar.ControllingClient.AgentId, Scene.RegionInfo.RegionName); | ||
1953 | } | ||
1954 | } | ||
1955 | |||
1956 | public byte GetAttachmentPoint() | ||
1957 | { | ||
1958 | return m_rootPart.Shape.State; | ||
1959 | } | ||
1960 | |||
1961 | public void DetachToGround() | ||
1962 | { | ||
1963 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
1964 | if (avatar == null) | ||
1965 | return; | ||
1966 | m_rootPart.Shape.LastAttachPoint = m_rootPart.Shape.State; | ||
1967 | m_rootPart.AttachedPos = m_rootPart.OffsetPosition; | ||
1968 | avatar.RemoveAttachment(this); | ||
1969 | |||
1970 | Vector3 detachedpos = new Vector3(127f,127f,127f); | ||
1971 | if (avatar == null) | ||
1972 | return; | ||
1973 | |||
1974 | detachedpos = avatar.AbsolutePosition; | ||
1975 | FromItemID = UUID.Zero; | ||
1976 | |||
1977 | AbsolutePosition = detachedpos; | ||
1978 | AttachedAvatar = UUID.Zero; | ||
1979 | |||
1980 | //SceneObjectPart[] parts = m_parts.GetArray(); | ||
1981 | //for (int i = 0; i < parts.Length; i++) | ||
1982 | // parts[i].AttachedAvatar = UUID.Zero; | ||
1983 | |||
1984 | m_rootPart.SetParentLocalId(0); | ||
1985 | AttachmentPoint = (byte)0; | ||
1986 | // must check if buildind should be true or false here | ||
1987 | // m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive,false); | ||
1988 | ApplyPhysics(); | ||
1989 | |||
1990 | HasGroupChanged = true; | ||
1991 | RootPart.Rezzed = DateTime.Now; | ||
1992 | RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
1993 | AttachToBackup(); | ||
1994 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | ||
1995 | m_rootPart.ScheduleFullUpdate(); | ||
1996 | m_rootPart.ClearUndoState(); | ||
1997 | } | ||
1998 | |||
1999 | public void DetachToInventoryPrep() | ||
2000 | { | ||
2001 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | ||
2002 | //Vector3 detachedpos = new Vector3(127f, 127f, 127f); | ||
2003 | if (avatar != null) | ||
2004 | { | ||
2005 | //detachedpos = avatar.AbsolutePosition; | ||
2006 | avatar.RemoveAttachment(this); | ||
2007 | } | ||
2008 | |||
2009 | AttachedAvatar = UUID.Zero; | ||
2010 | |||
2011 | /*SceneObjectPart[] parts = m_parts.GetArray(); | ||
2012 | for (int i = 0; i < parts.Length; i++) | ||
2013 | parts[i].AttachedAvatar = UUID.Zero;*/ | ||
2014 | |||
2015 | m_rootPart.SetParentLocalId(0); | ||
2016 | //m_rootPart.SetAttachmentPoint((byte)0); | ||
2017 | IsAttachment = false; | ||
2018 | AbsolutePosition = m_rootPart.AttachedPos; | ||
2019 | //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); | ||
2020 | //AttachToBackup(); | ||
2021 | //m_rootPart.ScheduleFullUpdate(); | ||
2022 | } | ||
1320 | 2023 | ||
1321 | /// <summary> | 2024 | /// <summary> |
1322 | /// | 2025 | /// |
@@ -1358,7 +2061,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1358 | public void AddPart(SceneObjectPart part) | 2061 | public void AddPart(SceneObjectPart part) |
1359 | { | 2062 | { |
1360 | part.SetParent(this); | 2063 | part.SetParent(this); |
1361 | part.LinkNum = m_parts.Add(part.UUID, part); | 2064 | m_parts.Add(part.UUID, part); |
2065 | |||
2066 | part.LinkNum = m_parts.Count; | ||
2067 | |||
1362 | if (part.LinkNum == 2) | 2068 | if (part.LinkNum == 2) |
1363 | RootPart.LinkNum = 1; | 2069 | RootPart.LinkNum = 1; |
1364 | } | 2070 | } |
@@ -1384,6 +2090,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1384 | parts[i].UUID = UUID.Random(); | 2090 | parts[i].UUID = UUID.Random(); |
1385 | } | 2091 | } |
1386 | 2092 | ||
2093 | // helper provided for parts. | ||
2094 | public int GetSceneMaxUndo() | ||
2095 | { | ||
2096 | if (m_scene != null) | ||
2097 | return m_scene.MaxUndoCount; | ||
2098 | return 5; | ||
2099 | } | ||
2100 | |||
1387 | // justincc: I don't believe this hack is needed any longer, especially since the physics | 2101 | // justincc: I don't believe this hack is needed any longer, especially since the physics |
1388 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false | 2102 | // parts of set AbsolutePosition were already commented out. By changing HasGroupChanged to false |
1389 | // this method was preventing proper reload of scene objects. | 2103 | // this method was preventing proper reload of scene objects. |
@@ -1405,11 +2119,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1405 | // Setting this SOG's absolute position also loops through and sets the positions | 2119 | // Setting this SOG's absolute position also loops through and sets the positions |
1406 | // of the SOP's in this SOG's linkset. This has the side affect of making sure | 2120 | // of the SOP's in this SOG's linkset. This has the side affect of making sure |
1407 | // the physics world matches the simulated world. | 2121 | // the physics world matches the simulated world. |
1408 | AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? | 2122 | // AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? |
1409 | 2123 | ||
1410 | // teravus: AbsolutePosition is NOT a normal property! | 2124 | // teravus: AbsolutePosition is NOT a normal property! |
1411 | // the code in the getter of AbsolutePosition is significantly different then the code in the setter! | 2125 | // the code in the getter of AbsolutePosition is significantly different then the code in the setter! |
1412 | // jhurliman: Then why is it a property instead of two methods? | 2126 | // jhurliman: Then why is it a property instead of two methods? |
2127 | |||
2128 | // do only what is supposed to do | ||
2129 | Vector3 groupPosition = m_rootPart.GroupPosition; | ||
2130 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
2131 | |||
2132 | foreach (SceneObjectPart part in parts) | ||
2133 | { | ||
2134 | if (part != m_rootPart) | ||
2135 | part.GroupPosition = groupPosition; | ||
2136 | } | ||
1413 | } | 2137 | } |
1414 | 2138 | ||
1415 | public UUID GetPartsFullID(uint localID) | 2139 | public UUID GetPartsFullID(uint localID) |
@@ -1441,7 +2165,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1441 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", | 2165 | // "[SCENE OBJECT GROUP]: Processing OnGrabPart for {0} on {1} {2}, offsetPos {3}", |
1442 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); | 2166 | // remoteClient.Name, part.Name, part.LocalId, offsetPos); |
1443 | 2167 | ||
1444 | part.StoreUndoState(); | 2168 | // part.StoreUndoState(); |
1445 | part.OnGrab(offsetPos, remoteClient); | 2169 | part.OnGrab(offsetPos, remoteClient); |
1446 | } | 2170 | } |
1447 | 2171 | ||
@@ -1461,28 +2185,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1461 | /// <param name="silent">If true then deletion is not broadcast to clients</param> | 2185 | /// <param name="silent">If true then deletion is not broadcast to clients</param> |
1462 | public void DeleteGroupFromScene(bool silent) | 2186 | public void DeleteGroupFromScene(bool silent) |
1463 | { | 2187 | { |
2188 | // We need to keep track of this state in case this group is still queued for backup. | ||
2189 | IsDeleted = true; | ||
2190 | |||
2191 | DetachFromBackup(); | ||
2192 | |||
1464 | SceneObjectPart[] parts = m_parts.GetArray(); | 2193 | SceneObjectPart[] parts = m_parts.GetArray(); |
1465 | for (int i = 0; i < parts.Length; i++) | 2194 | for (int i = 0; i < parts.Length; i++) |
1466 | { | 2195 | { |
1467 | SceneObjectPart part = parts[i]; | 2196 | SceneObjectPart part = parts[i]; |
1468 | 2197 | ||
1469 | Scene.ForEachScenePresence(sp => | 2198 | if (Scene != null) |
1470 | { | 2199 | { |
2200 | <<<<<<< HEAD | ||
1471 | if (!sp.IsChildAgent && sp.ParentID == part.LocalId) | 2201 | if (!sp.IsChildAgent && sp.ParentID == part.LocalId) |
1472 | sp.StandUp(); | 2202 | sp.StandUp(); |
1473 | 2203 | ||
1474 | if (!silent) | 2204 | if (!silent) |
2205 | ======= | ||
2206 | Scene.ForEachRootScenePresence(delegate(ScenePresence avatar) | ||
2207 | >>>>>>> avn/ubitvar | ||
1475 | { | 2208 | { |
1476 | part.ClearUpdateSchedule(); | 2209 | if (avatar.ParentID == LocalId) |
1477 | if (part == m_rootPart) | 2210 | avatar.StandUp(); |
2211 | |||
2212 | if (!silent) | ||
1478 | { | 2213 | { |
1479 | if (!IsAttachment | 2214 | part.ClearUpdateSchedule(); |
1480 | || AttachedAvatar == sp.UUID | 2215 | if (part == m_rootPart) |
1481 | || !HasPrivateAttachmentPoint) | 2216 | { |
1482 | sp.ControllingClient.SendKillObject(new List<uint> { part.LocalId }); | 2217 | if (!IsAttachment |
2218 | || AttachedAvatar == avatar.ControllingClient.AgentId | ||
2219 | || !HasPrivateAttachmentPoint) | ||
2220 | avatar.ControllingClient.SendKillObject(new List<uint> { part.LocalId }); | ||
2221 | } | ||
1483 | } | 2222 | } |
1484 | } | 2223 | }); |
1485 | }); | 2224 | } |
1486 | } | 2225 | } |
1487 | } | 2226 | } |
1488 | 2227 | ||
@@ -1553,28 +2292,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
1553 | /// </summary> | 2292 | /// </summary> |
1554 | public void ApplyPhysics() | 2293 | public void ApplyPhysics() |
1555 | { | 2294 | { |
1556 | // Apply physics to the root prim | ||
1557 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive); | ||
1558 | |||
1559 | // Apply physics to child prims | ||
1560 | SceneObjectPart[] parts = m_parts.GetArray(); | 2295 | SceneObjectPart[] parts = m_parts.GetArray(); |
1561 | if (parts.Length > 1) | 2296 | if (parts.Length > 1) |
1562 | { | 2297 | { |
2298 | ResetChildPrimPhysicsPositions(); | ||
2299 | |||
2300 | // Apply physics to the root prim | ||
2301 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, true); | ||
2302 | |||
2303 | |||
1563 | for (int i = 0; i < parts.Length; i++) | 2304 | for (int i = 0; i < parts.Length; i++) |
1564 | { | 2305 | { |
1565 | SceneObjectPart part = parts[i]; | 2306 | SceneObjectPart part = parts[i]; |
1566 | if (part.LocalId != m_rootPart.LocalId) | 2307 | if (part.LocalId != m_rootPart.LocalId) |
1567 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive); | 2308 | part.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), part.VolumeDetectActive, true); |
1568 | } | 2309 | } |
1569 | |||
1570 | // Hack to get the physics scene geometries in the right spot | 2310 | // Hack to get the physics scene geometries in the right spot |
1571 | ResetChildPrimPhysicsPositions(); | 2311 | // ResetChildPrimPhysicsPositions(); |
2312 | if (m_rootPart.PhysActor != null) | ||
2313 | { | ||
2314 | m_rootPart.PhysActor.Building = false; | ||
2315 | } | ||
2316 | } | ||
2317 | else | ||
2318 | { | ||
2319 | // Apply physics to the root prim | ||
2320 | m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, false); | ||
1572 | } | 2321 | } |
1573 | } | 2322 | } |
1574 | 2323 | ||
1575 | public void SetOwnerId(UUID userId) | 2324 | public void SetOwnerId(UUID userId) |
1576 | { | 2325 | { |
1577 | ForEachPart(delegate(SceneObjectPart part) { part.OwnerID = userId; }); | 2326 | ForEachPart(delegate(SceneObjectPart part) |
2327 | { | ||
2328 | |||
2329 | part.OwnerID = userId; | ||
2330 | |||
2331 | }); | ||
1578 | } | 2332 | } |
1579 | 2333 | ||
1580 | public void ForEachPart(Action<SceneObjectPart> whatToDo) | 2334 | public void ForEachPart(Action<SceneObjectPart> whatToDo) |
@@ -1599,18 +2353,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1599 | return; | 2353 | return; |
1600 | } | 2354 | } |
1601 | 2355 | ||
1602 | if (IsDeleted || UUID == UUID.Zero) | 2356 | if (IsDeleted || inTransit || UUID == UUID.Zero) |
1603 | { | 2357 | { |
1604 | // m_log.DebugFormat( | 2358 | // m_log.DebugFormat( |
1605 | // "[WATER WARS]: Ignoring backup of {0} {1} since object is marked as already deleted", Name, UUID); | 2359 | // "[WATER WARS]: Ignoring backup of {0} {1} since object is marked as already deleted", Name, UUID); |
1606 | return; | 2360 | return; |
1607 | } | 2361 | } |
1608 | 2362 | ||
2363 | if ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0) | ||
2364 | return; | ||
2365 | |||
1609 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let | 2366 | // Since this is the top of the section of call stack for backing up a particular scene object, don't let |
1610 | // any exception propogate upwards. | 2367 | // any exception propogate upwards. |
1611 | try | 2368 | try |
1612 | { | 2369 | { |
1613 | if (!m_scene.ShuttingDown) // if shutting down then there will be nothing to handle the return so leave till next restart | 2370 | if (!m_scene.ShuttingDown || // if shutting down then there will be nothing to handle the return so leave till next restart |
2371 | !m_scene.LoginsEnabled || // We're starting up or doing maintenance, don't mess with things | ||
2372 | m_scene.LoadingPrims) // Land may not be valid yet | ||
2373 | |||
1614 | { | 2374 | { |
1615 | ILandObject parcel = m_scene.LandChannel.GetLandObject( | 2375 | ILandObject parcel = m_scene.LandChannel.GetLandObject( |
1616 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); | 2376 | m_rootPart.GroupPosition.X, m_rootPart.GroupPosition.Y); |
@@ -1637,6 +2397,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1637 | } | 2397 | } |
1638 | } | 2398 | } |
1639 | } | 2399 | } |
2400 | |||
1640 | } | 2401 | } |
1641 | 2402 | ||
1642 | if (m_scene.UseBackup && HasGroupChanged) | 2403 | if (m_scene.UseBackup && HasGroupChanged) |
@@ -1644,10 +2405,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
1644 | // don't backup while it's selected or you're asking for changes mid stream. | 2405 | // don't backup while it's selected or you're asking for changes mid stream. |
1645 | if (isTimeToPersist() || forcedBackup) | 2406 | if (isTimeToPersist() || forcedBackup) |
1646 | { | 2407 | { |
2408 | if (m_rootPart.PhysActor != null && | ||
2409 | (!m_rootPart.PhysActor.IsPhysical)) | ||
2410 | { | ||
2411 | // Possible ghost prim | ||
2412 | if (m_rootPart.PhysActor.Position != m_rootPart.GroupPosition) | ||
2413 | { | ||
2414 | foreach (SceneObjectPart part in m_parts.GetArray()) | ||
2415 | { | ||
2416 | // Re-set physics actor positions and | ||
2417 | // orientations | ||
2418 | part.GroupPosition = m_rootPart.GroupPosition; | ||
2419 | } | ||
2420 | } | ||
2421 | } | ||
1647 | // m_log.DebugFormat( | 2422 | // m_log.DebugFormat( |
1648 | // "[SCENE]: Storing {0}, {1} in {2}", | 2423 | // "[SCENE]: Storing {0}, {1} in {2}", |
1649 | // Name, UUID, m_scene.RegionInfo.RegionName); | 2424 | // Name, UUID, m_scene.RegionInfo.RegionName); |
1650 | 2425 | ||
2426 | if (RootPart.Shape.PCode == 9 && RootPart.Shape.State != 0) | ||
2427 | { | ||
2428 | RootPart.Shape.LastAttachPoint = RootPart.Shape.State; | ||
2429 | RootPart.Shape.State = 0; | ||
2430 | ScheduleGroupForFullUpdate(); | ||
2431 | } | ||
2432 | |||
1651 | SceneObjectGroup backup_group = Copy(false); | 2433 | SceneObjectGroup backup_group = Copy(false); |
1652 | backup_group.RootPart.Velocity = RootPart.Velocity; | 2434 | backup_group.RootPart.Velocity = RootPart.Velocity; |
1653 | backup_group.RootPart.Acceleration = RootPart.Acceleration; | 2435 | backup_group.RootPart.Acceleration = RootPart.Acceleration; |
@@ -1657,13 +2439,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1657 | GroupContainsForeignPrims = false; | 2439 | GroupContainsForeignPrims = false; |
1658 | 2440 | ||
1659 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); | 2441 | m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this); |
2442 | |||
1660 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); | 2443 | datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID); |
1661 | 2444 | ||
1662 | backup_group.ForEachPart(delegate(SceneObjectPart part) | 2445 | backup_group.ForEachPart(delegate(SceneObjectPart part) |
1663 | { | 2446 | { |
1664 | part.Inventory.ProcessInventoryBackup(datastore); | 2447 | part.Inventory.ProcessInventoryBackup(datastore); |
2448 | |||
2449 | // take the change to delete things | ||
2450 | if(part.KeyframeMotion != null) | ||
2451 | { | ||
2452 | part.KeyframeMotion.Delete(); | ||
2453 | part.KeyframeMotion = null; | ||
2454 | } | ||
1665 | }); | 2455 | }); |
1666 | 2456 | ||
2457 | |||
1667 | backup_group = null; | 2458 | backup_group = null; |
1668 | } | 2459 | } |
1669 | // else | 2460 | // else |
@@ -1713,6 +2504,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1713 | /// <returns></returns> | 2504 | /// <returns></returns> |
1714 | public SceneObjectGroup Copy(bool userExposed) | 2505 | public SceneObjectGroup Copy(bool userExposed) |
1715 | { | 2506 | { |
2507 | <<<<<<< HEAD | ||
1716 | // FIXME: This is dangerous since it's easy to forget to reset some references when necessary and end up | 2508 | // FIXME: This is dangerous since it's easy to forget to reset some references when necessary and end up |
1717 | // with bugs that only occur in some circumstances (e.g. crossing between regions on the same simulator | 2509 | // with bugs that only occur in some circumstances (e.g. crossing between regions on the same simulator |
1718 | // but not between regions on different simulators). Really, all copying should be done explicitly. | 2510 | // but not between regions on different simulators). Really, all copying should be done explicitly. |
@@ -1721,18 +2513,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
1721 | dupe.Backup = false; | 2513 | dupe.Backup = false; |
1722 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); | 2514 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); |
1723 | dupe.m_sittingAvatars = new List<ScenePresence>(); | 2515 | dupe.m_sittingAvatars = new List<ScenePresence>(); |
2516 | ======= | ||
2517 | m_dupeInProgress = true; | ||
2518 | SceneObjectGroup dupe = (SceneObjectGroup)MemberwiseClone(); | ||
2519 | dupe.m_isBackedUp = false; | ||
2520 | dupe.m_parts = new MapAndArray<OpenMetaverse.UUID, SceneObjectPart>(); | ||
2521 | |||
2522 | dupe.inTransit = inTransit; // this shouldn't be needed TEST | ||
2523 | |||
2524 | // new group as no sitting avatars | ||
2525 | dupe.m_linkedAvatars = new List<ScenePresence>(); | ||
2526 | dupe.m_sittingAvatars = new List<UUID>(); | ||
2527 | |||
2528 | >>>>>>> avn/ubitvar | ||
1724 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); | 2529 | dupe.CopyRootPart(m_rootPart, OwnerID, GroupID, userExposed); |
1725 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; | 2530 | dupe.m_rootPart.LinkNum = m_rootPart.LinkNum; |
2531 | |||
1726 | 2532 | ||
1727 | if (userExposed) | 2533 | if (userExposed) |
1728 | dupe.m_rootPart.TrimPermissions(); | 2534 | dupe.m_rootPart.TrimPermissions(); |
1729 | 2535 | ||
1730 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); | 2536 | List<SceneObjectPart> partList = new List<SceneObjectPart>(m_parts.GetArray()); |
1731 | 2537 | ||
1732 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) | 2538 | partList.Sort(delegate(SceneObjectPart p1, SceneObjectPart p2) |
1733 | { | 2539 | { |
1734 | return p1.LinkNum.CompareTo(p2.LinkNum); | 2540 | return p1.LinkNum.CompareTo(p2.LinkNum); |
1735 | } | 2541 | } |
1736 | ); | 2542 | ); |
1737 | 2543 | ||
1738 | foreach (SceneObjectPart part in partList) | 2544 | foreach (SceneObjectPart part in partList) |
@@ -1742,43 +2548,56 @@ namespace OpenSim.Region.Framework.Scenes | |||
1742 | { | 2548 | { |
1743 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); | 2549 | newPart = dupe.CopyPart(part, OwnerID, GroupID, userExposed); |
1744 | newPart.LinkNum = part.LinkNum; | 2550 | newPart.LinkNum = part.LinkNum; |
1745 | } | 2551 | // if (userExposed) |
2552 | newPart.ParentID = dupe.m_rootPart.LocalId; | ||
2553 | } | ||
1746 | else | 2554 | else |
1747 | { | 2555 | { |
1748 | newPart = dupe.m_rootPart; | 2556 | newPart = dupe.m_rootPart; |
1749 | } | 2557 | } |
2558 | /* | ||
2559 | bool isphys = ((newPart.Flags & PrimFlags.Physics) != 0); | ||
2560 | bool isphan = ((newPart.Flags & PrimFlags.Phantom) != 0); | ||
1750 | 2561 | ||
1751 | // Need to duplicate the physics actor as well | 2562 | // Need to duplicate the physics actor as well |
1752 | PhysicsActor originalPartPa = part.PhysActor; | 2563 | if (userExposed && (isphys || !isphan || newPart.VolumeDetectActive)) |
1753 | if (originalPartPa != null && userExposed) | ||
1754 | { | 2564 | { |
1755 | PrimitiveBaseShape pbs = newPart.Shape; | 2565 | PrimitiveBaseShape pbs = newPart.Shape; |
1756 | |||
1757 | newPart.PhysActor | 2566 | newPart.PhysActor |
1758 | = m_scene.PhysicsScene.AddPrimShape( | 2567 | = m_scene.PhysicsScene.AddPrimShape( |
1759 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), | 2568 | string.Format("{0}/{1}", newPart.Name, newPart.UUID), |
1760 | pbs, | 2569 | pbs, |
1761 | newPart.AbsolutePosition, | 2570 | newPart.AbsolutePosition, |
1762 | newPart.Scale, | 2571 | newPart.Scale, |
1763 | newPart.RotationOffset, | 2572 | newPart.GetWorldRotation(), |
1764 | originalPartPa.IsPhysical, | 2573 | isphys, |
2574 | isphan, | ||
1765 | newPart.LocalId); | 2575 | newPart.LocalId); |
1766 | 2576 | ||
1767 | newPart.DoPhysicsPropertyUpdate(originalPartPa.IsPhysical, true); | 2577 | newPart.DoPhysicsPropertyUpdate(isphys, true); |
1768 | } | 2578 | */ |
2579 | if (userExposed) | ||
2580 | newPart.ApplyPhysics((uint)newPart.Flags,newPart.VolumeDetectActive,true); | ||
2581 | // } | ||
2582 | // copy keyframemotion | ||
1769 | if (part.KeyframeMotion != null) | 2583 | if (part.KeyframeMotion != null) |
1770 | newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); | 2584 | newPart.KeyframeMotion = part.KeyframeMotion.Copy(dupe); |
1771 | } | 2585 | } |
1772 | 2586 | ||
1773 | if (userExposed) | 2587 | if (userExposed) |
1774 | { | 2588 | { |
1775 | dupe.UpdateParentIDs(); | 2589 | // done above dupe.UpdateParentIDs(); |
2590 | |||
2591 | if (dupe.m_rootPart.PhysActor != null) | ||
2592 | dupe.m_rootPart.PhysActor.Building = false; // tell physics to finish building | ||
2593 | |||
1776 | dupe.HasGroupChanged = true; | 2594 | dupe.HasGroupChanged = true; |
1777 | dupe.AttachToBackup(); | 2595 | dupe.AttachToBackup(); |
1778 | 2596 | ||
1779 | ScheduleGroupForFullUpdate(); | 2597 | ScheduleGroupForFullUpdate(); |
1780 | } | 2598 | } |
1781 | 2599 | ||
2600 | m_dupeInProgress = false; | ||
1782 | return dupe; | 2601 | return dupe; |
1783 | } | 2602 | } |
1784 | 2603 | ||
@@ -1790,7 +2609,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1790 | /// <param name="cGroupID"></param> | 2609 | /// <param name="cGroupID"></param> |
1791 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2610 | public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
1792 | { | 2611 | { |
1793 | SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); | 2612 | SceneObjectPart newpart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed); |
2613 | // SceneObjectPart newpart = part.Copy(part.LocalId, OwnerID, GroupID, 0, userExposed); | ||
2614 | // newpart.LocalId = m_scene.AllocateLocalId(); | ||
2615 | |||
2616 | SetRootPart(newpart); | ||
2617 | if (userExposed) | ||
2618 | RootPart.Velocity = Vector3.Zero; // In case source is moving | ||
1794 | } | 2619 | } |
1795 | 2620 | ||
1796 | public void ScriptSetPhysicsStatus(bool usePhysics) | 2621 | public void ScriptSetPhysicsStatus(bool usePhysics) |
@@ -1848,13 +2673,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1848 | 2673 | ||
1849 | if (pa != null) | 2674 | if (pa != null) |
1850 | { | 2675 | { |
1851 | pa.AddForce(impulse, true); | 2676 | // false to be applied as a impulse |
2677 | pa.AddForce(impulse, false); | ||
1852 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2678 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1853 | } | 2679 | } |
1854 | } | 2680 | } |
1855 | } | 2681 | } |
1856 | 2682 | ||
1857 | public void applyAngularImpulse(Vector3 impulse) | 2683 | public void ApplyAngularImpulse(Vector3 impulse) |
1858 | { | 2684 | { |
1859 | PhysicsActor pa = RootPart.PhysActor; | 2685 | PhysicsActor pa = RootPart.PhysActor; |
1860 | 2686 | ||
@@ -1862,21 +2688,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1862 | { | 2688 | { |
1863 | if (!IsAttachment) | 2689 | if (!IsAttachment) |
1864 | { | 2690 | { |
1865 | pa.AddAngularForce(impulse, true); | 2691 | // false to be applied as a impulse |
1866 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2692 | pa.AddAngularForce(impulse, false); |
1867 | } | ||
1868 | } | ||
1869 | } | ||
1870 | |||
1871 | public void setAngularImpulse(Vector3 impulse) | ||
1872 | { | ||
1873 | PhysicsActor pa = RootPart.PhysActor; | ||
1874 | |||
1875 | if (pa != null) | ||
1876 | { | ||
1877 | if (!IsAttachment) | ||
1878 | { | ||
1879 | pa.Torque = impulse; | ||
1880 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 2693 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
1881 | } | 2694 | } |
1882 | } | 2695 | } |
@@ -1884,21 +2697,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1884 | 2697 | ||
1885 | public Vector3 GetTorque() | 2698 | public Vector3 GetTorque() |
1886 | { | 2699 | { |
1887 | PhysicsActor pa = RootPart.PhysActor; | 2700 | return RootPart.Torque; |
1888 | |||
1889 | if (pa != null) | ||
1890 | { | ||
1891 | if (!IsAttachment) | ||
1892 | { | ||
1893 | Vector3 torque = pa.Torque; | ||
1894 | return torque; | ||
1895 | } | ||
1896 | } | ||
1897 | |||
1898 | return Vector3.Zero; | ||
1899 | } | 2701 | } |
1900 | 2702 | ||
2703 | <<<<<<< HEAD | ||
1901 | public void MoveToTarget(Vector3 target, float tau) | 2704 | public void MoveToTarget(Vector3 target, float tau) |
2705 | ======= | ||
2706 | // This is used by both Double-Click Auto-Pilot and llMoveToTarget() in an attached object | ||
2707 | public void moveToTarget(Vector3 target, float tau) | ||
2708 | >>>>>>> avn/ubitvar | ||
1902 | { | 2709 | { |
1903 | if (IsAttachment) | 2710 | if (IsAttachment) |
1904 | { | 2711 | { |
@@ -1925,6 +2732,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1925 | if (IsAttachment) | 2732 | if (IsAttachment) |
1926 | { | 2733 | { |
1927 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); | 2734 | ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); |
2735 | <<<<<<< HEAD | ||
1928 | 2736 | ||
1929 | if (avatar != null) | 2737 | if (avatar != null) |
1930 | avatar.ResetMoveToTarget(); | 2738 | avatar.ResetMoveToTarget(); |
@@ -1938,10 +2746,64 @@ namespace OpenSim.Region.Framework.Scenes | |||
1938 | pa.PIDActive = false; | 2746 | pa.PIDActive = false; |
1939 | 2747 | ||
1940 | ScheduleGroupForTerseUpdate(); | 2748 | ScheduleGroupForTerseUpdate(); |
2749 | ======= | ||
2750 | if (avatar != null) | ||
2751 | { | ||
2752 | avatar.ResetMoveToTarget(); | ||
2753 | } | ||
2754 | } | ||
2755 | else | ||
2756 | { | ||
2757 | PhysicsActor pa = RootPart.PhysActor; | ||
2758 | |||
2759 | if (pa != null) | ||
2760 | pa.PIDActive = false; | ||
2761 | |||
2762 | RootPart.ScheduleTerseUpdate(); // send a stop information | ||
2763 | } | ||
2764 | } | ||
2765 | |||
2766 | public void rotLookAt(Quaternion target, float strength, float damping) | ||
2767 | { | ||
2768 | SceneObjectPart rootpart = m_rootPart; | ||
2769 | if (rootpart != null) | ||
2770 | { | ||
2771 | if (IsAttachment) | ||
2772 | { | ||
2773 | /* | ||
2774 | ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); | ||
2775 | if (avatar != null) | ||
2776 | { | ||
2777 | Rotate the Av? | ||
2778 | } */ | ||
2779 | } | ||
2780 | else | ||
2781 | { | ||
2782 | if (rootpart.PhysActor != null) | ||
2783 | { // APID must be implemented in your physics system for this to function. | ||
2784 | rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W); | ||
2785 | rootpart.PhysActor.APIDStrength = strength; | ||
2786 | rootpart.PhysActor.APIDDamping = damping; | ||
2787 | rootpart.PhysActor.APIDActive = true; | ||
2788 | } | ||
2789 | >>>>>>> avn/ubitvar | ||
1941 | } | 2790 | } |
1942 | } | 2791 | } |
1943 | } | 2792 | } |
2793 | |||
2794 | public void stopLookAt() | ||
2795 | { | ||
2796 | SceneObjectPart rootpart = m_rootPart; | ||
2797 | if (rootpart != null) | ||
2798 | { | ||
2799 | if (rootpart.PhysActor != null) | ||
2800 | { // APID must be implemented in your physics system for this to function. | ||
2801 | rootpart.PhysActor.APIDActive = false; | ||
2802 | } | ||
2803 | } | ||
1944 | 2804 | ||
2805 | } | ||
2806 | |||
1945 | /// <summary> | 2807 | /// <summary> |
1946 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. | 2808 | /// Uses a PID to attempt to clamp the object on the Z axis at the given height over tau seconds. |
1947 | /// </summary> | 2809 | /// </summary> |
@@ -1958,7 +2820,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1958 | { | 2820 | { |
1959 | pa.PIDHoverHeight = height; | 2821 | pa.PIDHoverHeight = height; |
1960 | pa.PIDHoverType = hoverType; | 2822 | pa.PIDHoverType = hoverType; |
1961 | pa.PIDTau = tau; | 2823 | pa.PIDHoverTau = tau; |
1962 | pa.PIDHoverActive = true; | 2824 | pa.PIDHoverActive = true; |
1963 | } | 2825 | } |
1964 | else | 2826 | else |
@@ -1999,6 +2861,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1999 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) | 2861 | public SceneObjectPart CopyPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed) |
2000 | { | 2862 | { |
2001 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); | 2863 | SceneObjectPart newPart = part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed); |
2864 | // SceneObjectPart newPart = part.Copy(part.LocalId, OwnerID, GroupID, m_parts.Count, userExposed); | ||
2865 | // newPart.LocalId = m_scene.AllocateLocalId(); | ||
2866 | |||
2002 | AddPart(newPart); | 2867 | AddPart(newPart); |
2003 | 2868 | ||
2004 | SetPartAsNonRoot(newPart); | 2869 | SetPartAsNonRoot(newPart); |
@@ -2048,6 +2913,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2048 | 2913 | ||
2049 | #endregion | 2914 | #endregion |
2050 | 2915 | ||
2916 | |||
2051 | public override void Update() | 2917 | public override void Update() |
2052 | { | 2918 | { |
2053 | // Check that the group was not deleted before the scheduled update | 2919 | // Check that the group was not deleted before the scheduled update |
@@ -2055,7 +2921,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2055 | // an object has been deleted from a scene before update was processed. | 2921 | // an object has been deleted from a scene before update was processed. |
2056 | // A more fundamental overhaul of the update mechanism is required to eliminate all | 2922 | // A more fundamental overhaul of the update mechanism is required to eliminate all |
2057 | // the race conditions. | 2923 | // the race conditions. |
2058 | if (IsDeleted) | 2924 | if (IsDeleted || inTransit) |
2059 | return; | 2925 | return; |
2060 | 2926 | ||
2061 | // Even temporary objects take part in physics (e.g. temp-on-rez bullets) | 2927 | // Even temporary objects take part in physics (e.g. temp-on-rez bullets) |
@@ -2066,18 +2932,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2066 | // check to see if the physical position or rotation warrant an update. | 2932 | // check to see if the physical position or rotation warrant an update. |
2067 | if (m_rootPart.UpdateFlag == UpdateRequired.NONE) | 2933 | if (m_rootPart.UpdateFlag == UpdateRequired.NONE) |
2068 | { | 2934 | { |
2069 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); | 2935 | // rootpart SendScheduledUpdates will check if a update is needed |
2070 | 2936 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | |
2071 | if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) | 2937 | } |
2072 | { | ||
2073 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | ||
2074 | lastPhysGroupPos = AbsolutePosition; | ||
2075 | } | ||
2076 | 2938 | ||
2077 | if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) | 2939 | if (IsAttachment) |
2940 | { | ||
2941 | ScenePresence sp = m_scene.GetScenePresence(AttachedAvatar); | ||
2942 | if (sp != null) | ||
2078 | { | 2943 | { |
2079 | m_rootPart.UpdateFlag = UpdateRequired.TERSE; | 2944 | sp.SendAttachmentScheduleUpdate(this); |
2080 | lastPhysGroupRot = GroupRotation; | 2945 | return; |
2081 | } | 2946 | } |
2082 | } | 2947 | } |
2083 | 2948 | ||
@@ -2137,20 +3002,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
2137 | /// Immediately send a full update for this scene object. | 3002 | /// Immediately send a full update for this scene object. |
2138 | /// </summary> | 3003 | /// </summary> |
2139 | public void SendGroupFullUpdate() | 3004 | public void SendGroupFullUpdate() |
2140 | { | 3005 | { |
2141 | if (IsDeleted) | 3006 | if (IsDeleted) |
2142 | return; | 3007 | return; |
2143 | 3008 | ||
2144 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); | 3009 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); |
2145 | 3010 | ||
2146 | RootPart.SendFullUpdateToAllClients(); | 3011 | if (IsAttachment) |
3012 | { | ||
3013 | ScenePresence sp = m_scene.GetScenePresence(AttachedAvatar); | ||
3014 | if (sp != null) | ||
3015 | { | ||
3016 | sp.SendAttachmentUpdate(this,UpdateRequired.FULL); | ||
3017 | return; | ||
3018 | } | ||
3019 | } | ||
3020 | |||
3021 | RootPart.SendFullUpdateToAllClientsInternal(); | ||
2147 | 3022 | ||
2148 | SceneObjectPart[] parts = m_parts.GetArray(); | 3023 | SceneObjectPart[] parts = m_parts.GetArray(); |
2149 | for (int i = 0; i < parts.Length; i++) | 3024 | for (int i = 0; i < parts.Length; i++) |
2150 | { | 3025 | { |
2151 | SceneObjectPart part = parts[i]; | 3026 | SceneObjectPart part = parts[i]; |
2152 | if (part != RootPart) | 3027 | if (part != RootPart) |
2153 | part.SendFullUpdateToAllClients(); | 3028 | part.SendFullUpdateToAllClientsInternal(); |
2154 | } | 3029 | } |
2155 | } | 3030 | } |
2156 | 3031 | ||
@@ -2162,7 +3037,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2162 | /// </summary> | 3037 | /// </summary> |
2163 | public void SendGroupRootTerseUpdate() | 3038 | public void SendGroupRootTerseUpdate() |
2164 | { | 3039 | { |
2165 | if (IsDeleted) | 3040 | if (IsDeleted || inTransit) |
2166 | return; | 3041 | return; |
2167 | 3042 | ||
2168 | RootPart.SendTerseUpdateToAllClients(); | 3043 | RootPart.SendTerseUpdateToAllClients(); |
@@ -2181,12 +3056,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2181 | /// </summary> | 3056 | /// </summary> |
2182 | public void SendGroupTerseUpdate() | 3057 | public void SendGroupTerseUpdate() |
2183 | { | 3058 | { |
2184 | if (IsDeleted) | 3059 | if (IsDeleted || inTransit) |
2185 | return; | 3060 | return; |
2186 | 3061 | ||
3062 | if (IsAttachment) | ||
3063 | { | ||
3064 | ScenePresence sp = m_scene.GetScenePresence(AttachedAvatar); | ||
3065 | if (sp != null) | ||
3066 | { | ||
3067 | sp.SendAttachmentUpdate(this, UpdateRequired.TERSE); | ||
3068 | return; | ||
3069 | } | ||
3070 | } | ||
3071 | |||
2187 | SceneObjectPart[] parts = m_parts.GetArray(); | 3072 | SceneObjectPart[] parts = m_parts.GetArray(); |
2188 | for (int i = 0; i < parts.Length; i++) | 3073 | for (int i = 0; i < parts.Length; i++) |
2189 | parts[i].SendTerseUpdateToAllClients(); | 3074 | parts[i].SendTerseUpdateToAllClientsInternal(); |
2190 | } | 3075 | } |
2191 | 3076 | ||
2192 | /// <summary> | 3077 | /// <summary> |
@@ -2294,9 +3179,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
2294 | return; | 3179 | return; |
2295 | } | 3180 | } |
2296 | 3181 | ||
3182 | // physical prims count limit | ||
3183 | // not very eficient :( | ||
3184 | |||
3185 | if (UsesPhysics && m_scene.m_linksetPhysCapacity > 0 && (PrimCount + objectGroup.PrimCount) > | ||
3186 | m_scene.m_linksetPhysCapacity) | ||
3187 | { | ||
3188 | int cntr = 0; | ||
3189 | foreach (SceneObjectPart part in Parts) | ||
3190 | { | ||
3191 | if (part.PhysicsShapeType != (byte)PhysicsShapeType.None) | ||
3192 | cntr++; | ||
3193 | } | ||
3194 | foreach (SceneObjectPart part in objectGroup.Parts) | ||
3195 | { | ||
3196 | if (part.PhysicsShapeType != (byte)PhysicsShapeType.None) | ||
3197 | cntr++; | ||
3198 | } | ||
3199 | |||
3200 | if (cntr > m_scene.m_linksetPhysCapacity) | ||
3201 | { | ||
3202 | // cancel physics | ||
3203 | RootPart.Flags &= ~PrimFlags.Physics; | ||
3204 | ApplyPhysics(); | ||
3205 | } | ||
3206 | } | ||
3207 | |||
3208 | |||
2297 | // 'linkPart' == the root of the group being linked into this group | 3209 | // 'linkPart' == the root of the group being linked into this group |
2298 | SceneObjectPart linkPart = objectGroup.m_rootPart; | 3210 | SceneObjectPart linkPart = objectGroup.m_rootPart; |
2299 | 3211 | ||
3212 | if (m_rootPart.PhysActor != null) | ||
3213 | m_rootPart.PhysActor.Building = true; | ||
3214 | if (linkPart.PhysActor != null) | ||
3215 | linkPart.PhysActor.Building = true; | ||
3216 | |||
2300 | // physics flags from group to be applied to linked parts | 3217 | // physics flags from group to be applied to linked parts |
2301 | bool grpusephys = UsesPhysics; | 3218 | bool grpusephys = UsesPhysics; |
2302 | bool grptemporary = IsTemporary; | 3219 | bool grptemporary = IsTemporary; |
@@ -2313,22 +3230,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2313 | // First move the new group's root SOP's position to be relative to ours | 3230 | // First move the new group's root SOP's position to be relative to ours |
2314 | // (radams1: Not sure if the multiple setting of OffsetPosition is required. If not, | 3231 | // (radams1: Not sure if the multiple setting of OffsetPosition is required. If not, |
2315 | // this code can be reordered to have a more logical flow.) | 3232 | // this code can be reordered to have a more logical flow.) |
2316 | linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; | 3233 | linkPart.setOffsetPosition(linkPart.GroupPosition - AbsolutePosition); |
2317 | // Assign the new parent to the root of the old group | 3234 | // Assign the new parent to the root of the old group |
2318 | linkPart.ParentID = m_rootPart.LocalId; | 3235 | linkPart.ParentID = m_rootPart.LocalId; |
2319 | // Now that it's a child, it's group position is our root position | 3236 | // Now that it's a child, it's group position is our root position |
2320 | linkPart.GroupPosition = AbsolutePosition; | 3237 | linkPart.setGroupPosition(AbsolutePosition); |
2321 | 3238 | ||
2322 | Vector3 axPos = linkPart.OffsetPosition; | ||
2323 | // Rotate the linking root SOP's position to be relative to the new root prim | 3239 | // Rotate the linking root SOP's position to be relative to the new root prim |
2324 | Quaternion parentRot = m_rootPart.RotationOffset; | 3240 | Quaternion parentRot = m_rootPart.RotationOffset; |
2325 | axPos *= Quaternion.Inverse(parentRot); | ||
2326 | linkPart.OffsetPosition = axPos; | ||
2327 | 3241 | ||
2328 | // Make the linking root SOP's rotation relative to the new root prim | 3242 | // Make the linking root SOP's rotation relative to the new root prim |
2329 | Quaternion oldRot = linkPart.RotationOffset; | 3243 | Quaternion oldRot = linkPart.RotationOffset; |
2330 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 3244 | Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; |
2331 | linkPart.RotationOffset = newRot; | 3245 | linkPart.setRotationOffset(newRot); |
3246 | |||
3247 | Vector3 axPos = linkPart.OffsetPosition; | ||
3248 | axPos *= Quaternion.Conjugate(parentRot); | ||
3249 | linkPart.OffsetPosition = axPos; | ||
3250 | |||
2332 | 3251 | ||
2333 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. | 3252 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. |
2334 | // Now that we know this SOG has at least two SOPs in it, the new root | 3253 | // Now that we know this SOG has at least two SOPs in it, the new root |
@@ -2358,10 +3277,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2358 | m_parts.Add(linkPart.UUID, linkPart); | 3277 | m_parts.Add(linkPart.UUID, linkPart); |
2359 | 3278 | ||
2360 | linkPart.SetParent(this); | 3279 | linkPart.SetParent(this); |
3280 | m_scene.updateScenePartGroup(linkPart, this); | ||
3281 | |||
2361 | linkPart.CreateSelected = true; | 3282 | linkPart.CreateSelected = true; |
2362 | 3283 | ||
2363 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now | 3284 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now |
2364 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive); | 3285 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); |
2365 | 3286 | ||
2366 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 3287 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2367 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 3288 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2371,6 +3292,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2371 | } | 3292 | } |
2372 | 3293 | ||
2373 | linkPart.LinkNum = linkNum++; | 3294 | linkPart.LinkNum = linkNum++; |
3295 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2374 | 3296 | ||
2375 | // Get a list of the SOP's in the old group in order of their linknum's. | 3297 | // Get a list of the SOP's in the old group in order of their linknum's. |
2376 | SceneObjectPart[] ogParts = objectGroup.Parts; | 3298 | SceneObjectPart[] ogParts = objectGroup.Parts; |
@@ -2389,7 +3311,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2389 | 3311 | ||
2390 | // Update the physics flags for the newly added SOP | 3312 | // Update the physics flags for the newly added SOP |
2391 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) | 3313 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) |
2392 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive); | 3314 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); |
2393 | 3315 | ||
2394 | // If the added SOP is physical, also tell the physics engine about the link relationship. | 3316 | // If the added SOP is physical, also tell the physics engine about the link relationship. |
2395 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 3317 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
@@ -2407,7 +3329,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2407 | objectGroup.IsDeleted = true; | 3329 | objectGroup.IsDeleted = true; |
2408 | 3330 | ||
2409 | objectGroup.m_parts.Clear(); | 3331 | objectGroup.m_parts.Clear(); |
2410 | 3332 | ||
2411 | // Can't do this yet since backup still makes use of the root part without any synchronization | 3333 | // Can't do this yet since backup still makes use of the root part without any synchronization |
2412 | // objectGroup.m_rootPart = null; | 3334 | // objectGroup.m_rootPart = null; |
2413 | 3335 | ||
@@ -2423,6 +3345,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2423 | // unmoved prims! | 3345 | // unmoved prims! |
2424 | ResetChildPrimPhysicsPositions(); | 3346 | ResetChildPrimPhysicsPositions(); |
2425 | 3347 | ||
3348 | if (m_rootPart.PhysActor != null) | ||
3349 | m_rootPart.PhysActor.Building = false; | ||
3350 | |||
2426 | //HasGroupChanged = true; | 3351 | //HasGroupChanged = true; |
2427 | //ScheduleGroupForFullUpdate(); | 3352 | //ScheduleGroupForFullUpdate(); |
2428 | } | 3353 | } |
@@ -2490,7 +3415,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2490 | // m_log.DebugFormat( | 3415 | // m_log.DebugFormat( |
2491 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", | 3416 | // "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", |
2492 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); | 3417 | // linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); |
2493 | 3418 | ||
3419 | if (m_rootPart.PhysActor != null) | ||
3420 | m_rootPart.PhysActor.Building = true; | ||
3421 | |||
2494 | linkPart.ClearUndoState(); | 3422 | linkPart.ClearUndoState(); |
2495 | 3423 | ||
2496 | Vector3 worldPos = linkPart.GetWorldPosition(); | 3424 | Vector3 worldPos = linkPart.GetWorldPosition(); |
@@ -2545,20 +3473,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2545 | linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; | 3473 | linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; |
2546 | linkPart.OffsetPosition = new Vector3(0, 0, 0); | 3474 | linkPart.OffsetPosition = new Vector3(0, 0, 0); |
2547 | */ | 3475 | */ |
2548 | linkPart.GroupPosition = worldPos; | 3476 | linkPart.setGroupPosition(worldPos); |
2549 | linkPart.OffsetPosition = Vector3.Zero; | 3477 | linkPart.setOffsetPosition(Vector3.Zero); |
2550 | linkPart.RotationOffset = worldRot; | 3478 | linkPart.setRotationOffset(worldRot); |
2551 | 3479 | ||
2552 | // Create a new SOG to go around this unlinked and unattached SOP | 3480 | // Create a new SOG to go around this unlinked and unattached SOP |
2553 | SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); | 3481 | SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); |
2554 | 3482 | ||
2555 | m_scene.AddNewSceneObject(objectGroup, true); | 3483 | m_scene.AddNewSceneObject(objectGroup, true); |
2556 | 3484 | ||
2557 | if (sendEvents) | ||
2558 | linkPart.TriggerScriptChangedEvent(Changed.LINK); | ||
2559 | |||
2560 | linkPart.Rezzed = RootPart.Rezzed; | 3485 | linkPart.Rezzed = RootPart.Rezzed; |
2561 | 3486 | ||
3487 | <<<<<<< HEAD | ||
2562 | // We must persist the delinked group to the database immediately, for safety. The problem | 3488 | // We must persist the delinked group to the database immediately, for safety. The problem |
2563 | // is that although in memory the new group has a new SceneGroupID, in the database it | 3489 | // is that although in memory the new group has a new SceneGroupID, in the database it |
2564 | // still has the parent group's SceneGroupID (until the next backup). This means that if the | 3490 | // still has the parent group's SceneGroupID (until the next backup). This means that if the |
@@ -2569,6 +3495,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2569 | // not happen. (We can't use a just-in-time trick like GroupContainsForeignPrims in this case | 3495 | // not happen. (We can't use a just-in-time trick like GroupContainsForeignPrims in this case |
2570 | // because the delinked group doesn't know when the source group is deleted.) | 3496 | // because the delinked group doesn't know when the source group is deleted.) |
2571 | m_scene.ForceSceneObjectBackup(objectGroup); | 3497 | m_scene.ForceSceneObjectBackup(objectGroup); |
3498 | ======= | ||
3499 | // When we delete a group, we currently have to force persist to the database if the object id has changed | ||
3500 | // (since delete works by deleting all rows which have a given object id) | ||
3501 | |||
3502 | // this is as it seems to be in sl now | ||
3503 | if(linkPart.PhysicsShapeType == (byte)PhysShapeType.none) | ||
3504 | linkPart.PhysicsShapeType = linkPart.DefaultPhysicsShapeType(); // root prims can't have type none for now | ||
3505 | |||
3506 | if (m_rootPart.PhysActor != null) | ||
3507 | m_rootPart.PhysActor.Building = false; | ||
3508 | |||
3509 | objectGroup.HasGroupChangedDueToDelink = true; | ||
3510 | >>>>>>> avn/ubitvar | ||
3511 | |||
3512 | if (sendEvents) | ||
3513 | linkPart.TriggerScriptChangedEvent(Changed.LINK); | ||
2572 | 3514 | ||
2573 | return objectGroup; | 3515 | return objectGroup; |
2574 | } | 3516 | } |
@@ -2579,7 +3521,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2579 | /// <param name="objectGroup"></param> | 3521 | /// <param name="objectGroup"></param> |
2580 | public virtual void DetachFromBackup() | 3522 | public virtual void DetachFromBackup() |
2581 | { | 3523 | { |
3524 | <<<<<<< HEAD | ||
2582 | if (Backup && Scene != null) | 3525 | if (Backup && Scene != null) |
3526 | ======= | ||
3527 | if (m_scene != null) | ||
3528 | m_scene.SceneGraph.FireDetachFromBackup(this); | ||
3529 | if (m_isBackedUp && Scene != null) | ||
3530 | >>>>>>> avn/ubitvar | ||
2583 | m_scene.EventManager.OnBackup -= ProcessBackup; | 3531 | m_scene.EventManager.OnBackup -= ProcessBackup; |
2584 | 3532 | ||
2585 | Backup = false; | 3533 | Backup = false; |
@@ -2595,14 +3543,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2595 | Quaternion parentRot = oldGroupRotation; | 3543 | Quaternion parentRot = oldGroupRotation; |
2596 | Quaternion oldRot = part.RotationOffset; | 3544 | Quaternion oldRot = part.RotationOffset; |
2597 | 3545 | ||
2598 | // Move our position to not be relative to the old parent | 3546 | // Move our position in world |
2599 | Vector3 axPos = part.OffsetPosition; | 3547 | Vector3 axPos = part.OffsetPosition; |
2600 | axPos *= parentRot; | 3548 | axPos *= parentRot; |
2601 | part.OffsetPosition = axPos; | 3549 | Vector3 newPos = oldGroupPosition + axPos; |
2602 | part.GroupPosition = oldGroupPosition + part.OffsetPosition; | 3550 | part.setGroupPosition(newPos); |
2603 | part.OffsetPosition = Vector3.Zero; | 3551 | part.setOffsetPosition(Vector3.Zero); |
2604 | 3552 | ||
2605 | // Compution our rotation to be not relative to the old parent | 3553 | // Compution our rotation in world |
2606 | Quaternion worldRot = parentRot * oldRot; | 3554 | Quaternion worldRot = parentRot * oldRot; |
2607 | part.RotationOffset = worldRot; | 3555 | part.RotationOffset = worldRot; |
2608 | 3556 | ||
@@ -2613,29 +3561,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
2613 | 3561 | ||
2614 | part.LinkNum = linkNum; | 3562 | part.LinkNum = linkNum; |
2615 | 3563 | ||
3564 | m_scene.updateScenePartGroup(part, this); | ||
3565 | |||
2616 | // Compute the new position of this SOP relative to the group position | 3566 | // Compute the new position of this SOP relative to the group position |
2617 | part.OffsetPosition = part.GroupPosition - AbsolutePosition; | 3567 | part.setOffsetPosition(newPos - AbsolutePosition); |
2618 | 3568 | ||
2619 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. | 3569 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. |
2620 | // It would have the affect of setting the physics engine position multiple | 3570 | // It would have the affect of setting the physics engine position multiple |
2621 | // times. In theory, that is not necessary but I don't have a good linkset | 3571 | // times. In theory, that is not necessary but I don't have a good linkset |
2622 | // test to know that cleaning up this code wouldn't break things.) | 3572 | // test to know that cleaning up this code wouldn't break things.) |
2623 | 3573 | ||
2624 | // Rotate the relative position by the rotation of the group | ||
2625 | Quaternion rootRotation = m_rootPart.RotationOffset; | ||
2626 | Vector3 pos = part.OffsetPosition; | ||
2627 | pos *= Quaternion.Inverse(rootRotation); | ||
2628 | part.OffsetPosition = pos; | ||
2629 | |||
2630 | // Compute the SOP's rotation relative to the rotation of the group. | 3574 | // Compute the SOP's rotation relative to the rotation of the group. |
2631 | parentRot = m_rootPart.RotationOffset; | 3575 | parentRot = m_rootPart.RotationOffset; |
3576 | |||
2632 | oldRot = part.RotationOffset; | 3577 | oldRot = part.RotationOffset; |
2633 | Quaternion newRot = Quaternion.Inverse(parentRot) * oldRot; | 3578 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
2634 | part.RotationOffset = newRot; | 3579 | part.setRotationOffset(newRot); |
3580 | |||
3581 | Vector3 pos = part.OffsetPosition; | ||
3582 | pos *= Quaternion.Conjugate(parentRot); | ||
3583 | |||
3584 | part.OffsetPosition = pos; // update position and orientation on physics also | ||
2635 | 3585 | ||
2636 | // Since this SOP's state has changed, push those changes into the physics engine | 3586 | // Since this SOP's state has changed, push those changes into the physics engine |
2637 | // and the simulator. | 3587 | // and the simulator. |
2638 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect); | 3588 | // done on caller |
3589 | // part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | ||
2639 | } | 3590 | } |
2640 | 3591 | ||
2641 | /// <summary> | 3592 | /// <summary> |
@@ -2663,10 +3614,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2663 | { | 3614 | { |
2664 | if (!BlockGrabOverride && !part.BlockGrab) | 3615 | if (!BlockGrabOverride && !part.BlockGrab) |
2665 | { | 3616 | { |
2666 | Vector3 llmoveforce = pos - AbsolutePosition; | 3617 | /* Vector3 llmoveforce = pos - AbsolutePosition; |
2667 | Vector3 grabforce = llmoveforce; | 3618 | Vector3 grabforce = llmoveforce; |
2668 | grabforce = (grabforce / 10) * pa.Mass; | 3619 | grabforce = (grabforce / 10) * pa.Mass; |
2669 | pa.AddForce(grabforce, true); | 3620 | */ |
3621 | // empirically convert distance diference to a impulse | ||
3622 | Vector3 grabforce = pos - AbsolutePosition; | ||
3623 | grabforce = grabforce * (pa.Mass/ 10.0f); | ||
3624 | pa.AddForce(grabforce, false); | ||
2670 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); | 3625 | m_scene.PhysicsScene.AddPhysicsActorTaint(pa); |
2671 | } | 3626 | } |
2672 | } | 3627 | } |
@@ -2880,6 +3835,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2880 | /// <param name="SetVolumeDetect"></param> | 3835 | /// <param name="SetVolumeDetect"></param> |
2881 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) | 3836 | public void UpdatePrimFlags(uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVolumeDetect) |
2882 | { | 3837 | { |
3838 | HasGroupChanged = true; | ||
3839 | |||
2883 | SceneObjectPart selectionPart = GetPart(localID); | 3840 | SceneObjectPart selectionPart = GetPart(localID); |
2884 | 3841 | ||
2885 | if (Scene != null) | 3842 | if (Scene != null) |
@@ -2905,8 +3862,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2905 | { | 3862 | { |
2906 | SceneObjectPart[] parts = m_parts.GetArray(); | 3863 | SceneObjectPart[] parts = m_parts.GetArray(); |
2907 | 3864 | ||
2908 | if (Scene != null) | 3865 | if (Scene != null && UsePhysics) |
2909 | { | 3866 | { |
3867 | int maxprims = m_scene.m_linksetPhysCapacity; | ||
3868 | bool checkShape = (maxprims > 0 && | ||
3869 | parts.Length > maxprims); | ||
3870 | |||
2910 | for (int i = 0; i < parts.Length; i++) | 3871 | for (int i = 0; i < parts.Length; i++) |
2911 | { | 3872 | { |
2912 | SceneObjectPart part = parts[i]; | 3873 | SceneObjectPart part = parts[i]; |
@@ -2917,11 +3878,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
2917 | UsePhysics = false; // Reset physics | 3878 | UsePhysics = false; // Reset physics |
2918 | break; | 3879 | break; |
2919 | } | 3880 | } |
3881 | |||
3882 | if (checkShape && part.PhysicsShapeType != (byte)PhysicsShapeType.None) | ||
3883 | { | ||
3884 | if (--maxprims < 0) | ||
3885 | { | ||
3886 | UsePhysics = false; | ||
3887 | break; | ||
3888 | } | ||
3889 | } | ||
2920 | } | 3890 | } |
2921 | } | 3891 | } |
2922 | 3892 | ||
2923 | for (int i = 0; i < parts.Length; i++) | 3893 | if (parts.Length > 1) |
2924 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect); | 3894 | { |
3895 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3896 | |||
3897 | for (int i = 0; i < parts.Length; i++) | ||
3898 | { | ||
3899 | |||
3900 | if (parts[i].UUID != m_rootPart.UUID) | ||
3901 | parts[i].UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, true); | ||
3902 | } | ||
3903 | |||
3904 | if (m_rootPart.PhysActor != null) | ||
3905 | m_rootPart.PhysActor.Building = false; | ||
3906 | } | ||
3907 | else | ||
3908 | m_rootPart.UpdatePrimFlags(UsePhysics, SetTemporary, SetPhantom, SetVolumeDetect, false); | ||
2925 | } | 3909 | } |
2926 | } | 3910 | } |
2927 | 3911 | ||
@@ -2934,6 +3918,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2934 | } | 3918 | } |
2935 | } | 3919 | } |
2936 | 3920 | ||
3921 | |||
3922 | |||
3923 | /// <summary> | ||
3924 | /// Gets the number of parts | ||
3925 | /// </summary> | ||
3926 | /// <returns></returns> | ||
3927 | public int GetPartCount() | ||
3928 | { | ||
3929 | return Parts.Count(); | ||
3930 | } | ||
3931 | |||
2937 | /// <summary> | 3932 | /// <summary> |
2938 | /// Update the texture entry for this part | 3933 | /// Update the texture entry for this part |
2939 | /// </summary> | 3934 | /// </summary> |
@@ -2978,7 +3973,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2978 | { | 3973 | { |
2979 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); | 3974 | RootPart.UpdatePermissions(AgentID, field, localID, mask, addRemTF); |
2980 | 3975 | ||
3976 | <<<<<<< HEAD | ||
2981 | AdjustChildPrimPermissions(Scene.Permissions.IsGod(AgentID)); | 3977 | AdjustChildPrimPermissions(Scene.Permissions.IsGod(AgentID)); |
3978 | ======= | ||
3979 | bool god = Scene.Permissions.IsGod(AgentID); | ||
3980 | |||
3981 | if (field == 1 && god) | ||
3982 | { | ||
3983 | ForEachPart(part => | ||
3984 | { | ||
3985 | part.BaseMask = RootPart.BaseMask; | ||
3986 | }); | ||
3987 | } | ||
3988 | |||
3989 | AdjustChildPrimPermissions(); | ||
3990 | >>>>>>> avn/ubitvar | ||
3991 | |||
3992 | if (field == 1 && god) // Base mask was set. Update all child part inventories | ||
3993 | { | ||
3994 | foreach (SceneObjectPart part in Parts) | ||
3995 | part.Inventory.ApplyGodPermissions(RootPart.BaseMask); | ||
3996 | } | ||
2982 | 3997 | ||
2983 | HasGroupChanged = true; | 3998 | HasGroupChanged = true; |
2984 | 3999 | ||
@@ -3025,8 +4040,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3025 | 4040 | ||
3026 | PhysicsActor pa = m_rootPart.PhysActor; | 4041 | PhysicsActor pa = m_rootPart.PhysActor; |
3027 | 4042 | ||
3028 | RootPart.StoreUndoState(true); | ||
3029 | |||
3030 | if (Scene != null) | 4043 | if (Scene != null) |
3031 | { | 4044 | { |
3032 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); | 4045 | scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X)); |
@@ -3054,7 +4067,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3054 | SceneObjectPart obPart = parts[i]; | 4067 | SceneObjectPart obPart = parts[i]; |
3055 | if (obPart.UUID != m_rootPart.UUID) | 4068 | if (obPart.UUID != m_rootPart.UUID) |
3056 | { | 4069 | { |
3057 | // obPart.IgnoreUndoUpdate = true; | ||
3058 | Vector3 oldSize = new Vector3(obPart.Scale); | 4070 | Vector3 oldSize = new Vector3(obPart.Scale); |
3059 | 4071 | ||
3060 | float f = 1.0f; | 4072 | float f = 1.0f; |
@@ -3166,8 +4178,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3166 | z *= a; | 4178 | z *= a; |
3167 | } | 4179 | } |
3168 | } | 4180 | } |
3169 | |||
3170 | // obPart.IgnoreUndoUpdate = false; | ||
3171 | } | 4181 | } |
3172 | } | 4182 | } |
3173 | } | 4183 | } |
@@ -3177,9 +4187,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3177 | prevScale.Y *= y; | 4187 | prevScale.Y *= y; |
3178 | prevScale.Z *= z; | 4188 | prevScale.Z *= z; |
3179 | 4189 | ||
3180 | // RootPart.IgnoreUndoUpdate = true; | ||
3181 | RootPart.Resize(prevScale); | 4190 | RootPart.Resize(prevScale); |
3182 | // RootPart.IgnoreUndoUpdate = false; | ||
3183 | 4191 | ||
3184 | for (int i = 0; i < parts.Length; i++) | 4192 | for (int i = 0; i < parts.Length; i++) |
3185 | { | 4193 | { |
@@ -3187,8 +4195,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3187 | 4195 | ||
3188 | if (obPart.UUID != m_rootPart.UUID) | 4196 | if (obPart.UUID != m_rootPart.UUID) |
3189 | { | 4197 | { |
3190 | obPart.IgnoreUndoUpdate = true; | ||
3191 | |||
3192 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); | 4198 | Vector3 currentpos = new Vector3(obPart.OffsetPosition); |
3193 | currentpos.X *= x; | 4199 | currentpos.X *= x; |
3194 | currentpos.Y *= y; | 4200 | currentpos.Y *= y; |
@@ -3201,16 +4207,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3201 | 4207 | ||
3202 | obPart.Resize(newSize); | 4208 | obPart.Resize(newSize); |
3203 | obPart.UpdateOffSet(currentpos); | 4209 | obPart.UpdateOffSet(currentpos); |
3204 | |||
3205 | obPart.IgnoreUndoUpdate = false; | ||
3206 | } | 4210 | } |
3207 | 4211 | ||
3208 | // obPart.IgnoreUndoUpdate = false; | 4212 | HasGroupChanged = true; |
3209 | // obPart.StoreUndoState(); | 4213 | m_rootPart.TriggerScriptChangedEvent(Changed.SCALE); |
4214 | ScheduleGroupForTerseUpdate(); | ||
3210 | } | 4215 | } |
3211 | |||
3212 | // m_log.DebugFormat( | ||
3213 | // "[SCENE OBJECT GROUP]: Finished group resizing {0} {1} to {2}", Name, LocalId, RootPart.Scale); | ||
3214 | } | 4216 | } |
3215 | 4217 | ||
3216 | #endregion | 4218 | #endregion |
@@ -3223,14 +4225,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3223 | /// <param name="pos"></param> | 4225 | /// <param name="pos"></param> |
3224 | public void UpdateGroupPosition(Vector3 pos) | 4226 | public void UpdateGroupPosition(Vector3 pos) |
3225 | { | 4227 | { |
3226 | // m_log.DebugFormat("[SCENE OBJECT GROUP]: Updating group position on {0} {1} to {2}", Name, LocalId, pos); | ||
3227 | |||
3228 | RootPart.StoreUndoState(true); | ||
3229 | |||
3230 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3231 | // for (int i = 0; i < parts.Length; i++) | ||
3232 | // parts[i].StoreUndoState(); | ||
3233 | |||
3234 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) | 4228 | if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) |
3235 | { | 4229 | { |
3236 | if (IsAttachment) | 4230 | if (IsAttachment) |
@@ -3263,21 +4257,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
3263 | /// </summary> | 4257 | /// </summary> |
3264 | /// <param name="pos"></param> | 4258 | /// <param name="pos"></param> |
3265 | /// <param name="localID"></param> | 4259 | /// <param name="localID"></param> |
4260 | /// | ||
4261 | |||
3266 | public void UpdateSinglePosition(Vector3 pos, uint localID) | 4262 | public void UpdateSinglePosition(Vector3 pos, uint localID) |
3267 | { | 4263 | { |
3268 | SceneObjectPart part = GetPart(localID); | 4264 | SceneObjectPart part = GetPart(localID); |
3269 | 4265 | ||
3270 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3271 | // for (int i = 0; i < parts.Length; i++) | ||
3272 | // parts[i].StoreUndoState(); | ||
3273 | |||
3274 | if (part != null) | 4266 | if (part != null) |
3275 | { | 4267 | { |
3276 | // m_log.DebugFormat( | 4268 | // unlock parts position change |
3277 | // "[SCENE OBJECT GROUP]: Updating single position of {0} {1} to {2}", part.Name, part.LocalId, pos); | 4269 | if (m_rootPart.PhysActor != null) |
3278 | 4270 | m_rootPart.PhysActor.Building = true; | |
3279 | part.StoreUndoState(false); | ||
3280 | part.IgnoreUndoUpdate = true; | ||
3281 | 4271 | ||
3282 | if (part.UUID == m_rootPart.UUID) | 4272 | if (part.UUID == m_rootPart.UUID) |
3283 | { | 4273 | { |
@@ -3288,8 +4278,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3288 | part.UpdateOffSet(pos); | 4278 | part.UpdateOffSet(pos); |
3289 | } | 4279 | } |
3290 | 4280 | ||
4281 | if (m_rootPart.PhysActor != null) | ||
4282 | m_rootPart.PhysActor.Building = false; | ||
4283 | |||
3291 | HasGroupChanged = true; | 4284 | HasGroupChanged = true; |
3292 | part.IgnoreUndoUpdate = false; | ||
3293 | } | 4285 | } |
3294 | } | 4286 | } |
3295 | 4287 | ||
@@ -3299,13 +4291,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3299 | /// <param name="newPos"></param> | 4291 | /// <param name="newPos"></param> |
3300 | public void UpdateRootPosition(Vector3 newPos) | 4292 | public void UpdateRootPosition(Vector3 newPos) |
3301 | { | 4293 | { |
3302 | // m_log.DebugFormat( | 4294 | // needs to be called with phys building true |
3303 | // "[SCENE OBJECT GROUP]: Updating root position of {0} {1} to {2}", Name, LocalId, pos); | ||
3304 | |||
3305 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3306 | // for (int i = 0; i < parts.Length; i++) | ||
3307 | // parts[i].StoreUndoState(); | ||
3308 | |||
3309 | Vector3 oldPos; | 4295 | Vector3 oldPos; |
3310 | 4296 | ||
3311 | if (IsAttachment) | 4297 | if (IsAttachment) |
@@ -3326,12 +4312,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
3326 | } | 4312 | } |
3327 | 4313 | ||
3328 | AbsolutePosition = newPos; | 4314 | AbsolutePosition = newPos; |
3329 | 4315 | ||
3330 | if (IsAttachment) | 4316 | if (IsAttachment) |
3331 | m_rootPart.AttachedPos = newPos; | 4317 | m_rootPart.AttachedPos = newPos; |
3332 | 4318 | ||
3333 | HasGroupChanged = true; | 4319 | HasGroupChanged = true; |
3334 | ScheduleGroupForTerseUpdate(); | 4320 | if (m_rootPart.Undoing) |
4321 | { | ||
4322 | ScheduleGroupForFullUpdate(); | ||
4323 | } | ||
4324 | else | ||
4325 | { | ||
4326 | ScheduleGroupForTerseUpdate(); | ||
4327 | } | ||
3335 | } | 4328 | } |
3336 | 4329 | ||
3337 | #endregion | 4330 | #endregion |
@@ -3344,24 +4337,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3344 | /// <param name="rot"></param> | 4337 | /// <param name="rot"></param> |
3345 | public void UpdateGroupRotationR(Quaternion rot) | 4338 | public void UpdateGroupRotationR(Quaternion rot) |
3346 | { | 4339 | { |
3347 | // m_log.DebugFormat( | ||
3348 | // "[SCENE OBJECT GROUP]: Updating group rotation R of {0} {1} to {2}", Name, LocalId, rot); | ||
3349 | |||
3350 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3351 | // for (int i = 0; i < parts.Length; i++) | ||
3352 | // parts[i].StoreUndoState(); | ||
3353 | |||
3354 | m_rootPart.StoreUndoState(true); | ||
3355 | |||
3356 | m_rootPart.UpdateRotation(rot); | 4340 | m_rootPart.UpdateRotation(rot); |
3357 | 4341 | ||
4342 | /* this is done by rootpart RotationOffset set called by UpdateRotation | ||
3358 | PhysicsActor actor = m_rootPart.PhysActor; | 4343 | PhysicsActor actor = m_rootPart.PhysActor; |
3359 | if (actor != null) | 4344 | if (actor != null) |
3360 | { | 4345 | { |
3361 | actor.Orientation = m_rootPart.RotationOffset; | 4346 | actor.Orientation = m_rootPart.RotationOffset; |
3362 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); | 4347 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
3363 | } | 4348 | } |
3364 | 4349 | */ | |
3365 | HasGroupChanged = true; | 4350 | HasGroupChanged = true; |
3366 | ScheduleGroupForTerseUpdate(); | 4351 | ScheduleGroupForTerseUpdate(); |
3367 | } | 4352 | } |
@@ -3373,16 +4358,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3373 | /// <param name="rot"></param> | 4358 | /// <param name="rot"></param> |
3374 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) | 4359 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) |
3375 | { | 4360 | { |
3376 | // m_log.DebugFormat( | ||
3377 | // "[SCENE OBJECT GROUP]: Updating group rotation PR of {0} {1} to {2}", Name, LocalId, rot); | ||
3378 | |||
3379 | // SceneObjectPart[] parts = m_parts.GetArray(); | ||
3380 | // for (int i = 0; i < parts.Length; i++) | ||
3381 | // parts[i].StoreUndoState(); | ||
3382 | |||
3383 | RootPart.StoreUndoState(true); | ||
3384 | RootPart.IgnoreUndoUpdate = true; | ||
3385 | |||
3386 | m_rootPart.UpdateRotation(rot); | 4361 | m_rootPart.UpdateRotation(rot); |
3387 | 4362 | ||
3388 | PhysicsActor actor = m_rootPart.PhysActor; | 4363 | PhysicsActor actor = m_rootPart.PhysActor; |
@@ -3401,8 +4376,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3401 | 4376 | ||
3402 | HasGroupChanged = true; | 4377 | HasGroupChanged = true; |
3403 | ScheduleGroupForTerseUpdate(); | 4378 | ScheduleGroupForTerseUpdate(); |
3404 | |||
3405 | RootPart.IgnoreUndoUpdate = false; | ||
3406 | } | 4379 | } |
3407 | 4380 | ||
3408 | /// <summary> | 4381 | /// <summary> |
@@ -3415,13 +4388,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3415 | SceneObjectPart part = GetPart(localID); | 4388 | SceneObjectPart part = GetPart(localID); |
3416 | 4389 | ||
3417 | SceneObjectPart[] parts = m_parts.GetArray(); | 4390 | SceneObjectPart[] parts = m_parts.GetArray(); |
3418 | for (int i = 0; i < parts.Length; i++) | ||
3419 | parts[i].StoreUndoState(); | ||
3420 | 4391 | ||
3421 | if (part != null) | 4392 | if (part != null) |
3422 | { | 4393 | { |
3423 | // m_log.DebugFormat( | 4394 | if (m_rootPart.PhysActor != null) |
3424 | // "[SCENE OBJECT GROUP]: Updating single rotation of {0} {1} to {2}", part.Name, part.LocalId, rot); | 4395 | m_rootPart.PhysActor.Building = true; |
3425 | 4396 | ||
3426 | if (part.UUID == m_rootPart.UUID) | 4397 | if (part.UUID == m_rootPart.UUID) |
3427 | { | 4398 | { |
@@ -3431,6 +4402,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3431 | { | 4402 | { |
3432 | part.UpdateRotation(rot); | 4403 | part.UpdateRotation(rot); |
3433 | } | 4404 | } |
4405 | |||
4406 | if (m_rootPart.PhysActor != null) | ||
4407 | m_rootPart.PhysActor.Building = false; | ||
3434 | } | 4408 | } |
3435 | } | 4409 | } |
3436 | 4410 | ||
@@ -3444,12 +4418,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3444 | SceneObjectPart part = GetPart(localID); | 4418 | SceneObjectPart part = GetPart(localID); |
3445 | if (part != null) | 4419 | if (part != null) |
3446 | { | 4420 | { |
3447 | // m_log.DebugFormat( | 4421 | if (m_rootPart.PhysActor != null) |
3448 | // "[SCENE OBJECT GROUP]: Updating single position and rotation of {0} {1} to {2}", | 4422 | m_rootPart.PhysActor.Building = true; |
3449 | // part.Name, part.LocalId, rot); | ||
3450 | |||
3451 | part.StoreUndoState(); | ||
3452 | part.IgnoreUndoUpdate = true; | ||
3453 | 4423 | ||
3454 | if (part.UUID == m_rootPart.UUID) | 4424 | if (part.UUID == m_rootPart.UUID) |
3455 | { | 4425 | { |
@@ -3462,7 +4432,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3462 | part.OffsetPosition = pos; | 4432 | part.OffsetPosition = pos; |
3463 | } | 4433 | } |
3464 | 4434 | ||
3465 | part.IgnoreUndoUpdate = false; | 4435 | if (m_rootPart.PhysActor != null) |
4436 | m_rootPart.PhysActor.Building = false; | ||
3466 | } | 4437 | } |
3467 | } | 4438 | } |
3468 | 4439 | ||
@@ -3472,15 +4443,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3472 | /// <param name="rot"></param> | 4443 | /// <param name="rot"></param> |
3473 | public void UpdateRootRotation(Quaternion rot) | 4444 | public void UpdateRootRotation(Quaternion rot) |
3474 | { | 4445 | { |
3475 | // m_log.DebugFormat( | 4446 | // needs to be called with phys building true |
3476 | // "[SCENE OBJECT GROUP]: Updating root rotation of {0} {1} to {2}", | ||
3477 | // Name, LocalId, rot); | ||
3478 | |||
3479 | Quaternion axRot = rot; | 4447 | Quaternion axRot = rot; |
3480 | Quaternion oldParentRot = m_rootPart.RotationOffset; | 4448 | Quaternion oldParentRot = m_rootPart.RotationOffset; |
3481 | 4449 | ||
3482 | m_rootPart.StoreUndoState(); | 4450 | //Don't use UpdateRotation because it schedules an update prematurely |
3483 | m_rootPart.UpdateRotation(rot); | 4451 | m_rootPart.RotationOffset = rot; |
3484 | 4452 | ||
3485 | PhysicsActor pa = m_rootPart.PhysActor; | 4453 | PhysicsActor pa = m_rootPart.PhysActor; |
3486 | 4454 | ||
@@ -3496,35 +4464,145 @@ namespace OpenSim.Region.Framework.Scenes | |||
3496 | SceneObjectPart prim = parts[i]; | 4464 | SceneObjectPart prim = parts[i]; |
3497 | if (prim.UUID != m_rootPart.UUID) | 4465 | if (prim.UUID != m_rootPart.UUID) |
3498 | { | 4466 | { |
3499 | prim.IgnoreUndoUpdate = true; | 4467 | Quaternion NewRot = oldParentRot * prim.RotationOffset; |
4468 | NewRot = Quaternion.Inverse(axRot) * NewRot; | ||
4469 | prim.RotationOffset = NewRot; | ||
4470 | |||
3500 | Vector3 axPos = prim.OffsetPosition; | 4471 | Vector3 axPos = prim.OffsetPosition; |
4472 | |||
3501 | axPos *= oldParentRot; | 4473 | axPos *= oldParentRot; |
3502 | axPos *= Quaternion.Inverse(axRot); | 4474 | axPos *= Quaternion.Inverse(axRot); |
3503 | prim.OffsetPosition = axPos; | 4475 | prim.OffsetPosition = axPos; |
3504 | Quaternion primsRot = prim.RotationOffset; | ||
3505 | Quaternion newRot = oldParentRot * primsRot; | ||
3506 | newRot = Quaternion.Inverse(axRot) * newRot; | ||
3507 | prim.RotationOffset = newRot; | ||
3508 | prim.ScheduleTerseUpdate(); | ||
3509 | prim.IgnoreUndoUpdate = false; | ||
3510 | } | 4476 | } |
3511 | } | 4477 | } |
3512 | 4478 | ||
3513 | // for (int i = 0; i < parts.Length; i++) | 4479 | HasGroupChanged = true; |
3514 | // { | 4480 | ScheduleGroupForFullUpdate(); |
3515 | // SceneObjectPart childpart = parts[i]; | 4481 | } |
3516 | // if (childpart != m_rootPart) | ||
3517 | // { | ||
3518 | //// childpart.IgnoreUndoUpdate = false; | ||
3519 | //// childpart.StoreUndoState(); | ||
3520 | // } | ||
3521 | // } | ||
3522 | 4482 | ||
3523 | m_rootPart.ScheduleTerseUpdate(); | 4483 | private enum updatetype :int |
4484 | { | ||
4485 | none = 0, | ||
4486 | partterse = 1, | ||
4487 | partfull = 2, | ||
4488 | groupterse = 3, | ||
4489 | groupfull = 4 | ||
4490 | } | ||
3524 | 4491 | ||
3525 | // m_log.DebugFormat( | 4492 | public void doChangeObject(SceneObjectPart part, ObjectChangeData data) |
3526 | // "[SCENE OBJECT GROUP]: Updated root rotation of {0} {1} to {2}", | 4493 | { |
3527 | // Name, LocalId, rot); | 4494 | // TODO this still as excessive *.Schedule*Update()s |
4495 | |||
4496 | if (part != null && part.ParentGroup != null) | ||
4497 | { | ||
4498 | ObjectChangeType change = data.change; | ||
4499 | bool togroup = ((change & ObjectChangeType.Group) != 0); | ||
4500 | // bool uniform = ((what & ObjectChangeType.UniformScale) != 0); not in use | ||
4501 | |||
4502 | SceneObjectGroup group = part.ParentGroup; | ||
4503 | PhysicsActor pha = group.RootPart.PhysActor; | ||
4504 | |||
4505 | updatetype updateType = updatetype.none; | ||
4506 | |||
4507 | if (togroup) | ||
4508 | { | ||
4509 | // related to group | ||
4510 | if ((change & (ObjectChangeType.Rotation | ObjectChangeType.Position)) != 0) | ||
4511 | { | ||
4512 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4513 | { | ||
4514 | group.RootPart.UpdateRotation(data.rotation); | ||
4515 | updateType = updatetype.none; | ||
4516 | } | ||
4517 | if ((change & ObjectChangeType.Position) != 0) | ||
4518 | { | ||
4519 | if (IsAttachment || m_scene.Permissions.CanObjectEntry(group.UUID, false, data.position)) | ||
4520 | UpdateGroupPosition(data.position); | ||
4521 | updateType = updatetype.groupterse; | ||
4522 | } | ||
4523 | else | ||
4524 | // ugly rotation update of all parts | ||
4525 | { | ||
4526 | group.ResetChildPrimPhysicsPositions(); | ||
4527 | } | ||
4528 | |||
4529 | } | ||
4530 | if ((change & ObjectChangeType.Scale) != 0) | ||
4531 | { | ||
4532 | if (pha != null) | ||
4533 | pha.Building = true; | ||
4534 | |||
4535 | group.GroupResize(data.scale); | ||
4536 | updateType = updatetype.none; | ||
4537 | |||
4538 | if (pha != null) | ||
4539 | pha.Building = false; | ||
4540 | } | ||
4541 | } | ||
4542 | else | ||
4543 | { | ||
4544 | // related to single prim in a link-set ( ie group) | ||
4545 | if (pha != null) | ||
4546 | pha.Building = true; | ||
4547 | |||
4548 | // root part is special | ||
4549 | // parts offset positions or rotations need to change also | ||
4550 | |||
4551 | if (part == group.RootPart) | ||
4552 | { | ||
4553 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4554 | group.UpdateRootRotation(data.rotation); | ||
4555 | if ((change & ObjectChangeType.Position) != 0) | ||
4556 | group.UpdateRootPosition(data.position); | ||
4557 | if ((change & ObjectChangeType.Scale) != 0) | ||
4558 | part.Resize(data.scale); | ||
4559 | } | ||
4560 | else | ||
4561 | { | ||
4562 | if ((change & ObjectChangeType.Position) != 0) | ||
4563 | { | ||
4564 | part.OffsetPosition = data.position; | ||
4565 | updateType = updatetype.partterse; | ||
4566 | } | ||
4567 | if ((change & ObjectChangeType.Rotation) != 0) | ||
4568 | { | ||
4569 | part.UpdateRotation(data.rotation); | ||
4570 | updateType = updatetype.none; | ||
4571 | } | ||
4572 | if ((change & ObjectChangeType.Scale) != 0) | ||
4573 | { | ||
4574 | part.Resize(data.scale); | ||
4575 | updateType = updatetype.none; | ||
4576 | } | ||
4577 | } | ||
4578 | |||
4579 | if (pha != null) | ||
4580 | pha.Building = false; | ||
4581 | } | ||
4582 | |||
4583 | if (updateType != updatetype.none) | ||
4584 | { | ||
4585 | group.HasGroupChanged = true; | ||
4586 | |||
4587 | switch (updateType) | ||
4588 | { | ||
4589 | case updatetype.partterse: | ||
4590 | part.ScheduleTerseUpdate(); | ||
4591 | break; | ||
4592 | case updatetype.partfull: | ||
4593 | part.ScheduleFullUpdate(); | ||
4594 | break; | ||
4595 | case updatetype.groupterse: | ||
4596 | group.ScheduleGroupForTerseUpdate(); | ||
4597 | break; | ||
4598 | case updatetype.groupfull: | ||
4599 | group.ScheduleGroupForFullUpdate(); | ||
4600 | break; | ||
4601 | default: | ||
4602 | break; | ||
4603 | } | ||
4604 | } | ||
4605 | } | ||
3528 | } | 4606 | } |
3529 | 4607 | ||
3530 | #endregion | 4608 | #endregion |
@@ -3565,6 +4643,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3565 | waypoint.handle = handle; | 4643 | waypoint.handle = handle; |
3566 | lock (m_rotTargets) | 4644 | lock (m_rotTargets) |
3567 | { | 4645 | { |
4646 | if (m_rotTargets.Count >= 8) | ||
4647 | m_rotTargets.Remove(m_rotTargets.ElementAt(0).Key); | ||
3568 | m_rotTargets.Add(handle, waypoint); | 4648 | m_rotTargets.Add(handle, waypoint); |
3569 | } | 4649 | } |
3570 | m_scene.AddGroupTarget(this); | 4650 | m_scene.AddGroupTarget(this); |
@@ -3590,6 +4670,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3590 | waypoint.handle = handle; | 4670 | waypoint.handle = handle; |
3591 | lock (m_targets) | 4671 | lock (m_targets) |
3592 | { | 4672 | { |
4673 | if (m_targets.Count >= 8) | ||
4674 | m_targets.Remove(m_targets.ElementAt(0).Key); | ||
3593 | m_targets.Add(handle, waypoint); | 4675 | m_targets.Add(handle, waypoint); |
3594 | } | 4676 | } |
3595 | m_scene.AddGroupTarget(this); | 4677 | m_scene.AddGroupTarget(this); |
@@ -3623,10 +4705,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3623 | scriptPosTarget target = m_targets[idx]; | 4705 | scriptPosTarget target = m_targets[idx]; |
3624 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) | 4706 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) |
3625 | { | 4707 | { |
4708 | at_target = true; | ||
4709 | |||
3626 | // trigger at_target | 4710 | // trigger at_target |
3627 | if (m_scriptListens_atTarget) | 4711 | if (m_scriptListens_atTarget) |
3628 | { | 4712 | { |
3629 | at_target = true; | ||
3630 | scriptPosTarget att = new scriptPosTarget(); | 4713 | scriptPosTarget att = new scriptPosTarget(); |
3631 | att.targetPos = target.targetPos; | 4714 | att.targetPos = target.targetPos; |
3632 | att.tolerance = target.tolerance; | 4715 | att.tolerance = target.tolerance; |
@@ -3744,11 +4827,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
3744 | } | 4827 | } |
3745 | } | 4828 | } |
3746 | } | 4829 | } |
3747 | 4830 | ||
4831 | public Vector3 GetGeometricCenter() | ||
4832 | { | ||
4833 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
4834 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
4835 | // ignoring tortured prims details since sl also seems to ignore | ||
4836 | // so no real use in doing it on physics | ||
4837 | |||
4838 | Vector3 gc = Vector3.Zero; | ||
4839 | |||
4840 | int nparts = m_parts.Count; | ||
4841 | if (nparts <= 1) | ||
4842 | return gc; | ||
4843 | |||
4844 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4845 | nparts = parts.Length; // just in case it changed | ||
4846 | if (nparts <= 1) | ||
4847 | return gc; | ||
4848 | |||
4849 | Quaternion parentRot = RootPart.RotationOffset; | ||
4850 | Vector3 pPos; | ||
4851 | |||
4852 | // average all parts positions | ||
4853 | for (int i = 0; i < nparts; i++) | ||
4854 | { | ||
4855 | // do it directly | ||
4856 | // gc += parts[i].GetWorldPosition(); | ||
4857 | if (parts[i] != RootPart) | ||
4858 | { | ||
4859 | pPos = parts[i].OffsetPosition; | ||
4860 | gc += pPos; | ||
4861 | } | ||
4862 | |||
4863 | } | ||
4864 | gc /= nparts; | ||
4865 | |||
4866 | // relative to root: | ||
4867 | // gc -= AbsolutePosition; | ||
4868 | return gc; | ||
4869 | } | ||
4870 | |||
3748 | public float GetMass() | 4871 | public float GetMass() |
3749 | { | 4872 | { |
3750 | float retmass = 0f; | 4873 | float retmass = 0f; |
3751 | |||
3752 | SceneObjectPart[] parts = m_parts.GetArray(); | 4874 | SceneObjectPart[] parts = m_parts.GetArray(); |
3753 | for (int i = 0; i < parts.Length; i++) | 4875 | for (int i = 0; i < parts.Length; i++) |
3754 | retmass += parts[i].GetMass(); | 4876 | retmass += parts[i].GetMass(); |
@@ -3756,6 +4878,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
3756 | return retmass; | 4878 | return retmass; |
3757 | } | 4879 | } |
3758 | 4880 | ||
4881 | // center of mass of full object | ||
4882 | public Vector3 GetCenterOfMass() | ||
4883 | { | ||
4884 | PhysicsActor pa = RootPart.PhysActor; | ||
4885 | |||
4886 | if(((RootPart.Flags & PrimFlags.Physics) !=0) && pa !=null) | ||
4887 | { | ||
4888 | // physics knows better about center of mass of physical prims | ||
4889 | Vector3 tmp = pa.CenterOfMass; | ||
4890 | return tmp; | ||
4891 | } | ||
4892 | |||
4893 | Vector3 Ptot = Vector3.Zero; | ||
4894 | float totmass = 0f; | ||
4895 | float m; | ||
4896 | |||
4897 | SceneObjectPart[] parts = m_parts.GetArray(); | ||
4898 | for (int i = 0; i < parts.Length; i++) | ||
4899 | { | ||
4900 | m = parts[i].GetMass(); | ||
4901 | Ptot += parts[i].GetPartCenterOfMass() * m; | ||
4902 | totmass += m; | ||
4903 | } | ||
4904 | |||
4905 | if (totmass == 0) | ||
4906 | totmass = 0; | ||
4907 | else | ||
4908 | totmass = 1 / totmass; | ||
4909 | Ptot *= totmass; | ||
4910 | |||
4911 | return Ptot; | ||
4912 | } | ||
4913 | |||
3759 | /// <summary> | 4914 | /// <summary> |
3760 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that | 4915 | /// If the object is a sculpt/mesh, retrieve the mesh data for each part and reinsert it into each shape so that |
3761 | /// the physics engine can use it. | 4916 | /// the physics engine can use it. |
@@ -3935,6 +5090,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3935 | FromItemID = uuid; | 5090 | FromItemID = uuid; |
3936 | } | 5091 | } |
3937 | 5092 | ||
5093 | public void ResetOwnerChangeFlag() | ||
5094 | { | ||
5095 | ForEachPart(delegate(SceneObjectPart part) | ||
5096 | { | ||
5097 | part.ResetOwnerChangeFlag(); | ||
5098 | }); | ||
5099 | } | ||
5100 | |||
3938 | #endregion | 5101 | #endregion |
3939 | } | 5102 | } |
3940 | } | 5103 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f6e8c7f..1cfa8ed 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -64,7 +64,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
64 | TELEPORT = 512, | 64 | TELEPORT = 512, |
65 | REGION_RESTART = 1024, | 65 | REGION_RESTART = 1024, |
66 | MEDIA = 2048, | 66 | MEDIA = 2048, |
67 | ANIMATION = 16384 | 67 | ANIMATION = 16384, |
68 | POSITION = 32768 | ||
68 | } | 69 | } |
69 | 70 | ||
70 | // I don't really know where to put this except here. | 71 | // I don't really know where to put this except here. |
@@ -123,7 +124,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
123 | /// Denote all sides of the prim | 124 | /// Denote all sides of the prim |
124 | /// </value> | 125 | /// </value> |
125 | public const int ALL_SIDES = -1; | 126 | public const int ALL_SIDES = -1; |
126 | 127 | ||
128 | private const scriptEvents PhysicsNeededSubsEvents = ( | ||
129 | scriptEvents.collision | scriptEvents.collision_start | scriptEvents.collision_end | | ||
130 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
131 | ); | ||
132 | private const scriptEvents PhyscicsPhantonSubsEvents = ( | ||
133 | scriptEvents.land_collision | scriptEvents.land_collision_start | scriptEvents.land_collision_end | ||
134 | ); | ||
135 | private const scriptEvents PhyscicsVolumeDtcSubsEvents = ( | ||
136 | scriptEvents.collision_start | scriptEvents.collision_end | ||
137 | ); | ||
138 | |||
127 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 139 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
128 | 140 | ||
129 | /// <summary> | 141 | /// <summary> |
@@ -160,7 +172,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
160 | /// </remarks> | 172 | /// </remarks> |
161 | public bool IsRoot | 173 | public bool IsRoot |
162 | { | 174 | { |
163 | get { return ParentGroup.RootPart == this; } | 175 | get { return Object.ReferenceEquals(ParentGroup.RootPart, this); } |
164 | } | 176 | } |
165 | 177 | ||
166 | /// <summary> | 178 | /// <summary> |
@@ -233,6 +245,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
233 | 245 | ||
234 | public uint TimeStampTerse; | 246 | public uint TimeStampTerse; |
235 | 247 | ||
248 | // The following two are to hold the attachment data | ||
249 | // while an object is inworld | ||
250 | [XmlIgnore] | ||
251 | public byte AttachPoint = 0; | ||
252 | |||
253 | [XmlIgnore] | ||
254 | public Quaternion AttachRotation = Quaternion.Identity; | ||
255 | |||
256 | [XmlIgnore] | ||
236 | public int STATUS_ROTATE_X; | 257 | public int STATUS_ROTATE_X; |
237 | 258 | ||
238 | public int STATUS_ROTATE_Y; | 259 | public int STATUS_ROTATE_Y; |
@@ -259,8 +280,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
259 | 280 | ||
260 | public Vector3 RotationAxis = Vector3.One; | 281 | public Vector3 RotationAxis = Vector3.One; |
261 | 282 | ||
262 | public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this | 283 | public bool VolumeDetectActive; |
263 | // Certainly this must be a persistant setting finally | ||
264 | 284 | ||
265 | public bool IsWaitingForFirstSpinUpdatePacket; | 285 | public bool IsWaitingForFirstSpinUpdatePacket; |
266 | 286 | ||
@@ -300,10 +320,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
300 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; | 320 | private Quaternion m_sitTargetOrientation = Quaternion.Identity; |
301 | private Vector3 m_sitTargetPosition; | 321 | private Vector3 m_sitTargetPosition; |
302 | private string m_sitAnimation = "SIT"; | 322 | private string m_sitAnimation = "SIT"; |
323 | private bool m_occupied; // KF if any av is sitting on this prim | ||
303 | private string m_text = String.Empty; | 324 | private string m_text = String.Empty; |
304 | private string m_touchName = String.Empty; | 325 | private string m_touchName = String.Empty; |
305 | private readonly List<UndoState> m_undo = new List<UndoState>(5); | 326 | private UndoRedoState m_UndoRedo = null; |
306 | private readonly List<UndoState> m_redo = new List<UndoState>(5); | ||
307 | 327 | ||
308 | private bool m_passTouches = false; | 328 | private bool m_passTouches = false; |
309 | private bool m_passCollisions = false; | 329 | private bool m_passCollisions = false; |
@@ -331,14 +351,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
331 | protected Vector3 m_lastVelocity; | 351 | protected Vector3 m_lastVelocity; |
332 | protected Vector3 m_lastAcceleration; | 352 | protected Vector3 m_lastAcceleration; |
333 | protected Vector3 m_lastAngularVelocity; | 353 | protected Vector3 m_lastAngularVelocity; |
334 | protected int m_lastTerseSent; | 354 | protected int m_lastUpdateSentTime; |
355 | protected float m_buoyancy = 0.0f; | ||
356 | protected Vector3 m_force; | ||
357 | protected Vector3 m_torque; | ||
335 | 358 | ||
336 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; | 359 | protected byte m_physicsShapeType = (byte)PhysShapeType.prim; |
337 | protected float m_density = 1000.0f; // in kg/m^3 | 360 | protected float m_density = 1000.0f; // in kg/m^3 |
338 | protected float m_gravitymod = 1.0f; | 361 | protected float m_gravitymod = 1.0f; |
339 | protected float m_friction = 0.6f; // wood | 362 | protected float m_friction = 0.6f; // wood |
340 | protected float m_bounce = 0.5f; // wood | 363 | protected float m_bounce = 0.5f; // wood |
341 | 364 | ||
365 | |||
366 | protected bool m_isSelected = false; | ||
367 | |||
342 | /// <summary> | 368 | /// <summary> |
343 | /// Stores media texture data | 369 | /// Stores media texture data |
344 | /// </summary> | 370 | /// </summary> |
@@ -350,15 +376,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
350 | private Vector3 m_cameraAtOffset; | 376 | private Vector3 m_cameraAtOffset; |
351 | private bool m_forceMouselook; | 377 | private bool m_forceMouselook; |
352 | 378 | ||
353 | // TODO: Collision sound should have default. | 379 | |
380 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
381 | private sbyte m_collisionSoundType; | ||
354 | private UUID m_collisionSound; | 382 | private UUID m_collisionSound; |
355 | private float m_collisionSoundVolume; | 383 | private float m_collisionSoundVolume; |
356 | 384 | ||
385 | private int LastColSoundSentTime; | ||
386 | |||
387 | |||
388 | private SOPVehicle m_vehicleParams = null; | ||
389 | |||
357 | public KeyframeMotion KeyframeMotion | 390 | public KeyframeMotion KeyframeMotion |
358 | { | 391 | { |
359 | get; set; | 392 | get; set; |
360 | } | 393 | } |
361 | 394 | ||
395 | |||
362 | #endregion Fields | 396 | #endregion Fields |
363 | 397 | ||
364 | // ~SceneObjectPart() | 398 | // ~SceneObjectPart() |
@@ -388,6 +422,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
388 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from | 422 | // this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from |
389 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log | 423 | // the prim into an agent inventory (Linden client reports that the "Object not found for drop" in its log |
390 | m_inventory = new SceneObjectPartInventory(this); | 424 | m_inventory = new SceneObjectPartInventory(this); |
425 | LastColSoundSentTime = Util.EnvironmentTickCount(); | ||
391 | } | 426 | } |
392 | 427 | ||
393 | /// <summary> | 428 | /// <summary> |
@@ -402,7 +437,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
402 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, | 437 | UUID ownerID, PrimitiveBaseShape shape, Vector3 groupPosition, |
403 | Quaternion rotationOffset, Vector3 offsetPosition) : this() | 438 | Quaternion rotationOffset, Vector3 offsetPosition) : this() |
404 | { | 439 | { |
405 | m_name = "Primitive"; | 440 | m_name = "Object"; |
406 | 441 | ||
407 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); | 442 | CreationDate = (int)Utils.DateTimeToUnixTime(Rezzed); |
408 | LastOwnerID = CreatorID = OwnerID = ownerID; | 443 | LastOwnerID = CreatorID = OwnerID = ownerID; |
@@ -441,7 +476,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
441 | private uint _ownerMask = (uint)(PermissionMask.All | PermissionMask.Export); | 476 | private uint _ownerMask = (uint)(PermissionMask.All | PermissionMask.Export); |
442 | private uint _groupMask = (uint)PermissionMask.None; | 477 | private uint _groupMask = (uint)PermissionMask.None; |
443 | private uint _everyoneMask = (uint)PermissionMask.None; | 478 | private uint _everyoneMask = (uint)PermissionMask.None; |
444 | private uint _nextOwnerMask = (uint)PermissionMask.All; | 479 | private uint _nextOwnerMask = (uint)(PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer); |
445 | private PrimFlags _flags = PrimFlags.None; | 480 | private PrimFlags _flags = PrimFlags.None; |
446 | private DateTime m_expires; | 481 | private DateTime m_expires; |
447 | private DateTime m_rezzed; | 482 | private DateTime m_rezzed; |
@@ -539,12 +574,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
539 | } | 574 | } |
540 | 575 | ||
541 | /// <value> | 576 | /// <value> |
542 | /// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes | 577 | /// Get the inventory list |
543 | /// </value> | 578 | /// </value> |
544 | public TaskInventoryDictionary TaskInventory | 579 | public TaskInventoryDictionary TaskInventory |
545 | { | 580 | { |
546 | get { return m_inventory.Items; } | 581 | get { |
547 | set { m_inventory.Items = value; } | 582 | return m_inventory.Items; |
583 | } | ||
584 | set { | ||
585 | m_inventory.Items = value; | ||
586 | } | ||
548 | } | 587 | } |
549 | 588 | ||
550 | /// <summary> | 589 | /// <summary> |
@@ -594,20 +633,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
594 | } | 633 | } |
595 | } | 634 | } |
596 | 635 | ||
597 | public byte Material | ||
598 | { | ||
599 | get { return (byte) m_material; } | ||
600 | set | ||
601 | { | ||
602 | m_material = (Material)value; | ||
603 | |||
604 | PhysicsActor pa = PhysActor; | ||
605 | |||
606 | if (pa != null) | ||
607 | pa.SetMaterial((int)value); | ||
608 | } | ||
609 | } | ||
610 | |||
611 | [XmlIgnore] | 636 | [XmlIgnore] |
612 | public bool PassTouches | 637 | public bool PassTouches |
613 | { | 638 | { |
@@ -633,6 +658,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
633 | } | 658 | } |
634 | } | 659 | } |
635 | 660 | ||
661 | public bool IsSelected | ||
662 | { | ||
663 | get { return m_isSelected; } | ||
664 | set | ||
665 | { | ||
666 | m_isSelected = value; | ||
667 | if (ParentGroup != null) | ||
668 | ParentGroup.PartSelectChanged(value); | ||
669 | |||
670 | } | ||
671 | } | ||
672 | |||
673 | |||
636 | public Dictionary<int, string> CollisionFilter | 674 | public Dictionary<int, string> CollisionFilter |
637 | { | 675 | { |
638 | get { return m_CollisionFilter; } | 676 | get { return m_CollisionFilter; } |
@@ -707,14 +745,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
707 | set { m_LoopSoundSlavePrims = value; } | 745 | set { m_LoopSoundSlavePrims = value; } |
708 | } | 746 | } |
709 | 747 | ||
710 | |||
711 | public Byte[] TextureAnimation | 748 | public Byte[] TextureAnimation |
712 | { | 749 | { |
713 | get { return m_TextureAnimation; } | 750 | get { return m_TextureAnimation; } |
714 | set { m_TextureAnimation = value; } | 751 | set { m_TextureAnimation = value; } |
715 | } | 752 | } |
716 | 753 | ||
717 | |||
718 | public Byte[] ParticleSystem | 754 | public Byte[] ParticleSystem |
719 | { | 755 | { |
720 | get { return m_particleSystem; } | 756 | get { return m_particleSystem; } |
@@ -742,18 +778,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
742 | set { m_damage = value; } | 778 | set { m_damage = value; } |
743 | } | 779 | } |
744 | 780 | ||
781 | |||
782 | |||
783 | |||
784 | public void setGroupPosition(Vector3 pos) | ||
785 | { | ||
786 | m_groupPosition = pos; | ||
787 | } | ||
788 | |||
745 | /// <summary> | 789 | /// <summary> |
746 | /// The position of the entire group that this prim belongs to. | 790 | /// The position of the entire group that this prim belongs to. |
747 | /// </summary> | 791 | /// </summary> |
792 | /// | ||
793 | |||
794 | |||
748 | public Vector3 GroupPosition | 795 | public Vector3 GroupPosition |
749 | { | 796 | { |
750 | get | 797 | get |
751 | { | 798 | { |
752 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 799 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
753 | PhysicsActor actor = PhysActor; | 800 | PhysicsActor actor = PhysActor; |
754 | // If physical and the root prim of a linkset, the position of the group is what physics thinks. | 801 | if (ParentID == 0) |
755 | if (actor != null && ParentID == 0) | 802 | { |
756 | m_groupPosition = actor.Position; | 803 | if (actor != null) |
804 | m_groupPosition = actor.Position; | ||
805 | return m_groupPosition; | ||
806 | } | ||
757 | 807 | ||
758 | // If I'm an attachment, my position is reported as the position of who I'm attached to | 808 | // If I'm an attachment, my position is reported as the position of who I'm attached to |
759 | if (ParentGroup.IsAttachment) | 809 | if (ParentGroup.IsAttachment) |
@@ -763,21 +813,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
763 | return sp.AbsolutePosition; | 813 | return sp.AbsolutePosition; |
764 | } | 814 | } |
765 | 815 | ||
816 | // use root prim's group position. Physics may have updated it | ||
817 | if (ParentGroup.RootPart != this) | ||
818 | m_groupPosition = ParentGroup.RootPart.GroupPosition; | ||
766 | return m_groupPosition; | 819 | return m_groupPosition; |
767 | } | 820 | } |
768 | set | 821 | set |
769 | { | 822 | { |
770 | m_groupPosition = value; | 823 | m_groupPosition = value; |
771 | |||
772 | PhysicsActor actor = PhysActor; | 824 | PhysicsActor actor = PhysActor; |
773 | if (actor != null) | 825 | if (actor != null && ParentGroup.Scene.PhysicsScene != null) |
774 | { | 826 | { |
775 | try | 827 | try |
776 | { | 828 | { |
777 | // Root prim actually goes at Position | 829 | // Root prim actually goes at Position |
778 | if (ParentID == 0) | 830 | if (ParentID == 0) |
779 | { | 831 | { |
780 | actor.Position = value; | 832 | actor.Position = value; |
781 | } | 833 | } |
782 | else | 834 | else |
783 | { | 835 | { |
@@ -798,12 +850,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
798 | } | 850 | } |
799 | } | 851 | } |
800 | 852 | ||
853 | public void setOffsetPosition(Vector3 pos) | ||
854 | { | ||
855 | m_offsetPosition = pos; | ||
856 | } | ||
857 | |||
801 | public Vector3 OffsetPosition | 858 | public Vector3 OffsetPosition |
802 | { | 859 | { |
803 | get { return m_offsetPosition; } | 860 | get { return m_offsetPosition; } |
804 | set | 861 | set |
805 | { | 862 | { |
806 | // StoreUndoState(); | 863 | Vector3 oldpos = m_offsetPosition; |
807 | m_offsetPosition = value; | 864 | m_offsetPosition = value; |
808 | 865 | ||
809 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 866 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
@@ -815,10 +872,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
815 | actor.Orientation = GetWorldRotation(); | 872 | actor.Orientation = GetWorldRotation(); |
816 | 873 | ||
817 | // Tell the physics engines that this prim changed. | 874 | // Tell the physics engines that this prim changed. |
818 | if (ParentGroup.Scene != null) | 875 | if (ParentGroup.Scene != null && ParentGroup.Scene.PhysicsScene != null) |
819 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 876 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
820 | } | 877 | } |
878 | |||
879 | if (!m_parentGroup.m_dupeInProgress) | ||
880 | { | ||
881 | List<ScenePresence> avs = ParentGroup.GetLinkedAvatars(); | ||
882 | foreach (ScenePresence av in avs) | ||
883 | { | ||
884 | if (av.ParentID == m_localId) | ||
885 | { | ||
886 | Vector3 offset = (m_offsetPosition - oldpos); | ||
887 | av.AbsolutePosition += offset; | ||
888 | // av.SendAvatarDataToAllAgents(); | ||
889 | av.SendTerseUpdateToAllClients(); | ||
890 | } | ||
891 | } | ||
892 | } | ||
821 | } | 893 | } |
894 | TriggerScriptChangedEvent(Changed.POSITION); | ||
822 | } | 895 | } |
823 | } | 896 | } |
824 | 897 | ||
@@ -840,6 +913,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
840 | } | 913 | } |
841 | } | 914 | } |
842 | 915 | ||
916 | public void setRotationOffset(Quaternion q) | ||
917 | { | ||
918 | m_rotationOffset = q; | ||
919 | } | ||
920 | |||
843 | public Quaternion RotationOffset | 921 | public Quaternion RotationOffset |
844 | { | 922 | { |
845 | get | 923 | get |
@@ -869,7 +947,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
869 | 947 | ||
870 | set | 948 | set |
871 | { | 949 | { |
872 | StoreUndoState(); | 950 | // StoreUndoState(); |
873 | m_rotationOffset = value; | 951 | m_rotationOffset = value; |
874 | 952 | ||
875 | PhysicsActor actor = PhysActor; | 953 | PhysicsActor actor = PhysActor; |
@@ -960,7 +1038,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
960 | get | 1038 | get |
961 | { | 1039 | { |
962 | PhysicsActor actor = PhysActor; | 1040 | PhysicsActor actor = PhysActor; |
963 | if ((actor != null) && actor.IsPhysical) | 1041 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this) |
964 | { | 1042 | { |
965 | m_angularVelocity = actor.RotationalVelocity; | 1043 | m_angularVelocity = actor.RotationalVelocity; |
966 | } | 1044 | } |
@@ -968,6 +1046,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
968 | } | 1046 | } |
969 | set | 1047 | set |
970 | { | 1048 | { |
1049 | <<<<<<< HEAD | ||
971 | if (Util.IsNanOrInfinity(value)) | 1050 | if (Util.IsNanOrInfinity(value)) |
972 | m_angularVelocity = Vector3.Zero; | 1051 | m_angularVelocity = Vector3.Zero; |
973 | else | 1052 | else |
@@ -976,12 +1055,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
976 | PhysicsActor actor = PhysActor; | 1055 | PhysicsActor actor = PhysActor; |
977 | if ((actor != null) && actor.IsPhysical) | 1056 | if ((actor != null) && actor.IsPhysical) |
978 | actor.RotationalVelocity = m_angularVelocity; | 1057 | actor.RotationalVelocity = m_angularVelocity; |
1058 | ======= | ||
1059 | m_angularVelocity = value; | ||
1060 | PhysicsActor actor = PhysActor; | ||
1061 | if ((actor != null) && actor.IsPhysical && ParentGroup.RootPart == this && VehicleType == (int)Vehicle.TYPE_NONE) | ||
1062 | { | ||
1063 | actor.RotationalVelocity = m_angularVelocity; | ||
1064 | } | ||
1065 | >>>>>>> avn/ubitvar | ||
979 | } | 1066 | } |
980 | } | 1067 | } |
981 | 1068 | ||
982 | /// <summary></summary> | 1069 | /// <summary></summary> |
983 | public Vector3 Acceleration | 1070 | public Vector3 Acceleration |
984 | { | 1071 | { |
1072 | <<<<<<< HEAD | ||
985 | get { return m_acceleration; } | 1073 | get { return m_acceleration; } |
986 | set | 1074 | set |
987 | { | 1075 | { |
@@ -990,6 +1078,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
990 | else | 1078 | else |
991 | m_acceleration = value; | 1079 | m_acceleration = value; |
992 | } | 1080 | } |
1081 | ======= | ||
1082 | get | ||
1083 | { | ||
1084 | PhysicsActor actor = PhysActor; | ||
1085 | if (actor != null) | ||
1086 | { | ||
1087 | m_acceleration = actor.Acceleration; | ||
1088 | } | ||
1089 | return m_acceleration; | ||
1090 | } | ||
1091 | |||
1092 | set { m_acceleration = value; } | ||
1093 | >>>>>>> avn/ubitvar | ||
993 | } | 1094 | } |
994 | 1095 | ||
995 | public string Description { get; set; } | 1096 | public string Description { get; set; } |
@@ -1056,7 +1157,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1056 | public PrimitiveBaseShape Shape | 1157 | public PrimitiveBaseShape Shape |
1057 | { | 1158 | { |
1058 | get { return m_shape; } | 1159 | get { return m_shape; } |
1059 | set { m_shape = value;} | 1160 | set |
1161 | { | ||
1162 | m_shape = value; | ||
1163 | } | ||
1060 | } | 1164 | } |
1061 | 1165 | ||
1062 | /// <summary> | 1166 | /// <summary> |
@@ -1069,7 +1173,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1069 | { | 1173 | { |
1070 | if (m_shape != null) | 1174 | if (m_shape != null) |
1071 | { | 1175 | { |
1072 | StoreUndoState(); | ||
1073 | 1176 | ||
1074 | m_shape.Scale = value; | 1177 | m_shape.Scale = value; |
1075 | 1178 | ||
@@ -1137,10 +1240,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1137 | { | 1240 | { |
1138 | get | 1241 | get |
1139 | { | 1242 | { |
1140 | if (ParentGroup.IsAttachment) | 1243 | return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); |
1141 | return GroupPosition; | ||
1142 | |||
1143 | return m_offsetPosition + m_groupPosition; | ||
1144 | } | 1244 | } |
1145 | } | 1245 | } |
1146 | 1246 | ||
@@ -1309,6 +1409,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1309 | _flags = value; | 1409 | _flags = value; |
1310 | } | 1410 | } |
1311 | } | 1411 | } |
1412 | |||
1413 | [XmlIgnore] | ||
1414 | public bool IsOccupied // KF If an av is sittingon this prim | ||
1415 | { | ||
1416 | get { return m_occupied; } | ||
1417 | set { m_occupied = value; } | ||
1418 | } | ||
1312 | 1419 | ||
1313 | /// <summary> | 1420 | /// <summary> |
1314 | /// 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 | 1421 | /// 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 |
@@ -1359,12 +1466,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1359 | set { m_sitAnimation = value; } | 1466 | set { m_sitAnimation = value; } |
1360 | } | 1467 | } |
1361 | 1468 | ||
1469 | public UUID invalidCollisionSoundUUID = new UUID("ffffffff-ffff-ffff-ffff-ffffffffffff"); | ||
1470 | |||
1471 | // 0 for default collision sounds, -1 for script disabled sound 1 for script defined sound | ||
1472 | // runtime thing.. do not persist | ||
1473 | [XmlIgnore] | ||
1474 | public sbyte CollisionSoundType | ||
1475 | { | ||
1476 | get | ||
1477 | { | ||
1478 | return m_collisionSoundType; | ||
1479 | } | ||
1480 | set | ||
1481 | { | ||
1482 | m_collisionSoundType = value; | ||
1483 | if (value == -1) | ||
1484 | m_collisionSound = invalidCollisionSoundUUID; | ||
1485 | else if (value == 0) | ||
1486 | m_collisionSound = UUID.Zero; | ||
1487 | } | ||
1488 | } | ||
1489 | |||
1362 | public UUID CollisionSound | 1490 | public UUID CollisionSound |
1363 | { | 1491 | { |
1364 | get { return m_collisionSound; } | 1492 | get { return m_collisionSound; } |
1365 | set | 1493 | set |
1366 | { | 1494 | { |
1367 | m_collisionSound = value; | 1495 | m_collisionSound = value; |
1496 | |||
1497 | if (value == invalidCollisionSoundUUID) | ||
1498 | m_collisionSoundType = -1; | ||
1499 | else if (value == UUID.Zero) | ||
1500 | m_collisionSoundType = 0; | ||
1501 | else | ||
1502 | m_collisionSoundType = 1; | ||
1503 | |||
1368 | aggregateScriptEvents(); | 1504 | aggregateScriptEvents(); |
1369 | } | 1505 | } |
1370 | } | 1506 | } |
@@ -1375,6 +1511,125 @@ namespace OpenSim.Region.Framework.Scenes | |||
1375 | set { m_collisionSoundVolume = value; } | 1511 | set { m_collisionSoundVolume = value; } |
1376 | } | 1512 | } |
1377 | 1513 | ||
1514 | public float Buoyancy | ||
1515 | { | ||
1516 | get | ||
1517 | { | ||
1518 | if (ParentGroup.RootPart == this) | ||
1519 | return m_buoyancy; | ||
1520 | |||
1521 | return ParentGroup.RootPart.Buoyancy; | ||
1522 | } | ||
1523 | set | ||
1524 | { | ||
1525 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1526 | { | ||
1527 | ParentGroup.RootPart.Buoyancy = value; | ||
1528 | return; | ||
1529 | } | ||
1530 | m_buoyancy = value; | ||
1531 | if (PhysActor != null) | ||
1532 | PhysActor.Buoyancy = value; | ||
1533 | } | ||
1534 | } | ||
1535 | |||
1536 | public Vector3 Force | ||
1537 | { | ||
1538 | get | ||
1539 | { | ||
1540 | if (ParentGroup.RootPart == this) | ||
1541 | return m_force; | ||
1542 | |||
1543 | return ParentGroup.RootPart.Force; | ||
1544 | } | ||
1545 | |||
1546 | set | ||
1547 | { | ||
1548 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1549 | { | ||
1550 | ParentGroup.RootPart.Force = value; | ||
1551 | return; | ||
1552 | } | ||
1553 | m_force = value; | ||
1554 | if (PhysActor != null) | ||
1555 | PhysActor.Force = value; | ||
1556 | } | ||
1557 | } | ||
1558 | |||
1559 | public Vector3 Torque | ||
1560 | { | ||
1561 | get | ||
1562 | { | ||
1563 | if (ParentGroup.RootPart == this) | ||
1564 | return m_torque; | ||
1565 | |||
1566 | return ParentGroup.RootPart.Torque; | ||
1567 | } | ||
1568 | |||
1569 | set | ||
1570 | { | ||
1571 | if (ParentGroup != null && ParentGroup.RootPart != null && ParentGroup.RootPart != this) | ||
1572 | { | ||
1573 | ParentGroup.RootPart.Torque = value; | ||
1574 | return; | ||
1575 | } | ||
1576 | m_torque = value; | ||
1577 | if (PhysActor != null) | ||
1578 | PhysActor.Torque = value; | ||
1579 | } | ||
1580 | } | ||
1581 | |||
1582 | public byte Material | ||
1583 | { | ||
1584 | get { return (byte)m_material; } | ||
1585 | set | ||
1586 | { | ||
1587 | if (value >= 0 && value <= (byte)SOPMaterialData.MaxMaterial) | ||
1588 | { | ||
1589 | bool update = false; | ||
1590 | |||
1591 | if (m_material != (Material)value) | ||
1592 | { | ||
1593 | update = true; | ||
1594 | m_material = (Material)value; | ||
1595 | } | ||
1596 | |||
1597 | if (m_friction != SOPMaterialData.friction(m_material)) | ||
1598 | { | ||
1599 | update = true; | ||
1600 | m_friction = SOPMaterialData.friction(m_material); | ||
1601 | } | ||
1602 | |||
1603 | if (m_bounce != SOPMaterialData.bounce(m_material)) | ||
1604 | { | ||
1605 | update = true; | ||
1606 | m_bounce = SOPMaterialData.bounce(m_material); | ||
1607 | } | ||
1608 | |||
1609 | if (update) | ||
1610 | { | ||
1611 | if (PhysActor != null) | ||
1612 | { | ||
1613 | PhysActor.SetMaterial((int)value); | ||
1614 | } | ||
1615 | if(ParentGroup != null) | ||
1616 | ParentGroup.HasGroupChanged = true; | ||
1617 | ScheduleFullUpdateIfNone(); | ||
1618 | UpdatePhysRequired = true; | ||
1619 | } | ||
1620 | } | ||
1621 | } | ||
1622 | } | ||
1623 | |||
1624 | // not a propriety to move to methods place later | ||
1625 | private bool HasMesh() | ||
1626 | { | ||
1627 | if (Shape != null && (Shape.SculptType == (byte)SculptType.Mesh)) | ||
1628 | return true; | ||
1629 | return false; | ||
1630 | } | ||
1631 | |||
1632 | // not a propriety to move to methods place later | ||
1378 | public byte DefaultPhysicsShapeType() | 1633 | public byte DefaultPhysicsShapeType() |
1379 | { | 1634 | { |
1380 | byte type; | 1635 | byte type; |
@@ -1387,6 +1642,65 @@ namespace OpenSim.Region.Framework.Scenes | |||
1387 | return type; | 1642 | return type; |
1388 | } | 1643 | } |
1389 | 1644 | ||
1645 | [XmlIgnore] | ||
1646 | public bool UsesComplexCost | ||
1647 | { | ||
1648 | get | ||
1649 | { | ||
1650 | byte pst = PhysicsShapeType; | ||
1651 | if(pst == (byte) PhysShapeType.none || pst == (byte) PhysShapeType.convex || HasMesh()) | ||
1652 | return true; | ||
1653 | return false; | ||
1654 | } | ||
1655 | } | ||
1656 | |||
1657 | [XmlIgnore] | ||
1658 | public float PhysicsCost | ||
1659 | { | ||
1660 | get | ||
1661 | { | ||
1662 | if(PhysicsShapeType == (byte)PhysShapeType.none) | ||
1663 | return 0; | ||
1664 | |||
1665 | float cost = 0.1f; | ||
1666 | if (PhysActor != null) | ||
1667 | cost = PhysActor.PhysicsCost; | ||
1668 | else | ||
1669 | cost = 0.1f; | ||
1670 | |||
1671 | if ((Flags & PrimFlags.Physics) != 0) | ||
1672 | cost *= (1.0f + 0.01333f * Scale.LengthSquared()); // 0.01333 == 0.04/3 | ||
1673 | return cost; | ||
1674 | } | ||
1675 | } | ||
1676 | |||
1677 | [XmlIgnore] | ||
1678 | public float StreamingCost | ||
1679 | { | ||
1680 | get | ||
1681 | { | ||
1682 | float cost; | ||
1683 | if (PhysActor != null) | ||
1684 | cost = PhysActor.StreamCost; | ||
1685 | else | ||
1686 | cost = 1.0f; | ||
1687 | return 1.0f; | ||
1688 | } | ||
1689 | } | ||
1690 | |||
1691 | [XmlIgnore] | ||
1692 | public float SimulationCost | ||
1693 | { | ||
1694 | get | ||
1695 | { | ||
1696 | // ignoring scripts. Don't like considering them for this | ||
1697 | if((Flags & PrimFlags.Physics) != 0) | ||
1698 | return 1.0f; | ||
1699 | |||
1700 | return 0.5f; | ||
1701 | } | ||
1702 | } | ||
1703 | |||
1390 | public byte PhysicsShapeType | 1704 | public byte PhysicsShapeType |
1391 | { | 1705 | { |
1392 | get { return m_physicsShapeType; } | 1706 | get { return m_physicsShapeType; } |
@@ -1420,11 +1734,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1420 | } | 1734 | } |
1421 | else if (PhysActor == null) | 1735 | else if (PhysActor == null) |
1422 | { | 1736 | { |
1423 | ApplyPhysics((uint)Flags, VolumeDetectActive); | 1737 | ApplyPhysics((uint)Flags, VolumeDetectActive, false); |
1738 | UpdatePhysicsSubscribedEvents(); | ||
1424 | } | 1739 | } |
1425 | else | 1740 | else |
1426 | { | 1741 | { |
1427 | PhysActor.PhysicsShapeType = m_physicsShapeType; | 1742 | PhysActor.PhysicsShapeType = m_physicsShapeType; |
1743 | // if (Shape.SculptEntry) | ||
1744 | // CheckSculptAndLoad(); | ||
1428 | } | 1745 | } |
1429 | 1746 | ||
1430 | if (ParentGroup != null) | 1747 | if (ParentGroup != null) |
@@ -1526,6 +1843,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1526 | } | 1843 | } |
1527 | } | 1844 | } |
1528 | 1845 | ||
1846 | |||
1529 | #endregion Public Properties with only Get | 1847 | #endregion Public Properties with only Get |
1530 | 1848 | ||
1531 | private uint ApplyMask(uint val, bool set, uint mask) | 1849 | private uint ApplyMask(uint val, bool set, uint mask) |
@@ -1614,6 +1932,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1614 | 1932 | ||
1615 | public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim) | 1933 | public void AddTextureAnimation(Primitive.TextureAnimation pTexAnim) |
1616 | { | 1934 | { |
1935 | <<<<<<< HEAD | ||
1617 | byte[] data; | 1936 | byte[] data; |
1618 | 1937 | ||
1619 | if (pTexAnim.Flags == Primitive.TextureAnimMode.ANIM_OFF) | 1938 | if (pTexAnim.Flags == Primitive.TextureAnimMode.ANIM_OFF) |
@@ -1625,6 +1944,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1625 | data = new byte[16]; | 1944 | data = new byte[16]; |
1626 | int pos = 0; | 1945 | int pos = 0; |
1627 | 1946 | ||
1947 | ======= | ||
1948 | if (((int)pTexAnim.Flags & 1) != 0) // ANIM_ON | ||
1949 | { | ||
1950 | byte[] data = new byte[16]; | ||
1951 | int pos = 0; | ||
1952 | |||
1953 | >>>>>>> avn/ubitvar | ||
1628 | // The flags don't like conversion from uint to byte, so we have to do | 1954 | // The flags don't like conversion from uint to byte, so we have to do |
1629 | // it the crappy way. See the above function :( | 1955 | // it the crappy way. See the above function :( |
1630 | 1956 | ||
@@ -1636,9 +1962,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1636 | Utils.FloatToBytes(pTexAnim.Start).CopyTo(data, pos); | 1962 | Utils.FloatToBytes(pTexAnim.Start).CopyTo(data, pos); |
1637 | Utils.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4); | 1963 | Utils.FloatToBytes(pTexAnim.Length).CopyTo(data, pos + 4); |
1638 | Utils.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8); | 1964 | Utils.FloatToBytes(pTexAnim.Rate).CopyTo(data, pos + 8); |
1965 | <<<<<<< HEAD | ||
1639 | } | 1966 | } |
1967 | ======= | ||
1968 | >>>>>>> avn/ubitvar | ||
1640 | 1969 | ||
1641 | m_TextureAnimation = data; | 1970 | m_TextureAnimation = data; |
1971 | } | ||
1972 | else | ||
1973 | { | ||
1974 | m_TextureAnimation = Utils.EmptyBytes; | ||
1975 | } | ||
1642 | } | 1976 | } |
1643 | 1977 | ||
1644 | public void AdjustSoundGain(double volume) | 1978 | public void AdjustSoundGain(double volume) |
@@ -1680,6 +2014,61 @@ namespace OpenSim.Region.Framework.Scenes | |||
1680 | } | 2014 | } |
1681 | } | 2015 | } |
1682 | 2016 | ||
2017 | // SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future | ||
2018 | public void SetVelocity(Vector3 pVel, bool localGlobalTF) | ||
2019 | { | ||
2020 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
2021 | return; | ||
2022 | |||
2023 | if (ParentGroup.IsAttachment) | ||
2024 | return; // don't work on attachments (for now ??) | ||
2025 | |||
2026 | SceneObjectPart root = ParentGroup.RootPart; | ||
2027 | |||
2028 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
2029 | return; | ||
2030 | |||
2031 | PhysicsActor pa = root.PhysActor; | ||
2032 | |||
2033 | if (pa == null || !pa.IsPhysical) | ||
2034 | return; | ||
2035 | |||
2036 | if (localGlobalTF) | ||
2037 | { | ||
2038 | pVel = pVel * GetWorldRotation(); | ||
2039 | } | ||
2040 | |||
2041 | ParentGroup.Velocity = pVel; | ||
2042 | } | ||
2043 | |||
2044 | // SetAngularVelocity for LSL llSetAngularVelocity.. may need revision if having other uses in future | ||
2045 | public void SetAngularVelocity(Vector3 pAngVel, bool localGlobalTF) | ||
2046 | { | ||
2047 | if (ParentGroup == null || ParentGroup.IsDeleted) | ||
2048 | return; | ||
2049 | |||
2050 | if (ParentGroup.IsAttachment) | ||
2051 | return; // don't work on attachments (for now ??) | ||
2052 | |||
2053 | SceneObjectPart root = ParentGroup.RootPart; | ||
2054 | |||
2055 | if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles | ||
2056 | return; | ||
2057 | |||
2058 | PhysicsActor pa = root.PhysActor; | ||
2059 | |||
2060 | if (pa == null || !pa.IsPhysical) | ||
2061 | return; | ||
2062 | |||
2063 | if (localGlobalTF) | ||
2064 | { | ||
2065 | pAngVel = pAngVel * GetWorldRotation(); | ||
2066 | } | ||
2067 | |||
2068 | root.AngularVelocity = pAngVel; | ||
2069 | } | ||
2070 | |||
2071 | |||
1683 | /// <summary> | 2072 | /// <summary> |
1684 | /// hook to the physics scene to apply angular impulse | 2073 | /// hook to the physics scene to apply angular impulse |
1685 | /// This is sent up to the group, which then finds the root prim | 2074 | /// This is sent up to the group, which then finds the root prim |
@@ -1700,7 +2089,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1700 | impulse = newimpulse; | 2089 | impulse = newimpulse; |
1701 | } | 2090 | } |
1702 | 2091 | ||
1703 | ParentGroup.applyAngularImpulse(impulse); | 2092 | ParentGroup.ApplyAngularImpulse(impulse); |
1704 | } | 2093 | } |
1705 | 2094 | ||
1706 | /// <summary> | 2095 | /// <summary> |
@@ -1710,20 +2099,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1710 | /// </summary> | 2099 | /// </summary> |
1711 | /// <param name="impulsei">Vector force</param> | 2100 | /// <param name="impulsei">Vector force</param> |
1712 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> | 2101 | /// <param name="localGlobalTF">true for the local frame, false for the global frame</param> |
1713 | public void SetAngularImpulse(Vector3 impulsei, bool localGlobalTF) | 2102 | |
2103 | // this is actualy Set Torque.. keeping naming so not to edit lslapi also | ||
2104 | public void SetAngularImpulse(Vector3 torquei, bool localGlobalTF) | ||
1714 | { | 2105 | { |
1715 | Vector3 impulse = impulsei; | 2106 | Vector3 torque = torquei; |
1716 | 2107 | ||
1717 | if (localGlobalTF) | 2108 | if (localGlobalTF) |
1718 | { | 2109 | { |
2110 | /* | ||
1719 | Quaternion grot = GetWorldRotation(); | 2111 | Quaternion grot = GetWorldRotation(); |
1720 | Quaternion AXgrot = grot; | 2112 | Quaternion AXgrot = grot; |
1721 | Vector3 AXimpulsei = impulsei; | 2113 | Vector3 AXimpulsei = impulsei; |
1722 | Vector3 newimpulse = AXimpulsei * AXgrot; | 2114 | Vector3 newimpulse = AXimpulsei * AXgrot; |
1723 | impulse = newimpulse; | 2115 | */ |
2116 | torque *= GetWorldRotation(); | ||
1724 | } | 2117 | } |
1725 | 2118 | ||
1726 | ParentGroup.setAngularImpulse(impulse); | 2119 | Torque = torque; |
1727 | } | 2120 | } |
1728 | 2121 | ||
1729 | /// <summary> | 2122 | /// <summary> |
@@ -1731,7 +2124,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1731 | /// </summary> | 2124 | /// </summary> |
1732 | /// <param name="rootObjectFlags"></param> | 2125 | /// <param name="rootObjectFlags"></param> |
1733 | /// <param name="VolumeDetectActive"></param> | 2126 | /// <param name="VolumeDetectActive"></param> |
1734 | public void ApplyPhysics(uint rootObjectFlags, bool _VolumeDetectActive) | 2127 | /// <param name="building"></param> |
2128 | |||
2129 | public void ApplyPhysics(uint _ObjectFlags, bool _VolumeDetectActive, bool building) | ||
1735 | { | 2130 | { |
1736 | VolumeDetectActive = _VolumeDetectActive; | 2131 | VolumeDetectActive = _VolumeDetectActive; |
1737 | 2132 | ||
@@ -1741,8 +2136,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1741 | if (PhysicsShapeType == (byte)PhysShapeType.none) | 2136 | if (PhysicsShapeType == (byte)PhysShapeType.none) |
1742 | return; | 2137 | return; |
1743 | 2138 | ||
1744 | bool isPhysical = (rootObjectFlags & (uint) PrimFlags.Physics) != 0; | 2139 | bool isPhysical = (_ObjectFlags & (uint) PrimFlags.Physics) != 0; |
1745 | bool isPhantom = (rootObjectFlags & (uint) PrimFlags.Phantom) != 0; | 2140 | bool isPhantom = (_ObjectFlags & (uint)PrimFlags.Phantom) != 0; |
1746 | 2141 | ||
1747 | if (_VolumeDetectActive) | 2142 | if (_VolumeDetectActive) |
1748 | isPhantom = true; | 2143 | isPhantom = true; |
@@ -1756,7 +2151,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1756 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment | 2151 | if ((!isPhantom || isPhysical || _VolumeDetectActive) && !ParentGroup.IsAttachment |
1757 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) | 2152 | && !(Shape.PathCurve == (byte)Extrusion.Flexible)) |
1758 | { | 2153 | { |
1759 | AddToPhysics(isPhysical, isPhantom, isPhysical); | 2154 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); |
2155 | UpdatePhysicsSubscribedEvents(); // not sure if appliable here | ||
1760 | } | 2156 | } |
1761 | else | 2157 | else |
1762 | PhysActor = null; // just to be sure | 2158 | PhysActor = null; // just to be sure |
@@ -1785,7 +2181,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1785 | /// <param name="linkNum"></param> | 2181 | /// <param name="linkNum"></param> |
1786 | /// <param name="userExposed">True if the duplicate will immediately be in the scene, false otherwise</param> | 2182 | /// <param name="userExposed">True if the duplicate will immediately be in the scene, false otherwise</param> |
1787 | /// <returns></returns> | 2183 | /// <returns></returns> |
1788 | public SceneObjectPart Copy(uint localID, UUID AgentID, UUID GroupID, int linkNum, bool userExposed) | 2184 | public SceneObjectPart Copy(uint plocalID, UUID AgentID, UUID GroupID, int linkNum, bool userExposed) |
1789 | { | 2185 | { |
1790 | // FIXME: This is dangerous since it's easy to forget to reset some references when necessary and end up | 2186 | // FIXME: This is dangerous since it's easy to forget to reset some references when necessary and end up |
1791 | // with bugs that only occur in some circumstances (e.g. crossing between regions on the same simulator | 2187 | // with bugs that only occur in some circumstances (e.g. crossing between regions on the same simulator |
@@ -1815,6 +2211,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1815 | dupe.Category = Category; | 2211 | dupe.Category = Category; |
1816 | dupe.m_rezzed = m_rezzed; | 2212 | dupe.m_rezzed = m_rezzed; |
1817 | 2213 | ||
2214 | dupe.m_UndoRedo = null; | ||
2215 | dupe.m_isSelected = false; | ||
2216 | |||
2217 | dupe.IgnoreUndoUpdate = false; | ||
2218 | dupe.Undoing = false; | ||
2219 | |||
1818 | dupe.m_inventory = new SceneObjectPartInventory(dupe); | 2220 | dupe.m_inventory = new SceneObjectPartInventory(dupe); |
1819 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); | 2221 | dupe.m_inventory.Items = (TaskInventoryDictionary)m_inventory.Items.Clone(); |
1820 | 2222 | ||
@@ -1829,7 +2231,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1829 | } | 2231 | } |
1830 | 2232 | ||
1831 | // Move afterwards ResetIDs as it clears the localID | 2233 | // Move afterwards ResetIDs as it clears the localID |
1832 | dupe.LocalId = localID; | 2234 | dupe.LocalId = plocalID; |
2235 | |||
1833 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. | 2236 | // This may be wrong... it might have to be applied in SceneObjectGroup to the object that's being duplicated. |
1834 | dupe.LastOwnerID = OwnerID; | 2237 | dupe.LastOwnerID = OwnerID; |
1835 | 2238 | ||
@@ -1856,8 +2259,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1856 | */ | 2259 | */ |
1857 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); | 2260 | bool UsePhysics = ((dupe.Flags & PrimFlags.Physics) != 0); |
1858 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); | 2261 | dupe.DoPhysicsPropertyUpdate(UsePhysics, true); |
2262 | // dupe.UpdatePhysicsSubscribedEvents(); // not sure... | ||
1859 | } | 2263 | } |
1860 | 2264 | ||
2265 | if (dupe.PhysActor != null) | ||
2266 | dupe.PhysActor.LocalID = plocalID; | ||
2267 | |||
1861 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); | 2268 | ParentGroup.Scene.EventManager.TriggerOnSceneObjectPartCopy(dupe, this, userExposed); |
1862 | 2269 | ||
1863 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); | 2270 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clone of {0} {1} finished", Name, UUID); |
@@ -1876,10 +2283,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1876 | { | 2283 | { |
1877 | if (asset != null) | 2284 | if (asset != null) |
1878 | SculptTextureCallback(asset); | 2285 | SculptTextureCallback(asset); |
1879 | else | 2286 | // else |
1880 | m_log.WarnFormat( | 2287 | // m_log.WarnFormat( |
1881 | "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", | 2288 | // "[SCENE OBJECT PART]: Part {0} {1} requested mesh/sculpt data for asset id {2} from asset service but received no data", |
1882 | Name, UUID, id); | 2289 | // Name, UUID, id); |
1883 | } | 2290 | } |
1884 | */ | 2291 | */ |
1885 | /// <summary> | 2292 | /// <summary> |
@@ -1978,6 +2385,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1978 | 2385 | ||
1979 | /// <summary> | 2386 | /// <summary> |
1980 | /// Do a physics propery update for this part. | 2387 | /// Do a physics propery update for this part. |
2388 | /// now also updates phantom and volume detector | ||
1981 | /// </summary> | 2389 | /// </summary> |
1982 | /// <param name="UsePhysics"></param> | 2390 | /// <param name="UsePhysics"></param> |
1983 | /// <param name="isNew"></param> | 2391 | /// <param name="isNew"></param> |
@@ -2003,64 +2411,69 @@ namespace OpenSim.Region.Framework.Scenes | |||
2003 | { | 2411 | { |
2004 | if (pa.IsPhysical) // implies UsePhysics==false for this block | 2412 | if (pa.IsPhysical) // implies UsePhysics==false for this block |
2005 | { | 2413 | { |
2006 | if (!isNew) | 2414 | if (!isNew) // implies UsePhysics==false for this block |
2415 | { | ||
2007 | ParentGroup.Scene.RemovePhysicalPrim(1); | 2416 | ParentGroup.Scene.RemovePhysicalPrim(1); |
2008 | 2417 | ||
2009 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | 2418 | Velocity = new Vector3(0, 0, 0); |
2010 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | 2419 | Acceleration = new Vector3(0, 0, 0); |
2011 | pa.delink(); | 2420 | if (ParentGroup.RootPart == this) |
2421 | AngularVelocity = new Vector3(0, 0, 0); | ||
2012 | 2422 | ||
2013 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints && (!isNew)) | 2423 | if (pa.Phantom && !VolumeDetectActive) |
2014 | { | 2424 | { |
2015 | // destroy all joints connected to this now deactivated body | 2425 | RemoveFromPhysics(); |
2016 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | 2426 | return; |
2017 | } | 2427 | } |
2018 | 2428 | ||
2019 | // stop client-side interpolation of all joint proxy objects that have just been deleted | 2429 | pa.IsPhysical = UsePhysics; |
2020 | // this is done because RemoveAllJointsConnectedToActor invokes the OnJointDeactivated callback, | 2430 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; |
2021 | // which stops client-side interpolation of deactivated joint proxy objects. | 2431 | pa.OnOutOfBounds -= PhysicsOutOfBounds; |
2432 | pa.delink(); | ||
2433 | if (ParentGroup.Scene.PhysicsScene.SupportsNINJAJoints) | ||
2434 | { | ||
2435 | // destroy all joints connected to this now deactivated body | ||
2436 | ParentGroup.Scene.PhysicsScene.RemoveAllJointsConnectedToActorThreadLocked(pa); | ||
2437 | } | ||
2438 | } | ||
2022 | } | 2439 | } |
2023 | 2440 | ||
2024 | if (!UsePhysics && !isNew) | 2441 | if (pa.IsPhysical != UsePhysics) |
2025 | { | 2442 | pa.IsPhysical = UsePhysics; |
2026 | // reset velocity to 0 on physics switch-off. Without that, the client thinks the | ||
2027 | // prim still has velocity and continues to interpolate its position along the old | ||
2028 | // velocity-vector. | ||
2029 | Velocity = new Vector3(0, 0, 0); | ||
2030 | Acceleration = new Vector3(0, 0, 0); | ||
2031 | AngularVelocity = new Vector3(0, 0, 0); | ||
2032 | //RotationalVelocity = new Vector3(0, 0, 0); | ||
2033 | } | ||
2034 | 2443 | ||
2035 | pa.IsPhysical = UsePhysics; | 2444 | if (UsePhysics) |
2445 | { | ||
2446 | if (ParentGroup.RootPart.KeyframeMotion != null) | ||
2447 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2448 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2449 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
2036 | 2450 | ||
2037 | // If we're not what we're supposed to be in the physics scene, recreate ourselves. | 2451 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
2038 | //m_parentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 2452 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; |
2039 | /// that's not wholesome. Had to make Scene public | ||
2040 | //PhysActor = null; | ||
2041 | 2453 | ||
2042 | if ((Flags & PrimFlags.Phantom) == 0) | 2454 | if (ParentID != 0 && ParentID != LocalId) |
2043 | { | ||
2044 | if (UsePhysics) | ||
2045 | { | 2455 | { |
2046 | if (ParentGroup.RootPart.KeyframeMotion != null) | 2456 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; |
2047 | ParentGroup.RootPart.KeyframeMotion.Stop(); | ||
2048 | ParentGroup.RootPart.KeyframeMotion = null; | ||
2049 | ParentGroup.Scene.AddPhysicalPrim(1); | ||
2050 | |||
2051 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | ||
2052 | pa.OnOutOfBounds += PhysicsOutOfBounds; | ||
2053 | if (ParentID != 0 && ParentID != LocalId) | ||
2054 | { | ||
2055 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | ||
2056 | 2457 | ||
2057 | if (parentPa != null) | 2458 | if (parentPa != null) |
2058 | { | 2459 | { |
2059 | pa.link(parentPa); | 2460 | pa.link(parentPa); |
2060 | } | ||
2061 | } | 2461 | } |
2062 | } | 2462 | } |
2063 | } | 2463 | } |
2464 | } | ||
2465 | |||
2466 | bool phan = ((Flags & PrimFlags.Phantom) != 0); | ||
2467 | if (pa.Phantom != phan) | ||
2468 | pa.Phantom = phan; | ||
2469 | |||
2470 | // some engines dont' have this check still | ||
2471 | // if (VolumeDetectActive != pa.IsVolumeDtc) | ||
2472 | { | ||
2473 | if (VolumeDetectActive) | ||
2474 | pa.SetVolumeDetect(1); | ||
2475 | else | ||
2476 | pa.SetVolumeDetect(0); | ||
2064 | } | 2477 | } |
2065 | 2478 | ||
2066 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the | 2479 | // If this part is a sculpt then delay the physics update until we've asynchronously loaded the |
@@ -2163,42 +2576,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
2163 | 2576 | ||
2164 | public Vector3 GetGeometricCenter() | 2577 | public Vector3 GetGeometricCenter() |
2165 | { | 2578 | { |
2579 | // this is not real geometric center but a average of positions relative to root prim acording to | ||
2580 | // http://wiki.secondlife.com/wiki/llGetGeometricCenter | ||
2581 | // ignoring tortured prims details since sl also seems to ignore | ||
2582 | // so no real use in doing it on physics | ||
2583 | if (ParentGroup.IsDeleted) | ||
2584 | return new Vector3(0, 0, 0); | ||
2585 | |||
2586 | return ParentGroup.GetGeometricCenter(); | ||
2587 | } | ||
2588 | |||
2589 | public float GetMass() | ||
2590 | { | ||
2166 | PhysicsActor pa = PhysActor; | 2591 | PhysicsActor pa = PhysActor; |
2167 | 2592 | ||
2168 | if (pa != null) | 2593 | if (pa != null) |
2169 | return pa.GeometricCenter; | 2594 | return pa.Mass; |
2170 | else | 2595 | else |
2171 | return Vector3.Zero; | 2596 | return 0; |
2172 | } | 2597 | } |
2173 | 2598 | ||
2174 | public Vector3 GetCenterOfMass() | 2599 | public Vector3 GetCenterOfMass() |
2175 | { | 2600 | { |
2601 | if (ParentGroup.RootPart == this) | ||
2602 | { | ||
2603 | if (ParentGroup.IsDeleted) | ||
2604 | return AbsolutePosition; | ||
2605 | return ParentGroup.GetCenterOfMass(); | ||
2606 | } | ||
2607 | |||
2176 | PhysicsActor pa = PhysActor; | 2608 | PhysicsActor pa = PhysActor; |
2177 | 2609 | ||
2178 | if (pa != null) | 2610 | if (pa != null) |
2179 | return pa.CenterOfMass; | 2611 | { |
2612 | Vector3 tmp = pa.CenterOfMass; | ||
2613 | return tmp; | ||
2614 | } | ||
2180 | else | 2615 | else |
2181 | return Vector3.Zero; | 2616 | return AbsolutePosition; |
2182 | } | 2617 | } |
2183 | 2618 | ||
2184 | public float GetMass() | 2619 | public Vector3 GetPartCenterOfMass() |
2185 | { | 2620 | { |
2186 | PhysicsActor pa = PhysActor; | 2621 | PhysicsActor pa = PhysActor; |
2187 | 2622 | ||
2188 | if (pa != null) | 2623 | if (pa != null) |
2189 | return pa.Mass; | 2624 | { |
2625 | Vector3 tmp = pa.CenterOfMass; | ||
2626 | return tmp; | ||
2627 | } | ||
2190 | else | 2628 | else |
2191 | return 0; | 2629 | return AbsolutePosition; |
2192 | } | 2630 | } |
2193 | 2631 | ||
2632 | |||
2194 | public Vector3 GetForce() | 2633 | public Vector3 GetForce() |
2195 | { | 2634 | { |
2196 | PhysicsActor pa = PhysActor; | 2635 | return Force; |
2197 | |||
2198 | if (pa != null) | ||
2199 | return pa.Force; | ||
2200 | else | ||
2201 | return Vector3.Zero; | ||
2202 | } | 2636 | } |
2203 | 2637 | ||
2204 | /// <summary> | 2638 | /// <summary> |
@@ -2313,6 +2747,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2313 | detobj.velVector = obj.Velocity; | 2747 | detobj.velVector = obj.Velocity; |
2314 | detobj.colliderType = 0; | 2748 | detobj.colliderType = 0; |
2315 | detobj.groupUUID = obj.GroupID; | 2749 | detobj.groupUUID = obj.GroupID; |
2750 | detobj.linkNumber = LinkNum; // pass my link number | ||
2316 | 2751 | ||
2317 | return detobj; | 2752 | return detobj; |
2318 | } | 2753 | } |
@@ -2328,6 +2763,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2328 | detobj.velVector = av.Velocity; | 2763 | detobj.velVector = av.Velocity; |
2329 | detobj.colliderType = 0; | 2764 | detobj.colliderType = 0; |
2330 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | 2765 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; |
2766 | detobj.linkNumber = LinkNum; // pass my link number | ||
2331 | 2767 | ||
2332 | return detobj; | 2768 | return detobj; |
2333 | } | 2769 | } |
@@ -2343,6 +2779,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2343 | detobj.velVector = Vector3.Zero; | 2779 | detobj.velVector = Vector3.Zero; |
2344 | detobj.colliderType = 0; | 2780 | detobj.colliderType = 0; |
2345 | detobj.groupUUID = UUID.Zero; | 2781 | detobj.groupUUID = UUID.Zero; |
2782 | detobj.linkNumber = LinkNum; // pass my link number not sure needed.. but no harm | ||
2346 | 2783 | ||
2347 | return detobj; | 2784 | return detobj; |
2348 | } | 2785 | } |
@@ -2413,14 +2850,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2413 | 2850 | ||
2414 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) | 2851 | private void SendLandCollisionEvent(scriptEvents ev, ScriptCollidingNotification notify) |
2415 | { | 2852 | { |
2416 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0) | 2853 | bool sendToRoot = true; |
2417 | { | ||
2418 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
2419 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2420 | |||
2421 | colliding.Add(CreateDetObjectForGround()); | ||
2422 | LandCollidingMessage.Colliders = colliding; | ||
2423 | 2854 | ||
2855 | ColliderArgs LandCollidingMessage = new ColliderArgs(); | ||
2856 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
2857 | |||
2858 | colliding.Add(CreateDetObjectForGround()); | ||
2859 | LandCollidingMessage.Colliders = colliding; | ||
2860 | |||
2861 | <<<<<<< HEAD | ||
2424 | DoNotify(notify, LocalId, LandCollidingMessage); | 2862 | DoNotify(notify, LocalId, LandCollidingMessage); |
2425 | } | 2863 | } |
2426 | } | 2864 | } |
@@ -2448,6 +2886,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2448 | else | 2886 | else |
2449 | { | 2887 | { |
2450 | notify(id, collargs); | 2888 | notify(id, collargs); |
2889 | ======= | ||
2890 | if (Inventory.ContainsScripts()) | ||
2891 | { | ||
2892 | if (!PassCollisions) | ||
2893 | sendToRoot = false; | ||
2894 | } | ||
2895 | if ((ScriptEvents & ev) != 0) | ||
2896 | notify(LocalId, LandCollidingMessage); | ||
2897 | |||
2898 | if ((ParentGroup.RootPart.ScriptEvents & ev) != 0 && sendToRoot) | ||
2899 | { | ||
2900 | notify(ParentGroup.RootPart.LocalId, LandCollidingMessage); | ||
2901 | >>>>>>> avn/ubitvar | ||
2451 | } | 2902 | } |
2452 | } | 2903 | } |
2453 | 2904 | ||
@@ -2463,44 +2914,81 @@ namespace OpenSim.Region.Framework.Scenes | |||
2463 | List<uint> endedColliders = new List<uint>(); | 2914 | List<uint> endedColliders = new List<uint>(); |
2464 | List<uint> startedColliders = new List<uint>(); | 2915 | List<uint> startedColliders = new List<uint>(); |
2465 | 2916 | ||
2466 | // calculate things that started colliding this time | 2917 | if (collissionswith.Count == 0) |
2467 | // and build up list of colliders this time | ||
2468 | foreach (uint localid in collissionswith.Keys) | ||
2469 | { | 2918 | { |
2470 | thisHitColliders.Add(localid); | 2919 | if (m_lastColliders.Count == 0) |
2471 | if (!m_lastColliders.Contains(localid)) | 2920 | return; // nothing to do |
2472 | startedColliders.Add(localid); | ||
2473 | } | ||
2474 | 2921 | ||
2475 | // calculate things that ended colliding | 2922 | foreach (uint localID in m_lastColliders) |
2476 | foreach (uint localID in m_lastColliders) | 2923 | { |
2477 | { | ||
2478 | if (!thisHitColliders.Contains(localID)) | ||
2479 | endedColliders.Add(localID); | 2924 | endedColliders.Add(localID); |
2925 | } | ||
2926 | m_lastColliders.Clear(); | ||
2480 | } | 2927 | } |
2481 | 2928 | ||
2482 | //add the items that started colliding this time to the last colliders list. | 2929 | else |
2483 | foreach (uint localID in startedColliders) | 2930 | { |
2484 | m_lastColliders.Add(localID); | 2931 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); |
2485 | 2932 | ||
2486 | // remove things that ended colliding from the last colliders list | 2933 | // calculate things that started colliding this time |
2487 | foreach (uint localID in endedColliders) | 2934 | // and build up list of colliders this time |
2488 | m_lastColliders.Remove(localID); | 2935 | if (!VolumeDetectActive && CollisionSoundType >= 0) |
2936 | { | ||
2937 | CollisionForSoundInfo soundinfo; | ||
2938 | ContactPoint curcontact; | ||
2489 | 2939 | ||
2490 | // play the sound. | 2940 | foreach (uint id in collissionswith.Keys) |
2491 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) | 2941 | { |
2492 | { | 2942 | thisHitColliders.Add(id); |
2493 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | 2943 | if (!m_lastColliders.Contains(id)) |
2494 | if (soundModule != null) | 2944 | { |
2945 | startedColliders.Add(id); | ||
2946 | |||
2947 | curcontact = collissionswith[id]; | ||
2948 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
2949 | { | ||
2950 | soundinfo = new CollisionForSoundInfo(); | ||
2951 | soundinfo.colliderID = id; | ||
2952 | soundinfo.position = curcontact.Position; | ||
2953 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2954 | soundinfolist.Add(soundinfo); | ||
2955 | } | ||
2956 | } | ||
2957 | } | ||
2958 | } | ||
2959 | else | ||
2960 | { | ||
2961 | foreach (uint id in collissionswith.Keys) | ||
2962 | { | ||
2963 | thisHitColliders.Add(id); | ||
2964 | if (!m_lastColliders.Contains(id)) | ||
2965 | startedColliders.Add(id); | ||
2966 | } | ||
2967 | } | ||
2968 | |||
2969 | // calculate things that ended colliding | ||
2970 | foreach (uint localID in m_lastColliders) | ||
2495 | { | 2971 | { |
2496 | soundModule.SendSound(UUID, CollisionSound, | 2972 | if (!thisHitColliders.Contains(localID)) |
2497 | CollisionSoundVolume, true, 0, 0, false, | 2973 | endedColliders.Add(localID); |
2498 | false); | ||
2499 | } | 2974 | } |
2975 | |||
2976 | //add the items that started colliding this time to the last colliders list. | ||
2977 | foreach (uint localID in startedColliders) | ||
2978 | m_lastColliders.Add(localID); | ||
2979 | |||
2980 | // remove things that ended colliding from the last colliders list | ||
2981 | foreach (uint localID in endedColliders) | ||
2982 | m_lastColliders.Remove(localID); | ||
2983 | |||
2984 | // play sounds. | ||
2985 | if (soundinfolist.Count > 0) | ||
2986 | CollisionSounds.PartCollisionSound(this, soundinfolist); | ||
2500 | } | 2987 | } |
2501 | 2988 | ||
2502 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2989 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2503 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2990 | if (!VolumeDetectActive) |
2991 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | ||
2504 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 2992 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); |
2505 | 2993 | ||
2506 | if (startedColliders.Contains(0)) | 2994 | if (startedColliders.Contains(0)) |
@@ -2511,6 +2999,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
2511 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); | 2999 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); |
2512 | } | 3000 | } |
2513 | 3001 | ||
3002 | // The Collision sounds code calls this | ||
3003 | public void SendCollisionSound(UUID soundID, double volume, Vector3 position) | ||
3004 | { | ||
3005 | if (soundID == UUID.Zero) | ||
3006 | return; | ||
3007 | |||
3008 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | ||
3009 | if (soundModule == null) | ||
3010 | return; | ||
3011 | |||
3012 | if (volume > 1) | ||
3013 | volume = 1; | ||
3014 | if (volume < 0) | ||
3015 | volume = 0; | ||
3016 | |||
3017 | int now = Util.EnvironmentTickCount(); | ||
3018 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) | ||
3019 | return; | ||
3020 | |||
3021 | LastColSoundSentTime = now; | ||
3022 | |||
3023 | UUID ownerID = OwnerID; | ||
3024 | UUID objectID = ParentGroup.RootPart.UUID; | ||
3025 | UUID parentID = ParentGroup.UUID; | ||
3026 | ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; | ||
3027 | |||
3028 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, 0 ); | ||
3029 | } | ||
3030 | |||
2514 | public void PhysicsOutOfBounds(Vector3 pos) | 3031 | public void PhysicsOutOfBounds(Vector3 pos) |
2515 | { | 3032 | { |
2516 | // Note: This is only being called on the root prim at this time. | 3033 | // Note: This is only being called on the root prim at this time. |
@@ -2529,7 +3046,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2529 | 3046 | ||
2530 | if (pa != null) | 3047 | if (pa != null) |
2531 | { | 3048 | { |
3049 | <<<<<<< HEAD | ||
2532 | Vector3 newpos = pa.Position; | 3050 | Vector3 newpos = pa.Position; |
3051 | ======= | ||
3052 | Vector3 newpos = new Vector3(pa.Position.GetBytes(), 0); | ||
3053 | |||
3054 | >>>>>>> avn/ubitvar | ||
2533 | if (!ParentGroup.Scene.PositionIsInCurrentRegion(newpos)) | 3055 | if (!ParentGroup.Scene.PositionIsInCurrentRegion(newpos)) |
2534 | { | 3056 | { |
2535 | // Setting position outside current region will start region crossing | 3057 | // Setting position outside current region will start region crossing |
@@ -2538,7 +3060,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2538 | } | 3060 | } |
2539 | //ParentGroup.RootPart.m_groupPosition = newpos; | 3061 | //ParentGroup.RootPart.m_groupPosition = newpos; |
2540 | } | 3062 | } |
2541 | 3063 | /* ubit: there are no flexible links | |
2542 | if (pa != null && ParentID != 0 && ParentGroup != null) | 3064 | if (pa != null && ParentID != 0 && ParentGroup != null) |
2543 | { | 3065 | { |
2544 | // Special case where a child object is requesting property updates. | 3066 | // Special case where a child object is requesting property updates. |
@@ -2558,7 +3080,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2558 | // m_log.DebugFormat("{0} PhysicsRequestingTerseUpdate child: pos={1}, rot={2}, offPos={3}, offRot={4}", | 3080 | // m_log.DebugFormat("{0} PhysicsRequestingTerseUpdate child: pos={1}, rot={2}, offPos={3}, offRot={4}", |
2559 | // "[SCENE OBJECT PART]", pa.Position, pa.Orientation, m_offsetPosition, RotationOffset); | 3081 | // "[SCENE OBJECT PART]", pa.Position, pa.Orientation, m_offsetPosition, RotationOffset); |
2560 | } | 3082 | } |
2561 | 3083 | */ | |
2562 | ScheduleTerseUpdate(); | 3084 | ScheduleTerseUpdate(); |
2563 | } | 3085 | } |
2564 | 3086 | ||
@@ -2811,7 +3333,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2811 | 3333 | ||
2812 | // m_log.DebugFormat( | 3334 | // m_log.DebugFormat( |
2813 | // "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); | 3335 | // "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); |
2814 | 3336 | ||
3337 | |||
3338 | if (ParentGroup.IsAttachment) | ||
3339 | { | ||
3340 | ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); | ||
3341 | if (sp != null) | ||
3342 | { | ||
3343 | sp.SendAttachmentUpdate(this, UpdateRequired.FULL); | ||
3344 | } | ||
3345 | } | ||
3346 | |||
3347 | /* this does nothing | ||
3348 | SendFullUpdateToClient(remoteClient, Position) ignores position parameter | ||
2815 | if (IsRoot) | 3349 | if (IsRoot) |
2816 | { | 3350 | { |
2817 | if (ParentGroup.IsAttachment) | 3351 | if (ParentGroup.IsAttachment) |
@@ -2823,6 +3357,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2823 | SendFullUpdateToClient(remoteClient, AbsolutePosition); | 3357 | SendFullUpdateToClient(remoteClient, AbsolutePosition); |
2824 | } | 3358 | } |
2825 | } | 3359 | } |
3360 | */ | ||
2826 | else | 3361 | else |
2827 | { | 3362 | { |
2828 | SendFullUpdateToClient(remoteClient); | 3363 | SendFullUpdateToClient(remoteClient); |
@@ -2832,17 +3367,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
2832 | /// <summary> | 3367 | /// <summary> |
2833 | /// Send a full update for this part to all clients. | 3368 | /// Send a full update for this part to all clients. |
2834 | /// </summary> | 3369 | /// </summary> |
2835 | public void SendFullUpdateToAllClients() | 3370 | public void SendFullUpdateToAllClientsInternal() |
2836 | { | 3371 | { |
2837 | if (ParentGroup == null) | 3372 | if (ParentGroup == null) |
2838 | return; | 3373 | return; |
2839 | 3374 | ||
3375 | // Update the "last" values | ||
3376 | m_lastPosition = OffsetPosition; | ||
3377 | m_lastRotation = RotationOffset; | ||
3378 | m_lastVelocity = Velocity; | ||
3379 | m_lastAcceleration = Acceleration; | ||
3380 | m_lastAngularVelocity = AngularVelocity; | ||
3381 | m_lastUpdateSentTime = Environment.TickCount; | ||
3382 | |||
2840 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 3383 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) |
2841 | { | 3384 | { |
2842 | SendFullUpdate(avatar.ControllingClient); | 3385 | SendFullUpdate(avatar.ControllingClient); |
2843 | }); | 3386 | }); |
2844 | } | 3387 | } |
2845 | 3388 | ||
3389 | public void SendFullUpdateToAllClients() | ||
3390 | { | ||
3391 | if (ParentGroup == null) | ||
3392 | return; | ||
3393 | |||
3394 | // Update the "last" values | ||
3395 | m_lastPosition = OffsetPosition; | ||
3396 | m_lastRotation = RotationOffset; | ||
3397 | m_lastVelocity = Velocity; | ||
3398 | m_lastAcceleration = Acceleration; | ||
3399 | m_lastAngularVelocity = AngularVelocity; | ||
3400 | m_lastUpdateSentTime = Environment.TickCount; | ||
3401 | |||
3402 | if (ParentGroup.IsAttachment) | ||
3403 | { | ||
3404 | ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); | ||
3405 | if (sp != null) | ||
3406 | { | ||
3407 | sp.SendAttachmentUpdate(this, UpdateRequired.FULL); | ||
3408 | } | ||
3409 | } | ||
3410 | else | ||
3411 | { | ||
3412 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | ||
3413 | { | ||
3414 | SendFullUpdate(avatar.ControllingClient); | ||
3415 | }); | ||
3416 | } | ||
3417 | } | ||
3418 | |||
2846 | /// <summary> | 3419 | /// <summary> |
2847 | /// Sends a full update to the client | 3420 | /// Sends a full update to the client |
2848 | /// </summary> | 3421 | /// </summary> |
@@ -2863,9 +3436,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2863 | return; | 3436 | return; |
2864 | 3437 | ||
2865 | // Suppress full updates during attachment editing | 3438 | // Suppress full updates during attachment editing |
2866 | // | 3439 | // sl Does send them |
2867 | if (ParentGroup.IsSelected && ParentGroup.IsAttachment) | 3440 | // if (ParentGroup.IsSelected && ParentGroup.IsAttachment) |
2868 | return; | 3441 | // return; |
2869 | 3442 | ||
2870 | if (ParentGroup.IsDeleted) | 3443 | if (ParentGroup.IsDeleted) |
2871 | return; | 3444 | return; |
@@ -2895,8 +3468,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2895 | { | 3468 | { |
2896 | const float ROTATION_TOLERANCE = 0.01f; | 3469 | const float ROTATION_TOLERANCE = 0.01f; |
2897 | const float VELOCITY_TOLERANCE = 0.001f; | 3470 | const float VELOCITY_TOLERANCE = 0.001f; |
2898 | const float POSITION_TOLERANCE = 0.05f; | 3471 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary |
2899 | const int TIME_MS_TOLERANCE = 3000; | 3472 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. |
2900 | 3473 | ||
2901 | switch (UpdateFlag) | 3474 | switch (UpdateFlag) |
2902 | { | 3475 | { |
@@ -2910,40 +3483,74 @@ namespace OpenSim.Region.Framework.Scenes | |||
2910 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || | 3483 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || |
2911 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || | 3484 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || |
2912 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 3485 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
2913 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | 3486 | Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) |
2914 | { | 3487 | { |
2915 | SendTerseUpdateToAllClients(); | 3488 | SendTerseUpdateToAllClientsInternal(); |
2916 | |||
2917 | // Update the "last" values | ||
2918 | m_lastPosition = OffsetPosition; | ||
2919 | m_lastRotation = RotationOffset; | ||
2920 | m_lastVelocity = Velocity; | ||
2921 | m_lastAcceleration = Acceleration; | ||
2922 | m_lastAngularVelocity = AngularVelocity; | ||
2923 | m_lastTerseSent = Environment.TickCount; | ||
2924 | } | 3489 | } |
2925 | break; | 3490 | break; |
2926 | } | 3491 | } |
2927 | case UpdateRequired.FULL: | 3492 | case UpdateRequired.FULL: |
2928 | { | 3493 | { |
2929 | ClearUpdateSchedule(); | 3494 | ClearUpdateSchedule(); |
2930 | SendFullUpdateToAllClients(); | 3495 | SendFullUpdateToAllClientsInternal(); |
2931 | break; | 3496 | break; |
2932 | } | 3497 | } |
2933 | } | 3498 | } |
2934 | } | 3499 | } |
2935 | 3500 | ||
3501 | |||
2936 | /// <summary> | 3502 | /// <summary> |
2937 | /// Send a terse update to all clients | 3503 | /// Send a terse update to all clients |
2938 | /// </summary> | 3504 | /// </summary> |
2939 | public void SendTerseUpdateToAllClients() | 3505 | public void SendTerseUpdateToAllClientsInternal() |
2940 | { | 3506 | { |
3507 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3508 | return; | ||
3509 | |||
3510 | // Update the "last" values | ||
3511 | m_lastPosition = OffsetPosition; | ||
3512 | m_lastRotation = RotationOffset; | ||
3513 | m_lastVelocity = Velocity; | ||
3514 | m_lastAcceleration = Acceleration; | ||
3515 | m_lastAngularVelocity = AngularVelocity; | ||
3516 | m_lastUpdateSentTime = Environment.TickCount; | ||
3517 | |||
2941 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | 3518 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) |
2942 | { | 3519 | { |
2943 | SendTerseUpdateToClient(client); | 3520 | SendTerseUpdateToClient(client); |
2944 | }); | 3521 | }); |
2945 | } | 3522 | } |
2946 | 3523 | ||
3524 | public void SendTerseUpdateToAllClients() | ||
3525 | { | ||
3526 | if (ParentGroup == null || ParentGroup.Scene == null) | ||
3527 | return; | ||
3528 | |||
3529 | // Update the "last" values | ||
3530 | m_lastPosition = OffsetPosition; | ||
3531 | m_lastRotation = RotationOffset; | ||
3532 | m_lastVelocity = Velocity; | ||
3533 | m_lastAcceleration = Acceleration; | ||
3534 | m_lastAngularVelocity = AngularVelocity; | ||
3535 | m_lastUpdateSentTime = Environment.TickCount; | ||
3536 | |||
3537 | if (ParentGroup.IsAttachment) | ||
3538 | { | ||
3539 | ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); | ||
3540 | if (sp != null) | ||
3541 | { | ||
3542 | sp.SendAttachmentUpdate(this, UpdateRequired.TERSE); | ||
3543 | } | ||
3544 | } | ||
3545 | else | ||
3546 | { | ||
3547 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | ||
3548 | { | ||
3549 | SendTerseUpdateToClient(client); | ||
3550 | }); | ||
3551 | } | ||
3552 | } | ||
3553 | |||
2947 | public void SetAxisRotation(int axis, int rotate) | 3554 | public void SetAxisRotation(int axis, int rotate) |
2948 | { | 3555 | { |
2949 | ParentGroup.SetAxisRotation(axis, rotate); | 3556 | ParentGroup.SetAxisRotation(axis, rotate); |
@@ -2961,10 +3568,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2961 | 3568 | ||
2962 | public void SetBuoyancy(float fvalue) | 3569 | public void SetBuoyancy(float fvalue) |
2963 | { | 3570 | { |
2964 | PhysicsActor pa = PhysActor; | 3571 | Buoyancy = fvalue; |
2965 | 3572 | /* | |
2966 | if (pa != null) | 3573 | if (PhysActor != null) |
2967 | pa.Buoyancy = fvalue; | 3574 | { |
3575 | PhysActor.Buoyancy = fvalue; | ||
3576 | } | ||
3577 | */ | ||
2968 | } | 3578 | } |
2969 | 3579 | ||
2970 | public void SetDieAtEdge(bool p) | 3580 | public void SetDieAtEdge(bool p) |
@@ -2980,47 +3590,111 @@ namespace OpenSim.Region.Framework.Scenes | |||
2980 | PhysicsActor pa = PhysActor; | 3590 | PhysicsActor pa = PhysActor; |
2981 | 3591 | ||
2982 | if (pa != null) | 3592 | if (pa != null) |
2983 | pa.FloatOnWater = floatYN == 1; | 3593 | pa.FloatOnWater = (floatYN == 1); |
2984 | } | 3594 | } |
2985 | 3595 | ||
2986 | public void SetForce(Vector3 force) | 3596 | public void SetForce(Vector3 force) |
2987 | { | 3597 | { |
2988 | PhysicsActor pa = PhysActor; | 3598 | Force = force; |
3599 | } | ||
2989 | 3600 | ||
2990 | if (pa != null) | 3601 | public SOPVehicle VehicleParams |
2991 | pa.Force = force; | 3602 | { |
3603 | get | ||
3604 | { | ||
3605 | return m_vehicleParams; | ||
3606 | } | ||
3607 | set | ||
3608 | { | ||
3609 | m_vehicleParams = value; | ||
3610 | } | ||
3611 | } | ||
3612 | |||
3613 | |||
3614 | public int VehicleType | ||
3615 | { | ||
3616 | get | ||
3617 | { | ||
3618 | if (m_vehicleParams == null) | ||
3619 | return (int)Vehicle.TYPE_NONE; | ||
3620 | else | ||
3621 | return (int)m_vehicleParams.Type; | ||
3622 | } | ||
3623 | set | ||
3624 | { | ||
3625 | SetVehicleType(value); | ||
3626 | } | ||
2992 | } | 3627 | } |
2993 | 3628 | ||
2994 | public void SetVehicleType(int type) | 3629 | public void SetVehicleType(int type) |
2995 | { | 3630 | { |
2996 | PhysicsActor pa = PhysActor; | 3631 | m_vehicleParams = null; |
3632 | |||
3633 | if (type == (int)Vehicle.TYPE_NONE) | ||
3634 | { | ||
3635 | if (_parentID ==0 && PhysActor != null) | ||
3636 | PhysActor.VehicleType = (int)Vehicle.TYPE_NONE; | ||
3637 | return; | ||
3638 | } | ||
3639 | m_vehicleParams = new SOPVehicle(); | ||
3640 | m_vehicleParams.ProcessTypeChange((Vehicle)type); | ||
3641 | { | ||
3642 | if (_parentID ==0 && PhysActor != null) | ||
3643 | PhysActor.VehicleType = type; | ||
3644 | return; | ||
3645 | } | ||
3646 | } | ||
2997 | 3647 | ||
2998 | if (pa != null) | 3648 | public void SetVehicleFlags(int param, bool remove) |
2999 | pa.VehicleType = type; | 3649 | { |
3650 | if (m_vehicleParams == null) | ||
3651 | return; | ||
3652 | |||
3653 | m_vehicleParams.ProcessVehicleFlags(param, remove); | ||
3654 | |||
3655 | if (_parentID ==0 && PhysActor != null) | ||
3656 | { | ||
3657 | PhysActor.VehicleFlags(param, remove); | ||
3658 | } | ||
3000 | } | 3659 | } |
3001 | 3660 | ||
3002 | public void SetVehicleFloatParam(int param, float value) | 3661 | public void SetVehicleFloatParam(int param, float value) |
3003 | { | 3662 | { |
3004 | PhysicsActor pa = PhysActor; | 3663 | if (m_vehicleParams == null) |
3664 | return; | ||
3005 | 3665 | ||
3006 | if (pa != null) | 3666 | m_vehicleParams.ProcessFloatVehicleParam((Vehicle)param, value); |
3007 | pa.VehicleFloatParam(param, value); | 3667 | |
3668 | if (_parentID == 0 && PhysActor != null) | ||
3669 | { | ||
3670 | PhysActor.VehicleFloatParam(param, value); | ||
3671 | } | ||
3008 | } | 3672 | } |
3009 | 3673 | ||
3010 | public void SetVehicleVectorParam(int param, Vector3 value) | 3674 | public void SetVehicleVectorParam(int param, Vector3 value) |
3011 | { | 3675 | { |
3012 | PhysicsActor pa = PhysActor; | 3676 | if (m_vehicleParams == null) |
3677 | return; | ||
3013 | 3678 | ||
3014 | if (pa != null) | 3679 | m_vehicleParams.ProcessVectorVehicleParam((Vehicle)param, value); |
3015 | pa.VehicleVectorParam(param, value); | 3680 | |
3681 | if (_parentID == 0 && PhysActor != null) | ||
3682 | { | ||
3683 | PhysActor.VehicleVectorParam(param, value); | ||
3684 | } | ||
3016 | } | 3685 | } |
3017 | 3686 | ||
3018 | public void SetVehicleRotationParam(int param, Quaternion rotation) | 3687 | public void SetVehicleRotationParam(int param, Quaternion rotation) |
3019 | { | 3688 | { |
3020 | PhysicsActor pa = PhysActor; | 3689 | if (m_vehicleParams == null) |
3690 | return; | ||
3021 | 3691 | ||
3022 | if (pa != null) | 3692 | m_vehicleParams.ProcessRotationVehicleParam((Vehicle)param, rotation); |
3023 | pa.VehicleRotationParam(param, rotation); | 3693 | |
3694 | if (_parentID == 0 && PhysActor != null) | ||
3695 | { | ||
3696 | PhysActor.VehicleRotationParam(param, rotation); | ||
3697 | } | ||
3024 | } | 3698 | } |
3025 | 3699 | ||
3026 | /// <summary> | 3700 | /// <summary> |
@@ -3221,14 +3895,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3221 | hasProfileCut = hasDimple; // is it the same thing? | 3895 | hasProfileCut = hasDimple; // is it the same thing? |
3222 | } | 3896 | } |
3223 | 3897 | ||
3224 | public void SetVehicleFlags(int param, bool remove) | ||
3225 | { | ||
3226 | PhysicsActor pa = PhysActor; | ||
3227 | |||
3228 | if (pa != null) | ||
3229 | pa.VehicleFlags(param, remove); | ||
3230 | } | ||
3231 | |||
3232 | public void SetGroup(UUID groupID, IClientAPI client) | 3898 | public void SetGroup(UUID groupID, IClientAPI client) |
3233 | { | 3899 | { |
3234 | // Scene.AddNewPrims() calls with client == null so can't use this. | 3900 | // Scene.AddNewPrims() calls with client == null so can't use this. |
@@ -3237,8 +3903,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3237 | // Name, groupID, OwnerID); | 3903 | // Name, groupID, OwnerID); |
3238 | 3904 | ||
3239 | GroupID = groupID; | 3905 | GroupID = groupID; |
3240 | if (client != null) | 3906 | // if (client != null) |
3241 | SendPropertiesToClient(client); | 3907 | // SendPropertiesToClient(client); |
3242 | UpdateFlag = UpdateRequired.FULL; | 3908 | UpdateFlag = UpdateRequired.FULL; |
3243 | } | 3909 | } |
3244 | 3910 | ||
@@ -3330,70 +3996,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3330 | 3996 | ||
3331 | public void StopMoveToTarget() | 3997 | public void StopMoveToTarget() |
3332 | { | 3998 | { |
3999 | <<<<<<< HEAD | ||
3333 | ParentGroup.StopMoveToTarget(); | 4000 | ParentGroup.StopMoveToTarget(); |
3334 | } | 4001 | ======= |
4002 | ParentGroup.stopMoveToTarget(); | ||
3335 | 4003 | ||
3336 | public void StoreUndoState() | 4004 | // ParentGroup.ScheduleGroupForTerseUpdate(); |
3337 | { | 4005 | //ParentGroup.ScheduleGroupForFullUpdate(); |
3338 | StoreUndoState(false); | 4006 | >>>>>>> avn/ubitvar |
3339 | } | 4007 | } |
3340 | 4008 | ||
3341 | public void StoreUndoState(bool forGroup) | 4009 | public void StoreUndoState(ObjectChangeType change) |
3342 | { | 4010 | { |
3343 | if (ParentGroup == null || ParentGroup.Scene == null) | 4011 | if (m_UndoRedo == null) |
3344 | return; | 4012 | m_UndoRedo = new UndoRedoState(5); |
3345 | |||
3346 | if (Undoing) | ||
3347 | { | ||
3348 | // m_log.DebugFormat( | ||
3349 | // "[SCENE OBJECT PART]: Ignoring undo store for {0} {1} since already undoing", Name, LocalId); | ||
3350 | return; | ||
3351 | } | ||
3352 | 4013 | ||
3353 | if (IgnoreUndoUpdate) | 4014 | lock (m_UndoRedo) |
3354 | { | 4015 | { |
3355 | // m_log.DebugFormat("[SCENE OBJECT PART]: Ignoring undo store for {0} {1}", Name, LocalId); | 4016 | if (!Undoing && !IgnoreUndoUpdate && ParentGroup != null) // just to read better - undo is in progress, or suspended |
3356 | return; | ||
3357 | } | ||
3358 | |||
3359 | lock (m_undo) | ||
3360 | { | ||
3361 | if (m_undo.Count > 0) | ||
3362 | { | ||
3363 | UndoState last = m_undo[m_undo.Count - 1]; | ||
3364 | if (last != null) | ||
3365 | { | ||
3366 | // TODO: May need to fix for group comparison | ||
3367 | if (last.Compare(this)) | ||
3368 | { | ||
3369 | // m_log.DebugFormat( | ||
3370 | // "[SCENE OBJECT PART]: Not storing undo for {0} {1} since current state is same as last undo state, initial stack size {2}", | ||
3371 | // Name, LocalId, m_undo.Count); | ||
3372 | |||
3373 | return; | ||
3374 | } | ||
3375 | } | ||
3376 | } | ||
3377 | |||
3378 | // m_log.DebugFormat( | ||
3379 | // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", | ||
3380 | // Name, LocalId, forGroup, m_undo.Count); | ||
3381 | |||
3382 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3383 | { | 4017 | { |
3384 | UndoState nUndo = new UndoState(this, forGroup); | 4018 | m_UndoRedo.StoreUndo(this, change); |
3385 | |||
3386 | m_undo.Add(nUndo); | ||
3387 | |||
3388 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3389 | m_undo.RemoveAt(0); | ||
3390 | |||
3391 | if (m_redo.Count > 0) | ||
3392 | m_redo.Clear(); | ||
3393 | |||
3394 | // m_log.DebugFormat( | ||
3395 | // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", | ||
3396 | // Name, LocalId, forGroup, m_undo.Count); | ||
3397 | } | 4019 | } |
3398 | } | 4020 | } |
3399 | } | 4021 | } |
@@ -3405,88 +4027,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
3405 | { | 4027 | { |
3406 | get | 4028 | get |
3407 | { | 4029 | { |
3408 | lock (m_undo) | 4030 | if (m_UndoRedo == null) |
3409 | return m_undo.Count; | 4031 | return 0; |
4032 | return m_UndoRedo.Count; | ||
3410 | } | 4033 | } |
3411 | } | 4034 | } |
3412 | 4035 | ||
3413 | public void Undo() | 4036 | public void Undo() |
3414 | { | 4037 | { |
3415 | lock (m_undo) | 4038 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3416 | { | 4039 | return; |
3417 | // m_log.DebugFormat( | ||
3418 | // "[SCENE OBJECT PART]: Handling undo request for {0} {1}, stack size {2}", | ||
3419 | // Name, LocalId, m_undo.Count); | ||
3420 | |||
3421 | if (m_undo.Count > 0) | ||
3422 | { | ||
3423 | UndoState goback = m_undo[m_undo.Count - 1]; | ||
3424 | m_undo.RemoveAt(m_undo.Count - 1); | ||
3425 | |||
3426 | UndoState nUndo = null; | ||
3427 | |||
3428 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3429 | { | ||
3430 | nUndo = new UndoState(this, goback.ForGroup); | ||
3431 | } | ||
3432 | |||
3433 | goback.PlaybackState(this); | ||
3434 | |||
3435 | if (nUndo != null) | ||
3436 | { | ||
3437 | m_redo.Add(nUndo); | ||
3438 | |||
3439 | if (m_redo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3440 | m_redo.RemoveAt(0); | ||
3441 | } | ||
3442 | } | ||
3443 | 4040 | ||
3444 | // m_log.DebugFormat( | 4041 | lock (m_UndoRedo) |
3445 | // "[SCENE OBJECT PART]: Handled undo request for {0} {1}, stack size now {2}", | 4042 | { |
3446 | // Name, LocalId, m_undo.Count); | 4043 | Undoing = true; |
4044 | m_UndoRedo.Undo(this); | ||
4045 | Undoing = false; | ||
3447 | } | 4046 | } |
3448 | } | 4047 | } |
3449 | 4048 | ||
3450 | public void Redo() | 4049 | public void Redo() |
3451 | { | 4050 | { |
3452 | lock (m_undo) | 4051 | if (m_UndoRedo == null || Undoing || ParentGroup == null) |
3453 | { | 4052 | return; |
3454 | // m_log.DebugFormat( | ||
3455 | // "[SCENE OBJECT PART]: Handling redo request for {0} {1}, stack size {2}", | ||
3456 | // Name, LocalId, m_redo.Count); | ||
3457 | |||
3458 | if (m_redo.Count > 0) | ||
3459 | { | ||
3460 | UndoState gofwd = m_redo[m_redo.Count - 1]; | ||
3461 | m_redo.RemoveAt(m_redo.Count - 1); | ||
3462 | |||
3463 | if (ParentGroup.Scene.MaxUndoCount > 0) | ||
3464 | { | ||
3465 | UndoState nUndo = new UndoState(this, gofwd.ForGroup); | ||
3466 | |||
3467 | m_undo.Add(nUndo); | ||
3468 | |||
3469 | if (m_undo.Count > ParentGroup.Scene.MaxUndoCount) | ||
3470 | m_undo.RemoveAt(0); | ||
3471 | } | ||
3472 | |||
3473 | gofwd.PlayfwdState(this); | ||
3474 | 4053 | ||
3475 | // m_log.DebugFormat( | 4054 | lock (m_UndoRedo) |
3476 | // "[SCENE OBJECT PART]: Handled redo request for {0} {1}, stack size now {2}", | 4055 | { |
3477 | // Name, LocalId, m_redo.Count); | 4056 | Undoing = true; |
3478 | } | 4057 | m_UndoRedo.Redo(this); |
4058 | Undoing = false; | ||
3479 | } | 4059 | } |
3480 | } | 4060 | } |
3481 | 4061 | ||
3482 | public void ClearUndoState() | 4062 | public void ClearUndoState() |
3483 | { | 4063 | { |
3484 | // m_log.DebugFormat("[SCENE OBJECT PART]: Clearing undo and redo stacks in {0} {1}", Name, LocalId); | 4064 | if (m_UndoRedo == null || Undoing) |
4065 | return; | ||
3485 | 4066 | ||
3486 | lock (m_undo) | 4067 | lock (m_UndoRedo) |
3487 | { | 4068 | { |
3488 | m_undo.Clear(); | 4069 | m_UndoRedo.Clear(); |
3489 | m_redo.Clear(); | ||
3490 | } | 4070 | } |
3491 | } | 4071 | } |
3492 | 4072 | ||
@@ -4038,7 +4618,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4038 | if (god) | 4618 | if (god) |
4039 | { | 4619 | { |
4040 | BaseMask = ApplyMask(BaseMask, set, mask); | 4620 | BaseMask = ApplyMask(BaseMask, set, mask); |
4041 | Inventory.ApplyGodPermissions(_baseMask); | 4621 | Inventory.ApplyGodPermissions(BaseMask); |
4042 | } | 4622 | } |
4043 | 4623 | ||
4044 | break; | 4624 | break; |
@@ -4069,7 +4649,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4069 | } | 4649 | } |
4070 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & | 4650 | NextOwnerMask = ApplyMask(NextOwnerMask, set, mask) & |
4071 | baseMask; | 4651 | baseMask; |
4072 | // Prevent the client from creating no mod, no copy | 4652 | // Prevent the client from creating no copy, no transfer |
4073 | // objects | 4653 | // objects |
4074 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) | 4654 | if ((NextOwnerMask & (uint)PermissionMask.Copy) == 0) |
4075 | NextOwnerMask |= (uint)PermissionMask.Transfer; | 4655 | NextOwnerMask |= (uint)PermissionMask.Transfer; |
@@ -4087,20 +4667,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4087 | { | 4667 | { |
4088 | bool update = false; | 4668 | bool update = false; |
4089 | 4669 | ||
4090 | if (BaseMask != source.BaseMask || | 4670 | uint prevOwnerMask = OwnerMask; |
4091 | OwnerMask != source.OwnerMask || | 4671 | uint prevGroupMask = GroupMask; |
4092 | GroupMask != source.GroupMask || | 4672 | uint prevEveryoneMask = EveryoneMask; |
4093 | EveryoneMask != source.EveryoneMask || | 4673 | uint prevNextOwnerMask = NextOwnerMask; |
4094 | NextOwnerMask != source.NextOwnerMask) | ||
4095 | update = true; | ||
4096 | 4674 | ||
4097 | BaseMask = source.BaseMask; | 4675 | OwnerMask = source.OwnerMask & BaseMask; |
4098 | OwnerMask = source.OwnerMask; | 4676 | GroupMask = source.GroupMask & BaseMask; |
4099 | GroupMask = source.GroupMask; | 4677 | EveryoneMask = source.EveryoneMask & BaseMask; |
4100 | EveryoneMask = source.EveryoneMask; | 4678 | NextOwnerMask = source.NextOwnerMask & BaseMask; |
4101 | NextOwnerMask = source.NextOwnerMask; | ||
4102 | 4679 | ||
4103 | if (update) | 4680 | if (OwnerMask != prevOwnerMask || |
4681 | GroupMask != prevGroupMask || | ||
4682 | EveryoneMask != prevEveryoneMask || | ||
4683 | NextOwnerMask != prevNextOwnerMask) | ||
4104 | SendFullUpdateToAllClients(); | 4684 | SendFullUpdateToAllClients(); |
4105 | } | 4685 | } |
4106 | 4686 | ||
@@ -4151,6 +4731,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4151 | } | 4731 | } |
4152 | } | 4732 | } |
4153 | 4733 | ||
4734 | |||
4154 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) | 4735 | public void UpdateExtraPhysics(ExtraPhysicsData physdata) |
4155 | { | 4736 | { |
4156 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) | 4737 | if (physdata.PhysShapeType == PhysShapeType.invalid || ParentGroup == null) |
@@ -4178,7 +4759,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4178 | /// <param name="SetTemporary"></param> | 4759 | /// <param name="SetTemporary"></param> |
4179 | /// <param name="SetPhantom"></param> | 4760 | /// <param name="SetPhantom"></param> |
4180 | /// <param name="SetVD"></param> | 4761 | /// <param name="SetVD"></param> |
4181 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD) | 4762 | public void UpdatePrimFlags(bool UsePhysics, bool SetTemporary, bool SetPhantom, bool SetVD, bool building) |
4182 | { | 4763 | { |
4183 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); | 4764 | bool wasUsingPhysics = ((Flags & PrimFlags.Physics) != 0); |
4184 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); | 4765 | bool wasTemporary = ((Flags & PrimFlags.TemporaryOnRez) != 0); |
@@ -4188,99 +4769,110 @@ namespace OpenSim.Region.Framework.Scenes | |||
4188 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) | 4769 | if ((UsePhysics == wasUsingPhysics) && (wasTemporary == SetTemporary) && (wasPhantom == SetPhantom) && (SetVD == wasVD)) |
4189 | return; | 4770 | return; |
4190 | 4771 | ||
4191 | PhysicsActor pa = PhysActor; | 4772 | VolumeDetectActive = SetVD; |
4192 | |||
4193 | // Special cases for VD. VD can only be called from a script | ||
4194 | // and can't be combined with changes to other states. So we can rely | ||
4195 | // that... | ||
4196 | // ... if VD is changed, all others are not. | ||
4197 | // ... if one of the others is changed, VD is not. | ||
4198 | if (SetVD) // VD is active, special logic applies | ||
4199 | { | ||
4200 | // State machine logic for VolumeDetect | ||
4201 | // More logic below | ||
4202 | bool phanReset = (SetPhantom != wasPhantom) && !SetPhantom; | ||
4203 | |||
4204 | if (phanReset) // Phantom changes from on to off switch VD off too | ||
4205 | { | ||
4206 | SetVD = false; // Switch it of for the course of this routine | ||
4207 | VolumeDetectActive = false; // and also permanently | ||
4208 | 4773 | ||
4209 | if (pa != null) | 4774 | // volume detector implies phantom |
4210 | pa.SetVolumeDetect(0); // Let physics know about it too | 4775 | if (VolumeDetectActive) |
4211 | } | ||
4212 | else | ||
4213 | { | ||
4214 | // If volumedetect is active we don't want phantom to be applied. | ||
4215 | // If this is a new call to VD out of the state "phantom" | ||
4216 | // this will also cause the prim to be visible to physics | ||
4217 | SetPhantom = false; | ||
4218 | } | ||
4219 | } | ||
4220 | |||
4221 | if (UsePhysics && IsJoint()) | ||
4222 | { | ||
4223 | SetPhantom = true; | 4776 | SetPhantom = true; |
4224 | } | ||
4225 | 4777 | ||
4226 | if (UsePhysics) | 4778 | if (UsePhysics) |
4227 | { | ||
4228 | AddFlag(PrimFlags.Physics); | 4779 | AddFlag(PrimFlags.Physics); |
4229 | if (!wasUsingPhysics) | ||
4230 | { | ||
4231 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4232 | } | ||
4233 | } | ||
4234 | else | 4780 | else |
4235 | { | ||
4236 | RemFlag(PrimFlags.Physics); | 4781 | RemFlag(PrimFlags.Physics); |
4237 | if (wasUsingPhysics) | ||
4238 | { | ||
4239 | DoPhysicsPropertyUpdate(UsePhysics, false); | ||
4240 | } | ||
4241 | } | ||
4242 | 4782 | ||
4243 | if (SetPhantom | 4783 | if (SetPhantom) |
4244 | || ParentGroup.IsAttachment | ||
4245 | || PhysicsShapeType == (byte)PhysShapeType.none | ||
4246 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) // note: this may have been changed above in the case of joints | ||
4247 | { | ||
4248 | AddFlag(PrimFlags.Phantom); | 4784 | AddFlag(PrimFlags.Phantom); |
4785 | else | ||
4786 | RemFlag(PrimFlags.Phantom); | ||
4249 | 4787 | ||
4250 | if (PhysActor != null) | 4788 | if (SetTemporary) |
4789 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4790 | else | ||
4791 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4792 | |||
4793 | |||
4794 | if (ParentGroup.Scene == null) | ||
4795 | return; | ||
4796 | |||
4797 | PhysicsActor pa = PhysActor; | ||
4798 | |||
4799 | if (pa != null && building && pa.Building != building) | ||
4800 | pa.Building = building; | ||
4801 | |||
4802 | if ((SetPhantom && !UsePhysics && !SetVD) || ParentGroup.IsAttachment || PhysicsShapeType == (byte)PhysShapeType.none | ||
4803 | || (Shape.PathCurve == (byte)Extrusion.Flexible)) | ||
4804 | { | ||
4805 | if (pa != null) | ||
4251 | { | 4806 | { |
4807 | if(wasUsingPhysics) | ||
4808 | ParentGroup.Scene.RemovePhysicalPrim(1); | ||
4252 | RemoveFromPhysics(); | 4809 | RemoveFromPhysics(); |
4253 | pa = null; | ||
4254 | } | 4810 | } |
4811 | |||
4812 | Velocity = new Vector3(0, 0, 0); | ||
4813 | Acceleration = new Vector3(0, 0, 0); | ||
4814 | if (ParentGroup.RootPart == this) | ||
4815 | AngularVelocity = new Vector3(0, 0, 0); | ||
4255 | } | 4816 | } |
4256 | else // Not phantom | 4817 | |
4818 | else | ||
4257 | { | 4819 | { |
4258 | RemFlag(PrimFlags.Phantom); | 4820 | if (ParentGroup.Scene.CollidablePrims) |
4259 | |||
4260 | if (ParentGroup.Scene == null) | ||
4261 | return; | ||
4262 | |||
4263 | if (ParentGroup.Scene.CollidablePrims && pa == null) | ||
4264 | { | 4821 | { |
4265 | AddToPhysics(UsePhysics, SetPhantom, false); | 4822 | if (pa == null) |
4266 | pa = PhysActor; | 4823 | { |
4267 | 4824 | AddToPhysics(UsePhysics, SetPhantom, building, false); | |
4268 | if (pa != null) | 4825 | pa = PhysActor; |
4826 | /* | ||
4827 | if (pa != null) | ||
4828 | { | ||
4829 | if ( | ||
4830 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4831 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4832 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4833 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4834 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4835 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4836 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4837 | ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || | ||
4838 | (CollisionSound != UUID.Zero) | ||
4839 | ) | ||
4840 | { | ||
4841 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4842 | pa.SubscribeEvents(1000); | ||
4843 | } | ||
4844 | } | ||
4845 | */ | ||
4846 | if (pa != null) | ||
4847 | { | ||
4848 | pa.SetMaterial(Material); | ||
4849 | DoPhysicsPropertyUpdate(UsePhysics, true); | ||
4850 | } | ||
4851 | } | ||
4852 | else // it already has a physical representation | ||
4269 | { | 4853 | { |
4854 | <<<<<<< HEAD | ||
4270 | pa.SetMaterial(Material); | 4855 | pa.SetMaterial(Material); |
4271 | pa.Position = GetWorldPosition(); | 4856 | pa.Position = GetWorldPosition(); |
4272 | pa.Orientation = GetWorldRotation(); | 4857 | pa.Orientation = GetWorldRotation(); |
4273 | DoPhysicsPropertyUpdate(UsePhysics, true); | 4858 | DoPhysicsPropertyUpdate(UsePhysics, true); |
4859 | ======= | ||
4860 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. | ||
4861 | /* moved into DoPhysicsPropertyUpdate | ||
4862 | if(VolumeDetectActive) | ||
4863 | pa.SetVolumeDetect(1); | ||
4864 | else | ||
4865 | pa.SetVolumeDetect(0); | ||
4866 | */ | ||
4867 | >>>>>>> avn/ubitvar | ||
4274 | 4868 | ||
4275 | SubscribeForCollisionEvents(); | 4869 | if (pa.Building != building) |
4870 | pa.Building = building; | ||
4276 | } | 4871 | } |
4277 | } | ||
4278 | else // it already has a physical representation | ||
4279 | { | ||
4280 | DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim | ||
4281 | } | ||
4282 | } | ||
4283 | 4872 | ||
4873 | UpdatePhysicsSubscribedEvents(); | ||
4874 | } | ||
4875 | } | ||
4284 | if (SetVD) | 4876 | if (SetVD) |
4285 | { | 4877 | { |
4286 | // If the above logic worked (this is urgent candidate to unit tests!) | 4878 | // If the above logic worked (this is urgent candidate to unit tests!) |
@@ -4294,6 +4886,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4294 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active | 4886 | AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active |
4295 | VolumeDetectActive = true; | 4887 | VolumeDetectActive = true; |
4296 | } | 4888 | } |
4889 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | ||
4297 | } | 4890 | } |
4298 | else if (SetVD != wasVD) | 4891 | else if (SetVD != wasVD) |
4299 | { | 4892 | { |
@@ -4305,105 +4898,51 @@ namespace OpenSim.Region.Framework.Scenes | |||
4305 | RemFlag(PrimFlags.Phantom); | 4898 | RemFlag(PrimFlags.Phantom); |
4306 | VolumeDetectActive = false; | 4899 | VolumeDetectActive = false; |
4307 | } | 4900 | } |
4308 | 4901 | // and last in case we have a new actor and not building | |
4309 | if (SetTemporary) | ||
4310 | { | ||
4311 | AddFlag(PrimFlags.TemporaryOnRez); | ||
4312 | } | ||
4313 | else | ||
4314 | { | ||
4315 | RemFlag(PrimFlags.TemporaryOnRez); | ||
4316 | } | ||
4317 | |||
4318 | // m_log.Debug("Update: PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString()); | ||
4319 | 4902 | ||
4320 | if (ParentGroup != null) | 4903 | if (ParentGroup != null) |
4321 | { | 4904 | { |
4322 | ParentGroup.HasGroupChanged = true; | 4905 | ParentGroup.HasGroupChanged = true; |
4323 | ScheduleFullUpdate(); | 4906 | ScheduleFullUpdate(); |
4324 | } | 4907 | } |
4325 | 4908 | ||
4326 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); | 4909 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); |
4327 | } | 4910 | } |
4328 | 4911 | ||
4329 | /// <summary> | 4912 | /// <summary> |
4330 | /// Subscribe for physics collision events if needed for scripts and sounds | ||
4331 | /// </summary> | ||
4332 | public void SubscribeForCollisionEvents() | ||
4333 | { | ||
4334 | PhysicsActor pa = PhysActor; | ||
4335 | |||
4336 | if (pa != null) | ||
4337 | { | ||
4338 | if ( | ||
4339 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4340 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4341 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4342 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4343 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4344 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4345 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4346 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4347 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4348 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4349 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4350 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4351 | (CollisionSound != UUID.Zero) | ||
4352 | ) | ||
4353 | { | ||
4354 | if (!pa.SubscribedEvents()) | ||
4355 | { | ||
4356 | // If not already subscribed for event, set up for a collision event. | ||
4357 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4358 | pa.SubscribeEvents(1000); | ||
4359 | } | ||
4360 | } | ||
4361 | else | ||
4362 | { | ||
4363 | // There is no need to be subscribed to collisions so, if subscribed, remove subscription | ||
4364 | if (pa.SubscribedEvents()) | ||
4365 | { | ||
4366 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4367 | pa.UnSubscribeEvents(); | ||
4368 | } | ||
4369 | } | ||
4370 | } | ||
4371 | } | ||
4372 | |||
4373 | /// <summary> | ||
4374 | /// Adds this part to the physics scene. | 4913 | /// Adds this part to the physics scene. |
4914 | /// and sets the PhysActor property | ||
4375 | /// </summary> | 4915 | /// </summary> |
4376 | /// <remarks>This method also sets the PhysActor property.</remarks> | 4916 | /// <param name="isPhysical">Add this prim as physical.</param> |
4377 | /// <param name="rigidBody">Add this prim with a rigid body.</param> | 4917 | /// <param name="isPhantom">Add this prim as phantom.</param> |
4378 | /// <returns> | 4918 | /// <param name="building">tells physics to delay full construction of object</param> |
4379 | /// The physics actor. null if there was a failure. | 4919 | /// <param name="applyDynamics">applies velocities, force and torque</param> |
4380 | /// </returns> | 4920 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool building, bool applyDynamics) |
4381 | private void AddToPhysics(bool isPhysical, bool isPhantom, bool applyDynamics) | 4921 | { |
4382 | { | ||
4383 | PhysicsActor pa; | 4922 | PhysicsActor pa; |
4384 | 4923 | ||
4385 | Vector3 velocity = Velocity; | 4924 | Vector3 velocity = Velocity; |
4386 | Vector3 rotationalVelocity = AngularVelocity;; | 4925 | Vector3 rotationalVelocity = AngularVelocity;; |
4387 | 4926 | ||
4388 | try | 4927 | try |
4389 | { | 4928 | { |
4390 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( | 4929 | pa = ParentGroup.Scene.PhysicsScene.AddPrimShape( |
4391 | string.Format("{0}/{1}", Name, UUID), | 4930 | string.Format("{0}/{1}", Name, UUID), |
4392 | Shape, | 4931 | Shape, |
4393 | AbsolutePosition, | 4932 | AbsolutePosition, |
4394 | Scale, | 4933 | Scale, |
4395 | GetWorldRotation(), | 4934 | GetWorldRotation(), |
4396 | isPhysical, | 4935 | isPhysical, |
4397 | isPhantom, | 4936 | isPhantom, |
4398 | PhysicsShapeType, | 4937 | PhysicsShapeType, |
4399 | m_localId); | 4938 | m_localId); |
4400 | } | 4939 | } |
4401 | catch (Exception e) | 4940 | catch (Exception e) |
4402 | { | 4941 | { |
4403 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); | 4942 | m_log.ErrorFormat("[SCENE]: caught exception meshing object {0}. Object set to phantom. e={1}", m_uuid, e); |
4404 | pa = null; | 4943 | pa = null; |
4405 | } | 4944 | } |
4406 | 4945 | ||
4407 | if (pa != null) | 4946 | if (pa != null) |
4408 | { | 4947 | { |
4409 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info | 4948 | pa.SOPName = this.Name; // save object into the PhysActor so ODE internals know the joint/body info |
@@ -4416,9 +4955,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4416 | 4955 | ||
4417 | if (VolumeDetectActive) // change if not the default only | 4956 | if (VolumeDetectActive) // change if not the default only |
4418 | pa.SetVolumeDetect(1); | 4957 | pa.SetVolumeDetect(1); |
4958 | |||
4959 | if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) | ||
4960 | m_vehicleParams.SetVehicle(pa); | ||
4961 | |||
4419 | // we are going to tell rest of code about physics so better have this here | 4962 | // we are going to tell rest of code about physics so better have this here |
4420 | PhysActor = pa; | 4963 | PhysActor = pa; |
4421 | 4964 | ||
4965 | // DoPhysicsPropertyUpdate(isPhysical, true); | ||
4966 | // lets expand it here just with what it really needs to do | ||
4967 | |||
4422 | if (isPhysical) | 4968 | if (isPhysical) |
4423 | { | 4969 | { |
4424 | if (ParentGroup.RootPart.KeyframeMotion != null) | 4970 | if (ParentGroup.RootPart.KeyframeMotion != null) |
@@ -4440,19 +4986,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
4440 | } | 4986 | } |
4441 | } | 4987 | } |
4442 | 4988 | ||
4443 | if (applyDynamics) | 4989 | if (applyDynamics) |
4444 | // do independent of isphysical so parameters get setted (at least some) | 4990 | // do independent of isphysical so parameters get setted (at least some) |
4445 | { | 4991 | { |
4446 | Velocity = velocity; | 4992 | Velocity = velocity; |
4447 | AngularVelocity = rotationalVelocity; | 4993 | AngularVelocity = rotationalVelocity; |
4448 | // pa.Velocity = velocity; | 4994 | // pa.Velocity = velocity; |
4449 | pa.RotationalVelocity = rotationalVelocity; | 4995 | pa.RotationalVelocity = rotationalVelocity; |
4996 | |||
4997 | // if not vehicle and root part apply force and torque | ||
4998 | if ((m_vehicleParams == null || m_vehicleParams.Type == Vehicle.TYPE_NONE) | ||
4999 | && LocalId == ParentGroup.RootPart.LocalId) | ||
5000 | { | ||
5001 | pa.Force = Force; | ||
5002 | pa.Torque = Torque; | ||
5003 | } | ||
4450 | } | 5004 | } |
4451 | 5005 | ||
4452 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | 5006 | // if (Shape.SculptEntry) |
5007 | // CheckSculptAndLoad(); | ||
5008 | // else | ||
5009 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(pa); | ||
5010 | |||
5011 | if (!building) | ||
5012 | pa.Building = false; | ||
4453 | } | 5013 | } |
4454 | 5014 | ||
4455 | PhysActor = pa; | 5015 | PhysActor = pa; |
5016 | |||
4456 | ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); | 5017 | ParentGroup.Scene.EventManager.TriggerObjectAddedToPhysicalScene(this); |
4457 | } | 5018 | } |
4458 | 5019 | ||
@@ -4461,14 +5022,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
4461 | /// </summary> | 5022 | /// </summary> |
4462 | /// <remarks> | 5023 | /// <remarks> |
4463 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics | 5024 | /// This isn't the same as turning off physical, since even without being physical the prim has a physics |
4464 | /// representation for collision detection. Rather, this would be used in situations such as making a prim | 5025 | /// representation for collision detection. |
4465 | /// phantom. | ||
4466 | /// </remarks> | 5026 | /// </remarks> |
4467 | public void RemoveFromPhysics() | 5027 | public void RemoveFromPhysics() |
4468 | { | 5028 | { |
4469 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | 5029 | PhysicsActor pa = PhysActor; |
4470 | if (ParentGroup.Scene.PhysicsScene != null) | 5030 | if (pa != null) |
4471 | ParentGroup.Scene.PhysicsScene.RemovePrim(PhysActor); | 5031 | { |
5032 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5033 | pa.OnRequestTerseUpdate -= PhysicsRequestingTerseUpdate; | ||
5034 | pa.OnOutOfBounds -= PhysicsOutOfBounds; | ||
5035 | |||
5036 | ParentGroup.Scene.PhysicsScene.RemovePrim(pa); | ||
5037 | |||
5038 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | ||
5039 | } | ||
4472 | PhysActor = null; | 5040 | PhysActor = null; |
4473 | } | 5041 | } |
4474 | 5042 | ||
@@ -4600,6 +5168,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4600 | { | 5168 | { |
4601 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); | 5169 | // m_log.DebugFormat("Processing CheckSculptAndLoad for {0} {1}", Name, LocalId); |
4602 | 5170 | ||
5171 | return; | ||
5172 | |||
4603 | if (ParentGroup.IsDeleted) | 5173 | if (ParentGroup.IsDeleted) |
4604 | return; | 5174 | return; |
4605 | 5175 | ||
@@ -4723,6 +5293,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
4723 | } | 5293 | } |
4724 | } | 5294 | } |
4725 | 5295 | ||
5296 | |||
5297 | private void UpdatePhysicsSubscribedEvents() | ||
5298 | { | ||
5299 | PhysicsActor pa = PhysActor; | ||
5300 | if (pa == null) | ||
5301 | return; | ||
5302 | |||
5303 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5304 | |||
5305 | bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0)); | ||
5306 | |||
5307 | scriptEvents CombinedEvents = AggregateScriptEvents; | ||
5308 | |||
5309 | // merge with root part | ||
5310 | if (ParentGroup != null && ParentGroup.RootPart != null) | ||
5311 | CombinedEvents |= ParentGroup.RootPart.AggregateScriptEvents; | ||
5312 | |||
5313 | // submit to this part case | ||
5314 | if (VolumeDetectActive) | ||
5315 | CombinedEvents &= PhyscicsVolumeDtcSubsEvents; | ||
5316 | else if ((Flags & PrimFlags.Phantom) != 0) | ||
5317 | CombinedEvents &= PhyscicsPhantonSubsEvents; | ||
5318 | else | ||
5319 | CombinedEvents &= PhysicsNeededSubsEvents; | ||
5320 | |||
5321 | if (hassound || CombinedEvents != 0) | ||
5322 | { | ||
5323 | // subscribe to physics updates. | ||
5324 | pa.OnCollisionUpdate += PhysicsCollision; | ||
5325 | pa.SubscribeEvents(50); // 20 reports per second | ||
5326 | } | ||
5327 | else | ||
5328 | { | ||
5329 | pa.UnSubscribeEvents(); | ||
5330 | } | ||
5331 | } | ||
5332 | |||
5333 | |||
4726 | public void aggregateScriptEvents() | 5334 | public void aggregateScriptEvents() |
4727 | { | 5335 | { |
4728 | if (ParentGroup == null || ParentGroup.RootPart == null) | 5336 | if (ParentGroup == null || ParentGroup.RootPart == null) |
@@ -4759,8 +5367,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
4759 | { | 5367 | { |
4760 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 5368 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4761 | } | 5369 | } |
4762 | 5370 | /* | |
4763 | SubscribeForCollisionEvents(); | 5371 | PhysicsActor pa = PhysActor; |
5372 | if (pa != null) | ||
5373 | { | ||
5374 | if ( | ||
5375 | // ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
5376 | // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
5377 | // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
5378 | // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
5379 | // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
5380 | // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
5381 | ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero) | ||
5382 | ) | ||
5383 | { | ||
5384 | // subscribe to physics updates. | ||
5385 | pa.OnCollisionUpdate += PhysicsCollision; | ||
5386 | pa.SubscribeEvents(1000); | ||
5387 | } | ||
5388 | else | ||
5389 | { | ||
5390 | pa.UnSubscribeEvents(); | ||
5391 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
5392 | } | ||
5393 | } | ||
5394 | */ | ||
5395 | UpdatePhysicsSubscribedEvents(); | ||
4764 | 5396 | ||
4765 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 5397 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4766 | //{ | 5398 | //{ |
@@ -4969,6 +5601,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4969 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); | 5601 | return new Color4(color.R, color.G, color.B, (byte)(0xFF - color.A)); |
4970 | } | 5602 | } |
4971 | 5603 | ||
5604 | public void ResetOwnerChangeFlag() | ||
5605 | { | ||
5606 | List<UUID> inv = Inventory.GetInventoryList(); | ||
5607 | |||
5608 | foreach (UUID itemID in inv) | ||
5609 | { | ||
5610 | TaskInventoryItem item = Inventory.GetInventoryItem(itemID); | ||
5611 | item.OwnerChanged = false; | ||
5612 | Inventory.UpdateInventoryItem(item, false, false); | ||
5613 | } | ||
5614 | } | ||
5615 | |||
4972 | /// <summary> | 5616 | /// <summary> |
4973 | /// Record an avatar sitting on this part. | 5617 | /// Record an avatar sitting on this part. |
4974 | /// </summary> | 5618 | /// </summary> |
@@ -5062,4 +5706,4 @@ namespace OpenSim.Region.Framework.Scenes | |||
5062 | } | 5706 | } |
5063 | } | 5707 | } |
5064 | } | 5708 | } |
5065 | } \ No newline at end of file | 5709 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index ec39726..7af0b20 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -46,9 +46,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | private string m_inventoryFileName = String.Empty; | ||
50 | private byte[] m_inventoryFileData = new byte[0]; | 49 | private byte[] m_inventoryFileData = new byte[0]; |
51 | private uint m_inventoryFileNameSerial = 0; | 50 | private uint m_inventoryFileNameSerial = 0; |
51 | private bool m_inventoryPrivileged = false; | ||
52 | private object m_inventoryFileLock = new object(); | ||
53 | |||
54 | private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>(); | ||
52 | 55 | ||
53 | /// <value> | 56 | /// <value> |
54 | /// The part to which the inventory belongs. | 57 | /// The part to which the inventory belongs. |
@@ -85,7 +88,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
85 | /// </value> | 88 | /// </value> |
86 | protected internal TaskInventoryDictionary Items | 89 | protected internal TaskInventoryDictionary Items |
87 | { | 90 | { |
88 | get { return m_items; } | 91 | get { |
92 | return m_items; | ||
93 | } | ||
89 | set | 94 | set |
90 | { | 95 | { |
91 | m_items = value; | 96 | m_items = value; |
@@ -134,38 +139,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
134 | public void ResetInventoryIDs() | 139 | public void ResetInventoryIDs() |
135 | { | 140 | { |
136 | if (null == m_part) | 141 | if (null == m_part) |
137 | return; | 142 | m_items.LockItemsForWrite(true); |
138 | 143 | ||
139 | lock (m_items) | 144 | if (Items.Count == 0) |
140 | { | 145 | { |
141 | if (0 == m_items.Count) | 146 | m_items.LockItemsForWrite(false); |
142 | return; | 147 | return; |
148 | } | ||
143 | 149 | ||
144 | IList<TaskInventoryItem> items = GetInventoryItems(); | 150 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
145 | m_items.Clear(); | 151 | Items.Clear(); |
146 | 152 | ||
147 | foreach (TaskInventoryItem item in items) | 153 | foreach (TaskInventoryItem item in items) |
148 | { | 154 | { |
149 | item.ResetIDs(m_part.UUID); | 155 | item.ResetIDs(m_part.UUID); |
150 | m_items.Add(item.ItemID, item); | 156 | Items.Add(item.ItemID, item); |
151 | } | ||
152 | } | 157 | } |
158 | m_items.LockItemsForWrite(false); | ||
153 | } | 159 | } |
154 | 160 | ||
155 | public void ResetObjectID() | 161 | public void ResetObjectID() |
156 | { | 162 | { |
157 | lock (Items) | 163 | m_items.LockItemsForWrite(true); |
164 | |||
165 | if (Items.Count == 0) | ||
158 | { | 166 | { |
159 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | 167 | m_items.LockItemsForWrite(false); |
160 | Items.Clear(); | 168 | return; |
161 | |||
162 | foreach (TaskInventoryItem item in items) | ||
163 | { | ||
164 | item.ParentPartID = m_part.UUID; | ||
165 | item.ParentID = m_part.UUID; | ||
166 | Items.Add(item.ItemID, item); | ||
167 | } | ||
168 | } | 169 | } |
170 | |||
171 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); | ||
172 | Items.Clear(); | ||
173 | |||
174 | foreach (TaskInventoryItem item in items) | ||
175 | { | ||
176 | item.ParentPartID = m_part.UUID; | ||
177 | item.ParentID = m_part.UUID; | ||
178 | Items.Add(item.ItemID, item); | ||
179 | } | ||
180 | m_items.LockItemsForWrite(false); | ||
169 | } | 181 | } |
170 | 182 | ||
171 | /// <summary> | 183 | /// <summary> |
@@ -174,17 +186,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
174 | /// <param name="ownerId"></param> | 186 | /// <param name="ownerId"></param> |
175 | public void ChangeInventoryOwner(UUID ownerId) | 187 | public void ChangeInventoryOwner(UUID ownerId) |
176 | { | 188 | { |
177 | lock (Items) | 189 | List<TaskInventoryItem> items = GetInventoryItems(); |
178 | { | ||
179 | if (0 == Items.Count) | ||
180 | { | ||
181 | return; | ||
182 | } | ||
183 | } | ||
184 | 190 | ||
191 | if (items.Count == 0) | ||
192 | return; | ||
193 | |||
194 | m_items.LockItemsForWrite(true); | ||
185 | HasInventoryChanged = true; | 195 | HasInventoryChanged = true; |
186 | m_part.ParentGroup.HasGroupChanged = true; | 196 | m_part.ParentGroup.HasGroupChanged = true; |
187 | List<TaskInventoryItem> items = GetInventoryItems(); | ||
188 | foreach (TaskInventoryItem item in items) | 197 | foreach (TaskInventoryItem item in items) |
189 | { | 198 | { |
190 | if (ownerId != item.OwnerID) | 199 | if (ownerId != item.OwnerID) |
@@ -195,6 +204,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
195 | item.PermsGranter = UUID.Zero; | 204 | item.PermsGranter = UUID.Zero; |
196 | item.OwnerChanged = true; | 205 | item.OwnerChanged = true; |
197 | } | 206 | } |
207 | m_items.LockItemsForWrite(false); | ||
198 | } | 208 | } |
199 | 209 | ||
200 | /// <summary> | 210 | /// <summary> |
@@ -203,12 +213,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
203 | /// <param name="groupID"></param> | 213 | /// <param name="groupID"></param> |
204 | public void ChangeInventoryGroup(UUID groupID) | 214 | public void ChangeInventoryGroup(UUID groupID) |
205 | { | 215 | { |
206 | lock (Items) | 216 | m_items.LockItemsForWrite(true); |
217 | if (0 == Items.Count) | ||
207 | { | 218 | { |
208 | if (0 == Items.Count) | 219 | m_items.LockItemsForWrite(false); |
209 | { | 220 | return; |
210 | return; | ||
211 | } | ||
212 | } | 221 | } |
213 | 222 | ||
214 | // Don't let this set the HasGroupChanged flag for attachments | 223 | // Don't let this set the HasGroupChanged flag for attachments |
@@ -220,12 +229,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
220 | m_part.ParentGroup.HasGroupChanged = true; | 229 | m_part.ParentGroup.HasGroupChanged = true; |
221 | } | 230 | } |
222 | 231 | ||
223 | List<TaskInventoryItem> items = GetInventoryItems(); | 232 | IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values); |
224 | foreach (TaskInventoryItem item in items) | 233 | foreach (TaskInventoryItem item in items) |
225 | { | 234 | { |
226 | if (groupID != item.GroupID) | 235 | if (groupID != item.GroupID) |
236 | { | ||
227 | item.GroupID = groupID; | 237 | item.GroupID = groupID; |
238 | } | ||
228 | } | 239 | } |
240 | m_items.LockItemsForWrite(false); | ||
229 | } | 241 | } |
230 | 242 | ||
231 | private void QueryScriptStates() | 243 | private void QueryScriptStates() |
@@ -233,15 +245,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
233 | if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) | 245 | if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) |
234 | return; | 246 | return; |
235 | 247 | ||
236 | lock (Items) | 248 | Items.LockItemsForRead(true); |
249 | foreach (TaskInventoryItem item in Items.Values) | ||
237 | { | 250 | { |
238 | foreach (TaskInventoryItem item in Items.Values) | 251 | if (item.InvType == (int)InventoryType.LSL) |
239 | { | 252 | { |
240 | bool running; | 253 | bool running; |
241 | if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running)) | 254 | if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running)) |
242 | item.ScriptRunning = running; | 255 | item.ScriptRunning = running; |
243 | } | 256 | } |
244 | } | 257 | } |
258 | |||
259 | Items.LockItemsForRead(false); | ||
245 | } | 260 | } |
246 | 261 | ||
247 | public bool TryGetScriptInstanceRunning(UUID itemId, out bool running) | 262 | public bool TryGetScriptInstanceRunning(UUID itemId, out bool running) |
@@ -318,7 +333,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
318 | { | 333 | { |
319 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); | 334 | List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); |
320 | foreach (TaskInventoryItem item in scripts) | 335 | foreach (TaskInventoryItem item in scripts) |
336 | { | ||
321 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); | 337 | RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted); |
338 | m_part.RemoveScriptEvents(item.ItemID); | ||
339 | } | ||
322 | } | 340 | } |
323 | 341 | ||
324 | /// <summary> | 342 | /// <summary> |
@@ -340,7 +358,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
340 | // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 358 | // item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
341 | 359 | ||
342 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) | 360 | if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) |
361 | { | ||
362 | StoreScriptError(item.ItemID, "no permission"); | ||
343 | return false; | 363 | return false; |
364 | } | ||
344 | 365 | ||
345 | m_part.AddFlag(PrimFlags.Scripted); | 366 | m_part.AddFlag(PrimFlags.Scripted); |
346 | 367 | ||
@@ -350,14 +371,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
350 | if (stateSource == 2 && // Prim crossing | 371 | if (stateSource == 2 && // Prim crossing |
351 | m_part.ParentGroup.Scene.m_trustBinaries) | 372 | m_part.ParentGroup.Scene.m_trustBinaries) |
352 | { | 373 | { |
353 | lock (m_items) | 374 | m_items.LockItemsForWrite(true); |
354 | { | 375 | m_items[item.ItemID].PermsMask = 0; |
355 | m_items[item.ItemID].PermsMask = 0; | 376 | m_items[item.ItemID].PermsGranter = UUID.Zero; |
356 | m_items[item.ItemID].PermsGranter = UUID.Zero; | 377 | m_items.LockItemsForWrite(false); |
357 | } | ||
358 | |||
359 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 378 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
360 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); | 379 | m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); |
380 | StoreScriptErrors(item.ItemID, null); | ||
361 | m_part.ParentGroup.AddActiveScriptCount(1); | 381 | m_part.ParentGroup.AddActiveScriptCount(1); |
362 | m_part.ScheduleFullUpdate(); | 382 | m_part.ScheduleFullUpdate(); |
363 | return true; | 383 | return true; |
@@ -366,6 +386,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
366 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); | 386 | AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
367 | if (null == asset) | 387 | if (null == asset) |
368 | { | 388 | { |
389 | string msg = String.Format("asset ID {0} could not be found", item.AssetID); | ||
390 | StoreScriptError(item.ItemID, msg); | ||
369 | m_log.ErrorFormat( | 391 | m_log.ErrorFormat( |
370 | "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", | 392 | "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", |
371 | item.Name, item.ItemID, m_part.AbsolutePosition, | 393 | item.Name, item.ItemID, m_part.AbsolutePosition, |
@@ -378,16 +400,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
378 | if (m_part.ParentGroup.m_savedScriptState != null) | 400 | if (m_part.ParentGroup.m_savedScriptState != null) |
379 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); | 401 | item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID); |
380 | 402 | ||
381 | lock (m_items) | 403 | m_items.LockItemsForWrite(true); |
382 | { | ||
383 | m_items[item.ItemID].OldItemID = item.OldItemID; | ||
384 | m_items[item.ItemID].PermsMask = 0; | ||
385 | m_items[item.ItemID].PermsGranter = UUID.Zero; | ||
386 | } | ||
387 | 404 | ||
405 | m_items[item.ItemID].OldItemID = item.OldItemID; | ||
406 | m_items[item.ItemID].PermsMask = 0; | ||
407 | m_items[item.ItemID].PermsGranter = UUID.Zero; | ||
408 | |||
409 | m_items.LockItemsForWrite(false); | ||
410 | |||
388 | string script = Utils.BytesToString(asset.Data); | 411 | string script = Utils.BytesToString(asset.Data); |
389 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( | 412 | m_part.ParentGroup.Scene.EventManager.TriggerRezScript( |
390 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); | 413 | m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); |
414 | StoreScriptErrors(item.ItemID, null); | ||
391 | if (!item.ScriptRunning) | 415 | if (!item.ScriptRunning) |
392 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript( | 416 | m_part.ParentGroup.Scene.EventManager.TriggerStopScript( |
393 | m_part.LocalId, item.ItemID); | 417 | m_part.LocalId, item.ItemID); |
@@ -466,22 +490,138 @@ namespace OpenSim.Region.Framework.Scenes | |||
466 | return stateID; | 490 | return stateID; |
467 | } | 491 | } |
468 | 492 | ||
493 | /// <summary> | ||
494 | /// Start a script which is in this prim's inventory. | ||
495 | /// Some processing may occur in the background, but this routine returns asap. | ||
496 | /// </summary> | ||
497 | /// <param name="itemId"> | ||
498 | /// A <see cref="UUID"/> | ||
499 | /// </param> | ||
469 | public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | 500 | public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) |
470 | { | 501 | { |
471 | TaskInventoryItem item = GetInventoryItem(itemId); | 502 | lock (m_scriptErrors) |
472 | if (item != null) | 503 | { |
504 | // Indicate to CreateScriptInstanceInternal() we don't want it to wait for completion | ||
505 | m_scriptErrors.Remove(itemId); | ||
506 | } | ||
507 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
508 | return true; | ||
509 | } | ||
510 | |||
511 | private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
512 | { | ||
513 | m_items.LockItemsForRead(true); | ||
514 | |||
515 | if (m_items.ContainsKey(itemId)) | ||
473 | { | 516 | { |
474 | return CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); | 517 | TaskInventoryItem it = m_items[itemId]; |
518 | m_items.LockItemsForRead(false); | ||
519 | |||
520 | CreateScriptInstance(it, startParam, postOnRez, engine, stateSource); | ||
475 | } | 521 | } |
476 | else | 522 | else |
477 | { | 523 | { |
478 | m_log.ErrorFormat( | 524 | m_items.LockItemsForRead(false); |
479 | "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", | 525 | string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID, |
480 | itemId, m_part.Name, m_part.UUID, | ||
481 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 526 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
527 | StoreScriptError(itemId, msg); | ||
528 | m_log.ErrorFormat( | ||
529 | "[PRIM INVENTORY]: " + | ||
530 | "Couldn't start script with ID {0} since it {1}", itemId, msg); | ||
531 | } | ||
532 | } | ||
482 | 533 | ||
483 | return false; | 534 | /// <summary> |
535 | /// Start a script which is in this prim's inventory and return any compilation error messages. | ||
536 | /// </summary> | ||
537 | /// <param name="itemId"> | ||
538 | /// A <see cref="UUID"/> | ||
539 | /// </param> | ||
540 | public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) | ||
541 | { | ||
542 | ArrayList errors; | ||
543 | |||
544 | // Indicate to CreateScriptInstanceInternal() we want it to | ||
545 | // post any compilation/loading error messages | ||
546 | lock (m_scriptErrors) | ||
547 | { | ||
548 | m_scriptErrors[itemId] = null; | ||
484 | } | 549 | } |
550 | |||
551 | // Perform compilation/loading | ||
552 | CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); | ||
553 | |||
554 | // Wait for and retrieve any errors | ||
555 | lock (m_scriptErrors) | ||
556 | { | ||
557 | while ((errors = m_scriptErrors[itemId]) == null) | ||
558 | { | ||
559 | if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000)) | ||
560 | { | ||
561 | m_log.ErrorFormat( | ||
562 | "[PRIM INVENTORY]: " + | ||
563 | "timedout waiting for script {0} errors", itemId); | ||
564 | errors = m_scriptErrors[itemId]; | ||
565 | if (errors == null) | ||
566 | { | ||
567 | errors = new ArrayList(1); | ||
568 | errors.Add("timedout waiting for errors"); | ||
569 | } | ||
570 | break; | ||
571 | } | ||
572 | } | ||
573 | m_scriptErrors.Remove(itemId); | ||
574 | } | ||
575 | return errors; | ||
576 | } | ||
577 | |||
578 | // Signal to CreateScriptInstanceEr() that compilation/loading is complete | ||
579 | private void StoreScriptErrors(UUID itemId, ArrayList errors) | ||
580 | { | ||
581 | lock (m_scriptErrors) | ||
582 | { | ||
583 | // If compilation/loading initiated via CreateScriptInstance(), | ||
584 | // it does not want the errors, so just get out | ||
585 | if (!m_scriptErrors.ContainsKey(itemId)) | ||
586 | { | ||
587 | return; | ||
588 | } | ||
589 | |||
590 | // Initiated via CreateScriptInstanceEr(), if we know what the | ||
591 | // errors are, save them and wake CreateScriptInstanceEr(). | ||
592 | if (errors != null) | ||
593 | { | ||
594 | m_scriptErrors[itemId] = errors; | ||
595 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
596 | return; | ||
597 | } | ||
598 | } | ||
599 | |||
600 | // Initiated via CreateScriptInstanceEr() but we don't know what | ||
601 | // the errors are yet, so retrieve them from the script engine. | ||
602 | // This may involve some waiting internal to GetScriptErrors(). | ||
603 | errors = GetScriptErrors(itemId); | ||
604 | |||
605 | // Get a default non-null value to indicate success. | ||
606 | if (errors == null) | ||
607 | { | ||
608 | errors = new ArrayList(); | ||
609 | } | ||
610 | |||
611 | // Post to CreateScriptInstanceEr() and wake it up | ||
612 | lock (m_scriptErrors) | ||
613 | { | ||
614 | m_scriptErrors[itemId] = errors; | ||
615 | System.Threading.Monitor.PulseAll(m_scriptErrors); | ||
616 | } | ||
617 | } | ||
618 | |||
619 | // Like StoreScriptErrors(), but just posts a single string message | ||
620 | private void StoreScriptError(UUID itemId, string message) | ||
621 | { | ||
622 | ArrayList errors = new ArrayList(1); | ||
623 | errors.Add(message); | ||
624 | StoreScriptErrors(itemId, errors); | ||
485 | } | 625 | } |
486 | 626 | ||
487 | /// <summary> | 627 | /// <summary> |
@@ -494,15 +634,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
494 | /// </param> | 634 | /// </param> |
495 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) | 635 | public void RemoveScriptInstance(UUID itemId, bool sceneObjectBeingDeleted) |
496 | { | 636 | { |
497 | bool scriptPresent = false; | 637 | if (m_items.ContainsKey(itemId)) |
498 | |||
499 | lock (m_items) | ||
500 | { | ||
501 | if (m_items.ContainsKey(itemId)) | ||
502 | scriptPresent = true; | ||
503 | } | ||
504 | |||
505 | if (scriptPresent) | ||
506 | { | 638 | { |
507 | if (!sceneObjectBeingDeleted) | 639 | if (!sceneObjectBeingDeleted) |
508 | m_part.RemoveScriptEvents(itemId); | 640 | m_part.RemoveScriptEvents(itemId); |
@@ -573,14 +705,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
573 | /// <returns></returns> | 705 | /// <returns></returns> |
574 | private bool InventoryContainsName(string name) | 706 | private bool InventoryContainsName(string name) |
575 | { | 707 | { |
576 | lock (m_items) | 708 | m_items.LockItemsForRead(true); |
709 | foreach (TaskInventoryItem item in m_items.Values) | ||
577 | { | 710 | { |
578 | foreach (TaskInventoryItem item in m_items.Values) | 711 | if (item.Name == name) |
579 | { | 712 | { |
580 | if (item.Name == name) | 713 | m_items.LockItemsForRead(false); |
581 | return true; | 714 | return true; |
582 | } | 715 | } |
583 | } | 716 | } |
717 | m_items.LockItemsForRead(false); | ||
584 | return false; | 718 | return false; |
585 | } | 719 | } |
586 | 720 | ||
@@ -622,8 +756,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
622 | /// <param name="item"></param> | 756 | /// <param name="item"></param> |
623 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) | 757 | public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop) |
624 | { | 758 | { |
625 | List<TaskInventoryItem> il = GetInventoryItems(); | 759 | m_items.LockItemsForRead(true); |
626 | 760 | List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values); | |
761 | m_items.LockItemsForRead(false); | ||
627 | foreach (TaskInventoryItem i in il) | 762 | foreach (TaskInventoryItem i in il) |
628 | { | 763 | { |
629 | if (i.Name == item.Name) | 764 | if (i.Name == item.Name) |
@@ -661,14 +796,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
661 | item.Name = name; | 796 | item.Name = name; |
662 | item.GroupID = m_part.GroupID; | 797 | item.GroupID = m_part.GroupID; |
663 | 798 | ||
664 | lock (m_items) | 799 | m_items.LockItemsForWrite(true); |
665 | m_items.Add(item.ItemID, item); | 800 | m_items.Add(item.ItemID, item); |
666 | 801 | m_items.LockItemsForWrite(false); | |
667 | if (allowedDrop) | 802 | if (allowedDrop) |
668 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); | 803 | m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP); |
669 | else | 804 | else |
670 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 805 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
671 | 806 | ||
672 | m_inventorySerial++; | 807 | m_inventorySerial++; |
673 | //m_inventorySerial += 2; | 808 | //m_inventorySerial += 2; |
674 | HasInventoryChanged = true; | 809 | HasInventoryChanged = true; |
@@ -684,15 +819,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
684 | /// <param name="items"></param> | 819 | /// <param name="items"></param> |
685 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) | 820 | public void RestoreInventoryItems(ICollection<TaskInventoryItem> items) |
686 | { | 821 | { |
687 | lock (m_items) | 822 | m_items.LockItemsForWrite(true); |
823 | foreach (TaskInventoryItem item in items) | ||
688 | { | 824 | { |
689 | foreach (TaskInventoryItem item in items) | 825 | m_items.Add(item.ItemID, item); |
690 | { | 826 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
691 | m_items.Add(item.ItemID, item); | ||
692 | // m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | ||
693 | } | ||
694 | m_inventorySerial++; | ||
695 | } | 827 | } |
828 | m_items.LockItemsForWrite(false); | ||
829 | |||
830 | m_inventorySerial++; | ||
696 | } | 831 | } |
697 | 832 | ||
698 | /// <summary> | 833 | /// <summary> |
@@ -703,23 +838,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
703 | public TaskInventoryItem GetInventoryItem(UUID itemId) | 838 | public TaskInventoryItem GetInventoryItem(UUID itemId) |
704 | { | 839 | { |
705 | TaskInventoryItem item; | 840 | TaskInventoryItem item; |
706 | 841 | m_items.LockItemsForRead(true); | |
707 | lock (m_items) | 842 | m_items.TryGetValue(itemId, out item); |
708 | m_items.TryGetValue(itemId, out item); | 843 | m_items.LockItemsForRead(false); |
709 | |||
710 | return item; | 844 | return item; |
711 | } | 845 | } |
712 | 846 | ||
713 | public TaskInventoryItem GetInventoryItem(string name) | 847 | public TaskInventoryItem GetInventoryItem(string name) |
714 | { | 848 | { |
715 | lock (m_items) | 849 | m_items.LockItemsForRead(true); |
850 | foreach (TaskInventoryItem item in m_items.Values) | ||
716 | { | 851 | { |
717 | foreach (TaskInventoryItem item in m_items.Values) | 852 | if (item.Name == name) |
718 | { | 853 | { |
719 | if (item.Name == name) | 854 | m_items.LockItemsForRead(false); |
720 | return item; | 855 | return item; |
721 | } | 856 | } |
722 | } | 857 | } |
858 | m_items.LockItemsForRead(false); | ||
723 | 859 | ||
724 | return null; | 860 | return null; |
725 | } | 861 | } |
@@ -728,19 +864,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
728 | { | 864 | { |
729 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); | 865 | List<TaskInventoryItem> items = new List<TaskInventoryItem>(); |
730 | 866 | ||
731 | lock (m_items) | 867 | m_items.LockItemsForRead(true); |
868 | |||
869 | foreach (TaskInventoryItem item in m_items.Values) | ||
732 | { | 870 | { |
733 | foreach (TaskInventoryItem item in m_items.Values) | 871 | if (item.Name == name) |
734 | { | 872 | items.Add(item); |
735 | if (item.Name == name) | ||
736 | items.Add(item); | ||
737 | } | ||
738 | } | 873 | } |
739 | 874 | ||
875 | m_items.LockItemsForRead(false); | ||
876 | |||
740 | return items; | 877 | return items; |
741 | } | 878 | } |
742 | 879 | ||
743 | public bool GetRezReadySceneObjects(TaskInventoryItem item, out List<SceneObjectGroup> objlist, out List<Vector3> veclist) | 880 | public bool GetRezReadySceneObjects(TaskInventoryItem item, out List<SceneObjectGroup> objlist, out List<Vector3> veclist, out Vector3 bbox, out float offsetHeight) |
744 | { | 881 | { |
745 | AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); | 882 | AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); |
746 | 883 | ||
@@ -751,18 +888,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
751 | item.AssetID, item.Name, m_part.Name); | 888 | item.AssetID, item.Name, m_part.Name); |
752 | objlist = null; | 889 | objlist = null; |
753 | veclist = null; | 890 | veclist = null; |
891 | bbox = Vector3.Zero; | ||
892 | offsetHeight = 0; | ||
754 | return false; | 893 | return false; |
755 | } | 894 | } |
895 | <<<<<<< HEAD | ||
756 | 896 | ||
757 | Vector3 bbox; | 897 | Vector3 bbox; |
758 | float offsetHeight; | 898 | float offsetHeight; |
759 | 899 | ||
760 | m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight); | 900 | m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight); |
901 | ======= | ||
902 | |||
903 | bool single = m_part.ParentGroup.Scene.GetObjectsToRez(rezAsset.Data, false, out objlist, out veclist, out bbox, out offsetHeight); | ||
904 | >>>>>>> avn/ubitvar | ||
761 | 905 | ||
762 | for (int i = 0; i < objlist.Count; i++) | 906 | for (int i = 0; i < objlist.Count; i++) |
763 | { | 907 | { |
764 | SceneObjectGroup group = objlist[i]; | 908 | SceneObjectGroup group = objlist[i]; |
765 | 909 | /* | |
910 | group.RootPart.AttachPoint = group.RootPart.Shape.State; | ||
911 | group.RootPart.AttachedPos = group.AbsolutePosition; | ||
912 | group.RootPart.AttachRotation = group.GroupRotation; | ||
913 | */ | ||
766 | group.ResetIDs(); | 914 | group.ResetIDs(); |
767 | 915 | ||
768 | SceneObjectPart rootPart = group.GetPart(group.UUID); | 916 | SceneObjectPart rootPart = group.GetPart(group.UUID); |
@@ -771,12 +919,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
771 | // in the serialization, transfer the correct name from the inventory to the | 919 | // in the serialization, transfer the correct name from the inventory to the |
772 | // object itself before we rez. | 920 | // object itself before we rez. |
773 | // Only do these for the first object if we are rezzing a coalescence. | 921 | // Only do these for the first object if we are rezzing a coalescence. |
774 | if (i == 0) | 922 | // nahh dont mess with coalescence objects, |
923 | // the name in inventory can be change for inventory purpuses only | ||
924 | if (objlist.Count == 1) | ||
775 | { | 925 | { |
776 | rootPart.Name = item.Name; | 926 | rootPart.Name = item.Name; |
777 | rootPart.Description = item.Description; | 927 | rootPart.Description = item.Description; |
778 | } | 928 | } |
779 | 929 | /* reverted to old code till part.ApplyPermissionsOnRez is better reviewed/fixed | |
780 | group.SetGroup(m_part.GroupID, null); | 930 | group.SetGroup(m_part.GroupID, null); |
781 | 931 | ||
782 | foreach (SceneObjectPart part in group.Parts) | 932 | foreach (SceneObjectPart part in group.Parts) |
@@ -792,7 +942,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
792 | 942 | ||
793 | part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene); | 943 | part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene); |
794 | } | 944 | } |
945 | */ | ||
946 | // old code start | ||
947 | SceneObjectPart[] partList = group.Parts; | ||
948 | |||
949 | group.SetGroup(m_part.GroupID, null); | ||
795 | 950 | ||
951 | // TODO: Remove magic number badness | ||
952 | if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number | ||
953 | { | ||
954 | if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) | ||
955 | { | ||
956 | foreach (SceneObjectPart part in partList) | ||
957 | { | ||
958 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | ||
959 | part.EveryoneMask = item.EveryonePermissions; | ||
960 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | ||
961 | part.NextOwnerMask = item.NextPermissions; | ||
962 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) | ||
963 | part.GroupMask = item.GroupPermissions; | ||
964 | } | ||
965 | |||
966 | group.ApplyNextOwnerPermissions(); | ||
967 | } | ||
968 | } | ||
969 | |||
970 | foreach (SceneObjectPart part in partList) | ||
971 | { | ||
972 | // TODO: Remove magic number badness | ||
973 | if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number | ||
974 | { | ||
975 | part.LastOwnerID = part.OwnerID; | ||
976 | part.OwnerID = item.OwnerID; | ||
977 | part.Inventory.ChangeInventoryOwner(item.OwnerID); | ||
978 | } | ||
979 | |||
980 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) | ||
981 | part.EveryoneMask = item.EveryonePermissions; | ||
982 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) | ||
983 | part.NextOwnerMask = item.NextPermissions; | ||
984 | if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) | ||
985 | part.GroupMask = item.GroupPermissions; | ||
986 | } | ||
987 | // old code end | ||
796 | rootPart.TrimPermissions(); | 988 | rootPart.TrimPermissions(); |
797 | } | 989 | } |
798 | 990 | ||
@@ -817,8 +1009,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
817 | 1009 | ||
818 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) | 1010 | public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents, bool considerChanged) |
819 | { | 1011 | { |
820 | TaskInventoryItem it = GetInventoryItem(item.ItemID); | 1012 | m_items.LockItemsForWrite(true); |
821 | if (it != null) | 1013 | |
1014 | if (m_items.ContainsKey(item.ItemID)) | ||
822 | { | 1015 | { |
823 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); | 1016 | // m_log.DebugFormat("[PRIM INVENTORY]: Updating item {0} in {1}", item.Name, m_part.Name); |
824 | 1017 | ||
@@ -831,14 +1024,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
831 | item.GroupID = m_part.GroupID; | 1024 | item.GroupID = m_part.GroupID; |
832 | 1025 | ||
833 | if (item.AssetID == UUID.Zero) | 1026 | if (item.AssetID == UUID.Zero) |
834 | item.AssetID = it.AssetID; | 1027 | item.AssetID = m_items[item.ItemID].AssetID; |
835 | 1028 | ||
836 | lock (m_items) | 1029 | m_items[item.ItemID] = item; |
837 | { | 1030 | m_inventorySerial++; |
838 | m_items[item.ItemID] = item; | ||
839 | m_inventorySerial++; | ||
840 | } | ||
841 | |||
842 | if (fireScriptEvents) | 1031 | if (fireScriptEvents) |
843 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 1032 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
844 | 1033 | ||
@@ -847,7 +1036,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
847 | HasInventoryChanged = true; | 1036 | HasInventoryChanged = true; |
848 | m_part.ParentGroup.HasGroupChanged = true; | 1037 | m_part.ParentGroup.HasGroupChanged = true; |
849 | } | 1038 | } |
850 | 1039 | m_items.LockItemsForWrite(false); | |
851 | return true; | 1040 | return true; |
852 | } | 1041 | } |
853 | else | 1042 | else |
@@ -858,8 +1047,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
858 | item.ItemID, m_part.Name, m_part.UUID, | 1047 | item.ItemID, m_part.Name, m_part.UUID, |
859 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | 1048 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); |
860 | } | 1049 | } |
861 | return false; | 1050 | m_items.LockItemsForWrite(false); |
862 | 1051 | ||
1052 | return false; | ||
863 | } | 1053 | } |
864 | 1054 | ||
865 | /// <summary> | 1055 | /// <summary> |
@@ -870,160 +1060,187 @@ namespace OpenSim.Region.Framework.Scenes | |||
870 | /// in this prim's inventory.</returns> | 1060 | /// in this prim's inventory.</returns> |
871 | public int RemoveInventoryItem(UUID itemID) | 1061 | public int RemoveInventoryItem(UUID itemID) |
872 | { | 1062 | { |
873 | TaskInventoryItem item = GetInventoryItem(itemID); | 1063 | m_items.LockItemsForRead(true); |
874 | if (item != null) | 1064 | |
1065 | if (m_items.ContainsKey(itemID)) | ||
875 | { | 1066 | { |
876 | int type = m_items[itemID].InvType; | 1067 | int type = m_items[itemID].InvType; |
1068 | m_items.LockItemsForRead(false); | ||
877 | if (type == 10) // Script | 1069 | if (type == 10) // Script |
878 | { | 1070 | { |
1071 | <<<<<<< HEAD | ||
879 | // route it through here, to handle script cleanup tasks | 1072 | // route it through here, to handle script cleanup tasks |
880 | RemoveScriptInstance(itemID, false); | 1073 | RemoveScriptInstance(itemID, false); |
1074 | ======= | ||
1075 | m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID); | ||
1076 | >>>>>>> avn/ubitvar | ||
881 | } | 1077 | } |
1078 | m_items.LockItemsForWrite(true); | ||
882 | m_items.Remove(itemID); | 1079 | m_items.Remove(itemID); |
1080 | m_items.LockItemsForWrite(false); | ||
883 | m_inventorySerial++; | 1081 | m_inventorySerial++; |
884 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 1082 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
885 | 1083 | ||
886 | HasInventoryChanged = true; | 1084 | HasInventoryChanged = true; |
887 | m_part.ParentGroup.HasGroupChanged = true; | 1085 | m_part.ParentGroup.HasGroupChanged = true; |
888 | 1086 | ||
889 | if (!ContainsScripts()) | 1087 | int scriptcount = 0; |
1088 | m_items.LockItemsForRead(true); | ||
1089 | foreach (TaskInventoryItem item in m_items.Values) | ||
1090 | { | ||
1091 | if (item.Type == 10) | ||
1092 | { | ||
1093 | scriptcount++; | ||
1094 | } | ||
1095 | } | ||
1096 | m_items.LockItemsForRead(false); | ||
1097 | |||
1098 | |||
1099 | if (scriptcount <= 0) | ||
1100 | { | ||
890 | m_part.RemFlag(PrimFlags.Scripted); | 1101 | m_part.RemFlag(PrimFlags.Scripted); |
1102 | } | ||
891 | 1103 | ||
892 | m_part.ScheduleFullUpdate(); | 1104 | m_part.ScheduleFullUpdate(); |
893 | 1105 | ||
894 | return type; | 1106 | return type; |
895 | |||
896 | } | 1107 | } |
897 | else | 1108 | else |
898 | { | 1109 | { |
1110 | m_items.LockItemsForRead(false); | ||
899 | m_log.ErrorFormat( | 1111 | m_log.ErrorFormat( |
900 | "[PRIM INVENTORY]: " + | 1112 | "[PRIM INVENTORY]: " + |
901 | "Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory", | 1113 | "Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory", |
902 | itemID, m_part.Name, m_part.UUID, | 1114 | itemID, m_part.Name, m_part.UUID); |
903 | m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); | ||
904 | } | 1115 | } |
905 | 1116 | ||
906 | return -1; | 1117 | return -1; |
907 | } | 1118 | } |
908 | 1119 | ||
909 | private bool CreateInventoryFile() | 1120 | |
1121 | /// <summary> | ||
1122 | /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client | ||
1123 | /// </summary> | ||
1124 | /// <param name="xferManager"></param> | ||
1125 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) | ||
910 | { | 1126 | { |
911 | // m_log.DebugFormat( | ||
912 | // "[PRIM INVENTORY]: Creating inventory file for {0} {1} {2}, serial {3}", | ||
913 | // m_part.Name, m_part.UUID, m_part.LocalId, m_inventorySerial); | ||
914 | 1127 | ||
915 | if (m_inventoryFileName == String.Empty || | 1128 | lock (m_inventoryFileLock) |
916 | m_inventoryFileNameSerial < m_inventorySerial) | ||
917 | { | 1129 | { |
918 | // Something changed, we need to create a new file | 1130 | string filename = "inventory_" + UUID.Random().ToString() + ".tmp"; |
919 | m_inventoryFileName = "inventory_" + UUID.Random().ToString() + ".tmp"; | ||
920 | m_inventoryFileNameSerial = m_inventorySerial; | ||
921 | 1131 | ||
922 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); | 1132 | bool changed = false; |
923 | 1133 | if (m_inventoryFileNameSerial < m_inventorySerial) | |
924 | lock (m_items) | ||
925 | { | 1134 | { |
926 | foreach (TaskInventoryItem item in m_items.Values) | 1135 | m_inventoryFileNameSerial = m_inventorySerial; |
927 | { | 1136 | changed = true; |
928 | // m_log.DebugFormat( | 1137 | } |
929 | // "[PRIM INVENTORY]: Adding item {0} {1} for serial {2} on prim {3} {4} {5}", | ||
930 | // item.Name, item.ItemID, m_inventorySerial, m_part.Name, m_part.UUID, m_part.LocalId); | ||
931 | |||
932 | UUID ownerID = item.OwnerID; | ||
933 | uint everyoneMask = 0; | ||
934 | uint baseMask = item.BasePermissions; | ||
935 | uint ownerMask = item.CurrentPermissions; | ||
936 | uint groupMask = item.GroupPermissions; | ||
937 | 1138 | ||
938 | invString.AddItemStart(); | 1139 | if (m_inventoryFileData.Length < 2) |
939 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); | 1140 | changed = true; |
940 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
941 | 1141 | ||
942 | invString.AddPermissionsStart(); | 1142 | bool includeAssets = false; |
1143 | if (m_part.ParentGroup.Scene.Permissions.CanEditObjectInventory(m_part.UUID, client.AgentId)) | ||
1144 | includeAssets = true; | ||
943 | 1145 | ||
944 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | 1146 | if (m_inventoryPrivileged != includeAssets) |
945 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | 1147 | changed = true; |
946 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
947 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
948 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
949 | 1148 | ||
950 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
951 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
952 | 1149 | ||
953 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | 1150 | Items.LockItemsForRead(true); |
954 | 1151 | ||
955 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | 1152 | if (m_inventorySerial == 0) // No inventory |
956 | invString.AddSectionEnd(); | 1153 | { |
1154 | Items.LockItemsForRead(false); | ||
1155 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | ||
1156 | |||
1157 | return; | ||
1158 | } | ||
957 | 1159 | ||
958 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | 1160 | if (m_items.Count == 0) // No inventory |
959 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | 1161 | { |
960 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | 1162 | Items.LockItemsForRead(false); |
961 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | 1163 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); |
1164 | return; | ||
1165 | } | ||
962 | 1166 | ||
963 | invString.AddSaleStart(); | 1167 | if (!changed) |
964 | invString.AddNameValueLine("sale_type", "not"); | 1168 | { |
965 | invString.AddNameValueLine("sale_price", "0"); | 1169 | Items.LockItemsForRead(false); |
966 | invString.AddSectionEnd(); | ||
967 | 1170 | ||
968 | invString.AddNameValueLine("name", item.Name + "|"); | 1171 | xferManager.AddNewFile(filename, |
969 | invString.AddNameValueLine("desc", item.Description + "|"); | 1172 | m_inventoryFileData); |
1173 | client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial, | ||
1174 | Util.StringToBytes256(filename)); | ||
970 | 1175 | ||
971 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | 1176 | return; |
972 | invString.AddSectionEnd(); | ||
973 | } | ||
974 | } | 1177 | } |
975 | 1178 | ||
976 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); | 1179 | m_inventoryPrivileged = includeAssets; |
977 | 1180 | ||
978 | return true; | 1181 | InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero); |
979 | } | ||
980 | |||
981 | // No need to recreate, the existing file is fine | ||
982 | return false; | ||
983 | } | ||
984 | 1182 | ||
985 | /// <summary> | 1183 | foreach (TaskInventoryItem item in m_items.Values) |
986 | /// Serialize all the metadata for the items in this prim's inventory ready for sending to the client | ||
987 | /// </summary> | ||
988 | /// <param name="xferManager"></param> | ||
989 | public void RequestInventoryFile(IClientAPI client, IXfer xferManager) | ||
990 | { | ||
991 | lock (m_items) | ||
992 | { | ||
993 | // Don't send a inventory xfer name if there are no items. Doing so causes viewer 3 to crash when rezzing | ||
994 | // a new script if any previous deletion has left the prim inventory empty. | ||
995 | if (m_items.Count == 0) // No inventory | ||
996 | { | 1184 | { |
997 | // m_log.DebugFormat( | 1185 | UUID ownerID = item.OwnerID; |
998 | // "[PRIM INVENTORY]: Not sending inventory data for part {0} {1} {2} for {3} since no items", | 1186 | uint everyoneMask = 0; |
999 | // m_part.Name, m_part.LocalId, m_part.UUID, client.Name); | 1187 | uint baseMask = item.BasePermissions; |
1188 | uint ownerMask = item.CurrentPermissions; | ||
1189 | uint groupMask = item.GroupPermissions; | ||
1000 | 1190 | ||
1001 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); | 1191 | invString.AddItemStart(); |
1002 | return; | 1192 | invString.AddNameValueLine("item_id", item.ItemID.ToString()); |
1193 | invString.AddNameValueLine("parent_id", m_part.UUID.ToString()); | ||
1194 | |||
1195 | invString.AddPermissionsStart(); | ||
1196 | |||
1197 | invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask)); | ||
1198 | invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask)); | ||
1199 | invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask)); | ||
1200 | invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask)); | ||
1201 | invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions)); | ||
1202 | |||
1203 | invString.AddNameValueLine("creator_id", item.CreatorID.ToString()); | ||
1204 | invString.AddNameValueLine("owner_id", ownerID.ToString()); | ||
1205 | |||
1206 | invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString()); | ||
1207 | |||
1208 | invString.AddNameValueLine("group_id", item.GroupID.ToString()); | ||
1209 | invString.AddSectionEnd(); | ||
1210 | |||
1211 | if (includeAssets) | ||
1212 | invString.AddNameValueLine("asset_id", item.AssetID.ToString()); | ||
1213 | else | ||
1214 | invString.AddNameValueLine("asset_id", UUID.Zero.ToString()); | ||
1215 | invString.AddNameValueLine("type", Utils.AssetTypeToString((AssetType)item.Type)); | ||
1216 | invString.AddNameValueLine("inv_type", Utils.InventoryTypeToString((InventoryType)item.InvType)); | ||
1217 | invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags)); | ||
1218 | |||
1219 | invString.AddSaleStart(); | ||
1220 | invString.AddNameValueLine("sale_type", "not"); | ||
1221 | invString.AddNameValueLine("sale_price", "0"); | ||
1222 | invString.AddSectionEnd(); | ||
1223 | |||
1224 | invString.AddNameValueLine("name", item.Name + "|"); | ||
1225 | invString.AddNameValueLine("desc", item.Description + "|"); | ||
1226 | |||
1227 | invString.AddNameValueLine("creation_date", item.CreationDate.ToString()); | ||
1228 | invString.AddSectionEnd(); | ||
1003 | } | 1229 | } |
1004 | 1230 | ||
1005 | CreateInventoryFile(); | 1231 | Items.LockItemsForRead(false); |
1006 | 1232 | ||
1007 | // In principle, we should only do the rest if the inventory changed; | 1233 | m_inventoryFileData = Utils.StringToBytes(invString.BuildString); |
1008 | // by sending m_inventorySerial to the client, it ought to know | 1234 | |
1009 | // that nothing changed and that it doesn't need to request the file. | ||
1010 | // Unfortunately, it doesn't look like the client optimizes this; | ||
1011 | // the client seems to always come back and request the Xfer, | ||
1012 | // no matter what value m_inventorySerial has. | ||
1013 | // FIXME: Could probably be > 0 here rather than > 2 | ||
1014 | if (m_inventoryFileData.Length > 2) | 1235 | if (m_inventoryFileData.Length > 2) |
1015 | { | 1236 | { |
1016 | // Add the file for Xfer | 1237 | xferManager.AddNewFile(filename, m_inventoryFileData); |
1017 | // m_log.DebugFormat( | 1238 | client.SendTaskInventory(m_part.UUID, (short)m_inventoryFileNameSerial, |
1018 | // "[PRIM INVENTORY]: Adding inventory file {0} (length {1}) for transfer on {2} {3} {4}", | 1239 | Util.StringToBytes256(filename)); |
1019 | // m_inventoryFileName, m_inventoryFileData.Length, m_part.Name, m_part.UUID, m_part.LocalId); | 1240 | return; |
1020 | |||
1021 | xferManager.AddNewFile(m_inventoryFileName, m_inventoryFileData); | ||
1022 | } | 1241 | } |
1023 | 1242 | ||
1024 | // Tell the client we're ready to Xfer the file | 1243 | client.SendTaskInventory(m_part.UUID, 0, new byte[0]); |
1025 | client.SendTaskInventory(m_part.UUID, (short)m_inventorySerial, | ||
1026 | Util.StringToBytes256(m_inventoryFileName)); | ||
1027 | } | 1244 | } |
1028 | } | 1245 | } |
1029 | 1246 | ||
@@ -1033,13 +1250,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
1033 | /// <param name="datastore"></param> | 1250 | /// <param name="datastore"></param> |
1034 | public void ProcessInventoryBackup(ISimulationDataService datastore) | 1251 | public void ProcessInventoryBackup(ISimulationDataService datastore) |
1035 | { | 1252 | { |
1036 | if (HasInventoryChanged) | 1253 | // Removed this because linking will cause an immediate delete of the new |
1037 | { | 1254 | // child prim from the database and the subsequent storing of the prim sees |
1255 | // the inventory of it as unchanged and doesn't store it at all. The overhead | ||
1256 | // of storing prim inventory needlessly is much less than the aggravation | ||
1257 | // of prim inventory loss. | ||
1258 | // if (HasInventoryChanged) | ||
1259 | // { | ||
1260 | Items.LockItemsForRead(true); | ||
1261 | try | ||
1262 | { | ||
1263 | datastore.StorePrimInventory(m_part.UUID, Items.Values); | ||
1264 | } | ||
1265 | catch {} | ||
1266 | |||
1038 | HasInventoryChanged = false; | 1267 | HasInventoryChanged = false; |
1039 | List<TaskInventoryItem> items = GetInventoryItems(); | ||
1040 | datastore.StorePrimInventory(m_part.UUID, items); | ||
1041 | 1268 | ||
1042 | } | 1269 | Items.LockItemsForRead(false); |
1270 | |||
1271 | |||
1272 | // } | ||
1043 | } | 1273 | } |
1044 | 1274 | ||
1045 | public class InventoryStringBuilder | 1275 | public class InventoryStringBuilder |
@@ -1105,65 +1335,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
1105 | { | 1335 | { |
1106 | uint mask=0x7fffffff; | 1336 | uint mask=0x7fffffff; |
1107 | 1337 | ||
1108 | lock (m_items) | 1338 | foreach (TaskInventoryItem item in m_items.Values) |
1109 | { | 1339 | { |
1110 | foreach (TaskInventoryItem item in m_items.Values) | 1340 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) |
1341 | mask &= ~((uint)PermissionMask.Copy >> 13); | ||
1342 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1343 | mask &= ~((uint)PermissionMask.Transfer >> 13); | ||
1344 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | ||
1345 | mask &= ~((uint)PermissionMask.Modify >> 13); | ||
1346 | |||
1347 | if (item.InvType == (int)InventoryType.Object) | ||
1111 | { | 1348 | { |
1112 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Copy) == 0) | 1349 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1113 | mask &= ~((uint)PermissionMask.Copy >> 13); | 1350 | mask &= ~((uint)PermissionMask.Copy >> 13); |
1114 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Transfer) == 0) | 1351 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1115 | mask &= ~((uint)PermissionMask.Transfer >> 13); | 1352 | mask &= ~((uint)PermissionMask.Transfer >> 13); |
1116 | if ((item.CurrentPermissions & item.NextPermissions & (uint)PermissionMask.Modify) == 0) | 1353 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1117 | mask &= ~((uint)PermissionMask.Modify >> 13); | 1354 | mask &= ~((uint)PermissionMask.Modify >> 13); |
1118 | |||
1119 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1120 | mask &= ~(uint)PermissionMask.Copy; | ||
1121 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1122 | mask &= ~(uint)PermissionMask.Transfer; | ||
1123 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1124 | mask &= ~(uint)PermissionMask.Modify; | ||
1125 | } | 1355 | } |
1356 | |||
1357 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
1358 | mask &= ~(uint)PermissionMask.Copy; | ||
1359 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
1360 | mask &= ~(uint)PermissionMask.Transfer; | ||
1361 | if ((item.CurrentPermissions & (uint)PermissionMask.Modify) == 0) | ||
1362 | mask &= ~(uint)PermissionMask.Modify; | ||
1126 | } | 1363 | } |
1127 | |||
1128 | return mask; | 1364 | return mask; |
1129 | } | 1365 | } |
1130 | 1366 | ||
1131 | public void ApplyNextOwnerPermissions() | 1367 | public void ApplyNextOwnerPermissions() |
1132 | { | 1368 | { |
1133 | lock (m_items) | 1369 | foreach (TaskInventoryItem item in m_items.Values) |
1134 | { | 1370 | { |
1135 | foreach (TaskInventoryItem item in m_items.Values) | 1371 | if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) |
1136 | { | 1372 | { |
1137 | // m_log.DebugFormat ( | 1373 | if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) |
1138 | // "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", | 1374 | item.CurrentPermissions &= ~(uint)PermissionMask.Copy; |
1139 | // item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); | 1375 | if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) |
1140 | 1376 | item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; | |
1141 | if (item.InvType == (int)InventoryType.Object) | 1377 | if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) |
1142 | { | 1378 | item.CurrentPermissions &= ~(uint)PermissionMask.Modify; |
1143 | uint perms = item.CurrentPermissions; | ||
1144 | PermissionsUtil.ApplyFoldedPermissions(perms, ref perms); | ||
1145 | item.CurrentPermissions = perms; | ||
1146 | } | ||
1147 | |||
1148 | item.CurrentPermissions &= item.NextPermissions; | ||
1149 | item.BasePermissions &= item.NextPermissions; | ||
1150 | item.EveryonePermissions &= item.NextPermissions; | ||
1151 | item.OwnerChanged = true; | ||
1152 | item.PermsMask = 0; | ||
1153 | item.PermsGranter = UUID.Zero; | ||
1154 | } | 1379 | } |
1380 | item.CurrentPermissions &= item.NextPermissions; | ||
1381 | item.BasePermissions &= item.NextPermissions; | ||
1382 | item.EveryonePermissions &= item.NextPermissions; | ||
1383 | item.OwnerChanged = true; | ||
1384 | item.PermsMask = 0; | ||
1385 | item.PermsGranter = UUID.Zero; | ||
1155 | } | 1386 | } |
1156 | } | 1387 | } |
1157 | 1388 | ||
1158 | public void ApplyGodPermissions(uint perms) | 1389 | public void ApplyGodPermissions(uint perms) |
1159 | { | 1390 | { |
1160 | lock (m_items) | 1391 | foreach (TaskInventoryItem item in m_items.Values) |
1161 | { | 1392 | { |
1162 | foreach (TaskInventoryItem item in m_items.Values) | 1393 | item.CurrentPermissions = perms; |
1163 | { | 1394 | item.BasePermissions = perms; |
1164 | item.CurrentPermissions = perms; | ||
1165 | item.BasePermissions = perms; | ||
1166 | } | ||
1167 | } | 1395 | } |
1168 | 1396 | ||
1169 | m_inventorySerial++; | 1397 | m_inventorySerial++; |
@@ -1176,14 +1404,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1176 | /// <returns></returns> | 1404 | /// <returns></returns> |
1177 | public bool ContainsScripts() | 1405 | public bool ContainsScripts() |
1178 | { | 1406 | { |
1179 | lock (m_items) | 1407 | foreach (TaskInventoryItem item in m_items.Values) |
1180 | { | 1408 | { |
1181 | foreach (TaskInventoryItem item in m_items.Values) | 1409 | if (item.InvType == (int)InventoryType.LSL) |
1182 | { | 1410 | { |
1183 | if (item.InvType == (int)InventoryType.LSL) | 1411 | return true; |
1184 | { | ||
1185 | return true; | ||
1186 | } | ||
1187 | } | 1412 | } |
1188 | } | 1413 | } |
1189 | 1414 | ||
@@ -1197,17 +1422,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1197 | public int ScriptCount() | 1422 | public int ScriptCount() |
1198 | { | 1423 | { |
1199 | int count = 0; | 1424 | int count = 0; |
1200 | lock (m_items) | 1425 | Items.LockItemsForRead(true); |
1426 | foreach (TaskInventoryItem item in m_items.Values) | ||
1201 | { | 1427 | { |
1202 | foreach (TaskInventoryItem item in m_items.Values) | 1428 | if (item.InvType == (int)InventoryType.LSL) |
1203 | { | 1429 | { |
1204 | if (item.InvType == (int)InventoryType.LSL) | 1430 | count++; |
1205 | { | ||
1206 | count++; | ||
1207 | } | ||
1208 | } | 1431 | } |
1209 | } | 1432 | } |
1210 | 1433 | Items.LockItemsForRead(false); | |
1211 | return count; | 1434 | return count; |
1212 | } | 1435 | } |
1213 | /// <summary> | 1436 | /// <summary> |
@@ -1243,11 +1466,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1243 | { | 1466 | { |
1244 | List<UUID> ret = new List<UUID>(); | 1467 | List<UUID> ret = new List<UUID>(); |
1245 | 1468 | ||
1246 | lock (m_items) | 1469 | foreach (TaskInventoryItem item in m_items.Values) |
1247 | { | 1470 | ret.Add(item.ItemID); |
1248 | foreach (TaskInventoryItem item in m_items.Values) | ||
1249 | ret.Add(item.ItemID); | ||
1250 | } | ||
1251 | 1471 | ||
1252 | return ret; | 1472 | return ret; |
1253 | } | 1473 | } |
@@ -1256,8 +1476,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1256 | { | 1476 | { |
1257 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1477 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1258 | 1478 | ||
1259 | lock (m_items) | 1479 | Items.LockItemsForRead(true); |
1260 | ret = new List<TaskInventoryItem>(m_items.Values); | 1480 | ret = new List<TaskInventoryItem>(m_items.Values); |
1481 | Items.LockItemsForRead(false); | ||
1261 | 1482 | ||
1262 | return ret; | 1483 | return ret; |
1263 | } | 1484 | } |
@@ -1266,18 +1487,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1266 | { | 1487 | { |
1267 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); | 1488 | List<TaskInventoryItem> ret = new List<TaskInventoryItem>(); |
1268 | 1489 | ||
1269 | lock (m_items) | 1490 | Items.LockItemsForRead(true); |
1270 | { | 1491 | |
1271 | foreach (TaskInventoryItem item in m_items.Values) | 1492 | foreach (TaskInventoryItem item in m_items.Values) |
1272 | if (item.InvType == (int)type) | 1493 | if (item.InvType == (int)type) |
1273 | ret.Add(item); | 1494 | ret.Add(item); |
1274 | } | 1495 | |
1496 | Items.LockItemsForRead(false); | ||
1275 | 1497 | ||
1276 | return ret; | 1498 | return ret; |
1277 | } | 1499 | } |
1278 | 1500 | ||
1279 | public Dictionary<UUID, string> GetScriptStates() | 1501 | public Dictionary<UUID, string> GetScriptStates() |
1280 | { | 1502 | { |
1503 | return GetScriptStates(false); | ||
1504 | } | ||
1505 | |||
1506 | public Dictionary<UUID, string> GetScriptStates(bool oldIDs) | ||
1507 | { | ||
1281 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); | 1508 | Dictionary<UUID, string> ret = new Dictionary<UUID, string>(); |
1282 | 1509 | ||
1283 | if (m_part.ParentGroup.Scene == null) // Group not in a scene | 1510 | if (m_part.ParentGroup.Scene == null) // Group not in a scene |
@@ -1303,14 +1530,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1303 | string n = e.GetXMLState(item.ItemID); | 1530 | string n = e.GetXMLState(item.ItemID); |
1304 | if (n != String.Empty) | 1531 | if (n != String.Empty) |
1305 | { | 1532 | { |
1306 | if (!ret.ContainsKey(item.ItemID)) | 1533 | if (oldIDs) |
1307 | ret[item.ItemID] = n; | 1534 | { |
1535 | if (!ret.ContainsKey(item.OldItemID)) | ||
1536 | ret[item.OldItemID] = n; | ||
1537 | } | ||
1538 | else | ||
1539 | { | ||
1540 | if (!ret.ContainsKey(item.ItemID)) | ||
1541 | ret[item.ItemID] = n; | ||
1542 | } | ||
1308 | break; | 1543 | break; |
1309 | } | 1544 | } |
1310 | } | 1545 | } |
1311 | } | 1546 | } |
1312 | } | 1547 | } |
1313 | |||
1314 | return ret; | 1548 | return ret; |
1315 | } | 1549 | } |
1316 | 1550 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2f19b50..4bccb7d 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -90,7 +90,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
90 | m_scene.EventManager.TriggerScenePresenceUpdated(this); | 90 | m_scene.EventManager.TriggerScenePresenceUpdated(this); |
91 | } | 91 | } |
92 | 92 | ||
93 | public PresenceType PresenceType { get; private set; } | 93 | public bool isNPC { get; private set; } |
94 | |||
95 | private PresenceType m_presenceType; | ||
96 | public PresenceType PresenceType { | ||
97 | get {return m_presenceType;} | ||
98 | private set | ||
99 | { | ||
100 | m_presenceType = value; | ||
101 | isNPC = (m_presenceType == PresenceType.Npc); | ||
102 | } | ||
103 | } | ||
94 | 104 | ||
95 | private ScenePresenceStateMachine m_stateMachine; | 105 | private ScenePresenceStateMachine m_stateMachine; |
96 | 106 | ||
@@ -142,13 +152,100 @@ namespace OpenSim.Region.Framework.Scenes | |||
142 | /// </summary> | 152 | /// </summary> |
143 | public static readonly float SIGNIFICANT_MOVEMENT = 2.0f; | 153 | public static readonly float SIGNIFICANT_MOVEMENT = 2.0f; |
144 | 154 | ||
145 | public UUID currentParcelUUID = UUID.Zero; | 155 | private UUID m_previusParcelUUID = UUID.Zero; |
156 | private UUID m_currentParcelUUID = UUID.Zero; | ||
157 | private bool m_previusParcelHide = false; | ||
158 | private bool m_currentParcelHide = false; | ||
159 | private object parcelLock = new Object(); | ||
160 | |||
161 | public UUID currentParcelUUID | ||
162 | { | ||
163 | get { return m_currentParcelUUID; } | ||
164 | set | ||
165 | { | ||
166 | lock (parcelLock) | ||
167 | { | ||
168 | bool oldhide = m_currentParcelHide; | ||
169 | bool checksame = true; | ||
170 | if (value != m_currentParcelUUID) | ||
171 | { | ||
172 | m_previusParcelHide = m_currentParcelHide; | ||
173 | m_previusParcelUUID = m_currentParcelUUID; | ||
174 | checksame = false; | ||
175 | } | ||
176 | m_currentParcelUUID = value; | ||
177 | m_currentParcelHide = false; | ||
178 | |||
179 | ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); | ||
180 | if (land != null && !land.LandData.SeeAVs) | ||
181 | m_currentParcelHide = true; | ||
182 | |||
183 | if (m_previusParcelUUID != UUID.Zero || checksame) | ||
184 | ParcelCrossCheck(m_currentParcelUUID,m_previusParcelUUID,m_currentParcelHide, m_previusParcelHide, oldhide,checksame); | ||
185 | } | ||
186 | } | ||
187 | } | ||
188 | |||
189 | public void sitSOGmoved() | ||
190 | { | ||
191 | if (IsDeleted || !IsSatOnObject) | ||
192 | //what me? nahh | ||
193 | return; | ||
194 | if (IsInTransit) | ||
195 | return; | ||
196 | |||
197 | ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); | ||
198 | if (land == null) | ||
199 | return; //?? | ||
200 | UUID parcelID = land.LandData.GlobalID; | ||
201 | if (m_currentParcelUUID != parcelID) | ||
202 | currentParcelUUID = parcelID; | ||
203 | } | ||
204 | |||
205 | |||
206 | public bool ParcelAllowThisAvatarSounds | ||
207 | { | ||
208 | get | ||
209 | { | ||
210 | try | ||
211 | { | ||
212 | lock (parcelLock) | ||
213 | { | ||
214 | ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X, AbsolutePosition.Y); | ||
215 | if (land == null) | ||
216 | return true; | ||
217 | if (land.LandData.AnyAVSounds) | ||
218 | return true; | ||
219 | if (!land.LandData.GroupAVSounds) | ||
220 | return false; | ||
221 | return land.LandData.GroupID == ControllingClient.ActiveGroupId; | ||
222 | } | ||
223 | } | ||
224 | catch | ||
225 | { | ||
226 | return true; | ||
227 | } | ||
228 | } | ||
229 | } | ||
146 | 230 | ||
231 | public bool ParcelHideThisAvatar | ||
232 | { | ||
233 | get | ||
234 | { | ||
235 | return m_currentParcelHide; | ||
236 | } | ||
237 | } | ||
238 | |||
147 | /// <value> | 239 | /// <value> |
148 | /// The animator for this avatar | 240 | /// The animator for this avatar |
149 | /// </value> | 241 | /// </value> |
150 | public ScenePresenceAnimator Animator { get; private set; } | 242 | public ScenePresenceAnimator Animator { get; private set; } |
151 | 243 | ||
244 | /// <value> | ||
245 | /// Server Side Animation Override | ||
246 | /// </value> | ||
247 | public MovementAnimationOverrides Overrides { get; private set; } | ||
248 | public String sitAnimation = "SIT"; | ||
152 | /// <summary> | 249 | /// <summary> |
153 | /// Attachments recorded on this avatar. | 250 | /// Attachments recorded on this avatar. |
154 | /// </summary> | 251 | /// </summary> |
@@ -192,14 +289,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
192 | set { PhysicsActor.Flying = value; } | 289 | set { PhysicsActor.Flying = value; } |
193 | } | 290 | } |
194 | 291 | ||
195 | // add for fly velocity control | 292 | public bool IsColliding |
196 | private bool FlyingOld {get; set;} | ||
197 | public bool WasFlying | ||
198 | { | ||
199 | get; private set; | ||
200 | } | ||
201 | |||
202 | public bool IsColliding | ||
203 | { | 293 | { |
204 | get { return PhysicsActor != null && PhysicsActor.IsColliding; } | 294 | get { return PhysicsActor != null && PhysicsActor.IsColliding; } |
205 | // We would expect setting IsColliding to be private but it's used by a hack in Scene | 295 | // We would expect setting IsColliding to be private but it's used by a hack in Scene |
@@ -247,7 +337,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
247 | 337 | ||
248 | protected ulong crossingFromRegion; | 338 | protected ulong crossingFromRegion; |
249 | 339 | ||
250 | private readonly Vector3[] Dir_Vectors = new Vector3[11]; | 340 | private readonly Vector3[] Dir_Vectors = new Vector3[12]; |
251 | 341 | ||
252 | protected Timer m_reprioritization_timer; | 342 | protected Timer m_reprioritization_timer; |
253 | protected bool m_reprioritizing; | 343 | protected bool m_reprioritizing; |
@@ -303,7 +393,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
303 | /// <summary> | 393 | /// <summary> |
304 | /// Implemented Control Flags | 394 | /// Implemented Control Flags |
305 | /// </summary> | 395 | /// </summary> |
306 | private enum Dir_ControlFlags | 396 | private enum Dir_ControlFlags:uint |
307 | { | 397 | { |
308 | DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, | 398 | DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, |
309 | DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, | 399 | DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, |
@@ -315,6 +405,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
315 | DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, | 405 | DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG, |
316 | DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, | 406 | DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS, |
317 | DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, | 407 | DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG, |
408 | DIR_CONTROL_FLAG_UP_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS, | ||
318 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 409 | DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG |
319 | } | 410 | } |
320 | 411 | ||
@@ -413,11 +504,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
413 | } | 504 | } |
414 | 505 | ||
415 | private ulong m_rootRegionHandle; | 506 | private ulong m_rootRegionHandle; |
507 | private Vector3 m_rootRegionPosition = new Vector3(); | ||
416 | 508 | ||
417 | public ulong RegionHandle | 509 | public ulong RegionHandle |
418 | { | 510 | { |
419 | get { return m_rootRegionHandle; } | 511 | get { return m_rootRegionHandle; } |
420 | private set { m_rootRegionHandle = value; } | 512 | private set |
513 | { | ||
514 | m_rootRegionHandle = value; | ||
515 | // position rounded to lower multiple of 256m | ||
516 | m_rootRegionPosition.X = (float)((m_rootRegionHandle >> 32) & 0xffffff00); | ||
517 | m_rootRegionPosition.Y = (float)(m_rootRegionHandle & 0xffffff00); | ||
518 | } | ||
421 | } | 519 | } |
422 | 520 | ||
423 | #region Client Camera | 521 | #region Client Camera |
@@ -449,11 +547,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
449 | get | 547 | get |
450 | { | 548 | { |
451 | Vector3 a = new Vector3(CameraAtAxis.X, CameraAtAxis.Y, 0); | 549 | Vector3 a = new Vector3(CameraAtAxis.X, CameraAtAxis.Y, 0); |
452 | 550 | a.Normalize(); | |
453 | if (a == Vector3.Zero) | 551 | return a; |
454 | return a; | ||
455 | |||
456 | return Util.GetNormalizedVector(a); | ||
457 | } | 552 | } |
458 | } | 553 | } |
459 | #endregion | 554 | #endregion |
@@ -505,6 +600,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
505 | } | 600 | } |
506 | } | 601 | } |
507 | 602 | ||
603 | |||
508 | public byte State { get; set; } | 604 | public byte State { get; set; } |
509 | 605 | ||
510 | private AgentManager.ControlFlags m_AgentControlFlags; | 606 | private AgentManager.ControlFlags m_AgentControlFlags; |
@@ -557,10 +653,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
557 | // in the sim unless the avatar is on a sit target. While | 653 | // in the sim unless the avatar is on a sit target. While |
558 | // on a sit target, m_pos will contain the desired offset | 654 | // on a sit target, m_pos will contain the desired offset |
559 | // without the parent rotation applied. | 655 | // without the parent rotation applied. |
656 | <<<<<<< HEAD | ||
560 | SceneObjectPart sitPart = ParentPart; | 657 | SceneObjectPart sitPart = ParentPart; |
561 | 658 | ||
562 | if (sitPart != null) | 659 | if (sitPart != null) |
563 | return sitPart.ParentGroup.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); | 660 | return sitPart.ParentGroup.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); |
661 | ======= | ||
662 | if (ParentPart != null) | ||
663 | { | ||
664 | SceneObjectPart rootPart = ParentPart.ParentGroup.RootPart; | ||
665 | // if (sitPart != null) | ||
666 | // return sitPart.AbsolutePosition + (m_pos * sitPart.GetWorldRotation()); | ||
667 | if (rootPart != null) | ||
668 | return rootPart.AbsolutePosition + (m_pos * rootPart.GetWorldRotation()); | ||
669 | } | ||
670 | >>>>>>> avn/ubitvar | ||
564 | } | 671 | } |
565 | 672 | ||
566 | return m_pos; | 673 | return m_pos; |
@@ -661,24 +768,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
661 | m_velocity = value; | 768 | m_velocity = value; |
662 | } | 769 | } |
663 | } | 770 | } |
664 | /* | ||
665 | public override Vector3 AngularVelocity | ||
666 | { | ||
667 | get | ||
668 | { | ||
669 | if (PhysicsActor != null) | ||
670 | { | ||
671 | m_rotationalvelocity = PhysicsActor.RotationalVelocity; | ||
672 | |||
673 | // m_log.DebugFormat( | ||
674 | // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", | ||
675 | // m_velocity, Name, Scene.RegionInfo.RegionName); | ||
676 | } | ||
677 | 771 | ||
678 | return m_rotationalvelocity; | ||
679 | } | ||
680 | } | ||
681 | */ | ||
682 | private Quaternion m_bodyRot = Quaternion.Identity; | 772 | private Quaternion m_bodyRot = Quaternion.Identity; |
683 | 773 | ||
684 | /// <summary> | 774 | /// <summary> |
@@ -794,22 +884,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
794 | else | 884 | else |
795 | seeds = new Dictionary<ulong, string>(); | 885 | seeds = new Dictionary<ulong, string>(); |
796 | 886 | ||
887 | /* we can't do this anymore | ||
797 | List<ulong> old = new List<ulong>(); | 888 | List<ulong> old = new List<ulong>(); |
798 | foreach (ulong handle in seeds.Keys) | 889 | foreach (ulong handle in seeds.Keys) |
799 | { | 890 | { |
800 | uint x, y; | 891 | uint x, y; |
801 | Util.RegionHandleToRegionLoc(handle, out x, out y); | 892 | Util.RegionHandleToRegionLoc(handle, out x, out y); |
893 | <<<<<<< HEAD | ||
802 | 894 | ||
803 | if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) | 895 | if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) |
896 | ======= | ||
897 | no information to check this | ||
898 | // if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY,)) | ||
899 | >>>>>>> avn/ubitvar | ||
804 | { | 900 | { |
805 | old.Add(handle); | 901 | old.Add(handle); |
806 | } | 902 | } |
807 | } | 903 | } |
904 | |||
808 | DropOldNeighbours(old); | 905 | DropOldNeighbours(old); |
809 | 906 | ||
810 | if (Scene.CapsModule != null) | 907 | if (Scene.CapsModule != null) |
811 | Scene.CapsModule.SetChildrenSeed(UUID, seeds); | 908 | Scene.CapsModule.SetChildrenSeed(UUID, seeds); |
812 | 909 | */ | |
813 | KnownRegions = seeds; | 910 | KnownRegions = seeds; |
814 | //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); | 911 | //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); |
815 | //DumpKnownRegions(); | 912 | //DumpKnownRegions(); |
@@ -852,13 +949,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
852 | } | 949 | } |
853 | } | 950 | } |
854 | 951 | ||
855 | private float m_speedModifier = 1.0f; | ||
856 | |||
857 | public float SpeedModifier | ||
858 | { | ||
859 | get { return m_speedModifier; } | ||
860 | set { m_speedModifier = value; } | ||
861 | } | ||
862 | 952 | ||
863 | /// <summary> | 953 | /// <summary> |
864 | /// Modifier for agent movement if we get an AGENT_CONTROL_STOP whilst walking or running | 954 | /// Modifier for agent movement if we get an AGENT_CONTROL_STOP whilst walking or running |
@@ -866,7 +956,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
866 | /// <remarks> | 956 | /// <remarks> |
867 | /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers. | 957 | /// AGENT_CONTRL_STOP comes about if user holds down space key on viewers. |
868 | /// </remarks> | 958 | /// </remarks> |
869 | private float AgentControlStopSlowWhilstMoving = 0.5f; | 959 | private const float AgentControlStopSlowVel = 0.2f; |
960 | // velocities | ||
961 | public const float AgentControlNudgeVel = 1.0f; // setting this diferent from normal as no effect currently | ||
962 | public const float AgentControlNormalVel = 1.0f; | ||
963 | |||
964 | // old normal speed was tuned to match sl normal plus Fast modifiers | ||
965 | // so we need to rescale it | ||
966 | private float m_speedModifier = 1.0f; | ||
967 | |||
968 | public float SpeedModifier | ||
969 | { | ||
970 | get { return m_speedModifier; } | ||
971 | set { m_speedModifier = value; } | ||
972 | } | ||
870 | 973 | ||
871 | private bool m_forceFly; | 974 | private bool m_forceFly; |
872 | 975 | ||
@@ -907,6 +1010,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
907 | IsLoggingIn = false; | 1010 | IsLoggingIn = false; |
908 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; | 1011 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; |
909 | Animator = new ScenePresenceAnimator(this); | 1012 | Animator = new ScenePresenceAnimator(this); |
1013 | Overrides = new MovementAnimationOverrides(); | ||
910 | PresenceType = type; | 1014 | PresenceType = type; |
911 | // DrawDistance = world.DefaultDrawDistance; | 1015 | // DrawDistance = world.DefaultDrawDistance; |
912 | DrawDistance = Constants.RegionSize; | 1016 | DrawDistance = Constants.RegionSize; |
@@ -917,7 +1021,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
917 | m_name = String.Format("{0} {1}", Firstname, Lastname); | 1021 | m_name = String.Format("{0} {1}", Firstname, Lastname); |
918 | m_scene = world; | 1022 | m_scene = world; |
919 | m_uuid = client.AgentId; | 1023 | m_uuid = client.AgentId; |
920 | LocalId = m_scene.AllocateLocalId(); | 1024 | LocalId = m_scene.AllocatePresenceLocalId(); |
921 | 1025 | ||
922 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); | 1026 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); |
923 | if (account != null) | 1027 | if (account != null) |
@@ -930,7 +1034,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
930 | 1034 | ||
931 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 1035 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
932 | if (gm != null) | 1036 | if (gm != null) |
933 | Grouptitle = gm.GetGroupTitle(m_uuid); | 1037 | Grouptitle = gm.GetGroupTitle(m_uuid); |
934 | 1038 | ||
935 | m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); | 1039 | m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); |
936 | 1040 | ||
@@ -988,8 +1092,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
988 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 1092 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
989 | ControllingClient.OnStartAnim += HandleStartAnim; | 1093 | ControllingClient.OnStartAnim += HandleStartAnim; |
990 | ControllingClient.OnStopAnim += HandleStopAnim; | 1094 | ControllingClient.OnStopAnim += HandleStopAnim; |
1095 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
991 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 1096 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
992 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 1097 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
1098 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
993 | 1099 | ||
994 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 1100 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
995 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 1101 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -997,6 +1103,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
997 | 1103 | ||
998 | private void SetDirectionVectors() | 1104 | private void SetDirectionVectors() |
999 | { | 1105 | { |
1106 | <<<<<<< HEAD | ||
1000 | Dir_Vectors[0] = Vector3.UnitX; //FORWARD | 1107 | Dir_Vectors[0] = Vector3.UnitX; //FORWARD |
1001 | Dir_Vectors[1] = -Vector3.UnitX; //BACK | 1108 | Dir_Vectors[1] = -Vector3.UnitX; //BACK |
1002 | Dir_Vectors[2] = Vector3.UnitY; //LEFT | 1109 | Dir_Vectors[2] = Vector3.UnitY; //LEFT |
@@ -1010,6 +1117,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
1010 | Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge | 1117 | Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge |
1011 | } | 1118 | } |
1012 | 1119 | ||
1120 | ======= | ||
1121 | Dir_Vectors[0] = new Vector3(AgentControlNormalVel,0,0); //FORWARD | ||
1122 | Dir_Vectors[1] = new Vector3(-AgentControlNormalVel,0,0);; //BACK | ||
1123 | Dir_Vectors[2] = new Vector3(0,AgentControlNormalVel,0); //LEFT | ||
1124 | Dir_Vectors[3] = new Vector3(0,-AgentControlNormalVel,0); //RIGHT | ||
1125 | Dir_Vectors[4] = new Vector3(0,0,AgentControlNormalVel); //UP | ||
1126 | Dir_Vectors[5] = new Vector3(0,0,-AgentControlNormalVel); //DOWN | ||
1127 | Dir_Vectors[6] = new Vector3(AgentControlNudgeVel, 0f, 0f); //FORWARD_NUDGE | ||
1128 | Dir_Vectors[7] = new Vector3(-AgentControlNudgeVel, 0f, 0f); //BACK_NUDGE | ||
1129 | Dir_Vectors[8] = new Vector3(0f, AgentControlNudgeVel, 0f); //LEFT_NUDGE | ||
1130 | Dir_Vectors[9] = new Vector3(0f, -AgentControlNudgeVel, 0f); //RIGHT_NUDGE | ||
1131 | Dir_Vectors[10] = new Vector3(0f, 0f, AgentControlNudgeVel); //UP_Nudge | ||
1132 | Dir_Vectors[11] = new Vector3(0f, 0f, -AgentControlNudgeVel); //DOWN_Nudge | ||
1133 | } | ||
1134 | |||
1135 | /* dont see any use for this | ||
1136 | private Vector3[] GetWalkDirectionVectors() | ||
1137 | { | ||
1138 | Vector3[] vector = new Vector3[12]; | ||
1139 | vector[0] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD | ||
1140 | vector[1] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK | ||
1141 | vector[2] = Vector3.UnitY; //LEFT | ||
1142 | vector[3] = -Vector3.UnitY; //RIGHT | ||
1143 | vector[4] = new Vector3(CameraAtAxis.Z, 0f, CameraUpAxis.Z); //UP | ||
1144 | vector[5] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN | ||
1145 | vector[6] = new Vector3(CameraUpAxis.Z, 0f, -CameraAtAxis.Z); //FORWARD_NUDGE | ||
1146 | vector[7] = new Vector3(-CameraUpAxis.Z, 0f, CameraAtAxis.Z); //BACK_NUDGE | ||
1147 | vector[8] = Vector3.UnitY; //LEFT_NUDGE | ||
1148 | vector[9] = -Vector3.UnitY; //RIGHT_NUDGE | ||
1149 | vector[10] = new Vector3(CameraAtAxis.Z, 0f, CameraUpAxis.Z); //UP_NUDGE | ||
1150 | vector[11] = new Vector3(-CameraAtAxis.Z, 0f, -CameraUpAxis.Z); //DOWN_NUDGE | ||
1151 | return vector; | ||
1152 | } | ||
1153 | */ | ||
1154 | >>>>>>> avn/ubitvar | ||
1013 | #endregion | 1155 | #endregion |
1014 | 1156 | ||
1015 | #region Status Methods | 1157 | #region Status Methods |
@@ -1026,18 +1168,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
1026 | /// This method is on the critical path for transferring an avatar from one region to another. Delay here | 1168 | /// This method is on the critical path for transferring an avatar from one region to another. Delay here |
1027 | /// delays that crossing. | 1169 | /// delays that crossing. |
1028 | /// </remarks> | 1170 | /// </remarks> |
1171 | |||
1172 | |||
1173 | // only in use as part of completemovement | ||
1174 | // other uses need fix | ||
1029 | private bool MakeRootAgent(Vector3 pos, bool isFlying) | 1175 | private bool MakeRootAgent(Vector3 pos, bool isFlying) |
1030 | { | 1176 | { |
1177 | int ts = Util.EnvironmentTickCount(); | ||
1178 | |||
1031 | lock (m_completeMovementLock) | 1179 | lock (m_completeMovementLock) |
1032 | { | 1180 | { |
1033 | if (!IsChildAgent) | 1181 | if (!IsChildAgent) |
1034 | return false; | 1182 | return false; |
1035 | 1183 | ||
1184 | m_log.DebugFormat("[MakeRootAgent] enter lock: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
1036 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); | 1185 | //m_log.DebugFormat("[SCENE]: known regions in {0}: {1}", Scene.RegionInfo.RegionName, KnownChildRegionHandles.Count); |
1037 | 1186 | ||
1038 | // m_log.InfoFormat( | 1187 | // m_log.InfoFormat( |
1039 | // "[SCENE]: Upgrading child to root agent for {0} in {1}", | 1188 | // "[SCENE]: Upgrading child to root agent for {0} in {1}", |
1040 | // Name, m_scene.RegionInfo.RegionName); | 1189 | // Name, m_scene.RegionInfo.RegionName); |
1041 | 1190 | ||
1042 | if (ParentUUID != UUID.Zero) | 1191 | if (ParentUUID != UUID.Zero) |
1043 | { | 1192 | { |
@@ -1046,20 +1195,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
1046 | if (part == null) | 1195 | if (part == null) |
1047 | { | 1196 | { |
1048 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); | 1197 | m_log.ErrorFormat("[SCENE PRESENCE]: Can't find prim {0} to sit on", ParentUUID); |
1198 | ParentID = 0; | ||
1199 | ParentPart = null; | ||
1200 | PrevSitOffset = Vector3.Zero; | ||
1201 | HandleForceReleaseControls(ControllingClient, UUID); // needs testing | ||
1202 | IsLoggingIn = false; | ||
1049 | } | 1203 | } |
1050 | else | 1204 | else |
1051 | { | 1205 | { |
1206 | <<<<<<< HEAD | ||
1052 | part.AddSittingAvatar(this); | 1207 | part.AddSittingAvatar(this); |
1053 | // ParentPosition = part.GetWorldPosition(); | 1208 | // ParentPosition = part.GetWorldPosition(); |
1209 | ======= | ||
1210 | part.ParentGroup.AddAvatar(UUID); | ||
1211 | if (part.SitTargetPosition != Vector3.Zero) | ||
1212 | part.SitTargetAvatar = UUID; | ||
1213 | >>>>>>> avn/ubitvar | ||
1054 | ParentID = part.LocalId; | 1214 | ParentID = part.LocalId; |
1055 | ParentPart = part; | 1215 | ParentPart = part; |
1056 | m_pos = PrevSitOffset; | 1216 | m_pos = PrevSitOffset; |
1057 | // pos = ParentPosition; | ||
1058 | pos = part.GetWorldPosition(); | 1217 | pos = part.GetWorldPosition(); |
1059 | } | 1218 | } |
1060 | ParentUUID = UUID.Zero; | 1219 | ParentUUID = UUID.Zero; |
1061 | |||
1062 | // Animator.TrySetMovementAnimation("SIT"); | ||
1063 | } | 1220 | } |
1064 | else | 1221 | else |
1065 | { | 1222 | { |
@@ -1069,15 +1226,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1069 | IsChildAgent = false; | 1226 | IsChildAgent = false; |
1070 | } | 1227 | } |
1071 | 1228 | ||
1229 | m_log.DebugFormat("[MakeRootAgent] out lock: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
1230 | |||
1072 | // Must reset this here so that a teleport to a region next to an existing region does not keep the flag | 1231 | // Must reset this here so that a teleport to a region next to an existing region does not keep the flag |
1073 | // set and prevent the close of the connection on a subsequent re-teleport. | 1232 | // set and prevent the close of the connection on a subsequent re-teleport. |
1074 | // Should not be needed if we are not trying to tell this region to close | 1233 | // Should not be needed if we are not trying to tell this region to close |
1075 | // DoNotCloseAfterTeleport = false; | 1234 | // DoNotCloseAfterTeleport = false; |
1076 | 1235 | ||
1077 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 1236 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
1078 | if (gm != null) | 1237 | if (gm != null) |
1079 | Grouptitle = gm.GetGroupTitle(m_uuid); | 1238 | Grouptitle = gm.GetGroupTitle(m_uuid); |
1080 | 1239 | ||
1240 | <<<<<<< HEAD | ||
1081 | AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode); | 1241 | AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(ControllingClient.CircuitCode); |
1082 | uint teleportFlags = (aCircuit == null) ? 0 : aCircuit.teleportFlags; | 1242 | uint teleportFlags = (aCircuit == null) ? 0 : aCircuit.teleportFlags; |
1083 | if ((teleportFlags & (uint)TeleportFlags.ViaHGLogin) != 0) | 1243 | if ((teleportFlags & (uint)TeleportFlags.ViaHGLogin) != 0) |
@@ -1088,11 +1248,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1088 | // But we have a trick that can force them to update the name anyway. | 1248 | // But we have a trick that can force them to update the name anyway. |
1089 | ForceViewersUpdateName(); | 1249 | ForceViewersUpdateName(); |
1090 | } | 1250 | } |
1251 | ======= | ||
1252 | m_log.DebugFormat("[MakeRootAgent] Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
1253 | >>>>>>> avn/ubitvar | ||
1091 | 1254 | ||
1092 | RegionHandle = m_scene.RegionInfo.RegionHandle; | 1255 | RegionHandle = m_scene.RegionInfo.RegionHandle; |
1093 | 1256 | ||
1094 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); | 1257 | m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); |
1258 | m_log.DebugFormat("[MakeRootAgent] TriggerSetRootAgentScene: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
1095 | 1259 | ||
1260 | <<<<<<< HEAD | ||
1096 | UUID groupUUID = ControllingClient.ActiveGroupId; | 1261 | UUID groupUUID = ControllingClient.ActiveGroupId; |
1097 | string groupName = string.Empty; | 1262 | string groupName = string.Empty; |
1098 | ulong groupPowers = 0; | 1263 | ulong groupPowers = 0; |
@@ -1145,6 +1310,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1145 | } | 1310 | } |
1146 | */ | 1311 | */ |
1147 | 1312 | ||
1313 | ======= | ||
1314 | |||
1315 | if (ParentID == 0) | ||
1316 | { | ||
1317 | >>>>>>> avn/ubitvar | ||
1148 | CheckAndAdjustLandingPoint(ref pos); | 1318 | CheckAndAdjustLandingPoint(ref pos); |
1149 | 1319 | ||
1150 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 1320 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
@@ -1166,7 +1336,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1166 | 1336 | ||
1167 | if (pos.X < m_scene.RegionInfo.RegionSizeX && pos.Y < m_scene.RegionInfo.RegionSizeY) | 1337 | if (pos.X < m_scene.RegionInfo.RegionSizeX && pos.Y < m_scene.RegionInfo.RegionSizeY) |
1168 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 1338 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
1169 | 1339 | ||
1170 | float newPosZ = posZLimit + localAVHeight / 2; | 1340 | float newPosZ = posZLimit + localAVHeight / 2; |
1171 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 1341 | if (posZLimit >= (pos.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
1172 | { | 1342 | { |
@@ -1190,6 +1360,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1190 | else | 1360 | else |
1191 | { | 1361 | { |
1192 | AddToPhysicalScene(isFlying); | 1362 | AddToPhysicalScene(isFlying); |
1363 | <<<<<<< HEAD | ||
1193 | } | 1364 | } |
1194 | 1365 | ||
1195 | // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a | 1366 | // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a |
@@ -1198,6 +1369,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1198 | // the value to a negative position which does not trigger the border cross. | 1369 | // the value to a negative position which does not trigger the border cross. |
1199 | // This may not be the best location for this. | 1370 | // This may not be the best location for this. |
1200 | CheckForBorderCrossing(); | 1371 | CheckForBorderCrossing(); |
1372 | ======= | ||
1373 | // reset camera to avatar pos | ||
1374 | CameraPosition = pos; | ||
1375 | } | ||
1376 | >>>>>>> avn/ubitvar | ||
1201 | 1377 | ||
1202 | if (ForceFly) | 1378 | if (ForceFly) |
1203 | { | 1379 | { |
@@ -1207,6 +1383,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1207 | { | 1383 | { |
1208 | Flying = false; | 1384 | Flying = false; |
1209 | } | 1385 | } |
1386 | <<<<<<< HEAD | ||
1210 | } | 1387 | } |
1211 | 1388 | ||
1212 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying | 1389 | // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying |
@@ -1239,8 +1416,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1239 | string.Format("Start attachment scripts for {0} in {1}", Name, Scene.Name), | 1416 | string.Format("Start attachment scripts for {0} in {1}", Name, Scene.Name), |
1240 | true); | 1417 | true); |
1241 | } | 1418 | } |
1419 | ======= | ||
1420 | |||
1421 | // XXX: This is to trigger any secondary teleport needed for a megaregion when the user has teleported to a | ||
1422 | // location outside the 'root region' (the south-west 256x256 corner). This is the earlist we can do it | ||
1423 | // since it requires a physics actor to be present. If it is left any later, then physics appears to reset | ||
1424 | // the value to a negative position which does not trigger the border cross. | ||
1425 | // This may not be the best location for this. | ||
1426 | |||
1427 | |||
1428 | // its not | ||
1429 | // CheckForBorderCrossing(); | ||
1430 | >>>>>>> avn/ubitvar | ||
1242 | } | 1431 | } |
1432 | |||
1433 | m_log.DebugFormat("[MakeRootAgent] position and physical: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
1434 | m_scene.SwapRootAgentCount(false); | ||
1243 | 1435 | ||
1436 | <<<<<<< HEAD | ||
1244 | SendAvatarDataToAllClients(); | 1437 | SendAvatarDataToAllClients(); |
1245 | 1438 | ||
1246 | // send the animations of the other presences to me | 1439 | // send the animations of the other presences to me |
@@ -1249,6 +1442,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1249 | if (presence != this) | 1442 | if (presence != this) |
1250 | presence.Animator.SendAnimPackToClient(ControllingClient); | 1443 | presence.Animator.SendAnimPackToClient(ControllingClient); |
1251 | }); | 1444 | }); |
1445 | ======= | ||
1446 | >>>>>>> avn/ubitvar | ||
1252 | 1447 | ||
1253 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will | 1448 | // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will |
1254 | // stall on the border crossing since the existing child agent will still have the last movement | 1449 | // stall on the border crossing since the existing child agent will still have the last movement |
@@ -1256,6 +1451,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1256 | MovementFlag = ForceUpdateMovementFlagValue; | 1451 | MovementFlag = ForceUpdateMovementFlagValue; |
1257 | 1452 | ||
1258 | m_scene.EventManager.TriggerOnMakeRootAgent(this); | 1453 | m_scene.EventManager.TriggerOnMakeRootAgent(this); |
1454 | m_log.DebugFormat("[MakeRootAgent] TriggerOnMakeRootAgent and done: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
1259 | 1455 | ||
1260 | return true; | 1456 | return true; |
1261 | } | 1457 | } |
@@ -1347,11 +1543,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1347 | /// It doesn't get called for a teleport. Reason being, an agent that | 1543 | /// It doesn't get called for a teleport. Reason being, an agent that |
1348 | /// teleports out may not end up anywhere near this region | 1544 | /// teleports out may not end up anywhere near this region |
1349 | /// </remarks> | 1545 | /// </remarks> |
1350 | public void MakeChildAgent() | 1546 | public void MakeChildAgent(ulong newRegionHandle) |
1351 | { | 1547 | { |
1352 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | 1548 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; |
1353 | 1549 | ||
1354 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1}", Name, Scene.RegionInfo.RegionName); | 1550 | RegionHandle = newRegionHandle; |
1551 | |||
1552 | m_log.DebugFormat("[SCENE PRESENCE]: Making {0} a child agent in {1} from root region {2}", | ||
1553 | Name, Scene.RegionInfo.RegionName, newRegionHandle); | ||
1554 | |||
1555 | // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating | ||
1556 | // from the source simulator has completed on a V2 teleport. | ||
1557 | lock (m_originRegionIDAccessLock) | ||
1558 | m_originRegionID = UUID.Zero; | ||
1355 | 1559 | ||
1356 | // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating | 1560 | // Reset the m_originRegionID as it has dual use as a flag to signal that the UpdateAgent() call orignating |
1357 | // from the source simulator has completed on a V2 teleport. | 1561 | // from the source simulator has completed on a V2 teleport. |
@@ -1371,7 +1575,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1371 | else | 1575 | else |
1372 | Animator.ResetAnimations(); | 1576 | Animator.ResetAnimations(); |
1373 | 1577 | ||
1374 | 1578 | ||
1375 | // m_log.DebugFormat( | 1579 | // m_log.DebugFormat( |
1376 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", | 1580 | // "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", |
1377 | // Name, UUID, m_scene.RegionInfo.RegionName); | 1581 | // Name, UUID, m_scene.RegionInfo.RegionName); |
@@ -1385,8 +1589,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1385 | RemoveFromPhysicalScene(); | 1589 | RemoveFromPhysicalScene(); |
1386 | ParentID = 0; // Child agents can't be sitting | 1590 | ParentID = 0; // Child agents can't be sitting |
1387 | 1591 | ||
1592 | // we dont have land information for child | ||
1593 | m_previusParcelHide = false; | ||
1594 | m_previusParcelUUID = UUID.Zero; | ||
1595 | m_currentParcelHide = false; | ||
1596 | m_currentParcelUUID = UUID.Zero; | ||
1388 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into | 1597 | // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into |
1389 | 1598 | ||
1599 | CollisionPlane = Vector4.UnitW; | ||
1600 | |||
1390 | m_scene.EventManager.TriggerOnMakeChildAgent(this); | 1601 | m_scene.EventManager.TriggerOnMakeChildAgent(this); |
1391 | } | 1602 | } |
1392 | 1603 | ||
@@ -1473,6 +1684,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1473 | 1684 | ||
1474 | public void StopFlying() | 1685 | public void StopFlying() |
1475 | { | 1686 | { |
1687 | if (IsInTransit) | ||
1688 | return; | ||
1689 | |||
1476 | Vector3 pos = AbsolutePosition; | 1690 | Vector3 pos = AbsolutePosition; |
1477 | if (Appearance.AvatarHeight != 127.0f) | 1691 | if (Appearance.AvatarHeight != 127.0f) |
1478 | pos += new Vector3(0f, 0f, (Appearance.AvatarHeight / 6f)); | 1692 | pos += new Vector3(0f, 0f, (Appearance.AvatarHeight / 6f)); |
@@ -1492,7 +1706,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1492 | else | 1706 | else |
1493 | CollisionPlane = new Vector4(0, 0, 0, pos.Z - (1.56f / 6f)); | 1707 | CollisionPlane = new Vector4(0, 0, 0, pos.Z - (1.56f / 6f)); |
1494 | 1708 | ||
1495 | ControllingClient.SendAgentTerseUpdate(this); | 1709 | SendAgentTerseUpdate(this); |
1496 | } | 1710 | } |
1497 | 1711 | ||
1498 | /// <summary> | 1712 | /// <summary> |
@@ -1578,15 +1792,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
1578 | // holds the seed cap for the child agent in that region | 1792 | // holds the seed cap for the child agent in that region |
1579 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); | 1793 | private Dictionary<ulong, string> m_knownChildRegions = new Dictionary<ulong, string>(); |
1580 | 1794 | ||
1581 | public void AddNeighbourRegion(ulong regionHandle, string cap) | 1795 | struct spRegionSizeInfo |
1796 | { | ||
1797 | public int sizeX; | ||
1798 | public int sizeY; | ||
1799 | } | ||
1800 | |||
1801 | private Dictionary<ulong, spRegionSizeInfo> m_knownChildRegionsSizeInfo = new Dictionary<ulong, spRegionSizeInfo>(); | ||
1802 | |||
1803 | |||
1804 | public void AddNeighbourRegionSizeInfo(GridRegion region) | ||
1582 | { | 1805 | { |
1583 | lock (m_knownChildRegions) | 1806 | lock (m_knownChildRegions) |
1584 | { | 1807 | { |
1585 | if (!m_knownChildRegions.ContainsKey(regionHandle)) | 1808 | spRegionSizeInfo sizeInfo = new spRegionSizeInfo(); |
1809 | sizeInfo.sizeX = region.RegionSizeX; | ||
1810 | sizeInfo.sizeY = region.RegionSizeY; | ||
1811 | ulong regionHandle = region.RegionHandle; | ||
1812 | |||
1813 | if (!m_knownChildRegionsSizeInfo.ContainsKey(regionHandle)) | ||
1586 | { | 1814 | { |
1587 | uint x, y; | 1815 | m_knownChildRegionsSizeInfo.Add(regionHandle, sizeInfo); |
1588 | Utils.LongToUInts(regionHandle, out x, out y); | 1816 | |
1589 | m_knownChildRegions.Add(regionHandle, cap); | 1817 | } |
1818 | else | ||
1819 | m_knownChildRegionsSizeInfo[regionHandle] = sizeInfo; | ||
1820 | } | ||
1821 | } | ||
1822 | |||
1823 | public void SetNeighbourRegionSizeInfo(List<GridRegion> regionsList) | ||
1824 | { | ||
1825 | lock (m_knownChildRegions) | ||
1826 | { | ||
1827 | m_knownChildRegionsSizeInfo.Clear(); | ||
1828 | foreach (GridRegion region in regionsList) | ||
1829 | { | ||
1830 | spRegionSizeInfo sizeInfo = new spRegionSizeInfo(); | ||
1831 | sizeInfo.sizeX = region.RegionSizeX; | ||
1832 | sizeInfo.sizeY = region.RegionSizeY; | ||
1833 | ulong regionHandle = region.RegionHandle; | ||
1834 | m_knownChildRegionsSizeInfo.Add(regionHandle, sizeInfo); | ||
1590 | } | 1835 | } |
1591 | } | 1836 | } |
1592 | } | 1837 | } |
@@ -1600,6 +1845,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1600 | //if (m_knownChildRegions.ContainsKey(regionHandle)) | 1845 | //if (m_knownChildRegions.ContainsKey(regionHandle)) |
1601 | // m_log.DebugFormat(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count); | 1846 | // m_log.DebugFormat(" !!! removing known region {0} in {1}. Count = {2}", regionHandle, Scene.RegionInfo.RegionName, m_knownChildRegions.Count); |
1602 | m_knownChildRegions.Remove(regionHandle); | 1847 | m_knownChildRegions.Remove(regionHandle); |
1848 | m_knownChildRegionsSizeInfo.Remove(regionHandle); | ||
1603 | } | 1849 | } |
1604 | } | 1850 | } |
1605 | 1851 | ||
@@ -1612,6 +1858,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1612 | } | 1858 | } |
1613 | } | 1859 | } |
1614 | 1860 | ||
1861 | public void DropThisRootRegionFromNeighbours() | ||
1862 | { | ||
1863 | ulong handle = m_scene.RegionInfo.RegionHandle; | ||
1864 | RemoveNeighbourRegion(handle); | ||
1865 | Scene.CapsModule.DropChildSeed(UUID, handle); | ||
1866 | } | ||
1867 | |||
1615 | public Dictionary<ulong, string> KnownRegions | 1868 | public Dictionary<ulong, string> KnownRegions |
1616 | { | 1869 | { |
1617 | get | 1870 | get |
@@ -1662,12 +1915,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1662 | public void SetSize(Vector3 size, float feetoffset) | 1915 | public void SetSize(Vector3 size, float feetoffset) |
1663 | { | 1916 | { |
1664 | if (PhysicsActor != null && !IsChildAgent) | 1917 | if (PhysicsActor != null && !IsChildAgent) |
1918 | <<<<<<< HEAD | ||
1665 | { | 1919 | { |
1666 | // Eventually there will be a physics call that sets avatar size that includes offset info. | 1920 | // Eventually there will be a physics call that sets avatar size that includes offset info. |
1667 | // For the moment, just set the size as passed. | 1921 | // For the moment, just set the size as passed. |
1668 | PhysicsActor.Size = size; | 1922 | PhysicsActor.Size = size; |
1669 | // PhysicsActor.setAvatarSize(size, feetoffset); | 1923 | // PhysicsActor.setAvatarSize(size, feetoffset); |
1670 | } | 1924 | } |
1925 | ======= | ||
1926 | PhysicsActor.setAvatarSize(size, feetoffset); | ||
1927 | |||
1928 | >>>>>>> avn/ubitvar | ||
1671 | } | 1929 | } |
1672 | 1930 | ||
1673 | private bool WaitForUpdateAgent(IClientAPI client) | 1931 | private bool WaitForUpdateAgent(IClientAPI client) |
@@ -1704,12 +1962,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1704 | /// </param> | 1962 | /// </param> |
1705 | public void CompleteMovement(IClientAPI client, bool openChildAgents) | 1963 | public void CompleteMovement(IClientAPI client, bool openChildAgents) |
1706 | { | 1964 | { |
1707 | // DateTime startTime = DateTime.Now; | 1965 | int ts = Util.EnvironmentTickCount(); |
1708 | 1966 | ||
1709 | m_log.InfoFormat( | 1967 | m_log.InfoFormat( |
1710 | "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", | 1968 | "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", |
1711 | client.Name, Scene.Name, AbsolutePosition); | 1969 | client.Name, Scene.Name, AbsolutePosition); |
1970 | |||
1971 | m_inTransit = true; | ||
1712 | 1972 | ||
1973 | <<<<<<< HEAD | ||
1713 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); // Get this ahead of time because IsInTransit modifies 'm_AgentControlFlags' | 1974 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); // Get this ahead of time because IsInTransit modifies 'm_AgentControlFlags' |
1714 | 1975 | ||
1715 | IsInTransit = true; | 1976 | IsInTransit = true; |
@@ -1742,16 +2003,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
1742 | pos.Z = ground + 1.5f; | 2003 | pos.Z = ground + 1.5f; |
1743 | AbsolutePosition = pos; | 2004 | AbsolutePosition = pos; |
1744 | } | 2005 | } |
2006 | ======= | ||
2007 | try | ||
2008 | { | ||
2009 | // Make sure it's not a login agent. We don't want to wait for updates during login | ||
2010 | if (!isNPC && (m_teleportFlags & TeleportFlags.ViaLogin) == 0) | ||
2011 | { | ||
2012 | |||
2013 | // Let's wait until UpdateAgent (called by departing region) is done | ||
2014 | if (!WaitForUpdateAgent(client)) | ||
2015 | // The sending region never sent the UpdateAgent data, we have to refuse | ||
2016 | return; | ||
2017 | } | ||
2018 | |||
2019 | m_log.DebugFormat("[CompleteMovement] WaitForUpdateAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
2020 | |||
2021 | bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | ||
2022 | >>>>>>> avn/ubitvar | ||
1745 | 2023 | ||
1746 | if (!MakeRootAgent(AbsolutePosition, flying)) | 2024 | if (!MakeRootAgent(AbsolutePosition, flying)) |
1747 | { | 2025 | { |
1748 | m_log.DebugFormat( | 2026 | m_log.DebugFormat( |
2027 | <<<<<<< HEAD | ||
1749 | "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root", | 2028 | "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root", |
2029 | ======= | ||
2030 | "[SCENE PRESENCE]: Aborting CompleteMovement call for {0} in {1} as they are already root", | ||
2031 | >>>>>>> avn/ubitvar | ||
1750 | Name, Scene.Name); | 2032 | Name, Scene.Name); |
1751 | 2033 | ||
1752 | return; | 2034 | return; |
1753 | } | 2035 | } |
1754 | 2036 | ||
2037 | <<<<<<< HEAD | ||
1755 | // Tell the client that we're totally ready | 2038 | // Tell the client that we're totally ready |
1756 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); | 2039 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); |
1757 | 2040 | ||
@@ -1832,6 +2115,249 @@ namespace OpenSim.Region.Framework.Scenes | |||
1832 | sog.ScheduleGroupForFullUpdate(); | 2115 | sog.ScheduleGroupForFullUpdate(); |
1833 | } | 2116 | } |
1834 | } | 2117 | } |
2118 | ======= | ||
2119 | m_log.DebugFormat("[CompleteMovement] MakeRootAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
2120 | |||
2121 | Vector3 look = Lookat; | ||
2122 | if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01)) | ||
2123 | { | ||
2124 | look = Velocity; | ||
2125 | look.Z = 0; | ||
2126 | look.Normalize(); | ||
2127 | if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01) ) | ||
2128 | look = new Vector3(0.99f, 0.042f, 0); | ||
2129 | } | ||
2130 | |||
2131 | // start sending terrain patchs | ||
2132 | if (!isNPC) | ||
2133 | Scene.SendLayerData(ControllingClient); | ||
2134 | |||
2135 | if (!IsChildAgent && !isNPC) | ||
2136 | { | ||
2137 | InventoryFolderBase cof = m_scene.InventoryService.GetFolderForType(client.AgentId, (AssetType)46); | ||
2138 | if (cof == null) | ||
2139 | COF = UUID.Zero; | ||
2140 | else | ||
2141 | COF = cof.ID; | ||
2142 | |||
2143 | m_log.DebugFormat("[ScenePresence]: CompleteMovement COF for {0} is {1}", client.AgentId, COF); | ||
2144 | } | ||
2145 | |||
2146 | // Tell the client that we're totally ready | ||
2147 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); | ||
2148 | |||
2149 | m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
2150 | |||
2151 | if (!string.IsNullOrEmpty(m_callbackURI)) | ||
2152 | { | ||
2153 | // We cannot sleep here since this would hold up the inbound packet processing thread, as | ||
2154 | // CompleteMovement() is executed synchronously. However, it might be better to delay the release | ||
2155 | // here until we know for sure that the agent is active in this region. Sending AgentMovementComplete | ||
2156 | // is not enough for Imprudence clients - there appears to be a small delay (<200ms, <500ms) until they regard this | ||
2157 | // region as the current region, meaning that a close sent before then will fail the teleport. | ||
2158 | // System.Threading.Thread.Sleep(2000); | ||
2159 | |||
2160 | m_log.DebugFormat( | ||
2161 | "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}", | ||
2162 | client.Name, client.AgentId, m_callbackURI); | ||
2163 | |||
2164 | UUID originID; | ||
2165 | |||
2166 | lock (m_originRegionIDAccessLock) | ||
2167 | originID = m_originRegionID; | ||
2168 | |||
2169 | Scene.SimulationService.ReleaseAgent(originID, UUID, m_callbackURI); | ||
2170 | m_callbackURI = null; | ||
2171 | } | ||
2172 | // else | ||
2173 | // { | ||
2174 | // m_log.DebugFormat( | ||
2175 | // "[SCENE PRESENCE]: No callback provided on CompleteMovement of {0} {1} to {2}", | ||
2176 | // client.Name, client.AgentId, m_scene.RegionInfo.RegionName); | ||
2177 | // } | ||
2178 | |||
2179 | m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
2180 | |||
2181 | m_previusParcelHide = false; | ||
2182 | m_previusParcelUUID = UUID.Zero; | ||
2183 | m_currentParcelHide = false; | ||
2184 | m_currentParcelUUID = UUID.Zero; | ||
2185 | |||
2186 | // send initial land overlay and parcel | ||
2187 | ILandChannel landch = m_scene.LandChannel; | ||
2188 | if (landch != null) | ||
2189 | landch.sendClientInitialLandInfo(client); | ||
2190 | |||
2191 | if (!IsChildAgent) | ||
2192 | { | ||
2193 | |||
2194 | // ValidateAndSendAppearanceAndAgentData(); | ||
2195 | |||
2196 | // do it here in line | ||
2197 | // so sequence is clear | ||
2198 | |||
2199 | // verify baked textures and cache | ||
2200 | >>>>>>> avn/ubitvar | ||
2201 | |||
2202 | |||
2203 | bool cachedbaked = false; | ||
2204 | |||
2205 | if (isNPC) | ||
2206 | cachedbaked = true; | ||
2207 | else | ||
2208 | { | ||
2209 | if (m_scene.AvatarFactory != null) | ||
2210 | cachedbaked = m_scene.AvatarFactory.ValidateBakedTextureCache(this); | ||
2211 | |||
2212 | // not sure we need this | ||
2213 | if (!cachedbaked) | ||
2214 | { | ||
2215 | if (m_scene.AvatarFactory != null) | ||
2216 | m_scene.AvatarFactory.QueueAppearanceSave(UUID); | ||
2217 | } | ||
2218 | } | ||
2219 | |||
2220 | List<ScenePresence> allpresences = m_scene.GetScenePresences(); | ||
2221 | |||
2222 | // send avatar object to all presences including us, so they cross it into region | ||
2223 | // then hide if necessary | ||
2224 | SendInitialAvatarDataToAllAgents(allpresences); | ||
2225 | |||
2226 | // send this look | ||
2227 | SendAppearanceToAgent(this); | ||
2228 | |||
2229 | // send this animations | ||
2230 | |||
2231 | UUID[] animIDs = null; | ||
2232 | int[] animseqs = null; | ||
2233 | UUID[] animsobjs = null; | ||
2234 | |||
2235 | if (Animator != null) | ||
2236 | Animator.GetArrays(out animIDs, out animseqs, out animsobjs); | ||
2237 | |||
2238 | bool haveAnims = (animIDs != null && animseqs != null && animsobjs != null); | ||
2239 | |||
2240 | if (haveAnims) | ||
2241 | SendAnimPackToAgent(this, animIDs, animseqs, animsobjs); | ||
2242 | |||
2243 | // we should be able to receive updates, etc | ||
2244 | // so release them | ||
2245 | m_inTransit = false; | ||
2246 | |||
2247 | // send look and animations to others | ||
2248 | // if not cached we send greys | ||
2249 | // uncomented if will wait till avatar does baking | ||
2250 | //if (cachedbaked) | ||
2251 | { | ||
2252 | foreach (ScenePresence p in allpresences) | ||
2253 | { | ||
2254 | if (p == this) | ||
2255 | continue; | ||
2256 | |||
2257 | if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
2258 | continue; | ||
2259 | |||
2260 | SendAppearanceToAgentNF(p); | ||
2261 | if (haveAnims) | ||
2262 | SendAnimPackToAgentNF(p, animIDs, animseqs, animsobjs); | ||
2263 | } | ||
2264 | } // greys if | ||
2265 | |||
2266 | m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
2267 | |||
2268 | // attachments | ||
2269 | |||
2270 | if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) | ||
2271 | { | ||
2272 | if (Scene.AttachmentsModule != null) | ||
2273 | // Util.FireAndForget( | ||
2274 | // o => | ||
2275 | // { | ||
2276 | if (!isNPC) | ||
2277 | Scene.AttachmentsModule.RezAttachments(this); | ||
2278 | else | ||
2279 | Util.FireAndForget(x => | ||
2280 | { | ||
2281 | Scene.AttachmentsModule.RezAttachments(this); | ||
2282 | }); | ||
2283 | // }); | ||
2284 | } | ||
2285 | else | ||
2286 | { | ||
2287 | if (m_attachments.Count > 0) | ||
2288 | { | ||
2289 | m_log.DebugFormat( | ||
2290 | "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); | ||
2291 | |||
2292 | foreach (SceneObjectGroup sog in m_attachments) | ||
2293 | { | ||
2294 | sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); | ||
2295 | sog.ResumeScripts(); | ||
2296 | } | ||
2297 | |||
2298 | foreach (ScenePresence p in allpresences) | ||
2299 | { | ||
2300 | if (p == this) | ||
2301 | { | ||
2302 | SendTerseUpdateToAgentNF(this); | ||
2303 | SendAttachmentsToAgentNF(this); | ||
2304 | continue; | ||
2305 | } | ||
2306 | |||
2307 | if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
2308 | continue; | ||
2309 | |||
2310 | SendTerseUpdateToAgentNF(p); | ||
2311 | SendAttachmentsToAgentNF(p); | ||
2312 | } | ||
2313 | } | ||
2314 | } | ||
2315 | |||
2316 | m_log.DebugFormat("[CompleteMovement] attachments: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
2317 | if (openChildAgents) | ||
2318 | { | ||
2319 | // Create child agents in neighbouring regions | ||
2320 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | ||
2321 | if (m_agentTransfer != null) | ||
2322 | { | ||
2323 | m_agentTransfer.EnableChildAgents(this); | ||
2324 | } | ||
2325 | } | ||
2326 | } | ||
2327 | |||
2328 | m_log.DebugFormat("[CompleteMovement] openChildAgents: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
2329 | |||
2330 | // send the rest of the world | ||
2331 | if (m_teleportFlags > 0 && !isNPC || m_currentParcelHide) | ||
2332 | SendInitialDataToMe(); | ||
2333 | |||
2334 | m_log.DebugFormat("[CompleteMovement] SendInitialDataToMe: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
2335 | |||
2336 | if (!IsChildAgent && openChildAgents) | ||
2337 | { | ||
2338 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | ||
2339 | if (friendsModule != null) | ||
2340 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | ||
2341 | |||
2342 | m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
2343 | |||
2344 | } | ||
2345 | } | ||
2346 | finally | ||
2347 | { | ||
2348 | m_inTransit = false; | ||
2349 | } | ||
2350 | // if hide force a check | ||
2351 | // if (!IsChildAgent && newhide) | ||
2352 | // { | ||
2353 | // ParcelLoginCheck(m_currentParcelUUID); | ||
2354 | // m_currentParcelHide = newhide; | ||
2355 | // } | ||
2356 | |||
2357 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | ||
2358 | |||
2359 | m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
2360 | } | ||
1835 | 2361 | ||
1836 | /// <summary> | 2362 | /// <summary> |
1837 | /// Callback for the Camera view block check. Gets called with the results of the camera view block test | 2363 | /// Callback for the Camera view block check. Gets called with the results of the camera view block test |
@@ -1921,6 +2447,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1921 | return; | 2447 | return; |
1922 | } | 2448 | } |
1923 | 2449 | ||
2450 | if (IsInTransit) | ||
2451 | return; | ||
2452 | |||
1924 | #region Sanity Checking | 2453 | #region Sanity Checking |
1925 | 2454 | ||
1926 | // This is irritating. Really. | 2455 | // This is irritating. Really. |
@@ -1955,8 +2484,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1955 | // When we get to the point of re-computing neighbors everytime this | 2484 | // When we get to the point of re-computing neighbors everytime this |
1956 | // changes, then start using the agent's drawdistance rather than the | 2485 | // changes, then start using the agent's drawdistance rather than the |
1957 | // region's draw distance. | 2486 | // region's draw distance. |
2487 | <<<<<<< HEAD | ||
1958 | DrawDistance = agentData.Far; | 2488 | DrawDistance = agentData.Far; |
1959 | // DrawDistance = Scene.DefaultDrawDistance; | 2489 | // DrawDistance = Scene.DefaultDrawDistance; |
2490 | ======= | ||
2491 | |||
2492 | DrawDistance = Util.Clamp(agentData.Far, 32, m_scene.MaxDrawDistance); | ||
2493 | |||
2494 | // DrawDistance = Scene.DefaultDrawDistance; | ||
2495 | >>>>>>> avn/ubitvar | ||
1960 | 2496 | ||
1961 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | 2497 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; |
1962 | 2498 | ||
@@ -1977,6 +2513,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1977 | // (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) | 2513 | // (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) |
1978 | // m_updateCount = UPDATE_COUNT; | 2514 | // m_updateCount = UPDATE_COUNT; |
1979 | 2515 | ||
2516 | |||
1980 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) | 2517 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) |
1981 | { | 2518 | { |
1982 | StandUp(); | 2519 | StandUp(); |
@@ -2032,7 +2569,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2032 | 2569 | ||
2033 | // We need to send this back to the client in order to stop the edit beams | 2570 | // We need to send this back to the client in order to stop the edit beams |
2034 | if ((oldState & (uint)AgentState.Editing) != 0 && State == (uint)AgentState.None) | 2571 | if ((oldState & (uint)AgentState.Editing) != 0 && State == (uint)AgentState.None) |
2035 | ControllingClient.SendAgentTerseUpdate(this); | 2572 | SendAgentTerseUpdate(this); |
2036 | 2573 | ||
2037 | PhysicsActor actor = PhysicsActor; | 2574 | PhysicsActor actor = PhysicsActor; |
2038 | 2575 | ||
@@ -2045,10 +2582,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2045 | 2582 | ||
2046 | if (AllowMovement && !SitGround) | 2583 | if (AllowMovement && !SitGround) |
2047 | { | 2584 | { |
2048 | // m_log.DebugFormat("[SCENE PRESENCE]: Initial body rotation {0} for {1}", agentData.BodyRotation, Name); | 2585 | // m_log.DebugFormat("[SCENE PRESENCE]: Initial body rotation {0} for {1}", agentData.BodyRotation, Name); |
2049 | |||
2050 | bool update_rotation = false; | 2586 | bool update_rotation = false; |
2051 | |||
2052 | if (agentData.BodyRotation != Rotation) | 2587 | if (agentData.BodyRotation != Rotation) |
2053 | { | 2588 | { |
2054 | Rotation = agentData.BodyRotation; | 2589 | Rotation = agentData.BodyRotation; |
@@ -2075,7 +2610,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2075 | bool DCFlagKeyPressed = false; | 2610 | bool DCFlagKeyPressed = false; |
2076 | Vector3 agent_control_v3 = Vector3.Zero; | 2611 | Vector3 agent_control_v3 = Vector3.Zero; |
2077 | 2612 | ||
2078 | bool newFlying = actor.Flying; | 2613 | bool newFlying = false; |
2079 | 2614 | ||
2080 | if (ForceFly) | 2615 | if (ForceFly) |
2081 | newFlying = true; | 2616 | newFlying = true; |
@@ -2096,6 +2631,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2096 | { | 2631 | { |
2097 | bool bAllowUpdateMoveToPosition = false; | 2632 | bool bAllowUpdateMoveToPosition = false; |
2098 | 2633 | ||
2634 | <<<<<<< HEAD | ||
2635 | ======= | ||
2636 | Vector3[] dirVectors; | ||
2637 | |||
2638 | // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying | ||
2639 | // this prevents 'jumping' in inappropriate situations. | ||
2640 | // if (!Flying && (m_mouseLook || m_leftButtonDown)) | ||
2641 | // dirVectors = GetWalkDirectionVectors(); | ||
2642 | // else | ||
2643 | dirVectors = Dir_Vectors; | ||
2644 | |||
2645 | |||
2646 | >>>>>>> avn/ubitvar | ||
2099 | // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. | 2647 | // A DIR_CONTROL_FLAG occurs when the user is trying to move in a particular direction. |
2100 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | 2648 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) |
2101 | { | 2649 | { |
@@ -2115,10 +2663,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2115 | // Why did I get this? | 2663 | // Why did I get this? |
2116 | } | 2664 | } |
2117 | 2665 | ||
2118 | if (((MovementFlag & (uint)DCF) == 0) & !AgentControlStopActive) | 2666 | if (((MovementFlag & (uint)DCF) == 0)) |
2119 | { | 2667 | { |
2120 | //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); | 2668 | //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); |
2121 | MovementFlag += (uint)DCF; | 2669 | MovementFlag |= (uint)DCF; |
2122 | update_movementflag = true; | 2670 | update_movementflag = true; |
2123 | } | 2671 | } |
2124 | } | 2672 | } |
@@ -2127,7 +2675,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2127 | if ((MovementFlag & (uint)DCF) != 0) | 2675 | if ((MovementFlag & (uint)DCF) != 0) |
2128 | { | 2676 | { |
2129 | //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); | 2677 | //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); |
2130 | MovementFlag -= (uint)DCF; | 2678 | MovementFlag &= (uint)~DCF; |
2131 | update_movementflag = true; | 2679 | update_movementflag = true; |
2132 | 2680 | ||
2133 | /* | 2681 | /* |
@@ -2180,11 +2728,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2180 | if (Flying && !ForceFly) | 2728 | if (Flying && !ForceFly) |
2181 | { | 2729 | { |
2182 | // Need to stop in mid air if user holds down AGENT_CONTROL_STOP | 2730 | // Need to stop in mid air if user holds down AGENT_CONTROL_STOP |
2183 | if (AgentControlStopActive) | 2731 | // if (AgentControlStopActive) |
2184 | { | 2732 | // { |
2185 | agent_control_v3 = Vector3.Zero; | 2733 | // agent_control_v3 = Vector3.Zero; |
2186 | } | 2734 | // } |
2187 | else | 2735 | // else |
2188 | { | 2736 | { |
2189 | // Landing detection code | 2737 | // Landing detection code |
2190 | 2738 | ||
@@ -2192,38 +2740,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
2192 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 2740 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
2193 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 2741 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
2194 | 2742 | ||
2195 | //m_log.Debug("[CONTROL]: " +flags); | 2743 | //m_log.Debug("[CONTROL]: " +flags); |
2196 | // Applies a satisfying roll effect to the avatar when flying. | 2744 | // Applies a satisfying roll effect to the avatar when flying. |
2197 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) | 2745 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0) |
2198 | { | 2746 | { |
2199 | ApplyFlyingRoll( | 2747 | ApplyFlyingRoll( |
2200 | FLY_ROLL_RADIANS_PER_UPDATE, | 2748 | FLY_ROLL_RADIANS_PER_UPDATE, |
2201 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, | 2749 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, |
2202 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); | 2750 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); |
2203 | } | 2751 | } |
2204 | else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 && | 2752 | else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 && |
2205 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) | 2753 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0) |
2206 | { | 2754 | { |
2207 | ApplyFlyingRoll( | 2755 | ApplyFlyingRoll( |
2208 | -FLY_ROLL_RADIANS_PER_UPDATE, | 2756 | -FLY_ROLL_RADIANS_PER_UPDATE, |
2209 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, | 2757 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0, |
2210 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); | 2758 | (flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0); |
2211 | } | 2759 | } |
2212 | else | 2760 | else |
2213 | { | 2761 | { |
2214 | if (m_AngularVelocity.Z != 0) | 2762 | if (m_AngularVelocity.Z != 0) |
2215 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); | 2763 | m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); |
2216 | } | ||
2217 | |||
2218 | if (Flying && IsColliding && controlland) | ||
2219 | { | ||
2220 | // nesting this check because LengthSquared() is expensive and we don't | ||
2221 | // want to do it every step when flying. | ||
2222 | if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) | ||
2223 | StopFlying(); | ||
2224 | } | 2764 | } |
2765 | |||
2766 | /* | ||
2767 | if (Flying && IsColliding && controlland) | ||
2768 | { | ||
2769 | // nesting this check because LengthSquared() is expensive and we don't | ||
2770 | // want to do it every step when flying. | ||
2771 | if ((Velocity.LengthSquared() <= LAND_VELOCITYMAG_MAX)) | ||
2772 | StopFlying(); | ||
2773 | } | ||
2774 | */ | ||
2225 | } | 2775 | } |
2226 | } | 2776 | } |
2777 | else if (IsColliding && agent_control_v3.Z < 0f) | ||
2778 | agent_control_v3.Z = 0; | ||
2779 | // else if(AgentControlStopActive %% Velocity.Z <0.01f) | ||
2780 | |||
2227 | 2781 | ||
2228 | // m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name); | 2782 | // m_log.DebugFormat("[SCENE PRESENCE]: MovementFlag {0} for {1}", MovementFlag, Name); |
2229 | 2783 | ||
@@ -2236,32 +2790,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2236 | if (update_movementflag | 2790 | if (update_movementflag |
2237 | || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0))) | 2791 | || (update_rotation && DCFlagKeyPressed && (!AgentControlStopActive || MovementFlag != 0))) |
2238 | { | 2792 | { |
2239 | // if (update_movementflag || !AgentControlStopActive || MovementFlag != 0) | ||
2240 | // { | ||
2241 | // m_log.DebugFormat( | ||
2242 | // "[SCENE PRESENCE]: In {0} adding velocity of {1} to {2}, umf = {3}, mf = {4}, ur = {5}", | ||
2243 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name, | ||
2244 | // update_movementflag, MovementFlag, update_rotation); | ||
2245 | |||
2246 | float speedModifier; | ||
2247 | 2793 | ||
2248 | if (AgentControlStopActive) | 2794 | if (AgentControlStopActive) |
2249 | speedModifier = AgentControlStopSlowWhilstMoving; | 2795 | { |
2796 | // if (MovementFlag == 0 && Animator.Falling) | ||
2797 | if (MovementFlag == 0 && Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) | ||
2798 | { | ||
2799 | AddNewMovement(agent_control_v3, AgentControlStopSlowVel, true); | ||
2800 | } | ||
2250 | else | 2801 | else |
2251 | speedModifier = 1; | 2802 | AddNewMovement(agent_control_v3, AgentControlStopSlowVel); |
2803 | } | ||
2804 | else | ||
2805 | { | ||
2806 | AddNewMovement(agent_control_v3); | ||
2807 | } | ||
2252 | 2808 | ||
2253 | AddNewMovement(agent_control_v3, speedModifier); | ||
2254 | // } | ||
2255 | } | 2809 | } |
2256 | // else | ||
2257 | // { | ||
2258 | // if (!update_movementflag) | ||
2259 | // { | ||
2260 | // m_log.DebugFormat( | ||
2261 | // "[SCENE PRESENCE]: In {0} ignoring requested update of {1} for {2} as update_movementflag = false", | ||
2262 | // m_scene.RegionInfo.RegionName, agent_control_v3, Name); | ||
2263 | // } | ||
2264 | // } | ||
2265 | 2810 | ||
2266 | if (update_movementflag && ParentID == 0) | 2811 | if (update_movementflag && ParentID == 0) |
2267 | { | 2812 | { |
@@ -2274,7 +2819,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2274 | 2819 | ||
2275 | // We need to send this back to the client in order to see the edit beams | 2820 | // We need to send this back to the client in order to see the edit beams |
2276 | if ((State & (uint)AgentState.Editing) != 0) | 2821 | if ((State & (uint)AgentState.Editing) != 0) |
2277 | ControllingClient.SendAgentTerseUpdate(this); | 2822 | SendAgentTerseUpdate(this); |
2278 | 2823 | ||
2279 | m_scene.EventManager.TriggerOnClientMovement(this); | 2824 | m_scene.EventManager.TriggerOnClientMovement(this); |
2280 | } | 2825 | } |
@@ -2320,8 +2865,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2320 | // When we get to the point of re-computing neighbors everytime this | 2865 | // When we get to the point of re-computing neighbors everytime this |
2321 | // changes, then start using the agent's drawdistance rather than the | 2866 | // changes, then start using the agent's drawdistance rather than the |
2322 | // region's draw distance. | 2867 | // region's draw distance. |
2868 | <<<<<<< HEAD | ||
2323 | DrawDistance = agentData.Far; | 2869 | DrawDistance = agentData.Far; |
2324 | // DrawDistance = Scene.DefaultDrawDistance; | 2870 | // DrawDistance = Scene.DefaultDrawDistance; |
2871 | ======= | ||
2872 | DrawDistance = Util.Clamp(agentData.Far, 32, m_scene.MaxDrawDistance); | ||
2873 | >>>>>>> avn/ubitvar | ||
2325 | 2874 | ||
2326 | // Check if Client has camera in 'follow cam' or 'build' mode. | 2875 | // Check if Client has camera in 'follow cam' or 'build' mode. |
2327 | Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); | 2876 | Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); |
@@ -2358,11 +2907,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2358 | 2907 | ||
2359 | bool updated = false; | 2908 | bool updated = false; |
2360 | 2909 | ||
2910 | Vector3 LocalVectorToTarget3D = MoveToPositionTarget - AbsolutePosition; | ||
2911 | |||
2361 | // m_log.DebugFormat( | 2912 | // m_log.DebugFormat( |
2362 | // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", | 2913 | // "[SCENE PRESENCE]: bAllowUpdateMoveToPosition {0}, m_moveToPositionInProgress {1}, m_autopilotMoving {2}", |
2363 | // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); | 2914 | // allowUpdate, m_moveToPositionInProgress, m_autopilotMoving); |
2364 | 2915 | ||
2365 | double distanceToTarget = Util.GetDistanceTo(AbsolutePosition, MoveToPositionTarget); | 2916 | double distanceToTarget = LocalVectorToTarget3D.Length(); |
2366 | 2917 | ||
2367 | // m_log.DebugFormat( | 2918 | // m_log.DebugFormat( |
2368 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", | 2919 | // "[SCENE PRESENCE]: Abs pos of {0} is {1}, target {2}, distance {3}", |
@@ -2385,11 +2936,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2385 | // Theoretically we might need a more complex PID approach here if other | 2936 | // Theoretically we might need a more complex PID approach here if other |
2386 | // unknown forces are acting on the avatar and we need to adaptively respond | 2937 | // unknown forces are acting on the avatar and we need to adaptively respond |
2387 | // to such forces, but the following simple approach seems to works fine. | 2938 | // to such forces, but the following simple approach seems to works fine. |
2388 | Vector3 LocalVectorToTarget3D = | 2939 | |
2389 | (MoveToPositionTarget - AbsolutePosition) // vector from cur. pos to target in global coords | 2940 | LocalVectorToTarget3D = LocalVectorToTarget3D * Quaternion.Inverse(Rotation); // change to avatar coords |
2390 | * Matrix4.CreateFromQuaternion(Quaternion.Inverse(Rotation)); // change to avatar coords | ||
2391 | // Ignore z component of vector | 2941 | // Ignore z component of vector |
2392 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); | 2942 | // Vector3 LocalVectorToTarget2D = new Vector3((float)(LocalVectorToTarget3D.X), (float)(LocalVectorToTarget3D.Y), 0f); |
2943 | |||
2393 | LocalVectorToTarget3D.Normalize(); | 2944 | LocalVectorToTarget3D.Normalize(); |
2394 | 2945 | ||
2395 | // update avatar movement flags. the avatar coordinate system is as follows: | 2946 | // update avatar movement flags. the avatar coordinate system is as follows: |
@@ -2413,28 +2964,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
2413 | 2964 | ||
2414 | // based on the above avatar coordinate system, classify the movement into | 2965 | // based on the above avatar coordinate system, classify the movement into |
2415 | // one of left/right/back/forward. | 2966 | // one of left/right/back/forward. |
2967 | |||
2968 | const uint noMovFlagsMask = (uint)(~(Dir_ControlFlags.DIR_CONTROL_FLAG_BACK | | ||
2969 | Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD | Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT | | ||
2970 | Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT | Dir_ControlFlags.DIR_CONTROL_FLAG_UP | | ||
2971 | Dir_ControlFlags.DIR_CONTROL_FLAG_DOWN)); | ||
2972 | |||
2973 | MovementFlag &= noMovFlagsMask; | ||
2974 | AgentControlFlags &= noMovFlagsMask; | ||
2975 | |||
2416 | if (LocalVectorToTarget3D.X < 0) //MoveBack | 2976 | if (LocalVectorToTarget3D.X < 0) //MoveBack |
2417 | { | 2977 | { |
2418 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | 2978 | MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; |
2419 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; | 2979 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_BACK; |
2420 | updated = true; | 2980 | updated = true; |
2421 | } | 2981 | } |
2422 | else if (LocalVectorToTarget3D.X > 0) //Move Forward | 2982 | else if (LocalVectorToTarget3D.X > 0) //Move Forward |
2423 | { | 2983 | { |
2424 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | 2984 | MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; |
2425 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; | 2985 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD; |
2426 | updated = true; | 2986 | updated = true; |
2427 | } | 2987 | } |
2428 | 2988 | ||
2429 | if (LocalVectorToTarget3D.Y > 0) //MoveLeft | 2989 | if (LocalVectorToTarget3D.Y > 0) //MoveLeft |
2430 | { | 2990 | { |
2431 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | 2991 | MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; |
2432 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; | 2992 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_LEFT; |
2433 | updated = true; | 2993 | updated = true; |
2434 | } | 2994 | } |
2435 | else if (LocalVectorToTarget3D.Y < 0) //MoveRight | 2995 | else if (LocalVectorToTarget3D.Y < 0) //MoveRight |
2436 | { | 2996 | { |
2437 | MovementFlag += (byte)(uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | 2997 | MovementFlag |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; |
2438 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; | 2998 | AgentControlFlags |= (uint)Dir_ControlFlags.DIR_CONTROL_FLAG_RIGHT; |
2439 | updated = true; | 2999 | updated = true; |
2440 | } | 3000 | } |
@@ -2518,6 +3078,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2518 | // } | 3078 | // } |
2519 | 3079 | ||
2520 | // Get terrain height for sub-region in a megaregion if necessary | 3080 | // Get terrain height for sub-region in a megaregion if necessary |
3081 | <<<<<<< HEAD | ||
3082 | ======= | ||
3083 | int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X); | ||
3084 | int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y); | ||
3085 | GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); | ||
3086 | // If X and Y is NaN, target_region will be null | ||
3087 | if (target_region == null) | ||
3088 | return; | ||
3089 | UUID target_regionID = target_region.RegionID; | ||
3090 | Scene targetScene = m_scene; | ||
3091 | >>>>>>> avn/ubitvar | ||
2521 | 3092 | ||
2522 | //COMMENT: If its only nessesary in a megaregion, why do it on normal region's too? | 3093 | //COMMENT: If its only nessesary in a megaregion, why do it on normal region's too? |
2523 | 3094 | ||
@@ -2527,6 +3098,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2527 | int y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y); | 3098 | int y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y); |
2528 | GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); | 3099 | GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y); |
2529 | 3100 | ||
3101 | <<<<<<< HEAD | ||
2530 | // If X and Y is NaN, target_region will be null | 3102 | // If X and Y is NaN, target_region will be null |
2531 | if (target_region == null) | 3103 | if (target_region == null) |
2532 | return; | 3104 | return; |
@@ -2535,6 +3107,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2535 | } | 3107 | } |
2536 | 3108 | ||
2537 | float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)]; | 3109 | float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)]; |
3110 | ======= | ||
3111 | float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)]; | ||
3112 | // dont try to land underground | ||
3113 | terrainHeight += Appearance.AvatarHeight / 2; | ||
3114 | >>>>>>> avn/ubitvar | ||
2538 | pos.Z = Math.Max(terrainHeight, pos.Z); | 3115 | pos.Z = Math.Max(terrainHeight, pos.Z); |
2539 | 3116 | ||
2540 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is | 3117 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is |
@@ -2543,9 +3120,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2543 | if (pos.Z - terrainHeight < 0.2) | 3120 | if (pos.Z - terrainHeight < 0.2) |
2544 | pos.Z = terrainHeight; | 3121 | pos.Z = terrainHeight; |
2545 | 3122 | ||
3123 | <<<<<<< HEAD | ||
3124 | ======= | ||
3125 | // m_log.DebugFormat( | ||
3126 | // "[SCENE PRESENCE]: Avatar {0} set move to target {1} (terrain height {2}) in {3}", | ||
3127 | // Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); | ||
3128 | |||
3129 | |||
3130 | >>>>>>> avn/ubitvar | ||
2546 | if (noFly) | 3131 | if (noFly) |
2547 | Flying = false; | 3132 | Flying = false; |
2548 | else if (pos.Z > terrainHeight) | 3133 | else if (pos.Z > terrainHeight + Appearance.AvatarHeight / 2 || Flying) |
2549 | Flying = true; | 3134 | Flying = true; |
2550 | 3135 | ||
2551 | // m_log.DebugFormat( | 3136 | // m_log.DebugFormat( |
@@ -2629,29 +3214,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
2629 | } | 3214 | } |
2630 | } | 3215 | } |
2631 | 3216 | ||
3217 | <<<<<<< HEAD | ||
3218 | ======= | ||
3219 | part.ParentGroup.DeleteAvatar(UUID); | ||
3220 | |||
3221 | Quaternion standRotation = part.ParentGroup.RootPart.RotationOffset; | ||
3222 | Vector3 sitPartWorldPosition = part.ParentGroup.AbsolutePosition + m_pos * standRotation; | ||
3223 | >>>>>>> avn/ubitvar | ||
2632 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); | 3224 | ControllingClient.SendClearFollowCamProperties(part.ParentUUID); |
2633 | 3225 | ||
2634 | ParentID = 0; | 3226 | ParentID = 0; |
2635 | ParentPart = null; | 3227 | ParentPart = null; |
2636 | 3228 | ||
2637 | Quaternion standRotation; | ||
2638 | |||
2639 | if (part.SitTargetAvatar == UUID) | 3229 | if (part.SitTargetAvatar == UUID) |
2640 | { | 3230 | standRotation = standRotation * part.SitTargetOrientation; |
2641 | standRotation = part.GetWorldRotation(); | 3231 | else |
3232 | standRotation = standRotation * m_bodyRot; | ||
2642 | 3233 | ||
2643 | if (!part.IsRoot) | 3234 | m_bodyRot = standRotation; |
2644 | standRotation = standRotation * part.SitTargetOrientation; | 3235 | |
2645 | // standRotation = part.RotationOffset * part.SitTargetOrientation; | 3236 | Quaternion standRotationZ = new Quaternion(0,0,standRotation.Z,standRotation.W); |
2646 | // else | ||
2647 | // standRotation = part.SitTargetOrientation; | ||
2648 | 3237 | ||
3238 | float t = standRotationZ.W * standRotationZ.W + standRotationZ.Z * standRotationZ.Z; | ||
3239 | if (t > 0) | ||
3240 | { | ||
3241 | t = 1.0f / (float)Math.Sqrt(t); | ||
3242 | standRotationZ.W *= t; | ||
3243 | standRotationZ.Z *= t; | ||
2649 | } | 3244 | } |
2650 | else | 3245 | else |
2651 | { | 3246 | { |
2652 | standRotation = Rotation; | 3247 | standRotationZ.W = 1.0f; |
3248 | standRotationZ.Z = 0f; | ||
2653 | } | 3249 | } |
2654 | 3250 | ||
3251 | <<<<<<< HEAD | ||
2655 | //Vector3 standPos = ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); | 3252 | //Vector3 standPos = ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); |
2656 | //Vector3 standPos = ParentPosition; | 3253 | //Vector3 standPos = ParentPosition; |
2657 | 3254 | ||
@@ -2664,13 +3261,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2664 | Vector3 adjustmentForSitPose = new Vector3(0.74f, 0f, 0f) * standRotation; | 3261 | Vector3 adjustmentForSitPose = new Vector3(0.74f, 0f, 0f) * standRotation; |
2665 | 3262 | ||
2666 | Vector3 standPos = part.ParentGroup.AbsolutePosition + adjustmentForSitPosition + adjustmentForSitPose; | 3263 | Vector3 standPos = part.ParentGroup.AbsolutePosition + adjustmentForSitPosition + adjustmentForSitPose; |
3264 | ======= | ||
3265 | Vector3 adjustmentForSitPose = new Vector3(0.75f, 0, m_sitAvatarHeight + .3f) * standRotationZ; | ||
2667 | 3266 | ||
2668 | // m_log.DebugFormat( | 3267 | Vector3 standPos = sitPartWorldPosition + adjustmentForSitPose; |
2669 | // "[SCENE PRESENCE]: Setting stand to pos {0}, (adjustmentForSitPosition {1}, adjustmentForSitPose {2}) rotation {3} for {4} in {5}", | 3268 | >>>>>>> avn/ubitvar |
2670 | // standPos, adjustmentForSitPosition, adjustmentForSitPose, standRotation, Name, Scene.Name); | ||
2671 | 3269 | ||
2672 | Rotation = standRotation; | 3270 | m_pos = standPos; |
2673 | AbsolutePosition = standPos; | ||
2674 | } | 3271 | } |
2675 | 3272 | ||
2676 | // We need to wait until we have calculated proper stand positions before sitting up the physical | 3273 | // We need to wait until we have calculated proper stand positions before sitting up the physical |
@@ -2680,18 +3277,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
2680 | 3277 | ||
2681 | if (satOnObject) | 3278 | if (satOnObject) |
2682 | { | 3279 | { |
3280 | <<<<<<< HEAD | ||
2683 | SendAvatarDataToAllClients(); | 3281 | SendAvatarDataToAllClients(); |
2684 | m_requestedSitTargetID = 0; | 3282 | m_requestedSitTargetID = 0; |
2685 | 3283 | ||
2686 | part.RemoveSittingAvatar(this); | 3284 | part.RemoveSittingAvatar(this); |
2687 | 3285 | ||
3286 | ======= | ||
3287 | m_requestedSitTargetID = 0; | ||
3288 | part.RemoveSittingAvatar(UUID); | ||
3289 | >>>>>>> avn/ubitvar | ||
2688 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 3290 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
3291 | |||
3292 | SendAvatarDataToAllAgents(); | ||
2689 | } | 3293 | } |
2690 | 3294 | ||
2691 | else if (PhysicsActor == null) | 3295 | // reset to default sitAnimation |
2692 | AddToPhysicalScene(false); | 3296 | sitAnimation = "SIT"; |
3297 | |||
3298 | // Animator.TrySetMovementAnimation("STAND"); | ||
3299 | Animator.SetMovementAnimations("STAND"); | ||
2693 | 3300 | ||
2694 | Animator.TrySetMovementAnimation("STAND"); | ||
2695 | TriggerScenePresenceUpdated(); | 3301 | TriggerScenePresenceUpdated(); |
2696 | } | 3302 | } |
2697 | 3303 | ||
@@ -2739,6 +3345,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2739 | if (part == null) | 3345 | if (part == null) |
2740 | return; | 3346 | return; |
2741 | 3347 | ||
3348 | |||
2742 | if (PhysicsActor != null) | 3349 | if (PhysicsActor != null) |
2743 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; | 3350 | m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; |
2744 | 3351 | ||
@@ -2746,23 +3353,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2746 | 3353 | ||
2747 | if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) | 3354 | if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) |
2748 | { | 3355 | { |
2749 | // m_log.DebugFormat( | ||
2750 | // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is set and unoccupied", | ||
2751 | // Name, part.Name, part.LocalId); | ||
2752 | |||
2753 | offset = part.SitTargetPosition; | 3356 | offset = part.SitTargetPosition; |
2754 | sitOrientation = part.SitTargetOrientation; | 3357 | sitOrientation = part.SitTargetOrientation; |
2755 | 3358 | ||
2756 | if (!part.IsRoot) | ||
2757 | { | ||
2758 | // m_log.DebugFormat("Old sit orient {0}", sitOrientation); | ||
2759 | sitOrientation = part.RotationOffset * sitOrientation; | ||
2760 | // m_log.DebugFormat("New sit orient {0}", sitOrientation); | ||
2761 | // m_log.DebugFormat("Old sit offset {0}", offset); | ||
2762 | offset = offset * part.RotationOffset; | ||
2763 | // m_log.DebugFormat("New sit offset {0}", offset); | ||
2764 | } | ||
2765 | |||
2766 | canSit = true; | 3359 | canSit = true; |
2767 | } | 3360 | } |
2768 | else | 3361 | else |
@@ -2826,9 +3419,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
2826 | 3419 | ||
2827 | forceMouselook = part.GetForceMouselook(); | 3420 | forceMouselook = part.GetForceMouselook(); |
2828 | 3421 | ||
2829 | // An viewer expects to specify sit positions as offsets to the root prim, even if a child prim is | 3422 | if (!part.IsRoot) |
2830 | // being sat upon. | 3423 | { |
2831 | offset += part.OffsetPosition; | 3424 | sitOrientation = part.RotationOffset * sitOrientation; |
3425 | offset = offset * part.RotationOffset; | ||
3426 | offset += part.OffsetPosition; | ||
3427 | |||
3428 | if (CameraAtAxis == Vector3.Zero && cameraEyeOffset == Vector3.Zero) | ||
3429 | { | ||
3430 | CameraAtAxis = part.ParentGroup.RootPart.GetCameraAtOffset(); | ||
3431 | cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset(); | ||
3432 | } | ||
3433 | else | ||
3434 | { | ||
3435 | cameraAtOffset = cameraAtOffset * part.RotationOffset; | ||
3436 | cameraAtOffset += part.OffsetPosition; | ||
3437 | cameraEyeOffset = cameraEyeOffset * part.RotationOffset; | ||
3438 | cameraEyeOffset += part.OffsetPosition; | ||
3439 | } | ||
3440 | } | ||
3441 | |||
2832 | 3442 | ||
2833 | ControllingClient.SendSitResponse( | 3443 | ControllingClient.SendSitResponse( |
2834 | part.ParentGroup.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 3444 | part.ParentGroup.UUID, offset, sitOrientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); |
@@ -2875,9 +3485,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2875 | // returns false if does not suport so older sit can be tried | 3485 | // returns false if does not suport so older sit can be tried |
2876 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) | 3486 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) |
2877 | { | 3487 | { |
2878 | // TODO: Pull in these bits | ||
2879 | return false; | ||
2880 | /* | ||
2881 | if (part == null || part.ParentGroup.IsAttachment) | 3488 | if (part == null || part.ParentGroup.IsAttachment) |
2882 | { | 3489 | { |
2883 | return true; | 3490 | return true; |
@@ -2907,7 +3514,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2907 | return true; | 3514 | return true; |
2908 | 3515 | ||
2909 | return false; | 3516 | return false; |
2910 | */ | ||
2911 | } | 3517 | } |
2912 | 3518 | ||
2913 | 3519 | ||
@@ -2952,6 +3558,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2952 | ResetMoveToTarget(); | 3558 | ResetMoveToTarget(); |
2953 | 3559 | ||
2954 | Velocity = Vector3.Zero; | 3560 | Velocity = Vector3.Zero; |
3561 | m_AngularVelocity = Vector3.Zero; | ||
2955 | 3562 | ||
2956 | part.AddSittingAvatar(this); | 3563 | part.AddSittingAvatar(this); |
2957 | 3564 | ||
@@ -2959,23 +3566,58 @@ namespace OpenSim.Region.Framework.Scenes | |||
2959 | Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); | 3566 | Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); |
2960 | bool forceMouselook = part.GetForceMouselook(); | 3567 | bool forceMouselook = part.GetForceMouselook(); |
2961 | 3568 | ||
2962 | ControllingClient.SendSitResponse( | 3569 | m_bodyRot = Orientation; |
2963 | part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | 3570 | |
3571 | if (!part.IsRoot) | ||
3572 | { | ||
3573 | Orientation = part.RotationOffset * Orientation; | ||
3574 | offset = offset * part.RotationOffset; | ||
3575 | offset += part.OffsetPosition; | ||
3576 | |||
3577 | if (CameraAtAxis == Vector3.Zero && cameraEyeOffset == Vector3.Zero) | ||
3578 | { | ||
3579 | CameraAtAxis = part.ParentGroup.RootPart.GetCameraAtOffset(); | ||
3580 | cameraEyeOffset = part.ParentGroup.RootPart.GetCameraEyeOffset(); | ||
3581 | } | ||
3582 | else | ||
3583 | { | ||
3584 | cameraAtOffset = cameraAtOffset * part.RotationOffset; | ||
3585 | cameraAtOffset += part.OffsetPosition; | ||
3586 | cameraEyeOffset = cameraEyeOffset * part.RotationOffset; | ||
3587 | cameraEyeOffset += part.OffsetPosition; | ||
3588 | } | ||
2964 | 3589 | ||
2965 | // not using autopilot | 3590 | } |
2966 | 3591 | ||
2967 | Rotation = Orientation; | ||
2968 | m_pos = offset; | 3592 | m_pos = offset; |
2969 | 3593 | ||
3594 | ControllingClient.SendSitResponse( | ||
3595 | part.ParentGroup.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); | ||
3596 | |||
3597 | |||
2970 | m_requestedSitTargetID = 0; | 3598 | m_requestedSitTargetID = 0; |
2971 | 3599 | ||
2972 | ParentPart = part; | 3600 | ParentPart = part; |
2973 | ParentID = part.LocalId; | 3601 | ParentID = part.LocalId; |
3602 | |||
3603 | SendAvatarDataToAllAgents(); | ||
3604 | |||
3605 | /* | ||
2974 | if(status == 3) | 3606 | if(status == 3) |
2975 | Animator.TrySetMovementAnimation("SIT_GROUND"); | 3607 | Animator.TrySetMovementAnimation("SIT_GROUND"); |
2976 | else | 3608 | else |
2977 | Animator.TrySetMovementAnimation("SIT"); | 3609 | Animator.TrySetMovementAnimation("SIT"); |
3610 | <<<<<<< HEAD | ||
2978 | SendAvatarDataToAllClients(); | 3611 | SendAvatarDataToAllClients(); |
3612 | ======= | ||
3613 | */ | ||
3614 | if (status == 3) | ||
3615 | sitAnimation = "SIT_GROUND"; | ||
3616 | else | ||
3617 | sitAnimation = "SIT"; | ||
3618 | |||
3619 | Animator.SetMovementAnimations("SIT"); | ||
3620 | >>>>>>> avn/ubitvar | ||
2979 | 3621 | ||
2980 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); | 3622 | part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); |
2981 | } | 3623 | } |
@@ -3084,13 +3726,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3084 | Velocity = Vector3.Zero; | 3726 | Velocity = Vector3.Zero; |
3085 | RemoveFromPhysicalScene(); | 3727 | RemoveFromPhysicalScene(); |
3086 | 3728 | ||
3087 | String sitAnimation = "SIT"; | 3729 | SendAvatarDataToAllAgents(); |
3730 | |||
3731 | sitAnimation = "SIT"; | ||
3088 | if (!String.IsNullOrEmpty(part.SitAnimation)) | 3732 | if (!String.IsNullOrEmpty(part.SitAnimation)) |
3089 | { | 3733 | { |
3090 | sitAnimation = part.SitAnimation; | 3734 | sitAnimation = part.SitAnimation; |
3091 | } | 3735 | } |
3736 | <<<<<<< HEAD | ||
3092 | Animator.TrySetMovementAnimation(sitAnimation); | 3737 | Animator.TrySetMovementAnimation(sitAnimation); |
3093 | SendAvatarDataToAllClients(); | 3738 | SendAvatarDataToAllClients(); |
3739 | ======= | ||
3740 | // Animator.TrySetMovementAnimation(sitAnimation); | ||
3741 | Animator.SetMovementAnimations("SIT"); | ||
3742 | >>>>>>> avn/ubitvar | ||
3094 | TriggerScenePresenceUpdated(); | 3743 | TriggerScenePresenceUpdated(); |
3095 | } | 3744 | } |
3096 | } | 3745 | } |
@@ -3102,10 +3751,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3102 | 3751 | ||
3103 | // m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.. | 3752 | // m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.. |
3104 | m_AngularVelocity = Vector3.Zero; | 3753 | m_AngularVelocity = Vector3.Zero; |
3105 | Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | 3754 | sitAnimation = "SIT_GROUND_CONSTRAINED"; |
3106 | TriggerScenePresenceUpdated(); | 3755 | // Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); |
3756 | // TriggerScenePresenceUpdated(); | ||
3107 | SitGround = true; | 3757 | SitGround = true; |
3108 | RemoveFromPhysicalScene(); | 3758 | RemoveFromPhysicalScene(); |
3759 | |||
3760 | Animator.SetMovementAnimations("SITGROUND"); | ||
3761 | TriggerScenePresenceUpdated(); | ||
3109 | } | 3762 | } |
3110 | 3763 | ||
3111 | /// <summary> | 3764 | /// <summary> |
@@ -3129,18 +3782,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3129 | TriggerScenePresenceUpdated(); | 3782 | TriggerScenePresenceUpdated(); |
3130 | } | 3783 | } |
3131 | 3784 | ||
3785 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
3786 | { | ||
3787 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
3788 | } | ||
3789 | |||
3790 | |||
3791 | |||
3132 | /// <summary> | 3792 | /// <summary> |
3133 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 3793 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
3134 | /// </summary> | 3794 | /// </summary> |
3135 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> | 3795 | /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> |
3136 | /// <param name="thisAddSpeedModifier"> | 3796 | /// <param name="thisAddSpeedModifier"> |
3137 | /// Optional additional speed modifier for this particular add. Default is 1</param> | 3797 | /// Optional additional speed modifier for this particular add. Default is 1</param> |
3138 | public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1) | 3798 | public void AddNewMovement(Vector3 vec, float thisAddSpeedModifier = 1, bool breaking = false) |
3139 | { | 3799 | { |
3140 | // m_log.DebugFormat( | 3800 | // m_log.DebugFormat( |
3141 | // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", | 3801 | // "[SCENE PRESENCE]: Adding new movement {0} with rotation {1}, thisAddSpeedModifier {2} for {3}", |
3142 | // vec, Rotation, thisAddSpeedModifier, Name); | 3802 | // vec, Rotation, thisAddSpeedModifier, Name); |
3143 | 3803 | ||
3804 | <<<<<<< HEAD | ||
3144 | Quaternion rot = Rotation; | 3805 | Quaternion rot = Rotation; |
3145 | if (!Flying && PresenceType != PresenceType.Npc) | 3806 | if (!Flying && PresenceType != PresenceType.Npc) |
3146 | { | 3807 | { |
@@ -3153,61 +3814,51 @@ namespace OpenSim.Region.Framework.Scenes | |||
3153 | } | 3814 | } |
3154 | 3815 | ||
3155 | Vector3 direc = vec * rot; | 3816 | Vector3 direc = vec * rot; |
3817 | ======= | ||
3818 | // rotate from avatar coord space to world | ||
3819 | // for now all controls assume this is only a rotation around Z | ||
3820 | // if not all checks below need to be done before this rotation | ||
3821 | Vector3 direc = vec * Rotation; | ||
3822 | >>>>>>> avn/ubitvar | ||
3156 | direc.Normalize(); | 3823 | direc.Normalize(); |
3157 | 3824 | ||
3158 | if (Flying != FlyingOld) // add for fly velocity control | 3825 | // mouse look situation ? |
3159 | { | ||
3160 | FlyingOld = Flying; // add for fly velocity control | ||
3161 | if (!Flying) | ||
3162 | WasFlying = true; // add for fly velocity control | ||
3163 | } | ||
3164 | |||
3165 | if (IsColliding) | ||
3166 | WasFlying = false; // add for fly velocity control | ||
3167 | |||
3168 | if ((vec.Z == 0f) && !Flying) | 3826 | if ((vec.Z == 0f) && !Flying) |
3169 | direc.Z = 0f; // Prevent camera WASD up. | 3827 | direc.Z = 0f; // Prevent camera WASD up. |
3170 | 3828 | ||
3829 | // odd rescalings | ||
3171 | direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier; | 3830 | direc *= 0.03f * 128f * SpeedModifier * thisAddSpeedModifier; |
3172 | 3831 | ||
3173 | // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); | 3832 | // m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name); |
3174 | 3833 | ||
3175 | if (PhysicsActor != null) | 3834 | if (Animator.currentControlState == ScenePresenceAnimator.motionControlStates.falling) |
3176 | { | 3835 | { |
3177 | if (Flying) | 3836 | if (breaking) |
3178 | { | 3837 | direc.Z = -9999f; //hack to tell physics to stop on Z |
3838 | else | ||
3839 | direc = Vector3.Zero; | ||
3840 | } | ||
3841 | else if (Flying) | ||
3842 | { | ||
3843 | if (IsColliding && direc.Z < 0) | ||
3844 | // landing situation, prevent avatar moving or it may fail to land | ||
3845 | // animator will handle this condition and do the land | ||
3846 | direc = Vector3.Zero; | ||
3847 | else | ||
3179 | direc *= 4.0f; | 3848 | direc *= 4.0f; |
3180 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 3849 | } |
3181 | //if (controlland) | 3850 | else if (IsColliding) |
3182 | // m_log.Info("[AGENT]: landCommand"); | 3851 | { |
3183 | //if (IsColliding) | 3852 | if (direc.Z > 2.0f) // reinforce jumps |
3184 | // m_log.Info("[AGENT]: colliding"); | ||
3185 | //if (Flying && IsColliding && controlland) | ||
3186 | //{ | ||
3187 | // StopFlying(); | ||
3188 | // m_log.Info("[AGENT]: Stop Flying"); | ||
3189 | //} | ||
3190 | } | ||
3191 | if (Animator.Falling && WasFlying) // if falling from flying, disable motion add | ||
3192 | { | ||
3193 | direc *= 0.0f; | ||
3194 | } | ||
3195 | else if (!Flying && IsColliding) | ||
3196 | { | 3853 | { |
3197 | if (direc.Z > 2.0f) | 3854 | direc.Z *= 2.6f; |
3198 | { | ||
3199 | direc.Z *= 2.6f; | ||
3200 | |||
3201 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | ||
3202 | // Animator.TrySetMovementAnimation("PREJUMP"); | ||
3203 | // Animator.TrySetMovementAnimation("JUMP"); | ||
3204 | } | ||
3205 | } | 3855 | } |
3856 | else if (direc.Z < 0) // on a surface moving down (pg down) only changes animation | ||
3857 | direc.Z = 0; | ||
3206 | } | 3858 | } |
3207 | 3859 | ||
3208 | // m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); | 3860 | // m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name); |
3209 | 3861 | ||
3210 | // TODO: Add the force instead of only setting it to support multiple forces per frame? | ||
3211 | m_forceToApply = direc; | 3862 | m_forceToApply = direc; |
3212 | Animator.UpdateMovementAnimations(); | 3863 | Animator.UpdateMovementAnimations(); |
3213 | } | 3864 | } |
@@ -3220,6 +3871,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3220 | { | 3871 | { |
3221 | if (IsChildAgent == false) | 3872 | if (IsChildAgent == false) |
3222 | { | 3873 | { |
3874 | CheckForBorderCrossing(); | ||
3875 | |||
3876 | if (IsInTransit) | ||
3877 | return; | ||
3878 | |||
3223 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | 3879 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to |
3224 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | 3880 | // grab the latest PhysicsActor velocity, whereas m_velocity is often |
3225 | // storing a requested force instead of an actual traveling velocity | 3881 | // storing a requested force instead of an actual traveling velocity |
@@ -3248,9 +3904,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3248 | m_lastVelocity = Velocity; | 3904 | m_lastVelocity = Velocity; |
3249 | } | 3905 | } |
3250 | 3906 | ||
3907 | <<<<<<< HEAD | ||
3251 | if (Scene.AllowAvatarCrossing) | 3908 | if (Scene.AllowAvatarCrossing) |
3252 | CheckForBorderCrossing(); | 3909 | CheckForBorderCrossing(); |
3253 | 3910 | ||
3911 | ======= | ||
3912 | >>>>>>> avn/ubitvar | ||
3254 | CheckForSignificantMovement(); // sends update to the modules. | 3913 | CheckForSignificantMovement(); // sends update to the modules. |
3255 | } | 3914 | } |
3256 | } | 3915 | } |
@@ -3259,8 +3918,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
3259 | 3918 | ||
3260 | #region Update Client(s) | 3919 | #region Update Client(s) |
3261 | 3920 | ||
3921 | <<<<<<< HEAD | ||
3922 | ======= | ||
3923 | public void SendUpdateToAgent(ScenePresence p) | ||
3924 | { | ||
3925 | IClientAPI remoteClient = p.ControllingClient; | ||
3926 | |||
3927 | if (remoteClient.IsActive) | ||
3928 | { | ||
3929 | //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); | ||
3930 | remoteClient.SendEntityUpdate(this, PrimUpdateFlags.FullUpdate); | ||
3931 | m_scene.StatsReporter.AddAgentUpdates(1); | ||
3932 | } | ||
3933 | } | ||
3934 | |||
3935 | public void SendFullUpdateToClient(IClientAPI remoteClient) | ||
3936 | { | ||
3937 | if (remoteClient.IsActive) | ||
3938 | { | ||
3939 | //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); | ||
3940 | remoteClient.SendEntityUpdate(this, PrimUpdateFlags.FullUpdate); | ||
3941 | m_scene.StatsReporter.AddAgentUpdates(1); | ||
3942 | } | ||
3943 | } | ||
3944 | |||
3945 | // this is diferente from SendTerseUpdateToClient | ||
3946 | // this sends bypassing entities updates | ||
3947 | public void SendAgentTerseUpdate(ISceneEntity p) | ||
3948 | { | ||
3949 | ControllingClient.SendAgentTerseUpdate(p); | ||
3950 | } | ||
3951 | |||
3952 | >>>>>>> avn/ubitvar | ||
3262 | /// <summary> | 3953 | /// <summary> |
3263 | /// Sends a location update to the client connected to this scenePresence | 3954 | /// Sends a location update to the client connected to this scenePresence |
3955 | /// via entity updates | ||
3264 | /// </summary> | 3956 | /// </summary> |
3265 | /// <param name="remoteClient"></param> | 3957 | /// <param name="remoteClient"></param> |
3266 | public void SendTerseUpdateToClient(IClientAPI remoteClient) | 3958 | public void SendTerseUpdateToClient(IClientAPI remoteClient) |
@@ -3293,7 +3985,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3293 | return; | 3985 | return; |
3294 | 3986 | ||
3295 | //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); | 3987 | //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); |
3296 | |||
3297 | remoteClient.SendEntityUpdate( | 3988 | remoteClient.SendEntityUpdate( |
3298 | this, | 3989 | this, |
3299 | PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | 3990 | PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity |
@@ -3303,6 +3994,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
3303 | } | 3994 | } |
3304 | } | 3995 | } |
3305 | 3996 | ||
3997 | public void SendTerseUpdateToAgent(ScenePresence p) | ||
3998 | { | ||
3999 | IClientAPI remoteClient = p.ControllingClient; | ||
4000 | |||
4001 | if (!remoteClient.IsActive) | ||
4002 | return; | ||
4003 | |||
4004 | if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200) | ||
4005 | return; | ||
4006 | |||
4007 | //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); | ||
4008 | remoteClient.SendEntityUpdate( | ||
4009 | this, | ||
4010 | PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
4011 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); | ||
4012 | |||
4013 | m_scene.StatsReporter.AddAgentUpdates(1); | ||
4014 | } | ||
4015 | |||
4016 | public void SendTerseUpdateToAgentNF(ScenePresence p) | ||
4017 | { | ||
4018 | IClientAPI remoteClient = p.ControllingClient; | ||
4019 | if (remoteClient.IsActive) | ||
4020 | { | ||
4021 | //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); | ||
4022 | remoteClient.SendEntityUpdate(this, | ||
4023 | PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
4024 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); | ||
4025 | m_scene.StatsReporter.AddAgentUpdates(1); | ||
4026 | } | ||
4027 | } | ||
4028 | |||
3306 | 4029 | ||
3307 | // vars to support reduced update frequency when velocity is unchanged | 4030 | // vars to support reduced update frequency when velocity is unchanged |
3308 | private Vector3 lastVelocitySentToAllClients = Vector3.Zero; | 4031 | private Vector3 lastVelocitySentToAllClients = Vector3.Zero; |
@@ -3354,7 +4077,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3354 | m_terseUpdateCount++; | 4077 | m_terseUpdateCount++; |
3355 | 4078 | ||
3356 | // Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name); | 4079 | // Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name); |
3357 | m_scene.ForEachClient(SendTerseUpdateToClient); | 4080 | // m_scene.ForEachClient(SendTerseUpdateToClient); |
4081 | m_scene.ForEachScenePresence(SendTerseUpdateToAgent); | ||
3358 | } | 4082 | } |
3359 | TriggerScenePresenceUpdated(); | 4083 | TriggerScenePresenceUpdated(); |
3360 | } | 4084 | } |
@@ -3393,22 +4117,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
3393 | // we created a new ScenePresence (a new child agent) in a fresh region. | 4117 | // we created a new ScenePresence (a new child agent) in a fresh region. |
3394 | // Request info about all the (root) agents in this region | 4118 | // Request info about all the (root) agents in this region |
3395 | // Note: This won't send data *to* other clients in that region (children don't send) | 4119 | // Note: This won't send data *to* other clients in that region (children don't send) |
4120 | <<<<<<< HEAD | ||
3396 | SendOtherAgentsAvatarDataToClient(); | 4121 | SendOtherAgentsAvatarDataToClient(); |
3397 | SendOtherAgentsAppearanceToClient(); | 4122 | SendOtherAgentsAppearanceToClient(); |
4123 | ======= | ||
4124 | if (m_teleportFlags <= 0) | ||
4125 | { | ||
4126 | ILandChannel landch = m_scene.LandChannel; | ||
4127 | if (landch != null) | ||
4128 | { | ||
4129 | landch.sendClientInitialLandInfo(ControllingClient); | ||
4130 | } | ||
4131 | } | ||
4132 | >>>>>>> avn/ubitvar | ||
3398 | 4133 | ||
4134 | SendOtherAgentsAvatarFullToMe(); | ||
3399 | EntityBase[] entities = Scene.Entities.GetEntities(); | 4135 | EntityBase[] entities = Scene.Entities.GetEntities(); |
3400 | foreach (EntityBase e in entities) | 4136 | foreach (EntityBase e in entities) |
3401 | { | 4137 | { |
3402 | if (e != null && e is SceneObjectGroup) | 4138 | if (e != null && e is SceneObjectGroup && !((SceneObjectGroup)e).IsAttachment) |
3403 | ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); | 4139 | ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); |
3404 | } | 4140 | } |
4141 | <<<<<<< HEAD | ||
3405 | }, null, string.Format("SendInitialDataToClient ({0} in {1})", Name, Scene.Name), false, true); | 4142 | }, null, string.Format("SendInitialDataToClient ({0} in {1})", Name, Scene.Name), false, true); |
4143 | ======= | ||
4144 | }); | ||
4145 | >>>>>>> avn/ubitvar | ||
3406 | } | 4146 | } |
3407 | 4147 | ||
3408 | /// <summary> | 4148 | /// <summary> |
3409 | /// Do everything required once a client completes its movement into a region and becomes | 4149 | /// Do everything required once a client completes its movement into a region and becomes |
3410 | /// a root agent. | 4150 | /// a root agent. |
3411 | /// </summary> | 4151 | /// </summary> |
4152 | /// | ||
4153 | /* only called from on place, do done inline there | ||
3412 | private void ValidateAndSendAppearanceAndAgentData() | 4154 | private void ValidateAndSendAppearanceAndAgentData() |
3413 | { | 4155 | { |
3414 | //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID); | 4156 | //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID); |
@@ -3422,14 +4164,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3422 | // to see if all the baked textures are already here. | 4164 | // to see if all the baked textures are already here. |
3423 | if (m_scene.AvatarFactory != null) | 4165 | if (m_scene.AvatarFactory != null) |
3424 | cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(this); | 4166 | cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(this); |
3425 | 4167 | ||
3426 | // If we aren't using a cached appearance, then clear out the baked textures | 4168 | // If we aren't using a cached appearance, then clear out the baked textures |
3427 | if (!cachedappearance) | 4169 | if (!cachedappearance) |
3428 | { | 4170 | { |
3429 | Appearance.ResetAppearance(); | ||
3430 | if (m_scene.AvatarFactory != null) | 4171 | if (m_scene.AvatarFactory != null) |
3431 | m_scene.AvatarFactory.QueueAppearanceSave(UUID); | 4172 | m_scene.AvatarFactory.QueueAppearanceSave(UUID); |
3432 | } | 4173 | } |
4174 | <<<<<<< HEAD | ||
3433 | 4175 | ||
3434 | // This agent just became root. We are going to tell everyone about it. The process of | 4176 | // This agent just became root. We are going to tell everyone about it. The process of |
3435 | // getting other avatars information was initiated elsewhere immediately after the child circuit connected... don't do it | 4177 | // getting other avatars information was initiated elsewhere immediately after the child circuit connected... don't do it |
@@ -3439,17 +4181,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
3439 | 4181 | ||
3440 | // This invocation always shows up in the viewer logs as an error. Is it needed? | 4182 | // This invocation always shows up in the viewer logs as an error. Is it needed? |
3441 | SendAppearanceToClient(this); | 4183 | SendAppearanceToClient(this); |
4184 | ======= | ||
4185 | |||
4186 | // send avatar object to all viewers so they cross it into region | ||
4187 | bool newhide = m_currentParcelHide; | ||
4188 | m_currentParcelHide = false; | ||
4189 | |||
4190 | SendAvatarDataToAllAgents(); | ||
4191 | |||
4192 | // now hide | ||
4193 | if (newhide) | ||
4194 | { | ||
4195 | ParcelLoginCheck(m_currentParcelUUID); | ||
4196 | m_currentParcelHide = true; | ||
4197 | } | ||
4198 | |||
4199 | SendAppearanceToAgent(this); | ||
4200 | >>>>>>> avn/ubitvar | ||
4201 | |||
4202 | m_inTransit = false; | ||
3442 | 4203 | ||
3443 | // If we are using the the cached appearance then send it out to everyone | 4204 | SendAppearanceToAllOtherAgents(); |
3444 | if (cachedappearance) | 4205 | |
4206 | if(Animator!= null) | ||
4207 | Animator.SendAnimPack(); | ||
4208 | } | ||
4209 | */ | ||
4210 | /// <summary> | ||
4211 | /// Send avatar full data appearance and animations for all other root agents to this agent, this agent | ||
4212 | /// can be either a child or root | ||
4213 | /// </summary> | ||
4214 | public void SendOtherAgentsAvatarFullToMe() | ||
4215 | { | ||
4216 | int count = 0; | ||
4217 | m_scene.ForEachRootScenePresence(delegate(ScenePresence p) | ||
3445 | { | 4218 | { |
3446 | m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); | 4219 | // only send information about other root agents |
4220 | if (p.UUID == UUID) | ||
4221 | return; | ||
3447 | 4222 | ||
4223 | <<<<<<< HEAD | ||
3448 | // If the avatars baked textures are all in the cache, then we have a | 4224 | // If the avatars baked textures are all in the cache, then we have a |
3449 | // complete appearance... send it out, if not, then we'll send it when | 4225 | // complete appearance... send it out, if not, then we'll send it when |
3450 | // the avatar finishes updating its appearance | 4226 | // the avatar finishes updating its appearance |
3451 | SendAppearanceToAllOtherClients(); | 4227 | SendAppearanceToAllOtherClients(); |
3452 | } | 4228 | } |
4229 | ======= | ||
4230 | // get the avatar, then a kill if can't see it | ||
4231 | p.SendInitialAvatarDataToAgent(this); | ||
4232 | |||
4233 | if (p.ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && GodLevel < 200) | ||
4234 | return; | ||
4235 | |||
4236 | p.SendAppearanceToAgentNF(this); | ||
4237 | p.SendAnimPackToAgentNF(this); | ||
4238 | p.SendAttachmentsToAgentNF(this); | ||
4239 | count++; | ||
4240 | }); | ||
4241 | |||
4242 | m_scene.StatsReporter.AddAgentUpdates(count); | ||
4243 | >>>>>>> avn/ubitvar | ||
3453 | } | 4244 | } |
3454 | 4245 | ||
3455 | public void SendAvatarDataToAllClients() | 4246 | public void SendAvatarDataToAllClients() |
@@ -3470,32 +4261,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
3470 | m_log.WarnFormat( | 4261 | m_log.WarnFormat( |
3471 | "[SCENE PRESENCE]: Attempt to send avatar data from a child agent for {0} in {1}", | 4262 | "[SCENE PRESENCE]: Attempt to send avatar data from a child agent for {0} in {1}", |
3472 | Name, Scene.RegionInfo.RegionName); | 4263 | Name, Scene.RegionInfo.RegionName); |
3473 | |||
3474 | return; | 4264 | return; |
3475 | } | 4265 | } |
3476 | 4266 | ||
3477 | m_lastSize = Appearance.AvatarSize; | 4267 | m_lastSize = Appearance.AvatarSize; |
3478 | |||
3479 | int count = 0; | 4268 | int count = 0; |
4269 | |||
3480 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 4270 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
3481 | { | 4271 | { |
4272 | <<<<<<< HEAD | ||
3482 | if (full) | 4273 | if (full) |
3483 | SendAvatarDataToClient(scenePresence); | 4274 | SendAvatarDataToClient(scenePresence); |
3484 | else | 4275 | else |
3485 | scenePresence.ControllingClient.SendAvatarDataImmediate(this); | 4276 | scenePresence.ControllingClient.SendAvatarDataImmediate(this); |
4277 | ======= | ||
4278 | SendAvatarDataToAgent(scenePresence); | ||
4279 | >>>>>>> avn/ubitvar | ||
3486 | count++; | 4280 | count++; |
3487 | }); | 4281 | }); |
3488 | 4282 | ||
3489 | m_scene.StatsReporter.AddAgentUpdates(count); | 4283 | m_scene.StatsReporter.AddAgentUpdates(count); |
3490 | } | 4284 | } |
3491 | 4285 | ||
4286 | <<<<<<< HEAD | ||
3492 | /// <summary> | 4287 | /// <summary> |
3493 | /// Send avatar data for all other root agents to this agent, this agent | 4288 | /// Send avatar data for all other root agents to this agent, this agent |
3494 | /// can be either a child or root | 4289 | /// can be either a child or root |
3495 | /// </summary> | 4290 | /// </summary> |
3496 | public void SendOtherAgentsAvatarDataToClient() | 4291 | public void SendOtherAgentsAvatarDataToClient() |
4292 | ======= | ||
4293 | // sends avatar object to all clients so they cross it into region | ||
4294 | // then sends kills to hide | ||
4295 | public void SendInitialAvatarDataToAllAgents(List<ScenePresence> presences) | ||
4296 | >>>>>>> avn/ubitvar | ||
3497 | { | 4297 | { |
4298 | m_lastSize = Appearance.AvatarSize; | ||
3498 | int count = 0; | 4299 | int count = 0; |
4300 | <<<<<<< HEAD | ||
3499 | m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) | 4301 | m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) |
3500 | { | 4302 | { |
3501 | // only send information about other root agents | 4303 | // only send information about other root agents |
@@ -3505,29 +4307,65 @@ namespace OpenSim.Region.Framework.Scenes | |||
3505 | scenePresence.SendAvatarDataToClient(this); | 4307 | scenePresence.SendAvatarDataToClient(this); |
3506 | count++; | 4308 | count++; |
3507 | }); | 4309 | }); |
4310 | ======= | ||
4311 | >>>>>>> avn/ubitvar | ||
3508 | 4312 | ||
4313 | foreach (ScenePresence p in presences) | ||
4314 | { | ||
4315 | p.ControllingClient.SendAvatarDataImmediate(this); | ||
4316 | if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
4317 | // either just kill the object | ||
4318 | // p.ControllingClient.SendKillObject(new List<uint> {LocalId}); | ||
4319 | // or also attachments viewer may still know about | ||
4320 | SendKillTo(p); | ||
4321 | count++; | ||
4322 | } | ||
3509 | m_scene.StatsReporter.AddAgentUpdates(count); | 4323 | m_scene.StatsReporter.AddAgentUpdates(count); |
3510 | } | 4324 | } |
3511 | 4325 | ||
4326 | public void SendInitialAvatarDataToAgent(ScenePresence p) | ||
4327 | { | ||
4328 | p.ControllingClient.SendAvatarDataImmediate(this); | ||
4329 | if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
4330 | // either just kill the object | ||
4331 | // p.ControllingClient.SendKillObject(new List<uint> {LocalId}); | ||
4332 | // or also attachments viewer may still know about | ||
4333 | SendKillTo(p); | ||
4334 | } | ||
4335 | |||
3512 | /// <summary> | 4336 | /// <summary> |
3513 | /// Send avatar data to an agent. | 4337 | /// Send avatar data to an agent. |
3514 | /// </summary> | 4338 | /// </summary> |
3515 | /// <param name="avatar"></param> | 4339 | /// <param name="avatar"></param> |
3516 | public void SendAvatarDataToClient(ScenePresence avatar) | 4340 | public void SendAvatarDataToClient(ScenePresence avatar) |
3517 | { | 4341 | { |
4342 | <<<<<<< HEAD | ||
3518 | //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToClient from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); | 4343 | //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToClient from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); |
3519 | 4344 | ||
4345 | ======= | ||
4346 | //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); | ||
4347 | if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200) | ||
4348 | return; | ||
4349 | >>>>>>> avn/ubitvar | ||
3520 | avatar.ControllingClient.SendAvatarDataImmediate(this); | 4350 | avatar.ControllingClient.SendAvatarDataImmediate(this); |
3521 | Animator.SendAnimPackToClient(avatar.ControllingClient); | ||
3522 | } | 4351 | } |
3523 | 4352 | ||
4353 | public void SendAvatarDataToAgentNF(ScenePresence avatar) | ||
4354 | { | ||
4355 | avatar.ControllingClient.SendAvatarDataImmediate(this); | ||
4356 | } | ||
4357 | |||
3524 | /// <summary> | 4358 | /// <summary> |
3525 | /// Send this agent's appearance to all other root and child agents in the scene | 4359 | /// Send this agent's appearance to all other root and child agents in the scene |
3526 | /// This agent must be root. | 4360 | /// This agent must be root. |
3527 | /// </summary> | 4361 | /// </summary> |
3528 | public void SendAppearanceToAllOtherClients() | 4362 | public void SendAppearanceToAllOtherClients() |
3529 | { | 4363 | { |
4364 | <<<<<<< HEAD | ||
3530 | // m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherClients: {0} {1}", Name, UUID); | 4365 | // m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherClients: {0} {1}", Name, UUID); |
4366 | ======= | ||
4367 | // m_log.DebugFormat("[SCENE PRESENCE] SendAppearanceToAllOtherAgents: {0} {1}", Name, UUID); | ||
4368 | >>>>>>> avn/ubitvar | ||
3531 | 4369 | ||
3532 | // only send update from root agents to other clients; children are only "listening posts" | 4370 | // only send update from root agents to other clients; children are only "listening posts" |
3533 | if (IsChildAgent) | 4371 | if (IsChildAgent) |
@@ -3538,7 +4376,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3538 | 4376 | ||
3539 | return; | 4377 | return; |
3540 | } | 4378 | } |
3541 | 4379 | ||
3542 | int count = 0; | 4380 | int count = 0; |
3543 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) | 4381 | m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) |
3544 | { | 4382 | { |
@@ -3549,6 +4387,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3549 | SendAppearanceToClient(scenePresence); | 4387 | SendAppearanceToClient(scenePresence); |
3550 | count++; | 4388 | count++; |
3551 | }); | 4389 | }); |
4390 | <<<<<<< HEAD | ||
3552 | 4391 | ||
3553 | m_scene.StatsReporter.AddAgentUpdates(count); | 4392 | m_scene.StatsReporter.AddAgentUpdates(count); |
3554 | } | 4393 | } |
@@ -3572,6 +4411,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3572 | count++; | 4411 | count++; |
3573 | }); | 4412 | }); |
3574 | 4413 | ||
4414 | ======= | ||
4415 | >>>>>>> avn/ubitvar | ||
3575 | m_scene.StatsReporter.AddAgentUpdates(count); | 4416 | m_scene.StatsReporter.AddAgentUpdates(count); |
3576 | } | 4417 | } |
3577 | 4418 | ||
@@ -3583,11 +4424,62 @@ namespace OpenSim.Region.Framework.Scenes | |||
3583 | { | 4424 | { |
3584 | // m_log.DebugFormat( | 4425 | // m_log.DebugFormat( |
3585 | // "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); | 4426 | // "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); |
4427 | if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200) | ||
4428 | return; | ||
4429 | SendAppearanceToAgentNF(avatar); | ||
4430 | } | ||
3586 | 4431 | ||
4432 | public void SendAppearanceToAgentNF(ScenePresence avatar) | ||
4433 | { | ||
3587 | avatar.ControllingClient.SendAppearance( | 4434 | avatar.ControllingClient.SendAppearance( |
3588 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); | 4435 | UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); |
4436 | } | ||
3589 | 4437 | ||
3590 | 4438 | public void SendAnimPackToAgent(ScenePresence p) | |
4439 | { | ||
4440 | if (IsChildAgent || Animator == null) | ||
4441 | return; | ||
4442 | |||
4443 | if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
4444 | return; | ||
4445 | |||
4446 | Animator.SendAnimPackToClient(p.ControllingClient); | ||
4447 | } | ||
4448 | |||
4449 | public void SendAnimPackToAgent(ScenePresence p, UUID[] animations, int[] seqs, UUID[] objectIDs) | ||
4450 | { | ||
4451 | if (IsChildAgent) | ||
4452 | return; | ||
4453 | |||
4454 | if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
4455 | return; | ||
4456 | |||
4457 | p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); | ||
4458 | } | ||
4459 | |||
4460 | public void SendAnimPackToAgentNF(ScenePresence p) | ||
4461 | { | ||
4462 | if (IsChildAgent || Animator == null) | ||
4463 | return; | ||
4464 | Animator.SendAnimPackToClient(p.ControllingClient); | ||
4465 | } | ||
4466 | |||
4467 | public void SendAnimPackToAgentNF(ScenePresence p, UUID[] animations, int[] seqs, UUID[] objectIDs) | ||
4468 | { | ||
4469 | p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); | ||
4470 | } | ||
4471 | |||
4472 | public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) | ||
4473 | { | ||
4474 | if (IsChildAgent) | ||
4475 | return; | ||
4476 | |||
4477 | m_scene.ForEachScenePresence(delegate(ScenePresence p) | ||
4478 | { | ||
4479 | if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
4480 | return; | ||
4481 | p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); | ||
4482 | }); | ||
3591 | } | 4483 | } |
3592 | 4484 | ||
3593 | #endregion | 4485 | #endregion |
@@ -3611,6 +4503,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3611 | m_lastChildAgentUpdatePosition = AbsolutePosition; | 4503 | m_lastChildAgentUpdatePosition = AbsolutePosition; |
3612 | // m_lastChildAgentUpdateCamPosition = CameraPosition; | 4504 | // m_lastChildAgentUpdateCamPosition = CameraPosition; |
3613 | 4505 | ||
4506 | /* cadu is not used | ||
3614 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | 4507 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); |
3615 | cadu.ActiveGroupID = UUID.Zero.Guid; | 4508 | cadu.ActiveGroupID = UUID.Zero.Guid; |
3616 | cadu.AgentID = UUID.Guid; | 4509 | cadu.AgentID = UUID.Guid; |
@@ -3624,6 +4517,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3624 | 4517 | ||
3625 | // Throttles | 4518 | // Throttles |
3626 | float multiplier = 1; | 4519 | float multiplier = 1; |
4520 | |||
3627 | int childRegions = KnownRegionCount; | 4521 | int childRegions = KnownRegionCount; |
3628 | if (childRegions != 0) | 4522 | if (childRegions != 0) |
3629 | multiplier = 1f / childRegions; | 4523 | multiplier = 1f / childRegions; |
@@ -3634,9 +4528,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3634 | 4528 | ||
3635 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); | 4529 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); |
3636 | cadu.Velocity = Velocity; | 4530 | cadu.Velocity = Velocity; |
3637 | 4531 | */ | |
3638 | AgentPosition agentpos = new AgentPosition(); | 4532 | AgentPosition agentpos = new AgentPosition(); |
3639 | agentpos.CopyFrom(cadu, ControllingClient.SessionId); | 4533 | // agentpos.CopyFrom(cadu, ControllingClient.SessionId); |
4534 | |||
4535 | agentpos.AgentID = new UUID(UUID.Guid); | ||
4536 | agentpos.SessionID = ControllingClient.SessionId; | ||
4537 | |||
4538 | agentpos.Size = Appearance.AvatarSize; | ||
4539 | |||
4540 | agentpos.Center = CameraPosition; | ||
4541 | agentpos.Far = DrawDistance; | ||
4542 | agentpos.Position = AbsolutePosition; | ||
4543 | agentpos.Velocity = Velocity; | ||
4544 | agentpos.RegionHandle = RegionHandle; | ||
4545 | agentpos.Throttles = ControllingClient.GetThrottlesPacked(1); | ||
4546 | |||
3640 | 4547 | ||
3641 | // Let's get this out of the update loop | 4548 | // Let's get this out of the update loop |
3642 | Util.FireAndForget( | 4549 | Util.FireAndForget( |
@@ -3657,7 +4564,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3657 | protected void CheckForBorderCrossing() | 4564 | protected void CheckForBorderCrossing() |
3658 | { | 4565 | { |
3659 | // Check that we we are not a child | 4566 | // Check that we we are not a child |
3660 | if (IsChildAgent) | 4567 | if (IsChildAgent || IsInTransit) |
3661 | return; | 4568 | return; |
3662 | 4569 | ||
3663 | // If we don't have a PhysActor, we can't cross anyway | 4570 | // If we don't have a PhysActor, we can't cross anyway |
@@ -3667,6 +4574,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3667 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) | 4574 | if (ParentID != 0 || PhysicsActor == null || ParentUUID != UUID.Zero) |
3668 | return; | 4575 | return; |
3669 | 4576 | ||
4577 | <<<<<<< HEAD | ||
3670 | if (IsInTransit) | 4578 | if (IsInTransit) |
3671 | return; | 4579 | return; |
3672 | 4580 | ||
@@ -3740,6 +4648,70 @@ namespace OpenSim.Region.Framework.Scenes | |||
3740 | ret.Y = extentY - borderFudge; | 4648 | ret.Y = extentY - borderFudge; |
3741 | 4649 | ||
3742 | return ret; | 4650 | return ret; |
4651 | ======= | ||
4652 | Vector3 pos2 = AbsolutePosition; | ||
4653 | Vector3 vel = Velocity; | ||
4654 | |||
4655 | float timeStep = 0.1f; | ||
4656 | pos2.X += vel.X * timeStep; | ||
4657 | pos2.Y += vel.Y * timeStep; | ||
4658 | pos2.Z += vel.Z * timeStep; | ||
4659 | |||
4660 | // m_log.DebugFormat( | ||
4661 | // "[SCENE PRESENCE]: Testing border check for projected position {0} of {1} in {2}", | ||
4662 | // pos2, Name, Scene.Name); | ||
4663 | |||
4664 | if (Scene.PositionIsInCurrentRegion(pos2)) | ||
4665 | return; | ||
4666 | |||
4667 | if (!CrossToNewRegion() && m_requestedSitTargetUUID == UUID.Zero) | ||
4668 | { | ||
4669 | // we don't have entity transfer module | ||
4670 | Vector3 pos = AbsolutePosition; | ||
4671 | float px = pos.X; | ||
4672 | if (px < 0) | ||
4673 | pos.X += Velocity.X * 2; | ||
4674 | else if (px > m_scene.RegionInfo.RegionSizeX) | ||
4675 | pos.X -= Velocity.X * 2; | ||
4676 | |||
4677 | float py = pos.Y; | ||
4678 | if (py < 0) | ||
4679 | pos.Y += Velocity.Y * 2; | ||
4680 | else if (py > m_scene.RegionInfo.RegionSizeY) | ||
4681 | pos.Y -= Velocity.Y * 2; | ||
4682 | |||
4683 | Velocity = Vector3.Zero; | ||
4684 | AbsolutePosition = pos; | ||
4685 | } | ||
4686 | } | ||
4687 | |||
4688 | public void CrossToNewRegionFail() | ||
4689 | { | ||
4690 | if (m_requestedSitTargetUUID == UUID.Zero) | ||
4691 | { | ||
4692 | bool isFlying = Flying; | ||
4693 | RemoveFromPhysicalScene(); | ||
4694 | |||
4695 | Vector3 pos = AbsolutePosition; | ||
4696 | float px = pos.X; | ||
4697 | if (px < 0) | ||
4698 | pos.X += Velocity.X * 2; | ||
4699 | else if (px > m_scene.RegionInfo.RegionSizeX) | ||
4700 | pos.X -= Velocity.X * 2; | ||
4701 | |||
4702 | float py = pos.Y; | ||
4703 | if (py < 0) | ||
4704 | pos.Y += Velocity.Y * 2; | ||
4705 | else if (py > m_scene.RegionInfo.RegionSizeY) | ||
4706 | pos.Y -= Velocity.Y * 2; | ||
4707 | |||
4708 | Velocity = Vector3.Zero; | ||
4709 | AbsolutePosition = pos; | ||
4710 | |||
4711 | AddToPhysicalScene(isFlying); | ||
4712 | } | ||
4713 | |||
4714 | >>>>>>> avn/ubitvar | ||
3743 | } | 4715 | } |
3744 | 4716 | ||
3745 | /// <summary> | 4717 | /// <summary> |
@@ -3750,16 +4722,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
3750 | /// </summary> | 4722 | /// </summary> |
3751 | protected bool CrossToNewRegion() | 4723 | protected bool CrossToNewRegion() |
3752 | { | 4724 | { |
4725 | bool result = false; | ||
4726 | // parcelRegionCross(false); | ||
3753 | try | 4727 | try |
3754 | { | 4728 | { |
3755 | return m_scene.CrossAgentToNewRegion(this, Flying); | 4729 | result = m_scene.CrossAgentToNewRegion(this, Flying); |
3756 | } | 4730 | } |
3757 | catch | 4731 | catch |
3758 | { | 4732 | { |
3759 | return m_scene.CrossAgentToNewRegion(this, false); | 4733 | // result = m_scene.CrossAgentToNewRegion(this, false); |
4734 | return false; | ||
3760 | } | 4735 | } |
4736 | // if(!result) | ||
4737 | // parcelRegionCross(true); | ||
4738 | |||
4739 | return result; | ||
4740 | |||
3761 | } | 4741 | } |
3762 | 4742 | ||
4743 | /* useless. Either use MakeChild or delete the presence | ||
3763 | public void Reset() | 4744 | public void Reset() |
3764 | { | 4745 | { |
3765 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting {0} in {1}", Name, Scene.RegionInfo.RegionName); | 4746 | // m_log.DebugFormat("[SCENE PRESENCE]: Resetting {0} in {1}", Name, Scene.RegionInfo.RegionName); |
@@ -3770,7 +4751,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3770 | 4751 | ||
3771 | Animator.ResetAnimations(); | 4752 | Animator.ResetAnimations(); |
3772 | } | 4753 | } |
3773 | 4754 | */ | |
3774 | /// <summary> | 4755 | /// <summary> |
3775 | /// Computes which child agents to close when the scene presence moves to another region. | 4756 | /// Computes which child agents to close when the scene presence moves to another region. |
3776 | /// Removes those regions from m_knownRegions. | 4757 | /// Removes those regions from m_knownRegions. |
@@ -3778,8 +4759,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3778 | /// <param name="newRegionX">The new region's x on the map</param> | 4759 | /// <param name="newRegionX">The new region's x on the map</param> |
3779 | /// <param name="newRegionY">The new region's y on the map</param> | 4760 | /// <param name="newRegionY">The new region's y on the map</param> |
3780 | /// <returns></returns> | 4761 | /// <returns></returns> |
3781 | public void CloseChildAgents(uint newRegionX, uint newRegionY) | 4762 | public void CloseChildAgents(ulong newRegionHandle, int newRegionSizeX, int newRegionSizeY) |
3782 | { | 4763 | { |
4764 | uint newRegionX, newRegionY; | ||
3783 | List<ulong> byebyeRegions = new List<ulong>(); | 4765 | List<ulong> byebyeRegions = new List<ulong>(); |
3784 | List<ulong> knownRegions = KnownRegionHandles; | 4766 | List<ulong> knownRegions = KnownRegionHandles; |
3785 | m_log.DebugFormat( | 4767 | m_log.DebugFormat( |
@@ -3787,11 +4769,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
3787 | knownRegions.Count, Scene.RegionInfo.RegionName); | 4769 | knownRegions.Count, Scene.RegionInfo.RegionName); |
3788 | //DumpKnownRegions(); | 4770 | //DumpKnownRegions(); |
3789 | 4771 | ||
4772 | Util.RegionHandleToRegionLoc(newRegionHandle, out newRegionX, out newRegionY); | ||
4773 | |||
4774 | uint x, y; | ||
4775 | spRegionSizeInfo regInfo; | ||
4776 | |||
3790 | foreach (ulong handle in knownRegions) | 4777 | foreach (ulong handle in knownRegions) |
3791 | { | 4778 | { |
3792 | // Don't close the agent on this region yet | 4779 | // Don't close the agent on this region yet |
3793 | if (handle != Scene.RegionInfo.RegionHandle) | 4780 | if (handle != Scene.RegionInfo.RegionHandle) |
3794 | { | 4781 | { |
4782 | <<<<<<< HEAD | ||
3795 | uint x, y; | 4783 | uint x, y; |
3796 | Util.RegionHandleToRegionLoc(handle, out x, out y); | 4784 | Util.RegionHandleToRegionLoc(handle, out x, out y); |
3797 | 4785 | ||
@@ -3800,8 +4788,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
3800 | float dist = (float)Math.Max(Scene.DefaultDrawDistance, | 4788 | float dist = (float)Math.Max(Scene.DefaultDrawDistance, |
3801 | (float)Math.Max(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY)); | 4789 | (float)Math.Max(Scene.RegionInfo.RegionSizeX, Scene.RegionInfo.RegionSizeY)); |
3802 | if (Util.IsOutsideView(dist, x, newRegionX, y, newRegionY)) | 4790 | if (Util.IsOutsideView(dist, x, newRegionX, y, newRegionY)) |
4791 | ======= | ||
4792 | Util.RegionHandleToRegionLoc(handle, out x, out y); | ||
4793 | if (m_knownChildRegionsSizeInfo.TryGetValue(handle, out regInfo)) | ||
3803 | { | 4794 | { |
3804 | byebyeRegions.Add(handle); | 4795 | |
4796 | // m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); | ||
4797 | // m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); | ||
4798 | if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY, | ||
4799 | regInfo.sizeX, regInfo.sizeY, newRegionSizeX, newRegionSizeY)) | ||
4800 | { | ||
4801 | byebyeRegions.Add(handle); | ||
4802 | } | ||
4803 | } | ||
4804 | else | ||
4805 | >>>>>>> avn/ubitvar | ||
4806 | { | ||
4807 | if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY, | ||
4808 | (int)Constants.RegionSize, (int)Constants.RegionSize, newRegionSizeX, newRegionSizeY)) | ||
4809 | { | ||
4810 | byebyeRegions.Add(handle); | ||
4811 | } | ||
3805 | } | 4812 | } |
3806 | } | 4813 | } |
3807 | } | 4814 | } |
@@ -3820,6 +4827,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3820 | foreach (ulong handle in byebyeRegions) | 4827 | foreach (ulong handle in byebyeRegions) |
3821 | { | 4828 | { |
3822 | RemoveNeighbourRegion(handle); | 4829 | RemoveNeighbourRegion(handle); |
4830 | Scene.CapsModule.DropChildSeed(UUID, handle); | ||
3823 | } | 4831 | } |
3824 | } | 4832 | } |
3825 | 4833 | ||
@@ -3831,6 +4839,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3831 | /// </summary> | 4839 | /// </summary> |
3832 | public void GrantGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godStatus) | 4840 | public void GrantGodlikePowers(UUID agentID, UUID sessionID, UUID token, bool godStatus) |
3833 | { | 4841 | { |
4842 | int oldgodlevel = GodLevel; | ||
4843 | |||
3834 | if (godStatus) | 4844 | if (godStatus) |
3835 | { | 4845 | { |
3836 | // For now, assign god level 200 to anyone | 4846 | // For now, assign god level 200 to anyone |
@@ -3851,6 +4861,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3851 | } | 4861 | } |
3852 | 4862 | ||
3853 | ControllingClient.SendAdminResponse(token, (uint)GodLevel); | 4863 | ControllingClient.SendAdminResponse(token, (uint)GodLevel); |
4864 | |||
4865 | if(oldgodlevel != GodLevel) | ||
4866 | parcelGodCheck(m_currentParcelUUID, GodLevel >= 200); | ||
3854 | } | 4867 | } |
3855 | 4868 | ||
3856 | #region Child Agent Updates | 4869 | #region Child Agent Updates |
@@ -3868,6 +4881,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3868 | 4881 | ||
3869 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 4882 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3870 | 4883 | ||
4884 | private void RaiseUpdateThrottles() | ||
4885 | { | ||
4886 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
4887 | } | ||
4888 | |||
3871 | /// <summary> | 4889 | /// <summary> |
3872 | /// This updates important decision making data about a child agent | 4890 | /// This updates important decision making data about a child agent |
3873 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 4891 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3877,6 +4895,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3877 | if (!IsChildAgent) | 4895 | if (!IsChildAgent) |
3878 | return; | 4896 | return; |
3879 | 4897 | ||
4898 | <<<<<<< HEAD | ||
3880 | // m_log.DebugFormat( | 4899 | // m_log.DebugFormat( |
3881 | // "[SCENE PRESENCE]: ChildAgentPositionUpdate for {0} in {1}, tRegion {2},{3}, rRegion {4},{5}, pos {6}", | 4900 | // "[SCENE PRESENCE]: ChildAgentPositionUpdate for {0} in {1}, tRegion {2},{3}, rRegion {4},{5}, pos {6}", |
3882 | // Name, Scene.Name, tRegionX, tRegionY, rRegionX, rRegionY, cAgentData.Position); | 4901 | // Name, Scene.Name, tRegionX, tRegionY, rRegionX, rRegionY, cAgentData.Position); |
@@ -3886,6 +4905,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3886 | // uint | 4905 | // uint |
3887 | int shiftx = (int)(((int)rRegionX - (int)tRegionX) * Constants.RegionSize); | 4906 | int shiftx = (int)(((int)rRegionX - (int)tRegionX) * Constants.RegionSize); |
3888 | int shifty = (int)(((int)rRegionY - (int)tRegionY) * Constants.RegionSize); | 4907 | int shifty = (int)(((int)rRegionY - (int)tRegionY) * Constants.RegionSize); |
4908 | ======= | ||
4909 | RegionHandle = cAgentData.RegionHandle; | ||
4910 | |||
4911 | //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); | ||
4912 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; | ||
4913 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; | ||
4914 | >>>>>>> avn/ubitvar | ||
3889 | 4915 | ||
3890 | Vector3 offset = new Vector3(shiftx, shifty, 0f); | 4916 | Vector3 offset = new Vector3(shiftx, shifty, 0f); |
3891 | 4917 | ||
@@ -3893,7 +4919,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3893 | // changes, then start using the agent's drawdistance rather than the | 4919 | // changes, then start using the agent's drawdistance rather than the |
3894 | // region's draw distance. | 4920 | // region's draw distance. |
3895 | DrawDistance = cAgentData.Far; | 4921 | DrawDistance = cAgentData.Far; |
4922 | <<<<<<< HEAD | ||
3896 | // DrawDistance = Scene.DefaultDrawDistance; | 4923 | // DrawDistance = Scene.DefaultDrawDistance; |
4924 | ======= | ||
4925 | // DrawDistance = Scene.DefaultDrawDistance; | ||
4926 | >>>>>>> avn/ubitvar | ||
3897 | 4927 | ||
3898 | if (cAgentData.Position != marker) // UGH!! | 4928 | if (cAgentData.Position != marker) // UGH!! |
3899 | m_pos = cAgentData.Position + offset; | 4929 | m_pos = cAgentData.Position + offset; |
@@ -3907,10 +4937,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
3907 | CameraPosition = cAgentData.Center + offset; | 4937 | CameraPosition = cAgentData.Center + offset; |
3908 | 4938 | ||
3909 | if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) | 4939 | if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) |
3910 | ControllingClient.SetChildAgentThrottle(cAgentData.Throttles); | 4940 | { |
4941 | // some scaling factor | ||
4942 | float x = m_pos.X; | ||
4943 | if (x > m_scene.RegionInfo.RegionSizeX) | ||
4944 | x -= m_scene.RegionInfo.RegionSizeX; | ||
4945 | float y = m_pos.Y; | ||
4946 | if (y > m_scene.RegionInfo.RegionSizeY) | ||
4947 | y -= m_scene.RegionInfo.RegionSizeY; | ||
4948 | |||
4949 | x = x * x + y * y; | ||
4950 | |||
4951 | const float distScale = 0.4f / Constants.RegionSize / Constants.RegionSize; | ||
4952 | float factor = 1.0f - distScale * x; | ||
4953 | if (factor < 0.2f) | ||
4954 | factor = 0.2f; | ||
4955 | |||
4956 | ControllingClient.SetChildAgentThrottle(cAgentData.Throttles,factor); | ||
4957 | } | ||
4958 | |||
4959 | if(cAgentData.ChildrenCapSeeds != null && cAgentData.ChildrenCapSeeds.Count >0) | ||
4960 | { | ||
4961 | if (Scene.CapsModule != null) | ||
4962 | { | ||
4963 | Scene.CapsModule.SetChildrenSeed(UUID, cAgentData.ChildrenCapSeeds); | ||
4964 | } | ||
4965 | |||
4966 | KnownRegions = cAgentData.ChildrenCapSeeds; | ||
4967 | } | ||
3911 | 4968 | ||
3912 | //cAgentData.AVHeight; | 4969 | //cAgentData.AVHeight; |
3913 | RegionHandle = cAgentData.RegionHandle; | ||
3914 | //m_velocity = cAgentData.Velocity; | 4970 | //m_velocity = cAgentData.Velocity; |
3915 | } | 4971 | } |
3916 | 4972 | ||
@@ -3932,16 +4988,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3932 | cAgent.Far = DrawDistance; | 4988 | cAgent.Far = DrawDistance; |
3933 | 4989 | ||
3934 | // Throttles | 4990 | // Throttles |
3935 | float multiplier = 1; | 4991 | cAgent.Throttles = ControllingClient.GetThrottlesPacked(1); |
3936 | int childRegions = KnownRegionCount; | ||
3937 | if (childRegions != 0) | ||
3938 | multiplier = 1f / childRegions; | ||
3939 | |||
3940 | // Minimum throttle for a child region is 1/4 of the root region throttle | ||
3941 | if (multiplier <= 0.25f) | ||
3942 | multiplier = 0.25f; | ||
3943 | |||
3944 | cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier); | ||
3945 | 4992 | ||
3946 | cAgent.HeadRotation = m_headrotation; | 4993 | cAgent.HeadRotation = m_headrotation; |
3947 | cAgent.BodyRotation = Rotation; | 4994 | cAgent.BodyRotation = Rotation; |
@@ -3954,7 +5001,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3954 | 5001 | ||
3955 | cAgent.AlwaysRun = SetAlwaysRun; | 5002 | cAgent.AlwaysRun = SetAlwaysRun; |
3956 | 5003 | ||
3957 | cAgent.Appearance = new AvatarAppearance(Appearance); | 5004 | // make clear we want the all thing |
5005 | cAgent.Appearance = new AvatarAppearance(Appearance,true,true); | ||
3958 | 5006 | ||
3959 | cAgent.ParentPart = ParentUUID; | 5007 | cAgent.ParentPart = ParentUUID; |
3960 | cAgent.SitOffset = PrevSitOffset; | 5008 | cAgent.SitOffset = PrevSitOffset; |
@@ -3980,12 +5028,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
3980 | cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; | 5028 | cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; |
3981 | cAgent.AnimState = Animator.Animations.ImplicitDefaultAnimation; | 5029 | cAgent.AnimState = Animator.Animations.ImplicitDefaultAnimation; |
3982 | 5030 | ||
5031 | cAgent.MovementAnimationOverRides = Overrides.CloneAOPairs(); | ||
5032 | |||
5033 | cAgent.MotionState = (byte)Animator.currentControlState; | ||
5034 | |||
3983 | if (Scene.AttachmentsModule != null) | 5035 | if (Scene.AttachmentsModule != null) |
3984 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); | 5036 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); |
3985 | } | 5037 | } |
3986 | 5038 | ||
3987 | private void CopyFrom(AgentData cAgent) | 5039 | private void CopyFrom(AgentData cAgent) |
3988 | { | 5040 | { |
5041 | <<<<<<< HEAD | ||
5042 | ======= | ||
5043 | |||
5044 | >>>>>>> avn/ubitvar | ||
3989 | m_callbackURI = cAgent.CallbackURI; | 5045 | m_callbackURI = cAgent.CallbackURI; |
3990 | // m_log.DebugFormat( | 5046 | // m_log.DebugFormat( |
3991 | // "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()", | 5047 | // "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()", |
@@ -4004,7 +5060,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4004 | // changes, then start using the agent's drawdistance rather than the | 5060 | // changes, then start using the agent's drawdistance rather than the |
4005 | // region's draw distance. | 5061 | // region's draw distance. |
4006 | DrawDistance = cAgent.Far; | 5062 | DrawDistance = cAgent.Far; |
5063 | <<<<<<< HEAD | ||
4007 | // DrawDistance = Scene.DefaultDrawDistance; | 5064 | // DrawDistance = Scene.DefaultDrawDistance; |
5065 | ======= | ||
5066 | //DrawDistance = Scene.DefaultDrawDistance; | ||
5067 | |||
5068 | if (cAgent.ChildrenCapSeeds != null && cAgent.ChildrenCapSeeds.Count > 0) | ||
5069 | { | ||
5070 | if (Scene.CapsModule != null) | ||
5071 | { | ||
5072 | Scene.CapsModule.SetChildrenSeed(UUID, cAgent.ChildrenCapSeeds); | ||
5073 | } | ||
5074 | KnownRegions = cAgent.ChildrenCapSeeds; | ||
5075 | } | ||
5076 | >>>>>>> avn/ubitvar | ||
4008 | 5077 | ||
4009 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) | 5078 | if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0) |
4010 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); | 5079 | ControllingClient.SetChildAgentThrottle(cAgent.Throttles); |
@@ -4017,14 +5086,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
4017 | GodLevel = cAgent.GodLevel; | 5086 | GodLevel = cAgent.GodLevel; |
4018 | SetAlwaysRun = cAgent.AlwaysRun; | 5087 | SetAlwaysRun = cAgent.AlwaysRun; |
4019 | 5088 | ||
5089 | |||
4020 | Appearance = new AvatarAppearance(cAgent.Appearance); | 5090 | Appearance = new AvatarAppearance(cAgent.Appearance); |
5091 | /* | ||
5092 | bool isFlying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | ||
5093 | |||
4021 | if (PhysicsActor != null) | 5094 | if (PhysicsActor != null) |
4022 | { | 5095 | { |
4023 | bool isFlying = Flying; | ||
4024 | RemoveFromPhysicalScene(); | 5096 | RemoveFromPhysicalScene(); |
4025 | AddToPhysicalScene(isFlying); | 5097 | AddToPhysicalScene(isFlying); |
4026 | } | 5098 | } |
4027 | 5099 | */ | |
4028 | try | 5100 | try |
4029 | { | 5101 | { |
4030 | lock (scriptedcontrols) | 5102 | lock (scriptedcontrols) |
@@ -4048,15 +5120,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
4048 | } | 5120 | } |
4049 | catch { } | 5121 | catch { } |
4050 | 5122 | ||
5123 | Animator.ResetAnimations(); | ||
5124 | |||
5125 | Overrides.CopyAOPairsFrom(cAgent.MovementAnimationOverRides); | ||
5126 | |||
4051 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? | 5127 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? |
4052 | if (cAgent.Anims != null) | ||
4053 | Animator.Animations.FromArray(cAgent.Anims); | ||
4054 | if (cAgent.DefaultAnim != null) | 5128 | if (cAgent.DefaultAnim != null) |
4055 | Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); | 5129 | Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); |
4056 | if (cAgent.AnimState != null) | 5130 | if (cAgent.AnimState != null) |
4057 | Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero); | 5131 | Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero); |
5132 | if (cAgent.Anims != null) | ||
5133 | Animator.Animations.FromArray(cAgent.Anims); | ||
5134 | if (cAgent.MotionState != 0) | ||
5135 | Animator.currentControlState = (ScenePresenceAnimator.motionControlStates) cAgent.MotionState; | ||
4058 | 5136 | ||
4059 | if (Scene.AttachmentsModule != null) | 5137 | if (Scene.AttachmentsModule != null) |
5138 | <<<<<<< HEAD | ||
4060 | { | 5139 | { |
4061 | // If the JobEngine is running we can schedule this job now and continue rather than waiting for all | 5140 | // If the JobEngine is running we can schedule this job now and continue rather than waiting for all |
4062 | // attachments to copy, which might take a long time in the Hypergrid case as the entire inventory | 5141 | // attachments to copy, which might take a long time in the Hypergrid case as the entire inventory |
@@ -4078,6 +5157,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
4078 | // script attachments can outrace this thread. | 5157 | // script attachments can outrace this thread. |
4079 | lock (m_originRegionIDAccessLock) | 5158 | lock (m_originRegionIDAccessLock) |
4080 | m_originRegionID = cAgent.RegionID; | 5159 | m_originRegionID = cAgent.RegionID; |
5160 | ======= | ||
5161 | Scene.AttachmentsModule.CopyAttachments(cAgent, this); | ||
5162 | |||
5163 | lock (m_originRegionIDAccessLock) | ||
5164 | m_originRegionID = cAgent.RegionID; | ||
5165 | |||
5166 | >>>>>>> avn/ubitvar | ||
4081 | } | 5167 | } |
4082 | 5168 | ||
4083 | public bool CopyAgent(out IAgentData agent) | 5169 | public bool CopyAgent(out IAgentData agent) |
@@ -4094,6 +5180,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4094 | /// </summary> | 5180 | /// </summary> |
4095 | public void UpdateMovement() | 5181 | public void UpdateMovement() |
4096 | { | 5182 | { |
5183 | if (IsInTransit) | ||
5184 | return; | ||
4097 | if (m_forceToApply.HasValue) | 5185 | if (m_forceToApply.HasValue) |
4098 | { | 5186 | { |
4099 | Vector3 force = m_forceToApply.Value; | 5187 | Vector3 force = m_forceToApply.Value; |
@@ -4131,9 +5219,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4131 | new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); | 5219 | new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); |
4132 | */ | 5220 | */ |
4133 | 5221 | ||
5222 | <<<<<<< HEAD | ||
4134 | PhysicsActor = m_scene.PhysicsScene.AddAvatar( | 5223 | PhysicsActor = m_scene.PhysicsScene.AddAvatar( |
4135 | LocalId, Firstname + "." + Lastname, AbsolutePosition, Velocity, | 5224 | LocalId, Firstname + "." + Lastname, AbsolutePosition, Velocity, |
4136 | Appearance.AvatarBoxSize, isFlying); | 5225 | Appearance.AvatarBoxSize, isFlying); |
5226 | ======= | ||
5227 | PhysicsActor = scene.AddAvatar( | ||
5228 | LocalId, Firstname + "." + Lastname, pVec, | ||
5229 | Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); | ||
5230 | >>>>>>> avn/ubitvar | ||
4137 | 5231 | ||
4138 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 5232 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
4139 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 5233 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
@@ -4168,7 +5262,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
4168 | { | 5262 | { |
4169 | if (IsChildAgent || Animator == null) | 5263 | if (IsChildAgent || Animator == null) |
4170 | return; | 5264 | return; |
4171 | 5265 | ||
5266 | if(IsInTransit) | ||
5267 | return; | ||
4172 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 5268 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
4173 | // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( | 5269 | // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( |
4174 | // as of this comment the interval is set in AddToPhysicalScene | 5270 | // as of this comment the interval is set in AddToPhysicalScene |
@@ -4192,7 +5288,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
4192 | // m_lastColCount = coldata.Count; | 5288 | // m_lastColCount = coldata.Count; |
4193 | // } | 5289 | // } |
4194 | 5290 | ||
4195 | CollisionPlane = Vector4.UnitW; | 5291 | if (coldata.Count != 0) |
5292 | { | ||
5293 | /* | ||
5294 | switch (Animator.CurrentMovementAnimation) | ||
5295 | { | ||
5296 | case "STAND": | ||
5297 | case "WALK": | ||
5298 | case "RUN": | ||
5299 | case "CROUCH": | ||
5300 | case "CROUCHWALK": | ||
5301 | { | ||
5302 | */ | ||
5303 | ContactPoint lowest; | ||
5304 | lowest.SurfaceNormal = Vector3.Zero; | ||
5305 | lowest.Position = Vector3.Zero; | ||
5306 | lowest.Position.Z = float.MaxValue; | ||
5307 | |||
5308 | foreach (ContactPoint contact in coldata.Values) | ||
5309 | { | ||
5310 | |||
5311 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | ||
5312 | { | ||
5313 | lowest = contact; | ||
5314 | } | ||
5315 | } | ||
5316 | |||
5317 | if (lowest.Position.Z != float.MaxValue) | ||
5318 | { | ||
5319 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | ||
5320 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
5321 | } | ||
5322 | else | ||
5323 | CollisionPlane = Vector4.UnitW; | ||
5324 | /* | ||
5325 | } | ||
5326 | break; | ||
5327 | } | ||
5328 | */ | ||
5329 | } | ||
5330 | else | ||
5331 | CollisionPlane = Vector4.UnitW; | ||
5332 | |||
5333 | RaiseCollisionScriptEvents(coldata); | ||
4196 | 5334 | ||
4197 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 5335 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
4198 | if (Invulnerable || GodLevel > 0) | 5336 | if (Invulnerable || GodLevel > 0) |
@@ -4311,6 +5449,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
4311 | 5449 | ||
4312 | m_attachments.Add(gobj); | 5450 | m_attachments.Add(gobj); |
4313 | } | 5451 | } |
5452 | |||
5453 | IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
5454 | if (bakedModule != null) | ||
5455 | bakedModule.UpdateMeshAvatar(m_uuid); | ||
4314 | } | 5456 | } |
4315 | 5457 | ||
4316 | /// <summary> | 5458 | /// <summary> |
@@ -4474,6 +5616,287 @@ namespace OpenSim.Region.Framework.Scenes | |||
4474 | return validated; | 5616 | return validated; |
4475 | } | 5617 | } |
4476 | 5618 | ||
5619 | public void SendAttachmentsToAllAgents() | ||
5620 | { | ||
5621 | lock (m_attachments) | ||
5622 | { | ||
5623 | foreach (SceneObjectGroup sog in m_attachments) | ||
5624 | { | ||
5625 | m_scene.ForEachScenePresence(delegate(ScenePresence p) | ||
5626 | { | ||
5627 | if (p != this && sog.HasPrivateAttachmentPoint) | ||
5628 | return; | ||
5629 | |||
5630 | if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
5631 | return; | ||
5632 | |||
5633 | SendTerseUpdateToAgentNF(p); | ||
5634 | SendAttachmentFullUpdateToAgentNF(sog, p); | ||
5635 | }); | ||
5636 | } | ||
5637 | } | ||
5638 | } | ||
5639 | |||
5640 | // send attachments to a client without filters except for huds | ||
5641 | // for now they are checked in several places down the line... | ||
5642 | public void SendAttachmentsToAgentNF(ScenePresence p) | ||
5643 | { | ||
5644 | SendTerseUpdateToAgentNF(p); | ||
5645 | lock (m_attachments) | ||
5646 | { | ||
5647 | foreach (SceneObjectGroup sog in m_attachments) | ||
5648 | { | ||
5649 | SendAttachmentFullUpdateToAgentNF(sog, p); | ||
5650 | } | ||
5651 | } | ||
5652 | } | ||
5653 | |||
5654 | public void SendAttachmentFullUpdateToAgentNF(SceneObjectGroup sog, ScenePresence p) | ||
5655 | { | ||
5656 | if (p != this && sog.HasPrivateAttachmentPoint) | ||
5657 | return; | ||
5658 | |||
5659 | SceneObjectPart[] parts = sog.Parts; | ||
5660 | SceneObjectPart rootpart = sog.RootPart; | ||
5661 | |||
5662 | p.ControllingClient.SendEntityUpdate(rootpart, PrimUpdateFlags.FullUpdate); | ||
5663 | |||
5664 | for (int i = 0; i < parts.Length; i++) | ||
5665 | { | ||
5666 | SceneObjectPart part = parts[i]; | ||
5667 | if (part == rootpart) | ||
5668 | continue; | ||
5669 | p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); | ||
5670 | } | ||
5671 | } | ||
5672 | |||
5673 | public void SendAttachmentScheduleUpdate(SceneObjectGroup sog) | ||
5674 | { | ||
5675 | if (IsChildAgent || IsInTransit) | ||
5676 | return; | ||
5677 | |||
5678 | SceneObjectPart[] origparts = sog.Parts; | ||
5679 | SceneObjectPart[] parts = new SceneObjectPart[origparts.Length]; | ||
5680 | PrimUpdateFlags[] flags = new PrimUpdateFlags[origparts.Length]; | ||
5681 | |||
5682 | SceneObjectPart rootpart = sog.RootPart; | ||
5683 | UpdateRequired rootreq = sog.RootPart.UpdateFlag; | ||
5684 | |||
5685 | int j = 0; | ||
5686 | bool allterse = true; | ||
5687 | for (int i = 0; i < origparts.Length; i++) | ||
5688 | { | ||
5689 | if (origparts[i] != rootpart) | ||
5690 | { | ||
5691 | switch (origparts[i].UpdateFlag) | ||
5692 | { | ||
5693 | case UpdateRequired.NONE: | ||
5694 | break; | ||
5695 | |||
5696 | case UpdateRequired.TERSE: | ||
5697 | flags[j] = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
5698 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; | ||
5699 | parts[j] = origparts[i]; | ||
5700 | j++; | ||
5701 | break; | ||
5702 | |||
5703 | case UpdateRequired.FULL: | ||
5704 | flags[j] = PrimUpdateFlags.FullUpdate; | ||
5705 | allterse = false; | ||
5706 | parts[j] = origparts[i]; | ||
5707 | j++; | ||
5708 | break; | ||
5709 | } | ||
5710 | } | ||
5711 | origparts[i].UpdateFlag = 0; | ||
5712 | } | ||
5713 | |||
5714 | if (j == 0 && rootreq == UpdateRequired.NONE) | ||
5715 | return; | ||
5716 | |||
5717 | PrimUpdateFlags rootflag = PrimUpdateFlags.FullUpdate; | ||
5718 | |||
5719 | if (rootreq != UpdateRequired.FULL && allterse) | ||
5720 | { | ||
5721 | rootflag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
5722 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; | ||
5723 | } | ||
5724 | |||
5725 | int nparts = j; | ||
5726 | |||
5727 | ControllingClient.SendEntityUpdate(rootpart, rootflag); | ||
5728 | |||
5729 | for (int i = 0; i < nparts; i++) | ||
5730 | { | ||
5731 | ControllingClient.SendEntityUpdate(parts[i], flags[i]); | ||
5732 | } | ||
5733 | |||
5734 | if (sog.HasPrivateAttachmentPoint) | ||
5735 | return; | ||
5736 | |||
5737 | List<ScenePresence> allPresences = m_scene.GetScenePresences(); | ||
5738 | foreach (ScenePresence p in allPresences) | ||
5739 | { | ||
5740 | if (p == this) | ||
5741 | continue; | ||
5742 | |||
5743 | if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
5744 | continue; | ||
5745 | |||
5746 | p.ControllingClient.SendEntityUpdate(rootpart, rootflag); | ||
5747 | |||
5748 | for (int i = 0; i < nparts; i++) | ||
5749 | { | ||
5750 | p.ControllingClient.SendEntityUpdate(parts[i], flags[i]); | ||
5751 | } | ||
5752 | } | ||
5753 | } | ||
5754 | |||
5755 | public void SendAttachmentUpdate(SceneObjectGroup sog, UpdateRequired UpdateFlag) | ||
5756 | { | ||
5757 | if (IsChildAgent || IsInTransit) | ||
5758 | return; | ||
5759 | |||
5760 | PrimUpdateFlags flag; | ||
5761 | switch (UpdateFlag) | ||
5762 | { | ||
5763 | case UpdateRequired.TERSE: | ||
5764 | flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
5765 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; | ||
5766 | break; | ||
5767 | |||
5768 | case UpdateRequired.FULL: | ||
5769 | flag = PrimUpdateFlags.FullUpdate; | ||
5770 | break; | ||
5771 | |||
5772 | default: | ||
5773 | return; | ||
5774 | } | ||
5775 | |||
5776 | SceneObjectPart[] parts = sog.Parts; | ||
5777 | SceneObjectPart rootpart = sog.RootPart; | ||
5778 | |||
5779 | // rootpart.UpdateFlag = 0; | ||
5780 | |||
5781 | ControllingClient.SendEntityUpdate(rootpart, flag); | ||
5782 | |||
5783 | for (int i = 0; i < parts.Length; i++) | ||
5784 | { | ||
5785 | SceneObjectPart part = parts[i]; | ||
5786 | if (part == rootpart) | ||
5787 | continue; | ||
5788 | ControllingClient.SendEntityUpdate(part, flag); | ||
5789 | // part.UpdateFlag = 0; | ||
5790 | } | ||
5791 | |||
5792 | if (sog.HasPrivateAttachmentPoint) | ||
5793 | return; | ||
5794 | |||
5795 | |||
5796 | List<ScenePresence> allPresences = m_scene.GetScenePresences(); | ||
5797 | foreach (ScenePresence p in allPresences) | ||
5798 | { | ||
5799 | if (p == this) | ||
5800 | continue; | ||
5801 | |||
5802 | if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
5803 | continue; | ||
5804 | |||
5805 | p.ControllingClient.SendEntityUpdate(rootpart, flag); | ||
5806 | |||
5807 | for (int i = 0; i < parts.Length; i++) | ||
5808 | { | ||
5809 | SceneObjectPart part = parts[i]; | ||
5810 | if (part == rootpart) | ||
5811 | continue; | ||
5812 | p.ControllingClient.SendEntityUpdate(part, flag); | ||
5813 | } | ||
5814 | } | ||
5815 | } | ||
5816 | |||
5817 | public void SendAttachmentScheduleUpdate(SceneObjectPart part) | ||
5818 | { | ||
5819 | if (IsChildAgent || IsInTransit) | ||
5820 | return; | ||
5821 | |||
5822 | |||
5823 | PrimUpdateFlags flag; | ||
5824 | switch (part.UpdateFlag) | ||
5825 | { | ||
5826 | case UpdateRequired.TERSE: | ||
5827 | flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
5828 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; | ||
5829 | break; | ||
5830 | |||
5831 | case UpdateRequired.FULL: | ||
5832 | flag = PrimUpdateFlags.FullUpdate; | ||
5833 | break; | ||
5834 | |||
5835 | default: | ||
5836 | return; | ||
5837 | } | ||
5838 | |||
5839 | part.UpdateFlag = 0; | ||
5840 | |||
5841 | ControllingClient.SendEntityUpdate(part, flag); | ||
5842 | |||
5843 | if (part.ParentGroup.HasPrivateAttachmentPoint) | ||
5844 | return; | ||
5845 | |||
5846 | List<ScenePresence> allPresences = m_scene.GetScenePresences(); | ||
5847 | foreach (ScenePresence p in allPresences) | ||
5848 | { | ||
5849 | if (p == this) | ||
5850 | continue; | ||
5851 | |||
5852 | if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
5853 | continue; | ||
5854 | |||
5855 | p.ControllingClient.SendEntityUpdate(part, flag); | ||
5856 | } | ||
5857 | } | ||
5858 | |||
5859 | |||
5860 | public void SendAttachmentUpdate(SceneObjectPart part, UpdateRequired UpdateFlag) | ||
5861 | { | ||
5862 | if (IsChildAgent || IsInTransit) | ||
5863 | return; | ||
5864 | |||
5865 | PrimUpdateFlags flag; | ||
5866 | switch (UpdateFlag) | ||
5867 | { | ||
5868 | case UpdateRequired.TERSE: | ||
5869 | flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity | ||
5870 | | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity; | ||
5871 | break; | ||
5872 | |||
5873 | case UpdateRequired.FULL: | ||
5874 | flag = PrimUpdateFlags.FullUpdate; | ||
5875 | break; | ||
5876 | |||
5877 | default: | ||
5878 | return; | ||
5879 | } | ||
5880 | |||
5881 | // part.UpdateFlag = 0; | ||
5882 | |||
5883 | ControllingClient.SendEntityUpdate(part, flag); | ||
5884 | |||
5885 | if (part.ParentGroup.HasPrivateAttachmentPoint) | ||
5886 | return; | ||
5887 | |||
5888 | List<ScenePresence> allPresences = m_scene.GetScenePresences(); | ||
5889 | foreach (ScenePresence p in allPresences) | ||
5890 | { | ||
5891 | if (p == this) | ||
5892 | continue; | ||
5893 | if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) | ||
5894 | continue; | ||
5895 | |||
5896 | p.ControllingClient.SendEntityUpdate(part, flag); | ||
5897 | } | ||
5898 | } | ||
5899 | |||
4477 | /// <summary> | 5900 | /// <summary> |
4478 | /// Send a script event to this scene presence's attachments | 5901 | /// Send a script event to this scene presence's attachments |
4479 | /// </summary> | 5902 | /// </summary> |
@@ -4592,6 +6015,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4592 | ControllingClient.SendTakeControls(int.MaxValue, false, false); | 6015 | ControllingClient.SendTakeControls(int.MaxValue, false, false); |
4593 | } | 6016 | } |
4594 | 6017 | ||
6018 | public void ClearControls() | ||
6019 | { | ||
6020 | IgnoredControls = ScriptControlled.CONTROL_ZERO; | ||
6021 | lock (scriptedcontrols) | ||
6022 | { | ||
6023 | scriptedcontrols.Clear(); | ||
6024 | } | ||
6025 | } | ||
6026 | |||
4595 | private void UnRegisterSeatControls(UUID obj) | 6027 | private void UnRegisterSeatControls(UUID obj) |
4596 | { | 6028 | { |
4597 | List<UUID> takers = new List<UUID>(); | 6029 | List<UUID> takers = new List<UUID>(); |
@@ -4833,11 +6265,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4833 | SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray(); | 6265 | SpawnPoint[] spawnPoints = m_scene.RegionInfo.RegionSettings.SpawnPoints().ToArray(); |
4834 | if (spawnPoints.Length == 0) | 6266 | if (spawnPoints.Length == 0) |
4835 | { | 6267 | { |
4836 | if(m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) | 6268 | pos.X = 128.0f; |
4837 | { | 6269 | pos.Y = 128.0f; |
4838 | pos.X = 128.0f; | ||
4839 | pos.Y = 128.0f; | ||
4840 | } | ||
4841 | return; | 6270 | return; |
4842 | } | 6271 | } |
4843 | 6272 | ||
@@ -4982,8 +6411,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4982 | pos = land.LandData.UserLocation; | 6411 | pos = land.LandData.UserLocation; |
4983 | } | 6412 | } |
4984 | } | 6413 | } |
4985 | 6414 | // this is now done in completeMovement for all cases and not just this | |
4986 | land.SendLandUpdateToClient(ControllingClient); | 6415 | // land.SendLandUpdateToClient(ControllingClient); |
4987 | } | 6416 | } |
4988 | } | 6417 | } |
4989 | 6418 | ||
@@ -4998,6 +6427,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4998 | detobj.velVector = obj.Velocity; | 6427 | detobj.velVector = obj.Velocity; |
4999 | detobj.colliderType = 0; | 6428 | detobj.colliderType = 0; |
5000 | detobj.groupUUID = obj.GroupID; | 6429 | detobj.groupUUID = obj.GroupID; |
6430 | detobj.linkNumber = 0; | ||
5001 | 6431 | ||
5002 | return detobj; | 6432 | return detobj; |
5003 | } | 6433 | } |
@@ -5013,6 +6443,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5013 | detobj.velVector = av.Velocity; | 6443 | detobj.velVector = av.Velocity; |
5014 | detobj.colliderType = 0; | 6444 | detobj.colliderType = 0; |
5015 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; | 6445 | detobj.groupUUID = av.ControllingClient.ActiveGroupId; |
6446 | detobj.linkNumber = 0; | ||
5016 | 6447 | ||
5017 | return detobj; | 6448 | return detobj; |
5018 | } | 6449 | } |
@@ -5028,7 +6459,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5028 | detobj.velVector = Vector3.Zero; | 6459 | detobj.velVector = Vector3.Zero; |
5029 | detobj.colliderType = 0; | 6460 | detobj.colliderType = 0; |
5030 | detobj.groupUUID = UUID.Zero; | 6461 | detobj.groupUUID = UUID.Zero; |
5031 | 6462 | detobj.linkNumber = 0; | |
5032 | return detobj; | 6463 | return detobj; |
5033 | } | 6464 | } |
5034 | 6465 | ||
@@ -5095,6 +6526,95 @@ namespace OpenSim.Region.Framework.Scenes | |||
5095 | } | 6526 | } |
5096 | } | 6527 | } |
5097 | 6528 | ||
6529 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
6530 | { | ||
6531 | try | ||
6532 | { | ||
6533 | List<uint> thisHitColliders = new List<uint>(); | ||
6534 | List<uint> endedColliders = new List<uint>(); | ||
6535 | List<uint> startedColliders = new List<uint>(); | ||
6536 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
6537 | CollisionForSoundInfo soundinfo; | ||
6538 | ContactPoint curcontact; | ||
6539 | |||
6540 | if (coldata.Count == 0) | ||
6541 | { | ||
6542 | if (m_lastColliders.Count == 0) | ||
6543 | return; // nothing to do | ||
6544 | |||
6545 | foreach (uint localID in m_lastColliders) | ||
6546 | { | ||
6547 | endedColliders.Add(localID); | ||
6548 | } | ||
6549 | m_lastColliders.Clear(); | ||
6550 | } | ||
6551 | |||
6552 | else | ||
6553 | { | ||
6554 | bool candoparcelSound = ParcelAllowThisAvatarSounds; | ||
6555 | |||
6556 | foreach (uint id in coldata.Keys) | ||
6557 | { | ||
6558 | thisHitColliders.Add(id); | ||
6559 | if (!m_lastColliders.Contains(id)) | ||
6560 | { | ||
6561 | startedColliders.Add(id); | ||
6562 | curcontact = coldata[id]; | ||
6563 | if (candoparcelSound && Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
6564 | { | ||
6565 | soundinfo = new CollisionForSoundInfo(); | ||
6566 | soundinfo.colliderID = id; | ||
6567 | soundinfo.position = curcontact.Position; | ||
6568 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
6569 | soundinfolist.Add(soundinfo); | ||
6570 | } | ||
6571 | } | ||
6572 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
6573 | } | ||
6574 | |||
6575 | // calculate things that ended colliding | ||
6576 | foreach (uint localID in m_lastColliders) | ||
6577 | { | ||
6578 | if (!thisHitColliders.Contains(localID)) | ||
6579 | { | ||
6580 | endedColliders.Add(localID); | ||
6581 | } | ||
6582 | } | ||
6583 | //add the items that started colliding this time to the last colliders list. | ||
6584 | foreach (uint localID in startedColliders) | ||
6585 | { | ||
6586 | m_lastColliders.Add(localID); | ||
6587 | } | ||
6588 | // remove things that ended colliding from the last colliders list | ||
6589 | foreach (uint localID in endedColliders) | ||
6590 | { | ||
6591 | m_lastColliders.Remove(localID); | ||
6592 | } | ||
6593 | |||
6594 | if (soundinfolist.Count > 0) | ||
6595 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
6596 | } | ||
6597 | |||
6598 | foreach (SceneObjectGroup att in GetAttachments()) | ||
6599 | { | ||
6600 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
6601 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
6602 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
6603 | |||
6604 | if (startedColliders.Contains(0)) | ||
6605 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
6606 | if (m_lastColliders.Contains(0)) | ||
6607 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
6608 | if (endedColliders.Contains(0)) | ||
6609 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
6610 | } | ||
6611 | } | ||
6612 | finally | ||
6613 | { | ||
6614 | m_collisionEventFlag = false; | ||
6615 | } | ||
6616 | } | ||
6617 | |||
5098 | private void TeleportFlagsDebug() { | 6618 | private void TeleportFlagsDebug() { |
5099 | 6619 | ||
5100 | // Some temporary debugging help to show all the TeleportFlags we have... | 6620 | // Some temporary debugging help to show all the TeleportFlags we have... |
@@ -5119,5 +6639,282 @@ namespace OpenSim.Region.Framework.Scenes | |||
5119 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); | 6639 | m_log.InfoFormat("[SCENE PRESENCE]: TELEPORT ******************"); |
5120 | 6640 | ||
5121 | } | 6641 | } |
6642 | |||
6643 | private void parcelGodCheck(UUID currentParcelID, bool isGod) | ||
6644 | { | ||
6645 | List<ScenePresence> allpresences = m_scene.GetScenePresences(); | ||
6646 | |||
6647 | foreach (ScenePresence p in allpresences) | ||
6648 | { | ||
6649 | if (p.IsDeleted || p.IsChildAgent || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) | ||
6650 | continue; | ||
6651 | |||
6652 | if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID) | ||
6653 | { | ||
6654 | if (isGod) | ||
6655 | p.SendViewTo(this); | ||
6656 | else | ||
6657 | p.SendKillTo(this); | ||
6658 | } | ||
6659 | } | ||
6660 | } | ||
6661 | |||
6662 | private void ParcelCrossCheck(UUID currentParcelID,UUID previusParcelID, | ||
6663 | bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) | ||
6664 | { | ||
6665 | List<ScenePresence> killsToSendto = new List<ScenePresence>(); | ||
6666 | List<ScenePresence> killsToSendme = new List<ScenePresence>(); | ||
6667 | List<ScenePresence> viewsToSendto = new List<ScenePresence>(); | ||
6668 | List<ScenePresence> viewsToSendme = new List<ScenePresence>(); | ||
6669 | List<ScenePresence> allpresences = null; | ||
6670 | |||
6671 | if (IsInTransit || IsChildAgent) | ||
6672 | return; | ||
6673 | |||
6674 | if (check) | ||
6675 | { | ||
6676 | // check is relative to current parcel only | ||
6677 | if (currentParcelUUID == null || oldhide == currentParcelHide) | ||
6678 | return; | ||
6679 | |||
6680 | allpresences = m_scene.GetScenePresences(); | ||
6681 | |||
6682 | if (oldhide) | ||
6683 | { // where private | ||
6684 | foreach (ScenePresence p in allpresences) | ||
6685 | { | ||
6686 | if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) | ||
6687 | continue; | ||
6688 | |||
6689 | // those on not on parcel see me | ||
6690 | if (currentParcelID != p.currentParcelUUID) | ||
6691 | { | ||
6692 | viewsToSendto.Add(p); // they see me | ||
6693 | } | ||
6694 | } | ||
6695 | } // where private end | ||
6696 | |||
6697 | else | ||
6698 | { // where public | ||
6699 | foreach (ScenePresence p in allpresences) | ||
6700 | { | ||
6701 | if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) | ||
6702 | continue; | ||
6703 | |||
6704 | // those not on parcel dont see me | ||
6705 | if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200) | ||
6706 | { | ||
6707 | killsToSendto.Add(p); // they dont see me | ||
6708 | } | ||
6709 | } | ||
6710 | } // where public end | ||
6711 | |||
6712 | allpresences.Clear(); | ||
6713 | } | ||
6714 | else | ||
6715 | { | ||
6716 | if (currentParcelHide) | ||
6717 | { | ||
6718 | // now on a private parcel | ||
6719 | allpresences = m_scene.GetScenePresences(); | ||
6720 | |||
6721 | if (previusParcelHide && previusParcelID != UUID.Zero) | ||
6722 | { | ||
6723 | foreach (ScenePresence p in allpresences) | ||
6724 | { | ||
6725 | if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) | ||
6726 | continue; | ||
6727 | |||
6728 | // only those on previus parcel need receive kills | ||
6729 | if (previusParcelID == p.currentParcelUUID) | ||
6730 | { | ||
6731 | if(p.GodLevel < 200) | ||
6732 | killsToSendto.Add(p); // they dont see me | ||
6733 | if(GodLevel < 200) | ||
6734 | killsToSendme.Add(p); // i dont see them | ||
6735 | } | ||
6736 | // only those on new parcel need see | ||
6737 | if (currentParcelID == p.currentParcelUUID) | ||
6738 | { | ||
6739 | viewsToSendto.Add(p); // they see me | ||
6740 | viewsToSendme.Add(p); // i see them | ||
6741 | } | ||
6742 | } | ||
6743 | } | ||
6744 | else | ||
6745 | { | ||
6746 | //was on a public area | ||
6747 | allpresences = m_scene.GetScenePresences(); | ||
6748 | |||
6749 | foreach (ScenePresence p in allpresences) | ||
6750 | { | ||
6751 | if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) | ||
6752 | continue; | ||
6753 | |||
6754 | // those not on new parcel dont see me | ||
6755 | if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200) | ||
6756 | { | ||
6757 | killsToSendto.Add(p); // they dont see me | ||
6758 | } | ||
6759 | else | ||
6760 | { | ||
6761 | viewsToSendme.Add(p); // i see those on it | ||
6762 | } | ||
6763 | } | ||
6764 | } | ||
6765 | allpresences.Clear(); | ||
6766 | } // now on a private parcel end | ||
6767 | |||
6768 | else | ||
6769 | { | ||
6770 | // now on public parcel | ||
6771 | if (previusParcelHide && previusParcelID != UUID.Zero) | ||
6772 | { | ||
6773 | // was on private area | ||
6774 | allpresences = m_scene.GetScenePresences(); | ||
6775 | |||
6776 | foreach (ScenePresence p in allpresences) | ||
6777 | { | ||
6778 | if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) | ||
6779 | continue; | ||
6780 | // only those old parcel need kills | ||
6781 | if (previusParcelID == p.currentParcelUUID && GodLevel < 200) | ||
6782 | { | ||
6783 | killsToSendme.Add(p); // i dont see them | ||
6784 | } | ||
6785 | else | ||
6786 | { | ||
6787 | viewsToSendto.Add(p); // they see me | ||
6788 | } | ||
6789 | } | ||
6790 | } | ||
6791 | else | ||
6792 | return; // was on a public area also | ||
6793 | } // now on public parcel end | ||
6794 | } | ||
6795 | |||
6796 | // send the things | ||
6797 | |||
6798 | if (killsToSendto.Count > 0) | ||
6799 | { | ||
6800 | foreach (ScenePresence p in killsToSendto) | ||
6801 | { | ||
6802 | m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); | ||
6803 | SendKillTo(p); | ||
6804 | } | ||
6805 | } | ||
6806 | |||
6807 | if (killsToSendme.Count > 0) | ||
6808 | { | ||
6809 | foreach (ScenePresence p in killsToSendme) | ||
6810 | { | ||
6811 | m_log.Debug("[AVATAR]: killToMe: " + Lastname + " " + p.Lastname); | ||
6812 | p.SendKillTo(this); | ||
6813 | } | ||
6814 | } | ||
6815 | |||
6816 | if (viewsToSendto.Count > 0) | ||
6817 | { | ||
6818 | foreach (ScenePresence p in viewsToSendto) | ||
6819 | { | ||
6820 | SendViewTo(p); | ||
6821 | } | ||
6822 | } | ||
6823 | |||
6824 | if (viewsToSendme.Count > 0 ) | ||
6825 | { | ||
6826 | foreach (ScenePresence p in viewsToSendme) | ||
6827 | { | ||
6828 | if (p.IsChildAgent) | ||
6829 | continue; | ||
6830 | // m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); | ||
6831 | p.SendViewTo(this); | ||
6832 | } | ||
6833 | } | ||
6834 | } | ||
6835 | |||
6836 | public void HasMovedAway(bool nearRegion) | ||
6837 | { | ||
6838 | |||
6839 | if (nearRegion) | ||
6840 | { | ||
6841 | if (Scene.AttachmentsModule != null) | ||
6842 | Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); | ||
6843 | |||
6844 | if (!ParcelHideThisAvatar || GodLevel >= 200) | ||
6845 | return; | ||
6846 | |||
6847 | List<ScenePresence> allpresences = m_scene.GetScenePresences(); | ||
6848 | foreach (ScenePresence p in allpresences) | ||
6849 | { | ||
6850 | if (p.IsDeleted || p == this || p.IsChildAgent || p.ControllingClient == null || !p.ControllingClient.IsActive) | ||
6851 | continue; | ||
6852 | |||
6853 | if (p.currentParcelUUID == m_currentParcelUUID) | ||
6854 | { | ||
6855 | p.SendKillTo(this); | ||
6856 | } | ||
6857 | } | ||
6858 | } | ||
6859 | else | ||
6860 | { | ||
6861 | List<ScenePresence> allpresences = m_scene.GetScenePresences(); | ||
6862 | foreach (ScenePresence p in allpresences) | ||
6863 | { | ||
6864 | if (p == this) | ||
6865 | continue; | ||
6866 | SendKillTo(p); | ||
6867 | if (!p.IsChildAgent) | ||
6868 | p.SendKillTo(this); | ||
6869 | } | ||
6870 | |||
6871 | if (Scene.AttachmentsModule != null) | ||
6872 | Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); | ||
6873 | } | ||
6874 | } | ||
6875 | |||
6876 | |||
6877 | // kill with attachs root kills | ||
6878 | public void SendKillTo(ScenePresence p) | ||
6879 | { | ||
6880 | List<uint> ids = new List<uint>(m_attachments.Count + 1); | ||
6881 | foreach (SceneObjectGroup sog in m_attachments) | ||
6882 | { | ||
6883 | ids.Add(sog.RootPart.LocalId); | ||
6884 | } | ||
6885 | |||
6886 | ids.Add(LocalId); | ||
6887 | p.ControllingClient.SendKillObject(ids); | ||
6888 | } | ||
6889 | |||
6890 | /* | ||
6891 | // kill with hack | ||
6892 | public void SendKillTo(ScenePresence p) | ||
6893 | { | ||
6894 | foreach (SceneObjectGroup sog in m_attachments) | ||
6895 | p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1); | ||
6896 | p.ControllingClient.SendKillObject(new List<uint> { LocalId }); | ||
6897 | } | ||
6898 | */ | ||
6899 | public void SendViewTo(ScenePresence p) | ||
6900 | { | ||
6901 | SendAvatarDataToAgentNF(p); | ||
6902 | SendAppearanceToAgent(p); | ||
6903 | if (Animator != null) | ||
6904 | Animator.SendAnimPackToClient(p.ControllingClient); | ||
6905 | SendAttachmentsToAgentNF(p); | ||
6906 | } | ||
6907 | |||
6908 | public void SetAnimationOverride(string animState, UUID animID) | ||
6909 | { | ||
6910 | Overrides.SetOverride(animState, animID); | ||
6911 | // Animator.SendAnimPack(); | ||
6912 | Animator.ForceUpdateMovementAnimations(); | ||
6913 | } | ||
6914 | |||
6915 | public UUID GetAnimationOverride(string animState) | ||
6916 | { | ||
6917 | return Overrides.GetOverriddenAnimation(animState); | ||
6918 | } | ||
5122 | } | 6919 | } |
5123 | } | 6920 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 4caa9cb..dc5de58 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -278,7 +278,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
278 | // Script state may, or may not, exist. Not having any, is NOT | 278 | // Script state may, or may not, exist. Not having any, is NOT |
279 | // ever a problem. | 279 | // ever a problem. |
280 | sceneObject.LoadScriptState(doc); | 280 | sceneObject.LoadScriptState(doc); |
281 | 281 | ||
282 | return sceneObject; | 282 | return sceneObject; |
283 | } | 283 | } |
284 | catch (Exception e) | 284 | catch (Exception e) |
@@ -307,14 +307,21 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
307 | } | 307 | } |
308 | } | 308 | } |
309 | 309 | ||
310 | <<<<<<< HEAD | ||
310 | 311 | ||
312 | ======= | ||
313 | >>>>>>> avn/ubitvar | ||
311 | /// <summary> | 314 | /// <summary> |
312 | /// Modifies a SceneObjectGroup. | 315 | /// Modifies a SceneObjectGroup. |
313 | /// </summary> | 316 | /// </summary> |
314 | /// <param name="sog">The object</param> | 317 | /// <param name="sog">The object</param> |
315 | /// <returns>Whether the object was actually modified</returns> | 318 | /// <returns>Whether the object was actually modified</returns> |
316 | public delegate bool SceneObjectModifier(SceneObjectGroup sog); | 319 | public delegate bool SceneObjectModifier(SceneObjectGroup sog); |
320 | <<<<<<< HEAD | ||
317 | 321 | ||
322 | ======= | ||
323 | |||
324 | >>>>>>> avn/ubitvar | ||
318 | /// <summary> | 325 | /// <summary> |
319 | /// Modifies an object by deserializing it; applying 'modifier' to each SceneObjectGroup; and reserializing. | 326 | /// Modifies an object by deserializing it; applying 'modifier' to each SceneObjectGroup; and reserializing. |
320 | /// </summary> | 327 | /// </summary> |
@@ -328,7 +335,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
328 | CoalescedSceneObjects coa = null; | 335 | CoalescedSceneObjects coa = null; |
329 | 336 | ||
330 | string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(data)); | 337 | string xmlData = ExternalRepresentationUtils.SanitizeXml(Utils.BytesToString(data)); |
338 | <<<<<<< HEAD | ||
331 | 339 | ||
340 | ======= | ||
341 | |||
342 | >>>>>>> avn/ubitvar | ||
332 | if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa)) | 343 | if (CoalescedSceneObjectsSerializer.TryFromXml(xmlData, out coa)) |
333 | { | 344 | { |
334 | // m_log.DebugFormat("[SERIALIZER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count); | 345 | // m_log.DebugFormat("[SERIALIZER]: Loaded coalescence {0} has {1} objects", assetId, coa.Count); |
@@ -373,7 +384,10 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
373 | 384 | ||
374 | return data; | 385 | return data; |
375 | } | 386 | } |
387 | <<<<<<< HEAD | ||
376 | 388 | ||
389 | ======= | ||
390 | >>>>>>> avn/ubitvar | ||
377 | 391 | ||
378 | #region manual serialization | 392 | #region manual serialization |
379 | 393 | ||
@@ -450,11 +464,27 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
450 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); | 464 | m_SOPXmlProcessors.Add("PayPrice3", ProcessPayPrice3); |
451 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); | 465 | m_SOPXmlProcessors.Add("PayPrice4", ProcessPayPrice4); |
452 | 466 | ||
467 | m_SOPXmlProcessors.Add("Buoyancy", ProcessBuoyancy); | ||
468 | m_SOPXmlProcessors.Add("Force", ProcessForce); | ||
469 | m_SOPXmlProcessors.Add("Torque", ProcessTorque); | ||
470 | m_SOPXmlProcessors.Add("VolumeDetectActive", ProcessVolumeDetectActive); | ||
471 | |||
472 | |||
473 | m_SOPXmlProcessors.Add("Vehicle", ProcessVehicle); | ||
474 | |||
453 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); | 475 | m_SOPXmlProcessors.Add("PhysicsShapeType", ProcessPhysicsShapeType); |
454 | m_SOPXmlProcessors.Add("Density", ProcessDensity); | 476 | m_SOPXmlProcessors.Add("Density", ProcessDensity); |
455 | m_SOPXmlProcessors.Add("Friction", ProcessFriction); | 477 | m_SOPXmlProcessors.Add("Friction", ProcessFriction); |
456 | m_SOPXmlProcessors.Add("Bounce", ProcessBounce); | 478 | m_SOPXmlProcessors.Add("Bounce", ProcessBounce); |
457 | m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); | 479 | m_SOPXmlProcessors.Add("GravityModifier", ProcessGravityModifier); |
480 | m_SOPXmlProcessors.Add("CameraEyeOffset", ProcessCameraEyeOffset); | ||
481 | m_SOPXmlProcessors.Add("CameraAtOffset", ProcessCameraAtOffset); | ||
482 | |||
483 | m_SOPXmlProcessors.Add("SoundID", ProcessSoundID); | ||
484 | m_SOPXmlProcessors.Add("SoundGain", ProcessSoundGain); | ||
485 | m_SOPXmlProcessors.Add("SoundFlags", ProcessSoundFlags); | ||
486 | m_SOPXmlProcessors.Add("SoundRadius", ProcessSoundRadius); | ||
487 | m_SOPXmlProcessors.Add("SoundQueueing", ProcessSoundQueueing); | ||
458 | 488 | ||
459 | #endregion | 489 | #endregion |
460 | 490 | ||
@@ -483,7 +513,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
483 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); | 513 | m_TaskInventoryXmlProcessors.Add("PermsMask", ProcessTIPermsMask); |
484 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); | 514 | m_TaskInventoryXmlProcessors.Add("Type", ProcessTIType); |
485 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); | 515 | m_TaskInventoryXmlProcessors.Add("OwnerChanged", ProcessTIOwnerChanged); |
486 | 516 | ||
487 | #endregion | 517 | #endregion |
488 | 518 | ||
489 | #region ShapeXmlProcessors initialization | 519 | #region ShapeXmlProcessors initialization |
@@ -709,7 +739,62 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
709 | obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); | 739 | obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty); |
710 | } | 740 | } |
711 | 741 | ||
742 | <<<<<<< HEAD | ||
712 | private static void ProcessShape(SceneObjectPart obj, XmlReader reader) | 743 | private static void ProcessShape(SceneObjectPart obj, XmlReader reader) |
744 | ======= | ||
745 | private static void ProcessCameraEyeOffset(SceneObjectPart obj, XmlTextReader reader) | ||
746 | { | ||
747 | obj.SetCameraEyeOffset(Util.ReadVector(reader, "CameraEyeOffset")); | ||
748 | } | ||
749 | |||
750 | private static void ProcessCameraAtOffset(SceneObjectPart obj, XmlTextReader reader) | ||
751 | { | ||
752 | obj.SetCameraAtOffset(Util.ReadVector(reader, "CameraAtOffset")); | ||
753 | } | ||
754 | |||
755 | private static void ProcessSoundID(SceneObjectPart obj, XmlTextReader reader) | ||
756 | { | ||
757 | obj.Sound = Util.ReadUUID(reader, "SoundID"); | ||
758 | } | ||
759 | |||
760 | private static void ProcessSoundGain(SceneObjectPart obj, XmlTextReader reader) | ||
761 | { | ||
762 | obj.SoundGain = reader.ReadElementContentAsDouble("SoundGain", String.Empty); | ||
763 | } | ||
764 | |||
765 | private static void ProcessSoundFlags(SceneObjectPart obj, XmlTextReader reader) | ||
766 | { | ||
767 | obj.SoundFlags = (byte)reader.ReadElementContentAsInt("SoundFlags", String.Empty); | ||
768 | } | ||
769 | |||
770 | private static void ProcessSoundRadius(SceneObjectPart obj, XmlTextReader reader) | ||
771 | { | ||
772 | obj.SoundRadius = reader.ReadElementContentAsDouble("SoundRadius", String.Empty); | ||
773 | } | ||
774 | |||
775 | private static void ProcessSoundQueueing(SceneObjectPart obj, XmlTextReader reader) | ||
776 | { | ||
777 | obj.SoundQueueing = Util.ReadBoolean(reader); | ||
778 | } | ||
779 | private static void ProcessVehicle(SceneObjectPart obj, XmlTextReader reader) | ||
780 | { | ||
781 | SOPVehicle vehicle = SOPVehicle.FromXml2(reader); | ||
782 | |||
783 | if (vehicle == null) | ||
784 | { | ||
785 | obj.VehicleParams = null; | ||
786 | m_log.DebugFormat( | ||
787 | "[SceneObjectSerializer]: Parsing Vehicle for object part {0} {1} encountered errors. Please see earlier log entries.", | ||
788 | obj.Name, obj.UUID); | ||
789 | } | ||
790 | else | ||
791 | { | ||
792 | obj.VehicleParams = vehicle; | ||
793 | } | ||
794 | } | ||
795 | |||
796 | private static void ProcessShape(SceneObjectPart obj, XmlTextReader reader) | ||
797 | >>>>>>> avn/ubitvar | ||
713 | { | 798 | { |
714 | List<string> errorNodeNames; | 799 | List<string> errorNodeNames; |
715 | obj.Shape = ReadShape(reader, "Shape", out errorNodeNames, obj); | 800 | obj.Shape = ReadShape(reader, "Shape", out errorNodeNames, obj); |
@@ -883,6 +968,25 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
883 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); | 968 | obj.PayPrice[4] = (int)reader.ReadElementContentAsInt("PayPrice4", String.Empty); |
884 | } | 969 | } |
885 | 970 | ||
971 | private static void ProcessBuoyancy(SceneObjectPart obj, XmlTextReader reader) | ||
972 | { | ||
973 | obj.Buoyancy = (float)reader.ReadElementContentAsFloat("Buoyancy", String.Empty); | ||
974 | } | ||
975 | |||
976 | private static void ProcessForce(SceneObjectPart obj, XmlTextReader reader) | ||
977 | { | ||
978 | obj.Force = Util.ReadVector(reader, "Force"); | ||
979 | } | ||
980 | private static void ProcessTorque(SceneObjectPart obj, XmlTextReader reader) | ||
981 | { | ||
982 | obj.Torque = Util.ReadVector(reader, "Torque"); | ||
983 | } | ||
984 | |||
985 | private static void ProcessVolumeDetectActive(SceneObjectPart obj, XmlTextReader reader) | ||
986 | { | ||
987 | obj.VolumeDetectActive = Util.ReadBoolean(reader); | ||
988 | } | ||
989 | |||
886 | #endregion | 990 | #endregion |
887 | 991 | ||
888 | #region TaskInventoryXmlProcessors | 992 | #region TaskInventoryXmlProcessors |
@@ -1271,12 +1375,13 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1271 | 1375 | ||
1272 | if (sog.RootPart.KeyframeMotion != null) | 1376 | if (sog.RootPart.KeyframeMotion != null) |
1273 | { | 1377 | { |
1274 | Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); | 1378 | Byte[] data = sog.RootPart.KeyframeMotion.Serialize(); |
1275 | 1379 | ||
1276 | writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); | 1380 | writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty); |
1277 | writer.WriteBase64(data, 0, data.Length); | 1381 | writer.WriteBase64(data, 0, data.Length); |
1278 | writer.WriteEndElement(); | 1382 | writer.WriteEndElement(); |
1279 | } | 1383 | } |
1384 | |||
1280 | 1385 | ||
1281 | writer.WriteEndElement(); | 1386 | writer.WriteEndElement(); |
1282 | } | 1387 | } |
@@ -1388,8 +1493,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1388 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); | 1493 | writer.WriteElementString("PayPrice3", sop.PayPrice[3].ToString()); |
1389 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); | 1494 | writer.WriteElementString("PayPrice4", sop.PayPrice[4].ToString()); |
1390 | 1495 | ||
1391 | if(sop.PhysicsShapeType != sop.DefaultPhysicsShapeType()) | 1496 | writer.WriteElementString("Buoyancy", sop.Buoyancy.ToString()); |
1392 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); | 1497 | |
1498 | WriteVector(writer, "Force", sop.Force); | ||
1499 | WriteVector(writer, "Torque", sop.Torque); | ||
1500 | |||
1501 | writer.WriteElementString("VolumeDetectActive", sop.VolumeDetectActive.ToString().ToLower()); | ||
1502 | |||
1503 | if (sop.VehicleParams != null) | ||
1504 | sop.VehicleParams.ToXml2(writer); | ||
1505 | |||
1506 | writer.WriteElementString("PhysicsShapeType", sop.PhysicsShapeType.ToString().ToLower()); | ||
1393 | if (sop.Density != 1000.0f) | 1507 | if (sop.Density != 1000.0f) |
1394 | writer.WriteElementString("Density", sop.Density.ToString().ToLower()); | 1508 | writer.WriteElementString("Density", sop.Density.ToString().ToLower()); |
1395 | if (sop.Friction != 0.6f) | 1509 | if (sop.Friction != 0.6f) |
@@ -1398,7 +1512,18 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1398 | writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); | 1512 | writer.WriteElementString("Bounce", sop.Restitution.ToString().ToLower()); |
1399 | if (sop.GravityModifier != 1.0f) | 1513 | if (sop.GravityModifier != 1.0f) |
1400 | writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); | 1514 | writer.WriteElementString("GravityModifier", sop.GravityModifier.ToString().ToLower()); |
1515 | WriteVector(writer, "CameraEyeOffset", sop.GetCameraEyeOffset()); | ||
1516 | WriteVector(writer, "CameraAtOffset", sop.GetCameraAtOffset()); | ||
1401 | 1517 | ||
1518 | // if (sop.Sound != UUID.Zero) force it till sop crossing does clear it on child prim | ||
1519 | { | ||
1520 | WriteUUID(writer, "SoundID", sop.Sound, options); | ||
1521 | writer.WriteElementString("SoundGain", sop.SoundGain.ToString().ToLower()); | ||
1522 | writer.WriteElementString("SoundFlags", sop.SoundFlags.ToString().ToLower()); | ||
1523 | writer.WriteElementString("SoundRadius", sop.SoundRadius.ToString().ToLower()); | ||
1524 | } | ||
1525 | writer.WriteElementString("SoundQueueing", sop.SoundQueueing.ToString().ToLower()); | ||
1526 | |||
1402 | writer.WriteEndElement(); | 1527 | writer.WriteEndElement(); |
1403 | } | 1528 | } |
1404 | 1529 | ||
@@ -1625,12 +1750,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1625 | { | 1750 | { |
1626 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); | 1751 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); |
1627 | 1752 | ||
1628 | if (reader.IsEmptyElement) | ||
1629 | { | ||
1630 | reader.Read(); | ||
1631 | return tinv; | ||
1632 | } | ||
1633 | |||
1634 | reader.ReadStartElement(name, String.Empty); | 1753 | reader.ReadStartElement(name, String.Empty); |
1635 | 1754 | ||
1636 | while (reader.Name == "TaskInventoryItem") | 1755 | while (reader.Name == "TaskInventoryItem") |
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 2174e51..52e3ff1 100755 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |||
@@ -184,7 +184,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
184 | 184 | ||
185 | // saved last reported value so there is something available for llGetRegionFPS | 185 | // saved last reported value so there is something available for llGetRegionFPS |
186 | private float lastReportedSimFPS; | 186 | private float lastReportedSimFPS; |
187 | <<<<<<< HEAD | ||
187 | private float[] lastReportedSimStats = new float[m_statisticArraySize]; | 188 | private float[] lastReportedSimStats = new float[m_statisticArraySize]; |
189 | ======= | ||
190 | private float[] lastReportedSimStats = new float[23]; | ||
191 | >>>>>>> avn/ubitvar | ||
188 | private float m_pfps; | 192 | private float m_pfps; |
189 | 193 | ||
190 | /// <summary> | 194 | /// <summary> |
@@ -198,13 +202,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
198 | private int m_objectUpdates; | 202 | private int m_objectUpdates; |
199 | 203 | ||
200 | private int m_frameMS; | 204 | private int m_frameMS; |
201 | private int m_spareMS; | 205 | |
202 | private int m_netMS; | 206 | private int m_netMS; |
203 | private int m_agentMS; | 207 | private int m_agentMS; |
204 | private int m_physicsMS; | 208 | private int m_physicsMS; |
205 | private int m_imageMS; | 209 | private int m_imageMS; |
206 | private int m_otherMS; | 210 | private int m_otherMS; |
211 | <<<<<<< HEAD | ||
207 | private int m_scriptMS; | 212 | private int m_scriptMS; |
213 | ======= | ||
214 | private int m_sleeptimeMS; | ||
215 | |||
216 | //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. | ||
217 | //Ckrinke private int m_scriptMS = 0; | ||
218 | >>>>>>> avn/ubitvar | ||
208 | 219 | ||
209 | private int m_rootAgents; | 220 | private int m_rootAgents; |
210 | private int m_childAgents; | 221 | private int m_childAgents; |
@@ -355,11 +366,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
355 | if (!m_scene.Active) | 366 | if (!m_scene.Active) |
356 | return; | 367 | return; |
357 | 368 | ||
369 | <<<<<<< HEAD | ||
358 | // Create arrays to hold the statistics for this current scene, | 370 | // Create arrays to hold the statistics for this current scene, |
359 | // these will be passed to the SimExtraStatsCollector, they are also | 371 | // these will be passed to the SimExtraStatsCollector, they are also |
360 | // sent to the SimStats class | 372 | // sent to the SimStats class |
361 | SimStatsPacket.StatBlock[] sb = new | 373 | SimStatsPacket.StatBlock[] sb = new |
362 | SimStatsPacket.StatBlock[m_statisticArraySize]; | 374 | SimStatsPacket.StatBlock[m_statisticArraySize]; |
375 | ======= | ||
376 | SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; | ||
377 | >>>>>>> avn/ubitvar | ||
363 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); | 378 | SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); |
364 | 379 | ||
365 | // Know what's not thread safe in Mono... modifying timers. | 380 | // Know what's not thread safe in Mono... modifying timers. |
@@ -404,6 +419,35 @@ namespace OpenSim.Region.Framework.Scenes | |||
404 | physfps = 0; | 419 | physfps = 0; |
405 | 420 | ||
406 | #endregion | 421 | #endregion |
422 | float factor = 1 / m_statsUpdateFactor; | ||
423 | |||
424 | if (reportedFPS <= 0) | ||
425 | reportedFPS = 1; | ||
426 | |||
427 | float perframe = 1.0f / (float)reportedFPS; | ||
428 | |||
429 | float TotalFrameTime = m_frameMS * perframe; | ||
430 | |||
431 | float targetframetime = 1100.0f / (float)m_nominalReportedFps; | ||
432 | |||
433 | float sparetime; | ||
434 | float sleeptime; | ||
435 | |||
436 | if (TotalFrameTime > targetframetime) | ||
437 | { | ||
438 | sparetime = 0; | ||
439 | sleeptime = 0; | ||
440 | } | ||
441 | else | ||
442 | { | ||
443 | sparetime = m_frameMS - m_physicsMS - m_agentMS; | ||
444 | sparetime *= perframe; | ||
445 | if (sparetime < 0) | ||
446 | sparetime = 0; | ||
447 | else if (sparetime > TotalFrameTime) | ||
448 | sparetime = TotalFrameTime; | ||
449 | sleeptime = m_sleeptimeMS * perframe; | ||
450 | } | ||
407 | 451 | ||
408 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); | 452 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); |
409 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); | 453 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); |
@@ -417,16 +461,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
417 | // so that stat numbers are always consistent. | 461 | // so that stat numbers are always consistent. |
418 | CheckStatSanity(); | 462 | CheckStatSanity(); |
419 | 463 | ||
420 | //Our time dilation is 0.91 when we're running a full speed, | 464 | // other MS is actually simulation time |
421 | // therefore to make sure we get an appropriate range, | 465 | // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; |
422 | // we have to factor in our error. (0.10f * statsUpdateFactor) | 466 | // m_imageMS m_netMS are not included in m_frameMS |
423 | // multiplies the fix for the error times the amount of times it'll occur a second | ||
424 | // / 10 divides the value by the number of times the sim heartbeat runs (10fps) | ||
425 | // Then we divide the whole amount by the amount of seconds pass in between stats updates. | ||
426 | |||
427 | // 'statsUpdateFactor' is how often stats packets are sent in seconds. Used below to change | ||
428 | // values to X-per-second values. | ||
429 | 467 | ||
468 | <<<<<<< HEAD | ||
430 | uint thisFrame = m_scene.Frame; | 469 | uint thisFrame = m_scene.Frame; |
431 | uint numFrames = thisFrame - m_lastUpdateFrame; | 470 | uint numFrames = thisFrame - m_lastUpdateFrame; |
432 | float framesUpdated = (float)numFrames * m_reportedFpsCorrectionFactor; | 471 | float framesUpdated = (float)numFrames * m_reportedFpsCorrectionFactor; |
@@ -437,6 +476,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
437 | framesUpdated = 1; | 476 | framesUpdated = 1; |
438 | 477 | ||
439 | for (int i = 0; i < m_statisticArraySize; i++) | 478 | for (int i = 0; i < m_statisticArraySize; i++) |
479 | ======= | ||
480 | m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; | ||
481 | if (m_otherMS < 0) | ||
482 | m_otherMS = 0; | ||
483 | |||
484 | for (int i = 0; i < 23; i++) | ||
485 | >>>>>>> avn/ubitvar | ||
440 | { | 486 | { |
441 | sb[i] = new SimStatsPacket.StatBlock(); | 487 | sb[i] = new SimStatsPacket.StatBlock(); |
442 | } | 488 | } |
@@ -501,6 +547,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
501 | // ORIGINAL code commented out until we have time to add our own | 547 | // ORIGINAL code commented out until we have time to add our own |
502 | // statistics to the statistics window | 548 | // statistics to the statistics window |
503 | sb[8].StatID = (uint)Stats.FrameMS; | 549 | sb[8].StatID = (uint)Stats.FrameMS; |
550 | <<<<<<< HEAD | ||
504 | //sb[8].StatValue = m_frameMS / framesUpdated; | 551 | //sb[8].StatValue = m_frameMS / framesUpdated; |
505 | sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored; | 552 | sb[8].StatValue = (float) totalSumFrameTime / m_numberFramesStored; |
506 | 553 | ||
@@ -511,13 +558,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
511 | sb[10].StatID = (uint)Stats.PhysicsMS; | 558 | sb[10].StatID = (uint)Stats.PhysicsMS; |
512 | //sb[10].StatValue = m_physicsMS / framesUpdated; | 559 | //sb[10].StatValue = m_physicsMS / framesUpdated; |
513 | sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored; | 560 | sb[10].StatValue = (float) physicsSumFrameTime / m_numberFramesStored; |
561 | ======= | ||
562 | sb[8].StatValue = TotalFrameTime; | ||
563 | |||
564 | sb[9].StatID = (uint)Stats.NetMS; | ||
565 | sb[9].StatValue = m_netMS * perframe; | ||
566 | |||
567 | sb[10].StatID = (uint)Stats.PhysicsMS; | ||
568 | sb[10].StatValue = m_physicsMS * perframe; | ||
569 | >>>>>>> avn/ubitvar | ||
514 | 570 | ||
515 | sb[11].StatID = (uint)Stats.ImageMS ; | 571 | sb[11].StatID = (uint)Stats.ImageMS ; |
516 | sb[11].StatValue = m_imageMS / framesUpdated; | 572 | sb[11].StatValue = m_imageMS * perframe; |
517 | 573 | ||
518 | sb[12].StatID = (uint)Stats.OtherMS; | 574 | sb[12].StatID = (uint)Stats.OtherMS; |
575 | <<<<<<< HEAD | ||
519 | //sb[12].StatValue = m_otherMS / framesUpdated; | 576 | //sb[12].StatValue = m_otherMS / framesUpdated; |
520 | sb[12].StatValue = (float) simulationSumFrameTime / m_numberFramesStored; | 577 | sb[12].StatValue = (float) simulationSumFrameTime / m_numberFramesStored; |
578 | ======= | ||
579 | sb[12].StatValue = m_otherMS * perframe; | ||
580 | >>>>>>> avn/ubitvar | ||
521 | 581 | ||
522 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; | 582 | sb[13].StatID = (uint)Stats.InPacketsPerSecond; |
523 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); | 583 | sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); |
@@ -529,7 +589,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
529 | sb[15].StatValue = m_unAckedBytes; | 589 | sb[15].StatValue = m_unAckedBytes; |
530 | 590 | ||
531 | sb[16].StatID = (uint)Stats.AgentMS; | 591 | sb[16].StatID = (uint)Stats.AgentMS; |
532 | sb[16].StatValue = m_agentMS / framesUpdated; | 592 | sb[16].StatValue = m_agentMS * perframe; |
533 | 593 | ||
534 | sb[17].StatID = (uint)Stats.PendingDownloads; | 594 | sb[17].StatID = (uint)Stats.PendingDownloads; |
535 | sb[17].StatValue = m_pendingDownloads; | 595 | sb[17].StatValue = m_pendingDownloads; |
@@ -544,7 +604,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
544 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; | 604 | sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; |
545 | 605 | ||
546 | sb[21].StatID = (uint)Stats.SimSpareMs; | 606 | sb[21].StatID = (uint)Stats.SimSpareMs; |
547 | sb[21].StatValue = m_spareMS / framesUpdated; | 607 | sb[21].StatValue = sparetime; |
608 | |||
609 | sb[22].StatID = (uint)Stats.SimSleepMs; | ||
610 | sb[22].StatValue = sleeptime; | ||
548 | 611 | ||
549 | // Current ratio between the sum of physics and sim rate, and the | 612 | // Current ratio between the sum of physics and sim rate, and the |
550 | // minimum time to run a scene's frame | 613 | // minimum time to run a scene's frame |
@@ -587,28 +650,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
587 | } | 650 | } |
588 | 651 | ||
589 | // Extra statistics that aren't currently sent to clients | 652 | // Extra statistics that aren't currently sent to clients |
590 | lock (m_lastReportedExtraSimStats) | 653 | if (m_scene.PhysicsScene != null) |
591 | { | 654 | { |
592 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; | 655 | lock (m_lastReportedExtraSimStats) |
593 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
594 | |||
595 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
596 | |||
597 | if (physicsStats != null) | ||
598 | { | 656 | { |
599 | foreach (KeyValuePair<string, float> tuple in physicsStats) | 657 | m_lastReportedExtraSimStats[LastReportedObjectUpdateStatName] = m_objectUpdates / m_statsUpdateFactor; |
658 | m_lastReportedExtraSimStats[SlowFramesStat.ShortName] = (float)SlowFramesStat.Value; | ||
659 | |||
660 | Dictionary<string, float> physicsStats = m_scene.PhysicsScene.GetStats(); | ||
661 | |||
662 | if (physicsStats != null) | ||
600 | { | 663 | { |
601 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second | 664 | foreach (KeyValuePair<string, float> tuple in physicsStats) |
602 | // Need to change things so that stats source can indicate whether they are per second or | 665 | { |
603 | // per frame. | 666 | // FIXME: An extremely dirty hack to divide MS stats per frame rather than per second |
604 | if (tuple.Key.EndsWith("MS")) | 667 | // Need to change things so that stats source can indicate whether they are per second or |
605 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; | 668 | // per frame. |
606 | else | 669 | if (tuple.Key.EndsWith("MS")) |
607 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | 670 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; |
671 | else | ||
672 | m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; | ||
673 | } | ||
608 | } | 674 | } |
609 | } | 675 | } |
610 | } | 676 | } |
611 | 677 | ||
678 | // LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor; | ||
612 | ResetValues(); | 679 | ResetValues(); |
613 | } | 680 | } |
614 | } | 681 | } |
@@ -635,8 +702,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
635 | m_physicsMS = 0; | 702 | m_physicsMS = 0; |
636 | m_imageMS = 0; | 703 | m_imageMS = 0; |
637 | m_otherMS = 0; | 704 | m_otherMS = 0; |
705 | <<<<<<< HEAD | ||
638 | m_scriptMS = 0; | 706 | m_scriptMS = 0; |
639 | m_spareMS = 0; | 707 | m_spareMS = 0; |
708 | ======= | ||
709 | // m_spareMS = 0; | ||
710 | m_sleeptimeMS = 0; | ||
711 | |||
712 | //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. | ||
713 | //Ckrinke m_scriptMS = 0; | ||
714 | >>>>>>> avn/ubitvar | ||
640 | } | 715 | } |
641 | 716 | ||
642 | # region methods called from Scene | 717 | # region methods called from Scene |
@@ -717,11 +792,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
717 | SlowFramesStat.Value++; | 792 | SlowFramesStat.Value++; |
718 | } | 793 | } |
719 | 794 | ||
720 | public void AddSpareMS(int ms) | ||
721 | { | ||
722 | m_spareMS += ms; | ||
723 | } | ||
724 | |||
725 | public void addNetMS(int ms) | 795 | public void addNetMS(int ms) |
726 | { | 796 | { |
727 | m_netMS += ms; | 797 | m_netMS += ms; |
@@ -747,6 +817,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
747 | m_otherMS += ms; | 817 | m_otherMS += ms; |
748 | } | 818 | } |
749 | 819 | ||
820 | <<<<<<< HEAD | ||
750 | public void AddScriptMS(int ms) | 821 | public void AddScriptMS(int ms) |
751 | { | 822 | { |
752 | m_scriptMS += ms; | 823 | m_scriptMS += ms; |
@@ -776,6 +847,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
776 | // first, the next location needs to loop back to the beginning of the | 847 | // first, the next location needs to loop back to the beginning of the |
777 | // list whenever it reaches the end | 848 | // list whenever it reaches the end |
778 | m_nextLocation = m_nextLocation % m_numberFramesStored; | 849 | m_nextLocation = m_nextLocation % m_numberFramesStored; |
850 | ======= | ||
851 | public void addSleepMS(int ms) | ||
852 | { | ||
853 | m_sleeptimeMS += ms; | ||
854 | >>>>>>> avn/ubitvar | ||
779 | } | 855 | } |
780 | 856 | ||
781 | public void AddPendingDownloads(int count) | 857 | public void AddPendingDownloads(int count) |
diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index 3d563a6..6fd9096 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs | |||
@@ -49,6 +49,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
49 | { | 49 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | private static string LogHeader = "[TERRAIN CHANNEL]"; | 51 | private static string LogHeader = "[TERRAIN CHANNEL]"; |
52 | <<<<<<< HEAD | ||
52 | 53 | ||
53 | protected TerrainData m_terrainData; | 54 | protected TerrainData m_terrainData; |
54 | 55 | ||
@@ -57,6 +58,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
57 | public int Height { get { return m_terrainData.SizeY; } } // Y dimension | 58 | public int Height { get { return m_terrainData.SizeY; } } // Y dimension |
58 | public int Altitude { get { return m_terrainData.SizeZ; } } // Y dimension | 59 | public int Altitude { get { return m_terrainData.SizeZ; } } // Y dimension |
59 | 60 | ||
61 | ======= | ||
62 | |||
63 | protected TerrainData m_terrainData; | ||
64 | |||
65 | public int Width { get { return m_terrainData.SizeX; } } // X dimension | ||
66 | // Unfortunately, for historical reasons, in this module 'Width' is X and 'Height' is Y | ||
67 | public int Height { get { return m_terrainData.SizeY; } } // Y dimension | ||
68 | public int Altitude { get { return m_terrainData.SizeZ; } } // Y dimension | ||
69 | |||
70 | >>>>>>> avn/ubitvar | ||
60 | // Default, not-often-used builder | 71 | // Default, not-often-used builder |
61 | public TerrainChannel() | 72 | public TerrainChannel() |
62 | { | 73 | { |
@@ -157,7 +168,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
157 | { | 168 | { |
158 | if (Double.IsNaN(value) || Double.IsInfinity(value)) | 169 | if (Double.IsNaN(value) || Double.IsInfinity(value)) |
159 | return; | 170 | return; |
160 | 171 | <<<<<<< HEAD | |
172 | |||
173 | ======= | ||
174 | if (value < 0) | ||
175 | value = 0; | ||
176 | else | ||
177 | if (value > 655.35) | ||
178 | value = 655.35; | ||
179 | >>>>>>> avn/ubitvar | ||
161 | m_terrainData[x, y] = (float)value; | 180 | m_terrainData[x, y] = (float)value; |
162 | } | 181 | } |
163 | } | 182 | } |
@@ -363,8 +382,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
363 | public int SizeY; | 382 | public int SizeY; |
364 | public int SizeZ; | 383 | public int SizeZ; |
365 | public float CompressionFactor; | 384 | public float CompressionFactor; |
385 | <<<<<<< HEAD | ||
366 | public int[] Map; | 386 | public int[] Map; |
367 | public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, int[] pMap) | 387 | public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, int[] pMap) |
388 | ======= | ||
389 | public float[] Map; | ||
390 | public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, float[] pMap) | ||
391 | >>>>>>> avn/ubitvar | ||
368 | { | 392 | { |
369 | Version = 1; | 393 | Version = 1; |
370 | SizeX = pX; | 394 | SizeX = pX; |
@@ -395,10 +419,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
395 | // Fill the heightmap with the center bump terrain | 419 | // Fill the heightmap with the center bump terrain |
396 | private void PinHeadIsland() | 420 | private void PinHeadIsland() |
397 | { | 421 | { |
422 | <<<<<<< HEAD | ||
423 | ======= | ||
424 | float cx = m_terrainData.SizeX * 0.5f; | ||
425 | float cy = m_terrainData.SizeY * 0.5f; | ||
426 | float h; | ||
427 | >>>>>>> avn/ubitvar | ||
398 | for (int x = 0; x < Width; x++) | 428 | for (int x = 0; x < Width; x++) |
399 | { | 429 | { |
400 | for (int y = 0; y < Height; y++) | 430 | for (int y = 0; y < Height; y++) |
401 | { | 431 | { |
432 | <<<<<<< HEAD | ||
402 | m_terrainData[x, y] = (float)TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; | 433 | m_terrainData[x, y] = (float)TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; |
403 | float spherFacA = (float)(TerrainUtil.SphericalFactor(x, y, m_terrainData.SizeX / 2.0, m_terrainData.SizeY / 2.0, 50) * 0.01d); | 434 | float spherFacA = (float)(TerrainUtil.SphericalFactor(x, y, m_terrainData.SizeX / 2.0, m_terrainData.SizeY / 2.0, 50) * 0.01d); |
404 | float spherFacB = (float)(TerrainUtil.SphericalFactor(x, y, m_terrainData.SizeX / 2.0, m_terrainData.SizeY / 2.0, 100) * 0.001d); | 435 | float spherFacB = (float)(TerrainUtil.SphericalFactor(x, y, m_terrainData.SizeX / 2.0, m_terrainData.SizeY / 2.0, 100) * 0.001d); |
@@ -406,6 +437,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
406 | m_terrainData[x, y]= spherFacA; | 437 | m_terrainData[x, y]= spherFacA; |
407 | if (m_terrainData[x, y]< spherFacB) | 438 | if (m_terrainData[x, y]< spherFacB) |
408 | m_terrainData[x, y] = spherFacB; | 439 | m_terrainData[x, y] = spherFacB; |
440 | ======= | ||
441 | // h = (float)TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; | ||
442 | h = 1.0f; | ||
443 | float spherFacA = (float)(TerrainUtil.SphericalFactor(x, y, cx, cy, 50) * 0.01d); | ||
444 | float spherFacB = (float)(TerrainUtil.SphericalFactor(x, y, cx, cy, 100) * 0.001d); | ||
445 | if (h < spherFacA) | ||
446 | h = spherFacA; | ||
447 | if (h < spherFacB) | ||
448 | h = spherFacB; | ||
449 | m_terrainData[x, y] = h; | ||
450 | >>>>>>> avn/ubitvar | ||
409 | } | 451 | } |
410 | } | 452 | } |
411 | } | 453 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index 558ba2c..b7e9499 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs | |||
@@ -82,8 +82,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
82 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 82 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
83 | 83 | ||
84 | TestScene scene = new SceneHelpers().SetupScene(); | 84 | TestScene scene = new SceneHelpers().SetupScene(); |
85 | SceneHelpers.SetupSceneModules(scene, new PermissionsModule()); | 85 | IConfigSource configSource = new IniConfigSource(); |
86 | TestClient client = (TestClient)SceneHelpers.AddScenePresence(scene, userId).ControllingClient; | 86 | IConfig config = configSource.AddConfig("Startup"); |
87 | config.Set("serverside_object_permissions", true); | ||
88 | SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new DefaultPermissionsModule() }); | ||
89 | IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; | ||
87 | 90 | ||
88 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | 91 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. |
89 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | 92 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; |
@@ -105,9 +108,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
105 | 108 | ||
106 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | 109 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); |
107 | Assert.That(retrievedPart2, Is.Null); | 110 | Assert.That(retrievedPart2, Is.Null); |
108 | |||
109 | Assert.That(client.ReceivedKills.Count, Is.EqualTo(1)); | ||
110 | Assert.That(client.ReceivedKills[0], Is.EqualTo(soLocalId)); | ||
111 | } | 111 | } |
112 | 112 | ||
113 | /// <summary> | 113 | /// <summary> |
@@ -134,7 +134,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
134 | SceneHelpers.SetupSceneModules(sceneB, config, etmB); | 134 | SceneHelpers.SetupSceneModules(sceneB, config, etmB); |
135 | 135 | ||
136 | // We need this for derez | 136 | // We need this for derez |
137 | SceneHelpers.SetupSceneModules(sceneA, new PermissionsModule()); | 137 | //SceneHelpers.SetupSceneModules(sceneA, new PermissionsModule()); |
138 | 138 | ||
139 | UserAccount uaA = UserAccountHelpers.CreateUserWithInventory(sceneA, "Andy", "AAA", 0x1, ""); | 139 | UserAccount uaA = UserAccountHelpers.CreateUserWithInventory(sceneA, "Andy", "AAA", 0x1, ""); |
140 | UserAccount uaB = UserAccountHelpers.CreateUserWithInventory(sceneA, "Brian", "BBB", 0x2, ""); | 140 | UserAccount uaB = UserAccountHelpers.CreateUserWithInventory(sceneA, "Brian", "BBB", 0x2, ""); |
@@ -154,12 +154,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
154 | uint soLocalId = so.LocalId; | 154 | uint soLocalId = so.LocalId; |
155 | 155 | ||
156 | sceneA.DeleteSceneObject(so, false); | 156 | sceneA.DeleteSceneObject(so, false); |
157 | |||
158 | Assert.That(clientA.ReceivedKills.Count, Is.EqualTo(1)); | ||
159 | Assert.That(clientA.ReceivedKills[0], Is.EqualTo(soLocalId)); | ||
160 | |||
161 | Assert.That(childClientsB[0].ReceivedKills.Count, Is.EqualTo(1)); | ||
162 | Assert.That(childClientsB[0].ReceivedKills[0], Is.EqualTo(soLocalId)); | ||
163 | } | 157 | } |
164 | 158 | ||
165 | /// <summary> | 159 | /// <summary> |
@@ -178,7 +172,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
178 | UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); | 172 | UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001"); |
179 | 173 | ||
180 | TestScene scene = new SceneHelpers().SetupScene(); | 174 | TestScene scene = new SceneHelpers().SetupScene(); |
181 | SceneHelpers.SetupSceneModules(scene, new PermissionsModule()); | 175 | IConfigSource configSource = new IniConfigSource(); |
176 | IConfig config = configSource.AddConfig("Startup"); | ||
177 | config.Set("serverside_object_permissions", true); | ||
178 | SceneHelpers.SetupSceneModules(scene, configSource, new object[] { new DefaultPermissionsModule() }); | ||
182 | IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; | 179 | IClientAPI client = SceneHelpers.AddScenePresence(scene, userId).ControllingClient; |
183 | 180 | ||
184 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | 181 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. |
@@ -261,4 +258,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
261 | // Assert.That(retrievedPart, Is.Null); | 258 | // Assert.That(retrievedPart, Is.Null); |
262 | } | 259 | } |
263 | } | 260 | } |
264 | } \ No newline at end of file | 261 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index 11e9084..ce7fc0e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs | |||
@@ -61,6 +61,8 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
61 | Assert.That(g1Post.RootPart.Scale.X, Is.EqualTo(2)); | 61 | Assert.That(g1Post.RootPart.Scale.X, Is.EqualTo(2)); |
62 | Assert.That(g1Post.RootPart.Scale.Y, Is.EqualTo(3)); | 62 | Assert.That(g1Post.RootPart.Scale.Y, Is.EqualTo(3)); |
63 | Assert.That(g1Post.RootPart.Scale.Z, Is.EqualTo(4)); | 63 | Assert.That(g1Post.RootPart.Scale.Z, Is.EqualTo(4)); |
64 | |||
65 | Assert.That(g1Post.RootPart.UndoCount, Is.EqualTo(1)); | ||
64 | } | 66 | } |
65 | 67 | ||
66 | /// <summary> | 68 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs index fd49c88..32d6649 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs | |||
@@ -43,7 +43,7 @@ using OpenSim.Tests.Common; | |||
43 | namespace OpenSim.Region.Framework.Scenes.Tests | 43 | namespace OpenSim.Region.Framework.Scenes.Tests |
44 | { | 44 | { |
45 | [TestFixture] | 45 | [TestFixture] |
46 | public class SceneObjectUserGroupTests : OpenSimTestCase | 46 | public class SceneObjectUserGroupTests |
47 | { | 47 | { |
48 | /// <summary> | 48 | /// <summary> |
49 | /// Test share with group object functionality | 49 | /// Test share with group object functionality |
@@ -53,6 +53,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
53 | public void TestShareWithGroup() | 53 | public void TestShareWithGroup() |
54 | { | 54 | { |
55 | TestHelpers.InMethod(); | 55 | TestHelpers.InMethod(); |
56 | // log4net.Config.XmlConfigurator.Configure(); | ||
56 | 57 | ||
57 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); | 58 | UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); |
58 | 59 | ||
@@ -69,7 +70,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
69 | 70 | ||
70 | SceneHelpers.SetupSceneModules( | 71 | SceneHelpers.SetupSceneModules( |
71 | scene, configSource, new object[] | 72 | scene, configSource, new object[] |
72 | { new PermissionsModule(), | 73 | { new DefaultPermissionsModule(), |
73 | new GroupsModule(), | 74 | new GroupsModule(), |
74 | new MockGroupsServicesConnector() }); | 75 | new MockGroupsServicesConnector() }); |
75 | 76 | ||
@@ -80,4 +81,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
80 | groupsModule.CreateGroup(client, "group1", "To boldly go", true, UUID.Zero, 5, true, true, true); | 81 | groupsModule.CreateGroup(client, "group1", "To boldly go", true, UUID.Zero, 5, true, true, true); |
81 | } | 82 | } |
82 | } | 83 | } |
83 | } \ No newline at end of file | 84 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs index cca30db..45bfbff 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs | |||
@@ -74,14 +74,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
74 | SceneHelpers.SetupSceneModules(scene, capsMod); | 74 | SceneHelpers.SetupSceneModules(scene, capsMod); |
75 | 75 | ||
76 | ScenePresence sp = SceneHelpers.AddChildScenePresence(scene, spUuid); | 76 | ScenePresence sp = SceneHelpers.AddChildScenePresence(scene, spUuid); |
77 | Assert.That(capsMod.GetCapsForUser(spUuid), Is.Not.Null); | 77 | //Assert.That(capsMod.GetCapsForUser(spUuid), Is.Not.Null); |
78 | 78 | ||
79 | // TODO: Need to add tests for other ICapabiltiesModule methods. | 79 | // TODO: Need to add tests for other ICapabiltiesModule methods. |
80 | 80 | ||
81 | // scene.IncomingCloseAgent(sp.UUID, false); | ||
82 | // //Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null); | ||
81 | scene.CloseAgent(sp.UUID, false); | 83 | scene.CloseAgent(sp.UUID, false); |
82 | Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null); | 84 | // Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null); |
83 | 85 | ||
84 | // TODO: Need to add tests for other ICapabiltiesModule methods. | 86 | // TODO: Need to add tests for other ICapabiltiesModule methods. |
85 | } | 87 | } |
86 | } | 88 | } |
87 | } \ No newline at end of file | 89 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs index e14da8b..c193a97 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs | |||
@@ -191,7 +191,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
191 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny | 191 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny |
192 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default | 192 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default |
193 | // IsAdministrator if no permissions module is present is true. | 193 | // IsAdministrator if no permissions module is present is true. |
194 | SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new PermissionsModule(), etmB); | 194 | // SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new PermissionsModule(), etmB); |
195 | 195 | ||
196 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); | 196 | AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId); |
197 | TestClient tc = new TestClient(acd, sceneA); | 197 | TestClient tc = new TestClient(acd, sceneA); |
@@ -245,4 +245,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
245 | Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True); | 245 | Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | } \ No newline at end of file | 248 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index da93d44..42276dd 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |||
@@ -281,7 +281,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
281 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny | 281 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny |
282 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default | 282 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default |
283 | // IsAdministrator if no permissions module is present is true. | 283 | // IsAdministrator if no permissions module is present is true. |
284 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB }); | 284 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new DefaultPermissionsModule(), etmB }); |
285 | 285 | ||
286 | // Shared scene modules | 286 | // Shared scene modules |
287 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); | 287 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); |
@@ -446,7 +446,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
446 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny | 446 | // We need to set up the permisions module on scene B so that our later use of agent limit to deny |
447 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default | 447 | // QueryAccess won't succeed anyway because administrators are always allowed in and the default |
448 | // IsAdministrator if no permissions module is present is true. | 448 | // IsAdministrator if no permissions module is present is true. |
449 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new PermissionsModule(), etmB }); | 449 | SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new DefaultPermissionsModule(), etmB }); |
450 | 450 | ||
451 | // Shared scene modules | 451 | // Shared scene modules |
452 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); | 452 | SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); |
@@ -659,4 +659,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
659 | // TestHelpers.DisableLogging(); | 659 | // TestHelpers.DisableLogging(); |
660 | } | 660 | } |
661 | } | 661 | } |
662 | } \ No newline at end of file | 662 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 8ec6974..3caea8b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | |||
@@ -96,7 +96,7 @@ namespace OpenSim.Region.Framework.Tests | |||
96 | Quaternion rezRot = new Quaternion(0.5f, 0.5f, 0.5f, 0.5f); | 96 | Quaternion rezRot = new Quaternion(0.5f, 0.5f, 0.5f, 0.5f); |
97 | Vector3 rezVel = new Vector3(2, 2, 2); | 97 | Vector3 rezVel = new Vector3(2, 2, 2); |
98 | 98 | ||
99 | scene.RezObject(sop1, taskSceneObjectItem, rezPos, rezRot, rezVel, 0); | 99 | scene.RezObject(sop1, taskSceneObjectItem, rezPos, rezRot, rezVel, 0,false); |
100 | 100 | ||
101 | SceneObjectGroup rezzedObject = scene.GetSceneObjectGroup("tso"); | 101 | SceneObjectGroup rezzedObject = scene.GetSceneObjectGroup("tso"); |
102 | 102 | ||
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 9ec4e1d..25bbd3a 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -120,12 +120,52 @@ namespace OpenSim.Region.Framework.Scenes | |||
120 | /// <param name="uuid">UUID.</param> | 120 | /// <param name="uuid">UUID.</param> |
121 | public bool AddForInspection(UUID uuid) | 121 | public bool AddForInspection(UUID uuid) |
122 | { | 122 | { |
123 | <<<<<<< HEAD | ||
123 | if (m_assetUuidsToInspect.Contains(uuid)) | 124 | if (m_assetUuidsToInspect.Contains(uuid)) |
124 | return false; | 125 | return false; |
125 | 126 | ||
126 | // m_log.DebugFormat("[UUID GATHERER]: Adding asset {0} for inspection", uuid); | 127 | // m_log.DebugFormat("[UUID GATHERER]: Adding asset {0} for inspection", uuid); |
127 | 128 | ||
128 | m_assetUuidsToInspect.Enqueue(uuid); | 129 | m_assetUuidsToInspect.Enqueue(uuid); |
130 | ======= | ||
131 | try | ||
132 | { | ||
133 | assetUuids[assetUuid] = assetType; | ||
134 | |||
135 | if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType) | ||
136 | { | ||
137 | GetWearableAssetUuids(assetUuid, assetUuids); | ||
138 | } | ||
139 | else if ((sbyte)AssetType.Gesture == assetType) | ||
140 | { | ||
141 | GetGestureAssetUuids(assetUuid, assetUuids); | ||
142 | } | ||
143 | else if ((sbyte)AssetType.Notecard == assetType) | ||
144 | { | ||
145 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); | ||
146 | } | ||
147 | else if ((sbyte)AssetType.LSLText == assetType) | ||
148 | { | ||
149 | GetTextEmbeddedAssetUuids(assetUuid, assetUuids); | ||
150 | } | ||
151 | else if ((sbyte)OpenSimAssetType.Material == assetType) | ||
152 | { | ||
153 | GetMaterialAssetUuids(assetUuid, assetUuids); | ||
154 | } | ||
155 | else if ((sbyte)AssetType.Object == assetType) | ||
156 | { | ||
157 | GetSceneObjectAssetUuids(assetUuid, assetUuids); | ||
158 | } | ||
159 | } | ||
160 | catch (Exception) | ||
161 | { | ||
162 | m_log.ErrorFormat( | ||
163 | "[UUID GATHERER]: Failed to gather uuids for asset id {0}, type {1}", | ||
164 | assetUuid, assetType); | ||
165 | throw; | ||
166 | } | ||
167 | } | ||
168 | >>>>>>> avn/ubitvar | ||
129 | 169 | ||
130 | return true; | 170 | return true; |
131 | } | 171 | } |