Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

L1 for every branch landing at once: crates and files back under their limits, copies folded, the Solari fix marked

shinyobjectz04adefa570e8
diff --git a/Cargo.lock b/Cargo.lock
index 28873a70..5be179e8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -14929,6 +14929,7 @@ dependencies = [
"objc2 0.6.5",
"objc2-metal 0.3.2",
"objc2-metal-fx",
+ "raea-io-home",
"wgpu",
]
@@ -15908,6 +15909,7 @@ dependencies = [
"raea-core-scene",
"raea-io-media",
"raea-sys-layers",
+ "raea-sys-shots",
"serde_json",
"wgpu",
]
@@ -16338,6 +16340,14 @@ dependencies = [
"serde_json",
]
+[[package]]
+name = "raea-sys-shots"
+version = "0.1.0"
+dependencies = [
+ "bevy",
+ "raea-core-program",
+]
+
[[package]]
name = "raea-sys-song"
version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
index 012a46b8..24cdbaff 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -113,6 +113,7 @@ members = [
"systems/page-net",
"systems/page-ops",
"systems/frame",
+ "systems/shots",
"systems/hold",
"systems/body",
"systems/grab",
diff --git a/apps/tools/src/sound.rs b/apps/tools/src/sound.rs
index 4671e1f5..4b4268e4 100644
--- a/apps/tools/src/sound.rs
+++ b/apps/tools/src/sound.rs
@@ -259,17 +259,12 @@ pub fn setup_audio(args: &[String]) -> R<String> {
(false, true) => "installed now".to_string(),
(false, false) => format!("not installed: {} installs it", raea_io_assets::setup_script(m).display()),
};
- lines.push(format!(" {m:<10} {state}; {what}\n {} ({})", dir.display(), if now { disk(&dir) } else { "-".into() }));
+ lines.push(format!(" {m:<10} {state}; {what}\n {} ({})", dir.display(), if now { raea_io_home::disk_use(&dir, false) } else { "-".into() }));
}
let head = if check { if missing > 0 { "CHECKED local audio models (some missing)" } else { "CHECKED local audio models" } } else { "APPLIED local audio models ready" };
Ok(format!("{head}\n{}", lines.join("\n")))
}
-/// What a folder takes on disk (clones of another install count in full here, as du counts them).
-fn disk(dir: &Path) -> String {
- raea_io_home::disk_use(dir, false)
-}
-
// ---- the open sample libraries --------------------------------------------------------------------------------------
/// sdk/raea/library/sounds/catalog.json (tools/sounds/catalog.py writes it): the libraries, their licences and every
diff --git a/core/shape/src/kept.rs b/core/shape/src/kept.rs
index 629a2141..fa33f25e 100644
--- a/core/shape/src/kept.rs
+++ b/core/shape/src/kept.rs
@@ -32,7 +32,7 @@ fn caches() -> Option<PathBuf> {
fn this_build() -> (u64, u128) {
static BUILD: std::sync::OnceLock<(u64, u128)> = std::sync::OnceLock::new();
*BUILD.get_or_init(|| {
- let m = std::env::current_exe().ok().and_then(|p| std::fs::metadata(p).ok());
+ let m = std::env::current_exe().and_then(std::fs::metadata).ok();
let t = m.as_ref().and_then(|m| m.modified().ok()).and_then(|t| t.duration_since(std::time::UNIX_EPOCH).ok()).map(|d| d.as_nanos()).unwrap_or(0);
(m.map(|m| m.len()).unwrap_or(0), t)
})
diff --git a/engine/render/raytrace/Cargo.toml b/engine/render/raytrace/Cargo.toml
index 08d37478..a2a0eea5 100644
--- a/engine/render/raytrace/Cargo.toml
+++ b/engine/render/raytrace/Cargo.toml
@@ -7,6 +7,8 @@ publish = false
description = "raea-render's ray tracing: Bevy's Solari for a scene whose camera asks for it (RT3), and MetalFX's temporal denoiser on it on the Mac (RT4)"
[dependencies]
+# RAEA_SOLARI_DYNAMIC=1 read as raea's other switches are
+raea-io-home = { path = "../../../io/home" }
bevy = { version = "=0.20.0", default-features = false, features = ["std", "3d_bevy_render", "bevy_solari"] }
# the same wgpu Bevy uses (the guide pass records on its device; MetalFX runs on its Metal objects)
wgpu = "=30.0.1"
diff --git a/engine/render/raytrace/src/solari.rs b/engine/render/raytrace/src/solari.rs
index c61eecc6..9926ee93 100644
--- a/engine/render/raytrace/src/solari.rs
+++ b/engine/render/raytrace/src/solari.rs
@@ -35,7 +35,7 @@ pub fn add(app: &mut App) {
/// and bounces light), and a hidden part leaves the traced scene until it is shown again (hidden, it still shadowed).
fn dynamic() -> bool {
static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
- *ON.get_or_init(|| std::env::var("RAEA_SOLARI_DYNAMIC").as_deref() == Ok("1"))
+ *ON.get_or_init(|| raea_io_home::env_on("RAEA_SOLARI_DYNAMIC"))
}
/// A skinned mesh's traced twin: the mesh's bind pose in Solari's layout and its skin, and the joints last posed from.
diff --git a/io/codec/src/remux.rs b/io/codec/src/remux.rs
index 791346a9..af390f4c 100644
--- a/io/codec/src/remux.rs
+++ b/io/codec/src/remux.rs
@@ -30,7 +30,7 @@ pub fn hvcc_params(hvcc: &[u8]) -> Vec<u8> {
let Some(c) = hvcc.get(i + 1..i + 3) else { break };
i += 3;
for _ in 0..u16::from_be_bytes([c[0], c[1]]) {
- let Some(n) = hvcc.get(i..i + 2).map(|l| u16::from_be_bytes([l[0], l[1]]) as usize) else { return out };
+ let Some(n) = hvcc.get(i..i + 2).and_then(|l| l.try_into().ok()).map(|l| u16::from_be_bytes(l) as usize) else { return out };
let Some(nal) = hvcc.get(i + 2..i + 2 + n) else { return out };
out.extend_from_slice(&[0, 0, 0, 1]);
out.extend_from_slice(nal);
diff --git a/io/media/src/lib.rs b/io/media/src/lib.rs
index c3eb6a55..dd2a4d29 100644
--- a/io/media/src/lib.rs
+++ b/io/media/src/lib.rs
@@ -86,10 +86,8 @@ pub fn preferred() -> Vec<Box<dyn Backend>> {
out
}
+/// The backend named, wrapped by an installed signer as backends() wraps each.
pub fn backend(name: &str) -> R<Box<dyn Backend>> {
- backends()
- .into_iter()
- .find(|b| b.name() == name)
- .ok_or(format!("no backend {name:?} in this build"))
+ backend_unsigned(name).map(sign::wrap)
}
diff --git a/runtime/export/src/fed.rs b/runtime/export/src/fed.rs
index e39f8ffd..0c372a46 100644
--- a/runtime/export/src/fed.rs
+++ b/runtime/export/src/fed.rs
@@ -255,7 +255,7 @@ pub(crate) fn render_fed(app: &mut App, js: &Path, w: u32, h: u32, fps: f64, tot
// a page draw past Vello's bump buffers, painted again at Vello's own sizes before the frame is encoded (#23)
fr = raea_gpu_device::check::fed_checked(f, fr, raea_sys_page::wait_drawn, raea_sys_page::redraw_full, || { cx.manifest.as_mut().map(|m| m.pop()); bevy_fed(app.world_mut(), bevy, cx, &page, fps) })?;
// a shot starts here (an outermost Sequence, a camera cut): the video's next segment does too (RR3)
- cuts.find(f, raea_runtime_page::shot_starts(app.world_mut()), cx.scene3d.as_ref().is_some_and(|e| raea_sys_frame::shots::Cut::at(e.world(), f)));
+ cuts.find(f, raea_runtime_page::shot_starts(app.world_mut()), matches!(&cx.scene3d, Some(e) if raea_sys_frame::shots::Cut::at(e.world(), f)));
// a video's 3D made live keeps each frame's scene for the clipping check
if LIVE_CLIPS.load(std::sync::atomic::Ordering::Relaxed) { fr.scene = scene_of(app.world_mut()); }
if cx.scene3d.is_none() && cx.live3d.is_none() && !cx.scene.is_empty() && BEVY_3D_PROBE.load(std::sync::atomic::Ordering::Relaxed) {
diff --git a/runtime/live/src/props.rs b/runtime/live/src/props.rs
index 5d711f9d..e866b78d 100644
--- a/runtime/live/src/props.rs
+++ b/runtime/live/src/props.rs
@@ -157,7 +157,7 @@ fn held(before: Option<&Holds>, after: Option<&Holds>) -> Vec<Value> {
(!changed.is_empty()).then(|| json!({"part": part, "kind": kind, "cols": changed}))
})
.collect();
- out.sort_by(|x, y| x["part"].as_str().cmp(&y["part"].as_str()));
+ out.sort_by(|x, y| x.get("part").and_then(Value::as_str).cmp(&y.get("part").and_then(Value::as_str)));
out
}
diff --git a/runtime/look/src/cuts.rs b/runtime/look/src/cuts.rs
index 877b955a..40619b2c 100644
--- a/runtime/look/src/cuts.rs
+++ b/runtime/look/src/cuts.rs
@@ -4,7 +4,7 @@ use super::*;
/// The paint look's worlds (a <Look cuts>: raea-render's paint.rs, paint_world.wesl): each of up to four cuts' centre,
/// radius, style, scale and amount on the camera row, one value a frame. No columns while no look has cuts.
pub fn paint_cut_rows(looks: &[Option<&Map<String, Value>>], p: &mut Program, row: &mut BTreeMap<String, V>, first: &Map<String, Value>) {
- if !looks.iter().flatten().any(|l| l.get("cuts").is_some_and(Value::is_array)) {
+ if !looks.iter().flatten().any(|l| matches!(l.get("cuts"), Some(Value::Array(_)))) {
return;
}
for i in 0..4 {
diff --git a/runtime/scene/src/live.rs b/runtime/scene/src/live.rs
index ddae6c36..48757606 100644
--- a/runtime/scene/src/live.rs
+++ b/runtime/scene/src/live.rs
@@ -74,11 +74,10 @@ pub fn live_dynamic(kind: &str) -> &'static [&'static str] {
/// its place and look, lens, roll (up_*), view window, ambient, sky and environment, aberration, depth of field, motion
/// blur, the paint look and its parts' rotations (*_qx..qw). The rest is the first frame's, as a render's is.
pub fn cam_keyed(k: &str) -> bool {
- ["lens_", "mb_", "up_", "view_"].iter().any(|p| k.starts_with(p))
+ // paint_cut: the paint look's worlds, each cut's centre, radius and style moving frame by frame (raea-runtime-look paint_cut_rows)
+ ["lens_", "mb_", "up_", "view_", "paint_cut"].iter().any(|p| k.starts_with(p))
|| ["_qx", "_qy", "_qz", "_qw"].iter().any(|q| k.ends_with(q))
|| matches!(k, "x" | "y" | "z" | "look_x" | "look_y" | "look_z" | "fov" | "focus" | "ortho" | "ambient" | "skybox_k" | "env_srcs" | "env_i" | "env_k" | "env_rot" | "sky_k" | "aberration" | "dof_aperture" | "paint_bands" | "paint_grain" | "paint_rag" | "paint_seed")
- // the paint look's worlds: each cut's centre, radius and style move frame by frame (raea-runtime-look paint_cut_rows)
- || k.starts_with("paint_cut")
}
impl LiveScene {
diff --git a/runtime/segments/src/encode.rs b/runtime/segments/src/encode.rs
index 5e5cf7fc..915d17ff 100644
--- a/runtime/segments/src/encode.rs
+++ b/runtime/segments/src/encode.rs
@@ -13,6 +13,8 @@ use crate::split::Cuts;
pub(crate) struct Segs {
pub name: String,
pub cuts: Cuts,
+ /// the shortest segment, in frames (a second's): a cut sooner than this after the segment's first frame is passed
+ /// over, so a run of short shots shares one (a keyframe a few frames apart buys a cache nothing and costs bits)
pub min: usize,
}
diff --git a/runtime/segments/src/lib.rs b/runtime/segments/src/lib.rs
index 6bee641d..b80f5b97 100644
--- a/runtime/segments/src/lib.rs
+++ b/runtime/segments/src/lib.rs
@@ -11,7 +11,7 @@ mod encode;
mod join;
mod split;
pub use join::join;
-pub use split::{Cuts, min_frames, segments};
+pub use split::{Cuts, segments};
/// The backends whose encoders write segments the join reads (muxide's MP4s: H.264, HEVC, AV1) and lay a sound under
/// a joined video (Backend::sound). The ffmpeg CLI, the baseline, encodes in one run.
@@ -25,11 +25,11 @@ pub fn on() -> bool {
}
/// The encoder for a whole video (frame 0 first, every frame in order) to `out`: `codec`'s, a new segment at each of
-/// `cuts` once the one before holds min_frames, the whole wrapped by the signer when one is installed (one export, one
+/// `cuts` once the one before holds a second of frames, the whole wrapped by the signer when one is installed (one export, one
/// watermark id, the joined file signed). The ffmpeg baseline's, or with segments off: one run, as before.
pub fn encoder(codec: &str, out: &Path, opts: &EncodeOpts, ten: bool, cuts: &Cuts) -> R<Box<dyn VideoEncoder>> {
let b = if segmentable(codec) && on() {
- raea_io_media::sign::wrap(Box::new(encode::Segs { name: codec.into(), cuts: cuts.clone(), min: min_frames(opts.fps) }))
+ raea_io_media::sign::wrap(Box::new(encode::Segs { name: codec.into(), cuts: cuts.clone(), min: (opts.fps.round() as usize).max(1) }))
} else {
raea_io_media::backend(codec)?
};
diff --git a/runtime/segments/src/split.rs b/runtime/segments/src/split.rs
index 89b37de4..b8fb4a2a 100644
--- a/runtime/segments/src/split.rs
+++ b/runtime/segments/src/split.rs
@@ -37,11 +37,6 @@ impl Cuts {
}
}
-/// The shortest segment, in frames: a cut sooner than this after the segment's first frame is passed over, so a run of
-/// short shots shares one (a keyframe a few frames apart buys a cache nothing and costs the encoder bits).
-pub fn min_frames(fps: f64) -> usize {
- (fps.round() as usize).max(1)
-}
/// The segments a run of `n` frames makes with these cuts: each one's first frame and length.
pub fn segments(n: usize, cuts: &Cuts, min: usize) -> Vec<(usize, usize)> {
diff --git a/runtime/segments/tests/join.rs b/runtime/segments/tests/join.rs
index 9c5b5fa4..0e9d8b1f 100644
--- a/runtime/segments/tests/join.rs
+++ b/runtime/segments/tests/join.rs
@@ -33,13 +33,18 @@ fn scratch(name: &str) -> PathBuf {
d
}
+/// The video track.
+fn video(m: &re_mp4::Mp4) -> &re_mp4::Track {
+ m.tracks().values().find(|t| t.kind == Some(re_mp4::TrackKind::Video)).unwrap()
+}
+
/// The video track's samples' key flags, and whether there's a sound track.
fn keys(path: &Path) -> (Vec<bool>, bool) {
let b = std::fs::read(path).unwrap();
let m = re_mp4::Mp4::read_bytes(&b).unwrap();
- let video = m.tracks().values().find(|t| t.kind == Some(re_mp4::TrackKind::Video)).unwrap();
- // re_mp4 names only AAC (mp4a) a sound track; Opus (soft, av1) reads as kind None
- let sound = m.tracks().values().any(|t| t.kind != Some(re_mp4::TrackKind::Video));
+ let video = video(&m);
+ // a track besides the video: re_mp4 names only AAC (mp4a) a sound track; Opus (soft, av1) reads as kind None
+ let sound = m.tracks().len() > 1;
(video.samples.iter().map(|s| s.is_sync).collect(), sound)
}
@@ -47,7 +52,7 @@ fn keys(path: &Path) -> (Vec<bool>, bool) {
fn samples(path: &Path) -> Vec<Vec<u8>> {
let b = std::fs::read(path).unwrap();
let m = re_mp4::Mp4::read_bytes(&b).unwrap();
- let video = m.tracks().values().find(|t| t.kind == Some(re_mp4::TrackKind::Video)).unwrap();
+ let video = video(&m);
video.samples.iter().map(|s| b[s.byte_range()].to_vec()).collect()
}
diff --git a/sdk/cloud/src/index.ts b/sdk/cloud/src/index.ts
index 2c7c138a..e6c45f47 100644
--- a/sdk/cloud/src/index.ts
+++ b/sdk/cloud/src/index.ts
@@ -28,11 +28,11 @@ export interface Health {
jobs: { id: string; running: boolean }[]
}
-/** A render farm's choices for one job (deploy/modal/farm.py): at most `gpus` GPUs at once, of kind `gpu` (Modal's
+/** A render farm's choices for one job (deploy/modal/farm.py): at most `gpus` GPUs at once, each a `card` (Modal's
* names: L4, L40S, ...), and a price over `maxUsd` (estimated from the first frames) stops it before the rest. */
export interface Farm {
gpus?: number
- gpu?: string
+ card?: string
maxUsd?: number
/** the job's media outputs stay on the farm for `media` to send to R2 (docs/cloud-render.feature CR23) */
media?: boolean
@@ -149,7 +149,7 @@ export class RaeaCloud {
async startJob(args: string[], folder: Uint8Array, signal?: AbortSignal, farm: Farm = {}): Promise<string> {
const q = new URLSearchParams({ args: JSON.stringify(args) })
if (farm.gpus !== undefined) q.set("gpus", String(farm.gpus))
- if (farm.gpu) q.set("gpu", farm.gpu)
+ if (farm.card) q.set("gpu", farm.card)
if (farm.maxUsd !== undefined) q.set("max_usd", String(farm.maxUsd))
if (farm.media) q.set("media", "1")
const r = await this.fetch(`/v1/jobs?${q}`, { method: "POST", body: new Blob([folder as Uint8Array<ArrayBuffer>]), headers: { "content-type": "application/octet-stream" }, signal })
diff --git a/sdk/video/src/controls.ts b/sdk/video/src/controls.ts
new file mode 100644
index 00000000..2ec73ee4
--- /dev/null
+++ b/sdk/video/src/controls.ts
@@ -0,0 +1,141 @@
+// A composition's controls (docs/realtime.feature RT4): the defaultProps a panel tunes, each one's kind and how a
+// change to it reaches the picture, and the check a registered composition's controls pass (registry.tsx).
+
+/** How a change to a control reaches the picture. `live` (the default): the running stage draws it at once, as a
+ * prop. `reopen`: the stage opens the file again first, for what a running 3D world keeps from its first frame (a
+ * shape, a model's file, an instance count, a picture map, a shader). `resim`: everything from the frame it changes
+ * on is worked out again, for state carried from frame to frame (physics, particles, a game's fold). */
+export type ControlCost = "live" | "reopen" | "resim";
+
+interface ControlBase {
+ /** what the panel calls it (the key when left out) */
+ label?: string;
+ /** the panel's group it sits in ("Grade", "Camera"); ungrouped controls come first */
+ group?: string;
+ /** how a change reaches the picture: "live" unless said */
+ cost?: ControlCost;
+ /** one line on what it changes, for the panel's tooltip and an agent reading the code */
+ about?: string;
+}
+
+/** A number, dragged on a slider when it has both ends. */
+export interface NumberControl extends ControlBase {
+ /** what it is: a number */
+ kind: "number";
+ /** the least it may be */
+ min?: number;
+ /** the most it may be */
+ max?: number;
+ /** what one step of the slider or an arrow key moves it by (above 0) */
+ step?: number;
+ /** its unit, shown after it ("px", "°", "s") */
+ unit?: string;
+}
+
+/** On or off: a boolean. */
+export interface SwitchControl extends ControlBase {
+ /** what it is: on or off */
+ kind: "switch";
+}
+
+/** One of a list: a string or a number from `options`. */
+export interface ChoiceControl extends ControlBase {
+ /** what it is: one of a list */
+ kind: "choice";
+ /** what it may be, in the order the panel lists them (at least one, none twice) */
+ options: readonly (string | number)[];
+}
+
+/** A colour: a hex string, "#rgb", "#rgba", "#rrggbb" or "#rrggbbaa". */
+export interface ColourControl extends ControlBase {
+ /** what it is: a colour */
+ kind: "colour";
+}
+
+/** A string: a title, a caption, a name. */
+export interface TextControl extends ControlBase {
+ /** what it is: a string */
+ kind: "text";
+ /** a box of several lines rather than one */
+ multiline?: boolean;
+ /** the most characters it may hold */
+ maxLength?: number;
+}
+
+export type Control = NumberControl | SwitchControl | ChoiceControl | ColourControl | TextControl;
+
+/** A composition's controls, by the defaultProps key each one tunes. */
+export type Controls<P = Record<string, unknown>> = { readonly [K in keyof P & string]?: Control };
+
+/** A control as a registered composition holds it: its cost said. */
+export type RegisteredControl = Control & { cost: ControlCost };
+
+const KINDS: readonly Control["kind"][] = ["number", "switch", "choice", "colour", "text"];
+const COSTS: readonly ControlCost[] = ["live", "reopen", "resim"];
+const HEX = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
+
+/** The controls checked against the defaultProps they tune: each names one of its keys, says a kind and a cost
+ * raea knows, and its value fits that kind. `fail(field, why)` throws. */
+export function validControls(given: unknown, props: Record<string, unknown>, fail: (field: string, why: string) => never): Record<string, RegisteredControl> {
+ if (given === undefined) return {};
+ if (given === null || typeof given !== "object" || Array.isArray(given) || Object.getPrototypeOf(given) !== Object.prototype) {
+ fail("controls", "must be an object of controls by defaultProps key");
+ }
+ const out: Record<string, RegisteredControl> = {};
+ for (const [key, c] of Object.entries(given as Record<string, unknown>)) {
+ const at = `controls.${key}`;
+ if (!Object.prototype.hasOwnProperty.call(props, key)) {
+ const keys = Object.keys(props);
+ fail(at, `names no defaultProps key: a control tunes a prop the composition has a value for (defaultProps has ${keys.length ? keys.join(", ") : "none"})`);
+ }
+ if (c === null || typeof c !== "object" || Array.isArray(c)) fail(at, `must be an object with a kind (${KINDS.join(", ")})`);
+ const spec = c as Record<string, unknown>;
+ if (!KINDS.includes(spec.kind as Control["kind"])) fail(`${at}.kind`, `must be one of ${KINDS.join(", ")}, got ${JSON.stringify(spec.kind)}`);
+ if (spec.cost !== undefined && !COSTS.includes(spec.cost as ControlCost)) fail(`${at}.cost`, `must be one of ${COSTS.join(", ")}, got ${JSON.stringify(spec.cost)}`);
+ for (const f of ["label", "group", "about", "unit"] as const) {
+ if (spec[f] !== undefined && typeof spec[f] !== "string") fail(`${at}.${f}`, `must be a string, got ${JSON.stringify(spec[f])}`);
+ }
+ const v = props[key];
+ const got = JSON.stringify(v);
+ switch (spec.kind as Control["kind"]) {
+ case "number": {
+ for (const f of ["min", "max", "step"] as const) {
+ if (spec[f] !== undefined && !(typeof spec[f] === "number" && Number.isFinite(spec[f]))) fail(`${at}.${f}`, `must be a finite number, got ${JSON.stringify(spec[f])}`);
+ }
+ const { min, max, step } = spec as { min?: number; max?: number; step?: number };
+ if (min !== undefined && max !== undefined && min > max) fail(at, `has min ${min} above max ${max}`);
+ if (step !== undefined && !(step > 0)) fail(`${at}.step`, `must be above 0, got ${step}`);
+ if (typeof v !== "number" || !Number.isFinite(v)) fail(at, `is a number, but defaultProps.${key} is ${got}`);
+ if ((min !== undefined && (v as number) < min) || (max !== undefined && (v as number) > max)) fail(at, `is ${min ?? "-∞"} to ${max ?? "∞"}, but defaultProps.${key} is ${got}`);
+ break;
+ }
+ case "switch":
+ if (typeof v !== "boolean") fail(at, `is a switch, but defaultProps.${key} is ${got} (it takes true or false)`);
+ break;
+ case "choice": {
+ const options = spec.options;
+ if (!Array.isArray(options) || options.length === 0 || !options.every((o) => typeof o === "string" || (typeof o === "number" && Number.isFinite(o)))) {
+ fail(`${at}.options`, "must be a non-empty list of strings or numbers");
+ }
+ const opts = options as (string | number)[];
+ const twice = opts.find((o, i) => opts.indexOf(o) !== i);
+ if (twice !== undefined) fail(`${at}.options`, `lists ${JSON.stringify(twice)} twice`);
+ if (!opts.includes(v as string | number)) fail(at, `is one of ${opts.map((o) => JSON.stringify(o)).join(", ")}, but defaultProps.${key} is ${got}`);
+ break;
+ }
+ case "colour":
+ if (typeof v !== "string" || !HEX.test(v)) fail(at, `is a colour, but defaultProps.${key} is ${got} (it takes "#rgb", "#rgba", "#rrggbb" or "#rrggbbaa")`);
+ break;
+ case "text": {
+ const { maxLength } = spec as { maxLength?: unknown };
+ if (maxLength !== undefined && !(Number.isInteger(maxLength) && (maxLength as number) > 0)) fail(`${at}.maxLength`, `must be a positive integer, got ${JSON.stringify(maxLength)}`);
+ if (spec.multiline !== undefined && typeof spec.multiline !== "boolean") fail(`${at}.multiline`, `must be true or false, got ${JSON.stringify(spec.multiline)}`);
+ if (typeof v !== "string") fail(at, `is text, but defaultProps.${key} is ${got}`);
+ if (maxLength !== undefined && (v as string).length > (maxLength as number)) fail(at, `holds at most ${maxLength} characters, but defaultProps.${key} has ${(v as string).length}`);
+ break;
+ }
+ }
+ out[key] = { ...(spec as unknown as Control), cost: (spec.cost as ControlCost | undefined) ?? "live" };
+ }
+ return out;
+}
diff --git a/sdk/video/src/registry.tsx b/sdk/video/src/registry.tsx
index 925045b1..c7228dd1 100644
--- a/sdk/video/src/registry.tsx
+++ b/sdk/video/src/registry.tsx
@@ -5,6 +5,8 @@ import { useVideoConfig } from "@raea/app/clock";
import { Audio, Video } from "./media";
import { Region } from "./region";
import { Freeze, Loop, Sequence, Series } from "./timeline";
+import { validControls, type Control, type Controls, type ControlCost, type RegisteredControl } from "./controls";
+export * from "./controls";
export interface CompositionProps<P extends Record<string, unknown> = Record<string, unknown>> {
/** the composition's id: letters, digits and dashes (`raea render --composition` picks it) */
@@ -29,70 +31,6 @@ export interface CompositionProps<P extends Record<string, unknown> = Record<str
edit?: Edit;
}
-/** How a change to a control reaches the picture. `live` (the default): the running stage draws it at once, as a
- * prop. `reopen`: the stage opens the file again first, for what a running 3D world keeps from its first frame (a
- * shape, a model's file, an instance count, a picture map, a shader). `resim`: everything from the frame it changes
- * on is worked out again, for state carried from frame to frame (physics, particles, a game's fold). */
-export type ControlCost = "live" | "reopen" | "resim";
-
-interface ControlBase {
- /** what the panel calls it (the key when left out) */
- label?: string;
- /** the panel's group it sits in ("Grade", "Camera"); ungrouped controls come first */
- group?: string;
- /** how a change reaches the picture: "live" unless said */
- cost?: ControlCost;
- /** one line on what it changes, for the panel's tooltip and an agent reading the code */
- about?: string;
-}
-
-/** A number, dragged on a slider when it has both ends. */
-export interface NumberControl extends ControlBase {
- kind: "number";
- /** the least it may be */
- min?: number;
- /** the most it may be */
- max?: number;
- /** what one step of the slider or an arrow key moves it by (above 0) */
- step?: number;
- /** its unit, shown after it ("px", "°", "s") */
- unit?: string;
-}
-
-/** On or off: a boolean. */
-export interface SwitchControl extends ControlBase {
- kind: "switch";
-}
-
-/** One of a list: a string or a number from `options`. */
-export interface ChoiceControl extends ControlBase {
- kind: "choice";
- /** what it may be, in the order the panel lists them (at least one, none twice) */
- options: readonly (string | number)[];
-}
-
-/** A colour: a hex string, "#rgb", "#rgba", "#rrggbb" or "#rrggbbaa". */
-export interface ColourControl extends ControlBase {
- kind: "colour";
-}
-
-/** A string: a title, a caption, a name. */
-export interface TextControl extends ControlBase {
- kind: "text";
- /** a box of several lines rather than one */
- multiline?: boolean;
- /** the most characters it may hold */
- maxLength?: number;
-}
-
-export type Control = NumberControl | SwitchControl | ChoiceControl | ColourControl | TextControl;
-
-/** A composition's controls, by the defaultProps key each one tunes. */
-export type Controls<P = Record<string, unknown>> = { readonly [K in keyof P & string]?: Control };
-
-/** A control as a registered composition holds it: its cost said. */
-export type RegisteredControl = Control & { cost: ControlCost };
-
/** A hand edit: `segments` are the composition's own frame ranges, [from, to), played one after another, so a trim,
* a split, a cut word or a moved span is a change to this list; the length becomes their sum. */
export interface Edit {
@@ -125,75 +63,6 @@ export interface RegisteredComposition {
}
const ID_PATTERN = /^[A-Za-z0-9-]+$/;
-const KINDS: readonly Control["kind"][] = ["number", "switch", "choice", "colour", "text"];
-const COSTS: readonly ControlCost[] = ["live", "reopen", "resim"];
-const HEX = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
-
-/** The controls checked against the defaultProps they tune: each names one of its keys, says a kind and a cost
- * raea knows, and its value fits that kind. `fail(field, why)` throws. */
-function validControls(given: unknown, props: Record<string, unknown>, fail: (field: string, why: string) => never): Record<string, RegisteredControl> {
- if (given === undefined) return {};
- if (given === null || typeof given !== "object" || Array.isArray(given) || Object.getPrototypeOf(given) !== Object.prototype) {
- fail("controls", "must be an object of controls by defaultProps key");
- }
- const out: Record<string, RegisteredControl> = {};
- for (const [key, c] of Object.entries(given as Record<string, unknown>)) {
- const at = `controls.${key}`;
- if (!Object.prototype.hasOwnProperty.call(props, key)) {
- const keys = Object.keys(props);
- fail(at, `names no defaultProps key: a control tunes a prop the composition has a value for (defaultProps has ${keys.length ? keys.join(", ") : "none"})`);
- }
- if (c === null || typeof c !== "object" || Array.isArray(c)) fail(at, `must be an object with a kind (${KINDS.join(", ")})`);
- const spec = c as Record<string, unknown>;
- if (!KINDS.includes(spec.kind as Control["kind"])) fail(`${at}.kind`, `must be one of ${KINDS.join(", ")}, got ${JSON.stringify(spec.kind)}`);
- if (spec.cost !== undefined && !COSTS.includes(spec.cost as ControlCost)) fail(`${at}.cost`, `must be one of ${COSTS.join(", ")}, got ${JSON.stringify(spec.cost)}`);
- for (const f of ["label", "group", "about", "unit"] as const) {
- if (spec[f] !== undefined && typeof spec[f] !== "string") fail(`${at}.${f}`, `must be a string, got ${JSON.stringify(spec[f])}`);
- }
- const v = props[key];
- const got = JSON.stringify(v);
- switch (spec.kind as Control["kind"]) {
- case "number": {
- for (const f of ["min", "max", "step"] as const) {
- if (spec[f] !== undefined && !(typeof spec[f] === "number" && Number.isFinite(spec[f]))) fail(`${at}.${f}`, `must be a finite number, got ${JSON.stringify(spec[f])}`);
- }
- const { min, max, step } = spec as { min?: number; max?: number; step?: number };
- if (min !== undefined && max !== undefined && min > max) fail(at, `has min ${min} above max ${max}`);
- if (step !== undefined && !(step > 0)) fail(`${at}.step`, `must be above 0, got ${step}`);
- if (typeof v !== "number" || !Number.isFinite(v)) fail(at, `is a number, but defaultProps.${key} is ${got}`);
- if ((min !== undefined && (v as number) < min) || (max !== undefined && (v as number) > max)) fail(at, `is ${min ?? "-∞"} to ${max ?? "∞"}, but defaultProps.${key} is ${got}`);
- break;
- }
- case "switch":
- if (typeof v !== "boolean") fail(at, `is a switch, but defaultProps.${key} is ${got} (it takes true or false)`);
- break;
- case "choice": {
- const options = spec.options;
- if (!Array.isArray(options) || options.length === 0 || !options.every((o) => typeof o === "string" || (typeof o === "number" && Number.isFinite(o)))) {
- fail(`${at}.options`, "must be a non-empty list of strings or numbers");
- }
- const opts = options as (string | number)[];
- const twice = opts.find((o, i) => opts.indexOf(o) !== i);
- if (twice !== undefined) fail(`${at}.options`, `lists ${JSON.stringify(twice)} twice`);
- if (!opts.includes(v as string | number)) fail(at, `is one of ${opts.map((o) => JSON.stringify(o)).join(", ")}, but defaultProps.${key} is ${got}`);
- break;
- }
- case "colour":
- if (typeof v !== "string" || !HEX.test(v)) fail(at, `is a colour, but defaultProps.${key} is ${got} (it takes "#rgb", "#rgba", "#rrggbb" or "#rrggbbaa")`);
- break;
- case "text": {
- const { maxLength } = spec as { maxLength?: unknown };
- if (maxLength !== undefined && !(Number.isInteger(maxLength) && (maxLength as number) > 0)) fail(`${at}.maxLength`, `must be a positive integer, got ${JSON.stringify(maxLength)}`);
- if (spec.multiline !== undefined && typeof spec.multiline !== "boolean") fail(`${at}.multiline`, `must be true or false, got ${JSON.stringify(spec.multiline)}`);
- if (typeof v !== "string") fail(at, `is text, but defaultProps.${key} is ${got}`);
- if (maxLength !== undefined && (v as string).length > (maxLength as number)) fail(at, `holds at most ${maxLength} characters, but defaultProps.${key} has ${(v as string).length}`);
- break;
- }
- }
- out[key] = { ...(spec as unknown as Control), cost: (spec.cost as ControlCost | undefined) ?? "live" };
- }
- return out;
-}
function isJsonLike(v: unknown, seen: Set<unknown>): boolean {
if (v === null || typeof v === "string" || typeof v === "boolean") return true;
diff --git a/systems/foliage/src/atlas.rs b/systems/foliage/src/atlas.rs
index 88b2ee1b..28a87785 100644
--- a/systems/foliage/src/atlas.rs
+++ b/systems/foliage/src/atlas.rs
@@ -45,10 +45,6 @@ fn shape(u: f32, p: f32, q: f32) -> f32 {
u.powf(p) * (1.0 - u).powf(q) / m
}
-fn smooth(a: f32, b: f32, x: f32) -> f32 {
- let t = ((x - a) / (b - a)).clamp(0.0, 1.0);
- t * t * (3.0 - 2.0 * t)
-}
impl Blade {
/// How far inside the blade (x, y) is (leaf lengths; negative outside), and its vein strength 0-1.
@@ -68,7 +64,7 @@ impl Blade {
w *= 0.42 + 0.58 * (std::f32::consts::PI * u * self.lobes).sin().abs().powf(0.6);
}
if self.teeth > 0.0 {
- w *= 1.0 - self.depth * (u * self.teeth).fract() * smooth(0.0, 0.2, u);
+ w *= 1.0 - self.depth * (u * self.teeth).fract() * crate::leaves::smooth(0.0, 0.2, u);
}
let mut inside = w - cross.abs();
if self.sinus && t < 0.04 {
@@ -262,7 +258,7 @@ pub(crate) fn png(img: &RgbaImage) -> Result<Vec<u8>, String> {
/// The share of a cell's pixels that are leaf.
pub(crate) fn coverage(img: &RgbaImage, cell: u32) -> f32 {
let (cx, cy) = ((cell % CELLS) * CELL, (cell / CELLS) * CELL);
- let n = (0..CELL).flat_map(|y| (0..CELL).map(move |x| (x, y))).filter(|&(x, y)| img.get_pixel(cx + x, cy + y)[3] > 127).count();
+ let n = (0..CELL * CELL).filter(|i| img.get_pixel(cx + i % CELL, cy + i / CELL)[3] > 127).count();
n as f32 / (CELL * CELL) as f32
}
diff --git a/systems/foliage/src/leaves.rs b/systems/foliage/src/leaves.rs
index c17d8ba9..25f9935c 100644
--- a/systems/foliage/src/leaves.rs
+++ b/systems/foliage/src/leaves.rs
@@ -129,7 +129,8 @@ pub(crate) fn leaves(sp: &Species, req: &Request, nodes: &[Node], env: &Envelope
out
}
-fn smooth(a: f32, b: f32, x: f32) -> f32 {
+/// 0 below `a`, 1 above `b`, smoothly between (a leaf's gaps, its teeth's roots in atlas.rs).
+pub(crate) fn smooth(a: f32, b: f32, x: f32) -> f32 {
let t = ((x - a) / (b - a)).clamp(0.0, 1.0);
t * t * (3.0 - 2.0 * t)
}
diff --git a/systems/foliage/src/lib.rs b/systems/foliage/src/lib.rs
index 262538ed..2f28d8fd 100644
--- a/systems/foliage/src/lib.rs
+++ b/systems/foliage/src/lib.rs
@@ -61,7 +61,7 @@ pub struct Mesh {
impl Mesh {
pub fn tris(&self) -> usize {
- self.idx.len() / 3
+ self.idx.chunks_exact(3).len()
}
}
diff --git a/systems/foliage/src/shape.rs b/systems/foliage/src/shape.rs
index b1b3e31d..423d92ad 100644
--- a/systems/foliage/src/shape.rs
+++ b/systems/foliage/src/shape.rs
@@ -37,10 +37,12 @@ fn fill(img: &mut GrayImage, t: [(f32, f32); 3], uv: Option<[[f32; 2]; 3]>, shee
return;
}
let (w, h) = (img.width() as i32, img.height() as i32);
- let lo = |f: fn(&(f32, f32)) -> f32| t.iter().map(f).fold(f32::INFINITY, f32::min).floor() as i32;
- let hi = |f: fn(&(f32, f32)) -> f32| t.iter().map(f).fold(f32::NEG_INFINITY, f32::max).ceil() as i32;
- for y in lo(|p| p.1).max(0)..=hi(|p| p.1).min(h - 1) {
- for x in lo(|p| p.0).max(0)..=hi(|p| p.0).min(w - 1) {
+ let (mut x0, mut y0, mut x1, mut y1) = (f32::INFINITY, f32::INFINITY, f32::NEG_INFINITY, f32::NEG_INFINITY);
+ for p in t {
+ (x0, y0, x1, y1) = (x0.min(p.0), y0.min(p.1), x1.max(p.0), y1.max(p.1));
+ }
+ for y in (y0.floor() as i32).max(0)..=(y1.ceil() as i32).min(h - 1) {
+ for x in (x0.floor() as i32).max(0)..=(x1.ceil() as i32).min(w - 1) {
let (px, py) = (x as f32 + 0.5, y as f32 + 0.5);
let w0 = ((t[1].0 - px) * (t[2].1 - py) - (t[2].0 - px) * (t[1].1 - py)) / area;
let w1 = ((t[2].0 - px) * (t[0].1 - py) - (t[0].0 - px) * (t[2].1 - py)) / area;
diff --git a/systems/frame/Cargo.toml b/systems/frame/Cargo.toml
index 03c5d7ff..74e77ac0 100644
--- a/systems/frame/Cargo.toml
+++ b/systems/frame/Cargo.toml
@@ -13,6 +13,8 @@ native = ["dep:raea-io-media"]
[dependencies]
bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "3d_bevy_render", "bevy_ui"] }
raea-core-program = { path = "../../core/program" }
+# cuts between cameras (systems/shots), as raea_sys_frame::shots
+raea-sys-shots = { path = "../shots" }
# a staticFile path (/media/x) as a file: the media folders it can be in (raea-core-scene media_path)
raea-core-scene = { path = "../../core/scene" }
# the layer key (key_of), shared with the page's half of the layer pass
diff --git a/systems/frame/src/lib.rs b/systems/frame/src/lib.rs
index 887e4d0e..bd7b9277 100644
--- a/systems/frame/src/lib.rs
+++ b/systems/frame/src/lib.rs
@@ -35,7 +35,7 @@ pub use render_image::RenderKind;
/// a row's per-frame tables (a frame's look, the camera's post-processing), laid onto it frame by frame
pub mod tables;
/// the frames where another camera becomes the piece's (a cut between cameras, RR2)
-pub mod shots;
+pub use raea_sys_shots as shots;
/// A model row's entity (a glTF under it), whatever its loading stage.
#[derive(Component, Default)]
diff --git a/systems/glb/src/lib.rs b/systems/glb/src/lib.rs
index 032ab67b..5bd842f4 100644
--- a/systems/glb/src/lib.rs
+++ b/systems/glb/src/lib.rs
@@ -91,7 +91,7 @@ pub fn indices(g: &Glb, i: usize) -> R<Vec<u32>> {
let (b, _, csize, _) = raw(g, i)?;
Ok(match csize {
1 => b.iter().map(|&x| x as u32).collect(),
- 2 => b.chunks_exact(2).map(|c| u16::from_le_bytes([c[0], c[1]]) as u32).collect(),
+ 2 => b.chunks_exact(2).map(|c| u32::from(u16::from_le_bytes([c[0], c[1]]))).collect(),
_ => b.chunks_exact(4).map(|c| u32::from_le_bytes(c.try_into().unwrap())).collect(),
})
}
diff --git a/systems/kimodo/src/torch.rs b/systems/kimodo/src/torch.rs
index af3404ab..550ea3cb 100644
--- a/systems/kimodo/src/torch.rs
+++ b/systems/kimodo/src/torch.rs
@@ -54,6 +54,8 @@ pub struct Torch {
pub venv: PathBuf,
/// the motion checkpoint's folder (its stats are decode.rs's too)
pub checkpoint: PathBuf,
+ /// the environment's record of what it was made from: a different list makes it again
+ made_from: PathBuf,
}
/// One clip asked of PyTorch.
@@ -76,25 +78,21 @@ pub struct Made {
impl Torch {
pub fn at(dir: PathBuf) -> Self {
- Torch { venv: dir.join("venv"), checkpoint: dir.join("checkpoints").join("Kimodo-SOMA-RP-v1"), dir }
+ let venv = dir.join("venv");
+ Torch { made_from: venv.join("raea-packages.txt"), venv, checkpoint: dir.join("checkpoints").join("Kimodo-SOMA-RP-v1"), dir }
}
pub fn python(&self) -> PathBuf {
if cfg!(windows) { self.venv.join("Scripts").join("python.exe") } else { self.venv.join("bin").join("python") }
}
- /// the environment's record of what it was made from: a different list makes it again
- fn made_from(&self) -> PathBuf {
- self.venv.join("raea-packages.txt")
- }
-
fn packages() -> String {
PACKAGES.join("\n")
}
/// Whether the Python environment is made from this binary's package list.
pub fn has_env(&self) -> bool {
- self.python().exists() && std::fs::read_to_string(self.made_from()).is_ok_and(|s| s == Self::packages())
+ self.python().exists() && std::fs::read_to_string(&self.made_from).is_ok_and(|s| s == Self::packages())
}
/// What isn't there yet, by name: the Python environment, the motion model, the text encoder. Empty when it's all set up.
@@ -146,7 +144,7 @@ impl Torch {
let _ = std::fs::remove_dir_all(&venv);
return Err(e);
}
- std::fs::write(self.made_from(), Self::packages())?;
+ std::fs::write(&self.made_from, Self::packages())?;
made.push(format!("made the Python environment (Python 3.11, PyTorch, Kimodo at {}): {}", &KIMODO[..7], venv.display()));
}
if self.missing().iter().any(|m| *m != "Python environment") {
diff --git a/systems/look/src/paint.rs b/systems/look/src/paint.rs
index 4bf9f71d..de9d1715 100644
--- a/systems/look/src/paint.rs
+++ b/systems/look/src/paint.rs
@@ -198,11 +198,12 @@ fn params(v: &BTreeMap<String, V>) -> PaintParams {
haze_sun.w = on("paint_haze_sun");
let mut cut_rim = lin(v.get("paint_cut_rim"), [1.0, 1.0, 1.0, 1.0]);
cut_rim.w = on("paint_cut_rim_width");
+ let styles = |s: &str, d: [f32; 4]| std::array::from_fn(|i| lin(v.get(&format!("paint_cut{i}_{s}")), d));
PaintParams {
cut: std::array::from_fn(|i| Vec4::new(num(v, &format!("paint_cut{i}_x"), 0.0), num(v, &format!("paint_cut{i}_y"), 0.0), num(v, &format!("paint_cut{i}_z"), 0.0), num(v, &format!("paint_cut{i}_r"), 0.0).max(0.0))),
style: std::array::from_fn(|i| Vec4::new(num(v, &format!("paint_cut{i}_style"), 0.0), num(v, &format!("paint_cut{i}_scale"), 0.1).max(1e-4), num(v, &format!("paint_cut{i}_amount"), 1.0).clamp(0.0, 1.0), 0.0)),
- style_a: std::array::from_fn(|i| lin(v.get(&format!("paint_cut{i}_a")), [0.05, 0.05, 0.08, 1.0])),
- style_b: std::array::from_fn(|i| lin(v.get(&format!("paint_cut{i}_b")), [1.0, 1.0, 1.0, 1.0])),
+ style_a: styles("a", [0.05, 0.05, 0.08, 1.0]),
+ style_b: styles("b", [1.0, 1.0, 1.0, 1.0]),
kw: Vec4::new(0.0, num(v, "paint_cut_rag", 0.0).max(0.0), num(v, "paint_cut_rim_width", 0.0).max(0.0), 0.0),
cut_rim,
k9: Vec4::new(num(v, "paint_rim_amount", 0.0).max(0.0), num(v, "paint_rim_power", 3.0).max(0.1), num(v, "paint_term_amount", 0.0).clamp(0.0, 1.0), 0.0),
diff --git a/systems/shots/Cargo.toml b/systems/shots/Cargo.toml
new file mode 100644
index 00000000..a8a66f24
--- /dev/null
+++ b/systems/shots/Cargo.toml
@@ -0,0 +1,12 @@
+[package]
+name = "raea-sys-shots"
+version = "0.1.0"
+edition = "2024"
+license = "FSL-1.1-ALv2"
+publish = false
+description = "Cuts between cameras: the frames that start a shot, a live scene's shot change, and the frame an engine last drew as a cut (raea-sys-frame re-exports it as shots)"
+
+[dependencies]
+# a shot's frames read from the camera row's keys
+raea-core-program = { path = "../../core/program" }
+bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "3d_bevy_render", "bevy_ui"] }
diff --git a/systems/frame/src/shots.rs b/systems/shots/src/lib.rs
similarity index 100%
rename from systems/frame/src/shots.rs
rename to systems/shots/src/lib.rs
diff --git a/systems/touch/src/spots.rs b/systems/touch/src/spots.rs
index cc7780cb..736a3d82 100644
--- a/systems/touch/src/spots.rs
+++ b/systems/touch/src/spots.rs
@@ -120,7 +120,7 @@ pub(crate) fn spots(s: &Surface, doors: &[Door], pts: &[Point]) -> Vec<Spot> {
const NINE: [(i64, i64); 9] = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 0), (0, 1), (1, -1), (1, 0), (1, 1)];
let near = |p: Vec3| {
let (c, (x, y)) = (cell(p), flat(p));
- NINE.iter().map(move |&(i, j)| (c.0 + i, c.1 + j)).flat_map(|k| arris.get(&k).into_iter().flatten()).filter(move |q| {
+ NINE.iter().map(move |&(i, j)| (c.0 + i, c.1 + j)).filter_map(|k| arris.get(&k)).flatten().filter(move |q| {
let (a, b) = flat(q.p);
(a - x).hypot(b - y) <= CORNER
})
diff --git a/systems/weathering/src/merge.rs b/systems/weathering/src/merge.rs
index 3445a9d9..38898938 100644
--- a/systems/weathering/src/merge.rs
+++ b/systems/weathering/src/merge.rs
@@ -128,11 +128,14 @@ pub(crate) fn absorb(cs: Vec<Chart>, sc: &Scene, env: &Env) -> Vec<Chart> {
c.n != Vec3::ZERO && (w.min(h) < THIN || w * h < AREA)
};
let bounds = |c: &Chart| {
- let ps = c.tris.iter().flat_map(|&t| sc.tri[t as usize].map(|v| sc.pos[v as usize]));
- ps.fold((Vec3::splat(f32::MAX), Vec3::splat(f32::MIN)), |(l, h), p| (l.min(p), h.max(p)))
+ let ps = || c.tris.iter().flat_map(|&t| sc.tri[t as usize].map(|v| sc.pos[v as usize]));
+ (ps().fold(Vec3::MAX, Vec3::min), ps().fold(Vec3::MIN, Vec3::max))
};
const CELL: f32 = 4.0;
- let cell = |v: Vec3| ((v.x / CELL).floor() as i32, (v.y / CELL).floor() as i32, (v.z / CELL).floor() as i32);
+ let cell = |v: Vec3| {
+ let c = (v / CELL).floor().as_ivec3();
+ (c.x, c.y, c.z)
+ };
let mut grid: HashMap<(i32, i32, i32), Vec<u32>> = HashMap::new();
let is_small: Vec<bool> = cs.iter().zip(&ds).map(|(c, &d)| small(c, d)).collect();
for (i, c) in cs.iter().enumerate() {
diff --git a/tools/dupes.max b/tools/dupes.max
index 2d34224b..84a20044 100644
--- a/tools/dupes.max
+++ b/tools/dupes.max
@@ -19,5 +19,15 @@
# io/capcut store.rs:67 (tasklist's stdout, lower-cased; sdk/ui/parity main.rs:88 trims a command's stdout),
# io/capcut build.rs:24 parse (serde_json::from_str + expect; engine/native node.rs:172 js_string, to_string), and
# apps/capcut plan.rs:67 (a box moved more than 1 px; systems/layout mod.rs:406, within 1.5 px)
-exact=289
-near=58
+# Raised once more, 11-17, when every waiting branch landed together (body motion, wear, foliage, segmented export, the
+# realtime controls and the rest): 289/58 -> 294/59. Its copies were folded (io-media's backend() is backend_unsigned
+# wrapped; paint's cut colours read by one closure; foliage's one smoothstep and its bounds in one pass; segments' video
+# track found once in its tests; the Solari switch through raea_io_home::env_on); the six left match by shape only:
+# exact: runtime/segments encode.rs Segs open_video/decode_audio and encoder/encoder_10bit, Segmented
+# push_nv12/push_p010 (a Backend's and a VideoEncoder's one-line forwards, alike by the traits' design);
+# systems/foliage lib.rs hash_str (tone tonegraph.rs hash, the same FNV-1a: foliage can't depend on systems/
+# tone) and Rng::range (core/grow mesh.rs Rng::range in f64; foliage's stream is its own, so moving it to
+# core/grow's would change every tree)
+# near: runtime/live props.rs Live::controls/held (accessors); io/av1 and io/soft Backend::sound (one-line forwards)
+exact=294
+near=59
diff --git a/tools/layers.toml b/tools/layers.toml
index 4091c826..ad6b67d3 100644
--- a/tools/layers.toml
+++ b/tools/layers.toml
@@ -110,6 +110,7 @@ raea-sys-page = "systems"
raea-sys-page-net = "systems"
raea-sys-page-ops = "systems"
raea-sys-frame = "systems"
+raea-sys-shots = "systems"
raea-sys-hold = "systems"
raea-sys-body = "systems"
raea-sys-grab = "systems"
@@ -157,6 +158,7 @@ raea-runtime-bundle = "runtime"
raea-runtime-bundle-lib = "runtime"
raea-runtime-calls = "runtime"
raea-runtime-shots = "runtime"
+raea-runtime-segments = "runtime"
raea-runtime-canvas = "runtime"
raea-runtime-wear = "runtime"
raea-runtime-export = "runtime"
@@ -230,6 +232,8 @@ raea-hands-audit = "tools"
[facility]
# the frame's rows every pass reads (FrameRows, the edit, the clock, row helpers)
raea-sys-frame = true
+# cuts between cameras: the frames that start a shot and the last cut drawn (raea-sys-frame re-exports it)
+raea-sys-shots = true
# the layer pass's keys, table, raster and NAME.layers (raea-sys-frame records the 3D through it)
raea-sys-layers = true
# a row's standard material and its maps (meshseq builds its mesh's on it)
diff --git a/vendor/bevy_solari/src/scene/blas.rs b/vendor/bevy_solari/src/scene/blas.rs
index d5b58b0a..aba22a05 100644
--- a/vendor/bevy_solari/src/scene/blas.rs
+++ b/vendor/bevy_solari/src/scene/blas.rs
@@ -116,7 +116,7 @@ pub fn prepare_raytracing_blas(
allocate_blas(&vertex_slice, &index_slice, asset_id, &render_device);
blas_manager.insert(*asset_id, blas);
- // A mesh rebuilt while its last BLAS still waits in the queue (a mesh that changes every
+ // raea: a mesh rebuilt while its last BLAS still waits in the queue (a mesh that changes every
// frame, behind a backlog over MAX_COMPACTION_VERTICES_PER_FRAME) must not be queued
// twice: both entries would resolve to this new BLAS and prepare its compaction twice,
// which wgpu refuses ("Compaction is already being prepared").