diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 361 |
1 files changed, 235 insertions, 126 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f20d065..3167282 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -277,6 +277,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
277 | private Quaternion m_lastRotation; | 277 | private Quaternion m_lastRotation; |
278 | private Vector3 m_lastVelocity; | 278 | private Vector3 m_lastVelocity; |
279 | private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); | 279 | private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); |
280 | private bool SentInitialData = false; | ||
280 | 281 | ||
281 | private bool m_followCamAuto = false; | 282 | private bool m_followCamAuto = false; |
282 | 283 | ||
@@ -342,8 +343,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
342 | private const float FLY_ROLL_RESET_RADIANS_PER_UPDATE = 0.02f; | 343 | private const float FLY_ROLL_RESET_RADIANS_PER_UPDATE = 0.02f; |
343 | 344 | ||
344 | private float m_health = 100f; | 345 | private float m_health = 100f; |
346 | private float m_healRate = 1f; | ||
347 | private float m_healRatePerFrame = 0.05f; | ||
345 | 348 | ||
346 | protected ulong crossingFromRegion; | 349 | // protected ulong crossingFromRegion; |
347 | 350 | ||
348 | private readonly Vector3[] Dir_Vectors = new Vector3[12]; | 351 | private readonly Vector3[] Dir_Vectors = new Vector3[12]; |
349 | 352 | ||
@@ -565,19 +568,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
565 | public string Firstname { get; private set; } | 568 | public string Firstname { get; private set; } |
566 | public string Lastname { get; private set; } | 569 | public string Lastname { get; private set; } |
567 | 570 | ||
571 | public bool haveGroupInformation; | ||
572 | public bool gotCrossUpdate; | ||
573 | public byte crossingFlags; | ||
574 | |||
568 | public string Grouptitle | 575 | public string Grouptitle |
569 | { | 576 | { |
570 | get { return UseFakeGroupTitle ? "(Loading)" : m_groupTitle; } | 577 | get { return m_groupTitle; } |
571 | set { m_groupTitle = value; } | 578 | set { m_groupTitle = value; } |
572 | } | 579 | } |
573 | private string m_groupTitle; | 580 | private string m_groupTitle; |
574 | 581 | ||
575 | /// <summary> | ||
576 | /// When this is 'true', return a dummy group title instead of the real group title. This is | ||
577 | /// used as part of a hack to force viewers to update the displayed avatar name. | ||
578 | /// </summary> | ||
579 | public bool UseFakeGroupTitle { get; set; } | ||
580 | |||
581 | // Agent's Draw distance. | 582 | // Agent's Draw distance. |
582 | private float m_drawDistance = 255f; | 583 | private float m_drawDistance = 255f; |
583 | public float DrawDistance | 584 | public float DrawDistance |
@@ -860,6 +861,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
860 | set { m_health = value; } | 861 | set { m_health = value; } |
861 | } | 862 | } |
862 | 863 | ||
864 | public float HealRate | ||
865 | { | ||
866 | get { return m_healRate; } | ||
867 | set | ||
868 | { | ||
869 | if(value > 100.0f) | ||
870 | m_healRate = 100.0f; | ||
871 | else if (value <= 0.0) | ||
872 | m_healRate = 0.0f; | ||
873 | else | ||
874 | m_healRate = value; | ||
875 | |||
876 | if(Scene != null) | ||
877 | m_healRatePerFrame = m_healRate * Scene.FrameTime; | ||
878 | else | ||
879 | m_healRatePerFrame = 0.05f; | ||
880 | } | ||
881 | } | ||
882 | |||
883 | |||
863 | /// <summary> | 884 | /// <summary> |
864 | /// Gets the world rotation of this presence. | 885 | /// Gets the world rotation of this presence. |
865 | /// </summary> | 886 | /// </summary> |
@@ -1039,9 +1060,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1039 | if (account != null) | 1060 | if (account != null) |
1040 | UserLevel = account.UserLevel; | 1061 | UserLevel = account.UserLevel; |
1041 | 1062 | ||
1042 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 1063 | // IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
1043 | if (gm != null) | 1064 | // if (gm != null) |
1044 | Grouptitle = gm.GetGroupTitle(m_uuid); | 1065 | // Grouptitle = gm.GetGroupTitle(m_uuid); |
1045 | 1066 | ||
1046 | m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); | 1067 | m_scriptEngines = m_scene.RequestModuleInterfaces<IScriptModule>(); |
1047 | 1068 | ||
@@ -1063,6 +1084,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1063 | 1084 | ||
1064 | m_stateMachine = new ScenePresenceStateMachine(this); | 1085 | m_stateMachine = new ScenePresenceStateMachine(this); |
1065 | 1086 | ||
1087 | HealRate = 0.5f; | ||
1088 | |||
1066 | IConfig sconfig = m_scene.Config.Configs["EntityTransfer"]; | 1089 | IConfig sconfig = m_scene.Config.Configs["EntityTransfer"]; |
1067 | if (sconfig != null) | 1090 | if (sconfig != null) |
1068 | { | 1091 | { |
@@ -1073,6 +1096,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1073 | 1096 | ||
1074 | } | 1097 | } |
1075 | 1098 | ||
1099 | private float lastHealthSent = 0; | ||
1100 | |||
1076 | private void RegionHeartbeatEnd(Scene scene) | 1101 | private void RegionHeartbeatEnd(Scene scene) |
1077 | { | 1102 | { |
1078 | if (IsChildAgent) | 1103 | if (IsChildAgent) |
@@ -1095,7 +1120,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1095 | } | 1120 | } |
1096 | else | 1121 | else |
1097 | { | 1122 | { |
1098 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | 1123 | // m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; |
1124 | } | ||
1125 | } | ||
1126 | |||
1127 | if(m_healRatePerFrame != 0f && Health != 100.0f) | ||
1128 | { | ||
1129 | float last = Health; | ||
1130 | Health += m_healRatePerFrame; | ||
1131 | if(Health > 100.0f) | ||
1132 | { | ||
1133 | Health = 100.0f; | ||
1134 | lastHealthSent = Health; | ||
1135 | ControllingClient.SendHealth(Health); | ||
1136 | } | ||
1137 | else if(Math.Abs(Health - lastHealthSent) > 1.0) | ||
1138 | { | ||
1139 | lastHealthSent = Health; | ||
1140 | ControllingClient.SendHealth(Health); | ||
1099 | } | 1141 | } |
1100 | } | 1142 | } |
1101 | } | 1143 | } |
@@ -1190,8 +1232,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1190 | else | 1232 | else |
1191 | { | 1233 | { |
1192 | part.AddSittingAvatar(this); | 1234 | part.AddSittingAvatar(this); |
1193 | if (part.SitTargetPosition != Vector3.Zero) | 1235 | // if not actually on the target invalidate it |
1194 | part.SitTargetAvatar = UUID; | 1236 | if(gotCrossUpdate && (crossingFlags & 0x04) == 0) |
1237 | part.SitTargetAvatar = UUID.Zero; | ||
1238 | |||
1195 | ParentID = part.LocalId; | 1239 | ParentID = part.LocalId; |
1196 | ParentPart = part; | 1240 | ParentPart = part; |
1197 | m_pos = PrevSitOffset; | 1241 | m_pos = PrevSitOffset; |
@@ -1214,11 +1258,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1214 | // Should not be needed if we are not trying to tell this region to close | 1258 | // Should not be needed if we are not trying to tell this region to close |
1215 | // DoNotCloseAfterTeleport = false; | 1259 | // DoNotCloseAfterTeleport = false; |
1216 | 1260 | ||
1217 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | ||
1218 | if (gm != null) | ||
1219 | Grouptitle = gm.GetGroupTitle(m_uuid); | ||
1220 | |||
1221 | m_log.DebugFormat("[MakeRootAgent] Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | ||
1222 | 1261 | ||
1223 | RegionHandle = m_scene.RegionInfo.RegionHandle; | 1262 | RegionHandle = m_scene.RegionInfo.RegionHandle; |
1224 | 1263 | ||
@@ -1467,6 +1506,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1467 | /// </remarks> | 1506 | /// </remarks> |
1468 | public void MakeChildAgent(ulong newRegionHandle) | 1507 | public void MakeChildAgent(ulong newRegionHandle) |
1469 | { | 1508 | { |
1509 | haveGroupInformation = false; | ||
1510 | gotCrossUpdate = false; | ||
1511 | crossingFlags = 0; | ||
1470 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; | 1512 | m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; |
1471 | 1513 | ||
1472 | RegionHandle = newRegionHandle; | 1514 | RegionHandle = newRegionHandle; |
@@ -1934,25 +1976,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
1934 | 1976 | ||
1935 | m_log.DebugFormat("[CompleteMovement] MakeRootAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | 1977 | m_log.DebugFormat("[CompleteMovement] MakeRootAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); |
1936 | 1978 | ||
1979 | if(!haveGroupInformation && !IsChildAgent && !isNPC) | ||
1980 | { | ||
1981 | // oh crap.. lets retry it directly | ||
1982 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | ||
1983 | if (gm != null) | ||
1984 | Grouptitle = gm.GetGroupTitle(m_uuid); | ||
1937 | 1985 | ||
1938 | // start sending terrain patchs | 1986 | m_log.DebugFormat("[CompleteMovement] Missing Grouptitle: {0}ms", Util.EnvironmentTickCountSubtract(ts)); |
1939 | if (!isNPC) | ||
1940 | Scene.SendLayerData(ControllingClient); | ||
1941 | 1987 | ||
1942 | if (!IsChildAgent && !isNPC) | ||
1943 | { | ||
1944 | InventoryFolderBase cof = m_scene.InventoryService.GetFolderForType(client.AgentId, (FolderType)46); | 1988 | InventoryFolderBase cof = m_scene.InventoryService.GetFolderForType(client.AgentId, (FolderType)46); |
1945 | if (cof == null) | 1989 | if (cof == null) |
1946 | COF = UUID.Zero; | 1990 | COF = UUID.Zero; |
1947 | else | 1991 | else |
1948 | COF = cof.ID; | 1992 | COF = cof.ID; |
1949 | 1993 | ||
1950 | m_log.DebugFormat("[ScenePresence]: CompleteMovement COF for {0} is {1}", client.AgentId, COF); | 1994 | m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF); |
1951 | } | 1995 | } |
1952 | 1996 | ||
1997 | |||
1953 | // Tell the client that we're totally ready | 1998 | // Tell the client that we're totally ready |
1954 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); | 1999 | ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); |
1955 | 2000 | ||
2001 | |||
1956 | m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | 2002 | m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts)); |
1957 | 2003 | ||
1958 | if (!string.IsNullOrEmpty(m_callbackURI)) | 2004 | if (!string.IsNullOrEmpty(m_callbackURI)) |
@@ -1985,6 +2031,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1985 | 2031 | ||
1986 | m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | 2032 | m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); |
1987 | 2033 | ||
2034 | // start sending terrain patchs | ||
2035 | if (!gotCrossUpdate && !isNPC) | ||
2036 | Scene.SendLayerData(ControllingClient); | ||
2037 | |||
1988 | m_previusParcelHide = false; | 2038 | m_previusParcelHide = false; |
1989 | m_previusParcelUUID = UUID.Zero; | 2039 | m_previusParcelUUID = UUID.Zero; |
1990 | m_currentParcelHide = false; | 2040 | m_currentParcelHide = false; |
@@ -2143,8 +2193,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2143 | { | 2193 | { |
2144 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | 2194 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); |
2145 | if (friendsModule != null) | 2195 | if (friendsModule != null) |
2146 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | 2196 | { |
2147 | 2197 | if(gotCrossUpdate) | |
2198 | friendsModule.IsNpwRoot(this); | ||
2199 | else | ||
2200 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | ||
2201 | } | ||
2148 | m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | 2202 | m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts)); |
2149 | 2203 | ||
2150 | } | 2204 | } |
@@ -2160,6 +2214,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2160 | // m_currentParcelHide = newhide; | 2214 | // m_currentParcelHide = newhide; |
2161 | // } | 2215 | // } |
2162 | 2216 | ||
2217 | haveGroupInformation = true; | ||
2218 | gotCrossUpdate = false; | ||
2219 | crossingFlags = 0; | ||
2220 | |||
2163 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; | 2221 | m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; |
2164 | 2222 | ||
2165 | m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts)); | 2223 | m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts)); |
@@ -3114,6 +3172,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3114 | ResetMoveToTarget(); | 3172 | ResetMoveToTarget(); |
3115 | 3173 | ||
3116 | Velocity = Vector3.Zero; | 3174 | Velocity = Vector3.Zero; |
3175 | m_AngularVelocity = Vector3.Zero; | ||
3117 | 3176 | ||
3118 | part.AddSittingAvatar(this); | 3177 | part.AddSittingAvatar(this); |
3119 | 3178 | ||
@@ -3439,9 +3498,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3439 | part.AddSittingAvatar(this); | 3498 | part.AddSittingAvatar(this); |
3440 | ParentPart = part; | 3499 | ParentPart = part; |
3441 | ParentID = m_requestedSitTargetID; | 3500 | ParentID = m_requestedSitTargetID; |
3501 | |||
3502 | RemoveFromPhysicalScene(); | ||
3442 | m_AngularVelocity = Vector3.Zero; | 3503 | m_AngularVelocity = Vector3.Zero; |
3443 | Velocity = Vector3.Zero; | 3504 | Velocity = Vector3.Zero; |
3444 | RemoveFromPhysicalScene(); | ||
3445 | 3505 | ||
3446 | m_requestedSitTargetID = 0; | 3506 | m_requestedSitTargetID = 0; |
3447 | 3507 | ||
@@ -3464,13 +3524,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
3464 | return; | 3524 | return; |
3465 | 3525 | ||
3466 | // m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.. | 3526 | // m_updateCount = 0; // Kill animation update burst so that the SIT_G.. will stick.. |
3467 | m_AngularVelocity = Vector3.Zero; | ||
3468 | sitAnimation = "SIT_GROUND_CONSTRAINED"; | 3527 | sitAnimation = "SIT_GROUND_CONSTRAINED"; |
3469 | // Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); | 3528 | // Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED"); |
3470 | // TriggerScenePresenceUpdated(); | 3529 | // TriggerScenePresenceUpdated(); |
3471 | SitGround = true; | 3530 | SitGround = true; |
3472 | RemoveFromPhysicalScene(); | 3531 | RemoveFromPhysicalScene(); |
3473 | 3532 | ||
3533 | m_AngularVelocity = Vector3.Zero; | ||
3534 | Velocity = Vector3.Zero; | ||
3535 | |||
3474 | Animator.SetMovementAnimations("SITGROUND"); | 3536 | Animator.SetMovementAnimations("SITGROUND"); |
3475 | TriggerScenePresenceUpdated(); | 3537 | TriggerScenePresenceUpdated(); |
3476 | } | 3538 | } |
@@ -3758,6 +3820,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3758 | public void SendInitialDataToMe() | 3820 | public void SendInitialDataToMe() |
3759 | { | 3821 | { |
3760 | // Send all scene object to the new client | 3822 | // Send all scene object to the new client |
3823 | SentInitialData = true; | ||
3761 | Util.FireAndForget(delegate | 3824 | Util.FireAndForget(delegate |
3762 | { | 3825 | { |
3763 | // we created a new ScenePresence (a new child agent) in a fresh region. | 3826 | // we created a new ScenePresence (a new child agent) in a fresh region. |
@@ -3993,6 +4056,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3993 | if(IsDeleted || !ControllingClient.IsActive) | 4056 | if(IsDeleted || !ControllingClient.IsActive) |
3994 | return; | 4057 | return; |
3995 | 4058 | ||
4059 | if(!SentInitialData) | ||
4060 | { | ||
4061 | SendInitialDataToMe(); | ||
4062 | return; | ||
4063 | } | ||
4064 | |||
3996 | if(m_reprioritizationBusy) | 4065 | if(m_reprioritizationBusy) |
3997 | return; | 4066 | return; |
3998 | 4067 | ||
@@ -4142,19 +4211,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
4142 | { | 4211 | { |
4143 | // we don't have entity transfer module | 4212 | // we don't have entity transfer module |
4144 | Vector3 pos = AbsolutePosition; | 4213 | Vector3 pos = AbsolutePosition; |
4214 | vel = Velocity; | ||
4145 | float px = pos.X; | 4215 | float px = pos.X; |
4146 | if (px < 0) | 4216 | if (px < 0) |
4147 | pos.X += Velocity.X * 2; | 4217 | pos.X += vel.X * 2; |
4148 | else if (px > m_scene.RegionInfo.RegionSizeX) | 4218 | else if (px > m_scene.RegionInfo.RegionSizeX) |
4149 | pos.X -= Velocity.X * 2; | 4219 | pos.X -= vel.X * 2; |
4150 | 4220 | ||
4151 | float py = pos.Y; | 4221 | float py = pos.Y; |
4152 | if (py < 0) | 4222 | if (py < 0) |
4153 | pos.Y += Velocity.Y * 2; | 4223 | pos.Y += vel.Y * 2; |
4154 | else if (py > m_scene.RegionInfo.RegionSizeY) | 4224 | else if (py > m_scene.RegionInfo.RegionSizeY) |
4155 | pos.Y -= Velocity.Y * 2; | 4225 | pos.Y -= vel.Y * 2; |
4156 | 4226 | ||
4157 | Velocity = Vector3.Zero; | 4227 | Velocity = Vector3.Zero; |
4228 | m_AngularVelocity = Vector3.Zero; | ||
4158 | AbsolutePosition = pos; | 4229 | AbsolutePosition = pos; |
4159 | } | 4230 | } |
4160 | } | 4231 | } |
@@ -4167,19 +4238,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
4167 | RemoveFromPhysicalScene(); | 4238 | RemoveFromPhysicalScene(); |
4168 | 4239 | ||
4169 | Vector3 pos = AbsolutePosition; | 4240 | Vector3 pos = AbsolutePosition; |
4241 | Vector3 vel = Velocity; | ||
4170 | float px = pos.X; | 4242 | float px = pos.X; |
4171 | if (px < 0) | 4243 | if (px < 0) |
4172 | pos.X += Velocity.X * 2; | 4244 | pos.X += vel.X * 2; |
4173 | else if (px > m_scene.RegionInfo.RegionSizeX) | 4245 | else if (px > m_scene.RegionInfo.RegionSizeX) |
4174 | pos.X -= Velocity.X * 2; | 4246 | pos.X -= vel.X * 2; |
4175 | 4247 | ||
4176 | float py = pos.Y; | 4248 | float py = pos.Y; |
4177 | if (py < 0) | 4249 | if (py < 0) |
4178 | pos.Y += Velocity.Y * 2; | 4250 | pos.Y += vel.Y * 2; |
4179 | else if (py > m_scene.RegionInfo.RegionSizeY) | 4251 | else if (py > m_scene.RegionInfo.RegionSizeY) |
4180 | pos.Y -= Velocity.Y * 2; | 4252 | pos.Y -= vel.Y * 2; |
4181 | 4253 | ||
4182 | Velocity = Vector3.Zero; | 4254 | Velocity = Vector3.Zero; |
4255 | m_AngularVelocity = Vector3.Zero; | ||
4183 | AbsolutePosition = pos; | 4256 | AbsolutePosition = pos; |
4184 | 4257 | ||
4185 | AddToPhysicalScene(isFlying); | 4258 | AddToPhysicalScene(isFlying); |
@@ -4419,7 +4492,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4419 | checkRePrioritization(); | 4492 | checkRePrioritization(); |
4420 | } | 4493 | } |
4421 | 4494 | ||
4422 | public void CopyTo(AgentData cAgent) | 4495 | public void CopyTo(AgentData cAgent, bool isCrossUpdate) |
4423 | { | 4496 | { |
4424 | cAgent.CallbackURI = m_callbackURI; | 4497 | cAgent.CallbackURI = m_callbackURI; |
4425 | 4498 | ||
@@ -4483,6 +4556,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
4483 | 4556 | ||
4484 | if (Scene.AttachmentsModule != null) | 4557 | if (Scene.AttachmentsModule != null) |
4485 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); | 4558 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); |
4559 | |||
4560 | cAgent.CrossingFlags = isCrossUpdate ? crossingFlags : (byte)0; | ||
4561 | |||
4562 | if(isCrossUpdate && haveGroupInformation) | ||
4563 | { | ||
4564 | cAgent.agentCOF = COF; | ||
4565 | cAgent.ActiveGroupID = ControllingClient.ActiveGroupId; | ||
4566 | cAgent.ActiveGroupName = ControllingClient.ActiveGroupName; | ||
4567 | cAgent.ActiveGroupTitle = Grouptitle; | ||
4568 | Dictionary<UUID, ulong> gpowers = ControllingClient.GetGroupPowers(); | ||
4569 | if(gpowers.Count >0) | ||
4570 | { | ||
4571 | cAgent.Groups = new AgentGroupData[gpowers.Count]; | ||
4572 | int i = 0; | ||
4573 | foreach (UUID gid in gpowers.Keys) | ||
4574 | { | ||
4575 | // WARNING we dont' have AcceptNotices in cache.. sending as true mb no one notices ;) | ||
4576 | AgentGroupData agd = new AgentGroupData(gid,gpowers[gid],true); | ||
4577 | cAgent.Groups[i++] = agd; | ||
4578 | } | ||
4579 | } | ||
4580 | } | ||
4486 | } | 4581 | } |
4487 | 4582 | ||
4488 | private void CopyFrom(AgentData cAgent) | 4583 | private void CopyFrom(AgentData cAgent) |
@@ -4578,6 +4673,45 @@ namespace OpenSim.Region.Framework.Scenes | |||
4578 | if (Scene.AttachmentsModule != null) | 4673 | if (Scene.AttachmentsModule != null) |
4579 | Scene.AttachmentsModule.CopyAttachments(cAgent, this); | 4674 | Scene.AttachmentsModule.CopyAttachments(cAgent, this); |
4580 | 4675 | ||
4676 | haveGroupInformation = false; | ||
4677 | |||
4678 | // using this as protocol detection don't want to mess with the numbers for now | ||
4679 | if(cAgent.ActiveGroupTitle != null) | ||
4680 | { | ||
4681 | COF = cAgent.agentCOF; | ||
4682 | ControllingClient.ActiveGroupId = cAgent.ActiveGroupID; | ||
4683 | ControllingClient.ActiveGroupName = cAgent.ActiveGroupName; | ||
4684 | ControllingClient.ActiveGroupPowers = 0; | ||
4685 | Grouptitle = cAgent.ActiveGroupTitle; | ||
4686 | int ngroups = cAgent.Groups.Length; | ||
4687 | if(ngroups > 0) | ||
4688 | { | ||
4689 | Dictionary<UUID, ulong> gpowers = new Dictionary<UUID, ulong>(ngroups); | ||
4690 | for(int i = 0 ; i < ngroups; i++) | ||
4691 | { | ||
4692 | AgentGroupData agd = cAgent.Groups[i]; | ||
4693 | gpowers[agd.GroupID] = agd.GroupPowers; | ||
4694 | } | ||
4695 | |||
4696 | ControllingClient.SetGroupPowers(gpowers); | ||
4697 | |||
4698 | if(cAgent.ActiveGroupID == UUID.Zero) | ||
4699 | haveGroupInformation = true; | ||
4700 | else if(gpowers.ContainsKey(cAgent.ActiveGroupID)) | ||
4701 | { | ||
4702 | ControllingClient.ActiveGroupPowers = gpowers[cAgent.ActiveGroupID]; | ||
4703 | haveGroupInformation = true; | ||
4704 | } | ||
4705 | } | ||
4706 | else if(cAgent.ActiveGroupID == UUID.Zero) | ||
4707 | { | ||
4708 | haveGroupInformation = true; | ||
4709 | } | ||
4710 | } | ||
4711 | |||
4712 | crossingFlags = cAgent.CrossingFlags; | ||
4713 | gotCrossUpdate = (crossingFlags != 0); | ||
4714 | |||
4581 | lock (m_originRegionIDAccessLock) | 4715 | lock (m_originRegionIDAccessLock) |
4582 | m_originRegionID = cAgent.RegionID; | 4716 | m_originRegionID = cAgent.RegionID; |
4583 | } | 4717 | } |
@@ -4585,7 +4719,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4585 | public bool CopyAgent(out IAgentData agent) | 4719 | public bool CopyAgent(out IAgentData agent) |
4586 | { | 4720 | { |
4587 | agent = new CompleteAgentData(); | 4721 | agent = new CompleteAgentData(); |
4588 | CopyTo((AgentData)agent); | 4722 | CopyTo((AgentData)agent, false); |
4589 | return true; | 4723 | return true; |
4590 | } | 4724 | } |
4591 | 4725 | ||
@@ -4667,18 +4801,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
4667 | /// <param name="e"></param> | 4801 | /// <param name="e"></param> |
4668 | public void PhysicsCollisionUpdate(EventArgs e) | 4802 | public void PhysicsCollisionUpdate(EventArgs e) |
4669 | { | 4803 | { |
4670 | if (IsChildAgent || Animator == null) | 4804 | if (IsChildAgent) |
4671 | return; | 4805 | return; |
4672 | 4806 | ||
4673 | if(IsInTransit) | 4807 | if(IsInTransit) |
4674 | return; | 4808 | return; |
4809 | |||
4675 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) | 4810 | //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) |
4676 | // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( | 4811 | // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents( |
4677 | // as of this comment the interval is set in AddToPhysicalScene | 4812 | // as of this comment the interval is set in AddToPhysicalScene |
4678 | 4813 | ||
4679 | // if (m_updateCount > 0) | 4814 | // if (m_updateCount > 0) |
4680 | // { | 4815 | // { |
4681 | if (Animator.UpdateMovementAnimations()) | 4816 | if (Animator != null && Animator.UpdateMovementAnimations()) |
4682 | TriggerScenePresenceUpdated(); | 4817 | TriggerScenePresenceUpdated(); |
4683 | // m_updateCount--; | 4818 | // m_updateCount--; |
4684 | // } | 4819 | // } |
@@ -4686,7 +4821,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4686 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; | 4821 | CollisionEventUpdate collisionData = (CollisionEventUpdate)e; |
4687 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; | 4822 | Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; |
4688 | 4823 | ||
4689 | |||
4690 | // // No collisions at all means we may be flying. Update always | 4824 | // // No collisions at all means we may be flying. Update always |
4691 | // // to make falling work | 4825 | // // to make falling work |
4692 | // if (m_lastColCount != coldata.Count || coldata.Count == 0) | 4826 | // if (m_lastColCount != coldata.Count || coldata.Count == 0) |
@@ -4697,42 +4831,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
4697 | 4831 | ||
4698 | if (coldata.Count != 0) | 4832 | if (coldata.Count != 0) |
4699 | { | 4833 | { |
4700 | /* | 4834 | ContactPoint lowest; |
4701 | switch (Animator.CurrentMovementAnimation) | 4835 | lowest.SurfaceNormal = Vector3.Zero; |
4702 | { | 4836 | lowest.Position = Vector3.Zero; |
4703 | case "STAND": | 4837 | lowest.Position.Z = float.MaxValue; |
4704 | case "WALK": | ||
4705 | case "RUN": | ||
4706 | case "CROUCH": | ||
4707 | case "CROUCHWALK": | ||
4708 | { | ||
4709 | */ | ||
4710 | ContactPoint lowest; | ||
4711 | lowest.SurfaceNormal = Vector3.Zero; | ||
4712 | lowest.Position = Vector3.Zero; | ||
4713 | lowest.Position.Z = float.MaxValue; | ||
4714 | 4838 | ||
4715 | foreach (ContactPoint contact in coldata.Values) | 4839 | foreach (ContactPoint contact in coldata.Values) |
4716 | { | 4840 | { |
4717 | 4841 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | |
4718 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | 4842 | lowest = contact; |
4719 | { | 4843 | } |
4720 | lowest = contact; | ||
4721 | } | ||
4722 | } | ||
4723 | 4844 | ||
4724 | if (lowest.Position.Z != float.MaxValue) | 4845 | if (lowest.Position.Z != float.MaxValue) |
4725 | { | 4846 | { |
4726 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | 4847 | lowest.SurfaceNormal = -lowest.SurfaceNormal; |
4727 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | 4848 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); |
4728 | } | ||
4729 | else | ||
4730 | CollisionPlane = Vector4.UnitW; | ||
4731 | /* | ||
4732 | } | ||
4733 | break; | ||
4734 | } | 4849 | } |
4735 | */ | 4850 | else |
4851 | CollisionPlane = Vector4.UnitW; | ||
4736 | } | 4852 | } |
4737 | else | 4853 | else |
4738 | CollisionPlane = Vector4.UnitW; | 4854 | CollisionPlane = Vector4.UnitW; |
@@ -4745,73 +4861,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4745 | 4861 | ||
4746 | // The following may be better in the ICombatModule | 4862 | // The following may be better in the ICombatModule |
4747 | // probably tweaking of the values for ground and normal prim collisions will be needed | 4863 | // probably tweaking of the values for ground and normal prim collisions will be needed |
4748 | float starthealth = Health; | 4864 | float startHealth = Health; |
4749 | uint killerObj = 0; | 4865 | if(coldata.Count > 0) |
4750 | SceneObjectPart part = null; | ||
4751 | foreach (uint localid in coldata.Keys) | ||
4752 | { | 4866 | { |
4753 | if (localid == 0) | 4867 | uint killerObj = 0; |
4754 | { | 4868 | SceneObjectPart part = null; |
4755 | part = null; | 4869 | float rvel; // relative velocity, negative on approch |
4756 | } | 4870 | foreach (uint localid in coldata.Keys) |
4757 | else | ||
4758 | { | 4871 | { |
4759 | part = Scene.GetSceneObjectPart(localid); | 4872 | if (localid == 0) |
4760 | } | 4873 | { |
4761 | if (part != null) | 4874 | // 0 is the ground |
4762 | { | 4875 | rvel = coldata[0].RelativeSpeed; |
4763 | // Ignore if it has been deleted or volume detect | 4876 | if(rvel < -5.0f) |
4764 | if (!part.ParentGroup.IsDeleted && !part.ParentGroup.IsVolumeDetect) | 4877 | Health -= 0.01f * rvel * rvel; |
4878 | } | ||
4879 | else | ||
4765 | { | 4880 | { |
4766 | if (part.ParentGroup.Damage > 0.0f) | 4881 | part = Scene.GetSceneObjectPart(localid); |
4882 | |||
4883 | if(part != null && !part.ParentGroup.IsVolumeDetect) | ||
4767 | { | 4884 | { |
4768 | // Something with damage... | 4885 | if (part.ParentGroup.Damage > 0.0f) |
4769 | Health -= part.ParentGroup.Damage; | 4886 | { |
4770 | part.ParentGroup.Scene.DeleteSceneObject(part.ParentGroup, false); | 4887 | // Something with damage... |
4888 | Health -= part.ParentGroup.Damage; | ||
4889 | part.ParentGroup.Scene.DeleteSceneObject(part.ParentGroup, false); | ||
4890 | } | ||
4891 | else | ||
4892 | { | ||
4893 | // An ordinary prim | ||
4894 | rvel = coldata[localid].RelativeSpeed; | ||
4895 | if(rvel < -5.0f) | ||
4896 | { | ||
4897 | Health -= 0.005f * rvel * rvel; | ||
4898 | } | ||
4899 | } | ||
4771 | } | 4900 | } |
4772 | else | 4901 | else |
4773 | { | 4902 | { |
4774 | // An ordinary prim | 4903 | |
4775 | if (coldata[localid].PenetrationDepth >= 0.10f) | ||
4776 | Health -= coldata[localid].PenetrationDepth * 5.0f; | ||
4777 | } | 4904 | } |
4778 | } | 4905 | } |
4779 | } | ||
4780 | else | ||
4781 | { | ||
4782 | // 0 is the ground | ||
4783 | // what about collisions with other avatars? | ||
4784 | if (localid == 0 && coldata[localid].PenetrationDepth >= 0.10f) | ||
4785 | Health -= coldata[localid].PenetrationDepth * 5.0f; | ||
4786 | } | ||
4787 | |||
4788 | 4906 | ||
4789 | if (Health <= 0.0f) | 4907 | if (Health <= 0.0f) |
4790 | { | 4908 | { |
4791 | if (localid != 0) | 4909 | if (localid != 0) |
4792 | killerObj = localid; | 4910 | killerObj = localid; |
4793 | } | 4911 | } |
4794 | //m_log.Debug("[AVATAR]: Collision with localid: " + localid.ToString() + " at depth: " + coldata[localid].ToString()); | ||
4795 | } | ||
4796 | //Health = 100; | ||
4797 | if (!Invulnerable) | ||
4798 | { | ||
4799 | if (starthealth != Health) | ||
4800 | { | ||
4801 | ControllingClient.SendHealth(Health); | ||
4802 | } | 4912 | } |
4913 | |||
4803 | if (Health <= 0) | 4914 | if (Health <= 0) |
4804 | { | 4915 | { |
4805 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); | ||
4806 | } | ||
4807 | if (starthealth == Health && Health < 100.0f) | ||
4808 | { | ||
4809 | Health += 0.03f; | ||
4810 | if (Health > 100.0f) | ||
4811 | Health = 100.0f; | ||
4812 | ControllingClient.SendHealth(Health); | 4916 | ControllingClient.SendHealth(Health); |
4917 | m_scene.EventManager.TriggerAvatarKill(killerObj, this); | ||
4918 | return; | ||
4813 | } | 4919 | } |
4814 | } | 4920 | } |
4921 | |||
4922 | if(Math.Abs(Health - startHealth) > 1.0) | ||
4923 | ControllingClient.SendHealth(Health); | ||
4815 | } | 4924 | } |
4816 | 4925 | ||
4817 | public void setHealthWithUpdate(float health) | 4926 | public void setHealthWithUpdate(float health) |