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

Update Bricks.cpp #26

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

Conversation

jamierobertson1
Copy link
Contributor

@jamierobertson1 jamierobertson1 commented Dec 7, 2024

Fixes a bug in "divide_round" which resulted in incorrect keys being calculated for negative values falling on divisor boundaries.

    auto divide_round = [](int64_t value, int64_t divisor) -> int64_t {
        if (value < 0)
            return -1 - (-value / divisor);
        else
            return value / divisor;
    };

For example if value is -256 and divisor is 256, this would return a key of -2, when it should be the first entry in key -1

This resulted in artifacts on pointclouds with negative coordinates.

proposed fix is:

        if (value < 0)
            return -1 + (value + 1) / divisor;

Fixed bug in "divide_round" which resulted in incorrect keys being calulated for negative values falling on divisor boundaries
Fixes a bug in "divide_round" which resulted in incorrect keys being calculated for negative values falling on divisor boundaries.

    auto divide_round = [](int64_t value, int64_t divisor) -> int64_t {
        if (value < 0)
            return -1 - (-value / divisor);
        else
            return value / divisor;
    };
For example if value is -256 and divisor is 256, this would return a key of -2, when it should be the first entry in key -1

This resulted in artifacts on pointclouds with negative coordinates.

proposed fix is:

        if (value < 0)
            return -1 - -(value + 1) / divisor;
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.

1 participant