mirror of
https://github.com/hannobraun/Fornjot
synced 2025-08-08 18:26:08 +00:00
Make use of Vertices
more explicit
This commit is contained in:
parent
b3e765373e
commit
3a21d86393
@ -18,6 +18,7 @@ pub use self::{
|
||||
device::DeviceError,
|
||||
draw_config::DrawConfig,
|
||||
renderer::{Renderer, RendererInitError},
|
||||
vertices::Vertices,
|
||||
};
|
||||
|
||||
pub const DEPTH_FORMAT: wgpu::TextureFormat = wgpu::TextureFormat::Depth32Float;
|
||||
|
@ -17,17 +17,7 @@ impl Vertices {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn vertices(&self) -> &[Vertex] {
|
||||
self.vertices.as_slice()
|
||||
}
|
||||
|
||||
pub fn indices(&self) -> &[Index] {
|
||||
self.indices.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&Mesh<fj_math::Point<3>>> for Vertices {
|
||||
fn from(mesh: &Mesh<fj_math::Point<3>>) -> Self {
|
||||
pub fn from_mesh(mesh: &Mesh<fj_math::Point<3>>) -> Self {
|
||||
let mut vertices = Vec::new();
|
||||
let mut indices = Vec::new();
|
||||
let mut indices_by_vertex = BTreeMap::new();
|
||||
@ -59,6 +49,14 @@ impl From<&Mesh<fj_math::Point<3>>> for Vertices {
|
||||
|
||||
Self { vertices, indices }
|
||||
}
|
||||
|
||||
pub fn vertices(&self) -> &[Vertex] {
|
||||
self.vertices.as_slice()
|
||||
}
|
||||
|
||||
pub fn indices(&self) -> &[Index] {
|
||||
self.indices.as_slice()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
|
@ -5,7 +5,7 @@ use tracing::warn;
|
||||
use crate::{
|
||||
RendererInitError,
|
||||
camera::{Camera, FocusPoint},
|
||||
graphics::{DrawConfig, Renderer},
|
||||
graphics::{DrawConfig, Renderer, Vertices},
|
||||
input::{
|
||||
CameraTuningConfig, DEFAULT_CAMERA_TUNING_CONFIG, InputEvent,
|
||||
MouseButton,
|
||||
@ -58,7 +58,8 @@ impl Viewer {
|
||||
|
||||
/// Handle the model being updated
|
||||
pub fn handle_model_update(&mut self, model: Model) {
|
||||
self.renderer.update_geometry((&model.mesh).into());
|
||||
self.renderer
|
||||
.update_geometry(Vertices::from_mesh(&model.mesh));
|
||||
|
||||
let aabb = model.mesh.aabb();
|
||||
if self.model.replace((model, aabb)).is_none() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user