Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jujurocket
Copy link

@jujurocket jujurocket commented Aug 4, 2025

Description of change

fixes #11597

When an object's cullArea is defined, during culling the cullArea will be transformed from local coordinate space to global space (which it should do according to the docs).

I fixed it in a bit of a crude manner, so I might have missed some usecases. Please feel free to make changes or suggest any.

It is currently failing the following test in Culler.test.ts:

'cullable container should be rendered if bounds intersects the frame'

If this is indeed the desired behaviour then I will go ahead and change the test as well.

Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Documentation is changed or added
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

@jujurocket jujurocket changed the title project container.cullArea to global coordinates before doing cull check fix: project container.cullArea to global coordinates before doing cull check Aug 4, 2025
@jujurocket jujurocket changed the title fix: project container.cullArea to global coordinates before doing cull check fix: project container.cullArea from local to global coordinate space before doing cull check Aug 4, 2025
@mayakwd
Copy link
Collaborator

mayakwd commented Aug 19, 2025

@jujurocket , have you had a chance to look into failing unit tests?

@jujurocket jujurocket force-pushed the fix-cull-area branch 2 times, most recently from c87e643 to 20be1dc Compare August 22, 2025 17:35
@jujurocket
Copy link
Author

jujurocket commented Aug 22, 2025

The test "cullable container with cullArea should be rendered if the bounds intersect the frame" was failing because my previous solution failed to account for rotation or other transforms applied to the parent container other than just translation.

While I was trying to figure it out however I took the time to create a test scene to visualise it:
https://www.pixiplayground.com/#/edit/PYOm13pQio3looudvu51n

The tiny red pixel in the top left is how the cullArea behaved before my fix. Because it was global, its position and rotation were unaffected by the position and rotation of its parent. It tests for container.culled === false and so it passes because the cullArea is intersecting the culling view rectangle by one pixel.

The green rectangle is how it behaves after my fix, and as you can see it just about touches the corner of the view area.

Was this test written as an edge case by design? The cull area really does only just barely touch the view rectangle corner.

@jujurocket jujurocket force-pushed the fix-cull-area branch 2 times, most recently from f35e1e3 to ad46f56 Compare August 22, 2025 21:40
Copy link

pkg-pr-new bot commented Aug 24, 2025

pixi.js-basepixi.js-bunny-mark

npm i https://pkg.pr.new/pixijs/pixijs/pixi.js@11598

commit: bec2170

@mayakwd
Copy link
Collaborator

mayakwd commented Aug 25, 2025

Thank you @jujurocket!

|| bounds.y + bounds.height <= view.y;
container.culled = !tempRectangle.intersects(
container.cullArea,
container.getGlobalTransform(Matrix.shared, skipUpdateTransform)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello! we should be able to grab the transform and avoid getGlobalTransform via

container.worldTransform <- this should be a ready to go global matrix 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this not mean that the skipUpdateTransform flag gets ignored though?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoodBoyDigital could we get a follow-up on this? Happy to go either way, just wanted to make sure this flag is not being overlooked

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heya - sorry for the later reply! slammed at the mo :D
it should yes, my thinking is that al the transforms should have already happened and we don't need to recalcualte them?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no worries!

Ok I am not as familiar with the codebase so happy to go with your suggestion, was just making sure it was not being overlooked 👍

@jujurocket
Copy link
Author

jujurocket commented Sep 8, 2025

@GoodBoyDigital applied your suggestion and it seems to work the same 👍

to you and @mayakwd thank you both very much for your help!

@mayakwd
Copy link
Collaborator

mayakwd commented Sep 11, 2025

Everything is green, well done @jujurocket!
@GoodBoyDigital, do you think we can merge it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Container.cullArea uses global coordinates, despite docs saying it uses container's local space coordinates
3 participants