forked from 1b-agent/opencadstudio-upstream
feat(render): GPU analytical curve extraction for multi-arc polylines and blocks
This commit is contained in:
1 parent
6e01d464e5
commit
75ec08dc55
6 files changed
+186
-88
No files matched your search
@@ -199,22 +199,13 @@ pub fn create_pipelines(
|
||||
(circle_pipeline, circle_xray_pipeline)
|
||||
}
|
||||
|
||||
/// Helper to extract an analytical circle or circular arc instance from a `WireModel`.
|
||||
pub fn extract_circle_instance(
|
||||
/// Helper to extract an analytical circle or circular arc instance from a single `TangentGeom`.
|
||||
pub fn extract_circle_instance_from_geom(
|
||||
geom: &crate::scene::model::wire_model::TangentGeom,
|
||||
wire: &crate::scene::WireModel,
|
||||
draw_depth: f32,
|
||||
) -> Option<CircleInstance> {
|
||||
// Only thin 2D planar circles or circular arcs have exactly 1 PlanarCircle / Arc tangent geometry
|
||||
// and no 3D mesh fills or text quads.
|
||||
if wire.tangent_geoms.len() != 1
|
||||
|| !wire.fill_tris.is_empty()
|
||||
|| !wire.pick_tris.is_empty()
|
||||
|| !wire.text_verts.is_empty()
|
||||
|| wire.render_instance.is_some()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let (center, axis_x, axis_y, radius, start_angle, end_angle) = match wire.tangent_geoms[0] {
|
||||
let (center, axis_x, axis_y, radius, start_angle, end_angle) = match *geom {
|
||||
crate::scene::model::wire_model::TangentGeom::Circle { center, radius } => (
|
||||
[center[0] as f64, center[1] as f64, center[2] as f64],
|
||||
[1.0, 0.0, 0.0],
|
||||
@@ -271,6 +262,46 @@ pub fn extract_circle_instance(
|
||||
})
|
||||
}
|
||||
|
||||
/// Helper to extract all analytical circle/arc instances from a `WireModel`.
|
||||
///
|
||||
/// Returns `Some(instances)` if the wire is non-empty, contains solely analytical
|
||||
/// circle/arc tangent geometries, and has no mesh/pick fills, text, or block instance.
|
||||
pub fn extract_circle_instances(
|
||||
wire: &crate::scene::WireModel,
|
||||
draw_depth: f32,
|
||||
) -> Option<Vec<CircleInstance>> {
|
||||
if wire.tangent_geoms.is_empty()
|
||||
|| !wire.fill_tris.is_empty()
|
||||
|| !wire.pick_tris.is_empty()
|
||||
|| !wire.text_verts.is_empty()
|
||||
|| wire.render_instance.is_some()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut instances = Vec::with_capacity(wire.tangent_geoms.len());
|
||||
for geom in &wire.tangent_geoms {
|
||||
if let Some(inst) = extract_circle_instance_from_geom(geom, wire, draw_depth) {
|
||||
instances.push(inst);
|
||||
} else {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Some(instances)
|
||||
}
|
||||
|
||||
/// Helper to extract a single analytical circle or circular arc instance from a `WireModel`.
|
||||
pub fn extract_circle_instance(
|
||||
wire: &crate::scene::WireModel,
|
||||
draw_depth: f32,
|
||||
) -> Option<CircleInstance> {
|
||||
if wire.tangent_geoms.len() == 1 {
|
||||
extract_circle_instances(wire, draw_depth).and_then(|mut v| v.pop())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
fn split_ds_xyz(x: f64, y: f64, z: f64) -> ([f32; 3], [f32; 3]) {
|
||||
let hx = x as f32;
|
||||
let lx = (x - hx as f64) as f32;
|
||||
|
||||
Reference in new issue
Block a user