Skip to content

Commit 11b5da5

Browse files
committed
!BREAKING refactor: remove GLM dependency
GLM structures are replaced by `Vec{2,3,4}`, `Quat`, `Color` and `Mat{3,4}` in `zenkit/Misc.hh`.
1 parent 4935440 commit 11b5da5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+614
-402
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@
77
[submodule "vendor/libsquish"]
88
path = vendor/libsquish
99
url = https://github.com/lmichaelis/phoenix-libsquish.git
10-
[submodule "vendor/glm"]
11-
path = vendor/glm
12-
url = https://github.com/g-truc/glm.git

CMakeLists.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,13 @@ target_include_directories(zenkit PUBLIC include)
130130
target_compile_definitions(zenkit PRIVATE _ZKEXPORT=1 ZKNO_REM=1)
131131
target_compile_options(zenkit PRIVATE ${_ZK_COMPILE_FLAGS})
132132
target_link_options(zenkit PUBLIC ${_ZK_LINK_FLAGS})
133-
target_link_libraries(zenkit PUBLIC glm::glm_static squish)
133+
target_link_libraries(zenkit PUBLIC squish)
134134
set_target_properties(zenkit PROPERTIES DEBUG_POSTFIX "d" VERSION ${PROJECT_VERSION})
135135

136136
if (ZK_ENABLE_INSTALL)
137137
install(TARGETS zenkit ARCHIVE LIBRARY RUNTIME)
138138
install(DIRECTORY "include/phoenix" TYPE INCLUDE)
139139
install(DIRECTORY "include/zenkit" TYPE INCLUDE)
140-
141-
if (NOT ZK_BUILD_SHARED)
142-
# For static linking we'll need to provide the dependency static libraries
143-
install(DIRECTORY "${glm_SOURCE_DIR}/glm" TYPE INCLUDE FILES_MATCHING PATTERN "*.hpp" PATTERN "*.inl" PATTERN "*.h")
144-
145-
foreach (lib glm::glm_static)
146-
install(FILES "$<TARGET_LINKER_FILE:${lib}>" TYPE LIB)
147-
endforeach ()
148-
endif ()
149140
endif ()
150141

151142
# when building tests, create a test executable and load it into CTest

include/zenkit/Archive.hh

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
#include "zenkit/Stream.hh"
88
#include "zenkit/Error.hh"
99

