diff options
40 files changed, 652 insertions, 260 deletions
diff --git a/extern/clew/include/clew.h b/extern/clew/include/clew.h index 328fd52857a..1b72f813c9f 100644 --- a/extern/clew/include/clew.h +++ b/extern/clew/include/clew.h @@ -2751,6 +2751,30 @@ CLEW_FUN_EXPORT PFNCLGETGLCONTEXTINFOKHR __clewGetGLContextInfoKH #endif #define clGetGLContextInfoKHR CLEW_GET_FUN(__clewGetGLContextInfoKHR ) +/* cl_ext */ + +/****************************************** + * cl_nv_device_attribute_query extension * + ******************************************/ +/* cl_nv_device_attribute_query extension - no extension #define since it has no functions */ +#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000 +#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001 +#define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002 +#define CL_DEVICE_WARP_SIZE_NV 0x4003 +#define CL_DEVICE_GPU_OVERLAP_NV 0x4004 +#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005 +#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006 + +/********************************* + * cl_amd_device_attribute_query * + *********************************/ +#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036 + +/********************************* + * cl_arm_printf extension + *********************************/ +#define CL_PRINTF_CALLBACK_ARM 0x40B0 +#define CL_PRINTF_BUFFERSIZE_ARM 0x40B1 #define CLEW_SUCCESS 0 //!< Success error code #define CLEW_ERROR_OPEN_FAILED -1 //!< Error code for failing to open the dynamic library diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index acd021bd8a7..0daf6784798 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -394,6 +394,12 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): default=0, ) + cls.use_animated_seed = BoolProperty( + name="Use Animated Seed", + description="Use different seed values (and hence noise patterns) at different frames", + default=False, + ) + cls.sample_clamp_direct = FloatProperty( name="Clamp Direct", description="If non-zero, the maximum value for a direct sample, " diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 2f729307e2f..e808759557f 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -135,7 +135,11 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel): col = split.column() sub = col.column(align=True) sub.label("Settings:") - sub.prop(cscene, "seed") + + seed_sub = sub.row(align=True) + seed_sub.prop(cscene, "seed") + seed_sub.prop(cscene, "use_animated_seed", text="", icon="TIME") + sub.prop(cscene, "sample_clamp_direct") sub.prop(cscene, "sample_clamp_indirect") @@ -558,11 +562,16 @@ class Cycles_PT_context_material(CyclesButtonsPanel, Panel): ob = context.object slot = context.material_slot space = context.space_data + is_sortable = len(ob.material_slots) > 1 if ob: + rows = 1 + if (is_sortable): + rows = 4 + row = layout.row() - row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=1) + row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows) col = row.column(align=True) col.operator("object.material_slot_add", icon='ZOOMIN', text="") @@ -570,6 +579,12 @@ class Cycles_PT_context_material(CyclesButtonsPanel, Panel): col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="") + if is_sortable: + col.separator() + + col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP' + col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN' + if ob.mode == 'EDIT': row = layout.row(align=True) row.operator("object.material_slot_assign", text="Assign") diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 4d4427eb708..87e2932d6b1 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -36,6 +36,7 @@ #include "util_debug.h" #include "util_foreach.h" #include "util_opengl.h" +#include "util_hash.h" CCL_NAMESPACE_BEGIN @@ -195,6 +196,9 @@ void BlenderSync::sync_integrator() integrator->filter_glossy = get_float(cscene, "blur_glossy"); integrator->seed = get_int(cscene, "seed"); + if(get_boolean(cscene, "use_animated_seed")) + integrator->seed = hash_int_2d(b_scene.frame_current(), get_int(cscene, "seed")); + integrator->sampling_pattern = (SamplingPattern)RNA_enum_get(&cscene, "sampling_pattern"); integrator->layer_flag = render_layer.layer; diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 4b325947f0f..f050153d914 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -281,7 +281,7 @@ public: nvcc, major, minor, machine, kernel.c_str(), cubin.c_str(), include.c_str(), cuda_version); if(experimental) - command += " -D__KERNEL_CUDA_EXPERIMENTAL__"; + command += " -D__KERNEL_EXPERIMENTAL__"; if(getenv("CYCLES_CUDA_EXTRA_CFLAGS")) { command += string(" ") + getenv("CYCLES_CUDA_EXTRA_CFLAGS"); diff --git a/intern/cycles/device/device_opencl.cpp b/intern/cycles/device/device_opencl.cpp index f2ac5fcc00b..f77b567a093 100644 --- a/intern/cycles/device/device_opencl.cpp +++ b/intern/cycles/device/device_opencl.cpp @@ -102,37 +102,6 @@ static bool opencl_kernel_use_advanced_shading(const string& platform) return false; } -static string opencl_kernel_build_options(const string& platform, const string *debug_src = NULL) -{ - string build_options = " -cl-fast-relaxed-math "; - - if(platform == "NVIDIA CUDA") - build_options += "-D__KERNEL_OPENCL_NVIDIA__ -cl-nv-maxrregcount=32 -cl-nv-verbose "; - - else if(platform == "Apple") - build_options += "-D__KERNEL_OPENCL_APPLE__ "; - - else if(platform == "AMD Accelerated Parallel Processing") - build_options += "-D__KERNEL_OPENCL_AMD__ "; - - else if(platform == "Intel(R) OpenCL") { - build_options += "-D__KERNEL_OPENCL_INTEL_CPU__ "; - - /* options for gdb source level kernel debugging. this segfaults on linux currently */ - if(opencl_kernel_use_debug() && debug_src) - build_options += "-g -s \"" + *debug_src + "\" "; - } - - if(opencl_kernel_use_debug()) - build_options += "-D__KERNEL_OPENCL_DEBUG__ "; - -#ifdef WITH_CYCLES_DEBUG - build_options += "-D__KERNEL_DEBUG__ "; -#endif - - return build_options; -} - /* thread safe cache for contexts and programs */ class OpenCLCache { @@ -657,7 +626,7 @@ public: const string *debug_src = NULL) { string build_options; - build_options = opencl_kernel_build_options(platform_name, debug_src) + custom_kernel_build_options; + build_options = kernel_build_options(debug_src) + custom_kernel_build_options; ciErr = clBuildProgram(*kernel_program, 0, NULL, build_options.c_str(), NULL, NULL); @@ -731,7 +700,7 @@ public: md5.append((uint8_t*)name, strlen(name)); md5.append((uint8_t*)driver, strlen(driver)); - string options = opencl_kernel_build_options(platform_name); + string options = kernel_build_options(); options += kernel_custom_build_options; md5.append((uint8_t*)options.c_str(), options.size()); @@ -1119,6 +1088,53 @@ public: virtual void thread_run(DeviceTask * /*task*/) = 0; protected: + + string kernel_build_options(const string *debug_src = NULL) + { + string build_options = " -cl-fast-relaxed-math "; + + if(platform_name == "NVIDIA CUDA") { + build_options += "-D__KERNEL_OPENCL_NVIDIA__ " + "-cl-nv-maxrregcount=32 " + "-cl-nv-verbose "; + + uint compute_capability_major, compute_capability_minor; + clGetDeviceInfo(cdDevice, CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV, + sizeof(cl_uint), &compute_capability_major, NULL); + clGetDeviceInfo(cdDevice, CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV, + sizeof(cl_uint), &compute_capability_minor, NULL); + + build_options += string_printf("-D__COMPUTE_CAPABILITY__=%u ", + compute_capability_major * 100 + + compute_capability_minor * 10); + } + + else if(platform_name == "Apple") + build_options += "-D__KERNEL_OPENCL_APPLE__ "; + + else if(platform_name == "AMD Accelerated Parallel Processing") + build_options += "-D__KERNEL_OPENCL_AMD__ "; + + else if(platform_name == "Intel(R) OpenCL") { + build_options += "-D__KERNEL_OPENCL_INTEL_CPU__ "; + + /* Options for gdb source level kernel debugging. + * this segfaults on linux currently. + */ + if(opencl_kernel_use_debug() && debug_src) + build_options += "-g -s \"" + *debug_src + "\" "; + } + + if(opencl_kernel_use_debug()) + build_options += "-D__KERNEL_OPENCL_DEBUG__ "; + +#ifdef WITH_CYCLES_DEBUG + build_options += "-D__KERNEL_DEBUG__ "; +#endif + + return build_options; + } + class ArgumentWrapper { public: ArgumentWrapper() : size(0), pointer(NULL) {} @@ -1433,7 +1449,7 @@ public: }; /* TODO(sergey): This is to keep tile split on OpenCL level working - * for now, since withotu this viewport render does not work as it + * for now, since without this view-port render does not work as it * should. * * Ideally it'll be done on the higher level, but we need to get ready @@ -1473,7 +1489,7 @@ public: buffers = tile.buffers; } - /* Split kernel is device global memory constained; + /* Split kernel is device global memory constrained; * hence split kernel cant render big tile size's in * one go. If the user sets a big tile size (big tile size * is a term relative to the available device global memory), @@ -1520,7 +1536,7 @@ public: /* Global memory variables [porting]; These memory is used for * co-operation between different kernels; Data written by one - * kernel will be avaible to another kernel via this global + * kernel will be available to another kernel via this global * memory. */ cl_mem rng_coop; @@ -1569,16 +1585,21 @@ public: cl_mem ray_depth_sd_DL_shadow; cl_mem transparent_depth_sd; cl_mem transparent_depth_sd_DL_shadow; -#ifdef __RAY_DIFFERENTIALS__ + + /* Ray differentials. */ cl_mem dP_sd, dI_sd; cl_mem dP_sd_DL_shadow, dI_sd_DL_shadow; cl_mem du_sd, dv_sd; cl_mem du_sd_DL_shadow, dv_sd_DL_shadow; -#endif -#ifdef __DPDU__ + + /* Dp/Du */ cl_mem dPdu_sd, dPdv_sd; cl_mem dPdu_sd_DL_shadow, dPdv_sd_DL_shadow; -#endif + + /* Object motion. */ + cl_mem ob_tfm_sd, ob_itfm_sd; + cl_mem ob_tfm_sd_DL_shadow, ob_itfm_sd_DL_shadow; + cl_mem closure_sd; cl_mem closure_sd_DL_shadow; cl_mem num_closure_sd; @@ -1719,7 +1740,8 @@ public: ray_depth_sd_DL_shadow = NULL; transparent_depth_sd = NULL; transparent_depth_sd_DL_shadow = NULL; -#ifdef __RAY_DIFFERENTIALS__ + + /* Ray differentials. */ dP_sd = NULL; dI_sd = NULL; dP_sd_DL_shadow = NULL; @@ -1728,13 +1750,19 @@ public: dv_sd = NULL; du_sd_DL_shadow = NULL; dv_sd_DL_shadow = NULL; -#endif -#ifdef __DPDU__ + + /* Dp/Du */ dPdu_sd = NULL; dPdv_sd = NULL; dPdu_sd_DL_shadow = NULL; dPdv_sd_DL_shadow = NULL; -#endif + + /* Object motion. */ + ob_tfm_sd = NULL; + ob_itfm_sd = NULL; + ob_tfm_sd_DL_shadow = NULL; + ob_itfm_sd_DL_shadow = NULL; + closure_sd = NULL; closure_sd_DL_shadow = NULL; num_closure_sd = NULL; @@ -1865,7 +1893,7 @@ public: size_t get_shader_closure_size(int max_closure) { - return (sizeof(ShaderClosure)* max_closure); + return (sizeof(ShaderClosure) * max_closure); } size_t get_shader_data_size(size_t shader_closure_size) @@ -1898,10 +1926,8 @@ public: { size_t shader_soa_size = 0; -#define SD_VAR(type, what) \ - shader_soa_size += sizeof(void *); -#define SD_CLOSURE_VAR(type, what, max_closure) - shader_soa_size += sizeof(void *); +#define SD_VAR(type, what) shader_soa_size += sizeof(void *); +#define SD_CLOSURE_VAR(type, what, max_closure) shader_soa_size += sizeof(void *); #include "kernel_shaderdata_vars.h" #undef SD_VAR #undef SD_CLOSURE_VAR @@ -1974,6 +2000,9 @@ public: #ifdef __WORK_STEALING__ common_custom_build_options += "-D__WORK_STEALING__ "; #endif + if(requested_features.experimental) { + common_custom_build_options += "-D__KERNEL_EXPERIMENTAL__ "; + } #define LOAD_KERNEL(program, name) \ do { \ @@ -2088,7 +2117,8 @@ public: release_mem_object_safe(ray_depth_sd_DL_shadow); release_mem_object_safe(transparent_depth_sd); release_mem_object_safe(transparent_depth_sd_DL_shadow); -#ifdef __RAY_DIFFERENTIALS__ + + /* Ray differentials. */ release_mem_object_safe(dP_sd); release_mem_object_safe(dP_sd_DL_shadow); release_mem_object_safe(dI_sd); @@ -2097,13 +2127,20 @@ public: release_mem_object_safe(du_sd_DL_shadow); release_mem_object_safe(dv_sd); release_mem_object_safe(dv_sd_DL_shadow); -#endif -#ifdef __DPDU__ + + /* Dp/Du */ release_mem_object_safe(dPdu_sd); release_mem_object_safe(dPdu_sd_DL_shadow); release_mem_object_safe(dPdv_sd); release_mem_object_safe(dPdv_sd_DL_shadow); -#endif + + /* Object motion. */ + release_mem_object_safe(ob_tfm_sd); + release_mem_object_safe(ob_itfm_sd); + + release_mem_object_safe(ob_tfm_sd_DL_shadow); + release_mem_object_safe(ob_itfm_sd_DL_shadow); + release_mem_object_safe(closure_sd); release_mem_object_safe(closure_sd_DL_shadow); release_mem_object_safe(num_closure_sd); @@ -2212,7 +2249,7 @@ public: */ if(num_parallel_samples >= 64) { /* TODO(sergey): Could use generic round-up here. */ - num_parallel_samples = (num_parallel_samples / 64) * 64 + num_parallel_samples = (num_parallel_samples / 64) * 64; } assert(num_parallel_samples != 0); @@ -2283,7 +2320,7 @@ public: transparent_depth_sd = mem_alloc(num_global_elements * sizeof(int)); transparent_depth_sd_DL_shadow = mem_alloc(num_global_elements * 2 * sizeof(int)); -#ifdef __RAY_DIFFERENTIALS__ + /* Ray differentials. */ dP_sd = mem_alloc(num_global_elements * sizeof(differential3)); dP_sd_DL_shadow = mem_alloc(num_global_elements * 2 * sizeof(differential3)); dI_sd = mem_alloc(num_global_elements * sizeof(differential3)); @@ -2292,14 +2329,19 @@ public: du_sd_DL_shadow = mem_alloc(num_global_elements * 2 * sizeof(differential)); dv_sd = mem_alloc(num_global_elements * sizeof(differential)); dv_sd_DL_shadow = mem_alloc(num_global_elements * 2 * sizeof(differential)); -#endif -#ifdef __DPDU__ + /* Dp/Du */ dPdu_sd = mem_alloc(num_global_elements * sizeof(float3)); dPdu_sd_DL_shadow = mem_alloc(num_global_elements * 2 * sizeof(float3)); dPdv_sd = mem_alloc(num_global_elements * sizeof(float3)); dPdv_sd_DL_shadow = mem_alloc(num_global_elements * 2 * sizeof(float3)); -#endif + + /* Object motion. */ + ob_tfm_sd = mem_alloc(num_global_elements * sizeof(Transform)); + ob_tfm_sd_DL_shadow = mem_alloc(num_global_elements * 2 * sizeof(Transform)); + ob_itfm_sd = mem_alloc(num_global_elements * sizeof(float3)); + ob_itfm_sd_DL_shadow = mem_alloc(num_global_elements * 2 * sizeof(Transform)); + closure_sd = mem_alloc(num_global_elements * ShaderClosure_size); closure_sd_DL_shadow = mem_alloc(num_global_elements * 2 * ShaderClosure_size); num_closure_sd = mem_alloc(num_global_elements * sizeof(int)); @@ -2385,10 +2427,10 @@ public: transparent_depth_sd, transparent_depth_sd_DL_shadow); + /* Ray differentials. */ start_arg_index += kernel_set_args(ckPathTraceKernel_data_init, start_arg_index, -#ifdef __RAY_DIFFERENTIALS__ dP_sd, dP_sd_DL_shadow, dI_sd, @@ -2396,14 +2438,29 @@ public: du_sd, du_sd_DL_shadow, dv_sd, - dv_sd_DL_shadow, -#endif -#ifdef __DPDU__ + dv_sd_DL_shadow); + + /* Dp/Du */ + start_arg_index += + kernel_set_args(ckPathTraceKernel_data_init, + start_arg_index, dPdu_sd, dPdu_sd_DL_shadow, dPdv_sd, - dPdv_sd_DL_shadow, -#endif + dPdv_sd_DL_shadow); + + /* Object motion. */ + start_arg_index += + kernel_set_args(ckPathTraceKernel_data_init, + start_arg_index, + ob_tfm_sd, + ob_tfm_sd_DL_shadow, + ob_itfm_sd, + ob_itfm_sd_DL_shadow); + + start_arg_index += + kernel_set_args(ckPathTraceKernel_data_init, + start_arg_index, closure_sd, closure_sd_DL_shadow, num_closure_sd, diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 1fed33f493e..519ff94d647 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -192,7 +192,7 @@ if(WITH_CYCLES_CUDA_BINARIES) macro(CYCLES_CUDA_KERNEL_ADD arch experimental) if(${experimental}) - set(cuda_extra_flags "-D__KERNEL_CUDA_EXPERIMENTAL__") + set(cuda_extra_flags "-D__KERNEL_EXPERIMENTAL__") set(cuda_cubin kernel_experimental_${arch}.cubin) else() set(cuda_extra_flags "") diff --git a/intern/cycles/kernel/SConscript b/intern/cycles/kernel/SConscript index c0d969e24ae..24cc4517eaf 100644 --- a/intern/cycles/kernel/SConscript +++ b/intern/cycles/kernel/SConscript @@ -87,7 +87,7 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']: last_cubin_file = None configs = (("kernel_%s.cubin", ''), - ("kernel_experimental_%s.cubin", ' -D__KERNEL_CUDA_EXPERIMENTAL__')) + ("kernel_experimental_%s.cubin", ' -D__KERNEL_EXPERIMENTAL__')) # add command for each cuda architecture for arch in cuda_archs: diff --git a/intern/cycles/kernel/geom/geom_triangle_intersect.h b/intern/cycles/kernel/geom/geom_triangle_intersect.h index 49f475e3679..d6e4abc8267 100644 --- a/intern/cycles/kernel/geom/geom_triangle_intersect.h +++ b/intern/cycles/kernel/geom/geom_triangle_intersect.h @@ -50,7 +50,7 @@ typedef struct IsectPrecalc { } IsectPrecalc; /* Workaround for CUDA toolkit 6.5.16. */ -#if defined(__KERNEL_CPU__) || !defined(__KERNEL_CUDA_EXPERIMENTAL__) || __CUDA_ARCH__ < 500 +#if defined(__KERNEL_CPU__) || !defined(__KERNEL_EXPERIMENTAL__) || __CUDA_ARCH__ < 500 # if (defined(i386) || defined(_M_IX86)) ccl_device_noinline # else diff --git a/intern/cycles/kernel/kernel.cl b/intern/cycles/kernel/kernel.cl index 19e394936ee..cbc0592fe1f 100644 --- a/intern/cycles/kernel/kernel.cl +++ b/intern/cycles/kernel/kernel.cl @@ -102,8 +102,19 @@ __kernel void kernel_ocl_bake( int x = sx + get_global_id(0); - if(x < sx + sw) + if(x < sx + sw) { +#if defined(__KERNEL_OPENCL_NVIDIA__) && __COMPUTE_CAPABILITY__ < 300 + /* NVidia compiler is spending infinite amount of time trying + * to deal with kernel_bake_evaluate() on architectures prior + * to sm_30. + * For now we disable baking kernel for those devices, so at + * least rendering with split kernel could be compiled. + */ + output[x] = make_float4(0.0f, 0.0f, 0.0f, 0.0f); +#else kernel_bake_evaluate(kg, input, output, (ShaderEvalType)type, x, offset, sample); +#endif + } } __kernel void kernel_ocl_convert_to_byte( diff --git a/intern/cycles/kernel/kernel_data_init.cl b/intern/cycles/kernel/kernel_data_init.cl index dbf9e62ccbf..4c5f08639dd 100644 --- a/intern/cycles/kernel/kernel_data_init.cl +++ b/intern/cycles/kernel/kernel_data_init.cl @@ -100,7 +100,8 @@ __kernel void kernel_ocl_path_trace_data_initialization( ccl_global int *transparent_depth_sd, ccl_global int *transparent_depth_sd_DL_shadow, - #ifdef __RAY_DIFFERENTIALS__ + + /* Ray differentials. */ ccl_global differential3 *dP_sd, ccl_global differential3 *dP_sd_DL_shadow, @@ -112,14 +113,21 @@ __kernel void kernel_ocl_path_trace_data_initialization( ccl_global differential *dv_sd, ccl_global differential *dv_sd_DL_shadow, - #endif - #ifdef __DPDU__ + + /* Dp/Du */ ccl_global float3 *dPdu_sd, ccl_global float3 *dPdu_sd_DL_shadow, ccl_global float3 *dPdv_sd, ccl_global float3 *dPdv_sd_DL_shadow, - #endif + + /* Object motion. */ + ccl_global Transform *ob_tfm_sd, + ccl_global Transform *ob_tfm_sd_DL_shadow, + + ccl_global Transform *ob_itfm_sd, + ccl_global Transform *ob_itfm_sd_DL_shadow, + ShaderClosure *closure_sd, ShaderClosure *closure_sd_DL_shadow, @@ -248,6 +256,14 @@ __kernel void kernel_ocl_path_trace_data_initialization( #endif #endif +#ifdef __OBJECT_MOTION__ + sd->ob_tfm = ob_tfm_sd; + sd_DL_shadow->ob_tfm = ob_tfm_sd_DL_shadow; + + sd->ob_itfm = ob_itfm_sd; + sd_DL_shadow->ob_itfm = ob_itfm_sd_DL_shadow; +#endif + sd->closure = closure_sd; sd_DL_shadow->closure = closure_sd_DL_shadow; diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 3d9d483c651..bae7460a357 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -84,7 +84,7 @@ CCL_NAMESPACE_BEGIN #define __VOLUME_SCATTER__ /* Experimental on GPU */ -#ifdef __KERNEL_CUDA_EXPERIMENTAL__ +#ifdef __KERNEL_EXPERIMENTAL__ #define __SUBSURFACE__ #define __CMJ__ #endif @@ -110,6 +110,10 @@ CCL_NAMESPACE_BEGIN # define __LAMP_MIS__ # define __AO__ # define __HAIR__ +# define __CAMERA_MOTION__ +# endif +# ifdef __KERNEL_EXPERIMENTAL__ +# define __CMJ__ # endif #endif @@ -135,21 +139,11 @@ CCL_NAMESPACE_BEGIN #endif #ifdef __KERNEL_OPENCL_INTEL_CPU__ -#define __CL_USE_NATIVE__ -#define __KERNEL_SHADING__ -/* TODO(sergey): Advanced shading code still requires work - * for split kernel. - */ -# ifndef __SPLIT_KERNEL__ -# define __KERNEL_ADV_SHADING__ -# else -# define __MULTI_CLOSURE__ -# define __TRANSPARENT_SHADOWS__ -# define __PASSES__ -# define __BACKGROUND_MIS__ -# define __LAMP_MIS__ -# define __AO__ -# define __HAIR__ +# define __CL_USE_NATIVE__ +# define __KERNEL_SHADING__ +# define __KERNEL_ADV_SHADING__ +# ifdef __KERNEL_EXPERIMENTAL__ +# define __CMJ__ # endif #endif @@ -473,7 +467,7 @@ typedef struct differential { typedef struct Ray { /* TODO(sergey): This is only needed because current AMD - * compilet has hard time bulding the kernel with this + * compiler has hard time building the kernel with this * reshuffle. And at the same time reshuffle will cause * less optimal CPU code in certain places. * diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c index a6e0ca31cf7..e631a4a365d 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@ -1510,8 +1510,8 @@ static void pbvh_bmesh_node_limit_ensure_fast(PBVH *bvh, BMFace **nodeinfo, BBC num_child2--; } - /* at this point, faces should have been split along the array range sequencially, each sequencial - * part belonging to one node only */ + /* at this point, faces should have been split along the array range sequentially, + * each sequential part belonging to one node only */ BLI_assert((num_child1 + num_child2) == node->totface); node->child1 = child1 = BLI_memarena_alloc(arena, sizeof(FastNodeBuildInfo)); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index d5454bac535..81cc55f754d 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -139,8 +139,8 @@ static void sound_sync_callback(void *data, int mode, float time) BKE_sound_play_scene(scene); else BKE_sound_stop_scene(scene); - if (scene->sound_scene_handle) - AUD_seek(scene->sound_scene_handle, time); + if (scene->playback_handle) + AUD_seek(scene->playback_handle, time); } scene = scene->id.next; } @@ -383,15 +383,15 @@ void BKE_sound_create_scene(struct Scene *scene) scene->sound_scene = AUD_createSequencer(FPS, scene->audio.flag & AUDIO_MUTE); AUD_updateSequencerData(scene->sound_scene, scene->audio.speed_of_sound, scene->audio.doppler_factor, scene->audio.distance_model); - scene->sound_scene_handle = NULL; + scene->playback_handle = NULL; scene->sound_scrub_handle = NULL; scene->speaker_handles = NULL; } void BKE_sound_destroy_scene(struct Scene *scene) { - if (scene->sound_scene_handle) - AUD_stop(scene->sound_scene_handle); + if (scene->playback_handle) + AUD_stop(scene->playback_handle); if (scene->sound_scrub_handle) AUD_stop(scene->sound_scrub_handle); if (scene->sound_scene) @@ -524,13 +524,13 @@ void BKE_sound_update_sequencer(struct Main *main, bSound *sound) static void sound_start_play_scene(struct Scene *scene) { - if (scene->sound_scene_handle) - AUD_stop(scene->sound_scene_handle); + if (scene->playback_handle) + AUD_stop(scene->playback_handle); AUD_setSequencerDeviceSpecs(scene->sound_scene); - if ((scene->sound_scene_handle = AUD_play(scene->sound_scene, 1))) - AUD_setLoop(scene->sound_scene_handle, -1); + if ((scene->playback_handle = AUD_play(scene->sound_scene, 1))) + AUD_setLoop(scene->playback_handle, -1); } void BKE_sound_play_scene(struct Scene *scene) @@ -540,20 +540,20 @@ void BKE_sound_play_scene(struct Scene *scene) AUD_lock(); - status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID; + status = scene->playback_handle ? AUD_getStatus(scene->playback_handle) : AUD_STATUS_INVALID; if (status == AUD_STATUS_INVALID) { sound_start_play_scene(scene); - if (!scene->sound_scene_handle) { + if (!scene->playback_handle) { AUD_unlock(); return; } } if (status != AUD_STATUS_PLAYING) { - AUD_seek(scene->sound_scene_handle, cur_time); - AUD_resume(scene->sound_scene_handle); + AUD_seek(scene->playback_handle, cur_time); + AUD_resume(scene->playback_handle); } if (scene->audio.flag & AUDIO_SYNC) @@ -564,8 +564,8 @@ void BKE_sound_play_scene(struct Scene *scene) void BKE_sound_stop_scene(struct Scene *scene) { - if (scene->sound_scene_handle) { - AUD_pause(scene->sound_scene_handle); + if (scene->playback_handle) { + AUD_pause(scene->playback_handle); if (scene->audio.flag & AUDIO_SYNC) AUD_stopPlayback(); @@ -583,17 +583,17 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene) AUD_lock(); - status = scene->sound_scene_handle ? AUD_getStatus(scene->sound_scene_handle) : AUD_STATUS_INVALID; + status = scene->playback_handle ? AUD_getStatus(scene->playback_handle) : AUD_STATUS_INVALID; if (status == AUD_STATUS_INVALID) { sound_start_play_scene(scene); - if (!scene->sound_scene_handle) { + if (!scene->playback_handle) { AUD_unlock(); return; } - AUD_pause(scene->sound_scene_handle); + AUD_pause(scene->playback_handle); } animation_playing = 0; @@ -606,13 +606,13 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene) if ((scene->audio.flag & AUDIO_SCRUB) && !animation_playing) { if (scene->audio.flag & AUDIO_SYNC) { - AUD_seek(scene->sound_scene_handle, cur_time); - AUD_seekSequencer(scene->sound_scene_handle, cur_time); + AUD_seek(scene->playback_handle, cur_time); + AUD_seekSequencer(scene->playback_handle, cur_time); } else { - AUD_seek(scene->sound_scene_handle, cur_time); + AUD_seek(scene->playback_handle, cur_time); } - AUD_resume(scene->sound_scene_handle); + AUD_resume(scene->playback_handle); if (scene->sound_scrub_handle && AUD_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID) { AUD_seek(scene->sound_scrub_handle, 0); } @@ -620,16 +620,16 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene) if (scene->sound_scrub_handle) { AUD_stop(scene->sound_scrub_handle); } - scene->sound_scrub_handle = AUD_pauseAfter(scene->sound_scene_handle, one_frame); + scene->sound_scrub_handle = AUD_pauseAfter(scene->playback_handle, one_frame); } } else { if (scene->audio.flag & AUDIO_SYNC) { - AUD_seekSequencer(scene->sound_scene_handle, cur_time); + AUD_seekSequencer(scene->playback_handle, cur_time); } else { if (status == AUD_STATUS_PLAYING) { - AUD_seek(scene->sound_scene_handle, cur_time); + AUD_seek(scene->playback_handle, cur_time); } } } @@ -639,11 +639,11 @@ void BKE_sound_seek_scene(struct Main *bmain, struct Scene *scene) float BKE_sound_sync_scene(struct Scene *scene) { - if (scene->sound_scene_handle) { + if (scene->playback_handle) { if (scene->audio.flag & AUDIO_SYNC) - return AUD_getSequencerPosition(scene->sound_scene_handle); + return AUD_getSequencerPosition(scene->playback_handle); else - return AUD_getPosition(scene->sound_scene_handle); + return AUD_getPosition(scene->playback_handle); } return NAN_FLT; } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 0cfb76325fb..3a4b95d8f18 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -301,7 +301,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, float uv[3] = {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */ limit[0] = limit[1] = STD_UV_CONNECT_LIMIT; - /* previous behaviour here is without accounting for winding, however this causes stretching in + /* previous behavior here is without accounting for winding, however this causes stretching in * UV map in really simple cases with mirror + subsurf, see second part of T44530. Also, initially * intention is to treat merged vertices from mirror modifier as seams, see code below with ME_VERT_MERGED * This fixes a very old regression (2.49 was correct here) */ diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 2a69edd47b0..ee2ade51108 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -2633,7 +2633,7 @@ static void bmesh_edge_vert_swap__recursive(BMEdge *e, BMVert *v_dst, BMVert *v_ /** * This function assumes l_sep is apart of a larger fan which has already been - * isolated by calling bmesh_edge_separate to segragate it radially. + * isolated by calling bmesh_edge_separate to segregate it radially. */ BMVert *bmesh_urmv_loop_region(BMesh *bm, BMLoop *l_sep) { diff --git a/source/blender/bmesh/intern/bmesh_walkers.h b/source/blender/bmesh/intern/bmesh_walkers.h index e84880dc61e..1877611d580 100644 --- a/source/blender/bmesh/intern/bmesh_walkers.h +++ b/source/blender/bmesh/intern/bmesh_walkers.h @@ -93,6 +93,11 @@ void BMW_state_remove(BMWalker *walker); void *BMW_walk(BMWalker *walker); void BMW_reset(BMWalker *walker); +#define BMW_ITER(ele, walker, data) \ + for (BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BMW_begin(walker, (BM_CHECK_TYPE_ELEM(data), data)); \ + ele; \ + BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BMW_step(walker)) + /* * example of usage, walking over an island of tool flagged faces: * @@ -109,8 +114,9 @@ void BMW_reset(BMWalker *walker); enum { BMW_VERT_SHELL, + BMW_LOOP_SHELL, BMW_FACE_SHELL, - BMW_LOOP, + BMW_EDGELOOP, BMW_FACELOOP, BMW_EDGERING, BMW_EDGEBOUNDARY, diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index b7bf80b0e3f..1fbfbba5c5e 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -223,6 +223,121 @@ static void *bmw_VertShellWalker_step(BMWalker *walker) /** \} */ +/** \name LoopShell Walker + * \{ + * + * Starts at any element on the mesh and walks over the 'shell' it belongs + * to via visiting connected loops. + * + * \note this is mainly useful to loop over a shell delimited by edges. + */ +static void bmw_LoopShellWalker_visitLoop(BMWalker *walker, BMLoop *l) +{ + BMwLoopShellWalker *shellWalk = NULL; + + if (BLI_gset_haskey(walker->visit_set, l)) { + return; + } + + shellWalk = BMW_state_add(walker); + shellWalk->curloop = l; + BLI_gset_insert(walker->visit_set, l); +} + +static void bmw_LoopShellWalker_begin(BMWalker *walker, void *data) +{ + BMIter iter; + BMHeader *h = data; + + if (UNLIKELY(h == NULL)) { + return; + } + + switch (h->htype) { + case BM_LOOP: + { + /* starting the walk at a vert, add all the edges + * to the worklist */ + BMLoop *l = (BMLoop *)h; + bmw_LoopShellWalker_visitLoop(walker, l); + break; + } + + case BM_VERT: + { + BMVert *v = (BMVert *)h; + BMLoop *l; + BM_ITER_ELEM (l, &iter, v, BM_LOOPS_OF_VERT) { + bmw_LoopShellWalker_visitLoop(walker, l); + } + break; + } + case BM_EDGE: + { + BMEdge *e = (BMEdge *)h; + BMLoop *l; + BM_ITER_ELEM (l, &iter, e, BM_LOOPS_OF_EDGE) { + bmw_LoopShellWalker_visitLoop(walker, l); + } + break; + } + case BM_FACE: + { + BMFace *f = (BMFace *)h; + BMLoop *l = BM_FACE_FIRST_LOOP(f); + /* walker will handle other loops within the face */ + bmw_LoopShellWalker_visitLoop(walker, l); + break; + } + default: + BLI_assert(0); + } +} + +static void *bmw_LoopShellWalker_yield(BMWalker *walker) +{ + BMwLoopShellWalker *shellWalk = BMW_current_state(walker); + return shellWalk->curloop; +} + +static void *bmw_LoopShellWalker_step(BMWalker *walker) +{ + BMwLoopShellWalker *swalk, owalk; + BMLoop *l; + int i; + BMEdge *e_edj_pair[2]; + + BMW_state_remove_r(walker, &owalk); + swalk = &owalk; + + l = swalk->curloop; + bmw_LoopShellWalker_visitLoop(walker, l->next); + bmw_LoopShellWalker_visitLoop(walker, l->prev); + + e_edj_pair[0] = l->e; + e_edj_pair[1] = l->prev->e; + + for (i = 0; i < 2; i++) { + BMEdge *e = e_edj_pair[i]; + if (bmw_mask_check_edge(walker, e)) { + BMLoop *l_iter, *l_first; + + l_iter = l_first = e->l; + do { + BMLoop *l_radial = (l_iter->v == l->v) ? l_iter : l_iter->next; + BLI_assert(l_radial->v == l->v); + if (l != l_radial) { + bmw_LoopShellWalker_visitLoop(walker, l_radial); + } + } while ((l_iter = l_iter->radial_next) != l_first); + } + } + + return l; +} + +/** \} */ + /** \name FaceShell Walker * \{ @@ -543,9 +658,9 @@ static bool bm_edge_is_single(BMEdge *e) (BM_edge_is_boundary(e->l->next->e) || BM_edge_is_boundary(e->l->prev->e))); } -static void bmw_LoopWalker_begin(BMWalker *walker, void *data) +static void bmw_EdgeLoopWalker_begin(BMWalker *walker, void *data) { - BMwLoopWalker *lwalk = NULL, owalk, *owalk_pt; + BMwEdgeLoopWalker *lwalk = NULL, owalk, *owalk_pt; BMEdge *e = data; BMVert *v; const int vert_edge_count[2] = { @@ -593,7 +708,7 @@ static void bmw_LoopWalker_begin(BMWalker *walker, void *data) /* rewind */ while ((owalk_pt = BMW_current_state(walker))) { - owalk = *((BMwLoopWalker *)owalk_pt); + owalk = *((BMwEdgeLoopWalker *)owalk_pt); BMW_walk(walker); } @@ -606,16 +721,16 @@ static void bmw_LoopWalker_begin(BMWalker *walker, void *data) BLI_gset_insert(walker->visit_set, owalk.cur); } -static void *bmw_LoopWalker_yield(BMWalker *walker) +static void *bmw_EdgeLoopWalker_yield(BMWalker *walker) { - BMwLoopWalker *lwalk = BMW_current_state(walker); + BMwEdgeLoopWalker *lwalk = BMW_current_state(walker); return lwalk->cur; } -static void *bmw_LoopWalker_step(BMWalker *walker) +static void *bmw_EdgeLoopWalker_step(BMWalker *walker) { - BMwLoopWalker *lwalk, owalk; + BMwEdgeLoopWalker *lwalk, owalk; BMEdge *e, *nexte = NULL; BMLoop *l; BMVert *v; @@ -1248,6 +1363,16 @@ static BMWalker bmw_VertShellWalker_Type = { BM_EDGE, /* valid restrict masks */ }; +static BMWalker bmw_LoopShellWalker_Type = { + BM_LOOP | BM_VERT | BM_EDGE, + bmw_LoopShellWalker_begin, + bmw_LoopShellWalker_step, + bmw_LoopShellWalker_yield, + sizeof(BMwLoopShellWalker), + BMW_BREADTH_FIRST, + BM_EDGE, /* valid restrict masks */ +}; + static BMWalker bmw_FaceShellWalker_Type = { BM_EDGE, bmw_FaceShellWalker_begin, @@ -1278,12 +1403,12 @@ static BMWalker bmw_IslandWalker_Type = { BM_EDGE | BM_FACE, /* valid restrict masks */ }; -static BMWalker bmw_LoopWalker_Type = { +static BMWalker bmw_EdgeLoopWalker_Type = { BM_EDGE, - bmw_LoopWalker_begin, - bmw_LoopWalker_step, - bmw_LoopWalker_yield, - sizeof(BMwLoopWalker), + bmw_EdgeLoopWalker_begin, + bmw_EdgeLoopWalker_step, + bmw_EdgeLoopWalker_yield, + sizeof(BMwEdgeLoopWalker), BMW_DEPTH_FIRST, 0, /* valid restrict masks */ /* could add flags here but so far none are used */ }; @@ -1340,8 +1465,9 @@ static BMWalker bmw_ConnectedVertexWalker_Type = { BMWalker *bm_walker_types[] = { &bmw_VertShellWalker_Type, /* BMW_VERT_SHELL */ + &bmw_LoopShellWalker_Type, /* BMW_LOOP_SHELL */ &bmw_FaceShellWalker_Type, /* BMW_FACE_SHELL */ - &bmw_LoopWalker_Type, /* BMW_LOOP */ + &bmw_EdgeLoopWalker_Type, /* BMW_EDGELOOP */ &bmw_FaceLoopWalker_Type, /* BMW_FACELOOP */ &bmw_EdgeringWalker_Type, /* BMW_EDGERING */ &bmw_EdgeboundaryWalker_Type, /* BMW_EDGEBOUNDARY */ diff --git a/source/blender/bmesh/intern/bmesh_walkers_private.h b/source/blender/bmesh/intern/bmesh_walkers_private.h index 82d1e760db7..826d2eef1af 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_private.h +++ b/source/blender/bmesh/intern/bmesh_walkers_private.h @@ -45,6 +45,11 @@ typedef struct BMwShellWalker { BMEdge *curedge; } BMwShellWalker; +typedef struct BMwLoopShellWalker { + BMwGenericWalker header; + BMLoop *curloop; +} BMwLoopShellWalker; + typedef struct BMwIslandboundWalker { BMwGenericWalker header; BMLoop *base; @@ -57,14 +62,14 @@ typedef struct BMwIslandWalker { BMFace *cur; } BMwIslandWalker; -typedef struct BMwLoopWalker { +typedef struct BMwEdgeLoopWalker { BMwGenericWalker header; BMEdge *cur, *start; BMVert *lastv, *startv; BMFace *f_hub; bool is_boundary; /* boundary looping changes behavior */ bool is_single; /* single means the edge verts are only connected to 1 face */ -} BMwLoopWalker; +} BMwEdgeLoopWalker; typedef struct BMwFaceLoopWalker { BMwGenericWalker header; diff --git a/source/blender/depsgraph/intern/depsnode.h b/source/blender/depsgraph/intern/depsnode.h index 84554aef7ea..4f3dc3b7303 100644 --- a/source/blender/depsgraph/intern/depsnode.h +++ b/source/blender/depsgraph/intern/depsnode.h @@ -195,7 +195,7 @@ struct IDDepsNode : public DepsNode { int layers; /* Additional flags needed for scene evaluation. - * TODO(sergey): Only needed for until really granual updates + * TODO(sergey): Only needed for until really granular updates * of all the entities. */ int eval_flags; diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index fd7551abab3..d08a32c6e6b 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -3055,7 +3055,7 @@ static bool select_anim_channel_keys(bAnimContext *ac, int channel_index, bool e ANIM_animdata_freelist(&anim_data); /* F-Curve may not have any keyframes */ - if (fcu->bezt) { + if (fcu && fcu->bezt) { BezTriple *bezt; if (!extend) { diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 7d669e8c93e..d5945425576 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -389,7 +389,8 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short flag return 1.0f; } -static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prevfra) { +static bool find_prev_next_keyframes(struct bContext *C, int *nextfra, int *prevfra) +{ Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); bGPdata *gpd = CTX_data_gpencil_data(C); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 01736a272ae..a57352d1039 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -9104,6 +9104,9 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo block = ar->uiblocks.first; but = ui_but_find_active_in_region(ar); + + BLI_assert(but); + data = but->active; submenu = data->menu; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 95fca10d60b..4b0585c34b3 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1215,7 +1215,6 @@ static void ui_panel_drag_collapse(bContext *C, uiPanelDragCollapseHandle *dragc rect.ymin = rect.ymax; rect.ymax = rect.ymin + PNL_HEADER; if (pa->flag & PNL_CLOSEDX) { - rect.xmin = rect.xmin; rect.xmax = rect.xmin + PNL_HEADER; } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 9f5aa37351a..3f0dac5f872 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1427,7 +1427,8 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, if (down || top) { if (dir1 == UI_DIR_UP && top == 0) dir1 = UI_DIR_DOWN; if (dir1 == UI_DIR_DOWN && down == 0) dir1 = UI_DIR_UP; - if (dir2 == UI_DIR_UP && top == 0) dir2 = UI_DIR_DOWN; + BLI_assert(dir2 != UI_DIR_UP); +// if (dir2 == UI_DIR_UP && top == 0) dir2 = UI_DIR_DOWN; if (dir2 == UI_DIR_DOWN && down == 0) dir2 = UI_DIR_UP; } diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 2f46c0906ae..4b683f3fcc2 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -323,10 +323,14 @@ void UI_fontstyle_draw_simple_backdrop( /* XXX: read a style configure */ uiStyle *UI_style_get(void) { +#if 0 uiStyle *style = NULL; /* offset is two struct uiStyle pointers */ - /* style = BLI_findstring(&U.uistyles, "Unifont Style", sizeof(style) * 2) */; + style = BLI_findstring(&U.uistyles, "Unifont Style", sizeof(style) * 2); return (style != NULL) ? style : U.uistyles.first; +#else + return U.uistyles.first; +#endif } /* for drawing, scaled with DPI setting */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index c5b48298858..cf5d504ff6e 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -3219,7 +3219,7 @@ void uiTemplateList( /* add scrollbar */ if (len > layoutdata.visual_items) { - col = uiLayoutColumn(row, false); + /* col = */ uiLayoutColumn(row, false); uiDefButI(block, UI_BTYPE_SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * dyn_data->visual_height, &ui_list->list_scroll, 0, dyn_data->height - dyn_data->visual_height, dyn_data->visual_height, 0, ""); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 4ce493def5b..93aad7fdfb7 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1454,7 +1454,7 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op) else { for (edindex = 0; edindex < totedgesel; edindex += 1) { eed = edarray[edindex]; - walker_select(em, BMW_LOOP, eed, true); + walker_select(em, BMW_EDGELOOP, eed, true); } EDBM_selectmode_flush(em); } @@ -1512,12 +1512,12 @@ static void mouse_mesh_loop_edge(BMEditMesh *em, BMEdge *eed, bool select, bool { bool edge_boundary = false; - /* cycle between BMW_LOOP / BMW_EDGEBOUNDARY */ + /* cycle between BMW_EDGELOOP / BMW_EDGEBOUNDARY */ if (select_cycle && BM_edge_is_boundary(eed)) { int tot[2]; /* if the loops selected toggle the boundaries */ - walker_select_count(em, BMW_LOOP, eed, select, false, + walker_select_count(em, BMW_EDGELOOP, eed, select, false, &tot[0], &tot[1]); if (tot[select] == 0) { edge_boundary = true; @@ -1539,7 +1539,7 @@ static void mouse_mesh_loop_edge(BMEditMesh *em, BMEdge *eed, bool select, bool walker_select(em, BMW_EDGEBOUNDARY, eed, select); } else { - walker_select(em, BMW_LOOP, eed, select); + walker_select(em, BMW_EDGELOOP, eed, select); } } @@ -2353,7 +2353,6 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) BMEditMesh *em = BKE_editmesh_from_object(obedit); BMesh *bm = em->bm; BMIter iter; - BMEdge *e; BMWalker walker; int limit; @@ -2362,63 +2361,136 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op) limit = RNA_boolean_get(op->ptr, "limit"); - if (em->selectmode == SCE_SELECT_FACE) { - BMFace *efa; + if (limit) { + BMEdge *e; + /* grr, shouldn't need to alloc BMO flags here */ + BM_mesh_elem_toolflags_ensure(bm); + if (em->selectmode == SCE_SELECT_FACE) { + BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { + const bool is_walk_ok = ( + BM_elem_flag_test(e, BM_ELEM_SEAM) == 0); - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - BM_elem_flag_set(efa, BM_ELEM_TAG, BM_elem_flag_test(efa, BM_ELEM_SELECT)); + BMO_elem_flag_set(bm, e, BMO_ELE_TAG, is_walk_ok); + } } - - if (limit) { - /* grr, shouldn't need to alloc BMO flags here */ - BM_mesh_elem_toolflags_ensure(bm); + else { + /* don't delimit selected edges in vert/edge mode */ BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - BMO_elem_flag_set(bm, e, BMO_ELE_TAG, !BM_elem_flag_test(e, BM_ELEM_SEAM)); + const bool is_walk_ok = ( + BM_elem_flag_test(e, BM_ELEM_SEAM) == 0 || + BM_elem_flag_test(e, BM_ELEM_SELECT)); + + BMO_elem_flag_set(bm, e, BMO_ELE_TAG, is_walk_ok); } } + } - BMW_init(&walker, bm, BMW_ISLAND, + if (em->selectmode & SCE_SELECT_VERTEX) { + BMVert *v; + + BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { + BM_elem_flag_set(v, BM_ELEM_TAG, BM_elem_flag_test(v, BM_ELEM_SELECT)); + } + + BMW_init(&walker, em->bm, limit ? BMW_LOOP_SHELL : BMW_VERT_SHELL, BMW_MASK_NOP, limit ? BMO_ELE_TAG : BMW_MASK_NOP, BMW_MASK_NOP, BMW_FLAG_TEST_HIDDEN, BMW_NIL_LAY); - BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - if (BM_elem_flag_test(efa, BM_ELEM_TAG)) { - for (efa = BMW_begin(&walker, efa); efa; efa = BMW_step(&walker)) { - BM_face_select_set(bm, efa, true); - BM_elem_flag_disable(efa, BM_ELEM_TAG); + if (limit) { + BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { + if (BM_elem_flag_test(v, BM_ELEM_TAG)) { + BMLoop *l_walk; + BMW_ITER (l_walk, &walker, v) { + BM_vert_select_set(em->bm, l_walk->v, true); + BM_elem_flag_disable(l_walk->v, BM_ELEM_TAG); + } } } } + else { + BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { + if (BM_elem_flag_test(v, BM_ELEM_TAG)) { + BMEdge *e_walk; + BMW_ITER (e_walk, &walker, v) { + BM_edge_select_set(em->bm, e_walk, true); + BM_elem_flag_disable(e_walk, BM_ELEM_TAG); + } + } + } + } + BMW_end(&walker); + EDBM_selectmode_flush(em); + } + else if (em->selectmode & SCE_SELECT_EDGE) { + BMEdge *e; + + BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { + BM_elem_flag_set(e, BM_ELEM_TAG, BM_elem_flag_test(e, BM_ELEM_SELECT)); + } + + BMW_init(&walker, em->bm, limit ? BMW_LOOP_SHELL : BMW_VERT_SHELL, + BMW_MASK_NOP, limit ? BMO_ELE_TAG : BMW_MASK_NOP, BMW_MASK_NOP, + BMW_FLAG_TEST_HIDDEN, + BMW_NIL_LAY); + if (limit) { - BM_mesh_elem_toolflags_clear(bm); + BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e, BM_ELEM_TAG)) { + BMLoop *l_walk; + BMW_ITER (l_walk, &walker, e) { + BM_edge_select_set(em->bm, l_walk->e, true); + BM_edge_select_set(em->bm, l_walk->prev->e, true); + BM_elem_flag_disable(l_walk->e, BM_ELEM_TAG); + } + } + } + } + else { + BM_ITER_MESH (e, &iter, em->bm, BM_EDGES_OF_MESH) { + if (BM_elem_flag_test(e, BM_ELEM_TAG)) { + BMEdge *e_walk; + BMW_ITER (e_walk, &walker, e) { + BM_edge_select_set(em->bm, e_walk, true); + BM_elem_flag_disable(e_walk, BM_ELEM_TAG); + } + } + } } + + BMW_end(&walker); + + EDBM_selectmode_flush(em); } else { - BMVert *v; + BMFace *f; - BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { - BM_elem_flag_set(v, BM_ELEM_TAG, BM_elem_flag_test(v, BM_ELEM_SELECT)); + BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { + BM_elem_flag_set(f, BM_ELEM_TAG, BM_elem_flag_test(f, BM_ELEM_SELECT)); } - BMW_init(&walker, em->bm, BMW_VERT_SHELL, - BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP, + BMW_init(&walker, bm, BMW_ISLAND, + BMW_MASK_NOP, limit ? BMO_ELE_TAG : BMW_MASK_NOP, BMW_MASK_NOP, BMW_FLAG_TEST_HIDDEN, BMW_NIL_LAY); - BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(v, BM_ELEM_TAG)) { - for (e = BMW_begin(&walker, v); e; e = BMW_step(&walker)) { - BM_edge_select_set(em->bm, e, true); - BM_elem_flag_disable(e, BM_ELEM_TAG); + BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { + if (BM_elem_flag_test(f, BM_ELEM_TAG)) { + BMFace *f_walk; + BMW_ITER (f_walk, &walker, f) { + BM_face_select_set(bm, f_walk, true); + BM_elem_flag_disable(f_walk, BM_ELEM_TAG); } } } + BMW_end(&walker); + } - EDBM_selectmode_flush(em); + if (limit) { + BM_mesh_elem_toolflags_clear(bm); } WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index e492696a446..541c7f21cdc 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1364,16 +1364,22 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { ar->winrct = *remainder; - if (alignment == RGN_ALIGN_TOP) - ar->winrct.ymin = ar->winrct.ymax; - else if (alignment == RGN_ALIGN_BOTTOM) - ar->winrct.ymax = ar->winrct.ymin; - else if (alignment == RGN_ALIGN_RIGHT) - ar->winrct.xmin = ar->winrct.xmax; - else if (alignment == RGN_ALIGN_LEFT) - ar->winrct.xmax = ar->winrct.xmin; - else /* prevent winrct to be valid */ - ar->winrct.xmax = ar->winrct.xmin; + switch (alignment) { + case RGN_ALIGN_TOP: + ar->winrct.ymin = ar->winrct.ymax; + break; + case RGN_ALIGN_BOTTOM: + ar->winrct.ymax = ar->winrct.ymin; + break; + case RGN_ALIGN_RIGHT: + ar->winrct.xmin = ar->winrct.xmax; + break; + case RGN_ALIGN_LEFT: + default: + /* prevent winrct to be valid */ + ar->winrct.xmax = ar->winrct.xmin; + break; + } } /* restore prev-split exception */ @@ -2263,7 +2269,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rctf rect, int fontid, const bool i static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top) { - char str[MAX_METADATA_STR]; + char str[MAX_METADATA_STR] = ""; short i, count = 0; const float height = BLF_height_max(fontid) + 0.1f * U.widget_unit; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 3a40c300338..6e51d21b8d7 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1750,7 +1750,9 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) newsa = sa; } } - + + BLI_assert(newsa); + if (sa && (sa->spacetype != type)) { newsa->flag |= AREA_FLAG_TEMP_TYPE; } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index d0fd3559534..0f1d04102bb 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -1235,7 +1235,7 @@ static void filelist_from_main(struct FileList *filelist) files = filelist->filelist; - if (!filelist->filter_data.hide_parent) { + if (files && !filelist->filter_data.hide_parent) { memset(&(filelist->filelist[0]), 0, sizeof(struct direntry)); filelist->filelist[0].relname = BLI_strdup(FILENAME_PARENT); filelist->filelist[0].type |= S_IFDIR; @@ -1247,7 +1247,7 @@ static void filelist_from_main(struct FileList *filelist) for (id = lb->first; id; id = id->next) { ok = 1; if (ok) { - if (!filelist->filter_data.hide_dot || id->name[2] != '.') { + if (files && (!filelist->filter_data.hide_dot || id->name[2] != '.')) { memset(files, 0, sizeof(struct direntry)); if (id->lib == NULL) { files->relname = BLI_strdup(id->name + 2); diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 5b0024f81a1..d27ddc99851 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -125,7 +125,7 @@ void ED_node_tag_update_id(ID *id) return; /* TODO(sergey): With the new dependency graph it - * should be just enough to ony tag ntree itself, + * should be just enough to only tag ntree itself, * all the users of this tree will have update * flushed from the tree, */ diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index fa3b0596ea8..59632d19625 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -3424,6 +3424,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in GPUOffScreen *ofs; bool draw_sky = (alpha_mode == R_ADDSKY) && v3d && (v3d->flag3 & V3D_SHOW_WORLD); + if (UNLIKELY(v3d == NULL)) + return NULL; + /* state changes make normal drawing go weird otherwise */ glPushAttrib(GL_LIGHTING_BIT); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 99cfc23a168..fea0984001b 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -1057,8 +1057,6 @@ static void draw_manipulator_rotate( glRotatef(90.0, 1.0, 0.0, 0.0); postOrtho(ortho); } - - if (arcs) glDisable(GL_CLIP_PLANE0); } // donut arcs if (arcs) { diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 182baabe92d..94b609e9b9f 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1423,7 +1423,7 @@ typedef struct Scene { ListBase transform_spaces; void *sound_scene; - void *sound_scene_handle; + void *playback_handle; void *sound_scrub_handle; void *speaker_handles; diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 01db245a22c..c565161eabe 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1173,7 +1173,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA CTX_wm_operator_poll_msg_set(C, NULL); /* dummie test */ - if (ot && C) { + if (ot) { wmWindow *window = CTX_wm_window(C); switch (context) { @@ -2533,7 +2533,7 @@ void wm_event_do_handlers(bContext *C) /* XXX hrmf, this gives reliable previous mouse coord for area change, feels bad? * doing it on ghost queue gives errors when mousemoves go over area borders */ - if (doit && win->screen && win->screen->subwinactive != win->screen->mainwin) { + if (doit && win->screen->subwinactive != win->screen->mainwin) { win->eventstate->prevx = event->x; win->eventstate->prevy = event->y; //printf("win->eventstate->prev = %d %d\n", event->x, event->y); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 0ee1f9f7eeb..c765587b7cb 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -546,7 +546,7 @@ static void wm_keymap_diff(wmKeyMap *diff_km, wmKeyMap *from_km, wmKeyMap *to_km if (to_kmi) { orig_kmi = WM_keymap_item_find_id(orig_km, kmi->id); - if (!orig_kmi) + if (!orig_kmi && addon_km) orig_kmi = wm_keymap_find_item_equals(addon_km, kmi); if (orig_kmi) { diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 061357c3906..66c502cba53 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -222,6 +222,9 @@ typedef struct PlayAnimPict { } PlayAnimPict; static struct ListBase picsbase = {NULL, NULL}; +/* frames in memory - store them here to for easy deallocation later */ +static struct ListBase inmempicsbase = {NULL, NULL}; +static int added_images = 0; static bool fromdisk = false; static double ptottime = 0.0, swaptime = 0.04; @@ -1130,10 +1133,33 @@ static char *wm_main_playanim_intern(int argc, const char **argv) } if (ibuf) { + LinkData *node; #ifdef USE_IMB_CACHE ps.picture->ibuf = ibuf; #endif + /* really basic memory conservation scheme. Keep frames in a fifo queue */ + node = inmempicsbase.last; + + while (added_images > 30) { + PlayAnimPict *pic = (PlayAnimPict *)node->data; + + if (pic->ibuf != ibuf) { + LinkData *node_tmp; + IMB_freeImBuf(pic->ibuf); + pic->ibuf = NULL; + node_tmp = node->prev; + BLI_freelinkN(&inmempicsbase, node); + added_images--; + node = node_tmp; + } + else { + node = node->prev; + } + } + + BLI_addhead(&inmempicsbase, BLI_genericNodeN(ps.picture)); + added_images++; BLI_strncpy(ibuf->name, ps.picture->name, sizeof(ibuf->name)); diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 7ec2673bf1f..8e534ee1821 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -96,18 +96,20 @@ void KX_BlenderMaterial::Initialize( ); Material *ma = data->material; - // Save material data to restore on exit - mSavedData.r = ma->r; - mSavedData.g = ma->g; - mSavedData.b = ma->b; - mSavedData.a = ma->alpha; - mSavedData.specr = ma->specr; - mSavedData.specg = ma->specg; - mSavedData.specb = ma->specb; - mSavedData.spec = ma->spec; - mSavedData.ref = ma->ref; - mSavedData.hardness = ma->har; - mSavedData.emit = ma->emit; + if (ma) { + // Save material data to restore on exit + mSavedData.r = ma->r; + mSavedData.g = ma->g; + mSavedData.b = ma->b; + mSavedData.a = ma->alpha; + mSavedData.specr = ma->specr; + mSavedData.specg = ma->specg; + mSavedData.specb = ma->specb; + mSavedData.spec = ma->spec; + mSavedData.ref = ma->ref; + mSavedData.hardness = ma->har; + mSavedData.emit = ma->emit; + } mMaterial = data; mShader = 0; @@ -140,18 +142,21 @@ void KX_BlenderMaterial::Initialize( KX_BlenderMaterial::~KX_BlenderMaterial() { Material *ma = mMaterial->material; - // Restore Blender material data - ma->r = mSavedData.r; - ma->g = mSavedData.g; - ma->b = mSavedData.b; - ma->alpha = mSavedData.a; - ma->specr = mSavedData.specr; - ma->specg = mSavedData.specg; - ma->specb = mSavedData.specb; - ma->spec = mSavedData.spec; - ma->ref = mSavedData.ref; - ma->har = mSavedData.hardness; - ma->emit = mSavedData.emit; + + if (ma) { + // Restore Blender material data + ma->r = mSavedData.r; + ma->g = mSavedData.g; + ma->b = mSavedData.b; + ma->alpha = mSavedData.a; + ma->specr = mSavedData.specr; + ma->specg = mSavedData.specg; + ma->specb = mSavedData.specb; + ma->spec = mSavedData.spec; + ma->ref = mSavedData.ref; + ma->har = mSavedData.hardness; + ma->emit = mSavedData.emit; + } // cleanup work if (mConstructed) @@ -823,18 +828,34 @@ void KX_BlenderMaterial::UpdateIPO( { // only works one deep now - // GLSL Multitexture Input - mMaterial->material->specr = mMaterial->speccolor[0] = (float)(specrgb)[0]; - mMaterial->material->specg = mMaterial->speccolor[1] = (float)(specrgb)[1]; - mMaterial->material->specb = mMaterial->speccolor[2] = (float)(specrgb)[2]; - mMaterial->material->r = mMaterial->matcolor[0] = (float)(rgba[0]); - mMaterial->material->g = mMaterial->matcolor[1] = (float)(rgba[1]); - mMaterial->material->b = mMaterial->matcolor[2] = (float)(rgba[2]); - mMaterial->material->alpha = mMaterial->alpha = (float)(rgba[3]); - mMaterial->material->har = mMaterial->hard = (float)(hard); - mMaterial->material->emit = mMaterial->emit = (float)(emit); - mMaterial->material->spec = mMaterial->spec_f = (float)(spec); - mMaterial->material->ref = mMaterial->ref = (float)(ref); + // Multitexture Input + mMaterial->speccolor[0] = (float)(specrgb)[0]; + mMaterial->speccolor[1] = (float)(specrgb)[1]; + mMaterial->speccolor[2] = (float)(specrgb)[2]; + mMaterial->matcolor[0] = (float)(rgba[0]); + mMaterial->matcolor[1] = (float)(rgba[1]); + mMaterial->matcolor[2] = (float)(rgba[2]); + mMaterial->alpha = (float)(rgba[3]); + mMaterial->hard = (float)(hard); + mMaterial->emit = (float)(emit); + mMaterial->spec_f = (float)(spec); + mMaterial->ref = (float)(ref); + + Material *ma = mMaterial->material; + if (ma) { + // GLSL Input + ma->specr = (float)(specrgb)[0]; + ma->specg = (float)(specrgb)[1]; + ma->specb = (float)(specrgb)[2]; + ma->r = (float)(rgba[0]); + ma->g = (float)(rgba[1]); + ma->b = (float)(rgba[2]); + ma->alpha = (float)(rgba[3]); + ma->har = (float)(hard); + ma->emit = (float)(emit); + ma->spec = (float)(spec); + ma->ref = (float)(ref); + } } void KX_BlenderMaterial::Replace_IScene(SCA_IScene *val) diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index a460d9bd392..5ec1c2e2846 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -823,38 +823,30 @@ void KX_Scene::DupliGroupRecurse(CValue* obj, int level) // the logic must be replicated first because we need // the new logic bricks before relinking vector<KX_GameObject*>::iterator git; - for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) - { - (*git)->ReParentLogic(); - } - - // relink any pointers as necessary, sort of a temporary solution - for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) - { + for (git = m_logicHierarchicalGameObjects.begin(); git != m_logicHierarchicalGameObjects.end(); ++git) { + KX_GameObject *gameobj = *git; + + gameobj->ReParentLogic(); + + // relink any pointers as necessary, sort of a temporary solution // this will also relink the actuator to objects within the hierarchy - (*git)->Relink(&m_map_gameobject_to_replica); + gameobj->Relink(&m_map_gameobject_to_replica); // add the object in the layer of the parent - (*git)->SetLayer(groupobj->GetLayer()); - } + gameobj->SetLayer(groupobj->GetLayer()); - // replicate crosslinks etc. between logic bricks - for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) - { - ReplicateLogic((*git)); - } + // replicate crosslinks etc. between logic bricks + ReplicateLogic(gameobj); - // now look if object in the hierarchy have dupli group and recurse - for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git) - { + // now look if object in the hierarchy have dupli group and recurse /* Replicate all constraints. */ - if ((*git)->GetPhysicsController()) { - (*git)->GetPhysicsController()->ReplicateConstraints((*git), m_logicHierarchicalGameObjects); - (*git)->ClearConstraints(); + if (gameobj->GetPhysicsController()) { + gameobj->GetPhysicsController()->ReplicateConstraints(gameobj, m_logicHierarchicalGameObjects); + gameobj->ClearConstraints(); } - if ((*git) != groupobj && (*git)->IsDupliGroup()) + if (gameobj != groupobj && gameobj->IsDupliGroup()) // can't instantiate group immediately as it destroys m_logicHierarchicalGameObjects - duplilist.push_back((*git)); + duplilist.push_back(gameobj); } for (git = duplilist.begin(); !(git == duplilist.end()); ++git) |