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
Zoom: Set zoom FOV per-player using a player object property #6650
Conversation
src/object_properties.cpp
Outdated
@@ -109,7 +109,7 @@ void ObjectProperties::serialize(std::ostream &os) const | |||
writeF1000(os, automatic_face_movement_max_rotation_per_sec); | |||
os << serializeString(infotext); | |||
os << serializeString(wield_item); | |||
writeU8(os, can_zoom); | |||
writeF1000(os, zoom_fov); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok to just change this and not move it? The comment for this section says to only add stuff to the bottom and not remove anything, but maybe that doesn't apply since we are breaking compatibility and 'can zoom' was added during 0.5.0dev.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause an offset in the ObjectProperties' network packet (before: 8 bits, now: 32 bits)
Yes, we are in backwards compat breakage but nevertheless you should either raise the version number here from 2 to 3 or deprecate this single byte.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raising version just for this seems excessive.
Maybe it's best to keep using 'can zoom' also.
By deprecation i assume you mean keep writing 'can zoom' but set it to a fixed bool and don't read it? I don't like the messiness of that.
src/script/common/c_content.cpp
Outdated
lua_pushboolean(L, prop->can_zoom); | ||
lua_setfield(L, -2, "can_zoom"); | ||
lua_pushnumber(L, prop->zoom_fov); | ||
lua_setfield(L, -2, "zoom_fov"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do, i always do docs last.
Not sure which of the 3 options to do: EDIT: I decided to raise version to 3. |
Both seems reasonable, given that you may want an on/off as well as a zoom
fov value. (Speaking of setting (zoom_)FOV during gameplay, is that
possible?)
…On Mon, Nov 20, 2017 at 10:21 PM, Paramat ***@***.***> wrote:
Not sure which of the 3 options to do:
Raise version 2>3.
Deprecate the byte (packets then have an unused byte).
Keep 'can zoom' and just add 'zoom fov'.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#6650 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AWXKYtLBHdcUQB2RAKnFIvlrv4pWqvydks5s4kHGgaJpZM4Qjp4l>
.
|
Updated with version raised to 3. |
Has a bug. I'm not actually changing |
Ok fixed, retested and docs added, ready for review. |
Tested with MTG PR. |
src/camera.cpp
Outdated
if (player->getPlayerControl().zoom && player->getCanZoom()) { | ||
fov_degrees = m_cache_zoom_fov; | ||
// Disable zoom with zoom FOV = 0 | ||
if (player->getPlayerControl().zoom && player->getZoomFOV() != 0.0f) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps change this to player->getZoomFOV() > 0.001f
for floating point errors and invalid input from Lua-side (as negative values sometimes disable other features)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea.
src/object_properties.h
Outdated
@@ -60,6 +59,7 @@ struct ObjectProperties | |||
std::string wield_item; | |||
bool static_save = true; | |||
float eye_height = 1.625f; | |||
float zoom_fov = 15.0f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means the server will force a zoom fov of 15 as soon the ObjectProperties are sent to the player. The client has no control about the limits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this struct does not set the defaults for properties, these values are overriden in content_sao, however currently to the wrong value (the server's zoom_fov setting).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But see my other line comments for a related problem.
Is the way i increased object property version correct? |
IRC:
|
Updated but more testing coming. |
src/content_sao.cpp
Outdated
m_hp = m_prop.hp_max; | ||
m_breath = m_prop.breath_max; | ||
// Allow the client to set a limited range of zoom FOV, a more powerful | ||
// zoom can only be set by server mods. | ||
m_prop.zoom_fov = rangelim(g_settings->getFloat("zoom_fov"), 15.0f, 160.0f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this, seems this will get the 'zoom_fov' of the server not the client.
My testing has been with 2 instances of MT, both with identical zoom_fov settings, which may have caused false testing results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem is, when any property is set, all of these are set, which will then override the client's 'zoom_fov' setting. I need to work on this.
bool getCanZoom() const { return m_can_zoom; } | ||
void setCanZoom(bool can_zoom) { m_can_zoom = can_zoom; } | ||
float getZoomFOV() const { return m_zoom_fov; } | ||
void setZoomFOV(float zoom_fov) { m_zoom_fov = zoom_fov; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i think this should only be changed if the value is being altered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No that won't work, the server has no idea what the client's local setting is.
This is getting more tricky the more i think about it. |
The client's local zoomFOV setting is the problem and has to be removed, unfortunately. All other object properties are not client-settable which is why they avoid the problems i'm encountering. |
Updated but in testing. |
Remove player object property 'can zoom'. Add player object property 'zoom fov'. Remove clientside setting for 'zoom fov'. Object property default is 15 degrees in creative mode, zoom disabled in survival mode. Needed due to zoom now loading and/or generating distant world according to zoom FOV. Update object properties serialisation version to 3.
Updated and tested, ready for merge. The client 'zoom fov' setting is removed. As zoom now loads and/or generated distant world beyond the server's send/generate distances, zoom FOV should be under server control (not client setting or CSM). |
-- ^ For players only. Zoom FOV in degrees. | ||
-- Note that zoom loads and/or generates world beyond the server's maximum | ||
-- send and generate distances, so acts like a telescope. | ||
-- Smaller zoomFOV values increase the distance loaded and/or generated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really necessary to provide this information, as people expect this to happen anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those used to MT don't expect it, so it's a warning about this powerful ability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, code and functionality-wise.
So in creative mode a "zoom-tool" can still override the default 15 degrees zoom FOV, right? |
Yes as in the binoculars mod:
|
Trying this a bit. I'm not a fan of not being to able to control the zoom in creative mode anymore (if just for testing higher zooms). In fact I think this should be a prominent config option (which can overridden by mods) |
You can set zoomFOV easily in creative with a 3 line mod. A tiny bit less convenient but no issue. You mean you prefer clientside control of zoomFOV in creative mode? If so i disagree with that due to the power zoom now has, it may be creative mode but i don't think clients can have that power clientside, after all it loads distant terrain and overrides the server's own send and generate distances. The server should obviously have control over it. It's like CSM, things that can significantly affect a server can't be clientside. Servers can use a mod that gives players the ability to choose their own zoomFOV, or can set any zoomFOV they want for creative. |
I see. Client can still set the FOV (though there's a lower limit of 30). It seems inconsistent not to be able to set the zoom fov. The fact that there's perhaps more server load is a but specious; that applies to the normal fov as well, which can be set to 180 degrees, which causes about 3x the server load. I get the point, though. In that case I would prefer that there be absolutely no zoom by default (i.e. unless granted by some mod in some way, such as now done in MT game). The hardcoded 15 is definitely arbitrary. |
I kept 15 for creative because that was the former default and i expected there would be complaints if it was disabled by default in creative, but i personally don't mind if it's disabled by default in creative mode. |
Zoom: Set zoom FOV per-player using a player object property
Remove player object property 'can zoom'.
Add player object property 'zoom fov'.
Remove clientside setting for 'zoom fov'.
Object property default is 15 degrees in creative mode, zoom disabled
in survival mode.
Needed due to zoom now loading and/or generating distant world
according to zoom FOV.
Update object properties serialisation version to 3.
///////////////
Merge minetest/minetest_game#1956 soon after this.
Together with lhofhansl's recent work this will allow a game to provide an item which enables a particular zoom FOV, which in turn allows a certain distance of world to be loaded in when using zoom.
For example a powerful telescope item that allows a zoom FOV of 1 degree, which is capable of loading (and/or generating) world 2000 nodes away.
A server mod can still disable zooming for a player by setting zoom FOV to 0. So the functionality of the previous 'can zoom' property is kept.