Skip to content

Commit

Permalink
Implemented writeZ parameter on render.draw3DLine (thegrb93#1611)
Browse files Browse the repository at this point in the history
* initial implementation of writeZ on draw3DLine

* oops

* restored default values

* parameter note

* requested PR change

* removed unnecessary typecheck

* implemented writeZ on draw3DWireframeSphere

* implemented writeZ in draw3DWireframeBox

* set default behavior to true
  • Loading branch information
FevenKitsune authored Feb 9, 2024
1 parent 5f496d0 commit d5fb22d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions lua/starfall/libs_cl/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1881,23 +1881,27 @@ end
-- @param number radius Radius of the sphere
-- @param number longitudeSteps The amount of longitude steps. The larger this number is, the smoother the sphere is
-- @param number latitudeSteps The amount of latitude steps. The larger this number is, the smoother the sphere is
function render_library.draw3DWireframeSphere(pos, radius, longitudeSteps, latitudeSteps)
-- @param boolean? writeZ Optional should the sphere be drawn with depth considered (default: true)
function render_library.draw3DWireframeSphere(pos, radius, longitudeSteps, latitudeSteps, writeZ)
if writeZ == nil then writeZ = true end
if not renderdata.isRendering then SF.Throw("Not in rendering hook.", 2) end
pos = vunwrap(pos)
longitudeSteps = math.Clamp(longitudeSteps, 3, 50)
latitudeSteps = math.Clamp(latitudeSteps, 3, 50)
render.DrawWireframeSphere(pos, radius, longitudeSteps, latitudeSteps, currentcolor, true)
render.DrawWireframeSphere(pos, radius, longitudeSteps, latitudeSteps, currentcolor, writeZ)
end

--- Draws a 3D Line
-- @param Vector startPos Starting position
-- @param Vector endPos Ending position
function render_library.draw3DLine(startPos, endPos)
-- @param boolean? writeZ Optional should the line be drawn with depth considered (default: true)
function render_library.draw3DLine(startPos, endPos, writeZ)
if writeZ == nil then writeZ = true end
if not renderdata.isRendering then SF.Throw("Not in rendering hook.", 2) end
startPos = vunwrap(startPos)
endPos = vunwrap(endPos)

render.DrawLine(startPos, endPos, currentcolor, true)
render.DrawLine(startPos, endPos, currentcolor, writeZ)
end

--- Draws a box in 3D space
Expand All @@ -1920,14 +1924,16 @@ end
-- @param Angle angle Orientation of the box
-- @param Vector mins Start position of the box, relative to origin.
-- @param Vector maxs End position of the box, relative to origin.
function render_library.draw3DWireframeBox(origin, angle, mins, maxs)
-- @param boolean? writeZ Optional should the box be drawn with depth considered (default: true)
function render_library.draw3DWireframeBox(origin, angle, mins, maxs, writeZ)
if writeZ == nil then writeZ = true end
if not renderdata.isRendering then SF.Throw("Not in rendering hook.", 2) end
origin = vunwrap(origin)
mins = vunwrap(mins)
maxs = vunwrap(maxs)
angle = aunwrap(angle)

render.DrawWireframeBox(origin, angle, mins, maxs, currentcolor, false)
render.DrawWireframeBox(origin, angle, mins, maxs, currentcolor, writeZ)
end

--- Draws textured beam.
Expand Down

0 comments on commit d5fb22d

Please sign in to comment.