Resolve a bunch of CLion warnings.

master
Nicole Collings 2019-10-10 23:36:45 -07:00
parent 659c63388a
commit e2e4e3010b
16 changed files with 39 additions and 73 deletions

View File

@ -230,6 +230,6 @@ set(ZEPHA_SRC
game/entity/world/LuaEntity.cpp
game/entity/world/LuaEntity.h
lua/api/modules/cRegisterEntity.h
def/model/SerializedModel.h server/asset/AssetType.h def/model/ModelStore.cpp def/model/ModelStore.h)
def/model/SerializedModel.h server/asset/AssetType.h def/model/ModelStore.h)
add_library (Zepha_Core ${ZEPHA_SRC})

View File

@ -2,6 +2,9 @@
// Created by aurailus on 13/08/19.
//
#pragma clang diagnostic push
#pragma ide diagnostic ignored "cppcoreguidelines-pro-type-static-cast-downcast"
#include "DefinitionAtlas.h"
ItemDef& DefinitionAtlas::fromId(unsigned int id) {
@ -65,3 +68,5 @@ unsigned int DefinitionAtlas::size() {
DefinitionAtlas::~DefinitionAtlas() {
for (auto def : defs) delete def;
}
#pragma clang diagnostic pop

View File

@ -7,7 +7,6 @@
#include "MapGen.h"
#include "../../util/Timer.h"
#include "NoiseSample.h"
#include "../../util/Vec.h"
MapGen::MapGen(unsigned int seed, DefinitionAtlas& atlas) {
this->seed = seed;

View File

@ -18,13 +18,10 @@ struct MapGenJob {
glm::vec3 pos {};
explicit MapGenJob(glm::vec3 pos) {
this->pos = pos;
blocks = std::array<uint, 4096>();
density = std::vector<float>((unsigned long)pow(TransPos::CHUNK_SIZE, 3));
depth = std::vector<int>((unsigned long)pow(TransPos::CHUNK_SIZE, 3));
depthFloat = std::vector<float>((unsigned long)pow(TransPos::CHUNK_SIZE, 3));
}
explicit MapGenJob(glm::vec3 pos) :
pos(pos),
blocks(),
density(4096),
depth(4096),
depthFloat(4096) {}
};

View File

@ -31,12 +31,12 @@ void NoiseSample::set(glm::vec3 pos, float value) {
}
float NoiseSample::get(glm::vec3& pos) {
int xInt = (int)pos.x;
int yInt = (int)pos.y;
int zInt = (int)pos.z;
auto xInt = static_cast<int>(pos.x);
auto yInt = static_cast<int>(pos.y);
auto zInt = static_cast<int>(pos.z);
int offsetH = (int)((float)TransPos::CHUNK_SIZE / hPrecision);
int offsetV = (int)((float)TransPos::CHUNK_SIZE / vPrecision);
int offsetH = static_cast<int>(static_cast<float>(TransPos::CHUNK_SIZE) / hPrecision);
int offsetV = static_cast<int>(static_cast<float>(TransPos::CHUNK_SIZE) / vPrecision);
auto xBase = xInt / offsetH;
auto yBase = yInt / offsetV;

View File

@ -26,7 +26,7 @@ void BlockDef::createModel() {
for (MeshPart& p : pArray) {
for (const BlockModelVertex &vertex : p.vertices) {
vertices.push_back(EntityVertex {
vertex.pos - glm::vec3(0.5),
vertex.pos - glm::vec3(0.5f),
{vertex.tex.x, vertex.tex.y, 0, 0},
{1, 1, 1},
true,

View File

@ -14,18 +14,9 @@
class SelectionBox {
public:
SelectionBox() {
set({0, 0, 0}, {1, 1, 1});
}
SelectionBox(glm::vec3 a, glm::vec3 b) {
set(a, b);
}
SelectionBox& operator=(const SelectionBox &s) {
a = s.a;
b = s.b;
}
SelectionBox() = default;
SelectionBox(glm::vec3 a, glm::vec3 b) : a(a), b(b) {};
SelectionBox& operator=(const SelectionBox &s) = default;
bool operator==(const SelectionBox &o) {
return (a == o.a && b == o.b);
@ -45,12 +36,12 @@ public:
vec -= blockOffset; //Normalize Vector Position
if (fabs(vec.y - b.y) < THRESH && vec.x > a.x && vec.x < b.x && vec.z > a.z && vec.z < b.z) return TOP;
if (fabs(vec.y - a.y) < THRESH && vec.x > a.x && vec.x < b.x && vec.z > a.z && vec.z < b.z) return BOTTOM;
if (fabs(vec.z - a.z) < THRESH && vec.x > a.x && vec.x < b.x && vec.y > a.y && vec.y < b.y) return FRONT;
if (fabs(vec.z - b.z) < THRESH && vec.x > a.x && vec.x < b.x && vec.y > a.y && vec.y < b.y) return BACK;
if (fabs(vec.x - b.x) < THRESH && vec.z > a.z && vec.z < b.z && vec.y > a.y && vec.y < b.y) return LEFT;
if (fabs(vec.x - a.x) < THRESH && vec.z > a.z && vec.z < b.z && vec.y > a.y && vec.y < b.y) return RIGHT;
if (std::abs(vec.y - b.y) < THRESH && vec.x > a.x && vec.x < b.x && vec.z > a.z && vec.z < b.z) return TOP;
if (std::abs(vec.y - a.y) < THRESH && vec.x > a.x && vec.x < b.x && vec.z > a.z && vec.z < b.z) return BOTTOM;
if (std::abs(vec.z - a.z) < THRESH && vec.x > a.x && vec.x < b.x && vec.y > a.y && vec.y < b.y) return FRONT;
if (std::abs(vec.z - b.z) < THRESH && vec.x > a.x && vec.x < b.x && vec.y > a.y && vec.y < b.y) return BACK;
if (std::abs(vec.x - b.x) < THRESH && vec.z > a.z && vec.z < b.z && vec.y > a.y && vec.y < b.y) return LEFT;
if (std::abs(vec.x - a.x) < THRESH && vec.z > a.z && vec.z < b.z && vec.y > a.y && vec.y < b.y) return RIGHT;
return NONE;
}
@ -68,6 +59,6 @@ public:
return positionOffsets[f];
}
glm::vec3 a {}, b {};
glm::vec3 a {}, b {1, 1, 1};
};

View File

@ -1,5 +0,0 @@
//
// Created by aurailus on 09/10/19.
//
#include "ModelStore.h"

View File

@ -21,7 +21,7 @@ public:
private:
void getCharWidths(TextureAtlas& atlas);
glm::vec2 atlasSize;
glm::vec2 atlasSize {};
std::shared_ptr<AtlasRef> fontTex = nullptr;
std::array<unsigned short, 95> charWidths {};

View File

@ -7,7 +7,7 @@
#include <map>
#include <memory>
#include <vector>
#include <tgmath.h>
#include <ctgmath>
#include <glm/vec2.hpp>
#include <GL/glew.h>
#include <cute_files/cute_files.h>

View File

@ -31,7 +31,7 @@ int Model::fromFile(const std::string &path, const std::vector<std::shared_ptr<A
return 0;
}
int Model::fromModel(const SerializedModel& model, const std::vector<std::shared_ptr<AtlasRef>> &textures) {
int Model::fromSerialized(const SerializedModel& model, const std::vector<std::shared_ptr<AtlasRef>>& textures) {
this->textures = textures;
Assimp::Importer importer;
@ -46,9 +46,7 @@ int Model::fromModel(const SerializedModel& model, const std::vector<std::shared
loadAnimations(scene);
calcBoneHeirarchy(scene->mRootNode, scene, -1);
globalInverseTransform = glm::inverse(MatConv::AiToGLMMat4(scene->mRootNode->mTransformation));
return 0;
}

View File

@ -26,7 +26,7 @@ public:
void fromMesh(uptr<EntityMesh> mesh);
int fromFile(const std::string &path, const std::vector<std::shared_ptr<AtlasRef>> &texture);
int fromModel(const SerializedModel& model, const std::vector<std::shared_ptr<AtlasRef>> &texture);
int fromSerialized(const SerializedModel &model, const std::vector<std::shared_ptr<AtlasRef>> &texture);
void getTransformsByFrame(double frame, std::tuple<int, int> bounds, std::vector<glm::mat4>& transforms);
// void getTransformsByTime(double time, std::tuple<uint> bounds, std::vector<glm::mat4>& transforms);

View File

@ -61,21 +61,14 @@ void LuaEntity::set_display_type(const std::string &type, const std::string &arg
if (type == std::string("gameobject")) {
ItemDef& def = defs.defs().fromStr(arg);
switch (def.type) {
case ItemDef::Type::BLOCK:
entity->setModel(static_cast<BlockDef&>(def).entityModel);
break;
case ItemDef::Type::CRAFTITEM: {
entity->setModel(static_cast<CraftItemDef&>(def).entityModel);
break;
}
default:
throw "Invalid definition type.";
}
if (def.type == ItemDef::Type::BLOCK)
entity->setModel(static_cast<BlockDef&>(def).entityModel);
else if (def.type == ItemDef::Type::CRAFTITEM)
entity->setModel(static_cast<CraftItemDef&>(def).entityModel);
}
else if (type == std::string("model") && arg2 && !arg2->empty()) {
auto model = std::make_shared<Model>();
model->fromModel(defs.models().models[arg], {defs.textures().getTextureRef(*arg2)});
model->fromSerialized(defs.models().models[arg], {defs.textures().getTextureRef(*arg2)});
entity->setModel(model);
}
}

View File

@ -161,18 +161,6 @@ void ConnectScene::update() {
}
else if (p.type == PacketType::MEDIA_DONE) {
components.get<GUIRect>("loadBar")->setScale({state.renderer.getWindow().getSize().x, 32});
// std::string order = Serializer::decodeString(&p.data[0]);
//
// size_t pos = 0;
// std::string token;
// while ((pos = order.find(',')) != std::string::npos) {
// token = order.substr(0, pos);
// state.defs.lua().modsOrder.push_back(token);
// order.erase(0, pos + 1);
// }
// state.defs.lua().modsOrder.push_back(order);
statusText->setText(statusText->getText() + "Done downloading media.\nJoining world...\n");
connectState = State::DONE;

View File

@ -12,7 +12,7 @@ namespace ClientApi {
core.set_function("delay", [&](sol::function function, float delay, sol::variadic_args args) {
std::vector<sol::object> argsObject;
for (auto arg : args) argsObject.push_back(arg);
funcs.push_back({function, argsObject, delay, delay});
funcs.push_back(LocalLuaParser::DelayedFunction{function, argsObject, delay, delay});
});
}
}

View File

@ -12,7 +12,7 @@ namespace ServerApi {
core.set_function("delay", [&](sol::function function, float delay, sol::variadic_args args) {
std::vector<sol::object> argsObject;
for (auto arg : args) argsObject.push_back(arg);
funcs.push_back({function, argsObject, delay, delay});
funcs.push_back(ServerLuaParser::DelayedFunction{function, argsObject, delay, delay});
});
}
}