update UbitOde
parent
99bb3ccb3d
commit
01fcd400d7
|
@ -158,9 +158,10 @@ namespace OpenSim.Region.Physics.Manager
|
|||
|
||||
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; }
|
||||
|
|
|
@ -136,7 +136,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
public UUID m_uuid;
|
||||
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)
|
||||
{
|
||||
|
@ -168,8 +169,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
m_density = density;
|
||||
m_mass = 80f; // sure we have a default
|
||||
|
||||
AvatarContactData.mu = parent_scene.AvatarFriction;
|
||||
AvatarContactData.bounce = parent_scene.AvatarBounce;
|
||||
mu = parent_scene.AvatarFriction;
|
||||
bounce = parent_scene.AvatarBounce;
|
||||
|
||||
walkDivisor = walk_divisor;
|
||||
runDivisor = rundivisor;
|
||||
|
@ -190,9 +191,10 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
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; }
|
||||
|
|
|
@ -119,25 +119,22 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
// auxiliar
|
||||
private float m_lmEfect = 0; // current linear motor eficiency
|
||||
private float m_amEfect = 0; // current angular motor eficiency
|
||||
private float m_ffactor = 1.0f;
|
||||
|
||||
public bool EngineActive
|
||||
public float FrictionFactor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_lmEfect > 0.01)
|
||||
return true;
|
||||
return false;
|
||||
return m_ffactor;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ODEDynamics(OdePrim rootp)
|
||||
{
|
||||
rootPrim = rootp;
|
||||
_pParentScene = rootPrim._parent_scene;
|
||||
}
|
||||
|
||||
|
||||
public void DoSetVehicle(VehicleData vd)
|
||||
{
|
||||
|
||||
|
@ -212,6 +209,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
m_lmEfect = 0;
|
||||
m_amEfect = 0;
|
||||
m_ffactor = 1.0f;
|
||||
}
|
||||
|
||||
internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
|
||||
|
@ -329,6 +327,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
if (len > 30.0f)
|
||||
m_linearMotorDirection *= (30.0f / len);
|
||||
m_lmEfect = 1.0f; // turn it on
|
||||
m_ffactor = 0.01f;
|
||||
if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
|
||||
&& !rootPrim.m_isSelected && !rootPrim.m_disabled)
|
||||
d.BodyEnable(rootPrim.Body);
|
||||
|
@ -379,6 +378,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
if (len > 30.0f)
|
||||
m_linearMotorDirection *= (30.0f / len);
|
||||
m_lmEfect = 1.0f; // turn it on
|
||||
m_ffactor = 0.01f;
|
||||
if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
|
||||
&& !rootPrim.m_isSelected && !rootPrim.m_disabled)
|
||||
d.BodyEnable(rootPrim.Body);
|
||||
|
@ -425,6 +425,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
float invtimestep = _pParentScene.ODE_STEPSIZE;
|
||||
m_lmEfect = 0;
|
||||
m_amEfect = 0;
|
||||
m_ffactor = 1f;
|
||||
|
||||
m_linearMotorDirection = Vector3.Zero;
|
||||
m_angularMotorDirection = Vector3.Zero;
|
||||
|
@ -602,6 +603,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
{
|
||||
m_lmEfect = 0;
|
||||
m_amEfect = 0;
|
||||
m_ffactor = 1f;
|
||||
}
|
||||
|
||||
public static Vector3 Xrot(Quaternion rot)
|
||||
|
@ -752,9 +754,14 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
force.Z += tmpV.Z;
|
||||
}
|
||||
m_lmEfect *= (1.0f - 1.0f / m_linearMotorDecayTimescale);
|
||||
|
||||
m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lmEfect = 0;
|
||||
m_ffactor = 1f;
|
||||
}
|
||||
|
||||
// friction
|
||||
if (curLocalVel.X != 0 || curLocalVel.Y != 0 || curLocalVel.Z != 0)
|
||||
|
|
|
@ -187,7 +187,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
public ODEDynamics m_vehicle;
|
||||
|
||||
internal int m_material = (int)Material.Wood;
|
||||
protected ContactData primContactData = new ContactData { mu = 0f, bounce = 0.1f };
|
||||
private float mu;
|
||||
private float bounce;
|
||||
|
||||
/// <summary>
|
||||
/// Is this prim subject to physics? Even if not, it's still solid for collision purposes.
|
||||
|
@ -218,23 +219,21 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
}
|
||||
|
||||
public override ContactData ContactData
|
||||
public override void getContactData(ref ContactData cdata)
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_isphysical)
|
||||
{
|
||||
ODEDynamics veh;
|
||||
if (_parent != null)
|
||||
veh = ((OdePrim)_parent).m_vehicle;
|
||||
else
|
||||
veh = m_vehicle;
|
||||
cdata.mu = mu;
|
||||
cdata.bounce = bounce;
|
||||
|
||||
if (veh != null)
|
||||
if (veh.Type != Vehicle.TYPE_NONE && veh.EngineActive)
|
||||
return new ContactData(0, 0);
|
||||
}
|
||||
return primContactData;
|
||||
if (m_isphysical)
|
||||
{
|
||||
ODEDynamics veh;
|
||||
if (_parent != null)
|
||||
veh = ((OdePrim)_parent).m_vehicle;
|
||||
else
|
||||
veh = m_vehicle;
|
||||
|
||||
if (veh != null && veh.Type != Vehicle.TYPE_NONE)
|
||||
cdata.mu *= veh.FrictionFactor;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -745,8 +744,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
public override void SetMaterial(int pMaterial)
|
||||
{
|
||||
m_material = pMaterial;
|
||||
primContactData.mu = _parent_scene.m_materialContactsData[pMaterial].mu;
|
||||
primContactData.bounce = _parent_scene.m_materialContactsData[pMaterial].bounce;
|
||||
mu = _parent_scene.m_materialContactsData[pMaterial].mu;
|
||||
bounce = _parent_scene.m_materialContactsData[pMaterial].bounce;
|
||||
}
|
||||
|
||||
public void setPrimForRemoval()
|
||||
|
@ -899,8 +898,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
m_isSelected = false;
|
||||
m_delaySelect = false;
|
||||
|
||||
primContactData.mu = parent_scene.m_materialContactsData[(int)Material.Wood].mu;
|
||||
primContactData.bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce;
|
||||
mu = parent_scene.m_materialContactsData[(int)Material.Wood].mu;
|
||||
bounce = parent_scene.m_materialContactsData[(int)Material.Wood].bounce;
|
||||
|
||||
CalcPrimBodyData();
|
||||
|
||||
|
|
|
@ -163,8 +163,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
const float comumSoftContactERP = 0.1f;
|
||||
const float comumContactCFM = 0.0001f;
|
||||
|
||||
float frictionScale = 1.0f;
|
||||
|
||||
float frictionMovementMult = 0.3f;
|
||||
|
||||
float TerrainBounce = 0.1f;
|
||||
|
@ -450,33 +448,30 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.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.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.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.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.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.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.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.light].mu = 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)
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -580,7 +568,13 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
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)
|
||||
{
|
||||
|
@ -699,8 +693,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
// big messy collision analises
|
||||
float mu = 0;
|
||||
float bounce = 0;
|
||||
ContactData contactdata1;
|
||||
ContactData contactdata2;
|
||||
ContactData contactdata1 = new ContactData(0, 0);
|
||||
ContactData contactdata2 = new ContactData(0, 0);
|
||||
bool erpSoft = false;
|
||||
|
||||
String name = null;
|
||||
|
@ -714,8 +708,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
switch (p2.PhysicsActorType)
|
||||
{
|
||||
case (int)ActorTypes.Agent:
|
||||
contactdata1 = p1.ContactData;
|
||||
contactdata2 = p2.ContactData;
|
||||
p1.getContactData(ref contactdata1);
|
||||
p2.getContactData(ref contactdata2);
|
||||
|
||||
bounce = contactdata1.bounce * contactdata2.bounce;
|
||||
|
||||
mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
|
||||
|
@ -727,8 +722,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
p2.CollidingObj = true;
|
||||
break;
|
||||
case (int)ActorTypes.Prim:
|
||||
contactdata1 = p1.ContactData;
|
||||
contactdata2 = p2.ContactData;
|
||||
p1.getContactData(ref contactdata1);
|
||||
p2.getContactData(ref contactdata2);
|
||||
bounce = contactdata1.bounce * contactdata2.bounce;
|
||||
|
||||
mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
|
||||
|
@ -749,8 +744,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
switch (p2.PhysicsActorType)
|
||||
{
|
||||
case (int)ActorTypes.Agent:
|
||||
contactdata1 = p1.ContactData;
|
||||
contactdata2 = p2.ContactData;
|
||||
p1.getContactData(ref contactdata1);
|
||||
p2.getContactData(ref contactdata2);
|
||||
bounce = contactdata1.bounce * contactdata2.bounce;
|
||||
|
||||
mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
|
||||
|
@ -768,8 +763,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
p1.CollidingObj = true;
|
||||
p2.CollidingObj = true;
|
||||
}
|
||||
contactdata1 = p1.ContactData;
|
||||
contactdata2 = p2.ContactData;
|
||||
p1.getContactData(ref contactdata1);
|
||||
p2.getContactData(ref contactdata2);
|
||||
bounce = contactdata1.bounce * contactdata2.bounce;
|
||||
erpSoft = true;
|
||||
mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu);
|
||||
|
@ -784,7 +779,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
if (name == "Terrain")
|
||||
{
|
||||
erpSoft = true;
|
||||
contactdata1 = p1.ContactData;
|
||||
p1.getContactData(ref contactdata1);
|
||||
bounce = contactdata1.bounce * TerrainBounce;
|
||||
mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction);
|
||||
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;
|
||||
p2.CollidingGround = true;
|
||||
contactdata2 = p2.ContactData;
|
||||
p2.getContactData(ref contactdata2);
|
||||
bounce = contactdata2.bounce * TerrainBounce;
|
||||
mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction);
|
||||
|
||||
|
|
Loading…
Reference in New Issue