BulletSim: adjust friction and restitution based on material type.
parent
af8d53657d
commit
ce5083a504
|
@ -60,6 +60,9 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
Linkset = BSLinkset.Factory(PhysicsScene, this);
|
Linkset = BSLinkset.Factory(PhysicsScene, this);
|
||||||
LastAssetBuildFailed = false;
|
LastAssetBuildFailed = false;
|
||||||
|
|
||||||
|
// Default material type
|
||||||
|
Material = MaterialAttributes.Material.Wood;
|
||||||
|
|
||||||
CollisionCollection = new CollisionEventUpdate();
|
CollisionCollection = new CollisionEventUpdate();
|
||||||
SubscribedEventsMs = 0;
|
SubscribedEventsMs = 0;
|
||||||
CollidingStep = 0;
|
CollidingStep = 0;
|
||||||
|
@ -109,6 +112,13 @@ public abstract class BSPhysObject : PhysicsActor
|
||||||
public abstract bool IsSolid { get; }
|
public abstract bool IsSolid { get; }
|
||||||
public abstract bool IsStatic { get; }
|
public abstract bool IsStatic { get; }
|
||||||
|
|
||||||
|
// Materialness
|
||||||
|
public MaterialAttributes.Material Material { get; private set; }
|
||||||
|
public override void SetMaterial(int material)
|
||||||
|
{
|
||||||
|
Material = (MaterialAttributes.Material)material;
|
||||||
|
}
|
||||||
|
|
||||||
// Stop all physical motion.
|
// Stop all physical motion.
|
||||||
public abstract void ZeroMotion(bool inTaintTime);
|
public abstract void ZeroMotion(bool inTaintTime);
|
||||||
public abstract void ZeroAngularMotion(bool inTaintTime);
|
public abstract void ZeroAngularMotion(bool inTaintTime);
|
||||||
|
|
|
@ -683,8 +683,9 @@ public sealed class BSPrim : BSPhysObject
|
||||||
ZeroMotion(true);
|
ZeroMotion(true);
|
||||||
|
|
||||||
// Set various physical properties so other object interact properly
|
// Set various physical properties so other object interact properly
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, PhysicsScene.Params.defaultFriction);
|
MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false);
|
||||||
BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.defaultRestitution);
|
BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction);
|
||||||
|
BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution);
|
||||||
|
|
||||||
// Mass is zero which disables a bunch of physics stuff in Bullet
|
// Mass is zero which disables a bunch of physics stuff in Bullet
|
||||||
UpdatePhysicalMassProperties(0f);
|
UpdatePhysicalMassProperties(0f);
|
||||||
|
@ -711,9 +712,10 @@ public sealed class BSPrim : BSPhysObject
|
||||||
// Not a Bullet static object
|
// Not a Bullet static object
|
||||||
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT);
|
CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT);
|
||||||
|
|
||||||
// Set various physical properties so internal dynamic properties will get computed correctly as they are set
|
// Set various physical properties so other object interact properly
|
||||||
BulletSimAPI.SetFriction2(PhysBody.ptr, PhysicsScene.Params.defaultFriction);
|
MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true);
|
||||||
BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.defaultRestitution);
|
BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction);
|
||||||
|
BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution);
|
||||||
|
|
||||||
// per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382
|
// per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382
|
||||||
// Since this can be called multiple times, only zero forces when becoming physical
|
// Since this can be called multiple times, only zero forces when becoming physical
|
||||||
|
|
Loading…
Reference in New Issue