[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24547] branches/soc-2009-chingachgook/ source/blender/collada/DocumentImporter.cpp: COLLADA: triangles created by polygon tesselation now get correct winding order (i. e.

joe joeedh at gmail.com
Fri Nov 13 19:12:41 CET 2009


BTW I suppose I should mention I got this from Geoffry, heh :)

Joe

On Fri, Nov 13, 2009 at 7:36 AM, Arystanbek Dyussenov
<arystan.d at gmail.com> wrote:
> Revision: 24547
>          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24547
> Author:   kazanbas
> Date:     2009-11-13 16:36:46 +0100 (Fri, 13 Nov 2009)
>
> Log Message:
> -----------
> COLLADA: triangles created by polygon tesselation now get correct winding order (i.e. no flipping). Thanks Joseph for the algorithm!
>
> Modified Paths:
> --------------
>    branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp
>
> Modified: branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp
> ===================================================================
> --- branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp  2009-11-13 13:06:26 UTC (rev 24546)
> +++ branches/soc-2009-chingachgook/source/blender/collada/DocumentImporter.cpp  2009-11-13 15:36:46 UTC (rev 24547)
> @@ -85,6 +85,7 @@
>
>  #include <string>
>  #include <map>
> +#include <algorithm> // sort()
>
>  #include <math.h>
>  #include <float.h>
> @@ -1298,9 +1299,16 @@
>                        tottri = dl->parts;
>
>                        int *index = dl->index;
> -                       for (i = 0; i < tottri * 3; i++) {
> -                               tri.push_back(*index);
> -                               index++;
> +                       for (i= 0; i < tottri; i++) {
> +                               int t[3]= {*index, *(index + 1), *(index + 2)};
> +
> +                               std::sort(t, t + 3);
> +
> +                               tri.push_back(t[0]);
> +                               tri.push_back(t[1]);
> +                               tri.push_back(t[2]);
> +
> +                               index += 3;
>                        }
>                }
>
> @@ -1414,6 +1422,8 @@
>                                                MTFace *mtface = (MTFace*)CustomData_get_layer_n(&me->fdata, CD_MTFACE, k);
>                                                set_face_uv(&mtface[face_index], uvs, k, *index_list_array[k], index, false);
>                                        }
> +
> +                                       test_index_face(mface, &me->fdata, face_index, 3);
>
>                                        index += 3;
>                                        mface++;
> @@ -1432,7 +1442,6 @@
>                                        if (vcount == 3 || vcount == 4) {
>
>                                                set_face_indices(mface, indices, vcount == 4);
> -                                               indices += vcount;
>
>                                                // set mtface for each uv set
>                                                // it is assumed that all primitives have equal number of UV sets
> @@ -1445,7 +1454,6 @@
>
>                                                test_index_face(mface, &me->fdata, face_index, vcount);
>
> -                                               index += mface->v4 ? 4 : 3;
>                                                mface++;
>                                                face_index++;
>                                                prim.totface++;
> @@ -1483,10 +1491,10 @@
>                                                        face_index++;
>                                                        prim.totface++;
>                                                }
> -
> -                                               index += vcount;
> -                                               indices += vcount;
>                                        }
> +
> +                                       index += vcount;
> +                                       indices += vcount;
>                                }
>                        }
>
>
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>


More information about the Bf-committers mailing list