-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathAlignedIndexedMeshArray.cs
More file actions
172 lines (141 loc) · 3.84 KB
/
Copy pathAlignedIndexedMeshArray.cs
File metadata and controls
172 lines (141 loc) · 3.84 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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using static BulletSharp.UnsafeNativeMethods;
namespace BulletSharp
{
public class AlignedIndexedMeshArrayDebugView
{
private readonly AlignedIndexedMeshArray _array;
public AlignedIndexedMeshArrayDebugView(AlignedIndexedMeshArray array)
{
_array = array;
}
[DebuggerBrowsable(DebuggerBrowsableState.RootHidden)]
public IndexedMesh[] Items
{
get
{
var array = new IndexedMesh[_array.Count];
for (int i = 0; i < _array.Count; i++)
{
array[i] = _array[i];
}
return array;
}
}
}
public struct AlignedIndexedMeshArrayEnumerator : IEnumerator<IndexedMesh>
{
private int _i;
private readonly int _count;
private readonly AlignedIndexedMeshArray _array;
public AlignedIndexedMeshArrayEnumerator(AlignedIndexedMeshArray array)
{
_array = array;
_count = array.Count;
_i = -1;
}
public IndexedMesh Current => _array[_i];
public void Dispose()
{
}
object System.Collections.IEnumerator.Current => _array[_i];
public bool MoveNext()
{
_i++;
return _i != _count;
}
public void Reset()
{
_i = -1;
}
}
[Serializable, DebuggerTypeProxy(typeof(AlignedIndexedMeshArrayDebugView)), DebuggerDisplay("Count = {Count}")]
public class AlignedIndexedMeshArray : BulletObject, IList<IndexedMesh>
{
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)
{
if (item == null)
{
return -1;
}
return _backingList.IndexOf(item);
}
public void Insert(int index, IndexedMesh item)
{
throw new NotImplementedException();
}
public void RemoveAt(int index)
{
throw new NotImplementedException();
}
public IndexedMesh this[int index]
{
get => _backingList[index];
set
{
throw new NotImplementedException();
}
}
public void Add(IndexedMesh item)
{
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)
{
return _backingList.Contains(item);
}
public void CopyTo(IndexedMesh[] 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.", nameof(array));
for (int i = 0; i < count; i++)
{
array[arrayIndex + i] = _backingList[i];
}
}
public int Count => _backingList.Count;
public bool IsReadOnly => false;
public bool Remove(IndexedMesh item)
{
throw new NotImplementedException();
}
public AlignedIndexedMeshArrayEnumerator GetEnumerator()
{
return new AlignedIndexedMeshArrayEnumerator(this);
}
IEnumerator<IndexedMesh> IEnumerable<IndexedMesh>.GetEnumerator()
{
return _backingList.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return _backingList.GetEnumerator();
}
}
}