nipkownix / re4_tweaks

Fixes and tweaks for the "UHD" port of Resident Evil 4
zlib License
339 stars 33 forks source link

Freecam improvements #436

Open emoose opened 1 year ago

emoose commented 1 year ago

The freecam works pretty well, but could still use some improvements, right now it feels a little "floaty" for me, and also seems like the camera is still pivoting around something slightly in the distance, rather than being rotated directly by our inputs. (eg if you move camera next to corner of something, moving camera to point at the corner will actually move the camera itself around the corner, instead of just being rotated to look at it)

I noticed setting the STATUS flag STA_KLAUSER_TRANSFORM seems to help with the pivoting issue a little, but the floatiness seems like it might be worse with that (seems like it makes Y axis more sensitive than X or something like that...) - found that flag being checked inside CameraQuasiFPS::move, think that func is what handles the pivoting for the camera (looks like there's a few different modes available in there, but only mode 0 and 2 ever get used?)

The func that calls that (CameraControl::Move) also calls into CameraSmooth::move & CameraInterpolation::move, maybe those are responsible for making it feel floaty too, will need to look into these some more.

E: hmm, found that overwriting CamSmth.m_ratio_FC (bio4.exe+870180+FC float) to 0 gets rid of a lot of the floatiness, I think there's still some kind of acceleration applied there though. Can be applied while playing without freecam by also overwriting CamCtrl.m_QuasiFPS_278.m_walk_ratio_1B0 to 0 too (bio4.exe+8702D0+278+1B0 float), since game will overwrite the CamSmth value with that when walking.

Seems removing all the smoothing in-game makes the camera more "jerky" though, I guess since it's directly attached to character position, walking around means it jerks camera up/down a lot as the character climbs small hills etc, so I guess some smoothing is probably still needed in-game, for freecam I think it should be fine to remove though.

E: also, would it be possible for us to make pausing the player with SPF_PL optional? I tried using the freecam to check stuff for PlSetFace before but couldn't because of player being paused... seems the code is kinda relying on SPF_PL though, so not sure how possible this is.


E: btw, does anyone know if any other mods ever added a freecam mode? Companion maybe? or has @qingsheng8848 made something for it?

emoose commented 1 year ago

@nipkownix got some code setup to overwrite/restore CamSmth.m_ratio_FC when in freecam, could you give it a try with CE and see what you think of it first though? (E: or use #437 instead)

It feels a bit better without the smoothing, but also kinda feels like distant things have slightly jerky movement, not sure what's up with that... maybe I'm just seeing things though lol, I know in-game camera attached to chara definitely has jerky/sudden movements, but not completely sure about freecam. If there is still some weirdness with freecam maybe we can just try reducing the smoothing value instead of removing it entirely.

emoose commented 1 year ago

Setting g_transOfs[1].m_campos_0[0].x, g_transOfs[1].m_campos_0[0].z, g_transOfs[2].m_campos_0[0].x, g_transOfs[2].m_campos_0[0].z to 0 seems to help get rid of the X axis pivoting:

bio4.exe+7FB258+2C bio4.exe+7FB258+2C+8 bio4.exe+7FB258+2C+2C bio4.exe+7FB258+2C+2C+8

Haven't had any luck with the Y axis yet though, setting the Y values to 0 makes up/down rotation on mouse act weird, and seems to break movement somehow (feels like movement is still moving camera where it would have pointed before m_campos_0[0].y were overwritten, maybe there's a different value it's using for it...)

Camera movement is also a little weird even when we change just X & Z like above, seems like whatever Y axis is being used for movement is slightly off.

IIRC the GC debug build did have a debug camera function (which I think could rotate without needing to pivot fine), can't really remember how to activate that on GC though... if anyone knows more about it pls let me know

(GC debug also has a bunch of code for debugCamera class which sadly isn't included in UHD... quite a bit of code there, I think most of that is special debug cam stuff like jumping to/pivoting around different items etc, the main camera code is hopefully just a small part of it)

E: pushed a commit that helps improve the movement a little, that doesn't affect the pivoting/orbiting issue though, but maybe the improved movement can help us find a way to get rid of the Y axis pivot now...

linkthehylian commented 1 year ago

I think the GC debug camera is what Boundary Break used for their most recent video as well. It also allowed them to freely move the camera outside of being loaded into a level.

I love exploring the outer parts of this game a lot so any improvements will definitely help.

linkthehylian commented 1 year ago

Also @emoose, I noticed that when the free camera is enabled (using the build from https://github.com/nipkownix/re4_tweaks/pull/437) it immediately jolts down under Leon. Just curious if that's intentional because it didn't do that before.