#Using a Camera.setRotation mixin to move the camera causes missing terrain

8 messages · Page 1 of 1 (latest)

median oxide
#

I'm making a mod that adds some abilities from the Super Mario games, one of which is the "Sideflip", which has the player flip over and turn around in midair. To handle the camera movement for this, I've set up a mixin to the Camera.setRotation method that lets me apply an offset to the player's pitch and yaw, and, very importantly, set camera roll.
However, I've noticed that when I swivel the camera around in this way, any terrain that's revealed by this motion will have large sections missing. Adjusting the camera manually by moving the mouse immediately fills in the missing terrain. I suspect that this is probably related to the game's frustum culling, right? It seems to me like when I do this, the game isn't entirely aware that I'm changing the camera angle, and so it doesn't recalculate what part of the world needs to be on screen.

Something that seems notable to me, though: When a Sideflip is executed, the player entity's yaw is immediately flipped 180 degrees, and a variable is set to trigger the mixin code to start adjusting the camera, to smoothly adjust it to this new rotation. As such, from the moment the Sideflip begins, the mixin is actually starting off with a massive camera offset, and then interpolates it all the way down to zero, to bring the camera angle in line with the player's true orientation (at which point the variable is changed back, so the mixin stops interfering with the camera at all).
So if the issue was that the game doesn't take the angles set by my mixin into account at all for frustum culling, I would expect that the effect would be that the instant the Sideflip starts, everything on-screen would be culled, and my mixin would swing the camera around to reveal fully visible terrain. But that's not what happens, so I'm not sure what to make of it.

Is there something I can do to fix this, or should I be taking some entirely different approach to do first-person camera animations? Any help would be appreciated!

runic stream
#

Be patient, rendering advice takes a minute on this server.

#

If you see a gap when someone is in #mod-dev-rendering it may be appropriate to make your case there

median oxide
#

Okie doke! Thanks for letting me know! 😁

#

Also, an additional note - by slowing the animation waaaay down and then moving the mouse during the animation, I can verify that the game does use my modified angles for culling, it just doesn't seem to realize the angle is changing? Unless I move my mouse to change it manually. So I think what I need is some way to tell the game to recalculate the culling?

runic stream
#

The rendering pros look to last have been on 8 hrs ago, so if your timezone allows it, that seems to be a good time to put it apon them

median oxide
#

OOOOOH I GOT IT! I figured it out! Yay! But also now it's a bit embarrassing that i asked and then like immediately found the solution kjdlbs oops,,,,,
Anyways it seems that WorldRenderer's scheduleTerrainUpdate method is exactly what I was looking for!! Triggering that each time I change the camera angle fixes this perfectly.