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. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/* Revision 2011 by Ubit Umarov /* Revision 2011/12 by Ubit Umarov
* *
* *
*/ */
@ -225,19 +225,6 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
get 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; return primContactData;
} }
} }
@ -400,7 +387,6 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override void SetVolumeDetect(int param) public override void SetVolumeDetect(int param)
{ {
AddChange(changes.VolumeDtc, (param != 0)); AddChange(changes.VolumeDtc, (param != 0));
@ -483,14 +469,6 @@ namespace OpenSim.Region.Physics.OdePlugin
// client object interpolation works a 'little' better // client object interpolation works a 'little' better
if (_zeroFlag) if (_zeroFlag)
return Vector3.Zero; 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; return _velocity;
} }
set set
@ -652,6 +630,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override int VehicleType public override int VehicleType
{ {
// we may need to put a fake on this
get get
{ {
if (m_vehicle == null) if (m_vehicle == null)
@ -661,44 +640,32 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
set set
{ {
if (m_vehicle == null) AddChange(changes.VehicleType, value);
{
if (value != (int)Vehicle.TYPE_NONE)
{
m_vehicle = new ODEDynamics(this);
m_vehicle.ProcessTypeChange((Vehicle)value);
}
}
else
m_vehicle.ProcessTypeChange((Vehicle)value);
} }
} }
public override void VehicleFloatParam(int param, float value) public override void VehicleFloatParam(int param, float value)
{ {
if (m_vehicle == null) strVehicleFloatParam fp = new strVehicleFloatParam();
return; fp.param = param;
m_vehicle.ProcessFloatVehicleParam((Vehicle)param, value); fp.value = value;
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) AddChange(changes.VehicleFloatParam, fp);
d.BodyEnable(Body);
} }
public override void VehicleVectorParam(int param, Vector3 value) public override void VehicleVectorParam(int param, Vector3 value)
{ {
if (m_vehicle == null) strVehicleVectorParam fp = new strVehicleVectorParam();
return; fp.param = param;
m_vehicle.ProcessVectorVehicleParam((Vehicle)param, value); fp.value = value;
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) AddChange(changes.VehicleVectorParam, fp);
d.BodyEnable(Body);
} }
public override void VehicleRotationParam(int param, Quaternion rotation) public override void VehicleRotationParam(int param, Quaternion value)
{ {
if (m_vehicle == null) strVehicleQuatParam fp = new strVehicleQuatParam();
return; fp.param = param;
m_vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); fp.value = value;
if (Body != IntPtr.Zero && !d.BodyIsEnabled(Body)) AddChange(changes.VehicleVectorParam, fp);
d.BodyEnable(Body);
} }
public override void VehicleFlags(int param, bool remove) public override void VehicleFlags(int param, bool remove)
@ -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 #endregion
public void Move() public void Move()
@ -3236,6 +3254,26 @@ namespace OpenSim.Region.Physics.OdePlugin
changeBuilding((bool)arg); changeBuilding((bool)arg);
break; 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: case changes.Null:
donullchange(); donullchange();
break; break;
@ -3251,5 +3289,30 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
_parent_scene.AddChange(this, what, arg); _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/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
@ -137,6 +136,12 @@ namespace OpenSim.Region.Physics.OdePlugin
disabled, disabled,
building, building,
VehicleType,
VehicleFloatParam,
VehicleVectorParam,
VehicleRotationParam,
VehicleFlags,
Null //keep this last used do dim the methods array. does nothing but pulsing the prim Null //keep this last used do dim the methods array. does nothing but pulsing the prim
} }