Skip to content

Commit e015137

Browse files
committed
🎨 Format code
1 parent a8766f9 commit e015137

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+781
-1188
lines changed

‎.clang-format

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Generated from CLion C/C++ Code Style settings
12
---
23
Language: Cpp
34
BasedOnStyle: LLVM

‎.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/.name

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/celestial-roll.iml

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/codeStyles/Project.xml

+109
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.idea/codeStyles/codeStyleConfig.xml

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎include/collision/aabbCollider.hpp

+10-22
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,15 @@
55
// #include "sphereCollider.hpp"
66

77
// TODO: refactor this to exclude circular dependency with sphereCollider
8-
class AABBCollider : public Collider
9-
{
10-
public:
11-
AABBCollider(const glm::vec3 &min, const glm::vec3 &max)
12-
: minBounds(min, 0.0f), maxBounds(max, 0.0f), Collider(ColliderType::AABB)
13-
{
14-
}
8+
class AABBCollider final : public Collider {
9+
public:
10+
AABBCollider(const glm::vec3 &min, const glm::vec3 &max) :
11+
Collider(ColliderType::AABB), minBounds(min, 0.0f), maxBounds(max, 0.0f) {}
1512

16-
CollisionResult checkCollision(const Collider &other) const override
17-
{
13+
[[nodiscard]] CollisionResult checkCollision(const Collider &other) const override {
1814
// not implement properly yet since we only handle collision from the player perspective, which is a sphere
1915

20-
const AABBCollider *otherBox = dynamic_cast<const AABBCollider *>(&other);
21-
if (otherBox && transform)
22-
{
16+
if (const auto *otherBox = dynamic_cast<const AABBCollider *>(&other); otherBox && transform) {
2317

2418
return CollisionDetector::aabbToAABB(getMinBounds(), getMaxBounds(), otherBox->getMinBounds(),
2519
otherBox->getMaxBounds());
@@ -37,16 +31,10 @@ class AABBCollider : public Collider
3731
return CollisionResult{false, glm::vec4(0.0f)};
3832
}
3933

40-
glm::vec4 getMinBounds() const
41-
{
42-
return minBounds + transform->getPosition();
43-
}
34+
[[nodiscard]] glm::vec4 getMinBounds() const { return minBounds + transform->getPosition(); }
4435

45-
glm::vec4 getMaxBounds() const
46-
{
47-
return maxBounds + transform->getPosition();
48-
}
36+
[[nodiscard]] glm::vec4 getMaxBounds() const { return maxBounds + transform->getPosition(); }
4937

50-
private:
38+
private:
5139
glm::vec4 minBounds, maxBounds;
52-
};
40+
};

‎include/collision/collider.hpp

+14-33
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,39 @@
11
#pragma once
22

3+
#include <iostream>
34
#include "collisionDetector.hpp"
45
#include "game/component.hpp"
56
#include "game/gameObject.hpp"
67
#include "transform.hpp"
7-
#include <iostream>
8-
#include <memory>
98

10-
enum class ColliderType
11-
{
9+
enum class ColliderType {
1210
OBB,
1311
AABB,
1412
Sphere,
1513
};
1614

17-
class Collider : public Component
18-
{
19-
public:
20-
Collider(ColliderType type) : transform(nullptr), type(type)
21-
{
22-
}
15+
class Collider : public Component {
16+
public:
17+
explicit Collider(const ColliderType type) : type(type), transform(nullptr) {}
2318

24-
void initialize() override
25-
{
19+
void initialize() override {
2620
transform = gameObject->getComponent<Transform>();
27-
if (!transform)
28-
{
21+
if (!transform) {
2922
std::cerr << "Collider requires a Transform component.\n";
3023
}
3124
}
3225

33-
std::shared_ptr<Transform> getTransform() const
34-
{
35-
return transform;
36-
}
26+
[[nodiscard]] std::shared_ptr<Transform> getTransform() const { return transform; }
3727

38-
ColliderType getType() const
39-
{
40-
return type;
41-
}
28+
[[nodiscard]] ColliderType getType() const { return type; }
4229

43-
glm::mat4 getRotationMatrix() const
44-
{
45-
return transform->getRotationMatrix();
46-
}
30+
[[nodiscard]] glm::mat4 getRotationMatrix() const { return transform->getRotationMatrix(); }
4731

48-
glm::vec4 getPosition() const
49-
{
50-
return transform->getPosition();
51-
}
32+
[[nodiscard]] glm::vec4 getPosition() const { return transform->getPosition(); }
5233

53-
virtual CollisionResult checkCollision(const Collider &other) const = 0;
34+
[[nodiscard]] virtual CollisionResult checkCollision(const Collider &other) const = 0;
5435

55-
protected:
36+
protected:
5637
ColliderType type;
5738
std::shared_ptr<Transform> transform;
58-
};
39+
};

0 commit comments

Comments
 (0)