Skip to content

Commit

Permalink
chore: formatted include/
Browse files Browse the repository at this point in the history
  • Loading branch information
Sygmei committed May 10, 2023
1 parent 248e496 commit 83dbb7b
Show file tree
Hide file tree
Showing 22 changed files with 76 additions and 56 deletions.
3 changes: 1 addition & 2 deletions include/Core/Animation/Animation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <Types/Serializable.hpp>
#include <Types/SmartEnum.hpp>


namespace obe
{
namespace engine
Expand Down Expand Up @@ -331,7 +330,7 @@ namespace obe::animation
[[nodiscard]] bool is_anti_aliased() const noexcept;
[[nodiscard]] AnimationState make_state() const;

[[nodiscard]] vili::node get_frame_metadata(uint32_t frame_index) const;
[[nodiscard]] vili::node get_frame_metadata(uint32_t frame_index) const;
[[nodiscard]] uint32_t get_frames_amount() const;
[[nodiscard]] uint32_t get_current_frame_index() const;

Expand Down
3 changes: 2 additions & 1 deletion include/Core/Collision/Collider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ namespace obe::collision
* \param offset Distance the Collider should move to (if nothing collides)
* \return The maximum distance the Collider can travel before colliding
*/
[[nodiscard]] virtual transform::UnitVector get_offset_before_collision(const Collider& collider,
[[nodiscard]] virtual transform::UnitVector get_offset_before_collision(
const Collider& collider,
const transform::UnitVector& self_offset = transform::UnitVector(0, 0),
const transform::UnitVector& other_offset = transform::UnitVector(0, 0)) const;

Expand Down
6 changes: 3 additions & 3 deletions include/Core/Collision/ColliderComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

#include <Collision/CapsuleCollider.hpp>
#include <Collision/CircleCollider.hpp>
#include <Collision/ComplexPolygonCollider.hpp>
#include <Collision/PolygonCollider.hpp>
#include <Collision/RectangleCollider.hpp>
#include <Collision/ComplexPolygonCollider.hpp>
#include <Component/Component.hpp>

#include <variant>
Expand Down Expand Up @@ -53,8 +53,8 @@ namespace obe::collision
{
};

using ColliderTypes
= std::variant<CapsuleCollider, CircleCollider, PolygonCollider, RectangleCollider, ComplexPolygonCollider>;
using ColliderTypes = std::variant<CapsuleCollider, CircleCollider, PolygonCollider,
RectangleCollider, ComplexPolygonCollider>;
template <typename ColliderClass>
concept IsValidColliderClass = is_variant_member<ColliderClass, ColliderTypes>::value;

Expand Down
8 changes: 5 additions & 3 deletions include/Core/Collision/CollisionSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ namespace obe::collision
std::unordered_set<const Collider*> m_colliders;
std::unordered_map<std::string, std::unordered_set<std::string>> m_tags_blacklists;
Quadtree m_quadtree;

protected:
static bool matches_any_tag(const std::unordered_set<std::string>& input_tags,
const std::unordered_set<std::string>& whitelist_or_blacklist);
bool can_collide_with(const Collider& collider1, const Collider& collider2, bool check_both_directions = true) const;
bool can_collide_with(const Collider& collider1, const Collider& collider2,
bool check_both_directions = true) const;

public:
CollisionSpace();

Expand Down Expand Up @@ -67,8 +70,7 @@ namespace obe::collision
const transform::UnitVector& offset = transform::UnitVector(0, 0)) const;
[[nodiscard]] transform::UnitVector get_offset_before_collision(const Collider& collider,
const std::vector<ReachableCollider>& reachable_colliders,
const transform::UnitVector& offset
= transform::UnitVector(0, 0)) const;
const transform::UnitVector& offset = transform::UnitVector(0, 0)) const;
std::vector<ReachableCollider> get_reachable_colliders(const Collider& collider,
const transform::UnitVector& offset = transform::UnitVector(0, 0)) const;

Expand Down
4 changes: 2 additions & 2 deletions include/Core/Collision/ComplexPolygonCollider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace obe::collision
{
private:
std::vector<transform::UnitVector> m_points;

protected:
[[nodiscard]] const void* get_c2_shape() const override;
[[nodiscard]] const c2x* get_c2_space_transform() const override;
Expand Down Expand Up @@ -51,8 +52,7 @@ namespace obe::collision
* \param offset Distance the Collider should move to (if nothing collides)
* \return The maximum distance the Collider can travel before colliding
*/
[[nodiscard]] transform::UnitVector get_offset_before_collision(
const Collider& collider,
[[nodiscard]] transform::UnitVector get_offset_before_collision(const Collider& collider,
const transform::UnitVector& self_offset = transform::UnitVector(0, 0),
const transform::UnitVector& other_offset = transform::UnitVector(0, 0)) const override;

Expand Down
10 changes: 6 additions & 4 deletions include/Core/Collision/Quadtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ namespace obe::collision
bool is_leaf(const Node* node) const;
transform::AABB compute_box(const transform::AABB& box, int i) const;
int get_quadrant(const transform::AABB& nodeBox, const transform::AABB& valueBox) const;
void add_internal(Node* node, std::size_t depth, const transform::AABB& box, const Collider* value);
void add_internal(
Node* node, std::size_t depth, const transform::AABB& box, const Collider* value);
void split(Node* node, const transform::AABB& box);
bool remove_internal(Node* node, const transform::AABB& box, const Collider* value);
void remove_value(Node* node, const Collider* value);
bool try_merge(Node* node);
void query_internal(Node* node, const transform::AABB& box, const transform::AABB& query_box, std::vector<const Collider*>& values) const;
void find_all_intersections_internal(Node* node, std::vector<std::pair<const Collider*, const Collider*>>& intersections) const;
void query_internal(Node* node, const transform::AABB& box,
const transform::AABB& query_box, std::vector<const Collider*>& values) const;
void find_all_intersections_internal(Node* node,
std::vector<std::pair<const Collider*, const Collider*>>& intersections) const;
void find_intersections_in_descendants(Node* node, const Collider* value,
std::vector<std::pair<const Collider*, const Collider*>>& intersections) const;

Expand All @@ -47,5 +50,4 @@ namespace obe::collision
std::vector<std::pair<const Collider*, const Collider*>> find_all_intersections() const;
};


}
18 changes: 13 additions & 5 deletions include/Core/Component/Component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
#include <Types/Serializable.hpp>
#include <Types/UniqueIdentifiable.hpp>


namespace obe::component
{
class ComponentBase : public types::Identifiable, public types::Serializable, public types::UniqueIdentifiable
class ComponentBase : public types::Identifiable,
public types::Serializable,
public types::UniqueIdentifiable
{
public:
using Caster = std::function<sol::lua_value(ComponentBase*)>;
Expand Down Expand Up @@ -64,7 +65,8 @@ namespace obe::component
void Component<DerivedComponent>::Register()
{
ComponentCasters[DerivedComponent::ComponentType]
= [](ComponentBase* component) -> sol::lua_value {
= [](ComponentBase* component) -> sol::lua_value
{
return static_cast<DerivedComponent*>(component);
};
}
Expand All @@ -80,7 +82,10 @@ namespace obe::component
Component<DerivedComponent>::~Component()
{
Pool.erase(std::remove_if(Pool.begin(), Pool.end(),
[&](DerivedComponent* ptr) -> bool { return (this == ptr); }),
[&](DerivedComponent* ptr) -> bool
{
return (this == ptr);
}),
Pool.end());
}

Expand All @@ -90,7 +95,10 @@ namespace obe::component
RemoveComponent(this);
DerivedComponent::Pool.erase(
std::remove_if(DerivedComponent::Pool.begin(), DerivedComponent::Pool.end(),
[&](auto& elem) { return (this == elem); }),
[&](auto& elem)
{
return (this == elem);
}),
DerivedComponent::Pool.end());
}

