From: Mikko Rasa Date: Thu, 5 Mar 2020 17:46:03 +0000 (+0200) Subject: Check that Object has a Mesh when rendering X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b13f1bced27e0ad3e4661e645f6bafed38359120;p=libs%2Fgl.git Check that Object has a Mesh when rendering --- diff --git a/source/object.cpp b/source/object.cpp index d4562b86..dc1f4f3f 100644 --- a/source/object.cpp +++ b/source/object.cpp @@ -140,11 +140,15 @@ void Object::render(Renderer &renderer, const Tag &tag) const if(!pass) return; + const Mesh *mesh = lods.front().mesh.get(); + if (!mesh) + throw logic_error("no mesh"); + Renderer::Push push(renderer); pass->apply(renderer); setup_render(renderer, tag); - lods.front().mesh->draw(renderer); + mesh->draw(renderer); finish_render(renderer, tag); } @@ -155,12 +159,16 @@ void Object::render(Renderer &renderer, const ObjectInstance &inst, const Tag &t if(!pass) return; + const Mesh *mesh = lods[lod].mesh.get(); + if (!mesh) + throw logic_error("no mesh"); + Renderer::Push push(renderer); pass->apply(renderer); setup_render(renderer, tag); inst.setup_render(renderer, tag); - lods[lod].mesh->draw(renderer); + mesh->draw(renderer); inst.finish_render(renderer, tag); finish_render(renderer, tag); }