Commit Graph

33 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
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 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 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 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
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
fredzio 4ef36973fb Make the Actor class manage its collision object and position. 4 years ago
fredzio 82da2045a9 Non functionnal changes in preparation for async physics feature 4 years ago
elsid 43b39e8418
Use not scaled player half extents as default to find path 5 years ago
Bret Curtis 14c93b3df0 Revert "Merge pull request #2204 from elsid/fix_navigator_update"
This reverts commit 26fb0e7a0f, reversing
changes made to 42b2391303.
5 years ago
elsid c066ee9dc5
Use not scaled player half extents as default to find path 5 years ago
elsid c866fdff86
Move physics object, heightfield, ptrholder into separate files 6 years ago
scrawl 99ffaafe30
Revert "Merge pull request #1701 from akortunov/standfix"
This reverts commit da47fc79f5, reversing
changes made to 7324bd368f.
6 years ago
Andrei Kortunov 3636cf2015 Do not apply queue movement for standing actors 6 years ago
Ewan Higgs 38a2de3c51 convert std::autor_ptr to std::unique_ptr, originally by Ewan Higgs and updated by Bret Curtis 7 years ago
scrawl fb073e5c14 Avoid unnecessary AABB update for rotationally invariant collision shapes 7 years ago
scrawl b3d5c2bd7f Use the actor's collision shape in findGround()
The cylinder base is no longer appropriate as of the change to capsules.

This also works around a bug when tracing a small cylinder/box shape apparently introduced with bullet 2.86.
7 years ago
scrawl 541fbb4792 Movement solver: add usage of 'on slope' flag to improve handling of steep slopes
Previously we were handling 'on slope' synonymously with 'in air' which caused some odd effects.

Practical changes:
 - Sliding down a slope no longer applies fall damage.
 - Fixed a climbing exploit that would allow climbing steep slopes with repeated use of the Jump function.
7 years ago
Aussiemon b794aa7c2f Helper methods for updateCollisionMask(), prevent water collision being removed twice, remove Bullet 2.8.5 methods 8 years ago
scrawl 383524c688 Run physics in fixed timesteps, use the remainder to interpolate between current and previous state
Based on http://gafferongames.com/game-physics/fix-your-timestep/
8 years ago
scrawl 3552b3a82c Don't create a BulletShapeInstance for actors 8 years ago
scrawl 795032621c Use a ConstPtr for the ActorMap and ObjectMap 9 years ago
scrawl 8cf57ef6ac Move BulletShapeManager and BulletShape to resource/ 9 years ago
scrawl a5f8ffb83d aimToTarget: Fix the collision box translation not being taken into account 9 years ago
scrawl bd9dc58560 Use the correct scale for actor swim height (Fixes #2833) 9 years ago
scrawl 1f00174c02 Use a btCollisionWorld instead of btDiscreteDynamicsWorld
Slightly improves performance, since we no longer need to stepSimulation(). We don't use any Dynamics (yet).
9 years ago
scrawl 85345e663a Restore getHitContact 9 years ago
scrawl 2bc95df265 Actor collision object placement fix 9 years ago
scrawl 65f0195c71 Readded animated collision shape support 9 years ago
scrawl 47758c11cd Readded collision objects and movement physics 9 years ago