Facepunch / garrysmod-requests

Feature requests for Garry's Mod
86 stars 24 forks source link

Add mesh.Position(x, y, z) and mesh.Normal(x, y, z) overload #2407

Closed Jaffies closed 5 months ago

Jaffies commented 5 months ago

Basically, this overload should use bare numbers as 3 integers, instead of vectors. It would be good, because the original source function (meshBuilder.Position3f, meshBuilder.Normal3f) uses 3 numbers, not vectors. Better for performance too, you do not need to create a lot of vectors. Just use numbers, as they are easier. Example of new code

hook.Add('HUDPaint', 'test', function()
    render.SetColorMaterial()
    mesh.Begin(MATERIAL_LINE_LOOP, 3)
        mesh.Color(255, 255, 255, 255)
        mesh.Position(0, 0, 0)

        mesh.AdvanceVertex()

        mesh.Color(255, 0, 0, 255)
        mesh.Position(100, 64, 0)

        mesh.AdvanceVertex()

        mesh.Color(0, 0, 255, 255)
        mesh.Position(64, 90, 0)

        mesh.AdvanceVertex()
    mesh.End()
end)
robotboy655 commented 5 months ago

Done for the following:

Keep in mind overloading like this incurs a performance penalty for both, number only and vector inputs.