Applied Energistics 2

Applied Energistics 2

160M Downloads

Breaking Hud Rendering for mods.

mysticdrew opened this issue ยท 6 comments

commented

Describe the bug

50887f6#diff-d900c8177524586430df1a6e2733fda16853eb9a9ebeca1610ff2011527af0eeR62

You should not be inverting the camera rotation like this, this will cause issues with a bunch of mods.

Suggestion is to do

        Quaternionf rotation = new Quaternionf();
        minecraft.gameRenderer.getMainCamera().rotation().conjugate(rotation);
        poseStack.mulPose(rotation);
    or 
        Quaternionf rotation = new Quaternionf();
        minecraft.gameRenderer.getMainCamera().rotation().conjugate(rotation);
        poseStack.mulPose(rotation);

How to reproduce the bug

Add JourneyMap, create a waypoint. See that the waypoint icon and text is moving around.

Expected behavior

to not rotate the main camera

Additional details

This commit broke waypoint rendering in JourneyMap.

Which minecraft version are you using?

1.21

On which mod loaders does it happen?

NeoForge

Crash log

none

commented

Thanks for the lesson and sorry for costing you time to debug it.

commented

Thanks for the lesson and sorry for costing you time to debug it.

No worries! Glad we got it sorted.

commented

That is indeed very bad.
And also of note: This code should not be running if no overlays are active.
I am also adding a fast-exit for that.

commented

Thanks!

commented

Just for my learning opportunity: The problem was, that the original approach modified the rotation value inside the main camera, thus affecting every user of the main camera at a later point in the rendering of the frame and that a local copy can be modified without affecting anybody else. Is that correct?

Another question: You suggested conjugate rather than invert. In my tests both yielded the same results with regards to the rendering. Besides the fact that invert has no implementation that takes a parameter for the result, is there any reason to choose one over the other?

commented

Just for my learning opportunity: The problem was, that the original approach modified the rotation value inside the main camera, thus affecting every user of the main camera at a later point in the rendering of the frame and that a local copy can be modified without affecting anybody else. Is that correct?

That is correct.

Another question: You suggested conjugate rather than invert. In my tests both yielded the same results with regards to the rendering. Besides the fact that invert has no implementation that takes a parameter for the result, is there any reason to choose one over the other?

They generally do the same thing with different math. Conjugate reverses the normalized matrix by flipping the access of rotation.
Invert normalizes the matrix before flipping it. This case, the matrix is normalized, so it is fine to use either. Conjugate will be slightly faster since there is less math since it is already normalized.