10-
#include <glm/mat3x3.hpp>
11-
#include <glm/vec2.hpp>
12-
#include <glm/vec3.hpp>
13-
1410
#include <memory>
1511
#include <string>
1612
#include <unordered_map>
@@ -203,17 +199,17 @@ namespace zenkit {
203199
/// \brief Reads a RGBA color value from the reader.
204200
/// \return The value read.
205201
/// \throws zenkit::ParserError if the value actually present is not a color
206-
virtual glm::u8vec4 read_color() = 0;
202+
virtual Color read_color() = 0;
207203

208204
/// \brief Reads a vec3 value from the reader.
209205
/// \return The value read.
210206
/// \throws zenkit::ParserError if the value actually present is not a vec3
211-
virtual glm::vec3 read_vec3() = 0;
207+
virtual Vec3 read_vec3() = 0;
212208

213209
/// \brief Reads a vec2 value from the reader.
214210
/// \return The value read.
215211
/// \throws zenkit::ParserError if the value actually present is not a vec2
216-
virtual glm::vec2 read_vec2() = 0;
212+
virtual Vec2 read_vec2() = 0;
217213

218214
/// \brief Reads a bounding box consisting of two consecutive vec3's from the reader.
219215
/// \return The value read.
@@ -222,7 +218,7 @@ namespace zenkit {
222218

223219
/// \brief Reads a 3-by-3 matrix from the reader.
224220
/// \return The matrix.
225-
virtual glm::mat3x3 read_mat3x3() = 0;
221+
virtual Mat3 read_mat3x3() = 0;
226222

227223
virtual std::unique_ptr<Read> read_raw(std::size_t size) = 0;
228224

@@ -285,11 +281,11 @@ namespace zenkit {
285281
virtual void write_word(std::string_view name, std::uint16_t v) = 0;
286282
virtual void write_enum(std::string_view name, std::uint32_t v) = 0;
287283
virtual void write_bool(std::string_view name, bool v) = 0;
288-
virtual void write_color(std::string_view name, glm::u8vec4 v) = 0;
289-
virtual void write_vec3(std::string_view name, glm::vec3 const& v) = 0;
290-
virtual void write_vec2(std::string_view name, glm::vec2 v) = 0;
284+
virtual void write_color(std::string_view name, Color v) = 0;
285+
virtual void write_vec3(std::string_view name, Vec3 const& v) = 0;
286+
virtual void write_vec2(std::string_view name, Vec2 v) = 0;
291287
virtual void write_bbox(std::string_view name, AxisAlignedBoundingBox const& v) = 0;
292-
virtual void write_mat3x3(std::string_view name, glm::mat3x3 const& v) = 0;
288+
virtual void write_mat3x3(std::string_view name, Mat3 const& v) = 0;
293289
virtual void write_raw(std::string_view name, std::vector<std::byte> const& v) = 0;
294290
virtual void write_raw(std::string_view name, std::byte const* v, std::uint16_t length) = 0;
295291
virtual void write_raw_float(std::string_view name, float const* v, std::uint16_t length) = 0;

include/zenkit/Boxes.hh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// SPDX-License-Identifier: MIT
33
#pragma once
44
#include "zenkit/Library.hh"
5-
6-
#include <glm/vec3.hpp>
5+
#include "zenkit/Misc.hh"
76

87
#include <vector>
98

@@ -14,14 +13,14 @@ namespace zenkit {
1413
/// \brief Represents a axis-aligned bounding box (AABB)
1514
struct AxisAlignedBoundingBox {
1615
static constexpr AxisAlignedBoundingBox zero() {
17-
return {glm::vec3 {0}, glm::vec3 {0}};
16+
return {Vec3 {0}, Vec3 {0}};
1817
}
1918

2019
/// \brief The coordinates of the minimum corner of the bounding box.
21-
glm::vec3 min;
20+
Vec3 min;
2221

2322
/// \brief The coordinates of the maximum corner of the bounding box.
24-
glm::vec3 max;
23+
Vec3 max;
2524

2625
ZKAPI void load(Read* r);
2726
ZKAPI void save(Write* w) const;
@@ -33,9 +32,9 @@ namespace zenkit {
3332
/// boxes](https://en.wikipedia.org/wiki/Minimum_bounding_box#Arbitrarily_oriented_minimum_bounding_box) may be
3433
/// rotated in the coordinate system and don't have to align with its axes.
3534
struct OrientedBoundingBox {
36-
glm::vec3 center;
37-
glm::vec3 axes[3];
38-
glm::vec3 half_width;
35+
Vec3 center;
36+
Vec3 axes[3];
37+
Vec3 half_width;
3938

4039
std::vector<OrientedBoundingBox> children;
4140

include/zenkit/Font.hh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
// SPDX-License-Identifier: MIT
33
#pragma once
44
#include "zenkit/Library.hh"
5-
6-
#include <glm/vec2.hpp>
5+
#include "zenkit/Misc.hh"
76

87
#include <cstdint>
98
#include <string>
@@ -22,7 +21,7 @@ namespace zenkit {
2221
/// \note These values are not stored as absolute pixels but rather in percent of the width and
2322
/// height of the image. Thus to calculate the real pixel position of the top left corner,
2423
/// one multiplies `uv[0].x` by the width of the font texture and `uv[0].y` by its height.
25-
glm::vec2 uv[2];
24+
Vec2 uv[2];
2625

2726
[[nodiscard]] ZKAPI bool operator==(FontGlyph const& g) const noexcept;
2827
};

include/zenkit/Material.hh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
// Copyright © 2021-2023 GothicKit Contributors.
1+
// Copyright © 2021-2024 GothicKit Contributors.
22
// SPDX-License-Identifier: MIT
33
#pragma once
44
#include "Object.hh"
55
#include "zenkit/Library.hh"
66
#include "zenkit/Misc.hh"
77

8-
#include <glm/vec2.hpp>
9-
#include <glm/vec4.hpp>
10-
118
#include <string>
129

1310
namespace zenkit {
@@ -149,13 +146,13 @@ namespace zenkit {
149146

150147
std::string name;
151148
MaterialGroup group {MaterialGroup::UNDEFINED};
152-
glm::u8vec4 color {0, 0, 0, 0};
149+
Color color {0, 0, 0, 0};
153150
float smooth_angle {0.0f};
154151
std::string texture {};
155-
glm::vec2 texture_scale {};
152+
Vec2 texture_scale {};
156153
float texture_anim_fps {0.0f};
157154
AnimationMapping texture_anim_map_mode {AnimationMapping::NONE};
158-
glm::vec2 texture_anim_map_dir {};
155+
Vec2 texture_anim_map_dir {};
159156
bool disable_collision {false};
160157
bool disable_lightmap {false};
161158
bool dont_collapse {false};
@@ -175,6 +172,6 @@ namespace zenkit {
175172
float wave_grid_size {0.0f};
176173
bool ignore_sun {false};
177174
AlphaFunction alpha_func {AlphaFunction::NONE};
178-
glm::vec2 default_mapping {};
175+
Vec2 default_mapping {};
179176
};
180177
} // namespace zenkit

include/zenkit/Mesh.hh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
#include "zenkit/Material.hh"
88
#include "zenkit/Texture.hh"
99

10-
#include <glm/vec2.hpp>
11-
#include <glm/vec3.hpp>
12-
1310
#include <memory>
1411
#include <string>
1512
#include <vector>
@@ -21,20 +18,20 @@ namespace zenkit {
2118
/// \brief Represents a light map.
2219
struct LightMap {
2320
std::shared_ptr<Texture> image;
24-
glm::vec3 normals[2];
25-
glm::vec3 origin;
21+
Vec3 normals[2];
22+
Vec3 origin;
2623
};
2724

2825
/// \brief Represents a vertex feature.
2926
struct VertexFeature {
3027
/// \brief The texture coordinates of the polygon.
31-
glm::vec2 texture;
28+
Vec2 texture;
3229

3330
/// \brief A value indicating the light level of the polygon.
3431
uint32_t light;
3532

3633
/// The normal vector of the polygon.
37-
glm::vec3 normal;
34+
Vec3 normal;
3835
};
3936

4037
/// \brief Flags set for a polygon of a mesh.
@@ -111,7 +108,7 @@ namespace zenkit {
111108
std::vector<Material> materials {};
112109

113110
/// \brief A list of vertices of this mesh.
114-
std::vector<glm::vec3> vertices {};
111+
std::vector<Vec3> vertices {};
115112

116113
/// \brief A list of vertex features of this mesh.
117114
std::vector<VertexFeature> features {};

0 commit comments

Comments
 (0)