From 3da613adf5c803edfcca41f260017b96b1d80fb5 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 24 Apr 2012 23:13:57 +0100 Subject: [PATCH] fix chODE loosing some part positions when doing isPhysical false --- OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 45 ++++++++++++++++--- .../Region/Physics/UbitOdePlugin/ODEPrim.cs | 8 ++-- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs index 77ea2aff0f..5b743e8a02 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs @@ -461,6 +461,13 @@ namespace OpenSim.Region.Physics.OdePlugin } } + public override bool IsVolumeDtc + { + set { return; } + get { return m_isVolumeDetect; } + + } + public override bool Phantom { get { return m_isphantom; } @@ -598,6 +605,7 @@ namespace OpenSim.Region.Physics.OdePlugin } } + public override Vector3 CenterOfMass { 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() { //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) { if (childrenPrim.Count > 0) { foreach (OdePrim prm in childrenPrim) { - if (prm.m_NoColide && prm.prim_geom != IntPtr.Zero) + if (prm.prim_geom != IntPtr.Zero) { - d.GeomSetCategoryBits(prm.prim_geom, 0); - d.GeomSetCollideBits(prm.prim_geom, 0); - d.GeomDisable(prm.prim_geom); - } + if (prm.m_NoColide) + { + d.GeomSetCategoryBits(prm.prim_geom, 0); + d.GeomSetCollideBits(prm.prim_geom, 0); + d.GeomDisable(prm.prim_geom); + } + prm.UpdateDataFromGeom(); + } _parent_scene.remActivePrim(prm); prm.Body = IntPtr.Zero; } } } + d.BodyDestroy(Body); Body = IntPtr.Zero; } } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index dc6c18d220..2d587ab53a 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -2467,15 +2467,14 @@ namespace OpenSim.Region.Physics.OdePlugin { if (prim_geom != IntPtr.Zero) { - d.Quaternion qtmp = new d.Quaternion { }; + 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.GeomCopyPosition(prim_geom, out lpos); + d.Vector3 lpos = d.GeomGetPosition(prim_geom); _position.X = lpos.X; _position.Y = lpos.Y; _position.Z = lpos.Z; @@ -3565,8 +3564,7 @@ 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.Vector3 lpos = d.GeomGetPosition(prim_geom); d.Quaternion ori; d.GeomCopyQuaternion(prim_geom, out ori);