Expand Down
3 changes: 2 additions & 1 deletion include/Core/Debug/Render.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ namespace obe::debug::render
const graphics::Color color = graphics::Color(255, 0, 0, 150);
};

void draw_collider(const graphics::RenderTarget target, const collision::ColliderComponent& collider, const ColliderRenderOptions& render_options);
void draw_collider(const graphics::RenderTarget target,
const collision::ColliderComponent& collider, const ColliderRenderOptions& render_options);
}
6 changes: 4 additions & 2 deletions include/Core/Graphics/Canvas.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,10 @@ namespace obe::graphics::canvas
m_sort_required = true;
std::unique_ptr<T> new_element = std::make_unique<T>(*this, id);
auto insert_it = std::find_if(m_elements.begin(), m_elements.end(),
[&new_element](
const CanvasElement::Ptr& elem) { return new_element->layer <= elem->layer; });
[&new_element](const CanvasElement::Ptr& elem)
{
return new_element->layer <= elem->layer;
});
auto elem_it = m_elements.insert(insert_it, std::move(new_element));
return *static_cast<T*>(elem_it->get());
}
Expand Down
3 changes: 2 additions & 1 deletion include/Core/Graphics/NinePatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ namespace obe::graphics
public:
NinePatch();

void set_texture(const sf::Texture& texture, bool reset_size = true, bool reset_rect = true);
void set_texture(
const sf::Texture& texture, bool reset_size = true, bool reset_rect = true);
void set_texture();

[[nodiscard]] sf::Vector2f get_size() const;
Expand Down
1 change: 1 addition & 0 deletions include/Core/Graphics/Spritesheet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace obe::graphics
std::vector<transform::AABB> m_frames;

graphics::Texture load_texture(const std::string& texture_path) const;

public:
Spritesheet(engine::ResourceManager* resources = nullptr);

Expand Down
2 changes: 1 addition & 1 deletion include/Core/Graphics/Texture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <tuple>
#include <variant>

#include <lunasvg.h>
#include <SFML/Graphics/Texture.hpp>
#include <lunasvg.h>

#include <Graphics/Color.hpp>
#include <Transform/AABB.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/Core/Input/InputButtonMonitor.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <Event/EventGroup.hpp>
#include <Input/InputSourceState.hpp>
#include <Input/InputSource.hpp>
#include <Input/InputSourceState.hpp>
#include <memory>

namespace obe::events
Expand Down
2 changes: 1 addition & 1 deletion include/Core/Input/InputCondition.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

#include <Input/InputButtonMonitor.hpp>
#include <Input/InputSourceState.hpp>
#include <Input/InputSource.hpp>
#include <Input/InputSourceState.hpp>
#include <Types/FlagSet.hpp>
#include <Types/Togglable.hpp>
#include <vector>
Expand Down
7 changes: 3 additions & 4 deletions include/Core/Input/InputSourceKeyboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ namespace obe::input
* \param printable_char The character printed when the key is pressed
*/
InputSourceKeyboardKey(
sf::Keyboard::Key key, const std::string& printable_char);
InputSourceKeyboardKey(sf::Keyboard::Key key, const std::string& printable_char);
/**
* \brief Creates a new InputSource representing a Keyboard key
* \param key SFML Keyboard Key
* \param name Name of the Key
* \param printable_char The character printed when the key is pressed
*/
InputSourceKeyboardKey(sf::Keyboard::Key key, const std::string& name,
const std::string& printable_char);
InputSourceKeyboardKey(
sf::Keyboard::Key key, const std::string& name, const std::string& printable_char);
/**
* \brief Get the SFML Keyboard Key
* \return SFML Keyboard Key
Expand Down
35 changes: 17 additions & 18 deletions include/Core/Script/AutoCastManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,24 @@ namespace obe::script
#define VirtuallyTyped class // clang 15 and below does not support concepts on abstract classes
#else
template <class T>
concept VirtuallyTyped = requires(T x)
{
{
x.type()
}
->std::same_as<std::string_view>;
{ std::has_virtual_destructor_v<T> };
};
concept VirtuallyTyped = requires(T x) {
{
x.type()
} -> std::same_as<std::string_view>;
{
std::has_virtual_destructor_v<T>
};
};
#endif

template <class T, class CastableBase>
concept VirtuallyTypedChildClass
= std::derived_from<T, CastableBase>&& std::same_as<std::remove_cvref_t<decltype(T::Type)>,
std::string_view> && !std::is_abstract_v<T> && requires(T x)
{
{
x.type()
}
->std::same_as<std::string_view>;
};
concept VirtuallyTypedChildClass = std::derived_from<T, CastableBase>
&& std::same_as<std::remove_cvref_t<decltype(T::Type)>, std::string_view> && !
std::is_abstract_v<T>&& requires(T x) {
{
x.type()
} -> std::same_as<std::string_view>;
};

template <VirtuallyTyped CastableBase>
class AutoCastManager
Expand All @@ -70,7 +68,8 @@ namespace obe::script
template <VirtuallyTypedChildClass<CastableBase> CastableSubClass>
void AutoCastManager<CastableBase>::Register()
{
CastersMap[CastableSubClass::Type] = [](CastableBase* ptr) -> sol::lua_value {
CastersMap[CastableSubClass::Type] = [](CastableBase* ptr) -> sol::lua_value
{
return static_cast<CastableSubClass*>(ptr);
};
}
Expand Down
1 change: 0 additions & 1 deletion include/Core/Script/Casters/Base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace obe::script
{
class DummyCast
{

};

/**
Expand Down
6 changes: 5 additions & 1 deletion include/Core/System/Cursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ namespace obe::system
*/
void set_constraint(
const PositionConstraint& constraint,
ConstraintCondition condition = []() { return true; });
ConstraintCondition condition =
[]()
{
return true;
});
bool is_pressed(sf::Mouse::Button button) const;
/**
* \brief Change the cursor
Expand Down
5 changes: 3 additions & 2 deletions include/Core/Tiles/Layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ namespace obe::tiles
static void clear_quad(sf::Vertex* quad);

public:
TileLayer(const TileScene& scene, const std::string& id, int32_t layer, int32_t sublayer, uint32_t x,
uint32_t y, uint32_t width, uint32_t height, std::vector<uint32_t> data, bool visible);
TileLayer(const TileScene& scene, const std::string& id, int32_t layer, int32_t sublayer,
uint32_t x, uint32_t y, uint32_t width, uint32_t height, std::vector<uint32_t> data,
bool visible);

[[nodiscard]] std::string get_id() const;

Expand Down
2 changes: 1 addition & 1 deletion include/Core/Transform/AABB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace obe::transform
using Movable::get_position;
using Movable::move;
using Movable::set_position;

AABB() = default;
AABB(const transform::UnitVector& position, const transform::UnitVector& size);

Expand Down
4 changes: 2 additions & 2 deletions include/Core/Transform/Polygon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <Transform/UnitBasedObject.hpp>
#include <Transform/UnitVector.hpp>


namespace obe::transform
{
class Polygon;
Expand All @@ -30,7 +29,8 @@ namespace obe::transform
};

explicit PolygonPoint(Polygon& parent, point_index_t index);
explicit PolygonPoint(Polygon& parent, point_index_t index, const transform::UnitVector& position);
explicit PolygonPoint(
Polygon& parent, point_index_t index, const transform::UnitVector& position);

PolygonPoint& operator=(const PolygonPoint& point);

Expand Down
1 change: 1 addition & 0 deletions include/Core/Types/Serializable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace obe::types
* \return vili::node that contains the validation schema
*/
[[nodiscard]] virtual vili::node schema() const = 0;

public:
virtual ~Serializable() = default;
/**
Expand Down

0 comments on commit 83dbb7b

Please sign in to comment.