aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
authorUbitUmarov2016-07-25 00:51:37 +0100
committerUbitUmarov2016-07-25 00:51:37 +0100
commit76239602b48d660b8735d9f2a07ec01aa08584ee (patch)
treeb20fa0d235ec963349f698014d778c570050616d /OpenSim/Region/Framework/Scenes/ScenePresence.cs
parentpreserve max relative velocity on a colision report time slice (diff)
downloadopensim-SC_OLD-76239602b48d660b8735d9f2a07ec01aa08584ee.zip
opensim-SC_OLD-76239602b48d660b8735d9f2a07ec01aa08584ee.tar.gz
opensim-SC_OLD-76239602b48d660b8735d9f2a07ec01aa08584ee.tar.bz2
opensim-SC_OLD-76239602b48d660b8735d9f2a07ec01aa08584ee.tar.xz
change avatar Health, from bad penetration depth to relative velocity
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs180
1 files changed, 89 insertions, 91 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index f20d065..8618a66 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
@@ -1073,6 +1074,8 @@ namespace OpenSim.Region.Framework.Scenes
1073 1074
1074 } 1075 }
1075 1076
1077 private float lastHealthSent = 0;
1078
1076 private void RegionHeartbeatEnd(Scene scene) 1079 private void RegionHeartbeatEnd(Scene scene)
1077 { 1080 {
1078 if (IsChildAgent) 1081 if (IsChildAgent)
@@ -1095,7 +1098,24 @@ namespace OpenSim.Region.Framework.Scenes
1095 } 1098 }
1096 else 1099 else
1097 { 1100 {
1098 m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd; 1101// m_scene.EventManager.OnRegionHeartbeatEnd -= RegionHeartbeatEnd;
1102 }
1103 }
1104
1105 if(Health != 100.0f)
1106 {
1107 float last = Health;
1108 Health += 0.05f;
1109 if(Health > 100.0f)
1110 {
1111 Health = 100.0f;
1112 lastHealthSent = Health;
1113 ControllingClient.SendHealth(Health);
1114 }
1115 else if(Math.Abs(Health - lastHealthSent) > 1.0)
1116 {
1117 lastHealthSent = Health;
1118 ControllingClient.SendHealth(Health);
1099 } 1119 }
1100 } 1120 }
1101 } 1121 }
@@ -3758,6 +3778,7 @@ namespace OpenSim.Region.Framework.Scenes
3758 public void SendInitialDataToMe() 3778 public void SendInitialDataToMe()
3759 { 3779 {
3760 // Send all scene object to the new client 3780 // Send all scene object to the new client
3781 SentInitialData = true;
3761 Util.FireAndForget(delegate 3782 Util.FireAndForget(delegate
3762 { 3783 {
3763 // we created a new ScenePresence (a new child agent) in a fresh region. 3784 // we created a new ScenePresence (a new child agent) in a fresh region.
@@ -3993,6 +4014,12 @@ namespace OpenSim.Region.Framework.Scenes
3993 if(IsDeleted || !ControllingClient.IsActive) 4014 if(IsDeleted || !ControllingClient.IsActive)
3994 return; 4015 return;
3995 4016
4017 if(!SentInitialData)
4018 {
4019 SendInitialDataToMe();
4020 return;
4021 }
4022
3996 if(m_reprioritizationBusy) 4023 if(m_reprioritizationBusy)
3997 return; 4024 return;
3998 4025
@@ -4667,18 +4694,19 @@ namespace OpenSim.Region.Framework.Scenes
4667 /// <param name="e"></param> 4694 /// <param name="e"></param>
4668 public void PhysicsCollisionUpdate(EventArgs e) 4695 public void PhysicsCollisionUpdate(EventArgs e)
4669 { 4696 {
4670 if (IsChildAgent || Animator == null) 4697 if (IsChildAgent)
4671 return; 4698 return;
4672 4699
4673 if(IsInTransit) 4700 if(IsInTransit)
4674 return; 4701 return;
4702
4675 //if ((Math.Abs(Velocity.X) > 0.1e-9f) || (Math.Abs(Velocity.Y) > 0.1e-9f)) 4703 //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( 4704 // The Physics Scene will send updates every 500 ms grep: PhysicsActor.SubscribeEvents(
4677 // as of this comment the interval is set in AddToPhysicalScene 4705 // as of this comment the interval is set in AddToPhysicalScene
4678 4706
4679// if (m_updateCount > 0) 4707// if (m_updateCount > 0)
4680// { 4708// {
4681 if (Animator.UpdateMovementAnimations()) 4709 if (Animator != null && Animator.UpdateMovementAnimations())
4682 TriggerScenePresenceUpdated(); 4710 TriggerScenePresenceUpdated();
4683// m_updateCount--; 4711// m_updateCount--;
4684// } 4712// }
@@ -4686,7 +4714,6 @@ namespace OpenSim.Region.Framework.Scenes
4686 CollisionEventUpdate collisionData = (CollisionEventUpdate)e; 4714 CollisionEventUpdate collisionData = (CollisionEventUpdate)e;
4687 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList; 4715 Dictionary<uint, ContactPoint> coldata = collisionData.m_objCollisionList;
4688 4716
4689
4690// // No collisions at all means we may be flying. Update always 4717// // No collisions at all means we may be flying. Update always
4691// // to make falling work 4718// // to make falling work
4692// if (m_lastColCount != coldata.Count || coldata.Count == 0) 4719// if (m_lastColCount != coldata.Count || coldata.Count == 0)
@@ -4697,42 +4724,24 @@ namespace OpenSim.Region.Framework.Scenes
4697 4724
4698 if (coldata.Count != 0) 4725 if (coldata.Count != 0)
4699 { 4726 {
4700/* 4727 ContactPoint lowest;
4701 switch (Animator.CurrentMovementAnimation) 4728 lowest.SurfaceNormal = Vector3.Zero;
4702 { 4729 lowest.Position = Vector3.Zero;
4703 case "STAND": 4730 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 4731
4715 foreach (ContactPoint contact in coldata.Values) 4732 foreach (ContactPoint contact in coldata.Values)
4716 { 4733 {
4717 4734 if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z)
4718 if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) 4735 lowest = contact;
4719 { 4736 }
4720 lowest = contact;
4721 }
4722 }
4723 4737
4724 if (lowest.Position.Z != float.MaxValue) 4738 if (lowest.Position.Z != float.MaxValue)
4725 { 4739 {
4726 lowest.SurfaceNormal = -lowest.SurfaceNormal; 4740 lowest.SurfaceNormal = -lowest.SurfaceNormal;
4727 CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); 4741 CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal));
4728 }
4729 else
4730 CollisionPlane = Vector4.UnitW;
4731/*
4732 }
4733 break;
4734 } 4742 }
4735*/ 4743 else
4744 CollisionPlane = Vector4.UnitW;
4736 } 4745 }
4737 else 4746 else
4738 CollisionPlane = Vector4.UnitW; 4747 CollisionPlane = Vector4.UnitW;
@@ -4745,73 +4754,62 @@ namespace OpenSim.Region.Framework.Scenes
4745 4754
4746 // The following may be better in the ICombatModule 4755 // The following may be better in the ICombatModule
4747 // probably tweaking of the values for ground and normal prim collisions will be needed 4756 // probably tweaking of the values for ground and normal prim collisions will be needed
4748 float starthealth = Health; 4757 float startHealth = Health;
4749 uint killerObj = 0; 4758 if(coldata.Count > 0)
4750 SceneObjectPart part = null;
4751 foreach (uint localid in coldata.Keys)
4752 { 4759 {
4753 if (localid == 0) 4760 uint killerObj = 0;
4761 SceneObjectPart part = null;
4762 float rvel; // relative velocity, negative on approch
4763 foreach (uint localid in coldata.Keys)
4754 { 4764 {
4755 part = null; 4765 if (localid == 0)
4756 }
4757 else
4758 {
4759 part = Scene.GetSceneObjectPart(localid);
4760 }
4761 if (part != null)
4762 {
4763 // Ignore if it has been deleted or volume detect
4764 if (!part.ParentGroup.IsDeleted && !part.ParentGroup.IsVolumeDetect)
4765 { 4766 {
4766 if (part.ParentGroup.Damage > 0.0f) 4767 // 0 is the ground
4767 { 4768 rvel = coldata[0].RelativeSpeed;
4768 // Something with damage... 4769 if(rvel < -5.0f)
4769 Health -= part.ParentGroup.Damage; 4770 Health -= 0.01f * rvel * rvel;
4770 part.ParentGroup.Scene.DeleteSceneObject(part.ParentGroup, false); 4771 }
4771 } 4772 else
4772 else 4773 {
4774 part = Scene.GetSceneObjectPart(localid);
4775
4776 if(part != null && !part.ParentGroup.IsDeleted && !part.ParentGroup.IsVolumeDetect)
4773 { 4777 {
4774 // An ordinary prim 4778 if (part.ParentGroup.Damage > 0.0f)
4775 if (coldata[localid].PenetrationDepth >= 0.10f) 4779 {
4776 Health -= coldata[localid].PenetrationDepth * 5.0f; 4780 // Something with damage...
4781 Health -= part.ParentGroup.Damage;
4782 part.ParentGroup.Scene.DeleteSceneObject(part.ParentGroup, false);
4783 }
4784 else
4785 {
4786 // An ordinary prim
4787 rvel = coldata[localid].RelativeSpeed;
4788 if(rvel < -5.0f)
4789 {
4790 Health -= 0.005f * rvel * rvel;;
4791 }
4792 }
4777 } 4793 }
4778 } 4794 }
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 4795
4789 if (Health <= 0.0f) 4796 if (Health <= 0.0f)
4790 { 4797 {
4791 if (localid != 0) 4798 if (localid != 0)
4792 killerObj = localid; 4799 killerObj = localid;
4793 } 4800 }
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 } 4801 }
4802
4803 if (Health <= 0) 4803 if (Health <= 0)
4804 { 4804 {
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); 4805 ControllingClient.SendHealth(Health);
4806 m_scene.EventManager.TriggerAvatarKill(killerObj, this);
4807 return;
4813 } 4808 }
4814 } 4809 }
4810
4811 if(Math.Abs(Health - startHealth) > 1.0)
4812 ControllingClient.SendHealth(Health);
4815 } 4813 }
4816 4814
4817 public void setHealthWithUpdate(float health) 4815 public void setHealthWithUpdate(float health)