[Bf-blender-cvs] [b0cc8e8ddec] master: Cycles: switch from pretabulated 2D PMJ02 to pretabulated 4D Sobol
Commit: b0cc8e8ddec3f1771b69234860b40511be975039 Author: Nathan Vegdahl Date: Tue Dec 13 19:14:29 2022 +0100 Branches: master https://developer.blender.org/rBb0cc8e8ddec3f1771b69234860b40511be975039 Cycles: switch from pretabulated 2D PMJ02 to pretabulated 4D Sobol The first two dimensions of scrambled, shuffled Sobol and shuffled PMJ02 are equivalent, so this makes no real difference for the first two dimensions. But Sobol allows us to naturally extend to more dimensions. Pretabulated Sobol is now always used, and the sampling pattern settings is now only available as a debug option. This in turn allows the following two things (also implemented): * Use proper 3D samples for combined lens + motion blur sampling. This notably reduces the noise on objects that are simultaneously out-of-focus and motion blurred. * Use proper 3D samples for combined light selection + light sampling. Cycles was already doing something clever here with 2D samples, but using 3D samples is more straightforward and avoids overloading one of the dimensions. In the future this will also allow for proper sampling of e.g. volumetric light sources and other things that may need three or four dimensions. Differential Revision: https://developer.blender.org/D16443 === M intern/cycles/blender/addon/properties.py M intern/cycles/blender/addon/ui.py M intern/cycles/blender/addon/version_update.py M intern/cycles/blender/sync.cpp M intern/cycles/kernel/CMakeLists.txt M intern/cycles/kernel/data_arrays.h M intern/cycles/kernel/data_template.h M intern/cycles/kernel/integrator/init_from_camera.h M intern/cycles/kernel/integrator/path_state.h M intern/cycles/kernel/integrator/shade_surface.h M intern/cycles/kernel/integrator/shade_volume.h M intern/cycles/kernel/light/distribution.h M intern/cycles/kernel/light/sample.h M intern/cycles/kernel/light/tree.h D intern/cycles/kernel/sample/jitter.h M intern/cycles/kernel/sample/pattern.h A intern/cycles/kernel/sample/tabulated_sobol.h M intern/cycles/kernel/types.h M intern/cycles/scene/CMakeLists.txt M intern/cycles/scene/integrator.cpp D intern/cycles/scene/jitter.cpp D intern/cycles/scene/jitter.h A intern/cycles/scene/tabulated_sobol.cpp A intern/cycles/scene/tabulated_sobol.h === diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 2da763b9eb1..eff6384c85e 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -82,8 +82,8 @@ enum_use_layer_samples = ( ) enum_sampling_pattern = ( -('SOBOL', "Sobol-Burley", "Use Sobol-Burley random sampling pattern", 0), -('PROGRESSIVE_MULTI_JITTER', "Progressive Multi-Jitter", "Use Progressive Multi-Jitter random sampling pattern", 1), +('SOBOL_BURLEY', "Sobol-Burley", "Use on-the-fly computed Owen-scrambled Sobol for random sampling", 0), +('TABULATED_SOBOL', "Tabulated Sobol", "Use precomputed tables of Owen-scrambled Sobol for random sampling", 1), ) enum_emission_sampling = ( @@ -412,9 +412,9 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): sampling_pattern: EnumProperty( name="Sampling Pattern", -description="Random sampling pattern used by the integrator. When adaptive sampling is enabled, Progressive Multi-Jitter is always used instead of Sobol-Burley", +description="Random sampling pattern used by the integrator", items=enum_sampling_pattern, -default='PROGRESSIVE_MULTI_JITTER', +default='TABULATED_SOBOL', ) scrambling_distance: FloatProperty( diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index c3477ae0284..4746790aae8 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -364,16 +364,13 @@ class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel): row.prop(cscene, "seed") row.prop(cscene, "use_animated_seed", text="", icon='TIME') -col = layout.column(align=True) -col.prop(cscene, "sampling_pattern", text="Pattern") - col = layout.column(align=True) col.prop(cscene, "sample_offset") layout.separator() heading = layout.column(align=True, heading="Scrambling Distance") -heading.active = cscene.sampling_pattern != 'SOBOL' +heading.active = cscene.sampling_pattern != 'TABULATED_SOBOL' heading.prop(cscene, "auto_scrambling_distance", text="Automatic") heading.prop(cscene,
[Bf-blender-cvs] [d9192aaa6d2] master: Cycles: limit the internal sample index of Sobol-Burley for performance
Commit: d9192aaa6d2a0a17bcfe158bade77314f0679cf7 Author: Nathan Vegdahl Date: Wed Dec 14 16:43:12 2022 +0100 Branches: master https://developer.blender.org/rBd9192aaa6d2a0a17bcfe158bade77314f0679cf7 Cycles: limit the internal sample index of Sobol-Burley for performance This is done based on the render sample count so that it doesn't impact sampling quality. It's similar in spirit to the adaptive table size in D16561, but in this case for performance rather than memory usage. Differential Revision: https://developer.blender.org/D16726 === M intern/cycles/kernel/data_template.h M intern/cycles/kernel/sample/pattern.h M intern/cycles/kernel/sample/sobol_burley.h M intern/cycles/scene/integrator.cpp === diff --git a/intern/cycles/kernel/data_template.h b/intern/cycles/kernel/data_template.h index af7a6d2ef41..ddc462e02f6 100644 --- a/intern/cycles/kernel/data_template.h +++ b/intern/cycles/kernel/data_template.h @@ -180,6 +180,7 @@ KERNEL_STRUCT_MEMBER(integrator, int, use_caustics) /* Sampling pattern. */ KERNEL_STRUCT_MEMBER(integrator, int, sampling_pattern) KERNEL_STRUCT_MEMBER(integrator, int, tabulated_sobol_sequence_size) +KERNEL_STRUCT_MEMBER(integrator, int, sobol_index_mask) KERNEL_STRUCT_MEMBER(integrator, float, scrambling_distance) /* Volume render. */ KERNEL_STRUCT_MEMBER(integrator, int, use_volumes) @@ -204,7 +205,6 @@ KERNEL_STRUCT_MEMBER(integrator, int, use_guiding_mis_weights) /* Padding. */ KERNEL_STRUCT_MEMBER(integrator, int, pad1) -KERNEL_STRUCT_MEMBER(integrator, int, pad2) KERNEL_STRUCT_END(KernelIntegrator) /* SVM. For shader specialization. */ diff --git a/intern/cycles/kernel/sample/pattern.h b/intern/cycles/kernel/sample/pattern.h index f6f1de448e0..71018bb1e91 100644 --- a/intern/cycles/kernel/sample/pattern.h +++ b/intern/cycles/kernel/sample/pattern.h @@ -3,8 +3,8 @@ #pragma once -#include "kernel/sample/tabulated_sobol.h" #include "kernel/sample/sobol_burley.h" +#include "kernel/sample/tabulated_sobol.h" #include "util/hash.h" CCL_NAMESPACE_BEGIN @@ -23,7 +23,8 @@ ccl_device_forceinline float path_rng_1D(KernelGlobals kg, #endif if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_SOBOL_BURLEY) { -return sobol_burley_sample_1D(sample, dimension, rng_hash); +const uint index_mask = kernel_data.integrator.sobol_index_mask; +return sobol_burley_sample_1D(sample, dimension, rng_hash, index_mask); } else { return tabulated_sobol_sample_1D(kg, sample, rng_hash, dimension); @@ -40,7 +41,8 @@ ccl_device_forceinline float2 path_rng_2D(KernelGlobals kg, #endif if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_SOBOL_BURLEY) { -return sobol_burley_sample_2D(sample, dimension, rng_hash); +const uint index_mask = kernel_data.integrator.sobol_index_mask; +return sobol_burley_sample_2D(sample, dimension, rng_hash, index_mask); } else { return tabulated_sobol_sample_2D(kg, sample, rng_hash, dimension); @@ -57,7 +59,8 @@ ccl_device_forceinline float3 path_rng_3D(KernelGlobals kg, #endif if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_SOBOL_BURLEY) { -return sobol_burley_sample_3D(sample, dimension, rng_hash); +const uint index_mask = kernel_data.integrator.sobol_index_mask; +return sobol_burley_sample_3D(sample, dimension, rng_hash, index_mask); } else { return tabulated_sobol_sample_3D(kg, sample, rng_hash, dimension); @@ -74,7 +77,8 @@ ccl_device_forceinline float4 path_rng_4D(KernelGlobals kg, #endif if (kernel_data.integrator.sampling_pattern == SAMPLING_PATTERN_SOBOL_BURLEY) { -return sobol_burley_sample_4D(sample, dimension, rng_hash); +const uint index_mask = kernel_data.integrator.sobol_index_mask; +return sobol_burley_sample_4D(sample, dimension, rng_hash, index_mask); } else { return tabulated_sobol_sample_4D(kg, sample, rng_hash, dimension); diff --git a/intern/cycles/kernel/sample/sobol_burley.h b/intern/cycles/kernel/sample/sobol_burley.h index 47796ae7998..f3fcde4ff62 100644 --- a/intern/cycles/kernel/sample/sobol_burley.h +++ b/intern/cycles/kernel/sample/sobol_burley.h @@ -64,32 +64,76 @@ ccl_device_forceinline float sobol_burley(uint rev_bit_index, return uint_to_float_excl(result); } +/* + * NOTE: the functions below intentionally produce samples that are + * uncorrelated between functions. For example, a 1D sample and 2D + * sample produced with the same index, dimension, and seed are + * uncorrelated with each other. This allows more care-free usage + * of the functions together, without having to worry about + * e.g. 1D and 2D samples being accidentally correlated with each + * other. + */ + /* * Computes a 1D Owen-scrambled and shuffled Sobol sample. + * + * `index` is
[Bf-blender-cvs] [03b5be4e3cd] blender-v3.4-release: Cycles: use more PMJ patterns and make their size adaptive.
Commit: 03b5be4e3cdf6a4967cb438dacd595c23075db79 Author: Nathan Vegdahl Date: Mon Nov 21 18:16:27 2022 +0100 Branches: blender-v3.4-release https://developer.blender.org/rB03b5be4e3cdf6a4967cb438dacd595c23075db79 Cycles: use more PMJ patterns and make their size adaptive. This resolves some issues with correlation artifacts at higher sample counts. Fix T101356, correlation issues in new PMJ pattern. Differential Revision: https://developer.blender.org/D16561 === M intern/cycles/kernel/data_template.h M intern/cycles/kernel/sample/jitter.h M intern/cycles/kernel/types.h M intern/cycles/scene/integrator.cpp === diff --git a/intern/cycles/kernel/data_template.h b/intern/cycles/kernel/data_template.h index 6b89de13797..c7b50b20c70 100644 --- a/intern/cycles/kernel/data_template.h +++ b/intern/cycles/kernel/data_template.h @@ -183,6 +183,7 @@ KERNEL_STRUCT_MEMBER(integrator, int, use_lamp_mis) KERNEL_STRUCT_MEMBER(integrator, int, use_caustics) /* Sampling pattern. */ KERNEL_STRUCT_MEMBER(integrator, int, sampling_pattern) +KERNEL_STRUCT_MEMBER(integrator, int, pmj_sequence_size) KERNEL_STRUCT_MEMBER(integrator, float, scrambling_distance) /* Volume render. */ KERNEL_STRUCT_MEMBER(integrator, int, use_volumes) @@ -205,6 +206,11 @@ KERNEL_STRUCT_MEMBER(integrator, int, use_surface_guiding) KERNEL_STRUCT_MEMBER(integrator, int, use_volume_guiding) KERNEL_STRUCT_MEMBER(integrator, int, use_guiding_direct_light) KERNEL_STRUCT_MEMBER(integrator, int, use_guiding_mis_weights) + +/* Padding. */ +KERNEL_STRUCT_MEMBER(integrator, int, pad1) +KERNEL_STRUCT_MEMBER(integrator, int, pad2) +KERNEL_STRUCT_MEMBER(integrator, int, pad3) KERNEL_STRUCT_END(KernelIntegrator) /* SVM. For shader specialization. */ diff --git a/intern/cycles/kernel/sample/jitter.h b/intern/cycles/kernel/sample/jitter.h index e748f95fc7d..1cde9f9d3de 100644 --- a/intern/cycles/kernel/sample/jitter.h +++ b/intern/cycles/kernel/sample/jitter.h @@ -7,6 +7,25 @@ #pragma once CCL_NAMESPACE_BEGIN +ccl_device uint pmj_shuffled_sample_index(KernelGlobals kg, uint sample, uint dimension, uint seed) +{ + const uint sample_count = kernel_data.integrator.pmj_sequence_size; + + /* Shuffle the pattern order and sample index to better decorrelate + * dimensions and make the most of the finite patterns we have. + * The funky sample mask stuff is to ensure that we only shuffle + * *within* the current sample pattern, which is necessary to avoid + * early repeat pattern use. */ + const uint pattern_i = hash_shuffle_uint(dimension, NUM_PMJ_PATTERNS, seed); + /* sample_count should always be a power of two, so this results in a mask. */ + const uint sample_mask = sample_count - 1; + const uint sample_shuffled = nested_uniform_scramble(sample, + hash_wang_seeded_uint(dimension, seed)); + sample = (sample & ~sample_mask) | (sample_shuffled & sample_mask); + + return ((pattern_i * sample_count) + sample) % (sample_count * NUM_PMJ_PATTERNS); +} + ccl_device float pmj_sample_1D(KernelGlobals kg, uint sample, const uint rng_hash, @@ -20,22 +39,9 @@ ccl_device float pmj_sample_1D(KernelGlobals kg, seed = kernel_data.integrator.seed; } - /* Shuffle the pattern order and sample index to better decorrelate - * dimensions and make the most of the finite patterns we have. - * The funky sample mask stuff is to ensure that we only shuffle - * *within* the current sample pattern, which is necessary to avoid - * early repeat pattern use. */ - const uint pattern_i = hash_shuffle_uint(dimension, NUM_PMJ_PATTERNS, seed); - /* NUM_PMJ_SAMPLES should be a power of two, so this results in a mask. */ - const uint sample_mask = NUM_PMJ_SAMPLES - 1; - const uint sample_shuffled = nested_uniform_scramble(sample, - hash_wang_seeded_uint(dimension, seed)); - sample = (sample & ~sample_mask) | (sample_shuffled & sample_mask); - /* Fetch the sample. */ - const uint index = ((pattern_i * NUM_PMJ_SAMPLES) + sample) % - (NUM_PMJ_SAMPLES * NUM_PMJ_PATTERNS); - float x = kernel_data_fetch(sample_pattern_lut, index * 2); + const uint index = pmj_shuffled_sample_index(kg, sample, dimension, seed); + float x = kernel_data_fetch(sample_pattern_lut, index * NUM_PMJ_DIMENSIONS); /* Do limited Cranley-Patterson rotation when using scrambling distance. */ if (kernel_data.integrator.scrambling_distance < 1.0f) { @@ -61,23 +67,10 @@ ccl_device float2 pmj_sample_2D(KernelGlobals kg, seed = kernel_data.integrator.seed; } - /* Shuffle the pattern order and sample index to better decorrelate - * dimensions and make the most of the finite patterns we have. -
[Bf-blender-cvs] [49ca810bf30] master: Cycles: enable adaptive sampling for Sobol-Burley
Commit: 49ca810bf302fdf48e37527d1f8d160fcbd958d2 Author: Nathan Vegdahl Date: Fri Sep 2 17:32:34 2022 +0200 Branches: master https://developer.blender.org/rB49ca810bf302fdf48e37527d1f8d160fcbd958d2 Cycles: enable adaptive sampling for Sobol-Burley This uses the same sample classification approach as used for PMJ, because it turns out to also work equally well with Sobol-Burley. This also implements a fallback (random classification) that should work "okay" for other samplers, though there are no other samplers at the moment. Differential Revision: https://developer.blender.org/D15845 === M intern/cycles/blender/addon/ui.py M intern/cycles/kernel/film/light_passes.h M intern/cycles/kernel/sample/pattern.h M intern/cycles/scene/integrator.cpp === diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 37fecec771b..ee284dd899a 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -296,7 +296,6 @@ class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel): row.prop(cscene, "use_animated_seed", text="", icon='TIME') col = layout.column(align=True) -col.active = not (cscene.use_adaptive_sampling and cscene.use_preview_adaptive_sampling) col.prop(cscene, "sampling_pattern", text="Pattern") col = layout.column(align=True) diff --git a/intern/cycles/kernel/film/light_passes.h b/intern/cycles/kernel/film/light_passes.h index 5c306e8f088..b45b5305119 100644 --- a/intern/cycles/kernel/film/light_passes.h +++ b/intern/cycles/kernel/film/light_passes.h @@ -147,16 +147,16 @@ ccl_device void film_write_adaptive_buffer(KernelGlobals kg, const Spectrum contribution, ccl_global float *ccl_restrict buffer) { - /* Adaptive Sampling. Fill the additional buffer with the odd samples and calculate our stopping - * criteria. This is the heuristic from "A hierarchical automatic stopping condition for Monte - * Carlo global illumination" except that here it is applied per pixel and not in hierarchical - * tiles. */ + /* Adaptive Sampling. Fill the additional buffer with only one half of the samples and + * calculate our stopping criteria. This is the heuristic from "A hierarchical automatic + * stopping condition for Monte Carlo global illumination" except that here it is applied + * per pixel and not in hierarchical tiles. */ if (kernel_data.film.pass_adaptive_aux_buffer == PASS_UNUSED) { return; } - if (sample_is_even(kernel_data.integrator.sampling_pattern, sample)) { + if (sample_is_class_A(kernel_data.integrator.sampling_pattern, sample)) { const float3 contribution_rgb = spectrum_to_rgb(contribution); film_write_pass_float4(buffer + kernel_data.film.pass_adaptive_aux_buffer, diff --git a/intern/cycles/kernel/sample/pattern.h b/intern/cycles/kernel/sample/pattern.h index 6477e29fa40..fa48cc216af 100644 --- a/intern/cycles/kernel/sample/pattern.h +++ b/intern/cycles/kernel/sample/pattern.h @@ -90,18 +90,31 @@ ccl_device_inline uint path_rng_hash_init(KernelGlobals kg, return rng_hash; } -ccl_device_inline bool sample_is_even(int pattern, int sample) +/** + * Splits samples into two different classes, A and B, which can be + * compared for variance estimation. + */ +ccl_device_inline bool sample_is_class_A(int pattern, int sample) { - if (pattern == SAMPLING_PATTERN_PMJ) { -/* See Section 10.2.1, "Progressive Multi-Jittered Sample Sequences", Christensen et al. - * We can use this to get divide sample sequence into two classes for easier variance - * estimation. */ -return popcount(uint(sample) & 0x) & 1; - } - else { -/* TODO(Stefan): Are there reliable ways of dividing Sobol-Burley into two classes? */ -return sample & 0x1; +#if 0 + if (!(pattern == SAMPLING_PATTERN_PMJ || pattern == SAMPLING_PATTERN_SOBOL_BURLEY)) { +/* Fallback: assign samples randomly. + * This is guaranteed to work "okay" for any sampler, but isn't good. + * (Note: the seed constant is just a random number to guard against + * possible interactions with other uses of the hash. There's nothing + * special about it.) + */ +return hash_hp_seeded_uint(sample, 0xa771f873) & 1; } -} +#endif + /* This follows the approach from section 10.2.1 of "Progressive + * Multi-Jittered Sample Sequences" by Christensen et al., but + * implemented with efficient bit-fiddling. + * + * This approach also turns out to work equally well with Sobol-Burley + * (see https://developer.blender.org/D15746#429471). + */ + return popcount(uint(sam
[Bf-blender-cvs] [50df9caef01] master: Cycles: improve Progressive Multi-Jittered sampling
Commit: 50df9caef01a4225db216d9c4c0515134f7a37bf Author: Nathan Vegdahl Date: Tue Aug 23 20:48:48 2022 +0200 Branches: master https://developer.blender.org/rB50df9caef01a4225db216d9c4c0515134f7a37bf Cycles: improve Progressive Multi-Jittered sampling Fix two issues in the previous implementation: * Only power-of-two prefixes were progressively stratified, not suffixes. This resulted in unnecessarily increased noise when using non-power-of-two sample counts. * In order to try to get away with just a single sample pattern, the code used a combination of sample index shuffling and Cranley-Patterson rotation. Index shuffling is normally fine, but due to the sample patterns themselves not being quite right (as described above) this actually resulted in additional increased noise. Cranley-Patterson, on the other hand, always increases noise with randomized (t,s) nets like PMJ02, and should be avoided with these kinds of sequences. Addressed with the following changes: * Replace the sample pattern generation code with a much simpler algorithm recently published in the paper "Stochastic Generation of (t, s) Sample Sequences". This new implementation is easier to verify, produces fully progressively stratified PMJ02, and is *far* faster than the previous code, being O(N) in the number of samples generated. * It keeps the sample index shuffling, which works correctly now due to the improved sample patterns. But it now uses a newer high-quality hash instead of the original Laine-Karras hash. * The scrambling distance feature cannot (to my knowledge) be implemented with any decorrelation strategy other than Cranley-Patterson, so Cranley-Patterson is still used when that feature is enabled. But it is now disabled otherwise, since it increases noise. * In place of Cranley-Patterson, multiple independent patterns are generated and randomly chosen for different pixels and dimensions as described in the original PMJ paper. In this patch, the pattern selection is done via hash-based shuffling to ensure there are no repeats within a single pixel until all patterns have been used. The combination of these fixes brings the quality of Cycles' PMJ sampler in line with the previously submitted Sobol-Burley sampler in D15679. They are essentially indistinguishable in terms of quality/noise, which is expected since they are both randomized (0,2) sequences. Differential Revision: https://developer.blender.org/D15746 === M intern/cycles/kernel/integrator/subsurface_random_walk.h M intern/cycles/kernel/sample/jitter.h M intern/cycles/kernel/sample/util.h M intern/cycles/kernel/types.h M intern/cycles/scene/jitter.cpp M intern/cycles/scene/jitter.h M intern/cycles/util/hash.h === diff --git a/intern/cycles/kernel/integrator/subsurface_random_walk.h b/intern/cycles/kernel/integrator/subsurface_random_walk.h index baca0d745e8..e0c69c96fc6 100644 --- a/intern/cycles/kernel/integrator/subsurface_random_walk.h +++ b/intern/cycles/kernel/integrator/subsurface_random_walk.h @@ -229,7 +229,7 @@ ccl_device_inline bool subsurface_random_walk(KernelGlobals kg, const float phase_log = logf((diffusion_length + 1.0f) / (diffusion_length - 1.0f)); /* Modify state for RNGs, decorrelated from other paths. */ - rng_state.rng_hash = hash_cmj_seeded_uint(rng_state.rng_hash + rng_state.rng_offset, 0xdeadbeef); + rng_state.rng_hash = hash_hp_seeded_uint(rng_state.rng_hash + rng_state.rng_offset, 0xdeadbeef); /* Random walk until we hit the surface again. */ bool hit = false; diff --git a/intern/cycles/kernel/sample/jitter.h b/intern/cycles/kernel/sample/jitter.h index dd170cf2120..6a9ff1beec5 100644 --- a/intern/cycles/kernel/sample/jitter.h +++ b/intern/cycles/kernel/sample/jitter.h @@ -7,57 +7,40 @@ #pragma once CCL_NAMESPACE_BEGIN -ccl_device_inline uint32_t nested_uniform_scramble(uint32_t x, uint32_t seed) -{ - x = reverse_integer_bits(x); - x = laine_karras_permutation(x, seed); - x = reverse_integer_bits(x); - - return x; -} - ccl_device float pmj_sample_1D(KernelGlobals kg, uint sample, uint rng_hash, uint dimension) { - uint hash = rng_hash; - float jitter_x = 0.0f; - if (kernel_data.integrator.scrambling_distance < 1.0f) { -hash = kernel_data.integrator.seed; + uint seed = rng_hash; -jitter_x = hash_wang_seeded_float(dimension, rng_hash) * - kernel_data.integrator.scrambling_distance; + /* Use the same sample sequence seed for all pixels when using + * scrambling distance. */ + if (kernel_data.integrator.scrambling_distance < 1.0f) { +seed = kernel_data.integrator.seed; } - /* Perform Owen shuffle of the sample number to reorder the samples. */ - const uint rv = hash_cmj_seeded_uint(dimension, hash); -#ifdef _XOR_SHUFFLE_ -# wa
[Bf-blender-cvs] [a06c9b5ca83] master: Cycles: add Sobol-Burley sampling pattern
Commit: a06c9b5ca8364f95bbfa6c3bedd23307e6817437 Author: Nathan Vegdahl Date: Thu Aug 18 20:45:09 2022 +0200 Branches: master https://developer.blender.org/rBa06c9b5ca8364f95bbfa6c3bedd23307e6817437 Cycles: add Sobol-Burley sampling pattern Based on the paper "Practical Hash-based Owen Scrambling" by Brent Burley, 2020, Journal of Computer Graphics Techniques. It is distinct from the existing Sobol sampler in two important ways: * It is Owen scrambled, which gives it a much better convergence rate in many situations. * It uses padding for higher dimensions, rather than using higher Sobol dimensions directly. In practice this is advantagous because high-dimensional Sobol sequences have holes in their sampling patterns that don't resolve until an unreasonable number of samples are taken. (See Burley's paper for details.) The pattern reduces noise in some benchmark scenes, however it is also slower, particularly on the CPU. So for now Progressive Multi-Jittered sampling remains the default. Differential Revision: https://developer.blender.org/D15679 === M intern/cycles/blender/addon/properties.py M intern/cycles/kernel/CMakeLists.txt M intern/cycles/kernel/integrator/path_state.h M intern/cycles/kernel/integrator/subsurface_random_walk.h M intern/cycles/kernel/sample/jitter.h M intern/cycles/kernel/sample/pattern.h A intern/cycles/kernel/sample/sobol_burley.h A intern/cycles/kernel/sample/util.h M intern/cycles/kernel/tables.h M intern/cycles/kernel/types.h M intern/cycles/scene/integrator.cpp M intern/cycles/util/hash.h === diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 2c926893f9d..859560c8062 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -83,6 +83,7 @@ enum_use_layer_samples = ( enum_sampling_pattern = ( ('SOBOL', "Sobol", "Use Sobol random sampling pattern", 0), ('PROGRESSIVE_MULTI_JITTER', "Progressive Multi-Jitter", "Use Progressive Multi-Jitter random sampling pattern", 1), +('SOBOL_BURLEY', "Sobol-Burley", "Use Sobol-Burley random sampling pattern", 2), ) enum_volume_sampling = ( diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index fbc30234dac..c7dcc928c0d 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -274,6 +274,8 @@ set(SRC_KERNEL_SAMPLE_HEADERS sample/mapping.h sample/mis.h sample/pattern.h + sample/sobol_burley.h + sample/util.h ) set(SRC_KERNEL_UTIL_HEADERS diff --git a/intern/cycles/kernel/integrator/path_state.h b/intern/cycles/kernel/integrator/path_state.h index 5ec94b934ca..a41e922b593 100644 --- a/intern/cycles/kernel/integrator/path_state.h +++ b/intern/cycles/kernel/integrator/path_state.h @@ -321,8 +321,10 @@ ccl_device_inline float path_state_rng_1D_hash(KernelGlobals kg, /* Use a hash instead of dimension, this is not great but avoids adding * more dimensions to each bounce which reduces quality of dimensions we * are already using. */ - return path_rng_1D( - kg, cmj_hash_simple(rng_state->rng_hash, hash), rng_state->sample, rng_state->rng_offset); + return path_rng_1D(kg, + hash_wang_seeded_uint(rng_state->rng_hash, hash), + rng_state->sample, + rng_state->rng_offset); } ccl_device_inline float path_branched_rng_1D(KernelGlobals kg, diff --git a/intern/cycles/kernel/integrator/subsurface_random_walk.h b/intern/cycles/kernel/integrator/subsurface_random_walk.h index 9c67d909bd4..baca0d745e8 100644 --- a/intern/cycles/kernel/integrator/subsurface_random_walk.h +++ b/intern/cycles/kernel/integrator/subsurface_random_walk.h @@ -229,7 +229,7 @@ ccl_device_inline bool subsurface_random_walk(KernelGlobals kg, const float phase_log = logf((diffusion_length + 1.0f) / (diffusion_length - 1.0f)); /* Modify state for RNGs, decorrelated from other paths. */ - rng_state.rng_hash = cmj_hash(rng_state.rng_hash + rng_state.rng_offset, 0xdeadbeef); + rng_state.rng_hash = hash_cmj_seeded_uint(rng_state.rng_hash + rng_state.rng_offset, 0xdeadbeef); /* Random walk until we hit the surface again. */ bool hit = false; diff --git a/intern/cycles/kernel/sample/jitter.h b/intern/cycles/kernel/sample/jitter.h index b5cfa624406..dd170cf2120 100644 --- a/intern/cycles/kernel/sample/jitter.h +++ b/intern/cycles/kernel/sample/jitter.h @@ -1,20 +1,12 @@ /* SPDX-License-Identifier: Apache-2.0 * Copyright 2011-2022 Blender Foundation */ +#include "kernel/sample/util.h" +#include "util/hash.h" + #pragma once CCL_NAMESPACE_BEGIN
Re: [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55068] trunk/blender/release/scripts/ startup/bl_ui/space_dopesheet.py: Feature Request: Show Errors Filter for Anim Editors now works for
Awesome, thanks Joshua! :-D --Nathan On Tue, Mar 5, 2013 at 4:56 PM, Joshua Leung aligor...@gmail.com wrote: Revision: 55068 http://projects.blender.org/scm/viewvc.php?view=revroot=bf-blenderrevision=55068 Author: aligorith Date: 2013-03-06 00:56:58 + (Wed, 06 Mar 2013) Log Message: --- Feature Request: Show Errors Filter for Anim Editors now works for F-Curves/Animation as well as Drivers This is useful for tracking down invalid F-Curves which might need to have their paths fixed, or perhaps to remove F-Curves for controls which no longer exist in a new rig. Modified Paths: -- trunk/blender/release/scripts/startup/bl_ui/space_dopesheet.py Modified: trunk/blender/release/scripts/startup/bl_ui/space_dopesheet.py === --- trunk/blender/release/scripts/startup/bl_ui/space_dopesheet.py 2013-03-05 23:21:10 UTC (rev 55067) +++ trunk/blender/release/scripts/startup/bl_ui/space_dopesheet.py 2013-03-06 00:56:58 UTC (rev 55068) @@ -29,7 +29,6 @@ def dopesheet_filter(layout, context, genericFiltersOnly=False): dopesheet = context.space_data.dopesheet is_nla = context.area.type == 'NLA_EDITOR' -is_drivers = (context.area.type == 'GRAPH_EDITOR' and context.space_data.mode == 'DRIVERS') row = layout.row(align=True) row.prop(dopesheet, show_only_selected, text=) @@ -37,8 +36,7 @@ if is_nla: row.prop(dopesheet, show_missing_nla, text=) - -if is_drivers: +else: # graph and dopesheet editors - F-Curves and drivers only row.prop(dopesheet, show_only_errors, text=) if not genericFiltersOnly: ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52419] trunk/blender/source/blender/ editors/mesh: Change edge loop select and edge ring select to be consistent with
Revision: 52419 http://projects.blender.org/scm/viewvc.php?view=revroot=bf-blenderrevision=52419 Author: cessen Date: 2012-11-21 01:51:31 + (Wed, 21 Nov 2012) Log Message: --- Change edge loop select and edge ring select to be consistent with other selection operators. Instead of having only a single extend option which causes the selection to toggle, there are now three options: - extend: adds to selection - deselect: removes from selection - toggle: toggles the selection The default keymap is adjusted to have identical behavior as before, using these new options, so end-users shouldn't experience any difference. Modified Paths: -- trunk/blender/source/blender/editors/mesh/editmesh_select.c trunk/blender/source/blender/editors/mesh/mesh_ops.c Modified: trunk/blender/source/blender/editors/mesh/editmesh_select.c === --- trunk/blender/source/blender/editors/mesh/editmesh_select.c 2012-11-21 01:07:30 UTC (rev 52418) +++ trunk/blender/source/blender/editors/mesh/editmesh_select.c 2012-11-21 01:51:31 UTC (rev 52419) @@ -1083,7 +1083,7 @@ /* * loop select (non modal) ** */ -static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring) +static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short deselect, short toggle, short ring) { ViewContext vc; BMEditMesh *em; @@ -1102,16 +1102,22 @@ eed = EDBM_edge_find_nearest(vc, dist); if (eed) { - if (extend == 0) { + if (extend == 0 deselect == 0 toggle == 0) { EDBM_flag_disable_all(em, BM_ELEM_SELECT); } - if (BM_elem_flag_test(eed, BM_ELEM_SELECT) == 0) { + if (extend) { select = TRUE; } - else if (extend) { + else if (deselect) { select = FALSE; } + else if (BM_elem_flag_test(eed, BM_ELEM_SELECT) == 0) { + select = TRUE; + } + else if (toggle) { + select = FALSE; + } if (em-selectmode SCE_SELECT_FACE) { walker_select(em, BMW_FACELOOP, eed, select); @@ -1202,6 +1208,8 @@ view3d_operator_needs_opengl(C); mouse_mesh_loop(C, event-mval, RNA_boolean_get(op-ptr, extend), + RNA_boolean_get(op-ptr, deselect), + RNA_boolean_get(op-ptr, toggle), RNA_boolean_get(op-ptr, ring)); /* cannot do tweaks for as long this keymap is after transform map */ @@ -1224,6 +1232,8 @@ /* properties */ RNA_def_boolean(ot-srna, extend, 0, Extend Select, Extend the selection); + RNA_def_boolean(ot-srna, deselect, 0, Deselect, Remove from the selection); + RNA_def_boolean(ot-srna, toggle, 0, Toggle Select, Toggle the selection); RNA_def_boolean(ot-srna, ring, 0, Select Ring, Select ring); } @@ -1242,6 +1252,8 @@ ot-flag = OPTYPE_UNDO; RNA_def_boolean(ot-srna, extend, 0, Extend, Extend the selection); + RNA_def_boolean(ot-srna, deselect, 0, Deselect, Remove from the selection); + RNA_def_boolean(ot-srna, toggle, 0, Toggle Select, Toggle the selection); RNA_def_boolean(ot-srna, ring, 1, Select Ring, Select ring); } Modified: trunk/blender/source/blender/editors/mesh/mesh_ops.c === --- trunk/blender/source/blender/editors/mesh/mesh_ops.c2012-11-21 01:07:30 UTC (rev 52418) +++ trunk/blender/source/blender/editors/mesh/mesh_ops.c2012-11-21 01:51:31 UTC (rev 52419) @@ -278,13 +278,21 @@ /* standard mouse selection goes via space_view3d */ kmi = WM_keymap_add_item(keymap, MESH_OT_loop_select, SELECTMOUSE, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi-ptr, extend, FALSE); + RNA_boolean_set(kmi-ptr, deselect, FALSE); + RNA_boolean_set(kmi-ptr, toggle, FALSE); kmi = WM_keymap_add_item(keymap, MESH_OT_loop_select, SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0); - RNA_boolean_set(kmi-ptr, extend, TRUE); + RNA_boolean_set(kmi-ptr, extend, FALSE); + RNA_boolean_set(kmi-ptr, deselect, FALSE); + RNA_boolean_set(kmi-ptr, toggle, TRUE); kmi = WM_keymap_add_item(keymap, MESH_OT_edgering_select, SELECTMOUSE, KM_PRESS, KM_ALT | KM_CTRL, 0); RNA_boolean_set(kmi-ptr, extend, FALSE); + RNA_boolean_set(kmi-ptr, deselect, FALSE); + RNA_boolean_set(kmi-ptr, toggle, FALSE); kmi = WM_keymap_add_item(keymap, MESH_OT_edgering_select, SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT | KM_CTRL, 0); - RNA_boolean_set(kmi-ptr, extend, TRUE); + RNA_boolean_set(kmi-ptr, extend,
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46986] trunk/blender/source/blender/ editors: Modifications to the view3d.select() operator:
Revision: 46986 http://projects.blender.org/scm/viewvc.php?view=revroot=bf-blenderrevision=46986 Author: cessen Date: 2012-05-24 21:05:27 + (Thu, 24 May 2012) Log Message: --- Modifications to the view3d.select() operator: 1. Two new boolean options have been added to the operator: deselect and toggle. 2. The previous behavior of extend (toggling the selection) has been moved to the toggle option. 3. extend now only extends the selection, it never deselects. 4. deselect is pretty self-explanatory: it deselects (i.e. opposite of extend). 5. The built-in keymap has been changed to use toggle where extend was used before for this operator, to maintain the previous behavior in the default keymap. In short, this works towards making extend and deselect fully consistent across all selection tools (adding to and removing from selection, respectively), but still preserves the old behavior as well. (Patch reviewed by Brecht.) Modified Paths: -- trunk/blender/source/blender/editors/armature/editarmature.c trunk/blender/source/blender/editors/curve/editcurve.c trunk/blender/source/blender/editors/include/ED_armature.h trunk/blender/source/blender/editors/include/ED_curve.h trunk/blender/source/blender/editors/include/ED_mball.h trunk/blender/source/blender/editors/include/ED_mesh.h trunk/blender/source/blender/editors/include/ED_object.h trunk/blender/source/blender/editors/include/ED_particle.h trunk/blender/source/blender/editors/mesh/editface.c trunk/blender/source/blender/editors/mesh/editmesh_select.c trunk/blender/source/blender/editors/metaball/mball_edit.c trunk/blender/source/blender/editors/object/object_lattice.c trunk/blender/source/blender/editors/physics/particle_edit.c trunk/blender/source/blender/editors/space_view3d/view3d_ops.c trunk/blender/source/blender/editors/space_view3d/view3d_select.c Modified: trunk/blender/source/blender/editors/armature/editarmature.c === --- trunk/blender/source/blender/editors/armature/editarmature.c 2012-05-24 20:20:12 UTC (rev 46985) +++ trunk/blender/source/blender/editors/armature/editarmature.c 2012-05-24 21:05:27 UTC (rev 46986) @@ -1842,7 +1842,7 @@ } /* context: editmode armature in view3d */ -int mouse_armature(bContext *C, const int mval[2], int extend) +int mouse_armature(bContext *C, const int mval[2], int extend, int deselect, int toggle) { Object *obedit = CTX_data_edit_object(C); bArmature *arm = obedit-data; @@ -1857,7 +1857,7 @@ nearBone = get_nearest_editbonepoint(vc, mval, arm-edbo, 1, selmask); if (nearBone) { - if (!extend) + if (!extend !deselect !toggle) ED_armature_deselect_all(obedit, 0); /* by definition the non-root connected bones have no root point drawn, @@ -1867,6 +1867,18 @@ if (nearBone-parent (nearBone-flag BONE_CONNECTED)) { /* click in a chain */ if (extend) { + /* select this bone */ + nearBone-flag |= BONE_TIPSEL; + nearBone-parent-flag |= BONE_TIPSEL; + } + else if (deselect) { + /* deselect this bone */ + nearBone-flag = ~(BONE_TIPSEL | BONE_SELECTED); + /* only deselect parent tip if it is not selected */ + if (!(nearBone-parent-flag BONE_SELECTED)) + nearBone-parent-flag = ~BONE_TIPSEL; + } + else if (toggle) { /* hold shift inverts this bone's selection */ if (nearBone-flag BONE_SELECTED) { /* deselect this bone */ @@ -1889,18 +1901,29 @@ } else { if (extend) { + nearBone-flag |= (BONE_TIPSEL | BONE_ROOTSEL); + } + else if (deselect) { + nearBone-flag = ~(BONE_TIPSEL | BONE_ROOTSEL); + } + else if (toggle) { /* hold shift inverts this bone's selection */ if (nearBone-flag BONE_SELECTED) nearBone-flag = ~(BONE_TIPSEL | BONE_ROOTSEL);
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46987] trunk/blender/source/blender/ editors/mesh/editmesh_select.c: Missed a change from extend to toggle in last commit.
Revision: 46987 http://projects.blender.org/scm/viewvc.php?view=revroot=bf-blenderrevision=46987 Author: cessen Date: 2012-05-24 21:42:35 + (Thu, 24 May 2012) Log Message: --- Missed a change from extend to toggle in last commit. Thanks Campbell for the catch. :-) Modified Paths: -- trunk/blender/source/blender/editors/mesh/editmesh_select.c Modified: trunk/blender/source/blender/editors/mesh/editmesh_select.c === --- trunk/blender/source/blender/editors/mesh/editmesh_select.c 2012-05-24 21:05:27 UTC (rev 46986) +++ trunk/blender/source/blender/editors/mesh/editmesh_select.c 2012-05-24 21:42:35 UTC (rev 46987) @@ -1496,7 +1496,7 @@ BM_select_history_store(vc.em-bm, efa); BM_face_select_set(vc.em-bm, efa, TRUE); } - else if (extend) { + else if (toggle) { BM_select_history_remove(vc.em-bm, efa); BM_face_select_set(vc.em-bm, efa, FALSE); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43787] trunk/blender/source/blender/ makesrna/intern/rna_constraint.c: Action constraint transform channel was listing X Scale as Z Scale,
Revision: 43787 http://projects.blender.org/scm/viewvc.php?view=revroot=bf-blenderrevision=43787 Author: cessen Date: 2012-01-31 04:23:49 + (Tue, 31 Jan 2012) Log Message: --- Action constraint transform channel was listing X Scale as Z Scale, resulting in two Z Scale listings in the menu. Fixed. Modified Paths: -- trunk/blender/source/blender/makesrna/intern/rna_constraint.c Modified: trunk/blender/source/blender/makesrna/intern/rna_constraint.c === --- trunk/blender/source/blender/makesrna/intern/rna_constraint.c 2012-01-31 03:54:51 UTC (rev 43786) +++ trunk/blender/source/blender/makesrna/intern/rna_constraint.c 2012-01-31 04:23:49 UTC (rev 43787) @@ -1032,7 +1032,7 @@ {00, ROTATION_X, 0, X Rotation, }, {01, ROTATION_Y, 0, Y Rotation, }, {02, ROTATION_Z, 0, Z Rotation, }, - {10, SCALE_X, 0, Z Scale, }, + {10, SCALE_X, 0, X Scale, }, {11, SCALE_Y, 0, Y Scale, }, {12, SCALE_Z, 0, Z Scale, }, {0, NULL, 0, NULL, NULL}}; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36692] trunk/blender/release/scripts/ startup/bl_ui/properties_data_mesh.py: Button for adding shape keys now creates shapes from base mesh instead o
Revision: 36692 http://projects.blender.org/scm/viewvc.php?view=revroot=bf-blenderrevision=36692 Author: cessen Date: 2011-05-14 20:23:05 + (Sat, 14 May 2011) Log Message: --- Button for adding shape keys now creates shapes from base mesh instead of from the current shape mix. The old behavior is still accessable from the menu as New Shape From Mix. Checked with Sergey and Bassam that this is a good change. New users expect the add shape button to simply add a new blank shape, and get confused when that is not the case. It is also really easy to accidentally have other shape information in a new shape when the from mix behavior is default. Modified Paths: -- trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py === --- trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py 2011-05-14 18:54:56 UTC (rev 36691) +++ trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py 2011-05-14 20:23:05 UTC (rev 36692) @@ -46,6 +46,8 @@ layout.operator(object.shape_key_transfer, icon='COPY_ID') # icon is not ideal layout.operator(object.join_shapes, icon='COPY_ID') # icon is not ideal layout.operator(object.shape_key_mirror, icon='ARROW_LEFTRIGHT') +op = layout.operator(object.shape_key_add, icon='ZOOMIN', text=New Shape From Mix) +op.from_mix = True class MeshButtonsPanel(): @@ -193,7 +195,8 @@ col = row.column() sub = col.column(align=True) -sub.operator(object.shape_key_add, icon='ZOOMIN', text=) +op = sub.operator(object.shape_key_add, icon='ZOOMIN', text=) +op.from_mix = False sub.operator(object.shape_key_remove, icon='ZOOMOUT', text=) sub.menu(MESH_MT_shape_key_specials, icon='DOWNARROW_HLT', text=) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35040] trunk/blender/release/scripts/ modules/bpy_types.py: Editbone length was still using normalize() instead of normalized()
Revision: 35040 http://projects.blender.org/scm/viewvc.php?view=revroot=bf-blenderrevision=35040 Author: cessen Date: 2011-02-21 20:26:37 + (Mon, 21 Feb 2011) Log Message: --- Editbone length was still using normalize() instead of normalized() for setting length, which was thus failing and erroring out. Modified Paths: -- trunk/blender/release/scripts/modules/bpy_types.py Modified: trunk/blender/release/scripts/modules/bpy_types.py === --- trunk/blender/release/scripts/modules/bpy_types.py 2011-02-21 18:18:55 UTC (rev 35039) +++ trunk/blender/release/scripts/modules/bpy_types.py 2011-02-21 20:26:37 UTC (rev 35040) @@ -188,7 +188,7 @@ @length.setter def length(self, value): -self.tail = self.head + ((self.tail - self.head).normalize() * value) +self.tail = self.head + ((self.tail - self.head).normalized() * value) @property def vector(self): ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32711] trunk/blender/release/scripts: Removed old rigify code, as it is starting to interfere with the newer Rigify addon.
Revision: 32711 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=32711 Author: cessen Date: 2010-10-26 07:07:09 +0200 (Tue, 26 Oct 2010) Log Message: --- Removed old rigify code, as it is starting to interfere with the newer Rigify addon. The newer addon currently resides here: bzr://bzr.cessen.com/rigify But will eventually be included in svn. Removed Paths: - trunk/blender/release/scripts/modules/rigify/ trunk/blender/release/scripts/modules/rigify_utils.py trunk/blender/release/scripts/op/add_armature_human.py trunk/blender/release/scripts/ui/properties_data_armature_rigify.py Deleted: trunk/blender/release/scripts/modules/rigify_utils.py === --- trunk/blender/release/scripts/modules/rigify_utils.py 2010-10-26 01:55:06 UTC (rev 32710) +++ trunk/blender/release/scripts/modules/rigify_utils.py 2010-10-26 05:07:09 UTC (rev 32711) @@ -1,467 +0,0 @@ -# # BEGIN GPL LICENSE BLOCK # -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software Foundation, -# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# # END GPL LICENSE BLOCK # - -# pep8 compliant - -# rigify its self does not depend on this module, however some of the -# rigify templates use these utility functions. -# -# So even though this can be for general purpose use, this module was created -# for rigify so in some cases seemingly generic functions make assumptions -# that a generic function would need to check for. - -import bpy -from mathutils import Vector -from rna_prop_ui import rna_idprop_ui_prop_get - -DELIMITER = '-._' -EMPTY_LAYER = [False] * 32 - - -def add_stretch_to(obj, from_name, to_name, name): -''' -Adds a bone that stretches from one to another -''' - -mode_orig = obj.mode -bpy.ops.object.mode_set(mode='EDIT') - -arm = obj.data -stretch_ebone = arm.edit_bones.new(name) -stretch_name = stretch_ebone.name -del name - -head = stretch_ebone.head = arm.edit_bones[from_name].head.copy() -#tail = stretch_ebone.tail = arm.edit_bones[to_name].head.copy() - -# annoying exception for zero length bones, since its using stretch_to the rest pose doesnt really matter -#if (head - tail).length 0.1: -if 1: -tail = stretch_ebone.tail = arm.edit_bones[from_name].tail.copy() - - -# Now for the constraint -bpy.ops.object.mode_set(mode='OBJECT') - -stretch_pbone = obj.pose.bones[stretch_name] - -con = stretch_pbone.constraints.new('COPY_LOCATION') -con.target = obj -con.subtarget = from_name - -con = stretch_pbone.constraints.new('STRETCH_TO') -con.target = obj -con.subtarget = to_name -con.rest_length = (head - tail).length -con.keep_axis = 'PLANE_X' -con.volume = 'NO_VOLUME' - -bpy.ops.object.mode_set(mode=mode_orig) - -return stretch_name - - -def copy_bone_simple(arm, from_bone, name, parent=False): -ebone = arm.edit_bones[from_bone] -ebone_new = arm.edit_bones.new(name) - -if parent: -ebone_new.use_connect = ebone.use_connect -ebone_new.parent = ebone.parent - -ebone_new.head = ebone.head -ebone_new.tail = ebone.tail -ebone_new.roll = ebone.roll -ebone_new.layers = list(ebone.layers) -return ebone_new - - -def copy_bone_simple_list(arm, from_bones, to_bones, parent=False): - -if len(from_bones) != len(to_bones): -raise Exception(bone list sizes must match) - -copy_bones = [copy_bone_simple(arm, bone_name, to_bones[i], True) for i, bone_name in enumerate(from_bones)] - -# now we need to re-parent -for ebone in copy_bones: -parent = ebone.parent -if parent: -try: -i = from_bones.index(parent.name) -except: -i = -1 - -if i == -1: -ebone.parent = None -else: -ebone.parent = copy_bones[i] - -return copy_bones - - -def blend_bone_list(obj, apply_bones, from_bones, to_bones, target_bone=None, target_prop=blend, blend_default=0.5): - -if obj.mode == 'EDIT': -raise Exception(blending cant be called in editmode) - -if len(apply_bones) != len(from_bones): -raise Exception(lists differ in length (from - apply): \n\t%s\n\t%s %
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28824] branches/render25/release/scripts/ modules/rigify/eye_lid.py: Fix for the eyelid rig type.
Revision: 28824 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=28824 Author: cessen Date: 2010-05-18 15:46:56 +0200 (Tue, 18 May 2010) Log Message: --- Fix for the eyelid rig type. Vector(#, #, #) to Vector((#, #, #)) Modified Paths: -- branches/render25/release/scripts/modules/rigify/eye_lid.py Modified: branches/render25/release/scripts/modules/rigify/eye_lid.py === --- branches/render25/release/scripts/modules/rigify/eye_lid.py 2010-05-18 13:18:37 UTC (rev 28823) +++ branches/render25/release/scripts/modules/rigify/eye_lid.py 2010-05-18 13:46:56 UTC (rev 28824) @@ -299,7 +299,7 @@ lid8 = copy_bone_simple(obj.data, definitions[9], base_names[definitions[9]]).name size = eb[lid1].length -size_y = Vector(0.0, size, 0.0) +size_y = Vector((0.0, size, 0.0)) eb[lid1].tail = eb[lid1].head + size_y eb[lid2].tail = eb[lid2].head + size_y eb[lid3].tail = eb[lid3].head + size_y ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28286] branches/render25/release/scripts/ modules: Updated rigify scripts for minor driver api change.
Revision: 28286 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=28286 Author: cessen Date: 2010-04-19 17:20:33 +0200 (Mon, 19 Apr 2010) Log Message: --- Updated rigify scripts for minor driver api change. Modified Paths: -- branches/render25/release/scripts/modules/rigify/arm_biped.py branches/render25/release/scripts/modules/rigify/eye_balls.py branches/render25/release/scripts/modules/rigify/eye_lid.py branches/render25/release/scripts/modules/rigify/finger_curl.py branches/render25/release/scripts/modules/rigify/leg_biped.py branches/render25/release/scripts/modules/rigify/leg_quadruped.py branches/render25/release/scripts/modules/rigify/mouth.py branches/render25/release/scripts/modules/rigify/neck.py branches/render25/release/scripts/modules/rigify/neck_flex.py branches/render25/release/scripts/modules/rigify/shape_key_control.py branches/render25/release/scripts/modules/rigify/shape_key_distance.py branches/render25/release/scripts/modules/rigify/shape_key_rotdiff.py branches/render25/release/scripts/modules/rigify/spine_pivot_flex.py branches/render25/release/scripts/modules/rigify/tail_control.py branches/render25/release/scripts/modules/rigify/tongue.py branches/render25/release/scripts/modules/rigify_utils.py Modified: branches/render25/release/scripts/modules/rigify/arm_biped.py === --- branches/render25/release/scripts/modules/rigify/arm_biped.py 2010-04-19 13:37:44 UTC (rev 28285) +++ branches/render25/release/scripts/modules/rigify/arm_biped.py 2010-04-19 15:20:33 UTC (rev 28286) @@ -240,7 +240,7 @@ con.name = hinge con.target = obj con.subtarget = mt.shoulder -driver_fcurve = con.driver_add(influence, 0) +driver_fcurve = con.driver_add(influence) driver = driver_fcurve.driver Modified: branches/render25/release/scripts/modules/rigify/eye_balls.py === --- branches/render25/release/scripts/modules/rigify/eye_balls.py 2010-04-19 13:37:44 UTC (rev 28285) +++ branches/render25/release/scripts/modules/rigify/eye_balls.py 2010-04-19 15:20:33 UTC (rev 28286) @@ -57,7 +57,7 @@ if driver_s.data_path == driver_path: fcurve = driver_s if fcurve == None: -fcurve = obj.data.shape_keys.keys[name].driver_add(value, 0) +fcurve = obj.data.shape_keys.keys[name].driver_add(value) fcurve.driver.type = 'AVERAGE' new = True @@ -295,7 +295,7 @@ con.target = obj con.subtarget = head -fcurve = con.driver_add(influence, 0) +fcurve = con.driver_add(influence) driver = fcurve.driver driver.type = 'AVERAGE' mod = fcurve.modifiers[0] Modified: branches/render25/release/scripts/modules/rigify/eye_lid.py === --- branches/render25/release/scripts/modules/rigify/eye_lid.py 2010-04-19 13:37:44 UTC (rev 28285) +++ branches/render25/release/scripts/modules/rigify/eye_lid.py 2010-04-19 15:20:33 UTC (rev 28286) @@ -438,7 +438,7 @@ con.minimum = -distance*2 con.maximum = distance con.target_space = 'LOCAL' -fcurve = con.driver_add(influence, 0) +fcurve = con.driver_add(influence) driver = fcurve.driver driver.type = 'AVERAGE' var = driver.variables.new() @@ -457,7 +457,7 @@ con.minimum = -distance*2 con.maximum = distance con.target_space = 'LOCAL' -fcurve = con.driver_add(influence, 0) +fcurve = con.driver_add(influence) driver = fcurve.driver driver.type = 'AVERAGE' var = driver.variables.new() @@ -475,7 +475,7 @@ con.minimum = -distance*2 con.maximum = distance con.target_space = 'LOCAL' -fcurve = con.driver_add(influence, 0) +fcurve = con.driver_add(influence) driver = fcurve.driver driver.type = 'AVERAGE' var = driver.variables.new() @@ -493,7 +493,7 @@ con.minimum = -distance*2 con.maximum = distance con.target_space = 'LOCAL' -fcurve = con.driver_add(influence, 0) +fcurve = con.driver_add(influence) driver = fcurve.driver driver.type = 'AVERAGE' var = driver.variables.new() @@ -511,7 +511,7 @@ con.minimum = -distance*2 con.maximum = distance con.target_space = 'LOCAL' -fcurve = con.driver_add(influence, 0) +fcurve = con.driver_add(influence) driver = fcurve.driver driver.type = 'AVERAGE' var = driver.variables.new() @@ -530,7 +530,7 @@ con.minimum = -distance con.maximum = distance*2 con.target_space = 'LOCAL' -fcurve = con.driver_add(influence, 0) +fcurve = con.driver_add(influence) driver = fcurve.driver driver.type = 'AVERAGE' var = driver.variables.new() @@ -548,7 +548,7 @@
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28072] trunk/blender/release/scripts/ modules/rigify: Added tongue and neck rigs.
Revision: 28072 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=28072 Author: cessen Date: 2010-04-07 16:46:06 +0200 (Wed, 07 Apr 2010) Log Message: --- Added tongue and neck rigs. The neck rig is quite solid, I think, and is working well in production on Durian. The tongue rig is a bit hacky, but I'm adding it for now since we're using it in Durian. Also added pupil dilation to the eye rig type, and made the finger rig type work with two-digit fingers. Modified Paths: -- trunk/blender/release/scripts/modules/rigify/eye_balls.py trunk/blender/release/scripts/modules/rigify/finger_curl.py Added Paths: --- trunk/blender/release/scripts/modules/rigify/neck.py trunk/blender/release/scripts/modules/rigify/tongue.py Modified: trunk/blender/release/scripts/modules/rigify/eye_balls.py === --- trunk/blender/release/scripts/modules/rigify/eye_balls.py 2010-04-07 14:01:59 UTC (rev 28071) +++ trunk/blender/release/scripts/modules/rigify/eye_balls.py 2010-04-07 14:46:06 UTC (rev 28072) @@ -27,6 +27,85 @@ #METARIG_NAMES = (cpy,) RIG_TYPE = eye_balls +def addget_shape_key(obj, name=Key): + Fetches a shape key, or creates it if it doesn't exist + +# Create a shapekey set if it doesn't already exist +if obj.data.shape_keys is None: +shape = obj.add_shape_key(name=Basis, from_mix=False) +obj.active_shape_key_index = 0 + +# Get the shapekey, or create it if it doesn't already exist +if name in obj.data.shape_keys.keys: +shape_key = obj.data.shape_keys.keys[name] +else: +shape_key = obj.add_shape_key(name=name, from_mix=False) + +return shape_key + + +def addget_shape_key_driver(obj, name=Key): + Fetches the driver for the shape key, or creates it if it doesn't +already exist. + +driver_path = 'keys[' + name + '].value' +fcurve = None +driver = None +new = False +if obj.data.shape_keys.animation_data is not None: +for driver_s in obj.data.shape_keys.animation_data.drivers: +if driver_s.data_path == driver_path: +fcurve = driver_s +if fcurve == None: +fcurve = obj.data.shape_keys.keys[name].driver_add(value, 0) +fcurve.driver.type = 'AVERAGE' +new = True + +return fcurve, new + + +def create_shape_and_driver(obj, bone, meshes, shape_name, var_name, var_path, expression): + Creates/gets a shape key and sets up a driver for it. + +obj = armature object +bone = driving bone name +meshes = list of meshes to create the shapekey/driver on +shape_name = name of the shape key +var_name = name of the driving variable +var_path = path to the property on the bone to drive with +expression = python expression for the driver + +pb = obj.pose.bones +bpy.ops.object.mode_set(mode='OBJECT') + +for mesh_name in meshes: +mesh_obj = bpy.data.objects[mesh_name] + +# Add/get the shape key +shape = addget_shape_key(mesh_obj, name=shape_name) + +# Add/get the shape key driver +fcurve, a = addget_shape_key_driver(mesh_obj, name=shape_name) + +# Set up the driver +driver = fcurve.driver +driver.type = 'SCRIPTED' +driver.expression = expression + +# Get the variable, or create it if it doesn't already exist +if var_name in driver.variables: +var = driver.variables[var_name] +else: +var = driver.variables.new() +var.name = var_name + +# Set up the variable +var.type = SINGLE_PROP +var.targets[0].id_type = 'OBJECT' +var.targets[0].id = obj +var.targets[0].data_path = 'pose.bones[' + bone + ']' + var_path + + def mark_actions(): for action in bpy.data.actions: action.tag = True @@ -120,6 +199,12 @@ head = definitions[0] eye_target = definitions[1] +# Get list of pupil mesh objects +if mesh in options: +pupil_meshes = options[mesh].replace( , ).split(,) +else: +pupil_meshes = [] + # Get list of eyes if eyes in options: eye_base_names = options[eyes].replace( , ).split(,) @@ -246,9 +331,53 @@ con.minimum = 0.0 con.maximum = 2.0 con.target_space = 'LOCAL' + + +# Get/create the shape keys and drivers for pupil dilation +shape_names = [PUPILS-dilate_wide, PUPILS-dilate_narrow] +slider_name = pupil_dilate + +# Set up the custom property on the bone +prop = rna_idprop_ui_prop_get(pb[target_ctrl], slider_name, create=True) +pb[target_ctrl][slider_name] = 0.0 +prop[min] = 0.0 +prop[max] = 1.0 +prop[soft_min] = 0.0 +prop[soft_max] = 1.0 +if len(shape_names) 1: +prop[min] = -1.0 +prop[soft_min] =
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27089] trunk/blender/release/scripts/ modules/rigify: Made a more generic rig type for giving animators direct control over shape keys .
Revision: 27089 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=27089 Author: cessen Date: 2010-02-22 19:07:16 +0100 (Mon, 22 Feb 2010) Log Message: --- Made a more generic rig type for giving animators direct control over shape keys. With this rig type you can attach shape keys both to the transforms of the bone and any number custom properties on the bone. Modified Paths: -- trunk/blender/release/scripts/modules/rigify/leg_quadruped.py Added Paths: --- trunk/blender/release/scripts/modules/rigify/shape_key_control.py Removed Paths: - trunk/blender/release/scripts/modules/rigify/shape_key_transforms.py Modified: trunk/blender/release/scripts/modules/rigify/leg_quadruped.py === --- trunk/blender/release/scripts/modules/rigify/leg_quadruped.py 2010-02-22 16:34:27 UTC (rev 27088) +++ trunk/blender/release/scripts/modules/rigify/leg_quadruped.py 2010-02-22 18:07:16 UTC (rev 27089) @@ -129,6 +129,9 @@ # keep the foot_ik as the parent ik_chain.toe_e.connected = False + +# Foot uses pose space, not local space, for translation +ik_chain.foot_e.local_location = False # must be after disconnecting the toe ik_chain.foot_e.align_orientation(mt_chain.toe_e) @@ -259,6 +262,8 @@ con = ik.foot_roll_01_p.constraints.new('COPY_ROTATION') con.target = obj con.subtarget = ik.foot_roll +con.target_space = 'LOCAL' +con.owner_space = 'LOCAL' # IK Copied: trunk/blender/release/scripts/modules/rigify/shape_key_control.py (from rev 27075, trunk/blender/release/scripts/modules/rigify/shape_key_transforms.py) === --- trunk/blender/release/scripts/modules/rigify/shape_key_control.py (rev 0) +++ trunk/blender/release/scripts/modules/rigify/shape_key_control.py 2010-02-22 18:07:16 UTC (rev 27089) @@ -0,0 +1,320 @@ +# # BEGIN GPL LICENSE BLOCK # +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# # END GPL LICENSE BLOCK # + +# pep8 compliant + +import bpy +from rigify import RigifyError +from rigify_utils import copy_bone_simple +from rna_prop_ui import rna_idprop_ui_prop_get + +#METARIG_NAMES = (cpy,) +RIG_TYPE = shape_key_control + + +def addget_shape_key(obj, name=Key): + Fetches a shape key, or creates it if it doesn't exist + +# Create a shapekey set if it doesn't already exist +if obj.data.shape_keys is None: +shape = obj.add_shape_key(name=Basis, from_mix=False) +obj.active_shape_key_index = 0 + +# Get the shapekey, or create it if it doesn't already exist +if name in obj.data.shape_keys.keys: +shape_key = obj.data.shape_keys.keys[name] +else: +shape_key = obj.add_shape_key(name=name, from_mix=False) + +return shape_key + + +def addget_shape_key_driver(obj, name=Key): + Fetches the driver for the shape key, or creates it if it doesn't +already exist. + +driver_path = 'keys[' + name + '].value' +fcurve = None +driver = None +new = False +if obj.data.shape_keys.animation_data is not None: +for driver_s in obj.data.shape_keys.animation_data.drivers: +if driver_s.data_path == driver_path: +fcurve = driver_s +if fcurve == None: +fcurve = obj.data.shape_keys.keys[name].driver_add(value, 0) +fcurve.driver.type = 'AVERAGE' +new = True + +return fcurve, new + + +# TODO: +def metarig_template(): +# generated by rigify.write_meta_rig +#bpy.ops.object.mode_set(mode='EDIT') +#obj = bpy.context.active_object +#arm = obj.data +#bone = arm.edit_bones.new('Bone') +#bone.head[:] = 0., 0., 0. +#bone.tail[:] = 0., 0., 1. +#bone.roll = 0. +#bone.connected = False +# +#bpy.ops.object.mode_set(mode='OBJECT') +#pbone = obj.pose.bones['Bone'] +#pbone['type'] = 'copy' +pass + + +def metarig_definition(obj, orig_bone_name): +bone = obj.data.bones[orig_bone_name] +return [bone.name] + + +def main(obj, definitions, base_names, options): + A rig that drives
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26935] trunk/blender/release/scripts/ modules/rigify/tail_control.py: Rigify:
Revision: 26935 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=26935 Author: cessen Date: 2010-02-15 17:46:24 +0100 (Mon, 15 Feb 2010) Log Message: --- Rigify: Added a tail control rig. For now, you have to manually hook the resulting controls up to a separate spline IK rig that you make by hand. Perhaps this can be automated in the future. For anyone using this: keep in mind that you need separate armatures for the tail deformation bones and tail control bones. Otherwise you create a cyclic dependency like so: tail deform bones - spline object - tail control bones Added Paths: --- trunk/blender/release/scripts/modules/rigify/tail_control.py Added: trunk/blender/release/scripts/modules/rigify/tail_control.py === --- trunk/blender/release/scripts/modules/rigify/tail_control.py (rev 0) +++ trunk/blender/release/scripts/modules/rigify/tail_control.py 2010-02-15 16:46:24 UTC (rev 26935) @@ -0,0 +1,166 @@ +# # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# # END GPL LICENSE BLOCK # + +# pep8 compliant + +import bpy +from rigify import RigifyError +from rigify_utils import bone_class_instance, copy_bone_simple +from rna_prop_ui import rna_idprop_ui_prop_get +from Mathutils import Vector, RotationMatrix +from math import radians, pi + +# not used, defined for completeness +METARIG_NAMES = (pelvis, ribcage) + + +def metarig_template(): +# TODO +pass +# generated by rigify.write_meta_rig +#bpy.ops.object.mode_set(mode='EDIT') +#obj = bpy.context.active_object +#arm = obj.data +#bone = arm.edit_bones.new('tail.01') +#bone.head[:] = 0., -0.0306, 0.1039 +#bone.tail[:] = 0., -0.0306, -0.0159 +#bone.roll = 0. +#bone.connected = False + +#bpy.ops.object.mode_set(mode='OBJECT') +#pbone = obj.pose.bones['tail.01'] +#pbone['type'] = 'tail_spline_ik' + + +def metarig_definition(obj, orig_bone_name): + Collects and returns the relevent bones for the rig. +The bone given is the first in the chain of tail bones. +It includes bones in the chain up until it hits a bone that doesn't +have the same name base. + +tail.01 - tail.02 - tail.03 - ... - tail.n + +arm = obj.data +tail_base = arm.bones[orig_bone_name] + +if tail_base.parent == None: +raise RigifyError('tail_control' rig type on bone '%s' requires a parent. % orig_bone_name) + +bone_definitions = [tail_base.name] +bone_definitions.extend([child.name for child in tail_base.children_recursive_basename]) +return bone_definitions + + +def main(obj, bone_definitions, base_names, options): +bpy.ops.object.mode_set(mode='EDIT') +arm = obj.data +bb = obj.data.bones +eb = obj.data.edit_bones +pb = obj.pose.bones + +# Create bones for hinge/free +# hinge 1 sticks with the parent +# hinge 2 is the parent of the tail controls +hinge1 = copy_bone_simple(arm, bone_definitions[0], MCH-%s.hinge1 % base_names[bone_definitions[0]], parent=True).name +hinge2 = copy_bone_simple(arm, bone_definitions[0], MCH-%s.hinge2 % base_names[bone_definitions[0]], parent=False).name + +# Create tail control bones +bones = [] +i = 0 +for bone_def in bone_definitions: +bone = copy_bone_simple(arm, bone_def, base_names[bone_def], parent=True).name +if i == 1: # Don't change parent of first tail bone +eb[bone].connected = False +eb[bone].parent = eb[hinge2] +eb[bone].local_location = False +i = 1 +bones += [bone] + + +bpy.ops.object.mode_set(mode='OBJECT') + +# Rotation mode and axis locks +for bone, org_bone in zip(bones, bone_definitions): +pb[bone].rotation_mode = pb[org_bone].rotation_mode +pb[bone].lock_location = tuple(pb[org_bone].lock_location) +pb[bone].lock_rotations_4d = pb[org_bone].lock_rotations_4d +pb[bone].lock_rotation = tuple(pb[org_bone].lock_rotation) +pb[bone].lock_rotation_w = pb[org_bone].lock_rotation_w +pb[bone].lock_scale =
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26582] trunk/blender/release/scripts/ modules/rigify/shape_key_transforms.py: Added a new rig type shape_key_transforms that drives shape keys bas
Revision: 26582 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=26582 Author: cessen Date: 2010-02-03 16:40:56 +0100 (Wed, 03 Feb 2010) Log Message: --- Added a new rig type shape_key_transforms that drives shape keys based on the local transforms of a single bone. Quite useful in a variety of situations. Required options: mesh: name of mesh object(s) to add/get shapekeys to/from (if multiple objects, make a comma-separated list) Optional options: loc_x/y/z: name of the shape key to tie to translation of the bone loc_x/y/z_fac: default multiplier of the bone influence on the shape key rot_x/y/z: name of the shape key to tie to rotation of the bone rot_x/y/z_fac: default multiplier of the bone influence on the shape key scale_x/y/z: name of the shape key to tie to scale of the bone scale_x/y/z_fac: default multiplier of the bone influence on the shape key Added Paths: --- trunk/blender/release/scripts/modules/rigify/shape_key_transforms.py Added: trunk/blender/release/scripts/modules/rigify/shape_key_transforms.py === --- trunk/blender/release/scripts/modules/rigify/shape_key_transforms.py (rev 0) +++ trunk/blender/release/scripts/modules/rigify/shape_key_transforms.py 2010-02-03 15:40:56 UTC (rev 26582) @@ -0,0 +1,263 @@ +# # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# # END GPL LICENSE BLOCK # + +# pep8 compliant + +import bpy +from rigify import RigifyError +from rigify_utils import copy_bone_simple +from rna_prop_ui import rna_idprop_ui_prop_get + +#METARIG_NAMES = (cpy,) +RIG_TYPE = shape_key_transforms + + +def addget_shape_key(obj, name=Key): + Fetches a shape key, or creates it if it doesn't exist + +# Create a shapekey set if it doesn't already exist +if obj.data.shape_keys is None: +shape = obj.add_shape_key(name=Basis, from_mix=False) +obj.active_shape_key_index = 0 + +# Get the shapekey, or create it if it doesn't already exist +if name in obj.data.shape_keys.keys: +shape_key = obj.data.shape_keys.keys[name] +else: +shape_key = obj.add_shape_key(name=name, from_mix=False) + +return shape_key + + +def addget_shape_key_driver(obj, name=Key): + Fetches the driver for the shape key, or creates it if it doesn't +already exist. + +driver_path = 'keys[' + name + '].value' +fcurve = None +driver = None +new = False +if obj.data.shape_keys.animation_data is not None: +for driver_s in obj.data.shape_keys.animation_data.drivers: +if driver_s.data_path == driver_path: +fcurve = driver_s +if fcurve == None: +fcurve = obj.data.shape_keys.keys[name].driver_add(value, 0) +fcurve.driver.type = 'AVERAGE' +new = True + +return fcurve, new + + +# TODO: +def metarig_template(): +# generated by rigify.write_meta_rig +#bpy.ops.object.mode_set(mode='EDIT') +#obj = bpy.context.active_object +#arm = obj.data +#bone = arm.edit_bones.new('Bone') +#bone.head[:] = 0., 0., 0. +#bone.tail[:] = 0., 0., 1. +#bone.roll = 0. +#bone.connected = False +# +#bpy.ops.object.mode_set(mode='OBJECT') +#pbone = obj.pose.bones['Bone'] +#pbone['type'] = 'copy' +pass + + +def metarig_definition(obj, orig_bone_name): +bone = obj.data.bones[orig_bone_name] +return [bone.name] + + +def main(obj, definitions, base_names, options): + A rig that drives shape keys with the local transforms of a single bone. + +Required options: +mesh: name of mesh object(s) to add/get shapekeys to/from + (if multiple objects, make a comma-separated list) +Optional options: +loc_x/y/z: name of the shape key to tie to translation of the bone +loc_x/y/z_fac: default multiplier of the bone influence on the shape key +rot_x/y/z: name of the shape key to tie to rotation of the bone +rot_x/y/z_fac: default multiplier of the bone
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26583] trunk/blender/release/scripts/ modules/rigify/shape_key_transforms.py: Eh...
Revision: 26583 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=26583 Author: cessen Date: 2010-02-03 16:44:19 +0100 (Wed, 03 Feb 2010) Log Message: --- Eh... stupid me. Left a duplicate main function in the rig type. (Tail between legs, walks away shamefully.) Modified Paths: -- trunk/blender/release/scripts/modules/rigify/shape_key_transforms.py Modified: trunk/blender/release/scripts/modules/rigify/shape_key_transforms.py === --- trunk/blender/release/scripts/modules/rigify/shape_key_transforms.py 2010-02-03 15:40:56 UTC (rev 26582) +++ trunk/blender/release/scripts/modules/rigify/shape_key_transforms.py 2010-02-03 15:44:19 UTC (rev 26583) @@ -254,10 +254,3 @@ var_fac.targets[0].id = obj var_fac.targets[0].data_path = 'pose.bones[' + bone + '][' + fac_name + ']' - -def main(obj, bone_definition, base_names, options): -control(obj, bone_definition, base_names, options) - - -return (None,) - ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26559] trunk/blender/release/scripts/ modules/rigify/mouth.py: Updates to mouth rig.
Revision: 26559 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=26559 Author: cessen Date: 2010-02-02 18:57:12 +0100 (Tue, 02 Feb 2010) Log Message: --- Updates to mouth rig. Old method didn't work well in combination with shape keys. This new method (effectively just weighting directly to the lip control bones) is much simpler, but also requires more manual weight painting to get it to look right. Modified Paths: -- trunk/blender/release/scripts/modules/rigify/mouth.py Modified: trunk/blender/release/scripts/modules/rigify/mouth.py === --- trunk/blender/release/scripts/modules/rigify/mouth.py 2010-02-02 17:41:32 UTC (rev 26558) +++ trunk/blender/release/scripts/modules/rigify/mouth.py 2010-02-02 17:57:12 UTC (rev 26559) @@ -71,15 +71,17 @@ driver_path = 'keys[' + name + '].value' fcurve = None driver = None +new = False if obj.data.shape_keys.animation_data is not None: for driver_s in obj.data.shape_keys.animation_data.drivers: if driver_s.data_path == driver_path: fcurve = driver_s if fcurve == None: fcurve = obj.data.shape_keys.keys[name].driver_add(value, 0) -fcurve.driver.type = 'AVERAGE' +fcurve.driver.type = 'AVERAGE' +new = True -return fcurve +return fcurve, new def metarig_template(): @@ -132,88 +134,42 @@ meshes = options[mesh].replace( , ).split(,) -# Upper lip MCH -lip1 = make_lip_stretch_bone(obj, MCH-lip, definitions[3], definitions[2], 0.0) -lip2 = make_lip_stretch_bone(obj, MCH-lip, definitions[4], definitions[3], 0.0) -lip22 = make_lip_stretch_bone(obj, MCH-lip, definitions[5], definitions[4], 0.0) -lip33 = make_lip_stretch_bone(obj, MCH-lip, definitions[3], definitions[4], 0.0) -lip3 = make_lip_stretch_bone(obj, MCH-lip, definitions[4], definitions[5], 0.0) -lip4 = make_lip_stretch_bone(obj, MCH-lip, definitions[5], definitions[6], 0.0) +# Lip DEF +lip1 = copy_bone_simple(obj.data, definitions[2], DEF- + base_names[definitions[2]]).name +lip2 = copy_bone_simple(obj.data, definitions[3], DEF- + base_names[definitions[3]]).name +lip3 = copy_bone_simple(obj.data, definitions[4], DEF- + base_names[definitions[4]]).name +lip4 = copy_bone_simple(obj.data, definitions[5], DEF- + base_names[definitions[5]]).name +lip5 = copy_bone_simple(obj.data, definitions[6], DEF- + base_names[definitions[6]]).name +lip6 = copy_bone_simple(obj.data, definitions[7], DEF- + base_names[definitions[7]]).name +lip7 = copy_bone_simple(obj.data, definitions[8], DEF- + base_names[definitions[8]]).name +lip8 = copy_bone_simple(obj.data, definitions[9], DEF- + base_names[definitions[9]]).name -eb[lip1].parent = eb[definitions[3]] -eb[lip2].parent = eb[definitions[4]] -eb[lip22].parent = eb[definitions[5]] -eb[lip33].parent = eb[definitions[3]] -eb[lip3].parent = eb[definitions[4]] -eb[lip4].parent = eb[definitions[5]] +# Mouth corner spread bones (for driving corrective shape keys) +spread_l_1 = copy_bone_simple(obj.data, definitions[6], MCH- + base_names[definitions[6]] + .spread_1).name +spread_l_2 = copy_bone_simple(obj.data, definitions[6], MCH- + base_names[definitions[6]] + .spread_2).name +eb[spread_l_1].tail = eb[definitions[5]].head +eb[spread_l_2].tail = eb[definitions[5]].head +eb[spread_l_1].roll = 0 +eb[spread_l_2].roll = 0 +eb[spread_l_1].connected = False +eb[spread_l_2].connected = False +eb[spread_l_1].parent = eb[definitions[6]] +eb[spread_l_2].parent = eb[definitions[6]] -eb[lip22].bbone_segments = 8 -eb[lip33].bbone_segments = 8 +spread_r_1 = copy_bone_simple(obj.data, definitions[2], MCH- + base_names[definitions[2]] + .spread_1).name +spread_r_2 = copy_bone_simple(obj.data, definitions[2], MCH- + base_names[definitions[2]] + .spread_2).name +eb[spread_r_1].tail = eb[definitions[3]].head +eb[spread_r_2].tail = eb[definitions[3]].head +eb[spread_r_1].roll = 0 +eb[spread_r_2].roll = 0 +eb[spread_r_1].connected = False +eb[spread_r_2].connected = False +eb[spread_r_1].parent = eb[definitions[2]] +eb[spread_r_2].parent = eb[definitions[2]] -# Lower lip MCH -lip5 = make_lip_stretch_bone(obj, MCH-lip, definitions[7], definitions[6], 0.0) -lip6 = make_lip_stretch_bone(obj, MCH-lip, definitions[8], definitions[7], 0.0) -lip66 = make_lip_stretch_bone(obj, MCH-lip, definitions[9], definitions[8], 0.0) -lip77 = make_lip_stretch_bone(obj, MCH-lip, definitions[7], definitions[8], 0.0) -lip7 = make_lip_stretch_bone(obj, MCH-lip, definitions[8], definitions[9], 0.0) -lip8 = make_lip_stretch_bone(obj, MCH-lip, definitions[9], definitions[2], 0.0) -eb[lip5].parent =
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26289] trunk/blender/release/scripts/ modules/rigify: Rigify:
Revision: 26289 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=26289 Author: cessen Date: 2010-01-26 12:17:41 +0100 (Tue, 26 Jan 2010) Log Message: --- Rigify: - Removed control-shape deformation bones from the spine rig (no longer necessary thanks to the new custom shape at feature). - Various improvements to the mouth rig, including a corrective shape key for mouth-open. - The new method of generating into the same armature object every time wasn't copying pose bone data in the process, such as rotation mode and transform locks. Modified Paths: -- trunk/blender/release/scripts/modules/rigify/__init__.py trunk/blender/release/scripts/modules/rigify/mouth.py trunk/blender/release/scripts/modules/rigify/spine_pivot_flex.py Modified: trunk/blender/release/scripts/modules/rigify/__init__.py === --- trunk/blender/release/scripts/modules/rigify/__init__.py2010-01-26 11:15:45 UTC (rev 26288) +++ trunk/blender/release/scripts/modules/rigify/__init__.py2010-01-26 11:17:41 UTC (rev 26289) @@ -231,11 +231,32 @@ obj.selected = True scene.objects.active = obj -# Copy over the pose_bone custom properties +# Copy over the pose_bone properties for bone in obj_orig.pose.bones: +bone_gen = obj.pose.bones[bone.name] + +# Rotation mode and transform locks +bone_gen.rotation_mode = bone.rotation_mode +bone_gen.lock_rotation = tuple(bone.lock_rotation) +bone_gen.lock_rotation_w = bone.lock_rotation_w +bone_gen.lock_rotations_4d = bone.lock_rotations_4d +bone_gen.lock_location = tuple(bone.lock_location) +bone_gen.lock_scale= tuple(bone.lock_scale) + +# Custom properties for prop in bone.keys(): -obj.pose.bones[bone.name][prop] = bone[prop] +bone_gen[prop] = bone[prop] +# Copy over bone properties +for bone in obj_orig.data.bones: +bone_gen = obj.data.bones[bone.name] + +# B-bone stuff +bone_gen.bbone_segments = bone.bbone_segments +bone_gen.bbone_in = bone.bbone_in +bone_gen.bbone_out = bone.bbone_out + + # Create proxy deformation rig # TODO: remove this if META_DEF: Modified: trunk/blender/release/scripts/modules/rigify/mouth.py === --- trunk/blender/release/scripts/modules/rigify/mouth.py 2010-01-26 11:15:45 UTC (rev 26288) +++ trunk/blender/release/scripts/modules/rigify/mouth.py 2010-01-26 11:17:41 UTC (rev 26289) @@ -119,8 +119,11 @@ bpy.ops.object.mode_set(mode='EDIT') eb = obj.data.edit_bones +bb = obj.data.bones pb = obj.pose.bones +jaw = definitions[1] + # Options req_options = [mesh] for option in req_options: @@ -210,6 +213,16 @@ eb[dlip7].bbone_segments = 8 eb[dlip8].bbone_segments = 8 +# Jaw open bones +jopen1 = copy_bone_simple(obj.data, jaw, MCH-+base_names[jaw]+.track1, parent=True).name +eb[jopen1].connected = False +eb[jopen1].head = eb[jaw].tail +eb[jopen1].tail = eb[jopen1].head + Vector(0, 0, eb[jaw].length/4) + +jopen2 = copy_bone_simple(obj.data, jopen1, MCH-+base_names[jaw]+.track2).name +eb[jopen2].parent = eb[jaw] + + bpy.ops.object.mode_set(mode='OBJECT') # Constraints @@ -255,8 +268,7 @@ bpy.ops.object.mode_set(mode='OBJECT') - -# Left side +# Left side shape key for mesh_name in meshes: mesh_obj = bpy.data.objects[mesh_name] shape_key_name = COR- + base_names[definitions[4]] + .L.spread @@ -278,10 +290,8 @@ # Set up the variable var.type = ROTATION_DIFF -#var.targets[0].id_type = 'OBJECT' var.targets[0].id = obj var.targets[0].bone_target = lip4 -#var.targets[1].id_type = 'OBJECT' var.targets[1].id = obj var.targets[1].bone_target = lip5 @@ -291,7 +301,7 @@ mod.coefficients[0] = -rotdiff_l / (pi-rotdiff_l) mod.coefficients[1] = 1 / (pi-rotdiff_l) -# Right side +# Right side shape key for mesh_name in meshes: mesh_obj = bpy.data.objects[mesh_name] shape_key_name = COR- + base_names[definitions[4]] + .R.spread @@ -313,10 +323,8 @@ # Set up the variable var.type = ROTATION_DIFF -#var.targets[0].id_type = 'OBJECT' var.targets[0].id = obj var.targets[0].bone_target = lip1 -#var.targets[1].id_type = 'OBJECT' var.targets[1].id = obj var.targets[1].bone_target = lip8 @@ -325,7 +333,38 @@ if rotdiff_r != pi: mod.coefficients[0] = -rotdiff_r / (pi-rotdiff_r)
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26248] trunk/blender/release/scripts/ modules/rigify: Rigify now generates the rig into the same armature every time, so you don 't have to re-hook-u
Revision: 26248 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=26248 Author: cessen Date: 2010-01-25 15:19:12 +0100 (Mon, 25 Jan 2010) Log Message: --- Rigify now generates the rig into the same armature every time, so you don't have to re-hook-up things like armature modifiers, parenting, etc. By default the generated rig object is named rig. But you can add a custom rig_object_name property to the metarig to specify the name of the object to generate into. Modified Paths: -- trunk/blender/release/scripts/modules/rigify/__init__.py trunk/blender/release/scripts/modules/rigify/arm_biped.py trunk/blender/release/scripts/modules/rigify/leg_biped.py trunk/blender/release/scripts/modules/rigify/mouth.py Modified: trunk/blender/release/scripts/modules/rigify/__init__.py === --- trunk/blender/release/scripts/modules/rigify/__init__.py2010-01-25 13:19:52 UTC (rev 26247) +++ trunk/blender/release/scripts/modules/rigify/__init__.py2010-01-25 14:19:12 UTC (rev 26248) @@ -154,6 +154,8 @@ from collections import OrderedDict import rigify_utils reload(rigify_utils) + +print(Begin...) # Not needed but catches any errors before duplicating validate_rig(context, obj_orig) @@ -164,23 +166,85 @@ rest_backup = obj_orig.data.pose_position obj_orig.data.pose_position = 'REST' - bpy.ops.object.mode_set(mode='OBJECT') scene = context.scene -# copy object and data +# Check if the generated rig already exists, so we can +# regenerate in the same object. If not, create a new +# object to generate the rig in. +print(Fetch rig.) +try: +name = obj_orig[rig_object_name] +except KeyError: +name = rig + +try: +obj = scene.objects[name] +except KeyError: +obj = bpy.data.objects.new(name, type='ARMATURE') +obj.data = bpy.data.armatures.new(name) +scene.objects.link(obj) + +obj.data.pose_position = 'POSE' + +# Get rid of anim data in case the rig already existed +print(Clear rig animation data.) +obj.animation_data_clear() + +# Select generated rig object obj_orig.selected = False -obj = obj_orig.copy() -obj.data = obj_orig.data.copy() -scene.objects.link(obj) +obj.selected = True scene.objects.active = obj + +# Remove all bones from the generated rig armature. +bpy.ops.object.mode_set(mode='EDIT') +for bone in obj.data.edit_bones: +obj.data.edit_bones.remove(bone) +bpy.ops.object.mode_set(mode='OBJECT') + +# Create temporary duplicates for merging +temp_rig_1 = obj_orig.copy() +temp_rig_1.data = obj_orig.data.copy() +scene.objects.link(temp_rig_1) + +temp_rig_2 = obj_orig.copy() +temp_rig_2.data = obj.data +scene.objects.link(temp_rig_2) + +# Select the temp rigs for merging +for objt in scene.objects: +objt.selected = False # deselect all objects +temp_rig_1.selected = True +temp_rig_2.selected = True +scene.objects.active = temp_rig_2 + +# Merge the temporary rigs +bpy.ops.object.join(context) + +# Delete the second temp rig +bpy.ops.object.delete() + +# Select the generated rig +for objt in scene.objects: +objt.selected = False # deselect all objects obj.selected = True - +scene.objects.active = obj + +# Copy over the pose_bone custom properties +for bone in obj_orig.pose.bones: +for prop in bone.keys(): +obj.pose.bones[bone.name][prop] = bone[prop] + +# Create proxy deformation rig +# TODO: remove this if META_DEF: obj_def = obj_orig.copy() obj_def.data = obj_orig.data.copy() scene.objects.link(obj_def) + +scene.update() +print(On to the real work.) arm = obj.data @@ -255,7 +319,7 @@ # for pbone in obj.pose.bones: for pbone in bones_sorted: bone_name = pbone.name - +print(bone_name) if bone_name not in bone_typeinfos: continue @@ -268,6 +332,7 @@ bone_names_pre = {bone.name for bone in arm.bones} for type_name, type_func in bone_typeinfos[bone_name]: +print( + type_name) # this bones definition of the current typeinfo definition = bone_def_dict[type_name] options = get_bone_type_options(pbone, type_name) @@ -386,7 +451,10 @@ bpy.ops.object.mode_set(mode=mode_orig) obj_orig.data.pose_position = rest_backup obj.data.pose_position = 'POSE' +obj_orig.data.pose_position = 'POSE' context.user_preferences.edit.global_undo = global_undo + +print(Done.\n) return obj Modified: trunk/blender/release/scripts/modules/rigify/arm_biped.py
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26115] trunk/blender/release/scripts/ modules/rigify: Added eyeball and eyelid rig types to rigify.
Revision: 26115 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=26115 Author: cessen Date: 2010-01-19 19:52:45 +0100 (Tue, 19 Jan 2010) Log Message: --- Added eyeball and eyelid rig types to rigify. (First commit! Let's hope this works!) Added Paths: --- trunk/blender/release/scripts/modules/rigify/eye_balls.py trunk/blender/release/scripts/modules/rigify/eye_lid.py Added: trunk/blender/release/scripts/modules/rigify/eye_balls.py === --- trunk/blender/release/scripts/modules/rigify/eye_balls.py (rev 0) +++ trunk/blender/release/scripts/modules/rigify/eye_balls.py 2010-01-19 18:52:45 UTC (rev 26115) @@ -0,0 +1,277 @@ +# # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# # END GPL LICENSE BLOCK # + +# pep8 compliant + +import bpy +from rna_prop_ui import rna_idprop_ui_prop_get +from math import acos +from Mathutils import Vector +from rigify import get_layer_dict +from rigify_utils import bone_class_instance, copy_bone_simple + +#METARIG_NAMES = (cpy,) +RIG_TYPE = eye_balls + +def mark_actions(): +for action in bpy.data.actions: +action.tag = True + +def get_unmarked_action(): +for action in bpy.data.actions: +if action.tag != True: +return action +return None + +def add_action(name=None): +mark_actions() +bpy.ops.action.new() +action = get_unmarked_action() +if name is not None: +action.name = name +return action + + +def metarig_template(): +# generated by rigify.write_meta_rig +bpy.ops.object.mode_set(mode='EDIT') +obj = bpy.context.active_object +arm = obj.data +bone = arm.edit_bones.new('Bone') +bone.head[:] = 0., 0., 0. +bone.tail[:] = 0., 0., 1. +bone.roll = 0. +bone.connected = False + +bpy.ops.object.mode_set(mode='OBJECT') +pbone = obj.pose.bones['Bone'] +pbone['type'] = 'copy' + + +def metarig_definition(obj, orig_bone_name): +bone = obj.data.bones[orig_bone_name] +chain = [] + +try: +chain += [bone.parent.name, bone.name] +except AttributeError: +raise RigifyError('%s' rig type requires a parent (bone: %s) % (RIG_TYPE, base_names[0])) + +return chain + + +def deform(obj, definitions, base_names, options): +bpy.ops.object.mode_set(mode='EDIT') + +eb = obj.data.edit_bones +pb = obj.pose.bones + +# Get list of eyes +if eyes in options: +eye_base_names = options[eyes].replace( , ).split(,) +else: +eye_base_names = [] + +# Get their ORG- names +eyes = [] +for name in eye_base_names: +eyes += [ORG-+name] + +# Duplicate the eyes to make deformation bones +def_eyes = [] # def/org pairs +for eye in eyes: +def_eyes += [(copy_bone_simple(obj.data, eye, DEF-+base_names[eye], parent=True).name, eye)] + + +bpy.ops.object.mode_set(mode='OBJECT') + +# Constraints +for eye in def_eyes: +con = pb[eye[0]].constraints.new('COPY_TRANSFORMS') +con.target = obj +con.subtarget = eye[1] + +return (None,) + + + + +def control(obj, definitions, base_names, options): +bpy.ops.object.mode_set(mode='EDIT') + +eb = obj.data.edit_bones +bb = obj.data.bones +pb = obj.pose.bones + +head = definitions[0] +eye_target = definitions[1] + +# Get list of eyes +if eyes in options: +eye_base_names = options[eyes].replace( , ).split(,) +else: +eye_base_names = [] + +# Get their ORG- names +eyes = [] +for name in eye_base_names: +eyes += [ORG-+name] + +# Get the average position of the eyes +center = Vector(0,0,0) +for eye in eyes: +center += eb[eye].head +if len(eyes) != 0: +center /= len(eyes) + +# Get the average length of the eyes +length = 0.0 +for eye in eyes: +length += eb[eye].length +if len(eyes) == 0: +length = 1.0 +else: +length /= len(eyes) + + +# Make the mind's eye +minds_eye =
[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26116] trunk/blender/release/scripts/ modules: Rigify:
Revision: 26116 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=revroot=bf-blenderrevision=26116 Author: cessen Date: 2010-01-19 20:07:09 +0100 (Tue, 19 Jan 2010) Log Message: --- Rigify: - Added two driven-shape-key rig types that create and drive shape keys on a mesh/meshes based on the distance or rotation difference between two bones. - Fixed bug in finger curl rig type where secondary finger controls were not created. Finger type can also now (optionally) have a hinge switch (useful when using it for wings). - Changed the blending system in rigify_utils to use copy_transforms constraints instead of copy_loc+copy_rot. - Finished the quadruped leg type. Now has both ik and fk control and ik/fk switching. Also uses a rotating bone to control the knee direction instead of a pole target (seems to work more consistently for quadruped setups). There's still one annoying bug regarding foot roll, but it's not blocking. I'll track it down later. - Mouth rig now creates corrective shape keys on the face mesh for dealing with mouth corners when they spread open. - Biped arm and leg types now cause mesh to scale when you scale the fk controls. - Misc improvements to the rig types. Modified Paths: -- trunk/blender/release/scripts/modules/rigify/arm_biped.py trunk/blender/release/scripts/modules/rigify/finger_curl.py trunk/blender/release/scripts/modules/rigify/leg_biped.py trunk/blender/release/scripts/modules/rigify/leg_quadruped.py trunk/blender/release/scripts/modules/rigify/mouth.py trunk/blender/release/scripts/modules/rigify/neck_flex.py trunk/blender/release/scripts/modules/rigify/palm_curl.py trunk/blender/release/scripts/modules/rigify/spine_pivot_flex.py trunk/blender/release/scripts/modules/rigify_utils.py Added Paths: --- trunk/blender/release/scripts/modules/rigify/shape_key_distance.py trunk/blender/release/scripts/modules/rigify/shape_key_rotdiff.py Modified: trunk/blender/release/scripts/modules/rigify/arm_biped.py === --- trunk/blender/release/scripts/modules/rigify/arm_biped.py 2010-01-19 18:52:45 UTC (rev 26115) +++ trunk/blender/release/scripts/modules/rigify/arm_biped.py 2010-01-19 19:07:09 UTC (rev 26116) @@ -223,6 +223,7 @@ fk_chain.forearm_p.rotation_mode = 'XYZ' fk_chain.forearm_p.lock_rotation = (False, True, True) fk_chain.hand_p.rotation_mode = 'ZXY' +fk_chain.arm_p.lock_location = True, True, True con = fk_chain.arm_p.constraints.new('COPY_LOCATION') con.target = obj @@ -276,8 +277,15 @@ fk_chain.arm_b.layer = layer fk_chain.forearm_b.layer = layer fk_chain.hand_b.layer= layer - + +# Forearm was getting wrong roll somehow. Hack to fix that. bpy.ops.object.mode_set(mode='EDIT') +fk_chain.update() +mt.update() +fk_chain.forearm_e.roll = mt.forearm_e.roll +bpy.ops.object.mode_set(mode='OBJECT') + +bpy.ops.object.mode_set(mode='EDIT') return None, fk_chain.arm, fk_chain.forearm, fk_chain.hand @@ -338,6 +346,11 @@ con.target = obj con.subtarget = definitions[2] +con = uarm1.constraints.new('COPY_SCALE') +con.name = trackto +con.target = obj +con.subtarget = definitions[1] + con = uarm2.constraints.new('COPY_ROTATION') con.name = copy_rot con.target = obj @@ -349,6 +362,11 @@ con.target = obj con.subtarget = definitions[2] +con = farm1.constraints.new('COPY_SCALE') +con.name = copy_rot +con.target = obj +con.subtarget = definitions[2] + con = farm2.constraints.new('COPY_ROTATION') con.name = copy_rot con.target = obj Modified: trunk/blender/release/scripts/modules/rigify/finger_curl.py === --- trunk/blender/release/scripts/modules/rigify/finger_curl.py 2010-01-19 18:52:45 UTC (rev 26115) +++ trunk/blender/release/scripts/modules/rigify/finger_curl.py 2010-01-19 19:07:09 UTC (rev 26116) @@ -150,103 +150,171 @@ def main(obj, bone_definition, base_names, options): # *** EDITMODE - +bpy.ops.object.mode_set(mode='EDIT') + # get assosiated data arm = obj.data -orig_ebone = arm.edit_bones[bone_definition[0]] +bb = obj.data.bones +eb = obj.data.edit_bones +pb = obj.pose.bones + +org_f1 = bone_definition[0] # Original finger bone 01 +org_f2 = bone_definition[1] # Original finger bone 02 +org_f3 = bone_definition[2] # Original finger bone 03 + +# Check options +if bend_ratio in options: +bend_ratio = options[bend_ratio] +else: +bend_ratio = 0.4 + +yes = [1, 1.0, True, True, true, Yes, yes] +make_hinge = False +if (hinge in options) and (eb[org_f1].parent is not None): +if options[hinge] in yes: +make_hinge = True -