diff options
author | Robert Adams | 2012-09-18 11:26:19 -0700 |
---|---|---|
committer | Robert Adams | 2012-09-27 22:01:16 -0700 |
commit | 91efccabdcb45ed95ae35ab24ed5d3ed5508b463 (patch) | |
tree | fb801ca0bd72aae3427a5ca439f807ec3802d7c3 /OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |
parent | BulletSim: move a bunch of common logic out of BSPrim and BSCharacter (diff) | |
download | opensim-SC-91efccabdcb45ed95ae35ab24ed5d3ed5508b463.zip opensim-SC-91efccabdcb45ed95ae35ab24ed5d3ed5508b463.tar.gz opensim-SC-91efccabdcb45ed95ae35ab24ed5d3ed5508b463.tar.bz2 opensim-SC-91efccabdcb45ed95ae35ab24ed5d3ed5508b463.tar.xz |
BulletSim: Convert BSCharacter to use common BSPhysObject code and variables.
Fix avatar height calculation to properly account for the capsule ends.
Rearrange some locking in TerrainManager to eliminate possible race conditions.
Move DetailLog() definition into common BSPhysObject class.
Some variable renaming to make usage clearer (refactor.rename makes this so easy).
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 242aa80..b575e37 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -39,9 +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) | 42 | protected void BaseInitialize(BSScene parentScene, uint localID, string name) |
43 | { | 43 | { |
44 | PhysicsScene = parentScene; | 44 | PhysicsScene = parentScene; |
45 | LocalID = localID; | ||
46 | PhysObjectName = name; | ||
47 | |||
45 | Linkset = new BSLinkset(PhysicsScene, this); | 48 | Linkset = new BSLinkset(PhysicsScene, this); |
46 | 49 | ||
47 | CollisionCollection = new CollisionEventUpdate(); | 50 | CollisionCollection = new CollisionEventUpdate(); |
@@ -51,6 +54,8 @@ public abstract class BSPhysObject : PhysicsActor | |||
51 | } | 54 | } |
52 | 55 | ||
53 | public BSScene PhysicsScene { get; protected set; } | 56 | public BSScene PhysicsScene { get; protected set; } |
57 | // public override uint LocalID { get; set; } // Use the LocalID definition in PhysicsActor | ||
58 | public string PhysObjectName { get; protected set; } | ||
54 | 59 | ||
55 | public BSLinkset Linkset { get; set; } | 60 | public BSLinkset Linkset { get; set; } |
56 | 61 | ||
@@ -111,13 +116,13 @@ public abstract class BSPhysObject : PhysicsActor | |||
111 | return ret; | 116 | return ret; |
112 | } | 117 | } |
113 | 118 | ||
114 | PhysicsScene.PhysicsLogging.Write("{0},BSPhysObject.Collison,call,with={1}", LocalID, collidingWith); | 119 | DetailLog("{0},BSPhysObject.Collison,call,with={1}", LocalID, collidingWith); |
115 | 120 | ||
116 | // if someone has subscribed for collision events.... | 121 | // if someone has subscribed for collision events.... |
117 | if (SubscribedEvents()) { | 122 | if (SubscribedEvents()) { |
118 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); | 123 | CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); |
119 | PhysicsScene.PhysicsLogging.Write("{0},BSPhysObject.Collison.AddCollider,call,with={1},point={2},normal={3},depth={4},next={5}", | 124 | DetailLog("{0},BSPhysObject.Collison.AddCollider,call,with={1},point={2},normal={3},depth={4}", |
120 | LocalID, collidingWith, contactPoint, contactNormal, pentrationDepth, NextCollisionOkTime.ToString("yyyyMMddHHmmssfff")); | 125 | LocalID, collidingWith, contactPoint, contactNormal, pentrationDepth); |
121 | ret = true; | 126 | ret = true; |
122 | } | 127 | } |
123 | return ret; | 128 | return ret; |
@@ -127,6 +132,8 @@ public abstract class BSPhysObject : PhysicsActor | |||
127 | // Also handles removal of this from the collection of objects with collisions if | 132 | // Also handles removal of this from the collection of objects with collisions if |
128 | // there are no collisions from this object. Mechanism is create one last | 133 | // there are no collisions from this object. Mechanism is create one last |
129 | // collision event to make collision_end work. | 134 | // collision event to make collision_end work. |
135 | // Called at taint time from within the Step() function thus no locking problems | ||
136 | // with CollisionCollection and ObjectsWithNoMoreCollisions. | ||
130 | public virtual void SendCollisions() | 137 | public virtual void SendCollisions() |
131 | { | 138 | { |
132 | // throttle the collisions to the number of milliseconds specified in the subscription | 139 | // throttle the collisions to the number of milliseconds specified in the subscription |
@@ -140,10 +147,11 @@ public abstract class BSPhysObject : PhysicsActor | |||
140 | if (CollisionCollection.Count == 0) | 147 | if (CollisionCollection.Count == 0) |
141 | PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); | 148 | PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); |
142 | 149 | ||
150 | DetailLog("{0},SendCollisions.SendCollisionUpdate,call,numCollisions={1}", LocalID, CollisionCollection.Count); | ||
143 | base.SendCollisionUpdate(CollisionCollection); | 151 | base.SendCollisionUpdate(CollisionCollection); |
144 | 152 | ||
145 | // The collisionCollection structure is passed around in the simulator. | 153 | // The collisionCollection structure is passed around in the simulator. |
146 | // Make sure we don't have a handle to that one and that a new one is used next time. | 154 | // Make sure we don't have a handle to that one and that a new one is used for next time. |
147 | CollisionCollection = new CollisionEventUpdate(); | 155 | CollisionCollection = new CollisionEventUpdate(); |
148 | } | 156 | } |
149 | } | 157 | } |
@@ -156,8 +164,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
156 | { | 164 | { |
157 | // make sure first collision happens | 165 | // make sure first collision happens |
158 | NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs); | 166 | NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs); |
159 | PhysicsScene.PhysicsLogging.Write("{0},SubscribeEvents,call,ms={1},nextOKTime={2}", | 167 | DetailLog("{0},SubscribeEvents,call,ms={1}", LocalID, SubscribedEventsMs); |
160 | LocalID, SubscribedEventsMs, NextCollisionOkTime.ToString("yyyyMMddHHmmssfff")); | ||
161 | 168 | ||
162 | PhysicsScene.TaintedObject("BSPhysObject.SubscribeEvents", delegate() | 169 | PhysicsScene.TaintedObject("BSPhysObject.SubscribeEvents", delegate() |
163 | { | 170 | { |
@@ -172,7 +179,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
172 | } | 179 | } |
173 | public override void UnSubscribeEvents() { | 180 | public override void UnSubscribeEvents() { |
174 | SubscribedEventsMs = 0; | 181 | SubscribedEventsMs = 0; |
175 | PhysicsScene.PhysicsLogging.Write("{0},UnSubscribeEvents,call", LocalID); | 182 | DetailLog("{0},UnSubscribeEvents,call", LocalID); |
176 | PhysicsScene.TaintedObject("BSPhysObject.UnSubscribeEvents", delegate() | 183 | PhysicsScene.TaintedObject("BSPhysObject.UnSubscribeEvents", delegate() |
177 | { | 184 | { |
178 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 185 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
@@ -184,5 +191,11 @@ public abstract class BSPhysObject : PhysicsActor | |||
184 | } | 191 | } |
185 | 192 | ||
186 | #endregion // Collisions | 193 | #endregion // Collisions |
194 | |||
195 | // High performance detailed logging routine used by the physical objects. | ||
196 | protected void DetailLog(string msg, params Object[] args) | ||
197 | { | ||
198 | PhysicsScene.PhysicsLogging.Write(msg, args); | ||
199 | } | ||
187 | } | 200 | } |
188 | } | 201 | } |