Pick, plates and minimap follow what the scene drew, as 1.12.1 (#2355)

What the scene drew and what the camera looks at now decide plates, the mouse pick and the minimap, as in 1.12.1.

- **Mouse pick:** static doodads occlude it with their drawn opaque meshes, not their hulls (`0x69cdb0`, mode 2 of `0x7089c0`).
- **Plates:** a plate needs its unit drawn last frame (`0x6704c0`). Under far sight, plates centre on the camera's object, and there are none when it isn't a unit (`0x60f77c`).
- **Far sight:** `SMSG_CLEAR_FAR_SIGHT_IMMEDIATE` ends it (`0x5e43f8` → `0x5ee590`).
- **Minimap:**
  - the interior window keeps its z until x/y leave it or the group changes (`0x6d952c`);
  - party and pet dots and the group rim arrows have tooltips (`0x4eb33c`, `0x4eb42d`).
- **Tutorials:** Equippable Items skips ammo and quivers (`0x809200`).

Each fix has a test that failed before it.

Fixes #756
Fixes #2341
Fixes #2342
Fixes #2343
Fixes #2344
Fixes #2345
Fixes #2347

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sam Sung
2026-10-24 21:51:12 +07:00
committed by GitHub
parent 53e088b678
commit 308ca91d9e
30 changed files with 1141 additions and 245 deletions
+6 -21
View File
@@ -9,7 +9,8 @@
//! 20 yd (3-D). Self is not excluded. A new line replaces the old bubble, never queues.
//! - Lifetime and fade (`0x4b0c30`): a 250 ms fade in, the line's [`duration_ms`], a 250 ms fade
//! out, then the frame goes back to the pool. Out of range, or with the speaker not drawn in the
//! last render ([`speaker_drawn`]), it fades out and hides, and fades back in on return.
//! last render ([`crate::entities::SceneDrawn`]), it fades out and hides, and fades back in on
//! return.
//! - Anchor (`0x4b0c30`): unit z + height × model scale + 0.7, the text's BOTTOM on the projected
//! point (`0x4b157a`), growing upward. The height is the Stand sequence box's Z extent from the
//! model header (`0x711a20`), not the posed attachment the overhead name reads (`0x608640`),
@@ -312,22 +313,6 @@ struct Bubble {
depth: Option<f32>,
}
/// Whether the speaker was drawn in the last render: the reference's scene-node test `0x6704c0`
/// (`node && [node+0x94] == 0`, read at `0x4b0cab`). Every frame sets `[node+0x94]` on every node
/// in the scene list `[0xca7d70]` (`0x698a07`) and clears it only for a node that passes the
/// frustum test `0x682ef0` and the horizon test `0x686000` (`0x6833dd`-`0x6833ec`, and
/// `0x68359b`-`0x6835aa` in WMO groups). Here it is any of the unit's meshes passing last frame's
/// visibility check; benilla has no horizon cull yet, so that is the frustum verdict alone.
fn speaker_drawn(
unit: Entity,
children: &Query<&Children>,
meshes: &Query<&ViewVisibility, With<Mesh3d>>,
) -> bool {
children
.get(unit)
.is_ok_and(|kids| kids.iter().any(|c| meshes.get(c).is_ok_and(|v| v.get())))
}
/// The live bubbles by speaker guid, at most one per unit, their stacking, and the next line's
/// number.
#[derive(Resource, Default)]
@@ -419,8 +404,8 @@ fn drive_bubbles(
time: Res<Time>,
window: Query<&Window, With<bevy::window::PrimaryWindow>>,
mut feed: ResMut<BubbleFeed>,
// The speakers' meshes and their last-frame visibility, for [`speaker_drawn`].
drawn: (Query<&Children>, Query<&ViewVisibility, With<Mesh3d>>),
// Whether the last render drew each speaker (`0x6704c0`, read at `0x4b0cab`).
drawn: crate::entities::SceneDrawn,
) {
active.0.clear();
feed.states.clear();
@@ -498,8 +483,8 @@ fn drive_bubbles(
let (Some((entity, _, tf)), Some(s)) = (find(*guid), self_tf) else {
return false;
};
let in_range = speaker_drawn(entity, &drawn.0, &drawn.1)
&& (tf.translation - s.translation).length_squared() < MAX_DIST_SQ;
let in_range =
drawn.unit(entity) && (tf.translation - s.translation).length_squared() < MAX_DIST_SQ;
b.fade.tick(now, in_range, b.born, b.duration)
});
+4
View File
@@ -59,6 +59,10 @@ use live_display::{refresh_live_display, tick_scale_ease};
/// Terrain conform: a model flagged `GlobalModelFlags & 3 ∈ {1,3}` tilts to the ground.
mod conform;
/// Whether the last render drew a unit, the scene-node test the bubble and plate gates read.
mod scene_drawn;
pub(crate) use scene_drawn::SceneDrawn;
/// The per-unit collision height, the `h` the swim, wade, splash and foam depths are fractions of.
mod collision_height;
use collision_height::stamp_collision_heights;
@@ -0,0 +1,28 @@
//! Whether the scene drew a unit in the last render: the reference's scene-node test `0x6704c0`
//! (`node && [node+0x94] == 0`), which the chat bubble (`0x4b0cab`) and the plate gate
//! (`0x60f649`) both read off the unit's scene node `[unit+0xe0]`.
use bevy::ecs::system::SystemParam;
use bevy::prelude::*;
/// A unit's meshes and their last-frame visibility. Every frame sets `[node+0x94]` on every node
/// in the scene list `[0xca7d70]` (`0x698a07`) and clears it only for a node that passes the
/// frustum test `0x682ef0` and the horizon test `0x686000` (`0x6833dd`-`0x6833ec`, and
/// `0x68359b`-`0x6835aa` in WMO groups). Here that is any of the unit's meshes passing last
/// frame's visibility check, the frustum and the indoor portal walk; benilla has no horizon cull
/// yet, and a unit with no model yet has no node.
#[derive(SystemParam)]
pub(crate) struct SceneDrawn<'w, 's> {
children: Query<'w, 's, &'static Children>,
meshes: Query<'w, 's, &'static ViewVisibility, With<Mesh3d>>,
}
impl SceneDrawn<'_, '_> {
/// Whether the last render drew any of `unit`'s meshes.
pub(crate) fn unit(&self, unit: Entity) -> bool {
self.children.get(unit).is_ok_and(|kids| {
kids.iter()
.any(|c| self.meshes.get(c).is_ok_and(|v| v.get()))
})
}
}
+117 -16
View File
@@ -16,7 +16,7 @@ use crate::names::NameCache;
use crate::net::{GuidIndex, NetEntity, ObjectStore};
use crate::ui_pass::{UiQuad, UiQuads, UvRect};
use super::{group_positions, BlipCtx, MinimapBlipHover, TrackedCandidates, BLIP_BASIS_PX};
use super::{group_records, BlipCtx, MinimapBlipHover, TrackedCandidates, BLIP_BASIS_PX};
/// The quest dot's quad, 8 px (`0xbc82a8`, frozen by the ctor); the per-cell scale table
/// `{1,1,1,1,1.3}` scales only the party cell 4.
@@ -260,9 +260,13 @@ enum DotName {
}
/// The party and pet dots, the in-range half of the party placement `0x6dad10`: blue cell 4 at
/// 1.3× for each of the five [`group_positions`] records within 0.8 of the radius
/// 1.3× for each of the five [`group_records`] records within 0.8 of the radius
/// (`0x4ed6b0`-`0x4ed7a7`), drawn last in the map's own layer (`0x4ed7b7`), under every arrow
/// child.
/// child. The probe names each record under the cursor by its guid, never grey (the dot's
/// `+0x10` is 0, `0x4ed740`): its dot in category 4 (`0x4eb2fa`-`0x4eb33c`), else its arrow frame
/// (`0x4eb42d`-`0x4eb4a9`), whose name is the member's cache entry or the pet's unit name
/// (`0x6daeee`-`0x6daf26`).
#[allow(clippy::too_many_arguments)] // the shared blip inputs plus the hover out
pub(in crate::minimap) fn emit_party_dots(
ctx: &BlipCtx,
group: &crate::ui_party::GroupState,
@@ -271,26 +275,34 @@ pub(in crate::minimap) fn emit_party_dots(
pet: Option<u64>,
icons: &Handle<Image>,
quads: &mut UiQuads,
hover: &mut MinimapBlipHover,
) {
for (x, y) in group_positions(group, guids, unit_pos, pet)
for (guid, (x, y)) in group_records(group, guids, unit_pos, pet)
.into_iter()
.flatten()
{
let d = ((x - ctx.wx).powi(2) + (y - ctx.wy).powi(2)).sqrt();
if d / ctx.radius_yd > super::BLIP_EDGE_RATIO {
continue; // out of range: the arrow pass drew it
}
quads.overlays.push(UiQuad {
rect: Rect::from_center_size(
let rect = if d / ctx.radius_yd > super::BLIP_EDGE_RATIO {
// Out of range: the arrow child draws it; only its frame is hit-tested here.
super::rim_arrow_rect(ctx, [x, y, 0.0])
} else {
let rect = Rect::from_center_size(
ctx.center + ctx.offset([x, y, 0.0]),
Vec2::splat(ctx.side * (PARTY_DOT_PX / BLIP_BASIS_PX)),
),
z_key: ctx.z,
texture: Some(icons.clone()),
uv: UvRect::from_tex_coords(PARTY_DOT_CELL),
color: [1.0, 1.0, 1.0, ctx.alpha],
..default()
});
);
quads.overlays.push(UiQuad {
rect,
z_key: ctx.z,
texture: Some(icons.clone()),
uv: UvRect::from_tex_coords(PARTY_DOT_CELL),
color: [1.0, 1.0, 1.0, ctx.alpha],
..default()
});
rect
};
if ctx.cursor.is_some_and(|c| rect.contains(c)) {
*hover = MinimapBlipHover::Npc(guid, false);
}
}
}
@@ -428,6 +440,7 @@ mod tests {
pet,
&Handle::default(),
&mut quads,
&mut MinimapBlipHover::None,
);
quads
.overlays
@@ -460,6 +473,94 @@ mod tests {
assert!(dots(&mut world, None).is_empty(), "no pet");
}
/// The probe names the party and pet blips under the cursor: an in-range dot of category 4
/// by its guid (`0x4eb2fa`-`0x4eb33c`), through the object's name method else the name cache,
/// and a rim arrow through the five group arrow frames (`0x4eb42d`-`0x4eb4a9`), by its
/// record's name, the member's cache entry or the pet's unit name (`0x6daeee`-`0x6daf26`).
/// Neither draws grey (the dot record's `+0x10` is 0, `0x4ed740`).
#[test]
fn party_and_pet_dots_and_arrows_hover_by_guid() {
use bevy::ecs::system::RunSystemOnce;
const MEMBER: u64 = 0x51;
const PET: u64 = 0xF140;
let mut world = World::new();
let unit = |w: [f32; 3]| {
(
NetEntity {
kind: EntityKind::Unit,
display_id: None,
scale: 1.0,
},
GlobalTransform::from_translation(benilla_assets::coords::wow_to_bevy(w)),
)
};
// The member 50 yd north, in range; the pet 120 yd west, past 0.8 of 133.
let member = world.spawn(unit([50.0, 0.0, 0.0])).id();
let pet = world.spawn(unit([0.0, 120.0, 0.0])).id();
let mut guids = GuidIndex::default();
guids.0.extend([(MEMBER, member), (PET, pet)]);
world.insert_resource(guids);
let mut group = crate::ui_party::GroupState::default();
let entry = |guid: u64, name: &str| benilla_protocol::messages::GroupMemberEntry {
name: name.into(),
guid,
status: 1,
flags: 0,
};
group.apply_list(0, 0, vec![entry(MEMBER, "Aldwyn")], MEMBER, None, None);
world.insert_resource(group);
let ctx = |cursor: Vec2| BlipCtx {
center: Vec2::ZERO,
side: BLIP_BASIS_PX,
px_per_yd: BLIP_BASIS_PX * 0.5 / 133.0,
radius_yd: 133.0,
z: 0,
alpha: 1.0,
wx: 0.0,
wy: 0.0,
wz: 0.0,
cursor: Some(cursor),
};
let hover = |world: &mut World, cursor: Vec2| {
world
.run_system_once(
move |q: Query<&GlobalTransform, With<NetEntity>>,
guids: Res<GuidIndex>,
group: Res<crate::ui_party::GroupState>| {
let ctx = ctx(cursor);
let mut quads = UiQuads::default();
let mut hover = MinimapBlipHover::None;
emit_party_dots(
&ctx,
&group,
&guids,
&q,
Some(PET),
&Handle::default(),
&mut quads,
&mut hover,
);
match hover {
MinimapBlipHover::Npc(guid, grey) => Some((guid, grey)),
_ => None,
}
},
)
.unwrap()
};
// The member's dot, north (up): offset (0, -50 · px_per_yd).
let dot = Vec2::new(0.0, -50.0 * BLIP_BASIS_PX * 0.5 / 133.0);
assert_eq!(hover(&mut world, dot), Some((MEMBER, false)), "the dot");
// The pet's arrow on the 0.8 rim toward the west (left).
let arrow = Vec2::new(-BLIP_BASIS_PX * 0.5 * super::super::BLIP_EDGE_RATIO, 0.0);
assert_eq!(hover(&mut world, arrow), Some((PET, false)), "the arrow");
assert_eq!(
hover(&mut world, Vec2::new(0.0, 30.0)),
None,
"south of us: neither"
);
}
/// Status 6 draws nothing on the 1.12 client despite vmangos's "red dot" comment (`0x4eac31`).
#[test]
fn quest_dot_is_status_seven_only_gold_cell_three() {
+22 -21
View File
@@ -289,7 +289,8 @@ pub(super) fn emit_landmarks(
}
}
/// A rim arrow's square on the 0.8 rim toward its target, for the hover test.
/// A rim arrow's square on the 0.8 rim toward its target, for the hover test: the probe tests the
/// landmark and the group arrow frames alike (`0x4eb3b0`, `0x4eb433`).
fn rim_arrow_rect(ctx: &BlipCtx, target: [f32; 3]) -> Rect {
let dir = ctx.offset(target).normalize_or_zero();
let pos = ctx.center + dir * (ctx.side * 0.5 * BLIP_EDGE_RATIO);
@@ -352,32 +353,30 @@ pub(crate) fn party_member_pos<F: bevy::ecs::query::QueryFilter>(
.map(|(x, y)| (f32::from(x), f32::from(y)))
}
/// The five group records' positions of the party placement `0x6dad10`: slots 0 to 3 the party
/// members, slot 4 the pet, our charm else our summon (`0x6dad60`–`0x6dad9c`), each fetched as a
/// unit (`0x6dadc8`); a member that is not streamed falls back to its party-stats position, the
/// pet to nothing (`0x6dae25`).
pub(super) fn group_positions<F: bevy::ecs::query::QueryFilter>(
/// The five group records of the party placement `0x6dad10`, each its guid (record `+0`) and
/// position: slots 0 to 3 the party members, slot 4 the pet, our charm else our summon
/// (`0x6dad60`–`0x6dad9c`), each fetched as a unit (`0x6dadc8`); a member that is not streamed
/// falls back to its party-stats position, the pet to nothing (`0x6dae25`).
pub(super) fn group_records<F: bevy::ecs::query::QueryFilter>(
group: &crate::ui_party::GroupState,
guids: &GuidIndex,
unit_pos: &Query<&GlobalTransform, F>,
pet: Option<u64>,
) -> [Option<(f32, f32)>; benilla_ui::widget::MINIMAP_GROUP_ARROWS] {
) -> [Option<(u64, (f32, f32))>; benilla_ui::widget::MINIMAP_GROUP_ARROWS] {
let mut records = [None; benilla_ui::widget::MINIMAP_GROUP_ARROWS];
for (i, m) in group.party_slots().enumerate().take(4) {
records[i] = party_member_pos(m, group, guids, unit_pos);
records[i] = party_member_pos(m, group, guids, unit_pos).map(|p| (m.guid, p));
}
records[4] = pet
.and_then(|g| guids.0.get(&g))
.and_then(|e| unit_pos.get(*e).ok())
.map(|tf| {
let w = bevy_to_wow(tf.translation());
(w[0], w[1])
});
records[4] = pet.and_then(|g| {
let tf = unit_pos.get(*guids.0.get(&g)?).ok()?;
let w = bevy_to_wow(tf.translation());
Some((g, (w[0], w[1])))
});
records
}
/// The party and pet arrow frames' bearings, the out-of-range half of the placement: beyond 0.8
/// of the radius a [`group_positions`] record has an arrow at its bearing (`0x6daf5c`–`0x6daf7f`).
/// of the radius a [`group_records`] record has an arrow at its bearing (`0x6daf5c`–`0x6daf7f`).
pub(super) fn group_arrow_records<F: bevy::ecs::query::QueryFilter>(
wx: f32,
wy: f32,
@@ -387,11 +386,13 @@ pub(super) fn group_arrow_records<F: bevy::ecs::query::QueryFilter>(
unit_pos: &Query<&GlobalTransform, F>,
pet: Option<u64>,
) -> [Option<f32>; benilla_ui::widget::MINIMAP_GROUP_ARROWS] {
group_positions(group, guids, unit_pos, pet).map(|pos| {
pos.filter(|&(x, y)| {
((x - wx).powi(2) + (y - wy).powi(2)).sqrt() / radius_yd > BLIP_EDGE_RATIO
})
.map(|(x, y)| bearing(wx, wy, x, y))
group_records(group, guids, unit_pos, pet).map(|record| {
record
.map(|(_, pos)| pos)
.filter(|&(x, y)| {
((x - wx).powi(2) + (y - wy).powi(2)).sqrt() / radius_yd > BLIP_EDGE_RATIO
})
.map(|(x, y)| bearing(wx, wy, x, y))
})
}
+119 -19
View File
@@ -1,5 +1,6 @@
//! The WMO-interior minimap's group selection (the portal flood-fill) and tile-name stem.
use bevy::ecs::entity::Entity;
use bevy::math::{Affine3A, Vec3};
use benilla_assets::coords::{bevy_to_wow, wow_to_bevy};
@@ -36,18 +37,78 @@ fn interior_window(p: [f32; 3], c: f32) -> ([f32; 3], [f32; 3]) {
([x, y, z], [x + c, y + c, c * 0.5 + z])
}
/// The interior window as its last rebuild stored it (`0xcea9c4`-`0xcea9d8`), what the rebuild
/// keyed on, and the groups its flood chose, which draw until the next rebuild.
pub(super) struct InteriorWindow {
/// The WMO instance the player is in (the pair `0xceaa68`/`0xceaa64`).
instance: Entity,
/// The player's group (`0x86f6a0`).
group: usize,
/// The zoom radius `c`; a zoom change sets the dirty bit (`SetZoomIndex`, `0x6da915`).
radius: f32,
min: [f32; 3],
max: [f32; 3],
drawable: Vec<bool>,
}
impl InteriorWindow {
/// Whether `UpdateMinimap` keeps the window (`0x6d95f0`): no change of instance (`0x6d94ef`)
/// or group (`0x6d9523`), no dirty bit, and x and y strictly inside the window's x/y bounds
/// (`0x6d952c`-`0x6d9579`). Nothing compares z, so a climb inside one cell and one group keeps
/// the window's z range, and the flood's box floor, as stored.
fn holds(&self, instance: Entity, group: usize, radius: f32, p: [f32; 3]) -> bool {
self.instance == instance
&& self.group == group
&& self.radius == radius
&& p[0] > self.min[0]
&& p[0] < self.max[0]
&& p[1] > self.min[1]
&& p[1] < self.max[1]
}
}
/// The groups the interior minimap draws, per absolute group index: the stored window's flood,
/// rebuilt from the player's position (`0x6d95f8`-`0x6d96ab`) only when [`InteriorWindow::holds`]
/// fails.
pub(super) fn interior_drawable<'a>(
stored: &'a mut Option<InteriorWindow>,
model: &WmoModel,
world_from_local: &Affine3A,
instance: Entity,
player_pos: Vec3,
radius: f32,
seed: usize,
) -> &'a [bool] {
let p = bevy_to_wow(player_pos);
if !stored
.as_ref()
.is_some_and(|w| w.holds(instance, seed, radius, p))
{
let (min, max) = interior_window(p, radius);
*stored = Some(InteriorWindow {
instance,
group: seed,
radius,
min,
max,
drawable: interior_group_selection(model, world_from_local, (min, max), radius, seed),
});
}
stored.as_ref().map_or(&[], |w| &w.drawable)
}
/// Which groups' tiles draw, per absolute group index: the reference's portal flood-fill from the
/// player's group (`0x6a5020`) inside the query box.
/// player's group (`0x6a5020`) inside the query box of the stored `window`.
///
/// The box is [`interior_window`] grown by `c` on every side (`0x6d96b6`-`0x6d96f3`), moved into
/// the model frame as the AABB of its image (`0x6dc540`), its top z then replaced by the seed
/// group's ceiling (`0x6a524b`, the group's `+0x28`). A group whose bbox misses the box in XY
/// neither emits nor floods onward (`0x6a51f4`); there is no per-group Z test. A portal is crossed
/// unless its polygon lies wholly outside one of the box's six planes, the only Z gate.
pub(super) fn interior_group_selection(
fn interior_group_selection(
model: &WmoModel,
world_from_local: &Affine3A,
player_pos: Vec3,
window: ([f32; 3], [f32; 3]),
radius: f32,
seed: usize,
) -> Vec<bool> {
@@ -57,8 +118,7 @@ pub(super) fn interior_group_selection(
return drawable;
}
let c = radius;
let (wmin, wmax) = interior_window(bevy_to_wow(player_pos), c);
let (wmin, wmax) = (wmin.map(|v| v - c), wmax.map(|v| v + c));
let (wmin, wmax) = (window.0.map(|v| v - c), window.1.map(|v| v + c));
// A world point (WoW axes) to the model frame, where the reference floods.
let local_from_world = world_from_local.inverse();
@@ -145,14 +205,61 @@ pub(super) fn interior_group_selection(
#[cfg(test)]
mod tests {
use benilla_assets::WmoModel;
use bevy::math::{Affine3A, Vec3};
/// The flood of the window a rebuild at `pos` stores, the model at the origin.
fn select(model: &WmoModel, pos: Vec3, c: f32, seed: usize) -> Vec<bool> {
let window = super::interior_window(benilla_assets::coords::bevy_to_wow(pos), c);
super::interior_group_selection(model, &Affine3A::IDENTITY, window, c, seed)
}
/// `UpdateMinimap` rebuilds the window only on a change of instance or group, the dirty bit
/// or x/y leaving the window (`0x6d952c`-`0x6d9579`); z is never compared, so climbing in one
/// cell and one group floods from the stored box floor `pz − 1.5c`, not the player's.
#[test]
fn a_climb_in_one_cell_keeps_the_stored_window() {
use super::interior_drawable;
use benilla_assets::coords::wow_to_bevy;
use bevy::ecs::entity::Entity;
// A 60-yd tall seed and a neighbour through a portal at z −40, below the box floor
// −37.5 of a rebuild at z 0 with `c` 25, above the floor −47.5 of one at z −10.
let model = two_groups(60.0, [-5.0, 5.0], 0.0, -40.0);
let instance = Entity::from_raw_u32(1).unwrap();
let at = |stored: &mut Option<super::InteriorWindow>, p: [f32; 3], c: f32| {
interior_drawable(
stored,
&model,
&Affine3A::IDENTITY,
instance,
wow_to_bevy(p),
c,
0,
)[1]
};
let mut stored = None;
assert!(!at(&mut stored, [1.0, 1.0, 0.0], 25.0), "rebuilt at z 0");
assert!(
!at(&mut stored, [1.0, 1.0, -10.0], 25.0),
"10 yd lower in the same cell: the window's z stays"
);
assert!(
at(&mut stored, [1.0, 1.0, -10.0], 25.5),
"a zoom change rebuilds at the current height"
);
let mut stored = None;
at(&mut stored, [1.0, 1.0, 0.0], 25.0);
assert!(
at(&mut stored, [-1.0, 1.0, -10.0], 25.0),
"x leaving the cell rebuilds at the current height"
);
}
/// A 4-group building: g0 (the player's) and g1 (a cellar) join by a floor hole and both draw;
/// g2 sits 1000 yd off in XY, reached but not drawn; g3 overlaps the box but is reachable only
/// through g2, by a portal inside the box, so only g2's XY gate keeps it out (`0x6a51f4`).
#[test]
fn interior_flood_fill_gates_on_xy_and_blocks_recursion_through_a_missed_group() {
use super::interior_group_selection;
use benilla_assets::{WmoGroupNav, WmoModel, WmoPortalInfo, WmoPortalRef};
use bevy::math::{Affine3A, Vec3};
let nav = |zmin: f32, zmax: f32, x: f32, ref_start: u16, ref_count: u16| WmoGroupNav {
flags: 0,
@@ -234,7 +341,7 @@ mod tests {
convex_volume: Vec::new(),
};
let drawable = interior_group_selection(&model, &Affine3A::IDENTITY, Vec3::ZERO, 25.0, 0);
let drawable = select(&model, Vec3::ZERO, 25.0, 0);
assert!(drawable[0], "the player's own group draws");
assert!(
drawable[1],
@@ -254,9 +361,7 @@ mod tests {
/// crossed.
#[test]
fn interior_flood_fill_rejects_a_portal_outside_the_query_box_z_extent() {
use super::interior_group_selection;
use benilla_assets::{WmoGroupNav, WmoModel, WmoPortalInfo, WmoPortalRef};
use bevy::math::{Affine3A, Vec3};
let nav = |zmin: f32, zmax: f32, ref_start: u16, ref_count: u16| WmoGroupNav {
flags: 0,
@@ -323,7 +428,7 @@ mod tests {
convex_volume: Vec::new(),
};
let drawable = interior_group_selection(&model, &Affine3A::IDENTITY, Vec3::ZERO, 25.0, 0);
let drawable = select(&model, Vec3::ZERO, 25.0, 0);
assert!(drawable[0]);
assert!(
!drawable[1],
@@ -388,11 +493,9 @@ mod tests {
/// `[−25, 50]`, so a group 30 yd west misses it and one 40 yd east is inside.
#[test]
fn the_query_window_is_the_snapped_cell_grown_by_its_width() {
use super::interior_group_selection;
use bevy::math::{Affine3A, Vec3};
let at = |g1_x: [f32; 2], portal_x: f32| {
let model = two_groups(3.0, g1_x, portal_x, 1.0);
interior_group_selection(&model, &Affine3A::IDENTITY, Vec3::ZERO, 25.0, 0)[1]
select(&model, Vec3::ZERO, 25.0, 0)[1]
};
assert!(
!at([-45.0, -30.0], -4.0),
@@ -406,9 +509,8 @@ mod tests {
assert!(!at([51.0, 60.0], 4.0), "past it");
// At x = 30 the cell is [25, 50], so the window is [0, 75].
let model = two_groups(3.0, [-12.0, -1.0], -4.0, 1.0);
let west = interior_group_selection(
let west = select(
&model,
&Affine3A::IDENTITY,
benilla_assets::coords::wow_to_bevy([30.0, 0.0, 0.0]),
25.0,
0,
@@ -424,11 +526,9 @@ mod tests {
/// under a low ceiling a portal above it is not.
#[test]
fn the_flood_box_tops_out_at_the_seed_groups_ceiling() {
use super::interior_group_selection;
use bevy::math::{Affine3A, Vec3};
let crossed = |seed_top: f32, portal_z: f32| {
let model = two_groups(seed_top, [-5.0, 5.0], 0.0, portal_z);
interior_group_selection(&model, &Affine3A::IDENTITY, Vec3::ZERO, 25.0, 0)[1]
select(&model, Vec3::ZERO, 25.0, 0)[1]
};
assert!(
crossed(40.0, 35.0),
+30 -13
View File
@@ -29,7 +29,7 @@ use benilla_assets::minimap_grid::group_axis_grid;
use benilla_assets::WmoModel;
use benilla_formats::{tile_to_world, world_to_tile, MinimapTranslate};
use interior::{interior_group_selection, wmo_minimap_stem};
use interior::{interior_drawable, wmo_minimap_stem, InteriorWindow};
use benilla_ui::widget::{MinimapArt, MinimapArtSlot, MINIMAP_DEFAULT_ZOOM};
@@ -238,6 +238,9 @@ struct MinimapTileCache {
tiles: HashMap<(u32, u32), Option<Handle<Image>>>,
interior_stem: Option<String>,
interior: HashMap<(usize, u32, u32), Option<Handle<Image>>>,
/// The interior window and its flood as the last rebuild stored them; outdoors, none, as the
/// indoor edge sets the dirty bit (`0x6d95ab`).
interior_window: Option<InteriorWindow>,
}
/// Load the translate catalog and the minimap art once the patch chain is open.
@@ -316,18 +319,18 @@ fn setup_minimap(
/// the flood seed once the gate says indoors.
fn minimap_interior<'a>(
player: &Player,
instances: &Query<&WmoPortalInstance>,
instances: &Query<(Entity, &WmoPortalInstance)>,
wmos: &'a Assets<WmoModel>,
world: &benilla_world::world_point::WorldPoint,
asset_server: &AssetServer,
) -> Option<(Affine3A, &'a WmoModel, String, usize)> {
) -> Option<(Entity, Affine3A, &'a WmoModel, String, usize)> {
if !player.active || player.detached || world.area_interior().is_none() {
return None;
}
let eye = player.pos + Vec3::Y * INTERIOR_PROBE_HEIGHT;
// The down-ray races the terrain, as the zone tracker does: grass above a mine is not in it.
let terrain = world.terrain_height_under(eye);
instances.iter().find_map(|inst| {
instances.iter().find_map(|(entity, inst)| {
let model = wmos.get(&inst.handle)?;
if model.wmo_id == 0 {
return None;
@@ -339,7 +342,7 @@ fn minimap_interior<'a>(
let stem = asset_server
.get_path(inst.handle.id())
.and_then(|p| wmo_minimap_stem(&p.path().to_string_lossy()))?;
Some((inst.world_from_local, model, stem, in_group))
Some((entity, inst.world_from_local, model, stem, in_group))
})
}
@@ -353,7 +356,7 @@ fn emit_minimap(
catalog: Option<Res<MapCatalogRes>>,
player: Res<Player>,
lighting: Option<Res<benilla_world::lighting::WowLighting>>,
instances: Query<&WmoPortalInstance>,
instances: Query<(Entity, &WmoPortalInstance)>,
wmos: Res<Assets<WmoModel>>,
world: benilla_world::world_point::WorldPoint,
asset_server: Res<AssetServer>,
@@ -417,11 +420,15 @@ fn emit_minimap(
// For the dots' indoor test; the branch below consumes `interior`.
let player_indoors = interior.is_some();
if !player_indoors {
cache.interior_window = None;
}
let view_radius = view_radius_yd(zoom, inside_zoom, player_indoors);
if assets.tex(MinimapArtSlot::Mask).is_none() {
// An empty mask name leaves no texture, and the render returns at once (`0x4ec959`,
// `0x4ec968`): no tiles, and with no scale no landmarks, rim arrows or dots either.
} else if let Some((world_from_local, model, stem, in_group)) = interior {
} else if let Some((instance, world_from_local, model, stem, in_group)) = interior {
let cache = &mut *cache;
// Interior: the WMO's own per-group tiles, drawn white. They are baked in the model frame
// (north = model +X), so each sits at its model-space centre through the placement and the
// whole set turns by one placement yaw (`0x6da180`).
@@ -452,10 +459,18 @@ fn emit_minimap(
let rt_half = composite::RT_SIZE as f32 * 0.5;
composite.active = true;
// The portal flood-fill from the player's group (`0x6a5020`). Its query box uses the draw
// radius (`0x6d96b6`), so zooming in also tightens the box's Z extent.
let drawable =
interior_group_selection(model, &world_from_local, player.pos, radius, in_group);
// The portal flood-fill from the player's group (`0x6a5020`) in the stored window. Its
// query box uses the draw radius (`0x6d96b6`), so zooming in also tightens the box's Z
// extent.
let drawable = interior_drawable(
&mut cache.interior_window,
model,
&world_from_local,
instance,
player.pos,
radius,
in_group,
);
// Draw order (`0x4ebeb0`, keyed at `0x6d9e30`): ascending by `Zmidpoint − playerZ`, the
// player's own group keyed `FLT_MAX`, so it draws last and no storey covers the room.
let player_z = bevy_to_wow(world_from_local.inverse().transform_point3(player.pos))[2];
@@ -697,7 +712,9 @@ fn emit_minimap(
);
// The in-range party dots (blue cell 4, 1.3×), last.
let pet = me.and_then(|(s, _)| s.0.unit_pet_guid());
blips::emit_party_dots(ctx, &group, &guids, &unit_pos, pet, icons, &mut quads);
blips::emit_party_dots(
ctx, &group, &guids, &unit_pos, pet, icons, &mut quads, &mut hover,
);
}
}
*blip_hover = hover;
@@ -712,7 +729,7 @@ fn feed_minimap_inside(
mut hosted_vm: crate::script_calls::HostedVm,
world: benilla_world::world_point::WorldPoint,
player: Res<Player>,
instances: Query<&WmoPortalInstance>,
instances: Query<(Entity, &WmoPortalInstance)>,
wmos: Res<Assets<WmoModel>>,
asset_server: Res<AssetServer>,
mut inside_res: ResMut<MinimapInside>,
+4
View File
@@ -69,6 +69,9 @@ mod state;
pub(crate) mod step_probe;
mod swim;
mod view_subject;
/// A far-sight pose, for a test that seats the camera on another object.
#[cfg(test)]
pub(crate) use view_subject::RemoteView;
mod walk;
mod wire_in;
pub(crate) use wire_in::regain_control_on_arrival;
@@ -317,6 +320,7 @@ impl Plugin for PlayerPlugin {
app.init_resource::<camera_dynamics::CameraOptions>();
// Far sight resolves `PLAYER_FARSIGHT` to a pose before `control` seats the camera: a
// separate system, as `control` holds our `Transform` mutably and cannot read another's.
view_subject::register(app);
app.init_resource::<view_subject::ViewSubject>()
.init_resource::<view_subject::FarSight>()
.init_resource::<scoped_view::ScopedView>()
+98 -3
View File
@@ -6,8 +6,9 @@
//! the server with `CMSG_FAR_SIGHT`. vmangos defers the set by 400 ms
//! (`Player::ScheduleCameraUpdate`, `Player.cpp:19136`), so the subject has streamed first, and
//! sends the clear at once to every client in range (`DirectSendPublicValueUpdate`), so only our
//! [`SelfPlayer`] store is read; it never sends `SMSG_CLEAR_FAR_SIGHT_IMMEDIATE`. Mind Control
//! sets the same field (`SpellAuras.cpp:2975`).
//! [`SelfPlayer`] store is read; it never sends `SMSG_CLEAR_FAR_SIGHT_IMMEDIATE`, which another
//! server may, and which ends far sight at once ([`on_clear_far_sight`]). Mind Control sets the
//! same field (`SpellAuras.cpp:2975`).
use std::sync::{Mutex, PoisonError};
@@ -194,6 +195,35 @@ pub(super) fn publish_view_subject(
});
}
/// `SMSG_CLEAR_FAR_SIGHT_IMMEDIATE` (`0x20d`): the handler's jump table (`0x5e417e`, entry 5)
/// leads to `0x5e43f8`, which looks up the active player (`0x5e440e`) and runs `EndFarSight` on it
/// (`0x5ee590` at `0x5e441d`), reading no body. The field still names the object, so the view
/// stays home until it changes.
fn on_clear_far_sight(
In(ev): In<benilla_protocol::SessionEvent>,
far_sight: Res<FarSight>,
self_store: Query<&ObjectStore, With<SelfPlayer>>,
index: Res<GuidIndex>,
net: Res<NetCommands>,
) {
let (benilla_protocol::SessionEvent::FarSightCleared, Some(store)) =
(ev, self_store.iter().next())
else {
return;
};
let held = |guid: u64| index.0.contains_key(&guid);
far_sight.end(store.0.player_farsight(), held, &net);
}
/// The far-sight packet's handler.
pub(super) fn register(app: &mut App) {
use crate::net::NetHandlerApp;
app.net_handler(
benilla_protocol::SessionEventKind::FarSightCleared,
on_clear_far_sight,
);
}
#[cfg(test)]
mod tests {
use super::*;
@@ -302,7 +332,7 @@ mod tests {
app.update();
assert!(
app.world().resource::<ViewSubject>().remote.is_none(),
"a zeroed field is the ONLY teardown signal there is — no CLEAR_FAR_SIGHT_IMMEDIATE"
"a zeroed field is vmangos's teardown signal: it sends no CLEAR_FAR_SIGHT_IMMEDIATE"
);
assert_eq!(votes(&rx), [false], "and the release votes 0, once");
}
@@ -404,4 +434,69 @@ mod tests {
);
assert_eq!(publish(&mut app), Some(totem));
}
/// `SMSG_CLEAR_FAR_SIGHT_IMMEDIATE` (`0x20d`) leads through the handler's jump table
/// (`0x5e417e`, entry 5) to `0x5e43f8`, which runs `EndFarSight` (`0x5ee590`) on the active
/// player, the body unread: with far sight on, `CMSG_FAR_SIGHT` 0 and the camera back on the
/// player at once, though the field still names the object; with it off, nothing.
#[test]
fn the_clear_far_sight_packet_ends_the_view_at_once() {
const EYE: u64 = 0xF130_0000_0000_0043;
const FARSIGHT: u16 = 712;
let (tx, rx) = crossbeam_channel::unbounded();
let mut app = crate::game_plugins::schedule_tests::headless_client_unrun();
app.insert_resource(NetCommands(tx));
let eye = app
.world_mut()
.spawn(Transform::from_xyz(50.0, 0.0, 0.0))
.id();
app.world_mut()
.resource_mut::<GuidIndex>()
.0
.insert(EYE, eye);
app.world_mut().spawn((
SelfPlayer,
Transform::default(),
ObjectStore(benilla_protocol::ObjectFields::from_pairs(&[
(FARSIGHT, EYE as u32),
(FARSIGHT + 1, (EYE >> 32) as u32),
])),
));
let votes = |rx: &crossbeam_channel::Receiver<ClientCommand>| -> Vec<bool> {
rx.try_iter()
.filter_map(|c| match c {
ClientCommand::FarSight { engage } => Some(engage),
_ => None,
})
.collect()
};
let publish = |app: &mut App| {
app.world_mut()
.run_system_cached(publish_view_subject)
.unwrap();
app.world()
.resource::<ViewSubject>()
.remote
.map(|r| r.entity)
};
let clear = |app: &mut App| {
crate::net::handlers::dispatch(
app.world_mut(),
vec![benilla_protocol::SessionEvent::FarSightCleared],
);
};
assert_eq!(publish(&mut app), Some(eye));
assert_eq!(votes(&rx), [true]);
clear(&mut app);
assert_eq!(votes(&rx), [false], "the server is told at once");
assert_eq!(publish(&mut app), None, "the camera is back on the player");
assert_eq!(
publish(&mut app),
None,
"and stays there while the field still names the object"
);
clear(&mut app);
assert!(votes(&rx).is_empty(), "with far sight off, nothing");
}
}
+128 -16
View File
@@ -18,45 +18,57 @@ use crate::ui_script::PointerOverUi;
use benilla_world::billboard::BillboardCard;
use benilla_world::collision::PickOccluder;
use benilla_world::interact::{
ray_mesh_bounds, ray_posed_mesh, CreaturePickPart, GoPickPart, PickParts,
ray_mesh_bounds, ray_posed_mesh, CreaturePickPart, DoodadOccluders, GoPickPart, PickParts,
};
use benilla_world::view::WorldCamera;
use super::{Hovered, HoveredObject, PickOcclusion};
/// Trace this frame's world hit, the reference's `CWorld::Intersect` leg of the scene trace
/// (`0x480df0`), through the [`PickOccluder`] set: terrain, the WMO walk-bake faces (about the
/// `0x84` reject mask) and static doodad hulls. Net entities are the object trace, not occluders,
/// so a chest never occludes itself. The picks run unbounded and compare against it after.
/// (`0x480df0`, mask `0x1000114`): the [`PickOccluder`] colliders, terrain and the WMO walk-bake
/// faces (about the `0x84` reject mask), and the static doodads' drawn opaque batches
/// ([`DoodadOccluders`]), never their collision hulls. Net entities are the object trace, not
/// occluders, so a chest never occludes itself. The picks run unbounded and compare against it
/// after.
pub(super) fn update_pick_occlusion(
camera: Query<(&Camera, &GlobalTransform), With<WorldCamera>>,
window: Query<&Window, With<PrimaryWindow>>,
spatial: avian3d::prelude::SpatialQuery,
occluders: Query<(), With<PickOccluder>>,
doodads: DoodadOccluders,
mut occlusion: ResMut<PickOcclusion>,
) {
*occlusion = PickOcclusion::default();
let (Ok((camera, cam_tf)), Ok(window)) = (camera.single(), window.single()) else {
return;
};
let Some(cursor) = window.cursor_position() else {
// A cursorless window traces from the hover probe's aim, as the picks do, which publish it
// after this runs: a resting aim is last frame's point.
let Some(cursor) = window.cursor_position().or_else(super::hover_probe::now) else {
return;
};
let Ok(ray) = camera.viewport_to_world(cam_tf, cursor) else {
return;
};
occlusion.ray = Some(ray.direction);
if let Some(hit) = spatial.cast_ray_predicate(
ray.origin,
ray.direction,
f32::MAX,
true,
// The mask that reaches every `PickOccluder` collider; the marker picks the set within it.
&benilla_world::collision::WorldCollision::body_filter(),
&|e| occluders.contains(e),
) {
occlusion.distance = hit.distance;
occlusion.point = Some(ray.origin + *ray.direction * hit.distance);
let collider = spatial
.cast_ray_predicate(
ray.origin,
ray.direction,
f32::MAX,
true,
// The mask that reaches every `PickOccluder` collider; the marker picks the set within.
&benilla_world::collision::WorldCollision::body_filter(),
&|e| occluders.contains(e),
)
.map(|hit| hit.distance);
let nearest = match (collider, doodads.nearest(ray)) {
(Some(a), Some(b)) => Some(a.min(b)),
(a, b) => a.or(b),
};
if let Some(distance) = nearest {
occlusion.distance = distance;
occlusion.point = Some(ray.origin + *ray.direction * distance);
}
}
@@ -941,6 +953,106 @@ mod tests {
);
}
/// The world trace tests a static doodad's drawn opaque render mesh, never its collision
/// hull (`0x69cdb0` queues it in mode 2 under the mask `0x1000114`; mode 2 of `0x7089c0` tests
/// the skinned submeshes of blend 0). The plaque on Stormwind's cathedral fountain: along the
/// cursor ray the fountain's hull is at 3.909, nearer than the plaque at 3.943, and its opaque
/// mesh at 4.029, behind it; so the trace's hit is the mesh, and the plaque picks. A nearer
/// alpha-keyed batch and an undrawn opaque one do not occlude; terrain behind still does.
#[test]
fn a_doodad_occludes_the_pick_by_its_drawn_opaque_mesh_not_its_hull() {
use avian3d::prelude::{Collider, RigidBody};
use benilla_formats::{ModelBlend, RenderSubmesh};
use benilla_world::model_render::{ModelKind, ModelPart};
use bevy::camera::visibility::SetViewVisibility;
use bevy::camera::RenderTargetInfo;
use bevy::window::WindowResolution;
let mut app = App::new();
app.add_plugins((
MinimalPlugins,
bevy::transform::TransformPlugin,
bevy::asset::AssetPlugin::default(),
bevy::scene::ScenePlugin,
avian3d::prelude::PhysicsPlugins::new(bevy::app::PostUpdate),
));
app.init_asset::<Mesh>()
.init_resource::<benilla_world::collision::ColliderEpoch>()
.init_resource::<PickOcclusion>();
app.finish();
app.cleanup();
// The camera ten yards up +Z, looking down it, the cursor at the centre.
let mut camera = Camera::default();
camera.computed.clip_from_view = Mat4::perspective_infinite_reverse_rh(1.0, 1.0, 0.1);
camera.computed.target_info = Some(RenderTargetInfo {
physical_size: UVec2::splat(100),
scale_factor: 1.0,
});
let world = app.world_mut();
world.spawn((camera, Transform::from_xyz(0.0, 0.0, 10.0), WorldCamera));
let mut window = Window {
resolution: WindowResolution::new(100, 100),
..Default::default()
};
window.set_cursor_position(Some(Vec2::splat(50.0)));
world.spawn((window, PrimaryWindow));
// The ray starts on the near plane, 0.1 in front of the camera.
const EYE: f32 = 9.9;
// A slab facing the camera `d` yards along the ray: in WoW axes the plane x = 0, which
// bakes into Bevy's z = 0, moved to z = EYE - d.
let slab = |blend| {
std::sync::Arc::new(RenderSubmesh {
positions: vec![[0.0, -5.0, -5.0], [0.0, 5.0, -5.0], [0.0, 0.0, 5.0]],
indices: vec![0, 1, 2],
blend,
..Default::default()
})
};
let mut batch = |d: f32, blend, drawn: bool| {
let mut e = world.spawn((
benilla_world::interact::PickMesh(slab(blend)),
GlobalTransform::from_translation(Vec3::new(0.0, 0.0, EYE - d)),
ViewVisibility::HIDDEN,
ModelPart {
kind: ModelKind::Doodad,
blend,
},
));
// What the spawn marks a static doodad's batch of blend 0 with.
if blend == ModelBlend::Opaque {
e.insert(benilla_world::interact::PickOccluderPart);
}
if drawn {
e.get_mut::<ViewVisibility>().unwrap().set_visible();
}
};
batch(4.029, ModelBlend::Opaque, true);
batch(3.5, ModelBlend::AlphaTest, true);
batch(3.0, ModelBlend::Opaque, false);
// The fountain's hull, a static body with no occluder mark, as every doodad hull spawns.
world.spawn((
RigidBody::Static,
Collider::cuboid(4.0, 4.0, 0.2),
Transform::from_xyz(0.0, 0.0, EYE - 3.909 - 0.1),
));
// Terrain behind it all.
world.spawn((
RigidBody::Static,
Collider::cuboid(40.0, 40.0, 0.2),
Transform::from_xyz(0.0, 0.0, EYE - 12.0 - 0.1),
PickOccluder,
));
app.update();
app.world_mut()
.run_system_once(update_pick_occlusion)
.unwrap();
let distance = app.world().resource::<PickOcclusion>().distance;
assert!(
(distance - 4.029).abs() < 1e-3,
"the fountain's opaque mesh, behind the plaque at 3.943: {distance}"
);
}
/// The picker's inputs with a camera ten yards up the Z axis, looking down it through a
/// 100-pixel square with the cursor at its centre, over whatever stands at the origin.
fn pick_world() -> World {
+6 -1
View File
@@ -342,7 +342,12 @@ impl Plugin for TargetPlugin {
Update,
(
// The latch first, before any pick refresh clears what the press was over.
(latch_press_pick, hover::update_pick_occlusion).chain(),
// The trace reads the static world after this frame's stream reshapes it.
(
latch_press_pick,
hover::update_pick_occlusion.after(WorldStage::Stream),
)
.chain(),
hover::update_hover,
hover::update_hovered_object,
cursor_mode::classify_cursor,
+54 -5
View File
@@ -433,6 +433,13 @@ struct SelfWatch {
/// The hearthstone's item entry (`0x1b24`).
const HEARTHSTONE: u32 = 6948;
const INVTYPE_RANGED: u32 = 15;
/// The equipment-slot mask per inventory type 0 to 28 (`0x809200`): bit `n` is slot `n`. Types 0
/// (not equippable), 24 (ammo) and 27 (quiver) fit no slot.
const INVENTORY_SLOT_MASK: [u32; 29] = [
0, 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, 0xc00, 0x3000, 0x18000, 0x10000,
0x20000, 0x4000, 0x8000, 0x780000, 0x40000, 0x10, 0x8000, 0x10000, 0x10000, 0, 0x20000,
0x20000, 0, 0x20000,
];
const CLASS_HUNTER: u8 = 3;
/// The keyring bag and its slot band (`edi == 0xff`, slot ∈ [0x51, 0x70]).
const KEYRING_BAG: u8 = 0xff;
@@ -468,10 +475,9 @@ fn feed_tutorials(
}
// The item-received sites in the handler's order (`0x491cec`-`0x491ec9`): Backpack
// always; Using Items for an on-use spell; Equippable Items for any non-zero inventory
// type (the reference's 23-bit mask `0x809200` is not decoded); Bags for a container;
// Keyrings by the slot band; Hearthstones by entry; Ranged Weapons for a ranged type on a
// non-hunter.
// always; Using Items for an on-use spell; Equippable Items for an inventory type that
// fits a slot ([`INVENTORY_SLOT_MASK`]); Bags for a container; Keyrings by the slot band;
// Hearthstones by entry; Ranged Weapons for a ranged type on a non-hunter.
let pushes = std::mem::take(&mut tutorials.pushes);
let class = self_q.single().ok().and_then(|s| s.0.unit_class());
for (entry, bag, slot) in pushes {
@@ -481,7 +487,12 @@ fn feed_tutorials(
if info.is_some_and(|i| i.spells.iter().any(|s| s.trigger == 0)) {
tutorials.trigger(id::USING_ITEMS, 0, now);
}
if info.is_some_and(|i| i.inventory_type != 0) {
// A set bit among the first 23 of the type's slot mask (`0x491d23`-`0x491d3f`).
if info.is_some_and(|i| {
INVENTORY_SLOT_MASK
.get(i.inventory_type as usize)
.is_some_and(|m| m & 0x7f_ffff != 0)
}) {
tutorials.trigger(id::EQUIPPABLE_ITEMS, 0, now);
}
// Class 1, Container (`0x491d4f cmp [esi],1`).
@@ -1458,4 +1469,42 @@ mod tests {
app.update();
assert_eq!(seen(&mut app), [0x08, 0x09, 0x0a]);
}
/// Equippable Items fires on a set bit among the first 23 of the slot mask `0x809200`
/// indexed by the inventory type (`0x491d23`-`0x491d4a`). The mask is 0 for types 0, 24
/// (ammo) and 27 (quiver), so those raise no prompt; a bag (type 18, `0x780000`) does.
#[test]
fn equippable_items_reads_the_slot_mask_so_ammo_and_quivers_raise_none() {
let mut app = recording_feeder();
{
let mut items = app.world_mut().resource_mut::<crate::items::Items>();
for (entry, inventory_type) in [(1, 0), (2, 24), (3, 27), (4, 18)] {
items.insert_template(
entry,
Some(benilla_protocol::messages::ItemInfo {
inventory_type,
..crate::items::test_template("Item")
}),
);
}
}
{
let mut t = app.world().resource::<Tutorials>().lock();
t.item_received(1, 0, 23);
t.item_received(2, 0, 24);
t.item_received(3, 0, 25);
}
app.update();
assert_eq!(
seen(&mut app),
[0x08],
"only Backpack: no equippable prompt for types 0, 24 and 27"
);
app.world()
.resource::<Tutorials>()
.lock()
.item_received(4, 0, 26);
app.update();
assert_eq!(seen(&mut app), [0x08, 0x18], "a bag is worn in a bag slot");
}
}
+37 -14
View File
@@ -4,10 +4,11 @@
//!
//! - Toggles: the `[0xc4da34]` bitmask, bit 0 enemy and bit 3 friendly, both off at boot.
//! - Gate (`0x60f600`): never the camera's unit (`camera+0x88`, `0x60f68c`) or a `NOT_SELECTABLE`
//! one; enemy or friendly by `CanAttack` from the active player (`0x606980`), and a player
//! subject must also pass `CanCooperate` (equal faction-group masks); no friendly totem
//! (`0x60f757`); 20 yd from the camera's unit (`0x60f7b8`); no occlusion; a unit not projected
//! into view loses its plate.
//! one; only a unit the last render drew (`0x6704c0` at `0x60f649`, [`SceneDrawn`]); enemy or
//! friendly by `CanAttack` from the active player (`0x606980`), and a player subject must also
//! pass `CanCooperate` (equal faction-group masks); no friendly totem (`0x60f757`); 20 yd from
//! the camera's unit (`0x60f7b8`), and none at all when the camera's object is no unit
//! (`0x60f77c`); a unit not projected into view loses its plate.
//! - Anchor: the overhead head point (`0x608640`) plus 2/3 yd (`[0x80abfc]`), projected every
//! frame (`0x483ee0`), the plate's top centre on it (`0x509ec0`), sized in gx units of the
//! screen diagonal (`0x41ad10`), outside uiScale. Deviation: the basis is damped past
@@ -30,7 +31,7 @@ use benilla_ui::script::{
unit_is_grey, PlateGeometry, PlateState, PLATE_BIT_ENEMY, PLATE_BIT_FRIEND,
};
use crate::entities::{overhead_anchor, BoneAttach, OverheadFallback};
use crate::entities::{overhead_anchor, BoneAttach, OverheadFallback, SceneDrawn};
use crate::names::NameCache;
use crate::net::{Embodied, Guid, NetEntity, ObjectStore, SelfPlayer};
use crate::query_cache::Ask;
@@ -325,9 +326,12 @@ struct PlateWorld<'w, 's> {
),
>,
self_q: Query<'w, 's, Option<&'static ObjectStore>, With<SelfPlayer>>,
// The camera's unit (`0x4818f0`, its `+0x88` resolved at `0x60f67c`): the plates' centre and
// the one unit that never gets one. Our own body unless we are attached to another unit.
// The body we control: the camera's unit (`0x4818f0`, its `+0x88`) unless far sight moved the
// camera onto another object ([`crate::player::ViewSubject`]).
centre: Query<'w, 's, (Entity, &'static Transform), With<Embodied>>,
view: Res<'w, crate::player::ViewSubject>,
// Whether the last render drew each unit (`0x6704c0`).
drawn: SceneDrawn<'w, 's>,
relations: crate::target::RelationWorld<'w, 's>,
selection: Res<'w, Selection>,
// With `selection`, the highlight's pair: the watcher's globals `[0xb4e2c8]`/`[0xb4e2d8]`.
@@ -374,12 +378,26 @@ fn drive_vplates(
if !mode.enemies && !mode.friends {
return PlateStep::Retire;
}
// No camera unit (`0x60f685`) fails every unit at `0x60f77c`.
let (Ok((cam, cam_pose)), Ok(self_store), Ok((centre, centre_tf))) = (
world.camera.single(),
world.self_q.single(),
world.centre.single(),
) else {
// The camera's object (`[cam+0x88]`), resolved with the unit mask alone (`0x60f677`): the
// far-sight object while the camera follows one (`0x5ee483`, `0x5ee4ae`, whatever its
// type), else our body. No camera unit (`0x60f685`), or an object that is no unit, a Far
// Sight dynamic object, fails every unit at `0x60f77c`.
let centre = match world.view.remote {
Some(remote) => world
.units
.get(remote.entity)
.ok()
.filter(|(_, net, ..)| matches!(net.kind, EntityKind::Unit | EntityKind::Player))
.map(|(e, _, _, tf, _)| (e, tf.translation)),
None => world
.centre
.single()
.ok()
.map(|(e, tf)| (e, tf.translation)),
};
let (Ok((cam, cam_pose)), Ok(self_store), Some((centre, centre_pos))) =
(world.camera.single(), world.self_q.single(), centre)
else {
return PlateStep::Retire;
};
let Some(script) = script else {
@@ -453,8 +471,13 @@ fn drive_vplates(
if store.is_some_and(|s| s.0.unit_is_ghost_visual()) {
continue;
}
// The unit's scene node, drawn in the last render (`0x60f63b`-`0x60f650`): culled by
// the frustum, or with no model yet, it has no plate.
if !world.drawn.unit(entity) {
continue;
}
// Measured from the camera's unit (`0x60f780`-`0x60f7b8`).
if (tf.translation - centre_tf.translation).length_squared() > MAX_DIST_SQ {
if (tf.translation - centre_pos).length_squared() > MAX_DIST_SQ {
continue;
}
// A CREATEDBY owner, no SUMMONEDBY owner and flags bit 9 (`0x200`): no plate in either
@@ -82,9 +82,24 @@ fn plates_app() -> App {
.id();
world.resource_mut::<GuidIndex>().0.insert(ME, me);
world.resource_mut::<SelfGuid>().0 = Some(ME);
part(&mut app, me, true);
app
}
/// A mesh part under `unit`, drawn in the last render or not: the scene node's cull word
/// `[+0x94]` the gate reads through `0x6704c0`.
fn part(app: &mut App, unit: Entity, drawn: bool) -> Entity {
use bevy::camera::visibility::SetViewVisibility;
let world = app.world_mut();
let part = world
.spawn((Mesh3d::default(), ViewVisibility::HIDDEN, ChildOf(unit)))
.id();
if drawn {
world.get_mut::<ViewVisibility>(part).unwrap().set_visible();
}
part
}
/// A living creature `guid` at `at`, with `fields` over its health.
fn unit(app: &mut App, guid: u64, at: Vec3, fields: &[(u16, u32)]) -> Entity {
let mut pairs = vec![(2, 0x9), (HEALTH, 100), (MAX_HEALTH, 100)];
@@ -104,6 +119,7 @@ fn unit(app: &mut App, guid: u64, at: Vec3, fields: &[(u16, u32)]) -> Entity {
))
.id();
world.resource_mut::<GuidIndex>().0.insert(guid, e);
part(app, e, true);
e
}
@@ -250,9 +266,90 @@ fn an_unnamed_units_plate_reads_unknownobject() {
.resource_mut::<GuidIndex>()
.0
.insert(0x40, player);
part(&mut app, player, true);
assert_eq!(
plate_names(&mut app),
vec!["Unknown", "Unknown", "Wolf"],
"the unknown creature and the unknown player"
);
}
/// The gate needs the unit's scene node, and its cull word clear (`0x60f63b`-`0x60f650`): the
/// scene sets the word on every node each frame (`0x698a07`) and clears it only for a node it
/// draws (`0x6833dd`-`0x6833ec`). A unit outside last frame's render, or with no model yet, has
/// no plate though it is in range and projects into view.
#[test]
fn a_unit_the_scene_did_not_draw_last_frame_has_no_plate() {
let mut app = plates_app();
let drawn = unit(&mut app, mob(0x31), Vec3::X * 3.0, &[]);
let culled = unit(&mut app, mob(0x32), Vec3::X * 5.0, &[]);
let culled_part = app.world().entity(culled).get::<Children>().unwrap()[0];
app.world_mut()
.entity_mut(culled_part)
.insert(ViewVisibility::HIDDEN);
let modelless = unit(&mut app, mob(0x33), Vec3::X * 7.0, &[]);
let modelless_part = app.world().entity(modelless).get::<Children>().unwrap()[0];
app.world_mut().entity_mut(modelless_part).despawn();
assert_eq!(
plated(&mut app),
HashSet::from([drawn]),
"only the unit the last render drew"
);
// A second part drawn is enough: the node is the whole model.
part(&mut app, culled, true);
assert_eq!(plated(&mut app), HashSet::from([drawn, culled]));
}
/// Under far sight the camera follows the far-sight object whatever its type (`0x5ee483`,
/// `0x5ee4ae`), and the gate resolves the camera's GUID as a unit only (`0x60f677`): a unit
/// there is the centre of the 20 yards and has no plate, and our body is a candidate; a dynamic
/// object resolves to nothing and every plate fails (`0x60f77c`).
#[test]
fn far_sight_judges_plates_around_the_cameras_object() {
use crate::player::RemoteView;
let mut app = plates_app();
let me = app.world().resource::<GuidIndex>().0[&ME];
let near_me = unit(&mut app, mob(0x31), Vec3::new(-8.0, 0.0, 0.0), &[]);
let eye = unit(&mut app, mob(0x32), Vec3::new(14.0, 0.0, 0.0), &[]);
let near_eye = unit(&mut app, mob(0x33), Vec3::new(24.0, 0.0, 0.0), &[]);
let view = |app: &mut App, entity: Option<Entity>| {
app.world_mut()
.resource_mut::<crate::player::ViewSubject>()
.remote = entity.map(|entity| RemoteView {
entity,
feet: Vec3::ZERO,
pivot_height: 0.0,
});
};
view(&mut app, Some(eye));
assert_eq!(
plated(&mut app),
HashSet::from([me, near_eye]),
"around the viewed unit: our body and the unit within 20 yards of it, never itself"
);
let far_sight = app
.world_mut()
.spawn((
Guid(0xF110_0000_0000_0001),
NetEntity {
kind: EntityKind::DynamicObject,
display_id: None,
scale: 1.0,
},
Transform::from_xyz(14.0, 0.0, 0.0),
))
.id();
view(&mut app, Some(far_sight));
assert!(
plated(&mut app).is_empty(),
"a dynamic object is no unit: no plates at all"
);
view(&mut app, None);
assert_eq!(
plated(&mut app),
HashSet::from([near_me, eye]),
"home: around our body again"
);
}
@@ -113,6 +113,7 @@ const PUBLISHED: &[(&str, &str)] = &[
("frame_pace::FrameStep", "record"),
("instance_tint::InstanceTintMirrors", "record"),
("instance_tint::InstanceTints", "record"),
("interact::DoodadOccluders", "wall"),
("interact::PickMesh", "record"),
("interact::WorldObject", "record"),
("interact::WorldPick", "record"),
+3
View File
@@ -234,6 +234,9 @@ pub enum SessionEvent {
LogoutResponse { reason: u32, instant: bool },
/// The server dropped a pending logout at our `CMSG_LOGOUT_CANCEL` (`SMSG_LOGOUT_CANCEL_ACK`).
LogoutCancelled,
/// `SMSG_CLEAR_FAR_SIGHT_IMMEDIATE`: end far sight now (`0x5e43f8` runs `EndFarSight`
/// `0x5ee590` on the active player).
FarSightCleared,
/// The world session ended, and with [`SessionEnd::Lost`] the link with it; `reason` is
/// human-readable.
Disconnected { reason: String, end: SessionEnd },
@@ -46,6 +46,7 @@ pub fn decode(packet: ServerPacket) -> Vec<SessionEvent> {
vec![SessionEvent::LogoutResponse { reason, instant }]
}
ServerPacket::LogoutCancelAck => vec![SessionEvent::LogoutCancelled],
ServerPacket::ClearFarSightImmediate => vec![SessionEvent::FarSightCleared],
ServerPacket::PlaySound { sound_id } => vec![SessionEvent::PlaySound { sound_id }],
ServerPacket::PlayMusic { music_id } => vec![SessionEvent::PlayMusic { music_id }],
ServerPacket::PlayObjectSound { sound_id, guid } => {
@@ -468,6 +468,9 @@ pub const CMSG_MOVE_NOT_ACTIVE_MOVER: u16 = 0x02D1; // 721
/// body (`MiscHandler.cpp:1138-1155`). Sending 0 moves visibility home while the camera stays on
/// the object, so it must be deliberate; the server expects no reply.
pub const CMSG_FAR_SIGHT: u16 = 0x027A; // 634
/// End far sight now: empty body, the view back on the player (`0x5e43f8`). vmangos never sends
/// it; it clears `PLAYER_FARSIGHT` instead.
pub const SMSG_CLEAR_FAR_SIGHT_IMMEDIATE: u16 = 0x020D; // 525
/// Stop auto-repeat: empty body, sent from the local cancel (`0x6ea080`), so on every cancel.
pub const CMSG_CANCEL_AUTO_REPEAT_SPELL: u16 = 0x026D; // 621
@@ -956,6 +956,8 @@ pub enum ServerPacket {
},
/// `SMSG_LOGOUT_CANCEL_ACK` (empty): the logout was cancelled; it takes the countdown down.
LogoutCancelAck,
/// `SMSG_CLEAR_FAR_SIGHT_IMMEDIATE` (empty): end far sight on the active player (`0x5e43f8`).
ClearFarSightImmediate,
/// `SMSG_PONG`: our `CMSG_PING`'s sequence echoed back, timed for the round trip.
Pong {
sequence: u32,
@@ -1569,6 +1571,7 @@ impl ServerPacket {
ServerPacket::LogoutComplete => "SMSG_LOGOUT_COMPLETE".into(),
ServerPacket::LogoutResponse { .. } => "SMSG_LOGOUT_RESPONSE".into(),
ServerPacket::LogoutCancelAck => "SMSG_LOGOUT_CANCEL_ACK".into(),
ServerPacket::ClearFarSightImmediate => "SMSG_CLEAR_FAR_SIGHT_IMMEDIATE".into(),
ServerPacket::Pong { .. } => "SMSG_PONG".into(),
ServerPacket::ForceSpeedChange { kind, .. } => {
format!("SMSG_FORCE_{kind:?}_SPEED_CHANGE")
@@ -1339,6 +1339,7 @@ fn parse_server_body(
instant: read_u8(&mut r)? != 0,
},
opcode::SMSG_LOGOUT_CANCEL_ACK => ServerPacket::LogoutCancelAck,
opcode::SMSG_CLEAR_FAR_SIGHT_IMMEDIATE => ServerPacket::ClearFarSightImmediate,
opcode::SMSG_PONG => ServerPacket::Pong {
sequence: read_u32_le(&mut r)?,
},
@@ -1680,6 +1681,19 @@ fn parse_server_body(
mod tests {
use super::*;
/// `SMSG_CLEAR_FAR_SIGHT_IMMEDIATE` (`0x20d`) has a handler: its jump-table entry leads to
/// `0x5e43f8`, which ends far sight on the active player and reads no body.
#[test]
fn the_clear_far_sight_packet_decodes_to_its_event() {
let (packet, tail) = parse_server_with_tail(opcode::SMSG_CLEAR_FAR_SIGHT_IMMEDIATE, &[])
.expect("an empty body decodes");
assert_eq!(tail, 0);
assert!(matches!(
crate::events::decode(packet).as_slice(),
[crate::SessionEvent::FarSightCleared]
));
}
/// `SMSG_AUTH_RESPONSE` as vmangos writes its four shapes: the admitting `AUTH_OK` and the first
/// `AUTH_WAIT_QUEUE` with the billing group (`World.cpp:325-331`, `:374-381`), then the queue's
/// later positions and its closing `AUTH_OK` without (`WorldSession.cpp:961-976`).
+6 -4
View File
@@ -97,10 +97,12 @@ pub struct GroundDecalSurface;
/// Marks a static collider that occludes the mouse pick: the reference traces the world too and
/// drops the object hit when the world hit is strictly nearer (`0x480df0` at `0x480eb4`,
/// `CWorld::Intersect` `0x672170`, mask `0x1000114`), so a unit behind a wall is not hoverable.
/// Occluders are terrain (DDA `0x69c920`), WMO group faces outside MOPY reject mask `0x84` (here
/// the walk collider, which rejects only `0x04`: a `0x84` face set is not built) and static
/// default-set doodad hulls (`0x69cdb0`). Liquid (mask bits 16-19 off) is not, nor are unit and
/// server-spawned GameObject hulls, transports included: those are the object trace.
/// Occluder colliders are terrain (DDA `0x69c920`) and WMO group faces outside MOPY reject mask
/// `0x84` (here the walk collider, which rejects only `0x04`: a `0x84` face set is not built). A
/// static doodad occludes by its drawn opaque render batches, never its collision hull
/// (`0x69cdb0` queues it in mode 2, [`crate::interact::DoodadOccluders`]), so no doodad hull
/// carries this. Liquid (mask bits 16-19 off) is not an occluder, nor are unit and server-spawned
/// GameObject hulls, transports included: those are the object trace.
#[derive(Component)]
pub struct PickOccluder;
+91 -2
View File
@@ -14,12 +14,26 @@ use crate::model_render::ModelKind;
mod pick;
pub use pick::{
cast_object_ray, cast_pick_ray, cast_pick_ray_inflated, pick_at_cursor, pick_object_at_cursor,
ObjectHit, PickBlob, PickBox, PickMember, PickMesh, PickParts, PickSource,
cast_object_ray, cast_pick_ray, cast_pick_ray_inflated, occludes_pick, pick_at_cursor,
pick_object_at_cursor, ObjectHit, PickBlob, PickBox, PickMember, PickMesh, PickParts,
PickSource,
};
pub(crate) use pick::{ray_aabb, world_aabb};
pub use pick::{ray_member, ray_mesh_bounds, ray_posed_mesh, RayHit};
/// Marks a static doodad's drawn batch that occludes the mouse pick ([`occludes_pick`]): an
/// entity part of blend 0, so [`DoodadOccluders`] walks these alone, never every model part.
#[derive(Component, Clone, Copy)]
pub struct PickOccluderPart;
impl PickOccluderPart {
/// The marker for a static doodad's batch of `blend`, `None` for any other.
pub(crate) fn of(blend: benilla_formats::ModelBlend) -> Option<Self> {
(blend == benilla_formats::ModelBlend::Opaque).then_some(Self)
}
}
/// The identity of a pickable world thing, attached to its renderable mesh entities at spawn.
#[derive(Component, Clone, Debug)]
pub struct WorldObject {
@@ -115,6 +129,81 @@ impl WorldPick<'_, '_> {
}
}
/// The static doodads' drawn batches that occlude the mouse pick ([`occludes_pick`]), in every
/// lane that draws them: entity parts, the static merge's blobs and the retained pass. Only what
/// the last render drew: `0x7089c0` skips a model the scene has not animated this frame
/// (`0x708bd9`, instance `+0x40` against the scene's frame `+0x10`), and the scene animates what
/// it collects to draw. The collision hulls are no part of it.
#[derive(bevy::ecs::system::SystemParam)]
pub struct DoodadOccluders<'w, 's> {
#[allow(clippy::type_complexity)] // one query of the part's pick inputs
parts: Query<
'w,
's,
(
&'static PickMesh,
&'static GlobalTransform,
&'static ViewVisibility,
Option<&'static bevy::camera::primitives::Aabb>,
),
With<PickOccluderPart>,
>,
#[allow(clippy::type_complexity)] // one query of the blob's pick inputs
blobs: Query<
'w,
's,
(
&'static PickBlob,
&'static GlobalTransform,
&'static ViewVisibility,
Option<&'static bevy::camera::primitives::Aabb>,
),
>,
gx: Option<Res<'w, crate::static_gx::StaticGx>>,
}
impl DoodadOccluders<'_, '_> {
/// The distance along `ray` to the nearest occluding doodad batch.
pub fn nearest(&self, ray: Ray3d) -> Option<f32> {
let (origin, dir) = (ray.origin, *ray.direction);
let mut best: Option<f32> = None;
let beyond = |best: Option<f32>, entry: Option<f32>| match entry {
None => true,
Some(t) => best.is_some_and(|b| t > b),
};
for (mesh, gt, vis, aabb) in &self.parts {
if !vis.get() {
continue;
}
if aabb.is_some_and(|b| beyond(best, pick::ray_mesh_bounds(origin, dir, b, gt))) {
continue;
}
if let Some(hit) = pick::ray_member_at(&mesh.0, gt, ray) {
best = Some(best.map_or(hit.distance, |b| b.min(hit.distance)));
}
}
for (blob, gt, vis, aabb) in &self.blobs {
if !vis.get()
|| aabb.is_some_and(|b| beyond(best, pick::ray_mesh_bounds(origin, dir, b, gt)))
{
continue;
}
for m in blob.0.iter() {
if !occludes_pick(&m.object, &m.geometry) {
continue;
}
if let Some(hit) = pick::ray_member(&m.geometry, m.transform, ray) {
best = Some(best.map_or(hit.distance, |b| b.min(hit.distance)));
}
}
}
if let Some(d) = self.gx.as_deref().and_then(|gx| gx.nearest_occluder(ray)) {
best = Some(best.map_or(d, |b| b.min(d)));
}
best
}
}
/// Registers the three world click messages.
pub struct InteractPlugin;
+25
View File
@@ -55,6 +55,22 @@ pub struct ObjectHit {
pub trait PickSource {
/// Append the nearest hit per member along `ray`; `all_hits` asks for the whole ray.
fn cast_objects(&self, ray: Ray3d, all_hits: bool, out: &mut Vec<(Arc<WorldObject>, RayHit)>);
/// The distance to the nearest drawn batch along `ray` that occludes the mouse pick
/// ([`occludes_pick`]); run every frame, so a lane keeps what it needs inline.
fn nearest_occluder(&self, ray: Ray3d) -> Option<f32>;
}
/// Whether a drawn batch is the static-doodad geometry the reference's world trace tests
/// (`0x69c0f0`, the mouse pick's mask `0x1000114`): `0x69cdb0` queues a doodad def whose owner pair
/// `+0x180` is zero, a map doodad rather than a GameObject's, in mode 2 under bits 4 and
/// `0x1000000`, and mode 2 of `0x7089c0` tests the render submeshes, skipping any blend but 0
/// (`0x70903b`). The def is queued once flag `0x80` of `+0xc` is set, which the pending-doodad
/// drain sets once its model is loaded (`0x698c50`, `or byte [ebx+0xc],0x81` at `0x698cc1`). The
/// collision triangles, mode 3, need bit 1 or `0x100000`, which the pick's mask lacks.
pub fn occludes_pick(object: &WorldObject, geometry: &RenderSubmesh) -> bool {
object.kind == crate::model_render::ModelKind::Doodad
&& geometry.blend == benilla_formats::ModelBlend::Opaque
}
/// One triangle-accurate hit; the normal follows the authored winding, not the ray.
@@ -484,6 +500,15 @@ pub fn ray_member(geometry: &RenderSubmesh, transform: Transform, ray: Ray3d) ->
)
}
/// [`ray_member`] for a part posed by its entity's `GlobalTransform`.
pub(crate) fn ray_member_at(
geometry: &RenderSubmesh,
gt: &GlobalTransform,
ray: Ray3d,
) -> Option<RayHit> {
ray_submesh(geometry, gt, ray.origin, *ray.direction, false)
}
/// Ray against an entity's `Aabb` taken to world space corner by corner: the broad phase, and the
/// whole test for a part with no resident geometry.
pub fn ray_mesh_bounds(origin: Vec3, dir: Vec3, aabb: &Aabb, gt: &GlobalTransform) -> Option<f32> {
@@ -122,6 +122,9 @@ fn spawn_exile(commands: &mut Commands, f: &GxFader, alpha: f32, admitted: bool)
if let Some(aabb) = b.aabb {
e.insert((aabb, bevy::camera::visibility::NoAutoAabb));
}
if let Some(m) = crate::interact::PickOccluderPart::of(b.blend_mode) {
e.insert(m);
}
ents.push(e.id());
}
if fade_trace() {
+41 -3
View File
@@ -135,8 +135,11 @@ struct GxItem {
transform: Transform,
/// The placement identity the pick names, shared by the placement's batches.
object: Arc<crate::interact::WorldObject>,
/// The batch's model-local bound for the pick's broad phase; `None` is always narrow-tested.
local_aabb: Option<Aabb>,
/// [`crate::interact::occludes_pick`], held inline for the per-frame occluder cast.
occludes: bool,
/// The batch's world box `(min, max)` for the pick's broad phase, from its model-local bound
/// and placement, taken once at the divert; `None` is always narrow-tested.
world_bounds: Option<(Vec3, Vec3)>,
/// The owner tile, read only by [`StaticGx::release_owner`]; regions follow their instance.
owner: (i32, i32),
texture: Option<AssetId<bevy::image::Image>>,
@@ -238,6 +241,35 @@ struct GxCell {
settled: Option<bool>,
/// A prop region's distinct referrer sets, indexed by [`GxItemProp::set`].
sets: Vec<Arc<[u16]>>,
/// The union of the items' [`GxItem::world_bounds`], the pick's per-cell broad phase.
pick_bounds: Option<(Vec3, Vec3)>,
/// An item without a bound: the cell is always walked.
pick_unbounded: bool,
}
impl GxCell {
/// Take `bounds` into [`Self::pick_bounds`].
fn grow_pick_bounds(&mut self, bounds: Option<(Vec3, Vec3)>) {
match bounds {
Some((mn, mx)) => {
self.pick_bounds = Some(match self.pick_bounds {
Some((a, b)) => (a.min(mn), b.max(mx)),
None => (mn, mx),
});
}
None => self.pick_unbounded = true,
}
}
/// Rebuild the pick's cell bound from the items, after a removal.
fn rebuild_pick_bounds(&mut self) {
self.pick_bounds = None;
self.pick_unbounded = false;
let bounds: Vec<_> = self.items.iter().map(|i| i.world_bounds).collect();
for b in bounds {
self.grow_pick_bounds(b);
}
}
}
/// The main-world collector and its published draw set.
@@ -526,11 +558,16 @@ impl StaticGx {
entry.settled = None;
}
}
let world_bounds = b
.aabb
.map(|a| crate::interact::world_aabb(&a, &GlobalTransform::from(b.transform)));
entry.grow_pick_bounds(world_bounds);
entry.items.push(GxItem {
geometry: b.geometry.clone(),
transform: b.transform,
object: b.object.clone(),
local_aabb: b.aabb,
occludes: crate::interact::occludes_pick(b.object, b.geometry),
world_bounds,
owner: b.owner,
texture: b.texture.as_ref().map(Handle::id),
_texture_handle: b.texture,
@@ -575,6 +612,7 @@ impl StaticGx {
let before = cell.items.len();
cell.items.retain(|i| i.owner != owner);
if cell.items.len() != before {
cell.rebuild_pick_bounds();
if !cell.dirty {
cell.dirty_since = frame;
}
+157 -70
View File
@@ -8,96 +8,147 @@ use std::sync::Arc;
use bevy::prelude::*;
use super::{FaderState, GxCell, StaticGx};
use crate::interact::{ray_member, ray_mesh_bounds, PickSource, RayHit, WorldObject};
use crate::interact::{ray_aabb, ray_member, PickSource, RayHit, WorldObject};
impl PickSource for StaticGx {
fn cast_objects(&self, ray: Ray3d, all_hits: bool, out: &mut Vec<(Arc<WorldObject>, RayHit)>) {
self.cast(ray, all_hits, false, out);
}
fn nearest_occluder(&self, ray: Ray3d) -> Option<f32> {
let mut out = Vec::new();
self.cast(ray, false, true, &mut out);
out.iter().map(|(_, hit)| hit.distance).reduce(f32::min)
}
}
impl StaticGx {
/// The cast over the drawn items, or with `occluders` over the drawn doodad items that occlude
/// the pick alone ([`super::GxItem::occludes`]). Regions are walked nearest bound first, and
/// without `all_hits` the walk stops at the first region that starts beyond the best hit.
fn cast(
&self,
ray: Ray3d,
all_hits: bool,
occluders: bool,
out: &mut Vec<(Arc<WorldObject>, RayHit)>,
) {
let (origin, dir) = (ray.origin, *ray.direction);
// Broad phase, nearest box entry first as in the entity cast: the narrow walk stops once a
// hit beats every remaining box.
let mut candidates: Vec<(f32, &GxCell, usize)> = Vec::new();
let mut regions: Vec<(f32, Region)> = Vec::new();
let enters = |cell: &GxCell| {
if cell.pick_unbounded {
Some(0.0)
} else {
cell.pick_bounds
.and_then(|(mn, mx)| ray_aabb(origin, dir, mn, mx))
}
};
for entry in &self.world.visible {
match entry {
super::render::GxDoodadVis::Cell(coord) => {
let Some(cell) = self.cells.get(coord) else {
continue;
};
gather(cell, origin, dir, &mut candidates, |cell, i| {
// A fader draws here only while Steady; exiled, its entities answer.
match cell.items[i].fader {
Some(uid) => matches!(
cell.faders.get(&uid).map(|f| &f.state),
Some(FaderState::Steady)
),
None => true,
if let Some(cell) = self.cells.get(coord) {
if let Some(t) = enters(cell) {
regions.push((t, Region::Cell(cell)));
}
});
}
}
super::render::GxDoodadVis::Prop(instance, sets) => {
let Some(region) = self.props.get(instance) else {
continue;
};
gather(region, origin, dir, &mut candidates, |region, i| {
region.items[i].prop.as_ref().is_some_and(|p| {
sets.drawn.get(usize::from(p.set)).copied().unwrap_or(false)
})
});
if let Some(cell) = self.props.get(instance) {
if let Some(t) = enters(cell) {
regions.push((t, Region::Prop(cell, sets)));
}
}
}
}
}
for (instance, groups) in &self.world.visible_wmos {
let Some(region) = self.wmos.get(instance) else {
continue;
};
gather(region, origin, dir, &mut candidates, |region, i| {
region.items[i].wmo.as_ref().is_some_and(|w| {
groups
.drawn
.get(usize::from(w.group))
.copied()
.unwrap_or(false)
})
});
}
candidates.sort_unstable_by(|a, b| a.0.total_cmp(&b.0));
let mut best = f32::INFINITY;
for (entry, cell, i) in candidates {
if !all_hits && best < entry {
break;
// WMO group geometry never occludes the pick here: that is the walk collider's.
if !occluders {
for (instance, groups) in &self.world.visible_wmos {
if let Some(cell) = self.wmos.get(instance) {
if let Some(t) = enters(cell) {
regions.push((t, Region::Wmo(cell, groups)));
}
}
}
let item = &cell.items[i];
if let Some(hit) = ray_member(&item.geometry, item.transform, ray) {
best = best.min(hit.distance);
out.push((item.object.clone(), hit));
}
regions.sort_unstable_by(|a, b| a.0.total_cmp(&b.0));
let mut best = f32::INFINITY;
let mut candidates: Vec<(f32, usize)> = Vec::new();
for (start, region) in regions {
if !all_hits && best < start {
break; // every remaining region starts beyond the confirmed nearest hit
}
let cell = region.cell();
candidates.clear();
// Broad phase, nearest box entry first as in the entity cast.
for (i, item) in cell.items.iter().enumerate() {
// The inline box before the admission, which may chase the item's pointers.
let entry = match item.world_bounds {
Some((mn, mx)) => match ray_aabb(origin, dir, mn, mx) {
Some(t) => t,
None => continue,
},
None => 0.0,
};
if (occluders && !item.occludes) || !region.draws(i) {
continue;
}
candidates.push((entry, i));
}
candidates.sort_unstable_by(|a, b| a.0.total_cmp(&b.0));
for &(entry, i) in &candidates {
if !all_hits && best < entry {
break;
}
let item = &cell.items[i];
if let Some(hit) = ray_member(&item.geometry, item.transform, ray) {
best = best.min(hit.distance);
out.push((item.object.clone(), hit));
}
}
}
}
}
/// Add one region's admitted items to the broad phase; an item without a bound enters at 0 and is
/// always narrow-tested, as in the entity cast.
fn gather<'a>(
cell: &'a GxCell,
origin: Vec3,
dir: Vec3,
out: &mut Vec<(f32, &'a GxCell, usize)>,
admitted: impl Fn(&GxCell, usize) -> bool,
) {
for (i, item) in cell.items.iter().enumerate() {
if !admitted(cell, i) {
continue;
/// One drawn region and what its draw admits per item.
enum Region<'a> {
/// A cell: a fader draws here only while Steady; exiled, its entities answer.
Cell(&'a GxCell),
/// A prop region: an item whose referrer set is drawn.
Prop(&'a GxCell, &'a super::render::GxSel),
/// A WMO region: an item whose group is drawn.
Wmo(&'a GxCell, &'a super::render::GxSel),
}
impl Region<'_> {
fn cell(&self) -> &GxCell {
match self {
Region::Cell(c) | Region::Prop(c, _) | Region::Wmo(c, _) => c,
}
}
/// Whether this frame's draw includes item `i`.
fn draws(&self, i: usize) -> bool {
match self {
Region::Cell(cell) => match cell.items[i].fader {
Some(uid) => matches!(
cell.faders.get(&uid).map(|f| &f.state),
Some(FaderState::Steady)
),
None => true,
},
Region::Prop(cell, sets) => cell.items[i]
.prop
.as_ref()
.is_some_and(|p| sets.drawn.get(usize::from(p.set)).copied().unwrap_or(false)),
Region::Wmo(cell, groups) => cell.items[i].wmo.as_ref().is_some_and(|w| {
groups
.drawn
.get(usize::from(w.group))
.copied()
.unwrap_or(false)
}),
}
let entry = match &item.local_aabb {
Some(aabb) => {
let gt = GlobalTransform::from(item.transform);
match ray_mesh_bounds(origin, dir, aabb, &gt) {
Some(t) => t,
None => continue,
}
}
None => 0.0,
};
out.push((entry, cell, i));
}
}
@@ -140,6 +191,42 @@ mod tests {
);
}
/// The world trace's doodad leg admits a drawn doodad batch of blend 0 alone
/// ([`crate::interact::occludes_pick`]): an alpha-keyed batch nearer along the ray does not
/// occlude.
#[test]
fn the_occluder_cast_takes_only_opaque_doodad_batches() {
let mut gx = StaticGx::default();
let (rock, leaves) = (object(5), object(6));
let opaque = tri([0.0; 3]);
let keyed = Arc::new(benilla_formats::RenderSubmesh {
blend: ModelBlend::AlphaTest,
..(*tri([0.0, 0.0, 2.0])).clone()
});
assert!(gx.divert(batch_of(
&rock,
&opaque,
Vec3::ZERO,
None,
ModelBlend::Opaque
)));
assert!(gx.divert(batch_of(
&leaves,
&keyed,
Vec3::ZERO,
None,
ModelBlend::AlphaTest
)));
gx.world.visible.push(GxDoodadVis::Cell((0, 0)));
let ray = Ray3d::new(Vec3::new(-0.3, 5.0, -0.3), Dir3::NEG_Y);
assert_eq!(
gx.nearest_occluder(ray),
Some(5.0),
"the rock, not the leaves 2 yd above it"
);
assert_eq!(cast(&gx).len(), 2, "the identified pick still names both");
}
/// Exiled, the placement draws as entities that carry their own pick, so the lane goes quiet.
#[test]
fn an_exiled_fader_stops_answering() {
@@ -474,6 +474,10 @@ pub fn spawn_model_entities(
Some(slot) => MeshTag(crate::mesh_tag::probe_bits(slot)),
None => MeshTag(alpha_bits(1.0)),
};
// A static doodad's opaque batch occludes the mouse pick; a WMO's is the walk collider's.
let occluder = (kind == ModelKind::Doodad)
.then(|| crate::interact::PickOccluderPart::of(sub.blend))
.flatten();
// A billboard card's transform is the billboard system's; it still fades with its doodad,
// from its pivot, where the mesh is centred (`ZERO`).
let (entity, fade_center) = if let Some(info) = &sub.billboard {
@@ -500,6 +504,9 @@ pub fn spawn_model_entities(
mesh_tag,
card,
));
if let Some(m) = occluder {
card_entity.insert(m);
}
// The build-time Aabb, inserted here: `calculate_bounds` can race extraction of a
// `RENDER_WORLD` form, and the exterior cull fails open without a bound.
if let Some(aabb) = stat_aabb {
@@ -524,6 +531,9 @@ pub fn spawn_model_entities(
crate::interact::PickMesh(sub.geometry.clone()),
mesh_tag,
));
if let Some(m) = occluder {
part_entity.insert(m);
}
// An animated placement's joints move the vertices away from the bind-pose bound, so
// it widens to the authored all-animation box; a card, which follows its joint, needs
// none. `NoAutoAabb` keeps the bound: `calculate_bounds` recomputes it on
@@ -235,9 +235,8 @@ pub(super) fn spawn_loaded_placements(
.entity(*e)
.insert(crate::exterior_cull::ExteriorScene);
}
// The collision hull, welded into the owner tile's batch, which carries the
// `PickOccluder` clamp. A hull-less model (a tree canopy) stays pick-through,
// as the reference's world trace tests only collision-flagged doodads.
// The collision hull, welded into the owner tile's batch: the body's alone, as
// the mouse pick tests the drawn batches (`interact::DoodadOccluders`).
if let Some((verts, tris)) = (!doodad_bodies_disabled())
.then(|| placement_collider_data(m.collision.as_ref(), &p.transform))
.flatten()
@@ -245,13 +244,10 @@ pub(super) fn spawn_loaded_placements(
if hull_weld_disabled() {
ents.push(
commands
.spawn((
PendingCollider::new(
build_collider_task(verts, tris),
None,
!doodad_hulls_bare(),
),
PickOccluder,
.spawn(PendingCollider::new(
build_collider_task(verts, tris),
None,
!doodad_hulls_bare(),
))
.id(),
);
@@ -715,13 +711,10 @@ pub(super) fn spawn_loaded_placements(
if hull_weld_disabled() {
ents.push(
commands
.spawn((
PendingCollider::new(
build_collider_task(verts, tris),
None,
!doodad_hulls_bare(),
),
PickOccluder,
.spawn(PendingCollider::new(
build_collider_task(verts, tris),
None,
!doodad_hulls_bare(),
))
.id(),
);
@@ -1,6 +1,6 @@
//! Doodad-hull welding: world-static hulls batch into a few dozen welded trimeshes instead of
//! thousands of colliders, with the same triangles, layers and [`PickOccluder`] clamp (the clamp
//! reads a distance, and hover picks cast against pick meshes, never these hulls).
//! thousands of colliders, with the same triangles and layers. A hull never occludes the mouse
//! pick, which tests a doodad's drawn render batches ([`crate::interact::DoodadOccluders`]).
//!
//! - WMO props weld per placement (uniqueId) and despawn with it, as the single hulls did.
//! - ADT doodads weld per the placement's first-registering tile and despawn with that tile. A
@@ -12,7 +12,6 @@ use std::collections::HashMap;
use bevy::prelude::*;
use super::collider::{build_collider_task, doodad_hulls_bare, PendingCollider};
use crate::collision::PickOccluder;
use crate::interact::WorldObject;
use crate::model_render::ModelKind;
@@ -147,14 +146,13 @@ pub(super) fn flush_hull_welds(
}
/// One closed batch as one off-thread trimesh build with a single hull's components: default
/// layers, the pick clamp and a static body unless `doodad_hulls_bare`. Not pickable.
/// layers and a static body unless `doodad_hulls_bare`. Not pickable, and no pick occluder.
fn spawn_weld(commands: &mut Commands, acc: &mut WeldAcc) -> Entity {
let verts = std::mem::take(&mut acc.verts);
let tris = std::mem::take(&mut acc.tris);
commands
.spawn((
PendingCollider::new(build_collider_task(verts, tris), None, !doodad_hulls_bare()),
PickOccluder,
WorldObject {
kind: ModelKind::Doodad,
label: "hull-weld".into(),
@@ -238,7 +236,12 @@ mod tests {
let owned = streamer.tiles.get(&(3, 4)).unwrap().welds.clone();
assert_eq!(owned.len(), 1);
assert!(app.world().get::<PendingCollider>(owned[0]).is_some());
assert!(app.world().get::<PickOccluder>(owned[0]).is_some());
assert!(
app.world()
.get::<crate::collision::PickOccluder>(owned[0])
.is_none(),
"a hull never occludes the mouse pick"
);
}
#[test]
+14 -14
View File
@@ -93,7 +93,7 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
#### chat_bubble
- Sizes ride the plates' damped diagonal basis (`plate_basis`), not the unbounded reference law, so bubble text and plate text keep one em at every window size. ([`src/chat_bubble.rs:23`](../crates/benilla-app/src/chat_bubble.rs#L23))
- Sizes ride the plates' damped diagonal basis (`plate_basis`), not the unbounded reference law, so bubble text and plate text keep one em at every window size. ([`src/chat_bubble.rs:24`](../crates/benilla-app/src/chat_bubble.rs#L24))
#### cinematic
@@ -489,13 +489,13 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
#### vplates
- The basis is damped past `PLATE_DIAG_KNEE`, because the reference's unbounded growth (`0x7705b0`) draws plates too large and soft at high resolutions. ([`src/vplates.rs:13`](../crates/benilla-app/src/vplates.rs#L13))
- The bar fill brightens by `LIT_BOOST` in place of the reference's ADD `Nameplate-Glow` rim, which reads as hard edge lines under benilla's linear blending. ([`src/vplates.rs:17`](../crates/benilla-app/src/vplates.rs#L17))
- `LEVEL_H` is 0.0086, one em under the reference's 0.009, because the level number read too large. ([`src/vplates.rs:110`](../crates/benilla-app/src/vplates.rs#L110))
- The reference dims non-target plates to `0x7F`; raised because that fades them too far to read. ([`src/vplates.rs:126`](../crates/benilla-app/src/vplates.rs#L126))
- The reference draws at fractional device coordinates; the snap keeps the magnified border crisp. ([`src/vplates.rs:185`](../crates/benilla-app/src/vplates.rs#L185))
- The reference's plates grow with the diagonal without limit (`0x7705b0`), which reads too big and soft; past this diagonal, where the frame is the border art's native 128x32 px, the basis grows at `PLATE_GROWTH_DAMP` of that rate. ([`src/vplates.rs:191`](../crates/benilla-app/src/vplates.rs#L191))
- A constant one-logical-pixel shadow, not the reference's 0.001 gx, which draws 2 px thick and too heavy at larger windows. ([`src/vplates.rs:670`](../crates/benilla-app/src/vplates.rs#L670))
- The basis is damped past `PLATE_DIAG_KNEE`, because the reference's unbounded growth (`0x7705b0`) draws plates too large and soft at high resolutions. ([`src/vplates.rs:14`](../crates/benilla-app/src/vplates.rs#L14))
- The bar fill brightens by `LIT_BOOST` in place of the reference's ADD `Nameplate-Glow` rim, which reads as hard edge lines under benilla's linear blending. ([`src/vplates.rs:18`](../crates/benilla-app/src/vplates.rs#L18))
- `LEVEL_H` is 0.0086, one em under the reference's 0.009, because the level number read too large. ([`src/vplates.rs:111`](../crates/benilla-app/src/vplates.rs#L111))
- The reference dims non-target plates to `0x7F`; raised because that fades them too far to read. ([`src/vplates.rs:127`](../crates/benilla-app/src/vplates.rs#L127))
- The reference draws at fractional device coordinates; the snap keeps the magnified border crisp. ([`src/vplates.rs:186`](../crates/benilla-app/src/vplates.rs#L186))
- The reference's plates grow with the diagonal without limit (`0x7705b0`), which reads too big and soft; past this diagonal, where the frame is the border art's native 128x32 px, the basis grows at `PLATE_GROWTH_DAMP` of that rate. ([`src/vplates.rs:192`](../crates/benilla-app/src/vplates.rs#L192))
- A constant one-logical-pixel shadow, not the reference's 0.001 gx, which draws 2 px thick and too heavy at larger windows. ([`src/vplates.rs:693`](../crates/benilla-app/src/vplates.rs#L693))
- The reference magnifies the 128 × 32 `Interface\Tooltips\Nameplate-Border` art with `GL_LINEAR` (`0x770200`, filter `[0x878cf0]` = 1), smearing its 1 px bevel once the plate is larger than native; we resample the same pixels to the plate's physical size with sharp bilinear and draw it 1:1, because the chosen look is the same art with a crisp bevel. `super::drive_vplates` regenerates it when the physical size changes. ([`src/vplates/border.rs:3`](../crates/benilla-app/src/vplates/border.rs#L3))
#### wdb
@@ -638,9 +638,9 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
#### events
- `benilla::spell_mods` refuses an out-of-range pair, because the reference would overrun it. ([`src/events.rs:731`](../crates/benilla-protocol/src/events.rs#L731))
- An out-of-range list past the first block reads no body in the write passes (`0x466076`), which misread every block behind it, while the notify pass reads past it (`0x465fd0`) and stays in step; benilla reads the list and drops it, keeping the blocks behind it whole. ([`src/events/decode.rs:1133`](../crates/benilla-protocol/src/events/decode.rs#L1133))
- The flagged pass reads a movement block's guid as 8 raw bytes (`0x467140`, `0x46714d`) where the wire packs it, so unless the packed guid happens to be 8 bytes the reference misreads the rest of that pass; benilla reads the block once, packed, as pass 0 does (`0x467080`). ([`src/events/decode.rs:1150`](../crates/benilla-protocol/src/events/decode.rs#L1150))
- `benilla::spell_mods` refuses an out-of-range pair, because the reference would overrun it. ([`src/events.rs:734`](../crates/benilla-protocol/src/events.rs#L734))
- An out-of-range list past the first block reads no body in the write passes (`0x466076`), which misread every block behind it, while the notify pass reads past it (`0x465fd0`) and stays in step; benilla reads the list and drops it, keeping the blocks behind it whole. ([`src/events/decode.rs:1134`](../crates/benilla-protocol/src/events/decode.rs#L1134))
- The flagged pass reads a movement block's guid as 8 raw bytes (`0x467140`, `0x46714d`) where the wire packs it, so unless the packed guid happens to be 8 bytes the reference misreads the rest of that pass; benilla reads the block once, packed, as pass 0 does (`0x467080`). ([`src/events/decode.rs:1151`](../crates/benilla-protocol/src/events/decode.rs#L1151))
#### examples
@@ -656,7 +656,7 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
- Zone and position are kept, not set to the viewer's zone and the object's position, because nothing in benilla reads them. ([`src/messages/group.rs:256`](../crates/benilla-protocol/src/messages/group.rs#L256))
- String reads are unbounded. The reference `0x4191b0` caps each field, counting the NUL (roster name `0x30`, notes `0x80`, MOTD `0x200`, info `0x7d0`, guild name `0x60`, rank name `0x40`), and on overflow empties it and no-ops every later read in the packet. ([`src/messages/guild.rs:4`](../crates/benilla-protocol/src/messages/guild.rs#L4))
- A reason of 3 or more is silent, where the reference prints an uninitialized stack buffer, because 3 is the server's `INSTANCERESET_FAIL_SILENTLY`. ([`src/messages/instance.rs:70`](../crates/benilla-protocol/src/messages/instance.rs#L70))
- 2 or more prints nothing, because the reference prints an uninitialized buffer. ([`src/messages/opcode.rs:1041`](../crates/benilla-protocol/src/messages/opcode.rs#L1041))
- 2 or more prints nothing, because the reference prints an uninitialized buffer. ([`src/messages/opcode.rs:1044`](../crates/benilla-protocol/src/messages/opcode.rs#L1044))
- The consumer refuses 64 and up, because there the reference's store overruns its table. ([`src/messages/packet.rs:637`](../crates/benilla-protocol/src/messages/packet.rs#L637))
- A body too short for the position gives `None` where the client redisplays a stale global, because showing a stale queue position as current is a client bug. ([`src/messages/parse.rs:285`](../crates/benilla-protocol/src/messages/parse.rs#L285))
- A type outside 1-7 reads as nothing rather than the reference's default arm, which under-pushes its returns. ([`src/messages/pet.rs:71`](../crates/benilla-protocol/src/messages/pet.rs#L71))
@@ -869,7 +869,7 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
#### interact
- The broad bound is the mesh `Aabb` grown by 1 unit, not the reference's sequence-bounds sphere, because it can only err permissive. ([`src/interact/pick.rs:174`](../crates/benilla-world/src/interact/pick.rs#L174))
- The broad bound is the mesh `Aabb` grown by 1 unit, not the reference's sequence-bounds sphere, because it can only err permissive. ([`src/interact/pick.rs:190`](../crates/benilla-world/src/interact/pick.rs#L190))
#### lighting
@@ -911,7 +911,7 @@ Each entry is the first sentence of a `Deviation:` comment, linking to where it
- A read still loading after `INNER_WAIT_CAP` is given up on with a warning, once per request, and its tile then streams on unwaited like the outer ring, where the reference waits for ever: a hung read costs one capped stall, not one every frame. ([`src/terrain_stream.rs:825`](../crates/benilla-world/src/terrain_stream.rs#L825))
- Benilla gates on terrain alone, which is more permissive; the settle hold covers a building or doodad arriving after a teleport. ([`src/terrain_stream/residency.rs:9`](../crates/benilla-world/src/terrain_stream/residency.rs#L9))
- Tagged per submesh, where the reference tests the whole object, because a placement has no root entity to carry the bound. ([`src/terrain_stream/spawn/mod.rs:229`](../crates/benilla-world/src/terrain_stream/spawn/mod.rs#L229))
- The box, where the reference tests its circumsphere (`0x683700` → `0x682ef0` → `0x686b80` on the `[rec+0x5c]` centre and `[rec+0x68]` radius × scale), because Bevy culls by box and the box is tighter. ([`src/terrain_stream/spawn/mod.rs:896`](../crates/benilla-world/src/terrain_stream/spawn/mod.rs#L896))
- The box, where the reference tests its circumsphere (`0x683700` → `0x682ef0` → `0x686b80` on the `[rec+0x5c]` centre and `[rec+0x68]` radius × scale), because Bevy culls by box and the box is tighter. ([`src/terrain_stream/spawn/mod.rs:889`](../crates/benilla-world/src/terrain_stream/spawn/mod.rs#L889))
- Whole tiles, because benilla loads, spawns and releases ADT tiles, not chunks: a tile is wanted when any of its chunks lies in the outer window, and waited for when any lies in the inner one, so each edge is a tile line where the reference's is a chunk line. ([`src/terrain_stream/window.rs:7`](../crates/benilla-world/src/terrain_stream/window.rs#L7))
- A one-chunk keep band (`KEEP_BAND_CHUNKS`), because a tile reload re-decodes and re-spawns where the reference's is a cheap read: a tile releases only past `outer + 1`. ([`src/terrain_stream/window.rs:10`](../crates/benilla-world/src/terrain_stream/window.rs#L10))