fix [#33303] face selection masking for painting does not work with mesh with n-gon

caused by own change to how origindex is used, now if mpoly's CD_ORIGINDEX array is missing its assumes that its the original mpoly array.
This commit is contained in:
Campbell Barton 2012-11-26 10:15:32 +00:00
parent 240ee2fccb
commit e3d3ffe746
6 changed files with 27 additions and 21 deletions

@ -709,10 +709,16 @@ void DM_debug_print(DerivedMesh *dm);
void DM_debug_print_cdlayers(CustomData *cdata); void DM_debug_print_cdlayers(CustomData *cdata);
#endif #endif
#ifdef __GNUC__
BLI_INLINE int DM_origindex_mface_mpoly(const int *index_mf_to_mpoly, const int *index_mp_to_orig, const int i)
__attribute__((nonnull(1)))
;
#endif
BLI_INLINE int DM_origindex_mface_mpoly(const int *index_mf_to_mpoly, const int *index_mp_to_orig, const int i) BLI_INLINE int DM_origindex_mface_mpoly(const int *index_mf_to_mpoly, const int *index_mp_to_orig, const int i)
{ {
const int j = index_mf_to_mpoly[i]; const int j = index_mf_to_mpoly[i];
return (j != ORIGINDEX_NONE) ? index_mp_to_orig[j] : ORIGINDEX_NONE; return (j != ORIGINDEX_NONE) ? (index_mp_to_orig ? index_mp_to_orig[j] : j) : ORIGINDEX_NONE;
} }
#endif #endif

@ -623,8 +623,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm,
/* double lookup */ /* double lookup */
const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) { if (index_mf_to_mpoly == NULL) {
index_mf_to_mpoly = index_mp_to_orig = NULL; index_mp_to_orig = NULL;
} }
colType = CD_TEXTURE_MCOL; colType = CD_TEXTURE_MCOL;
@ -812,8 +812,8 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm,
/* double lookup */ /* double lookup */
const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) { if (index_mf_to_mpoly == NULL) {
index_mf_to_mpoly = index_mp_to_orig = NULL; index_mp_to_orig = NULL;
} }
@ -1048,8 +1048,8 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm,
/* double lookup */ /* double lookup */
const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) { if (index_mf_to_mpoly == NULL) {
index_mf_to_mpoly = index_mp_to_orig = NULL; index_mp_to_orig = NULL;
} }
cdDM_update_normals_from_pbvh(dm); cdDM_update_normals_from_pbvh(dm);
@ -1349,8 +1349,8 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm,
/* double lookup */ /* double lookup */
const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) { if (index_mf_to_mpoly == NULL) {
index_mf_to_mpoly = index_mp_to_orig = NULL; index_mp_to_orig = NULL;
} }
cdDM_update_normals_from_pbvh(dm); cdDM_update_normals_from_pbvh(dm);

@ -822,8 +822,8 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot)
index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) { if (index_mf_to_mpoly == NULL) {
index_mf_to_mpoly = index_mp_to_orig = NULL; index_mp_to_orig = NULL;
} }
facearea = MEM_callocN(sizeof(float) * totorigface, "SimplifyFaceArea"); facearea = MEM_callocN(sizeof(float) * totorigface, "SimplifyFaceArea");
@ -1645,8 +1645,8 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const f
/* double lookup */ /* double lookup */
const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) { if (index_mf_to_mpoly == NULL) {
index_mf_to_mpoly = index_mp_to_orig = NULL; index_mp_to_orig = NULL;
} }
mpoly = dm->getPolyArray(dm); mpoly = dm->getPolyArray(dm);

@ -257,8 +257,8 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in
/* double lookup */ /* double lookup */
const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); const int *index_mf_to_mpoly = dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX); const int *index_mp_to_orig = dm->getPolyDataArray(dm, CD_ORIGINDEX);
if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) { if (index_mf_to_mpoly == NULL) {
index_mf_to_mpoly = index_mp_to_orig = NULL; index_mp_to_orig = NULL;
} }
minabsw = 1e10; minabsw = 1e10;

@ -1707,8 +1707,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
totface= psmd->dm->getNumTessFaces(psmd->dm); totface= psmd->dm->getNumTessFaces(psmd->dm);
index_mf_to_mpoly = psmd->dm->getTessFaceDataArray(psmd->dm, CD_ORIGINDEX); index_mf_to_mpoly = psmd->dm->getTessFaceDataArray(psmd->dm, CD_ORIGINDEX);
index_mp_to_orig = psmd->dm->getPolyDataArray(psmd->dm, CD_ORIGINDEX); index_mp_to_orig = psmd->dm->getPolyDataArray(psmd->dm, CD_ORIGINDEX);
if ((index_mf_to_mpoly && index_mp_to_orig) == FALSE) { if (index_mf_to_mpoly == NULL) {
index_mf_to_mpoly = index_mp_to_orig = NULL; index_mp_to_orig = NULL;
} }
for (a=0; a<totface; a++) for (a=0; a<totface; a++)
strandbuf->totbound = max_ii(strandbuf->totbound, (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a): a); strandbuf->totbound = max_ii(strandbuf->totbound, (index_mf_to_mpoly) ? DM_origindex_mface_mpoly(index_mf_to_mpoly, index_mp_to_orig, a): a);

@ -1507,8 +1507,8 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm,
/* double lookup */ /* double lookup */
const int *index_mf_to_mpoly = (const int *)dm->getTessFaceDataArray(dm, CD_ORIGINDEX); const int *index_mf_to_mpoly = (const int *)dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
const int *index_mp_to_orig = (const int *)dm->getPolyDataArray(dm, CD_ORIGINDEX); const int *index_mp_to_orig = (const int *)dm->getPolyDataArray(dm, CD_ORIGINDEX);
if ((index_mf_to_mpoly && index_mp_to_orig) == false) { if (index_mf_to_mpoly == NULL) {
index_mf_to_mpoly = index_mp_to_orig = NULL; index_mp_to_orig = NULL;
} }
m_shapeType = (polytope) ? PHY_SHAPE_POLYTOPE : PHY_SHAPE_MESH; m_shapeType = (polytope) ? PHY_SHAPE_POLYTOPE : PHY_SHAPE_MESH;
@ -1816,8 +1816,8 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject* gameobj, class RA
/* double lookup */ /* double lookup */
const int *index_mf_to_mpoly = (const int *)dm->getTessFaceDataArray(dm, CD_ORIGINDEX); const int *index_mf_to_mpoly = (const int *)dm->getTessFaceDataArray(dm, CD_ORIGINDEX);
const int *index_mp_to_orig = (const int *)dm->getPolyDataArray(dm, CD_ORIGINDEX); const int *index_mp_to_orig = (const int *)dm->getPolyDataArray(dm, CD_ORIGINDEX);
if ((index_mf_to_mpoly && index_mp_to_orig) == false) { if (index_mf_to_mpoly == NULL) {
index_mf_to_mpoly = index_mp_to_orig = NULL; index_mp_to_orig = NULL;
} }
MFace *mf; MFace *mf;