Fixed health area size changing during crouch.
No longer bothering to update cam pos / look angles on model change. Just do it every paint.
This commit is contained in:
parent
59dc08372b
commit
aa08d47a35
1 changed files with 12 additions and 16 deletions
|
@ -138,22 +138,14 @@ function PANEL:Think()
|
||||||
self.BarricadeGhosting = math.Approach(self.BarricadeGhosting, lp:IsBarricadeGhosting() and 1 or 0, FrameTime() * 5)
|
self.BarricadeGhosting = math.Approach(self.BarricadeGhosting, lp:IsBarricadeGhosting() and 1 or 0, FrameTime() * 5)
|
||||||
|
|
||||||
local model = lp:GetModel()
|
local model = lp:GetModel()
|
||||||
local modelscale = lp:GetModelScale()
|
|
||||||
local ent = self.Entity
|
local ent = self.Entity
|
||||||
if not ent or not ent:IsValid() or model ~= ent:GetModel() or modelscale ~= ent:GetModelScale() then
|
if not ent or not ent:IsValid() or model ~= ent:GetModel() then
|
||||||
if IsValid(self.OverrideEntity) then
|
if IsValid(self.OverrideEntity) then
|
||||||
self.OverrideEntity:Remove()
|
self.OverrideEntity:Remove()
|
||||||
self.OverrideEntity = nil
|
self.OverrideEntity = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
self:SetModel(model)
|
self:SetModel(model)
|
||||||
|
|
||||||
if IsValid(self.Entity) then
|
|
||||||
local mins, maxs = lp:OBBMins(), lp:OBBMaxs()
|
|
||||||
self:SetCamPos(mins:Distance(maxs) * Vector(0, -0.9, 0.4))
|
|
||||||
self:SetLookAt((mins + maxs) / 2)
|
|
||||||
self.Entity:SetModelScale(modelscale, 0)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local overridemodel = lp.status_overridemodel
|
local overridemodel = lp.status_overridemodel
|
||||||
|
@ -209,29 +201,33 @@ function PANEL:Paint()
|
||||||
if not lp:IsValid() then return end
|
if not lp:IsValid() then return end
|
||||||
|
|
||||||
local x, y = self:LocalToScreen(0, 0)
|
local x, y = self:LocalToScreen(0, 0)
|
||||||
local ang = self.aLookAngle
|
|
||||||
local w, h = self:GetSize()
|
local w, h = self:GetSize()
|
||||||
local health = self.Health
|
local health = self.Health
|
||||||
local entpos = ent:GetPos()
|
local entpos = ent:GetPos()
|
||||||
|
local mins, maxs = lp:OBBMins(), lp:OBBMaxs()
|
||||||
|
maxs.z = maxs.x * 4.5
|
||||||
|
local campos = mins:Distance(maxs) * Vector(0, -0.9, 0.4)
|
||||||
|
local lookat = (mins + maxs) / 2
|
||||||
|
local ang = (lookat - campos):Angle()
|
||||||
|
local modelscale = lp:GetModelScale()
|
||||||
|
if ent:GetModelScale() ~= modelscale then
|
||||||
|
ent:SetModelScale(modelscale, 0)
|
||||||
|
end
|
||||||
|
|
||||||
self:LayoutEntity(ent)
|
self:LayoutEntity(ent)
|
||||||
|
|
||||||
if not ang then
|
|
||||||
ang = (self.vLookatPos - self.vCamPos):Angle()
|
|
||||||
end
|
|
||||||
|
|
||||||
render.ModelMaterialOverride(matWhite)
|
render.ModelMaterialOverride(matWhite)
|
||||||
render.SuppressEngineLighting(true)
|
render.SuppressEngineLighting(true)
|
||||||
cam.IgnoreZ(true)
|
cam.IgnoreZ(true)
|
||||||
|
|
||||||
cam.Start3D(self.vCamPos - ang:Forward() * 16, ang, self.fFOV * 0.75, x, y, w, h, 5, 4096)
|
cam.Start3D(campos - ang:Forward() * 16, ang, self.fFOV * 0.75, x, y, w, h, 5, 4096)
|
||||||
render.OverrideDepthEnable(true, false)
|
render.OverrideDepthEnable(true, false)
|
||||||
render.SetColorModulation(0, 0, self.BarricadeGhosting)
|
render.SetColorModulation(0, 0, self.BarricadeGhosting)
|
||||||
ent:DrawModel()
|
ent:DrawModel()
|
||||||
render.OverrideDepthEnable(false)
|
render.OverrideDepthEnable(false)
|
||||||
cam.End3D()
|
cam.End3D()
|
||||||
|
|
||||||
cam.Start3D(self.vCamPos, ang, self.fFOV, x, y, w, h, 5, 4096)
|
cam.Start3D(campos, ang, self.fFOV, x, y, w, h, 5, 4096)
|
||||||
|
|
||||||
render.SetMaterial(matShadow)
|
render.SetMaterial(matShadow)
|
||||||
render.DrawQuadEasy(entpos, Vector(0, 0, 1), 45, 90, colShadow)
|
render.DrawQuadEasy(entpos, Vector(0, 0, 1), 45, 90, colShadow)
|
||||||
|
|
Loading…
Reference in a new issue