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
|
ARC9.CSModelPile = newpile
|
||||||
|
|
||||||
if ARC9.Dev(2) then
|
-- if ARC9.Dev(2) then
|
||||||
if removed > 0 then
|
-- if removed > 0 then
|
||||||
print("ARC9 GC: Removed " .. tostring(removed) .. " CSModels")
|
-- print("ARC9 GC: Removed " .. tostring(removed) .. " CSModels")
|
||||||
else
|
-- else
|
||||||
-- print("ARC9 GC: Nothing removed")
|
-- -- print("ARC9 GC: Nothing removed")
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
end
|
||||||
|
|
||||||
hook.Add("PostCleanupMap", "ARC9.CleanGarbage", function()
|
hook.Add("PostCleanupMap", "ARC9.CleanGarbage", function()
|
||||||
|
@ -25,7 +25,9 @@ function SWEP:DrawCustomModel(wm, custompos, customang)
|
|||||||
local owner = self:GetOwner()
|
local owner = self:GetOwner()
|
||||||
|
|
||||||
if !wm and !IsValid(owner) then return end
|
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 wm and ARC9.RTScopeRender then return end
|
||||||
if custompos then wm = true end
|
if custompos then wm = true end
|
||||||
|
|
||||||
@ -37,7 +39,6 @@ function SWEP:DrawCustomModel(wm, custompos, customang)
|
|||||||
mdl = self.CModel
|
mdl = self.CModel
|
||||||
else
|
else
|
||||||
mdl = self.WModel
|
mdl = self.WModel
|
||||||
lod = self:ShouldLOD()
|
|
||||||
|
|
||||||
if lod == 0 and mdl and mdl[1]:IsValid() then
|
if lod == 0 and mdl and mdl[1]:IsValid() then
|
||||||
mdl[1]:SetMaterial(self:GetProcessedValue("Material", true))
|
mdl[1]:SetMaterial(self:GetProcessedValue("Material", true))
|
||||||
@ -74,7 +75,7 @@ function SWEP:DrawCustomModel(wm, custompos, customang)
|
|||||||
if lod < 2 then
|
if lod < 2 then
|
||||||
local onground = wm and !IsValid(owner)
|
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
|
for _, model in ipairs(mdl or {}) do
|
||||||
if model.IsAnimationProxy then continue end
|
if model.IsAnimationProxy then continue end
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
SWEP.ModelVersion = 0
|
SWEP.ModelVersion = 0
|
||||||
local v0, a0 = Vector(0, 0, 0), Angle(0, 0, 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)
|
function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, customang, dupli)
|
||||||
dupli = dupli or 0
|
dupli = dupli or 0
|
||||||
@ -77,25 +82,56 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
|
|||||||
bone = slottbl.DuplicateModels[dupli].Bone or bone
|
bone = slottbl.DuplicateModels[dupli].Bone or bone
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local selfpos, selfang = self:GetPos(), self:GetAngles()
|
||||||
|
|
||||||
if parentmdl and bone then
|
if parentmdl and bone then
|
||||||
local boneindex = parentmdl:LookupBone(bone)
|
-- local bonecached = false
|
||||||
|
|
||||||
if !boneindex then return v0, a0, v0 end
|
-- 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 parentmdl == self:GetOwner() then
|
-- if !bonecached then
|
||||||
parentmdl:SetupBones()
|
local boneindex = parentmdl:LookupBone(bone)
|
||||||
parentmdl:InvalidateBoneCache()
|
|
||||||
end
|
if !boneindex then return v0, a0, v0 end
|
||||||
local bonemat = parentmdl:GetBoneMatrix(boneindex)
|
|
||||||
if bonemat then
|
if parentmdl == self:GetOwner() then
|
||||||
bpos = bonemat:GetTranslation()
|
parentmdl:SetupBones()
|
||||||
bang = bonemat:GetAngles()
|
parentmdl:InvalidateBoneCache()
|
||||||
end
|
end
|
||||||
|
local bonemat = parentmdl:GetBoneMatrix(boneindex)
|
||||||
|
if bonemat then
|
||||||
|
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
|
elseif custompos then
|
||||||
bpos = custompos
|
bpos = custompos
|
||||||
bang = customang or a0
|
bang = customang or a0
|
||||||
end
|
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
|
if slottbl.OriginalAddress then
|
||||||
local eles = self:GetAttachmentElements()
|
local eles = self:GetAttachmentElements()
|
||||||
|
|
||||||
@ -110,11 +146,6 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if !bang or !bpos then
|
|
||||||
bang = self:GetAngles()
|
|
||||||
bpos = self:GetPos()
|
|
||||||
end
|
|
||||||
|
|
||||||
if wm then
|
if wm then
|
||||||
offset_pos = offset_pos * (self.WorldModelOffset.Scale or 1)
|
offset_pos = offset_pos * (self.WorldModelOffset.Scale or 1)
|
||||||
end
|
end
|
||||||
@ -171,6 +202,11 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
|
|||||||
apos = data.pos or apos
|
apos = data.pos or apos
|
||||||
aang = data.ang or aang
|
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
|
return apos, aang, icon_offset
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user