-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sparky-game/feature/2d-physics
Box2D integration with the engine
- Loading branch information
Showing
13 changed files
with
172 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
#pragma once | ||
|
||
#include <box2d/box2d.h> | ||
#include "IComponent.hh" | ||
#include "../Core/Vector2.hh" | ||
|
||
namespace volt::runtime { | ||
enum class Rigidbody2DType { | ||
Static = b2_staticBody, | ||
Kinematic = b2_kinematicBody, | ||
Dynamic = b2_dynamicBody | ||
}; | ||
|
||
struct Rigidbody2DComponent : public IComponent { | ||
static inline auto cmp_name { "Rigidbody2D" }; | ||
core::Vector2<float> velocity; | ||
Rigidbody2DComponent(const core::Vector2<float> &v = core::Vector2<>::zero()); | ||
Rigidbody2DType type { Rigidbody2DType::Static }; | ||
bool fixedRotation { false }; | ||
float gravityScale { 1 }; | ||
core::Vector2<float> linearVelocity { core::Vector2<>::zero() }; | ||
Rigidbody2DComponent(void) = default; | ||
void Serialize(YAML::Emitter &out) final; | ||
bool Deserialize(YAML::Node &in) final; | ||
void Draw(void) final; | ||
inline b2BodyId GetBodyID(void) const { return m_bodyID; } | ||
inline void SetBodyID(b2BodyId id) { m_bodyID = id; } | ||
inline b2Vec2 GetExtent(void) const { return m_extent; } | ||
inline void SetExtent(const core::Vector2<float> &e) { m_extent = {e.X(), e.Y()}; } | ||
private: | ||
b2BodyId m_bodyID; | ||
b2Vec2 m_extent; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.