These were present to implement actor freezing in software rendering mode
in the way original engine was intended for performance reason.
In residualvm, software rendering will generalise the principle through
dirty-rectangles management, so off-screen buffers should not be needed.
Also, properly implementing them requires invasive changes (move previous
draw call list from global OpenGL context to individual off-screen buffers,
along with associated linear vertex allocator, adding a new draw call to
track requested buffer changes until final on-screen frame buffer
presentation).
So instead of such added complexity, lie to lua API about actor not being
in set but keep it in so it is part of normal redraw sequence.
Fixes disappearing actors in cn, bi.
Likely also fixes at, ly, sh, mn, dd which uses free/thaw lua API, but
which I did not check.
- if Lua_V2::SetActorGlobalAlpha() is called with a mesh name,
set a mesh-specific alpha value / mode
- use this alpha value in drawEMIModelFace()
- fixes the problem that the whole actor vanishes in some scenes
(e.g. when entering or leaving the porch of the of LUA bar)
TurnActorTo is mapped to Actor::singleTurnTo() which only
turns the actor (according to its turn rate) by a small amount.
If the turn could not be completed, TurnActorTo returns false.
In EMI, all LUA calls to TurnActorTo are repeated until the
actor does eventually look into the correct direction.
However, for parallel running LUA threads, calls to IsActorTurning
would return false during such a "LUA-controlled" turn.
In the scene with the dart players, the LUA code for the dialog
waits for the dart player to stop moving (and turning) by repeatedly
calling IsActorTurning. Since that function returns false
even if the players are still turning towards the dart board, the
dialog code starts and spawns a parallel LUA thread to use
TurnActorTo to make the dart players looking at Guybrush.
This means, that eventually for each dart player, two LUA
threads with contradicting TurnActorTo directions will run forever
since in none of the threads the final direction is ever reached.
To fix that, a new actor state variable, _singleTurning, is introduced.
It is set to true if an Actor::singleTurnTo() call indicates that
the turn is not complete. It is set to false once the turning has
fininshed.
Since all TurnActorTo calls in EMI are repeated until the function returns
false, it is safe to use that variable to indicate that a "LUA-controlled"
turning is in progress.
In GRIM, that's not the case and so isTurning() is only changed for EMI.
This fixes Guybrush occasionally being visible through the buildings and foliage on Lucre island when walking at the edge of the walkable sectors. This happened because for positions at the edge of the walkable sector the method Sector::isPointInSector may not always return true.
Sometimes a texi component may refer to a material that was initialized by some other costume than the owner costume of the texi component. For example, the candles in gmi have a costume "fx/aura1.cos" that controls the animation of a material originally initialized by a sprite component of "fx/candle.cos".
In Lua, The wear chore of dumbshadow.cos is only started if GetActorPuckVector returns a non-nil value. In the original game GetActorPuckVector seems to always return nil until a call is made to SetActorFollowBoxes.
This fixes the candles not appearing in the set gmi. The original Lua code only starts the candle animation if the candle actor is not playing any chores. Previously the wear chore of dumbshadow.cos was playing, so the animation was never started.
Some chores need to stay active even after a call to
StopAllChores(). E.g. the hold chores should stay active
even after changing the set (which calls StopAllChores()).
It looks like that the previously unknown boolean paramter
of StopAllChores() controls that behavior. If set to TRUE,
stop only the non-looping chores.
This patch fixes:
- hold chore was lost when switching sets
- blue painting did not show the ultimate insult when opening
the inventory
The hold chore was always lost after e.g. turning left or right.
Although that chore was still in _playingChores, it was not shown.
The patch uses the following order for drawing the chores:
- wear chores
- rest chores
- walk/turn chores
- other chores (in order of the playChore calls)
Use matrix multiplications to fix the rotation for attached actors:
- calculate the final transformation matrix recursively for attached
actors (instead of using getWorldPos and getWorldRot)
- use a different order for building the quaternions out of the Euler
angles
- changed handling of camera position (just apply the rotation of the
camera, the (inverted) position of the camera and the position of the
actor
- no functional changes for GRIM
- no changes for drawing in overworld
Code simplification for GRIM:
- no need to use _currentPos in calculations for GRIM since it is
always (0, 0, 0)
This fixes:
- the rotation of any items Guybrush is holding in his hands
- the handling of the pole when using the raft in the swamps
- getting the bananas with the banana picker
- the costumes are handled on a stack per Actor
- the last costume is considered the current one
- currently, the costumes are never removed from from the stack
- this causes an issue when Guybrush is using its original
costume first, later the monkey robot costume for the final Monkey Kombat
and then again the standard costume (the robot costume will remain the last
on the stack and cosidered the current one - this causes a problem
when attaching the head actor since the robot has different joints
than guybrush with the standard costume)
- if a new wear chore is set and it uses a different costume than the
current one and neither of them is the shadow costume remove the old
costume before setting the new one
- additionally, this patch makes sure, that all active chores of all
costumes on the stack of an actor are stopped
- for solving the Monkey Kombat puzzle it is necessary that a kombat is
triggered when Guybrush runs into one of the monkeys on the map
- implement SetActorCollisionMode and SetActorCollisionScale
- add EMI-specific calculations for retrieving the sphere data for the
actors (and some minor refactoring for better readability)
The following changes may alter the behaviour in GRIM, too:
- in Actor::collisionHandlerCallback(), call the collision handler for
both affected objects (that is necessary since only one actor may have
a collision handler associated in lua but it may happen that the
character with the handler is standing still and the other one is run
into him)
- Actor::handleCollisionTo() did only update a given position to ensure
that there is no collision - so it is necessary to actually check for
collisions and execute the lua callback if necessary (via
Actor::handleCollisionWith())
EMI uses a different coordinate system than Grim, so we have to switch
dimensions in various places to share common code for walking and turning
actors. This patch fixes several yaw angle sign errors causing actors to
look into wrong directions.
The floor in the Hall of Justice is hidden by a solid gray actor named
"trap plane". This actor is originally positioned far in the background
but moved to the foreground because we can't find a sort plane in the
sector.
This patch stores returns an actor to the original sort order set by
the game script when entering a sector that has no sort information.