Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
BoundsSystem.cpp
Go to the documentation of this file.
1
2
4
7
9
10// For debug rendering
12
13namespace Divide {
15 : PlatformContextComponent(context),
16 ECSSystem(parentEngine)
17 {
18 }
19
21 {
22 }
23
24
27
29
30 for (BoundsComponent* bComp : _componentCache) {
31 if (Attorney::SceneNodeBoundsSystem::boundsChanged(bComp->parentSGN()->getNode())) {
32 bComp->flagBoundingBoxDirty(to_U32(TransformType::ALL), false);
33
34 SceneGraphNode* parent = bComp->parentSGN()->parent();
35 while (parent != nullptr) {
37 parent = parent->parent();
38 }
39 }
40 }
41 }
42
43 void BoundsSystem::Update(const F32 dt) {
45
47 // This is fast and does not need to run in parallel
48 for (BoundsComponent* bComp : _componentCache) {
49 const SceneNode& sceneNode = bComp->parentSGN()->getNode();
51 bComp->setRefBoundingBox(sceneNode.getBounds());
52 }
53 }
54 for (BoundsComponent* bComp : _componentCache) {
55 if (Attorney::SceneNodeBoundsSystem::boundsChanged(bComp->parentSGN()->getNode())) {
56 bComp->appendChildRefBBs();
57 }
58 }
59 }
60
63
65
66 for (BoundsComponent* bComp : _componentCache) {
67 bComp->updateBoundingBoxTransform();
68 }
69
70 for (BoundsComponent* bComp : _componentCache) {
71 bComp->appendChildBBs();
72 }
73
74 for (BoundsComponent* bComp : _componentCache) {
75 Attorney::SceneNodeBoundsSystem::clearBoundsChanged(bComp->parentSGN()->getNode());
76 bComp->parentSGN()->SendEvent(
77 {
79 ._sourceCmp = bComp,
80 });
81 }
82 for (BoundsComponent* bComp : _componentCache) {
83 if (!bComp->showAABB()) {
84 continue;
85 }
86
87 const BoundingBox& bb = bComp->getBoundingBox();
88 IM::BoxDescriptor descriptor;
89 descriptor.min = bb.getMin();
90 descriptor.max = bb.getMax();
92 context().gfx().debugDrawBox(bComp->getGUID() + 0, descriptor);
93 }
94 }
95
96} //namespace Divide
#define PROFILE_SCOPE_AUTO(CATEGORY)
Definition: Profiler.h:87
static bool boundsChanged(const SceneNode &node) noexcept
Definition: SceneNode.h:210
static void setBoundsChanged(SceneNode &node) noexcept
Definition: SceneNode.h:214
static bool clearBoundsChanged(SceneNode &node) noexcept
Definition: SceneNode.h:218
const vec3< F32 > & getMax() const noexcept
const vec3< F32 > & getMin() const noexcept
BoundsSystem(ECS::ECSEngine &parentEngine, PlatformContext &context)
void PostUpdate(F32 dt) override
virtual ~BoundsSystem() override
void PreUpdate(F32 dt) override
void Update(F32 dt) override
vector< BoundsComponent * > _componentCache
Definition: ECSSystem.h:92
void debugDrawBox(const I64 ID, IM::BoxDescriptor descriptor) noexcept
Definition: GFXDevice.cpp:2877
PlatformContext & context() noexcept
GFXDevice & gfx() noexcept
ProjectManager & parent() noexcept
const BoundingBox & getBounds() const noexcept
Definition: SceneNode.h:120
constexpr Optick::Category::Type Scene
Definition: Profiler.h:66
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
constexpr U32 to_U32(const T value)
Project & parent
Definition: DefaultScene.h:41