Skip to content

Commit

Permalink
(0.629.0.6290609)
Browse files Browse the repository at this point in the history
  • Loading branch information
EgoMoose authored and github-actions[bot] committed Jun 13, 2024
1 parent 462b8cd commit c933fdf
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 339 deletions.
49 changes: 5 additions & 44 deletions src/PlayerModulePatched/CameraModule/ClassicCamera.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,10 @@ local FIRST_PERSON_DISTANCE_MIN = 0.5
local CommonUtils = script.Parent.Parent:WaitForChild("CommonUtils")
local FlagUtil = require(CommonUtils:WaitForChild("FlagUtil"))

local FFlagUserRemoveVRReferences
do
local success, result = pcall(function()
return UserSettings():IsUserFeatureEnabled("UserRemoveVRReferences")
end)
FFlagUserRemoveVRReferences = success and result
end
local FFlagUserFixCameraOffsetJitter = FlagUtil.getUserFlag("UserFixCameraOffsetJitter2")

--[[ Services ]]--
local PlayersService = game:GetService("Players")
local VRService = game:GetService("VRService") -- remove with FFlagUserRemoveVRReferences

local CameraInput = require(script.Parent:WaitForChild("CameraInput"))
local Util = require(script.Parent:WaitForChild("CameraUtils"))
Expand Down Expand Up @@ -179,7 +171,7 @@ function ClassicCamera:Update()
end
end

elseif self.isFollowCamera and (not (isInFirstPerson or userRecentlyPannedCamera) and (FFlagUserRemoveVRReferences or (not VRService.VREnabled))) then
elseif self.isFollowCamera and not (isInFirstPerson or userRecentlyPannedCamera) then
-- Logic that was unique to the old FollowCamera module
local lastVec = -(self.lastCameraTransform.p - subjectPosition)

Expand All @@ -200,46 +192,15 @@ function ClassicCamera:Update()
end

if not self.isFollowCamera then
local VREnabled = VRService.VREnabled and not FFlagUserRemoveVRReferences

if VREnabled then -- remove with FFlagUserRemoveVRReferences
newCameraFocus = self:GetVRFocus(subjectPosition, timeDelta)
else
newCameraFocus = CFrame.new(subjectPosition)
end
newCameraFocus = CFrame.new(subjectPosition)

local cameraFocusP = newCameraFocus.p
if VREnabled and not self:IsInFirstPerson() then
local vecToSubject = (subjectPosition - camera.CFrame.p)
local distToSubject = vecToSubject.magnitude

local flaggedRotateInput = rotateInput

-- Only move the camera if it exceeded a maximum distance to the subject in VR
if distToSubject > zoom or flaggedRotateInput.x ~= 0 then
local desiredDist = math.min(distToSubject, zoom)
vecToSubject = self:CalculateNewLookVectorFromArg(nil, rotateInput) * desiredDist
local newPos = cameraFocusP - vecToSubject
local desiredLookDir = camera.CFrame.lookVector
if flaggedRotateInput.x ~= 0 then
desiredLookDir = vecToSubject
end
local lookAt = Vector3.new(newPos.x + desiredLookDir.x, newPos.y, newPos.z + desiredLookDir.z)

newCameraCFrame = CFrame.new(newPos, lookAt) + Vector3.new(0, cameraHeight, 0)
end
else
local newLookVector = self:CalculateNewLookVectorFromArg(overrideCameraLookVector, rotateInput)
newCameraCFrame = CFrame.new(cameraFocusP - (zoom * newLookVector), cameraFocusP)
end
local newLookVector = self:CalculateNewLookVectorFromArg(overrideCameraLookVector, rotateInput)
newCameraCFrame = CFrame.new(cameraFocusP - (zoom * newLookVector), cameraFocusP)
else -- is FollowCamera
local newLookVector = self:CalculateNewLookVectorFromArg(overrideCameraLookVector, rotateInput)

if VRService.VREnabled and not FFlagUserRemoveVRReferences then
newCameraFocus = self:GetVRFocus(subjectPosition, timeDelta)
else
newCameraFocus = CFrame.new(subjectPosition)
end
newCameraFocus = CFrame.new(subjectPosition)
newCameraCFrame = CFrame.new(newCameraFocus.p - (zoom * newLookVector), newCameraFocus.p) + Vector3.new(0, cameraHeight, 0)
end

Expand Down
56 changes: 12 additions & 44 deletions src/PlayerModulePatched/CameraModule/OrbitalCamera.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ local TAU = 2 * math.pi
local MIN_ALLOWED_ELEVATION_DEG = -80
local MAX_ALLOWED_ELEVATION_DEG = 80

local FFlagUserRemoveVRReferences
do
local success, result = pcall(function()
return UserSettings():IsUserFeatureEnabled("UserRemoveVRReferences")
end)
FFlagUserRemoveVRReferences = success and result
end

local externalProperties = {}
externalProperties["InitialDistance"] = 25
externalProperties["MinDistance"] = 10
Expand All @@ -40,7 +32,6 @@ local CameraInput = require(script.Parent:WaitForChild("CameraInput"))

--[[ Services ]]--
local PlayersService = game:GetService('Players')
local VRService = game:GetService("VRService") -- remove with FFlagUserRemoveVRReferences

--[[ The Module ]]--
local BaseCamera = require(script.Parent:WaitForChild("BaseCamera"))
Expand Down Expand Up @@ -254,49 +245,26 @@ function OrbitalCamera:Update(dt: number): (CFrame, CFrame)
self:SetCameraToSubjectDistance(self.currentSubjectDistance * self.gamepadDollySpeedMultiplier)
end

local VREnabled = VRService.VREnabled and not FFlagUserRemoveVRReferences
newCameraFocus = VREnabled and self:GetVRFocus(subjectPosition, timeDelta) or CFrame.new(subjectPosition)
newCameraFocus = CFrame.new(subjectPosition)

local flaggedRotateInput = CameraInput.getRotation()

local cameraFocusP = newCameraFocus.p
if VREnabled and not self:IsInFirstPerson() then
local cameraHeight = self:GetCameraHeight()
local vecToSubject: Vector3 = (subjectPosition - camera.CFrame.p)
local distToSubject: number = vecToSubject.Magnitude

-- Only move the camera if it exceeded a maximum distance to the subject in VR
if distToSubject > self.currentSubjectDistance or flaggedRotateInput.X ~= 0 then
local desiredDist = math.min(distToSubject, self.currentSubjectDistance)

-- Note that CalculateNewLookVector is overridden from BaseCamera
vecToSubject = self:CalculateNewLookVector(vecToSubject.Unit * X1_Y0_Z1, Vector2.new(flaggedRotateInput.X, 0)) * desiredDist

local newPos = cameraFocusP - vecToSubject
local desiredLookDir = camera.CFrame.LookVector
if flaggedRotateInput.X ~= 0 then
desiredLookDir = vecToSubject
end
local lookAt = Vector3.new(newPos.X + desiredLookDir.X, newPos.Y, newPos.Z + desiredLookDir.Z)
newCameraCFrame = CFrame.new(newPos, lookAt) + Vector3.new(0, cameraHeight, 0)
end
else
-- rotateInput is a Vector2 of mouse movement deltas since last update
self.curAzimuthRad = self.curAzimuthRad - flaggedRotateInput.X
-- rotateInput is a Vector2 of mouse movement deltas since last update
self.curAzimuthRad = self.curAzimuthRad - flaggedRotateInput.X

if self.useAzimuthLimits then
self.curAzimuthRad = math.clamp(self.curAzimuthRad, self.minAzimuthAbsoluteRad, self.maxAzimuthAbsoluteRad)
else
self.curAzimuthRad = (self.curAzimuthRad ~= 0) and (math.sign(self.curAzimuthRad) * (math.abs(self.curAzimuthRad) % TAU)) or 0
end
if self.useAzimuthLimits then
self.curAzimuthRad = math.clamp(self.curAzimuthRad, self.minAzimuthAbsoluteRad, self.maxAzimuthAbsoluteRad)
else
self.curAzimuthRad = (self.curAzimuthRad ~= 0) and (math.sign(self.curAzimuthRad) * (math.abs(self.curAzimuthRad) % TAU)) or 0
end

self.curElevationRad = math.clamp(self.curElevationRad + flaggedRotateInput.Y, self.minElevationRad, self.maxElevationRad)
self.curElevationRad = math.clamp(self.curElevationRad + flaggedRotateInput.Y, self.minElevationRad, self.maxElevationRad)

local cameraPosVector = self.currentSubjectDistance * ( CFrame.fromEulerAnglesYXZ( -self.curElevationRad, self.curAzimuthRad, 0 ) * UNIT_Z )
local camPos = subjectPosition + cameraPosVector
local cameraPosVector = self.currentSubjectDistance * ( CFrame.fromEulerAnglesYXZ( -self.curElevationRad, self.curAzimuthRad, 0 ) * UNIT_Z )
local camPos = subjectPosition + cameraPosVector

