wyozi / 3d2d-imgui

Immediate mode 3D2D UI for Garry's Mod
MIT License
43 stars 15 forks source link

Angle being set by something else #13

Closed Mrkrabz closed 8 years ago

Mrkrabz commented 8 years ago

Trying to run this code:

local lposition = Vector(-13846, 570, 12880)
local lang = Angle(0,0,0)
local p
hook.Add("PostDrawTranslucentRenderables", "Paint3D2DUI", function()
    p = p or tdui.Create()

    p:Rect(-320, 0, 640, 600, Color(255,0,0, 50), Color(255,0,0,255))

    p:Text(game.GetMap(), "!Roboto@90", 0, 0)

    p:Cursor()

    p:Render(lposition, lang, 0.1)
    print(lang)

end)

lang constantly gets set between 3 Angles 90.000 90.000 0.000 -0.000 0.000 0.000 -0.000 -90.000 90.000 Doing the local var inside the hook, or putting the angle directly into the Render part works fine (I'm reading from a table however so cannot).

The position however is fine.

wyozi commented 8 years ago

Yup, it's set by this part: https://github.com/wyozi/3d2d-imgui/blob/master/lua/autorun/client/3d2dimgui.lua#L632-L635 which I still don't know if it is a good idea but can't easily change anymore either.

For now the best way to fix that would be to clone the angle and pass that to the method (ie. Angle(lang.p, lang.y, lang.r))

robotboy655 commented 8 years ago

You really should fix this, and make a copy before you modify the angle.

https://github.com/wyozi/3d2d-imgui/blob/master/tdui.lua#L743-L746