mirror of
https://github.com/overte-org/overte.git
synced 2025-07-16 19:17:16 +02:00
adding better performance stats
This commit is contained in:
parent
e3307d91ad
commit
bcd7876f6c
1 changed files with 53 additions and 27 deletions
|
@ -205,7 +205,6 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
|
||||||
details._considered += inSelection.numItems();
|
details._considered += inSelection.numItems();
|
||||||
|
|
||||||
// Eventually use a frozen frustum
|
// Eventually use a frozen frustum
|
||||||
auto queryFrustum = args->_viewFrustum;
|
|
||||||
auto argFrustum = args->_viewFrustum;
|
auto argFrustum = args->_viewFrustum;
|
||||||
if (_freezeFrustum) {
|
if (_freezeFrustum) {
|
||||||
if (_justFrozeFrustum) {
|
if (_justFrozeFrustum) {
|
||||||
|
@ -220,12 +219,22 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
|
||||||
CullFunctor _functor;
|
CullFunctor _functor;
|
||||||
RenderArgs* _args;
|
RenderArgs* _args;
|
||||||
RenderDetails::Item& _renderDetails;
|
RenderDetails::Item& _renderDetails;
|
||||||
|
glm::vec3 _eyePos;
|
||||||
|
float _squareTanAlpha;
|
||||||
|
|
||||||
Test(CullFunctor& functor, RenderArgs* pargs, RenderDetails::Item& renderDetails) :
|
Test(CullFunctor& functor, RenderArgs* pargs, RenderDetails::Item& renderDetails) :
|
||||||
_functor(functor),
|
_functor(functor),
|
||||||
_args(pargs),
|
_args(pargs),
|
||||||
_renderDetails(renderDetails)
|
_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) {
|
bool frustumTest(const AABox& bound) {
|
||||||
PerformanceTimer perfTimer("frustumItemTest");
|
PerformanceTimer perfTimer("frustumItemTest");
|
||||||
|
@ -238,6 +247,11 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
|
||||||
|
|
||||||
bool solidAngleTest(const AABox& bound) {
|
bool solidAngleTest(const AABox& bound) {
|
||||||
PerformanceTimer perfTimer("solidAngleItemTest");
|
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)) {
|
if (!_functor(_args, bound)) {
|
||||||
_renderDetails._tooSmall++;
|
_renderDetails._tooSmall++;
|
||||||
return false;
|
return false;
|
||||||
|
@ -255,46 +269,58 @@ void CullSpatialSelection::run(const SceneContextPointer& sceneContext, const Re
|
||||||
// filter individually against the _filter
|
// filter individually against the _filter
|
||||||
// visibility cull if partially selected ( octree cell contianing it was partial)
|
// visibility cull if partially selected ( octree cell contianing it was partial)
|
||||||
// distance cull if was a subcell item ( octree cell is way bigger than the item bound itself, so now need to test per item)
|
// 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
|
// inside & fit items: easy, just filter
|
||||||
for (auto id : inSelection.insideItems) {
|
{
|
||||||
auto& item = scene->getItem(id);
|
PerformanceTimer perfTimer("insideFitItems");
|
||||||
if (_filter.test(item.getKey())) {
|
for (auto id : inSelection.insideItems) {
|
||||||
ItemBound itemBound(id, item.getBound());
|
auto& item = scene->getItem(id);
|
||||||
outItems.emplace_back(itemBound);
|
if (_filter.test(item.getKey())) {
|
||||||
|
ItemBound itemBound(id, item.getBound());
|
||||||
|
outItems.emplace_back(itemBound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// inside & subcell items: filter & distance cull
|
// inside & subcell items: filter & distance cull
|
||||||
for (auto id : inSelection.insideSubcellItems) {
|
{
|
||||||
auto& item = scene->getItem(id);
|
PerformanceTimer perfTimer("insideSmallItems");
|
||||||
if (_filter.test(item.getKey())) {
|
for (auto id : inSelection.insideSubcellItems) {
|
||||||
ItemBound itemBound(id, item.getBound());
|
auto& item = scene->getItem(id);
|
||||||
if (test.solidAngleTest(itemBound.bound)) {
|
if (_filter.test(item.getKey())) {
|
||||||
outItems.emplace_back(itemBound);
|
ItemBound itemBound(id, item.getBound());
|
||||||
|
if (test.solidAngleTest(itemBound.bound)) {
|
||||||
|
outItems.emplace_back(itemBound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// partial & fit items: filter & frustum cull
|
// partial & fit items: filter & frustum cull
|
||||||
for (auto id : inSelection.partialItems) {
|
{
|
||||||
auto& item = scene->getItem(id);
|
PerformanceTimer perfTimer("partialFitItems");
|
||||||
if (_filter.test(item.getKey())) {
|
for (auto id : inSelection.partialItems) {
|
||||||
ItemBound itemBound(id, item.getBound());
|
auto& item = scene->getItem(id);
|
||||||
if (test.frustumTest(itemBound.bound)) {
|
if (_filter.test(item.getKey())) {
|
||||||
outItems.emplace_back(itemBound);
|
ItemBound itemBound(id, item.getBound());
|
||||||
|
if (test.frustumTest(itemBound.bound)) {
|
||||||
|
outItems.emplace_back(itemBound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// partial & subcell items:: filter & frutum cull & solidangle cull
|
// partial & subcell items:: filter & frutum cull & solidangle cull
|
||||||
for (auto id : inSelection.partialSubcellItems) {
|
{
|
||||||
auto& item = scene->getItem(id);
|
PerformanceTimer perfTimer("partialSmallItems");
|
||||||
if (_filter.test(item.getKey())) {
|
for (auto id : inSelection.partialSubcellItems) {
|
||||||
ItemBound itemBound(id, item.getBound());
|
auto& item = scene->getItem(id);
|
||||||
if (test.frustumTest(itemBound.bound)) {
|
if (_filter.test(item.getKey())) {
|
||||||
if (test.solidAngleTest(itemBound.bound)) {
|
ItemBound itemBound(id, item.getBound());
|
||||||
outItems.emplace_back(itemBound);
|
if (test.frustumTest(itemBound.bound)) {
|
||||||
|
if (test.solidAngleTest(itemBound.bound)) {
|
||||||
|
outItems.emplace_back(itemBound);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue