diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-09-18 14:11:41 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-09-18 16:55:41 +0300 |
commit | d0344d7b7d619e62bc852c4d00df52cfbfdda544 (patch) | |
tree | 713d7bfd2faa3d77ef1f67a8072abf8a05a29256 /source/blender/makesrna/intern/rna_mesh.c | |
parent | c4fc9c4a8ecc421fdbf1f5d06d3b67ac4c8c1895 (diff) |
Cleanup: use clamped rounding functions
Diffstat (limited to 'source/blender/makesrna/intern/rna_mesh.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index c25a70cea20..3d6dd9a5f35 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -304,7 +304,7 @@ static float rna_MeshVertex_bevel_weight_get(PointerRNA *ptr) static void rna_MeshVertex_bevel_weight_set(PointerRNA *ptr, float value) { MVert *mvert = (MVert *)ptr->data; - mvert->bweight = (char)(CLAMPIS(value * 255.0f, 0, 255)); + mvert->bweight = round_fl_to_uchar_clamp(value * 255.0f); } static float rna_MEdge_bevel_weight_get(PointerRNA *ptr) @@ -316,7 +316,7 @@ static float rna_MEdge_bevel_weight_get(PointerRNA *ptr) static void rna_MEdge_bevel_weight_set(PointerRNA *ptr, float value) { MEdge *medge = (MEdge *)ptr->data; - medge->bweight = (char)(CLAMPIS(value * 255.0f, 0, 255)); + medge->bweight = round_fl_to_uchar_clamp(value * 255.0f); } static float rna_MEdge_crease_get(PointerRNA *ptr) @@ -328,7 +328,7 @@ static float rna_MEdge_crease_get(PointerRNA *ptr) static void rna_MEdge_crease_set(PointerRNA *ptr, float value) { MEdge *medge = (MEdge *)ptr->data; - medge->crease = (char)(CLAMPIS(value * 255.0f, 0, 255)); + medge->crease = round_fl_to_uchar_clamp(value * 255.0f); } static void rna_MeshLoop_normal_get(PointerRNA *ptr, float *values) @@ -586,9 +586,9 @@ static void rna_MeshColor_color1_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[0].r)[2] = (char)(CLAMPIS(values[0] * 255.0f, 0, 255)); - (&mcol[0].r)[1] = (char)(CLAMPIS(values[1] * 255.0f, 0, 255)); - (&mcol[0].r)[0] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255)); + (&mcol[0].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); + (&mcol[0].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); + (&mcol[0].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); } static void rna_MeshColor_color2_get(PointerRNA *ptr, float *values) @@ -604,9 +604,9 @@ static void rna_MeshColor_color2_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[1].r)[2] = (char)(CLAMPIS(values[0] * 255.0f, 0, 255)); - (&mcol[1].r)[1] = (char)(CLAMPIS(values[1] * 255.0f, 0, 255)); - (&mcol[1].r)[0] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255)); + (&mcol[1].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); + (&mcol[1].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); + (&mcol[1].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); } static void rna_MeshColor_color3_get(PointerRNA *ptr, float *values) @@ -622,9 +622,9 @@ static void rna_MeshColor_color3_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[2].r)[2] = (char)(CLAMPIS(values[0] * 255.0f, 0, 255)); - (&mcol[2].r)[1] = (char)(CLAMPIS(values[1] * 255.0f, 0, 255)); - (&mcol[2].r)[0] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255)); + (&mcol[2].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); + (&mcol[2].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); + (&mcol[2].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); } static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values) @@ -640,9 +640,9 @@ static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&mcol[3].r)[2] = (char)(CLAMPIS(values[0] * 255.0f, 0, 255)); - (&mcol[3].r)[1] = (char)(CLAMPIS(values[1] * 255.0f, 0, 255)); - (&mcol[3].r)[0] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255)); + (&mcol[3].r)[2] = round_fl_to_uchar_clamp(values[0] * 255.0f); + (&mcol[3].r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); + (&mcol[3].r)[0] = round_fl_to_uchar_clamp(values[2] * 255.0f); } static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values) @@ -658,9 +658,9 @@ static void rna_MeshLoopColor_color_set(PointerRNA *ptr, const float *values) { MLoopCol *mcol = (MLoopCol *)ptr->data; - (&mcol->r)[0] = (char)(CLAMPIS(values[0] * 255.0f, 0, 255)); - (&mcol->r)[1] = (char)(CLAMPIS(values[1] * 255.0f, 0, 255)); - (&mcol->r)[2] = (char)(CLAMPIS(values[2] * 255.0f, 0, 255)); + (&mcol->r)[0] = round_fl_to_uchar_clamp(values[0] * 255.0f); + (&mcol->r)[1] = round_fl_to_uchar_clamp(values[1] * 255.0f); + (&mcol->r)[2] = round_fl_to_uchar_clamp(values[2] * 255.0f); } static int rna_Mesh_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info)) |