diff --git a/CMakeLists.txt b/CMakeLists.txt index 99872204..589b5630 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,9 @@ add_executable(unit_tests EXCLUDE_FROM_ALL tests/MainTest.cpp tests/EngineTests.cpp tests/CallbackTest.cpp - tests/MoveTests.cpp) + tests/MoveTests.cpp + tests/CollisionTest.cpp + ) target_include_directories(unit_tests PUBLIC sources) target_link_libraries(unit_tests PUBLIC wal ray) diff --git a/lib/Ray/sources/Model/ModelAnimations.cpp b/lib/Ray/sources/Model/ModelAnimations.cpp index 5d5d297f..b70abf56 100644 --- a/lib/Ray/sources/Model/ModelAnimations.cpp +++ b/lib/Ray/sources/Model/ModelAnimations.cpp @@ -16,7 +16,7 @@ RAY::ModelAnimations::ModelAnimations(const std::string &filePath): ::ModelAnimation *ptr = this->_animationsPtr.get(); for (int i = 0; i < this->_animationCount; i++) - this->_animations.emplace_back(RAY::ModelAnimation(ptr[i])); + this->_animations.emplace_back(ptr[i]); } RAY::ModelAnimation &RAY::ModelAnimations::operator[](int index) diff --git a/lib/Ray/sources/Utils/Cache.hpp b/lib/Ray/sources/Utils/Cache.hpp index a1eef87a..7f041853 100644 --- a/lib/Ray/sources/Utils/Cache.hpp +++ b/lib/Ray/sources/Utils/Cache.hpp @@ -60,15 +60,17 @@ namespace RAY { {}; std::shared_ptr<::ModelAnimation> fetch(const std::string &path, int *counter) { + if (this->_cache.find(path) != this->_cache.end()) + return this->_cache[path]; + ::ModelAnimation *animations = this->_dataLoader(path.c_str(), counter); unsigned int animCount = *counter; - if (this->_cache.find(path) == this->_cache.end()) - this->_cache.emplace(path, std::shared_ptr<::ModelAnimation>( - animations, [this, animCount](::ModelAnimation *p) { - this->_dataUnloader(p, animCount); - })); - return _cache[path]; + this->_cache.emplace(path, std::shared_ptr<::ModelAnimation>( + animations, [this, animCount](::ModelAnimation *p) { + this->_dataUnloader(p, animCount); + })); + return this->_cache[path]; }; private: //! @brief function to call to load data diff --git a/sources/Component/Animation/AnimationsComponent.cpp b/sources/Component/Animation/AnimationsComponent.cpp index 72be399f..4461cc8e 100644 --- a/sources/Component/Animation/AnimationsComponent.cpp +++ b/sources/Component/Animation/AnimationsComponent.cpp @@ -20,8 +20,8 @@ namespace BBM WAL::Component *AnimationsComponent::clone(WAL::Entity &entity) const { return new AnimationsComponent(entity, - RAY::ModelAnimations(this->_modelAnimation.getFilePath()), - this->_currentAnimIndex); + RAY::ModelAnimations(this->_modelAnimation.getFilePath()), + this->_currentAnimIndex); } size_t AnimationsComponent::getCurrentAnimFrameCounter() const diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 8b9f70e7..00218852 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -60,8 +60,8 @@ namespace BBM RAY::Window &window = RAY::Window::getInstance(600, 400, "Bomberman", FLAG_WINDOW_RESIZABLE); wal.addSystem>(); - wal.addSystem(); wal.addSystem>(); + wal.addSystem(); wal.addSystem(window) .addSystem>(); @@ -76,12 +76,12 @@ namespace BBM .addComponent>("assets/player/player.iqm", std::make_pair(MAP_DIFFUSE, "assets/player/blue.png")) .addComponent() .addComponent() - .addComponent(RAY::ModelAnimations("assets/player/player.iqm"), 3) + .addComponent(RAY::ModelAnimations("assets/player/player.iqm"), 1) .addComponent(2) .addComponent(); scene->addEntity("cube") - .addComponent(-5, 0, -5) - .addComponent>(Vector3f(-5, 0, -5), Vector3f(3, 3, 3), RED) + .addComponent(5, 0, 5) + .addComponent>(Vector3f(5, 0, 5), Vector3f(3, 3, 3), RED) .addComponent() .addComponent() .addComponent([](WAL::Entity &, const WAL::Entity &){}, @@ -96,7 +96,7 @@ namespace BBM .addComponent(8, 20, 7) .addComponent(Vector3f(8, 0, 8)); std::srand(std::time(NULL)); - MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene); + //MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene); return scene; } diff --git a/sources/System/Animation/AnimationsSystem.cpp b/sources/System/Animation/AnimationsSystem.cpp index fb9f79e0..3400cf10 100644 --- a/sources/System/Animation/AnimationsSystem.cpp +++ b/sources/System/Animation/AnimationsSystem.cpp @@ -13,7 +13,7 @@ namespace BBM AnimationsSystem::AnimationsSystem() : WAL::System({ - typeid(Drawable3DComponent), + typeid(Drawable3DComponent), typeid(AnimationsComponent) }) {