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

Expose player FOV to Lua API #7557

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
9 participants
@ClobberXD
Copy link
Contributor

ClobberXD commented Jul 15, 2018

This PR aims to make the zoom feature more generic by allowing mods to individually override player FOVs with arbitrary values. Once this is merged, I'll work on making builtin zoom use these methods instead. Here are the changes:

  • Add Lua API methods ObjectRef::set_fov(), ObjectRef::get_fov().
    • Passing 0 to set_fov will clear FOV overrides
  • Add Player::m_fov.
    • Implement getters and setters separately in LocalPlayer and RemotePlayer.
  • Implement server->client FOV sending using a new packet TOCLIENT_FOV.
  • If m_fov equals 0 (i.e. player's FOV not overridden by a mod), player's default FOV (from minetest.conf) is taken, which is the default behaviour.
  • If m_fov does not equal 0 (i.e. mod enforces FOV), client uses m_fov.

Here's a mod to test out the new Lua API methods: fov_test

@ClobberXD ClobberXD force-pushed the ClobberXD:lua_fov branch from 1c67a1e to 672d65f Jul 15, 2018

@lhofhansl

This comment has been minimized.

Copy link
Contributor

lhofhansl commented Jul 15, 2018

How should be integrate this best with the zoom stuff?
Perhaps we simply allow to set the fov, and zoom is just a boolean controlling whether the server is allow to retrieve more distant blocks...?

@paramat FYI

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Jul 15, 2018

That sounds like a good idea, since there are situations where only the fov change is required, and loading distant blocks is unnecessary...

@paramat

This comment has been minimized.

Copy link
Member

paramat commented Jul 15, 2018

That sounds like a good idea, since there are situations where only the fov change is required, and loading distant blocks is unnecessary...

I agree, you may want to set a very narrow FOV for an effect but not want world 2000 nodes away being generated and/or loaded.

@TMcSquared

This comment has been minimized.

Copy link

TMcSquared commented Jul 16, 2018

I just had a thought, someone could use this feature to animate the FOV for a nausea-type effect

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Jul 16, 2018

Just a gentle reminder: The PR is still WIP since the documentation hasn't been updated yet, but the actual code is complete. I can start working on the documentation only when the code has been approved, and nothing needs to be majorly modified. :)

@rubenwardy rubenwardy changed the title [WIP] Expose player FOV to Lua API Expose player FOV to Lua API Jul 16, 2018

@ClobberXD ClobberXD force-pushed the ClobberXD:lua_fov branch from 672d65f to d211afa Jul 25, 2018

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Aug 4, 2018

Has anyone reviewed this PR yet? Is there anything that needs to be changed in a major way? I'll start adding the documentation now; if something needs change, will update the relevant docs accordingly...

@ClobberXD ClobberXD force-pushed the ClobberXD:lua_fov branch from e965c60 to 84c12c2 Aug 4, 2018

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Aug 4, 2018

Updated lua_api.txt, but I'm still not sure about whether or not to bump the latest protocol version. I'm sure the minimum version needn't be bumped since only new packets have been added, preserving backwards compat. with version 36.

@SmallJoker
Copy link
Member

SmallJoker left a comment

Couldn't this be just like the physics modifiers, so that the FOV is changed by a factor instead of overwriting the client's settings?

Show resolved Hide resolved doc/lua_api.txt Outdated
Show resolved Hide resolved src/camera.cpp Outdated
Show resolved Hide resolved src/client.h Outdated
Show resolved Hide resolved src/network/clientopcodes.cpp Outdated
Show resolved Hide resolved src/network/clientpackethandler.cpp Outdated
Show resolved Hide resolved src/network/serveropcodes.cpp Outdated
Show resolved Hide resolved src/network/serveropcodes.cpp Outdated
Show resolved Hide resolved src/remoteplayer.h
Show resolved Hide resolved src/script/lua_api/l_object.cpp Outdated
Show resolved Hide resolved src/script/lua_api/l_object.cpp Outdated
@paramat

This comment has been minimized.

Copy link
Member

paramat commented Aug 6, 2018

Where is the option for controlling distant-world loading caused by zoom?

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Aug 7, 2018

@paramat This does not cause distant-world loading at all. Only the FOV is changed. Should this behaviour be changed? If yes, how?

@ClobberXD ClobberXD force-pushed the ClobberXD:lua_fov branch from 6b76c24 to 458fb8e Aug 7, 2018

@paramat

This comment has been minimized.

Copy link
Member

paramat commented Aug 7, 2018

Ok i see. It's ok then. I see no need for this to cause distant world loading.

@SmallJoker
Copy link
Member

SmallJoker left a comment

Contains a bit too many irrelevant changes for my taste. Also needs some changes.

Show resolved Hide resolved src/remoteplayer.h Outdated
Show resolved Hide resolved src/script/lua_api/l_object.cpp Outdated
Show resolved Hide resolved src/script/lua_api/l_object.cpp Outdated
Show resolved Hide resolved src/server.cpp Outdated

@ClobberXD ClobberXD force-pushed the ClobberXD:lua_fov branch from a4ceb26 to 2935602 Aug 17, 2018

@ClobberXD ClobberXD force-pushed the ClobberXD:lua_fov branch 3 times, most recently from e939669 to 9d6aff3 Aug 17, 2018

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Aug 17, 2018

Addressed comments; rebased. What would be the future of zoom, keeping in mind this feature?

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Sep 30, 2018

Keeping in mind the recent discussions about Degrees vs Radians, I suggest this stays as-is, since unlike vectors and rotations, degrees is the most natural way to express FOV.

@paramat

This comment has been minimized.

Copy link
Member

paramat commented Sep 30, 2018

Yes i agree with degrees for this, zoom FOV and zoom settings are also degrees.

@Wuzzy2

This comment has been minimized.

Copy link
Contributor

Wuzzy2 commented Oct 14, 2018

I don't get this PR. This would mean that FOV is no longer a client setting, only the server is supposed to get control over your FOV?

Also, this would be useless if someone use a hacked, err, modified client to set whatever FOV they like. :D

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Oct 15, 2018

Using the provided API methods, mods would be able to override client's FOV (set by the client itself). Passing a value of 0 to set_fov would nullify the override, and the FOV is reset to client's original value

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Nov 26, 2018

@SmallJoker You have done some considerable amount of reviewing to this PR. Would you like to suggest any more changes/improvements?

@ClobberXD ClobberXD force-pushed the ClobberXD:lua_fov branch from 5d6e737 to fa468a1 Dec 3, 2018

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Dec 3, 2018

Rebased :)

@SmallJoker: Note that the (var == 0) --> (!var), incorrect pointer placements, and other such code-style issues exist throughout the touched file(s), and you asked me to fix them in a later PR.

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Dec 7, 2018

#5797 would be the best solution, but considering that the feature would need SSCSM to actually be useful... Hm, looks like the need for server-sent FOV has already been expressed here #5797 (comment)

To clarify, this won't add to lag in any significant way, as the server only sends TOCLIENT_FOV once, every time the FOV needs to be changed. It isn't advisable to use this within a globalstep.

The feature freeze for 5.0.0 seems to be nearing. @SmallJoker you had expressed that a couple of codestyle issues required attention, which I clarified in my previous comment. Would you like anything else to be changed to make this PR merge-worthy? Should we discuss on overrides vs modifiers for player FOV? Unlike player physics, using modifiers here doesn't seem to be a good idea.

EDIT: Rebased

@ClobberXD ClobberXD force-pushed the ClobberXD:lua_fov branch from fa468a1 to 8d36899 Dec 7, 2018

@paramat

This comment has been minimized.

Copy link
Member

paramat commented Dec 8, 2018

using modifiers here doesn't seem to be a good idea.

Agreed, combinable modifiers would be silly.

@SmallJoker
Copy link
Member

SmallJoker left a comment

Possibly missed message. PRs ought to gradually improve the code style of each file over time. In this case it would've been nice to have correctly formatted code - but if you're going to fix the file in a future PR that's acceptable too.

Tested. Works.

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Dec 8, 2018

I did see that message, and I thought I'll fix it in a follow-up PR which would just fix code-style in a couple of files. But I understand that the touched code should follow the correct code-style, even if the rest of the file currently doesn't. Thanks for pointing that out :)

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Dec 8, 2018

@SmallJoker Fixed code-style, only in the touched code. Thanks for the approval.

Show resolved Hide resolved doc/lua_api.txt Outdated

@ClobberXD ClobberXD force-pushed the ClobberXD:lua_fov branch from a1eeb9a to 3590f6f Dec 9, 2018

@ClobberXD

This comment has been minimized.

Copy link
Contributor Author

ClobberXD commented Dec 9, 2018

Fixed pointer placement in client.h, improved get_fov documentation, and squashed.

@nerzhul nerzhul added this to the 5.1.0 milestone Dec 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.