diff options
-rw-r--r-- | source/blender/blenkernel/BKE_subdiv_ccg.h | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subdiv_ccg.c | 25 |
2 files changed, 14 insertions, 16 deletions
diff --git a/source/blender/blenkernel/BKE_subdiv_ccg.h b/source/blender/blenkernel/BKE_subdiv_ccg.h index 83d97974a28..cbdc32e319b 100644 --- a/source/blender/blenkernel/BKE_subdiv_ccg.h +++ b/source/blender/blenkernel/BKE_subdiv_ccg.h @@ -148,6 +148,7 @@ typedef struct SubdivCCG { /* Create real hi-res CCG from subdivision. * + * NOTE: Subdiv is expected to be refined and ready for evaluation. * NOTE: CCG becomes an owner of subdiv. * * TODO(sergey): Allow some user-counter or more explicit control over who owns @@ -156,9 +157,7 @@ typedef struct SubdivCCG { */ struct SubdivCCG *BKE_subdiv_to_ccg( struct Subdiv *subdiv, - const SubdivToCCGSettings *settings, - const struct Mesh *coarse_mesh); - + const SubdivToCCGSettings *settings); /* Destroy CCG representation of subdivision surface. */ void BKE_subdiv_ccg_destroy(SubdivCCG *subdiv_ccg); diff --git a/source/blender/blenkernel/intern/subdiv_ccg.c b/source/blender/blenkernel/intern/subdiv_ccg.c index f9017ef4b1f..43a94c117c5 100644 --- a/source/blender/blenkernel/intern/subdiv_ccg.c +++ b/source/blender/blenkernel/intern/subdiv_ccg.c @@ -318,17 +318,10 @@ static void subdiv_ccg_eval_grids_task( static bool subdiv_ccg_evaluate_grids( SubdivCCG *subdiv_ccg, - Subdiv *subdiv, - const Mesh *coarse_mesh) + Subdiv *subdiv) { OpenSubdiv_TopologyRefiner *topology_refiner = subdiv->topology_refiner; const int num_faces = topology_refiner->getNumFaces(topology_refiner); - /* Make sure evaluator is ready. */ - if (!BKE_subdiv_eval_update_from_mesh(subdiv, coarse_mesh)) { - if (num_faces) { - return false; - } - } /* Initialize data passed to all the tasks. */ CCGEvalGridsData data; data.subdiv_ccg = subdiv_ccg; @@ -374,8 +367,7 @@ static void subdiv_ccg_init_faces(SubdivCCG *subdiv_ccg) SubdivCCG *BKE_subdiv_to_ccg( Subdiv *subdiv, - const SubdivToCCGSettings *settings, - const Mesh *coarse_mesh) + const SubdivToCCGSettings *settings) { BKE_subdiv_stats_begin(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG); SubdivCCG *subdiv_ccg = MEM_callocN(sizeof(SubdivCCG), "subdiv ccg"); @@ -386,7 +378,7 @@ SubdivCCG *BKE_subdiv_to_ccg( subdiv_ccg_init_layers(subdiv_ccg, settings); subdiv_ccg_alloc_elements(subdiv_ccg, subdiv); subdiv_ccg_init_faces(subdiv_ccg); - if (!subdiv_ccg_evaluate_grids(subdiv_ccg, subdiv, coarse_mesh)) { + if (!subdiv_ccg_evaluate_grids(subdiv_ccg, subdiv)) { BKE_subdiv_ccg_destroy(subdiv_ccg); BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG); return NULL; @@ -400,8 +392,15 @@ Mesh *BKE_subdiv_to_ccg_mesh( const SubdivToCCGSettings *settings, const Mesh *coarse_mesh) { - SubdivCCG *subdiv_ccg = BKE_subdiv_to_ccg( - subdiv, settings, coarse_mesh); + /* 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)) { + if (coarse_mesh->totpoly) { + return false; + } + } + BKE_subdiv_stats_end(&subdiv->stats, SUBDIV_STATS_SUBDIV_TO_CCG); + SubdivCCG *subdiv_ccg = BKE_subdiv_to_ccg(subdiv, settings); if (subdiv_ccg == NULL) { return NULL; } |