| 203 | } |
| 204 | |
| 205 | ITr2SpriteObject* Tr2Sprite2dLineTrace::PickPoint( float x, float y, Tr2Sprite2dScene* renderer ) |
| 206 | { |
| 207 | if( !m_display ) |
| 208 | { |
| 209 | return nullptr; |
| 210 | } |
| 211 | |
| 212 | if( m_pickState == TR2_SPS_ON ) |
| 213 | { |
| 214 | if( m_renderVertices.size() < 2 ) |
| 215 | { |
| 216 | return nullptr; |
| 217 | } |
| 218 | |
| 219 | if( !m_pickingMask || m_pickingMask->SampleMask( renderer->InverseTransformPoint( Vector2( x, y ) ), m_translation, m_displayWidth, m_displayHeight ) ) |
| 220 | { |
| 221 | Vector2 p( x, y ); |
| 222 | |
| 223 | for( auto it = m_drawCalls.begin(); it != m_drawCalls.end(); ++it ) |
| 224 | { |
| 225 | for( size_t i = 0; i < size_t( it->indexCount / 3 ); ++i ) |
| 226 | { |
| 227 | auto ix0 = m_renderIndices[i * 3 + it->indexOffset]; |
| 228 | auto ix1 = m_renderIndices[i * 3 + it->indexOffset + 1]; |
| 229 | auto ix2 = m_renderIndices[i * 3 + it->indexOffset + 2]; |
| 230 | |
| 231 | auto v0 = m_renderVertices[ix0 + it->vertexOffset]; |
| 232 | auto v1 = m_renderVertices[ix1 + it->vertexOffset]; |
| 233 | auto v2 = m_renderVertices[ix2 + it->vertexOffset]; |
| 234 | |
| 235 | if( renderer->IsInsideTriangle( p, *(Vector2*)&v0.position, *(Vector2*)&v1.position, *(Vector2*)&v2.position ) ) |
| 236 | { |
| 237 | return this; |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | return nullptr; |
| 245 | } |
| 246 | |
| 247 | float Tr2Sprite2dLineTrace::CalcLength() |
| 248 | { |
nothing calls this directly
no test coverage detected