From cb2727cf6e7b40473d10cfbea61155f5bcf6646f Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 18 Mar 2012 11:53:53 -0700 Subject: [PATCH] BulletSim: Add AvatarRestitution parameter. Centralize computation of buoyancy for flying. Tweek avatar default friction and resititution --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 9 ++++++--- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 3 +++ bin/OpenSimDefaults.ini | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index e816b61e22..1a61431d59 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -94,7 +94,7 @@ public class BSCharacter : PhysicsActor _flying = isFlying; _orientation = Quaternion.Identity; _velocity = Vector3.Zero; - _buoyancy = isFlying ? 1f : 0f; + _buoyancy = ComputeBuoyancyFromFlying(isFlying); _scale = new Vector3(1f, 1f, 1f); _density = _scene.Params.avatarDensity; ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale @@ -110,7 +110,7 @@ public class BSCharacter : PhysicsActor shapeData.Buoyancy = _buoyancy; shapeData.Static = ShapeData.numericFalse; shapeData.Friction = _scene.Params.avatarFriction; - shapeData.Restitution = _scene.Params.defaultRestitution; + shapeData.Restitution = _scene.Params.avatarRestitution; // do actual create at taint time _scene.TaintedObject(delegate() @@ -261,9 +261,12 @@ public class BSCharacter : PhysicsActor set { _flying = value; // simulate flying by changing the effect of gravity - this.Buoyancy(_flying ? 1f : 0f); + this.Buoyancy(ComputeBuoyancyFromFlying(_flying)); } } + private float ComputeBuoyancyFromFlying(bool ifFlying) { + return ifFlying ? 1f : 0f; + } public override bool SetAlwaysRun { get { return _setAlwaysRun; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 977dcbeb4b..9b12b4f277 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -235,6 +235,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.terrainHitFraction = 0.8f; parms.terrainRestitution = 0f; parms.avatarFriction = 0.5f; + parms.avatarRestitution = 0.0f; parms.avatarDensity = 60f; parms.avatarCapsuleRadius = 0.37f; parms.avatarCapsuleHeight = 1.5f; // 2.140599f @@ -279,7 +280,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.terrainHitFraction = pConfig.GetFloat("TerrainHitFraction", parms.terrainHitFraction); parms.terrainRestitution = pConfig.GetFloat("TerrainRestitution", parms.terrainRestitution); parms.avatarFriction = pConfig.GetFloat("AvatarFriction", parms.avatarFriction); + parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution); parms.avatarDensity = pConfig.GetFloat("AvatarDensity", parms.avatarDensity); + parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution); parms.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", parms.avatarCapsuleRadius); parms.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", parms.avatarCapsuleHeight); } diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index d291cfb929..2f4a549f1b 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -833,7 +833,8 @@ TerrainFriction = 0.50 TerrainHitFriction = 0.8 TerrainRestitution = 0 - AvatarFriction = 0.5 + AvatarFriction = 0.2 + AvatarRestitution = 0.0 AvatarDensity = 60.0 AvatarCapsuleRadius = 0.37 AvatarCapsuleHeight = 1.5