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

Fix Cam Controller uncontrollable zooming on constant inputs #3249

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
9 changes: 5 additions & 4 deletions lua/entities/gmod_wire_cameracontroller.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
local enabled = false
local self

local clientprop

Check warning on line 48 in lua/entities/gmod_wire_cameracontroller.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: clientprop

-- Position
local pos = Vector(0,0,0)
Expand All @@ -53,10 +53,11 @@

-- Distance & zooming
local distance = 0
local curdistance = 0

Check warning on line 56 in lua/entities/gmod_wire_cameracontroller.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: curdistance
local oldcurdistance = 0

Check warning on line 57 in lua/entities/gmod_wire_cameracontroller.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: oldcurdistance
local smoothdistance = 0
local maxdistance = 16000
local adjustmaxdistance = false

local zoomdistance = 0
local zoombind = 0
Expand All @@ -65,11 +66,11 @@
local ang = Angle(0,0,0)
local smoothang = Angle(0,0,0)

local oldeyeang = Angle(0,0,0)

Check warning on line 69 in lua/entities/gmod_wire_cameracontroller.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: oldeyeang
local unroll = false

-- Options
local ParentLocal = false

Check warning on line 73 in lua/entities/gmod_wire_cameracontroller.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: ParentLocal
local AutoMove = false
local FreeMove = false
local LocalMove = false
Expand Down Expand Up @@ -115,7 +116,7 @@
local tr = {
start = start,
endpos = endpos,
mask = (AutoUnclip_IgnoreWater and CONTENTS_SOLID or bit.bor(MASK_WATER, CONTENTS_SOLID)),

Check warning on line 119 in lua/entities/gmod_wire_cameracontroller.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary parentheses"

Unnecessary parentheses
mins = Vector(-8,-8,-8),
maxs = Vector(8,8,8)
}
Expand Down Expand Up @@ -151,12 +152,13 @@
smoothpos = LerpVector( FrameTime() * pos_speed, smoothpos, curpos )

local pos_speed = pos_speed_convar:GetFloat()
local ang_speed = pos_speed - 2

Check warning on line 155 in lua/entities/gmod_wire_cameracontroller.lua

View workflow job for this annotation

GitHub Actions / lint

"Unused variable"

Unused variable: ang_speed

if AllowZoom then
if zoombind ~= 0 then
if zoombind ~= 0 or adjustmaxdistance then
zoomdistance = math.Clamp(zoomdistance + zoombind * FrameTime() * 100 * max((abs(curdistance) + abs(zoomdistance))/10,10),0,math.min(16000-curdistance, maxdistance))
zoombind = 0
adjustmaxdistance = false
end
curdistance = curdistance + zoomdistance
end
Expand Down Expand Up @@ -270,9 +272,8 @@
-- distance
distance = math.Clamp(net.ReadFloat(),-16000,16000)
maxdistance = net.ReadFloat()

if AutoMove and AllowZoom then
zoombind = 1
if AllowZoom and AutoMove then
adjustmaxdistance = true
end

-- Parent
Expand Down Expand Up @@ -587,7 +588,7 @@
local tr = {
start = start,
endpos = endpos,
mask = (self.AutoUnclip_IgnoreWater and CONTENTS_SOLID or bit.bor(MASK_WATER, CONTENTS_SOLID)),

Check warning on line 591 in lua/entities/gmod_wire_cameracontroller.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary parentheses"

Unnecessary parentheses
mins = Vector(-8,-8,-8),
maxs = Vector(8,8,8)
}
Expand Down
Loading