aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs102
1 files changed, 48 insertions, 54 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6812914..f6bcb59 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -790,37 +790,13 @@ namespace OpenSim.Region.Framework.Scenes
790 /// </summary> 790 /// </summary>
791 public void SendPrimUpdates() 791 public void SendPrimUpdates()
792 { 792 {
793 m_perfMonMS = EnvironmentTickCount(); 793 m_perfMonMS = Util.EnvironmentTickCount();
794 794
795 m_sceneViewer.SendPrimUpdates(); 795 m_sceneViewer.SendPrimUpdates();
796 796
797 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); 797 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
798 } 798 }
799 799
800 /// <summary>
801 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive
802 /// and negative every 24.9 days. This trims down TickCount so it doesn't wrap
803 /// for the callers.
804 /// This trims it to a 12 day interval so don't let your frame time get too long.
805 /// </summary>
806 /// <returns></returns>
807 const Int32 EnvironmentTickCountMask = 0x3fffffff;
808 private static Int32 EnvironmentTickCount() {
809 return Environment.TickCount & EnvironmentTickCountMask;
810 }
811
812 /// <summary>
813 /// Environment.TickCount is an int but it counts all 32 bits so it goes positive
814 /// and negative every 24.9 days. Subtracts the passed value (previously fetched by
815 /// 'EnvironmentTickCount()') and accounts for any wrapping.
816 /// </summary>
817 /// <returns>subtraction of passed prevValue from current Environment.TickCount</returns>
818 private static Int32 EnvironmentTickCountSubtract(Int32 prevValue) {
819 Int32 diff = EnvironmentTickCount() - prevValue;
820 return (diff >= 0) ? diff : (diff + EnvironmentTickCountMask + 1);
821 }
822
823
824 #region Status Methods 800 #region Status Methods
825 801
826 /// <summary> 802 /// <summary>
@@ -1166,7 +1142,7 @@ namespace OpenSim.Region.Framework.Scenes
1166 /// <param name="collisionPoint"></param> 1142 /// <param name="collisionPoint"></param>
1167 /// <param name="localid"></param> 1143 /// <param name="localid"></param>
1168 /// <param name="distance"></param> 1144 /// <param name="distance"></param>
1169 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) 1145 public void RayCastCameraCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 pNormal)
1170 { 1146 {
1171 const float POSITION_TOLERANCE = 0.02f; 1147 const float POSITION_TOLERANCE = 0.02f;
1172 const float VELOCITY_TOLERANCE = 0.02f; 1148 const float VELOCITY_TOLERANCE = 0.02f;
@@ -1209,7 +1185,7 @@ namespace OpenSim.Region.Framework.Scenes
1209 // return; 1185 // return;
1210 //} 1186 //}
1211 1187
1212 m_perfMonMS = EnvironmentTickCount(); 1188 m_perfMonMS = Util.EnvironmentTickCount();
1213 1189
1214 ++m_movementUpdateCount; 1190 ++m_movementUpdateCount;
1215 if (m_movementUpdateCount < 1) 1191 if (m_movementUpdateCount < 1)
@@ -1539,7 +1515,7 @@ namespace OpenSim.Region.Framework.Scenes
1539 1515
1540 m_scene.EventManager.TriggerOnClientMovement(this); 1516 m_scene.EventManager.TriggerOnClientMovement(this);
1541 1517
1542 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); 1518 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
1543 } 1519 }
1544 1520
1545 public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client) 1521 public void DoAutoPilot(uint not_used, Vector3 Pos, IClientAPI remote_client)
@@ -1764,11 +1740,14 @@ namespace OpenSim.Region.Framework.Scenes
1764 UUID avOnTargetAlready = part.GetAvatarOnSitTarget(); 1740 UUID avOnTargetAlready = part.GetAvatarOnSitTarget();
1765 1741
1766 bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero)); 1742 bool SitTargetUnOccupied = (!(avOnTargetAlready != UUID.Zero));
1767// bool SitTargetisSet = 1743 bool SitTargetisSet =
1768// (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f && avSitOrientation.W == 0f && 1744 (!(avSitOffSet.X == 0f && avSitOffSet.Y == 0f && avSitOffSet.Z == 0f &&
1769// avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f)); 1745 (
1770 1746 avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 1f // Valid Zero Rotation quaternion
1771 bool SitTargetisSet = ((Vector3.Zero != avSitOffSet) || (Quaternion.Identity != avSitOrientation)); 1747 || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 1f && avSitOrientation.W == 0f // W-Z Mapping was invalid at one point
1748 || avSitOrientation.X == 0f && avSitOrientation.Y == 0f && avSitOrientation.Z == 0f && avSitOrientation.W == 0f // Invalid Quaternion
1749 )
1750 ));
1772 1751
1773//Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied + 1752//Console.WriteLine("SendSitResponse offset=" + offset + " UnOccup=" + SitTargetUnOccupied +
1774// " TargSet=" + SitTargetisSet); 1753// " TargSet=" + SitTargetisSet);
@@ -1850,7 +1829,7 @@ namespace OpenSim.Region.Framework.Scenes
1850 StandUp(); 1829 StandUp();
1851 } 1830 }
1852 m_nextSitAnimation = "SIT"; 1831 m_nextSitAnimation = "SIT";
1853 1832
1854 //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID); 1833 //SceneObjectPart part = m_scene.GetSceneObjectPart(targetID);
1855 SceneObjectPart part = FindNextAvailableSitTarget(targetID); 1834 SceneObjectPart part = FindNextAvailableSitTarget(targetID);
1856 1835
@@ -1862,12 +1841,23 @@ namespace OpenSim.Region.Framework.Scenes
1862 } 1841 }
1863 m_requestedSitTargetID = part.LocalId; 1842 m_requestedSitTargetID = part.LocalId;
1864 //m_requestedSitOffset = offset; 1843 //m_requestedSitOffset = offset;
1844 //offset.X += part.Scale.X;// *offset.X;
1845 //offset.Y += part.Scale.Y;// * offset.Y;
1846 //offset.Z += part.Scale.Z;// * offset.Z;
1847 //m_requestedSitOffset = offset;
1848 m_log.DebugFormat("[SIT]: Client requested Sit Position: {0}", offset);
1865 } 1849 }
1866 else 1850 else
1867 { 1851 {
1868 1852
1869 m_log.Warn("Sit requested on unknown object: " + targetID.ToString()); 1853 m_log.Warn("Sit requested on unknown object: " + targetID.ToString());
1870 } 1854 }
1855
1856 if (m_scene.PhysicsScene.SupportsRayCast())
1857 {
1858 //m_scene.PhysicsScene.RaycastWorld(Vector3.Zero,Vector3.Zero, 0.01f,new RaycastCallback());
1859 }
1860
1871 SendSitResponse(remoteClient, targetID, offset); 1861 SendSitResponse(remoteClient, targetID, offset);
1872 } 1862 }
1873 1863
@@ -1982,7 +1972,7 @@ namespace OpenSim.Region.Framework.Scenes
1982 SendFullUpdateToAllClients(); 1972 SendFullUpdateToAllClients();
1983 } 1973 }
1984 1974
1985 public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance) 1975 public void SitAltitudeCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal)
1986 { 1976 {
1987 if(hitYN) 1977 if(hitYN)
1988 { 1978 {
@@ -2057,7 +2047,7 @@ namespace OpenSim.Region.Framework.Scenes
2057 return; 2047 return;
2058 } 2048 }
2059 2049
2060 m_perfMonMS = EnvironmentTickCount(); 2050 m_perfMonMS = Util.EnvironmentTickCount();
2061 2051
2062 Rotation = rotation; 2052 Rotation = rotation;
2063 Vector3 direc = vec * rotation; 2053 Vector3 direc = vec * rotation;
@@ -2099,7 +2089,7 @@ namespace OpenSim.Region.Framework.Scenes
2099 // TODO: Add the force instead of only setting it to support multiple forces per frame? 2089 // TODO: Add the force instead of only setting it to support multiple forces per frame?
2100 m_forceToApply = direc; 2090 m_forceToApply = direc;
2101 m_isNudging = Nudging; 2091 m_isNudging = Nudging;
2102 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCount() - m_perfMonMS); 2092 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2103 } 2093 }
2104 2094
2105 #endregion 2095 #endregion
@@ -2168,7 +2158,7 @@ namespace OpenSim.Region.Framework.Scenes
2168 // server. 2158 // server.
2169 if (remoteClient.IsActive) 2159 if (remoteClient.IsActive)
2170 { 2160 {
2171 m_perfMonMS = EnvironmentTickCount(); 2161 m_perfMonMS = Util.EnvironmentTickCount();
2172 2162
2173 PhysicsActor actor = m_physicsActor; 2163 PhysicsActor actor = m_physicsActor;
2174 Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero; 2164 Vector3 velocity = (actor != null) ? actor.Velocity : Vector3.Zero;
@@ -2181,7 +2171,7 @@ namespace OpenSim.Region.Framework.Scenes
2181 remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId, 2171 remoteClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
2182 pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient))); 2172 pos, velocity, Vector3.Zero, m_bodyRot, CollisionPlane, m_uuid, null, GetUpdatePriority(remoteClient)));
2183 2173
2184 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); 2174 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2185 m_scene.StatsReporter.AddAgentUpdates(1); 2175 m_scene.StatsReporter.AddAgentUpdates(1);
2186 } 2176 }
2187 } 2177 }
@@ -2191,11 +2181,11 @@ namespace OpenSim.Region.Framework.Scenes
2191 /// </summary> 2181 /// </summary>
2192 public void SendTerseUpdateToAllClients() 2182 public void SendTerseUpdateToAllClients()
2193 { 2183 {
2194 m_perfMonMS = EnvironmentTickCount(); 2184 m_perfMonMS = Util.EnvironmentTickCount();
2195 2185
2196 m_scene.ForEachClient(SendTerseUpdateToClient); 2186 m_scene.ForEachClient(SendTerseUpdateToClient);
2197 2187
2198 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); 2188 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2199 } 2189 }
2200 2190
2201 public void SendCoarseLocations() 2191 public void SendCoarseLocations()
@@ -2215,7 +2205,7 @@ namespace OpenSim.Region.Framework.Scenes
2215 2205
2216 public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p) 2206 public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p)
2217 { 2207 {
2218 m_perfMonMS = EnvironmentTickCount(); 2208 m_perfMonMS = Util.EnvironmentTickCount();
2219 2209
2220 List<Vector3> CoarseLocations = new List<Vector3>(); 2210 List<Vector3> CoarseLocations = new List<Vector3>();
2221 List<UUID> AvatarUUIDs = new List<UUID>(); 2211 List<UUID> AvatarUUIDs = new List<UUID>();
@@ -2251,7 +2241,7 @@ namespace OpenSim.Region.Framework.Scenes
2251 2241
2252 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations); 2242 m_controllingClient.SendCoarseLocationUpdate(AvatarUUIDs, CoarseLocations);
2253 2243
2254 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); 2244 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2255 } 2245 }
2256 2246
2257 public void CoarseLocationChange() 2247 public void CoarseLocationChange()
@@ -2288,7 +2278,7 @@ namespace OpenSim.Region.Framework.Scenes
2288 /// </summary> 2278 /// </summary>
2289 public void SendInitialFullUpdateToAllClients() 2279 public void SendInitialFullUpdateToAllClients()
2290 { 2280 {
2291 m_perfMonMS = EnvironmentTickCount(); 2281 m_perfMonMS = Util.EnvironmentTickCount();
2292 2282
2293 ScenePresence[] avatars = m_scene.GetScenePresences(); 2283 ScenePresence[] avatars = m_scene.GetScenePresences();
2294 2284
@@ -2314,14 +2304,14 @@ namespace OpenSim.Region.Framework.Scenes
2314 } 2304 }
2315 2305
2316 m_scene.StatsReporter.AddAgentUpdates(avatars.Length); 2306 m_scene.StatsReporter.AddAgentUpdates(avatars.Length);
2317 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); 2307 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2318 2308
2319 //Animator.SendAnimPack(); 2309 //Animator.SendAnimPack();
2320 } 2310 }
2321 2311
2322 public void SendFullUpdateToAllClients() 2312 public void SendFullUpdateToAllClients()
2323 { 2313 {
2324 m_perfMonMS = EnvironmentTickCount(); 2314 m_perfMonMS = Util.EnvironmentTickCount();
2325 2315
2326 // only send update from root agents to other clients; children are only "listening posts" 2316 // only send update from root agents to other clients; children are only "listening posts"
2327 List<ScenePresence> avatars = m_scene.GetAvatars(); 2317 List<ScenePresence> avatars = m_scene.GetAvatars();
@@ -2331,7 +2321,7 @@ namespace OpenSim.Region.Framework.Scenes
2331 2321
2332 } 2322 }
2333 m_scene.StatsReporter.AddAgentUpdates(avatars.Count); 2323 m_scene.StatsReporter.AddAgentUpdates(avatars.Count);
2334 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); 2324 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2335 2325
2336 Animator.SendAnimPack(); 2326 Animator.SendAnimPack();
2337 } 2327 }
@@ -2373,7 +2363,7 @@ namespace OpenSim.Region.Framework.Scenes
2373 /// </summary> 2363 /// </summary>
2374 public void SendAppearanceToAllOtherAgents() 2364 public void SendAppearanceToAllOtherAgents()
2375 { 2365 {
2376 m_perfMonMS = EnvironmentTickCount(); 2366 m_perfMonMS = Util.EnvironmentTickCount();
2377 2367
2378 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 2368 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
2379 { 2369 {
@@ -2382,8 +2372,8 @@ namespace OpenSim.Region.Framework.Scenes
2382 SendAppearanceToOtherAgent(scenePresence); 2372 SendAppearanceToOtherAgent(scenePresence);
2383 } 2373 }
2384 }); 2374 });
2385 2375
2386 m_scene.StatsReporter.AddAgentTime(EnvironmentTickCountSubtract(m_perfMonMS)); 2376 m_scene.StatsReporter.AddAgentTime(Util.EnvironmentTickCountSubtract(m_perfMonMS));
2387 } 2377 }
2388 2378
2389 /// <summary> 2379 /// <summary>
@@ -3084,7 +3074,9 @@ namespace OpenSim.Region.Framework.Scenes
3084 3074
3085 // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents( 3075 // The Physics Scene will send updates every 500 ms grep: m_physicsActor.SubscribeEvents(
3086 // as of this comment the interval is set in AddToPhysicalScene 3076 // as of this comment the interval is set in AddToPhysicalScene
3087 3077 if (Animator!=null)
3078 Animator.UpdateMovementAnimations();
3079
3088 CollisionEventUpdate collisionData = (CollisionEventUpdate)e; 3080 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
3089 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; 3081 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;
3090 3082
@@ -3096,7 +3088,7 @@ namespace OpenSim.Region.Framework.Scenes
3096 m_lastColCount = coldata.Count; 3088 m_lastColCount = coldata.Count;
3097 } 3089 }
3098 3090
3099 if (coldata.Count != 0) 3091 if (coldata.Count != 0 && Animator != null)
3100 { 3092 {
3101 switch (Animator.CurrentMovementAnimation) 3093 switch (Animator.CurrentMovementAnimation)
3102 { 3094 {
@@ -3200,11 +3192,13 @@ namespace OpenSim.Region.Framework.Scenes
3200 3192
3201 // I don't get it but mono crashes when you try to dispose of this timer, 3193 // I don't get it but mono crashes when you try to dispose of this timer,
3202 // unsetting the elapsed callback should be enough to allow for cleanup however. 3194 // unsetting the elapsed callback should be enough to allow for cleanup however.
3203 //m_reprioritizationTimer.Dispose(); 3195 // m_reprioritizationTimer.Dispose();
3204 3196
3205 m_sceneViewer.Close(); 3197 m_sceneViewer.Close();
3206 3198
3207 RemoveFromPhysicalScene(); 3199 RemoveFromPhysicalScene();
3200 m_animator.Close();
3201 m_animator = null;
3208 } 3202 }
3209 3203
3210 public ScenePresence() 3204 public ScenePresence()