Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypass GlobalCurve in more code #1114

Merged
merged 9 commits into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions crates/fj-kernel/src/algorithms/intersect/surface_surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct SurfaceSurfaceIntersection {

impl SurfaceSurfaceIntersection {
/// Compute the intersection between two surfaces
pub fn compute(surfaces: [&Surface; 2], store: &Stores) -> Option<Self> {
pub fn compute(surfaces: [&Surface; 2], stores: &Stores) -> Option<Self> {
// Algorithm from Real-Time Collision Detection by Christer Ericson. See
// section 5.4.4, Intersection of Two Planes.
//
Expand Down Expand Up @@ -52,14 +52,14 @@ impl SurfaceSurfaceIntersection {
let line = Line::from_origin_and_direction(origin, direction);

let curves = planes_parametric.map(|(surface, plane)| {
let local = project_line_into_plane(&line, &plane);
let global = store.global_curves.insert(GlobalCurve::from_path(
GlobalPath::Line(Line::from_origin_and_direction(
origin, direction,
let path = project_line_into_plane(&line, &plane);
let global_form = stores.global_curves.insert(
GlobalCurve::from_path(GlobalPath::Line(
Line::from_origin_and_direction(origin, direction),
)),
));
);

Curve::new(surface, local, global)
Curve::new(surface, path, global_form)
});

Some(Self {
Expand Down
6 changes: 3 additions & 3 deletions crates/fj-kernel/src/algorithms/validate/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ pub fn validate_vertex(
// lies on the curve.

let local = vertex.position();
let local_as_surface = vertex.curve().path().point_from_path_coords(local);
let local_as_global = vertex
.curve()
.global_form()
.path()
.point_from_path_coords(local);
.surface()
.point_from_surface_coords(local_as_surface);
let global = vertex.global_form().position();
let distance = (local_as_global - global).magnitude();

Expand Down
12 changes: 6 additions & 6 deletions crates/fj-kernel/src/builder/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ impl<'a> CurveBuilder<'a> {
pub fn line_from_points(&self, points: [impl Into<Point<2>>; 2]) -> Curve {
let points = points.map(Into::into);

let local = Line::from_points(points);
let global = self.stores.global_curves.insert(GlobalCurve::from_path(
GlobalPath::Line(Line::from_points(
let path = SurfacePath::Line(Line::from_points(points));
let global_form = self.stores.global_curves.insert(
GlobalCurve::from_path(GlobalPath::Line(Line::from_points(
points
.map(|point| self.surface.point_from_surface_coords(point)),
)),
));
))),
);

Curve::new(self.surface, SurfacePath::Line(local), global)
Curve::new(self.surface, path, global_form)
}
}

Expand Down
9 changes: 4 additions & 5 deletions crates/fj-kernel/src/builder/edge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ impl<'a> HalfEdgeBuilder<'a> {
let [a_curve, b_curve] =
[Scalar::ZERO, Scalar::TAU].map(|coord| Point::from([coord]));

let global_vertex = GlobalVertex::from_position(
curve.global_form().path().point_from_path_coords(a_curve),
);
let global_vertex =
GlobalVertex::build().from_curve_and_position(&curve, a_curve);

let surface_vertices = [a_curve, b_curve].map(|point_curve| {
let point_surface =
Expand Down Expand Up @@ -90,15 +89,15 @@ impl<'a> HalfEdgeBuilder<'a> {

let curve = {
let path = SurfacePath::Line(Line::from_points(points));
let curve_global = {
let global_form = {
let points = global_vertices
.map(|global_vertex| global_vertex.position());
self.stores.global_curves.insert(GlobalCurve::from_path(
GlobalPath::Line(Line::from_points(points)),
))
};

Curve::new(self.surface, path, curve_global)
Curve::new(self.surface, path, global_form)
};

let vertices = {
Expand Down