row = layout.row()
row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
row.prop(md, "invert_vertex_group")
+ layout.prop(md, "use_triangulate")
elif decimate_type == 'UNSUBDIV':
layout.prop(md, "iterations")
else: # decimate_type == 'DISSOLVE':
* \ingroup bmesh
*/
-void BM_mesh_decimate_collapse(BMesh *bm, const float factor, float *vweights);
+void BM_mesh_decimate_collapse(BMesh *bm, const float factor, float *vweights, const int do_triangulate);
void BM_mesh_decimate_unsubdivide_ex(BMesh *bm, const int iterations, const int tag_only);
void BM_mesh_decimate_unsubdivide(BMesh *bm, const int iterations);
* \param vertex_weights Optional array of vertex aligned weights [0 - 1],
* a vertex group is the usual source for this.
*/
-void BM_mesh_decimate_collapse(BMesh *bm, const float factor, float *vweights)
+void BM_mesh_decimate_collapse(BMesh *bm, const float factor, float *vweights, const int do_triangulate)
{
Heap *eheap; /* edge heap */
HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */
#ifdef USE_TRIANGULATE
- /* its possible we only had triangles, skip this step in that case */
- if (LIKELY(use_triangulate)) {
- /* temp convert quads to triangles */
- bm_decim_triangulate_end(bm);
+ if (do_triangulate == FALSE) {
+ /* its possible we only had triangles, skip this step in that case */
+ if (LIKELY(use_triangulate)) {
+ /* temp convert quads to triangles */
+ bm_decim_triangulate_end(bm);
+ }
}
#endif
} DecimateModifierData;
enum {
- MOD_DECIM_FLAG_INVERT_VGROUP = (1 << 0)
+ MOD_DECIM_FLAG_INVERT_VGROUP = (1 << 0),
+ MOD_DECIM_FLAG_TRIANGULATE = (1 << 1) /* for collapse only. dont convert tri pairs back to quads */
};
enum {
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_INVERT_VGROUP);
RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
+
+ prop = RNA_def_property(srna, "use_triangulate", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_TRIANGULATE);
+ RNA_def_property_ui_text(prop, "Triangulate", "Keep triangulated faces resulting from decimation");
+ RNA_def_property_update(prop, 0, "rna_Modifier_update");
/* end collapse-only option */
/* all modes use this */
BMEditMesh *em;
BMesh *bm;
+ const int do_triangulate = (dmd->flag & MOD_DECIM_FLAG_TRIANGULATE) != 0;
+
float *vweights = NULL;
#ifdef USE_TIMEIT
switch (dmd->mode) {
case MOD_DECIM_MODE_COLLAPSE:
- BM_mesh_decimate_collapse(bm, dmd->percent, vweights);
+ BM_mesh_decimate_collapse(bm, dmd->percent, vweights, do_triangulate);
break;
case MOD_DECIM_MODE_UNSUBDIV:
BM_mesh_decimate_unsubdivide(bm, dmd->iter);