As I can see it, start and end parameters restrict the range of particles for which the update function is called but it does not lower the buffer size update.
Near the end of the setParticle
function there is:
if (this._computeParticleColor) {
mesh.updateVerticesData(VertexBuffer.ColorKind, colors32, false, false);
}
if (this._computeParticleTexture) {
mesh.updateVerticesData(VertexBuffer.UVKind, uvs32, false, false);
}
mesh.updateVerticesData(VertexBuffer.PositionKind, positions32, false, false);
...
The whole buffers (colors32
, uvs32
, etc) are passed to the update functions.
I don’t think there’s a way to update only a part of the GPU buffer (I think the update function would take an offset and size if that were possible).
However, I can see that the option does exist in the core engine:
public updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray,
byteOffset?: number, byteLength?: number): void {
so maybe something could be done about this…
[…] What you need nearly exists, we can find this function on Geometry
:
public updateVerticesDataDirectly(kind: string, data: DataArray, offset: number,
useBytes: boolean = false): void {
It only misses the vertexCount
parameter, which does exist in the underlying buffer class:
public updateDirectly(data: DataArray, offset: number, vertexCount?: number,
useBytes: boolean = false): void {
I guess the vertexCount
parameter could be added to the Geometry.updateVerticesDataDirectly
function, but maybe there was a reason why it was not added in the first place, so waiting for inputs from @Deltakosh or @Sebavan about this.
Also, I’m not sure of the use of byteOffset
in Engine.updateDynamicVertexBuffer
, it seems to only be the offset in the data buffer passed in, not the offset in the destination buffer…