From ceb5a69cab1304674ecccafa0c09d7ec85b5ac1e Mon Sep 17 00:00:00 2001 From: gcask <53709079+gcask@users.noreply.github.com> Date: Wed, 17 Mar 2021 21:53:44 -0400 Subject: [PATCH] Update collisionable.h Fixing case (Box2D 2.4 went all lowercase) --- src/collisionable.cpp | 12 ++++++------ src/collisionable.h | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/collisionable.cpp b/src/collisionable.cpp index 1afe3a57..5961342b 100644 --- a/src/collisionable.cpp +++ b/src/collisionable.cpp @@ -39,7 +39,7 @@ class QueryCallback : public b2QueryCallback /// @return false to terminate the query. virtual bool ReportFixture(b2Fixture* fixture) override { - P ptr = (Collisionable*)fixture->GetBody()->GetUserData(); + P ptr = reinterpret_cast(fixture->GetBody()->GetUserData().pointer); if (ptr) list.push_back(ptr); return true; @@ -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(contact->GetFixtureA()->GetBody()->GetUserData().pointer); + Collisionable* B = reinterpret_cast(contact->GetFixtureB()->GetBody()->GetUserData().pointer); if (!A->isDestroyed() && !B->isDestroyed()) { float collision_force = 0.0f; @@ -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(this); bodyDef.allowSleep = false; bodyDef.position = v2b(this->position); bodyDef.angle = glm::radians(this->rotation); @@ -409,8 +409,8 @@ std::vector Collisionable::getCollisionShape() const case b2Shape::e_polygon: { b2PolygonShape* cs = static_cast(s); - for(int n=0; nGetVertexCount(); n++) - ret.push_back(b2v(cs->GetVertex(n))); + for(int n=0; nm_count; n++) + ret.push_back(b2v(cs->m_vertices[n])); } break; default: diff --git a/src/collisionable.h b/src/collisionable.h index fb0a17e7..75391b7a 100644 --- a/src/collisionable.h +++ b/src/collisionable.h @@ -7,6 +7,8 @@ class b2World; class b2Body; class b2Shape; +#include "box2d/box2d.h" + class Collisionable; class CollisionManager {