Skip to content

3D solids with solidcore, and a 3D Modeling workspace laid out as on Windows - #20

Closed
SkryxDev wants to merge 18 commits into
mainfrom
feat/solids-3d
Closed

SkryxDev wants to merge 18 commits into
mainfrom
feat/solids-3d

Conversation

@SkryxDev

Copy link
Copy Markdown
Member

3D solid modelling behind the cargo feature solids. With the feature off, the build, the tests and the wasm build are what they were. docs/solids.md has the status, how to try it, the measurements, the decisions and open questions, and the advisory that planned the work.

What's in it

  • Kernel: solidcore (Apache-2.0, a pure-Rust port of NVIDIA SMLib), pinned to ce5c6e9. draftcraft-solid (L0) is the only crate that names it.
  • Commands:
    • Primitives: BOX, CYLINDER, CONE, SPHERE, WEDGE, TORUS.
    • Sweeps: EXTRUDE (with taper), REVOLVE.
    • Booleans: UNION, SUBTRACT, INTERSECT.
    • Editing: SLICE, FILLETEDGE, CHAMFEREDGE, SOLIDEDIT shell.
    • Inquiry and drawings: INTERFERE, MASSPROP (with moments of inertia), FLATSHOT, SECTION.
  • Saving: in DWG/DXF a solid is a polyface mesh, with the exact body in an extension-dictionary record. DraftCraft reopens it as a solid.
  • 3D view: VPOINT, 3DORBIT, PLAN, VSCURRENT, in the wireframe, hidden and shaded styles. Hidden lines are DraftCraft's own.
  • Interface, laid out like AutoCAD's 3D Modeling workspace (structure observed only; every icon drawn in code):
    • Workspaces: two built in, 2D Drafting and 3D Modeling. Switch from the Quick Access Toolbar, the status bar or WSCURRENT.
    • Ribbon in 3D Modeling:
      • Home: Modeling, Solid Editing, Draw, Modify, Section, View, Layers.
      • Solid: Primitive, Solid, Boolean, Solid Editing, Section.
      • Visualize: Views, Visual Styles.
    • Viewport controls [-][view][style], each one a menu.
    • A 3D ViewCube: 26 clickable spots, drag to orbit, Home, compass ring.
    • A navigation bar: Zoom Extents, In, Out, Orbit.
    • Preset commands: vpoint.top … vpoint.nwiso and vscurrent.*.
    • Translations: Italian and Chinese for the new strings.
  • xtask: cargo xtask ci --solids runs clippy and the tests with the feature on, plus a wasm32 check of the kernel.

Measured (Apple M4)

Without solids With solids
Release draftcraft 61.4 MB 105.8 MB
draftcraft-web wasm (before wasm-opt) 53.8 MB 105.3 MB
Cold build of the kernel chain — 2 min 21 s

Checks

cargo xtask ci and cargo xtask ci --solids were run on macOS:

  • fmt and clippy (-D warnings): pass.
  • Assets, layers, wasm, and the solids wasm32 check: pass.
  • Tests (workspace, both feature sets): pass, except the three tests documented in AGENTS.md as failing only on macOS: read_file_refuses_a_name_that_is_not_unicode, usage::non_unicode_output_names, thai_marks_stack_in_an_installed_font.

The UI was checked through the control channel with screenshots: the 3D Modeling ribbon tabs, the viewport-control menus, ViewCube clicks (face, edge, Home), the status-bar workspace menu and the navigation bar.

Not in this PR

  • ACIS read/write (S5, S7). The interim form is mesh plus exact body.
  • Snaps and grips in 3D, and a view per viewport.
  • Surface, Mesh, Pyramid, Sweep, Loft, Presspull.
  • Solids on the web build. A kernel panic can't be caught on wasm, so the web build keeps solids off (open question 1 in the docs).

🤖 Generated with Claude Code

SkryxDev and others added 6 commits November 14, 2026 18:28
…ture kernel)

SolidCraft's kernel and geom crates as git dependencies pinned to withshalom/solidcraft
d11d268 (v0.27.0), with its truck patches repeated in the root manifest. Only
draftcraft-solid names them; cargo xtask layers enforces it. Without its kernel feature
the crate is empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…DE, REVOLVE, booleans, SLICE, FILLETEDGE, CHAMFEREDGE, SOLIDEDIT shell, INTERFERE, MASSPROP, FLATSHOT, SECTION)

Behind the engine feature `solids`; without it nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…extension dictionary record, reopened as solids

DXF and DWG keep a DraftCraft solid as a polyface mesh every program can see, and an XRECORD
DRAFTCRAFT_SOLID in its extension dictionary with the body, placement and counts. With the io
feature `solids` the reader turns the mesh back into the solid (the engine redraws it from the
body); without it the mesh and its record are kept as they are. The save says so on the command
line. The `solids` feature reaches ui-egui, mcp and the three apps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…labels

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…with wireframe, hidden and shaded styles

