From f79a3bfcbd81cc6ab61a76b88056921408fb706e Mon Sep 17 00:00:00 2001 From: foul11 Date: Wed, 27 Sep 2023 12:29:30 +0700 Subject: [PATCH] Adding features and fixing docs (#1525) * fix docs * * alias render.getEyeVector/getEye * add render.getMatrix * add ent:setBoneMatrix * delete docs for aliases --- lua/starfall/libs_cl/material.lua | 2 +- lua/starfall/libs_cl/render.lua | 16 +++++++++++----- lua/starfall/libs_sh/entities.lua | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lua/starfall/libs_cl/material.lua b/lua/starfall/libs_cl/material.lua index cddfb772b..df4f33243 100644 --- a/lua/starfall/libs_cl/material.lua +++ b/lua/starfall/libs_cl/material.lua @@ -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)) diff --git a/lua/starfall/libs_cl/render.lua b/lua/starfall/libs_cl/render.lua index ca254f6d7..7befb7a7b 100644 --- a/lua/starfall/libs_cl/render.lua +++ b/lua/starfall/libs_cl/render.lua @@ -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() @@ -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) @@ -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) @@ -728,7 +728,7 @@ 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 @@ -736,6 +736,12 @@ function render_library.popMatrix() 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 = { diff --git a/lua/starfall/libs_sh/entities.lua b/lua/starfall/libs_sh/entities.lua index 88102b6ac..e422c72ef 100644 --- a/lua/starfall/libs_sh/entities.lua +++ b/lua/starfall/libs_sh/entities.lua @@ -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