diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-07-16 20:36:03 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-07-16 20:55:14 +0300 |
commit | 595a491e63d6f3f3462675d38cfa71b4e784fe9c (patch) | |
tree | df32ec17691b9280d7b2fa675cd5e5a0f87ea849 /source/blender/blenlib/intern | |
parent | c8f6313487dfbbee030c6796220cc0d91228d658 (diff) |
Add tessellation data to DerivedMesh (LoopTri)
This stores loop indices into the loop array giving easier acess
to data such as vertex-colors and UV's,
removing the need to store an MFace duplicate of custom-data.
This doesn't yet move all internal code from MFace to LoopTri just yet.
Only applies to:
- opengl drawing
- sculpting (pbvh)
- vertex/weight paint
Thanks to @psy-fi for review, fixes and improvements to drawing!
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/math_geom.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index f40f1cc3f97..4662762ad21 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -3549,6 +3549,40 @@ void map_to_sphere(float *r_u, float *r_v, const float x, const float y, const f /********************************* Normals **********************************/ +void accumulate_vertex_normals_tri( + float n1[3], float n2[3], float n3[3], + const float f_no[3], + const float co1[3], const float co2[3], const float co3[3]) +{ + float vdiffs[3][3]; + const int nverts = 3; + + /* compute normalized edge vectors */ + sub_v3_v3v3(vdiffs[0], co2, co1); + sub_v3_v3v3(vdiffs[1], co3, co2); + sub_v3_v3v3(vdiffs[2], co1, co3); + + normalize_v3(vdiffs[0]); + normalize_v3(vdiffs[1]); + normalize_v3(vdiffs[2]); + + /* accumulate angle weighted face normal */ + { + float *vn[] = {n1, n2, n3}; + const float *prev_edge = vdiffs[nverts - 1]; + int i; + + for (i = 0; i < nverts; i++) { + const float *cur_edge = vdiffs[i]; + const float fac = saacos(-dot_v3v3(cur_edge, prev_edge)); + + /* accumulate */ + madd_v3_v3fl(vn[i], f_no, fac); + prev_edge = cur_edge; + } + } +} + void accumulate_vertex_normals( float n1[3], float n2[3], float n3[3], float n4[3], const float f_no[3], |