SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FixedPointValue.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2018 SEGS Team (see Authors.txt)
5  * This software is licensed! (See License.txt for details)
6  */
7 
8 #pragma once
9 #include <stdint.h>
10 #include <cmath>
11 #include <cassert>
12 #include <glm/vec3.hpp>
13 
15 {
16  int32_t store;
17  constexpr FixedPointValue() : store(0x800000) {}
18  constexpr explicit FixedPointValue(float v) : store(int(v * 64.0f) + 0x800000)
19  {
20 #ifndef _MSC_VER
21  assert(!std::isnan(v));
22  assert(std::abs(v)*64 <0x800000);
23 #endif
24  }
25  explicit operator float() const { return (store-0x800000) / 64.0f; }
26 };
27 
29 {
31  Vector3_FPV() = default;
32  Vector3_FPV(glm::vec3 from) : x(from.x),y(from.y),z(from.z) {}
33 };
FixedPointValue x
Definition: FixedPointValue.h:30
Vector3_FPV()=default
FixedPointValue z
Definition: FixedPointValue.h:30
constexpr FixedPointValue(float v)
Definition: FixedPointValue.h:18
FixedPointValue y
Definition: FixedPointValue.h:30
Definition: FixedPointValue.h:14
Definition: FixedPointValue.h:28
int32_t store
Definition: FixedPointValue.h:16
constexpr FixedPointValue()
Definition: FixedPointValue.h:17
Vector3_FPV(glm::vec3 from)
Definition: FixedPointValue.h:32