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

Method IsInside

trinity/Sprite2d/Tr2Sprite2dScene.cpp:1338–1446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1336}
1337
1338bool Tr2Sprite2dScene::IsInside( const Vector2& pointIn, const Vector2& topLeft, float width, float height, float radius )
1339{
1340 if( !IsInsideClipRect( pointIn ) )
1341 {
1342 return false;
1343 }
1344
1345 //local copy so we can manipulate it
1346 //this makes non-translation transforms easier to implement
1347 Vector2 point = pointIn;
1348
1349 float top;
1350 float left;
1351 float bottom;
1352 float right;
1353
1354 if( m_transformStack->empty() )
1355 {
1356 left = topLeft.x;
1357 top = topLeft.y;
1358 right = left + width;
1359 bottom = top + height;
1360 }
1361 else
1362 {
1363 const TransformStackEntry& topEntry = m_transformStack->back();
1364
1365 if( topEntry.isTranslationOnly )
1366 {
1367 left = topLeft.x + topEntry.translation.x;
1368 top = topLeft.y + topEntry.translation.y;
1369 right = left + width;
1370 bottom = top + height;
1371 }
1372 else
1373 {
1374 left = topLeft.x;
1375 top = topLeft.y;
1376 right = left + width;
1377 bottom = top + height;
1378
1379 const Matrix& transform = topEntry.transform;
1380
1381 //construct inverse, transform point by this, compare against
1382 // untransformed bounding rectangle
1383 Matrix inv = Inverse( transform );
1384
1385 TransformPoint( point, point, inv );
1386 }
1387 }
1388
1389 if( point.x < left )
1390 {
1391 return false;
1392 }
1393 if( point.x > right )
1394 {
1395 return false;

Callers 8

PickPointMethod · 0.80
PickPointMethod · 0.80
PickPointMethod · 0.80
PickPointMethod · 0.80
PickPointMethod · 0.80
PickPointMethod · 0.80
PickPointMethod · 0.80
PickPointMethod · 0.80

Calls 2

TransformPointFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected