mln-rs-engine 0.0.18

Part of mln-rs, a Rust port of the MapLibre Native map rendering core. Depend on mln-rs instead.
Documentation
#[derive(Clone, Debug, PartialEq, mln_wire::Wire)]
pub(crate) struct SegmentBase {
    pub(crate) vertex_offset: usize,
    pub(crate) index_offset: usize,
    pub(crate) vertex_length: usize,
    pub(crate) index_length: usize,
    pub(crate) base_instance: usize,
    pub(crate) instance_count: usize,
    pub(crate) sort_key: f32,
}

impl SegmentBase {
    #[must_use]
    pub(crate) fn new(vertex_offset: usize, index_offset: usize) -> Self {
        Self::with_lengths(vertex_offset, index_offset, 0, 0)
    }

    #[must_use]
    pub(crate) fn with_lengths(
        vertex_offset: usize,
        index_offset: usize,
        vertex_length: usize,
        index_length: usize,
    ) -> Self {
        SegmentBase {
            vertex_offset,
            index_offset,
            vertex_length,
            index_length,
            base_instance: 0,
            instance_count: 1,
            sort_key: 0.0,
        }
    }

    /// The field-by-field copy the C++ code spells out (there is no copy
    /// constructor).
    #[must_use]
    pub(crate) fn copy(&self) -> Self {
        SegmentBase {
            vertex_offset: self.vertex_offset,
            index_offset: self.index_offset,
            vertex_length: self.vertex_length,
            index_length: self.index_length,
            base_instance: self.base_instance,
            instance_count: self.instance_count,
            sort_key: self.sort_key,
        }
    }
}

/// The most vertices a segment holds, since they are addressed by 16-bit
/// indices.
pub(crate) const MAX_SEGMENT_VERTICES: usize = u16::MAX as usize;