diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2014-01-24 20:49:29 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2014-01-24 20:49:29 +0400 |
commit | 9e2ebecb21d949aa503a9bd8c881a7fcf1175d1a (patch) | |
tree | 14fbe552f8f42ab85538ee2f243efa7ffa825bd8 /source/blender | |
parent | 257f4088649e751a8a739dbcc17ad5b299d68c25 (diff) |
Add convinient access to full bitangent for loops (some export formats like FBX expect full bitangents, better to compute them in C than in python...)
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index cf634f9c7d4..6e1b39e9ea7 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -361,6 +361,22 @@ static float rna_MeshLoop_bitangent_sign_get(PointerRNA *ptr) return (vec) ? (*vec)[3] : 0.0f; } +static void rna_MeshLoop_bitangent_get(PointerRNA *ptr, float *values) +{ + Mesh *me = rna_mesh(ptr); + MLoop *ml = (MLoop *)ptr->data; + const float (*nor)[3] = CustomData_get(&me->ldata, (int)(ml - me->mloop), CD_NORMAL); + const float (*vec)[4] = CustomData_get(&me->ldata, (int)(ml - me->mloop), CD_MLOOPTANGENT); + + if (nor && vec) { + cross_v3_v3v3(values, (const float *)nor, (const float *)vec); + mul_v3_fl(values, (*vec)[3]); + } + else { + zero_v3(values); + } +} + static void rna_MeshPolygon_normal_get(PointerRNA *ptr, float *values) { Mesh *me = rna_mesh(ptr); @@ -1913,6 +1929,15 @@ static void rna_def_mloop(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Bitangent Sign", "Sign of the bitangent vector of this vertex for this polygon (must be computed " "beforehand using calc_tangents, bitangent = bitangent_sign * cross(normal, tangent))"); + + prop = RNA_def_property(srna, "bitangent", PROP_FLOAT, PROP_DIRECTION); + RNA_def_property_array(prop, 3); + RNA_def_property_range(prop, -1.0f, 1.0f); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_float_funcs(prop, "rna_MeshLoop_bitangent_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Bitangent", + "Bitangent vector of this vertex for this polygon (must be computed beforehand using " + "calc_tangents, *use it only if really needed*, slower access than bitangent_sign)"); } static void rna_def_mpolygon(BlenderRNA *brna) |