Class Cube¶
Defined in File cube.hpp
Nested Relationships¶
Nested Types¶
Inheritance Relationships¶
Base Type¶
public std::enable_shared_from_this< Cube >
Class Documentation¶
-
class inexor::vulkan_renderer::world::Cube : public std::enable_shared_from_this<Cube>¶
Public Types
Public Functions
-
Cube() = default¶
Create an empty cube.
-
Cube(float size, const glm::vec3 &position)¶
Create an empty cube.
-
Cube(std::weak_ptr<Cube> parent, std::uint8_t index, float size, const glm::vec3 &position)¶
Create an empty cube.
-
~Cube() = default¶
-
std::shared_ptr<Cube> clone() const¶
Clone a cube, which has no relations to the current one or its children. It will be a root cube.
-
bool is_root() const noexcept¶
Is the current cube root.
-
std::size_t grid_level() const noexcept¶
At which child level this cube is. root cube = 0
-
std::size_t count_geometry_cubes() const noexcept¶
Count the number of Type::SOLID and Type::NORMAL cubes.
-
inline glm::vec3 center() const noexcept¶
-
inline glm::vec3 position() const noexcept¶
-
inline std::array<glm::vec3, 2> bounding_box() const¶
-
inline float size() const noexcept¶
-
std::array<Indentation, Cube::EDGES> indentations() const noexcept¶
Get indentations.
-
void set_indent(std::uint8_t edge_id, Indentation indentation)¶
Set an indent by the edge id.
-
void indent(std::uint8_t edge_id, bool positive_direction, std::uint8_t steps)¶
Indent a specific edge by steps.
- Parameters
positive_direction – Indent in positive axis direction.
-
void rotate(const RotationAxis::Type &axis, int rotations)¶
Rotate the cube 90° clockwise around the given axis. Repeats with the given rotations.
- Parameters
axis – Only one index should be one.
rotations – Value does not need to be adjusted beforehand. (e.g. mod 4)
-
void update_polygon_cache() const¶
TODO: in special cases some polygons have no surface, if completely surrounded by others
Warning
Will update the cache even if it is considered as valid.
-
void invalidate_polygon_cache() const¶
Invalidate polygon cache.
-
std::vector<PolygonCache> polygons(bool update_invalid = false) const¶
Recursive way to collect all the caches.
- Parameters
update_invalid – If true it will update invalid polygon caches.
-
std::shared_ptr<Cube> neighbor(NeighborAxis axis, NeighborDirection direction)¶
Get the (face) neighbor of this cube.
Get the (face) neighbor of this cube by using a similar implementation to Samets “OT_GTEQ_FACE_NEIGHBOR(P,I)”.
- See
Samet, H. (1989) Neighbor finding in Images Represented by Octrees. Computer Vision, Graphics, and Image Processing. 46 (3), 367-386.
- Parameters
axis – The axis on which to get the neighboring cube
direction – Whether to get the cube which is above or below this cube on the selected axis
- Returns
Same-sized neighbor if existent, else larger neighbor if exists, otherwise (i.e. when no neighbor exists) nullptr.
Public Static Attributes
-
static constexpr std::size_t SUB_CUBES = {8}¶
Maximum of sub cubes (children)
Private Functions
-
friend void ::swap(Cube &lhs, Cube &rhs) noexcept¶
-
void remove_children()¶
Removes all children recursive.
-
std::array<glm::vec3, 8> vertices() const noexcept¶
Get the vertices of this cube. Use only on geometry cubes.
-
template<int Rotations>
void rotate(const RotationAxis::Type &axis)¶ Optimized implementations of 90°, 180° and 270° rotations.
Private Members
-
float m_size = {32}¶
-
glm::vec3 m_position = {0.0f, 0.0f, 0.0f}¶
-
std::uint8_t m_index_in_parent = {}¶
Index of this in m_parent.m_children; undefined behavior if root.
-
std::array<Indentation, Cube::EDGES> m_indentations¶
Indentations, should only be used if it is a geometry cube.
-
mutable PolygonCache m_polygon_cache¶
Only geometry cube (Type::SOLID and Type::Normal) have a polygon cache.
-
mutable bool m_polygon_cache_valid = {false}¶
Friends
- friend class io::NXOCParser
-
struct RotationAxis¶
IDs of the children and edges which will be swapped to receive the rotation. To achieve a 90 degree rotation the 0th index have to be swapped with the 1st and the 1st with the 2nd, etc.
Public Types
-
using ChildType = std::array<std::array<std::size_t, 4>, 2>¶
-
using EdgeType = std::array<std::array<std::size_t, 4>, 3>¶
Public Static Attributes
-
static constexpr Type X = {{{{0, 1, 3, 2}, {4, 5, 7, 6}}}, {{{2, 4, 11, 1}, {5, 7, 8, 10}, {0, 9, 6, 3}}}}¶
IDs of the children / edges which will be swapped to receive the rotation around X axis.
-
using ChildType = std::array<std::array<std::size_t, 4>, 2>¶
-
Cube() = default¶