]> git.tdb.fi Git - libs/gl.git/commitdiff
Check that Object has a Mesh when rendering
authorMikko Rasa <tdb@tdb.fi>
Thu, 5 Mar 2020 17:46:03 +0000 (19:46 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 2 May 2020 14:55:45 +0000 (17:55 +0300)
source/object.cpp

index d4562b86103af8abd34a8dbdcf3c2cf46dd8221e..dc1f4f3f1a7996bd55008732df21c0c826f27af5 100644 (file)
@@ -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);
 }