Merge pull request #26 from wrefgtzweve/optimizations

Check for dormancy, only do physics fix awake physics
This commit is contained in:
shadowscion 2024-08-26 18:18:21 -05:00 committed by GitHub
commit b823ee240c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,3 +1,9 @@
local entMeta = FindMetaTable( "Entity" )
local entIsDormant = entMeta.IsDormant
local entGetTable = entMeta.GetTable
local CLIENT = CLIENT
local SERVER = SERVER
local class = { Type = "anim", Base = "base_anim", Spawnable = false, AdminOnly = true, IsPrimitive = true }
@ -363,25 +369,28 @@ function class:PrimitiveSetThread( result )
end
function class:Think()
if self.primitive.init then
if self.PRIMITIVE_FROM_DUPE then
if CLIENT and entIsDormant( self ) then return end
local entTable = entGetTable( self )
if entTable.primitive.init then
if entTable.PRIMITIVE_FROM_DUPE then
return
end
if SysTime() - self.primitive.init > updateTime:GetFloat() then
if SysTime() - entTable.primitive.init > updateTime:GetFloat() then
self:PrimitiveReconstruct()
self.primitive.init = nil
end
end
if CLIENT and self.m_bCustomCollisions then
if CLIENT and entTable.m_bCustomCollisions then
-- workaround for clientside physics bug
-- https://github.com/Facepunch/garrysmod-issues/issues/5060
local physobj = self:GetPhysicsObject()
if physobj:IsValid() then
if physobj:IsValid() and not physobj:IsAsleep() then
physobj:SetPos( self:GetPos() )
physobj:SetAngles( self:GetAngles() )
physobj:EnableMotion( false )