[engine] 为动态图集管理器增加一些实用接口(getUnusedAtlas, deleteAtlas, destroyUnusedAtlases)

This commit is contained in:
SmallMain 2024-09-04 17:10:08 +08:00
parent 4000e01fa9
commit 2a97bc3a57
No known key found for this signature in database
3 changed files with 34 additions and 1 deletions

View File

@ -366,6 +366,36 @@ let dynamicAtlasManager = {
_atlases[i].update();
}
},
getUnusedAtlas() {
if (!this.enabled) return null;
for (let i = 0; i <= _atlasIndex; i++) {
if (_atlases[i].isEmpty()) {
return _atlases[i];
}
}
return null;
},
deleteAtlas(index) {
if (!this.enabled) return;
_atlases[index].destroy();
_atlases.splice(index, 1);
_atlasIndex--;
},
destroyUnusedAtlases() {
if (!this.enabled) return;
for (let i = 0; i <= _atlasIndex; i++) {
if (_atlases[i].isEmpty()) {
_atlases[i].destroy();
}
}
},
};
/**

View File

@ -623,6 +623,8 @@ export class Atlas {
/**
*
*
*
*/
destroy() {
this.reset();

View File

@ -61,10 +61,11 @@ export class MultiBatcher {
/**
* 使
*
*/
reset() {
this.handlers.length = 0;
this.nextHandler = null!;
}
}