Fix #27048: text + SimpleDeform modifier = weird render result!
authorSergey Sharybin <sergey.vfx@gmail.com>
Sat, 23 Apr 2011 15:27:35 +0000 (15:27 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sat, 23 Apr 2011 15:27:35 +0000 (15:27 +0000)
It's not real fix, just patch which makes things better by using average
normal for each displist separately. There are still some artifacts with
quite highly deformed letters "O" or "g", but correct fix would need
to calculate derivative of modifiers, which isn't implemented yet.

source/blender/render/intern/source/convertblender.c

index 93062bfb59a8f5b93db7933ab099164c3a6f5475..1a19bbe7320d7613e812f958bc16792f07d26f12 100644 (file)
@@ -2868,17 +2868,10 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
                                startvert= obr->totvert;
                                data= dl->verts;
 
-                               n[0]= ob->imat[0][2];
-                               n[1]= ob->imat[1][2];
-                               n[2]= ob->imat[2][2];
-                               normalize_v3(n);
-
                                for(a=0; a<dl->nr; a++, data+=3) {
                                        ver= RE_findOrAddVert(obr, obr->totvert++);
                                        VECCOPY(ver->co, data);
 
-                                       negate_v3_v3(ver->n, n);
-
                                        mul_m4_v3(mat, ver->co);
 
                                        if (orco) {
@@ -2888,21 +2881,41 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
                                }
 
                                if(timeoffset==0) {
+                                       float tmp[3];
+                                       const int startvlak= obr->totvlak;
+
+                                       zero_v3(n);
                                        index= dl->index;
                                        for(a=0; a<dl->parts; a++, index+=3) {
-
                                                vlr= RE_findOrAddVlak(obr, obr->totvlak++);
                                                vlr->v1= RE_findOrAddVert(obr, startvert+index[0]);
                                                vlr->v2= RE_findOrAddVert(obr, startvert+index[1]);
                                                vlr->v3= RE_findOrAddVert(obr, startvert+index[2]);
                                                vlr->v4= NULL;
 
-                                               negate_v3_v3(vlr->n, n);
+                                               normal_tri_v3(tmp, vlr->v3->co, vlr->v2->co, vlr->v1->co);
+                                               add_v3_v3(n, tmp);
 
                                                vlr->mat= matar[ dl->col ];
                                                vlr->flag= 0;
                                                vlr->ec= 0;
                                        }
+
+                                       normalize_v3(n);
+
+                                       /* vertex normals */
+                                       for(a= startvlak; a<obr->totvlak; a++) {
+                                               vlr= RE_findOrAddVlak(obr, a);
+
+                                               copy_v3_v3(vlr->n, n);
+                                               add_v3_v3(vlr->v1->n, vlr->n);
+                                               add_v3_v3(vlr->v3->n, vlr->n);
+                                               add_v3_v3(vlr->v2->n, vlr->n);
+                                       }
+                                       for(a=startvert; a<obr->totvert; a++) {
+                                               ver= RE_findOrAddVert(obr, a);
+                                               normalize_v3(ver->n);
+                                       }
                                }
                        }
                        else if (dl->type==DL_SURF) {