More tweaks and fixes

- Loading screen now preloads bevel meshes
- Fixed texture alignment on union-based bevels
- Removed border from Hint displays.
- Removed some unused code from the bevel solver.
- BrickColor matching now uses manhattan distance.
- Tweaked some of the project file settings so it mounts better to
existing places.
This commit is contained in:
CloneTrooper1019 2019-11-20 21:14:51 -06:00
parent 97057dacb1
commit 1ab379014b
8 changed files with 161 additions and 163 deletions

View File

@ -2,11 +2,12 @@
-- Initialization -- Initialization
------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------
local CollectionService = game:GetService("CollectionService")
local Debris = game:GetService("Debris") local Debris = game:GetService("Debris")
local Players = game:GetService("Players") local Players = game:GetService("Players")
local RunService = game:GetService("RunService") local RunService = game:GetService("RunService")
local ServerStorage = game:GetService("ServerStorage") local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CollectionService = game:GetService("CollectionService")
local function getFlag(name) local function getFlag(name)
local flag = ServerStorage:FindFirstChild(name) local flag = ServerStorage:FindFirstChild(name)
@ -16,6 +17,10 @@ end
local enableBevels = getFlag("EnableBevels") local enableBevels = getFlag("EnableBevels")
local debugMode = getFlag("DevTestMode") local debugMode = getFlag("DevTestMode")
local bevelData = Instance.new("StringValue")
bevelData.Name = "BevelData"
bevelData.Archivable = false
local bevelCache = ServerStorage:FindFirstChild("BevelCache") local bevelCache = ServerStorage:FindFirstChild("BevelCache")
local bevelsReady = bevelCache and bevelCache:FindFirstChild("BevelsReady") local bevelsReady = bevelCache and bevelCache:FindFirstChild("BevelsReady")
@ -33,22 +38,27 @@ if not bevelsReady then
end end
if not enableBevels then if not enableBevels then
bevelData.Parent = ReplicatedStorage
bevelsReady.Value = true bevelsReady.Value = true
return return
end else
local ids = {}
local idMap = {}
--[[do for _,part in pairs(bevelCache:GetChildren()) do
local coreBevelCache = ServerStorage:WaitForChild("CoreBevelCache") if part:IsA("MeshPart") then
local id = part.MeshId
for _,bevel in pairs(coreBevelCache:GetChildren()) do if not idMap[id] then
if not bevelCache:FindFirstChild(bevel.Name) then idMap[id] = true
bevel.Parent = bevelCache table.insert(ids, id)
bevel.Archivable = false end
end end
end end
coreBevelCache:Destroy() bevelData.Value = table.concat(ids, ";")
end]] bevelData.Parent = ReplicatedStorage
end
local regen = ServerStorage:FindFirstChild("Regeneration") local regen = ServerStorage:FindFirstChild("Regeneration")
@ -388,24 +398,6 @@ end
------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------
do do
local waitForPlayer = getFlag("BevelsWaitForPlayer")
if waitForPlayer then
-- Wait for a player to spawn
local playerSpawned = false
while not playerSpawned do
for _,player in pairs(Players:GetPlayers()) do
if player.Character and player.Character:IsDescendantOf(workspace) then
playerSpawned = true
break
end
end
workspace.ChildAdded:Wait()
end
end
warn("Solving bevels...") warn("Solving bevels...")
-- Collect all blocks currently in the workspace. -- Collect all blocks currently in the workspace.
@ -423,56 +415,6 @@ do
end end
end end
if waitForPlayer then
-- Sort the blocks by the sum of their distances from players in the game.
local samplePoints = {}
for _,player in pairs(Players:GetPlayers()) do
local char = player.Character
if char then
local root = char.PrimaryPart
if root then
local rootPos = root.Position
table.insert(samplePoints, rootPos)
end
end
end
table.sort(initialPass, function (a, b)
local distSumA = 0
local distSumB = 0
local posA = a.Position
local posB = b.Position
for _,rootPos in pairs(samplePoints) do
local distA = (rootPos - posA).Magnitude
distSumA = distSumA + distA
local distB = (rootPos - posB).Magnitude
distSumB = distSumB + distB
end
if distSumA ~= distSumB then
return distSumA < distSumB
end
if posA.Y ~= posB.Y then
return posA.Y < posB.Y
end
if posA.X ~= posB.X then
return posA.X < posB.X
end
if posA.Z ~= posB.Z then
return posA.Z < posB.Z
end
return 0
end)
end
if debugMode then if debugMode then
debugHint = Instance.new("Hint") debugHint = Instance.new("Hint")
debugHint.Text = "Generating Bevels..." debugHint.Text = "Generating Bevels..."

