config option for ignoring fronts of containers

This commit is contained in:
2026-03-28 04:43:19 +01:00
parent 1e20533f10
commit b23345b273
6 changed files with 21 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
{
"total": 73071,
"total": 75390,
"sessions": [
{
"begin": "2026-03-11T23:50:47+01:00",
@@ -70,6 +70,11 @@
"begin": "2026-03-15T21:00:39+01:00",
"end": "2026-03-15T23:04:35+01:00",
"duration": 7435
},
{
"begin": "2026-03-28T03:48:55+01:00",
"end": "2026-03-28T04:27:34+01:00",
"duration": 2319
}
]
}

View File

@@ -6,6 +6,8 @@ public sealed class Config
public bool HoldKey { get; set; } = true;
public bool BillboardIgnoreFront { get; set; } = false;
public int BillboardColumnsPerBlock { get; set; } = 4;
public int ColumnsUnderCursor { get; set; } = 10;

View File

@@ -11,12 +11,13 @@ using Vintagestory.GameContent;
namespace ChestPreview.Rendering;
internal class WorldBillboardPresenter(ICoreClientAPI api)
internal class WorldBillboardPresenter(ICoreClientAPI api, Config config)
{
private const int multiblock_scan_radius = 2;
private static readonly float front_face_offset = 0.05f;
private readonly ICoreClientAPI api = api;
private readonly Config config = config;
private readonly List<BillboardTarget> frameBillboards = [];
public IReadOnlyList<BillboardTarget> FrameBillboards => frameBillboards;
@@ -162,7 +163,7 @@ internal class WorldBillboardPresenter(ICoreClientAPI api)
right = new Vec3f(1f, 0f, 0f);
up = new Vec3f(0f, 1f, 0f);
if (TryGetMeshAngle(blockEntity, out float meshAngleRadians))
if (!config.BillboardIgnoreFront && TryGetMeshAngle(blockEntity, out float meshAngleRadians))
{
// MeshAngle is around Y axis in radians.
forward = new Vec3f(MathF.Sin(meshAngleRadians), 0f, MathF.Cos(meshAngleRadians));
@@ -171,7 +172,7 @@ internal class WorldBillboardPresenter(ICoreClientAPI api)
return true;
}
if (TryGetBlockSideFacing(block, out forward))
if (!config.BillboardIgnoreFront && TryGetBlockSideFacing(block, out forward))
{
BuildBasisFromForward(forward, out right, out up);
return true;

View File

@@ -19,7 +19,7 @@ internal class WorldBillboardRenderer(ICoreClientAPI api, Config config, CardRen
private readonly List<PreviewTarget> frameTargets = [];
private readonly CardRenderer cardRenderer = cardRenderer;
private readonly PreviewTargetProvider targetProvider = new(api, config);
private readonly WorldBillboardPresenter worldBillboardPresenter = new(api);
private readonly WorldBillboardPresenter worldBillboardPresenter = new(api, config);
private readonly MeshRef quadMeshRef = api.Render.UploadMesh(
QuadMeshUtil.GetCustomQuadModelData(
1f,

View File

@@ -27,6 +27,13 @@
"default": true,
"clientSide": true
},
{
"code": "BillboardIgnoreFront",
"comment": "config-desc-BillboardIgnoreFront",
"type": "boolean",
"default": false,
"clientSide": true
},
{
"code": "BillboardColumnsPerBlock",
"comment": "config-desc-BillboardColumnsPerBlock",

View File

@@ -3,6 +3,7 @@
"hotkey-preview-containers-nearby": "Preview containers nearby",
"config-desc-Mode": "Preview mode. Valid values: None, UnderCursor, OnHoveredContainer, OnNearbyContainers.",
"config-desc-HoldKey": "Previews only show while the \"Preview containers\" key is held.",
"config-desc-BillboardIgnoreFront": "With this set to false, in-world previews show on the front side of containers. By setting this to true, the previews show on the side determined to be most visible.",
"config-desc-BillboardColumnsPerBlock": "Columns per block width used for world billboards. For containers 2 blocks wide it's doubled.",
"config-desc-ColumnsUnderCursor": "Columns in the UnderCursor mode.",
"config-desc-PreviewNearbyRadius": "Radius for \"Preview containers nearby\".",