NcEngine
PhysicsTick.h
Go to the documentation of this file.
1
6
#pragma once
7
8
#include <compare>
9
#include <cstdint>
10
#include <limits>
11
12
namespace
nc
13
{
15
class
PhysicsTick
16
{
17
public
:
18
using
tick_t = uint32_t;
19
static
constexpr
auto
NullTick = std::numeric_limits<tick_t>::max();
20
21
constexpr
explicit
PhysicsTick
() noexcept
22
: m_value{NullTick} {}
23
24
constexpr
explicit
PhysicsTick
(tick_t tick) noexcept
25
: m_value{tick} {}
26
27
constexpr
static
auto
Null()
noexcept
->
PhysicsTick
{
return
PhysicsTick
{}; }
28
constexpr
auto
IsNull()
const
noexcept
->
bool
{
return
m_value == NullTick; }
29
constexpr
auto
Value()
const
noexcept
-> tick_t {
return
m_value; }
30
constexpr
explicit
operator
tick_t()
const
noexcept
{
return
m_value; }
31
constexpr
auto
operator++()
noexcept
->
PhysicsTick
& { ++m_value;
return
*
this
; }
32
constexpr
auto
operator++(
int
)
noexcept
->
PhysicsTick
{
auto
temp = *
this
; ++(*this);
return
temp;}
33
constexpr
auto
operator--()
noexcept
->
PhysicsTick
& { --m_value;
return
*
this
; }
34
constexpr
auto
operator--(
int
)
noexcept
->
PhysicsTick
{
auto
temp = *
this
; --(*this);
return
temp;}
35
constexpr
auto
operator+ (tick_t rhs)
const
noexcept
->
PhysicsTick
{
return
PhysicsTick
(m_value + rhs); }
36
constexpr
auto
operator- (tick_t rhs)
const
noexcept
->
PhysicsTick
{
return
PhysicsTick
(m_value - rhs); }
37
constexpr
auto
operator+=(tick_t rhs)
noexcept
->
PhysicsTick
& { m_value += rhs;
return
*
this
; }
38
constexpr
auto
operator-=(tick_t rhs)
noexcept
->
PhysicsTick
& { m_value -= rhs;
return
*
this
; }
39
constexpr
auto
operator<=>(
const
PhysicsTick
&)
const
noexcept
=
default
;
40
41
private
:
42
tick_t m_value;
43
};
44
}
// namespace nc
nc::PhysicsTick
Type safe wrapper representing a timepoint in the physics simulation.
Definition:
PhysicsTick.h:16
include
ncengine
physics
PhysicsTick.h
Generated by
1.9.4