Commit Graph

21 Commits (18ef32ca82bd9c3cfcdc9f420131e4697ee054c9)

Author SHA1 Message Date
wareya 18ef32ca82 values for this higher than sGroundOffset cause jittering on some surface; use safe-seeming value slightly less than sGroundOffset 3 years ago
Alexei Dobrohotov e9a8636d18 Merge branch 'restore_absolute_position_handling' into 'master'
Restore pre-async handling of absolute actors positionning

See merge request OpenMW/openmw!486
3 years ago
Alexei Dobrohotov ce36dd8a52 Merge branch 'misc_cleanup' into 'master'
Small cleanup

See merge request OpenMW/openmw!482
3 years ago
fredzio 5bd921fa3a Restore pre-async handling of absolute actors positionning
One of the issue since the introduction of async physics is the quirky
handling of scripted moves. Previous attempt to account for them was
based on detecting changes in actor position while the physics thread is
running. To this end, semantics of Actor::updatePosition() (which is
responsible for set the absolute position of an actor in the world) was
toned down to merely store the desired position, with the physics system
actually responsible for moving the actor. For the cases were complete
override of the physics simulation was needed, I introduced
Actor::resetPosition(), which actually have same semantics as
original updatePosition(). This in turn introduced a loads of new bugs
when the weakened semantics broke key assumptions inside the engine
(spawning, summoning, teleport, etc).
Instead of tracking them down, count on the newly introduced support for
object relative movements in the engine (World::moveObjectBy) to
register relative movements and restore original handling of absolute positionning.

Changes are relatively small:
- move resetPosition() content into updatePosition()
- call updatePosition() everywhere it was called before
- remove all added calls to the now non-existing resetPosition()

tldr; ditch last month worth of bug introduction and eradication and redo
it properly
3 years ago
fredzio 8e084dea2e Don't cache Ptr, it can be updated while the simulation is running. 3 years ago
fredzio 58297ffbf4 Move stats update into their own function. 3 years ago
fredzio 4e7c9b6696 Embed physics simulation results inside of actor class.
This gives finer control over reseting positions (switch off tcl is no
longer glitchy) and solve most of the erroneous usage of stale World::Ptr
indicated by:
"Error in frame: moveTo: object is not in this cell"
3 years ago
fredzio 7bae6691b6 Introduce World::moveObjectBy() function to translate an object relatively to
its current position.
Use it in relevant MWScripts opcode (move and moveworld).
Remove the fragile detection of scripted translation from PhysicsTaskScheduler.

No user visible change, just a more robust mechanism.
3 years ago
fredzio 66fe3b0d38 Modify projectile collision to work with async physics 3 years ago
fredzio 7843dad35d Don't let the actor "nowhere" after a teleport but move them in their
place.
This solve the problem where after loading, an empty frame was rendered
because the player is "nowhere".
4 years ago
fredzio 5a4872393a Rework actor position reset. While solving the issue with invalid
position being used under heavy load, I introduced a regression that
prevented the position to be updated in case of teleport.
Move the logic in its own function and decide in PhysicsSystem whether a
reset is needed.
4 years ago
fredzio ea2ba27084 Move the moment when the actor origin is saved before simulation so to
be sure the simulation is over. Otherwise, if the simulation is too slow
the position is wrong, and the actors would jump back and forth between
old and new position instead of actually moving.
4 years ago
Frederic Chardon 9aba55a21a Add the async physics worker to the profiler overlay. 4 years ago
Frederic Chardon bb5213670c Use bigger hammer to set Actor's position after teleporting. Otherwise traceDown() would use old collision object transform and gives incorrect results, making the Actor "fall" in the new position. 4 years ago
fredzio d64ed6cf53 Get rid of the StandingActorsMap. Just embed the necessary info into
Actor class.
4 years ago
fredzio e5fa457fe7 Properly account for interleaved move of actors.
Before this change, if an actor position was changed while the physics
simulation was running, the simulation result would be discarded. It is
fine in case of one off event such as teleport, but in the case of
scripts making use of this functionality to make lifts or conveyor (such
as Sotha Sil Expanded mod) it broke actor movement.

To alleviate this issue, at the end of the simulation, the position of the Actor
in the world is compared to the position it had at the beginning of the
simulation. A difference indicate a force move occured. In this case,
the Actor mPosition and mPreviousPosition are translated by the difference of position.

Since the Actor position will be really set while the next simulation runs, we
save it in the mNextPosition field.
4 years ago
Andrei Kortunov 64ba81ecf2 Fix some issues, found by CoverityScan 4 years ago
fredzio 1357bba0a0 Use some C++17 where it makes the code more readable
Also replace boost::optional
4 years ago
fredzio a036183248 Use a much simpler and assert-free check for Bullet multithreading support 4 years ago
fredzio 978af12c2d Restore fall damage 4 years ago
fredzio 3c2504b442 Process movement queue in one or several background threads
Before movement calculation, the main thread prepare a
vector of ActorFrameData, which contains all data necessary to perform
the simulation, and feed it to the solver. At the same time it fetches
the result from the previous background simulation, which in turn is
used by the game mechanics.
Other functions of the physics system (weapon hit for instance)
interrupt the background simulation, with some exceptions described
below.

The number of threads is controlled by the numeric setting

[Physics]
async num threads

In case 'async num threads' > 1 and Bullet doesn't support multiple threads,
1 async thread will be used. 0 means synchronous solver.
Additional settings (will be silently switched off if async num threads = 0)

[Physics]
defer aabb update

Update AABBs of actors and objects in the background thread(s). It is not an especially
costly operation, but it needs exclusive access to the collision world, which blocks
other operations. Since AABB needs to be updated for collision detection, one can queue
them to defer update before start of the movement solver. Extensive tests on as much
as one installation (mine) show no drawback having that switched on.

[Physics]
lineofsight keep inactive cache

Control for how long (how many frames) the line of sight (LOS) request will be kept updated.
When a request for LOS is made for the first time, the background threads are stopped to
service it. From now on, the LOS will be refreshed preemptively as part of the background
routine until it is not required for lineofsight keep inactive cache frames. This mean
that subsequent request will not interrupt the background computation.
4 years ago