mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-01 12:55:54 +00:00
Prepare to refer to Vertex
by Handle
This commit is contained in:
parent
1122367341
commit
f66603375b
@ -20,6 +20,13 @@ impl<T> Handle<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get(&self) -> T
|
||||
where
|
||||
T: Copy,
|
||||
{
|
||||
*self.as_ref()
|
||||
}
|
||||
|
||||
pub fn to_any(&self) -> HandleAny
|
||||
where
|
||||
T: Operation + 'static,
|
||||
@ -35,6 +42,12 @@ impl<T> Handle<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> AsRef<T> for Handle<T> {
|
||||
fn as_ref(&self) -> &T {
|
||||
self.inner.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Clone for Handle<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
|
@ -16,11 +16,11 @@ impl Shape {
|
||||
pub fn vertex(
|
||||
&mut self,
|
||||
vertex: impl Into<Vertex>,
|
||||
) -> OperationResult<(Vertex,)> {
|
||||
let vertex = vertex.into();
|
||||
) -> OperationResult<(Handle<Vertex>,)> {
|
||||
let vertex = Handle::new(vertex.into());
|
||||
|
||||
self.operations.push(OperationInSequence {
|
||||
operation: HandleAny::new(vertex),
|
||||
operation: vertex.to_any(),
|
||||
previous: self
|
||||
.operations
|
||||
.last()
|
||||
@ -124,7 +124,7 @@ impl<'r, T> OperationResult<'r, T> {
|
||||
vertex: impl Into<Vertex>,
|
||||
) -> OperationResult<'r, T::Out>
|
||||
where
|
||||
T: CombinRight<Vertex>,
|
||||
T: CombinRight<Handle<Vertex>>,
|
||||
{
|
||||
let OperationResult {
|
||||
results: (vertex,), ..
|
||||
|
@ -12,6 +12,9 @@ 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])
|
||||
|
Loading…
Reference in New Issue
Block a user