A few blind changes to go try to go around bad mesh little box replacement fail

avinationmerge
UbitUmarov 2012-02-28 20:14:26 +00:00
parent 9bad3b846f
commit 1c7700db88
1 changed files with 50 additions and 67 deletions

View File

@ -1804,22 +1804,18 @@ namespace OpenSim.Region.Physics.OdePlugin
mesh.getVertexListAsPtrToFloatArray(out vertices, out vertexStride, out vertexCount); // Note, that vertices are fixed in unmanaged heap mesh.getVertexListAsPtrToFloatArray(out vertices, out vertexStride, out vertexCount); // Note, that vertices are fixed in unmanaged heap
mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage
// warning this destroys the mesh for eventual future use. Only pinned float arrays stay valid
mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
if (vertexCount == 0 || indexCount == 0) if (vertexCount == 0 || indexCount == 0)
{ {
m_log.WarnFormat("[PHYSICS]: Got invalid mesh on prim {0} at <{1},{2},{3}>. It can be a sculp with alpha channel in map. Replacing it by a small box.", Name, _position.X, _position.Y, _position.Z); m_log.WarnFormat("[PHYSICS]: Got invalid mesh on prim {0} at <{1},{2},{3}>. It can be a sculp with alpha channel in map. Replacing it by a small box.", Name, _position.X, _position.Y, _position.Z);
_size.X = 0.01f; _size.X = 0.01f;
_size.Y = 0.01f; _size.Y = 0.01f;
_size.Z = 0.01f; _size.Z = 0.01f;
mesh.releaseSourceMeshData(); return false;
// Temporarily hacking this to true which causes the object
// to get no physical representation, effectively making it
// phantom
return true;
} }
// warning this destroys the mesh for eventual future use. Only pinned float arrays stay valid
mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
/* /*
if (m_MeshToTriMeshMap.ContainsKey(mesh)) if (m_MeshToTriMeshMap.ContainsKey(mesh))
{ {
@ -1846,16 +1842,18 @@ namespace OpenSim.Region.Physics.OdePlugin
SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null)); SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, null, null, null));
// } // }
} }
catch (AccessViolationException) catch (Exception e)
{ {
m_log.Error("[PHYSICS]: MESH LOCKED"); m_log.ErrorFormat("[PHYSICS]: Create trimesh failed on prim {0} : {1}",Name,e.Message);
if (_triMeshData != IntPtr.Zero) if (_triMeshData != IntPtr.Zero)
{ {
d.GeomTriMeshDataDestroy(_triMeshData); d.GeomTriMeshDataDestroy(_triMeshData);
_triMeshData = IntPtr.Zero; _triMeshData = IntPtr.Zero;
} }
_size.X = 0.01f;
_size.Y = 0.01f;
_size.Z = 0.01f;
return false; return false;
} }
@ -1878,6 +1876,9 @@ namespace OpenSim.Region.Physics.OdePlugin
changeadd(timestep); changeadd(timestep);
} }
if (m_taintremove)
return;
if (prim_geom != IntPtr.Zero) if (prim_geom != IntPtr.Zero)
{ {
if (!_position.ApproxEquals(m_taintposition, 0f)) if (!_position.ApproxEquals(m_taintposition, 0f))
@ -2342,69 +2343,47 @@ namespace OpenSim.Region.Physics.OdePlugin
if (!gottrimesh) // not a mesh if (!gottrimesh) // not a mesh
{ {
if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) // special profile?? IntPtr geo = IntPtr.Zero;
if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1
&& _size.X == _size.Y && _size.X == _size.Z)
{ {
if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) // Equi-size // its a sphere
_parent_scene.waitForSpaceUnlock(m_targetSpace);
try
{ {
if (((_size.X / 2f) > 0f)) // Has size geo = d.CreateSphere(m_targetSpace, _size.X * 0.5f);
}
catch (Exception e)
{
m_log.WarnFormat("[PHYSICS]: Unable to create basic sphere for object {0}", e.Message);
geo = IntPtr.Zero;
ode.dunlock(_parent_scene.world);
}
}
else // make it a box
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace); _parent_scene.waitForSpaceUnlock(m_targetSpace);
try try
{ {
SetGeom(d.CreateSphere(m_targetSpace, _size.X / 2)); geo = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z);
} }
catch (AccessViolationException) catch (Exception e)
{ {
m_log.Warn("[PHYSICS]: Unable to create physics proxy for object"); m_log.WarnFormat("[PHYSICS]: Unable to create basic sphere for object {0}", e.Message);
geo = IntPtr.Zero;
ode.dunlock(_parent_scene.world); ode.dunlock(_parent_scene.world);
return;
}
}
else
{
_parent_scene.waitForSpaceUnlock(m_targetSpace);
try
{
SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
}
catch (AccessViolationException)
{
m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
ode.dunlock(_parent_scene.world);
return;
}
}
}
else // not equi-size
{
_parent_scene.waitForSpaceUnlock(m_targetSpace);
try
{
SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
}
catch (AccessViolationException)
{
m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
ode.dunlock(_parent_scene.world);
return;
}
} }
} }
else // not special profile if (geo == IntPtr.Zero)
{ {
_parent_scene.waitForSpaceUnlock(m_targetSpace); m_taintremove = true;
try _parent_scene.AddPhysicsActorTaint(this);
{
SetGeom(d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z));
}
catch (AccessViolationException)
{
m_log.Warn("[PHYSICS]: Unable to create physics proxy for object");
ode.dunlock(_parent_scene.world);
return; return;
} }
}
SetGeom(geo);
} }
} }
@ -2422,7 +2401,6 @@ 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
try try
{ {
_mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, (int)LevelOfDetail.High, true); _mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, (int)LevelOfDetail.High, true);
@ -2431,9 +2409,9 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
//Don't continuously try to mesh prims when meshing has failed //Don't continuously try to mesh prims when meshing has failed
m_meshfailed = true; m_meshfailed = true;
_mesh = null;
m_log.WarnFormat("[PHYSICS]: changeAdd CreateMesh fail on prim {0} at <{1},{2},{3}>", Name, _position.X, _position.Y, _position.Z);
} }
// createmesh returns null when it's a shape that isn't a cube.
// m_log.Debug(m_localID);
} }
} }
@ -2685,12 +2663,12 @@ namespace OpenSim.Region.Physics.OdePlugin
catch catch
{ {
m_meshfailed = true; m_meshfailed = true;
mesh = null;
m_log.WarnFormat("[PHYSICS]: changeSize CreateMesh fail on prim {0} at <{1},{2},{3}>", Name, _position.X, _position.Y, _position.Z);
} }
//IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical); //IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, meshlod, IsPhysical);
CreateGeom(m_targetSpace, mesh); CreateGeom(m_targetSpace, mesh);
} }
else else
{ {
@ -2782,18 +2760,23 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
// Don't need to re-enable body.. it's done in SetMesh // Don't need to re-enable body.. it's done in SetMesh
float meshlod = _parent_scene.meshSculptLOD; float meshlod = _parent_scene.meshSculptLOD;
IMesh mesh;
if (IsPhysical) if (IsPhysical)
meshlod = _parent_scene.MeshSculptphysicalLOD; meshlod = _parent_scene.MeshSculptphysicalLOD;
try try
{ {
IMesh mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, (int)LevelOfDetail.High, true); mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, (int)LevelOfDetail.High, true);
CreateGeom(m_targetSpace, mesh);
} }
catch catch
{ {
mesh = null;
m_meshfailed = true; m_meshfailed = true;
m_log.WarnFormat("[PHYSICS]: changeAdd CreateMesh fail on prim {0} at <{1},{2},{3}>", Name, _position.X, _position.Y, _position.Z);
} }
CreateGeom(m_targetSpace, mesh);
// createmesh returns null when it doesn't mesh. // createmesh returns null when it doesn't mesh.
} }
else else