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

Break executeCommands into functions #12058

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

javagl
Copy link
Contributor

@javagl javagl commented Jul 1, 2024

The Scene.executeCommands function had >400 lines and did ... a lot of things, with a lot of redundant redundancy. Sometimes obvious, around the pattern

    uniformState.updatePass(...);
    commands = frustumCommands.commands[...];
    length = frustumCommands.indices[...];
    for (j = 0; j < length; ++j) {
      executeCommand(commands[j], scene, context, passState);
    }

(with commands, length, and j being defined at function scope and re-assigned all over the place). Sometimes, with subtle differences, where the above block was just

    uniformState.updatePass(...);
    commands = frustumCommands.commands[...];
    length = frustumCommands.indices[...];
    for (j = 0; j < length; ++j) {
      executeIdCommand(commands[j], scene, context, passState);
    }

This PR breaks the executeCommands function into smaller blocks, reducing redundancy, adding comments etc.

This was just quickly written down. while trying to roughly understand some aspects of what's going on there. So this PR is rather some sort of "internal notes", and opened as a DRAFT, and will likely be closed without merging. The main reason for opening it is to ask whether "something like this" could be considered to be of value (and whether it should be reviewed and tested with the goal to bring it into a mergeable state), or whether such a change is "too drastic" and contains too many risks for bugs to ever be merged anyhow.

Copy link

github-actions bot commented Jul 1, 2024

Thank you for the pull request, @javagl!

✅ We can confirm we have a CLA on file for you.

@jjhembd
Copy link
Contributor

jjhembd commented Jul 11, 2024

I think this could be a valuable change.

or whether such a change is "too drastic" and contains too many risks for bugs

A refactor here could reduce the risk for bugs. I remember having to track down several bugs in #11828, which were caused by my not understanding what was happening in executeCommands

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