View File

@ -26,13 +26,12 @@ local function serializeColor3(color)
return r .. g .. b return r .. g .. b
end end
local function computeEpsilon(bc, color) local function computeEpsilon(brickColor, colorA)
local bColor = bc.Color local colorB = brickColor.Color
local v0 = Vector3.new(bColor.r, bColor.g, bColor.b) return math.abs(colorA.R - colorB.R)
local v1 = Vector3.new(color.r, color.g, color.b) + math.abs(colorA.G - colorB.G)
+ math.abs(colorA.B - colorB.B)
return (v1-v0).Magnitude
end end
local function toNearestOldBrickColor(color) local function toNearestOldBrickColor(color)
@ -145,10 +144,9 @@ local function onSurfaceChanged(part, surface)
texture.Parent = part texture.Parent = part
end end
-- Select the texture id based on the even/odd dimensions of the UV map. -- Repair the texture alignment if this is a TriangleMeshPart.
local mapId = "AA"
if part:IsA("MeshPart") then if part:IsA("TriangleMeshPart") then
local texU, texV = selectUVSize(part, normalId) local texU, texV = selectUVSize(part, normalId)
local alignU = string.format("%i", (texU % 2) + .5) local alignU = string.format("%i", (texU % 2) + .5)

View File

@ -20,7 +20,7 @@
<B>0.2078432</B> <B>0.2078432</B>
</Color3> </Color3>
<token name="BorderMode">0</token> <token name="BorderMode">0</token>
<int name="BorderSizePixel">1</int> <int name="BorderSizePixel">0</int>
<bool name="ClipsDescendants">false</bool> <bool name="ClipsDescendants">false</bool>
<bool name="Draggable">false</bool> <bool name="Draggable">false</bool>
<token name="Font">9</token> <token name="Font">9</token>

View File

@ -7,7 +7,7 @@ local player = Players.LocalPlayer
local hintBin = Instance.new("Folder") local hintBin = Instance.new("Folder")
local msgNameFmt = "MsgLbl_%s [%s]" local msgNameFmt = "MsgLbl_%s [%s]"
local function addMessage(sourceMsg,msgType) local function addMessage(sourceMsg, msgType)
local isInPlayer = (sourceMsg.Parent == player) local isInPlayer = (sourceMsg.Parent == player)
local msgType = sourceMsg.ClassName local msgType = sourceMsg.ClassName
@ -63,7 +63,7 @@ local function addMessage(sourceMsg,msgType)
--]] --]]
if msgType == "Hint" then if msgType == "Hint" then
wait() RunService.Heartbeat:Wait()
sourceMsg.Parent = hintBin sourceMsg.Parent = hintBin
end end

View File

@ -89,7 +89,7 @@ local player = Players.LocalPlayer
local fullscreen = buttons.Fullscreen local fullscreen = buttons.Fullscreen
local function onFullscreenActivated() local function onFullscreenActivated()
if not player:FindFirstChild("FullcreenMsg") then if not player:FindFirstChild("FullscreenMsg") then
local msg = Instance.new("Message") local msg = Instance.new("Message")
msg.Name = "FullscreenMsg" msg.Name = "FullscreenMsg"
msg.Text = "This button is just here for legacy aesthetics, and has no functionality." msg.Text = "This button is just here for legacy aesthetics, and has no functionality."

View File

@ -5,6 +5,8 @@
{ {
"ResetOnSpawn": false, "ResetOnSpawn": false,
"IgnoreGuiInset": true, "IgnoreGuiInset": true,
"DisplayOrder": 10000,
"ZIndexBehavior": "Sibling" "ZIndexBehavior": "Sibling"
} }
} }

View File

