Camera: add a distance to bounding box function
This commit is contained in:
parent
06e5c6adab
commit
9031796f85
@ -501,6 +501,17 @@ float Camera::GetDistance(const Vector3& worldPos) const
|
||||
return Abs((GetView() * worldPos).z_);
|
||||
}
|
||||
|
||||
float Camera::GetDistance(const BoundingBox& box) const
|
||||
{
|
||||
if (!orthographic_)
|
||||
{
|
||||
const Vector3& cameraPos = node_ ? node_->GetWorldPosition() : Vector3::ZERO;
|
||||
return box.DistanceToPoint(cameraPos);
|
||||
}
|
||||
else
|
||||
return Abs((GetView() * box.Center()).z_);
|
||||
}
|
||||
|
||||
float Camera::GetDistanceSquared(const Vector3& worldPos) const
|
||||
{
|
||||
if (!orthographic_)
|
||||
|
@ -234,6 +234,8 @@ public:
|
||||
|
||||
/// Return distance to position. In orthographic mode uses only Z coordinate.
|
||||
float GetDistance(const Vector3& worldPos) const;
|
||||
/// Return distance to bounding box. In orthographic mode uses only Z coordinate.
|
||||
float GetDistance(const BoundingBox& box) const;
|
||||
/// Return squared distance to position. In orthographic mode uses only Z coordinate.
|
||||
float GetDistanceSquared(const Vector3& worldPos) const;
|
||||
/// Return a scene node's LOD scaled distance.
|
||||
|
Loading…
Reference in New Issue
Block a user