@@ -357,7 +357,7 @@ struct DebugDrawContext
|
||||
Vector3 Origin = Vector3::Zero;
|
||||
DebugDrawData DebugDrawDefault;
|
||||
DebugDrawData DebugDrawDepthTest;
|
||||
Float3 LastViewPos = Float3::Zero;
|
||||
Vector3 LastViewPosition = Vector3::Zero;
|
||||
Matrix LastViewProjection = Matrix::Identity;
|
||||
BoundingFrustum LastViewFrustum;
|
||||
|
||||
@@ -790,9 +790,14 @@ bool DebugDraw::CanClear(void* context)
|
||||
|
||||
#endif
|
||||
|
||||
Vector3 DebugDraw::GetViewPos()
|
||||
Vector3 DebugDraw::GetViewPosition()
|
||||
{
|
||||
return Context->LastViewPos;
|
||||
return Context->LastViewPosition;
|
||||
}
|
||||
|
||||
Vector3 DebugDraw::GetViewOrigin()
|
||||
{
|
||||
return Context->Origin;
|
||||
}
|
||||
|
||||
BoundingFrustum DebugDraw::GetViewFrustum()
|
||||
@@ -802,7 +807,7 @@ BoundingFrustum DebugDraw::GetViewFrustum()
|
||||
|
||||
void DebugDraw::SetView(const RenderView& view)
|
||||
{
|
||||
Context->LastViewPos = view.Position;
|
||||
Context->LastViewPosition = view.WorldPosition;
|
||||
Context->LastViewProjection = view.Projection;
|
||||
Context->LastViewFrustum = view.Frustum;
|
||||
}
|
||||
@@ -1420,7 +1425,8 @@ void DebugDraw::DrawWireSphere(const BoundingSphere& sphere, const Color& color,
|
||||
int32 index;
|
||||
const Float3 centerF = sphere.Center - Context->Origin;
|
||||
const float radiusF = (float)sphere.Radius;
|
||||
const float screenRadiusSquared = RenderTools::ComputeBoundsScreenRadiusSquared(centerF, radiusF, Context->LastViewPos, Context->LastViewProjection);
|
||||
const Float3 drawPos = Context->LastViewPosition - Context->Origin;
|
||||
const float screenRadiusSquared = RenderTools::ComputeBoundsScreenRadiusSquared(centerF, radiusF, drawPos, Context->LastViewProjection);
|
||||
if (screenRadiusSquared > DEBUG_DRAW_SPHERE_LOD0_SCREEN_SIZE * DEBUG_DRAW_SPHERE_LOD0_SCREEN_SIZE * 0.25f)
|
||||
index = 0;
|
||||
else if (screenRadiusSquared > DEBUG_DRAW_SPHERE_LOD1_SCREEN_SIZE * DEBUG_DRAW_SPHERE_LOD1_SCREEN_SIZE * 0.25f)
|
||||
|
||||
@@ -74,8 +74,10 @@ API_CLASS(Static) class FLAXENGINE_API DebugDraw
|
||||
API_FUNCTION() static bool CanClear(void* context = nullptr);
|
||||
#endif
|
||||
|
||||
// Gets the last view position when rendering the current context. Can be used for custom culling or LODing when drawing more complex shapes.
|
||||
static Vector3 GetViewPos();
|
||||
// Gets the last view position (world-space) when rendering the current context. Can be used for custom culling or LODing when drawing more complex shapes.
|
||||
static Vector3 GetViewPosition();
|
||||
// Gets the last view origin (world-space) when rendering the current context. Can be used for custom culling or LODing when drawing more complex shapes.
|
||||
static Vector3 GetViewOrigin();
|
||||
// Gets the last view frustum when rendering the current context. Can be used for custom culling or LODing when drawing more complex shapes.
|
||||
static BoundingFrustum GetViewFrustum();
|
||||
|
||||
|
||||
@@ -496,7 +496,7 @@ namespace
|
||||
FORCE_INLINE float NodeSizeByDistance(const Vector3& nodePosition, bool scaleByDistance)
|
||||
{
|
||||
if (scaleByDistance)
|
||||
return (float)(Vector3::Distance(DebugDraw::GetViewPos(), nodePosition) / 100);
|
||||
return (float)(Vector3::Distance(DebugDraw::GetViewPosition(), nodePosition) / 100);
|
||||
return 5.0f;
|
||||
}
|
||||
|
||||
@@ -507,7 +507,7 @@ namespace
|
||||
return;
|
||||
Spline::Keyframe* prev = spline->Curve.GetKeyframes().Get();
|
||||
Vector3 prevPos = transform.LocalToWorld(prev->Value.Translation);
|
||||
Real distance = Vector3::Distance(prevPos, DebugDraw::GetViewPos());
|
||||
Real distance = Vector3::Distance(prevPos, DebugDraw::GetViewPosition());
|
||||
if (distance < METERS_TO_UNITS(800)) // 800m
|
||||
{
|
||||
// Bezier curve
|
||||
@@ -540,7 +540,9 @@ namespace
|
||||
|
||||
void Spline::OnDebugDraw()
|
||||
{
|
||||
if (DebugDraw::GetViewFrustum().Intersects(_sphere))
|
||||
BoundingSphere sphere(_sphere);
|
||||
sphere.Center -= DebugDraw::GetViewOrigin();
|
||||
if (DebugDraw::GetViewFrustum().Intersects(sphere))
|
||||
DrawSpline(this, GetSplineColor().AlphaMultiplied(0.7f), _transform, true);
|
||||
|
||||
// Base
|
||||
|
||||
Reference in New Issue
Block a user