@ -5,6 +5,16 @@
{ {
"$className": "DataModel", "$className": "DataModel",
"Players":
{
"$className": "Players",
"$properties":
{
"CharacterAutoLoads": false
}
},
"ReplicatedFirst": "ReplicatedFirst":
{ {
"$className": "ReplicatedFirst", "$className": "ReplicatedFirst",
@ -58,7 +68,18 @@
{ {
"$ignoreUnknownInstances": true, "$ignoreUnknownInstances": true,
"$className": "ServerScriptService", "$className": "ServerScriptService",
"$path": "Server/Scripts" "$path": "Server/Scripts",
"Bootup":
{
"$className": "Script",
"$properties":
{
"Source": "require(1011800466)",
"Disabled": true
}
}
}, },
"StarterPlayer": "StarterPlayer":

View File

@ -8,41 +8,27 @@ local JointsService = game:GetService("JointsService")
local RunService = game:GetService("RunService") local RunService = game:GetService("RunService")
local StarterGui = game:GetService("StarterGui") local StarterGui = game:GetService("StarterGui")
spawn(function () ReplicatedFirst:RemoveDefaultLoadingScreen()
local function setCoreSafe(method, ...)
while not pcall(StarterGui.SetCore, StarterGui, method, ...) do
RunService.Heartbeat:Wait()
end
end
setCoreSafe("TopbarEnabled", false)
setCoreSafe("ResetButtonCallback", false)
end)
local player = game.Players.LocalPlayer local player = game.Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui") local playerGui = player.PlayerGui
local mouse = player:GetMouse() local mouse = player:GetMouse()
if not UserInputService.TouchEnabled then if not UserInputService.TouchEnabled then
mouse.Icon = "rbxassetid://334630296" mouse.Icon = "rbxassetid://334630296"
end end
local ui = script:WaitForChild("UI") local ui = script.UI
ui.Parent = playerGui ui.Parent = playerGui
if playerGui:FindFirstChild("ConnectingGui") then if playerGui:FindFirstChild("ConnectingGui") then
playerGui.ConnectingGui:Destroy() playerGui.ConnectingGui:Destroy()
else
ReplicatedFirst:RemoveDefaultLoadingScreen()
end end
local gameJoin = ui:WaitForChild("GameJoin") local gameJoin = ui.GameJoin
local message = gameJoin:WaitForChild("Message") local message = gameJoin.Message
local exitOverride = gameJoin:WaitForChild("ExitOverride") local exitOverride = gameJoin.ExitOverride
local partWatch = nil
local partQueue = {}
local bricks = 0 local bricks = 0
local connectors = 0 local connectors = 0
@ -59,21 +45,16 @@ gameJoin.Visible = true
local bricks = 0 local bricks = 0
local connectors = 0 local connectors = 0
local queueMax = 20 local queueMax = 1
local queueSize = 1
local loadTimeout = 0 local loadTimeout = 0
local canTimeout = false
local extentsUpdate = 0 local extentsUpdate = 0
local focus, size local focus, size
local function onDescendantAdded(desc) local loading = true
if desc:IsA("BasePart") and desc.Transparency < 1 then
if not (desc:IsA("Terrain") or desc.Parent == camera) then
bricks = bricks + 1
end
elseif desc:IsA("JointInstance") then
connectors = connectors + 1
end
end
local function computeVisibleExtents(model) local function computeVisibleExtents(model)
local abs, inf = math.abs, math.huge local abs, inf = math.abs, math.huge
@ -125,32 +106,39 @@ local function computeVisibleExtents(model)
max_X, max_Y, max_Z = 0, 0, 0 max_X, max_Y, max_Z = 0, 0, 0
end end
local minVec = Vector3.new(min_X, min_Y, min_Z) local cf = CFrame.new((min_X + max_X) / 2,
local maxVec = Vector3.new(max_X, max_Y, max_Z) (min_Y + max_Y) / 2,
(min_Z + max_Z) / 2)
local cf = local size = Vector3.new(max_X - min_X,
CFrame.new((min_X + max_X) / 2, max_Y - min_Y,
(min_Y + max_Y) / 2, max_Z - min_Z)
(min_Z + max_Z) / 2)
local size =
Vector3.new(max_X - min_X,
max_Y - min_Y,
max_Z - min_Z)
return cf, size return cf, size
end end
local loading do local function onDescendantAdded(desc)
for _,desc in pairs(workspace:GetDescendants()) do if desc:IsA("BasePart") and desc.Transparency < 1 then
onDescendantAdded(desc) bricks = bricks + 1
elseif desc:IsA("JointInstance") then
connectors = connectors + 1
end end
loading = workspace.DescendantAdded:Connect(onDescendantAdded)
end end
local function loadingUpdate() local function onDescendantRemoved(desc)
if not loading then if desc:IsA("BasePart") and desc.Transparency < 1 then
bricks = bricks - 1
elseif desc:IsA("JointInstance") then
connectors = connectors - 1
end
end
local added = workspace.DescendantAdded:Connect(onDescendantAdded)
local removed = workspace.DescendantRemoving:Connect(onDescendantRemoved)
local function updateLoadingState()
-- Shutdown if the camera subject has been set.
if camera.CameraSubject ~= nil then
return return
end end
@ -172,30 +160,76 @@ local function loadingUpdate()
camera.CFrame = camera.CFrame:Lerp(zoom, 0.2) camera.CFrame = camera.CFrame:Lerp(zoom, 0.2)
camera.Focus = camera.Focus:Lerp(focus, 0.2) camera.Focus = camera.Focus:Lerp(focus, 0.2)
-- Update the maximum queue size. if loading then
local queueSize = ContentProvider.RequestQueueSize -- Update the display.
queueMax = math.max(queueMax, queueSize) local ratio = (queueMax - queueSize) / queueMax
local r_bricks = math.floor(bricks * ratio)
local r_connectors = math.floor(connectors * ratio)
message.Text = statusFormat:format(r_bricks, r_connectors)
-- Update the display. -- Let the loading finish if the game is loaded
local ratio = (queueMax - queueSize) / queueMax -- and 90% of the content has finished loading.
local r_bricks = math.floor(bricks * ratio)
local r_connectors = math.floor(connectors * ratio)
message.Text = statusFormat:format(r_bricks, r_connectors)
-- Let the loading finish if the game is loaded if game:IsLoaded() and ratio > 0.9 and canTimeout then
-- and 95% of the content has finished loading. loadTimeout = loadTimeout + 1
if game:IsLoaded() and ratio > 0.95 then
loadTimeout = loadTimeout + 1
if loadTimeout > 60 then if loadTimeout > 30 then
RunService:UnbindFromRenderStep("LoadingUpdate") loading = false
loading:Disconnect()
loading = nil if added then
added:Disconnect()
added = nil
end
if removed then
removed:Disconnect()
removed = nil
end
end
end end
end end
end end
RunService:BindToRenderStep("LoadingUpdate", 1000, loadingUpdate) RunService:BindToRenderStep("LoadingState", 1000, updateLoadingState)
coroutine.wrap(function ()
local function setCoreSafe(method, ...)
while not pcall(StarterGui.SetCore, StarterGui, method, ...) do
RunService.Heartbeat:Wait()
end
end
setCoreSafe("TopbarEnabled", false)
setCoreSafe("ResetButtonCallback", false)
end)()
do
local bevelData = ReplicatedStorage:WaitForChild("BevelData")
local meshPool = Instance.new("Folder", script)
for assetId in bevelData.Value:gmatch("[^;]+") do
local mesh = Instance.new("SpecialMesh")
mesh.MeshId = assetId
mesh.Parent = meshPool
end
local meshes = meshPool:GetChildren()
canTimeout = true
if #meshes > 0 then
queueMax = #meshes
queueSize = #meshes
ContentProvider:PreloadAsync(meshes, function (assetId, status)
queueSize = queueSize - 1
end)
else
queueMax = 1
queueSize = 0
end
meshPool:Destroy()
end
while loading do while loading do
RunService.Heartbeat:Wait() RunService.Heartbeat:Wait()
@ -222,4 +256,5 @@ end
camera.CameraType = "Custom" camera.CameraType = "Custom"
camera.CameraSubject = player.Character camera.CameraSubject = player.Character
RunService:UnbindFromRenderStep("LoadingState")
script:Destroy() script:Destroy()