yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::zelda3::ObjectGeometry Class Reference

Side-car geometry engine that replays draw routines against an off-screen buffer to calculate real extents. More...

#include <object_geometry.h>

Public Member Functions

const DrawRoutineInfoLookupRoutine (int routine_id) const
 
absl::StatusOr< GeometryBoundsMeasureByRoutineId (int routine_id, const RoomObject &object) const
 
absl::StatusOr< GeometryBoundsMeasureRoutine (const DrawRoutineInfo &routine, const RoomObject &object) const
 
absl::StatusOr< GeometryBoundsMeasureForLayerCompositing (int routine_id, const RoomObject &object) const
 Measure bounds for a BG2 overlay object and mark it for masking.
 

Static Public Member Functions

static ObjectGeometryGet ()
 
static bool IsLayerOneRoutine (int routine_id)
 Get list of routine IDs that draw to BG2 layer.
 
static bool IsDiagonalCeilingRoutine (int routine_id)
 Check if a routine ID corresponds to a diagonal ceiling.
 
static GeometryBounds ApplySelectionBounds (GeometryBounds render_bounds, int routine_id)
 Compute tighter selection bounds for diagonal shapes.
 

Private Member Functions

 ObjectGeometry ()
 
void BuildRegistry ()
 

Private Attributes

std::vector< DrawRoutineInforoutines_
 
std::unordered_map< int, DrawRoutineInforoutine_map_
 

Detailed Description

Side-car geometry engine that replays draw routines against an off-screen buffer to calculate real extents.

This is intentionally self-contained (no ROM or editor coupling) so it can be tested in isolation and later dropped into ObjectDrawer/editor hit-testing paths.

Definition at line 116 of file object_geometry.h.

Constructor & Destructor Documentation

◆ ObjectGeometry()

yaze::zelda3::ObjectGeometry::ObjectGeometry ( )
private

Definition at line 56 of file object_geometry.cc.

References BuildRegistry().

Here is the call graph for this function:

Member Function Documentation

◆ Get()

ObjectGeometry & yaze::zelda3::ObjectGeometry::Get ( )
static

Definition at line 51 of file object_geometry.cc.

◆ LookupRoutine()

const DrawRoutineInfo * yaze::zelda3::ObjectGeometry::LookupRoutine ( int routine_id) const

Definition at line 72 of file object_geometry.cc.

References routine_map_.

Referenced by MeasureByRoutineId().

◆ MeasureByRoutineId()

absl::StatusOr< GeometryBounds > yaze::zelda3::ObjectGeometry::MeasureByRoutineId ( int routine_id,
const RoomObject & object ) const

Definition at line 80 of file object_geometry.cc.

References LookupRoutine(), and MeasureRoutine().

Referenced by MeasureForLayerCompositing().

Here is the call graph for this function:

◆ MeasureRoutine()

◆ MeasureForLayerCompositing()

absl::StatusOr< GeometryBounds > yaze::zelda3::ObjectGeometry::MeasureForLayerCompositing ( int routine_id,
const RoomObject & object ) const

Measure bounds for a BG2 overlay object and mark it for masking.

This is a convenience method that measures the object and sets the is_bg2_overlay flag if the object's layer indicates it draws to BG2. Used by the dungeon editor to determine BG1 mask regions.

Parameters
routine_idDraw routine ID
objectObject with layer information
Returns
GeometryBounds with is_bg2_overlay set appropriately

Definition at line 151 of file object_geometry.cc.

References yaze::zelda3::RoomObject::BG2, yaze::zelda3::GeometryBounds::is_bg2_overlay, and MeasureByRoutineId().

Here is the call graph for this function:

◆ IsLayerOneRoutine()

bool yaze::zelda3::ObjectGeometry::IsLayerOneRoutine ( int routine_id)
static

Get list of routine IDs that draw to BG2 layer.

These routines write to the lower tilemap (BG2) and require corresponding BG1 transparency for proper compositing.

Definition at line 167 of file object_geometry.cc.

◆ IsDiagonalCeilingRoutine()

bool yaze::zelda3::ObjectGeometry::IsDiagonalCeilingRoutine ( int routine_id)
static

Check if a routine ID corresponds to a diagonal ceiling.

Diagonal ceilings (routines 75-78 for objects 0xA0-0xA3) have triangular fill patterns that require tighter selection bounds than their bounding box.

Definition at line 183 of file object_geometry.cc.

Referenced by ApplySelectionBounds().

◆ ApplySelectionBounds()

GeometryBounds yaze::zelda3::ObjectGeometry::ApplySelectionBounds ( GeometryBounds render_bounds,
int routine_id )
static

Compute tighter selection bounds for diagonal shapes.

For triangular diagonal ceilings, this computes a selection rectangle that's roughly 70% of the bounding box, centered on the visual content.

Parameters
render_boundsFull render bounds from MeasureRoutine
routine_idThe routine ID to check for diagonal shapes
Returns
GeometryBounds with selection_bounds set if applicable

Definition at line 192 of file object_geometry.cc.

References yaze::zelda3::SelectionRect::height_tiles, yaze::zelda3::GeometryBounds::height_tiles, IsDiagonalCeilingRoutine(), yaze::zelda3::GeometryBounds::min_x_tiles, yaze::zelda3::GeometryBounds::min_y_tiles, yaze::zelda3::GeometryBounds::selection_bounds, yaze::zelda3::SelectionRect::width_tiles, yaze::zelda3::GeometryBounds::width_tiles, yaze::zelda3::SelectionRect::x_tiles, and yaze::zelda3::SelectionRect::y_tiles.

Here is the call graph for this function:

◆ BuildRegistry()

void yaze::zelda3::ObjectGeometry::BuildRegistry ( )
private

Definition at line 58 of file object_geometry.cc.

References yaze::zelda3::DrawRoutineRegistry::Get(), routine_map_, and routines_.

Referenced by ObjectGeometry().

Here is the call graph for this function:

Member Data Documentation

◆ routines_

std::vector<DrawRoutineInfo> yaze::zelda3::ObjectGeometry::routines_
private

Definition at line 178 of file object_geometry.h.

Referenced by BuildRegistry().

◆ routine_map_

std::unordered_map<int, DrawRoutineInfo> yaze::zelda3::ObjectGeometry::routine_map_
private

Definition at line 179 of file object_geometry.h.

Referenced by BuildRegistry(), and LookupRoutine().


The documentation for this class was generated from the following files: