17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-03 12:00:22 +01:00

pch migration to modules [wip]

This commit is contained in:
maj00r
2026-09-09 20:35:26 +02:00
parent c3007e3237
commit 3f7960aad5
350 changed files with 5958 additions and 3059 deletions

View File

@@ -7,64 +7,30 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#ifndef ClassesH
#define ClassesH
//---------------------------------------------------------------------------
// Ra: zestaw klas do robienia wskaźników, aby uporządkować nagłówki
//---------------------------------------------------------------------------
class opengl_renderer;
class opengl33_renderer;
class TTrack; // odcinek trajektorii
class basic_event;
class TTrain; // pojazd sterowany
class TDynamicObject; // pojazd w scenerii
struct material_data;
class TAnimModel; // opakowanie egzemplarz modelu
class TAnimContainer; // fragment opakowania egzemplarza modelu
class TModel3d; //siatka modelu wspólna dla egzemplarzy
class TSubModel; // fragment modelu (tu do wyświetlania terenu)
class TMemCell; // komórka pamięci
class cParser;
class sound_source;
class TEventLauncher;
class TTraction; // drut
class TTractionPowerSource; // zasilanie drutów
class TCamera;
class scenario_time;
class TMoverParameters;
class ui_layer;
class editor_ui;
class itemproperties_panel;
class event_manager;
class memory_table;
class powergridsource_table;
class instance_table;
class vehicle_table;
class train_table;
struct light_array;
class particle_manager;
struct dictionary_source;
class trainset_desc;
class scenery_desc;
module;
#include <cstddef>
#include <stdexcept>
export module eu07.utilities.classes;
export {
namespace plc {
using element_handle = short;
class basic_controller;
}
namespace scene {
struct node_data;
class basic_node;
using group_handle = std::size_t;
}
namespace Mtable
{
class TTrainParameters; // rozkład jazdy
class TMtableTime; // czas dla danego posterunku
};
class TController; // obiekt sterujący pociągiem (AI)
enum class TCommandType
{ // binarne odpowiedniki komend w komórce pamięci
@@ -91,4 +57,5 @@ struct invalid_scenery_exception : std::runtime_error {
invalid_scenery_exception() : std::runtime_error("cannot load scenery") {}
};
#endif
} // export

View File

@@ -1,3 +1,9 @@
module;
#include <istream>
#include <ostream>
module eu07.utilities.float3d;
import eu07.scene.sn_utils;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
@@ -7,9 +13,6 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "utilities/Float3d.h"
#include "scene/sn_utils.h"
//---------------------------------------------------------------------------

348
utilities/Float3d.cppm Normal file
View File

@@ -0,0 +1,348 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
//---------------------------------------------------------------------------
module;
#include <cmath>
#include <istream>
#include <ostream>
export module eu07.utilities.float3d;
import eu07.glm;
// Deklaracje klas
export class float3 {
public:
float x, y, z;
float3(void) : x(0), y(0), z(0) {};
float3(float a, float b, float c) : x(a), y(b), z(c) {};
float Length() const;
float LengthSquared() const;
operator glm::vec3() const {
return glm::vec3(x, y, z);
}
};
export class float4 {
public:
float x, y, z, w;
float4() : x(0), y(0), z(0), w(1) {};
float4(float a, float b, float c, float d) : x(a), y(b), z(c), w(d) {};
float inline LengthSquared() const {
return x * x + y * y + z * z + w * w;
};
float inline Length() const {
return sqrt(x * x + y * y + z * z + w * w);
};
};
export struct float8 {
float3 Point;
float3 Normal;
float tu, tv;
};
export class float4x4 {
public:
float e[16];
void deserialize_float32(std::istream&);
void deserialize_float64(std::istream&);
void serialize_float32(std::ostream&);
float4x4(void) {
Identity();
};
float4x4(const float f[16]) {
for (int i = 0; i < 16; ++i)
e[i] = f[i];
};
float * operator()(int i) {
return &e[i << 2];
}
const float * readArray(void) const {
return e;
}
void Identity() {
for (int i = 0; i < 16; ++i)
e[i] = 0;
e[0] = e[5] = e[10] = e[15] = 1.0f;
}
const float *operator[](int i) const {
return &e[i << 2];
};
void InitialRotate() {
float f;
for (int i = 0; i < 16; i += 4) {
e[i] = -e[i];
f = e[i + 1];
e[i + 1] = e[i + 2];
e[i + 2] = f;
}
};
float4x4 &Rotation(float const angle, float3 const &axis);
bool IdentityIs() {
for (int i = 0; i < 16; ++i)
if (e[i] != (i % 5 ? 0.0 : 1.0))
return false;
return true;
}
void Quaternion(float4 *q);
float3 *TranslationGet() {
return (float3 *)(e + 12);
}
};
// Funkcje globalne - każda z osobnym export
export inline bool operator==(const float3 &v1, const float3 &v2);
export inline float3 &operator+=(float3 &v1, const float3 &v2);
export inline float3 operator-(const float3 &v);
export inline float3 operator-(const float3 &v1, const float3 &v2);
export inline float3 operator+(const float3 &v1, const float3 &v2);
export inline float3 operator*(float3 const &v, float const k);
export inline float3 operator/(float3 const &v, float const k);
export inline float3 SafeNormalize(const float3 &v);
export inline float3 CrossProduct(float3 const &v1, float3 const &v2);
export inline float DotProduct(float3 const &v1, float3 const &v2);
export inline float3 Interpolate(float3 const &First, float3 const &Second, float const Factor);
export inline float4 operator*(const float4 &q1, const float4 &q2);
export inline float4 operator-(const float4 &q);
export inline float4 operator-(const float4 &q1, const float4 &q2);
export inline float4 operator+(const float4 &v1, const float4 &v2);
export inline float4 operator/(const float4 &v, float const k);
export inline float4 Normalize(const float4 &v);
export inline float Dot(const float4 &q1, const float4 &q2);
export inline float4 &operator*=(float4 &v1, float const d);
export inline float4 Slerp(const float4 &q0, const float4 &q1, float t);
export inline float3 operator*(const float4x4 &m, const float3 &v);
inline glm::vec3 operator*(const float4x4 &m, const glm::vec3 &v);
export inline float4x4 operator*(const float4x4 &m1, const float4x4 &m2);
export inline float Det2x2(float a, float b, float c, float d);
export inline float Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3);
export inline float Det(const float4x4 &m);
export inline bool operator==(const float4x4& v1, const float4x4& v2);
// Definicje funkcji składowych
inline float float3::Length() const {
return std::sqrt(LengthSquared());
};
inline float float3::LengthSquared() const {
return x * x + y * y + z * z;
}
inline float4x4 &float4x4::Rotation(float const Angle, float3 const &Axis) {
auto const c = std::cos(Angle);
auto const s = std::sin(Angle);
auto const omc = 1.f - c;
auto const axis = SafeNormalize(Axis);
auto const xs = axis.x * s;
auto const ys = axis.y * s;
auto const zs = axis.z * s;
auto const xyomc = axis.x * axis.y * omc;
auto const xzomc = axis.x * axis.z * omc;
auto const yzomc = axis.y * axis.z * omc;
e[0] = axis.x * axis.x * omc + c;
e[1] = xyomc + zs;
e[2] = xzomc - ys;
e[3] = 0;
e[4] = xyomc - zs;
e[5] = axis.y * axis.y * omc + c;
e[6] = yzomc + xs;
e[7] = 0;
e[8] = xzomc + ys;
e[9] = yzomc - xs;
e[10] = axis.z * axis.z * omc + c;
e[11] = 0;
e[12] = 0;
e[13] = 0;
e[14] = 0;
e[15] = 1;
return *this;
};
// Definicje funkcji globalnych
export inline bool operator==(const float3 &v1, const float3 &v2) {
return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z;
}
export inline float3 &operator+=(float3 &v1, const float3 &v2) {
v1.x += v2.x;
v1.y += v2.y;
v1.z += v2.z;
return v1;
}
export inline float3 operator-(const float3 &v) {
return float3(-v.x, -v.y, -v.z);
}
export inline float3 operator-(const float3 &v1, const float3 &v2) {
return float3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
}
export inline float3 operator+(const float3 &v1, const float3 &v2) {
return float3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
}
export inline float3 operator*(float3 const &v, float const k) {
return float3(v.x * k, v.y * k, v.z * k);
}
export inline float3 operator/(float3 const &v, float const k) {
return float3(v.x / k, v.y / k, v.z / k);
}
export inline float3 SafeNormalize(const float3 &v) {
auto const l = v.Length();
float3 retVal;
if (l == 0)
retVal.x = retVal.y = retVal.z = 0;
else
retVal = v / l;
return retVal;
}
export inline float3 CrossProduct(float3 const &v1, float3 const &v2) {
return float3(v1.y * v2.z - v1.z * v2.y,
v2.x * v1.z - v2.z * v1.x,
v1.x * v2.y - v1.y * v2.x);
}
export inline float DotProduct(float3 const &v1, float3 const &v2) {
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
}
export inline float3 Interpolate(float3 const &First, float3 const &Second, float const Factor) {
return First * (1.0f - Factor) + Second * Factor;
}
export inline float4 operator*(const float4 &q1, const float4 &q2) {
return float4(q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y,
q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z,
q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x,
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z);
}
export inline float4 operator-(const float4 &q) {
return float4(-q.x, -q.y, -q.z, q.w);
}
export inline float4 operator-(const float4 &q1, const float4 &q2) {
return -q1 * q2;
}
export inline float4 operator+(const float4 &v1, const float4 &v2) {
return float4(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w);
}
export inline float4 operator/(const float4 &v, float const k) {
return float4(v.x / k, v.y / k, v.z / k, v.w / k);
}
export inline float4 Normalize(const float4 &v) {
auto const lengthsquared = v.LengthSquared();
if (lengthsquared == 1.0)
return v;
if (lengthsquared == 0.0)
return float4();
else
return v / std::sqrt(lengthsquared);
}
export inline float Dot(const float4 &q1, const float4 &q2) {
return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w;
}
export inline float4 &operator*=(float4 &v1, float const d) {
v1.x *= d;
v1.y *= d;
v1.z *= d;
v1.w *= d;
return v1;
}
export inline float4 Slerp(const float4 &q0, const float4 &q1, float t) {
float cosOmega = Dot(q0, q1);
float4 new_q1(q1);
if (cosOmega < 0.0f) {
new_q1.x = -new_q1.x;
new_q1.y = -new_q1.y;
new_q1.z = -new_q1.z;
new_q1.w = -new_q1.w;
cosOmega = -cosOmega;
}
float k0, k1;
if (cosOmega > 0.9999f) {
k0 = 1.0f - t;
k1 = t;
}
else {
auto const sinOmega = std::sqrt(1.0f - cosOmega * cosOmega);
auto const omega = std::atan2(sinOmega, cosOmega);
auto const oneOverSinOmega = 1.0f / sinOmega;
k0 = sin((1.0f - t) * omega) * oneOverSinOmega;
k1 = sin(t * omega) * oneOverSinOmega;
}
return float4(q0.x * k0 + new_q1.x * k1,
q0.y * k0 + new_q1.y * k1,
q0.z * k0 + new_q1.z * k1,
q0.w * k0 + new_q1.w * k1);
}
export inline float3 operator*(const float4x4 &m, const float3 &v) {
return float3(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0],
v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1],
v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]);
}
inline glm::vec3 operator*(const float4x4 &m, const glm::vec3 &v) {
return glm::vec3(
v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0],
v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1],
v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]);
}
export inline bool operator==(const float4x4& v1, const float4x4& v2) {
for (size_t i = 0; i < 16; i++) {
if (v1.e[i] != v2.e[i])
return false;
}
return true;
}
export inline float4x4 operator*(const float4x4 &m1, const float4x4 &m2) {
float4x4 retVal;
for (int x = 0; x < 4; ++x)
for (int y = 0; y < 4; ++y) {
retVal(x)[y] = 0;
for (int i = 0; i < 4; ++i)
retVal(x)[y] += m1[i][y] * m2[x][i];
}
return retVal;
}
export inline float Det2x2(float a, float b, float c, float d) {
return a * d - b * c;
}
export inline float Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3) {
return +a1 * Det2x2(b2, b3, c2, c3) - b1 * Det2x2(a2, a3, c2, c3) + c1 * Det2x2(a2, a3, b2, b3);
}
export inline float Det(const float4x4 &m) {
float a1 = m[0][0], a2 = m[1][0], a3 = m[2][0], a4 = m[3][0];
float b1 = m[0][1], b2 = m[1][1], b3 = m[2][1], b4 = m[3][1];
float c1 = m[0][2], c2 = m[1][2], c3 = m[2][2], c4 = m[3][2];
float d1 = m[0][3], d2 = m[1][3], d3 = m[2][3], d4 = m[3][3];
return +a1 * Det3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4) -
b1 * Det3x3(a2, a3, a4, c2, c3, c4, d2, d3, d4) +
c1 * Det3x3(a2, a3, a4, b2, b3, b4, d2, d3, d4) -
d1 * Det3x3(a2, a3, a4, b2, b3, b4, c2, c3, c4);
}

