forked from 1b-agent/opencadstudio-upstream
refactor(scene): rename model_solid to solid_model
Match the `*_model` naming of the sibling render models (wire_model, hatch_model, mesh_model, image_model). Also realign the related Scene API for consistency: model_solids → solid_models, add_model_solid → add_solid_model, register_model_solid → register_solid_model. No behavior change; build and tests are green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
7fe7e0230d
commit
c6152ef705
6 files changed
+26
-26
No files matched your search
@@ -134,7 +134,7 @@ impl OpenCADStudio {
|
||||
CmdResult::CommitSolid { entity, solid } => {
|
||||
let label = self.history_label_from_active_cmd(i, "SOLID");
|
||||
self.push_undo_snapshot(i, label);
|
||||
self.add_model_solid(entity, *solid);
|
||||
self.add_solid_model(entity, *solid);
|
||||
self.tabs[i].dirty = true;
|
||||
self.tabs[i].scene.clear_preview_wire();
|
||||
self.tabs[i].active_cmd = None;
|
||||
|
||||
@@ -9,18 +9,18 @@ use truck_modeling::Solid;
|
||||
|
||||
use super::Message;
|
||||
use crate::modules::model::boolean_cmd::BoolOp;
|
||||
use crate::scene::model::model_solid::{self, Bool};
|
||||
use crate::scene::model::solid_model::{self, Bool};
|
||||
|
||||
impl super::OpenCADStudio {
|
||||
/// Commit a Model-tab solid: add its acadrust entity to the document, then
|
||||
/// register the truck B-rep (caches it for booleans + tessellates it into
|
||||
/// the shaded mesh pipeline). Returns the new entity handle.
|
||||
pub(super) fn add_model_solid(&mut self, entity: EntityType, solid: Solid) -> Handle {
|
||||
pub(super) fn add_solid_model(&mut self, entity: EntityType, solid: Solid) -> Handle {
|
||||
let i = self.active_tab;
|
||||
let Some(handle) = self.commit_entity_handle(entity) else {
|
||||
return Handle::NULL;
|
||||
};
|
||||
self.tabs[i].scene.register_model_solid(handle, solid);
|
||||
self.tabs[i].scene.register_solid_model(handle, solid);
|
||||
handle
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ impl super::OpenCADStudio {
|
||||
.selected
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|h| self.tabs[i].scene.model_solids.contains_key(h))
|
||||
.filter(|h| self.tabs[i].scene.solid_models.contains_key(h))
|
||||
.collect();
|
||||
if handles.len() != 2 {
|
||||
self.command_line.push_error(
|
||||
@@ -42,14 +42,14 @@ impl super::OpenCADStudio {
|
||||
);
|
||||
return Task::none();
|
||||
}
|
||||
let a = self.tabs[i].scene.model_solids[&handles[0]].clone();
|
||||
let b = self.tabs[i].scene.model_solids[&handles[1]].clone();
|
||||
let a = self.tabs[i].scene.solid_models[&handles[0]].clone();
|
||||
let b = self.tabs[i].scene.solid_models[&handles[1]].clone();
|
||||
let kind = match op {
|
||||
BoolOp::Union => Bool::Union,
|
||||
BoolOp::Subtract => Bool::Subtract,
|
||||
BoolOp::Intersect => Bool::Intersect,
|
||||
};
|
||||
let Some(result) = model_solid::boolean(kind, &a, &b) else {
|
||||
let Some(result) = solid_model::boolean(kind, &a, &b) else {
|
||||
self.command_line
|
||||
.push_error("Boolean failed — the solids may not overlap.");
|
||||
return Task::none();
|
||||
@@ -62,8 +62,8 @@ impl super::OpenCADStudio {
|
||||
// so it lives as a Solid3D whose render/boolean data is the injected
|
||||
// truck mesh + cached B-rep; its edge wires make it pickable.
|
||||
let mut s3d = Solid3D::new();
|
||||
s3d.wires = model_solid::edge_wires(&result);
|
||||
let handle = self.add_model_solid(EntityType::Solid3D(s3d), result);
|
||||
s3d.wires = solid_model::edge_wires(&result);
|
||||
let handle = self.add_solid_model(EntityType::Solid3D(s3d), result);
|
||||
self.tabs[i].scene.deselect_all();
|
||||
if !handle.is_null() {
|
||||
self.tabs[i].scene.select_entity(handle, false);
|
||||
|
||||
@@ -13,7 +13,7 @@ use glam::Vec3;
|
||||
use truck_modeling::Solid;
|
||||
|
||||
use crate::command::{CadCommand, CmdResult};
|
||||
use crate::scene::model::model_solid;
|
||||
use crate::scene::model::solid_model;
|
||||
use crate::scene::model::wire_model::WireModel;
|
||||
|
||||
/// Which primitive a `PrimitiveCommand` builds.
|
||||
@@ -116,13 +116,13 @@ impl PrimitiveCommand {
|
||||
];
|
||||
(
|
||||
primitives::build_box(center, length, width, height),
|
||||
model_solid::box_solid(center, length, width, height),
|
||||
solid_model::box_solid(center, length, width, height),
|
||||
)
|
||||
} else {
|
||||
let origin = [a.x.min(b.x) as f64, a.y.min(b.y) as f64, 0.0];
|
||||
(
|
||||
primitives::build_wedge(origin, length, width, height),
|
||||
model_solid::wedge_solid(origin, length, width, height),
|
||||
solid_model::wedge_solid(origin, length, width, height),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -136,12 +136,12 @@ impl PrimitiveCommand {
|
||||
if self.shape == Shape::Cylinder {
|
||||
(
|
||||
primitives::build_cylinder(center, r, height),
|
||||
model_solid::cylinder_solid(center, r, height),
|
||||
solid_model::cylinder_solid(center, r, height),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
primitives::build_cone(center, r, height),
|
||||
model_solid::cone_solid(center, r, height),
|
||||
solid_model::cone_solid(center, r, height),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ impl PrimitiveCommand {
|
||||
let center = [c.x as f64, c.y as f64, 0.0];
|
||||
(
|
||||
primitives::build_sphere(center, r),
|
||||
model_solid::sphere_solid(center, r),
|
||||
solid_model::sphere_solid(center, r),
|
||||
)
|
||||
}
|
||||
Shape::Torus => {
|
||||
@@ -167,7 +167,7 @@ impl PrimitiveCommand {
|
||||
let center = [c.x as f64, c.y as f64, 0.0];
|
||||
(
|
||||
primitives::build_torus(center, major, minor),
|
||||
model_solid::torus_solid(center, major, minor),
|
||||
solid_model::torus_solid(center, major, minor),
|
||||
)
|
||||
}
|
||||
};
|
||||
@@ -175,7 +175,7 @@ impl PrimitiveCommand {
|
||||
s3d.set_sat_document(&doc);
|
||||
// Edge wires make the solid click-pickable and draw a wireframe over
|
||||
// the shaded mesh.
|
||||
s3d.wires = model_solid::edge_wires(&solid);
|
||||
s3d.wires = solid_model::edge_wires(&solid);
|
||||
Some((EntityType::Solid3D(s3d), solid))
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -685,7 +685,7 @@ pub struct Scene {
|
||||
/// keyed by entity handle. Backs the Design-group boolean tools (a solid
|
||||
/// must be here to be combined). Not persisted — rebuilt only by creating
|
||||
/// or combining primitives in-session.
|
||||
pub model_solids: HashMap<Handle, truck_modeling::Solid>,
|
||||
pub solid_models: HashMap<Handle, truck_modeling::Solid>,
|
||||
/// GPU render data for raster images (RasterImage entities), keyed by handle.
|
||||
pub images: HashMap<Handle, ImageModel>,
|
||||
/// The viewport that is currently "entered" (MSPACE mode).
|
||||
@@ -821,7 +821,7 @@ impl Scene {
|
||||
current_layout: "Model".to_string(),
|
||||
hatches: HashMap::default(),
|
||||
meshes: HashMap::default(),
|
||||
model_solids: HashMap::default(),
|
||||
solid_models: HashMap::default(),
|
||||
images: HashMap::default(),
|
||||
active_viewport: None,
|
||||
bg_color: [0.11, 0.11, 0.11, 1.0],
|
||||
@@ -1011,16 +1011,16 @@ impl Scene {
|
||||
/// tessellate it into the shaded mesh pipeline under `handle`. The solid is
|
||||
/// in the same offset-relative frame the mesh pipeline uses, so the mesh is
|
||||
/// stored as-is (Model-tab geometry is authored at world_offset 0).
|
||||
pub fn register_model_solid(&mut self, handle: Handle, solid: truck_modeling::Solid) {
|
||||
pub fn register_solid_model(&mut self, handle: Handle, solid: truck_modeling::Solid) {
|
||||
let color = self
|
||||
.document
|
||||
.get_entity(handle)
|
||||
.map(|e| self.render_style(e).0)
|
||||
.unwrap_or([0.8, 0.8, 0.85, 1.0]);
|
||||
if let Some(set) = crate::scene::model::model_solid::mesh_from_solid(&solid, color) {
|
||||
if let Some(set) = crate::scene::model::solid_model::mesh_from_solid(&solid, color) {
|
||||
self.meshes.insert(handle, set);
|
||||
}
|
||||
self.model_solids.insert(handle, solid);
|
||||
self.solid_models.insert(handle, solid);
|
||||
self.bump_geometry();
|
||||
}
|
||||
|
||||
@@ -3360,7 +3360,7 @@ impl Scene {
|
||||
for h in &to_remove {
|
||||
self.hatches.remove(h);
|
||||
self.meshes.remove(h);
|
||||
self.model_solids.remove(h);
|
||||
self.solid_models.remove(h);
|
||||
self.document.remove_entity(*h);
|
||||
}
|
||||
|
||||
@@ -4808,7 +4808,7 @@ impl Scene {
|
||||
self.selected.remove(&h);
|
||||
self.hatches.remove(&h);
|
||||
self.meshes.remove(&h);
|
||||
self.model_solids.remove(&h);
|
||||
self.solid_models.remove(&h);
|
||||
self.mark_entity_dirty(h);
|
||||
}
|
||||
// Remove erased handles from all groups; delete groups that become empty.
|
||||
|
||||
@@ -3,5 +3,5 @@ pub mod hatch_model;
|
||||
pub mod hatch_patterns;
|
||||
pub mod image_model;
|
||||
pub mod mesh_model;
|
||||
pub mod model_solid;
|
||||
pub mod solid_model;
|
||||
pub mod object;
|
||||
File renamed without changes.
Reference in new issue
Block a user