]> git.tdb.fi Git - libs/gl.git/commitdiff
Have Object provide an identity matrix from get_matrix
authorMikko Rasa <tdb@tdb.fi>
Mon, 2 Jul 2018 21:00:28 +0000 (00:00 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 2 Jul 2018 21:00:28 +0000 (00:00 +0300)
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.

source/object.cpp
source/object.h

index bdb292bb64e4721208c7bed12dca73bb30d03433..1852f91b50222ead401dfa177605c31d9d1ee21b 100644 (file)
@@ -17,6 +17,8 @@ using namespace std;
 namespace Msp {
 namespace GL {
 
 namespace Msp {
 namespace GL {
 
+Matrix Object::identity_matrix;
+
 Object::Object():
        lods(1),
        lod0_watched(false)
 Object::Object():
        lods(1),
        lod0_watched(false)
index c8e372601077c1b1e9c43dd82a221b53b1a904a7..48e3045930559fd354af6d868a935100a2fab09d 100644 (file)
@@ -74,6 +74,8 @@ private:
        Geometry::BoundingSphere<float, 3> bounding_sphere;
        bool lod0_watched;
 
        Geometry::BoundingSphere<float, 3> bounding_sphere;
        bool lod0_watched;
 
+       static Matrix identity_matrix;
+
 public:
        Object();
        Object(const Mesh *, const Technique *);
 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(); }
 
        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<float, 3> *get_bounding_sphere() const { return &bounding_sphere; }
 
        virtual void render(Renderer &, const Tag & = Tag()) const;
        virtual const Geometry::BoundingSphere<float, 3> *get_bounding_sphere() const { return &bounding_sphere; }
 
        virtual void render(Renderer &, const Tag & = Tag()) const;