aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs4
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs82
2 files changed, 57 insertions, 29 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 21d47aa..4715558 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -5216,6 +5216,10 @@ namespace OpenSim.Region.Framework.Scenes
5216 return null; 5216 return null;
5217 } 5217 }
5218 5218
5219 // Get terrain height at the specified <x,y> location.
5220 // Presumes the underlying implementation is a heightmap which is a 1m grid.
5221 // Finds heightmap grid points before and after the point and
5222 // does a linear approximation of the height at this intermediate point.
5219 public float GetGroundHeight(float x, float y) 5223 public float GetGroundHeight(float x, float y)
5220 { 5224 {
5221 if (x < 0) 5225 if (x < 0)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 2bf32e7..a4ef709 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -76,8 +76,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
76 private Vector3 m_linearMotorOffset = Vector3.Zero; // the point of force can be offset from the center 76 private Vector3 m_linearMotorOffset = Vector3.Zero; // the point of force can be offset from the center
77 private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL 77 private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL
78 private Vector3 m_linearFrictionTimescale = Vector3.Zero; 78 private Vector3 m_linearFrictionTimescale = Vector3.Zero;
79 private float m_linearMotorDecayTimescale = 0; 79 private float m_linearMotorDecayTimescale = 1;
80 private float m_linearMotorTimescale = 0; 80 private float m_linearMotorTimescale = 1;
81 private Vector3 m_lastLinearVelocityVector = Vector3.Zero; 81 private Vector3 m_lastLinearVelocityVector = Vector3.Zero;
82 private Vector3 m_lastPositionVector = Vector3.Zero; 82 private Vector3 m_lastPositionVector = Vector3.Zero;
83 // private bool m_LinearMotorSetLastFrame = false; 83 // private bool m_LinearMotorSetLastFrame = false;
@@ -88,8 +88,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
88 private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor 88 private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor
89 // private int m_angularMotorApply = 0; // application frame counter 89 // private int m_angularMotorApply = 0; // application frame counter
90 private Vector3 m_angularMotorVelocity = Vector3.Zero; // current angular motor velocity 90 private Vector3 m_angularMotorVelocity = Vector3.Zero; // current angular motor velocity
91 private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate 91 private float m_angularMotorTimescale = 1; // motor angular velocity ramp up rate
92 private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate 92 private float m_angularMotorDecayTimescale = 1; // motor angular velocity decay rate
93 private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate 93 private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate
94 private Vector3 m_lastAngularVelocity = Vector3.Zero; 94 private Vector3 m_lastAngularVelocity = Vector3.Zero;
95 private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body 95 private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body
@@ -103,7 +103,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
103 103
104 //Banking properties 104 //Banking properties
105 private float m_bankingEfficiency = 0; 105 private float m_bankingEfficiency = 0;
106 private float m_bankingMix = 0; 106 private float m_bankingMix = 1;
107 private float m_bankingTimescale = 0; 107 private float m_bankingTimescale = 0;
108 108
109 //Hover and Buoyancy properties 109 //Hover and Buoyancy properties
@@ -124,8 +124,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
124 private float m_verticalAttractionTimescale = 510f; 124 private float m_verticalAttractionTimescale = 510f;
125 125
126 // Just some recomputed constants: 126 // Just some recomputed constants:
127 static readonly float PIOverFour = ((float)Math.PI) / 4f;
128#pragma warning disable 414 127#pragma warning disable 414
128 static readonly float TwoPI = ((float)Math.PI) * 2f;
129 static readonly float FourPI = ((float)Math.PI) * 4f;
130 static readonly float PIOverFour = ((float)Math.PI) / 4f;
129 static readonly float PIOverTwo = ((float)Math.PI) / 2f; 131 static readonly float PIOverTwo = ((float)Math.PI) / 2f;
130#pragma warning restore 414 132#pragma warning restore 414
131 133
@@ -159,56 +161,58 @@ namespace OpenSim.Region.Physics.BulletSPlugin
159 public void ProcessFloatVehicleParam(Vehicle pParam, float pValue) 161 public void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
160 { 162 {
161 VDetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", ControllingPrim.LocalID, pParam, pValue); 163 VDetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", ControllingPrim.LocalID, pParam, pValue);
164 float clampTemp;
165
162 switch (pParam) 166 switch (pParam)
163 { 167 {
164 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: 168 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY:
165 m_angularDeflectionEfficiency = ClampInRange(0f, pValue, 1f); 169 m_angularDeflectionEfficiency = ClampInRange(0f, pValue, 1f);
166 break; 170 break;
167 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: 171 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE:
168 m_angularDeflectionTimescale = Math.Max(pValue, 0.01f); 172 m_angularDeflectionTimescale = ClampInRange(0.25f, pValue, 120);
169 break; 173 break;
170 case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: 174 case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE:
171 m_angularMotorDecayTimescale = ClampInRange(0.01f, pValue, 120); 175 m_angularMotorDecayTimescale = ClampInRange(0.25f, pValue, 120);
172 m_angularMotor.TargetValueDecayTimeScale = m_angularMotorDecayTimescale; 176 m_angularMotor.TargetValueDecayTimeScale = m_angularMotorDecayTimescale;
173 break; 177 break;
174 case Vehicle.ANGULAR_MOTOR_TIMESCALE: 178 case Vehicle.ANGULAR_MOTOR_TIMESCALE:
175 m_angularMotorTimescale = Math.Max(pValue, 0.01f); 179 m_angularMotorTimescale = ClampInRange(0.25f, pValue, 120);
176 m_angularMotor.TimeScale = m_angularMotorTimescale; 180 m_angularMotor.TimeScale = m_angularMotorTimescale;
177 break; 181 break;
178 case Vehicle.BANKING_EFFICIENCY: 182 case Vehicle.BANKING_EFFICIENCY:
179 m_bankingEfficiency = ClampInRange(-1f, pValue, 1f); 183 m_bankingEfficiency = ClampInRange(-1f, pValue, 1f);
180 break; 184 break;
181 case Vehicle.BANKING_MIX: 185 case Vehicle.BANKING_MIX:
182 m_bankingMix = Math.Max(pValue, 0.01f); 186 m_bankingMix = ClampInRange(0.01f, pValue, 1);
183 break; 187 break;
184 case Vehicle.BANKING_TIMESCALE: 188 case Vehicle.BANKING_TIMESCALE:
185 m_bankingTimescale = Math.Max(pValue, 0.01f); 189 m_bankingTimescale = ClampInRange(0.25f, pValue, 120);
186 break; 190 break;
187 case Vehicle.BUOYANCY: 191 case Vehicle.BUOYANCY:
188 m_VehicleBuoyancy = ClampInRange(-1f, pValue, 1f); 192 m_VehicleBuoyancy = ClampInRange(-1f, pValue, 1f);
189 m_VehicleGravity = ControllingPrim.ComputeGravity(m_VehicleBuoyancy); 193 m_VehicleGravity = ControllingPrim.ComputeGravity(m_VehicleBuoyancy);
190 break; 194 break;
191 case Vehicle.HOVER_EFFICIENCY: 195 case Vehicle.HOVER_EFFICIENCY:
192 m_VhoverEfficiency = ClampInRange(0f, pValue, 1f); 196 m_VhoverEfficiency = ClampInRange(0.01f, pValue, 1f);
193 break; 197 break;
194 case Vehicle.HOVER_HEIGHT: 198 case Vehicle.HOVER_HEIGHT:
195 m_VhoverHeight = pValue; 199 m_VhoverHeight = ClampInRange(0f, pValue, 1000000f);
196 break; 200 break;
197 case Vehicle.HOVER_TIMESCALE: 201 case Vehicle.HOVER_TIMESCALE:
198 m_VhoverTimescale = Math.Max(pValue, 0.01f); 202 m_VhoverTimescale = ClampInRange(0.01f, pValue, 120);
199 break; 203 break;
200 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: 204 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY:
201 m_linearDeflectionEfficiency = ClampInRange(0f, pValue, 1f); 205 m_linearDeflectionEfficiency = ClampInRange(0f, pValue, 1f);
202 break; 206 break;
203 case Vehicle.LINEAR_DEFLECTION_TIMESCALE: 207 case Vehicle.LINEAR_DEFLECTION_TIMESCALE:
204 m_linearDeflectionTimescale = Math.Max(pValue, 0.01f); 208 m_linearDeflectionTimescale = ClampInRange(0.01f, pValue, 120);
205 break; 209 break;
206 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: 210 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
207 m_linearMotorDecayTimescale = ClampInRange(0.01f, pValue, 120); 211 m_linearMotorDecayTimescale = ClampInRange(0.01f, pValue, 120);
208 m_linearMotor.TargetValueDecayTimeScale = m_linearMotorDecayTimescale; 212 m_linearMotor.TargetValueDecayTimeScale = m_linearMotorDecayTimescale;
209 break; 213 break;
210 case Vehicle.LINEAR_MOTOR_TIMESCALE: 214 case Vehicle.LINEAR_MOTOR_TIMESCALE:
211 m_linearMotorTimescale = Math.Max(pValue, 0.01f); 215 m_linearMotorTimescale = ClampInRange(0.01f, pValue, 120);
212 m_linearMotor.TimeScale = m_linearMotorTimescale; 216 m_linearMotor.TimeScale = m_linearMotorTimescale;
213 break; 217 break;
214 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: 218 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY:
@@ -216,30 +220,35 @@ namespace OpenSim.Region.Physics.BulletSPlugin
216 m_verticalAttractionMotor.Efficiency = m_verticalAttractionEfficiency; 220 m_verticalAttractionMotor.Efficiency = m_verticalAttractionEfficiency;
217 break; 221 break;
218 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: 222 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE:
219 m_verticalAttractionTimescale = Math.Max(pValue, 0.01f); 223 m_verticalAttractionTimescale = ClampInRange(0.01f, pValue, 120);
220 m_verticalAttractionMotor.TimeScale = m_verticalAttractionTimescale; 224 m_verticalAttractionMotor.TimeScale = m_verticalAttractionTimescale;
221 break; 225 break;
222 226
223 // These are vector properties but the engine lets you use a single float value to 227 // These are vector properties but the engine lets you use a single float value to
224 // set all of the components to the same value 228 // set all of the components to the same value
225 case Vehicle.ANGULAR_FRICTION_TIMESCALE: 229 case Vehicle.ANGULAR_FRICTION_TIMESCALE:
226 m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue); 230 clampTemp = ClampInRange(0.01f, pValue, 120);
231 m_angularFrictionTimescale = new Vector3(clampTemp, clampTemp, clampTemp);
227 break; 232 break;
228 case Vehicle.ANGULAR_MOTOR_DIRECTION: 233 case Vehicle.ANGULAR_MOTOR_DIRECTION:
229 m_angularMotorDirection = new Vector3(pValue, pValue, pValue); 234 clampTemp = ClampInRange(-TwoPI, pValue, TwoPI);
235 m_angularMotorDirection = new Vector3(clampTemp, clampTemp, clampTemp);
230 m_angularMotor.Zero(); 236 m_angularMotor.Zero();
231 m_angularMotor.SetTarget(m_angularMotorDirection); 237 m_angularMotor.SetTarget(m_angularMotorDirection);
232 break; 238 break;
233 case Vehicle.LINEAR_FRICTION_TIMESCALE: 239 case Vehicle.LINEAR_FRICTION_TIMESCALE:
234 m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); 240 clampTemp = ClampInRange(0.01f, pValue, 120);
241 m_linearFrictionTimescale = new Vector3(clampTemp, clampTemp, clampTemp);
235 break; 242 break;
236 case Vehicle.LINEAR_MOTOR_DIRECTION: 243 case Vehicle.LINEAR_MOTOR_DIRECTION:
237 m_linearMotorDirection = new Vector3(pValue, pValue, pValue); 244 clampTemp = ClampInRange(-BSParam.MaxLinearVelocity, pValue, BSParam.MaxLinearVelocity);
238 m_linearMotorDirectionLASTSET = new Vector3(pValue, pValue, pValue); 245 m_linearMotorDirection = new Vector3(clampTemp, clampTemp, clampTemp);
246 m_linearMotorDirectionLASTSET = new Vector3(clampTemp, clampTemp, clampTemp);
239 m_linearMotor.SetTarget(m_linearMotorDirection); 247 m_linearMotor.SetTarget(m_linearMotorDirection);
240 break; 248 break;
241 case Vehicle.LINEAR_MOTOR_OFFSET: 249 case Vehicle.LINEAR_MOTOR_OFFSET:
242 m_linearMotorOffset = new Vector3(pValue, pValue, pValue); 250 clampTemp = ClampInRange(-1000, pValue, 1000);
251 m_linearMotorOffset = new Vector3(clampTemp, clampTemp, clampTemp);
243 break; 252 break;
244 253
245 } 254 }
@@ -251,29 +260,46 @@ namespace OpenSim.Region.Physics.BulletSPlugin
251 switch (pParam) 260 switch (pParam)
252 { 261 {
253 case Vehicle.ANGULAR_FRICTION_TIMESCALE: 262 case Vehicle.ANGULAR_FRICTION_TIMESCALE:
263 pValue.X = ClampInRange(0.25f, pValue.X, 120);
264 pValue.Y = ClampInRange(0.25f, pValue.Y, 120);
265 pValue.Z = ClampInRange(0.25f, pValue.Z, 120);
254 m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); 266 m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
255 break; 267 break;
256 case Vehicle.ANGULAR_MOTOR_DIRECTION: 268 case Vehicle.ANGULAR_MOTOR_DIRECTION:
257 // Limit requested angular speed to 2 rps= 4 pi rads/sec 269 // Limit requested angular speed to 2 rps= 4 pi rads/sec
258 pValue.X = ClampInRange(-12.56f, pValue.X, 12.56f); 270 pValue.X = ClampInRange(-FourPI, pValue.X, FourPI);
259 pValue.Y = ClampInRange(-12.56f, pValue.Y, 12.56f); 271 pValue.Y = ClampInRange(-FourPI, pValue.Y, FourPI);
260 pValue.Z = ClampInRange(-12.56f, pValue.Z, 12.56f); 272 pValue.Z = ClampInRange(-FourPI, pValue.Z, FourPI);
261 m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); 273 m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
262 m_angularMotor.Zero(); 274 m_angularMotor.Zero();
263 m_angularMotor.SetTarget(m_angularMotorDirection); 275 m_angularMotor.SetTarget(m_angularMotorDirection);
264 break; 276 break;
265 case Vehicle.LINEAR_FRICTION_TIMESCALE: 277 case Vehicle.LINEAR_FRICTION_TIMESCALE:
278 pValue.X = ClampInRange(0.25f, pValue.X, 120);
279 pValue.Y = ClampInRange(0.25f, pValue.Y, 120);
280 pValue.Z = ClampInRange(0.25f, pValue.Z, 120);
266 m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); 281 m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
267 break; 282 break;
268 case Vehicle.LINEAR_MOTOR_DIRECTION: 283 case Vehicle.LINEAR_MOTOR_DIRECTION:
284 pValue.X = ClampInRange(-BSParam.MaxLinearVelocity, pValue.X, BSParam.MaxLinearVelocity);
285 pValue.Y = ClampInRange(-BSParam.MaxLinearVelocity, pValue.Y, BSParam.MaxLinearVelocity);
286 pValue.Z = ClampInRange(-BSParam.MaxLinearVelocity, pValue.Z, BSParam.MaxLinearVelocity);
269 m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); 287 m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
270 m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z); 288 m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z);
271 m_linearMotor.SetTarget(m_linearMotorDirection); 289 m_linearMotor.SetTarget(m_linearMotorDirection);
272 break; 290 break;
273 case Vehicle.LINEAR_MOTOR_OFFSET: 291 case Vehicle.LINEAR_MOTOR_OFFSET:
292 // Not sure the correct range to limit this variable
293 pValue.X = ClampInRange(-1000, pValue.X, 1000);
294 pValue.Y = ClampInRange(-1000, pValue.Y, 1000);
295 pValue.Z = ClampInRange(-1000, pValue.Z, 1000);
274 m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); 296 m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z);
275 break; 297 break;
276 case Vehicle.BLOCK_EXIT: 298 case Vehicle.BLOCK_EXIT:
299 // Not sure the correct range to limit this variable
300 pValue.X = ClampInRange(-10000, pValue.X, 10000);
301 pValue.Y = ClampInRange(-10000, pValue.Y, 10000);
302 pValue.Z = ClampInRange(-10000, pValue.Z, 10000);
277 m_BlockingEndPoint = new Vector3(pValue.X, pValue.Y, pValue.Z); 303 m_BlockingEndPoint = new Vector3(pValue.X, pValue.Y, pValue.Z);
278 break; 304 break;
279 } 305 }
@@ -1601,7 +1627,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1601 deflectContributionV = (-deflectionError) * ClampInRange(0, m_angularDeflectionEfficiency/m_angularDeflectionTimescale,1f); 1627 deflectContributionV = (-deflectionError) * ClampInRange(0, m_angularDeflectionEfficiency/m_angularDeflectionTimescale,1f);
1602 //deflectContributionV /= m_angularDeflectionTimescale; 1628 //deflectContributionV /= m_angularDeflectionTimescale;
1603 1629
1604 // VehicleRotationalVelocity += deflectContributionV * VehicleOrientation;
1605 VehicleRotationalVelocity += deflectContributionV; 1630 VehicleRotationalVelocity += deflectContributionV;
1606 VDetailLog("{0}, MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}", 1631 VDetailLog("{0}, MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}",
1607 ControllingPrim.LocalID, movingDirection, pointingDirection, deflectionError, deflectContributionV); 1632 ControllingPrim.LocalID, movingDirection, pointingDirection, deflectionError, deflectContributionV);
@@ -1659,7 +1684,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1659 1684
1660 // TODO: the banking effect should not go to infinity but what to limit it to? 1685 // TODO: the banking effect should not go to infinity but what to limit it to?
1661 // And what should happen when this is being added to a user defined yaw that is already PI*4? 1686 // And what should happen when this is being added to a user defined yaw that is already PI*4?
1662 mixedYawAngle = ClampInRange(-12, mixedYawAngle, 12); 1687 mixedYawAngle = ClampInRange(-FourPI, mixedYawAngle, FourPI);
1663 1688
1664 // Build the force vector to change rotation from what it is to what it should be 1689 // Build the force vector to change rotation from what it is to what it should be
1665 bankingContributionV.Z = -mixedYawAngle; 1690 bankingContributionV.Z = -mixedYawAngle;
@@ -1667,7 +1692,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1667 // Don't do it all at once. Fudge because 1 second is too fast with most user defined roll as PI*4. 1692 // Don't do it all at once. Fudge because 1 second is too fast with most user defined roll as PI*4.
1668 bankingContributionV /= m_bankingTimescale * BSParam.VehicleAngularBankingTimescaleFudge; 1693 bankingContributionV /= m_bankingTimescale * BSParam.VehicleAngularBankingTimescaleFudge;
1669 1694
1670 //VehicleRotationalVelocity += bankingContributionV * VehicleOrientation;
1671 VehicleRotationalVelocity += bankingContributionV; 1695 VehicleRotationalVelocity += bankingContributionV;
1672 1696
1673 1697