diff options
author | Robert Adams | 2013-07-22 12:09:17 -0700 |
---|---|---|
committer | Robert Adams | 2013-07-22 12:09:17 -0700 |
commit | c45659863d8821a48a32e5b687c7b2a6d90b0300 (patch) | |
tree | ab9dcd8912dd1b339e70e6de22784d1db90fb9f3 | |
parent | Revert "BulletSim: only create vehicle prim actor when vehicles are enabled." (diff) | |
download | opensim-SC-c45659863d8821a48a32e5b687c7b2a6d90b0300.zip opensim-SC-c45659863d8821a48a32e5b687c7b2a6d90b0300.tar.gz opensim-SC-c45659863d8821a48a32e5b687c7b2a6d90b0300.tar.bz2 opensim-SC-c45659863d8821a48a32e5b687c7b2a6d90b0300.tar.xz |
Revert "BulletSim: move collision processing for linksets from BSPrimLinkable"
The changes don't seem to be ready for prime time.
This reverts commit b4c3a791aa55390bff071b3fe4bbe70c1d252703.
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 16 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 75 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 5 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 32 |
5 files changed, 18 insertions, 121 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 1540df1..4c2c1c1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -1001,7 +1001,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1001 | else if (newVelocityLengthSq < 0.001f) | 1001 | else if (newVelocityLengthSq < 0.001f) |
1002 | VehicleVelocity = Vector3.Zero; | 1002 | VehicleVelocity = Vector3.Zero; |
1003 | 1003 | ||
1004 | VDetailLog("{0}, MoveLinear,done,isColl={1},newVel={2}", ControllingPrim.LocalID, ControllingPrim.HasSomeCollision, VehicleVelocity ); | 1004 | VDetailLog("{0}, MoveLinear,done,isColl={1},newVel={2}", ControllingPrim.LocalID, ControllingPrim.IsColliding, VehicleVelocity ); |
1005 | 1005 | ||
1006 | } // end MoveLinear() | 1006 | } // end MoveLinear() |
1007 | 1007 | ||
@@ -1062,7 +1062,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1062 | Vector3 linearDeflectionW = linearDeflectionV * VehicleOrientation; | 1062 | Vector3 linearDeflectionW = linearDeflectionV * VehicleOrientation; |
1063 | 1063 | ||
1064 | // Optionally, if not colliding, don't effect world downward velocity. Let falling things fall. | 1064 | // Optionally, if not colliding, don't effect world downward velocity. Let falling things fall. |
1065 | if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.HasSomeCollision) | 1065 | if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.IsColliding) |
1066 | { | 1066 | { |
1067 | linearDeflectionW.Z = 0f; | 1067 | linearDeflectionW.Z = 0f; |
1068 | } | 1068 | } |
@@ -1222,7 +1222,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1222 | float targetHeight = Type == Vehicle.TYPE_BOAT ? GetWaterLevel(VehiclePosition) : GetTerrainHeight(VehiclePosition); | 1222 | float targetHeight = Type == Vehicle.TYPE_BOAT ? GetWaterLevel(VehiclePosition) : GetTerrainHeight(VehiclePosition); |
1223 | distanceAboveGround = VehiclePosition.Z - targetHeight; | 1223 | distanceAboveGround = VehiclePosition.Z - targetHeight; |
1224 | // Not colliding if the vehicle is off the ground | 1224 | // Not colliding if the vehicle is off the ground |
1225 | if (!Prim.HasSomeCollision) | 1225 | if (!Prim.IsColliding) |
1226 | { | 1226 | { |
1227 | // downForce = new Vector3(0, 0, -distanceAboveGround / m_bankingTimescale); | 1227 | // downForce = new Vector3(0, 0, -distanceAboveGround / m_bankingTimescale); |
1228 | VehicleVelocity += new Vector3(0, 0, -distanceAboveGround); | 1228 | VehicleVelocity += new Vector3(0, 0, -distanceAboveGround); |
@@ -1233,12 +1233,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1233 | // be computed with a motor. | 1233 | // be computed with a motor. |
1234 | // TODO: add interaction with banking. | 1234 | // TODO: add interaction with banking. |
1235 | VDetailLog("{0}, MoveLinear,limitMotorUp,distAbove={1},colliding={2},ret={3}", | 1235 | VDetailLog("{0}, MoveLinear,limitMotorUp,distAbove={1},colliding={2},ret={3}", |
1236 | Prim.LocalID, distanceAboveGround, Prim.HasSomeCollision, ret); | 1236 | Prim.LocalID, distanceAboveGround, Prim.IsColliding, ret); |
1237 | */ | 1237 | */ |
1238 | 1238 | ||
1239 | // Another approach is to measure if we're going up. If going up and not colliding, | 1239 | // Another approach is to measure if we're going up. If going up and not colliding, |
1240 | // the vehicle is in the air. Fix that by pushing down. | 1240 | // the vehicle is in the air. Fix that by pushing down. |
1241 | if (!ControllingPrim.HasSomeCollision && VehicleVelocity.Z > 0.1) | 1241 | if (!ControllingPrim.IsColliding && VehicleVelocity.Z > 0.1) |
1242 | { | 1242 | { |
1243 | // Get rid of any of the velocity vector that is pushing us up. | 1243 | // Get rid of any of the velocity vector that is pushing us up. |
1244 | float upVelocity = VehicleVelocity.Z; | 1244 | float upVelocity = VehicleVelocity.Z; |
@@ -1260,7 +1260,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1260 | } | 1260 | } |
1261 | */ | 1261 | */ |
1262 | VDetailLog("{0}, MoveLinear,limitMotorUp,collide={1},upVel={2},newVel={3}", | 1262 | VDetailLog("{0}, MoveLinear,limitMotorUp,collide={1},upVel={2},newVel={3}", |
1263 | ControllingPrim.LocalID, ControllingPrim.HasSomeCollision, upVelocity, VehicleVelocity); | 1263 | ControllingPrim.LocalID, ControllingPrim.IsColliding, upVelocity, VehicleVelocity); |
1264 | } | 1264 | } |
1265 | } | 1265 | } |
1266 | } | 1266 | } |
@@ -1270,14 +1270,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1270 | Vector3 appliedGravity = m_VehicleGravity * m_vehicleMass; | 1270 | Vector3 appliedGravity = m_VehicleGravity * m_vehicleMass; |
1271 | 1271 | ||
1272 | // Hack to reduce downward force if the vehicle is probably sitting on the ground | 1272 | // Hack to reduce downward force if the vehicle is probably sitting on the ground |
1273 | if (ControllingPrim.HasSomeCollision && IsGroundVehicle) | 1273 | if (ControllingPrim.IsColliding && IsGroundVehicle) |
1274 | appliedGravity *= BSParam.VehicleGroundGravityFudge; | 1274 | appliedGravity *= BSParam.VehicleGroundGravityFudge; |
1275 | 1275 | ||
1276 | VehicleAddForce(appliedGravity); | 1276 | VehicleAddForce(appliedGravity); |
1277 | 1277 | ||
1278 | VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={5}", | 1278 | VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={5}", |
1279 | ControllingPrim.LocalID, m_VehicleGravity, | 1279 | ControllingPrim.LocalID, m_VehicleGravity, |
1280 | ControllingPrim.HasSomeCollision, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); | 1280 | ControllingPrim.IsColliding, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); |
1281 | } | 1281 | } |
1282 | 1282 | ||
1283 | // ======================================================================= | 1283 | // ======================================================================= |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 78c0af7..ad8e10f 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | |||
@@ -203,33 +203,6 @@ public abstract class BSLinkset | |||
203 | return ret; | 203 | return ret; |
204 | } | 204 | } |
205 | 205 | ||
206 | // Called after a simulation step to post a collision with this object. | ||
207 | // Return 'true' if linkset processed the collision. 'false' says the linkset didn't have | ||
208 | // anything to add for the collision and it should be passed through normal processing. | ||
209 | // Default processing for a linkset. | ||
210 | public virtual bool HandleCollide(uint collidingWith, BSPhysObject collidee, | ||
211 | OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) | ||
212 | { | ||
213 | bool ret = false; | ||
214 | |||
215 | // prims in the same linkset cannot collide with each other | ||
216 | BSPrimLinkable convCollidee = collidee as BSPrimLinkable; | ||
217 | if (convCollidee != null && (LinksetID == convCollidee.Linkset.LinksetID)) | ||
218 | { | ||
219 | // By returning 'true', we tell the caller the collision has been 'handled' so it won't | ||
220 | // do anything about this collision and thus, effectivily, ignoring the collision. | ||
221 | ret = true; | ||
222 | } | ||
223 | else | ||
224 | { | ||
225 | // Not a collision between members of the linkset. Must be a real collision. | ||
226 | // So the linkset root can know if there is a collision anywhere in the linkset. | ||
227 | LinksetRoot.SomeCollisionSimulationStep = m_physicsScene.SimulationStep; | ||
228 | } | ||
229 | |||
230 | return ret; | ||
231 | } | ||
232 | |||
233 | // I am the root of a linkset and a new child is being added | 206 | // I am the root of a linkset and a new child is being added |
234 | // Called while LinkActivity is locked. | 207 | // Called while LinkActivity is locked. |
235 | protected abstract void AddChildToLinkset(BSPrimLinkable child); | 208 | protected abstract void AddChildToLinkset(BSPrimLinkable child); |
@@ -278,53 +251,6 @@ public abstract class BSLinkset | |||
278 | public abstract bool RemoveDependencies(BSPrimLinkable child); | 251 | public abstract bool RemoveDependencies(BSPrimLinkable child); |
279 | 252 | ||
280 | // ================================================================ | 253 | // ================================================================ |
281 | // Some physical setting happen to all members of the linkset | ||
282 | public virtual void SetPhysicalFriction(float friction) | ||
283 | { | ||
284 | ForEachMember((member) => | ||
285 | { | ||
286 | if (member.PhysBody.HasPhysicalBody) | ||
287 | m_physicsScene.PE.SetFriction(member.PhysBody, friction); | ||
288 | return false; // 'false' says to continue looping | ||
289 | } | ||
290 | ); | ||
291 | } | ||
292 | public virtual void SetPhysicalRestitution(float restitution) | ||
293 | { | ||
294 | ForEachMember((member) => | ||
295 | { | ||
296 | if (member.PhysBody.HasPhysicalBody) | ||
297 | m_physicsScene.PE.SetRestitution(member.PhysBody, restitution); | ||
298 | return false; // 'false' says to continue looping | ||
299 | } | ||
300 | ); | ||
301 | } | ||
302 | public virtual void SetPhysicalGravity(OMV.Vector3 gravity) | ||
303 | { | ||
304 | ForEachMember((member) => | ||
305 | { | ||
306 | if (member.PhysBody.HasPhysicalBody) | ||
307 | m_physicsScene.PE.SetGravity(member.PhysBody, gravity); | ||
308 | return false; // 'false' says to continue looping | ||
309 | } | ||
310 | ); | ||
311 | } | ||
312 | public virtual void ComputeLocalInertia() | ||
313 | { | ||
314 | ForEachMember((member) => | ||
315 | { | ||
316 | if (member.PhysBody.HasPhysicalBody) | ||
317 | { | ||
318 | OMV.Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(member.PhysShape.physShapeInfo, member.Mass); | ||
319 | member.Inertia = inertia * BSParam.VehicleInertiaFactor; | ||
320 | m_physicsScene.PE.SetMassProps(member.PhysBody, member.Mass, member.Inertia); | ||
321 | m_physicsScene.PE.UpdateInertiaTensor(member.PhysBody); | ||
322 | } | ||
323 | return false; // 'false' says to continue looping | ||
324 | } | ||
325 | ); | ||
326 | } | ||
327 | // ================================================================ | ||
328 | protected virtual float ComputeLinksetMass() | 254 | protected virtual float ComputeLinksetMass() |
329 | { | 255 | { |
330 | float mass = LinksetRoot.RawMass; | 256 | float mass = LinksetRoot.RawMass; |
@@ -385,5 +311,6 @@ public abstract class BSLinkset | |||
385 | if (m_physicsScene.PhysicsLogging.Enabled) | 311 | if (m_physicsScene.PhysicsLogging.Enabled) |
386 | m_physicsScene.DetailLog(msg, args); | 312 | m_physicsScene.DetailLog(msg, args); |
387 | } | 313 | } |
314 | |||
388 | } | 315 | } |
389 | } | 316 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index d34b797..fc4545f 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -353,16 +353,6 @@ public abstract class BSPhysObject : PhysicsActor | |||
353 | CollidingStep = BSScene.NotASimulationStep; | 353 | CollidingStep = BSScene.NotASimulationStep; |
354 | } | 354 | } |
355 | } | 355 | } |
356 | // Complex objects (like linksets) need to know if there is a collision on any part of | ||
357 | // their shape. 'IsColliding' has an existing definition of reporting a collision on | ||
358 | // only this specific prim or component of linksets. | ||
359 | // 'HasSomeCollision' is defined as reporting if there is a collision on any part of | ||
360 | // the complex body that this prim is the root of. | ||
361 | public virtual bool HasSomeCollision | ||
362 | { | ||
363 | get { return IsColliding; } | ||
364 | set { IsColliding = value; } | ||
365 | } | ||
366 | public override bool CollidingGround { | 356 | public override bool CollidingGround { |
367 | get { return (CollidingGroundStep == PhysScene.SimulationStep); } | 357 | get { return (CollidingGroundStep == PhysScene.SimulationStep); } |
368 | set | 358 | set |
@@ -396,7 +386,6 @@ public abstract class BSPhysObject : PhysicsActor | |||
396 | // Return 'true' if a collision was processed and should be sent up. | 386 | // Return 'true' if a collision was processed and should be sent up. |
397 | // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision. | 387 | // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision. |
398 | // Called at taint time from within the Step() function | 388 | // Called at taint time from within the Step() function |
399 | public delegate bool CollideCall(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth); | ||
400 | public virtual bool Collide(uint collidingWith, BSPhysObject collidee, | 389 | public virtual bool Collide(uint collidingWith, BSPhysObject collidee, |
401 | OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) | 390 | OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) |
402 | { | 391 | { |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 4771934..d43448e 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -495,8 +495,8 @@ public class BSPrim : BSPhysObject | |||
495 | } | 495 | } |
496 | } | 496 | } |
497 | 497 | ||
498 | // Find and return a handle to the current vehicle actor. | 498 | // Find and return a handle to the current vehicle actor. |
499 | // Return 'null' if there is no vehicle actor. | 499 | // Return 'null' if there is no vehicle actor. |
500 | public BSDynamics GetVehicleActor() | 500 | public BSDynamics GetVehicleActor() |
501 | { | 501 | { |
502 | BSDynamics ret = null; | 502 | BSDynamics ret = null; |
@@ -507,7 +507,6 @@ public class BSPrim : BSPhysObject | |||
507 | } | 507 | } |
508 | return ret; | 508 | return ret; |
509 | } | 509 | } |
510 | |||
511 | public override int VehicleType { | 510 | public override int VehicleType { |
512 | get { | 511 | get { |
513 | int ret = (int)Vehicle.TYPE_NONE; | 512 | int ret = (int)Vehicle.TYPE_NONE; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 2f392da..1fbcfcc 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs | |||
@@ -200,38 +200,20 @@ public class BSPrimLinkable : BSPrimDisplaced | |||
200 | } | 200 | } |
201 | 201 | ||
202 | // Called after a simulation step to post a collision with this object. | 202 | // Called after a simulation step to post a collision with this object. |
203 | // This returns 'true' if the collision has been queued and the SendCollisions call must | ||
204 | // be made at the end of the simulation step. | ||
205 | public override bool Collide(uint collidingWith, BSPhysObject collidee, | 203 | public override bool Collide(uint collidingWith, BSPhysObject collidee, |
206 | OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) | 204 | OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) |
207 | { | 205 | { |
208 | bool ret = false; | 206 | // prims in the same linkset cannot collide with each other |
209 | // Ask the linkset if it wants to handle the collision | 207 | BSPrimLinkable convCollidee = collidee as BSPrimLinkable; |
210 | if (!Linkset.HandleCollide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth)) | 208 | if (convCollidee != null && (this.Linkset.LinksetID == convCollidee.Linkset.LinksetID)) |
211 | { | 209 | { |
212 | // The linkset didn't handle it so pass the collision through normal processing | 210 | return false; |
213 | ret = base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); | ||
214 | } | 211 | } |
215 | return ret; | ||
216 | } | ||
217 | 212 | ||
218 | // A linkset reports any collision on any part of the linkset. | 213 | // TODO: handle collisions of other objects with with children of linkset. |
219 | public long SomeCollisionSimulationStep = 0; | 214 | // This is a problem for LinksetCompound since the children are packed into the root. |
220 | public override bool HasSomeCollision | ||
221 | { | ||
222 | get | ||
223 | { | ||
224 | return (SomeCollisionSimulationStep == PhysScene.SimulationStep) || base.IsColliding; | ||
225 | } | ||
226 | set | ||
227 | { | ||
228 | if (value) | ||
229 | SomeCollisionSimulationStep = PhysScene.SimulationStep; | ||
230 | else | ||
231 | SomeCollisionSimulationStep = 0; | ||
232 | 215 | ||
233 | base.HasSomeCollision = value; | 216 | return base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); |
234 | } | ||
235 | } | 217 | } |
236 | } | 218 | } |
237 | } | 219 | } |