PistonDevelopers / hematite

A simple Minecraft written in Rust with the Piston game engine
http://hematite.piston.rs/
MIT License
1.85k stars 105 forks source link

Fixed Camera shifting Bug #250

Closed RichardlL closed 8 years ago

RichardlL commented 8 years ago

See Bug: https://github.com/PistonDevelopers/hematite/issues/201

Fixed Camera X/Y changing when Pitch/Yaw is at Min and max

bvssvni commented 8 years ago

Thanks!

bvssvni commented 8 years ago

@RichardlL You can write "Closes " or "Fixes " in the commend and Github will automatically close the issue.

toqueteos commented 8 years ago

Good catch!

RichardlL commented 8 years ago

O.k. It looks like vec3_scales in piston are used for calculating angle for viewing sometime, respective of camera position . (Like if you had a moon and you always wanted the moons face looking at the earth) or vise versa.

In minecraft we don't use this, as camera angle isn't dependent on movement and movement isn't dependent on on camera angle

e.g. moving up-left and you still are looking forwards

We don't need this in minecraft, as camera is not dependent on movement

The camera's y should be set 1.62 above the players y position. (assuming that's its feet)

What makes it even more confusing is it seems x and y in piston for camera position, so @eddyb is right, the whole thing is unneeded.

**So what seems what was happening

  1. Camera X (relative, meaning the camera is moving forward) .01 * the yaw change of the camera
  2. It seems to be due to only happen near the axis's due to rounding,
  3. Changing the value from .1 to 5 confirms this, This effectively is making the player xy position move when the camera yaw and pitch moves, yet it does nothing, normally due to rounding, but occurs at extremes near the axis
  4. This is not intended behavior, as we are not orbiting anything

So put in layman's terms...

The camera is moving forwards when looking down, or backwards when looking up.

This is used in places with orbiting, such as 3rd person.

For first person, this shouldn't happen at all, since the players eyes are centered, and where not staring at something .1 meters in front of us.

If you change the value to 5 (from 0.1), it puts you in " third person", you're orbiting your players postion in 3rd person, and that eliminates the rounding problem.

This is how third person in minecraft works, as the camera is just orbiting 1.62 above your position instead of being 1.62 above your location, and your body is rendered too.

Changing this to 0.0 fixes the bug due to nullifying the effects entirely.

Deleting this doesn't remove the feature, it only removes the bug.

Camera XYY should be players X, Y+1.62 ,Z.

This doesn't do that, it makes the camera orbit something .1 meters away from the player