View File

@@ -1,356 +0,0 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include <cmath>
//---------------------------------------------------------------------------
class float3
{ // wapółrzędne wierchołka 3D o pojedynczej precyzji
public:
float x, y, z;
float3(void){};
float3(float a, float b, float c)
{
x = a;
y = b;
z = c;
};
float Length() const;
float LengthSquared() const;
operator glm::vec3() const
{
return glm::vec3(x, y, z);
}
};
inline bool operator==(const float3 &v1, const float3 &v2)
{
return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z;
};
inline float3 &operator+=(float3 &v1, const float3 &v2)
{
v1.x += v2.x;
v1.y += v2.y;
v1.z += v2.z;
return v1;
};
inline float3 operator-(const float3 &v)
{
return float3(-v.x, -v.y, -v.z);
};
inline float3 operator-(const float3 &v1, const float3 &v2)
{
return float3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
};
inline float3 operator+(const float3 &v1, const float3 &v2)
{
return float3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
};
inline float float3::Length() const
{
return std::sqrt(LengthSquared());
};
inline float float3::LengthSquared() const {
return x * x + y * y + z * z;
}
inline float3 operator*( float3 const &v, float const k ) {
return float3( v.x * k, v.y * k, v.z * k );
};
inline float3 operator/( float3 const &v, float const k )
{
return float3(v.x / k, v.y / k, v.z / k);
};
inline float3 SafeNormalize(const float3 &v)
{ // bezpieczna normalizacja (wektor długości 1.0)
auto const l = v.Length();
float3 retVal;
if (l == 0)
retVal.x = retVal.y = retVal.z = 0;
else
retVal = v / l;
return retVal;
};
inline float3 CrossProduct( float3 const &v1, float3 const &v2 )
{
return float3(v1.y * v2.z - v1.z * v2.y, v2.x * v1.z - v2.z * v1.x, v1.x * v2.y - v1.y * v2.x);
}
inline float DotProduct( float3 const &v1, float3 const &v2 ) {
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
}
inline float3 Interpolate( float3 const &First, float3 const &Second, float const Factor ) {
return First * (1.0f - Factor) + Second * Factor;
}
class float4
{ // kwaternion obrotu
public:
float x, y, z, w;
float4()
{
x = y = z = 0.f;
w = 1.f;
};
float4(float a, float b, float c, float d)
{
x = a;
y = b;
z = c;
w = d;
};
float inline LengthSquared() const
{
return x * x + y * y + z * z + w * w;
};
float inline Length() const
{
return sqrt(x * x + y * y + z * z + w * w);
};
};
inline float4 operator*(const float4 &q1, const float4 &q2)
{ // mnożenie to prawie jak mnożenie macierzy
return float4(q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y,
q1.w * q2.y + q1.y * q2.w + q1.z * q2.x - q1.x * q2.z,
q1.w * q2.z + q1.z * q2.w + q1.x * q2.y - q1.y * q2.x,
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z);
}
inline float4 operator-(const float4 &q)
{ // sprzężony; odwrotny tylko dla znormalizowanych!
return float4(-q.x, -q.y, -q.z, q.w);
};
inline float4 operator-(const float4 &q1, const float4 &q2)
{ // z odejmowaniem nie ma lekko
return -q1 * q2; // inwersja tylko dla znormalizowanych!
};
inline float4 operator+(const float4 &v1, const float4 &v2)
{
return float4(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w);
};
inline float4 operator/(const float4 &v, float const k)
{
return float4(v.x / k, v.y / k, v.z / k, v.w / k);
};
inline float4 Normalize(const float4 &v)
{ // bezpieczna normalizacja (wektor długości 1.0)
auto const lengthsquared = v.LengthSquared();
if (lengthsquared == 1.0)
return v;
if (lengthsquared == 0.0)
return float4(); // wektor zerowy, w=1
else
return v / std::sqrt(lengthsquared); // pierwiastek liczony tylko jeśli trzeba wykonać dzielenia
};
inline
float Dot(const float4 &q1, const float4 &q2)
{ // iloczyn skalarny
return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w;
}
inline float4 &operator*=(float4 &v1, float const d)
{ // mnożenie przez skalar, jaki ma sens?
v1.x *= d;
v1.y *= d;
v1.z *= d;
v1.w *= d;
return v1;
};
inline float4 Slerp(const float4 &q0, const float4 &q1, float t)
// void Slerp(QUATERNION *Out, const QUATERNION &q0, const QUATERNION &q1, float t)
{ // interpolacja sweryczna
float cosOmega = Dot(q0, q1);
float4 new_q1(q1);
if (cosOmega < 0.0f)
{ // jeżeli są niezgodne kierunki, jeden z nich trzeba zanegować
new_q1.x = -new_q1.x;
new_q1.y = -new_q1.y;
new_q1.z = -new_q1.z;
new_q1.w = -new_q1.w;
cosOmega = -cosOmega;
}
float k0, k1;
if (cosOmega > 0.9999f)
{ // jeśli jesteśmy z (t) na maksimum kosinusa, to tam prawie liniowo jest
k0 = 1.0f - t;
k1 = t;
}
else
{ // a w ogólnym przypadku trzeba liczyć na trygonometrię
auto const sinOmega = std::sqrt(1.0f - cosOmega * cosOmega); // sinus z jedynki tryg.
auto const omega = std::atan2(sinOmega, cosOmega); // wyznaczenie kąta
auto const oneOverSinOmega = 1.0f / sinOmega; // odwrotność sinusa, bo sinus w mianowniku
k0 = sin((1.0f - t) * omega) * oneOverSinOmega;
k1 = sin(t * omega) * oneOverSinOmega;
}
return float4(q0.x * k0 + new_q1.x * k1, q0.y * k0 + new_q1.y * k1, q0.z * k0 + new_q1.z * k1,
q0.w * k0 + new_q1.w * k1);
}
struct float8
{ // wierchołek 3D z wektorem normalnym i mapowaniem, pojedyncza precyzja
public:
float3 Point;
float3 Normal;
float tu, tv;
};
class float4x4
{ // macierz transformacji pojedynczej precyzji
public:
float e[16];
void deserialize_float32(std::istream&);
void deserialize_float64(std::istream&);
void serialize_float32(std::ostream&);
float4x4(void){};
float4x4(const float f[16])
{
for (int i = 0; i < 16; ++i)
e[i] = f[i];
};
float * operator()(int i)
{
return &e[i << 2];
}
const float * readArray(void) const
{
return e;
}
void Identity()
{
for (int i = 0; i < 16; ++i)
e[i] = 0;
e[0] = e[5] = e[10] = e[15] = 1.0f;
}
const float *operator[](int i) const
{
return &e[i << 2];
};
void InitialRotate()
{ // taka specjalna rotacja, nie ma co ciągać trygonometrii
float f;
for (int i = 0; i < 16; i += 4)
{
e[i] = -e[i]; // zmiana znaku X
f = e[i + 1];
e[i + 1] = e[i + 2];
e[i + 2] = f; // zamiana Y i Z
}
};
inline float4x4 &Rotation(float const angle, float3 const &axis);
inline bool IdentityIs()
{ // sprawdzenie jednostkowości
for (int i = 0; i < 16; ++i)
if (e[i] != (i % 5 ? 0.0 : 1.0)) // jedynki tylko na 0, 5, 10 i 15
return false;
return true;
}
void Quaternion(float4 *q);
inline float3 *TranslationGet()
{
return (float3 *)(e + 12);
}
};
inline float3 operator*(const float4x4 &m, const float3 &v)
{ // mnożenie wektora przez macierz
return float3(v.x * m[0][0] + v.y * m[1][0] + v.z * m[2][0] + m[3][0],
v.x * m[0][1] + v.y * m[1][1] + v.z * m[2][1] + m[3][1],
v.x * m[0][2] + v.y * m[1][2] + v.z * m[2][2] + m[3][2]);
}
inline glm::vec3 operator*( const float4x4 &m, const glm::vec3 &v ) { // mnożenie wektora przez macierz
return glm::vec3(
v.x * m[ 0 ][ 0 ] + v.y * m[ 1 ][ 0 ] + v.z * m[ 2 ][ 0 ] + m[ 3 ][ 0 ],
v.x * m[ 0 ][ 1 ] + v.y * m[ 1 ][ 1 ] + v.z * m[ 2 ][ 1 ] + m[ 3 ][ 1 ],
v.x * m[ 0 ][ 2 ] + v.y * m[ 1 ][ 2 ] + v.z * m[ 2 ][ 2 ] + m[ 3 ][ 2 ] );
}
inline float4x4 &float4x4::Rotation(float const Angle, float3 const &Axis)
{
auto const c = std::cos(Angle);
auto const s = std::sin(Angle);
// One minus c (short name for legibility of formulai)
auto const omc = 1.f - c;
auto const axis = SafeNormalize(Axis);
auto const xs = axis.x * s;
auto const ys = axis.y * s;
auto const zs = axis.z * s;
auto const xyomc = axis.x * axis.y * omc;
auto const xzomc = axis.x * axis.z * omc;
auto const yzomc = axis.y * axis.z * omc;
e[0] = axis.x * axis.x * omc + c;
e[1] = xyomc + zs;
e[2] = xzomc - ys;
e[3] = 0;
e[4] = xyomc - zs;
e[5] = axis.y * axis.y * omc + c;
e[6] = yzomc + xs;
e[7] = 0;
e[8] = xzomc + ys;
e[9] = yzomc - xs;
e[10] = axis.z * axis.z * omc + c;
e[11] = 0;
e[12] = 0;
e[13] = 0;
e[14] = 0;
e[15] = 1;
return *this;
};
inline bool operator==(const float4x4& v1, const float4x4& v2)
{
for (size_t i = 0; i < 16; i++)
{
if (v1.e[i] != v2.e[i])
return false;
}
return true;
}
inline float4x4 operator*(const float4x4 &m1, const float4x4 &m2)
{ // iloczyn macierzy
float4x4 retVal;
for (int x = 0; x < 4; ++x)
for (int y = 0; y < 4; ++y)
{
retVal(x)[y] = 0;
for (int i = 0; i < 4; ++i)
retVal(x)[y] += m1[i][y] * m2[x][i];
}
return retVal;
};
// From code in Graphics Gems; p. 766
inline float Det2x2(float a, float b, float c, float d)
{ // obliczenie wyznacznika macierzy 2×2
return a * d - b * c;
};
inline float Det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2,
float c3)
{ // obliczenie wyznacznika macierzy 3×3
return +a1 * Det2x2(b2, b3, c2, c3) - b1 * Det2x2(a2, a3, c2, c3) + c1 * Det2x2(a2, a3, b2, b3);
};
inline
float Det(const float4x4 &m)
{ // obliczenie wyznacznika macierzy 4×4
float a1 = m[0][0], a2 = m[1][0], a3 = m[2][0], a4 = m[3][0];
float b1 = m[0][1], b2 = m[1][1], b3 = m[2][1], b4 = m[3][1];
float c1 = m[0][2], c2 = m[1][2], c3 = m[2][2], c4 = m[3][2];
float d1 = m[0][3], d2 = m[1][3], d3 = m[2][3], d4 = m[3][3];
return +a1 * Det3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4) -
b1 * Det3x3(a2, a3, a4, c2, c3, c4, d2, d3, d4) +
c1 * Det3x3(a2, a3, a4, b2, b3, b4, d2, d3, d4) -
d1 * Det3x3(a2, a3, a4, b2, b3, b4, c2, c3, c4);
};

