diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 72 | ||||
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs | 8 | ||||
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 112 |
3 files changed, 104 insertions, 88 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; |
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs index e9023c3..672212f 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs | |||
@@ -78,11 +78,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
78 | 78 | ||
79 | IntPtr geom = ((OdePrim)actor).prim_geom; | 79 | IntPtr geom = ((OdePrim)actor).prim_geom; |
80 | 80 | ||
81 | // Vector3 geopos = d.GeomGetPositionOMV(geom); | 81 | Vector3 geopos = d.GeomGetPositionOMV(geom); |
82 | // Quaternion geomOri = d.GeomGetQuaternionOMV(geom); | 82 | Quaternion geomOri = d.GeomGetQuaternionOMV(geom); |
83 | 83 | ||
84 | Vector3 geopos = actor.Position; | 84 | // Vector3 geopos = actor.Position; |
85 | Quaternion geomOri = actor.Orientation; | 85 | // Quaternion geomOri = actor.Orientation; |
86 | 86 | ||
87 | Quaternion geomInvOri = Quaternion.Conjugate(geomOri); | 87 | Quaternion geomInvOri = Quaternion.Conjugate(geomOri); |
88 | 88 | ||
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 8abf6cf..9bf2abe 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | |||
@@ -833,13 +833,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
833 | switch (p2.PhysicsActorType) | 833 | switch (p2.PhysicsActorType) |
834 | { | 834 | { |
835 | case (int)ActorTypes.Agent: | 835 | case (int)ActorTypes.Agent: |
836 | p1.CollidingObj = true; | ||
837 | p2.CollidingObj = true; | ||
838 | break; | ||
839 | |||
840 | case (int)ActorTypes.Prim: | 836 | case (int)ActorTypes.Prim: |
841 | if (p2.Velocity.LengthSquared() > 0.0f) | ||
842 | p2.CollidingObj = true; | ||
843 | break; | 837 | break; |
844 | 838 | ||
845 | default: | 839 | default: |
@@ -850,55 +844,53 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
850 | } | 844 | } |
851 | 845 | ||
852 | case (int)ActorTypes.Prim: | 846 | case (int)ActorTypes.Prim: |
853 | switch (p2.PhysicsActorType) | ||
854 | { | 847 | { |
855 | case (int)ActorTypes.Agent: | 848 | switch (p2.PhysicsActorType) |
856 | 849 | { | |
857 | dop2ava = true; | 850 | case (int)ActorTypes.Agent: |
858 | 851 | dop2ava = true; | |
859 | if (p1.Velocity.LengthSquared() > 0.0f) | 852 | break; |
860 | p1.CollidingObj = true; | ||
861 | break; | ||
862 | |||
863 | case (int)ActorTypes.Prim: | ||
864 | Vector3 relV = p1.Velocity - p2.Velocity; | ||
865 | float relVlenSQ = relV.LengthSquared(); | ||
866 | if (relVlenSQ > 0.0001f) | ||
867 | { | ||
868 | p1.CollidingObj = true; | ||
869 | p2.CollidingObj = true; | ||
870 | } | ||
871 | p1.getContactData(ref contactdata1); | ||
872 | p2.getContactData(ref contactdata2); | ||
873 | bounce = contactdata1.bounce * contactdata2.bounce; | ||
874 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); | ||
875 | 853 | ||
876 | if (relVlenSQ > 0.01f) | 854 | case (int)ActorTypes.Prim: |
877 | mu *= frictionMovementMult; | 855 | Vector3 relV = p1.Velocity - p2.Velocity; |
856 | float relVlenSQ = relV.LengthSquared(); | ||
857 | if (relVlenSQ > 0.0001f) | ||
858 | { | ||
859 | p1.CollidingObj = true; | ||
860 | p2.CollidingObj = true; | ||
861 | } | ||
862 | p1.getContactData(ref contactdata1); | ||
863 | p2.getContactData(ref contactdata2); | ||
864 | bounce = contactdata1.bounce * contactdata2.bounce; | ||
865 | mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); | ||
878 | 866 | ||
879 | break; | 867 | if (relVlenSQ > 0.01f) |
868 | mu *= frictionMovementMult; | ||
880 | 869 | ||
881 | case (int)ActorTypes.Ground: | 870 | break; |
882 | p1.getContactData(ref contactdata1); | ||
883 | bounce = contactdata1.bounce * TerrainBounce; | ||
884 | mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); | ||
885 | 871 | ||
886 | if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) | 872 | case (int)ActorTypes.Ground: |
887 | mu *= frictionMovementMult; | 873 | p1.getContactData(ref contactdata1); |
888 | p1.CollidingGround = true; | 874 | bounce = contactdata1.bounce * TerrainBounce; |
889 | /* | 875 | mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); |
890 | if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) | 876 | |
891 | { | 877 | if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) |
892 | if (curContact.side1 > 0) | 878 | mu *= frictionMovementMult; |
893 | IgnoreNegSides = true; | 879 | p1.CollidingGround = true; |
894 | } | 880 | /* |
895 | */ | 881 | if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) |
896 | break; | 882 | { |
883 | if (curContact.side1 > 0) | ||
884 | IgnoreNegSides = true; | ||
885 | } | ||
886 | */ | ||
887 | break; | ||
897 | 888 | ||
898 | case (int)ActorTypes.Water: | 889 | case (int)ActorTypes.Water: |
899 | default: | 890 | default: |
900 | ignore = true; | 891 | ignore = true; |
901 | break; | 892 | break; |
893 | } | ||
902 | } | 894 | } |
903 | break; | 895 | break; |
904 | 896 | ||
@@ -950,14 +942,25 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
950 | bool noskip = true; | 942 | bool noskip = true; |
951 | if (dop1ava) | 943 | if (dop1ava) |
952 | { | 944 | { |
953 | if (!(((OdeCharacter)p1).Collide(g1, false, ref curContact, ref FeetCollision))) | 945 | if (!(((OdeCharacter)p1).Collide(g1, g2, false, ref curContact, ref FeetCollision))) |
954 | |||
955 | noskip = false; | 946 | noskip = false; |
947 | else | ||
948 | { | ||
949 | if(p2.PhysicsActorType == (int)ActorTypes.Agent) | ||
950 | { | ||
951 | p1.CollidingObj = true; | ||
952 | p2.CollidingObj = true; | ||
953 | } | ||
954 | else if (p2.Velocity.LengthSquared() > 0.0f) | ||
955 | p2.CollidingObj = true; | ||
956 | } | ||
956 | } | 957 | } |
957 | else if (dop2ava) | 958 | else if (dop2ava) |
958 | { | 959 | { |
959 | if (!(((OdeCharacter)p2).Collide(g2, true, ref curContact, ref FeetCollision))) | 960 | if (!(((OdeCharacter)p2).Collide(g2,g1, true, ref curContact, ref FeetCollision))) |
960 | noskip = false; | 961 | noskip = false; |
962 | else if (p1.Velocity.LengthSquared() > 0.0f) | ||
963 | p1.CollidingObj = true; | ||
961 | } | 964 | } |
962 | 965 | ||
963 | if (noskip) | 966 | if (noskip) |
@@ -1095,10 +1098,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1095 | // do colisions with static space | 1098 | // do colisions with static space |
1096 | d.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, nearCallback); | 1099 | d.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, nearCallback); |
1097 | 1100 | ||
1098 | // chars with chars | ||
1099 | d.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback); | ||
1100 | // no coll with gnd | 1101 | // no coll with gnd |
1101 | } | 1102 | } |
1103 | // chars with chars | ||
1104 | d.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback); | ||
1105 | |||
1102 | } | 1106 | } |
1103 | catch (AccessViolationException) | 1107 | catch (AccessViolationException) |
1104 | { | 1108 | { |