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

Method PickPoint

trinity/Sprite2d/Tr2Sprite2dLineTrace.cpp:205–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205ITr2SpriteObject* 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
247float Tr2Sprite2dLineTrace::CalcLength()
248{

Callers

nothing calls this directly

Calls 6

sizeMethod · 0.80
SampleMaskMethod · 0.80
InverseTransformPointMethod · 0.80
IsInsideTriangleMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected