]> git.tdb.fi Git - libs/game.git/commitdiff
Drop the shape wrapper statement from ShapeSetup loader
authorMikko Rasa <tdb@tdb.fi>
Sat, 15 Mar 2025 10:54:35 +0000 (12:54 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 15 Mar 2025 12:55:38 +0000 (14:55 +0200)
Instead use an auxiliary loader to allow the shape to be specified
inline with the rest of the setup.

source/game/setups_special.cpp
source/game/setups_special.h

index 1e0ca799321f7c0aaf23e0e378e8bffca62f33e2..2f7075bde894cb977ebe9fc79f97399fba0c96d2 100644 (file)
@@ -1,5 +1,4 @@
 #include "setups_special.h"
-#include <msp/geometry/loader.h>
 
 namespace Msp::Game {
 
@@ -8,20 +7,19 @@ ShapeSetup::Loader::Loader(ShapeSetup &s):
 {
        static ActionMap shared_actions;
        set_actions(shared_actions);
+
+       add_auxiliary_loader(shape_ldr);
 }
 
 void ShapeSetup::Loader::init_actions()
 {
        add("render_detail", &ShapeSetup::render_detail);
-       add("shape", &Loader::shape);
        add("technique_name", &ShapeSetup::technique_name);
 }
 
-void ShapeSetup::Loader::shape()
+void ShapeSetup::Loader::finish()
 {
-       Geometry::Loader<float, 3> ldr;
-       load_sub_with(ldr);
-       obj.shape = ldr.take_shape();
+       obj.shape = shape_ldr.take_shape();
 }
 
 } // namespace Msp::Game
index 9e6d2066571c677b0e8b201d78abce904ef567cc..1674a7ca208027d767e1adf90991a0a106e882fa 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <memory>
 #include <msp/datafile/objectloader.h>
+#include <msp/geometry/loader.h>
 #include <msp/geometry/shape.h>
 #include "mspgame_api.h"
 
@@ -12,13 +13,15 @@ struct MSPGAME_API ShapeSetup
 {
        class MSPGAME_API Loader: public DataFile::ObjectLoader<ShapeSetup>
        {
+       private:
+               Geometry::Loader<float, 3> shape_ldr;
+
        public:
                Loader(ShapeSetup &);
 
        private:
                void init_actions() override;
-
-               void shape();
+               void finish() override;
        };
 
        std::unique_ptr<Geometry::Shape<float, 3>> shape;