mirror of
https://github.com/hannobraun/Fornjot
synced 2025-02-01 21:05: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
|
pub fn to_any(&self) -> HandleAny
|
||||||
where
|
where
|
||||||
T: Operation + 'static,
|
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> {
|
impl<T> Clone for Handle<T> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
@ -16,11 +16,11 @@ impl Shape {
|
|||||||
pub fn vertex(
|
pub fn vertex(
|
||||||
&mut self,
|
&mut self,
|
||||||
vertex: impl Into<Vertex>,
|
vertex: impl Into<Vertex>,
|
||||||
) -> OperationResult<(Vertex,)> {
|
) -> OperationResult<(Handle<Vertex>,)> {
|
||||||
let vertex = vertex.into();
|
let vertex = Handle::new(vertex.into());
|
||||||
|
|
||||||
self.operations.push(OperationInSequence {
|
self.operations.push(OperationInSequence {
|
||||||
operation: HandleAny::new(vertex),
|
operation: vertex.to_any(),
|
||||||
previous: self
|
previous: self
|
||||||
.operations
|
.operations
|
||||||
.last()
|
.last()
|
||||||
@ -124,7 +124,7 @@ impl<'r, T> OperationResult<'r, T> {
|
|||||||
vertex: impl Into<Vertex>,
|
vertex: impl Into<Vertex>,
|
||||||
) -> OperationResult<'r, T::Out>
|
) -> OperationResult<'r, T::Out>
|
||||||
where
|
where
|
||||||
T: CombinRight<Vertex>,
|
T: CombinRight<Handle<Vertex>>,
|
||||||
{
|
{
|
||||||
let OperationResult {
|
let OperationResult {
|
||||||
results: (vertex,), ..
|
results: (vertex,), ..
|
||||||
|
@ -12,6 +12,9 @@ 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])
|
||||||
|
Loading…
Reference in New Issue
Block a user