mirror of
https://github.com/HaodongMo/ARC-9.git
synced 2025-03-04 03:02:58 -05:00
attachment position cache test, please see if anything changed
This commit is contained in:
parent
0c252b5f6f
commit
ad37026066
@ -21,13 +21,13 @@ function ARC9.CollectGarbage()
|
||||
|
||||
ARC9.CSModelPile = newpile
|
||||
|
||||
if ARC9.Dev(2) then
|
||||
if removed > 0 then
|
||||
print("ARC9 GC: Removed " .. tostring(removed) .. " CSModels")
|
||||
else
|
||||
-- print("ARC9 GC: Nothing removed")
|
||||
end
|
||||
end
|
||||
-- if ARC9.Dev(2) then
|
||||
-- if removed > 0 then
|
||||
-- print("ARC9 GC: Removed " .. tostring(removed) .. " CSModels")
|
||||
-- else
|
||||
-- -- print("ARC9 GC: Nothing removed")
|
||||
-- end
|
||||
-- end
|
||||
end
|
||||
|
||||
hook.Add("PostCleanupMap", "ARC9.CleanGarbage", function()
|
||||
|
@ -25,7 +25,9 @@ function SWEP:DrawCustomModel(wm, custompos, customang)
|
||||
local owner = self:GetOwner()
|
||||
|
||||
if !wm and !IsValid(owner) then return end
|
||||
if !wm and owner:IsNPC() then return end
|
||||
local lod = self:ShouldLOD()
|
||||
local isnpc = owner:IsNPC() or lod > 0
|
||||
if !wm and isnpc then return end
|
||||
if wm and ARC9.RTScopeRender then return end
|
||||
if custompos then wm = true end
|
||||
|
||||
@ -37,7 +39,6 @@ function SWEP:DrawCustomModel(wm, custompos, customang)
|
||||
mdl = self.CModel
|
||||
else
|
||||
mdl = self.WModel
|
||||
lod = self:ShouldLOD()
|
||||
|
||||
if lod == 0 and mdl and mdl[1]:IsValid() then
|
||||
mdl[1]:SetMaterial(self:GetProcessedValue("Material", true))
|
||||
@ -74,7 +75,7 @@ function SWEP:DrawCustomModel(wm, custompos, customang)
|
||||
if lod < 2 then
|
||||
local onground = wm and !IsValid(owner)
|
||||
|
||||
local hidebones = self:GetHiddenBones(wm)
|
||||
local hidebones = isnpc and {} or self:GetHiddenBones(wm)
|
||||
|
||||
for _, model in ipairs(mdl or {}) do
|
||||
if model.IsAnimationProxy then continue end
|
||||
|
@ -1,5 +1,10 @@
|
||||
SWEP.ModelVersion = 0
|
||||
local v0, a0 = Vector(0, 0, 0), Angle(0, 0, 0)
|
||||
local wwWorldToLocal = WorldToLocal
|
||||
local llLocalToWorld = LocalToWorld
|
||||
|
||||
SWEP.AttPosCache = {}
|
||||
-- SWEP.BonePosCache = {}
|
||||
|
||||
function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, customang, dupli)
|
||||
dupli = dupli or 0
|
||||
@ -77,7 +82,20 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
|
||||
bone = slottbl.DuplicateModels[dupli].Bone or bone
|
||||
end
|
||||
|
||||
local selfpos, selfang = self:GetPos(), self:GetAngles()
|
||||
|
||||
if parentmdl and bone then
|
||||
-- local bonecached = false
|
||||
|
||||
-- local possiblebonecache = self.BonePosCache[bone] -- bone cache
|
||||
-- if possiblebonecache then
|
||||
-- if (possiblebonecache[3] or 0) > CurTime() then
|
||||
-- bpos, bang = llLocalToWorld(possiblebonecache[1], possiblebonecache[2], selfpos, selfang)
|
||||
-- bonecached = true
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- if !bonecached then
|
||||
local boneindex = parentmdl:LookupBone(bone)
|
||||
|
||||
if !boneindex then return v0, a0, v0 end
|
||||
@ -91,11 +109,29 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
|
||||
bpos = bonemat:GetTranslation()
|
||||
bang = bonemat:GetAngles()
|
||||
end
|
||||
|
||||
if !bang or !bpos then
|
||||
bang = selfang
|
||||
bpos = selfpos
|
||||
end
|
||||
|
||||
-- local xpos, xang = wwWorldToLocal(bpos, bang, selfpos, selfang) -- bone cache
|
||||
-- self.BonePosCache[bone] = {xpos, xang, CurTime() + 1}
|
||||
-- end
|
||||
elseif custompos then
|
||||
bpos = custompos
|
||||
bang = customang or a0
|
||||
end
|
||||
|
||||
|
||||
local possiblecache = self.AttPosCache[slottbl.Address] -- att pos cache
|
||||
if possiblecache then
|
||||
if (possiblecache[4] or 0) > CurTime() then
|
||||
local qpos, qang = llLocalToWorld(possiblecache[1], possiblecache[2], bpos, bang)
|
||||
return qpos, qang, possiblecache[3]
|
||||
end
|
||||
end
|
||||
|
||||
if slottbl.OriginalAddress then
|
||||
local eles = self:GetAttachmentElements()
|
||||
|
||||
@ -110,11 +146,6 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
|
||||
end
|
||||
end
|
||||
|
||||
if !bang or !bpos then
|
||||
bang = self:GetAngles()
|
||||
bpos = self:GetPos()
|
||||
end
|
||||
|
||||
if wm then
|
||||
offset_pos = offset_pos * (self.WorldModelOffset.Scale or 1)
|
||||
end
|
||||
@ -171,6 +202,11 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
|
||||
apos = data.pos or apos
|
||||
aang = data.ang or aang
|
||||
|
||||
if slottbl.Address then -- att pos cache
|
||||
local ypos, yang = wwWorldToLocal(apos, aang, bpos, bang)
|
||||
self.AttPosCache[slottbl.Address] = {ypos, yang, icon_offset, CurTime() + 5}
|
||||
end
|
||||
|
||||
return apos, aang, icon_offset
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user