From 1994ed00a388d7eed3c9d4dfda614c41693c114e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Feb 2013 13:44:18 +0000 Subject: add option not to calculate tessellation faces when converting an object to a mesh. (OBJ export no longer needs, so save some CPU cycles and skip tessellation) --- intern/cycles/blender/blender_util.h | 2 +- source/blender/makesrna/intern/rna_internal.h | 4 +++- source/blender/makesrna/intern/rna_main_api.c | 12 +++++++++--- source/blender/makesrna/intern/rna_object_api.c | 9 +++++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 0947b5a2e9d..976ed875211 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -41,7 +41,7 @@ CCL_NAMESPACE_BEGIN static inline BL::Mesh object_to_mesh(BL::BlendData data, BL::Object object, BL::Scene scene, bool apply_modifiers, bool render) { - return data.meshes.new_from_object(scene, object, apply_modifiers, (render)? 2: 1); + return data.meshes.new_from_object(scene, object, apply_modifiers, (render)? 2: 1, true); } static inline void colorramp_to_array(BL::ColorRamp ramp, float4 *data, int size) diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index eaa69a8124c..c1f5698016c 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -398,7 +398,9 @@ PointerRNA rna_pointer_inherit_refine(struct PointerRNA *ptr, struct StructRNA * int rna_parameter_size(struct PropertyRNA *parm); int rna_parameter_size_alloc(struct PropertyRNA *parm); -struct Mesh *rna_Main_meshes_new_from_object(struct Main *bmain, struct ReportList *reports, struct Scene *sce, struct Object *ob, int apply_modifiers, int settings); +struct Mesh *rna_Main_meshes_new_from_object( + struct Main *bmain, struct ReportList *reports, struct Scene *sce, + struct Object *ob, int apply_modifiers, int settings, int calc_tessface); /* XXX, these should not need to be defined here~! */ struct MTex *rna_mtex_texture_slots_add(struct ID *self, struct bContext *C, struct ReportList *reports); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index ab94b88e3d7..7175c8eab78 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -37,6 +37,7 @@ #include "DNA_modifier_types.h" #include "BLI_path_util.h" +#include "BLI_utildefines.h" #include "RNA_define.h" #include "RNA_access.h" @@ -263,7 +264,9 @@ static Mesh *rna_Main_meshes_new(Main *bmain, const char *name) /* copied from Mesh_getFromObject and adapted to RNA interface */ /* settings: 1 - preview, 2 - render */ -Mesh *rna_Main_meshes_new_from_object(Main *bmain, ReportList *reports, Scene *sce, Object *ob, int apply_modifiers, int settings) +Mesh *rna_Main_meshes_new_from_object( + Main *bmain, ReportList *reports, Scene *sce, + Object *ob, int apply_modifiers, int settings, int calc_tessface) { Mesh *tmpmesh; Curve *tmpcu = NULL, *copycu; @@ -446,8 +449,10 @@ Mesh *rna_Main_meshes_new_from_object(Main *bmain, ReportList *reports, Scene *s break; } /* end copy materials */ - /* cycles and exporters rely on this still */ - BKE_mesh_tessface_ensure(tmpmesh); + if (calc_tessface) { + /* cycles and exporters rely on this still */ + BKE_mesh_tessface_ensure(tmpmesh); + } /* make sure materials get updated in objects */ test_object_materials(&tmpmesh->id); @@ -1138,6 +1143,7 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply"); RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "calc_tessface", true, "Calculate Tessellation", "Calculate tessellation faces"); parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object, remove it if it is only used for export"); RNA_def_function_return(func, parm); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 51725bda7f9..2b7df1ca317 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -34,6 +34,8 @@ #include #include +#include "BLI_utildefines.h" + #include "RNA_define.h" #include "DNA_constraint_types.h" @@ -109,9 +111,11 @@ static void rna_Scene_mat_convert_space(Object *ob, ReportList *reports, bPoseCh /* copied from Mesh_getFromObject and adapted to RNA interface */ /* settings: 0 - preview, 1 - render */ -static Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_modifiers, int settings) +static Mesh *rna_Object_to_mesh( + Object *ob, ReportList *reports, Scene *sce, + int apply_modifiers, int settings, int calc_tessface) { - return rna_Main_meshes_new_from_object(G.main, reports, sce, ob, apply_modifiers, settings); + return rna_Main_meshes_new_from_object(G.main, reports, sce, ob, apply_modifiers, settings, calc_tessface); } /* mostly a copy from convertblender.c */ @@ -442,6 +446,7 @@ void RNA_api_object(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED); parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply"); RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "calc_tessface", true, "Calculate Tessellation", "Calculate tessellation faces"); parm = RNA_def_pointer(func, "mesh", "Mesh", "", "Mesh created from object, remove it if it is only used for export"); RNA_def_function_return(func, parm); -- cgit v1.2.3