diff options
author | Robert Adams | 2012-09-20 10:12:51 -0700 |
---|---|---|
committer | Robert Adams | 2012-09-27 22:01:26 -0700 |
commit | 22290ef35aa13edb1501c69b3cce63a885302563 (patch) | |
tree | 2c4762479fb5336c3338acdd2d761fc8c15a04e9 /OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |
parent | BulletSim: add class and infrastructure for shape and object (diff) | |
download | opensim-SC-22290ef35aa13edb1501c69b3cce63a885302563.zip opensim-SC-22290ef35aa13edb1501c69b3cce63a885302563.tar.gz opensim-SC-22290ef35aa13edb1501c69b3cce63a885302563.tar.bz2 opensim-SC-22290ef35aa13edb1501c69b3cce63a885302563.tar.xz |
BulletSim: complete code for managed code shape and body tracking. Not debugged.
Eliminate some null exceptions created adding the above code.
Add and remove some detailed logging statements.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index b575e37..70a10b1 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -39,11 +39,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
39 | // unless the difference is significant. | 39 | // unless the difference is significant. |
40 | public abstract class BSPhysObject : PhysicsActor | 40 | public abstract class BSPhysObject : PhysicsActor |
41 | { | 41 | { |
42 | protected void BaseInitialize(BSScene parentScene, uint localID, string name) | 42 | protected void BaseInitialize(BSScene parentScene, uint localID, string name, string typeName) |
43 | { | 43 | { |
44 | PhysicsScene = parentScene; | 44 | PhysicsScene = parentScene; |
45 | LocalID = localID; | 45 | LocalID = localID; |
46 | PhysObjectName = name; | 46 | PhysObjectName = name; |
47 | TypeName = typeName; | ||
47 | 48 | ||
48 | Linkset = new BSLinkset(PhysicsScene, this); | 49 | Linkset = new BSLinkset(PhysicsScene, this); |
49 | 50 | ||
@@ -56,6 +57,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
56 | public BSScene PhysicsScene { get; protected set; } | 57 | public BSScene PhysicsScene { get; protected set; } |
57 | // public override uint LocalID { get; set; } // Use the LocalID definition in PhysicsActor | 58 | // public override uint LocalID { get; set; } // Use the LocalID definition in PhysicsActor |
58 | public string PhysObjectName { get; protected set; } | 59 | public string PhysObjectName { get; protected set; } |
60 | public string TypeName { get; protected set; } | ||
59 | 61 | ||
60 | public BSLinkset Linkset { get; set; } | 62 | public BSLinkset Linkset { get; set; } |
61 | 63 | ||
@@ -63,9 +65,9 @@ public abstract class BSPhysObject : PhysicsActor | |||
63 | public abstract float MassRaw { get; } | 65 | public abstract float MassRaw { get; } |
64 | 66 | ||
65 | // Reference to the physical body (btCollisionObject) of this object | 67 | // Reference to the physical body (btCollisionObject) of this object |
66 | public BulletBody BSBody { get; protected set; } | 68 | public BulletBody BSBody; |
67 | // Reference to the physical shape (btCollisionShape) of this object | 69 | // Reference to the physical shape (btCollisionShape) of this object |
68 | public BulletShape BSShape { get; protected set; } | 70 | public BulletShape BSShape; |
69 | 71 | ||
70 | // Stop all physical motion. | 72 | // Stop all physical motion. |
71 | public abstract void ZeroMotion(); | 73 | public abstract void ZeroMotion(); |
@@ -116,13 +118,11 @@ public abstract class BSPhysObject : PhysicsActor | |||
116 | return ret; | 118 | return ret; |
117 | } | 119 | } |
118 | 120 | ||
119 | DetailLog("{0},BSPhysObject.Collison,call,with={1}", LocalID, collidingWith); | ||
120 | |||
121 | // if someone has subscribed for collision events.... | 121 | // if someone has subscribed for collision events.... |
122 | if (SubscribedEvents()) { | 122 | if (SubscribedEvents()) { |
123 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); | 123 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); |
124 | DetailLog("{0},BSPhysObject.Collison.AddCollider,call,with={1},point={2},normal={3},depth={4}", | 124 | // DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}", |
125 | LocalID, collidingWith, contactPoint, contactNormal, pentrationDepth); | 125 | // LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth); |
126 | ret = true; | 126 | ret = true; |
127 | } | 127 | } |
128 | return ret; | 128 | return ret; |
@@ -147,7 +147,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
147 | if (CollisionCollection.Count == 0) | 147 | if (CollisionCollection.Count == 0) |
148 | PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); | 148 | PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); |
149 | 149 | ||
150 | DetailLog("{0},SendCollisions.SendCollisionUpdate,call,numCollisions={1}", LocalID, CollisionCollection.Count); | 150 | // DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); |
151 | base.SendCollisionUpdate(CollisionCollection); | 151 | base.SendCollisionUpdate(CollisionCollection); |
152 | 152 | ||
153 | // The collisionCollection structure is passed around in the simulator. | 153 | // The collisionCollection structure is passed around in the simulator. |
@@ -164,9 +164,8 @@ public abstract class BSPhysObject : PhysicsActor | |||
164 | { | 164 | { |
165 | // make sure first collision happens | 165 | // make sure first collision happens |
166 | NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs); | 166 | NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs); |
167 | DetailLog("{0},SubscribeEvents,call,ms={1}", LocalID, SubscribedEventsMs); | ||
168 | 167 | ||
169 | PhysicsScene.TaintedObject("BSPhysObject.SubscribeEvents", delegate() | 168 | PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate() |
170 | { | 169 | { |
171 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 170 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
172 | }); | 171 | }); |
@@ -179,8 +178,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
179 | } | 178 | } |
180 | public override void UnSubscribeEvents() { | 179 | public override void UnSubscribeEvents() { |
181 | SubscribedEventsMs = 0; | 180 | SubscribedEventsMs = 0; |
182 | DetailLog("{0},UnSubscribeEvents,call", LocalID); | 181 | PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() |
183 | PhysicsScene.TaintedObject("BSPhysObject.UnSubscribeEvents", delegate() | ||
184 | { | 182 | { |
185 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 183 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
186 | }); | 184 | }); |