From ee7cda261cbbc9dcd558c35eabc070cc0bf45644 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 18 Sep 2012 08:39:52 -0700 Subject: BulletSim: move a bunch of common logic out of BSPrim and BSCharacter and into the parent class BSPhysObject. Rework collision logic to enable extra collision after done colliding. Rename 'Scene' to 'PhysicsScene' to differentiate it from the simulator 'Scene'. --- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 138 +++++++++++++++++++-- 1 file changed, 131 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 3fe71e1..242aa80 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -39,26 +39,150 @@ namespace OpenSim.Region.Physics.BulletSPlugin // unless the difference is significant. public abstract class BSPhysObject : PhysicsActor { - public abstract BSLinkset Linkset { get; set; } + protected void BaseInitialize(BSScene parentScene) + { + PhysicsScene = parentScene; + Linkset = new BSLinkset(PhysicsScene, this); - public abstract bool Collide(uint collidingWith, BSPhysObject collidee, - OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth); - public abstract void SendCollisions(); + CollisionCollection = new CollisionEventUpdate(); + SubscribedEventsMs = 0; + CollidingStep = 0; + CollidingGroundStep = 0; + } - // Return the object mass without calculating it or side effects + public BSScene PhysicsScene { get; protected set; } + + public BSLinkset Linkset { get; set; } + + // Return the object mass without calculating it or having side effects public abstract float MassRaw { get; } // Reference to the physical body (btCollisionObject) of this object - public abstract BulletBody BSBody { get; set; } + public BulletBody BSBody { get; protected set; } // Reference to the physical shape (btCollisionShape) of this object - public abstract BulletShape BSShape { get; set; } + public BulletShape BSShape { get; protected set; } + // Stop all physical motion. public abstract void ZeroMotion(); + // Step the vehicle simulation for this object. A NOOP if the vehicle was not configured. public virtual void StepVehicle(float timeStep) { } + // Update the physical location and motion of the object. Called with data from Bullet. public abstract void UpdateProperties(EntityProperties entprop); + // Tell the object to clean up. public abstract void Destroy(); + + #region Collisions + + // Requested number of milliseconds between collision events. Zero means disabled. + protected int SubscribedEventsMs { get; set; } + // Given subscription, the time that a collision may be passed up + protected int NextCollisionOkTime { get; set; } + // The simulation step that last had a collision + protected long CollidingStep { get; set; } + // The simulation step that last had a collision with the ground + protected long CollidingGroundStep { get; set; } + // The collision flags we think are set in Bullet + protected CollisionFlags CurrentCollisionFlags { get; set; } + + // The collisions that have been collected this tick + protected CollisionEventUpdate CollisionCollection; + + // The simulation step is telling this object about a collision. + // Return 'true' if a collision was processed and should be sent up. + // Called at taint time from within the Step() function + public virtual bool Collide(uint collidingWith, BSPhysObject collidee, + OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) + { + bool ret = false; + + // The following lines make IsColliding() and IsCollidingGround() work + CollidingStep = PhysicsScene.SimulationStep; + if (collidingWith <= PhysicsScene.TerrainManager.HighestTerrainID) + { + CollidingGroundStep = PhysicsScene.SimulationStep; + } + + // prims in the same linkset cannot collide with each other + if (collidee != null && (this.Linkset.LinksetID == collidee.Linkset.LinksetID)) + { + return ret; + } + + PhysicsScene.PhysicsLogging.Write("{0},BSPhysObject.Collison,call,with={1}", LocalID, collidingWith); + + // if someone has subscribed for collision events.... + if (SubscribedEvents()) { + CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); + PhysicsScene.PhysicsLogging.Write("{0},BSPhysObject.Collison.AddCollider,call,with={1},point={2},normal={3},depth={4},next={5}", + LocalID, collidingWith, contactPoint, contactNormal, pentrationDepth, NextCollisionOkTime.ToString("yyyyMMddHHmmssfff")); + ret = true; + } + return ret; + } + + // Routine to send the collected collisions into the simulator. + // Also handles removal of this from the collection of objects with collisions if + // there are no collisions from this object. Mechanism is create one last + // collision event to make collision_end work. + public virtual void SendCollisions() + { + // throttle the collisions to the number of milliseconds specified in the subscription + int nowTime = PhysicsScene.SimulationNowTime; + if (nowTime >= NextCollisionOkTime) + { + NextCollisionOkTime = nowTime + SubscribedEventsMs; + + // We are called if we previously had collisions. If there are no collisions + // this time, send up one last empty event so OpenSim can sense collision end. + if (CollisionCollection.Count == 0) + PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); + + base.SendCollisionUpdate(CollisionCollection); + + // The collisionCollection structure is passed around in the simulator. + // Make sure we don't have a handle to that one and that a new one is used next time. + CollisionCollection = new CollisionEventUpdate(); + } + } + + // Subscribe for collision events. + // Parameter is the millisecond rate the caller wishes collision events to occur. + public override void SubscribeEvents(int ms) { + SubscribedEventsMs = ms; + if (ms > 0) + { + // make sure first collision happens + NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs); + PhysicsScene.PhysicsLogging.Write("{0},SubscribeEvents,call,ms={1},nextOKTime={2}", + LocalID, SubscribedEventsMs, NextCollisionOkTime.ToString("yyyyMMddHHmmssfff")); + + PhysicsScene.TaintedObject("BSPhysObject.SubscribeEvents", delegate() + { + CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); + }); + } + else + { + // Subscribing for zero or less is the same as unsubscribing + UnSubscribeEvents(); + } + } + public override void UnSubscribeEvents() { + SubscribedEventsMs = 0; + PhysicsScene.PhysicsLogging.Write("{0},UnSubscribeEvents,call", LocalID); + PhysicsScene.TaintedObject("BSPhysObject.UnSubscribeEvents", delegate() + { + CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); + }); + } + // Return 'true' if the simulator wants collision events + public override bool SubscribedEvents() { + return (SubscribedEventsMs > 0); + } + + #endregion // Collisions } } -- cgit v1.1 From 91efccabdcb45ed95ae35ab24ed5d3ed5508b463 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 18 Sep 2012 11:26:19 -0700 Subject: 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). --- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs') 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 // unless the difference is significant. public abstract class BSPhysObject : PhysicsActor { - protected void BaseInitialize(BSScene parentScene) + protected void BaseInitialize(BSScene parentScene, uint localID, string name) { PhysicsScene = parentScene; + LocalID = localID; + PhysObjectName = name; + Linkset = new BSLinkset(PhysicsScene, this); CollisionCollection = new CollisionEventUpdate(); @@ -51,6 +54,8 @@ public abstract class BSPhysObject : PhysicsActor } public BSScene PhysicsScene { get; protected set; } + // public override uint LocalID { get; set; } // Use the LocalID definition in PhysicsActor + public string PhysObjectName { get; protected set; } public BSLinkset Linkset { get; set; } @@ -111,13 +116,13 @@ public abstract class BSPhysObject : PhysicsActor return ret; } - PhysicsScene.PhysicsLogging.Write("{0},BSPhysObject.Collison,call,with={1}", LocalID, collidingWith); + DetailLog("{0},BSPhysObject.Collison,call,with={1}", LocalID, collidingWith); // if someone has subscribed for collision events.... if (SubscribedEvents()) { CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); - PhysicsScene.PhysicsLogging.Write("{0},BSPhysObject.Collison.AddCollider,call,with={1},point={2},normal={3},depth={4},next={5}", - LocalID, collidingWith, contactPoint, contactNormal, pentrationDepth, NextCollisionOkTime.ToString("yyyyMMddHHmmssfff")); + DetailLog("{0},BSPhysObject.Collison.AddCollider,call,with={1},point={2},normal={3},depth={4}", + LocalID, collidingWith, contactPoint, contactNormal, pentrationDepth); ret = true; } return ret; @@ -127,6 +132,8 @@ public abstract class BSPhysObject : PhysicsActor // Also handles removal of this from the collection of objects with collisions if // there are no collisions from this object. Mechanism is create one last // collision event to make collision_end work. + // Called at taint time from within the Step() function thus no locking problems + // with CollisionCollection and ObjectsWithNoMoreCollisions. public virtual void SendCollisions() { // throttle the collisions to the number of milliseconds specified in the subscription @@ -140,10 +147,11 @@ public abstract class BSPhysObject : PhysicsActor if (CollisionCollection.Count == 0) PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); + DetailLog("{0},SendCollisions.SendCollisionUpdate,call,numCollisions={1}", LocalID, CollisionCollection.Count); base.SendCollisionUpdate(CollisionCollection); // The collisionCollection structure is passed around in the simulator. - // Make sure we don't have a handle to that one and that a new one is used next time. + // Make sure we don't have a handle to that one and that a new one is used for next time. CollisionCollection = new CollisionEventUpdate(); } } @@ -156,8 +164,7 @@ public abstract class BSPhysObject : PhysicsActor { // make sure first collision happens NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs); - PhysicsScene.PhysicsLogging.Write("{0},SubscribeEvents,call,ms={1},nextOKTime={2}", - LocalID, SubscribedEventsMs, NextCollisionOkTime.ToString("yyyyMMddHHmmssfff")); + DetailLog("{0},SubscribeEvents,call,ms={1}", LocalID, SubscribedEventsMs); PhysicsScene.TaintedObject("BSPhysObject.SubscribeEvents", delegate() { @@ -172,7 +179,7 @@ public abstract class BSPhysObject : PhysicsActor } public override void UnSubscribeEvents() { SubscribedEventsMs = 0; - PhysicsScene.PhysicsLogging.Write("{0},UnSubscribeEvents,call", LocalID); + DetailLog("{0},UnSubscribeEvents,call", LocalID); PhysicsScene.TaintedObject("BSPhysObject.UnSubscribeEvents", delegate() { CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); @@ -184,5 +191,11 @@ public abstract class BSPhysObject : PhysicsActor } #endregion // Collisions + + // High performance detailed logging routine used by the physical objects. + protected void DetailLog(string msg, params Object[] args) + { + PhysicsScene.PhysicsLogging.Write(msg, args); + } } } -- cgit v1.1 From 22290ef35aa13edb1501c69b3cce63a885302563 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 20 Sep 2012 10:12:51 -0700 Subject: 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. --- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs') 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 // unless the difference is significant. public abstract class BSPhysObject : PhysicsActor { - protected void BaseInitialize(BSScene parentScene, uint localID, string name) + protected void BaseInitialize(BSScene parentScene, uint localID, string name, string typeName) { PhysicsScene = parentScene; LocalID = localID; PhysObjectName = name; + TypeName = typeName; Linkset = new BSLinkset(PhysicsScene, this); @@ -56,6 +57,7 @@ public abstract class BSPhysObject : PhysicsActor public BSScene PhysicsScene { get; protected set; } // public override uint LocalID { get; set; } // Use the LocalID definition in PhysicsActor public string PhysObjectName { get; protected set; } + public string TypeName { get; protected set; } public BSLinkset Linkset { get; set; } @@ -63,9 +65,9 @@ public abstract class BSPhysObject : PhysicsActor public abstract float MassRaw { get; } // Reference to the physical body (btCollisionObject) of this object - public BulletBody BSBody { get; protected set; } + public BulletBody BSBody; // Reference to the physical shape (btCollisionShape) of this object - public BulletShape BSShape { get; protected set; } + public BulletShape BSShape; // Stop all physical motion. public abstract void ZeroMotion(); @@ -116,13 +118,11 @@ public abstract class BSPhysObject : PhysicsActor return ret; } - DetailLog("{0},BSPhysObject.Collison,call,with={1}", LocalID, collidingWith); - // if someone has subscribed for collision events.... if (SubscribedEvents()) { CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); - DetailLog("{0},BSPhysObject.Collison.AddCollider,call,with={1},point={2},normal={3},depth={4}", - LocalID, collidingWith, contactPoint, contactNormal, pentrationDepth); + // DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}", + // LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth); ret = true; } return ret; @@ -147,7 +147,7 @@ public abstract class BSPhysObject : PhysicsActor if (CollisionCollection.Count == 0) PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); - DetailLog("{0},SendCollisions.SendCollisionUpdate,call,numCollisions={1}", LocalID, CollisionCollection.Count); + // DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); base.SendCollisionUpdate(CollisionCollection); // The collisionCollection structure is passed around in the simulator. @@ -164,9 +164,8 @@ public abstract class BSPhysObject : PhysicsActor { // make sure first collision happens NextCollisionOkTime = Util.EnvironmentTickCountSubtract(SubscribedEventsMs); - DetailLog("{0},SubscribeEvents,call,ms={1}", LocalID, SubscribedEventsMs); - PhysicsScene.TaintedObject("BSPhysObject.SubscribeEvents", delegate() + PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate() { CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); }); @@ -179,8 +178,7 @@ public abstract class BSPhysObject : PhysicsActor } public override void UnSubscribeEvents() { SubscribedEventsMs = 0; - DetailLog("{0},UnSubscribeEvents,call", LocalID); - PhysicsScene.TaintedObject("BSPhysObject.UnSubscribeEvents", delegate() + PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() { CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); }); -- cgit v1.1 From d016051fa028a485b09fac47b3fa3d8fd08e207a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 23 Sep 2012 18:39:46 -0700 Subject: BulletSim: renamed members of BulletShape, BulletSim and BulletBody so the members case is consistant. Caused modifications everywhere. New logic in BSShapeCollection to track use and sharing of shapes. I just reslized, though, that shapes cannot be shared because the shape's UserPointer is the localID of the prim and is required for tracking collisions. More changes coming. Added DuplicateCollisionShape2() to API and changed BuildNativeShape2 to take a ShapeData structure so don't have to pass so many parameters. This matches the latest version of BulletSim.dll. Additions and removal of DetailLog() statements for debugging. --- OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 70a10b1..6a9fe50 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -121,8 +121,8 @@ public abstract class BSPhysObject : PhysicsActor // if someone has subscribed for collision events.... if (SubscribedEvents()) { CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); - // DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}", - // LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth); + DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}", + LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth); ret = true; } return ret; @@ -147,7 +147,7 @@ public abstract class BSPhysObject : PhysicsActor if (CollisionCollection.Count == 0) PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); - // DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); + DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); base.SendCollisionUpdate(CollisionCollection); // The collisionCollection structure is passed around in the simulator. @@ -158,7 +158,8 @@ public abstract class BSPhysObject : PhysicsActor // Subscribe for collision events. // Parameter is the millisecond rate the caller wishes collision events to occur. - public override void SubscribeEvents(int ms) { + public override void SubscribeEvents(int ms) { + DetailLog("{0},BSScene.SubscribeEvents,subscribing,ms={1}", BSScene.DetailLogZero, ms); SubscribedEventsMs = ms; if (ms > 0) { @@ -167,7 +168,7 @@ public abstract class BSPhysObject : PhysicsActor PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate() { - CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); + CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); }); } else @@ -177,10 +178,11 @@ public abstract class BSPhysObject : PhysicsActor } } public override void UnSubscribeEvents() { + DetailLog("{0},BSScene.UnSubscribeEvents,unsubscribing", BSScene.DetailLogZero); SubscribedEventsMs = 0; PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() { - CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); + CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); }); } // Return 'true' if the simulator wants collision events -- cgit v1.1 From 735d89e3692bb7c620b9e3c248a1dbd5924b8b3f Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 25 Sep 2012 15:01:18 -0700 Subject: BulletSim: btGhostObjects working to make 'volume detect' work. Rearrangement and cleanup of shape collection code. Much more readable. Enabling and use of collision filters and masks. Addition of ID to body creation BulletSimAPI calls so always set in shape for collision reporting. Change default of ShouldSplitSimulationIslands and ShouldRandomizeSolverOrder from 'false' to 'true'. When 'false', this suppresses NO_CONTACT_RESPONSE which makes volume detect fail. --- OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 6a9fe50..3458477 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -123,6 +123,7 @@ public abstract class BSPhysObject : PhysicsActor CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}", LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth); + ret = true; } return ret; @@ -145,7 +146,10 @@ public abstract class BSPhysObject : PhysicsActor // We are called if we previously had collisions. If there are no collisions // this time, send up one last empty event so OpenSim can sense collision end. if (CollisionCollection.Count == 0) + { + // If I have no collisions this time, remove me from the list of objects with collisions. PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); + } DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); base.SendCollisionUpdate(CollisionCollection); @@ -159,7 +163,7 @@ public abstract class BSPhysObject : PhysicsActor // Subscribe for collision events. // Parameter is the millisecond rate the caller wishes collision events to occur. public override void SubscribeEvents(int ms) { - DetailLog("{0},BSScene.SubscribeEvents,subscribing,ms={1}", BSScene.DetailLogZero, ms); + DetailLog("{0},{1}.SubscribeEvents,subscribing,ms={2}", LocalID, TypeName, ms); SubscribedEventsMs = ms; if (ms > 0) { @@ -178,7 +182,7 @@ public abstract class BSPhysObject : PhysicsActor } } public override void UnSubscribeEvents() { - DetailLog("{0},BSScene.UnSubscribeEvents,unsubscribing", BSScene.DetailLogZero); + DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName); SubscribedEventsMs = 0; PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() { -- cgit v1.1 From 4589bc84a32366c6aae68b67f1fc7a2ee08be86d Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 26 Sep 2012 09:25:56 -0700 Subject: BulletSim: Terrain sets proper collision flags on creation. Static objects are set to ISLAND_SLEEPING rather than DISABLE_SIMULATION. Might reconsider this and, alternatively, have dynamic objects force activation. Clean up use of DetailLog(). --- OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 3458477..4f83adc 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -121,8 +121,8 @@ public abstract class BSPhysObject : PhysicsActor // if someone has subscribed for collision events.... if (SubscribedEvents()) { CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); - DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}", - LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth); + // DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}", + // LocalID, TypeName, collidingWith, contactPoint, contactNormal, pentrationDepth); ret = true; } @@ -151,7 +151,7 @@ public abstract class BSPhysObject : PhysicsActor PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); } - DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); + // DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); base.SendCollisionUpdate(CollisionCollection); // The collisionCollection structure is passed around in the simulator. @@ -163,7 +163,7 @@ public abstract class BSPhysObject : PhysicsActor // Subscribe for collision events. // Parameter is the millisecond rate the caller wishes collision events to occur. public override void SubscribeEvents(int ms) { - DetailLog("{0},{1}.SubscribeEvents,subscribing,ms={2}", LocalID, TypeName, ms); + // DetailLog("{0},{1}.SubscribeEvents,subscribing,ms={2}", LocalID, TypeName, ms); SubscribedEventsMs = ms; if (ms > 0) { @@ -182,7 +182,7 @@ public abstract class BSPhysObject : PhysicsActor } } public override void UnSubscribeEvents() { - DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName); + // DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName); SubscribedEventsMs = 0; PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() { -- cgit v1.1 From f82b903deeaaf8eaa7ae5c4d4b7e917dd0a6ce7b Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 27 Sep 2012 08:23:29 -0700 Subject: BulletSim: Fix linkset crash. Caused by the different body and shape pointers at runtime and at taint-time. Now passes the body into the taint. Vehicles zero inertia when active to eliminate Bullet's contribution to vehicle motion. --- OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 4f83adc..df95625 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -135,8 +135,11 @@ public abstract class BSPhysObject : PhysicsActor // collision event to make collision_end work. // Called at taint time from within the Step() function thus no locking problems // with CollisionCollection and ObjectsWithNoMoreCollisions. - public virtual void SendCollisions() + // Return 'true' if there were some actual collisions passed up + public virtual bool SendCollisions() { + bool ret = true; + // throttle the collisions to the number of milliseconds specified in the subscription int nowTime = PhysicsScene.SimulationNowTime; if (nowTime >= NextCollisionOkTime) @@ -148,7 +151,7 @@ public abstract class BSPhysObject : PhysicsActor if (CollisionCollection.Count == 0) { // If I have no collisions this time, remove me from the list of objects with collisions. - PhysicsScene.ObjectsWithNoMoreCollisions.Add(this); + ret = false; } // DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); @@ -158,6 +161,7 @@ public abstract class BSPhysObject : PhysicsActor // Make sure we don't have a handle to that one and that a new one is used for next time. CollisionCollection = new CollisionEventUpdate(); } + return ret; } // Subscribe for collision events. -- cgit v1.1 From 7b65985047bdf0789fe3eccf8f515279f362abf1 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 27 Sep 2012 09:31:33 -0700 Subject: BulletSim: remove the trailing spaces from lines to make git happier --- OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index df95625..d9b738b 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -100,7 +100,7 @@ public abstract class BSPhysObject : PhysicsActor // The simulation step is telling this object about a collision. // Return 'true' if a collision was processed and should be sent up. // Called at taint time from within the Step() function - public virtual bool Collide(uint collidingWith, BSPhysObject collidee, + public virtual bool Collide(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) { bool ret = false; -- cgit v1.1