mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 10:15:33 +08:00
BulletSim: do not zero an avatar's standing velocity if it is standing
on a moving object. Rearrange pre/post action subscription code to put more in locks. Add meshmerizer params to BulletSimTestUtil scene creation (and fix line endings). Rebuilt version of DLLs and SOs with cleaned up code and no profiling for sure.
This commit is contained in:
@@ -96,6 +96,7 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
CollidingStep = 0;
|
||||
CollidingGroundStep = 0;
|
||||
CollisionAccumulation = 0;
|
||||
ColliderIsMoving = false;
|
||||
CollisionScore = 0;
|
||||
}
|
||||
|
||||
@@ -177,13 +178,14 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
public abstract OMV.Vector3 RawPosition { get; set; }
|
||||
public abstract OMV.Vector3 ForcePosition { get; set; }
|
||||
|
||||
// Position is what the simulator thinks the positions of the prim is.
|
||||
// 'Position' and 'Orientation' is what the simulator thinks the positions of the prim is.
|
||||
// Because Bullet needs the zero coordinate to be the center of mass of the linkset,
|
||||
// sometimes it is necessary to displace the position the physics engine thinks
|
||||
// the position is. PositionDisplacement must be added and removed from the
|
||||
// position as the simulator position is stored and fetched from the physics
|
||||
// engine.
|
||||
// engine. Similar to OrientationDisplacement.
|
||||
public virtual OMV.Vector3 PositionDisplacement { get; set; }
|
||||
public virtual OMV.Quaternion OrientationDisplacement { get; set; }
|
||||
|
||||
public abstract OMV.Quaternion RawOrientation { get; set; }
|
||||
public abstract OMV.Quaternion ForceOrientation { get; set; }
|
||||
@@ -240,6 +242,9 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
protected long CollidingObjectStep { get; set; }
|
||||
// The collision flags we think are set in Bullet
|
||||
protected CollisionFlags CurrentCollisionFlags { get; set; }
|
||||
// On a collision, check the collider and remember if the last collider was moving
|
||||
// Used to modify the standing of avatars (avatars on stationary things stand still)
|
||||
protected bool ColliderIsMoving;
|
||||
|
||||
// Count of collisions for this object
|
||||
protected long CollisionAccumulation { get; set; }
|
||||
@@ -307,7 +312,10 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
|
||||
CollisionAccumulation++;
|
||||
|
||||
// if someone has subscribed for collision events....
|
||||
// For movement tests, remember if we are colliding with an object that is moving.
|
||||
ColliderIsMoving = collidee != null ? collidee.RawVelocity != OMV.Vector3.Zero : false;
|
||||
|
||||
// If someone has subscribed for collision events log the collision so it will be reported up
|
||||
if (SubscribedEvents()) {
|
||||
CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
|
||||
DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}",
|
||||
@@ -393,12 +401,13 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
public override bool SubscribedEvents() {
|
||||
return (SubscribedEventsMs > 0);
|
||||
}
|
||||
// Because 'CollisionScore' is calls many times while sorting it should not be recomputed
|
||||
// Because 'CollisionScore' is called many times while sorting, it should not be recomputed
|
||||
// each time called. So this is built to be light weight for each collision and to do
|
||||
// all the processing when the user asks for the info.
|
||||
public void ComputeCollisionScore()
|
||||
{
|
||||
// Scale the collision count by the time since the last collision
|
||||
// Scale the collision count by the time since the last collision.
|
||||
// The "+1" prevents dividing by zero.
|
||||
long timeAgo = PhysicsScene.SimulationStep - CollidingStep + 1;
|
||||
CollisionScore = CollisionAccumulation / timeAgo;
|
||||
}
|
||||
@@ -423,13 +432,15 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
UnRegisterPreStepAction(op, id);
|
||||
|
||||
RegisteredPrestepActions[identifier] = actn;
|
||||
|
||||
PhysicsScene.BeforeStep += actn;
|
||||
}
|
||||
PhysicsScene.BeforeStep += actn;
|
||||
DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier);
|
||||
}
|
||||
|
||||
// Unregister a pre step action. Safe to call if the action has not been registered.
|
||||
protected void UnRegisterPreStepAction(string op, uint id)
|
||||
// Returns 'true' if an action was actually removed
|
||||
protected bool UnRegisterPreStepAction(string op, uint id)
|
||||
{
|
||||
string identifier = op + "-" + id.ToString();
|
||||
bool removed = false;
|
||||
@@ -443,6 +454,7 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
}
|
||||
}
|
||||
DetailLog("{0},BSPhysObject.UnRegisterPreStepAction,id={1},removed={2}", LocalID, identifier, removed);
|
||||
return removed;
|
||||
}
|
||||
|
||||
protected void UnRegisterAllPreStepActions()
|
||||
@@ -468,13 +480,15 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
UnRegisterPostStepAction(op, id);
|
||||
|
||||
RegisteredPoststepActions[identifier] = actn;
|
||||
|
||||
PhysicsScene.AfterStep += actn;
|
||||
}
|
||||
PhysicsScene.AfterStep += actn;
|
||||
DetailLog("{0},BSPhysObject.RegisterPostStepAction,id={1}", LocalID, identifier);
|
||||
}
|
||||
|
||||
// Unregister a pre step action. Safe to call if the action has not been registered.
|
||||
protected void UnRegisterPostStepAction(string op, uint id)
|
||||
// Returns 'true' if an action was actually removed.
|
||||
protected bool UnRegisterPostStepAction(string op, uint id)
|
||||
{
|
||||
string identifier = op + "-" + id.ToString();
|
||||
bool removed = false;
|
||||
@@ -488,6 +502,7 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
}
|
||||
}
|
||||
DetailLog("{0},BSPhysObject.UnRegisterPostStepAction,id={1},removed={2}", LocalID, identifier, removed);
|
||||
return removed;
|
||||
}
|
||||
|
||||
protected void UnRegisterAllPostStepActions()
|
||||
|
||||
Reference in New Issue
Block a user