diff --git a/engine/core/object/physics/Contact2D.cpp b/engine/core/object/physics/Contact2D.cpp index e53e087c..4458e48d 100644 --- a/engine/core/object/physics/Contact2D.cpp +++ b/engine/core/object/physics/Contact2D.cpp @@ -38,6 +38,10 @@ Manifold2D Contact2D::getManifold(){ return Manifold2D(scene, contact->GetManifold()); } +WorldManifold2D Contact2D::getWorldManifold(){ + return WorldManifold2D(scene, contact->GetWorldManifold()); +} + bool Contact2D::isTouching() const{ return contact->IsTouching(); } diff --git a/engine/core/object/physics/Contact2D.h b/engine/core/object/physics/Contact2D.h index 1b4bf0c7..1d9d55a6 100644 --- a/engine/core/object/physics/Contact2D.h +++ b/engine/core/object/physics/Contact2D.h @@ -8,6 +8,7 @@ #include "Entity.h" #include "Body2D.h" #include "Manifold2D.h" +#include "WorldManifold2D.h" class b2Contact; class b2Manifold; @@ -29,6 +30,7 @@ namespace Supernova{ b2Contact* getBox2DContact(); Manifold2D getManifold(); + WorldManifold2D getWorldManifold(); bool isTouching() const; diff --git a/engine/core/object/physics/Manifold2D.h b/engine/core/object/physics/Manifold2D.h index ca0b8503..ab5644f8 100644 --- a/engine/core/object/physics/Manifold2D.h +++ b/engine/core/object/physics/Manifold2D.h @@ -5,8 +5,7 @@ #ifndef MANIFOLD2D_H #define MANIFOLD2D_H -#include "Entity.h" -#include "Body2D.h" +#include "Scene.h" class b2Manifold; diff --git a/engine/core/object/physics/WorldManifold2D.cpp b/engine/core/object/physics/WorldManifold2D.cpp new file mode 100644 index 00000000..8efc8905 --- /dev/null +++ b/engine/core/object/physics/WorldManifold2D.cpp @@ -0,0 +1,36 @@ +// +// (c) 2023 Eduardo Doria. +// + +#include "WorldManifold2D.h" + +#include "PhysicsSystem.h" +#include "box2d.h" + +using namespace Supernova; + +WorldManifold2D::WorldManifold2D(Scene* scene, b2WorldManifold* worldmanifold){ + this->scene = scene; + this->worldmanifold = worldmanifold; +} + +WorldManifold2D::~WorldManifold2D(){ + +} + +WorldManifold2D::WorldManifold2D(const WorldManifold2D& rhs){ + scene = rhs.scene; + worldmanifold = rhs.worldmanifold; + +} + +WorldManifold2D& WorldManifold2D::operator=(const WorldManifold2D& rhs){ + scene = rhs.scene; + worldmanifold = rhs.worldmanifold; + + return *this; +} + +b2WorldManifold* Manifold2D::getBox2DWorldManifold(){ + return worldmanifold; +} \ No newline at end of file diff --git a/engine/core/object/physics/WorldManifold2D.h b/engine/core/object/physics/WorldManifold2D.h new file mode 100644 index 00000000..02e66e3d --- /dev/null +++ b/engine/core/object/physics/WorldManifold2D.h @@ -0,0 +1,34 @@ +// +// (c) 2023 Eduardo Doria. +// + +#ifndef WORLDMANIFOLD2D_H +#define WORLDMANIFOLD2D_H + +#include "Scene.h" + +class b2WorldManifold; + +namespace Supernova{ + + class WorldManifold2D{ + private: + Scene* scene; + b2WorldManifold* worldmanifold; + + public: + WorldManifold2D(Scene* scene, b2WorldManifold* worldmanifold); + virtual ~WorldManifold2D(); + + WorldManifold2D(const WorldManifold2D& rhs); + WorldManifold2D& operator=(const WorldManifold2D& rhs); + + b2WorldManifold* getBox2DWorldManifold(); + + Vector2 getNormal() const; + Vector2 getPoint() const; + float getSeparations() const; + }; +} + +#endif //WORLDMANIFOLD2D_H \ No newline at end of file