DJUI color interpolation / combiner editing / transforms#1216
DJUI color interpolation / combiner editing / transforms#1216Cooliokid956 wants to merge 34 commits into
Conversation
shoutouts to @PeachyPeachSM64's new very flexible djui hud utils refactor
feature so big i can't seem to figure it out so have this for now - 1:03:47 am
all except for the text disappearing in the loading screen...
it was all in the proper initialization of the gCombinerState! C:
for remote development
```lua
local s = .5
local x = 0
hook_event(HOOK_ON_HUD_RENDER, function ()
local c = gControllers[0]
if c.buttonDown & X_BUTTON ~= 0 then x = x - 0x100 end
if c.buttonDown & Z_TRIG ~= 0 then x = 0 end
if c.buttonDown & Y_BUTTON ~= 0 then s = 1-(1-s)*.95 end
if c.buttonDown & R_TRIG ~= 0 then s = 0.1 end
djui_hud_set_resolution(RESOLUTION_N64)
djui_hud_set_color(255, 255, 255, 255)
djui_hud_set_rotation(x)
djui_hud_render_rect(0,0,20,20)
-- local x, y = 20, -20
-- local x, y = 0, 0
local x, y = djui_hud_get_mouse_x(), djui_hud_get_mouse_y()
-- djui_hud_transform(x, y, 1, 1, function ()
djui_hud_transform(x, y, s, s, function ()
djui_hud_set_rotation(0)
djui_hud_render_rect(0,0,20,20)
djui_hud_render_rect(0,220,20,20)
djui_hud_render_rect((djui_hud_get_screen_width()-320)/2-x*1/s,220-y*1/s,20,20)
end)
end)
```
local s = .5
local x = 0
hook_event(HOOK_ON_HUD_RENDER, function ()
local c = gControllers[0]
if c.buttonDown & X_BUTTON ~= 0 then x = x - 0x100 end
if c.buttonDown & Z_TRIG ~= 0 then x = 0 end
if c.buttonDown & Y_BUTTON ~= 0 then s = 1-(1-s)*.9 end
if c.buttonDown & R_TRIG ~= 0 then s = 0.1 end
djui_hud_set_resolution(RESOLUTION_N64)
djui_hud_set_color(255, 255, 255, 255)
djui_hud_set_rotation(x)
djui_hud_render_rect(0,0,20,20)
-- local x, y = 20, -20
-- local x, y = 0, 0
local x, y = djui_hud_get_mouse_x(), djui_hud_get_mouse_y()
-- djui_hud_transform(x, y, 1, 1, function ()
djui_hud_transform(x, y, s*s, s, function ()
djui_hud_set_rotation(0)
djui_hud_set_color(0, 0, 0, 255)
djui_hud_render_rect(0,0,djui_hud_get_screen_width(),240)
djui_hud_set_color(255, 255, 255, 255)
djui_hud_render_rect(0,0,20,20)
djui_hud_render_rect(0,220,20,20)
djui_hud_render_rect((djui_hud_get_screen_width()-320)/2-x*1/s,220-y*1/s,20,20)
end)
end)
local s = .5
local x = 0
hook_event(HOOK_ON_HUD_RENDER, function ()
local c = gControllers[0]
if c.buttonDown & X_BUTTON ~= 0 then x = x - 0x100 end
if c.buttonDown & Z_TRIG ~= 0 then x = 0 end
if c.buttonDown & Y_BUTTON ~= 0 then s = 1-(1-s)*.9 end
if c.buttonDown & R_TRIG ~= 0 then s = 0.1 end
djui_hud_set_resolution(RESOLUTION_N64)
djui_hud_set_color(255, 255, 255, 255)
djui_hud_set_rotation(x)
djui_hud_render_rect(0,0,20,20)
-- local x, y = 20, -20
-- local x, y = 0, 0
local x, y = djui_hud_get_mouse_x(), djui_hud_get_mouse_y()
-- djui_hud_transform(x, y, 1, 1, function ()
djui_hud_transform(x, y, s*s, s)
djui_hud_set_rotation(0)
djui_hud_set_color(0, 0, 0, 255)
djui_hud_render_rect(0,0,djui_hud_get_screen_width(),240)
djui_hud_set_color(255, 255, 255, 255)
djui_hud_render_rect(0,0,20,20)
djui_hud_render_rect(0,220,20,20)
djui_hud_render_rect((djui_hud_get_screen_width()-320)/2-x*1/s,220-y*1/s,20,20)
-- djui_hud_close_transform()
end)
i no longer need to trust that users will clean up after themselves (although they still should)
everything djui should now conform to the djui coordinate system
so far, so good! but i may have missed a few spots. we need to test all djui features available
local s = .5
local x = 0
hook_event(HOOK_ON_HUD_RENDER, function ()
local c = gControllers[0]
if c.buttonDown & X_BUTTON ~= 0 then x = x - 0x100 end
if c.buttonDown & Z_TRIG ~= 0 then x = 0 end
if c.buttonDown & Y_BUTTON ~= 0 then s = 1-(1-s)*.9 end
if c.buttonDown & R_TRIG ~= 0 then s = 0.1 end
djui_hud_set_resolution(RESOLUTION_N64)
djui_hud_set_color(255, 255, 255, 255)
djui_hud_set_rotation(x)
djui_hud_render_rect(0,0,20,20)
-- local x, y = 20, -20
-- local x, y = 0, 0
local x, y = djui_hud_get_mouse_x(), djui_hud_get_mouse_y()
-- djui_hud_transform(x, y, 1, 1, function ()
djui_hud_transform(x, y, s*s, s)
djui_hud_set_rotation(0)
djui_hud_set_color(0, 0, 0, 255)
djui_hud_render_rect(0,0,djui_hud_get_screen_width(),240)
djui_hud_set_color(255, 255, 255, 255)
djui_hud_render_rect(0,0,20,20)
djui_hud_render_rect(0,220,20,20)
djui_hud_render_rect((djui_hud_get_screen_width()-320)/2-x*1/s,220-y*1/s,20,20)
-- djui_hud_close_transform()
-- djui_hud_close_transform()
end)
some things aren't matching interp yet since i'm still working on them
KILLed gDjuiHudUtilsZ (please stop hallucinating there's no zbuffer) let's generalize
tile rendering's broken, though? I think (check cs)
it seems to be an interp leak
space for: - default mtx - djui mtx - whatever comes after the transform no more crashing, but there's still something going on
demo mod 1:
local c = gControllers[0]
local t = 0
local s = 1
local x = -1
hook_event(HOOK_ON_HUD_RENDER, function ()
tP = t
if c.buttonPressed & B_BUTTON ~= 0 and x < 7 then x = x + 1 end
if djui_hud_get_mouse_buttons_down() & M_MOUSE_BUTTON ~= 0 then t = t * 0.9 end
t = t + djui_hud_get_raw_mouse_y()
s = s + djui_hud_get_mouse_scroll_y()/10
djui_hud_set_resolution(RESOLUTION_N64)
local rotP, rot = (tP)*0x10, (t)*0x10
djui_hud_set_rotation_interpolated(rotP, 0,0, rot, 0,0)
djui_hud_render_rect(djui_hud_get_mouse_x(), djui_hud_get_mouse_y(),40,40)
-- for i = 0, 10 do
local i = 0
while i < x do
if i == 0 then
djui_hud_set_rotation_interpolated(-rotP*x, 0,0, -x*rot, 0,0)
else
djui_hud_set_rotation_interpolated(rotP, 0,0, rot, 0,0)
end
djui_hud_transform(
-- djui_hud_transform_interpolated(
-- 20, 10, s, 1,
20, 10, s, 1)
djui_hud_set_rotation(0, 0, 0)
djui_hud_set_color(get_colors(i*40))
djui_hud_render_rect(0,0,20,10)
i = i + 1
end
djui_hud_reset_transform()
end)
demo mod 2:
local c = gControllers[0]
local t = 0
local s = 1
local x = -1
hook_event(HOOK_ON_HUD_RENDER, function ()
tP = t
if c.buttonPressed & B_BUTTON ~= 0 and x < 7 then x = x + 1 end
if djui_hud_get_mouse_buttons_down() & M_MOUSE_BUTTON ~= 0 then t = t * 0.9 end
t = t + djui_hud_get_raw_mouse_y()
s = s + djui_hud_get_mouse_scroll_y()/10
djui_hud_set_resolution(RESOLUTION_N64)
local rotP, rot = (tP)*0x10, (t)*0x10
djui_hud_set_rotation_interpolated(rotP, 0,0, rot, 0,0)
djui_hud_render_rect(djui_hud_get_mouse_x(), djui_hud_get_mouse_y(),40,40)
-- for i = 0, 10 do
local i = 0
while i < x do
if i == 0 then
djui_hud_set_rotation_interpolated(-rotP*x, 0,0, -x*rot, 0,0)
else
djui_hud_set_rotation_interpolated(rotP, 0,0, rot, 0,0)
end
djui_hud_transform(
-- djui_hud_transform_interpolated(
-- 20, 10, s, 1,
20, 10, s, 1)
djui_hud_set_rotation(0, 0, 0)
djui_hud_set_color(get_colors(i*40))
djui_hud_render_rect(0,0,20,10)
i = i + 1
end
djui_hud_reset_transform()
end)
forgot to include this function with test mod 1! here it is
local function get_colors(t)
return
(t*6 + 0) % 256,
(t*6 + 50) % 256,
(t*6 + 100) % 256,
255
end
|
Hi! I've had this PR in the works for a while but the third and final feature has had me stumped for a while... it all seems to work but somewhere along the way crashing has become prominent even when using regular DJUI functions... so I'd like to ask for guidance on the matter, and maybe also a review on the two already completed features. (@coderabbitai) |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainHi 🏁 Script executed: Length of output: 518 🏁 Script executed: Length of output: 89346
🐛 Root Cause of the Crashes1.
|
| Issue | Severity |
|---|---|
djui_hud_close_transform missing interp entry → matrix stack overflow |
🔴 Critical / crash |
djui_hud_transform_interpolated passes prevX/prevY + current scale |
🟠 Bug |
Combiner optional params default to CS_0 not CS_KEEP |
🟡 Correctness |
sCombinerCycleType not reset in djui_hud_reset_combiner |
🟡 Minor |
| Color interpolation feature | ✅ Looks good |
The fix for the crash is focused: djui_hud_close_transform needs to enqueue an interp entry so the interpolation pass can balance every push with a pop. Let me know if you'd like me to help sketch out more of the solution!
🐇 (ó﹏ò。)
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Three sets of features that people of all ages will enjoy!
Color interpolation
djui_hud_set_color_interpolated: Takes twice as many arguments asdjui_hud_set_colorCombiner editing
djui_hud_set_combinerdjui_hud_reset_combiner: Resets the above, reverting combine modes back to the defaults for each elementdjui_hud_set_combiner_cycles: Sets the amount of cycles used in renderingTransforms
djui_hud_transform: Applies a transformation (translate, rotate, scale) to subsequent DJUI HUD elements until closeddjui_hud_transform_interpolated: The interpolated version of the previous function! Takes twice as many argumentsdjui_hud_close_transform: Closes the previous transformdjui_hud_reset_transform: Closes all current transforms, restoring a fullscreen state