This commit is contained in:
AndresTraks 2017-12-24 15:26:58 +02:00
Родитель 7ed12a800c
Коммит e75978655b
19 изменённых файлов: 906 добавлений и 203 удалений

Просмотреть файл

@ -58,6 +58,8 @@
<Compile Include="Collision\ConvexPointCloudShape.cs" />
<Compile Include="Collision\ConvexTriangleMeshShape.cs" />
<Compile Include="Collision\Dbvt.cs" />
<Compile Include="Collision\DbvtArray.cs" />
<Compile Include="Collision\DbvtNodePtrArray.cs" />
<Compile Include="Collision\EmptyCollisionAlgorithm.cs" />
<Compile Include="Collision\EmptyShape.cs" />
<Compile Include="Collision\GImpact\CompoundFromGImpact.cs" />
@ -208,6 +210,7 @@
<Compile Include="Math\Matrix.cs" />
<Compile Include="Math\Quaternion.cs" />
<Compile Include="Math\Vector3.cs" />
<Compile Include="Math\Vector3Array.cs" />
<Compile Include="Math\Vector4.cs" />
<Compile Include="Native.cs">
<SubType>Code</SubType>

Просмотреть файл

@ -134,7 +134,7 @@ namespace BulletSharp
public CompoundShapeChildArray ChildList => _childList;
public Dbvt DynamicAabbTree => new Dbvt(btCompoundShape_getDynamicAabbTree(Native), true);
public Dbvt DynamicAabbTree => new Dbvt(btCompoundShape_getDynamicAabbTree(Native));
public int NumChildShapes => _childList.Count;

Просмотреть файл

@ -136,19 +136,40 @@ namespace BulletSharp
public class DbvtNode
{
internal IntPtr Native;
internal readonly IntPtr Native;
internal DbvtNode(IntPtr native)
{
Native = native;
}
/*
public override bool Equals(object obj)
{
if (this == obj)
{
return true;
}
var objDbvt = obj as DbvtNode;
if (objDbvt == null)
{
return false;
}
return Native == objDbvt.Native;
}
public override int GetHashCode() => (int)Native;
public DbvtNodePtrArray Childs
{
get { return btDbvtNode_getChilds(Native); }
get
{
int childCount = IsLeaf ? 0 : 2;
return new DbvtNodePtrArray(btDbvtNode_getChilds(Native), childCount);
}
}
*/
public IntPtr Data
{
get => btDbvtNode_getData(Native);
@ -163,7 +184,7 @@ namespace BulletSharp
public bool IsInternal => btDbvtNode_isinternal(Native);
public bool Isleaf => btDbvtNode_isleaf(Native);
public bool IsLeaf => btDbvtNode_isleaf(Native);
public DbvtNode Parent
{
@ -193,7 +214,7 @@ namespace BulletSharp
}
}
public class Dbvt : IDisposable
public class Dbvt
{
public class IClone : IDisposable
{
@ -570,18 +591,11 @@ namespace BulletSharp
}
}
internal IntPtr Native;
bool _preventDelete;
internal readonly IntPtr Native;
internal Dbvt(IntPtr native, bool preventDelete)
internal Dbvt(IntPtr native)
{
Native = native;
_preventDelete = preventDelete;
}
public Dbvt()
{
Native = btDbvt_new();
}
/*
public static int Allocate(AlignedIntArray ifree, AlignedStkNpsArray stock,
@ -661,7 +675,7 @@ namespace BulletSharp
{
return btDbvt_empty(Native);
}
/*
/*
public static void EnumLeaves(DbvtNode root, ICollide policy)
{
btDbvt_enumLeaves(root.Native, policy.Native);
@ -671,13 +685,31 @@ namespace BulletSharp
{
btDbvt_enumNodes(root.Native, policy.Native);
}
*/
public override bool Equals(object obj)
{
if (this == obj)
{
return true;
}
var objDbvt = obj as Dbvt;
if (objDbvt == null)
{
return false;
}
return Native == objDbvt.Native;
}
/*
public static void ExtractLeaves(DbvtNode node, AlignedDbvtNodeArray leaves)
{
btDbvt_extractLeaves(node.Native, leaves.Native);
}
*/
public DbvtNode Insert(DbvtVolume box, IntPtr data)
public override int GetHashCode() => (int)Native;
public DbvtNode Insert(DbvtVolume box, IntPtr data)
{
return new DbvtNode(btDbvt_insert(Native, box.Native, data));
}
@ -811,27 +843,5 @@ namespace BulletSharp
get { return btDbvt_getStkStack(Native); }
}
*/
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (Native != IntPtr.Zero)
{
if (!_preventDelete)
{
btDbvt_delete(Native);
}
Native = IntPtr.Zero;
}
}
~Dbvt()
{
Dispose(false);
}
}
}

