Skip to main content

molgfx_render/engine/chunk_placement/
instances.rs

1use super::ChunkPlacementId;
2use molgfx_core::{AnalyticTemplate, ResidencyTicket};
3use molgfx_math::Rgba8;
4use std::sync::Arc;
5
6/// Declarative analytic rendering of one resident rigid-instance chunk.
7#[derive(Clone, Debug)]
8pub struct InstanceChunkPlacement {
9    id: ChunkPlacementId,
10    ticket: ResidencyTicket,
11    template: Arc<AnalyticTemplate>,
12    color: Rgba8,
13}
14
15impl PartialEq for InstanceChunkPlacement {
16    fn eq(&self, other: &Self) -> bool {
17        self.id == other.id
18            && self.ticket == other.ticket
19            && Arc::ptr_eq(&self.template, &other.template)
20            && self.color == other.color
21    }
22}
23
24impl InstanceChunkPlacement {
25    /// References immutable template geometry and one exact transform generation.
26    #[must_use]
27    pub fn new(
28        id: ChunkPlacementId,
29        ticket: ResidencyTicket,
30        template: Arc<AnalyticTemplate>,
31        color: Rgba8,
32    ) -> Self {
33        Self {
34            id,
35            ticket,
36            template,
37            color,
38        }
39    }
40
41    /// Stable caller-owned placement identity.
42    #[must_use]
43    pub const fn id(&self) -> ChunkPlacementId {
44        self.id
45    }
46
47    /// Exact rigid-transform generation.
48    #[must_use]
49    pub const fn ticket(&self) -> ResidencyTicket {
50        self.ticket
51    }
52
53    /// Shared homogeneous analytic template.
54    #[must_use]
55    pub const fn template(&self) -> &Arc<AnalyticTemplate> {
56        &self.template
57    }
58
59    /// Uniform fallback color used until a paged visual descriptor is attached.
60    #[must_use]
61    pub const fn color(&self) -> Rgba8 {
62        self.color
63    }
64}