aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2012-08-17 09:37:02 -0700
committerRobert Adams2012-08-17 13:34:16 -0700
commit8eda290262bb7049aa55a7df2bdb1565bad85a99 (patch)
treef58fa1a710a6156beb04fa309b8b16798c9cb2db /OpenSim/Region
parentBulletSim: in BSDynamics, merge 'flags' and 'hoverFlags' as they are defined ... (diff)
downloadopensim-SC_OLD-8eda290262bb7049aa55a7df2bdb1565bad85a99.zip
opensim-SC_OLD-8eda290262bb7049aa55a7df2bdb1565bad85a99.tar.gz
opensim-SC_OLD-8eda290262bb7049aa55a7df2bdb1565bad85a99.tar.bz2
opensim-SC_OLD-8eda290262bb7049aa55a7df2bdb1565bad85a99.tar.xz
BulletSim: comments and parameter changes in dynamics engine.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs50
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs6
2 files changed, 30 insertions, 26 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 78bfa05..d7213fc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -57,6 +57,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
57 private int frcount = 0; // Used to limit dynamics debug output to 57 private int frcount = 0; // Used to limit dynamics debug output to
58 // every 100th frame 58 // every 100th frame
59 59
60 private BSScene m_physicsScene;
60 private BSPrim m_prim; // the prim this dynamic controller belongs to 61 private BSPrim m_prim; // the prim this dynamic controller belongs to
61 62
62 // Vehicle properties 63 // Vehicle properties
@@ -123,15 +124,16 @@ namespace OpenSim.Region.Physics.BulletSPlugin
123 private float m_verticalAttractionEfficiency = 1.0f; // damped 124 private float m_verticalAttractionEfficiency = 1.0f; // damped
124 private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. 125 private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor.
125 126
126 public BSDynamics(BSPrim myPrim) 127 public BSDynamics(BSScene myScene, BSPrim myPrim)
127 { 128 {
129 m_physicsScene = myScene;
128 m_prim = myPrim; 130 m_prim = myPrim;
129 m_type = Vehicle.TYPE_NONE; 131 m_type = Vehicle.TYPE_NONE;
130 } 132 }
131 133
132 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue, float timestep) 134 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue, float timestep)
133 { 135 {
134 DetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); 136 VDetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
135 switch (pParam) 137 switch (pParam)
136 { 138 {
137 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: 139 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY:
@@ -230,7 +232,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
230 232
231 internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue, float timestep) 233 internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue, float timestep)
232 { 234 {
233 DetailLog("{0},ProcessVectorVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); 235 VDetailLog("{0},ProcessVectorVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
234 switch (pParam) 236 switch (pParam)
235 { 237 {
236 case Vehicle.ANGULAR_FRICTION_TIMESCALE: 238 case Vehicle.ANGULAR_FRICTION_TIMESCALE:
@@ -265,7 +267,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
265 267
266 internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) 268 internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue)
267 { 269 {
268 DetailLog("{0},ProcessRotationalVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); 270 VDetailLog("{0},ProcessRotationalVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
269 switch (pParam) 271 switch (pParam)
270 { 272 {
271 case Vehicle.REFERENCE_FRAME: 273 case Vehicle.REFERENCE_FRAME:
@@ -279,7 +281,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
279 281
280 internal void ProcessVehicleFlags(int pParam, bool remove) 282 internal void ProcessVehicleFlags(int pParam, bool remove)
281 { 283 {
282 DetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", m_prim.LocalID, pParam, remove); 284 VDetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", m_prim.LocalID, pParam, remove);
283 VehicleFlag parm = (VehicleFlag)pParam; 285 VehicleFlag parm = (VehicleFlag)pParam;
284 if (remove) 286 if (remove)
285 { 287 {
@@ -297,9 +299,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
297 } 299 }
298 }//end ProcessVehicleFlags 300 }//end ProcessVehicleFlags
299 301
300 internal void ProcessTypeChange(Vehicle pType) 302 internal void ProcessTypeChange(Vehicle pType, float stepSize)
301 { 303 {
302 DetailLog("{0},ProcessTypeChange,type={1}", m_prim.LocalID, pType); 304 VDetailLog("{0},ProcessTypeChange,type={1}", m_prim.LocalID, pType);
303 // Set Defaults For Type 305 // Set Defaults For Type
304 m_type = pType; 306 m_type = pType;
305 switch (pType) 307 switch (pType)
@@ -475,7 +477,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
475 MoveAngular(pTimestep); 477 MoveAngular(pTimestep);
476 LimitRotation(pTimestep); 478 LimitRotation(pTimestep);
477 479
478 DetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", 480 VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}",
479 m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity); 481 m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity);
480 }// end Step 482 }// end Step
481 483
@@ -519,7 +521,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
519 521
520 */ 522 */
521 523
522 DetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},decay={4},dir={5},vel={6}", 524 VDetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},decay={4},dir={5},vel={6}",
523 m_prim.LocalID, origDir, origVel, addAmount, decayfraction, m_linearMotorDirection, m_lastLinearVelocityVector); 525 m_prim.LocalID, origDir, origVel, addAmount, decayfraction, m_linearMotorDirection, m_lastLinearVelocityVector);
524 } 526 }
525 else 527 else
@@ -531,7 +533,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
531 m_lastLinearVelocityVector = Vector3.Zero; 533 m_lastLinearVelocityVector = Vector3.Zero;
532 } 534 }
533 535
534 // convert requested object velocity to world-referenced vector 536 // convert requested object velocity to object relative vector
535 Quaternion rotq = m_prim.Orientation; 537 Quaternion rotq = m_prim.Orientation;
536 m_dir = m_lastLinearVelocityVector * rotq; 538 m_dir = m_lastLinearVelocityVector * rotq;
537 539
@@ -584,7 +586,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
584 if (changed) 586 if (changed)
585 { 587 {
586 m_prim.Position = pos; 588 m_prim.Position = pos;
587 DetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}", 589 VDetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}",
588 m_prim.LocalID, m_BlockingEndPoint, posChange, pos); 590 m_prim.LocalID, m_BlockingEndPoint, posChange, pos);
589 } 591 }
590 } 592 }
@@ -594,7 +596,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
594 { 596 {
595 pos.Z = m_prim.Scene.GetTerrainHeightAtXYZ(pos) + 2; 597 pos.Z = m_prim.Scene.GetTerrainHeightAtXYZ(pos) + 2;
596 m_prim.Position = pos; 598 m_prim.Position = pos;
597 DetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos); 599 VDetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos);
598 } 600 }
599 601
600 // Check if hovering 602 // Check if hovering
@@ -641,7 +643,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
641 } 643 }
642 } 644 }
643 645
644 DetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_dir, m_VhoverHeight, m_VhoverTargetHeight); 646 VDetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_dir, m_VhoverHeight, m_VhoverTargetHeight);
645 647
646// m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped 648// m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped
647// m_VhoverTimescale = 0f; // time to acheive height 649// m_VhoverTimescale = 0f; // time to acheive height
@@ -677,7 +679,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
677 { 679 {
678 grav.Z = (float)(grav.Z * 1.037125); 680 grav.Z = (float)(grav.Z * 1.037125);
679 } 681 }
680 DetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav); 682 VDetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav);
681 //End Experimental Values 683 //End Experimental Values
682 } 684 }
683 if ((m_flags & (VehicleFlag.NO_X)) != 0) 685 if ((m_flags & (VehicleFlag.NO_X)) != 0)
@@ -706,7 +708,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
706 Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep); 708 Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep);
707 m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount; 709 m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount;
708 710
709 DetailLog("{0},MoveLinear,done,pos={1},vel={2},force={3},decay={4}", 711 VDetailLog("{0},MoveLinear,done,pos={1},vel={2},force={3},decay={4}",
710 m_prim.LocalID, m_lastPositionVector, m_dir, grav, decayamount); 712 m_prim.LocalID, m_lastPositionVector, m_dir, grav, decayamount);
711 713
712 } // end MoveLinear() 714 } // end MoveLinear()
@@ -732,13 +734,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
732 // There are m_angularMotorApply steps. 734 // There are m_angularMotorApply steps.
733 Vector3 origAngularVelocity = m_angularMotorVelocity; 735 Vector3 origAngularVelocity = m_angularMotorVelocity;
734 // ramp up to new value 736 // ramp up to new value
735 // current velocity += error / (time to get there / step interval) 737 // current velocity += error / (time to get there / step interval)
736 // requested speed - last motor speed 738 // requested speed - last motor speed
737 m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep); 739 m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep);
738 m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); 740 m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep);
739 m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); 741 m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep);
740 742
741 DetailLog("{0},MoveAngular,angularMotorApply,apply={1},origvel={2},dir={3},vel={4}", 743 VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},origvel={2},dir={3},vel={4}",
742 m_prim.LocalID,m_angularMotorApply,origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity); 744 m_prim.LocalID,m_angularMotorApply,origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity);
743 745
744 m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected 746 m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected
@@ -749,6 +751,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
749 // No motor recently applied, keep the body velocity 751 // No motor recently applied, keep the body velocity
750 // and decay the velocity 752 // and decay the velocity
751 m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep); 753 m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep);
754 if (m_angularMotorVelocity.LengthSquared() < 0.00001)
755 m_angularMotorVelocity = Vector3.Zero;
752 } // end motor section 756 } // end motor section
753 757
754 // Vertical attractor section 758 // Vertical attractor section
@@ -786,7 +790,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
786 vertattr.X += bounce * angularVelocity.X; 790 vertattr.X += bounce * angularVelocity.X;
787 vertattr.Y += bounce * angularVelocity.Y; 791 vertattr.Y += bounce * angularVelocity.Y;
788 792
789 DetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}", 793 VDetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}",
790 m_prim.LocalID, verterr, bounce, vertattr); 794 m_prim.LocalID, verterr, bounce, vertattr);
791 795
792 } // else vertical attractor is off 796 } // else vertical attractor is off
@@ -804,13 +808,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
804 { 808 {
805 m_lastAngularVelocity.X = 0; 809 m_lastAngularVelocity.X = 0;
806 m_lastAngularVelocity.Y = 0; 810 m_lastAngularVelocity.Y = 0;
807 DetailLog("{0},MoveAngular,noDeflectionUp,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity); 811 VDetailLog("{0},MoveAngular,noDeflectionUp,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity);
808 } 812 }
809 813
810 if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) 814 if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
811 { 815 {
812 m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero. 816 m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero.
813 DetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity); 817 VDetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity);
814 } 818 }
815 819
816 // apply friction 820 // apply friction
@@ -820,7 +824,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
820 // Apply to the body 824 // Apply to the body
821 m_prim.RotationalVelocity = m_lastAngularVelocity; 825 m_prim.RotationalVelocity = m_lastAngularVelocity;
822 826
823 DetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", m_prim.LocalID, decayamount, m_lastAngularVelocity); 827 VDetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", m_prim.LocalID, decayamount, m_lastAngularVelocity);
824 } //end MoveAngular 828 } //end MoveAngular
825 829
826 internal void LimitRotation(float timestep) 830 internal void LimitRotation(float timestep)
@@ -867,11 +871,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
867 if (changed) 871 if (changed)
868 m_prim.Orientation = m_rot; 872 m_prim.Orientation = m_rot;
869 873
870 DetailLog("{0},LimitRotation,done,changed={1},orig={2},new={3}", m_prim.LocalID, changed, rotq, m_rot); 874 VDetailLog("{0},LimitRotation,done,changed={1},orig={2},new={3}", m_prim.LocalID, changed, rotq, m_rot);
871 } 875 }
872 876
873 // Invoke the detailed logger and output something if it's enabled. 877 // Invoke the detailed logger and output something if it's enabled.
874 private void DetailLog(string msg, params Object[] args) 878 private void VDetailLog(string msg, params Object[] args)
875 { 879 {
876 if (m_prim.Scene.VehicleLoggingEnabled) 880 if (m_prim.Scene.VehicleLoggingEnabled)
877 m_prim.Scene.PhysicsLogging.Write(msg, args); 881 m_prim.Scene.PhysicsLogging.Write(msg, args);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index c157669..b918f84 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -141,8 +141,8 @@ public sealed class BSPrim : PhysicsActor
141 _friction = _scene.Params.defaultFriction; // TODO: compute based on object material 141 _friction = _scene.Params.defaultFriction; // TODO: compute based on object material
142 _density = _scene.Params.defaultDensity; // TODO: compute based on object material 142 _density = _scene.Params.defaultDensity; // TODO: compute based on object material
143 _restitution = _scene.Params.defaultRestitution; 143 _restitution = _scene.Params.defaultRestitution;
144 _linkset = new BSLinkset(_scene, this); // a linkset of one 144 _linkset = new BSLinkset(Scene, this); // a linkset of one
145 _vehicle = new BSDynamics(this); // add vehicleness 145 _vehicle = new BSDynamics(Scene, this); // add vehicleness
146 _mass = CalculateMass(); 146 _mass = CalculateMass();
147 // do the actual object creation at taint time 147 // do the actual object creation at taint time
148 DetailLog("{0},BSPrim.constructor,call", LocalID); 148 DetailLog("{0},BSPrim.constructor,call", LocalID);
@@ -354,7 +354,7 @@ public sealed class BSPrim : PhysicsActor
354 { 354 {
355 // Done at taint time so we're sure the physics engine is not using the variables 355 // Done at taint time so we're sure the physics engine is not using the variables
356 // Vehicle code changes the parameters for this vehicle type. 356 // Vehicle code changes the parameters for this vehicle type.
357 _vehicle.ProcessTypeChange(type); 357 _vehicle.ProcessTypeChange(type, Scene.LastSimulatedTimestep);
358 // Tell the scene about the vehicle so it will get processing each frame. 358 // Tell the scene about the vehicle so it will get processing each frame.
359 _scene.VehicleInSceneTypeChanged(this, type); 359 _scene.VehicleInSceneTypeChanged(this, type);
360 }); 360 });