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!
This commit is contained in:
@@ -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],
|
||||
|
||||
Reference in New Issue
Block a user