LayerProcGen v0.4.0
Layer-based infinite procedural generation
Loading...
Searching...
No Matches
IOriginHandler

Interface for handling floating origin shifts, which should update all state that represents a position in the scene. More...

Inherited by FloatingOriginSetter, and TransformWrapper.

Public Member Functions

void HandleOriginShift (Point3 oldOrigin, Point3 newOrigin)
 An origin handler can either be authoritative or delta-based.

Detailed Description

Interface for handling floating origin shifts, which should update all state that represents a position in the scene.

A floating origin entails a difference between:

World space, which can be very large and should be expressed in fixed point coordinates.

Scene space, which is what the engine sees and is handled in floating point coordinates.

The floating origin refers to the ability to specify and change the position of the scene origin in world space. An object's scene space coordinates are then equal their world space coordinates relative to the (world space) scene origin. The origin handlers need to enforce this whenever the scene origin changes.

Member Function Documentation

◆ HandleOriginShift()

void HandleOriginShift ( Point3 oldOrigin,
Point3 newOrigin )

An origin handler can either be authoritative or delta-based.

An authoritative handler knows an object's world position in fixed point coordinates and calculates a new scene position based on that, disregarding the old origin parameter.

A delta-based handler only knows an object's current scene position and applies a delta to it which is the new origin minus the old one.

The two approaches produce almost identical results, but the delta-based approach can lead to subtle drifting. This is typically not a problem for dynamically moving objects like the player or NPCs.

Parameters
oldOriginThe old scene origin in world space.
newOriginThe new scene origin in world space.

Implemented in FloatingOriginSetter, and TransformWrapper.