Added simple binary serializer/deserializer to chODE. 100% untested and most like still broken

avinationmerge
UbitUmarov 2012-02-17 21:09:00 +00:00
parent f6c35cf26f
commit 7d77ccc659
5 changed files with 1515 additions and 1010 deletions

View File

@ -27,6 +27,7 @@
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
@ -48,6 +49,11 @@ namespace OpenSim.Region.Physics.OdePlugin
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public class SerialControl
{
public object alock = new object();
public byte[] data = new byte[0];
}
private Vector3 _position;
private Vector3 _velocity;
private Vector3 _torque;
@ -112,7 +118,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private bool m_taintPhysics;
private bool m_collidesLand = true;
private bool m_collidesWater;
public bool m_returnCollisions;
// public bool m_returnCollisions;
// Default we're a Geometry
private CollisionCategories m_collisionCategories = (CollisionCategories.Geom);
@ -163,8 +169,8 @@ namespace OpenSim.Region.Physics.OdePlugin
private int throttleCounter;
public int m_interpenetrationcount;
public float m_collisionscore;
public int m_roundsUnderMotionThreshold;
private int m_crossingfailures;
// public int m_roundsUnderMotionThreshold;
// private int m_crossingfailures;
public bool m_outofBounds;
private float m_density = 10.000006836f; // Aluminum g/cm3;
@ -186,9 +192,6 @@ namespace OpenSim.Region.Physics.OdePlugin
internal int m_material = (int)Material.Wood;
private int frcount = 0; // Used to limit dynamics debug output to
private int revcount = 0; // Reverse motion while > 0
private IntPtr m_body = IntPtr.Zero;
// Vehicle properties ============================================================================================
@ -250,10 +253,408 @@ namespace OpenSim.Region.Physics.OdePlugin
private float m_verticalAttractionEfficiency = 1.0f; // damped
private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor.
SerialControl m_taintserial = null;
public override byte[] Serialize(bool PhysIsRunning)
{
SerialControl sc = new SerialControl();
lock (sc.alock)
{
if (PhysIsRunning)
{
m_taintserial = sc;
if (!Monitor.Wait(sc.alock, 1000))
{
m_log.Error("[chOde] prim data serialization timed out");
m_taintserial = null;
return new byte[0];
}
}
else
DoSerialize(sc);
}
return sc.data;
}
public void DoSerialize(SerialControl sc)
{
wstreamer st = new wstreamer();
Vector3 vtmp;
ushort version = 2;
if (!BitConverter.IsLittleEndian)
version |= 1;
st.Wushort(version); //version lower bit codes endian type for future use
// compact booleans in a ushort
ushort flags = 0;
if (m_isphysical) // this should be true for now
flags |= 1;
if (m_isSelected)
flags |= 2;
if (m_isVolumeDetect)
flags |= 4;
if (m_disabled)
flags |= 8;
if (m_collidesWater)
flags |= 16;
if (m_collidesLand)
flags |= 32;
if (m_usePID)
flags |= 64;
if (m_useAPID)
flags |= 128;
if (m_useHoverPID)
flags |= 256;
if (m_throttleUpdates)
flags |= 512;
st.Wushort(flags);
st.Wvector3(_size);
st.Wint(m_material);
st.Wfloat(m_density);
st.Wfloat(0); // future gravity mod V3
st.Wfloat(0); // future friction V3
st.Wfloat(0); // future bounce V3
// st.Wuint((uint)m_collisionCategories);
// st.Wuint((uint)m_collisionFlags);
if (_parent == null)
{
st.Wvector3(_position); // ??
st.Wquat(_orientation);
}
else // for childs save offsets
{
Quaternion to;
Quaternion ipo = Quaternion.Inverse(_parent.Orientation);
if (m_isphysical && prim_geom != IntPtr.Zero)
{
d.Vector3 dvt;
d.GeomCopyPosition(prim_geom, out dvt);
vtmp.X = dvt.X;
vtmp.Y = dvt.Y;
vtmp.Z = dvt.Z;
d.Quaternion dqt;
d.GeomCopyQuaternion(prim_geom, out dqt);
to.X = dqt.X;
to.Y = dqt.Y;
to.Z = dqt.Z;
to.W = dqt.W; // rotation in world
}
else
{
vtmp = _position;
to = _orientation;
}
vtmp -= _parent.Position; // offset in world
vtmp *= ipo; // offset in local
st.Wvector3(vtmp);
ipo *= to; // own rotation
st.Wquat(ipo);
}
st.Wvector3(_velocity);
st.Wvector3(m_rotationalVelocity);
st.Wvector3(_acceleration);
st.Wvector3(m_rotateEnable);
vtmp = Vector3.Zero;
for (int i = 0; i < m_forcelist.Count; i++)
{
vtmp += (m_forcelist[i] * 100);
}
st.Wvector3(vtmp); // force acc
vtmp = Vector3.Zero;
for (int i = 0; i < m_angularforcelist.Count; i++)
{
vtmp += (m_angularforcelist[i] * 100);
}
st.Wvector3(vtmp); // angular force acc
st.Wvector3(m_PIDTarget);
st.Wfloat(m_PIDTau);
st.Wfloat(PID_D);
st.Wfloat(PID_G);
st.Wquat(m_APIDTarget);
st.Wfloat(m_APIDStrength);
st.Wfloat(m_APIDDamping);
st.Wfloat(m_APIDdamper);
st.Wint((int)m_PIDHoverType);
st.Wfloat(m_PIDHoverHeight);
st.Wfloat(m_PIDHoverTau);
st.Wfloat(m_targetHoverHeight);
st.Wfloat(m_groundHeight);
st.Wfloat(m_waterHeight);
st.Wfloat(m_buoyancy);
// this must be last since type none ends stream
if (m_type == Vehicle.TYPE_NONE)
st.Wint((int)Vehicle.TYPE_NONE);
else
{
st.Wint((int)m_type);
st.Wquat(Quaternion.Identity); //m_referenceFrame
st.Wint((int)m_flags);
st.Wvector3(m_linearMotorDirection);
st.Wfloat(
(float)Math.Sqrt(m_lLinMotorDVel.LengthSquared() / m_linearMotorDirection.LengthSquared()));
st.Wvector3(m_linearFrictionTimescale);
st.Wfloat(m_linearMotorDecayTimescale);
st.Wfloat(m_linearMotorTimescale);
st.Wvector3(new Vector3(0, 0, 0)); //m_linearMotorOffset);
st.Wvector3(m_angularMotorDirection);
st.Wfloat((float)Math.Sqrt(m_angularMotorDVel.LengthSquared() / m_angularMotorDirection.LengthSquared()));
st.Wvector3(m_angularFrictionTimescale);
st.Wfloat(m_angularMotorDecayTimescale);
st.Wfloat(m_angularMotorTimescale);
st.Wfloat(0); //m_linearDeflectionEfficiency);
st.Wfloat(1000); //m_linearDeflectionTimescale);
st.Wfloat(0); //m_angularDeflectionEfficiency);
st.Wfloat(120); //m_angularDeflectionTimescale);
st.Wfloat(0); // m_bankingEfficiency);
st.Wfloat(0); //m_bankingMix);
st.Wfloat(1000); //m_bankingTimescale);
st.Wfloat(m_VhoverHeight);
st.Wfloat(0.5f); //m_VhoverEfficiency);
st.Wfloat(m_VhoverTimescale);
st.Wfloat(m_VehicleBuoyancy);
st.Wfloat(m_verticalAttractionEfficiency);
st.Wfloat(m_verticalAttractionTimescale);
}
sc.data = st.close();
m_taintserial = null;
Monitor.PulseAll(sc.alock);
}
public bool DeSerialize(byte[] data)
{
rstreamer st = new rstreamer(data);
int version =st.Rushort(); //version
// merge booleans in a ushort
ushort flags = st.Rushort();
if ((flags & 1) != 0)
m_isphysical = true;
if ((flags & 2) != 0)
m_taintselected = true;
if ((flags & 4) != 0)
m_isVolumeDetect = true;
if ((flags & 8) != 0)
m_taintdisable = true;
if ((flags & 16) != 0)
m_taintCollidesWater = true;
if ((flags & 32) != 0)
m_collidesLand = true;
if ((flags & 64) != 0)
m_usePID = true;
if ((flags & 128) != 0)
m_useAPID = true;
if ((flags & 256) != 0)
m_useHoverPID = true;
if ((flags & 512) != 0)
m_throttleUpdates = true;
_size = st.Rvector3();
m_taintsize = _size;
m_material= st.Rint();
m_density = st.Rfloat();
st.Rfloat(); // future gravity mod V3
st.Rfloat(); // future friction V3
st.Rfloat(); // future bounce V3
// m_collisionCategories = (CollisionCategories)st.Ruint();
// m_collisionFlags = (CollisionCategories) st.Ruint();
if (m_taintparent == null)
{
st.Rvector3(); // ignore old position sop/sog as to tell the new one
m_taintrot = st.Rquat(); //
_orientation = m_taintrot;
}
else
{
m_taintrot = _parent.Orientation;
m_taintposition = st.Rvector3(); // ??
_position = m_taintposition;
m_taintposition *= m_taintrot;
m_taintposition += _parent.Position;
m_taintrot *= st.Rquat(); //
_orientation = m_taintrot;
}
m_taintVelocity = st.Rvector3();
m_rotationalVelocity = st.Rvector3();
_acceleration = st.Rvector3();
m_rotateEnableRequest = st.Rvector3();
m_rotateEnableUpdate = true;
Vector3 vtmp;
vtmp = st.Rvector3(); // forces acc
m_forcelist.Add(vtmp);
m_taintforce = true;
vtmp = st.Rvector3(); // angular forces acc
m_angularforcelist.Add(vtmp);
m_taintaddangularforce = true;
m_PIDTarget = st.Rvector3();
m_PIDTau = st.Rfloat();
PID_D = st.Rfloat();
PID_G = st.Rfloat();
m_APIDTarget = st.Rquat();
m_APIDStrength = st.Rfloat();
m_APIDDamping = st.Rfloat();
m_APIDdamper = st.Rfloat();
m_PIDHoverType = (PIDHoverType) st.Rint();
m_PIDHoverHeight = st.Rfloat();
m_PIDHoverTau = st.Rfloat();
m_targetHoverHeight = st.Rfloat();
m_groundHeight = st.Rfloat();
m_waterHeight = st.Rfloat();
m_buoyancy = st.Rfloat();
// this must be last since type none ends stream
m_type = (Vehicle) st.Rint();
if (m_type != Vehicle.TYPE_NONE)
{
float ftmp;
st.Rquat(); //m_referenceFrame
m_flags = (VehicleFlag) st.Rint();
m_linearMotorDirection = st.Rvector3();
ftmp = st.Rfloat();
m_lLinMotorDVel = m_linearMotorDirection * ftmp;
m_linearFrictionTimescale = st.Rvector3();
m_linearMotorDecayTimescale = st.Rfloat();
m_linearMotorTimescale = st.Rfloat();
st.Rvector3(); //m_linearMotorOffset);
m_angularMotorDirection = st.Rvector3();
ftmp = st.Rfloat();
m_angularMotorDVel = m_angularMotorDirection * ftmp;
m_angularFrictionTimescale = st.Rvector3();
m_angularMotorDecayTimescale = st.Rfloat();
m_angularMotorTimescale = st.Rfloat();
st.Rfloat(); //m_linearDeflectionEfficiency);
st.Rfloat(); //m_linearDeflectionTimescale);
st.Rfloat(); //m_angularDeflectionEfficiency);
st.Rfloat(); //m_angularDeflectionTimescale);
st.Rfloat(); // m_bankingEfficiency);
st.Rfloat(); //m_bankingMix);
st.Rfloat(); //m_bankingTimescale);
m_VhoverHeight = st.Rfloat();
st.Rfloat(); //m_VhoverEfficiency);
m_VhoverTimescale = st.Rfloat();
m_VehicleBuoyancy = st.Rfloat();
m_verticalAttractionEfficiency = st.Rfloat();
m_verticalAttractionTimescale = st.Rfloat();
}
st.close();
return true;
}
public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, PhysicsActor parent,
PrimitiveBaseShape pbs, CollisionLocker dode, uint localid, byte[] sdata)
{
m_localID = localid;
ode = dode;
if (parent == null)
{
m_taintparent = null;
if (!pos.IsFinite())
{
pos = new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f),
parent_scene.GetTerrainHeightAtXY(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f)) + 0.5f);
m_log.Warn("[PHYSICS]: Got nonFinite Object create Position");
}
_position = pos;
m_taintposition = pos;
}
else
m_taintparent = parent;
body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
prim_geom = IntPtr.Zero;
_mesh = null;
m_meshfailed = false;
_pbs = pbs;
_parent_scene = parent_scene;
m_targetSpace = (IntPtr)0;
if(sdata != null && sdata.Length > 1)
DeSerialize(sdata);
if (m_isphysical)
m_targetSpace = _parent_scene.space;
m_primName = primName;
m_taintserial = null;
m_taintadd = true;
_parent_scene.AddPhysicsActorTaint(this);
// don't do .add() here; old geoms get recycled with the same hash
}
public OdePrim(String primName, OdeScene parent_scene, Vector3 pos, Vector3 size,
Quaternion rotation, IMesh mesh, PrimitiveBaseShape pbs, bool pisPhysical, CollisionLocker dode, uint localid)
@ -275,7 +676,6 @@ namespace OpenSim.Region.Physics.OdePlugin
// m_tensor = parent_scene.bodyMotorJointMaxforceTensor;
body_autodisable_frames = parent_scene.bodyFramesAutoDisable;
prim_geom = IntPtr.Zero;
// prev_geom = IntPtr.Zero;
@ -317,6 +717,8 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_isphysical)
m_targetSpace = _parent_scene.space;
}
m_taintserial = null;
m_primName = primName;
m_taintadd = true;
_parent_scene.AddPhysicsActorTaint(this);
@ -337,9 +739,11 @@ namespace OpenSim.Region.Physics.OdePlugin
public override uint LocalID
{
set {
set
{
//m_log.Info("[PHYSICS]: Setting TrackerID: " + value);
m_localID = value; }
m_localID = value;
}
}
public override bool Grabbed
@ -349,7 +753,8 @@ namespace OpenSim.Region.Physics.OdePlugin
public override bool Selected
{
set {
set
{
//Console.WriteLine("Sel {0} {1} {2}", m_primName, value, m_isphysical);
// This only makes the object not collidable if the object
@ -430,7 +835,9 @@ namespace OpenSim.Region.Physics.OdePlugin
{
get { return _position; }
set { _position = value;
set
{
_position = value;
//m_log.Info("[PHYSICS]: " + _position.ToString());
}
}
@ -614,7 +1021,8 @@ namespace OpenSim.Region.Physics.OdePlugin
public override bool FloatOnWater
{
set {
set
{
m_taintCollidesWater = value;
_parent_scene.AddPhysicsActorTaint(this);
}
@ -1434,6 +1842,10 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_taintCollidesWater != m_collidesWater)
changefloatonwater(timestep);
if (m_taintserial != null)
DoSerialize(m_taintserial);
/* obsolete
if (!m_angularLock.ApproxEquals(m_taintAngularLock,0f))
changeAngularLock(timestep);
@ -2995,9 +3407,6 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!");
private void UpdateLinDecay()
{
// if (Math.Abs(m_linearMotorDirection.X) > Math.Abs(m_lLinMotorDVel.X)) m_lLinMotorDVel.X = m_linearMotorDirection.X;
// if (Math.Abs(m_linearMotorDirection.Y) > Math.Abs(m_lLinMotorDVel.Y)) m_lLinMotorDVel.Y = m_linearMotorDirection.Y;
// if (Math.Abs(m_linearMotorDirection.Z) > Math.Abs(m_lLinMotorDVel.Z)) m_lLinMotorDVel.Z = m_linearMotorDirection.Z;
m_lLinMotorDVel.X = m_linearMotorDirection.X;
m_lLinMotorDVel.Y = m_linearMotorDirection.Y;
m_lLinMotorDVel.Z = m_linearMotorDirection.Z;
@ -3005,9 +3414,6 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!");
private void UpdateAngDecay()
{
// if (Math.Abs(m_angularMotorDirection.X) > Math.Abs(m_angularMotorDVel.X)) m_angularMotorDVel.X = m_angularMotorDirection.X;
// if (Math.Abs(m_angularMotorDirection.Y) > Math.Abs(m_angularMotorDVel.Y)) m_angularMotorDVel.Y = m_angularMotorDirection.Y;
// if (Math.Abs(m_angularMotorDirection.Z) > Math.Abs(m_angularMotorDVel.Z)) m_angularMotorDVel.Z = m_angularMotorDirection.Z;
m_angularMotorDVel.X = m_angularMotorDirection.X;
m_angularMotorDVel.Y = m_angularMotorDirection.Y;
m_angularMotorDVel.Z = m_angularMotorDirection.Z;
@ -3019,19 +3425,10 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!");
float fy = 0;
float fz = 0;
Vector3 linvel; // velocity applied, including any reversal
int outside = 0;
// If geomCrossingFailuresBeforeOutofbounds is set to 0 in OpenSim.ini then phys objects bounce off region borders.
// This is a temp patch until proper region crossing is developed.
int failureLimit = _parent_scene.geomCrossingFailuresBeforeOutofbounds;
float fence = _parent_scene.geomRegionFence;
frcount++; // used to limit debug comment output
if (frcount > 50)
frcount = 0;
if(revcount > 0) revcount--;
if (IsPhysical && (Body != IntPtr.Zero) && !m_isSelected && !childPrim && !m_outofBounds) // Only move root prims.
{
@ -3065,75 +3462,6 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!");
_torque = new Vector3(torque.X, torque.Y, torque.Z);
//Console.WriteLine("Move {0} at {1}", m_primName, l_position);
/*
// Check if outside region
// In Scene.cs/CrossPrimGroupIntoNewRegion the object is checked for 0.1M from border!
if (l_position.X > ((float)_parent_scene.WorldExtents.X - fence))
{
l_position.X = ((float)_parent_scene.WorldExtents.X - fence);
outside = 1;
}
if (l_position.X < fence)
{
l_position.X = fence;
outside = 2;
}
if (l_position.Y > ((float)_parent_scene.WorldExtents.Y - fence))
{
l_position.Y = ((float)_parent_scene.WorldExtents.Y - fence);
outside = 3;
}
if (l_position.Y < fence)
{
l_position.Y = fence;
outside = 4;
}
if (outside > 0)
{
//Console.WriteLine("Border {0} fence={1}", l_position, fence);
if (fence > 0.0f) // bounce object off boundary
{
if (revcount == 0)
{
if (outside < 3)
{
_velocity.X = -_velocity.X;
}
else
{
_velocity.Y = -_velocity.Y;
}
if (m_type != Vehicle.TYPE_NONE) Halt();
_position = l_position;
m_taintposition = _position;
m_lastVelocity = _velocity;
_acceleration = Vector3.Zero;
d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z);
base.RequestPhysicsterseUpdate();
revcount = 25; // wait for object to move away from border
}
} // else old crossing mode
else if (m_crossingfailures < failureLimit)
{ // keep trying to cross?
_position = l_position;
//_parent_scene.remActivePrim(this);
if (_parent == null) base.RequestPhysicsterseUpdate();
return; // Dont process any other motion?
}
else
{ // Too many tries
if (_parent == null) base.RaiseOutOfBounds(l_position);
return; // Dont process any other motion?
} // end various methods
} // end outside region horizontally
*/
if (_position.X < 0f || _position.X > _parent_scene.WorldExtents.X
|| _position.Y < 0f || _position.Y > _parent_scene.WorldExtents.Y
)
@ -3146,41 +3474,11 @@ Console.WriteLine("ODEPrim JointCreateFixed !!!");
_position.Z = Util.Clip(l_position.Z, -100f, 50000f);
d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
d.BodySetLinearVel(Body, 0, 0, 0);
/*
if (Interlocked.Exchange(ref m_crossingfailures, m_crossingfailures) == 0)
{ // tell base code only once
Interlocked.Increment(ref m_crossingfailures);
base.RequestPhysicsterseUpdate();
}
*/
m_outofBounds = true;
base.RequestPhysicsterseUpdate();
return;
}
/*
if (Interlocked.Exchange(ref m_crossingfailures, 0) != 0)
{
// main simulator had a crossing failure
// park it inside region
_position.X = Util.Clip(l_position.X, 0.5f, _parent_scene.WorldExtents.X - 0.5f);
_position.Y = Util.Clip(l_position.Y, 0.5f, _parent_scene.WorldExtents.Y - 0.5f);
_position.Z = Util.Clip(l_position.Z, -100f, 50000f);
d.BodySetPosition(Body, _position.X, _position.Y, _position.Z);
m_lastposition = _position;
_velocity = Vector3.Zero;
m_lastVelocity = _velocity;
if (m_type != Vehicle.TYPE_NONE)
Halt();
d.BodySetLinearVel(Body, 0, 0, 0);
base.RequestPhysicsterseUpdate();
return;
}
*/
base.RequestPhysicsterseUpdate();
if (l_position.Z < 0)

View File

@ -1736,6 +1736,23 @@ namespace OpenSim.Region.Physics.OdePlugin
return newPrim;
}
private PhysicsActor AddPrim(String name, Vector3 position, PhysicsActor parent,
PrimitiveBaseShape pbs, uint localid, byte[] sdata)
{
Vector3 pos = position;
OdePrim newPrim;
lock (OdeLock)
{
newPrim = new OdePrim(name, this, pos, parent, pbs, ode, localid, sdata);
lock (_prims)
_prims.Add(newPrim);
}
return newPrim;
}
public void addActivePrim(OdePrim activatePrim)
{
// adds active prim.. (ones that should be iterated over in collisions_optimized
@ -1762,6 +1779,17 @@ namespace OpenSim.Region.Physics.OdePlugin
return result;
}
public override PhysicsActor AddPrimShape(string primName, PhysicsActor parent, PrimitiveBaseShape pbs, Vector3 position,
uint localid, byte[] sdata)
{
PhysicsActor result;
result = AddPrim(primName, position, parent,
pbs, localid, sdata);
return result;
}
public override float TimeDilation
{
get { return m_timeDilation; }

View File

@ -0,0 +1,167 @@
// adapted from libomv removing cpu endian adjust
// for prims lowlevel serialization
using System;
using System.IO;
using OpenMetaverse;
namespace OpenSim.Region.Physics.OdePlugin
{
public class wstreamer
{
private MemoryStream st;
public wstreamer()
{
st = new MemoryStream();
}
public byte[] close()
{
byte[] data = st.ToArray();
st.Close();
return data;
}
public void Wshort(short value)
{
st.Write(BitConverter.GetBytes(value), 0, 2);
}
public void Wushort(ushort value)
{
byte[] t = BitConverter.GetBytes(value);
st.Write(BitConverter.GetBytes(value), 0, 2);
}
public void Wint(int value)
{
st.Write(BitConverter.GetBytes(value), 0, 4);
}
public void Wuint(uint value)
{
st.Write(BitConverter.GetBytes(value), 0, 4);
}
public void Wlong(long value)
{
st.Write(BitConverter.GetBytes(value), 0, 8);
}
public void Wulong(ulong value)
{
st.Write(BitConverter.GetBytes(value), 0, 8);
}
public void Wfloat(float value)
{
st.Write(BitConverter.GetBytes(value), 0, 4);
}
public void Wdouble(double value)
{
st.Write(BitConverter.GetBytes(value), 0, 8);
}
public void Wvector3(Vector3 value)
{
st.Write(BitConverter.GetBytes(value.X), 0, 4);
st.Write(BitConverter.GetBytes(value.Y), 0, 4);
st.Write(BitConverter.GetBytes(value.Z), 0, 4);
}
public void Wquat(Quaternion value)
{
st.Write(BitConverter.GetBytes(value.X), 0, 4);
st.Write(BitConverter.GetBytes(value.Y), 0, 4);
st.Write(BitConverter.GetBytes(value.Z), 0, 4);
st.Write(BitConverter.GetBytes(value.W), 0, 4);
}
}
public class rstreamer
{
private byte[] rbuf;
private int ptr;
public rstreamer(byte[] data)
{
rbuf = data;
ptr = 0;
}
public void close()
{
}
public short Rshort()
{
short v = BitConverter.ToInt16(rbuf, ptr);
ptr += 2;
return v;
}
public ushort Rushort()
{
ushort v = BitConverter.ToUInt16(rbuf, ptr);
ptr += 2;
return v;
}
public int Rint()
{
int v = BitConverter.ToInt32(rbuf, ptr);
ptr += 4;
return v;
}
public uint Ruint()
{
uint v = BitConverter.ToUInt32(rbuf, ptr);
ptr += 4;
return v;
}
public long Rlong()
{
long v = BitConverter.ToInt64(rbuf, ptr);
ptr += 8;
return v;
}
public ulong Rulong()
{
ulong v = BitConverter.ToUInt64(rbuf, ptr);
ptr += 8;
return v;
}
public float Rfloat()
{
float v = BitConverter.ToSingle(rbuf, ptr);
ptr += 4;
return v;
}
public double Rdouble()
{
double v = BitConverter.ToDouble(rbuf, ptr);
ptr += 8;
return v;
}
public Vector3 Rvector3()
{
Vector3 v;
v.X = BitConverter.ToSingle(rbuf, ptr);
ptr += 4;
v.Y = BitConverter.ToSingle(rbuf, ptr);
ptr += 4;
v.Z = BitConverter.ToSingle(rbuf, ptr);
ptr += 4;
return v;
}
public Quaternion Rquat()
{
Quaternion v;
v.X = BitConverter.ToSingle(rbuf, ptr);
ptr += 4;
v.Y = BitConverter.ToSingle(rbuf, ptr);
ptr += 4;
v.Z = BitConverter.ToSingle(rbuf, ptr);
ptr += 4;
v.W = BitConverter.ToSingle(rbuf, ptr);
ptr += 4;
return v;
}
}
}

View File

@ -214,6 +214,11 @@ namespace OpenSim.Region.Physics.Manager
}
}
public virtual byte[] Serialize(bool PhysIsRunning)
{
return new byte[0];
}
public virtual void RaiseOutOfBounds(Vector3 pos)
{
// Make a temporary copy of the event to avoid possibility of
@ -573,5 +578,6 @@ namespace OpenSim.Region.Physics.Manager
{
return false;
}
}
}

View File

@ -128,6 +128,12 @@ namespace OpenSim.Region.Physics.Manager
public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
Vector3 size, Quaternion rotation, bool isPhysical, uint localid);
public virtual PhysicsActor AddPrimShape(string primName, PhysicsActor parent, PrimitiveBaseShape pbs, Vector3 position,
uint localid, byte[] sdata)
{
return null;
}
public virtual float TimeDilation
{
get { return 1.0f; }