update UbitOde

avinationmerge
UbitUmarov 2012-03-04 04:26:05 +00:00
parent 99bb3ccb3d
commit 01fcd400d7
5 changed files with 70 additions and 66 deletions

View File

@ -158,9 +158,10 @@ namespace OpenSim.Region.Physics.Manager
public virtual bool Building { get; set; } public virtual bool Building { get; set; }
public virtual ContactData ContactData public virtual void getContactData(ref ContactData cdata)
{ {
get { return new ContactData(0, 0); } cdata.mu = 0;
cdata.bounce = 0;
} }
public abstract bool Stopped { get; } public abstract bool Stopped { get; }

View File

@ -136,7 +136,8 @@ namespace OpenSim.Region.Physics.OdePlugin
public UUID m_uuid; public UUID m_uuid;
public bool bad = false; public bool bad = false;
public ContactData AvatarContactData = new ContactData(10f, 0.3f); float mu;
float bounce;
public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float density, float walk_divisor, float rundivisor) public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 size, float pid_d, float pid_p, float capsule_radius, float density, float walk_divisor, float rundivisor)
{ {
@ -168,8 +169,8 @@ namespace OpenSim.Region.Physics.OdePlugin
m_density = density; m_density = density;
m_mass = 80f; // sure we have a default m_mass = 80f; // sure we have a default
AvatarContactData.mu = parent_scene.AvatarFriction; mu = parent_scene.AvatarFriction;
AvatarContactData.bounce = parent_scene.AvatarBounce; bounce = parent_scene.AvatarBounce;
walkDivisor = walk_divisor; walkDivisor = walk_divisor;
runDivisor = rundivisor; runDivisor = rundivisor;
@ -190,9 +191,10 @@ namespace OpenSim.Region.Physics.OdePlugin
set { return; } set { return; }
} }
public override ContactData ContactData public override void getContactData(ref ContactData cdata)
{ {
get { return AvatarContactData; } cdata.mu = mu;
cdata.bounce = bounce;
} }
public override bool Building { get; set; } public override bool Building { get; set; }

View File

@ -119,25 +119,22 @@ namespace OpenSim.Region.Physics.OdePlugin
// auxiliar // auxiliar
private float m_lmEfect = 0; // current linear motor eficiency private float m_lmEfect = 0; // current linear motor eficiency
private float m_amEfect = 0; // current angular motor eficiency private float m_amEfect = 0; // current angular motor eficiency
private float m_ffactor = 1.0f;
public bool EngineActive public float FrictionFactor
{ {
get get
{ {
if (m_lmEfect > 0.01) return m_ffactor;
return true;
return false;
} }
} }
public ODEDynamics(OdePrim rootp) public ODEDynamics(OdePrim rootp)
{ {
rootPrim = rootp; rootPrim = rootp;
_pParentScene = rootPrim._parent_scene; _pParentScene = rootPrim._parent_scene;
} }
public void DoSetVehicle(VehicleData vd) public void DoSetVehicle(VehicleData vd)
{ {
@ -212,6 +209,7 @@ namespace OpenSim.Region.Physics.OdePlugin
m_lmEfect = 0; m_lmEfect = 0;
m_amEfect = 0; m_amEfect = 0;
m_ffactor = 1.0f;
} }
internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
@ -329,6 +327,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (len > 30.0f) if (len > 30.0f)
m_linearMotorDirection *= (30.0f / len); m_linearMotorDirection *= (30.0f / len);
m_lmEfect = 1.0f; // turn it on m_lmEfect = 1.0f; // turn it on
m_ffactor = 0.01f;
if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
&& !rootPrim.m_isSelected && !rootPrim.m_disabled) && !rootPrim.m_isSelected && !rootPrim.m_disabled)
d.BodyEnable(rootPrim.Body); d.BodyEnable(rootPrim.Body);
@ -379,6 +378,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (len > 30.0f) if (len > 30.0f)
m_linearMotorDirection *= (30.0f / len); m_linearMotorDirection *= (30.0f / len);
m_lmEfect = 1.0f; // turn it on m_lmEfect = 1.0f; // turn it on
m_ffactor = 0.01f;
if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
&& !rootPrim.m_isSelected && !rootPrim.m_disabled) && !rootPrim.m_isSelected && !rootPrim.m_disabled)
d.BodyEnable(rootPrim.Body); d.BodyEnable(rootPrim.Body);
@ -425,6 +425,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float invtimestep = _pParentScene.ODE_STEPSIZE; float invtimestep = _pParentScene.ODE_STEPSIZE;
m_lmEfect = 0; m_lmEfect = 0;
m_amEfect = 0; m_amEfect = 0;
m_ffactor = 1f;
m_linearMotorDirection = Vector3.Zero; m_linearMotorDirection = Vector3.Zero;
m_angularMotorDirection = Vector3.Zero; m_angularMotorDirection = Vector3.Zero;
@ -602,6 +603,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
m_lmEfect = 0; m_lmEfect = 0;
m_amEfect = 0; m_amEfect = 0;
m_ffactor = 1f;
} }
public static Vector3 Xrot(Quaternion rot) public static Vector3 Xrot(Quaternion rot)
@ -752,9 +754,14 @@ namespace OpenSim.Region.Physics.OdePlugin
force.Z += tmpV.Z; force.Z += tmpV.Z;
} }
m_lmEfect *= (1.0f - 1.0f / m_linearMotorDecayTimescale); m_lmEfect *= (1.0f - 1.0f / m_linearMotorDecayTimescale);
m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared();
} }
else else
{
m_lmEfect = 0; m_lmEfect = 0;
m_ffactor = 1f;
}
// friction // friction
if (curLocalVel.X != 0 || curLocalVel.Y != 0 || curLocalVel.Z != 0) if (curLocalVel.X != 0 || curLocalVel.Y != 0 || curLocalVel.Z != 0)

