mirror of
https://github.com/hannobraun/Fornjot
synced 2025-08-15 13:46:04 +00:00
Simplify
This commit is contained in:
parent
44ab4227da
commit
b8d8cb3550
@ -8,7 +8,11 @@ use winit::{
|
||||
window::{Window, WindowAttributes, WindowId},
|
||||
};
|
||||
|
||||
use crate::{object::HandleAny, render::Renderer, view::OperationView};
|
||||
use crate::{
|
||||
object::{HandleAny, Object},
|
||||
render::Renderer,
|
||||
view::OperationView,
|
||||
};
|
||||
|
||||
pub fn run(shape: HandleAny) -> anyhow::Result<()> {
|
||||
let view = OperationView::new(shape);
|
||||
@ -71,7 +75,7 @@ impl ApplicationHandler for App {
|
||||
event_loop.exit();
|
||||
}
|
||||
WindowEvent::RedrawRequested => {
|
||||
if let Err(err) = renderer.render(&self.view) {
|
||||
if let Err(err) = renderer.render(&self.view.tri_mesh()) {
|
||||
eprintln!("Render error: {err}");
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||
use anyhow::anyhow;
|
||||
use winit::window::Window;
|
||||
|
||||
use crate::{object::Object, view::OperationView};
|
||||
use crate::geometry::TriMesh;
|
||||
|
||||
use super::{geometry::Geometry, pipeline::Pipeline};
|
||||
|
||||
@ -76,11 +76,8 @@ impl Renderer {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn render(&mut self, operations: &OperationView) -> anyhow::Result<()> {
|
||||
let selected_operation = operations.selected();
|
||||
|
||||
let geometry =
|
||||
Geometry::new(&self.device, &selected_operation.tri_mesh());
|
||||
pub fn render(&mut self, tri_mesh: &TriMesh) -> anyhow::Result<()> {
|
||||
let geometry = Geometry::new(&self.device, tri_mesh);
|
||||
|
||||
let mut encoder = self
|
||||
.device
|
||||
|
@ -6,27 +6,11 @@ use crate::{
|
||||
#[derive(Clone)]
|
||||
pub struct OperationView {
|
||||
operation: HandleAny,
|
||||
children: Vec<Self>,
|
||||
selected: Option<usize>,
|
||||
}
|
||||
|
||||
impl OperationView {
|
||||
pub fn new(operation: HandleAny) -> Self {
|
||||
let children =
|
||||
operation.children().into_iter().map(Self::new).collect();
|
||||
|
||||
Self {
|
||||
operation,
|
||||
children,
|
||||
selected: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn selected(&self) -> &Self {
|
||||
self.selected
|
||||
.and_then(|selected| self.children.get(selected))
|
||||
.map(|child| child.selected())
|
||||
.unwrap_or(self)
|
||||
Self { operation }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user