aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2012-04-27 03:36:49 +0100
committerUbitUmarov2012-04-27 03:36:49 +0100
commitd8f691664a8de15655eb7a3dd0485c21202982e2 (patch)
treee96a8a3db8c9f8f36741ee339d39f0500486ce5e /OpenSim/Region
parenttesting (diff)
downloadopensim-SC_OLD-d8f691664a8de15655eb7a3dd0485c21202982e2.zip
opensim-SC_OLD-d8f691664a8de15655eb7a3dd0485c21202982e2.tar.gz
opensim-SC_OLD-d8f691664a8de15655eb7a3dd0485c21202982e2.tar.bz2
opensim-SC_OLD-d8f691664a8de15655eb7a3dd0485c21202982e2.tar.xz
testing
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs129
1 files changed, 71 insertions, 58 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
index 4b093ba..2c1197a 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs
@@ -103,6 +103,7 @@ namespace OpenSim.Region.Physics.OdePlugin
103 103
104 private float m_buoyancy = 0f; 104 private float m_buoyancy = 0f;
105 105
106 private bool m_freemove = false;
106 // private CollisionLocker ode; 107 // private CollisionLocker ode;
107 108
108 private string m_name = String.Empty; 109 private string m_name = String.Empty;
@@ -687,6 +688,7 @@ namespace OpenSim.Region.Physics.OdePlugin
687 688
688 _zeroFlag = false; 689 _zeroFlag = false;
689 m_pidControllerActive = true; 690 m_pidControllerActive = true;
691 m_freemove = false;
690 692
691 d.BodySetAutoDisableFlag(Body, false); 693 d.BodySetAutoDisableFlag(Body, false);
692 d.BodySetPosition(Body, npositionX, npositionY, npositionZ); 694 d.BodySetPosition(Body, npositionX, npositionY, npositionZ);
@@ -789,7 +791,7 @@ namespace OpenSim.Region.Physics.OdePlugin
789 qtmp.Z = 0; 791 qtmp.Z = 0;
790 d.BodySetQuaternion(Body, ref qtmp); 792 d.BodySetQuaternion(Body, ref qtmp);
791 793
792 if (m_pidControllerActive == false) 794 if (m_pidControllerActive == false && !m_freemove)
793 { 795 {
794 _zeroPosition = localpos; 796 _zeroPosition = localpos;
795 } 797 }
@@ -861,6 +863,7 @@ namespace OpenSim.Region.Physics.OdePlugin
861 float terrainheight = _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y); 863 float terrainheight = _parent_scene.GetTerrainHeightAtXY(posch.X, posch.Y);
862 if (chrminZ < terrainheight) 864 if (chrminZ < terrainheight)
863 { 865 {
866 m_freemove = false;
864 float depth = terrainheight - chrminZ; 867 float depth = terrainheight - chrminZ;
865 if (!flying) 868 if (!flying)
866 { 869 {
@@ -896,77 +899,86 @@ namespace OpenSim.Region.Physics.OdePlugin
896 899
897 //****************************************** 900 //******************************************
898 901
899 // if velocity is zero, use position control; otherwise, velocity control 902 bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f);
900 if (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f 903
901 && m_iscolliding) 904 if(!tviszero || !m_iscolliding)
905 m_freemove = false;
906
907 if (!m_freemove)
902 { 908 {
903 // keep track of where we stopped. No more slippin' & slidin' 909
904 if (!_zeroFlag) 910 // if velocity is zero, use position control; otherwise, velocity control
905 { 911 if (tviszero && m_iscolliding)
906 _zeroFlag = true;
907 _zeroPosition = localpos;
908 }
909 if (m_pidControllerActive)
910 { 912 {
911 // We only want to deactivate the PID Controller if we think we want to have our surrogate 913 // keep track of where we stopped. No more slippin' & slidin'
912 // react to the physics scene by moving it's position. 914 if (!_zeroFlag)
913 // Avatar to Avatar collisions
914 // Prim to avatar collisions
915
916 vec.X = -vel.X * PID_D + (_zeroPosition.X - localpos.X) * (PID_P * 2);
917 vec.Y = -vel.Y * PID_D + (_zeroPosition.Y - localpos.Y) * (PID_P * 2);
918 if (flying)
919 { 915 {
920 vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P; 916 _zeroFlag = true;
917 _zeroPosition = localpos;
921 } 918 }
922 } 919 if (m_pidControllerActive)
923 //PidStatus = true;
924 }
925 else
926 {
927 m_pidControllerActive = true;
928 _zeroFlag = false;
929
930 if (m_iscolliding)
931 {
932 if (!flying)
933 { 920 {
934 if (_target_velocity.Z > 0.0f) 921 // We only want to deactivate the PID Controller if we think we want to have our surrogate
922 // react to the physics scene by moving it's position.
923 // Avatar to Avatar collisions
924 // Prim to avatar collisions
925
926 vec.X = -vel.X * PID_D + (_zeroPosition.X - localpos.X) * (PID_P * 2);
927 vec.Y = -vel.Y * PID_D + (_zeroPosition.Y - localpos.Y) * (PID_P * 2);
928 if (flying)
935 { 929 {
936 // We're colliding with something and we're not flying but we're moving 930 vec.Z += -vel.Z * PID_D + (_zeroPosition.Z - localpos.Z) * PID_P;
937 // This means we're walking or running. JUMPING
938 vec.Z += (_target_velocity.Z - vel.Z) * PID_D * 1.2f;// +(_zeroPosition.Z - localpos.Z) * PID_P;
939 } 931 }
940 // We're standing on something
941 vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D);
942 vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D);
943 }
944 else
945 {
946 // We're flying and colliding with something
947 vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 0.0625f);
948 vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 0.0625f);
949 vec.Z += (_target_velocity.Z - vel.Z) * (PID_D);
950 } 932 }
933 //PidStatus = true;
951 } 934 }
952 else // ie not colliding 935 else
953 { 936 {
954 if (flying) //(!m_iscolliding && flying) 937 m_freemove = false;
938 m_pidControllerActive = true;
939 _zeroFlag = false;
940
941 if (m_iscolliding)
955 { 942 {
956 // we're in mid air suspended 943 if (!flying)
957 vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 1.667f); 944 {
958 vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 1.667f); 945 if (_target_velocity.Z > 0.0f)
959 vec.Z += (_target_velocity.Z - vel.Z) * (PID_D); 946 {
947 // We're colliding with something and we're not flying but we're moving
948 // This means we're walking or running. JUMPING
949 vec.Z += (_target_velocity.Z - vel.Z) * PID_D * 1.2f;// +(_zeroPosition.Z - localpos.Z) * PID_P;
950 }
951 // We're standing on something
952 vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D);
953 vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D);
954 }
955 else
956 {
957 // We're flying and colliding with something
958 vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 0.0625f);
959 vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 0.0625f);
960 vec.Z += (_target_velocity.Z - vel.Z) * (PID_D);
961 }
960 } 962 }
961 963 else // ie not colliding
962 else
963 { 964 {
964 // we're not colliding and we're not flying so that means we're falling! 965 if (flying) //(!m_iscolliding && flying)
965 // m_iscolliding includes collisions with the ground. 966 {
967 // we're in mid air suspended
968 vec.X = ((_target_velocity.X * movementdivisor) - vel.X) * (PID_D * 1.667f);
969 vec.Y = ((_target_velocity.Y * movementdivisor) - vel.Y) * (PID_D * 1.667f);
970 vec.Z += (_target_velocity.Z - vel.Z) * (PID_D);
971 }
966 972
967 // d.Vector3 pos = d.BodyGetPosition(Body); 973 else
968 vec.X = (_target_velocity.X - vel.X) * PID_D * 0.833f; 974 {
969 vec.Y = (_target_velocity.Y - vel.Y) * PID_D * 0.833f; 975 // we're not colliding and we're not flying so that means we're falling!
976 // m_iscolliding includes collisions with the ground.
977
978 // d.Vector3 pos = d.BodyGetPosition(Body);
979 vec.X = (_target_velocity.X - vel.X) * PID_D * 0.833f;
980 vec.Y = (_target_velocity.Y - vel.Y) * PID_D * 0.833f;
981 }
970 } 982 }
971 } 983 }
972 } 984 }
@@ -1274,6 +1286,7 @@ namespace OpenSim.Region.Physics.OdePlugin
1274 { 1286 {
1275 _velocity = newmomentum; 1287 _velocity = newmomentum;
1276 _target_velocity = Vector3.Zero; 1288 _target_velocity = Vector3.Zero;
1289 m_freemove = true;
1277 m_pidControllerActive = true; 1290 m_pidControllerActive = true;
1278 m_colliderfilter = 0; 1291 m_colliderfilter = 0;
1279 m_colliderObjectfilter = 0; 1292 m_colliderObjectfilter = 0;