From 13399ff4393b0fbf6e2caf79542f62e9b4ba4281 Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Sat, 12 Jul 2008 01:58:20 +0000 Subject: [PATCH] Passes prim physical status to mesher from physics plugins Small prims now get a full mesh if they are physical Fixed a logic bug that was preventing many prim meshes from having excess memory cleaned up Switched to more conservative method of vertex and triangle list trimming to prevent possible crash --- .../Physics/BulletXPlugin/BulletXPlugin.cs | 2 +- OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 36 ++++++++++--------- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 4 +-- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 2 +- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 144ad536f3..5ef196f612 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -621,7 +621,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin } else { - IMesh mesh = mesher.CreateMesh(primName, pbs, size, 32f); + IMesh mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical); result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical); } break; diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 42b6a90cf0..045a25d034 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -2178,31 +2178,33 @@ namespace OpenSim.Region.Physics.Meshing //} if (mesh != null) - if (size.X < minSizeForComplexMesh && size.Y < minSizeForComplexMesh && size.Z < minSizeForComplexMesh) + { + if ((!isPhysical) && size.X < minSizeForComplexMesh && size.Y < minSizeForComplexMesh && size.Z < minSizeForComplexMesh) { #if SPAM Console.WriteLine("Meshmerizer: prim " + primName + " has a size of " + size.ToString() + " which is below threshold of " + minSizeForComplexMesh.ToString() + " - creating simple bounding box" ); #endif mesh = CreateBoundingBoxMesh(mesh); mesh.DumpRaw(baseDir, primName, "Z extruded"); - - // trim the vertex and triangle lists to free up memory - //mesh.vertices.TrimExcess(); - //mesh.triangles.TrimExcess(); - - int vertCount = 0; - foreach (Vertex v in mesh.vertices) - if (v != null) - vertCount++; - mesh.vertices.Capacity = vertCount; - - int triCount = 0; - foreach (Triangle t in mesh.triangles) - if ( t != null ) - triCount++; - mesh.triangles.Capacity = triCount; } + // trim the vertex and triangle lists to free up memory + mesh.vertices.TrimExcess(); + mesh.triangles.TrimExcess(); + + //int vertCount = 0; + //foreach (Vertex v in mesh.vertices) + // if (v != null) + // vertCount++; + //mesh.vertices.Capacity = vertCount; + + //int triCount = 0; + //foreach (Triangle t in mesh.triangles) + // if (t != null) + // triCount++; + //mesh.triangles.Capacity = triCount; + } + return mesh; } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index d063507547..f7fbaf11fb 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -922,7 +922,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (_parent_scene.needsMeshing(_pbs)) { // Don't need to re-enable body.. it's done in SetMesh - _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD); + _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD, IsPhysical); // createmesh returns null when it's a shape that isn't a cube. } } @@ -1496,7 +1496,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (IsPhysical) meshlod = _parent_scene.MeshSculptphysicalLOD; - IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod); + IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); // createmesh returns null when it's a shape that isn't a cube. if (mesh != null) { diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 3dd80ea975..cd5032c198 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -1177,7 +1177,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// support simple box & hollow box now; later, more shapes if (needsMeshing(pbs)) { - mesh = mesher.CreateMesh(primName, pbs, size, 32f); + mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical); } break;