Просмотреть файл

@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using static BulletSharp.UnsafeNativeMethods;
namespace BulletSharp
{
public class DbvtArrayEnumerator : IEnumerator<Dbvt>
{
private int _i;
private int _count;
private IList<Dbvt> _array;
public DbvtArrayEnumerator(IList<Dbvt> array)
{
_array = array;
_count = array.Count;
_i = -1;
}
public void Dispose()
{
}
public bool MoveNext()
{
_i++;
return _i != _count;
}
public void Reset()
{
_i = 0;
}
public Dbvt Current => _array[_i];
object System.Collections.IEnumerator.Current => _array[_i];
}
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(ListDebugView))]
public class DbvtArray : FixedSizeArray, IList<Dbvt>
{
internal DbvtArray(IntPtr native, int count)
: base(native, count)
{
}
public int IndexOf(Dbvt item)
{
return btDbvt_array_index_of(_native, item != null ? item.Native : IntPtr.Zero, _count);
}
public void Insert(int index, Dbvt item)
{
throw new NotSupportedException();
}
public Dbvt this[int index]
{
get
{
if ((uint)index >= (uint)Count)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
IntPtr ptr = btDbvt_array_at(_native, index);
return new Dbvt(ptr);
}
set
{
throw new NotSupportedException();
}
}
public void Add(Dbvt item)
{
throw new NotSupportedException();
}
public bool Contains(Dbvt item)
{
return IndexOf(item) != -1;
}
public void CopyTo(Dbvt[] array, int arrayIndex)
{
if (array == null)
throw new ArgumentNullException(nameof(array));
if (arrayIndex < 0)
throw new ArgumentOutOfRangeException(nameof(array));
int count = Count;
if (arrayIndex + count > array.Length)
throw new ArgumentException("Array too small.", "array");
for (int i = 0; i < count; i++)
{
array[arrayIndex + i] = this[i];
}
}
public bool Remove(Dbvt item)
{
throw new NotSupportedException();
}
public IEnumerator<Dbvt> GetEnumerator()
{
return new DbvtArrayEnumerator(this);
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return new DbvtArrayEnumerator(this);
}
}
}

Просмотреть файл

@ -160,7 +160,7 @@ namespace BulletSharp
set => btDbvtBroadphase_setReleasepaircache(Native, value);
}
//public DbvtArray Sets => btDbvtBroadphase_getSets(Native);
public DbvtArray Sets => new DbvtArray(btDbvtBroadphase_getSets(Native), 2);
public int StageCurrent
{

Просмотреть файл

@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using static BulletSharp.UnsafeNativeMethods;
namespace BulletSharp
{
public class DbvtNodePtrArrayEnumerator : IEnumerator<DbvtNode>
{
private int _i;
private int _count;
private IList<DbvtNode> _array;
public DbvtNodePtrArrayEnumerator(IList<DbvtNode> array)
{
_array = array;
_count = array.Count;
_i = -1;
}
public void Dispose()
{
}
public bool MoveNext()
{
_i++;
return _i != _count;
}
public void Reset()
{
_i = 0;
}
public DbvtNode Current => _array[_i];
object System.Collections.IEnumerator.Current => _array[_i];
}
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(ListDebugView))]
public class DbvtNodePtrArray : FixedSizeArray, IList<DbvtNode>
{
internal DbvtNodePtrArray(IntPtr native, int count)
: base(native, count)
{
}
public int IndexOf(DbvtNode item)
{
return btDbvtNodePtr_array_index_of(_native, item != null ? item.Native : IntPtr.Zero, _count);
}
public void Insert(int index, DbvtNode item)
{
throw new NotSupportedException();
}
public DbvtNode this[int index]
{
get
{
if ((uint)index >= (uint)Count)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
IntPtr ptr = btDbvtNodePtr_array_at(_native, index);
return (ptr != IntPtr.Zero) ? new DbvtNode(ptr) : null;
}
set
{
throw new NotSupportedException();
}
}
public void Add(DbvtNode item)
{
throw new NotSupportedException();
}
public bool Contains(DbvtNode item)
{
return IndexOf(item) != -1;
}
public void CopyTo(DbvtNode[] array, int arrayIndex)
{
if (array == null)
throw new ArgumentNullException(nameof(array));
if (arrayIndex < 0)
throw new ArgumentOutOfRangeException(nameof(array));
int count = Count;
if (arrayIndex + count > array.Length)
throw new ArgumentException("Array too small.", "array");
for (int i = 0; i < count; i++)
{
array[arrayIndex + i] = this[i];
}
}
public bool Remove(DbvtNode item)
{
throw new NotSupportedException();
}
public IEnumerator<DbvtNode> GetEnumerator()
{
return new DbvtNodePtrArrayEnumerator(this);
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return new DbvtNodePtrArrayEnumerator(this);
}
}
}

