diff --git a/demo/demo/topdown.cpp b/demo/demo/topdown.cpp index fb313b6abfb384fb615f8aaa49690ad0a8bdb347..dfc9609eb9bed49b11734052ad6ef375d6945829 100644 --- a/demo/demo/topdown.cpp +++ b/demo/demo/topdown.cpp @@ -137,6 +137,10 @@ void TopDown::update() { } void TopDown::pick_object() { + if (!hasPhys()) { + return; + } + auto cameras = world().find<fggl::gfx::Camera>(); if ( cameras.empty() ) { return; @@ -152,7 +156,7 @@ void TopDown::pick_object() { auto ray = fggl::gfx::get_camera_ray(world(), cam, position); auto hit = phys().raycast(ray); if ( hit != fggl::entity::INVALID) { - //fggl::debug::log("hit: {}", hit); + fggl::debug::info("hit: {}", (int)hit); } else { fggl::debug::info("no hit"); } diff --git a/include/fggl/gfx/ogl/shader.hpp b/include/fggl/gfx/ogl/shader.hpp index 5ac1877938a85bbcb13cff0a95f99d9b62d43e81..a5cba96718b86da8fdea34da8d465448c7d09880 100644 --- a/include/fggl/gfx/ogl/shader.hpp +++ b/include/fggl/gfx/ogl/shader.hpp @@ -82,7 +82,7 @@ namespace fggl::gfx { void initFallbackPipelines(); private: - std::shared_ptr<fggl::data::Storage> m_storage; + fggl::data::Storage* m_storage; std::unordered_map<std::string, GLuint> m_shaders; // extensions diff --git a/include/fggl/scenes/game.hpp b/include/fggl/scenes/game.hpp index 07be3050cdf5d2007e09da2c2ec9a6d5681d3a0f..c5a074d25c6100325a874d121bf604ee7ec69a15 100644 --- a/include/fggl/scenes/game.hpp +++ b/include/fggl/scenes/game.hpp @@ -41,7 +41,12 @@ namespace fggl::scenes { return *m_world; } + bool hasPhys() const { + return m_phys != nullptr; + } + inline auto phys() -> phys::PhysicsEngine & { + assert(m_phys != nullptr); return *m_phys; }