From 3b3f47aa0d55709595613c7a7b926b4b9ee523a9 Mon Sep 17 00:00:00 2001 From: Christian Semmler Date: Fri, 29 Dec 2023 20:03:42 -0500 Subject: [PATCH] Some WIP rect --- LEGO1/legoomni.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ LEGO1/legoomni.h | 13 +++++++++++++ LEGO1/mxrect32.h | 8 ++++++++ 3 files changed, 67 insertions(+) diff --git a/LEGO1/legoomni.cpp b/LEGO1/legoomni.cpp index ddf0e454..7acb592c 100644 --- a/LEGO1/legoomni.cpp +++ b/LEGO1/legoomni.cpp @@ -695,6 +695,52 @@ MxResult Start(MxDSAction* p_dsAction) return MxOmni::GetInstance()->Start(p_dsAction); } +// Probably should be somewhere else +// FUNCTION: LEGO1 0x100b6e10 +MxBool FUN_100b6e10( + MxS32 p_bitmapWidth, + MxS32 p_bitmapHeight, + MxS32 p_videoParamWidth, + MxS32 p_videoParamHeight, + MxS32* p_left, + MxS32* p_top, + MxS32* p_right, + MxS32* p_bottom, + MxS32* p_width, + MxS32* p_height +) +{ + MxPoint32 topLeft(*p_left, *p_top); + MxRect32 bitmapRect(MxPoint32(0, 0), MxSize32(p_bitmapWidth, p_bitmapHeight)); + + MxPoint32 bottomRight(*p_right, *p_bottom); + MxRect32 videoParamRect(MxPoint32(0, 0), MxSize32(p_videoParamWidth, p_videoParamHeight)); + + MxRect32 rect(0, 0, *p_width, *p_height); + rect.AddPoint(topLeft); + + if (!rect.IntersectsWith(bitmapRect)) + return FALSE; + + rect.Intersect(bitmapRect); + rect.SubtractPoint(topLeft); + rect.AddPoint(bottomRight); + + if (!rect.IntersectsWith(videoParamRect)) + return FALSE; + rect.Intersect(videoParamRect); + rect.SubtractPoint(bottomRight); + + *p_left += rect.GetLeft(); + *p_top += rect.GetTop(); + *p_right += rect.GetLeft(); + *p_bottom += rect.GetTop(); + *p_width = rect.GetWidth(); + *p_height = rect.GetHeight(); + + return TRUE; +} + // FUNCTION: LEGO1 0x100b6ff0 void MakeSourceName(char* p_output, const char* p_input) { diff --git a/LEGO1/legoomni.h b/LEGO1/legoomni.h index dff06fb5..2aaba4cc 100644 --- a/LEGO1/legoomni.h +++ b/LEGO1/legoomni.h @@ -166,6 +166,19 @@ void FUN_10015820(MxU32, MxU32); LegoEntity* FindEntityByAtomIdOrEntityId(const MxAtomId& p_atom, MxS32 p_entityid); MxDSAction& GetCurrentAction(); +MxBool FUN_100b6e10( + MxS32 p_bitmapWidth, + MxS32 p_bitmapHeight, + MxS32 p_videoParamWidth, + MxS32 p_videoParamHeight, + MxS32* p_left, + MxS32* p_top, + MxS32* p_right, + MxS32* p_bottom, + MxS32* p_width, + MxS32* p_height +); + void PlayMusic(MxU32 p_index); void SetIsWorldActive(MxBool p_isWorldActive); void RegisterScripts(); diff --git a/LEGO1/mxrect32.h b/LEGO1/mxrect32.h index c05d5c67..f3695a15 100644 --- a/LEGO1/mxrect32.h +++ b/LEGO1/mxrect32.h @@ -56,6 +56,14 @@ class MxRect32 { this->m_bottom += p_point.GetY(); } + inline void SubtractPoint(const MxPoint32& p_point) + { + this->m_left -= p_point.GetX(); + this->m_top -= p_point.GetY(); + this->m_right -= p_point.GetX(); + this->m_bottom -= p_point.GetY(); + } + inline void SetSize(const MxSize32& p_size) { this->m_right = p_size.GetWidth();