autogen cached models
This commit is contained in:
@@ -6294,6 +6294,74 @@ func TestApplyAutogenConsumersAugmentsHeadVisualeffectsFromLocalOverride(t *test
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuildGenerated2DAAssetsAppendsCachedModelsFromHeadVisualeffects(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
mkdirAll(t, filepath.Join(root, "assets", "vfxs", "head_accessories"))
|
||||
mkdirAll(t, filepath.Join(root, "assets", "vfxs", "head_features", "hair"))
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "data", "cachedmodels"))
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "head_accessories", "hfx_bandana.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "head_accessories", "hfx_existing.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "assets", "vfxs", "head_features", "hair", "hfx_hair_bangs.mdl"), "mdl\n")
|
||||
writeFile(t, filepath.Join(root, "topdata", "data", "cachedmodels", "base.json"), `{
|
||||
"columns": ["Model"],
|
||||
"rows": [
|
||||
{"id": 0, "Model": "grn_m_bone"},
|
||||
{"id": 1, "Model": "hfx_existing"}
|
||||
]
|
||||
}`+"\n")
|
||||
|
||||
p := testProject(root)
|
||||
p.Config.Paths.Assets = "assets"
|
||||
p.Config.Generated.TopData2DA = []project.GeneratedTopData2DAConfig{
|
||||
{
|
||||
ID: "cachedmodels",
|
||||
Source: "topdata",
|
||||
Output: ".cache/generated-assets/cachedmodels-2da",
|
||||
IncludeDatasets: []string{"cachedmodels"},
|
||||
PackageRoot: "vfxs",
|
||||
Autogen: project.AutogenConsumerConfig{
|
||||
ID: "cachedmodels",
|
||||
Mode: "cachedmodels_rows",
|
||||
Root: "vfxs",
|
||||
Include: []string{"head_accessories/**/*.mdl", "head_features/**/*.mdl"},
|
||||
Derive: project.AutogenDeriveConfig{Kind: "model_stem", GroupFrom: "first_path_segment"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
assets, err := BuildGenerated2DAAssets(p, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("BuildGenerated2DAAssets failed: %v", err)
|
||||
}
|
||||
if len(assets) != 1 {
|
||||
t.Fatalf("expected one generated asset, got %#v", assets)
|
||||
}
|
||||
if assets[0].Rel != "vfxs/cachedmodels.2da" {
|
||||
t.Fatalf("expected vfxs/cachedmodels.2da rel, got %q", assets[0].Rel)
|
||||
}
|
||||
bytes, err := os.ReadFile(assets[0].SourcePath)
|
||||
if err != nil {
|
||||
t.Fatalf("read generated cachedmodels.2da: %v", err)
|
||||
}
|
||||
text := string(bytes)
|
||||
for _, want := range []string{
|
||||
"0\tgrn_m_bone",
|
||||
"1\thfx_existing",
|
||||
"2\thfx_bandana",
|
||||
"3\thfx_hair_bangs",
|
||||
} {
|
||||
if !strings.Contains(text, want) {
|
||||
t.Fatalf("expected generated cachedmodels output to contain %q, got:\n%s", want, text)
|
||||
}
|
||||
}
|
||||
if strings.Contains(text, ".mdl") {
|
||||
t.Fatalf("expected cached model rows without .mdl extension, got:\n%s", text)
|
||||
}
|
||||
if strings.Count(text, "hfx_existing") != 1 {
|
||||
t.Fatalf("expected duplicate discovered model to be skipped, got:\n%s", text)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeProjectImportsLegacyLoadscreens(t *testing.T) {
|
||||
root := testProjectRoot(t)
|
||||
mkdirAll(t, filepath.Join(root, "topdata", "data"))
|
||||
|
||||
Reference in New Issue
Block a user