[Bf-blender-cvs] [c55ec07] cycles-ptex-24: Texpaint beginning
Nicholas Bishop
noreply at git.blender.org
Fri Jan 30 18:00:38 CET 2015
Commit: c55ec074ef0a37b6cf193c9f290cc1543f84712c
Author: Nicholas Bishop
Date: Thu Jan 22 20:02:51 2015 +0100
Branches: cycles-ptex-24
https://developer.blender.org/rBc55ec074ef0a37b6cf193c9f290cc1543f84712c
Texpaint beginning
===================================================================
M source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 6bc597f..cc5cf9d 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -223,6 +223,9 @@ typedef struct ProjPaintState {
MTFace **dm_mtface_clone; /* other UV map, use for cloning between layers */
MTFace *dm_mtface_stencil;
+ /* TODO */
+ MTFace *dm_mtface_ptex;
+
Image *stencil_ima;
Image *canvas_ima;
Image *clone_ima;
@@ -3293,7 +3296,8 @@ static bool proj_paint_state_dm_init(ProjPaintState *ps)
ps->dm_release = true;
}
- if (!CustomData_has_layer(&ps->dm->faceData, CD_MTFACE)) {
+ if (!CustomData_has_layer(&ps->dm->faceData, CD_MTFACE) &&
+ !CustomData_has_layer(&ps->dm->faceData, CD_TESSFACE_PTEX)) {
if (ps->dm_release)
ps->dm->release(ps->dm);
@@ -3307,9 +3311,15 @@ static bool proj_paint_state_dm_init(ProjPaintState *ps)
ps->dm_totvert = ps->dm->getNumVerts(ps->dm);
ps->dm_totface = ps->dm->getNumTessFaces(ps->dm);
+ tess_ptex = ps->dm->getTessFaceDataArray(ps->dm, CD_TESSFACE_PTEX);
ps->dm_mvert = ps->dm->getVertArray(ps->dm);
ps->dm_mface = ps->dm->getTessFaceArray(ps->dm);
ps->dm_mtface = MEM_mallocN(ps->dm_totface * sizeof(MTFace *), "proj_paint_mtfaces");
+ // TODO
+ if (CustomData_has_layer(&ps->dm->faceData, CD_TESSFACE_PTEX)) {
+ ps->dm_mtface_ptex = MEM_callocN(ps->dm_totface * sizeof(*ps->dm_mtface_ptex),
+ "ProjPaintState.dm_mtface_ptex");
+ }
return true;
}
@@ -3570,6 +3580,8 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps, MemArena *arena,
slot = project_paint_face_paint_slot(ps, face_index);
/* all faces should have a valid slot, reassert here */
if (slot == NULL) {
+ // TODO
+ BLI_assert(!"Ptex TODO");
tf_base = CustomData_get_layer(&ps->dm->faceData, CD_MTFACE);
tpage = ps->canvas_ima;
}
@@ -3580,6 +3592,12 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps, MemArena *arena,
slot_last = slot;
}
+ // TODO
+ if (loop_ptex) {
+ slot->ima = loop_ptex->image;
+ tf_base = ps->dm_mtface_ptex;
+ }
+
/* don't allow using the same inage for painting and stencilling */
if (slot->ima == ps->stencil_ima)
continue;
@@ -3592,6 +3610,23 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps, MemArena *arena,
}
*tf = tf_base + face_index;
+ // TODO
+ if (ps->dm_mtface_ptex) {
+ ImBuf *ibuf = BKE_image_acquire_ibuf(slot->ima, NULL, NULL);
+ if (ibuf && ibuf->ptex_regions) {
+ // I'm sleepy
+ int abc;
+ for (abc = 0; abc < 4; abc++) {
+ float *dst = (*tf)->uv[abc];
+ const MLoopPtexUV *src = &tess_ptex[face_index].corners[abc];
+ const ImPtexRegion *ipr = &ibuf->ptex_regions[src->id];
+
+ dst[0] = (src->uv[0] * ipr->width + ipr->x) / ibuf->x;
+ dst[1] = (src->uv[1] * ipr->height + ipr->y) / ibuf->y;
+ }
+ }
+ BKE_image_release_ibuf(slot->ima, ibuf, NULL);
+ }
if (project_paint_clone_face_skip(ps, layer_clone, slot, face_index)) {
continue;
@@ -3659,7 +3694,11 @@ static void project_paint_begin(ProjPaintState *ps)
const int diameter = 2 * BKE_brush_size_get(ps->scene, ps->brush);
- bool reset_threads = false;
+ bool reset_threads = true;
+
+ Mesh *me = ps->ob->data;
+ MLoopPtex *loop_ptex = CustomData_get_layer(&me->ldata, CD_LOOP_PTEX);
+ MTessFacePtex *tess_ptex = NULL;
/* ---- end defines ---- */
@@ -3775,6 +3814,10 @@ static void project_paint_end(ProjPaintState *ps)
BLI_spin_end(ps->tile_lock);
MEM_freeN((void *)ps->tile_lock);
}
+ if (ps->dm_mtface_ptex) {
+ MEM_freeN(ps->dm_mtface_ptex);
+ ps->dm_mtface_ptex = NULL;
+ }
image_undo_end_locks();
#ifndef PROJ_DEBUG_NOSEAMBLEED
@@ -5218,6 +5261,12 @@ bool BKE_paint_proj_mesh_data_check(Scene *scene, Object *ob, bool *uvs, bool *m
if (layernum == 0) {
hasuvs = false;
+
+ layernum = CustomData_number_of_layers(&me->ldata, CD_LOOP_PTEX);
+
+ if (layernum) {
+ hasuvs = true;
+ }
}
/* Make sure we have a stencil to paint on! */
More information about the Bf-blender-cvs
mailing list