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

« back to all changes in this revision

Viewing changes to source/blender/modifiers/intern/MOD_remesh.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:
50
50
 
51
51
static void initData(ModifierData *md)
52
52
{
53
 
        RemeshModifierData *rmd = (RemeshModifierData*) md;
 
53
        RemeshModifierData *rmd = (RemeshModifierData *) md;
54
54
 
55
55
        rmd->scale = 0.9;
56
56
        rmd->depth = 4;
62
62
 
63
63
static void copyData(ModifierData *md, ModifierData *target)
64
64
{
65
 
        RemeshModifierData *rmd = (RemeshModifierData*) md;
66
 
        RemeshModifierData *trmd = (RemeshModifierData*) target;
 
65
        RemeshModifierData *rmd = (RemeshModifierData *) md;
 
66
        RemeshModifierData *trmd = (RemeshModifierData *) target;
67
67
 
68
68
        trmd->threshold = rmd->threshold;
69
69
        trmd->scale = rmd->scale;
79
79
{
80
80
        memset(mesh, 0, sizeof(DualConInput));
81
81
 
82
 
        mesh->co = (void*)dm->getVertArray(dm);
 
82
        mesh->co = (void *)dm->getVertArray(dm);
83
83
        mesh->co_stride = sizeof(MVert);
84
84
        mesh->totco = dm->getNumVerts(dm);
85
85
 
86
 
        mesh->faces = (void*)dm->getTessFaceArray(dm);
 
86
        mesh->faces = (void *)dm->getTessFaceArray(dm);
87
87
        mesh->face_stride = sizeof(MFace);
88
88
        mesh->totface = dm->getNumTessFaces(dm);
89
89
 
 
90
        INIT_MINMAX(mesh->min, mesh->max);
90
91
        dm->getMinMax(dm, mesh->min, mesh->max);
91
92
}
92
93
 
103
104
        DualConOutput *output;
104
105
 
105
106
        if (!(output = MEM_callocN(sizeof(DualConOutput),
106
 
                                                          "DualConOutput")))
 
107
                                   "DualConOutput")))
 
108
        {
107
109
                return NULL;
 
110
        }
108
111
        
109
 
        output->dm = CDDM_new(totvert, 0, 0, 4*totquad, totquad);
 
112
        output->dm = CDDM_new(totvert, 0, 0, 4 * totquad, totquad);
110
113
        return output;
111
114
}
112
115
 
143
146
}
144
147
 
145
148
static DerivedMesh *applyModifier(ModifierData *md,
146
 
                                                                  Object *UNUSED(ob),
147
 
                                                                  DerivedMesh *dm,
148
 
                                                                  int UNUSED(useRenderParams),
149
 
                                                                  int UNUSED(isFinalCalc))
 
149
                                  Object *UNUSED(ob),
 
150
                                  DerivedMesh *dm,
 
151
                                  ModifierApplyFlag UNUSED(flag))
150
152
{
151
153
        RemeshModifierData *rmd;
152
154
        DualConOutput *output;
157
159
 
158
160
        DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
159
161
 
160
 
        rmd = (RemeshModifierData*)md;
 
162
        rmd = (RemeshModifierData *)md;
161
163
 
162
164
        init_dualcon_mesh(&input, dm);
163
165
 
164
166
        if (rmd->flag & MOD_REMESH_FLOOD_FILL)
165
167
                flags |= DUALCON_FLOOD_FILL;
166
168
 
167
 
        switch(rmd->mode) {
168
 
        case MOD_REMESH_CENTROID:
169
 
                mode = DUALCON_CENTROID;
170
 
                break;
171
 
        case MOD_REMESH_MASS_POINT:
172
 
                mode = DUALCON_MASS_POINT;
173
 
                break;
174
 
        case MOD_REMESH_SHARP_FEATURES:
175
 
                mode = DUALCON_SHARP_FEATURES;
176
 
                break;
 
169
        switch (rmd->mode) {
 
170
                case MOD_REMESH_CENTROID:
 
171
                        mode = DUALCON_CENTROID;
 
172
                        break;
 
173
                case MOD_REMESH_MASS_POINT:
 
174
                        mode = DUALCON_MASS_POINT;
 
175
                        break;
 
176
                case MOD_REMESH_SHARP_FEATURES:
 
177
                        mode = DUALCON_SHARP_FEATURES;
 
178
                        break;
177
179
        }
178
180
        
179
181
        output = dualcon(&input,
180
 
                                         dualcon_alloc_output,
181
 
                                         dualcon_add_vert,
182
 
                                         dualcon_add_quad,
183
 
                                         flags,
184
 
                                         mode,
185
 
                                         rmd->threshold,
186
 
                                         rmd->hermite_num,
187
 
                                         rmd->scale,
188
 
                                         rmd->depth);
 
182
                         dualcon_alloc_output,
 
183
                         dualcon_add_vert,
 
184
                         dualcon_add_quad,
 
185
                         flags,
 
186
                         mode,
 
187
                         rmd->threshold,
 
188
                         rmd->hermite_num,
 
189
                         rmd->scale,
 
190
                         rmd->depth);
189
191
        result = output->dm;
190
192
        MEM_freeN(output);
191
193
 
 
194
        if (rmd->flag & MOD_REMESH_SMOOTH_SHADING) {
 
195
                MPoly *mpoly = CDDM_get_polys(result);
 
196
                int i, totpoly = result->getNumPolys(result);
 
197
                
 
198
                /* Apply smooth shading to output faces */
 
199
                for (i = 0; i < totpoly; i++) {
 
200
                        mpoly[i].flag |= ME_SMOOTH;
 
201
                }
 
202
        }
 
203
 
192
204
        CDDM_calc_edges(result);
193
205
        CDDM_calc_normals(result);
194
206
        return result;
197
209
#else /* !WITH_MOD_REMESH */
198
210
 
199
211
static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob),
200
 
                                                DerivedMesh *derivedData,
201
 
                                                int UNUSED(useRenderParams),
202
 
                                                int UNUSED(isFinalCalc))
 
212
                                  DerivedMesh *derivedData,
 
213
                                  ModifierApplyFlag UNUSED(flag))
203
214
{
204
215
        return derivedData;
205
216
}
211
222
        /* structName */        "RemeshModifierData",
212
223
        /* structSize */        sizeof(RemeshModifierData),
213
224
        /* type */              eModifierTypeType_Nonconstructive,
214
 
        /* flags */             eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode,
 
225
        /* flags */             eModifierTypeFlag_AcceptsMesh |
 
226
                                eModifierTypeFlag_AcceptsCVs |
 
227
                                eModifierTypeFlag_SupportsEditmode,
215
228
        /* copyData */          copyData,
216
229
        /* deformVerts */       NULL,
217
230
        /* deformMatrices */    NULL,