From 908e17ee1f85472237aae329f8605a985841a4e8 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Thu, 21 Jul 2022 22:02:57 -0400 Subject: temporary fix for new assets, major cleanup --- src/objects/effect.cc | 7 ++----- src/objects/effect.h | 9 +++------ src/objects/material.cc | 14 +++++++------- src/objects/material.h | 6 ++---- src/objects/model.cc | 12 ++++++------ src/objects/model.h | 8 +++----- src/objects/object.cc | 23 +++++++---------------- src/objects/object.h | 8 ++------ src/objects/pass.cc | 44 ++++++++++++++++++-------------------------- src/objects/pass.h | 18 ++++++++---------- src/objects/scene.cc | 17 +++++++---------- src/objects/scene.h | 20 +++++++------------- 12 files changed, 72 insertions(+), 114 deletions(-) (limited to 'src/objects') diff --git a/src/objects/effect.cc b/src/objects/effect.cc index 8e61964..9257061 100644 --- a/src/objects/effect.cc +++ b/src/objects/effect.cc @@ -5,10 +5,7 @@ #include "effect.h" #include "object.h" - -#include "objects/pass.h" - -#include +#include "pass.h" using namespace Mauri; @@ -55,7 +52,7 @@ void Effect::load(Engine *engine, Object *object, bool last) u32 index = 0; - for (u32 i = 0; i < passes1.size(); i++) + for (auto i = 0u; i < passes1.size(); i++) { Pass pass; diff --git a/src/objects/effect.h b/src/objects/effect.h index 840830b..8be54e7 100644 --- a/src/objects/effect.h +++ b/src/objects/effect.h @@ -1,11 +1,9 @@ #ifndef _EFFECT_H #define _EFFECT_H -#include - -#include "engine.h" -#include "texture.h" -#include "util.h" +#include "../util.h" +#include "../engine.h" +#include "../texture.h" namespace Mauri { @@ -34,7 +32,6 @@ class Effect std::vector passes; - void load(Engine *engine, Object *object, bool last); void draw(Engine *engine); diff --git a/src/objects/material.cc b/src/objects/material.cc index aae5940..b99b918 100644 --- a/src/objects/material.cc +++ b/src/objects/material.cc @@ -1,11 +1,11 @@ -#include "assets.h" -#include "engine.h" -#include "json.h" -#include "log.h" +#include "../assets.h" +#include "../engine.h" +#include "../json.h" +#include "../log.h" -#include "objects/material.h" -#include "objects/object.h" -#include "objects/pass.h" +#include "material.h" +#include "object.h" +#include "pass.h" using namespace Mauri; diff --git a/src/objects/material.h b/src/objects/material.h index 11a2c46..5bc7c3a 100644 --- a/src/objects/material.h +++ b/src/objects/material.h @@ -1,10 +1,8 @@ #ifndef _MATERIAL_H #define _MATERIAL_H -#include - -#include "json.h" -#include "engine.h" +#include "../json.h" +#include "../engine.h" namespace Mauri { diff --git a/src/objects/model.cc b/src/objects/model.cc index 7fac34b..8af3224 100644 --- a/src/objects/model.cc +++ b/src/objects/model.cc @@ -1,10 +1,10 @@ -#include "assets.h" -#include "json.h" -#include "log.h" +#include "../assets.h" +#include "../json.h" +#include "../log.h" -#include "objects/material.h" -#include "objects/model.h" -#include "objects/pass.h" +#include "material.h" +#include "model.h" +#include "pass.h" using namespace Mauri; diff --git a/src/objects/model.h b/src/objects/model.h index 243de1f..a9b2b01 100644 --- a/src/objects/model.h +++ b/src/objects/model.h @@ -1,12 +1,10 @@ #ifndef _MODEL_H #define _MODEL_H -#include +#include "../engine.h" +#include "../json.h" -#include "engine.h" -#include "json.h" - -#include "objects/material.h" +#include "material.h" namespace Mauri { diff --git a/src/objects/object.cc b/src/objects/object.cc index bc744d1..4c7273b 100644 --- a/src/objects/object.cc +++ b/src/objects/object.cc @@ -1,21 +1,12 @@ -#include -#include -#include -#include - -#include -#include -#include - #include "../gl.h" #include "../json.h" #include "../log.h" -#include "objects/effect.h" -#include "objects/model.h" -#include "objects/object.h" -#include "objects/scene.h" -#include "objects/pass.h" +#include "effect.h" +#include "model.h" +#include "object.h" +#include "scene.h" +#include "pass.h" using namespace Mauri; @@ -31,13 +22,13 @@ Object::Object(Parser &p, json &root) // object or are repeated. This could be handled be sorting objects // on the scene in order of deps but I'm not sure if that would // break other things. - std::vector::const_iterator it = deps.begin(); + std::vector::const_iterator it = deps.begin(); while (it != deps.end()) { bool remove = false; - if (*it == id) + if ((u32)(*it) == id) { remove = true; } diff --git a/src/objects/object.h b/src/objects/object.h index eb8ad5a..d4a31a5 100644 --- a/src/objects/object.h +++ b/src/objects/object.h @@ -1,14 +1,10 @@ #ifndef _OBJECT_H #define _OBJECT_H -#include - #include "../engine.h" -#include "effect.h" #include "model.h" - -using namespace glm; +#include "effect.h" namespace Mauri { @@ -35,7 +31,7 @@ class Object bool visible; - std::vector deps; + std::vector deps; bool passthrough = false; bool fullscreen = false; diff --git a/src/objects/pass.cc b/src/objects/pass.cc index e938823..db5084a 100644 --- a/src/objects/pass.cc +++ b/src/objects/pass.cc @@ -1,23 +1,15 @@ -#include -#include -#include -#include -#include -#include - -#include "assets.h" -#include "engine.h" -#include "gl.h" -#include "json.h" -#include "shader.h" -#include "json.h" -#include "texture.h" - -#include "objects/pass.h" -#include "objects/material.h" -#include "objects/model.h" -#include "objects/object.h" -#include "objects/scene.h" +#include "../assets.h" +#include "../engine.h" +#include "../gl.h" +#include "../json.h" +#include "../shader.h" +#include "../texture.h" + +#include "pass.h" +#include "material.h" +#include "model.h" +#include "object.h" +#include "scene.h" using namespace Mauri; @@ -83,7 +75,7 @@ Pass::Pass(Parser &p, json &root, PassStage stage) auto _textures = root["textures"]; - for (int i = 0; i < _textures.size(); i++) + for (auto i = 0u; i < _textures.size(); i++) { auto texture = _textures[i]; if (texture.is_string()) @@ -102,7 +94,7 @@ void Pass::load(Engine *engine, PassStage stage, Pass *pass) { intermidiate = true; - for (int i = 0; i < MAX_TEXTURES; i++) + for (auto i = 0; i < MAX_TEXTURES; i++) { if (textures[i].empty()) continue; @@ -132,7 +124,7 @@ void Pass::load(Engine *engine, PassStage stage, Pass *pass) if (!pass->target.empty()) pass->target.append(pass->effect->buffer_id); - for (int i = 0; i < MAX_TEXTURES; i++) + for (auto i = 0; i < MAX_TEXTURES; i++) { if (binds[i].empty()) continue; @@ -194,7 +186,7 @@ RenderPass::RenderPass(Engine *engine, Pass *pass) shader = new Shader(engine->parser, pass->shader); - for (int i = 0; i < shader->texture_count; i++) + for (auto i = 0u; i < shader->texture_count; i++) { if (!shader->textures[i].empty()) { @@ -361,7 +353,7 @@ void RenderPass::draw(Engine *engine) _target->buffer->bind(); - for (int i = 0; i < shader->texture_count; i++) + for (auto i = 0u; i < shader->texture_count; i++) { if (texture_types[i] == PREVIOUS) { @@ -393,7 +385,7 @@ void RenderPass::draw(Engine *engine) #if FRAME_STEP _target->buffer->blit(0, context()->width, context()->height); context()->swap_buffers(); - std::this_thread::sleep_for(std::chrono::seconds(2)); + std::this_thread::sleep_for(std::chrono::seconds(1)); #endif break; diff --git a/src/objects/pass.h b/src/objects/pass.h index c8d8d0e..d2806d9 100644 --- a/src/objects/pass.h +++ b/src/objects/pass.h @@ -1,16 +1,14 @@ #ifndef _PASS_H #define _PASS_H -#include - -#include "json.h" -#include "context.h" -#include "engine.h" -#include "gl.h" -#include "shader.h" -#include "texture.h" - -#include "objects/object.h" +#include "../json.h" +#include "../context.h" +#include "../engine.h" +#include "../gl.h" +#include "../shader.h" +#include "../texture.h" + +#include "object.h" #define MAX_TEXTURES 8 diff --git a/src/objects/scene.cc b/src/objects/scene.cc index 97b9f58..9bdc86c 100644 --- a/src/objects/scene.cc +++ b/src/objects/scene.cc @@ -1,13 +1,10 @@ -#include -#include +#include "../assets.h" +#include "../json.h" +#include "../log.h" +#include "../util.h" -#include "assets.h" -#include "json.h" -#include "log.h" -#include "util.h" - -#include "objects/scene.h" -#include "objects/pass.h" +#include "scene.h" +#include "pass.h" using namespace Mauri; @@ -17,7 +14,7 @@ Scene::Scene(Parser &p, const std::string &path) if (asset->type == ASSET_VOID) { - log_error("err: failed to open scene.json"); + log_error("%s", "failed to open scene.json"); return; } diff --git a/src/objects/scene.h b/src/objects/scene.h index 5c2b3a0..7dda288 100644 --- a/src/objects/scene.h +++ b/src/objects/scene.h @@ -1,17 +1,11 @@ #ifndef _SCENE_H #define _SCENE_H -#include +#include "../assets.h" +#include "../engine.h" +#include "../json.h" -#include - -#include "assets.h" -#include "engine.h" - -#include "json.h" -#include "objects/object.h" - -using namespace glm; +#include "object.h" namespace Mauri { @@ -20,9 +14,9 @@ struct Camera { vec3 center; vec3 eye; vec3 up; - float farz; - float nearz; - float fov; + f32 farz; + f32 nearz; + f32 fov; }; class Scene -- cgit v1.2.3-101-g0448