Skip to content

Commit

Permalink
Resolved error when getting length for Record type
Browse files Browse the repository at this point in the history
  • Loading branch information
troublemaker52025 committed Sep 11, 2023
1 parent d7f90a3 commit 31e763f
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions cocos/render-scene/scene/submodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { DescriptorSet, DescriptorSetInfo, Device, InputAssembler, Texture, Text
import { errorID, Mat4, cclegacy } from '../../core';
import { getPhaseID } from '../../rendering/pass-phase';
import { Root } from '../../root';
import { MacroRecord } from '../core/pass-utils';
import { MacroRecord, overrideMacros } from '../core/pass-utils';

const _dsInfo = new DescriptorSetInfo(null!);
const MAX_PASS_COUNT = 8;
Expand All @@ -55,7 +55,7 @@ export class SubModel {
protected _shaders: Shader[] | null = null;
protected _subMesh: RenderingSubMesh | null = null;
protected _patches: IMacroPatch[] | null = null;
protected _globalPatches: MacroRecord | null = null;
protected _globalPatches: MacroRecord = {};
protected _priority: RenderPriority = RenderPriority.DEFAULT;
protected _inputAssembler: InputAssembler | null = null;
protected _descriptorSet: DescriptorSet | null = null;
Expand Down Expand Up @@ -296,7 +296,6 @@ export class SubModel {
this.priority = RenderPriority.DEFAULT;

this._patches = null;
this._globalPatches = null;
this._subMesh = null;

this._passes = null;
Expand Down Expand Up @@ -330,18 +329,16 @@ export class SubModel {
const root = cclegacy.director.root as Root;
const pipeline = root.pipeline;
const pipelinePatches = Object.entries(pipeline.macros);
if (!this._globalPatches && pipelinePatches.length === 0) {
const globalPatches = Object.entries(this._globalPatches);
if (globalPatches.length === 0 && pipelinePatches.length === 0) {
return;
} else if (pipelinePatches.length) {
if (this._globalPatches) {
const globalPatches = Object.entries(this._globalPatches);
if (pipelinePatches.length === globalPatches.length) {
const patchesStateUnchanged = JSON.stringify(pipelinePatches.sort()) === JSON.stringify(globalPatches.sort());
if (patchesStateUnchanged) return;
}
}
}
this._globalPatches = pipeline.macros;

if (pipelinePatches.length === globalPatches.length) {
const patchesStateUnchanged = JSON.stringify(pipelinePatches.sort()) === JSON.stringify(globalPatches.sort());
if (patchesStateUnchanged) return;
}
overrideMacros(this._globalPatches, pipeline.macros);

const passes = this._passes;
if (!passes) { return; }
Expand Down

0 comments on commit 31e763f

Please sign in to comment.