From e6e6f0fe81a2f92985e65ae0de708974194d81a3 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 6 Oct 2021 01:19:53 +0300 Subject: [PATCH] Store materials and scenes using actual types --- source/resources/resources.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/source/resources/resources.cpp b/source/resources/resources.cpp index 63a72404..32f59d93 100644 --- a/source/resources/resources.cpp +++ b/source/resources/resources.cpp @@ -2,28 +2,33 @@ #include #include "animation.h" #include "armature.h" +#include "basicmaterial.h" #include "camera.h" #include "error.h" #include "font.h" #include "keyframe.h" #include "light.h" #include "lighting.h" -#include "material.h" #include "mesh.h" #include "module.h" #include "object.h" +#include "occludedscene.h" +#include "orderedscene.h" +#include "pbrmaterial.h" #include "sequencetemplate.h" #include "pose.h" #include "program.h" #include "resourcemanager.h" #include "resources.h" #include "sampler.h" -#include "scene.h" +#include "simplescene.h" #include "technique.h" #include "texture1d.h" #include "texture2d.h" #include "texture2darray.h" #include "texturecube.h" +#include "unlitmaterial.h" +#include "zsortedscene.h" #include "glsl/compiler.h" using namespace std; @@ -42,6 +47,9 @@ Resources::Resources(bool set_as_global): { add_type().suffix(".anim").keyword("animation"); add_type().suffix(".arma").keyword("armature"); + add_type().base().suffix(".mat") + .creator([this](const string &n) -> BasicMaterial * { create_generic(n); return 0; }) + .notify(&set_debug_name); add_type().keyword("camera") .notify(&set_debug_name); add_type().keyword("font"); @@ -49,15 +57,19 @@ Resources::Resources(bool set_as_global): add_type().keyword("light"); add_type().suffix(".lightn").keyword("lighting") .notify(&set_debug_name); - add_type().suffix(".mat") - .creator([this](const string &n){ return create_generic(n); }) - .notify(&set_debug_name); add_type().keyword("mesh") .creator([this](const string &n){ return create_mesh(n); }) .notify(&set_debug_name); add_type().suffix(".glsl").suffix(".spv") .creator([this](const string &n){ return create_module(n); }); add_type().keyword("object"); + add_type().base().suffix(".scene") + .creator([this](const string &n) -> OccludedScene * { create_generic(n); return 0; }); + add_type().base().suffix(".scene") + .creator([this](const string &n) -> OrderedScene * { create_generic(n); return 0; }); + add_type().base().suffix(".mat") + .creator([this](const string &n) -> PbrMaterial * { create_generic(n); return 0; }) + .notify(&set_debug_name); add_type().suffix(".seq").keyword("sequence"); add_type().keyword("pose"); add_type().keyword("shader") @@ -65,8 +77,8 @@ Resources::Resources(bool set_as_global): .notify(&set_debug_name); add_type().suffix(".samp").keyword("sampler") .notify(&set_debug_name); - add_type().suffix(".scene") - .creator([this](const string &n){ return create_generic(n); }); + add_type().base().suffix(".scene") + .creator([this](const string &n) -> SimpleScene * { create_generic(n); return 0; }); add_type().suffix(".tech").keyword("technique") .notify(&set_debug_name); add_type().base().suffix(".tex1d").keyword("texture1d") @@ -80,6 +92,11 @@ Resources::Resources(bool set_as_global): .notify(&set_debug_name); add_type().base().suffix(".tex2da").keyword("texture2d_array") .notify(&set_debug_name); + add_type().base().suffix(".mat") + .creator([this](const string &n) -> UnlitMaterial * { create_generic(n); return 0; }) + .notify(&set_debug_name); + add_type().base().suffix(".scene") + .creator([this](const string &n) -> ZSortedScene * { create_generic(n); return 0; }); add_source(get_builtins()); @@ -133,7 +150,7 @@ T *Resources::create_generic(const string &name) DataFile::Parser parser(*io, name); typename T::GenericLoader ldr(*this); ldr.load(parser); - return ldr.get_object(); + ldr.store_object(*this, name); } return 0; -- 2.45.2