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
0.6.0-stable
Dahlia Trimble 2008-07-12 01:58:20 +00:00
parent d85774c101
commit 13399ff439
4 changed files with 23 additions and 21 deletions

View File

@ -621,7 +621,7 @@ namespace OpenSim.Region.Physics.BulletXPlugin
} }
else 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); result = AddPrim(primName, position, size, rotation, mesh, pbs, isPhysical);
} }
break; break;

View File

@ -2178,31 +2178,33 @@ namespace OpenSim.Region.Physics.Meshing
//} //}
if (mesh != null) 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 #if SPAM
Console.WriteLine("Meshmerizer: prim " + primName + " has a size of " + size.ToString() + " which is below threshold of " + minSizeForComplexMesh.ToString() + " - creating simple bounding box" ); Console.WriteLine("Meshmerizer: prim " + primName + " has a size of " + size.ToString() + " which is below threshold of " + minSizeForComplexMesh.ToString() + " - creating simple bounding box" );
#endif #endif
mesh = CreateBoundingBoxMesh(mesh); mesh = CreateBoundingBoxMesh(mesh);
mesh.DumpRaw(baseDir, primName, "Z extruded"); 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; return mesh;
} }

View File

@ -922,7 +922,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (_parent_scene.needsMeshing(_pbs)) 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 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. // createmesh returns null when it's a shape that isn't a cube.
} }
} }
@ -1496,7 +1496,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (IsPhysical) if (IsPhysical)
meshlod = _parent_scene.MeshSculptphysicalLOD; 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. // createmesh returns null when it's a shape that isn't a cube.
if (mesh != null) if (mesh != null)
{ {

View File

@ -1177,7 +1177,7 @@ namespace OpenSim.Region.Physics.OdePlugin
/// support simple box & hollow box now; later, more shapes /// support simple box & hollow box now; later, more shapes
if (needsMeshing(pbs)) if (needsMeshing(pbs))
{ {
mesh = mesher.CreateMesh(primName, pbs, size, 32f); mesh = mesher.CreateMesh(primName, pbs, size, 32f, isPhysical);
} }
break; break;