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:
authorSergey Sharybin <sergey.vfx@gmail.com>2018-09-13 12:29:08 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-09-14 15:43:56 +0300
commitf827e3c84bc9ec585d16a796b614f4b1694e4507 (patch)
tree5b3fb044d4678810c14037b3fb0a6e2f7f8f8925 /source/blender/blenkernel
parente37479ad895c0bfb12dd0456cc520e1b73b99878 (diff)
Subdiv: Cache Subdiv in CCG surface
Allows to do re-shaping easier, since we will know for sure what was the limit surface the CCG is created for.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_subdiv_ccg.h15
-rw-r--r--source/blender/blenkernel/intern/subdiv_ccg.c4
2 files changed, 18 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_subdiv_ccg.h b/source/blender/blenkernel/BKE_subdiv_ccg.h
index 8f8a605d309..59a31e158cc 100644
--- a/source/blender/blenkernel/BKE_subdiv_ccg.h
+++ b/source/blender/blenkernel/BKE_subdiv_ccg.h
@@ -57,6 +57,12 @@ typedef struct SubdivToCCGSettings {
/* Representation of subdivision surface which uses CCG grids. */
typedef struct SubdivCCG {
+ /* This is a subdivision surface this CCG was created for.
+ *
+ * TODO(sergey): Make sure the whole descriptor is valid, including all the
+ * displacement attached to the surface.
+ */
+ struct Subdiv *subdiv;
/* A level at which geometry was subdivided. This is what defines grid
* resolution. It is NOT the topology refinement level.
*/
@@ -110,7 +116,14 @@ typedef struct SubdivCCG {
*/
} SubdivCCG;
-/* Create real hi-res CCG from subdivision. */
+/* Create real hi-res CCG from subdivision.
+ *
+ * NOTE: CCG becomes an owner of subdiv.
+ *
+ * TODO(sergey): Allow some user-counter or more explicit control over who owns
+ * the Subdiv. The goal should be to allow viewport GL Mesh and CCG to share
+ * same Subsurf without conflicts.
+ */
struct SubdivCCG *BKE_subdiv_to_ccg(
struct Subdiv *subdiv,
const SubdivToCCGSettings *settings,
diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c
index 9f44ce0d090..505d215e7e9 100644
--- a/source/blender/blenkernel/intern/subdiv_ccg.c
+++ b/source/blender/blenkernel/intern/subdiv_ccg.c
@@ -331,6 +331,7 @@ SubdivCCG *BKE_subdiv_to_ccg(
return NULL;
}
BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG);
+ subdiv_ccg->subdiv = subdiv;
return subdiv_ccg;
}
@@ -364,6 +365,9 @@ void BKE_subdiv_ccg_destroy(SubdivCCG *subdiv_ccg)
}
MEM_freeN(subdiv_ccg->grid_hidden);
}
+ if (subdiv_ccg->subdiv != NULL) {
+ BKE_subdiv_free(subdiv_ccg->subdiv);
+ }
MEM_freeN(subdiv_ccg);
}