minor wm render optimiz

This commit is contained in:
Darsu 2025-01-31 07:19:04 +07:00
parent 05ce80d82d
commit 0c252b5f6f
3 changed files with 95 additions and 91 deletions

View File

@ -39,7 +39,7 @@ function SWEP:DrawCustomModel(wm, custompos, customang)
mdl = self.WModel
lod = self:ShouldLOD()
if mdl and mdl[1]:IsValid() then
if lod == 0 and mdl and mdl[1]:IsValid() then
mdl[1]:SetMaterial(self:GetProcessedValue("Material", true))
for ind = 0, 31 do
@ -71,11 +71,11 @@ function SWEP:DrawCustomModel(wm, custompos, customang)
end
end
if lod < 2 then
local onground = wm and !IsValid(owner)
local hidebones = self:GetHiddenBones(wm)
if lod < 2 then
for _, model in ipairs(mdl or {}) do
if model.IsAnimationProxy then continue end
local slottbl = model.slottbl

View File

@ -1,4 +1,5 @@
SWEP.ModelVersion = 0
local v0, a0 = Vector(0, 0, 0), Angle(0, 0, 0)
function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, customang, dupli)
dupli = dupli or 0
@ -63,10 +64,10 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
atttbl = self:GetFinalAttTable(slottbl)
end
local icon_offset = slottbl.Icon_Offset or Vector()
local icon_offset = slottbl.Icon_Offset or v0
local offset_pos = slottbl.Pos or Vector(0, 0, 0)
local offset_ang = slottbl.Ang or Angle(0, 0, 0)
local offset_pos = slottbl.Pos or v0
local offset_ang = slottbl.Ang or a0
local bpos, bang
if dupli > 0 then
@ -79,7 +80,7 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
if parentmdl and bone then
local boneindex = parentmdl:LookupBone(bone)
if !boneindex then return vector_origin, angle_zero, vector_origin end
if !boneindex then return v0, a0, v0 end
if parentmdl == self:GetOwner() then
parentmdl:SetupBones()
@ -92,7 +93,7 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
end
elseif custompos then
bpos = custompos
bang = customang or Angle(0, 0, 0)
bang = customang or a0
end
if slottbl.OriginalAddress then
@ -130,7 +131,7 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
apos = apos + aang:Up() * offset_pos.z
if !nomodeloffset then
offset_ang = offset_ang + (atttbl.ModelAngleOffset or angle_zero)
offset_ang = offset_ang + (atttbl.ModelAngleOffset or a0)
end
aang:Set(bang)
@ -144,7 +145,7 @@ function SWEP:GetAttachmentPos(slottbl, wm, idle, nomodeloffset, custompos, cust
aang:RotateAroundAxis(up, offset_ang.y)
if !nomodeloffset then
local moffset = (atttbl.ModelOffset or Vector(0, 0, 0)) * (slottbl.Scale or 1)
local moffset = (atttbl.ModelOffset or v0) * (slottbl.Scale or 1)
if wm then
moffset = moffset * (self.WorldModelOffset.Scale or 1)
end

View File

@ -5,8 +5,9 @@ function SWEP:DoBodygroups(wm, cm)
if cm then wm = true end
local owner = self:GetOwner()
if !wm and !IsValid(owner) then return end
if !wm and owner:IsNPC() then return end
local isnpc = owner:IsNPC() or self:ShouldLOD() > 0
if !wm and !IsValid(owner) or isnpc then return end
local dbg = self.DefaultBodygroups
@ -26,10 +27,6 @@ function SWEP:DoBodygroups(wm, cm)
mdl:SetSkin(self.DefaultSkin)
mdl:SetBodyGroups(dbg or "")
for i = 0, mdl:GetBoneCount() do
mdl:ManipulateBoneScale(i, v1)
end
local eles = self:GetAttachmentElements()
for _, ele in ipairs(eles) do
@ -44,9 +41,14 @@ function SWEP:DoBodygroups(wm, cm)
end
end
if !isnpc then
for i = 0, mdl:GetBoneCount() do
mdl:ManipulateBoneScale(i, v1)
end
local bbg = self.BulletBodygroups
if bbg then
if bbg and !isnpc then
local amt = self:Clip1()
if self:GetReloading() then
@ -63,7 +65,7 @@ function SWEP:DoBodygroups(wm, cm)
end
local stbg = self.SoundTableBodygroups
if stbg then
if stbg and !isnpc then
for i, k in pairs(stbg) do
mdl:SetBodygroup(i, k)
end
@ -134,6 +136,7 @@ function SWEP:DoBodygroups(wm, cm)
end
end
end
end
mdl.CustomCamoTexture = self:GetProcessedValue("CustomCamoTexture", true)
mdl.CustomCamoScale = self:GetProcessedValue("CustomCamoScale", true)
@ -143,7 +146,7 @@ function SWEP:DoBodygroups(wm, cm)
self:RunHook("Hook_ModifyBodygroups", {model = mdl, elements = self:GetElements()})
if CLIENT then
if CLIENT and !isnpc then
local pptables = self:GetReloadPoseParameterTable(wm)
for pp, ppv in pairs(pptables or {}) do