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:
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/mesh/editface.c4
-rw-r--r--source/blender/editors/mesh/mesh_data.c2
-rw-r--r--source/blender/editors/object/object_bake.c30
-rw-r--r--source/blender/editors/sculpt_paint/paint_utils.c10
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c2
-rw-r--r--source/blender/editors/space_view3d/drawobject.c16
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c5
7 files changed, 47 insertions, 22 deletions
diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c
index 429b2148894..4350c005f95 100644
--- a/source/blender/editors/mesh/editface.c
+++ b/source/blender/editors/mesh/editface.c
@@ -85,7 +85,7 @@ void paintface_flush_flags(Object *ob)
* - Final derived polys => Final derived tessfaces
*/
- if ((index_array = CustomData_get_layer(&me->fdata, CD_POLYINDEX))) {
+ if ((index_array = CustomData_get_layer(&me->fdata, CD_ORIGINDEX))) {
faces = me->mface;
totface = me->totface;
@@ -109,7 +109,7 @@ void paintface_flush_flags(Object *ob)
}
}
- if ((index_array = CustomData_get_layer(&dm->faceData, CD_POLYINDEX))) {
+ if ((index_array = CustomData_get_layer(&dm->faceData, CD_ORIGINDEX))) {
polys = dm->getPolyArray(dm);
faces = dm->getTessFaceArray(dm);
totface = dm->getNumTessFaces(dm);
diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c
index 4adf37a14c3..a4640677a4e 100644
--- a/source/blender/editors/mesh/mesh_data.c
+++ b/source/blender/editors/mesh/mesh_data.c
@@ -902,7 +902,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface)
* so rather then add poly-index layer and calculate normals for it
* calculate normals only for the mvert's. - campbell */
#ifdef USE_BMESH_MPOLY_NORMALS
- polyindex = CustomData_get_layer(&mesh->fdata, CD_POLYINDEX);
+ polyindex = CustomData_get_layer(&mesh->fdata, CD_ORIGINDEX);
/* add a normals layer for tessellated faces, a tessface normal will
* contain the normal of the poly the face was tessellated from. */
face_nors = CustomData_add_layer(&mesh->fdata, CD_NORMAL, CD_CALLOC, NULL, mesh->totface);
diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c
index 2914a1ff673..ee3c66b6eac 100644
--- a/source/blender/editors/object/object_bake.c
+++ b/source/blender/editors/object/object_bake.c
@@ -150,11 +150,13 @@ typedef struct {
float height_min, height_max;
Image *ima;
DerivedMesh *ssdm;
- const int *origindex;
+ const int *orig_index_mf_to_mpoly;
+ const int *orig_index_mp_to_orig;
} MHeightBakeData;
typedef struct {
- const int *origindex;
+ const int *orig_index_mf_to_mpoly;
+ const int *orig_index_mp_to_orig;
} MNormalBakeData;
static void multiresbake_get_normal(const MResolvePixelData *data, float norm[], const int face_num, const int vert_index)
@@ -508,7 +510,9 @@ static void interp_bilinear_grid(CCGKey *key, CCGElem *grid, float crn_x, float
interp_bilinear_quad_data(data, u, v, res);
}
-static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *origindex, const int lvl, const int face_index, const float u, const float v, float co[3], float n[3])
+static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm,
+ const int *index_mf_to_mpoly, const int *index_mp_to_orig,
+ const int lvl, const int face_index, const float u, const float v, float co[3], float n[3])
{
MFace mface;
CCGElem **grid_data;
@@ -532,7 +536,7 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig
}
else {
int side = (1 << (lvl - 1)) + 1;
- int grid_index = origindex[face_index];
+ int grid_index = DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, face_index);
int loc_offs = face_index % (1 << (2 * lvl));
int cell_index = loc_offs % ((side - 1) * (side - 1));
int cell_side = (grid_size - 1) / (side - 1);
@@ -628,7 +632,8 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima)
}
}
- height_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX);
+ height_data->orig_index_mf_to_mpoly = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX);
+ height_data->orig_index_mp_to_orig = lodm->getPolyDataArray(lodm, CD_ORIGINDEX);
return (void *)height_data;
}
@@ -640,7 +645,8 @@ static void *init_normal_data(MultiresBakeRender *bkr, Image *UNUSED(ima))
normal_data = MEM_callocN(sizeof(MNormalBakeData), "MultiresBake normalData");
- normal_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX);
+ normal_data->orig_index_mf_to_mpoly = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX);
+ normal_data->orig_index_mp_to_orig = lodm->getPolyDataArray(lodm, CD_ORIGINDEX);
return (void *)normal_data;
}
@@ -735,10 +741,14 @@ static void apply_heights_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
CLAMP(uv[0], 0.0f, 1.0f);
CLAMP(uv[1], 0.0f, 1.0f);
- get_ccgdm_data(lores_dm, hires_dm, height_data->origindex, lvl, face_index, uv[0], uv[1], p1, 0);
+ get_ccgdm_data(lores_dm, hires_dm,
+ height_data->orig_index_mf_to_mpoly, height_data->orig_index_mf_to_mpoly,
+ lvl, face_index, uv[0], uv[1], p1, 0);
if (height_data->ssdm) {
- get_ccgdm_data(lores_dm, height_data->ssdm, height_data->origindex, 0, face_index, uv[0], uv[1], p0, n);
+ get_ccgdm_data(lores_dm, height_data->ssdm,
+ height_data->orig_index_mf_to_mpoly, height_data->orig_index_mf_to_mpoly,
+ 0, face_index, uv[0], uv[1], p0, n);
}
else {
lores_dm->getTessFace(lores_dm, face_index, &mface);
@@ -808,7 +818,9 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, DerivedMesh *hires_dm,
CLAMP(uv[0], 0.0f, 1.0f);
CLAMP(uv[1], 0.0f, 1.0f);
- get_ccgdm_data(lores_dm, hires_dm, normal_data->origindex, lvl, face_index, uv[0], uv[1], NULL, n);
+ get_ccgdm_data(lores_dm, hires_dm,
+ normal_data->orig_index_mf_to_mpoly, normal_data->orig_index_mp_to_orig,
+ lvl, face_index, uv[0], uv[1], NULL, n);
mul_v3_m3v3(vec, tangmat, n);
normalize_v3(vec);
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index b3679516fff..c5eff1a1f0e 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -248,19 +248,25 @@ static void imapaint_tri_weights(Object *ob,
void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2])
{
DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
- const int *index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
MTFace *tface = dm->getTessFaceDataArray(dm, CD_MTFACE), *tf;
int numfaces = dm->getNumTessFaces(dm), a, findex;
float p[2], w[3], absw, minabsw;
MFace mf;
MVert mv[4];
+ /* double lookup */
+ const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
+ const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
+ if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) {
+ index_mf_to_mpoly = index_mp_to_orig = NULL;
+ }
+
minabsw = 1e10;
uv[0] = uv[1] = 0.0;
/* test all faces in the derivedmesh with the original index of the picked face */
for (a = 0; a < numfaces; a++) {
- findex = index ? index[a] : a;
+ findex = index_mf_to_mpoly ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a) : a;
if (findex == faceindex) {
dm->getTessFace(dm, a, &mf);
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 0846dc6d89e..56d46a22e10 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -2570,7 +2570,7 @@ static void vpaint_build_poly_facemap(struct VPaintData *vd, Mesh *me)
vd->polyfacemap = BLI_memarena_alloc(vd->polyfacemap_arena, sizeof(ListBase) * me->totpoly);
- origIndex = CustomData_get_layer(&me->fdata, CD_POLYINDEX);
+ origIndex = CustomData_get_layer(&me->fdata, CD_ORIGINDEX);
mf = me->mface;
if (!origIndex)
diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c
index 04549b53b6a..16d66eb6f9a 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -132,7 +132,8 @@ typedef struct drawDMFacesSel_userData {
BMEditMesh *em; /* BMESH BRANCH ONLY */
BMFace *efa_act;
- int *orig_index;
+ int *orig_index_mf_to_mpoly;
+ int *orig_index_mp_to_orig;
} drawDMFacesSel_userData;
typedef struct drawDMNormal_userData {
@@ -2310,11 +2311,11 @@ static int draw_dm_faces_sel__compareDrawOptions(void *userData, int index, int
unsigned char *col, *next_col;
- if (!data->orig_index)
+ if (!data->orig_index_mf_to_mpoly)
return 0;
- efa = EDBM_face_at_index(data->em, data->orig_index[index]);
- next_efa = EDBM_face_at_index(data->em, data->orig_index[next_index]);
+ efa = EDBM_face_at_index(data->em, DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, index));
+ next_efa = EDBM_face_at_index(data->em, DM_origindex_mface_mpoly(data->orig_index_mf_to_mpoly, data->orig_index_mp_to_orig, next_index));
if (efa == next_efa)
return 1;
@@ -2342,7 +2343,12 @@ static void draw_dm_faces_sel(BMEditMesh *em, DerivedMesh *dm, unsigned char *ba
data.cols[1] = selCol;
data.cols[2] = actCol;
data.efa_act = efa_act;
- data.orig_index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
+ /* double lookup */
+ data.orig_index_mf_to_mpoly = DM_get_tessface_data_layer(dm, CD_ORIGINDEX);
+ data.orig_index_mp_to_orig = DM_get_poly_data_layer(dm, CD_ORIGINDEX);
+ if ((data.orig_index_mf_to_mpoly && data.orig_index_mp_to_orig) == FALSE) {
+ data.orig_index_mf_to_mpoly = data.orig_index_mp_to_orig = NULL;
+ }
dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, GPU_enable_material, draw_dm_faces_sel__compareDrawOptions, &data, 0);
}
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 74d007e92c0..8b61aaa93d1 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -369,7 +369,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
/* Used to hold subsurfed Mesh */
DerivedMesh *derivedMesh, *initialDerived;
/* holds original indices for subsurfed mesh */
- int *origVertIndices, *origFaceIndices, *origEdgeIndices;
+ int *origVertIndices, *origEdgeIndices, *origFaceIndices, *origPolyIndices;
/* Holds vertices of subsurfed mesh */
MVert *subsurfedVerts;
MEdge *subsurfedEdges;
@@ -422,6 +422,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
origVertIndices = derivedMesh->getVertDataArray(derivedMesh, CD_ORIGINDEX);
origEdgeIndices = derivedMesh->getEdgeDataArray(derivedMesh, CD_ORIGINDEX);
origFaceIndices = derivedMesh->getTessFaceDataArray(derivedMesh, CD_ORIGINDEX);
+ origPolyIndices = derivedMesh->getPolyDataArray(derivedMesh, CD_ORIGINDEX);
numOfEdges = derivedMesh->getNumEdges(derivedMesh);
numOfFaces = derivedMesh->getNumTessFaces(derivedMesh);
@@ -433,7 +434,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
/* map subsurfed faces to original editFaces */
for (i = 0; i < numOfFaces; i++)
- faceMap[i] = EDBM_face_at_index(em, origFaceIndices[i]);
+ faceMap[i] = EDBM_face_at_index(em, DM_origindex_mface_mpoly(origFaceIndices, origPolyIndices, i));
edgeMap = MEM_mallocN(numOfEdges * sizeof(BMEdge *), "unwrap_edit_edge_map");