Skip to content

CameraTools

Generated from engine/render/camera_tools.h at 862e08b. The text under each declaration is the header's own comment, word for word. About the reference says how these pages are made.

Browse the render module

#include "engine/render/camera_tools.h" · namespace labrador

Camera calculate_camera(
const mattmath::Vector2F& player_center,
const mattmath::Vector2F& viewport_size,
const Camera& prev_camera,
const mattmath::RectangleF& camera_bounds) const;

viewport_size is in WORLD units, not pixels, and that distinction is the whole contract. Every line of the body adds it to prev_camera.translation, which is a world position, and compares the result against camera_bounds, which is a world rectangle. The function never reads prev_camera.scale and must not: the scale is already spent by the time the size gets here.

So a caller with a zoomed camera passes camera.visible_rectangle(viewport).size(), not viewport.size(). Passing pixels is correct only at scale 1, silently and everywhere - the borders, the edges and the bounds test all drift together, so the camera simply chases wrong without ever looking broken.

static BorderThickness calculate_camera_scroll_border(
const mattmath::Vector2F& viewport_size);

The dead zone the player moves inside before the camera follows, for a viewport this size. Public because it is the whole of the camera model that can be checked without simulating one, and it carries an invariant worth checking directly: opposing borders never sum past the viewport, or calculate_camera()'s near edge ends up beyond its far edge.

Named in the public declarations above: BorderThickness, Camera, RectangleF, Vector2F.

The files that include this header directly. A file can also reach it through another header.

Development documentation (unreleased). Built from Labrador 862e08b of 2026-10-08.