aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRobert Adams2013-07-23 08:13:01 -0700
committerRobert Adams2013-07-23 08:13:01 -0700
commitaec8852af793699a4c1093a38b992daf2dbd97f3 (patch)
tree8d628e8e17e0773fc2ee95e500a2ae919fcd6da9
parentRevert "Revert "Add experimental stubs for an extension function interface on... (diff)
downloadopensim-SC_OLD-aec8852af793699a4c1093a38b992daf2dbd97f3.zip
opensim-SC_OLD-aec8852af793699a4c1093a38b992daf2dbd97f3.tar.gz
opensim-SC_OLD-aec8852af793699a4c1093a38b992daf2dbd97f3.tar.bz2
opensim-SC_OLD-aec8852af793699a4c1093a38b992daf2dbd97f3.tar.xz
Revert "Revert "BulletSim: move collision processing for linksets from BSPrimLinkable""
Found that the vehicle movement problem was not caused by these physics changes. This reverts commit c45659863d8821a48a32e5b687c7b2a6d90b0300.
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs16
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs75
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs11
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs5
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs32
5 files changed, 121 insertions, 18 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 4c2c1c1..1540df1 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.IsColliding, VehicleVelocity ); 1004 VDetailLog("{0}, MoveLinear,done,isColl={1},newVel={2}", ControllingPrim.LocalID, ControllingPrim.HasSomeCollision, 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.IsColliding) 1065 if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.HasSomeCollision)
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.IsColliding) 1225 if (!Prim.HasSomeCollision)
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.IsColliding, ret); 1236 Prim.LocalID, distanceAboveGround, Prim.HasSomeCollision, 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.IsColliding && VehicleVelocity.Z > 0.1) 1241 if (!ControllingPrim.HasSomeCollision && 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.IsColliding, upVelocity, VehicleVelocity); 1263 ControllingPrim.LocalID, ControllingPrim.HasSomeCollision, 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.IsColliding && IsGroundVehicle) 1273 if (ControllingPrim.HasSomeCollision && 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.IsColliding, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); 1280 ControllingPrim.HasSomeCollision, 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 ad8e10f..78c0af7 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -203,6 +203,33 @@ 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
206 // I am the root of a linkset and a new child is being added 233 // I am the root of a linkset and a new child is being added
207 // Called while LinkActivity is locked. 234 // Called while LinkActivity is locked.
208 protected abstract void AddChildToLinkset(BSPrimLinkable child); 235 protected abstract void AddChildToLinkset(BSPrimLinkable child);
@@ -251,6 +278,53 @@ public abstract class BSLinkset
251 public abstract bool RemoveDependencies(BSPrimLinkable child); 278 public abstract bool RemoveDependencies(BSPrimLinkable child);
252 279
253 // ================================================================ 280 // ================================================================
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 // ================================================================
254 protected virtual float ComputeLinksetMass() 328 protected virtual float ComputeLinksetMass()
255 { 329 {
256 float mass = LinksetRoot.RawMass; 330 float mass = LinksetRoot.RawMass;
@@ -311,6 +385,5 @@ public abstract class BSLinkset
311 if (m_physicsScene.PhysicsLogging.Enabled) 385 if (m_physicsScene.PhysicsLogging.Enabled)
312 m_physicsScene.DetailLog(msg, args); 386 m_physicsScene.DetailLog(msg, args);
313 } 387 }
314
315} 388}
316} 389}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index fc4545f..d34b797 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -353,6 +353,16 @@ 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 }
356 public override bool CollidingGround { 366 public override bool CollidingGround {
357 get { return (CollidingGroundStep == PhysScene.SimulationStep); } 367 get { return (CollidingGroundStep == PhysScene.SimulationStep); }
358 set 368 set
@@ -386,6 +396,7 @@ public abstract class BSPhysObject : PhysicsActor
386 // Return 'true' if a collision was processed and should be sent up. 396 // Return 'true' if a collision was processed and should be sent up.
387 // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision. 397 // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision.
388 // Called at taint time from within the Step() function 398 // 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);
389 public virtual bool Collide(uint collidingWith, BSPhysObject collidee, 400 public virtual bool Collide(uint collidingWith, BSPhysObject collidee,
390 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) 401 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
391 { 402 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index d43448e..4771934 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,6 +507,7 @@ public class BSPrim : BSPhysObject
507 } 507 }
508 return ret; 508 return ret;
509 } 509 }
510
510 public override int VehicleType { 511 public override int VehicleType {
511 get { 512 get {
512 int ret = (int)Vehicle.TYPE_NONE; 513 int ret = (int)Vehicle.TYPE_NONE;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
index 1fbcfcc..2f392da 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
@@ -200,20 +200,38 @@ 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.
203 public override bool Collide(uint collidingWith, BSPhysObject collidee, 205 public override bool Collide(uint collidingWith, BSPhysObject collidee,
204 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) 206 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
205 { 207 {
206 // prims in the same linkset cannot collide with each other 208 bool ret = false;
207 BSPrimLinkable convCollidee = collidee as BSPrimLinkable; 209 // Ask the linkset if it wants to handle the collision
208 if (convCollidee != null && (this.Linkset.LinksetID == convCollidee.Linkset.LinksetID)) 210 if (!Linkset.HandleCollide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth))
209 { 211 {
210 return false; 212 // The linkset didn't handle it so pass the collision through normal processing
213 ret = base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth);
211 } 214 }
215 return ret;
216 }
212 217
213 // TODO: handle collisions of other objects with with children of linkset. 218 // A linkset reports any collision on any part of the linkset.
214 // This is a problem for LinksetCompound since the children are packed into the root. 219 public long SomeCollisionSimulationStep = 0;
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;
215 232
216 return base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); 233 base.HasSomeCollision = value;
234 }
217 } 235 }
218} 236}
219} 237}