Skip to content

Commit

Permalink
Adding features and fixing docs (#1525)
Browse files Browse the repository at this point in the history
* fix docs

* * alias render.getEyeVector/getEye
* add render.getMatrix

* add ent:setBoneMatrix

* delete docs for aliases
  • Loading branch information
foul11 authored Sep 27, 2023
1 parent 26badfa commit f79a3bf
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lua/starfall/libs_cl/material.lua
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ end
--- Returns a vector keyvalue
-- @name material_methods.getVector
-- @param string key The key to get the vector from
-- @return string? The string id of the texture or nil if it doesn't exist
-- @return Vector? The vector value or nil if it doesn't exist
function lmaterial_methods:getVector(key)
checkluatype(key, TYPE_STRING)
return vwrap(lunwrap(self):GetVector(key))
Expand Down
16 changes: 11 additions & 5 deletions lua/starfall/libs_cl/render.lua
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,6 @@ function render_library.getEyePos()
return vwrap(EyePos())
end

--- Alias render.getEyePos(). Call EyePos()
-- @return Vector The origin of the current render context as calculated by calcview.
render_library.getOrigin = render_library.getEyePos

--- Call EyeAngles()
Expand All @@ -539,10 +537,12 @@ end

--- Call EyeVector()
-- @return Vector The normal vector of the current render context as calculated by calcview, similar to render.getAngles.
function render_library.getEye()
function render_library.getEyeVector()
return vwrap(EyeVector())
end

render_library.getEye = render_library.getEyeVector

--- Sets whether stencil tests are carried out for each rendered pixel. Only pixels passing the stencil test are written to the render target.
-- @param boolean enable True to enable, false to disable
function render_library.setStencilEnable(enable)
Expand Down Expand Up @@ -687,7 +687,7 @@ end

-- ------------------------------------------------------------------ --

--- Pushes a matrix onto the matrix stack.
--- Pushes a matrix onto the model matrix stack.
-- @param VMatrix m The matrix
-- @param boolean? world Should the transformation be relative to the screen or world?
function render_library.pushMatrix(m, world)
Expand Down Expand Up @@ -728,14 +728,20 @@ function render_library.disableScissorRect()
render.SetScissorRect(0 , 0 , 0 , 0, false)
end

--- Pops a matrix from the matrix stack.
--- Pops a matrix from the model matrix stack.
function render_library.popMatrix()
if not renderdata.isRendering then SF.Throw("Not in rendering hook.", 2) end
if #matrix_stack <= 0 then SF.Throw("Popped too many matrices", 2) end
matrix_stack[#matrix_stack] = nil
cam.PopModelMatrix()
end

--- Returns a copy of the model matrix that is at the top of the stack.
-- @return VMatrix The currently active matrix.
function render_library.getMatrix()
if not renderdata.isRendering then SF.Throw("Not in rendering hook.", 2) end
return mwrap(cam.GetModelMatrix())
end

local viewmatrix_checktypes =
{
Expand Down
14 changes: 14 additions & 0 deletions lua/starfall/libs_sh/entities.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,20 @@ function ents_methods:getBoneMatrix(bone)
return mwrap(getent(self):GetBoneMatrix(bone))
end

--- Sets the bone matrix of given bone to given matrix. See also Entity:getBoneMatrix.
-- @shared
-- @param number bone The bone ID
-- @param VMatrix matrix The matrix to set
function ents_methods:setBoneMatrix(bone, matrix)
local matrix = munwrap(matrix)
local ent = getent(self)

checkluatype(bone, TYPE_NUMBER)
checkpermission(instance, ent, "entities.setRenderProperty")

ent:SetBoneMatrix(bone, matrix)
end

--- Returns the world transform matrix of the entity
-- @shared
-- @return VMatrix The matrix
Expand Down

0 comments on commit f79a3bf

Please sign in to comment.