diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 216 |
1 files changed, 103 insertions, 113 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 4bc266b..7e2af78 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -101,21 +101,21 @@ public class BSPrim : BSPhysObject | |||
101 | _isVolumeDetect = false; | 101 | _isVolumeDetect = false; |
102 | 102 | ||
103 | // We keep a handle to the vehicle actor so we can set vehicle parameters later. | 103 | // We keep a handle to the vehicle actor so we can set vehicle parameters later. |
104 | VehicleActor = new BSDynamics(PhysicsScene, this, VehicleActorName); | 104 | VehicleActor = new BSDynamics(PhysScene, this, VehicleActorName); |
105 | PhysicalActors.Add(VehicleActorName, VehicleActor); | 105 | PhysicalActors.Add(VehicleActorName, VehicleActor); |
106 | 106 | ||
107 | _mass = CalculateMass(); | 107 | _mass = CalculateMass(); |
108 | 108 | ||
109 | // DetailLog("{0},BSPrim.constructor,call", LocalID); | 109 | // DetailLog("{0},BSPrim.constructor,call", LocalID); |
110 | // do the actual object creation at taint time | 110 | // do the actual object creation at taint time |
111 | PhysicsScene.TaintedObject("BSPrim.create", delegate() | 111 | PhysScene.TaintedObject("BSPrim.create", delegate() |
112 | { | 112 | { |
113 | // Make sure the object is being created with some sanity. | 113 | // Make sure the object is being created with some sanity. |
114 | ExtremeSanityCheck(true /* inTaintTime */); | 114 | ExtremeSanityCheck(true /* inTaintTime */); |
115 | 115 | ||
116 | CreateGeomAndObject(true); | 116 | CreateGeomAndObject(true); |
117 | 117 | ||
118 | CurrentCollisionFlags = PhysicsScene.PE.GetCollisionFlags(PhysBody); | 118 | CurrentCollisionFlags = PhysScene.PE.GetCollisionFlags(PhysBody); |
119 | }); | 119 | }); |
120 | } | 120 | } |
121 | 121 | ||
@@ -128,14 +128,14 @@ public class BSPrim : BSPhysObject | |||
128 | // Undo any vehicle properties | 128 | // Undo any vehicle properties |
129 | this.VehicleType = (int)Vehicle.TYPE_NONE; | 129 | this.VehicleType = (int)Vehicle.TYPE_NONE; |
130 | 130 | ||
131 | PhysicsScene.TaintedObject("BSPrim.Destroy", delegate() | 131 | PhysScene.TaintedObject("BSPrim.Destroy", delegate() |
132 | { | 132 | { |
133 | DetailLog("{0},BSPrim.Destroy,taint,", LocalID); | 133 | DetailLog("{0},BSPrim.Destroy,taint,", LocalID); |
134 | // If there are physical body and shape, release my use of same. | 134 | // If there are physical body and shape, release my use of same. |
135 | PhysicsScene.Shapes.DereferenceBody(PhysBody, null); | 135 | PhysScene.Shapes.DereferenceBody(PhysBody, null); |
136 | PhysBody.Clear(); | 136 | PhysBody.Clear(); |
137 | PhysicsScene.Shapes.DereferenceShape(PhysShape, null); | 137 | PhysShape.Dereference(PhysScene); |
138 | PhysShape.Clear(); | 138 | PhysShape = new BSShapeNull(); |
139 | }); | 139 | }); |
140 | } | 140 | } |
141 | 141 | ||
@@ -161,25 +161,13 @@ public class BSPrim : BSPhysObject | |||
161 | ForceBodyShapeRebuild(false); | 161 | ForceBodyShapeRebuild(false); |
162 | } | 162 | } |
163 | } | 163 | } |
164 | // 'unknown' says to choose the best type | ||
165 | public override BSPhysicsShapeType PreferredPhysicalShape | ||
166 | { get { return BSPhysicsShapeType.SHAPE_UNKNOWN; } } | ||
167 | |||
168 | public override bool ForceBodyShapeRebuild(bool inTaintTime) | 164 | public override bool ForceBodyShapeRebuild(bool inTaintTime) |
169 | { | 165 | { |
170 | if (inTaintTime) | 166 | PhysScene.TaintedObject(inTaintTime, "BSPrim.ForceBodyShapeRebuild", delegate() |
171 | { | 167 | { |
172 | _mass = CalculateMass(); // changing the shape changes the mass | 168 | _mass = CalculateMass(); // changing the shape changes the mass |
173 | CreateGeomAndObject(true); | 169 | CreateGeomAndObject(true); |
174 | } | 170 | }); |
175 | else | ||
176 | { | ||
177 | PhysicsScene.TaintedObject("BSPrim.ForceBodyShapeRebuild", delegate() | ||
178 | { | ||
179 | _mass = CalculateMass(); // changing the shape changes the mass | ||
180 | CreateGeomAndObject(true); | ||
181 | }); | ||
182 | } | ||
183 | return true; | 171 | return true; |
184 | } | 172 | } |
185 | public override bool Grabbed { | 173 | public override bool Grabbed { |
@@ -192,7 +180,7 @@ public class BSPrim : BSPhysObject | |||
192 | if (value != _isSelected) | 180 | if (value != _isSelected) |
193 | { | 181 | { |
194 | _isSelected = value; | 182 | _isSelected = value; |
195 | PhysicsScene.TaintedObject("BSPrim.setSelected", delegate() | 183 | PhysScene.TaintedObject("BSPrim.setSelected", delegate() |
196 | { | 184 | { |
197 | DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected); | 185 | DetailLog("{0},BSPrim.selected,taint,selected={1}", LocalID, _isSelected); |
198 | SetObjectDynamic(false); | 186 | SetObjectDynamic(false); |
@@ -238,23 +226,23 @@ public class BSPrim : BSPhysObject | |||
238 | _rotationalVelocity = OMV.Vector3.Zero; | 226 | _rotationalVelocity = OMV.Vector3.Zero; |
239 | 227 | ||
240 | // Zero some other properties in the physics engine | 228 | // Zero some other properties in the physics engine |
241 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() | 229 | PhysScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() |
242 | { | 230 | { |
243 | if (PhysBody.HasPhysicalBody) | 231 | if (PhysBody.HasPhysicalBody) |
244 | PhysicsScene.PE.ClearAllForces(PhysBody); | 232 | PhysScene.PE.ClearAllForces(PhysBody); |
245 | }); | 233 | }); |
246 | } | 234 | } |
247 | public override void ZeroAngularMotion(bool inTaintTime) | 235 | public override void ZeroAngularMotion(bool inTaintTime) |
248 | { | 236 | { |
249 | _rotationalVelocity = OMV.Vector3.Zero; | 237 | _rotationalVelocity = OMV.Vector3.Zero; |
250 | // Zero some other properties in the physics engine | 238 | // Zero some other properties in the physics engine |
251 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() | 239 | PhysScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() |
252 | { | 240 | { |
253 | // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); | 241 | // DetailLog("{0},BSPrim.ZeroAngularMotion,call,rotVel={1}", LocalID, _rotationalVelocity); |
254 | if (PhysBody.HasPhysicalBody) | 242 | if (PhysBody.HasPhysicalBody) |
255 | { | 243 | { |
256 | PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); | 244 | PhysScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); |
257 | PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); | 245 | PhysScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); |
258 | } | 246 | } |
259 | }); | 247 | }); |
260 | } | 248 | } |
@@ -272,11 +260,11 @@ public class BSPrim : BSPhysObject | |||
272 | 260 | ||
273 | EnableActor(LockedAxis != LockedAxisFree, LockedAxisActorName, delegate() | 261 | EnableActor(LockedAxis != LockedAxisFree, LockedAxisActorName, delegate() |
274 | { | 262 | { |
275 | return new BSActorLockAxis(PhysicsScene, this, LockedAxisActorName); | 263 | return new BSActorLockAxis(PhysScene, this, LockedAxisActorName); |
276 | }); | 264 | }); |
277 | 265 | ||
278 | // Update parameters so the new actor's Refresh() action is called at the right time. | 266 | // Update parameters so the new actor's Refresh() action is called at the right time. |
279 | PhysicsScene.TaintedObject("BSPrim.LockAngularMotion", delegate() | 267 | PhysScene.TaintedObject("BSPrim.LockAngularMotion", delegate() |
280 | { | 268 | { |
281 | UpdatePhysicalParameters(); | 269 | UpdatePhysicalParameters(); |
282 | }); | 270 | }); |
@@ -306,7 +294,7 @@ public class BSPrim : BSPhysObject | |||
306 | _position = value; | 294 | _position = value; |
307 | PositionSanityCheck(false); | 295 | PositionSanityCheck(false); |
308 | 296 | ||
309 | PhysicsScene.TaintedObject("BSPrim.setPosition", delegate() | 297 | PhysScene.TaintedObject("BSPrim.setPosition", delegate() |
310 | { | 298 | { |
311 | DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 299 | DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
312 | ForcePosition = _position; | 300 | ForcePosition = _position; |
@@ -316,14 +304,14 @@ public class BSPrim : BSPhysObject | |||
316 | 304 | ||
317 | public override OMV.Vector3 ForcePosition { | 305 | public override OMV.Vector3 ForcePosition { |
318 | get { | 306 | get { |
319 | _position = PhysicsScene.PE.GetPosition(PhysBody); | 307 | _position = PhysScene.PE.GetPosition(PhysBody); |
320 | return _position; | 308 | return _position; |
321 | } | 309 | } |
322 | set { | 310 | set { |
323 | _position = value; | 311 | _position = value; |
324 | if (PhysBody.HasPhysicalBody) | 312 | if (PhysBody.HasPhysicalBody) |
325 | { | 313 | { |
326 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); | 314 | PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); |
327 | ActivateIfPhysical(false); | 315 | ActivateIfPhysical(false); |
328 | } | 316 | } |
329 | } | 317 | } |
@@ -340,7 +328,7 @@ public class BSPrim : BSPhysObject | |||
340 | if (!IsPhysicallyActive) | 328 | if (!IsPhysicallyActive) |
341 | return ret; | 329 | return ret; |
342 | 330 | ||
343 | if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition)) | 331 | if (!PhysScene.TerrainManager.IsWithinKnownTerrain(RawPosition)) |
344 | { | 332 | { |
345 | // The physical object is out of the known/simulated area. | 333 | // The physical object is out of the known/simulated area. |
346 | // Upper levels of code will handle the transition to other areas so, for | 334 | // Upper levels of code will handle the transition to other areas so, for |
@@ -348,7 +336,7 @@ public class BSPrim : BSPhysObject | |||
348 | return ret; | 336 | return ret; |
349 | } | 337 | } |
350 | 338 | ||
351 | float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); | 339 | float terrainHeight = PhysScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); |
352 | OMV.Vector3 upForce = OMV.Vector3.Zero; | 340 | OMV.Vector3 upForce = OMV.Vector3.Zero; |
353 | float approxSize = Math.Max(Size.X, Math.Max(Size.Y, Size.Z)); | 341 | float approxSize = Math.Max(Size.X, Math.Max(Size.Y, Size.Z)); |
354 | if ((RawPosition.Z + approxSize / 2f) < terrainHeight) | 342 | if ((RawPosition.Z + approxSize / 2f) < terrainHeight) |
@@ -369,7 +357,7 @@ public class BSPrim : BSPhysObject | |||
369 | 357 | ||
370 | if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) | 358 | if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) |
371 | { | 359 | { |
372 | float waterHeight = PhysicsScene.TerrainManager.GetWaterLevelAtXYZ(_position); | 360 | float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(_position); |
373 | // TODO: a floating motor so object will bob in the water | 361 | // TODO: a floating motor so object will bob in the water |
374 | if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f) | 362 | if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f) |
375 | { | 363 | { |
@@ -377,7 +365,7 @@ public class BSPrim : BSPhysObject | |||
377 | upForce.Z = (waterHeight - RawPosition.Z) * 1f; | 365 | upForce.Z = (waterHeight - RawPosition.Z) * 1f; |
378 | 366 | ||
379 | // Apply upforce and overcome gravity. | 367 | // Apply upforce and overcome gravity. |
380 | OMV.Vector3 correctionForce = upForce - PhysicsScene.DefaultGravity; | 368 | OMV.Vector3 correctionForce = upForce - PhysScene.DefaultGravity; |
381 | DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, _position, upForce, correctionForce); | 369 | DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, _position, upForce, correctionForce); |
382 | AddForce(correctionForce, false, inTaintTime); | 370 | AddForce(correctionForce, false, inTaintTime); |
383 | ret = true; | 371 | ret = true; |
@@ -432,7 +420,7 @@ public class BSPrim : BSPhysObject | |||
432 | get { return _mass; } | 420 | get { return _mass; } |
433 | } | 421 | } |
434 | // used when we only want this prim's mass and not the linkset thing | 422 | // used when we only want this prim's mass and not the linkset thing |
435 | public override float RawMass { | 423 | public override float RawMass { |
436 | get { return _mass; } | 424 | get { return _mass; } |
437 | } | 425 | } |
438 | // Set the physical mass to the passed mass. | 426 | // Set the physical mass to the passed mass. |
@@ -443,10 +431,10 @@ public class BSPrim : BSPhysObject | |||
443 | { | 431 | { |
444 | if (IsStatic) | 432 | if (IsStatic) |
445 | { | 433 | { |
446 | PhysicsScene.PE.SetGravity(PhysBody, PhysicsScene.DefaultGravity); | 434 | PhysScene.PE.SetGravity(PhysBody, PhysScene.DefaultGravity); |
447 | Inertia = OMV.Vector3.Zero; | 435 | Inertia = OMV.Vector3.Zero; |
448 | PhysicsScene.PE.SetMassProps(PhysBody, 0f, Inertia); | 436 | PhysScene.PE.SetMassProps(PhysBody, 0f, Inertia); |
449 | PhysicsScene.PE.UpdateInertiaTensor(PhysBody); | 437 | PhysScene.PE.UpdateInertiaTensor(PhysBody); |
450 | } | 438 | } |
451 | else | 439 | else |
452 | { | 440 | { |
@@ -455,16 +443,16 @@ public class BSPrim : BSPhysObject | |||
455 | // Changing interesting properties doesn't change proxy and collision cache | 443 | // Changing interesting properties doesn't change proxy and collision cache |
456 | // information. The Bullet solution is to re-add the object to the world | 444 | // information. The Bullet solution is to re-add the object to the world |
457 | // after parameters are changed. | 445 | // after parameters are changed. |
458 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); | 446 | PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody); |
459 | } | 447 | } |
460 | 448 | ||
461 | // The computation of mass props requires gravity to be set on the object. | 449 | // The computation of mass props requires gravity to be set on the object. |
462 | Gravity = ComputeGravity(Buoyancy); | 450 | Gravity = ComputeGravity(Buoyancy); |
463 | PhysicsScene.PE.SetGravity(PhysBody, Gravity); | 451 | PhysScene.PE.SetGravity(PhysBody, Gravity); |
464 | 452 | ||
465 | Inertia = PhysicsScene.PE.CalculateLocalInertia(PhysShape, physMass); | 453 | Inertia = PhysScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass); |
466 | PhysicsScene.PE.SetMassProps(PhysBody, physMass, Inertia); | 454 | PhysScene.PE.SetMassProps(PhysBody, physMass, Inertia); |
467 | PhysicsScene.PE.UpdateInertiaTensor(PhysBody); | 455 | PhysScene.PE.UpdateInertiaTensor(PhysBody); |
468 | 456 | ||
469 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", | 457 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2},grav={3},inWorld={4}", |
470 | LocalID, physMass, Inertia, Gravity, inWorld); | 458 | LocalID, physMass, Inertia, Gravity, inWorld); |
@@ -480,7 +468,7 @@ public class BSPrim : BSPhysObject | |||
480 | // Return what gravity should be set to this very moment | 468 | // Return what gravity should be set to this very moment |
481 | public OMV.Vector3 ComputeGravity(float buoyancy) | 469 | public OMV.Vector3 ComputeGravity(float buoyancy) |
482 | { | 470 | { |
483 | OMV.Vector3 ret = PhysicsScene.DefaultGravity; | 471 | OMV.Vector3 ret = PhysScene.DefaultGravity; |
484 | 472 | ||
485 | if (!IsStatic) | 473 | if (!IsStatic) |
486 | { | 474 | { |
@@ -509,7 +497,7 @@ public class BSPrim : BSPhysObject | |||
509 | RawForce = value; | 497 | RawForce = value; |
510 | EnableActor(RawForce != OMV.Vector3.Zero, SetForceActorName, delegate() | 498 | EnableActor(RawForce != OMV.Vector3.Zero, SetForceActorName, delegate() |
511 | { | 499 | { |
512 | return new BSActorSetForce(PhysicsScene, this, SetForceActorName); | 500 | return new BSActorSetForce(PhysScene, this, SetForceActorName); |
513 | }); | 501 | }); |
514 | } | 502 | } |
515 | } | 503 | } |
@@ -521,7 +509,7 @@ public class BSPrim : BSPhysObject | |||
521 | set { | 509 | set { |
522 | Vehicle type = (Vehicle)value; | 510 | Vehicle type = (Vehicle)value; |
523 | 511 | ||
524 | PhysicsScene.TaintedObject("setVehicleType", delegate() | 512 | PhysScene.TaintedObject("setVehicleType", delegate() |
525 | { | 513 | { |
526 | // Vehicle code changes the parameters for this vehicle type. | 514 | // Vehicle code changes the parameters for this vehicle type. |
527 | VehicleActor.ProcessTypeChange(type); | 515 | VehicleActor.ProcessTypeChange(type); |
@@ -531,7 +519,7 @@ public class BSPrim : BSPhysObject | |||
531 | } | 519 | } |
532 | public override void VehicleFloatParam(int param, float value) | 520 | public override void VehicleFloatParam(int param, float value) |
533 | { | 521 | { |
534 | PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() | 522 | PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() |
535 | { | 523 | { |
536 | VehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); | 524 | VehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); |
537 | ActivateIfPhysical(false); | 525 | ActivateIfPhysical(false); |
@@ -539,7 +527,7 @@ public class BSPrim : BSPhysObject | |||
539 | } | 527 | } |
540 | public override void VehicleVectorParam(int param, OMV.Vector3 value) | 528 | public override void VehicleVectorParam(int param, OMV.Vector3 value) |
541 | { | 529 | { |
542 | PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() | 530 | PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() |
543 | { | 531 | { |
544 | VehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); | 532 | VehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); |
545 | ActivateIfPhysical(false); | 533 | ActivateIfPhysical(false); |
@@ -547,7 +535,7 @@ public class BSPrim : BSPhysObject | |||
547 | } | 535 | } |
548 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) | 536 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) |
549 | { | 537 | { |
550 | PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() | 538 | PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() |
551 | { | 539 | { |
552 | VehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); | 540 | VehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); |
553 | ActivateIfPhysical(false); | 541 | ActivateIfPhysical(false); |
@@ -555,7 +543,7 @@ public class BSPrim : BSPhysObject | |||
555 | } | 543 | } |
556 | public override void VehicleFlags(int param, bool remove) | 544 | public override void VehicleFlags(int param, bool remove) |
557 | { | 545 | { |
558 | PhysicsScene.TaintedObject("BSPrim.VehicleFlags", delegate() | 546 | PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() |
559 | { | 547 | { |
560 | VehicleActor.ProcessVehicleFlags(param, remove); | 548 | VehicleActor.ProcessVehicleFlags(param, remove); |
561 | }); | 549 | }); |
@@ -567,7 +555,7 @@ public class BSPrim : BSPhysObject | |||
567 | if (_isVolumeDetect != newValue) | 555 | if (_isVolumeDetect != newValue) |
568 | { | 556 | { |
569 | _isVolumeDetect = newValue; | 557 | _isVolumeDetect = newValue; |
570 | PhysicsScene.TaintedObject("BSPrim.SetVolumeDetect", delegate() | 558 | PhysScene.TaintedObject("BSPrim.SetVolumeDetect", delegate() |
571 | { | 559 | { |
572 | // DetailLog("{0},setVolumeDetect,taint,volDetect={1}", LocalID, _isVolumeDetect); | 560 | // DetailLog("{0},setVolumeDetect,taint,volDetect={1}", LocalID, _isVolumeDetect); |
573 | SetObjectDynamic(true); | 561 | SetObjectDynamic(true); |
@@ -578,7 +566,7 @@ public class BSPrim : BSPhysObject | |||
578 | public override void SetMaterial(int material) | 566 | public override void SetMaterial(int material) |
579 | { | 567 | { |
580 | base.SetMaterial(material); | 568 | base.SetMaterial(material); |
581 | PhysicsScene.TaintedObject("BSPrim.SetMaterial", delegate() | 569 | PhysScene.TaintedObject("BSPrim.SetMaterial", delegate() |
582 | { | 570 | { |
583 | UpdatePhysicalParameters(); | 571 | UpdatePhysicalParameters(); |
584 | }); | 572 | }); |
@@ -591,7 +579,7 @@ public class BSPrim : BSPhysObject | |||
591 | if (base.Friction != value) | 579 | if (base.Friction != value) |
592 | { | 580 | { |
593 | base.Friction = value; | 581 | base.Friction = value; |
594 | PhysicsScene.TaintedObject("BSPrim.setFriction", delegate() | 582 | PhysScene.TaintedObject("BSPrim.setFriction", delegate() |
595 | { | 583 | { |
596 | UpdatePhysicalParameters(); | 584 | UpdatePhysicalParameters(); |
597 | }); | 585 | }); |
@@ -606,7 +594,7 @@ public class BSPrim : BSPhysObject | |||
606 | if (base.Restitution != value) | 594 | if (base.Restitution != value) |
607 | { | 595 | { |
608 | base.Restitution = value; | 596 | base.Restitution = value; |
609 | PhysicsScene.TaintedObject("BSPrim.setRestitution", delegate() | 597 | PhysScene.TaintedObject("BSPrim.setRestitution", delegate() |
610 | { | 598 | { |
611 | UpdatePhysicalParameters(); | 599 | UpdatePhysicalParameters(); |
612 | }); | 600 | }); |
@@ -623,7 +611,7 @@ public class BSPrim : BSPhysObject | |||
623 | if (base.Density != value) | 611 | if (base.Density != value) |
624 | { | 612 | { |
625 | base.Density = value; | 613 | base.Density = value; |
626 | PhysicsScene.TaintedObject("BSPrim.setDensity", delegate() | 614 | PhysScene.TaintedObject("BSPrim.setDensity", delegate() |
627 | { | 615 | { |
628 | UpdatePhysicalParameters(); | 616 | UpdatePhysicalParameters(); |
629 | }); | 617 | }); |
@@ -638,7 +626,7 @@ public class BSPrim : BSPhysObject | |||
638 | if (base.GravModifier != value) | 626 | if (base.GravModifier != value) |
639 | { | 627 | { |
640 | base.GravModifier = value; | 628 | base.GravModifier = value; |
641 | PhysicsScene.TaintedObject("BSPrim.setGravityModifier", delegate() | 629 | PhysScene.TaintedObject("BSPrim.setGravityModifier", delegate() |
642 | { | 630 | { |
643 | UpdatePhysicalParameters(); | 631 | UpdatePhysicalParameters(); |
644 | }); | 632 | }); |
@@ -649,7 +637,7 @@ public class BSPrim : BSPhysObject | |||
649 | get { return RawVelocity; } | 637 | get { return RawVelocity; } |
650 | set { | 638 | set { |
651 | RawVelocity = value; | 639 | RawVelocity = value; |
652 | PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate() | 640 | PhysScene.TaintedObject("BSPrim.setVelocity", delegate() |
653 | { | 641 | { |
654 | // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, RawVelocity); | 642 | // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, RawVelocity); |
655 | ForceVelocity = RawVelocity; | 643 | ForceVelocity = RawVelocity; |
@@ -659,13 +647,13 @@ public class BSPrim : BSPhysObject | |||
659 | public override OMV.Vector3 ForceVelocity { | 647 | public override OMV.Vector3 ForceVelocity { |
660 | get { return RawVelocity; } | 648 | get { return RawVelocity; } |
661 | set { | 649 | set { |
662 | PhysicsScene.AssertInTaintTime("BSPrim.ForceVelocity"); | 650 | PhysScene.AssertInTaintTime("BSPrim.ForceVelocity"); |
663 | 651 | ||
664 | RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity); | 652 | RawVelocity = Util.ClampV(value, BSParam.MaxLinearVelocity); |
665 | if (PhysBody.HasPhysicalBody) | 653 | if (PhysBody.HasPhysicalBody) |
666 | { | 654 | { |
667 | DetailLog("{0},BSPrim.ForceVelocity,taint,vel={1}", LocalID, RawVelocity); | 655 | DetailLog("{0},BSPrim.ForceVelocity,taint,vel={1}", LocalID, RawVelocity); |
668 | PhysicsScene.PE.SetLinearVelocity(PhysBody, RawVelocity); | 656 | PhysScene.PE.SetLinearVelocity(PhysBody, RawVelocity); |
669 | ActivateIfPhysical(false); | 657 | ActivateIfPhysical(false); |
670 | } | 658 | } |
671 | } | 659 | } |
@@ -676,7 +664,7 @@ public class BSPrim : BSPhysObject | |||
676 | RawTorque = value; | 664 | RawTorque = value; |
677 | EnableActor(RawTorque != OMV.Vector3.Zero, SetTorqueActorName, delegate() | 665 | EnableActor(RawTorque != OMV.Vector3.Zero, SetTorqueActorName, delegate() |
678 | { | 666 | { |
679 | return new BSActorSetTorque(PhysicsScene, this, SetTorqueActorName); | 667 | return new BSActorSetTorque(PhysScene, this, SetTorqueActorName); |
680 | }); | 668 | }); |
681 | DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, RawTorque); | 669 | DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, RawTorque); |
682 | } | 670 | } |
@@ -699,7 +687,7 @@ public class BSPrim : BSPhysObject | |||
699 | return; | 687 | return; |
700 | _orientation = value; | 688 | _orientation = value; |
701 | 689 | ||
702 | PhysicsScene.TaintedObject("BSPrim.setOrientation", delegate() | 690 | PhysScene.TaintedObject("BSPrim.setOrientation", delegate() |
703 | { | 691 | { |
704 | ForceOrientation = _orientation; | 692 | ForceOrientation = _orientation; |
705 | }); | 693 | }); |
@@ -710,14 +698,14 @@ public class BSPrim : BSPhysObject | |||
710 | { | 698 | { |
711 | get | 699 | get |
712 | { | 700 | { |
713 | _orientation = PhysicsScene.PE.GetOrientation(PhysBody); | 701 | _orientation = PhysScene.PE.GetOrientation(PhysBody); |
714 | return _orientation; | 702 | return _orientation; |
715 | } | 703 | } |
716 | set | 704 | set |
717 | { | 705 | { |
718 | _orientation = value; | 706 | _orientation = value; |
719 | if (PhysBody.HasPhysicalBody) | 707 | if (PhysBody.HasPhysicalBody) |
720 | PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); | 708 | PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); |
721 | } | 709 | } |
722 | } | 710 | } |
723 | public override int PhysicsActorType { | 711 | public override int PhysicsActorType { |
@@ -730,7 +718,7 @@ public class BSPrim : BSPhysObject | |||
730 | if (_isPhysical != value) | 718 | if (_isPhysical != value) |
731 | { | 719 | { |
732 | _isPhysical = value; | 720 | _isPhysical = value; |
733 | PhysicsScene.TaintedObject("BSPrim.setIsPhysical", delegate() | 721 | PhysScene.TaintedObject("BSPrim.setIsPhysical", delegate() |
734 | { | 722 | { |
735 | DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical); | 723 | DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical); |
736 | SetObjectDynamic(true); | 724 | SetObjectDynamic(true); |
@@ -785,7 +773,7 @@ public class BSPrim : BSPhysObject | |||
785 | 773 | ||
786 | // Mangling all the physical properties requires the object not be in the physical world. | 774 | // Mangling all the physical properties requires the object not be in the physical world. |
787 | // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). | 775 | // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). |
788 | PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, PhysBody); | 776 | PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody); |
789 | 777 | ||
790 | // Set up the object physicalness (does gravity and collisions move this object) | 778 | // Set up the object physicalness (does gravity and collisions move this object) |
791 | MakeDynamic(IsStatic); | 779 | MakeDynamic(IsStatic); |
@@ -802,10 +790,11 @@ public class BSPrim : BSPhysObject | |||
802 | AddObjectToPhysicalWorld(); | 790 | AddObjectToPhysicalWorld(); |
803 | 791 | ||
804 | // Rebuild its shape | 792 | // Rebuild its shape |
805 | PhysicsScene.PE.UpdateSingleAabb(PhysicsScene.World, PhysBody); | 793 | PhysScene.PE.UpdateSingleAabb(PhysScene.World, PhysBody); |
806 | 794 | ||
807 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,taintExit,static={1},solid={2},mass={3},collide={4},cf={5:X},cType={6},body={7},shape={8}", | 795 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,taintExit,static={1},solid={2},mass={3},collide={4},cf={5:X},cType={6},body={7},shape={8}", |
808 | LocalID, IsStatic, IsSolid, Mass, SubscribedEvents(), CurrentCollisionFlags, PhysBody.collisionType, PhysBody, PhysShape); | 796 | LocalID, IsStatic, IsSolid, Mass, SubscribedEvents(), |
797 | CurrentCollisionFlags, PhysBody.collisionType, PhysBody, PhysShape); | ||
809 | } | 798 | } |
810 | 799 | ||
811 | // "Making dynamic" means changing to and from static. | 800 | // "Making dynamic" means changing to and from static. |
@@ -818,28 +807,28 @@ public class BSPrim : BSPhysObject | |||
818 | if (makeStatic) | 807 | if (makeStatic) |
819 | { | 808 | { |
820 | // Become a Bullet 'static' object type | 809 | // Become a Bullet 'static' object type |
821 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); | 810 | CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); |
822 | // Stop all movement | 811 | // Stop all movement |
823 | ZeroMotion(true); | 812 | ZeroMotion(true); |
824 | 813 | ||
825 | // Set various physical properties so other object interact properly | 814 | // Set various physical properties so other object interact properly |
826 | PhysicsScene.PE.SetFriction(PhysBody, Friction); | 815 | PhysScene.PE.SetFriction(PhysBody, Friction); |
827 | PhysicsScene.PE.SetRestitution(PhysBody, Restitution); | 816 | PhysScene.PE.SetRestitution(PhysBody, Restitution); |
828 | PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); | 817 | PhysScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); |
829 | 818 | ||
830 | // Mass is zero which disables a bunch of physics stuff in Bullet | 819 | // Mass is zero which disables a bunch of physics stuff in Bullet |
831 | UpdatePhysicalMassProperties(0f, false); | 820 | UpdatePhysicalMassProperties(0f, false); |
832 | // Set collision detection parameters | 821 | // Set collision detection parameters |
833 | if (BSParam.CcdMotionThreshold > 0f) | 822 | if (BSParam.CcdMotionThreshold > 0f) |
834 | { | 823 | { |
835 | PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); | 824 | PhysScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); |
836 | PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); | 825 | PhysScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); |
837 | } | 826 | } |
838 | 827 | ||
839 | // The activation state is 'disabled' so Bullet will not try to act on it. | 828 | // The activation state is 'disabled' so Bullet will not try to act on it. |
840 | // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_SIMULATION); | 829 | // PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.DISABLE_SIMULATION); |
841 | // Start it out sleeping and physical actions could wake it up. | 830 | // Start it out sleeping and physical actions could wake it up. |
842 | PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ISLAND_SLEEPING); | 831 | PhysScene.PE.ForceActivationState(PhysBody, ActivationState.ISLAND_SLEEPING); |
843 | 832 | ||
844 | // This collides like a static object | 833 | // This collides like a static object |
845 | PhysBody.collisionType = CollisionType.Static; | 834 | PhysBody.collisionType = CollisionType.Static; |
@@ -847,11 +836,11 @@ public class BSPrim : BSPhysObject | |||
847 | else | 836 | else |
848 | { | 837 | { |
849 | // Not a Bullet static object | 838 | // Not a Bullet static object |
850 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); | 839 | CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_STATIC_OBJECT); |
851 | 840 | ||
852 | // Set various physical properties so other object interact properly | 841 | // Set various physical properties so other object interact properly |
853 | PhysicsScene.PE.SetFriction(PhysBody, Friction); | 842 | PhysScene.PE.SetFriction(PhysBody, Friction); |
854 | PhysicsScene.PE.SetRestitution(PhysBody, Restitution); | 843 | PhysScene.PE.SetRestitution(PhysBody, Restitution); |
855 | // DetailLog("{0},BSPrim.MakeDynamic,frict={1},rest={2}", LocalID, Friction, Restitution); | 844 | // DetailLog("{0},BSPrim.MakeDynamic,frict={1},rest={2}", LocalID, Friction, Restitution); |
856 | 845 | ||
857 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 | 846 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 |
@@ -869,22 +858,22 @@ public class BSPrim : BSPhysObject | |||
869 | // Set collision detection parameters | 858 | // Set collision detection parameters |
870 | if (BSParam.CcdMotionThreshold > 0f) | 859 | if (BSParam.CcdMotionThreshold > 0f) |
871 | { | 860 | { |
872 | PhysicsScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); | 861 | PhysScene.PE.SetCcdMotionThreshold(PhysBody, BSParam.CcdMotionThreshold); |
873 | PhysicsScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); | 862 | PhysScene.PE.SetCcdSweptSphereRadius(PhysBody, BSParam.CcdSweptSphereRadius); |
874 | } | 863 | } |
875 | 864 | ||
876 | // Various values for simulation limits | 865 | // Various values for simulation limits |
877 | PhysicsScene.PE.SetDamping(PhysBody, BSParam.LinearDamping, BSParam.AngularDamping); | 866 | PhysScene.PE.SetDamping(PhysBody, BSParam.LinearDamping, BSParam.AngularDamping); |
878 | PhysicsScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime); | 867 | PhysScene.PE.SetDeactivationTime(PhysBody, BSParam.DeactivationTime); |
879 | PhysicsScene.PE.SetSleepingThresholds(PhysBody, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold); | 868 | PhysScene.PE.SetSleepingThresholds(PhysBody, BSParam.LinearSleepingThreshold, BSParam.AngularSleepingThreshold); |
880 | PhysicsScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); | 869 | PhysScene.PE.SetContactProcessingThreshold(PhysBody, BSParam.ContactProcessingThreshold); |
881 | 870 | ||
882 | // This collides like an object. | 871 | // This collides like an object. |
883 | PhysBody.collisionType = CollisionType.Dynamic; | 872 | PhysBody.collisionType = CollisionType.Dynamic; |
884 | 873 | ||
885 | // Force activation of the object so Bullet will act on it. | 874 | // Force activation of the object so Bullet will act on it. |
886 | // Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects. | 875 | // Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects. |
887 | PhysicsScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG); | 876 | PhysScene.PE.ForceActivationState(PhysBody, ActivationState.ACTIVE_TAG); |
888 | } | 877 | } |
889 | } | 878 | } |
890 | 879 | ||
@@ -894,7 +883,7 @@ public class BSPrim : BSPhysObject | |||
894 | // the functions after this one set up the state of a possibly newly created collision body. | 883 | // the functions after this one set up the state of a possibly newly created collision body. |
895 | private void MakeSolid(bool makeSolid) | 884 | private void MakeSolid(bool makeSolid) |
896 | { | 885 | { |
897 | CollisionObjectTypes bodyType = (CollisionObjectTypes)PhysicsScene.PE.GetBodyType(PhysBody); | 886 | CollisionObjectTypes bodyType = (CollisionObjectTypes)PhysScene.PE.GetBodyType(PhysBody); |
898 | if (makeSolid) | 887 | if (makeSolid) |
899 | { | 888 | { |
900 | // Verify the previous code created the correct shape for this type of thing. | 889 | // Verify the previous code created the correct shape for this type of thing. |
@@ -902,7 +891,7 @@ public class BSPrim : BSPhysObject | |||
902 | { | 891 | { |
903 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType); | 892 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType); |
904 | } | 893 | } |
905 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 894 | CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
906 | } | 895 | } |
907 | else | 896 | else |
908 | { | 897 | { |
@@ -910,7 +899,7 @@ public class BSPrim : BSPhysObject | |||
910 | { | 899 | { |
911 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); | 900 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); |
912 | } | 901 | } |
913 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 902 | CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
914 | 903 | ||
915 | // Change collision info from a static object to a ghosty collision object | 904 | // Change collision info from a static object to a ghosty collision object |
916 | PhysBody.collisionType = CollisionType.VolumeDetect; | 905 | PhysBody.collisionType = CollisionType.VolumeDetect; |
@@ -922,11 +911,11 @@ public class BSPrim : BSPhysObject | |||
922 | { | 911 | { |
923 | if (wantsCollisionEvents) | 912 | if (wantsCollisionEvents) |
924 | { | 913 | { |
925 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 914 | CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
926 | } | 915 | } |
927 | else | 916 | else |
928 | { | 917 | { |
929 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 918 | CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
930 | } | 919 | } |
931 | } | 920 | } |
932 | 921 | ||
@@ -937,7 +926,7 @@ public class BSPrim : BSPhysObject | |||
937 | { | 926 | { |
938 | if (PhysBody.HasPhysicalBody) | 927 | if (PhysBody.HasPhysicalBody) |
939 | { | 928 | { |
940 | PhysicsScene.PE.AddObjectToWorld(PhysicsScene.World, PhysBody); | 929 | PhysScene.PE.AddObjectToWorld(PhysScene.World, PhysBody); |
941 | } | 930 | } |
942 | else | 931 | else |
943 | { | 932 | { |
@@ -972,12 +961,12 @@ public class BSPrim : BSPhysObject | |||
972 | public override bool FloatOnWater { | 961 | public override bool FloatOnWater { |
973 | set { | 962 | set { |
974 | _floatOnWater = value; | 963 | _floatOnWater = value; |
975 | PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate() | 964 | PhysScene.TaintedObject("BSPrim.setFloatOnWater", delegate() |
976 | { | 965 | { |
977 | if (_floatOnWater) | 966 | if (_floatOnWater) |
978 | CurrentCollisionFlags = PhysicsScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); | 967 | CurrentCollisionFlags = PhysScene.PE.AddToCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); |
979 | else | 968 | else |
980 | CurrentCollisionFlags = PhysicsScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); | 969 | CurrentCollisionFlags = PhysScene.PE.RemoveFromCollisionFlags(PhysBody, CollisionFlags.BS_FLOATS_ON_WATER); |
981 | }); | 970 | }); |
982 | } | 971 | } |
983 | } | 972 | } |
@@ -989,7 +978,7 @@ public class BSPrim : BSPhysObject | |||
989 | _rotationalVelocity = value; | 978 | _rotationalVelocity = value; |
990 | Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity); | 979 | Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity); |
991 | // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); | 980 | // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); |
992 | PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() | 981 | PhysScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() |
993 | { | 982 | { |
994 | ForceRotationalVelocity = _rotationalVelocity; | 983 | ForceRotationalVelocity = _rotationalVelocity; |
995 | }); | 984 | }); |
@@ -1004,7 +993,7 @@ public class BSPrim : BSPhysObject | |||
1004 | if (PhysBody.HasPhysicalBody) | 993 | if (PhysBody.HasPhysicalBody) |
1005 | { | 994 | { |
1006 | DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); | 995 | DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); |
1007 | PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); | 996 | PhysScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); |
1008 | // PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); | 997 | // PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); |
1009 | ActivateIfPhysical(false); | 998 | ActivateIfPhysical(false); |
1010 | } | 999 | } |
@@ -1020,7 +1009,7 @@ public class BSPrim : BSPhysObject | |||
1020 | get { return _buoyancy; } | 1009 | get { return _buoyancy; } |
1021 | set { | 1010 | set { |
1022 | _buoyancy = value; | 1011 | _buoyancy = value; |
1023 | PhysicsScene.TaintedObject("BSPrim.setBuoyancy", delegate() | 1012 | PhysScene.TaintedObject("BSPrim.setBuoyancy", delegate() |
1024 | { | 1013 | { |
1025 | ForceBuoyancy = _buoyancy; | 1014 | ForceBuoyancy = _buoyancy; |
1026 | }); | 1015 | }); |
@@ -1043,7 +1032,7 @@ public class BSPrim : BSPhysObject | |||
1043 | base.MoveToTargetActive = value; | 1032 | base.MoveToTargetActive = value; |
1044 | EnableActor(MoveToTargetActive, MoveToTargetActorName, delegate() | 1033 | EnableActor(MoveToTargetActive, MoveToTargetActorName, delegate() |
1045 | { | 1034 | { |
1046 | return new BSActorMoveToTarget(PhysicsScene, this, MoveToTargetActorName); | 1035 | return new BSActorMoveToTarget(PhysScene, this, MoveToTargetActorName); |
1047 | }); | 1036 | }); |
1048 | } | 1037 | } |
1049 | } | 1038 | } |
@@ -1055,7 +1044,7 @@ public class BSPrim : BSPhysObject | |||
1055 | base.HoverActive = value; | 1044 | base.HoverActive = value; |
1056 | EnableActor(HoverActive, HoverActorName, delegate() | 1045 | EnableActor(HoverActive, HoverActorName, delegate() |
1057 | { | 1046 | { |
1058 | return new BSActorHover(PhysicsScene, this, HoverActorName); | 1047 | return new BSActorHover(PhysScene, this, HoverActorName); |
1059 | }); | 1048 | }); |
1060 | } | 1049 | } |
1061 | } | 1050 | } |
@@ -1065,7 +1054,7 @@ public class BSPrim : BSPhysObject | |||
1065 | OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); | 1054 | OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude); |
1066 | 1055 | ||
1067 | // Since this force is being applied in only one step, make this a force per second. | 1056 | // Since this force is being applied in only one step, make this a force per second. |
1068 | addForce /= PhysicsScene.LastTimeStep; | 1057 | addForce /= PhysScene.LastTimeStep; |
1069 | AddForce(addForce, pushforce, false /* inTaintTime */); | 1058 | AddForce(addForce, pushforce, false /* inTaintTime */); |
1070 | } | 1059 | } |
1071 | 1060 | ||
@@ -1080,13 +1069,13 @@ public class BSPrim : BSPhysObject | |||
1080 | // DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); | 1069 | // DetailLog("{0},BSPrim.addForce,call,force={1}", LocalID, addForce); |
1081 | 1070 | ||
1082 | OMV.Vector3 addForce = force; | 1071 | OMV.Vector3 addForce = force; |
1083 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() | 1072 | PhysScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() |
1084 | { | 1073 | { |
1085 | // Bullet adds this central force to the total force for this tick | 1074 | // Bullet adds this central force to the total force for this tick |
1086 | DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce); | 1075 | DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce); |
1087 | if (PhysBody.HasPhysicalBody) | 1076 | if (PhysBody.HasPhysicalBody) |
1088 | { | 1077 | { |
1089 | PhysicsScene.PE.ApplyCentralForce(PhysBody, addForce); | 1078 | PhysScene.PE.ApplyCentralForce(PhysBody, addForce); |
1090 | ActivateIfPhysical(false); | 1079 | ActivateIfPhysical(false); |
1091 | } | 1080 | } |
1092 | }); | 1081 | }); |
@@ -1108,13 +1097,13 @@ public class BSPrim : BSPhysObject | |||
1108 | OMV.Vector3 addImpulse = Util.ClampV(impulse, BSParam.MaxAddForceMagnitude); | 1097 | OMV.Vector3 addImpulse = Util.ClampV(impulse, BSParam.MaxAddForceMagnitude); |
1109 | // DetailLog("{0},BSPrim.addForceImpulse,call,impulse={1}", LocalID, impulse); | 1098 | // DetailLog("{0},BSPrim.addForceImpulse,call,impulse={1}", LocalID, impulse); |
1110 | 1099 | ||
1111 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddImpulse", delegate() | 1100 | PhysScene.TaintedObject(inTaintTime, "BSPrim.AddImpulse", delegate() |
1112 | { | 1101 | { |
1113 | // Bullet adds this impulse immediately to the velocity | 1102 | // Bullet adds this impulse immediately to the velocity |
1114 | DetailLog("{0},BSPrim.addForceImpulse,taint,impulseforce={1}", LocalID, addImpulse); | 1103 | DetailLog("{0},BSPrim.addForceImpulse,taint,impulseforce={1}", LocalID, addImpulse); |
1115 | if (PhysBody.HasPhysicalBody) | 1104 | if (PhysBody.HasPhysicalBody) |
1116 | { | 1105 | { |
1117 | PhysicsScene.PE.ApplyCentralImpulse(PhysBody, addImpulse); | 1106 | PhysScene.PE.ApplyCentralImpulse(PhysBody, addImpulse); |
1118 | ActivateIfPhysical(false); | 1107 | ActivateIfPhysical(false); |
1119 | } | 1108 | } |
1120 | }); | 1109 | }); |
@@ -1133,12 +1122,12 @@ public class BSPrim : BSPhysObject | |||
1133 | if (force.IsFinite()) | 1122 | if (force.IsFinite()) |
1134 | { | 1123 | { |
1135 | OMV.Vector3 angForce = force; | 1124 | OMV.Vector3 angForce = force; |
1136 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddAngularForce", delegate() | 1125 | PhysScene.TaintedObject(inTaintTime, "BSPrim.AddAngularForce", delegate() |
1137 | { | 1126 | { |
1138 | if (PhysBody.HasPhysicalBody) | 1127 | if (PhysBody.HasPhysicalBody) |
1139 | { | 1128 | { |
1140 | DetailLog("{0},BSPrim.AddAngularForce,taint,angForce={1}", LocalID, angForce); | 1129 | DetailLog("{0},BSPrim.AddAngularForce,taint,angForce={1}", LocalID, angForce); |
1141 | PhysicsScene.PE.ApplyTorque(PhysBody, angForce); | 1130 | PhysScene.PE.ApplyTorque(PhysBody, angForce); |
1142 | ActivateIfPhysical(false); | 1131 | ActivateIfPhysical(false); |
1143 | } | 1132 | } |
1144 | }); | 1133 | }); |
@@ -1157,11 +1146,11 @@ public class BSPrim : BSPhysObject | |||
1157 | public void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime) | 1146 | public void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime) |
1158 | { | 1147 | { |
1159 | OMV.Vector3 applyImpulse = impulse; | 1148 | OMV.Vector3 applyImpulse = impulse; |
1160 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate() | 1149 | PhysScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate() |
1161 | { | 1150 | { |
1162 | if (PhysBody.HasPhysicalBody) | 1151 | if (PhysBody.HasPhysicalBody) |
1163 | { | 1152 | { |
1164 | PhysicsScene.PE.ApplyTorqueImpulse(PhysBody, applyImpulse); | 1153 | PhysScene.PE.ApplyTorqueImpulse(PhysBody, applyImpulse); |
1165 | ActivateIfPhysical(false); | 1154 | ActivateIfPhysical(false); |
1166 | } | 1155 | } |
1167 | }); | 1156 | }); |
@@ -1463,12 +1452,13 @@ public class BSPrim : BSPhysObject | |||
1463 | // Create the correct physical representation for this type of object. | 1452 | // Create the correct physical representation for this type of object. |
1464 | // Updates base.PhysBody and base.PhysShape with the new information. | 1453 | // Updates base.PhysBody and base.PhysShape with the new information. |
1465 | // Ignore 'forceRebuild'. 'GetBodyAndShape' makes the right choices and changes of necessary. | 1454 | // Ignore 'forceRebuild'. 'GetBodyAndShape' makes the right choices and changes of necessary. |
1466 | PhysicsScene.Shapes.GetBodyAndShape(false /*forceRebuild */, PhysicsScene.World, this, null, delegate(BulletBody dBody) | 1455 | PhysScene.Shapes.GetBodyAndShape(false /*forceRebuild */, PhysScene.World, this, delegate(BulletBody pBody, BulletShape pShape) |
1467 | { | 1456 | { |
1468 | // Called if the current prim body is about to be destroyed. | 1457 | // Called if the current prim body is about to be destroyed. |
1469 | // Remove all the physical dependencies on the old body. | 1458 | // Remove all the physical dependencies on the old body. |
1470 | // (Maybe someday make the changing of BSShape an event to be subscribed to by BSLinkset, ...) | 1459 | // (Maybe someday make the changing of BSShape an event to be subscribed to by BSLinkset, ...) |
1471 | RemoveBodyDependencies(); | 1460 | // Note: this virtual function is overloaded by BSPrimLinkable to remove linkset constraints. |
1461 | RemoveDependencies(); | ||
1472 | }); | 1462 | }); |
1473 | 1463 | ||
1474 | // Make sure the properties are set on the new object | 1464 | // Make sure the properties are set on the new object |
@@ -1477,9 +1467,9 @@ public class BSPrim : BSPhysObject | |||
1477 | } | 1467 | } |
1478 | 1468 | ||
1479 | // Called at taint-time | 1469 | // Called at taint-time |
1480 | protected virtual void RemoveBodyDependencies() | 1470 | protected virtual void RemoveDependencies() |
1481 | { | 1471 | { |
1482 | PhysicalActors.RemoveBodyDependencies(); | 1472 | PhysicalActors.RemoveDependencies(); |
1483 | } | 1473 | } |
1484 | 1474 | ||
1485 | // The physics engine says that properties have updated. Update same and inform | 1475 | // The physics engine says that properties have updated. Update same and inform |