diff options
Diffstat (limited to '')
17 files changed, 910 insertions, 769 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs index 7a8aba2..8386030 100644 --- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using OpenMetaverse; | 28 | using OpenMetaverse; |
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using System.Collections.Generic; | ||
30 | 31 | ||
31 | namespace OpenSim.Region.Framework.Interfaces | 32 | namespace OpenSim.Region.Framework.Interfaces |
32 | { | 33 | { |
@@ -45,5 +46,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
45 | /// </param> | 46 | /// </param> |
46 | /// <param name="offerMessage"></param> | 47 | /// <param name="offerMessage"></param> |
47 | void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage); | 48 | void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage); |
49 | List<FriendListItem> GetUserFriends(UUID agentID); | ||
48 | } | 50 | } |
49 | } | 51 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/ILandObject.cs b/OpenSim/Region/Framework/Interfaces/ILandObject.cs index c2b1292..084184f 100644 --- a/OpenSim/Region/Framework/Interfaces/ILandObject.cs +++ b/OpenSim/Region/Framework/Interfaces/ILandObject.cs | |||
@@ -54,6 +54,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
54 | bool IsBannedFromLand(UUID avatar); | 54 | bool IsBannedFromLand(UUID avatar); |
55 | bool IsRestrictedFromLand(UUID avatar); | 55 | bool IsRestrictedFromLand(UUID avatar); |
56 | void SendLandUpdateToClient(IClientAPI remote_client); | 56 | void SendLandUpdateToClient(IClientAPI remote_client); |
57 | void SendLandUpdateToClient(bool snap_selection, IClientAPI remote_client); | ||
57 | List<UUID> CreateAccessListArrayByFlag(AccessList flag); | 58 | List<UUID> CreateAccessListArrayByFlag(AccessList flag); |
58 | void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); | 59 | void SendAccessList(UUID agentID, UUID sessionID, uint flags, int sequenceID, IClientAPI remote_client); |
59 | void UpdateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client); | 60 | void UpdateAccessList(uint flags, List<ParcelManager.ParcelAccessEntry> entries, IClientAPI remote_client); |
diff --git a/OpenSim/Grid/GridServer/Program.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index 741a01b..5cdf191 100644 --- a/OpenSim/Grid/GridServer/Program.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs | |||
@@ -25,41 +25,20 @@ | |||
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 log4net.Config; | 28 | using System; |
29 | using Nini.Config; | 29 | using OpenMetaverse; |
30 | 30 | ||
31 | namespace OpenSim.Grid.GridServer | 31 | namespace OpenSim.Region.Framework.Interfaces |
32 | { | 32 | { |
33 | public class Program | 33 | public delegate void ScriptCommand(UUID script, string id, string module, string command, string k); |
34 | { | ||
35 | public static void Main(string[] args) | ||
36 | { | ||
37 | ArgvConfigSource argvSource = new ArgvConfigSource(args); | ||
38 | argvSource.AddSwitch("Startup", "console", "c"); | ||
39 | argvSource.AddSwitch("Startup", "xmlfile", "x"); | ||
40 | |||
41 | XmlConfigurator.Configure(); | ||
42 | 34 | ||
43 | GridServerBase app = new GridServerBase(); | 35 | public interface IScriptModuleComms |
44 | 36 | { | |
45 | IConfig startupConfig = argvSource.Configs["Startup"]; | 37 | event ScriptCommand OnScriptCommand; |
46 | if (startupConfig != null) | ||
47 | { | ||
48 | app.m_consoleType = startupConfig.GetString("console", "local"); | ||
49 | app.m_configFile = startupConfig.GetString("xmlfile", "GridServer_Config.xml"); | ||
50 | } | ||
51 | 38 | ||
52 | app.m_configSource = argvSource; | 39 | void DispatchReply(UUID script, int code, string text, string k); |
53 | 40 | ||
54 | // if (args.Length > 0 && args[0] == "-setuponly") | 41 | // For use ONLY by the script API |
55 | // { | 42 | void RaiseEvent(UUID script, string id, string module, string command, string k); |
56 | // app.Config(); | ||
57 | // } | ||
58 | // else | ||
59 | // { | ||
60 | app.Startup(); | ||
61 | app.Work(); | ||
62 | // } | ||
63 | } | ||
64 | } | 43 | } |
65 | } | 44 | } |
diff --git a/OpenSim/Region/Framework/Scenes/EntityBase.cs b/OpenSim/Region/Framework/Scenes/EntityBase.cs index c2ec6a5..1c76c54 100644 --- a/OpenSim/Region/Framework/Scenes/EntityBase.cs +++ b/OpenSim/Region/Framework/Scenes/EntityBase.cs | |||
@@ -94,14 +94,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
94 | set { m_velocity = value; } | 94 | set { m_velocity = value; } |
95 | } | 95 | } |
96 | 96 | ||
97 | protected Quaternion m_rotation = new Quaternion(0f, 0f, 1f, 0f); | ||
98 | |||
99 | public virtual Quaternion Rotation | ||
100 | { | ||
101 | get { return m_rotation; } | ||
102 | set { m_rotation = value; } | ||
103 | } | ||
104 | |||
105 | protected uint m_localId; | 97 | protected uint m_localId; |
106 | 98 | ||
107 | public virtual uint LocalId | 99 | public virtual uint LocalId |
@@ -115,13 +107,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
115 | /// </summary> | 107 | /// </summary> |
116 | public EntityBase() | 108 | public EntityBase() |
117 | { | 109 | { |
118 | m_uuid = UUID.Zero; | ||
119 | |||
120 | m_pos = Vector3.Zero; | ||
121 | m_velocity = Vector3.Zero; | ||
122 | Rotation = Quaternion.Identity; | ||
123 | m_name = "(basic entity)"; | 110 | m_name = "(basic entity)"; |
124 | m_rotationalvelocity = Vector3.Zero; | ||
125 | } | 111 | } |
126 | 112 | ||
127 | /// <summary> | 113 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index 244ac3b..ec50598 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | |||
@@ -77,13 +77,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
77 | 77 | ||
78 | #region Internal functions | 78 | #region Internal functions |
79 | 79 | ||
80 | private string UserAssetURL(UUID userID) | 80 | // private string UserAssetURL(UUID userID) |
81 | { | 81 | // { |
82 | CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); | 82 | // CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); |
83 | if (uinfo != null) | 83 | // if (uinfo != null) |
84 | return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI; | 84 | // return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI; |
85 | return null; | 85 | // return null; |
86 | } | 86 | // } |
87 | 87 | ||
88 | // private string UserInventoryURL(UUID userID) | 88 | // private string UserInventoryURL(UUID userID) |
89 | // { | 89 | // { |
@@ -118,7 +118,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid | |||
118 | // HGAssetService dispatches it to the remote grid. | 118 | // HGAssetService dispatches it to the remote grid. |
119 | // It's not pretty, but the best that can be done while | 119 | // It's not pretty, but the best that can be done while |
120 | // not having a global naming infrastructure | 120 | // not having a global naming infrastructure |
121 | AssetBase asset1 = new AssetBase(); | 121 | AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type); |
122 | Copy(asset, asset1); | 122 | Copy(asset, asset1); |
123 | try | 123 | try |
124 | { | 124 | { |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 4d76b4ef..66fb918 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -93,7 +93,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
93 | 93 | ||
94 | public void AddInventoryItem(UUID AgentID, InventoryItemBase item) | 94 | public void AddInventoryItem(UUID AgentID, InventoryItemBase item) |
95 | { | 95 | { |
96 | |||
97 | if (InventoryService.AddItem(item)) | 96 | if (InventoryService.AddItem(item)) |
98 | { | 97 | { |
99 | int userlevel = 0; | 98 | int userlevel = 0; |
@@ -627,11 +626,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
627 | /// <returns></returns> | 626 | /// <returns></returns> |
628 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) | 627 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) |
629 | { | 628 | { |
630 | AssetBase asset = new AssetBase(); | 629 | AssetBase asset = new AssetBase(UUID.Random(), name, assetType); |
631 | asset.Name = name; | ||
632 | asset.Description = description; | 630 | asset.Description = description; |
633 | asset.Type = assetType; | ||
634 | asset.FullID = UUID.Random(); | ||
635 | asset.Data = (data == null) ? new byte[1] : data; | 631 | asset.Data = (data == null) ? new byte[1] : data; |
636 | 632 | ||
637 | return asset; | 633 | return asset; |
@@ -807,20 +803,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
807 | InventoryService.DeleteFolders(remoteClient.AgentId, folderIDs); | 803 | InventoryService.DeleteFolders(remoteClient.AgentId, folderIDs); |
808 | } | 804 | } |
809 | 805 | ||
810 | private SceneObjectGroup GetGroupByPrim(uint localID) | ||
811 | { | ||
812 | List<EntityBase> EntityList = GetEntities(); | ||
813 | |||
814 | foreach (EntityBase ent in EntityList) | ||
815 | { | ||
816 | if (ent is SceneObjectGroup) | ||
817 | { | ||
818 | if (((SceneObjectGroup) ent).HasChildPrim(localID)) | ||
819 | return (SceneObjectGroup) ent; | ||
820 | } | ||
821 | } | ||
822 | return null; | ||
823 | } | ||
824 | 806 | ||
825 | /// <summary> | 807 | /// <summary> |
826 | /// Send the details of a prim's inventory to the client. | 808 | /// Send the details of a prim's inventory to the client. |
@@ -1175,7 +1157,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1175 | { | 1157 | { |
1176 | m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); | 1158 | m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); |
1177 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); | 1159 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); |
1178 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, fetchFolders, fetchItems); | 1160 | InventoryFolderBase containingFolder = new InventoryFolderBase(); |
1161 | containingFolder.ID = folder.ID; | ||
1162 | containingFolder.Owner = client.AgentId; | ||
1163 | containingFolder = InventoryService.GetFolder(containingFolder); | ||
1164 | int version = containingFolder.Version; | ||
1165 | |||
1166 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); | ||
1179 | } | 1167 | } |
1180 | 1168 | ||
1181 | /// <summary> | 1169 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 1a91f0c..47fbeb4 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -462,7 +462,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
462 | { | 462 | { |
463 | remoteClient.SendInventoryFolderDetails( | 463 | remoteClient.SendInventoryFolderDetails( |
464 | fold.Owner, folderID, fold.RequestListOfItems(), | 464 | fold.Owner, folderID, fold.RequestListOfItems(), |
465 | fold.RequestListOfFolders(), fetchFolders, fetchItems); | 465 | fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); |
466 | return; | 466 | return; |
467 | } | 467 | } |
468 | 468 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index d01cef7..d1d6b6a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs | |||
@@ -35,7 +35,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
35 | namespace OpenSim.Region.Framework.Scenes | 35 | namespace OpenSim.Region.Framework.Scenes |
36 | { | 36 | { |
37 | #region Delegates | 37 | #region Delegates |
38 | public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectIDID); | 38 | public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectID); |
39 | public delegate void SetBypassPermissionsHandler(bool value); | 39 | public delegate void SetBypassPermissionsHandler(bool value); |
40 | public delegate bool BypassPermissionsHandler(); | 40 | public delegate bool BypassPermissionsHandler(); |
41 | public delegate bool PropagatePermissionsHandler(); | 41 | public delegate bool PropagatePermissionsHandler(); |
@@ -147,28 +147,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
147 | 147 | ||
148 | public uint GenerateClientFlags(UUID userID, UUID objectID) | 148 | public uint GenerateClientFlags(UUID userID, UUID objectID) |
149 | { | 149 | { |
150 | SceneObjectPart part=m_scene.GetSceneObjectPart(objectID); | 150 | // libomv will moan about PrimFlags.ObjectYouOfficer being |
151 | // obsolete... | ||
152 | #pragma warning disable 0612 | ||
153 | const PrimFlags DEFAULT_FLAGS = | ||
154 | PrimFlags.ObjectModify | | ||
155 | PrimFlags.ObjectCopy | | ||
156 | PrimFlags.ObjectMove | | ||
157 | PrimFlags.ObjectTransfer | | ||
158 | PrimFlags.ObjectYouOwner | | ||
159 | PrimFlags.ObjectAnyOwner | | ||
160 | PrimFlags.ObjectOwnerModify | | ||
161 | PrimFlags.ObjectYouOfficer; | ||
162 | #pragma warning restore 0612 | ||
163 | |||
164 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectID); | ||
151 | 165 | ||
152 | if (part == null) | 166 | if (part == null) |
153 | return 0; | 167 | return 0; |
154 | 168 | ||
155 | // libomv will moan about PrimFlags.ObjectYouOfficer being | 169 | uint perms = part.GetEffectiveObjectFlags() | (uint)DEFAULT_FLAGS; |
156 | // obsolete... | ||
157 | #pragma warning disable 0612 | ||
158 | uint perms=part.GetEffectiveObjectFlags() | | ||
159 | (uint)PrimFlags.ObjectModify | | ||
160 | (uint)PrimFlags.ObjectCopy | | ||
161 | (uint)PrimFlags.ObjectMove | | ||
162 | (uint)PrimFlags.ObjectTransfer | | ||
163 | (uint)PrimFlags.ObjectYouOwner | | ||
164 | (uint)PrimFlags.ObjectAnyOwner | | ||
165 | (uint)PrimFlags.ObjectOwnerModify | | ||
166 | (uint)PrimFlags.ObjectYouOfficer; | ||
167 | #pragma warning restore 0612 | ||
168 | |||
169 | GenerateClientFlagsHandler handlerGenerateClientFlags = | ||
170 | OnGenerateClientFlags; | ||
171 | 170 | ||
171 | GenerateClientFlagsHandler handlerGenerateClientFlags = OnGenerateClientFlags; | ||
172 | if (handlerGenerateClientFlags != null) | 172 | if (handlerGenerateClientFlags != null) |
173 | { | 173 | { |
174 | Delegate[] list = handlerGenerateClientFlags.GetInvocationList(); | 174 | Delegate[] list = handlerGenerateClientFlags.GetInvocationList(); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7c3875d..aeca7df 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -36,6 +36,7 @@ using System.Timers; | |||
36 | using System.Xml; | 36 | using System.Xml; |
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | using OpenMetaverse; | 38 | using OpenMetaverse; |
39 | using OpenMetaverse.Packets; | ||
39 | using OpenMetaverse.Imaging; | 40 | using OpenMetaverse.Imaging; |
40 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
41 | using OpenSim.Services.Interfaces; | 42 | using OpenSim.Services.Interfaces; |
@@ -87,8 +88,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
87 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 88 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
88 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 89 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
89 | 90 | ||
90 | public volatile bool BordersLocked = false; | 91 | private volatile int m_bordersLocked = 0; |
91 | 92 | public bool BordersLocked | |
93 | { | ||
94 | get { return m_bordersLocked == 1; } | ||
95 | set | ||
96 | { | ||
97 | if (value == true) | ||
98 | m_bordersLocked = 1; | ||
99 | else | ||
100 | m_bordersLocked = 0; | ||
101 | } | ||
102 | } | ||
92 | public List<Border> NorthBorders = new List<Border>(); | 103 | public List<Border> NorthBorders = new List<Border>(); |
93 | public List<Border> EastBorders = new List<Border>(); | 104 | public List<Border> EastBorders = new List<Border>(); |
94 | public List<Border> SouthBorders = new List<Border>(); | 105 | public List<Border> SouthBorders = new List<Border>(); |
@@ -135,6 +146,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
135 | protected SceneCommunicationService m_sceneGridService; | 146 | protected SceneCommunicationService m_sceneGridService; |
136 | public bool loginsdisabled = true; | 147 | public bool loginsdisabled = true; |
137 | 148 | ||
149 | public new float TimeDilation | ||
150 | { | ||
151 | get { return m_sceneGraph.PhysicsScene.TimeDilation; } | ||
152 | } | ||
153 | |||
138 | public SceneCommunicationService SceneGridService | 154 | public SceneCommunicationService SceneGridService |
139 | { | 155 | { |
140 | get { return m_sceneGridService; } | 156 | get { return m_sceneGridService; } |
@@ -252,7 +268,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
252 | // Central Update Loop | 268 | // Central Update Loop |
253 | 269 | ||
254 | protected int m_fps = 10; | 270 | protected int m_fps = 10; |
255 | protected int m_frame; | 271 | protected uint m_frame; |
256 | protected float m_timespan = 0.089f; | 272 | protected float m_timespan = 0.089f; |
257 | protected DateTime m_lastupdate = DateTime.UtcNow; | 273 | protected DateTime m_lastupdate = DateTime.UtcNow; |
258 | 274 | ||
@@ -269,6 +285,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
269 | private int physicsMS2; | 285 | private int physicsMS2; |
270 | private int physicsMS; | 286 | private int physicsMS; |
271 | private int otherMS; | 287 | private int otherMS; |
288 | private int tempOnRezMS; | ||
289 | private int eventMS; | ||
290 | private int backupMS; | ||
291 | private int terrainMS; | ||
292 | private int landMS; | ||
293 | private int lastCompletedFrame; | ||
294 | |||
295 | public int MonitorFrameTime { get { return frameMS; } } | ||
296 | public int MonitorPhysicsUpdateTime { get { return physicsMS; } } | ||
297 | public int MonitorPhysicsSyncTime { get { return physicsMS2; } } | ||
298 | public int MonitorOtherTime { get { return otherMS; } } | ||
299 | public int MonitorTempOnRezTime { get { return tempOnRezMS; } } | ||
300 | public int MonitorEventTime { get { return eventMS; } } // This may need to be divided into each event? | ||
301 | public int MonitorBackupTime { get { return backupMS; } } | ||
302 | public int MonitorTerrainTime { get { return terrainMS; } } | ||
303 | public int MonitorLandTime { get { return landMS; } } | ||
304 | public int MonitorLastFrameTick { get { return lastCompletedFrame; } } | ||
272 | 305 | ||
273 | private bool m_physics_enabled = true; | 306 | private bool m_physics_enabled = true; |
274 | private bool m_scripts_enabled = true; | 307 | private bool m_scripts_enabled = true; |
@@ -375,6 +408,73 @@ namespace OpenSim.Region.Framework.Scenes | |||
375 | 408 | ||
376 | #endregion | 409 | #endregion |
377 | 410 | ||
411 | #region BinaryStats | ||
412 | |||
413 | public class StatLogger | ||
414 | { | ||
415 | public DateTime StartTime; | ||
416 | public string Path; | ||
417 | public System.IO.BinaryWriter Log; | ||
418 | } | ||
419 | static StatLogger m_statLog = null; | ||
420 | static TimeSpan m_statLogPeriod = TimeSpan.FromSeconds(300); | ||
421 | static string m_statsDir = String.Empty; | ||
422 | static Object m_statLockObject = new Object(); | ||
423 | private void LogSimStats(SimStats stats) | ||
424 | { | ||
425 | SimStatsPacket pack = new SimStatsPacket(); | ||
426 | pack.Region = new SimStatsPacket.RegionBlock(); | ||
427 | pack.Region.RegionX = stats.RegionX; | ||
428 | pack.Region.RegionY = stats.RegionY; | ||
429 | pack.Region.RegionFlags = stats.RegionFlags; | ||
430 | pack.Region.ObjectCapacity = stats.ObjectCapacity; | ||
431 | //pack.Region = //stats.RegionBlock; | ||
432 | pack.Stat = stats.StatsBlock; | ||
433 | pack.Header.Reliable = false; | ||
434 | |||
435 | // note that we are inside the reporter lock when called | ||
436 | DateTime now = DateTime.Now; | ||
437 | |||
438 | // hide some time information into the packet | ||
439 | pack.Header.Sequence = (uint)now.Ticks; | ||
440 | |||
441 | lock (m_statLockObject) // m_statLog is shared so make sure there is only executer here | ||
442 | { | ||
443 | try | ||
444 | { | ||
445 | if (m_statLog == null || now > m_statLog.StartTime + m_statLogPeriod) | ||
446 | { | ||
447 | // First log file or time has expired, start writing to a new log file | ||
448 | if (m_statLog != null && m_statLog.Log != null) | ||
449 | { | ||
450 | m_statLog.Log.Close(); | ||
451 | } | ||
452 | m_statLog = new StatLogger(); | ||
453 | m_statLog.StartTime = now; | ||
454 | m_statLog.Path = (m_statsDir.Length > 0 ? m_statsDir + System.IO.Path.DirectorySeparatorChar.ToString() : "") | ||
455 | + String.Format("stats-{0}.log", now.ToString("yyyyMMddHHmmss")); | ||
456 | m_statLog.Log = new BinaryWriter(File.Open(m_statLog.Path, FileMode.Append, FileAccess.Write)); | ||
457 | } | ||
458 | |||
459 | // Write the serialized data to disk | ||
460 | if (m_statLog != null && m_statLog.Log != null) | ||
461 | m_statLog.Log.Write(pack.ToBytes()); | ||
462 | } | ||
463 | catch (Exception ex) | ||
464 | { | ||
465 | m_log.Error("statistics gathering failed: " + ex.Message, ex); | ||
466 | if (m_statLog != null && m_statLog.Log != null) | ||
467 | { | ||
468 | m_statLog.Log.Close(); | ||
469 | } | ||
470 | m_statLog = null; | ||
471 | } | ||
472 | } | ||
473 | return; | ||
474 | } | ||
475 | |||
476 | #endregion | ||
477 | |||
378 | #region Constructors | 478 | #region Constructors |
379 | 479 | ||
380 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, | 480 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, |
@@ -560,6 +660,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
560 | } | 660 | } |
561 | 661 | ||
562 | m_log.Info("[SCENE]: Using the " + m_update_prioritization_scheme + " prioritization scheme"); | 662 | m_log.Info("[SCENE]: Using the " + m_update_prioritization_scheme + " prioritization scheme"); |
663 | |||
664 | #region BinaryStats | ||
665 | |||
666 | try | ||
667 | { | ||
668 | IConfig statConfig = m_config.Configs["Statistics.Binary"]; | ||
669 | if (statConfig.Contains("enabled") && statConfig.GetBoolean("enabled")) | ||
670 | { | ||
671 | if (statConfig.Contains("collect_region_stats")) | ||
672 | { | ||
673 | if (statConfig.GetBoolean("collect_region_stats")) | ||
674 | { | ||
675 | // if enabled, add us to the event. If not enabled, I won't get called | ||
676 | StatsReporter.OnSendStatsResult += LogSimStats; | ||
677 | } | ||
678 | } | ||
679 | if (statConfig.Contains("region_stats_period_seconds")) | ||
680 | { | ||
681 | m_statLogPeriod = TimeSpan.FromSeconds(statConfig.GetInt("region_stats_period_seconds")); | ||
682 | } | ||
683 | if (statConfig.Contains("stats_dir")) | ||
684 | { | ||
685 | m_statsDir = statConfig.GetString("stats_dir"); | ||
686 | } | ||
687 | } | ||
688 | } | ||
689 | catch | ||
690 | { | ||
691 | // if it doesn't work, we don't collect anything | ||
692 | } | ||
693 | |||
694 | #endregion BinaryStats | ||
563 | } | 695 | } |
564 | catch | 696 | catch |
565 | { | 697 | { |
@@ -1013,36 +1145,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
1013 | /// </summary> | 1145 | /// </summary> |
1014 | public override void Update() | 1146 | public override void Update() |
1015 | { | 1147 | { |
1016 | int maintc = 0; | 1148 | float physicsFPS; |
1149 | int maintc; | ||
1150 | |||
1017 | while (!shuttingdown) | 1151 | while (!shuttingdown) |
1018 | { | 1152 | { |
1019 | //#if DEBUG | ||
1020 | // int w = 0, io = 0; | ||
1021 | // ThreadPool.GetAvailableThreads(out w, out io); | ||
1022 | // if ((w < 10) || (io < 10)) | ||
1023 | // m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io); | ||
1024 | //#endif | ||
1025 | maintc = Environment.TickCount; | ||
1026 | |||
1027 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; | 1153 | TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate; |
1028 | float physicsFPS = 0; | 1154 | physicsFPS = 0f; |
1029 | 1155 | ||
1030 | frameMS = Environment.TickCount; | 1156 | maintc = otherMS = Environment.TickCount; |
1157 | int tmpFrameMS = maintc; | ||
1158 | |||
1159 | // Increment the frame counter | ||
1160 | ++m_frame; | ||
1031 | 1161 | ||
1032 | try | 1162 | try |
1033 | { | 1163 | { |
1034 | // Increment the frame counter | ||
1035 | m_frame++; | ||
1036 | |||
1037 | // Loop it | ||
1038 | if (m_frame == Int32.MaxValue) | ||
1039 | m_frame = 0; | ||
1040 | |||
1041 | otherMS = Environment.TickCount; | ||
1042 | |||
1043 | // Check if any objects have reached their targets | 1164 | // Check if any objects have reached their targets |
1044 | CheckAtTargets(); | 1165 | CheckAtTargets(); |
1045 | 1166 | ||
1046 | // Update SceneObjectGroups that have scheduled themselves for updates | 1167 | // Update SceneObjectGroups that have scheduled themselves for updates |
1047 | // Objects queue their updates onto all scene presences | 1168 | // Objects queue their updates onto all scene presences |
1048 | if (m_frame % m_update_objects == 0) | 1169 | if (m_frame % m_update_objects == 0) |
@@ -1053,62 +1174,92 @@ namespace OpenSim.Region.Framework.Scenes | |||
1053 | if (m_frame % m_update_presences == 0) | 1174 | if (m_frame % m_update_presences == 0) |
1054 | m_sceneGraph.UpdatePresences(); | 1175 | m_sceneGraph.UpdatePresences(); |
1055 | 1176 | ||
1056 | physicsMS2 = Environment.TickCount; | 1177 | int TempPhysicsMS2 = Environment.TickCount; |
1057 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) | 1178 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) |
1058 | m_sceneGraph.UpdatePreparePhysics(); | 1179 | m_sceneGraph.UpdatePreparePhysics(); |
1059 | physicsMS2 = Environment.TickCount - physicsMS2; | 1180 | TempPhysicsMS2 = Environment.TickCount - TempPhysicsMS2; |
1181 | physicsMS2 = TempPhysicsMS2; | ||
1060 | 1182 | ||
1061 | if (m_frame % m_update_entitymovement == 0) | 1183 | if (m_frame % m_update_entitymovement == 0) |
1062 | m_sceneGraph.UpdateScenePresenceMovement(); | 1184 | m_sceneGraph.UpdateScenePresenceMovement(); |
1063 | 1185 | ||
1064 | physicsMS = Environment.TickCount; | 1186 | int TempPhysicsMS = Environment.TickCount; |
1065 | if ((m_frame % m_update_physics == 0) && m_physics_enabled) | 1187 | if (m_frame % m_update_physics == 0) |
1066 | physicsFPS = m_sceneGraph.UpdatePhysics( | 1188 | { |
1067 | Math.Max(SinceLastFrame.TotalSeconds, m_timespan) | 1189 | if (m_physics_enabled) |
1068 | ); | 1190 | physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan)); |
1069 | if (m_frame % m_update_physics == 0 && SynchronizeScene != null) | 1191 | if (SynchronizeScene != null) |
1070 | SynchronizeScene(this); | 1192 | SynchronizeScene(this); |
1071 | 1193 | } | |
1072 | physicsMS = Environment.TickCount - physicsMS; | 1194 | TempPhysicsMS = Environment.TickCount - TempPhysicsMS; |
1073 | physicsMS += physicsMS2; | 1195 | physicsMS = TempPhysicsMS; |
1074 | 1196 | ||
1075 | // Delete temp-on-rez stuff | 1197 | // Delete temp-on-rez stuff |
1076 | if (m_frame % m_update_backup == 0) | 1198 | if (m_frame % m_update_backup == 0) |
1199 | { | ||
1200 | int tozMS = Environment.TickCount; | ||
1077 | CleanTempObjects(); | 1201 | CleanTempObjects(); |
1202 | tozMS -= Environment.TickCount; | ||
1203 | tempOnRezMS = tozMS; | ||
1204 | } | ||
1078 | 1205 | ||
1079 | if (RegionStatus != RegionStatus.SlaveScene) | 1206 | if (RegionStatus != RegionStatus.SlaveScene) |
1080 | { | 1207 | { |
1081 | if (m_frame % m_update_events == 0) | 1208 | if (m_frame % m_update_events == 0) |
1209 | { | ||
1210 | int evMS = Environment.TickCount; | ||
1082 | UpdateEvents(); | 1211 | UpdateEvents(); |
1212 | evMS -= Environment.TickCount; | ||
1213 | eventMS = evMS; | ||
1214 | } | ||
1083 | 1215 | ||
1084 | if (m_frame % m_update_backup == 0) | 1216 | if (m_frame % m_update_backup == 0) |
1217 | { | ||
1218 | int backMS = Environment.TickCount; | ||
1085 | UpdateStorageBackup(); | 1219 | UpdateStorageBackup(); |
1220 | backMS -= Environment.TickCount; | ||
1221 | backupMS = backMS; | ||
1222 | } | ||
1086 | 1223 | ||
1087 | if (m_frame % m_update_terrain == 0) | 1224 | if (m_frame % m_update_terrain == 0) |
1225 | { | ||
1226 | int terMS = Environment.TickCount; | ||
1088 | UpdateTerrain(); | 1227 | UpdateTerrain(); |
1228 | terMS -= Environment.TickCount; | ||
1229 | terrainMS = terMS; | ||
1230 | } | ||
1089 | 1231 | ||
1090 | if (m_frame % m_update_land == 0) | 1232 | if (m_frame % m_update_land == 0) |
1233 | { | ||
1234 | int ldMS = Environment.TickCount; | ||
1091 | UpdateLand(); | 1235 | UpdateLand(); |
1236 | ldMS -= Environment.TickCount; | ||
1237 | landMS = ldMS; | ||
1238 | } | ||
1239 | |||
1240 | int tickCount = Environment.TickCount; | ||
1241 | otherMS = tickCount - otherMS; | ||
1242 | tmpFrameMS -= tickCount; | ||
1243 | frameMS = tmpFrameMS; | ||
1244 | lastCompletedFrame = tickCount; | ||
1092 | 1245 | ||
1093 | otherMS = Environment.TickCount - otherMS; | ||
1094 | // if (m_frame%m_update_avatars == 0) | 1246 | // if (m_frame%m_update_avatars == 0) |
1095 | // UpdateInWorldTime(); | 1247 | // UpdateInWorldTime(); |
1096 | StatsReporter.AddPhysicsFPS(physicsFPS); | 1248 | StatsReporter.AddPhysicsFPS(physicsFPS); |
1097 | StatsReporter.AddTimeDilation(m_timedilation); | 1249 | StatsReporter.AddTimeDilation(TimeDilation); |
1098 | StatsReporter.AddFPS(1); | 1250 | StatsReporter.AddFPS(1); |
1099 | StatsReporter.AddInPackets(0); | ||
1100 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); | 1251 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); |
1101 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); | 1252 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); |
1102 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); | 1253 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); |
1103 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); | 1254 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); |
1104 | frameMS = Environment.TickCount - frameMS; | ||
1105 | StatsReporter.addFrameMS(frameMS); | 1255 | StatsReporter.addFrameMS(frameMS); |
1106 | StatsReporter.addPhysicsMS(physicsMS); | 1256 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); |
1107 | StatsReporter.addOtherMS(otherMS); | 1257 | StatsReporter.addOtherMS(otherMS); |
1108 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); | 1258 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); |
1109 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | 1259 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); |
1110 | } | 1260 | } |
1111 | if (loginsdisabled && (m_frame > 20)) | 1261 | |
1262 | if (loginsdisabled && m_frame > 20) | ||
1112 | { | 1263 | { |
1113 | // In 99.9% of cases it is a bad idea to manually force garbage collection. However, | 1264 | // In 99.9% of cases it is a bad idea to manually force garbage collection. However, |
1114 | // this is a rare case where we know we have just went through a long cycle of heap | 1265 | // this is a rare case where we know we have just went through a long cycle of heap |
@@ -1141,18 +1292,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1141 | } | 1292 | } |
1142 | finally | 1293 | finally |
1143 | { | 1294 | { |
1144 | //updateLock.ReleaseMutex(); | ||
1145 | // Get actual time dilation | ||
1146 | float tmpval = (m_timespan / (float)SinceLastFrame.TotalSeconds); | ||
1147 | |||
1148 | // If actual time dilation is greater then one, we're catching up, so subtract | ||
1149 | // the amount that's greater then 1 from the time dilation | ||
1150 | if (tmpval > 1.0) | ||
1151 | { | ||
1152 | tmpval = tmpval - (tmpval - 1.0f); | ||
1153 | } | ||
1154 | m_timedilation = tmpval; | ||
1155 | |||
1156 | m_lastupdate = DateTime.UtcNow; | 1295 | m_lastupdate = DateTime.UtcNow; |
1157 | } | 1296 | } |
1158 | maintc = Environment.TickCount - maintc; | 1297 | maintc = Environment.TickCount - maintc; |
@@ -1183,9 +1322,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1183 | { | 1322 | { |
1184 | lock (m_groupsWithTargets) | 1323 | lock (m_groupsWithTargets) |
1185 | { | 1324 | { |
1186 | foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in m_groupsWithTargets) | 1325 | foreach (SceneObjectGroup entry in m_groupsWithTargets.Values) |
1187 | { | 1326 | { |
1188 | kvp.Value.checkAtTargets(); | 1327 | entry.checkAtTargets(); |
1189 | } | 1328 | } |
1190 | } | 1329 | } |
1191 | } | 1330 | } |
@@ -4244,6 +4383,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
4244 | return m_sceneGraph.GetSceneObjectPart(fullID); | 4383 | return m_sceneGraph.GetSceneObjectPart(fullID); |
4245 | } | 4384 | } |
4246 | 4385 | ||
4386 | /// <summary> | ||
4387 | /// Get a scene object group that contains the prim with the given local id | ||
4388 | /// </summary> | ||
4389 | /// <param name="localID"></param> | ||
4390 | /// <returns>null if no scene object group containing that prim is found</returns> | ||
4391 | public SceneObjectGroup GetGroupByPrim(uint localID) | ||
4392 | { | ||
4393 | return m_sceneGraph.GetGroupByPrim(localID); | ||
4394 | } | ||
4395 | |||
4247 | public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) | 4396 | public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) |
4248 | { | 4397 | { |
4249 | return m_sceneGraph.TryGetAvatar(avatarId, out avatar); | 4398 | return m_sceneGraph.TryGetAvatar(avatarId, out avatar); |
@@ -4606,7 +4755,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4606 | SceneObjectPart trackedBody = GetSceneObjectPart(joint.TrackedBodyName); // FIXME: causes a sequential lookup | 4755 | SceneObjectPart trackedBody = GetSceneObjectPart(joint.TrackedBodyName); // FIXME: causes a sequential lookup |
4607 | if (trackedBody == null) return; // the actor may have been deleted but the joint still lingers around a few frames waiting for deletion. during this time, trackedBody is NULL to prevent further motion of the joint proxy. | 4756 | if (trackedBody == null) return; // the actor may have been deleted but the joint still lingers around a few frames waiting for deletion. during this time, trackedBody is NULL to prevent further motion of the joint proxy. |
4608 | jointProxyObject.Velocity = trackedBody.Velocity; | 4757 | jointProxyObject.Velocity = trackedBody.Velocity; |
4609 | jointProxyObject.RotationalVelocity = trackedBody.RotationalVelocity; | 4758 | jointProxyObject.AngularVelocity = trackedBody.AngularVelocity; |
4610 | switch (joint.Type) | 4759 | switch (joint.Type) |
4611 | { | 4760 | { |
4612 | case PhysicsJointType.Ball: | 4761 | case PhysicsJointType.Ball: |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 82731d1..1547f9a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -106,9 +106,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
106 | 106 | ||
107 | public float TimeDilation | 107 | public float TimeDilation |
108 | { | 108 | { |
109 | get { return m_timedilation; } | 109 | get { return 1.0f; } |
110 | } | 110 | } |
111 | protected float m_timedilation = 1.0f; | ||
112 | 111 | ||
113 | protected ulong m_regionHandle; | 112 | protected ulong m_regionHandle; |
114 | protected string m_regionName; | 113 | protected string m_regionName; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index db055f9..2fdb48d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -369,26 +369,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
369 | /// </summary> | 369 | /// </summary> |
370 | protected internal void UpdateObjectGroups() | 370 | protected internal void UpdateObjectGroups() |
371 | { | 371 | { |
372 | Dictionary<UUID, SceneObjectGroup> updates; | 372 | List<SceneObjectGroup> updates; |
373 | |||
373 | // Some updates add more updates to the updateList. | 374 | // Some updates add more updates to the updateList. |
374 | // Get the current list of updates and clear the list before iterating | 375 | // Get the current list of updates and clear the list before iterating |
375 | lock (m_updateList) | 376 | lock (m_updateList) |
376 | { | 377 | { |
377 | updates = new Dictionary<UUID, SceneObjectGroup>(m_updateList); | 378 | updates = new List<SceneObjectGroup>(m_updateList.Values); |
378 | m_updateList.Clear(); | 379 | m_updateList.Clear(); |
379 | } | 380 | } |
381 | |||
380 | // Go through all updates | 382 | // Go through all updates |
381 | foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in updates) | 383 | for (int i = 0; i < updates.Count; i++) |
382 | { | 384 | { |
385 | SceneObjectGroup sog = updates[i]; | ||
386 | |||
383 | // Don't abort the whole update if one entity happens to give us an exception. | 387 | // Don't abort the whole update if one entity happens to give us an exception. |
384 | try | 388 | try |
385 | { | 389 | { |
386 | kvp.Value.Update(); | 390 | sog.Update(); |
387 | } | 391 | } |
388 | catch (Exception e) | 392 | catch (Exception e) |
389 | { | 393 | { |
390 | m_log.ErrorFormat( | 394 | m_log.ErrorFormat( |
391 | "[INNER SCENE]: Failed to update {0}, {1} - {2}", kvp.Value.Name, kvp.Value.UUID, e); | 395 | "[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e); |
392 | } | 396 | } |
393 | } | 397 | } |
394 | } | 398 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index ab7abbe..ea4f2c7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -204,6 +204,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
204 | get { return m_parts.Count; } | 204 | get { return m_parts.Count; } |
205 | } | 205 | } |
206 | 206 | ||
207 | protected Quaternion m_rotation = Quaternion.Identity; | ||
208 | |||
209 | public virtual Quaternion Rotation | ||
210 | { | ||
211 | get { return m_rotation; } | ||
212 | set { m_rotation = value; } | ||
213 | } | ||
214 | |||
207 | public Quaternion GroupRotation | 215 | public Quaternion GroupRotation |
208 | { | 216 | { |
209 | get { return m_rootPart.RotationOffset; } | 217 | get { return m_rootPart.RotationOffset; } |
@@ -1015,9 +1023,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1015 | } | 1023 | } |
1016 | } | 1024 | } |
1017 | 1025 | ||
1018 | public float GetTimeDilation() | 1026 | public ushort GetTimeDilation() |
1019 | { | 1027 | { |
1020 | return m_scene.TimeDilation; | 1028 | return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f); |
1021 | } | 1029 | } |
1022 | 1030 | ||
1023 | /// <summary> | 1031 | /// <summary> |
@@ -1896,28 +1904,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1896 | { | 1904 | { |
1897 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); | 1905 | bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); |
1898 | 1906 | ||
1899 | //if (IsAttachment) | 1907 | if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f)) |
1900 | //{ | ||
1901 | //foreach (SceneObjectPart part in m_parts.Values) | ||
1902 | //{ | ||
1903 | //part.SendScheduledUpdates(); | ||
1904 | //} | ||
1905 | //return; | ||
1906 | //} | ||
1907 | |||
1908 | if (UsePhysics && Util.DistanceLessThan(lastPhysGroupPos, AbsolutePosition, 0.02)) | ||
1909 | { | 1908 | { |
1910 | m_rootPart.UpdateFlag = 1; | 1909 | m_rootPart.UpdateFlag = 1; |
1911 | lastPhysGroupPos = AbsolutePosition; | 1910 | lastPhysGroupPos = AbsolutePosition; |
1912 | } | 1911 | } |
1913 | 1912 | ||
1914 | if (UsePhysics && ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) | 1913 | if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f)) |
1915 | || (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1) | ||
1916 | || (Math.Abs(lastPhysGroupRot.Y - GroupRotation.Y) > 0.1) | ||
1917 | || (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1))) | ||
1918 | { | 1914 | { |
1919 | m_rootPart.UpdateFlag = 1; | 1915 | m_rootPart.UpdateFlag = 1; |
1920 | |||
1921 | lastPhysGroupRot = GroupRotation; | 1916 | lastPhysGroupRot = GroupRotation; |
1922 | } | 1917 | } |
1923 | 1918 | ||
@@ -2011,12 +2006,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2011 | /// Note: this may not be cused by opensim (it probably should) but it's used by | 2006 | /// Note: this may not be cused by opensim (it probably should) but it's used by |
2012 | /// external modules. | 2007 | /// external modules. |
2013 | /// </summary> | 2008 | /// </summary> |
2014 | public void SendGroupRootUpdate() | 2009 | public void SendGroupRootTerseUpdate() |
2015 | { | 2010 | { |
2016 | if (IsDeleted) | 2011 | if (IsDeleted) |
2017 | return; | 2012 | return; |
2018 | 2013 | ||
2019 | RootPart.SendFullUpdateToAllClients(); | 2014 | RootPart.SendTerseUpdateToAllClients(); |
2020 | } | 2015 | } |
2021 | 2016 | ||
2022 | public void QueueForUpdateCheck() | 2017 | public void QueueForUpdateCheck() |
@@ -2998,12 +2993,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2998 | /// <param name="rot"></param> | 2993 | /// <param name="rot"></param> |
2999 | public void UpdateGroupRotationR(Quaternion rot) | 2994 | public void UpdateGroupRotationR(Quaternion rot) |
3000 | { | 2995 | { |
3001 | |||
3002 | m_rootPart.UpdateRotation(rot); | 2996 | m_rootPart.UpdateRotation(rot); |
3003 | if (m_rootPart.PhysActor != null) | 2997 | |
2998 | PhysicsActor actor = m_rootPart.PhysActor; | ||
2999 | if (actor != null) | ||
3004 | { | 3000 | { |
3005 | m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; | 3001 | actor.Orientation = m_rootPart.RotationOffset; |
3006 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 3002 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
3007 | } | 3003 | } |
3008 | 3004 | ||
3009 | HasGroupChanged = true; | 3005 | HasGroupChanged = true; |
@@ -3018,11 +3014,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3018 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) | 3014 | public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) |
3019 | { | 3015 | { |
3020 | m_rootPart.UpdateRotation(rot); | 3016 | m_rootPart.UpdateRotation(rot); |
3021 | if (m_rootPart.PhysActor != null) | 3017 | |
3018 | PhysicsActor actor = m_rootPart.PhysActor; | ||
3019 | if (actor != null) | ||
3022 | { | 3020 | { |
3023 | m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset; | 3021 | actor.Orientation = m_rootPart.RotationOffset; |
3024 | m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); | 3022 | m_scene.PhysicsScene.AddPhysicsActorTaint(actor); |
3025 | } | 3023 | } |
3024 | |||
3026 | AbsolutePosition = pos; | 3025 | AbsolutePosition = pos; |
3027 | 3026 | ||
3028 | HasGroupChanged = true; | 3027 | HasGroupChanged = true; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 7d889ee..bf2f3d3 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -243,7 +243,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
243 | protected SceneObjectGroup m_parentGroup; | 243 | protected SceneObjectGroup m_parentGroup; |
244 | protected byte[] m_particleSystem = Utils.EmptyBytes; | 244 | protected byte[] m_particleSystem = Utils.EmptyBytes; |
245 | protected ulong m_regionHandle; | 245 | protected ulong m_regionHandle; |
246 | protected Quaternion m_rotationOffset; | 246 | protected Quaternion m_rotationOffset = Quaternion.Identity; |
247 | protected PrimitiveBaseShape m_shape; | 247 | protected PrimitiveBaseShape m_shape; |
248 | protected UUID m_uuid; | 248 | protected UUID m_uuid; |
249 | protected Vector3 m_velocity; | 249 | protected Vector3 m_velocity; |
@@ -253,6 +253,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
253 | protected Vector3 m_lastVelocity; | 253 | protected Vector3 m_lastVelocity; |
254 | protected Vector3 m_lastAcceleration; | 254 | protected Vector3 m_lastAcceleration; |
255 | protected Vector3 m_lastAngularVelocity; | 255 | protected Vector3 m_lastAngularVelocity; |
256 | protected int m_lastTerseSent; | ||
256 | 257 | ||
257 | // TODO: Those have to be changed into persistent properties at some later point, | 258 | // TODO: Those have to be changed into persistent properties at some later point, |
258 | // or sit-camera on vehicles will break on sim-crossing. | 259 | // or sit-camera on vehicles will break on sim-crossing. |
@@ -506,20 +507,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
506 | get | 507 | get |
507 | { | 508 | { |
508 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 509 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
509 | if (PhysActor != null && _parentID == 0) | 510 | PhysicsActor actor = PhysActor; |
511 | if (actor != null && _parentID == 0) | ||
510 | { | 512 | { |
511 | m_groupPosition.X = PhysActor.Position.X; | 513 | m_groupPosition = actor.Position; |
512 | m_groupPosition.Y = PhysActor.Position.Y; | ||
513 | m_groupPosition.Z = PhysActor.Position.Z; | ||
514 | } | 514 | } |
515 | 515 | ||
516 | if (IsAttachment) | 516 | if (IsAttachment) |
517 | { | 517 | { |
518 | ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); | 518 | ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); |
519 | if (sp != null) | 519 | if (sp != null) |
520 | { | ||
521 | return sp.AbsolutePosition; | 520 | return sp.AbsolutePosition; |
522 | } | ||
523 | } | 521 | } |
524 | 522 | ||
525 | return m_groupPosition; | 523 | return m_groupPosition; |
@@ -530,26 +528,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
530 | 528 | ||
531 | m_groupPosition = value; | 529 | m_groupPosition = value; |
532 | 530 | ||
533 | if (PhysActor != null) | 531 | PhysicsActor actor = PhysActor; |
532 | if (actor != null) | ||
534 | { | 533 | { |
535 | try | 534 | try |
536 | { | 535 | { |
537 | // Root prim actually goes at Position | 536 | // Root prim actually goes at Position |
538 | if (_parentID == 0) | 537 | if (_parentID == 0) |
539 | { | 538 | { |
540 | PhysActor.Position = value; | 539 | actor.Position = value; |
541 | } | 540 | } |
542 | else | 541 | else |
543 | { | 542 | { |
544 | // To move the child prim in respect to the group position and rotation we have to calculate | 543 | // To move the child prim in respect to the group position and rotation we have to calculate |
545 | Vector3 resultingposition = GetWorldPosition(); | 544 | actor.Position = GetWorldPosition(); |
546 | PhysActor.Position = resultingposition; | 545 | actor.Orientation = GetWorldRotation(); |
547 | Quaternion resultingrot = GetWorldRotation(); | ||
548 | PhysActor.Orientation = resultingrot; | ||
549 | } | 546 | } |
550 | 547 | ||
551 | // Tell the physics engines that this prim changed. | 548 | // Tell the physics engines that this prim changed. |
552 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 549 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
553 | } | 550 | } |
554 | catch (Exception e) | 551 | catch (Exception e) |
555 | { | 552 | { |
@@ -582,15 +579,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
582 | 579 | ||
583 | if (ParentGroup != null && !ParentGroup.IsDeleted) | 580 | if (ParentGroup != null && !ParentGroup.IsDeleted) |
584 | { | 581 | { |
585 | if (_parentID != 0 && PhysActor != null) | 582 | PhysicsActor actor = PhysActor; |
583 | if (_parentID != 0 && actor != null) | ||
586 | { | 584 | { |
587 | Vector3 resultingposition = GetWorldPosition(); | 585 | actor.Position = GetWorldPosition(); |
588 | PhysActor.Position = resultingposition; | 586 | actor.Orientation = GetWorldRotation(); |
589 | Quaternion resultingrot = GetWorldRotation(); | ||
590 | PhysActor.Orientation = resultingrot; | ||
591 | 587 | ||
592 | // Tell the physics engines that this prim changed. | 588 | // Tell the physics engines that this prim changed. |
593 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 589 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
594 | } | 590 | } |
595 | } | 591 | } |
596 | } | 592 | } |
@@ -601,12 +597,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
601 | get | 597 | get |
602 | { | 598 | { |
603 | // We don't want the physics engine mucking up the rotations in a linkset | 599 | // We don't want the physics engine mucking up the rotations in a linkset |
604 | if ((_parentID == 0) && (Shape.PCode != 9 || Shape.State == 0) && (PhysActor != null)) | 600 | PhysicsActor actor = PhysActor; |
601 | if (_parentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) | ||
605 | { | 602 | { |
606 | if (PhysActor.Orientation.X != 0 || PhysActor.Orientation.Y != 0 | 603 | if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f |
607 | || PhysActor.Orientation.Z != 0 || PhysActor.Orientation.W != 0) | 604 | || actor.Orientation.Z != 0f || actor.Orientation.W != 0f) |
608 | { | 605 | { |
609 | m_rotationOffset = PhysActor.Orientation; | 606 | m_rotationOffset = actor.Orientation; |
610 | } | 607 | } |
611 | } | 608 | } |
612 | 609 | ||
@@ -618,24 +615,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
618 | StoreUndoState(); | 615 | StoreUndoState(); |
619 | m_rotationOffset = value; | 616 | m_rotationOffset = value; |
620 | 617 | ||
621 | if (PhysActor != null) | 618 | PhysicsActor actor = PhysActor; |
619 | if (actor != null) | ||
622 | { | 620 | { |
623 | try | 621 | try |
624 | { | 622 | { |
625 | // Root prim gets value directly | 623 | // Root prim gets value directly |
626 | if (_parentID == 0) | 624 | if (_parentID == 0) |
627 | { | 625 | { |
628 | PhysActor.Orientation = value; | 626 | actor.Orientation = value; |
629 | //m_log.Info("[PART]: RO1:" + PhysActor.Orientation.ToString()); | 627 | //m_log.Info("[PART]: RO1:" + actor.Orientation.ToString()); |
630 | } | 628 | } |
631 | else | 629 | else |
632 | { | 630 | { |
633 | // Child prim we have to calculate it's world rotationwel | 631 | // Child prim we have to calculate it's world rotationwel |
634 | Quaternion resultingrotation = GetWorldRotation(); | 632 | Quaternion resultingrotation = GetWorldRotation(); |
635 | PhysActor.Orientation = resultingrotation; | 633 | actor.Orientation = resultingrotation; |
636 | //m_log.Info("[PART]: RO2:" + PhysActor.Orientation.ToString()); | 634 | //m_log.Info("[PART]: RO2:" + actor.Orientation.ToString()); |
637 | } | 635 | } |
638 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 636 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
639 | //} | 637 | //} |
640 | } | 638 | } |
641 | catch (Exception ex) | 639 | catch (Exception ex) |
@@ -652,16 +650,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
652 | { | 650 | { |
653 | get | 651 | get |
654 | { | 652 | { |
655 | //if (PhysActor.Velocity.X != 0 || PhysActor.Velocity.Y != 0 | 653 | PhysicsActor actor = PhysActor; |
656 | //|| PhysActor.Velocity.Z != 0) | 654 | if (actor != null) |
657 | //{ | ||
658 | if (PhysActor != null) | ||
659 | { | 655 | { |
660 | if (PhysActor.IsPhysical) | 656 | if (actor.IsPhysical) |
661 | { | 657 | { |
662 | m_velocity.X = PhysActor.Velocity.X; | 658 | m_velocity = actor.Velocity; |
663 | m_velocity.Y = PhysActor.Velocity.Y; | ||
664 | m_velocity.Z = PhysActor.Velocity.Z; | ||
665 | } | 659 | } |
666 | } | 660 | } |
667 | 661 | ||
@@ -671,31 +665,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
671 | set | 665 | set |
672 | { | 666 | { |
673 | m_velocity = value; | 667 | m_velocity = value; |
674 | if (PhysActor != null) | 668 | |
669 | PhysicsActor actor = PhysActor; | ||
670 | if (actor != null) | ||
675 | { | 671 | { |
676 | if (PhysActor.IsPhysical) | 672 | if (actor.IsPhysical) |
677 | { | 673 | { |
678 | PhysActor.Velocity = value; | 674 | actor.Velocity = value; |
679 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 675 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
680 | } | 676 | } |
681 | } | 677 | } |
682 | } | 678 | } |
683 | } | 679 | } |
684 | 680 | ||
685 | public Vector3 RotationalVelocity | ||
686 | { | ||
687 | get { return AngularVelocity; } | ||
688 | set { AngularVelocity = value; } | ||
689 | } | ||
690 | |||
691 | /// <summary></summary> | 681 | /// <summary></summary> |
692 | public Vector3 AngularVelocity | 682 | public Vector3 AngularVelocity |
693 | { | 683 | { |
694 | get | 684 | get |
695 | { | 685 | { |
696 | if ((PhysActor != null) && PhysActor.IsPhysical) | 686 | PhysicsActor actor = PhysActor; |
687 | if ((actor != null) && actor.IsPhysical) | ||
697 | { | 688 | { |
698 | m_angularVelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(), 0); | 689 | m_angularVelocity = actor.RotationalVelocity; |
699 | } | 690 | } |
700 | return m_angularVelocity; | 691 | return m_angularVelocity; |
701 | } | 692 | } |
@@ -715,9 +706,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
715 | set | 706 | set |
716 | { | 707 | { |
717 | m_description = value; | 708 | m_description = value; |
718 | if (PhysActor != null) | 709 | PhysicsActor actor = PhysActor; |
710 | if (actor != null) | ||
719 | { | 711 | { |
720 | PhysActor.SOPDescription = value; | 712 | actor.SOPDescription = value; |
721 | } | 713 | } |
722 | } | 714 | } |
723 | } | 715 | } |
@@ -808,21 +800,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
808 | set | 800 | set |
809 | { | 801 | { |
810 | StoreUndoState(); | 802 | StoreUndoState(); |
811 | if (m_shape != null) { | 803 | if (m_shape != null) |
812 | m_shape.Scale = value; | ||
813 | |||
814 | if (PhysActor != null && m_parentGroup != null) | ||
815 | { | 804 | { |
816 | if (m_parentGroup.Scene != null) | 805 | m_shape.Scale = value; |
806 | |||
807 | PhysicsActor actor = PhysActor; | ||
808 | if (actor != null && m_parentGroup != null) | ||
817 | { | 809 | { |
818 | if (m_parentGroup.Scene.PhysicsScene != null) | 810 | if (m_parentGroup.Scene != null) |
819 | { | 811 | { |
820 | PhysActor.Size = m_shape.Scale; | 812 | if (m_parentGroup.Scene.PhysicsScene != null) |
821 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor); | 813 | { |
814 | actor.Size = m_shape.Scale; | ||
815 | m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | ||
816 | } | ||
822 | } | 817 | } |
823 | } | 818 | } |
824 | } | 819 | } |
825 | } | ||
826 | TriggerScriptChangedEvent(Changed.SCALE); | 820 | TriggerScriptChangedEvent(Changed.SCALE); |
827 | } | 821 | } |
828 | } | 822 | } |
@@ -1056,8 +1050,6 @@ if (m_shape != null) { | |||
1056 | 1050 | ||
1057 | #endregion Public Properties with only Get | 1051 | #endregion Public Properties with only Get |
1058 | 1052 | ||
1059 | |||
1060 | |||
1061 | #region Private Methods | 1053 | #region Private Methods |
1062 | 1054 | ||
1063 | private uint ApplyMask(uint val, bool set, uint mask) | 1055 | private uint ApplyMask(uint val, bool set, uint mask) |
@@ -1072,14 +1064,6 @@ if (m_shape != null) { | |||
1072 | } | 1064 | } |
1073 | } | 1065 | } |
1074 | 1066 | ||
1075 | /// <summary> | ||
1076 | /// Clear all pending updates of parts to clients | ||
1077 | /// </summary> | ||
1078 | private void ClearUpdateSchedule() | ||
1079 | { | ||
1080 | m_updateFlag = 0; | ||
1081 | } | ||
1082 | |||
1083 | private void SendObjectPropertiesToClient(UUID AgentID) | 1067 | private void SendObjectPropertiesToClient(UUID AgentID) |
1084 | { | 1068 | { |
1085 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); | 1069 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); |
@@ -1551,9 +1535,9 @@ if (m_shape != null) { | |||
1551 | m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed? | 1535 | m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed? |
1552 | 1536 | ||
1553 | // make sure client isn't interpolating the joint proxy object | 1537 | // make sure client isn't interpolating the joint proxy object |
1554 | Velocity = new Vector3(0, 0, 0); | 1538 | Velocity = Vector3.Zero; |
1555 | RotationalVelocity = new Vector3(0, 0, 0); | 1539 | AngularVelocity = Vector3.Zero; |
1556 | Acceleration = new Vector3(0, 0, 0); | 1540 | Acceleration = Vector3.Zero; |
1557 | } | 1541 | } |
1558 | } | 1542 | } |
1559 | } | 1543 | } |
@@ -1816,7 +1800,7 @@ if (m_shape != null) { | |||
1816 | } | 1800 | } |
1817 | 1801 | ||
1818 | CollisionEventUpdate a = (CollisionEventUpdate)e; | 1802 | CollisionEventUpdate a = (CollisionEventUpdate)e; |
1819 | Dictionary<uint, float> collissionswith = a.m_objCollisionList; | 1803 | Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList; |
1820 | List<uint> thisHitColliders = new List<uint>(); | 1804 | List<uint> thisHitColliders = new List<uint>(); |
1821 | List<uint> endedColliders = new List<uint>(); | 1805 | List<uint> endedColliders = new List<uint>(); |
1822 | List<uint> startedColliders = new List<uint>(); | 1806 | List<uint> startedColliders = new List<uint>(); |
@@ -2387,8 +2371,8 @@ if (m_shape != null) { | |||
2387 | //isattachment = ParentGroup.RootPart.IsAttachment; | 2371 | //isattachment = ParentGroup.RootPart.IsAttachment; |
2388 | 2372 | ||
2389 | byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; | 2373 | byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A}; |
2390 | remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape, | 2374 | remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, m_shape, |
2391 | lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID, | 2375 | lPos, Velocity, Acceleration, RotationOffset, AngularVelocity, clientFlags, m_uuid, _ownerID, |
2392 | m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, | 2376 | m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment, |
2393 | AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient))); | 2377 | AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient))); |
2394 | } | 2378 | } |
@@ -2398,20 +2382,23 @@ if (m_shape != null) { | |||
2398 | /// </summary> | 2382 | /// </summary> |
2399 | public void SendScheduledUpdates() | 2383 | public void SendScheduledUpdates() |
2400 | { | 2384 | { |
2401 | const float VELOCITY_TOLERANCE = 0.01f; | 2385 | const float ROTATION_TOLERANCE = 0.01f; |
2402 | const float POSITION_TOLERANCE = 0.1f; | 2386 | const float VELOCITY_TOLERANCE = 0.001f; |
2387 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary | ||
2388 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. | ||
2403 | 2389 | ||
2404 | if (m_updateFlag == 1) | 2390 | if (m_updateFlag == 1) |
2405 | { | 2391 | { |
2406 | // Throw away duplicate or insignificant updates | 2392 | // Throw away duplicate or insignificant updates |
2407 | if (RotationOffset != m_lastRotation || | 2393 | if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2408 | Acceleration != m_lastAcceleration || | 2394 | !Acceleration.Equals(m_lastAcceleration) || |
2409 | (Velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || | 2395 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2410 | (RotationalVelocity - m_lastAngularVelocity).Length() > VELOCITY_TOLERANCE || | 2396 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || |
2411 | (OffsetPosition - m_lastPosition).Length() > POSITION_TOLERANCE) | 2397 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
2398 | Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | ||
2412 | { | 2399 | { |
2413 | AddTerseUpdateToAllAvatars(); | 2400 | AddTerseUpdateToAllAvatars(); |
2414 | ClearUpdateSchedule(); | 2401 | |
2415 | 2402 | ||
2416 | // This causes the Scene to 'poll' physical objects every couple of frames | 2403 | // This causes the Scene to 'poll' physical objects every couple of frames |
2417 | // bad, so it's been replaced by an event driven method. | 2404 | // bad, so it's been replaced by an event driven method. |
@@ -2426,15 +2413,18 @@ if (m_shape != null) { | |||
2426 | m_lastRotation = RotationOffset; | 2413 | m_lastRotation = RotationOffset; |
2427 | m_lastVelocity = Velocity; | 2414 | m_lastVelocity = Velocity; |
2428 | m_lastAcceleration = Acceleration; | 2415 | m_lastAcceleration = Acceleration; |
2429 | m_lastAngularVelocity = RotationalVelocity; | 2416 | m_lastAngularVelocity = AngularVelocity; |
2417 | m_lastTerseSent = Environment.TickCount; | ||
2430 | } | 2418 | } |
2419 | //Moved this outside of the if clause so updates don't get blocked.. *sigh* | ||
2420 | m_updateFlag = 0; //Why were we calling a function to do this? Inefficient! *screams* | ||
2431 | } | 2421 | } |
2432 | else | 2422 | else |
2433 | { | 2423 | { |
2434 | if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes | 2424 | if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes |
2435 | { | 2425 | { |
2436 | AddFullUpdateToAllAvatars(); | 2426 | AddFullUpdateToAllAvatars(); |
2437 | ClearUpdateSchedule(); | 2427 | m_updateFlag = 0; //Same here |
2438 | } | 2428 | } |
2439 | } | 2429 | } |
2440 | } | 2430 | } |
@@ -3774,14 +3764,12 @@ if (m_shape != null) { | |||
3774 | 3764 | ||
3775 | Vector3 lPos = OffsetPosition; | 3765 | Vector3 lPos = OffsetPosition; |
3776 | 3766 | ||
3777 | byte state = Shape.State; | ||
3778 | if (IsAttachment) | 3767 | if (IsAttachment) |
3779 | { | 3768 | { |
3780 | if (ParentGroup.RootPart != this) | 3769 | if (ParentGroup.RootPart != this) |
3781 | return; | 3770 | return; |
3782 | 3771 | ||
3783 | lPos = ParentGroup.RootPart.AttachedPos; | 3772 | lPos = ParentGroup.RootPart.AttachedPos; |
3784 | state = (byte)AttachmentPoint; | ||
3785 | } | 3773 | } |
3786 | else | 3774 | else |
3787 | { | 3775 | { |
@@ -3792,10 +3780,9 @@ if (m_shape != null) { | |||
3792 | // Causes this thread to dig into the Client Thread Data. | 3780 | // Causes this thread to dig into the Client Thread Data. |
3793 | // Remember your locking here! | 3781 | // Remember your locking here! |
3794 | remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle, | 3782 | remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle, |
3795 | (ushort)(m_parentGroup.GetTimeDilation() * | 3783 | m_parentGroup.GetTimeDilation(), LocalId, lPos, |
3796 | (float)ushort.MaxValue), LocalId, lPos, | ||
3797 | RotationOffset, Velocity, Acceleration, | 3784 | RotationOffset, Velocity, Acceleration, |
3798 | RotationalVelocity, state, FromItemID, | 3785 | AngularVelocity, FromItemID, |
3799 | OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient))); | 3786 | OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient))); |
3800 | } | 3787 | } |
3801 | 3788 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 87fac0c..08c144a 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -76,8 +76,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
77 | 77 | ||
78 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; | 78 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; |
79 | 79 | // private static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); | |
80 | public static byte[] DefaultTexture; | 80 | private static readonly Array DIR_CONTROL_FLAGS = Enum.GetValues(typeof(Dir_ControlFlags)); |
81 | private static readonly Vector3 HEAD_ADJUSTMENT = new Vector3(0f, 0f, 0.3f); | ||
82 | /// <summary> | ||
83 | /// Experimentally determined "fudge factor" to make sit-target positions | ||
84 | /// the same as in SecondLife. Fudge factor was tested for 36 different | ||
85 | /// test cases including prims of type box, sphere, cylinder, and torus, | ||
86 | /// with varying parameters for sit target location, prim size, prim | ||
87 | /// rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | ||
88 | /// issue #1716 | ||
89 | /// </summary> | ||
90 | private static readonly Vector3 SIT_TARGET_ADJUSTMENT = new Vector3(0.1f, 0.0f, 0.3f); | ||
81 | 91 | ||
82 | public UUID currentParcelUUID = UUID.Zero; | 92 | public UUID currentParcelUUID = UUID.Zero; |
83 | 93 | ||
@@ -92,16 +102,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
92 | //private SceneObjectPart proxyObjectPart = null; | 102 | //private SceneObjectPart proxyObjectPart = null; |
93 | public Vector3 lastKnownAllowedPosition; | 103 | public Vector3 lastKnownAllowedPosition; |
94 | public bool sentMessageAboutRestrictedParcelFlyingDown; | 104 | public bool sentMessageAboutRestrictedParcelFlyingDown; |
105 | public Vector4 CollisionPlane = Vector4.UnitW; | ||
95 | 106 | ||
96 | private Vector3 m_lastPosition; | 107 | private Vector3 m_lastPosition; |
97 | private Quaternion m_lastRotation; | 108 | private Quaternion m_lastRotation; |
98 | private Vector3 m_lastVelocity; | 109 | private Vector3 m_lastVelocity; |
110 | //private int m_lastTerseSent; | ||
99 | 111 | ||
100 | private bool m_updateflag; | 112 | private bool m_updateflag; |
101 | private byte m_movementflag; | 113 | private byte m_movementflag; |
102 | private readonly List<NewForce> m_forcesList = new List<NewForce>(); | 114 | private Vector3? m_forceToApply; |
103 | private uint m_requestedSitTargetID; | 115 | private uint m_requestedSitTargetID; |
104 | private UUID m_requestedSitTargetUUID = UUID.Zero; | 116 | private UUID m_requestedSitTargetUUID; |
105 | private SendCourseLocationsMethod m_sendCourseLocationsMethod; | 117 | private SendCourseLocationsMethod m_sendCourseLocationsMethod; |
106 | 118 | ||
107 | private bool m_startAnimationSet; | 119 | private bool m_startAnimationSet; |
@@ -112,30 +124,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
112 | 124 | ||
113 | private float m_sitAvatarHeight = 2.0f; | 125 | private float m_sitAvatarHeight = 2.0f; |
114 | 126 | ||
115 | // experimentally determined "fudge factor" to make sit-target positions | ||
116 | // the same as in SecondLife. Fudge factor was tested for 36 different | ||
117 | // test cases including prims of type box, sphere, cylinder, and torus, | ||
118 | // with varying parameters for sit target location, prim size, prim | ||
119 | // rotation, prim cut, prim twist, prim taper, and prim shear. See mantis | ||
120 | // issue #1716 | ||
121 | private static readonly Vector3 m_sitTargetCorrectionOffset = new Vector3(0.1f, 0.0f, 0.3f); | ||
122 | private float m_godlevel; | 127 | private float m_godlevel; |
123 | 128 | ||
124 | private bool m_invulnerable = true; | 129 | private bool m_invulnerable = true; |
125 | 130 | ||
126 | private Vector3 m_LastChildAgentUpdatePosition; | 131 | private Vector3 m_lastChildAgentUpdatePosition; |
132 | private Vector3 m_lastChildAgentUpdateCamPosition; | ||
127 | 133 | ||
128 | private int m_perfMonMS; | 134 | private int m_perfMonMS; |
129 | 135 | ||
130 | private bool m_setAlwaysRun; | 136 | private bool m_setAlwaysRun; |
131 | 137 | ||
132 | private string m_movementAnimation = "DEFAULT"; | 138 | private string m_movementAnimation = "DEFAULT"; |
133 | private long m_animPersistUntil = 0; | 139 | private int m_animTickFall; |
134 | private bool m_allowFalling = false; | 140 | private int m_animTickJump; |
135 | private bool m_useFlySlow = false; | 141 | private bool m_useFlySlow; |
136 | private bool m_usePreJump = false; | 142 | private bool m_usePreJump; |
137 | private bool m_forceFly = false; | 143 | private bool m_forceFly; |
138 | private bool m_flyDisabled = false; | 144 | private bool m_flyDisabled; |
139 | 145 | ||
140 | private float m_speedModifier = 1.0f; | 146 | private float m_speedModifier = 1.0f; |
141 | 147 | ||
@@ -143,7 +149,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
143 | 149 | ||
144 | public bool IsRestrictedToRegion; | 150 | public bool IsRestrictedToRegion; |
145 | 151 | ||
146 | public string JID = string.Empty; | 152 | public string JID = String.Empty; |
147 | 153 | ||
148 | // Agent moves with a PID controller causing a force to be exerted. | 154 | // Agent moves with a PID controller causing a force to be exerted. |
149 | private bool m_newCoarseLocations = true; | 155 | private bool m_newCoarseLocations = true; |
@@ -158,43 +164,43 @@ namespace OpenSim.Region.Framework.Scenes | |||
158 | private readonly Vector3[] Dir_Vectors = new Vector3[6]; | 164 | private readonly Vector3[] Dir_Vectors = new Vector3[6]; |
159 | 165 | ||
160 | // Position of agent's camera in world (region cordinates) | 166 | // Position of agent's camera in world (region cordinates) |
161 | protected Vector3 m_CameraCenter = Vector3.Zero; | 167 | protected Vector3 m_CameraCenter; |
162 | protected Vector3 m_lastCameraCenter = Vector3.Zero; | 168 | protected Vector3 m_lastCameraCenter; |
163 | 169 | ||
164 | protected Timer m_reprioritization_timer; | 170 | protected Timer m_reprioritization_timer; |
165 | protected bool m_reprioritizing = false; | 171 | protected bool m_reprioritizing; |
166 | protected bool m_reprioritization_called = false; | 172 | protected bool m_reprioritization_called; |
167 | 173 | ||
168 | // Use these three vectors to figure out what the agent is looking at | 174 | // Use these three vectors to figure out what the agent is looking at |
169 | // Convert it to a Matrix and/or Quaternion | 175 | // Convert it to a Matrix and/or Quaternion |
170 | protected Vector3 m_CameraAtAxis = Vector3.Zero; | 176 | protected Vector3 m_CameraAtAxis; |
171 | protected Vector3 m_CameraLeftAxis = Vector3.Zero; | 177 | protected Vector3 m_CameraLeftAxis; |
172 | protected Vector3 m_CameraUpAxis = Vector3.Zero; | 178 | protected Vector3 m_CameraUpAxis; |
173 | private uint m_AgentControlFlags; | 179 | private AgentManager.ControlFlags m_AgentControlFlags; |
174 | private Quaternion m_headrotation = Quaternion.Identity; | 180 | private Quaternion m_headrotation = Quaternion.Identity; |
175 | private byte m_state; | 181 | private byte m_state; |
176 | 182 | ||
177 | //Reuse the Vector3 instead of creating a new one on the UpdateMovement method | 183 | //Reuse the Vector3 instead of creating a new one on the UpdateMovement method |
178 | private Vector3 movementvector = Vector3.Zero; | 184 | // private Vector3 movementvector; |
179 | 185 | ||
180 | private bool m_autopilotMoving; | 186 | private bool m_autopilotMoving; |
181 | private Vector3 m_autoPilotTarget = Vector3.Zero; | 187 | private Vector3 m_autoPilotTarget; |
182 | private bool m_sitAtAutoTarget; | 188 | private bool m_sitAtAutoTarget; |
183 | 189 | ||
184 | private string m_nextSitAnimation = String.Empty; | 190 | private string m_nextSitAnimation = String.Empty; |
185 | 191 | ||
186 | //PauPaw:Proper PID Controler for autopilot************ | 192 | //PauPaw:Proper PID Controler for autopilot************ |
187 | private bool m_moveToPositionInProgress; | 193 | private bool m_moveToPositionInProgress; |
188 | private Vector3 m_moveToPositionTarget = Vector3.Zero; | 194 | private Vector3 m_moveToPositionTarget; |
189 | 195 | ||
190 | private bool m_followCamAuto = false; | 196 | private bool m_followCamAuto; |
191 | 197 | ||
192 | private int m_movementUpdateCount = 0; | 198 | private int m_movementUpdateCount; |
193 | 199 | ||
194 | private const int NumMovementsBetweenRayCast = 5; | 200 | private const int NumMovementsBetweenRayCast = 5; |
195 | 201 | ||
196 | private bool CameraConstraintActive = false; | 202 | private bool CameraConstraintActive; |
197 | //private int m_moveToPositionStateStatus = 0; | 203 | //private int m_moveToPositionStateStatus; |
198 | //***************************************************** | 204 | //***************************************************** |
199 | 205 | ||
200 | // Agent's Draw distance. | 206 | // Agent's Draw distance. |
@@ -268,11 +274,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
268 | get { return m_godlevel; } | 274 | get { return m_godlevel; } |
269 | } | 275 | } |
270 | 276 | ||
271 | private readonly ulong m_regionHandle; | ||
272 | |||
273 | public ulong RegionHandle | 277 | public ulong RegionHandle |
274 | { | 278 | { |
275 | get { return m_regionHandle; } | 279 | get { return m_rootRegionHandle; } |
276 | } | 280 | } |
277 | 281 | ||
278 | public Vector3 CameraPosition | 282 | public Vector3 CameraPosition |
@@ -379,8 +383,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
379 | 383 | ||
380 | public uint AgentControlFlags | 384 | public uint AgentControlFlags |
381 | { | 385 | { |
382 | get { return m_AgentControlFlags; } | 386 | get { return (uint)m_AgentControlFlags; } |
383 | set { m_AgentControlFlags = value; } | 387 | set { m_AgentControlFlags = (AgentManager.ControlFlags)value; } |
384 | } | 388 | } |
385 | 389 | ||
386 | /// <summary> | 390 | /// <summary> |
@@ -411,31 +415,27 @@ namespace OpenSim.Region.Framework.Scenes | |||
411 | } | 415 | } |
412 | 416 | ||
413 | /// <summary> | 417 | /// <summary> |
414 | /// Absolute position of this avatar in 'region cordinates' | 418 | /// Position of this avatar relative to the region the avatar is in |
415 | /// </summary> | 419 | /// </summary> |
416 | public override Vector3 AbsolutePosition | 420 | public override Vector3 AbsolutePosition |
417 | { | 421 | { |
418 | get | 422 | get |
419 | { | 423 | { |
420 | if (m_physicsActor != null) | 424 | PhysicsActor actor = m_physicsActor; |
421 | { | 425 | if (actor != null) |
422 | m_pos.X = m_physicsActor.Position.X; | 426 | m_pos = actor.Position; |
423 | m_pos.Y = m_physicsActor.Position.Y; | ||
424 | m_pos.Z = m_physicsActor.Position.Z; | ||
425 | } | ||
426 | 427 | ||
427 | return m_parentPosition + m_pos; | 428 | return m_parentPosition + m_pos; |
428 | } | 429 | } |
429 | set | 430 | set |
430 | { | 431 | { |
431 | if (m_physicsActor != null) | 432 | PhysicsActor actor = m_physicsActor; |
433 | if (actor != null) | ||
432 | { | 434 | { |
433 | try | 435 | try |
434 | { | 436 | { |
435 | lock (m_scene.SyncRoot) | 437 | lock (m_scene.SyncRoot) |
436 | { | ||
437 | m_physicsActor.Position = value; | 438 | m_physicsActor.Position = value; |
438 | } | ||
439 | } | 439 | } |
440 | catch (Exception e) | 440 | catch (Exception e) |
441 | { | 441 | { |
@@ -444,7 +444,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
444 | } | 444 | } |
445 | 445 | ||
446 | m_pos = value; | 446 | m_pos = value; |
447 | m_parentPosition = new Vector3(0, 0, 0); | 447 | m_parentPosition = Vector3.Zero; |
448 | } | 448 | } |
449 | } | 449 | } |
450 | 450 | ||
@@ -455,27 +455,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
455 | { | 455 | { |
456 | get | 456 | get |
457 | { | 457 | { |
458 | if (m_physicsActor != null) | 458 | PhysicsActor actor = m_physicsActor; |
459 | { | 459 | if (actor != null) |
460 | m_velocity.X = m_physicsActor.Velocity.X; | 460 | m_velocity = actor.Velocity; |
461 | m_velocity.Y = m_physicsActor.Velocity.Y; | ||
462 | m_velocity.Z = m_physicsActor.Velocity.Z; | ||
463 | } | ||
464 | 461 | ||
465 | return m_velocity; | 462 | return m_velocity; |
466 | } | 463 | } |
467 | set | 464 | set |
468 | { | 465 | { |
469 | //m_log.DebugFormat("In {0} setting velocity of {1} to {2}", m_scene.RegionInfo.RegionName, Name, value); | 466 | PhysicsActor actor = m_physicsActor; |
470 | 467 | if (actor != null) | |
471 | if (m_physicsActor != null) | ||
472 | { | 468 | { |
473 | try | 469 | try |
474 | { | 470 | { |
475 | lock (m_scene.SyncRoot) | 471 | lock (m_scene.SyncRoot) |
476 | { | 472 | actor.Velocity = value; |
477 | m_physicsActor.Velocity = value; | ||
478 | } | ||
479 | } | 473 | } |
480 | catch (Exception e) | 474 | catch (Exception e) |
481 | { | 475 | { |
@@ -487,6 +481,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
487 | } | 481 | } |
488 | } | 482 | } |
489 | 483 | ||
484 | public Quaternion Rotation | ||
485 | { | ||
486 | get { return m_bodyRot; } | ||
487 | set { m_bodyRot = value; } | ||
488 | } | ||
489 | |||
490 | /// <summary> | 490 | /// <summary> |
491 | /// If this is true, agent doesn't have a representation in this scene. | 491 | /// If this is true, agent doesn't have a representation in this scene. |
492 | /// this is an agent 'looking into' this scene from a nearby scene(region) | 492 | /// this is an agent 'looking into' this scene from a nearby scene(region) |
@@ -627,7 +627,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
627 | { | 627 | { |
628 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 628 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
629 | CreateSceneViewer(); | 629 | CreateSceneViewer(); |
630 | m_regionHandle = reginfo.RegionHandle; | 630 | m_rootRegionHandle = reginfo.RegionHandle; |
631 | m_controllingClient = client; | 631 | m_controllingClient = client; |
632 | m_firstname = m_controllingClient.FirstName; | 632 | m_firstname = m_controllingClient.FirstName; |
633 | m_lastname = m_controllingClient.LastName; | 633 | m_lastname = m_controllingClient.LastName; |
@@ -710,25 +710,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
710 | 710 | ||
711 | private void SetDirectionVectors() | 711 | private void SetDirectionVectors() |
712 | { | 712 | { |
713 | Dir_Vectors[0] = new Vector3(1, 0, 0); //FORWARD | 713 | Dir_Vectors[0] = Vector3.UnitX; //FORWARD |
714 | Dir_Vectors[1] = new Vector3(-1, 0, 0); //BACK | 714 | Dir_Vectors[1] = -Vector3.UnitX; //BACK |
715 | Dir_Vectors[2] = new Vector3(0, 1, 0); //LEFT | 715 | Dir_Vectors[2] = Vector3.UnitY; //LEFT |
716 | Dir_Vectors[3] = new Vector3(0, -1, 0); //RIGHT | 716 | Dir_Vectors[3] = -Vector3.UnitY; //RIGHT |
717 | Dir_Vectors[4] = new Vector3(0, 0, 1); //UP | 717 | Dir_Vectors[4] = Vector3.UnitZ; //UP |
718 | Dir_Vectors[5] = new Vector3(0, 0, -1); //DOWN | 718 | Dir_Vectors[5] = -Vector3.UnitZ; //DOWN |
719 | Dir_Vectors[5] = new Vector3(0, 0, -0.5f); //DOWN_Nudge | 719 | Dir_Vectors[5] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge |
720 | } | 720 | } |
721 | 721 | ||
722 | private Vector3[] GetWalkDirectionVectors() | 722 | private Vector3[] GetWalkDirectionVectors() |
723 | { | 723 | { |
724 | Vector3[] vector = new Vector3[6]; | 724 | Vector3[] vector = new Vector3[6]; |
725 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0, -m_CameraAtAxis.Z); //FORWARD | 725 | vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD |
726 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0, m_CameraAtAxis.Z); //BACK | 726 | vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK |
727 | vector[2] = new Vector3(0, 1, 0); //LEFT | 727 | vector[2] = Vector3.UnitY; //LEFT |
728 | vector[3] = new Vector3(0, -1, 0); //RIGHT | 728 | vector[3] = -Vector3.UnitY; //RIGHT |
729 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0, m_CameraUpAxis.Z); //UP | 729 | vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP |
730 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0, -m_CameraUpAxis.Z); //DOWN | 730 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN |
731 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0, -m_CameraUpAxis.Z); //DOWN_Nudge | 731 | vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge |
732 | return vector; | 732 | return vector; |
733 | } | 733 | } |
734 | 734 | ||
@@ -781,6 +781,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
781 | if (gm != null) | 781 | if (gm != null) |
782 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 782 | m_grouptitle = gm.GetGroupTitle(m_uuid); |
783 | 783 | ||
784 | m_rootRegionHandle = m_scene.RegionInfo.RegionHandle; | ||
785 | |||
784 | m_scene.SetRootAgentScene(m_uuid); | 786 | m_scene.SetRootAgentScene(m_uuid); |
785 | 787 | ||
786 | // Moved this from SendInitialData to ensure that m_appearance is initialized | 788 | // Moved this from SendInitialData to ensure that m_appearance is initialized |
@@ -811,7 +813,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
811 | pos = emergencyPos; | 813 | pos = emergencyPos; |
812 | } | 814 | } |
813 | 815 | ||
814 | |||
815 | float localAVHeight = 1.56f; | 816 | float localAVHeight = 1.56f; |
816 | if (m_avHeight != 127.0f) | 817 | if (m_avHeight != 127.0f) |
817 | { | 818 | { |
@@ -906,6 +907,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
906 | m_isChildAgent = true; | 907 | m_isChildAgent = true; |
907 | m_scene.SwapRootAgentCount(true); | 908 | m_scene.SwapRootAgentCount(true); |
908 | RemoveFromPhysicalScene(); | 909 | RemoveFromPhysicalScene(); |
910 | |||
911 | // FIXME: Set m_rootRegionHandle to the region handle of the scene this agent is moving into | ||
909 | 912 | ||
910 | m_scene.EventManager.TriggerOnMakeChildAgent(this); | 913 | m_scene.EventManager.TriggerOnMakeChildAgent(this); |
911 | } | 914 | } |
@@ -937,7 +940,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
937 | isFlying = m_physicsActor.Flying; | 940 | isFlying = m_physicsActor.Flying; |
938 | 941 | ||
939 | RemoveFromPhysicalScene(); | 942 | RemoveFromPhysicalScene(); |
940 | Velocity = new Vector3(0, 0, 0); | 943 | Velocity = Vector3.Zero; |
941 | AbsolutePosition = pos; | 944 | AbsolutePosition = pos; |
942 | AddToPhysicalScene(isFlying); | 945 | AddToPhysicalScene(isFlying); |
943 | if (m_appearance != null) | 946 | if (m_appearance != null) |
@@ -985,12 +988,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
985 | 988 | ||
986 | if (m_avHeight != 127.0f) | 989 | if (m_avHeight != 127.0f) |
987 | { | 990 | { |
988 | AbsolutePosition = AbsolutePosition + new Vector3(0, 0, (m_avHeight / 6f)); | 991 | AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (m_avHeight / 6f)); |
989 | } | 992 | } |
990 | else | 993 | else |
991 | { | 994 | { |
992 | AbsolutePosition = AbsolutePosition + new Vector3(0, 0, (1.56f / 6f)); | 995 | AbsolutePosition = AbsolutePosition + new Vector3(0f, 0f, (1.56f / 6f)); |
993 | } | 996 | } |
997 | |||
994 | TrySetMovementAnimation("LAND"); | 998 | TrySetMovementAnimation("LAND"); |
995 | SendFullUpdateToAllClients(); | 999 | SendFullUpdateToAllClients(); |
996 | } | 1000 | } |
@@ -1076,7 +1080,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1076 | } | 1080 | } |
1077 | 1081 | ||
1078 | m_isChildAgent = false; | 1082 | m_isChildAgent = false; |
1079 | bool m_flying = ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | 1083 | bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); |
1080 | MakeRootAgent(AbsolutePosition, m_flying); | 1084 | MakeRootAgent(AbsolutePosition, m_flying); |
1081 | 1085 | ||
1082 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) | 1086 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) |
@@ -1103,9 +1107,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1103 | /// <param name="distance"></param> | 1107 | /// <param name="distance"></param> |
1104 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) | 1108 | public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) |
1105 | { | 1109 | { |
1110 | const float POSITION_TOLERANCE = 0.02f; | ||
1111 | const float VELOCITY_TOLERANCE = 0.02f; | ||
1112 | const float ROTATION_TOLERANCE = 0.02f; | ||
1113 | |||
1106 | if (m_followCamAuto) | 1114 | if (m_followCamAuto) |
1107 | { | 1115 | { |
1108 | |||
1109 | if (hitYN) | 1116 | if (hitYN) |
1110 | { | 1117 | { |
1111 | CameraConstraintActive = true; | 1118 | CameraConstraintActive = true; |
@@ -1114,11 +1121,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1114 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); | 1121 | Vector3 normal = Vector3.Normalize(new Vector3(0f, 0f, collisionPoint.Z) - collisionPoint); |
1115 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); | 1122 | ControllingClient.SendCameraConstraint(new Vector4(normal.X, normal.Y, normal.Z, -1 * Vector3.Distance(new Vector3(0,0,collisionPoint.Z),collisionPoint))); |
1116 | } | 1123 | } |
1117 | else | 1124 | else |
1118 | { | 1125 | { |
1119 | if ((m_pos - m_lastPosition).Length() > 0.02f || | 1126 | if (!m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || |
1120 | (m_velocity - m_lastVelocity).Length() > 0.02f || | 1127 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
1121 | m_bodyRot != m_lastRotation) | 1128 | !m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE)) |
1122 | { | 1129 | { |
1123 | if (CameraConstraintActive) | 1130 | if (CameraConstraintActive) |
1124 | { | 1131 | { |
@@ -1127,13 +1134,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1127 | } | 1134 | } |
1128 | } | 1135 | } |
1129 | } | 1136 | } |
1130 | } | 1137 | } |
1131 | } | 1138 | } |
1132 | 1139 | ||
1133 | Array m_dirControlFlags = Enum.GetValues(typeof(Dir_ControlFlags)); | ||
1134 | |||
1135 | /// <summary> | 1140 | /// <summary> |
1136 | /// This is the event handler for client movement. If a client is moving, this event is triggering. | 1141 | /// This is the event handler for client movement. If a client is moving, this event is triggering. |
1137 | /// </summary> | 1142 | /// </summary> |
1138 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) | 1143 | public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) |
1139 | { | 1144 | { |
@@ -1149,15 +1154,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1149 | if (m_movementUpdateCount < 1) | 1154 | if (m_movementUpdateCount < 1) |
1150 | m_movementUpdateCount = 1; | 1155 | m_movementUpdateCount = 1; |
1151 | 1156 | ||
1152 | // Must check for standing up even when PhysicsActor is null, | 1157 | #region Sanity Checking |
1153 | // since sitting currently removes avatar from physical scene | ||
1154 | //m_log.Debug("agentPos:" + AbsolutePosition.ToString()); | ||
1155 | 1158 | ||
1156 | // This is irritating. Really. | 1159 | // This is irritating. Really. |
1157 | if (!AbsolutePosition.IsFinite()) | 1160 | if (!AbsolutePosition.IsFinite()) |
1158 | { | 1161 | { |
1159 | RemoveFromPhysicalScene(); | 1162 | RemoveFromPhysicalScene(); |
1160 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999902"); | 1163 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999902"); |
1161 | 1164 | ||
1162 | m_pos = m_LastFinitePos; | 1165 | m_pos = m_LastFinitePos; |
1163 | if (!m_pos.IsFinite()) | 1166 | if (!m_pos.IsFinite()) |
@@ -1165,7 +1168,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1165 | m_pos.X = 127f; | 1168 | m_pos.X = 127f; |
1166 | m_pos.Y = 127f; | 1169 | m_pos.Y = 127f; |
1167 | m_pos.Z = 127f; | 1170 | m_pos.Z = 127f; |
1168 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error# 9999903"); | 1171 | m_log.Error("[AVATAR]: NonFinite Avatar position detected... Reset Position. Mantis this please. Error #9999903"); |
1169 | } | 1172 | } |
1170 | 1173 | ||
1171 | AddToPhysicalScene(false); | 1174 | AddToPhysicalScene(false); |
@@ -1175,18 +1178,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1175 | m_LastFinitePos = m_pos; | 1178 | m_LastFinitePos = m_pos; |
1176 | } | 1179 | } |
1177 | 1180 | ||
1178 | //m_physicsActor.AddForce(new PhysicsVector(999999999, 99999999, 999999999999999), true); | 1181 | #endregion Sanity Checking |
1179 | 1182 | ||
1180 | //ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | 1183 | #region Inputs |
1181 | //if (land != null) | ||
1182 | //{ | ||
1183 | //if (land.landData.landingType == (byte)1 && land.landData.userLocation != Vector3.Zero) | ||
1184 | //{ | ||
1185 | // agent.startpos = land.landData.userLocation; | ||
1186 | //} | ||
1187 | //} | ||
1188 | 1184 | ||
1189 | uint flags = agentData.ControlFlags; | 1185 | AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; |
1190 | Quaternion bodyRotation = agentData.BodyRotation; | 1186 | Quaternion bodyRotation = agentData.BodyRotation; |
1191 | 1187 | ||
1192 | // Camera location in world. We'll need to raytrace | 1188 | // Camera location in world. We'll need to raytrace |
@@ -1207,87 +1203,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
1207 | // The Agent's Draw distance setting | 1203 | // The Agent's Draw distance setting |
1208 | m_DrawDistance = agentData.Far; | 1204 | m_DrawDistance = agentData.Far; |
1209 | 1205 | ||
1210 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) | ||
1211 | { | ||
1212 | StandUp(); | ||
1213 | } | ||
1214 | |||
1215 | // Check if Client has camera in 'follow cam' or 'build' mode. | 1206 | // Check if Client has camera in 'follow cam' or 'build' mode. |
1216 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); | 1207 | Vector3 camdif = (Vector3.One * m_bodyRot - Vector3.One * CameraRotation); |
1217 | 1208 | ||
1218 | m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) | 1209 | m_followCamAuto = ((m_CameraUpAxis.Z > 0.959f && m_CameraUpAxis.Z < 0.98f) |
1219 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; | 1210 | && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; |
1220 | 1211 | ||
1212 | m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | ||
1213 | m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; | ||
1214 | |||
1215 | #endregion Inputs | ||
1216 | |||
1217 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_STAND_UP) != 0) | ||
1218 | { | ||
1219 | StandUp(); | ||
1220 | } | ||
1221 | |||
1221 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); | 1222 | //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); |
1222 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view | 1223 | // Raycast from the avatar's head to the camera to see if there's anything blocking the view |
1223 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) | 1224 | if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) |
1224 | { | 1225 | { |
1225 | if (m_followCamAuto) | 1226 | if (m_followCamAuto) |
1226 | { | 1227 | { |
1227 | Vector3 headadjustment = new Vector3(0, 0, 0.3f); | 1228 | Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; |
1228 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - (m_pos + headadjustment)), Vector3.Distance(m_CameraCenter, (m_pos + headadjustment)) + 0.3f, RayCastCameraCallback); | 1229 | m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(m_CameraCenter - posAdjusted), Vector3.Distance(m_CameraCenter, posAdjusted) + 0.3f, RayCastCameraCallback); |
1229 | } | 1230 | } |
1230 | } | 1231 | } |
1231 | 1232 | ||
1232 | m_mouseLook = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; | ||
1233 | m_leftButtonDown = (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; | ||
1234 | |||
1235 | lock (scriptedcontrols) | 1233 | lock (scriptedcontrols) |
1236 | { | 1234 | { |
1237 | if (scriptedcontrols.Count > 0) | 1235 | if (scriptedcontrols.Count > 0) |
1238 | { | 1236 | { |
1239 | SendControlToScripts(flags); | 1237 | SendControlToScripts((uint)flags); |
1240 | flags = RemoveIgnoredControls(flags, IgnoredControls); | 1238 | flags = RemoveIgnoredControls(flags, IgnoredControls); |
1241 | } | 1239 | } |
1242 | } | 1240 | } |
1243 | 1241 | ||
1244 | if (PhysicsActor == null) | ||
1245 | { | ||
1246 | return; | ||
1247 | } | ||
1248 | |||
1249 | if (m_autopilotMoving) | 1242 | if (m_autopilotMoving) |
1250 | CheckAtSitTarget(); | 1243 | CheckAtSitTarget(); |
1251 | 1244 | ||
1252 | if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1245 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1253 | { | 1246 | { |
1254 | // TODO: This doesn't prevent the user from walking yet. | 1247 | // TODO: This doesn't prevent the user from walking yet. |
1255 | // Setting parent ID would fix this, if we knew what value | 1248 | // Setting parent ID would fix this, if we knew what value |
1256 | // to use. Or we could add a m_isSitting variable. | 1249 | // to use. Or we could add a m_isSitting variable. |
1257 | |||
1258 | TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | 1250 | TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); |
1259 | } | 1251 | } |
1252 | |||
1260 | // In the future, these values might need to go global. | 1253 | // In the future, these values might need to go global. |
1261 | // Here's where you get them. | 1254 | // Here's where you get them. |
1262 | |||
1263 | m_AgentControlFlags = flags; | 1255 | m_AgentControlFlags = flags; |
1264 | m_headrotation = agentData.HeadRotation; | 1256 | m_headrotation = agentData.HeadRotation; |
1265 | m_state = agentData.State; | 1257 | m_state = agentData.State; |
1266 | 1258 | ||
1259 | PhysicsActor actor = PhysicsActor; | ||
1260 | if (actor == null) | ||
1261 | { | ||
1262 | return; | ||
1263 | } | ||
1264 | |||
1267 | if (m_allowMovement) | 1265 | if (m_allowMovement) |
1268 | { | 1266 | { |
1269 | int i = 0; | 1267 | int i = 0; |
1270 | bool update_movementflag = false; | 1268 | bool update_movementflag = false; |
1271 | bool update_rotation = false; | 1269 | bool update_rotation = false; |
1272 | bool DCFlagKeyPressed = false; | 1270 | bool DCFlagKeyPressed = false; |
1273 | Vector3 agent_control_v3 = new Vector3(0, 0, 0); | 1271 | Vector3 agent_control_v3 = Vector3.Zero; |
1274 | Quaternion q = bodyRotation; | 1272 | Quaternion q = bodyRotation; |
1275 | if (PhysicsActor != null) | ||
1276 | { | ||
1277 | bool oldflying = PhysicsActor.Flying; | ||
1278 | 1273 | ||
1279 | if (m_forceFly) | 1274 | bool oldflying = PhysicsActor.Flying; |
1280 | PhysicsActor.Flying = true; | ||
1281 | else if (m_flyDisabled) | ||
1282 | PhysicsActor.Flying = false; | ||
1283 | else | ||
1284 | PhysicsActor.Flying = ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | ||
1285 | 1275 | ||
1286 | if (PhysicsActor.Flying != oldflying) | 1276 | if (m_forceFly) |
1287 | { | 1277 | actor.Flying = true; |
1288 | update_movementflag = true; | 1278 | else if (m_flyDisabled) |
1289 | } | 1279 | actor.Flying = false; |
1290 | } | 1280 | else |
1281 | actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); | ||
1282 | |||
1283 | if (actor.Flying != oldflying) | ||
1284 | update_movementflag = true; | ||
1291 | 1285 | ||
1292 | if (q != m_bodyRot) | 1286 | if (q != m_bodyRot) |
1293 | { | 1287 | { |
@@ -1309,10 +1303,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1309 | else | 1303 | else |
1310 | dirVectors = Dir_Vectors; | 1304 | dirVectors = Dir_Vectors; |
1311 | 1305 | ||
1312 | 1306 | foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS) | |
1313 | foreach (Dir_ControlFlags DCF in m_dirControlFlags) | ||
1314 | { | 1307 | { |
1315 | if ((flags & (uint)DCF) != 0) | 1308 | if (((uint)flags & (uint)DCF) != 0) |
1316 | { | 1309 | { |
1317 | bResetMoveToPosition = true; | 1310 | bResetMoveToPosition = true; |
1318 | DCFlagKeyPressed = true; | 1311 | DCFlagKeyPressed = true; |
@@ -1358,7 +1351,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1358 | if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) | 1351 | if (bAllowUpdateMoveToPosition && (m_moveToPositionInProgress && !m_autopilotMoving)) |
1359 | { | 1352 | { |
1360 | //Check the error term of the current position in relation to the target position | 1353 | //Check the error term of the current position in relation to the target position |
1361 | if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 1.5) | 1354 | if (Util.GetDistanceTo(AbsolutePosition, m_moveToPositionTarget) <= 1.5f) |
1362 | { | 1355 | { |
1363 | // we are close enough to the target | 1356 | // we are close enough to the target |
1364 | m_moveToPositionTarget = Vector3.Zero; | 1357 | m_moveToPositionTarget = Vector3.Zero; |
@@ -1439,8 +1432,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1439 | if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) | 1432 | if (m_physicsActor != null && m_physicsActor.Flying && !m_forceFly) |
1440 | { | 1433 | { |
1441 | // Are the landing controls requirements filled? | 1434 | // Are the landing controls requirements filled? |
1442 | bool controlland = (((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || | 1435 | bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || |
1443 | ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 1436 | ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
1444 | 1437 | ||
1445 | // Are the collision requirements fulfilled? | 1438 | // Are the collision requirements fulfilled? |
1446 | bool colliding = (m_physicsActor.IsColliding == true); | 1439 | bool colliding = (m_physicsActor.IsColliding == true); |
@@ -1537,7 +1530,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1537 | if (part != null) | 1530 | if (part != null) |
1538 | { | 1531 | { |
1539 | AbsolutePosition = part.AbsolutePosition; | 1532 | AbsolutePosition = part.AbsolutePosition; |
1540 | Velocity = new Vector3(0, 0, 0); | 1533 | Velocity = Vector3.Zero; |
1541 | SendFullUpdateToAllClients(); | 1534 | SendFullUpdateToAllClients(); |
1542 | 1535 | ||
1543 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); | 1536 | //HandleAgentSit(ControllingClient, m_requestedSitTargetUUID); |
@@ -1607,7 +1600,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1607 | } | 1600 | } |
1608 | 1601 | ||
1609 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); | 1602 | m_pos += m_parentPosition + new Vector3(0.0f, 0.0f, 2.0f*m_sitAvatarHeight); |
1610 | m_parentPosition = new Vector3(); | 1603 | m_parentPosition = Vector3.Zero; |
1611 | 1604 | ||
1612 | m_parentID = 0; | 1605 | m_parentID = 0; |
1613 | SendFullUpdateToAllClients(); | 1606 | SendFullUpdateToAllClients(); |
@@ -1834,7 +1827,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1834 | //Quaternion result = (sitTargetOrient * vq) * nq; | 1827 | //Quaternion result = (sitTargetOrient * vq) * nq; |
1835 | 1828 | ||
1836 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); | 1829 | m_pos = new Vector3(sitTargetPos.X, sitTargetPos.Y, sitTargetPos.Z); |
1837 | m_pos += m_sitTargetCorrectionOffset; | 1830 | m_pos += SIT_TARGET_ADJUSTMENT; |
1838 | m_bodyRot = sitTargetOrient; | 1831 | m_bodyRot = sitTargetOrient; |
1839 | //Rotation = sitTargetOrient; | 1832 | //Rotation = sitTargetOrient; |
1840 | m_parentPosition = part.AbsolutePosition; | 1833 | m_parentPosition = part.AbsolutePosition; |
@@ -1854,7 +1847,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1854 | } | 1847 | } |
1855 | m_parentID = m_requestedSitTargetID; | 1848 | m_parentID = m_requestedSitTargetID; |
1856 | 1849 | ||
1857 | Velocity = new Vector3(0, 0, 0); | 1850 | Velocity = Vector3.Zero; |
1858 | RemoveFromPhysicalScene(); | 1851 | RemoveFromPhysicalScene(); |
1859 | 1852 | ||
1860 | TrySetMovementAnimation(sitAnimation); | 1853 | TrySetMovementAnimation(sitAnimation); |
@@ -1925,14 +1918,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1925 | } | 1918 | } |
1926 | 1919 | ||
1927 | 1920 | ||
1928 | AssetBase Animasset = new AssetBase(); | 1921 | AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); |
1929 | Animasset.Data = anim.ToBytes(); | 1922 | Animasset.Data = anim.ToBytes(); |
1930 | Animasset.Temporary = true; | 1923 | Animasset.Temporary = true; |
1931 | Animasset.Local = true; | 1924 | Animasset.Local = true; |
1932 | Animasset.FullID = UUID.Random(); | ||
1933 | Animasset.ID = Animasset.FullID.ToString(); | ||
1934 | Animasset.Name = "Random Animation"; | ||
1935 | Animasset.Type = (sbyte)AssetType.Animation; | ||
1936 | Animasset.Description = "dance"; | 1925 | Animasset.Description = "dance"; |
1937 | //BinBVHAnimation bbvhanim = new BinBVHAnimation(Animasset.Data); | 1926 | //BinBVHAnimation bbvhanim = new BinBVHAnimation(Animasset.Data); |
1938 | 1927 | ||
@@ -2011,7 +2000,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2011 | protected void TrySetMovementAnimation(string anim) | 2000 | protected void TrySetMovementAnimation(string anim) |
2012 | { | 2001 | { |
2013 | //m_log.DebugFormat("Updating movement animation to {0}", anim); | 2002 | //m_log.DebugFormat("Updating movement animation to {0}", anim); |
2014 | 2003 | ||
2015 | if (!m_isChildAgent) | 2004 | if (!m_isChildAgent) |
2016 | { | 2005 | { |
2017 | if (m_animations.TrySetDefaultAnimation(anim, m_controllingClient.NextAnimationSequenceNumber, UUID.Zero)) | 2006 | if (m_animations.TrySetDefaultAnimation(anim, m_controllingClient.NextAnimationSequenceNumber, UUID.Zero)) |
@@ -2046,200 +2035,169 @@ namespace OpenSim.Region.Framework.Scenes | |||
2046 | /// </summary> | 2035 | /// </summary> |
2047 | public string GetMovementAnimation() | 2036 | public string GetMovementAnimation() |
2048 | { | 2037 | { |
2049 | if ((m_animPersistUntil > 0) && (m_animPersistUntil > DateTime.Now.Ticks)) | 2038 | const float FALL_DELAY = 0.33f; |
2050 | { | 2039 | const float PREJUMP_DELAY = 0.25f; |
2051 | //We don't want our existing state to end yet. | ||
2052 | return m_movementAnimation; | ||
2053 | 2040 | ||
2054 | } | 2041 | #region Inputs |
2055 | else if (m_movementflag != 0) | 2042 | |
2043 | AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_AgentControlFlags; | ||
2044 | PhysicsActor actor = m_physicsActor; | ||
2045 | |||
2046 | // Create forward and left vectors from the current avatar rotation | ||
2047 | Matrix4 rotMatrix = Matrix4.CreateFromQuaternion(m_bodyRot); | ||
2048 | Vector3 fwd = Vector3.Transform(Vector3.UnitX, rotMatrix); | ||
2049 | Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix); | ||
2050 | |||
2051 | // Check control flags | ||
2052 | bool heldForward = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; | ||
2053 | bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG; | ||
2054 | bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS; | ||
2055 | bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG; | ||
2056 | //bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT; | ||
2057 | //bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT; | ||
2058 | bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS; | ||
2059 | bool heldDown = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG; | ||
2060 | //bool flying = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) == AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
2061 | //bool mouselook = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) == AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK; | ||
2062 | |||
2063 | // Direction in which the avatar is trying to move | ||
2064 | Vector3 move = Vector3.Zero; | ||
2065 | if (heldForward) { move.X += fwd.X; move.Y += fwd.Y; } | ||
2066 | if (heldBack) { move.X -= fwd.X; move.Y -= fwd.Y; } | ||
2067 | if (heldLeft) { move.X += left.X; move.Y += left.Y; } | ||
2068 | if (heldRight) { move.X -= left.X; move.Y -= left.Y; } | ||
2069 | if (heldUp) { move.Z += 1; } | ||
2070 | if (heldDown) { move.Z -= 1; } | ||
2071 | |||
2072 | // Is the avatar trying to move? | ||
2073 | // bool moving = (move != Vector3.Zero); | ||
2074 | bool jumping = m_animTickJump != 0; | ||
2075 | |||
2076 | #endregion Inputs | ||
2077 | |||
2078 | #region Flying | ||
2079 | |||
2080 | if (actor != null && actor.Flying) | ||
2056 | { | 2081 | { |
2057 | //We're moving | 2082 | m_animTickFall = 0; |
2058 | m_allowFalling = true; | 2083 | m_animTickJump = 0; |
2059 | if (PhysicsActor != null && PhysicsActor.IsColliding) | 2084 | |
2085 | if (move.X != 0f || move.Y != 0f) | ||
2060 | { | 2086 | { |
2061 | //And colliding. Can you guess what it is yet? | 2087 | return (m_useFlySlow ? "FLYSLOW" : "FLY"); |
2062 | if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) | 2088 | } |
2063 | { | 2089 | else if (move.Z > 0f) |
2064 | //Down key is being pressed. | 2090 | { |
2065 | if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) + (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0) | 2091 | return "HOVER_UP"; |
2066 | { | 2092 | } |
2067 | return "CROUCHWALK"; | 2093 | else if (move.Z < 0f) |
2068 | } | 2094 | { |
2069 | else | 2095 | if (actor != null && actor.IsColliding) |
2070 | { | 2096 | return "LAND"; |
2071 | return "CROUCH"; | ||
2072 | } | ||
2073 | } | ||
2074 | else if (m_setAlwaysRun) | ||
2075 | { | ||
2076 | return "RUN"; | ||
2077 | } | ||
2078 | else | 2097 | else |
2079 | { | 2098 | return "HOVER_DOWN"; |
2080 | //If we're prejumping then inhibit this, it's a problem | ||
2081 | //caused by a false positive on IsColliding | ||
2082 | if (m_movementAnimation == "PREJUMP") | ||
2083 | { | ||
2084 | return "PREJUMP"; | ||
2085 | } | ||
2086 | else | ||
2087 | { | ||
2088 | return "WALK"; | ||
2089 | } | ||
2090 | } | ||
2091 | |||
2092 | } | 2099 | } |
2093 | else | 2100 | else |
2094 | { | 2101 | { |
2095 | //We're not colliding. Colliding isn't cool these days. | 2102 | return "HOVER"; |
2096 | if (PhysicsActor != null && PhysicsActor.Flying) | 2103 | } |
2097 | { | 2104 | } |
2098 | //Are we moving forwards or backwards? | ||
2099 | if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0) | ||
2100 | { | ||
2101 | //Then we really are flying | ||
2102 | if (m_setAlwaysRun) | ||
2103 | { | ||
2104 | return "FLY"; | ||
2105 | } | ||
2106 | else | ||
2107 | { | ||
2108 | if (m_useFlySlow == false) | ||
2109 | { | ||
2110 | return "FLY"; | ||
2111 | } | ||
2112 | else | ||
2113 | { | ||
2114 | return "FLYSLOW"; | ||
2115 | } | ||
2116 | } | ||
2117 | } | ||
2118 | else | ||
2119 | { | ||
2120 | if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) | ||
2121 | { | ||
2122 | return "HOVER_UP"; | ||
2123 | } | ||
2124 | else | ||
2125 | { | ||
2126 | return "HOVER_DOWN"; | ||
2127 | } | ||
2128 | } | ||
2129 | 2105 | ||
2130 | } | 2106 | #endregion Flying |
2131 | else if (m_movementAnimation == "JUMP") | ||
2132 | { | ||
2133 | //If we were already jumping, continue to jump until we collide | ||
2134 | return "JUMP"; | ||
2135 | 2107 | ||
2136 | } | 2108 | #region Falling/Floating/Landing |
2137 | else if (m_movementAnimation == "PREJUMP" && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == 0) | ||
2138 | { | ||
2139 | //If we were in a prejump, and the UP key is no longer being held down | ||
2140 | //then we're not going to fly, so we're jumping | ||
2141 | return "JUMP"; | ||
2142 | 2109 | ||
2143 | } | 2110 | if (actor == null || !actor.IsColliding) |
2144 | else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) | 2111 | { |
2145 | { | 2112 | float fallElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; |
2146 | //They're pressing up, so we're either going to fly or jump | 2113 | float fallVelocity = (actor != null) ? actor.Velocity.Z : 0.0f; |
2147 | return "PREJUMP"; | 2114 | |
2148 | } | 2115 | if (m_animTickFall == 0 || (fallElapsed > FALL_DELAY && fallVelocity >= 0.0f)) |
2149 | else | 2116 | { |
2150 | { | 2117 | // Just started falling |
2151 | //If we're moving and not flying and not jumping and not colliding.. | 2118 | m_animTickFall = Environment.TickCount; |
2152 | 2119 | } | |
2153 | if (m_movementAnimation == "WALK" || m_movementAnimation == "RUN") | 2120 | else if (!jumping && fallElapsed > FALL_DELAY) |
2154 | { | 2121 | { |
2155 | //Let's not enter a FALLDOWN state here, since we're probably | 2122 | // Falling long enough to trigger the animation |
2156 | //not colliding because we're going down hill. | 2123 | return "FALLDOWN"; |
2157 | return m_movementAnimation; | ||
2158 | } | ||
2159 | //Record the time we enter this state so we know whether to "land" or not | ||
2160 | m_animPersistUntil = DateTime.Now.Ticks; | ||
2161 | return "FALLDOWN"; | ||
2162 | |||
2163 | } | ||
2164 | } | 2124 | } |
2125 | |||
2126 | return m_movementAnimation; | ||
2165 | } | 2127 | } |
2166 | else | 2128 | |
2129 | #endregion Falling/Floating/Landing | ||
2130 | |||
2131 | #region Ground Movement | ||
2132 | |||
2133 | if (m_movementAnimation == "FALLDOWN") | ||
2167 | { | 2134 | { |
2168 | //We're not moving. | 2135 | m_animTickFall = Environment.TickCount; |
2169 | if (PhysicsActor != null && PhysicsActor.IsColliding) | ||
2170 | { | ||
2171 | //But we are colliding. | ||
2172 | if (m_movementAnimation == "FALLDOWN") | ||
2173 | { | ||
2174 | //We're re-using the m_animPersistUntil value here to see how long we've been falling | ||
2175 | if ((DateTime.Now.Ticks - m_animPersistUntil) > TimeSpan.TicksPerSecond) | ||
2176 | { | ||
2177 | //Make sure we don't change state for a bit | ||
2178 | m_animPersistUntil = DateTime.Now.Ticks + TimeSpan.TicksPerSecond; | ||
2179 | return "LAND"; | ||
2180 | } | ||
2181 | else | ||
2182 | { | ||
2183 | //We haven't been falling very long, we were probably just walking down hill | ||
2184 | return "STAND"; | ||
2185 | } | ||
2186 | } | ||
2187 | else if (m_movementAnimation == "JUMP" || m_movementAnimation == "HOVER_DOWN") | ||
2188 | { | ||
2189 | //Make sure we don't change state for a bit | ||
2190 | m_animPersistUntil = DateTime.Now.Ticks + (1 * TimeSpan.TicksPerSecond); | ||
2191 | return "SOFT_LAND"; | ||
2192 | 2136 | ||
2193 | } | 2137 | // TODO: SOFT_LAND support |
2194 | else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) | 2138 | return "LAND"; |
2195 | { | 2139 | } |
2196 | return "PREJUMP"; | 2140 | else if (m_movementAnimation == "LAND") |
2197 | } | 2141 | { |
2198 | else if (PhysicsActor != null && PhysicsActor.Flying) | 2142 | float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f; |
2199 | { | 2143 | |
2200 | m_allowFalling = true; | 2144 | if (landElapsed <= FALL_DELAY) |
2201 | if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0) | 2145 | return "LAND"; |
2202 | { | 2146 | } |
2203 | return "HOVER_UP"; | ||
2204 | } | ||
2205 | else if ((m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) | ||
2206 | { | ||
2207 | return "HOVER_DOWN"; | ||
2208 | } | ||
2209 | else | ||
2210 | { | ||
2211 | return "HOVER"; | ||
2212 | } | ||
2213 | } | ||
2214 | else | ||
2215 | { | ||
2216 | return "STAND"; | ||
2217 | } | ||
2218 | 2147 | ||
2148 | m_animTickFall = 0; | ||
2149 | |||
2150 | if (move.Z > 0f) | ||
2151 | { | ||
2152 | // Jumping | ||
2153 | if (!jumping) | ||
2154 | { | ||
2155 | // Begin prejump | ||
2156 | m_animTickJump = Environment.TickCount; | ||
2157 | return "PREJUMP"; | ||
2219 | } | 2158 | } |
2220 | else | 2159 | else if (Environment.TickCount - m_animTickJump > PREJUMP_DELAY * 1000.0f) |
2221 | { | 2160 | { |
2222 | //We're not colliding. | 2161 | // Start actual jump |
2223 | if (PhysicsActor != null && PhysicsActor.Flying) | 2162 | if (m_animTickJump == -1) |
2224 | { | 2163 | { |
2225 | 2164 | // Already jumping! End the current jump | |
2226 | return "HOVER"; | 2165 | m_animTickJump = 0; |
2227 | 2166 | return "JUMP"; | |
2228 | } | 2167 | } |
2229 | else if ((m_movementAnimation == "JUMP" || m_movementAnimation == "PREJUMP") && (m_movementflag & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == 0) | ||
2230 | { | ||
2231 | 2168 | ||
2232 | return "JUMP"; | 2169 | m_animTickJump = -1; |
2170 | return "JUMP"; | ||
2171 | } | ||
2172 | } | ||
2173 | else | ||
2174 | { | ||
2175 | // Not jumping | ||
2176 | m_animTickJump = 0; | ||
2233 | 2177 | ||
2234 | } | 2178 | if (move.X != 0f || move.Y != 0f) |
2179 | { | ||
2180 | // Walking / crouchwalking / running | ||
2181 | if (move.Z < 0f) | ||
2182 | return "CROUCHWALK"; | ||
2183 | else if (m_setAlwaysRun) | ||
2184 | return "RUN"; | ||
2235 | else | 2185 | else |
2236 | { | 2186 | return "WALK"; |
2237 | //Record the time we enter this state so we know whether to "land" or not | 2187 | } |
2238 | m_animPersistUntil = DateTime.Now.Ticks; | 2188 | else |
2239 | return "FALLDOWN"; // this falling animation is invoked too frequently when capsule tilt correction is used - why? | 2189 | { |
2240 | } | 2190 | // Not walking |
2191 | if (move.Z < 0f) | ||
2192 | return "CROUCH"; | ||
2193 | else | ||
2194 | return "STAND"; | ||
2241 | } | 2195 | } |
2242 | } | 2196 | } |
2197 | |||
2198 | #endregion Ground Movement | ||
2199 | |||
2200 | return m_movementAnimation; | ||
2243 | } | 2201 | } |
2244 | 2202 | ||
2245 | /// <summary> | 2203 | /// <summary> |
@@ -2247,24 +2205,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2247 | /// </summary> | 2205 | /// </summary> |
2248 | protected void UpdateMovementAnimations() | 2206 | protected void UpdateMovementAnimations() |
2249 | { | 2207 | { |
2250 | string movementAnimation = GetMovementAnimation(); | 2208 | m_movementAnimation = GetMovementAnimation(); |
2251 | 2209 | ||
2252 | if (movementAnimation == "FALLDOWN" && m_allowFalling == false) | 2210 | if (m_movementAnimation == "PREJUMP" && !m_usePreJump) |
2253 | { | ||
2254 | movementAnimation = m_movementAnimation; | ||
2255 | } | ||
2256 | else | ||
2257 | { | ||
2258 | m_movementAnimation = movementAnimation; | ||
2259 | } | ||
2260 | if (movementAnimation == "PREJUMP" && m_usePreJump == false) | ||
2261 | { | 2211 | { |
2262 | //This was the previous behavior before PREJUMP | 2212 | // This was the previous behavior before PREJUMP |
2263 | TrySetMovementAnimation("JUMP"); | 2213 | TrySetMovementAnimation("JUMP"); |
2264 | } | 2214 | } |
2265 | else | 2215 | else |
2266 | { | 2216 | { |
2267 | TrySetMovementAnimation(movementAnimation); | 2217 | TrySetMovementAnimation(m_movementAnimation); |
2268 | } | 2218 | } |
2269 | } | 2219 | } |
2270 | 2220 | ||
@@ -2277,7 +2227,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2277 | { | 2227 | { |
2278 | if (m_isChildAgent) | 2228 | if (m_isChildAgent) |
2279 | { | 2229 | { |
2280 | m_log.Debug("DEBUG: AddNewMovement: child agent, Making root agent!"); | 2230 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); |
2281 | 2231 | ||
2282 | // we have to reset the user's child agent connections. | 2232 | // we have to reset the user's child agent connections. |
2283 | // Likely, here they've lost the eventqueue for other regions so border | 2233 | // Likely, here they've lost the eventqueue for other regions so border |
@@ -2286,7 +2236,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2286 | List<ulong> regions = new List<ulong>(KnownChildRegionHandles); | 2236 | List<ulong> regions = new List<ulong>(KnownChildRegionHandles); |
2287 | regions.Remove(m_scene.RegionInfo.RegionHandle); | 2237 | regions.Remove(m_scene.RegionInfo.RegionHandle); |
2288 | 2238 | ||
2289 | MakeRootAgent(new Vector3(127, 127, 127), true); | 2239 | MakeRootAgent(new Vector3(127f, 127f, 127f), true); |
2290 | 2240 | ||
2291 | // Async command | 2241 | // Async command |
2292 | if (m_scene.SceneGridService != null) | 2242 | if (m_scene.SceneGridService != null) |
@@ -2298,47 +2248,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
2298 | System.Threading.Thread.Sleep(500); | 2248 | System.Threading.Thread.Sleep(500); |
2299 | } | 2249 | } |
2300 | 2250 | ||
2301 | |||
2302 | if (m_scene.SceneGridService != null) | 2251 | if (m_scene.SceneGridService != null) |
2303 | { | 2252 | { |
2304 | m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); | 2253 | m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); |
2305 | } | 2254 | } |
2306 | 2255 | ||
2307 | |||
2308 | |||
2309 | return; | 2256 | return; |
2310 | } | 2257 | } |
2311 | 2258 | ||
2312 | m_perfMonMS = Environment.TickCount; | 2259 | m_perfMonMS = Environment.TickCount; |
2313 | 2260 | ||
2314 | m_rotation = rotation; | 2261 | Rotation = rotation; |
2315 | NewForce newVelocity = new NewForce(); | ||
2316 | Vector3 direc = vec * rotation; | 2262 | Vector3 direc = vec * rotation; |
2317 | direc.Normalize(); | 2263 | direc.Normalize(); |
2318 | 2264 | ||
2319 | direc *= 0.03f * 128f * m_speedModifier; | 2265 | direc *= 0.03f * 128f * m_speedModifier; |
2320 | if (m_physicsActor.Flying) | 2266 | |
2321 | { | 2267 | PhysicsActor actor = m_physicsActor; |
2322 | direc *= 4; | 2268 | if (actor != null) |
2323 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | ||
2324 | //bool colliding = (m_physicsActor.IsColliding==true); | ||
2325 | //if (controlland) | ||
2326 | // m_log.Info("[AGENT]: landCommand"); | ||
2327 | //if (colliding) | ||
2328 | // m_log.Info("[AGENT]: colliding"); | ||
2329 | //if (m_physicsActor.Flying && colliding && controlland) | ||
2330 | //{ | ||
2331 | // StopFlying(); | ||
2332 | // m_log.Info("[AGENT]: Stop FLying"); | ||
2333 | //} | ||
2334 | } | ||
2335 | else | ||
2336 | { | 2269 | { |
2337 | if (!m_physicsActor.Flying && m_physicsActor.IsColliding) | 2270 | if (actor.Flying) |
2271 | { | ||
2272 | direc *= 4.0f; | ||
2273 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | ||
2274 | //bool colliding = (m_physicsActor.IsColliding==true); | ||
2275 | //if (controlland) | ||
2276 | // m_log.Info("[AGENT]: landCommand"); | ||
2277 | //if (colliding) | ||
2278 | // m_log.Info("[AGENT]: colliding"); | ||
2279 | //if (m_physicsActor.Flying && colliding && controlland) | ||
2280 | //{ | ||
2281 | // StopFlying(); | ||
2282 | // m_log.Info("[AGENT]: Stop FLying"); | ||
2283 | //} | ||
2284 | } | ||
2285 | else if (!actor.Flying && actor.IsColliding) | ||
2338 | { | 2286 | { |
2339 | if (direc.Z > 2.0f) | 2287 | if (direc.Z > 2.0f) |
2340 | { | 2288 | { |
2341 | direc.Z *= 3; | 2289 | direc.Z *= 3.0f; |
2342 | 2290 | ||
2343 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. | 2291 | // TODO: PreJump and jump happen too quickly. Many times prejump gets ignored. |
2344 | TrySetMovementAnimation("PREJUMP"); | 2292 | TrySetMovementAnimation("PREJUMP"); |
@@ -2347,10 +2295,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2347 | } | 2295 | } |
2348 | } | 2296 | } |
2349 | 2297 | ||
2350 | newVelocity.X = direc.X; | 2298 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2351 | newVelocity.Y = direc.Y; | 2299 | m_forceToApply = direc; |
2352 | newVelocity.Z = direc.Z; | ||
2353 | m_forcesList.Add(newVelocity); | ||
2354 | 2300 | ||
2355 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2301 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); |
2356 | } | 2302 | } |
@@ -2361,8 +2307,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2361 | 2307 | ||
2362 | public override void Update() | 2308 | public override void Update() |
2363 | { | 2309 | { |
2364 | const float VELOCITY_TOLERANCE = 0.01f; | 2310 | const float ROTATION_TOLERANCE = 0.01f; |
2365 | const float POSITION_TOLERANCE = 10.0f; | 2311 | const float VELOCITY_TOLERANCE = 0.001f; |
2312 | const float POSITION_TOLERANCE = 0.05f; | ||
2313 | //const int TIME_MS_TOLERANCE = 3000; | ||
2366 | 2314 | ||
2367 | SendPrimUpdates(); | 2315 | SendPrimUpdates(); |
2368 | 2316 | ||
@@ -2374,17 +2322,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2374 | 2322 | ||
2375 | if (m_isChildAgent == false) | 2323 | if (m_isChildAgent == false) |
2376 | { | 2324 | { |
2325 | // PhysicsActor actor = m_physicsActor; | ||
2326 | |||
2327 | // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to | ||
2328 | // grab the latest PhysicsActor velocity, whereas m_velocity is often | ||
2329 | // storing a requested force instead of an actual traveling velocity | ||
2330 | |||
2377 | // Throw away duplicate or insignificant updates | 2331 | // Throw away duplicate or insignificant updates |
2378 | if (m_bodyRot != m_lastRotation || | 2332 | if (!m_bodyRot.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || |
2379 | (m_velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE || | 2333 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || |
2380 | (m_pos - m_lastPosition).Length() > POSITION_TOLERANCE) | 2334 | !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) |
2335 | //Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE) | ||
2381 | { | 2336 | { |
2382 | SendTerseUpdateToAllClients(); | 2337 | SendTerseUpdateToAllClients(); |
2383 | 2338 | ||
2384 | // Update the "last" values | 2339 | // Update the "last" values |
2385 | m_lastPosition = m_pos; | 2340 | m_lastPosition = m_pos; |
2386 | m_lastRotation = m_bodyRot; | 2341 | m_lastRotation = m_bodyRot; |
2387 | m_lastVelocity = m_velocity; | 2342 | m_lastVelocity = Velocity; |
2343 | //m_lastTerseSent = Environment.TickCount; | ||
2388 | } | 2344 | } |
2389 | 2345 | ||
2390 | // followed suggestion from mic bowman. reversed the two lines below. | 2346 | // followed suggestion from mic bowman. reversed the two lines below. |
@@ -2410,11 +2366,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2410 | { | 2366 | { |
2411 | m_perfMonMS = Environment.TickCount; | 2367 | m_perfMonMS = Environment.TickCount; |
2412 | 2368 | ||
2369 | PhysicsActor actor = m_physicsActor; | ||
2370 | Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; | ||
2371 | |||
2413 | Vector3 pos = m_pos; | 2372 | Vector3 pos = m_pos; |
2414 | pos.Z -= m_appearance.HipOffset; | 2373 | pos.Z += m_appearance.HipOffset; |
2415 | 2374 | ||
2416 | remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_regionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, | 2375 | //m_log.DebugFormat("[SCENEPRESENCE]: TerseUpdate: Pos={0} Rot={1} Vel={2}", m_pos, m_bodyRot, m_velocity); |
2417 | pos, m_velocity, Vector3.Zero, m_bodyRot, Vector4.UnitW, m_uuid, null, GetUpdatePriority(remoteClient))); | 2376 | |
2377 | remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, | ||
2378 | pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient))); | ||
2418 | 2379 | ||
2419 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2380 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); |
2420 | m_scene.StatsReporter.AddAgentUpdates(1); | 2381 | m_scene.StatsReporter.AddAgentUpdates(1); |
@@ -2510,7 +2471,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2510 | return; | 2471 | return; |
2511 | 2472 | ||
2512 | Vector3 pos = m_pos; | 2473 | Vector3 pos = m_pos; |
2513 | pos.Z -= m_appearance.HipOffset; | 2474 | pos.Z += m_appearance.HipOffset; |
2514 | 2475 | ||
2515 | remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, | 2476 | remoteAvatar.m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, |
2516 | LocalId, pos, m_appearance.Texture.GetBytes(), | 2477 | LocalId, pos, m_appearance.Texture.GetBytes(), |
@@ -2581,7 +2542,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2581 | // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); | 2542 | // m_scene.GetAvatarAppearance(m_controllingClient, out m_appearance); |
2582 | 2543 | ||
2583 | Vector3 pos = m_pos; | 2544 | Vector3 pos = m_pos; |
2584 | pos.Z -= m_appearance.HipOffset; | 2545 | pos.Z += m_appearance.HipOffset; |
2585 | 2546 | ||
2586 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, | 2547 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, |
2587 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); | 2548 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); |
@@ -2690,7 +2651,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2690 | } | 2651 | } |
2691 | 2652 | ||
2692 | Vector3 pos = m_pos; | 2653 | Vector3 pos = m_pos; |
2693 | pos.Z -= m_appearance.HipOffset; | 2654 | pos.Z += m_appearance.HipOffset; |
2694 | 2655 | ||
2695 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, | 2656 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, |
2696 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); | 2657 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); |
@@ -2778,7 +2739,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2778 | } | 2739 | } |
2779 | 2740 | ||
2780 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m | 2741 | // Minimum Draw distance is 64 meters, the Radius of the draw distance sphere is 32m |
2781 | if (Util.GetDistanceTo(AbsolutePosition, m_LastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance) | 2742 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || |
2743 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) | ||
2782 | { | 2744 | { |
2783 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | 2745 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); |
2784 | cadu.ActiveGroupID = UUID.Zero.Guid; | 2746 | cadu.ActiveGroupID = UUID.Zero.Guid; |
@@ -2792,7 +2754,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2792 | cadu.godlevel = m_godlevel; | 2754 | cadu.godlevel = m_godlevel; |
2793 | cadu.GroupAccess = 0; | 2755 | cadu.GroupAccess = 0; |
2794 | cadu.Position = new sLLVector3(AbsolutePosition); | 2756 | cadu.Position = new sLLVector3(AbsolutePosition); |
2795 | cadu.regionHandle = m_scene.RegionInfo.RegionHandle; | 2757 | cadu.regionHandle = m_rootRegionHandle; |
2796 | float multiplier = 1; | 2758 | float multiplier = 1; |
2797 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); | 2759 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); |
2798 | if (innacurateNeighbors != 0) | 2760 | if (innacurateNeighbors != 0) |
@@ -2812,11 +2774,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2812 | agentpos.CopyFrom(cadu); | 2774 | agentpos.CopyFrom(cadu); |
2813 | 2775 | ||
2814 | m_scene.SendOutChildAgentUpdates(agentpos, this); | 2776 | m_scene.SendOutChildAgentUpdates(agentpos, this); |
2815 | |||
2816 | m_LastChildAgentUpdatePosition.X = AbsolutePosition.X; | ||
2817 | m_LastChildAgentUpdatePosition.Y = AbsolutePosition.Y; | ||
2818 | m_LastChildAgentUpdatePosition.Z = AbsolutePosition.Z; | ||
2819 | 2777 | ||
2778 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
2779 | m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
2820 | } | 2780 | } |
2821 | } | 2781 | } |
2822 | 2782 | ||
@@ -2941,9 +2901,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2941 | m_inTransit = true; | 2901 | m_inTransit = true; |
2942 | 2902 | ||
2943 | if ((m_physicsActor != null) && m_physicsActor.Flying) | 2903 | if ((m_physicsActor != null) && m_physicsActor.Flying) |
2944 | m_AgentControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | 2904 | m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; |
2945 | else if ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) | 2905 | else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) |
2946 | m_AgentControlFlags &= ~(uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | 2906 | m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; |
2947 | } | 2907 | } |
2948 | 2908 | ||
2949 | public void NotInTransit() | 2909 | public void NotInTransit() |
@@ -2959,7 +2919,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2959 | public void Reset() | 2919 | public void Reset() |
2960 | { | 2920 | { |
2961 | // Put the child agent back at the center | 2921 | // Put the child agent back at the center |
2962 | AbsolutePosition = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 70); | 2922 | AbsolutePosition = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70); |
2963 | ResetAnimations(); | 2923 | ResetAnimations(); |
2964 | } | 2924 | } |
2965 | 2925 | ||
@@ -3069,9 +3029,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3069 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; | 3029 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; |
3070 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; | 3030 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; |
3071 | 3031 | ||
3032 | Vector3 offset = new Vector3(shiftx, shifty, 0f); | ||
3033 | |||
3072 | m_DrawDistance = cAgentData.Far; | 3034 | m_DrawDistance = cAgentData.Far; |
3073 | if (cAgentData.Position != new Vector3(-1, -1, -1)) // UGH!! | 3035 | if (cAgentData.Position != new Vector3(-1f, -1f, -1f)) // UGH!! |
3074 | m_pos = new Vector3(cAgentData.Position.X + shiftx, cAgentData.Position.Y + shifty, cAgentData.Position.Z); | 3036 | m_pos = cAgentData.Position + offset; |
3075 | 3037 | ||
3076 | if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) | 3038 | if (Vector3.Distance(AbsolutePosition, posLastSignificantMove) >= Scene.ChildReprioritizationDistance) |
3077 | { | 3039 | { |
@@ -3079,8 +3041,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3079 | ReprioritizeUpdates(); | 3041 | ReprioritizeUpdates(); |
3080 | } | 3042 | } |
3081 | 3043 | ||
3082 | // It's hard to say here.. We can't really tell where the camera position is unless it's in world cordinates from the sending region | 3044 | m_CameraCenter = cAgentData.Center + offset; |
3083 | m_CameraCenter = cAgentData.Center; | ||
3084 | 3045 | ||
3085 | m_avHeight = cAgentData.Size.Z; | 3046 | m_avHeight = cAgentData.Size.Z; |
3086 | //SetHeight(cAgentData.AVHeight); | 3047 | //SetHeight(cAgentData.AVHeight); |
@@ -3093,16 +3054,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3093 | m_sceneViewer.Reset(); | 3054 | m_sceneViewer.Reset(); |
3094 | 3055 | ||
3095 | //cAgentData.AVHeight; | 3056 | //cAgentData.AVHeight; |
3096 | //cAgentData.regionHandle; | 3057 | m_rootRegionHandle = cAgentData.RegionHandle; |
3097 | //m_velocity = cAgentData.Velocity; | 3058 | //m_velocity = cAgentData.Velocity; |
3098 | } | 3059 | } |
3099 | 3060 | ||
3100 | public void CopyTo(AgentData cAgent) | 3061 | public void CopyTo(AgentData cAgent) |
3101 | { | 3062 | { |
3102 | cAgent.AgentID = UUID; | 3063 | cAgent.AgentID = UUID; |
3103 | cAgent.RegionHandle = m_scene.RegionInfo.RegionHandle; | 3064 | cAgent.RegionHandle = m_rootRegionHandle; |
3104 | 3065 | ||
3105 | cAgent.Position = m_pos; | 3066 | cAgent.Position = AbsolutePosition; |
3106 | cAgent.Velocity = m_velocity; | 3067 | cAgent.Velocity = m_velocity; |
3107 | cAgent.Center = m_CameraCenter; | 3068 | cAgent.Center = m_CameraCenter; |
3108 | // Don't copy the size; it is inferred from apearance parameters | 3069 | // Don't copy the size; it is inferred from apearance parameters |
@@ -3129,7 +3090,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3129 | 3090 | ||
3130 | cAgent.HeadRotation = m_headrotation; | 3091 | cAgent.HeadRotation = m_headrotation; |
3131 | cAgent.BodyRotation = m_bodyRot; | 3092 | cAgent.BodyRotation = m_bodyRot; |
3132 | cAgent.ControlFlags = m_AgentControlFlags; | 3093 | cAgent.ControlFlags = (uint)m_AgentControlFlags; |
3133 | 3094 | ||
3134 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3095 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3135 | cAgent.GodLevel = (byte)m_godlevel; | 3096 | cAgent.GodLevel = (byte)m_godlevel; |
@@ -3199,7 +3160,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3199 | 3160 | ||
3200 | public void CopyFrom(AgentData cAgent) | 3161 | public void CopyFrom(AgentData cAgent) |
3201 | { | 3162 | { |
3202 | m_rootRegionHandle= cAgent.RegionHandle; | 3163 | m_rootRegionHandle = cAgent.RegionHandle; |
3164 | |||
3203 | m_callbackURI = cAgent.CallbackURI; | 3165 | m_callbackURI = cAgent.CallbackURI; |
3204 | 3166 | ||
3205 | m_pos = cAgent.Position; | 3167 | m_pos = cAgent.Position; |
@@ -3217,7 +3179,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3217 | 3179 | ||
3218 | m_headrotation = cAgent.HeadRotation; | 3180 | m_headrotation = cAgent.HeadRotation; |
3219 | m_bodyRot = cAgent.BodyRotation; | 3181 | m_bodyRot = cAgent.BodyRotation; |
3220 | m_AgentControlFlags = cAgent.ControlFlags; | 3182 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; |
3221 | 3183 | ||
3222 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3184 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3223 | m_godlevel = cAgent.GodLevel; | 3185 | m_godlevel = cAgent.GodLevel; |
@@ -3291,47 +3253,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3291 | /// </summary> | 3253 | /// </summary> |
3292 | public override void UpdateMovement() | 3254 | public override void UpdateMovement() |
3293 | { | 3255 | { |
3294 | lock (m_forcesList) | 3256 | if (m_forceToApply.HasValue) |
3295 | { | 3257 | { |
3296 | if (m_forcesList.Count > 0) | 3258 | Vector3 force = m_forceToApply.Value; |
3297 | { | ||
3298 | //we are only interested in the last velocity added to the list [Although they are called forces, they are actually velocities] | ||
3299 | NewForce force = m_forcesList[m_forcesList.Count - 1]; | ||
3300 | 3259 | ||
3301 | m_updateflag = true; | 3260 | m_updateflag = true; |
3302 | try | 3261 | // movementvector = force; |
3303 | { | 3262 | Velocity = force; |
3304 | movementvector.X = force.X; | ||
3305 | movementvector.Y = force.Y; | ||
3306 | movementvector.Z = force.Z; | ||
3307 | Velocity = movementvector; | ||
3308 | } | ||
3309 | catch (NullReferenceException) | ||
3310 | { | ||
3311 | // Under extreme load, this returns a NullReference Exception that we can ignore. | ||
3312 | // Ignoring this causes no movement to be sent to the physics engine... | ||
3313 | // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter! | ||
3314 | } | ||
3315 | 3263 | ||
3316 | m_forcesList.Clear(); | 3264 | m_forceToApply = null; |
3317 | } | ||
3318 | } | 3265 | } |
3319 | } | 3266 | } |
3320 | 3267 | ||
3321 | static ScenePresence() | ||
3322 | { | ||
3323 | Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); | ||
3324 | DefaultTexture = textu.GetBytes(); | ||
3325 | |||
3326 | } | ||
3327 | |||
3328 | public class NewForce | ||
3329 | { | ||
3330 | public float X; | ||
3331 | public float Y; | ||
3332 | public float Z; | ||
3333 | } | ||
3334 | |||
3335 | public override void SetText(string text, Vector3 color, double alpha) | 3268 | public override void SetText(string text, Vector3 color, double alpha) |
3336 | { | 3269 | { |
3337 | throw new Exception("Can't set Text on avatar."); | 3270 | throw new Exception("Can't set Text on avatar."); |
@@ -3342,7 +3275,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3342 | /// </summary> | 3275 | /// </summary> |
3343 | public void AddToPhysicalScene(bool isFlying) | 3276 | public void AddToPhysicalScene(bool isFlying) |
3344 | { | 3277 | { |
3345 | |||
3346 | PhysicsScene scene = m_scene.PhysicsScene; | 3278 | PhysicsScene scene = m_scene.PhysicsScene; |
3347 | 3279 | ||
3348 | Vector3 pVec = AbsolutePosition; | 3280 | Vector3 pVec = AbsolutePosition; |
@@ -3388,15 +3320,48 @@ namespace OpenSim.Region.Framework.Scenes | |||
3388 | // as of this comment the interval is set in AddToPhysicalScene | 3320 | // as of this comment the interval is set in AddToPhysicalScene |
3389 | UpdateMovementAnimations(); | 3321 | UpdateMovementAnimations(); |
3390 | 3322 | ||
3323 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | ||
3324 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | ||
3325 | |||
3326 | CollisionPlane = Vector4.UnitW; | ||
3327 | |||
3328 | if (coldata.Count != 0) | ||
3329 | { | ||
3330 | switch (m_movementAnimation) | ||
3331 | { | ||
3332 | case "STAND": | ||
3333 | case "WALK": | ||
3334 | case "RUN": | ||
3335 | case "CROUCH": | ||
3336 | case "CROUCHWALK": | ||
3337 | { | ||
3338 | ContactPoint lowest; | ||
3339 | lowest.SurfaceNormal = Vector3.Zero; | ||
3340 | lowest.Position = Vector3.Zero; | ||
3341 | lowest.Position.Z = Single.NaN; | ||
3342 | |||
3343 | foreach (ContactPoint contact in coldata.Values) | ||
3344 | { | ||
3345 | if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) | ||
3346 | { | ||
3347 | lowest = contact; | ||
3348 | } | ||
3349 | } | ||
3350 | |||
3351 | CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
3352 | } | ||
3353 | break; | ||
3354 | } | ||
3355 | } | ||
3356 | |||
3391 | if (m_invulnerable) | 3357 | if (m_invulnerable) |
3392 | return; | 3358 | return; |
3393 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 3359 | |
3394 | Dictionary<uint, float> coldata = collisionData.m_objCollisionList; | ||
3395 | float starthealth = Health; | 3360 | float starthealth = Health; |
3396 | uint killerObj = 0; | 3361 | uint killerObj = 0; |
3397 | foreach (uint localid in coldata.Keys) | 3362 | foreach (uint localid in coldata.Keys) |
3398 | { | 3363 | { |
3399 | if (coldata[localid] <= 0.10f || m_invulnerable) | 3364 | if (coldata[localid].PenetrationDepth <= 0.10f || m_invulnerable) |
3400 | continue; | 3365 | continue; |
3401 | //if (localid == 0) | 3366 | //if (localid == 0) |
3402 | //continue; | 3367 | //continue; |
@@ -3406,9 +3371,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3406 | if (part != null && part.ParentGroup.Damage != -1.0f) | 3371 | if (part != null && part.ParentGroup.Damage != -1.0f) |
3407 | Health -= part.ParentGroup.Damage; | 3372 | Health -= part.ParentGroup.Damage; |
3408 | else | 3373 | else |
3409 | Health -= coldata[localid] * 5; | 3374 | Health -= coldata[localid].PenetrationDepth * 5.0f; |
3410 | 3375 | ||
3411 | if (Health <= 0) | 3376 | if (Health <= 0.0f) |
3412 | { | 3377 | { |
3413 | if (localid != 0) | 3378 | if (localid != 0) |
3414 | killerObj = localid; | 3379 | killerObj = localid; |
@@ -3471,11 +3436,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3471 | 3436 | ||
3472 | public ScenePresence() | 3437 | public ScenePresence() |
3473 | { | 3438 | { |
3474 | if (DefaultTexture == null) | ||
3475 | { | ||
3476 | Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); | ||
3477 | DefaultTexture = textu.GetBytes(); | ||
3478 | } | ||
3479 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 3439 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
3480 | CreateSceneViewer(); | 3440 | CreateSceneViewer(); |
3481 | } | 3441 | } |
@@ -3632,19 +3592,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3632 | IgnoredControls &= ~(ScriptControlled)controls; | 3592 | IgnoredControls &= ~(ScriptControlled)controls; |
3633 | if (scriptedcontrols.ContainsKey(Script_item_UUID)) | 3593 | if (scriptedcontrols.ContainsKey(Script_item_UUID)) |
3634 | scriptedcontrols.Remove(Script_item_UUID); | 3594 | scriptedcontrols.Remove(Script_item_UUID); |
3635 | |||
3636 | } | 3595 | } |
3637 | else | 3596 | else |
3638 | { | 3597 | { |
3639 | 3598 | scriptedcontrols[Script_item_UUID] = obj; | |
3640 | if (scriptedcontrols.ContainsKey(Script_item_UUID)) | ||
3641 | { | ||
3642 | scriptedcontrols[Script_item_UUID] = obj; | ||
3643 | } | ||
3644 | else | ||
3645 | { | ||
3646 | scriptedcontrols.Add(Script_item_UUID, obj); | ||
3647 | } | ||
3648 | } | 3599 | } |
3649 | } | 3600 | } |
3650 | ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); | 3601 | ControllingClient.SendTakeControls(controls, pass_on == 1 ? true : false, true); |
@@ -3662,12 +3613,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3662 | 3613 | ||
3663 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) | 3614 | public void UnRegisterControlEventsToScript(uint Obj_localID, UUID Script_item_UUID) |
3664 | { | 3615 | { |
3616 | ScriptControllers takecontrols; | ||
3617 | |||
3665 | lock (scriptedcontrols) | 3618 | lock (scriptedcontrols) |
3666 | { | 3619 | { |
3667 | if (scriptedcontrols.ContainsKey(Script_item_UUID)) | 3620 | if (scriptedcontrols.TryGetValue(Script_item_UUID, out takecontrols)) |
3668 | { | 3621 | { |
3669 | ScriptControllers takecontrolls = scriptedcontrols[Script_item_UUID]; | 3622 | ScriptControlled sctc = takecontrols.eventControls; |
3670 | ScriptControlled sctc = takecontrolls.eventControls; | 3623 | |
3671 | ControllingClient.SendTakeControls((int)sctc, false, false); | 3624 | ControllingClient.SendTakeControls((int)sctc, false, false); |
3672 | ControllingClient.SendTakeControls((int)sctc, true, false); | 3625 | ControllingClient.SendTakeControls((int)sctc, true, false); |
3673 | 3626 | ||
@@ -3678,7 +3631,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3678 | IgnoredControls |= scData.ignoreControls; | 3631 | IgnoredControls |= scData.ignoreControls; |
3679 | } | 3632 | } |
3680 | } | 3633 | } |
3681 | |||
3682 | } | 3634 | } |
3683 | } | 3635 | } |
3684 | 3636 | ||
@@ -3745,9 +3697,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3745 | { | 3697 | { |
3746 | lock (scriptedcontrols) | 3698 | lock (scriptedcontrols) |
3747 | { | 3699 | { |
3748 | foreach (UUID scriptUUID in scriptedcontrols.Keys) | 3700 | foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) |
3749 | { | 3701 | { |
3750 | ScriptControllers scriptControlData = scriptedcontrols[scriptUUID]; | 3702 | UUID scriptUUID = kvp.Key; |
3703 | ScriptControllers scriptControlData = kvp.Value; | ||
3704 | |||
3751 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us | 3705 | ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us |
3752 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle | 3706 | ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle |
3753 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits | 3707 | ScriptControlled localChange = localHeld ^ localLast; // the changed bits |
@@ -3763,37 +3717,40 @@ namespace OpenSim.Region.Framework.Scenes | |||
3763 | LastCommands = allflags; | 3717 | LastCommands = allflags; |
3764 | } | 3718 | } |
3765 | 3719 | ||
3766 | internal static uint RemoveIgnoredControls(uint flags, ScriptControlled Ignored) | 3720 | internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) |
3767 | { | 3721 | { |
3768 | if (Ignored == ScriptControlled.CONTROL_ZERO) | 3722 | if (ignored == ScriptControlled.CONTROL_ZERO) |
3769 | return flags; | 3723 | return flags; |
3770 | if ((Ignored & ScriptControlled.CONTROL_BACK) != 0) | 3724 | |
3771 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); | 3725 | if ((ignored & ScriptControlled.CONTROL_BACK) != 0) |
3772 | if ((Ignored & ScriptControlled.CONTROL_FWD) != 0) | 3726 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG); |
3773 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); | 3727 | if ((ignored & ScriptControlled.CONTROL_FWD) != 0) |
3774 | if ((Ignored & ScriptControlled.CONTROL_DOWN) != 0) | 3728 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS | AgentManager.ControlFlags.AGENT_CONTROL_AT_POS); |
3775 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); | 3729 | if ((ignored & ScriptControlled.CONTROL_DOWN) != 0) |
3776 | if ((Ignored & ScriptControlled.CONTROL_UP) != 0) | 3730 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG); |
3777 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); | 3731 | if ((ignored & ScriptControlled.CONTROL_UP) != 0) |
3778 | if ((Ignored & ScriptControlled.CONTROL_LEFT) != 0) | 3732 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS | AgentManager.ControlFlags.AGENT_CONTROL_UP_POS); |
3779 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); | 3733 | if ((ignored & ScriptControlled.CONTROL_LEFT) != 0) |
3780 | if ((Ignored & ScriptControlled.CONTROL_RIGHT) != 0) | 3734 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS | AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS); |
3781 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); | 3735 | if ((ignored & ScriptControlled.CONTROL_RIGHT) != 0) |
3782 | if ((Ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) | 3736 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG | AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG); |
3783 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); | 3737 | if ((ignored & ScriptControlled.CONTROL_ROT_LEFT) != 0) |
3784 | if ((Ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) | 3738 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG); |
3785 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); | 3739 | if ((ignored & ScriptControlled.CONTROL_ROT_RIGHT) != 0) |
3786 | if ((Ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) | 3740 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS); |
3787 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); | 3741 | if ((ignored & ScriptControlled.CONTROL_ML_LBUTTON) != 0) |
3788 | if ((Ignored & ScriptControlled.CONTROL_LBUTTON) != 0) | 3742 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN); |
3789 | flags &= ~((uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); | 3743 | if ((ignored & ScriptControlled.CONTROL_LBUTTON) != 0) |
3790 | //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, | 3744 | flags &= ~(AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP | AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN); |
3791 | //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, | 3745 | |
3792 | //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, | 3746 | //DIR_CONTROL_FLAG_FORWARD = AgentManager.ControlFlags.AGENT_CONTROL_AT_POS, |
3793 | //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, | 3747 | //DIR_CONTROL_FLAG_BACK = AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG, |
3794 | //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, | 3748 | //DIR_CONTROL_FLAG_LEFT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS, |
3795 | //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | 3749 | //DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG, |
3796 | //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | 3750 | //DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS, |
3751 | //DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG, | ||
3752 | //DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG | ||
3753 | |||
3797 | return flags; | 3754 | return flags; |
3798 | } | 3755 | } |
3799 | 3756 | ||
@@ -3950,7 +3907,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3950 | } | 3907 | } |
3951 | else | 3908 | else |
3952 | { | 3909 | { |
3953 | group = Scene.SceneGraph.GetGroupByPrim(data.localID); | 3910 | group = Scene.GetGroupByPrim(data.localID); |
3954 | if (group != null) | 3911 | if (group != null) |
3955 | return GetSOGUpdatePriority(group); | 3912 | return GetSOGUpdatePriority(group); |
3956 | } | 3913 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index 19c0fea..f495022 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | |||
@@ -219,7 +219,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
219 | Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); | 219 | Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent"); |
220 | 220 | ||
221 | // Accepts 0 but rejects Constants.RegionSize | 221 | // Accepts 0 but rejects Constants.RegionSize |
222 | Vector3 pos = new Vector3(0,Constants.RegionSize-1,0); | 222 | Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0); |
223 | presence.MakeRootAgent(pos,true); | 223 | presence.MakeRootAgent(pos,true); |
224 | Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); | 224 | Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent"); |
225 | Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); | 225 | Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered"); |
@@ -246,7 +246,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
246 | scene2.AddNewClient(testclient); | 246 | scene2.AddNewClient(testclient); |
247 | 247 | ||
248 | ScenePresence presence = scene.GetScenePresence(agent1); | 248 | ScenePresence presence = scene.GetScenePresence(agent1); |
249 | presence.MakeRootAgent(new Vector3(0,Constants.RegionSize-1,0), true); | 249 | presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true); |
250 | 250 | ||
251 | ScenePresence presence2 = scene2.GetScenePresence(agent1); | 251 | ScenePresence presence2 = scene2.GetScenePresence(agent1); |
252 | 252 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs new file mode 100644 index 0000000..b68a044 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | using NUnit.Framework; | ||
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | using OpenSim.Tests.Common; | ||
37 | using OpenSim.Tests.Common.Setup; | ||
38 | using OpenSim.Tests.Common.Mock; | ||
39 | |||
40 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
41 | { | ||
42 | [TestFixture] | ||
43 | public class UuidGathererTests | ||
44 | { | ||
45 | protected IAssetService m_assetService; | ||
46 | protected UuidGatherer m_uuidGatherer; | ||
47 | |||
48 | [SetUp] | ||
49 | public void Init() | ||
50 | { | ||
51 | m_assetService = new MockAssetService(); | ||
52 | m_uuidGatherer = new UuidGatherer(m_assetService); | ||
53 | } | ||
54 | |||
55 | [Test] | ||
56 | public void TestCorruptAsset() | ||
57 | { | ||
58 | TestHelper.InMethod(); | ||
59 | |||
60 | UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); | ||
61 | AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET"); | ||
62 | m_assetService.Store(corruptAsset); | ||
63 | |||
64 | IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); | ||
65 | m_uuidGatherer.GatherAssetUuids(corruptAssetUuid, AssetType.Object, foundAssetUuids); | ||
66 | |||
67 | // We count the uuid as gathered even if the asset itself is corrupt. | ||
68 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); | ||
69 | } | ||
70 | |||
71 | /// <summary> | ||
72 | /// Test requests made for non-existent assets while we're gathering | ||
73 | /// </summary> | ||
74 | [Test] | ||
75 | public void TestMissingAsset() | ||
76 | { | ||
77 | TestHelper.InMethod(); | ||
78 | |||
79 | UUID missingAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); | ||
80 | IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); | ||
81 | |||
82 | m_uuidGatherer.GatherAssetUuids(missingAssetUuid, AssetType.Object, foundAssetUuids); | ||
83 | |||
84 | // We count the uuid as gathered even if the asset itself is missing. | ||
85 | Assert.That(foundAssetUuids.Count, Is.EqualTo(1)); | ||
86 | } | ||
87 | } | ||
88 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 525a93a..930af81 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -273,7 +273,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
273 | { | 273 | { |
274 | string xml = Utils.BytesToString(objectAsset.Data); | 274 | string xml = Utils.BytesToString(objectAsset.Data); |
275 | SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml); | 275 | SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(xml); |
276 | GatherAssetUuids(sog, assetUuids); | 276 | |
277 | if (null != sog) | ||
278 | GatherAssetUuids(sog, assetUuids); | ||
277 | } | 279 | } |
278 | } | 280 | } |
279 | } | 281 | } |