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

Transform stand-in that chunks can create outside of the main thread. More...

Inherits IOriginHandler.

Public Member Functions

void AddChild (Transform child, bool matchParentLayer=false)
 Creates the wrapper's own Transform if it doesn't exist, then adds the child. The child's position is interpreted as a local position relative to the wrapper's.
void Destroy ()
 Destroys the Transform and unregisters the wrapper. Must be called from the main thread.
void HandleOriginShift (Point3 oldOrigin, Point3 newOrigin)
 An origin handler can either be authoritative or delta-based.
 TransformWrapper (Transform layerParent, Point chunkIndex, Point3 worldPosition=default)

Properties

Transform transform [get]

Detailed Description

Transform stand-in that chunks can create outside of the main thread.

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.

Implements IOriginHandler.