~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/modifiers/intern/MOD_weightvg_util.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
            !ELEM7(falloff_type, MOD_WVG_MAPPING_CURVE, MOD_WVG_MAPPING_SHARP, MOD_WVG_MAPPING_SMOOTH,
70
70
                   MOD_WVG_MAPPING_ROOT, MOD_WVG_MAPPING_SPHERE, MOD_WVG_MAPPING_RANDOM,
71
71
                   MOD_WVG_MAPPING_STEP))
 
72
        {
72
73
                return;
 
74
        }
 
75
 
 
76
        if (cmap && falloff_type == MOD_WVG_MAPPING_CURVE) {
 
77
                curvemapping_initialize(cmap);
 
78
        }
73
79
 
74
80
        /* Map each weight (vertex) to its new value, accordingly to the chosen mode. */
75
81
        for (i = 0; i < num; ++i) {
77
83
 
78
84
                /* Code borrowed from the warp modifier. */
79
85
                /* Closely matches PROP_SMOOTH and similar. */
80
 
                switch(falloff_type) {
81
 
                case MOD_WVG_MAPPING_CURVE:
82
 
                        fac = curvemapping_evaluateF(cmap, 0, fac);
83
 
                        break;
84
 
                case MOD_WVG_MAPPING_SHARP:
85
 
                        fac = fac*fac;
86
 
                        break;
87
 
                case MOD_WVG_MAPPING_SMOOTH:
88
 
                        fac = 3.0f*fac*fac - 2.0f*fac*fac*fac;
89
 
                        break;
90
 
                case MOD_WVG_MAPPING_ROOT:
91
 
                        fac = (float)sqrt(fac);
92
 
                        break;
93
 
                case MOD_WVG_MAPPING_SPHERE:
94
 
                        fac = (float)sqrt(2*fac - fac * fac);
95
 
                        break;
96
 
                case MOD_WVG_MAPPING_RANDOM:
97
 
                        BLI_srand(BLI_rand()); /* random seed */
98
 
                        fac = BLI_frand()*fac;
99
 
                        break;
100
 
                case MOD_WVG_MAPPING_STEP:
101
 
                        fac = (fac >= 0.5f)?1.0f:0.0f;
102
 
                        break;
 
86
                switch (falloff_type) {
 
87
                        case MOD_WVG_MAPPING_CURVE:
 
88
                                fac = curvemapping_evaluateF(cmap, 0, fac);
 
89
                                break;
 
90
                        case MOD_WVG_MAPPING_SHARP:
 
91
                                fac = fac * fac;
 
92
                                break;
 
93
                        case MOD_WVG_MAPPING_SMOOTH:
 
94
                                fac = 3.0f * fac * fac - 2.0f * fac * fac * fac;
 
95
                                break;
 
96
                        case MOD_WVG_MAPPING_ROOT:
 
97
                                fac = (float)sqrt(fac);
 
98
                                break;
 
99
                        case MOD_WVG_MAPPING_SPHERE:
 
100
                                fac = (float)sqrt(2 * fac - fac * fac);
 
101
                                break;
 
102
                        case MOD_WVG_MAPPING_RANDOM:
 
103
                                BLI_srand(BLI_rand()); /* random seed */
 
104
                                fac = BLI_frand() * fac;
 
105
                                break;
 
106
                        case MOD_WVG_MAPPING_STEP:
 
107
                                fac = (fac >= 0.5f) ? 1.0f : 0.0f;
 
108
                                break;
103
109
                }
104
110
 
105
111
                new_w[i] = fac;
152
158
                for (i = 0; i < num; ++i) {
153
159
                        int idx = indices ? indices[i] : i;
154
160
                        TexResult texres;
155
 
                        float h, s, v; /* For HSV color space. */
 
161
                        float hsv[3]; /* For HSV color space. */
156
162
 
157
163
                        texres.nor = NULL;
158
164
                        get_texture_value(texture, tex_co[idx], &texres);
159
165
                        /* Get the good channel value... */
160
 
                        switch(tex_use_channel) {
161
 
                        case MOD_WVG_MASK_TEX_USE_INT:
162
 
                                org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin*fact)));
163
 
                                break;
164
 
                        case MOD_WVG_MASK_TEX_USE_RED:
165
 
                                org_w[i] = (new_w[i] * texres.tr * fact) + (org_w[i] * (1.0f - (texres.tr*fact)));
166
 
                                break;
167
 
                        case MOD_WVG_MASK_TEX_USE_GREEN:
168
 
                                org_w[i] = (new_w[i] * texres.tg * fact) + (org_w[i] * (1.0f - (texres.tg*fact)));
169
 
                                break;
170
 
                        case MOD_WVG_MASK_TEX_USE_BLUE:
171
 
                                org_w[i] = (new_w[i] * texres.tb * fact) + (org_w[i] * (1.0f - (texres.tb*fact)));
172
 
                                break;
173
 
                        case MOD_WVG_MASK_TEX_USE_HUE:
174
 
                                rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v);
