1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-23 22:53:52 +00:00
openmw-tes3mp/apps/openmw/mwphysics
fredzio b13afd758c Remove both racy and useless code.
Actor's position can be determined in 3 ways:
1/ as a result of physics simulation
2/ after a script require a relative position change (SetPos, Move)
3/ absolutely set from games mechanics event (teleport) or script
(PositionCell)

In case 1/, RefData::mPosition is updated with the physics simulation result
In case 2/, when RefData::mPosition is updated, physics simulation is informed of the change and update accordingly
In case 3/, when RefData::mPosition is updated, the physics simulation state is reset

In all 3 cases, we don't need to check the RefData::mPosition to get a
correct behaviour.

TSAN reported the following data race:
  Read of size 4 at 0x7b50005b75b0 by thread T12 (mutexes: write M656173, write M84859534346343880):
    #0 ESM::Position::asVec3() const /build/openmw/openmw/master2/.build/freebsd/TSAN/../../.././components/esm/defs.hpp:55:27 (openmw+0xb809d5)
    #1 MWPhysics::Actor::updateWorldPosition() /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwphysics/actor.cpp:131:59 (openmw+0xb809d5)
    #2 MWPhysics::Actor::setPosition(osg::Vec3f const&) /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwphysics/actor.cpp:177:5 (openmw+0xb809d5)
    #3 MWPhysics::PhysicsTaskScheduler::updateActorsPositions() /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwphysics/mtphysics.cpp:524:28 (openmw+0xb91ac0)
    #4 MWPhysics::PhysicsTaskScheduler::afterPostStep() /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwphysics/mtphysics.cpp:614:13 (openmw+0xb915e7)
    #5 MWPhysics::PhysicsTaskScheduler::worker()::$_5::operator()() const /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwphysics/mtphysics.cpp:498:45 (openmw+0xb915e7)
    #6 void Misc::Barrier::wait<MWPhysics::PhysicsTaskScheduler::worker()::$_5>(MWPhysics::PhysicsTaskScheduler::worker()::$_5&&) /build/openmw/openmw/master2/.build/freebsd/TSAN/../../.././components/misc/barrier.hpp:30:21 (openmw+0xb915e7)
    #7 MWPhysics::PhysicsTaskScheduler::worker() /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwphysics/mtphysics.cpp:498:31 (openmw+0xb915e7)
    #8 MWPhysics::PhysicsTaskScheduler::PhysicsTaskScheduler(float, btCollisionWorld*, MWRender::DebugDrawer*)::$_0::operator()() const /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwphysics/mtphysics.cpp:162:45 (openmw+0xb92630)
    #9 decltype(std::__1::forward<MWPhysics::PhysicsTaskScheduler::PhysicsTaskScheduler(float, btCollisionWorld*, MWRender::DebugDrawer*)::$_0>(fp)()) std::__1::__invoke<MWPhysics::PhysicsTaskScheduler::PhysicsTaskScheduler(float, btCollisionWorld*, MWRender::DebugDrawer*)::$_0>(MWPhysics::PhysicsTaskScheduler::PhysicsTaskScheduler(float, btCollisionWorld*, MWRender::DebugDrawer*)::$_0&&) /usr/include/c++/v1/type_traits:3899:1 (openmw+0xb92630)
    #10 void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, MWPhysics::PhysicsTaskScheduler::PhysicsTaskScheduler(float, btCollisionWorld*, MWRender::DebugDrawer*)::$_0>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, MWPhysics::PhysicsTaskScheduler::PhysicsTaskScheduler(float, btCollisionWorld*, MWRender::DebugDrawer*)::$_0>&, std::__1::__tuple_indices<>) /usr/include/c++/v1/thread:280:5 (openmw+0xb92630)
    #11 void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, MWPhysics::PhysicsTaskScheduler::PhysicsTaskScheduler(float, btCollisionWorld*, MWRender::DebugDrawer*)::$_0> >(void*) /usr/include/c++/v1/thread:291:5 (openmw+0xb92630)

  Previous write of size 8 at 0x7b50005b75b0 by main thread:
    #0 memcpy /wrkdirs/usr/ports/devel/llvm-devel/work-default/llvm-project-3f6753efe1990a928ed120bd907940a9fb3e2fc3/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:827:5 (openmw+0x55a057)
    #1 MWWorld::RefData::setPosition(ESM::Position const&) /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwworld/refdata.cpp:216:19 (openmw+0xa3de1c)
    #2 MWWorld::World::moveObject(MWWorld::Ptr const&, MWWorld::CellStore*, float, float, float, bool) /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwworld/worldimp.cpp:1130:26 (openmw+0xa57300)
    #3 MWWorld::World::moveObject(MWWorld::Ptr const&, float, float, float, bool, bool) /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwworld/worldimp.cpp:1253:16 (openmw+0xa580c8)
    #4 MWWorld::World::doPhysics(float, unsigned long long, unsigned int, osg::Stats&) /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwworld/worldimp.cpp:1530:17 (openmw+0xa5af8f)
    #5 MWWorld::World::updatePhysics(float, bool, unsigned long long, unsigned int, osg::Stats&) /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/mwworld/worldimp.cpp:1862:13 (openmw+0xa61a7c)
    #6 OMW::Engine::frame(float) /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/engine.cpp:333:42 (openmw+0xcce9e7)
    #7 OMW::Engine::go() /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/engine.cpp:935:14 (openmw+0xcd86ed)
    #8 runApplication(int, char**) /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/main.cpp:296:17 (openmw+0xcbffac)
    #9 wrapApplication(int (*)(int, char**), int, char**, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../components/debug/debugging.cpp:205:15 (openmw+0x1335442)
    #10 main /build/openmw/openmw/master2/.build/freebsd/TSAN/../../../apps/openmw/main.cpp:308:12 (openmw+0xcc008a)
