Changeset View
Standalone View
source/blender/makesrna/intern/rna_main_api.c
| Show First 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | static Mesh *rna_Main_meshes_new(Main *bmain, const char *name) | ||||
| rna_idname_validate(name, safe_name); | rna_idname_validate(name, safe_name); | ||||
| Mesh *me = BKE_mesh_add(bmain, safe_name); | Mesh *me = BKE_mesh_add(bmain, safe_name); | ||||
| id_us_min(&me->id); | id_us_min(&me->id); | ||||
| return me; | return me; | ||||
| } | } | ||||
| /* copied from Mesh_getFromObject and adapted to RNA interface */ | /* copied from Mesh_getFromObject and adapted to RNA interface */ | ||||
| Mesh *rna_Main_meshes_new_from_object(Main *bmain, | Mesh *rna_Main_meshes_new_from_object(Main *bmain, ReportList *reports, Object *object) | ||||
| ReportList *reports, | |||||
| Depsgraph *depsgraph, | |||||
| Object *ob, | |||||
| bool apply_modifiers, | |||||
| bool calc_undeformed) | |||||
| { | { | ||||
| Scene *sce = DEG_get_evaluated_scene(depsgraph); | switch (object->type) { | ||||
| switch (ob->type) { | |||||
| case OB_FONT: | case OB_FONT: | ||||
| case OB_CURVE: | case OB_CURVE: | ||||
| case OB_SURF: | case OB_SURF: | ||||
| case OB_MBALL: | case OB_MBALL: | ||||
| case OB_MESH: | case OB_MESH: | ||||
| break; | break; | ||||
| default: | default: | ||||
| BKE_report(reports, RPT_ERROR, "Object does not have geometry data"); | BKE_report(reports, RPT_ERROR, "Object does not have geometry data"); | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| return BKE_mesh_new_from_object(depsgraph, bmain, sce, ob, apply_modifiers, calc_undeformed); | return BKE_mesh_new_from_object(bmain, object); | ||||
| } | } | ||||
| static Light *rna_Main_lights_new(Main *bmain, const char *name, int type) | static Light *rna_Main_lights_new(Main *bmain, const char *name, int type) | ||||
| { | { | ||||
| char safe_name[MAX_ID_NAME - 2]; | char safe_name[MAX_ID_NAME - 2]; | ||||
| rna_idname_validate(name, safe_name); | rna_idname_validate(name, safe_name); | ||||
| Light *lamp = BKE_light_add(bmain, safe_name); | Light *lamp = BKE_light_add(bmain, safe_name); | ||||
| ▲ Show 20 Lines • Show All 596 Lines • ▼ Show 20 Lines | void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) | ||||
| RNA_def_function_ui_description(func, "Add a new mesh to the main database"); | RNA_def_function_ui_description(func, "Add a new mesh to the main database"); | ||||
| parm = RNA_def_string(func, "name", "Mesh", 0, "", "New name for the data-block"); | parm = RNA_def_string(func, "name", "Mesh", 0, "", "New name for the data-block"); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| /* return type */ | /* return type */ | ||||
| parm = RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh data-block"); | parm = RNA_def_pointer(func, "mesh", "Mesh", "", "New mesh data-block"); | ||||
| RNA_def_function_return(func, parm); | RNA_def_function_return(func, parm); | ||||
| func = RNA_def_function(srna, "new_from_object", "rna_Main_meshes_new_from_object"); | func = RNA_def_function(srna, "new_from_object", "rna_Main_meshes_new_from_object"); | ||||
| RNA_def_function_ui_description(func, | RNA_def_function_ui_description( | ||||
| "Add a new mesh created from object with modifiers applied"); | func, | ||||
| "Add a new mesh created from given object (undeformed geometry if object is original, and " | |||||
| "final evaluated geometry, with all modifiers etc., if object is evaluated)"); | |||||
campbellbarton: double space. | |||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS); | RNA_def_function_flag(func, FUNC_USE_REPORTS); | ||||
| parm = RNA_def_pointer(func, | |||||
| "depsgraph", | |||||
| "Depsgraph", | |||||
| "Dependency Graph", | |||||
| "Evaluated dependency graph within which to evaluate modifiers"); | |||||
| RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); | |||||
| parm = RNA_def_pointer(func, "object", "Object", "", "Object to create mesh from"); | parm = RNA_def_pointer(func, "object", "Object", "", "Object to create mesh from"); | ||||
Not Done Inline ActionsDescriptions here are to be updated to reflect new behavior I guess? mont29: Descriptions here are to be updated to reflect new behavior I guess? | |||||
Done Inline ActionsUpdated the function description. Dependency graph argument is actually annoying one here. I feel liker we can get rid of it if we are happy with BKE_mesh_new_from_object(). Dependency graph is only used to check whether mball is a motherball or not. But think we can replace that check with check whether displist exists for the object. I don't see how properly evaluated motherball will not have displist, and can't see why non-motherballs will have a displist. sergey: Updated the function description.
Dependency graph argument is actually annoying one here.
I… | |||||
Not Done Inline ActionsWould be nice to get rid of that depsgrah argument if possible, yes… Also, I wouldn’t mind a note about how you can pass original or evaluated object, at least (and ideally what's the difference between both cases). Reason is, those end up directly in API doc, so while having more comprehensive description of the process to get mesh from objects elsewhere is fine, I think it is worth having basics covered directly in func doc? Something like that maybe: Add a new mesh created from given object (original undeformed geometry if object is original, and final evaluated geometry, with all modifiers etc., if object is evaluated) Slightly longer description are not a problem here, those won't show in UI, only in API doc. mont29: Would be nice to get rid of that depsgrah argument if possible, yes…
Also, I wouldn’t mind a… | |||||
| RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); | RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED); | ||||
| parm = RNA_def_boolean(func, "apply_modifiers", 0, "", "Apply modifiers"); | |||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | |||||
| RNA_def_boolean(func, | |||||
| "calc_undeformed", | |||||
| false, | |||||
| "Calculate Undeformed", | |||||
| "Calculate undeformed vertex coordinates"); | |||||
| parm = RNA_def_pointer(func, | parm = RNA_def_pointer(func, | ||||
| "mesh", | "mesh", | ||||
| "Mesh", | "Mesh", | ||||
| "", | "", | ||||
| "Mesh created from object, remove it if it is only used for export"); | "Mesh created from object, remove it if it is only used for export"); | ||||
| RNA_def_function_return(func, parm); | RNA_def_function_return(func, parm); | ||||
| func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); | func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); | ||||
| ▲ Show 20 Lines • Show All 1,093 Lines • Show Last 20 Lines | |||||
double space.