BulletSim: Added avatar capsule scaling for size of avatar.
This also fixes computation of avatar mass. Added parameter MaxPersistantManifoldPoolSize. Fixed a parameter setting bug which caused crashes of there were more than 400 or so physical objects. I tested up to 5000. Updated BulletSim DLLs and SOs.integration
parent
926c0b90a1
commit
19417fca41
|
@ -102,7 +102,9 @@ public class BSCharacter : PhysicsActor
|
|||
_orientation = Quaternion.Identity;
|
||||
_velocity = Vector3.Zero;
|
||||
_buoyancy = ComputeBuoyancyFromFlying(isFlying);
|
||||
_scale = new Vector3(1f, 1f, 1f);
|
||||
// The dimensions of the avatar capsule are kept in the scale.
|
||||
// Physics creates a unit capsule which is scaled by the physics engine.
|
||||
_scale = new Vector3(_scene.Params.avatarCapsuleRadius, _scene.Params.avatarCapsuleRadius, size.Z);
|
||||
_density = _scene.Params.avatarDensity;
|
||||
ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale
|
||||
|
||||
|
@ -150,9 +152,28 @@ public class BSCharacter : PhysicsActor
|
|||
public override bool Stopped {
|
||||
get { return false; }
|
||||
}
|
||||
public override Vector3 Size {
|
||||
get { return _size; }
|
||||
set { _size = value;
|
||||
public override Vector3 Size {
|
||||
get
|
||||
{
|
||||
// Avatar capsule size is kept in the scale parameter.
|
||||
return new Vector3(_scale.X * 2, _scale.Y * 2, _scale.Z);
|
||||
}
|
||||
|
||||
set {
|
||||
// When an avatar's size is set, only the height is changed
|
||||
// and that really only depends on the radius.
|
||||
_size = value;
|
||||
_scale.Z = (_size.Z * 1.15f) - (_scale.X + _scale.Y);
|
||||
|
||||
// TODO: something has to be done with the avatar's vertical position
|
||||
|
||||
ComputeAvatarVolumeAndMass();
|
||||
|
||||
_scene.TaintedObject(delegate()
|
||||
{
|
||||
BulletSimAPI.SetObjectScaleMass(_scene.WorldID, LocalID, _scale, _mass, true);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
public override PrimitiveBaseShape Shape {
|
||||
|
@ -419,9 +440,15 @@ public class BSCharacter : PhysicsActor
|
|||
{
|
||||
_avatarVolume = (float)(
|
||||
Math.PI
|
||||
* _scene.Params.avatarCapsuleRadius * _scale.X
|
||||
* _scene.Params.avatarCapsuleRadius * _scale.Y
|
||||
* _scene.Params.avatarCapsuleHeight * _scale.Z);
|
||||
* _scale.X
|
||||
* _scale.Y // the area of capsule cylinder
|
||||
* _scale.Z // times height of capsule cylinder
|
||||
+ 1.33333333f
|
||||
* Math.PI
|
||||
* _scale.X
|
||||
* Math.Min(_scale.X, _scale.Y)
|
||||
* _scale.Y // plus the volume of the capsule end caps
|
||||
);
|
||||
_mass = _density * _avatarVolume;
|
||||
}
|
||||
|
||||
|
|
|
@ -977,8 +977,8 @@ public sealed class BSPrim : PhysicsActor
|
|||
{
|
||||
if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1)
|
||||
{
|
||||
if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z)
|
||||
{
|
||||
// if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z)
|
||||
// {
|
||||
// m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size);
|
||||
if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE))
|
||||
{
|
||||
|
@ -989,7 +989,7 @@ public sealed class BSPrim : PhysicsActor
|
|||
// TODO: do we need to check for and destroy a mesh or hull that might have been left from before?
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1039,7 +1039,7 @@ public sealed class BSPrim : PhysicsActor
|
|||
// if this new shape is the same as last time, don't recreate the mesh
|
||||
if (_meshKey == newMeshKey) return;
|
||||
|
||||
DetailLog("{0},CreateGeomMesh,create,key={1}", LocalID, _meshKey);
|
||||
DetailLog("{0},CreateGeomMesh,create,key={1}", LocalID, newMeshKey);
|
||||
// Since we're recreating new, get rid of any previously generated shape
|
||||
if (_meshKey != 0)
|
||||
{
|
||||
|
|
|
@ -1027,14 +1027,19 @@ public class BSScene : PhysicsScene, IPhysicsParameters
|
|||
(s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarContactProcessingThreshold, p, l, v); } ),
|
||||
|
||||
|
||||
new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default)",
|
||||
new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)",
|
||||
0f, // zero to disable
|
||||
(s,cf,p,v) => { s.m_params[0].maxPersistantManifoldPoolSize = cf.GetFloat(p, v); },
|
||||
(s) => { return s.m_params[0].maxPersistantManifoldPoolSize; },
|
||||
(s,p,l,v) => { s.m_params[0].maxPersistantManifoldPoolSize = v; } ),
|
||||
new ParameterDefn("MaxCollisionAlgorithmPoolSize", "Number of collisions pooled (0 means default of 4096)",
|
||||
0f, // zero to disable
|
||||
(s,cf,p,v) => { s.m_params[0].maxCollisionAlgorithmPoolSize = cf.GetFloat(p, v); },
|
||||
(s) => { return s.m_params[0].maxCollisionAlgorithmPoolSize; },
|
||||
(s,p,l,v) => { s.m_params[0].maxCollisionAlgorithmPoolSize = v; } ),
|
||||
new ParameterDefn("ShouldDisableContactPoolDynamicAllocation", "Enable to allow large changes in object count",
|
||||
ConfigurationParameters.numericTrue,
|
||||
(s,cf,p,v) => { s.m_params[0].maxPersistantManifoldPoolSize = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); },
|
||||
ConfigurationParameters.numericFalse,
|
||||
(s,cf,p,v) => { s.m_params[0].shouldDisableContactPoolDynamicAllocation = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); },
|
||||
(s) => { return s.m_params[0].shouldDisableContactPoolDynamicAllocation; },
|
||||
(s,p,l,v) => { s.m_params[0].shouldDisableContactPoolDynamicAllocation = v; } ),
|
||||
new ParameterDefn("ShouldForceUpdateAllAabbs", "Enable to recomputer AABBs every simulator step",
|
||||
|
|
|
@ -158,6 +158,7 @@ public struct ConfigurationParameters
|
|||
public float avatarContactProcessingThreshold;
|
||||
|
||||
public float maxPersistantManifoldPoolSize;
|
||||
public float maxCollisionAlgorithmPoolSize;
|
||||
public float shouldDisableContactPoolDynamicAllocation;
|
||||
public float shouldForceUpdateAllAabbs;
|
||||
public float shouldRandomizeSolverOrder;
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue