When using getRelDir before setVectorDirAndUp on a Player the Camera Rotation and Alignment Breaks.
Description
Details
- Severity
- None
- Resolution
- Open
- Reproducibility
- Unable To Reproduce
- Operating System
- Windows 10 x64
- Operating System Version
- 21h1
- Category
- Scripting
- Load The Test Mission
- Rest your Weapon on a steep hill
- Go into 3rd Person
- execute Code in Debug Console
JK_fnc_test = { player getRelDir player; player setVectorDirAndUp [vectorDir player, [0, 0, 1]]; }; if (isNil "JK_Test") then { JK_Test = addMissionEventHandler ["EachFrame", { call JK_fnc_test; }] };
Related Issue: https://github.com/diwako/diwako_dui/issues/140
Expected Camera Angle: https://i.imgur.com/BD3ppBi.jpg
Caused Camera Angle: https://i.imgur.com/ga3Rq2v.jpeg
A temporary workaround is calculating the relative direction your self with this snipped
private _relDir = (((player getDir target) - getDir player) + 360) % 360;
Event Timeline
@BIS_fnc_KK did you go into 3rd Person? I forgot to add that to the Repro steps. in 3rd person, I can to 100% reproduce it on 3 different PCs
Obviously I went into 3rd person. Are you using mods? What Arma 3 version you have. Is this MP, SP, or both?
I am Running Total Vanilla, Arma 3 Performance Profiling branch, and reproducible in SP and MP(i currently only tested locally hosted)
I noticed that a few positions do not trigger not that extreme effect. on Stratis laying on exactly that position [4444.16,6439.13,-0.000411987] you have the extreme angle, but a few steps back you don't have that issue
RPT:
I cannot reproduce the issue on the latest dev branch build. It is probably specific to the profiling branch.
Reproduced first try, not sure what the issue with reproing was.
Also as expected executing
JK_fnc_test = { player setVectorDirAndUp [vectorDir player, [0, 0, 1]]; };
Fixes the camera angle.
Oh wow thats a good bug.
Found the cause, wonder what else this has broken all over the place without being noticed...
For performance we cache some calculated data from the players position/orientation when its first requested.
And when you modify that position/orientation its supposed to delete the cached entries.
That reset was forgotten for setDirAndUp, so the cached values were considered "correct" even though they weren't after the direction was changed.