Skip to content

Commit

Permalink
Created WorldManifold2D
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardodoria committed Sep 5, 2023
1 parent 257b066 commit 0c7de2e
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
4 changes: 4 additions & 0 deletions engine/core/object/physics/Contact2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 2 additions & 0 deletions engine/core/object/physics/Contact2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "Entity.h"
#include "Body2D.h"
#include "Manifold2D.h"
#include "WorldManifold2D.h"

class b2Contact;
class b2Manifold;
Expand All @@ -29,6 +30,7 @@ namespace Supernova{
b2Contact* getBox2DContact();

Manifold2D getManifold();
WorldManifold2D getWorldManifold();

bool isTouching() const;

Expand Down
3 changes: 1 addition & 2 deletions engine/core/object/physics/Manifold2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
#ifndef MANIFOLD2D_H
#define MANIFOLD2D_H

#include "Entity.h"
#include "Body2D.h"
#include "Scene.h"

class b2Manifold;

Expand Down
36 changes: 36 additions & 0 deletions engine/core/object/physics/WorldManifold2D.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
34 changes: 34 additions & 0 deletions engine/core/object/physics/WorldManifold2D.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0c7de2e

Please sign in to comment.