diff options
-rw-r--r-- | assetFactory/assetFactory.cpp (renamed from assetFactory/modelFactory.cpp) | 12 | ||||
-rw-r--r-- | assetFactory/assetFactory.h (renamed from assetFactory/modelFactory.h) | 8 | ||||
-rw-r--r-- | assetFactory/use.cpp | 4 | ||||
-rw-r--r-- | res/brush47.xml | 2 | ||||
-rw-r--r-- | test/Jamfile.jam | 2 | ||||
-rw-r--r-- | test/test-assetFactory.cpp (renamed from test/test-modelFactory.cpp) | 26 |
6 files changed, 27 insertions, 27 deletions
diff --git a/assetFactory/modelFactory.cpp b/assetFactory/assetFactory.cpp index 2642900..0ee1f94 100644 --- a/assetFactory/modelFactory.cpp +++ b/assetFactory/assetFactory.cpp @@ -1,4 +1,4 @@ -#include "modelFactory.h" +#include "assetFactory.h" #include "cuboid.h" #include "cylinder.h" #include "modelFactoryMesh_fwd.h" @@ -7,7 +7,7 @@ #include "saxParse-persistence.h" #include <filesystem.h> -ModelFactory::ModelFactory() : +AssetFactory::AssetFactory() : shapes { {"plane", std::make_shared<Plane>()}, {"cuboid", std::make_shared<Cuboid>()}, @@ -16,15 +16,15 @@ ModelFactory::ModelFactory() : { } -std::shared_ptr<ModelFactory> -ModelFactory::loadXML(const std::filesystem::path & filename) +std::shared_ptr<AssetFactory> +AssetFactory::loadXML(const std::filesystem::path & filename) { filesystem::FileStar file {filename.c_str(), "r"}; - return Persistence::SAXParsePersistence {}.loadState<std::shared_ptr<ModelFactory>>(file); + return Persistence::SAXParsePersistence {}.loadState<std::shared_ptr<AssetFactory>>(file); } bool -ModelFactory::persist(Persistence::PersistenceStore & store) +AssetFactory::persist(Persistence::PersistenceStore & store) { using MapObjects = Persistence::MapByMember<Shapes, Object>; return STORE_TYPE && STORE_NAME_HELPER("object", shapes, MapObjects); diff --git a/assetFactory/modelFactory.h b/assetFactory/assetFactory.h index 94db055..5cf90dd 100644 --- a/assetFactory/modelFactory.h +++ b/assetFactory/assetFactory.h @@ -4,16 +4,16 @@ #include "shape.h" #include <filesystem> -class ModelFactory : public Persistence::Persistable { +class AssetFactory : public Persistence::Persistable { public: using Shapes = std::map<std::string, Shape::CPtr, std::less<>>; - ModelFactory(); - [[nodiscard]] static std::shared_ptr<ModelFactory> loadXML(const std::filesystem::path &); + AssetFactory(); + [[nodiscard]] static std::shared_ptr<AssetFactory> loadXML(const std::filesystem::path &); Shapes shapes; private: - friend Persistence::SelectionPtrBase<std::shared_ptr<ModelFactory>, true>; + friend Persistence::SelectionPtrBase<std::shared_ptr<AssetFactory>, true>; bool persist(Persistence::PersistenceStore & store) override; }; diff --git a/assetFactory/use.cpp b/assetFactory/use.cpp index 21e26f3..3b574c3 100644 --- a/assetFactory/use.cpp +++ b/assetFactory/use.cpp @@ -1,5 +1,5 @@ #include "use.h" -#include "modelFactory.h" +#include "assetFactory.h" Shape::CreatedFaces Use::createMesh(ModelFactoryMesh & mesh, const Mutation::Matrix & mutation) const @@ -17,7 +17,7 @@ struct Lookup : public Persistence::SelectionV<Shape::CPtr> { void setValue(std::string && str) override { - if (auto mf = std::dynamic_pointer_cast<const ModelFactory>(Persistence::sharedObjects.at("modelFactory"))) { + if (auto mf = std::dynamic_pointer_cast<const AssetFactory>(Persistence::sharedObjects.at("assetFactory"))) { v = mf->shapes.at(str); } } diff --git a/res/brush47.xml b/res/brush47.xml index 8f1d934..3c6705a 100644 --- a/res/brush47.xml +++ b/res/brush47.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<ilt p.id="modelFactory"> +<ilt p.id="assetFactory"> <object id="wheel"> <use type="cylinder" position="0,0,0.571" scale="1.142,1.142,0.07" rotation="0,0,90"/> </object> diff --git a/test/Jamfile.jam b/test/Jamfile.jam index 027b880..06f907a 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -52,6 +52,6 @@ run test-text.cpp ; run test-enumDetails.cpp ; run test-render.cpp : : : <library>test ; run test-glContextBhvr.cpp ; -run test-modelFactory.cpp : -- : ../res/brush47.xml : <library>test ; +run test-assetFactory.cpp : -- : ../res/brush47.xml : <library>test ; compile test-static-enumDetails.cpp ; compile test-static-stream_support.cpp ; diff --git a/test/test-modelFactory.cpp b/test/test-assetFactory.cpp index 8f2d56c..64d6a62 100644 --- a/test/test-modelFactory.cpp +++ b/test/test-assetFactory.cpp @@ -1,12 +1,12 @@ -#define BOOST_TEST_MODULE test_model_factory +#define BOOST_TEST_MODULE test_asset_factory #include "testHelpers.h" #include "testRenderOutput.h" #include <boost/test/data/test_case.hpp> #include <boost/test/unit_test.hpp> +#include "assetFactory/assetFactory.h" #include "assetFactory/factoryMesh.h" -#include "assetFactory/modelFactory.h" #include "assetFactory/object.h" #include "gfx/gl/sceneRenderer.h" #include "lib/collection.hpp" @@ -66,37 +66,37 @@ private: BOOST_FIXTURE_TEST_SUITE(m, FactoryFixture); BOOST_AUTO_TEST_CASE(brush47) { - ModelFactory modelFactory; + AssetFactory assetFactory; { auto wheel = std::make_shared<Object>("wheel"); { auto wheelCylinder = wheel->uses.emplace_back(std::make_shared<Use>()); - wheelCylinder->type = modelFactory.shapes.at("cylinder"); + wheelCylinder->type = assetFactory.shapes.at("cylinder"); wheelCylinder->position = {0, 0, 0.571}; wheelCylinder->scale = {1.142, 1.142, 0.07}; wheelCylinder->rotation = {0, 0, half_pi}; wheelCylinder->colour = "#2C3539"; } - modelFactory.shapes.emplace(wheel->id, wheel); + assetFactory.shapes.emplace(wheel->id, wheel); } { auto axel = std::make_shared<Object>("axel"); for (float x : {-1.f, 1.f}) { auto wheel = axel->uses.emplace_back(std::make_shared<Use>()); - wheel->type = modelFactory.shapes.at("wheel"); + wheel->type = assetFactory.shapes.at("wheel"); wheel->position = {x * 0.717f, 0, 0}; wheel->rotation = {0, x == 1.f ? pi : 0.f, 0}; } - modelFactory.shapes.emplace(axel->id, axel); + assetFactory.shapes.emplace(axel->id, axel); } { auto bogey = std::make_shared<Object>("bogey"); for (float y : {-2.f, 0.f, 2.f}) { auto axel = bogey->uses.emplace_back(std::make_shared<Use>()); - axel->type = modelFactory.shapes.at("axel"); + axel->type = assetFactory.shapes.at("axel"); axel->position = {0, y, 0}; } - modelFactory.shapes.emplace(bogey->id, bogey); + assetFactory.shapes.emplace(bogey->id, bogey); } FactoryMesh::Collection factoryMeshes; { @@ -105,7 +105,7 @@ BOOST_AUTO_TEST_CASE(brush47) auto bogey = factoryMeshes.emplace_back(std::make_shared<FactoryMesh>()); bogey->id = "bogey" + std::to_string(b); auto bogeyUse = bogey->uses.emplace_back(std::make_shared<Use>()); - bogeyUse->type = modelFactory.shapes.at("bogey"); + bogeyUse->type = assetFactory.shapes.at("bogey"); bogeyUse->position = {0, y, 0}; bogeyUse->rotation = {0, b * pi, 0}; b++; @@ -117,7 +117,7 @@ BOOST_AUTO_TEST_CASE(brush47) body->size = {2.69f, 19.38f, 3.9f}; { auto bodyLower = body->uses.emplace_back(std::make_shared<Use>()); - bodyLower->type = modelFactory.shapes.at("cuboid"); + bodyLower->type = assetFactory.shapes.at("cuboid"); bodyLower->position = {0, 0, 1.2}; bodyLower->scale = {2.69, 19.38, 1.5}; bodyLower->colour = "#1111DD"; @@ -134,7 +134,7 @@ BOOST_AUTO_TEST_CASE(brush47) } { auto batteryBox = body->uses.emplace_back(std::make_shared<Use>()); - batteryBox->type = modelFactory.shapes.at("cuboid"); + batteryBox->type = assetFactory.shapes.at("cuboid"); batteryBox->position = {0, 0, .2}; batteryBox->scale = {2.6, 4.5, 1}; batteryBox->colour = "#2C3539"; @@ -149,7 +149,7 @@ BOOST_AUTO_TEST_CASE(brush47) } BOOST_AUTO_TEST_CASE(brush47xml) { - auto mf = ModelFactory::loadXML(RESDIR "/brush47.xml"); + auto mf = AssetFactory::loadXML(RESDIR "/brush47.xml"); BOOST_REQUIRE(mf); BOOST_REQUIRE_EQUAL(6, mf->shapes.size()); BOOST_CHECK(mf->shapes.at("plane")); |