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

Method _validateEyePoint

Engine/source/T3D/camera.cpp:1517–1566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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