aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/PhysicsModules')
-rw-r--r--OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs4
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs357
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs18
3 files changed, 255 insertions, 124 deletions
diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
index d23d9c1..2fa98b5 100644
--- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
+++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs
@@ -256,6 +256,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
256 /// </summary> 256 /// </summary>
257 public string SOPName; 257 public string SOPName;
258 258
259 public virtual void CrossingStart() { }
259 public abstract void CrossingFailure(); 260 public abstract void CrossingFailure();
260 261
261 public abstract void link(PhysicsActor obj); 262 public abstract void link(PhysicsActor obj);
@@ -462,6 +463,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
462 public abstract bool SubscribedEvents(); 463 public abstract bool SubscribedEvents();
463 464
464 public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { } 465 public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { }
466 public virtual void AddVDTCCollisionEvent(uint CollidedWith, ContactPoint contact) { }
465 467
466 public virtual PhysicsInertiaData GetInertiaData() 468 public virtual PhysicsInertiaData GetInertiaData()
467 { 469 {
@@ -477,6 +479,8 @@ namespace OpenSim.Region.PhysicsModules.SharedBase
477 { 479 {
478 } 480 }
479 481
482 public virtual float SimulationSuspended { get; set; }
483
480 // Warning in a parent part it returns itself, not null 484 // Warning in a parent part it returns itself, not null
481 public virtual PhysicsActor ParentActor { get { return this; } } 485 public virtual PhysicsActor ParentActor { get { return this; } }
482 486
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
index f784990..98bea09 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
@@ -109,8 +109,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
109 private float m_waterHeight; 109 private float m_waterHeight;
110 private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle. 110 private float m_buoyancy; //KF: m_buoyancy should be set by llSetBuoyancy() for non-vehicle.
111 111
112 private int body_autodisable_frames; 112 private int m_body_autodisable_frames;
113 public int bodydisablecontrol = 0; 113 public int m_bodydisablecontrol = 0;
114 public int m_bodyMoveCoolDown = 0;
114 private float m_gravmod = 1.0f; 115 private float m_gravmod = 1.0f;
115 116
116 // Default we're a Geometry 117 // Default we're a Geometry
@@ -196,6 +197,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
196 private int m_eventsubscription; 197 private int m_eventsubscription;
197 private int m_cureventsubscription; 198 private int m_cureventsubscription;
198 private CollisionEventUpdate CollisionEventsThisFrame = null; 199 private CollisionEventUpdate CollisionEventsThisFrame = null;
200 private CollisionEventUpdate CollisionVDTCEventsThisFrame = null;
199 private bool SentEmptyCollisionsEvent; 201 private bool SentEmptyCollisionsEvent;
200 202
201 public volatile bool childPrim; 203 public volatile bool childPrim;
@@ -668,7 +670,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
668 { 670 {
669 if (value.IsFinite()) 671 if (value.IsFinite())
670 { 672 {
671 AddChange(changes.Velocity, value); 673 if(m_outbounds)
674 _velocity = value;
675 else
676 AddChange(changes.Velocity, value);
672 } 677 }
673 else 678 else
674 { 679 {
@@ -972,31 +977,70 @@ namespace OpenSim.Region.PhysicsModule.ubOde
972 977
973 public override void CrossingFailure() 978 public override void CrossingFailure()
974 { 979 {
975 if (m_outbounds) 980 lock(_parent_scene.OdeLock)
976 { 981 {
977 _position.X = Util.Clip(_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f); 982 if (m_outbounds)
978 _position.Y = Util.Clip(_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f); 983 {
979 _position.Z = Util.Clip(_position.Z + 0.2f, -100f, 50000f); 984 _position.X = Util.Clip(_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f);
985 _position.Y = Util.Clip(_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f);
986 _position.Z = Util.Clip(_position.Z + 0.2f, -100f, 50000f);
980 987
981 m_lastposition = _position; 988 m_lastposition = _position;
982 _velocity.X = 0; 989 _velocity.X = 0;
983 _velocity.Y = 0; 990 _velocity.Y = 0;
984 _velocity.Z = 0; 991 _velocity.Z = 0;
985 992
986 d.AllocateODEDataForThread(0); 993 d.AllocateODEDataForThread(0);
987 994
988 m_lastVelocity = _velocity; 995 m_lastVelocity = _velocity;
989 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) 996 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE)
990 m_vehicle.Stop(); 997 m_vehicle.Stop();
991 998
999 if(Body != IntPtr.Zero)
1000 d.BodySetLinearVel(Body, 0, 0, 0); // stop it
1001 if (prim_geom != IntPtr.Zero)
1002 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1003
1004 m_outbounds = false;
1005 changeDisable(false);
1006 base.RequestPhysicsterseUpdate();
1007 }
1008 }
1009 }
1010
1011 public override void CrossingStart()
1012 {
1013 lock(_parent_scene.OdeLock)
1014 {
1015 if (m_outbounds || childPrim)
1016 return;
1017
1018 m_outbounds = true;
1019
1020 m_lastposition = _position;
1021 m_lastorientation = _orientation;
1022
1023 d.AllocateODEDataForThread(0);
992 if(Body != IntPtr.Zero) 1024 if(Body != IntPtr.Zero)
993 d.BodySetLinearVel(Body, 0, 0, 0); // stop it 1025 {
994 if (prim_geom != IntPtr.Zero) 1026 if(m_bodyMoveCoolDown >= 0)
995 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z); 1027 {
1028 d.Vector3 dtmp = d.BodyGetAngularVel(Body);
1029 m_rotationalVelocity.X = dtmp.X;
1030 m_rotationalVelocity.Y = dtmp.Y;
1031 m_rotationalVelocity.Z = dtmp.Z;
996 1032
997 m_outbounds = false; 1033 dtmp = d.BodyGetLinearVel(Body);
998 changeDisable(false); 1034 _velocity.X = dtmp.X;
999 base.RequestPhysicsterseUpdate(); 1035 _velocity.Y = dtmp.Y;
1036 _velocity.Z = dtmp.Z;
1037 }
1038 d.BodySetLinearVel(Body, 0, 0, 0); // stop it
1039 d.BodySetAngularVel(Body, 0, 0, 0);
1040 }
1041 d.GeomSetPosition(prim_geom, _position.X, _position.Y, _position.Z);
1042 disableBodySoft(); // stop collisions
1043 UnSubscribeEvents();
1000 } 1044 }
1001 } 1045 }
1002 1046
@@ -1090,11 +1134,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1090 m_cureventsubscription = 0; 1134 m_cureventsubscription = 0;
1091 if (CollisionEventsThisFrame == null) 1135 if (CollisionEventsThisFrame == null)
1092 CollisionEventsThisFrame = new CollisionEventUpdate(); 1136 CollisionEventsThisFrame = new CollisionEventUpdate();
1137 if (CollisionVDTCEventsThisFrame == null)
1138 CollisionVDTCEventsThisFrame = new CollisionEventUpdate();
1093 SentEmptyCollisionsEvent = false; 1139 SentEmptyCollisionsEvent = false;
1094 } 1140 }
1095 1141
1096 public override void UnSubscribeEvents() 1142 public override void UnSubscribeEvents()
1097 { 1143 {
1144 if (CollisionVDTCEventsThisFrame != null)
1145 {
1146 CollisionVDTCEventsThisFrame.Clear();
1147 CollisionVDTCEventsThisFrame = null;
1148 }
1098 if (CollisionEventsThisFrame != null) 1149 if (CollisionEventsThisFrame != null)
1099 { 1150 {
1100 CollisionEventsThisFrame.Clear(); 1151 CollisionEventsThisFrame.Clear();
@@ -1113,21 +1164,44 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1113 _parent_scene.AddCollisionEventReporting(this); 1164 _parent_scene.AddCollisionEventReporting(this);
1114 } 1165 }
1115 1166
1167 public override void AddVDTCCollisionEvent(uint CollidedWith, ContactPoint contact)
1168 {
1169 if (CollisionVDTCEventsThisFrame == null)
1170 CollisionVDTCEventsThisFrame = new CollisionEventUpdate();
1171
1172 CollisionVDTCEventsThisFrame.AddCollider(CollidedWith, contact);
1173 _parent_scene.AddCollisionEventReporting(this);
1174 }
1175
1116 internal void SleeperAddCollisionEvents() 1176 internal void SleeperAddCollisionEvents()
1117 { 1177 {
1118 if (CollisionEventsThisFrame == null) 1178 if(CollisionEventsThisFrame != null && CollisionEventsThisFrame.m_objCollisionList.Count != 0)
1119 return; 1179 {
1120 if(CollisionEventsThisFrame.m_objCollisionList.Count == 0) 1180 foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionEventsThisFrame.m_objCollisionList)
1121 return; 1181 {
1122 foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionEventsThisFrame.m_objCollisionList) 1182 if(kvp.Key == 0)
1183 continue;
1184 OdePrim other = _parent_scene.getPrim(kvp.Key);
1185 if(other == null)
1186 continue;
1187 ContactPoint cp = kvp.Value;
1188 cp.SurfaceNormal = - cp.SurfaceNormal;
1189 cp.RelativeSpeed = -cp.RelativeSpeed;
1190 other.AddCollisionEvent(ParentActor.LocalID,cp);
1191 }
1192 }
1193 if(CollisionVDTCEventsThisFrame != null && CollisionVDTCEventsThisFrame.m_objCollisionList.Count != 0)
1123 { 1194 {
1124 OdePrim other = _parent_scene.getPrim(kvp.Key); 1195 foreach(KeyValuePair<uint,ContactPoint> kvp in CollisionVDTCEventsThisFrame.m_objCollisionList)
1125 if(other == null) 1196 {
1126 continue; 1197 OdePrim other = _parent_scene.getPrim(kvp.Key);
1127 ContactPoint cp = kvp.Value; 1198 if(other == null)
1128 cp.SurfaceNormal = - cp.SurfaceNormal; 1199 continue;
1129 cp.RelativeSpeed = -cp.RelativeSpeed; 1200 ContactPoint cp = kvp.Value;
1130 other.AddCollisionEvent(ParentActor.LocalID,cp); 1201 cp.SurfaceNormal = - cp.SurfaceNormal;
1202 cp.RelativeSpeed = -cp.RelativeSpeed;
1203 other.AddCollisionEvent(ParentActor.LocalID,cp);
1204 }
1131 } 1205 }
1132 } 1206 }
1133 1207
@@ -1160,6 +1234,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1160 CollisionEventsThisFrame.Clear(); 1234 CollisionEventsThisFrame.Clear();
1161 } 1235 }
1162 } 1236 }
1237 if(CollisionVDTCEventsThisFrame != null && (Body == IntPtr.Zero || d.BodyIsEnabled(Body)))
1238 CollisionVDTCEventsThisFrame.Clear();
1163 } 1239 }
1164 1240
1165 public override bool SubscribedEvents() 1241 public override bool SubscribedEvents()
@@ -1192,7 +1268,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1192 m_invTimeStep = 1f / m_timeStep; 1268 m_invTimeStep = 1f / m_timeStep;
1193 1269
1194 m_density = parent_scene.geomDefaultDensity; 1270 m_density = parent_scene.geomDefaultDensity;
1195 body_autodisable_frames = parent_scene.bodyFramesAutoDisable; 1271 m_body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
1196 1272
1197 prim_geom = IntPtr.Zero; 1273 prim_geom = IntPtr.Zero;
1198 collide_geom = IntPtr.Zero; 1274 collide_geom = IntPtr.Zero;
@@ -1257,6 +1333,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1257 bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce; 1333 bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce;
1258 1334
1259 m_building = true; // control must set this to false when done 1335 m_building = true; // control must set this to false when done
1336 m_bodyMoveCoolDown = 0;
1260 1337
1261 AddChange(changes.Add, null); 1338 AddChange(changes.Add, null);
1262 1339
@@ -1963,7 +2040,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1963 d.BodySetGravityMode(Body, false); 2040 d.BodySetGravityMode(Body, false);
1964 2041
1965 d.BodySetAutoDisableFlag(Body, true); 2042 d.BodySetAutoDisableFlag(Body, true);
1966 d.BodySetAutoDisableSteps(Body, body_autodisable_frames); 2043 d.BodySetAutoDisableSteps(Body, m_body_autodisable_frames);
1967 d.BodySetAutoDisableAngularThreshold(Body, 0.05f); 2044 d.BodySetAutoDisableAngularThreshold(Body, 0.05f);
1968 d.BodySetAutoDisableLinearThreshold(Body, 0.05f); 2045 d.BodySetAutoDisableLinearThreshold(Body, 0.05f);
1969 d.BodySetDamping(Body, .004f, .001f); 2046 d.BodySetDamping(Body, .004f, .001f);
@@ -2055,11 +2132,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2055 } 2132 }
2056 else 2133 else
2057 { 2134 {
2135 /*
2058 d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z); 2136 d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z);
2059 d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); 2137 d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
2138 */
2060 _zeroFlag = false; 2139 _zeroFlag = false;
2061 bodydisablecontrol = 0; 2140 m_bodydisablecontrol = 0;
2062 } 2141 }
2142 m_bodyMoveCoolDown = -5;
2063 _parent_scene.addActiveGroups(this); 2143 _parent_scene.addActiveGroups(this);
2064 } 2144 }
2065 2145
@@ -2152,6 +2232,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2152 } 2232 }
2153 m_mass = primMass; 2233 m_mass = primMass;
2154 m_collisionscore = 0; 2234 m_collisionscore = 0;
2235 m_bodyMoveCoolDown = 0;
2155 } 2236 }
2156 2237
2157 private void FixInertia(Vector3 NewPos,Quaternion newrot) 2238 private void FixInertia(Vector3 NewPos,Quaternion newrot)
@@ -2814,6 +2895,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2814 { 2895 {
2815 _zeroFlag = true; 2896 _zeroFlag = true;
2816 d.BodyEnable(Body); 2897 d.BodyEnable(Body);
2898 m_bodyMoveCoolDown = -5;
2817 } 2899 }
2818 } 2900 }
2819// else if (_parent != null) 2901// else if (_parent != null)
@@ -2856,6 +2938,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2856 { 2938 {
2857 d.GeomSetPosition(prim_geom, newPos.X, newPos.Y, newPos.Z); 2939 d.GeomSetPosition(prim_geom, newPos.X, newPos.Y, newPos.Z);
2858 _position = newPos; 2940 _position = newPos;
2941 m_bodyMoveCoolDown = -5;
2859 } 2942 }
2860 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) 2943 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
2861 { 2944 {
@@ -2915,8 +2998,13 @@ namespace OpenSim.Region.PhysicsModule.ubOde
2915 myrot.W = newOri.W; 2998 myrot.W = newOri.W;
2916 d.GeomSetQuaternion(prim_geom, ref myrot); 2999 d.GeomSetQuaternion(prim_geom, ref myrot);
2917 _orientation = newOri; 3000 _orientation = newOri;
2918 if (Body != IntPtr.Zero && m_angularlocks != 0) 3001
2919 createAMotor(m_angularlocks); 3002 if (Body != IntPtr.Zero)
3003 {
3004 if(m_angularlocks != 0)
3005 createAMotor(m_angularlocks);
3006 m_bodyMoveCoolDown = -5;
3007 }
2920 } 3008 }
2921 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) 3009 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
2922 { 3010 {
@@ -3212,7 +3300,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3212 3300
3213 private void changeSetTorque(Vector3 newtorque) 3301 private void changeSetTorque(Vector3 newtorque)
3214 { 3302 {
3215 if (!m_isSelected) 3303 if (!m_isSelected && !m_outbounds)
3216 { 3304 {
3217 if (m_isphysical && Body != IntPtr.Zero) 3305 if (m_isphysical && Body != IntPtr.Zero)
3218 { 3306 {
@@ -3229,14 +3317,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3229 private void changeForce(Vector3 force) 3317 private void changeForce(Vector3 force)
3230 { 3318 {
3231 m_force = force; 3319 m_force = force;
3232 if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) 3320 if (!m_isSelected && !m_outbounds && Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
3233 d.BodyEnable(Body); 3321 d.BodyEnable(Body);
3234 } 3322 }
3235 3323
3236 private void changeAddForce(Vector3 theforce) 3324 private void changeAddForce(Vector3 theforce)
3237 { 3325 {
3238 m_forceacc += theforce; 3326 m_forceacc += theforce;
3239 if (!m_isSelected) 3327 if (!m_isSelected && !m_outbounds)
3240 { 3328 {
3241 lock (this) 3329 lock (this)
3242 { 3330 {
@@ -3257,7 +3345,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3257 private void changeAddAngularImpulse(Vector3 aimpulse) 3345 private void changeAddAngularImpulse(Vector3 aimpulse)
3258 { 3346 {
3259 m_angularForceacc += aimpulse * m_invTimeStep; 3347 m_angularForceacc += aimpulse * m_invTimeStep;
3260 if (!m_isSelected) 3348 if (!m_isSelected && !m_outbounds)
3261 { 3349 {
3262 lock (this) 3350 lock (this)
3263 { 3351 {
@@ -3282,7 +3370,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3282 newVel *= len; 3370 newVel *= len;
3283 } 3371 }
3284 3372
3285 if (!m_isSelected) 3373 if (!m_isSelected && !m_outbounds)
3286 { 3374 {
3287 if (Body != IntPtr.Zero) 3375 if (Body != IntPtr.Zero)
3288 { 3376 {
@@ -3290,8 +3378,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3290 enableBodySoft(); 3378 enableBodySoft();
3291 else if (!d.BodyIsEnabled(Body)) 3379 else if (!d.BodyIsEnabled(Body))
3292 d.BodyEnable(Body); 3380 d.BodyEnable(Body);
3293 3381 if(m_bodyMoveCoolDown >= 0)
3294 d.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z); 3382 d.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z);
3295 } 3383 }
3296 //resetCollisionAccounting(); 3384 //resetCollisionAccounting();
3297 } 3385 }
@@ -3307,7 +3395,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3307 newAngVel *= len; 3395 newAngVel *= len;
3308 } 3396 }
3309 3397
3310 if (!m_isSelected) 3398 if (!m_isSelected && !m_outbounds)
3311 { 3399 {
3312 if (Body != IntPtr.Zero) 3400 if (Body != IntPtr.Zero)
3313 { 3401 {
@@ -3316,8 +3404,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3316 else if (!d.BodyIsEnabled(Body)) 3404 else if (!d.BodyIsEnabled(Body))
3317 d.BodyEnable(Body); 3405 d.BodyEnable(Body);
3318 3406
3319 3407 if(m_bodyMoveCoolDown >= 0);
3320 d.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z); 3408 d.BodySetAngularVel(Body, newAngVel.X, newAngVel.Y, newAngVel.Z);
3321 } 3409 }
3322 //resetCollisionAccounting(); 3410 //resetCollisionAccounting();
3323 } 3411 }
@@ -3468,13 +3556,33 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3468 if (!childPrim && m_isphysical && Body != IntPtr.Zero && 3556 if (!childPrim && m_isphysical && Body != IntPtr.Zero &&
3469 !m_disabled && !m_isSelected && !m_building && !m_outbounds) 3557 !m_disabled && !m_isSelected && !m_building && !m_outbounds)
3470 { 3558 {
3559 if(m_bodyMoveCoolDown < 0)
3560 {
3561 m_bodyMoveCoolDown++;
3562// if(!IsColliding)
3563// m_bodyCoolDown +=2;
3564 if(m_bodyMoveCoolDown >= 0)
3565 {
3566 d.BodySetAngularVel(Body, m_rotationalVelocity.X, m_rotationalVelocity.Y, m_rotationalVelocity.Z);
3567 d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
3568 }
3569 else
3570 {
3571 d.BodySetAngularVel(Body, 0, 0, 0);
3572 d.BodySetLinearVel(Body, 0, 0, 0);
3573 m_forceacc = Vector3.Zero;
3574 m_angularForceacc = Vector3.Zero;
3575 _zeroFlag = false;
3576 return;
3577 }
3578 }
3471 if (!d.BodyIsEnabled(Body)) 3579 if (!d.BodyIsEnabled(Body))
3472 { 3580 {
3473 // let vehicles sleep 3581 // let vehicles sleep
3474 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE) 3582 if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE)
3475 return; 3583 return;
3476 3584
3477 if (++bodydisablecontrol < 50) 3585 if (++m_bodydisablecontrol < 50)
3478 return; 3586 return;
3479 3587
3480 // clear residuals 3588 // clear residuals
@@ -3482,11 +3590,11 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3482 d.BodySetLinearVel(Body,0f,0f,0f); 3590 d.BodySetLinearVel(Body,0f,0f,0f);
3483 _zeroFlag = true; 3591 _zeroFlag = true;
3484 d.BodyEnable(Body); 3592 d.BodyEnable(Body);
3485 bodydisablecontrol = -4; 3593 m_bodydisablecontrol = -4;
3486 } 3594 }
3487 3595
3488 if(bodydisablecontrol < 0) 3596 if(m_bodydisablecontrol < 0)
3489 bodydisablecontrol ++; 3597 m_bodydisablecontrol ++;
3490 3598
3491 d.Vector3 lpos = d.GeomGetPosition(prim_geom); // root position that is seem by rest of simulator 3599 d.Vector3 lpos = d.GeomGetPosition(prim_geom); // root position that is seem by rest of simulator
3492 3600
@@ -3655,7 +3763,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3655 { 3763 {
3656 bool bodyenabled = d.BodyIsEnabled(Body); 3764 bool bodyenabled = d.BodyIsEnabled(Body);
3657 3765
3658 if(bodydisablecontrol < 0) 3766 if(m_bodydisablecontrol < 0)
3659 return; 3767 return;
3660 3768
3661 if (bodyenabled || !_zeroFlag) 3769 if (bodyenabled || !_zeroFlag)
@@ -3723,15 +3831,18 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3723 m_lastposition = _position; 3831 m_lastposition = _position;
3724 m_lastorientation = _orientation; 3832 m_lastorientation = _orientation;
3725 3833
3726 d.Vector3 dtmp = d.BodyGetAngularVel(Body); 3834 if(m_bodyMoveCoolDown >= 0)
3727 m_rotationalVelocity.X = dtmp.X; 3835 {
3728 m_rotationalVelocity.Y = dtmp.Y; 3836 d.Vector3 dtmp = d.BodyGetAngularVel(Body);
3729 m_rotationalVelocity.Z = dtmp.Z; 3837 m_rotationalVelocity.X = dtmp.X;
3730 3838 m_rotationalVelocity.Y = dtmp.Y;
3731 dtmp = d.BodyGetLinearVel(Body); 3839 m_rotationalVelocity.Z = dtmp.Z;
3732 _velocity.X = dtmp.X; 3840
3733 _velocity.Y = dtmp.Y; 3841 dtmp = d.BodyGetLinearVel(Body);
3734 _velocity.Z = dtmp.Z; 3842 _velocity.X = dtmp.X;
3843 _velocity.Y = dtmp.Y;
3844 _velocity.Z = dtmp.Z;
3845 }
3735 3846
3736 d.BodySetLinearVel(Body, 0, 0, 0); // stop it 3847 d.BodySetLinearVel(Body, 0, 0, 0); // stop it
3737 d.BodySetAngularVel(Body, 0, 0, 0); 3848 d.BodySetAngularVel(Body, 0, 0, 0);
@@ -3756,30 +3867,33 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3756 } 3867 }
3757 else 3868 else
3758 { 3869 {
3759 float poserror; 3870 if(m_bodyMoveCoolDown >= 0)
3760 float angerror;
3761 if(_zeroFlag)
3762 {
3763 poserror = 0.01f;
3764 angerror = 0.001f;
3765 }
3766 else
3767 { 3871 {
3768 poserror = 0.005f; 3872 float poserror;
3769 angerror = 0.0005f; 3873 float angerror;
3770 } 3874 if(_zeroFlag)
3875 {
3876 poserror = 0.01f;
3877 angerror = 0.001f;
3878 }
3879 else
3880 {
3881 poserror = 0.005f;
3882 angerror = 0.0005f;
3883 }
3771 3884
3772 if ( 3885 if (
3773 (Math.Abs(_position.X - lpos.X) < poserror) 3886 (Math.Abs(_position.X - lpos.X) < poserror)
3774 && (Math.Abs(_position.Y - lpos.Y) < poserror) 3887 && (Math.Abs(_position.Y - lpos.Y) < poserror)
3775 && (Math.Abs(_position.Z - lpos.Z) < poserror) 3888 && (Math.Abs(_position.Z - lpos.Z) < poserror)
3776 && (Math.Abs(_orientation.X - ori.X) < angerror) 3889 && (Math.Abs(_orientation.X - ori.X) < angerror)
3777 && (Math.Abs(_orientation.Y - ori.Y) < angerror) 3890 && (Math.Abs(_orientation.Y - ori.Y) < angerror)
3778 && (Math.Abs(_orientation.Z - ori.Z) < angerror) // ignore W 3891 && (Math.Abs(_orientation.Z - ori.Z) < angerror) // ignore W
3779 ) 3892 )
3780 _zeroFlag = true; 3893 _zeroFlag = true;
3781 else 3894 else
3782 _zeroFlag = false; 3895 _zeroFlag = false;
3896 }
3783 } 3897 }
3784 3898
3785 // update position 3899 // update position
@@ -3805,46 +3919,49 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3805 } 3919 }
3806 else 3920 else
3807 { 3921 {
3808 d.Vector3 vel = d.BodyGetLinearVel(Body); 3922 if(m_bodyMoveCoolDown >= 0)
3923 {
3924 d.Vector3 vel = d.BodyGetLinearVel(Body);
3809 3925
3810 _acceleration = _velocity; 3926 _acceleration = _velocity;
3811 3927
3812 if ((Math.Abs(vel.X) < 0.005f) && 3928 if ((Math.Abs(vel.X) < 0.005f) &&
3813 (Math.Abs(vel.Y) < 0.005f) && 3929 (Math.Abs(vel.Y) < 0.005f) &&
3814 (Math.Abs(vel.Z) < 0.005f)) 3930 (Math.Abs(vel.Z) < 0.005f))
3815 { 3931 {
3816 _velocity = Vector3.Zero; 3932 _velocity = Vector3.Zero;
3817 float t = -m_invTimeStep; 3933 float t = -m_invTimeStep;
3818 _acceleration = _acceleration * t; 3934 _acceleration = _acceleration * t;
3819 } 3935 }
3820 else 3936 else
3821 { 3937 {
3822 _velocity.X = vel.X; 3938 _velocity.X = vel.X;
3823 _velocity.Y = vel.Y; 3939 _velocity.Y = vel.Y;
3824 _velocity.Z = vel.Z; 3940 _velocity.Z = vel.Z;
3825 _acceleration = (_velocity - _acceleration) * m_invTimeStep; 3941 _acceleration = (_velocity - _acceleration) * m_invTimeStep;
3826 } 3942 }
3827 3943
3828 if ((Math.Abs(_acceleration.X) < 0.01f) && 3944 if ((Math.Abs(_acceleration.X) < 0.01f) &&
3829 (Math.Abs(_acceleration.Y) < 0.01f) && 3945 (Math.Abs(_acceleration.Y) < 0.01f) &&
3830 (Math.Abs(_acceleration.Z) < 0.01f)) 3946 (Math.Abs(_acceleration.Z) < 0.01f))
3831 { 3947 {
3832 _acceleration = Vector3.Zero; 3948 _acceleration = Vector3.Zero;
3833 } 3949 }
3834 3950
3835 vel = d.BodyGetAngularVel(Body); 3951 vel = d.BodyGetAngularVel(Body);
3836 if ((Math.Abs(vel.X) < 0.0001) && 3952 if ((Math.Abs(vel.X) < 0.0001) &&
3837 (Math.Abs(vel.Y) < 0.0001) && 3953 (Math.Abs(vel.Y) < 0.0001) &&
3838 (Math.Abs(vel.Z) < 0.0001) 3954 (Math.Abs(vel.Z) < 0.0001)
3839 ) 3955 )
3840 { 3956 {
3841 m_rotationalVelocity = Vector3.Zero; 3957 m_rotationalVelocity = Vector3.Zero;
3842 } 3958 }
3843 else 3959 else
3844 { 3960 {
3845 m_rotationalVelocity.X = vel.X; 3961 m_rotationalVelocity.X = vel.X;
3846 m_rotationalVelocity.Y = vel.Y; 3962 m_rotationalVelocity.Y = vel.Y;
3847 m_rotationalVelocity.Z = vel.Z; 3963 m_rotationalVelocity.Z = vel.Z;
3964 }
3848 } 3965 }
3849 } 3966 }
3850 3967
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
index 6279d6a..4a82f77 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
@@ -186,7 +186,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
186 186
187 float frictionMovementMult = 0.8f; 187 float frictionMovementMult = 0.8f;
188 188
189 float TerrainBounce = 0.1f; 189 float TerrainBounce = 0.001f;
190 float TerrainFriction = 0.3f; 190 float TerrainFriction = 0.3f;
191 191
192 public float AvatarFriction = 0;// 0.9f * 0.5f; 192 public float AvatarFriction = 0;// 0.9f * 0.5f;
@@ -1083,9 +1083,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1083 case ActorTypes.Prim: 1083 case ActorTypes.Prim:
1084 if (p2events) 1084 if (p2events)
1085 { 1085 {
1086 AddCollisionEventReporting(p2); 1086 //AddCollisionEventReporting(p2);
1087 p2.AddCollisionEvent(p1.ParentActor.LocalID, contact); 1087 p2.AddCollisionEvent(p1.ParentActor.LocalID, contact);
1088 } 1088 }
1089 else if(p1.IsVolumeDtc)
1090 p2.AddVDTCCollisionEvent(p1.ParentActor.LocalID, contact);
1091
1089 obj2LocalID = p2.ParentActor.LocalID; 1092 obj2LocalID = p2.ParentActor.LocalID;
1090 break; 1093 break;
1091 1094
@@ -1099,9 +1102,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1099 { 1102 {
1100 contact.SurfaceNormal = -contact.SurfaceNormal; 1103 contact.SurfaceNormal = -contact.SurfaceNormal;
1101 contact.RelativeSpeed = -contact.RelativeSpeed; 1104 contact.RelativeSpeed = -contact.RelativeSpeed;
1102 AddCollisionEventReporting(p1); 1105 //AddCollisionEventReporting(p1);
1103 p1.AddCollisionEvent(obj2LocalID, contact); 1106 p1.AddCollisionEvent(obj2LocalID, contact);
1104 } 1107 }
1108 else if(p2.IsVolumeDtc)
1109 {
1110 contact.SurfaceNormal = -contact.SurfaceNormal;
1111 contact.RelativeSpeed = -contact.RelativeSpeed;
1112 //AddCollisionEventReporting(p1);
1113 p1.AddVDTCCollisionEvent(obj2LocalID, contact);
1114 }
1105 break; 1115 break;
1106 } 1116 }
1107 case ActorTypes.Ground: 1117 case ActorTypes.Ground:
@@ -1110,7 +1120,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1110 { 1120 {
1111 if (p2events && !p2.IsVolumeDtc) 1121 if (p2events && !p2.IsVolumeDtc)
1112 { 1122 {
1113 AddCollisionEventReporting(p2); 1123 //AddCollisionEventReporting(p2);
1114 p2.AddCollisionEvent(0, contact); 1124 p2.AddCollisionEvent(0, contact);
1115 } 1125 }
1116 break; 1126 break;