diff --git a/changelog/snippets/feature.6906.md b/changelog/snippets/feature.6906.md new file mode 100644 index 00000000000..9101a4a0d67 --- /dev/null +++ b/changelog/snippets/feature.6906.md @@ -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. diff --git a/env/Common/Props/hydrocarbonDeposit01_prop.bp b/env/Common/Props/hydrocarbonDeposit01_prop.bp index 35668bd670e..0c52e7847d5 100644 --- a/env/Common/Props/hydrocarbonDeposit01_prop.bp +++ b/env/Common/Props/hydrocarbonDeposit01_prop.bp @@ -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, } \ No newline at end of file diff --git a/env/Common/Props/massDeposit01_prop.bp b/env/Common/Props/massDeposit01_prop.bp index f9a1bd5fa2f..77d6e15951b 100644 --- a/env/Common/Props/massDeposit01_prop.bp +++ b/env/Common/Props/massDeposit01_prop.bp @@ -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, } \ No newline at end of file diff --git a/lua/system/blueprints-props.lua b/lua/system/blueprints-props.lua index 2923cbcda8b..685f0a05eb9 100644 --- a/lua/system/blueprints-props.lua +++ b/lua/system/blueprints-props.lua @@ -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