diff --git a/include/CVertexBuffer.h b/include/CVertexBuffer.h index 40a4d037..cf569e60 100644 --- a/include/CVertexBuffer.h +++ b/include/CVertexBuffer.h @@ -26,6 +26,7 @@ namespace scene virtual void push_back (const video::S3DVertex &element) =0; virtual void setValue(u32 index, const video::S3DVertex &value) =0; + virtual video::S3DVertex& operator [](u32 index) = 0; virtual video::S3DVertex& operator [](const u32 index) const =0; virtual video::S3DVertex& getLast() =0; virtual void set_used(u32 usedNow) =0; @@ -51,6 +52,9 @@ namespace scene virtual void setValue(u32 index, const video::S3DVertex &value) IRR_OVERRIDE {Vertices[index] = (T&)value;} + virtual video::S3DVertex& operator [](u32 index) IRR_OVERRIDE + {return (video::S3DVertex&)Vertices[index];} + virtual video::S3DVertex& operator [](const u32 index) const IRR_OVERRIDE {return (video::S3DVertex&)Vertices[index];} @@ -158,6 +162,11 @@ namespace scene Vertices->setValue(index, value); } + virtual video::S3DVertex& operator [](u32 index) IRR_OVERRIDE + { + return (*Vertices)[index]; + } + virtual video::S3DVertex& operator [](const u32 index) const IRR_OVERRIDE { return (*Vertices)[index]; diff --git a/include/IVertexBuffer.h b/include/IVertexBuffer.h index 0fc3b237..e201a5b4 100644 --- a/include/IVertexBuffer.h +++ b/include/IVertexBuffer.h @@ -37,12 +37,14 @@ namespace scene //* Note that depending on vertex type reference has to be one of the types derived from video::S3DVertex. */ virtual void push_back(const video::S3DVertex &element) =0; - //! Set value at index. - /** Depending on vertex type reference has to be one of the types derived from video::S3DVertex. - Buffer must be already large enough. This is basically the non const version of operator [] */ + //! Set value at index. Buffer must be already large enough that element exists. + /** Depending on vertex type reference has to be one of the types derived from video::S3DVertex */ virtual void setValue(u32 index, const video::S3DVertex &value) =0; - // Note that the reference can also be to one of the derived types + // Note that the reference can also be to one of the types derived from video::S3DVertex. + // This is especially important for the non const access version - you need to have the correct type and do some casting + // if you write vertices. + virtual video::S3DVertex& operator [](u32 index) = 0; virtual video::S3DVertex& operator [](const u32 index) const =0; virtual video::S3DVertex& getLast() =0;