diff options
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 23 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object_api.c | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_texture.c | 4 |
5 files changed, 35 insertions, 7 deletions
diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 0a2c876ec50..b78972ea64c 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -405,7 +405,7 @@ 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, int calc_tessface); + struct Object *ob, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed); /* 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 5d554f4393c..1e77a799cd4 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -276,7 +276,7 @@ static Mesh *rna_Main_meshes_new(Main *bmain, const char *name) /* 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, int calc_tessface) + Object *ob, int apply_modifiers, int settings, int calc_tessface, int calc_undeformed) { Mesh *tmpmesh; Curve *tmpcu = NULL, *copycu; @@ -379,6 +379,9 @@ Mesh *rna_Main_meshes_new_from_object( CustomDataMask mask = CD_MASK_MESH; /* this seems more suitable, exporter, * for example, needs CD_MASK_MDEFORMVERT */ + if (calc_undeformed) + mask |= CD_MASK_ORCO; + /* Write the display mesh into the dummy mesh */ if (render) dm = mesh_create_derived_render(sce, ob, mask); @@ -386,7 +389,7 @@ Mesh *rna_Main_meshes_new_from_object( dm = mesh_create_derived_view(sce, ob, mask); tmpmesh = BKE_mesh_add(bmain, "Mesh"); - DM_to_mesh(dm, tmpmesh, ob); + DM_to_mesh(dm, tmpmesh, ob, mask); dm->release(dm); } @@ -1172,6 +1175,7 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) 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"); + RNA_def_boolean(func, "calc_undeformed", false, "Calculate Undeformed", "Calculate undeformed vertex coordinates"); 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_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index ecdd0c949bd..86b2aa4fb2b 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -591,6 +591,23 @@ static void rna_MeshVertex_groups_begin(CollectionPropertyIterator *iter, Pointe rna_iterator_array_begin(iter, NULL, 0, 0, 0, NULL); } +static void rna_MeshVertex_undeformed_co_get(PointerRNA *ptr, float values[3]) +{ + Mesh *me = rna_mesh(ptr); + MVert *mvert = (MVert *)ptr->data; + float (*orco)[3] = CustomData_get_layer(&me->vdata, CD_ORCO); + + if (orco) { + /* orco is normalized to 0..1, we do inverse to match mvert->co */ + float loc[3], size[3]; + + BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, loc, NULL, size); + madd_v3_v3v3v3(values, loc, orco[(mvert - me->mvert)], size); + } + else + copy_v3_v3(values, mvert->co); +} + static int rna_CustomDataLayer_active_get(PointerRNA *ptr, CustomData *data, int type, int render) { int n = ((CustomDataLayer *)ptr->data) - data->layers; @@ -1638,6 +1655,12 @@ static void rna_def_mvert(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_int_funcs(prop, "rna_MeshVertex_index_get", NULL, NULL); RNA_def_property_ui_text(prop, "Index", "Index number of the vertex"); + + prop = RNA_def_property(srna, "undeformed_co", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Undeformed Location", "For meshes with modifiers applied, the coordinate of the vertex with no deforming modifiers applied, as used for generated texture coordinates. "); + RNA_def_property_float_funcs(prop, "rna_MeshVertex_undeformed_co_get", NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); } static void rna_def_medge(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 7715dfa64de..a4e532660f1 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -115,9 +115,9 @@ static void rna_Scene_mat_convert_space(Object *ob, ReportList *reports, bPoseCh /* settings: 0 - preview, 1 - render */ static Mesh *rna_Object_to_mesh( Object *ob, ReportList *reports, Scene *sce, - int apply_modifiers, int settings, int calc_tessface) + int apply_modifiers, int settings, int calc_tessface, int calc_undeformed) { - return rna_Main_meshes_new_from_object(G.main, reports, sce, ob, apply_modifiers, settings, calc_tessface); + return rna_Main_meshes_new_from_object(G.main, reports, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed); } /* mostly a copy from convertblender.c */ @@ -456,6 +456,7 @@ void RNA_api_object(StructRNA *srna) 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"); + RNA_def_boolean(func, "calc_undeformed", false, "Calculate Undeformed", "Calculate undeformed vertex coordinates"); 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_texture.c b/source/blender/makesrna/intern/rna_texture.c index d01eab053bd..be6defa11d7 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1625,7 +1625,7 @@ static void rna_def_texture_pointdensity(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - static EnumPropertyItem vertice_cache_items[] = { + static EnumPropertyItem vertex_cache_items[] = { {TEX_PD_OBJECTLOC, "OBJECT_LOCATION", 0, "Object Location", ""}, {TEX_PD_OBJECTSPACE, "OBJECT_SPACE", 0, "Object Space", ""}, {TEX_PD_WORLDSPACE, "WORLD_SPACE", 0, "Global Space", ""}, @@ -1695,7 +1695,7 @@ static void rna_def_texture_pointdensity(BlenderRNA *brna) prop = RNA_def_property(srna, "vertex_cache_space", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ob_cache_space"); - RNA_def_property_enum_items(prop, vertice_cache_items); + RNA_def_property_enum_items(prop, vertex_cache_items); RNA_def_property_ui_text(prop, "Vertices Cache", "Coordinate system to cache vertices in"); RNA_def_property_update(prop, 0, "rna_Texture_update"); |