Skip to content

Commit

Permalink
Update collisionable.h
Browse files Browse the repository at this point in the history
Fixing case (Box2D 2.4 went all lowercase)
  • Loading branch information
gcask authored and oznogon committed Mar 19, 2023
1 parent a672a31 commit ceb5a69
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/collisionable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class QueryCallback : public b2QueryCallback
/// @return false to terminate the query.
virtual bool ReportFixture(b2Fixture* fixture) override
{
P<Collisionable> ptr = (Collisionable*)fixture->GetBody()->GetUserData();
P<Collisionable> ptr = reinterpret_cast<Collisionable*>(fixture->GetBody()->GetUserData().pointer);
if (ptr)
list.push_back(ptr);
return true;
Expand Down Expand Up @@ -84,8 +84,8 @@ void CollisionManager::handleCollisions(float delta)
{
if (contact->IsTouching() && contact->IsEnabled())
{
Collisionable* A = (Collisionable*)contact->GetFixtureA()->GetBody()->GetUserData();
Collisionable* B = (Collisionable*)contact->GetFixtureB()->GetBody()->GetUserData();
Collisionable* A = reinterpret_cast<Collisionable*>(contact->GetFixtureA()->GetBody()->GetUserData().pointer);
Collisionable* B = reinterpret_cast<Collisionable*>(contact->GetFixtureB()->GetBody()->GetUserData().pointer);
if (!A->isDestroyed() && !B->isDestroyed())
{
float collision_force = 0.0f;
Expand Down Expand Up @@ -289,7 +289,7 @@ void Collisionable::createBody(b2Shape* shape)
}else{
b2BodyDef bodyDef;
bodyDef.type = static_physics ? b2_kinematicBody : b2_dynamicBody;
bodyDef.userData = this;
bodyDef.userData.pointer = reinterpret_cast<uintptr_t>(this);
bodyDef.allowSleep = false;
bodyDef.position = v2b(this->position);
bodyDef.angle = glm::radians(this->rotation);
Expand Down Expand Up @@ -409,8 +409,8 @@ std::vector<glm::vec2> Collisionable::getCollisionShape() const
case b2Shape::e_polygon:
{
b2PolygonShape* cs = static_cast<b2PolygonShape*>(s);
for(int n=0; n<cs->GetVertexCount(); n++)
ret.push_back(b2v(cs->GetVertex(n)));
for(int n=0; n<cs->m_count; n++)
ret.push_back(b2v(cs->m_vertices[n]));
}
break;
default:
Expand Down
2 changes: 2 additions & 0 deletions src/collisionable.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class b2World;
class b2Body;
class b2Shape;

#include "box2d/box2d.h"

class Collisionable;
class CollisionManager
{
Expand Down

0 comments on commit ceb5a69

Please sign in to comment.