[fix] skybox crash with auto releasing assets (#12348)

This commit is contained in:
徐兵
2022-08-05 14:38:21 +08:00
committed by GitHub
parent d38c8c1a52
commit bf05e1e403
2 changed files with 11 additions and 17 deletions
+7 -8
View File
@@ -376,15 +376,14 @@ export class Skybox {
skybox_material.setProperty('environmentMap', envmap);
skybox_material.recompileShaders({ USE_RGBE_CUBEMAP: this.isRGBE });
}
}
if (this._model) {
if (this._editableMaterial) {
this._model.setSubModelMaterial(0, this._editableMaterial);
} else {
this._model.setSubModelMaterial(0, skybox_material!);
if (this._model) {
if (this._editableMaterial) {
this._model.setSubModelMaterial(0, this._editableMaterial);
} else {
this._model.setSubModelMaterial(0, skybox_material!);
}
this._updateSubModes();
}
this._updateSubModes();
}
}
+4 -9
View File
@@ -355,11 +355,11 @@ void Skybox::updatePipeline() const {
}
_material->setProperty("environmentMap", envmap);
_material->recompileShaders({{"USE_RGBE_CUBEMAP", isRGBE()}});
}
if (_model != nullptr && _material != nullptr) {
_model->setSubModelMaterial(0, _material);
updateSubModes();
if (_model != nullptr) {
_model->setSubModelMaterial(0, _material);
updateSubModes();
}
}
Root *root = Root::getInstance();
@@ -424,11 +424,6 @@ void Skybox::updatePipeline() const {
valueChanged = true;
}
//set the macro value first before update the material
if (isEnabled() && _material != nullptr) {
_material->recompileShaders({ {"USE_RGBE_CUBEMAP", isRGBE()} });
}
if (_model != nullptr && _material != nullptr) {
_model->setSubModelMaterial(0, _material);
}