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/Framework/PrimitiveBaseShape.cs | 46 ++++++++++++------- .../Caps/ObjectCaps/UploadObjectAssetModule.cs | 4 +- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 1 - .../Scenes/Serialization/SceneObjectSerializer.cs | 2 + OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 5 ++- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 52 ++++++++++++++-------- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 5 +-- 7 files changed, 72 insertions(+), 43 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 7b5fb2e..8489ad8 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -213,6 +213,8 @@ namespace OpenSim.Framework /// public PrimitiveBaseShape(Primitive prim) { +// m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Creating from {0}", prim.ID); + PCode = (byte)prim.PrimData.PCode; ExtraParams = new byte[1]; @@ -613,29 +615,39 @@ namespace OpenSim.Framework } } - public byte SculptType { - get { + public byte SculptType + { + get + { return _sculptType; } - set { + set + { _sculptType = value; } } - public byte[] SculptData { - get { + public byte[] SculptData + { + get + { return _sculptData; } - set { + set + { +// m_log.DebugFormat("[PRIMITIVE BASE SHAPE]: Setting SculptData to data with length {0}", value.Length); _sculptData = value; } } - public int FlexiSoftness { - get { + public int FlexiSoftness + { + get + { return _flexiSoftness; } - set { + set + { _flexiSoftness = value; } } @@ -849,6 +861,8 @@ namespace OpenSim.Framework public byte[] ExtraParamsToBytes() { +// m_log.DebugFormat("[EXTRAPARAMS]: Called ExtraParamsToBytes()"); + ushort FlexiEP = 0x10; ushort LightEP = 0x20; ushort SculptEP = 0x30; @@ -864,18 +878,21 @@ namespace OpenSim.Framework TotalBytesLength += 16;// data TotalBytesLength += 2 + 4; // type } + if (_lightEntry) { ExtraParamsNum++; TotalBytesLength += 16;// data TotalBytesLength += 2 + 4; // type } + if (_sculptEntry) { ExtraParamsNum++; TotalBytesLength += 17;// data TotalBytesLength += 2 + 4; // type } + if (_projectionEntry) { ExtraParamsNum++; @@ -885,7 +902,6 @@ namespace OpenSim.Framework byte[] returnbytes = new byte[TotalBytesLength]; - // uint paramlength = ExtraParamsNum; // Stick in the number of parameters @@ -905,6 +921,7 @@ namespace OpenSim.Framework Array.Copy(FlexiData, 0, returnbytes, i, FlexiData.Length); i += FlexiData.Length; } + if (_lightEntry) { byte[] LightData = GetLightBytes(); @@ -919,6 +936,7 @@ namespace OpenSim.Framework Array.Copy(LightData, 0, returnbytes, i, LightData.Length); i += LightData.Length; } + if (_sculptEntry) { byte[] SculptData = GetSculptBytes(); @@ -933,6 +951,7 @@ namespace OpenSim.Framework Array.Copy(SculptData, 0, returnbytes, i, SculptData.Length); i += SculptData.Length; } + if (_projectionEntry) { byte[] ProjectionData = GetProjectionBytes(); @@ -946,6 +965,7 @@ namespace OpenSim.Framework Array.Copy(ProjectionData, 0, returnbytes, i, ProjectionData.Length); i += ProjectionData.Length; } + if (!_flexiEntry && !_lightEntry && !_sculptEntry && !_projectionEntry) { byte[] returnbyte = new byte[1]; @@ -953,10 +973,7 @@ namespace OpenSim.Framework return returnbyte; } - return returnbytes; - //m_log.Info("[EXTRAPARAMS]: Length = " + m_shape.ExtraParams.Length.ToString()); - } public void ReadInUpdateExtraParam(ushort type, bool inUse, byte[] data) @@ -1027,7 +1044,6 @@ namespace OpenSim.Framework extraParamCount = data[i++]; } - for (int k = 0; k < extraParamCount; k++) { ushort epType = Utils.BytesToUInt16(data, i); @@ -1071,7 +1087,6 @@ namespace OpenSim.Framework _sculptEntry = false; if (!lGotFilter) _projectionEntry = false; - } public void ReadSculptData(byte[] data, int pos) @@ -1100,6 +1115,7 @@ namespace OpenSim.Framework if (_sculptType != (byte)1 && _sculptType != (byte)2 && _sculptType != (byte)3 && _sculptType != (byte)4) _sculptType = 4; } + _sculptTexture = SculptUUID; _sculptType = SculptTypel; //m_log.Info("[SCULPT]:" + SculptUUID.ToString()); diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs index 3809f84..15ed3b3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs @@ -250,11 +250,9 @@ namespace OpenSim.Region.ClientStack.Linden case 0x40: pbs.ReadProjectionData(extraParam.ExtraParamData, 0); break; - } - - } + pbs.PathBegin = (ushort) obj.PathBegin; pbs.PathCurve = (byte) obj.PathCurve; pbs.PathEnd = (ushort) obj.PathEnd; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index cd5046a..307c92a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2958,7 +2958,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public void SculptTextureCallback(UUID textureID, AssetBase texture) { if (m_shape.SculptEntry) diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index fcf7e0c..c18c93a 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -1001,6 +1001,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization private static void ProcessShpSculptData(PrimitiveBaseShape shp, XmlTextReader reader) { +// m_log.DebugFormat("[SCENE OBJECT SERIALIZER]: Setting sculpt data length {0}", shp.SculptData.Length); + shp.SculptData = Convert.FromBase64String(reader.ReadElementString("SculptData")); } diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index e92e97b..b79e1a1 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -540,7 +540,6 @@ namespace OpenSim.Region.Physics.Meshing profileBegin = 0.5f * profileBegin + 0.5f; profileEnd = 0.5f * profileEnd + 0.5f; - } int hollowSides = sides; @@ -660,7 +659,9 @@ namespace OpenSim.Region.Physics.Meshing public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical) { -// m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName); +#if SPAM + m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName); +#endif Mesh mesh = null; ulong key = 0; 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