From f34e03d34d79785bdb4710b668b4cf803704c9a4 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 20 Nov 2017 10:12:21 +0100 Subject: Fix (unreported) Crash: broken RNA accessors to tesselated MCol data. Regression from rB823bcf1689a3 (VPaint 2017 GSoC, this is not in 2.79 release). Also cleanup, using fake-array-ification to access struct members is generally not a great idea, but when we already have a totally confusing broken struct layout, this is pure evil, as demonstrated here! Found while investigating T53341. --- release/scripts/addons | 2 +- source/blender/makesrna/intern/rna_mesh.c | 83 ++++++++++++++++--------------- source/tools | 2 +- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/release/scripts/addons b/release/scripts/addons index 5b02e6e1acc..85a2b50e0e3 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 5b02e6e1acc4c3cf4822607ab33f48d7cffecbd3 +Subproject commit 85a2b50e0e3d505f702a172efc0befa46e87d853 diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 41758758178..18fd4c64242 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -577,99 +577,100 @@ static void rna_MeshColor_color1_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[2] = (&mcol[0].r)[0] / 255.0f; - values[1] = (&mcol[0].r)[1] / 255.0f; - values[0] = (&mcol[0].r)[2] / 255.0f; + values[3] = mcol[0].a / 255.0f; + values[2] = mcol[0].r / 255.0f; + values[1] = mcol[0].g / 255.0f; + values[0] = mcol[0].b / 255.0f; } static void rna_MeshColor_color1_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&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); - (&mcol[0].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[0].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[0].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[0].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[0].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshColor_color2_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[3] = (&mcol[1].r)[3] / 255.0f; - values[2] = (&mcol[1].r)[0] / 255.0f; - values[1] = (&mcol[1].r)[1] / 255.0f; - values[0] = (&mcol[1].r)[2] / 255.0f; + values[3] = mcol[1].a / 255.0f; + values[2] = mcol[1].r / 255.0f; + values[1] = mcol[1].g / 255.0f; + values[0] = mcol[1].b / 255.0f; } static void rna_MeshColor_color2_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&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); - (&mcol[1].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[1].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[1].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[1].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[1].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshColor_color3_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[3] = (&mcol[2].r)[3] / 255.0f; - values[2] = (&mcol[2].r)[0] / 255.0f; - values[1] = (&mcol[2].r)[1] / 255.0f; - values[0] = (&mcol[2].r)[2] / 255.0f; + values[3] = mcol[2].a / 255.0f; + values[2] = mcol[2].r / 255.0f; + values[1] = mcol[2].g / 255.0f; + values[0] = mcol[2].b / 255.0f; } static void rna_MeshColor_color3_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&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); - (&mcol[2].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[2].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[2].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[2].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[2].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshColor_color4_get(PointerRNA *ptr, float *values) { MCol *mcol = (MCol *)ptr->data; - values[2] = (&mcol[3].r)[0] / 255.0f; - values[1] = (&mcol[3].r)[1] / 255.0f; - values[0] = (&mcol[3].r)[2] / 255.0f; - values[3] = (&mcol[3].r)[3] / 255.0f; + values[3] = mcol[3].a / 255.0f; + values[2] = mcol[3].r / 255.0f; + values[1] = mcol[3].g / 255.0f; + values[0] = mcol[3].b / 255.0f; } static void rna_MeshColor_color4_set(PointerRNA *ptr, const float *values) { MCol *mcol = (MCol *)ptr->data; - (&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); - (&mcol[3].r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[3].a = round_fl_to_uchar_clamp(values[3] * 255.0f); + mcol[3].r = round_fl_to_uchar_clamp(values[2] * 255.0f); + mcol[3].g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mcol[3].b = round_fl_to_uchar_clamp(values[0] * 255.0f); } static void rna_MeshLoopColor_color_get(PointerRNA *ptr, float *values) { - MLoopCol *mcol = (MLoopCol *)ptr->data; + MLoopCol *mlcol = (MLoopCol *)ptr->data; - values[0] = (&mcol->r)[0] / 255.0f; - values[1] = (&mcol->r)[1] / 255.0f; - values[2] = (&mcol->r)[2] / 255.0f; - values[3] = (&mcol->r)[3] / 255.0f; + values[0] = mlcol->r / 255.0f; + values[1] = mlcol->g / 255.0f; + values[2] = mlcol->b / 255.0f; + values[3] = mlcol->a / 255.0f; } static void rna_MeshLoopColor_color_set(PointerRNA *ptr, const float *values) { - MLoopCol *mcol = (MLoopCol *)ptr->data; + MLoopCol *mlcol = (MLoopCol *)ptr->data; - (&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); - (&mcol->r)[3] = round_fl_to_uchar_clamp(values[3] * 255.0f); + mlcol->r = round_fl_to_uchar_clamp(values[0] * 255.0f); + mlcol->g = round_fl_to_uchar_clamp(values[1] * 255.0f); + mlcol->b = round_fl_to_uchar_clamp(values[2] * 255.0f); + mlcol->a = round_fl_to_uchar_clamp(values[3] * 255.0f); } static int rna_Mesh_texspace_editable(PointerRNA *ptr, const char **UNUSED(r_info)) diff --git a/source/tools b/source/tools index 9ea62ef860c..e10a1b031b2 160000 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit 9ea62ef860cde8eb313b74cd1b23ca5a0734eefe +Subproject commit e10a1b031b243482371c0673ee17aa3c0f53637a -- cgit v1.2.3