ZBrushCentral

Decimal points in ISliders and Variables

Hi

I am having trouble making my ISlider respect an increment value of .3, for example. When dragging the slider it will show all sorts of values but none of them are increments of .3. I cannot remember seeing this before. Any ideas?

My code:

[IShowActions, 0]
 [IConfig, 3.5]
 
 [ISlider, "My Value", 0, .3, -4, 4, "",
 
 , , 1]

My second problem has to do with the decimal point count of variables which to my knowledge are always assigned as floats, regardless of the values’ integer or real nature.

It seems there is just 5 decimal points of precision in the stored value. But calculated values display 6 points of precision (displayed in a note window or the notebar).

This causes problems as zspheres use 6 points of precision to describe size, position and rotation values. There does not seem to be a way to retain that precision if a scripted function needs to store those values.

A note window clearly shows 6 decimal points from a [Val,…] calculation with a 5 decimal point value(the max that is apparently allowed) so perhaps the radix is calculated incorrectly when storing 6 decimals points in a variable ?

Example code:

[IButton, "Test", ,
 [VarSet, decimals5, .00001]
 [VarSet, decimals6, .000001]
 [Note, [StrMerge, "5 decimals points reveals the 6th:   2*0.00001 = " , [Val, 2*decimals5], "
With 6 decimals it does not work:  2*0.000001 = ", [Val, 2*decimals6],  ]]
 ]

Hope someone can shed some light on this. I was thinking that perhaps bitshifting the zsphere values before storing them might work. But I am hoping I am just missing something obvious.

For what it is worth I tested both these problems on a 64bit and 32 bit machine, not that it should matter.

Thanks in advance.

Hello Mark,

For sliders, the increment can only be an integer. I don’t know why this has changed from earlier versions. (Though the bounds for your example should actually be -3.9 and 3.9, shouldn’t they? :wink: )

For your second problem, short answer: I don’t know. Longer answer, I imagine that ZBrush’s storing/handling of float values is not typical. In your example, if you change the value of the variable decimals6 to 0.000011 then you’ll get the correct answer.

Curiously, you’ll also get the right answer if the multiple is 20 instead of 2, so the correct value is being stored by decimals6. From my brief tests it seems that at some point decimal values <.00001 are rounded down to the nearest integer. This also goes for sliders in the UI - try entering a value in the Preferences>Utilities>Temp Value sliders.

HTH,

Thanks for the confirmation. Too bad. I suppose I could just use integer values and integer increments instead. Thanks.

-3.9 and 3.9? Why? Sometimes 3*11 = 40… especially after dinner and to much red wine :smiley:

It does seem like a .000001 value is stored except I could not assign it to a ZSphere. But that could be a different problem.

I noticed that entering .000001 into a slider will seemingly round down to 0. But if you then multiply the slider value by 10 you get .000010. So the slider values, like the variable values, are stored correctly up to the 6 decimal points of precision. They are just not displayed correctly, which is not so great, even if it is only the 6th decimal point.

[Note, [Val, 10*[IGet,“ZPlugin:3D Printing Exporter:Width”]]]