maruohon / minihud

A client-side Minecraft mod with configurable "info lines" ("mini-F3") and various overlays, such as light level and structure bounding boxes
GNU Lesser General Public License v3.0
419 stars 119 forks source link

Strange/incorrect sphere shapes #215

Open scrapmech opened 2 years ago

scrapmech commented 2 years ago

Minecraft version: 1.18.1 MiniHUD version: 0.21.3

When using Sphere block-based generator I noticed strange behavior: generated spheres are often not symmetrical, especially when using block snap corner or none options. Adjustable spawn sphere seems to produce better results.

Attached is an example for this behavior. You can see that on the right side there are several extra blocks.

2022-02-15_20 11 05 2022-02-15_20 11 13

maruohon commented 2 years ago

I believe the "normal" sphere uses the distance of the block center to the center point as the deciding criteria for which blocks to consider as the edge. So if the center of the circle is not centered on a block, then I guess it's entirely possible that it will not look symmetrical because the "unsymmetrical distances" on the opposing sides of the sphere result in different blocks being selected as the edge.

scrapmech commented 2 years ago

@maruohon The center of the sphere is exactly in the corner of a block though? The block centers of blocks that are symmetric are exactly the same distance from it. For example sphere with center at (0, 63, 0) and radius of 6. Two gold blocks whose centers are at (3.5, 66.5, 3.5) and (-3.5, 66.5, 3.5). The distance is sqrt((3.5^2)*3)=6.062177826. Left one is included in the sphere but right one is not

2022-02-16_03 17 21

maruohon commented 2 years ago

Yep that is certainly weird when the center is at the corner of the blocks. I haven't properly debugged this yet, but it might be a sort of directional preference in the way the code builds the "rings" by walking around the perimeter. Maybe it's not properly trying all the required sides when it comes to the points where the "outside direction vector" kinda changes. I'll need to take a proper look at it at some point soon.

HiggsBogan commented 2 years ago

I was building a 128 radius sphere before i updated and now it doesnt line up no matter what i do. I keep thinking maybe i stuffed it up but theres no way i made this many mistakes when you can clearly see mis-placed blocks :( 2022-03-05_06 14 38

maruohon commented 2 years ago

@HiggsBogan Is the center point, block snap setting and radius exactly the same as before? If you didn't use a block snap setting and you moved the center point even slightly, then it's possible that the positions changed like this. What version of the mod did you use before? If this was all in the 1.18+ versions, then I don't think I changed anything yet with the sphere stuff since the first "official" 1.18.0 release. I did rewrite some of the sphere stuff recently at one point, but I think it was leading up to the full 1.18.0 release.

I decided to leave the fixes this issue report is related to, to the bigger mod rewrites that are happening in 1.12.2, as I may need to or want to rewrite some more of how the shapes are generated, so I didn't want to delay the 1.18.2 updates further. So it's also possible that the sphere is just slightly crooked depending on the center point in relation to the block bounds (apparently). But even so it shouldn't change over time if the center and the settings remain the same.

HiggsBogan commented 2 years ago

not too long ago I messed up and deleted the sphere i was using. once i got it back to where it should be i took a screen shot of the coords and set up. the one above maybe off a bit because i was trying to get it right. just for you i re installed what i had before and set it to the settings in the screen shot i took for reference. heres that one 2022-03-05_06 47 46

As you can see give or take the few mis placed blocks everything is fine.

Its all good :) I can wait or if i need to i will roll back when i need too. just thought id show you that its a bit wonky.

Thanks for your response

Oh also yeh I was using 0.19.0 - dev20211204.230657

Firazoid commented 2 years ago

Has there been any update on this bug? I am encountering the same issue. It seems to me like the misshapen side is always on the west, regardless of any combination of settings. I notice the images provided by the OP also show errors on the west side only.

As is, I consider the sphere tool to be unusable.

Wolkenfarmer commented 2 years ago

Still present in 1.19.2.

Jescudie commented 11 months ago

Still present in 1.20.1.

obfuscoder commented 11 months ago

Before creating my issue, I failed to use the search function to figure out if this was already reported. I had the same issue wiuth spheres. It does not matter what snap method is used. The sphere is always asymetrical. Cylinders shapes ARE symetrical so my guess is that the function to calculate the points on the sphere is faulty (My guess is that the floating point arythmetic is incorrect. Ssome rounding issue? Using integers where floating/fixed point values ought to be used?)..

OldMensch commented 8 months ago

Still an issue in 1.20.4

Alexandre-LvLDesign commented 7 months ago

seriouslybro Still an issue in 1.20.4 ( 29/02/2024)

the bug is present since Feb 2022, I don't think it will be fix

CaduceusBasilisk commented 5 months ago

Still an issue in 1.20.4 (03/05/2024) IMG_5848

valve-developer commented 2 months ago

Untitled still present in 1.21

sakura-ryoko commented 2 months ago

I am aware of it, I just haven't had a chance to look at it yet (1.20.6/1.21)

AdielHub commented 2 months ago

I guess in the meantime the only fix is to make a cylinder with a radius of +1/-1 for each increment of y level

Very very very inconvenient but it's better than a wrong sphere

Maruohon, like, disable the sphere feature until it's fixed. The only thing worse than not having a sphere tool is having a sphere tool that you only realise hasn't worked properly until your minecraft project is done

Hlebuw3k commented 1 week ago

I built something with this, unaware that it was not correct. Please disable the feature until fixed.