Skip to main content

Crate alice_lol

Crate alice_lol 

Source
Expand description

§ALICE-LOL: Law-Oriented Language

A text language for signed distance fields: the lol! macro (compile time) and runtime_parser (run time) turn the same text into an SdfNode tree, which can be evaluated on the CPU, transpiled to GLSL / WGSL / HLSL, exported for 3D printing, and checked against geometric constraints (law). research_law holds unit-checked formulas with valid ranges, residuals and provenance.

use alice_lol::lol;
use alice_lol::runtime_parser::parse_lol;
use alice_lol::Vec3;

// Compile time: the macro builds the tree
let scene = lol! {
    smooth_union(0.2,
        sphere(1.0),
        translate(2.0, 0.0, 0.0, box3d(0.5, 0.5, 0.5))
    )
};

// Run time: the same text through the parser (from a file or a language model)
let parsed = parse_lol(
    "smooth_union(0.2, sphere(1.0), translate(2.0, 0.0, 0.0, box3d(0.5, 0.5, 0.5)))",
)
.unwrap();

// Both are the same field; the origin is inside the sphere
let p = Vec3::new(0.3, 0.1, 0.0);
assert_eq!(alice_lol::eval(&scene, p), alice_lol::eval(&parsed, p));
assert!(alice_lol::eval(&scene, Vec3::ZERO) < 0.0);

// GLSL source for a shader (default feature `glsl`)
let glsl = alice_lol::to_glsl(&scene);
assert!(!glsl.is_empty());

Modules§

angle
Canonicalizing a user-supplied angle before it is converted to radians Reducing a user-supplied angle, in degrees, to a numerically well-conditioned range before it is ever converted to radians.
audit_law
監査の Law — 検査を「何が成立すべきか」として書く.
emit
SdfNode → LOL text (runtime parser の逆変換、Track C0) SdfNode → LOL text (Track C0、runtime_parser::parse_lol の逆変換)
geometry_id
The geometry evaluation’s identifier — .lol text → SdfNode tree → evaluation result, and the reverse (emit’s canonical form).
intent
Intent Layer (Milestone B.1: IntentNode 独立 enum + Program 構造)
laser_pattern
レーザー彫刻向け2Dパターン生成
law
法則(Law)制約チェッカー
law_id
Law の識別子 — 同じ主張に同じ名前を付ける.
law_input
入力の読み方 — 型を持つ x-input と、request の JSON の読み.
limits
Named resource limits for user-controlled parameters, and the error types that report a refusal.
parity
When two evaluations of a field agree (IEEE-total: ±∞ and NaN are results) When two evaluations of a field agree
print_export
3Dプリント向けエクスポートモジュール
pruned_compile
空間枝刈りコンパイラ
research_law
Research laws: multi-variable formulas with units, a valid range, measured residuals, provenance and reference values
runtime_parser
ランタイム LOL パーサー
stdlib
Standard Library — LOL 標準パターンライブラリ

Macros§

lol
LOL (Law-Oriented Language) proc_macro.

Structs§

AabbPacked
SIMD-friendly AABB structure (32 bytes, cache-aligned)
CompiledSdf
Compiled SDF representation
CompiledSdfBvh
Compiled SDF with BVH acceleration data
Dual
1D dual number: val + eps * dot.
Dual3
3D dual number: value + gradient (∂f/∂x, ∂f/∂y, ∂f/∂z).
Interval
A closed interval [lo, hi] representing a range of possible values
Quat
A quaternion representing an orientation.
RenderConfig
レンダリング設定
Vec2
A 2-dimensional vector.
Vec3
A 3-dimensional vector.
Vec3Interval
3D interval representing an axis-aligned box region
Vec3x8
8 3D vectors packed for SIMD processing

Enums§

CompileError
Error type for SDF compilation failures.
EulerRot
Rotation Helper Euler rotation sequences.
SdfNode
Signed Distance Function Node

Constants§

LOL_GBNF
The LOL DSL grammar (lol.gbnf, GBNF) as shipped with this crate version.

Functions§

eval
Evaluate the SDF distance at a single point (CPU).
eval_compiled
Evaluate a compiled SDF at a point
eval_compiled_batch_simd
Batch evaluate compiled SDF using SIMD (8 points at a time)
eval_compiled_batch_simd_parallel
Parallel batch evaluate compiled SDF using SIMD
eval_compiled_batch_soa
Evaluate compiled SDF at many points using SoA layout (single-threaded)
eval_compiled_batch_soa_parallel
Evaluate compiled SDF at many points using SoA layout (multi-threaded)
eval_compiled_bvh
Evaluate compiled SDF with BVH annotations.
eval_compiled_distance_and_normal
Combined distance + normal from 4 evaluations (tetrahedral method).
eval_compiled_normal
Evaluate compiled SDF and compute normal using finite differences
eval_compiled_simd
Evaluate compiled SDF at 8 points simultaneously
eval_hessian
Compute the Hessian (second derivatives) at a point via finite differences on the gradient.
eval_interval
Evaluate an SDF tree over a spatial region, returning distance bounds.
eval_with_gradient
Evaluate SDF value and gradient simultaneously.
gaussian_curvature
Compute Gaussian curvature K = k1 * k2 at a surface point.
get_scene_aabb
Get the AABB for the entire compiled SDF
mean_curvature
Compute mean curvature at a point on the surface.
principal_curvatures
Compute principal curvatures (k1, k2) at a surface point.
to_glsl
Transpile an SdfNode tree to GLSL (hardcoded constants).
to_glsl_dynamic
Transpile an SdfNode tree to GLSL with dynamic parameters (uniform block).
to_glsl_full
フルレンダリングパイプライン付きGLSLを生成