No longer render vertices

Vertices are currently exposed through `Operation` in a privileged way,
and with the new topographical operations incoming, this no longer makes
sense.

Rendering vertices depends on this privileged way. I'm removing it, so I
can then clean up `Operation` itself. Right now, this feature isn't
adding a lot of value, so I don't think it's much of a loss.

It seems desirable to render vertices again at some point. But it also
seems desirable to render other things that currently aren't, like
planes (or surfaces in general). It makes sense that we'd grow a
mechanism for things with specialized rendering in the future, but right
now I neither know what that would be, nor do I want to be weighed down
by it.
This commit is contained in:
Hanno Braun 2025-01-13 19:46:49 +01:00
parent 30a57f8fde
commit 14367cd783
3 changed files with 3 additions and 51 deletions

View File

@ -5,7 +5,7 @@ use wgpu::util::DeviceExt;
use crate::geometry::Operation;
use super::pipelines::{triangles, vertices};
use super::pipelines::triangles;
pub struct Geometry<V> {
pub vertices: wgpu::Buffer,
@ -14,42 +14,6 @@ pub struct Geometry<V> {
_vertex: PhantomData<V>,
}
impl Geometry<vertices::Vertex> {
pub fn vertices(device: &wgpu::Device, operation: &dyn Operation) -> Self {
let mut mesh_vertices = Vec::new();
operation.vertices(&mut mesh_vertices);
let mut vertices = Vec::new();
let mut indices = Vec::new();
for mesh_vertex in mesh_vertices {
let s = 0.05;
let p = mesh_vertex.point;
let [a, b, c, d] = [[-s, -s], [s, -s], [-s, s], [s, s]]
.map(|[x, y]| p + [x, y, 0.])
.map(|point| {
point.coords.components.map(|scalar| scalar.value() as f32)
});
for vertex in [a, b, c, c, b, d] {
let index = vertices.len() as u32;
let vertex = vertices::Vertex {
position: vertex,
center: p.coords.components.map(|s| s.value() as f32),
radius: s as f32,
};
vertices.push(vertex);
indices.push(index);
}
}
Self::new(device, &vertices, &indices)
}
}
impl Geometry<triangles::Vertex> {
pub fn triangles(device: &wgpu::Device, operation: &dyn Operation) -> Self {
let mut mesh_triangles = Vec::new();

View File

@ -3,10 +3,9 @@ use std::f32::consts::PI;
use glam::{Mat4, Vec3};
use wgpu::util::DeviceExt;
use super::{triangles, vertices, Pipeline};
use super::{triangles, Pipeline};
pub struct Pipelines {
pub vertices: Pipeline<vertices::Vertex>,
pub triangles: Pipeline<triangles::Vertex>,
}
@ -25,12 +24,6 @@ impl Pipelines {
usage: wgpu::BufferUsages::UNIFORM,
});
let vertices = Pipeline::new(
device,
config,
wgpu::include_wgsl!("shaders/vertices.wgsl"),
&uniforms,
);
let triangles = Pipeline::new(
device,
config,
@ -38,10 +31,7 @@ impl Pipelines {
&uniforms,
);
Self {
vertices,
triangles,
}
Self { triangles }
}
}

View File

@ -90,7 +90,6 @@ impl Renderer {
pub fn render(&mut self, operations: &OperationView) -> anyhow::Result<()> {
let selected_operation = operations.selected();
let vertices = Geometry::vertices(&self.device, selected_operation);
let triangles = Geometry::triangles(&self.device, selected_operation);
let mut encoder = self
@ -129,7 +128,6 @@ impl Renderer {
occlusion_query_set: None,
});
self.pipelines.vertices.draw(&mut render_pass, &vertices);
self.pipelines.triangles.draw(&mut render_pass, &triangles);
self.text_renderer.render(
operations,