diff options
author | Melanie | 2012-10-02 23:02:53 +0100 |
---|---|---|
committer | Melanie | 2012-10-02 23:02:53 +0100 |
commit | ca5c0814f4c6e286e24e1971620aec3c0ee1c2d3 (patch) | |
tree | f630648180aca5a498cb674bfb1f967eb9bcb260 /OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |
parent | Attempt to fix Mantis #6311. Honor a destination folder if one is given (diff) | |
parent | correcting typo (diff) | |
download | opensim-SC-ca5c0814f4c6e286e24e1971620aec3c0ee1c2d3.zip opensim-SC-ca5c0814f4c6e286e24e1971620aec3c0ee1c2d3.tar.gz opensim-SC-ca5c0814f4c6e286e24e1971620aec3c0ee1c2d3.tar.bz2 opensim-SC-ca5c0814f4c6e286e24e1971620aec3c0ee1c2d3.tar.xz |
Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index b88ec3c..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. |
@@ -234,6 +246,15 @@ public class BSCharacter : BSPhysObject | |||
234 | _position.Z = terrainHeight + 2.0f; | 246 | _position.Z = terrainHeight + 2.0f; |
235 | ret = true; | 247 | ret = true; |
236 | } | 248 | } |
249 | if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) | ||
250 | { | ||
251 | float waterHeight = PhysicsScene.GetWaterLevelAtXYZ(_position); | ||
252 | if (Position.Z < waterHeight) | ||
253 | { | ||
254 | _position.Z = waterHeight; | ||
255 | ret = true; | ||
256 | } | ||
257 | } | ||
237 | 258 | ||
238 | // TODO: check for out of bounds | 259 | // TODO: check for out of bounds |
239 | return ret; | 260 | return ret; |
@@ -242,18 +263,22 @@ public class BSCharacter : BSPhysObject | |||
242 | // A version of the sanity check that also makes sure a new position value is | 263 | // A version of the sanity check that also makes sure a new position value is |
243 | // pushed back to the physics engine. This routine would be used by anyone | 264 | // pushed back to the physics engine. This routine would be used by anyone |
244 | // who is not already pushing the value. | 265 | // who is not already pushing the value. |
245 | private bool PositionSanityCheck2() | 266 | private bool PositionSanityCheck2(bool atTaintTime) |
246 | { | 267 | { |
247 | bool ret = false; | 268 | bool ret = false; |
248 | if (PositionSanityCheck()) | 269 | if (PositionSanityCheck()) |
249 | { | 270 | { |
250 | // The new position value must be pushed into the physics engine but we can't | 271 | // The new position value must be pushed into the physics engine but we can't |
251 | // just assign to "Position" because of potential call loops. | 272 | // just assign to "Position" because of potential call loops. |
252 | PhysicsScene.TaintedObject("BSCharacter.PositionSanityCheck", delegate() | 273 | BSScene.TaintCallback sanityOperation = delegate() |
253 | { | 274 | { |
254 | DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 275 | DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
255 | BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); | 276 | BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); |
256 | }); | 277 | }; |
278 | if (atTaintTime) | ||
279 | sanityOperation(); | ||
280 | else | ||
281 | PhysicsScene.TaintedObject("BSCharacter.PositionSanityCheck", sanityOperation); | ||
257 | ret = true; | 282 | ret = true; |
258 | } | 283 | } |
259 | return ret; | 284 | return ret; |
@@ -333,6 +358,20 @@ public class BSCharacter : BSPhysObject | |||
333 | }); | 358 | }); |
334 | } | 359 | } |
335 | } | 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 | } | ||
336 | public override int PhysicsActorType { | 375 | public override int PhysicsActorType { |
337 | get { return _physicsActorType; } | 376 | get { return _physicsActorType; } |
338 | set { _physicsActorType = value; | 377 | set { _physicsActorType = value; |
@@ -378,7 +417,16 @@ public class BSCharacter : BSPhysObject | |||
378 | set { _collidingObj = value; } | 417 | set { _collidingObj = value; } |
379 | } | 418 | } |
380 | public override bool FloatOnWater { | 419 | public override bool FloatOnWater { |
381 | set { _floatOnWater = value; } | 420 | set { |
421 | _floatOnWater = value; | ||
422 | PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate() | ||
423 | { | ||
424 | if (_floatOnWater) | ||
425 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | ||
426 | else | ||
427 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | ||
428 | }); | ||
429 | } | ||
382 | } | 430 | } |
383 | public override OMV.Vector3 RotationalVelocity { | 431 | public override OMV.Vector3 RotationalVelocity { |
384 | get { return _rotationalVelocity; } | 432 | get { return _rotationalVelocity; } |
@@ -493,15 +541,14 @@ public class BSCharacter : BSPhysObject | |||
493 | _velocity = entprop.Velocity; | 541 | _velocity = entprop.Velocity; |
494 | _acceleration = entprop.Acceleration; | 542 | _acceleration = entprop.Acceleration; |
495 | _rotationalVelocity = entprop.RotationalVelocity; | 543 | _rotationalVelocity = entprop.RotationalVelocity; |
544 | // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. | ||
545 | PositionSanityCheck2(true); | ||
546 | |||
496 | // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. | 547 | // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. |
497 | // base.RequestPhysicsterseUpdate(); | 548 | // base.RequestPhysicsterseUpdate(); |
498 | 549 | ||
499 | // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. | 550 | DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", |
500 | PositionSanityCheck2(); | 551 | LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); |
501 | |||
502 | float heightHere = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); // only for debug | ||
503 | DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5},terrain={6}", | ||
504 | LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity, heightHere); | ||
505 | } | 552 | } |
506 | } | 553 | } |
507 | } | 554 | } |