forked from bartvdbraak/blender
code cleanup: lots of calls to BKE_mesh_calc_normals_mapping were not using the mapping functionality.
replace ED_mesh_calc_normals with BKE_mesh_calc_normals().
This commit is contained in:
parent
c987aa7df5
commit
ef4db04da8
@ -211,18 +211,20 @@ void BKE_mesh_calc_normals_mapping(
|
||||
struct MVert *mverts, int numVerts,
|
||||
struct MLoop *mloop, struct MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3],
|
||||
struct MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3]);
|
||||
/* extended version of 'BKE_mesh_calc_normals' with option not to calc vertex normals */
|
||||
/* extended version of 'BKE_mesh_calc_normals_poly' with option not to calc vertex normals */
|
||||
void BKE_mesh_calc_normals_mapping_ex(
|
||||
struct MVert *mverts, int numVerts,
|
||||
struct MLoop *mloop, struct MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3],
|
||||
struct MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3],
|
||||
const bool only_face_normals);
|
||||
|
||||
void BKE_mesh_calc_normals(
|
||||
void BKE_mesh_calc_normals_poly(
|
||||
struct MVert *mverts, int numVerts,
|
||||
struct MLoop *mloop, struct MPoly *mpolys,
|
||||
int numLoops, int numPolys, float (*polyNors_r)[3]);
|
||||
|
||||
void BKE_mesh_calc_normals(struct Mesh *me);
|
||||
|
||||
/* Return a newly MEM_malloc'd array of all the mesh vertex locations
|
||||
* (_numVerts_r_ may be NULL) */
|
||||
float (*BKE_mesh_vertexCos_get(struct Mesh *me, int *r_numVerts))[3];
|
||||
|
@ -2283,8 +2283,8 @@ void CDDM_calc_normals(DerivedMesh *dm)
|
||||
poly_nors = CustomData_add_layer(&dm->polyData, CD_NORMAL, CD_CALLOC, NULL, dm->numPolyData);
|
||||
}
|
||||
|
||||
BKE_mesh_calc_normals(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm),
|
||||
dm->numLoopData, dm->numPolyData, poly_nors);
|
||||
BKE_mesh_calc_normals_poly(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm),
|
||||
dm->numLoopData, dm->numPolyData, poly_nors);
|
||||
}
|
||||
|
||||
void CDDM_calc_normals_tessface(DerivedMesh *dm)
|
||||
|
@ -1197,7 +1197,7 @@ void BKE_mesh_from_metaball(ListBase *lb, Mesh *me)
|
||||
|
||||
BKE_mesh_update_customdata_pointers(me, true);
|
||||
|
||||
BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL);
|
||||
BKE_mesh_calc_normals(me);
|
||||
|
||||
BKE_mesh_calc_edges(me, true, false);
|
||||
}
|
||||
@ -1591,7 +1591,7 @@ void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase, const bool use
|
||||
me->mloopuv = CustomData_add_layer_named(&me->ldata, CD_MLOOPUV, CD_ASSIGN, alluv, me->totloop, uvname);
|
||||
}
|
||||
|
||||
BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL);
|
||||
BKE_mesh_calc_normals(me);
|
||||
}
|
||||
else {
|
||||
me = BKE_mesh_add(G.main, "Mesh");
|
||||
@ -1907,7 +1907,7 @@ void BKE_mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts,
|
||||
if (only_face_normals == FALSE) {
|
||||
/* vertex normals are optional, they require some extra calculations,
|
||||
* so make them optional */
|
||||
BKE_mesh_calc_normals(mverts, numVerts, mloop, mpolys, numLoops, numPolys, pnors);
|
||||
BKE_mesh_calc_normals_poly(mverts, numVerts, mloop, mpolys, numLoops, numPolys, pnors);
|
||||
}
|
||||
else {
|
||||
/* only calc poly normals */
|
||||
@ -1929,7 +1929,7 @@ void BKE_mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts,
|
||||
}
|
||||
else {
|
||||
/* eek, we're not corresponding to polys */
|
||||
printf("error in BKE_mesh_calc_normals; tessellation face indices are incorrect. normals may look bad.\n");
|
||||
printf("error in %s: tessellation face indices are incorrect. normals may look bad.\n", __func__);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1993,10 +1993,10 @@ static void mesh_calc_normals_poly_accum(MPoly *mp, MLoop *ml,
|
||||
|
||||
}
|
||||
|
||||
void BKE_mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys,
|
||||
int UNUSED(numLoops), int numPolys, float (*polyNors_r)[3])
|
||||
void BKE_mesh_calc_normals_poly(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys,
|
||||
int UNUSED(numLoops), int numPolys, float (*r_polynors)[3])
|
||||
{
|
||||
float (*pnors)[3] = polyNors_r;
|
||||
float (*pnors)[3] = r_polynors;
|
||||
float (*tnorms)[3];
|
||||
float tpnor[3]; /* temp poly normal */
|
||||
int i;
|
||||
@ -2025,6 +2025,13 @@ void BKE_mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpo
|
||||
MEM_freeN(tnorms);
|
||||
}
|
||||
|
||||
void BKE_mesh_calc_normals(Mesh *mesh)
|
||||
{
|
||||
BKE_mesh_calc_normals_poly(mesh->mvert, mesh->totvert,
|
||||
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float (*faceNors_r)[3])
|
||||
{
|
||||
float (*tnorms)[3] = MEM_callocN(numVerts * sizeof(*tnorms), "tnorms");
|
||||
|
@ -861,7 +861,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob)
|
||||
* Probably this is possible to do in the loop above, but this is rather tricky because
|
||||
* we don't know all needed vertices' coordinates there yet.
|
||||
*/
|
||||
BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL);
|
||||
BKE_mesh_calc_normals(me);
|
||||
|
||||
/* subdivide the mesh to highest level without displacements */
|
||||
cddm = CDDM_from_mesh(me, NULL);
|
||||
|
@ -710,7 +710,7 @@ void MeshImporter::bmeshConversion()
|
||||
if ((*m).second) {
|
||||
Mesh *me = (*m).second;
|
||||
BKE_mesh_tessface_clear(me);
|
||||
BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL);
|
||||
BKE_mesh_calc_normals(me);
|
||||
//BKE_mesh_validate(me, 1);
|
||||
}
|
||||
}
|
||||
@ -1033,10 +1033,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta
|
||||
Mesh *new_mesh = uid_mesh_map[*geom_uid];
|
||||
|
||||
BKE_mesh_assign_object(ob, new_mesh);
|
||||
BKE_mesh_calc_normals_mapping(new_mesh->mvert, new_mesh->totvert,
|
||||
new_mesh->mloop, new_mesh->mpoly,
|
||||
new_mesh->totloop, new_mesh->totpoly,
|
||||
NULL, NULL, 0, NULL, NULL);
|
||||
BKE_mesh_calc_normals(new_mesh);
|
||||
|
||||
if (old_mesh->id.us == 0) BKE_libblock_free(&G.main->mesh, old_mesh);
|
||||
|
||||
|
@ -259,7 +259,6 @@ void ED_mesh_edges_remove(struct Mesh *mesh, struct ReportList *reports, int cou
|
||||
void ED_mesh_vertices_remove(struct Mesh *mesh, struct ReportList *reports, int count);
|
||||
|
||||
void ED_mesh_transform(struct Mesh *me, float *mat);
|
||||
void ED_mesh_calc_normals(struct Mesh *me);
|
||||
void ED_mesh_calc_tessface(struct Mesh *mesh);
|
||||
void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int calc_tessface);
|
||||
|
||||
|
@ -896,8 +896,6 @@ void MESH_OT_customdata_clear_skin(wmOperatorType *ot)
|
||||
|
||||
void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface)
|
||||
{
|
||||
int *polyindex = NULL;
|
||||
float (*face_nors)[3];
|
||||
bool tessface_input = false;
|
||||
|
||||
if (mesh->totface > 0 && mesh->totpoly == 0) {
|
||||
@ -920,28 +918,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface)
|
||||
BKE_mesh_tessface_clear(mesh);
|
||||
}
|
||||
|
||||
/* note on this if/else - looks like these layers are not needed
|
||||
* 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_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);
|
||||
|
||||
BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert,
|
||||
mesh->mloop, mesh->mpoly,
|
||||
mesh->totloop, mesh->totpoly,
|
||||
NULL /* polyNors_r */,
|
||||
mesh->mface, mesh->totface,
|
||||
polyindex, face_nors, false);
|
||||
#else
|
||||
BKE_mesh_calc_normals(mesh->mvert, mesh->totvert,
|
||||
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
|
||||
NULL);
|
||||
(void)polyindex;
|
||||
(void)face_nors;
|
||||
#endif
|
||||
BKE_mesh_calc_normals(mesh);
|
||||
|
||||
DAG_id_tag_update(&mesh->id, 0);
|
||||
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mesh);
|
||||
@ -1257,19 +1234,6 @@ void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count)
|
||||
mesh_add_polys(mesh, count);
|
||||
}
|
||||
|
||||
void ED_mesh_calc_normals(Mesh *mesh)
|
||||
{
|
||||
#ifdef USE_BMESH_MPOLY_NORMALS
|
||||
BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert,
|
||||
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
|
||||
NULL, NULL, 0, NULL, NULL, false);
|
||||
#else
|
||||
BKE_mesh_calc_normals(mesh->mvert, mesh->totvert,
|
||||
mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly,
|
||||
NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ED_mesh_calc_tessface(Mesh *mesh)
|
||||
{
|
||||
if (mesh->edit_btmesh) {
|
||||
|
@ -507,7 +507,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
|
||||
BKE_mesh_update_customdata_pointers(me, false);
|
||||
|
||||
/* update normals in case objects with non-uniform scale are joined */
|
||||
ED_mesh_calc_normals(me);
|
||||
BKE_mesh_calc_normals(me);
|
||||
|
||||
/* old material array */
|
||||
for (a = 1; a <= ob->totcol; a++) {
|
||||
|
@ -503,7 +503,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo
|
||||
}
|
||||
|
||||
/* update normals */
|
||||
BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL);
|
||||
BKE_mesh_calc_normals(me);
|
||||
}
|
||||
else if (ob->type == OB_ARMATURE) {
|
||||
ED_armature_apply_transform(ob, mat);
|
||||
|
@ -2942,9 +2942,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3])
|
||||
for (a = 0; a < me->totvert; a++, mvert++)
|
||||
copy_v3_v3(mvert->co, vertCos[a]);
|
||||
|
||||
BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop,
|
||||
me->mpoly, me->totloop, me->totpoly,
|
||||
NULL, NULL, 0, NULL, NULL);
|
||||
BKE_mesh_calc_normals(me);
|
||||
}
|
||||
|
||||
/* apply new coords on active key block */
|
||||
@ -3278,7 +3276,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob)
|
||||
/* Modifiers could depend on mesh normals, so we should update them/
|
||||
* Note, then if sculpting happens on locked key, normals should be re-calculated
|
||||
* after applying coords from keyblock on base mesh */
|
||||
BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL);
|
||||
BKE_mesh_calc_normals(me);
|
||||
}
|
||||
else if (ss->kb) {
|
||||
sculpt_update_keyblock(ob);
|
||||
|
@ -221,9 +221,6 @@ typedef struct TFace {
|
||||
#define USE_BMESH_SAVE_AS_COMPAT
|
||||
#define USE_BMESH_SAVE_WITHOUT_MFACE
|
||||
|
||||
/* enable this to calculate mpoly normal layer and face origindex mapping */
|
||||
// #define USE_BMESH_MPOLY_NORMALS
|
||||
|
||||
/* enable this so meshes get tessfaces calculated by default */
|
||||
// #define USE_TESSFACE_DEFAULT
|
||||
|
||||
|
@ -66,7 +66,7 @@ void RNA_api_mesh(StructRNA *srna)
|
||||
parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
|
||||
RNA_def_property_flag(parm, PROP_REQUIRED);
|
||||
|
||||
func = RNA_def_function(srna, "calc_normals", "ED_mesh_calc_normals");
|
||||
func = RNA_def_function(srna, "calc_normals", "BKE_mesh_calc_normals");
|
||||
RNA_def_function_ui_description(func, "Calculate vertex normals");
|
||||
|
||||
func = RNA_def_function(srna, "calc_tessface", "ED_mesh_calc_tessface");
|
||||
|
@ -356,7 +356,6 @@ void uiLayoutSetScaleX(struct uiLayout *layout, float scale) {STUB_ASSERT(0);}
|
||||
void uiLayoutSetScaleY(struct uiLayout *layout, float scale) {STUB_ASSERT(0);}
|
||||
void uiTemplateIconView(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname) {STUB_ASSERT(0);}
|
||||
void ED_base_object_free_and_unlink(struct Scene *scene, struct Base *base) {STUB_ASSERT(0);}
|
||||
void ED_mesh_calc_normals(struct Mesh *me) {STUB_ASSERT(0);}
|
||||
void ED_mesh_geometry_add(struct Mesh *mesh, struct ReportList *reports, int verts, int edges, int faces) {STUB_ASSERT(0);}
|
||||
void ED_mesh_material_add(struct Mesh *me, struct Material *ma) {STUB_ASSERT(0);}
|
||||
void ED_mesh_transform(struct Mesh *me, float *mat) {STUB_ASSERT(0);}
|
||||
|
Loading…
Reference in New Issue
Block a user