View File

@@ -1,3 +1,21 @@
module;
#include <cmath>
#include "glad/glad.h"
#include <chrono>
#include <vector>
#include <GLFW/glfw3.h>
#include <algorithm>
#include <string>
#include "utilities/Globals_macros.h"
#include "scripting/PyInt_macros.h"
module eu07.utilities.globals;
import eu07.simulation.simulation;
import eu07.simulation.simulationenvironment;
import eu07.simcore;
import eu07.utilities.logs;
import eu07.utilities.timer;
import eu07.gl.vao;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
@@ -11,17 +29,7 @@ http://mozilla.org/MPL/2.0/.
Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
*/
#include "stdafx.h"
#include "utilities/Globals.h"
#include "simulation/simulation.h"
#include "simulation/simulationenvironment.h"
#include "vehicle/Driver.h"
#include "utilities/Logs.h"
#include "Console.h"
#include "scripting/PyInt.h"
#include "utilities/Timer.h"
#include "vao.h"
void global_settings::LoadIniFile(std::string asFileName)
{

View File

@@ -6,22 +6,38 @@ distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "utilities/Classes.h"
#include "vehicle/Camera.h"
#include "utilities/Float3d.h"
#include "rendering/light.h"
#include "utilities/utilities.h"
#include "utilities/motiontelemetry.h"
module;
#include <optional>
#include <unordered_map>
#include "utilities/Globals_macros.h"
#include "utilities/utilities_macros.h"
#include <map>
#include "glad/glad.h"
#include <random>
#include <thread>
export module eu07.utilities.globals;
import eu07.glm;
import eu07.utilities.motiontelemetry;
import eu07.utilities.parser;
import eu07.utilities.classes;
import eu07.vehicle.camera;
import eu07.utilities.float3d;
import eu07.rendering.light;
import eu07.utilities.utilities;
#ifdef WITH_UART
import eu07.utilities.uart;
#endif
#ifdef WITH_ZMQ
#endif
export {
#ifdef WITH_UART
#include "utilities/uart.h"
#endif
#ifdef WITH_ZMQ
#include "input/zmq_input.h"
#endif
struct global_settings {
@@ -376,6 +392,9 @@ global_settings::export_as_text( std::ostream &Output, std::string const Key, Ty
Output << Key << " " << Value << "\n";
}
} // export -- out-of-line member definitions and explicit
// specialisations are not namespace-scope declarations, so they cannot
// carry `export`; the class itself is exported and that is what counts.
template <>
void
global_settings::export_as_text( std::ostream &Output, std::string const Key, std::string const &Value ) const;
@@ -383,7 +402,9 @@ global_settings::export_as_text( std::ostream &Output, std::string const Key, st
template <>
void
global_settings::export_as_text( std::ostream &Output, std::string const Key, bool const &Value ) const;
export {
extern global_settings& GetGlobalSettings();
#define Global (GetGlobalSettings())
} // export

View File

@@ -0,0 +1,8 @@
#pragma once
// Macros cannot cross a module boundary, so they live in a plain header
// that consumers pull into their global module fragment. The bodies are
// expanded at the use site, where the imported names are in scope, so this
// header deliberately includes nothing.
#define Global (GetGlobalSettings())

View File

@@ -1,3 +1,15 @@
module;
#include <format>
#include "utilities/Globals_macros.h"
#include "winheaders.h"
#include "utilities/utilities_macros.h"
#include <deque>
#include <mutex>
#include <thread>
module eu07.utilities.logs;
import eu07.utilities.globals;
import eu07.utilities.utilities;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
@@ -7,14 +19,7 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "utilities/Logs.h"
#include "utilities/Globals.h"
#include "winheaders.h"
#include "utilities/utilities.h"
#include "application/uilayer.h"
#include <deque>
std::ofstream output; // standardowy "log.txt", można go wyłączyć
std::ofstream errors; // lista błędów "errors.txt", zawsze działa

View File

@@ -6,8 +6,14 @@ distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
module;
#include <deque>
#include <string>
export module eu07.utilities.logs;
export {
#pragma once
enum class logtype : unsigned int {
@@ -33,3 +39,5 @@ void CommLog( const char *str );
void CommLog( const std::string &str );
extern std::deque<std::string> log_scrollback;
} // export

View File

@@ -6,11 +6,17 @@ distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
module;
#include <unordered_map>
#include <string>
#include <deque>
#include <cstdint>
export module eu07.utilities.names;
export {
template <typename Type_>
class basic_table {
@@ -100,3 +106,5 @@ public:
return m_items; }
};
} // export

View File

@@ -1,3 +1,10 @@
module;
#include <ctime>
#include "utilities/Globals_macros.h"
#include "winheaders.h"
module eu07.utilities.timer;
import eu07.utilities.globals;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
@@ -7,10 +14,6 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "utilities/Timer.h"
#include "utilities/Globals.h"
#include "winheaders.h"
namespace Timer {

View File

@@ -6,8 +6,13 @@ distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
module;
#include <chrono>
export module eu07.utilities.timer;
export {
#pragma once
namespace Timer {
@@ -71,3 +76,5 @@ extern subsystem_stopwatches subsystem;
};
//---------------------------------------------------------------------------
} // export

9
utilities/U8.cppm Normal file
View File

@@ -0,0 +1,9 @@
module;
#include "utilities/U8_macros.h"
export module eu07.utilities.u8;
export {
} // export

View File

@@ -1,3 +0,0 @@
#pragma once
#define U8(str) (const char *)u8##str

8
utilities/U8_macros.h Normal file
View File

@@ -0,0 +1,8 @@
#pragma once
// Macros cannot cross a module boundary, so they live in a plain header
// that consumers pull into their global module fragment. The bodies are
// expanded at the use site, where the imported names are in scope, so this
// header deliberately includes nothing.
#define U8(str) (const char *)u8##str

View File

@@ -1,4 +1,11 @@
#pragma once
module;
#include <algorithm>
#include <cmath>
export module eu07.utilities.color;
import eu07.glm;
export {
namespace colors {
@@ -126,3 +133,5 @@ HSVtoRGB( glm::vec3 const &HSV ) {
}
} // namespace colors
} // export

View File

@@ -1,4 +1,10 @@
/*
module;
#include <string>
export module eu07.utilities.comparison;
export {
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
@@ -7,7 +13,6 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
enum class comparison_operator {
equal, // ==
@@ -76,3 +81,5 @@ comparison_operator_from_string( std::string const Input ) {
//---------------------------------------------------------------------------
} // export

View File

@@ -1,3 +1,4 @@
module;
#include <client/crash_report_database.h>
#include <client/settings.h>
#include <client/crashpad_client.h>
@@ -8,6 +9,8 @@
#include <iostream>
#include "version_info.h"
module eu07.utilities.crashreporter;
#if defined __has_attribute
# if __has_attribute (init_priority)
# define INITPRIO_CLASS __attribute__ ((init_priority (5000)))

View File

@@ -1,3 +1,12 @@
module;
#include "utilities/crashreporter_macros.h"
#include <string>
export module eu07.utilities.crashreporter;
export {
#ifdef WITH_CRASHPAD
void crashreport_add_info(const char *name, const std::string &value);
const std::string& crashreport_get_provider();
@@ -6,10 +15,6 @@ bool crashreport_is_pending();
void crashreport_upload_reject();
void crashreport_upload_accept();
#else
#define crashreport_add_info(a,b)
#define crashreport_get_provider() (std::string(""))
#define crashreport_set_autoupload()
#define crashreport_is_pending() (false)
#define crashreport_upload_reject()
#define crashreport_upload_accept()
#endif
} // export

View File

@@ -0,0 +1,13 @@
#pragma once
// Macros cannot cross a module boundary, so they live in a plain header
// that consumers pull into their global module fragment. The bodies are
// expanded at the use site, where the imported names are in scope, so this
// header deliberately includes nothing.
#define crashreport_add_info(a,b)
#define crashreport_get_provider() (std::string(""))
#define crashreport_set_autoupload()
#define crashreport_is_pending() (false)
#define crashreport_upload_reject()
#define crashreport_upload_accept()

View File

@@ -1,3 +1,13 @@
module;
#include <string>
#include <sstream>
#include "vehicle/DynObj_macros.h"
module eu07.utilities.dictionary;
import eu07.utilities.utilities;
import eu07.simulation.simulation;
import eu07.simcore;
import eu07.world.mtable;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
@@ -7,13 +17,7 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "utilities/dictionary.h"
#include "simulation/simulation.h"
#include "vehicle/DynObj.h"
#include "vehicle/Driver.h"
#include "world/mtable.h"
dictionary_source::dictionary_source( std::string const &Input ) {

View File

@@ -7,10 +7,17 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
// collection of keyword-value pairs
// NOTE: since our python dictionary operates on a few types, most of the class was hardcoded for simplicity
module;
#include <string>
#include <vector>
export module eu07.utilities.dictionary;
import eu07.glm;
export {
struct dictionary_source {
// types
template <typename Type_>
@@ -31,3 +38,5 @@ struct dictionary_source {
inline void insert( std::string const &Key, std::string const Value ) { strings.emplace_back( Key, Value ); }
inline void insert( std::string const &Key, std::vector<glm::vec2> const Value ) { vec2_lists.emplace_back( Key, Value ); }
};
} // export

View File

@@ -1,5 +1,10 @@
#pragma once
#include <glm/glm.hpp>
module;
#include <cmath>
export module eu07.utilities.glmhelpers;
import eu07.glm;
export {
inline glm::dmat4 BasisChange(glm::dvec3 u, glm::dvec3 v, glm::dvec3 n)
{
@@ -19,3 +24,5 @@ template <typename T> inline glm::vec<3, T> RotateY(const glm::vec<3, T> &v, T a
return glm::vec<3, T>(c * v.x + s * v.z, v.y, c * v.z - s * v.x);
}
} // export

71
utilities/glm_module.cppm Normal file
View File

@@ -0,0 +1,71 @@
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
module;
// Everything glm reaches for from the standard library and the intrinsics headers
// is included here, in the global module fragment. Their include guards then turn
// glm's own #includes into no-ops, so only glm's declarations land in the purview
// below -- otherwise the export block would try to export system functions that
// have internal linkage, which is ill-formed.
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <climits>
#include <limits>
#include <type_traits>
#include <iterator>
#include <algorithm>
#include <cassert>
#include <memory>
#include <string>
#include <sstream>
#include <iostream>
#include <immintrin.h>
export module eu07.glm;
// glm is header-only. Including it inside the module purview attaches its
// declarations to this module, which is what lets them be exported. Every other
// module imports this one instead of including glm directly: GCC 16 rejects the
// merge when the same glm declarations arrive from several different modules
// ("conflicting imported declaration" on glm::detail::storage), so glm has to be
// compiled into exactly one module.
export {
#include <glm/glm.hpp>
#include <glm/fwd.hpp>
#include <glm/mat4x4.hpp>
#include <glm/gtc/constants.hpp>
#include <glm/gtc/epsilon.hpp>
#include <glm/gtc/matrix_access.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/packing.hpp>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtc/type_ptr.hpp>
#include <glm/gtx/compatibility.hpp>
#include <glm/gtx/euler_angles.hpp>
#include <glm/gtx/matrix_transform_2d.hpp>
#include <glm/gtx/norm.hpp>
#include <glm/gtx/quaternion.hpp>
#include <glm/gtx/rotate_vector.hpp>
// gtx/string_cast is deliberately absent: it defines static label constants,
// and an export block may not export entities with internal linkage. The two
// call sites of glm::to_string include it in their own module fragment.
#include <glm/gtx/transform.hpp>
}
export {
// 12-byte vec3 that stays packed regardless of GLM_FORCE_DEFAULT_ALIGNED_GENTYPES.
// Use in structs that must match an exact binary layout (UBOs, vertex data,
// serialized formats).
using packed_vec3 = glm::vec<3, float, glm::packed_highp>;
}

View File

@@ -1,7 +1,11 @@
#include "stdafx.h"
#include "utilities/headtrack.h"
#include "utilities/Globals.h"
module;
#include <string>
#include "utilities/Globals_macros.h"
#include <GLFW/glfw3.h>
module eu07.utilities.headtrack;
import eu07.utilities.globals;
import eu07.glm;
headtrack::headtrack()
{

View File

@@ -1,4 +1,8 @@
#pragma once
module;
export module eu07.utilities.headtrack;
export {
class headtrack
{
@@ -12,3 +16,5 @@ public:
void update();
};
} // export

View File

@@ -1,23 +1,48 @@
#include "stdafx.h"
#include "utilities/motiontelemetry.h"
#include "utilities/Globals.h"
#include "utilities/Logs.h"
#include "vehicle/Train.h"
#include "utilities/Timer.h"
#include "vehicle/Driver.h"
#include "simulation/simulation.h"
module;
#include <chrono>
#include <cmath>
#include <cstring>
#include <stdexcept>
#include "utilities/Globals_macros.h"
#ifdef _WIN32
#include <winsock2.h>
#endif
#ifdef _WIN32
#include <ws2tcpip.h>
#endif
#ifdef _WIN32
#else
#include <sys/types.h>
#endif
#ifdef _WIN32
#else
#include <sys/socket.h>
#endif
#ifdef _WIN32
#else
#include <netdb.h>
#endif
#ifdef _WIN32
#else
#include <arpa/inet.h>
#endif
#ifdef _WIN32
#else
#include <netinet/in.h>
#endif
module eu07.utilities.motiontelemetry;
import eu07.utilities.globals;
import eu07.utilities.logs;
import eu07.vehicle.train;
import eu07.utilities.timer;
import eu07.simcore;
import eu07.simulation.simulation;
#ifdef _WIN32
#else
#endif
motiontelemetry::motiontelemetry()
{
conf = Global.motiontelemetry_conf;

View File

@@ -1,8 +1,13 @@
#pragma once
module;
#include <string>
#include <chrono>
export module eu07.utilities.motiontelemetry;
import eu07.glm;
export {
class motiontelemetry
{
public:
@@ -32,3 +37,5 @@ public:
~motiontelemetry();
void update();
};
} // export

View File

@@ -1,3 +1,19 @@
module;
#include "utilities/Globals_macros.h"
#include <cstring>
#include <array>
#include <cctype>
#include <cstddef>
#include <ios>
#include <string>
#include <vector>
module eu07.utilities.parser;
import eu07.scene.scenenodegroups;
import eu07.utilities.globals;
import eu07.utilities.logs;
import eu07.utilities.utilities;
import eu07.simcore;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
@@ -7,11 +23,7 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#include "stdafx.h"
#include "utilities/parser.h"
#include "utilities/Logs.h"
#include "scene/scenenodegroups.h"
/*
MaSzyna EU07 locomotive simulator parser

View File

@@ -7,16 +7,23 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
/////////////////////////////////////////////////////////////////////////////////////////////////////
// cParser -- generic class for parsing text data, either from file or provided string
module;
#include <string>
#include <sstream>
#include <fstream>
#include <vector>
#include <map>
#include <deque>
#include <memory>
/////////////////////////////////////////////////////////////////////////////////////////////////////
// cParser -- generic class for parsing text data, either from file or provided string
export module eu07.utilities.parser;
import eu07.glm;
export {
class cParser //: public std::stringstream
{
@@ -129,6 +136,9 @@ class cParser //: public std::stringstream
};
} // export -- out-of-line member definitions and explicit
// specialisations are not namespace-scope declarations, so they cannot
// carry `export`; the class itself is exported and that is what counts.
template <>
glm::vec3
cParser::getToken( bool const ToLower, const char *Break );
@@ -158,3 +168,6 @@ cParser::operator>>( bool &Right );
template<>
bool
cParser::getToken<bool>( bool const ToLower, const char *Break );
export {
} // export

View File

@@ -1,3 +1,19 @@
module;
#include <unordered_map>
#include <fstream>
#include <istream>
#include <string>
#include "utilities/translation_macros.h"
#include "utilities/Globals_macros.h"
#include "McZapkie/MOVER_macros.h"
#include "utilities/crashreporter_macros.h"
module eu07.utilities.translation;
import eu07.utilities.logs;
import eu07.utilities.globals;
import eu07.simcore;
import eu07.rendering.geometrybank;
import eu07.utilities.crashreporter;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
@@ -11,11 +27,6 @@ http://mozilla.org/MPL/2.0/.
Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
*/
#include "stdafx.h"
#include "utilities/translation.h"
#include "utilities/Logs.h"
#include "utilities/Globals.h"
#include "MOVER.h"
void locale::init()
{

View File

@@ -6,12 +6,17 @@ distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
module;
#include "utilities/translation_macros.h"
#include <string>
#include <unordered_map>
export module eu07.utilities.translation;
export {
class locale {
public:
void init();
@@ -31,8 +36,7 @@ private:
extern locale Translations;
#define STR(x) Translations.lookup_s(x, false)
#define STR_C(x) Translations.lookup_c(x, true)
#define STRN(x) x
//find . -name "*.cpp" | xargs xgettext --from-code="UTF-8" -k --keyword=STR --keyword=STR_C --keyword=STRN
} // export

View File

@@ -0,0 +1,10 @@
#pragma once
// Macros cannot cross a module boundary, so they live in a plain header
// that consumers pull into their global module fragment. The bodies are
// expanded at the use site, where the imported names are in scope, so this
// header deliberately includes nothing.
#define STR(x) Translations.lookup_s(x, false)
#define STR_C(x) Translations.lookup_c(x, true)
#define STRN(x) x

View File

@@ -1,15 +1,26 @@
#include "stdafx.h"
#include "utilities/uart.h"
#include "utilities/Globals.h"
#include "simulation/simulation.h"
#include "vehicle/Train.h"
#include "utilities/parser.h"
#include "utilities/Logs.h"
#include "utilities/utilities.h"
#include "simulation/simulationtime.h"
#include "application/application.h"
module;
#include <libserialport.h>
#include "winheaders.h"
#include <filesystem>
#include <cstring>
#include <GLFW/glfw3.h>
#include <array>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <string>
#include <unordered_map>
#include "utilities/Globals_macros.h"
#include "utilities/utilities_macros.h"
module eu07.utilities.uart;
import eu07.utilities.globals;
import eu07.simulation.simulation;
import eu07.utilities.logs;
import eu07.gl.buffer;
import eu07.utilities.parser;
import eu07.utilities.utilities;
import eu07.simulation.simulationtime;
const char* uart_baudrates_list[] = {
"300",
"1200",

View File

@@ -1,7 +1,13 @@
#pragma once
module;
#include <libserialport.h>
#include "input/command.h"
#include <chrono>
#include <cstdint>
#include <string>
export module eu07.utilities.uart;
import eu07.input.command;
export {
extern const char* uart_baudrates_list[];
extern const size_t uart_baudrates_list_num;
@@ -111,3 +117,5 @@ private:
};
extern uart_status UartStatus;
} // export

View File

@@ -1,4 +1,20 @@
/*
module;
#include <algorithm>
#include <chrono>
#include <unordered_map>
#include <ranges>
#include "utilities/utilities_macros.h"
#include "utilities/Globals_macros.h"
#include "utilities/U8_macros.h"
#include <filesystem>
#include <random>
#include <sys/stat.h>
module eu07.utilities.utilities;
import eu07.utilities.globals;
import eu07.utilities.parser;
import eu07.utilities.u8;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
@@ -11,11 +27,9 @@ MaSzyna EU07 - SPKS
Brakes.
Copyright (C) 2007-2014 Maciej Cierniak
*/
//#include "stdafx.h"
//
//#include <sys/types.h>
//#include <sys/stat.h>
#include <ranges>
//#ifndef WIN32
//#include <unistd.h>
//#endif
@@ -24,10 +38,6 @@ Copyright (C) 2007-2014 Maciej Cierniak
//#define stat _stat
//#endif
#include "utilities/utilities.h"
#include "utilities/Globals.h"
#include "utilities/parser.h"
#include "utilities/U8.h"
//#include "utilities/Logs.h"

View File

@@ -7,13 +7,24 @@ obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "stdafx.h"
#include "utilities/parser.h"
/*rozne takie duperele do operacji na stringach w paszczalu, pewnie w delfi sa lepsze*/
/*konwersja zmiennych na stringi, funkcje matematyczne, logiczne, lancuchowe, I/O etc*/
module;
#include "utilities/utilities_macros.h"
#include <algorithm>
#include <chrono>
#include <cmath>
#include <condition_variable>
#include <filesystem>
#include <mutex>
export module eu07.utilities.utilities;
import eu07.glm;
import eu07.utilities.parser;
export {
template <typename T> T sign(T x)
{
@@ -40,7 +51,6 @@ inline constexpr const char *sounds = "sounds/";
inline constexpr const char *data = "data/";
}
#define MAKE_ID4(a, b, c, d) (((std::uint32_t)(d) << 24) | ((std::uint32_t)(c) << 16) | ((std::uint32_t)(b) << 8) | (std::uint32_t)(a))
extern bool DebugModeFlag;
extern bool FreeFlyModeFlag;
@@ -360,7 +370,7 @@ template <typename VecType_> typename VecType_::value_type nearest_segment_point
return c1 / c2;
}
glm::dvec3 LoadPoint(class cParser &Input);
glm::dvec3 LoadPoint(cParser &Input);
// extracts a group of tokens from provided data stream
std::string deserialize_random_set(cParser &Input, char const *Break = "\n\r\t ;");
@@ -433,3 +443,5 @@ class condition_variable
} // namespace threading
//---------------------------------------------------------------------------
} // export

View File

@@ -0,0 +1,8 @@
#pragma once
// Macros cannot cross a module boundary, so they live in a plain header
// that consumers pull into their global module fragment. The bodies are
// expanded at the use site, where the imported names are in scope, so this
// header deliberately includes nothing.
#define MAKE_ID4(a, b, c, d) (((std::uint32_t)(d) << 24) | ((std::uint32_t)(c) << 16) | ((std::uint32_t)(b) << 8) | (std::uint32_t)(a))

View File

@@ -1,4 +1,4 @@
#pragma once
module;
#include <array>
#include <random>
#include <sstream>
@@ -7,6 +7,10 @@
#include <algorithm>
#include <cstdint>
export module eu07.utilities.uuid;
export {
class UID {
public:
std::array<uint8_t,16> bytes;
@@ -66,4 +70,5 @@ public:
bool operator!=(const UID &other) const noexcept {
return !(*this == other);
}
};
};
} // export