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

make /mars_lightup more reliable #3

Merged
merged 1 commit into from
Feb 17, 2022
Merged

Conversation

SwissalpS
Copy link
Contributor

Sometimes nothing happens when standing at a certain pos. With rounded pos, standing at the same position it works perfectly.

e.g. standing at -2450.001953125 15005.5 1672.8519287109 doesn't work.
rounding coordinates results in: -2450 15006 1673 and lightup works fine.

Maybe this is cause for similar unreliable results in other functions that use VoxelManip()/core.get_voxel_manip()

Sometimes nothing happens when standing at a certain pos. With rounded pos, standing at the same position it works perfectly.
SwissalpS added a commit to pandorabox-io/spill_removal that referenced this pull request Feb 16, 2022
Did not test on this mod, but tested extensively on [plante_mars]'s /mars_lightup command.
pandorabox-io/planet_mars#3
@SwissalpS
Copy link
Contributor Author

SwissalpS commented Feb 16, 2022

possibly similar change could help:
woodcutting { seems safe }
jumpdrive.is_area_empty(), jumpdrive.move_mapdata(), jumpdrive.clear_area(), jumpdrive.fleet.find_engines() { is OK as it converts all coords to int first }
boost_cart:is_rail() { passes integer pos, so no problem here }
ropes.destroy_rope() { seems unafected, passes int in on normal usage }
find_nodes_in_area_cache.create_entry() { seems safe }
vacuum.flush_airpump() {unafected as sends pos from formspec}

-- I didn't check yet if these round beforehand, just keeping a pre-purged list. They don't all use the same method for retrieving index hash. Purge == leave out those instances where VoxelManip is only used to force-loald an area.

BuckarooBanzay pushed a commit to pandorabox-io/spill_removal that referenced this pull request Feb 17, 2022
Did not test on this mod, but tested extensively on [plante_mars]'s /mars_lightup command.
pandorabox-io/planet_mars#3
@BuckarooBanzay
Copy link
Contributor

you might be on to something: i had that issue a few times already in various other projects and just shrugged it off as a minetest-thing, but it looks like some of the engine-api surface doesn't like non-rounded floats (non-ints?) :/

@BuckarooBanzay BuckarooBanzay merged commit 20f7465 into master Feb 17, 2022
@BuckarooBanzay BuckarooBanzay added the bug Something isn't working label Feb 17, 2022
@SwissalpS SwissalpS deleted the SwissalpSpatchLightUp branch February 17, 2022 11:43
@SwissalpS
Copy link
Contributor Author

Yes, it may seem an engine issue on first sight. On second thought it makes sense to have mod developers round coordinates where there is no need for decimals.
There is no reason to have decimals when working on placed nodes and it's theoretically faster to calculate true ints over floats.
It also keeps pos_hash short and simple and avoids rounding errors in the process, which is possibly what is causing the issue.

@SwissalpS
Copy link
Contributor Author

from https://github.com/minetest/minetest/blob/5d0b18a0d0bd02a9b77b8948d6887bb661a385da/doc/lua_api.txt#L4330

x, y and z must be integers to avoid an incorrect index result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants