diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-05 09:56:41 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-05-05 09:56:41 +0400 |
commit | 62087935ec92e24bce362489cadc944bc256e8cc (patch) | |
tree | b8056f1bfebd2812a5a8ed6120ba168ee79bd28f /source/blender/makesrna/intern/rna_mesh.c | |
parent | 998b9241bedea82f4501b4c4e5453d7becb07d3e (diff) |
Fix #35209: cycles generated texture coordinates did not stick to deforming meshes.
Diffstat (limited to 'source/blender/makesrna/intern/rna_mesh.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 23 |
1 files changed, 23 insertions, 0 deletions
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) |