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