Просмотреть файл

@ -1,9 +1,10 @@
using BulletSharp.Math;
using System;
using static BulletSharp.UnsafeNativeMethods;
namespace BulletSharp
{
public class ShapeHull : IDisposable
public class ShapeHull : IDisposable
{
internal IntPtr Native;

Просмотреть файл

@ -29,27 +29,6 @@ namespace BulletSharp
}
};
internal class Vector3ListDebugView
{
private IList<Vector3> _list;
public Vector3ListDebugView(IList<Vector3> list)
{
_list = list;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public Vector3[] Items
{
get
{
var arr = new Vector3[_list.Count];
_list.CopyTo(arr, 0);
return arr;
}
}
};
public class CompoundShapeChildArrayEnumerator : IEnumerator<CompoundShapeChild>
{
private int _i;
@ -116,39 +95,6 @@ namespace BulletSharp
object System.Collections.IEnumerator.Current => _array[_i];
}
public class Vector3ArrayEnumerator : IEnumerator<Vector3>
{
private int _i;
private int _count;
private IList<Vector3> _array;
public Vector3ArrayEnumerator(IList<Vector3> array)
{
_array = array;
_count = array.Count;
_i = -1;
}
public void Dispose()
{
}
public bool MoveNext()
{
_i++;
return _i != _count;
}
public void Reset()
{
_i = 0;
}
public Vector3 Current => _array[_i];
object System.Collections.IEnumerator.Current => _array[_i];
}
public class FixedSizeArray
{
internal IntPtr _native;
@ -349,89 +295,4 @@ namespace BulletSharp
throw new NotSupportedException();
}
}
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(Vector3ListDebugView))]
public class Vector3Array : FixedSizeArray, IList<Vector3>
{
internal Vector3Array(IntPtr native, int count)
: base(native, count)
{
}
public int IndexOf(Vector3 item)
{
throw new NotImplementedException();
}
public void Insert(int index, Vector3 item)
{
throw new NotSupportedException();
}
public Vector3 this[int index]
{
get
{
if ((uint)index >= (uint)Count)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Vector3 value;
btVector3_array_at(_native, index, out value);
return value;
}
set
{
if ((uint)index >= (uint)Count)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
btVector3_array_set(_native, index, ref value);
}
}
public void Add(Vector3 item)
{
throw new NotSupportedException();
}
public bool Contains(Vector3 item)
{
throw new NotImplementedException();
}
public void CopyTo(Vector3[] array, int arrayIndex)
{
if (array == null)
throw new ArgumentNullException(nameof(array));
if (arrayIndex < 0)
throw new ArgumentOutOfRangeException(nameof(array));
int count = Count;
if (arrayIndex + count > array.Length)
throw new ArgumentException("Array too small.", "array");
for (int i = 0; i < count; i++)
{
array[arrayIndex + i] = this[i];
}
}
public bool Remove(Vector3 item)
{
throw new NotSupportedException();
}
public IEnumerator<Vector3> GetEnumerator()
{
return new Vector3ArrayEnumerator(this);
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return new Vector3ArrayEnumerator(this);
}
}
}

Просмотреть файл