View File

@ -187,7 +187,8 @@ namespace OpenSim.Region.Physics.OdePlugin
public ODEDynamics m_vehicle; public ODEDynamics m_vehicle;
internal int m_material = (int)Material.Wood; internal int m_material = (int)Material.Wood;
protected ContactData primContactData = new ContactData { mu = 0f, bounce = 0.1f }; private float mu;
private float bounce;
/// <summary> /// <summary>
/// Is this prim subject to physics? Even if not, it's still solid for collision purposes. /// Is this prim subject to physics? Even if not, it's still solid for collision purposes.
@ -218,25 +219,23 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override ContactData ContactData public override void getContactData(ref ContactData cdata)
{ {
get cdata.mu = mu;
{ cdata.bounce = bounce;
if (m_isphysical)
{
ODEDynamics veh;
if (_parent != null)
veh = ((OdePrim)_parent).m_vehicle;
else
veh = m_vehicle;
if (veh != null) if (m_isphysical)
if (veh.Type != Vehicle.TYPE_NONE && veh.EngineActive) {
return new ContactData(0, 0); ODEDynamics veh;
} if (_parent != null)
return primContactData; veh = ((OdePrim)_parent).m_vehicle;
else
veh = m_vehicle;
if (veh != null && veh.Type != Vehicle.TYPE_NONE)
cdata.mu *= veh.FrictionFactor;
} }
} }
public override int PhysicsActorType public override int PhysicsActorType
{ {
@ -745,8 +744,8 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void SetMaterial(int pMaterial) public override void SetMaterial(int pMaterial)
{ {
m_material = pMaterial; m_material = pMaterial;
primContactData.mu = _parent_scene.m_materialContactsData[pMaterial].mu; mu = _parent_scene.m_materialContactsData[pMaterial].mu;
primContactData.bounce = _parent_scene.m_materialContactsData[pMaterial].bounce; bounce = _parent_scene.m_materialContactsData[pMaterial].bounce;
} }
public void setPrimForRemoval() public void setPrimForRemoval()
@ -899,8 +898,8 @@ namespace OpenSim.Region.Physics.OdePlugin
m_isSelected = false; m_isSelected = false;
m_delaySelect = false; m_delaySelect = false;
primContactData.mu = parent_scene.m_materialContactsData[(int)Material.Wood].mu; mu = parent_scene.m_materialContactsData[(int)Material.Wood].mu;
primContactData.bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce; bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce;
CalcPrimBodyData(); CalcPrimBodyData();

View File

@ -163,8 +163,6 @@ namespace OpenSim.Region.Physics.OdePlugin
const float comumSoftContactERP = 0.1f; const float comumSoftContactERP = 0.1f;
const float comumContactCFM = 0.0001f; const float comumContactCFM = 0.0001f;
float frictionScale = 1.0f;
float frictionMovementMult = 0.3f; float frictionMovementMult = 0.3f;
float TerrainBounce = 0.1f; float TerrainBounce = 0.1f;
@ -450,33 +448,30 @@ namespace OpenSim.Region.Physics.OdePlugin
ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf);
GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf);
m_materialContactsData[(int)Material.Stone].mu = frictionScale * 0.8f; m_materialContactsData[(int)Material.Stone].mu = 0.8f;
m_materialContactsData[(int)Material.Stone].bounce = 0.4f; m_materialContactsData[(int)Material.Stone].bounce = 0.4f;
m_materialContactsData[(int)Material.Metal].mu = frictionScale * 0.3f; m_materialContactsData[(int)Material.Metal].mu = 0.3f;
m_materialContactsData[(int)Material.Metal].bounce = 0.4f; m_materialContactsData[(int)Material.Metal].bounce = 0.4f;
m_materialContactsData[(int)Material.Glass].mu = frictionScale * 0.2f; m_materialContactsData[(int)Material.Glass].mu = 0.2f;
m_materialContactsData[(int)Material.Glass].bounce = 0.7f; m_materialContactsData[(int)Material.Glass].bounce = 0.7f;
m_materialContactsData[(int)Material.Wood].mu = frictionScale * 0.6f; m_materialContactsData[(int)Material.Wood].mu = 0.6f;
m_materialContactsData[(int)Material.Wood].bounce = 0.5f; m_materialContactsData[(int)Material.Wood].bounce = 0.5f;
m_materialContactsData[(int)Material.Flesh].mu = frictionScale * 0.9f; m_materialContactsData[(int)Material.Flesh].mu = 0.9f;
m_materialContactsData[(int)Material.Flesh].bounce = 0.3f; m_materialContactsData[(int)Material.Flesh].bounce = 0.3f;
m_materialContactsData[(int)Material.Plastic].mu = frictionScale * 0.4f; m_materialContactsData[(int)Material.Plastic].mu = 0.4f;
m_materialContactsData[(int)Material.Plastic].bounce = 0.7f; m_materialContactsData[(int)Material.Plastic].bounce = 0.7f;
m_materialContactsData[(int)Material.Rubber].mu = frictionScale * 0.9f; m_materialContactsData[(int)Material.Rubber].mu = 0.9f;
m_materialContactsData[(int)Material.Rubber].bounce = 0.95f; m_materialContactsData[(int)Material.Rubber].bounce = 0.95f;
m_materialContactsData[(int)Material.light].mu = 0.0f; m_materialContactsData[(int)Material.light].mu = 0.0f;
m_materialContactsData[(int)Material.light].bounce = 0.0f; m_materialContactsData[(int)Material.light].bounce = 0.0f;
TerrainFriction *= frictionScale;
// AvatarFriction *= frictionScale;
// Set the gravity,, don't disable things automatically (we set it explicitly on some things) // Set the gravity,, don't disable things automatically (we set it explicitly on some things)
d.WorldSetGravity(world, gravityx, gravityy, gravityz); d.WorldSetGravity(world, gravityx, gravityy, gravityz);
@ -562,13 +557,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
/// <summary>
/// This is our near callback. A geometry is near a body
/// </summary>
/// <param name="space">The space that contains the geoms. Remember, spaces are also geoms</param>
/// <param name="g1">a geometry or space</param>
/// <param name="g2">another geometry or space</param>
///
private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom) private bool GetCurContactGeom(int index, ref d.ContactGeom newcontactgeom)
{ {
@ -580,7 +568,13 @@ namespace OpenSim.Region.Physics.OdePlugin
return true; return true;
} }
/// <summary>
/// This is our near callback. A geometry is near a body
/// </summary>
/// <param name="space">The space that contains the geoms. Remember, spaces are also geoms</param>
/// <param name="g1">a geometry or space</param>
/// <param name="g2">another geometry or space</param>
///
private void near(IntPtr space, IntPtr g1, IntPtr g2) private void near(IntPtr space, IntPtr g1, IntPtr g2)
{ {
@ -699,8 +693,8 @@ namespace OpenSim.Region.Physics.OdePlugin
// big messy collision analises // big messy collision analises
float mu = 0; float mu = 0;
float bounce = 0; float bounce = 0;
ContactData contactdata1; ContactData contactdata1 = new ContactData(0, 0);
ContactData contactdata2; ContactData contactdata2 = new ContactData(0, 0);
bool erpSoft = false; bool erpSoft = false;
String name = null; String name = null;
@ -714,8 +708,9 @@ namespace OpenSim.Region.Physics.OdePlugin
switch (p2.PhysicsActorType) switch (p2.PhysicsActorType)
{ {
case (int)ActorTypes.Agent: case (int)ActorTypes.Agent:
contactdata1 = p1.ContactData; p1.getContactData(ref contactdata1);
contactdata2 = p2.ContactData; p2.getContactData(ref contactdata2);
bounce = contactdata1.bounce * contactdata2.bounce; bounce = contactdata1.bounce * contactdata2.bounce;
mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
@ -727,8 +722,8 @@ namespace OpenSim.Region.Physics.OdePlugin
p2.CollidingObj = true; p2.CollidingObj = true;
break; break;
case (int)ActorTypes.Prim: case (int)ActorTypes.Prim:
contactdata1 = p1.ContactData; p1.getContactData(ref contactdata1);
contactdata2 = p2.ContactData; p2.getContactData(ref contactdata2);
bounce = contactdata1.bounce * contactdata2.bounce; bounce = contactdata1.bounce * contactdata2.bounce;
mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
@ -749,8 +744,8 @@ namespace OpenSim.Region.Physics.OdePlugin
switch (p2.PhysicsActorType) switch (p2.PhysicsActorType)
{ {
case (int)ActorTypes.Agent: case (int)ActorTypes.Agent:
contactdata1 = p1.ContactData; p1.getContactData(ref contactdata1);
contactdata2 = p2.ContactData; p2.getContactData(ref contactdata2);
bounce = contactdata1.bounce * contactdata2.bounce; bounce = contactdata1.bounce * contactdata2.bounce;
mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
@ -768,8 +763,8 @@ namespace OpenSim.Region.Physics.OdePlugin
p1.CollidingObj = true; p1.CollidingObj = true;
p2.CollidingObj = true; p2.CollidingObj = true;
} }
contactdata1 = p1.ContactData; p1.getContactData(ref contactdata1);
contactdata2 = p2.ContactData; p2.getContactData(ref contactdata2);
bounce = contactdata1.bounce * contactdata2.bounce; bounce = contactdata1.bounce * contactdata2.bounce;
erpSoft = true; erpSoft = true;
mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
@ -784,7 +779,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (name == "Terrain") if (name == "Terrain")
{ {
erpSoft = true; erpSoft = true;
contactdata1 = p1.ContactData; p1.getContactData(ref contactdata1);
bounce = contactdata1.bounce * TerrainBounce; bounce = contactdata1.bounce * TerrainBounce;
mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction);
if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f)
@ -811,7 +806,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
erpSoft = true; erpSoft = true;
p2.CollidingGround = true; p2.CollidingGround = true;
contactdata2 = p2.ContactData; p2.getContactData(ref contactdata2);
bounce = contactdata2.bounce * TerrainBounce; bounce = contactdata2.bounce * TerrainBounce;
mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction); mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction);