diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index f6a890e7bf..b05d4eeb9e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -60,6 +60,9 @@ public abstract class BSPhysObject : PhysicsActor Linkset = BSLinkset.Factory(PhysicsScene, this); LastAssetBuildFailed = false; + // Default material type + Material = MaterialAttributes.Material.Wood; + CollisionCollection = new CollisionEventUpdate(); SubscribedEventsMs = 0; CollidingStep = 0; @@ -109,6 +112,13 @@ public abstract class BSPhysObject : PhysicsActor public abstract bool IsSolid { 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. public abstract void ZeroMotion(bool inTaintTime); public abstract void ZeroAngularMotion(bool inTaintTime); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 4d203ffc48..627393a982 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -683,8 +683,9 @@ public sealed class BSPrim : BSPhysObject ZeroMotion(true); // Set various physical properties so other object interact properly - BulletSimAPI.SetFriction2(PhysBody.ptr, PhysicsScene.Params.defaultFriction); - BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.defaultRestitution); + MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false); + BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction); + BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution); // Mass is zero which disables a bunch of physics stuff in Bullet UpdatePhysicalMassProperties(0f); @@ -711,9 +712,10 @@ public sealed class BSPrim : BSPhysObject // Not a Bullet 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 - BulletSimAPI.SetFriction2(PhysBody.ptr, PhysicsScene.Params.defaultFriction); - BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.defaultRestitution); + // Set various physical properties so other object interact properly + MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, true); + BulletSimAPI.SetFriction2(PhysBody.ptr, matAttrib.friction); + BulletSimAPI.SetRestitution2(PhysBody.ptr, matAttrib.restitution); // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 // Since this can be called multiple times, only zero forces when becoming physical