mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Catch instance rendering process in scene editor (#5806)
Don't show in changelog
This commit is contained in:
@@ -157,25 +157,41 @@ export default class LayerRenderer {
|
||||
const pixiObject: PIXI.DisplayObject | null = renderedInstance.getPixiObject();
|
||||
if (pixiObject) pixiObject.zOrder = instance.getZOrder();
|
||||
|
||||
// "Culling" improves rendering performance of large levels
|
||||
const isVisible = this._isInstanceVisible(instance);
|
||||
if (pixiObject) {
|
||||
pixiObject.visible = isVisible;
|
||||
pixiObject.eventMode =
|
||||
this.layer.isLocked() || (instance.isLocked() && instance.isSealed())
|
||||
? 'auto'
|
||||
: 'static';
|
||||
}
|
||||
if (isVisible) renderedInstance.update();
|
||||
|
||||
if (renderedInstance instanceof Rendered3DInstance) {
|
||||
const threeObject = renderedInstance.getThreeObject();
|
||||
if (this._threeGroup && threeObject) {
|
||||
this._threeGroup.add(threeObject);
|
||||
try {
|
||||
// "Culling" improves rendering performance of large levels
|
||||
const isVisible = this._isInstanceVisible(instance);
|
||||
if (pixiObject) {
|
||||
pixiObject.visible = isVisible;
|
||||
pixiObject.eventMode =
|
||||
this.layer.isLocked() ||
|
||||
(instance.isLocked() && instance.isSealed())
|
||||
? 'auto'
|
||||
: 'static';
|
||||
}
|
||||
}
|
||||
if (isVisible) renderedInstance.update();
|
||||
|
||||
renderedInstance.wasUsed = true;
|
||||
if (renderedInstance instanceof Rendered3DInstance) {
|
||||
const threeObject = renderedInstance.getThreeObject();
|
||||
if (this._threeGroup && threeObject) {
|
||||
this._threeGroup.add(threeObject);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (error instanceof TypeError) {
|
||||
// When reloading a texture when a resource changed externally, rendering
|
||||
// an instance could crash when trying to access a non-existent PIXI base texture.
|
||||
// The error is not propagated in order to avoid a crash at the SceneEditor level.
|
||||
// See https://github.com/4ian/GDevelop/issues/5802.
|
||||
console.error(
|
||||
`An error occurred when rendering instance for object ${instance.getObjectName()}:`,
|
||||
error
|
||||
);
|
||||
return;
|
||||
}
|
||||
throw error;
|
||||
} finally {
|
||||
renderedInstance.wasUsed = true;
|
||||
}
|
||||
};
|
||||
|
||||
// TODO (3D) Should it handle preference changes without needing to reopen tabs?
|
||||
|
Reference in New Issue
Block a user