Skip to content

Commit 7b2d027

Browse files
committed
first working modules!
1 parent 7b405e3 commit 7b2d027

38 files changed

+2079
-1325
lines changed

main.sharpmake.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public Common() : base(typeof(CustomTarget))
4545
{
4646
SourceFilesExtensions.Add(".sig");
4747
SourceFilesExtensions.Add(".hlsl");
48+
SourceFilesExtensions.Add(".ixx");
49+
50+
SourceFilesCompileExtensions.Add(".ixx");
4851

4952
RootPath = @"[project.SharpmakeCsPath]\projects\[project.Name]";
5053

@@ -67,6 +70,8 @@ public virtual void ConfigureAll(Configuration conf, CustomTarget target)
6770
conf.ProjectPath = @"[project.RootPath]";
6871

6972
conf.IncludePaths.Add(SourceRootPath);
73+
conf.ExportAdditionalLibrariesEvenForStaticLib = true;
74+
conf.PrecompSourceExcludeExtension.Add(".ixx");
7075

7176
conf.Options.Add(Options.Vc.Compiler.CppLanguageStandard.Latest);
7277
conf.Options.Add(Options.Vc.Compiler.Exceptions.Enable);

sources/Core/Data/Data.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22
#include "Debug/Exceptions.h"
33
#include "Utils/utils.h"
4-
4+
#include "Serialization/serialization.h"
55
namespace DataPacker
66
{
77

@@ -212,9 +212,7 @@ class Cache
212212
}
213213

214214
private:
215-
friend class boost::serialization::access;
216-
template<class Archive>
217-
void serialize(Archive& ar, const unsigned int)
215+
SERIALIZE()
218216
{
219217
ar& NVP(table);
220218
}

sources/Core/Events/Events.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22
#include "Data/Data.h"
33
#include "Serialization/serialization.h"
4+
5+
import Vectors;
46
namespace Events
57
{
68

sources/Core/Math/Constants.h

Lines changed: 0 additions & 86 deletions
This file was deleted.

sources/Core/Math/Constants.ixx

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
module;
2+
#include <cmath>
3+
export module Constants;
4+
5+
export
6+
{
7+
namespace Math
8+
{
9+
// precision constants
10+
11+
const float eps2 = 0.001f;
12+
const float eps4 = 0.00001f;
13+
const float eps6 = 0.0000001f;
14+
const float eps8 = 0.000000001f;
15+
const float eps10 = 0.00000000001f;
16+
const float eps12 = 0.0000000000001f;
17+
18+
// math constants
19+
const float pi = 3.141592653589793238462643383279f;
20+
const float e = 2.718281828459045235360287471352f;
21+
const float radToDeg = 180 / pi;
22+
const float degToRad = pi / 180;
23+
24+
const float m_pi_2 = pi / 2.0f;
25+
const float m_2_pi = pi * 2.0f;
26+
27+
28+
// math special functions
29+
template<class T>
30+
T clamp(const T& n, const T& min, const T& max)
31+
{
32+
return std::min(std::max(n, min), max);
33+
}
34+
35+
template<class T>
36+
T saturate(const T& n)
37+
{
38+
return clamp(n, static_cast<T>(0), static_cast<T>(1));
39+
}
40+
41+
42+
inline float sin(const float angle)
43+
{
44+
return sinf(angle);
45+
}
46+
47+
inline float cos(const float angle)
48+
{
49+
return cosf(angle);
50+
}
51+
52+
inline float asin(const float angle)
53+
{
54+
return asinf(angle);
55+
}
56+
57+
inline float acos(const float angle)
58+
{
59+
return acosf(angle);
60+
}
61+
62+
63+
template <class A, class B>
64+
auto pow(A a, B b)
65+
{
66+
return std::pow(a, b);
67+
}
68+
69+
template <class A>
70+
auto sqrt(A a)
71+
{
72+
return std::sqrt(a);
73+
}
74+
75+
76+
template <typename T> __forceinline T AlignUpWithMask(T value, size_t mask)
77+
{
78+
return (T)(((size_t)value + mask) & ~mask);
79+
}
80+
81+
template <typename T> __forceinline T AlignDownWithMask(T value, size_t mask)
82+
{
83+
return (T)((size_t)value & ~mask);
84+
}
85+
86+
template <typename T> __forceinline T AlignUp(T value, size_t alignment)
87+
{
88+
return AlignUpWithMask(value, alignment - 1);
89+
}
90+
91+
template <typename T> __forceinline T roundUp(T num, size_t factor) { return num + factor - 1 - (num + factor - 1) % factor; }
92+
93+
template <typename T> __forceinline T AlignDown(T value, size_t alignment)
94+
{
95+
return AlignDownWithMask(value, alignment - 1);
96+
}
97+
98+
template <typename T> __forceinline bool IsAligned(T value, size_t alignment)
99+
{
100+
return 0 == (size_t(value) & (alignment - 1));
101+
}
102+
103+
template <typename T> __forceinline T DivideByMultiple(T value, size_t alignment)
104+
{
105+
return (T)((value + alignment - 1) / alignment);
106+
}
107+
}
108+
}

sources/Core/Math/Math.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
#include "Constants.h"
2-
#include "Types/Vectors.h"
3-
#include "Types/Quaternions.h"
4-
#include "Types/Matrices.h"
1+
2+
import Constants;
3+
import Vectors;
4+
import Quaternion;
5+
import Matrices;
6+
57

68
#include "Primitives/Intersections.h"

sources/Core/Math/Primitives/Primitive.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#pragma once
2-
#include "../Constants.h"
3-
#include "../Types/Vectors.h"
4-
#include "../Types/Matrices.h"
2+
import Constants;
3+
import Vectors;
4+
import Quaternion;
5+
import Matrices;
6+
#include "Serialization/serialization.h"
57

68
enum class primitive_types
79
{

sources/Core/Math/Types/Matrices.cpp

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)