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-06 18:06:17 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2018-09-11 17:37:02 +0300
commit3fbdcefa174dd85972b7b63c0955e3a8d42f6943 (patch)
tree6b1d4b1538f18e847f2e12204a79d89b937edc28 /source/blender/blenkernel/intern/paint.c
parent998a80435819387ce88d922d7fd7049e8e27b7bf (diff)
Subdiv: Initial implementation of CCG
Attempts to substitude CCGDM with an OpenSubdiv based structure which has less abstraction levels. The missing part in this substitude is a face pointers which old CCGDM/multires code was using to stitch faces (averaging boundaries). Another curial bit missing: "reshaping" of multires CD_MDISPS to the state of new PBVH grids. The new code is only available when OpenSubdiv modifier is enabled (WITH_OPENSUBDIV_MODIFIER=ON) and with debug value of 128. This is so this WIP code is not interfering with current production machines in the studio. Reviewers: brecht Reviewed By: brecht Differential Revision: https://developer.blender.org/D3685
Diffstat (limited to 'source/blender/blenkernel/intern/paint.c')
-rw-r--r--source/blender/blenkernel/intern/paint.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 12cdb4586c1..edea8784715 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -55,6 +55,7 @@
#include "BKE_animsys.h"
#include "BKE_brush.h"
+#include "BKE_ccg.h"
#include "BKE_colortools.h"
#include "BKE_deform.h"
#include "BKE_main.h"
@@ -72,6 +73,7 @@
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_pbvh.h"
+#include "BKE_subdiv_ccg.h"
#include "BKE_subsurf.h"
#include "DEG_depsgraph.h"
@@ -910,7 +912,6 @@ void BKE_sculpt_update_mesh_elements(
ss->kb = (mmd == NULL) ? BKE_keyblock_from_object(ob) : NULL;
Mesh *me_eval = mesh_get_eval_final(depsgraph, scene, ob, CD_MASK_BAREMESH);
- Mesh *me_eval_deform = mesh_get_eval_deform(depsgraph, scene, ob, CD_MASK_BAREMESH);
/* VWPaint require mesh info for loop lookup, so require sculpt mode here */
if (mmd && ob->mode & OB_MODE_SCULPT) {
@@ -931,7 +932,7 @@ void BKE_sculpt_update_mesh_elements(
ss->vmask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK);
}
- PBVH *pbvh = BKE_sculpt_object_pbvh_ensure(ob, me_eval_deform);
+ PBVH *pbvh = BKE_sculpt_object_pbvh_ensure(depsgraph, ob);
BLI_assert(pbvh == ss->pbvh);
UNUSED_VARS_NDEBUG(pbvh);
MEM_SAFE_FREE(ss->pmap);
@@ -1139,7 +1140,7 @@ static PBVH *build_pbvh_for_dynamic_topology(Object *ob)
return pbvh;
}
-static PBVH *build_regular_mesh_pbvh(Object *ob, Mesh *me_eval_deform)
+static PBVH *build_pbvh_from_regular_mesh(Object *ob, Mesh *me_eval_deform)
{
Mesh *me = BKE_object_get_original_mesh(ob);
const int looptris_num = poly_to_tri_count(me->totpoly, me->totloop);
@@ -1174,7 +1175,24 @@ static PBVH *build_regular_mesh_pbvh(Object *ob, Mesh *me_eval_deform)
return pbvh;
}
-PBVH *BKE_sculpt_object_pbvh_ensure(Object *ob, Mesh *me_eval_deform)
+static PBVH *build_pbvh_from_ccg(Object *ob, SubdivCCG *subdiv_ccg)
+{
+ CCGKey key;
+ BKE_subdiv_ccg_key_top_level(&key, subdiv_ccg);
+ PBVH *pbvh = BKE_pbvh_new();
+ BKE_pbvh_build_grids(
+ pbvh,
+ subdiv_ccg->grids, subdiv_ccg->num_grids,
+ &key,
+ NULL,
+ subdiv_ccg->grid_flag_mats,
+ subdiv_ccg->grid_hidden);
+ pbvh_show_diffuse_color_set(pbvh, ob->sculpt->show_diffuse_color);
+ pbvh_show_mask_set(pbvh, ob->sculpt->show_mask);
+ return pbvh;
+}
+
+PBVH *BKE_sculpt_object_pbvh_ensure(Depsgraph *depsgraph, Object *ob)
{
if (ob == NULL || ob->sculpt == NULL) {
return NULL;
@@ -1189,8 +1207,17 @@ PBVH *BKE_sculpt_object_pbvh_ensure(Object *ob, Mesh *me_eval_deform)
/* Sculpting on a BMesh (dynamic-topology) gets a special PBVH. */
pbvh = build_pbvh_for_dynamic_topology(ob);
}
- else if (ob->type == OB_MESH) {
- pbvh = build_regular_mesh_pbvh(ob, me_eval_deform);
+ else {
+ Object *object_eval = DEG_get_evaluated_object(depsgraph, ob);
+ Mesh *mesh_eval = object_eval->data;
+ if (mesh_eval->runtime.subsurf_ccg != NULL) {
+ pbvh = build_pbvh_from_ccg(ob, mesh_eval->runtime.subsurf_ccg);
+ }
+ else if (ob->type == OB_MESH) {
+ Mesh *me_eval_deform = mesh_get_eval_deform(
+ depsgraph, DEG_get_evaluated_scene(depsgraph), ob, CD_MASK_BAREMESH);
+ pbvh = build_pbvh_from_regular_mesh(ob, me_eval_deform);
+ }
}
ob->sculpt->pbvh = pbvh;