void Spawner::TrySpawn() {
if (controllers.size() >= max_entities) return;
- glm::tvec3<int> chunk(
+ glm::ivec3 chunk(
(rand() % (chunk_range * 2 + 1)) - chunk_range,
(rand() % (chunk_range * 2 + 1)) - chunk_range,
(rand() % (chunk_range * 2 + 1)) - chunk_range
);
- glm::tvec3<int> pos(
+ glm::ivec3 pos(
rand() % Chunk::width,
rand() % Chunk::height,
rand() % Chunk::depth
Spawn(world.Player().ChunkCoords() + chunk, glm::vec3(pos) + glm::vec3(0.5f));
}
-void Spawner::Spawn(const glm::tvec3<int> &chunk, const glm::vec3 &pos) {
+void Spawner::Spawn(const glm::ivec3 &chunk, const glm::vec3 &pos) {
glm::vec3 color(rand() % 6, rand() % 6, rand() % 6);
color = color * 0.15f + 0.25f;
private:
void CheckDespawn() noexcept;
void TrySpawn();
- void Spawn(const glm::tvec3<int> &, const glm::vec3 &);
+ void Spawn(const glm::ivec3 &, const glm::vec3 &);
private:
World &world;
bool HasGlyph(Uint16) const noexcept;
- glm::tvec2<int> TextSize(const char *) const;
+ glm::ivec2 TextSize(const char *) const;
Texture Render(const char *) const;
void Render(const char *, Texture &) const;
}
-glm::tvec2<int> Font::TextSize(const char *text) const {
- glm::tvec2<int> size;
+glm::ivec2 Font::TextSize(const char *text) const {
+ glm::ivec2 size;
if (TTF_SizeUTF8(handle, text, &size.x, &size.y) != 0) {
throw std::runtime_error(TTF_GetError());
}
Sound place_sound;
Sound remove_sound;
- glm::tvec3<int> fwd, rev;
+ glm::ivec3 fwd, rev;
};
}
}
- static glm::tvec3<int> FaceNormal(Face face) noexcept {
+ static glm::ivec3 FaceNormal(Face face) noexcept {
return face2normal[face];
}
};
private:
- static const glm::tvec3<int> face2normal[6];
+ static const glm::ivec3 face2normal[6];
static const glm::mat4 orient2transform[ORIENT_COUNT];
static const Face orient2face[ORIENT_COUNT][FACE_COUNT];
class Chunk {
public:
- using Pos = glm::tvec3<int>;
+ using Pos = glm::ivec3;
public:
explicit Chunk(const BlockTypeRegistry &) noexcept;
return chunks.ForceLoad(player->ChunkCoords());
}
-Chunk &World::Next(const Chunk &to, const glm::tvec3<int> &dir) {
+Chunk &World::Next(const Chunk &to, const glm::ivec3 &dir) {
const Chunk::Pos tgt_pos = to.Position() + dir;
return chunks.ForceLoad(tgt_pos);
}
Entity &AddEntity() { entities.emplace_back(); return entities.back(); }
Chunk &PlayerChunk();
- Chunk &Next(const Chunk &to, const glm::tvec3<int> &dir);
+ Chunk &Next(const Chunk &to, const glm::ivec3 &dir);
void Update(int dt);
{ 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, }, // face: back, turn: right
};
-const glm::tvec3<int> Block::face2normal[FACE_COUNT] = {
+const glm::ivec3 Block::face2normal[FACE_COUNT] = {
{ 0, 1, 0 },
{ 0, -1, 0 },
{ 1, 0, 0 },
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"bad number of components for vec2i",
- 2, gl_traits<glm::tvec2<int>>::size
+ 2, gl_traits<glm::ivec2>::size
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"bad number of components for vec3i",
- 3, gl_traits<glm::tvec3<int>>::size
+ 3, gl_traits<glm::ivec3>::size
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"bad number of components for vec4i",
- 4, gl_traits<glm::tvec4<int>>::size
+ 4, gl_traits<glm::ivec4>::size
);
}
void BlockTest::testFaceNormal() {
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"[ 0, 1, 0 ] not normal of UP",
- glm::tvec3<int>(0, 1, 0), Block::FaceNormal(Block::FACE_UP)
+ glm::ivec3(0, 1, 0), Block::FaceNormal(Block::FACE_UP)
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"[ 0, -1, 0 ] not normal of DOWN",
- glm::tvec3<int>(0, -1, 0), Block::FaceNormal(Block::FACE_DOWN)
+ glm::ivec3(0, -1, 0), Block::FaceNormal(Block::FACE_DOWN)
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"[ 1, 0, 0 ] not normal of RIGHT",
- glm::tvec3<int>(1, 0, 0), Block::FaceNormal(Block::FACE_RIGHT)
+ glm::ivec3(1, 0, 0), Block::FaceNormal(Block::FACE_RIGHT)
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"[ -1, 0, 0 ] not normal of LEFT",
- glm::tvec3<int>(-1, 0, 0), Block::FaceNormal(Block::FACE_LEFT)
+ glm::ivec3(-1, 0, 0), Block::FaceNormal(Block::FACE_LEFT)
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"[ 0, 0, 1 ] not normal of FRONT",
- glm::tvec3<int>(0, 0, 1), Block::FaceNormal(Block::FACE_FRONT)
+ glm::ivec3(0, 0, 1), Block::FaceNormal(Block::FACE_FRONT)
);
CPPUNIT_ASSERT_EQUAL_MESSAGE(
"[ 0, 0, -1 ] not normal of BACK",
- glm::tvec3<int>(0, 0, -1), Block::FaceNormal(Block::FACE_BACK)
+ glm::ivec3(0, 0, -1), Block::FaceNormal(Block::FACE_BACK)
);
}