Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify: Weld and no-collide conditions #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lua/weapons/gmod_tool/stools/stacker_improved.lua
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ function TOOL:LeftClick( tr, isRightClick )
local stayInWorld = cvarStayInWorld:GetBool()

-- store the properties of the original prop so we can apply them to the stacked props
local ent = tr.Entity
local ent = tr.Entity
local entPos = ent:GetPos()
local entAng = ent:GetAngles()
local entMod = ent:GetModel()
Expand All @@ -662,9 +662,7 @@ function TOOL:LeftClick( tr, isRightClick )
RenderFX = ent:GetRenderFX()
}

local newEnt
local newEnts = { ent }
local lastEnt = ent
local newEnts, lastEnt, newEnt = { ent }, ent, nil

local direction, offset
-- we only need to calculate the distance once based on the direction the user selected
Expand Down Expand Up @@ -874,7 +872,7 @@ end
-- Attempts to weld the new entity to the last entity.
--]]--
function TOOL:ApplyWeld( lastEnt, newEnt )
if ( not self:ShouldForceWeld() and not self:ShouldApplyWeld() ) then return true end
if ( not ( self:ShouldForceWeld() or self:ShouldApplyWeld() ) ) then return true end

local forceLimit = 0
local isNocollided = self:ShouldForceNoCollide() or self:ShouldApplyNoCollide()
Expand All @@ -897,7 +895,7 @@ end
-- Attempts to nocollide the new entity to the last entity.
--]]--
function TOOL:ApplyNoCollide( lastEnt, newEnt )
if ( not self:ShouldForceNoCollide() and not self:ShouldApplyNoCollide() ) then return true end
if ( not ( self:ShouldForceNoCollide() or self:ShouldApplyNoCollide() ) ) then return true end
-- we can skip this function if the client is trying to weld -and- nocollide, because
-- constraint.Weld already has a nocollide parameter
if ( self:ShouldForceWeld() or self:ShouldApplyWeld() ) then return true end
Expand Down Expand Up @@ -1678,4 +1676,4 @@ if ( CLIENT ) then
end
end )
end )
end
end