BulletSim: rework some parameter setting implementation moving functionality that was in BSScene to BSParam. Remove unused parameters that were passed to the unmanaged code. Update DLLs and SOs for the new param block.

user_profiles
Robert Adams 2013-02-03 16:08:09 -08:00
parent 2b6d226911
commit ad438ee59f
9 changed files with 149 additions and 155 deletions

View File

@ -1088,7 +1088,7 @@ private sealed class BulletConstraintXNA : BulletConstraint
{ {
CollisionWorld.WorldData.ParamData p = new CollisionWorld.WorldData.ParamData(); CollisionWorld.WorldData.ParamData p = new CollisionWorld.WorldData.ParamData();
p.angularDamping = o[0].XangularDamping; p.angularDamping = BSParam.AngularDamping;
p.defaultFriction = o[0].defaultFriction; p.defaultFriction = o[0].defaultFriction;
p.defaultFriction = o[0].defaultFriction; p.defaultFriction = o[0].defaultFriction;
p.defaultDensity = o[0].defaultDensity; p.defaultDensity = o[0].defaultDensity;
@ -1096,32 +1096,32 @@ private sealed class BulletConstraintXNA : BulletConstraint
p.collisionMargin = o[0].collisionMargin; p.collisionMargin = o[0].collisionMargin;
p.gravity = o[0].gravity; p.gravity = o[0].gravity;
p.linearDamping = o[0].XlinearDamping; p.linearDamping = BSParam.LinearDamping;
p.angularDamping = o[0].XangularDamping; p.angularDamping = BSParam.AngularDamping;
p.deactivationTime = o[0].XdeactivationTime; p.deactivationTime = BSParam.DeactivationTime;
p.linearSleepingThreshold = o[0].XlinearSleepingThreshold; p.linearSleepingThreshold = BSParam.LinearSleepingThreshold;
p.angularSleepingThreshold = o[0].XangularSleepingThreshold; p.angularSleepingThreshold = BSParam.AngularSleepingThreshold;
p.ccdMotionThreshold = o[0].XccdMotionThreshold; p.ccdMotionThreshold = BSParam.CcdMotionThreshold;
p.ccdSweptSphereRadius = o[0].XccdSweptSphereRadius; p.ccdSweptSphereRadius = BSParam.CcdSweptSphereRadius;
p.contactProcessingThreshold = o[0].XcontactProcessingThreshold; p.contactProcessingThreshold = BSParam.ContactProcessingThreshold;
p.terrainImplementation = o[0].XterrainImplementation; p.terrainImplementation = BSParam.TerrainImplementation;
p.terrainFriction = o[0].XterrainFriction; p.terrainFriction = BSParam.TerrainFriction;
p.terrainHitFraction = o[0].XterrainHitFraction; p.terrainHitFraction = BSParam.TerrainHitFraction;
p.terrainRestitution = o[0].XterrainRestitution; p.terrainRestitution = BSParam.TerrainRestitution;
p.terrainCollisionMargin = o[0].XterrainCollisionMargin; p.terrainCollisionMargin = BSParam.TerrainCollisionMargin;
p.avatarFriction = o[0].XavatarFriction; p.avatarFriction = BSParam.AvatarFriction;
p.avatarStandingFriction = o[0].XavatarStandingFriction; p.avatarStandingFriction = BSParam.AvatarStandingFriction;
p.avatarDensity = o[0].XavatarDensity; p.avatarDensity = BSParam.AvatarDensity;
p.avatarRestitution = o[0].XavatarRestitution; p.avatarRestitution = BSParam.AvatarRestitution;
p.avatarCapsuleWidth = o[0].XavatarCapsuleWidth; p.avatarCapsuleWidth = BSParam.AvatarCapsuleWidth;
p.avatarCapsuleDepth = o[0].XavatarCapsuleDepth; p.avatarCapsuleDepth = BSParam.AvatarCapsuleDepth;
p.avatarCapsuleHeight = o[0].XavatarCapsuleHeight; p.avatarCapsuleHeight = BSParam.AvatarCapsuleHeight;
p.avatarContactProcessingThreshold = o[0].XavatarContactProcessingThreshold; p.avatarContactProcessingThreshold = BSParam.AvatarContactProcessingThreshold;
p.vehicleAngularDamping = o[0].XvehicleAngularDamping; p.vehicleAngularDamping = BSParam.VehicleAngularDamping;
p.maxPersistantManifoldPoolSize = o[0].maxPersistantManifoldPoolSize; p.maxPersistantManifoldPoolSize = o[0].maxPersistantManifoldPoolSize;
p.maxCollisionAlgorithmPoolSize = o[0].maxCollisionAlgorithmPoolSize; p.maxCollisionAlgorithmPoolSize = o[0].maxCollisionAlgorithmPoolSize;
@ -1132,15 +1132,15 @@ private sealed class BulletConstraintXNA : BulletConstraint
p.shouldEnableFrictionCaching = o[0].shouldEnableFrictionCaching; p.shouldEnableFrictionCaching = o[0].shouldEnableFrictionCaching;
p.numberOfSolverIterations = o[0].numberOfSolverIterations; p.numberOfSolverIterations = o[0].numberOfSolverIterations;
p.linksetImplementation = o[0].XlinksetImplementation; p.linksetImplementation = BSParam.LinksetImplementation;
p.linkConstraintUseFrameOffset = o[0].XlinkConstraintUseFrameOffset; p.linkConstraintUseFrameOffset = BSParam.LinkConstraintUseFrameOffset;
p.linkConstraintEnableTransMotor = o[0].XlinkConstraintEnableTransMotor; p.linkConstraintEnableTransMotor = BSParam.LinkConstraintEnableTransMotor;
p.linkConstraintTransMotorMaxVel = o[0].XlinkConstraintTransMotorMaxVel; p.linkConstraintTransMotorMaxVel = BSParam.LinkConstraintTransMotorMaxVel;
p.linkConstraintTransMotorMaxForce = o[0].XlinkConstraintTransMotorMaxForce; p.linkConstraintTransMotorMaxForce = BSParam.LinkConstraintTransMotorMaxForce;
p.linkConstraintERP = o[0].XlinkConstraintERP; p.linkConstraintERP = BSParam.LinkConstraintERP;
p.linkConstraintCFM = o[0].XlinkConstraintCFM; p.linkConstraintCFM = BSParam.LinkConstraintCFM;
p.linkConstraintSolverIterations = o[0].XlinkConstraintSolverIterations; p.linkConstraintSolverIterations = BSParam.LinkConstraintSolverIterations;
p.physicsLoggingFrames = o[0].XphysicsLoggingFrames; p.physicsLoggingFrames = o[0].physicsLoggingFrames;
DefaultCollisionConstructionInfo ccci = new DefaultCollisionConstructionInfo(); DefaultCollisionConstructionInfo ccci = new DefaultCollisionConstructionInfo();
DefaultCollisionConfiguration cci = new DefaultCollisionConfiguration(); DefaultCollisionConfiguration cci = new DefaultCollisionConfiguration();

View File

@ -174,32 +174,6 @@ public struct ConfigurationParameters
public float collisionMargin; public float collisionMargin;
public float gravity; public float gravity;
public float XlinearDamping;
public float XangularDamping;
public float XdeactivationTime;
public float XlinearSleepingThreshold;
public float XangularSleepingThreshold;
public float XccdMotionThreshold;
public float XccdSweptSphereRadius;
public float XcontactProcessingThreshold;
public float XterrainImplementation;
public float XterrainFriction;
public float XterrainHitFraction;
public float XterrainRestitution;
public float XterrainCollisionMargin;
public float XavatarFriction;
public float XavatarStandingFriction;
public float XavatarDensity;
public float XavatarRestitution;
public float XavatarCapsuleWidth;
public float XavatarCapsuleDepth;
public float XavatarCapsuleHeight;
public float XavatarContactProcessingThreshold;
public float XvehicleAngularDamping;
public float maxPersistantManifoldPoolSize; public float maxPersistantManifoldPoolSize;
public float maxCollisionAlgorithmPoolSize; public float maxCollisionAlgorithmPoolSize;
public float shouldDisableContactPoolDynamicAllocation; public float shouldDisableContactPoolDynamicAllocation;
@ -208,17 +182,9 @@ public struct ConfigurationParameters
public float shouldSplitSimulationIslands; public float shouldSplitSimulationIslands;
public float shouldEnableFrictionCaching; public float shouldEnableFrictionCaching;
public float numberOfSolverIterations; public float numberOfSolverIterations;
public float useSingleSidedMeshes;
public float XlinksetImplementation; public float physicsLoggingFrames;
public float XlinkConstraintUseFrameOffset;
public float XlinkConstraintEnableTransMotor;
public float XlinkConstraintTransMotorMaxVel;
public float XlinkConstraintTransMotorMaxForce;
public float XlinkConstraintERP;
public float XlinkConstraintCFM;
public float XlinkConstraintSolverIterations;
public float XphysicsLoggingFrames;
public const float numericTrue = 1f; public const float numericTrue = 1f;
public const float numericFalse = 0f; public const float numericFalse = 0f;

View File

@ -68,6 +68,24 @@ public static class BSParam
public static float TerrainRestitution { get; private set; } public static float TerrainRestitution { get; private set; }
public static float TerrainCollisionMargin { get; private set; } public static float TerrainCollisionMargin { get; private set; }
public static float DefaultFriction;
public static float DefaultDensity;
public static float DefaultRestitution;
public static float CollisionMargin;
public static float Gravity;
// Physics Engine operation
public static float MaxPersistantManifoldPoolSize;
public static float MaxCollisionAlgorithmPoolSize;
public static float ShouldDisableContactPoolDynamicAllocation;
public static float ShouldForceUpdateAllAabbs;
public static float ShouldRandomizeSolverOrder;
public static float ShouldSplitSimulationIslands;
public static float ShouldEnableFrictionCaching;
public static float NumberOfSolverIterations;
public static bool UseSingleSidedMeshes { get { return UseSingleSidedMeshesF != ConfigurationParameters.numericFalse; } }
public static float UseSingleSidedMeshesF;
// Avatar parameters // Avatar parameters
public static float AvatarFriction { get; private set; } public static float AvatarFriction { get; private set; }
public static float AvatarStandingFriction { get; private set; } public static float AvatarStandingFriction { get; private set; }
@ -287,29 +305,29 @@ public static class BSParam
new ParameterDefn("DefaultFriction", "Friction factor used on new objects", new ParameterDefn("DefaultFriction", "Friction factor used on new objects",
0.2f, 0.2f,
(s,cf,p,v) => { s.UnmanagedParams[0].defaultFriction = cf.GetFloat(p, v); }, (s,cf,p,v) => { DefaultFriction = cf.GetFloat(p, v); },
(s) => { return s.UnmanagedParams[0].defaultFriction; }, (s) => { return DefaultFriction; },
(s,p,l,v) => { s.UnmanagedParams[0].defaultFriction = v; } ), (s,p,l,v) => { DefaultFriction = v; s.UnmanagedParams[0].defaultFriction = v; } ),
new ParameterDefn("DefaultDensity", "Density for new objects" , new ParameterDefn("DefaultDensity", "Density for new objects" ,
10.000006836f, // Aluminum g/cm3 10.000006836f, // Aluminum g/cm3
(s,cf,p,v) => { s.UnmanagedParams[0].defaultDensity = cf.GetFloat(p, v); }, (s,cf,p,v) => { DefaultDensity = cf.GetFloat(p, v); },
(s) => { return s.UnmanagedParams[0].defaultDensity; }, (s) => { return DefaultDensity; },
(s,p,l,v) => { s.UnmanagedParams[0].defaultDensity = v; } ), (s,p,l,v) => { DefaultDensity = v; s.UnmanagedParams[0].defaultDensity = v; } ),
new ParameterDefn("DefaultRestitution", "Bouncyness of an object" , new ParameterDefn("DefaultRestitution", "Bouncyness of an object" ,
0f, 0f,
(s,cf,p,v) => { s.UnmanagedParams[0].defaultRestitution = cf.GetFloat(p, v); }, (s,cf,p,v) => { DefaultRestitution = cf.GetFloat(p, v); },
(s) => { return s.UnmanagedParams[0].defaultRestitution; }, (s) => { return DefaultRestitution; },
(s,p,l,v) => { s.UnmanagedParams[0].defaultRestitution = v; } ), (s,p,l,v) => { DefaultRestitution = v; s.UnmanagedParams[0].defaultRestitution = v; } ),
new ParameterDefn("CollisionMargin", "Margin around objects before collisions are calculated (must be zero!)", new ParameterDefn("CollisionMargin", "Margin around objects before collisions are calculated (must be zero!)",
0.04f, 0.04f,
(s,cf,p,v) => { s.UnmanagedParams[0].collisionMargin = cf.GetFloat(p, v); }, (s,cf,p,v) => { CollisionMargin = cf.GetFloat(p, v); },
(s) => { return s.UnmanagedParams[0].collisionMargin; }, (s) => { return CollisionMargin; },
(s,p,l,v) => { s.UnmanagedParams[0].collisionMargin = v; } ), (s,p,l,v) => { CollisionMargin = v; s.UnmanagedParams[0].collisionMargin = v; } ),
new ParameterDefn("Gravity", "Vertical force of gravity (negative means down)", new ParameterDefn("Gravity", "Vertical force of gravity (negative means down)",
-9.80665f, -9.80665f,
(s,cf,p,v) => { s.UnmanagedParams[0].gravity = cf.GetFloat(p, v); }, (s,cf,p,v) => { Gravity = cf.GetFloat(p, v); },
(s) => { return s.UnmanagedParams[0].gravity; }, (s) => { return Gravity; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{s.UnmanagedParams[0].gravity=x;}, p, PhysParameterEntry.APPLY_TO_NONE, v); }, (s,p,l,v) => { Gravity = v; s.UnmanagedParams[0].gravity = v; },
(s,o,v) => { s.PE.SetGravity(o.PhysBody, new Vector3(0f,0f,v)); } ), (s,o,v) => { s.PE.SetGravity(o.PhysBody, new Vector3(0f,0f,v)); } ),
@ -317,49 +335,49 @@ public static class BSParam
0f, 0f,
(s,cf,p,v) => { LinearDamping = cf.GetFloat(p, v); }, (s,cf,p,v) => { LinearDamping = cf.GetFloat(p, v); },
(s) => { return LinearDamping; }, (s) => { return LinearDamping; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearDamping=x;}, p, l, v); }, (s,p,l,v) => { LinearDamping = v; },
(s,o,v) => { s.PE.SetDamping(o.PhysBody, v, AngularDamping); } ), (s,o,v) => { s.PE.SetDamping(o.PhysBody, v, AngularDamping); } ),
new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)", new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)",
0f, 0f,
(s,cf,p,v) => { AngularDamping = cf.GetFloat(p, v); }, (s,cf,p,v) => { AngularDamping = cf.GetFloat(p, v); },
(s) => { return AngularDamping; }, (s) => { return AngularDamping; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularDamping=x;}, p, l, v); }, (s,p,l,v) => { AngularDamping = v; },
(s,o,v) => { s.PE.SetDamping(o.PhysBody, LinearDamping, v); } ), (s,o,v) => { s.PE.SetDamping(o.PhysBody, LinearDamping, v); } ),
new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static", new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static",
0.2f, 0.2f,
(s,cf,p,v) => { DeactivationTime = cf.GetFloat(p, v); }, (s,cf,p,v) => { DeactivationTime = cf.GetFloat(p, v); },
(s) => { return DeactivationTime; }, (s) => { return DeactivationTime; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{DeactivationTime=x;}, p, l, v); }, (s,p,l,v) => { DeactivationTime = v; },
(s,o,v) => { s.PE.SetDeactivationTime(o.PhysBody, v); } ), (s,o,v) => { s.PE.SetDeactivationTime(o.PhysBody, v); } ),
new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static", new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static",
0.8f, 0.8f,
(s,cf,p,v) => { LinearSleepingThreshold = cf.GetFloat(p, v); }, (s,cf,p,v) => { LinearSleepingThreshold = cf.GetFloat(p, v); },
(s) => { return LinearSleepingThreshold; }, (s) => { return LinearSleepingThreshold; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{LinearSleepingThreshold=x;}, p, l, v); }, (s,p,l,v) => { LinearSleepingThreshold = v;},
(s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ), (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ),
new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static", new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static",
1.0f, 1.0f,
(s,cf,p,v) => { AngularSleepingThreshold = cf.GetFloat(p, v); }, (s,cf,p,v) => { AngularSleepingThreshold = cf.GetFloat(p, v); },
(s) => { return AngularSleepingThreshold; }, (s) => { return AngularSleepingThreshold; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); }, (s,p,l,v) => { AngularSleepingThreshold = v;},
(s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ), (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ),
new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ,
0.0f, // set to zero to disable 0.0f, // set to zero to disable
(s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); }, (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); },
(s) => { return CcdMotionThreshold; }, (s) => { return CcdMotionThreshold; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); }, (s,p,l,v) => { CcdMotionThreshold = v;},
(s,o,v) => { s.PE.SetCcdMotionThreshold(o.PhysBody, v); } ), (s,o,v) => { s.PE.SetCcdMotionThreshold(o.PhysBody, v); } ),
new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" , new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" ,
0.2f, 0.2f,
(s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); }, (s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); },
(s) => { return CcdSweptSphereRadius; }, (s) => { return CcdSweptSphereRadius; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); }, (s,p,l,v) => { CcdSweptSphereRadius = v;},
(s,o,v) => { s.PE.SetCcdSweptSphereRadius(o.PhysBody, v); } ), (s,o,v) => { s.PE.SetCcdSweptSphereRadius(o.PhysBody, v); } ),
new ParameterDefn("ContactProcessingThreshold", "Distance above which contacts can be discarded (0 means no discard)" , new ParameterDefn("ContactProcessingThreshold", "Distance above which contacts can be discarded (0 means no discard)" ,
0.0f, 0.0f,
(s,cf,p,v) => { ContactProcessingThreshold = cf.GetFloat(p, v); }, (s,cf,p,v) => { ContactProcessingThreshold = cf.GetFloat(p, v); },
(s) => { return ContactProcessingThreshold; }, (s) => { return ContactProcessingThreshold; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{ContactProcessingThreshold=x;}, p, l, v); }, (s,p,l,v) => { ContactProcessingThreshold = v;},
(s,o,v) => { s.PE.SetContactProcessingThreshold(o.PhysBody, v); } ), (s,o,v) => { s.PE.SetContactProcessingThreshold(o.PhysBody, v); } ),
new ParameterDefn("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)", new ParameterDefn("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)",
@ -392,7 +410,7 @@ public static class BSParam
0.2f, 0.2f,
(s,cf,p,v) => { AvatarFriction = cf.GetFloat(p, v); }, (s,cf,p,v) => { AvatarFriction = cf.GetFloat(p, v); },
(s) => { return AvatarFriction; }, (s) => { return AvatarFriction; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarFriction=x;}, p, l, v); } ), (s,p,l,v) => { AvatarFriction = v; } ),
new ParameterDefn("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.", new ParameterDefn("AvatarStandingFriction", "Avatar friction when standing. Changed on avatar recreation.",
10.0f, 10.0f,
(s,cf,p,v) => { AvatarStandingFriction = cf.GetFloat(p, v); }, (s,cf,p,v) => { AvatarStandingFriction = cf.GetFloat(p, v); },
@ -407,32 +425,32 @@ public static class BSParam
3.5f, 3.5f,
(s,cf,p,v) => { AvatarDensity = cf.GetFloat(p, v); }, (s,cf,p,v) => { AvatarDensity = cf.GetFloat(p, v); },
(s) => { return AvatarDensity; }, (s) => { return AvatarDensity; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarDensity=x;}, p, l, v); } ), (s,p,l,v) => { AvatarDensity = v; } ),
new ParameterDefn("AvatarRestitution", "Bouncyness. Changed on avatar recreation.", new ParameterDefn("AvatarRestitution", "Bouncyness. Changed on avatar recreation.",
0f, 0f,
(s,cf,p,v) => { AvatarRestitution = cf.GetFloat(p, v); }, (s,cf,p,v) => { AvatarRestitution = cf.GetFloat(p, v); },
(s) => { return AvatarRestitution; }, (s) => { return AvatarRestitution; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarRestitution=x;}, p, l, v); } ), (s,p,l,v) => { AvatarRestitution = v; } ),
new ParameterDefn("AvatarCapsuleWidth", "The distance between the sides of the avatar capsule", new ParameterDefn("AvatarCapsuleWidth", "The distance between the sides of the avatar capsule",
0.6f, 0.6f,
(s,cf,p,v) => { AvatarCapsuleWidth = cf.GetFloat(p, v); }, (s,cf,p,v) => { AvatarCapsuleWidth = cf.GetFloat(p, v); },
(s) => { return AvatarCapsuleWidth; }, (s) => { return AvatarCapsuleWidth; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarCapsuleWidth=x;}, p, l, v); } ), (s,p,l,v) => { AvatarCapsuleWidth = v; } ),
new ParameterDefn("AvatarCapsuleDepth", "The distance between the front and back of the avatar capsule", new ParameterDefn("AvatarCapsuleDepth", "The distance between the front and back of the avatar capsule",
0.45f, 0.45f,
(s,cf,p,v) => { AvatarCapsuleDepth = cf.GetFloat(p, v); }, (s,cf,p,v) => { AvatarCapsuleDepth = cf.GetFloat(p, v); },
(s) => { return AvatarCapsuleDepth; }, (s) => { return AvatarCapsuleDepth; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarCapsuleDepth=x;}, p, l, v); } ), (s,p,l,v) => { AvatarCapsuleDepth = v; } ),
new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar", new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar",
1.5f, 1.5f,
(s,cf,p,v) => { AvatarCapsuleHeight = cf.GetFloat(p, v); }, (s,cf,p,v) => { AvatarCapsuleHeight = cf.GetFloat(p, v); },
(s) => { return AvatarCapsuleHeight; }, (s) => { return AvatarCapsuleHeight; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarCapsuleHeight=x;}, p, l, v); } ), (s,p,l,v) => { AvatarCapsuleHeight = v; } ),
new ParameterDefn("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions", new ParameterDefn("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions",
0.1f, 0.1f,
(s,cf,p,v) => { AvatarContactProcessingThreshold = cf.GetFloat(p, v); }, (s,cf,p,v) => { AvatarContactProcessingThreshold = cf.GetFloat(p, v); },
(s) => { return AvatarContactProcessingThreshold; }, (s) => { return AvatarContactProcessingThreshold; },
(s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarContactProcessingThreshold=x;}, p, l, v); } ), (s,p,l,v) => { AvatarContactProcessingThreshold = v; } ),
new ParameterDefn("AvatarStepHeight", "Height of a step obstacle to consider step correction", new ParameterDefn("AvatarStepHeight", "Height of a step obstacle to consider step correction",
0.3f, 0.3f,
(s,cf,p,v) => { AvatarStepHeight = cf.GetFloat(p, v); }, (s,cf,p,v) => { AvatarStepHeight = cf.GetFloat(p, v); },
@ -497,44 +515,49 @@ public static class BSParam
new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)", new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)",
0f, 0f,
(s,cf,p,v) => { s.UnmanagedParams[0].maxPersistantManifoldPoolSize = cf.GetFloat(p, v); }, (s,cf,p,v) => { MaxPersistantManifoldPoolSize = cf.GetFloat(p, v); },
(s) => { return s.UnmanagedParams[0].maxPersistantManifoldPoolSize; }, (s) => { return MaxPersistantManifoldPoolSize; },
(s,p,l,v) => { s.UnmanagedParams[0].maxPersistantManifoldPoolSize = v; } ), (s,p,l,v) => { MaxPersistantManifoldPoolSize = v; s.UnmanagedParams[0].maxPersistantManifoldPoolSize = v; } ),
new ParameterDefn("MaxCollisionAlgorithmPoolSize", "Number of collisions pooled (0 means default of 4096)", new ParameterDefn("MaxCollisionAlgorithmPoolSize", "Number of collisions pooled (0 means default of 4096)",
0f, 0f,
(s,cf,p,v) => { s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize = cf.GetFloat(p, v); }, (s,cf,p,v) => { MaxCollisionAlgorithmPoolSize = cf.GetFloat(p, v); },
(s) => { return s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize; }, (s) => { return MaxCollisionAlgorithmPoolSize; },
(s,p,l,v) => { s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize = v; } ), (s,p,l,v) => { MaxCollisionAlgorithmPoolSize = v; s.UnmanagedParams[0].maxCollisionAlgorithmPoolSize = v; } ),
new ParameterDefn("ShouldDisableContactPoolDynamicAllocation", "Enable to allow large changes in object count", new ParameterDefn("ShouldDisableContactPoolDynamicAllocation", "Enable to allow large changes in object count",
ConfigurationParameters.numericFalse, ConfigurationParameters.numericFalse,
(s,cf,p,v) => { s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, (s,cf,p,v) => { ShouldDisableContactPoolDynamicAllocation = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
(s) => { return s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation; }, (s) => { return ShouldDisableContactPoolDynamicAllocation; },
(s,p,l,v) => { s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation = v; } ), (s,p,l,v) => { ShouldDisableContactPoolDynamicAllocation = v; s.UnmanagedParams[0].shouldDisableContactPoolDynamicAllocation = v; } ),
new ParameterDefn("ShouldForceUpdateAllAabbs", "Enable to recomputer AABBs every simulator step", new ParameterDefn("ShouldForceUpdateAllAabbs", "Enable to recomputer AABBs every simulator step",
ConfigurationParameters.numericFalse, ConfigurationParameters.numericFalse,
(s,cf,p,v) => { s.UnmanagedParams[0].shouldForceUpdateAllAabbs = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, (s,cf,p,v) => { ShouldForceUpdateAllAabbs = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
(s) => { return s.UnmanagedParams[0].shouldForceUpdateAllAabbs; }, (s) => { return ShouldForceUpdateAllAabbs; },
(s,p,l,v) => { s.UnmanagedParams[0].shouldForceUpdateAllAabbs = v; } ), (s,p,l,v) => { ShouldForceUpdateAllAabbs = v; s.UnmanagedParams[0].shouldForceUpdateAllAabbs = v; } ),
new ParameterDefn("ShouldRandomizeSolverOrder", "Enable for slightly better stacking interaction", new ParameterDefn("ShouldRandomizeSolverOrder", "Enable for slightly better stacking interaction",
ConfigurationParameters.numericTrue, ConfigurationParameters.numericTrue,
(s,cf,p,v) => { s.UnmanagedParams[0].shouldRandomizeSolverOrder = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, (s,cf,p,v) => { ShouldRandomizeSolverOrder = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
(s) => { return s.UnmanagedParams[0].shouldRandomizeSolverOrder; }, (s) => { return ShouldRandomizeSolverOrder; },
(s,p,l,v) => { s.UnmanagedParams[0].shouldRandomizeSolverOrder = v; } ), (s,p,l,v) => { ShouldRandomizeSolverOrder = v; s.UnmanagedParams[0].shouldRandomizeSolverOrder = v; } ),
new ParameterDefn("ShouldSplitSimulationIslands", "Enable splitting active object scanning islands", new ParameterDefn("ShouldSplitSimulationIslands", "Enable splitting active object scanning islands",
ConfigurationParameters.numericTrue, ConfigurationParameters.numericTrue,
(s,cf,p,v) => { s.UnmanagedParams[0].shouldSplitSimulationIslands = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, (s,cf,p,v) => { ShouldSplitSimulationIslands = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
(s) => { return s.UnmanagedParams[0].shouldSplitSimulationIslands; }, (s) => { return ShouldSplitSimulationIslands; },
(s,p,l,v) => { s.UnmanagedParams[0].shouldSplitSimulationIslands = v; } ), (s,p,l,v) => { ShouldSplitSimulationIslands = v; s.UnmanagedParams[0].shouldSplitSimulationIslands = v; } ),
new ParameterDefn("ShouldEnableFrictionCaching", "Enable friction computation caching", new ParameterDefn("ShouldEnableFrictionCaching", "Enable friction computation caching",
ConfigurationParameters.numericTrue, ConfigurationParameters.numericTrue,
(s,cf,p,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, (s,cf,p,v) => { ShouldEnableFrictionCaching = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
(s) => { return s.UnmanagedParams[0].shouldEnableFrictionCaching; }, (s) => { return ShouldEnableFrictionCaching; },
(s,p,l,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = v; } ), (s,p,l,v) => { ShouldEnableFrictionCaching = v; s.UnmanagedParams[0].shouldEnableFrictionCaching = v; } ),
new ParameterDefn("NumberOfSolverIterations", "Number of internal iterations (0 means default)", new ParameterDefn("NumberOfSolverIterations", "Number of internal iterations (0 means default)",
0f, // zero says use Bullet default 0f, // zero says use Bullet default
(s,cf,p,v) => { s.UnmanagedParams[0].numberOfSolverIterations = cf.GetFloat(p, v); }, (s,cf,p,v) => { NumberOfSolverIterations = cf.GetFloat(p, v); },
(s) => { return s.UnmanagedParams[0].numberOfSolverIterations; }, (s) => { return NumberOfSolverIterations; },
(s,p,l,v) => { s.UnmanagedParams[0].numberOfSolverIterations = v; } ), (s,p,l,v) => { NumberOfSolverIterations = v; s.UnmanagedParams[0].numberOfSolverIterations = v; } ),
new ParameterDefn("UseSingleSidedMeshes", "Whether to compute collisions based on single sided meshes.",
ConfigurationParameters.numericTrue,
(s,cf,p,v) => { UseSingleSidedMeshesF = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
(s) => { return UseSingleSidedMeshesF; },
(s,p,l,v) => { UseSingleSidedMeshesF = v; s.UnmanagedParams[0].useSingleSidedMeshes = v; } ),
new ParameterDefn("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)", new ParameterDefn("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)",
(float)BSLinkset.LinksetImplementation.Compound, (float)BSLinkset.LinksetImplementation.Compound,

View File

@ -882,30 +882,25 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
BSParam.ParameterDefn theParam; BSParam.ParameterDefn theParam;
if (BSParam.TryGetParameter(parm, out theParam)) if (BSParam.TryGetParameter(parm, out theParam))
{ {
// Set the value in the C# code
theParam.setter(this, parm, localID, val); theParam.setter(this, parm, localID, val);
ret = true;
}
return ret;
}
// Optionally set the parameter in the unmanaged code
if (theParam.onObject != null)
{
// update all the localIDs specified // update all the localIDs specified
// If the local ID is APPLY_TO_NONE, just change the default value // If the local ID is APPLY_TO_NONE, just change the default value
// If the localID is APPLY_TO_ALL change the default value and apply the new value to all the lIDs // If the localID is APPLY_TO_ALL change the default value and apply the new value to all the lIDs
// If the localID is a specific object, apply the parameter change to only that object // If the localID is a specific object, apply the parameter change to only that object
internal delegate void AssignVal(float x);
internal void UpdateParameterObject(AssignVal setDefault, string parm, uint localID, float val)
{
List<uint> objectIDs = new List<uint>(); List<uint> objectIDs = new List<uint>();
switch (localID) switch (localID)
{ {
case PhysParameterEntry.APPLY_TO_NONE: case PhysParameterEntry.APPLY_TO_NONE:
setDefault(val); // setting only the default value
// This will cause a call into the physical world if some operation is specified (SetOnObject). // This will cause a call into the physical world if some operation is specified (SetOnObject).
objectIDs.Add(TERRAIN_ID); objectIDs.Add(TERRAIN_ID);
TaintedUpdateParameter(parm, objectIDs, val); TaintedUpdateParameter(parm, objectIDs, val);
break; break;
case PhysParameterEntry.APPLY_TO_ALL: case PhysParameterEntry.APPLY_TO_ALL:
setDefault(val); // setting ALL also sets the default value
lock (PhysObjects) objectIDs = new List<uint>(PhysObjects.Keys); lock (PhysObjects) objectIDs = new List<uint>(PhysObjects.Keys);
TaintedUpdateParameter(parm, objectIDs, val); TaintedUpdateParameter(parm, objectIDs, val);
break; break;
@ -917,6 +912,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
} }
} }
ret = true;
}
return ret;
}
// schedule the actual updating of the paramter to when the phys engine is not busy // schedule the actual updating of the paramter to when the phys engine is not busy
private void TaintedUpdateParameter(string parm, List<uint> lIDs, float val) private void TaintedUpdateParameter(string parm, List<uint> lIDs, float val)
{ {

View File

@ -96,7 +96,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
{ {
// DISASTER!! // DISASTER!!
PhysicsScene.DetailLog("{0},BSTerrainMesh.create,failedCreationOfShape", ID); PhysicsScene.DetailLog("{0},BSTerrainMesh.create,failedCreationOfShape", ID);
physicsScene.Logger.ErrorFormat("{0} Failed creation of terrain mesh! base={1}", LogHeader, TerrainBase); PhysicsScene.Logger.ErrorFormat("{0} Failed creation of terrain mesh! base={1}", LogHeader, TerrainBase);
// Something is very messed up and a crash is in our future. // Something is very messed up and a crash is in our future.
return; return;
} }
@ -108,7 +108,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
if (!m_terrainBody.HasPhysicalBody) if (!m_terrainBody.HasPhysicalBody)
{ {
// DISASTER!! // DISASTER!!
physicsScene.Logger.ErrorFormat("{0} Failed creation of terrain body! base={1}", LogHeader, TerrainBase); PhysicsScene.Logger.ErrorFormat("{0} Failed creation of terrain body! base={1}", LogHeader, TerrainBase);
// Something is very messed up and a crash is in our future. // Something is very messed up and a crash is in our future.
return; return;
} }
@ -131,6 +131,12 @@ public sealed class BSTerrainMesh : BSTerrainPhys
m_terrainBody.collisionType = CollisionType.Terrain; m_terrainBody.collisionType = CollisionType.Terrain;
m_terrainBody.ApplyCollisionMask(PhysicsScene); m_terrainBody.ApplyCollisionMask(PhysicsScene);
if (BSParam.UseSingleSidedMeshes)
{
PhysicsScene.DetailLog("{0},BSTerrainMesh.settingCustomMaterial", id);
PhysicsScene.PE.AddToCollisionFlags(m_terrainBody, CollisionFlags.CF_CUSTOM_MATERIAL_CALLBACK);
}
// Make it so the terrain will not move or be considered for movement. // Make it so the terrain will not move or be considered for movement.
PhysicsScene.PE.ForceActivationState(m_terrainBody, ActivationState.DISABLE_SIMULATION); PhysicsScene.PE.ForceActivationState(m_terrainBody, ActivationState.DISABLE_SIMULATION);
} }
@ -176,8 +182,7 @@ public sealed class BSTerrainMesh : BSTerrainPhys
// Convert the passed heightmap to mesh information suitable for CreateMeshShape2(). // Convert the passed heightmap to mesh information suitable for CreateMeshShape2().
// Return 'true' if successfully created. // Return 'true' if successfully created.
public static bool ConvertHeightmapToMesh( public static bool ConvertHeightmapToMesh( BSScene physicsScene,
BSScene physicsScene,
float[] heightMap, int sizeX, int sizeY, // parameters of incoming heightmap float[] heightMap, int sizeX, int sizeY, // parameters of incoming heightmap
float extentX, float extentY, // zero based range for output vertices float extentX, float extentY, // zero based range for output vertices
Vector3 extentBase, // base to be added to all vertices Vector3 extentBase, // base to be added to all vertices

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.