mantis 8384: try to fix bullet heimap managed memory sharing with unmanaged lib

0.9.1.0-post-fixes
UbitUmarov 2018-10-03 21:17:23 +01:00
parent 57ae99b113
commit 1bcdcc2419
3 changed files with 10 additions and 1 deletions

View File

@ -136,6 +136,7 @@ public sealed class BSTerrainHeightmap : BSTerrainPhys
// Frees both the body and the shape. // Frees both the body and the shape.
m_physicsScene.PE.DestroyObject(m_physicsScene.World, m_mapInfo.terrainBody); m_physicsScene.PE.DestroyObject(m_physicsScene.World, m_mapInfo.terrainBody);
} }
m_mapInfo.Release();
} }
m_mapInfo = null; m_mapInfo = null;
} }

View File

@ -27,6 +27,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Runtime.InteropServices;
using OMV = OpenMetaverse; using OMV = OpenMetaverse;
namespace OpenSim.Region.PhysicsModule.BulletS namespace OpenSim.Region.PhysicsModule.BulletS
@ -169,7 +170,7 @@ public class BulletHMapInfo
public BulletHMapInfo(uint id, float[] hm, float pSizeX, float pSizeY) { public BulletHMapInfo(uint id, float[] hm, float pSizeX, float pSizeY) {
ID = id; ID = id;
heightMap = hm; heightMap = hm;
terrainRegionBase = OMV.Vector3.Zero; heightMapHandle = GCHandle.Alloc(heightMap, GCHandleType.Pinned);
minCoords = new OMV.Vector3(100f, 100f, 25f); minCoords = new OMV.Vector3(100f, 100f, 25f);
maxCoords = new OMV.Vector3(101f, 101f, 26f); maxCoords = new OMV.Vector3(101f, 101f, 26f);
minZ = maxZ = 0f; minZ = maxZ = 0f;
@ -185,6 +186,13 @@ public class BulletHMapInfo
public float minZ, maxZ; public float minZ, maxZ;
public BulletShape terrainShape; public BulletShape terrainShape;
public BulletBody terrainBody; public BulletBody terrainBody;
private GCHandle heightMapHandle;
public void Release()
{
if(heightMapHandle.IsAllocated)
heightMapHandle.Free();
}
} }
// The general class of collsion object. // The general class of collsion object.

Binary file not shown.