Skip to content

Commit

Permalink
avoid mesh data leak. (cocos#8413)
Browse files Browse the repository at this point in the history
* release mesh data.

* mesh maybe share with other object, so just modify the batch utils.

* remove empty space.

* remove empty space.
  • Loading branch information
xianyinchen authored and pandamicro committed Apr 20, 2021
1 parent 621a039 commit 445c8ad
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cocos/3d/misc/batch-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,18 @@ export class BatchingUtility {
* @param batchedRoot the target output node
*/
public static unbatchStaticModel (staticModelRoot: Node, batchedRoot: Node) {
const models = staticModelRoot.getComponentsInChildren('cc.MeshRenderer');
const models = staticModelRoot.getComponentsInChildren(MeshRenderer);
for (let i = 0; i < models.length; i++) {
const comp = models[i];
comp.enabled = true;
}
const batchedModel = batchedRoot.getComponent('cc.MeshRenderer');
if (batchedModel) { batchedModel.destroy(); }
const batchedModel = batchedRoot.getComponent(MeshRenderer);
if (batchedModel) {
if (batchedModel.mesh) {
batchedModel.mesh.destroyRenderingMesh();
}
batchedModel.destroy();
}
return true;
}
}

0 comments on commit 445c8ad

Please sign in to comment.