Crates.io | procedural_modelling |
lib.rs | procedural_modelling |
version | |
source | src |
created_at | 2024-02-28 10:56:54.235823 |
updated_at | 2024-12-16 11:10:11.360936 |
description | A framework-agnostic Procedural Modelling crate. |
homepage | https://bevy-procedural.org/modelling |
repository | https://github.com/bevy-procedural/modelling |
max_upload_size | |
id | 1156332 |
Cargo.toml error: | TOML parse error at line 26, column 1 | 26 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A Framework-Agnostic Procedural Modelling Library.
Uses a data structure based on half-edge meshes to represent (open) manifold meshes with optional non-manifold vertices. Our goal is to implement operations like Boolean Operations, Subdivisions, Curved Surfaces, and Stitching. The library aims to support the triangulation of 2d surfaces in a modular way that can be used without any of the 3d features.
Goal of this project is to provide a reusable and framework-agnostic implementation of procedural modelling and geometry algorithms. Flexibility is generally preferred over performance, though, often a good balance can be achieved.
This crate is still in a very early stage of development. Expect frequent API modifications, bugs, and missing features. Feel free to contribute by opening issues, pull requests or sharing your ideas in GitHub Discussion.
Install using cargo add procedural_modelling
. Generate the above mesh using the following code for rendering with bevy:
let mut mesh = BevyMesh3d::new();
let mut edge = mesh.insert_regular_star(1.0, 0.8, 30);
mesh.flip_yz().translate(&Vec3::new(0.0, -0.99, 0.0));
let trans = Transform::from_rotation(Quat::from_rotation_y(0.3))
.with_translation(Vec3::new(-0.2, 0.3, -0.3));
edge = mesh.extrude_tri(edge, trans);
for _ in 0..5 {
edge = mesh.extrude_tri_face(mesh.edge(edge).face_id(), trans);
}
mesh.to_bevy(RenderAssetUsages::default())
Or run the examples on your computer like, e.g., cargo run --features="bevy bevy/bevy_pbr bevy/bevy_winit bevy/tonemapping_luts" --profile fast-dev --example box
.
For package development, we recommend using the playground_bevy
- resp. playground_wgpu
-subcrate. This example has a little egui-editor. Run it using cargo watch -w playground -w src -x "run -p playground_bevy --profile fast-dev"
. The fast-dev
profile will enable optimizations for the dependencies, but not for the package itself. This will slow down the first build significantly, but incremental builds are slightly faster and bevy's performance (bevy is used as the renderer in the examples) improves a lot.
When developing tests, we recommend cargo watch -w src -x "test --profile fast-dev"
resp. cargo llvm-cov --html
to generate a coverage report.
We are currently working on some tutorials for the most important features.
Attributes
Mesh Types
Triangulation
Primitives
Operations
Tools
Extensions
The availability of algorithms and operations for different mesh data structures is represented by traits. Some examples:
Transformable
trait indicates that you can apply affine transformation to a mesh and implements methods such as translate
and rotate
.EuclideanMeshType
indicates that the mesh has vertex positions and lives in an Euclidean space and associates the mesh data type with a Scalar
and Vector
type etc.MakePrismatoid
trait implements methods such as insert_pyramid
or insert_cube
.MeshTypeHalfEdge
trait indicates that the mesh is based on a half-edge data structure (or can be treated as if) and makes sure that the mesh uses edge implementations that implement half-edge related methods like twin_id
. It also enables the use of many algorithms that are currently only implemented for half-edge meshes.For a full list of traits see the documentation.
When using this trait-based library, you need to define your own type of Mesh
and implement all traits you need. For most traits all methods have reasonable default implementations. This allows you to quickly implement meshes backed by a custom data structure or using custom vertex, face, edge, or mesh payloads. If you don't need anything special, you can use one of our default implementations such as Bevy3dMesh
or the generic backend-agnostic MeshNd<d>
. See backends/bevy/mesh3d.rs
or backends/nalgebra/mesh_nd.rs
for the exemplary default implementations.
The following cargo features are available:
bevy
-- Compiles with support for bevy.wgpu
-- Compiles with support for wgpu.example_deps
-- Compiles with the dependencies necessary for the examples.netsci
-- Enable network science tools.svg
-- Enable SVG import. Adds usvg as a dependency.fonts
-- Enable font rendering. Adds ab_glyph as a dependency.meshopt
-- Enable mesh optimization. Adds meshopt as a dependency.nalgebra
-- Enable nalgebra as a backend. This is usually required for anything but bevy.For development only:
sweep_debug
-- Collect debug information during the sweepline triangulation and enable visualizations in the bevy backend.sweep_debug_print
-- Print debug information for the sweepline triangulation.bevy_dynamic
-- Use dynamic linking for bevy. This is useful for faster incremental builds.The package supports different triangulation algorithms. The robustness and rendering speed of the produced triangulations varies significantly. These performance differences usually only matter for meshes with extremely large flat surfaces. In the table below, we compare the performance of the different algorithms for a circle with 100, 1000, and 10000 vertices. The "ZigZag" mesh has 1000 reps. 10000 vertices and is designed to demonstrate the worst-case for the Sweep algorithm.
Sweep
and the quality of MinWeight
.cargo bench --features benchmarks --profile release
.cargo run -p fps_bench --profile release
and julia --project=./playground/fps_bench/FPSBench ./playground/fps_bench/FPSBench/src/main.jl
. For the non-Delaunay algorithms, the rendering time deteriorates for the larger circles since the edge length is not minimized causing significant overdraw.The following table shows the compatibility of procedural_modelling
(when using the bevy
feature) with certain versions of Bevy:
bevy | bevy_procedural_meshes |
---|---|
0.15 | 0.3.*, main |
0.14 | 0.2.* |
0.13 | 0.1.* |
Except where noted (below and/or in individual files), all code in this repository is dual-licensed, allowing you the flexibility to choose between:
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
We welcome contributions from the community! Here are some ways you can help:
Report Bugs:
Suggest Features:
Submit Pull Requests:
Improve Documentation: