From 7466c5c99c9ebbc4acf804546b17834c0f31579a Mon Sep 17 00:00:00 2001 From: Silent Date: Sun, 8 Dec 2019 13:09:46 +0100 Subject: [PATCH] SA: Disable building pipeline for skinned objects Fixes parachute animations without having to edit the model --- SilentPatchSA/SilentPatchSA.cpp | 57 +++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/SilentPatchSA/SilentPatchSA.cpp b/SilentPatchSA/SilentPatchSA.cpp index e7d56ac..4d0b9d3 100644 --- a/SilentPatchSA/SilentPatchSA.cpp +++ b/SilentPatchSA/SilentPatchSA.cpp @@ -1638,6 +1638,36 @@ namespace StaticShadowAlphaFix } }; + +// ============= Disable building pipeline for skinned objects (like parachute) ============= +namespace SkinBuildingPipelineFix +{ + static bool atomicHasSkinPipe; + + static uint32_t (*orgGetPipelineID)(RpAtomic*); + static uint32_t GetPipelineID_SkinCheck( RpAtomic* atomic ) + { + RxPipeline* pipeline; + RpAtomicGetPipeline( atomic, &pipeline ); + + // If skin pipeline, mark it as such + if ( pipeline != nullptr && pipeline->pluginId == rwID_SKINPLUGIN ) + { + atomicHasSkinPipe = true; + return pipeline->pluginId; + } + + atomicHasSkinPipe = false; + return orgGetPipelineID( atomic ); + } + + static void* (*orgGetExtraVertColourPtr)(RpGeometry*); + static void* GetExtraVertColourPtr_SkinCheck( RpGeometry* geometry ) + { + return !atomicHasSkinPipe ? orgGetExtraVertColourPtr( geometry ) : nullptr; + } +}; + // ============= LS-RP Mode stuff ============= namespace LSRPMode { @@ -4224,6 +4254,19 @@ void Patch_SA_10() InjectHook( 0x53E0C8, RenderStoredShadows_StateFix ); } + + // Disable building pipeline for skinned objects (like parachute) + { + using namespace SkinBuildingPipelineFix; + + ReadCall( 0x5D7F46, orgGetPipelineID ); + InjectHook( 0x5D7F46, GetPipelineID_SkinCheck ); + + ReadCall( 0x5D7F60, orgGetExtraVertColourPtr ); + InjectHook( 0x5D7F60, GetExtraVertColourPtr_SkinCheck ); + } + + #if FULL_PRECISION_D3D // Test - full precision D3D device Patch( 0x7F672B+1, *(uint8_t*)(0x7F672B+1) | D3DCREATE_FPU_PRESERVE ); @@ -5666,6 +5709,20 @@ void Patch_SA_NewBinaries_Common() ReadCall( renderStaticShadows.get( 1 + 5 + 5 + 5 ), orgRenderStoredShadows ); InjectHook( renderStaticShadows.get( 1 + 5 + 5 + 5 ), RenderStoredShadows_StateFix ); } + + + // Disable building pipeline for skinned objects (like parachute) + { + using namespace SkinBuildingPipelineFix; + + auto getPipeID = pattern( "E8 ? ? ? ? 8B 76 18 83 C4 04" ).get_one(); + + ReadCall( getPipeID.get(), orgGetPipelineID ); + InjectHook( getPipeID.get(), GetPipelineID_SkinCheck ); + + ReadCall( getPipeID.get( 0x1A ), orgGetExtraVertColourPtr ); + InjectHook( getPipeID.get( 0x1A ), GetExtraVertColourPtr_SkinCheck ); + } }