fix chODE loosing some part positions when doing isPhysical false

avinationmerge
UbitUmarov 2012-04-24 23:13:57 +01:00
parent 816a44d6da
commit 3da613adf5
2 changed files with 42 additions and 11 deletions

View File

@ -461,6 +461,13 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override bool IsVolumeDtc
{
set { return; }
get { return m_isVolumeDetect; }
}
public override bool Phantom public override bool Phantom
{ {
get { return m_isphantom; } get { return m_isphantom; }
@ -598,6 +605,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
public override Vector3 CenterOfMass public override Vector3 CenterOfMass
{ {
get { return Vector3.Zero; } get { return Vector3.Zero; }
@ -1372,6 +1380,25 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
private void UpdateDataFromGeom()
{
if (prim_geom != IntPtr.Zero)
{
d.Quaternion qtmp;
d.GeomCopyQuaternion(prim_geom, out qtmp);
_orientation.W = qtmp.W;
_orientation.X = qtmp.X;
_orientation.Y = qtmp.Y;
_orientation.Z = qtmp.Z;
d.Vector3 lpos = d.GeomGetPosition(prim_geom);
_position.X = lpos.X;
_position.Y = lpos.Y;
_position.Z = lpos.Z;
}
}
public void disableBody() public void disableBody()
{ {
//this kills the body so things like 'mesh' can re-create it. //this kills the body so things like 'mesh' can re-create it.
@ -1400,25 +1427,31 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
} }
d.BodyDestroy(Body); UpdateDataFromGeom();
lock (childrenPrim) lock (childrenPrim)
{ {
if (childrenPrim.Count > 0) if (childrenPrim.Count > 0)
{ {
foreach (OdePrim prm in childrenPrim) foreach (OdePrim prm in childrenPrim)
{ {
if (prm.m_NoColide && prm.prim_geom != IntPtr.Zero) if (prm.prim_geom != IntPtr.Zero)
{
if (prm.m_NoColide)
{ {
d.GeomSetCategoryBits(prm.prim_geom, 0); d.GeomSetCategoryBits(prm.prim_geom, 0);
d.GeomSetCollideBits(prm.prim_geom, 0); d.GeomSetCollideBits(prm.prim_geom, 0);
d.GeomDisable(prm.prim_geom); d.GeomDisable(prm.prim_geom);
}
}
prm.UpdateDataFromGeom();
}
_parent_scene.remActivePrim(prm); _parent_scene.remActivePrim(prm);
prm.Body = IntPtr.Zero; prm.Body = IntPtr.Zero;
} }
} }
} }
d.BodyDestroy(Body);
Body = IntPtr.Zero; Body = IntPtr.Zero;
} }
} }

View File

@ -2467,15 +2467,14 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
if (prim_geom != IntPtr.Zero) if (prim_geom != IntPtr.Zero)
{ {
d.Quaternion qtmp = new d.Quaternion { }; d.Quaternion qtmp;
d.GeomCopyQuaternion(prim_geom, out qtmp); d.GeomCopyQuaternion(prim_geom, out qtmp);
_orientation.W = qtmp.W; _orientation.W = qtmp.W;
_orientation.X = qtmp.X; _orientation.X = qtmp.X;
_orientation.Y = qtmp.Y; _orientation.Y = qtmp.Y;
_orientation.Z = qtmp.Z; _orientation.Z = qtmp.Z;
d.Vector3 lpos; d.Vector3 lpos = d.GeomGetPosition(prim_geom);
d.GeomCopyPosition(prim_geom, out lpos);
_position.X = lpos.X; _position.X = lpos.X;
_position.Y = lpos.Y; _position.Y = lpos.Y;
_position.Z = lpos.Z; _position.Z = lpos.Z;
@ -3565,8 +3564,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
bool lastZeroFlag = _zeroFlag; bool lastZeroFlag = _zeroFlag;
d.Vector3 lpos; d.Vector3 lpos = d.GeomGetPosition(prim_geom);
d.GeomCopyPosition(prim_geom, out lpos); // root position that is seem by rest of simulator
d.Quaternion ori; d.Quaternion ori;
d.GeomCopyQuaternion(prim_geom, out ori); d.GeomCopyQuaternion(prim_geom, out ori);