force allocation of mesh data on creation ( messy code version )
parent
5ef48c5980
commit
8717541288
|
@ -2190,7 +2190,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
convex = false;
|
||||
try
|
||||
{
|
||||
_mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, (int)LevelOfDetail.High, true,convex);
|
||||
_mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, (int)LevelOfDetail.High, true,convex,false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -2557,7 +2557,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
try
|
||||
{
|
||||
mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, (int)LevelOfDetail.High, true, convex);
|
||||
mesh = _parent_scene.mesher.CreateMesh(oldname, _pbs, _size, (int)LevelOfDetail.High, true, convex,false);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace OpenSim.Region.Physics.Manager
|
|||
{
|
||||
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod);
|
||||
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical);
|
||||
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex);
|
||||
IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex, bool forOde);
|
||||
IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex);
|
||||
void ReleaseMesh(IMesh mesh);
|
||||
void ExpireReleaseMeshs();
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace OpenSim.Region.Physics.Manager
|
|||
return CreateMesh(primName, primShape, size, lod, false);
|
||||
}
|
||||
|
||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex)
|
||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex,bool forOde)
|
||||
{
|
||||
return CreateMesh(primName, primShape, size, lod, false);
|
||||
}
|
||||
|
|
|
@ -259,6 +259,7 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
public void getVertexListAsPtrToFloatArray(out IntPtr vertices, out int vertexStride, out int vertexCount)
|
||||
{
|
||||
// A vertex is 3 floats
|
||||
|
||||
vertexStride = 3 * sizeof(float);
|
||||
|
||||
// If there isn't an unmanaged array allocated yet, do it now
|
||||
|
|
|
@ -702,10 +702,11 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
return CreateMesh(primName, primShape, size, lod, false);
|
||||
}
|
||||
|
||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex)
|
||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex, bool forOde)
|
||||
{
|
||||
return CreateMesh(primName, primShape, size, lod, false);
|
||||
}
|
||||
|
||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
|
||||
{
|
||||
#if SPAM
|
||||
|
|
|
@ -315,6 +315,32 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
return result;
|
||||
}
|
||||
|
||||
public void PrepForOde()
|
||||
{
|
||||
// If there isn't an unmanaged array allocated yet, do it now
|
||||
if (m_verticesPtr == IntPtr.Zero)
|
||||
{
|
||||
float[] vertexList = getVertexListAsFloat();
|
||||
// Each vertex is 3 elements (floats)
|
||||
m_vertexCount = vertexList.Length / 3;
|
||||
int byteCount = m_vertexCount * 3 * sizeof(float);
|
||||
m_verticesPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(byteCount);
|
||||
System.Runtime.InteropServices.Marshal.Copy(vertexList, 0, m_verticesPtr, m_vertexCount * 3);
|
||||
}
|
||||
|
||||
// If there isn't an unmanaged array allocated yet, do it now
|
||||
if (m_indicesPtr == IntPtr.Zero)
|
||||
{
|
||||
int[] indexList = getIndexListAsInt();
|
||||
m_indexCount = indexList.Length;
|
||||
int byteCount = m_indexCount * sizeof(int);
|
||||
m_indicesPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(byteCount);
|
||||
System.Runtime.InteropServices.Marshal.Copy(indexList, 0, m_indicesPtr, m_indexCount);
|
||||
}
|
||||
|
||||
releaseSourceMeshData();
|
||||
}
|
||||
|
||||
public void getVertexListAsPtrToFloatArray(out IntPtr vertices, out int vertexStride, out int vertexCount)
|
||||
{
|
||||
// A vertex is 3 floats
|
||||
|
|
|
@ -993,12 +993,12 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
|
||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod)
|
||||
{
|
||||
return CreateMesh(primName, primShape, size, lod, false,false);
|
||||
return CreateMesh(primName, primShape, size, lod, false,false,false);
|
||||
}
|
||||
|
||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical)
|
||||
{
|
||||
return CreateMesh(primName, primShape, size, lod, false,false);
|
||||
return CreateMesh(primName, primShape, size, lod, false,false,false);
|
||||
}
|
||||
|
||||
private static Vector3 m_MeshUnitSize = new Vector3(0.5f, 0.5f, 0.5f);
|
||||
|
@ -1039,7 +1039,7 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
return null;
|
||||
}
|
||||
|
||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex)
|
||||
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex, bool forOde)
|
||||
{
|
||||
#if SPAM
|
||||
m_log.DebugFormat("[MESH]: Creating mesh for {0}", primName);
|
||||
|
@ -1094,8 +1094,14 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
mesh.DumpRaw(baseDir, primName, "Z extruded");
|
||||
}
|
||||
|
||||
// trim the vertex and triangle lists to free up memory
|
||||
mesh.TrimExcess();
|
||||
if (forOde)
|
||||
{
|
||||
// force pinned mem allocation
|
||||
mesh.PrepForOde();
|
||||
}
|
||||
else
|
||||
mesh.TrimExcess();
|
||||
|
||||
mesh.Key = key;
|
||||
mesh.RefCount = 1;
|
||||
|
||||
|
|
|
@ -518,7 +518,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
}
|
||||
|
||||
mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, convex);
|
||||
mesh = m_mesher.CreateMesh(actor.Name, pbs, size, clod, true, convex,true);
|
||||
}
|
||||
|
||||
repData.mesh = mesh;
|
||||
|
|
|
@ -1385,7 +1385,6 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
int vertexCount, indexCount;
|
||||
int vertexStride, triStride;
|
||||
|
||||
|
||||
IMesh mesh = m_mesh;
|
||||
|
||||
if (mesh == null)
|
||||
|
|
Loading…
Reference in New Issue