forked from 1b-agent/opencadstudio-upstream
chore: drop dead scene/IO helpers + simplify XATTACH command state
* helpers::wcs_to_ucs — UCS inverse transform with zero call sites. * scene::Scene::compute_and_set_world_offset — never called; the load path uses the free function `compute_world_offset` directly. * tessellate::tessellate_mesh — never called; mesh tessellation goes through `solid3d_tess`, not the truck Shell/Solid path. * truck_tess::tess_to_mesh_model — orphaned with tessellate_mesh's removal. * MeshModel::WHITE / MeshModel::SELECTED — only used by the removed tessellate_mesh. * xattach::Step::FilePath variant — never constructed; XATTACH always enters through `with_path` after the file picker. Replaced the Step enum + prefilled_path field with flat `path` / `block_name` fields and dropped the unreachable text-input flow. Co-Authored-By: Claude Opus 4.7 <[email protected]>
This commit is contained in:
1 parent
22543e4f97
commit
a1ed87da3d
7 files changed
+19
-163
No files matched your search
@@ -46,29 +46,6 @@ pub(super) fn ucs_to_wcs(pt: glam::Vec3, ucs: &Ucs) -> glam::Vec3 {
|
||||
o + x * pt.x + y * pt.y + z_ax * pt.z
|
||||
}
|
||||
|
||||
/// Convert a WCS point back to UCS local coordinates.
|
||||
#[allow(dead_code)]
|
||||
pub(super) fn wcs_to_ucs(pt: glam::Vec3, ucs: &Ucs) -> glam::Vec3 {
|
||||
let o = glam::Vec3::new(
|
||||
ucs.origin.x as f32,
|
||||
ucs.origin.y as f32,
|
||||
ucs.origin.z as f32,
|
||||
);
|
||||
let x = glam::Vec3::new(
|
||||
ucs.x_axis.x as f32,
|
||||
ucs.x_axis.y as f32,
|
||||
ucs.x_axis.z as f32,
|
||||
);
|
||||
let y = glam::Vec3::new(
|
||||
ucs.y_axis.x as f32,
|
||||
ucs.y_axis.y as f32,
|
||||
ucs.y_axis.z as f32,
|
||||
);
|
||||
let z_ax = ucs_z_axis(ucs);
|
||||
let d = pt - o;
|
||||
glam::Vec3::new(d.dot(x), d.dot(y), d.dot(z_ax))
|
||||
}
|
||||
|
||||
/// Return the normalised Z axis of a UCS (cross product of X and Y axes).
|
||||
pub(super) fn ucs_z_axis(ucs: &Ucs) -> glam::Vec3 {
|
||||
let x = glam::Vec3::new(
|
||||
|
||||
@@ -67,7 +67,6 @@ pub struct PlotStyleTable {
|
||||
|
||||
impl PlotStyleTable {
|
||||
/// Create an identity CTB table (no overrides for any color).
|
||||
#[allow(dead_code)]
|
||||
pub fn identity(name: impl Into<String>) -> Self {
|
||||
PlotStyleTable {
|
||||
name: name.into(),
|
||||
|
||||
@@ -28,39 +28,16 @@ pub fn tool() -> ToolDef {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
enum Step {
|
||||
/// Waiting for the user to type (or accept) a file path.
|
||||
FilePath,
|
||||
/// File path is confirmed; waiting for an insertion point.
|
||||
InsertionPoint { path: String, block_name: String },
|
||||
}
|
||||
|
||||
pub struct XAttachCommand {
|
||||
step: Step,
|
||||
/// Pre-supplied path (from the file-picker message).
|
||||
prefilled_path: Option<String>,
|
||||
path: String,
|
||||
block_name: String,
|
||||
}
|
||||
|
||||
impl XAttachCommand {
|
||||
#[allow(dead_code)]
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
step: Step::FilePath,
|
||||
prefilled_path: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Create an XATTACH command with a path already filled in (from file-picker).
|
||||
pub fn with_path(path: String) -> Self {
|
||||
let block_name = path_to_block_name(&path);
|
||||
Self {
|
||||
step: Step::InsertionPoint {
|
||||
path: path.clone(),
|
||||
block_name,
|
||||
},
|
||||
prefilled_path: Some(path),
|
||||
}
|
||||
Self { path, block_name }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,47 +47,16 @@ impl CadCommand for XAttachCommand {
|
||||
}
|
||||
|
||||
fn prompt(&self) -> String {
|
||||
match &self.step {
|
||||
Step::FilePath => "XATTACH Enter path to external DWG/DXF file:".to_string(),
|
||||
Step::InsertionPoint { block_name, .. } => {
|
||||
format!("XATTACH Specify insertion point for \"{}\":", block_name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn wants_text_input(&self) -> bool {
|
||||
matches!(self.step, Step::FilePath)
|
||||
}
|
||||
|
||||
fn on_text_input(&mut self, text: &str) -> Option<CmdResult> {
|
||||
if !matches!(self.step, Step::FilePath) {
|
||||
return None;
|
||||
}
|
||||
let path = text.trim().to_string();
|
||||
if path.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let block_name = path_to_block_name(&path);
|
||||
self.step = Step::InsertionPoint { path, block_name };
|
||||
Some(CmdResult::NeedPoint)
|
||||
format!("XATTACH Specify insertion point for \"{}\":", self.block_name)
|
||||
}
|
||||
|
||||
fn on_point(&mut self, pt: Vec3) -> CmdResult {
|
||||
match &self.step {
|
||||
Step::FilePath => CmdResult::NeedPoint,
|
||||
Step::InsertionPoint {
|
||||
path: _,
|
||||
block_name,
|
||||
} => {
|
||||
// We return the INSERT entity; the command handler in
|
||||
// commands.rs will call `prepare_xref_block` on the scene
|
||||
// before committing.
|
||||
CmdResult::CommitAndExit(EntityType::Insert(Insert::new(
|
||||
block_name.clone(),
|
||||
Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64),
|
||||
)))
|
||||
}
|
||||
}
|
||||
// We return the INSERT entity; the command handler in commands.rs
|
||||
// calls `prepare_xref_block` on the scene before committing.
|
||||
CmdResult::CommitAndExit(EntityType::Insert(Insert::new(
|
||||
self.block_name.clone(),
|
||||
Vector3::new(pt.x as f64, pt.y as f64, pt.z as f64),
|
||||
)))
|
||||
}
|
||||
|
||||
fn on_enter(&mut self) -> CmdResult {
|
||||
@@ -122,10 +68,7 @@ impl CadCommand for XAttachCommand {
|
||||
}
|
||||
|
||||
fn xattach_path(&self) -> Option<String> {
|
||||
match &self.step {
|
||||
Step::InsertionPoint { path, .. } => Some(path.clone()),
|
||||
Step::FilePath => self.prefilled_path.clone(),
|
||||
}
|
||||
Some(self.path.clone())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,6 @@ pub struct MeshModel {
|
||||
pub selected: bool,
|
||||
}
|
||||
|
||||
impl MeshModel {
|
||||
#[allow(dead_code)]
|
||||
pub const WHITE: [f32; 4] = [1.00, 1.00, 1.00, 1.0];
|
||||
pub const SELECTED: [f32; 4] = [0.15, 0.55, 1.00, 1.0];
|
||||
}
|
||||
|
||||
/// Bundle of mesh tessellations at different sampling densities, picked
|
||||
/// per frame by the render pipeline based on the projected pixel size of
|
||||
/// `world_aabb`. Phase 3.4 LOD ladder:
|
||||
|
||||
@@ -632,14 +632,6 @@ impl Scene {
|
||||
self.geometry_epoch = GEOMETRY_EPOCH.fetch_add(1, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn compute_and_set_world_offset(&mut self) {
|
||||
let model_block = self.model_space_block_handle();
|
||||
let (offset, lim) = compute_world_offset(&self.document, model_block);
|
||||
self.world_offset = offset;
|
||||
self.local_extent_max = lim;
|
||||
}
|
||||
|
||||
/// Returns true if this viewport should display model-space content
|
||||
/// (i.e. it is a user viewport, not the sheet/overall viewport).
|
||||
///
|
||||
|
||||
+8
-30
@@ -23,9 +23,8 @@ use acadrust::{CadDocument, EntityType, Handle};
|
||||
use glam::Vec3;
|
||||
|
||||
use crate::scene::acad_to_truck::{convert, TruckObject};
|
||||
use crate::scene::mesh_model::MeshModel;
|
||||
use crate::scene::truck_tess::{
|
||||
self, tessellate_edge, tessellate_solid, tessellate_vertex, tessellate_wire, TruckTessResult,
|
||||
tessellate_edge, tessellate_vertex, tessellate_wire, TruckTessResult,
|
||||
};
|
||||
use crate::scene::wire_model::{SnapHint, TangentGeom, WireModel};
|
||||
|
||||
@@ -47,7 +46,8 @@ pub fn aci_to_rgba(color: &AcadColor) -> [f32; 4] {
|
||||
/// Tessellate one entity into a WireModel.
|
||||
/// For Text/MText entities this produces one WireModel with all glyph strokes
|
||||
/// encoded as NaN-separated segments (wire_gpu skips NaN pairs).
|
||||
/// For Solid3D entities this returns an empty wire; use `tessellate_mesh` instead.
|
||||
/// For Solid3D entities this returns an empty wire; mesh tessellation lives
|
||||
/// in `solid3d_tess` and is uploaded via the mesh pipeline instead.
|
||||
pub fn tessellate(
|
||||
document: &CadDocument,
|
||||
handle: Handle,
|
||||
@@ -351,10 +351,11 @@ pub fn tessellate(
|
||||
}
|
||||
|
||||
TruckObject::Volume(_) => {
|
||||
// Solid3D / Region / Body → handled by tessellate_mesh().
|
||||
// As a wire fallback, render the pre-computed edge wires
|
||||
// stored in the entity when present (e.g. from SOLVIEW output
|
||||
// or when the SAT kernel cannot parse the ACIS data).
|
||||
// Solid3D / Region / Body → mesh tessellation lives in
|
||||
// `solid3d_tess`. As a wire fallback, render the pre-computed
|
||||
// edge wires stored in the entity when present (e.g. from
|
||||
// SOLVIEW output or when the SAT kernel cannot parse the
|
||||
// ACIS data).
|
||||
let wire_pts = solid_wire_fallback(entity, world_offset);
|
||||
let mut wm = WireModel::solid(name, wire_pts, color, selected);
|
||||
// Add insertion snap at point_of_reference.
|
||||
@@ -1098,29 +1099,6 @@ pub fn tessellate_multileader(
|
||||
wires
|
||||
}
|
||||
|
||||
/// Tessellate a Solid3D entity into a MeshModel (truck Shell/Solid path).
|
||||
#[allow(dead_code)]
|
||||
pub fn tessellate_mesh(
|
||||
document: &CadDocument,
|
||||
handle: Handle,
|
||||
entity: &EntityType,
|
||||
selected: bool,
|
||||
color: [f32; 4],
|
||||
world_offset: [f64; 3],
|
||||
) -> Option<MeshModel> {
|
||||
let te = convert(entity, document)?;
|
||||
let result = match te.object {
|
||||
TruckObject::Volume(solid) => tessellate_solid(&solid, world_offset),
|
||||
_ => return None,
|
||||
};
|
||||
truck_tess::tess_to_mesh_model(
|
||||
result,
|
||||
handle.value().to_string(),
|
||||
if selected { MeshModel::SELECTED } else { color },
|
||||
selected,
|
||||
)
|
||||
}
|
||||
|
||||
// ── Entity Z helper ───────────────────────────────────────────────────────
|
||||
|
||||
/// Extract the Z elevation from a text/mtext entity.
|
||||
|
||||
@@ -13,7 +13,6 @@ use truck_modeling::base::{BoundedCurve, ParameterDivision1D};
|
||||
use truck_modeling::{Edge, Shell, Solid, Vertex, Wire};
|
||||
use truck_polymesh::PolygonMesh;
|
||||
|
||||
use crate::scene::mesh_model::MeshModel;
|
||||
|
||||
// Chord-height tolerance used for adaptive curve sampling (world units).
|
||||
const CURVE_TOL: f64 = 0.005;
|
||||
@@ -141,32 +140,6 @@ pub fn tessellate_solid(s: &Solid, offset: [f64; 3]) -> TruckTessResult {
|
||||
polygon_to_result(meshed.to_polygon(), offset)
|
||||
}
|
||||
|
||||
// ── MeshModel helper ──────────────────────────────────────────────────────
|
||||
|
||||
/// Convert a TruckTessResult::Mesh into a MeshModel (fills name/color later).
|
||||
pub fn tess_to_mesh_model(
|
||||
result: TruckTessResult,
|
||||
name: String,
|
||||
color: [f32; 4],
|
||||
selected: bool,
|
||||
) -> Option<MeshModel> {
|
||||
match result {
|
||||
TruckTessResult::Mesh {
|
||||
verts,
|
||||
normals,
|
||||
indices,
|
||||
} => Some(MeshModel {
|
||||
name,
|
||||
verts,
|
||||
normals,
|
||||
indices,
|
||||
color,
|
||||
selected,
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
// ── Internal ─────────────────────────────────────────────────────────────
|
||||
|
||||
fn polygon_to_result(mesh: PolygonMesh, offset: [f64; 3]) -> TruckTessResult {
|
||||
|
||||
Reference in new issue
Block a user