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

GetMarcherSizeAndOffset could be more efficient with ranges and grabbing all the marchers info #519

Open
rmpowell77 opened this issue Jun 23, 2024 · 0 comments

Comments

@rmpowell77
Copy link
Contributor

This:

auto AnimationView::GetMarcherSizeAndOffset() const -> std::pair<wxPoint, wxPoint>
{
    auto mode_size = towxPoint(mView->GetShowFieldSize());
    auto bounding_box_upper_left = mode_size;
    auto bounding_box_low_right = towxPoint({ 0, 0 });

    for (auto i = 0; mAnimation && i < mView->GetNumPoints(); ++i) {
        auto position = towxPoint(mAnimation->GetAnimateInfo(mCurrentBeat, i).mMarcherInfo.mPosition);
        bounding_box_upper_left = wxPoint(std::min(bounding_box_upper_left.x, position.x), std::min(bounding_box_upper_left.y, position.y));
        bounding_box_low_right = wxPoint(std::max(bounding_box_low_right.x, position.x), std::max(bounding_box_low_right.y, position.y));
    }

    return { bounding_box_low_right - bounding_box_upper_left, mode_size / 2 + bounding_box_upper_left };
}

Looks like it could be done with ranges more efficiently.

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

No branches or pull requests

1 participant