Merge pull request #278 from MihailRis/revert-277-pvs-fix
Revert "fix: optimization: Various PVS-Studio warnings"
This commit is contained in:
commit
6da85af19b
@ -1,6 +1,7 @@
|
||||
#include "Assets.hpp"
|
||||
|
||||
Assets::~Assets() = default;
|
||||
Assets::~Assets() {
|
||||
}
|
||||
|
||||
const std::vector<TextureAnimation>& Assets::getAnimations() {
|
||||
return animations;
|
||||
|
||||
@ -68,7 +68,7 @@ class Assets {
|
||||
std::unordered_map<std::type_index, assets_map> assets;
|
||||
std::vector<assetload::setupfunc> setupFuncs;
|
||||
public:
|
||||
Assets() = default;
|
||||
Assets() {}
|
||||
Assets(const Assets&) = delete;
|
||||
~Assets();
|
||||
|
||||
|
||||
@ -40,8 +40,7 @@ namespace AL {
|
||||
/// @param field enum value
|
||||
/// @param def default value will be returned in case of error
|
||||
/// @return field value or default
|
||||
inline glm::vec3 getSource3f(uint source, ALenum field, const glm::vec3& def= {}
|
||||
) {
|
||||
inline glm::vec3 getSource3f(uint source, ALenum field, glm::vec3 def={}) {
|
||||
glm::vec3 value = def;
|
||||
if (source == 0)
|
||||
return def;
|
||||
|
||||
@ -210,10 +210,10 @@ std::unique_ptr<Stream> audio::open_stream(std::shared_ptr<PCMStream> stream, bo
|
||||
|
||||
|
||||
void audio::set_listener(
|
||||
const glm::vec3& position,
|
||||
const glm::vec3& velocity,
|
||||
const glm::vec3& lookAt,
|
||||
const glm::vec3& up
|
||||
glm::vec3 position,
|
||||
glm::vec3 velocity,
|
||||
glm::vec3 lookAt,
|
||||
glm::vec3 up
|
||||
) {
|
||||
backend->setListener(position, velocity, lookAt, up);
|
||||
}
|
||||
@ -253,7 +253,7 @@ speakerid_t audio::play(
|
||||
if (!sound->variants.empty()) {
|
||||
size_t index = rand() % (sound->variants.size() + 1);
|
||||
if (index < sound->variants.size()) {
|
||||
sound = sound->variants[index].get();
|
||||
sound = sound->variants.at(index).get();
|
||||
}
|
||||
}
|
||||
auto speaker_ptr = sound->newInstance(priority, channel);
|
||||
@ -266,7 +266,7 @@ speakerid_t audio::play(
|
||||
}
|
||||
auto speaker = speaker_ptr.get();
|
||||
speakerid_t id = nextId++;
|
||||
speakers.try_emplace(id, std::move(speaker_ptr));
|
||||
speakers.emplace(id, std::move(speaker_ptr));
|
||||
speaker->setPosition(position);
|
||||
speaker->setVolume(volume);
|
||||
speaker->setPitch(pitch);
|
||||
@ -295,8 +295,8 @@ speakerid_t audio::play(
|
||||
}
|
||||
auto speaker = speaker_ptr.get();
|
||||
speakerid_t id = nextId++;
|
||||
streams.try_emplace(id, stream);
|
||||
speakers.try_emplace(id, std::move(speaker_ptr));
|
||||
streams.emplace(id, stream);
|
||||
speakers.emplace(id, std::move(speaker_ptr));
|
||||
stream->bindSpeaker(id);
|
||||
|
||||
speaker->setPosition(position);
|
||||
@ -310,7 +310,7 @@ speakerid_t audio::play(
|
||||
|
||||
speakerid_t audio::play_stream(
|
||||
const fs::path& file,
|
||||
const glm::vec3& position,
|
||||
glm::vec3 position,
|
||||
bool relative,
|
||||
float volume,
|
||||
float pitch,
|
||||
|
||||
@ -399,10 +399,10 @@ namespace audio {
|
||||
/// @param lookAt point the listener look at
|
||||
/// @param up camera up vector
|
||||
void set_listener(
|
||||
const glm::vec3& position,
|
||||
const glm::vec3& velocity,
|
||||
const glm::vec3& lookAt,
|
||||
const glm::vec3& up
|
||||
glm::vec3 position,
|
||||
glm::vec3 velocity,
|
||||
glm::vec3 lookAt,
|
||||
glm::vec3 up
|
||||
);
|
||||
|
||||
/// @brief Play 3D sound in the world
|
||||
@ -457,7 +457,7 @@ namespace audio {
|
||||
/// @return speaker id or 0
|
||||
speakerid_t play_stream(
|
||||
const fs::path& file,
|
||||
const glm::vec3& position,
|
||||
glm::vec3 position,
|
||||
bool relative,
|
||||
float volume,
|
||||
float pitch,
|
||||
|
||||
@ -23,7 +23,7 @@ namespace xml {
|
||||
std::string name;
|
||||
std::string text;
|
||||
public:
|
||||
Attribute() = default;
|
||||
Attribute() {};
|
||||
Attribute(std::string name, std::string text);
|
||||
|
||||
const std::string& getName() const;
|
||||
|
||||
@ -46,7 +46,8 @@ Content::Content(
|
||||
}
|
||||
}
|
||||
|
||||
Content::~Content() = default;
|
||||
Content::~Content() {
|
||||
}
|
||||
|
||||
const rigging::SkeletonConfig* Content::getSkeleton(const std::string& id) const {
|
||||
auto found = skeletons.find(id);
|
||||
|
||||
@ -119,7 +119,7 @@ public:
|
||||
|
||||
static constexpr size_t MISSING = SIZE_MAX;
|
||||
|
||||
void add(const std::string& name, dynamic::Map_sptr map) {
|
||||
void add(std::string name, dynamic::Map_sptr map) {
|
||||
indices[name] = names.size();
|
||||
names.push_back(name);
|
||||
savedData->push_back(map);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
#include "../objects/rigging.hpp"
|
||||
|
||||
ContentBuilder::~ContentBuilder() = default;
|
||||
ContentBuilder::~ContentBuilder() {}
|
||||
|
||||
void ContentBuilder::add(std::unique_ptr<ContentPackRuntime> pack) {
|
||||
packs[pack->getId()] = std::move(pack);
|
||||
|
||||
@ -85,7 +85,7 @@ bool ContentLoader::fixPackIndices(
|
||||
indexed.push_back(name);
|
||||
}
|
||||
}
|
||||
for (const auto &name : detected) {
|
||||
for (auto name : detected) {
|
||||
if (!util::contains(indexed, name)) {
|
||||
arr->put(name);
|
||||
modified = true;
|
||||
@ -176,10 +176,9 @@ void ContentLoader::loadBlock(Block& def, const std::string& name, const fs::pat
|
||||
def.hitboxes.resize(boxarr->size());
|
||||
for (uint i = 0; i < boxarr->size(); i++) {
|
||||
auto box = boxarr->list(i);
|
||||
auto& hitboxesIndex = def.hitboxes[i];
|
||||
hitboxesIndex.a = glm::vec3(box->num(0), box->num(1), box->num(2));
|
||||
hitboxesIndex.b = glm::vec3(box->num(3), box->num(4), box->num(5));
|
||||
hitboxesIndex.b += hitboxesIndex.a;
|
||||
def.hitboxes[i].a = glm::vec3(box->num(0), box->num(1), box->num(2));
|
||||
def.hitboxes[i].b = glm::vec3(box->num(3), box->num(4), box->num(5));
|
||||
def.hitboxes[i].b += def.hitboxes[i].a;
|
||||
}
|
||||
} else if ((boxarr = root->list("hitbox"))){
|
||||
AABB aabb;
|
||||
@ -252,11 +251,11 @@ void ContentLoader::loadCustomBlockModel(Block& def, dynamic::Map* primitives) {
|
||||
|
||||
if (boxarr->size() == 7)
|
||||
for (uint j = 6; j < 12; j++) {
|
||||
def.modelTextures.emplace_back(boxarr->str(6));
|
||||
def.modelTextures.push_back(boxarr->str(6));
|
||||
}
|
||||
else if (boxarr->size() == 12)
|
||||
for (uint j = 6; j < 12; j++) {
|
||||
def.modelTextures.emplace_back(boxarr->str(j));
|
||||
def.modelTextures.push_back(boxarr->str(j));
|
||||
}
|
||||
else
|
||||
for (uint j = 6; j < 12; j++) {
|
||||
@ -277,7 +276,7 @@ void ContentLoader::loadCustomBlockModel(Block& def, dynamic::Map* primitives) {
|
||||
def.modelExtraPoints.push_back(p1+xw+yh);
|
||||
def.modelExtraPoints.push_back(p1+yh);
|
||||
|
||||
def.modelTextures.emplace_back(tgonobj->str(9));
|
||||
def.modelTextures.push_back(tgonobj->str(9));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -314,7 +313,7 @@ void ContentLoader::loadEntity(EntityDef& def, const std::string& name, const fs
|
||||
auto root = files::read_json(file);
|
||||
if (auto componentsarr = root->list("components")) {
|
||||
for (size_t i = 0; i < componentsarr->size(); i++) {
|
||||
def.components.emplace_back(componentsarr->str(i));
|
||||
def.components.push_back(componentsarr->str(i));
|
||||
}
|
||||
}
|
||||
if (auto boxarr = root->list("hitbox")) {
|
||||
@ -325,12 +324,12 @@ void ContentLoader::loadEntity(EntityDef& def, const std::string& name, const fs
|
||||
if (auto sensorarr = sensorsarr->list(i)) {
|
||||
auto sensorType = sensorarr->str(0);
|
||||
if (sensorType == "aabb") {
|
||||
def.boxSensors.emplace_back(i, AABB{
|
||||
def.boxSensors.push_back({i, {
|
||||
{sensorarr->num(1), sensorarr->num(2), sensorarr->num(3)},
|
||||
{sensorarr->num(4), sensorarr->num(5), sensorarr->num(6)}
|
||||
});
|
||||
}});
|
||||
} else if (sensorType == "radius") {
|
||||
def.radialSensors.emplace_back(i, sensorarr->num(1));
|
||||
def.radialSensors.push_back({i, sensorarr->num(1)});
|
||||
} else {
|
||||
logger.error() << name << ": sensor #" << i << " - unknown type "
|
||||
<< util::quote(sensorType);
|
||||
|
||||
@ -142,4 +142,5 @@ ContentPackRuntime::ContentPackRuntime(
|
||||
{
|
||||
}
|
||||
|
||||
ContentPackRuntime::~ContentPackRuntime() = default;
|
||||
ContentPackRuntime::~ContentPackRuntime() {
|
||||
}
|
||||
|
||||
@ -5,10 +5,11 @@
|
||||
#include <queue>
|
||||
#include <sstream>
|
||||
|
||||
PacksManager::PacksManager() = default;
|
||||
PacksManager::PacksManager() {
|
||||
}
|
||||
|
||||
void PacksManager::setSources(std::vector<fs::path> sources) {
|
||||
this->sources = std::move(sources);
|
||||
this->sources = sources;
|
||||
}
|
||||
|
||||
void PacksManager::scan() {
|
||||
@ -18,7 +19,7 @@ void PacksManager::scan() {
|
||||
for (auto& folder : sources) {
|
||||
ContentPack::scanFolder(folder, packsList);
|
||||
for (auto& pack : packsList) {
|
||||
packs.try_emplace(pack.id, pack);
|
||||
packs.emplace(pack.id, pack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ namespace dynamic {
|
||||
public:
|
||||
std::vector<Value> values;
|
||||
|
||||
List() = default;
|
||||
List() {}
|
||||
List(std::vector<Value> values) : values(std::move(values)) {}
|
||||
|
||||
std::string str(size_t index) const;
|
||||
@ -79,7 +79,7 @@ namespace dynamic {
|
||||
public:
|
||||
std::unordered_map<std::string, Value> values;
|
||||
|
||||
Map() = default;
|
||||
Map() {}
|
||||
Map(std::unordered_map<std::string, Value> values)
|
||||
: values(std::move(values)) {};
|
||||
|
||||
@ -118,34 +118,34 @@ namespace dynamic {
|
||||
List_sptr list(const std::string& key) const;
|
||||
void flag(const std::string& key, bool& dst) const;
|
||||
|
||||
Map& put(const std::string& key, std::unique_ptr<Map> value) {
|
||||
Map& put(std::string key, std::unique_ptr<Map> value) {
|
||||
return put(key, Map_sptr(value.release()));
|
||||
}
|
||||
Map& put(const std::string& key, std::unique_ptr<List> value) {
|
||||
Map& put(std::string key, std::unique_ptr<List> value) {
|
||||
return put(key, List_sptr(value.release()));
|
||||
}
|
||||
Map& put(const std::string& key, int value) {
|
||||
Map& put(std::string key, int value) {
|
||||
return put(key, Value(static_cast<integer_t>(value)));
|
||||
}
|
||||
Map& put(const std::string& key, unsigned int value) {
|
||||
Map& put(std::string key, unsigned int value) {
|
||||
return put(key, Value(static_cast<integer_t>(value)));
|
||||
}
|
||||
Map& put(const std::string& key, int64_t value) {
|
||||
Map& put(std::string key, int64_t value) {
|
||||
return put(key, Value(static_cast<integer_t>(value)));
|
||||
}
|
||||
Map& put(const std::string& key, uint64_t value) {
|
||||
Map& put(std::string key, uint64_t value) {
|
||||
return put(key, Value(static_cast<integer_t>(value)));
|
||||
}
|
||||
Map& put(const std::string& key, float value) {
|
||||
Map& put(std::string key, float value) {
|
||||
return put(key, Value(static_cast<number_t>(value)));
|
||||
}
|
||||
Map& put(const std::string& key, double value) {
|
||||
Map& put(std::string key, double value) {
|
||||
return put(key, Value(static_cast<number_t>(value)));
|
||||
}
|
||||
Map& put(const std::string& key, bool value) {
|
||||
Map& put(std::string key, bool value) {
|
||||
return put(key, Value(static_cast<bool>(value)));
|
||||
}
|
||||
Map& put(const std::string& key, const char* value) {
|
||||
Map& put(std::string key, const char* value) {
|
||||
return put(key, Value(value));
|
||||
}
|
||||
Map& put(const std::string& key, const Value& value);
|
||||
|
||||
@ -55,7 +55,7 @@ static void add_world_generators() {
|
||||
WorldGenerators::addGenerator<FlatWorldGenerator>("core:flat");
|
||||
}
|
||||
|
||||
static void create_channel(Engine* engine, const std::string& name, NumberSetting& setting) {
|
||||
static void create_channel(Engine* engine, std::string name, NumberSetting& setting) {
|
||||
if (name != "master") {
|
||||
audio::create_channel(name);
|
||||
}
|
||||
|
||||
@ -73,12 +73,11 @@ std::shared_ptr<Task> WorldConverter::startTask(
|
||||
[=](){return std::make_shared<ConverterWorker>(converter);},
|
||||
[=](int&) {}
|
||||
);
|
||||
auto& converterTasks = converter->tasks;
|
||||
while (!converterTasks.empty()) {
|
||||
const convert_task& task = converterTasks.front();
|
||||
while (!converter->tasks.empty()) {
|
||||
const convert_task& task = converter->tasks.front();
|
||||
auto ptr = std::make_shared<convert_task>(task);
|
||||
pool->enqueueJob(ptr);
|
||||
converterTasks.pop();
|
||||
converter->tasks.pop();
|
||||
}
|
||||
pool->setOnComplete([=]() {
|
||||
converter->write();
|
||||
|
||||
@ -47,7 +47,8 @@ WorldFiles::WorldFiles(const fs::path& directory, const DebugSettings& settings)
|
||||
regions.doWriteLights = doWriteLights;
|
||||
}
|
||||
|
||||
WorldFiles::~WorldFiles() = default;
|
||||
WorldFiles::~WorldFiles() {
|
||||
}
|
||||
|
||||
void WorldFiles::createDirectories() {
|
||||
fs::create_directories(directory / fs::path("data"));
|
||||
|
||||
@ -56,7 +56,8 @@ WorldRegion::WorldRegion()
|
||||
sizes(std::make_unique<uint32_t[]>(REGION_CHUNKS_COUNT))
|
||||
{}
|
||||
|
||||
WorldRegion::~WorldRegion() = default;
|
||||
WorldRegion::~WorldRegion() {
|
||||
}
|
||||
|
||||
void WorldRegion::setUnsaved(bool unsaved) {
|
||||
this->unsaved = unsaved;
|
||||
@ -97,7 +98,8 @@ WorldRegions::WorldRegions(const fs::path& directory) : directory(directory) {
|
||||
layers[REGION_LAYER_ENTITIES].folder = directory/fs::path("entities");
|
||||
}
|
||||
|
||||
WorldRegions::~WorldRegions() = default;
|
||||
WorldRegions::~WorldRegions() {
|
||||
}
|
||||
|
||||
WorldRegion* WorldRegions::getRegion(int x, int z, int layer) {
|
||||
RegionsLayer& regions = layers[layer];
|
||||
@ -196,7 +198,7 @@ ubyte* WorldRegions::getData(int x, int z, int layer, uint32_t& size) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
regfile_ptr WorldRegions::useRegFile(const glm::ivec3& coord) {
|
||||
regfile_ptr WorldRegions::useRegFile(glm::ivec3 coord) {
|
||||
auto* file = openRegFiles[coord].get();
|
||||
file->inUse = true;
|
||||
return regfile_ptr(file, ®FilesCv);
|
||||
@ -208,7 +210,7 @@ void WorldRegions::closeRegFile(glm::ivec3 coord) {
|
||||
}
|
||||
|
||||
// Marks regfile as used and unmarks when shared_ptr dies
|
||||
regfile_ptr WorldRegions::getRegFile(const glm::ivec3& coord, bool create) {
|
||||
regfile_ptr WorldRegions::getRegFile(glm::ivec3 coord, bool create) {
|
||||
{
|
||||
std::lock_guard lock(regFilesMutex);
|
||||
const auto found = openRegFiles.find(coord);
|
||||
@ -225,7 +227,7 @@ regfile_ptr WorldRegions::getRegFile(const glm::ivec3& coord, bool create) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
regfile_ptr WorldRegions::createRegFile(const glm::ivec3& coord) {
|
||||
regfile_ptr WorldRegions::createRegFile(glm::ivec3 coord) {
|
||||
fs::path file = layers[coord[2]].folder/getRegionFilename(coord[0], coord[1]);
|
||||
if (!fs::exists(file)) {
|
||||
return nullptr;
|
||||
@ -352,7 +354,7 @@ static std::unique_ptr<ubyte[]> write_inventories(Chunk* chunk, uint& datasize)
|
||||
}
|
||||
|
||||
/// @brief Store chunk data (voxels and lights) in region (existing or new)
|
||||
void WorldRegions::put(Chunk* chunk, const std::vector<ubyte>& entitiesData){
|
||||
void WorldRegions::put(Chunk* chunk, std::vector<ubyte> entitiesData){
|
||||
assert(chunk != nullptr);
|
||||
if (!chunk->flags.lighted) {
|
||||
return;
|
||||
|
||||
@ -149,10 +149,10 @@ class WorldRegions {
|
||||
|
||||
ubyte* getData(int x, int z, int layer, uint32_t& size);
|
||||
|
||||
regfile_ptr getRegFile(const glm::ivec3& coord, bool create=true);
|
||||
regfile_ptr getRegFile(glm::ivec3 coord, bool create=true);
|
||||
void closeRegFile(glm::ivec3 coord);
|
||||
regfile_ptr useRegFile(const glm::ivec3& coord);
|
||||
regfile_ptr createRegFile(const glm::ivec3& coord);
|
||||
regfile_ptr useRegFile(glm::ivec3 coord);
|
||||
regfile_ptr createRegFile(glm::ivec3 coord);
|
||||
|
||||
fs::path getRegionFilename(int x, int y) const;
|
||||
|
||||
@ -172,7 +172,7 @@ public:
|
||||
~WorldRegions();
|
||||
|
||||
/// @brief Put all chunk data to regions
|
||||
void put(Chunk* chunk, const std::vector<ubyte>& entitiesData);
|
||||
void put(Chunk* chunk, std::vector<ubyte> entitiesData);
|
||||
|
||||
/// @brief Store data in specified region
|
||||
/// @param x chunk.x
|
||||
|
||||
@ -214,7 +214,7 @@ std::vector<std::string> ResPaths::listdirRaw(const std::string& folderName) con
|
||||
continue;
|
||||
for (const auto& entry : fs::directory_iterator(folder)) {
|
||||
auto name = entry.path().filename().u8string();
|
||||
entries.emplace_back(root.name+":"+folderName+"/"+name);
|
||||
entries.push_back(root.name+":"+folderName+"/"+name);
|
||||
}
|
||||
}
|
||||
{
|
||||
@ -223,7 +223,7 @@ std::vector<std::string> ResPaths::listdirRaw(const std::string& folderName) con
|
||||
return entries;
|
||||
for (const auto& entry : fs::directory_iterator(folder)) {
|
||||
auto name = entry.path().filename().u8string();
|
||||
entries.emplace_back("core:"+folderName+"/"+name);
|
||||
entries.push_back("core:"+folderName+"/"+name);
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
|
||||
@ -103,7 +103,7 @@ std::string files::read_string(const fs::path& filename) {
|
||||
return std::string((const char*)bytes.get(), size);
|
||||
}
|
||||
|
||||
bool files::write_string(const fs::path& filename, const std::string& content) {
|
||||
bool files::write_string(const fs::path& filename, const std::string content) {
|
||||
std::ofstream file(filename);
|
||||
if (!file) {
|
||||
return false;
|
||||
|
||||
@ -40,7 +40,7 @@ namespace files {
|
||||
uint append_bytes(const fs::path& file, const ubyte* data, size_t size);
|
||||
|
||||
/// @brief Write string to the file
|
||||
bool write_string(const fs::path& filename, const std::string& content);
|
||||
bool write_string(const fs::path& filename, const std::string content);
|
||||
|
||||
/// @brief Write dynamic data to the JSON file
|
||||
/// @param nice if true, human readable format will be used, otherwise minimal
|
||||
|
||||
@ -38,7 +38,8 @@ ContentGfxCache::ContentGfxCache(const Content* content, Assets* assets) : conte
|
||||
}
|
||||
}
|
||||
|
||||
ContentGfxCache::~ContentGfxCache() = default;
|
||||
ContentGfxCache::~ContentGfxCache() {
|
||||
}
|
||||
|
||||
const Content* ContentGfxCache::getContent() const {
|
||||
return content;
|
||||
|
||||
@ -81,7 +81,8 @@ LevelFrontend::LevelFrontend(
|
||||
);
|
||||
}
|
||||
|
||||
LevelFrontend::~LevelFrontend() = default;
|
||||
LevelFrontend::~LevelFrontend() {
|
||||
}
|
||||
|
||||
Level* LevelFrontend::getLevel() const {
|
||||
return level;
|
||||
|
||||
@ -314,7 +314,7 @@ void Hud::openInventory() {
|
||||
}
|
||||
|
||||
void Hud::openInventory(
|
||||
const glm::ivec3& block,
|
||||
glm::ivec3 block,
|
||||
UiDocument* doc,
|
||||
std::shared_ptr<Inventory> blockinv,
|
||||
bool playerInventory
|
||||
@ -406,9 +406,9 @@ void Hud::add(const HudElement& element) {
|
||||
using namespace dynamic;
|
||||
|
||||
gui->add(element.getNode());
|
||||
auto invview = std::dynamic_pointer_cast<InventoryView>(element.getNode());
|
||||
auto document = element.getDocument();
|
||||
if (document) {
|
||||
auto invview = std::dynamic_pointer_cast<InventoryView>(element.getNode());
|
||||
auto inventory = invview ? invview->getInventory() : nullptr;
|
||||
std::vector<Value> args;
|
||||
args.emplace_back(inventory ? inventory.get()->getId() : 0);
|
||||
|
||||
@ -140,12 +140,12 @@ public:
|
||||
/// @brief Show block inventory in inventory-mode
|
||||
/// @param block block position
|
||||
/// @param doc block ui layout
|
||||
/// @param blockinv block inventory
|
||||
/// @param blockInv block inventory
|
||||
/// @param playerInventory show player inventory too
|
||||
void openInventory(
|
||||
const glm::ivec3& block,
|
||||
glm::ivec3 block,
|
||||
UiDocument* doc,
|
||||
std::shared_ptr<Inventory> blockinv,
|
||||
std::shared_ptr<Inventory> blockInv,
|
||||
bool playerInventory
|
||||
);
|
||||
|
||||
|
||||
@ -146,7 +146,7 @@ void langs::load(const fs::path& resdir,
|
||||
if (locale != fallback) {
|
||||
load(resdir, locale, packs, *lang.get());
|
||||
}
|
||||
current = std::move(lang);
|
||||
current.reset(lang.release());
|
||||
}
|
||||
|
||||
void langs::setup(const fs::path& resdir,
|
||||
|
||||
@ -19,7 +19,8 @@ Atlas::Atlas(
|
||||
}
|
||||
}
|
||||
|
||||
Atlas::~Atlas() = default;
|
||||
Atlas::~Atlas() {
|
||||
}
|
||||
|
||||
void Atlas::prepare() {
|
||||
texture = Texture::from(image.get());
|
||||
|
||||
@ -47,7 +47,7 @@ class AtlasBuilder {
|
||||
std::vector<atlasentry> entries;
|
||||
std::set<std::string> names;
|
||||
public:
|
||||
AtlasBuilder() = default;
|
||||
AtlasBuilder() {}
|
||||
void add(const std::string& name, std::unique_ptr<ImageData> image);
|
||||
bool has(const std::string& name) const;
|
||||
const std::set<std::string>& getNames() { return names; };
|
||||
|
||||
@ -59,8 +59,8 @@ void Batch2D::vertex(
|
||||
buffer[index++] = a;
|
||||
}
|
||||
void Batch2D::vertex(
|
||||
const glm::vec2& point,
|
||||
const glm::vec2& uvpoint,
|
||||
glm::vec2 point,
|
||||
glm::vec2 uvpoint,
|
||||
float r, float g, float b, float a
|
||||
) {
|
||||
buffer[index++] = point.x;
|
||||
@ -138,7 +138,7 @@ void Batch2D::rect(
|
||||
UVRegion region,
|
||||
bool flippedX,
|
||||
bool flippedY,
|
||||
const glm::vec4& tint
|
||||
glm::vec4 tint
|
||||
) {
|
||||
if (index + 6*B2D_VERTEX_SIZE >= capacity) {
|
||||
flush();
|
||||
@ -322,13 +322,11 @@ void Batch2D::rect(
|
||||
vertex(v1, glm::vec2(0, 0), r2,g2,b2,1.0f);
|
||||
}
|
||||
|
||||
void Batch2D::sprite(float x, float y, float w, float h, const UVRegion& region,
|
||||
const glm::vec4& tint){
|
||||
void Batch2D::sprite(float x, float y, float w, float h, const UVRegion& region, glm::vec4 tint){
|
||||
rect(x, y, w, h, region.u1, region.v1, region.u2-region.u1, region.v2-region.v1, tint.r, tint.g, tint.b, tint.a);
|
||||
}
|
||||
|
||||
void Batch2D::sprite(float x, float y, float w, float h, int atlasRes, int index,
|
||||
const glm::vec4& tint){
|
||||
void Batch2D::sprite(float x, float y, float w, float h, int atlasRes, int index, glm::vec4 tint){
|
||||
float scale = 1.0f / (float)atlasRes;
|
||||
float u = (index % atlasRes) * scale;
|
||||
float v = 1.0f - ((index / atlasRes) * scale) - scale;
|
||||
|
||||
@ -31,8 +31,8 @@ class Batch2D : public Flushable {
|
||||
);
|
||||
|
||||
void vertex(
|
||||
const glm::vec2& point,
|
||||
const glm::vec2& uvpoint,
|
||||
glm::vec2 point,
|
||||
glm::vec2 uvpoint,
|
||||
float r, float g, float b, float a
|
||||
);
|
||||
|
||||
@ -44,13 +44,11 @@ public:
|
||||
void texture(Texture* texture);
|
||||
void untexture();
|
||||
void setRegion(UVRegion region);
|
||||
void sprite(float x, float y, float w, float h, const UVRegion& region,
|
||||
const glm::vec4& tint);
|
||||
void sprite(float x, float y, float w, float h, int atlasRes, int index,
|
||||
const glm::vec4& tint);
|
||||
void sprite(float x, float y, float w, float h, const UVRegion& region, glm::vec4 tint);
|
||||
void sprite(float x, float y, float w, float h, int atlasRes, int index, glm::vec4 tint);
|
||||
void point(float x, float y, float r, float g, float b, float a);
|
||||
|
||||
inline void setColor(const glm::vec4& color) {
|
||||
inline void setColor(glm::vec4 color) {
|
||||
this->color = color;
|
||||
}
|
||||
inline glm::vec4 getColor() const {
|
||||
@ -71,7 +69,7 @@ public:
|
||||
float ox, float oy,
|
||||
float angle, UVRegion region,
|
||||
bool flippedX, bool flippedY,
|
||||
const glm::vec4& tint
|
||||
glm::vec4 tint
|
||||
);
|
||||
|
||||
void rect(float x, float y, float w, float h);
|
||||
|
||||
@ -51,7 +51,7 @@ void Batch3D::vertex(
|
||||
buffer[index++] = a;
|
||||
}
|
||||
void Batch3D::vertex(
|
||||
const glm::vec3& coord, float u, float v,
|
||||
glm::vec3 coord, float u, float v,
|
||||
float r, float g, float b, float a
|
||||
) {
|
||||
buffer[index++] = coord.x;
|
||||
@ -65,8 +65,8 @@ void Batch3D::vertex(
|
||||
buffer[index++] = a;
|
||||
}
|
||||
void Batch3D::vertex(
|
||||
const glm::vec3& point,
|
||||
const glm::vec2& uvpoint,
|
||||
glm::vec3 point,
|
||||
glm::vec2 uvpoint,
|
||||
float r, float g, float b, float a
|
||||
) {
|
||||
buffer[index++] = point.x;
|
||||
@ -118,12 +118,12 @@ void Batch3D::texture(Texture* new_texture){
|
||||
}
|
||||
|
||||
void Batch3D::sprite(
|
||||
const glm::vec3& pos,
|
||||
const glm::vec3& up,
|
||||
const glm::vec3& right,
|
||||
glm::vec3 pos,
|
||||
glm::vec3 up,
|
||||
glm::vec3 right,
|
||||
float w, float h,
|
||||
const UVRegion& uv,
|
||||
const glm::vec4& color
|
||||
const UVRegion& uv,
|
||||
glm::vec4 color
|
||||
){
|
||||
const float r = color.r;
|
||||
const float g = color.g;
|
||||
@ -245,11 +245,11 @@ void Batch3D::blockCube(
|
||||
cube((1.0f - size) * -0.5f, size, texfaces, tint, shading);
|
||||
}
|
||||
|
||||
void Batch3D::point(const glm::vec3& coord, const glm::vec2& uv, const glm::vec4& tint) {
|
||||
void Batch3D::point(glm::vec3 coord, glm::vec2 uv, glm::vec4 tint) {
|
||||
vertex(coord, uv, tint.r, tint.g, tint.b, tint.a);
|
||||
}
|
||||
|
||||
void Batch3D::point(const glm::vec3& coord, const glm::vec4& tint) {
|
||||
void Batch3D::point(glm::vec3 coord, glm::vec4 tint) {
|
||||
point(coord, glm::vec2(), tint);
|
||||
}
|
||||
|
||||
|
||||
@ -27,13 +27,12 @@ class Batch3D : public Flushable {
|
||||
float r, float g, float b, float a
|
||||
);
|
||||
void vertex(
|
||||
const glm::vec3& coord,
|
||||
glm::vec3 coord,
|
||||
float u, float v,
|
||||
float r, float g, float b, float a
|
||||
);
|
||||
void vertex(
|
||||
const glm::vec3& point,
|
||||
const glm::vec2& uvpoint,
|
||||
glm::vec3 point, glm::vec2 uvpoint,
|
||||
float r, float g, float b, float a
|
||||
);
|
||||
void face(
|
||||
@ -50,18 +49,12 @@ public:
|
||||
|
||||
void begin();
|
||||
void texture(Texture* texture);
|
||||
void sprite(
|
||||
const glm::vec3& pos,
|
||||
const glm::vec3& up,
|
||||
const glm::vec3& right, float w, float h, const UVRegion& uv,
|
||||
const glm::vec4& color
|
||||
);
|
||||
void sprite(glm::vec3 pos, glm::vec3 up, glm::vec3 right, float w, float h, const UVRegion& uv, glm::vec4 tint);
|
||||
void xSprite(float w, float h, const UVRegion& uv, const glm::vec4 tint, bool shading=true);
|
||||
void cube(const glm::vec3 coords, const glm::vec3 size, const UVRegion(&texfaces)[6], const glm::vec4 tint, bool shading=true);
|
||||
void blockCube(const glm::vec3 size, const UVRegion(&texfaces)[6], const glm::vec4 tint, bool shading=true);
|
||||
void point(
|
||||
const glm::vec3& coord, const glm::vec2& uv, const glm::vec4& tint);
|
||||
void point(const glm::vec3& coord, const glm::vec4& tint);
|
||||
void point(glm::vec3 pos, glm::vec2 uv, glm::vec4 tint);
|
||||
void point(glm::vec3 pos, glm::vec4 tint);
|
||||
void flush() override;
|
||||
void flushPoints();
|
||||
};
|
||||
|
||||
@ -148,7 +148,7 @@ void DrawContext::setBlendMode(BlendMode mode) {
|
||||
set_blend_mode(mode);
|
||||
}
|
||||
|
||||
void DrawContext::setScissors(const glm::vec4& area) {
|
||||
void DrawContext::setScissors(glm::vec4 area) {
|
||||
Window::pushScissor(area);
|
||||
scissorsCount++;
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ public:
|
||||
void setDepthTest(bool flag);
|
||||
void setCullFace(bool flag);
|
||||
void setBlendMode(BlendMode mode);
|
||||
void setScissors(const glm::vec4& area);
|
||||
void setScissors(glm::vec4 area);
|
||||
void setLineWidth(float width);
|
||||
};
|
||||
|
||||
|
||||
@ -12,7 +12,8 @@ Font::Font(std::vector<std::unique_ptr<Texture>> pages, int lineHeight, int yoff
|
||||
: lineHeight(lineHeight), yoffset(yoffset), pages(std::move(pages)) {
|
||||
}
|
||||
|
||||
Font::~Font() = default;
|
||||
Font::~Font(){
|
||||
}
|
||||
|
||||
int Font::getYOffset() const {
|
||||
return yoffset;
|
||||
|
||||
@ -41,7 +41,8 @@ ImageData::ImageData(ImageFormat format, uint width, uint height, const ubyte* d
|
||||
std::memcpy(this->data.get(), data, width * height * pixsize);
|
||||
}
|
||||
|
||||
ImageData::~ImageData() = default;
|
||||
ImageData::~ImageData() {
|
||||
}
|
||||
|
||||
void ImageData::flipX() {
|
||||
switch (format) {
|
||||
|
||||
@ -18,7 +18,7 @@ public:
|
||||
LineBatch(size_t capacity=4096);
|
||||
~LineBatch();
|
||||
|
||||
inline void line(const glm::vec3 &a, const glm::vec3 &b, const glm::vec4 &color) {
|
||||
inline void line(const glm::vec3 a, const glm::vec3 b, const glm::vec4 color) {
|
||||
line(a.x, a.y, a.z, b.x, b.y, b.z, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
void line(float x1, float y1, float z1, float x2, float y2, float z2,
|
||||
@ -26,7 +26,7 @@ public:
|
||||
void box(float x, float y, float z, float w, float h, float d,
|
||||
float r, float g, float b, float a);
|
||||
|
||||
inline void box(const glm::vec3 &xyz, const glm::vec3 &whd, const glm::vec4 &rgba) {
|
||||
inline void box(glm::vec3 xyz, glm::vec3 whd, glm::vec4 rgba) {
|
||||
box(xyz.x, xyz.y, xyz.z, whd.x, whd.y, whd.z,
|
||||
rgba.r, rgba.g, rgba.b, rgba.a);
|
||||
}
|
||||
|
||||
@ -8,11 +8,7 @@ inline constexpr glm::vec3 X(1, 0, 0);
|
||||
inline constexpr glm::vec3 Y(0, 1, 0);
|
||||
inline constexpr glm::vec3 Z(0, 0, 1);
|
||||
|
||||
void Mesh::addPlane(
|
||||
const glm::vec3 &pos,
|
||||
const glm::vec3 &right,
|
||||
const glm::vec3 &up,
|
||||
const glm::vec3 &norm) {
|
||||
void Mesh::addPlane(glm::vec3 pos, glm::vec3 right, glm::vec3 up, glm::vec3 norm) {
|
||||
vertices.push_back({pos-right-up, {0,0}, norm});
|
||||
vertices.push_back({pos+right-up, {1,0}, norm});
|
||||
vertices.push_back({pos+right+up, {1,1}, norm});
|
||||
@ -22,7 +18,7 @@ void Mesh::addPlane(
|
||||
vertices.push_back({pos-right+up, {0,1}, norm});
|
||||
}
|
||||
|
||||
void Mesh::addBox(const glm::vec3 &pos, const glm::vec3 &size) {
|
||||
void Mesh::addBox(glm::vec3 pos, glm::vec3 size) {
|
||||
addPlane(pos+Z*size, X*size, Y*size, Z);
|
||||
addPlane(pos-Z*size, -X*size, Y*size, -Z);
|
||||
|
||||
|
||||
@ -16,12 +16,8 @@ namespace model {
|
||||
std::string texture;
|
||||
std::vector<Vertex> vertices;
|
||||
|
||||
void addPlane(
|
||||
const glm::vec3& pos,
|
||||
const glm::vec3& right,
|
||||
const glm::vec3& up,
|
||||
const glm::vec3& norm);
|
||||
void addBox(const glm::vec3& pos, const glm::vec3& size);
|
||||
void addPlane(glm::vec3 pos, glm::vec3 right, glm::vec3 up, glm::vec3 norm);
|
||||
void addBox(glm::vec3 pos, glm::vec3 size);
|
||||
};
|
||||
|
||||
struct Model {
|
||||
|
||||
@ -18,7 +18,8 @@ PostProcessing::PostProcessing() {
|
||||
quadMesh = std::make_unique<Mesh>(vertices, 6, attrs);
|
||||
}
|
||||
|
||||
PostProcessing::~PostProcessing() = default;
|
||||
PostProcessing::~PostProcessing() {
|
||||
}
|
||||
|
||||
void PostProcessing::use(DrawContext& context) {
|
||||
const auto& vp = context.getViewport();
|
||||
|
||||
@ -32,7 +32,7 @@ uint Shader::getUniformLocation(const std::string& name) {
|
||||
auto found = uniformLocations.find(name);
|
||||
if (found == uniformLocations.end()) {
|
||||
uint location = glGetUniformLocation(id, name.c_str());
|
||||
uniformLocations.try_emplace(name, location);
|
||||
uniformLocations.emplace(name, location);
|
||||
return location;
|
||||
}
|
||||
return found->second;
|
||||
@ -54,11 +54,11 @@ void Shader::uniform2f(const std::string& name, float x, float y){
|
||||
glUniform2f(getUniformLocation(name), x, y);
|
||||
}
|
||||
|
||||
void Shader::uniform2f(const std::string& name, const glm::vec2& xy){
|
||||
void Shader::uniform2f(const std::string& name, glm::vec2 xy){
|
||||
glUniform2f(getUniformLocation(name), xy.x, xy.y);
|
||||
}
|
||||
|
||||
void Shader::uniform2i(const std::string& name, const glm::ivec2& xy){
|
||||
void Shader::uniform2i(const std::string& name, glm::ivec2 xy){
|
||||
glUniform2i(getUniformLocation(name), xy.x, xy.y);
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ void Shader::uniform3f(const std::string& name, float x, float y, float z){
|
||||
glUniform3f(getUniformLocation(name), x,y,z);
|
||||
}
|
||||
|
||||
void Shader::uniform3f(const std::string& name, const glm::vec3& xyz){
|
||||
void Shader::uniform3f(const std::string& name, glm::vec3 xyz){
|
||||
glUniform3f(getUniformLocation(name), xyz.x, xyz.y, xyz.z);
|
||||
}
|
||||
|
||||
|
||||
@ -26,10 +26,10 @@ public:
|
||||
void uniform1i(const std::string& name, int x);
|
||||
void uniform1f(const std::string& name, float x);
|
||||
void uniform2f(const std::string& name, float x, float y);
|
||||
void uniform2f(const std::string& name, const glm::vec2& xy);
|
||||
void uniform2i(const std::string& name, const glm::ivec2& xy);
|
||||
void uniform2f(const std::string& name, glm::vec2 xy);
|
||||
void uniform2i(const std::string& name, glm::ivec2 xy);
|
||||
void uniform3f(const std::string& name, float x, float y, float z);
|
||||
void uniform3f(const std::string& name, const glm::vec3& xyz);
|
||||
void uniform3f(const std::string& name, glm::vec3 xyz);
|
||||
|
||||
/// @brief Create shader program using vertex and fragment shaders source.
|
||||
/// @param vertexFile vertex shader file name
|
||||
|
||||
@ -22,7 +22,7 @@ struct Frame {
|
||||
class TextureAnimation {
|
||||
public:
|
||||
TextureAnimation(Texture* srcTex, Texture* dstTex) : srcTexture(srcTex), dstTexture(dstTex) {};
|
||||
~TextureAnimation() = default;
|
||||
~TextureAnimation() {};
|
||||
|
||||
void addFrame(const Frame& frame) { frames.emplace_back(frame); };
|
||||
|
||||
|
||||
@ -50,10 +50,9 @@ std::unique_ptr<ImageData> BlocksPreview::draw(
|
||||
}
|
||||
offset = glm::vec3(1, 1, 0.0f);
|
||||
shader->uniformMatrix("u_apply", glm::translate(glm::mat4(1.0f), offset));
|
||||
glm::vec3 scaledSize = glm::vec3(size * 0.63f);
|
||||
batch->cube(
|
||||
-hitbox * scaledSize * 0.5f * glm::vec3(1,1,-1),
|
||||
hitbox * scaledSize,
|
||||
-hitbox * glm::vec3(size * 0.63f)*0.5f * glm::vec3(1,1,-1),
|
||||
hitbox * glm::vec3(size * 0.63f),
|
||||
texfaces, glm::vec4(1.0f),
|
||||
!def->rt.emissive
|
||||
);
|
||||
|
||||
@ -35,7 +35,7 @@ struct DecomposedMat4 {
|
||||
glm::vec4 perspective;
|
||||
};
|
||||
|
||||
static glm::mat4 extract_rotation(const glm::mat4& matrix) {
|
||||
static glm::mat4 extract_rotation(glm::mat4 matrix) {
|
||||
DecomposedMat4 decomposed = {};
|
||||
glm::quat rotation;
|
||||
glm::decompose(
|
||||
@ -64,12 +64,11 @@ ModelBatch::ModelBatch(size_t capacity, Assets* assets, Chunks* chunks)
|
||||
blank = Texture::from(&image);
|
||||
}
|
||||
|
||||
ModelBatch::~ModelBatch() = default;
|
||||
ModelBatch::~ModelBatch() {
|
||||
}
|
||||
|
||||
void ModelBatch::draw(const model::Mesh& mesh,
|
||||
const glm::mat4& matrix,
|
||||
const glm::mat3& rotation,
|
||||
const glm::vec3& tint,
|
||||
void ModelBatch::draw(const model::Mesh& mesh, const glm::mat4& matrix,
|
||||
const glm::mat3& rotation, glm::vec3 tint,
|
||||
const texture_names_map* varTextures) {
|
||||
glm::vec3 gpos = matrix * glm::vec4(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
light_t light = chunks->getLight(floor(gpos.x), floor(gpos.y), floor(gpos.z));
|
||||
@ -96,9 +95,8 @@ void ModelBatch::draw(const model::Mesh& mesh,
|
||||
}
|
||||
}
|
||||
|
||||
void ModelBatch::draw(
|
||||
const glm::mat4& matrix,
|
||||
const glm::vec3& tint,
|
||||
void ModelBatch::draw(glm::mat4 matrix,
|
||||
glm::vec3 tint,
|
||||
const model::Model* model,
|
||||
const texture_names_map* varTextures) {
|
||||
for (const auto& mesh : model->meshes) {
|
||||
|
||||
@ -37,10 +37,7 @@ class ModelBatch {
|
||||
static inline glm::vec3 SUN_VECTOR {0.411934f, 0.863868f, -0.279161f};
|
||||
|
||||
inline void vertex(
|
||||
const glm::vec3& pos,
|
||||
const glm::vec2& uv,
|
||||
const glm::vec4& light,
|
||||
const glm::vec3& tint
|
||||
glm::vec3 pos, glm::vec2 uv, glm::vec4 light, glm::vec3 tint
|
||||
) {
|
||||
float* buffer = this->buffer.get();
|
||||
buffer[index++] = pos.x;
|
||||
@ -67,8 +64,8 @@ class ModelBatch {
|
||||
|
||||
void draw(const model::Mesh& mesh,
|
||||
const glm::mat4& matrix,
|
||||
const glm::mat3& rotation,
|
||||
const glm::vec3& tint,
|
||||
const glm::mat3& rotation,
|
||||
glm::vec3 tint,
|
||||
const texture_names_map* varTextures);
|
||||
void setTexture(const std::string& name,
|
||||
const texture_names_map* varTextures);
|
||||
@ -87,9 +84,8 @@ public:
|
||||
ModelBatch(size_t capacity, Assets* assets, Chunks* chunks);
|
||||
~ModelBatch();
|
||||
|
||||
void draw(
|
||||
const glm::mat4& matrix,
|
||||
const glm::vec3& tint,
|
||||
void draw(glm::mat4 matrix,
|
||||
glm::vec3 tint,
|
||||
const model::Model* model,
|
||||
const texture_names_map* varTextures);
|
||||
void render();
|
||||
|
||||
@ -55,7 +55,8 @@ Skybox::Skybox(uint size, Shader* shader)
|
||||
});
|
||||
}
|
||||
|
||||
Skybox::~Skybox() = default;
|
||||
Skybox::~Skybox() {
|
||||
}
|
||||
|
||||
void Skybox::drawBackground(Camera* camera, Assets* assets, int width, int height) {
|
||||
auto backShader = assets->get<Shader>("background");
|
||||
|
||||
@ -75,7 +75,8 @@ WorldRenderer::WorldRenderer(Engine* engine, LevelFrontend* frontend, Player* pl
|
||||
);
|
||||
}
|
||||
|
||||
WorldRenderer::~WorldRenderer() = default;
|
||||
WorldRenderer::~WorldRenderer() {
|
||||
}
|
||||
|
||||
bool WorldRenderer::drawChunk(
|
||||
size_t index,
|
||||
@ -230,29 +231,26 @@ void WorldRenderer::renderBlockSelection() {
|
||||
: block->hitboxes;
|
||||
|
||||
lineBatch->lineWidth(2.0f);
|
||||
constexpr auto boxOffset = glm::vec3(0.02);
|
||||
constexpr auto boxColor = glm::vec4(0.f, 0.f, 0.f, 0.5f);
|
||||
for (auto& hitbox: hitboxes) {
|
||||
const glm::vec3 center = glm::vec3(pos) + hitbox.center();
|
||||
const glm::vec3 size = hitbox.size();
|
||||
lineBatch->box(center, size + boxOffset, boxColor);
|
||||
lineBatch->box(center, size + glm::vec3(0.02), glm::vec4(0.f, 0.f, 0.f, 0.5f));
|
||||
if (player->debug) {
|
||||
lineBatch->line(point, point+norm*0.5f, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f));
|
||||
}
|
||||
}
|
||||
lineBatch->flush();
|
||||
}
|
||||
|
||||
void WorldRenderer::renderLines(
|
||||
Camera* camera, Shader* linesShader, const DrawContext& pctx
|
||||
) {
|
||||
auto ctx = pctx.sub(lineBatch.get());
|
||||
linesShader->use();
|
||||
linesShader->uniformMatrix("u_projview", camera->getProjView());
|
||||
if (player->selection.vox.id != BLOCK_VOID) {
|
||||
renderBlockSelection();
|
||||
}
|
||||
if (player->debug && showEntitiesDebug) {
|
||||
auto ctx = pctx.sub(lineBatch.get());
|
||||
level->entities->renderDebug(*lineBatch, *frustumCulling, ctx);
|
||||
}
|
||||
}
|
||||
@ -343,12 +341,12 @@ void WorldRenderer::draw(
|
||||
ctx.setDepthTest(true);
|
||||
ctx.setCullFace(true);
|
||||
renderLevel(ctx, camera, settings, delta, pause);
|
||||
|
||||
// Debug lines
|
||||
if (hudVisible){
|
||||
renderLines(camera, linesShader, ctx);
|
||||
}
|
||||
}
|
||||
// Debug lines
|
||||
|
||||
if (hudVisible && player->debug) {
|
||||
renderDebugLines(wctx, camera, linesShader);
|
||||
}
|
||||
|
||||
@ -44,7 +44,8 @@ GUI::GUI() {
|
||||
container->add(tooltip);
|
||||
}
|
||||
|
||||
GUI::~GUI() = default;
|
||||
GUI::~GUI() {
|
||||
}
|
||||
|
||||
std::shared_ptr<Menu> GUI::getMenu() {
|
||||
return menu;
|
||||
|
||||
@ -52,7 +52,7 @@ InventoryBuilder::InventoryBuilder() {
|
||||
|
||||
void InventoryBuilder::addGrid(
|
||||
int cols, int count,
|
||||
const glm::vec2 &pos,
|
||||
glm::vec2 pos,
|
||||
int padding,
|
||||
bool addpanel,
|
||||
const SlotLayout& slotLayout
|
||||
@ -126,7 +126,7 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
|
||||
langs::get(util::str2wstr_utf8(def->caption))
|
||||
);
|
||||
} else {
|
||||
tooltip.clear();
|
||||
tooltip = L"";
|
||||
}
|
||||
}
|
||||
prevItem = itemid;
|
||||
@ -381,7 +381,7 @@ void InventoryView::setPos(glm::vec2 pos) {
|
||||
Container::setPos(pos - origin);
|
||||
}
|
||||
|
||||
void InventoryView::setOrigin(const glm::vec2 &origin) {
|
||||
void InventoryView::setOrigin(glm::vec2 origin) {
|
||||
this->origin = origin;
|
||||
}
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ namespace gui {
|
||||
|
||||
virtual void setPos(glm::vec2 pos) override;
|
||||
|
||||
void setOrigin(const glm::vec2 &origin);
|
||||
void setOrigin(glm::vec2 origin);
|
||||
glm::vec2 getOrigin() const;
|
||||
|
||||
void setSelected(int index);
|
||||
@ -130,7 +130,7 @@ namespace gui {
|
||||
/// @param slotLayout slot settings (index and position are ignored)
|
||||
void addGrid(
|
||||
int cols, int count,
|
||||
const glm::vec2 &pos,
|
||||
glm::vec2 pos,
|
||||
int padding,
|
||||
bool addpanel,
|
||||
const SlotLayout& slotLayout
|
||||
|
||||
@ -145,7 +145,7 @@ uint Label::getLineByYOffset(int offset) const {
|
||||
|
||||
uint Label::getLineByTextIndex(size_t index) const {
|
||||
for (size_t i = 0; i < cache.lines.size(); i++) {
|
||||
if (cache.lines[i].offset > index) {
|
||||
if (cache.lines.at(i).offset > index) {
|
||||
return i-1;
|
||||
}
|
||||
}
|
||||
@ -195,7 +195,7 @@ void Label::draw(const DrawContext* pctx, Assets* assets) {
|
||||
|
||||
if (multiline) {
|
||||
for (size_t i = 0; i < cache.lines.size(); i++) {
|
||||
auto& line = cache.lines[i];
|
||||
auto& line = cache.lines.at(i);
|
||||
size_t offset = line.offset;
|
||||
std::wstring_view view(text.c_str()+offset, text.length()-offset);
|
||||
if (i < cache.lines.size()-1) {
|
||||
|
||||
@ -203,7 +203,7 @@ static void _readPanel(UiXmlReader& reader, const xml::xmlelement& element, Pane
|
||||
panel.setMaxLength(element->attr("max-length").asInt());
|
||||
}
|
||||
if (element->has("orientation")) {
|
||||
const auto &oname = element->attr("orientation").getText();
|
||||
auto oname = element->attr("orientation").getText();
|
||||
if (oname == "horizontal") {
|
||||
panel.setOrientation(Orientation::horizontal);
|
||||
}
|
||||
@ -286,7 +286,7 @@ static std::shared_ptr<UINode> readButton(UiXmlReader& reader, const xml::xmlele
|
||||
|
||||
std::shared_ptr<Button> button;
|
||||
auto& elements = element->getElements();
|
||||
if (!elements.empty() && elements[0]->getTag() != "#") {
|
||||
if (!elements.empty() && elements.at(0)->getTag() != "#") {
|
||||
auto inner = reader.readUINode(element->getElements().at(0));
|
||||
if (inner != nullptr) {
|
||||
button = std::make_shared<Button>(inner, padding);
|
||||
|
||||
@ -8,7 +8,8 @@
|
||||
Inventories::Inventories(Level& level) : level(level) {
|
||||
}
|
||||
|
||||
Inventories::~Inventories() = default;
|
||||
Inventories::~Inventories() {
|
||||
}
|
||||
|
||||
std::shared_ptr<Inventory> Inventories::create(size_t size) {
|
||||
int64_t id = level.getWorld()->getNextInventoryId();
|
||||
|
||||
@ -38,8 +38,8 @@ struct ItemDef {
|
||||
|
||||
struct {
|
||||
itemid_t id;
|
||||
blockid_t placingBlock;
|
||||
item_funcs_set funcsset {};
|
||||
blockid_t placingBlock;
|
||||
bool emissive = false;
|
||||
} rt {};
|
||||
|
||||
|
||||
@ -20,7 +20,8 @@ Lighting::Lighting(const Content* content, Chunks* chunks)
|
||||
solverS = std::make_unique<LightSolver>(indices, chunks, 3);
|
||||
}
|
||||
|
||||
Lighting::~Lighting() = default;
|
||||
Lighting::~Lighting(){
|
||||
}
|
||||
|
||||
void Lighting::clear(){
|
||||
for (size_t index = 0; index < chunks->volume; index++){
|
||||
|
||||
@ -30,7 +30,8 @@ ChunksController::ChunksController(Level* level, uint padding)
|
||||
generator(WorldGenerators::createGenerator(level->getWorld()->getGenerator(), level->content)) {
|
||||
}
|
||||
|
||||
ChunksController::~ChunksController() = default;
|
||||
ChunksController::~ChunksController(){
|
||||
}
|
||||
|
||||
void ChunksController::update(int64_t maxDuration) {
|
||||
int64_t mcstotal = 0;
|
||||
@ -112,22 +113,21 @@ bool ChunksController::buildLights(const std::shared_ptr<Chunk>& chunk) {
|
||||
void ChunksController::createChunk(int x, int z) {
|
||||
auto chunk = level->chunksStorage->create(x, z);
|
||||
chunks->putChunk(chunk);
|
||||
auto& chunkFlags = chunk->flags;
|
||||
|
||||
if (!chunkFlags.loaded) {
|
||||
if (!chunk->flags.loaded) {
|
||||
generator->generate(
|
||||
chunk->voxels, x, z,
|
||||
level->getWorld()->getSeed()
|
||||
);
|
||||
chunkFlags.unsaved = true;
|
||||
chunk->flags.unsaved = true;
|
||||
}
|
||||
chunk->updateHeights();
|
||||
|
||||
if (!chunkFlags.loadedLights) {
|
||||
if (!chunk->flags.loadedLights) {
|
||||
Lighting::prebuildSkyLight(
|
||||
chunk.get(), level->content->getIndices()
|
||||
);
|
||||
}
|
||||
chunkFlags.loaded = true;
|
||||
chunkFlags.ready = true;
|
||||
chunk->flags.loaded = true;
|
||||
chunk->flags.ready = true;
|
||||
}
|
||||
|
||||
@ -255,8 +255,8 @@ public:
|
||||
}
|
||||
|
||||
dynamic::Value applyRelative(
|
||||
Argument* arg,
|
||||
const dynamic::Value& value,
|
||||
Argument* arg,
|
||||
dynamic::Value value,
|
||||
const dynamic::Value& origin
|
||||
) {
|
||||
if (origin.index() == 0) {
|
||||
|
||||
@ -55,7 +55,7 @@ namespace cmd {
|
||||
std::string description;
|
||||
executor_func executor;
|
||||
public:
|
||||
Command() = default;
|
||||
Command() {}
|
||||
|
||||
Command(
|
||||
std::string name,
|
||||
|
||||
@ -47,12 +47,11 @@ void LevelController::update(float delta, bool input, bool pause) {
|
||||
player->postUpdate(delta, input, pause);
|
||||
|
||||
// erease null pointers
|
||||
auto& objects = level->objects;
|
||||
objects.erase(
|
||||
level->objects.erase(
|
||||
std::remove_if(
|
||||
objects.begin(), objects.end(),
|
||||
level->objects.begin(), level->objects.end(),
|
||||
[](auto obj) { return obj == nullptr; }),
|
||||
objects.end()
|
||||
level->objects.end()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ glm::vec3 CameraControl::updateCameraShaking(const Hitbox& hitbox, float delta)
|
||||
}
|
||||
|
||||
void CameraControl::updateFovEffects(const Hitbox& hitbox,
|
||||
PlayerInput input, float delta) {
|
||||
const PlayerInput& input, float delta) {
|
||||
bool crouch = input.shift && hitbox.grounded && !input.sprint;
|
||||
|
||||
float dt = fmin(1.0f, delta * ZOOM_SPEED);
|
||||
@ -146,7 +146,7 @@ void CameraControl::switchCamera() {
|
||||
}
|
||||
}
|
||||
|
||||
void CameraControl::update(PlayerInput input, float delta, Chunks* chunks) {
|
||||
void CameraControl::update(const PlayerInput& input, float delta, Chunks* chunks) {
|
||||
offset = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
if (auto hitbox = player->getHitbox()) {
|
||||
@ -455,7 +455,7 @@ void PlayerController::updateEntityInteraction(entityid_t eid, bool lclick, bool
|
||||
if (!entityOpt.has_value()) {
|
||||
return;
|
||||
}
|
||||
auto entity = *entityOpt;
|
||||
auto entity = entityOpt.value();
|
||||
if (lclick) {
|
||||
scripting::on_attacked(entity, player.get(), player->getEntity());
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ class CameraControl {
|
||||
/// @brief Update field-of-view effects
|
||||
/// @param input player inputs
|
||||
/// @param delta delta time
|
||||
void updateFovEffects(const Hitbox& hitbox, PlayerInput input,
|
||||
void updateFovEffects(const Hitbox& hitbox, const PlayerInput& input,
|
||||
float delta);
|
||||
|
||||
/// @brief Switch active player camera
|
||||
@ -41,7 +41,7 @@ public:
|
||||
CameraControl(const std::shared_ptr<Player>& player,
|
||||
const CameraSettings& settings);
|
||||
void updateMouse(PlayerInput& input);
|
||||
void update(PlayerInput input, float delta, Chunks* chunks);
|
||||
void update(const PlayerInput& input, float delta, Chunks* chunks);
|
||||
void refresh();
|
||||
};
|
||||
|
||||
|
||||
@ -75,7 +75,7 @@ static int l_get_command_info(lua::State* L) {
|
||||
|
||||
lua::createtable(L, args.size(), 0);
|
||||
for (size_t i = 0; i < args.size(); i++) {
|
||||
auto& arg = args[i];
|
||||
auto& arg = args.at(i);
|
||||
lua::createtable(L, 0, 2);
|
||||
|
||||
lua::pushstring(L, arg.name);
|
||||
|
||||
@ -324,6 +324,8 @@ static int l_gui_getattr(lua::State* L) {
|
||||
auto docname = lua::require_string(L, 1);
|
||||
auto element = lua::require_string(L, 2);
|
||||
auto attr = lua::require_string(L, 3);
|
||||
auto docnode = getDocumentNode(L, docname, element);
|
||||
auto node = docnode.node;
|
||||
|
||||
static const std::unordered_map<std::string_view, std::function<int(UINode*,lua::State*)>> getters {
|
||||
{"color", p_get_color},
|
||||
@ -365,8 +367,6 @@ static int l_gui_getattr(lua::State* L) {
|
||||
};
|
||||
auto func = getters.find(attr);
|
||||
if (func != getters.end()) {
|
||||
auto docnode = getDocumentNode(L, docname, element);
|
||||
auto node = docnode.node;
|
||||
return func->second(node.get(), L);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@ -95,7 +95,7 @@ static int l_pack_get_info(lua::State* L, const ContentPack& pack, const Content
|
||||
if (!pack.dependencies.empty()) {
|
||||
lua::createtable(L, pack.dependencies.size(), 0);
|
||||
for (size_t i = 0; i < pack.dependencies.size(); i++) {
|
||||
auto& dpack = pack.dependencies[i];
|
||||
auto& dpack = pack.dependencies.at(i);
|
||||
std::string prefix;
|
||||
switch (dpack.level) {
|
||||
case DependencyLevel::required: prefix = "!"; break;
|
||||
@ -142,7 +142,7 @@ static int l_pack_get_info(lua::State* L) {
|
||||
manager.scan();
|
||||
auto vec = manager.getAll({packid});
|
||||
if (!vec.empty()) {
|
||||
return l_pack_get_info(L, vec[0], content);
|
||||
return l_pack_get_info(L, vec.at(0), content);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -151,20 +151,20 @@ namespace lua {
|
||||
return 3;
|
||||
}
|
||||
|
||||
inline int pushivec3_stack(lua::State* L, const glm::ivec3 &vec) {
|
||||
inline int pushivec3_stack(lua::State* L, glm::ivec3 vec) {
|
||||
pushinteger(L, vec.x);
|
||||
pushinteger(L, vec.y);
|
||||
pushinteger(L, vec.z);
|
||||
return 3;
|
||||
}
|
||||
|
||||
inline int pushvec3_stack(lua::State* L, const glm::vec3 &vec) {
|
||||
inline int pushvec3_stack(lua::State* L, glm::vec3 vec) {
|
||||
pushnumber(L, vec.x);
|
||||
pushnumber(L, vec.y);
|
||||
pushnumber(L, vec.z);
|
||||
return 3;
|
||||
}
|
||||
inline int pushvec4_stack(lua::State* L, const glm::vec4 &vec) {
|
||||
inline int pushvec4_stack(lua::State* L, glm::vec4 vec) {
|
||||
pushnumber(L, vec.x);
|
||||
pushnumber(L, vec.y);
|
||||
pushnumber(L, vec.z);
|
||||
@ -179,15 +179,15 @@ namespace lua {
|
||||
lua_pushvalue(L, idx);
|
||||
return 1;
|
||||
}
|
||||
inline int pushvec2(lua::State* L, const glm::vec2 &vec) {
|
||||
inline int pushvec2(lua::State* L, glm::vec2 vec) {
|
||||
return pushvec(L, vec);
|
||||
}
|
||||
|
||||
inline int pushvec3(lua::State* L, const glm::vec3 &vec) {
|
||||
inline int pushvec3(lua::State* L, glm::vec3 vec) {
|
||||
return pushvec(L, vec);
|
||||
}
|
||||
|
||||
inline int pushvec4(lua::State* L, const glm::vec4 &vec) {
|
||||
inline int pushvec4(lua::State* L, glm::vec4 vec) {
|
||||
return pushvec(L, vec);
|
||||
}
|
||||
inline int pushcolor(lua::State* L, glm::vec4 vec) {
|
||||
@ -210,7 +210,7 @@ namespace lua {
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
inline int pushmat4(lua::State* L, const glm::mat4 &matrix) {
|
||||
inline int pushmat4(lua::State* L, glm::mat4 matrix) {
|
||||
createtable(L, 16, 0);
|
||||
for (uint y = 0; y < 4; y++) {
|
||||
for (uint x = 0; x < 4; x++) {
|
||||
@ -222,7 +222,7 @@ namespace lua {
|
||||
return 1;
|
||||
}
|
||||
/// @brief pushes matrix table to the stack and updates it with glm matrix
|
||||
inline int setmat4(lua::State* L, int idx, const glm::mat4 &matrix) {
|
||||
inline int setmat4(lua::State* L, int idx, glm::mat4 matrix) {
|
||||
pushvalue(L, idx);
|
||||
for (uint y = 0; y < 4; y++) {
|
||||
for (uint x = 0; x < 4; x++) {
|
||||
|
||||
@ -240,8 +240,8 @@ void scripting::on_block_placed(Player* player, const Block* block, int x, int y
|
||||
}
|
||||
|
||||
void scripting::on_block_broken(Player* player, const Block* block, int x, int y, int z) {
|
||||
std::string name = block->name + ".broken";
|
||||
if (block->rt.funcsset.onbroken) {
|
||||
std::string name = block->name + ".broken";
|
||||
lua::emit_event(lua::get_main_thread(), name, [x, y, z, player] (auto L) {
|
||||
lua::pushivec3_stack(L, x, y, z);
|
||||
lua::pushinteger(L, player ? player->getId() : -1);
|
||||
|
||||
@ -66,7 +66,7 @@ wstringsupplier scripting::create_wstring_supplier(
|
||||
auto str = lua::require_wstring(L, -1); lua::pop(L);
|
||||
return str;
|
||||
}
|
||||
return std::wstring();
|
||||
return std::wstring(L"");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
class Frustum {
|
||||
public:
|
||||
Frustum() = default;
|
||||
Frustum() {};
|
||||
|
||||
void update(glm::mat4 projview);
|
||||
bool isBoxVisible(const glm::vec3& minp, const glm::vec3& maxp) const;
|
||||
|
||||
@ -70,7 +70,7 @@ struct AABB {
|
||||
b = end;
|
||||
}
|
||||
|
||||
inline void addPoint(const glm::vec3& p) {
|
||||
inline void addPoint(glm::vec3 p) {
|
||||
a = glm::min(a, p);
|
||||
b = glm::max(b, p);
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ class AABBFaces {
|
||||
public:
|
||||
std::array<std::pair<rayvec3, rayvec2>, AABBFACES_COUNT> faces; // every face is min-point and opposite corner point
|
||||
|
||||
AABBFaces() = default;
|
||||
AABBFaces(){};
|
||||
AABBFaces(const rayvec3& parentBoxPos, const AABB& parentBox);
|
||||
};
|
||||
|
||||
|
||||
@ -186,7 +186,7 @@ void Entities::loadEntity(const dynamic::Map_sptr& map) {
|
||||
spawn(def, {}, nullptr, map, uid);
|
||||
}
|
||||
|
||||
void Entities::loadEntity(const dynamic::Map_sptr& map, const Entity &entity) {
|
||||
void Entities::loadEntity(const dynamic::Map_sptr& map, Entity entity) {
|
||||
auto& transform = entity.getTransform();
|
||||
auto& body = entity.getRigidbody();
|
||||
auto& skeleton = entity.getSkeleton();
|
||||
@ -228,7 +228,7 @@ void Entities::loadEntity(const dynamic::Map_sptr& map, const Entity &entity) {
|
||||
}
|
||||
|
||||
std::optional<Entities::RaycastResult> Entities::rayCast(
|
||||
const glm::vec3 &start, const glm::vec3 &dir, float maxDistance, entityid_t ignore
|
||||
glm::vec3 start, glm::vec3 dir, float maxDistance, entityid_t ignore
|
||||
) {
|
||||
Ray ray(start, dir);
|
||||
auto view = registry.view<EntityId, Transform, Rigidbody>();
|
||||
@ -547,7 +547,7 @@ bool Entities::hasBlockingInside(AABB aabb) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<Entity> Entities::getAllInside(const AABB &aabb) {
|
||||
std::vector<Entity> Entities::getAllInside(AABB aabb) {
|
||||
std::vector<Entity> collected;
|
||||
auto view = registry.view<Transform>();
|
||||
for (auto [entity, transform] : view.each()) {
|
||||
@ -564,7 +564,7 @@ std::vector<Entity> Entities::getAllInside(const AABB &aabb) {
|
||||
return collected;
|
||||
}
|
||||
|
||||
std::vector<Entity> Entities::getAllInRadius(const glm::vec3 ¢er, float radius) {
|
||||
std::vector<Entity> Entities::getAllInRadius(glm::vec3 center, float radius) {
|
||||
std::vector<Entity> collected;
|
||||
auto view = registry.view<Transform>();
|
||||
for (auto [entity, transform] : view.each()) {
|
||||
|
||||
@ -49,19 +49,19 @@ struct Transform {
|
||||
|
||||
void refresh();
|
||||
|
||||
inline void setRot(const glm::mat3 &m) {
|
||||
inline void setRot(glm::mat3 m) {
|
||||
rot = m;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
inline void setSize(const glm::vec3 &v) {
|
||||
inline void setSize(glm::vec3 v) {
|
||||
if (glm::distance2(displaySize, v) >= 0.00001f) {
|
||||
dirty = true;
|
||||
}
|
||||
size = v;
|
||||
}
|
||||
|
||||
inline void setPos(const glm::vec3 &v) {
|
||||
inline void setPos(glm::vec3 v) {
|
||||
if (glm::distance2(displayPos, v) >= 0.0001f) {
|
||||
dirty = true;
|
||||
}
|
||||
@ -212,15 +212,15 @@ public:
|
||||
/// @param ignore Ignored entity ID
|
||||
/// @return An optional structure containing entity, normal and distance
|
||||
std::optional<RaycastResult> rayCast(
|
||||
const glm::vec3 &start, const glm::vec3 &dir, float maxDistance, entityid_t ignore=-1);
|
||||
glm::vec3 start, glm::vec3 dir, float maxDistance, entityid_t ignore=-1);
|
||||
|
||||
void loadEntities(dynamic::Map_sptr map);
|
||||
void loadEntity(const dynamic::Map_sptr& map);
|
||||
void loadEntity(const dynamic::Map_sptr& map, const Entity &entity);
|
||||
void loadEntity(const dynamic::Map_sptr& map, Entity entity);
|
||||
void onSave(const Entity& entity);
|
||||
bool hasBlockingInside(AABB aabb);
|
||||
std::vector<Entity> getAllInside(const AABB &aabb);
|
||||
std::vector<Entity> getAllInRadius(const glm::vec3 ¢er, float radius);
|
||||
std::vector<Entity> getAllInside(AABB aabb);
|
||||
std::vector<Entity> getAllInRadius(glm::vec3 center, float radius);
|
||||
void despawn(entityid_t id);
|
||||
dynamic::Value serialize(const Entity& entity);
|
||||
|
||||
|
||||
@ -169,7 +169,7 @@ void Player::postUpdate() {
|
||||
glm::mat4(1.0f), glm::radians(cam.y), glm::vec3(1, 0, 0));
|
||||
}
|
||||
|
||||
void Player::teleport(const glm::vec3 &position) {
|
||||
void Player::teleport(glm::vec3 position) {
|
||||
this->position = position;
|
||||
if (auto hitbox = getHitbox()) {
|
||||
hitbox->position = position;
|
||||
@ -239,7 +239,7 @@ std::shared_ptr<Inventory> Player::getInventory() const {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
void Player::setSpawnPoint(const glm::vec3 &spawnpoint) {
|
||||
void Player::setSpawnPoint(glm::vec3 spawnpoint) {
|
||||
this->spawnpoint = spawnpoint;
|
||||
}
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ public:
|
||||
std::shared_ptr<Inventory> inv, entityid_t eid);
|
||||
~Player();
|
||||
|
||||
void teleport(const glm::vec3 &position);
|
||||
void teleport(glm::vec3 position);
|
||||
void updateEntity();
|
||||
void updateInput(PlayerInput& input, float delta);
|
||||
void updateSelectedEntity();
|
||||
@ -96,7 +96,7 @@ public:
|
||||
|
||||
Hitbox* getHitbox();
|
||||
|
||||
void setSpawnPoint(const glm::vec3 &spawnpoint);
|
||||
void setSpawnPoint(glm::vec3 point);
|
||||
glm::vec3 getSpawnPoint() const;
|
||||
|
||||
std::unique_ptr<dynamic::Map> serialize() const override;
|
||||
|
||||
@ -68,8 +68,8 @@ SkeletonConfig::SkeletonConfig(const std::string& name, std::unique_ptr<Bone> ro
|
||||
size_t SkeletonConfig::update(
|
||||
size_t index,
|
||||
Skeleton& skeleton,
|
||||
Bone* node,
|
||||
const glm::mat4& matrix) const
|
||||
Bone* node,
|
||||
glm::mat4 matrix) const
|
||||
{
|
||||
auto boneMatrix = skeleton.pose.matrices[index];
|
||||
auto boneOffset = node->getOffset();
|
||||
@ -85,7 +85,7 @@ size_t SkeletonConfig::update(
|
||||
return count;
|
||||
}
|
||||
|
||||
void SkeletonConfig::update(Skeleton& skeleton, const glm::mat4& matrix) const {
|
||||
void SkeletonConfig::update(Skeleton& skeleton, glm::mat4 matrix) const {
|
||||
update(0, skeleton, root.get(), matrix);
|
||||
}
|
||||
|
||||
|
||||
@ -103,12 +103,12 @@ namespace rigging {
|
||||
size_t index,
|
||||
Skeleton& skeleton,
|
||||
Bone* node,
|
||||
const glm::mat4& matrix) const;
|
||||
glm::mat4 matrix) const;
|
||||
public:
|
||||
SkeletonConfig(const std::string& name, std::unique_ptr<Bone> root,
|
||||
size_t nodesCount);
|
||||
|
||||
void update(Skeleton& skeleton, const glm::mat4& matrix) const;
|
||||
void update(Skeleton& skeleton, glm::mat4 matrix) const;
|
||||
void render(
|
||||
Assets* assets,
|
||||
ModelBatch& batch,
|
||||
|
||||
@ -28,8 +28,8 @@ struct ThreadPoolResult {
|
||||
template<class T, class R>
|
||||
class Worker {
|
||||
public:
|
||||
Worker() = default;
|
||||
virtual ~Worker() = default;
|
||||
Worker() {}
|
||||
virtual ~Worker() {}
|
||||
virtual R operator()(const std::shared_ptr<T>&) = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -11,12 +11,12 @@
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
class ArgsReader {
|
||||
const char* last = "";
|
||||
char** argv;
|
||||
int argc;
|
||||
char** argv;
|
||||
int pos = 0;
|
||||
const char* last = "";
|
||||
public:
|
||||
ArgsReader(int argc, char** argv) : argv(argv), argc(argc) {}
|
||||
ArgsReader(int argc, char** argv) : argc(argc), argv(argv) {}
|
||||
|
||||
void skip() {
|
||||
pos++;
|
||||
|
||||
@ -7,7 +7,7 @@ std::string util::to_string(const std::vector<std::string>& vec) {
|
||||
std::stringstream ss;
|
||||
ss << "[";
|
||||
for (size_t i = 0; i < vec.size(); i++) {
|
||||
ss << util::quote(vec[1]);
|
||||
ss << util::quote(vec.at(i));
|
||||
if (i < vec.size()-1) {
|
||||
ss << ", ";
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ std::string util::quote(const std::string& s) {
|
||||
return escape(s);
|
||||
}
|
||||
|
||||
std::wstring util::lfill(const std::wstring& s, uint length, wchar_t c) {
|
||||
std::wstring util::lfill(std::wstring s, uint length, wchar_t c) {
|
||||
if (s.length() >= length) {
|
||||
return s;
|
||||
}
|
||||
@ -49,7 +49,7 @@ std::wstring util::lfill(const std::wstring& s, uint length, wchar_t c) {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
std::wstring util::rfill(const std::wstring& s, uint length, wchar_t c) {
|
||||
std::wstring util::rfill(std::wstring s, uint length, wchar_t c) {
|
||||
if (s.length() >= length) {
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -13,8 +13,8 @@ namespace util {
|
||||
/// @brief Function used for error messages
|
||||
std::string quote(const std::string& s);
|
||||
|
||||
std::wstring lfill(const std::wstring& s, uint length, wchar_t c);
|
||||
std::wstring rfill(const std::wstring& s, uint length, wchar_t c);
|
||||
std::wstring lfill(std::wstring s, uint length, wchar_t c);
|
||||
std::wstring rfill(std::wstring s, uint length, wchar_t c);
|
||||
|
||||
uint encode_utf8(uint32_t c, ubyte* bytes);
|
||||
uint32_t decode_utf8(uint& size, const char* bytes);
|
||||
|
||||
@ -48,7 +48,7 @@ struct CoordSystem {
|
||||
|
||||
void transform(AABB& aabb) const;
|
||||
|
||||
inline bool isVectorHasNegatives(const glm::ivec3& vec) {
|
||||
inline bool isVectorHasNegatives(glm::ivec3 vec) {
|
||||
return (vec.x < 0 || vec.y < 0 || vec.z < 0);
|
||||
}
|
||||
};
|
||||
|
||||
@ -232,13 +232,13 @@ void Chunks::repairSegments(const Block* def, blockstate state, int x, int y, in
|
||||
}
|
||||
}
|
||||
|
||||
bool Chunks::checkReplaceability(const Block* def, blockstate state, const glm::ivec3 &coord, blockid_t ignore) {
|
||||
bool Chunks::checkReplaceability(const Block* def, blockstate state, glm::ivec3 origin, blockid_t ignore) {
|
||||
const auto& rotation = def->rotations.variants[state.rotation];
|
||||
const auto size = def->size;
|
||||
for (int sy = 0; sy < size.y; sy++) {
|
||||
for (int sz = 0; sz < size.z; sz++) {
|
||||
for (int sx = 0; sx < size.x; sx++) {
|
||||
auto pos = coord;
|
||||
auto pos = origin;
|
||||
pos += rotation.axisX * sx;
|
||||
pos += rotation.axisY * sy;
|
||||
pos += rotation.axisZ * sz;
|
||||
@ -257,7 +257,7 @@ bool Chunks::checkReplaceability(const Block* def, blockstate state, const glm::
|
||||
}
|
||||
|
||||
void Chunks::setRotationExtended(
|
||||
Block* def, blockstate state, const glm::ivec3 &origin, uint8_t index
|
||||
Block* def, blockstate state, glm::ivec3 origin, uint8_t index
|
||||
) {
|
||||
auto newstate = state;
|
||||
newstate.rotation = index;
|
||||
@ -387,8 +387,8 @@ void Chunks::set(int32_t x, int32_t y, int32_t z, uint32_t id, blockstate state)
|
||||
}
|
||||
|
||||
voxel* Chunks::rayCast(
|
||||
const glm::vec3 &start,
|
||||
const glm::vec3 &dir,
|
||||
glm::vec3 start,
|
||||
glm::vec3 dir,
|
||||
float maxDist,
|
||||
glm::vec3& end,
|
||||
glm::ivec3& norm,
|
||||
@ -520,7 +520,7 @@ voxel* Chunks::rayCast(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
glm::vec3 Chunks::rayCastToObstacle(const glm::vec3 &start, const glm::vec3 &dir, float maxDist) {
|
||||
glm::vec3 Chunks::rayCastToObstacle(glm::vec3 start, glm::vec3 dir, float maxDist) {
|
||||
const float px = start.x;
|
||||
const float py = start.y;
|
||||
const float pz = start.z;
|
||||
|
||||
@ -27,7 +27,7 @@ class Chunks {
|
||||
|
||||
void eraseSegments(const Block* def, blockstate state, int x, int y, int z);
|
||||
void repairSegments(const Block* def, blockstate state, int x, int y, int z);
|
||||
void setRotationExtended(Block* def, blockstate state, const glm::ivec3 &origin, uint8_t rotation);
|
||||
void setRotationExtended(Block* def, blockstate state, glm::ivec3 origin, uint8_t rotation);
|
||||
public:
|
||||
std::vector<std::shared_ptr<Chunk>> chunks;
|
||||
std::vector<std::shared_ptr<Chunk>> chunksSecond;
|
||||
@ -48,7 +48,7 @@ public:
|
||||
Chunk* getChunkByVoxel(int32_t x, int32_t y, int32_t z);
|
||||
voxel* get(int32_t x, int32_t y, int32_t z) const;
|
||||
|
||||
inline voxel* get(const glm::ivec3 &pos) {
|
||||
inline voxel* get(glm::ivec3 pos) {
|
||||
return get(pos.x, pos.y, pos.z);
|
||||
}
|
||||
|
||||
@ -68,20 +68,20 @@ public:
|
||||
/// @param state the block state
|
||||
/// @param coord position of the zone start
|
||||
/// @param ignore ignored block id (will be counted as replaceable)
|
||||
bool checkReplaceability(const Block* def, blockstate state, const glm::ivec3 &coord, blockid_t ignore=0);
|
||||
bool checkReplaceability(const Block* def, blockstate state, glm::ivec3 coord, blockid_t ignore=0);
|
||||
|
||||
void setRotation(int32_t x, int32_t y, int32_t z, uint8_t rotation);
|
||||
|
||||
voxel* rayCast(
|
||||
const glm::vec3 &start,
|
||||
const glm::vec3 &dir,
|
||||
glm::vec3 start,
|
||||
glm::vec3 dir,
|
||||
float maxLength,
|
||||
glm::vec3& end,
|
||||
glm::ivec3& norm,
|
||||
glm::ivec3& iend
|
||||
);
|
||||
|
||||
glm::vec3 rayCastToObstacle(const glm::vec3 &start, const glm::vec3 &dir, float maxDist);
|
||||
glm::vec3 rayCastToObstacle(glm::vec3 start, glm::vec3 dir, float maxDist);
|
||||
|
||||
const AABB* isObstacleAt(float x, float y, float z);
|
||||
bool isSolidBlock(int32_t x, int32_t y, int32_t z);
|
||||
|
||||
@ -115,7 +115,7 @@ void Events::bind(const std::string& name, inputtype type, mousecode code) {
|
||||
}
|
||||
|
||||
void Events::bind(const std::string& name, inputtype type, int code) {
|
||||
bindings.try_emplace(name, Binding(type, code));
|
||||
bindings.emplace(name, Binding(type, code));
|
||||
}
|
||||
|
||||
void Events::rebind(const std::string& name, inputtype type, int code) {
|
||||
|
||||
@ -205,11 +205,11 @@ void Window::clearDepth() {
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void Window::setBgColor(const glm::vec3 &color) {
|
||||
void Window::setBgColor(glm::vec3 color) {
|
||||
glClearColor(color.r, color.g, color.b, 1.0f);
|
||||
}
|
||||
|
||||
void Window::setBgColor(const glm::vec4 &color) {
|
||||
void Window::setBgColor(glm::vec4 color) {
|
||||
glClearColor(color.r, color.g, color.b, color.a);
|
||||
}
|
||||
|
||||
|
||||
@ -49,8 +49,8 @@ public:
|
||||
|
||||
static void clear();
|
||||
static void clearDepth();
|
||||
static void setBgColor(const glm::vec3 &color);
|
||||
static void setBgColor(const glm::vec4 &color);
|
||||
static void setBgColor(glm::vec3 color);
|
||||
static void setBgColor(glm::vec4 color);
|
||||
static double time();
|
||||
static const char* getClipboardText();
|
||||
static void setClipboardText(const char* text);
|
||||
|
||||
@ -142,7 +142,7 @@ struct Binding {
|
||||
bool state = false;
|
||||
bool justChange = false;
|
||||
|
||||
Binding() = default;
|
||||
Binding(){}
|
||||
Binding(inputtype type, int code) : type(type), code(code) {}
|
||||
|
||||
bool active() const {
|
||||
|
||||
@ -201,7 +201,7 @@ void World::deserialize(dynamic::Map* root) {
|
||||
generator = root->get("generator", generator);
|
||||
seed = root->get("seed", seed);
|
||||
|
||||
if (generator.empty()) {
|
||||
if (generator == "") {
|
||||
generator = WorldGenerators::getDefaultGeneratorID();
|
||||
}
|
||||
if (auto verobj = root->map("version")) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user