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:
JetBoom 2014-11-08 22:49:03 -05:00
parent 59dc08372b
commit aa08d47a35

View file

@ -138,22 +138,14 @@ function PANEL:Think()
self.BarricadeGhosting = math.Approach(self.BarricadeGhosting, lp:IsBarricadeGhosting() and 1 or 0, FrameTime() * 5)
local model = lp:GetModel()
local modelscale = lp:GetModelScale()
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
self.OverrideEntity:Remove()
self.OverrideEntity = nil
end
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
local overridemodel = lp.status_overridemodel
@ -209,29 +201,33 @@ function PANEL:Paint()
if not lp:IsValid() then return end
local x, y = self:LocalToScreen(0, 0)
local ang = self.aLookAngle
local w, h = self:GetSize()
local health = self.Health
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)
if not ang then
ang = (self.vLookatPos - self.vCamPos):Angle()
end
render.ModelMaterialOverride(matWhite)
render.SuppressEngineLighting(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.SetColorModulation(0, 0, self.BarricadeGhosting)
ent:DrawModel()
render.OverrideDepthEnable(false)
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.DrawQuadEasy(entpos, Vector(0, 0, 1), 45, 90, colShadow)