mirror of
https://github.com/hannobraun/Fornjot
synced 2025-01-20 15:16:16 +00:00
Refer to Vertex
via Handle
This commit is contained in:
parent
4780753fb6
commit
23d73c5410
@ -13,6 +13,7 @@ pub fn export(shape: &Shape) -> anyhow::Result<()> {
|
||||
|
||||
for triangle in shape_triangles {
|
||||
let triangle = triangle.vertices.map(|vertex| {
|
||||
let vertex = vertex.get();
|
||||
*indices_by_vertex.entry(vertex).or_insert_with(|| {
|
||||
let index = vertices.len();
|
||||
vertices.push(vertex);
|
||||
|
@ -2,7 +2,10 @@ use std::fmt;
|
||||
|
||||
use crate::math::Point;
|
||||
|
||||
use super::{operation::HandleAny, Operation};
|
||||
use super::{
|
||||
operation::{Handle, HandleAny},
|
||||
Operation,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub struct Vertex {
|
||||
@ -41,13 +44,13 @@ impl Operation for Vertex {
|
||||
|
||||
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub struct Triangle {
|
||||
pub vertices: [Vertex; 3],
|
||||
pub vertices: [Handle<Vertex>; 3],
|
||||
}
|
||||
|
||||
impl From<[&Vertex; 3]> for Triangle {
|
||||
fn from(vertices: [&Vertex; 3]) -> Self {
|
||||
impl From<[&Handle<Vertex>; 3]> for Triangle {
|
||||
fn from(vertices: [&Handle<Vertex>; 3]) -> Self {
|
||||
Self {
|
||||
vertices: vertices.map(|vertex| *vertex),
|
||||
vertices: vertices.map(|vertex| vertex.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -66,9 +69,6 @@ impl Operation for Triangle {
|
||||
}
|
||||
|
||||
fn children(&self) -> Vec<HandleAny> {
|
||||
self.vertices
|
||||
.iter()
|
||||
.map(|vertex| HandleAny::new(*vertex))
|
||||
.collect()
|
||||
self.vertices.iter().map(|vertex| vertex.to_any()).collect()
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,6 @@ pub fn model(shape: &mut Shape) {
|
||||
.vertex([0.5, 0.5, 0.5])
|
||||
.results();
|
||||
|
||||
let [a, b, c, d, e, f, g, h] =
|
||||
[a, b, c, d, e, f, g, h].map(|vertex| vertex.get());
|
||||
|
||||
shape
|
||||
.triangle([&a, &e, &g]) // left
|
||||
.triangle([&a, &g, &c])
|
||||
|
@ -59,9 +59,10 @@ impl Geometry<triangles::Vertex> {
|
||||
let mut vertices = Vec::new();
|
||||
|
||||
for triangle in &mesh_triangles {
|
||||
let triangle = triangle.vertices.map(|vertex| {
|
||||
let triangle = triangle.vertices.each_ref().map(|vertex| {
|
||||
Vec3::from(
|
||||
vertex
|
||||
.as_ref()
|
||||
.point
|
||||
.coords
|
||||
.components
|
||||
|
Loading…
Reference in New Issue
Block a user