MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / findHitControls

Method findHitControls

Engine/source/gui/core/guiControl.cpp:1991–2050  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1989//-----------------------------------------------------------------------------
1990
1991bool GuiControl::findHitControls( const RectI& rect, Vector< GuiControl* >& outResult, U32 flags, S32 initialLayer, U32 depth )
1992{
1993 if( !mVisible )
1994 return false;
1995 else if( !mCanHit && flags & HIT_NoCanHitNoRecurse )
1996 return false;
1997
1998 // Check for hit. If not full-box, always counts.
1999
2000 bool isHit = mVisible;
2001 if( flags & HIT_FullBoxOnly )
2002 {
2003 RectI rectInParentSpace = rect;
2004 rectInParentSpace.point += getPosition();
2005
2006 isHit &= rectInParentSpace.contains( getBounds() );
2007 }
2008 else
2009 isHit &= mCanHit;
2010
2011 // If we have a hit and should not recurse into children,
2012 // return us.
2013
2014 if( isHit && flags & HIT_ParentPreventsChildHit && depth > 0 )
2015 {
2016 outResult.push_back( this );
2017 return true;
2018 }
2019
2020 // Check child controls.
2021
2022 bool haveFoundChild = false;
2023 iterator i = end();
2024
2025 while( i != begin() )
2026 {
2027 i --;
2028
2029 GuiControl* ctrl = static_cast< GuiControl* >( *i );
2030 if( initialLayer >= 0 && ctrl->mLayer > initialLayer )
2031 continue;
2032
2033 if( ctrl->getBounds().overlaps( rect ) )
2034 {
2035 RectI transposedRect = rect;
2036 transposedRect.point -= ctrl->getPosition();
2037
2038 if( ctrl->findHitControls( transposedRect, outResult, flags, -1, depth + 1 ) )
2039 haveFoundChild = true;
2040 }
2041 }
2042
2043 if( ( !haveFoundChild || flags & HIT_AddParentHits ) && isHit )
2044 {
2045 outResult.push_back( this );
2046 return true;
2047 }
2048

Callers 3

guiControl.cppFile · 0.80
doControlSnapMethod · 0.80

Calls 9

getPositionFunction · 0.85
getBoundsFunction · 0.85
endFunction · 0.85
beginFunction · 0.85
overlapsMethod · 0.80
containsMethod · 0.45
push_backMethod · 0.45
getBoundsMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected