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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
use std::ops::Range;

use crate::layout::{
    FieldAlignment, PointAttributeDefinition, PointLayout, PointType, PrimitiveType,
};

use super::{
    InterleavedPointBuffer, PerAttributePointBuffer, PerAttributePointBufferSlice, PointBuffer,
};

/// A non-owning view for a contiguous slice of interleaved point data. This is like `InterleavedVecPointBuffer`, but it
/// does not own the point data. It is useful for passing around point data in an untyped but safe manner, for example in
/// I/O heavy code.
pub struct InterleavedPointView<'d> {
    point_data: &'d [u8],
    point_layout: PointLayout,
    point_count: usize,
    size_of_point_entry: usize,
}

impl<'d> InterleavedPointView<'d> {
    /// Creates a new `InterleavedPointView` referencing the given slice of points
    ///
    /// ```
    /// # use pasture_core::containers::*;
    /// # use pasture_core::layout::*;
    /// # use pasture_derive::PointType;
    ///
    /// #[repr(C)]
    /// #[derive(PointType)]
    /// struct MyPointType(#[pasture(BUILTIN_INTENSITY)] u16);
    ///
    /// let points = vec![MyPointType(42), MyPointType(43)];
    /// let view = InterleavedPointView::from_slice(points.as_slice());
    /// ```
    pub fn from_slice<T: PointType>(points: &'d [T]) -> Self {
        let raw_points_data = unsafe {
            std::slice::from_raw_parts(
                points.as_ptr() as *const u8,
                points.len() * std::mem::size_of::<T>(),
            )
        };
        let point_layout = T::layout();
        let size_of_point_entry = point_layout.size_of_point_entry() as usize;
        Self {
            point_data: raw_points_data,
            point_layout,
            point_count: points.len(),
            size_of_point_entry,
        }
    }

    /// Creates a new `InterleavedPointView` referencing the given slice of untyped point data
    pub fn from_raw_slice(points: &'d [u8], layout: PointLayout) -> Self {
        let size_of_single_point = layout.size_of_point_entry() as usize;
        if points.len() % size_of_single_point != 0 {
            panic!("InterleavedPointView::from_raw_slice: points.len() is no multiple of point entry size in PointLayout!");
        }
        let num_points = points.len() / size_of_single_point;
        let size_of_point_entry = layout.size_of_point_entry() as usize;
        Self {
            point_data: points,
            point_layout: layout,
            point_count: num_points,
            size_of_point_entry,
        }
    }

    /// Returns the data for the points of the associated `InterleavedPointView` as a typed slice.
    ///
    /// # Panics
    ///
    /// If the `PointLayout` of the view does not match the layout of type `T`
    ///
    /// ```
    /// # use pasture_core::containers::*;
    /// # use pasture_core::layout::*;
    /// # use pasture_derive::PointType;
    ///
    /// #[repr(C)]
    /// #[derive(Debug, Copy, Clone, PartialEq, Eq, PointType)]
    /// struct MyPointType(#[pasture(BUILTIN_INTENSITY)] u16);
    ///
    /// let points = vec![MyPointType(42), MyPointType(43)];
    /// let view = InterleavedPointView::from_slice(points.as_slice());
    /// let points_ref = view.get_typed_data::<MyPointType>();
    /// assert_eq!(points_ref, points.as_slice());
    /// ```
    pub fn get_typed_data<T: PointType>(&self) -> &'d [T] {
        if self.point_layout != T::layout() {
            panic!("InterleavedPointView::get_typed_data: Point layout does not match type T!");
        }
        unsafe {
            std::slice::from_raw_parts(self.point_data.as_ptr() as *const T, self.point_count)
        }
    }
}

impl<'d> PointBuffer for InterleavedPointView<'d> {
    // TODO Refactor the code here and in InterleavedVecPointStorage (they are basically identical) by extracting them into a standalone function
    fn get_raw_point(&self, point_index: usize, buf: &mut [u8]) {
        if point_index >= self.len() {
            panic!(
                "InterleavedPointView::get_raw_point: Point index {} out of bounds",
                point_index
            );
        }

        let offset_to_point = point_index * self.size_of_point_entry;
        let point_slice =
            &self.point_data[offset_to_point..(offset_to_point + self.size_of_point_entry)];
        buf.copy_from_slice(point_slice);
    }

    fn get_raw_attribute(
        &self,
        point_index: usize,
        attribute: &PointAttributeDefinition,
        buf: &mut [u8],
    ) {
        if point_index >= self.len() {
            panic!(
                "InterleavedPointView::get_raw_attribute: Point index {} out of bounds!",
                point_index
            );
        }

        if let Some(attribute_in_buffer) = self.point_layout.get_attribute(attribute) {
            let offset_to_point_bytes = point_index * self.size_of_point_entry as usize;
            let offset_to_attribute = offset_to_point_bytes + attribute_in_buffer.offset() as usize;
            let attribute_size = attribute.size() as usize;

            buf.copy_from_slice(
                &self.point_data[offset_to_attribute..offset_to_attribute + attribute_size],
            );
        } else {
            panic!("InterleavedPointView::get_raw_attribute: Attribute {:?} is not part of this PointBuffer's PointLayout!", attribute);
        }
    }

    fn get_raw_points(&self, index_range: std::ops::Range<usize>, buf: &mut [u8]) {
        let points_ref = self.get_raw_points_ref(index_range);
        buf[0..points_ref.len()].copy_from_slice(points_ref);
    }

    fn get_raw_attribute_range(
        &self,
        index_range: std::ops::Range<usize>,
        attribute: &PointAttributeDefinition,
        buf: &mut [u8],
    ) {
        if index_range.end > self.len() {
            panic!(
                "InterleavedPointView::get_raw_attribute_range: Point indices {:?} out of bounds!",
                index_range
            );
        }

        if let Some(attribute_in_buffer) = self.point_layout.get_attribute(attribute) {
            let attribute_size = attribute.size() as usize;
            let start_index = index_range.start;

            for point_index in index_range {
                let offset_to_point_bytes = point_index * self.size_of_point_entry as usize;
                let offset_to_attribute =
                    offset_to_point_bytes + attribute_in_buffer.offset() as usize;
                let offset_in_target_buf = (point_index - start_index) * attribute_size;
                let target_buf_slice =
                    &mut buf[offset_in_target_buf..offset_in_target_buf + attribute_size];

                target_buf_slice.copy_from_slice(
                    &self.point_data[offset_to_attribute..offset_to_attribute + attribute_size],
                );
            }
        } else {
            panic!("InterleavedPointView::get_raw_attribute: Attribute {:?} is not part of this PointBuffer's PointLayout!", attribute);
        }
    }

    fn len(&self) -> usize {
        self.point_count
    }

    fn point_layout(&self) -> &PointLayout {
        &self.point_layout
    }

    fn as_interleaved(&self) -> Option<&dyn InterleavedPointBuffer> {
        Some(self)
    }
}

impl<'d> InterleavedPointBuffer for InterleavedPointView<'d> {
    fn get_raw_point_ref(&self, point_index: usize) -> &[u8] {
        if point_index >= self.len() {
            panic!(
                "InterleavedPointView::get_raw_point_ref: Point index {} out of bounds!",
                point_index
            );
        }

        let offset_to_point = point_index * self.size_of_point_entry as usize;
        &self.point_data[offset_to_point..offset_to_point + self.size_of_point_entry as usize]
    }

    fn get_raw_points_ref(&self, index_range: std::ops::Range<usize>) -> &[u8] {
        if index_range.end > self.len() {
            panic!(
                "InterleavedPointView::get_raw_points_ref: Point indices {:?} out of bounds!",
                index_range
            );
        }

        let offset_to_point = index_range.start * self.size_of_point_entry as usize;
        let total_bytes_of_range =
            (index_range.end - index_range.start) * self.size_of_point_entry as usize;
        &self.point_data[offset_to_point..offset_to_point + total_bytes_of_range]
    }
}

/// A non-owning view for per-attribute point data. This is like `PerAttributeVecPointBuffer`, but it does not own the
/// point data. It is useful for passing around point data in an untyped but safe manner, for example in I/O heavy code.
pub struct PerAttributePointView<'d> {
    point_data: Vec<&'d [u8]>,
    point_layout: PointLayout,
    point_count: usize,
}

impl<'d> PerAttributePointView<'d> {
    /// Creates a new empty `PerAttributePointView` that stores no data and has an empty `PointLayout`
    /// ```
    /// # use pasture_core::containers::*;
    /// # use pasture_core::layout::*;
    ///
    /// let point_view = PerAttributePointView::new();
    /// assert_eq!(point_view.point_layout(), &PointLayout::default());
    /// ```
    pub fn new() -> Self {
        Self {
            point_data: vec![],
            point_layout: PointLayout::default(),
            point_count: 0,
        }
    }

    /// Creates a new `PerAttributePointView` from the given attribute buffers and `PointLayout`. The
    /// `attributes` parameter must contain one slice for each `PointAttributeDefinition` in the given
    /// `PointLayout`, in the exact order in which they are defined in the `PointLayout`.
    /// *Note*: You will rarely have to use this method directly, instead prefer to use the `per_attribute_point_view!`
    /// macro or use `PerAttributePointView::new()` together with `PerAttributePointView::push_attribute`
    ///
    /// # Panics
    ///
    /// If the slices in `attributes` don't match the expected data layout of `point_layout`. Reasons for this
    /// can be that `attributes.len()` does not match the number of attributes in the `PointLayout`, or that
    /// the length of one of the slices in `attributes` is no multiple of the size of a single entry of the
    /// corresponding point attribute in the `PointLayout`.
    pub fn from_slices(attributes: Vec<&'d [u8]>, point_layout: PointLayout) -> Self {
        if !Self::attribute_buffers_match_layout(&attributes, &point_layout) {
            panic!("PerAttributePointView::from_slices: attributes don't match the PointLayout!");
        }

        let point_count = if attributes.len() != 0 {
            attributes[0].len() / point_layout.attributes().next().unwrap().size() as usize
        } else {
            0
        };

        Self {
            point_data: attributes,
            point_layout,
            point_count,
        }
    }

    /// Push data for a new point attribute into the associated `PerAttributePointView`. This extends the internal
    /// `PointLayout` of the view. The number of entries in `attribute` must match the number of entries in all other
    /// attributes that this view stores, if there are any.
    ///
    /// # Panics
    ///
    /// If there are attributes already stored in this view, but `attribute.len()` does not match the length of the
    /// other attributes
    ///
    /// ```
    /// # use pasture_core::containers::*;
    /// # use pasture_core::layout::*;
    /// # use nalgebra::Vector3;
    ///
    /// let positions = vec![Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 1.0, 1.0)];
    ///
    /// let mut point_view = PerAttributePointView::new();
    /// point_view.push_attribute(&positions, &attributes::POSITION_3D);
    /// ```
    pub fn push_attribute<T: PrimitiveType>(
        &mut self,
        attribute: &'d [T],
        attribute_definition: &PointAttributeDefinition,
    ) {
        if attribute_definition.datatype() != T::data_type() {
            panic!("PerAttributePointView::push_attribute: data type of T and PointAttributeDefinition do not match!");
        }
        if self.point_data.is_empty() {
            self.push_first_attribute(attribute, attribute_definition);
        } else {
            self.push_additional_attribute(attribute, attribute_definition);
        }
    }

    /// Returns the raw data for the given point attribute. Returns `None` if no matching attribute
    /// is stored in the associated `PerAttributePointView`.
    ///
    /// ```
    /// # use pasture_core::containers::*;
    /// # use pasture_core::layout::*;
    /// # use nalgebra::Vector3;
    ///
    /// let positions = vec![Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 1.0, 1.0)];
    ///
    /// let mut point_view = PerAttributePointView::new();
    /// point_view.push_attribute(&positions, &attributes::POSITION_3D);
    ///
    /// let raw_positions = point_view.get_raw_data_for_attribute(&attributes::POSITION_3D);
    /// ```
    pub fn get_raw_data_for_attribute(
        &self,
        attribute: &PointAttributeDefinition,
    ) -> Option<&'d [u8]> {
        self.point_layout
            .index_of(attribute)
            .map(|attribute_index| self.point_data[attribute_index])
    }

    /// Returns the data for the given point attribute as a typed slice. Returns `None` if no matching
    /// attribute is stored in the associated `PerAttributePointView`.
    ///
    /// # Panics
    ///
    /// If the associated `PointAttributeDefinition` does not store values of data type `T`
    ///
    /// ```
    /// # use pasture_core::containers::*;
    /// # use pasture_core::layout::*;
    /// # use nalgebra::Vector3;
    ///
    /// let positions = vec![Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 1.0, 1.0)];
    ///
    /// let mut point_view = PerAttributePointView::new();
    /// point_view.push_attribute(&positions, &attributes::POSITION_3D);
    ///
    /// let retrieved_positions = point_view.get_typed_data_for_attribute::<Vector3<f64>>(&attributes::POSITION_3D).unwrap();
    /// assert_eq!(retrieved_positions, positions.as_slice());
    /// ```
    pub fn get_typed_data_for_attribute<T: PrimitiveType>(
        &self,
        attribute: &PointAttributeDefinition,
    ) -> Option<&'d [T]> {
        if attribute.datatype() != T::data_type() {
            panic!("PerAttributePointView::get_typed_data_for_attribute: PointAttributeDefinition does not have datatype T!");
        }
        self.point_layout
            .index_of(attribute)
            .map(|attribute_index| {
                let raw_slice = self.point_data[attribute_index];
                unsafe {
                    std::slice::from_raw_parts(raw_slice.as_ptr() as *const T, self.point_count)
                }
            })
    }

    /// Returns the `PointLayout` of the associated `PerAttributePointView`
    ///
    /// ```
    /// # use pasture_core::containers::*;
    /// # use pasture_core::layout::*;
    /// # use nalgebra::Vector3;
    ///
    /// let positions = vec![Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 1.0, 1.0)];
    ///
    /// let mut point_view = PerAttributePointView::new();
    /// point_view.push_attribute(&positions, &attributes::POSITION_3D);
    ///
    /// assert_eq!(point_view.point_layout(), &PointLayout::from_attributes(&[attributes::POSITION_3D]));
    /// ```
    pub fn point_layout(&self) -> &PointLayout {
        &self.point_layout
    }

    /// Returns the number of unique point entries in the associated `PerAttributePointView`
    ///
    /// ```
    /// # use pasture_core::containers::*;
    /// # use pasture_core::layout::*;
    /// # use nalgebra::Vector3;
    ///
    /// let positions = vec![Vector3::new(0.0, 0.0, 0.0), Vector3::new(1.0, 1.0, 1.0)];
    ///
    /// let mut point_view = PerAttributePointView::new();
    /// point_view.push_attribute(&positions, &attributes::POSITION_3D);
    ///
    /// assert_eq!(2, point_view.len());
    /// ```
    pub fn len(&self) -> usize {
        self.point_count
    }

    fn push_first_attribute<T: PrimitiveType>(
        &mut self,
        attribute: &'d [T],
        attribute_definition: &PointAttributeDefinition,
    ) {
        self.point_count = attribute.len();

        let attribute_bytes = unsafe {
            std::slice::from_raw_parts(
                attribute.as_ptr() as *const u8,
                attribute.len() * std::mem::size_of::<T>(),
            )
        };
        self.point_data.push(attribute_bytes);
        self.point_layout
            .add_attribute(attribute_definition.clone(), FieldAlignment::Default);
    }

    fn push_additional_attribute<T: PrimitiveType>(
        &mut self,
        attribute: &'d [T],
        attribute_definition: &PointAttributeDefinition,
    ) {
        if attribute.len() != self.point_count {
            panic!("PerAttributePointView::push_attribute: attribute data length does not match point count of this view!");
        }

        let attribute_bytes = unsafe {
            std::slice::from_raw_parts(
                attribute.as_ptr() as *const u8,
                attribute.len() * std::mem::size_of::<T>(),
            )
        };
        self.point_data.push(attribute_bytes);
        self.point_layout
            .add_attribute(attribute_definition.clone(), FieldAlignment::Default);
    }

    fn attribute_buffers_match_layout(attributes: &[&[u8]], point_layout: &PointLayout) -> bool {
        if attributes.len() != point_layout.attributes().count() {
            return false;
        }

        // Check that all attribute slices store the same number of entries
        let mut num_points = None;
        for (attribute_definition, &data) in point_layout.attributes().zip(attributes.iter()) {
            if data.len() as u64 % attribute_definition.size() != 0 {
                return false;
            }
            let point_count_in_data = data.len() as u64 / attribute_definition.size();
            if let Some(point_count) = num_points {
                if point_count != point_count_in_data {
                    return false;
                }
            } else {
                num_points = Some(point_count_in_data);
            }
        }

        true
    }
}

impl<'d> PointBuffer for PerAttributePointView<'d> {
    fn get_raw_point(&self, point_index: usize, buf: &mut [u8]) {
        if point_index >= self.len() {
            panic!(
                "PerAttributePointView::get_raw_point: Point index {} out of bounds!",
                point_index
            );
        }

        for (idx, attribute) in self.point_layout.attributes().enumerate() {
            let attribute_buffer = self.point_data[idx];
            let attribute_size = attribute.size() as usize;
            let offset_in_buffer = point_index * attribute_size;
            let offset_in_point = attribute.offset() as usize;

            let buf_slice = &mut buf[offset_in_point..offset_in_point + attribute_size];
            let attribute_slice =
                &attribute_buffer[offset_in_buffer..offset_in_buffer + attribute_size];
            buf_slice.copy_from_slice(attribute_slice);
        }
    }

    fn get_raw_attribute(
        &self,
        point_index: usize,
        attribute: &PointAttributeDefinition,
        buf: &mut [u8],
    ) {
        let attribute_slice = self.get_raw_attribute_ref(point_index, attribute);
        buf.copy_from_slice(attribute_slice);
    }

    fn get_raw_points(&self, index_range: std::ops::Range<usize>, buf: &mut [u8]) {
        if index_range.end > self.len() {
            panic!(
                "PerAttributePointView::get_raw_points: Point indices {:?} out of bounds!",
                index_range
            );
        }

        let point_size = self.point_layout.size_of_point_entry() as usize;

        for (idx, attribute) in self.point_layout.attributes().enumerate() {
            let attribute_buffer = self.point_data[idx];
            let attribute_size = attribute.size() as usize;
            for point_index in index_range.clone() {
                // Get the appropriate subsections of the attribute buffer and the point buffer that is passed in
                let offset_in_attribute_buffer = point_index * attribute_size;
                let attribute_slice = &attribute_buffer
                    [offset_in_attribute_buffer..offset_in_attribute_buffer + attribute_size];

                let offset_in_point = attribute.offset() as usize;
                let offset_in_points_buffer = point_index * point_size + offset_in_point;
                let buf_slice =
                    &mut buf[offset_in_points_buffer..offset_in_points_buffer + attribute_size];

                buf_slice.copy_from_slice(attribute_slice);
            }
        }
    }

    fn get_raw_attribute_range(
        &self,
        index_range: std::ops::Range<usize>,
        attribute: &PointAttributeDefinition,
        buf: &mut [u8],
    ) {
        let attribute_buffer_slice = self.get_raw_attribute_range_ref(index_range, attribute);
        buf.copy_from_slice(attribute_buffer_slice);
    }

    fn len(&self) -> usize {
        self.point_count
    }

    fn point_layout(&self) -> &PointLayout {
        &self.point_layout
    }

    fn as_per_attribute(&self) -> Option<&dyn PerAttributePointBuffer> {
        Some(self)
    }
}

impl<'d> PerAttributePointBuffer for PerAttributePointView<'d> {
    fn get_raw_attribute_ref(
        &self,
        point_index: usize,
        attribute: &PointAttributeDefinition,
    ) -> &[u8] {
        if point_index >= self.len() {
            panic!(
                "PerAttributePointView::get_raw_attribute_ref: Point index {} out of bounds!",
                point_index
            );
        }

        let attribute_index = match self.point_layout.index_of(attribute) {
            Some(idx) => idx,
            None => panic!("PerAttributePointView::get_raw_attribute_ref: Attribute {:?} is not part of this PointBuffer's PointLayout!", attribute),
        };

        let attribute_buffer = self.point_data[attribute_index];
        let attribute_size = attribute.size() as usize;
        let offset_in_attribute_buffer = point_index * attribute_size;
        &attribute_buffer[offset_in_attribute_buffer..offset_in_attribute_buffer + attribute_size]
    }

    fn get_raw_attribute_range_ref(
        &self,
        index_range: Range<usize>,
        attribute: &PointAttributeDefinition,
    ) -> &[u8] {
        if index_range.end > self.len() {
            panic!(
                "PerAttributePointView::get_raw_attribute_range_ref: Point indices {:?} out of bounds!",
                index_range
            );
        }

        let attribute_index = match self.point_layout.index_of(attribute) {
            Some(idx) => idx,
            None => panic!("PerAttributePointView::get_raw_attribute_range_ref: Attribute {:?} is not part of this PointBuffer's PointLayout!", attribute),
        };

        let attribute_buffer = self.point_data[attribute_index];
        let start_offset_in_attribute_buffer = index_range.start * attribute.size() as usize;
        let end_offset_in_attribute_buffer = start_offset_in_attribute_buffer
            + (index_range.end - index_range.start) * attribute.size() as usize;
        &attribute_buffer[start_offset_in_attribute_buffer..end_offset_in_attribute_buffer]
    }

    fn slice(&self, range: Range<usize>) -> PerAttributePointBufferSlice<'_> {
        PerAttributePointBufferSlice::new(self, range)
    }
}