:wqa
2021-05-20 20:46:44 +02:00
..
actor.cpp Remove both racy and useless code. 2021-05-20 20:46:44 +02:00
actor.hpp Remove both racy and useless code. 2021-05-20 20:46:44 +02:00
actorconvexcallback.cpp Remove some useless includes in apps/openmw/mwphysics 2021-05-15 23:13:46 +02:00
actorconvexcallback.hpp Use convexSweepTest for projectile movement to solve any 2021-01-21 20:36:33 +01:00
closestnotmerayresultcallback.cpp Use convexSweepTest for projectile movement to solve any 2021-01-21 20:36:33 +01:00
closestnotmerayresultcallback.hpp Use convexSweepTest for projectile movement to solve any 2021-01-21 20:36:33 +01:00
collisiontype.hpp Use a separate collision type for doors (Fixes #1962) 2015-12-18 18:32:42 +01:00
constants.hpp Fix double -> float conversions 2021-04-19 15:36:58 +04:00
contacttestresultcallback.cpp Do not block a door when it turns away. 2020-11-01 23:01:18 +01:00
contacttestresultcallback.hpp Remove some useless includes in apps/openmw/mwphysics 2021-05-15 23:13:46 +02:00
contacttestwrapper.cpp values for this higher than sGroundOffset cause jittering on some surface; use safe-seeming value slightly less than sGroundOffset 2020-12-27 22:16:11 +00:00
contacttestwrapper.h values for this higher than sGroundOffset cause jittering on some surface; use safe-seeming value slightly less than sGroundOffset 2020-12-27 22:16:11 +00:00
deepestnotmecontacttestresultcallback.cpp Visualize hand to hand hits 2020-10-26 13:48:15 +01:00
deepestnotmecontacttestresultcallback.hpp Visualize hand to hand hits 2020-10-26 13:48:15 +01:00
hasspherecollisioncallback.hpp components/compiler cleanup; also cleaned up related cascading warnings; fixed up final/override issues 2020-10-22 23:57:53 +02:00
heightfield.cpp Avoid heightfield conversion in newer Bullet 2021-03-11 23:52:12 +00:00
heightfield.hpp Avoid heightfield conversion in newer Bullet 2021-03-11 23:52:12 +00:00
movementsolver.cpp Tone down actor's skip simulation flag to an optional skip collision 2021-05-01 14:22:30 +02:00
movementsolver.hpp Remove some useless includes in apps/openmw/mwphysics 2021-05-15 23:13:46 +02:00
mtphysics.cpp Remove an unused struct 2021-05-15 19:49:15 +02:00
mtphysics.hpp Do not store callback inside Misc::Barrier 2021-05-05 23:42:47 +02:00
object.cpp Make the code less verbose / more readable using for range loop and 2021-05-16 12:42:16 +02:00
object.hpp Revert "Remove physics dependency on basenode" 2021-01-29 16:51:13 +04:00
physicssystem.cpp Remove both racy and useless code. 2021-05-20 20:46:44 +02:00
physicssystem.hpp Embed actor velocity inside its class. It makes the code simpler. 2021-05-16 12:42:17 +02:00
projectile.cpp An another pass 2021-04-30 20:27:33 +02:00
projectile.hpp An another pass 2021-04-30 20:27:33 +02:00
projectileconvexcallback.cpp Remove a brainfart from precise projectile handling: all non-actor 2021-01-27 07:15:09 +01:00
projectileconvexcallback.hpp Remove some useless includes in apps/openmw/mwphysics 2021-05-15 23:13:46 +02:00
ptrholder.hpp Don't cache Ptr, it can be updated while the simulation is running. 2020-12-18 22:22:37 +01:00
raycasting.hpp Use convexSweepTest for projectile movement to solve any 2021-01-21 20:36:33 +01:00
stepper.cpp Remove some useless includes in apps/openmw/mwphysics 2021-05-15 23:13:46 +02:00
stepper.hpp values for this higher than sGroundOffset cause jittering on some surface; use safe-seeming value slightly less than sGroundOffset 2020-12-27 22:16:11 +00:00
trace.cpp Use convexSweepTest for projectile movement to solve any 2021-01-21 20:36:33 +01:00
trace.h Use tracer hit height to skip stepping up in movement solver. 2016-12-24 23:07:44 +01:00