diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 156 |
1 files changed, 147 insertions, 9 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index cf98ef2..8ff17f6 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -936,8 +936,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
936 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 936 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
937 | ControllingClient.OnStartAnim += HandleStartAnim; | 937 | ControllingClient.OnStartAnim += HandleStartAnim; |
938 | ControllingClient.OnStopAnim += HandleStopAnim; | 938 | ControllingClient.OnStopAnim += HandleStopAnim; |
939 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
939 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 940 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
940 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 941 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
942 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
941 | 943 | ||
942 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 944 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
943 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 945 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -1553,9 +1555,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1553 | 1555 | ||
1554 | public void SetSize(Vector3 size, float feetoffset) | 1556 | public void SetSize(Vector3 size, float feetoffset) |
1555 | { | 1557 | { |
1556 | // TODO: Merge the physics bits | 1558 | if (PhysicsActor != null && !IsChildAgent) |
1557 | // if (PhysicsActor != null && !IsChildAgent) | 1559 | PhysicsActor.setAvatarSize(size, feetoffset); |
1558 | // PhysicsActor.setAvatarSize(size, feetoffset); | ||
1559 | 1560 | ||
1560 | } | 1561 | } |
1561 | 1562 | ||
@@ -2705,9 +2706,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2705 | // returns false if does not suport so older sit can be tried | 2706 | // returns false if does not suport so older sit can be tried |
2706 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) | 2707 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) |
2707 | { | 2708 | { |
2708 | // TODO: Pull in these bits | ||
2709 | return false; | ||
2710 | /* | ||
2711 | if (part == null || part.ParentGroup.IsAttachment) | 2709 | if (part == null || part.ParentGroup.IsAttachment) |
2712 | { | 2710 | { |
2713 | return true; | 2711 | return true; |
@@ -2737,7 +2735,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2737 | return true; | 2735 | return true; |
2738 | 2736 | ||
2739 | return false; | 2737 | return false; |
2740 | */ | ||
2741 | } | 2738 | } |
2742 | 2739 | ||
2743 | 2740 | ||
@@ -2952,6 +2949,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2952 | TriggerScenePresenceUpdated(); | 2949 | TriggerScenePresenceUpdated(); |
2953 | } | 2950 | } |
2954 | 2951 | ||
2952 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2953 | { | ||
2954 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2955 | } | ||
2956 | |||
2957 | |||
2958 | |||
2955 | /// <summary> | 2959 | /// <summary> |
2956 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2960 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2957 | /// </summary> | 2961 | /// </summary> |
@@ -3684,6 +3688,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3684 | 3688 | ||
3685 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3689 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3686 | 3690 | ||
3691 | private void RaiseUpdateThrottles() | ||
3692 | { | ||
3693 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
3694 | } | ||
3695 | |||
3687 | /// <summary> | 3696 | /// <summary> |
3688 | /// This updates important decision making data about a child agent | 3697 | /// This updates important decision making data about a child agent |
3689 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3698 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3930,7 +3939,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3930 | 3939 | ||
3931 | PhysicsActor = scene.AddAvatar( | 3940 | PhysicsActor = scene.AddAvatar( |
3932 | LocalId, Firstname + "." + Lastname, pVec, | 3941 | LocalId, Firstname + "." + Lastname, pVec, |
3933 | Appearance.AvatarBoxSize, isFlying); | 3942 | Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); |
3934 | 3943 | ||
3935 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3944 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3936 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3945 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
@@ -3989,7 +3998,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
3989 | // m_lastColCount = coldata.Count; | 3998 | // m_lastColCount = coldata.Count; |
3990 | // } | 3999 | // } |
3991 | 4000 | ||
3992 | CollisionPlane = Vector4.UnitW; | 4001 | if (coldata.Count != 0) |
4002 | { | ||
4003 | /* | ||
4004 | switch (Animator.CurrentMovementAnimation) | ||
4005 | { | ||
4006 | case "STAND": | ||
4007 | case "WALK": | ||
4008 | case "RUN": | ||
4009 | case "CROUCH": | ||
4010 | case "CROUCHWALK": | ||
4011 | { | ||
4012 | */ | ||
4013 | ContactPoint lowest; | ||
4014 | lowest.SurfaceNormal = Vector3.Zero; | ||
4015 | lowest.Position = Vector3.Zero; | ||
4016 | lowest.Position.Z = float.MaxValue; | ||
4017 | |||
4018 | foreach (ContactPoint contact in coldata.Values) | ||
4019 | { | ||
4020 | |||
4021 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | ||
4022 | { | ||
4023 | lowest = contact; | ||
4024 | } | ||
4025 | } | ||
4026 | |||
4027 | if (lowest.Position.Z != float.MaxValue) | ||
4028 | { | ||
4029 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | ||
4030 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
4031 | } | ||
4032 | else | ||
4033 | CollisionPlane = Vector4.UnitW; | ||
4034 | /* | ||
4035 | } | ||
4036 | break; | ||
4037 | } | ||
4038 | */ | ||
4039 | } | ||
4040 | else | ||
4041 | CollisionPlane = Vector4.UnitW; | ||
4042 | |||
4043 | RaiseCollisionScriptEvents(coldata); | ||
3993 | 4044 | ||
3994 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 4045 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
3995 | if (Invulnerable || GodLevel > 0) | 4046 | if (Invulnerable || GodLevel > 0) |
@@ -4891,6 +4942,93 @@ namespace OpenSim.Region.Framework.Scenes | |||
4891 | } | 4942 | } |
4892 | } | 4943 | } |
4893 | 4944 | ||
4945 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4946 | { | ||
4947 | try | ||
4948 | { | ||
4949 | List<uint> thisHitColliders = new List<uint>(); | ||
4950 | List<uint> endedColliders = new List<uint>(); | ||
4951 | List<uint> startedColliders = new List<uint>(); | ||
4952 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4953 | CollisionForSoundInfo soundinfo; | ||
4954 | ContactPoint curcontact; | ||
4955 | |||
4956 | if (coldata.Count == 0) | ||
4957 | { | ||
4958 | if (m_lastColliders.Count == 0) | ||
4959 | return; // nothing to do | ||
4960 | |||
4961 | foreach (uint localID in m_lastColliders) | ||
4962 | { | ||
4963 | endedColliders.Add(localID); | ||
4964 | } | ||
4965 | m_lastColliders.Clear(); | ||
4966 | } | ||
4967 | |||
4968 | else | ||
4969 | { | ||
4970 | foreach (uint id in coldata.Keys) | ||
4971 | { | ||
4972 | thisHitColliders.Add(id); | ||
4973 | if (!m_lastColliders.Contains(id)) | ||
4974 | { | ||
4975 | startedColliders.Add(id); | ||
4976 | curcontact = coldata[id]; | ||
4977 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
4978 | { | ||
4979 | soundinfo = new CollisionForSoundInfo(); | ||
4980 | soundinfo.colliderID = id; | ||
4981 | soundinfo.position = curcontact.Position; | ||
4982 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
4983 | soundinfolist.Add(soundinfo); | ||
4984 | } | ||
4985 | } | ||
4986 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
4987 | } | ||
4988 | |||
4989 | // calculate things that ended colliding | ||
4990 | foreach (uint localID in m_lastColliders) | ||
4991 | { | ||
4992 | if (!thisHitColliders.Contains(localID)) | ||
4993 | { | ||
4994 | endedColliders.Add(localID); | ||
4995 | } | ||
4996 | } | ||
4997 | //add the items that started colliding this time to the last colliders list. | ||
4998 | foreach (uint localID in startedColliders) | ||
4999 | { | ||
5000 | m_lastColliders.Add(localID); | ||
5001 | } | ||
5002 | // remove things that ended colliding from the last colliders list | ||
5003 | foreach (uint localID in endedColliders) | ||
5004 | { | ||
5005 | m_lastColliders.Remove(localID); | ||
5006 | } | ||
5007 | |||
5008 | if (soundinfolist.Count > 0) | ||
5009 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
5010 | } | ||
5011 | |||
5012 | foreach (SceneObjectGroup att in GetAttachments()) | ||
5013 | { | ||
5014 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
5015 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
5016 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
5017 | |||
5018 | if (startedColliders.Contains(0)) | ||
5019 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
5020 | if (m_lastColliders.Contains(0)) | ||
5021 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
5022 | if (endedColliders.Contains(0)) | ||
5023 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
5024 | } | ||
5025 | } | ||
5026 | finally | ||
5027 | { | ||
5028 | m_collisionEventFlag = false; | ||
5029 | } | ||
5030 | } | ||
5031 | |||
4894 | private void TeleportFlagsDebug() { | 5032 | private void TeleportFlagsDebug() { |
4895 | 5033 | ||
4896 | // Some temporary debugging help to show all the TeleportFlags we have... | 5034 | // Some temporary debugging help to show all the TeleportFlags we have... |