Expand description
GPU-free scene data for drawing CAD geometry.
plan:Plan2d, a persistent store of 2D lines, polylines, arcs and circles split into fixed-size chunks. Each chunk encodes its curves once into GPU instances (layout) in f32 coordinates relative to the chunk center; every frame checks the f32 representation error against a screen-space budget and hands chunks that exceed it back to the caller’s CPU path.mesh:Mesh3dtriangle meshes in f64 world coordinates andrelative_positions, the error-checked f64 to f32 conversion for upload.
The crate knows how to draw, not what the geometry means: callers map their own objects to
ObjectIds, decide colors and widths, track which objects changed and call
Plan2d::upsert / Plan2d::remove. cadkit-gpu renders the result with wgpu.
Coordinates are in the caller’s model units; screen quantities are in logical pixels
unless a name says physical.
use cadkit_geom::{Curve, LineSegment, Point2};
use cadkit_scene::{GroupId, ObjectId, Plan2d, Plan2dOptions, PlanItem, PlanView};
use std::collections::BTreeSet;
let mut plan = Plan2d::new(Plan2dOptions::new());
let wall = Curve::Line(LineSegment { start: Point2::new(0., 0.), end: Point2::new(5., 0.) });
plan.upsert(ObjectId(1), PlanItem::new(GroupId(0), vec![wall], [40, 40, 40, 255], 1.5));
let view = PlanView::new(Point2::new(2.5, 0.), 100., [800., 600.], 800.);
plan.prepare(&view, |_| true);
let frame = plan.frame(&view, |_| true, &BTreeSet::new(), true);
assert_eq!(frame.draws.len(), 1);
assert!(frame.cpu.is_empty());Re-exports§
pub use mesh::Mesh3d;pub use mesh::MeshBudget;pub use mesh::MeshScene;pub use mesh::relative_positions;pub use plan::ChunkDraw;pub use plan::Plan2d;pub use plan::Plan2dOptions;pub use plan::PlanFrame;pub use plan::PlanItem;pub use plan::PlanView;pub use plan::curve_bounds;
Modules§
- document
- Bridge from a
cadkit_core::Documentmodel toPlanItems (featuredocument). - layout
- Byte layout of the 2D GPU instances that
crate::Plan2dencodes andcadkit-gpudraws. - mesh
- Neutral 3D triangle meshes in f64 world coordinates.
- plan
- Persistent, chunked 2D store of lines, polylines, arcs and circles for GPU drawing.
Structs§
- GroupId
- A group the caller can show or hide per frame without rebuilding, such as a storey or a sheet. Chunks never mix groups; groups are drawn in ascending id order.
- Object
Id - Identifier of one caller object. The caller assigns it;
Plan2ddraws objects of a chunk in ascending id order, so later ids are drawn on top.
Enums§
- Scene
Error - Why scene data could not be produced.