From 7add6b89bc25a59490f93cad44dfe2887c8006c8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 23 May 2017 10:34:03 +0200 Subject: Fix T51592: Simplify AO Cycles setting remains active while Simplify is disabled --- source/blender/makesrna/intern/rna_scene.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 333833a79eb..20c3ab89b8e 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1816,7 +1816,7 @@ static void object_simplify_update(Object *ob) } } -static void rna_Scene_use_simplify_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Scene_use_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr) { Scene *sce = ptr->id.data; Scene *sce_iter; @@ -1827,6 +1827,7 @@ static void rna_Scene_use_simplify_update(Main *bmain, Scene *UNUSED(scene), Poi object_simplify_update(base->object); WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); + DAG_id_tag_update(&scene->id, 0); } static void rna_Scene_simplify_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) -- cgit v1.2.3 From 8d26f2c2228f0553972c0c3419bd570d02312780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 23 May 2017 12:29:58 +0200 Subject: Fix T51319: Alembic export crash w/simple child particles if Display value < 100% This was two-fold. 1) The export used viewport settings to obtain the particle cache, rather than render settings. 2) The child hair writer tried to obtain UV-coordinates from the parent chair, without checking whether those were available in the first place. --- source/blender/alembic/intern/abc_hair.cc | 56 ++++++++++++++----------------- 1 file changed, 25 insertions(+), 31 deletions(-) (limited to 'source/blender') diff --git a/source/blender/alembic/intern/abc_hair.cc b/source/blender/alembic/intern/abc_hair.cc index 2d42c532c9b..8f8ed2019d5 100644 --- a/source/blender/alembic/intern/abc_hair.cc +++ b/source/blender/alembic/intern/abc_hair.cc @@ -76,7 +76,7 @@ void AbcHairWriter::do_write() return; } - DerivedMesh *dm = mesh_create_derived_view(m_scene, m_object, CD_MASK_MESH); + DerivedMesh *dm = mesh_create_derived_render(m_scene, m_object, CD_MASK_MESH); DM_ensure_tessface(dm); std::vector verts; @@ -251,44 +251,38 @@ void AbcHairWriter::write_hair_child_sample(DerivedMesh *dm, for (int p = 0; p < m_psys->totchild; ++p, ++pc) { path = cache[p]; - if (part->from == PART_FROM_FACE) { - if (part->childtype == PART_CHILD_PARTICLES || !mtface) { - /* Face index is unknown for these particles, so just take info - * from the parent. */ - uv_values.push_back(uv_values[pc->parent]); - norm_values.push_back(norm_values[pc->parent]); + if (part->from == PART_FROM_FACE && + part->childtype != PART_CHILD_PARTICLES && + mtface) { + const int num = pc->num; + if (num < 0) { + ABC_LOG(m_settings.logger) + << "Warning, child particle of hair system " << m_psys->name + << " has unknown face index of geometry of "<< (m_object->id.name + 2) + << ", skipping child hair." << std::endl; + continue; } - else { - const int num = pc->num; - if (num < 0) { - ABC_LOG(m_settings.logger) - << "Warning, child particle of hair system " << m_psys->name - << " has unknown face index of geometry of "<< (m_object->id.name + 2) - << ", skipping child hair." << std::endl; - continue; - } - MFace *face = static_cast(dm->getTessFaceData(dm, num, CD_MFACE)); - MTFace *tface = mtface + num; + MFace *face = static_cast(dm->getTessFaceData(dm, num, CD_MFACE)); + MTFace *tface = mtface + num; - float r_uv[2], tmpnor[3], mapfw[4], vec[3]; + float r_uv[2], tmpnor[3], mapfw[4], vec[3]; - psys_interpolate_uvs(tface, face->v4, pc->fuv, r_uv); - uv_values.push_back(Imath::V2f(r_uv[0], r_uv[1])); + psys_interpolate_uvs(tface, face->v4, pc->fuv, r_uv); + uv_values.push_back(Imath::V2f(r_uv[0], r_uv[1])); - psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, tmpnor, NULL, NULL, NULL, NULL); + psys_interpolate_face(mverts, face, tface, NULL, mapfw, vec, tmpnor, NULL, NULL, NULL, NULL); - /* Convert Z-up to Y-up. */ - norm_values.push_back(Imath::V3f(tmpnor[0], tmpnor[2], -tmpnor[1])); - } + /* Convert Z-up to Y-up. */ + norm_values.push_back(Imath::V3f(tmpnor[0], tmpnor[2], -tmpnor[1])); } else { - ABC_LOG(m_settings.logger) - << "Unknown particle type " << part->from - << " for child hair of system " << m_psys->name - << std::endl; - uv_values.push_back(uv_values[pc->parent]); - norm_values.push_back(norm_values[pc->parent]); + if (uv_values.size()) { + uv_values.push_back(uv_values[pc->parent]); + } + if (norm_values.size()) { + norm_values.push_back(norm_values[pc->parent]); + } } int steps = path->segments + 1; -- cgit v1.2.3 From 72d67ba4c24d4d86c30061a7c2ad3f29c2550529 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 23 May 2017 12:40:12 +0200 Subject: Make msvc2015 happy again. Looks like that wanabe compiler does not support more than a few tens of if/else conditions... --- .../blender/editors/space_text/text_format_pov.c | 58 ++++++++++++++-------- 1 file changed, 37 insertions(+), 21 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c index ed915d6b72c..caf062c1e76 100644 --- a/source/blender/editors/space_text/text_format_pov.c +++ b/source/blender/editors/space_text/text_format_pov.c @@ -85,26 +85,15 @@ static int txtfmt_pov_find_keyword(const char *string) return (i == 0 || text_check_identifier(string[i])) ? -1 : i; } -static int txtfmt_pov_find_reserved(const char *string) +static int txtfmt_pov_find_reserved_keywords(const char *string) { int i, len; /* POV-Ray Built-in Variables * list is from... * http://www.povray.org/documentation/view/3.7.0/212/ */ - if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len; /* Language Keywords */ - else if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) i = len; + if (STR_LITERAL_STARTSWITH(string, "aa_level", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "aa_threshold", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "absorption", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len; @@ -270,6 +259,32 @@ static int txtfmt_pov_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "vertex_vectors", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "water_level", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "width", len)) i = len; + + else i = 0; + + /* If next source char is an identifier (eg. 'i' in "definate") no match */ + return (i == 0 || text_check_identifier(string[i])) ? -1 : i; +} + + +static int txtfmt_pov_find_reserved_builtins(const char *string) +{ + int i, len; + /* POV-Ray Built-in Variables + * list is from... + * http://www.povray.org/documentation/view/3.7.0/212/ + */ + if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "initial_clock", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "initial_frame", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len; /* Built-in Vectors */ else if (STR_LITERAL_STARTSWITH(string, "t", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "u", len)) i = len; @@ -432,7 +447,6 @@ static int txtfmt_pov_find_reserved(const char *string) } - /* Checks the specified source string for a POV modifiers. This * name must start at the beginning of the source string and must be followed * by a non-identifier (see text_check_identifier(char)) or null character. @@ -624,10 +638,11 @@ static int txtfmt_pov_find_bool(const char *string) static char txtfmt_pov_format_identifier(const char *str) { char fmt; - if ((txtfmt_pov_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL; - else if ((txtfmt_pov_find_keyword(str)) != -1) fmt = FMT_TYPE_KEYWORD; - else if ((txtfmt_pov_find_reserved(str)) != -1) fmt = FMT_TYPE_RESERVED; - else fmt = FMT_TYPE_DEFAULT; + if ((txtfmt_pov_find_specialvar(str)) != -1) fmt = FMT_TYPE_SPECIAL; + else if ((txtfmt_pov_find_keyword(str)) != -1) fmt = FMT_TYPE_KEYWORD; + else if ((txtfmt_pov_find_reserved_keywords(str)) != -1) fmt = FMT_TYPE_RESERVED; + else if ((txtfmt_pov_find_reserved_builtins(str)) != -1) fmt = FMT_TYPE_RESERVED; + else fmt = FMT_TYPE_DEFAULT; return fmt; } @@ -748,9 +763,10 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_ else { /* Special vars(v) or built-in keywords(b) */ /* keep in sync with 'txtfmt_pov_format_identifier()' */ - if ((i = txtfmt_pov_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL; - else if ((i = txtfmt_pov_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD; - else if ((i = txtfmt_pov_find_reserved(str)) != -1) prev = FMT_TYPE_RESERVED; + if ((i = txtfmt_pov_find_specialvar(str)) != -1) prev = FMT_TYPE_SPECIAL; + else if ((i = txtfmt_pov_find_keyword(str)) != -1) prev = FMT_TYPE_KEYWORD; + else if ((i = txtfmt_pov_find_reserved_keywords(str)) != -1) prev = FMT_TYPE_RESERVED; + else if ((i = txtfmt_pov_find_reserved_builtins(str)) != -1) prev = FMT_TYPE_RESERVED; if (i > 0) { text_format_fill_ascii(&str, &fmt, prev, i); -- cgit v1.2.3 From 49cc78ef1818eaff3db722683d155d3466d35e82 Mon Sep 17 00:00:00 2001 From: Howard Trickey Date: Tue, 23 May 2017 07:55:14 -0400 Subject: Fix T48668, bevel mistake on presumed reflex angle. Note: the angle in bug isn't really reflex - using the vertex normal for this test isn't always right, but usually is. At any rate, shouldn't try to put vertex on edge between if a reflex angle. --- source/blender/bmesh/tools/bmesh_bevel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index a05c12a2730..5f4ed3db261 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -916,8 +916,12 @@ static bool offset_meet_edge(EdgeHalf *e1, EdgeHalf *e2, BMVert *v, float meetc return false; } cross_v3_v3v3(fno, dir1, dir2); - if (dot_v3v3(fno, v->no) < 0.0f) + if (dot_v3v3(fno, v->no) < 0.0f) { ang = 2.0f * (float)M_PI - ang; /* angle is reflex */ + if (r_angle) + *r_angle = ang; + return false; + } if (r_angle) *r_angle = ang; -- cgit v1.2.3 From 116e8933a64fe5c0274cf17dd6e0f06df3ba4210 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 23 May 2017 16:41:48 +0200 Subject: Fix some POV keywords not colored correctly. We need to ensure longer keywords are catched first, when there are shorter subsets of them in keywords list as well! --- .../blender/editors/space_text/text_format_pov.c | 117 +++++++++++---------- .../editors/space_text/text_format_pov_ini.c | 20 ++-- 2 files changed, 68 insertions(+), 69 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c index caf062c1e76..eb6877d297d 100644 --- a/source/blender/editors/space_text/text_format_pov.c +++ b/source/blender/editors/space_text/text_format_pov.c @@ -56,16 +56,16 @@ static int txtfmt_pov_find_keyword(const char *string) else if (STR_LITERAL_STARTSWITH(string, "declare", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "macro", len)) i = len; @@ -99,13 +99,13 @@ static int txtfmt_pov_find_reserved_keywords(const char *string) else if (STR_LITERAL_STARTSWITH(string, "accuracy", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "adc_bailout", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "albedo", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "all", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "all_intersections", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "all", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "alpha", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "altitude", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "always_sample", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "ambient", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ambient_light", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "ambient", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "angle", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "aperture", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "arc_angle", len)) i = len; @@ -133,8 +133,8 @@ static int txtfmt_pov_find_reserved_keywords(const char *string) else if (STR_LITERAL_STARTSWITH(string, "cutaway_textures", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "diffuse", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "direction", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "dispersion", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "dispersion_samples", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "dispersion", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "dist_exp", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "distance", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "eccentricity", len)) i = len; @@ -146,8 +146,8 @@ static int txtfmt_pov_find_reserved_keywords(const char *string) else if (STR_LITERAL_STARTSWITH(string, "exterior", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "extinction", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "face_indices", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "falloff_angle", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "falloff", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "file_gamma", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "finish", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "flatness", len)) i = len; @@ -171,8 +171,8 @@ static int txtfmt_pov_find_reserved_keywords(const char *string) else if (STR_LITERAL_STARTSWITH(string, "internal", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "intervals", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ior", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "irid", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "irid_wavelength", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "irid", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "load_file", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "location", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "look_at", len)) i = len; @@ -185,8 +185,8 @@ static int txtfmt_pov_find_reserved_keywords(const char *string) else if (STR_LITERAL_STARTSWITH(string, "max_intersections", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "max_iteration", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "max_sample", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "max_trace", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "max_trace_level", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "max_trace", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "maximum_reuse", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "metallic", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "method", len)) i = len; @@ -202,8 +202,8 @@ static int txtfmt_pov_find_reserved_keywords(const char *string) else if (STR_LITERAL_STARTSWITH(string, "orientation", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "pass_through", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "pattern", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "phong", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "phong_size", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "phong", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "point_at", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "pot", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "precision", len)) i = len; @@ -218,8 +218,8 @@ static int txtfmt_pov_find_reserved_keywords(const char *string) else if (STR_LITERAL_STARTSWITH(string, "ratio", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "reciprocal", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "recursion_limit", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "reflection", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "reflection_exponent", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "reflection", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "refraction", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "repeat", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "right", len)) i = len; @@ -270,12 +270,13 @@ static int txtfmt_pov_find_reserved_keywords(const char *string) static int txtfmt_pov_find_reserved_builtins(const char *string) { int i, len; + /* POV-Ray Built-in Variables * list is from... * http://www.povray.org/documentation/view/3.7.0/212/ */ - if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len; + if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len; @@ -285,28 +286,21 @@ static int txtfmt_pov_find_reserved_builtins(const char *string) else if (STR_LITERAL_STARTSWITH(string, "image_height", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "image_width", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "input_file_name", len)) i = len; - /* Built-in Vectors */ - else if (STR_LITERAL_STARTSWITH(string, "t", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "u", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "v", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "x", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "y", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "z", len)) i = len; /* Color Identifiers */ else if (STR_LITERAL_STARTSWITH(string, "blue", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "filter", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "gray", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "green", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "red", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "rgb", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "rgbf", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "rgbft", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "rgbf", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "rgbt", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "rgb", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "srgb", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "sRGB", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "SRGB", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "srgbf", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "srgbft", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "srgbf", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "srgbt", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "transmit", len)) i = len; /* Patterns */ @@ -374,8 +368,8 @@ static int txtfmt_pov_find_reserved_builtins(const char *string) else if (STR_LITERAL_STARTSWITH(string, "light_group", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "light_source", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "merge", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "mesh", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "mesh2", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "mesh", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "object", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ovus", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "parametric", len)) i = len; @@ -389,8 +383,8 @@ static int txtfmt_pov_find_reserved_builtins(const char *string) else if (STR_LITERAL_STARTSWITH(string, "rainbow", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "sky_sphere", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "smooth_triangle", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sphere", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "sphere_sweep", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sphere", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "spline", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "superellipsoid", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "sor", len)) i = len; @@ -439,6 +433,13 @@ static int txtfmt_pov_find_reserved_builtins(const char *string) else if (STR_LITERAL_STARTSWITH(string, "panoramic", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "perspective", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ultra_wide_angle", len)) i = len; + /* Built-in Vectors */ + else if (STR_LITERAL_STARTSWITH(string, "t", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "u", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "v", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "x", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "y", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "z", len)) i = len; else i = 0; @@ -471,15 +472,15 @@ static int txtfmt_pov_find_specialvar(const char *string) else if (STR_LITERAL_STARTSWITH(string, "circular", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "clipped_by", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "cubic", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "color", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "color_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "colour", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "color", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "colour_map", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "colour", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "control0", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "control1", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "cubic_wave", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "density", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "density_map", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "density", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "double_illuminate", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fade_color", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fade_colour", len)) i = len; @@ -489,15 +490,15 @@ static int txtfmt_pov_find_specialvar(const char *string) else if (STR_LITERAL_STARTSWITH(string, "global_lights", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "hollow", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "image_map", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "interior", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "interior_texture", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "interior", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "interpolate", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "inverse", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "jitter", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "lambda", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "map_type", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "material", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "material_map", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "material", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "matrix", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "media", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "media_attenuation", len)) i = len; @@ -510,8 +511,8 @@ static int txtfmt_pov_find_specialvar(const char *string) else if (STR_LITERAL_STARTSWITH(string, "no_reflection", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "no_shadow", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "noise_generator", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "normal", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "normal_map", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "normal", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "octaves", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "omega", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "once", len)) i = len; @@ -519,8 +520,8 @@ static int txtfmt_pov_find_specialvar(const char *string) else if (STR_LITERAL_STARTSWITH(string, "parallel", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "phase", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "photons", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "pigment", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "pigment_map", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "pigment", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "poly_wave", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "projected_through", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "quick_color", len)) i = len; @@ -533,8 +534,8 @@ static int txtfmt_pov_find_specialvar(const char *string) else if (STR_LITERAL_STARTSWITH(string, "sine_wave", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "slope_map", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "subsurface", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "texture", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "texture_map", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "texture", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "transform", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "translate", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "triangle_wave", len)) i = len; @@ -545,23 +546,41 @@ static int txtfmt_pov_find_specialvar(const char *string) else if (STR_LITERAL_STARTSWITH(string, "uv_mapping", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "warp", len)) i = len; + /* Vector Functions */ + else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "min_extent", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "trace", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vaxis_rotate", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vcross", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vnormalize", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vrotate", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vturbulence", len)) i = len; + /* String Functions */ + else if (STR_LITERAL_STARTSWITH(string, "chr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "concat", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "datetime", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "str", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "strlwr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "strupr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "substr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "vstr", len)) i = len; /* Float Functions */ else if (STR_LITERAL_STARTSWITH(string, "abs", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "acos", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "acosh", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "acos", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "asc", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "asin", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "asinh", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "atan", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "asin", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "atan2", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "atand", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "atanh", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "atan", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "bitwise_and", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "bitwise_or", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "bitwise_xor", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ceil", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "cos", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "cosh", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "cos", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "defined", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "degrees", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "dimension_size", len)) i = len; @@ -582,35 +601,17 @@ static int txtfmt_pov_find_specialvar(const char *string) else if (STR_LITERAL_STARTSWITH(string, "rand", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "seed", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "select", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sin", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "sinh", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "sqr", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sin", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "sqrt", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "sqr", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "strcmp", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "strlen", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "tan", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "tanh", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "tan", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "val", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "vdot", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "vlength", len)) i = len; - /* Vector Functions */ - else if (STR_LITERAL_STARTSWITH(string, "max_extent", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "min_extent", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "trace", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vaxis_rotate", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vcross", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vnormalize", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vrotate", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vturbulence", len)) i = len; - /* String Functions */ - else if (STR_LITERAL_STARTSWITH(string, "chr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "concat", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "datetime", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "str", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "strlwr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "strupr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "substr", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "vstr", len)) i = len; else i = 0; /* If next source char is an identifier (eg. 'i' in "definate") no match */ diff --git a/source/blender/editors/space_text/text_format_pov_ini.c b/source/blender/editors/space_text/text_format_pov_ini.c index b88eae801b3..5c20a1c5f00 100644 --- a/source/blender/editors/space_text/text_format_pov_ini.c +++ b/source/blender/editors/space_text/text_format_pov_ini.c @@ -56,16 +56,16 @@ static int txtfmt_ini_find_keyword(const char *string) else if (STR_LITERAL_STARTSWITH(string, "declare", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "default", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "deprecated", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "elseif", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "else", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "end", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "error", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fclose", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "fopen", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "for", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ifdef", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "ifndef", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "if", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "include", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "local", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "macro", len)) i = len; @@ -104,9 +104,9 @@ static int txtfmt_ini_find_reserved(const char *string) * list is from... * http://www.povray.org/documentation/view/3.7.0/212/ */ - if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len; + if (STR_LITERAL_STARTSWITH(string, "clock_delta", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "clock_on", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "clock", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "final_clock", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "final_frame", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "frame_number", len)) i = len; @@ -127,13 +127,13 @@ static int txtfmt_ini_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "Start_Row", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "End_Column", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "End_Row", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Test_Abort", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Test_Abort_Count", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Test_Abort", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Continue_Trace", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Create_Continue_Trace_Log", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Create_Ini", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Display", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Display_Gamma", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Display", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Pause_When_Done", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Verbose", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Preview_Start_Size", len)) i = len; @@ -145,8 +145,8 @@ static int txtfmt_ini_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "Output_Alpha", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Bits_Per_Color", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Compression", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Dither_Method", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Dither", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Pre_Scene_Command", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Pre_Frame_Command", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Post_Scene_Command", len)) i = len; @@ -174,11 +174,9 @@ static int txtfmt_ini_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "Statistic_File", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Warning_File", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "All_File", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "All_File", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "All_File", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Quality", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Bounding", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Bounding_Threshold", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Bounding", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Light_Buffer", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Vista_Buffer", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Remove_Bounds", len)) i = len; @@ -186,8 +184,8 @@ static int txtfmt_ini_find_reserved(const char *string) else if (STR_LITERAL_STARTSWITH(string, "Antialias", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Sampling_Method", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Antialias_Threshold", len)) i = len; - else if (STR_LITERAL_STARTSWITH(string, "Jitter", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Jitter_Amount", len)) i = len; + else if (STR_LITERAL_STARTSWITH(string, "Jitter", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "Antialias_Depth", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "CheckNewVersion", len)) i = len; else if (STR_LITERAL_STARTSWITH(string, "RunCount", len)) i = len; -- cgit v1.2.3 From c1b321e1b8b567c85cd79064d9d7d0971a0a87ec Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 23 May 2017 17:09:19 +0200 Subject: Add PovRay file extensions to our 'textual' file filtering. --- source/blender/editors/space_file/filelist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 83469a48165..6c33091ff01 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -1964,7 +1964,7 @@ int ED_path_extension_type(const char *path) else if (BLI_testextensie(path, ".py")) { return FILE_TYPE_PYSCRIPT; } - else if (BLI_testextensie_n(path, ".txt", ".glsl", ".osl", ".data", NULL)) { + else if (BLI_testextensie_n(path, ".txt", ".glsl", ".osl", ".data", ".pov", ".ini", ".mcr", ".inc", NULL)) { return FILE_TYPE_TEXT; } else if (BLI_testextensie_n(path, ".ttf", ".ttc", ".pfb", ".otf", ".otc", NULL)) { -- cgit v1.2.3 From 96e068d3aa916bcc8152aedffafe1f8ddd7d27a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 23 May 2017 13:28:38 +0200 Subject: Alembic: split up read_custom_data_ex() into read_custom_data_{mcols,uvs}() The read_custom_data_ex() function was basically two functions inside if/else bodies. --- source/blender/alembic/intern/abc_customdata.cc | 86 +++++++++++++------------ 1 file changed, 44 insertions(+), 42 deletions(-) (limited to 'source/blender') diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc index 0d11ab79ddd..5fa3d10fa16 100644 --- a/source/blender/alembic/intern/abc_customdata.cc +++ b/source/blender/alembic/intern/abc_customdata.cc @@ -294,57 +294,59 @@ static void read_uvs(const CDStreamConfig &config, void *data, } } -static void read_custom_data_ex(const ICompoundProperty &prop, - const PropertyHeader &prop_header, - const CDStreamConfig &config, - const Alembic::Abc::ISampleSelector &iss, - int data_type) +static void read_custom_data_mcols(const ICompoundProperty &prop, + const PropertyHeader &prop_header, + const CDStreamConfig &config, + const Alembic::Abc::ISampleSelector &iss) { - if (data_type == CD_MLOOPCOL) { - C3fArraySamplePtr c3f_ptr = C3fArraySamplePtr(); - C4fArraySamplePtr c4f_ptr = C4fArraySamplePtr(); + C3fArraySamplePtr c3f_ptr = C3fArraySamplePtr(); + C4fArraySamplePtr c4f_ptr = C4fArraySamplePtr(); - if (IC3fGeomParam::matches(prop_header)) { - IC3fGeomParam color_param(prop, prop_header.getName()); - IC3fGeomParam::Sample sample; - color_param.getIndexed(sample, iss); + if (IC3fGeomParam::matches(prop_header)) { + IC3fGeomParam color_param(prop, prop_header.getName()); + IC3fGeomParam::Sample sample; + color_param.getIndexed(sample, iss); - c3f_ptr = sample.getVals(); - } - else if (IC4fGeomParam::matches(prop_header)) { - IC4fGeomParam color_param(prop, prop_header.getName()); - IC4fGeomParam::Sample sample; - color_param.getIndexed(sample, iss); - - c4f_ptr = sample.getVals(); - } - - void *cd_data = config.add_customdata_cb(config.user_data, - prop_header.getName().c_str(), - data_type); + c3f_ptr = sample.getVals(); + } + else if (IC4fGeomParam::matches(prop_header)) { + IC4fGeomParam color_param(prop, prop_header.getName()); + IC4fGeomParam::Sample sample; + color_param.getIndexed(sample, iss); - read_mcols(config, cd_data, c3f_ptr, c4f_ptr); + c4f_ptr = sample.getVals(); } - else if (data_type == CD_MLOOPUV) { - IV2fGeomParam uv_param(prop, prop_header.getName()); - if (!uv_param.isIndexed()) { - return; - } + void *cd_data = config.add_customdata_cb(config.user_data, + prop_header.getName().c_str(), + CD_MLOOPCOL); - IV2fGeomParam::Sample sample; - uv_param.getIndexed(sample, iss); + read_mcols(config, cd_data, c3f_ptr, c4f_ptr); +} - if (uv_param.getScope() != kFacevaryingScope) { - return; - } +static void read_custom_data_uvs(const ICompoundProperty &prop, + const PropertyHeader &prop_header, + const CDStreamConfig &config, + const Alembic::Abc::ISampleSelector &iss) +{ + IV2fGeomParam uv_param(prop, prop_header.getName()); + + if (!uv_param.isIndexed()) { + return; + } - void *cd_data = config.add_customdata_cb(config.user_data, - prop_header.getName().c_str(), - data_type); + IV2fGeomParam::Sample sample; + uv_param.getIndexed(sample, iss); - read_uvs(config, cd_data, sample.getVals(), sample.getIndices()); + if (uv_param.getScope() != kFacevaryingScope) { + return; } + + void *cd_data = config.add_customdata_cb(config.user_data, + prop_header.getName().c_str(), + CD_MLOOPUV); + + read_uvs(config, cd_data, sample.getVals(), sample.getIndices()); } void read_custom_data(const ICompoundProperty &prop, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss) @@ -367,7 +369,7 @@ void read_custom_data(const ICompoundProperty &prop, const CDStreamConfig &confi continue; } - read_custom_data_ex(prop, prop_header, config, iss, CD_MLOOPUV); + read_custom_data_uvs(prop, prop_header, config, iss); continue; } @@ -377,7 +379,7 @@ void read_custom_data(const ICompoundProperty &prop, const CDStreamConfig &confi continue; } - read_custom_data_ex(prop, prop_header, config, iss, CD_MLOOPCOL); + read_custom_data_mcols(prop, prop_header, config, iss); continue; } } -- cgit v1.2.3 From cc0cc880de5a66d72f571bec4c7d3eb1219aefc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 23 May 2017 14:19:38 +0200 Subject: Alembic: reduced code duplication in read_mcols() A big chunk of code was copied between the if and else bodies. By using a boolean to store whether the c3f_ptr or c4f_ptr should be used, the in-loop condition is kept as simple as possible. --- source/blender/alembic/intern/abc_customdata.cc | 36 +++++++++++-------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'source/blender') diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc index 5fa3d10fa16..c42e5f808b5 100644 --- a/source/blender/alembic/intern/abc_customdata.cc +++ b/source/blender/alembic/intern/abc_customdata.cc @@ -228,38 +228,34 @@ using Alembic::AbcGeom::IC4fGeomParam; using Alembic::AbcGeom::IV2fGeomParam; static void read_mcols(const CDStreamConfig &config, void *data, - const C3fArraySamplePtr &c3f_ptr, const C4fArraySamplePtr &c4f_ptr) + const C3fArraySamplePtr &c3f_ptr, + const C4fArraySamplePtr &c4f_ptr) { MCol *cfaces = static_cast(data); MPoly *polys = config.mpoly; MLoop *mloops = config.mloop; - if (c3f_ptr) { - for (int i = 0; i < config.totpoly; ++i) { - MPoly *p = &polys[i]; - MCol *cface = &cfaces[p->loopstart + p->totloop]; - MLoop *mloop = &mloops[p->loopstart + p->totloop]; + /* Either one or the other should be given. */ + BLI_assert(c3f_ptr || c4f_ptr); + const bool use_c3f_ptr = (c3f_ptr.get() != nullptr); - for (int j = 0; j < p->totloop; ++j) { - cface--; - mloop--; + for (int i = 0; i < config.totpoly; ++i) { + MPoly *p = &polys[i]; + MCol *cface = &cfaces[p->loopstart + p->totloop]; + MLoop *mloop = &mloops[p->loopstart + p->totloop]; + + for (int j = 0; j < p->totloop; ++j) { + cface--; + mloop--; + + if (use_c3f_ptr) { const Imath::C3f &color = (*c3f_ptr)[mloop->v]; cface->a = FTOCHAR(color[0]); cface->r = FTOCHAR(color[1]); cface->g = FTOCHAR(color[2]); cface->b = 255; } - } - } - else if (c4f_ptr) { - for (int i = 0; i < config.totpoly; ++i) { - MPoly *p = &polys[i]; - MCol *cface = &cfaces[p->loopstart + p->totloop]; - MLoop *mloop = &mloops[p->loopstart + p->totloop]; - - for (int j = 0; j < p->totloop; ++j) { - cface--; - mloop--; + else { const Imath::C4f &color = (*c4f_ptr)[mloop->v]; cface->a = FTOCHAR(color[0]); cface->r = FTOCHAR(color[1]); -- cgit v1.2.3 From 7b25ffb618dd7509d425f7a5891c64d4a3668743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 23 May 2017 17:27:09 +0200 Subject: Fix T51534: Alembic: added support for face-varying vertex colours Houdini writes vertex data in a different format than Blender does; Houdini uses "face-varying scope", which means that the vertex colours are indexed by an ever-increasing number over all vertices of all faces instead of the vertex index. I've also merged the read_custom_data_mcols() and read_mcols() functions, because the latter was only called from the former, and the changes in this commit would add yet more function parameters to pass. --- source/blender/alembic/intern/abc_customdata.cc | 95 ++++++++++++++----------- 1 file changed, 53 insertions(+), 42 deletions(-) (limited to 'source/blender') diff --git a/source/blender/alembic/intern/abc_customdata.cc b/source/blender/alembic/intern/abc_customdata.cc index c42e5f808b5..1d2bc689027 100644 --- a/source/blender/alembic/intern/abc_customdata.cc +++ b/source/blender/alembic/intern/abc_customdata.cc @@ -227,44 +227,6 @@ using Alembic::AbcGeom::IC3fGeomParam; using Alembic::AbcGeom::IC4fGeomParam; using Alembic::AbcGeom::IV2fGeomParam; -static void read_mcols(const CDStreamConfig &config, void *data, - const C3fArraySamplePtr &c3f_ptr, - const C4fArraySamplePtr &c4f_ptr) -{ - MCol *cfaces = static_cast(data); - MPoly *polys = config.mpoly; - MLoop *mloops = config.mloop; - - /* Either one or the other should be given. */ - BLI_assert(c3f_ptr || c4f_ptr); - const bool use_c3f_ptr = (c3f_ptr.get() != nullptr); - - for (int i = 0; i < config.totpoly; ++i) { - MPoly *p = &polys[i]; - MCol *cface = &cfaces[p->loopstart + p->totloop]; - MLoop *mloop = &mloops[p->loopstart + p->totloop]; - - for (int j = 0; j < p->totloop; ++j) { - cface--; - mloop--; - - if (use_c3f_ptr) { - const Imath::C3f &color = (*c3f_ptr)[mloop->v]; - cface->a = FTOCHAR(color[0]); - cface->r = FTOCHAR(color[1]); - cface->g = FTOCHAR(color[2]); - cface->b = 255; - } - else { - const Imath::C4f &color = (*c4f_ptr)[mloop->v]; - cface->a = FTOCHAR(color[0]); - cface->r = FTOCHAR(color[1]); - cface->g = FTOCHAR(color[2]); - cface->b = FTOCHAR(color[3]); - } - } - } -} static void read_uvs(const CDStreamConfig &config, void *data, const Alembic::AbcGeom::V2fArraySamplePtr &uvs, @@ -290,34 +252,83 @@ static void read_uvs(const CDStreamConfig &config, void *data, } } -static void read_custom_data_mcols(const ICompoundProperty &prop, +static void read_custom_data_mcols(const ICompoundProperty &arbGeomParams, const PropertyHeader &prop_header, const CDStreamConfig &config, const Alembic::Abc::ISampleSelector &iss) { C3fArraySamplePtr c3f_ptr = C3fArraySamplePtr(); C4fArraySamplePtr c4f_ptr = C4fArraySamplePtr(); + bool use_c3f_ptr; + bool is_facevarying; + /* Find the correct interpretation of the data */ if (IC3fGeomParam::matches(prop_header)) { - IC3fGeomParam color_param(prop, prop_header.getName()); + IC3fGeomParam color_param(arbGeomParams, prop_header.getName()); IC3fGeomParam::Sample sample; + BLI_assert(!strcmp("rgb", color_param.getInterpretation())); + color_param.getIndexed(sample, iss); + is_facevarying = sample.getScope() == kFacevaryingScope && + config.totloop == sample.getIndices()->size(); c3f_ptr = sample.getVals(); + use_c3f_ptr = true; } else if (IC4fGeomParam::matches(prop_header)) { - IC4fGeomParam color_param(prop, prop_header.getName()); + IC4fGeomParam color_param(arbGeomParams, prop_header.getName()); IC4fGeomParam::Sample sample; + BLI_assert(!strcmp("rgba", color_param.getInterpretation())); + color_param.getIndexed(sample, iss); + is_facevarying = sample.getScope() == kFacevaryingScope && + config.totloop == sample.getIndices()->size(); c4f_ptr = sample.getVals(); + use_c3f_ptr = false; + } + else { + /* this won't happen due to the checks in read_custom_data() */ + return; } + BLI_assert(c3f_ptr || c4f_ptr); + /* Read the vertex colors */ void *cd_data = config.add_customdata_cb(config.user_data, prop_header.getName().c_str(), CD_MLOOPCOL); + MCol *cfaces = static_cast(cd_data); + MPoly *mpolys = config.mpoly; + MLoop *mloops = config.mloop; + + size_t face_index = 0; + size_t color_index; + for (int i = 0; i < config.totpoly; ++i) { + MPoly *poly = &mpolys[i]; + MCol *cface = &cfaces[poly->loopstart + poly->totloop]; + MLoop *mloop = &mloops[poly->loopstart + poly->totloop]; + + for (int j = 0; j < poly->totloop; ++j, ++face_index) { + --cface; + --mloop; + color_index = is_facevarying ? face_index : mloop->v; - read_mcols(config, cd_data, c3f_ptr, c4f_ptr); + if (use_c3f_ptr) { + const Imath::C3f &color = (*c3f_ptr)[color_index]; + cface->a = FTOCHAR(color[0]); + cface->r = FTOCHAR(color[1]); + cface->g = FTOCHAR(color[2]); + cface->b = 255; + } + else { + const Imath::C4f &color = (*c4f_ptr)[color_index]; + cface->a = FTOCHAR(color[0]); + cface->r = FTOCHAR(color[1]); + cface->g = FTOCHAR(color[2]); + cface->b = FTOCHAR(color[3]); + } + } + } } static void read_custom_data_uvs(const ICompoundProperty &prop, -- cgit v1.2.3