|
102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
|
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <dttr_core.h>#include <dttr_pcdogs.h>#include <dttr_util_mem.h>Go to the source code of this file.
Data Structures | |
| struct | DTTR_Util_WorldView |
Macros | |
| #define | DTTR_UTIL_WORLDVIEW_FIXED_ONE 4096 |
| One logical unit spans this many world fixed-point units. | |
| #define | DTTR_UTIL_WORLDVIEW_MAX_POLYGON_POINTS 8u |
Typedefs | |
| typedef struct DTTR_Util_WorldView | DTTR_Util_WorldView |
| #define DTTR_UTIL_WORLDVIEW_FIXED_ONE 4096 |
One logical unit spans this many world fixed-point units.
Helpers for extracting the camera frame and projecting world geometry to draw space with near-plane clipping and sub-pixel output.
This header is exposed through dttr_sdk.h only when DTTR_SDK_ENABLE_UNSTABLE is set. It depends on PCDOGS layouts that are still being mapped, so source and ABI details may change without notice.
World positions are int32 fixed point at 4096 units per logical unit, and draw coordinates are in the game's logical resolution. Graphics_ListState stores eye/target as Math_Vec3I32XZY, whose .z field holds logical Y and whose .y field holds logical Z.
Definition at line 32 of file dttr_util_worldview.h.
Referenced by dttr_util_worldview_norm_q12(), DTTR_Util_WorldView_Refresh(), DTTR_Util_WorldView_ToView(), and DTTR_Util_WorldView_ViewToScreen().
| #define DTTR_UTIL_WORLDVIEW_MAX_POLYGON_POINTS 8u |
Polygon projection emits at most this many screen vertices. A quad clipped against one plane gains at most one vertex, so 8 leaves headroom.
Definition at line 36 of file dttr_util_worldview.h.
Referenced by DTTR_Util_WorldView_ProjectPolygon().
| typedef struct DTTR_Util_WorldView DTTR_Util_WorldView |
Cached camera frame in screen-draw space. Build it once per frame with DTTR_Util_WorldView_Refresh and reuse it for each projection.
|
inlinestatic |
Definition at line 278 of file dttr_util_worldview.h.
References DTTR_PCDOGS_T_Math_Vec3I32::x, DTTR_PCDOGS_T_Math_Vec3I32::y, and DTTR_PCDOGS_T_Math_Vec3I32::z.
Referenced by DTTR_Util_WorldView_ProjectPolygon().
|
inlinestatic |
Definition at line 59 of file dttr_util_worldview.h.
Referenced by DTTR_Util_WorldView_Refresh().
|
inlinestatic |
Definition at line 81 of file dttr_util_worldview.h.
References DTTR_UTIL_WORLDVIEW_FIXED_ONE.
Referenced by DTTR_Util_WorldView_Refresh().
|
inlinestatic |
Project a single world point to draw space, failing when the point is behind the near plane.
Definition at line 258 of file dttr_util_worldview.h.
References DTTR_Util_WorldView_ToView(), DTTR_Util_WorldView_ViewToScreen(), float, DTTR_Util_WorldView::near_fp, and DTTR_PCDOGS_T_Math_Vec3I32::z.
|
inlinestatic |
Project a convex world polygon to draw space, clipping it against the near plane so camera-crossing geometry still draws its visible part. Offscreen extent is left to the rasterizer.
Definition at line 299 of file dttr_util_worldview.h.
References dttr_util_worldview_clip_segment(), DTTR_UTIL_WORLDVIEW_MAX_POLYGON_POINTS, DTTR_Util_WorldView_ToView(), DTTR_Util_WorldView_ViewToScreen(), float, DTTR_Util_WorldView::near_fp, DTTR_Util_WorldView::valid, DTTR_PCDOGS_T_Math_Vec2F::x, x, DTTR_PCDOGS_T_Math_Vec2F::y, y, DTTR_PCDOGS_T_Math_Vec3I32::z, and z.
|
inlinestatic |
Rebuild the camera frame from live Graphics_ListState data for a draw target.
The basis is built from the eye and target positions because view_matrix does not hold a plain basis, with the right vector flipped horizontally and up = forward * right. The focal length is rescaled from the camera's reference resolution to the draw rectangle, given in draw-space pixels.
Definition at line 91 of file dttr_util_worldview.h.
References DTTR_PCDOGS_D_Graphics_AdjustLevelScale_ListState, DTTR_StatusOK(), DTTR_Util_MemReadable(), DTTR_UTIL_WORLDVIEW_FIXED_ONE, dttr_util_worldview_isqrt(), dttr_util_worldview_norm_q12(), DTTR_PCDOGS_T_Graphics_ListState::eye_pos, float, DTTR_PCDOGS_T_Graphics_ListState::focal_distance, DTTR_PCDOGS_T_Math_SizeI16::height, NULL, DTTR_PCDOGS_T_Graphics_ListState::projection_near_fp, DTTR_PCDOGS_T_Graphics_ListState::screen_half, target, DTTR_PCDOGS_T_Graphics_ListState::target_pos, DTTR_Util_WorldView::valid, DTTR_PCDOGS_T_Math_SizeI16::width, DTTR_PCDOGS_T_Math_Vec3I16::x, DTTR_PCDOGS_T_Math_Vec3I32::x, DTTR_PCDOGS_T_Math_Vec3I32XZY::x, DTTR_PCDOGS_T_Math_Vec3I16::y, DTTR_PCDOGS_T_Math_Vec3I32::y, DTTR_PCDOGS_T_Math_Vec3I32XZY::y, y, DTTR_PCDOGS_T_Math_Vec3I16::z, DTTR_PCDOGS_T_Math_Vec3I32::z, and DTTR_PCDOGS_T_Math_Vec3I32XZY::z.
|
inlinestatic |
Transform a world fixed-point point into view space, where z extends into the screen.
Definition at line 204 of file dttr_util_worldview.h.
References DTTR_UTIL_WORLDVIEW_FIXED_ONE, DTTR_Util_WorldView::eye, DTTR_Util_WorldView::forward, DTTR_Util_WorldView::right, DTTR_Util_WorldView::up, DTTR_Util_WorldView::valid, DTTR_PCDOGS_T_Math_Vec3I16::x, DTTR_PCDOGS_T_Math_Vec3I32::x, DTTR_PCDOGS_T_Math_Vec3I16::y, DTTR_PCDOGS_T_Math_Vec3I32::y, DTTR_PCDOGS_T_Math_Vec3I16::z, and DTTR_PCDOGS_T_Math_Vec3I32::z.
Referenced by DTTR_Util_WorldView_ProjectPoint(), and DTTR_Util_WorldView_ProjectPolygon().
|
inlinestatic |
Perspective-divide a view-space point to draw-space coordinates with sub-pixel precision. The call fails for points at or behind the camera plane.
Definition at line 231 of file dttr_util_worldview.h.
References DTTR_Util_WorldView::center, DTTR_UTIL_WORLDVIEW_FIXED_ONE, float, DTTR_Util_WorldView::focal, DTTR_Util_WorldView::valid, DTTR_PCDOGS_T_Math_Vec2F::x, DTTR_PCDOGS_T_Math_Vec3I32::x, DTTR_PCDOGS_T_Math_Vec2F::y, DTTR_PCDOGS_T_Math_Vec3I32::y, and DTTR_PCDOGS_T_Math_Vec3I32::z.
Referenced by DTTR_Util_WorldView_ProjectPoint(), and DTTR_Util_WorldView_ProjectPolygon().