let gravity modifier, friction, restitution and density changes be applied

to prim. Only have efect on root prim. Density doesn't get effect
imediatly, only on next change of size or shape. density change
implies a full body rebuild to be done later, after reducing the  number
of sets sop does. Other parameters should work. **** mainly untested ***
avinationmerge
UbitUmarov 2013-05-29 06:32:26 +01:00
parent 1cf24b7092
commit 269febc87e
2 changed files with 65 additions and 6 deletions

View File

@ -137,6 +137,7 @@ namespace OpenSim.Region.Physics.OdePlugin
float m_amdampY; float m_amdampY;
float m_amdampZ; float m_amdampZ;
float m_gravmod;
public float FrictionFactor public float FrictionFactor
{ {
@ -146,6 +147,14 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public float GravMod
{
set
{
m_gravmod = value;
}
}
public ODEDynamics(OdePrim rootp) public ODEDynamics(OdePrim rootp)
{ {
@ -153,6 +162,7 @@ namespace OpenSim.Region.Physics.OdePlugin
_pParentScene = rootPrim._parent_scene; _pParentScene = rootPrim._parent_scene;
m_timestep = _pParentScene.ODE_STEPSIZE; m_timestep = _pParentScene.ODE_STEPSIZE;
m_invtimestep = 1.0f / m_timestep; m_invtimestep = 1.0f / m_timestep;
m_gravmod = rootPrim.GravModifier;
} }
public void DoSetVehicle(VehicleData vd) public void DoSetVehicle(VehicleData vd)
@ -862,7 +872,7 @@ namespace OpenSim.Region.Physics.OdePlugin
force.Z += perr; force.Z += perr;
ldampZ *= -curVel.Z; ldampZ *= -curVel.Z;
force.Z += _pParentScene.gravityz * (1f - m_VehicleBuoyancy); force.Z += _pParentScene.gravityz * m_gravmod * (1f - m_VehicleBuoyancy);
} }
else // no buoyancy else // no buoyancy
force.Z += _pParentScene.gravityz; force.Z += _pParentScene.gravityz;
@ -870,7 +880,7 @@ namespace OpenSim.Region.Physics.OdePlugin
else else
{ {
// default gravity and Buoyancy // default gravity and Buoyancy
force.Z += _pParentScene.gravityz * (1f - m_VehicleBuoyancy); force.Z += _pParentScene.gravityz * m_gravmod * (1f - m_VehicleBuoyancy);
} }
// linear deflection // linear deflection
@ -1065,7 +1075,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
if (force.X != 0 || force.Y != 0 || force.Z != 0) if (force.X != 0 || force.Y != 0 || force.Z != 0)
{ {
force *= dmass.mass; force *= dmass.mass;

View File

@ -115,6 +115,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private int body_autodisable_frames; private int body_autodisable_frames;
public int bodydisablecontrol; public int bodydisablecontrol;
private float m_gravmod = 1.0f;
// Default we're a Geometry // Default we're a Geometry
@ -914,6 +915,55 @@ namespace OpenSim.Region.Physics.OdePlugin
bounce = _parent_scene.m_materialContactsData[pMaterial].bounce; bounce = _parent_scene.m_materialContactsData[pMaterial].bounce;
} }
public override float Density
{
get
{
return m_density * 100f;
}
set
{
m_density = value / 100f;
// for not prim mass is not updated since this implies full rebuild of body inertia TODO
}
}
public override float GravModifier
{
get
{
return m_gravmod;
}
set
{
m_gravmod = value;
if (m_vehicle != null)
m_vehicle.GravMod = m_gravmod;
}
}
public override float Friction
{
get
{
return mu;
}
set
{
mu = value;
}
}
public override float Restitution
{
get
{
return bounce;
}
set
{
bounce = value;
}
}
public void setPrimForRemoval() public void setPrimForRemoval()
{ {
AddChange(changes.Remove, null); AddChange(changes.Remove, null);
@ -3336,7 +3386,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
{ {
float b = (1.0f - m_buoyancy); float b = (1.0f - m_buoyancy) * m_gravmod;
fx = _parent_scene.gravityx * b; fx = _parent_scene.gravityx * b;
fy = _parent_scene.gravityy * b; fy = _parent_scene.gravityy * b;
fz = _parent_scene.gravityz * b; fz = _parent_scene.gravityz * b;