Skip to content

Commit

Permalink
Fix that the reparented items outside mask clip rect still could be t…
Browse files Browse the repository at this point in the history
…ouched.

When reattaching the current node, the masks of all its descendants need to be recalculated since IMask caches the index which means the distance to Mask node.

Reported at https://forum.cocos.org/t/topic/163455/238?u=dumganhar

There are two relevant PR requests:

## 1. #8313

This PR could not fix the issue totally, there is a currMask cache which will be used for all current node's descendants, but descendants's IMask may have different 'index' value which indicates the distance to the Mask node.

    public reattach (): void {
        let currMask;
        this.node.walk((node) => {
            if (!currMask) {
                currMask = _searchComponentsInParent(node as Node, NodeEventProcessor._comp);
            }
            ......
        });
    }

## 2. #9363

This PR made _searchComponentsInParent as instance method but  in 'reattach', it will always invoke '_searchComponentsInParent' for the current node.
  • Loading branch information
dumganhar committed Dec 16, 2024
1 parent dcdbc64 commit e371204
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions cocos/scene-graph/node-event-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,11 @@ export class NodeEventProcessor {
}

public reattach (): void {
let currentMaskList: IMask[] | null;
this.node.walk((node) => {
if (!currentMaskList) {
currentMaskList = this._searchComponentsInParent(NodeEventProcessor._maskComp);
}
node.eventProcessor.maskList = currentMaskList;
const eventProcessor = node.eventProcessor;
// NOTE: When reattaching the current node, the masks of all its descendants need to be recalculated
const currentMaskList = eventProcessor._searchComponentsInParent(NodeEventProcessor._maskComp);
eventProcessor.maskList = currentMaskList;
});
}

Expand Down

0 comments on commit e371204

Please sign in to comment.