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.
This commit is contained in:
@@ -57,6 +57,12 @@ typedef struct SubdivToCCGSettings {
|
|||||||
|
|
||||||
/* Representation of subdivision surface which uses CCG grids. */
|
/* Representation of subdivision surface which uses CCG grids. */
|
||||||
typedef struct SubdivCCG {
|
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
|
/* A level at which geometry was subdivided. This is what defines grid
|
||||||
* resolution. It is NOT the topology refinement level.
|
* resolution. It is NOT the topology refinement level.
|
||||||
*/
|
*/
|
||||||
@@ -110,7 +116,14 @@ typedef struct SubdivCCG {
|
|||||||
*/
|
*/
|
||||||
} 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 SubdivCCG *BKE_subdiv_to_ccg(
|
||||||
struct Subdiv *subdiv,
|
struct Subdiv *subdiv,
|
||||||
const SubdivToCCGSettings *settings,
|
const SubdivToCCGSettings *settings,
|
||||||
|
@@ -331,6 +331,7 @@ SubdivCCG *BKE_subdiv_to_ccg(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG);
|
BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG);
|
||||||
|
subdiv_ccg->subdiv = subdiv;
|
||||||
return subdiv_ccg;
|
return subdiv_ccg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,6 +365,9 @@ void BKE_subdiv_ccg_destroy(SubdivCCG *subdiv_ccg)
|
|||||||
}
|
}
|
||||||
MEM_freeN(subdiv_ccg->grid_hidden);
|
MEM_freeN(subdiv_ccg->grid_hidden);
|
||||||
}
|
}
|
||||||
|
if (subdiv_ccg->subdiv != NULL) {
|
||||||
|
BKE_subdiv_free(subdiv_ccg->subdiv);
|
||||||
|
}
|
||||||
MEM_freeN(subdiv_ccg);
|
MEM_freeN(subdiv_ccg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -227,14 +227,16 @@ static Mesh *applyModifier_subdiv(ModifierData *md,
|
|||||||
* still missing in implementation.
|
* still missing in implementation.
|
||||||
*/
|
*/
|
||||||
if ((ctx->object->mode & OB_MODE_SCULPT) && G.debug_value == 128) {
|
if ((ctx->object->mode & OB_MODE_SCULPT) && G.debug_value == 128) {
|
||||||
|
/* NOTE: CCG takes ownership over Subdiv. */
|
||||||
result = multires_as_ccg(mmd, ctx, mesh, subdiv);
|
result = multires_as_ccg(mmd, ctx, mesh, subdiv);
|
||||||
|
// BKE_subdiv_stats_print(&subdiv->stats);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
result = multires_as_mesh(mmd, ctx, mesh, subdiv);
|
result = multires_as_mesh(mmd, ctx, mesh, subdiv);
|
||||||
}
|
|
||||||
/* TODO(sergey): Cache subdiv somehow. */
|
/* TODO(sergey): Cache subdiv somehow. */
|
||||||
// BKE_subdiv_stats_print(&subdiv->stats);
|
// BKE_subdiv_stats_print(&subdiv->stats);
|
||||||
BKE_subdiv_free(subdiv);
|
BKE_subdiv_free(subdiv);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user