diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-10-29 14:52:05 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-10-29 14:52:05 +0300 |
commit | 67115dbcc184858cde0c29c6337e6b18f7369d16 (patch) | |
tree | b969d9bedd171110ea7ad20271f41630d290126c | |
parent | b230ca2a90df8b40f32b11082971fbc3cba9b13b (diff) | |
parent | 6a4a911fc39ffc5f5a43cf6da46bd6af34167992 (diff) |
Merge branch 'master' into libmv_prediction
94 files changed, 583 insertions, 371 deletions
diff --git a/build_files/scons/tools/Blender.py b/build_files/scons/tools/Blender.py index b5853b22455..d8094c0cf8c 100755 --- a/build_files/scons/tools/Blender.py +++ b/build_files/scons/tools/Blender.py @@ -813,6 +813,9 @@ def AppIt(target=None, source=None, env=None): commands.getoutput(cmd) cmd = 'install_name_tool -change @loader_path/libiomp5.dylib @loader_path/../Resources/lib/libiomp5.dylib %s/%s.app/Contents/MacOS/%s'%(installdir, binary, binary) # change ref to libiomp5 ( blender ) commands.getoutput(cmd) + notification = 'display notification "Finished compiling %s" with title "Blender" sound name "default"'%(binary.upper()) + cmd = "osascript -e '%s'"%(notification) + commands.getoutput(cmd) # extract copy system python, be sure to update other build systems # when making changes to the files that are copied. diff --git a/doc/python_api/rst/info_tutorial_addon.rst b/doc/python_api/rst/info_tutorial_addon.rst index 5637cf2f638..436f74bc441 100644 --- a/doc/python_api/rst/info_tutorial_addon.rst +++ b/doc/python_api/rst/info_tutorial_addon.rst @@ -563,20 +563,26 @@ Bringing it all together # handle the keymap wm = bpy.context.window_manager - km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY') - kmi = km.keymap_items.new(ObjectCursorArray.bl_idname, 'SPACE', 'PRESS', ctrl=True, shift=True) - kmi.properties.total = 4 - addon_keymaps.append((km, kmi)) + # Note that in background mode (no GUI available), keyconfigs are not available either, so we have to check this + # to avoid nasty errors in background case. + kc = wm.keyconfigs.addon + if kc: + km = wm.keyconfigs.addon.keymaps.new(name='Object Mode', space_type='EMPTY') + kmi = km.keymap_items.new(ObjectCursorArray.bl_idname, 'SPACE', 'PRESS', ctrl=True, shift=True) + kmi.properties.total = 4 + addon_keymaps.append((km, kmi)) def unregister(): - bpy.utils.unregister_class(ObjectCursorArray) - bpy.types.VIEW3D_MT_object.remove(menu_func) - + # Note: when unregistering, it's usually good practice to do it in reverse order you registered. + # Can avoid strange issues like keymap still referring to operators already unregistered... # handle the keymap for km, kmi in addon_keymaps: km.keymap_items.remove(kmi) addon_keymaps.clear() + bpy.utils.unregister_class(ObjectCursorArray) + bpy.types.VIEW3D_MT_object.remove(menu_func) + if __name__ == "__main__": register() diff --git a/extern/clew/include/clew.h b/extern/clew/include/clew.h index 624fdb299fe..f4a50dd7254 100644 --- a/extern/clew/include/clew.h +++ b/extern/clew/include/clew.h @@ -1815,6 +1815,11 @@ typedef struct _cl_buffer_region { /* Function signature typedef's */ +#ifdef __APPLE__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wignored-attributes" +#endif + /* Platform API */ typedef CL_API_ENTRY cl_int (CL_API_CALL * PFNCLGETPLATFORMIDS)(cl_uint /* num_entries */, @@ -2476,6 +2481,10 @@ PFNCLCREATEFROMGLTEXTURE3D)(cl_context /* context */, cl_int * /* errcode_ret */) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; #endif +#ifdef __APPLE__ +# pragma GCC diagnostic pop // ignored "-Wignored-attributes" +#endif + /* cl_khr_gl_sharing extension */ #define cl_khr_gl_sharing 1 diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 05a6f70d423..bd4ade05e5f 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -350,7 +350,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): description="Distance between volume shader samples when rendering the volume " "(lower values give more accurate and detailed results, but also increased render time)", default=0.1, - min=0.0000001, max=100000.0 + min=0.0000001, max=100000.0, soft_min=0.01, soft_max=1.0 ) cls.volume_max_steps = IntProperty( diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index c521e1383a4..0ff227938ae 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -91,6 +91,7 @@ set(SRC_SVM_HEADERS svm/svm_magic.h svm/svm_mapping.h svm/svm_math.h + svm/svm_math_util.h svm/svm_mix.h svm/svm_musgrave.h svm/svm_noise.h diff --git a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h index ad7864cb8ea..1a1c1af6f5d 100644 --- a/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h +++ b/intern/cycles/kernel/closure/bsdf_ashikhmin_shirley.h @@ -1,5 +1,5 @@ /* - * Copyright 2011-2013 Blender Foundation + * Copyright 2011-2014 Blender Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,24 +33,20 @@ CCL_NAMESPACE_BEGIN ccl_device int bsdf_ashikhmin_shirley_setup(ShaderClosure *sc) { - /* store roughness. could already convert to exponent to save some cycles - * in eval, but this is more consistent with other bsdfs and shader_blur. */ sc->data0 = clamp(sc->data0, 1e-4f, 1.0f); sc->data1 = sc->data0; sc->type = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID; - return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY; + return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } ccl_device int bsdf_ashikhmin_shirley_aniso_setup(ShaderClosure *sc) { - /* store roughness. could already convert to exponent to save some cycles - * in eval, but this is more consistent with other bsdfs and shader_blur. */ sc->data0 = clamp(sc->data0, 1e-4f, 1.0f); sc->data1 = clamp(sc->data1, 1e-4f, 1.0f); sc->type = CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID; - return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY; + return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } ccl_device void bsdf_ashikhmin_shirley_blur(ShaderClosure *sc, float roughness) @@ -73,7 +69,7 @@ ccl_device float3 bsdf_ashikhmin_shirley_eval_reflect(const ShaderClosure *sc, c float out = 0.0f; - if (NdotI > 0.0f && NdotO > 0.0f) { + if(NdotI > 0.0f && NdotO > 0.0f) { NdotI = fmaxf(NdotI, 1e-6f); NdotO = fmaxf(NdotO, 1e-6f); float3 H = normalize(omega_in + I); @@ -86,7 +82,8 @@ ccl_device float3 bsdf_ashikhmin_shirley_eval_reflect(const ShaderClosure *sc, c float n_x = bsdf_ashikhmin_shirley_roughness_to_exponent(sc->data0); float n_y = bsdf_ashikhmin_shirley_roughness_to_exponent(sc->data1); - if (n_x == n_y) { /* => isotropic case */ + if(n_x == n_y) { + /* isotropic */ float e = n_x; float lobe = powf(HdotN, e); float norm = (n_x + 1.0f) / (8.0f * M_PI_F); @@ -94,7 +91,8 @@ ccl_device float3 bsdf_ashikhmin_shirley_eval_reflect(const ShaderClosure *sc, c out = NdotO * norm * lobe * pump; *pdf = norm * lobe / HdotI; /* this is p_h / 4(H.I) (conversion from 'wh measure' to 'wi measure', eq. 8 in paper) */ } - else { /* => ANisotropic case */ + else { + /* anisotropic */ float3 X, Y; make_orthonormals_tangent(N, sc->T, &X, &Y); @@ -130,7 +128,7 @@ ccl_device int bsdf_ashikhmin_shirley_sample(const ShaderClosure *sc, float3 Ng, float3 N = sc->N; float NdotI = dot(N, I); - if (NdotI > 0.0f) { + if(NdotI > 0.0f) { float n_x = bsdf_ashikhmin_shirley_roughness_to_exponent(sc->data0); float n_y = bsdf_ashikhmin_shirley_roughness_to_exponent(sc->data1); @@ -146,21 +144,23 @@ ccl_device int bsdf_ashikhmin_shirley_sample(const ShaderClosure *sc, float3 Ng, /* sample spherical coords for h in tangent space */ float phi; float cos_theta; - if (n_x == n_y) { /* => simple isotropic sampling */ + if(n_x == n_y) { + /* isotropic sampling */ phi = M_2PI_F * randu; cos_theta = powf(randv, 1.0f / (n_x + 1.0f)); } - else { /* => more complex anisotropic sampling */ - if (randu < 0.25f) { /* first quadrant */ + else { + /* anisotropic sampling */ + if(randu < 0.25f) { /* first quadrant */ float remapped_randu = 4.0f * randu; bsdf_ashikhmin_shirley_sample_first_quadrant(n_x, n_y, remapped_randu, randv, &phi, &cos_theta); } - else if (randu < 0.5f) { /* second quadrant */ + else if(randu < 0.5f) { /* second quadrant */ float remapped_randu = 4.0f * (.5f - randu); bsdf_ashikhmin_shirley_sample_first_quadrant(n_x, n_y, remapped_randu, randv, &phi, &cos_theta); phi = M_PI_F - phi; } - else if (randu < 0.75f) { /* third quadrant */ + else if(randu < 0.75f) { /* third quadrant */ float remapped_randu = 4.0f * (randu - 0.5f); bsdf_ashikhmin_shirley_sample_first_quadrant(n_x, n_y, remapped_randu, randv, &phi, &cos_theta); phi = M_PI_F + phi; @@ -185,13 +185,12 @@ ccl_device int bsdf_ashikhmin_shirley_sample(const ShaderClosure *sc, float3 Ng, /* half vector to world space */ float3 H = h.x*X + h.y*Y + h.z*N; float HdotI = dot(H, I); - if (HdotI < 0.0f) H = -H; + if(HdotI < 0.0f) H = -H; /* reflect I on H to get omega_in */ *omega_in = -I + (2.0f * HdotI) * H; /* leave the rest to eval_reflect */ - /* (could maybe optimize a few things by manual inlining, but I doubt it would make much difference) */ *eval = bsdf_ashikhmin_shirley_eval_reflect(sc, I, *omega_in, pdf); #ifdef __RAY_DIFFERENTIALS__ @@ -201,7 +200,7 @@ ccl_device int bsdf_ashikhmin_shirley_sample(const ShaderClosure *sc, float3 Ng, #endif } - return LABEL_REFLECT | LABEL_GLOSSY; + return LABEL_REFLECT|LABEL_GLOSSY; } diff --git a/intern/cycles/kernel/closure/bsdf_diffuse.h b/intern/cycles/kernel/closure/bsdf_diffuse.h index 949fe869549..371f467000c 100644 --- a/intern/cycles/kernel/closure/bsdf_diffuse.h +++ b/intern/cycles/kernel/closure/bsdf_diffuse.h @@ -108,11 +108,6 @@ ccl_device float3 bsdf_translucent_eval_transmit(const ShaderClosure *sc, const return make_float3 (cos_pi, cos_pi, cos_pi); } -ccl_device float bsdf_translucent_albedo(const ShaderClosure *sc, const float3 I) -{ - return 1.0f; -} - ccl_device int bsdf_translucent_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) { float3 N = sc->N; diff --git a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h index b856774375f..cdaf84f1750 100644 --- a/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h +++ b/intern/cycles/kernel/closure/bsdf_diffuse_ramp.h @@ -41,9 +41,9 @@ ccl_device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const flo float npos = pos * (float)(MAXCOLORS - 1); int ipos = float_to_int(npos); - if (ipos < 0) + if(ipos < 0) return colors[0]; - if (ipos >= (MAXCOLORS - 1)) + if(ipos >= (MAXCOLORS - 1)) return colors[MAXCOLORS - 1]; float offset = npos - (float)ipos; return colors[ipos] * (1.0f - offset) + colors[ipos+1] * offset; @@ -52,7 +52,7 @@ ccl_device float3 bsdf_diffuse_ramp_get_color(const ShaderClosure *sc, const flo ccl_device int bsdf_diffuse_ramp_setup(ShaderClosure *sc) { sc->type = CLOSURE_BSDF_DIFFUSE_RAMP_ID; - return SD_BSDF | SD_BSDF_HAS_EVAL; + return SD_BSDF|SD_BSDF_HAS_EVAL; } ccl_device void bsdf_diffuse_ramp_blur(ShaderClosure *sc, float roughness) diff --git a/intern/cycles/kernel/closure/bsdf_oren_nayar.h b/intern/cycles/kernel/closure/bsdf_oren_nayar.h index 6f685d5eeea..6d3b915c24a 100644 --- a/intern/cycles/kernel/closure/bsdf_oren_nayar.h +++ b/intern/cycles/kernel/closure/bsdf_oren_nayar.h @@ -25,7 +25,7 @@ ccl_device float3 bsdf_oren_nayar_get_intensity(const ShaderClosure *sc, float3 float nv = max(dot(n, v), 0.0f); float t = dot(l, v) - nl * nv; - if (t > 0.0f) + if(t > 0.0f) t /= max(nl, nv) + FLT_MIN; float is = nl * (sc->data0 + sc->data1 * t); return make_float3(is, is, is); @@ -44,7 +44,7 @@ ccl_device int bsdf_oren_nayar_setup(ShaderClosure *sc) sc->data0 = 1.0f * div; sc->data1 = sigma * div; - return SD_BSDF | SD_BSDF_HAS_EVAL; + return SD_BSDF|SD_BSDF_HAS_EVAL; } ccl_device void bsdf_oren_nayar_blur(ShaderClosure *sc, float roughness) @@ -53,7 +53,7 @@ ccl_device void bsdf_oren_nayar_blur(ShaderClosure *sc, float roughness) ccl_device float3 bsdf_oren_nayar_eval_reflect(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf) { - if (dot(sc->N, omega_in) > 0.0f) { + if(dot(sc->N, omega_in) > 0.0f) { *pdf = 0.5f * M_1_PI_F; return bsdf_oren_nayar_get_intensity(sc, sc->N, I, omega_in); } @@ -72,7 +72,7 @@ ccl_device int bsdf_oren_nayar_sample(const ShaderClosure *sc, float3 Ng, float3 { sample_uniform_hemisphere(sc->N, randu, randv, omega_in, pdf); - if (dot(Ng, *omega_in) > 0.0f) { + if(dot(Ng, *omega_in) > 0.0f) { *eval = bsdf_oren_nayar_get_intensity(sc, sc->N, I, *omega_in); #ifdef __RAY_DIFFERENTIALS__ @@ -86,7 +86,7 @@ ccl_device int bsdf_oren_nayar_sample(const ShaderClosure *sc, float3 Ng, float3 *eval = make_float3(0.0f, 0.0f, 0.0f); } - return LABEL_REFLECT | LABEL_DIFFUSE; + return LABEL_REFLECT|LABEL_DIFFUSE; } diff --git a/intern/cycles/kernel/closure/bsdf_phong_ramp.h b/intern/cycles/kernel/closure/bsdf_phong_ramp.h index 2b4e1c68640..dfd093b676e 100644 --- a/intern/cycles/kernel/closure/bsdf_phong_ramp.h +++ b/intern/cycles/kernel/closure/bsdf_phong_ramp.h @@ -41,9 +41,9 @@ ccl_device float3 bsdf_phong_ramp_get_color(const ShaderClosure *sc, const float float npos = pos * (float)(MAXCOLORS - 1); int ipos = float_to_int(npos); - if (ipos < 0) + if(ipos < 0) return colors[0]; - if (ipos >= (MAXCOLORS - 1)) + if(ipos >= (MAXCOLORS - 1)) return colors[MAXCOLORS - 1]; float offset = npos - (float)ipos; return colors[ipos] * (1.0f - offset) + colors[ipos+1] * offset; @@ -54,7 +54,7 @@ ccl_device int bsdf_phong_ramp_setup(ShaderClosure *sc) sc->data0 = max(sc->data0, 0.0f); sc->type = CLOSURE_BSDF_PHONG_RAMP_ID; - return SD_BSDF | SD_BSDF_HAS_EVAL | SD_BSDF_GLOSSY; + return SD_BSDF|SD_BSDF_HAS_EVAL|SD_BSDF_GLOSSY; } ccl_device void bsdf_phong_ramp_blur(ShaderClosure *sc, float roughness) @@ -67,11 +67,11 @@ ccl_device float3 bsdf_phong_ramp_eval_reflect(const ShaderClosure *sc, const fl float cosNI = dot(sc->N, omega_in); float cosNO = dot(sc->N, I); - if (cosNI > 0 && cosNO > 0) { + if(cosNI > 0 && cosNO > 0) { // reflect the view vector float3 R = (2 * cosNO) * sc->N - I; float cosRI = dot(R, omega_in); - if (cosRI > 0) { + if(cosRI > 0) { float cosp = powf(cosRI, m_exponent); float common = 0.5f * M_1_PI_F * cosp; float out = cosNI * (m_exponent + 2) * common; @@ -93,7 +93,7 @@ ccl_device int bsdf_phong_ramp_sample(const ShaderClosure *sc, const float3 colo float cosNO = dot(sc->N, I); float m_exponent = sc->data0; - if (cosNO > 0) { + if(cosNO > 0) { // reflect the view vector float3 R = (2 * cosNO) * sc->N - I; @@ -111,12 +111,12 @@ ccl_device int bsdf_phong_ramp_sample(const ShaderClosure *sc, const float3 colo *omega_in = (cosf(phi) * sinTheta) * T + (sinf(phi) * sinTheta) * B + ( cosTheta) * R; - if (dot(Ng, *omega_in) > 0.0f) + if(dot(Ng, *omega_in) > 0.0f) { // common terms for pdf and eval float cosNI = dot(sc->N, *omega_in); // make sure the direction we chose is still in the right hemisphere - if (cosNI > 0) + if(cosNI > 0) { float cosp = powf(cosTheta, m_exponent); float common = 0.5f * M_1_PI_F * cosp; diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h index c13eae813d6..5acfbbf972b 100644 --- a/intern/cycles/kernel/svm/svm.h +++ b/intern/cycles/kernel/svm/svm.h @@ -164,6 +164,7 @@ CCL_NAMESPACE_END #include "svm_mapping.h" #include "svm_normal.h" #include "svm_wave.h" +#include "svm_math_util.h" #include "svm_math.h" #include "svm_mix.h" #include "svm_ramp.h" diff --git a/intern/cycles/kernel/svm/svm_math.h b/intern/cycles/kernel/svm/svm_math.h index 1ce9386e40e..e3d8c1f3242 100644 --- a/intern/cycles/kernel/svm/svm_math.h +++ b/intern/cycles/kernel/svm/svm_math.h @@ -16,56 +16,6 @@ CCL_NAMESPACE_BEGIN -ccl_device float svm_math(NodeMath type, float Fac1, float Fac2) -{ - float Fac; - - if(type == NODE_MATH_ADD) - Fac = Fac1 + Fac2; - else if(type == NODE_MATH_SUBTRACT) - Fac = Fac1 - Fac2; - else if(type == NODE_MATH_MULTIPLY) - Fac = Fac1*Fac2; - else if(type == NODE_MATH_DIVIDE) - Fac = safe_divide(Fac1, Fac2); - else if(type == NODE_MATH_SINE) - Fac = sinf(Fac1); - else if(type == NODE_MATH_COSINE) - Fac = cosf(Fac1); - else if(type == NODE_MATH_TANGENT) - Fac = tanf(Fac1); - else if(type == NODE_MATH_ARCSINE) - Fac = safe_asinf(Fac1); - else if(type == NODE_MATH_ARCCOSINE) - Fac = safe_acosf(Fac1); - else if(type == NODE_MATH_ARCTANGENT) - Fac = atanf(Fac1); - else if(type == NODE_MATH_POWER) - Fac = safe_powf(Fac1, Fac2); - else if(type == NODE_MATH_LOGARITHM) - Fac = safe_logf(Fac1, Fac2); - else if(type == NODE_MATH_MINIMUM) - Fac = fminf(Fac1, Fac2); - else if(type == NODE_MATH_MAXIMUM) - Fac = fmaxf(Fac1, Fac2); - else if(type == NODE_MATH_ROUND) - Fac = floorf(Fac1 + 0.5f); - else if(type == NODE_MATH_LESS_THAN) - Fac = Fac1 < Fac2; - else if(type == NODE_MATH_GREATER_THAN) - Fac = Fac1 > Fac2; - else if(type == NODE_MATH_MODULO) - Fac = safe_modulo(Fac1, Fac2); - else if(type == NODE_MATH_ABSOLUTE) - Fac = fabsf(Fac1); - else if(type == NODE_MATH_CLAMP) - Fac = clamp(Fac1, 0.0f, 1.0f); - else - Fac = 0.0f; - - return Fac; -} - ccl_device float average_fac(float3 v) { return (fabsf(v.x) + fabsf(v.y) + fabsf(v.z))/3.0f; diff --git a/intern/cycles/kernel/svm/svm_math_util.h b/intern/cycles/kernel/svm/svm_math_util.h new file mode 100644 index 00000000000..b813bf531dc --- /dev/null +++ b/intern/cycles/kernel/svm/svm_math_util.h @@ -0,0 +1,70 @@ +/* + * Copyright 2011-2014 Blender Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +CCL_NAMESPACE_BEGIN + +ccl_device float svm_math(NodeMath type, float Fac1, float Fac2) +{ + float Fac; + + if(type == NODE_MATH_ADD) + Fac = Fac1 + Fac2; + else if(type == NODE_MATH_SUBTRACT) + Fac = Fac1 - Fac2; + else if(type == NODE_MATH_MULTIPLY) + Fac = Fac1*Fac2; + else if(type == NODE_MATH_DIVIDE) + Fac = safe_divide(Fac1, Fac2); + else if(type == NODE_MATH_SINE) + Fac = sinf(Fac1); + else if(type == NODE_MATH_COSINE) + Fac = cosf(Fac1); + else if(type == NODE_MATH_TANGENT) + Fac = tanf(Fac1); + else if(type == NODE_MATH_ARCSINE) + Fac = safe_asinf(Fac1); + else if(type == NODE_MATH_ARCCOSINE) + Fac = safe_acosf(Fac1); + else if(type == NODE_MATH_ARCTANGENT) + Fac = atanf(Fac1); + else if(type == NODE_MATH_POWER) + Fac = safe_powf(Fac1, Fac2); + else if(type == NODE_MATH_LOGARITHM) + Fac = safe_logf(Fac1, Fac2); + else if(type == NODE_MATH_MINIMUM) + Fac = fminf(Fac1, Fac2); + else if(type == NODE_MATH_MAXIMUM) + Fac = fmaxf(Fac1, Fac2); + else if(type == NODE_MATH_ROUND) + Fac = floorf(Fac1 + 0.5f); + else if(type == NODE_MATH_LESS_THAN) + Fac = Fac1 < Fac2; + else if(type == NODE_MATH_GREATER_THAN) + Fac = Fac1 > Fac2; + else if(type == NODE_MATH_MODULO) + Fac = safe_modulo(Fac1, Fac2); + else if(type == NODE_MATH_ABSOLUTE) + Fac = fabsf(Fac1); + else if(type == NODE_MATH_CLAMP) + Fac = clamp(Fac1, 0.0f, 1.0f); + else + Fac = 0.0f; + + return Fac; +} + +CCL_NAMESPACE_END + diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index e8476bfac4c..971b96e4a16 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -17,6 +17,7 @@ #include "image.h" #include "nodes.h" #include "svm.h" +#include "svm_math_util.h" #include "osl.h" #include "sky_model.h" @@ -3682,9 +3683,24 @@ void MathNode::compile(SVMCompiler& compiler) ShaderInput *value2_in = input("Value2"); ShaderOutput *value_out = output("Value"); + compiler.stack_assign(value_out); + + /* Optimize math node without links to a single value node. */ + if(value1_in->link == NULL && value2_in->link == NULL) { + float optimized_value = svm_math((NodeMath)type_enum[type], + value1_in->value.x, + value2_in->value.x); + if(use_clamp) { + optimized_value = clamp(optimized_value, 0.0f, 1.0f); + } + compiler.add_node(NODE_VALUE_F, + __float_as_int(optimized_value), + value_out->stack_offset); + return; + } + compiler.stack_assign(value1_in); compiler.stack_assign(value2_in); - compiler.stack_assign(value_out); compiler.add_node(NODE_MATH, type_enum[type], value1_in->stack_offset, value2_in->stack_offset); compiler.add_node(NODE_MATH, value_out->stack_offset); diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 236002e9744..cfa1e8bf566 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -22,6 +22,7 @@ * * Contributors: Maarten Gribnau 05/2001 * Damien Plisson 09/2009 + * Jens Verwiebe 10/2014 * * ***** END GPL LICENSE BLOCK ***** */ @@ -56,6 +57,7 @@ #include "AssertMacros.h" + #pragma mark KeyMap, mouse converters static GHOST_TButtonMask convertButton(int button) @@ -313,8 +315,6 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction) @end - - #pragma mark initialization/finalization GHOST_SystemCocoa::GHOST_SystemCocoa() @@ -636,7 +636,6 @@ GHOST_TSuccess GHOST_SystemCocoa::getButtons(GHOST_Buttons& buttons) const } - #pragma mark Event handlers /** @@ -1573,7 +1572,6 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr) } - #pragma mark Clipboard get/set GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm index 44b3c5b2a81..ab313b06f66 100644 --- a/intern/ghost/intern/GHOST_WindowCocoa.mm +++ b/intern/ghost/intern/GHOST_WindowCocoa.mm @@ -23,6 +23,7 @@ * Contributor(s): Maarten Gribnau 05/2001 * Damien Plisson 10/2009 * Jason Wilkins 02/2014 + * Jens Verwiebe 10/2014 * * ***** END GPL LICENSE BLOCK ***** */ @@ -45,8 +46,6 @@ # include <Carbon/Carbon.h> #endif - - #include <sys/sysctl.h> #if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 @@ -77,7 +76,6 @@ enum { - (void)windowDidChangeBackingProperties:(NSNotification *)notification; @end - @implementation CocoaWindowDelegate : NSObject - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa { @@ -88,6 +86,8 @@ enum { - (void)windowDidBecomeKey:(NSNotification *)notification { systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow); + // work around for broken appswitching when combining cmd-tab and missioncontrol + [(NSWindow*)associatedWindow->getOSWindow() orderFrontRegardless]; } - (void)windowDidResignKey:(NSNotification *)notification @@ -171,6 +171,7 @@ enum { - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa; - (GHOST_SystemCocoa*)systemCocoa; @end + @implementation CocoaWindow - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa { @@ -261,8 +262,6 @@ enum { @end - - #pragma mark NSOpenGLView subclass //We need to subclass it in order to give Cocoa the feeling key events are trapped @interface CocoaOpenGLView : NSOpenGLView <NSTextInput> @@ -277,6 +276,7 @@ enum { } - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa; @end + @implementation CocoaOpenGLView - (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa @@ -1326,7 +1326,16 @@ GHOST_TSuccess GHOST_WindowCocoa::setProgressBar(float progress) return GHOST_kSuccess; } - +static void postNotification() +{ + NSUserNotification *notification = [[NSUserNotification alloc] init]; + notification.title = @"Blender progress notification"; + notification.informativeText = @"Calculation is finished"; + notification.soundName = NSUserNotificationDefaultSoundName; + [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification]; + [notification release]; +} + GHOST_TSuccess GHOST_WindowCocoa::endProgressBar() { if (!m_progressBarVisible) return GHOST_kFailure; @@ -1346,12 +1355,7 @@ GHOST_TSuccess GHOST_WindowCocoa::endProgressBar() // If Blender is not frontmost window, a message pops up with sound, in any case an entry in notifications if ([NSUserNotificationCenter respondsToSelector:@selector(defaultUserNotificationCenter)]) { - NSUserNotification *notification = [[NSUserNotification alloc] init]; - notification.title = @"Blender progress notification"; - notification.informativeText = @"Calculation ended"; - notification.soundName = NSUserNotificationDefaultSoundName; - [[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification]; - [notification release]; + postNotification(); } [dockIcon release]; @@ -1360,8 +1364,6 @@ GHOST_TSuccess GHOST_WindowCocoa::endProgressBar() return GHOST_kSuccess; } - - #pragma mark Cursor handling void GHOST_WindowCocoa::loadCursor(bool visible, GHOST_TStandardCursor cursor) const diff --git a/release/scripts/modules/animsys_refactor.py b/release/scripts/modules/animsys_refactor.py index aaa06c32312..39f0ad2f049 100644 --- a/release/scripts/modules/animsys_refactor.py +++ b/release/scripts/modules/animsys_refactor.py @@ -51,7 +51,7 @@ def classes_recursive(base_type, clss=None): return clss -class DataPathBuilder(object): +class DataPathBuilder: """Dummy class used to parse fcurve and driver data paths.""" __slots__ = ("data_path", ) diff --git a/release/scripts/modules/bpy/ops.py b/release/scripts/modules/bpy/ops.py index f5455ce5018..1bdb9eba48c 100644 --- a/release/scripts/modules/bpy/ops.py +++ b/release/scripts/modules/bpy/ops.py @@ -30,7 +30,7 @@ op_get_rna = ops_module.get_rna op_get_instance = ops_module.get_instance -class BPyOps(object): +class BPyOps: """ Fake module like class. @@ -68,7 +68,7 @@ class BPyOps(object): return "<module like class 'bpy.ops'>" -class BPyOpsSubMod(object): +class BPyOpsSubMod: """ Utility class to fake submodules. @@ -104,7 +104,7 @@ class BPyOpsSubMod(object): return "<module like class 'bpy.ops.%s'>" % self._module -class BPyOpsSubModOp(object): +class BPyOpsSubModOp: """ Utility class to fake submodule operators. diff --git a/release/scripts/modules/bpyml.py b/release/scripts/modules/bpyml.py index e942006010b..f2a73501672 100644 --- a/release/scripts/modules/bpyml.py +++ b/release/scripts/modules/bpyml.py @@ -57,7 +57,7 @@ class ReturnStore(tuple): return tuple.__getitem__(self, key) -class FunctionStore(object): +class FunctionStore: def __call__(self, **kwargs): return ReturnStore((self.__class__.__name__, kwargs, [])) diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py index 8f618e0632e..a120e2b2461 100644 --- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py +++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py @@ -23,7 +23,7 @@ from bpy.types import Operator import mathutils -class prettyface(object): +class prettyface: __slots__ = ( "uv", "width", diff --git a/release/scripts/startup/bl_operators/uvcalc_smart_project.py b/release/scripts/startup/bl_operators/uvcalc_smart_project.py index aa8a1742c1e..f29bf07ab3a 100644 --- a/release/scripts/startup/bl_operators/uvcalc_smart_project.py +++ b/release/scripts/startup/bl_operators/uvcalc_smart_project.py @@ -670,7 +670,7 @@ def VectoQuat(vec): return vec.to_track_quat('Z', 'X' if abs(vec.x) > 0.5 else 'Y').inverted() -class thickface(object): +class thickface: __slost__= "v", "uv", "no", "area", "edge_keys" def __init__(self, face, uv_layer, mesh_verts): self.v = [mesh_verts[i] for i in face.vertices] diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 2f90dae2782..feb90da3d63 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -338,7 +338,7 @@ class SEQUENCER_MT_strip(Menu): layout.operator("sequencer.cut", text="Cut (hard) at frame").type = 'HARD' layout.operator("sequencer.cut", text="Cut (soft) at frame").type = 'SOFT' - layout.operator("sequencer.trim", text="Trim Contents") + layout.operator("sequencer.slip", text="Slip Strip Contents") layout.operator("sequencer.images_separate") layout.operator("sequencer.offset_clear") layout.operator("sequencer.deinterlace_selected_movies") diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index a7ddec040a5..3390361c5d2 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -744,7 +744,7 @@ class USERPREF_PT_theme(Panel): col.separator() col.separator() - col.label("Menu Shadow:") + col.label("Styles:") row = col.row() @@ -762,11 +762,6 @@ class USERPREF_PT_theme(Panel): colsub = padding.column() colsub.row().prop(ui, "menu_shadow_width") - col.separator() - col.separator() - - col.label("Icons:") - row = col.row() subsplit = row.split(percentage=0.95) @@ -774,16 +769,14 @@ class USERPREF_PT_theme(Panel): padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() - # Not working yet. - #~ colsub.active = False - #~ colsub.row().prop(ui, "icon_file") + colsub.row().prop(ui, "icon_alpha") subsplit = row.split(percentage=0.85) padding = subsplit.split(percentage=0.15) colsub = padding.column() colsub = padding.column() - colsub.row().prop(ui, "icon_alpha") + colsub.row().prop(ui, "emboss") col.separator() col.separator() diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index da64caa7a30..81cdaf63271 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1058,7 +1058,7 @@ class TEXTURE_UL_texpaintslots(UIList): if self.layout_type in {'DEFAULT', 'COMPACT'}: layout.prop(item, "name", text="", emboss=False, icon_value=icon) - if (not mat.use_nodes) and (context.scene.render.engine == 'BLENDER_RENDER'): + if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}: mtex_index = mat.texture_paint_slots[index].index layout.prop(mat, "use_textures", text="", index=mtex_index) elif self.layout_type in {'GRID'}: @@ -1115,7 +1115,7 @@ class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel): mat, "texture_paint_images", mat, "paint_active_slot", rows=2) - if (not mat.use_nodes) and (context.scene.render.engine == 'BLENDER_RENDER'): + if (not mat.use_nodes) and context.scene.render.engine in {'BLENDER_RENDER', 'BLENDER_GAME'}: row = col.row(align=True) row.operator_menu_enum("paint.add_texture_paint_slot", "type") row.operator("paint.delete_texture_paint_slot", text="", icon='X') diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index 1bfe0eeea0b..efcd00b0877 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -131,7 +131,9 @@ int get_render_shadow_samples(struct RenderData *r, int samples); float get_render_aosss_error(struct RenderData *r, float error); bool BKE_scene_use_new_shading_nodes(struct Scene *scene); + bool BKE_scene_uses_blender_internal(struct Scene *scene); +bool BKE_scene_uses_blender_game(struct Scene *scene); void BKE_scene_disable_color_management(struct Scene *scene); bool BKE_scene_check_color_management_enabled(const struct Scene *scene); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index aff99d3e1bf..b878dbe1f39 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -627,6 +627,9 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua if (!bl->nr) return 0; if (bl->poly > -1) cycl = 1; + /* values below zero for non-cyclic curves give strange results */ + BLI_assert(cycl || ctime >= 0.0f); + ctime *= (path->len - 1); s1 = (int)floor(ctime); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index bb05b5de8a6..875815d7550 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1916,7 +1916,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos if (ikData->points) MEM_freeN(ikData->points); ikData->numpoints = ikData->chainlen + 1; - ikData->points = MEM_callocN(sizeof(float) * ikData->numpoints, "Spline IK Binding"); + ikData->points = MEM_mallocN(sizeof(float) * ikData->numpoints, "Spline IK Binding"); /* bind 'tip' of chain (i.e. first joint = tip of bone with the Spline IK Constraint) */ ikData->points[0] = 1.0f; @@ -1940,6 +1940,9 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos } } + /* disallow negative values (happens with float precision) */ + CLAMP_MIN(ikData->points[segcount], 0.0f); + /* spline has now been bound */ ikData->flag |= CONSTRAINT_SPLINEIK_BOUND; } @@ -1989,7 +1992,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos tree->chainlen = segcount; /* copy over the array of links to bones in the chain (from tip to root) */ - tree->chain = MEM_callocN(sizeof(bPoseChannel *) * segcount, "SplineIK Chain"); + tree->chain = MEM_mallocN(sizeof(bPoseChannel *) * segcount, "SplineIK Chain"); memcpy(tree->chain, pchanChain, sizeof(bPoseChannel *) * segcount); /* store reference to joint position array */ diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index eeca60f7ef4..ea1b9a3f13d 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1320,7 +1320,7 @@ void BKE_texpaint_slot_refresh_cache(Scene *scene, Material *ma) short index = 0, i; bool use_nodes = BKE_scene_use_new_shading_nodes(scene); - bool is_bi = BKE_scene_uses_blender_internal(scene); + bool is_bi = BKE_scene_uses_blender_internal(scene) || BKE_scene_uses_blender_game(scene); if (!ma) return; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 5bfd6e8a120..d9575079f73 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -98,6 +98,10 @@ # include <sys/time.h> #endif +const char *RE_engine_id_BLENDER_RENDER = "BLENDER_RENDER"; +const char *RE_engine_id_BLENDER_GAME = "BLENDER_GAME"; +const char *RE_engine_id_CYCLES = "CYCLES"; + void free_avicodecdata(AviCodecData *acd) { if (acd) { @@ -595,7 +599,7 @@ Scene *BKE_scene_add(Main *bmain, const char *name) sce->r.ffcodecdata.audio_bitrate = 192; sce->r.ffcodecdata.audio_channels = 2; - BLI_strncpy(sce->r.engine, "BLENDER_RENDER", sizeof(sce->r.engine)); + BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_RENDER, sizeof(sce->r.engine)); sce->audio.distance_model = 2.0f; sce->audio.doppler_factor = 1.0f; @@ -1902,9 +1906,13 @@ bool BKE_scene_use_new_shading_nodes(Scene *scene) bool BKE_scene_uses_blender_internal(struct Scene *scene) { - return strcmp("BLENDER_RENDER", scene->r.engine) == 0; + return STREQ(scene->r.engine, RE_engine_id_BLENDER_RENDER); } +bool BKE_scene_uses_blender_game(struct Scene *scene) +{ + return STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME); +} void BKE_scene_base_flag_to_objects(struct Scene *scene) { diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 7cd47fab83a..acf8bdc6768 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -316,19 +316,14 @@ void debug_markers_print_list(ListBase *markers) /* ************* Marker Drawing ************ */ /* function to draw markers */ -static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) +static void draw_marker( + View2D *v2d, TimeMarker *marker, int cfra, int flag, + /* avoid re-calculating each time */ + const float ypixels, const float xscale, const float yscale) { - float xpos, ypixels, xscale, yscale; - int icon_id = 0; - - xpos = marker->frame; - - /* no time correction for framelen! space is drawn with old values */ - ypixels = BLI_rcti_size_y(&v2d->mask); - UI_view2d_scale_get(v2d, &xscale, &yscale); - - glScalef(1.0f / xscale, 1.0f, 1.0f); - + const float xpos = marker->frame * xscale; + int icon_id; + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -347,8 +342,8 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) glColor4ub(0, 0, 0, 96); glBegin(GL_LINES); - glVertex2f((xpos * xscale) + 0.5f, 12.0f); - glVertex2f((xpos * xscale) + 0.5f, (v2d->cur.ymax + 12.0f) * yscale); + glVertex2f(xpos + 0.5f, 12.0f); + glVertex2f(xpos + 0.5f, (v2d->cur.ymax + 12.0f) * yscale); glEnd(); setlinestyle(0); @@ -365,7 +360,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) ICON_MARKER; } - UI_icon_draw(xpos * xscale - 0.45f * UI_DPI_ICON_SIZE, UI_DPI_ICON_SIZE, icon_id); + UI_icon_draw(xpos - 0.45f * UI_DPI_ICON_SIZE, UI_DPI_ICON_SIZE, icon_id); glDisable(GL_BLEND); @@ -378,19 +373,19 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) if (marker->flag & SELECT) { UI_ThemeColor(TH_TEXT_HI); - x = xpos * xscale + 4.0f * UI_DPI_FAC; + x = xpos + 4.0f * UI_DPI_FAC; y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC; y = max_ii(y, min_y); } else { UI_ThemeColor(TH_TEXT); if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) { - x = xpos * xscale + 8.0f * UI_DPI_FAC; + x = xpos + 8.0f * UI_DPI_FAC; y = (ypixels <= 39.0f * UI_DPI_FAC) ? (ypixels - 10.0f * UI_DPI_FAC) : 29.0f * UI_DPI_FAC; y = max_ii(y, min_y); } else { - x = xpos * xscale + 8.0f * UI_DPI_FAC; + x = xpos + 8.0f * UI_DPI_FAC; y = 17.0f * UI_DPI_FAC; } } @@ -406,37 +401,68 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) UI_DrawString(x, y, marker->name); } - - glScalef(xscale, 1.0f, 1.0f); } /* Draw Scene-Markers in time window */ -void draw_markers_time(const bContext *C, int flag) +void ED_markers_draw(const bContext *C, int flag) { ListBase *markers = ED_context_get_markers(C); View2D *v2d; TimeMarker *marker; Scene *scene; + int select_pass; + int v2d_clip_range_x[2]; + float font_width_max; - if (markers == NULL) + /* cache values */ + float ypixels, xscale, yscale; + + if (markers == NULL || BLI_listbase_is_empty(markers)) { return; + } scene = CTX_data_scene(C); v2d = UI_view2d_fromcontext(C); - /* unselected markers are drawn at the first time */ - for (marker = markers->first; marker; marker = marker->next) { - if ((marker->flag & SELECT) == 0) { - draw_marker(v2d, marker, scene->r.cfra, flag); - } + if (flag & DRAW_MARKERS_MARGIN) { + const unsigned char shade[4] = {0, 0, 0, 16}; + glColor4ubv(shade); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glRectf(v2d->cur.xmin, 0, v2d->cur.xmax, UI_MARKER_MARGIN_Y); + + glDisable(GL_BLEND); } - - /* selected markers are drawn later */ - for (marker = markers->first; marker; marker = marker->next) { - if (marker->flag & SELECT) { - draw_marker(v2d, marker, scene->r.cfra, flag); + + /* no time correction for framelen! space is drawn with old values */ + ypixels = BLI_rcti_size_y(&v2d->mask); + UI_view2d_scale_get(v2d, &xscale, &yscale); + glScalef(1.0f / xscale, 1.0f, 1.0f); + + /* x-bounds with offset for text (adjust for long string, avoid checking string width) */ + font_width_max = (10 * UI_DPI_FAC) / xscale; + v2d_clip_range_x[0] = v2d->cur.xmin - (sizeof(marker->name) * font_width_max); + v2d_clip_range_x[1] = v2d->cur.xmax + font_width_max; + + /* loop [unselected, selected] */ + for (select_pass = 0; select_pass <= SELECT; select_pass += SELECT) { + /* unselected markers are drawn at the first time */ + for (marker = markers->first; marker; marker = marker->next) { + if ((marker->flag & SELECT) == select_pass) { + /* bounds check */ + if ((marker->frame >= v2d_clip_range_x[0]) && + (marker->frame <= v2d_clip_range_x[1])) + { + draw_marker(v2d, marker, scene->r.cfra, flag, + ypixels, xscale, yscale); + } + } } } + + glScalef(xscale, 1.0f, 1.0f); } /* ************************ Marker Wrappers API ********************* */ @@ -503,8 +529,9 @@ static int ed_markers_opwrap_invoke_custom(bContext *C, wmOperator *op, const wm /* return status modifications - for now, make this spacetype dependent as above */ if (sa->spacetype != SPACE_TIME) { /* unless successful, must add "pass-through" to let normal operator's have a chance at tackling this event */ - if (retval != OPERATOR_FINISHED) + if ((retval & (OPERATOR_FINISHED | OPERATOR_INTERFACE)) == 0) { retval |= OPERATOR_PASS_THROUGH; + } } return retval; diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 4c2d90179a7..c2fabfadc35 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1407,7 +1407,7 @@ static int insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UN uiItemsEnumO(layout, "ANIM_OT_keyframe_insert_menu", "type"); uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } else { /* just call the exec() on the active keyingset */ diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index ad2db0d9c66..8386eadf962 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -477,7 +477,7 @@ static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, const wmEve uiItemsEnumO(layout, "ANIM_OT_keying_set_active_set", "type"); uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } static int keyingset_active_menu_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index 75fa4a5433f..22187682265 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -693,7 +693,7 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } void ARMATURE_OT_parent_set(wmOperatorType *ot) diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c index 50d9d300d15..4667e09360f 100644 --- a/source/blender/editors/armature/pose_group.c +++ b/source/blender/editors/armature/pose_group.c @@ -162,7 +162,7 @@ static int pose_groups_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U /* finish building the menu, and process it (should result in calling self again) */ uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } else { /* just use the active group index, and call the exec callback for the calling operator */ diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 0609fcc29e8..8bb1c586526 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -423,7 +423,7 @@ static int poselib_add_menu_invoke(bContext *C, wmOperator *op, const wmEvent *U uiPupMenuEnd(C, pup); /* this operator is only for a menu, not used further */ - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index a52b2a619dc..9c4ee4e09be 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -4799,7 +4799,7 @@ bool ed_editnurb_spin(float viewmat[4][4], Object *obedit, const float axis[3], ok = true; for (a = 0; a < 7; a++) { - ok = ed_editnurb_extrude_flag(cu->editnurb, 1); + ok = ed_editnurb_extrude_flag(cu->editnurb, SELECT); if (ok == false) return changed; @@ -5260,7 +5260,7 @@ static int extrude_exec(bContext *C, wmOperator *UNUSED(op)) addvert_Nurb(C, 'e', NULL); } else { - if (ed_editnurb_extrude_flag(editnurb, 1)) { /* '1'= flag */ + if (ed_editnurb_extrude_flag(editnurb, SELECT)) { if (ED_curve_updateAnimPaths(obedit->data)) WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); @@ -5386,7 +5386,7 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS layout = uiPupMenuLayout(pup); uiItemsEnumO(layout, op->type->idname, "direction"); uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } } } diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c index 8a3d4f3f4f5..662a7eb811a 100644 --- a/source/blender/editors/curve/editcurve_add.c +++ b/source/blender/editors/curve/editcurve_add.c @@ -355,10 +355,10 @@ Nurb *add_nurbs_primitive(bContext *C, Object *obedit, float mat[4][4], int type mul_mat3_m4_v3(mat, vec); - ed_editnurb_translate_flag(editnurb, 1, vec); - ed_editnurb_extrude_flag(cu->editnurb, 1); + ed_editnurb_translate_flag(editnurb, SELECT, vec); + ed_editnurb_extrude_flag(cu->editnurb, SELECT); mul_v3_fl(vec, -2.0f); - ed_editnurb_translate_flag(editnurb, 1, vec); + ed_editnurb_translate_flag(editnurb, SELECT, vec); BLI_remlink(editnurb, nu); diff --git a/source/blender/editors/include/ED_markers.h b/source/blender/editors/include/ED_markers.h index 76d36623b60..5eaf459a4e1 100644 --- a/source/blender/editors/include/ED_markers.h +++ b/source/blender/editors/include/ED_markers.h @@ -43,10 +43,11 @@ struct TimeMarker; /* flags for drawing markers */ enum { DRAW_MARKERS_LINES = (1 << 0), - DRAW_MARKERS_LOCAL = (1 << 1) + DRAW_MARKERS_LOCAL = (1 << 1), + DRAW_MARKERS_MARGIN = (1 << 2), }; -void draw_markers_time(const struct bContext *C, int flag); +void ED_markers_draw(const struct bContext *C, int flag); /* Backend API ----------------------------- */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index bc794bf3350..3704315bb61 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -359,15 +359,15 @@ void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head); struct uiLayout *uiPupMenuLayout(uiPopupMenu *head); void uiPupMenuReports(struct bContext *C, struct ReportList *reports) ATTR_NONNULL(); -bool uiPupMenuInvoke(struct bContext *C, const char *idname, struct ReportList *reports) ATTR_NONNULL(1, 2); +int uiPupMenuInvoke(struct bContext *C, const char *idname, struct ReportList *reports) ATTR_NONNULL(1, 2); /* Pie menus */ typedef struct uiPieMenu uiPieMenu; -void uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event); -void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname, +int uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event); +int uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname, const char *propname, const struct wmEvent *event); -void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path, const struct wmEvent *event); +int uiPieEnumInvoke(struct bContext *C, const char *title, const char *path, const struct wmEvent *event); struct uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const struct wmEvent *event) ATTR_NONNULL(); void uiPieMenuEnd(struct bContext *C, uiPieMenu *pie); diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 5b61e76f514..8e37e871501 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -266,6 +266,8 @@ enum { TH_NLA_SOUND, TH_NLA_SOUND_SEL, + TH_EMBOSS, + TH_AXIS_X, /* X/Y/Z Axis */ TH_AXIS_Y, TH_AXIS_Z, diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index cb7cf3ee404..4d7446a7a81 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -162,7 +162,7 @@ void UI_view2d_zoom_cache_reset(void); /* view matrix operations */ void UI_view2d_view_ortho(struct View2D *v2d); -void UI_view2d_view_orthoSpecial(struct ARegion *ar, struct View2D *v2d, short xaxis); +void UI_view2d_view_orthoSpecial(struct ARegion *ar, struct View2D *v2d, const bool xaxis); void UI_view2d_view_restore(const struct bContext *C); /* grid drawing */ @@ -234,5 +234,6 @@ void ED_keymap_view2d(struct wmKeyConfig *keyconf); void UI_view2d_smooth_view(struct bContext *C, struct ARegion *ar, const struct rctf *cur, const int smooth_viewtx); -#endif /* __UI_VIEW2D_H__ */ +#define UI_MARKER_MARGIN_Y (42 * UI_DPI_FAC) +#endif /* __UI_VIEW2D_H__ */ diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 1574ceace8a..db893896f89 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2794,7 +2794,7 @@ uiLayout *uiPieMenuLayout(uiPieMenu *pie) return pie->layout; } -void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *event) +int uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *event) { uiPieMenu *pie; uiLayout *layout; @@ -2803,11 +2803,11 @@ void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *even if (mt == NULL) { printf("%s: named menu \"%s\" not found\n", __func__, idname); - return; + return OPERATOR_CANCELLED; } if (mt->poll && mt->poll(C, mt) == 0) - return; + return OPERATOR_CANCELLED; pie = uiPieMenuBegin(C, IFACE_(mt->label), ICON_NONE, event); layout = uiPieMenuLayout(pie); @@ -2822,10 +2822,12 @@ void uiPieMenuInvoke(struct bContext *C, const char *idname, const wmEvent *even mt->draw(C, &menu); uiPieMenuEnd(C, pie); + + return OPERATOR_INTERFACE; } -void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname, - const char *propname, const wmEvent *event) +int uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname, + const char *propname, const wmEvent *event) { uiPieMenu *pie; uiLayout *layout; @@ -2837,10 +2839,12 @@ void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char * uiItemsEnumO(layout, opname, propname); uiPieMenuEnd(C, pie); + + return OPERATOR_INTERFACE; } -void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path, - const wmEvent *event) +int uiPieEnumInvoke(struct bContext *C, const char *title, const char *path, + const wmEvent *event) { PointerRNA ctx_ptr; PointerRNA r_ptr; @@ -2851,13 +2855,13 @@ void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path, RNA_pointer_create(NULL, &RNA_Context, C, &ctx_ptr); if (!RNA_path_resolve(&ctx_ptr, path, &r_ptr, &r_prop)) { - return; + return OPERATOR_CANCELLED; } /* invalid property, only accept enums */ if (RNA_property_type(r_prop) != PROP_ENUM) { BLI_assert(0); - return; + return OPERATOR_CANCELLED; } pie = uiPieMenuBegin(C, IFACE_(title), ICON_NONE, event); @@ -2868,6 +2872,8 @@ void uiPieEnumInvoke(struct bContext *C, const char *title, const char *path, uiItemFullR(layout, &r_ptr, r_prop, RNA_NO_INDEX, 0, UI_ITEM_R_EXPAND, NULL, 0); uiPieMenuEnd(C, pie); + + return OPERATOR_INTERFACE; } @@ -2922,7 +2928,7 @@ void uiPupMenuReports(bContext *C, ReportList *reports) } } -bool uiPupMenuInvoke(bContext *C, const char *idname, ReportList *reports) +int uiPupMenuInvoke(bContext *C, const char *idname, ReportList *reports) { uiPopupMenu *pup; uiLayout *layout; @@ -2931,11 +2937,11 @@ bool uiPupMenuInvoke(bContext *C, const char *idname, ReportList *reports) if (mt == NULL) { BKE_reportf(reports, RPT_ERROR, "Menu \"%s\" not found", idname); - return false; + return OPERATOR_CANCELLED; } if (mt->poll && mt->poll(C, mt) == 0) - return false; + return OPERATOR_CANCELLED; pup = uiPupMenuBegin(C, IFACE_(mt->label), ICON_NONE); layout = uiPupMenuLayout(pup); @@ -2951,7 +2957,7 @@ bool uiPupMenuInvoke(bContext *C, const char *idname, ReportList *reports) uiPupMenuEnd(C, pup); - return true; + return OPERATOR_INTERFACE; } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index b0bea42e3bc..6c054b93351 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -921,12 +921,18 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, uiBlockSetEmboss(block, UI_EMBOSSN); /* When Modifier is a simulation, show button to switch to context rather than the delete button. */ - if (modifier_can_delete(md) && (!modifier_is_simulation(md) || STREQ(scene->r.engine, "BLENDER_GAME"))) + if (modifier_can_delete(md) && + (!modifier_is_simulation(md) || + STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME))) + { uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove"); - else if (modifier_is_simulation(md) == 1) + } + else if (modifier_is_simulation(md) == 1) { uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PHYSICS"); - else if (modifier_is_simulation(md) == 2) + } + else if (modifier_is_simulation(md) == 2) { uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PARTICLES"); + } uiBlockSetEmboss(block, UI_EMBOSS); } @@ -1900,7 +1906,6 @@ static uiBlock *curvemap_clipping_func(bContext *C, ARegion *ar, void *cumap_v) uiBlockSetDirection(block, UI_RIGHT); - uiEndBlock(C, block); return block; } @@ -1975,7 +1980,6 @@ static uiBlock *curvemap_tools_posslope_func(bContext *C, ARegion *ar, void *cum uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); return block; } @@ -2003,7 +2007,6 @@ static uiBlock *curvemap_tools_negslope_func(bContext *C, ARegion *ar, void *cum uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); return block; } @@ -2027,7 +2030,6 @@ static uiBlock *curvemap_brush_tools_func(bContext *C, ARegion *ar, void *cumap_ uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 50); - uiEndBlock(C, block); return block; } @@ -3244,10 +3246,10 @@ static void operator_call_cb(bContext *C, void *UNUSED(arg1), void *arg2) static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) { - GHashIterator *iter = WM_operatortype_iter(); + GHashIterator iter; - for (; !BLI_ghashIterator_done(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot = BLI_ghashIterator_getValue(iter); + for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { + wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0) continue; @@ -3274,7 +3276,6 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char } } } - BLI_ghashIterator_free(iter); } void uiOperatorSearch_But(uiBut *but) diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index b7e61400cfa..46c2da902fe 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -746,6 +746,8 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glEnableClientState(GL_VERTEX_ARRAY); for (j = 0; j < WIDGET_AA_JITTER; j++) { + unsigned char emboss[4]; + glTranslatef(jit[j][0], jit[j][1], 0.0f); /* outline */ @@ -753,13 +755,17 @@ static void widgetbase_draw(uiWidgetBase *wtb, uiWidgetColors *wcol) glVertexPointer(2, GL_FLOAT, 0, quad_strip); glDrawArrays(GL_QUAD_STRIP, 0, wtb->totvert * 2 + 2); - + /* emboss bottom shadow */ - if (wtb->emboss) { - glColor4f(1.0f, 1.0f, 1.0f, 0.02f); + UI_GetThemeColor4ubv(TH_EMBOSS, emboss); - glVertexPointer(2, GL_FLOAT, 0, quad_strip_emboss); - glDrawArrays(GL_QUAD_STRIP, 0, wtb->halfwayvert * 2); + if (wtb->emboss) { + UI_GetThemeColor4ubv(TH_EMBOSS, emboss); + if (emboss[3]) { + glColor4ubv(emboss); + glVertexPointer(2, GL_FLOAT, 0, quad_strip_emboss); + glDrawArrays(GL_QUAD_STRIP, 0, wtb->halfwayvert * 2); + } } glTranslatef(-jit[j][0], -jit[j][1], 0.0f); diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index bcd85333709..5dc9ee0264e 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -619,6 +619,9 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp = ts->nla_sound_sel; break; + case TH_EMBOSS: + cp = btheme->tui.emboss; break; + case TH_AXIS_X: cp = btheme->tui.xaxis; break; case TH_AXIS_Y: @@ -815,6 +818,8 @@ void ui_theme_init_default(void) btheme->tui.panel.show_header = false; rgba_char_args_set(btheme->tui.panel.header, 0, 0, 0, 25); + rgba_char_args_set_fl(btheme->tui.emboss, 1.0f, 1.0f, 1.0f, 0.02f); + rgba_char_args_set(btheme->tui.xaxis, 220, 0, 0, 255); rgba_char_args_set(btheme->tui.yaxis, 0, 220, 0, 255); rgba_char_args_set(btheme->tui.zaxis, 0, 0, 220, 255); @@ -2491,6 +2496,13 @@ void init_userdef_do_versions(void) } } + if (U.versionfile < 272 || (U.versionfile == 272 && U.subversionfile < 2)) { + bTheme *btheme; + for (btheme = U.themes.first; btheme; btheme = btheme->next) { + rgba_char_args_set_fl(btheme->tui.emboss, 1.0f, 1.0f, 1.0f, 0.02f); + } + } + if (U.pixelsize == 0.0f) U.pixelsize = 1.0f; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index d48faa34618..6cc265d06ad 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1099,7 +1099,7 @@ void UI_view2d_view_ortho(View2D *v2d) /* Set view matrices to only use one axis of 'cur' only * - xaxis = if non-zero, only use cur x-axis, otherwise use cur-yaxis (mostly this will be used for x) */ -void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, short xaxis) +void UI_view2d_view_orthoSpecial(ARegion *ar, View2D *v2d, const bool xaxis) { rctf curmasked; float xofs, yofs; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index a396893f8f2..2b84c0678ae 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1726,7 +1726,7 @@ static void scroller_activate_apply(bContext *C, wmOperator *op) temp = vsm->fac * vsm->delta; /* round to pixel */ - temp = floorf(temp / vsm->fac_round + 0.5f) * vsm->fac_round; + temp = roundf(temp / vsm->fac_round) * vsm->fac_round; /* type of movement */ switch (vsm->zone) { diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 8972dd7cf08..24dcf85cec8 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -449,14 +449,23 @@ static int object_add_exec(bContext *C, wmOperator *op) Object *ob; bool enter_editmode; unsigned int layer; - float loc[3], rot[3]; + float loc[3], rot[3], radius; WM_operator_view3d_unit_defaults(C, op); if (!ED_object_add_generic_get_opts(C, op, 'Z', loc, rot, &enter_editmode, &layer, NULL)) return OPERATOR_CANCELLED; + radius = RNA_float_get(op->ptr, "radius"); ob = ED_object_add_type(C, RNA_enum_get(op->ptr, "type"), loc, rot, enter_editmode, layer); - BKE_object_obdata_size_init(ob, RNA_float_get(op->ptr, "radius")); + + if (ob->type == OB_LATTICE) { + /* lattice is a special case! + * we never want to scale the obdata since that is the rest-state */ + copy_v3_fl(ob->size, radius); + } + else { + BKE_object_obdata_size_init(ob, radius); + } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 92ed84b7f5e..7c11b3e9879 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -1911,7 +1911,7 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED /* finish building the menu, and process it (should result in calling self again) */ uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } /* call constraint_add_exec() to add the IK constraint */ diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 7cf661de52c..bef64fec8d0 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -320,6 +320,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) ED_keymap_proportional_cycle(keyconf, keymap); ED_keymap_proportional_obmode(keyconf, keymap); + /* game-engine only, leave free for users to define */ WM_keymap_add_item(keymap, "VIEW3D_OT_game_start", PKEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "OBJECT_OT_select_all", AKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 8f74278b424..798334ba2a7 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -309,14 +309,16 @@ static int make_proxy_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* present the menu and be done... */ uiPupMenuEnd(C, pup); + + /* this invoke just calls another instance of this operator... */ + return OPERATOR_INTERFACE; } else { /* error.. cannot continue */ BKE_report(op->reports, RPT_ERROR, "Can only make proxy for a referenced object or group"); + return OPERATOR_CANCELLED; } - /* this invoke just calls another instance of this operator... */ - return OPERATOR_CANCELLED; } static int make_proxy_exec(bContext *C, wmOperator *op) @@ -923,7 +925,7 @@ static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } static bool parent_set_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 450a3b19889..fb7653282b8 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -311,7 +311,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre * seems commonly used render engines does not support * such kind of rendering. */ - BLI_strncpy(sce->r.engine, "BLENDER_RENDER", sizeof(sce->r.engine)); + BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_RENDER, sizeof(sce->r.engine)); } else { BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine)); diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index df7ca9f11b2..6118db703b4 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -538,7 +538,7 @@ void ED_render_id_flush_update(Main *bmain, ID *id) void ED_render_internal_init(void) { - RenderEngineType *ret = RE_engines_find("BLENDER_RENDER"); + RenderEngineType *ret = RE_engines_find(RE_engine_id_BLENDER_RENDER); ret->view_update = render_view3d_update; ret->view_draw = render_view3d_draw; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index e38f3b5bee6..ed224b2d5c2 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1331,7 +1331,7 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand ARegion *ar; /* same local check for all areas */ static rcti rect = {0, 10000, 0, -1}; - rect.ymax = (30 * UI_DPI_FAC); + rect.ymax = UI_MARKER_MARGIN_Y; ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (ar) { WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index a4a7580c058..8d9371ef852 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2759,7 +2759,7 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } static void SCREEN_OT_area_options(wmOperatorType *ot) @@ -2866,7 +2866,7 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, const wmEvent *UNU uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } static int repeat_history_exec(bContext *C, wmOperator *op) @@ -3262,7 +3262,7 @@ static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEv uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } static void SCREEN_OT_header_toolbox(wmOperatorType *ot) diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 791c1b3ada1..304ca8509eb 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -5027,7 +5027,7 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); Material *ma; - bool is_bi = BKE_scene_uses_blender_internal(scene); + bool is_bi = BKE_scene_uses_blender_internal(scene) || BKE_scene_uses_blender_game(scene); Image *ima = NULL; if (!ob) @@ -5183,7 +5183,7 @@ static int texture_paint_delete_texture_paint_slot_exec(bContext *C, wmOperator Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); Material *ma; - bool is_bi = BKE_scene_uses_blender_internal(scene); + bool is_bi = BKE_scene_uses_blender_internal(scene) || BKE_scene_uses_blender_game(scene); TexPaintSlot *slot; /* not supported for node-based engines */ diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index e03c8a5f106..d41af26a4d1 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -292,6 +292,7 @@ static void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, c MVert mv[4]; float matrix[4][4], proj[4][4]; GLint view[4]; + ImagePaintMode mode = scene->toolsettings->imapaint.mode; /* compute barycentric coordinates */ @@ -320,19 +321,25 @@ static void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, c if (findex == faceindex) { dm->getTessFace(dm, a, &mf); - ma = dm->mat[mf.mat_nr]; - slot = &ma->texpaintslot[ma->paint_active_slot]; - dm->getVert(dm, mf.v1, &mv[0]); dm->getVert(dm, mf.v2, &mv[1]); dm->getVert(dm, mf.v3, &mv[2]); if (mf.v4) dm->getVert(dm, mf.v4, &mv[3]); - if (!(slot && slot->uvname && (tf_base = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, slot->uvname)))) - tf_base = CustomData_get_layer(&dm->faceData, CD_MTFACE); + if (mode == IMAGEPAINT_MODE_MATERIAL) { + ma = dm->mat[mf.mat_nr]; + slot = &ma->texpaintslot[ma->paint_active_slot]; - tf = &tf_base[a]; + if (!(slot && slot->uvname && (tf_base = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, slot->uvname)))) + tf_base = CustomData_get_layer(&dm->faceData, CD_MTFACE); + + tf = &tf_base[a]; + } + else { + tf_base = CustomData_get_layer(&dm->faceData, CD_MTFACE); + tf = &tf_base[a]; + } p[0] = xy[0]; p[1] = xy[1]; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 0e0012c198f..2e4c9a32607 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4738,7 +4738,7 @@ static int dyntopo_warning_popup(bContext *C, wmOperatorType *ot, bool vdata, bo uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 7ca8968a705..5d0b34a2e0c 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -197,8 +197,8 @@ static void action_main_area_draw(const bContext *C, ARegion *ar) /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); - flag = (ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0; - draw_markers_time(C, flag); + flag = ((ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0) | DRAW_MARKERS_MARGIN; + ED_markers_draw(C, flag); /* preview range */ UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index b651d684bf6..a62ec1b31e1 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -77,7 +77,7 @@ static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UN uiItemsEnumR(layout, &ptr, "align"); uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } void BUTTONS_OT_toolbox(wmOperatorType *ot) diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 6dba706b241..ef6cb198008 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -293,7 +293,7 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar) /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); - draw_markers_time(C, 0); + ED_markers_draw(C, DRAW_MARKERS_MARGIN); /* preview range */ UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index df556f94f28..b51897d1c5d 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -2256,7 +2256,7 @@ static int image_pack_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( BKE_image_release_ibuf(ima, ibuf, NULL); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } BKE_image_release_ibuf(ima, ibuf, NULL); diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 25fa31407ff..405c1f0a961 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -261,7 +261,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } void FILE_OT_unpack_all(wmOperatorType *ot) @@ -330,7 +330,7 @@ static int unpack_item_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } void FILE_OT_unpack_item(wmOperatorType *ot) diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index c787177a62a..fe0431b9618 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -2194,7 +2194,7 @@ static int nla_fmodifier_add_invoke(bContext *C, wmOperator *UNUSED(op), const w uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 134e5dd80a2..ee2914ad227 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -305,7 +305,7 @@ static void nla_main_area_draw(const bContext *C, ARegion *ar) /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); - draw_markers_time(C, 0); + ED_markers_draw(C, DRAW_MARKERS_MARGIN); /* preview range */ UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_node/node_group.c b/source/blender/editors/space_node/node_group.c index 96cc7fb4407..434d92d6531 100644 --- a/source/blender/editors/space_node/node_group.c +++ b/source/blender/editors/space_node/node_group.c @@ -571,7 +571,7 @@ static int node_group_separate_invoke(bContext *C, wmOperator *UNUSED(op), const uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } void NODE_OT_group_separate(wmOperatorType *ot) diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index ef621407abd..1ec41ac6df8 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1617,7 +1617,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event) uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } } else { diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 5801dd126e3..f8a90c942bc 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -434,7 +434,7 @@ static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *s outliner_add_element(soops, lb, sce->world, te, 0, 0); #ifdef WITH_FREESTYLE - if (STREQ(sce->r.engine, "BLENDER_RENDER") && (sce->r.mode & R_EDGE_FRS)) + if (STREQ(sce->r.engine, RE_engine_id_BLENDER_RENDER) && (sce->r.mode & R_EDGE_FRS)) outliner_add_line_styles(soops, lb, sce, te); #endif } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index f9ca713ad2d..1eb61f4bfd7 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1487,7 +1487,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar) /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); - draw_markers_time(C, DRAW_MARKERS_LINES); + ED_markers_draw(C, DRAW_MARKERS_LINES | DRAW_MARKERS_MARGIN); /* preview range */ UI_view2d_view_ortho(v2d); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 01259bb688f..2270c7dbe55 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1232,7 +1232,7 @@ void SEQUENCER_OT_snap(struct wmOperatorType *ot) } -typedef struct TrimData { +typedef struct SlipData { int init_mouse[2]; float init_mouseloc[2]; TransSeq *ts; @@ -1241,7 +1241,7 @@ typedef struct TrimData { int num_seq; bool slow; int slow_offset; /* offset at the point where offset was turned on */ -} TrimData; +} SlipData; static void transseq_backup(TransSeq *ts, Sequence *seq) { @@ -1274,7 +1274,7 @@ static void transseq_restore(TransSeq *ts, Sequence *seq) seq->len = ts->len; } -static int trim_add_sequences_rec(ListBase *seqbasep, Sequence **seq_array, bool *trim, int offset, bool first_level) +static int slip_add_sequences_rec(ListBase *seqbasep, Sequence **seq_array, bool *trim, int offset, bool first_level) { Sequence *seq; int num_items = 0; @@ -1287,7 +1287,7 @@ static int trim_add_sequences_rec(ListBase *seqbasep, Sequence **seq_array, bool if (seq->type == SEQ_TYPE_META) { /* trim the sub-sequences */ - num_items += trim_add_sequences_rec(&seq->seqbase, seq_array, trim, num_items + offset, false); + num_items += slip_add_sequences_rec(&seq->seqbase, seq_array, trim, num_items + offset, false); } else if (seq->type & SEQ_TYPE_EFFECT) { trim[offset + num_items] = false; @@ -1298,7 +1298,7 @@ static int trim_add_sequences_rec(ListBase *seqbasep, Sequence **seq_array, bool return num_items; } -static int trim_count_sequences_rec(ListBase *seqbasep, bool first_level) +static int slip_count_sequences_rec(ListBase *seqbasep, bool first_level) { Sequence *seq; int trimmed_sequences = 0; @@ -1309,7 +1309,7 @@ static int trim_count_sequences_rec(ListBase *seqbasep, bool first_level) if (seq->type == SEQ_TYPE_META) { /* trim the sub-sequences */ - trimmed_sequences += trim_count_sequences_rec(&seq->seqbase, false); + trimmed_sequences += slip_count_sequences_rec(&seq->seqbase, false); } } } @@ -1317,9 +1317,9 @@ static int trim_count_sequences_rec(ListBase *seqbasep, bool first_level) return trimmed_sequences; } -static int sequencer_trim_invoke(bContext *C, wmOperator *op, const wmEvent *event) +static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - TrimData *data; + SlipData *data; Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); float mouseloc[2]; @@ -1327,18 +1327,18 @@ static int sequencer_trim_invoke(bContext *C, wmOperator *op, const wmEvent *eve View2D *v2d = UI_view2d_fromcontext(C); /* first recursively cound the trimmed elements */ - num_seq = trim_count_sequences_rec(ed->seqbasep, true); + num_seq = slip_count_sequences_rec(ed->seqbasep, true); if (num_seq == 0) return OPERATOR_CANCELLED; - data = op->customdata = MEM_mallocN(sizeof(TrimData), "trimdata"); + data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata"); data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform"); data->seq_array = MEM_mallocN(num_seq * sizeof(Sequence *), "trimdata_sequences"); data->trim = MEM_mallocN(num_seq * sizeof(bool), "trimdata_trim"); data->num_seq = num_seq; - trim_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true); + slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true); for (i = 0; i < num_seq; i++) { transseq_backup(data->ts + i, data->seq_array[i]); @@ -1356,7 +1356,7 @@ static int sequencer_trim_invoke(bContext *C, wmOperator *op, const wmEvent *eve return OPERATOR_RUNNING_MODAL; } -static bool sequencer_trim_recursively(Scene *scene, TrimData *data, int offset) +static bool sequencer_slip_recursively(Scene *scene, SlipData *data, int offset) { /* only data types supported for now */ @@ -1415,9 +1415,9 @@ static bool sequencer_trim_recursively(Scene *scene, TrimData *data, int offset) return false; } -static int sequencer_trim_exec(bContext *C, wmOperator *op) +static int sequencer_slip_exec(bContext *C, wmOperator *op) { - TrimData *data; + SlipData *data; Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); int num_seq, i; @@ -1425,24 +1425,24 @@ static int sequencer_trim_exec(bContext *C, wmOperator *op) bool success = false; /* first recursively cound the trimmed elements */ - num_seq = trim_count_sequences_rec(ed->seqbasep, true); + num_seq = slip_count_sequences_rec(ed->seqbasep, true); if (num_seq == 0) return OPERATOR_CANCELLED; - data = op->customdata = MEM_mallocN(sizeof(TrimData), "trimdata"); + data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata"); data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform"); data->seq_array = MEM_mallocN(num_seq * sizeof(Sequence *), "trimdata_sequences"); data->trim = MEM_mallocN(num_seq * sizeof(bool), "trimdata_trim"); data->num_seq = num_seq; - trim_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true); + slip_add_sequences_rec(ed->seqbasep, data->seq_array, data->trim, 0, true); for (i = 0; i < num_seq; i++) { transseq_backup(data->ts + i, data->seq_array[i]); } - success = sequencer_trim_recursively(scene, data, offset); + success = sequencer_slip_recursively(scene, data, offset); MEM_freeN(data->seq_array); MEM_freeN(data->trim); @@ -1453,10 +1453,10 @@ static int sequencer_trim_exec(bContext *C, wmOperator *op) else return OPERATOR_CANCELLED; } -static int sequencer_trim_modal(bContext *C, wmOperator *op, const wmEvent *event) +static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *event) { Scene *scene = CTX_data_scene(C); - TrimData *data = (TrimData *)op->customdata; + SlipData *data = (SlipData *)op->customdata; ScrArea *sa = CTX_wm_area(C); switch (event->type) { @@ -1491,7 +1491,7 @@ static int sequencer_trim_modal(bContext *C, wmOperator *op, const wmEvent *even ED_area_headerprint(sa, msg); } - if (sequencer_trim_recursively(scene, data, offset)) { + if (sequencer_slip_recursively(scene, data, offset)) { WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); } break; @@ -1562,17 +1562,17 @@ static int sequencer_trim_modal(bContext *C, wmOperator *op, const wmEvent *even return OPERATOR_RUNNING_MODAL; } -void SEQUENCER_OT_trim(struct wmOperatorType *ot) +void SEQUENCER_OT_slip(struct wmOperatorType *ot) { /* identifiers */ ot->name = "Trim Strips"; - ot->idname = "SEQUENCER_OT_trim"; + ot->idname = "SEQUENCER_OT_slip"; ot->description = "Trim the contents of the active strip"; /* api callbacks */ - ot->invoke = sequencer_trim_invoke; - ot->modal = sequencer_trim_modal; - ot->exec = sequencer_trim_exec; + ot->invoke = sequencer_slip_invoke; + ot->modal = sequencer_slip_modal; + ot->exec = sequencer_slip_exec; ot->poll = sequencer_edit_poll; /* flags */ diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index 4fada72d0d9..438696d0327 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -84,7 +84,7 @@ struct wmOperatorType; struct wmKeyConfig; void SEQUENCER_OT_cut(struct wmOperatorType *ot); -void SEQUENCER_OT_trim(struct wmOperatorType *ot); +void SEQUENCER_OT_slip(struct wmOperatorType *ot); void SEQUENCER_OT_mute(struct wmOperatorType *ot); void SEQUENCER_OT_unmute(struct wmOperatorType *ot); void SEQUENCER_OT_lock(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_sequencer/sequencer_ops.c b/source/blender/editors/space_sequencer/sequencer_ops.c index dff8f69509e..88646b55e23 100644 --- a/source/blender/editors/space_sequencer/sequencer_ops.c +++ b/source/blender/editors/space_sequencer/sequencer_ops.c @@ -50,7 +50,7 @@ void sequencer_operatortypes(void) { /* sequencer_edit.c */ WM_operatortype_append(SEQUENCER_OT_cut); - WM_operatortype_append(SEQUENCER_OT_trim); + WM_operatortype_append(SEQUENCER_OT_slip); WM_operatortype_append(SEQUENCER_OT_mute); WM_operatortype_append(SEQUENCER_OT_unmute); WM_operatortype_append(SEQUENCER_OT_lock); @@ -317,7 +317,7 @@ void sequencer_keymap(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "SEQUENCER_MT_change", CKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "SEQUENCER_OT_trim", TKEY, KM_PRESS, 0, 0); + WM_keymap_add_item(keymap, "SEQUENCER_OT_slip", SKEY, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "WM_OT_context_set_int", OKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "scene.sequence_editor.overlay_frame"); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 852edaac7dc..3b3c86d6c06 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -3173,7 +3173,7 @@ static int text_resolve_conflict_invoke(bContext *C, wmOperator *op, const wmEve break; } - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } void TEXT_OT_resolve_conflict(wmOperatorType *ot) diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 88c57d45b79..d26ee982b20 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -520,7 +520,7 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); - draw_markers_time(C, 0); + ED_markers_draw(C, 0); /* caches */ time_draw_cache(stime, obact, scene); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 61bfb0176ef..32b4e4d1809 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -3413,7 +3413,7 @@ static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3 rv3d->rflag &= ~RV3D_IS_GAME_ENGINE; #ifdef WITH_GAMEENGINE - if (STREQ(scene->r.engine, "BLENDER_GAME")) { + if (STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME)) { rv3d->rflag |= RV3D_IS_GAME_ENGINE; /* Make sure LoDs are up to date */ diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index 3f7f12d2020..11e91800f88 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -151,10 +151,10 @@ static void operator_call_cb(struct bContext *C, void *arg_listbase, void *arg2) static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) { - GHashIterator *iter = WM_operatortype_iter(); + GHashIterator iter; - for (; !BLI_ghashIterator_done(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot = BLI_ghashIterator_getValue(iter); + for (WM_operatortype_iter(&iter); !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter)) { + wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); if (BLI_strcasestr(ot->name, str)) { if (WM_operator_poll((bContext *)C, ot)) { @@ -164,7 +164,6 @@ static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), cons } } } - BLI_ghashIterator_free(iter); } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 858d001a381..9faca757c62 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -1543,18 +1543,22 @@ static void game_set_commmandline_options(GameData *gm) static int game_engine_poll(bContext *C) { + bScreen *screen; /* we need a context and area to launch BGE * it's a temporary solution to avoid crash at load time * if we try to auto run the BGE. Ideally we want the * context to be set as soon as we load the file. */ if (CTX_wm_window(C) == NULL) return 0; - if (CTX_wm_screen(C) == NULL) return 0; + if ((screen = CTX_wm_screen(C)) == NULL) return 0; if (CTX_wm_area(C) == NULL) return 0; if (CTX_data_mode_enum(C) != CTX_MODE_OBJECT) return 0; + if (!BKE_scene_uses_blender_game(screen->scene)) + return 0; + return 1; } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 24499688835..068fce106a3 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1125,47 +1125,22 @@ int transformEvent(TransInfo *t, const wmEvent *event) handled = true; break; case TFM_MODAL_AXIS_X: - if ((t->flag & T_NO_CONSTRAINT) == 0) { - if (cmode == 'X') { - stopConstraint(t); - } - else { - if (t->flag & T_2D_EDIT) { - setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS0), IFACE_("along X")); - } - else { - setUserConstraint(t, t->current_orientation, (CON_AXIS0), IFACE_("along %s X")); - } - } + if (!(t->flag & T_NO_CONSTRAINT)) { + transform_event_xyz_constraint(t, XKEY, cmode); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_AXIS_Y: if ((t->flag & T_NO_CONSTRAINT) == 0) { - if (cmode == 'Y') { - stopConstraint(t); - } - else { - if (t->flag & T_2D_EDIT) { - setUserConstraint(t, V3D_MANIP_GLOBAL, (CON_AXIS1), IFACE_("along Y")); - } - else { - setUserConstraint(t, t->current_orientation, (CON_AXIS1), IFACE_("along %s Y")); - } - } + transform_event_xyz_constraint(t, YKEY, cmode); t->redraw |= TREDRAW_HARD; handled = true; } break; case TFM_MODAL_AXIS_Z: - if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) { - if (cmode == 'Z') { - stopConstraint(t); - } - else { - setUserConstraint(t, t->current_orientation, (CON_AXIS2), IFACE_("along %s Z")); - } + if ((t->flag & (T_NO_CONSTRAINT)) == 0) { + transform_event_xyz_constraint(t, ZKEY, cmode); t->redraw |= TREDRAW_HARD; handled = true; } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 81e065ee33a..05a147fe0d4 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -176,7 +176,7 @@ static int select_orientation_invoke(bContext *C, wmOperator *UNUSED(op), const uiItemsEnumO(layout, "TRANSFORM_OT_select_orientation", "orientation"); uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } static void TRANSFORM_OT_select_orientation(struct wmOperatorType *ot) diff --git a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp index 57882cbce0c..dfcc77d3b23 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderFileLoader.cpp @@ -457,6 +457,7 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id) unsigned nSize = vSize; float *normals = new float[nSize]; unsigned *numVertexPerFaces = new unsigned[numFaces]; + vector<Material *> meshMaterials; vector<FrsMaterial> meshFrsMaterials; IndexedFaceSet::TRIANGLES_STYLE *faceStyle = new IndexedFaceSet::TRIANGLES_STYLE[numFaces]; @@ -588,20 +589,21 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id) tmpMat.setPriority(mat->line_priority); } - if (meshFrsMaterials.empty()) { + if (meshMaterials.empty()) { + meshMaterials.push_back(mat); meshFrsMaterials.push_back(tmpMat); shape->setFrsMaterial(tmpMat); } else { - // find if the material is already in the list + // find if the Blender material is already in the list unsigned int i = 0; bool found = false; - for (vector<FrsMaterial>::iterator it = meshFrsMaterials.begin(), itend = meshFrsMaterials.end(); + for (vector<Material *>::iterator it = meshMaterials.begin(), itend = meshMaterials.end(); it != itend; it++, i++) { - if (*it == tmpMat) { + if (*it == mat) { ls.currentMIndex = i; found = true; break; @@ -609,6 +611,7 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id) } if (!found) { + meshMaterials.push_back(mat); meshFrsMaterials.push_back(tmpMat); ls.currentMIndex = meshFrsMaterials.size() - 1; } diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index 456118d4d2f..09701ab6acd 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -448,7 +448,7 @@ void BlenderStrokeRenderer::RenderStrokeRep(StrokeRep *iStrokeRep) const BLI_ghash_insert(_nodetree_hash, nt, ma); } - if (strcmp(freestyle_scene->r.engine, "CYCLES") == 0) { + if (STREQ(freestyle_scene->r.engine, RE_engine_id_CYCLES)) { PointerRNA scene_ptr, freestyle_scene_ptr; RNA_pointer_create(NULL, &RNA_Scene, old_scene, &scene_ptr); RNA_pointer_create(NULL, &RNA_Scene, freestyle_scene, &freestyle_scene_ptr); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index f8f962107f6..745b21618ca 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1484,7 +1484,10 @@ enum { /* sequencer seq_prev_type seq_rend_type */ - +/* scene->r.engine (scene.c) */ +extern const char *RE_engine_id_BLENDER_RENDER; +extern const char *RE_engine_id_BLENDER_GAME; +extern const char *RE_engine_id_CYCLES; /* **************** SCENE ********************* */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 769e2573aa4..d8653e1f5fe 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -168,11 +168,13 @@ typedef struct ThemeUI { uiPanelColors panel; /* depricated, but we keep it for do_versions (2.66.1) */ + char emboss[4]; + /* fac: 0 - 1 for blend factor, width in pixels */ float menu_shadow_fac; short menu_shadow_width; - short pad; + short pad[3]; char iconfile[256]; // FILE_MAXFILE length float icon_alpha; diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h index 4cf6bfe9a8f..73a70b48712 100644 --- a/source/blender/makesdna/DNA_windowmanager_types.h +++ b/source/blender/makesdna/DNA_windowmanager_types.h @@ -352,13 +352,22 @@ enum { OPERATOR_RUNNING_MODAL = (1 << 0), OPERATOR_CANCELLED = (1 << 1), OPERATOR_FINISHED = (1 << 2), -/* add this flag if the event should pass through */ + /* add this flag if the event should pass through */ OPERATOR_PASS_THROUGH = (1 << 3), -/* in case operator got executed outside WM code... like via fileselect */ + /* in case operator got executed outside WM code... like via fileselect */ OPERATOR_HANDLED = (1 << 4), + /* used for operators that act indirectly (eg. popup menu) + * note: this isn't great design (using operators to trigger UI) avoid where possible. */ + OPERATOR_INTERFACE = (1 << 5), }; -#define OPERATOR_FLAGS_ALL (OPERATOR_RUNNING_MODAL | OPERATOR_CANCELLED | OPERATOR_FINISHED | \ - OPERATOR_PASS_THROUGH | OPERATOR_HANDLED) +#define OPERATOR_FLAGS_ALL ( \ + OPERATOR_RUNNING_MODAL | \ + OPERATOR_CANCELLED | \ + OPERATOR_FINISHED | \ + OPERATOR_PASS_THROUGH | \ + OPERATOR_HANDLED | \ + OPERATOR_INTERFACE | \ + 0) /* sanity checks for debug mode only */ #define OPERATOR_RETVAL_CHECK(ret) (void)ret, BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret) diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 1bad9570893..a23c3ea8534 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1018,6 +1018,12 @@ static void rna_def_userdef_theme_ui(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Icon Alpha", "Transparency of icons in the interface, to reduce contrast"); RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "emboss", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_float_sdna(prop, NULL, "emboss"); + RNA_def_property_array(prop, 4); + RNA_def_property_ui_text(prop, "Emboss", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + /* axis */ prop = RNA_def_property(srna, "axis_x", PROP_FLOAT, PROP_COLOR_GAMMA); RNA_def_property_float_sdna(prop, NULL, "xaxis"); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 7513a687978..3c39308e7dc 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -429,6 +429,7 @@ EnumPropertyItem operator_return_items[] = { {OPERATOR_FINISHED, "FINISHED", 0, "Finished", "When the operator is complete, operator exits"}, /* used as a flag */ {OPERATOR_PASS_THROUGH, "PASS_THROUGH", 0, "Pass Through", "Do nothing and pass the event on"}, + {OPERATOR_INTERFACE, "INTERFACE", 0, "Interface", "Handled but not executed (popup menus)"}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index 299172ae4cc..bea1d0532e8 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -70,9 +70,9 @@ static int shader_tree_poll(const bContext *C, bNodeTreeType *UNUSED(treetype)) Scene *scene = CTX_data_scene(C); /* allow empty engine string too, this is from older versions that didn't have registerable engines yet */ return (scene->r.engine[0] == '\0' || - STREQ(scene->r.engine, "BLENDER_RENDER") || - STREQ(scene->r.engine, "BLENDER_GAME") || - STREQ(scene->r.engine, "CYCLES")); + STREQ(scene->r.engine, RE_engine_id_BLENDER_RENDER) || + STREQ(scene->r.engine, RE_engine_id_BLENDER_GAME) || + STREQ(scene->r.engine, RE_engine_id_CYCLES)); } static void shader_get_from_context(const bContext *C, bNodeTreeType *UNUSED(treetype), bNodeTree **r_ntree, ID **r_id, ID **r_from) diff --git a/source/blender/python/bmesh/bmesh_py_types.c b/source/blender/python/bmesh/bmesh_py_types.c index a31345cd7f5..8c13a66bea0 100644 --- a/source/blender/python/bmesh/bmesh_py_types.c +++ b/source/blender/python/bmesh/bmesh_py_types.c @@ -2311,6 +2311,22 @@ static PyObject *bpy_bmelemseq_index_update(BPy_BMElemSeq *self) Py_RETURN_NONE; } +PyDoc_STRVAR(bpy_bmelemseq_ensure_lookup_table_doc, +".. method:: ensure_lookup_table()\n" +"\n" +" Ensure internal data needed for int subscription is initialized with verts/edges/faces, eg ``bm.verts[index]``.\n" +"\n" +" This needs to be called again after adding/removing data in this sequence." +); +static PyObject *bpy_bmelemseq_ensure_lookup_table(BPy_BMElemSeq *self) +{ + BPY_BM_CHECK_OBJ(self); + + BM_mesh_elem_table_ensure(self->bm, bm_iter_itype_htype_map[self->itype]); + + Py_RETURN_NONE; +} + PyDoc_STRVAR(bpy_bmelemseq_sort_doc, ".. method:: sort(key=None, reverse=False)\n" "\n" @@ -2605,6 +2621,7 @@ static struct PyMethodDef bpy_bmvertseq_methods[] = { /* odd function, initializes index values */ {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc}, + {"ensure_lookup_table", (PyCFunction)bpy_bmelemseq_ensure_lookup_table, METH_NOARGS, bpy_bmelemseq_ensure_lookup_table_doc}, {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc}, {NULL, NULL, 0, NULL} }; @@ -2617,6 +2634,7 @@ static struct PyMethodDef bpy_bmedgeseq_methods[] = { /* odd function, initializes index values */ {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc}, + {"ensure_lookup_table", (PyCFunction)bpy_bmelemseq_ensure_lookup_table, METH_NOARGS, bpy_bmelemseq_ensure_lookup_table_doc}, {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc}, {NULL, NULL, 0, NULL} }; @@ -2629,6 +2647,7 @@ static struct PyMethodDef bpy_bmfaceseq_methods[] = { /* odd function, initializes index values */ {"index_update", (PyCFunction)bpy_bmelemseq_index_update, METH_NOARGS, bpy_bmelemseq_index_update_doc}, + {"ensure_lookup_table", (PyCFunction)bpy_bmelemseq_ensure_lookup_table, METH_NOARGS, bpy_bmelemseq_ensure_lookup_table_doc}, {"sort", (PyCFunction)bpy_bmelemseq_sort, METH_VARARGS | METH_KEYWORDS, bpy_bmelemseq_sort_doc}, {NULL, NULL, 0, NULL} }; @@ -2725,9 +2744,43 @@ static PyObject *bpy_bmelemseq_subscript_int(BPy_BMElemSeq *self, int keynum) if (keynum < 0) keynum += bpy_bmelemseq_length(self); /* only get length on negative value, may loop entire seq */ if (keynum >= 0) { - BMHeader *ele = BM_iter_at_index(self->bm, self->itype, self->py_ele ? self->py_ele->ele : NULL, keynum); - if (ele) { - return BPy_BMElem_CreatePyObject(self->bm, ele); + if (self->itype <= BM_FACES_OF_MESH) { + if ((self->bm->elem_table_dirty & bm_iter_itype_htype_map[self->itype]) == 0) { + BMHeader *ele = NULL; + switch (self->itype) { + case BM_VERTS_OF_MESH: + if (keynum < self->bm->totvert) { + ele = (BMHeader *)self->bm->vtable[keynum]; + } + break; + case BM_EDGES_OF_MESH: + if (keynum < self->bm->totedge) { + ele = (BMHeader *)self->bm->etable[keynum]; + } + break; + case BM_FACES_OF_MESH: + if (keynum < self->bm->totface) { + ele = (BMHeader *)self->bm->ftable[keynum]; + } + break; + } + if (ele) { + return BPy_BMElem_CreatePyObject(self->bm, ele); + } + /* fall through to index error below */ + } + else { + PyErr_SetString(PyExc_IndexError, + "BMElemSeq[index]: outdated internal index table, " + "run ensure_lookup_table() first"); + return NULL; + } + } + else { + BMHeader *ele = BM_iter_at_index(self->bm, self->itype, self->py_ele ? self->py_ele->ele : NULL, keynum); + if (ele) { + return BPy_BMElem_CreatePyObject(self->bm, ele); + } } } diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index 1e97d7aeada..86282f251c3 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -367,17 +367,17 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) static PyObject *pyop_dir(PyObject *UNUSED(self)) { - GHashIterator *iter = WM_operatortype_iter(); - PyObject *list = PyList_New(0), *name; + GHashIterator iter; + PyObject *list; + int i; - for ( ; !BLI_ghashIterator_done(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot = BLI_ghashIterator_getValue(iter); + WM_operatortype_iter(&iter); + list = PyList_New(BLI_ghash_size(iter.gh)); - name = PyUnicode_FromString(ot->idname); - PyList_Append(list, name); - Py_DECREF(name); + for (i = 0; !BLI_ghashIterator_done(&iter); BLI_ghashIterator_step(&iter), i++) { + wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); + PyList_SET_ITEM(list, i, PyUnicode_FromString(ot->idname)); } - BLI_ghashIterator_free(iter); return list; } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 7b43c77537f..c112f3da060 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -3098,7 +3098,8 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri if (G.is_break == true) { /* remove touched file */ if (BKE_imtype_is_movie(scene->r.im_format.imtype) == 0) { - if (scene->r.mode & R_TOUCH && BLI_exists(name) && BLI_file_size(name) == 0) { + if ((scene->r.mode & R_TOUCH) && (BLI_file_size(name) == 0)) { + /* BLI_exists(name) is implicit */ BLI_delete(name, false, false); } } diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index e1cd334637a..a580260c5b0 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -47,6 +47,7 @@ extern "C" { #endif struct bContext; +struct GHashIterator; struct IDProperty; struct wmEvent; struct wmEventHandler; @@ -223,12 +224,13 @@ void WM_operator_stack_clear(struct wmWindowManager *wm); void WM_operator_handlers_clear(wmWindowManager *wm, struct wmOperatorType *ot); struct wmOperatorType *WM_operatortype_find(const char *idname, bool quiet); -struct GHashIterator *WM_operatortype_iter(void); +void WM_operatortype_iter(struct GHashIterator *ghi); void WM_operatortype_append(void (*opfunc)(struct wmOperatorType *)); void WM_operatortype_append_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata); void WM_operatortype_append_macro_ptr(void (*opfunc)(struct wmOperatorType *, void *), void *userdata); void WM_operatortype_remove_ptr(struct wmOperatorType *ot); bool WM_operatortype_remove(const char *idname); +void WM_operatortype_last_properties_clear_all(void); struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag); struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname); diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 7865e09cbe2..8f0f76466e9 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -476,6 +476,8 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) BPY_python_reset(C); #endif + WM_operatortype_last_properties_clear_all(); + /* important to do before NULL'ing the context */ BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE); BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); @@ -668,6 +670,8 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c } #endif + WM_operatortype_last_properties_clear_all(); + /* important to do before NULL'ing the context */ BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_VERSION_UPDATE); BLI_callback_exec(CTX_data_main(C), NULL, BLI_CB_EVT_LOAD_POST); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 68aad2dbda6..3b0fa042f36 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -147,9 +147,9 @@ wmOperatorType *WM_operatortype_find(const char *idname, bool quiet) } /* caller must free */ -GHashIterator *WM_operatortype_iter(void) +void WM_operatortype_iter(GHashIterator *ghi) { - return BLI_ghashIterator_new(global_ops_hash); + BLI_ghashIterator_init(ghi, global_ops_hash); } /* all ops in 1 list (for time being... needs evaluation later) */ @@ -494,6 +494,27 @@ bool WM_operatortype_remove(const char *idname) return true; } +/** + * Remove memory of all previously executed tools. + */ +void WM_operatortype_last_properties_clear_all(void) +{ + GHashIterator iter; + + for (WM_operatortype_iter(&iter); + (!BLI_ghashIterator_done(&iter)); + (BLI_ghashIterator_step(&iter))) + { + wmOperatorType *ot = BLI_ghashIterator_getValue(&iter); + + if (ot->last_properties) { + IDP_FreeProperty(ot->last_properties); + MEM_freeN(ot->last_properties); + ot->last_properties = NULL; + } + } +} + /* SOME_OT_op -> some.op */ void WM_operator_py_idname(char *to, const char *from) { @@ -1058,6 +1079,7 @@ int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN); uiItemsFullEnumO(layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0); uiPupMenuEnd(C, pup); + return OPERATOR_INTERFACE; } return OPERATOR_CANCELLED; @@ -1102,7 +1124,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op) int WM_enum_search_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) { uiPupBlock(C, wm_enum_search_menu, op); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } /* Can't be used as an invoke directly, needs message arg (can be NULL) */ @@ -1124,7 +1146,7 @@ int WM_operator_confirm_message_ex(bContext *C, wmOperator *op, uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0); uiPupMenuEnd(C, pup); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message) @@ -1997,7 +2019,7 @@ static int wm_search_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNU { uiPupBlock(C, wm_block_search_menu, op); - return OPERATOR_CANCELLED; + return OPERATOR_INTERFACE; } /* op->poll */ @@ -2036,9 +2058,7 @@ static int wm_call_menu_exec(bContext *C, wmOperator *op) char idname[BKE_ST_MAXNAME]; RNA_string_get(op->ptr, "name", idname); - uiPupMenuInvoke(C, idname, op->reports); - - return OPERATOR_CANCELLED; + return uiPupMenuInvoke(C, idname, op->reports); } static void WM_OT_call_menu(wmOperatorType *ot) @@ -2060,9 +2080,7 @@ static int wm_call_pie_menu_invoke(bContext *C, wmOperator *op, const wmEvent *e char idname[BKE_ST_MAXNAME]; RNA_string_get(op->ptr, "name", idname); - uiPieMenuInvoke(C, idname, event); - - return OPERATOR_CANCELLED; + return uiPieMenuInvoke(C, idname, event); } static int wm_call_pie_menu_exec(bContext *C, wmOperator *op) @@ -2070,9 +2088,7 @@ static int wm_call_pie_menu_exec(bContext *C, wmOperator *op) char idname[BKE_ST_MAXNAME]; RNA_string_get(op->ptr, "name", idname); - uiPieMenuInvoke(C, idname, CTX_wm_window(C)->eventstate); - - return OPERATOR_CANCELLED; + return uiPieMenuInvoke(C, idname, CTX_wm_window(C)->eventstate); } static void WM_OT_call_menu_pie(wmOperatorType *ot) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 0846e37178d..25830fb77f0 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -597,7 +597,7 @@ void RE_FreePersistentData(void) RET_NONE /* python */ struct wmOperatorType *WM_operatortype_find(const char *idname, bool quiet) RET_NULL -struct GHashIterator *WM_operatortype_iter() RET_NULL +void WM_operatortype_iter(struct GHashIterator *ghi) RET_NONE struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname) RET_NULL int WM_operator_call_py(struct bContext *C, struct wmOperatorType *ot, short context, struct PointerRNA *properties, struct ReportList *reports, const bool is_undo) RET_ZERO void WM_operatortype_remove_ptr(struct wmOperatorType *ot) RET_NONE @@ -626,11 +626,11 @@ struct uiPopupMenu *uiPupMenuBegin(struct bContext *C, const char *title, int ic void uiPupMenuEnd(struct bContext *C, struct uiPopupMenu *head) RET_NONE struct uiLayout *uiPupMenuLayout(struct uiPopupMenu *head) RET_NULL struct uiLayout *uiPieMenuLayout(struct uiPieMenu *pie) RET_NULL -void uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event) RET_NONE +int uiPieMenuInvoke(struct bContext *C, const char *idname, const struct wmEvent *event) RET_NONE struct uiPieMenu *uiPieMenuBegin(struct bContext *C, const char *title, int icon, const struct wmEvent *event) RET_NULL void uiPieMenuEnd(struct bContext *C, uiPieMenu *pie) RET_NONE struct uiLayout *uiLayoutRadial(struct uiLayout *layout) RET_NULL -void uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname, +int uiPieOperatorEnumInvoke(struct bContext *C, const char *title, const char *opname, const char *propname, const struct wmEvent *event) RET_NONE /* RNA COLLADA dependency */ |