Skip to content

Commit

Permalink
Fix model mesh advanced data write bug (#1663)
Browse files Browse the repository at this point in the history
* fix: model mesh advanced data write bug
  • Loading branch information
GuoLei1990 authored Jul 25, 2023
1 parent 462ed1d commit 916043f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/core/src/mesh/ModelMesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,8 @@ export class ModelMesh extends Mesh {
uploadData(releaseData: boolean): void {
this._updateVertexElements();

// If releaseData is false, we shouldn't update buffer data version
releaseData || (this._advancedDataSyncToBuffer = true);
// Shouldn't update buffer data version when sync advanced data to buffer
this._advancedDataSyncToBuffer = true;

// Update internal vertex buffer if needed
this._updateInternalVertexBuffer(releaseData);
Expand Down Expand Up @@ -1296,6 +1296,14 @@ export class ModelMesh extends Mesh {

if (!isDestroy) {
this._vertexBufferBindings[this._internalVertexBufferIndex]?.buffer.markAsUnreadable();

// If release data, we need update buffer data version to ensure get data method can read buffer
const dataVersion = this._dataVersionCounter++;
const vertexBufferInfos = this._vertexBufferInfos;
for (let i = 0, n = vertexBufferInfos.length; i < n; i++) {
const vertexBufferInfo = vertexBufferInfos[i];
vertexBufferInfo && (vertexBufferInfo.dataVersion = dataVersion);
}
}
}

Expand Down

0 comments on commit 916043f

Please sign in to comment.