Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Camera shifting Bug #250

Merged
merged 1 commit into from
Dec 6, 2015
Merged

Conversation

RichardlL
Copy link
Contributor

See Bug: #201

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

See Bug: PistonDevelopers#201

Fixed  Camera  X/Y changing when Pitch/Yaw is at Min and max
@bvssvni
Copy link
Member

bvssvni commented Dec 6, 2015

Thanks!

bvssvni added a commit that referenced this pull request Dec 6, 2015
@bvssvni bvssvni merged commit 0d2ffd1 into PistonDevelopers:master Dec 6, 2015
@bvssvni
Copy link
Member

bvssvni commented Dec 6, 2015

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

@RichardlL RichardlL deleted the patch-1 branch December 6, 2015 19:00
@toqueteos
Copy link
Contributor

Good catch!

@@ -215,7 +215,7 @@ fn main() {
xz_forward = vec3_normalized(xz_forward);
camera.position = vec3_add(
camera.position,
vec3_scale(xz_forward, 0.1)
vec3_scale(xz_forward, 0.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait... what?! Wouldn't this remove xz_forward's effect completely? Then you should've just removed the whole vec3_add.
But there must be a reason I did this... Maybe I found it in Minecraft's source, although I doubt that.

Oh, you know what it is? It's the distance from the center of the feet to the "eye sockets".
So, yeah, this is not fixing the bug, but rather removing a feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except it causes the bug because the camera height shouldn't be determined by camera/ movement (which is why the bug happens, but should happen here 211/212)

let mut camera = first_person.camera(0.0);
                camera.position[1] += 1.62;

but instead add it to 1.62 + players position

@RichardlL
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants