From ee8832f8dbe3537499fbc452cf23e63e639efba3 Mon Sep 17 00:00:00 2001 From: Trsdy <914137150@qq.com> Date: Sun, 3 Nov 2024 20:13:45 +0800 Subject: [PATCH] cyka --- src/Ext/TechnoType/Hooks.Drawing.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Ext/TechnoType/Hooks.Drawing.cpp b/src/Ext/TechnoType/Hooks.Drawing.cpp index 4439750317..b1a693dc05 100644 --- a/src/Ext/TechnoType/Hooks.Drawing.cpp +++ b/src/Ext/TechnoType/Hooks.Drawing.cpp @@ -399,6 +399,9 @@ DEFINE_HOOK(0x73C47A, UnitClass_DrawAsVXL_Shadow, 0x5) return nullptr; }; + auto tur = GetTurretVoxel(pThis->CurrentTurretNumber); + if (tur && tur->VXL && tur->HVA) + { Matrix3D rot = Matrix3D::GetIdentity(); uTypeExt->ApplyTurretOffset(&rot, Pixel_Per_Lepton); rot.RotateZ(static_cast(pThis->SecondaryFacing.Current().GetRadian<32>() - pThis->PrimaryFacing.Current().GetRadian<32>())); @@ -407,15 +410,20 @@ DEFINE_HOOK(0x73C47A, UnitClass_DrawAsVXL_Shadow, 0x5) auto& arr = tur_mtx.row; arr[0][2] = arr[1][2] = arr[2][2] = arr[2][1] = arr[2][0] = 0; } - auto tur = GetTurretVoxel(pThis->CurrentTurretNumber); - + auto bar = GetBarrelVoxel(pThis->CurrentTurretNumber); + auto haveBar = bar && bar->VXL && bar->HVA && !bar->VXL->Initialized; + if (vxl_index_key.Is_Valid_Key()) + vxl_index_key.TurretWeapon.Facing = pThis->SecondaryFacing.Current().GetFacing<32>(); + if (haveBar) + vxl_index_key.Invalidate(); + auto* cache = haveBar || tur != &pType->TurretVoxel ? nullptr : reinterpret_castVoxelShadowCache)>(&pType->VoxelTurretBarrelCache); // sorry but you're fucked - if (tur && tur->VXL && tur->HVA) + pThis->DrawVoxelShadow( tur, 0, - std::bit_cast(-1), // no cache, no use for valid key - nullptr, // no cache atm + vxl_index_key, + cache, bounding, &why, &tur_mtx, @@ -424,10 +432,9 @@ DEFINE_HOOK(0x73C47A, UnitClass_DrawAsVXL_Shadow, 0x5) shadow_point ); - auto bar = GetBarrelVoxel(pThis->CurrentTurretNumber); // and you are utterly fucked - if (bar && bar->VXL && bar->HVA) + if (haveBar) pThis->DrawVoxelShadow( bar, 0, @@ -440,7 +447,7 @@ DEFINE_HOOK(0x73C47A, UnitClass_DrawAsVXL_Shadow, 0x5) surface, shadow_point ); - + } // Add caches in Ext if necessary, remember not to serialize these shit // IndexClass VoxelTurretShadowCache {}; // IndexClass VoxelBarrelShadowCache {};