Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
#5338: Move ObjectFinder to separate file
- Loading branch information
1 parent
54ae23f
commit 40da556
Showing
4 changed files
with
71 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#pragma once | ||
|
||
#include "inode.h" | ||
#include "iselectiontest.h" | ||
#include "selection/OccludeSelector.h" | ||
|
||
namespace camera | ||
{ | ||
|
||
class ObjectFinder : | ||
public scene::NodeVisitor | ||
{ | ||
private: | ||
scene::INodePtr _node; | ||
SelectionTest& _selectionTest; | ||
|
||
// To store the best intersection candidate | ||
SelectionIntersection _bestIntersection; | ||
|
||
public: | ||
// Constructor | ||
ObjectFinder(SelectionTest& test) : | ||
_selectionTest(test) | ||
{} | ||
|
||
const scene::INodePtr& getNode() const | ||
{ | ||
return _node; | ||
} | ||
|
||
// The visitor function | ||
bool pre(const scene::INodePtr& node) | ||
{ | ||
// Check if the node is filtered | ||
if (node->visible()) | ||
{ | ||
auto selectionTestable = Node_getSelectionTestable(node); | ||
|
||
if (selectionTestable) | ||
{ | ||
bool occluded; | ||
selection::OccludeSelector selector(_bestIntersection, occluded); | ||
selectionTestable->testSelect(selector, _selectionTest); | ||
|
||
if (occluded) | ||
{ | ||
_node = node; | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
return false; // don't traverse filtered nodes | ||
} | ||
|
||
return true; | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters