@@ -19,7 +19,7 @@ public sealed partial class MemoryAccessor
1919
2020 internal string _GetDebuggerDisplay ( )
2121 {
22- return _Slicer . _GetDebuggerDisplay ( ) ;
22+ return Attribute . _GetDebuggerDisplay ( ) ;
2323 }
2424
2525 #endregion
@@ -29,49 +29,39 @@ internal string _GetDebuggerDisplay()
2929 #if NETSTANDARD
3030 public MemoryAccessor ( Byte [ ] data , MemoryAccessInfo info )
3131 {
32- this . _Slicer = info ;
33- this . _Data = new ArraySegment < Byte > ( data ) ;
32+ this . Attribute = info ;
33+ this . Data = new ArraySegment < Byte > ( data ) ;
3434 }
3535 #endif
3636
3737 public MemoryAccessor ( BYTES data , MemoryAccessInfo info )
3838 {
39- this . _Slicer = info ;
40- this . _Data = data ;
39+ this . Attribute = info ;
40+ this . Data = data ;
4141 }
4242
4343 public MemoryAccessor ( MemoryAccessInfo info )
4444 {
45- this . _Slicer = info ;
46- this . _Data = default ;
45+ this . Attribute = info ;
46+ this . Data = default ;
4747 }
4848
49- #endregion
49+ #endregion
5050
5151 #region data
5252
53- [ System . Diagnostics . DebuggerBrowsable ( System . Diagnostics . DebuggerBrowsableState . Never ) ]
54- private MemoryAccessInfo _Slicer ;
55-
56- [ System . Diagnostics . DebuggerBrowsable ( System . Diagnostics . DebuggerBrowsableState . Never ) ]
57- private BYTES _Data ;
58-
59- #endregion
60-
61- #region properties
62-
63- public MemoryAccessInfo Attribute => _Slicer ;
53+ public MemoryAccessInfo Attribute { get ; private set ; }
6454
65- public BYTES Data => _Data ;
55+ public BYTES Data { get ; private set ; }
6656
6757 #endregion
6858
6959 #region API
7060
7161 public void Update ( BYTES data , MemoryAccessInfo encoding )
7262 {
73- this . _Slicer = encoding ;
74- this . _Data = data ;
63+ this . Attribute = encoding ;
64+ this . Data = data ;
7565 }
7666
7767 public IAccessorArray < T > AsArrayOf < T > ( )
@@ -108,73 +98,73 @@ public IAccessorArray<T> AsArrayOf<T>()
10898
10999 public IntegerArray AsIntegerArray ( )
110100 {
111- Guard . IsTrue ( _Slicer . IsValidIndexer , nameof ( _Slicer ) ) ;
112- Guard . IsTrue ( _Slicer . Dimensions == DIMENSIONS . SCALAR , nameof ( _Slicer ) ) ;
113- return new IntegerArray ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . Encoding . ToIndex ( ) ) ;
101+ Guard . IsTrue ( Attribute . IsValidIndexer , nameof ( Attribute ) ) ;
102+ Guard . IsTrue ( Attribute . Dimensions == DIMENSIONS . SCALAR , nameof ( Attribute ) ) ;
103+ return new IntegerArray ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . Encoding . ToIndex ( ) ) ;
114104 }
115105
116106 public ScalarArray AsScalarArray ( )
117107 {
118- Guard . IsTrue ( _Slicer . IsValidVertexAttribute , nameof ( _Slicer ) ) ;
119- Guard . IsTrue ( _Slicer . Dimensions == DIMENSIONS . SCALAR , nameof ( _Slicer ) ) ;
120- return new ScalarArray ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . ByteStride , _Slicer . Encoding , _Slicer . Normalized ) ;
108+ Guard . IsTrue ( Attribute . IsValidVertexAttribute , nameof ( Attribute ) ) ;
109+ Guard . IsTrue ( Attribute . Dimensions == DIMENSIONS . SCALAR , nameof ( Attribute ) ) ;
110+ return new ScalarArray ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . ByteStride , Attribute . Encoding , Attribute . Normalized ) ;
121111 }
122112
123113 public Vector2Array AsVector2Array ( )
124114 {
125- Guard . IsTrue ( _Slicer . IsValidVertexAttribute , nameof ( _Slicer ) ) ;
126- Guard . IsTrue ( _Slicer . Dimensions == DIMENSIONS . VEC2 , nameof ( _Slicer ) ) ;
127- return new Vector2Array ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . ByteStride , _Slicer . Encoding , _Slicer . Normalized ) ;
115+ Guard . IsTrue ( Attribute . IsValidVertexAttribute , nameof ( Attribute ) ) ;
116+ Guard . IsTrue ( Attribute . Dimensions == DIMENSIONS . VEC2 , nameof ( Attribute ) ) ;
117+ return new Vector2Array ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . ByteStride , Attribute . Encoding , Attribute . Normalized ) ;
128118 }
129119
130120 public Vector3Array AsVector3Array ( )
131121 {
132- Guard . IsTrue ( _Slicer . IsValidVertexAttribute , nameof ( _Slicer ) ) ;
133- Guard . IsTrue ( _Slicer . Dimensions == DIMENSIONS . VEC3 , nameof ( _Slicer ) ) ;
134- return new Vector3Array ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . ByteStride , _Slicer . Encoding , _Slicer . Normalized ) ;
122+ Guard . IsTrue ( Attribute . IsValidVertexAttribute , nameof ( Attribute ) ) ;
123+ Guard . IsTrue ( Attribute . Dimensions == DIMENSIONS . VEC3 , nameof ( Attribute ) ) ;
124+ return new Vector3Array ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . ByteStride , Attribute . Encoding , Attribute . Normalized ) ;
135125 }
136126
137127 public Vector4Array AsVector4Array ( )
138128 {
139- Guard . IsTrue ( _Slicer . IsValidVertexAttribute , nameof ( _Slicer ) ) ;
140- Guard . IsTrue ( _Slicer . Dimensions == DIMENSIONS . VEC4 , nameof ( _Slicer ) ) ;
141- return new Vector4Array ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . ByteStride , _Slicer . Encoding , _Slicer . Normalized ) ;
129+ Guard . IsTrue ( Attribute . IsValidVertexAttribute , nameof ( Attribute ) ) ;
130+ Guard . IsTrue ( Attribute . Dimensions == DIMENSIONS . VEC4 , nameof ( Attribute ) ) ;
131+ return new Vector4Array ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . ByteStride , Attribute . Encoding , Attribute . Normalized ) ;
142132 }
143133
144134 public QuaternionArray AsQuaternionArray ( )
145135 {
146- Guard . IsTrue ( _Slicer . IsValidVertexAttribute , nameof ( _Slicer ) ) ;
147- Guard . IsTrue ( _Slicer . Dimensions == DIMENSIONS . VEC4 , nameof ( _Slicer ) ) ;
148- return new QuaternionArray ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . ByteStride , _Slicer . Encoding , _Slicer . Normalized ) ;
136+ Guard . IsTrue ( Attribute . IsValidVertexAttribute , nameof ( Attribute ) ) ;
137+ Guard . IsTrue ( Attribute . Dimensions == DIMENSIONS . VEC4 , nameof ( Attribute ) ) ;
138+ return new QuaternionArray ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . ByteStride , Attribute . Encoding , Attribute . Normalized ) ;
149139 }
150140
151141 public Matrix2x2Array AsMatrix2x2Array ( )
152142 {
153- Guard . IsTrue ( _Slicer . IsValidVertexAttribute , nameof ( _Slicer ) ) ;
154- Guard . IsTrue ( _Slicer . Dimensions == DIMENSIONS . MAT2 , nameof ( _Slicer ) ) ;
155- return new Matrix2x2Array ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . ByteStride , _Slicer . Encoding , _Slicer . Normalized ) ;
143+ Guard . IsTrue ( Attribute . IsValidVertexAttribute , nameof ( Attribute ) ) ;
144+ Guard . IsTrue ( Attribute . Dimensions == DIMENSIONS . MAT2 , nameof ( Attribute ) ) ;
145+ return new Matrix2x2Array ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . ByteStride , Attribute . Encoding , Attribute . Normalized ) ;
156146 }
157147
158148 public Matrix3x3Array AsMatrix3x3Array ( )
159149 {
160- Guard . IsTrue ( _Slicer . IsValidVertexAttribute , nameof ( _Slicer ) ) ;
161- Guard . IsTrue ( _Slicer . Dimensions == DIMENSIONS . MAT3 , nameof ( _Slicer ) ) ;
162- return new Matrix3x3Array ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . ByteStride , _Slicer . Encoding , _Slicer . Normalized ) ;
150+ Guard . IsTrue ( Attribute . IsValidVertexAttribute , nameof ( Attribute ) ) ;
151+ Guard . IsTrue ( Attribute . Dimensions == DIMENSIONS . MAT3 , nameof ( Attribute ) ) ;
152+ return new Matrix3x3Array ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . ByteStride , Attribute . Encoding , Attribute . Normalized ) ;
163153 }
164154
165155 public Matrix4x3Array AsMatrix4x3Array ( )
166156 {
167- Guard . IsTrue ( _Slicer . IsValidVertexAttribute , nameof ( _Slicer ) ) ;
157+ Guard . IsTrue ( Attribute . IsValidVertexAttribute , nameof ( Attribute ) ) ;
168158 // Guard.IsTrue(_Slicer.Dimensions == DIMENSIONS.MAT3, nameof(_Slicer));
169159
170- return new Matrix4x3Array ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . ByteStride , _Slicer . Encoding , _Slicer . Normalized ) ;
160+ return new Matrix4x3Array ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . ByteStride , Attribute . Encoding , Attribute . Normalized ) ;
171161 }
172162
173163 public Matrix4x4Array AsMatrix4x4Array ( )
174164 {
175- Guard . IsTrue ( _Slicer . IsValidVertexAttribute , nameof ( _Slicer ) ) ;
176- Guard . IsTrue ( _Slicer . Dimensions == DIMENSIONS . MAT4 , nameof ( _Slicer ) ) ;
177- return new Matrix4x4Array ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . ByteStride , _Slicer . Encoding , _Slicer . Normalized ) ;
165+ Guard . IsTrue ( Attribute . IsValidVertexAttribute , nameof ( Attribute ) ) ;
166+ Guard . IsTrue ( Attribute . Dimensions == DIMENSIONS . MAT4 , nameof ( Attribute ) ) ;
167+ return new Matrix4x4Array ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . ByteStride , Attribute . Encoding , Attribute . Normalized ) ;
178168 }
179169
180170
@@ -188,28 +178,28 @@ public Matrix4x4Array AsMatrix4x4Array()
188178 /// <returns>An array of colors</returns>
189179 public ColorArray AsColorArray ( Single defaultW = 1 )
190180 {
191- Guard . IsTrue ( _Slicer . IsValidVertexAttribute , nameof ( _Slicer ) ) ;
192- Guard . IsTrue ( _Slicer . Dimensions == DIMENSIONS . VEC3 || _Slicer . Dimensions == DIMENSIONS . VEC4 , nameof ( _Slicer ) ) ;
193- return new ColorArray ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . ByteStride , _Slicer . Dimensions . DimCount ( ) , _Slicer . Encoding , _Slicer . Normalized , defaultW ) ;
181+ Guard . IsTrue ( Attribute . IsValidVertexAttribute , nameof ( Attribute ) ) ;
182+ Guard . IsTrue ( Attribute . Dimensions == DIMENSIONS . VEC3 || Attribute . Dimensions == DIMENSIONS . VEC4 , nameof ( Attribute ) ) ;
183+ return new ColorArray ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . ByteStride , Attribute . Dimensions . DimCount ( ) , Attribute . Encoding , Attribute . Normalized , defaultW ) ;
194184 }
195185
196186 public MultiArray AsMultiArray ( int dimensions )
197187 {
198- Guard . IsTrue ( _Slicer . IsValidVertexAttribute , nameof ( _Slicer ) ) ;
199- Guard . IsTrue ( _Slicer . Dimensions == DIMENSIONS . SCALAR , nameof ( _Slicer ) ) ;
200- Guard . IsTrue ( _Slicer . ByteStride == 0 , nameof ( _Slicer ) ) ;
201- return new MultiArray ( _Data , _Slicer . ByteOffset , _Slicer . ItemsCount , _Slicer . ByteStride , dimensions , _Slicer . Encoding , _Slicer . Normalized ) ;
188+ Guard . IsTrue ( Attribute . IsValidVertexAttribute , nameof ( Attribute ) ) ;
189+ Guard . IsTrue ( Attribute . Dimensions == DIMENSIONS . SCALAR , nameof ( Attribute ) ) ;
190+ Guard . IsTrue ( Attribute . ByteStride == 0 , nameof ( Attribute ) ) ;
191+ return new MultiArray ( Data , Attribute . ByteOffset , Attribute . ItemsCount , Attribute . ByteStride , dimensions , Attribute . Encoding , Attribute . Normalized ) ;
202192 }
203193
204194 public IEnumerable < BYTES > GetItemsAsRawBytes ( )
205195 {
206- var rowOffset = this . _Slicer . ByteOffset ;
207- var rowStride = this . _Slicer . StepByteLength ;
208- var itemSize = this . _Slicer . Dimensions . DimCount ( ) * _Slicer . Encoding . ByteLength ( ) ;
196+ var itemSize = this . Attribute . ByteLength ;
197+ var rowStride = this . Attribute . StepByteLength ;
198+ var rowOffset = this . Attribute . ByteOffset ;
209199
210- for ( int i = 0 ; i < this . _Slicer . ItemsCount ; ++ i )
200+ for ( int i = 0 ; i < this . Attribute . ItemsCount ; ++ i )
211201 {
212- yield return this . _Data . Slice ( ( i * rowStride ) + rowOffset , itemSize ) ;
202+ yield return this . Data . Slice ( i * rowStride + rowOffset , itemSize ) ;
213203 }
214204 }
215205
@@ -241,7 +231,7 @@ public IEnumerable<BYTES> GetItemsAsRawBytes()
241231 System . Buffers . Binary . BinaryPrimitives . WriteUInt32LittleEndian ( indicesBuffer . Slice ( i * 4 ) , indices [ i ] ) ;
242232 }
243233
244- var blen = Attribute . ItemByteLength ;
234+ var blen = Attribute . ByteLength ;
245235
246236 var vertexBuffer = new byte [ values . Count * blen ] ;
247237 for ( int i = 0 ; i < values . Count ; ++ i )
0 commit comments