Fix screw modifier
This commit is contained in:
parent
d8abf380e0
commit
bd4c68658f
|
@ -386,14 +386,6 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba
|
|||
make_edges_mdata_extend(*mesh);
|
||||
}
|
||||
|
||||
int sharp_faces_count = 0;
|
||||
for (const bool value : sharp_faces.span) {
|
||||
if (value) {
|
||||
sharp_faces_count++;
|
||||
}
|
||||
}
|
||||
std::cout << "Number of sharp faces: " << sharp_faces_count << '\n';
|
||||
|
||||
material_indices.finish();
|
||||
sharp_faces.finish();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "DNA_object_types.h"
|
||||
#include "DNA_screen_types.h"
|
||||
|
||||
#include "BKE_attribute.hh"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_lib_query.h"
|
||||
#include "BKE_mesh.h"
|
||||
|
@ -179,6 +180,7 @@ static Mesh *mesh_remove_doubles_on_axis(Mesh *result,
|
|||
|
||||
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *meshData)
|
||||
{
|
||||
using namespace blender;
|
||||
const Mesh *mesh = meshData;
|
||||
Mesh *result;
|
||||
ScrewModifierData *ltmd = (ScrewModifierData *)md;
|
||||
|
@ -245,6 +247,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
|
||||
ScrewVertConnect *vc, *vc_tmp, *vert_connect = nullptr;
|
||||
|
||||
const bool use_flat_shading = (ltmd->flag & MOD_SCREW_SMOOTH_SHADING) == 0;
|
||||
|
||||
/* don't do anything? */
|
||||
if (!totvert) {
|
||||
return BKE_mesh_new_nomain_from_template(mesh, 0, 0, 0, 0, 0);
|
||||
|
@ -387,6 +391,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
MEdge *medge_new = BKE_mesh_edges_for_write(result);
|
||||
MPoly *mpoly_new = BKE_mesh_polys_for_write(result);
|
||||
MLoop *mloop_new = BKE_mesh_loops_for_write(result);
|
||||
bke::MutableAttributeAccessor attributes = result->attributes_for_write();
|
||||
bke::SpanAttributeWriter<bool> sharp_faces = attributes.lookup_or_add_for_write_span<bool>(
|
||||
"sharp_face", ATTR_DOMAIN_FACE);
|
||||
|
||||
if (!CustomData_has_layer(&result->pdata, CD_ORIGINDEX)) {
|
||||
CustomData_add_layer(&result->pdata, CD_ORIGINDEX, CD_SET_DEFAULT, nullptr, int(maxPolys));
|
||||
|
@ -863,6 +870,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
else {
|
||||
origindex[mpoly_index] = ORIGINDEX_NONE;
|
||||
dst_material_index[mpoly_index] = mat_nr;
|
||||
sharp_faces.span[i] = use_flat_shading;
|
||||
}
|
||||
mp_new->loopstart = mpoly_index * 4;
|
||||
mp_new->totloop = 4;
|
||||
|
@ -988,6 +996,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
#endif
|
||||
|
||||
sharp_faces.finish();
|
||||
|
||||
if (edge_poly_map) {
|
||||
MEM_freeN(edge_poly_map);
|
||||
}
|
||||
|
@ -1006,8 +1016,6 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
ltmd->merge_dist);
|
||||
}
|
||||
|
||||
BKE_mesh_smooth_flag_set(result, ltmd->flag & MOD_SCREW_SMOOTH_SHADING);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue