mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 17:32:42 +08:00
BulletSim: fix density since the simulator/viewer track density in a
funny unit that is 100 times real density (default 1000). Fix avatar drifting slowly when stationary flying. Fix for physical prims getting corrected for being under terrain when it was just its geometric center that was below terrain. Add PreUpdatePropertyAction allowing plugable modifiction of phys parameters returned from Bullet. Fix an exception setting GravityMultiplier on initialization. Update DLLs and SOs for good measure (no functional change).
This commit is contained in:
@@ -99,6 +99,9 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
CollisionAccumulation = 0;
|
||||
ColliderIsMoving = false;
|
||||
CollisionScore = 0;
|
||||
|
||||
// All axis free.
|
||||
LockedAxis = LockedAxisFree;
|
||||
}
|
||||
|
||||
// Tell the object to clean up.
|
||||
@@ -172,7 +175,8 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false);
|
||||
Friction = matAttrib.friction;
|
||||
Restitution = matAttrib.restitution;
|
||||
Density = matAttrib.density;
|
||||
Density = matAttrib.density / BSParam.DensityScaleFactor;
|
||||
DetailLog("{0},{1}.SetMaterial,Mat={2},frict={3},rest={4},den={5}", LocalID, TypeName, Material, Friction, Restitution, Density);
|
||||
}
|
||||
|
||||
// Stop all physical motion.
|
||||
@@ -220,6 +224,9 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
// computed center-of-mass (like in linksets).
|
||||
public OMV.Vector3? UserSetCenterOfMass { get; set; }
|
||||
|
||||
public OMV.Vector3 LockedAxis { get; set; } // zero means locked. one means free.
|
||||
public readonly OMV.Vector3 LockedAxisFree = new OMV.Vector3(1f, 1f, 1f); // All axis are free
|
||||
|
||||
#region Collisions
|
||||
|
||||
// Requested number of milliseconds between collision events. Zero means disabled.
|
||||
@@ -416,9 +423,7 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
{
|
||||
// Clean out any existing action
|
||||
UnRegisterPreStepAction(op, id);
|
||||
|
||||
RegisteredPrestepActions[identifier] = actn;
|
||||
|
||||
PhysicsScene.BeforeStep += actn;
|
||||
}
|
||||
DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier);
|
||||
@@ -464,9 +469,7 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
{
|
||||
// Clean out any existing action
|
||||
UnRegisterPostStepAction(op, id);
|
||||
|
||||
RegisteredPoststepActions[identifier] = actn;
|
||||
|
||||
PhysicsScene.AfterStep += actn;
|
||||
}
|
||||
DetailLog("{0},BSPhysObject.RegisterPostStepAction,id={1}", LocalID, identifier);
|
||||
@@ -503,7 +506,58 @@ public abstract class BSPhysObject : PhysicsActor
|
||||
}
|
||||
DetailLog("{0},BSPhysObject.UnRegisterAllPostStepActions,", LocalID);
|
||||
}
|
||||
|
||||
|
||||
// When an update to the physical properties happens, this event is fired to let
|
||||
// different actors to modify the update before it is passed around
|
||||
public delegate void PreUpdatePropertyAction(ref EntityProperties entprop);
|
||||
public event PreUpdatePropertyAction OnPreUpdateProperty;
|
||||
protected void TriggerPreUpdatePropertyAction(ref EntityProperties entprop)
|
||||
{
|
||||
PreUpdatePropertyAction actions = OnPreUpdateProperty;
|
||||
if (actions != null)
|
||||
actions(ref entprop);
|
||||
}
|
||||
|
||||
private Dictionary<string, PreUpdatePropertyAction> RegisteredPreUpdatePropertyActions = new Dictionary<string, PreUpdatePropertyAction>();
|
||||
public void RegisterPreUpdatePropertyAction(string identifier, PreUpdatePropertyAction actn)
|
||||
{
|
||||
lock (RegisteredPreUpdatePropertyActions)
|
||||
{
|
||||
// Clean out any existing action
|
||||
UnRegisterPreUpdatePropertyAction(identifier);
|
||||
RegisteredPreUpdatePropertyActions[identifier] = actn;
|
||||
OnPreUpdateProperty += actn;
|
||||
}
|
||||
DetailLog("{0},BSPhysObject.RegisterPreUpdatePropertyAction,id={1}", LocalID, identifier);
|
||||
}
|
||||
public bool UnRegisterPreUpdatePropertyAction(string identifier)
|
||||
{
|
||||
bool removed = false;
|
||||
lock (RegisteredPreUpdatePropertyActions)
|
||||
{
|
||||
if (RegisteredPreUpdatePropertyActions.ContainsKey(identifier))
|
||||
{
|
||||
OnPreUpdateProperty -= RegisteredPreUpdatePropertyActions[identifier];
|
||||
RegisteredPreUpdatePropertyActions.Remove(identifier);
|
||||
removed = true;
|
||||
}
|
||||
}
|
||||
DetailLog("{0},BSPhysObject.UnRegisterPreUpdatePropertyAction,id={1},removed={2}", LocalID, identifier, removed);
|
||||
return removed;
|
||||
}
|
||||
public void UnRegisterAllPreUpdatePropertyActions()
|
||||
{
|
||||
lock (RegisteredPreUpdatePropertyActions)
|
||||
{
|
||||
foreach (KeyValuePair<string, PreUpdatePropertyAction> kvp in RegisteredPreUpdatePropertyActions)
|
||||
{
|
||||
OnPreUpdateProperty -= kvp.Value;
|
||||
}
|
||||
RegisteredPreUpdatePropertyActions.Clear();
|
||||
}
|
||||
DetailLog("{0},BSPhysObject.UnRegisterAllPreUpdatePropertyAction,", LocalID);
|
||||
}
|
||||
|
||||
#endregion // Per Simulation Step actions
|
||||
|
||||
// High performance detailed logging routine used by the physical objects.
|
||||
|
||||
Reference in New Issue
Block a user