vehicle changes done by simulation thread and not calling one

avinationmerge
UbitUmarov 2012-02-11 15:18:13 +00:00
parent 3f9c390b4d
commit d4e28ed113
2 changed files with 200 additions and 132 deletions

View File

@ -25,7 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Revision 2011 by Ubit Umarov
/* Revision 2011/12 by Ubit Umarov
*
*
*/
@ -190,7 +190,7 @@ 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};
protected ContactData primContactData = new ContactData { mu = 0f, bounce = 0.1f };
/// <summary>
/// Is this prim subject to physics? Even if not, it's still solid for collision purposes.
@ -225,19 +225,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{
get
{
/*
ODEDynamics v;
if(childPrim && _parent !=null)
{
v =((OdePrim)_parent).m_vehicle;
if(v != null && v.Type != Vehicle.TYPE_NONE)
return v.VehiculeContactData;
return primContactData;
}
if (m_vehicle != null && m_vehicle.Type != Vehicle.TYPE_NONE)
return m_vehicle.VehiculeContactData;
*/
return primContactData;
}
}
@ -276,7 +263,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
set
{
if(value)
if (value)
m_isSelected = value;
AddChange(changes.Selected, value);
}
@ -400,10 +387,9 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
public override void SetVolumeDetect(int param)
{
AddChange(changes.VolumeDtc,(param != 0));
AddChange(changes.VolumeDtc, (param != 0));
}
public override Vector3 GeometricCenter
@ -483,14 +469,6 @@ namespace OpenSim.Region.Physics.OdePlugin
// client object interpolation works a 'little' better
if (_zeroFlag)
return Vector3.Zero;
/*
Vector3 returnVelocity = Vector3.Zero;
returnVelocity.X = (m_lastVelocity.X + _velocity.X) / 2;
returnVelocity.Y = (m_lastVelocity.Y + _velocity.Y) / 2;
returnVelocity.Z = (m_lastVelocity.Z + _velocity.Z) / 2;
return returnVelocity;
*/
return _velocity;
}
set
@ -498,7 +476,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (value.IsFinite())
{
AddChange(changes.Velocity, value);
// _velocity = value;
// _velocity = value;
}
else
@ -548,7 +526,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
get
{
if (givefakeori>0)
if (givefakeori > 0)
return fakeori;
else
@ -652,6 +630,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override int VehicleType
{
// we may need to put a fake on this
get
{
if (m_vehicle == null)
@ -661,44 +640,32 @@ namespace OpenSim.Region.Physics.OdePlugin
}
set
{
if (m_vehicle == null)
{
if (value != (int)Vehicle.TYPE_NONE)
{
m_vehicle = new ODEDynamics(this);
m_vehicle.ProcessTypeChange((Vehicle)value);
}
}
else
m_vehicle.ProcessTypeChange((Vehicle)value);
AddChange(changes.VehicleType, value);
}
}
public override void VehicleFloatParam(int param, float value)
{
if (m_vehicle == null)
return;
m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value);
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
d.BodyEnable(Body);
strVehicleFloatParam fp = new strVehicleFloatParam();
fp.param = param;
fp.value = value;
AddChange(changes.VehicleFloatParam, fp);
}
public override void VehicleVectorParam(int param, Vector3 value)
{
if (m_vehicle == null)
return;
m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value);
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
d.BodyEnable(Body);
strVehicleVectorParam fp = new strVehicleVectorParam();
fp.param = param;
fp.value = value;
AddChange(changes.VehicleVectorParam, fp);
}
public override void VehicleRotationParam(int param, Quaternion rotation)
public override void VehicleRotationParam(int param, Quaternion value)
{
if (m_vehicle == null)
return;
m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation);
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
d.BodyEnable(Body);
strVehicleQuatParam fp = new strVehicleQuatParam();
fp.param = param;
fp.value = value;
AddChange(changes.VehicleVectorParam, fp);
}
public override void VehicleFlags(int param, bool remove)
@ -1023,7 +990,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (_parent != null)
{
OdePrim parent = (OdePrim)_parent;
parent.ChildDelink(this,false);
parent.ChildDelink(this, false);
}
}
else
@ -1093,7 +1060,7 @@ namespace OpenSim.Region.Physics.OdePlugin
_parent_scene.geom_name_map[prim_geom] = Name;
_parent_scene.actor_name_map[prim_geom] = this;
/*
/*
if (childPrim)
{
if (_parent != null && _parent is OdePrim)
@ -1131,7 +1098,7 @@ namespace OpenSim.Region.Physics.OdePlugin
haveMesh = setMesh(_parent_scene); // this will give a mesh to non trivial known prims
}
if(!haveMesh)
if (!haveMesh)
{
if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1
&& _size.X == _size.Y && _size.Y == _size.Z)
@ -1186,7 +1153,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// catch (System.AccessViolationException)
catch (Exception e)
{
m_log.ErrorFormat("[PHYSICS]: PrimGeom destruction failed for {0} exception {1}", Name,e);
m_log.ErrorFormat("[PHYSICS]: PrimGeom destruction failed for {0} exception {1}", Name, e);
}
prim_geom = IntPtr.Zero;
@ -1885,7 +1852,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (prm.prim_geom != IntPtr.Zero)
d.GeomSetBody(prm.prim_geom, IntPtr.Zero);
if(prm.Body != prim.Body)
if (prm.Body != prim.Body)
prm.DestroyBody(); // don't loose bodies around
prm.Body = IntPtr.Zero;
}
@ -2057,12 +2024,12 @@ namespace OpenSim.Region.Physics.OdePlugin
SetInStaticSpace(this);
}
// m_building = false; // REMOVE THIS LATER
// m_building = false; // REMOVE THIS LATER
if (m_isphysical && Body == IntPtr.Zero)
{
/*
/*
if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim)
{
changeShape(_pbs);
@ -2071,7 +2038,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
*/
MakeBody();
// }
// }
}
}
@ -2114,7 +2081,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (NewParent != _parent)
{
(_parent as OdePrim).ChildDelink(this,false); // for now...
(_parent as OdePrim).ChildDelink(this, false); // for now...
childPrim = false;
if (NewParent != null)
@ -2130,7 +2097,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private void Stop()
{
if(!childPrim)
if (!childPrim)
{
m_force = Vector3.Zero;
m_forceacc = Vector3.Zero;
@ -2236,7 +2203,7 @@ namespace OpenSim.Region.Physics.OdePlugin
givefakepos--;
if (givefakepos < 0)
givefakepos = 0;
// changeSelectedStatus();
// changeSelectedStatus();
resetCollisionAccounting();
}
@ -2385,7 +2352,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
if (Body == IntPtr.Zero)
{
/*
/*
if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim)
{
changeShape(_pbs);
@ -2402,7 +2369,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Body != IntPtr.Zero)
{
// UpdateChildsfromgeom();
/* if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim)
/* if (_pbs.SculptEntry && _parent_scene.meshSculptedPrim)
{
changeShape(_pbs);
}
@ -2609,6 +2576,57 @@ namespace OpenSim.Region.Physics.OdePlugin
}
}
private void changeVehicleType(int value)
{
if (m_vehicle == null)
{
if (value != (int)Vehicle.TYPE_NONE)
{
m_vehicle = new ODEDynamics(this);
m_vehicle.ProcessTypeChange((Vehicle)value);
}
}
else
m_vehicle.ProcessTypeChange((Vehicle)value);
}
private void changeVehicleFloatParam(strVehicleFloatParam fp)
{
if (m_vehicle == null)
return;
m_vehicle.ProcessFloatVehicleParam((Vehicle)fp.param, fp.value);
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
d.BodyEnable(Body);
}
private void changeVehicleVectorParam(strVehicleVectorParam vp)
{
if (m_vehicle == null)
return;
m_vehicle.ProcessVectorVehicleParam((Vehicle)vp.param, vp.value);
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
d.BodyEnable(Body);
}
private void changeVehicleRotationParam(strVehicleQuatParam qp)
{
if (m_vehicle == null)
return;
m_vehicle.ProcessRotationVehicleParam((Vehicle)qp.param, qp.value);
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
d.BodyEnable(Body);
}
private void changeVehicleFlags(strVehicleBoolParam bp)
{
if (m_vehicle == null)
return;
m_vehicle.ProcessVehicleFlags(bp.param, bp.value);
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body))
d.BodyEnable(Body);
}
#endregion
public void Move()
@ -2616,7 +2634,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (!childPrim && m_isphysical && Body != IntPtr.Zero &&
!m_disabled && !m_isSelected && d.BodyIsEnabled(Body) && !m_building) // KF: Only move root prims.
{
// if (!d.BodyIsEnabled(Body)) d.BodyEnable(Body); // KF add 161009
// if (!d.BodyIsEnabled(Body)) d.BodyEnable(Body); // KF add 161009
float timestep = _parent_scene.ODE_STEPSIZE;
@ -2871,10 +2889,10 @@ namespace OpenSim.Region.Physics.OdePlugin
bool lastZeroFlag = _zeroFlag;
d.Vector3 lpos;
d.GeomCopyPosition(prim_geom,out lpos); // root position that is seem by rest of simulator
d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator
// we need to use root position since that's all the rest of scene uses
if ( lpos.X < 0f || lpos.X > _parent_scene.WorldExtents.X
if (lpos.X < 0f || lpos.X > _parent_scene.WorldExtents.X
|| lpos.Y < 0f || lpos.Y > _parent_scene.WorldExtents.Y
)
{
@ -3137,10 +3155,10 @@ namespace OpenSim.Region.Physics.OdePlugin
if (_parent != null)
{
OdePrim parent = (OdePrim)_parent;
parent.ChildRemove(this,false);
parent.ChildRemove(this, false);
}
else
ChildRemove(this,false);
ChildRemove(this, false);
RemoveGeom();
m_targetSpace = IntPtr.Zero;
@ -3177,12 +3195,12 @@ namespace OpenSim.Region.Physics.OdePlugin
changevelocity((Vector3)arg);
break;
// case changes.Acceleration:
// changeacceleration((Vector3)arg);
// break;
// case changes.AngVelocity:
// changeangvelocity((Vector3)arg);
// break;
// case changes.Acceleration:
// changeacceleration((Vector3)arg);
// break;
// case changes.AngVelocity:
// changeangvelocity((Vector3)arg);
// break;
case changes.Force:
changeForce((Vector3)arg);
@ -3209,7 +3227,7 @@ namespace OpenSim.Region.Physics.OdePlugin
break;
case changes.Shape:
changeShape((PrimitiveBaseShape) arg);
changeShape((PrimitiveBaseShape)arg);
break;
case changes.CollidesWater:
@ -3229,13 +3247,33 @@ namespace OpenSim.Region.Physics.OdePlugin
break;
case changes.disabled:
changeDisable((bool) arg);
changeDisable((bool)arg);
break;
case changes.building:
changeBuilding((bool)arg);
break;
case changes.VehicleType:
changeVehicleType((int)arg);
break;
case changes.VehicleFlags:
changeVehicleFlags((strVehicleBoolParam) arg);
break;
case changes.VehicleFloatParam:
changeVehicleFloatParam((strVehicleFloatParam) arg);
break;
case changes.VehicleVectorParam:
changeVehicleVectorParam((strVehicleVectorParam) arg);
break;
case changes.VehicleRotationParam:
changeVehicleRotationParam((strVehicleQuatParam) arg);
break;
case changes.Null:
donullchange();
break;
@ -3251,5 +3289,30 @@ namespace OpenSim.Region.Physics.OdePlugin
{
_parent_scene.AddChange(this, what, arg);
}
private struct strVehicleBoolParam
{
public int param;
public bool value;
}
private struct strVehicleFloatParam
{
public int param;
public float value;
}
private struct strVehicleQuatParam
{
public int param;
public Quaternion value;
}
private struct strVehicleVectorParam
{
public int param;
public Vector3 value;
}
}
}

View File

@ -1,4 +1,3 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
@ -137,6 +136,12 @@ namespace OpenSim.Region.Physics.OdePlugin
disabled,
building,
VehicleType,
VehicleFloatParam,
VehicleVectorParam,
VehicleRotationParam,
VehicleFlags,
Null //keep this last used do dim the methods array. does nothing but pulsing the prim
}