Skip to content

Commit

Permalink
[octree] Rename m_index to m_index_in_parent
Browse files Browse the repository at this point in the history
  • Loading branch information
movabo committed Jun 26, 2021
1 parent fe486ac commit 1110ed3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/inexor/vulkan-renderer/world/cube.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Cube : public std::enable_shared_from_this<Cube> {
std::weak_ptr<Cube> m_parent{};

/// Index of this in m_parent.m_children; undefined behavior if root.
std::uint8_t m_index{};
std::uint8_t m_index_in_parent{};

/// Indentations, should only be used if it is a geometry cube.
std::array<Indentation, Cube::EDGES> m_indentations;
Expand Down
12 changes: 6 additions & 6 deletions src/vulkan-renderer/world/cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void swap(inexor::vulkan_renderer::world::Cube &lhs, inexor::vulkan_renderer::wo
std::swap(lhs.m_size, rhs.m_size);
std::swap(lhs.m_position, rhs.m_position);
std::swap(lhs.m_parent, rhs.m_parent);
std::swap(lhs.m_index, rhs.m_index);
std::swap(lhs.m_index_in_parent, rhs.m_index_in_parent);
std::swap(lhs.m_indentations, rhs.m_indentations);
std::swap(lhs.m_children, rhs.m_children);
std::swap(lhs.m_polygon_cache, rhs.m_polygon_cache);
Expand Down Expand Up @@ -174,7 +174,7 @@ Cube::Cube(const float size, const glm::vec3 &position) : m_size(size), m_positi
Cube::Cube(std::weak_ptr<Cube> parent, const std::uint8_t index, const float size, const glm::vec3 &position)
: Cube(size, position) {
m_parent = std::move(parent);
m_index = index;
m_index_in_parent = index;
}

Cube::Cube(Cube &&rhs) noexcept : Cube() {
Expand All @@ -199,7 +199,7 @@ std::shared_ptr<const Cube> Cube::operator[](std::size_t idx) const {
std::shared_ptr<Cube> Cube::clone() const {
std::shared_ptr<Cube> clone = std::make_shared<Cube>(this->m_size, this->m_position);
clone->m_type = this->m_type;
clone->m_index = this->m_index;
clone->m_index_in_parent = this->m_index_in_parent;

if (clone->m_type == Type::NORMAL) {
clone->m_indentations = this->m_indentations;
Expand Down Expand Up @@ -441,7 +441,7 @@ std::shared_ptr<Cube> Cube::neighbor(const NeighborAxis axis, const NeighborDire
};

auto parent = m_parent.lock();
const std::uint8_t index = m_index;
const std::uint8_t index = m_index_in_parent;
const bool home_bit = get_bit(index);

// The relevant bit denotes whether `m_parent` and `this` share a face on the upper side of the relevant axis.
Expand All @@ -463,14 +463,14 @@ std::shared_ptr<Cube> Cube::neighbor(const NeighborAxis axis, const NeighborDire

// Find the first cube where the bit (of `get_bit`) is different to `this_bit`.
// That cubes parent is the first mutual parent of the desired neighbor and `this`.
std::uint8_t p_index = parent->m_index;
std::uint8_t p_index = parent->m_index_in_parent;
history.push_back(p_index);
while (get_bit(p_index) == home_bit) {
parent = parent->m_parent.lock();
if (parent->is_root()) {
return nullptr;
}
p_index = parent->m_index;
p_index = parent->m_index_in_parent;
history.push_back(p_index);
}

Expand Down

0 comments on commit 1110ed3

Please sign in to comment.