Part of #41: the last of five `benilla-app` pieces. This one is everything the others did not cover: the addon harness, the settings registry, the glue screens (login, realm list, character select and create), key bindings, the minimap, nameplates, the loading screen, transports, the performance instruments, the smaller modules, the integration tests, and the UI asset files (`OptionsFrame.xml`, `benilla.toc` and the rest). Their comments are rewritten to the rule in `docs/METHOD.md`, which is what the code does and the reference fact behind it, in a line. 27,351 comment lines become 11,010. Fixes #33. Fixes #103. - **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: - The weapon trail's emissive is 0 (`0x70ca30`): the trail is a type-5 render record, so its ambient-only light term is exact. - The camera-style dropdown writes "1", "2", "0" (`UIOptionsFrame.lua:525,536,547`); several register-site addresses in the settings table are corrected. - The graphics settings are held until `RestartGx`, as in 1.12; `Fonts.xml`'s early load no longer carries a false reason. - vmangos sends a player-name invalidation after a rename (`CharacterHandler.cpp:839`), and the cinematic camera's announce packet has an empty handler there (`MiscHandler.cpp:919`). - Stock FrameXML and GlueXML line citations are checked against the stock 1.12 files, and vmangos line citations against the pinned revision. - **Deviation labels.** "Deviation:" now marks only a choice with its recorded reason. Declining to copy a reference defect is stated plainly, and so is an unbuilt behaviour or an untraced one. - **Verification.** Every file strips to identical code, apart from test literals in `login/`, `death/` and `ui_script/death_tests.rs` that now use placeholder account and character names, and `cargo fmt --check` is clean. Six second readers compared every file old against new, restored the facts the rewrite had dropped, and checked each new citation against the code, the stock files, vmangos and the reference. A second commit corrects one comment in `benilla-ui` (`unit_is_grey`: the reference's exclusion is players only). A third lowers `ui_script_wall`'s ceiling from 45 to 40: five gameplay files named `UiScript` only in comments the rewrite removed, and the ratchet asks for the number to follow. Behaviour differences the rewrite surfaced are filed as their own issues (#339 to #353 among them). 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>
113 lines
4.7 KiB
Rust
113 lines
4.7 KiB
Rust
//! Bevy's 2D opaque pass, skipped when both its phases are empty, which on our cameras they always
|
|
//! are (UI quads are transparent, Bevy UI and egui draw in their own nodes). The first pass to
|
|
//! touch the view target clears it, so the transparent pass after it takes the clear.
|
|
//! Registered under Bevy's own label: `add_node` is a map insert, so it replaces the node and the
|
|
//! edges keyed by label carry over.
|
|
|
|
use bevy::core_pipeline::core_2d::graph::{Core2d, Node2d};
|
|
use bevy::core_pipeline::core_2d::{AlphaMask2d, Opaque2d};
|
|
use bevy::ecs::query::QueryItem;
|
|
use bevy::prelude::*;
|
|
use bevy::render::camera::ExtractedCamera;
|
|
use bevy::render::diagnostic::RecordDiagnostics;
|
|
use bevy::render::render_graph::{
|
|
NodeRunError, RenderGraphContext, RenderGraphExt, ViewNode, ViewNodeRunner,
|
|
};
|
|
use bevy::render::render_phase::{TrackedRenderPass, ViewBinnedRenderPhases};
|
|
use bevy::render::render_resource::{CommandEncoderDescriptor, RenderPassDescriptor, StoreOp};
|
|
use bevy::render::renderer::RenderContext;
|
|
use bevy::render::view::{ExtractedView, ViewDepthTexture, ViewTarget};
|
|
use bevy::render::RenderApp;
|
|
|
|
#[derive(Default)]
|
|
struct SkipEmptyOpaque2dNode;
|
|
|
|
impl ViewNode for SkipEmptyOpaque2dNode {
|
|
type ViewQuery = (
|
|
&'static ExtractedCamera,
|
|
&'static ExtractedView,
|
|
&'static ViewTarget,
|
|
&'static ViewDepthTexture,
|
|
);
|
|
|
|
fn run<'w>(
|
|
&self,
|
|
graph: &mut RenderGraphContext,
|
|
render_context: &mut RenderContext<'w>,
|
|
(camera, view, target, depth): QueryItem<'w, '_, Self::ViewQuery>,
|
|
world: &'w World,
|
|
) -> Result<(), NodeRunError> {
|
|
let (Some(opaque_phases), Some(alpha_mask_phases)) = (
|
|
world.get_resource::<ViewBinnedRenderPhases<Opaque2d>>(),
|
|
world.get_resource::<ViewBinnedRenderPhases<AlphaMask2d>>(),
|
|
) else {
|
|
return Ok(());
|
|
};
|
|
let view_entity = graph.view_entity();
|
|
let (Some(opaque_phase), Some(alpha_mask_phase)) = (
|
|
opaque_phases.get(&view.retained_view_entity),
|
|
alpha_mask_phases.get(&view.retained_view_entity),
|
|
) else {
|
|
return Ok(());
|
|
};
|
|
// The one line Bevy's node lacks: the transparent pass that follows opens unconditionally
|
|
// and takes the target's first-call clear.
|
|
if opaque_phase.is_empty() && alpha_mask_phase.is_empty() {
|
|
return Ok(());
|
|
}
|
|
|
|
let diagnostics = render_context.diagnostic_recorder();
|
|
let color_attachments = [Some(target.get_color_attachment())];
|
|
let depth_stencil_attachment = Some(depth.get_attachment(StoreOp::Store));
|
|
|
|
render_context.add_command_buffer_generation_task(move |render_device| {
|
|
let mut command_encoder =
|
|
render_device.create_command_encoder(&CommandEncoderDescriptor {
|
|
label: Some("main_opaque_pass_2d_command_encoder"),
|
|
});
|
|
let render_pass = command_encoder.begin_render_pass(&RenderPassDescriptor {
|
|
label: Some("main_opaque_pass_2d"),
|
|
color_attachments: &color_attachments,
|
|
depth_stencil_attachment,
|
|
timestamp_writes: None,
|
|
occlusion_query_set: None,
|
|
});
|
|
let mut render_pass = TrackedRenderPass::new(&render_device, render_pass);
|
|
let pass_span = diagnostics.pass_span(&mut render_pass, "main_opaque_pass_2d");
|
|
if let Some(viewport) = camera.viewport.as_ref() {
|
|
render_pass.set_camera_viewport(viewport);
|
|
}
|
|
if !opaque_phase.is_empty() {
|
|
if let Err(err) = opaque_phase.render(&mut render_pass, world, view_entity) {
|
|
error!("Error encountered while rendering the 2d opaque phase {err:?}");
|
|
}
|
|
}
|
|
if !alpha_mask_phase.is_empty() {
|
|
if let Err(err) = alpha_mask_phase.render(&mut render_pass, world, view_entity) {
|
|
error!("Error encountered while rendering the 2d alpha mask phase {err:?}");
|
|
}
|
|
}
|
|
pass_span.end(&mut render_pass);
|
|
drop(render_pass);
|
|
command_encoder.finish()
|
|
});
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
/// Replaces Bevy's 2D opaque node; must be added after `DefaultPlugins` registers the original
|
|
/// (by [`crate::ui_pass::PlayerUiPlugin`]).
|
|
pub(crate) struct SkipEmptyOpaque2dPlugin;
|
|
|
|
impl Plugin for SkipEmptyOpaque2dPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
|
|
return;
|
|
};
|
|
render_app.add_render_graph_node::<ViewNodeRunner<SkipEmptyOpaque2dNode>>(
|
|
Core2d,
|
|
Node2d::MainOpaquePass,
|
|
);
|
|
}
|
|
}
|