mirror of
https://github.com/shadowscion/Primitive.git
synced 2025-03-04 03:02:58 -05:00
Merge pull request #26 from wrefgtzweve/optimizations
Check for dormancy, only do physics fix awake physics
This commit is contained in:
commit
b823ee240c
@ -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 )
|
||||
|
Loading…
Reference in New Issue
Block a user