various bug fix, serialization, adding shapes

This commit is contained in:
Erris
2026-03-05 01:22:41 +01:00
parent f45091349e
commit ecf27eae73
8 changed files with 215 additions and 92 deletions

View File

@@ -17,6 +17,7 @@
#include <Jolt/Physics/Body/BodyActivationListener.h>
#include <cstdarg>
#include <glm/glm.hpp>
using namespace JPH;
using namespace JPH::literals;
@@ -73,6 +74,8 @@ namespace BroadPhaseLayers
static constexpr uint NUM_LAYERS(2);
};
inline JPH::Vec3 ToJolt(const glm::vec3& v) { return JPH::Vec3(v.x, v.y, v.z); };
class BPLayerInterfaceImpl final : public BroadPhaseLayerInterface
{
public:

View File

@@ -124,23 +124,27 @@ namespace OpenEngine {
float linear_damping = 0.05f;
float angular_damping = 0.05f;
float gravity_factor = 1.0f;
float restitution = 0.8f;
float friction = 0.5f;
EMotionType type = EMotionType::Dynamic;
EActivation initial_activation_state = EActivation::Activate;
ObjectLayer layer = Layers::MOVING;
int type = (int)EMotionType::Static;
int initial_activation_state = (int)EActivation::Activate;
int layer = (int)Layers::MOVING;
PhysicsBodyComponent() = default;
PhysicsBodyComponent(const PhysicsBodyComponent&) = default;
};
struct PhysicsShapeComponent
// TODO: Let's add more shapes
struct BoxShapeComponent
{
ShapeRefC shape;
float restitution = 0.8f;
float friction = 0.5f;
glm::vec3 size = { 1.0f, 1.0f, 1.0f };
};
struct SphereShapeComponent
{
float radius = 1.0f;
};
}
#endif // COMPONENTS_HPP

View File

@@ -18,6 +18,7 @@ namespace OpenEngine {
public:
Scene() = default;
~Scene() = default;
Scene(Scene& other) {};
void OnRuntimeStart();
void OnRuntimeStop();
@@ -52,8 +53,6 @@ namespace OpenEngine {
std::vector<entt::entity> pending_deletion;
//BodyID sphere_id;
friend class SceneSerializer;
friend class Entity;
};