Player12
An open source football management simulator
Loading...
Searching...
No Matches
RenderMath Namespace Reference

Classes

struct  Mat4
 
struct  Projection
 
struct  ScreenPoint
 
struct  ScreenRect
 
class  ShirtNumbers
 
struct  Vec3
 
struct  Vec4
 

Functions

constexpr float dot (Vec3 a, Vec3 b)
 
constexpr Vec3 cross (Vec3 a, Vec3 b)
 
float length (Vec3 a)
 
Vec3 normalize (Vec3 a)
 
constexpr Vec3 lerp (Vec3 a, Vec3 b, float t)
 
Mat4 lookAt (Vec3 eye, Vec3 target, Vec3 up)
 
Mat4 perspective (float verticalFovRadians, float aspect, float nearPlane, float farPlane)
 
template<typename Vertex , typename WOf , typename Interpolate >
std::size_t clipConvexToNearPlane (std::span< const Vertex > input, std::span< Vertex > output, float nearPlane, WOf wOf, Interpolate interpolate)
 
constexpr Vec4 lerp (Vec4 a, Vec4 b, float t)
 
std::size_t clipPolygonToNearPlane (std::span< const Vec4 > input, std::span< Vec4 > output, float nearPlane)
 
float wrapAngle (float angle)
 
float lerpAngle (float from, float to, float t)
 
float dampingFactor (float ratePerSecond, float deltaSeconds)
 
constexpr Vec3 worldFromPitch (Vector2F normalized, float heightMetres=0.0f)
 
float worldYawFromFacing (float facingAngle)
 

Detailed Description

Minimal 3D math used by the software-projected match renderer.

World space is metric and right-handed: x runs along the pitch length (0..105 m, home attacks +x), y across its width (0..68 m, y = 0 is the near touchline of the broadcast camera) and z points up. Nothing here depends on ImGui, so the projection and clipping rules are unit-testable headless.

Function Documentation

◆ clipConvexToNearPlane()

template<typename Vertex , typename WOf , typename Interpolate >
std::size_t RenderMath::clipConvexToNearPlane ( std::span< const Vertex >  input,
std::span< Vertex >  output,
float  nearPlane,
WOf  wOf,
Interpolate  interpolate 
)

Clips a convex polygon against the near plane (w >= nearPlane) using Sutherland-Hodgman in homogeneous clip space. wOf(vertex) returns the clip-space w and interpolate(a, b, t) blends two vertices (including any attributes). output needs room for input.size() + 1 vertices. Returns the number of vertices written (0 when entirely behind the camera).

◆ clipPolygonToNearPlane()

std::size_t RenderMath::clipPolygonToNearPlane ( std::span< const Vec4 >  input,
std::span< Vec4 >  output,
float  nearPlane 
)
inline

Near-plane clip of plain clip-space points (see clipConvexToNearPlane).

◆ cross()

constexpr Vec3 RenderMath::cross ( Vec3  a,
Vec3  b 
)
constexpr

◆ dampingFactor()

float RenderMath::dampingFactor ( float  ratePerSecond,
float  deltaSeconds 
)
inline

Frame-rate independent exponential smoothing factor.

◆ dot()

constexpr float RenderMath::dot ( Vec3  a,
Vec3  b 
)
constexpr

◆ length()

float RenderMath::length ( Vec3  a)
inline

◆ lerp() [1/2]

constexpr Vec3 RenderMath::lerp ( Vec3  a,
Vec3  b,
float  t 
)
constexpr

◆ lerp() [2/2]

constexpr Vec4 RenderMath::lerp ( Vec4  a,
Vec4  b,
float  t 
)
constexpr

Linear blend of two clip-space points.

◆ lerpAngle()

float RenderMath::lerpAngle ( float  from,
float  to,
float  t 
)
inline

Interpolates two angles along the shortest arc.

◆ lookAt()

Mat4 RenderMath::lookAt ( Vec3  eye,
Vec3  target,
Vec3  up 
)
inline

Right-handed view matrix; the camera looks down its local -Z axis.

◆ normalize()

Vec3 RenderMath::normalize ( Vec3  a)
inline

◆ perspective()

Mat4 RenderMath::perspective ( float  verticalFovRadians,
float  aspect,
float  nearPlane,
float  farPlane 
)
inline

OpenGL-style perspective; clip.w equals the view-space depth.

◆ worldFromPitch()

constexpr Vec3 RenderMath::worldFromPitch ( Vector2F  normalized,
float  heightMetres = 0.0f 
)
constexpr

Maps normalised engine coordinates to metric world space (z = 0).

◆ worldYawFromFacing()

float RenderMath::worldYawFromFacing ( float  facingAngle)
inline

Converts an engine facing angle (measured in normalised pitch space) to a world yaw around +z, accounting for the anisotropic pitch scale and the flipped y axis.

◆ wrapAngle()

float RenderMath::wrapAngle ( float  angle)
inline

Wraps an angle to [-pi, pi].