diff --git a/ChangeLog.md b/ChangeLog.md index b7b0e9c7d..44e9d219d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -102,6 +102,7 @@ Nazara Development Kit: - ⚠️ Renamed World::Update() to World::Refresh() for more clarity and to differentiate it from World::Update(elapsedTime) - World entity ids are now reused from lowest to highest (they were previously reused in reverse order of death) - World now has an internal profiler, allowing to measure the refresh and system update time +- CollisionComponent[2D|3D] and PhysicsComponent[2D|3D] now configures their internal RigidBody userdata to the entity ID they belong to (useful for callbacks) # 0.4: diff --git a/SDK/src/NDK/Components/CollisionComponent2D.cpp b/SDK/src/NDK/Components/CollisionComponent2D.cpp index 2fe1c8b22..9e88f396b 100644 --- a/SDK/src/NDK/Components/CollisionComponent2D.cpp +++ b/SDK/src/NDK/Components/CollisionComponent2D.cpp @@ -59,6 +59,7 @@ namespace Ndk Nz::PhysWorld2D& physWorld = entityWorld->GetSystem().GetWorld(); m_staticBody = std::make_unique(&physWorld, 0.f, m_geom); + m_staticBody->SetUserdata(reinterpret_cast(static_cast(m_entity->GetId()))); Nz::Matrix4f matrix; if (m_entity->HasComponent()) diff --git a/SDK/src/NDK/Components/PhysicsComponent2D.cpp b/SDK/src/NDK/Components/PhysicsComponent2D.cpp index 087eee04d..e2e199a22 100644 --- a/SDK/src/NDK/Components/PhysicsComponent2D.cpp +++ b/SDK/src/NDK/Components/PhysicsComponent2D.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace Ndk { @@ -40,8 +41,9 @@ namespace Ndk else matrix.MakeIdentity(); - m_object.reset(new Nz::RigidBody2D(&world, 1.f, geom)); + m_object = std::make_unique(&world, 1.f, geom); m_object->SetPosition(Nz::Vector2f(matrix.GetTranslation())); + m_object->SetUserdata(reinterpret_cast(static_cast(m_entity->GetId()))); } /*!