Radium Engine  1.5.20
Loading...
Searching...
No Matches
AbstractGeometry.hpp
1#pragma once
2
3#include <Core/RaCore.hpp>
4#include <Core/Types.hpp>
5#include <Core/Utils/Observable.hpp>
6
7namespace Ra {
8namespace Core {
9namespace Geometry {
10
17struct RA_CORE_API AbstractGeometry {
18 /*
19 * Note: Explicitly defaulted virtual destructor, copy/move constructors,
20 * copy/move assignment operators
21 * When a base class is intended for polymorphic use, its destructor may have
22 * to be declared public and virtual. This blocks implicit moves
23 * (and deprecates implicit copies), and so the special member functions
24 */
25 virtual ~AbstractGeometry() = default;
26 AbstractGeometry() = default;
27 AbstractGeometry( const AbstractGeometry& other ) {
28 m_isAabbValid = other.m_isAabbValid;
29 m_aabb = other.m_aabb;
30 other.m_aabbObservable.copyObserversTo( m_aabbObservable );
31 }
32 AbstractGeometry& operator=( const AbstractGeometry& other ) {
33 m_isAabbValid = other.m_isAabbValid;
34 m_aabb = other.m_aabb;
35 other.m_aabbObservable.copyObserversTo( m_aabbObservable );
36 return *this;
37 }
39 virtual void clear() = 0;
40
42 virtual Aabb computeAabb() const = 0;
43
44 Ra::Core::Utils::ObservableVoid& getAabbObservable() { return m_aabbObservable; }
45
46 protected:
47 bool isAabbValid() const { return m_isAabbValid; }
48 Core::Aabb getAabb() const { return m_aabb; }
49
50 void invalidateAabb() const {
51 m_isAabbValid = false;
52 m_aabbObservable.notify();
53 }
54 // set a new (valid) aabb
55 void setAabb( const Core::Aabb& aabb ) const {
56 m_aabb = aabb;
57 m_isAabbValid = true;
58 }
59
60 private:
61 mutable bool m_isAabbValid { false };
62 mutable Core::Aabb m_aabb;
63 Ra::Core::Utils::ObservableVoid m_aabbObservable;
64};
65
66} // namespace Geometry
67} // namespace Core
68} // namespace Ra
void copyObserversTo(Observable &other) const
explicit copy of all attached observers the other Observable
@ Geometry
"Geometry" render objects are those loaded using Radium::IO and generated by GeometrySystem
hepler function to manage enum as underlying types in VariableSet
Definition Cage.cpp:3
virtual void clear()=0
Erases all data, making the geometry empty.
virtual Aabb computeAabb() const =0
Compute bounding box.