#include "BLI_math_geom.h"
#include "BLI_string.h"
+#include "BKE_cdderivedmesh.h"
#include "BKE_depsgraph.h"
-#include "BKE_DerivedMesh.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "WM_types.h"
#include "ED_mesh.h"
+
+#include "bmesh.h"
+#include "bmesh_tools.h"
}
using Alembic::Abc::FloatArraySample;
m_subsurf_mod->mode &= ~eModifierMode_DisableTemporary;
}
+ if (m_settings.triangulate) {
+ const bool tag_only = false;
+ const int quad_method = m_settings.quad_method;
+ const int ngon_method = m_settings.ngon_method;
+
+ BMesh *bm = DM_to_bmesh(dm, true);
+
+ BM_mesh_triangulate(bm, quad_method, ngon_method, tag_only, NULL, NULL, NULL);
+
+ DerivedMesh *result = CDDM_from_bmesh(bm, false);
+ BM_mesh_free(bm);
+
+ freeMesh(dm);
+
+ dm = result;
+ }
+
m_custom_data_config.pack_uvs = m_settings.pack_uv;
m_custom_data_config.mpoly = dm->getPolyArray(dm);
m_custom_data_config.mloop = dm->getLoopArray(dm);
#include "MEM_guardedalloc.h"
#include "DNA_mesh_types.h"
+#include "DNA_modifier_types.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
.use_subdiv_schema = RNA_boolean_get(op->ptr, "subdiv_schema"),
.compression_type = RNA_enum_get(op->ptr, "compression_type"),
.packuv = RNA_boolean_get(op->ptr, "packuv"),
+ .triangulate = RNA_boolean_get(op->ptr, "triangulate"),
+ .quad_method = RNA_boolean_get(op->ptr, "quad_method"),
+ .ngon_method = RNA_boolean_get(op->ptr, "ngon_method"),
.global_scale = RNA_float_get(op->ptr, "global_scale"),
};
row = uiLayoutRow(box, false);
uiItemR(row, imfptr, "apply_subdiv", 0, NULL, ICON_NONE);
+
+ row = uiLayoutRow(box, false);
+ uiItemR(row, imfptr, "triangulate", 0, NULL, ICON_NONE);
+
+ const bool triangulate = RNA_boolean_get(imfptr, "triangulate");
+
+ row = uiLayoutRow(box, false);
+ uiLayoutSetEnabled(row, triangulate);
+ uiItemR(row, imfptr, "quad_method", 0, NULL, ICON_NONE);
+
+ row = uiLayoutRow(box, false);
+ uiLayoutSetEnabled(row, triangulate);
+ uiItemR(row, imfptr, "ngon_method", 0, NULL, ICON_NONE);
}
static void wm_alembic_export_draw(bContext *UNUSED(C), wmOperator *op)
RNA_def_float(ot->srna, "global_scale", 1.0f, 0.0001f, 1000.0f, "Scale",
"Value by which to enlarge or shrink the objects with respect to the world's origin",
0.0001f, 1000.0f);
+
+ RNA_def_boolean(ot->srna, "triangulate", false, "Triangulate",
+ "Export Polygons (Quads & NGons) as Triangles");
+
+ RNA_def_enum(ot->srna, "quad_method", rna_enum_modifier_triangulate_quad_method_items,
+ MOD_TRIANGULATE_QUAD_SHORTEDGE, "Quad Method", "Method for splitting the quads into triangles");
+
+ RNA_def_enum(ot->srna, "ngon_method", rna_enum_modifier_triangulate_quad_method_items,
+ MOD_TRIANGULATE_NGON_BEAUTY, "Polygon Method", "Method for splitting the polygons into triangles");
}
/* ************************************************************************** */
int use_subdiv_schema,
int compression_type,
int packuv,
- float scale)
+ float scale,
+ int triangulate,
+ int quad_method,
+ int ngon_method)
{
/* We have to enable allow_threads, because we may change scene frame number
* during export. */
.use_subdiv_schema = use_subdiv_schema,
.compression_type = compression_type,
.packuv = packuv,
+ .triangulate = triangulate,
+ .quad_method = quad_method,
+ .ngon_method = ngon_method,
.global_scale = scale,
};
RNA_def_enum(func, "compression_type", rna_enum_abc_compression_items, 0, "Compression", "");
RNA_def_boolean(func, "packuv" , 0, "Export with packed UV islands", "Export with packed UV islands");
RNA_def_float(func, "scale", 1.0f, 0.0001f, 1000.0f, "Scale", "Value by which to enlarge or shrink the objects with respect to the world's origin", 0.0001f, 1000.0f);
+ RNA_def_boolean(func, "triangulate", 0, "Triangulate", "Export Polygons (Quads & NGons) as Triangles");
+ RNA_def_enum(func, "quad_method", rna_enum_modifier_triangulate_quad_method_items, 0, "Quad Method", "Method for splitting the quads into triangles");
+ RNA_def_enum(func, "ngon_method", rna_enum_modifier_triangulate_quad_method_items, 0, "Polygon Method", "Method for splitting the polygons into triangles");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
#endif