diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 0cab5d1..b08d5db 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -94,7 +94,7 @@ public class BSCharacter : PhysicsActor | |||
94 | _flying = isFlying; | 94 | _flying = isFlying; |
95 | _orientation = Quaternion.Identity; | 95 | _orientation = Quaternion.Identity; |
96 | _velocity = Vector3.Zero; | 96 | _velocity = Vector3.Zero; |
97 | _buoyancy = isFlying ? 1f : 0f; | 97 | _buoyancy = ComputeBuoyancyFromFlying(isFlying); |
98 | _scale = new Vector3(1f, 1f, 1f); | 98 | _scale = new Vector3(1f, 1f, 1f); |
99 | _density = _scene.Params.avatarDensity; | 99 | _density = _scene.Params.avatarDensity; |
100 | ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale | 100 | ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale |
@@ -110,7 +110,7 @@ public class BSCharacter : PhysicsActor | |||
110 | shapeData.Buoyancy = _buoyancy; | 110 | shapeData.Buoyancy = _buoyancy; |
111 | shapeData.Static = ShapeData.numericFalse; | 111 | shapeData.Static = ShapeData.numericFalse; |
112 | shapeData.Friction = _scene.Params.avatarFriction; | 112 | shapeData.Friction = _scene.Params.avatarFriction; |
113 | shapeData.Restitution = _scene.Params.defaultRestitution; | 113 | shapeData.Restitution = _scene.Params.avatarRestitution; |
114 | 114 | ||
115 | // do actual create at taint time | 115 | // do actual create at taint time |
116 | _scene.TaintedObject(delegate() | 116 | _scene.TaintedObject(delegate() |
@@ -260,13 +260,13 @@ public class BSCharacter : PhysicsActor | |||
260 | get { return _flying; } | 260 | get { return _flying; } |
261 | set { | 261 | set { |
262 | _flying = value; | 262 | _flying = value; |
263 | _scene.TaintedObject(delegate() | 263 | // simulate flying by changing the effect of gravity |
264 | { | 264 | this.Buoyancy = ComputeBuoyancyFromFlying(_flying); |
265 | // simulate flying by changing the effect of gravity | ||
266 | BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _flying ? 1f : 0f); | ||
267 | }); | ||
268 | } | 265 | } |
269 | } | 266 | } |
267 | private float ComputeBuoyancyFromFlying(bool ifFlying) { | ||
268 | return ifFlying ? 1f : 0f; | ||
269 | } | ||
270 | public override bool | 270 | public override bool |
271 | SetAlwaysRun { | 271 | SetAlwaysRun { |
272 | get { return _setAlwaysRun; } | 272 | get { return _setAlwaysRun; } |
@@ -299,6 +299,7 @@ public class BSCharacter : PhysicsActor | |||
299 | get { return _kinematic; } | 299 | get { return _kinematic; } |
300 | set { _kinematic = value; } | 300 | set { _kinematic = value; } |
301 | } | 301 | } |
302 | // neg=fall quickly, 0=1g, 1=0g, pos=float up | ||
302 | public override float Buoyancy { | 303 | public override float Buoyancy { |
303 | get { return _buoyancy; } | 304 | get { return _buoyancy; } |
304 | set { _buoyancy = value; | 305 | set { _buoyancy = value; |
@@ -355,7 +356,7 @@ public class BSCharacter : PhysicsActor | |||
355 | } | 356 | } |
356 | else | 357 | else |
357 | { | 358 | { |
358 | m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader); | 359 | m_log.ErrorFormat("{0}: Got a NaN force applied to a Character", LogHeader); |
359 | } | 360 | } |
360 | //m_lastUpdateSent = false; | 361 | //m_lastUpdateSent = false; |
361 | } | 362 | } |
@@ -425,6 +426,8 @@ public class BSCharacter : PhysicsActor | |||
425 | } | 426 | } |
426 | } | 427 | } |
427 | 428 | ||
429 | // Called by the scene when a collision with this object is reported | ||
430 | CollisionEventUpdate collisionCollection = null; | ||
428 | public void Collide(uint collidingWith, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth) | 431 | public void Collide(uint collidingWith, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth) |
429 | { | 432 | { |
430 | // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); | 433 | // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); |
@@ -442,10 +445,24 @@ public class BSCharacter : PhysicsActor | |||
442 | if (nowTime < (_lastCollisionTime + _subscribedEventsMs)) return; | 445 | if (nowTime < (_lastCollisionTime + _subscribedEventsMs)) return; |
443 | _lastCollisionTime = nowTime; | 446 | _lastCollisionTime = nowTime; |
444 | 447 | ||
445 | Dictionary<uint, ContactPoint> contactPoints = new Dictionary<uint, ContactPoint>(); | 448 | if (collisionCollection == null) |
446 | contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); | 449 | collisionCollection = new CollisionEventUpdate(); |
447 | CollisionEventUpdate args = new CollisionEventUpdate(contactPoints); | 450 | collisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); |
448 | base.SendCollisionUpdate(args); | 451 | } |
452 | |||
453 | public void SendCollisions() | ||
454 | { | ||
455 | // if (collisionCollection != null) | ||
456 | // { | ||
457 | // base.SendCollisionUpdate(collisionCollection); | ||
458 | // collisionCollection = null; | ||
459 | // } | ||
460 | // Kludge to make a collision call even if there are no collisions. | ||
461 | // This causes the avatar animation to get updated. | ||
462 | if (collisionCollection == null) | ||
463 | collisionCollection = new CollisionEventUpdate(); | ||
464 | base.SendCollisionUpdate(collisionCollection); | ||
465 | collisionCollection = null; | ||
449 | } | 466 | } |
450 | 467 | ||
451 | } | 468 | } |