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>

Classes

struct  CacheKey
 
struct  CacheKeyHash
 

Public Member Functions

const DrawRoutineInfoLookupRoutine (int routine_id) const
 
absl::StatusOr< GeometryBoundsMeasureByRoutineId (int routine_id, const RoomObject &object) const
 
absl::StatusOr< GeometryBoundsMeasureByObjectId (const RoomObject &object) const
 
absl::StatusOr< GeometryBoundsMeasureByObjectIdForState (const RoomObject &object, const DungeonState *state) const
 
void ClearCache ()
 
absl::StatusOr< GeometryBoundsMeasureRoutine (const DrawRoutineInfo &routine, const RoomObject &object) const
 
absl::StatusOr< GeometryBoundsMeasureRoutineForState (const DrawRoutineInfo &routine, const RoomObject &object, const DungeonState *state) const
 
std::pair< int, int > ResolveAnchor (int16_t object_id, uint8_t size_byte) const
 Resolve the canvas anchor (x, y) for a given object's draw routine.
 
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.
 

Private Member Functions

 ObjectGeometry ()
 
void BuildRegistry ()
 

Private Attributes

std::vector< DrawRoutineInforoutines_
 
std::unordered_map< int, DrawRoutineInforoutine_map_
 
std::unordered_map< CacheKey, GeometryBounds, CacheKeyHashcache_
 

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 102 of file object_geometry.h.

Constructor & Destructor Documentation

◆ ObjectGeometry()

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

Definition at line 124 of file object_geometry.cc.

References BuildRegistry().

Here is the call graph for this function:

Member Function Documentation

◆ Get()

◆ LookupRoutine()

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

Definition at line 142 of file object_geometry.cc.

References routine_map_.

Referenced by MeasureByObjectIdForState(), MeasureByRoutineId(), and ResolveAnchor().

◆ MeasureByRoutineId()

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

Definition at line 150 of file object_geometry.cc.

References LookupRoutine(), and MeasureRoutine().

Referenced by MeasureByObjectId(), and MeasureForLayerCompositing().

Here is the call graph for this function:

◆ MeasureByObjectId()

◆ MeasureByObjectIdForState()

absl::StatusOr< GeometryBounds > yaze::zelda3::ObjectGeometry::MeasureByObjectIdForState ( const RoomObject & object,
const DungeonState * state ) const

◆ ClearCache()

void yaze::zelda3::ObjectGeometry::ClearCache ( )

◆ MeasureRoutine()

absl::StatusOr< GeometryBounds > yaze::zelda3::ObjectGeometry::MeasureRoutine ( const DrawRoutineInfo & routine,
const RoomObject & object ) const

Definition at line 176 of file object_geometry.cc.

References MeasureRoutineForState().

Referenced by MeasureByRoutineId().

Here is the call graph for this function:

◆ MeasureRoutineForState()

◆ ResolveAnchor()

std::pair< int, int > yaze::zelda3::ObjectGeometry::ResolveAnchor ( int16_t object_id,
uint8_t size_byte ) const

Resolve the canvas anchor (x, y) for a given object's draw routine.

Replay-style preview/editor pipelines that call ObjectDrawer::DrawObject with hardcoded coordinates clip routines that draw upward or leftward (acute diagonals 0x09-0x14 / 0x15-0x20, diagonal ceilings 0xA0-0xAC, and moving wall west 0xCD). This returns the same anchor that ObjectGeometry uses internally for MeasureRoutine, so callers can position their RoomObject at coordinates that keep the full extent within the trace canvas.

Returns (0, 0) for unknown routines, or for routines whose draw direction does not require headroom.

Definition at line 160 of file object_geometry.cc.

References yaze::zelda3::DrawRoutineRegistry::Get(), yaze::zelda3::DrawRoutineRegistry::GetRoutineIdForObject(), and LookupRoutine().

Referenced by yaze::editor::TileObjectHandler::CalculateGhostPreviewGeometry(), and yaze::zelda3::ObjectTileEditor::CaptureObjectLayout().

Here is the call graph for this function:

◆ 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 302 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 318 of file object_geometry.cc.

◆ BuildRegistry()

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

Definition at line 128 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 206 of file object_geometry.h.

Referenced by BuildRegistry().

◆ routine_map_

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

Definition at line 207 of file object_geometry.h.

Referenced by BuildRegistry(), and LookupRoutine().

◆ cache_

std::unordered_map<CacheKey, GeometryBounds, CacheKeyHash> yaze::zelda3::ObjectGeometry::cache_
mutableprivate

Definition at line 208 of file object_geometry.h.

Referenced by ClearCache(), and MeasureByObjectId().


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