Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh: Add forceWorldMatrixInstancedBufferUpdate property #13282

Merged
merged 1 commit into from
Nov 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add forceWorldMatrixInstancedBufferUpdate property
  • Loading branch information
Popov72 committed Nov 24, 2022
commit beb75e0daf727f2e4c79e80e49f5c73796be8ca8
14 changes: 12 additions & 2 deletions packages/dev/core/src/Meshes/mesh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class _InstanceDataStorage {
public instancesPreviousData: Float32Array;
public overridenInstanceCount: number;
public isFrozen: boolean;
public forceMatrixUpdates: boolean;
public previousBatch: Nullable<_InstancesBatch>;
public hardwareInstancedRendering: boolean;
public sideOrientation: number;
Expand Down Expand Up @@ -501,6 +502,15 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
this._instanceDataStorage.previousManualUpdate = value;
}

/** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices must be performed in all cases (and notably even in frozen mode) */
public get forceWorldMatrixInstancedBufferUpdate() {
return this._instanceDataStorage.forceMatrixUpdates;
}

public set forceWorldMatrixInstancedBufferUpdate(value: boolean) {
this._instanceDataStorage.forceMatrixUpdates = value;
}

/**
* @constructor
* @param name The value used by scene.getMeshByName() to do a lookup.
Expand Down Expand Up @@ -1953,7 +1963,7 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
}
this._invalidateInstanceVertexArrayObject();
} else {
if (!this._instanceDataStorage.isFrozen) {
if (!this._instanceDataStorage.isFrozen || this._instanceDataStorage.forceMatrixUpdates) {
instancesBuffer!.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
if (this._scene.needsPreviousWorldMatrices && (!this._instanceDataStorage.manualUpdate || this._instanceDataStorage.previousManualUpdate)) {
instancesPreviousBuffer!.updateDirectly(instanceStorage.instancesPreviousData, 0, instancesCount);
Expand All @@ -1980,7 +1990,7 @@ export class Mesh extends AbstractMesh implements IGetSetVerticesData {
this._scene.needsPreviousWorldMatrices &&
!needUpdateBuffer &&
this._instanceDataStorage.manualUpdate &&
!this._instanceDataStorage.isFrozen &&
(!this._instanceDataStorage.isFrozen || this._instanceDataStorage.forceMatrixUpdates) &&
!this._instanceDataStorage.previousManualUpdate
) {
instancesPreviousBuffer!.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
Expand Down