Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions changelog/snippets/feature.6906.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- (#6906) Tweak the formula used to calculate the level of detail (LOD) for props.

Large props are visible for longer, and it should now be easier again to spot broken tree groups.
6 changes: 3 additions & 3 deletions env/Common/Props/hydrocarbonDeposit01_prop.bp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ PropBlueprint{
CollisionOffsetX = 0,
CollisionOffsetY = 0,
CollisionOffsetZ = 0,
SizeX = 0.1,
SizeY = 0.1,
SizeZ = 0.1,
SizeX = 1.0,
SizeY = 0.2,
SizeZ = 1.0,
}
4 changes: 2 additions & 2 deletions env/Common/Props/massDeposit01_prop.bp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PropBlueprint{
Physics = { BlockPath = false },
ScriptClass = "PropInvulnerable",
ScriptModule = "/lua/sim/prop.lua",
SizeX = 0.1,
SizeX = 0.9,
SizeY = 0.1,
SizeZ = 0.1,
SizeZ = 0.9,
}
48 changes: 26 additions & 22 deletions lua/system/blueprints-props.lua
Original file line number Diff line number Diff line change
Expand Up @@ -107,31 +107,35 @@ end
--- - https://github.com/FAForever/fa/pull/4675
---@param prop PropBlueprint
local function ProcessLOD(prop)

local sx = prop.SizeX or 1
local sy = prop.SizeY or 1
local sz = prop.SizeZ or 1

-- give more emphasis to the x / z value as that is easier to see in the average camera angle
local weighted = 0.40 * sx + 0.2 * sy + 0.4 * sz
if prop.ScriptClass == 'Tree' or prop.ScriptClass == 'TreeGroup' then
weighted = 10.0
end

-- https://www.desmos.com/calculator (0.9 * sqrt(100 * 500 * x))
local lod = 0.9 * MathSqrt(100 * 500 * weighted)

if prop.Display and prop.Display.Mesh and prop.Display.Mesh.LODs then
local n = TableGetn(prop.Display.Mesh.LODs)
for k = 1, n do
local data = prop.Display.Mesh.LODs[k]

-- https://www.desmos.com/calculator (x * x)
local factor = (k / n) * (k / n)
local LODCutoff = factor * lod
local sx = prop.SizeX or 1
local sy = prop.SizeY or 1
local sz = prop.SizeZ or 1

-- give more emphasis to the x / z value as that is easier to see in the average camera angle
local weightedLodSize = MathSqrt(sx * sx + 0.5 * sy * sy + sz * sz)
local maxLod = 180 * weightedLodSize

if (prop.ScriptClass == 'Tree' or prop.ScriptClass == 'TreeGroup')
then
if TableGetn(prop.Display.Mesh.LODs) == 3 then
prop.Display.Mesh.LODs[1].LODCutoff = 40
prop.Display.Mesh.LODs[2].LODCutoff = 165
prop.Display.Mesh.LODs[3].LODCutoff = 640
return
end
maxLod = 640
end

local levels = TableGetn(prop.Display.Mesh.LODs)
for n = 1, levels do
local data = prop.Display.Mesh.LODs[n]
local factor = (n / levels)
local LODCutoff = factor * maxLod

-- sanitize the value
data.LODCutoff = MathFloor(LODCutoff / 10 + 1) * 10
-- round the value
data.LODCutoff = MathFloor((LODCutoff + 5) / 10) * 10
end
end
end
Expand Down
Loading