vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::SampleTrack< N > Struct Template Reference

A short history of where one entity was, kept by tick. More...

#include <sample_track.h>

Public Member Functions

void record (uint32_t tick, const glm::vec3 &position, const glm::quat &rotation)
 Remember position and rotation as of tick.
bool poseAt (double tick, glm::vec3 &position, glm::quat &rotation) const
 Where the entity was at tick, which may fall between two samples.
uint32_t newest () const
 The newest moment remembered, or zero when nothing is.

Public Attributes

Sample samples [N]
 Oldest first, newest last; the first count are held.
size_t count = 0
 Samples held.

Detailed Description

template<size_t N>
struct Vkm::Engine::SampleTrack< N >

A short history of where one entity was, kept by tick.

Oldest first; answers "where was this at time t".

Template Parameters
NHow many samples to keep.

Member Function Documentation

◆ record()

template<size_t N>
void Vkm::Engine::SampleTrack< N >::record ( uint32_t tick,
const glm::vec3 & position,
const glm::quat & rotation )
inline

Remember position and rotation as of tick.

A sample not newer than the newest held is dropped, keeping the order poseAt relies on.

Parameters
tickThe moment the sample describes.
positionWhere the entity was then.
rotationHow it was turned then.

◆ poseAt()

template<size_t N>
bool Vkm::Engine::SampleTrack< N >::poseAt ( double tick,
glm::vec3 & position,
glm::quat & rotation ) const
inline

Where the entity was at tick, which may fall between two samples.

Past either end the nearest moment is given, not extrapolated: an overshoot yanked back reads worse than holding still.

Parameters
tickThe moment wanted; a double, since a tick count outgrows a float's precision within hours.
positionFilled with the pose's position.
rotationFilled with the pose's rotation.
Returns
False when nothing is remembered at all.

The documentation for this struct was generated from the following file: