animate1978 / MB-Lab

MB-Lab is a character creation tool for Blender 4.0 and above, based off ManuelBastioniLAB
Other
1.83k stars 315 forks source link

Bug in Algorithms.py (function generate_parameter) and its commit #221

Closed TetoTheSquirrelFox closed 4 years ago

TetoTheSquirrelFox commented 4 years ago

Describe the bug In the function generate_parameter(val, random_value, preserve_phenotype=False)

I think that it is written wrong. We have this : image

I think that this is more correct (?): image

ldo commented 4 years ago

Don’t do screenshots of text. How do you expect anybody to copy and paste the text? Post the text itself.

TetoTheSquirrelFox commented 4 years ago

I did that because it's easier to read the differences, as the correction can be made in less than 1 minute if I'm correct ?

TetoTheSquirrelFox commented 4 years ago

OK, the commit, properly formatted :


def generate_parameter(val, random_value, preserve_phenotype=False):

    if preserve_phenotype:
        if val > 0.5:
            if val > 0.8:
                new_value = 0.8 + 0.2*random.random()
            else:
                new_value = 0.5+random.random()*random_value
        else:
            if val < 0.2:
                new_value = 0.2*random.random()
            else:
                new_value = 0.5-random.random()*random_value
    else:
        r = random.random()
        if r > 0.5:
            new_value = min(1.0, 0.5+r*random_value)
        else:
            new_value = max(0.0, 0.5-r*random_value)
    return new_value
animate1978 commented 4 years ago

Sorry for the delay.

Will change this code soon :)