MONKEY (reviewfix): isolate animated sky materials
Co-Authored-By: GPT-5.6 Sol (Codex)
This commit is contained in:
co-authored by
GPT-5.6 Sol (Codex)
parent
488d451500
commit
82240e8e76
@@ -542,14 +542,16 @@ fn build_skybox(
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut lane_materials = [pair.steady.clone(), pair.fade_blend.clone()];
|
||||
let lane = SkyMatLane::register(
|
||||
sub,
|
||||
uv,
|
||||
tint,
|
||||
&mut table,
|
||||
mats.materials(),
|
||||
&[pair.steady.id(), pair.fade_blend.id()],
|
||||
&mut lane_materials,
|
||||
);
|
||||
[pair.steady, pair.fade_blend] = lane_materials;
|
||||
let mesh = meshes.add(mesh);
|
||||
let pose = match sole_bone(sub) {
|
||||
Some(b) if rig.bone_moves(b) => PartPose::Rigid(b),
|
||||
|
||||
@@ -333,21 +333,38 @@ impl SkyMatLane {
|
||||
tint: Option<Arc<benilla_formats::RgbAnim>>,
|
||||
table: &mut crate::mat_anim_table::MatAnimTable,
|
||||
materials: &mut Assets<benilla_assets::materials::WowModelMaterial>,
|
||||
mats: &[AssetId<benilla_assets::materials::WowModelMaterial>],
|
||||
mats: &mut [Handle<benilla_assets::materials::WowModelMaterial>],
|
||||
) -> Self {
|
||||
let mut lane = SkyMatLane::default();
|
||||
let write = |materials: &mut Assets<benilla_assets::materials::WowModelMaterial>,
|
||||
f: &dyn Fn(&mut benilla_assets::materials::WowModelMaterial)| {
|
||||
for id in mats {
|
||||
crate::model_render::lazy::with_material_mut(materials, *id, |m| f(m));
|
||||
// MONKEY (reviewfix): `model_material` is a cache. Animation slots are per sky batch, so
|
||||
// detach its handles before writing any slot (notably affine-only `.z`) into the material.
|
||||
let originals = mats.to_vec();
|
||||
for i in 0..mats.len() {
|
||||
if let Some(prior) = (0..i).find(|&j| originals[j].id() == originals[i].id()) {
|
||||
mats[i] = mats[prior].clone();
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if let Some(material) =
|
||||
crate::model_render::lazy::with_material_mut(materials, originals[i].id(), |m| {
|
||||
m.clone()
|
||||
})
|
||||
{
|
||||
mats[i] = materials.add(material);
|
||||
}
|
||||
}
|
||||
let mut lane = SkyMatLane::default();
|
||||
let write =
|
||||
|materials: &mut Assets<benilla_assets::materials::WowModelMaterial>,
|
||||
f: &dyn Fn(&mut benilla_assets::materials::WowModelMaterial)| {
|
||||
for id in mats.iter() {
|
||||
crate::model_render::lazy::with_material_mut(materials, id.id(), |m| f(m));
|
||||
}
|
||||
};
|
||||
if let Some(uv) = uv.filter(|a| a.period > 0.0) {
|
||||
if let Some(slot) = table.alloc() {
|
||||
let seed = mats
|
||||
.first()
|
||||
.and_then(|id| {
|
||||
crate::model_render::lazy::with_material_mut(materials, *id, |m| {
|
||||
.and_then(|handle| {
|
||||
crate::model_render::lazy::with_material_mut(materials, handle.id(), |m| {
|
||||
[m.extension.sun_scale.z, m.extension.sun_scale.w]
|
||||
})
|
||||
})
|
||||
@@ -376,8 +393,8 @@ impl SkyMatLane {
|
||||
if let Some(slot) = table.alloc() {
|
||||
let seed = mats
|
||||
.first()
|
||||
.and_then(|id| {
|
||||
crate::model_render::lazy::with_material_mut(materials, *id, |m| {
|
||||
.and_then(|handle| {
|
||||
crate::model_render::lazy::with_material_mut(materials, handle.id(), |m| {
|
||||
[m.extension.tint.x, m.extension.tint.y, m.extension.tint.z]
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user