Subdiv: Split evaluation begin+refine into separate steps
Actually, begin will do the entire initialization. Refine will only refine if there is a topology refiner associated with the Subdiv descriptor. Allows to refine Subdiv to new coarse positions without touching displacement evaluation. Will be needed to update SubdivCCG during sculpt undo.
This commit is contained in:
parent
29eb891658
commit
60d3a801db
|
@ -38,7 +38,10 @@ bool BKE_subdiv_eval_begin(struct Subdiv *subdiv);
|
|||
|
||||
/* coarse_vertex_cos is an optional argument which allows to override coordinates of the coarse
|
||||
* mesh. */
|
||||
bool BKE_subdiv_eval_update_from_mesh(struct Subdiv *subdiv,
|
||||
bool BKE_subdiv_eval_begin_from_mesh(struct Subdiv *subdiv,
|
||||
const struct Mesh *mesh,
|
||||
const float (*coarse_vertex_cos)[3]);
|
||||
bool BKE_subdiv_eval_refine_from_mesh(struct Subdiv *subdiv,
|
||||
const struct Mesh *mesh,
|
||||
const float (*coarse_vertex_cos)[3]);
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape
|
|||
|
||||
void multires_reshape_apply_base_refine_from_base(MultiresReshapeContext *reshape_context)
|
||||
{
|
||||
BKE_subdiv_eval_update_from_mesh(reshape_context->subdiv, reshape_context->base_mesh, NULL);
|
||||
BKE_subdiv_eval_refine_from_mesh(reshape_context->subdiv, reshape_context->base_mesh, NULL);
|
||||
}
|
||||
|
||||
void multires_reshape_apply_base_refine_from_deform(MultiresReshapeContext *reshape_context)
|
||||
|
@ -192,7 +192,7 @@ void multires_reshape_apply_base_refine_from_deform(MultiresReshapeContext *resh
|
|||
float(*deformed_verts)[3] = BKE_multires_create_deformed_base_mesh_vert_coords(
|
||||
depsgraph, object, mmd, NULL);
|
||||
|
||||
BKE_subdiv_eval_update_from_mesh(
|
||||
BKE_subdiv_eval_refine_from_mesh(
|
||||
reshape_context->subdiv, reshape_context->base_mesh, deformed_verts);
|
||||
|
||||
MEM_freeN(deformed_verts);
|
||||
|
|
|
@ -67,7 +67,7 @@ Subdiv *multires_reshape_create_subdiv(Depsgraph *depsgraph,
|
|||
SubdivSettings subdiv_settings;
|
||||
BKE_multires_subdiv_settings_init(&subdiv_settings, mmd);
|
||||
Subdiv *subdiv = BKE_subdiv_new_from_mesh(&subdiv_settings, base_mesh);
|
||||
if (!BKE_subdiv_eval_update_from_mesh(subdiv, base_mesh, NULL)) {
|
||||
if (!BKE_subdiv_eval_begin_from_mesh(subdiv, base_mesh, NULL)) {
|
||||
BKE_subdiv_free(subdiv);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -589,7 +589,7 @@ Mesh *BKE_subdiv_to_ccg_mesh(Subdiv *subdiv,
|
|||
{
|
||||
/* Make sure evaluator is ready. */
|
||||
BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG);
|
||||
if (!BKE_subdiv_eval_update_from_mesh(subdiv, coarse_mesh, NULL)) {
|
||||
if (!BKE_subdiv_eval_begin_from_mesh(subdiv, coarse_mesh, NULL)) {
|
||||
if (coarse_mesh->totpoly) {
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ void BKE_subdiv_deform_coarse_vertices(struct Subdiv *subdiv,
|
|||
BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_MESH);
|
||||
/* Make sure evaluator is up to date with possible new topology, and that
|
||||
* is refined for the new positions of coarse vertices. */
|
||||
if (!BKE_subdiv_eval_update_from_mesh(subdiv, coarse_mesh, vertex_cos)) {
|
||||
if (!BKE_subdiv_eval_begin_from_mesh(subdiv, coarse_mesh, vertex_cos)) {
|
||||
/* This could happen in two situations:
|
||||
* - OpenSubdiv is disabled.
|
||||
* - Something totally bad happened, and OpenSubdiv rejected our
|
||||
|
|
|
@ -121,13 +121,20 @@ static void set_face_varying_data_from_uv(Subdiv *subdiv,
|
|||
}
|
||||
}
|
||||
|
||||
bool BKE_subdiv_eval_update_from_mesh(Subdiv *subdiv,
|
||||
const Mesh *mesh,
|
||||
const float (*coarse_vertex_cos)[3])
|
||||
bool BKE_subdiv_eval_begin_from_mesh(Subdiv *subdiv,
|
||||
const Mesh *mesh,
|
||||
const float (*coarse_vertex_cos)[3])
|
||||
{
|
||||
if (!BKE_subdiv_eval_begin(subdiv)) {
|
||||
return false;
|
||||
}
|
||||
return BKE_subdiv_eval_refine_from_mesh(subdiv, mesh, coarse_vertex_cos);
|
||||
}
|
||||
|
||||
bool BKE_subdiv_eval_refine_from_mesh(Subdiv *subdiv,
|
||||
const Mesh *mesh,
|
||||
const float (*coarse_vertex_cos)[3])
|
||||
{
|
||||
if (subdiv->evaluator == NULL) {
|
||||
/* NOTE: This situation is supposed to be handled by begin(). */
|
||||
BLI_assert(!"Is not supposed to happen");
|
||||
|
|
|
@ -1168,7 +1168,7 @@ Mesh *BKE_subdiv_to_mesh(Subdiv *subdiv,
|
|||
BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_MESH);
|
||||
/* Make sure evaluator is up to date with possible new topology, and that
|
||||
* it is refined for the new positions of coarse vertices. */
|
||||
if (!BKE_subdiv_eval_update_from_mesh(subdiv, coarse_mesh, NULL)) {
|
||||
if (!BKE_subdiv_eval_begin_from_mesh(subdiv, coarse_mesh, NULL)) {
|
||||
/* This could happen in two situations:
|
||||
* - OpenSubdiv is disabled.
|
||||
* - Something totally bad happened, and OpenSubdiv rejected our
|
||||
|
|
Loading…
Reference in New Issue