-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathAlignedNodeArray.cs
More file actions
191 lines (162 loc) · 5.19 KB
/
AlignedNodeArray.cs
File metadata and controls
191 lines (162 loc) · 5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security;
using System.Diagnostics;
namespace BulletSharp.SoftBody
{
public class AlignedNodeArrayDebugView
{
private AlignedNodeArray _array;
public AlignedNodeArrayDebugView(AlignedNodeArray array)
{
_array = array;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public Node[] Items
{
get
{
int count = _array.Count;
Node[] array = new Node[count];
for (int i = 0; i < count; i++)
{
array[i] = _array[i];
}
return array;
}
}
}
public class AlignedNodeArrayEnumerator : IEnumerator<Node>
{
int _i;
int _count;
AlignedNodeArray _array;
public AlignedNodeArrayEnumerator(AlignedNodeArray array)
{
_array = array;
_count = array.Count;
_i = -1;
}
public Node Current
{
get { return _array[_i]; }
}
public void Dispose()
{
}
object System.Collections.IEnumerator.Current
{
get { return _array[_i]; }
}
public bool MoveNext()
{
_i++;
return _i != _count;
}
public void Reset()
{
_i = 0;
}
}
[Serializable, DebuggerTypeProxy(typeof(AlignedNodeArrayDebugView)), DebuggerDisplay("Count = {Count}")]
public class AlignedNodeArray : IList<Node>
{
private IntPtr _native;
private Dictionary<long, Node> _nodeObjects;
internal AlignedNodeArray(IntPtr native)
{
_native = native;
_nodeObjects = new Dictionary<long, Node>();
}
public int IndexOf(Node item)
{
return btAlignedSoftBodyNodeArray_index_of(_native, item._native);
}
public void Insert(int index, Node item)
{
throw new NotImplementedException();
}
public void RemoveAt(int index)
{
throw new NotImplementedException();
}
public Node this[int index]
{
get
{
if ((uint)index >= (uint)Count)
{
throw new ArgumentOutOfRangeException("index");
}
IntPtr nodePtr = btAlignedSoftBodyNodeArray_at(_native, index);
long nodePtrInt = nodePtr.ToInt64();
Node node;
if (!_nodeObjects.TryGetValue(nodePtrInt, out node))
{
node = new Node(nodePtr);
_nodeObjects.Add(nodePtrInt, node);
}
return node;
}
set
{
throw new NotImplementedException();
}
}
public IntPtr GetNodePointer(int index)
{
if ((uint)index >= (uint)Count)
{
throw new ArgumentOutOfRangeException("index");
}
return btAlignedSoftBodyNodeArray_at(_native, index);
}
public void Add(Node item)
{
btAlignedSoftBodyNodeArray_push_back(_native, item._native);
}
public void Clear()
{
btAlignedSoftBodyNodeArray_resizeNoInitialize(_native, 0);
}
public bool Contains(Node item)
{
throw new NotImplementedException();
}
public void CopyTo(Node[] array, int arrayIndex)
{
throw new NotImplementedException();
}
public int Count
{
get { return btAlignedSoftBodyNodeArray_size(_native); }
}
public bool IsReadOnly
{
get { return false; }
}
public bool Remove(Node item)
{
throw new NotImplementedException();
}
public IEnumerator<Node> GetEnumerator()
{
return new AlignedNodeArrayEnumerator(this);
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return new AlignedNodeArrayEnumerator(this);
}
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern IntPtr btAlignedSoftBodyNodeArray_at(IntPtr obj, int n);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern int btAlignedSoftBodyNodeArray_index_of(IntPtr obj, IntPtr val);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btAlignedSoftBodyNodeArray_push_back(IntPtr obj, IntPtr val);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern void btAlignedSoftBodyNodeArray_resizeNoInitialize(IntPtr obj, int newSize);
[DllImport(Native.Dll, CallingConvention = Native.Conv), SuppressUnmanagedCodeSecurity]
static extern int btAlignedSoftBodyNodeArray_size(IntPtr obj);
}
}