Showing the changes to interface/src/MetavoxelSystem.cpp (1 of 4 files). Show all
Unified · Split
| @@ -108,6 +108,12 @@ int RenderVisitor::visit(MetavoxelInfo& info) { · 107 unmodified lines | |||
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | void MetavoxelSystem::render() { | 110 | void MetavoxelSystem::render() { |
| 111 | // update the frustum | ||
| 112 | ViewFrustum* viewFrustum = Application::getInstance()->getViewFrustum(); | ||
| 113 | _frustum.set(viewFrustum->getFarTopLeft(), viewFrustum->getFarTopRight(), viewFrustum->getFarBottomLeft(), | ||
| 114 | viewFrustum->getFarBottomRight(), viewFrustum->getNearTopLeft(), viewFrustum->getNearTopRight(), | ||
| 115 | viewFrustum->getNearBottomLeft(), viewFrustum->getNearBottomRight()); | ||
| 116 | |||
| 111 | RenderVisitor renderVisitor(getLOD()); | 117 | RenderVisitor renderVisitor(getLOD()); |
| 112 | guideToAugmented(renderVisitor); | 118 | guideToAugmented(renderVisitor); |
| 113 | } | 119 | } |
| @@ -628,13 +634,31 @@ public: · 514 unmodified lines | |||
| 628 | 634 | ||
| 629 | SpannerRenderVisitor(const MetavoxelLOD& lod); | 635 | SpannerRenderVisitor(const MetavoxelLOD& lod); |
| 630 | 636 | ||
| 637 | virtual int visit(MetavoxelInfo& info); | ||
| 631 | virtual bool visit(Spanner* spanner, const glm::vec3& clipMinimum, float clipSize); | 638 | virtual bool visit(Spanner* spanner, const glm::vec3& clipMinimum, float clipSize); |
| 639 | |||
| 640 | private: | ||
| 641 | |||
| 642 | int _containmentDepth; | ||
| 632 | }; | 643 | }; |
| 633 | 644 | ||
| 634 | SpannerRenderVisitor::SpannerRenderVisitor(const MetavoxelLOD& lod) : | 645 | SpannerRenderVisitor::SpannerRenderVisitor(const MetavoxelLOD& lod) : |
| 635 | SpannerVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getSpannersAttribute(), | 646 | SpannerVisitor(QVector<AttributePointer>() << AttributeRegistry::getInstance()->getSpannersAttribute(), |
| 636 | QVector<AttributePointer>(), QVector<AttributePointer>(), QVector<AttributePointer>(), | 647 | QVector<AttributePointer>(), QVector<AttributePointer>(), QVector<AttributePointer>(), |
| 637 | lod, encodeOrder(Application::getInstance()->getViewFrustum()->getDirection())) { | 648 | lod, encodeOrder(Application::getInstance()->getViewFrustum()->getDirection())), |
| 649 | _containmentDepth(INT_MAX) { | ||
| 650 | } | ||
| 651 | |||
| 652 | int SpannerRenderVisitor::visit(MetavoxelInfo& info) { | ||
| 653 | if (_containmentDepth >= _depth) { | ||
| 654 | Frustum::IntersectionType intersection = Application::getInstance()->getMetavoxels()->getFrustum().getIntersectionType( | ||
| 655 | info.getBounds()); | ||
| 656 | if (intersection == Frustum::NO_INTERSECTION) { | ||
| 657 | return STOP_RECURSION; | ||
| 658 | } | ||
| 659 | _containmentDepth = (intersection == Frustum::CONTAINS_INTERSECTION) ? _depth : INT_MAX; | ||
| 660 | } | ||
| 661 | return SpannerVisitor::visit(info); | ||
| 638 | } | 662 | } |
| 639 | 663 | ||
| 640 | bool SpannerRenderVisitor::visit(Spanner* spanner, const glm::vec3& clipMinimum, float clipSize) { | 664 | bool SpannerRenderVisitor::visit(Spanner* spanner, const glm::vec3& clipMinimum, float clipSize) { |
| @@ -652,14 +676,24 @@ public: · 11 unmodified lines | |||
| 652 | private: | 676 | private: |
| 653 | 677 | ||
| 654 | int _order; | 678 | int _order; |
| 679 | int _containmentDepth; | ||
| 655 | }; | 680 | }; |
| 656 | 681 | ||
| 657 | BufferRenderVisitor::BufferRenderVisitor(const AttributePointer& attribute, const MetavoxelLOD& lod) : | 682 | BufferRenderVisitor::BufferRenderVisitor(const AttributePointer& attribute, const MetavoxelLOD& lod) : |
| 658 | MetavoxelVisitor(QVector<AttributePointer>() << attribute, QVector<AttributePointer>(), lod), | 683 | MetavoxelVisitor(QVector<AttributePointer>() << attribute, QVector<AttributePointer>(), lod), |
| 659 | _order(encodeOrder(Application::getInstance()->getViewFrustum()->getDirection())) { | 684 | _order(encodeOrder(Application::getInstance()->getViewFrustum()->getDirection())), |
| 685 | _containmentDepth(INT_MAX) { | ||
| 660 | } | 686 | } |
| 661 | 687 | ||
| 662 | int BufferRenderVisitor::visit(MetavoxelInfo& info) { | 688 | int BufferRenderVisitor::visit(MetavoxelInfo& info) { |
| 689 | if (_containmentDepth >= _depth) { | ||
| 690 | Frustum::IntersectionType intersection = Application::getInstance()->getMetavoxels()->getFrustum().getIntersectionType( | ||
| 691 | info.getBounds()); | ||
| 692 | if (intersection == Frustum::NO_INTERSECTION) { | ||
| 693 | return STOP_RECURSION; | ||
| 694 | } | ||
| 695 | _containmentDepth = (intersection == Frustum::CONTAINS_INTERSECTION) ? _depth : INT_MAX; | ||
| 696 | } | ||
| 663 | BufferDataPointer buffer = info.inputValues.at(0).getInlineValue<BufferDataPointer>(); | 697 | BufferDataPointer buffer = info.inputValues.at(0).getInlineValue<BufferDataPointer>(); |
| 664 | if (buffer) { | 698 | if (buffer) { |
| 665 | buffer->render(); | 699 | buffer->render(); |