Added debug octree stats, visible together with fps counter.

pull/278/head
pirogronian 2019-04-27 17:30:12 +02:00 committed by Łukasz Buczyński
parent 87963a6a42
commit b6f025abd3
10 changed files with 74 additions and 14 deletions

View File

@ -160,7 +160,8 @@ void DSODatabase::findVisibleDSOs(DSOHandler& dsoHandler,
const Quaternionf& obsOrient,
float fovY,
float aspectRatio,
float limitingMag) const
float limitingMag,
OctreeProcStats *stats) const
{
// Compute the bounding planes of an infinite view frustum
Hyperplane<double, 3> frustumPlanes[5];
@ -187,7 +188,8 @@ void DSODatabase::findVisibleDSOs(DSOHandler& dsoHandler,
obsPos,
frustumPlanes,
limitingMag,
DSO_OCTREE_ROOT_SIZE);
DSO_OCTREE_ROOT_SIZE,
stats);
}

View File

@ -47,7 +47,8 @@ class DSODatabase
const Eigen::Quaternionf& obsOrientation,
float fovY,
float aspectRatio,
float limitingMag) const;
float limitingMag,
OctreeProcStats * = nullptr) const;
void findCloseDSOs(DSOHandler& dsoHandler,
const Eigen::Vector3d& obsPosition,

View File

@ -71,8 +71,15 @@ void DSOOctree::processVisibleObjects(DSOHandler& processor,
const PointType& obsPosition,
const Hyperplane<double, 3>* frustumPlanes,
float limitingFactor,
double scale) const
double scale,
OctreeProcStats *stats) const
{
size_t h;
if (stats != nullptr)
{
h = stats->height + 1;
stats->nodes++;
}
// See if this node lies within the view frustum
// Test the cubic octree node against each one of the five
@ -95,6 +102,8 @@ void DSOOctree::processVisibleObjects(DSOHandler& processor,
for (unsigned int i=0; i<nObjects; ++i)
{
if (stats != nullptr)
stats->objects++;
DeepSkyObject* _obj = _firstObject[i];
float absMag = _obj->getAbsoluteMagnitude();
if (absMag < dimmest)
@ -120,8 +129,13 @@ void DSOOctree::processVisibleObjects(DSOHandler& processor,
obsPosition,
frustumPlanes,
limitingFactor,
scale * 0.5f);
scale * 0.5f,
stats);
if (stats != nullptr && stats->height > h)
h = stats->height;
}
if (stats != nullptr)
stats->height = h;
}
}
}

View File

@ -25,6 +25,13 @@
// OBJ's limiting property defined by the octree particular specialization: ie. we use [absolute magnitude] for star octrees, etc.
// For details, see notes below.
struct OctreeProcStats
{
size_t nodes { 0 };
size_t height { 0 };
size_t objects { 0 };
};
template <class OBJ, class PREC> class OctreeProcessor
{
public:
@ -118,7 +125,8 @@ template <class OBJ, class PREC> class StaticOctree
const PointType& obsPosition,
const Eigen::Hyperplane<PREC, 3>* frustumPlanes,
float limitingFactor,
PREC scale) const;
PREC scale,
OctreeProcStats * = nullptr) const;
void processCloseObjects(OctreeProcessor<OBJ, PREC>& processor,
const PointType& obsPosition,

View File

@ -6750,12 +6750,16 @@ void Renderer::renderPointStars(const StarDatabase& starDB,
else
starRenderer.starVertexBuffer->startSprites();
m_starProcStats.nodes = 0;
m_starProcStats.height = 0;
m_starProcStats.objects = 0;
starDB.findVisibleStars(starRenderer,
obsPos.cast<float>(),
observer.getOrientationf(),
degToRad(fov),
(float) windowWidth / (float) windowHeight,
faintestMagNight);
faintestMagNight,
&m_starProcStats);
starRenderer.starVertexBuffer->render();
starRenderer.glareVertexBuffer->render();
@ -7020,12 +7024,16 @@ void Renderer::renderDeepSkyObjects(const Universe& universe,
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
m_dsoProcStats.objects = 0;
m_dsoProcStats.nodes = 0;
m_dsoProcStats.height = 0;
dsoDB->findVisibleDSOs(dsoRenderer,
obsPos,
observer.getOrientationf(),
degToRad(fov),
(float) windowWidth / (float) windowHeight,
2 * faintestMagNight);
2 * faintestMagNight,
&m_dsoProcStats);
// clog << "DSOs processed: " << dsoRenderer.dsosProcessed << endl;

View File

@ -375,6 +375,8 @@ class Renderer
LightingState::EclipseShadowVector* eclipseShadows;
};
OctreeProcStats m_starProcStats;
OctreeProcStats m_dsoProcStats;
private:
struct SkyVertex
{

View File

@ -490,7 +490,8 @@ void StarDatabase::findVisibleStars(StarHandler& starHandler,
const Quaternionf& orientation,
float fovY,
float aspectRatio,
float limitingMag) const
float limitingMag,
OctreeProcStats *stats) const
{
// Compute the bounding planes of an infinite view frustum
Hyperplane<float, 3> frustumPlanes[5];
@ -513,7 +514,8 @@ void StarDatabase::findVisibleStars(StarHandler& starHandler,
position,
frustumPlanes,
limitingMag,
STAR_OCTREE_ROOT_SIZE);
STAR_OCTREE_ROOT_SIZE,
stats);
}

View File

@ -121,7 +121,8 @@ class StarDatabase
const Eigen::Quaternionf& obsOrientation,
float fovY,
float aspectRatio,
float limitingMag) const;
float limitingMag,
OctreeProcStats * = nullptr) const;
void findCloseStars(StarHandler& starHandler,
const Eigen::Vector3f& obsPosition,

View File

@ -89,8 +89,15 @@ void StarOctree::processVisibleObjects(StarHandler& processor,
const Vector3f& obsPosition,
const Hyperplane<float, 3>* frustumPlanes,
float limitingFactor,
float scale) const
float scale,
OctreeProcStats *stats) const
{
size_t h;
if (stats != nullptr)
{
h = stats->height + 1;
stats->nodes++;
}
// See if this node lies within the view frustum
// Test the cubic octree node against each one of the five
@ -112,6 +119,8 @@ void StarOctree::processVisibleObjects(StarHandler& processor,
for (unsigned int i=0; i<nObjects; ++i)
{
if (stats != nullptr)
stats->objects++;
const Star& obj = _firstObject[i];
if (obj.getAbsoluteMagnitude() < dimmest)
@ -137,8 +146,14 @@ void StarOctree::processVisibleObjects(StarHandler& processor,
obsPosition,
frustumPlanes,
limitingFactor,
scale * 0.5f);
scale * 0.5f,
stats
);
if (stats != nullptr && stats->height > h)
h = stats->height;
}
if (stats != nullptr)
stats->height = h;
}
}
}

View File

@ -3468,7 +3468,14 @@ void CelestiaCore::renderOverlay()
overlay->beginText();
*overlay << '\n';
if (showFPSCounter)
fmt::fprintf(*overlay, _("FPS: %.1f\n"), fps);
fmt::fprintf(*overlay, _("FPS: %.1f, vis. stars stats: [ %i : %i : %i ], vis. DSOs stats: [ %i : %i : %i ]\n"),
fps,
getRenderer()->m_starProcStats.objects,
getRenderer()->m_starProcStats.nodes,
getRenderer()->m_starProcStats.height,
getRenderer()->m_dsoProcStats.objects,
getRenderer()->m_dsoProcStats.nodes,
getRenderer()->m_dsoProcStats.height);
else
*overlay << '\n';