Fix memory leaks in demos
This commit is contained in:
Родитель
a5a7b6bf0a
Коммит
f7d0755ddc
|
@ -18,7 +18,7 @@
|
||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>TRACE;DEBUG;BULLET_OBJECT_TRACKING</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
<Optimize>true</Optimize>
|
<Optimize>true</Optimize>
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE;BULLET_OBJECT_TRACKING</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
|
|
@ -178,9 +178,7 @@ namespace BulletSharp
|
||||||
|
|
||||||
public class TriangleIndexVertexArray : StridingMeshInterface
|
public class TriangleIndexVertexArray : StridingMeshInterface
|
||||||
{
|
{
|
||||||
private List<IndexedMesh> _meshes = new List<IndexedMesh>();
|
|
||||||
private IndexedMesh _initialMesh;
|
private IndexedMesh _initialMesh;
|
||||||
private AlignedIndexedMeshArray _indexedMeshArray;
|
|
||||||
|
|
||||||
internal TriangleIndexVertexArray(ConstructionInfo info)
|
internal TriangleIndexVertexArray(ConstructionInfo info)
|
||||||
{
|
{
|
||||||
|
@ -190,12 +188,14 @@ namespace BulletSharp
|
||||||
{
|
{
|
||||||
IntPtr native = btTriangleIndexVertexArray_new();
|
IntPtr native = btTriangleIndexVertexArray_new();
|
||||||
InitializeUserOwned(native);
|
InitializeUserOwned(native);
|
||||||
|
InitializeMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TriangleIndexVertexArray(ICollection<int> triangles, ICollection<float> vertices)
|
public TriangleIndexVertexArray(ICollection<int> triangles, ICollection<float> vertices)
|
||||||
{
|
{
|
||||||
IntPtr native = btTriangleIndexVertexArray_new();
|
IntPtr native = btTriangleIndexVertexArray_new();
|
||||||
InitializeUserOwned(native);
|
InitializeUserOwned(native);
|
||||||
|
InitializeMembers();
|
||||||
|
|
||||||
_initialMesh = new IndexedMesh();
|
_initialMesh = new IndexedMesh();
|
||||||
_initialMesh.Allocate(triangles.Count / 3, vertices.Count / 3);
|
_initialMesh.Allocate(triangles.Count / 3, vertices.Count / 3);
|
||||||
|
@ -207,6 +207,7 @@ namespace BulletSharp
|
||||||
{
|
{
|
||||||
IntPtr native = btTriangleIndexVertexArray_new();
|
IntPtr native = btTriangleIndexVertexArray_new();
|
||||||
InitializeUserOwned(native);
|
InitializeUserOwned(native);
|
||||||
|
InitializeMembers();
|
||||||
|
|
||||||
_initialMesh = new IndexedMesh();
|
_initialMesh = new IndexedMesh();
|
||||||
_initialMesh.Allocate(triangles.Count / 3, vertices.Count);
|
_initialMesh.Allocate(triangles.Count / 3, vertices.Count);
|
||||||
|
@ -218,26 +219,21 @@ namespace BulletSharp
|
||||||
{
|
{
|
||||||
IntPtr native = btTriangleIndexVertexArray_new2(numTriangles, triangleIndexBase, triangleIndexStride, numVertices, vertexBase, vertexStride);
|
IntPtr native = btTriangleIndexVertexArray_new2(numTriangles, triangleIndexBase, triangleIndexStride, numVertices, vertexBase, vertexStride);
|
||||||
InitializeUserOwned(native);
|
InitializeUserOwned(native);
|
||||||
|
InitializeMembers();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected internal void InitializeMembers()
|
||||||
|
{
|
||||||
|
IndexedMeshArray = new AlignedIndexedMeshArray(btTriangleIndexVertexArray_getIndexedMeshArray(Native), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddIndexedMesh(IndexedMesh mesh, PhyScalarType indexType = PhyScalarType.Int32)
|
public void AddIndexedMesh(IndexedMesh mesh, PhyScalarType indexType = PhyScalarType.Int32)
|
||||||
{
|
{
|
||||||
_meshes.Add(mesh);
|
mesh.IndexType = indexType;
|
||||||
btTriangleIndexVertexArray_addIndexedMesh(Native, mesh.Native, indexType);
|
IndexedMeshArray.Add(mesh);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlignedIndexedMeshArray IndexedMeshArray
|
public AlignedIndexedMeshArray IndexedMeshArray { get; private set; }
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
// TODO: link _indexedMeshArray to _meshes
|
|
||||||
if (_indexedMeshArray == null)
|
|
||||||
{
|
|
||||||
_indexedMeshArray = new AlignedIndexedMeshArray(btTriangleIndexVertexArray_getIndexedMeshArray(Native));
|
|
||||||
}
|
|
||||||
return _indexedMeshArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace BulletSharp
|
||||||
{
|
{
|
||||||
IntPtr native = btTriangleMesh_new(use32BitIndices, use4ComponentVertices);
|
IntPtr native = btTriangleMesh_new(use32BitIndices, use4ComponentVertices);
|
||||||
InitializeUserOwned(native);
|
InitializeUserOwned(native);
|
||||||
|
InitializeMembers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddIndex(int index)
|
public void AddIndex(int index)
|
||||||
|
@ -18,12 +19,12 @@ namespace BulletSharp
|
||||||
btTriangleMesh_addIndex(Native, index);
|
btTriangleMesh_addIndex(Native, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTriangleRef(ref Vector3 vertex0, ref Vector3 vertex1, ref Vector3 vertex2,
|
public void AddTriangleRef(ref Vector3 vertex0, ref Vector3 vertex1, ref Vector3 vertex2,
|
||||||
bool removeDuplicateVertices = false)
|
bool removeDuplicateVertices = false)
|
||||||
{
|
{
|
||||||
btTriangleMesh_addTriangle(Native, ref vertex0, ref vertex1, ref vertex2,
|
btTriangleMesh_addTriangle(Native, ref vertex0, ref vertex1, ref vertex2,
|
||||||
removeDuplicateVertices);
|
removeDuplicateVertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddTriangle(Vector3 vertex0, Vector3 vertex1, Vector3 vertex2,
|
public void AddTriangle(Vector3 vertex0, Vector3 vertex1, Vector3 vertex2,
|
||||||
bool removeDuplicateVertices = false)
|
bool removeDuplicateVertices = false)
|
||||||
|
|
|
@ -103,9 +103,11 @@ namespace BulletSharp
|
||||||
start = Matrix.Translation(m_currentPosition + upAxisDirection[m_upAxis] * (m_convexShape.Margin + m_addedMargin));
|
start = Matrix.Translation(m_currentPosition + upAxisDirection[m_upAxis] * (m_convexShape.Margin + m_addedMargin));
|
||||||
end = Matrix.Translation(m_targetPosition);
|
end = Matrix.Translation(m_targetPosition);
|
||||||
|
|
||||||
KinematicClosestNotMeConvexResultCallback callback = new KinematicClosestNotMeConvexResultCallback(m_ghostObject, -upAxisDirection[m_upAxis], 0.7071f);
|
var callback = new KinematicClosestNotMeConvexResultCallback(m_ghostObject, -upAxisDirection[m_upAxis], 0.7071f)
|
||||||
callback.CollisionFilterGroup = GhostObject.BroadphaseHandle.CollisionFilterGroup;
|
{
|
||||||
callback.CollisionFilterMask = GhostObject.BroadphaseHandle.CollisionFilterMask;
|
CollisionFilterGroup = GhostObject.BroadphaseHandle.CollisionFilterGroup,
|
||||||
|
CollisionFilterMask = GhostObject.BroadphaseHandle.CollisionFilterMask
|
||||||
|
};
|
||||||
|
|
||||||
if (m_useGhostObjectSweepTest)
|
if (m_useGhostObjectSweepTest)
|
||||||
{
|
{
|
||||||
|
@ -141,6 +143,7 @@ namespace BulletSharp
|
||||||
m_currentPosition = m_targetPosition;
|
m_currentPosition = m_targetPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
callback.Dispose();
|
||||||
}
|
}
|
||||||
protected void UpdateTargetPositionBasedOnCollision(ref Vector3 hitNormal, float tangentMag, float normalMag)
|
protected void UpdateTargetPositionBasedOnCollision(ref Vector3 hitNormal, float tangentMag, float normalMag)
|
||||||
{
|
{
|
||||||
|
@ -758,6 +761,10 @@ namespace BulletSharp
|
||||||
{
|
{
|
||||||
static Vector3 zero = new Vector3();
|
static Vector3 zero = new Vector3();
|
||||||
|
|
||||||
|
protected CollisionObject _me;
|
||||||
|
protected Vector3 _up;
|
||||||
|
protected float _minSlopeDot;
|
||||||
|
|
||||||
public KinematicClosestNotMeConvexResultCallback(CollisionObject me, Vector3 up, float minSlopeDot)
|
public KinematicClosestNotMeConvexResultCallback(CollisionObject me, Vector3 up, float minSlopeDot)
|
||||||
: base(ref zero, ref zero)
|
: base(ref zero, ref zero)
|
||||||
{
|
{
|
||||||
|
@ -798,9 +805,5 @@ namespace BulletSharp
|
||||||
|
|
||||||
return base.AddSingleResult(convexResult, normalInWorldSpace);
|
return base.AddSingleResult(convexResult, normalInWorldSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CollisionObject _me;
|
|
||||||
protected Vector3 _up;
|
|
||||||
protected float _minSlopeDot;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,14 +65,29 @@ namespace BulletSharp
|
||||||
[Serializable, DebuggerTypeProxy(typeof(AlignedIndexedMeshArrayDebugView)), DebuggerDisplay("Count = {Count}")]
|
[Serializable, DebuggerTypeProxy(typeof(AlignedIndexedMeshArrayDebugView)), DebuggerDisplay("Count = {Count}")]
|
||||||
public class AlignedIndexedMeshArray : BulletObject, IList<IndexedMesh>
|
public class AlignedIndexedMeshArray : BulletObject, IList<IndexedMesh>
|
||||||
{
|
{
|
||||||
internal AlignedIndexedMeshArray(IntPtr native)
|
private List<IndexedMesh> _backingList = new List<IndexedMesh>();
|
||||||
|
private readonly TriangleIndexVertexArray _triangleIndexVertexArray;
|
||||||
|
|
||||||
|
internal AlignedIndexedMeshArray(IntPtr native, TriangleIndexVertexArray triangleIndexVertexArray)
|
||||||
{
|
{
|
||||||
Initialize(native);
|
Initialize(native);
|
||||||
|
_triangleIndexVertexArray = triangleIndexVertexArray;
|
||||||
|
|
||||||
|
int count = btAlignedObjectArray_btIndexedMesh_size(Native);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
var mesh = new IndexedMesh(btAlignedObjectArray_btIndexedMesh_at(native, i), this);
|
||||||
|
_backingList.Add(mesh);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int IndexOf(IndexedMesh item)
|
public int IndexOf(IndexedMesh item)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (item == null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return _backingList.IndexOf(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Insert(int index, IndexedMesh item)
|
public void Insert(int index, IndexedMesh item)
|
||||||
|
@ -87,14 +102,7 @@ namespace BulletSharp
|
||||||
|
|
||||||
public IndexedMesh this[int index]
|
public IndexedMesh this[int index]
|
||||||
{
|
{
|
||||||
get
|
get => _backingList[index];
|
||||||
{
|
|
||||||
if ((uint)index >= (uint)Count)
|
|
||||||
{
|
|
||||||
throw new ArgumentOutOfRangeException(nameof(index));
|
|
||||||
}
|
|
||||||
return new IndexedMesh(btAlignedObjectArray_btIndexedMesh_at(Native, index), this);
|
|
||||||
}
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
@ -103,17 +111,20 @@ namespace BulletSharp
|
||||||
|
|
||||||
public void Add(IndexedMesh item)
|
public void Add(IndexedMesh item)
|
||||||
{
|
{
|
||||||
btAlignedObjectArray_btIndexedMesh_push_back(Native, item.Native);
|
btTriangleIndexVertexArray_addIndexedMesh(_triangleIndexVertexArray.Native, item.Native, item.IndexType);
|
||||||
|
_backingList.Add(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
btAlignedObjectArray_btIndexedMesh_resizeNoInitialize(Native, 0);
|
btAlignedObjectArray_btIndexedMesh_resizeNoInitialize(Native, 0);
|
||||||
|
_backingList.Clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Contains(IndexedMesh item)
|
public bool Contains(IndexedMesh item)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
return _backingList.Contains(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CopyTo(IndexedMesh[] array, int arrayIndex)
|
public void CopyTo(IndexedMesh[] array, int arrayIndex)
|
||||||
|
@ -126,15 +137,15 @@ namespace BulletSharp
|
||||||
|
|
||||||
int count = Count;
|
int count = Count;
|
||||||
if (arrayIndex + count > array.Length)
|
if (arrayIndex + count > array.Length)
|
||||||
throw new ArgumentException("Array too small.", "array");
|
throw new ArgumentException("Array too small.", nameof(array));
|
||||||
|
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
array[arrayIndex + i] = this[i];
|
array[arrayIndex + i] = _backingList[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Count => btAlignedObjectArray_btIndexedMesh_size(Native);
|
public int Count => _backingList.Count;
|
||||||
|
|
||||||
public bool IsReadOnly => false;
|
public bool IsReadOnly => false;
|
||||||
|
|
||||||
|
@ -145,12 +156,12 @@ namespace BulletSharp
|
||||||
|
|
||||||
public IEnumerator<IndexedMesh> GetEnumerator()
|
public IEnumerator<IndexedMesh> GetEnumerator()
|
||||||
{
|
{
|
||||||
return new AlignedIndexedMeshArrayEnumerator(this);
|
return _backingList.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||||
{
|
{
|
||||||
return new AlignedIndexedMeshArrayEnumerator(this);
|
return _backingList.GetEnumerator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,8 +181,6 @@ namespace BulletSharp
|
||||||
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
|
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
|
||||||
public static extern IntPtr btAlignedObjectArray_btIndexedMesh_at(IntPtr obj, int n);
|
public static extern IntPtr btAlignedObjectArray_btIndexedMesh_at(IntPtr obj, int n);
|
||||||
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
|
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
|
||||||
public static extern void btAlignedObjectArray_btIndexedMesh_push_back(IntPtr obj, IntPtr val);
|
|
||||||
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
|
|
||||||
public static extern void btAlignedObjectArray_btIndexedMesh_resizeNoInitialize(IntPtr obj, int newSize);
|
public static extern void btAlignedObjectArray_btIndexedMesh_resizeNoInitialize(IntPtr obj, int newSize);
|
||||||
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
|
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
|
||||||
public static extern int btAlignedObjectArray_btIndexedMesh_size(IntPtr obj);
|
public static extern int btAlignedObjectArray_btIndexedMesh_size(IntPtr obj);
|
||||||
|
|
|
@ -30,6 +30,9 @@ namespace Box2DDemo
|
||||||
private const int NumObjectsX = 5, NumObjectsY = 5;
|
private const int NumObjectsX = 5, NumObjectsY = 5;
|
||||||
private const float Depth = 0.04f;
|
private const float Depth = 0.04f;
|
||||||
|
|
||||||
|
private readonly VoronoiSimplexSolver _simplexSolver;
|
||||||
|
private readonly MinkowskiPenetrationDepthSolver _penetrationDepthSolver;
|
||||||
|
|
||||||
private readonly Convex2DConvex2DAlgorithm.CreateFunc _convexAlgo2D;
|
private readonly Convex2DConvex2DAlgorithm.CreateFunc _convexAlgo2D;
|
||||||
private readonly Box2DBox2DCollisionAlgorithm.CreateFunc _boxAlgo2D;
|
private readonly Box2DBox2DCollisionAlgorithm.CreateFunc _boxAlgo2D;
|
||||||
|
|
||||||
|
@ -40,10 +43,10 @@ namespace Box2DDemo
|
||||||
// Use the default collision dispatcher. For parallel processing you can use a diffent dispatcher.
|
// Use the default collision dispatcher. For parallel processing you can use a diffent dispatcher.
|
||||||
Dispatcher = new CollisionDispatcher(CollisionConfiguration);
|
Dispatcher = new CollisionDispatcher(CollisionConfiguration);
|
||||||
|
|
||||||
var simplex = new VoronoiSimplexSolver();
|
_simplexSolver = new VoronoiSimplexSolver();
|
||||||
var pdSolver = new MinkowskiPenetrationDepthSolver();
|
_penetrationDepthSolver = new MinkowskiPenetrationDepthSolver();
|
||||||
|
|
||||||
_convexAlgo2D = new Convex2DConvex2DAlgorithm.CreateFunc(simplex, pdSolver);
|
_convexAlgo2D = new Convex2DConvex2DAlgorithm.CreateFunc(_simplexSolver, _penetrationDepthSolver);
|
||||||
_boxAlgo2D = new Box2DBox2DCollisionAlgorithm.CreateFunc();
|
_boxAlgo2D = new Box2DBox2DCollisionAlgorithm.CreateFunc();
|
||||||
|
|
||||||
Dispatcher.RegisterCollisionCreateFunc(BroadphaseNativeType.Convex2DShape, BroadphaseNativeType.Convex2DShape, _convexAlgo2D);
|
Dispatcher.RegisterCollisionCreateFunc(BroadphaseNativeType.Convex2DShape, BroadphaseNativeType.Convex2DShape, _convexAlgo2D);
|
||||||
|
@ -68,6 +71,8 @@ namespace Box2DDemo
|
||||||
{
|
{
|
||||||
_convexAlgo2D.Dispose();
|
_convexAlgo2D.Dispose();
|
||||||
_boxAlgo2D.Dispose();
|
_boxAlgo2D.Dispose();
|
||||||
|
_simplexSolver.Dispose();
|
||||||
|
_penetrationDepthSolver.Dispose();
|
||||||
this.StandardCleanup();
|
this.StandardCleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Debug\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
<Compile Include="BspDemo.cs" />
|
<Compile Include="BspDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
<Compile Include="BulletXmlImportDemo.cs" />
|
<Compile Include="BulletXmlImportDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
<Compile Include="CcdPhysicsDemo.cs" />
|
<Compile Include="CcdPhysicsDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
<Compile Include="CharacterDemo.cs" />
|
<Compile Include="CharacterDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -83,7 +83,7 @@
|
||||||
<Compile Include="CollisionInterfaceDemo.cs" />
|
<Compile Include="CollisionInterfaceDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
<Compile Include="ConcaveConvexCastDemo.cs" />
|
<Compile Include="ConcaveConvexCastDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -82,7 +82,8 @@
|
||||||
<Compile Include="ConcaveRaycastDemo.cs" />
|
<Compile Include="ConcaveRaycastDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
<Compile Include="ConstraintDemo.cs" />
|
<Compile Include="ConstraintDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -84,7 +84,8 @@
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -534,6 +534,7 @@ namespace DemoFramework
|
||||||
vertices[v++] = normal;
|
vertices[v++] = normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hull.Dispose();
|
||||||
return vertices;
|
return vertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -97,7 +97,8 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SharpDX, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
<Reference Include="SharpDX, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1, processorArchitecture=MSIL">
|
||||||
|
|
|
@ -96,7 +96,8 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="SlimDX, Version=4.0.13.43, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86">
|
<Reference Include="SlimDX, Version=4.0.13.43, Culture=neutral, PublicKeyToken=b1b0c32fd1ffe4f9, processorArchitecture=x86">
|
||||||
|
|
|
@ -84,7 +84,7 @@
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
<Compile Include="MotorDemo.cs" />
|
<Compile Include="MotorDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -83,7 +83,8 @@
|
||||||
<Compile Include="MultiThreadedDemo.cs" />
|
<Compile Include="MultiThreadedDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
<Compile Include="PendulumDemo.cs" />
|
<Compile Include="PendulumDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
<Compile Include="RollingFrictionDemo.cs" />
|
<Compile Include="RollingFrictionDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp, Version=0.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
|
|
@ -86,7 +86,8 @@
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
|
|
@ -86,7 +86,8 @@
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
|
|
@ -112,6 +112,8 @@ namespace VehicleDemo
|
||||||
private const float suspensionRestLength = 0.6f;
|
private const float suspensionRestLength = 0.6f;
|
||||||
private const float CUBE_HALF_EXTENTS = 1;
|
private const float CUBE_HALF_EXTENTS = 1;
|
||||||
|
|
||||||
|
private TriangleIndexVertexArray _groundVertexArray;
|
||||||
|
private IndexedMesh _groundMesh;
|
||||||
private IntPtr _terrainData;
|
private IntPtr _terrainData;
|
||||||
|
|
||||||
//private RaycastVehicle _vehicle;
|
//private RaycastVehicle _vehicle;
|
||||||
|
@ -159,6 +161,15 @@ namespace VehicleDemo
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
if (_groundVertexArray != null)
|
||||||
|
{
|
||||||
|
_groundVertexArray.Dispose();
|
||||||
|
}
|
||||||
|
if (_groundMesh != null)
|
||||||
|
{
|
||||||
|
_groundMesh.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
if (_terrainData != IntPtr.Zero)
|
if (_terrainData != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
Marshal.FreeHGlobal(_terrainData);
|
Marshal.FreeHGlobal(_terrainData);
|
||||||
|
@ -200,14 +211,14 @@ namespace VehicleDemo
|
||||||
|
|
||||||
const int totalTriangles = 2 * (NumVertsX - 1) * (NumVertsY - 1);
|
const int totalTriangles = 2 * (NumVertsX - 1) * (NumVertsY - 1);
|
||||||
|
|
||||||
var vertexArray = new TriangleIndexVertexArray();
|
_groundVertexArray = new TriangleIndexVertexArray();
|
||||||
var mesh = new IndexedMesh();
|
_groundMesh = new IndexedMesh();
|
||||||
mesh.Allocate(totalTriangles, totalVerts);
|
_groundMesh.Allocate(totalTriangles, totalVerts);
|
||||||
mesh.NumTriangles = totalTriangles;
|
_groundMesh.NumTriangles = totalTriangles;
|
||||||
mesh.NumVertices = totalVerts;
|
_groundMesh.NumVertices = totalVerts;
|
||||||
mesh.TriangleIndexStride = 3 * sizeof(int);
|
_groundMesh.TriangleIndexStride = 3 * sizeof(int);
|
||||||
mesh.VertexStride = Vector3.SizeInBytes;
|
_groundMesh.VertexStride = Vector3.SizeInBytes;
|
||||||
using (var indicesStream = mesh.GetTriangleStream())
|
using (var indicesStream = _groundMesh.GetTriangleStream())
|
||||||
{
|
{
|
||||||
var indices = new BinaryWriter(indicesStream);
|
var indices = new BinaryWriter(indicesStream);
|
||||||
for (int i = 0; i < NumVertsX - 1; i++)
|
for (int i = 0; i < NumVertsX - 1; i++)
|
||||||
|
@ -226,7 +237,7 @@ namespace VehicleDemo
|
||||||
indices.Dispose();
|
indices.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var vertexStream = mesh.GetVertexStream())
|
using (var vertexStream = _groundMesh.GetVertexStream())
|
||||||
{
|
{
|
||||||
var vertices = new BinaryWriter(vertexStream);
|
var vertices = new BinaryWriter(vertexStream);
|
||||||
for (int i = 0; i < NumVertsX; i++)
|
for (int i = 0; i < NumVertsX; i++)
|
||||||
|
@ -244,8 +255,8 @@ namespace VehicleDemo
|
||||||
vertices.Dispose();
|
vertices.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
vertexArray.AddIndexedMesh(mesh);
|
_groundVertexArray.AddIndexedMesh(_groundMesh);
|
||||||
var groundShape = new BvhTriangleMeshShape(vertexArray, true);
|
var groundShape = new BvhTriangleMeshShape(_groundVertexArray, true);
|
||||||
var groundScaled = new ScaledBvhTriangleMeshShape(groundShape, new Vector3(scale));
|
var groundScaled = new ScaledBvhTriangleMeshShape(groundShape, new Vector3(scale));
|
||||||
|
|
||||||
RigidBody ground = PhysicsHelper.CreateStaticBody(Matrix.Identity, groundScaled, World);
|
RigidBody ground = PhysicsHelper.CreateStaticBody(Matrix.Identity, groundScaled, World);
|
||||||
|
|
|
@ -83,7 +83,8 @@
|
||||||
<Compile Include="VehicleDemo.cs" />
|
<Compile Include="VehicleDemo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="BulletSharp">
|
<Reference Include="BulletSharp, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
|
Загрузка…
Ссылка в новой задаче