Mesh:attachAttribute: add an optional start array index parameter.

Allows easier use of a single instance buffer with multiple draws when instanced attributes are used (#1878).
This commit is contained in:
Sasha Szpakowski
2022-12-10 21:11:59 -04:00
parent f17d3d94f1
commit a37c2fb9a9
3 changed files with 16 additions and 6 deletions
+2 -1
View File
@@ -57,6 +57,7 @@ public:
StrongRef<Buffer> buffer;
StrongRef<Mesh> mesh;
int indexInBuffer;
int startArrayIndex;
AttributeStep step;
bool enabled;
};
@@ -109,7 +110,7 @@ public:
* to make sure this Mesh knows to flush the passed in Mesh's data to its
* buffer when drawing.
**/
void attachAttribute(const std::string &name, Buffer *buffer, Mesh *mesh, const std::string &attachname, AttributeStep step = STEP_PER_VERTEX);
void attachAttribute(const std::string &name, Buffer *buffer, Mesh *mesh, const std::string &attachname, int startindex = 0, AttributeStep step = STEP_PER_VERTEX);
bool detachAttribute(const std::string &name);
const std::vector<BufferAttribute> &getAttachedAttributes() const;