Commit Graph

360 Commits (master)

Author SHA1 Message Date
David Cernat 38363eee0d Add OpenMW 0.47 commits up to 4 Dec 2021 3 years ago
elsid 7f1e5b368e
Fix deadlock in physics system
* Reorder unlock and notify_all calls to avoid notifying when not all worker
  threads are waiting.
* Make sure main thread does not attempt to exclusively lock mSimulationMutex
  while not all workers are done with previous frame.
* Replace mNewFrame flag by counter to avoid modification from multiple
  threads.
3 years ago
David Cernat e010c61167 Add OpenMW 0.47 commits up to 10 Oct 2021 3 years ago
fredzio 32108adc31 Change projectile behaviour to be like in vanilla wrt. water plane:
- enchanted arrow explode upon hit the water plane
- non enchanted arrow disappear (or more accurately, they hit nothingness)
- enchanted arrow shot underwater explode immediately
- non enchanted arrow disappear immediately

Also, solve a bug that occured previously and could theoritically still happens where we use the last tested collision position for instead of the last registered hit:
Use the hit position as saved inside Projectile::hit() instead of the last position saved inside the callback.
If a projectile collides with several objects (bottom of the sea and water surface for instance), the last collision tested won't necessarily be the impact position as we have no control over the order in which the tests are performed.
3 years ago
David Cernat 26033ff7e7 Add OpenMW 0.47 commits up to 4 Aug 2021 3 years ago
elsid 08b026e907
Store copies of ref_ptr for btCollisionShape wrappers in Navigator
To keep btCollisionShape lifetime.
3 years ago
David Cernat 0567dc1fd4 Add OpenMW 0.47 commits up to 25 Jul 2021 3 years ago
fredzio 9d17cece3a Set mCanWaterWalk and mOnGround when adding Actor to the scene.
mCanWaterWalk was set to false and updated during next frame's simulation
mOnGround is set to true but then was updated as part of the scene
loading logic.
3 years ago
fredzio 744cfc6a51 Do not store a btTransform into Projectile class: reduce its size by 112 bytes 3 years ago
fredzio 20aefb5f5f Do not store btTransform into Object class: reduce its size by 104 bytes 3 years ago
fredzio 8861d53809 Do not store a btTransform into Actor class: reduce its size by 128 bytes 3 years ago
psi29a 59da0a0da9 Merge branch 'skip_async' into 'master'
Don't put player in the air after going out of tcl

See merge request OpenMW/openmw!1009

(cherry picked from commit 6d08a1d7318ae076839738d173b884fcc7b1a348)

6ad2cf8e Skip simulation result after calling Actor::updatePosition(). Otherwise
4 years ago
psi29a d1c0cfa524 Merge branch 'lifetime' into 'master'
Maybe fix #6071

Closes #6071

See merge request OpenMW/openmw!1010

(cherry picked from commit 64750820957773a00d449d29551bb15fbf5fe08b)

1650dabe Assign the return value of weak_ptr::lock() to a variable, so that the
4 years ago
David Cernat 1f0cb09933 Add OpenMW commits up to 1 Jun 2021
# Conflicts:
#   .travis.yml
#   README.md
4 years ago
Evil Eye b8472e1303 Use modified paralyze magnitude to fall and float 4 years ago
David Cernat 7a6dfc61ec Add OpenMW commits up to 21 May 2021
# Conflicts:
#   CMakeLists.txt
#   apps/openmw/mwscript/interpretercontext.cpp
#   components/CMakeLists.txt
4 years ago
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
4 years ago
fredzio 5b63019719 Embed actor velocity inside its class. It makes the code simpler. 4 years ago
fredzio c55db790f3 Make the code less verbose / more readable using for range loop and
structured binding.

No functional changes.
4 years ago
Frederic Chardon 730f1fe2a7 Merge branch 'useless_includes_mwphysics' into 'master'
Remove some useless includes in apps/openmw/mwphysics

See merge request OpenMW/openmw!872
4 years ago
jvoisin 9373e4ada7 Remove some useless includes in apps/openmw/mwphysics 4 years ago
jvoisin c1e3869f25 Remove an unused struct 4 years ago
Frederic Chardon caf382c19f Merge branch 'barrier' into 'master'
Do not store callback inside Misc::Barrier

See merge request OpenMW/openmw!821
4 years ago
psi29a 9b017ef04d Merge branch 'internal_includes_openmw' into 'master'
Clean up some internal includes of the openmw component

