Skip to main content

oxihuman_mesh/
lib.rs

1// Copyright (C) 2026 COOLJAPAN OU (Team KitaSan)
2// SPDX-License-Identifier: Apache-2.0
3
4//! Mesh processing, topology, and geometry algorithms for OxiHuman.
5//!
6//! This crate sits between the morph engine and the export pipeline. It takes
7//! raw [`oxihuman_morph::engine::MeshBuffers`] output and enriches it with
8//! recomputed normals, tangents, optional vertex colors, UV atlasing, LOD
9//! decimation, Catmull-Clark subdivision, cloth/skeleton skinning, geodesic
10//! distances, and a suite of topology repair routines.
11//!
12//! # Key types
13//!
14//! - [`MeshBuffers`] — the canonical mesh representation used by exporters.
15//! - [`Skeleton`] / [`Joint`] — rig hierarchy for linear blend skinning.
16//! - [`SkinWeights`] — per-vertex bone weights.
17//! - [`BodyMeasurements`] — computed anthropometric measurements from a mesh.
18//!
19//! # Example: build and repair a mesh
20//!
21//! ```rust
22//! use oxihuman_mesh::mesh::MeshBuffers;
23//! use oxihuman_mesh::repair::repair_mesh;
24//! use oxihuman_morph::engine::MeshBuffers as MorphBuffers;
25//!
26//! let morph_out = MorphBuffers {
27//!     positions: vec![[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]],
28//!     normals:   vec![[0.0, 0.0, 1.0]; 3],
29//!     uvs:       vec![[0.0, 0.0]; 3],
30//!     indices:   vec![0, 1, 2],
31//!     has_suit:  false,
32//! };
33//! let mut mesh = MeshBuffers::from_morph(morph_out);
34//! let report = repair_mesh(&mut mesh);
35//! assert!(report.degenerate_faces_removed == 0 || report.duplicate_faces_removed == 0);
36//! ```
37
38// ---------------------------------------------------------------------------
39// Color utilities (set_uniform_color + tests)
40// ---------------------------------------------------------------------------
41pub mod color_utils;
42pub use color_utils::set_uniform_color;
43
44// ---------------------------------------------------------------------------
45// Module batch A — core mesh types, normals, repair, connectivity, geodesic
46// (lines 38-134 and 191-500 of the original lib.rs)
47// ---------------------------------------------------------------------------
48include!("mods_a.rs");
49
50// ---------------------------------------------------------------------------
51// Module batch B — sampling, curvature, AO, BVH, marching-cubes, remesh …
52// (lines 501-1000 of the original lib.rs)
53// ---------------------------------------------------------------------------
54include!("mods_b.rs");
55
56// ---------------------------------------------------------------------------
57// Module batch C — mesh_lscm, mesh_tet, mesh_pca, mesh_progressive, …
58// (lines 1001-1600 of the original lib.rs)
59// ---------------------------------------------------------------------------
60include!("mods_c.rs");
61
62// ---------------------------------------------------------------------------
63// Module batch D — mesh_vertex_*, mesh_uv_*, cloth, hair, modifiers …
64// (lines 1601-2500 of the original lib.rs)
65// ---------------------------------------------------------------------------
66include!("mods_d.rs");
67
68// ---------------------------------------------------------------------------
69// Module batch E — dissolve, flatten, constraints, tools, query modules …
70// (lines 2501-3323 of the original lib.rs)
71// ---------------------------------------------------------------------------
72include!("mods_e.rs");