From 0d7817d1a46adebdad4cb68ea54169720e86068d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 28 Jun 2016 21:00:00 +1000 Subject: [PATCH 01/14] Cleanup: use bool for writefile --- source/blender/blenloader/intern/writefile.c | 30 +++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 9cf32e1fb73..2c8bb92ac4b 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -308,7 +308,8 @@ typedef struct { unsigned char *buf; MemFile *compare, *current; - int tot, count, error; + int tot, count; + bool error; /* Wrap writing, so we can use zlib or * other compression types later, see: G_FILE_COMPRESS @@ -316,7 +317,7 @@ typedef struct { WriteWrap *ww; #ifdef USE_BMESH_SAVE_AS_COMPAT - char use_mesh_compat; /* option to save with older mesh format */ + bool use_mesh_compat; /* option to save with older mesh format */ #endif } WriteData; @@ -349,7 +350,7 @@ static void writedata_do_write(WriteData *wd, const void *mem, int memlen) } else { if (wd->ww->write(wd->ww, mem, memlen) != memlen) { - wd->error = 1; + wd->error = true; } } } @@ -448,16 +449,14 @@ static WriteData *bgnwrite(WriteWrap *ww, MemFile *compare, MemFile *current) * \return unknown global variable otherwise * \warning Talks to other functions with global parameters */ -static int endwrite(WriteData *wd) +static bool endwrite(WriteData *wd) { - int err; - if (wd->count) { writedata_do_write(wd, wd->buf, wd->count); wd->count = 0; } - err = wd->error; + const bool err = wd->error; writedata_free(wd); return err; @@ -2179,7 +2178,7 @@ static void write_customdata( static void write_meshes(WriteData *wd, ListBase *idbase) { Mesh *mesh; - int save_for_old_blender = 0; + bool save_for_old_blender = false; #ifdef USE_BMESH_SAVE_AS_COMPAT save_for_old_blender = wd->use_mesh_compat; /* option to save with older mesh format */ @@ -3979,11 +3978,11 @@ static void write_thumb(WriteData *wd, const BlendThumbnail *thumb) } /* if MemFile * there's filesave to memory */ -static int write_file_handle( +static bool write_file_handle( Main *mainvar, WriteWrap *ww, MemFile *compare, MemFile *current, - int write_user_block, int write_flags, const BlendThumbnail *thumb) + int write_flags, const BlendThumbnail *thumb) { BHead bhead; ListBase mainlist; @@ -4050,7 +4049,7 @@ static int write_file_handle( write_linestyles(wd, &mainvar->linestyle); write_libraries(wd, mainvar->next); - if (write_user_block) { + if (write_flags & G_FILE_USERPREFS) { write_userdef(wd); } @@ -4128,7 +4127,6 @@ bool BLO_write_file( ReportList *reports, const BlendThumbnail *thumb) { char tempname[FILE_MAX + 1]; - int err, write_user_block; eWriteWrapType ww_type; WriteWrap ww; @@ -4183,15 +4181,13 @@ bool BLO_write_file( } } - write_user_block = write_flags & G_FILE_USERPREFS; - if (write_flags & G_FILE_RELATIVE_REMAP) { /* note, making relative to something OTHER then G.main->name */ BKE_bpath_relative_convert(mainvar, filepath, NULL); } /* actual file writing */ - err = write_file_handle(mainvar, &ww, NULL, NULL, write_user_block, write_flags, thumb); + const bool err = write_file_handle(mainvar, &ww, NULL, NULL, write_flags, thumb); ww.close(&ww); @@ -4230,9 +4226,9 @@ bool BLO_write_file( */ bool BLO_write_file_mem(Main *mainvar, MemFile *compare, MemFile *current, int write_flags) { - int err; + write_flags &= ~G_FILE_USERPREFS; - err = write_file_handle(mainvar, NULL, compare, current, 0, write_flags, NULL); + const bool err = write_file_handle(mainvar, NULL, compare, current, write_flags, NULL); return (err == 0); } From 23cc453975c42069bac21e849b1bf7e3e60cd8e7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 28 Jun 2016 17:11:17 +0500 Subject: [PATCH 02/14] Fix T48732: New GGX breaks OpenCL kernel Make sure we don't perform any implicit address space conversion. A bit annoying, but less intrusive approaches (like using temp private variable in .cl kernel) do not work correct here. Using generic address space will help from code side here, but will be somewhat slower due to extra things happening as far as i know. --- .../closure/bsdf_microfacet_multi_impl.h | 22 ++++++++++++------- intern/cycles/kernel/kernel_random.h | 20 +++++++++++++++-- intern/cycles/kernel/kernel_shader.h | 4 ++-- 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h b/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h index 8f8e19dd059..afd4a8da62a 100644 --- a/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h +++ b/intern/cycles/kernel/closure/bsdf_microfacet_multi_impl.h @@ -98,9 +98,10 @@ ccl_device float3 MF_FUNCTION_FULL_NAME(mf_eval)(float3 wi, float3 wo, const boo for(int order = 0; order < 10; order++) { /* Sample microfacet height and normal */ - if(!mf_sample_height(wr, &hr, &C1_r, &G1_r, &lambda_r, lcg_step_float(lcg_state))) + if(!mf_sample_height(wr, &hr, &C1_r, &G1_r, &lambda_r, lcg_step_float_addrspace(lcg_state))) break; - float3 wm = mf_sample_vndf(-wr, alpha, make_float2(lcg_step_float(lcg_state), lcg_step_float(lcg_state))); + float3 wm = mf_sample_vndf(-wr, alpha, make_float2(lcg_step_float_addrspace(lcg_state), + lcg_step_float_addrspace(lcg_state))); #ifdef MF_MULTI_DIFFUSE if(order == 0) { @@ -128,14 +129,16 @@ ccl_device float3 MF_FUNCTION_FULL_NAME(mf_eval)(float3 wi, float3 wo, const boo /* Bounce from the microfacet. */ #ifdef MF_MULTI_GLASS bool next_outside; - wr = mf_sample_phase_glass(-wr, outside? eta: 1.0f/eta, wm, lcg_step_float(lcg_state), &next_outside); + wr = mf_sample_phase_glass(-wr, outside? eta: 1.0f/eta, wm, lcg_step_float_addrspace(lcg_state), &next_outside); if(!next_outside) { outside = !outside; wr = -wr; hr = -hr; } #elif defined(MF_MULTI_DIFFUSE) - wr = mf_sample_phase_diffuse(wm, lcg_step_float(lcg_state), lcg_step_float(lcg_state)); + wr = mf_sample_phase_diffuse(wm, + lcg_step_float_addrspace(lcg_state), + lcg_step_float_addrspace(lcg_state)); #else /* MF_MULTI_GLOSSY */ wr = mf_sample_phase_glossy(-wr, n, k, &throughput, wm); #endif @@ -179,13 +182,14 @@ ccl_device float3 MF_FUNCTION_FULL_NAME(mf_sample)(float3 wi, float3 *wo, const int order; for(order = 0; order < 10; order++) { /* Sample microfacet height. */ - if(!mf_sample_height(wr, &hr, &C1_r, &G1_r, &lambda_r, lcg_step_float(lcg_state))) { + if(!mf_sample_height(wr, &hr, &C1_r, &G1_r, &lambda_r, lcg_step_float_addrspace(lcg_state))) { /* The random walk has left the surface. */ *wo = outside? wr: -wr; return throughput; } /* Sample microfacet normal. */ - float3 wm = mf_sample_vndf(-wr, alpha, make_float2(lcg_step_float(lcg_state), lcg_step_float(lcg_state))); + float3 wm = mf_sample_vndf(-wr, alpha, make_float2(lcg_step_float_addrspace(lcg_state), + lcg_step_float_addrspace(lcg_state))); /* First-bounce color is already accounted for in mix weight. */ if(order > 0) @@ -194,14 +198,16 @@ ccl_device float3 MF_FUNCTION_FULL_NAME(mf_sample)(float3 wi, float3 *wo, const /* Bounce from the microfacet. */ #ifdef MF_MULTI_GLASS bool next_outside; - wr = mf_sample_phase_glass(-wr, outside? eta: 1.0f/eta, wm, lcg_step_float(lcg_state), &next_outside); + wr = mf_sample_phase_glass(-wr, outside? eta: 1.0f/eta, wm, lcg_step_float_addrspace(lcg_state), &next_outside); if(!next_outside) { hr = -hr; wr = -wr; outside = !outside; } #elif defined(MF_MULTI_DIFFUSE) - wr = mf_sample_phase_diffuse(wm, lcg_step_float(lcg_state), lcg_step_float(lcg_state)); + wr = mf_sample_phase_diffuse(wm, + lcg_step_float_addrspace(lcg_state), + lcg_step_float_addrspace(lcg_state)); #else /* MF_MULTI_GLOSSY */ wr = mf_sample_phase_glossy(-wr, n, k, &throughput, wm); #endif diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h index bf3c25d2cb2..94598e2565e 100644 --- a/intern/cycles/kernel/kernel_random.h +++ b/intern/cycles/kernel/kernel_random.h @@ -232,14 +232,14 @@ ccl_device void path_rng_end(KernelGlobals *kg, ccl_global uint *rng_state, RNG /* Linear Congruential Generator */ -ccl_device uint lcg_step_uint(ccl_addr_space uint *rng) +ccl_device uint lcg_step_uint(uint *rng) { /* implicit mod 2^32 */ *rng = (1103515245*(*rng) + 12345); return *rng; } -ccl_device float lcg_step_float(ccl_addr_space uint *rng) +ccl_device float lcg_step_float(uint *rng) { /* implicit mod 2^32 */ *rng = (1103515245*(*rng) + 12345); @@ -314,5 +314,21 @@ ccl_device_inline uint lcg_state_init(RNG *rng, const ccl_addr_space PathState * return lcg_init(*rng + state->rng_offset + state->sample*scramble); } +/* TODO(sergey): For until we can use generic address space from OpenCL 2.0. */ + +ccl_device_inline uint lcg_state_init_addrspace(ccl_addr_space RNG *rng, + const ccl_addr_space PathState *state, + uint scramble) +{ + return lcg_init(*rng + state->rng_offset + state->sample*scramble); +} + +ccl_device float lcg_step_float_addrspace(ccl_addr_space uint *rng) +{ + /* implicit mod 2^32 */ + *rng = (1103515245*(*rng) + 12345); + return (float)*rng * (1.0f/(float)0xFFFFFFFF); +} + CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index 3a4770f82f1..765baa2a5ba 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -827,7 +827,7 @@ ccl_device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd) /* Surface Evaluation */ -ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, RNG *rng, +ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, ccl_addr_space RNG *rng, ccl_addr_space PathState *state, float randb, int path_flag, ShaderContext ctx) { ccl_fetch(sd, num_closure) = 0; @@ -851,7 +851,7 @@ ccl_device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd, RNG *rng, } if(rng && (ccl_fetch(sd, flag) & SD_BSDF_NEEDS_LCG)) { - ccl_fetch(sd, lcg_state) = lcg_state_init(rng, state, 0xb4bc3953); + ccl_fetch(sd, lcg_state) = lcg_state_init_addrspace(rng, state, 0xb4bc3953); } } From 5b325abf604954fc7172dfa3e436dca15897ab65 Mon Sep 17 00:00:00 2001 From: Martijn Berger Date: Tue, 28 Jun 2016 16:02:12 +0200 Subject: [PATCH 03/14] [msvc2015/OpenEXR] Linker hackery is no longer required in vc2015 Reviewers: juicyfruit Reviewed By: juicyfruit Differential Revision: https://developer.blender.org/D1892 --- source/blender/imbuf/intern/openexr/openexr_api.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 611ada5b077..89e796fb7ee 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -77,7 +77,7 @@ extern "C" { // The following prevents a linking error in debug mode for MSVC using the libs in CVS -#if defined(WITH_OPENEXR) && defined(_WIN32) && defined(DEBUG) && !defined(__MINGW32__) +#if defined(WITH_OPENEXR) && defined(_WIN32) && defined(DEBUG) && !defined(__MINGW32__) && _MSC_VER < 1900 _CRTIMP void __cdecl _invalid_parameter_noinfo(void) { } From a21549f822420d418c1b1189bfb2678f52f44e1f Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 28 Jun 2016 21:34:18 +0200 Subject: [PATCH 04/14] Usual i18n/UI messages cleanup & fixes. --- release/scripts/modules/bl_i18n_utils/utils_spell_check.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py index 636b6b0f46b..98a117e95a6 100644 --- a/release/scripts/modules/bl_i18n_utils/utils_spell_check.py +++ b/release/scripts/modules/bl_i18n_utils/utils_spell_check.py @@ -58,7 +58,6 @@ class SpellChecker: "vertices", # Merged words - #~ "addon", "addons", "antialiasing", "arcsine", "arccosine", "arctangent", "autoclip", @@ -127,6 +126,7 @@ class SpellChecker: "multipaint", "multires", "multiresolution", "multisampling", + "multiscatter", "multitexture", "multithreaded", "multiuser", @@ -530,6 +530,7 @@ class SpellChecker: "futura", "fx", "gfx", + "ggx", "gl", "glsl", "gpl", From 20f634cfc21086777164dd1ba1287181c037d911 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 29 Jun 2016 11:48:50 +1000 Subject: [PATCH 05/14] Fix T48755: Crash UV unwrapping --- .../blender/editors/uvedit/uvedit_parametrizer.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 59f9cd16908..4713ea73b58 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -740,6 +740,16 @@ static PVert *p_vert_add(PHandle *handle, PHashKey key, const float co[3], PEdge { PVert *v = (PVert *)BLI_memarena_alloc(handle->arena, sizeof(*v)); copy_v3_v3(v->co, co); + + /* Sanity check, a single nan/inf point causes the entire result to be invalid. + * Note that values within the calculation may _become_ non-finite, + * so the rest of the code still needs to take this possability into account. */ + for (int i = 0; i < 3; i++) { + if (UNLIKELY(!finite(v->co[i]))) { + v->co[i] = 0.0f; + } + } + v->u.key = key; v->edge = e; v->flag = 0; @@ -3040,8 +3050,10 @@ static void p_chart_lscm_begin(PChart *chart, PBool live, PBool abf) p_chart_boundaries(chart, NULL, &outer); - if (!p_chart_symmetry_pins(chart, outer, &pin1, &pin2)) + /* outer can be NULL with non-finite coords. */ + if (outer && !p_chart_symmetry_pins(chart, outer, &pin1, &pin2)) { p_chart_extrema_verts(chart, &pin1, &pin2); + } chart->u.lscm.pin1 = pin1; chart->u.lscm.pin2 = pin2; From 29a73106b45aa8d2367aebc3fde43cc2e2f5341e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 29 Jun 2016 12:00:17 +1000 Subject: [PATCH 06/14] UI: prevent softrange from becoming nan Quiets assert --- source/blender/editors/interface/interface.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 77990066027..ba7240be5d8 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -2576,9 +2576,11 @@ static void ui_set_but_soft_range(uiBut *but) } else if (but->poin && (but->pointype & UI_BUT_POIN_TYPES)) { float value = ui_but_value_get(but); - CLAMP(value, but->hardmin, but->hardmax); - but->softmin = min_ff(but->softmin, value); - but->softmax = max_ff(but->softmax, value); + if (isfinite(value)) { + CLAMP(value, but->hardmin, but->hardmax); + but->softmin = min_ff(but->softmin, value); + but->softmax = max_ff(but->softmax, value); + } } else { BLI_assert(0); From e6d947f037d341fc1f84fb422b2cada8bd6f5d0a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 29 Jun 2016 16:09:58 +1000 Subject: [PATCH 07/14] BMesh Intersect: use flags to keep track of verts For simple cases bitmasks were OK, but didnt work for vert/edge, vert/edge tests. Tag verts instead, makes logic easier to follow and gives minor speedup. --- source/blender/bmesh/intern/bmesh_private.h | 3 +- source/blender/bmesh/tools/bmesh_intersect.c | 169 +++++++++---------- 2 files changed, 84 insertions(+), 88 deletions(-) diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h index 9b3a147301d..d8d297c9298 100644 --- a/source/blender/bmesh/intern/bmesh_private.h +++ b/source/blender/bmesh/intern/bmesh_private.h @@ -67,12 +67,13 @@ enum { _FLAG_MV = (1 << 1), /* make face, vertex */ _FLAG_OVERLAP = (1 << 2), /* general overlap flag */ _FLAG_WALK = (1 << 3), /* general walk flag (keep clean) */ + _FLAG_WALK_ALT = (1 << 4), /* same as _FLAG_WALK, for when a second tag is needed */ _FLAG_ELEM_CHECK = (1 << 7), /* reserved for bmesh_elem_check */ }; #define BM_ELEM_API_FLAG_ENABLE(element, f) { ((element)->head.api_flag |= (f)); } (void)0 -#define BM_ELEM_API_FLAG_DISABLE(element, f) { ((element)->head.api_flag &= ~(f)); } (void)0 +#define BM_ELEM_API_FLAG_DISABLE(element, f) { ((element)->head.api_flag &= (unsigned char)~(f)); } (void)0 #define BM_ELEM_API_FLAG_TEST(element, f) ((element)->head.api_flag & (f)) #define BM_ELEM_API_FLAG_CLEAR(element) { ((element)->head.api_flag = 0); } (void)0 diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c index bd6a68faabb..58234ddf3bd 100644 --- a/source/blender/bmesh/tools/bmesh_intersect.c +++ b/source/blender/bmesh/tools/bmesh_intersect.c @@ -53,6 +53,8 @@ #include "BLI_buffer.h" #include "bmesh.h" +#include "intern/bmesh_private.h" + #include "bmesh_intersect.h" /* own include */ #include "tools/bmesh_edgesplit.h" @@ -87,18 +89,6 @@ // #define USE_DUMP -/* use only for small arrays */ -BLI_INLINE bool array_contains_pointer(const void **arr, unsigned int arr_len, const void *item) -{ - BLI_assert(arr_len < 3); - for (unsigned int i = 0; i < arr_len; i++) { - if (arr[i] == item) { - return true; - } - } - return false; -} - static void tri_v3_scale( float v1[3], float v2[3], float v3[3], const float t) @@ -547,9 +537,6 @@ static void bm_isect_tri_tri( const float *f_b_cos[3] = {UNPACK3_EX(, fv_b, ->co)}; float f_a_nor[3]; float f_b_nor[3]; - /* track vertices which have been added to 'iv_ls_a' & 'iv_ls_b' */ - int a_mask = 0; - int b_mask = 0; unsigned int i; @@ -569,24 +556,22 @@ static void bm_isect_tri_tri( STACK_INIT(iv_ls_a, ARRAY_SIZE(iv_ls_a)); STACK_INIT(iv_ls_b, ARRAY_SIZE(iv_ls_b)); - /* don't test, but we must be sure not to add doubles (assert instead). */ -#ifndef NDEBUG -# define STACK_PUSH_NOTEST(arr, ele) \ - { \ - BLI_assert(BLI_array_findindex(arr, STACK_SIZE(arr), &(ele)) == -1); \ - STACK_PUSH(arr, ele); \ - } ((void)0) -#else -# define STACK_PUSH_NOTEST STACK_PUSH -#endif +#define VERT_VISIT_A _FLAG_WALK +#define VERT_VISIT_B _FLAG_WALK_ALT - /* warning, this seems like it might be inefficent, - * however there will be <3 items in this case. */ -# define STACK_PUSH_TEST(arr, ele, arr_offset) \ - if (!array_contains_pointer((const void **)(&(arr)[arr_offset]), STACK_SIZE(arr) - (arr_offset), (void *)ele)) { \ - STACK_PUSH(arr, ele); \ +#define STACK_PUSH_TEST_A(ele) \ + if (BM_ELEM_API_FLAG_TEST(ele, VERT_VISIT_A) == 0) { \ + BM_ELEM_API_FLAG_ENABLE(ele, VERT_VISIT_A); \ + STACK_PUSH(iv_ls_a, ele); \ } ((void)0) +#define STACK_PUSH_TEST_B(ele) \ + if (BM_ELEM_API_FLAG_TEST(ele, VERT_VISIT_B) == 0) { \ + BM_ELEM_API_FLAG_ENABLE(ele, VERT_VISIT_B); \ + STACK_PUSH(iv_ls_b, ele); \ + } ((void)0) + + /* vert-vert * --------- */ { @@ -598,22 +583,18 @@ static void bm_isect_tri_tri( unsigned int i_b; for (i_b = 0; i_b < 3; i_b++) { if (len_squared_v3v3(fv_a[i_a]->co, fv_b[i_b]->co) <= s->epsilon.eps2x_sq) { - if (!((1 << i_a) & a_mask)) { - STACK_PUSH_NOTEST(iv_ls_a, fv_a[i_a]); - a_mask |= (1 << i_a); #ifdef USE_DUMP + if (BM_ELEM_API_FLAG_TEST(fv_a[i_a], VERT_VISIT) == 0) { printf(" ('VERT-VERT-A') %d, %d),\n", i_a, BM_elem_index_get(fv_a[i_a])); -#endif } - if (!((1 << i_b) & b_mask)) { - STACK_PUSH_NOTEST(iv_ls_b, fv_b[i_b]); - b_mask |= (1 << i_b); -#ifdef USE_DUMP + if (BM_ELEM_API_FLAG_TEST(fv_b[i_b], VERT_VISIT) == 0) { printf(" ('VERT-VERT-B') %d, %d),\n", i_b, BM_elem_index_get(fv_b[i_b])); -#endif } +#endif + STACK_PUSH_TEST_A(fv_a[i_a]); + STACK_PUSH_TEST_B(fv_b[i_b]); } } } @@ -624,22 +605,25 @@ static void bm_isect_tri_tri( { unsigned int i_a; for (i_a = 0; i_a < 3; i_a++) { - if (!((1 << i_a) & a_mask)) { + if (BM_ELEM_API_FLAG_TEST(fv_a[i_a], VERT_VISIT_A) == 0) { unsigned int i_b_e0; for (i_b_e0 = 0; i_b_e0 < 3; i_b_e0++) { unsigned int i_b_e1 = (i_b_e0 + 1) % 3; - float fac; - if (((1 << i_b_e0) | (1 << i_b_e1)) & b_mask) + + if (BM_ELEM_API_FLAG_TEST(fv_b[i_b_e0], VERT_VISIT_B) || + BM_ELEM_API_FLAG_TEST(fv_b[i_b_e1], VERT_VISIT_B)) + { continue; - fac = line_point_factor_v3(fv_a[i_a]->co, fv_b[i_b_e0]->co, fv_b[i_b_e1]->co); + } + + const float fac = line_point_factor_v3(fv_a[i_a]->co, fv_b[i_b_e0]->co, fv_b[i_b_e1]->co); if ((fac > 0.0f - s->epsilon.eps) && (fac < 1.0f + s->epsilon.eps)) { float ix[3]; interp_v3_v3v3(ix, fv_b[i_b_e0]->co, fv_b[i_b_e1]->co, fac); if (len_squared_v3v3(ix, fv_a[i_a]->co) <= s->epsilon.eps2x_sq) { BMEdge *e; - STACK_PUSH_NOTEST(iv_ls_b, fv_a[i_a]); - // STACK_PUSH_NOTEST(iv_ls_a, fv_a[i_a]); - a_mask |= (1 << i_a); + STACK_PUSH_TEST_B(fv_a[i_a]); + // STACK_PUSH_TEST_A(fv_a[i_a]); e = BM_edge_exists(fv_b[i_b_e0], fv_b[i_b_e1]); #ifdef USE_DUMP printf(" ('VERT-EDGE-A', %d, %d),\n", @@ -662,22 +646,25 @@ static void bm_isect_tri_tri( { unsigned int i_b; for (i_b = 0; i_b < 3; i_b++) { - if (!((1 << i_b) & b_mask)) { + if (BM_ELEM_API_FLAG_TEST(fv_b[i_b], VERT_VISIT_B) == 0) { unsigned int i_a_e0; for (i_a_e0 = 0; i_a_e0 < 3; i_a_e0++) { unsigned int i_a_e1 = (i_a_e0 + 1) % 3; - float fac; - if (((1 << i_a_e0) | (1 << i_a_e1)) & a_mask) + + if (BM_ELEM_API_FLAG_TEST(fv_a[i_a_e0], VERT_VISIT_A) || + BM_ELEM_API_FLAG_TEST(fv_a[i_a_e1], VERT_VISIT_A)) + { continue; - fac = line_point_factor_v3(fv_b[i_b]->co, fv_a[i_a_e0]->co, fv_a[i_a_e1]->co); + } + + const float fac = line_point_factor_v3(fv_b[i_b]->co, fv_a[i_a_e0]->co, fv_a[i_a_e1]->co); if ((fac > 0.0f - s->epsilon.eps) && (fac < 1.0f + s->epsilon.eps)) { float ix[3]; interp_v3_v3v3(ix, fv_a[i_a_e0]->co, fv_a[i_a_e1]->co, fac); if (len_squared_v3v3(ix, fv_b[i_b]->co) <= s->epsilon.eps2x_sq) { BMEdge *e; - STACK_PUSH_NOTEST(iv_ls_a, fv_b[i_b]); + STACK_PUSH_TEST_A(fv_b[i_b]); // STACK_PUSH_NOTEST(iv_ls_b, fv_b[i_b]); - b_mask |= (1 << i_b); e = BM_edge_exists(fv_a[i_a_e0], fv_a[i_a_e1]); #ifdef USE_DUMP printf(" ('VERT-EDGE-B', %d, %d),\n", @@ -711,14 +698,15 @@ static void bm_isect_tri_tri( // second check for verts intersecting the triangle for (i_a = 0; i_a < 3; i_a++) { - float ix[3]; - if ((1 << i_a) & a_mask) + if (BM_ELEM_API_FLAG_TEST(fv_a[i_a], VERT_VISIT_A)) { continue; + } + + float ix[3]; if (isect_point_tri_v3(fv_a[i_a]->co, UNPACK3(t_scale), ix)) { if (len_squared_v3v3(ix, fv_a[i_a]->co) <= s->epsilon.eps2x_sq) { - STACK_PUSH_NOTEST(iv_ls_a, fv_a[i_a]); - STACK_PUSH_NOTEST(iv_ls_b, fv_a[i_a]); - a_mask |= (1 << i_a); + STACK_PUSH_TEST_A(fv_a[i_a]); + STACK_PUSH_TEST_B(fv_a[i_a]); #ifdef USE_DUMP printf(" 'VERT TRI-A',\n"); #endif @@ -737,15 +725,15 @@ static void bm_isect_tri_tri( tri_v3_scale(UNPACK3(t_scale), 1.0f - s->epsilon.eps2x); for (i_b = 0; i_b < 3; i_b++) { - float ix[3]; - if ((1 << i_b) & b_mask) + if (BM_ELEM_API_FLAG_TEST(fv_b[i_b], VERT_VISIT_B)) { continue; + } + float ix[3]; if (isect_point_tri_v3(fv_b[i_b]->co, UNPACK3(t_scale), ix)) { if (len_squared_v3v3(ix, fv_b[i_b]->co) <= s->epsilon.eps2x_sq) { - STACK_PUSH_NOTEST(iv_ls_a, fv_b[i_b]); - STACK_PUSH_NOTEST(iv_ls_b, fv_b[i_b]); - b_mask |= (1 << i_b); + STACK_PUSH_TEST_A(fv_b[i_b]); + STACK_PUSH_TEST_B(fv_b[i_b]); #ifdef USE_DUMP printf(" 'VERT TRI-B',\n"); #endif @@ -760,7 +748,7 @@ static void bm_isect_tri_tri( #ifdef USE_DUMP printf("# OVERLAP\n"); #endif - return; + goto finally; } normal_tri_v3(f_a_nor, UNPACK3(f_a_cos)); @@ -769,44 +757,42 @@ static void bm_isect_tri_tri( /* edge-tri & edge-edge * -------------------- */ { - /** - * Note that its possible to add the same vertex multiple times - * with near degenerate faces (or a large epsilon). - * - * For this reason we have #STACK_PUSH_TEST macro which only adds vertices that aren't already added. - * Since we know none of the vertices from #bm_isect_edge_tri, the check can be offset. - */ - - const unsigned int iv_ls_a_offset = STACK_SIZE(iv_ls_a); - const unsigned int iv_ls_b_offset = STACK_SIZE(iv_ls_b); - - unsigned int i_e0; - for (i_e0 = 0; i_e0 < 3; i_e0++) { - unsigned int i_e1 = (i_e0 + 1) % 3; + for (unsigned int i_a_e0 = 0; i_a_e0 < 3; i_a_e0++) { + unsigned int i_a_e1 = (i_a_e0 + 1) % 3; enum ISectType side; BMVert *iv; - if (((1 << i_e0) | (1 << i_e1)) & a_mask) + + if (BM_ELEM_API_FLAG_TEST(fv_a[i_a_e0], VERT_VISIT_A) || + BM_ELEM_API_FLAG_TEST(fv_a[i_a_e1], VERT_VISIT_A)) + { continue; - iv = bm_isect_edge_tri(s, fv_a[i_e0], fv_a[i_e1], fv_b, b_index, f_b_cos, f_b_nor, &side); + } + + iv = bm_isect_edge_tri(s, fv_a[i_a_e0], fv_a[i_a_e1], fv_b, b_index, f_b_cos, f_b_nor, &side); if (iv) { - STACK_PUSH_TEST(iv_ls_a, iv, iv_ls_a_offset); - STACK_PUSH_TEST(iv_ls_b, iv, iv_ls_b_offset); + STACK_PUSH_TEST_A(iv); + STACK_PUSH_TEST_B(iv); #ifdef USE_DUMP printf(" ('EDGE-TRI-A', %d),\n", side); #endif } } - for (i_e0 = 0; i_e0 < 3; i_e0++) { - unsigned int i_e1 = (i_e0 + 1) % 3; + for (unsigned int i_b_e0 = 0; i_b_e0 < 3; i_b_e0++) { + unsigned int i_b_e1 = (i_b_e0 + 1) % 3; enum ISectType side; BMVert *iv; - if (((1 << i_e0) | (1 << i_e1)) & b_mask) + + if (BM_ELEM_API_FLAG_TEST(fv_b[i_b_e0], VERT_VISIT_B) || + BM_ELEM_API_FLAG_TEST(fv_b[i_b_e1], VERT_VISIT_B)) + { continue; - iv = bm_isect_edge_tri(s, fv_b[i_e0], fv_b[i_e1], fv_a, a_index, f_a_cos, f_a_nor, &side); + } + + iv = bm_isect_edge_tri(s, fv_b[i_b_e0], fv_b[i_b_e1], fv_a, a_index, f_a_cos, f_a_nor, &side); if (iv) { - STACK_PUSH_TEST(iv_ls_a, iv, iv_ls_a_offset); - STACK_PUSH_TEST(iv_ls_b, iv, iv_ls_b_offset); + STACK_PUSH_TEST_A(iv); + STACK_PUSH_TEST_B(iv); #ifdef USE_DUMP printf(" ('EDGE-TRI-B', %d),\n", side); #endif @@ -859,6 +845,15 @@ static void bm_isect_tri_tri( // BLI_assert(len(ie_vs) <= 2) } } + +finally: + for (i = 0; i < STACK_SIZE(iv_ls_a); i++) { + BM_ELEM_API_FLAG_DISABLE(iv_ls_a[i], VERT_VISIT_A); \ + } + for (i = 0; i < STACK_SIZE(iv_ls_b); i++) { + BM_ELEM_API_FLAG_DISABLE(iv_ls_b[i], VERT_VISIT_B); \ + } + } #ifdef USE_BVH From c7eb5eeaa9d28afd9513e9cbda789ab2b71bfba1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 29 Jun 2016 17:12:22 +1000 Subject: [PATCH 08/14] Cleanup: warning --- source/blender/makesrna/intern/rna_userdef.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index ac1e31aa358..d8dcbf1afd0 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -94,10 +94,12 @@ EnumPropertyItem rna_enum_navigation_mode_items[] = { {0, NULL, 0, NULL, NULL} }; +#if defined(WITH_INTERNATIONAL) || !defined(RNA_RUNTIME) static EnumPropertyItem rna_enum_language_default_items[] = { {0, "DEFAULT", 0, "Default (Default)", ""}, {0, NULL, 0, NULL, NULL} }; +#endif #ifdef RNA_RUNTIME From 2f532c78445a9de1e64014468049649ac1de39f1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 29 Jun 2016 13:08:12 +0500 Subject: [PATCH 09/14] Fix T48728: Vertex colors not shown in texture mode Regression caused by own changes to make texture paint more efficient from workflow point of view. Now the idea is to use vertex color outside of paint mode, so we don't break any compatibility here. --- source/blender/editors/space_view3d/drawmesh.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index ee82a4c5072..4326d45be83 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -979,11 +979,13 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d if (ob == OBACT) { if (ob->mode & OB_MODE_WEIGHT_PAINT) { dm_draw_flag |= DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH | DM_DRAW_SKIP_HIDDEN; - } else if (ob->mode & OB_MODE_SCULPT) { dm_draw_flag |= DM_DRAW_SKIP_HIDDEN; } + else if ((ob->mode & OB_MODE_ALL_PAINT) == 0) { + dm_draw_flag |= DM_DRAW_USE_COLORS; + } } From 9e173afca30b0c7b2762d13eeeea595400877506 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 29 Jun 2016 18:12:59 +1000 Subject: [PATCH 10/14] Cleanup: endian tests --- source/blender/blenloader/intern/readfile.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 323f0a93e05..325f846669b 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -880,8 +880,6 @@ static void decode_blender_header(FileData *fd) if (readsize == sizeof(header)) { if (STREQLEN(header, "BLENDER", 7)) { - int remove_this_endian_test = 1; - fd->flags |= FD_FLAGS_FILE_OK; /* what size are pointers in the file ? */ @@ -900,7 +898,7 @@ static void decode_blender_header(FileData *fd) /* is the file saved in a different endian * than we need ? */ - if (((((char *)&remove_this_endian_test)[0] == 1) ? L_ENDIAN : B_ENDIAN) != ((header[8] == 'v') ? L_ENDIAN : B_ENDIAN)) { + if (((header[8] == 'v') ? L_ENDIAN : B_ENDIAN) != ENDIAN_ORDER) { fd->flags |= FD_FLAGS_SWITCH_ENDIAN; } From 68fcc3b1f6f14873c8b5bc7d47f46d7ac20dfc79 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 29 Jun 2016 13:30:58 +0500 Subject: [PATCH 11/14] Correction to previous commit: Only skip colors for texture paint This way we avoid regression of sculpt mode shading. Hopefully now it's all fine. --- source/blender/editors/space_view3d/drawmesh.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 4326d45be83..a8df5c02881 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -981,9 +981,9 @@ static void draw_mesh_textured_old(Scene *scene, View3D *v3d, RegionView3D *rv3d dm_draw_flag |= DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH | DM_DRAW_SKIP_HIDDEN; } else if (ob->mode & OB_MODE_SCULPT) { - dm_draw_flag |= DM_DRAW_SKIP_HIDDEN; + dm_draw_flag |= DM_DRAW_SKIP_HIDDEN | DM_DRAW_USE_COLORS; } - else if ((ob->mode & OB_MODE_ALL_PAINT) == 0) { + else if ((ob->mode & OB_MODE_TEXTURE_PAINT) == 0) { dm_draw_flag |= DM_DRAW_USE_COLORS; } } From 2e41df6847b0234fc4ee17adbaff817702450446 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Wed, 29 Jun 2016 19:31:57 +1000 Subject: [PATCH 12/14] Fix T48695: Slowdown w/ edit-mesh & shrinkwrap 0b5a0d84 caused regression since edit-mesh BVH wasn't cached, each shrink-wrap modifier created its own BVH. --- source/blender/blenkernel/BKE_bvhutils.h | 20 ++++--- source/blender/blenkernel/intern/bvhutils.c | 48 +++++++++++++---- source/blender/blenkernel/intern/shrinkwrap.c | 54 ++++++++++++------- .../editors/transform/transform_snap_object.c | 2 +- 4 files changed, 86 insertions(+), 38 deletions(-) diff --git a/source/blender/blenkernel/BKE_bvhutils.h b/source/blender/blenkernel/BKE_bvhutils.h index 7bd3ca88076..7ec91b006b2 100644 --- a/source/blender/blenkernel/BKE_bvhutils.h +++ b/source/blender/blenkernel/BKE_bvhutils.h @@ -43,6 +43,8 @@ struct BMEditMesh; struct MVert; struct MFace; +typedef struct LinkNode BVHCache; + /** * struct that kepts basic information about a BVHTree build from a editmesh */ @@ -54,11 +56,13 @@ typedef struct BVHTreeFromEditMesh { BVHTree_RayCastCallback raycast_callback; BVHTree_NearestToRayCallback nearest_to_ray_callback; + struct BMEditMesh *em; + /* radius for raycast */ float sphere_radius; /* Private data */ - struct BMEditMesh *em; + bool cached; } BVHTreeFromEditMesh; @@ -133,12 +137,12 @@ BVHTree *bvhtree_from_mesh_faces_ex( float epsilon, int tree_type, int axis); BVHTree *bvhtree_from_editmesh_looptri( - BVHTreeFromEditMesh *data, struct BMEditMesh *em, float epsilon, - int tree_type, int axis); + BVHTreeFromEditMesh *data, struct BMEditMesh *em, + float epsilon, int tree_type, int axis, BVHCache **bvhCache); BVHTree *bvhtree_from_editmesh_looptri_ex( BVHTreeFromEditMesh *data, struct BMEditMesh *em, const BLI_bitmap *mask, int looptri_num_active, - float epsilon, int tree_type, int axis); + float epsilon, int tree_type, int axis, BVHCache **bvhCache); BVHTree *bvhtree_from_mesh_looptri( struct BVHTreeFromMesh *data, struct DerivedMesh *mesh, float epsilon, int tree_type, int axis); @@ -165,9 +169,7 @@ float bvhtree_ray_tri_intersection( float bvhtree_sphereray_tri_intersection( const BVHTreeRay *ray, float radius, const float m_dist, const float v0[3], const float v1[3], const float v2[3]); -float nearest_point_in_tri_surface_squared( - const float v0[3], const float v1[3], const float v2[3], - const float p[3], int *v, int *e, float nearest[3]); + /** * BVHCache @@ -179,9 +181,10 @@ enum { BVHTREE_FROM_EDGES = 1, BVHTREE_FROM_FACES = 2, BVHTREE_FROM_LOOPTRI = 3, + + BVHTREE_FROM_EM_LOOPTRI = 4, }; -typedef struct LinkNode BVHCache; BVHTree *bvhcache_find(BVHCache *cache, int type); bool bvhcache_has_tree(const BVHCache *cache, const BVHTree *tree); @@ -189,4 +192,5 @@ void bvhcache_insert(BVHCache **cache_p, BVHTree *tree, int type); void bvhcache_init(BVHCache **cache_p); void bvhcache_free(BVHCache **cache_p); + #endif diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index e0277c38e61..a3cfe3f80b4 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -968,17 +968,37 @@ static void bvhtree_from_mesh_looptri_setup_data( BVHTree *bvhtree_from_editmesh_looptri_ex( BVHTreeFromEditMesh *data, BMEditMesh *em, const BLI_bitmap *looptri_mask, int looptri_num_active, - float epsilon, int tree_type, int axis) + float epsilon, int tree_type, int axis, BVHCache **bvhCache) { /* BMESH specific check that we have tessfaces, - * we _could_ tessellate here but rather not - campbell - * - * this assert checks we have tessfaces, - * if not caller should use DM_ensure_tessface() */ + * we _could_ tessellate here but rather not - campbell */ - BVHTree *tree = bvhtree_from_editmesh_looptri_create_tree( - epsilon, tree_type, axis, - em, em->tottri, looptri_mask, looptri_num_active); + BVHTree *tree; + if (bvhCache) { + BLI_rw_mutex_lock(&cache_rwlock, THREAD_LOCK_READ); + tree = bvhcache_find(*bvhCache, BVHTREE_FROM_EM_LOOPTRI); + BLI_rw_mutex_unlock(&cache_rwlock); + if (tree == NULL) { + BLI_rw_mutex_lock(&cache_rwlock, THREAD_LOCK_WRITE); + tree = bvhcache_find(*bvhCache, BVHTREE_FROM_EM_LOOPTRI); + if (tree == NULL) { + tree = bvhtree_from_editmesh_looptri_create_tree( + epsilon, tree_type, axis, + em, em->tottri, looptri_mask, looptri_num_active); + if (tree) { + /* Save on cache for later use */ + /* printf("BVHTree built and saved on cache\n"); */ + bvhcache_insert(bvhCache, tree, BVHTREE_FROM_EM_LOOPTRI); + } + } + BLI_rw_mutex_unlock(&cache_rwlock); + } + } + else { + tree = bvhtree_from_editmesh_looptri_create_tree( + epsilon, tree_type, axis, + em, em->tottri, looptri_mask, looptri_num_active); + } if (tree) { data->tree = tree; @@ -987,17 +1007,18 @@ BVHTree *bvhtree_from_editmesh_looptri_ex( data->nearest_to_ray_callback = NULL; data->sphere_radius = 0.0f; data->em = em; + data->cached = bvhCache != NULL; } return tree; } BVHTree *bvhtree_from_editmesh_looptri( BVHTreeFromEditMesh *data, BMEditMesh *em, - float epsilon, int tree_type, int axis) + float epsilon, int tree_type, int axis, BVHCache **bvhCache) { return bvhtree_from_editmesh_looptri_ex( data, em, NULL, -1, - epsilon, tree_type, axis); + epsilon, tree_type, axis, bvhCache); } /** @@ -1045,6 +1066,9 @@ BVHTree *bvhtree_from_mesh_looptri( tree = bvhcache_find(dm->bvhCache, BVHTREE_FROM_LOOPTRI); if (tree == NULL) { int looptri_num = dm->getNumLoopTri(dm); + + /* this assert checks we have looptris, + * if not caller should use DM_ensure_looptri() */ BLI_assert(!(looptri_num == 0 && dm->getNumPolys(dm) != 0)); tree = bvhtree_from_mesh_looptri_create_tree( @@ -1102,7 +1126,9 @@ BVHTree *bvhtree_from_mesh_looptri_ex( void free_bvhtree_from_editmesh(struct BVHTreeFromEditMesh *data) { if (data->tree) { - BLI_bvhtree_free(data->tree); + if (!data->cached) { + BLI_bvhtree_free(data->tree); + } memset(data, 0, sizeof(*data)); } } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 518d8d68919..7094d5a3547 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -405,21 +405,28 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for /* use editmesh to avoid array allocation */ BMEditMesh *emtarget = NULL, *emaux = NULL; - BVHTreeFromEditMesh emtreedata_stack, emauxdata_stack; - BVHTreeFromMesh dmtreedata_stack, dmauxdata_stack; + union { + BVHTreeFromEditMesh emtreedata; + BVHTreeFromMesh dmtreedata; + } treedata_stack, auxdata_stack; + BVHTree *targ_tree; void *targ_callback; if (calc->smd->target && calc->target->type == DM_TYPE_EDITBMESH) { emtarget = BKE_editmesh_from_object(calc->smd->target); - if ((targ_tree = bvhtree_from_editmesh_looptri(&emtreedata_stack, emtarget, 0.0, 4, 6))) { - targ_callback = emtreedata_stack.raycast_callback; - treeData = &emtreedata_stack; + if ((targ_tree = bvhtree_from_editmesh_looptri( + &treedata_stack.emtreedata, emtarget, 0.0, 4, 6, &calc->target->bvhCache))) + { + targ_callback = treedata_stack.emtreedata.raycast_callback; + treeData = &treedata_stack.emtreedata; } } else { - if ((targ_tree = bvhtree_from_mesh_looptri(&dmtreedata_stack, calc->target, 0.0, 4, 6))) { - targ_callback = dmtreedata_stack.raycast_callback; - treeData = &dmtreedata_stack; + if ((targ_tree = bvhtree_from_mesh_looptri( + &treedata_stack.dmtreedata, calc->target, 0.0, 4, 6))) + { + targ_callback = treedata_stack.dmtreedata.raycast_callback; + treeData = &treedata_stack.dmtreedata; } } if (targ_tree) { @@ -429,15 +436,17 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for /* use editmesh to avoid array allocation */ if (calc->smd->auxTarget && auxMesh->type == DM_TYPE_EDITBMESH) { emaux = BKE_editmesh_from_object(calc->smd->auxTarget); - if ((aux_tree = bvhtree_from_editmesh_looptri(&emauxdata_stack, emaux, 0.0, 4, 6)) != NULL) { - aux_callback = emauxdata_stack.raycast_callback; - auxData = &emauxdata_stack; + if ((aux_tree = bvhtree_from_editmesh_looptri( + &auxdata_stack.emtreedata, emaux, 0.0, 4, 6, &auxMesh->bvhCache))) + { + aux_callback = auxdata_stack.emtreedata.raycast_callback; + auxData = &auxdata_stack.emtreedata; } } else { - if ((aux_tree = bvhtree_from_mesh_looptri(&dmauxdata_stack, auxMesh, 0.0, 4, 6)) != NULL) { - aux_callback = dmauxdata_stack.raycast_callback; - auxData = &dmauxdata_stack; + if ((aux_tree = bvhtree_from_mesh_looptri(&auxdata_stack.dmtreedata, auxMesh, 0.0, 4, 6)) != NULL) { + aux_callback = auxdata_stack.dmtreedata.raycast_callback; + auxData = &auxdata_stack.dmtreedata; } } } @@ -455,12 +464,21 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, bool for /* free data structures */ if (treeData) { - if (emtarget) free_bvhtree_from_editmesh(treeData); - else free_bvhtree_from_mesh(treeData); + if (emtarget) { + free_bvhtree_from_editmesh(treeData); + } + else { + free_bvhtree_from_mesh(treeData); + } } + if (auxData) { - if (emaux) free_bvhtree_from_editmesh(auxData); - else free_bvhtree_from_mesh(auxData); + if (emaux) { + free_bvhtree_from_editmesh(auxData); + } + else { + free_bvhtree_from_mesh(auxData); + } } } diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 28ad1d93215..357d40e6ee2 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -1059,7 +1059,7 @@ static bool snapEditMesh( em->bm, looptri_mask, sctx->callbacks.edit_mesh.test_face_fn, sctx->callbacks.edit_mesh.user_data); } - bvhtree_from_editmesh_looptri_ex(treedata, em, looptri_mask, looptri_num_active, 0.0f, 4, 6); + bvhtree_from_editmesh_looptri_ex(treedata, em, looptri_mask, looptri_num_active, 0.0f, 4, 6, NULL); if (looptri_mask) { MEM_freeN(looptri_mask); } From 0971749f4cdc6c5263b91f652c1d78c97e30b973 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 29 Jun 2016 20:37:54 +1000 Subject: [PATCH 13/14] Cleanup: spelling, indentation --- .../blender/blenkernel/intern/library_remap.c | 2 +- source/blender/blenlib/intern/task.c | 3 ++- source/blender/blenloader/intern/readfile.c | 2 +- source/blender/blenloader/intern/writefile.c | 2 +- source/blender/editors/animation/drivers.c | 2 +- .../editors/space_action/action_select.c | 2 +- .../editors/space_outliner/outliner_edit.c | 8 +++---- .../editors/space_outliner/outliner_tools.c | 22 +++++++++---------- .../editors/transform/transform_snap_object.c | 6 ++--- source/blender/makesrna/intern/rna_access.c | 2 +- .../windowmanager/intern/wm_files_link.c | 2 +- 11 files changed, 27 insertions(+), 26 deletions(-) diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index f08315b7896..10dd123a121 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -393,7 +393,7 @@ void BKE_libblock_remap_locked( if (old_ob->flag & OB_FROMGROUP) { /* Note that for Scene's BaseObject->flag, either we: * - unlinked old_ob (i.e. new_ob is NULL), in which case scenes' bases have been removed already. - * - remaped old_ob by new_ob, in which case scenes' bases are still valid as is. + * - remapped old_ob by new_ob, in which case scenes' bases are still valid as is. * So in any case, no need to update them here. */ if (BKE_group_object_find(NULL, old_ob) == NULL) { old_ob->flag &= ~OB_FROMGROUP; diff --git a/source/blender/blenlib/intern/task.c b/source/blender/blenlib/intern/task.c index 0b299af88aa..bd7b7f9cdbd 100644 --- a/source/blender/blenlib/intern/task.c +++ b/source/blender/blenlib/intern/task.c @@ -992,7 +992,8 @@ void BLI_task_parallel_range( * (similar to OpenMP's firstprivate). * \param userdata_chunk_size Memory size of \a userdata_chunk. * \param func_ex Callback function (advanced version). - * \param func_finalize Callback function, called after all workers have finisehd, useful to finalize accumulative tasks. + * \param func_finalize Callback function, called after all workers have finished, + * useful to finalize accumulative tasks. * \param use_threading If \a true, actually split-execute loop in threads, else just do a sequential forloop * (allows caller to use any kind of test to switch on parallelization or not). * \param use_dynamic_scheduling If \a true, the whole range is divided in a lot of small chunks (of size 32 currently), diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 325f846669b..b09ea45469c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6450,7 +6450,7 @@ static void *restore_pointer_by_name_main(Main *mainp, ID *id, ePointerUserMode * - USER_IGNORE: no usercount change * - USER_REAL: ensure a real user (even if a fake one is set) * \param id_map: lookup table, use when performing many lookups. - * this could be made an optional agument (falling back to a full lookup), + * this could be made an optional argument (falling back to a full lookup), * however at the moment it's always available. */ static void *restore_pointer_by_name(struct IDNameLib_Map *id_map, ID *id, ePointerUserMode user) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 2c8bb92ac4b..19fb80ffb66 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -514,7 +514,7 @@ static void writestruct_at_address_id( static void writestruct_nr( WriteData *wd, int filecode, const int struct_nr, int nr, - const void *adr) + const void *adr) { writestruct_at_address_nr(wd, filecode, struct_nr, nr, adr, adr); } diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index c24ca1e7027..21c25f829b1 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -209,7 +209,7 @@ static int add_driver_with_target( * (The only issue is with quat rotations vs euler channels...) * - To avoid problems with transform properties depending on the final transform that they * control (thus creating pseudo-cycles - see T48734), we don't use transform channels - * when both the source and destinaions are in same places. + * when both the source and destinations are in same places. */ dvar = driver_add_new_variable(driver); diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 0b6d3cb1f60..7900217e28e 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -379,7 +379,7 @@ void ACTION_OT_select_border(wmOperatorType *ot) /* ******************** Region Select Operators ***************************** */ /* "Region Select" operators include the Lasso and Circle Select operators. * These two ended up being lumped together, as it was easier in the - * original Graph Editor implmentation of these to do it this way. + * original Graph Editor implementation of these to do it this way. */ static void region_select_action_keys(bAnimContext *ac, const rctf *rectf_view, short mode, short selectmode, void *data) diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 57d9ff7825b..2618a14aa0d 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -416,7 +416,7 @@ static int outliner_id_remap_exec(bContext *C, wmOperator *op) } BKE_libblock_remap(bmain, old_id, new_id, - ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_NEVER_NULL_USAGE); + ID_REMAP_SKIP_INDIRECT_USAGE | ID_REMAP_SKIP_NEVER_NULL_USAGE); BKE_main_lib_objects_recalc_all(bmain); @@ -541,7 +541,7 @@ void id_remap_cb( /* Library relocate/reload --------------------------------------------------- */ static int lib_relocate( - bContext *C, TreeElement *te, TreeStoreElem *tselem, wmOperatorType *ot, const bool reload) + bContext *C, TreeElement *te, TreeStoreElem *tselem, wmOperatorType *ot, const bool reload) { PointerRNA op_props; int ret = 0; @@ -579,7 +579,7 @@ static int lib_relocate( } static int outliner_lib_relocate_invoke_do( - bContext *C, ReportList *reports, TreeElement *te, const float mval[2], const bool reload) + bContext *C, ReportList *reports, TreeElement *te, const float mval[2], const bool reload) { if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { TreeStoreElem *tselem = TREESTORE(te); @@ -642,7 +642,7 @@ void OUTLINER_OT_lib_relocate(wmOperatorType *ot) } /* XXX This does not work with several items - * (it is only called once in the end, due to the 'deffered' filebrowser invocation through event system...). */ + * (it is only called once in the end, due to the 'deferred' filebrowser invocation through event system...). */ void lib_relocate_cb( bContext *C, Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem, void *UNUSED(user_data)) diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 265df4a8def..e80ba5d40df 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -864,8 +864,8 @@ static EnumPropertyItem prop_object_op_types[] = { {OL_OP_SELECT_HIERARCHY, "SELECT_HIERARCHY", 0, "Select Hierarchy", ""}, {OL_OP_DELETE, "DELETE", 0, "Delete", ""}, {OL_OP_DELETE_HIERARCHY, "DELETE_HIERARCHY", 0, "Delete Hierarchy", ""}, - {OL_OP_REMAP, "REMAP", 0, "Remap Users", - "Make all users of selected datablocks to use instead a new chosen one"}, + {OL_OP_REMAP, "REMAP", 0, "Remap Users", + "Make all users of selected datablocks to use instead a new chosen one"}, {OL_OP_TOGVIS, "TOGVIS", 0, "Toggle Visible", ""}, {OL_OP_TOGSEL, "TOGSEL", 0, "Toggle Selectable", ""}, {OL_OP_TOGREN, "TOGREN", 0, "Toggle Renderable", ""}, @@ -1009,9 +1009,9 @@ static EnumPropertyItem prop_group_op_types[] = { {OL_GROUPOP_UNLINK, "UNLINK", 0, "Unlink Group", ""}, {OL_GROUPOP_LOCAL, "LOCAL", 0, "Make Local Group", ""}, {OL_GROUPOP_LINK, "LINK", 0, "Link Group Objects to Scene", ""}, - {OL_GROUPOP_DELETE, "DELETE", 0, "Delete Group", "WARNING: no undo"}, - {OL_GROUPOP_REMAP, "REMAP", 0, "Remap Users", - "Make all users of selected datablocks to use instead current (clicked) one"}, + {OL_GROUPOP_DELETE, "DELETE", 0, "Delete Group", "WARNING: no undo"}, + {OL_GROUPOP_REMAP, "REMAP", 0, "Remap Users", + "Make all users of selected datablocks to use instead current (clicked) one"}, {OL_GROUPOP_INSTANCE, "INSTANCE", 0, "Instance Groups in Scene", ""}, {OL_GROUPOP_TOGVIS, "TOGVIS", 0, "Toggle Visible Group", ""}, {OL_GROUPOP_TOGSEL, "TOGSEL", 0, "Toggle Selectable", ""}, @@ -1116,9 +1116,9 @@ static EnumPropertyItem prop_id_op_types[] = { {OUTLINER_IDOP_UNLINK, "UNLINK", 0, "Unlink", ""}, {OUTLINER_IDOP_LOCAL, "LOCAL", 0, "Make Local", ""}, {OUTLINER_IDOP_SINGLE, "SINGLE", 0, "Make Single User", ""}, - {OUTLINER_IDOP_DELETE, "DELETE", 0, "Delete", "WARNING: no undo"}, - {OUTLINER_IDOP_REMAP, "REMAP", 0, "Remap Users", - "Make all users of selected datablocks to use instead current (clicked) one"}, + {OUTLINER_IDOP_DELETE, "DELETE", 0, "Delete", "WARNING: no undo"}, + {OUTLINER_IDOP_REMAP, "REMAP", 0, "Remap Users", + "Make all users of selected datablocks to use instead current (clicked) one"}, {OUTLINER_IDOP_FAKE_ADD, "ADD_FAKE", 0, "Add Fake User", "Ensure datablock gets saved even if it isn't in use (e.g. for motion and material libraries)"}, {OUTLINER_IDOP_FAKE_CLEAR, "CLEAR_FAKE", 0, "Clear Fake User", ""}, @@ -1299,9 +1299,9 @@ typedef enum eOutlinerLibOpTypes { static EnumPropertyItem outliner_lib_op_type_items[] = { {OL_LIB_RENAME, "RENAME", 0, "Rename", ""}, - {OL_LIB_DELETE, "DELETE", 0, "Delete", "Delete this library and all its item from Blender - WARNING: no undo"}, - {OL_LIB_RELOCATE, "RELOCATE", 0, "Relocate", "Select a new path for this library, and reload all its data"}, - {OL_LIB_RELOAD, "RELOAD", 0, "Reload", "Reload all data from this library"}, + {OL_LIB_DELETE, "DELETE", 0, "Delete", "Delete this library and all its item from Blender - WARNING: no undo"}, + {OL_LIB_RELOCATE, "RELOCATE", 0, "Relocate", "Select a new path for this library, and reload all its data"}, + {OL_LIB_RELOAD, "RELOAD", 0, "Reload", "Reload all data from this library"}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 357d40e6ee2..897b6609721 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -1672,7 +1672,7 @@ bool ED_transform_snap_object_project_view3d_ex( float *ray_depth, float r_loc[3], float r_no[3], int *r_index) { - float ray_start[3], ray_normal[3], ray_orgigin[3]; + float ray_start[3], ray_normal[3], ray_origin[3]; float ray_depth_fallback; if (ray_depth == NULL) { @@ -1682,7 +1682,7 @@ bool ED_transform_snap_object_project_view3d_ex( if (!ED_view3d_win_to_ray_ex( sctx->v3d_data.ar, sctx->v3d_data.v3d, - mval, ray_orgigin, ray_normal, ray_start, true)) + mval, ray_origin, ray_normal, ray_start, true)) { return false; } @@ -1691,7 +1691,7 @@ bool ED_transform_snap_object_project_view3d_ex( sctx, snap_to, params->snap_select, params->use_object_edit_cage, mval, dist_px, - ray_start, ray_normal, ray_orgigin, ray_depth, + ray_start, ray_normal, ray_origin, ray_depth, r_loc, r_no, r_index, NULL, NULL, NULL); } diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index c49a6197a4e..0eaeabccd99 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -4678,7 +4678,7 @@ static void rna_path_array_multi_string_from_flat_index( } /** - * \param index_dim: The dimensiuon to show, 0 disables. 1 for 1d array, 2 for 2d. etc. + * \param index_dim: The dimension to show, 0 disables. 1 for 1d array, 2 for 2d. etc. * \param index: The *flattened* index to use when \a ``index_dim > 0``, * this is expanded when used with multi-dimensional arrays. */ diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index 3709e10b366..12ad8f91064 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -264,7 +264,7 @@ static void wm_link_do( mainl, &bh, item->idcode, item->name, flag, scene, v3d, use_placeholders, force_indirect); if (new_id) { - /* If the link is sucessful, clear item's libs 'todo' flags. + /* If the link is successful, clear item's libs 'todo' flags. * This avoids trying to link same item with other libraries to come. */ BLI_BITMAP_SET_ALL(item->libraries, false, lapp_data->num_libraries); item->new_id = new_id; From 903cb13bb8dfe5c3e093aeb76b245f17b1400f70 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 29 Jun 2016 23:22:54 +1000 Subject: [PATCH 14/14] Cleanup: use const --- .../ED_transform_snap_object_context.h | 2 +- source/blender/editors/include/ED_view3d.h | 10 ++++---- .../editors/space_view3d/view3d_project.c | 19 ++++++++------- .../editors/transform/transform_snap_object.c | 24 +++++++++---------- 4 files changed, 30 insertions(+), 25 deletions(-) diff --git a/source/blender/editors/include/ED_transform_snap_object_context.h b/source/blender/editors/include/ED_transform_snap_object_context.h index baf4ed574cf..7944b434057 100644 --- a/source/blender/editors/include/ED_transform_snap_object_context.h +++ b/source/blender/editors/include/ED_transform_snap_object_context.h @@ -75,7 +75,7 @@ SnapObjectContext *ED_transform_snap_object_context_create( SnapObjectContext *ED_transform_snap_object_context_create_view3d( struct Main *bmain, struct Scene *scene, int flag, /* extra args for view3d */ - struct ARegion *ar, struct View3D *v3d); + const struct ARegion *ar, const struct View3D *v3d); void ED_transform_snap_object_context_destroy(SnapObjectContext *sctx); /* callbacks to filter how snap works */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index baab6b6100d..b09284aa759 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -208,10 +208,12 @@ eV3DProjStatus ED_view3d_project_float_global(const struct ARegion *ar, const fl eV3DProjStatus ED_view3d_project_float_object(const struct ARegion *ar, const float co[3], float r_co[2], const eV3DProjTest flag); float ED_view3d_calc_zfac(const struct RegionView3D *rv3d, const float co[3], bool *r_flip); -bool ED_view3d_win_to_ray(const struct ARegion *ar, struct View3D *v3d, const float mval[2], - float ray_start[3], float ray_normal[3], const bool do_clip); -bool ED_view3d_win_to_ray_ex(const struct ARegion *ar, struct View3D *v3d, const float mval[2], - float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], bool do_clip); +bool ED_view3d_win_to_ray( + const struct ARegion *ar, const struct View3D *v3d, const float mval[2], + float ray_start[3], float ray_normal[3], const bool do_clip); +bool ED_view3d_win_to_ray_ex( + const struct ARegion *ar, const struct View3D *v3d, const float mval[2], + float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], bool do_clip); void ED_view3d_global_to_vector(const struct RegionView3D *rv3d, const float coord[3], float vec[3]); void ED_view3d_win_to_3d(const struct ARegion *ar, const float depth_pt[3], const float mval[2], float out[3]); void ED_view3d_win_to_3d_int(const struct ARegion *ar, const float depth_pt[3], const int mval[2], float out[3]); diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index 797d97586c7..ac05853e6d0 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -302,8 +302,9 @@ float ED_view3d_calc_zfac(const RegionView3D *rv3d, const float co[3], bool *r_f return zfac; } -static void view3d_win_to_ray_segment(const ARegion *ar, View3D *v3d, const float mval[2], - float r_ray_co[3], float r_ray_dir[3], float r_ray_start[3], float r_ray_end[3]) +static void view3d_win_to_ray_segment( + const ARegion *ar, const View3D *v3d, const float mval[2], + float r_ray_co[3], float r_ray_dir[3], float r_ray_start[3], float r_ray_end[3]) { RegionView3D *rv3d = ar->regiondata; float _ray_co[3], _ray_dir[3], start_offset, end_offset; @@ -346,7 +347,7 @@ static void view3d_win_to_ray_segment(const ARegion *ar, View3D *v3d, const floa } } -BLI_INLINE bool view3d_clip_segment(RegionView3D *rv3d, float ray_start[3], float ray_end[3]) +BLI_INLINE bool view3d_clip_segment(const RegionView3D *rv3d, float ray_start[3], float ray_end[3]) { if ((rv3d->rflag & RV3D_CLIPPING) && (clip_segment_v3_plane_n(ray_start, ray_end, rv3d->clip, 6, @@ -373,8 +374,9 @@ BLI_INLINE bool view3d_clip_segment(RegionView3D *rv3d, float ray_start[3], floa * \param do_clip Optionally clip the start of the ray by the view clipping planes. * \return success, false if the ray is totally clipped. */ -bool ED_view3d_win_to_ray_ex(const ARegion *ar, View3D *v3d, const float mval[2], - float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], bool do_clip) +bool ED_view3d_win_to_ray_ex( + const ARegion *ar, const View3D *v3d, const float mval[2], + float r_ray_co[3], float r_ray_normal[3], float r_ray_start[3], bool do_clip) { float ray_end[3]; @@ -382,7 +384,7 @@ bool ED_view3d_win_to_ray_ex(const ARegion *ar, View3D *v3d, const float mval[2] /* bounds clipping */ if (do_clip) { - return view3d_clip_segment((RegionView3D *)ar->regiondata, r_ray_start, ray_end); + return view3d_clip_segment(ar->regiondata, r_ray_start, ray_end); } return true; @@ -401,8 +403,9 @@ bool ED_view3d_win_to_ray_ex(const ARegion *ar, View3D *v3d, const float mval[2] * \param do_clip Optionally clip the start of the ray by the view clipping planes. * \return success, false if the ray is totally clipped. */ -bool ED_view3d_win_to_ray(const ARegion *ar, View3D *v3d, const float mval[2], - float r_ray_start[3], float r_ray_normal[3], const bool do_clip) +bool ED_view3d_win_to_ray( + const ARegion *ar, const View3D *v3d, const float mval[2], + float r_ray_start[3], float r_ray_normal[3], const bool do_clip) { return ED_view3d_win_to_ray_ex(ar, v3d, mval, NULL, r_ray_normal, r_ray_start, do_clip); } diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 897b6609721..0e1a65e073f 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -87,8 +87,8 @@ struct SnapObjectContext { * otherwise this doesn't take viewport into account. */ bool use_v3d; struct { - struct View3D *v3d; - struct ARegion *ar; + const struct View3D *v3d; + const struct ARegion *ar; } v3d_data; @@ -222,7 +222,7 @@ static void raycast_all_cb(void *userdata, int index, const BVHTreeRay *ray, BVH * \{ */ static bool snapEdge( - ARegion *ar, const float v1co[3], const short v1no[3], const float v2co[3], const short v2no[3], + const ARegion *ar, const float v1co[3], const short v1no[3], const float v2co[3], const short v2no[3], float obmat[4][4], float timat[3][3], const float mval_fl[2], float *dist_px, const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], float *ray_depth, float r_loc[3], float r_no[3]) @@ -312,7 +312,7 @@ static bool snapEdge( } static bool snapVertex( - ARegion *ar, const float vco[3], const float vno[3], + const ARegion *ar, const float vco[3], const float vno[3], float obmat[4][4], float timat[3][3], const float mval_fl[2], float *dist_px, const float ray_start[3], const float ray_start_local[3], const float ray_normal_local[3], float *ray_depth, float r_loc[3], float r_no[3]) @@ -362,7 +362,7 @@ static bool snapVertex( } static bool snapArmature( - ARegion *ar, Object *ob, bArmature *arm, float obmat[4][4], + const ARegion *ar, Object *ob, bArmature *arm, float obmat[4][4], const float mval[2], float *dist_px, const short snap_to, const float ray_start[3], const float ray_normal[3], float *ray_depth, float r_loc[3], float *UNUSED(r_no)) @@ -444,7 +444,7 @@ static bool snapArmature( } static bool snapCurve( - ARegion *ar, Object *ob, Curve *cu, float obmat[4][4], + const ARegion *ar, Object *ob, Curve *cu, float obmat[4][4], const float mval[2], float *dist_px, const short snap_to, const float ray_start[3], const float ray_normal[3], float *ray_depth, float r_loc[3], float *UNUSED(r_no)) @@ -542,7 +542,7 @@ static bool snapCurve( /* may extend later (for now just snaps to empty center) */ static bool snapEmpty( - ARegion *ar, Object *ob, float obmat[4][4], + const ARegion *ar, Object *ob, float obmat[4][4], const float mval[2], float *dist_px, const short snap_to, const float ray_start[3], const float ray_normal[3], float *ray_depth, float r_loc[3], float *UNUSED(r_no)) @@ -582,7 +582,7 @@ static bool snapEmpty( } static bool snapCamera( - ARegion *ar, Scene *scene, Object *object, float obmat[4][4], + const ARegion *ar, Scene *scene, Object *object, float obmat[4][4], const float mval[2], float *dist_px, const short snap_to, const float ray_start[3], const float ray_normal[3], float *ray_depth, float r_loc[3], float *UNUSED(r_no)) @@ -683,7 +683,7 @@ static bool snapDerivedMesh( float r_loc[3], float r_no[3], int *r_index, ListBase *r_hit_list) { - ARegion *ar = sctx->v3d_data.ar; + const ARegion *ar = sctx->v3d_data.ar; bool retval = false; if (snap_to == SCE_SNAP_MODE_FACE) { @@ -965,7 +965,7 @@ static bool snapEditMesh( float r_loc[3], float r_no[3], int *r_index, ListBase *r_hit_list) { - ARegion *ar = sctx->v3d_data.ar; + const ARegion *ar = sctx->v3d_data.ar; bool retval = false; if (snap_to == SCE_SNAP_MODE_FACE) { @@ -1242,7 +1242,7 @@ static bool snapObject( Object **r_ob, float r_obmat[4][4], ListBase *r_hit_list) { - ARegion *ar = sctx->v3d_data.ar; + const ARegion *ar = sctx->v3d_data.ar; bool retval = false; if (ob->type == OB_MESH) { @@ -1419,7 +1419,7 @@ SnapObjectContext *ED_transform_snap_object_context_create( SnapObjectContext *ED_transform_snap_object_context_create_view3d( Main *bmain, Scene *scene, int flag, /* extra args for view3d */ - ARegion *ar, View3D *v3d) + const ARegion *ar, const View3D *v3d) { SnapObjectContext *sctx = ED_transform_snap_object_context_create(bmain, scene, flag);