diff options
author | UbitUmarov | 2014-07-21 19:16:23 +0100 |
---|---|---|
committer | UbitUmarov | 2014-07-21 19:16:23 +0100 |
commit | d9797b64784d4c4ec1d1d55c7a7bdaa71bfe3ebe (patch) | |
tree | 0413820a59aef8212dc4e1caab8af94ac42aa44f | |
parent | bug fix (diff) | |
download | opensim-SC_OLD-d9797b64784d4c4ec1d1d55c7a7bdaa71bfe3ebe.zip opensim-SC_OLD-d9797b64784d4c4ec1d1d55c7a7bdaa71bfe3ebe.tar.gz opensim-SC_OLD-d9797b64784d4c4ec1d1d55c7a7bdaa71bfe3ebe.tar.bz2 opensim-SC_OLD-d9797b64784d4c4ec1d1d55c7a7bdaa71bfe3ebe.tar.xz |
change ava to ava collisions a bit
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 72 |
1 files changed, 42 insertions, 30 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index ecd5474..daf6c7c 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | |||
@@ -96,6 +96,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
96 | private float m_feetOffset = 0; | 96 | private float m_feetOffset = 0; |
97 | private float feetOff = 0; | 97 | private float feetOff = 0; |
98 | private float boneOff = 0; | 98 | private float boneOff = 0; |
99 | private float AvaAvaSizeXsq = 0.3f; | ||
100 | private float AvaAvaSizeYsq = 0.2f; | ||
99 | 101 | ||
100 | public float walkDivisor = 1.3f; | 102 | public float walkDivisor = 1.3f; |
101 | public float runDivisor = 0.8f; | 103 | public float runDivisor = 0.8f; |
@@ -136,7 +138,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
136 | public IntPtr Body = IntPtr.Zero; | 138 | public IntPtr Body = IntPtr.Zero; |
137 | private OdeScene _parent_scene; | 139 | private OdeScene _parent_scene; |
138 | private IntPtr capsule = IntPtr.Zero; | 140 | private IntPtr capsule = IntPtr.Zero; |
139 | private IntPtr bbox = IntPtr.Zero; | ||
140 | public IntPtr collider = IntPtr.Zero; | 141 | public IntPtr collider = IntPtr.Zero; |
141 | 142 | ||
142 | public IntPtr Amotor = IntPtr.Zero; | 143 | public IntPtr Amotor = IntPtr.Zero; |
@@ -709,6 +710,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
709 | 710 | ||
710 | feetOff = bot + feetsz; | 711 | feetOff = bot + feetsz; |
711 | 712 | ||
713 | AvaAvaSizeXsq = 0.4f * sx; | ||
714 | AvaAvaSizeXsq *= AvaAvaSizeXsq; | ||
715 | AvaAvaSizeYsq = 0.5f * sy; | ||
716 | AvaAvaSizeYsq *= AvaAvaSizeYsq; | ||
717 | |||
712 | _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); | 718 | _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); |
713 | 719 | ||
714 | collider = d.HashSpaceCreate(_parent_scene.CharsSpace); | 720 | collider = d.HashSpaceCreate(_parent_scene.CharsSpace); |
@@ -723,9 +729,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
723 | r = m_size.Y; | 729 | r = m_size.Y; |
724 | float l = m_size.Z - r; | 730 | float l = m_size.Z - r; |
725 | r *= 0.5f; | 731 | r *= 0.5f; |
726 | capsule = d.CreateCapsule(collider, r, l); | ||
727 | 732 | ||
728 | bbox = d.CreateBox(collider, m_size.X, m_size.Y, m_size.Z); | 733 | capsule = d.CreateCapsule(collider, r, l); |
729 | 734 | ||
730 | m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass | 735 | m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass |
731 | 736 | ||
@@ -750,8 +755,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
750 | _position.Z = npositionZ; | 755 | _position.Z = npositionZ; |
751 | 756 | ||
752 | d.BodySetMass(Body, ref ShellMass); | 757 | d.BodySetMass(Body, ref ShellMass); |
753 | |||
754 | d.GeomSetBody(bbox, Body); | ||
755 | d.GeomSetBody(capsule, Body); | 758 | d.GeomSetBody(capsule, Body); |
756 | 759 | ||
757 | // The purpose of the AMotor here is to keep the avatar's physical | 760 | // The purpose of the AMotor here is to keep the avatar's physical |
@@ -821,14 +824,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
821 | capsule = IntPtr.Zero; | 824 | capsule = IntPtr.Zero; |
822 | } | 825 | } |
823 | 826 | ||
824 | if (bbox != IntPtr.Zero) | ||
825 | { | ||
826 | _parent_scene.actor_name_map.Remove(bbox); | ||
827 | _parent_scene.waitForSpaceUnlock(collider); | ||
828 | d.GeomDestroy(bbox); | ||
829 | bbox = IntPtr.Zero; | ||
830 | } | ||
831 | |||
832 | if (collider != IntPtr.Zero) | 827 | if (collider != IntPtr.Zero) |
833 | { | 828 | { |
834 | d.SpaceDestroy(collider); | 829 | d.SpaceDestroy(collider); |
@@ -871,20 +866,44 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
871 | } | 866 | } |
872 | 867 | ||
873 | 868 | ||
874 | public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact, ref bool feetcollision) | 869 | public bool Collide(IntPtr me,IntPtr other, bool reverse, ref d.ContactGeom contact, ref bool feetcollision) |
875 | { | 870 | { |
876 | feetcollision = false; | 871 | feetcollision = false; |
877 | 872 | ||
878 | Vector3 offset; | ||
879 | |||
880 | offset.X = contact.pos.X - _position.X; | ||
881 | offset.Y = contact.pos.Y - _position.Y; | ||
882 | |||
883 | if (me == capsule) | 873 | if (me == capsule) |
884 | { | 874 | { |
875 | Vector3 offset; | ||
876 | |||
885 | float h = contact.pos.Z - _position.Z; | 877 | float h = contact.pos.Z - _position.Z; |
886 | offset.Z = h - feetOff; | 878 | offset.Z = h - feetOff; |
887 | 879 | ||
880 | offset.X = contact.pos.X - _position.X; | ||
881 | offset.Y = contact.pos.Y - _position.Y; | ||
882 | |||
883 | d.GeomClassID gtype = d.GeomGetClass(other); | ||
884 | if (gtype == d.GeomClassID.CapsuleClass) | ||
885 | { | ||
886 | Vector3 roff = offset * Quaternion.Inverse(m_orientation2D); | ||
887 | float r = roff.X *roff.X / AvaAvaSizeXsq; | ||
888 | r += (roff.Y * roff.Y) / AvaAvaSizeYsq; | ||
889 | if (r > 1.0f) | ||
890 | return false; | ||
891 | |||
892 | float dp = 1.0f -(float)Math.Sqrt((double)r); | ||
893 | if (dp > 0.05f) | ||
894 | dp = 0.05f; | ||
895 | |||
896 | contact.depth = dp; | ||
897 | |||
898 | if (offset.Z < 0) | ||
899 | { | ||
900 | feetcollision = true; | ||
901 | if (h < boneOff) | ||
902 | IsColliding = true; | ||
903 | } | ||
904 | return true; | ||
905 | } | ||
906 | |||
888 | if (offset.Z > 0) | 907 | if (offset.Z > 0) |
889 | return true; | 908 | return true; |
890 | 909 | ||
@@ -905,11 +924,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
905 | feetcollision = true; | 924 | feetcollision = true; |
906 | if (h < boneOff) | 925 | if (h < boneOff) |
907 | IsColliding = true; | 926 | IsColliding = true; |
927 | return true; | ||
908 | } | 928 | } |
909 | else | 929 | return false; |
910 | return false; | ||
911 | |||
912 | return true; | ||
913 | } | 930 | } |
914 | 931 | ||
915 | /// <summary> | 932 | /// <summary> |
@@ -1094,8 +1111,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1094 | // Avatar to Avatar collisions | 1111 | // Avatar to Avatar collisions |
1095 | // Prim to avatar collisions | 1112 | // Prim to avatar collisions |
1096 | 1113 | ||
1097 | vec.X = -vel.X * PID_D + (_zeroPosition.X - localpos.X) * (PID_P * 2); | 1114 | vec.X = -vel.X * PID_D * 2 + (_zeroPosition.X - localpos.X) * (PID_P * 5); |
1098 | vec.Y = -vel.Y * PID_D + (_zeroPosition.Y - localpos.Y) * (PID_P * 2); | 1115 | vec.Y = -vel.Y * PID_D * 2 + (_zeroPosition.Y - localpos.Y) * (PID_P * 5); |
1099 | if (flying) | 1116 | if (flying) |
1100 | { | 1117 | { |
1101 | vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P; | 1118 | vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P; |
@@ -1389,10 +1406,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1389 | AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z); | 1406 | AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z); |
1390 | 1407 | ||
1391 | _parent_scene.actor_name_map[collider] = (PhysicsActor)this; | 1408 | _parent_scene.actor_name_map[collider] = (PhysicsActor)this; |
1392 | // _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this; | ||
1393 | // _parent_scene.actor_name_map[midbox] = (PhysicsActor)this; | ||
1394 | // _parent_scene.actor_name_map[topbox] = (PhysicsActor)this; | ||
1395 | _parent_scene.actor_name_map[bbox] = (PhysicsActor)this; | ||
1396 | _parent_scene.actor_name_map[capsule] = (PhysicsActor)this; | 1409 | _parent_scene.actor_name_map[capsule] = (PhysicsActor)this; |
1397 | _parent_scene.AddCharacter(this); | 1410 | _parent_scene.AddCharacter(this); |
1398 | } | 1411 | } |
@@ -1449,7 +1462,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1449 | 1462 | ||
1450 | 1463 | ||
1451 | _parent_scene.actor_name_map[collider] = (PhysicsActor)this; | 1464 | _parent_scene.actor_name_map[collider] = (PhysicsActor)this; |
1452 | _parent_scene.actor_name_map[bbox] = (PhysicsActor)this; | ||
1453 | _parent_scene.actor_name_map[capsule] = (PhysicsActor)this; | 1465 | _parent_scene.actor_name_map[capsule] = (PhysicsActor)this; |
1454 | } | 1466 | } |
1455 | m_freemove = false; | 1467 | m_freemove = false; |