From 9265226a09f04afc48cc8567d73233f622f78050 Mon Sep 17 00:00:00 2001 From: Silent Date: Fri, 27 Dec 2019 16:04:46 +0100 Subject: [PATCH] III: Give chopper/escape their own col model which is big enough --- SilentPatchIII/ModelInfoIII.h | 75 +++++++++++++++++++++++++++++++ SilentPatchIII/SilentPatchIII.cpp | 12 +++++ 2 files changed, 87 insertions(+) diff --git a/SilentPatchIII/ModelInfoIII.h b/SilentPatchIII/ModelInfoIII.h index 8d573e2..c9f640d 100644 --- a/SilentPatchIII/ModelInfoIII.h +++ b/SilentPatchIII/ModelInfoIII.h @@ -1,6 +1,81 @@ #pragma once #include +#include "Maths.h" + +// This really belongs in Maths.h but San Andreas optimized those structured heavily... +struct CColSphere +{ + CVector m_center; + float m_radius; + uint8_t m_surface; + uint8_t m_piece; + + void Set(float radius, const CVector& center, uint8_t surf, uint8_t piece) + { + m_center = center; + m_radius = radius; + m_surface = surf; + m_piece = piece; + } + + void Set(float radius, const CVector& center) + { + m_center = center; + m_radius = radius; + } + + constexpr CColSphere( float radius, const CVector& center, uint8_t surf, uint8_t piece ) + : m_center( center ), m_radius( radius ), m_surface( surf ), m_piece( piece ) + { + } +}; + +struct CColBox +{ + CVector m_min; + CVector m_max; + uint8_t m_surface; + uint8_t m_piece; + + void Set(const CVector& min, const CVector& max, uint8_t surf, uint8_t piece) + { + m_min = min; + m_max = max; + m_surface = surf; + m_piece = piece; + } + + CVector GetSize() const { return m_max - m_min; } + + constexpr CColBox( const CVector& min, const CVector& max, uint8_t surf, uint8_t piece ) + : m_min( min ), m_max( max ), m_surface( surf ), m_piece( piece ) + { + } +}; + +struct CColModel +{ + CColSphere m_boundingSphere; + CColBox m_boundingBox; + short m_m_numSpheres = 0; + short m_numLines = 0; + short m_numBoxes = 0; + short m_numTriangles = 0; + int m_level = 0; + bool m_ownsCollisionVolumes = false; + CColSphere* m_spheres = nullptr; + struct CColLine* m_lines = nullptr; + CColBox* m_boxes = nullptr; + CVector* m_vertices = nullptr; + struct CColTriangle* m_triangles = nullptr; + struct CColTrianglePlane* m_trianglePlanes = nullptr; + + constexpr CColModel( const CColSphere& sphere, const CColBox& box ) + : m_boundingSphere( sphere ), m_boundingBox ( box ) + { + } +}; class CSimpleModelInfo { diff --git a/SilentPatchIII/SilentPatchIII.cpp b/SilentPatchIII/SilentPatchIII.cpp index 6c25d91..5cd4849 100644 --- a/SilentPatchIII/SilentPatchIII.cpp +++ b/SilentPatchIII/SilentPatchIII.cpp @@ -1213,6 +1213,18 @@ void Patch_III_Common() ReadCall( loadAllAudioScriptObjects, orgLoadAllAudioScriptObjects ); InjectHook( loadAllAudioScriptObjects, LoadAllAudioScriptObjects_InitializedCheck ); } + + + // Give chopper/escape a properly sized collision bounding box instead of using ped's + { + static constexpr CColModel colModelChopper( CColSphere( 8.5f, CVector(0.0f, -1.75f, 0.73f), 0, 0 ), + CColBox( CVector(-2.18f, -8.52f, -0.67f), CVector(-2.18f, 4.58f, 2.125f), 0, 0 ) ); + + auto initHelis = pattern( "C6 40 2C 00 A1" ).get_one(); + + Patch( initHelis.get( -7 + 3 ), &colModelChopper ); + Patch( initHelis.get( 9 + 3 ), &colModelChopper ); + } } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)