Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
RenderingComponentState.cpp
Go to the documentation of this file.
1
2
8
9namespace Divide {
10
11void RenderingComponent::toggleRenderOption(RenderOptions option, bool state, bool recursive) {
12 if (renderOptionEnabled(option) != state) {
13 if (recursive) {
14 const SceneGraphNode::ChildContainer& children = _parentSGN->getChildren();
15 SharedLock<SharedMutex> w_lock(children._lock);
16 const U32 childCount = children._count;
17 for (U32 i = 0u; i < childCount; ++i) {
18 if (children._data[i]->HasComponents(ComponentType::RENDERING)) {
19 children._data[i]->get<RenderingComponent>()->toggleRenderOption(option, state, recursive);
20 }
21 }
22 }
23
24 state ? _renderMask |= to_U32(option) : _renderMask &= ~to_U32(option);
25
26 onRenderOptionChanged(option, state);
27 }
28}
29
30bool RenderingComponent::renderOptionEnabled(const RenderOptions option) const noexcept {
31 return _renderMask & to_base(option);
32}
33
34void RenderingComponent::toggleBoundsDraw(const bool showAABB, const bool showBS, const bool showOBB, bool recursive) {
35 if (recursive) {
36 const SceneGraphNode::ChildContainer& children = _parentSGN->getChildren();
37 SharedLock<SharedMutex> w_lock(children._lock);
38 const U32 childCount = children._count;
39 for (U32 i = 0u; i < childCount; ++i) {
40 if (children._data[i]->HasComponents(ComponentType::RENDERING)) {
41 children._data[i]->get<RenderingComponent>()->toggleBoundsDraw(showAABB, showBS, showOBB, recursive);
42 }
43 }
44 }
45 _drawAABB = showAABB;
46 _drawBS = showBS;
47 _drawOBB = showOBB;
48}
49
50void RenderingComponent::onRenderOptionChanged(const RenderOptions option, const bool state)
51{
52 switch (option)
53 {
55 {
56 if (state && !_config.rendering.shadowMapping.enabled) {
58 return;
59 }
60 if (_materialInstance != INVALID_HANDLE<Material>)
61 {
62 Get(_materialInstance)->properties().receivesShadows(state);
63 }
64 } break;
65 default: break;
66 }
67}
68} //namespace Divide
bool renderOptionEnabled(RenderOptions option) const noexcept
Returns true if the specified render option is enabled.
void onRenderOptionChanged(RenderOptions option, bool state)
void toggleBoundsDraw(bool showAABB, bool showBS, bool showOBB, bool recursive)
const Configuration & _config
Handle< Material > _materialInstance
void toggleRenderOption(RenderOptions option, bool state, bool recursive=true)
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
constexpr U32 to_U32(const T value)
std::shared_lock< mutex > SharedLock
Definition: SharedMutex.h:49
FORCE_INLINE T * Get(const Handle< T > handle)
uint32_t U32
constexpr auto to_base(const Type value) -> Type
struct Divide::Configuration::Rendering::ShadowMapping shadowMapping
struct Divide::Configuration::Rendering rendering
eastl::fixed_vector< SceneGraphNode *, 32, true > _data