MCPcopy Create free account
hub / github.com/carbonengine/trinity / PickPoint

Method PickPoint

trinity/Sprite2d/Tr2Sprite2dTransform.cpp:44–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44ITr2SpriteObject* Tr2Sprite2dTransform::PickPoint( float x, float y, Tr2Sprite2dScene* renderer )
45{
46 if( !m_display )
47 {
48 return NULL;
49 }
50 if( m_pickState == TR2_SPS_OFF )
51 {
52 return NULL;
53 }
54
55 // Check that we're within the bounding box of the transform object itself
56 renderer->PushTranslation( m_translation );
57 bool isInside = renderer->IsInside( Vector2( x, y ), Vector2( 0.0f, 0.0f ), m_displayWidth, m_displayHeight, 0.0 );
58 if( isInside && m_pickingMask )
59 {
60 isInside = m_pickingMask->SampleMask( renderer->InverseTransformPoint( Vector2( x, y ) ), Vector2( 0.0f, 0.0f ), m_displayWidth, m_displayHeight );
61 }
62 renderer->PopTranslation();
63 if( !isInside )
64 {
65 return NULL;
66 }
67
68 ITr2SpriteObject* obj = NULL;
69 renderer->PushTransform( GetTransformationMatrix() );
70
71 for( ITr2SpriteObjectVector::iterator it = m_children.begin(); it != m_children.end(); ++it )
72 {
73 obj = ( *it )->PickPoint( x, y, renderer );
74 if( obj )
75 {
76 break;
77 }
78 }
79
80 // If transform itself is pickable and no child was found
81 if( m_pickState == TR2_SPS_ON )
82 {
83 this->m_auxMouseover = NULL;
84 if( !obj )
85 {
86 obj = this;
87 }
88 else
89 {
90 if( obj->IsAuxMouseover() )
91 {
92 // The auxiliary mouseover can add content to the mouseover text or context menu
93 this->m_auxMouseover = obj;
94 obj = this;
95 }
96 }
97 }
98 renderer->PopTransform();
99
100 return obj;
101}

Callers

nothing calls this directly

Calls 10

PushTranslationMethod · 0.80
IsInsideMethod · 0.80
SampleMaskMethod · 0.80
InverseTransformPointMethod · 0.80
PopTranslationMethod · 0.80
PushTransformMethod · 0.80
PopTransformMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
IsAuxMouseoverMethod · 0.45

Tested by

no test coverage detected