diff options
author | Robert Adams | 2012-10-02 11:06:07 -0700 |
---|---|---|
committer | Robert Adams | 2012-10-02 11:14:09 -0700 |
commit | ce47d0c4541159a730b2d83a7b2ccffc908d06f1 (patch) | |
tree | a45efbb6da0cbfa63cfd75c17fcd9827a1086817 /OpenSim/Region/Physics | |
parent | BulletSim: Fix problem where box shapes were not being rebuilt if the shape t... (diff) | |
download | opensim-SC_OLD-ce47d0c4541159a730b2d83a7b2ccffc908d06f1.zip opensim-SC_OLD-ce47d0c4541159a730b2d83a7b2ccffc908d06f1.tar.gz opensim-SC_OLD-ce47d0c4541159a730b2d83a7b2ccffc908d06f1.tar.bz2 opensim-SC_OLD-ce47d0c4541159a730b2d83a7b2ccffc908d06f1.tar.xz |
BulletSim: Add ForcePosition and ForceOrientation to BSPhysObject and to its children of BSPrim and BSCharacter.
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 26 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 39 |
3 files changed, 64 insertions, 5 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 2fe4d68..2a52e01 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -218,6 +218,18 @@ public class BSCharacter : BSPhysObject | |||
218 | }); | 218 | }); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | public override OMV.Vector3 ForcePosition { | ||
222 | get { | ||
223 | _position = BulletSimAPI.GetPosition2(BSBody.ptr); | ||
224 | return _position; | ||
225 | } | ||
226 | set { | ||
227 | _position = value; | ||
228 | PositionSanityCheck(); | ||
229 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | ||
230 | } | ||
231 | } | ||
232 | |||
221 | 233 | ||
222 | // Check that the current position is sane and, if not, modify the position to make it so. | 234 | // Check that the current position is sane and, if not, modify the position to make it so. |
223 | // Check for being below terrain and being out of bounds. | 235 | // Check for being below terrain and being out of bounds. |
@@ -346,6 +358,20 @@ public class BSCharacter : BSPhysObject | |||
346 | }); | 358 | }); |
347 | } | 359 | } |
348 | } | 360 | } |
361 | // Go directly to Bullet to get/set the value. | ||
362 | public override OMV.Quaternion ForceOrientation | ||
363 | { | ||
364 | get | ||
365 | { | ||
366 | _orientation = BulletSimAPI.GetOrientation2(BSBody.ptr); | ||
367 | return _orientation; | ||
368 | } | ||
369 | set | ||
370 | { | ||
371 | _orientation = value; | ||
372 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | ||
373 | } | ||
374 | } | ||
349 | public override int PhysicsActorType { | 375 | public override int PhysicsActorType { |
350 | get { return _physicsActorType; } | 376 | get { return _physicsActorType; } |
351 | set { _physicsActorType = value; | 377 | set { _physicsActorType = value; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index d9b738b..1ac8c59 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -81,6 +81,10 @@ public abstract class BSPhysObject : PhysicsActor | |||
81 | // Tell the object to clean up. | 81 | // Tell the object to clean up. |
82 | public abstract void Destroy(); | 82 | public abstract void Destroy(); |
83 | 83 | ||
84 | public abstract OMV.Vector3 ForcePosition { get; set; } | ||
85 | |||
86 | public abstract OMV.Quaternion ForceOrientation { get; set; } | ||
87 | |||
84 | #region Collisions | 88 | #region Collisions |
85 | 89 | ||
86 | // Requested number of milliseconds between collision events. Zero means disabled. | 90 | // Requested number of milliseconds between collision events. Zero means disabled. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index e37a4a0..f7b68ba 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -275,6 +275,17 @@ public sealed class BSPrim : BSPhysObject | |||
275 | }); | 275 | }); |
276 | } | 276 | } |
277 | } | 277 | } |
278 | public override OMV.Vector3 ForcePosition { | ||
279 | get { | ||
280 | _position = BulletSimAPI.GetPosition2(BSBody.ptr); | ||
281 | return _position; | ||
282 | } | ||
283 | set { | ||
284 | _position = value; | ||
285 | PositionSanityCheck(); | ||
286 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | ||
287 | } | ||
288 | } | ||
278 | 289 | ||
279 | // Check that the current position is sane and, if not, modify the position to make it so. | 290 | // Check that the current position is sane and, if not, modify the position to make it so. |
280 | // Check for being below terrain and being out of bounds. | 291 | // Check for being below terrain and being out of bounds. |
@@ -377,14 +388,15 @@ public sealed class BSPrim : BSPhysObject | |||
377 | } | 388 | } |
378 | set { | 389 | set { |
379 | Vehicle type = (Vehicle)value; | 390 | Vehicle type = (Vehicle)value; |
380 | BSPrim vehiclePrim = this; | 391 | |
392 | // Tell the scene about the vehicle so it will get processing each frame. | ||
393 | PhysicsScene.VehicleInSceneTypeChanged(this, type); | ||
394 | |||
381 | PhysicsScene.TaintedObject("setVehicleType", delegate() | 395 | PhysicsScene.TaintedObject("setVehicleType", delegate() |
382 | { | 396 | { |
383 | // Done at taint time so we're sure the physics engine is not using the variables | 397 | // Done at taint time so we're sure the physics engine is not using the variables |
384 | // Vehicle code changes the parameters for this vehicle type. | 398 | // Vehicle code changes the parameters for this vehicle type. |
385 | _vehicle.ProcessTypeChange(type); | 399 | this._vehicle.ProcessTypeChange(type); |
386 | // Tell the scene about the vehicle so it will get processing each frame. | ||
387 | PhysicsScene.VehicleInSceneTypeChanged(this, type); | ||
388 | }); | 400 | }); |
389 | } | 401 | } |
390 | } | 402 | } |
@@ -422,7 +434,9 @@ public sealed class BSPrim : BSPhysObject | |||
422 | public override void StepVehicle(float timeStep) | 434 | public override void StepVehicle(float timeStep) |
423 | { | 435 | { |
424 | if (IsPhysical) | 436 | if (IsPhysical) |
437 | { | ||
425 | _vehicle.Step(timeStep); | 438 | _vehicle.Step(timeStep); |
439 | } | ||
426 | } | 440 | } |
427 | 441 | ||
428 | // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more | 442 | // Allows the detection of collisions with inherently non-physical prims. see llVolumeDetect for more |
@@ -486,6 +500,20 @@ public sealed class BSPrim : BSPhysObject | |||
486 | }); | 500 | }); |
487 | } | 501 | } |
488 | } | 502 | } |
503 | // Go directly to Bullet to get/set the value. | ||
504 | public override OMV.Quaternion ForceOrientation | ||
505 | { | ||
506 | get | ||
507 | { | ||
508 | _orientation = BulletSimAPI.GetOrientation2(BSBody.ptr); | ||
509 | return _orientation; | ||
510 | } | ||
511 | set | ||
512 | { | ||
513 | _orientation = value; | ||
514 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | ||
515 | } | ||
516 | } | ||
489 | public override int PhysicsActorType { | 517 | public override int PhysicsActorType { |
490 | get { return _physicsActorType; } | 518 | get { return _physicsActorType; } |
491 | set { _physicsActorType = value; } | 519 | set { _physicsActorType = value; } |
@@ -1170,7 +1198,8 @@ public sealed class BSPrim : BSPhysObject | |||
1170 | 1198 | ||
1171 | // Create the correct physical representation for this type of object. | 1199 | // Create the correct physical representation for this type of object. |
1172 | // Updates BSBody and BSShape with the new information. | 1200 | // Updates BSBody and BSShape with the new information. |
1173 | PhysicsScene.Shapes.GetBodyAndShape(forceRebuild, PhysicsScene.World, this, shapeData, _pbs, | 1201 | // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. |
1202 | PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, shapeData, _pbs, | ||
1174 | null, delegate(BulletBody dBody) | 1203 | null, delegate(BulletBody dBody) |
1175 | { | 1204 | { |
1176 | // Called if the current prim body is about to be destroyed. | 1205 | // Called if the current prim body is about to be destroyed. |