Skip to content

Commit

Permalink
cyka
Browse files Browse the repository at this point in the history
  • Loading branch information
chaserli committed Nov 3, 2024
1 parent db0385b commit 23196c3
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/Ext/TechnoType/Hooks.Drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(pThis->SecondaryFacing.Current().GetRadian<32>() - pThis->PrimaryFacing.Current().GetRadian<32>()));
Expand All @@ -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_cast<decltype(&pType->VoxelShadowCache)>(&pType->VoxelTurretBarrelCache);
// sorry but you're fucked
if (tur && tur->VXL && tur->HVA)

pThis->DrawVoxelShadow(
tur,
0,
std::bit_cast<VoxelIndexKey>(-1), // no cache, no use for valid key
nullptr, // no cache atm
vxl_index_key,
cache,
bounding,
&why,
&tur_mtx,
Expand All @@ -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,
Expand All @@ -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<ShadowVoxelIndexKey, VoxelCacheStruct*> VoxelTurretShadowCache {};
// IndexClass<ShadowVoxelIndexKey, VoxelCacheStruct*> VoxelBarrelShadowCache {};
Expand Down

0 comments on commit 23196c3

Please sign in to comment.