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 <noreply@anthropic.com>
This commit is contained in:
Hakan Seven 2026-06-16 11:39:31 +03:00
commit c6152ef705
6 changed files with 26 additions and 26 deletions

View file

@ -134,7 +134,7 @@ impl OpenCADStudio {
CmdResult::CommitSolid { entity, solid } => { CmdResult::CommitSolid { entity, solid } => {
let label = self.history_label_from_active_cmd(i, "SOLID"); let label = self.history_label_from_active_cmd(i, "SOLID");
self.push_undo_snapshot(i, label); 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].dirty = true;
self.tabs[i].scene.clear_preview_wire(); self.tabs[i].scene.clear_preview_wire();
self.tabs[i].active_cmd = None; self.tabs[i].active_cmd = None;

View file

@ -9,18 +9,18 @@ use truck_modeling::Solid;
use super::Message; use super::Message;
use crate::modules::model::boolean_cmd::BoolOp; 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 { impl super::OpenCADStudio {
/// Commit a Model-tab solid: add its acadrust entity to the document, then /// 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 /// register the truck B-rep (caches it for booleans + tessellates it into
/// the shaded mesh pipeline). Returns the new entity handle. /// 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 i = self.active_tab;
let Some(handle) = self.commit_entity_handle(entity) else { let Some(handle) = self.commit_entity_handle(entity) else {
return Handle::NULL; return Handle::NULL;
}; };
self.tabs[i].scene.register_model_solid(handle, solid); self.tabs[i].scene.register_solid_model(handle, solid);
handle handle
} }
@ -34,7 +34,7 @@ impl super::OpenCADStudio {
.selected .selected
.iter() .iter()
.copied() .copied()
.filter(|h| self.tabs[i].scene.model_solids.contains_key(h)) .filter(|h| self.tabs[i].scene.solid_models.contains_key(h))
.collect(); .collect();
if handles.len() != 2 { if handles.len() != 2 {
self.command_line.push_error( self.command_line.push_error(
@ -42,14 +42,14 @@ impl super::OpenCADStudio {
); );
return Task::none(); return Task::none();
} }
let a = self.tabs[i].scene.model_solids[&handles[0]].clone(); let a = self.tabs[i].scene.solid_models[&handles[0]].clone();
let b = self.tabs[i].scene.model_solids[&handles[1]].clone(); let b = self.tabs[i].scene.solid_models[&handles[1]].clone();
let kind = match op { let kind = match op {
BoolOp::Union => Bool::Union, BoolOp::Union => Bool::Union,
BoolOp::Subtract => Bool::Subtract, BoolOp::Subtract => Bool::Subtract,
BoolOp::Intersect => Bool::Intersect, 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 self.command_line
.push_error("Boolean failed — the solids may not overlap."); .push_error("Boolean failed — the solids may not overlap.");
return Task::none(); return Task::none();
@ -62,8 +62,8 @@ impl super::OpenCADStudio {
// so it lives as a Solid3D whose render/boolean data is the injected // so it lives as a Solid3D whose render/boolean data is the injected
// truck mesh + cached B-rep; its edge wires make it pickable. // truck mesh + cached B-rep; its edge wires make it pickable.
let mut s3d = Solid3D::new(); let mut s3d = Solid3D::new();
s3d.wires = model_solid::edge_wires(&result); s3d.wires = solid_model::edge_wires(&result);
let handle = self.add_model_solid(EntityType::Solid3D(s3d), result); let handle = self.add_solid_model(EntityType::Solid3D(s3d), result);
self.tabs[i].scene.deselect_all(); self.tabs[i].scene.deselect_all();
if !handle.is_null() { if !handle.is_null() {
self.tabs[i].scene.select_entity(handle, false); self.tabs[i].scene.select_entity(handle, false);

View file

@ -13,7 +13,7 @@ use glam::Vec3;
use truck_modeling::Solid; use truck_modeling::Solid;
use crate::command::{CadCommand, CmdResult}; use crate::command::{CadCommand, CmdResult};
use crate::scene::model::model_solid; use crate::scene::model::solid_model;
use crate::scene::model::wire_model::WireModel; use crate::scene::model::wire_model::WireModel;
/// Which primitive a `PrimitiveCommand` builds. /// Which primitive a `PrimitiveCommand` builds.
@ -116,13 +116,13 @@ impl PrimitiveCommand {
]; ];
( (
primitives::build_box(center, length, width, height), primitives::build_box(center, length, width, height),
model_solid::box_solid(center, length, width, height), solid_model::box_solid(center, length, width, height),
) )
} else { } else {
let origin = [a.x.min(b.x) as f64, a.y.min(b.y) as f64, 0.0]; 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), 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 { if self.shape == Shape::Cylinder {
( (
primitives::build_cylinder(center, r, height), primitives::build_cylinder(center, r, height),
model_solid::cylinder_solid(center, r, height), solid_model::cylinder_solid(center, r, height),
) )
} else { } else {
( (
primitives::build_cone(center, r, height), 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]; let center = [c.x as f64, c.y as f64, 0.0];
( (
primitives::build_sphere(center, r), primitives::build_sphere(center, r),
model_solid::sphere_solid(center, r), solid_model::sphere_solid(center, r),
) )
} }
Shape::Torus => { Shape::Torus => {
@ -167,7 +167,7 @@ impl PrimitiveCommand {
let center = [c.x as f64, c.y as f64, 0.0]; let center = [c.x as f64, c.y as f64, 0.0];
( (
primitives::build_torus(center, major, minor), 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); s3d.set_sat_document(&doc);
// Edge wires make the solid click-pickable and draw a wireframe over // Edge wires make the solid click-pickable and draw a wireframe over
// the shaded mesh. // the shaded mesh.
s3d.wires = model_solid::edge_wires(&solid); s3d.wires = solid_model::edge_wires(&solid);
Some((EntityType::Solid3D(s3d), solid)) Some((EntityType::Solid3D(s3d), solid))
} }

View file

@ -685,7 +685,7 @@ pub struct Scene {
/// keyed by entity handle. Backs the Design-group boolean tools (a solid /// keyed by entity handle. Backs the Design-group boolean tools (a solid
/// must be here to be combined). Not persisted — rebuilt only by creating /// must be here to be combined). Not persisted — rebuilt only by creating
/// or combining primitives in-session. /// 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. /// GPU render data for raster images (RasterImage entities), keyed by handle.
pub images: HashMap<Handle, ImageModel>, pub images: HashMap<Handle, ImageModel>,
/// The viewport that is currently "entered" (MSPACE mode). /// The viewport that is currently "entered" (MSPACE mode).
@ -821,7 +821,7 @@ impl Scene {
current_layout: "Model".to_string(), current_layout: "Model".to_string(),
hatches: HashMap::default(), hatches: HashMap::default(),
meshes: HashMap::default(), meshes: HashMap::default(),
model_solids: HashMap::default(), solid_models: HashMap::default(),
images: HashMap::default(), images: HashMap::default(),
active_viewport: None, active_viewport: None,
bg_color: [0.11, 0.11, 0.11, 1.0], 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 /// 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 /// 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). /// 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 let color = self
.document .document
.get_entity(handle) .get_entity(handle)
.map(|e| self.render_style(e).0) .map(|e| self.render_style(e).0)
.unwrap_or([0.8, 0.8, 0.85, 1.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.meshes.insert(handle, set);
} }
self.model_solids.insert(handle, solid); self.solid_models.insert(handle, solid);
self.bump_geometry(); self.bump_geometry();
} }
@ -3360,7 +3360,7 @@ impl Scene {
for h in &to_remove { for h in &to_remove {
self.hatches.remove(h); self.hatches.remove(h);
self.meshes.remove(h); self.meshes.remove(h);
self.model_solids.remove(h); self.solid_models.remove(h);
self.document.remove_entity(*h); self.document.remove_entity(*h);
} }
@ -4808,7 +4808,7 @@ impl Scene {
self.selected.remove(&h); self.selected.remove(&h);
self.hatches.remove(&h); self.hatches.remove(&h);
self.meshes.remove(&h); self.meshes.remove(&h);
self.model_solids.remove(&h); self.solid_models.remove(&h);
self.mark_entity_dirty(h); self.mark_entity_dirty(h);
} }
// Remove erased handles from all groups; delete groups that become empty. // Remove erased handles from all groups; delete groups that become empty.

View file

@ -3,5 +3,5 @@ pub mod hatch_model;
pub mod hatch_patterns; pub mod hatch_patterns;
pub mod image_model; pub mod image_model;
pub mod mesh_model; pub mod mesh_model;
pub mod model_solid; pub mod solid_model;
pub mod object; pub mod object;