Skip to content

Commit

Permalink
Resolve scalable ent decal issues
Browse files Browse the repository at this point in the history
Fixes #178
(I think)
  • Loading branch information
thecraftianman committed Sep 6, 2024
1 parent f321296 commit 681012c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
2 changes: 1 addition & 1 deletion lua/entities/acf_ammo/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ do -- Spawning and Updating --------------------
local Class = Classes.GetGroup(Source, Data.Weapon) -- The class representing a weapon type (example IDs: "AC", "HW", etc.)
local Weapon = Source.GetItem(Class.ID, Data.Weapon) -- This is (unintentionally?) always nil due to Class.ID == Data.Weapon after verification
local Ammo = AmmoTypes.Get(Data.AmmoType) -- The class representing this ammo type
local Model = "models/holograms/rcube_thin.mdl"
local Model = "models/holograms/hq_rcube_thin.mdl"

local CanSpawn = HookRun("ACF_PreEntitySpawn", "acf_ammo", Player, Data, Class, Weapon, Ammo)

Expand Down
27 changes: 0 additions & 27 deletions lua/entities/base_scalable/cl_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -201,33 +201,6 @@ do -- Dealing with visual clip's bullshit
end

do -- Scalable entity related hooks
hook.Add("Initialize", "ACF Scalable Decals", function()
-- Detour decals to scale better on scaled entities
local DecalEx = util.DecalEx

util.DecalEx = function(Mat, Entity, Pos, Normal, Color, W, H, ...)
if Entity.IsScalable and Entity:GetSize() then -- If entity is scaled, offset decal pos
local Offset = Pos - Entity:GetPos()

-- Thank you, Garry. Very cool.
local O = Entity:GetOriginalSize()
local C = Entity:GetSize()
local Scaler = Vector(O[1] / C[1], O[2] / C[2], O[3] / C[3])

Pos = Entity:GetPos() + Offset * Scaler

local Max = math.max(Scaler[1], Scaler[2], Scaler[3])

W = W * Max
H = H * Max
end

DecalEx(Mat, Entity, Pos, Normal, Color, W, H, ...)
end

hook.Remove("Initialize", "Scalable Entities")
end)

-- NOTE: Someone reported this could maybe be causing crashes. Please confirm.
hook.Add("PhysgunPickup", "Scalable Entity Physgun", function(_, Entity)
if Entity.IsScalable then return false end
Expand Down

0 comments on commit 681012c

Please sign in to comment.