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 84201cc..f57d4fe 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -946,8 +946,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
946 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; | 946 | ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; |
947 | ControllingClient.OnStartAnim += HandleStartAnim; | 947 | ControllingClient.OnStartAnim += HandleStartAnim; |
948 | ControllingClient.OnStopAnim += HandleStopAnim; | 948 | ControllingClient.OnStopAnim += HandleStopAnim; |
949 | ControllingClient.OnChangeAnim += avnHandleChangeAnim; | ||
949 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; | 950 | ControllingClient.OnForceReleaseControls += HandleForceReleaseControls; |
950 | ControllingClient.OnAutoPilotGo += MoveToTarget; | 951 | ControllingClient.OnAutoPilotGo += MoveToTarget; |
952 | ControllingClient.OnUpdateThrottles += RaiseUpdateThrottles; | ||
951 | 953 | ||
952 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); | 954 | // ControllingClient.OnChildAgentStatus += new StatusChange(this.ChildStatusChange); |
953 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); | 955 | // ControllingClient.OnStopMovement += new GenericCall2(this.StopMovement); |
@@ -1582,9 +1584,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1582 | 1584 | ||
1583 | public void SetSize(Vector3 size, float feetoffset) | 1585 | public void SetSize(Vector3 size, float feetoffset) |
1584 | { | 1586 | { |
1585 | // TODO: Merge the physics bits | 1587 | if (PhysicsActor != null && !IsChildAgent) |
1586 | // if (PhysicsActor != null && !IsChildAgent) | 1588 | PhysicsActor.setAvatarSize(size, feetoffset); |
1587 | // PhysicsActor.setAvatarSize(size, feetoffset); | ||
1588 | 1589 | ||
1589 | } | 1590 | } |
1590 | 1591 | ||
@@ -2743,9 +2744,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2743 | // returns false if does not suport so older sit can be tried | 2744 | // returns false if does not suport so older sit can be tried |
2744 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) | 2745 | public bool PhysicsSit(SceneObjectPart part, Vector3 offset) |
2745 | { | 2746 | { |
2746 | // TODO: Pull in these bits | ||
2747 | return false; | ||
2748 | /* | ||
2749 | if (part == null || part.ParentGroup.IsAttachment) | 2747 | if (part == null || part.ParentGroup.IsAttachment) |
2750 | { | 2748 | { |
2751 | return true; | 2749 | return true; |
@@ -2775,7 +2773,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2775 | return true; | 2773 | return true; |
2776 | 2774 | ||
2777 | return false; | 2775 | return false; |
2778 | */ | ||
2779 | } | 2776 | } |
2780 | 2777 | ||
2781 | 2778 | ||
@@ -2989,6 +2986,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2989 | TriggerScenePresenceUpdated(); | 2986 | TriggerScenePresenceUpdated(); |
2990 | } | 2987 | } |
2991 | 2988 | ||
2989 | public void avnHandleChangeAnim(UUID animID, bool addRemove,bool sendPack) | ||
2990 | { | ||
2991 | Animator.avnChangeAnim(animID, addRemove, sendPack); | ||
2992 | } | ||
2993 | |||
2994 | |||
2995 | |||
2992 | /// <summary> | 2996 | /// <summary> |
2993 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector | 2997 | /// Rotate the avatar to the given rotation and apply a movement in the given relative vector |
2994 | /// </summary> | 2998 | /// </summary> |
@@ -3723,6 +3727,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3723 | 3727 | ||
3724 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); | 3728 | private static Vector3 marker = new Vector3(-1f, -1f, -1f); |
3725 | 3729 | ||
3730 | private void RaiseUpdateThrottles() | ||
3731 | { | ||
3732 | m_scene.EventManager.TriggerThrottleUpdate(this); | ||
3733 | } | ||
3734 | |||
3726 | /// <summary> | 3735 | /// <summary> |
3727 | /// This updates important decision making data about a child agent | 3736 | /// This updates important decision making data about a child agent |
3728 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region | 3737 | /// The main purpose is to figure out what objects to send to a child agent that's in a neighboring region |
@@ -3969,7 +3978,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3969 | 3978 | ||
3970 | PhysicsActor = scene.AddAvatar( | 3979 | PhysicsActor = scene.AddAvatar( |
3971 | LocalId, Firstname + "." + Lastname, pVec, | 3980 | LocalId, Firstname + "." + Lastname, pVec, |
3972 | Appearance.AvatarBoxSize, isFlying); | 3981 | Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); |
3973 | 3982 | ||
3974 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; | 3983 | //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; |
3975 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; | 3984 | PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; |
@@ -4028,7 +4037,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
4028 | // m_lastColCount = coldata.Count; | 4037 | // m_lastColCount = coldata.Count; |
4029 | // } | 4038 | // } |
4030 | 4039 | ||
4031 | CollisionPlane = Vector4.UnitW; | 4040 | if (coldata.Count != 0) |
4041 | { | ||
4042 | /* | ||
4043 | switch (Animator.CurrentMovementAnimation) | ||
4044 | { | ||
4045 | case "STAND": | ||
4046 | case "WALK": | ||
4047 | case "RUN": | ||
4048 | case "CROUCH": | ||
4049 | case "CROUCHWALK": | ||
4050 | { | ||
4051 | */ | ||
4052 | ContactPoint lowest; | ||
4053 | lowest.SurfaceNormal = Vector3.Zero; | ||
4054 | lowest.Position = Vector3.Zero; | ||
4055 | lowest.Position.Z = float.MaxValue; | ||
4056 | |||
4057 | foreach (ContactPoint contact in coldata.Values) | ||
4058 | { | ||
4059 | |||
4060 | if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) | ||
4061 | { | ||
4062 | lowest = contact; | ||
4063 | } | ||
4064 | } | ||
4065 | |||
4066 | if (lowest.Position.Z != float.MaxValue) | ||
4067 | { | ||
4068 | lowest.SurfaceNormal = -lowest.SurfaceNormal; | ||
4069 | CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); | ||
4070 | } | ||
4071 | else | ||
4072 | CollisionPlane = Vector4.UnitW; | ||
4073 | /* | ||
4074 | } | ||
4075 | break; | ||
4076 | } | ||
4077 | */ | ||
4078 | } | ||
4079 | else | ||
4080 | CollisionPlane = Vector4.UnitW; | ||
4081 | |||
4082 | RaiseCollisionScriptEvents(coldata); | ||
4032 | 4083 | ||
4033 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags | 4084 | // Gods do not take damage and Invulnerable is set depending on parcel/region flags |
4034 | if (Invulnerable || GodLevel > 0) | 4085 | if (Invulnerable || GodLevel > 0) |
@@ -4930,6 +4981,93 @@ namespace OpenSim.Region.Framework.Scenes | |||
4930 | } | 4981 | } |
4931 | } | 4982 | } |
4932 | 4983 | ||
4984 | private void RaiseCollisionScriptEvents(Dictionary<uint, ContactPoint> coldata) | ||
4985 | { | ||
4986 | try | ||
4987 | { | ||
4988 | List<uint> thisHitColliders = new List<uint>(); | ||
4989 | List<uint> endedColliders = new List<uint>(); | ||
4990 | List<uint> startedColliders = new List<uint>(); | ||
4991 | List<CollisionForSoundInfo> soundinfolist = new List<CollisionForSoundInfo>(); | ||
4992 | CollisionForSoundInfo soundinfo; | ||
4993 | ContactPoint curcontact; | ||
4994 | |||
4995 | if (coldata.Count == 0) | ||
4996 | { | ||
4997 | if (m_lastColliders.Count == 0) | ||
4998 | return; // nothing to do | ||
4999 | |||
5000 | foreach (uint localID in m_lastColliders) | ||
5001 | { | ||
5002 | endedColliders.Add(localID); | ||
5003 | } | ||
5004 | m_lastColliders.Clear(); | ||
5005 | } | ||
5006 | |||
5007 | else | ||
5008 | { | ||
5009 | foreach (uint id in coldata.Keys) | ||
5010 | { | ||
5011 | thisHitColliders.Add(id); | ||
5012 | if (!m_lastColliders.Contains(id)) | ||
5013 | { | ||
5014 | startedColliders.Add(id); | ||
5015 | curcontact = coldata[id]; | ||
5016 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
5017 | { | ||
5018 | soundinfo = new CollisionForSoundInfo(); | ||
5019 | soundinfo.colliderID = id; | ||
5020 | soundinfo.position = curcontact.Position; | ||
5021 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
5022 | soundinfolist.Add(soundinfo); | ||
5023 | } | ||
5024 | } | ||
5025 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
5026 | } | ||
5027 | |||
5028 | // calculate things that ended colliding | ||
5029 | foreach (uint localID in m_lastColliders) | ||
5030 | { | ||
5031 | if (!thisHitColliders.Contains(localID)) | ||
5032 | { | ||
5033 | endedColliders.Add(localID); | ||
5034 | } | ||
5035 | } | ||
5036 | //add the items that started colliding this time to the last colliders list. | ||
5037 | foreach (uint localID in startedColliders) | ||
5038 | { | ||
5039 | m_lastColliders.Add(localID); | ||
5040 | } | ||
5041 | // remove things that ended colliding from the last colliders list | ||
5042 | foreach (uint localID in endedColliders) | ||
5043 | { | ||
5044 | m_lastColliders.Remove(localID); | ||
5045 | } | ||
5046 | |||
5047 | if (soundinfolist.Count > 0) | ||
5048 | CollisionSounds.AvatarCollisionSound(this, soundinfolist); | ||
5049 | } | ||
5050 | |||
5051 | foreach (SceneObjectGroup att in GetAttachments()) | ||
5052 | { | ||
5053 | SendCollisionEvent(att, scriptEvents.collision_start, startedColliders, m_scene.EventManager.TriggerScriptCollidingStart); | ||
5054 | SendCollisionEvent(att, scriptEvents.collision , m_lastColliders , m_scene.EventManager.TriggerScriptColliding); | ||
5055 | SendCollisionEvent(att, scriptEvents.collision_end , endedColliders , m_scene.EventManager.TriggerScriptCollidingEnd); | ||
5056 | |||
5057 | if (startedColliders.Contains(0)) | ||
5058 | SendLandCollisionEvent(att, scriptEvents.land_collision_start, m_scene.EventManager.TriggerScriptLandCollidingStart); | ||
5059 | if (m_lastColliders.Contains(0)) | ||
5060 | SendLandCollisionEvent(att, scriptEvents.land_collision, m_scene.EventManager.TriggerScriptLandColliding); | ||
5061 | if (endedColliders.Contains(0)) | ||
5062 | SendLandCollisionEvent(att, scriptEvents.land_collision_end, m_scene.EventManager.TriggerScriptLandCollidingEnd); | ||
5063 | } | ||
5064 | } | ||
5065 | finally | ||
5066 | { | ||
5067 | m_collisionEventFlag = false; | ||
5068 | } | ||
5069 | } | ||
5070 | |||
4933 | private void TeleportFlagsDebug() { | 5071 | private void TeleportFlagsDebug() { |
4934 | 5072 | ||
4935 | // Some temporary debugging help to show all the TeleportFlags we have... | 5073 | // Some temporary debugging help to show all the TeleportFlags we have... |