-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Fix computation of view range (in blocks) sent to server #4882
Conversation
Can you elaborate? :) With wanted_range = 20, you'd get 19/17 now and 20/16 before, both would end up being 1. Does that fix the problem for you? I think there is another problem with the server only sending with 1 map block send distance. I had thought the fix is to send at least with a map block radius of 2. |
Yes, the bug is fixed. |
@est31 It does fix the issue I am seeing, and which I think is the bug @juhdanad reported. With wanted_range_nodes = 20: Basically, I changed the formula from: Maybe I should add some more clarification... |
@@ -939,7 +939,7 @@ void writePlayerPos(LocalPlayer *myplayer, ClientMap *clientMap, NetworkPacket * | |||
u32 keyPressed = myplayer->keyPressed; | |||
// scaled by 80, so that pi can fit into a u8 | |||
u8 fov = clientMap->getCameraFov() * 80; | |||
u8 wanted_range = clientMap->getControl().wanted_range / MAP_BLOCKSIZE; | |||
u8 wanted_range = (clientMap->getControl().wanted_range - 1) / MAP_BLOCKSIZE + 1; |
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.
don't we have a ceil()
function for this?
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.
There is double ceil(double)
. But then there'd be a useless conversion to floating point and back. Whereas integer arithmetic does the job. I am not aware of any int ceilDiv(int, int)
or so.
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.
I just noticed that wanted_range is in fact already a float. I assumed it was integral...
Changed to ceil().
Oh. I see. Of course. 👍 |
Now we can also change this, perhaps to 0.95. Or get rid of the factor altogether. |
Won't 1.0 work ? IIRC the fog formula reaches 100% fog before it reaches the max viewing range. So there should be no need to artificially reduce the viewing range. Edit: tested 1.0, and the results seem good with viewing ranges of 20 and 30. In both cases, nodes that are at |
Yeah. 1.0 works. I was wondering why that was still needed. You found the answer. @paramat would like that too :) |
Cool. This all is coming together nicely. This is a great community. |
Well... I've already got the code. Just need to commit and push... Edit: pushed. |
@Rogier-5 I meant removing the 0.9 fog range factor as part of this PR. |
Ah. You did already. Cool. |
Fixes minetest#4878 Also remove an artificial viewing range reduction that (presumably) was added to compensate for miscomputed viewing ranges, and that doesn't seem to be needed any more (thanks to lhofhansl).
@@ -4214,7 +4214,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, | |||
if (draw_control->range_all) { | |||
runData->fog_range = 100000 * BS; | |||
} else { | |||
runData->fog_range = 0.9 * draw_control->wanted_range * BS; | |||
runData->fog_range = draw_control->wanted_range * BS; |
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.
I'm unsure about this, the 'wanted range' here is surely a different local value in the client? the 'ceil(wanted range)' is only sent to the server?
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.
There's a high chance i'm wrong though.
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.
Oops i misunderstood, this is fine.
Tested this. I have not been able to produce any visible edges at any view range. We discussed this on #4811, there I said I can see edges when this removed. Turns out that was due to me sending inadvertently floor of view-range / MAP_BLOCKSIZE. Due to that we'd retrieve sightly less on terms of range. I remember I was wondering back then; now I have an explanation. :) |
Will test. |
Works 👍 |
👍 |
Fixes #4878