Skip to content
Snippets Groups Projects
Commit 6b7c48c2 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

prevent segfault when closing or clicking

parent aaf609e9
No related branches found
No related tags found
No related merge requests found
......@@ -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");
}
......
......@@ -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
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment