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