See merge request OpenMW/openmw!796
4 years ago
Andrei Kortunov a0582caa26 Fix uninitialized variable 4 years ago
David Cernat ea6d5c68ae Add OpenMW commits up to 6 May 2021
# Conflicts:
#   CMakeLists.txt
#   components/CMakeLists.txt
4 years ago
elsid 626e032931
Do not store callback inside Misc::Barrier
The only wait method can be provided with it so pass it as a template
parameter there.
4 years ago
David Cernat a3f304107b Add OpenMW commits up to 2 May 2021
# Conflicts:
#   components/CMakeLists.txt
4 years ago
fredzio 4fa0972b2d Tone down actor's skip simulation flag to an optional skip collision
detection flag.
4 years ago
jvoisin be371ccd9f An another pass 4 years ago
Bret Curtis 50d6cd2a34
Merge pull request #3070 from akortunov/coverity
Fix an another portion of Coverity warnings
4 years ago
Andrei Kortunov 651ad11ad8 Do not leave variables without initialization, even in execution paths where they are unused 4 years ago
Andrei Kortunov 0cadc97fb3 Fix double -> float conversions 4 years ago
Andrei Kortunov 987b231fdd Fix an another portion of Coverity warnings 4 years ago
fredzio e31cf7e6ac Follow up MR 722: do not apply mPositionOffset twice when we teleport.
Previous MR change the meaning of mPositionOffset: it is now just a log
of relative movement that were already applied to allow the physics
simulation to catch up, instead of changes that needs to be applied. As
such, after a teleport we need to reset it. Also, since mWorldPosition
is already with the offset we should not update its value in
applyPositionOffset().
4 years ago
fredzio 9d8fcec642 Remove bogus warning. It is a normal situation for projectiles to be
in-flight after the caster is gone.
4 years ago
David Cernat cedf70f367 Add OpenMW commits up to 13 Apr 2021
# Conflicts:
#   .travis.yml
#   apps/openmw/mwmechanics/actors.cpp
#   apps/openmw/mwmechanics/summoning.cpp
#   apps/openmw/mwphysics/mtphysics.hpp
4 years ago
fredzio 8874a5be22 Change (again) the way SetPos behave.
Instead of registering the desired change of position and rely on
physics simulation to apply it to the world, immediately change the
position in the world without reset the simulation.
4 years ago
fredzio 6e1c67a9ae Account for waterwalking when updating position. Otherwise we might
trace down the actor at waterlevel at the wrong coordinate.

Triggered by multimark mod with waterwalking effect.
4 years ago
fredzio 9cae7882dd Fix a bug that was triggered with multi mark mod.
When a script calls SetPos for x,y,z in sequence on an actor, we need to make sure
that the actor will not spawn under ground at x,y coordinates.
Now that change of coordinates are cumulated and applied all at once, we
need to account for the whole offset.
To this end move the terrain height check inside of Actor class.
4 years ago
fredzio 0fac172413 Remove wrong line that slipped in yesterday. 4 years ago
Evil Eye 582f1503c1 Merge branch 'setpos' into 'master'
Unbreak SetPos and the mods using it (#5919)

See merge request OpenMW/openmw!696
4 years ago
fredzio 7a67492d81 Unbreak SetPos and the mods using it.
To make SetPos works with async physics, it was modified to register a
position offset that would be applied to the real position during the
simulation.

A common pattern to teleport NPC in scripts is a sequence of SetPos/Disable/Enable in the same frame.
Since Disable/Enable creates a new physics actor using last known
RefData::Position, the registered offset never get a chance to be applied.

Modify disable() to call moveObject with the offset applied, so that the newly created physics actor will have up-to-date position
4 years ago
fredzio b58244ac26 Guard the Bullet drawing method with a read lock on the
btCollisionWorld. It closes a race on the collision shapes coordinates.
4 years ago
fredzio dbd6e3bfee Replace pointless usage of shared_ptr by unique_ptr / non-owning raw
pointer for btCollisionWorld.
4 years ago
fredzio ccd3cbc69a Use saved actor position instead of reading again RefData in unstuck. It
is a race condition to do so.
4 years ago
wareya 63f01d8c5f Prevent physics death spiral by falling back to true delta time when needed 4 years ago
psi29a 86bd173d69 Merge branch 'refactoring' into 'master'
"static const" -> "static constexpr" in headers

See merge request OpenMW/openmw!676
4 years ago
Petr Mikheev 7bbbe40abe "static const" -> "static constexpr" in headers 4 years ago
wareya e722c99e62 forgot to initialize these variables 4 years ago