Files
benilla-octo/crates/benilla-world/src/lib.rs
T
Sam SungandClaude Opus 5.5 fdfd8d39ec Comments in benilla-world: one line of fact each, no history, no record numbers (#121)
Part of #41: the comments of `benilla-world`, Rust and WGSL, are rewritten to the rule in `docs/METHOD.md`, which is what the code does and the reference fact behind it, in a line. 24,226 comment lines become 8,863.

- **The mechanical strip.** The citations that were only a private record number go first, and each edit is shown to be a pure removal.
- **Wrong facts corrected.** The rewrite corrects the comments that stated wrong facts. Among them:
  - `0x6b62e0` is the WMO group's liquid renderer, not a doodad drawer.
  - The reference creates a WMO's props once, when a group enters its streaming window (`0x698720` → `0x695aa0`). It then admits them each frame the portal walk visits the group (`0x685d70` → `0x6838f0`). The old text had them created per visible group.
  - The liquid query's comments now state the reference's order: the map-object leg first, then the ADT (`0x69b6d0`). They no longer call the Outdoors/Inside split a match.
  - The interior probe runs from the character, not the camera.
  - The reference lights ground clutter. The old comment said it draws unlit.
  - The model-particle "pool order" deviation was wrong. Each instance is its own mesh, depth-sorted every frame.
  - The reference's vertical field of view follows the aspect ratio (44.1° at 16:9). The comment now gives it beside our fixed 45°.
  - The effect shader's far wall is the live `farclip`, 177 to 777 yd, not a fixed 777 yd.
  - Dozens more turned up on the way: renamed or deleted items, docs sitting on the wrong item, stale counts and links.
- **Deviation labels.** "Deviation:" now marks only a choice with a reason. An unbuilt behaviour says so plainly.
- **Verification.** Every file strips to identical code, and `cargo fmt --check` is clean. Five second readers compared every file old against new, restored the facts the rewrite had dropped, and checked each new citation against the reference.

Defects the rewrite surfaced outside the comments are filed as their own issues (#106, #114, #115, #116). The comments here state what the code does. String literals are untouched; they are #92.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 17:43:40 +07:00

169 lines
4.8 KiB
Rust

//! benilla-world: the world renderer, with no game attached. It puts things into a world and
//! answers questions about it, and knows nothing of a session, the wire, an avatar or a UI. The
//! dependency edge holds that line: this crate does not depend on `benilla-app`, and
//! `benilla-worldview` links only this crate. Above it are `benilla-app` and the two binaries;
//! below it, `benilla-assets` and `benilla-formats`.
/// Re-exported so a shim binary needs no `bevy` dependency of its own.
pub use bevy::app::AppExit;
/// Test fixtures shared with dependent crates: ordinary public code, since `#[cfg(test)]` code is
/// not compiled for a downstream crate.
pub mod testing {
use benilla_formats::{
CellRamp, EmitParams, EmitTiming, OverLife, ParamsNow, ParticleBlend, ParticleEmitterDef,
ParticleShape,
};
/// The sampled parameters of [`particle_def`], constant so a sim test is deterministic.
pub fn particle_params_now() -> ParamsNow {
ParamsNow {
emission_speed: 1.0,
speed_variation: 0.0,
vertical_range: 0.5,
horizontal_range: std::f32::consts::PI,
gravity: 0.0,
lifespan: 1.0,
area_length: 2.0,
area_width: 4.0,
z_source: 0.0,
}
}
/// A minimal emitter def for kernel tests; only the fields the emit kernel reads matter.
pub fn particle_def(shape: ParticleShape) -> ParticleEmitterDef {
ParticleEmitterDef {
flags: 0,
position: [1.0, 2.0, 3.0],
bone: 0,
shape,
blend: ParticleBlend::Add,
lit: false,
texture: None,
tile_rows: 1,
tile_cols: 1,
head_tail: 0,
timing: EmitTiming::constant(10.0),
params: EmitParams::constant(particle_params_now()),
drag: 0.0,
tail_time: 0.0,
spline: None,
geometry_model: None,
recursion_model: None,
angular_velocity_min: [0.0; 3],
angular_velocity_max: [0.0; 3],
inherit_scale: 0.0,
follow_speed1: 0.0,
follow_scale1: 0.0,
follow_speed2: 0.0,
follow_scale2: 0.0,
twinkle_speed: 0.0,
twinkle_percent: 1.0,
twinkle_min: 0.0,
twinkle_max: 0.0,
spin: 0.0,
over_life: OverLife {
mid: 0.5,
color: [[1.0; 4]; 3],
scale: [1.0; 3],
head_cells: [CellRamp::new(0, 0); 2],
tail_cells: [CellRamp::new(0, 0); 2],
repeat: [1.0; 2],
},
}
}
/// The plain planar def most emitter tests want.
pub fn plain_particle_def() -> ParticleEmitterDef {
particle_def(ParticleShape::Plane)
}
/// A bind-pose [`crate::rig_anim::RigPose`] with one root-parented joint per entry, for tests
/// that resolve anchors (they spawn on demand through `RigPose::anchor_for`).
pub fn test_rig_pose(
root: bevy::ecs::entity::Entity,
joints: &[bevy::math::Vec3],
) -> crate::rig_anim::RigPose {
let skeleton = benilla_assets::ModelSkeleton {
joints: joints
.iter()
.map(|&t| benilla_assets::ModelJoint {
parent: -1,
local_translation: t,
billboard: None,
parent_arm: None,
})
.collect(),
spine_bone: None,
head_bone: None,
};
crate::rig_anim::RigPose::new(root, &skeleton)
}
}
pub mod art_scope;
pub mod assets;
pub mod bgwin;
pub mod billboard;
pub mod boot;
pub mod build_id;
pub mod clouds;
pub mod clutter;
pub mod collision;
pub mod decal;
pub mod dev_state;
pub mod doodad_anim;
pub mod entity_shade;
pub mod exterior_cull;
pub mod ffx_glow;
pub mod final_pass;
pub mod frame_pace;
pub mod ground_fx;
pub mod instance_tint;
pub mod interact;
pub mod interior;
pub mod lighting;
pub mod liquid;
pub mod log_ring;
/// macOS `Cmd+Q`, re-pointed at the window close so the shutdown systems run.
pub mod mac_quit;
pub mod map_proj;
pub mod mat_anim_table;
pub mod mesh_tag;
pub mod model_fade;
pub mod model_forms;
pub mod model_render;
pub mod modkeys;
pub mod particles;
pub mod ribbons;
pub mod ride_frame;
pub mod rig_anim;
pub mod rig_palette;
pub mod rig_rider;
pub mod schedule;
mod shaders;
pub mod sky;
pub mod sky_order;
pub mod skybox;
pub mod static_gx;
pub mod static_merge;
pub mod straddle;
pub mod sun;
pub mod surface;
pub mod terrain_stream;
pub mod thread_qos;
pub mod view;
pub mod vis_chain;
pub mod water_fx;
pub mod wdl;
pub mod weather;
pub mod wmo_portal;
pub mod world_census;
pub mod world_map;
pub mod world_plugins;
pub mod world_point;
pub mod world_unit;
pub mod worldview;
pub mod zfill;