* Releases Pinned vertex/index list in ODE on next mesh request.

0.6.0-stable
Teravus Ovares 2008-05-25 02:39:58 +00:00
parent 86c46e92cd
commit d3b013be1c
3 changed files with 28 additions and 5 deletions

View File

@ -46,5 +46,7 @@ namespace OpenSim.Region.Physics.Manager
int[] getIndexListAsInt();
int[] getIndexListAsIntLocked();
float[] getVertexListAsFloatLocked();
void releasePinned();
}
}

View File

@ -37,7 +37,8 @@ namespace OpenSim.Region.Physics.Meshing
{
public List<Vertex> vertices;
public List<Triangle> triangles;
GCHandle pinnedVirtexes;
GCHandle pinnedIndex;
public float[] normals;
public Mesh()
@ -164,7 +165,7 @@ namespace OpenSim.Region.Physics.Meshing
result[3*i + 1] = v.Y;
result[3*i + 2] = v.Z;
}
GCHandle.Alloc(result, GCHandleType.Pinned);
pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
return result;
}
@ -184,10 +185,17 @@ namespace OpenSim.Region.Physics.Meshing
public int[] getIndexListAsIntLocked()
{
int[] result = getIndexListAsInt();
GCHandle.Alloc(result, GCHandleType.Pinned);
pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned);
return result;
}
public void releasePinned()
{
pinnedVirtexes.Free();
pinnedIndex.Free();
}
public void Append(Mesh newMesh)
{

View File

@ -69,6 +69,7 @@ namespace OpenSim.Region.Physics.OdePlugin
private float PID_G = 25f;
private float m_tensor = 5f;
private int body_autodisable_frames = 20;
private IMesh primMesh = null;
private bool m_usePID = false;
@ -674,8 +675,13 @@ namespace OpenSim.Region.Physics.OdePlugin
disableBody();
}
float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
IMesh oldMesh = primMesh;
primMesh = mesh;
float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
int VertexCount = vertexList.GetLength(0)/3;
int IndexCount = indexList.GetLength(0);
@ -699,6 +705,13 @@ namespace OpenSim.Region.Physics.OdePlugin
m_log.Error("[PHYSICS]: MESH LOCKED");
return;
}
if (oldMesh != null)
{
oldMesh.releasePinned();
oldMesh = null;
}
if (IsPhysical && Body == (IntPtr) 0)
{
// Recreate the body