From 1b4487e813edac9c5b57b6d5c6175c46c4a54b1c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sat, 31 Dec 2011 15:10:38 +0000 Subject: [PATCH 01/18] Fix [#29728] Explode Modifier Causes Crash. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The problem was in fact in recent BLI_edgehash changes: a typo in the new macro EDGE_ORD made v0 > v1, instead of v0 < v1. This caused the bug in explode modifier, which (ab)uses that ordering feature a bit… --- source/blender/blenlib/intern/edgehash.c | 2 +- source/blender/modifiers/intern/MOD_explode.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/blender/blenlib/intern/edgehash.c b/source/blender/blenlib/intern/edgehash.c index b710e5d496d..97eb66eb49a 100644 --- a/source/blender/blenlib/intern/edgehash.c +++ b/source/blender/blenlib/intern/edgehash.c @@ -52,7 +52,7 @@ static unsigned int _ehash_hashsizes[]= { /* ensure v0 is smaller */ #define EDGE_ORD(v0, v1) \ - if (v0 < v1) { \ + if (v0 > v1) { \ v0 ^= v1; \ v1 ^= v0; \ v0 ^= v1; \ diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 5bd38579b67..b18be28ac7f 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -790,8 +790,8 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, /* float timestep; */ int *facepa=emd->facepa; int totdup=0,totvert=0,totface=0,totpart=0; - int i, v, mindex=0; - unsigned int ed_v1, ed_v2; + int i, v; + unsigned int ed_v1, ed_v2, mindex=0; MTFace *mtface = NULL, *mtf; totface= dm->getNumFaces(dm); From b5595298d36a5023cc33ed41463fd6c032f2ec7b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 31 Dec 2011 15:18:13 +0000 Subject: [PATCH 02/18] Cycles code refactoring: change displace kernel into more generic shader evaluate kernel, added background shader evaluate. --- intern/cycles/device/device.cpp | 19 ++++----- intern/cycles/device/device.h | 9 +++-- intern/cycles/device/device_cpu.cpp | 14 +++---- intern/cycles/device/device_cuda.cpp | 25 ++++++------ intern/cycles/device/device_multi.cpp | 4 +- intern/cycles/kernel/kernel.cl | 4 +- intern/cycles/kernel/kernel.cpp | 6 +-- intern/cycles/kernel/kernel.cu | 4 +- intern/cycles/kernel/kernel.h | 6 ++- intern/cycles/kernel/kernel_displace.h | 48 +++++++++++++++++++---- intern/cycles/kernel/kernel_optimized.cpp | 6 +-- intern/cycles/kernel/kernel_types.h | 7 ++++ intern/cycles/render/mesh_displace.cpp | 23 +++++------ 13 files changed, 112 insertions(+), 63 deletions(-) diff --git a/intern/cycles/device/device.cpp b/intern/cycles/device/device.cpp index 6ebc359fdb3..55fc3bacbba 100644 --- a/intern/cycles/device/device.cpp +++ b/intern/cycles/device/device.cpp @@ -38,7 +38,8 @@ CCL_NAMESPACE_BEGIN DeviceTask::DeviceTask(Type type_) : type(type_), x(0), y(0), w(0), h(0), rng_state(0), rgba(0), buffer(0), sample(0), resolution(0), - displace_input(0), displace_offset(0), displace_x(0), displace_w(0) + shader_input(0), shader_output(0), + shader_eval_type(0), shader_x(0), shader_w(0) { } @@ -46,8 +47,8 @@ void DeviceTask::split_max_size(list& tasks, int max_size) { int num; - if(type == DISPLACE) { - num = (displace_w + max_size - 1)/max_size; + if(type == SHADER) { + num = (shader_w + max_size - 1)/max_size; } else { max_size = max(1, max_size/w); @@ -68,17 +69,17 @@ void DeviceTask::split(ThreadQueue& queue, int num) void DeviceTask::split(list& tasks, int num) { - if(type == DISPLACE) { - num = min(displace_w, num); + if(type == SHADER) { + num = min(shader_w, num); for(int i = 0; i < num; i++) { - int tx = displace_x + (displace_w/num)*i; - int tw = (i == num-1)? displace_w - i*(displace_w/num): displace_w/num; + int tx = shader_x + (shader_w/num)*i; + int tw = (i == num-1)? shader_w - i*(shader_w/num): shader_w/num; DeviceTask task = *this; - task.displace_x = tx; - task.displace_w = tw; + task.shader_x = tx; + task.shader_w = tw; tasks.push_back(task); } diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h index a6a81e7b326..af9bb694c1b 100644 --- a/intern/cycles/device/device.h +++ b/intern/cycles/device/device.h @@ -52,7 +52,7 @@ enum MemoryType { class DeviceTask { public: - typedef enum { PATH_TRACE, TONEMAP, DISPLACE } Type; + typedef enum { PATH_TRACE, TONEMAP, SHADER } Type; Type type; int x, y, w, h; @@ -63,9 +63,10 @@ public: int resolution; int offset, stride; - device_ptr displace_input; - device_ptr displace_offset; - int displace_x, displace_w; + device_ptr shader_input; + device_ptr shader_output; + int shader_eval_type; + int shader_x, shader_w; DeviceTask(Type type = PATH_TRACE); diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index a45a4fb69f6..145eab9ff59 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -141,8 +141,8 @@ public: thread_path_trace(task); else if(task.type == DeviceTask::TONEMAP) thread_tonemap(task); - else if(task.type == DeviceTask::DISPLACE) - thread_displace(task); + else if(task.type == DeviceTask::SHADER) + thread_shader(task); tasks.worker_done(); } @@ -207,7 +207,7 @@ public: } } - void thread_displace(DeviceTask& task) + void thread_shader(DeviceTask& task) { #ifdef WITH_OSL if(kernel_osl_use(kg)) @@ -216,8 +216,8 @@ public: #ifdef WITH_OPTIMIZED_KERNEL if(system_cpu_support_optimized()) { - for(int x = task.displace_x; x < task.displace_x + task.displace_w; x++) { - kernel_cpu_optimized_displace(kg, (uint4*)task.displace_input, (float3*)task.displace_offset, x); + for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) { + kernel_cpu_optimized_shader(kg, (uint4*)task.shader_input, (float3*)task.shader_output, task.shader_eval_type, x); if(tasks.worker_cancel()) break; @@ -226,8 +226,8 @@ public: else #endif { - for(int x = task.displace_x; x < task.displace_x + task.displace_w; x++) { - kernel_cpu_displace(kg, (uint4*)task.displace_input, (float3*)task.displace_offset, x); + for(int x = task.shader_x; x < task.shader_x + task.shader_w; x++) { + kernel_cpu_shader(kg, (uint4*)task.shader_input, (float3*)task.shader_output, task.shader_eval_type, x); if(tasks.worker_cancel()) break; diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp index 2a49d4fae4c..3c5aafd3f60 100644 --- a/intern/cycles/device/device_cuda.cpp +++ b/intern/cycles/device/device_cuda.cpp @@ -615,16 +615,16 @@ public: cuda_pop_context(); } - void displace(DeviceTask& task) + void shader(DeviceTask& task) { cuda_push_context(); CUfunction cuDisplace; - CUdeviceptr d_input = cuda_device_ptr(task.displace_input); - CUdeviceptr d_offset = cuda_device_ptr(task.displace_offset); + CUdeviceptr d_input = cuda_device_ptr(task.shader_input); + CUdeviceptr d_offset = cuda_device_ptr(task.shader_output); /* get kernel function */ - cuda_assert(cuModuleGetFunction(&cuDisplace, cuModule, "kernel_cuda_displace")) + cuda_assert(cuModuleGetFunction(&cuDisplace, cuModule, "kernel_cuda_shader")) /* pass in parameters */ int offset = 0; @@ -635,11 +635,14 @@ public: cuda_assert(cuParamSetv(cuDisplace, offset, &d_offset, sizeof(d_offset))) offset += sizeof(d_offset); - int displace_x = task.displace_x; - offset = cuda_align_up(offset, __alignof(displace_x)); + int shader_eval_type = task.shader_eval_type; + offset = cuda_align_up(offset, __alignof(shader_eval_type)); - cuda_assert(cuParamSeti(cuDisplace, offset, task.displace_x)) - offset += sizeof(task.displace_x); + cuda_assert(cuParamSeti(cuDisplace, offset, task.shader_eval_type)) + offset += sizeof(task.shader_eval_type); + + cuda_assert(cuParamSeti(cuDisplace, offset, task.shader_x)) + offset += sizeof(task.shader_x); cuda_assert(cuParamSetSize(cuDisplace, offset)) @@ -649,7 +652,7 @@ public: #else int xthreads = 8; #endif - int xblocks = (task.displace_w + xthreads - 1)/xthreads; + int xblocks = (task.shader_w + xthreads - 1)/xthreads; cuda_assert(cuFuncSetCacheConfig(cuDisplace, CU_FUNC_CACHE_PREFER_L1)) cuda_assert(cuFuncSetBlockShape(cuDisplace, xthreads, 1, 1)) @@ -828,8 +831,8 @@ public: tonemap(task); else if(task.type == DeviceTask::PATH_TRACE) path_trace(task); - else if(task.type == DeviceTask::DISPLACE) - displace(task); + else if(task.type == DeviceTask::SHADER) + shader(task); } void task_wait() diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp index fc5348ad168..7f24e5789cc 100644 --- a/intern/cycles/device/device_multi.cpp +++ b/intern/cycles/device/device_multi.cpp @@ -306,8 +306,8 @@ public: if(task.buffer) subtask.buffer = sub.ptr_map[task.buffer]; if(task.rng_state) subtask.rng_state = sub.ptr_map[task.rng_state]; if(task.rgba) subtask.rgba = sub.ptr_map[task.rgba]; - if(task.displace_input) subtask.displace_input = sub.ptr_map[task.displace_input]; - if(task.displace_offset) subtask.displace_offset = sub.ptr_map[task.displace_offset]; + if(task.shader_input) subtask.shader_input = sub.ptr_map[task.shader_input]; + if(task.shader_output) subtask.shader_output = sub.ptr_map[task.shader_output]; sub.device->task_add(subtask); } diff --git a/intern/cycles/kernel/kernel.cl b/intern/cycles/kernel/kernel.cl index 90eb7a2513f..479cf9b2e64 100644 --- a/intern/cycles/kernel/kernel.cl +++ b/intern/cycles/kernel/kernel.cl @@ -80,10 +80,10 @@ __kernel void kernel_ocl_tonemap( kernel_film_tonemap(kg, rgba, buffer, sample, resolution, x, y, offset, stride); } -/*__kernel void kernel_ocl_displace(__global uint4 *input, __global float3 *offset, int sx) +/*__kernel void kernel_ocl_shader(__global uint4 *input, __global float3 *output, int type, int sx) { int x = sx + get_global_id(0); - kernel_displace(input, offset, x); + kernel_shader_evaluate(input, output, (ShaderEvalType)type, x); }*/ diff --git a/intern/cycles/kernel/kernel.cpp b/intern/cycles/kernel/kernel.cpp index b4c3839dbd0..e66ddd86cd6 100644 --- a/intern/cycles/kernel/kernel.cpp +++ b/intern/cycles/kernel/kernel.cpp @@ -216,11 +216,11 @@ void kernel_cpu_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffer, int sam kernel_film_tonemap(kg, rgba, buffer, sample, resolution, x, y, offset, stride); } -/* Displacement */ +/* Shader Evaluation */ -void kernel_cpu_displace(KernelGlobals *kg, uint4 *input, float3 *offset, int i) +void kernel_cpu_shader(KernelGlobals *kg, uint4 *input, float3 *output, int type, int i) { - kernel_displace(kg, input, offset, i); + kernel_shader_evaluate(kg, input, output, (ShaderEvalType)type, i); } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel.cu b/intern/cycles/kernel/kernel.cu index 71fc7ac3197..c97aeb67548 100644 --- a/intern/cycles/kernel/kernel.cu +++ b/intern/cycles/kernel/kernel.cu @@ -44,10 +44,10 @@ extern "C" __global__ void kernel_cuda_tonemap(uchar4 *rgba, float4 *buffer, int kernel_film_tonemap(NULL, rgba, buffer, sample, resolution, x, y, offset, stride); } -extern "C" __global__ void kernel_cuda_displace(uint4 *input, float3 *offset, int sx) +extern "C" __global__ void kernel_cuda_shader(uint4 *input, float3 *output, int type, int sx) { int x = sx + blockDim.x*blockIdx.x + threadIdx.x; - kernel_displace(NULL, input, offset, x); + kernel_shader_evaluate(NULL, input, output, (ShaderEvalType)type, x); } diff --git a/intern/cycles/kernel/kernel.h b/intern/cycles/kernel/kernel.h index 78247504b39..20d43c91169 100644 --- a/intern/cycles/kernel/kernel.h +++ b/intern/cycles/kernel/kernel.h @@ -40,14 +40,16 @@ void kernel_cpu_path_trace(KernelGlobals *kg, float4 *buffer, unsigned int *rng_ int sample, int x, int y, int offset, int stride); void kernel_cpu_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffer, int sample, int resolution, int x, int y, int offset, int stride); -void kernel_cpu_displace(KernelGlobals *kg, uint4 *input, float3 *offset, int i); +void kernel_cpu_shader(KernelGlobals *kg, uint4 *input, float3 *output, + int type, int i); #ifdef WITH_OPTIMIZED_KERNEL void kernel_cpu_optimized_path_trace(KernelGlobals *kg, float4 *buffer, unsigned int *rng_state, int sample, int x, int y, int offset, int stride); void kernel_cpu_optimized_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffer, int sample, int resolution, int x, int y, int offset, int stride); -void kernel_cpu_optimized_displace(KernelGlobals *kg, uint4 *input, float3 *offset, int i); +void kernel_cpu_optimized_shader(KernelGlobals *kg, uint4 *input, float3 *output, + int type, int i); #endif CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_displace.h b/intern/cycles/kernel/kernel_displace.h index ef6c3810a75..c39e5e43dbb 100644 --- a/intern/cycles/kernel/kernel_displace.h +++ b/intern/cycles/kernel/kernel_displace.h @@ -18,17 +18,51 @@ CCL_NAMESPACE_BEGIN -__device void kernel_displace(KernelGlobals *kg, uint4 *input, float3 *offset, int i) +__device void kernel_shader_evaluate(KernelGlobals *kg, uint4 *input, float3 *output, ShaderEvalType type, int i) { - /* setup shader data */ ShaderData sd; uint4 in = input[i]; - shader_setup_from_displace(kg, &sd, in.x, in.y, __int_as_float(in.z), __int_as_float(in.w)); + float3 out; - /* evaluate */ - float3 P = sd.P; - shader_eval_displacement(kg, &sd); - offset[i] = sd.P - P; + if(type == SHADER_EVAL_DISPLACE) { + /* setup shader data */ + int object = in.x; + int prim = in.y; + float u = __int_as_float(in.z); + float v = __int_as_float(in.w); + + shader_setup_from_displace(kg, &sd, object, prim, u, v); + + /* evaluate */ + float3 P = sd.P; + shader_eval_displacement(kg, &sd); + out = sd.P - P; + } + else { // SHADER_EVAL_BACKGROUND + /* setup ray */ + Ray ray; + + ray.P = make_float3(0.0f, 0.0f, 0.0f); + ray.D = make_float3(__int_as_float(in.x), __int_as_float(in.y), __int_as_float(in.z)); + ray.t = 0.0f; + +#ifdef __RAY_DIFFERENTIALS__ + ray.dD.dx = make_float3(0.0f, 0.0f, 0.0f); + ray.dD.dy = make_float3(0.0f, 0.0f, 0.0f); + ray.dP.dx = make_float3(0.0f, 0.0f, 0.0f); + ray.dP.dy = make_float3(0.0f, 0.0f, 0.0f); +#endif + + /* setup shader data */ + shader_setup_from_background(kg, &sd, &ray); + + /* evaluate */ + int flag = 0; /* we can't know which type of BSDF this is for */ + out = shader_eval_background(kg, &sd, flag); + } + + /* write output */ + output[i] = out; } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_optimized.cpp b/intern/cycles/kernel/kernel_optimized.cpp index ea43e01ab58..c437e06adfa 100644 --- a/intern/cycles/kernel/kernel_optimized.cpp +++ b/intern/cycles/kernel/kernel_optimized.cpp @@ -47,11 +47,11 @@ void kernel_cpu_optimized_tonemap(KernelGlobals *kg, uchar4 *rgba, float4 *buffe kernel_film_tonemap(kg, rgba, buffer, sample, resolution, x, y, offset, stride); } -/* Displacement */ +/* Shader Evaluate */ -void kernel_cpu_optimized_displace(KernelGlobals *kg, uint4 *input, float3 *offset, int i) +void kernel_cpu_optimized_shader(KernelGlobals *kg, uint4 *input, float3 *output, int type, int i) { - kernel_displace(kg, input, offset, i); + kernel_shader_evaluate(kg, input, output, (ShaderEvalType)type, i); } CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 56db4d2b78a..2c03a34df1f 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -78,6 +78,13 @@ CCL_NAMESPACE_BEGIN //#define __MODIFY_TP__ //#define __QBVH__ +/* Shader Evaluation */ + +enum ShaderEvalType { + SHADER_EVAL_DISPLACE, + SHADER_EVAL_BACKGROUND +}; + /* Path Tracing */ enum PathTraceDimension { diff --git a/intern/cycles/render/mesh_displace.cpp b/intern/cycles/render/mesh_displace.cpp index e86bea59ec1..f0ddf4e8d7b 100644 --- a/intern/cycles/render/mesh_displace.cpp +++ b/intern/cycles/render/mesh_displace.cpp @@ -89,25 +89,26 @@ bool MeshManager::displace(Device *device, Scene *scene, Mesh *mesh, Progress& p return false; /* run device task */ - device_vector d_offset; - d_offset.resize(d_input.size()); + device_vector d_output; + d_output.resize(d_input.size()); device->mem_alloc(d_input, MEM_READ_ONLY); device->mem_copy_to(d_input); - device->mem_alloc(d_offset, MEM_WRITE_ONLY); + device->mem_alloc(d_output, MEM_WRITE_ONLY); - DeviceTask task(DeviceTask::DISPLACE); - task.displace_input = d_input.device_pointer; - task.displace_offset = d_offset.device_pointer; - task.displace_x = 0; - task.displace_w = d_input.size(); + DeviceTask task(DeviceTask::SHADER); + task.shader_input = d_input.device_pointer; + task.shader_output = d_output.device_pointer; + task.shader_eval_type = SHADER_EVAL_DISPLACE; + task.shader_x = 0; + task.shader_w = d_input.size(); device->task_add(task); device->task_wait(); - device->mem_copy_from(d_offset, 0, sizeof(float3)*d_offset.size()); + device->mem_copy_from(d_output, 0, sizeof(float3)*d_output.size()); device->mem_free(d_input); - device->mem_free(d_offset); + device->mem_free(d_output); if(progress.get_cancel()) return false; @@ -117,7 +118,7 @@ bool MeshManager::displace(Device *device, Scene *scene, Mesh *mesh, Progress& p done.resize(mesh->verts.size(), false); int k = 0; - float3 *offset = (float3*)d_offset.data_pointer; + float3 *offset = (float3*)d_output.data_pointer; for(size_t i = 0; i < mesh->triangles.size(); i++) { Mesh::Triangle t = mesh->triangles[i]; From 28e658a3862c0e21e0b8a2cf14184065dfa97112 Mon Sep 17 00:00:00 2001 From: Alexander Kuznetsov Date: Sat, 31 Dec 2011 17:15:47 +0000 Subject: [PATCH 03/18] Openexr path change for scons (win) --- build_files/scons/config/win32-vc-config.py | 2 +- build_files/scons/config/win64-vc-config.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build_files/scons/config/win32-vc-config.py b/build_files/scons/config/win32-vc-config.py index 097740c4b85..07cd30b7ee1 100644 --- a/build_files/scons/config/win32-vc-config.py +++ b/build_files/scons/config/win32-vc-config.py @@ -57,7 +57,7 @@ WITH_BF_STATICOPENEXR = False BF_OPENEXR = LIBDIR + '/openexr' BF_OPENEXR_INC = '${BF_OPENEXR}/include ${BF_OPENEXR}/include/IlmImf ${BF_OPENEXR}/include/Iex ${BF_OPENEXR}/include/Imath ' BF_OPENEXR_LIB = ' Iex Half IlmImf Imath IlmThread ' -BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib_vs2008' +BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib' # Warning, this static lib configuration is untested! users of this OS please confirm. BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a' diff --git a/build_files/scons/config/win64-vc-config.py b/build_files/scons/config/win64-vc-config.py index f502d3ac360..2e7ea6d0034 100644 --- a/build_files/scons/config/win64-vc-config.py +++ b/build_files/scons/config/win64-vc-config.py @@ -61,7 +61,7 @@ WITH_BF_STATICOPENEXR = False BF_OPENEXR = LIBDIR + '/openexr' BF_OPENEXR_INC = '${BF_OPENEXR}/include ${BF_OPENEXR}/include/IlmImf ${BF_OPENEXR}/include/Iex ${BF_OPENEXR}/include/Imath ' BF_OPENEXR_LIB = ' Iex Half IlmImf Imath IlmThread ' -BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib_vs2008' +BF_OPENEXR_LIBPATH = '${BF_OPENEXR}/lib' # Warning, this static lib configuration is untested! users of this OS please confirm. BF_OPENEXR_LIB_STATIC = '${BF_OPENEXR}/lib/libHalf.a ${BF_OPENEXR}/lib/libIlmImf.a ${BF_OPENEXR}/lib/libIex.a ${BF_OPENEXR}/lib/libImath.a ${BF_OPENEXR}/lib/libIlmThread.a' From 6a1643ec1251adb1be06a250798987cbbe18d7fd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Jan 2012 04:37:08 +0000 Subject: [PATCH 04/18] initial rna <> xml module, copied from dump_rna2xml.py, not yet functional --- release/scripts/modules/rna_xml.py | 185 +++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 release/scripts/modules/rna_xml.py diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py new file mode 100644 index 00000000000..b36d433f87b --- /dev/null +++ b/release/scripts/modules/rna_xml.py @@ -0,0 +1,185 @@ +# ***** 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 ***** + +# + + +import bpy + +# easier to read +PRETTY_INTEND = True + +invalid_classes = ( + bpy.types.Operator, + bpy.types.Panel, + bpy.types.KeyingSet, + bpy.types.Header, + ) + + +def build_property_typemap(): + + property_typemap = {} + + for attr in dir(bpy.types): + cls = getattr(bpy.types, attr) + if issubclass(cls, invalid_classes): + continue + + properties = cls.bl_rna.properties.keys() + properties.remove("rna_type") + property_typemap[attr] = properties + + return property_typemap + + +def print_ln(data): + print(data, end="") + + +def rna2xml(fw=print_ln, ident_val=" "): + from xml.sax.saxutils import quoteattr + property_typemap = build_property_typemap() + + def rna2xml_node(ident, value, parent): + ident_next = ident + ident_val + + # divide into attrs and nodes. + node_attrs = [] + nodes_items = [] + nodes_lists = [] + + value_type = type(value) + + if issubclass(value_type, invalid_classes): + return + + # XXX, fixme, pointcache has eternal nested pointer to its self. + if value == parent: + return + + value_type_name = value_type.__name__ + for prop in property_typemap[value_type_name]: + + subvalue = getattr(value, prop) + subvalue_type = type(subvalue) + + if subvalue_type == int: + node_attrs.append("%s=\"%d\"" % (prop, subvalue)) + elif subvalue_type == float: + node_attrs.append("%s=\"%.4g\"" % (prop, subvalue)) + elif subvalue_type == bool: + node_attrs.append("%s=\"%s\"" % (prop, "TRUE" if subvalue else "FALSE")) + elif subvalue_type is str: + node_attrs.append("%s=%s" % (prop, quoteattr(subvalue))) + elif subvalue_type == set: + node_attrs.append("%s=%s" % (prop, quoteattr("{" + ",".join(list(subvalue)) + "}"))) + elif subvalue is None: + node_attrs.append("%s=\"NONE\"" % prop) + elif issubclass(subvalue_type, bpy.types.ID): + # special case, ID's are always referenced. + node_attrs.append("%s=%s" % (prop, quoteattr(subvalue_type.__name__ + ":" + subvalue.name))) + else: + try: + subvalue_ls = list(subvalue) + except: + subvalue_ls = None + + if subvalue_ls is None: + nodes_items.append((prop, subvalue, subvalue_type)) + else: + # check if the list contains native types + subvalue_rna = value.path_resolve(prop, False) + if type(subvalue_rna).__name__ == "bpy_prop_array": + # TODO, multi-dim! + def str_recursive(s): + if type(s) in (int, float, bool): + return str(s) + else: + return " ".join([str_recursive(si) for si in s]) + + node_attrs.append("%s=\"%s\"" % (prop, " ".join(str_recursive(v) for v in subvalue_rna))) + else: + nodes_lists.append((prop, subvalue_ls, subvalue_type)) + + # declare + attributes + if PRETTY_INTEND: + tmp_str = "<%s " % value_type_name + tmp_ident = "\n" + ident + (" " * len(tmp_str)) + + fw("%s%s%s>\n" % (ident, tmp_str, tmp_ident.join(node_attrs))) + + del tmp_str + del tmp_ident + else: + fw("%s<%s %s>\n" % (ident, value_type_name, " ".join(node_attrs))) + + + # unique members + for prop, subvalue, subvalue_type in nodes_items: + rna2xml_node(ident_next, subvalue, value) + + # list members + for prop, subvalue, subvalue_type in nodes_lists: + fw("%s<%s>\n" % (ident_next, prop)) + for subvalue_item in subvalue: + if subvalue_item is not None: + rna2xml_node(ident_next + ident_val, subvalue_item, value) + fw("%s\n" % (ident_next, prop)) + + fw("%s\n" % (ident, value_type_name)) + + fw("\n") + for attr in dir(bpy.data): + + # exceptions + if attr.startswith("_"): + continue + elif attr == "window_managers": + continue + + value = getattr(bpy.data, attr) + try: + ls = value[:] + except: + ls = None + + if type(ls) == list: + fw("%s<%s>\n" % (ident_val, attr)) + for blend_id in ls: + rna2xml_node(ident_val + ident_val, blend_id, None) + fw("%s\n" % (ident_val, attr)) + + fw("\n") + + +def main(): + filename = bpy.data.filepath.rstrip(".blend") + ".xml" + file = open(filename, 'w') + rna2xml(file.write) + file.close() + + # read back. + from xml.dom.minidom import parse + xml_nodes = parse(filename) + print("Written:", filename) + +if __name__ == "__main__": + main() From e32e6004e43d22f215cb279de482b655a5007b4f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Jan 2012 08:09:30 +0000 Subject: [PATCH 05/18] add the ability to read from XML into RNA for rna_xml module --- release/scripts/modules/rna_xml.py | 212 +++++++++++++++++++++-------- 1 file changed, 153 insertions(+), 59 deletions(-) diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py index b36d433f87b..80c663de33e 100644 --- a/release/scripts/modules/rna_xml.py +++ b/release/scripts/modules/rna_xml.py @@ -20,27 +20,16 @@ # - import bpy -# easier to read -PRETTY_INTEND = True -invalid_classes = ( - bpy.types.Operator, - bpy.types.Panel, - bpy.types.KeyingSet, - bpy.types.Header, - ) - - -def build_property_typemap(): +def build_property_typemap(skip_classes): property_typemap = {} for attr in dir(bpy.types): cls = getattr(bpy.types, attr) - if issubclass(cls, invalid_classes): + if issubclass(cls, skip_classes): continue properties = cls.bl_rna.properties.keys() @@ -54,9 +43,31 @@ def print_ln(data): print(data, end="") -def rna2xml(fw=print_ln, ident_val=" "): +def rna2xml(fw=print_ln, + root_node="", + root_rna=None, # must be set + root_rna_skip=set(), + ident_val=" ", + skip_classes=(bpy.types.Operator, + bpy.types.Panel, + bpy.types.KeyingSet, + bpy.types.Header, + ), + pretty_format=True, + method='DATA'): + from xml.sax.saxutils import quoteattr - property_typemap = build_property_typemap() + property_typemap = build_property_typemap(skip_classes) + + def number_to_str(val, val_type): + if val_type == int: + return "%d" % val + elif val_type == float: + return "%.6g" % val + elif val_type == bool: + return "TRUE" if val else "FALSE" + else: + raise NotImplemented("this type is not a number %s" % val_type) def rna2xml_node(ident, value, parent): ident_next = ident + ident_val @@ -68,7 +79,7 @@ def rna2xml(fw=print_ln, ident_val=" "): value_type = type(value) - if issubclass(value_type, invalid_classes): + if issubclass(value_type, skip_classes): return # XXX, fixme, pointcache has eternal nested pointer to its self. @@ -81,12 +92,8 @@ def rna2xml(fw=print_ln, ident_val=" "): subvalue = getattr(value, prop) subvalue_type = type(subvalue) - if subvalue_type == int: - node_attrs.append("%s=\"%d\"" % (prop, subvalue)) - elif subvalue_type == float: - node_attrs.append("%s=\"%.4g\"" % (prop, subvalue)) - elif subvalue_type == bool: - node_attrs.append("%s=\"%s\"" % (prop, "TRUE" if subvalue else "FALSE")) + if subvalue_type in (int, bool, float): + node_attrs.append("%s=\"%s\"" % (prop, number_to_str(subvalue, subvalue_type))) elif subvalue_type is str: node_attrs.append("%s=%s" % (prop, quoteattr(subvalue))) elif subvalue_type == set: @@ -95,7 +102,7 @@ def rna2xml(fw=print_ln, ident_val=" "): node_attrs.append("%s=\"NONE\"" % prop) elif issubclass(subvalue_type, bpy.types.ID): # special case, ID's are always referenced. - node_attrs.append("%s=%s" % (prop, quoteattr(subvalue_type.__name__ + ":" + subvalue.name))) + node_attrs.append("%s=%s" % (prop, quoteattr(subvalue_type.__name__ + "::" + subvalue.name))) else: try: subvalue_ls = list(subvalue) @@ -110,8 +117,9 @@ def rna2xml(fw=print_ln, ident_val=" "): if type(subvalue_rna).__name__ == "bpy_prop_array": # TODO, multi-dim! def str_recursive(s): - if type(s) in (int, float, bool): - return str(s) + subsubvalue_type = type(s) + if subsubvalue_type in (int, float, bool): + return number_to_str(s, subsubvalue_type) else: return " ".join([str_recursive(si) for si in s]) @@ -120,21 +128,22 @@ def rna2xml(fw=print_ln, ident_val=" "): nodes_lists.append((prop, subvalue_ls, subvalue_type)) # declare + attributes - if PRETTY_INTEND: + if pretty_format: tmp_str = "<%s " % value_type_name tmp_ident = "\n" + ident + (" " * len(tmp_str)) - + fw("%s%s%s>\n" % (ident, tmp_str, tmp_ident.join(node_attrs))) - + del tmp_str del tmp_ident else: fw("%s<%s %s>\n" % (ident, value_type_name, " ".join(node_attrs))) - # unique members for prop, subvalue, subvalue_type in nodes_items: - rna2xml_node(ident_next, subvalue, value) + fw("%s<%s>\n" % (ident_next, prop)) # XXX, this is awkward, how best to solve? + rna2xml_node(ident_next + ident_val, subvalue, value) + fw("%s\n" % (ident_next, prop)) # XXX, need to check on this. # list members for prop, subvalue, subvalue_type in nodes_lists: @@ -146,40 +155,125 @@ def rna2xml(fw=print_ln, ident_val=" "): fw("%s\n" % (ident, value_type_name)) - fw("\n") - for attr in dir(bpy.data): + # ------------------------------------------------------------------------- + # needs re-workign to be generic - # exceptions - if attr.startswith("_"): - continue - elif attr == "window_managers": - continue + if root_node: + fw("<%s>\n" % root_node) - value = getattr(bpy.data, attr) - try: - ls = value[:] - except: - ls = None + # bpy.data + if method == 'DATA': + for attr in dir(root_rna): - if type(ls) == list: - fw("%s<%s>\n" % (ident_val, attr)) - for blend_id in ls: - rna2xml_node(ident_val + ident_val, blend_id, None) - fw("%s\n" % (ident_val, attr)) + # exceptions + if attr.startswith("_"): + continue + elif attr in root_rna_skip: + continue - fw("\n") + value = getattr(root_rna, attr) + try: + ls = value[:] + except: + ls = None + + if type(ls) == list: + fw("%s<%s>\n" % (ident_val, attr)) + for blend_id in ls: + rna2xml_node(ident_val + ident_val, blend_id, None) + fw("%s\n" % (ident_val, attr)) + # any attribute + elif method == 'ATTR': + rna2xml_node("", root_rna, None) + + if root_node: + fw("\n" % root_node) -def main(): - filename = bpy.data.filepath.rstrip(".blend") + ".xml" - file = open(filename, 'w') - rna2xml(file.write) - file.close() +def xml2rna(root_xml, + root_rna=None, # must be set + ): - # read back. - from xml.dom.minidom import parse - xml_nodes = parse(filename) - print("Written:", filename) + def rna2xml_node(xml_node, value): +# print("evaluating:", xml_node.nodeName) -if __name__ == "__main__": - main() + # --------------------------------------------------------------------- + # Simple attributes + + for attr in xml_node.attributes.keys(): +# print(" ", attr) + subvalue = getattr(value, attr, Ellipsis) + + if subvalue is Ellipsis: + print("%s.%s not found" % (type(value).__name__, attr)) + else: + value_xml = xml_node.attributes[attr].value + + subvalue_type = type(subvalue) + tp_name = 'UNKNOWN' + if subvalue_type == float: + value_xml_coerce = float(value_xml) + tp_name = 'FLOAT' + elif subvalue_type == int: + value_xml_coerce = int(value_xml) + tp_name = 'INT' + elif subvalue_type == bool: + value_xml_coerce = {'TRUE': True, 'FALSE': False}[value_xml] + tp_name = 'BOOL' + elif subvalue_type == str: + value_xml_coerce = value_xml + tp_name = 'STR' + elif hasattr(subvalue, "__len__"): + value_xml_split = value_xml.split() + try: + value_xml_coerce = [int(v) for v in value_xml_split] + except ValueError: + value_xml_coerce = [float(v) for v in value_xml_split] + tp_name = 'ARRAY' + +# print(" %s.%s (%s) --- %s" % (type(value).__name__, attr, tp_name, subvalue_type)) + setattr(value, attr, value_xml_coerce) + + # --------------------------------------------------------------------- + # Complex attributes + for child_xml in xml_node.childNodes: + if child_xml.nodeType == child_xml.ELEMENT_NODE: + # print() + # print(child_xml.nodeName) + subvalue = getattr(value, child_xml.nodeName, None) + if subvalue is not None: + + elems = [] + for child_xml_real in child_xml.childNodes: + if child_xml_real.nodeType == child_xml_real.ELEMENT_NODE: + elems.append(child_xml_real) + del child_xml_real + + if hasattr(subvalue, "__len__"): + # Collection + if len(elems) != len(subvalue): + print("Size Mismatch! collection:", child_xml.nodeName) + else: + for i in range(len(elems)): + child_xml_real = elems[i] + subsubvalue = subvalue[i] + + if child_xml_real is None or subsubvalue is None: + print("None found %s - %d collection:", (child_xml.nodeName, i)) + else: + rna2xml_node(child_xml_real, subsubvalue) + + else: +# print(elems) + + if len(elems) == 1: + # sub node named by its type + child_xml_real, = elems + + # print(child_xml_real, subvalue) + rna2xml_node(child_xml_real, subvalue) + else: + # empty is valid too + pass + + rna2xml_node(root_xml, root_rna) From 418d66242fd00ffdbef5447d055811e5eb1bb46e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Jan 2012 08:12:51 +0000 Subject: [PATCH 06/18] theme import/export - uses generic rna_xml py module. --- release/scripts/startup/bl_operators/wm.py | 60 +++++++++++++++++++ .../scripts/startup/bl_ui/space_userpref.py | 2 + 2 files changed, 62 insertions(+) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index 4f498e72f4b..cf6d62a330b 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -1462,6 +1462,8 @@ class WM_OT_operator_cheat_sheet(Operator): self.report({'INFO'}, "See OperatorList.txt textblock") return {'FINISHED'} +# ----------------------------------------------------------------------------- +# Addon Operators class WM_OT_addon_enable(Operator): "Enable an addon" @@ -1762,3 +1764,61 @@ class WM_OT_addon_expand(Operator): info = addon_utils.module_bl_info(mod) info["show_expanded"] = not info["show_expanded"] return {'FINISHED'} + + +# ----------------------------------------------------------------------------- +# Theme IO +from bpy_extras.io_utils import (ImportHelper, + ExportHelper, + ) + + +class WM_OT_theme_import(Operator, ImportHelper): + bl_idname = "wm.theme_import" + bl_label = "Import Theme" + bl_options = {'REGISTER', 'UNDO'} + + filename_ext = ".xml" + filter_glob = StringProperty(default="*.xml", options={'HIDDEN'}) + + def execute(self, context): + import rna_xml + import xml.dom.minidom + + filepath = self.filepath + + xml_nodes = xml.dom.minidom.parse(filepath) + theme_xml = xml_nodes.getElementsByTagName("Theme")[0] + + # XXX, why always 0?, allow many? + theme = context.user_preferences.themes[0] + + rna_xml.xml2rna(theme_xml, + root_rna=theme, + ) + + return {'FINISHED'} + + +class WM_OT_theme_export(Operator, ExportHelper): + bl_idname = "wm.theme_export" + bl_label = "Export Theme" + + filename_ext = ".xml" + filter_glob = StringProperty(default="*.xml", options={'HIDDEN'}) + + def execute(self, context): + import rna_xml + + filepath = self.filepath + file = open(filepath, 'w', encoding='utf-8') + + # XXX, why always 0?, allow many? + theme = context.user_preferences.themes[0] + + rna_xml.rna2xml(file.write, + root_rna=theme, + method='ATTR', + ) + + return {'FINISHED'} diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index df8c085d77e..09286287541 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -96,6 +96,8 @@ class USERPREF_HT_header(Header): layout.menu("USERPREF_MT_addons_dev_guides") elif userpref.active_section == 'THEMES': layout.operator("ui.reset_default_theme") + layout.operator("wm.theme_import") + layout.operator("wm.theme_export") class USERPREF_PT_tabs(Panel): From c99975e24fe550e46c57639a1f236b89c4745a02 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Jan 2012 08:52:54 +0000 Subject: [PATCH 07/18] pep8 edits --- release/scripts/modules/animsys_refactor.py | 1 + release/scripts/modules/sys_info.py | 2 +- .../bl_operators/object_randomize_transform.py | 2 +- release/scripts/startup/bl_operators/wm.py | 12 ++++++++---- release/scripts/startup/bl_ui/properties_game.py | 10 ++++++---- release/scripts/startup/bl_ui/properties_particle.py | 2 +- release/scripts/startup/bl_ui/space_view3d.py | 2 +- 7 files changed, 19 insertions(+), 12 deletions(-) diff --git a/release/scripts/modules/animsys_refactor.py b/release/scripts/modules/animsys_refactor.py index f97ba3c2a50..8db21e357d9 100644 --- a/release/scripts/modules/animsys_refactor.py +++ b/release/scripts/modules/animsys_refactor.py @@ -38,6 +38,7 @@ class DataPathBuilder(object): """ Dummy class used to parse fcurve and driver data paths. """ __slots__ = ("data_path", ) + def __init__(self, attrs): self.data_path = attrs diff --git a/release/scripts/modules/sys_info.py b/release/scripts/modules/sys_info.py index 64ff1c0f007..10aba96afd0 100644 --- a/release/scripts/modules/sys_info.py +++ b/release/scripts/modules/sys_info.py @@ -99,7 +99,7 @@ def write_sysinfo(op): ffmpeg = bpy.app.ffmpeg if ffmpeg.supported: for lib in ['avcodec', 'avdevice', 'avformat', 'avutil', 'swscale']: - output.write('{}:{}{}\n'.format(lib, " "*(10-len(lib)), + output.write('{}:{}{}\n'.format(lib, " " * (10 - len(lib)), getattr(ffmpeg, lib + '_version_string'))) else: output.write('Blender was built without FFmpeg support\n') diff --git a/release/scripts/startup/bl_operators/object_randomize_transform.py b/release/scripts/startup/bl_operators/object_randomize_transform.py index fa36e48d47b..d3d70f892b8 100644 --- a/release/scripts/startup/bl_operators/object_randomize_transform.py +++ b/release/scripts/startup/bl_operators/object_randomize_transform.py @@ -49,7 +49,7 @@ def randomize_selected(seed, delta, loc, rot, scale, scale_even, scale_min): rotation_mode = obj.rotation_mode if rotation_mode in {'QUATERNION', 'AXIS_ANGLE'}: obj.rotation_mode = 'XYZ' - + if delta: obj.delta_rotation_euler[0] += vec[0] obj.delta_rotation_euler[1] += vec[1] diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index cf6d62a330b..fa3b84ed8d7 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -32,6 +32,7 @@ from rna_prop_ui import rna_idprop_ui_prop_get, rna_idprop_ui_prop_clear import subprocess import os + class MESH_OT_delete_edgeloop(Operator): '''Delete an edge loop by merging the faces on each side to a single face loop''' bl_idname = "mesh.delete_edgeloop" @@ -1176,27 +1177,29 @@ class WM_OT_copy_prev_settings(Operator): return {'CANCELLED'} + class WM_OT_blenderplayer_start(bpy.types.Operator): '''Launch the Blenderplayer with the current blendfile''' bl_idname = "wm.blenderplayer_start" bl_label = "Start" - + blender_bin_path = bpy.app.binary_path blender_bin_dir = os.path.dirname(blender_bin_path) ext = os.path.splitext(blender_bin_path)[-1] player_path = os.path.join(blender_bin_dir, "blenderplayer" + ext) - + def execute(self, context): import sys if sys.platform == "darwin": self.player_path = os.path.join(self.blender_bin_dir, "../../../blenderplayer.app/Contents/MacOS/blenderplayer") - + filepath = bpy.app.tempdir + "game.blend" bpy.ops.wm.save_as_mainfile(filepath=filepath, check_existing=False, copy=True) subprocess.call([self.player_path, filepath]) return {'FINISHED'} + class WM_OT_keyconfig_test(Operator): "Test keyconfig for conflicts" bl_idname = "wm.keyconfig_test" @@ -1462,6 +1465,7 @@ class WM_OT_operator_cheat_sheet(Operator): self.report({'INFO'}, "See OperatorList.txt textblock") return {'FINISHED'} + # ----------------------------------------------------------------------------- # Addon Operators @@ -1809,7 +1813,7 @@ class WM_OT_theme_export(Operator, ExportHelper): def execute(self, context): import rna_xml - + filepath = self.filepath file = open(filepath, 'w', encoding='utf-8') diff --git a/release/scripts/startup/bl_ui/properties_game.py b/release/scripts/startup/bl_ui/properties_game.py index 355a6771022..b7b2acc6b08 100644 --- a/release/scripts/startup/bl_ui/properties_game.py +++ b/release/scripts/startup/bl_ui/properties_game.py @@ -247,6 +247,7 @@ class RenderButtonsPanel(): class RENDER_PT_embedded(RenderButtonsPanel, bpy.types.Panel): bl_label = "Embedded Player" COMPAT_ENGINES = {'BLENDER_GAME'} + def draw(self, context): layout = self.layout @@ -270,17 +271,17 @@ class RENDER_PT_game_player(RenderButtonsPanel, Panel): layout = self.layout gs = context.scene.game_settings - + row = layout.row() row.operator("wm.blenderplayer_start", text="Start") row.prop(gs, "show_fullscreen") - + row = layout.row() row.label(text="Resolution:") row = layout.row(align=True) row.prop(gs, "resolution_x", slider=False, text="X") row.prop(gs, "resolution_y", slider=False, text="Y") - + col = layout.column() col.label(text="Quality:") col = layout.column(align=True) @@ -288,7 +289,6 @@ class RENDER_PT_game_player(RenderButtonsPanel, Panel): col.prop(gs, "frequency", text="Refresh Rate", slider=False) - class RENDER_PT_game_stereo(RenderButtonsPanel, Panel): bl_label = "Stereo" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -476,6 +476,7 @@ class SCENE_PT_game_navmesh(SceneButtonsPanel, Panel): row.prop(rd, "sample_dist") row.prop(rd, "sample_max_error") + class RENDER_PT_game_sound(RenderButtonsPanel, Panel): bl_label = "Sound" COMPAT_ENGINES = {'BLENDER_GAME'} @@ -491,6 +492,7 @@ class RENDER_PT_game_sound(RenderButtonsPanel, Panel): col.prop(scene, "audio_doppler_speed", text="Speed") col.prop(scene, "audio_doppler_factor") + class WorldButtonsPanel(): bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' diff --git a/release/scripts/startup/bl_ui/properties_particle.py b/release/scripts/startup/bl_ui/properties_particle.py index b19cf0032af..5e68351d9e6 100644 --- a/release/scripts/startup/bl_ui/properties_particle.py +++ b/release/scripts/startup/bl_ui/properties_particle.py @@ -85,7 +85,7 @@ class PARTICLE_PT_context_particles(ParticleButtonsPanel, Panel): def draw(self, context): layout = self.layout - + if context.scene.render.engine == "BLENDER_GAME": layout.label("Not available in the Game Engine") return diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 46a569c71d4..84d207f4e45 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -2248,7 +2248,7 @@ class VIEW3D_PT_view3d_meshdisplay(Panel): col.prop(mesh, "show_extra_face_angle") col.prop(mesh, "show_extra_face_area") if bpy.app.debug: - col.prop(mesh, "show_extra_indices") + col.prop(mesh, "show_extra_indices") class VIEW3D_PT_view3d_curvedisplay(Panel): From f01ac19c3c720505b35aca520935845e9c8af862 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Jan 2012 09:19:22 +0000 Subject: [PATCH 08/18] use __func__ for makesrna.c error prints rather then the function name (no functional changes) --- source/blender/makesrna/intern/makesrna.c | 66 ++++++++++++++--------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 90e68058d36..e0771dbedb7 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -484,7 +484,8 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr if(!manualfunc) { if(!dp->dnastructname || !dp->dnaname) { - fprintf(stderr, "rna_def_property_get_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier); + fprintf(stderr, "%s (0): %s.%s has no valid dna info.\n", + __func__, srna->identifier, prop->identifier); DefRNA.error= 1; return NULL; } @@ -495,7 +496,8 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr if(prop->type == PROP_FLOAT) { if(IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0) { if(prop->subtype != PROP_COLOR_GAMMA) { /* colors are an exception. these get translated */ - fprintf(stderr, "rna_def_property_get_func1: %s.%s is a '%s' but wrapped as type '%s'.\n", srna->identifier, prop->identifier, dp->dnatype, RNA_property_typename(prop->type)); + fprintf(stderr, "%s (1): %s.%s is a '%s' but wrapped as type '%s'.\n", + __func__, srna->identifier, prop->identifier, dp->dnatype, RNA_property_typename(prop->type)); DefRNA.error= 1; return NULL; } @@ -503,7 +505,8 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr } else if(prop->type == PROP_INT || prop->type == PROP_BOOLEAN || prop->type == PROP_ENUM) { if(IS_DNATYPE_INT_COMPAT(dp->dnatype) == 0) { - fprintf(stderr, "rna_def_property_get_func2: %s.%s is a '%s' but wrapped as type '%s'.\n", srna->identifier, prop->identifier, dp->dnatype, RNA_property_typename(prop->type)); + fprintf(stderr, "%s (2): %s.%s is a '%s' but wrapped as type '%s'.\n", + __func__, srna->identifier, prop->identifier, dp->dnatype, RNA_property_typename(prop->type)); DefRNA.error= 1; return NULL; } @@ -724,7 +727,8 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr if(!manualfunc) { if(!dp->dnastructname || !dp->dnaname) { if(prop->flag & PROP_EDITABLE) { - fprintf(stderr, "rna_def_property_set_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier); + fprintf(stderr, "%s: %s.%s has no valid dna info.\n", + __func__, srna->identifier, prop->identifier); DefRNA.error= 1; } return NULL; @@ -902,7 +906,8 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA if(prop->type == PROP_STRING) { if(!manualfunc) { if(!dp->dnastructname || !dp->dnaname) { - fprintf(stderr, "rna_def_property_length_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier); + fprintf(stderr, "%s: %s.%s has no valid dna info.\n", + __func__, srna->identifier, prop->identifier); DefRNA.error= 1; return NULL; } @@ -924,7 +929,8 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA else if(prop->type == PROP_COLLECTION) { if(!manualfunc) { if(prop->type == PROP_COLLECTION && (!(dp->dnalengthname || dp->dnalengthfixed)|| !dp->dnaname)) { - fprintf(stderr, "rna_def_property_length_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier); + fprintf(stderr, "%s: %s.%s has no valid dna info.\n", + __func__, srna->identifier, prop->identifier); DefRNA.error= 1; return NULL; } @@ -959,7 +965,8 @@ static char *rna_def_property_begin_func(FILE *f, StructRNA *srna, PropertyRNA * if(!manualfunc) { if(!dp->dnastructname || !dp->dnaname) { - fprintf(stderr, "rna_def_property_begin_func: %s.%s has no valid dna info.\n", srna->identifier, prop->identifier); + fprintf(stderr, "%s: %s.%s has no valid dna info.\n", + __func__, srna->identifier, prop->identifier); DefRNA.error= 1; return NULL; } @@ -1270,7 +1277,8 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp) pprop->get= (void*)rna_def_property_get_func(f, srna, prop, dp, (const char*)pprop->get); pprop->set= (void*)rna_def_property_set_func(f, srna, prop, dp, (const char*)pprop->set); if(!pprop->type) { - fprintf(stderr, "rna_def_property_funcs: %s.%s, pointer must have a struct type.\n", srna->identifier, prop->identifier); + fprintf(stderr, "%s: %s.%s, pointer must have a struct type.\n", + __func__, srna->identifier, prop->identifier); DefRNA.error= 1; } break; @@ -1298,20 +1306,24 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp) if(!(prop->flag & PROP_IDPROPERTY)) { if(!cprop->begin) { - fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a begin function.\n", srna->identifier, prop->identifier); + fprintf(stderr, "%s: %s.%s, collection must have a begin function.\n", + __func__, srna->identifier, prop->identifier); DefRNA.error= 1; } if(!cprop->next) { - fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a next function.\n", srna->identifier, prop->identifier); + fprintf(stderr, "%s: %s.%s, collection must have a next function.\n", + __func__, srna->identifier, prop->identifier); DefRNA.error= 1; } if(!cprop->get) { - fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a get function.\n", srna->identifier, prop->identifier); + fprintf(stderr, "%s: %s.%s, collection must have a get function.\n", + __func__, srna->identifier, prop->identifier); DefRNA.error= 1; } } if(!cprop->item_type) { - fprintf(stderr, "rna_def_property_funcs: %s.%s, collection must have a struct type.\n", srna->identifier, prop->identifier); + fprintf(stderr, "%s: %s.%s, collection must have a struct type.\n", + __func__, srna->identifier, prop->identifier); DefRNA.error= 1; } break; @@ -2136,19 +2148,22 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr if(prop->flag & PROP_ENUM_FLAG) { if(eprop->defaultvalue & ~totflag) { - fprintf(stderr, "rna_generate_structs: %s%s.%s, enum default includes unused bits (%d).\n", srna->identifier, errnest, prop->identifier, eprop->defaultvalue & ~totflag); + fprintf(stderr, "%s: %s%s.%s, enum default includes unused bits (%d).\n", + __func__, srna->identifier, errnest, prop->identifier, eprop->defaultvalue & ~totflag); DefRNA.error= 1; } } else { if(!defaultfound) { - fprintf(stderr, "rna_generate_structs: %s%s.%s, enum default is not in items.\n", srna->identifier, errnest, prop->identifier); + fprintf(stderr, "%s: %s%s.%s, enum default is not in items.\n", + __func__, srna->identifier, errnest, prop->identifier); DefRNA.error= 1; } } } else { - fprintf(stderr, "rna_generate_structs: %s%s.%s, enum must have items defined.\n", srna->identifier, errnest, prop->identifier); + fprintf(stderr, "%s: %s%s.%s, enum must have items defined.\n", + __func__, srna->identifier, errnest, prop->identifier); DefRNA.error= 1; } break; @@ -2262,7 +2277,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr if(prop->arraydimension && prop->totarraylength) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier); else fprintf(f, "NULL\n"); break; - } + } case PROP_FLOAT: { FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop; fprintf(f, "\t%s, %s, %s, %s, %s, ", rna_function_string(fprop->get), rna_function_string(fprop->set), rna_function_string(fprop->getarray), rna_function_string(fprop->setarray), rna_function_string(fprop->range)); @@ -2276,7 +2291,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr if(prop->arraydimension && prop->totarraylength) fprintf(f, "rna_%s%s_%s_default\n", srna->identifier, strnest, prop->identifier); else fprintf(f, "NULL\n"); break; - } + } case PROP_STRING: { StringPropertyRNA *sprop= (StringPropertyRNA*)prop; fprintf(f, "\t%s, %s, %s, %d, ", rna_function_string(sprop->get), rna_function_string(sprop->length), rna_function_string(sprop->set), sprop->maxlength); @@ -2299,7 +2314,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr if(pprop->type) fprintf(f, "&RNA_%s\n", (const char*)pprop->type); else fprintf(f, "NULL\n"); break; - } + } case PROP_COLLECTION: { CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; fprintf(f, "\t%s, %s, %s, %s, %s, %s, %s, %s, ", rna_function_string(cprop->begin), rna_function_string(cprop->next), rna_function_string(cprop->end), rna_function_string(cprop->get), rna_function_string(cprop->length), rna_function_string(cprop->lookupint), rna_function_string(cprop->lookupstring), rna_function_string(cprop->assignint)); @@ -2421,7 +2436,8 @@ static void rna_generate_struct(BlenderRNA *brna, StructRNA *srna, FILE *f) fprintf(f, "\t%s,\n", rna_function_string(srna->idproperties)); if(srna->reg && !srna->refine) { - fprintf(stderr, "rna_generate_struct: %s has a register function, must also have refine function.\n", srna->identifier); + fprintf(stderr, "%s: %s has a register function, must also have refine function.\n", + __func__, srna->identifier); DefRNA.error= 1; } @@ -2841,7 +2857,7 @@ static int rna_preprocess(const char *outfile) file = fopen(deffile, "w"); if(!file) { - printf ("Unable to open file: %s\n", deffile); + fprintf(stderr, "Unable to open file: %s\n", deffile); status = 1; } else { @@ -2869,7 +2885,7 @@ static int rna_preprocess(const char *outfile) file = fopen(deffile, "w"); if(!file) { - printf ("Unable to open file: %s\n", deffile); + fprintf(stderr, "Unable to open file: %s\n", deffile); status = 1; } else { @@ -2898,7 +2914,7 @@ static int rna_preprocess(const char *outfile) file = fopen(deffile, "w"); if(!file) { - printf ("Unable to open file: %s\n", deffile); + fprintf(stderr, "Unable to open file: %s\n", deffile); status = 1; } else { @@ -2928,18 +2944,18 @@ int main(int argc, char **argv) int totblock, return_status = 0; if(argc<2) { - printf("Usage: %s outdirectory/\n", argv[0]); + fprintf(stderr, "Usage: %s outdirectory/\n", argv[0]); return_status = 1; } else { - printf("Running makesrna, program versions %s\n", RNA_VERSION_DATE); + fprintf(stderr, "Running makesrna, program versions %s\n", RNA_VERSION_DATE); makesrna_path= argv[0]; return_status= rna_preprocess(argv[1]); } totblock= MEM_get_memory_blocks_in_use(); if(totblock!=0) { - printf("Error Totblock: %d\n",totblock); + fprintf(stderr, "Error Totblock: %d\n",totblock); MEM_set_error_callback(mem_error_cb); MEM_printmemlist(); } From 2c072d8f85fe38e3188813dd09147d1d32c775b5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Jan 2012 09:39:43 +0000 Subject: [PATCH 09/18] rna api - set hard min/max for colors which are float properties but internally use chars to 0/1. --- source/blender/makesrna/intern/makesrna.c | 8 +++----- source/blender/makesrna/intern/rna_define.c | 6 ++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index e0771dbedb7..0a67aa6e65e 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -448,11 +448,9 @@ static int rna_enum_bitmask(PropertyRNA *prop) static int rna_color_quantize(PropertyRNA *prop, PropertyDefRNA *dp) { - if(prop->type == PROP_FLOAT && (prop->subtype==PROP_COLOR || prop->subtype==PROP_COLOR_GAMMA)) - if(strcmp(dp->dnatype, "float") != 0 && strcmp(dp->dnatype, "double") != 0) - return 1; - - return 0; + return ( (prop->type == PROP_FLOAT) && + (prop->subtype==PROP_COLOR || prop->subtype==PROP_COLOR_GAMMA) && + (IS_DNATYPE_FLOAT_COMPAT(dp->dnatype) == 0) ); } static const char *rna_function_string(void *func) diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index caf43793996..53944f7ec5c 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1628,6 +1628,7 @@ void RNA_def_property_int_sdna(PropertyRNA *prop, const char *structname, const void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, const char *propname) { PropertyDefRNA *dp; + FloatPropertyRNA *fprop= (FloatPropertyRNA*)prop; StructRNA *srna= DefRNA.laststruct; if(!DefRNA.preprocess) { @@ -1652,6 +1653,11 @@ void RNA_def_property_float_sdna(PropertyRNA *prop, const char *structname, cons } } } + + if(dp->dnatype && strcmp(dp->dnatype, "char") == 0) { + fprop->hardmin= fprop->softmin= 0.0f; + fprop->hardmax= fprop->softmax= 1.0f; + } } rna_def_property_sdna(prop, structname, propname); From 5543928aa761f5504ec724585ad875948f72dac6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Jan 2012 10:05:04 +0000 Subject: [PATCH 10/18] rna_xml module - write colors as hexadecimal values, also swap import/export order of key config buttons, since they didnt match other uses where import is first. --- release/scripts/modules/rna_xml.py | 49 +++++++++++++------ .../scripts/startup/bl_ui/space_userpref.py | 2 +- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/release/scripts/modules/rna_xml.py b/release/scripts/modules/rna_xml.py index 80c663de33e..1a0cf4bab9d 100644 --- a/release/scripts/modules/rna_xml.py +++ b/release/scripts/modules/rna_xml.py @@ -47,7 +47,7 @@ def rna2xml(fw=print_ln, root_node="", root_rna=None, # must be set root_rna_skip=set(), - ident_val=" ", + ident_val=" ", skip_classes=(bpy.types.Operator, bpy.types.Panel, bpy.types.KeyingSet, @@ -115,15 +115,29 @@ def rna2xml(fw=print_ln, # check if the list contains native types subvalue_rna = value.path_resolve(prop, False) if type(subvalue_rna).__name__ == "bpy_prop_array": - # TODO, multi-dim! - def str_recursive(s): - subsubvalue_type = type(s) - if subsubvalue_type in (int, float, bool): - return number_to_str(s, subsubvalue_type) - else: - return " ".join([str_recursive(si) for si in s]) + # check if this is a 0-1 color (rgb, rgba) + # in that case write as a hexidecimal + prop_rna = value.bl_rna.properties[prop] + if (prop_rna.subtype == 'COLOR_GAMMA' and + prop_rna.hard_min == 0.0 and + prop_rna.hard_max == 1.0 and + prop_rna.array_length in {3, 4}): + # ----- + # color + array_value = "#" + "".join(("%.2x" % int(v * 255) for v in subvalue_rna)) - node_attrs.append("%s=\"%s\"" % (prop, " ".join(str_recursive(v) for v in subvalue_rna))) + else: + # default + def str_recursive(s): + subsubvalue_type = type(s) + if subsubvalue_type in (int, float, bool): + return number_to_str(s, subsubvalue_type) + else: + return " ".join([str_recursive(si) for si in s]) + + array_value = " ".join(str_recursive(v) for v in subvalue_rna) + + node_attrs.append("%s=\"%s\"" % (prop, array_value)) else: nodes_lists.append((prop, subvalue_ls, subvalue_type)) @@ -224,11 +238,18 @@ def xml2rna(root_xml, value_xml_coerce = value_xml tp_name = 'STR' elif hasattr(subvalue, "__len__"): - value_xml_split = value_xml.split() - try: - value_xml_coerce = [int(v) for v in value_xml_split] - except ValueError: - value_xml_coerce = [float(v) for v in value_xml_split] + if value_xml.startswith("#"): + # read hexidecimal value as float array + value_xml_split = value_xml[1:] + value_xml_coerce = [int(value_xml_split[i:i + 2], 16) / 255 for i in range(0, len(value_xml_split), 2)] + del value_xml_split + else: + value_xml_split = value_xml.split() + try: + value_xml_coerce = [int(v) for v in value_xml_split] + except ValueError: + value_xml_coerce = [float(v) for v in value_xml_split] + del value_xml_split tp_name = 'ARRAY' # print(" %s.%s (%s) --- %s" % (type(value).__name__, attr, tp_name, subvalue_type)) diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 09286287541..046026a3b6e 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -89,8 +89,8 @@ class USERPREF_HT_header(Header): layout.operator_context = 'INVOKE_DEFAULT' if userpref.active_section == 'INPUT': - layout.operator("wm.keyconfig_export") layout.operator("wm.keyconfig_import") + layout.operator("wm.keyconfig_export") elif userpref.active_section == 'ADDONS': layout.operator("wm.addon_install") layout.menu("USERPREF_MT_addons_dev_guides") From 9b45d8acad715061ea66a4c609b368a69d27fdbf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Jan 2012 10:27:53 +0000 Subject: [PATCH 11/18] __func__ define for msvc since its not c99 compat --- source/blender/makesrna/intern/makesrna.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 0a67aa6e65e..dc7400dd9ae 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -43,9 +43,14 @@ #define RNA_VERSION_DATE "FIXME-RNA_VERSION_DATE" #ifdef _WIN32 -#ifndef snprintf -#define snprintf _snprintf +# ifndef snprintf +# define snprintf _snprintf +# endif #endif + +/* so we can use __func__ everywhere */ +#if defined(_MSC_VER) +# define __func__ __FUNCTION__ #endif /* Replace if different */ From a49e80c48a7dc23ac388d7846ef47680e752d2d9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Jan 2012 13:09:58 +0000 Subject: [PATCH 12/18] use `props` all over for operator properties vars --- release/scripts/modules/rna_prop_ui.py | 8 ++-- release/scripts/startup/bl_operators/wm.py | 6 +-- .../startup/bl_ui/properties_object.py | 6 +-- release/scripts/startup/bl_ui/space_image.py | 42 +++++++++---------- release/scripts/startup/bl_ui/space_view3d.py | 18 ++++---- .../startup/bl_ui/space_view3d_toolbar.py | 12 +++--- 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index 388ae2b0e13..32c8ed11bc5 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -145,11 +145,11 @@ def draw(layout, context, context_member, property_type, use_edit=True): if use_edit: row = split.row(align=True) - prop = row.operator("wm.properties_edit", text="edit") - assign_props(prop, val_draw, key) + props = row.operator("wm.properties_edit", text="edit") + assign_props(props, val_draw, key) - prop = row.operator("wm.properties_remove", text="", icon='ZOOMOUT') - assign_props(prop, val_draw, key) + props = row.operator("wm.properties_remove", text="", icon='ZOOMOUT') + assign_props(props, val_draw, key) class PropertyPanel(): diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index fa3b84ed8d7..11326377a79 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -502,9 +502,9 @@ class WM_MT_context_menu_enum(Menu): values = [(i.name, i.identifier) for i in value_base.bl_rna.properties[prop_string].enum_items] for name, identifier in values: - prop = self.layout.operator("wm.context_set_enum", text=name) - prop.data_path = data_path - prop.value = identifier + props = self.layout.operator("wm.context_set_enum", text=name) + props.data_path = data_path + props.value = identifier class WM_OT_context_menu_enum(Operator): diff --git a/release/scripts/startup/bl_ui/properties_object.py b/release/scripts/startup/bl_ui/properties_object.py index 27b6aa721a4..f01c2ba45e0 100644 --- a/release/scripts/startup/bl_ui/properties_object.py +++ b/release/scripts/startup/bl_ui/properties_object.py @@ -181,9 +181,9 @@ class OBJECT_PT_groups(ObjectButtonsPanel, Panel): col = split.column() col.prop(group, "dupli_offset", text="") - prop = col.operator("wm.context_set_value", text="From Cursor") - prop.data_path = "object.users_group[%d].dupli_offset" % index - prop.value = value + props = col.operator("wm.context_set_value", text="From Cursor") + props.data_path = "object.users_group[%d].dupli_offset" % index + props.value = value index += 1 diff --git a/release/scripts/startup/bl_ui/space_image.py b/release/scripts/startup/bl_ui/space_image.py index 81526797109..4ccdef747ce 100644 --- a/release/scripts/startup/bl_ui/space_image.py +++ b/release/scripts/startup/bl_ui/space_image.py @@ -298,34 +298,34 @@ class IMAGE_MT_uvs_select_mode(Menu): # do smart things depending on whether uv_select_sync is on if toolsettings.use_uv_select_sync: - prop = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL') - prop.value = "(True, False, False)" - prop.data_path = "tool_settings.mesh_select_mode" + props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL') + props.value = "(True, False, False)" + props.data_path = "tool_settings.mesh_select_mode" - prop = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL') - prop.value = "(False, True, False)" - prop.data_path = "tool_settings.mesh_select_mode" + props = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL') + props.value = "(False, True, False)" + props.data_path = "tool_settings.mesh_select_mode" - prop = layout.operator("wm.context_set_value", text="Face", icon='FACESEL') - prop.value = "(False, False, True)" - prop.data_path = "tool_settings.mesh_select_mode" + props = layout.operator("wm.context_set_value", text="Face", icon='FACESEL') + props.value = "(False, False, True)" + props.data_path = "tool_settings.mesh_select_mode" else: - prop = layout.operator("wm.context_set_string", text="Vertex", icon='UV_VERTEXSEL') - prop.value = 'VERTEX' - prop.data_path = "tool_settings.uv_select_mode" + props = layout.operator("wm.context_set_string", text="Vertex", icon='UV_VERTEXSEL') + props.value = 'VERTEX' + props.data_path = "tool_settings.uv_select_mode" - prop = layout.operator("wm.context_set_string", text="Edge", icon='UV_EDGESEL') - prop.value = 'EDGE' - prop.data_path = "tool_settings.uv_select_mode" + props = layout.operator("wm.context_set_string", text="Edge", icon='UV_EDGESEL') + props.value = 'EDGE' + props.data_path = "tool_settings.uv_select_mode" - prop = layout.operator("wm.context_set_string", text="Face", icon='UV_FACESEL') - prop.value = 'FACE' - prop.data_path = "tool_settings.uv_select_mode" + props = layout.operator("wm.context_set_string", text="Face", icon='UV_FACESEL') + props.value = 'FACE' + props.data_path = "tool_settings.uv_select_mode" - prop = layout.operator("wm.context_set_string", text="Island", icon='UV_ISLANDSEL') - prop.value = 'ISLAND' - prop.data_path = "tool_settings.uv_select_mode" + props = layout.operator("wm.context_set_string", text="Island", icon='UV_ISLANDSEL') + props.value = 'ISLAND' + props.data_path = "tool_settings.uv_select_mode" class IMAGE_HT_header(Header): diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 84d207f4e45..22d0e39a54b 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -1523,17 +1523,17 @@ class VIEW3D_MT_edit_mesh_select_mode(Menu): layout.operator_context = 'INVOKE_REGION_WIN' - prop = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL') - prop.value = "(True, False, False)" - prop.data_path = "tool_settings.mesh_select_mode" + props = layout.operator("wm.context_set_value", text="Vertex", icon='VERTEXSEL') + props.value = "(True, False, False)" + props.data_path = "tool_settings.mesh_select_mode" - prop = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL') - prop.value = "(False, True, False)" - prop.data_path = "tool_settings.mesh_select_mode" + props = layout.operator("wm.context_set_value", text="Edge", icon='EDGESEL') + props.value = "(False, True, False)" + props.data_path = "tool_settings.mesh_select_mode" - prop = layout.operator("wm.context_set_value", text="Face", icon='FACESEL') - prop.value = "(False, False, True)" - prop.data_path = "tool_settings.mesh_select_mode" + props = layout.operator("wm.context_set_value", text="Face", icon='FACESEL') + props.value = "(False, False, True)" + props.data_path = "tool_settings.mesh_select_mode" class VIEW3D_MT_edit_mesh_extrude(Menu): diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 9644f57d6cd..25f81f2cde1 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1198,9 +1198,9 @@ class VIEW3D_MT_tools_projectpaint_clone(Menu): def draw(self, context): layout = self.layout for i, tex in enumerate(context.active_object.data.uv_textures): - prop = layout.operator("wm.context_set_int", text=tex.name) - prop.data_path = "active_object.data.uv_texture_clone_index" - prop.value = i + props = layout.operator("wm.context_set_int", text=tex.name) + props.data_path = "active_object.data.uv_texture_clone_index" + props.value = i class VIEW3D_MT_tools_projectpaint_stencil(Menu): @@ -1209,9 +1209,9 @@ class VIEW3D_MT_tools_projectpaint_stencil(Menu): def draw(self, context): layout = self.layout for i, tex in enumerate(context.active_object.data.uv_textures): - prop = layout.operator("wm.context_set_int", text=tex.name) - prop.data_path = "active_object.data.uv_texture_stencil_index" - prop.value = i + props = layout.operator("wm.context_set_int", text=tex.name) + props.data_path = "active_object.data.uv_texture_stencil_index" + props.value = i class VIEW3D_PT_tools_particlemode(View3DPanel, Panel): From defa99b65ce56b9c536ce7ade76a0ccfa3b4ceff Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 1 Jan 2012 16:09:32 +0000 Subject: [PATCH 13/18] Fixed names of VertexWeight modifiers RNA structs, in RNA_access.h (probably forgotten when they were renamed, before the merge in trunk, and was never noticed as they are not used...). Also removed the $ID$ from remesh modifier header, and quited a gcc warning. --- source/blender/makesrna/RNA_access.h | 6 +-- source/blender/modifiers/intern/MOD_remesh.c | 45 +++++++++----------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 215c7992ff3..9e708a0a5d7 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -580,9 +580,9 @@ extern StructRNA RNA_VoxelData; extern StructRNA RNA_VoxelDataTexture; extern StructRNA RNA_WarpModifier; extern StructRNA RNA_WaveModifier; -extern StructRNA RNA_WeightVGEditModifier; -extern StructRNA RNA_WeightVGMixModifier; -extern StructRNA RNA_WeightVGProximityModifier; +extern StructRNA RNA_VertexWeightEditModifier; +extern StructRNA RNA_VertexWeightMixModifier; +extern StructRNA RNA_VertexWeightProximityModifier; extern StructRNA RNA_Window; extern StructRNA RNA_WindowManager; extern StructRNA RNA_WipeSequence; diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c index c698985efc3..bc67237fb40 100644 --- a/source/blender/modifiers/intern/MOD_remesh.c +++ b/source/blender/modifiers/intern/MOD_remesh.c @@ -1,27 +1,24 @@ /* -* $Id$ -* -* ***** 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. -* -* The Original Code is Copyright (C) 2011 by Nicholas Bishop. -* -* ***** END GPL LICENSE BLOCK ***** -* -*/ + * ***** 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. + * + * The Original Code is Copyright (C) 2011 by Nicholas Bishop. + * + * ***** END GPL LICENSE BLOCK ***** + */ /** \file blender/modifiers/intern/MOD_remesh.c * \ingroup modifiers @@ -152,7 +149,7 @@ static DerivedMesh *applyModifier(ModifierData *md, DualConInput input; DerivedMesh *result; DualConFlags flags = 0; - DualConMode mode; + DualConMode mode = 0; rmd = (RemeshModifierData*)md; From ab097223d490c07125ba8278ee401ae41811576e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 1 Jan 2012 16:37:01 +0000 Subject: [PATCH 14/18] Fix [#29556] shrinkwrap generates spikes if vertices fall exactly on the edge bvhtree_ray_tri_intersection now using isect_ray_tri_epsilon_v3 with FLT_EPSILON. All devs I asked (incuding ones in physics/painting areas) were rather OK with this change, and better to do it now, with more than one month to detect regressions, if any! --- source/blender/blenkernel/intern/bvhutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 1100c1c0ef5..1aad0a242f9 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -52,7 +52,7 @@ float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_d { float dist; - if(isect_ray_tri_v3(ray->origin, ray->direction, v0, v1, v2, &dist, NULL)) + if(isect_ray_tri_epsilon_v3(ray->origin, ray->direction, v0, v1, v2, &dist, NULL, FLT_EPSILON)) return dist; return FLT_MAX; From 47cb54195dbe5074763ebe02c39c0daeeba1dc0f Mon Sep 17 00:00:00 2001 From: Jens Verwiebe Date: Sun, 1 Jan 2012 16:46:08 +0000 Subject: [PATCH 15/18] OSX: fix compile by conditional unsupported flags --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40a51f0b452..9c0477a9d34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1393,7 +1393,10 @@ if(CMAKE_COMPILER_IS_GNUCC) # disable because it gives warnings for printf() & friends. # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion) - ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable) + + if(NOT APPLE) + ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable) + endif() ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ALL -Wall) ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof) @@ -1405,7 +1408,10 @@ if(CMAKE_COMPILER_IS_GNUCC) # flags to undo strict flags ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations) ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_BUT_SET_VARIABLE -Wno-unused-but-set-variable) + + if(NOT APPLE) + ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_BUT_SET_VARIABLE ) + endif() elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") From ab4a93f2bc02c77ae6e82181dcc71bc04a7a2288 Mon Sep 17 00:00:00 2001 From: Tom Musgrove Date: Sun, 1 Jan 2012 21:19:40 +0000 Subject: [PATCH 16/18] part of line missing in Jens commit, this fixes compile on non Apple platforms, thanks to Lockal in IRC for pointing it out --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c0477a9d34..15a5e9d2744 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1410,7 +1410,7 @@ if(CMAKE_COMPILER_IS_GNUCC) ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter) if(NOT APPLE) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_BUT_SET_VARIABLE ) + ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable) endif() elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") From af54c83d28f5e8fd21d92a577bfad20f97ee75f6 Mon Sep 17 00:00:00 2001 From: Tom Musgrove Date: Sun, 1 Jan 2012 22:23:08 +0000 Subject: [PATCH 17/18] left out one tiny word... --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15a5e9d2744..24a117d6104 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1410,7 +1410,7 @@ if(CMAKE_COMPILER_IS_GNUCC) ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter) if(NOT APPLE) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable) + ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable) endif() elseif(CMAKE_C_COMPILER_ID MATCHES "Intel") From ec710a29297d5fa7c9065760dbef322b02bbec01 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Jan 2012 02:13:31 +0000 Subject: [PATCH 18/18] remove Id's that crept in --- source/blender/editors/space_buttons/buttons_texture.c | 2 -- source/blender/editors/space_node/node_templates.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index c0ccaeaea90..6927a78332f 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 6027a272270..a733d45c20b 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or