diff --git a/src/pe/rigidbody/BodyStorage.h b/src/pe/rigidbody/BodyStorage.h index dc4775ded7e744bb5ed50b90436a38fde83e9272..7e4475e9a7ab8dfd8e19730ae27ee141391a15f3 100644 --- a/src/pe/rigidbody/BodyStorage.h +++ b/src/pe/rigidbody/BodyStorage.h @@ -131,7 +131,7 @@ public: //**Add/Remove functions************************************************************************ /*!\name Add/Remove functions */ //@{ - inline RigidBody& add ( BodyID body ); + [[deprecated]] inline RigidBody& add ( BodyID body ); inline RigidBody& add ( std::unique_ptr<RigidBody>&& body ); inline iterator remove ( const id_t sid ); inline iterator remove ( BodyID body ); diff --git a/tests/pe/BodyStorage.cpp b/tests/pe/BodyStorage.cpp index 644f29a1c063de596a9d15081778b2bd23ef784f..498f973944f7d2529ea84072253a4516616104db 100644 --- a/tests/pe/BodyStorage.cpp +++ b/tests/pe/BodyStorage.cpp @@ -54,18 +54,21 @@ int main( int argc, char** argv ) MaterialID iron = Material::find("iron"); { BodyStorage storage; - auto bd1 = new Body1(1, iron); - auto bd2 = new Body2(2, iron); - auto bd3 = new Body2(3, iron); - auto bd4 = new Body2(4, iron); + auto bd1Ptr = std::make_unique<Body1>(1, iron); + auto bd2Ptr = std::make_unique<Body2>(2, iron); + auto bd3Ptr = std::make_unique<Body2>(3, iron); + auto bd4Ptr = std::make_unique<Body2>(4, iron); + + auto bd2 = bd2Ptr.get(); + auto bd3 = bd3Ptr.get(); WALBERLA_CHECK_EQUAL(Body1::refCount, 1); WALBERLA_CHECK_EQUAL(Body2::refCount, 3); - storage.add(bd1); - storage.add(bd2); - storage.add(bd3); - storage.add(bd4); + storage.add(std::move(bd1Ptr)); + storage.add(std::move(bd2Ptr)); + storage.add(std::move(bd3Ptr)); + storage.add(std::move(bd4Ptr)); WALBERLA_CHECK_EQUAL(storage.size(), 4); WALBERLA_CHECK_EQUAL(Body1::refCount, 1); diff --git a/tests/pe/RigidBody.cpp b/tests/pe/RigidBody.cpp index f73aa02ef2f28c6bebcdf1c8dcfc3058ec0d3927..20dfb8c0609e61a4080115bcade6882583f14a99 100644 --- a/tests/pe/RigidBody.cpp +++ b/tests/pe/RigidBody.cpp @@ -148,8 +148,8 @@ int main( int argc, char** argv ) MaterialID iron = Material::find("iron"); BodyStorage storage; - SphereID sphere = new Sphere(0, 0, Vec3(0,0,0), Vec3(0,0,0), Quat(), 1, iron, false, true, false); - storage.add(sphere); + SpherePtr spPtr = std::make_unique<Sphere>(0, 0, Vec3(0,0,0), Vec3(0,0,0), Quat(), 1, iron, false, true, false); + SphereID sphere = static_cast<SphereID>(&storage.add(std::move(spPtr))); Vec3 x0 = Vec3(-2,2,0); Vec3 v0 = Vec3(-1,-1,1); diff --git a/tests/pe/SimpleCCD.cpp b/tests/pe/SimpleCCD.cpp index 3e160acdd3c05d304abc4e2775dd2981d2abfe8e..527a846383cb8931c3215e5a16352093918f4699 100644 --- a/tests/pe/SimpleCCD.cpp +++ b/tests/pe/SimpleCCD.cpp @@ -60,7 +60,7 @@ int main( int argc, char** argv ) math::seedRandomGenerator(1337); for (uint_t i = 0; i < 100; ++i) - storage[0].add( new Sphere(UniqueID<Sphere>::createGlobal(), 0, Vec3( math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10))), Vec3(0,0,0), Quat(), 1, iron, false, false, false) ); + storage[0].add( std::make_unique<Sphere>(UniqueID<Sphere>::createGlobal(), 0, Vec3( math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10))), Vec3(0,0,0), Quat(), 1, iron, false, false, false) ); sccd.generatePossibleContacts(); @@ -84,14 +84,14 @@ int main( int argc, char** argv ) bs.clear(); - bs.add( new Sphere(UniqueID<Sphere>::createGlobal(), 0, Vec3( math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10))), Vec3(0,0,0), Quat(), 1, iron, false, false, false) ); + bs.add( std::make_unique<Sphere>(UniqueID<Sphere>::createGlobal(), 0, Vec3( math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10))), Vec3(0,0,0), Quat(), 1, iron, false, false, false) ); WcTimingPool pool; for (int runs = 0; runs < 10; ++runs) { auto oldSize = bs.size(); for (uint_t i = 0; i < oldSize; ++i) - bs.add( new Sphere(UniqueID<Sphere>::createGlobal(), 0, Vec3( math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10))), Vec3(0,0,0), Quat(), 0.5, iron, false, false, false) ); + bs.add( std::make_unique<Sphere>(UniqueID<Sphere>::createGlobal(), 0, Vec3( math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10)), math::realRandom(real_c(0), real_c(10))), Vec3(0,0,0), Quat(), 0.5, iron, false, false, false) ); pool["SCCD"].start(); sccd.generatePossibleContacts(); pool["SCCD"].end();