diff options
92 files changed, 898 insertions, 624 deletions
diff --git a/extern/bullet2/CMakeLists.txt b/extern/bullet2/CMakeLists.txt index 4bf26ab3794..c57474f99f2 100644 --- a/extern/bullet2/CMakeLists.txt +++ b/extern/bullet2/CMakeLists.txt @@ -314,6 +314,7 @@ set(SRC src/BulletDynamics/Character/btKinematicCharacterController.h src/BulletSoftBody/btSoftBody.h + src/BulletSoftBody/btSoftBodyInternals.h src/BulletSoftBody/btSoftBodyData.h src/BulletSoftBody/btSoftBodyConcaveCollisionAlgorithm.h src/BulletSoftBody/btSoftBodyHelpers.h @@ -355,6 +356,7 @@ set(SRC src/btBulletCollisionCommon.h src/btBulletDynamicsCommon.h + src/Bullet-C-Api.h ) if(CMAKE_COMPILER_IS_GNUCXX) diff --git a/intern/cycles/app/cycles_test.cpp b/intern/cycles/app/cycles_test.cpp index 75f76efc8e1..5ee351260c5 100644 --- a/intern/cycles/app/cycles_test.cpp +++ b/intern/cycles/app/cycles_test.cpp @@ -66,12 +66,13 @@ static void session_print(const string& str) static void session_print_status() { - int sample; + int sample, tile; double total_time, sample_time; string status, substatus; /* get status */ - options.session->progress.get_sample(sample, total_time, sample_time); + sample = options.session->progress.get_sample(); + options.session->progress.get_tile(tile, total_time, sample_time); options.session->progress.get_status(status, substatus); if(substatus != "") @@ -111,7 +112,7 @@ static void session_init() static void scene_init(int width, int height) { - options.scene = new Scene(options.scene_params); + options.scene = new Scene(options.scene_params, options.session_params.device); xml_read_file(options.scene, options.filepath.c_str()); if (width == 0 || height == 0) { @@ -147,11 +148,12 @@ static void display_info(Progress& progress) latency = (elapsed - last); last = elapsed; - int sample; + int sample, tile; double total_time, sample_time; string status, substatus; - progress.get_sample(sample, total_time, sample_time); + sample = progress.get_sample(); + progress.get_tile(tile, total_time, sample_time); progress.get_status(status, substatus); if(substatus != "") diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index c23f0196c2d..7f3eca471e6 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -244,7 +244,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): cls.resolution_divider = IntProperty( name="Resolution Divider", - description="Start viewport rendering with lower resolution which would be real resolution divided by two in power of this value", + description="For viewport render, the number of lower resolutions to render before the full resolution", min=1, max=512, default=4, ) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 885b488a3ea..bf44a558b1a 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -213,6 +213,8 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel): sub.prop(cscene, "debug_use_spatial_splits") sub.prop(cscene, "use_cache") + sub = col.column(align=True) + sub.label(text="Viewport:") sub.prop(cscene, "resolution_divider") diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index fd9f836eec0..eb9deb0de2d 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -305,8 +305,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion) for(; b_sce && !cancel; b_sce = b_sce.background_set()) { for(b_sce.objects.begin(b_ob); b_ob != b_sce.objects.end() && !cancel; ++b_ob) { bool hide = (render_layer.use_viewport_visibility)? b_ob->hide(): b_ob->hide_render(); - uint ob_layer = get_layer(b_ob->layers(), b_ob->layers_local_view(), object_is_light(*b_ob)); - CYCLES_LOCAL_LAYER_HACK(render_layer.use_localview, ob_layer); + uint ob_layer = get_layer(b_ob->layers(), b_ob->layers_local_view(), render_layer.use_localview, object_is_light(*b_ob)); hide = hide || !(ob_layer & scene_layer); if(!hide) { diff --git a/intern/cycles/blender/blender_particles.cpp b/intern/cycles/blender/blender_particles.cpp index 177912cd8f0..f309960fc55 100644 --- a/intern/cycles/blender/blender_particles.cpp +++ b/intern/cycles/blender/blender_particles.cpp @@ -199,8 +199,7 @@ void BlenderSync::sync_particle_systems() for(; b_sce; b_sce = b_sce.background_set()) { for(b_sce.objects.begin(b_ob); b_ob != b_sce.objects.end(); ++b_ob) { bool hide = (render_layer.use_viewport_visibility)? b_ob->hide(): b_ob->hide_render(); - uint ob_layer = get_layer(b_ob->layers(), b_ob->layers_local_view(), object_is_light(*b_ob)); - CYCLES_LOCAL_LAYER_HACK(render_layer.use_localview, ob_layer); + uint ob_layer = get_layer(b_ob->layers(), b_ob->layers_local_view(), render_layer.use_localview, object_is_light(*b_ob)); hide = hide || !(ob_layer & scene_layer); if(!hide) { diff --git a/intern/cycles/blender/blender_session.h b/intern/cycles/blender/blender_session.h index 4666b5982e1..d52e0103bbf 100644 --- a/intern/cycles/blender/blender_session.h +++ b/intern/cycles/blender/blender_session.h @@ -53,8 +53,7 @@ public: void write_render_tile(RenderTile& rtile); /* update functions are used to update display buffer only after sample was rendered - * only needed for better visual feedback - */ + * only needed for better visual feedback */ void update_render_result(BL::RenderResult b_rr, BL::RenderLayer b_rlay, RenderTile& rtile); void update_render_tile(RenderTile& rtile); diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index cb83309cc00..907573cf072 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -231,8 +231,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer) } else { render_layer.use_localview = (b_v3d.local_view() ? true : false); - render_layer.scene_layer = get_layer(b_v3d.layers(), b_v3d.layers_local_view()); - CYCLES_LOCAL_LAYER_HACK(render_layer.use_localview, render_layer.scene_layer); + render_layer.scene_layer = get_layer(b_v3d.layers(), b_v3d.layers_local_view(), render_layer.use_localview); render_layer.layer = render_layer.scene_layer; render_layer.holdout_layer = 0; render_layer.material_override = PointerRNA_NULL; @@ -354,8 +353,6 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine b_engine, BL::Use /* tiles */ if(params.device.type != DEVICE_CPU && !background) { - printf("%d\n", get_int(cscene, "debug_tile_size")); - /* currently GPU could be much slower than CPU when using tiles, * still need to be investigated, but meanwhile make it possible * to work in viewport smoothly diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index ac4cc37b74a..27f6b6ee4ee 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -137,20 +137,6 @@ private: Progress &progress; }; -/* we don't have spare bits for localview (normally 20-28) - * because PATH_RAY_LAYER_SHIFT uses 20-32. - * So - check if we have localview and if so, shift local - * view bits down to 1-8, since this is done for the view - * port only - it should be OK and not conflict with - * render layers. - Campbell. - * - * ... as an alternative we could use uint64_t - */ -#define CYCLES_LOCAL_LAYER_HACK(use_localview, layer) \ - if (use_localview) { \ - layer >>= 20; \ - } (void)0 - CCL_NAMESPACE_END #endif /* __BLENDER_SYNC_H__ */ diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index b0febcc23d4..d0fca9a9fb9 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -170,7 +170,7 @@ static inline uint get_layer(BL::Array<int, 20> array) return layer; } -static inline uint get_layer(BL::Array<int, 20> array, BL::Array<int, 8> local_array, bool is_light = false) +static inline uint get_layer(BL::Array<int, 20> array, BL::Array<int, 8> local_array, bool use_local, bool is_light = false) { uint layer = 0; @@ -188,7 +188,14 @@ static inline uint get_layer(BL::Array<int, 20> array, BL::Array<int, 8> local_a if(local_array[i]) layer |= (1 << (20+i)); } - + + /* we don't have spare bits for localview (normally 20-28) because + * PATH_RAY_LAYER_SHIFT uses 20-32. So - check if we have localview and if + * so, shift local view bits down to 1-8, since this is done for the view + * port only - it should be OK and not conflict with render layers. */ + if(use_local) + layer >>= 20; + return layer; } diff --git a/intern/cycles/kernel/kernel_displace.h b/intern/cycles/kernel/kernel_displace.h index f4b33605f5b..6461a1eea38 100644 --- a/intern/cycles/kernel/kernel_displace.h +++ b/intern/cycles/kernel/kernel_displace.h @@ -63,6 +63,8 @@ __device void kernel_shader_evaluate(KernelGlobals *kg, uint4 *input, float4 *ou out = shader_eval_background(kg, &sd, flag); } + shader_release(kg, &sd); + /* write output */ output[i] = make_float4(out.x, out.y, out.z, 0.0f); } diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 6c81fa4cfca..d606c3d634a 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -209,6 +209,8 @@ __device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ra if(ray->t != FLT_MAX) ray->D = normalize_len(Pend - ray->P, &ray->t); + shader_release(kg, &sd); + bounce++; } } @@ -294,8 +296,10 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample, L_transparent += average(holdout_weight*throughput); } - if(sd.flag & SD_HOLDOUT_MASK) + if(sd.flag & SD_HOLDOUT_MASK) { + shader_release(kg, &sd); break; + } } #endif @@ -313,8 +317,10 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample, float probability = path_state_terminate_probability(kg, &state, throughput); float terminate = path_rng(kg, rng, sample, rng_offset + PRNG_TERMINATE); - if(terminate >= probability) + if(terminate >= probability) { + shader_release(kg, &sd); break; + } throughput /= probability; @@ -380,8 +386,10 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample, #endif /* no BSDF? we can stop here */ - if(!(sd.flag & SD_BSDF)) + if(!(sd.flag & SD_BSDF)) { + shader_release(kg, &sd); break; + } /* sample BSDF */ float bsdf_pdf; @@ -486,8 +494,10 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray float probability = path_state_terminate_probability(kg, &state, throughput); float terminate = path_rng(kg, rng, sample, rng_offset + PRNG_TERMINATE); - if(terminate >= probability) + if(terminate >= probability) { + shader_release(kg, &sd); break; + } throughput /= probability; @@ -554,8 +564,10 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray #endif /* no BSDF? we can stop here */ - if(!(sd.flag & SD_BSDF)) + if(!(sd.flag & SD_BSDF)) { + shader_release(kg, &sd); break; + } /* sample BSDF */ float bsdf_pdf; @@ -661,8 +673,10 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam L_transparent += average(holdout_weight*throughput); } - if(sd.flag & SD_HOLDOUT_MASK) + if(sd.flag & SD_HOLDOUT_MASK) { + shader_release(kg, &sd); break; + } } #endif @@ -682,8 +696,10 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam float probability = path_state_terminate_probability(kg, &state, throughput); float terminate = path_rng(kg, rng, sample, rng_offset + PRNG_TERMINATE); - if(terminate >= probability) + if(terminate >= probability) { + shader_release(kg, &sd); break; + } throughput /= probability; } diff --git a/intern/cycles/kernel/kernel_shader.h b/intern/cycles/kernel/kernel_shader.h index 5ab3c2c2545..b57e27bc8ed 100644 --- a/intern/cycles/kernel/kernel_shader.h +++ b/intern/cycles/kernel/kernel_shader.h @@ -46,6 +46,11 @@ CCL_NAMESPACE_BEGIN __device_inline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray) { +#ifdef __OSL__ + if (kernel_osl_use(kg)) + OSLShader::init(kg, sd); +#endif + /* fetch triangle data */ int prim = kernel_tex_fetch(__prim_index, isect->prim); float4 Ns = kernel_tex_fetch(__tri_normal, prim); @@ -129,6 +134,11 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd, const float3 P, const float3 Ng, const float3 I, int shader, int object, int prim, float u, float v, float t, float time) { +#ifdef __OSL__ + if (kernel_osl_use(kg)) + OSLShader::init(kg, sd); +#endif + /* vectors */ sd->P = P; sd->N = Ng; @@ -233,6 +243,8 @@ __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd, __device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd, int object, int prim, float u, float v) { + /* Note: no OSLShader::init call here, this is done in shader_setup_from_sample! */ + float3 P, Ng, I = make_float3(0.0f, 0.0f, 0.0f); int shader; @@ -251,6 +263,11 @@ __device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd, __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray) { +#ifdef __OSL__ + if (kernel_osl_use(kg)) + OSLShader::init(kg, sd); +#endif + /* vectors */ sd->P = ray->D; sd->N = -sd->P; diff --git a/intern/cycles/kernel/osl/nodes/CMakeLists.txt b/intern/cycles/kernel/osl/nodes/CMakeLists.txt index 2d2b5b10ce6..08e9b9ee726 100644 --- a/intern/cycles/kernel/osl/nodes/CMakeLists.txt +++ b/intern/cycles/kernel/osl/nodes/CMakeLists.txt @@ -5,6 +5,7 @@ set(SRC_OSL node_add_closure.osl node_attribute.osl node_background.osl + node_brick_texture.osl node_bump.osl node_camera.osl node_checker_texture.osl diff --git a/intern/cycles/kernel/osl/nodes/node_brick_texture.osl b/intern/cycles/kernel/osl/nodes/node_brick_texture.osl new file mode 100644 index 00000000000..4daceb4018e --- /dev/null +++ b/intern/cycles/kernel/osl/nodes/node_brick_texture.osl @@ -0,0 +1,94 @@ +/* + * Copyright 2012, Blender Foundation. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "stdosl.h" +#include "node_texture.h" + +/* Brick */ + +float brick_noise(int n) /* fast integer noise */ +{ + int nn; + n = (n >> 13) ^ n; + nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 2147483647; + return 0.5 * ((float)nn / 1073741824.0); +} + +float brick(point p, float mortar_size, float bias, + float BrickWidth, float row_height, float offset_amount, int offset_frequency, + float squash_amount, int squash_frequency, float tint) +{ + int bricknum, rownum; + float offset = 0.0; + float brick_width = BrickWidth; + float x, y; + + rownum = (int)floor(p[1] / row_height); + + if(offset_frequency && squash_frequency) { + brick_width *= ((int)(rownum) % squash_frequency ) ? 1.0 : squash_amount; /* squash */ + offset = ((int)(rownum) % offset_frequency ) ? 0 : (brick_width*offset_amount); /* offset */ + } + + bricknum = (int)floor((p[0]+offset) / brick_width); + + x = (p[0]+offset) - brick_width*bricknum; + y = p[1] - row_height*rownum; + + tint = clamp((brick_noise((rownum << 16) + (bricknum & 65535)) + bias), 0.0, 1.0); + + return (x < mortar_size || y < mortar_size || + x > (brick_width - mortar_size) || + y > (row_height - mortar_size)) ? 1.0 : 0.0; +} + +shader node_brick_texture( + float Offset = 0.5, + int OffsetFrequency = 2, + float Squash = 1.0, + int SquashFrequency = 1, + point Vector = P, + color Color1 = color(0.2, 0.2, 0.2), + color Color2 = color(0.8, 0.8, 0.8), + color Mortar = color(0.0, 0.0, 0.0), + float Scale = 5.0, + float MortarSize = 0.02, + float Bias = 0.0, + float BrickWidth = 0.5, + float RowHeight = 0.25, + output float Fac = 0.0, + output color Color = color(0.2, 0.2, 0.2)) +{ + float tint = 0.0; + color Col = Color1; + + Fac = brick(Vector*Scale, MortarSize, Bias, BrickWidth, RowHeight, + Offset, OffsetFrequency, Squash, SquashFrequency, tint); + + if(Fac != 1.0) { + float facm = 1.0 - tint; + + Col[0] = facm * (Color1[0]) + tint * Color2[0]; + Col[1] = facm * (Color1[1]) + tint * Color2[1]; + Col[2] = facm * (Color1[2]) + tint * Color2[2]; + } + + Color = (Fac == 1.0) ? Mortar: Col; + +} + diff --git a/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl b/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl index e6fa014324c..a8dd65ae23b 100644 --- a/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl +++ b/intern/cycles/kernel/osl/nodes/node_gradient_texture.osl @@ -21,46 +21,40 @@ /* Gradient */ -float gradient(point p, string progression, string axis) +float gradient(point p, string type) { float x, y; - - if(axis == "Vertical") { - x= p[1]; - y= p[0]; - } - else { - x= p[0]; - y= p[1]; - } + + x = p[0]; + y = p[1]; float result = 0.0; - if(progression == "Linear") { + if(type == "Linear") { result = (1.0 + x)/2.0; } - else if(progression == "Quadratic") { + else if(type == "Quadratic") { float r = max((1.0 + x)/2.0, 0.0); result = r*r; } - else if(progression == "Easing") { + else if(type == "Easing") { float r = min(max((1.0 + x)/2.0, 0.0), 1.0); float t = r*r; result = (3.0*t - 2.0*t*r); } - else if(progression == "Diagonal") { + else if(type == "Diagonal") { result = (2.0 + x + y)/4.0; } - else if(progression == "Radial") { + else if(type == "Radial") { result = atan2(y, x)/(2*M_PI) + 0.5; } else { float r = max(1.0 - sqrt(x*x + y*y + p[2]*p[2]), 0.0); - if(progression == "Quadratic Sphere") + if(type == "Quadratic Sphere") result = r*r; - else if(progression == "Spherical") + else if(type == "Spherical") result = r; } @@ -68,11 +62,12 @@ float gradient(point p, string progression, string axis) } shader node_gradient_texture( - string Progression = "Linear", - string Axis = "Horizontal", + string Type = "Linear", point Vector = P, - output float Fac = 0.0) + output float Fac = 0.0, + output color Color = color(0.0, 0.0, 0.0)) { - Fac = gradient(Vector, Progression, Axis); + Fac = gradient(Vector, Type); + Color = color(Fac, Fac, Fac); } diff --git a/intern/cycles/kernel/osl/nodes/node_holdout.osl b/intern/cycles/kernel/osl/nodes/node_holdout.osl index 69f8d85a82e..aede50c7ca0 100644 --- a/intern/cycles/kernel/osl/nodes/node_holdout.osl +++ b/intern/cycles/kernel/osl/nodes/node_holdout.osl @@ -18,11 +18,9 @@ #include "stdosl.h" -shader node_background( - color Color = color(0.8, 0.8, 0.8), - float Strength = 1.0, - output closure color Background = background()) +shader node_holdout( + output closure color Holdout = holdout()) { - Background = Color*Strength*background(); + } diff --git a/intern/cycles/kernel/osl/nodes/node_musgrave_texture.osl b/intern/cycles/kernel/osl/nodes/node_musgrave_texture.osl index 3ab345279f1..3e1a6862660 100644 --- a/intern/cycles/kernel/osl/nodes/node_musgrave_texture.osl +++ b/intern/cycles/kernel/osl/nodes/node_musgrave_texture.osl @@ -186,32 +186,35 @@ float noise_musgrave_ridged_multi_fractal(point p, string basis, float H, float shader node_musgrave_texture( string Type = "fBM", - string Basis = "Perlin", float Dimension = 2.0, float Lacunarity = 1.0, - float Octaves = 2.0, + float Detail = 2.0, float Offset = 0.0, - float Intensity = 1.0, float Gain = 1.0, float Scale = 5.0, point Vector = P, - output float Fac = 0.0) + output float Fac = 0.0, + output color Color = color(0.0, 0.0, 0.0)) { - float dimension = max(Dimension, 0.0); - float octaves = max(Octaves, 0.0); + float dimension = max(Dimension, 1e-5); + float octaves = clamp(Detail, 0.0, 16.0); float lacunarity = max(Lacunarity, 1e-5); + string Basis = "Perlin"; + float intensity = 1.0; point p = Vector*Scale; if(Type == "Multifractal") - Fac = Intensity*noise_musgrave_multi_fractal(p, Basis, dimension, lacunarity, octaves); + Fac = intensity*noise_musgrave_multi_fractal(p, Basis, dimension, lacunarity, octaves); else if(Type == "fBM") - Fac = Intensity*noise_musgrave_fBm(p, Basis, dimension, lacunarity, octaves); + Fac = intensity*noise_musgrave_fBm(p, Basis, dimension, lacunarity, octaves); else if(Type == "Hybrid Multifractal") - Fac = Intensity*noise_musgrave_hybrid_multi_fractal(p, Basis, dimension, lacunarity, octaves, Offset, Gain); + Fac = intensity*noise_musgrave_hybrid_multi_fractal(p, Basis, dimension, lacunarity, octaves, Offset, Gain); else if(Type == "Ridged Multifractal") - Fac = Intensity*noise_musgrave_ridged_multi_fractal(p, Basis, dimension, lacunarity, octaves, Offset, Gain); + Fac = intensity*noise_musgrave_ridged_multi_fractal(p, Basis, dimension, lacunarity, octaves, Offset, Gain); else if(Type == "Hetero Terrain") - Fac = Intensity*noise_musgrave_hetero_terrain(p, Basis, dimension, lacunarity, octaves, Offset); + Fac = intensity*noise_musgrave_hetero_terrain(p, Basis, dimension, lacunarity, octaves, Offset); + + Color = color(Fac, Fac, Fac); } diff --git a/intern/cycles/kernel/osl/nodes/node_noise_texture.osl b/intern/cycles/kernel/osl/nodes/node_noise_texture.osl index 7738902f529..1ddb4d8a08b 100644 --- a/intern/cycles/kernel/osl/nodes/node_noise_texture.osl +++ b/intern/cycles/kernel/osl/nodes/node_noise_texture.osl @@ -21,11 +21,10 @@ /* Noise */ -float noise(point p, string basis, float distortion, float detail) +float noise(point p, string basis, float distortion, float detail, float fac, color Color) { point r; int hard = 0; - float fac = 0.0; if(distortion != 0.0) { r[0] = noise_basis(p + point(13.5), basis) * distortion; @@ -37,23 +36,21 @@ float noise(point p, string basis, float distortion, float detail) fac = noise_turbulence(p, basis, detail, hard); + Color = color(fac, noise_turbulence(point(p[1], p[0], p[2]), basis, detail, hard), + noise_turbulence(point(p[1], p[2], p[0]), basis, detail, hard)); + return fac; - - /* - Color[0] = Fac; - Color[1] = noise_turbulence(point(p[1], p[0], p[2]), basis, detail, hard); - Color[2] = noise_turbulence(point(p[1], p[2], p[0]), basis, detail, hard); - */ } shader node_noise_texture( - string Basis = "Perlin", float Distortion = 0.0, float Scale = 5.0, float Detail = 2.0, point Vector = P, - output float Fac = 0.0) + output float Fac = 0.0, + output color Color = color(0.2, 0.2, 0.2)) { - Fac = noise(Vector*Scale, Basis, Distortion, Detail); + string Basis = "Perlin"; + Fac = noise(Vector*Scale, Basis, Distortion, Detail, Fac, Color); } diff --git a/intern/cycles/kernel/osl/nodes/node_wave_texture.osl b/intern/cycles/kernel/osl/nodes/node_wave_texture.osl index 693f09ae24c..db53faaf94b 100644 --- a/intern/cycles/kernel/osl/nodes/node_wave_texture.osl +++ b/intern/cycles/kernel/osl/nodes/node_wave_texture.osl @@ -48,12 +48,14 @@ float wave(point p, float scale, string type, float detail, float distortion, fl shader node_wave_texture( string Type = "Bands", float Scale = 5.0, - float distortion = 0.0, - float detail = 2.0, - float dscale = 1.0, + float Distortion = 0.0, + float Detail = 2.0, + float DetailScale = 1.0, point Vector = P, - output float Fac = 0.0) + output float Fac = 0.0, + output color Color = color (0.0, 0.0, 0.0)) { - Fac = wave(Vector, Scale, Type, detail, distortion, dscale); + Fac = wave(Vector, Scale, Type, Detail, Distortion, DetailScale); + Color = color(Fac, Fac, Fac); } diff --git a/intern/cycles/kernel/osl/osl_shader.cpp b/intern/cycles/kernel/osl/osl_shader.cpp index 345614c2868..98ede0e4f60 100644 --- a/intern/cycles/kernel/osl/osl_shader.cpp +++ b/intern/cycles/kernel/osl/osl_shader.cpp @@ -204,10 +204,9 @@ void OSLShader::eval_surface(KernelGlobals *kg, ShaderData *sd, float randb, int OSL::ShadingSystem *ss = kg->osl.ss; OSLGlobals::ThreadData *tdata = tls_get(OSLGlobals::ThreadData, kg->osl.thread_data); OSL::ShaderGlobals *globals = &tdata->globals; - OSL::ShadingContext *ctx = ss->get_context(tdata->thread_info); + OSL::ShadingContext *ctx = (OSL::ShadingContext *)sd->osl_ctx; /* setup shader globals from shader data */ - sd->osl_ctx = ctx; shaderdata_to_shaderglobals(kg, sd, path_flag, globals); /* execute shader for this point */ @@ -262,10 +261,9 @@ float3 OSLShader::eval_background(KernelGlobals *kg, ShaderData *sd, int path_fl OSL::ShadingSystem *ss = kg->osl.ss; OSLGlobals::ThreadData *tdata = tls_get(OSLGlobals::ThreadData, kg->osl.thread_data); OSL::ShaderGlobals *globals = &tdata->globals; - OSL::ShadingContext *ctx = ss->get_context(tdata->thread_info); + OSL::ShadingContext *ctx = (OSL::ShadingContext *)sd->osl_ctx; /* setup shader globals from shader data */ - sd->osl_ctx = ctx; shaderdata_to_shaderglobals(kg, sd, path_flag, globals); /* execute shader for this point */ @@ -339,10 +337,9 @@ void OSLShader::eval_volume(KernelGlobals *kg, ShaderData *sd, float randb, int OSL::ShadingSystem *ss = kg->osl.ss; OSLGlobals::ThreadData *tdata = tls_get(OSLGlobals::ThreadData, kg->osl.thread_data); OSL::ShaderGlobals *globals = &tdata->globals; - OSL::ShadingContext *ctx = ss->get_context(tdata->thread_info); + OSL::ShadingContext *ctx = (OSL::ShadingContext *)sd->osl_ctx; /* setup shader globals from shader data */ - sd->osl_ctx = ctx; shaderdata_to_shaderglobals(kg, sd, path_flag, globals); /* execute shader */ @@ -363,10 +360,9 @@ void OSLShader::eval_displacement(KernelGlobals *kg, ShaderData *sd) OSL::ShadingSystem *ss = kg->osl.ss; OSLGlobals::ThreadData *tdata = tls_get(OSLGlobals::ThreadData, kg->osl.thread_data); OSL::ShaderGlobals *globals = &tdata->globals; - OSL::ShadingContext *ctx = ss->get_context(tdata->thread_info); + OSL::ShadingContext *ctx = (OSL::ShadingContext *)sd->osl_ctx; /* setup shader globals from shader data */ - sd->osl_ctx = ctx; shaderdata_to_shaderglobals(kg, sd, 0, globals); /* execute shader */ @@ -379,13 +375,19 @@ void OSLShader::eval_displacement(KernelGlobals *kg, ShaderData *sd) sd->P = TO_FLOAT3(globals->P); } -void OSLShader::release(KernelGlobals *kg, const ShaderData *sd) +void OSLShader::init(KernelGlobals *kg, ShaderData *sd) { OSL::ShadingSystem *ss = kg->osl.ss; OSLGlobals::ThreadData *tdata = tls_get(OSLGlobals::ThreadData, kg->osl.thread_data); - OSL::ShadingContext *ctx = ss->get_context(tdata->thread_info); + + sd->osl_ctx = ss->get_context(tdata->thread_info); +} - ss->release_context(ctx); +void OSLShader::release(KernelGlobals *kg, ShaderData *sd) +{ + OSL::ShadingSystem *ss = kg->osl.ss; + + ss->release_context((OSL::ShadingContext *)sd->osl_ctx); } /* BSDF Closure */ diff --git a/intern/cycles/kernel/osl/osl_shader.h b/intern/cycles/kernel/osl/osl_shader.h index 815557ed203..e55f98d4d02 100644 --- a/intern/cycles/kernel/osl/osl_shader.h +++ b/intern/cycles/kernel/osl/osl_shader.h @@ -79,7 +79,8 @@ public: const float3 omega_in, const float3 omega_out); /* release */ - static void release(KernelGlobals *kg, const ShaderData *sd); + static void init(KernelGlobals *kg, ShaderData *sd); + static void release(KernelGlobals *kg, ShaderData *sd); }; CCL_NAMESPACE_END diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp index 272ddb89b0c..e44caa90f12 100644 --- a/intern/cycles/render/camera.cpp +++ b/intern/cycles/render/camera.cpp @@ -75,7 +75,7 @@ Camera::Camera() need_update = true; need_device_update = true; - previous_motion = -1; + previous_need_motion = -1; } Camera::~Camera() @@ -145,12 +145,10 @@ void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene) update(); - if (previous_motion != need_motion) { - /* scene's motion model could have been changed since - * previous device camera update - * this could happen for example in case when one render - * layer has got motion pass and another not - */ + if (previous_need_motion != need_motion) { + /* scene's motion model could have been changed since previous device + * camera update this could happen for example in case when one render + * layer has got motion pass and another not */ need_device_update = true; } @@ -237,7 +235,7 @@ void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene) kcam->cliplength = (farclip == FLT_MAX)? FLT_MAX: farclip - nearclip; need_device_update = false; - previous_motion = need_motion; + previous_need_motion = need_motion; } void Camera::device_free(Device *device, DeviceScene *dscene) diff --git a/intern/cycles/render/camera.h b/intern/cycles/render/camera.h index a539510029f..82852bde5e0 100644 --- a/intern/cycles/render/camera.h +++ b/intern/cycles/render/camera.h @@ -91,7 +91,7 @@ public: /* update */ bool need_update; bool need_device_update; - int previous_motion; + int previous_need_motion; /* functions */ Camera(); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index da511b2d2f4..1f03ab4e347 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -984,9 +984,9 @@ void BrickTextureNode::compile(SVMCompiler& compiler) void BrickTextureNode::compile(OSLCompiler& compiler) { compiler.parameter("Offset", offset); - compiler.parameter("Offset Frequency", offset_frequency); + compiler.parameter("OffsetFrequency", offset_frequency); compiler.parameter("Squash", squash); - compiler.parameter("Squash Frequency", squash_frequency); + compiler.parameter("SquashFrequency", squash_frequency); compiler.add(this, "node_brick_texture"); } diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp index d4c93c07e2f..dbd6b0ac9d9 100644 --- a/intern/cycles/render/osl.cpp +++ b/intern/cycles/render/osl.cpp @@ -200,19 +200,19 @@ void OSLCompiler::add(ShaderNode *node, const char *name) switch(input->type) { case SHADER_SOCKET_COLOR: - parameter_color(input->name, input->value); + parameter_color(compatible_name(input->name).c_str(), input->value); break; case SHADER_SOCKET_POINT: - parameter_point(input->name, input->value); + parameter_point(compatible_name(input->name).c_str(), input->value); break; case SHADER_SOCKET_VECTOR: - parameter_vector(input->name, input->value); + parameter_vector(compatible_name(input->name).c_str(), input->value); break; case SHADER_SOCKET_NORMAL: - parameter_normal(input->name, input->value); + parameter_normal(compatible_name(input->name).c_str(), input->value); break; case SHADER_SOCKET_FLOAT: - parameter(input->name, input->value.x); + parameter(compatible_name(input->name).c_str(), input->value.x); break; case SHADER_SOCKET_CLOSURE: break; diff --git a/release/scripts/modules/addon_utils.py b/release/scripts/modules/addon_utils.py index 433d9024e0a..485b4829b71 100644 --- a/release/scripts/modules/addon_utils.py +++ b/release/scripts/modules/addon_utils.py @@ -148,7 +148,7 @@ def modules(module_cache): for path in path_list: # force all contrib addons to be 'TESTING' - if path.endswith("addons_contrib") or path.endswith("addons_extern"): + if path.endswith(("addons_contrib", "addons_extern")): force_support = 'TESTING' else: force_support = None diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index ed4d5dd55f5..513277a2099 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -735,7 +735,7 @@ class WM_OT_context_modal_mouse(Operator): if not self._values: self.report({'WARNING'}, "Nothing to operate on: %s[ ].%s" % - (self.data_path_iter, self.data_path_item)) + (self.data_path_iter, self.data_path_item)) return {'CANCELLED'} else: diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index d92325a8b3d..2ab90301bdb 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -449,7 +449,7 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): return strip.type in {'ADD', 'SUBTRACT', 'ALPHA_OVER', 'ALPHA_UNDER', 'CROSS', 'GAMMA_CROSS', 'MULTIPLY', 'OVER_DROP', 'WIPE', 'GLOW', 'TRANSFORM', 'COLOR', 'SPEED', - 'MULTICAM', 'ADJUSTMENT'} + 'MULTICAM'} def draw(self, context): layout = self.layout @@ -463,10 +463,6 @@ class SEQUENCER_PT_effect(SequencerButtonsPanel, Panel): if strip.input_count > 1: col.prop(strip, "input_2") - if strip.is_supports_mask: - col = layout.column() - col.prop_search(strip, "input_mask_strip", sequencer, "sequences", text="Mask") - if strip.type == 'COLOR': layout.prop(strip, "color") @@ -793,10 +789,6 @@ class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel): col.prop(strip, "use_premultiply") col.prop(strip, "use_float") - layout.prop(strip, "use_color_balance") - if strip.use_color_balance and strip.color_balance: # TODO - need to add this somehow - draw_color_balance(layout, strip.color_balance) - class SEQUENCER_PT_proxy(SequencerButtonsPanel, Panel): bl_label = "Proxy / Timecode" diff --git a/release/scripts/templates/operator_modal.py b/release/scripts/templates/operator_modal.py index d8115bc95bf..88e5ee80590 100644 --- a/release/scripts/templates/operator_modal.py +++ b/release/scripts/templates/operator_modal.py @@ -26,9 +26,10 @@ class ModalOperator(bpy.types.Operator): def invoke(self, context, event): if context.object: - context.window_manager.modal_handler_add(self) self.first_mouse_x = event.mouse_x self.first_value = context.object.location.x + + context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} else: self.report({'WARNING'}, "No active object, could not finish") diff --git a/release/scripts/templates/operator_modal_draw.py b/release/scripts/templates/operator_modal_draw.py index f2d5ad8982b..f1c4e113b0a 100644 --- a/release/scripts/templates/operator_modal_draw.py +++ b/release/scripts/templates/operator_modal_draw.py @@ -53,14 +53,13 @@ class ModalDrawOperator(bpy.types.Operator): def invoke(self, context, event): if context.area.type == 'VIEW_3D': - context.window_manager.modal_handler_add(self) - # Add the region OpenGL drawing callback # draw in view space with 'POST_VIEW' and 'PRE_VIEW' self._handle = context.region.callback_add(draw_callback_px, (self, context), 'POST_PIXEL') self.mouse_path = [] + context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} else: self.report({'WARNING'}, "View3D not found, cannot run operator") diff --git a/release/scripts/templates/operator_modal_timer.py b/release/scripts/templates/operator_modal_timer.py index 6d2ec95aedb..72c153df9d2 100644 --- a/release/scripts/templates/operator_modal_timer.py +++ b/release/scripts/templates/operator_modal_timer.py @@ -21,8 +21,8 @@ class ModalTimerOperator(bpy.types.Operator): return {'PASS_THROUGH'} def execute(self, context): - context.window_manager.modal_handler_add(self) self._timer = context.window_manager.event_timer_add(0.1, context.window) + context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} def cancel(self, context): diff --git a/release/scripts/templates/operator_modal_view3d.py b/release/scripts/templates/operator_modal_view3d.py index 0babf169610..c870bbffdcf 100644 --- a/release/scripts/templates/operator_modal_view3d.py +++ b/release/scripts/templates/operator_modal_view3d.py @@ -45,14 +45,13 @@ class ViewOperator(bpy.types.Operator): v3d = context.space_data rv3d = v3d.region_3d - context.window_manager.modal_handler_add(self) - if rv3d.view_perspective == 'CAMERA': rv3d.view_perspective = 'PERSP' self._initial_mouse = Vector((event.mouse_x, event.mouse_y, 0.0)) self._initial_location = rv3d.view_location.copy() + context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} else: self.report({'WARNING'}, "Active space must be a View3d") diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index 44e47e779e7..d750e88ac04 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -101,8 +101,6 @@ void get_objectspace_bone_matrix(struct Bone *bone, float M_accumulatedMatrix[][ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]); void mat3_to_vec_roll(float mat[][3], float *vec, float *roll); -int get_selected_defgroups(struct Object *ob, char *defbase_sel, int defbase_len); - /* Common Conversions Between Co-ordinate Spaces */ void BKE_armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outmat[][4]); void BKE_armature_loc_world_to_pose(struct Object *ob, const float inloc[3], float outloc[3]); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index dec4d3cb8cb..0e7bdbbb4dd 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 263 -#define BLENDER_SUBVERSION 17 +#define BLENDER_SUBVERSION 18 /* 262 was the last editmesh release but its has compatibility code for bmesh data, * so set the minversion to 2.61 */ diff --git a/source/blender/blenkernel/BKE_deform.h b/source/blender/blenkernel/BKE_deform.h index 25677165fc2..52a143ddf55 100644 --- a/source/blender/blenkernel/BKE_deform.h +++ b/source/blender/blenkernel/BKE_deform.h @@ -67,7 +67,8 @@ void defvert_remap(struct MDeformVert *dvert, int *map, const int map_len); void defvert_flip(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len); void defvert_flip_merged(struct MDeformVert *dvert, const int *flip_map, const int flip_map_len); void defvert_normalize(struct MDeformVert *dvert); -void defvert_normalize_lock(struct MDeformVert *dvert, const int def_nr_lock); +void defvert_normalize_lock_single(struct MDeformVert *dvert, const int def_nr_lock); +void defvert_normalize_lock_map(struct MDeformVert *dvert, const char *lock_flags, const int defbase_tot); /* utility function, note that MAX_VGROUP_NAME chars is the maximum string length since its only * used with defgroups currently */ diff --git a/source/blender/blenkernel/BKE_object_deform.h b/source/blender/blenkernel/BKE_object_deform.h new file mode 100644 index 00000000000..35a4e19a5bc --- /dev/null +++ b/source/blender/blenkernel/BKE_object_deform.h @@ -0,0 +1,38 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BKE_OBJECT_DEFORM_H__ +#define __BKE_OBJECT_DEFORM_H__ + +/** \file BKE_object_vgroup.h + * \ingroup bke + * \brief Functions for dealing with objects and deform verts, + * used by painting and tools. + */ + +struct Object; + +char *BKE_objdef_lock_flags_get(struct Object *ob, const int defbase_tot); +char *BKE_objdef_validmap_get(struct Object *ob, const int defbase_tot); +char *BKE_objdef_selected_get(struct Object *ob, int defbase_tot, int *r_dg_flags_sel_tot); + +#endif /* __BKE_OBJECT_DEFORM_H__ */ diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 0468d3fad9c..5bef0b2a771 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -380,7 +380,7 @@ typedef struct SequenceModifierTypeInfo { void (*copy_data) (struct SequenceModifierData *smd, struct SequenceModifierData *target); /* apply modifier on a given image buffer */ - struct ImBuf *(*apply) (struct SequenceModifierData *smd, struct ImBuf *ibuf, struct ImBuf *mask); + void (*apply) (struct SequenceModifierData *smd, struct ImBuf *ibuf, struct ImBuf *mask); } SequenceModifierTypeInfo; struct SequenceModifierTypeInfo *BKE_sequence_modifier_type_info_get(int type); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index afa3998fb49..576b79f899c 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -115,6 +115,7 @@ set(SRC intern/nla.c intern/node.c intern/object.c + intern/object_deform.c intern/ocean.c intern/packedFile.c intern/paint.c @@ -203,6 +204,7 @@ set(SRC BKE_nla.h BKE_node.h BKE_object.h + BKE_object_deform.h BKE_ocean.h BKE_packedFile.h BKE_paint.h diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 1aa54307841..a7f8e1bb161 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -59,6 +59,7 @@ #include "BKE_modifier.h" #include "BKE_mesh.h" #include "BKE_object.h" +#include "BKE_object_deform.h" #include "BKE_paint.h" #include "BKE_texture.h" #include "BKE_multires.h" @@ -1015,14 +1016,14 @@ static void calc_weightpaint_vert_color( unsigned char r_col[4], MDeformVert *dv, ColorBand *coba, const int defbase_tot, const int defbase_act, - const char *dg_flags, - const int selected, const int draw_flag) + const char *defbase_sel, const int defbase_sel_tot, + const int draw_flag) { float input = 0.0f; int make_black = FALSE; - if ((selected > 1) && (draw_flag & CALC_WP_MULTIPAINT)) { + if ((defbase_sel_tot > 1) && (draw_flag & CALC_WP_MULTIPAINT)) { int was_a_nonzero = FALSE; unsigned int i; @@ -1031,7 +1032,7 @@ static void calc_weightpaint_vert_color( /* in multipaint, get the average if auto normalize is inactive * get the sum if it is active */ if (dw->def_nr < defbase_tot) { - if (dg_flags[dw->def_nr]) { + if (defbase_sel[dw->def_nr]) { if (dw->weight) { input += dw->weight; was_a_nonzero = TRUE; @@ -1045,7 +1046,7 @@ static void calc_weightpaint_vert_color( make_black = TRUE; } else if ((draw_flag & CALC_WP_AUTO_NORMALIZE) == FALSE) { - input /= selected; /* get the average */ + input /= defbase_sel_tot; /* get the average */ } } else { @@ -1090,14 +1091,21 @@ static unsigned char *calc_weightpaint_vert_array(Object *ob, DerivedMesh *dm, i /* variables for multipaint */ const int defbase_tot = BLI_countlist(&ob->defbase); const int defbase_act = ob->actdef - 1; - char *dg_flags = MEM_mallocN(defbase_tot * sizeof(char), __func__); - const int selected = get_selected_defgroups(ob, dg_flags, defbase_tot); + + int defbase_sel_tot = 0; + char *defbase_sel = NULL; + + if (draw_flag & CALC_WP_MULTIPAINT) { + defbase_sel = BKE_objdef_selected_get(ob, defbase_tot, &defbase_sel_tot); + } for (i = numVerts; i != 0; i--, wc += 4, dv++) { - calc_weightpaint_vert_color(wc, dv, coba, defbase_tot, defbase_act, dg_flags, selected, draw_flag); + calc_weightpaint_vert_color(wc, dv, coba, defbase_tot, defbase_act, defbase_sel, defbase_sel_tot, draw_flag); } - MEM_freeN(dg_flags); + if (defbase_sel) { + MEM_freeN(defbase_sel); + } } else { int col_i; diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index aa834ff131b..b87342f85fa 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2517,36 +2517,6 @@ void BKE_pose_where_is(Scene *scene, Object *ob) } } - -/* Returns total selected vgroups, - * wpi.defbase_sel is assumed malloc'd, all values are set */ -int get_selected_defgroups(Object *ob, char *dg_selection, int defbase_tot) -{ - bDeformGroup *defgroup; - unsigned int i; - Object *armob = BKE_object_pose_armature_get(ob); - int dg_flags_sel_tot = 0; - - if (armob) { - bPose *pose = armob->pose; - for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { - bPoseChannel *pchan = BKE_pose_channel_find_name(pose, defgroup->name); - if (pchan && (pchan->bone->flag & BONE_SELECTED)) { - dg_selection[i] = TRUE; - dg_flags_sel_tot++; - } - else { - dg_selection[i] = FALSE; - } - } - } - else { - memset(dg_selection, FALSE, sizeof(char) * defbase_tot); - } - - return dg_flags_sel_tot; -} - /************** Bounding box ********************/ static int minmax_armature(Object *ob, float r_min[3], float r_max[3]) { diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 547a64a70d4..4110d4565b2 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -33,6 +33,7 @@ #include <string.h> #include <math.h> #include <ctype.h> +#include <stdlib.h> #include "MEM_guardedalloc.h" @@ -41,7 +42,10 @@ #include "BKE_deform.h" -#include "BLI_blenlib.h" +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_path_util.h" +#include "BLI_string.h" #include "BLI_utildefines.h" @@ -204,13 +208,15 @@ void defvert_normalize(MDeformVert *dvert) } } -void defvert_normalize_lock(MDeformVert *dvert, const int def_nr_lock) +void defvert_normalize_lock_single(MDeformVert *dvert, const int def_nr_lock) { if (dvert->totweight <= 0) { /* nothing */ } else if (dvert->totweight == 1) { - dvert->dw[0].weight = 1.0f; + if (def_nr_lock != 0) { + dvert->dw[0].weight = 1.0f; + } } else { MDeformWeight *dw_lock = NULL; @@ -246,6 +252,50 @@ void defvert_normalize_lock(MDeformVert *dvert, const int def_nr_lock) } } +void defvert_normalize_lock_map(MDeformVert *dvert, const char *lock_flags, const int defbase_tot) +{ + if (dvert->totweight <= 0) { + /* nothing */ + } + else if (dvert->totweight == 1) { + if (LIKELY(defbase_tot >= 1) && lock_flags[0]) { + dvert->dw[0].weight = 1.0f; + } + } + else { + MDeformWeight *dw; + unsigned int i; + float tot_weight = 0.0f; + float lock_iweight = 0.0f; + + for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) { + if ((dw->def_nr < defbase_tot) && (lock_flags[dw->def_nr] == FALSE)) { + tot_weight += dw->weight; + } + else { + /* invert after */ + lock_iweight += dw->weight; + } + } + + lock_iweight = maxf(0.0f, 1.0f - lock_iweight); + + if (tot_weight > 0.0f) { + /* paranoid, should be 1.0 but in case of float error clamp anyway */ + + float scalar = (1.0f / tot_weight) * lock_iweight; + for (i = dvert->totweight, dw = dvert->dw; i != 0; i--, dw++) { + if ((dw->def_nr < defbase_tot) && (lock_flags[dw->def_nr] == FALSE)) { + dw->weight *= scalar; + + /* in case of division errors with very low weights */ + CLAMP(dw->weight, 0.0f, 1.0f); + } + } + } + } +} + void defvert_flip(MDeformVert *dvert, const int *flip_map, const int flip_map_len) { MDeformWeight *dw; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 987963273bb..a0839a502b7 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2548,7 +2548,9 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ dither = iuser->scene->r.dither_intensity; /* combined layer gets added as first layer */ - if (rres.have_combined && layer == 0) ; + if (rres.have_combined && layer == 0) { + /* pass */ + } else if (rres.layers.first) { RenderLayer *rl = BLI_findlink(&rres.layers, layer - (rres.have_combined ? 1 : 0)); if (rl) { diff --git a/source/blender/blenkernel/intern/object_deform.c b/source/blender/blenkernel/intern/object_deform.c new file mode 100644 index 00000000000..7f9578250f2 --- /dev/null +++ b/source/blender/blenkernel/intern/object_deform.c @@ -0,0 +1,156 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/object_deform.c + * \ingroup bke + */ + +#include <stdlib.h> +#include <string.h> + +#include "MEM_guardedalloc.h" + +#include "BLI_utildefines.h" +#include "BLI_ghash.h" + +#include "BKE_action.h" +#include "BKE_object_deform.h" /* own include */ +#include "BKE_object.h" +#include "BKE_modifier.h" + +#include "DNA_armature_types.h" +#include "DNA_modifier_types.h" +#include "DNA_object_types.h" + +/* --- functions for getting vgroup aligned maps --- */ + +/** + * gets the status of "flag" for each bDeformGroup + * in ob->defbase and returns an array containing them + */ +char *BKE_objdef_lock_flags_get(Object *ob, const int defbase_tot) +{ + char is_locked = FALSE; + int i; + //int defbase_tot = BLI_countlist(&ob->defbase); + char *lock_flags = MEM_mallocN(defbase_tot * sizeof(char), "defflags"); + bDeformGroup *defgroup; + + for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { + lock_flags[i] = ((defgroup->flag & DG_LOCK_WEIGHT) != 0); + is_locked |= lock_flags[i]; + } + if (is_locked) { + return lock_flags; + } + + MEM_freeN(lock_flags); + return NULL; +} + +char *BKE_objdef_validmap_get(Object *ob, const int defbase_tot) +{ + bDeformGroup *dg; + ModifierData *md; + char *vgroup_validmap; + GHash *gh; + int i, step1 = 1; + //int defbase_tot = BLI_countlist(&ob->defbase); + + if (ob->defbase.first == NULL) { + return NULL; + } + + gh = BLI_ghash_str_new("BKE_objdef_validmap_get gh"); + + /* add all names to a hash table */ + for (dg = ob->defbase.first; dg; dg = dg->next) { + BLI_ghash_insert(gh, dg->name, NULL); + } + + BLI_assert(BLI_ghash_size(gh) == defbase_tot); + + /* now loop through the armature modifiers and identify deform bones */ + for (md = ob->modifiers.first; md; md = !md->next && step1 ? (step1 = 0), modifiers_getVirtualModifierList(ob) : md->next) { + if (!(md->mode & (eModifierMode_Realtime | eModifierMode_Virtual))) + continue; + + if (md->type == eModifierType_Armature) { + ArmatureModifierData *amd = (ArmatureModifierData *) md; + + if (amd->object && amd->object->pose) { + bPose *pose = amd->object->pose; + bPoseChannel *chan; + + for (chan = pose->chanbase.first; chan; chan = chan->next) { + if (chan->bone->flag & BONE_NO_DEFORM) + continue; + + if (BLI_ghash_remove(gh, chan->name, NULL, NULL)) { + BLI_ghash_insert(gh, chan->name, SET_INT_IN_POINTER(1)); + } + } + } + } + } + + vgroup_validmap = MEM_mallocN(defbase_tot, "wpaint valid map"); + + /* add all names to a hash table */ + for (dg = ob->defbase.first, i = 0; dg; dg = dg->next, i++) { + vgroup_validmap[i] = (BLI_ghash_lookup(gh, dg->name) != NULL); + } + + BLI_assert(i == BLI_ghash_size(gh)); + + BLI_ghash_free(gh, NULL, NULL); + + return vgroup_validmap; +} + +/* Returns total selected vgroups, + * wpi.defbase_sel is assumed malloc'd, all values are set */ +char *BKE_objdef_selected_get(Object *ob, int defbase_tot, int *r_dg_flags_sel_tot) +{ + char *dg_selection = MEM_mallocN(defbase_tot * sizeof(char), __func__); + bDeformGroup *defgroup; + unsigned int i; + Object *armob = BKE_object_pose_armature_get(ob); + (*r_dg_flags_sel_tot) = 0; + + if (armob) { + bPose *pose = armob->pose; + for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, defgroup->name); + if (pchan && (pchan->bone->flag & BONE_SELECTED)) { + dg_selection[i] = TRUE; + (*r_dg_flags_sel_tot) += 1; + } + else { + dg_selection[i] = FALSE; + } + } + } + else { + memset(dg_selection, FALSE, sizeof(char) * defbase_tot); + } + + return dg_selection; +} diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c index 0a195210e38..6028b40756d 100644 --- a/source/blender/blenkernel/intern/seqmodifier.c +++ b/source/blender/blenkernel/intern/seqmodifier.c @@ -154,14 +154,11 @@ void colorBalance_init_data(SequenceModifierData *smd) } } -ImBuf *colorBalance_apply(SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +void colorBalance_apply(SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) { ColorBalanceModifierData *cbmd = (ColorBalanceModifierData *) smd; - ImBuf *ibuf_new = IMB_dupImBuf(ibuf); - BKE_sequencer_color_balance_apply(&cbmd->color_balance, ibuf_new, cbmd->color_multiply, FALSE, mask); - - return ibuf_new; + BKE_sequencer_color_balance_apply(&cbmd->color_balance, ibuf, cbmd->color_multiply, FALSE, mask); } static SequenceModifierTypeInfo seqModifier_ColorBalance = { @@ -252,10 +249,9 @@ void curves_apply_threaded(int width, int height, unsigned char *rect, float *re } } -ImBuf *curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +void curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) { CurvesModifierData *cmd = (CurvesModifierData *) smd; - ImBuf *ibuf_new = IMB_dupImBuf(ibuf); float black[3] = {0.0f, 0.0f, 0.0f}; float white[3] = {1.0f, 1.0f, 1.0f}; @@ -265,11 +261,9 @@ ImBuf *curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) curvemapping_premultiply(&cmd->curve_mapping, 0); curvemapping_set_black_white(&cmd->curve_mapping, black, white); - modifier_apply_threaded(ibuf_new, mask, curves_apply_threaded, &cmd->curve_mapping); + modifier_apply_threaded(ibuf, mask, curves_apply_threaded, &cmd->curve_mapping); curvemapping_premultiply(&cmd->curve_mapping, 1); - - return ibuf_new; } static SequenceModifierTypeInfo seqModifier_Curves = { @@ -371,16 +365,13 @@ void hue_correct_apply_threaded(int width, int height, unsigned char *rect, floa } } -ImBuf *hue_correct_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +void hue_correct_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) { HueCorrectModifierData *hcmd = (HueCorrectModifierData *) smd; - ImBuf *ibuf_new = IMB_dupImBuf(ibuf); curvemapping_initialize(&hcmd->curve_mapping); - modifier_apply_threaded(ibuf_new, mask, hue_correct_apply_threaded, &hcmd->curve_mapping); - - return ibuf_new; + modifier_apply_threaded(ibuf, mask, hue_correct_apply_threaded, &hcmd->curve_mapping); } static SequenceModifierTypeInfo seqModifier_HueCorrect = { @@ -469,18 +460,15 @@ void brightcontrast_apply_threaded(int width, int height, unsigned char *rect, f } } -ImBuf *brightcontrast_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) +void brightcontrast_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *mask) { BrightContrastModifierData *bcmd = (BrightContrastModifierData *) smd; BrightContrastThreadData data; - ImBuf *ibuf_new = IMB_dupImBuf(ibuf); data.bright = bcmd->bright; data.contrast = bcmd->contrast; - modifier_apply_threaded(ibuf_new, mask, brightcontrast_apply_threaded, &data); - - return ibuf_new; + modifier_apply_threaded(ibuf, mask, brightcontrast_apply_threaded, &data); } static SequenceModifierTypeInfo seqModifier_BrightContrast = { @@ -595,7 +583,6 @@ ImBuf *BKE_sequence_modifier_apply_stack(SeqRenderData context, Sequence *seq, I for (smd = seq->modifiers.first; smd; smd = smd->next) { SequenceModifierTypeInfo *smti = BKE_sequence_modifier_type_info_get(smd->type); - ImBuf *ibuf_new; /* could happen if modifier is being removed or not exists in current version of blender */ if (!smti) @@ -611,12 +598,7 @@ ImBuf *BKE_sequence_modifier_apply_stack(SeqRenderData context, Sequence *seq, I if (processed_ibuf == ibuf) processed_ibuf = IMB_dupImBuf(ibuf); - ibuf_new = smti->apply(smd, processed_ibuf, mask); - - if (ibuf_new != processed_ibuf) { - IMB_freeImBuf(processed_ibuf); - processed_ibuf = ibuf_new; - } + smti->apply(smd, processed_ibuf, mask); if (mask) IMB_freeImBuf(mask); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 9aaa9fd79e8..0ac0db50fb5 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -166,9 +166,6 @@ static void seq_free_strip(Strip *strip) if (strip->transform) { MEM_freeN(strip->transform); } - if (strip->color_balance) { - MEM_freeN(strip->color_balance); - } MEM_freeN(strip); } @@ -1671,26 +1668,6 @@ void BKE_sequencer_color_balance_apply(StripColorBalance *cb, ImBuf *ibuf, float imb_freerectImBuf(ibuf); } -static void sequence_color_balance(SeqRenderData context, Sequence *seq, ImBuf *ibuf, float mul, int cfra) -{ - StripColorBalance *cb = seq->strip->color_balance; - ImBuf *mask_input = NULL; - short make_float = seq->flag & SEQ_MAKE_FLOAT; - - if (seq->mask_sequence) { - if (seq->mask_sequence != seq && !BKE_sequence_check_depend(seq, seq->mask_sequence)) { - int make_float = ibuf->rect_float != NULL; - - mask_input = BKE_sequencer_render_mask_input(context, SEQUENCE_MASK_INPUT_STRIP, seq->mask_sequence, NULL, cfra, make_float); - } - } - - BKE_sequencer_color_balance_apply(cb, ibuf, mul, make_float, mask_input); - - if (mask_input) - IMB_freeImBuf(mask_input); -} - /* * input preprocessing for SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE, SEQ_TYPE_MOVIECLIP and SEQ_TYPE_SCENE * @@ -1713,9 +1690,7 @@ int BKE_sequencer_input_have_to_preprocess(SeqRenderData UNUSED(context), Sequen { float mul; - if (seq->flag & (SEQ_FILTERY | SEQ_USE_CROP | SEQ_USE_TRANSFORM | SEQ_FLIPX | - SEQ_FLIPY | SEQ_USE_COLOR_BALANCE | SEQ_MAKE_PREMUL | SEQ_MAKE_FLOAT)) - { + if (seq->flag & (SEQ_FILTERY | SEQ_USE_CROP | SEQ_USE_TRANSFORM | SEQ_FLIPX | SEQ_FLIPY | SEQ_MAKE_PREMUL | SEQ_MAKE_FLOAT)) { return TRUE; } @@ -1834,11 +1809,6 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra, mul *= seq->blend_opacity / 100.0f; } - if (seq->flag & SEQ_USE_COLOR_BALANCE && seq->strip->color_balance) { - sequence_color_balance(context, seq, ibuf, mul, cfra); - mul = 1.0; - } - if (seq->flag & SEQ_MAKE_FLOAT) { if (!ibuf->rect_float) { IMB_colormanagement_imbuf_to_sequencer_space(ibuf, TRUE); @@ -4020,10 +3990,6 @@ static Sequence *seq_dupli(Scene *scene, Scene *scene_to, Sequence *seq, int dup seqn->strip->proxy->anim = NULL; } - if (seq->strip->color_balance) { - seqn->strip->color_balance = MEM_dupallocN(seq->strip->color_balance); - } - if (seqn->modifiers.first) { seqn->modifiers.first = seqn->modifiers.last = NULL; diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index fd755943e70..2836174be73 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -147,6 +147,7 @@ set(SRC BLI_utildefines.h BLI_uvproject.h BLI_vfontdata.h + BLI_voronoi.h BLI_voxel.h BLI_winstuff.h PIL_time.h diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 1021d2a794d..04c9d96ea0f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -4959,7 +4959,6 @@ static void direct_link_scene(FileData *fd, Scene *sce) seq->seq1= newdataadr(fd, seq->seq1); seq->seq2= newdataadr(fd, seq->seq2); seq->seq3= newdataadr(fd, seq->seq3); - seq->mask_sequence= newdataadr(fd, seq->mask_sequence); /* a patch: after introduction of effects with 3 input strips */ if (seq->seq3 == NULL) seq->seq3 = seq->seq2; @@ -5005,16 +5004,9 @@ static void direct_link_scene(FileData *fd, Scene *sce) else { seq->strip->proxy = NULL; } - if (seq->flag & SEQ_USE_COLOR_BALANCE) { - seq->strip->color_balance = newdataadr( - fd, seq->strip->color_balance); - } - else { - seq->strip->color_balance = NULL; - } - if (seq->strip->color_balance) { - // seq->strip->color_balance->gui = 0; // XXX - peter, is this relevant in 2.5? - } + + /* need to load color balance to it could be converted to modifier */ + seq->strip->color_balance = newdataadr(fd, seq->strip->color_balance); } direct_link_sequence_modifiers(fd, &seq->modifiers); @@ -7888,6 +7880,42 @@ static void do_versions(FileData *fd, Library *lib, Main *main) ntreetype->foreach_nodetree(main, NULL, do_version_ntree_mask_264); } + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 18)) { + Scene *scene; + + for (scene = main->scene.first; scene; scene = scene->id.next) { + if (scene->ed) { + Sequence *seq; + + SEQ_BEGIN (scene->ed, seq) + { + Strip *strip = seq->strip; + + if (strip && strip->color_balance) { + SequenceModifierData *smd; + ColorBalanceModifierData *cbmd; + + smd = BKE_sequence_modifier_new(seq, NULL, seqModifierType_ColorBalance); + cbmd = (ColorBalanceModifierData *) smd; + + cbmd->color_balance = *strip->color_balance; + + /* multiplication with color balance used is handled differently, + * so we need to move multiplication to modifier so files would be + * compatible + */ + cbmd->color_multiply = seq->mul; + seq->mul = 1.0f; + + MEM_freeN(strip->color_balance); + strip->color_balance = NULL; + } + } + SEQ_END + } + } + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ @@ -9443,9 +9471,9 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) cleanup_path(G.main->name, mainptr->curlib->filepath); fd = blo_openblenderfile(mainptr->curlib->filepath, basefd->reports); - fd->mainlist = mainlist; - + if (fd) { + fd->mainlist = mainlist; printf("found: '%s', party on macuno!\n", mainptr->curlib->filepath); } } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index f8b3a548345..109a844352f 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2214,9 +2214,6 @@ static void write_scenes(WriteData *wd, ListBase *scebase) if (seq->flag & SEQ_USE_PROXY && strip->proxy) { writestruct(wd, DATA, "StripProxy", 1, strip->proxy); } - if (seq->flag & SEQ_USE_COLOR_BALANCE && strip->color_balance) { - writestruct(wd, DATA, "StripColorBalance", 1, strip->color_balance); - } if (seq->type==SEQ_TYPE_IMAGE) writestruct(wd, DATA, "StripElem", MEM_allocN_len(strip->stripdata) / sizeof(struct StripElem), strip->stripdata); else if (seq->type==SEQ_TYPE_MOVIE || seq->type==SEQ_TYPE_SOUND_RAM || seq->type == SEQ_TYPE_SOUND_HD) diff --git a/source/blender/compositor/COM_compositor.h b/source/blender/compositor/COM_compositor.h index d9cfae8edb9..e6efd77f8b2 100644 --- a/source/blender/compositor/COM_compositor.h +++ b/source/blender/compositor/COM_compositor.h @@ -301,10 +301,17 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering); /** * @brief Deinitialize the compositor caches and allocated memory. + * Use COM_clearCaches to only free the caches. */ void COM_deinitialize(void); /** + * @brief Clear all compositor caches. (Compositor system will still remain available). + * To deinitialize the compositor use the COM_deinitialize method. + */ +void COM_clearCaches(void); + +/** * @brief Return a list of highlighted bnodes pointers. * @return */ diff --git a/source/blender/compositor/intern/COM_Device.h b/source/blender/compositor/intern/COM_Device.h index e33a2a4288f..dc39b2baca7 100644 --- a/source/blender/compositor/intern/COM_Device.h +++ b/source/blender/compositor/intern/COM_Device.h @@ -31,8 +31,15 @@ * work are packaged as a WorkPackage instance. */ class Device { + public: /** + * @brief Declaration of the virtual destructor + * @note resolve warning gcc 4.7 + */ + virtual ~Device() {} + + /** * @brief initialize the device */ virtual bool initialize() { return true; } diff --git a/source/blender/compositor/intern/COM_Node.cpp b/source/blender/compositor/intern/COM_Node.cpp index 320baacb669..50393d14f35 100644 --- a/source/blender/compositor/intern/COM_Node.cpp +++ b/source/blender/compositor/intern/COM_Node.cpp @@ -137,6 +137,21 @@ void Node::addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocke graph->addOperation(operation); } +/* when a node has no valid data (missing image or group pointer) */ +void Node::convertToOperations_invalid(ExecutionSystem *graph, CompositorContext *context) +{ + /* this is a really bad situation - bring on the pink! - so artists know this is bad */ + const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f}; + int index; + vector<OutputSocket *> &outputsockets = this->getOutputSockets(); + for (index = 0; index < outputsockets.size(); index++) { + SetColorOperation *operation = new SetColorOperation(); + this->getOutputSocket(index)->relinkConnections(operation->getOutputSocket()); + operation->setChannels(warning_color); + graph->addOperation(operation); + } +} + bNodeSocket *Node::getEditorInputSocket(int editorNodeInputSocketIndex) { bNodeSocket *bSock = (bNodeSocket *)this->getbNode()->inputs.first; diff --git a/source/blender/compositor/intern/COM_Node.h b/source/blender/compositor/intern/COM_Node.h index e19b1d774c9..7ce40e3cb34 100644 --- a/source/blender/compositor/intern/COM_Node.h +++ b/source/blender/compositor/intern/COM_Node.h @@ -100,6 +100,13 @@ public: void addSetVectorOperation(ExecutionSystem *graph, InputSocket *inputsocket, int editorNodeInputSocketIndex); /** + * when a node has no valid data (missing image or a group nodes ID pointer is NULL) + * call this function from #convertToOperations, this way the node sockets are converted + * into valid outputs, without this the compositor system gets confused and crashes, see [#32490] + */ + void convertToOperations_invalid(ExecutionSystem *graph, CompositorContext *context); + + /** * Creates a new link between an outputSocket and inputSocket and registrates the link to the graph * @return the new created link */ diff --git a/source/blender/compositor/intern/COM_NodeBase.h b/source/blender/compositor/intern/COM_NodeBase.h index 3c390f6bcdb..b55e444be80 100644 --- a/source/blender/compositor/intern/COM_NodeBase.h +++ b/source/blender/compositor/intern/COM_NodeBase.h @@ -71,13 +71,14 @@ protected: inline vector<OutputSocket *>& getOutputSockets() { return this->m_outputsockets; } -public: +protected: /** * @brief destructor * clean up memory related to this NodeBase. */ virtual ~NodeBase(); +public: /** * @brief get the reference to the SDNA bNode struct */ diff --git a/source/blender/compositor/intern/COM_Socket.h b/source/blender/compositor/intern/COM_Socket.h index 2aebe262594..bad112d20c7 100644 --- a/source/blender/compositor/intern/COM_Socket.h +++ b/source/blender/compositor/intern/COM_Socket.h @@ -62,6 +62,14 @@ private: DataType m_datatype; bNodeSocket *m_editorSocket; + +protected: + /** + * @brief Declaration of the virtual destructor + * @note resolve warning gcc 4.7 + */ + virtual ~Socket() {} + public: Socket(DataType datatype); diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index f9af23faea8..78e198ac9c2 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -103,7 +103,13 @@ void **g_highlightedNodesRead; void COM_startReadHighlights() { - if (g_highlightedNodesRead) { + if (!g_highlightInitialized) + { + return; + } + + if (g_highlightedNodesRead) + { MEM_freeN(g_highlightedNodesRead); } @@ -114,11 +120,15 @@ void COM_startReadHighlights() int COM_isHighlightedbNode(bNode *bnode) { + if (!g_highlightInitialized) { + return false; + } + if (!g_highlightedNodesRead) { return false; } - for (int i = 0 ; i < MAX_HIGHLIGHT; i++) { + for (int i = 0; i < MAX_HIGHLIGHT; i++) { void *p = g_highlightedNodesRead[i]; if (!p) return false; if (p == bnode) return true; @@ -397,13 +407,16 @@ void WorkScheduler::deinitialize() /* deinitialize highlighting */ if (g_highlightInitialized) { - if (g_highlightedNodes) + g_highlightInitialized = false; + if (g_highlightedNodes) { MEM_freeN(g_highlightedNodes); + g_highlightedNodes = NULL; + } - if (g_highlightedNodesRead) + if (g_highlightedNodesRead) { MEM_freeN(g_highlightedNodesRead); - - g_highlightInitialized = false; + g_highlightedNodesRead = NULL; + } } } diff --git a/source/blender/compositor/intern/COM_compositor.cpp b/source/blender/compositor/intern/COM_compositor.cpp index daf48d65caf..cb9166c929d 100644 --- a/source/blender/compositor/intern/COM_compositor.cpp +++ b/source/blender/compositor/intern/COM_compositor.cpp @@ -37,6 +37,11 @@ extern "C" { static ThreadMutex s_compositorMutex; static char is_compositorMutex_init = FALSE; +void intern_freeCompositorCaches() +{ + deintializeDistortionCache(); +} + void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) { /* initialize mutex, TODO this mutex init is actually not thread safe and @@ -63,7 +68,7 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) /* set progress bar to 0% and status to init compositing */ editingtree->progress(editingtree->prh, 0.0); - bool twopass = (editingtree->flag&NTREE_TWO_PASS) > 0 && !rendering; + bool twopass = (editingtree->flag & NTREE_TWO_PASS) > 0 && !rendering; /* initialize execution system */ if (twopass) { ExecutionSystem *system = new ExecutionSystem(rd, editingtree, rendering, twopass); @@ -86,14 +91,21 @@ void COM_execute(RenderData *rd, bNodeTree *editingtree, int rendering) BLI_mutex_unlock(&s_compositorMutex); } -void COM_deinitialize() +void COM_freeCaches() { if (is_compositorMutex_init) { BLI_mutex_lock(&s_compositorMutex); + intern_freeCompositorCaches(); + BLI_mutex_unlock(&s_compositorMutex); + } +} - deintializeDistortionCache(); +void COM_deinitialize() +{ + if (is_compositorMutex_init) { + BLI_mutex_lock(&s_compositorMutex); + intern_freeCompositorCaches(); WorkScheduler::deinitialize(); - is_compositorMutex_init = FALSE; BLI_mutex_unlock(&s_compositorMutex); BLI_mutex_end(&s_compositorMutex); diff --git a/source/blender/compositor/nodes/COM_GroupNode.cpp b/source/blender/compositor/nodes/COM_GroupNode.cpp index b1bc0966687..e10d7dbad2e 100644 --- a/source/blender/compositor/nodes/COM_GroupNode.cpp +++ b/source/blender/compositor/nodes/COM_GroupNode.cpp @@ -33,16 +33,7 @@ GroupNode::GroupNode(bNode *editorNode) : Node(editorNode) void GroupNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) { if (this->getbNode()->id == NULL) { - /* this is a really bad situation - bring on the pink! - so artists know this is bad */ - const float warning_color[4] = {1.0f, 0.0f, 1.0f, 1.0f}; - int index; - vector<OutputSocket *> &outputsockets = this->getOutputSockets(); - for (index = 0; index < outputsockets.size(); index++) { - SetColorOperation *operation = new SetColorOperation(); - this->getOutputSocket(index)->relinkConnections(operation->getOutputSocket()); - operation->setChannels(warning_color); - graph->addOperation(operation); - } + convertToOperations_invalid(graph, context); } } diff --git a/source/blender/compositor/nodes/COM_ImageNode.cpp b/source/blender/compositor/nodes/COM_ImageNode.cpp index addde140b9f..2d13ffb82b6 100644 --- a/source/blender/compositor/nodes/COM_ImageNode.cpp +++ b/source/blender/compositor/nodes/COM_ImageNode.cpp @@ -72,12 +72,16 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c /* force a load, we assume iuser index will be set OK anyway */ if (image && image->type == IMA_TYPE_MULTILAYER) { + bool is_multilayer_ok = false; BKE_image_get_ibuf(image, imageuser); if (image->rr) { RenderLayer *rl = (RenderLayer *)BLI_findlink(&image->rr->layers, imageuser->layer); if (rl) { OutputSocket *socket; int index; + + is_multilayer_ok = true; + for (index = 0; index < numberOfOutputs; index++) { socket = this->getOutputSocket(index); if (socket->isConnected() || index == 0) { @@ -114,6 +118,11 @@ void ImageNode::convertToOperations(ExecutionSystem *graph, CompositorContext *c } } } + + /* without this, multilayer that fail to load will crash blender [#32490] */ + if (is_multilayer_ok == false) { + convertToOperations_invalid(graph, context); + } } else { if (numberOfOutputs > 0) { diff --git a/source/blender/compositor/operations/COM_CompositorOperation.h b/source/blender/compositor/operations/COM_CompositorOperation.h index ae94e974db0..c1d91c16a3c 100644 --- a/source/blender/compositor/operations/COM_CompositorOperation.h +++ b/source/blender/compositor/operations/COM_CompositorOperation.h @@ -31,6 +31,9 @@ */ class CompositorOperation : public NodeOperation { private: + /** + * @brief Scene name, used for getting the render output, includes 'SC' prefix. + */ char m_sceneName[MAX_ID_NAME]; /** diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 2dbaa2998e3..12ab4166bc8 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -745,7 +745,9 @@ void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv); void uiLayoutSetContextPointer(uiLayout *layout, const char *name, struct PointerRNA *ptr); void uiLayoutContextCopy(uiLayout *layout, struct bContextStore *context); const char *uiLayoutIntrospect(uiLayout *layout); // XXX - testing -void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag); +void uiLayoutOperatorButs(const struct bContext *C, struct uiLayout *layout, struct wmOperator *op, + int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), + const char label_align, const short flag); struct MenuType *uiButGetMenuType(uiBut *but); void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index ffce2b618a3..f97b9864539 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -3722,8 +3722,14 @@ void uiButGetStrInfo(bContext *C, uiBut *but, int nbr, ...) if (type == BUT_GET_LABEL) { if (but->str) { - /* Menu labels can have some complex formating stuff marked by pipes, we don't want those here! */ - char *tc = strchr(but->str, '|'); + /* Menu labels can have some complex formating stuff marked by pipes or %t, we don't want those here! */ + const char *tc; + + if (but->type == MENU) + tc = strstr(but->str, "%t"); + else + tc = strchr(but->str, '|'); + if (tc) tmp = BLI_strdupn(but->str, tc - but->str); else diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b68e14898d0..803fd928085 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2837,7 +2837,9 @@ static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), void *op_pt, } /* this function does not initialize the layout, functions can be called on the layout before and after */ -void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const char label_align, const short flag) +void uiLayoutOperatorButs(const bContext *C, uiLayout *layout, wmOperator *op, + int (*check_prop)(struct PointerRNA *, struct PropertyRNA *), + const char label_align, const short flag) { if (!op->properties) { IDPropertyTemplate val = {0}; diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 67c0d04a79f..e8b8959fd43 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -908,19 +908,19 @@ static void UI_OT_editsource(wmOperatorType *ot) void edittranslation_find_po_file(const char *root, const char *uilng, char *path, const size_t maxlen) { - char t[32]; /* Should be more than enough! */ + char tstr[32]; /* Should be more than enough! */ /* First, full lang code. */ - sprintf(t, "%s.po", uilng); + BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng); BLI_join_dirfile(path, maxlen, root, uilng); - BLI_join_dirfile(path, maxlen, path, t); + BLI_join_dirfile(path, maxlen, path, tstr); if (BLI_is_file(path)) return; /* Now try without the second iso code part (_ES in es_ES). */ - strncpy(t, uilng, 2); - strcpy(t + 2, uilng + 5); /* Because of some codes like sr_SR@latin... */ - BLI_join_dirfile(path, maxlen, root, t); - sprintf(t, "%s.po", t); - BLI_join_dirfile(path, maxlen, path, t); + strncpy(tstr, uilng, 2); + BLI_strncpy(tstr + 2, uilng + 5, sizeof(tstr) - 2); /* Because of some codes like sr_SR@latin... */ + BLI_join_dirfile(path, maxlen, root, tstr); + strcat(tstr, ".po"); + BLI_join_dirfile(path, maxlen, path, tstr); if (BLI_is_file(path)) return; path[0] = '\0'; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 9aaafe28377..543ac18801c 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1024,7 +1024,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) uiDefBut(block, LABEL, B_CONSTRAINT_TEST, typestr, xco + 10, yco, 100, 18, NULL, 0.0, 0.0, 0.0, 0.0, ""); if (con->flag & CONSTRAINT_DISABLE) - uiLayoutSetRedAlert(row, 1); + uiLayoutSetRedAlert(row, TRUE); if (proxy_protected == 0) { uiItemR(row, &ptr, "name", 0, "", ICON_NONE); @@ -1032,7 +1032,7 @@ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) else uiItemL(row, con->name, ICON_NONE); - uiLayoutSetRedAlert(row, 0); + uiLayoutSetRedAlert(row, FALSE); /* proxy-protected constraints cannot be edited, so hide up/down + close buttons */ if (proxy_protected) { @@ -1200,7 +1200,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M block = uiLayoutGetBlock(layout); row = uiLayoutRow(layout, FALSE); col = uiLayoutColumn(row, FALSE); - uiLayoutSetKeepAspect(col, 1); + uiLayoutSetKeepAspect(col, TRUE); /* add preview */ uiDefBut(block, BUT_EXTRA, 0, "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, pid, 0.0, 0.0, 0, 0, ""); @@ -1894,7 +1894,7 @@ static void curvemap_buttons_layout(uiLayout *layout, PointerRNA *ptr, char labe } if (cmp) { - uiLayoutColumn(layout, TRUE); + uiLayoutRow(layout, TRUE); uiBlockSetNFunc(block, curvemap_buttons_update, NULL, cumap); uiDefButF(block, NUM, 0, "X", 0, 2 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, &cmp->x, 0.0f, 1.0f, 1, 5, ""); uiDefButF(block, NUM, 0, "Y", 0, 1 * UI_UNIT_Y, UI_UNIT_X * 10, UI_UNIT_Y, &cmp->y, 0.0f, 1.0f, 1, 5, ""); @@ -2205,7 +2205,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe row = uiLayoutRow(split, TRUE); if (i == 0 || (key->type != KEY_RELATIVE)) uiItemL(row, "", ICON_NONE); else uiItemR(row, itemptr, "value", 0, "", ICON_NONE); - uiItemR(row, itemptr, "mute", 0, "", 0); + uiItemR(row, itemptr, "mute", 0, "", ICON_NONE); if ((kb->flag & KEYBLOCK_MUTE) || (ob->mode == OB_MODE_EDIT && !((ob->shapeflag & OB_SHAPE_EDIT_MODE) && ob->type == OB_MESH))) @@ -2274,9 +2274,9 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiBlockSetEmboss(block, UI_EMBOSSN); row = uiLayoutRow(split, TRUE); uiItemR(row, itemptr, "alpha", 0, "", ICON_NONE); - uiItemR(row, itemptr, "hide", 0, "", 0); - uiItemR(row, itemptr, "hide_select", 0, "", 0); - uiItemR(row, itemptr, "hide_render", 0, "", 0); + uiItemR(row, itemptr, "hide", 0, "", ICON_NONE); + uiItemR(row, itemptr, "hide_select", 0, "", ICON_NONE); + uiItemR(row, itemptr, "hide_render", 0, "", ICON_NONE); uiBlockSetEmboss(block, UI_EMBOSS); } @@ -2321,7 +2321,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe while (id < prop_names_end) { if ((id_next = strchr(id, ':'))) *id_next++ = '\0'; else id_next = prop_names_end; - uiItemR(row, itemptr, id, 0, NULL, 0); + uiItemR(row, itemptr, id, 0, NULL, ICON_NONE); id = id_next; } MEM_freeN(prop_names); diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index d0ce3f0cace..0e6b8f77528 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -152,10 +152,10 @@ void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr) /* Export Options: */ box = uiLayoutBox(layout); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); uiItemL(row, IFACE_("Export Data Options:"), ICON_MESH_DATA); - row = uiLayoutRow(box, 0); + row = uiLayoutRow(box, FALSE); split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT); col = uiLayoutColumn(split, FALSE); uiItemR(col, imfptr, "apply_modifiers", 0, NULL, ICON_NONE); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 8f08c3afc36..7ecfb712c18 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -555,7 +555,7 @@ static int verge_linehit(const void *vlh1, const void *vlh2) } /* If there's a linehit connected (same face) as testi in range [firsti, lasti], return the first such, else -1. - * If testi is out of range, look for connection to f instead, if f is non-NULL */ + * If testi is out of range, look for connection to f instead, if f is non-NULL */ static int find_connected_linehit(KnifeTool_OpData *kcd, int testi, BMFace *f, int firsti, int lasti) { int i; @@ -563,9 +563,10 @@ static int find_connected_linehit(KnifeTool_OpData *kcd, int testi, BMFace *f, i for (i = firsti; i <= lasti; i++) { if (testi >= 0 && testi < kcd->totlinehit) { if (knife_find_common_face(&kcd->linehits[testi].kfe->faces, - &kcd->linehits[i].kfe->faces)) + &kcd->linehits[i].kfe->faces)) return i; - } else if (f) { + } + else if (f) { if (find_ref(&kcd->linehits[i].kfe->faces, f)) return i; } @@ -582,9 +583,9 @@ static void knife_sort_linehits(KnifeTool_OpData *kcd) /* for ranges of equal "l", swap if neccesary to make predecessor and * successor faces connected to the linehits at either end of the range */ - for (i = 0; i < kcd->totlinehit -1; i = nexti) { + for (i = 0; i < kcd->totlinehit - 1; i = nexti) { for (j = i + 1; j < kcd->totlinehit; j++) { - if (fabsf(kcd->linehits[j].l - kcd->linehits[i].l) > 80*FLT_EPSILON) + if (fabsf(kcd->linehits[j].l - kcd->linehits[i].l) > 80 * FLT_EPSILON) break; } nexti = j; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index b13a299c4c7..c8ba9240db3 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -62,6 +62,7 @@ #include "BKE_tessmesh.h" #include "BKE_report.h" #include "BKE_DerivedMesh.h" +#include "BKE_object_deform.h" #include "RNA_access.h" #include "RNA_define.h" @@ -1136,7 +1137,6 @@ static void vgroup_levels(Object *ob, float offset, float gain) } } -/* TODO - select between groups */ static void vgroup_normalize_all(Object *ob, int lock_active) { MDeformVert *dv, **dvert_array = NULL; @@ -1152,29 +1152,35 @@ static void vgroup_normalize_all(Object *ob, int lock_active) ED_vgroup_give_parray(ob->data, &dvert_array, &dvert_tot, use_vert_sel); if (dvert_array) { - if (lock_active) { + const int defbase_tot = BLI_countlist(&ob->defbase); + char *lock_flags = BKE_objdef_lock_flags_get(ob, defbase_tot); - for (i = 0; i < dvert_tot; i++) { - /* in case its not selected */ - if (!(dv = dvert_array[i])) { - continue; - } - - defvert_normalize_lock(dv, def_nr); - } + if ((lock_active == TRUE) && + (lock_flags != NULL) && + (def_nr < defbase_tot)) + { + lock_flags[def_nr] = TRUE; } - else { - for (i = 0; i < dvert_tot; i++) { - /* in case its not selected */ - if (!(dv = dvert_array[i])) { - continue; + for (i = 0; i < dvert_tot; i++) { + /* in case its not selected */ + if ((dv = dvert_array[i])) { + if (lock_flags) { + defvert_normalize_lock_map(dv, lock_flags, defbase_tot); + } + else if (lock_active) { + defvert_normalize_lock_single(dv, def_nr); + } + else { + defvert_normalize(dv); } - - defvert_normalize(dv); } } + if (lock_flags) { + MEM_freeN(lock_flags); + } + MEM_freeN(dvert_array); } } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 3c389f97b34..bf948bf9dd8 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -72,6 +72,7 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" +#include "BKE_object_deform.h" #include "BKE_paint.h" #include "BKE_report.h" @@ -1308,29 +1309,6 @@ static char has_locked_group(MDeformVert *dvert, const int defbase_tot, } return FALSE; } -/* - * gen_lck_flags gets the status of "flag" for each bDeformGroup - * in ob->defbase and returns an array containing them - */ -static char *gen_lock_flags(Object *ob, int defbase_tot) -{ - char is_locked = FALSE; - int i; - //int defbase_tot = BLI_countlist(&ob->defbase); - char *lock_flags = MEM_mallocN(defbase_tot * sizeof(char), "defflags"); - bDeformGroup *defgroup; - - for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { - lock_flags[i] = ((defgroup->flag & DG_LOCK_WEIGHT) != 0); - is_locked |= lock_flags[i]; - } - if (is_locked) { - return lock_flags; - } - - MEM_freeN(lock_flags); - return NULL; -} static int has_locked_group_selected(int defbase_tot, const char *defbase_sel, const char *lock_flags) { @@ -1722,10 +1700,6 @@ static int get_first_selected_nonzero_weight(MDeformVert *dvert, const int defba return -1; } - -static char *wpaint_make_validmap(Object *ob); - - static void do_weight_paint_vertex( /* vars which remain the same for every vert */ VPaint *wp, Object *ob, const WeightPaintInfo *wpi, @@ -2067,63 +2041,6 @@ struct WPaintData { int defbase_tot; }; -static char *wpaint_make_validmap(Object *ob) -{ - bDeformGroup *dg; - ModifierData *md; - char *vgroup_validmap; - GHash *gh; - int i, step1 = 1; - - if (ob->defbase.first == NULL) { - return NULL; - } - - gh = BLI_ghash_str_new("wpaint_make_validmap gh"); - - /* add all names to a hash table */ - for (dg = ob->defbase.first; dg; dg = dg->next) { - BLI_ghash_insert(gh, dg->name, NULL); - } - - /* now loop through the armature modifiers and identify deform bones */ - for (md = ob->modifiers.first; md; md = !md->next && step1 ? (step1 = 0), modifiers_getVirtualModifierList(ob) : md->next) { - if (!(md->mode & (eModifierMode_Realtime | eModifierMode_Virtual))) - continue; - - if (md->type == eModifierType_Armature) { - ArmatureModifierData *amd = (ArmatureModifierData *) md; - - if (amd->object && amd->object->pose) { - bPose *pose = amd->object->pose; - bPoseChannel *chan; - - for (chan = pose->chanbase.first; chan; chan = chan->next) { - if (chan->bone->flag & BONE_NO_DEFORM) - continue; - - if (BLI_ghash_remove(gh, chan->name, NULL, NULL)) { - BLI_ghash_insert(gh, chan->name, SET_INT_IN_POINTER(1)); - } - } - } - } - } - - vgroup_validmap = MEM_mallocN(BLI_ghash_size(gh), "wpaint valid map"); - - /* add all names to a hash table */ - for (dg = ob->defbase.first, i = 0; dg; dg = dg->next, i++) { - vgroup_validmap[i] = (BLI_ghash_lookup(gh, dg->name) != NULL); - } - - BLI_assert(i == BLI_ghash_size(gh)); - - BLI_ghash_free(gh, NULL, NULL); - - return vgroup_validmap; -} - static int wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UNUSED(mouse[2])) { Scene *scene = CTX_data_scene(C); @@ -2202,9 +2119,9 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UNU /* set up auto-normalize, and generate map for detecting which * vgroups affect deform bones */ wpd->defbase_tot = BLI_countlist(&ob->defbase); - wpd->lock_flags = gen_lock_flags(ob, wpd->defbase_tot); + wpd->lock_flags = BKE_objdef_lock_flags_get(ob, wpd->defbase_tot); if (ts->auto_normalize || ts->multipaint || wpd->lock_flags) { - wpd->vgroup_validmap = wpaint_make_validmap(ob); + wpd->vgroup_validmap = BKE_objdef_validmap_get(ob, wpd->defbase_tot); } /* painting on subsurfs should give correct points too, this returns me->totvert amount */ @@ -2243,7 +2160,6 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P float alpha; float mval[2]; int use_vert_sel; - char *defbase_sel; const float pressure = RNA_float_get(itemptr, "pressure"); const float brush_size_pressure = BKE_brush_size_get(scene, brush) * (BKE_brush_use_size_pressure(scene, brush) ? pressure : 1.0f); @@ -2277,12 +2193,13 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P + /* *** setup WeightPaintInfo - pass onto do_weight_paint_vertex *** */ wpi.defbase_tot = wpd->defbase_tot; - defbase_sel = MEM_mallocN(wpi.defbase_tot * sizeof(char), "wpi.defbase_sel"); - wpi.defbase_tot_sel = get_selected_defgroups(ob, defbase_sel, wpi.defbase_tot); - wpi.defbase_sel = defbase_sel; /* so we can stay const */ - if (wpi.defbase_tot_sel == 0 && ob->actdef > 0) wpi.defbase_tot_sel = 1; + wpi.defbase_sel = BKE_objdef_selected_get(ob, wpi.defbase_tot, &wpi.defbase_tot_sel); + if (wpi.defbase_tot_sel == 0 && ob->actdef > 0) { + wpi.defbase_tot_sel = 1; + } wpi.defbase_tot_unsel = wpi.defbase_tot - wpi.defbase_tot_sel; wpi.vgroup_active = wpd->vgroup_active; diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index d8c7bf3f809..1bdf5214192 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -230,7 +230,7 @@ static void clip_panel_operator_redo(const bContext *C, Panel *pa) block = uiLayoutGetBlock(pa->layout); if (!WM_operator_check_ui_enabled(C, op->type->name)) - uiLayoutSetEnabled(pa->layout, 0); + uiLayoutSetEnabled(pa->layout, FALSE); /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */ uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, op); diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 08e0934e8ae..12823de60d2 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -4352,38 +4352,38 @@ static void draw_actuator_steering(uiLayout *layout, PointerRNA *ptr) uiLayout *row; uiLayout *col; - uiItemR(layout, ptr, "mode", 0, NULL, 0); - uiItemR(layout, ptr, "target", 0, NULL, 0); - uiItemR(layout, ptr, "navmesh", 0, NULL, 0); + uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "target", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "navmesh", 0, NULL, ICON_NONE); row = uiLayoutRow(layout, FALSE); - uiItemR(row, ptr, "distance", 0, NULL, 0); - uiItemR(row, ptr, "velocity", 0, NULL, 0); + uiItemR(row, ptr, "distance", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "velocity", 0, NULL, ICON_NONE); row = uiLayoutRow(layout, FALSE); - uiItemR(row, ptr, "acceleration", 0, NULL, 0); - uiItemR(row, ptr, "turn_speed", 0, NULL, 0); + uiItemR(row, ptr, "acceleration", 0, NULL, ICON_NONE); + uiItemR(row, ptr, "turn_speed", 0, NULL, ICON_NONE); row = uiLayoutRow(layout, FALSE); col = uiLayoutColumn(row, FALSE); - uiItemR(col, ptr, "facing", 0, NULL, 0); + uiItemR(col, ptr, "facing", 0, NULL, ICON_NONE); col = uiLayoutColumn(row, FALSE); - uiItemR(col, ptr, "facing_axis", 0, NULL, 0); + uiItemR(col, ptr, "facing_axis", 0, NULL, ICON_NONE); if (!RNA_boolean_get(ptr, "facing")) { uiLayoutSetActive(col, FALSE); } col = uiLayoutColumn(row, FALSE); - uiItemR(col, ptr, "normal_up", 0, NULL, 0); + uiItemR(col, ptr, "normal_up", 0, NULL, ICON_NONE); if (!RNA_pointer_get(ptr, "navmesh").data) { uiLayoutSetActive(col, FALSE); } row = uiLayoutRow(layout, FALSE); - uiItemR(row, ptr, "self_terminated", 0, NULL, 0); + uiItemR(row, ptr, "self_terminated", 0, NULL, ICON_NONE); if (RNA_enum_get(ptr, "mode")==ACT_STEERING_PATHFOLLOWING) { - uiItemR(row, ptr, "update_period", 0, NULL, 0); + uiItemR(row, ptr, "update_period", 0, NULL, ICON_NONE); row = uiLayoutRow(layout, FALSE); } - uiItemR(row, ptr, "show_visualization", 0, NULL, 0); + uiItemR(row, ptr, "show_visualization", 0, NULL, ICON_NONE); } static void draw_brick_actuator(uiLayout *layout, PointerRNA *ptr, bContext *C) diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 1981d085583..3455e0b219c 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -901,7 +901,7 @@ void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr) static void node_common_buts_whileloop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiItemR(layout, ptr, "max_iterations", 0, NULL, 0); + uiItemR(layout, ptr, "max_iterations", 0, NULL, ICON_NONE); } /* XXX Does a bounding box update by iterating over all children. @@ -1555,9 +1555,9 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point uiItemR(col, ptr, "use_relative", 0, NULL, ICON_NONE); if (RNA_boolean_get(ptr, "use_relative")) { - uiItemL(col, IFACE_("Aspect Correction"), 0); + uiItemL(col, IFACE_("Aspect Correction"), ICON_NONE); row = uiLayoutRow(layout, TRUE); - uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, 0); + uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, ICON_NONE); col = uiLayoutColumn(layout, TRUE); uiItemR(col, ptr, "factor_x", 0, IFACE_("X"), ICON_NONE); @@ -1981,7 +1981,7 @@ static void node_draw_input_file_output(const bContext *C, uiBlock *block, NodeImageMultiFileSocket *input = sock->storage; RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr); - uiItemL(row, input->layer, 0); + uiItemL(row, input->layer, ICON_NONE); } else { NodeImageMultiFileSocket *input = sock->storage; @@ -1989,7 +1989,7 @@ static void node_draw_input_file_output(const bContext *C, uiBlock *block, const char *imtype_name; RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr); - uiItemL(row, input->path, 0); + uiItemL(row, input->path, ICON_NONE); if (!RNA_boolean_get(&inputptr, "use_node_format")) imfptr = RNA_pointer_get(&inputptr, "format"); @@ -1998,7 +1998,7 @@ static void node_draw_input_file_output(const bContext *C, uiBlock *block, RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop, RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name); uiBlockSetEmboss(block, UI_EMBOSSP); - uiItemL(row, imtype_name, 0); + uiItemL(row, imtype_name, ICON_NONE); uiBlockSetEmboss(block, UI_EMBOSSN); } @@ -2010,9 +2010,9 @@ static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C) int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER); if (multilayer) - uiItemL(layout, IFACE_("Path:"), 0); + uiItemL(layout, IFACE_("Path:"), ICON_NONE); else - uiItemL(layout, IFACE_("Base Path:"), 0); + uiItemL(layout, IFACE_("Base Path:"), ICON_NONE); uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE); } static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -2058,9 +2058,9 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C uiLayout *row, *col; col = uiLayoutColumn(layout, TRUE); - uiItemL(col, IFACE_("Layer:"), 0); + uiItemL(col, IFACE_("Layer:"), ICON_NONE); row = uiLayoutRow(col, FALSE); - uiItemR(row, &active_input_ptr, "name", 0, "", 0); + uiItemR(row, &active_input_ptr, "name", 0, "", ICON_NONE); uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); } @@ -2068,9 +2068,9 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C uiLayout *row, *col; col = uiLayoutColumn(layout, TRUE); - uiItemL(col, IFACE_("File Path:"), 0); + uiItemL(col, IFACE_("File Path:"), ICON_NONE); row = uiLayoutRow(col, FALSE); - uiItemR(row, &active_input_ptr, "path", 0, "", 0); + uiItemR(row, &active_input_ptr, "path", 0, "", ICON_NONE); uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); @@ -2078,8 +2078,8 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C imfptr = RNA_pointer_get(&active_input_ptr, "format"); col = uiLayoutColumn(layout, TRUE); - uiItemL(col, IFACE_("Format:"), 0); - uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, 0); + uiItemL(col, IFACE_("Format:"), ICON_NONE); + uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, ICON_NONE); col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == FALSE); @@ -2233,12 +2233,12 @@ static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, Pointe if (!node->id) return; - uiItemR(layout, ptr, "filter_type", 0, "", 0); + uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE); } static void node_composit_buts_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiItemR(layout, ptr, "filter_type", 0, "", 0); + uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE); } static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -2250,7 +2250,7 @@ static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, Po if (!node->id) return; - uiItemR(layout, ptr, "distortion_type", 0, "", 0); + uiItemR(layout, ptr, "distortion_type", 0, "", ICON_NONE); } static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -2263,15 +2263,15 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE); row = uiLayoutRow(layout, FALSE); - uiItemL(row, "", 0); - uiItemL(row, IFACE_("Saturation"), 0); - uiItemL(row, IFACE_("Contrast"), 0); - uiItemL(row, IFACE_("Gamma"), 0); - uiItemL(row, IFACE_("Gain"), 0); - uiItemL(row, IFACE_("Lift"), 0); + uiItemL(row, "", ICON_NONE); + uiItemL(row, IFACE_("Saturation"), ICON_NONE); + uiItemL(row, IFACE_("Contrast"), ICON_NONE); + uiItemL(row, IFACE_("Gamma"), ICON_NONE); + uiItemL(row, IFACE_("Gain"), ICON_NONE); + uiItemL(row, IFACE_("Lift"), ICON_NONE); row = uiLayoutRow(layout, FALSE); - uiItemL(row, IFACE_("Master"), 0); + uiItemL(row, IFACE_("Master"), ICON_NONE); uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2279,7 +2279,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); row = uiLayoutRow(layout, FALSE); - uiItemL(row, IFACE_("Highlights"), 0); + uiItemL(row, IFACE_("Highlights"), ICON_NONE); uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2287,7 +2287,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); row = uiLayoutRow(layout, FALSE); - uiItemL(row, IFACE_("Midtones"), 0); + uiItemL(row, IFACE_("Midtones"), ICON_NONE); uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2295,7 +2295,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSE uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, "", ICON_NONE); row = uiLayoutRow(layout, FALSE); - uiItemL(row, IFACE_("Shadows"), 0); + uiItemL(row, IFACE_("Shadows"), ICON_NONE); uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE); uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE); @@ -2316,31 +2316,31 @@ static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *U uiItemR(row, ptr, "green", 0, NULL, ICON_NONE); uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE); row = layout; - uiItemL(row, IFACE_("Saturation"), 0); + uiItemL(row, IFACE_("Saturation"), ICON_NONE); uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemL(row, IFACE_("Contrast"), 0); + uiItemL(row, IFACE_("Contrast"), ICON_NONE); uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemL(row, IFACE_("Gamma"), 0); + uiItemL(row, IFACE_("Gamma"), ICON_NONE); uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemL(row, IFACE_("Gain"), 0); + uiItemL(row, IFACE_("Gain"), ICON_NONE); uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemL(row, IFACE_("Lift"), 0); + uiItemL(row, IFACE_("Lift"), ICON_NONE); uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -2591,7 +2591,7 @@ static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRN RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr); - col = uiLayoutColumn(layout, 0); + col = uiLayoutColumn(layout, FALSE); uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA); object = BKE_tracking_object_get_named(tracking, data->tracking_object); diff --git a/source/blender/editors/space_node/node_buttons.c b/source/blender/editors/space_node/node_buttons.c index e50b1dc4ba6..da077d93641 100644 --- a/source/blender/editors/space_node/node_buttons.c +++ b/source/blender/editors/space_node/node_buttons.c @@ -110,8 +110,8 @@ static void active_node_panel(const bContext *C, Panel *pa) uiItemR(col, &ptr, "use_custom_color", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE); sub = uiLayoutRow(col, FALSE); if (!(node->flag & NODE_CUSTOM_COLOR)) - uiLayoutSetEnabled(sub, 0); - uiItemR(sub, &ptr, "color", 0, "", 0); + uiLayoutSetEnabled(sub, FALSE); + uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); col = uiLayoutColumn(row, TRUE); uiItemO(col, "", ICON_ZOOMIN, "node.node_color_preset_add"); diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 989b3999018..7881014ed54 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -627,11 +627,11 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, row = uiLayoutRow(split, FALSE); col = uiLayoutColumn(row, FALSE); - uiItemR(col, &inputptr, "default_value", 0, "", 0); + uiItemR(col, &inputptr, "default_value", 0, "", ICON_NONE); } else { row = uiLayoutRow(split, TRUE); - uiItemR(row, &inputptr, "default_value", 0, "", 0); + uiItemR(row, &inputptr, "default_value", 0, "", ICON_NONE); } } else diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index d2b3bcf6825..da93e07748a 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -1030,7 +1030,7 @@ void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, if (draw_flags & DRAW_FACE_SELECT) facemask = wpaint__setSolidDrawOptions_facemask; - if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { + if (ob->mode & OB_MODE_WEIGHT_PAINT) { if (do_light) { const float spec[4] = {0.47f, 0.47f, 0.47f, 0.47f}; diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index ee1ead76f7c..b40e880591a 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -111,7 +111,7 @@ static void view3d_panel_operator_redo(const bContext *C, Panel *pa) block = uiLayoutGetBlock(pa->layout); if (!WM_operator_check_ui_enabled(C, op->type->name)) - uiLayoutSetEnabled(pa->layout, 0); + uiLayoutSetEnabled(pa->layout, FALSE); /* note, blockfunc is a default but->func, use Handle func to allow button callbacks too */ uiBlockSetHandleFunc(block, ED_undo_operator_repeat_cb_evt, op); diff --git a/source/blender/editors/util/CMakeLists.txt b/source/blender/editors/util/CMakeLists.txt index c13e6c16413..e0991c48fa6 100644 --- a/source/blender/editors/util/CMakeLists.txt +++ b/source/blender/editors/util/CMakeLists.txt @@ -62,6 +62,7 @@ set(SRC ../include/ED_lattice.h ../include/ED_logic.h ../include/ED_markers.h + ../include/ED_mask.h ../include/ED_mball.h ../include/ED_mesh.h ../include/ED_node.h diff --git a/source/blender/imbuf/intern/moviecache.c b/source/blender/imbuf/intern/moviecache.c index dd6ccbb1dab..78a989ad48f 100644 --- a/source/blender/imbuf/intern/moviecache.c +++ b/source/blender/imbuf/intern/moviecache.c @@ -174,12 +174,13 @@ static int compare_int(const void *av, const void *bv) static void IMB_moviecache_destructor(void *p) { - MovieCacheItem *item = (MovieCacheItem *) p; - MovieCache *cache = item->cache_owner; - - PRINT("%s: cache '%s' destroy item %p buffer %p\n", __func__, cache->name, item, item->ibuf); + MovieCacheItem *item = (MovieCacheItem *)p; if (item && item->ibuf) { + MovieCache *cache = item->cache_owner; + + PRINT("%s: cache '%s' destroy item %p buffer %p\n", __func__, cache->name, item, item->ibuf); + IMB_freeImBuf(item->ibuf); item->ibuf = NULL; diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index c83bddbfc64..c34ff009405 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -99,7 +99,7 @@ typedef struct Strip { StripProxy *proxy; StripCrop *crop; StripTransform *transform; - StripColorBalance *color_balance; + StripColorBalance *color_balance DNA_DEPRECATED; } Strip; /** @@ -150,9 +150,6 @@ typedef struct Sequence { /* pointers for effects: */ struct Sequence *seq1, *seq2, *seq3; - /* maks input for effects */ - struct Sequence *mask_sequence; - ListBase seqbase; /* list of strips for metastrips */ struct bSound *sound; /* the linked "bSound" object */ @@ -315,7 +312,7 @@ typedef struct BrightContrastModifierData { #define SEQ_USE_PROXY (1 << 15) #define SEQ_USE_TRANSFORM (1 << 16) #define SEQ_USE_CROP (1 << 17) -#define SEQ_USE_COLOR_BALANCE (1 << 18) +/* #define SEQ_USE_COLOR_BALANCE (1 << 18) */ /* DEPRECATED */ #define SEQ_USE_PROXY_CUSTOM_DIR (1 << 19) #define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21) diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index a755e130bb7..5a3efb645a5 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -317,7 +317,7 @@ static void rna_def_render_engine(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_REQUIRED); prop = RNA_def_int(func, "h", 0, 0, INT_MAX, "Height", "", 0, INT_MAX); RNA_def_property_flag(prop, PROP_REQUIRED); - prop = RNA_def_string(func, "layer", "", 0, "Layer", "Single layer to get render result for"); + RNA_def_string(func, "layer", "", 0, "Layer", "Single layer to get render result for"); /* NULL ok here */ prop = RNA_def_pointer(func, "result", "RenderResult", "Result", ""); RNA_def_function_return(func, prop); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 88952e6ceca..e3e467a9abb 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -56,7 +56,6 @@ typedef struct EffectInfo { const char *ui_desc; void (*func)(StructRNA *); int inputs; - int supports_mask; } EffectInfo; EnumPropertyItem sequence_modifier_type_items[] = { @@ -244,28 +243,6 @@ static void rna_Sequence_channel_set(PointerRNA *ptr, int value) BKE_sequencer_sort(scene); } -/* properties that need to allocate structs */ -static void rna_Sequence_use_color_balance_set(PointerRNA *ptr, int value) -{ - Sequence *seq = (Sequence *)ptr->data; - int c; - - if (value) { - seq->flag |= SEQ_USE_COLOR_BALANCE; - if (seq->strip->color_balance == NULL) { - seq->strip->color_balance = MEM_callocN(sizeof(struct StripColorBalance), "StripColorBalance"); - for (c = 0; c < 3; c++) { - seq->strip->color_balance->lift[c] = 1.0f; - seq->strip->color_balance->gamma[c] = 1.0f; - seq->strip->color_balance->gain[c] = 1.0f; - } - } - } - else { - seq->flag ^= SEQ_USE_COLOR_BALANCE; - } -} - static void rna_Sequence_use_proxy_set(PointerRNA *ptr, int value) { Sequence *seq = (Sequence *)ptr->data; @@ -608,13 +585,6 @@ static int rna_Sequence_input_count_get(PointerRNA *ptr) return BKE_sequence_effect_get_num_inputs(seq->type); } -static int rna_Sequence_supports_mask_get(PointerRNA *ptr) -{ - Sequence *seq = (Sequence *)(ptr->data); - - return BKE_sequence_effect_get_supports_mask(seq->type); -} - #if 0 static void rna_SoundSequence_filename_set(PointerRNA *ptr, const char *value) { @@ -642,20 +612,6 @@ static void rna_Sequence_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Point } } -static int rna_Sequence_otherSequence_poll(PointerRNA *ptr, PointerRNA value) -{ - Sequence *seq = (Sequence *) ptr->data; - Sequence *cur = (Sequence *) value.data; - - if (seq == cur) - return FALSE; - - if (BKE_sequence_check_depend(seq, cur)) - return FALSE; - - return TRUE; -} - static void rna_Sequence_update_reopen_files(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { Scene *scene = (Scene *) ptr->id.data; @@ -1631,16 +1587,6 @@ static void rna_def_filter_video(StructRNA *srna) RNA_def_property_ui_text(prop, "Strobe", "Only display every nth frame"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); - prop = RNA_def_property(srna, "use_color_balance", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_COLOR_BALANCE); - RNA_def_property_ui_text(prop, "Use Color Balance", "(3-Way color correction) on input"); - RNA_def_property_boolean_funcs(prop, NULL, "rna_Sequence_use_color_balance_set"); - RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); - - prop = RNA_def_property(srna, "color_balance", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "strip->color_balance"); - RNA_def_property_ui_text(prop, "Color Balance", ""); - prop = RNA_def_property(srna, "use_translation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_TRANSFORM); RNA_def_property_ui_text(prop, "Use Translation", "Translate image before processing"); @@ -1706,7 +1652,7 @@ static void rna_def_input(StructRNA *srna) RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); } -static void rna_def_effect_inputs(StructRNA *srna, int count, int supports_mask) +static void rna_def_effect_inputs(StructRNA *srna, int count) { PropertyRNA *prop; @@ -1714,10 +1660,6 @@ static void rna_def_effect_inputs(StructRNA *srna, int count, int supports_mask) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_int_funcs(prop, "rna_Sequence_input_count_get", NULL, NULL); - prop = RNA_def_property(srna, "is_supports_mask", PROP_INT, PROP_UNSIGNED); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_int_funcs(prop, "rna_Sequence_supports_mask_get", NULL, NULL); - if (count >= 1) { prop = RNA_def_property(srna, "input_1", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "seq1"); @@ -1740,15 +1682,6 @@ static void rna_def_effect_inputs(StructRNA *srna, int count, int supports_mask) RNA_def_property_ui_text(prop, "Input 3", "Third input for the effect strip"); } */ - - if (supports_mask) { - prop = RNA_def_property(srna, "input_mask_strip", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "mask_sequence"); - RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Sequence_otherSequence_poll"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Mask", "Mask input for the effect strip"); - RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); - } } static void rna_def_image(BlenderRNA *brna) @@ -2189,28 +2122,28 @@ static void rna_def_speed_control(StructRNA *srna) } static EffectInfo def_effects[] = { - {"AddSequence", "Add Sequence", "Add Sequence", NULL, 2, FALSE}, + {"AddSequence", "Add Sequence", "Add Sequence", NULL, 2}, {"AdjustmentSequence", "Adjustment Layer Sequence", - "Sequence strip to perform filter adjustments to layers below", rna_def_input, 0, TRUE}, - {"AlphaOverSequence", "Alpha Over Sequence", "Alpha Over Sequence", NULL, 2, FALSE}, - {"AlphaUnderSequence", "Alpha Under Sequence", "Alpha Under Sequence", NULL, 2, FALSE}, + "Sequence strip to perform filter adjustments to layers below", rna_def_input, 0}, + {"AlphaOverSequence", "Alpha Over Sequence", "Alpha Over Sequence", NULL, 2}, + {"AlphaUnderSequence", "Alpha Under Sequence", "Alpha Under Sequence", NULL, 2}, {"ColorSequence", "Color Sequence", - "Sequence strip creating an image filled with a single color", rna_def_solid_color, 0, FALSE}, - {"CrossSequence", "Cross Sequence", "Cross Sequence", NULL, 2, FALSE}, - {"GammaCrossSequence", "Gamma Cross Sequence", "Gamma Cross Sequence", NULL, 2, FALSE}, - {"GlowSequence", "Glow Sequence", "Sequence strip creating a glow effect", rna_def_glow, 1, FALSE}, + "Sequence strip creating an image filled with a single color", rna_def_solid_color, 0}, + {"CrossSequence", "Cross Sequence", "Cross Sequence", NULL, 2}, + {"GammaCrossSequence", "Gamma Cross Sequence", "Gamma Cross Sequence", NULL, 2}, + {"GlowSequence", "Glow Sequence", "Sequence strip creating a glow effect", rna_def_glow, 1}, {"MulticamSequence", "Multicam Select Sequence", "Sequence strip to perform multicam editing", - rna_def_multicam, 0, FALSE}, - {"MultiplySequence", "Multiply Sequence", "Multiply Sequence", NULL, 2, FALSE}, - {"OverDropSequence", "Over Drop Sequence", "Over Drop Sequence", NULL, 2, FALSE}, + rna_def_multicam, 0}, + {"MultiplySequence", "Multiply Sequence", "Multiply Sequence", NULL, 2}, + {"OverDropSequence", "Over Drop Sequence", "Over Drop Sequence", NULL, 2}, {"SpeedControlSequence", "SpeedControl Sequence", - "Sequence strip to control the speed of other strips", rna_def_speed_control, 1, FALSE}, - {"SubtractSequence", "Subtract Sequence", "Subtract Sequence", NULL, 2, FALSE}, + "Sequence strip to control the speed of other strips", rna_def_speed_control, 1}, + {"SubtractSequence", "Subtract Sequence", "Subtract Sequence", NULL, 2}, {"TransformSequence", "Transform Sequence", - "Sequence strip applying affine transformations to other strips", rna_def_transform, 1, FALSE}, + "Sequence strip applying affine transformations to other strips", rna_def_transform, 1}, {"WipeSequence", "Wipe Sequence", "Sequence strip creating a wipe transition", - rna_def_wipe, 1, FALSE}, - {"", "", "", NULL, 0, FALSE} + rna_def_wipe, 1}, + {"", "", "", NULL, 0} }; static void rna_def_effects(BlenderRNA *brna) @@ -2223,7 +2156,7 @@ static void rna_def_effects(BlenderRNA *brna) RNA_def_struct_ui_text(srna, effect->ui_name, effect->ui_desc); RNA_def_struct_sdna(srna, "Sequence"); - rna_def_effect_inputs(srna, effect->inputs, effect->supports_mask); + rna_def_effect_inputs(srna, effect->inputs); if (effect->func) effect->func(srna); diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner.py b/source/blender/makesrna/rna_cleanup/rna_cleaner.py index b75d177d809..e3359fbae59 100755 --- a/source/blender/makesrna/rna_cleanup/rna_cleaner.py +++ b/source/blender/makesrna/rna_cleanup/rna_cleaner.py @@ -60,7 +60,7 @@ def check_commandline(): usage() if sys.argv[1] == '-h': help() - elif not (sys.argv[1].endswith(".txt") or sys.argv[1].endswith(".py")): + elif not sys.argv[1].endswith((".txt", ".py")): print ('\nBad input file extension... exiting.') usage() else: diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index 360b343daa9..eae636d3510 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -69,6 +69,7 @@ void register_node_type_sh_invert(struct bNodeTreeType *ttype); void register_node_type_sh_seprgb(struct bNodeTreeType *ttype); void register_node_type_sh_combrgb(struct bNodeTreeType *ttype); void register_node_type_sh_hue_sat(struct bNodeTreeType *ttype); +void register_node_type_sh_tex_brick(struct bNodeTreeType *ttype); void register_node_type_sh_attribute(struct bNodeTreeType *ttype); void register_node_type_sh_geometry(struct bNodeTreeType *ttype); diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 55750ca1bab..07db1ce1a18 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -606,11 +606,9 @@ static void ntreeCompositExecTreeOld(bNodeTree *ntree, RenderData *rd, int do_pr bNode *node; ListBase threads; ThreadData thdata; - int totnode, curnode, rendering= 1, n; - bNodeTreeExec *exec= ntree->execdata; - - if (ntree == NULL) return; - + int totnode, curnode, rendering = TRUE, n; + bNodeTreeExec *exec = ntree->execdata; + if (do_preview) ntreeInitPreview(ntree, 0, 0); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index aa9d81389da..1c63ab512f2 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -254,6 +254,15 @@ void BPY_python_start(int argc, const char **argv) Py_Initialize(); +#ifdef WIN32 + /* this is disappointing, its likely a bug in python? + * for some reason 'PYTHONIOENCODING' is ignored in windows + * see: [#31555] for details. */ + PyRun_SimpleString("import sys, io\n" + "sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='surrogateescape', line_buffering=True)\n" + "sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='surrogateescape', line_buffering=True)\n"); +#endif /* WIN32 */ + // PySys_SetArgv(argc, argv); // broken in py3, not a huge deal /* sigh, why do python guys not have a (char **) version anymore? */ { diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index 57993874c7a..636b3205b23 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -205,17 +205,19 @@ void RE_engine_end_result(RenderEngine *engine, RenderResult *result, int cancel Render *re = engine->re; RenderPart *pa; - if (!result) + if (!result) { return; + } /* merge. on break, don't merge in result for preview renders, looks nicer */ if (!cancel) { /* for exr tile render, detect tiles that are done */ for (pa = re->parts.first; pa; pa = pa->next) { if (result->tilerect.xmin == pa->disprect.xmin && - result->tilerect.ymin == pa->disprect.ymin && - result->tilerect.xmax == pa->disprect.xmax && - result->tilerect.ymax == pa->disprect.ymax) { + result->tilerect.ymin == pa->disprect.ymin && + result->tilerect.xmax == pa->disprect.xmax && + result->tilerect.ymax == pa->disprect.ymax) + { pa->ready = 1; } } diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 984efdbb563..7b0629063a6 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -195,14 +195,12 @@ float *RE_RenderLayerGetPass(RenderLayer *rl, int passtype) RenderLayer *RE_GetRenderLayer(RenderResult *rr, const char *name) { - RenderLayer *rl; - - if (rr == NULL) return NULL; - - for (rl = rr->layers.first; rl; rl = rl->next) - if (strncmp(rl->name, name, RE_MAXNAME) == 0) - return rl; - return NULL; + if (rr == NULL) { + return NULL; + } + else { + return BLI_findstring(&rr->layers, name, offsetof(RenderLayer, name)); + } } RenderResult *RE_MultilayerConvert(void *exrhandle, int rectx, int recty) @@ -1109,7 +1107,10 @@ static void merge_renderresult_fields(RenderResult *rr, RenderResult *rr1, Rende /* passes are allocated in sync */ rpass1 = rl1->passes.first; rpass2 = rl2->passes.first; - for (rpass = rl->passes.first; rpass && rpass1 && rpass2; rpass = rpass->next, rpass1 = rpass1->next, rpass2 = rpass2->next) { + for (rpass = rl->passes.first; + rpass && rpass1 && rpass2; + rpass = rpass->next, rpass1 = rpass1->next, rpass2 = rpass2->next) + { interleave_rect(rr, rpass->rect, rpass1->rect, rpass2->rect, rpass->channels); } } diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index 603e49766b1..509266bdc33 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -30,6 +30,7 @@ */ #include <stdio.h> +#include <stdlib.h> #include <string.h> #include "MEM_guardedalloc.h" @@ -554,8 +555,9 @@ RenderResult *render_result_new(Render *re, rcti *partrct, int crop, int savebuf IMB_exr_add_channel(rl->exrhandle, rl->name, "Combined.B", 0, 0, NULL); IMB_exr_add_channel(rl->exrhandle, rl->name, "Combined.A", 0, 0, NULL); } - else + else { rl->rectf = MEM_mapallocN(rectx * recty * sizeof(float) * 4, "Combined rgba"); + } /* note, this has to be in sync with scene.c */ rl->lay = (1 << 20) - 1; @@ -691,16 +693,18 @@ void render_result_merge(RenderResult *rr, RenderResult *rrpart) RenderPass *rpass, *rpassp; for (rl = rr->layers.first; rl; rl = rl->next) { - for (rlp = rrpart->layers.first; rlp; rlp = rlp->next) { - if (strcmp(rlp->name, rl->name) == 0) { - /* combined */ - if (rl->rectf && rlp->rectf) - do_merge_tile(rr, rrpart, rl->rectf, rlp->rectf, 4); - - /* passes are allocated in sync */ - for (rpass = rl->passes.first, rpassp = rlp->passes.first; rpass && rpassp; rpass = rpass->next, rpassp = rpassp->next) { - do_merge_tile(rr, rrpart, rpass->rect, rpassp->rect, rpass->channels); - } + rlp = RE_GetRenderLayer(rrpart, rl->name); + if (rlp) { + /* combined */ + if (rl->rectf && rlp->rectf) + do_merge_tile(rr, rrpart, rl->rectf, rlp->rectf, 4); + + /* passes are allocated in sync */ + for (rpass = rl->passes.first, rpassp = rlp->passes.first; + rpass && rpassp; + rpass = rpass->next, rpassp = rpassp->next) + { + do_merge_tile(rr, rrpart, rpass->rect, rpassp->rect, rpass->channels); } } } @@ -746,21 +750,24 @@ int RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *file /* combined */ if (rl->rectf) { int a, xstride = 4; - for (a = 0; a < xstride; a++) - IMB_exr_add_channel(exrhandle, rl->name, get_pass_name(SCE_PASS_COMBINED, a), + for (a = 0; a < xstride; a++) { + IMB_exr_add_channel(exrhandle, rl->name, get_pass_name(SCE_PASS_COMBINED, a), xstride, xstride * rr->rectx, rl->rectf + a); + } } /* passes are allocated in sync */ for (rpass = rl->passes.first; rpass; rpass = rpass->next) { int a, xstride = rpass->channels; for (a = 0; a < xstride; a++) { - if (rpass->passtype) - IMB_exr_add_channel(exrhandle, rl->name, get_pass_name(rpass->passtype, a), + if (rpass->passtype) { + IMB_exr_add_channel(exrhandle, rl->name, get_pass_name(rpass->passtype, a), xstride, xstride * rr->rectx, rpass->rect + a); - else - IMB_exr_add_channel(exrhandle, rl->name, make_pass_name(rpass, a), + } + else { + IMB_exr_add_channel(exrhandle, rl->name, make_pass_name(rpass, a), xstride, xstride * rr->rectx, rpass->rect + a); + } } } } @@ -818,8 +825,9 @@ void render_result_single_layer_end(Render *re) /* reconstruct render result layers */ for (nr = 0, srl = re->scene->r.layers.first; srl; srl = srl->next, nr++) { - if (nr == re->r.actlay) + if (nr == re->r.actlay) { BLI_addtail(&re->result->layers, rl); + } else { rlpush = RE_GetRenderLayer(re->pushedresult, srl->name); if (rlpush) { @@ -845,10 +853,14 @@ static void save_render_result_tile(RenderResult *rr, RenderResult *rrpart) BLI_lock_thread(LOCK_IMAGE); for (rlp = rrpart->layers.first; rlp; rlp = rlp->next) { - for (rl = rr->layers.first; rl; rl = rl->next) - if (strcmp(rl->name, rlp->name) == 0) - break; - + rl = RE_GetRenderLayer(rr, rlp->name); + + /* should never happen but prevents crash if it does */ + BLI_assert(rl); + if (UNLIKELY(rl == NULL)) { + continue; + } + if (rrpart->crop) { /* filters add pixel extra */ offs = (rrpart->crop + rrpart->crop * rrpart->rectx); } @@ -859,17 +871,19 @@ static void save_render_result_tile(RenderResult *rr, RenderResult *rrpart) /* combined */ if (rlp->rectf) { int a, xstride = 4; - for (a = 0; a < xstride; a++) + for (a = 0; a < xstride; a++) { IMB_exr_set_channel(rl->exrhandle, rlp->name, get_pass_name(SCE_PASS_COMBINED, a), xstride, xstride * rrpart->rectx, rlp->rectf + a + xstride * offs); + } } /* passes are allocated in sync */ for (rpassp = rlp->passes.first; rpassp; rpassp = rpassp->next) { int a, xstride = rpassp->channels; - for (a = 0; a < xstride; a++) + for (a = 0; a < xstride; a++) { IMB_exr_set_channel(rl->exrhandle, rlp->name, get_pass_name(rpassp->passtype, a), xstride, xstride * rrpart->rectx, rpassp->rect + a + xstride * offs); + } } } @@ -878,10 +892,14 @@ static void save_render_result_tile(RenderResult *rr, RenderResult *rrpart) partx = rrpart->tilerect.xmin + rrpart->crop; for (rlp = rrpart->layers.first; rlp; rlp = rlp->next) { - for (rl = rr->layers.first; rl; rl = rl->next) - if (strcmp(rl->name, rlp->name) == 0) - break; - + rl = RE_GetRenderLayer(rr, rlp->name); + + /* should never happen but prevents crash if it does */ + BLI_assert(rl); + if (UNLIKELY(rl == NULL)) { + continue; + } + IMB_exrtile_write_channels(rl->exrhandle, partx, party, 0); } diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 14c178c10f9..cbe8cc81451 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -93,13 +93,9 @@ extern struct Render R; static void init_render_texture(Render *re, Tex *tex) { - int cfra= re->scene->r.cfra; - - if (re) cfra= re->r.cfra; - /* imap test */ if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { - BKE_image_user_frame_calc(&tex->iuser, cfra, re?re->flag & R_SEC_FIELD:0); + BKE_image_user_frame_calc(&tex->iuser, re->r.cfra, re?re->flag & R_SEC_FIELD:0); } else if (tex->type==TEX_ENVMAP) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 60c61dbe88c..dee9d036891 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1444,14 +1444,15 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand } else { - printf("%s: error - missing modal\n", __func__); + printf("%s: error '%s' missing modal\n", __func__, op->idname); } } else { wmOperatorType *ot = WM_operatortype_find(event->keymap_idname, 0); - if (ot) + if (ot) { retval = wm_operator_invoke(C, ot, event, properties, NULL, FALSE); + } } /* Finished and pass through flag as handled */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 67cd202591d..0259146a9d3 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1002,7 +1002,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, width, UI_UNIT_Y, style); if (!WM_operator_check_ui_enabled(C, op->type->name)) - uiLayoutSetEnabled(layout, 0); + uiLayoutSetEnabled(layout, FALSE); if (op->type->flag & OPTYPE_MACRO) { for (op = op->macro.first; op; op = op->next) { diff --git a/source/tests/pep8.py b/source/tests/pep8.py index d12397ea81d..ccaaeb7c0cd 100644 --- a/source/tests/pep8.py +++ b/source/tests/pep8.py @@ -43,7 +43,7 @@ FORCE_PEP8_ALL = False def file_list_py(path): for dirpath, dirnames, filenames in os.walk(path): for filename in filenames: - if filename.endswith(".py") or filename.endswith(".cfg"): + if filename.endswith((".py", ".cfg")): yield os.path.join(dirpath, filename) |