molgfx_render/engine/chunk_placement/
points.rs1use super::{ChunkPlacementError, ChunkPlacementId, ChunkRepresentation};
2use molgfx_core::ResidencyTicket;
3use molgfx_math::{Mat4, Rgba8};
4
5#[derive(Clone, Copy, Debug, PartialEq)]
7pub struct PointChunkPlacement {
8 id: ChunkPlacementId,
9 ticket: ResidencyTicket,
10 model_to_world: Mat4,
11 diameter_pixels: f32,
12 color: Rgba8,
13}
14
15impl PointChunkPlacement {
16 pub fn new(
22 id: ChunkPlacementId,
23 ticket: ResidencyTicket,
24 model_to_world: Mat4,
25 diameter_pixels: f32,
26 color: Rgba8,
27 ) -> Result<Self, ChunkPlacementError> {
28 if !model_to_world.is_finite() {
29 return Err(ChunkPlacementError::NonFiniteTransform);
30 }
31 ChunkRepresentation::points(diameter_pixels, color)?;
32 Ok(Self {
33 id,
34 ticket,
35 model_to_world,
36 diameter_pixels,
37 color,
38 })
39 }
40
41 #[must_use]
43 pub const fn id(self) -> ChunkPlacementId {
44 self.id
45 }
46
47 #[must_use]
49 pub const fn ticket(self) -> ResidencyTicket {
50 self.ticket
51 }
52
53 #[must_use]
55 pub const fn model_to_world(self) -> Mat4 {
56 self.model_to_world
57 }
58
59 #[must_use]
61 pub const fn representation(self) -> ChunkRepresentation {
62 ChunkRepresentation::Points {
63 diameter_pixels: self.diameter_pixels,
64 color: self.color,
65 }
66 }
67
68 #[must_use]
70 pub const fn diameter_pixels(self) -> f32 {
71 self.diameter_pixels
72 }
73
74 #[must_use]
76 pub const fn color(self) -> Rgba8 {
77 self.color
78 }
79}