adding better performance stats

This commit is contained in:
samcake 2016-02-12 16:53:24 -08:00
parent e3307d91ad
commit bcd7876f6c

View file

@ -205,7 +205,6 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
details._considered += inSelection.numItems();
// Eventually use a frozen frustum
auto queryFrustum = args->_viewFrustum;
auto argFrustum = args->_viewFrustum;
if (_freezeFrustum) {
if (_justFrozeFrustum) {
@ -220,12 +219,22 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
CullFunctor _functor;
RenderArgs* _args;
RenderDetails::Item& _renderDetails;
glm::vec3 _eyePos;
float _squareTanAlpha;
Test(CullFunctor& functor, RenderArgs* pargs, RenderDetails::Item& renderDetails) :
_functor(functor),
_args(pargs),
_renderDetails(renderDetails)
{}
{
_eyePos = _args->_viewFrustum->getPosition();
float a = glm::degrees(_args->_viewFrustum->getAccuracyAngle(_args->_sizeScale, _args->_boundaryLevelAdjust));
auto angle = std::min(glm::radians(45.0f), a); // no worse than 45 degrees
angle = std::max(glm::radians(1.0f / 60.0f), a); // no better than 1 minute of degree
auto tanAlpha = tan(angle);
_squareTanAlpha = (float)(tanAlpha * tanAlpha);
}
bool frustumTest(const AABox& bound) {
PerformanceTimer perfTimer("frustumItemTest");
@ -238,6 +247,11 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
bool solidAngleTest(const AABox& bound) {
PerformanceTimer perfTimer("solidAngleItemTest");
// FIXME: Keep this code here even though we don't use it yet
//auto eyeToPoint = bound.calcCenter() - _eyePos;
//auto boundSize = bound.getDimensions();
//float test = (glm::dot(boundSize, boundSize) / glm::dot(eyeToPoint, eyeToPoint)) - squareTanAlpha;
//if (test < 0.0f) {
if (!_functor(_args, bound)) {
_renderDetails._tooSmall++;
return false;
@ -257,6 +271,8 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
// distance cull if was a subcell item ( octree cell is way bigger than the item bound itself, so now need to test per item)
// inside & fit items: easy, just filter
{
PerformanceTimer perfTimer("insideFitItems");
for (auto id : inSelection.insideItems) {
auto& item = scene->getItem(id);
if (_filter.test(item.getKey())) {
@ -264,8 +280,11 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
outItems.emplace_back(itemBound);
}
}
}
// inside & subcell items: filter & distance cull
{
PerformanceTimer perfTimer("insideSmallItems");
for (auto id : inSelection.insideSubcellItems) {
auto& item = scene->getItem(id);
if (_filter.test(item.getKey())) {
@ -275,8 +294,11 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
}
}
}
}
// partial & fit items: filter & frustum cull
{
PerformanceTimer perfTimer("partialFitItems");
for (auto id : inSelection.partialItems) {
auto& item = scene->getItem(id);
if (_filter.test(item.getKey())) {
@ -286,8 +308,11 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
}
}
}
}
// partial & subcell items:: filter & frutum cull & solidangle cull
{
PerformanceTimer perfTimer("partialSmallItems");
for (auto id : inSelection.partialSubcellItems) {
auto& item = scene->getItem(id);
if (_filter.test(item.getKey())) {
@ -299,6 +324,7 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
}
}
}
}
details._rendered += outItems.size();