use super::{ChunkPlacementError, ChunkPlacementId, ChunkRepresentation};
use molgfx_core::ResidencyTicket;
use molgfx_math::{Mat4, Rgba8};
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct PointChunkPlacement {
id: ChunkPlacementId,
ticket: ResidencyTicket,
model_to_world: Mat4,
diameter_pixels: f32,
color: Rgba8,
}
impl PointChunkPlacement {
pub fn new(
id: ChunkPlacementId,
ticket: ResidencyTicket,
model_to_world: Mat4,
diameter_pixels: f32,
color: Rgba8,
) -> Result<Self, ChunkPlacementError> {
if !model_to_world.is_finite() {
return Err(ChunkPlacementError::NonFiniteTransform);
}
ChunkRepresentation::points(diameter_pixels, color)?;
Ok(Self {
id,
ticket,
model_to_world,
diameter_pixels,
color,
})
}
#[must_use]
pub const fn id(self) -> ChunkPlacementId {
self.id
}
#[must_use]
pub const fn ticket(self) -> ResidencyTicket {
self.ticket
}
#[must_use]
pub const fn model_to_world(self) -> Mat4 {
self.model_to_world
}
#[must_use]
pub const fn representation(self) -> ChunkRepresentation {
ChunkRepresentation::Points {
diameter_pixels: self.diameter_pixels,
color: self.color,
}
}
#[must_use]
pub const fn diameter_pixels(self) -> f32 {
self.diameter_pixels
}
#[must_use]
pub const fn color(self) -> Rgba8 {
self.color
}
}