<commit_before>include( "shared.lua" )

ENT.RenderGroup = RENDERGROUP_BOTH

local blocked = {}
local scale_buffer = {}
local clip_buffer = {}
local vis_buffer = {}

function ENT:Initialize( )
	self:DoScale()

	local ownerid = self:GetNetworkedInt("ownerid")
	self.blocked = blocked[ownerid] or false

	self.clips = {}
	self.visible = true
end

function ENT:SetupClipping()
	local eidx = self:EntIndex()

	if clip_buffer[eidx] != nil then
		table.Merge( self.clips, clip_buffer[eidx] )

		clip_buffer[eidx] = nil
	end

	local nclips = 0

	if self.clips then nclips = table.Count( self.clips ) end

	if nclips > 0 then
		render.EnableClipping( true )

		for _,clip in pairs( self.clips ) do
			if clip.enabled and clip.normal and clip.origin then
				local norm = clip.normal
				local origin = clip.origin

				if !clip.isglobal then
					norm = self:LocalToWorld( norm ) - self:GetPos()
					origin = self:LocalToWorld( origin )
				end

				render.PushCustomClipPlane( norm, norm:Dot( origin ) )
			end
		end
	end
end

function ENT:FinishClipping()
	local nclips = 0

	if self.clips then nclips = table.Count( self.clips ) end

	if nclips > 0 then
		for i = 1, nclips do
			render.PopCustomClipPlane()
		end

		render.EnableClipping( false )
	end
end

function ENT:Draw()
	local eidx = self:EntIndex()

	if self.visible != vis_buffer[eidx] then
		self.visible = vis_buffer[eidx]
	end

	if self.blocked or self.visible == false then return end

	self:SetupClipping()

	self:DrawModel()

	self:FinishClipping()
end

/******************************************************************************/

local function CheckClip(eidx, cidx)
	clip_buffer[eidx] = clip_buffer[eidx] or {}
	clip_buffer[eidx][cidx] = clip_buffer[eidx][cidx] or {}

	return clip_buffer[eidx][cidx]
end

local function SetClipEnabled(eidx, cidx, enabled)
	local clip = CheckClip(eidx, cidx)

	clip.enabled = enabled
end

local function SetClip(eidx, cidx, origin, norm, isglobal)
	local clip = CheckClip(eidx, cidx)

	clip.normal = norm
	clip.origin = origin
	clip.isglobal = isglobal
end
<commit_msg>[E2] holograms cl_init.lua: Disabled engine lighting on holograms.  This has been suggested several times, being as how they are "holograms" it doesn't really make sense that they are dynamically lit.  If the community is really against this, it is a quick easy fix.<commit_after>include( "shared.lua" )

ENT.RenderGroup = RENDERGROUP_BOTH

local blocked = {}
local scale_buffer = {}
local clip_buffer = {}
local vis_buffer = {}

function ENT:Initialize( )
	self:DoScale()

	local ownerid = self:GetNetworkedInt("ownerid")
	self.blocked = blocked[ownerid] or false

	self.clips = {}
	self.visible = true
end

function ENT:SetupClipping()
	local eidx = self:EntIndex()

	if clip_buffer[eidx] != nil then
		table.Merge( self.clips, clip_buffer[eidx] )

		clip_buffer[eidx] = nil
	end

	local nclips = 0

	if self.clips then nclips = table.Count( self.clips ) end

	if nclips > 0 then
		render.EnableClipping( true )

		for _,clip in pairs( self.clips ) do
			if clip.enabled and clip.normal and clip.origin then
				local norm = clip.normal
				local origin = clip.origin

				if !clip.isglobal then
					norm = self:LocalToWorld( norm ) - self:GetPos()
					origin = self:LocalToWorld( origin )
				end

				render.PushCustomClipPlane( norm, norm:Dot( origin ) )
			end
		end
	end
end

function ENT:FinishClipping()
	local nclips = 0

	if self.clips then nclips = table.Count( self.clips ) end

	if nclips > 0 then
		for i = 1, nclips do
			render.PopCustomClipPlane()
		end

		render.EnableClipping( false )
	end
end

function ENT:Draw()
	local eidx = self:EntIndex()

	if self.visible != vis_buffer[eidx] then
		self.visible = vis_buffer[eidx]
	end

	if self.blocked or self.visible == false then return end

	self:SetupClipping()

	render.SuppressEngineLighting( true )

	self:DrawModel()

	render.SuppressEngineLighting( false )

	self:FinishClipping()
end

/******************************************************************************/

local function CheckClip(eidx, cidx)
	clip_buffer[eidx] = clip_buffer[eidx] or {}
	clip_buffer[eidx][cidx] = clip_buffer[eidx][cidx] or {}

	return clip_buffer[eidx][cidx]
end

local function SetClipEnabled(eidx, cidx, enabled)
	local clip = CheckClip(eidx, cidx)

	clip.enabled = enabled
end

local function SetClip(eidx, cidx, origin, norm, isglobal)
	local clip = CheckClip(eidx, cidx)

	clip.normal = norm
	clip.origin = origin
	clip.isglobal = isglobal
end

{'fraction_non_alphanumeric': 0.1322609472743521, 'fraction_numerical': 0.0024575513851653264, 'mean_word_length': 4.199767711962834, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4616044', 'n_tokens_mistral': 1654, 'n_tokens_neox': 1507, 'n_words': 424}