libprimis
libprimis copied to clipboard
Mystery ternary in `rendertexturepanel()`
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),
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]);
Why the values of 285
and 220
though?
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.
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.