@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using static BulletSharp.UnsafeNativeMethods;
namespace BulletSharp.Math
{
internal class Vector3ListDebugView
{
private IList<Vector3> _list;
public Vector3ListDebugView(IList<Vector3> list)
{
_list = list;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public Vector3[] Items
{
get
{
var arr = new Vector3[_list.Count];
_list.CopyTo(arr, 0);
return arr;
}
}
};
public class Vector3ArrayEnumerator : IEnumerator<Vector3>
{
private int _i;
private int _count;
private IList<Vector3> _array;
public Vector3ArrayEnumerator(IList<Vector3> array)
{
_array = array;
_count = array.Count;
_i = -1;
}
public void Dispose()
{
}
public bool MoveNext()
{
_i++;
return _i != _count;
}
public void Reset()
{
_i = 0;
}
public Vector3 Current => _array[_i];
object System.Collections.IEnumerator.Current => _array[_i];
}
[DebuggerDisplay("Count = {Count}")]
[DebuggerTypeProxy(typeof(Vector3ListDebugView))]
public class Vector3Array : FixedSizeArray, IList<Vector3>
{
internal Vector3Array(IntPtr native, int count)
: base(native, count)
{
}
public int IndexOf(Vector3 item)
{
throw new NotImplementedException();
}
public void Insert(int index, Vector3 item)
{
throw new NotSupportedException();
}
public Vector3 this[int index]
{
get
{
if ((uint)index >= (uint)Count)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
Vector3 value;
btVector3_array_at(_native, index, out value);
return value;
}
set
{
if ((uint)index >= (uint)Count)
{
throw new ArgumentOutOfRangeException(nameof(index));
}
btVector3_array_set(_native, index, ref value);
}
}
public void Add(Vector3 item)
{
throw new NotSupportedException();
}
public bool Contains(Vector3 item)
{
throw new NotImplementedException();
}
public void CopyTo(Vector3[] array, int arrayIndex)
{
if (array == null)
throw new ArgumentNullException(nameof(array));
if (arrayIndex < 0)
throw new ArgumentOutOfRangeException(nameof(array));
int count = Count;
if (arrayIndex + count > array.Length)
throw new ArgumentException("Array too small.", "array");
for (int i = 0; i < count; i++)
{
array[arrayIndex + i] = this[i];
}
}
public bool Remove(Vector3 item)
{
throw new NotSupportedException();
}
public IEnumerator<Vector3> GetEnumerator()
{
return new Vector3ArrayEnumerator(this);
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return new Vector3ArrayEnumerator(this);
}
}
}

Просмотреть файл

@ -3234,7 +3234,7 @@ namespace BulletSharp.SoftBody
{
if (_clusterDbvt == null)
{
_clusterDbvt = new Dbvt(btSoftBody_getCdbvt(Native), true);
_clusterDbvt = new Dbvt(btSoftBody_getCdbvt(Native));
}
return _clusterDbvt;
}
@ -3294,7 +3294,7 @@ namespace BulletSharp.SoftBody
{
if (_faceDbvt == null)
{
_faceDbvt = new Dbvt(btSoftBody_getFdbvt(Native), true);
_faceDbvt = new Dbvt(btSoftBody_getFdbvt(Native));
}
return _faceDbvt;
}
@ -3353,7 +3353,7 @@ namespace BulletSharp.SoftBody
{
if (_nodeDbvt == null)
{
_nodeDbvt = new Dbvt(btSoftBody_getNdbvt(Native), true);
_nodeDbvt = new Dbvt(btSoftBody_getNdbvt(Native));
}
return _nodeDbvt;
}

Просмотреть файл

@ -295,7 +295,7 @@ namespace BulletSharp
public static extern int btAlignedObjectArray_btSoftBody_Tetra_size(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern IntPtr btSoftBodyNodePtrArray_at(IntPtr obj, int n);
public static extern IntPtr btSoftBodyNodePtrArray_at(IntPtr obj, int index);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern IntPtr btSoftBodyNodePtrArray_set(IntPtr obj, IntPtr value, int index);
@ -1214,7 +1214,7 @@ namespace BulletSharp
public static extern void btCompoundShapeChild_setTransform(IntPtr obj, [In] ref Matrix value);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern IntPtr btCompoundShapeChild_array_at(IntPtr obj, int n);
public static extern IntPtr btCompoundShapeChild_array_at(IntPtr obj, int index);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern void btConcaveShape_processAllTriangles(IntPtr obj, IntPtr callback, [In] ref Vector3 aabbMin, [In] ref Vector3 aabbMax);
@ -1861,6 +1861,11 @@ namespace BulletSharp
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern void btDbvtNode_setParent(IntPtr obj, IntPtr value);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern IntPtr btDbvtNodePtr_array_at(IntPtr obj, int index);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern int btDbvtNodePtr_array_index_of(IntPtr obj, IntPtr value, int length);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern IntPtr btDbvtProxy_getLeaf(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
@ -1872,8 +1877,6 @@ namespace BulletSharp
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern void btDbvtProxy_setStage(IntPtr obj, int value);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern IntPtr btDbvt_new();
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern int btDbvt_allocate(IntPtr ifree, IntPtr stock, IntPtr value);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
@ -1946,10 +1949,13 @@ namespace BulletSharp
public static extern bool btDbvt_update6(IntPtr obj, IntPtr leaf, IntPtr volume, [In] ref Vector3 velocity, float margin);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern void btDbvt_write(IntPtr obj, IntPtr iwriter);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern void btDbvt_delete(IntPtr obj);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern IntPtr btDbvt_array_at(IntPtr obj, int index);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern int btDbvt_array_index_of(IntPtr obj, IntPtr value, int length);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern IntPtr btDbvtAabbMm_new();
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern void btDbvtAabbMm_Center(IntPtr obj, out Vector3 value);
@ -7128,9 +7134,9 @@ namespace BulletSharp
public static extern void btUsageBitfield_setUsedVertexD(IntPtr obj, bool value);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern IntPtr btVector3_array_at(IntPtr obj, int n, [Out] out Vector3 value);
public static extern IntPtr btVector3_array_at(IntPtr obj, int index, [Out] out Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern IntPtr btVector3_array_set(IntPtr obj, int n, [In] ref Vector3 value);
public static extern IntPtr btVector3_array_set(IntPtr obj, int index, [In] ref Vector3 value);
[DllImport(Native.Dll, CallingConvention = Native.Conv)]
public static extern IntPtr btVoronoiSimplexSolver_new();

72
BulletSharp/demos/DemoFramework/DebugInfo/DebugInfoForm.Designer.cs сгенерированный Normal file
Просмотреть файл

@ -0,0 +1,72 @@
namespace DemoFramework.DebugInfo
{
partial class DebugInfoForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.worldTree = new System.Windows.Forms.TreeView();
this.snapshotButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// worldTree
//
this.worldTree.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.worldTree.Location = new System.Drawing.Point(13, 42);
this.worldTree.Name = "worldTree";
this.worldTree.Size = new System.Drawing.Size(381, 416);
this.worldTree.TabIndex = 0;
//
// snapshotButton
//
this.snapshotButton.Location = new System.Drawing.Point(13, 13);
this.snapshotButton.Name = "snapshotButton";
this.snapshotButton.Size = new System.Drawing.Size(108, 23);
this.snapshotButton.TabIndex = 1;
this.snapshotButton.Text = "Take snapshot";
this.snapshotButton.UseVisualStyleBackColor = true;
this.snapshotButton.Click += new System.EventHandler(this.snapshotButton_Click);
//
// DebugInfoForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(625, 470);
this.Controls.Add(this.snapshotButton);
this.Controls.Add(this.worldTree);
this.Name = "DebugInfoForm";
this.Text = "Debug Info";
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TreeView worldTree;
private System.Windows.Forms.Button snapshotButton;
}
}

Просмотреть файл

@ -0,0 +1,200 @@
using BulletSharp;
using System.Collections.Generic;
using System.Windows.Forms;
namespace DemoFramework.DebugInfo
{
public partial class DebugInfoForm : Form
{
private readonly Demo _demo;
public DebugInfoForm(Demo demo)
{
_demo = demo;
InitializeComponent();
TakeSnapshot();
}
private void TakeSnapshot()
{
SetWorldTreeInfo();
}
private void SetWorldTreeInfo()
{
var world = _demo.Simulation.World;
TreeNode worldNode = GetOrCreateWorldNode(world);
SetCollisionObjectsInfo(world.CollisionObjectArray, worldNode);
SetBroadphaseInfo(world.Broadphase, worldNode);
}
private TreeNode GetOrCreateWorldNode(DiscreteDynamicsWorld world)
{
TreeNode worldNode;
if (worldTree.Nodes.Count == 1)
{
worldNode = worldTree.Nodes[0];
if (worldNode.Tag == world)
{
return worldNode;
}
worldTree.Nodes.Clear();
}
worldNode = worldTree.Nodes.Add(world.GetType().Name);
worldNode.Tag = world;
worldNode.Expand();
return worldNode;
}
private void SetCollisionObjectsInfo(IList<CollisionObject> collisionObjects, TreeNode worldNode)
{
TreeNode objectsNode = GetOrCreateChildNode("Objects", worldNode);
foreach (CollisionObject collisionObject in collisionObjects)
{
SetCollisionObjectInfo(collisionObject, objectsNode);
}
RemoveMissingObjects(collisionObjects, objectsNode);
}
private void SetCollisionObjectInfo(CollisionObject collisionObject, TreeNode objectsNode)
{
string objectName = collisionObject.GetType().Name;
CollisionShape shape = collisionObject.CollisionShape;
string shapeName = shape.GetType().Name;
string text = $"{objectName} ({shapeName})";
GetOrCreateChildNode(collisionObject, text, objectsNode);
}
private void SetBroadphaseInfo(BroadphaseInterface broadphase, TreeNode worldNode)
{
string text = broadphase.GetType().Name;
TreeNode broadphaseNode = GetOrCreateChildNode(broadphase, text, worldNode);
var dbvtBroadphase = broadphase as DbvtBroadphase;
if (dbvtBroadphase != null)
{
SetDbvtBroadphaseInfo(dbvtBroadphase, broadphaseNode);
}
}
private void SetDbvtBroadphaseInfo(DbvtBroadphase dbvtBroadphase, TreeNode broadphaseNode)
{
var sets = dbvtBroadphase.Sets;
Dbvt dynamicSet = sets[0];
Dbvt staticSet = sets[1];
TreeNode dynamicSetNode = GetOrCreateChildNode(dynamicSet, "Dynamic set", broadphaseNode);
SetDbvtInfo(dynamicSet, dynamicSetNode);
TreeNode staticSetNode = GetOrCreateChildNode(staticSet, "Static set", broadphaseNode);
SetDbvtInfo(staticSet, staticSetNode);
RemoveMissingObjects(sets, broadphaseNode);
}
private void SetDbvtInfo(Dbvt dbvtSet, TreeNode dbvtNode)
{
SetDbvtNodeInfo(dbvtSet.Root, dbvtNode);
}
private void SetDbvtNodeInfo(DbvtNode dbvtNode, TreeNode parentNode)
{
if (dbvtNode == null)
{
return;
}
string text = dbvtNode.GetType().Name + " " + dbvtNode.Data;
TreeNode dbvtNodeNode = GetOrCreateChildNode(dbvtNode, text, parentNode);
foreach (DbvtNode child in dbvtNode.Childs)
{
SetDbvtNodeInfo(child, dbvtNodeNode);
}
RemoveMissingObjects(dbvtNode.Childs, dbvtNodeNode);
}
private void snapshotButton_Click(object sender, System.EventArgs e)
{
TakeSnapshot();
}
private TreeNode GetOrCreateChildNode(object tag, string text, TreeNode parent)
{
TreeNode child = FindChildByTag(parent, tag);
if (child == null)
{
child = parent.Nodes.Add(text);
child.Tag = tag;
}
else
{
child.Text = text;
}
return child;
}
private TreeNode GetOrCreateChildNode(string text, TreeNode parent)
{
TreeNode child = FindChildByText(parent, text);
if (child == null)
{
child = parent.Nodes.Add(text);
}
else
{
child.Text = text;
}
return child;
}
private TreeNode FindChildByText(TreeNode parent, string text)
{
foreach (TreeNode node in parent.Nodes)
{
if (node.Text == text)
{
return node;
}
}
return null;
}
private TreeNode FindChildByTag(TreeNode parent, object tag)
{
foreach (TreeNode node in parent.Nodes)
{
if (Equals(node.Tag, tag))
{
return node;
}
}
return null;
}
private void RemoveMissingObjects<T>(ICollection<T> collection, TreeNode parentNode) where T : class
{
IList<TreeNode> nodesToRemove = new List<TreeNode>();
foreach (TreeNode objectNode in parentNode.Nodes)
{
if (!collection.Contains(objectNode.Tag as T))
{
nodesToRemove.Add(objectNode);
}
}
foreach (TreeNode node in nodesToRemove)
{
parentNode.Nodes.Remove(node);
}
}
}
}

Просмотреть файл

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

Просмотреть файл

@ -1,5 +1,6 @@
using BulletSharp;
using BulletSharp.Math;
using DemoFramework.DebugInfo;
using System;
using System.Drawing;
using System.Globalization;
@ -267,6 +268,10 @@ namespace DemoFramework
case Keys.F3:
IsDebugDrawEnabled = !IsDebugDrawEnabled;
break;
case Keys.F5:
var debugForm = new DebugInfoForm(this);
debugForm.Show();
break;
case Keys.F8:
Input.ClearKeyCache();
GraphicsLibraryManager.ExitWithReload = true;

Просмотреть файл

@ -76,11 +76,18 @@
<HintPath>..\..\bin\Release\BulletSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<Compile Include="DebugInfo\DebugInfoForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="DebugInfo\DebugInfoForm.Designer.cs">
<DependentUpon>DebugInfoForm.cs</DependentUpon>
</Compile>
<Compile Include="FileLoaders\UrdfLoader.cs" />
<Compile Include="FileLoaders\UrdfToBullet.cs" />
<Compile Include="IUpdateReceiver.cs" />
@ -115,6 +122,9 @@
<Compile Include="Simulation\SimulationExtensions.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="DebugInfo\DebugInfoForm.resx">
<DependentUpon>DebugInfoForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Graphics\LibrarySelection.resx">
<DependentUpon>LibrarySelection.cs</DependentUpon>
<SubType>Designer</SubType>

Просмотреть файл

@ -1,5 +1,4 @@
using System;
using BulletSharp;
using BulletSharp;
using System.Windows.Forms;
using BulletSharp.Math;

Просмотреть файл

@ -402,11 +402,6 @@ void btDbvt_sStkNPS_delete(btDbvt_sStkNPS* obj)
}
btDbvt* btDbvt_new()
{
return new btDbvt();
}
int btDbvt_allocate(btAlignedObjectArray_int* ifree, btAlignedObjectArray_btDbvt_sStkNPS* stock,
const btDbvt_sStkNPS* value)
{
@ -656,7 +651,38 @@ void btDbvt_write(btDbvt* obj, btDbvt_IWriter* iwriter)
obj->write(iwriter);
}
void btDbvt_delete(btDbvt* obj)
btDbvt* btDbvt_array_at(btDbvt* obj, int index)
{
delete obj;
return &obj[index];
}
int btDbvt_array_index_of(btDbvt* obj, btDbvt* value, int length)
{
for (int i = 0; i < length; i++)
{
if (&obj[i] == value)
{
return i;
}
}
return -1;
}
btDbvtNode* btDbvtNodePtr_array_at(btDbvtNode** obj, int index)
{
return obj[index];
}
int btDbvtNodePtr_array_index_of(btDbvtNode** obj, btDbvtNode* value, int length)
{
for (int i = 0; i < length; i++)
{
if (obj[i] == value)
{
return i;
}
}
return -1;
}

Просмотреть файл

@ -85,7 +85,6 @@ extern "C" {
EXPORT void btDbvt_sStkNPS_setValue(btDbvt_sStkNPS* obj, btScalar value);
EXPORT void btDbvt_sStkNPS_delete(btDbvt_sStkNPS* obj);
EXPORT btDbvt* btDbvt_new();
EXPORT int btDbvt_allocate(btAlignedObjectArray_int* ifree, btAlignedObjectArray_btDbvt_sStkNPS* stock, const btDbvt_sStkNPS* value);
EXPORT void btDbvt_benchmark();
EXPORT void btDbvt_clear(btDbvt* obj);
@ -131,7 +130,12 @@ extern "C" {
EXPORT bool btDbvt_update5(btDbvt* obj, btDbvtNode* leaf, btDbvtVolume* volume, const btVector3* velocity);
EXPORT bool btDbvt_update6(btDbvt* obj, btDbvtNode* leaf, btDbvtVolume* volume, const btVector3* velocity, btScalar margin);
EXPORT void btDbvt_write(btDbvt* obj, btDbvt_IWriter* iwriter);
EXPORT void btDbvt_delete(btDbvt* obj);
EXPORT btDbvt* btDbvt_array_at(btDbvt* obj, int index);
EXPORT int btDbvt_array_index_of(btDbvt* obj, btDbvt* value, int length);
EXPORT btDbvtNode* btDbvtNodePtr_array_at(btDbvtNode** obj, int index);
EXPORT int btDbvtNodePtr_array_index_of(btDbvtNode** obj, btDbvtNode* value, int length);
#ifdef __cplusplus
}
#endif