| 113 | } |
| 114 | |
| 115 | ITr2SpriteObject* Tr2Sprite2dPolygon::PickPoint( float x, float y, Tr2Sprite2dScene* renderer ) |
| 116 | { |
| 117 | if( !m_display || m_pickState != TR2_SPS_ON ) |
| 118 | { |
| 119 | return nullptr; |
| 120 | } |
| 121 | |
| 122 | if( !m_pickingMask || m_pickingMask->SampleMask( renderer->InverseTransformPoint( Vector2( x, y ) ), m_translation, m_displayWidth, m_displayHeight ) ) |
| 123 | { |
| 124 | renderer->PushTranslation( m_translation ); |
| 125 | ON_BLOCK_EXIT( [renderer] { renderer->PopTranslation(); } ); |
| 126 | |
| 127 | Vector2 query( x, y ); |
| 128 | |
| 129 | for( auto it = m_triangles.begin(); it != m_triangles.end(); ++it ) |
| 130 | { |
| 131 | auto p0 = m_vertices[( *it )->m_index[0]]->position; |
| 132 | auto p1 = m_vertices[( *it )->m_index[1]]->position; |
| 133 | auto p2 = m_vertices[( *it )->m_index[2]]->position; |
| 134 | |
| 135 | if( renderer->IsInsideTriangle( query, Vector2( p0.x, p0.y ), Vector2( p1.x, p1.y ), Vector2( p2.x, p2.y ) ) ) |
| 136 | { |
| 137 | return this; |
| 138 | } |
| 139 | if( renderer->IsInsideTriangle( query, Vector2( p0.x, p0.y ), Vector2( p2.x, p2.y ), Vector2( p1.x, p1.y ) ) ) |
| 140 | { |
| 141 | return this; |
| 142 | } |
| 143 | } |
| 144 | } |
| 145 | return nullptr; |
| 146 | } |
| 147 | |
| 148 | Color Tr2Sprite2dPolygon::GetColor() const |
| 149 | { |
nothing calls this directly
no test coverage detected