175
 
                                org_w[i] = (new_w[i] * h * fact) + (org_w[i] * (1.0f - (h*fact)));
176
 
                                break;
177
 
                        case MOD_WVG_MASK_TEX_USE_SAT:
178
 
                                rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v);
179
 
                                org_w[i] = (new_w[i] * s * fact) + (org_w[i] * (1.0f - (s*fact)));
180
 
                                break;
181
 
                        case MOD_WVG_MASK_TEX_USE_VAL:
182
 
                                rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v);
183
 
                                org_w[i] = (new_w[i] * v * fact) + (org_w[i] * (1.0f - (v*fact)));
184
 
                                break;
185
 
                        case MOD_WVG_MASK_TEX_USE_ALPHA:
186
 
                                org_w[i] = (new_w[i] * texres.ta * fact) + (org_w[i] * (1.0f - (texres.ta*fact)));
187
 
                                break;
188
 
                        default:
189
 
                                org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin*fact)));
190
 
                                break;
 
166
                        switch (tex_use_channel) {
 
167
                                case MOD_WVG_MASK_TEX_USE_INT:
 
168
                                        org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin * fact)));
 
169
                                        break;
 
170
                                case MOD_WVG_MASK_TEX_USE_RED:
 
171
                                        org_w[i] = (new_w[i] * texres.tr * fact) + (org_w[i] * (1.0f - (texres.tr * fact)));
 
172
                                        break;
 
173
                                case MOD_WVG_MASK_TEX_USE_GREEN:
 
174
                                        org_w[i] = (new_w[i] * texres.tg * fact) + (org_w[i] * (1.0f - (texres.tg * fact)));
 
175
                                        break;
 
176
                                case MOD_WVG_MASK_TEX_USE_BLUE:
 
177
                                        org_w[i] = (new_w[i] * texres.tb * fact) + (org_w[i] * (1.0f - (texres.tb * fact)));
 
178
                                        break;
 
179
                                case MOD_WVG_MASK_TEX_USE_HUE:
 
180
                                        rgb_to_hsv_v(&texres.tr, hsv);
 
181
                                        org_w[i] = (new_w[i] * hsv[0] * fact) + (org_w[i] * (1.0f - (hsv[0] * fact)));
 
182
                                        break;
 
183
                                case MOD_WVG_MASK_TEX_USE_SAT:
 
184
                                        rgb_to_hsv_v(&texres.tr, hsv);
 
185
                                        org_w[i] = (new_w[i] * hsv[1] * fact) + (org_w[i] * (1.0f - (hsv[1] * fact)));
 
186
                                        break;
 
187
                                case MOD_WVG_MASK_TEX_USE_VAL:
 
188
                                        rgb_to_hsv_v(&texres.tr, hsv);
 
189
                                        org_w[i] = (new_w[i] * hsv[2] * fact) + (org_w[i] * (1.0f - (hsv[2] * fact)));
 
190
                                        break;
 
191
                                case MOD_WVG_MASK_TEX_USE_ALPHA:
 
192
                                        org_w[i] = (new_w[i] * texres.ta * fact) + (org_w[i] * (1.0f - (texres.ta * fact)));
 
193
                                        break;
 
194
                                default:
 
195
                                        org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin * fact)));
 
196
                                        break;
191
197
                        }
192
198
                }
193
199
 
211
217
                for (i = 0; i < num; i++) {
212
218
                        int idx = indices ? indices[i] : i;
213
219
                        const float f = defvert_find_weight(&dvert[idx], ref_didx) * fact;
214
 
                        org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f-f));
 
220
                        org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f - f));
215
221
                        /* If that vertex is not in ref vgroup, assume null factor, and hence do nothing! */
216
222
                }
217
223
        }