diff options
author | Robert Adams | 2012-11-26 10:47:34 -0800 |
---|---|---|
committer | Robert Adams | 2012-11-26 10:47:34 -0800 |
commit | 5685b33071c683c41643fcb78d6f8a28d98db468 (patch) | |
tree | 3e180ef8124130c127823fefabed217031df6dd9 /OpenSim/Region/Physics | |
parent | BulletSim: use m_angularMotor to do the basic movement. Add the setting of sa... (diff) | |
download | opensim-SC_OLD-5685b33071c683c41643fcb78d6f8a28d98db468.zip opensim-SC_OLD-5685b33071c683c41643fcb78d6f8a28d98db468.tar.gz opensim-SC_OLD-5685b33071c683c41643fcb78d6f8a28d98db468.tar.bz2 opensim-SC_OLD-5685b33071c683c41643fcb78d6f8a28d98db468.tar.xz |
BulletSim: increase vehicle stability by suppressing Bullet's update to angular velocity.
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 21 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 50 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 12 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | 2 |
4 files changed, 26 insertions, 59 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 95a4134..6ff8a48 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -805,6 +805,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
805 | // m_angularFrictionTimescale // body angular velocity decay rate | 805 | // m_angularFrictionTimescale // body angular velocity decay rate |
806 | // m_lastAngularVelocity // what was last applied to body | 806 | // m_lastAngularVelocity // what was last applied to body |
807 | 807 | ||
808 | /* | ||
808 | if (m_angularMotorDirection.LengthSquared() > 0.0001) | 809 | if (m_angularMotorDirection.LengthSquared() > 0.0001) |
809 | { | 810 | { |
810 | Vector3 origVel = m_angularMotorVelocity; | 811 | Vector3 origVel = m_angularMotorVelocity; |
@@ -823,6 +824,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
823 | { | 824 | { |
824 | m_angularMotorVelocity = Vector3.Zero; | 825 | m_angularMotorVelocity = Vector3.Zero; |
825 | } | 826 | } |
827 | */ | ||
826 | 828 | ||
827 | Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep); | 829 | Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep); |
828 | 830 | ||
@@ -842,15 +844,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
842 | // verticalError.X and .Y are the World error amounts. They are 0 when there is no | 844 | // verticalError.X and .Y are the World error amounts. They are 0 when there is no |
843 | // error (Vehicle Body is 'vertical'), and .Z will be 1. As the body leans to its | 845 | // error (Vehicle Body is 'vertical'), and .Z will be 1. As the body leans to its |
844 | // side |.X| will increase to 1 and .Z fall to 0. As body inverts |.X| will fall | 846 | // side |.X| will increase to 1 and .Z fall to 0. As body inverts |.X| will fall |
845 | // and .Z will go // negative. Similar for tilt and |.Y|. .X and .Y must be | 847 | // and .Z will go negative. Similar for tilt and |.Y|. .X and .Y must be |
846 | // modulated to prevent a stable inverted body. | 848 | // modulated to prevent a stable inverted body. |
847 | 849 | ||
848 | // Error is 0 (no error) to +/- 2 (max error) | 850 | // Error is 0 (no error) to +/- 2 (max error) |
849 | if (verticalError.Z < 0.0f) | 851 | verticalError.X = Math.Max(-2f, Math.Min(verticalError.X, 2f)); |
850 | { | 852 | verticalError.Y = Math.Max(-2f, Math.Min(verticalError.Y, 2f)); |
851 | verticalError.X = 2.0f - verticalError.X; | 853 | |
852 | verticalError.Y = 2.0f - verticalError.Y; | ||
853 | } | ||
854 | // scale it by VAservo (timestep and timescale) | 854 | // scale it by VAservo (timestep and timescale) |
855 | verticalError = verticalError * VAservo; | 855 | verticalError = verticalError * VAservo; |
856 | 856 | ||
@@ -1013,10 +1013,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1013 | // Also remove any motion that is on the object so added motion is only from vehicle. | 1013 | // Also remove any motion that is on the object so added motion is only from vehicle. |
1014 | Vector3 applyAngularForce = ((m_lastAngularVelocity * pTimestep) | 1014 | Vector3 applyAngularForce = ((m_lastAngularVelocity * pTimestep) |
1015 | - Prim.ForceRotationalVelocity); | 1015 | - Prim.ForceRotationalVelocity); |
1016 | // Unscale the force by the angular factor so it overwhelmes the Bullet additions. | ||
1016 | Prim.ForceRotationalVelocity = applyAngularForce; | 1017 | Prim.ForceRotationalVelocity = applyAngularForce; |
1017 | 1018 | ||
1018 | VDetailLog("{0},MoveAngular,done,newRotVel={1},lastAngular={2}", | 1019 | VDetailLog("{0},MoveAngular,done,angMotor={1},vertAttr={2},bank={3},deflect={4},newAngForce={5},lastAngular={6}", |
1019 | Prim.LocalID, applyAngularForce, m_lastAngularVelocity); | 1020 | Prim.LocalID, |
1021 | angularMotorContribution, verticalAttractionContribution, | ||
1022 | bankingContribution, deflectionContribution, | ||
1023 | applyAngularForce, m_lastAngularVelocity | ||
1024 | ); | ||
1020 | } | 1025 | } |
1021 | } | 1026 | } |
1022 | 1027 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index caa6c46..c62c79a 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -1380,54 +1380,16 @@ public sealed class BSPrim : BSPhysObject | |||
1380 | 1380 | ||
1381 | public override void UpdateProperties(EntityProperties entprop) | 1381 | public override void UpdateProperties(EntityProperties entprop) |
1382 | { | 1382 | { |
1383 | /* | 1383 | // Updates only for individual prims and for the root object of a linkset. |
1384 | UpdatedProperties changed = 0; | 1384 | if (Linkset.IsRoot(this)) |
1385 | // assign to the local variables so the normal set action does not happen | ||
1386 | // if (_position != entprop.Position) | ||
1387 | if (!_position.ApproxEquals(entprop.Position, POSITION_TOLERANCE)) | ||
1388 | { | ||
1389 | _position = entprop.Position; | ||
1390 | changed |= UpdatedProperties.Position; | ||
1391 | } | ||
1392 | // if (_orientation != entprop.Rotation) | ||
1393 | if (!_orientation.ApproxEquals(entprop.Rotation, ROTATION_TOLERANCE)) | ||
1394 | { | ||
1395 | _orientation = entprop.Rotation; | ||
1396 | changed |= UpdatedProperties.Rotation; | ||
1397 | } | ||
1398 | // if (_velocity != entprop.Velocity) | ||
1399 | if (!_velocity.ApproxEquals(entprop.Velocity, VELOCITY_TOLERANCE)) | ||
1400 | { | ||
1401 | _velocity = entprop.Velocity; | ||
1402 | changed |= UpdatedProperties.Velocity; | ||
1403 | } | ||
1404 | // if (_acceleration != entprop.Acceleration) | ||
1405 | if (!_acceleration.ApproxEquals(entprop.Acceleration, ACCELERATION_TOLERANCE)) | ||
1406 | { | ||
1407 | _acceleration = entprop.Acceleration; | ||
1408 | changed |= UpdatedProperties.Acceleration; | ||
1409 | } | ||
1410 | // if (_rotationalVelocity != entprop.RotationalVelocity) | ||
1411 | if (!_rotationalVelocity.ApproxEquals(entprop.RotationalVelocity, ROTATIONAL_VELOCITY_TOLERANCE)) | ||
1412 | { | ||
1413 | _rotationalVelocity = entprop.RotationalVelocity; | ||
1414 | changed |= UpdatedProperties.RotationalVel; | ||
1415 | } | ||
1416 | if (changed != 0) | ||
1417 | { | 1385 | { |
1418 | // Only update the position of single objects and linkset roots | 1386 | // A temporary kludge to suppress the rotational effects introduced on vehicles by Bullet |
1419 | if (Linkset.IsRoot(this)) | 1387 | // TODO: handle physics introduced by Bullet with computed vehicle physics. |
1388 | if (_vehicle.IsActive) | ||
1420 | { | 1389 | { |
1421 | base.RequestPhysicsterseUpdate(); | 1390 | entprop.RotationalVelocity = OMV.Vector3.Zero; |
1422 | } | 1391 | } |
1423 | } | ||
1424 | */ | ||
1425 | |||
1426 | // Don't check for damping here -- it's done in BulletSim and SceneObjectPart. | ||
1427 | 1392 | ||
1428 | // Updates only for individual prims and for the root object of a linkset. | ||
1429 | if (Linkset.IsRoot(this)) | ||
1430 | { | ||
1431 | // Assign directly to the local variables so the normal set action does not happen | 1393 | // Assign directly to the local variables so the normal set action does not happen |
1432 | _position = entprop.Position; | 1394 | _position = entprop.Position; |
1433 | _orientation = entprop.Rotation; | 1395 | _orientation = entprop.Rotation; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 805e670..09b1423 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -515,9 +515,9 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
515 | collidersCount = 0; | 515 | collidersCount = 0; |
516 | } | 516 | } |
517 | 517 | ||
518 | // Don't have to use the pointers passed back since we know it is the same pinned memory we passed in | 518 | // Don't have to use the pointers passed back since we know it is the same pinned memory we passed in. |
519 | 519 | ||
520 | // Get a value for 'now' so all the collision and update routines don't have to get their own | 520 | // Get a value for 'now' so all the collision and update routines don't have to get their own. |
521 | SimulationNowTime = Util.EnvironmentTickCount(); | 521 | SimulationNowTime = Util.EnvironmentTickCount(); |
522 | 522 | ||
523 | // If there were collisions, process them by sending the event to the prim. | 523 | // If there were collisions, process them by sending the event to the prim. |
@@ -563,6 +563,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
563 | ObjectsWithCollisions.Remove(po); | 563 | ObjectsWithCollisions.Remove(po); |
564 | ObjectsWithNoMoreCollisions.Clear(); | 564 | ObjectsWithNoMoreCollisions.Clear(); |
565 | } | 565 | } |
566 | // Done with collisions. | ||
566 | 567 | ||
567 | // If any of the objects had updated properties, tell the object it has been changed by the physics engine | 568 | // If any of the objects had updated properties, tell the object it has been changed by the physics engine |
568 | if (updatedEntityCount > 0) | 569 | if (updatedEntityCount > 0) |
@@ -586,9 +587,8 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
586 | 587 | ||
587 | // The physics engine returns the number of milliseconds it simulated this call. | 588 | // The physics engine returns the number of milliseconds it simulated this call. |
588 | // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS. | 589 | // These are summed and normalized to one second and divided by 1000 to give the reported physics FPS. |
589 | // We multiply by 55 to give a recognizable running rate (55 or less). | 590 | // Multiply by 55 to give a nominal frame rate of 55. |
590 | return numSubSteps * m_fixedTimeStep * 1000 * 55; | 591 | return (float)numSubSteps * m_fixedTimeStep * 1000f * 55f; |
591 | // return timeStep * 1000 * 55; | ||
592 | } | 592 | } |
593 | 593 | ||
594 | // Something has collided | 594 | // Something has collided |
@@ -1172,7 +1172,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters | |||
1172 | (s) => { return s.m_params[0].avatarFriction; }, | 1172 | (s) => { return s.m_params[0].avatarFriction; }, |
1173 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarFriction, p, l, v); } ), | 1173 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarFriction, p, l, v); } ), |
1174 | new ParameterDefn("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.", | 1174 | new ParameterDefn("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.", |
1175 | 0.99f, | 1175 | 10.0f, |
1176 | (s,cf,p,v) => { s.m_params[0].avatarStandingFriction = cf.GetFloat(p, v); }, | 1176 | (s,cf,p,v) => { s.m_params[0].avatarStandingFriction = cf.GetFloat(p, v); }, |
1177 | (s) => { return s.m_params[0].avatarStandingFriction; }, | 1177 | (s) => { return s.m_params[0].avatarStandingFriction; }, |
1178 | (s,p,l,v) => { s.m_params[0].avatarStandingFriction = v; } ), | 1178 | (s,p,l,v) => { s.m_params[0].avatarStandingFriction = v; } ), |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 12baee9..1e003e6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | |||
@@ -357,7 +357,7 @@ public enum CollisionFlags : uint | |||
357 | CF_CHARACTER_OBJECT = 1 << 4, | 357 | CF_CHARACTER_OBJECT = 1 << 4, |
358 | CF_DISABLE_VISUALIZE_OBJECT = 1 << 5, | 358 | CF_DISABLE_VISUALIZE_OBJECT = 1 << 5, |
359 | CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6, | 359 | CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6, |
360 | // Following used by BulletSim to control collisions | 360 | // Following used by BulletSim to control collisions and updates |
361 | BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10, | 361 | BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10, |
362 | BS_FLOATS_ON_WATER = 1 << 11, | 362 | BS_FLOATS_ON_WATER = 1 << 11, |
363 | BS_NONE = 0, | 363 | BS_NONE = 0, |