Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Move marking the outOfBound render state to the end of the updat… #380

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions src/core/CoreNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ export class CoreNode extends EventEmitter {
}

const parent = this.props.parent;
let renderState = null;

if (this.updateType & UpdateType.ParentRenderTexture) {
let p = this.parent;
Expand Down Expand Up @@ -1015,8 +1016,15 @@ export class CoreNode extends EventEmitter {
}

if (this.updateType & UpdateType.RenderState) {
this.updateRenderState();
renderState = this.checkRenderBounds();
this.setUpdateType(UpdateType.IsRenderable);

// if we're not going out of bounds, update the render state
// this is done so the update loop can finish before we mark a node
// as out of bounds
if (renderState !== CoreNodeRenderState.OutOfBounds) {
this.updateRenderState(renderState);
}
}

if (this.updateType & UpdateType.IsRenderable) {
Expand Down Expand Up @@ -1120,6 +1128,13 @@ export class CoreNode extends EventEmitter {
this.sortChildren();
}

// If we're out of bounds, apply the render state now
// this is done so nodes can finish their entire update loop before
// being marked as out of bounds
if (renderState === CoreNodeRenderState.OutOfBounds) {
this.updateRenderState(renderState);
}

// reset update type
this.updateType = 0;
this.childUpdateType = 0;
Expand Down Expand Up @@ -1287,9 +1302,7 @@ export class CoreNode extends EventEmitter {
this.preloadBound = this.createPreloadBounds(this.strictBound);
}

updateRenderState() {
const renderState = this.checkRenderBounds();

updateRenderState(renderState: CoreNodeRenderState) {
if (renderState === this.renderState) {
return;
}
Expand Down
Loading