Skip to content

Refactor: DirectionalLightShadowRenderer reduce object allocations #2513

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

capdevon
Copy link
Contributor

@capdevon capdevon commented Jun 23, 2025

This PR refactors the DirectionalLightShadowRenderer class to improve code clarity, efficiency, and shadow rendering quality:

  • Improves documentation and comments for better maintainability and understanding.
  • Renames and clarifies variable purposes, including enhanced comments for splits, splitsArray, and reusable vectors.
  • Uses final for reusable arrays and temporary vectors to reduce allocations.
  • Adds and documents the tempVec reusable vector.
  • Clarifies shadow stabilization logic with a dedicated flag and improved comments.
  • Updates parameter and method documentation for accuracy and readability.
  • Minor code cleanup and formatting for consistency.

These changes do not modify functionality but make the codebase easier to maintain and extend, while also promoting efficient memory usage and clearer intent in shadow rendering logic.

@yaRnMcDonuts yaRnMcDonuts added this to the v3.9.0 milestone Jun 24, 2025
*/
protected DirectionalLightShadowRenderer() {
super();
}

/**
* Creates a DirectionalLight shadow renderer. More info on the technique at <a
* href="https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch10.html">https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch10.html</a>
* Creates a DirectionalLight shadow renderer. This renderer implements the
Copy link
Member

Choose a reason for hiding this comment

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

Why remove the link? Still seems to work

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see, you've moved it to the top. Makes sense

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.

3 participants