MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / _validateEyePoint

Method _validateEyePoint

Engine/source/T3D/camera.cpp:1514–1563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1512//-----------------------------------------------------------------------------
1513
1514void Camera::_validateEyePoint(F32 pos, MatrixF *mat)
1515{
1516 if (pos != 0)
1517 {
1518 // Use the eye transform to orient the camera
1519 Point3F dir;
1520 mat->getColumn(1, &dir);
1521 if (mMaxOrbitDist - mMinOrbitDist > 0.0f)
1522 pos *= mMaxOrbitDist - mMinOrbitDist;
1523
1524 // Use the camera node's pos.
1525 Point3F startPos = getRenderPosition();
1526 Point3F endPos;
1527
1528 // Make sure we don't extend the camera into anything solid
1529 if(mOrbitObject)
1530 mOrbitObject->disableCollision();
1531 disableCollision();
1532 RayInfo collision;
1533 U32 mask = TerrainObjectType |
1534 WaterObjectType |
1535 StaticShapeObjectType |
1536 PlayerObjectType |
1537 ItemObjectType |
1538 VehicleObjectType;
1539
1540 SceneContainer* pContainer = isServerObject() ? &gServerContainer : &gClientContainer;
1541 if (!pContainer->castRay(startPos, startPos - dir * 2.5 * pos, mask, &collision))
1542 endPos = startPos - dir * pos;
1543 else
1544 {
1545 float dot = mDot(dir, collision.normal);
1546 if (dot > 0.01f)
1547 {
1548 F32 colDist = mDot(startPos - collision.point, dir) - (1 / dot) * CameraRadius;
1549 if (colDist > pos)
1550 colDist = pos;
1551 if (colDist < 0.0f)
1552 colDist = 0.0f;
1553 endPos = startPos - dir * colDist;
1554 }
1555 else
1556 endPos = startPos - dir * pos;
1557 }
1558 mat->setColumn(3, endPos);
1559 enableCollision();
1560 if(mOrbitObject)
1561 mOrbitObject->enableCollision();
1562 }
1563}
1564
1565//-----------------------------------------------------------------------------
1566

Callers

nothing calls this directly

Calls 6

getColumnMethod · 0.80
setColumnMethod · 0.80
mDotFunction · 0.50
disableCollisionMethod · 0.45
castRayMethod · 0.45
enableCollisionMethod · 0.45

Tested by

no test coverage detected