Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-07-31 14:04:23 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-07-31 14:04:23 +0300
commit55fead4767efde7b3ab37443619e1ea984c0ba87 (patch)
tree11654c017a9bb16d4c60b6a725a94a458648cf8d /source
parent31fe49626f0e0aed87c54822af11410e1bbfed21 (diff)
Use polygon normals for sculpt drawing
Wasn't working correctly since using MLoopTri, this is improved over 2.75 which only handled tris & quads.
Diffstat (limited to 'source')
-rw-r--r--source/blender/gpu/intern/gpu_buffers.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index 11697c5a2b3..2e1b866a160 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -51,6 +51,7 @@
#include "BKE_ccg.h"
#include "BKE_DerivedMesh.h"
#include "BKE_paint.h"
+#include "BKE_mesh.h"
#include "BKE_pbvh.h"
#include "DNA_userdef_types.h"
@@ -1275,6 +1276,10 @@ void GPU_update_mesh_pbvh_buffers(
#undef UPDATE_VERTEX
}
else {
+ /* calculate normal for each polygon only once */
+ unsigned int mpoly_prev = UINT_MAX;
+ short no[3];
+
for (i = 0; i < buffers->face_indices_len; ++i) {
const MLoopTri *lt = &buffers->looptri[buffers->face_indices[i]];
const unsigned int vtri[3] = {
@@ -1282,8 +1287,6 @@ void GPU_update_mesh_pbvh_buffers(
buffers->mloop[lt->tri[1]].v,
buffers->mloop[lt->tri[2]].v,
};
- float fno[3];
- short no[3];
float fmask;
@@ -1291,16 +1294,19 @@ void GPU_update_mesh_pbvh_buffers(
continue;
/* Face normal and mask */
- normal_tri_v3(fno,
- mvert[vtri[0]].co,
- mvert[vtri[1]].co,
- mvert[vtri[2]].co);
+ if (lt->poly != mpoly_prev) {
+ const MPoly *mp = &buffers->mpoly[lt->poly];
+ float fno[3];
+ BKE_mesh_calc_poly_normal(mp, &buffers->mloop[mp->loopstart], mvert, fno);
+ normal_float_to_short_v3(no, fno);
+ mpoly_prev = lt->poly;
+ }
+
if (vmask) {
fmask = (vmask[vtri[0]] +
vmask[vtri[1]] +
vmask[vtri[2]]) / 3.0f;
}
- normal_float_to_short_v3(no, fno);
for (j = 0; j < 3; j++) {
const MVert *v = &mvert[vtri[j]];