Skip to content

Commit

Permalink
Add better rendergroup restriction (#1879)
Browse files Browse the repository at this point in the history
  • Loading branch information
thegrb93 authored Oct 22, 2024
1 parent 71ef3b7 commit 5b2798c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion lua/entities/starfall_hologram/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ function ENT:Initialize()
self.sf_userrenderbounds = false
self:SetupBones()
self:OnScaleChanged(nil, nil, self:GetScale())
self:OnRenderGroupChanged(nil, nil, self:GetRenderGroupInternal())

if self:EntIndex() == -1 then
self:SetPlayerColorInternal(VECTOR_PLAYER_COLOR_DISABLED)
Expand Down
14 changes: 11 additions & 3 deletions lua/starfall/libs_sh/hologram.lua
Original file line number Diff line number Diff line change
Expand Up @@ -500,17 +500,25 @@ function hologram_methods:setCullMode(mode)
holo:SetCullMode(mode==1)
end

local allowedRenderGroups = {
[RENDERGROUP_OPAQUE]=true,
[RENDERGROUP_TRANSLUCENT]=true,
[RENDERGROUP_BOTH]=true,
[RENDERGROUP_VIEWMODEL]=true,
[RENDERGROUP_VIEWMODEL_TRANSLUCENT]=true,
[RENDERGROUP_OPAQUE_BRUSH]=true,
}
--- Set the render group for a hologram.
-- @shared
-- @param number|nil group Render group. If unset, the engine will decide the render group based on the entity's materials.
-- @param number|nil group Render group. If unset, the engine will decide the render group based on the entity's materials. Can be RENDERGROUP.OPAQUE RENDERGROUP.TRANSLUCENT RENDERGROUP.BOTH RENDERGROUP.VIEWMODEL RENDERGROUP.VIEWMODEL.TRANSLUCENT RENDERGROUP.OPAQUE.BRUSH
function hologram_methods:setRenderGroup(group)
local holo = getholo(self)
checkpermission(instance, holo, "entities.setRenderProperty")

if group then
checkluatype(group, TYPE_NUMBER)

holo:SetRenderGroupInternal(math.Truncate(group))
if not allowedRenderGroups[group] then SF.Throw("Invalid rendergroup!") end
holo:SetRenderGroupInternal(group)
else
holo:SetRenderGroupInternal(-1)
end
Expand Down

0 comments on commit 5b2798c

Please sign in to comment.