* 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[] getIndexListAsInt();
|
||||||
int[] getIndexListAsIntLocked();
|
int[] getIndexListAsIntLocked();
|
||||||
float[] getVertexListAsFloatLocked();
|
float[] getVertexListAsFloatLocked();
|
||||||
|
void releasePinned();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,8 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
{
|
{
|
||||||
public List<Vertex> vertices;
|
public List<Vertex> vertices;
|
||||||
public List<Triangle> triangles;
|
public List<Triangle> triangles;
|
||||||
|
GCHandle pinnedVirtexes;
|
||||||
|
GCHandle pinnedIndex;
|
||||||
public float[] normals;
|
public float[] normals;
|
||||||
|
|
||||||
public Mesh()
|
public Mesh()
|
||||||
|
@ -164,7 +165,7 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
result[3*i + 1] = v.Y;
|
result[3*i + 1] = v.Y;
|
||||||
result[3*i + 2] = v.Z;
|
result[3*i + 2] = v.Z;
|
||||||
}
|
}
|
||||||
GCHandle.Alloc(result, GCHandleType.Pinned);
|
pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,10 +185,17 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
public int[] getIndexListAsIntLocked()
|
public int[] getIndexListAsIntLocked()
|
||||||
{
|
{
|
||||||
int[] result = getIndexListAsInt();
|
int[] result = getIndexListAsInt();
|
||||||
GCHandle.Alloc(result, GCHandleType.Pinned);
|
pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void releasePinned()
|
||||||
|
{
|
||||||
|
pinnedVirtexes.Free();
|
||||||
|
pinnedIndex.Free();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void Append(Mesh newMesh)
|
public void Append(Mesh newMesh)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,6 +69,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
private float PID_G = 25f;
|
private float PID_G = 25f;
|
||||||
private float m_tensor = 5f;
|
private float m_tensor = 5f;
|
||||||
private int body_autodisable_frames = 20;
|
private int body_autodisable_frames = 20;
|
||||||
|
private IMesh primMesh = null;
|
||||||
|
|
||||||
private bool m_usePID = false;
|
private bool m_usePID = false;
|
||||||
|
|
||||||
|
@ -674,8 +675,13 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
disableBody();
|
disableBody();
|
||||||
}
|
}
|
||||||
|
|
||||||
float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory
|
IMesh oldMesh = primMesh;
|
||||||
int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage
|
|
||||||
|
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 VertexCount = vertexList.GetLength(0)/3;
|
||||||
int IndexCount = indexList.GetLength(0);
|
int IndexCount = indexList.GetLength(0);
|
||||||
|
|
||||||
|
@ -699,6 +705,13 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
m_log.Error("[PHYSICS]: MESH LOCKED");
|
m_log.Error("[PHYSICS]: MESH LOCKED");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldMesh != null)
|
||||||
|
{
|
||||||
|
oldMesh.releasePinned();
|
||||||
|
oldMesh = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsPhysical && Body == (IntPtr) 0)
|
if (IsPhysical && Body == (IntPtr) 0)
|
||||||
{
|
{
|
||||||
// Recreate the body
|
// Recreate the body
|
||||||
|
|
Loading…
Reference in New Issue