From: Mikko Rasa Date: Mon, 2 Jul 2018 21:00:28 +0000 (+0300) Subject: Have Object provide an identity matrix from get_matrix X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=af0ba2af0167247bcda74e76f3c83c0c0e89650a Have Object provide an identity matrix from get_matrix It's often useful to have static geometry in a scene directly as an Object without creating an instance. Many features such as Z-sorting and culling require a matrix to be available. --- diff --git a/source/object.cpp b/source/object.cpp index bdb292bb..1852f91b 100644 --- a/source/object.cpp +++ b/source/object.cpp @@ -17,6 +17,8 @@ using namespace std; namespace Msp { namespace GL { +Matrix Object::identity_matrix; + Object::Object(): lods(1), lod0_watched(false) diff --git a/source/object.h b/source/object.h index c8e37260..48e30459 100644 --- a/source/object.h +++ b/source/object.h @@ -74,6 +74,8 @@ private: Geometry::BoundingSphere bounding_sphere; bool lod0_watched; + static Matrix identity_matrix; + public: Object(); Object(const Mesh *, const Technique *); @@ -105,6 +107,7 @@ public: const Technique *get_technique(unsigned = 0) const; unsigned get_n_lods() const { return lods.size(); } + virtual const Matrix *get_matrix() const { return &identity_matrix; } virtual const Geometry::BoundingSphere *get_bounding_sphere() const { return &bounding_sphere; } virtual void render(Renderer &, const Tag & = Tag()) const;