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