feat(ugc): brick data through the client's assets; colours from Materials.xml everywhere

The UGC server reads brickdb.zip and brickprimitives through DLU's
AssetManager (loose files first, then the client's packs, as the game
does), so packed clients and bricks added to a client work. It falls
back to loose files under res/ as before.

In the LU Toolbox palette (the default), a colour LU Toolbox doesn't
know but the client's Materials.xml has, such as one added to the brick
database, is drawn in its Materials.xml colour instead of black. Ids
neither knows stay LU Toolbox's black.

The dashboard's 3D viewers get the brick colours from the client's
Materials.xml (/api/bricks/materials.js) instead of a hardcoded copy, so
added colours show there too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Aaron Kimbrell
2026-09-27 17:47:00 -05:00
parent 453f728b5e
commit 36cefc1ede
11 changed files with 136 additions and 191 deletions

View File

@@ -161,6 +161,33 @@ TEST(UgcModel, BuildsOpaqueAndTransparentMeshes) {
EXPECT_NEAR(model.opaque.positions[0].x, 10.0f, 1e-5f);
}
// A color LU Toolbox's palette doesn't have but the client's Materials.xml does (one added to the brick database) is
// drawn in its Materials.xml color; one neither knows is LU Toolbox's black
TEST(UgcModel, ColorsOnlyInMaterialsXmlAreNotBlack) {
UgcBricks::BrickLibrary library(MakeRes(), 0);
constexpr uint32_t ADDED = 50001;
ASSERT_FALSE(UgcPalette::Linear(ADDED));
library.SetMaterials({ { ADDED, { 0, 200, 100, 255 } } });
std::string error;
UgcModel::BuildOptions options;
options.palette = UgcModel::ePalette::LU_TOOLBOX;
options.colorVariation = 0.0f;
const auto brick = [&error](uint32_t material) {
return UgcModel::ParseLxfml("<LXFML versionMajor=\"5\"><Bricks><Brick><Part designID=\"3001\" materials=\"" + std::to_string(material) +
"\"><Bone transformation=\"1,0,0,0,1,0,0,0,1,0,0,0\"/></Part></Brick></Bricks></LXFML>", error);
};
const auto added = UgcModel::Build(brick(ADDED), library, options);
ASSERT_FALSE(added.opaque.colors.empty());
EXPECT_NEAR(added.opaque.colors[0].g, 200.0f / 255.0f, 1e-3f);
EXPECT_NEAR(added.opaque.colors[0].r, 0.0f, 1e-3f);
ASSERT_FALSE(UgcPalette::Linear(50002));
const auto unknown = UgcModel::Build(brick(50002), library, options);
ASSERT_FALSE(unknown.opaque.colors.empty());
const auto black = UgcModel::Build(brick(UgcPalette::FALLBACK_ID), library, options);
ASSERT_FALSE(black.opaque.colors.empty());
EXPECT_EQ(unknown.opaque.colors[0], black.opaque.colors[0]);
}
TEST(UgcModel, SplitsBigMeshes) {
UgcModel::Mesh mesh;
for (uint32_t i = 0; i < 30; i++) {