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

Small Transformation Stack optimization #13

Closed
enbyted opened this issue Apr 8, 2015 · 2 comments
Closed

Small Transformation Stack optimization #13

enbyted opened this issue Apr 8, 2015 · 2 comments

Comments

@enbyted
Copy link

enbyted commented Apr 8, 2015

Instead of using vector's back() in push methoh in renderer2d, you could do:

    void push(const maths::mat4& matrix, bool override = false)
    {
        if (override) {
            m_TransformationStack.push_back(matrix);
        } else {
            maths::mat4* result = m_TransformationBack * matrix;
            m_TransformationStack.push_back(result);
            m_TransformationBack = result;
        }
    }

I haven't tested it, but it should be a bit faster

@holgk
Copy link

holgk commented Apr 8, 2015

Don't forget to change m_TransformationBack for the override part:

if (override) {
            m_TransformationStack.push_back(matrix);
            m_TransformationBack = matrix;
        } else {
            maths::mat4* result = m_TransformationBack * matrix;
            m_TransformationStack.push_back(result);
            m_TransformationBack = result;
        }

@TheCherno
Copy link
Owner

Keep in mind that the transformation stack vector does not hold pointers, so this isn't exactly going to work. Please open another issue if you think I am misunderstanding you. :)

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

3 participants