1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 21:19:57 +00:00
Commit graph

288 commits

Author SHA1 Message Date
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.
2021-04-09 23:34:03 +02:00
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.
2021-04-09 23:33:21 +02:00
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.
2021-03-31 19:34:06 +02:00
fredzio
0fac172413 Remove wrong line that slipped in yesterday. 2021-03-29 21:46:08 +02:00
Evil Eye
582f1503c1 Merge branch 'setpos' into 'master'
Unbreak SetPos and the mods using it (#5919)

See merge request OpenMW/openmw!696
2021-03-28 20:14:17 +00:00
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
2021-03-28 21:19:14 +02:00
fredzio
b58244ac26 Guard the Bullet drawing method with a read lock on the
btCollisionWorld. It closes a race on the collision shapes coordinates.
2021-03-26 23:49:31 +01:00
fredzio
dbd6e3bfee Replace pointless usage of shared_ptr by unique_ptr / non-owning raw
pointer for btCollisionWorld.
2021-03-26 23:49:31 +01:00
fredzio
ccd3cbc69a Use saved actor position instead of reading again RefData in unstuck. It
is a race condition to do so.
2021-03-26 23:49:31 +01:00
wareya
63f01d8c5f Prevent physics death spiral by falling back to true delta time when needed 2021-03-21 20:45:46 +00:00
psi29a
86bd173d69 Merge branch 'refactoring' into 'master'
"static const" -> "static constexpr" in headers

See merge request OpenMW/openmw!676
2021-03-21 15:43:47 +00:00
Petr Mikheev
7bbbe40abe "static const" -> "static constexpr" in headers 2021-03-21 13:57:54 +01:00
wareya
e722c99e62 forgot to initialize these variables 2021-03-21 08:57:15 -04:00
wareya
40265bf118 make unstucking slightly smarter (can turn itself off, also acts like flat ground) 2021-03-20 21:14:56 -04:00
wareya
1471ef003a fix async physics interpolation 2021-03-18 13:53:00 -04:00
Evil Eye
4db2f79a3c Merge branch 'setpos' into 'master'
Use relative movement inside of SetPos

See merge request OpenMW/openmw!649
2021-03-13 12:58:48 +00:00
fredzio
03b86c232b Apply the position offset even if the simulation is not performed
because we're too fast.
2021-03-13 09:52:05 +01:00
Gleb Mazovetskiy
351d11449b Avoid heightfield conversion in newer Bullet
Takes advantage of the direct `float` support implemented in
https://github.com/bulletphysics/bullet3/pull/3293
2021-03-11 23:52:12 +00:00
Alexei Dobrohotov
e9aa161ffc Merge branch 'reallyskipphysics' into 'master'
Close race that breaks scripted teleporting (#5873)

See merge request OpenMW/openmw!639
2021-03-07 08:41:20 +00:00
fredzio
31d8ce266b Close a race between main and physics threads when actor is positioned by scripts.
When a position is forced, the actor position in physics subsystem is
overriden. The background physics thread is not made aware of this,
its result are simply discarded.

There is a short window where this doesn't work (in this
example, actor is at A and script moves it to B)
1) actor position is set to B. (among others, Actor::mPosition is set to B)
2) physics thread reset Actor::mPosition with stale value (around A)
3) main thread read simulation result, reset Actor::mSkipSimulation flag => actor is at B
4) physics thread fetch latest Actor::mPosition value, which is around A
5) main thread read simulation result, actor is around A

To avoid this situation, do not perform 2) until after 3) occurs. This
way, at 4) starts the simulation with up-to-date Actor::mPosition
2021-03-06 10:41:55 +01:00
Alexei Dobrohotov
2bfee281fd Merge branch 'restore_caster' into 'master'
Restore projectile caster from savegame (#5860)

See merge request OpenMW/openmw!616

(cherry picked from commit d595c7adb0fb45eafed6d3d0403ad640a91411ed)

c5426bec In the savegame, projectile caster is identified by its actor id. When
2021-03-05 21:07:29 +00:00
Gleb Mazovetskiy
1fb442e701 heightfield: Only buildAccelerator on Bullet 2.89+
Fixes #5874
2021-03-01 08:27:24 +00:00
Gleb Mazovetskiy
21a70b7d2b heighfield: buildAccellerator()
This enables accelleration of heightfield collisions.

Unfortunately, `btHeightfieldTerrainShape::processAllTriangle` does not
yet use the accellerator data, so this change does not improve
performance yet but might do so in future bullet versions.

References:

* Accellerator introduced in:
  https://github.com/bulletphysics/bullet3/pull/2062

* Feature request to use the accellerator in `processAllTriangle`:
  https://github.com/bulletphysics/bullet3/issues/3276
2021-02-26 14:38:06 +00:00
psi29a
59e09cba5b Merge branch 'boltsize' into 'master'
Use projectile mesh size (#5829)

See merge request OpenMW/openmw!587
2021-02-15 08:40:30 +00:00
fredzio
b78820de55 Ignore projectiles inside of MovementSolver::unstuck. It is normal for actors to be inside of a
projectile collision shape.
A side effect of moving actors outside of projectile collision shape is that if both the actor and the projectile are
near a wall, the actor could get moved outside of the world.
2021-02-07 18:32:03 +01:00
fredzio
6e969ca3fa Use mesh collision box instead of node bounding sphere for projectile
size. The bounding sphere is much bigger than the mesh.
2021-02-05 22:53:45 +01:00
Andrei Kortunov
7b727e4d70 Revert "Remove physics dependency on basenode"
This reverts commit 165c731492.
2021-01-29 16:51:13 +04:00
Andrei Kortunov
165af1c365 Revert "Some actors are supposed to spawn on a static object that belong to an adjacent cell."
This reverts commit f031a191b8.
2021-01-29 16:51:05 +04:00
Andrei Kortunov
f8e8496d36 Revert "Revert a wrong change introduced in MR 546"
This reverts commit 23137d0c54.
2021-01-29 16:50:39 +04:00
Andrei Kortunov
d984d13b1c Merge branch 'animate_animated_objects' into 'master'
Unbreak animated objects (regression from !546)

See merge request OpenMW/openmw!570
2021-01-28 14:12:24 +00:00
Andrei Kortunov
5382d38b9b Merge branch 'hit_target_object' into 'master'
Unbreak targetted spell on objects (#5811)

See merge request OpenMW/openmw!569
2021-01-28 14:09:45 +00:00
fredzio
23137d0c54 Revert a wrong change introduced in MR 546
A prerequisite to create physics objects for statics was to remove the
dependency on base node (since it doesn't yet exists) for object
position. It is still necessary for animation though.

Restore the basenode (and the associated FIXME) so that animated objects works properly.
2021-01-27 16:24:11 +01:00
psi29a
699bd257ef Merge branch 'camera_stats' into 'master'
Collect all available stats if OPENMW_OSG_STATS_FILE is set and point to a valid file.

See merge request OpenMW/openmw!526
2021-01-27 08:04:33 +00:00
Frederic Chardon
7cd7fa2f08 Collect all available stats if OPENMW_OSG_STATS_FILE is set and point to
a valid file.
2021-01-27 08:04:33 +00:00
fredzio
64475ebedb Remove a brainfart from precise projectile handling: all non-actor
non-projectile objects were treated as ground.
2021-01-27 07:15:09 +01:00
fredzio
f031a191b8 Some actors are supposed to spawn on a static object that belong to an adjacent cell.
Since actors can be active in 3x3 grid around the player, we need to
first load all statics in a 5x5 grid around the player.

Split load and unloading in 2 phases. Add an mInactiveCells set into the
scene, which contains all cells inside the aforementioned 5x5 grid.
These cells contains only heightfields and physics objects of static
class.
2021-01-24 14:11:10 +01:00
fredzio
165c731492 Remove physics dependency on basenode
Necessary to be able to load physics objects from inactive cells.
2021-01-24 14:10:27 +01:00
psi29a
d2c5de5211 Merge branch 'projectile_physics' into 'master'
Precise projectile physics (closes #4201)

Closes #4201

See merge request OpenMW/openmw!550
2021-01-21 23:33:22 +00:00
fredzio
1f4c85520f Use convexSweepTest for projectile movement to solve any
imprecision issue with projectile collision detection.
Simplify the mechanics: manage hits in one spot.
Give magic projectiles a collision shape similar in size to their visible
model.

Rename the 2 convex result callback to clearly state their purpose.
2021-01-21 20:36:33 +01:00
fredzio
e37e5d4d16 Don't run unstuck if there is no simulation running in async case.
In this case, the actor mPreviousPosition is not updated, so the actor
position is interpolated between an old (stucked) position and the new
(unstucked) position. The new position is most likely "stucked", so the
unstuck code strikes again, making the actor "vibrates".

That's exactly what the sync code path does, and it doesn't exhibit this
behavior.
2021-01-18 17:45:57 +01:00
psi29a
6863c5a68f Merge branch 'raii' into 'master'
Make all physics object manage their own resources.

See merge request OpenMW/openmw!527
2021-01-10 20:50:55 +00:00
fredzio
d015f17a6c Make all physics object manage their own resources
Use smart pointer for heightfields and their members.
Move collision object addition inside of Object's ctor, as for Actors and HeightFields
2021-01-10 14:56:35 +01:00
elsid
8b7f3fe908 Merge branch 'nodeadlock' into 'master'
Avoid a rare but possible deadlock around mCollisionWorldMutex.

See merge request OpenMW/openmw!525
2021-01-10 13:41:31 +00:00
fredzio
9bc687e209 Avoid a rare but possible deadlock around mCollisionWorldMutex.
What happened is that the last handle to an Actor shared_ptr was a
promoted weak_ptr. When the shared_ptr goes out of scope, the Actor dtor
is invoked. That involves removing the Actor collision object after
exclusively locking mCollisionWorldMutex. In this case, the lock was
already held in the outter scope of the promoted weak_ptr.

Reduce the scope of the mCollisionWorldMutex to never encompass the
lifetime of a promoted weak_ptr.
2021-01-09 21:10:29 +01:00
Andrei Kortunov
33648313a6 Initialize variables 2021-01-09 14:21:57 +04:00
Andrei Kortunov
6a12c2b58b Fix GCC build warnings 2020-12-28 12:06:41 +04:00
wareya
18ef32ca82 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
fredzio
ebb564ad22 call moveObject() after applying waterwalking
This unbreak abot's boat mods: they're continually teleporting
the boats (who is an actor with waterwalking effect). As such, the
physics simulation was never run and the boat never went to sea level.
2020-12-27 17:31:55 +01:00
Alexei Dobrohotov
22476281da Fix paralyze for swimming actors 2020-12-22 08:03:51 +03:00
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
2020-12-20 22:52:35 +00:00