The engine keeps a 3D view per drawing (direction, framing, visual style); the commands change
the view, never the drawing. The drawing area paints it with egui's painter: faces back to
front, edges and silhouettes tested against the faces in front of them. The wheel zooms, the
middle button pans, Shift+middle (or the left button in 3DORBIT) orbits; clicks pick solids and
points on the XY plane. A View panel on the 3D Modeling tab. Without the solids feature
3DORBIT still says not available yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Windows

The kernel is now solidcore (tangency-labs/solidcore ce5c6e9, Apache-2.0), replacing
SolidCraft's truck-based kernel at the owner's request. The facade's API is unchanged:
- draftcraft-solid names solidcore-ops, -record and -tess; bodies are solidcore .smb behind
  the DCSMB001 magic, canonical so a reopened solid keeps its bytes.
- Hidden-line projection (FLATSHOT, views) is DraftCraft's own: exact edges projected,
  silhouettes from the mesh, visibility sampled against binned triangles.
- SOLIDEDIT shell passes solidcore's outward thickness negated; MASSPROP reports moments and
  products of inertia and radii of gyration.
- NOTICE and ATTRIBUTION carry solidcore's row and NVIDIA's SMLib notice.

The 3D UI follows the structure of AutoCAD's 3D Modeling workspace (structure only; every
icon drawn in code):
- Built-in workspaces 2D Drafting and 3D Modeling, switched from the Quick Access Toolbar,
  the status bar's Workspace Switching menu or WSCURRENT. In 3D Modeling the ribbon has its own
  Home (Modeling, Solid Editing, Draw, Modify, Section, View, Layers), Solid (Primitive,
  Solid, Boolean, Solid Editing, Section) and Visualize (Views, Visual Styles) tabs.
- Preset commands vpoint.top … vpoint.nwiso and vscurrent.2dwireframe … vscurrent.xray.
- In the 3D view: viewport controls [-][view][style], each a menu, and a 3D ViewCube that
  turns with the view, with 26 clickable spots, drag to orbit, Home, compass ring and a
  right-click menu; and a navigation bar (Zoom Extents, In, Out, Orbit).
- Italian and Chinese labels for the new strings.

xtask: `cargo xtask ci --solids` runs clippy and tests with the feature on, plus a wasm32
check of the kernel. docs/solids.md keeps the status, measurements and the advisory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@withshalom
withshalom marked this pull request as draft November 15, 2026 02:18
@withshalom
withshalom marked this pull request as ready for review November 15, 2026 03:56

@withshalom withshalom 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.

Review: bugs found in #20

Tested on Windows on main with this PR merged (both feature sets): with solids 3,782 tests pass, without it 3,736 pass, and cargo xtask ci --solids passes all 8 steps (wasm included). The bugs below are in the code, not the tests; the ones marked confirmed were reproduced with a test on that build. Fixes, with this PR's commits, are coming in #21, and this PR will be closed in its favour.

Data loss in the file form

  1. A solid changed in another program snaps back when DraftCraft reopens it (confirmed). The record's placement and body are trusted without checking that the mesh is still the one written (solid_file.rs#L242), and on open refresh_looks redraws every solid from that stale body (solids.rs#L32). Test: the saved mesh moved +100 in X reopens as a solid drawn at X 0–10. A MOVE, SCALE or vertex edit in AutoCAD, or in a DraftCraft build without solids, is overwritten on the next save; an AutoCAD COPY clones the record, so the copy reopens on top of the original.
  2. A solid saved as several meshes takes the next N−1 polyface meshes by position and deletes them (confirmed). solid_file.rs#L244 gathers the parts from entity order, #L271 removes them. Test: two boxes saved, the first record saying two meshes: the file reopens with one solid; the second box is gone. Any solid over 32,767 vertices is saved this way, so a deleted or reordered part in another program erases whatever mesh follows.

Correctness

  1. CI never builds the solids feature. The gate in ci.yml runs cargo xtask ci, so none of the feature-gated code is compiled or tested on a push. It passes today (locally), but nothing keeps it passing.
  2. Mirrored solids draw inside-out in the 3D view (confirmed). Face normals are worked out from drawing-space corners (view3d.rs#L126); MIRROR makes the placement's determinant negative and reverses the winding. Test: outward-facing triangles go from 100 % to 0 % after MIRROR, so back-face culling, the hidden-line test and shading all use the wrong side. The meshes written to DXF/DWG get the same reversed winding.
  3. SLICE's XY option always cuts at Z = 0 and always keeps the upper part; SECTION's XY option also cuts at Z = 0. Interactive points are 2D (Input::Point(Vec2)), so the plane point is p.to3(0.0) (edit.rs#L318; SectionM the same) and the side point lies on the plane, so (p − o)·n = 0 ≥ 0 keeps the positive side every time (edit.rs#L307). The JSON forms work.
  4. FILLETEDGE, CHAMFEREDGE and SOLIDEDIT shell can't reliably pick the edge or face clicked (confirmed). Edges are matched by their plan projection, so a box's top and bottom edges tie and the first in wire order wins (solids.rs#L219); faces only ever resolve to the topmost (#L247); in a 3D view the click is mapped onto Z = 0 first (view3d.rs#L551). Test, 10 × 10 × 10 box picked in plan: the middle of the left side fillets the top edge, the middle of the front side the bottom edge.
  5. Solids inside blocks draw flat in the 3D view. Only top-level Solid3d entities become 3D (view3d.rs#L99); a block reference holding solids falls through to the 2D display list and shows as its plan outline at Z = 0.
  6. A failed multi-object command leaves part of its work done. EXTRUDE of several profiles (sweep.rs#L130), SLICE of several solids, FLATSHOT stopping at its object cap, and a SUBTRACT of solids and regions together (the solids are combined before the region half can fail, edit.rs#L69). Session::execute restores the drawing only on a panic, not on an error.
  7. A saved workspace named "3D Modeling" is shadowed by the new built-in one (workspaces.rs#L27): it is listed twice and can't be made current, renamed or deleted.

Performance

  1. INTERFERE does quadratic kernel work on the UI thread. Both bodies are decoded for every pair, with no bounding-box check first, and each hit builds a full solid (encode, tessellate, mass) even with create: false (edit.rs#L587); 200 solids is about 40,000 decodes, with no way to cancel.
  2. Opening a file decodes and re-tessellates every DraftCraft solid, up to 100,000 (file.rs#L360), though the saved mesh already holds what is drawn. It is also what makes bug 1 revert edits.
  3. The 3D view redoes all its work on every repaint. It sorts every triangle, rebuilds the occlusion grid and samples every edge (view3d.rs#L378, #L397), and cell() clamps off-screen triangles into the border cells (#L254), so zooming into a large model makes those cells huge.

Project rules

  1. No CHANGELOG line. Since 3b6e91c (merged after this branch started) AGENTS.md asks for a line under ## Unreleased for every user-visible change. The status bar's Workspace button changes in every build (it did nothing; it now opens the workspace menu).
  2. draftcraft-web gains a solids feature (Cargo.toml#L30) although docs/solids.md keeps solids off the web because a kernel panic aborts there; the new section also separated the web-sys comment from its dependency. Suggestion for the web side: a compile_error! when solids is built for wasm32, and, if the 3D workspace should be discoverable, a greyed-out entry with a tooltip rather than struck-through text.

Checked and fine: a tapered EXTRUDE leans in the same way whichever way the outline was drawn (volume 417.018 both ways).

I'll send fixes to bugs with PR #21

@withshalom
withshalom marked this pull request as draft November 15, 2026 04:03
SkryxDev and others added 12 commits November 15, 2026 12:48
…nd solids save as 3DSOLIDs

- crates/solid/src/acis: reads ACIS SAT/SAB in any dialect AutoCAD writes (through cadmpeg-asm)
  and writes ACIS 700 SAT and SAB, both by way of STEP with solidcore.
- crates/io/src/solid_acis: adopts 3DSOLIDs on open and writes them for every version (SAT in
  groups 1/3 up to 2010, a data store record of SAB from 2013); AutoCAD reference drawings in
  crates/io/tests/data/acad-solids with tests that compare against AutoCAD's MASSPROP.

Fixes from opening DraftCraft's files in AutoCAD 2027:
- DXF: a 3DSOLID (and any unknown entity read from DWG) now carries 100 AcDbEntity before its
  layer; without it AutoCAD refused the whole file.
- A cone's apex is written as a loop of one point edge, as AutoCAD does; without it AutoCAD
  called the cone an invalid solid with no volume.
- DWG 2000-2010: the SAT lines end with a line feed alone, as in AutoCAD's own files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The state of the AutoCAD check (SAT in DWG 2000/2010 still rejected with 75003), the gaps in file
compatibility, commands, 3D interaction, visualization and the web build, and the order to take them in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…DWG 2000

AutoCAD 2027 discarded every solid DraftCraft wrote into a DWG 2000 or 2010 file (error 75003,
eCannotRestoreFromAcisFile), though it took the same SAT 700 text from DXF. AutoCAD's own DWG 2000
holds SAT 400, and its 3DSOLID container matches ours. SAT is now save format 400: no history fields
after an entity's attribute, no parameters or convexity on an edge, and a header that counts the
records. SAB stays 700 for the data store of 2013 and later.

Tests: sat_text_looks_like_acis_400, a_cone_apex_is_a_point_edge_loop (400 layout), and a check in
solids_save_as_autocad_3dsolids_in_every_version that every SAT for 2000 to 2010 is version 400.
Not yet checked in AutoCAD; handoff.md lists the check files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ACIS's own pcurves go to the kernel on spline faces, resampled onto the
kernel's edge parameter where it differs; a procedural helix becomes a
cubic spline; a closed circle edge starts exactly at its circle's angle 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The side face of a sweep closes on itself through a seam edge, whose two coedges carry ACIS
pcurves a period apart. The kernel's closed-form pcurve of the seam, worked out once for the
edge, put both uses on one side, and the face kept a sliver of its domain: the solid read with
the inner half of its tube only (volume 887). ACIS's own pcurves now come first.

The free-form test checks both solids against AutoCAD's MASSPROP: the loft 175685.13 about
z 36.27, the sweep 44855.46 about (150, 0, 40), read 44851.57 (the helix as a spline).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…m solids read

- Writer: spline-surface (exactsur), intcurve (exactcur) and an exppc pcurve on
  every coedge of a spline face, laid out as AutoCAD 2000 writes its LOFT and
  SWEEP in SAT 400; SAB stays save format 700 with full subtype names and the
  later formats' tails.
- Reader: SAT 400's exppc pcurves and parameterless circle edges; parcur rails,
  ASM-text procedural surfaces (loft_spl_sur, sweep_sur) and helices filled in
  from the records where cadmpeg-asm only reads them word by word.
- Tests: AutoCAD's loft and sweep from DXF 2000, DXF 2010 and DWG 2018 against
  MASSPROP; both written back as SAT and SAB and read again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…27 check passes

A SAT whose header gives no record count needs its end-of-data line. With SAT 700 and the line
dropped, AutoCAD 2027 discarded every solid of a DWG 2000 or 2010 file (error 75003).

Checked in AutoCAD 2027 with SAT 400 and the line kept. DraftCraft's DWG and DXF files in versions
2000, 2010, 2013 and 2018 open, and so do AutoCAD's own solids saved again by DraftCraft (DWG 2018,
DXF 2000). AUDIT finds 0 errors, SOLIDEDIT calls every solid valid, and MASSPROP matches to four
decimals: 8/8 per file, 6/6 for the resaved ones.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The interim form records each mesh's fingerprint (MARK "DraftCraft solid 2"):
  a mesh edited elsewhere stays a mesh, a missing part takes no other mesh, a
  mirrored solid's mesh faces out; interim solids open with their body's exact look.
- SLICE, SECTION and picking go along the line of sight and take typed Z.
- SLICE, SHELL, SWEEP, FLATSHOT and region booleans are all-or-nothing.
- INTERFERE skips far-apart solids and scales volumes by the placement.
- 3D view: solids in blocks, mirrored solids, off-screen occluders, paint cache.
- Workspaces: a saved "3D Modeling" is not hidden; greyed out without solids.
- CI: a gate job with solids; the web app no longer takes the solids feature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- REGION: ACIS sheet bodies read into regions (XY plane, lines and arcs) and
  regions written as REGION (SAT 400 / SAB 700, double-sided plane faces, one
  lump per outer loop with its holes). AutoCAD 2027's own regions open with its
  MASSPROP; DraftCraft's open in AutoCAD as REGIONs, AUDIT clean, EXTRUDE works.
- BODY: a BODY holding a solid opens as a solid and is saved as a BODY again.
- Region MASSPROP is exact on arcs (circular segments), equal to AutoCAD's.
- AutoCAD REGION test drawings (DXF 2000/2010/2018, DWG 2000/2013/2018).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…not $CTABLESTYLE

AutoCAD's DXF has no $CTABLESTYLE header variable (AutoCAD reports it as unknown): it keeps the
current table style as a DICTIONARYVAR of the AcDbVariableDictionary. DraftCraft's DXF now
writes that dictionary (and its DICTIONARYVAR class) as its DWG already did, and no longer
writes $CTABLESTYLE; $HANDSEED is raised above the dictionary's handles.

The dictionary is now modelled rather than kept raw: the DXF and DWG readers take it into
Drawing::variables (with the current table style), and both writers save it again with the
drawing's own current table style, so a style made current after opening is not lost to a
stale kept copy. $CTABLESTYLE in older files' headers is still read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…compared with AutoCAD

Checked against the code at afccf04: what already works, how to work (gates, the command
checklist, AutoCAD checks), and every missing piece by area (file compatibility, modelling
commands, 3D transforms, sub-objects, UCS and the 3D environment, sections and drawing views,
visualization, surfaces and meshes, platform), with the kernel functions that exist for each
and the order to do them in. docs/solids.md points to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants