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
diff options
context:
space:
mode:
authorLuca Rood <dev@lucarood.com>2016-11-23 22:19:03 +0300
committerLuca Rood <dev@lucarood.com>2016-12-01 17:41:56 +0300
commit7fe7835d13de669be3b65b4e36000e8883f7117b (patch)
tree5748a049c198e612225e0a330d602e436197d37a /source/blender/blenkernel/intern/subsurf_ccg.c
parent69a75b0169c64b14f00de7b7e2da45720cdc4d06 (diff)
Fix (unreported) looptri array not being recalculated in ccgDM and emDM
In ccgDM and emDM, looptri array recalculation was being handled directly by `*DM_getLoopTriArray` (`getLoopTriArray` callback), while `*DM_recalcLoopTri` (`recalcLoopTri` callback) was doing nothing. This results in the array not being recalculated when other functions that depend on the array data called the recalc function. This moves all the recalculation code to `*DM_recalcLoopTri` and makes `*DM_getLoopTriArray` call that. This commit also makes a minor change to the `getNumLoopTri` function, so that it returns the correct number without having to recalculate the looptri array. Reviewed By: mont29 Differential Revision: https://developer.blender.org/D2375
Diffstat (limited to 'source/blender/blenkernel/intern/subsurf_ccg.c')
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 6d57c5f09e8..c4665c40ec4 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -4474,46 +4474,46 @@ static void ccgDM_recalcTessellation(DerivedMesh *UNUSED(dm))
/* Nothing to do: CCG handles creating its own tessfaces */
}
-static void ccgDM_recalcLoopTri(DerivedMesh *UNUSED(dm))
+static void ccgDM_recalcLoopTri(DerivedMesh *dm)
{
- /* Nothing to do: CCG tessellation is known,
- * allocate and fill in with ccgDM_getLoopTriArray */
+ BLI_rw_mutex_lock(&loops_cache_rwlock, THREAD_LOCK_WRITE);
+ MLoopTri *mlooptri;
+ const int tottri = dm->numPolyData * 2;
+ int i, poly_index;
+
+ DM_ensure_looptri_data(dm);
+ mlooptri = dm->looptris.array;
+
+ BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num);
+ BLI_assert(tottri == dm->looptris.num);
+
+ for (i = 0, poly_index = 0; i < tottri; i += 2, poly_index += 1) {
+ MLoopTri *lt;
+ lt = &mlooptri[i];
+ /* quad is (0, 3, 2, 1) */
+ lt->tri[0] = (poly_index * 4) + 0;
+ lt->tri[1] = (poly_index * 4) + 2;
+ lt->tri[2] = (poly_index * 4) + 3;
+ lt->poly = poly_index;
+
+ lt = &mlooptri[i + 1];
+ lt->tri[0] = (poly_index * 4) + 0;
+ lt->tri[1] = (poly_index * 4) + 1;
+ lt->tri[2] = (poly_index * 4) + 2;
+ lt->poly = poly_index;
+ }
+ BLI_rw_mutex_unlock(&loops_cache_rwlock);
}
static const MLoopTri *ccgDM_getLoopTriArray(DerivedMesh *dm)
{
- BLI_rw_mutex_lock(&loops_cache_rwlock, THREAD_LOCK_WRITE);
if (dm->looptris.array) {
BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num);
}
else {
- MLoopTri *mlooptri;
- const int tottri = dm->numPolyData * 2;
- int i, poly_index;
-
- DM_ensure_looptri_data(dm);
- mlooptri = dm->looptris.array;
-
- BLI_assert(poly_to_tri_count(dm->numPolyData, dm->numLoopData) == dm->looptris.num);
- BLI_assert(tottri == dm->looptris.num);
-
- for (i = 0, poly_index = 0; i < tottri; i += 2, poly_index += 1) {
- MLoopTri *lt;
- lt = &mlooptri[i];
- /* quad is (0, 3, 2, 1) */
- lt->tri[0] = (poly_index * 4) + 0;
- lt->tri[1] = (poly_index * 4) + 2;
- lt->tri[2] = (poly_index * 4) + 3;
- lt->poly = poly_index;
-
- lt = &mlooptri[i + 1];
- lt->tri[0] = (poly_index * 4) + 0;
- lt->tri[1] = (poly_index * 4) + 1;
- lt->tri[2] = (poly_index * 4) + 2;
- lt->poly = poly_index;
- }
+ dm->recalcLoopTri(dm);
}
- BLI_rw_mutex_unlock(&loops_cache_rwlock);
+
return dm->looptris.array;
}