diff --git a/CREDITS.md b/CREDITS.md index e7dfbace7b..7ca3132006 100644 --- a/CREDITS.md +++ b/CREDITS.md @@ -52,6 +52,7 @@ This page lists all the individual contributions to the project by their author. - MP saves support for quicksave command and savegame trigger action - Ported XNA CnCNet Client MP save handling - Retint fix toggle + - Voxel drawing invisible sections skip - **Uranusian (Thrifinesma)**: - Mind Control enhancement - Custom warhead splash list @@ -546,6 +547,7 @@ This page lists all the individual contributions to the project by their author. - Fix a jumpjet crash related to voxel shadow drawing - Replace `BLOWFISH.DLL` using Red Alert source code - Adjust the dehardcoding of the 255 `OverlayType` limit to a different format + - Voxel drawing invisible sections skip - **CrimRecya**: - Fix `LimboKill` not working reliably - Allow using waypoints, area guard and attack move with aircraft diff --git a/docs/Fixed-or-Improved-Logics.md b/docs/Fixed-or-Improved-Logics.md index 9eea128b40..c5faa2f956 100644 --- a/docs/Fixed-or-Improved-Logics.md +++ b/docs/Fixed-or-Improved-Logics.md @@ -307,6 +307,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho - Fixed the bug that `DeploysInto` and `UndeploysInto` will make damaged techno lose 1 health. - Fixed the issue that the Jumpjet must end its movement before starting the next mission. - Fixed an issue where parachute units would die upon landing if bridges were destroyed during their descent. +- Voxel drawing code now skips sections that are invisible (have all zeros in the transform matrix main diagonal, meaning that the scale is 0% on all axes), thus increasing drawing performance for some voxels. ## Fixes / interactions with other extensions diff --git a/docs/Whats-New.md b/docs/Whats-New.md index 5d9d1aa65b..7d3bfc5b80 100644 --- a/docs/Whats-New.md +++ b/docs/Whats-New.md @@ -610,6 +610,7 @@ Vanilla fixes: - Fixed the bug that `DeploysInto` and `UndeploysInto` will make damaged techno lose 1 health (by CrimRecya) - Fixed the issue that the Jumpjet must end its movement before starting the next mission (by TaranDahl) - Fixed an issue where parachute units would die upon landing if bridges were destroyed during their descent (by FlyStar) +- Voxel drawing code now skips sections that are invisible (have all zeros in the transform matrix main diagonal, meaning that the scale is 0% on all axes), thus increasing drawing performance for some voxels (by Kerbiter, ZivDero) Phobos fixes: - Fixed the bug that `AllowAirstrike=no` cannot completely prevent air strikes from being launched against it (by NetsuNegi) diff --git a/src/Misc/Hooks.BugFixes.cpp b/src/Misc/Hooks.BugFixes.cpp index 4c34158b30..ab6b513b31 100644 --- a/src/Misc/Hooks.BugFixes.cpp +++ b/src/Misc/Hooks.BugFixes.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -3164,3 +3165,27 @@ DEFINE_HOOK(0x7442AB, UnitClass_ReadyToNextMission_FallingDown, 0x6) GET(FootClass*, pThis, ESI); return pThis->IsFallingDown ? ReturnZero : 0; } + +// sadly, useful for uncached voxels specifically, but no reason for the code to go to waste +DEFINE_HOOK(0x706F64, TechnoClass_RenderVoxelObject_SkipInvisibleSections, 0x0) +{ + enum { SkipLayer = 0x706FDF }; + + GET(MotLib* const, pMotLib, EDI); + + // stolen code + if (!pMotLib) + return 0x706FBD; + + GET(int const, layer, EBX); + GET_STACK(unsigned int const, frame, STACK_OFFSET(0x13C, 0x18)); + + auto mtx = pMotLib->GetLayerMatrix(layer, frame); + + if (mtx.row[0][0] == 0.0 && mtx.row[1][1] == 0.0 && mtx.row[2][2] == 0.0) + return SkipLayer; + + // stolen code + R->EAX(frame); + return 0x706F6F; +}