[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36362] trunk/blender/source/blender/ modifiers/intern/MOD_wave.c: skip some calculations with the wave modifier - when the vert has no vgroup weight or 0 .0 falloff.
Campbell Barton
ideasman42 at gmail.com
Thu Apr 28 07:34:11 CEST 2011
Revision: 36362
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36362
Author: campbellbarton
Date: 2011-04-28 05:34:11 +0000 (Thu, 28 Apr 2011)
Log Message:
-----------
skip some calculations with the wave modifier - when the vert has no vgroup weight or 0.0 falloff.
Modified Paths:
--------------
trunk/blender/source/blender/modifiers/intern/MOD_wave.c
Modified: trunk/blender/source/blender/modifiers/intern/MOD_wave.c
===================================================================
--- trunk/blender/source/blender/modifiers/intern/MOD_wave.c 2011-04-28 05:19:17 UTC (rev 36361)
+++ trunk/blender/source/blender/modifiers/intern/MOD_wave.c 2011-04-28 05:34:11 UTC (rev 36362)
@@ -263,6 +263,9 @@
(float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
float lifefac = wmd->height;
float (*tex_co)[3] = NULL;
+ const int wmd_axis= wmd->flag & (MOD_WAVE_X|MOD_WAVE_Y);
+ const float falloff= wmd->falloff;
+ float falloff_fac= 1.0f; /* when falloff == 0.0f this stays at 1.0f */
if(wmd->flag & MOD_WAVE_NORM && ob->type == OB_MESH)
mvert = dm->getVertArray(dm);
@@ -306,7 +309,7 @@
if(lifefac != 0.0f) {
/* avoid divide by zero checks within the loop */
- float falloff_inv= wmd->falloff ? 1.0f / wmd->falloff : 1.0f;
+ float falloff_inv= falloff ? 1.0f / falloff : 1.0f;
int i;
for(i = 0; i < numVerts; i++) {
@@ -314,52 +317,29 @@
float x = co[0] - wmd->startx;
float y = co[1] - wmd->starty;
float amplit= 0.0f;
- float dist = 0.0f;
- float falloff_fac = 0.0f;
- TexResult texres;
- MDeformWeight *def_weight = NULL;
+ float def_weight= 1.0f;
/* get weights */
if(dvert) {
- int j;
- for(j = 0; j < dvert[i].totweight; ++j) {
- if(dvert[i].dw[j].def_nr == defgrp_index) {
- def_weight = &dvert[i].dw[j];
- break;
- }
- }
+ def_weight= defvert_find_weight(&dvert[i], defgrp_index);
/* if this vert isn't in the vgroup, don't deform it */
- if(!def_weight) continue;
- }
-
- if(wmd->texture) {
- texres.nor = NULL;
- get_texture_value(wmd->texture, tex_co[i], &texres);
- }
-
- /*get dist*/
- if(wmd->flag & MOD_WAVE_X) {
- if(wmd->flag & MOD_WAVE_Y){
- dist = (float)sqrt(x*x + y*y);
+ if(def_weight == 0.0f) {
+ continue;
}
- else{
- dist = fabs(x);
- }
}
- else if(wmd->flag & MOD_WAVE_Y) {
- dist = fabs(y);
- }
- falloff_fac = (1.0f - (dist * falloff_inv));
- CLAMP(falloff_fac, 0.0f, 1.0f);
-
- if(wmd->flag & MOD_WAVE_X) {
- if(wmd->flag & MOD_WAVE_Y) amplit = (float)sqrt(x*x + y*y);
- else amplit = x;
+ switch(wmd_axis) {
+ case MOD_WAVE_X|MOD_WAVE_Y:
+ amplit = sqrtf(x*x + y*y);
+ break;
+ case MOD_WAVE_X:
+ amplit = x;
+ break;
+ case MOD_WAVE_Y:
+ amplit = y;
+ break;
}
- else if(wmd->flag & MOD_WAVE_Y)
- amplit= y;
/* this way it makes nice circles */
amplit -= (ctime - wmd->timeoffs) * wmd->speed;
@@ -369,23 +349,41 @@
+ wmd->width;
}
+ if(falloff != 0.0f) {
+ float dist = 0.0f;
+
+ switch(wmd_axis) {
+ case MOD_WAVE_X|MOD_WAVE_Y:
+ dist = sqrtf(x*x + y*y);
+ break;
+ case MOD_WAVE_X:
+ dist = fabsf(x);
+ break;
+ case MOD_WAVE_Y:
+ dist = fabsf(y);
+ break;
+ }
+
+ falloff_fac = (1.0f - (dist * falloff_inv));
+ CLAMP(falloff_fac, 0.0f, 1.0f);
+ }
+
/* GAUSSIAN */
- if(amplit > -wmd->width && amplit < wmd->width) {
+ if((falloff_fac != 0.0f) && (amplit > -wmd->width) && (amplit < wmd->width)) {
amplit = amplit * wmd->narrow;
amplit = (float)(1.0f / expf(amplit * amplit) - minfac);
/*apply texture*/
- if(wmd->texture)
- amplit = amplit * texres.tin;
+ if(wmd->texture) {
+ TexResult texres;
+ texres.nor = NULL;
+ get_texture_value(wmd->texture, tex_co[i], &texres);
+ amplit *= texres.tin;
+ }
- /*apply weight*/
- if(def_weight)
- amplit = amplit * def_weight->weight;
+ /*apply weight & falloff */
+ amplit *= def_weight * falloff_fac;
- /*apply falloff*/
- if (wmd->falloff > 0)
- amplit = amplit * falloff_fac;
-
if(mvert) {
/* move along normals */
if(wmd->flag & MOD_WAVE_NORM_X) {
More information about the Bf-blender-cvs
mailing list