Skip to content

oriented polyline#425

Open
cscorley wants to merge 1 commit into
dimforge:masterfrom
cscorley:oriented-polyline
Open

oriented polyline#425
cscorley wants to merge 1 commit into
dimforge:masterfrom
cscorley:oriented-polyline

Conversation

@cscorley

Copy link
Copy Markdown

closes #254

adds 2D version of TriMeshFlags::ORIENTED + TriMeshFlags::FixInternalEdges

@cscorley cscorley force-pushed the oriented-polyline branch from a0a863e to b906e3b Compare June 14, 2026 18:18
@cscorley cscorley marked this pull request as ready for review June 14, 2026 19:35

@sebcrozet sebcrozet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR!

Another modification that is needed is the behavior of the implementation of PointQuery for Polyline so it mirrors the trimesh behavior. If a Polyline is oriented, then a point starting inside of it should be considered to be its own projection.

See for example the case of an oriented TriMesh:

#[cfg(feature = "dim3")]
if let Some(pseudo_normals) = self.pseudo_normals_if_oriented() {
let pseudo_normal = match location {
TrianglePointLocation::OnFace(..) | TrianglePointLocation::OnSolid => {
Some(self.triangle(part_id).scaled_normal())
}
TrianglePointLocation::OnEdge(i, _) => pseudo_normals
.edges_pseudo_normal
.get(part_id as usize)
.map(|pn| pn[i as usize]),
TrianglePointLocation::OnVertex(i) => {
let idx = self.indices()[part_id as usize];
pseudo_normals
.vertices_pseudo_normal
.get(idx[i as usize] as usize)
.copied()
}
};
if let Some(pseudo_normal) = pseudo_normal {
let dpt = point - proj.point;
proj.is_inside = dpt.dot(pseudo_normal) <= 0.0;
}
}

Comment thread src/shape/polyline.rs
Comment on lines +296 to +299
/// Pseudo-normals are a 2D-only feature; in 3D this is a no-op. 3D stub so
/// `set_flags`/`scaled`/`reverse` compile; mirrors `TriMesh`'s dim2 stub.
#[cfg(feature = "dim3")]
fn compute_pseudo_normals(&mut self) {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be removed.

Comment thread src/shape/polyline.rs
Comment on lines +126 to +129
/// Per-vertex outward pseudo-normals, present when [`PolylineFlags::ORIENTED`] is set; contact
/// normals are then clamped to one side so the polyline acts as a one-sided surface.
pseudo_normals: Option<Vec<Vector>>,
flags: PolylineFlags,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since pseudo-normals (and the PolylineFlags as well) are only relevant in 2d, they should be excluded from 3d using #[cfg(feature = "dim2")].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement pseudo normals for polyline similar to how it's done in 3D for trimesh and heightmapfield

2 participants