Skip to content

Commit 34d79de

Browse files
committed
Make fixes to bring box2d up to date
1 parent 55d4bf7 commit 34d79de

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
44

55
find_package(SDL2 REQUIRED)
66
find_package(SDL2-image REQUIRED)
7-
find_package(unofficial-box2d CONFIG REQUIRED)
7+
find_package(box2d CONFIG REQUIRED)
88
find_package(slikenet CONFIG REQUIRED)
99
find_package(Ogg REQUIRED)
1010

@@ -189,7 +189,7 @@ target_link_libraries(Strife.Engine PUBLIC
189189
SDL2::SDL2
190190
SDL2::SDL2main
191191
SDL2::SDL2_image
192-
unofficial::box2d::box2d
192+
box2d::box2d
193193
OALWrapper
194194
SLikeNet
195195
Strife.ML

src/Components/RigidBodyComponent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ b2Body* RigidBodyComponent::CreateBody(b2BodyDef& bodyDef, bool createAtCurrentP
7676
ScaleToBox2D(bodyDef.position);
7777
ScaleToBox2D(bodyDef.linearVelocity);
7878

79-
bodyDef.userData = this;
79+
bodyDef.userData.pointer = (uintptr_t)this;
8080

8181
body = GetScene()->GetWorld()->CreateBody(&bodyDef);
8282

src/Physics/ColliderHandle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Entity* ColliderHandle::OwningEntity() const
1616

1717
RigidBodyComponent* ColliderHandle::OwningRigidBody() const
1818
{
19-
return reinterpret_cast<RigidBodyComponent*>(_fixture->GetBody()->GetUserData());
19+
return reinterpret_cast<RigidBodyComponent*>(_fixture->GetBody()->GetUserData().pointer);
2020
}
2121

2222
Rectangle ColliderHandle::Bounds() const

src/Physics/Physics.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ void CollisionManager::UpdateEntityPositions()
3333
{
3434
for (auto body = _world->GetBodyList(); body != nullptr; body = body->GetNext())
3535
{
36-
auto data = body->GetUserData();
36+
// TODO: This should use the new box2d userdata integration
37+
auto data = body->GetUserData().pointer;
3738

38-
if (data != nullptr)
39+
if ((void*)data != nullptr)
3940
{
4041
auto rigidBody = reinterpret_cast<RigidBodyComponent*>(data);
4142
auto entity = rigidBody->owner;

0 commit comments

Comments
 (0)