From 5e8900dfd058bd103cb6dcf8a57dc94683efd878 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 9 Jul 2011 00:35:30 +0100 Subject: minor: code tidy and inserted log lines for future use. Unable to get to the bottom of why resizing a mesh fails to properly reset the physics proxy, when toggling phantom does After a mesh is generated, the existing sculptdata is set to zero in PrimitiveBaseShape to save memory When phantom is toggled, the sculptdata is regenerated before remeshing. But on resize, the sculptdata is not regenerated. So clearly, resetting sculptdata is possible, but haven't quite been able to pin down how this is being done when phantom is toggled. --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 52 ++++++++++++++++++---------- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 5 +-- 2 files changed, 35 insertions(+), 22 deletions(-) (limited to 'OpenSim/Region/Physics/OdePlugin') diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index bc839e0..b63168a 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -38,6 +38,9 @@ * switch between 'VEHICLE' parameter use and general dynamics * settings use. */ + +//#define SPAM + using System; using System.Collections.Generic; using System.Reflection; @@ -746,7 +749,6 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); } - d.BodyDestroy(Body); lock (childrenPrim) { @@ -775,7 +777,6 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetCollideBits(prim_geom, (int)m_collisionFlags); } - Body = IntPtr.Zero; } } @@ -858,7 +859,7 @@ namespace OpenSim.Region.Physics.OdePlugin public void ProcessTaints(float timestep) { -//Console.WriteLine("ProcessTaints for " + Name); +Console.WriteLine("ProcessTaints for " + Name); if (m_taintadd) { changeadd(timestep); @@ -867,7 +868,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (prim_geom != IntPtr.Zero) { if (!_position.ApproxEquals(m_taintposition, 0f)) - changemove(timestep); + changemove(timestep); if (m_taintrot != _orientation) { @@ -885,19 +886,15 @@ namespace OpenSim.Region.Physics.OdePlugin rotate(timestep); } } - // if (m_taintPhysics != m_isphysical && !(m_taintparent != _parent)) changePhysicsStatus(timestep); - // - if (!_size.ApproxEquals(m_taintsize,0f)) + if (!_size.ApproxEquals(m_taintsize, 0f)) changesize(timestep); - // if (m_taintshape) changeshape(timestep); - // if (m_taintforce) changeAddForce(timestep); @@ -925,7 +922,6 @@ namespace OpenSim.Region.Physics.OdePlugin if (!m_angularlock.ApproxEquals(m_taintAngularLock,0f)) changeAngularLock(timestep); - } else { @@ -1424,10 +1420,11 @@ namespace OpenSim.Region.Physics.OdePlugin } } - lock (_parent_scene.OdeLock) { -//Console.WriteLine("changeadd 1"); +#if SPAM +Console.WriteLine("changeadd 1"); +#endif CreateGeom(m_targetSpace, _mesh); if (prim_geom != IntPtr.Zero) @@ -1890,6 +1887,10 @@ Console.WriteLine(" JointCreateFixed"); public void changesize(float timestamp) { +#if SPAM + m_log.DebugFormat("[ODE PRIM]: Called changesize"); +#endif + string oldname = _parent_scene.geom_name_map[prim_geom]; if (_size.X <= 0) _size.X = 0.01f; @@ -1899,8 +1900,9 @@ Console.WriteLine(" JointCreateFixed"); // Cleanup of old prim geometry if (_mesh != null) { - // Cleanup meshing here + // TODO: Cleanup meshing here } + //kill body to rebuild if (IsPhysical && Body != IntPtr.Zero) { @@ -1917,11 +1919,13 @@ Console.WriteLine(" JointCreateFixed"); disableBody(); } } + if (d.SpaceQuery(m_targetSpace, prim_geom)) { _parent_scene.waitForSpaceUnlock(m_targetSpace); d.SpaceRemove(m_targetSpace, prim_geom); } + d.GeomDestroy(prim_geom); prim_geom = IntPtr.Zero; // we don't need to do space calculation because the client sends a position update also. @@ -1941,13 +1945,19 @@ Console.WriteLine(" JointCreateFixed"); mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); -//Console.WriteLine("changesize 1"); +#if SPAM +Console.WriteLine("changesize 1"); +#endif CreateGeom(m_targetSpace, mesh); } else { _mesh = null; -//Console.WriteLine("changesize 2"); + +#if SPAM +Console.WriteLine("changesize 2"); +#endif + CreateGeom(m_targetSpace, _mesh); } @@ -2030,6 +2040,7 @@ Console.WriteLine(" JointCreateFixed"); prim_geom = IntPtr.Zero; m_log.ErrorFormat("[PHYSICS]: PrimGeom dead for {0}", Name); } + prim_geom = IntPtr.Zero; // we don't need to do space calculation because the client sends a position update also. if (_size.X <= 0) _size.X = 0.01f; @@ -2039,7 +2050,7 @@ Console.WriteLine(" JointCreateFixed"); if (_parent_scene.needsMeshing(_pbs)) { - // Don't need to re-enable body.. it's done in SetMesh + // Don't need to re-enable body.. it's done in CreateMesh float meshlod = _parent_scene.meshSculptLOD; if (IsPhysical) @@ -2047,13 +2058,18 @@ Console.WriteLine(" JointCreateFixed"); IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); // createmesh returns null when it doesn't mesh. -//Console.WriteLine("changeshape needed meshing"); +#if SPAM +Console.WriteLine("changeshape needed meshing"); +#endif CreateGeom(m_targetSpace, mesh); } else { _mesh = null; -//Console.WriteLine("changeshape not need meshing"); + +#if SPAM +Console.WriteLine("changeshape not need meshing"); +#endif CreateGeom(m_targetSpace, null); } diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 87d22af..f5172aa 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -26,7 +26,7 @@ */ //#define USE_DRAWSTUFF -//#define SPAM +#define SPAM using System; using System.Collections.Generic; @@ -312,7 +312,6 @@ namespace OpenSim.Region.Physics.OdePlugin #endif } - _watermap = new float[258 * 258]; // Zero out the prim spaces array (we split our space into smaller spaces so @@ -2563,7 +2562,6 @@ namespace OpenSim.Region.Physics.OdePlugin if (pbs.SculptEntry && meshSculptedPrim) iPropertiesNotSupportedDefault++; - if (iPropertiesNotSupportedDefault == 0) { #if SPAM @@ -2703,7 +2701,6 @@ namespace OpenSim.Region.Physics.OdePlugin { foreach (OdeCharacter character in _taintedActors) { - character.ProcessTaints(timeStep); processedtaints = true; -- cgit v1.1