* Releases Pinned vertex/index list in ODE on next mesh request.
parent
86c46e92cd
commit
d3b013be1c
|
@ -46,5 +46,7 @@ namespace OpenSim.Region.Physics.Manager
|
|||
int[] getIndexListAsInt();
|
||||
int[] getIndexListAsIntLocked();
|
||||
float[] getVertexListAsFloatLocked();
|
||||
void releasePinned();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue