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

Mystery ternary in rendertexturepanel() #203

Open
no-lex opened this issue Mar 3, 2021 · 4 comments
Open

Mystery ternary in rendertexturepanel() #203

no-lex opened this issue Mar 3, 2021 · 4 comments
Labels
documentation request resolving an undocumented part of the engine

Comments

@no-lex
Copy link
Member

no-lex commented Mar 3, 2021

octaedit.cpp's rendertexturepanel has an assignment with mysteriously arbitrary values assigned to a throwaway variable, which should be commented properly.

            int s = (i == 3 ? 285 : 220),
@no-lex no-lex added the documentation request resolving an undocumented part of the engine label Mar 3, 2021
@acerspyro
Copy link
Member

https://github.com/project-imprimis/libprimis/blob/main/src/engine/world/octaedit.cpp#L1869

The variable s is called into action on L1890 and L1891.

                int x = w*1800/h-s-50,
                    r = s;

Variable r is a texrotation type, while variable x goes on to be used as part of a gle::attribf call on L1942 through to L1945.

                    gle::attribf(x,   y);   gle::attrib(tc[0]);
                    gle::attribf(x+r, y);   gle::attrib(tc[1]);
                    gle::attribf(x,   y+r); gle::attrib(tc[3]);
                    gle::attribf(x+r, y+r); gle::attrib(tc[2]);

@no-lex
Copy link
Member Author

no-lex commented Mar 3, 2021

Why the values of 285 and 220 though?

@acerspyro
Copy link
Member

No clue, may have been used to resolve an undocumented edge case?

Remove the ternary and keep the variable s at 220 at all times, and see if issues arise.

@qreeves
Copy link

qreeves commented Feb 13, 2022

The r as a texrotation type is in a different scope to the int, and it isn't clear why the value is copied from s to r, though it is likely cruft from years of modification. The ternary is simply a size value which makes the currently selected texture in the panel bigger than the rest. The panel shows 3 textures before and after the current texture, making the range [0..6] where 3 is the middle one ([0] [1] [2] [ 3 ] [4] [5] [6]).

That being said, the texture panel is a legacy thing and should probably be replaced by an appropriate UI implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation request resolving an undocumented part of the engine
Projects
None yet
Development

No branches or pull requests

3 participants