Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
commit
77cd74ded6
|
@ -321,7 +321,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||||
// to avoid a race condition when the appearance module retrieves the item to set the asset id in
|
// to avoid a race condition when the appearance module retrieves the item to set the asset id in
|
||||||
// the AvatarAppearance structure.
|
// the AvatarAppearance structure.
|
||||||
item.AssetID = m_asset.FullID;
|
item.AssetID = m_asset.FullID;
|
||||||
m_Scene.InventoryService.UpdateItem(item);
|
if (item.AssetID != UUID.Zero)
|
||||||
|
m_Scene.InventoryService.UpdateItem(item);
|
||||||
|
|
||||||
if (m_uploadState == UploadState.Complete)
|
if (m_uploadState == UploadState.Complete)
|
||||||
{
|
{
|
||||||
|
|
|
@ -407,16 +407,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (item.Owner != remoteClient.AgentId)
|
if (item.Owner != remoteClient.AgentId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (UUID.Zero == transactionID)
|
item.Name = itemUpd.Name;
|
||||||
{
|
item.Description = itemUpd.Description;
|
||||||
item.Name = itemUpd.Name;
|
|
||||||
item.Description = itemUpd.Description;
|
|
||||||
|
|
||||||
// m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
// "[USER INVENTORY]: itemUpd {0} {1} {2} {3}, item {4} {5} {6} {7}",
|
// "[USER INVENTORY]: itemUpd {0} {1} {2} {3}, item {4} {5} {6} {7}",
|
||||||
// itemUpd.NextPermissions, itemUpd.GroupPermissions, itemUpd.EveryOnePermissions, item.Flags,
|
// itemUpd.NextPermissions, itemUpd.GroupPermissions, itemUpd.EveryOnePermissions, item.Flags,
|
||||||
// item.NextPermissions, item.GroupPermissions, item.EveryOnePermissions, item.CurrentPermissions);
|
// item.NextPermissions, item.GroupPermissions, item.EveryOnePermissions, item.CurrentPermissions);
|
||||||
|
|
||||||
|
if (itemUpd.NextPermissions != 0) // Use this to determine validity. Can never be 0 if valid
|
||||||
|
{
|
||||||
if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions))
|
if (item.NextPermissions != (itemUpd.NextPermissions & item.BasePermissions))
|
||||||
item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner;
|
item.Flags |= (uint)InventoryItemFlags.ObjectOverwriteNextOwner;
|
||||||
item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions;
|
item.NextPermissions = itemUpd.NextPermissions & item.BasePermissions;
|
||||||
|
@ -451,7 +451,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
InventoryService.UpdateItem(item);
|
InventoryService.UpdateItem(item);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (UUID.Zero != transactionID)
|
||||||
{
|
{
|
||||||
if (AgentTransactionsModule != null)
|
if (AgentTransactionsModule != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,7 +87,7 @@ public enum FixedShapeKey : ulong
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct ShapeData
|
public struct ShapeData
|
||||||
{
|
{
|
||||||
public uint ID;
|
public UInt32 ID;
|
||||||
public BSPhysicsShapeType Type;
|
public BSPhysicsShapeType Type;
|
||||||
public Vector3 Position;
|
public Vector3 Position;
|
||||||
public Quaternion Rotation;
|
public Quaternion Rotation;
|
||||||
|
@ -111,7 +111,7 @@ public struct ShapeData
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct SweepHit
|
public struct SweepHit
|
||||||
{
|
{
|
||||||
public uint ID;
|
public UInt32 ID;
|
||||||
public float Fraction;
|
public float Fraction;
|
||||||
public Vector3 Normal;
|
public Vector3 Normal;
|
||||||
public Vector3 Point;
|
public Vector3 Point;
|
||||||
|
@ -119,15 +119,15 @@ public struct SweepHit
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct RaycastHit
|
public struct RaycastHit
|
||||||
{
|
{
|
||||||
public uint ID;
|
public UInt32 ID;
|
||||||
public float Fraction;
|
public float Fraction;
|
||||||
public Vector3 Normal;
|
public Vector3 Normal;
|
||||||
}
|
}
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct CollisionDesc
|
public struct CollisionDesc
|
||||||
{
|
{
|
||||||
public uint aID;
|
public UInt32 aID;
|
||||||
public uint bID;
|
public UInt32 bID;
|
||||||
public Vector3 point;
|
public Vector3 point;
|
||||||
public Vector3 normal;
|
public Vector3 normal;
|
||||||
public float penetration;
|
public float penetration;
|
||||||
|
@ -135,7 +135,7 @@ public struct CollisionDesc
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct EntityProperties
|
public struct EntityProperties
|
||||||
{
|
{
|
||||||
public uint ID;
|
public UInt32 ID;
|
||||||
public Vector3 Position;
|
public Vector3 Position;
|
||||||
public Quaternion Rotation;
|
public Quaternion Rotation;
|
||||||
public Vector3 Velocity;
|
public Vector3 Velocity;
|
||||||
|
@ -325,7 +325,7 @@ public abstract BulletWorld Initialize(Vector3 maxPosition, ConfigurationParamet
|
||||||
public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep,
|
public abstract int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep,
|
||||||
out int updatedEntityCount, out int collidersCount);
|
out int updatedEntityCount, out int collidersCount);
|
||||||
|
|
||||||
public abstract bool UpdateParameter(BulletWorld world, uint localID, String parm, float value);
|
public abstract bool UpdateParameter(BulletWorld world, UInt32 localID, String parm, float value);
|
||||||
|
|
||||||
public abstract void Shutdown(BulletWorld sim);
|
public abstract void Shutdown(BulletWorld sim);
|
||||||
|
|
||||||
|
@ -366,24 +366,24 @@ public abstract void UpdateChildTransform(BulletShape pShape, int childIndex, Ve
|
||||||
|
|
||||||
public abstract void RecalculateCompoundShapeLocalAabb(BulletShape cShape);
|
public abstract void RecalculateCompoundShapeLocalAabb(BulletShape cShape);
|
||||||
|
|
||||||
public abstract BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, uint id);
|
public abstract BulletShape DuplicateCollisionShape(BulletWorld sim, BulletShape srcShape, UInt32 id);
|
||||||
|
|
||||||
public abstract bool DeleteCollisionShape(BulletWorld world, BulletShape shape);
|
public abstract bool DeleteCollisionShape(BulletWorld world, BulletShape shape);
|
||||||
|
|
||||||
public abstract CollisionObjectTypes GetBodyType(BulletBody obj);
|
public abstract CollisionObjectTypes GetBodyType(BulletBody obj);
|
||||||
|
|
||||||
public abstract BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot);
|
public abstract BulletBody CreateBodyFromShape(BulletWorld sim, BulletShape shape, UInt32 id, Vector3 pos, Quaternion rot);
|
||||||
|
|
||||||
public abstract BulletBody CreateBodyWithDefaultMotionState(BulletShape shape, uint id, Vector3 pos, Quaternion rot);
|
public abstract BulletBody CreateBodyWithDefaultMotionState(BulletShape shape, UInt32 id, Vector3 pos, Quaternion rot);
|
||||||
|
|
||||||
public abstract BulletBody CreateGhostFromShape(BulletWorld sim, BulletShape shape, uint id, Vector3 pos, Quaternion rot);
|
public abstract BulletBody CreateGhostFromShape(BulletWorld sim, BulletShape shape, UInt32 id, Vector3 pos, Quaternion rot);
|
||||||
|
|
||||||
public abstract void DestroyObject(BulletWorld sim, BulletBody obj);
|
public abstract void DestroyObject(BulletWorld sim, BulletBody obj);
|
||||||
|
|
||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
public abstract BulletShape CreateGroundPlaneShape(uint id, float height, float collisionMargin);
|
public abstract BulletShape CreateGroundPlaneShape(UInt32 id, float height, float collisionMargin);
|
||||||
|
|
||||||
public abstract BulletShape CreateTerrainShape(uint id, Vector3 size, float minHeight, float maxHeight, float[] heightMap,
|
public abstract BulletShape CreateTerrainShape(UInt32 id, Vector3 size, float minHeight, float maxHeight, float[] heightMap,
|
||||||
float scaleFactor, float collisionMargin);
|
float scaleFactor, float collisionMargin);
|
||||||
|
|
||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
|
@ -629,7 +629,7 @@ public abstract BulletConstraint GetConstraintRef(BulletBody obj, int index);
|
||||||
|
|
||||||
public abstract int GetNumConstraintRefs(BulletBody obj);
|
public abstract int GetNumConstraintRefs(BulletBody obj);
|
||||||
|
|
||||||
public abstract bool SetCollisionGroupMask(BulletBody body, uint filter, uint mask);
|
public abstract bool SetCollisionGroupMask(BulletBody body, UInt32 filter, UInt32 mask);
|
||||||
|
|
||||||
// =====================================================================================
|
// =====================================================================================
|
||||||
// btCollisionShape entries
|
// btCollisionShape entries
|
||||||
|
|
|
@ -56,7 +56,6 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
private int _physicsActorType;
|
private int _physicsActorType;
|
||||||
private bool _isPhysical;
|
private bool _isPhysical;
|
||||||
private bool _flying;
|
private bool _flying;
|
||||||
private bool _wasWalking; // 'true' if the avatar was walking/moving last frame
|
|
||||||
private bool _setAlwaysRun;
|
private bool _setAlwaysRun;
|
||||||
private bool _throttleUpdates;
|
private bool _throttleUpdates;
|
||||||
private bool _floatOnWater;
|
private bool _floatOnWater;
|
||||||
|
@ -84,7 +83,6 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
_position = pos;
|
_position = pos;
|
||||||
|
|
||||||
_flying = isFlying;
|
_flying = isFlying;
|
||||||
_wasWalking = true; // causes first step to initialize standing
|
|
||||||
_orientation = OMV.Quaternion.Identity;
|
_orientation = OMV.Quaternion.Identity;
|
||||||
_velocity = OMV.Vector3.Zero;
|
_velocity = OMV.Vector3.Zero;
|
||||||
_buoyancy = ComputeBuoyancyFromFlying(isFlying);
|
_buoyancy = ComputeBuoyancyFromFlying(isFlying);
|
||||||
|
@ -220,7 +218,13 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
{
|
{
|
||||||
// The avatar shouldn't be moving
|
// The avatar shouldn't be moving
|
||||||
_velocityMotor.Zero();
|
_velocityMotor.Zero();
|
||||||
ZeroMotion(true /* inTaintTime */);
|
|
||||||
|
// If we are colliding with a stationary object, presume we're standing and don't move around
|
||||||
|
if (!ColliderIsMoving)
|
||||||
|
{
|
||||||
|
DetailLog("{0},BSCharacter.MoveMotor,collidingWithStationary,zeroingMotion", LocalID);
|
||||||
|
ZeroMotion(true /* inTaintTime */);
|
||||||
|
}
|
||||||
|
|
||||||
// Standing has more friction on the ground
|
// Standing has more friction on the ground
|
||||||
if (_currentFriction != BSParam.AvatarStandingFriction)
|
if (_currentFriction != BSParam.AvatarStandingFriction)
|
||||||
|
@ -229,8 +233,6 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
PhysicsScene.PE.SetFriction(PhysBody, _currentFriction);
|
PhysicsScene.PE.SetFriction(PhysBody, _currentFriction);
|
||||||
}
|
}
|
||||||
DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1}", LocalID, _velocityMotor.TargetValue);
|
DetailLog("{0},BSCharacter.MoveMotor,taint,stopping,target={1}", LocalID, _velocityMotor.TargetValue);
|
||||||
|
|
||||||
_wasWalking = false;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -260,7 +262,6 @@ public sealed class BSCharacter : BSPhysObject
|
||||||
|
|
||||||
DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce);
|
DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce);
|
||||||
PhysicsScene.PE.ApplyCentralImpulse(PhysBody, moveForce);
|
PhysicsScene.PE.ApplyCentralImpulse(PhysBody, moveForce);
|
||||||
_wasWalking = true;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,9 +125,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
static readonly float PIOverTwo = ((float)Math.PI) / 2f;
|
static readonly float PIOverTwo = ((float)Math.PI) / 2f;
|
||||||
|
|
||||||
// For debugging, flags to turn on and off individual corrections.
|
// For debugging, flags to turn on and off individual corrections.
|
||||||
private bool enableAngularVerticalAttraction;
|
public bool enableAngularVerticalAttraction;
|
||||||
private bool enableAngularDeflection;
|
public bool enableAngularDeflection;
|
||||||
private bool enableAngularBanking;
|
public bool enableAngularBanking;
|
||||||
|
|
||||||
public BSDynamics(BSScene myScene, BSPrim myPrim)
|
public BSDynamics(BSScene myScene, BSPrim myPrim)
|
||||||
{
|
{
|
||||||
|
@ -146,7 +146,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
enableAngularBanking = false;
|
enableAngularBanking = false;
|
||||||
if (BSParam.VehicleDebuggingEnabled != ConfigurationParameters.numericFalse)
|
if (BSParam.VehicleDebuggingEnabled != ConfigurationParameters.numericFalse)
|
||||||
{
|
{
|
||||||
enableAngularVerticalAttraction = false;
|
enableAngularVerticalAttraction = true;
|
||||||
enableAngularDeflection = false;
|
enableAngularDeflection = false;
|
||||||
enableAngularBanking = false;
|
enableAngularBanking = false;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Vehicle parameter setting
|
#region Vehicle parameter setting
|
||||||
internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
|
public void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
|
||||||
{
|
{
|
||||||
VDetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", Prim.LocalID, pParam, pValue);
|
VDetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", Prim.LocalID, pParam, pValue);
|
||||||
switch (pParam)
|
switch (pParam)
|
||||||
|
@ -591,14 +591,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
m_vehicleMass = Prim.Linkset.LinksetMass;
|
m_vehicleMass = Prim.Linkset.LinksetMass;
|
||||||
|
|
||||||
// Friction affects are handled by this vehicle code
|
// Friction affects are handled by this vehicle code
|
||||||
float friction = 0f;
|
PhysicsScene.PE.SetFriction(Prim.PhysBody, BSParam.VehicleFriction);
|
||||||
PhysicsScene.PE.SetFriction(Prim.PhysBody, friction);
|
PhysicsScene.PE.SetRestitution(Prim.PhysBody, BSParam.VehicleRestitution);
|
||||||
|
|
||||||
// Moderate angular movement introduced by Bullet.
|
// Moderate angular movement introduced by Bullet.
|
||||||
// TODO: possibly set AngularFactor and LinearFactor for the type of vehicle.
|
// TODO: possibly set AngularFactor and LinearFactor for the type of vehicle.
|
||||||
// Maybe compute linear and angular factor and damping from params.
|
// Maybe compute linear and angular factor and damping from params.
|
||||||
float angularDamping = BSParam.VehicleAngularDamping;
|
PhysicsScene.PE.SetAngularDamping(Prim.PhysBody, BSParam.VehicleAngularDamping);
|
||||||
PhysicsScene.PE.SetAngularDamping(Prim.PhysBody, angularDamping);
|
PhysicsScene.PE.SetLinearFactor(Prim.PhysBody, BSParam.VehicleLinearFactorV);
|
||||||
|
PhysicsScene.PE.SetAngularFactorV(Prim.PhysBody, BSParam.VehicleAngularFactorV);
|
||||||
|
|
||||||
// Vehicles report collision events so we know when it's on the ground
|
// Vehicles report collision events so we know when it's on the ground
|
||||||
PhysicsScene.PE.AddToCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS);
|
PhysicsScene.PE.AddToCollisionFlags(Prim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS);
|
||||||
|
@ -613,8 +614,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
// The actual vehicle gravity is set to zero in Bullet so we can do all the application of same.
|
// The actual vehicle gravity is set to zero in Bullet so we can do all the application of same.
|
||||||
PhysicsScene.PE.SetGravity(Prim.PhysBody, Vector3.Zero);
|
PhysicsScene.PE.SetGravity(Prim.PhysBody, Vector3.Zero);
|
||||||
|
|
||||||
VDetailLog("{0},BSDynamics.Refresh,mass={1},frict={2},inert={3},aDamp={4},grav={5}",
|
VDetailLog("{0},BSDynamics.Refresh,mass={1},inert={2},grav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}",
|
||||||
Prim.LocalID, m_vehicleMass, friction, Prim.Inertia, angularDamping, m_VehicleGravity);
|
Prim.LocalID, m_vehicleMass, Prim.Inertia, m_VehicleGravity,
|
||||||
|
BSParam.VehicleAngularDamping, BSParam.VehicleFriction, BSParam.VehicleRestitution,
|
||||||
|
BSParam.VehicleLinearFactor, BSParam.VehicleAngularFactor
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -673,13 +677,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
private const int m_knownChangedWaterLevel = 1 << 9;
|
private const int m_knownChangedWaterLevel = 1 << 9;
|
||||||
private const int m_knownChangedForwardVelocity = 1 <<10;
|
private const int m_knownChangedForwardVelocity = 1 <<10;
|
||||||
|
|
||||||
private void ForgetKnownVehicleProperties()
|
public void ForgetKnownVehicleProperties()
|
||||||
{
|
{
|
||||||
m_knownHas = 0;
|
m_knownHas = 0;
|
||||||
m_knownChanged = 0;
|
m_knownChanged = 0;
|
||||||
}
|
}
|
||||||
// Push all the changed values back into the physics engine
|
// Push all the changed values back into the physics engine
|
||||||
private void PushKnownChanged()
|
public void PushKnownChanged()
|
||||||
{
|
{
|
||||||
if (m_knownChanged != 0)
|
if (m_knownChanged != 0)
|
||||||
{
|
{
|
||||||
|
@ -799,7 +803,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
m_knownVelocity = Prim.ForceVelocity;
|
m_knownVelocity = Prim.ForceVelocity;
|
||||||
m_knownHas |= m_knownChangedVelocity;
|
m_knownHas |= m_knownChangedVelocity;
|
||||||
}
|
}
|
||||||
return (Vector3)m_knownVelocity;
|
return m_knownVelocity;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
@ -898,9 +902,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
{
|
{
|
||||||
if (!IsActive) return;
|
if (!IsActive) return;
|
||||||
|
|
||||||
if (PhysicsScene.VehiclePhysicalLoggingEnabled)
|
|
||||||
PhysicsScene.PE.DumpRigidBody(PhysicsScene.World, Prim.PhysBody);
|
|
||||||
|
|
||||||
ForgetKnownVehicleProperties();
|
ForgetKnownVehicleProperties();
|
||||||
|
|
||||||
MoveLinear(pTimestep);
|
MoveLinear(pTimestep);
|
||||||
|
@ -922,6 +923,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
Prim.LocalID, VehiclePosition, m_knownForce, VehicleVelocity, VehicleRotationalVelocity);
|
Prim.LocalID, VehiclePosition, m_knownForce, VehicleVelocity, VehicleRotationalVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called after the simulation step
|
||||||
|
internal void PostStep(float pTimestep)
|
||||||
|
{
|
||||||
|
if (!IsActive) return;
|
||||||
|
|
||||||
|
if (PhysicsScene.VehiclePhysicalLoggingEnabled)
|
||||||
|
PhysicsScene.PE.DumpRigidBody(PhysicsScene.World, Prim.PhysBody);
|
||||||
|
}
|
||||||
|
|
||||||
// Apply the effect of the linear motor and other linear motions (like hover and float).
|
// Apply the effect of the linear motor and other linear motions (like hover and float).
|
||||||
private void MoveLinear(float pTimestep)
|
private void MoveLinear(float pTimestep)
|
||||||
{
|
{
|
||||||
|
@ -953,10 +963,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
// ==================================================================
|
// ==================================================================
|
||||||
// Clamp high or low velocities
|
// Clamp high or low velocities
|
||||||
float newVelocityLengthSq = VehicleVelocity.LengthSquared();
|
float newVelocityLengthSq = VehicleVelocity.LengthSquared();
|
||||||
if (newVelocityLengthSq > BSParam.VehicleMaxLinearVelocity)
|
if (newVelocityLengthSq > BSParam.VehicleMaxLinearVelocitySq)
|
||||||
{
|
{
|
||||||
|
Vector3 origVelW = VehicleVelocity; // DEBUG DEBUG
|
||||||
VehicleVelocity /= VehicleVelocity.Length();
|
VehicleVelocity /= VehicleVelocity.Length();
|
||||||
VehicleVelocity *= BSParam.VehicleMaxLinearVelocity;
|
VehicleVelocity *= BSParam.VehicleMaxLinearVelocity;
|
||||||
|
VDetailLog("{0}, MoveLinear,clampMax,origVelW={1},lenSq={2},maxVelSq={3},,newVelW={4}",
|
||||||
|
Prim.LocalID, origVelW, newVelocityLengthSq, BSParam.VehicleMaxLinearVelocitySq, VehicleVelocity);
|
||||||
}
|
}
|
||||||
else if (newVelocityLengthSq < 0.001f)
|
else if (newVelocityLengthSq < 0.001f)
|
||||||
VehicleVelocity = Vector3.Zero;
|
VehicleVelocity = Vector3.Zero;
|
||||||
|
@ -968,8 +981,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
public void ComputeLinearVelocity(float pTimestep)
|
public void ComputeLinearVelocity(float pTimestep)
|
||||||
{
|
{
|
||||||
// Step the motor from the current value. Get the correction needed this step.
|
// Step the motor from the current value. Get the correction needed this step.
|
||||||
Vector3 currentVel = VehicleVelocity * Quaternion.Inverse(VehicleOrientation);
|
Vector3 origVelW = VehicleVelocity; // DEBUG
|
||||||
Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVel);
|
Vector3 currentVelV = VehicleVelocity * Quaternion.Inverse(VehicleOrientation);
|
||||||
|
Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVelV);
|
||||||
|
|
||||||
// Motor is vehicle coordinates. Rotate it to world coordinates
|
// Motor is vehicle coordinates. Rotate it to world coordinates
|
||||||
Vector3 linearMotorVelocityW = linearMotorCorrectionV * VehicleOrientation;
|
Vector3 linearMotorVelocityW = linearMotorCorrectionV * VehicleOrientation;
|
||||||
|
@ -984,8 +998,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
// Add this correction to the velocity to make it faster/slower.
|
// Add this correction to the velocity to make it faster/slower.
|
||||||
VehicleVelocity += linearMotorVelocityW;
|
VehicleVelocity += linearMotorVelocityW;
|
||||||
|
|
||||||
VDetailLog("{0}, MoveLinear,velocity,vehVel={1},correction={2},force={3}",
|
VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5}",
|
||||||
Prim.LocalID, VehicleVelocity, linearMotorCorrectionV, linearMotorVelocityW);
|
Prim.LocalID, origVelW, currentVelV, linearMotorCorrectionV, linearMotorVelocityW, VehicleVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ComputeLinearTerrainHeightCorrection(float pTimestep)
|
public void ComputeLinearTerrainHeightCorrection(float pTimestep)
|
||||||
|
@ -1185,12 +1199,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
|
|
||||||
// Hack to reduce downward force if the vehicle is probably sitting on the ground
|
// Hack to reduce downward force if the vehicle is probably sitting on the ground
|
||||||
if (Prim.IsColliding && IsGroundVehicle)
|
if (Prim.IsColliding && IsGroundVehicle)
|
||||||
appliedGravity *= 0.2f;
|
appliedGravity *= BSParam.VehicleGroundGravityFudge;
|
||||||
|
|
||||||
VehicleAddForce(appliedGravity);
|
VehicleAddForce(appliedGravity);
|
||||||
|
|
||||||
VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},appliedForce-{2}",
|
VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},appliedForce={3}",
|
||||||
Prim.LocalID, m_VehicleGravity, appliedGravity);
|
Prim.LocalID, m_VehicleGravity, Prim.IsColliding, appliedGravity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
@ -1292,6 +1306,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
if (enableAngularVerticalAttraction && m_verticalAttractionTimescale < m_verticalAttractionCutoff)
|
if (enableAngularVerticalAttraction && m_verticalAttractionTimescale < m_verticalAttractionCutoff)
|
||||||
{
|
{
|
||||||
Vector3 vertContributionV = Vector3.Zero;
|
Vector3 vertContributionV = Vector3.Zero;
|
||||||
|
Vector3 origRotVelW = VehicleRotationalVelocity; // DEBUG DEBUG
|
||||||
|
|
||||||
// Take a vector pointing up and convert it from world to vehicle relative coords.
|
// Take a vector pointing up and convert it from world to vehicle relative coords.
|
||||||
Vector3 verticalError = Vector3.UnitZ * VehicleOrientation;
|
Vector3 verticalError = Vector3.UnitZ * VehicleOrientation;
|
||||||
|
@ -1319,13 +1334,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
|
|
||||||
// 'vertContrbution' is now the necessary angular correction to correct tilt in one second.
|
// 'vertContrbution' is now the necessary angular correction to correct tilt in one second.
|
||||||
// Correction happens over a number of seconds.
|
// Correction happens over a number of seconds.
|
||||||
Vector3 unscaledContrib = vertContributionV; // DEBUG DEBUG
|
Vector3 unscaledContribVerticalErrorV = vertContributionV; // DEBUG DEBUG
|
||||||
vertContributionV /= m_verticalAttractionTimescale;
|
vertContributionV /= m_verticalAttractionTimescale;
|
||||||
|
|
||||||
VehicleRotationalVelocity += vertContributionV * VehicleOrientation;
|
VehicleRotationalVelocity += vertContributionV * VehicleOrientation;
|
||||||
|
|
||||||
VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},eff={3},ts={4},vertAttr={5}",
|
VDetailLog("{0}, MoveAngular,verticalAttraction,,origRotVW={1},vertError={2},unscaledV={3},eff={4},ts={5},vertContribV={6}",
|
||||||
Prim.LocalID, verticalError, unscaledContrib, m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContributionV);
|
Prim.LocalID, origRotVelW, verticalError, unscaledContribVerticalErrorV,
|
||||||
|
m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContributionV);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
newLsi.OffsetFromCenterOfMass,
|
newLsi.OffsetFromCenterOfMass,
|
||||||
newLsi.OffsetRot,
|
newLsi.OffsetRot,
|
||||||
true /* shouldRecalculateLocalAabb */);
|
true /* shouldRecalculateLocalAabb */);
|
||||||
DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1}newLsi={2}",
|
DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1},newLsi={2}",
|
||||||
updated.LocalID, whichUpdated, newLsi);
|
updated.LocalID, whichUpdated, newLsi);
|
||||||
updated.LinksetInfo = newLsi;
|
updated.LinksetInfo = newLsi;
|
||||||
updatedChild = true;
|
updatedChild = true;
|
||||||
|
@ -377,7 +377,7 @@ public sealed class BSLinksetCompound : BSLinkset
|
||||||
// Constraint linksets are rebuilt every time.
|
// Constraint linksets are rebuilt every time.
|
||||||
// Note that this works for rebuilding just the root after a linkset is taken apart.
|
// Note that this works for rebuilding just the root after a linkset is taken apart.
|
||||||
// Called at taint time!!
|
// Called at taint time!!
|
||||||
private bool disableCOM = false; // disable until we get this debugged
|
private bool disableCOM = true; // disable until we get this debugged
|
||||||
private void RecomputeLinksetCompound()
|
private void RecomputeLinksetCompound()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -82,9 +82,19 @@ public static class BSParam
|
||||||
public static float AvatarStepApproachFactor { get; private set; }
|
public static float AvatarStepApproachFactor { get; private set; }
|
||||||
public static float AvatarStepForceFactor { get; private set; }
|
public static float AvatarStepForceFactor { get; private set; }
|
||||||
|
|
||||||
|
// Vehicle parameters
|
||||||
public static float VehicleMaxLinearVelocity { get; private set; }
|
public static float VehicleMaxLinearVelocity { get; private set; }
|
||||||
|
public static float VehicleMaxLinearVelocitySq { get; private set; }
|
||||||
public static float VehicleMaxAngularVelocity { get; private set; }
|
public static float VehicleMaxAngularVelocity { get; private set; }
|
||||||
|
public static float VehicleMaxAngularVelocitySq { get; private set; }
|
||||||
public static float VehicleAngularDamping { get; private set; }
|
public static float VehicleAngularDamping { get; private set; }
|
||||||
|
public static float VehicleFriction { get; private set; }
|
||||||
|
public static float VehicleRestitution { get; private set; }
|
||||||
|
public static float VehicleLinearFactor { get; private set; }
|
||||||
|
public static Vector3 VehicleLinearFactorV { get; private set; }
|
||||||
|
public static float VehicleAngularFactor { get; private set; }
|
||||||
|
public static Vector3 VehicleAngularFactorV { get; private set; }
|
||||||
|
public static float VehicleGroundGravityFudge { get; private set; }
|
||||||
public static float VehicleDebuggingEnabled { get; private set; }
|
public static float VehicleDebuggingEnabled { get; private set; }
|
||||||
|
|
||||||
public static float LinksetImplementation { get; private set; }
|
public static float LinksetImplementation { get; private set; }
|
||||||
|
@ -373,7 +383,7 @@ public static class BSParam
|
||||||
(s) => { return TerrainRestitution; },
|
(s) => { return TerrainRestitution; },
|
||||||
(s,p,l,v) => { TerrainRestitution = v; /* TODO: set on real terrain */ } ),
|
(s,p,l,v) => { TerrainRestitution = v; /* TODO: set on real terrain */ } ),
|
||||||
new ParameterDefn("TerrainCollisionMargin", "Margin where collision checking starts" ,
|
new ParameterDefn("TerrainCollisionMargin", "Margin where collision checking starts" ,
|
||||||
0.04f,
|
0.08f,
|
||||||
(s,cf,p,v) => { TerrainCollisionMargin = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { TerrainCollisionMargin = cf.GetFloat(p, v); },
|
||||||
(s) => { return TerrainCollisionMargin; },
|
(s) => { return TerrainCollisionMargin; },
|
||||||
(s,p,l,v) => { TerrainCollisionMargin = v; /* TODO: set on real terrain */ } ),
|
(s,p,l,v) => { TerrainCollisionMargin = v; /* TODO: set on real terrain */ } ),
|
||||||
|
@ -443,17 +453,42 @@ public static class BSParam
|
||||||
1000.0f,
|
1000.0f,
|
||||||
(s,cf,p,v) => { VehicleMaxLinearVelocity = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { VehicleMaxLinearVelocity = cf.GetFloat(p, v); },
|
||||||
(s) => { return (float)VehicleMaxLinearVelocity; },
|
(s) => { return (float)VehicleMaxLinearVelocity; },
|
||||||
(s,p,l,v) => { VehicleMaxLinearVelocity = v; } ),
|
(s,p,l,v) => { VehicleMaxLinearVelocity = v; VehicleMaxLinearVelocitySq = v * v; } ),
|
||||||
new ParameterDefn("VehicleMaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to a vehicle",
|
new ParameterDefn("VehicleMaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to a vehicle",
|
||||||
12.0f,
|
12.0f,
|
||||||
(s,cf,p,v) => { VehicleMaxAngularVelocity = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { VehicleMaxAngularVelocity = cf.GetFloat(p, v); },
|
||||||
(s) => { return (float)VehicleMaxAngularVelocity; },
|
(s) => { return (float)VehicleMaxAngularVelocity; },
|
||||||
(s,p,l,v) => { VehicleMaxAngularVelocity = v; } ),
|
(s,p,l,v) => { VehicleMaxAngularVelocity = v; VehicleMaxAngularVelocitySq = v * v; } ),
|
||||||
new ParameterDefn("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)",
|
new ParameterDefn("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)",
|
||||||
0.0f,
|
0.0f,
|
||||||
(s,cf,p,v) => { VehicleAngularDamping = cf.GetFloat(p, v); },
|
(s,cf,p,v) => { VehicleAngularDamping = cf.GetFloat(p, v); },
|
||||||
(s) => { return VehicleAngularDamping; },
|
(s) => { return VehicleAngularDamping; },
|
||||||
(s,p,l,v) => { VehicleAngularDamping = v; } ),
|
(s,p,l,v) => { VehicleAngularDamping = v; } ),
|
||||||
|
new ParameterDefn("VehicleLinearFactor", "Fraction of physical linear changes applied to vehicle (0.0 - 1.0)",
|
||||||
|
1.0f,
|
||||||
|
(s,cf,p,v) => { VehicleLinearFactor = cf.GetFloat(p, v); },
|
||||||
|
(s) => { return VehicleLinearFactor; },
|
||||||
|
(s,p,l,v) => { VehicleLinearFactor = v; VehicleLinearFactorV = new Vector3(v, v, v); } ),
|
||||||
|
new ParameterDefn("VehicleAngularFactor", "Fraction of physical angular changes applied to vehicle (0.0 - 1.0)",
|
||||||
|
1.0f,
|
||||||
|
(s,cf,p,v) => { VehicleAngularFactor = cf.GetFloat(p, v); },
|
||||||
|
(s) => { return VehicleAngularFactor; },
|
||||||
|
(s,p,l,v) => { VehicleAngularFactor = v; VehicleAngularFactorV = new Vector3(v, v, v); } ),
|
||||||
|
new ParameterDefn("VehicleFriction", "Friction of vehicle on the ground (0.0 - 1.0)",
|
||||||
|
0.0f,
|
||||||
|
(s,cf,p,v) => { VehicleFriction = cf.GetFloat(p, v); },
|
||||||
|
(s) => { return VehicleFriction; },
|
||||||
|
(s,p,l,v) => { VehicleFriction = v; } ),
|
||||||
|
new ParameterDefn("VehicleRestitution", "Bouncyness factor for vehicles (0.0 - 1.0)",
|
||||||
|
0.0f,
|
||||||
|
(s,cf,p,v) => { VehicleRestitution = cf.GetFloat(p, v); },
|
||||||
|
(s) => { return VehicleRestitution; },
|
||||||
|
(s,p,l,v) => { VehicleRestitution = v; } ),
|
||||||
|
new ParameterDefn("VehicleGroundGravityFudge", "Factor to multiple gravity if a ground vehicle is probably on the ground (0.0 - 1.0)",
|
||||||
|
0.2f,
|
||||||
|
(s,cf,p,v) => { VehicleGroundGravityFudge = cf.GetFloat(p, v); },
|
||||||
|
(s) => { return VehicleGroundGravityFudge; },
|
||||||
|
(s,p,l,v) => { VehicleGroundGravityFudge = v; } ),
|
||||||
new ParameterDefn("VehicleDebuggingEnable", "Turn on/off vehicle debugging",
|
new ParameterDefn("VehicleDebuggingEnable", "Turn on/off vehicle debugging",
|
||||||
ConfigurationParameters.numericFalse,
|
ConfigurationParameters.numericFalse,
|
||||||
(s,cf,p,v) => { VehicleDebuggingEnabled = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
|
(s,cf,p,v) => { VehicleDebuggingEnabled = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
|
||||||
|
|
|
@ -95,12 +95,16 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
SubscribedEventsMs = 0;
|
SubscribedEventsMs = 0;
|
||||||
CollidingStep = 0;
|
CollidingStep = 0;
|
||||||
CollidingGroundStep = 0;
|
CollidingGroundStep = 0;
|
||||||
|
CollisionAccumulation = 0;
|
||||||
|
ColliderIsMoving = false;
|
||||||
|
CollisionScore = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell the object to clean up.
|
// Tell the object to clean up.
|
||||||
public virtual void Destroy()
|
public virtual void Destroy()
|
||||||
{
|
{
|
||||||
UnRegisterAllPreStepActions();
|
UnRegisterAllPreStepActions();
|
||||||
|
UnRegisterAllPostStepActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BSScene PhysicsScene { get; protected set; }
|
public BSScene PhysicsScene { get; protected set; }
|
||||||
|
@ -174,13 +178,14 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
public abstract OMV.Vector3 RawPosition { get; set; }
|
public abstract OMV.Vector3 RawPosition { get; set; }
|
||||||
public abstract OMV.Vector3 ForcePosition { 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,
|
// 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
|
// sometimes it is necessary to displace the position the physics engine thinks
|
||||||
// the position is. PositionDisplacement must be added and removed from the
|
// the position is. PositionDisplacement must be added and removed from the
|
||||||
// position as the simulator position is stored and fetched from the physics
|
// 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.Vector3 PositionDisplacement { get; set; }
|
||||||
|
public virtual OMV.Quaternion OrientationDisplacement { get; set; }
|
||||||
|
|
||||||
public abstract OMV.Quaternion RawOrientation { get; set; }
|
public abstract OMV.Quaternion RawOrientation { get; set; }
|
||||||
public abstract OMV.Quaternion ForceOrientation { get; set; }
|
public abstract OMV.Quaternion ForceOrientation { get; set; }
|
||||||
|
@ -237,6 +242,12 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
protected long CollidingObjectStep { get; set; }
|
protected long CollidingObjectStep { get; set; }
|
||||||
// The collision flags we think are set in Bullet
|
// The collision flags we think are set in Bullet
|
||||||
protected CollisionFlags CurrentCollisionFlags { get; set; }
|
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; }
|
||||||
|
|
||||||
public override bool IsColliding {
|
public override bool IsColliding {
|
||||||
get { return (CollidingStep == PhysicsScene.SimulationStep); }
|
get { return (CollidingStep == PhysicsScene.SimulationStep); }
|
||||||
|
@ -299,7 +310,12 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if someone has subscribed for collision events....
|
CollisionAccumulation++;
|
||||||
|
|
||||||
|
// 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()) {
|
if (SubscribedEvents()) {
|
||||||
CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
|
CollisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth));
|
||||||
DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}",
|
DetailLog("{0},{1}.Collison.AddCollider,call,with={2},point={3},normal={4},depth={5}",
|
||||||
|
@ -385,6 +401,17 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
public override bool SubscribedEvents() {
|
public override bool SubscribedEvents() {
|
||||||
return (SubscribedEventsMs > 0);
|
return (SubscribedEventsMs > 0);
|
||||||
}
|
}
|
||||||
|
// 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.
|
||||||
|
// The "+1" prevents dividing by zero.
|
||||||
|
long timeAgo = PhysicsScene.SimulationStep - CollidingStep + 1;
|
||||||
|
CollisionScore = CollisionAccumulation / timeAgo;
|
||||||
|
}
|
||||||
|
public override float CollisionScore { get; set; }
|
||||||
|
|
||||||
#endregion // Collisions
|
#endregion // Collisions
|
||||||
|
|
||||||
|
@ -393,52 +420,103 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
// These actions are optional so, rather than scanning all the physical objects and asking them
|
// These actions are optional so, rather than scanning all the physical objects and asking them
|
||||||
// if they have anything to do, a physical object registers for an event call before the step is performed.
|
// if they have anything to do, a physical object registers for an event call before the step is performed.
|
||||||
// This bookkeeping makes it easy to add, remove and clean up after all these registrations.
|
// This bookkeeping makes it easy to add, remove and clean up after all these registrations.
|
||||||
private Dictionary<string, BSScene.PreStepAction> RegisteredActions = new Dictionary<string, BSScene.PreStepAction>();
|
private Dictionary<string, BSScene.PreStepAction> RegisteredPrestepActions = new Dictionary<string, BSScene.PreStepAction>();
|
||||||
|
private Dictionary<string, BSScene.PostStepAction> RegisteredPoststepActions = new Dictionary<string, BSScene.PostStepAction>();
|
||||||
protected void RegisterPreStepAction(string op, uint id, BSScene.PreStepAction actn)
|
protected void RegisterPreStepAction(string op, uint id, BSScene.PreStepAction actn)
|
||||||
{
|
{
|
||||||
string identifier = op + "-" + id.ToString();
|
string identifier = op + "-" + id.ToString();
|
||||||
|
|
||||||
lock (RegisteredActions)
|
lock (RegisteredPrestepActions)
|
||||||
{
|
{
|
||||||
// Clean out any existing action
|
// Clean out any existing action
|
||||||
UnRegisterPreStepAction(op, id);
|
UnRegisterPreStepAction(op, id);
|
||||||
|
|
||||||
RegisteredActions[identifier] = actn;
|
RegisteredPrestepActions[identifier] = actn;
|
||||||
|
|
||||||
|
PhysicsScene.BeforeStep += actn;
|
||||||
}
|
}
|
||||||
PhysicsScene.BeforeStep += actn;
|
|
||||||
DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier);
|
DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unregister a pre step action. Safe to call if the action has not been registered.
|
// 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();
|
string identifier = op + "-" + id.ToString();
|
||||||
bool removed = false;
|
bool removed = false;
|
||||||
lock (RegisteredActions)
|
lock (RegisteredPrestepActions)
|
||||||
{
|
{
|
||||||
if (RegisteredActions.ContainsKey(identifier))
|
if (RegisteredPrestepActions.ContainsKey(identifier))
|
||||||
{
|
{
|
||||||
PhysicsScene.BeforeStep -= RegisteredActions[identifier];
|
PhysicsScene.BeforeStep -= RegisteredPrestepActions[identifier];
|
||||||
RegisteredActions.Remove(identifier);
|
RegisteredPrestepActions.Remove(identifier);
|
||||||
removed = true;
|
removed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DetailLog("{0},BSPhysObject.UnRegisterPreStepAction,id={1},removed={2}", LocalID, identifier, removed);
|
DetailLog("{0},BSPhysObject.UnRegisterPreStepAction,id={1},removed={2}", LocalID, identifier, removed);
|
||||||
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void UnRegisterAllPreStepActions()
|
protected void UnRegisterAllPreStepActions()
|
||||||
{
|
{
|
||||||
lock (RegisteredActions)
|
lock (RegisteredPrestepActions)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredActions)
|
foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredPrestepActions)
|
||||||
{
|
{
|
||||||
PhysicsScene.BeforeStep -= kvp.Value;
|
PhysicsScene.BeforeStep -= kvp.Value;
|
||||||
}
|
}
|
||||||
RegisteredActions.Clear();
|
RegisteredPrestepActions.Clear();
|
||||||
}
|
}
|
||||||
DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID);
|
DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void RegisterPostStepAction(string op, uint id, BSScene.PostStepAction actn)
|
||||||
|
{
|
||||||
|
string identifier = op + "-" + id.ToString();
|
||||||
|
|
||||||
|
lock (RegisteredPoststepActions)
|
||||||
|
{
|
||||||
|
// Clean out any existing action
|
||||||
|
UnRegisterPostStepAction(op, id);
|
||||||
|
|
||||||
|
RegisteredPoststepActions[identifier] = 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.
|
||||||
|
// Returns 'true' if an action was actually removed.
|
||||||
|
protected bool UnRegisterPostStepAction(string op, uint id)
|
||||||
|
{
|
||||||
|
string identifier = op + "-" + id.ToString();
|
||||||
|
bool removed = false;
|
||||||
|
lock (RegisteredPoststepActions)
|
||||||
|
{
|
||||||
|
if (RegisteredPoststepActions.ContainsKey(identifier))
|
||||||
|
{
|
||||||
|
PhysicsScene.AfterStep -= RegisteredPoststepActions[identifier];
|
||||||
|
RegisteredPoststepActions.Remove(identifier);
|
||||||
|
removed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DetailLog("{0},BSPhysObject.UnRegisterPostStepAction,id={1},removed={2}", LocalID, identifier, removed);
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void UnRegisterAllPostStepActions()
|
||||||
|
{
|
||||||
|
lock (RegisteredPoststepActions)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<string, BSScene.PostStepAction> kvp in RegisteredPoststepActions)
|
||||||
|
{
|
||||||
|
PhysicsScene.AfterStep -= kvp.Value;
|
||||||
|
}
|
||||||
|
RegisteredPoststepActions.Clear();
|
||||||
|
}
|
||||||
|
DetailLog("{0},BSPhysObject.UnRegisterAllPostStepActions,", LocalID);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion // Per Simulation Step actions
|
#endregion // Per Simulation Step actions
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,6 @@ public sealed class BSPrim : BSPhysObject
|
||||||
private OMV.Vector3 _force;
|
private OMV.Vector3 _force;
|
||||||
private OMV.Vector3 _velocity;
|
private OMV.Vector3 _velocity;
|
||||||
private OMV.Vector3 _torque;
|
private OMV.Vector3 _torque;
|
||||||
private float _collisionScore;
|
|
||||||
private OMV.Vector3 _acceleration;
|
private OMV.Vector3 _acceleration;
|
||||||
private OMV.Quaternion _orientation;
|
private OMV.Quaternion _orientation;
|
||||||
private int _physicsActorType;
|
private int _physicsActorType;
|
||||||
|
@ -74,7 +73,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
private bool _kinematic;
|
private bool _kinematic;
|
||||||
private float _buoyancy;
|
private float _buoyancy;
|
||||||
|
|
||||||
private BSDynamics _vehicle;
|
public BSDynamics VehicleController { get; private set; }
|
||||||
|
|
||||||
private BSVMotor _targetMotor;
|
private BSVMotor _targetMotor;
|
||||||
private OMV.Vector3 _PIDTarget;
|
private OMV.Vector3 _PIDTarget;
|
||||||
|
@ -108,7 +107,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
_friction = PhysicsScene.Params.defaultFriction;
|
_friction = PhysicsScene.Params.defaultFriction;
|
||||||
_restitution = PhysicsScene.Params.defaultRestitution;
|
_restitution = PhysicsScene.Params.defaultRestitution;
|
||||||
|
|
||||||
_vehicle = new BSDynamics(PhysicsScene, this); // add vehicleness
|
VehicleController = new BSDynamics(PhysicsScene, this); // add vehicleness
|
||||||
|
|
||||||
_mass = CalculateMass();
|
_mass = CalculateMass();
|
||||||
|
|
||||||
|
@ -513,7 +512,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
|
|
||||||
public override int VehicleType {
|
public override int VehicleType {
|
||||||
get {
|
get {
|
||||||
return (int)_vehicle.Type; // if we are a vehicle, return that type
|
return (int)VehicleController.Type; // if we are a vehicle, return that type
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
Vehicle type = (Vehicle)value;
|
Vehicle type = (Vehicle)value;
|
||||||
|
@ -522,14 +521,20 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
// Done at taint time so we're sure the physics engine is not using the variables
|
// Done at taint time so we're sure the physics engine is not using the variables
|
||||||
// Vehicle code changes the parameters for this vehicle type.
|
// Vehicle code changes the parameters for this vehicle type.
|
||||||
_vehicle.ProcessTypeChange(type);
|
VehicleController.ProcessTypeChange(type);
|
||||||
ActivateIfPhysical(false);
|
ActivateIfPhysical(false);
|
||||||
|
|
||||||
// If an active vehicle, register the vehicle code to be called before each step
|
// If an active vehicle, register the vehicle code to be called before each step
|
||||||
if (_vehicle.Type == Vehicle.TYPE_NONE)
|
if (VehicleController.Type == Vehicle.TYPE_NONE)
|
||||||
|
{
|
||||||
UnRegisterPreStepAction("BSPrim.Vehicle", LocalID);
|
UnRegisterPreStepAction("BSPrim.Vehicle", LocalID);
|
||||||
|
PhysicsScene.AfterStep -= VehicleController.PostStep;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
RegisterPreStepAction("BSPrim.Vehicle", LocalID, _vehicle.Step);
|
{
|
||||||
|
RegisterPreStepAction("BSPrim.Vehicle", LocalID, VehicleController.Step);
|
||||||
|
PhysicsScene.AfterStep += VehicleController.PostStep;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -537,7 +542,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
|
PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
|
||||||
{
|
{
|
||||||
_vehicle.ProcessFloatVehicleParam((Vehicle)param, value);
|
VehicleController.ProcessFloatVehicleParam((Vehicle)param, value);
|
||||||
ActivateIfPhysical(false);
|
ActivateIfPhysical(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -545,7 +550,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
|
PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
|
||||||
{
|
{
|
||||||
_vehicle.ProcessVectorVehicleParam((Vehicle)param, value);
|
VehicleController.ProcessVectorVehicleParam((Vehicle)param, value);
|
||||||
ActivateIfPhysical(false);
|
ActivateIfPhysical(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -553,7 +558,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
|
PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
|
||||||
{
|
{
|
||||||
_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation);
|
VehicleController.ProcessRotationVehicleParam((Vehicle)param, rotation);
|
||||||
ActivateIfPhysical(false);
|
ActivateIfPhysical(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -561,7 +566,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
PhysicsScene.TaintedObject("BSPrim.VehicleFlags", delegate()
|
PhysicsScene.TaintedObject("BSPrim.VehicleFlags", delegate()
|
||||||
{
|
{
|
||||||
_vehicle.ProcessVehicleFlags(param, remove);
|
VehicleController.ProcessVehicleFlags(param, remove);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,11 +643,6 @@ public sealed class BSPrim : BSPhysObject
|
||||||
// DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque);
|
// DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override float CollisionScore {
|
|
||||||
get { return _collisionScore; }
|
|
||||||
set { _collisionScore = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public override OMV.Vector3 Acceleration {
|
public override OMV.Vector3 Acceleration {
|
||||||
get { return _acceleration; }
|
get { return _acceleration; }
|
||||||
set { _acceleration = value; }
|
set { _acceleration = value; }
|
||||||
|
@ -747,7 +747,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
// isSolid: other objects bounce off of this object
|
// isSolid: other objects bounce off of this object
|
||||||
// isVolumeDetect: other objects pass through but can generate collisions
|
// isVolumeDetect: other objects pass through but can generate collisions
|
||||||
// collisionEvents: whether this object returns collision events
|
// collisionEvents: whether this object returns collision events
|
||||||
private void UpdatePhysicalParameters()
|
public void UpdatePhysicalParameters()
|
||||||
{
|
{
|
||||||
// DetailLog("{0},BSPrim.UpdatePhysicalParameters,entry,body={1},shape={2}", LocalID, BSBody, BSShape);
|
// DetailLog("{0},BSPrim.UpdatePhysicalParameters,entry,body={1},shape={2}", LocalID, BSBody, BSShape);
|
||||||
|
|
||||||
|
@ -759,7 +759,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
MakeDynamic(IsStatic);
|
MakeDynamic(IsStatic);
|
||||||
|
|
||||||
// Update vehicle specific parameters (after MakeDynamic() so can change physical parameters)
|
// Update vehicle specific parameters (after MakeDynamic() so can change physical parameters)
|
||||||
_vehicle.Refresh();
|
VehicleController.Refresh();
|
||||||
|
|
||||||
// Arrange for collision events if the simulator wants them
|
// Arrange for collision events if the simulator wants them
|
||||||
EnableCollisions(SubscribedEvents());
|
EnableCollisions(SubscribedEvents());
|
||||||
|
@ -1601,7 +1601,7 @@ public sealed class BSPrim : BSPhysObject
|
||||||
// Remove all the physical dependencies on the old body.
|
// Remove all the physical dependencies on the old body.
|
||||||
// (Maybe someday make the changing of BSShape an event to be subscribed to by BSLinkset, ...)
|
// (Maybe someday make the changing of BSShape an event to be subscribed to by BSLinkset, ...)
|
||||||
Linkset.RemoveBodyDependencies(this);
|
Linkset.RemoveBodyDependencies(this);
|
||||||
_vehicle.RemoveBodyDependencies(this);
|
VehicleController.RemoveBodyDependencies(this);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make sure the properties are set on the new object
|
// Make sure the properties are set on the new object
|
||||||
|
@ -1618,9 +1618,9 @@ public sealed class BSPrim : BSPhysObject
|
||||||
{
|
{
|
||||||
// A temporary kludge to suppress the rotational effects introduced on vehicles by Bullet
|
// A temporary kludge to suppress the rotational effects introduced on vehicles by Bullet
|
||||||
// TODO: handle physics introduced by Bullet with computed vehicle physics.
|
// TODO: handle physics introduced by Bullet with computed vehicle physics.
|
||||||
if (_vehicle.IsActive)
|
if (VehicleController.IsActive)
|
||||||
{
|
{
|
||||||
// entprop.RotationalVelocity = OMV.Vector3.Zero;
|
entprop.RotationalVelocity = OMV.Vector3.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
// DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG
|
// DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -87,7 +88,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
public delegate void PreStepAction(float timeStep);
|
public delegate void PreStepAction(float timeStep);
|
||||||
public delegate void PostStepAction(float timeStep);
|
public delegate void PostStepAction(float timeStep);
|
||||||
public event PreStepAction BeforeStep;
|
public event PreStepAction BeforeStep;
|
||||||
public event PreStepAction AfterStep;
|
public event PostStepAction AfterStep;
|
||||||
|
|
||||||
// A value of the time now so all the collision and update routines do not have to get their own
|
// A value of the time now so all the collision and update routines do not have to get their own
|
||||||
// Set to 'now' just before all the prims and actors are called for collisions and updates
|
// Set to 'now' just before all the prims and actors are called for collisions and updates
|
||||||
|
@ -697,7 +698,21 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
|
|
||||||
public override Dictionary<uint, float> GetTopColliders()
|
public override Dictionary<uint, float> GetTopColliders()
|
||||||
{
|
{
|
||||||
return new Dictionary<uint, float>();
|
Dictionary<uint, float> topColliders;
|
||||||
|
|
||||||
|
lock (PhysObjects)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<uint, BSPhysObject> kvp in PhysObjects)
|
||||||
|
{
|
||||||
|
kvp.Value.ComputeCollisionScore();
|
||||||
|
}
|
||||||
|
|
||||||
|
List<BSPhysObject> orderedPrims = new List<BSPhysObject>(PhysObjects.Values);
|
||||||
|
orderedPrims.OrderByDescending(p => p.CollisionScore);
|
||||||
|
topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore);
|
||||||
|
}
|
||||||
|
|
||||||
|
return topColliders;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool IsThreaded { get { return false; } }
|
public override bool IsThreaded { get { return false; } }
|
||||||
|
@ -748,7 +763,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
|
|
||||||
private void TriggerPostStepEvent(float timeStep)
|
private void TriggerPostStepEvent(float timeStep)
|
||||||
{
|
{
|
||||||
PreStepAction actions = AfterStep;
|
PostStepAction actions = AfterStep;
|
||||||
if (actions != null)
|
if (actions != null)
|
||||||
actions(timeStep);
|
actions(timeStep);
|
||||||
|
|
||||||
|
@ -840,7 +855,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
|
||||||
{
|
{
|
||||||
DetailLog("{0},BSScene.AssertInTaintTime,NOT IN TAINT TIME,Region={1},Where={2}", DetailLogZero, RegionName, whereFrom);
|
DetailLog("{0},BSScene.AssertInTaintTime,NOT IN TAINT TIME,Region={1},Where={2}", DetailLogZero, RegionName, whereFrom);
|
||||||
m_log.ErrorFormat("{0} NOT IN TAINT TIME!! Region={1}, Where={2}", LogHeader, RegionName, whereFrom);
|
m_log.ErrorFormat("{0} NOT IN TAINT TIME!! Region={1}, Where={2}", LogHeader, RegionName, whereFrom);
|
||||||
Util.PrintCallStack(DetailLog);
|
// Util.PrintCallStack(DetailLog);
|
||||||
}
|
}
|
||||||
return InTaintTime;
|
return InTaintTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
CURRENT PRIORITIES
|
CURRENT PRIORITIES
|
||||||
=================================================
|
=================================================
|
||||||
|
One sided meshes? Should terrain be built into a closed shape?
|
||||||
|
When meshes get partially wedged into the terrain, they cannot push themselves out.
|
||||||
|
It is possible that Bullet processes collisions whether entering or leaving a mesh.
|
||||||
|
Ref: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4869
|
||||||
Deleting a linkset while standing on the root will leave the physical shape of the root behind.
|
Deleting a linkset while standing on the root will leave the physical shape of the root behind.
|
||||||
Not sure if it is because standing on it. Done with large prim linksets.
|
Not sure if it is because standing on it. Done with large prim linksets.
|
||||||
Child movement in linkset (don't rebuild linkset)
|
|
||||||
Vehicle angular vertical attraction
|
Vehicle angular vertical attraction
|
||||||
vehicle angular banking
|
vehicle angular banking
|
||||||
Center-of-gravity
|
Center-of-gravity
|
||||||
|
@ -12,6 +15,7 @@ when should angular and linear motor targets be zeroed? when selected?
|
||||||
Need a vehicle.clear()? Or an 'else' in prestep if not physical.
|
Need a vehicle.clear()? Or an 'else' in prestep if not physical.
|
||||||
Teravus llMoveToTarget script debug
|
Teravus llMoveToTarget script debug
|
||||||
Mixing of hover, buoyancy/gravity, moveToTarget, into one force
|
Mixing of hover, buoyancy/gravity, moveToTarget, into one force
|
||||||
|
Setting hover height to zero disables hover even if hover flags are on (from SL wiki)
|
||||||
Nebadon vehicles turning funny in arena
|
Nebadon vehicles turning funny in arena
|
||||||
limitMotorUp calibration (more down?)
|
limitMotorUp calibration (more down?)
|
||||||
llRotLookAt
|
llRotLookAt
|
||||||
|
@ -72,7 +76,11 @@ Incorporate inter-relationship of angular corrections. For instance, angularDefl
|
||||||
|
|
||||||
GENERAL TODO LIST:
|
GENERAL TODO LIST:
|
||||||
=================================================
|
=================================================
|
||||||
|
Avatar standing on a moving object should start to move with the object.
|
||||||
llMoveToTarget objects are not effected by gravity until target is removed.
|
llMoveToTarget objects are not effected by gravity until target is removed.
|
||||||
|
Compute CCD parameters based on body size
|
||||||
|
Can solver iterations be changed per body/shape? Can be for constraints but what
|
||||||
|
about regular vehicles?
|
||||||
Implement llSetPhysicalMaterial.
|
Implement llSetPhysicalMaterial.
|
||||||
extend it with Center-of-mass, rolling friction, density
|
extend it with Center-of-mass, rolling friction, density
|
||||||
Implement llSetForceAndTorque.
|
Implement llSetForceAndTorque.
|
||||||
|
@ -322,3 +330,4 @@ Boats float low in the water (DONE)
|
||||||
Boats floating at proper level (DONE)
|
Boats floating at proper level (DONE)
|
||||||
When is force introduced by SetForce removed? The prestep action could go forever. (DONE)
|
When is force introduced by SetForce removed? The prestep action could go forever. (DONE)
|
||||||
(Resolution: setForce registers a prestep action which keeps applying the force)
|
(Resolution: setForce registers a prestep action which keeps applying the force)
|
||||||
|
Child movement in linkset (don't rebuild linkset) (DONE 20130122))
|
|
@ -0,0 +1,127 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using log4net;
|
||||||
|
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Region.Physics.BulletSPlugin;
|
||||||
|
using OpenSim.Region.Physics.Manager;
|
||||||
|
using OpenSim.Tests.Common;
|
||||||
|
|
||||||
|
using OpenMetaverse;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Physics.BulletSPlugin.Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class BasicVehicles : OpenSimTestCase
|
||||||
|
{
|
||||||
|
// Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1
|
||||||
|
// Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1
|
||||||
|
|
||||||
|
BSScene PhysicsScene { get; set; }
|
||||||
|
BSPrim TestVehicle { get; set; }
|
||||||
|
Vector3 TestVehicleInitPosition { get; set; }
|
||||||
|
float timeStep = 0.089f;
|
||||||
|
|
||||||
|
[TestFixtureSetUp]
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
Dictionary<string, string> engineParams = new Dictionary<string, string>();
|
||||||
|
PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);
|
||||||
|
|
||||||
|
PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateSphere();
|
||||||
|
Vector3 pos = new Vector3(100.0f, 100.0f, 0f);
|
||||||
|
pos.Z = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos) + 2f;
|
||||||
|
TestVehicleInitPosition = pos;
|
||||||
|
Vector3 size = new Vector3(1f, 1f, 1f);
|
||||||
|
pbs.Scale = size;
|
||||||
|
Quaternion rot = Quaternion.Identity;
|
||||||
|
bool isPhys = false;
|
||||||
|
uint localID = 123;
|
||||||
|
|
||||||
|
PhysicsScene.AddPrimShape("testPrim", pbs, pos, size, rot, isPhys, localID);
|
||||||
|
TestVehicle = (BSPrim)PhysicsScene.PhysObjects[localID];
|
||||||
|
// The actual prim shape creation happens at taint time
|
||||||
|
PhysicsScene.ProcessTaints();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestFixtureTearDown]
|
||||||
|
public void TearDown()
|
||||||
|
{
|
||||||
|
if (PhysicsScene != null)
|
||||||
|
{
|
||||||
|
// The Dispose() will also free any physical objects in the scene
|
||||||
|
PhysicsScene.Dispose();
|
||||||
|
PhysicsScene = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestCase(25, 0.25f, 0.25f, 0.25f)]
|
||||||
|
[TestCase(25, -0.25f, 0.25f, 0.25f)]
|
||||||
|
[TestCase(25, 0.25f, -0.25f, 0.25f)]
|
||||||
|
[TestCase(25, -0.25f, -0.25f, 0.25f)]
|
||||||
|
public void VerticalAttraction(int simSteps, float initRoll, float initPitch, float initYaw)
|
||||||
|
{
|
||||||
|
Quaternion initOrientation = Quaternion.CreateFromEulers(initRoll, initPitch, initYaw);
|
||||||
|
TestVehicle.Orientation = initOrientation;
|
||||||
|
|
||||||
|
TestVehicle.Position = TestVehicleInitPosition;
|
||||||
|
|
||||||
|
// The vehicle controller is not enabled directly (set a vehicle type).
|
||||||
|
// Instead the appropriate values are set and calls are made just the parts of the
|
||||||
|
// controller we want to exercise. Stepping the physics engine then applies
|
||||||
|
// the actions of that one feature.
|
||||||
|
TestVehicle.VehicleController.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, 0.2f);
|
||||||
|
TestVehicle.VehicleController.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, 2f);
|
||||||
|
TestVehicle.VehicleController.enableAngularVerticalAttraction = true;
|
||||||
|
|
||||||
|
TestVehicle.IsPhysical = true;
|
||||||
|
PhysicsScene.ProcessTaints();
|
||||||
|
|
||||||
|
// Step the simulator a bunch of times and and vertical attraction should orient the vehicle up
|
||||||
|
for (int ii = 0; ii < simSteps; ii++)
|
||||||
|
{
|
||||||
|
TestVehicle.VehicleController.ForgetKnownVehicleProperties();
|
||||||
|
TestVehicle.VehicleController.ComputeAngularVerticalAttraction();
|
||||||
|
TestVehicle.VehicleController.PushKnownChanged();
|
||||||
|
|
||||||
|
PhysicsScene.Simulate(timeStep);
|
||||||
|
}
|
||||||
|
|
||||||
|
// After these steps, the vehicle should be upright
|
||||||
|
Vector3 upPointer = Vector3.UnitZ * TestVehicle.Orientation;
|
||||||
|
Assert.That(upPointer.Z, Is.GreaterThan(0.99f));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using log4net;
|
||||||
|
|
||||||
|
using OpenSim.Tests.Common;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Physics.BulletSPlugin.Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class BulletSimTests : OpenSimTestCase
|
||||||
|
{
|
||||||
|
// Documentation on attributes: http://www.nunit.org/index.php?p=attributes&r=2.6.1
|
||||||
|
// Documentation on assertions: http://www.nunit.org/index.php?p=assertions&r=2.6.1
|
||||||
|
|
||||||
|
[TestFixtureSetUp]
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestFixtureTearDown]
|
||||||
|
public void TearDown()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
* * Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* * Neither the name of the OpenSimulator Project nor the
|
||||||
|
* names of its contributors may be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using Nini.Config;
|
||||||
|
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Region.Physics.BulletSPlugin;
|
||||||
|
using OpenSim.Region.Physics.Meshing;
|
||||||
|
|
||||||
|
namespace OpenSim.Region.Physics.BulletSPlugin.Tests
|
||||||
|
{
|
||||||
|
// Utility functions for building up and tearing down the sample physics environments
|
||||||
|
public static class BulletSimTestsUtil
|
||||||
|
{
|
||||||
|
// 'engineName' is the Bullet engine to use. Either null (for unmanaged), "BulletUnmanaged" or "BulletXNA"
|
||||||
|
// 'params' is a set of keyValue pairs to set in the engine's configuration file (override defaults)
|
||||||
|
// May be 'null' if there are no overrides.
|
||||||
|
public static BSScene CreateBasicPhysicsEngine(Dictionary<string,string> paramOverrides)
|
||||||
|
{
|
||||||
|
IConfigSource openSimINI = new IniConfigSource();
|
||||||
|
IConfig startupConfig = openSimINI.AddConfig("Startup");
|
||||||
|
startupConfig.Set("physics", "BulletSim");
|
||||||
|
startupConfig.Set("meshing", "Meshmerizer");
|
||||||
|
startupConfig.Set("cacheSculptMaps", "false"); // meshmerizer shouldn't save maps
|
||||||
|
|
||||||
|
IConfig bulletSimConfig = openSimINI.AddConfig("BulletSim");
|
||||||
|
// If the caller cares, specify the bullet engine otherwise it will default to "BulletUnmanaged".
|
||||||
|
// bulletSimConfig.Set("BulletEngine", "BulletUnmanaged");
|
||||||
|
// bulletSimConfig.Set("BulletEngine", "BulletXNA");
|
||||||
|
bulletSimConfig.Set("MeshSculptedPrim", "false");
|
||||||
|
bulletSimConfig.Set("ForceSimplePrimMeshing", "true");
|
||||||
|
if (paramOverrides != null)
|
||||||
|
{
|
||||||
|
foreach (KeyValuePair<string, string> kvp in paramOverrides)
|
||||||
|
{
|
||||||
|
bulletSimConfig.Set(kvp.Key, kvp.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// bulletSimConfig.Set("PhysicsLoggingEnabled","True");
|
||||||
|
// bulletSimConfig.Set("PhysicsLoggingDoFlush","True");
|
||||||
|
// bulletSimConfig.Set("VehicleLoggingEnabled","True");
|
||||||
|
|
||||||
|
BSPlugin bsPlugin = new BSPlugin();
|
||||||
|
|
||||||
|
BSScene bsScene = (BSScene)bsPlugin.GetScene("BSTestRegion");
|
||||||
|
|
||||||
|
// Since the asset requestor is not initialized, any mesh or sculptie will be a cube.
|
||||||
|
// In the future, add a fake asset fetcher to get meshes and sculpts.
|
||||||
|
// bsScene.RequestAssetMethod = ???;
|
||||||
|
|
||||||
|
Meshing.Meshmerizer mesher = new Meshmerizer(openSimINI);
|
||||||
|
bsScene.Initialise(mesher, openSimINI);
|
||||||
|
|
||||||
|
return bsScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -4096,8 +4096,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
lock (_prims)
|
lock (_prims)
|
||||||
{
|
{
|
||||||
List<OdePrim> orderedPrims = new List<OdePrim>(_prims);
|
List<OdePrim> orderedPrims = new List<OdePrim>(_prims);
|
||||||
orderedPrims.OrderByDescending(p => p.CollisionScore).Take(25);
|
orderedPrims.OrderByDescending(p => p.CollisionScore);
|
||||||
topColliders = orderedPrims.ToDictionary(p => p.LocalID, p => p.CollisionScore);
|
topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore);
|
||||||
|
|
||||||
foreach (OdePrim p in _prims)
|
foreach (OdePrim p in _prims)
|
||||||
p.CollisionScore = 0;
|
p.CollisionScore = 0;
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
34
prebuild.xml
34
prebuild.xml
|
@ -3359,6 +3359,40 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
|
<Project frameworkVersion="v3_5" name="OpenSim.Region.Physics.BulletSPlugin.Tests" path="OpenSim/Region/Physics/BulletSPlugin/Tests" type="Library">
|
||||||
|
<Configuration name="Debug">
|
||||||
|
<Options>
|
||||||
|
<OutputPath>../../../../../bin/</OutputPath>
|
||||||
|
</Options>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration name="Release">
|
||||||
|
<Options>
|
||||||
|
<OutputPath>../../../../../bin/</OutputPath>
|
||||||
|
</Options>
|
||||||
|
</Configuration>
|
||||||
|
|
||||||
|
<ReferencePath>../../../../../bin/</ReferencePath>
|
||||||
|
<Reference name="System"/>
|
||||||
|
<Reference name="System.Core"/>
|
||||||
|
<Reference name="System.Data"/>
|
||||||
|
<Reference name="Nini" path="../../../../../bin/"/>
|
||||||
|
<Reference name="log4net" path="../../../../../bin/"/>
|
||||||
|
<Reference name="nunit.framework" path="../../../../../bin/"/>
|
||||||
|
<Reference name="OpenMetaverse" path="../../../../../bin/"/>
|
||||||
|
<Reference name="OpenMetaverseTypes" path="../../../../../bin/"/>
|
||||||
|
<Reference name="OpenSim.Framework"/>
|
||||||
|
<Reference name="OpenSim.Tests.Common"/>
|
||||||
|
<Reference name="OpenSim.Region.CoreModules"/>
|
||||||
|
<Reference name="OpenSim.Region.Physics.Meshing" path="../../../../../bin/Physics/"/>
|
||||||
|
<Reference name="OpenSim.Region.Physics.Manager"/>
|
||||||
|
<Reference name="OpenSim.Region.Physics.BulletSPlugin" path="../../../../../bin/Physics/"/>
|
||||||
|
|
||||||
|
<Files>
|
||||||
|
<Match pattern="*.cs" recurse="false"/>
|
||||||
|
</Files>
|
||||||
|
</Project>
|
||||||
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.Server.Handlers.Tests" path="OpenSim/Server/Handlers" type="Library">
|
<Project frameworkVersion="v3_5" name="OpenSim.Server.Handlers.Tests" path="OpenSim/Server/Handlers" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
|
|
Loading…
Reference in New Issue