Skip to content

GetPixelSizeAccross selects a different estimator according to argument type #42

Description

@cppctamber

Status:
Consistency question

Source version:
Carbon v5.0.0, commit 342fbe595b572070e09b583a03e215011f5924e9

Notes
I do not have a runnable Carbon build, so I could not determine whether these overload semantics are intentional.

Source
TriFrustum.cpp:236-307.

Description
GetPixelSizeAccross(const Vector3&, float) projects the center onto the view direction and divides by that depth, clamped at 1e-5.

GetPixelSizeAccrossEst(const Vector3&, float) instead divides by:

sqrt( lengthSq - radius^2 )

The remaining overloads choose between these formulas based on the argument type:

  • Vector4* forwards to the view-depth form at :236
  • Sphere forwards to GetPixelSizeAccrossEst at :295-297
  • AxisAlignedBox forwards through Sphere at :299-306

Equivalent bounds can therefore receive materially different screen-size measurements depending on whether the caller holds a Vector4, Sphere, or AxisAlignedBox.

The formulas particularly diverge off the view axis. The view-depth form can become very large when the projected depth approaches zero or is negative, while the estimated form continues to use center distance.

Both return FLT_MAX when the camera is inside the sphere. Some problematic positions may also be rejected by frustum culling before the result is consumed.

Is the type-dependent choice of estimator intentional?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions