diff options
author | Robert Adams | 2012-08-24 12:58:42 -0700 |
---|---|---|
committer | Robert Adams | 2012-08-31 11:41:12 -0700 |
commit | 7b6987ce83d16871f6070f3cc7d56280ad3d5dbe (patch) | |
tree | d996f2e9871d0d8bba505d9f581c7f42a8f040b3 /OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |
parent | BulletSim: add new interface for mesh, hull and terrain creation that will mo... (diff) | |
download | opensim-SC_OLD-7b6987ce83d16871f6070f3cc7d56280ad3d5dbe.zip opensim-SC_OLD-7b6987ce83d16871f6070f3cc7d56280ad3d5dbe.tar.gz opensim-SC_OLD-7b6987ce83d16871f6070f3cc7d56280ad3d5dbe.tar.bz2 opensim-SC_OLD-7b6987ce83d16871f6070f3cc7d56280ad3d5dbe.tar.xz |
BulletSim: unify physical objects under BSPhysObjects. Now BSScene and BSLinkset only know of BSPhysObject's and there is only one list to search in BSScene.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 1b23a36..784076d 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -34,7 +34,7 @@ using OpenSim.Region.Physics.Manager; | |||
34 | 34 | ||
35 | namespace OpenSim.Region.Physics.BulletSPlugin | 35 | namespace OpenSim.Region.Physics.BulletSPlugin |
36 | { | 36 | { |
37 | public class BSCharacter : PhysicsActor | 37 | public class BSCharacter : BSPhysObject |
38 | { | 38 | { |
39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
40 | private static readonly string LogHeader = "[BULLETS CHAR]"; | 40 | private static readonly string LogHeader = "[BULLETS CHAR]"; |
@@ -74,11 +74,8 @@ public class BSCharacter : PhysicsActor | |||
74 | private bool _kinematic; | 74 | private bool _kinematic; |
75 | private float _buoyancy; | 75 | private float _buoyancy; |
76 | 76 | ||
77 | private BulletBody m_body; | 77 | public override BulletBody Body { get; set; } |
78 | public BulletBody Body { | 78 | public override BSLinkset Linkset { get; set; } |
79 | get { return m_body; } | ||
80 | set { m_body = value; } | ||
81 | } | ||
82 | 79 | ||
83 | private int _subscribedEventsMs = 0; | 80 | private int _subscribedEventsMs = 0; |
84 | private int _nextCollisionOkTime = 0; | 81 | private int _nextCollisionOkTime = 0; |
@@ -108,6 +105,8 @@ public class BSCharacter : PhysicsActor | |||
108 | _density = _scene.Params.avatarDensity; | 105 | _density = _scene.Params.avatarDensity; |
109 | ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale | 106 | ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale |
110 | 107 | ||
108 | Linkset = new BSLinkset(_scene, this); | ||
109 | |||
111 | ShapeData shapeData = new ShapeData(); | 110 | ShapeData shapeData = new ShapeData(); |
112 | shapeData.ID = _localID; | 111 | shapeData.ID = _localID; |
113 | shapeData.Type = ShapeData.PhysicsShapeType.SHAPE_AVATAR; | 112 | shapeData.Type = ShapeData.PhysicsShapeType.SHAPE_AVATAR; |
@@ -130,7 +129,7 @@ public class BSCharacter : PhysicsActor | |||
130 | // Set the buoyancy for flying. This will be refactored when all the settings happen in C# | 129 | // Set the buoyancy for flying. This will be refactored when all the settings happen in C# |
131 | BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy); | 130 | BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy); |
132 | 131 | ||
133 | m_body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID)); | 132 | Body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID)); |
134 | // avatars get all collisions no matter what (makes walking on ground and such work) | 133 | // avatars get all collisions no matter what (makes walking on ground and such work) |
135 | BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 134 | BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
136 | }); | 135 | }); |
@@ -139,7 +138,7 @@ public class BSCharacter : PhysicsActor | |||
139 | } | 138 | } |
140 | 139 | ||
141 | // called when this character is being destroyed and the resources should be released | 140 | // called when this character is being destroyed and the resources should be released |
142 | public void Destroy() | 141 | public override void Destroy() |
143 | { | 142 | { |
144 | DetailLog("{0},BSCharacter.Destroy", LocalID); | 143 | DetailLog("{0},BSCharacter.Destroy", LocalID); |
145 | _scene.TaintedObject("BSCharacter.destroy", delegate() | 144 | _scene.TaintedObject("BSCharacter.destroy", delegate() |
@@ -245,6 +244,10 @@ public class BSCharacter : PhysicsActor | |||
245 | return _mass; | 244 | return _mass; |
246 | } | 245 | } |
247 | } | 246 | } |
247 | |||
248 | // used when we only want this prim's mass and not the linkset thing | ||
249 | public override float MassRaw { get {return _mass; } } | ||
250 | |||
248 | public override Vector3 Force { | 251 | public override Vector3 Force { |
249 | get { return _force; } | 252 | get { return _force; } |
250 | set { | 253 | set { |
@@ -448,6 +451,12 @@ public class BSCharacter : PhysicsActor | |||
448 | }); | 451 | }); |
449 | } | 452 | } |
450 | } | 453 | } |
454 | |||
455 | public override void ZeroMotion() | ||
456 | { | ||
457 | return; | ||
458 | } | ||
459 | |||
451 | // Stop collision events | 460 | // Stop collision events |
452 | public override void UnSubscribeEvents() { | 461 | public override void UnSubscribeEvents() { |
453 | _subscribedEventsMs = 0; | 462 | _subscribedEventsMs = 0; |
@@ -481,7 +490,7 @@ public class BSCharacter : PhysicsActor | |||
481 | 490 | ||
482 | // The physics engine says that properties have updated. Update same and inform | 491 | // The physics engine says that properties have updated. Update same and inform |
483 | // the world that things have changed. | 492 | // the world that things have changed. |
484 | public void UpdateProperties(EntityProperties entprop) | 493 | public override void UpdateProperties(EntityProperties entprop) |
485 | { | 494 | { |
486 | _position = entprop.Position; | 495 | _position = entprop.Position; |
487 | _orientation = entprop.Rotation; | 496 | _orientation = entprop.Rotation; |
@@ -500,7 +509,7 @@ public class BSCharacter : PhysicsActor | |||
500 | // The collision, if it should be reported to the character, is placed in a collection | 509 | // The collision, if it should be reported to the character, is placed in a collection |
501 | // that will later be sent to the simulator when SendCollisions() is called. | 510 | // that will later be sent to the simulator when SendCollisions() is called. |
502 | CollisionEventUpdate collisionCollection = null; | 511 | CollisionEventUpdate collisionCollection = null; |
503 | public void Collide(uint collidingWith, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth) | 512 | public override void Collide(uint collidingWith, BSPhysObject collidee, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth) |
504 | { | 513 | { |
505 | // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); | 514 | // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); |
506 | 515 | ||
@@ -525,7 +534,7 @@ public class BSCharacter : PhysicsActor | |||
525 | } | 534 | } |
526 | } | 535 | } |
527 | 536 | ||
528 | public void SendCollisions() | 537 | public override void SendCollisions() |
529 | { | 538 | { |
530 | /* | 539 | /* |
531 | if (collisionCollection != null && collisionCollection.Count > 0) | 540 | if (collisionCollection != null && collisionCollection.Count > 0) |