newCameraCFrame = CFrame.new(camPos, subjectPosition)
end
newCameraCFrame = CFrame.new(camPos, subjectPosition)

self.lastCameraTransform = newCameraCFrame
self.lastCameraFocus = newCameraFocus
Expand Down
10 changes: 1 addition & 9 deletions src/PlayerModulePatched/CameraModule/TransparencyController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
2018 Camera Update - AllYourBlox
--]]

local FFlagUserVRAvatarGestures
do
local success, result = pcall(function()
return UserSettings():IsUserFeatureEnabled("UserVRAvatarGestures")
end)
FFlagUserVRAvatarGestures = success and result
end

local VRService = game:GetService("VRService")
local MAX_TWEEN_RATE = 2.8 -- per second

Expand Down Expand Up @@ -178,7 +170,7 @@ function TransparencyController:Update(dt)
-- update transparencies
if self.transparencyDirty or self.lastTransparency ~= transparency then
for child, _ in pairs(self.cachedParts) do
if FFlagUserVRAvatarGestures and VRService.VREnabled and VRService.AvatarGestures then
if VRService.VREnabled and VRService.AvatarGestures then
-- keep the arms visible in VR
local hiddenAccessories = {
[Enum.AccessoryType.Hat] = true,
Expand Down
57 changes: 13 additions & 44 deletions src/PlayerModulePatched/CameraModule/VRCamera.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,6 @@

--[[ Services ]]--

local FFlagUserVRAvatarGestures
do
local success, result = pcall(function()
return UserSettings():IsUserFeatureEnabled("UserVRAvatarGestures")
end)
FFlagUserVRAvatarGestures = success and result
end

local FFlagUserFixVRAvatarGesturesSeats
do
local success, result = pcall(function()
return UserSettings():IsUserFeatureEnabled("UserFixVRAvatarGesturesSeats")
end)
FFlagUserFixVRAvatarGesturesSeats = success and result
end


local PlayersService = game:GetService("Players")
local VRService = game:GetService("VRService")
local UserGameSettings = UserSettings():GetService("UserGameSettings")
Expand All @@ -49,10 +32,8 @@ function VRCamera.new()
self.focusOffset = CFrame.new()
self:Reset()

if FFlagUserVRAvatarGestures then
self.controlModule = require(PlayersService.LocalPlayer:WaitForChild("PlayerScripts").PlayerModule:WaitForChild("ControlModule"))
self.savedAutoRotate = true
end
self.controlModule = require(PlayersService.LocalPlayer:WaitForChild("PlayerScripts").PlayerModule:WaitForChild("ControlModule"))
self.savedAutoRotate = true

return self
end
Expand Down Expand Up @@ -101,7 +82,7 @@ function VRCamera:Update(timeDelta)
newCameraFocus = self:GetVRFocus(subjectPosition, timeDelta)
-- update camera cframe based on first/third person
if self:IsInFirstPerson() then
if FFlagUserVRAvatarGestures and VRService.AvatarGestures then
if VRService.AvatarGestures then
-- the immersion camera better aligns the player with the avatar
newCameraCFrame, newCameraFocus = self:UpdateImmersionCamera(
timeDelta,newCameraCFrame, newCameraFocus, lastSubjPos, subjectPosition)
Expand Down Expand Up @@ -218,7 +199,7 @@ function VRCamera:UpdateImmersionCamera(timeDelta, newCameraCFrame, newCameraFoc
newCameraCFrame = subjectCFrame
else
-- if seated, just keep aligned with the seat itself
if FFlagUserFixVRAvatarGesturesSeats and humanoid.Sit then
if humanoid.Sit then
newCameraCFrame = subjectCFrame
if (newCameraCFrame.Position - curCamera.CFrame.Position).Magnitude > 0.01 then
self:StartVREdgeBlur(PlayersService.LocalPlayer)
Expand Down Expand Up @@ -291,12 +272,7 @@ function VRCamera:UpdateThirdPersonComfortTransform(timeDelta, newCameraCFrame,
-- compute delta of subject since last update
local player = PlayersService.LocalPlayer
local subjectDelta = lastSubjPos - subjectPosition
local moveVector
if FFlagUserVRAvatarGestures then
self.controlModule:GetMoveVector()
else
moveVector = require(player:WaitForChild("PlayerScripts").PlayerModule:WaitForChild("ControlModule")):GetMoveVector()
end
local moveVector = self.controlModule:GetMoveVector()

-- is the subject still moving?
local isMoving = subjectDelta.magnitude > 0.01 or moveVector.magnitude > 0.01
Expand Down Expand Up @@ -387,12 +363,7 @@ function VRCamera:UpdateThirdPersonFollowTransform(timeDelta, newCameraCFrame, n
-- figure out if the player is moving
local player = PlayersService.LocalPlayer
local subjectDelta = lastSubjPos - subjectPosition
local controlModule
if FFlagUserVRAvatarGestures then
controlModule = self.controlModule
else
controlModule = require(player:WaitForChild("PlayerScripts").PlayerModule:WaitForChild("ControlModule"))
end
local controlModule = self.controlModule
local moveVector = controlModule:GetMoveVector()

-- while moving, slowly adjust camera so the avatar is in front of your head
Expand Down Expand Up @@ -444,16 +415,14 @@ function VRCamera:LeaveFirstPerson()
self.VRBlur.Visible = false
end

if FFlagUserVRAvatarGestures then
if self.characterOrientation then
self.characterOrientation.Enabled = false
if self.characterOrientation then
self.characterOrientation.Enabled = false

end
local humanoid = self:GetHumanoid()
if humanoid then
humanoid.AutoRotate = self.savedAutoRotate
end
end
local humanoid = self:GetHumanoid()
if humanoid then
humanoid.AutoRotate = self.savedAutoRotate
end
end

return VRCamera
return VRCamera
32 changes: 5 additions & 27 deletions src/PlayerModulePatched/ControlModule/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ local DynamicThumbstick = require(script:WaitForChild("DynamicThumbstick"))

local FFlagUserUpdateInputConnections = FlagUtil.getUserFlag("UserUpdateInputConnections")


local FFlagUserVRAvatarGestures
do
local success, result = pcall(function()
return UserSettings():IsUserFeatureEnabled("UserVRAvatarGestures")
end)
FFlagUserVRAvatarGestures = success and result
end

local FFlagUserDynamicThumbstickSafeAreaUpdate do
local success, result = pcall(function()
return UserSettings():IsUserFeatureEnabled("UserDynamicThumbstickSafeAreaUpdate")
Expand All @@ -55,15 +46,6 @@ local FFlagUserFixTouchJumpBug do
end)
FFlagUserFixTouchJumpBug = success and result
end

local FFlagUserFixVRAvatarGesturesSeats
do
local success, result = pcall(function()
return UserSettings():IsUserFeatureEnabled("UserFixVRAvatarGesturesSeats")
end)
FFlagUserFixVRAvatarGesturesSeats = success and result
end

local TouchThumbstick = require(script:WaitForChild("TouchThumbstick"))

-- These controllers handle only walk/run movement, jumping is handled by the
Expand Down Expand Up @@ -139,9 +121,7 @@ function ControlModule.new()
self.touchControlFrame = nil
self.currentTorsoAngle = 0

if FFlagUserVRAvatarGestures then
self.inputMoveVector = Vector3.new(0,0,0)
end
self.inputMoveVector = Vector3.new(0,0,0)

self.vehicleController = VehicleController.new(CONTROL_ACTION_PRIORITY)

Expand Down Expand Up @@ -539,11 +519,9 @@ function ControlModule:OnRenderStepped(dt)
moveVector = self:calculateRawMoveVector(self.humanoid, moveVector)
end

if FFlagUserVRAvatarGestures then
self.inputMoveVector = moveVector
if VRService.VREnabled then
moveVector = self:updateVRMoveVector(moveVector)
end
self.inputMoveVector = moveVector
if VRService.VREnabled then
moveVector = self:updateVRMoveVector(moveVector)
end

self.moveFunction(Players.LocalPlayer, moveVector, false)
Expand All @@ -563,7 +541,7 @@ function ControlModule:updateVRMoveVector(moveVector)

-- if the player is not moving via input in first person, follow the VRHead
if moveVector.Magnitude == 0 and firstPerson and VRService.AvatarGestures and self.humanoid
and (not FFlagUserFixVRAvatarGesturesSeats or not self.humanoid.Sit) then
and not self.humanoid.Sit then

local vrHeadOffset = VRService:GetUserCFrame(Enum.UserCFrame.Head)
vrHeadOffset = vrHeadOffset.Rotation + vrHeadOffset.Position * curCamera.HeadScale
Expand Down
Loading

0 comments on commit c933fdf

Please sign in to comment.