fix(assets): count texture requests in mission plans
Docs Deploy / Build and Deploy MkDocs (push) Successful in 36s

This commit is contained in:
Valentin Popov committed 2026-10-31 06:05:47 +04:00
1 parent 11dccef6ac
commit 8f4b8d1d14
2 files changed
+94 -8

No files matched your search

+88 -8
View File
@@ -1910,16 +1910,12 @@ impl MissionAssets {
visual_count: self.visuals.len(), visual_count: self.visuals.len(),
model_count: self.models.len(), model_count: self.models.len(),
material_count: self.materials.len(), material_count: self.materials.len(),
texture_count: self texture_count: self.visuals.iter().map(|visual| visual.texture_count).sum(),
.textures
.iter()
.filter(|texture| texture.usage == PreparedTextureUsage::Diffuse)
.count(),
lightmap_count: self lightmap_count: self
.textures .visuals
.iter() .iter()
.filter(|texture| texture.usage == PreparedTextureUsage::Lightmap) .map(|visual| visual.lightmap_count)
.count(), .sum(),
} }
} }
} }
@@ -8152,6 +8148,90 @@ mod tests {
assert!(report.texture_pixels > 0); assert!(report.texture_pixels > 0);
} }
#[test]
fn mission_asset_plan_counts_texture_and_lightmap_requests() {
let msh = minimal_model_archive();
let mat0 = mat0_with_texture(b"TEX_A");
let texm = texm_payload();
let repo = repository_with_archives_meta(&[
(
"static.rlb",
&[
TestNresEntry {
name: b"tree.msh",
payload: &msh,
type_id: 0x4853_454D,
attr2: 0,
},
TestNresEntry {
name: b"tree.wea",
payload: b"2\n0 MAT_A\n1 MAT_A\n\nLIGHTMAPS\n2\n0 LM_A\n1 LM_A\n",
type_id: WEAR_KIND,
attr2: 0,
},
],
),
(
"material.lib",
&[TestNresEntry {
name: b"MAT_A",
payload: &mat0,
type_id: MAT0_KIND,
attr2: 0,
}],
),
(
TEXTURES_ARCHIVE,
&[TestNresEntry {
name: b"TEX_A",
payload: &texm,
type_id: 0,
attr2: 0,
}],
),
(
LIGHTMAP_ARCHIVE,
&[TestNresEntry {
name: b"LM_A",
payload: &texm,
type_id: 0,
attr2: 0,
}],
),
]);
let mesh_key = ResourceKey {
archive: parse_path("static.rlb").expect("archive"),
name: resource_name(b"tree.msh"),
type_id: Some(0x4853_454D),
};
let prototype = EffectivePrototype {
key: fparkan_prototype::PrototypeKey(resource_name(b"tree")),
geometry: PrototypeGeometry::Mesh(mesh_key.clone()),
source: fparkan_prototype::PrototypeSource::DirectArchive,
source_type: None,
dependencies: vec![mesh_key],
control_resource: None,
point_resource: None,
node_data_resource: None,
bas_resource: None,
};
let (assets, report) = prepare_mission_assets_profiled_with_repository(
&repo,
&[0..1],
&[prototype],
AssetPreparationLimits::default(),
)
.expect("prepared assets");
let plan = assets.to_plan();
assert_eq!(assets.visuals.len(), 1);
assert_eq!(assets.visuals[0].texture_count, 2);
assert_eq!(assets.visuals[0].lightmap_count, 2);
assert_eq!(assets.textures.len(), 2);
assert_eq!(report.texture_count, 2);
assert_eq!((plan.texture_count, plan.lightmap_count), (2, 2));
}
#[test] #[test]
fn asset_preparation_limits_reject_texture_pixel_budget() { fn asset_preparation_limits_reject_texture_pixel_budget() {
let (repo, prototypes) = collision_fixture(); let (repo, prototypes) = collision_fixture();
+6
View File
@@ -60,6 +60,12 @@ archive object и увеличивает счётчик владельцев. Г
предметного объекта не должен напрямую закрывать архив: он зависит от данных, предметного объекта не должен напрямую закрывать архив: он зависит от данных,
но не владеет файлом как ресурсом операционной системы. но не владеет файлом как ресурсом операционной системы.
План ресурсов считает запросы от уникальных визуальных прототипов. Если два
слота материала ссылаются на один MAT0 с одной и той же текстурной фазой, это
два запроса текстуры, хотя подготовленный набор хранит один ресурс. Повторные
ссылки на `lightmap` учитываются так же. `AssetPreparationReport` и ограничения
подготовки считают уникальные подготовленные ресурсы.
## Имена и пути ## Имена и пути
Большинство игровых имён сравнивается без учёта регистра в ASCII-диапазоне. Это Большинство игровых имён сравнивается без учёта регистра в ASCII-диапазоне. Это