Cleanup: Move several modifiers files to C++
For continued refactoring of the Mesh data structure. See T103343.
This commit is contained in:
parent
2ab72f6db8
commit
79053a6ff7
|
@ -37,22 +37,22 @@ set(SRC
|
|||
intern/MOD_array.cc
|
||||
intern/MOD_bevel.c
|
||||
intern/MOD_boolean.cc
|
||||
intern/MOD_build.c
|
||||
intern/MOD_build.cc
|
||||
intern/MOD_cast.c
|
||||
intern/MOD_cloth.c
|
||||
intern/MOD_collision.c
|
||||
intern/MOD_correctivesmooth.c
|
||||
intern/MOD_correctivesmooth.cc
|
||||
intern/MOD_curve.c
|
||||
intern/MOD_datatransfer.cc
|
||||
intern/MOD_decimate.c
|
||||
intern/MOD_displace.cc
|
||||
intern/MOD_dynamicpaint.c
|
||||
intern/MOD_edgesplit.c
|
||||
intern/MOD_explode.c
|
||||
intern/MOD_explode.cc
|
||||
intern/MOD_fluid.c
|
||||
intern/MOD_hook.c
|
||||
intern/MOD_laplaciandeform.c
|
||||
intern/MOD_laplaciansmooth.c
|
||||
intern/MOD_laplaciansmooth.cc
|
||||
intern/MOD_lattice.c
|
||||
intern/MOD_mask.cc
|
||||
intern/MOD_mesh_to_volume.cc
|
||||
|
@ -67,10 +67,10 @@ set(SRC
|
|||
intern/MOD_nodes.cc
|
||||
intern/MOD_none.c
|
||||
intern/MOD_normal_edit.cc
|
||||
intern/MOD_ocean.c
|
||||
intern/MOD_particleinstance.c
|
||||
intern/MOD_ocean.cc
|
||||
intern/MOD_particleinstance.cc
|
||||
intern/MOD_particlesystem.cc
|
||||
intern/MOD_remesh.c
|
||||
intern/MOD_remesh.cc
|
||||
intern/MOD_screw.cc
|
||||
intern/MOD_shapekey.c
|
||||
intern/MOD_shrinkwrap.c
|
||||
|
@ -78,12 +78,12 @@ set(SRC
|
|||
intern/MOD_skin.c
|
||||
intern/MOD_smooth.c
|
||||
intern/MOD_softbody.c
|
||||
intern/MOD_solidify.c
|
||||
intern/MOD_solidify_extrude.c
|
||||
intern/MOD_solidify_nonmanifold.c
|
||||
intern/MOD_solidify.cc
|
||||
intern/MOD_solidify_extrude.cc
|
||||
intern/MOD_solidify_nonmanifold.cc
|
||||
intern/MOD_subsurf.cc
|
||||
intern/MOD_surface.c
|
||||
intern/MOD_surfacedeform.c
|
||||
intern/MOD_surfacedeform.cc
|
||||
intern/MOD_triangulate.cc
|
||||
intern/MOD_ui_common.c
|
||||
intern/MOD_util.cc
|
||||
|
@ -104,7 +104,7 @@ set(SRC
|
|||
MOD_modifiertypes.h
|
||||
MOD_nodes.h
|
||||
intern/MOD_meshcache_util.h
|
||||
intern/MOD_solidify_util.h
|
||||
intern/MOD_solidify_util.hh
|
||||
intern/MOD_ui_common.h
|
||||
intern/MOD_util.h
|
||||
intern/MOD_weightvg_util.h
|
||||
|
|
|
@ -48,18 +48,17 @@ static void initData(ModifierData *md)
|
|||
MEMCPY_STRUCT_AFTER(bmd, DNA_struct_default_get(BuildModifierData), modifier);
|
||||
}
|
||||
|
||||
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md))
|
||||
static bool dependsOnTime(Scene * /*scene*/, ModifierData * /*md*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct Mesh *mesh)
|
||||
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
|
||||
{
|
||||
Mesh *result;
|
||||
BuildModifierData *bmd = (BuildModifierData *)md;
|
||||
int i, j, k;
|
||||
int faces_dst_num, edges_dst_num, loops_dst_num = 0;
|
||||
int *vertMap, *edgeMap, *faceMap;
|
||||
float frac;
|
||||
MPoly *mpoly_dst;
|
||||
MLoop *ml_dst;
|
||||
|
@ -79,15 +78,15 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
|
|||
const MPoly *mpoly_src = BKE_mesh_polys(mesh);
|
||||
const MLoop *mloop_src = BKE_mesh_loops(mesh);
|
||||
|
||||
vertMap = MEM_malloc_arrayN(vert_src_num, sizeof(*vertMap), "build modifier vertMap");
|
||||
edgeMap = MEM_malloc_arrayN(edge_src_num, sizeof(*edgeMap), "build modifier edgeMap");
|
||||
faceMap = MEM_malloc_arrayN(poly_src_num, sizeof(*faceMap), "build modifier faceMap");
|
||||
int *vertMap = static_cast<int *>(MEM_malloc_arrayN(vert_src_num, sizeof(int), __func__));
|
||||
int *edgeMap = static_cast<int *>(MEM_malloc_arrayN(edge_src_num, sizeof(int), __func__));
|
||||
int *faceMap = static_cast<int *>(MEM_malloc_arrayN(poly_src_num, sizeof(int), __func__));
|
||||
|
||||
range_vn_i(vertMap, vert_src_num, 0);
|
||||
range_vn_i(edgeMap, edge_src_num, 0);
|
||||
range_vn_i(faceMap, poly_src_num, 0);
|
||||
|
||||
struct Scene *scene = DEG_get_input_scene(ctx->depsgraph);
|
||||
Scene *scene = DEG_get_input_scene(ctx->depsgraph);
|
||||
frac = (BKE_scene_ctime_get(scene) - bmd->start) / bmd->length;
|
||||
CLAMP(frac, 0.0f, 1.0f);
|
||||
if (bmd->flag & MOD_BUILD_FLAG_REVERSE) {
|
||||
|
@ -253,9 +252,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
|
|||
}
|
||||
}
|
||||
|
||||
BLI_ghash_free(vertHash, NULL, NULL);
|
||||
BLI_ghash_free(edgeHash, NULL, NULL);
|
||||
BLI_ghash_free(edgeHash2, NULL, NULL);
|
||||
BLI_ghash_free(vertHash, nullptr, nullptr);
|
||||
BLI_ghash_free(edgeHash, nullptr, nullptr);
|
||||
BLI_ghash_free(edgeHash2, nullptr, nullptr);
|
||||
|
||||
MEM_freeN(vertMap);
|
||||
MEM_freeN(edgeMap);
|
||||
|
@ -265,40 +264,40 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, struct
|
|||
return result;
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, ptr, "frame_start", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "frame_duration", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_reverse", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "frame_start", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "frame_duration", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_reverse", 0, nullptr, ICON_NONE);
|
||||
|
||||
modifier_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void random_panel_header_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void random_panel_header_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
uiItemR(layout, ptr, "use_random_order", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_random_order", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
static void random_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void random_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_random_order"));
|
||||
uiItemR(layout, ptr, "seed", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "seed", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
|
@ -319,24 +318,24 @@ ModifierTypeInfo modifierType_Build = {
|
|||
|
||||
/*copyData*/ BKE_modifier_copydata_generic,
|
||||
|
||||
/*deformVerts*/ NULL,
|
||||
/*deformMatrices*/ NULL,
|
||||
/*deformVertsEM*/ NULL,
|
||||
/*deformMatricesEM*/ NULL,
|
||||
/*deformVerts*/ nullptr,
|
||||
/*deformMatrices*/ nullptr,
|
||||
/*deformVertsEM*/ nullptr,
|
||||
/*deformMatricesEM*/ nullptr,
|
||||
/*modifyMesh*/ modifyMesh,
|
||||
/*modifyGeometrySet*/ NULL,
|
||||
/*modifyGeometrySet*/ nullptr,
|
||||
|
||||
/*initData*/ initData,
|
||||
/*requiredDataMask*/ NULL,
|
||||
/*freeData*/ NULL,
|
||||
/*isDisabled*/ NULL,
|
||||
/*updateDepsgraph*/ NULL,
|
||||
/*requiredDataMask*/ nullptr,
|
||||
/*freeData*/ nullptr,
|
||||
/*isDisabled*/ nullptr,
|
||||
/*updateDepsgraph*/ nullptr,
|
||||
/*dependsOnTime*/ dependsOnTime,
|
||||
/*dependsOnNormals*/ NULL,
|
||||
/*foreachIDLink*/ NULL,
|
||||
/*foreachTexLink*/ NULL,
|
||||
/*freeRuntimeData*/ NULL,
|
||||
/*dependsOnNormals*/ nullptr,
|
||||
/*foreachIDLink*/ nullptr,
|
||||
/*foreachTexLink*/ nullptr,
|
||||
/*freeRuntimeData*/ nullptr,
|
||||
/*panelRegister*/ panelRegister,
|
||||
/*blendWrite*/ NULL,
|
||||
/*blendRead*/ NULL,
|
||||
/*blendWrite*/ nullptr,
|
||||
/*blendRead*/ nullptr,
|
||||
};
|
|
@ -62,7 +62,7 @@ static void initData(ModifierData *md)
|
|||
|
||||
MEMCPY_STRUCT_AFTER(csmd, DNA_struct_default_get(CorrectiveSmoothModifierData), modifier);
|
||||
|
||||
csmd->delta_cache.deltas = NULL;
|
||||
csmd->delta_cache.deltas = nullptr;
|
||||
}
|
||||
|
||||
static void copyData(const ModifierData *md, ModifierData *target, const int flag)
|
||||
|
@ -73,10 +73,10 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
|
|||
BKE_modifier_copydata_generic(md, target, flag);
|
||||
|
||||
if (csmd->bind_coords) {
|
||||
tcsmd->bind_coords = MEM_dupallocN(csmd->bind_coords);
|
||||
tcsmd->bind_coords = static_cast<float(*)[3]>(MEM_dupallocN(csmd->bind_coords));
|
||||
}
|
||||
|
||||
tcsmd->delta_cache.deltas = NULL;
|
||||
tcsmd->delta_cache.deltas = nullptr;
|
||||
tcsmd->delta_cache.deltas_num = 0;
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,8 @@ static void mesh_get_boundaries(Mesh *mesh, float *smooth_weights)
|
|||
const uint medge_num = (uint)mesh->totedge;
|
||||
|
||||
/* Flag boundary edges so only boundaries are set to 1. */
|
||||
uint8_t *boundaries = MEM_calloc_arrayN(medge_num, sizeof(*boundaries), __func__);
|
||||
uint8_t *boundaries = static_cast<uint8_t *>(
|
||||
MEM_calloc_arrayN(medge_num, sizeof(*boundaries), __func__));
|
||||
|
||||
for (uint i = 0; i < mpoly_num; i++) {
|
||||
const MPoly *p = &mpoly[i];
|
||||
|
@ -174,13 +175,14 @@ static void smooth_iter__simple(CorrectiveSmoothModifierData *csmd,
|
|||
|
||||
const uint edges_num = (uint)mesh->totedge;
|
||||
const MEdge *edges = BKE_mesh_edges(mesh);
|
||||
float *vertex_edge_count_div;
|
||||
|
||||
struct SmoothingData_Simple {
|
||||
float delta[3];
|
||||
} *smooth_data = MEM_calloc_arrayN(verts_num, sizeof(*smooth_data), __func__);
|
||||
};
|
||||
SmoothingData_Simple *smooth_data = MEM_cnew_array<SmoothingData_Simple>(verts_num, __func__);
|
||||
|
||||
vertex_edge_count_div = MEM_calloc_arrayN(verts_num, sizeof(float), __func__);
|
||||
float *vertex_edge_count_div = static_cast<float *>(
|
||||
MEM_calloc_arrayN(verts_num, sizeof(float), __func__));
|
||||
|
||||
/* calculate as floats to avoid int->float conversion in #smooth_iter */
|
||||
for (i = 0; i < edges_num; i++) {
|
||||
|
@ -190,7 +192,7 @@ static void smooth_iter__simple(CorrectiveSmoothModifierData *csmd,
|
|||
|
||||
/* a little confusing, but we can include 'lambda' and smoothing weight
|
||||
* here to avoid multiplying for every iteration */
|
||||
if (smooth_weights == NULL) {
|
||||
if (smooth_weights == nullptr) {
|
||||
for (i = 0; i < verts_num; i++) {
|
||||
vertex_edge_count_div[i] = lambda * (vertex_edge_count_div[i] ?
|
||||
(1.0f / vertex_edge_count_div[i]) :
|
||||
|
@ -210,8 +212,8 @@ static void smooth_iter__simple(CorrectiveSmoothModifierData *csmd,
|
|||
|
||||
while (iterations--) {
|
||||
for (i = 0; i < edges_num; i++) {
|
||||
struct SmoothingData_Simple *sd_v1;
|
||||
struct SmoothingData_Simple *sd_v2;
|
||||
SmoothingData_Simple *sd_v1;
|
||||
SmoothingData_Simple *sd_v2;
|
||||
float edge_dir[3];
|
||||
|
||||
sub_v3_v3v3(edge_dir, vertexCos[edges[i].v2], vertexCos[edges[i].v1]);
|
||||
|
@ -224,7 +226,7 @@ static void smooth_iter__simple(CorrectiveSmoothModifierData *csmd,
|
|||
}
|
||||
|
||||
for (i = 0; i < verts_num; i++) {
|
||||
struct SmoothingData_Simple *sd = &smooth_data[i];
|
||||
SmoothingData_Simple *sd = &smooth_data[i];
|
||||
madd_v3_v3fl(vertexCos[i], sd->delta, vertex_edge_count_div[i]);
|
||||
/* zero for the next iteration (saves memset on entire array) */
|
||||
memset(sd, 0, sizeof(*sd));
|
||||
|
@ -251,16 +253,18 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd,
|
|||
* and 2.0 rarely spikes, double the value for consistent behavior. */
|
||||
const float lambda = csmd->lambda * 2.0f;
|
||||
const MEdge *edges = BKE_mesh_edges(mesh);
|
||||
float *vertex_edge_count;
|
||||
uint i;
|
||||
|
||||
struct SmoothingData_Weighted {
|
||||
float delta[3];
|
||||
float edge_length_sum;
|
||||
} *smooth_data = MEM_calloc_arrayN(verts_num, sizeof(*smooth_data), __func__);
|
||||
};
|
||||
SmoothingData_Weighted *smooth_data = MEM_cnew_array<SmoothingData_Weighted>(verts_num,
|
||||
__func__);
|
||||
|
||||
/* calculate as floats to avoid int->float conversion in #smooth_iter */
|
||||
vertex_edge_count = MEM_calloc_arrayN(verts_num, sizeof(float), __func__);
|
||||
float *vertex_edge_count = static_cast<float *>(
|
||||
MEM_calloc_arrayN(verts_num, sizeof(float), __func__));
|
||||
for (i = 0; i < edges_num; i++) {
|
||||
vertex_edge_count[edges[i].v1] += 1.0f;
|
||||
vertex_edge_count[edges[i].v2] += 1.0f;
|
||||
|
@ -271,8 +275,8 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd,
|
|||
|
||||
while (iterations--) {
|
||||
for (i = 0; i < edges_num; i++) {
|
||||
struct SmoothingData_Weighted *sd_v1;
|
||||
struct SmoothingData_Weighted *sd_v2;
|
||||
SmoothingData_Weighted *sd_v1;
|
||||
SmoothingData_Weighted *sd_v2;
|
||||
float edge_dir[3];
|
||||
float edge_dist;
|
||||
|
||||
|
@ -292,10 +296,10 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd,
|
|||
sd_v2->edge_length_sum += edge_dist;
|
||||
}
|
||||
|
||||
if (smooth_weights == NULL) {
|
||||
if (smooth_weights == nullptr) {
|
||||
/* fast-path */
|
||||
for (i = 0; i < verts_num; i++) {
|
||||
struct SmoothingData_Weighted *sd = &smooth_data[i];
|
||||
SmoothingData_Weighted *sd = &smooth_data[i];
|
||||
/* Divide by sum of all neighbor distances (weighted) and amount of neighbors,
|
||||
* (mean average). */
|
||||
const float div = sd->edge_length_sum * vertex_edge_count[i];
|
||||
|
@ -316,7 +320,7 @@ static void smooth_iter__length_weight(CorrectiveSmoothModifierData *csmd,
|
|||
}
|
||||
else {
|
||||
for (i = 0; i < verts_num; i++) {
|
||||
struct SmoothingData_Weighted *sd = &smooth_data[i];
|
||||
SmoothingData_Weighted *sd = &smooth_data[i];
|
||||
const float div = sd->edge_length_sum * vertex_edge_count[i];
|
||||
if (div > eps) {
|
||||
const float lambda_w = lambda * smooth_weights[i];
|
||||
|
@ -358,11 +362,11 @@ static void smooth_verts(CorrectiveSmoothModifierData *csmd,
|
|||
float (*vertexCos)[3],
|
||||
uint verts_num)
|
||||
{
|
||||
float *smooth_weights = NULL;
|
||||
float *smooth_weights = nullptr;
|
||||
|
||||
if (dvert || (csmd->flag & MOD_CORRECTIVESMOOTH_PIN_BOUNDARY)) {
|
||||
|
||||
smooth_weights = MEM_malloc_arrayN(verts_num, sizeof(float), __func__);
|
||||
smooth_weights = static_cast<float *>(MEM_malloc_arrayN(verts_num, sizeof(float), __func__));
|
||||
|
||||
if (dvert) {
|
||||
mesh_get_weights(dvert,
|
||||
|
@ -372,7 +376,7 @@ static void smooth_verts(CorrectiveSmoothModifierData *csmd,
|
|||
smooth_weights);
|
||||
}
|
||||
else {
|
||||
copy_vn_fl(smooth_weights, (int)verts_num, 1.0f);
|
||||
copy_vn_fl(smooth_weights, int(verts_num), 1.0f);
|
||||
}
|
||||
|
||||
if (csmd->flag & MOD_CORRECTIVESMOOTH_PIN_BOUNDARY) {
|
||||
|
@ -423,9 +427,9 @@ static bool calc_tangent_loop(const float v_dir_prev[3],
|
|||
|
||||
/**
|
||||
* \param r_tangent_spaces: Loop aligned array of tangents.
|
||||
* \param r_tangent_weights: Loop aligned array of weights (may be NULL).
|
||||
* \param r_tangent_weights: Loop aligned array of weights (may be nullptr).
|
||||
* \param r_tangent_weights_per_vertex: Vertex aligned array, accumulating weights for each loop
|
||||
* (may be NULL).
|
||||
* (may be nullptr).
|
||||
*/
|
||||
static void calc_tangent_spaces(const Mesh *mesh,
|
||||
const float (*vertexCos)[3],
|
||||
|
@ -439,8 +443,8 @@ static void calc_tangent_spaces(const Mesh *mesh,
|
|||
const MLoop *mloop = BKE_mesh_loops(mesh);
|
||||
uint i;
|
||||
|
||||
if (r_tangent_weights_per_vertex != NULL) {
|
||||
copy_vn_fl(r_tangent_weights_per_vertex, (int)mvert_num, 0.0f);
|
||||
if (r_tangent_weights_per_vertex != nullptr) {
|
||||
copy_vn_fl(r_tangent_weights_per_vertex, int(mvert_num), 0.0f);
|
||||
}
|
||||
|
||||
for (i = 0; i < mpoly_num; i++) {
|
||||
|
@ -470,14 +474,14 @@ static void calc_tangent_spaces(const Mesh *mesh,
|
|||
normalize_v3(v_dir_next);
|
||||
|
||||
if (calc_tangent_loop(v_dir_prev, v_dir_next, ts)) {
|
||||
if (r_tangent_weights != NULL) {
|
||||
if (r_tangent_weights != nullptr) {
|
||||
const float weight = fabsf(acosf(dot_v3v3(v_dir_next, v_dir_prev)));
|
||||
r_tangent_weights[l_index] = weight;
|
||||
r_tangent_weights_per_vertex[l_curr->v] += weight;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (r_tangent_weights != NULL) {
|
||||
if (r_tangent_weights != nullptr) {
|
||||
r_tangent_weights[l_index] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -518,12 +522,12 @@ static void calc_deltas(CorrectiveSmoothModifierData *csmd,
|
|||
const MLoop *mloop = BKE_mesh_loops(mesh);
|
||||
const uint loops_num = (uint)mesh->totloop;
|
||||
|
||||
float(*smooth_vertex_coords)[3] = MEM_dupallocN(rest_coords);
|
||||
float(*tangent_spaces)[3][3];
|
||||
float(*smooth_vertex_coords)[3] = static_cast<float(*)[3]>(MEM_dupallocN(rest_coords));
|
||||
|
||||
uint l_index;
|
||||
|
||||
tangent_spaces = MEM_malloc_arrayN(loops_num, sizeof(float[3][3]), __func__);
|
||||
float(*tangent_spaces)[3][3] = static_cast<float(*)[3][3]>(
|
||||
MEM_malloc_arrayN(loops_num, sizeof(float[3][3]), __func__));
|
||||
|
||||
if (csmd->delta_cache.deltas_num != loops_num) {
|
||||
MEM_SAFE_FREE(csmd->delta_cache.deltas);
|
||||
|
@ -532,17 +536,18 @@ static void calc_deltas(CorrectiveSmoothModifierData *csmd,
|
|||
/* allocate deltas if they have not yet been allocated, otherwise we will just write over them */
|
||||
if (!csmd->delta_cache.deltas) {
|
||||
csmd->delta_cache.deltas_num = loops_num;
|
||||
csmd->delta_cache.deltas = MEM_malloc_arrayN(loops_num, sizeof(float[3]), __func__);
|
||||
csmd->delta_cache.deltas = static_cast<float(*)[3]>(
|
||||
MEM_malloc_arrayN(loops_num, sizeof(float[3]), __func__));
|
||||
}
|
||||
|
||||
smooth_verts(csmd, mesh, dvert, defgrp_index, smooth_vertex_coords, verts_num);
|
||||
|
||||
calc_tangent_spaces(mesh, smooth_vertex_coords, tangent_spaces, NULL, NULL);
|
||||
calc_tangent_spaces(mesh, smooth_vertex_coords, tangent_spaces, nullptr, nullptr);
|
||||
|
||||
copy_vn_fl(&csmd->delta_cache.deltas[0][0], (int)loops_num * 3, 0.0f);
|
||||
copy_vn_fl(&csmd->delta_cache.deltas[0][0], int(loops_num) * 3, 0.0f);
|
||||
|
||||
for (l_index = 0; l_index < loops_num; l_index++) {
|
||||
const int v_index = (int)mloop[l_index].v;
|
||||
const int v_index = int(mloop[l_index].v);
|
||||
float delta[3];
|
||||
sub_v3_v3v3(delta, rest_coords[v_index], smooth_vertex_coords[v_index]);
|
||||
|
||||
|
@ -563,7 +568,7 @@ static void correctivesmooth_modifier_do(ModifierData *md,
|
|||
Mesh *mesh,
|
||||
float (*vertexCos)[3],
|
||||
uint verts_num,
|
||||
struct BMEditMesh *em)
|
||||
BMEditMesh *em)
|
||||
{
|
||||
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
|
||||
|
||||
|
@ -577,7 +582,7 @@ static void correctivesmooth_modifier_do(ModifierData *md,
|
|||
const uint loops_num = (uint)mesh->totloop;
|
||||
|
||||
bool use_only_smooth = (csmd->flag & MOD_CORRECTIVESMOOTH_ONLY_SMOOTH) != 0;
|
||||
const MDeformVert *dvert = NULL;
|
||||
const MDeformVert *dvert = nullptr;
|
||||
int defgrp_index;
|
||||
|
||||
MOD_get_vgroup(ob, mesh, csmd->defgrp_name, &dvert, &defgrp_index);
|
||||
|
@ -587,14 +592,14 @@ static void correctivesmooth_modifier_do(ModifierData *md,
|
|||
/* signal to recalculate, whoever sets MUST also free bind coords */
|
||||
(csmd->bind_coords_num == (uint)-1)) {
|
||||
if (DEG_is_active(depsgraph)) {
|
||||
BLI_assert(csmd->bind_coords == NULL);
|
||||
csmd->bind_coords = MEM_dupallocN(vertexCos);
|
||||
BLI_assert(csmd->bind_coords == nullptr);
|
||||
csmd->bind_coords = static_cast<float(*)[3]>(MEM_dupallocN(vertexCos));
|
||||
csmd->bind_coords_num = verts_num;
|
||||
BLI_assert(csmd->bind_coords != NULL);
|
||||
BLI_assert(csmd->bind_coords != nullptr);
|
||||
/* Copy bound data to the original modifier. */
|
||||
CorrectiveSmoothModifierData *csmd_orig = (CorrectiveSmoothModifierData *)
|
||||
BKE_modifier_get_original(ob, &csmd->modifier);
|
||||
csmd_orig->bind_coords = MEM_dupallocN(csmd->bind_coords);
|
||||
csmd_orig->bind_coords = static_cast<float(*)[3]>(MEM_dupallocN(csmd->bind_coords));
|
||||
csmd_orig->bind_coords_num = csmd->bind_coords_num;
|
||||
}
|
||||
else {
|
||||
|
@ -607,7 +612,8 @@ static void correctivesmooth_modifier_do(ModifierData *md,
|
|||
return;
|
||||
}
|
||||
|
||||
if ((csmd->rest_source == MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND) && (csmd->bind_coords == NULL)) {
|
||||
if ((csmd->rest_source == MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND) &&
|
||||
(csmd->bind_coords == nullptr)) {
|
||||
BKE_modifier_set_error(ob, md, "Bind data required");
|
||||
goto error;
|
||||
}
|
||||
|
@ -653,7 +659,8 @@ static void correctivesmooth_modifier_do(ModifierData *md,
|
|||
else {
|
||||
int me_numVerts;
|
||||
rest_coords = em ? BKE_editmesh_vert_coords_alloc_orco(em, &me_numVerts) :
|
||||
BKE_mesh_vert_coords_alloc(ob->data, &me_numVerts);
|
||||
BKE_mesh_vert_coords_alloc(static_cast<const Mesh *>(ob->data),
|
||||
&me_numVerts);
|
||||
|
||||
BLI_assert((uint)me_numVerts == verts_num);
|
||||
is_rest_coords_alloc = true;
|
||||
|
@ -688,15 +695,14 @@ static void correctivesmooth_modifier_do(ModifierData *md,
|
|||
{
|
||||
uint l_index;
|
||||
|
||||
float(*tangent_spaces)[3][3];
|
||||
float *tangent_weights;
|
||||
|
||||
float *tangent_weights_per_vertex;
|
||||
const float scale = csmd->scale;
|
||||
|
||||
tangent_spaces = MEM_malloc_arrayN(loops_num, sizeof(float[3][3]), __func__);
|
||||
tangent_weights = MEM_malloc_arrayN(loops_num, sizeof(float), __func__);
|
||||
tangent_weights_per_vertex = MEM_malloc_arrayN(verts_num, sizeof(float), __func__);
|
||||
float(*tangent_spaces)[3][3] = static_cast<float(*)[3][3]>(
|
||||
MEM_malloc_arrayN(loops_num, sizeof(float[3][3]), __func__));
|
||||
float *tangent_weights = static_cast<float *>(
|
||||
MEM_malloc_arrayN(loops_num, sizeof(float), __func__));
|
||||
float *tangent_weights_per_vertex = static_cast<float *>(
|
||||
MEM_malloc_arrayN(verts_num, sizeof(float), __func__));
|
||||
|
||||
calc_tangent_spaces(
|
||||
mesh, vertexCos, tangent_spaces, tangent_weights, tangent_weights_per_vertex);
|
||||
|
@ -738,39 +744,40 @@ static void deformVerts(ModifierData *md,
|
|||
float (*vertexCos)[3],
|
||||
int verts_num)
|
||||
{
|
||||
Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false);
|
||||
Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false);
|
||||
|
||||
correctivesmooth_modifier_do(
|
||||
md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, (uint)verts_num, NULL);
|
||||
md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, (uint)verts_num, nullptr);
|
||||
|
||||
if (!ELEM(mesh_src, NULL, mesh)) {
|
||||
BKE_id_free(NULL, mesh_src);
|
||||
if (!ELEM(mesh_src, nullptr, mesh)) {
|
||||
BKE_id_free(nullptr, mesh_src);
|
||||
}
|
||||
}
|
||||
|
||||
static void deformVertsEM(ModifierData *md,
|
||||
const ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *editData,
|
||||
BMEditMesh *editData,
|
||||
Mesh *mesh,
|
||||
float (*vertexCos)[3],
|
||||
int verts_num)
|
||||
{
|
||||
Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false);
|
||||
Mesh *mesh_src = MOD_deform_mesh_eval_get(
|
||||
ctx->object, editData, mesh, nullptr, verts_num, false);
|
||||
|
||||
/* TODO(@campbellbarton): use edit-mode data only (remove this line). */
|
||||
if (mesh_src != NULL) {
|
||||
if (mesh_src != nullptr) {
|
||||
BKE_mesh_wrapper_ensure_mdata(mesh_src);
|
||||
}
|
||||
|
||||
correctivesmooth_modifier_do(
|
||||
md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, (uint)verts_num, editData);
|
||||
|
||||
if (!ELEM(mesh_src, NULL, mesh)) {
|
||||
BKE_id_free(NULL, mesh_src);
|
||||
if (!ELEM(mesh_src, nullptr, mesh)) {
|
||||
BKE_id_free(nullptr, mesh_src);
|
||||
}
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
|
@ -780,16 +787,16 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, ptr, "factor", 0, IFACE_("Factor"), ICON_NONE);
|
||||
uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "scale", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "smooth_type", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "iterations", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "scale", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "smooth_type", 0, nullptr, ICON_NONE);
|
||||
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL);
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr);
|
||||
|
||||
uiItemR(layout, ptr, "use_only_smooth", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_pin_boundary", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_only_smooth", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_pin_boundary", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "rest_source", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "rest_source", 0, nullptr, ICON_NONE);
|
||||
if (RNA_enum_get(ptr, "rest_source") == MOD_CORRECTIVESMOOTH_RESTSOURCE_BIND) {
|
||||
uiItemO(layout,
|
||||
(RNA_boolean_get(ptr, "is_bind") ? IFACE_("Unbind") : IFACE_("Bind")),
|
||||
|
@ -817,13 +824,13 @@ static void blendWrite(BlendWriter *writer, const ID *id_owner, const ModifierDa
|
|||
/* Modifier coming from linked data cannot be bound from an override, so we can remove all
|
||||
* binding data, can save a significant amount of memory. */
|
||||
csmd.bind_coords_num = 0;
|
||||
csmd.bind_coords = NULL;
|
||||
csmd.bind_coords = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
BLO_write_struct_at_address(writer, CorrectiveSmoothModifierData, md, &csmd);
|
||||
|
||||
if (csmd.bind_coords != NULL) {
|
||||
if (csmd.bind_coords != nullptr) {
|
||||
BLO_write_float3_array(writer, csmd.bind_coords_num, (float *)csmd.bind_coords);
|
||||
}
|
||||
}
|
||||
|
@ -833,11 +840,11 @@ static void blendRead(BlendDataReader *reader, ModifierData *md)
|
|||
CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)md;
|
||||
|
||||
if (csmd->bind_coords) {
|
||||
BLO_read_float3_array(reader, (int)csmd->bind_coords_num, (float **)&csmd->bind_coords);
|
||||
BLO_read_float3_array(reader, int(csmd->bind_coords_num), (float **)&csmd->bind_coords);
|
||||
}
|
||||
|
||||
/* runtime only */
|
||||
csmd->delta_cache.deltas = NULL;
|
||||
csmd->delta_cache.deltas = nullptr;
|
||||
csmd->delta_cache.deltas_num = 0;
|
||||
}
|
||||
|
||||
|
@ -853,22 +860,22 @@ ModifierTypeInfo modifierType_CorrectiveSmooth = {
|
|||
/*copyData*/ copyData,
|
||||
|
||||
/*deformVerts*/ deformVerts,
|
||||
/*deformMatrices*/ NULL,
|
||||
/*deformMatrices*/ nullptr,
|
||||
/*deformVertsEM*/ deformVertsEM,
|
||||
/*deformMatricesEM*/ NULL,
|
||||
/*modifyMesh*/ NULL,
|
||||
/*modifyGeometrySet*/ NULL,
|
||||
/*deformMatricesEM*/ nullptr,
|
||||
/*modifyMesh*/ nullptr,
|
||||
/*modifyGeometrySet*/ nullptr,
|
||||
|
||||
/*initData*/ initData,
|
||||
/*requiredDataMask*/ requiredDataMask,
|
||||
/*freeData*/ freeData,
|
||||
/*isDisabled*/ NULL,
|
||||
/*updateDepsgraph*/ NULL,
|
||||
/*dependsOnTime*/ NULL,
|
||||
/*dependsOnNormals*/ NULL,
|
||||
/*foreachIDLink*/ NULL,
|
||||
/*foreachTexLink*/ NULL,
|
||||
/*freeRuntimeData*/ NULL,
|
||||
/*isDisabled*/ nullptr,
|
||||
/*updateDepsgraph*/ nullptr,
|
||||
/*dependsOnTime*/ nullptr,
|
||||
/*dependsOnNormals*/ nullptr,
|
||||
/*foreachIDLink*/ nullptr,
|
||||
/*foreachTexLink*/ nullptr,
|
||||
/*freeRuntimeData*/ nullptr,
|
||||
/*panelRegister*/ panelRegister,
|
||||
/*blendWrite*/ blendWrite,
|
||||
/*blendRead*/ blendRead,
|
|
@ -72,9 +72,9 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
|
|||
|
||||
BKE_modifier_copydata_generic(md, target, flag);
|
||||
|
||||
temd->facepa = NULL;
|
||||
temd->facepa = nullptr;
|
||||
}
|
||||
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *UNUSED(md))
|
||||
static bool dependsOnTime(Scene * /*scene*/, ModifierData * /*md*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -90,12 +90,12 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma
|
|||
static void createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *psmd, Mesh *mesh)
|
||||
{
|
||||
ParticleSystem *psys = psmd->psys;
|
||||
MFace *fa = NULL, *mface = NULL;
|
||||
MFace *fa = nullptr, *mface = nullptr;
|
||||
ParticleData *pa;
|
||||
KDTree_3d *tree;
|
||||
RNG *rng;
|
||||
float center[3], co[3];
|
||||
int *facepa = NULL, *vertpa = NULL, totvert = 0, totface = 0, totpart = 0;
|
||||
int *facepa = nullptr, *vertpa = nullptr, totvert = 0, totface = 0, totpart = 0;
|
||||
int i, p, v1, v2, v3, v4 = 0;
|
||||
const bool invert_vgroup = (emd->flag & eExplodeFlag_INVERT_VGROUP) != 0;
|
||||
|
||||
|
@ -110,9 +110,9 @@ static void createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *p
|
|||
if (emd->facepa) {
|
||||
MEM_freeN(emd->facepa);
|
||||
}
|
||||
facepa = emd->facepa = MEM_calloc_arrayN(totface, sizeof(int), "explode_facepa");
|
||||
facepa = emd->facepa = static_cast<int *>(MEM_calloc_arrayN(totface, sizeof(int), __func__));
|
||||
|
||||
vertpa = MEM_calloc_arrayN(totvert, sizeof(int), "explode_vertpa");
|
||||
vertpa = static_cast<int *>(MEM_calloc_arrayN(totvert, sizeof(int), __func__));
|
||||
|
||||
/* initialize all faces & verts to no particle */
|
||||
for (i = 0; i < totface; i++) {
|
||||
|
@ -124,7 +124,7 @@ static void createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *p
|
|||
|
||||
/* set protected verts */
|
||||
if (emd->vgroup) {
|
||||
const MDeformVert *dvert = CustomData_get_layer(&mesh->vdata, CD_MDEFORMVERT);
|
||||
const MDeformVert *dvert = BKE_mesh_deform_verts(mesh);
|
||||
if (dvert) {
|
||||
const int defgrp_index = emd->vgroup - 1;
|
||||
for (i = 0; i < totvert; i++, dvert++) {
|
||||
|
@ -149,10 +149,10 @@ static void createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *p
|
|||
pa->fuv,
|
||||
pa->foffset,
|
||||
co,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr);
|
||||
BLI_kdtree_3d_insert(tree, p, co);
|
||||
}
|
||||
BLI_kdtree_3d_balance(tree);
|
||||
|
@ -169,7 +169,7 @@ static void createFacepa(ExplodeModifierData *emd, ParticleSystemModifierData *p
|
|||
mul_v3_fl(center, 1.0f / 3.0f);
|
||||
}
|
||||
|
||||
p = BLI_kdtree_3d_find_nearest(tree, center, NULL);
|
||||
p = BLI_kdtree_3d_find_nearest(tree, center, nullptr);
|
||||
|
||||
v1 = vertpa[fa->v1];
|
||||
v2 = vertpa[fa->v2];
|
||||
|
@ -215,7 +215,8 @@ static const short add_faces[24] = {
|
|||
|
||||
static MFace *get_dface(Mesh *mesh, Mesh *split, int cur, int i, MFace *mf)
|
||||
{
|
||||
MFace *mfaces = CustomData_get_layer_for_write(&split->fdata, CD_MFACE, split->totface);
|
||||
MFace *mfaces = static_cast<MFace *>(
|
||||
CustomData_get_layer_for_write(&split->fdata, CD_MFACE, split->totface));
|
||||
MFace *df = &mfaces[cur];
|
||||
CustomData_copy_data(&mesh->fdata, &split->fdata, i, cur, 1);
|
||||
*df = *mf;
|
||||
|
@ -284,11 +285,13 @@ static void remap_uvs_3_6_9_12(
|
|||
int l;
|
||||
|
||||
for (l = 0; l < layers_num; l++) {
|
||||
mf = CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface));
|
||||
df1 = mf + cur;
|
||||
df2 = df1 + 1;
|
||||
df3 = df1 + 2;
|
||||
mf = CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface));
|
||||
mf += i;
|
||||
|
||||
copy_v2_v2(df1->uv[0], mf->uv[c0]);
|
||||
|
@ -344,10 +347,12 @@ static void remap_uvs_5_10(
|
|||
int l;
|
||||
|
||||
for (l = 0; l < layers_num; l++) {
|
||||
mf = CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface));
|
||||
df1 = mf + cur;
|
||||
df2 = df1 + 1;
|
||||
mf = CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface));
|
||||
mf += i;
|
||||
|
||||
copy_v2_v2(df1->uv[0], mf->uv[c0]);
|
||||
|
@ -416,12 +421,14 @@ static void remap_uvs_15(
|
|||
int l;
|
||||
|
||||
for (l = 0; l < layers_num; l++) {
|
||||
mf = CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface));
|
||||
df1 = mf + cur;
|
||||
df2 = df1 + 1;
|
||||
df3 = df1 + 2;
|
||||
df4 = df1 + 3;
|
||||
mf = CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface));
|
||||
mf += i;
|
||||
|
||||
copy_v2_v2(df1->uv[0], mf->uv[c0]);
|
||||
|
@ -492,11 +499,13 @@ static void remap_uvs_7_11_13_14(
|
|||
int l;
|
||||
|
||||
for (l = 0; l < layers_num; l++) {
|
||||
mf = CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface));
|
||||
df1 = mf + cur;
|
||||
df2 = df1 + 1;
|
||||
df3 = df1 + 2;
|
||||
mf = CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface));
|
||||
mf += i;
|
||||
|
||||
copy_v2_v2(df1->uv[0], mf->uv[c0]);
|
||||
|
@ -552,10 +561,12 @@ static void remap_uvs_19_21_22(
|
|||
int l;
|
||||
|
||||
for (l = 0; l < layers_num; l++) {
|
||||
mf = CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface));
|
||||
df1 = mf + cur;
|
||||
df2 = df1 + 1;
|
||||
mf = CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface));
|
||||
mf += i;
|
||||
|
||||
copy_v2_v2(df1->uv[0], mf->uv[c0]);
|
||||
|
@ -614,10 +625,12 @@ static void remap_uvs_23(
|
|||
int l;
|
||||
|
||||
for (l = 0; l < layers_num; l++) {
|
||||
mf = CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&split->fdata, CD_MTFACE, l, split->totface));
|
||||
df1 = mf + cur;
|
||||
df2 = df1 + 1;
|
||||
mf = CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface);
|
||||
mf = static_cast<MTFace *>(
|
||||
CustomData_get_layer_n_for_write(&mesh->fdata, CD_MTFACE, l, mesh->totface));
|
||||
mf += i;
|
||||
|
||||
copy_v2_v2(df1->uv[0], mf->uv[c0]);
|
||||
|
@ -638,16 +651,17 @@ static void remap_uvs_23(
|
|||
static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh)
|
||||
{
|
||||
Mesh *split_m;
|
||||
MFace *mf = NULL, *df1 = NULL;
|
||||
MFace *mface = CustomData_get_layer_for_write(&mesh->fdata, CD_MFACE, mesh->totface);
|
||||
MFace *mf = nullptr, *df1 = nullptr;
|
||||
MFace *mface = static_cast<MFace *>(
|
||||
CustomData_get_layer_for_write(&mesh->fdata, CD_MFACE, mesh->totface));
|
||||
float *dupve;
|
||||
EdgeHash *edgehash;
|
||||
EdgeHashIterator *ehi;
|
||||
int totvert = mesh->totvert;
|
||||
int totface = mesh->totface;
|
||||
|
||||
int *facesplit = MEM_calloc_arrayN(totface, sizeof(int), "explode_facesplit");
|
||||
int *vertpa = MEM_calloc_arrayN(totvert, sizeof(int), "explode_vertpa2");
|
||||
int *facesplit = static_cast<int *>(MEM_calloc_arrayN(totface, sizeof(int), __func__));
|
||||
int *vertpa = static_cast<int *>(MEM_calloc_arrayN(totvert, sizeof(int), __func__));
|
||||
int *facepa = emd->facepa;
|
||||
int *fs, totesplit = 0, totfsplit = 0, curdupface = 0;
|
||||
int i, v1, v2, v3, v4, esplit, v[4] = {0, 0, 0, 0}, /* To quite gcc barking... */
|
||||
|
@ -674,12 +688,12 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh)
|
|||
v3 = vertpa[mf->v3];
|
||||
|
||||
if (v1 != v2) {
|
||||
BLI_edgehash_reinsert(edgehash, mf->v1, mf->v2, NULL);
|
||||
BLI_edgehash_reinsert(edgehash, mf->v1, mf->v2, nullptr);
|
||||
(*fs) |= 1;
|
||||
}
|
||||
|
||||
if (v2 != v3) {
|
||||
BLI_edgehash_reinsert(edgehash, mf->v2, mf->v3, NULL);
|
||||
BLI_edgehash_reinsert(edgehash, mf->v2, mf->v3, nullptr);
|
||||
(*fs) |= 2;
|
||||
}
|
||||
|
||||
|
@ -687,25 +701,25 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh)
|
|||
v4 = vertpa[mf->v4];
|
||||
|
||||
if (v3 != v4) {
|
||||
BLI_edgehash_reinsert(edgehash, mf->v3, mf->v4, NULL);
|
||||
BLI_edgehash_reinsert(edgehash, mf->v3, mf->v4, nullptr);
|
||||
(*fs) |= 4;
|
||||
}
|
||||
|
||||
if (v1 != v4) {
|
||||
BLI_edgehash_reinsert(edgehash, mf->v1, mf->v4, NULL);
|
||||
BLI_edgehash_reinsert(edgehash, mf->v1, mf->v4, nullptr);
|
||||
(*fs) |= 8;
|
||||
}
|
||||
|
||||
/* mark center vertex as a fake edge split */
|
||||
if (*fs == 15) {
|
||||
BLI_edgehash_reinsert(edgehash, mf->v1, mf->v3, NULL);
|
||||
BLI_edgehash_reinsert(edgehash, mf->v1, mf->v3, nullptr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
(*fs) |= 16; /* mark face as tri */
|
||||
|
||||
if (v1 != v3) {
|
||||
BLI_edgehash_reinsert(edgehash, mf->v1, mf->v3, NULL);
|
||||
BLI_edgehash_reinsert(edgehash, mf->v1, mf->v3, nullptr);
|
||||
(*fs) |= 4;
|
||||
}
|
||||
}
|
||||
|
@ -742,7 +756,8 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh)
|
|||
* later interpreted as tri's, for this to work right I think we probably
|
||||
* have to stop using tessface. */
|
||||
|
||||
facepa = MEM_calloc_arrayN((totface + (totfsplit * 2)), sizeof(int), "explode_facepa");
|
||||
facepa = static_cast<int *>(
|
||||
MEM_calloc_arrayN((totface + (totfsplit * 2)), sizeof(int), __func__));
|
||||
// memcpy(facepa, emd->facepa, totface*sizeof(int));
|
||||
emd->facepa = facepa;
|
||||
|
||||
|
@ -869,13 +884,14 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh)
|
|||
curdupface += add_faces[*fs] + 1;
|
||||
}
|
||||
|
||||
MFace *split_mface = CustomData_get_layer_for_write(&split_m->fdata, CD_MFACE, split_m->totface);
|
||||
MFace *split_mface = static_cast<MFace *>(
|
||||
CustomData_get_layer_for_write(&split_m->fdata, CD_MFACE, split_m->totface));
|
||||
for (i = 0; i < curdupface; i++) {
|
||||
mf = &split_mface[i];
|
||||
BKE_mesh_mface_index_validate(mf, &split_m->fdata, i, ((mf->flag & ME_FACE_SEL) ? 4 : 3));
|
||||
}
|
||||
|
||||
BLI_edgehash_free(edgehash, NULL);
|
||||
BLI_edgehash_free(edgehash, nullptr);
|
||||
MEM_freeN(facesplit);
|
||||
MEM_freeN(vertpa);
|
||||
|
||||
|
@ -891,14 +907,14 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
Mesh *to_explode)
|
||||
{
|
||||
Mesh *explode, *mesh = to_explode;
|
||||
MFace *mf = NULL, *mface;
|
||||
MFace *mf = nullptr, *mface;
|
||||
// ParticleSettings *part=psmd->psys->part; /* UNUSED */
|
||||
ParticleSimulationData sim = {NULL};
|
||||
ParticleData *pa = NULL, *pars = psmd->psys->particles;
|
||||
ParticleSimulationData sim = {nullptr};
|
||||
ParticleData *pa = nullptr, *pars = psmd->psys->particles;
|
||||
ParticleKey state, birth;
|
||||
EdgeHash *vertpahash;
|
||||
EdgeHashIterator *ehi;
|
||||
float *vertco = NULL, imat[4][4];
|
||||
float *vertco = nullptr, imat[4][4];
|
||||
float rot[4];
|
||||
float ctime;
|
||||
// float timestep;
|
||||
|
@ -909,7 +925,8 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
|
||||
totface = mesh->totface;
|
||||
totvert = mesh->totvert;
|
||||
mface = CustomData_get_layer_for_write(&mesh->fdata, CD_MFACE, mesh->totface);
|
||||
mface = static_cast<MFace *>(
|
||||
CustomData_get_layer_for_write(&mesh->fdata, CD_MFACE, mesh->totface));
|
||||
totpart = psmd->psys->totpart;
|
||||
|
||||
sim.depsgraph = ctx->depsgraph;
|
||||
|
@ -937,12 +954,12 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
}
|
||||
}
|
||||
else {
|
||||
pa = NULL;
|
||||
pa = nullptr;
|
||||
}
|
||||
|
||||
/* do mindex + totvert to ensure the vertex index to be the first
|
||||
* with BLI_edgehashIterator_getKey */
|
||||
if (pa == NULL || ctime < pa->time) {
|
||||
if (pa == nullptr || ctime < pa->time) {
|
||||
mindex = totvert + totpart;
|
||||
}
|
||||
else {
|
||||
|
@ -952,11 +969,11 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
mf = &mface[i];
|
||||
|
||||
/* set face vertices to exist in particle group */
|
||||
BLI_edgehash_reinsert(vertpahash, mf->v1, mindex, NULL);
|
||||
BLI_edgehash_reinsert(vertpahash, mf->v2, mindex, NULL);
|
||||
BLI_edgehash_reinsert(vertpahash, mf->v3, mindex, NULL);
|
||||
BLI_edgehash_reinsert(vertpahash, mf->v1, mindex, nullptr);
|
||||
BLI_edgehash_reinsert(vertpahash, mf->v2, mindex, nullptr);
|
||||
BLI_edgehash_reinsert(vertpahash, mf->v3, mindex, nullptr);
|
||||
if (mf->v4) {
|
||||
BLI_edgehash_reinsert(vertpahash, mf->v4, mindex, NULL);
|
||||
BLI_edgehash_reinsert(vertpahash, mf->v4, mindex, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -971,8 +988,8 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
/* the final duplicated vertices */
|
||||
explode = BKE_mesh_new_nomain_from_template(mesh, totdup, 0, totface - delface, 0, 0);
|
||||
|
||||
MTFace *mtface = CustomData_get_layer_named_for_write(
|
||||
&explode->fdata, CD_MTFACE, emd->uvname, explode->totface);
|
||||
MTFace *mtface = static_cast<MTFace *>(CustomData_get_layer_named_for_write(
|
||||
&explode->fdata, CD_MTFACE, emd->uvname, explode->totface));
|
||||
|
||||
/* getting back to object space */
|
||||
invert_m4_m4(imat, ctx->object->object_to_world);
|
||||
|
@ -1024,14 +1041,14 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
mul_m4_v3(imat, vertco);
|
||||
}
|
||||
else {
|
||||
pa = NULL;
|
||||
pa = nullptr;
|
||||
}
|
||||
}
|
||||
BLI_edgehashIterator_free(ehi);
|
||||
|
||||
/* Map new vertices to faces. */
|
||||
MFace *explode_mface = CustomData_get_layer_for_write(
|
||||
&explode->fdata, CD_MFACE, explode->totface);
|
||||
MFace *explode_mface = static_cast<MFace *>(
|
||||
CustomData_get_layer_for_write(&explode->fdata, CD_MFACE, explode->totface));
|
||||
for (i = 0, u = 0; i < totface; i++) {
|
||||
MFace source;
|
||||
int orig_v4;
|
||||
|
@ -1050,7 +1067,7 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
}
|
||||
}
|
||||
else {
|
||||
pa = NULL;
|
||||
pa = nullptr;
|
||||
}
|
||||
|
||||
source = mface[i];
|
||||
|
@ -1059,7 +1076,7 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
orig_v4 = source.v4;
|
||||
|
||||
/* Same as above in the first loop over mesh's faces. */
|
||||
if (pa == NULL || ctime < pa->time) {
|
||||
if (pa == nullptr || ctime < pa->time) {
|
||||
mindex = totvert + totpart;
|
||||
}
|
||||
else {
|
||||
|
@ -1079,7 +1096,7 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
|
||||
/* override uv channel for particle age */
|
||||
if (mtface) {
|
||||
float age = (pa != NULL) ? (ctime - pa->time) / pa->lifetime : 0.0f;
|
||||
float age = (pa != nullptr) ? (ctime - pa->time) / pa->lifetime : 0.0f;
|
||||
/* Clamp to this range to avoid flipping to the other side of the coordinates. */
|
||||
CLAMP(age, 0.001f, 0.999f);
|
||||
|
||||
|
@ -1094,7 +1111,7 @@ static Mesh *explodeMesh(ExplodeModifierData *emd,
|
|||
}
|
||||
|
||||
/* cleanup */
|
||||
BLI_edgehash_free(vertpahash, NULL);
|
||||
BLI_edgehash_free(vertpahash, nullptr);
|
||||
|
||||
/* finalization */
|
||||
BKE_mesh_calc_edges_tessface(explode);
|
||||
|
@ -1110,7 +1127,7 @@ static ParticleSystemModifierData *findPrecedingParticlesystem(Object *ob, Modif
|
|||
ModifierData *md;
|
||||
ParticleSystemModifierData *psmd = NULL;
|
||||
|
||||
for (md = ob->modifiers.first; emd != md; md = md->next) {
|
||||
for (md = static_cast<ModifierData *>(ob->modifiers.first); emd != md; md = md->next) {
|
||||
if (md->type == eModifierType_ParticleSystem) {
|
||||
psmd = (ParticleSystemModifierData *)md;
|
||||
}
|
||||
|
@ -1125,20 +1142,20 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
if (psmd) {
|
||||
ParticleSystem *psys = psmd->psys;
|
||||
|
||||
if (psys == NULL || psys->totpart == 0) {
|
||||
if (psys == nullptr || psys->totpart == 0) {
|
||||
return mesh;
|
||||
}
|
||||
if (psys->part == NULL || psys->particles == NULL) {
|
||||
if (psys->part == nullptr || psys->particles == nullptr) {
|
||||
return mesh;
|
||||
}
|
||||
if (psmd->mesh_final == NULL) {
|
||||
if (psmd->mesh_final == nullptr) {
|
||||
return mesh;
|
||||
}
|
||||
|
||||
BKE_mesh_tessface_ensure(mesh); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */
|
||||
|
||||
/* 1. find faces to be exploded if needed */
|
||||
if (emd->facepa == NULL || psmd->flag & eParticleSystemFlag_Pars ||
|
||||
if (emd->facepa == nullptr || psmd->flag & eParticleSystemFlag_Pars ||
|
||||
emd->flag & eExplodeFlag_CalcFaces ||
|
||||
MEM_allocN_len(emd->facepa) / sizeof(int) != mesh->totface) {
|
||||
if (psmd->flag & eParticleSystemFlag_Pars) {
|
||||
|
@ -1158,7 +1175,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
|
||||
MEM_freeN(emd->facepa);
|
||||
emd->facepa = facepa;
|
||||
BKE_id_free(NULL, split_m);
|
||||
BKE_id_free(nullptr, split_m);
|
||||
return explode;
|
||||
}
|
||||
|
||||
|
@ -1167,7 +1184,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
return mesh;
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *row, *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -1181,24 +1198,24 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemPointerR(layout, ptr, "particle_uv", &obj_data_ptr, "uv_layers", NULL, ICON_NONE);
|
||||
uiItemPointerR(layout, ptr, "particle_uv", &obj_data_ptr, "uv_layers", nullptr, ICON_NONE);
|
||||
|
||||
row = uiLayoutRowWithHeading(layout, true, IFACE_("Show"));
|
||||
uiItemR(row, ptr, "show_alive", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "show_dead", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "show_unborn", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "show_alive", toggles_flag, nullptr, ICON_NONE);
|
||||
uiItemR(row, ptr, "show_dead", toggles_flag, nullptr, ICON_NONE);
|
||||
uiItemR(row, ptr, "show_unborn", toggles_flag, nullptr, ICON_NONE);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, ptr, "use_edge_cut", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "use_size", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "use_edge_cut", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "use_size", 0, nullptr, ICON_NONE);
|
||||
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL);
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr);
|
||||
|
||||
row = uiLayoutRow(layout, false);
|
||||
uiLayoutSetActive(row, has_vertex_group);
|
||||
uiItemR(row, ptr, "protect", 0, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "protect", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemO(layout, IFACE_("Refresh"), ICON_NONE, "OBJECT_OT_explode_refresh");
|
||||
|
||||
|
@ -1210,11 +1227,11 @@ static void panelRegister(ARegionType *region_type)
|
|||
modifier_panel_register(region_type, eModifierType_Explode, panel_draw);
|
||||
}
|
||||
|
||||
static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md)
|
||||
static void blendRead(BlendDataReader * /*reader*/, ModifierData *md)
|
||||
{
|
||||
ExplodeModifierData *psmd = (ExplodeModifierData *)md;
|
||||
|
||||
psmd->facepa = NULL;
|
||||
psmd->facepa = nullptr;
|
||||
}
|
||||
|
||||
ModifierTypeInfo modifierType_Explode = {
|
||||
|
@ -1227,24 +1244,24 @@ ModifierTypeInfo modifierType_Explode = {
|
|||
/*icon*/ ICON_MOD_EXPLODE,
|
||||
/*copyData*/ copyData,
|
||||
|
||||
/*deformVerts*/ NULL,
|
||||
/*deformMatrices*/ NULL,
|
||||
/*deformVertsEM*/ NULL,
|
||||
/*deformMatricesEM*/ NULL,
|
||||
/*deformVerts*/ nullptr,
|
||||
/*deformMatrices*/ nullptr,
|
||||
/*deformVertsEM*/ nullptr,
|
||||
/*deformMatricesEM*/ nullptr,
|
||||
/*modifyMesh*/ modifyMesh,
|
||||
/*modifyGeometrySet*/ NULL,
|
||||
/*modifyGeometrySet*/ nullptr,
|
||||
|
||||
/*initData*/ initData,
|
||||
/*requiredDataMask*/ requiredDataMask,
|
||||
/*freeData*/ freeData,
|
||||
/*isDisabled*/ NULL,
|
||||
/*updateDepsgraph*/ NULL,
|
||||
/*isDisabled*/ nullptr,
|
||||
/*updateDepsgraph*/ nullptr,
|
||||
/*dependsOnTime*/ dependsOnTime,
|
||||
/*dependsOnNormals*/ NULL,
|
||||
/*foreachIDLink*/ NULL,
|
||||
/*foreachTexLink*/ NULL,
|
||||
/*freeRuntimeData*/ NULL,
|
||||
/*dependsOnNormals*/ nullptr,
|
||||
/*foreachIDLink*/ nullptr,
|
||||
/*foreachTexLink*/ nullptr,
|
||||
/*freeRuntimeData*/ nullptr,
|
||||
/*panelRegister*/ panelRegister,
|
||||
/*blendWrite*/ NULL,
|
||||
/*blendWrite*/ nullptr,
|
||||
/*blendRead*/ blendRead,
|
||||
};
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
#include "eigen_capi.h"
|
||||
|
||||
struct BLaplacianSystem {
|
||||
struct LaplacianSystem {
|
||||
float *eweights; /* Length weights per Edge */
|
||||
float (*fweights)[3]; /* Cotangent weights per face */
|
||||
float *ring_areas; /* Total area per ring. */
|
||||
|
@ -64,7 +64,6 @@ struct BLaplacianSystem {
|
|||
float min_area;
|
||||
float vert_centroid[3];
|
||||
};
|
||||
typedef struct BLaplacianSystem LaplacianSystem;
|
||||
|
||||
static float compute_volume(const float center[3],
|
||||
float (*vertexCos)[3],
|
||||
|
@ -97,10 +96,10 @@ static void delete_laplacian_system(LaplacianSystem *sys)
|
|||
if (sys->context) {
|
||||
EIG_linear_solver_delete(sys->context);
|
||||
}
|
||||
sys->vertexCos = NULL;
|
||||
sys->mpoly = NULL;
|
||||
sys->mloop = NULL;
|
||||
sys->medges = NULL;
|
||||
sys->vertexCos = nullptr;
|
||||
sys->mpoly = nullptr;
|
||||
sys->mloop = nullptr;
|
||||
sys->medges = nullptr;
|
||||
MEM_freeN(sys);
|
||||
}
|
||||
|
||||
|
@ -122,20 +121,20 @@ static LaplacianSystem *init_laplacian_system(int a_numEdges,
|
|||
int a_numVerts)
|
||||
{
|
||||
LaplacianSystem *sys;
|
||||
sys = MEM_callocN(sizeof(LaplacianSystem), "ModLaplSmoothSystem");
|
||||
sys = static_cast<LaplacianSystem *>(MEM_callocN(sizeof(LaplacianSystem), __func__));
|
||||
sys->edges_num = a_numEdges;
|
||||
sys->polys_num = a_numPolys;
|
||||
sys->loops_num = a_numLoops;
|
||||
sys->verts_num = a_numVerts;
|
||||
|
||||
sys->eweights = MEM_calloc_arrayN(sys->edges_num, sizeof(float), __func__);
|
||||
sys->fweights = MEM_calloc_arrayN(sys->loops_num, sizeof(float[3]), __func__);
|
||||
sys->ne_ed_num = MEM_calloc_arrayN(sys->verts_num, sizeof(short), __func__);
|
||||
sys->ne_fa_num = MEM_calloc_arrayN(sys->verts_num, sizeof(short), __func__);
|
||||
sys->ring_areas = MEM_calloc_arrayN(sys->verts_num, sizeof(float), __func__);
|
||||
sys->vlengths = MEM_calloc_arrayN(sys->verts_num, sizeof(float), __func__);
|
||||
sys->vweights = MEM_calloc_arrayN(sys->verts_num, sizeof(float), __func__);
|
||||
sys->zerola = MEM_calloc_arrayN(sys->verts_num, sizeof(bool), __func__);
|
||||
sys->eweights = MEM_cnew_array<float>(sys->edges_num, __func__);
|
||||
sys->fweights = MEM_cnew_array<float[3]>(sys->loops_num, __func__);
|
||||
sys->ne_ed_num = MEM_cnew_array<short>(sys->verts_num, __func__);
|
||||
sys->ne_fa_num = MEM_cnew_array<short>(sys->verts_num, __func__);
|
||||
sys->ring_areas = MEM_cnew_array<float>(sys->verts_num, __func__);
|
||||
sys->vlengths = MEM_cnew_array<float>(sys->verts_num, __func__);
|
||||
sys->vweights = MEM_cnew_array<float>(sys->verts_num, __func__);
|
||||
sys->zerola = MEM_cnew_array<bool>(sys->verts_num, __func__);
|
||||
|
||||
return sys;
|
||||
}
|
||||
|
@ -350,15 +349,15 @@ static void validate_solution(LaplacianSystem *sys, short flag, float lambda, fl
|
|||
lam = sys->ne_ed_num[i] == sys->ne_fa_num[i] ? (lambda >= 0.0f ? 1.0f : -1.0f) :
|
||||
(lambda_border >= 0.0f ? 1.0f : -1.0f);
|
||||
if (flag & MOD_LAPLACIANSMOOTH_X) {
|
||||
sys->vertexCos[i][0] += lam * ((float)EIG_linear_solver_variable_get(sys->context, 0, i) -
|
||||
sys->vertexCos[i][0] += lam * (float(EIG_linear_solver_variable_get(sys->context, 0, i)) -
|
||||
sys->vertexCos[i][0]);
|
||||
}
|
||||
if (flag & MOD_LAPLACIANSMOOTH_Y) {
|
||||
sys->vertexCos[i][1] += lam * ((float)EIG_linear_solver_variable_get(sys->context, 1, i) -
|
||||
sys->vertexCos[i][1] += lam * (float(EIG_linear_solver_variable_get(sys->context, 1, i)) -
|
||||
sys->vertexCos[i][1]);
|
||||
}
|
||||
if (flag & MOD_LAPLACIANSMOOTH_Z) {
|
||||
sys->vertexCos[i][2] += lam * ((float)EIG_linear_solver_variable_get(sys->context, 2, i) -
|
||||
sys->vertexCos[i][2] += lam * (float(EIG_linear_solver_variable_get(sys->context, 2, i)) -
|
||||
sys->vertexCos[i][2]);
|
||||
}
|
||||
}
|
||||
|
@ -374,8 +373,8 @@ static void laplaciansmoothModifier_do(
|
|||
LaplacianSmoothModifierData *smd, Object *ob, Mesh *mesh, float (*vertexCos)[3], int verts_num)
|
||||
{
|
||||
LaplacianSystem *sys;
|
||||
const MDeformVert *dvert = NULL;
|
||||
const MDeformVert *dv = NULL;
|
||||
const MDeformVert *dvert = nullptr;
|
||||
const MDeformVert *dv = nullptr;
|
||||
float w, wpaint;
|
||||
int i, iter;
|
||||
int defgrp_index;
|
||||
|
@ -412,7 +411,7 @@ static void laplaciansmoothModifier_do(
|
|||
}
|
||||
}
|
||||
if (iter == 0 && verts_num > 0) {
|
||||
mul_v3_fl(sys->vert_centroid, 1.0f / (float)verts_num);
|
||||
mul_v3_fl(sys->vert_centroid, 1.0f / float(verts_num));
|
||||
}
|
||||
|
||||
dv = dvert;
|
||||
|
@ -478,7 +477,7 @@ static void laplaciansmoothModifier_do(
|
|||
}
|
||||
}
|
||||
EIG_linear_solver_delete(sys->context);
|
||||
sys->context = NULL;
|
||||
sys->context = nullptr;
|
||||
|
||||
delete_laplacian_system(sys);
|
||||
}
|
||||
|
@ -492,9 +491,7 @@ static void init_data(ModifierData *md)
|
|||
MEMCPY_STRUCT_AFTER(smd, DNA_struct_default_get(LaplacianSmoothModifierData), modifier);
|
||||
}
|
||||
|
||||
static bool is_disabled(const struct Scene *UNUSED(scene),
|
||||
ModifierData *md,
|
||||
bool UNUSED(useRenderParams))
|
||||
static bool is_disabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/)
|
||||
{
|
||||
LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *)md;
|
||||
short flag;
|
||||
|
@ -531,19 +528,19 @@ static void deformVerts(ModifierData *md,
|
|||
return;
|
||||
}
|
||||
|
||||
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false);
|
||||
mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false);
|
||||
|
||||
laplaciansmoothModifier_do(
|
||||
(LaplacianSmoothModifierData *)md, ctx->object, mesh_src, vertexCos, verts_num);
|
||||
|
||||
if (!ELEM(mesh_src, NULL, mesh)) {
|
||||
BKE_id_free(NULL, mesh_src);
|
||||
if (!ELEM(mesh_src, nullptr, mesh)) {
|
||||
BKE_id_free(nullptr, mesh_src);
|
||||
}
|
||||
}
|
||||
|
||||
static void deformVertsEM(ModifierData *md,
|
||||
const ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *editData,
|
||||
BMEditMesh *editData,
|
||||
Mesh *mesh,
|
||||
float (*vertexCos)[3],
|
||||
int verts_num)
|
||||
|
@ -554,22 +551,22 @@ static void deformVertsEM(ModifierData *md,
|
|||
return;
|
||||
}
|
||||
|
||||
mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false);
|
||||
mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, nullptr, verts_num, false);
|
||||
|
||||
/* TODO(@campbellbarton): use edit-mode data only (remove this line). */
|
||||
if (mesh_src != NULL) {
|
||||
if (mesh_src != nullptr) {
|
||||
BKE_mesh_wrapper_ensure_mdata(mesh_src);
|
||||
}
|
||||
|
||||
laplaciansmoothModifier_do(
|
||||
(LaplacianSmoothModifierData *)md, ctx->object, mesh_src, vertexCos, verts_num);
|
||||
|
||||
if (!ELEM(mesh_src, NULL, mesh)) {
|
||||
BKE_id_free(NULL, mesh_src);
|
||||
if (!ELEM(mesh_src, nullptr, mesh)) {
|
||||
BKE_id_free(nullptr, mesh_src);
|
||||
}
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *row;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -580,20 +577,20 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "iterations", 0, nullptr, ICON_NONE);
|
||||
|
||||
row = uiLayoutRowWithHeading(layout, true, IFACE_("Axis"));
|
||||
uiItemR(row, ptr, "use_x", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_y", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_z", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_x", toggles_flag, nullptr, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_y", toggles_flag, nullptr, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_z", toggles_flag, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "lambda_factor", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "lambda_border", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "lambda_factor", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "lambda_border", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "use_volume_preserve", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_normalized", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_volume_preserve", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_normalized", 0, nullptr, ICON_NONE);
|
||||
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL);
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr);
|
||||
|
||||
modifier_panel_end(layout, ptr);
|
||||
}
|
||||
|
@ -615,23 +612,23 @@ ModifierTypeInfo modifierType_LaplacianSmooth = {
|
|||
/*copyData*/ BKE_modifier_copydata_generic,
|
||||
|
||||
/*deformVerts*/ deformVerts,
|
||||
/*deformMatrices*/ NULL,
|
||||
/*deformMatrices*/ nullptr,
|
||||
/*deformVertsEM*/ deformVertsEM,
|
||||
/*deformMatricesEM*/ NULL,
|
||||
/*modifyMesh*/ NULL,
|
||||
/*modifyGeometrySet*/ NULL,
|
||||
/*deformMatricesEM*/ nullptr,
|
||||
/*modifyMesh*/ nullptr,
|
||||
/*modifyGeometrySet*/ nullptr,
|
||||
|
||||
/*initData*/ init_data,
|
||||
/*requiredDataMask*/ required_data_mask,
|
||||
/*freeData*/ NULL,
|
||||
/*freeData*/ nullptr,
|
||||
/*isDisabled*/ is_disabled,
|
||||
/*updateDepsgraph*/ NULL,
|
||||
/*dependsOnTime*/ NULL,
|
||||
/*dependsOnNormals*/ NULL,
|
||||
/*foreachIDLink*/ NULL,
|
||||
/*foreachTexLink*/ NULL,
|
||||
/*freeRuntimeData*/ NULL,
|
||||
/*updateDepsgraph*/ nullptr,
|
||||
/*dependsOnTime*/ nullptr,
|
||||
/*dependsOnNormals*/ nullptr,
|
||||
/*foreachIDLink*/ nullptr,
|
||||
/*foreachTexLink*/ nullptr,
|
||||
/*freeRuntimeData*/ nullptr,
|
||||
/*panelRegister*/ panelRegister,
|
||||
/*blendWrite*/ NULL,
|
||||
/*blendRead*/ NULL,
|
||||
/*blendWrite*/ nullptr,
|
||||
/*blendRead*/ nullptr,
|
||||
};
|
|
@ -45,7 +45,7 @@
|
|||
#include "MOD_ui_common.h"
|
||||
|
||||
#ifdef WITH_OCEANSIM
|
||||
static void init_cache_data(Object *ob, struct OceanModifierData *omd, const int resolution)
|
||||
static void init_cache_data(Object *ob, OceanModifierData *omd, const int resolution)
|
||||
{
|
||||
const char *relbase = BKE_modifier_path_relbase_from_global(ob);
|
||||
|
||||
|
@ -60,7 +60,7 @@ static void init_cache_data(Object *ob, struct OceanModifierData *omd, const int
|
|||
resolution);
|
||||
}
|
||||
|
||||
static void simulate_ocean_modifier(struct OceanModifierData *omd)
|
||||
static void simulate_ocean_modifier(OceanModifierData *omd)
|
||||
{
|
||||
BKE_ocean_simulate(omd->ocean, omd->time, omd->wave_scale, omd->chop_amount);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
|
|||
|
||||
/* The oceancache object will be recreated for this copy
|
||||
* automatically when cached=true */
|
||||
tomd->oceancache = NULL;
|
||||
tomd->oceancache = nullptr;
|
||||
|
||||
tomd->ocean = BKE_ocean_add();
|
||||
if (BKE_ocean_init_from_modifier(tomd->ocean, tomd, tomd->viewport_resolution)) {
|
||||
|
@ -139,8 +139,7 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma
|
|||
}
|
||||
}
|
||||
#else /* WITH_OCEANSIM */
|
||||
static void requiredDataMask(ModifierData *UNUSED(md),
|
||||
CustomData_MeshMasks *UNUSED(r_cddata_masks))
|
||||
static void requiredDataMask(ModifierData * /*md*/, CustomData_MeshMasks * /*r_cddata_masks*/)
|
||||
{
|
||||
}
|
||||
#endif /* WITH_OCEANSIM */
|
||||
|
@ -153,7 +152,7 @@ static bool dependsOnNormals(ModifierData *md)
|
|||
|
||||
#ifdef WITH_OCEANSIM
|
||||
|
||||
typedef struct GenerateOceanGeometryData {
|
||||
struct GenerateOceanGeometryData {
|
||||
float (*vert_positions)[3];
|
||||
MPoly *mpolys;
|
||||
MLoop *mloops;
|
||||
|
@ -164,13 +163,13 @@ typedef struct GenerateOceanGeometryData {
|
|||
float ox, oy;
|
||||
float sx, sy;
|
||||
float ix, iy;
|
||||
} GenerateOceanGeometryData;
|
||||
};
|
||||
|
||||
static void generate_ocean_geometry_verts(void *__restrict userdata,
|
||||
const int y,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
GenerateOceanGeometryData *gogd = userdata;
|
||||
GenerateOceanGeometryData *gogd = static_cast<GenerateOceanGeometryData *>(userdata);
|
||||
int x;
|
||||
|
||||
for (x = 0; x <= gogd->res_x; x++) {
|
||||
|
@ -184,9 +183,9 @@ static void generate_ocean_geometry_verts(void *__restrict userdata,
|
|||
|
||||
static void generate_ocean_geometry_polys(void *__restrict userdata,
|
||||
const int y,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
GenerateOceanGeometryData *gogd = userdata;
|
||||
GenerateOceanGeometryData *gogd = static_cast<GenerateOceanGeometryData *>(userdata);
|
||||
int x;
|
||||
|
||||
for (x = 0; x < gogd->res_x; x++) {
|
||||
|
@ -213,9 +212,9 @@ static void generate_ocean_geometry_polys(void *__restrict userdata,
|
|||
|
||||
static void generate_ocean_geometry_uvs(void *__restrict userdata,
|
||||
const int y,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
GenerateOceanGeometryData *gogd = userdata;
|
||||
GenerateOceanGeometryData *gogd = static_cast<GenerateOceanGeometryData *>(userdata);
|
||||
int x;
|
||||
|
||||
for (x = 0; x < gogd->res_x; x++) {
|
||||
|
@ -288,8 +287,8 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, co
|
|||
|
||||
/* add uvs */
|
||||
if (CustomData_number_of_layers(&result->ldata, CD_PROP_FLOAT2) < MAX_MTFACE) {
|
||||
gogd.mloopuvs = CustomData_add_layer_named(
|
||||
&result->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, NULL, polys_num * 4, "UVMap");
|
||||
gogd.mloopuvs = static_cast<float(*)[2]>(CustomData_add_layer_named(
|
||||
&result->ldata, CD_PROP_FLOAT2, CD_SET_DEFAULT, nullptr, polys_num * 4, "UVMap"));
|
||||
|
||||
if (gogd.mloopuvs) { /* unlikely to fail */
|
||||
gogd.ix = 1.0 / gogd.rx;
|
||||
|
@ -309,11 +308,11 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
|
|||
BKE_modifier_set_error(ctx->object, md, "Failed to allocate memory");
|
||||
return mesh;
|
||||
}
|
||||
int cfra_scene = (int)DEG_get_ctime(ctx->depsgraph);
|
||||
int cfra_scene = int(DEG_get_ctime(ctx->depsgraph));
|
||||
Object *ob = ctx->object;
|
||||
bool allocated_ocean = false;
|
||||
|
||||
Mesh *result = NULL;
|
||||
Mesh *result = nullptr;
|
||||
OceanResult ocr;
|
||||
|
||||
const int resolution = (ctx->flag & MOD_APPLY_RENDER) ? omd->resolution :
|
||||
|
@ -343,7 +342,7 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
|
|||
BKE_ocean_simulate_cache(omd->oceancache, cfra_scene);
|
||||
}
|
||||
else {
|
||||
/* omd->ocean is NULL on an original object (in contrast to an evaluated one).
|
||||
/* omd->ocean is nullptr on an original object (in contrast to an evaluated one).
|
||||
* We can create a new one, but we have to free it as well once we're done.
|
||||
* This function is only called on an original object when applying the modifier
|
||||
* using the 'Apply Modifier' button, and thus it is not called frequently for
|
||||
|
@ -356,7 +355,7 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
|
|||
result = generate_ocean_geometry(omd, mesh, resolution);
|
||||
}
|
||||
else if (omd->geometry_mode == MOD_OCEAN_GEOM_DISPLACE) {
|
||||
result = (Mesh *)BKE_id_copy_ex(NULL, &mesh->id, NULL, LIB_ID_COPY_LOCALIZE);
|
||||
result = (Mesh *)BKE_id_copy_ex(nullptr, &mesh->id, nullptr, LIB_ID_COPY_LOCALIZE);
|
||||
}
|
||||
|
||||
cfra_for_cache = cfra_scene;
|
||||
|
@ -372,17 +371,21 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
|
|||
const int polys_num = result->totpoly;
|
||||
const int loops_num = result->totloop;
|
||||
const MLoop *mloops = BKE_mesh_loops(result);
|
||||
MLoopCol *mloopcols = CustomData_add_layer_named(
|
||||
&result->ldata, CD_PROP_BYTE_COLOR, CD_SET_DEFAULT, NULL, loops_num, omd->foamlayername);
|
||||
MLoopCol *mloopcols = static_cast<MLoopCol *>(CustomData_add_layer_named(&result->ldata,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
CD_SET_DEFAULT,
|
||||
nullptr,
|
||||
loops_num,
|
||||
omd->foamlayername));
|
||||
|
||||
MLoopCol *mloopcols_spray = NULL;
|
||||
MLoopCol *mloopcols_spray = nullptr;
|
||||
if (omd->flag & MOD_OCEAN_GENERATE_SPRAY) {
|
||||
mloopcols_spray = CustomData_add_layer_named(&result->ldata,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
CD_SET_DEFAULT,
|
||||
NULL,
|
||||
loops_num,
|
||||
omd->spraylayername);
|
||||
mloopcols_spray = static_cast<MLoopCol *>(CustomData_add_layer_named(&result->ldata,
|
||||
CD_PROP_BYTE_COLOR,
|
||||
CD_SET_DEFAULT,
|
||||
nullptr,
|
||||
loops_num,
|
||||
omd->spraylayername));
|
||||
}
|
||||
|
||||
if (mloopcols) { /* unlikely to fail */
|
||||
|
@ -392,7 +395,7 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
|
|||
const MLoop *ml = &mloops[mp->loopstart];
|
||||
MLoopCol *mlcol = &mloopcols[mp->loopstart];
|
||||
|
||||
MLoopCol *mlcolspray = NULL;
|
||||
MLoopCol *mlcolspray = nullptr;
|
||||
if (omd->flag & MOD_OCEAN_GENERATE_SPRAY) {
|
||||
mlcolspray = &mloopcols_spray[mp->loopstart];
|
||||
}
|
||||
|
@ -470,7 +473,7 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
|
|||
|
||||
if (allocated_ocean) {
|
||||
BKE_ocean_free(omd->ocean);
|
||||
omd->ocean = NULL;
|
||||
omd->ocean = nullptr;
|
||||
}
|
||||
|
||||
# undef OCEAN_CO
|
||||
|
@ -478,7 +481,7 @@ static Mesh *doOcean(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mes
|
|||
return result;
|
||||
}
|
||||
#else /* WITH_OCEANSIM */
|
||||
static Mesh *doOcean(ModifierData *UNUSED(md), const ModifierEvalContext *UNUSED(ctx), Mesh *mesh)
|
||||
static Mesh *doOcean(ModifierData * /*md*/, const ModifierEvalContext * /*ctx*/, Mesh *mesh)
|
||||
{
|
||||
return mesh;
|
||||
}
|
||||
|
@ -489,7 +492,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
return doOcean(md, ctx, mesh);
|
||||
}
|
||||
// #define WITH_OCEANSIM
|
||||
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
#ifdef WITH_OCEANSIM
|
||||
|
@ -501,7 +504,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, ptr, "geometry_mode", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "geometry_mode", 0, nullptr, ICON_NONE);
|
||||
if (RNA_enum_get(ptr, "geometry_mode") == MOD_OCEAN_GEOM_GENERATE) {
|
||||
sub = uiLayoutColumn(col, true);
|
||||
uiItemR(sub, ptr, "repeat_x", 0, IFACE_("Repeat X"), ICON_NONE);
|
||||
|
@ -512,15 +515,15 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiItemR(sub, ptr, "viewport_resolution", 0, IFACE_("Resolution Viewport"), ICON_NONE);
|
||||
uiItemR(sub, ptr, "resolution", 0, IFACE_("Render"), ICON_NONE);
|
||||
|
||||
uiItemR(col, ptr, "time", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "time", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(col, ptr, "depth", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "size", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "spatial_size", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "depth", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "size", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "spatial_size", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(col, ptr, "random_seed", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "random_seed", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(col, ptr, "use_normals", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "use_normals", 0, nullptr, ICON_NONE);
|
||||
|
||||
modifier_panel_end(layout, ptr);
|
||||
|
||||
|
@ -530,20 +533,20 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
}
|
||||
|
||||
#ifdef WITH_OCEANSIM
|
||||
static void waves_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void waves_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *col, *sub;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, ptr, "wave_scale", 0, IFACE_("Scale"), ICON_NONE);
|
||||
uiItemR(col, ptr, "wave_scale_min", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "choppiness", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "wind_velocity", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "wave_scale_min", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "choppiness", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "wind_velocity", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
|
@ -552,24 +555,24 @@ static void waves_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
sub = uiLayoutColumn(col, false);
|
||||
uiLayoutSetActive(sub, RNA_float_get(ptr, "wave_alignment") > 0.0f);
|
||||
uiItemR(sub, ptr, "wave_direction", 0, IFACE_("Direction"), ICON_NONE);
|
||||
uiItemR(sub, ptr, "damping", 0, NULL, ICON_NONE);
|
||||
uiItemR(sub, ptr, "damping", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
static void foam_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
|
||||
static void foam_panel_draw_header(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
uiItemR(layout, ptr, "use_foam", 0, IFACE_("Foam"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void foam_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void foam_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
bool use_foam = RNA_boolean_get(ptr, "use_foam");
|
||||
|
||||
|
@ -581,12 +584,12 @@ static void foam_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiItemR(col, ptr, "foam_coverage", 0, IFACE_("Coverage"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void spray_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
|
||||
static void spray_panel_draw_header(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *row;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
bool use_foam = RNA_boolean_get(ptr, "use_foam");
|
||||
|
||||
|
@ -595,12 +598,12 @@ static void spray_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
|
|||
uiItemR(row, ptr, "use_spray", 0, CTX_IFACE_(BLT_I18NCONTEXT_ID_MESH, "Spray"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void spray_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void spray_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
bool use_foam = RNA_boolean_get(ptr, "use_foam");
|
||||
bool use_spray = RNA_boolean_get(ptr, "use_spray");
|
||||
|
@ -613,31 +616,31 @@ static void spray_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiItemR(col, ptr, "invert_spray", 0, IFACE_("Invert"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void spectrum_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void spectrum_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
int spectrum = RNA_enum_get(ptr, "spectrum");
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, ptr, "spectrum", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "spectrum", 0, nullptr, ICON_NONE);
|
||||
if (ELEM(spectrum, MOD_OCEAN_SPECTRUM_TEXEL_MARSEN_ARSLOE, MOD_OCEAN_SPECTRUM_JONSWAP)) {
|
||||
uiItemR(col, ptr, "sharpen_peak_jonswap", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "fetch_jonswap", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "sharpen_peak_jonswap", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "fetch_jonswap", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
static void bake_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void bake_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
|
@ -650,17 +653,17 @@ static void bake_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
"OBJECT_OT_ocean_bake",
|
||||
IFACE_("Delete Bake"),
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_EXEC_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
RNA_boolean_set(&op_ptr, "free", true);
|
||||
}
|
||||
else {
|
||||
uiItemO(layout, NULL, ICON_NONE, "OBJECT_OT_ocean_bake");
|
||||
uiItemO(layout, nullptr, ICON_NONE, "OBJECT_OT_ocean_bake");
|
||||
}
|
||||
|
||||
uiItemR(layout, ptr, "filepath", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "filepath", 0, nullptr, ICON_NONE);
|
||||
|
||||
col = uiLayoutColumn(layout, true);
|
||||
uiLayoutSetEnabled(col, !is_cached);
|
||||
|
@ -669,7 +672,7 @@ static void bake_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiLayoutSetActive(col, use_foam);
|
||||
uiItemR(col, ptr, "bake_foam_fade", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "bake_foam_fade", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
#endif /* WITH_OCEANSIM */
|
||||
|
||||
|
@ -677,24 +680,24 @@ static void panelRegister(ARegionType *region_type)
|
|||
{
|
||||
PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Ocean, panel_draw);
|
||||
#ifdef WITH_OCEANSIM
|
||||
modifier_subpanel_register(region_type, "waves", "Waves", NULL, waves_panel_draw, panel_type);
|
||||
modifier_subpanel_register(region_type, "waves", "Waves", nullptr, waves_panel_draw, panel_type);
|
||||
PanelType *foam_panel = modifier_subpanel_register(
|
||||
region_type, "foam", "", foam_panel_draw_header, foam_panel_draw, panel_type);
|
||||
modifier_subpanel_register(
|
||||
region_type, "spray", "", spray_panel_draw_header, spray_panel_draw, foam_panel);
|
||||
modifier_subpanel_register(
|
||||
region_type, "spectrum", "Spectrum", NULL, spectrum_panel_draw, panel_type);
|
||||
modifier_subpanel_register(region_type, "bake", "Bake", NULL, bake_panel_draw, panel_type);
|
||||
region_type, "spectrum", "Spectrum", nullptr, spectrum_panel_draw, panel_type);
|
||||
modifier_subpanel_register(region_type, "bake", "Bake", nullptr, bake_panel_draw, panel_type);
|
||||
#else
|
||||
UNUSED_VARS(panel_type);
|
||||
#endif /* WITH_OCEANSIM */
|
||||
}
|
||||
|
||||
static void blendRead(BlendDataReader *UNUSED(reader), ModifierData *md)
|
||||
static void blendRead(BlendDataReader * /*reader*/, ModifierData *md)
|
||||
{
|
||||
OceanModifierData *omd = (OceanModifierData *)md;
|
||||
omd->oceancache = NULL;
|
||||
omd->ocean = NULL;
|
||||
omd->oceancache = nullptr;
|
||||
omd->ocean = nullptr;
|
||||
}
|
||||
|
||||
ModifierTypeInfo modifierType_Ocean = {
|
||||
|
@ -708,25 +711,25 @@ ModifierTypeInfo modifierType_Ocean = {
|
|||
/*icon*/ ICON_MOD_OCEAN,
|
||||
|
||||
/*copyData*/ copyData,
|
||||
/*deformMatrices_DM*/ NULL,
|
||||
/*deformMatrices_DM*/ nullptr,
|
||||
|
||||
/*deformMatrices*/ NULL,
|
||||
/*deformVertsEM*/ NULL,
|
||||
/*deformMatricesEM*/ NULL,
|
||||
/*deformMatrices*/ nullptr,
|
||||
/*deformVertsEM*/ nullptr,
|
||||
/*deformMatricesEM*/ nullptr,
|
||||
/*modifyMesh*/ modifyMesh,
|
||||
/*modifyGeometrySet*/ NULL,
|
||||
/*modifyGeometrySet*/ nullptr,
|
||||
|
||||
/*initData*/ initData,
|
||||
/*requiredDataMask*/ requiredDataMask,
|
||||
/*freeData*/ freeData,
|
||||
/*isDisabled*/ NULL,
|
||||
/*updateDepsgraph*/ NULL,
|
||||
/*dependsOnTime*/ NULL,
|
||||
/*isDisabled*/ nullptr,
|
||||
/*updateDepsgraph*/ nullptr,
|
||||
/*dependsOnTime*/ nullptr,
|
||||
/*dependsOnNormals*/ dependsOnNormals,
|
||||
/*foreachIDLink*/ NULL,
|
||||
/*foreachTexLink*/ NULL,
|
||||
/*freeRuntimeData*/ NULL,
|
||||
/*foreachIDLink*/ nullptr,
|
||||
/*foreachTexLink*/ nullptr,
|
||||
/*freeRuntimeData*/ nullptr,
|
||||
/*panelRegister*/ panelRegister,
|
||||
/*blendWrite*/ NULL,
|
||||
/*blendWrite*/ nullptr,
|
||||
/*blendRead*/ blendRead,
|
||||
};
|
|
@ -61,7 +61,7 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma
|
|||
}
|
||||
}
|
||||
|
||||
static bool isDisabled(const struct Scene *scene, ModifierData *md, bool useRenderParams)
|
||||
static bool isDisabled(const Scene *scene, ModifierData *md, bool useRenderParams)
|
||||
{
|
||||
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
|
||||
ParticleSystem *psys;
|
||||
|
@ -76,15 +76,16 @@ static bool isDisabled(const struct Scene *scene, ModifierData *md, bool useRend
|
|||
return true;
|
||||
}
|
||||
|
||||
psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1);
|
||||
if (psys == NULL) {
|
||||
psys = static_cast<ParticleSystem *>(BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1));
|
||||
if (psys == nullptr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* If the psys modifier is disabled we cannot use its data.
|
||||
* First look up the psys modifier from the object, then check if it is enabled.
|
||||
*/
|
||||
for (ob_md = pimd->ob->modifiers.first; ob_md; ob_md = ob_md->next) {
|
||||
for (ob_md = static_cast<ModifierData *>(pimd->ob->modifiers.first); ob_md;
|
||||
ob_md = ob_md->next) {
|
||||
if (ob_md->type == eModifierType_ParticleSystem) {
|
||||
ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)ob_md;
|
||||
if (psmd->psys == psys) {
|
||||
|
@ -112,7 +113,7 @@ static bool isDisabled(const struct Scene *scene, ModifierData *md, bool useRend
|
|||
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
|
||||
{
|
||||
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
|
||||
if (pimd->ob != NULL) {
|
||||
if (pimd->ob != nullptr) {
|
||||
DEG_add_object_relation(
|
||||
ctx->node, pimd->ob, DEG_OB_COMP_TRANSFORM, "Particle Instance Modifier");
|
||||
DEG_add_object_relation(
|
||||
|
@ -166,10 +167,10 @@ static bool particle_skip(ParticleInstanceModifierData *pimd, ParticleSystem *ps
|
|||
totpart = psys->totpart + psys->totchild;
|
||||
|
||||
/* TODO: make randomization optional? */
|
||||
randp = (int)(psys_frand(psys, 3578 + p) * totpart) % totpart;
|
||||
randp = int(psys_frand(psys, 3578 + p) * totpart) % totpart;
|
||||
|
||||
minp = (int)(totpart * pimd->particle_offset) % (totpart + 1);
|
||||
maxp = (int)(totpart * (pimd->particle_offset + pimd->particle_amount)) % (totpart + 1);
|
||||
minp = int(totpart * pimd->particle_offset) % (totpart + 1);
|
||||
maxp = int(totpart * (pimd->particle_offset + pimd->particle_amount)) % (totpart + 1);
|
||||
|
||||
if (maxp > minp) {
|
||||
return randp < minp || randp >= maxp;
|
||||
|
@ -194,16 +195,16 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
{
|
||||
Mesh *result;
|
||||
ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *)md;
|
||||
struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
||||
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
||||
ParticleSimulationData sim;
|
||||
ParticleSystem *psys = NULL;
|
||||
ParticleData *pa = NULL;
|
||||
ParticleSystem *psys = nullptr;
|
||||
ParticleData *pa = nullptr;
|
||||
int totvert, totpoly, totloop, totedge;
|
||||
int maxvert, maxpoly, maxloop, maxedge, part_end = 0, part_start;
|
||||
int k, p, p_skip;
|
||||
short track = ctx->object->trackflag % 3, trackneg, axis = pimd->axis;
|
||||
float max_co = 0.0, min_co = 0.0, temp_co[3];
|
||||
float *size = NULL;
|
||||
float *size = nullptr;
|
||||
float spacemat[4][4];
|
||||
const bool use_parents = pimd->flag & eParticleInstanceFlag_Parents;
|
||||
const bool use_children = pimd->flag & eParticleInstanceFlag_Children;
|
||||
|
@ -212,13 +213,13 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
trackneg = ((ctx->object->trackflag > 2) ? 1 : 0);
|
||||
|
||||
if (pimd->ob == ctx->object) {
|
||||
pimd->ob = NULL;
|
||||
pimd->ob = nullptr;
|
||||
return mesh;
|
||||
}
|
||||
|
||||
if (pimd->ob) {
|
||||
psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1);
|
||||
if (psys == NULL || psys->totpart == 0) {
|
||||
psys = static_cast<ParticleSystem *>(BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1));
|
||||
if (psys == nullptr || psys->totpart == 0) {
|
||||
return mesh;
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +250,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
|
||||
if (pimd->flag & eParticleInstanceFlag_UseSize) {
|
||||
float *si;
|
||||
si = size = MEM_calloc_arrayN(part_end, sizeof(float), "particle size array");
|
||||
si = size = static_cast<float *>(MEM_calloc_arrayN(part_end, sizeof(float), __func__));
|
||||
|
||||
if (pimd->flag & eParticleInstanceFlag_Parents) {
|
||||
for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++, si++) {
|
||||
|
@ -261,7 +262,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
ChildParticle *cpa = psys->child;
|
||||
|
||||
for (p = 0; p < psys->totchild; p++, cpa++, si++) {
|
||||
*si = psys_get_child_size(psys, cpa, 0.0f, NULL);
|
||||
*si = psys_get_child_size(psys, cpa, 0.0f, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -322,17 +323,17 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
MPoly *mpoly = BKE_mesh_polys_for_write(result);
|
||||
MLoop *mloop = BKE_mesh_loops_for_write(result);
|
||||
|
||||
MLoopCol *mloopcols_index = CustomData_get_layer_named_for_write(
|
||||
&result->ldata, CD_PROP_BYTE_COLOR, pimd->index_layer_name, result->totloop);
|
||||
MLoopCol *mloopcols_value = CustomData_get_layer_named_for_write(
|
||||
&result->ldata, CD_PROP_BYTE_COLOR, pimd->value_layer_name, result->totloop);
|
||||
int *vert_part_index = NULL;
|
||||
float *vert_part_value = NULL;
|
||||
if (mloopcols_index != NULL) {
|
||||
vert_part_index = MEM_calloc_arrayN(maxvert, sizeof(int), "vertex part index array");
|
||||
MLoopCol *mloopcols_index = static_cast<MLoopCol *>(CustomData_get_layer_named_for_write(
|
||||
&result->ldata, CD_PROP_BYTE_COLOR, pimd->index_layer_name, result->totloop));
|
||||
MLoopCol *mloopcols_value = static_cast<MLoopCol *>(CustomData_get_layer_named_for_write(
|
||||
&result->ldata, CD_PROP_BYTE_COLOR, pimd->value_layer_name, result->totloop));
|
||||
int *vert_part_index = nullptr;
|
||||
float *vert_part_value = nullptr;
|
||||
if (mloopcols_index != nullptr) {
|
||||
vert_part_index = MEM_cnew_array<int>(maxvert, "vertex part index array");
|
||||
}
|
||||
if (mloopcols_value) {
|
||||
vert_part_value = MEM_calloc_arrayN(maxvert, sizeof(float), "vertex part value array");
|
||||
vert_part_value = MEM_cnew_array<float>(maxvert, "vertex part value array");
|
||||
}
|
||||
|
||||
for (p = part_start, p_skip = 0; p < part_end; p++) {
|
||||
|
@ -352,10 +353,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
|
||||
CustomData_copy_data(&mesh->vdata, &result->vdata, k, vindex, 1);
|
||||
|
||||
if (vert_part_index != NULL) {
|
||||
if (vert_part_index != nullptr) {
|
||||
vert_part_index[vindex] = p;
|
||||
}
|
||||
if (vert_part_value != NULL) {
|
||||
if (vert_part_value != nullptr) {
|
||||
vert_part_value[vindex] = p_random;
|
||||
}
|
||||
|
||||
|
@ -495,12 +496,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
ml->v = inML->v + (p_skip * totvert);
|
||||
ml->e = inML->e + (p_skip * totedge);
|
||||
const int ml_index = (ml - mloop);
|
||||
if (mloopcols_index != NULL) {
|
||||
if (mloopcols_index != nullptr) {
|
||||
const int part_index = vert_part_index[ml->v];
|
||||
store_float_in_vcol(&mloopcols_index[ml_index],
|
||||
(float)part_index / (float)(psys->totpart - 1));
|
||||
float(part_index) / float(psys->totpart - 1));
|
||||
}
|
||||
if (mloopcols_value != NULL) {
|
||||
if (mloopcols_value != nullptr) {
|
||||
const float part_value = vert_part_value[ml->v];
|
||||
store_float_in_vcol(&mloopcols_value[ml_index], part_value);
|
||||
}
|
||||
|
@ -522,7 +523,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
return result;
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *row;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -535,7 +536,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "object", 0, nullptr, ICON_NONE);
|
||||
if (!RNA_pointer_is_null(&particle_obj_ptr)) {
|
||||
uiItemPointerR(layout,
|
||||
ptr,
|
||||
|
@ -552,14 +553,14 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiItemS(layout);
|
||||
|
||||
row = uiLayoutRowWithHeading(layout, true, IFACE_("Create Instances"));
|
||||
uiItemR(row, ptr, "use_normal", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_children", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_size", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_normal", toggles_flag, nullptr, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_children", toggles_flag, nullptr, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_size", toggles_flag, nullptr, ICON_NONE);
|
||||
|
||||
row = uiLayoutRowWithHeading(layout, true, IFACE_("Show"));
|
||||
uiItemR(row, ptr, "show_alive", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "show_dead", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "show_unborn", toggles_flag, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "show_alive", toggles_flag, nullptr, ICON_NONE);
|
||||
uiItemR(row, ptr, "show_dead", toggles_flag, nullptr, ICON_NONE);
|
||||
uiItemR(row, ptr, "show_unborn", toggles_flag, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "particle_amount", 0, IFACE_("Amount"), ICON_NONE);
|
||||
uiItemR(layout, ptr, "particle_offset", 0, IFACE_("Offset"), ICON_NONE);
|
||||
|
@ -568,21 +569,21 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiItemR(layout, ptr, "space", 0, IFACE_("Coordinate Space"), ICON_NONE);
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
|
||||
|
||||
modifier_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void path_panel_draw_header(const bContext *UNUSED(C), Panel *panel)
|
||||
static void path_panel_draw_header(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
|
||||
uiItemR(layout, ptr, "use_path", 0, IFACE_("Create Along Paths"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void path_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void path_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -595,16 +596,16 @@ static void path_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_path"));
|
||||
|
||||
col = uiLayoutColumn(layout, true);
|
||||
uiItemR(col, ptr, "position", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "position", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "random_position", UI_ITEM_R_SLIDER, IFACE_("Random"), ICON_NONE);
|
||||
col = uiLayoutColumn(layout, true);
|
||||
uiItemR(col, ptr, "rotation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "rotation", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "random_rotation", UI_ITEM_R_SLIDER, IFACE_("Random"), ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "use_preserve_shape", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_preserve_shape", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
static void layers_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void layers_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -629,7 +630,8 @@ static void panelRegister(ARegionType *region_type)
|
|||
region_type, eModifierType_ParticleInstance, panel_draw);
|
||||
modifier_subpanel_register(
|
||||
region_type, "paths", "", path_panel_draw_header, path_panel_draw, panel_type);
|
||||
modifier_subpanel_register(region_type, "layers", "Layers", NULL, layers_panel_draw, panel_type);
|
||||
modifier_subpanel_register(
|
||||
region_type, "layers", "Layers", nullptr, layers_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
ModifierTypeInfo modifierType_ParticleInstance = {
|
||||
|
@ -644,24 +646,24 @@ ModifierTypeInfo modifierType_ParticleInstance = {
|
|||
|
||||
/*copyData*/ BKE_modifier_copydata_generic,
|
||||
|
||||
/*deformVerts*/ NULL,
|
||||
/*deformMatrices*/ NULL,
|
||||
/*deformVertsEM*/ NULL,
|
||||
/*deformMatricesEM*/ NULL,
|
||||
/*deformVerts*/ nullptr,
|
||||
/*deformMatrices*/ nullptr,
|
||||
/*deformVertsEM*/ nullptr,
|
||||
/*deformMatricesEM*/ nullptr,
|
||||
/*modifyMesh*/ modifyMesh,
|
||||
/*modifyGeometrySet*/ NULL,
|
||||
/*modifyGeometrySet*/ nullptr,
|
||||
|
||||
/*initData*/ initData,
|
||||
/*requiredDataMask*/ requiredDataMask,
|
||||
/*freeData*/ NULL,
|
||||
/*freeData*/ nullptr,
|
||||
/*isDisabled*/ isDisabled,
|
||||
/*updateDepsgraph*/ updateDepsgraph,
|
||||
/*dependsOnTime*/ NULL,
|
||||
/*dependsOnNormals*/ NULL,
|
||||
/*dependsOnTime*/ nullptr,
|
||||
/*dependsOnNormals*/ nullptr,
|
||||
/*foreachIDLink*/ foreachIDLink,
|
||||
/*foreachTexLink*/ NULL,
|
||||
/*freeRuntimeData*/ NULL,
|
||||
/*foreachTexLink*/ nullptr,
|
||||
/*freeRuntimeData*/ nullptr,
|
||||
/*panelRegister*/ panelRegister,
|
||||
/*blendWrite*/ NULL,
|
||||
/*blendRead*/ NULL,
|
||||
/*blendWrite*/ nullptr,
|
||||
/*blendRead*/ nullptr,
|
||||
};
|
|
@ -7,10 +7,9 @@
|
|||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
|
@ -36,8 +35,8 @@
|
|||
#include "MOD_modifiertypes.h"
|
||||
#include "MOD_ui_common.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WITH_MOD_REMESH
|
||||
# include "BLI_math_vector.h"
|
||||
|
@ -60,14 +59,14 @@ static void init_dualcon_mesh(DualConInput *input, Mesh *mesh)
|
|||
{
|
||||
memset(input, 0, sizeof(DualConInput));
|
||||
|
||||
input->co = (void *)BKE_mesh_vert_positions(mesh);
|
||||
input->co = (DualConCo)BKE_mesh_vert_positions(mesh);
|
||||
input->co_stride = sizeof(float[3]);
|
||||
input->totco = mesh->totvert;
|
||||
|
||||
input->mloop = (void *)BKE_mesh_loops(mesh);
|
||||
input->mloop = (DualConLoop)BKE_mesh_loops(mesh);
|
||||
input->loop_stride = sizeof(MLoop);
|
||||
|
||||
input->looptri = (void *)BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
input->looptri = (DualConTri)BKE_mesh_runtime_looptri_ensure(mesh);
|
||||
input->tri_stride = sizeof(MLoopTri);
|
||||
input->tottri = BKE_mesh_runtime_looptri_len(mesh);
|
||||
|
||||
|
@ -90,8 +89,8 @@ static void *dualcon_alloc_output(int totvert, int totquad)
|
|||
{
|
||||
DualConOutput *output;
|
||||
|
||||
if (!(output = MEM_callocN(sizeof(DualConOutput), "DualConOutput"))) {
|
||||
return NULL;
|
||||
if (!(output = MEM_cnew<DualConOutput>(__func__))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
output->mesh = BKE_mesh_new_nomain(totvert, 0, 0, 4 * totquad, totquad);
|
||||
|
@ -104,7 +103,7 @@ static void *dualcon_alloc_output(int totvert, int totquad)
|
|||
|
||||
static void dualcon_add_vert(void *output_v, const float co[3])
|
||||
{
|
||||
DualConOutput *output = output_v;
|
||||
DualConOutput *output = static_cast<DualConOutput *>(output_v);
|
||||
|
||||
BLI_assert(output->curvert < output->mesh->totvert);
|
||||
|
||||
|
@ -114,7 +113,7 @@ static void dualcon_add_vert(void *output_v, const float co[3])
|
|||
|
||||
static void dualcon_add_quad(void *output_v, const int vert_indices[4])
|
||||
{
|
||||
DualConOutput *output = output_v;
|
||||
DualConOutput *output = static_cast<DualConOutput *>(output_v);
|
||||
Mesh *mesh = output->mesh;
|
||||
int i;
|
||||
|
||||
|
@ -133,25 +132,25 @@ static void dualcon_add_quad(void *output_v, const int vert_indices[4])
|
|||
output->curface++;
|
||||
}
|
||||
|
||||
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx), Mesh *mesh)
|
||||
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext * /*ctx*/, Mesh *mesh)
|
||||
{
|
||||
RemeshModifierData *rmd;
|
||||
DualConOutput *output;
|
||||
DualConInput input;
|
||||
Mesh *result;
|
||||
DualConFlags flags = 0;
|
||||
DualConMode mode = 0;
|
||||
DualConFlags flags = DualConFlags(0);
|
||||
DualConMode mode = DualConMode(0);
|
||||
|
||||
rmd = (RemeshModifierData *)md;
|
||||
|
||||
if (rmd->mode == MOD_REMESH_VOXEL) {
|
||||
/* OpenVDB modes. */
|
||||
if (rmd->voxel_size == 0.0f) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
result = BKE_mesh_remesh_voxel(mesh, rmd->voxel_size, rmd->adaptivity, 0.0f);
|
||||
if (result == NULL) {
|
||||
return NULL;
|
||||
if (result == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -159,7 +158,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
|
|||
init_dualcon_mesh(&input, mesh);
|
||||
|
||||
if (rmd->flag & MOD_REMESH_FLOOD_FILL) {
|
||||
flags |= DUALCON_FLOOD_FILL;
|
||||
flags = DualConFlags(flags | DUALCON_FLOOD_FILL);
|
||||
}
|
||||
|
||||
switch (rmd->mode) {
|
||||
|
@ -182,16 +181,16 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
|
|||
* This was identified when changing the task isolation's during T76553. */
|
||||
static ThreadMutex dualcon_mutex = BLI_MUTEX_INITIALIZER;
|
||||
BLI_mutex_lock(&dualcon_mutex);
|
||||
output = dualcon(&input,
|
||||
dualcon_alloc_output,
|
||||
dualcon_add_vert,
|
||||
dualcon_add_quad,
|
||||
flags,
|
||||
mode,
|
||||
rmd->threshold,
|
||||
rmd->hermite_num,
|
||||
rmd->scale,
|
||||
rmd->depth);
|
||||
output = static_cast<DualConOutput *>(dualcon(&input,
|
||||
dualcon_alloc_output,
|
||||
dualcon_add_vert,
|
||||
dualcon_add_quad,
|
||||
flags,
|
||||
mode,
|
||||
rmd->threshold,
|
||||
rmd->hermite_num,
|
||||
rmd->scale,
|
||||
rmd->depth));
|
||||
BLI_mutex_unlock(&dualcon_mutex);
|
||||
|
||||
result = output->mesh;
|
||||
|
@ -215,16 +214,14 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *UNUSED(ctx)
|
|||
|
||||
#else /* !WITH_MOD_REMESH */
|
||||
|
||||
static Mesh *modifyMesh(ModifierData *UNUSED(md),
|
||||
const ModifierEvalContext *UNUSED(ctx),
|
||||
Mesh *mesh)
|
||||
static Mesh *modifyMesh(ModifierData * /*md*/, const ModifierEvalContext * /*ctx*/, Mesh *mesh)
|
||||
{
|
||||
return mesh;
|
||||
}
|
||||
|
||||
#endif /* !WITH_MOD_REMESH */
|
||||
|
||||
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
#ifdef WITH_MOD_REMESH
|
||||
|
@ -235,29 +232,29 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
int mode = RNA_enum_get(ptr, "mode");
|
||||
|
||||
uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "mode", UI_ITEM_R_EXPAND, nullptr, ICON_NONE);
|
||||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
if (mode == MOD_REMESH_VOXEL) {
|
||||
uiItemR(col, ptr, "voxel_size", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "adaptivity", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "voxel_size", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "adaptivity", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
else {
|
||||
uiItemR(col, ptr, "octree_depth", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "scale", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "octree_depth", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "scale", 0, nullptr, ICON_NONE);
|
||||
|
||||
if (mode == MOD_REMESH_SHARP_FEATURES) {
|
||||
uiItemR(col, ptr, "sharpness", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "sharpness", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
uiItemR(layout, ptr, "use_remove_disconnected", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_remove_disconnected", 0, nullptr, ICON_NONE);
|
||||
row = uiLayoutRow(layout, false);
|
||||
uiLayoutSetActive(row, RNA_boolean_get(ptr, "use_remove_disconnected"));
|
||||
uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "threshold", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
uiItemR(layout, ptr, "use_smooth_shade", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_smooth_shade", 0, nullptr, ICON_NONE);
|
||||
|
||||
modifier_panel_end(layout, ptr);
|
||||
|
||||
|
@ -283,24 +280,24 @@ ModifierTypeInfo modifierType_Remesh = {
|
|||
|
||||
/*copyData*/ BKE_modifier_copydata_generic,
|
||||
|
||||
/*deformVerts*/ NULL,
|
||||
/*deformMatrices*/ NULL,
|
||||
/*deformVertsEM*/ NULL,
|
||||
/*deformMatricesEM*/ NULL,
|
||||
/*deformVerts*/ nullptr,
|
||||
/*deformMatrices*/ nullptr,
|
||||
/*deformVertsEM*/ nullptr,
|
||||
/*deformMatricesEM*/ nullptr,
|
||||
/*modifyMesh*/ modifyMesh,
|
||||
/*modifyGeometrySet*/ NULL,
|
||||
/*modifyGeometrySet*/ nullptr,
|
||||
|
||||
/*initData*/ initData,
|
||||
/*requiredDataMask*/ NULL,
|
||||
/*freeData*/ NULL,
|
||||
/*isDisabled*/ NULL,
|
||||
/*updateDepsgraph*/ NULL,
|
||||
/*dependsOnTime*/ NULL,
|
||||
/*dependsOnNormals*/ NULL,
|
||||
/*foreachIDLink*/ NULL,
|
||||
/*foreachTexLink*/ NULL,
|
||||
/*freeRuntimeData*/ NULL,
|
||||
/*requiredDataMask*/ nullptr,
|
||||
/*freeData*/ nullptr,
|
||||
/*isDisabled*/ nullptr,
|
||||
/*updateDepsgraph*/ nullptr,
|
||||
/*dependsOnTime*/ nullptr,
|
||||
/*dependsOnNormals*/ nullptr,
|
||||
/*foreachIDLink*/ nullptr,
|
||||
/*foreachTexLink*/ nullptr,
|
||||
/*freeRuntimeData*/ nullptr,
|
||||
/*panelRegister*/ panelRegister,
|
||||
/*blendWrite*/ NULL,
|
||||
/*blendRead*/ NULL,
|
||||
/*blendWrite*/ nullptr,
|
||||
/*blendRead*/ nullptr,
|
||||
};
|
|
@ -5,7 +5,7 @@
|
|||
* \ingroup modifiers
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
|||
#include "MOD_modifiertypes.h"
|
||||
#include "MOD_ui_common.h"
|
||||
|
||||
#include "MOD_solidify_util.h"
|
||||
#include "MOD_solidify_util.hh"
|
||||
|
||||
static bool dependsOnNormals(ModifierData *md)
|
||||
{
|
||||
|
@ -78,7 +78,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
return mesh;
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *sub, *row, *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -91,32 +91,32 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, ptr, "solidify_mode", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "solidify_mode", 0, nullptr, ICON_NONE);
|
||||
|
||||
if (solidify_mode == MOD_SOLIDIFY_MODE_NONMANIFOLD) {
|
||||
uiItemR(layout, ptr, "nonmanifold_thickness_mode", 0, IFACE_("Thickness Mode"), ICON_NONE);
|
||||
uiItemR(layout, ptr, "nonmanifold_boundary_mode", 0, IFACE_("Boundary"), ICON_NONE);
|
||||
}
|
||||
|
||||
uiItemR(layout, ptr, "thickness", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "thickness", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "offset", 0, nullptr, ICON_NONE);
|
||||
|
||||
if (solidify_mode == MOD_SOLIDIFY_MODE_NONMANIFOLD) {
|
||||
uiItemR(layout, ptr, "nonmanifold_merge_threshold", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "nonmanifold_merge_threshold", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
else {
|
||||
uiItemR(layout, ptr, "use_even_offset", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_even_offset", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
col = uiLayoutColumnWithHeading(layout, false, CTX_IFACE_(BLT_I18NCONTEXT_ID_MESH, "Rim"));
|
||||
uiItemR(col, ptr, "use_rim", 0, IFACE_("Fill"), ICON_NONE);
|
||||
sub = uiLayoutColumn(col, false);
|
||||
uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_rim"));
|
||||
uiItemR(sub, ptr, "use_rim_only", 0, NULL, ICON_NONE);
|
||||
uiItemR(sub, ptr, "use_rim_only", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL);
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr);
|
||||
row = uiLayoutRow(layout, false);
|
||||
uiLayoutSetActive(row, has_vertex_group);
|
||||
uiItemR(row, ptr, "thickness_vertex_group", 0, IFACE_("Factor"), ICON_NONE);
|
||||
|
@ -124,13 +124,13 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
if (solidify_mode == MOD_SOLIDIFY_MODE_NONMANIFOLD) {
|
||||
row = uiLayoutRow(layout, false);
|
||||
uiLayoutSetActive(row, has_vertex_group);
|
||||
uiItemR(row, ptr, "use_flat_faces", 0, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_flat_faces", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
modifier_panel_end(layout, ptr);
|
||||
}
|
||||
|
||||
static void normals_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void normals_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -149,7 +149,7 @@ static void normals_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
}
|
||||
}
|
||||
|
||||
static void materials_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void materials_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -159,14 +159,14 @@ static void materials_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, ptr, "material_offset", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "material_offset", 0, nullptr, ICON_NONE);
|
||||
col = uiLayoutColumn(layout, true);
|
||||
uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_rim"));
|
||||
uiItemR(
|
||||
col, ptr, "material_offset_rim", 0, CTX_IFACE_(BLT_I18NCONTEXT_ID_MESH, "Rim"), ICON_NONE);
|
||||
}
|
||||
|
||||
static void edge_data_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void edge_data_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
|
@ -184,10 +184,10 @@ static void edge_data_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiItemR(col, ptr, "edge_crease_outer", 0, IFACE_("Outer"), ICON_NONE);
|
||||
uiItemR(col, ptr, "edge_crease_rim", 0, CTX_IFACE_(BLT_I18NCONTEXT_ID_MESH, "Rim"), ICON_NONE);
|
||||
}
|
||||
uiItemR(layout, ptr, "bevel_convex", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "bevel_convex", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
static void clamp_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void clamp_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *row, *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -198,13 +198,13 @@ static void clamp_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, ptr, "thickness_clamp", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "thickness_clamp", 0, nullptr, ICON_NONE);
|
||||
row = uiLayoutRow(col, false);
|
||||
uiLayoutSetActive(row, RNA_float_get(ptr, "thickness_clamp") > 0.0f);
|
||||
uiItemR(row, ptr, "use_thickness_angle_clamp", 0, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "use_thickness_angle_clamp", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
static void vertex_group_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void vertex_group_panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -230,17 +230,17 @@ static void panelRegister(ARegionType *region_type)
|
|||
{
|
||||
PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Solidify, panel_draw);
|
||||
modifier_subpanel_register(
|
||||
region_type, "normals", "Normals", NULL, normals_panel_draw, panel_type);
|
||||
region_type, "normals", "Normals", nullptr, normals_panel_draw, panel_type);
|
||||
modifier_subpanel_register(
|
||||
region_type, "materials", "Materials", NULL, materials_panel_draw, panel_type);
|
||||
region_type, "materials", "Materials", nullptr, materials_panel_draw, panel_type);
|
||||
modifier_subpanel_register(
|
||||
region_type, "edge_data", "Edge Data", NULL, edge_data_panel_draw, panel_type);
|
||||
region_type, "edge_data", "Edge Data", nullptr, edge_data_panel_draw, panel_type);
|
||||
modifier_subpanel_register(
|
||||
region_type, "clamp", "Thickness Clamp", NULL, clamp_panel_draw, panel_type);
|
||||
region_type, "clamp", "Thickness Clamp", nullptr, clamp_panel_draw, panel_type);
|
||||
modifier_subpanel_register(region_type,
|
||||
"vertex_groups",
|
||||
"Output Vertex Groups",
|
||||
NULL,
|
||||
nullptr,
|
||||
vertex_group_panel_draw,
|
||||
panel_type);
|
||||
}
|
||||
|
@ -259,24 +259,24 @@ ModifierTypeInfo modifierType_Solidify = {
|
|||
|
||||
/*copyData*/ BKE_modifier_copydata_generic,
|
||||
|
||||
/*deformVerts*/ NULL,
|
||||
/*deformMatrices*/ NULL,
|
||||
/*deformVertsEM*/ NULL,
|
||||
/*deformMatricesEM*/ NULL,
|
||||
/*deformVerts*/ nullptr,
|
||||
/*deformMatrices*/ nullptr,
|
||||
/*deformVertsEM*/ nullptr,
|
||||
/*deformMatricesEM*/ nullptr,
|
||||
/*modifyMesh*/ modifyMesh,
|
||||
/*modifyGeometrySet*/ NULL,
|
||||
/*modifyGeometrySet*/ nullptr,
|
||||
|
||||
/*initData*/ initData,
|
||||
/*requiredDataMask*/ requiredDataMask,
|
||||
/*freeData*/ NULL,
|
||||
/*isDisabled*/ NULL,
|
||||
/*updateDepsgraph*/ NULL,
|
||||
/*dependsOnTime*/ NULL,
|
||||
/*freeData*/ nullptr,
|
||||
/*isDisabled*/ nullptr,
|
||||
/*updateDepsgraph*/ nullptr,
|
||||
/*dependsOnTime*/ nullptr,
|
||||
/*dependsOnNormals*/ dependsOnNormals,
|
||||
/*foreachIDLink*/ NULL,
|
||||
/*foreachTexLink*/ NULL,
|
||||
/*freeRuntimeData*/ NULL,
|
||||
/*foreachIDLink*/ nullptr,
|
||||
/*foreachTexLink*/ nullptr,
|
||||
/*freeRuntimeData*/ nullptr,
|
||||
/*panelRegister*/ panelRegister,
|
||||
/*blendWrite*/ NULL,
|
||||
/*blendRead*/ NULL,
|
||||
/*blendWrite*/ nullptr,
|
||||
/*blendRead*/ nullptr,
|
||||
};
|
|
@ -21,7 +21,7 @@
|
|||
#include "BKE_particle.h"
|
||||
|
||||
#include "MOD_modifiertypes.h"
|
||||
#include "MOD_solidify_util.h" /* own include */
|
||||
#include "MOD_solidify_util.hh" /* own include */
|
||||
#include "MOD_util.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
@ -38,10 +38,10 @@
|
|||
/* *** derived mesh high quality normal calculation function *** */
|
||||
/* could be exposed for other functions to use */
|
||||
|
||||
typedef struct EdgeFaceRef {
|
||||
struct EdgeFaceRef {
|
||||
int p1; /* init as -1 */
|
||||
int p2;
|
||||
} EdgeFaceRef;
|
||||
};
|
||||
|
||||
BLI_INLINE bool edgeref_is_init(const EdgeFaceRef *edge_ref)
|
||||
{
|
||||
|
@ -73,8 +73,7 @@ static void mesh_calc_hq_normal(Mesh *mesh,
|
|||
const MPoly *mp = mpoly;
|
||||
|
||||
{
|
||||
EdgeFaceRef *edge_ref_array = MEM_calloc_arrayN(
|
||||
(size_t)edges_num, sizeof(EdgeFaceRef), "Edge Connectivity");
|
||||
EdgeFaceRef *edge_ref_array = MEM_cnew_array<EdgeFaceRef>((size_t)edges_num, __func__);
|
||||
EdgeFaceRef *edge_ref;
|
||||
float edge_normal[3];
|
||||
|
||||
|
@ -156,10 +155,10 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
Mesh *result;
|
||||
const SolidifyModifierData *smd = (SolidifyModifierData *)md;
|
||||
|
||||
const uint verts_num = (uint)mesh->totvert;
|
||||
const uint edges_num = (uint)mesh->totedge;
|
||||
const uint polys_num = (uint)mesh->totpoly;
|
||||
const uint loops_num = (uint)mesh->totloop;
|
||||
const uint verts_num = uint(mesh->totvert);
|
||||
const uint edges_num = uint(mesh->totedge);
|
||||
const uint polys_num = uint(mesh->totpoly);
|
||||
const uint loops_num = uint(mesh->totloop);
|
||||
uint newLoops = 0, newPolys = 0, newEdges = 0, newVerts = 0, rimVerts = 0;
|
||||
|
||||
/* Only use material offsets if we have 2 or more materials. */
|
||||
|
@ -169,20 +168,19 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
|
||||
/* use for edges */
|
||||
/* over-alloc new_vert_arr, old_vert_arr */
|
||||
uint *new_vert_arr = NULL;
|
||||
uint *new_vert_arr = nullptr;
|
||||
STACK_DECLARE(new_vert_arr);
|
||||
|
||||
uint *new_edge_arr = NULL;
|
||||
uint *new_edge_arr = nullptr;
|
||||
STACK_DECLARE(new_edge_arr);
|
||||
|
||||
uint *old_vert_arr = MEM_calloc_arrayN(
|
||||
verts_num, sizeof(*old_vert_arr), "old_vert_arr in solidify");
|
||||
uint *old_vert_arr = MEM_cnew_array<uint>(verts_num, "old_vert_arr in solidify");
|
||||
|
||||
uint *edge_users = NULL;
|
||||
int *edge_order = NULL;
|
||||
uint *edge_users = nullptr;
|
||||
int *edge_order = nullptr;
|
||||
|
||||
float(*vert_nors)[3] = NULL;
|
||||
const float(*poly_nors)[3] = NULL;
|
||||
float(*vert_nors)[3] = nullptr;
|
||||
const float(*poly_nors)[3] = nullptr;
|
||||
|
||||
const bool need_poly_normals = (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) ||
|
||||
(smd->flag & MOD_SOLIDIFY_EVEN) ||
|
||||
|
@ -236,12 +234,13 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
#define INVALID_UNUSED ((uint)-1)
|
||||
#define INVALID_PAIR ((uint)-2)
|
||||
|
||||
new_vert_arr = MEM_malloc_arrayN(verts_num, 2 * sizeof(*new_vert_arr), __func__);
|
||||
new_edge_arr = MEM_malloc_arrayN(
|
||||
((edges_num * 2) + verts_num), sizeof(*new_edge_arr), __func__);
|
||||
new_vert_arr = static_cast<uint *>(
|
||||
MEM_malloc_arrayN(verts_num, 2 * sizeof(*new_vert_arr), __func__));
|
||||
new_edge_arr = static_cast<uint *>(
|
||||
MEM_malloc_arrayN(((edges_num * 2) + verts_num), sizeof(*new_edge_arr), __func__));
|
||||
|
||||
edge_users = MEM_malloc_arrayN(edges_num, sizeof(*edge_users), "solid_mod edges");
|
||||
edge_order = MEM_malloc_arrayN(edges_num, sizeof(*edge_order), "solid_mod order");
|
||||
edge_users = static_cast<uint *>(MEM_malloc_arrayN(edges_num, sizeof(*edge_users), __func__));
|
||||
edge_order = static_cast<int *>(MEM_malloc_arrayN(edges_num, sizeof(*edge_order), __func__));
|
||||
|
||||
/* save doing 2 loops here... */
|
||||
#if 0
|
||||
|
@ -317,7 +316,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
#endif
|
||||
|
||||
if (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) {
|
||||
vert_nors = MEM_calloc_arrayN(verts_num, sizeof(float[3]), "mod_solid_vno_hq");
|
||||
vert_nors = static_cast<float(*)[3]>(MEM_calloc_arrayN(verts_num, sizeof(float[3]), __func__));
|
||||
mesh_calc_hq_normal(mesh,
|
||||
poly_nors,
|
||||
vert_nors
|
||||
|
@ -329,11 +328,11 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
}
|
||||
|
||||
result = BKE_mesh_new_nomain_from_template(mesh,
|
||||
(int)((verts_num * stride) + newVerts),
|
||||
(int)((edges_num * stride) + newEdges + rimVerts),
|
||||
int((verts_num * stride) + newVerts),
|
||||
int((edges_num * stride) + newEdges + rimVerts),
|
||||
0,
|
||||
(int)((loops_num * stride) + newLoops),
|
||||
(int)((polys_num * stride) + newPolys));
|
||||
int((loops_num * stride) + newLoops),
|
||||
int((polys_num * stride) + newPolys));
|
||||
|
||||
float(*vert_positions)[3] = BKE_mesh_vert_positions_for_write(result);
|
||||
MEdge *medge = BKE_mesh_edges_for_write(result);
|
||||
|
@ -341,35 +340,35 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
MLoop *mloop = BKE_mesh_loops_for_write(result);
|
||||
|
||||
if (do_shell) {
|
||||
CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, (int)verts_num);
|
||||
CustomData_copy_data(&mesh->vdata, &result->vdata, 0, (int)verts_num, (int)verts_num);
|
||||
CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, int(verts_num));
|
||||
CustomData_copy_data(&mesh->vdata, &result->vdata, 0, int(verts_num), int(verts_num));
|
||||
|
||||
CustomData_copy_data(&mesh->edata, &result->edata, 0, 0, (int)edges_num);
|
||||
CustomData_copy_data(&mesh->edata, &result->edata, 0, (int)edges_num, (int)edges_num);
|
||||
CustomData_copy_data(&mesh->edata, &result->edata, 0, 0, int(edges_num));
|
||||
CustomData_copy_data(&mesh->edata, &result->edata, 0, int(edges_num), int(edges_num));
|
||||
|
||||
CustomData_copy_data(&mesh->ldata, &result->ldata, 0, 0, (int)loops_num);
|
||||
CustomData_copy_data(&mesh->ldata, &result->ldata, 0, 0, int(loops_num));
|
||||
/* DO NOT copy here the 'copied' part of loop data, we want to reverse loops
|
||||
* (so that winding of copied face get reversed, so that normals get reversed
|
||||
* and point in expected direction...).
|
||||
* If we also copy data here, then this data get overwritten
|
||||
* (and allocated memory becomes a memory leak). */
|
||||
|
||||
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)polys_num);
|
||||
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, (int)polys_num, (int)polys_num);
|
||||
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, int(polys_num));
|
||||
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, int(polys_num), int(polys_num));
|
||||
}
|
||||
else {
|
||||
int i, j;
|
||||
CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, (int)verts_num);
|
||||
for (i = 0, j = (int)verts_num; i < verts_num; i++) {
|
||||
CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, int(verts_num));
|
||||
for (i = 0, j = int(verts_num); i < verts_num; i++) {
|
||||
if (old_vert_arr[i] != INVALID_UNUSED) {
|
||||
CustomData_copy_data(&mesh->vdata, &result->vdata, i, j, 1);
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
CustomData_copy_data(&mesh->edata, &result->edata, 0, 0, (int)edges_num);
|
||||
CustomData_copy_data(&mesh->edata, &result->edata, 0, 0, int(edges_num));
|
||||
|
||||
for (i = 0, j = (int)edges_num; i < edges_num; i++) {
|
||||
for (i = 0, j = int(edges_num); i < edges_num; i++) {
|
||||
if (!ELEM(edge_users[i], INVALID_UNUSED, INVALID_PAIR)) {
|
||||
MEdge *ed_src, *ed_dst;
|
||||
CustomData_copy_data(&mesh->edata, &result->edata, i, j, 1);
|
||||
|
@ -383,14 +382,14 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
}
|
||||
|
||||
/* will be created later */
|
||||
CustomData_copy_data(&mesh->ldata, &result->ldata, 0, 0, (int)loops_num);
|
||||
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, (int)polys_num);
|
||||
CustomData_copy_data(&mesh->ldata, &result->ldata, 0, 0, int(loops_num));
|
||||
CustomData_copy_data(&mesh->pdata, &result->pdata, 0, 0, int(polys_num));
|
||||
}
|
||||
|
||||
float *result_edge_bweight = NULL;
|
||||
float *result_edge_bweight = nullptr;
|
||||
if (do_bevel_convex) {
|
||||
result_edge_bweight = CustomData_add_layer(
|
||||
&result->edata, CD_BWEIGHT, CD_SET_DEFAULT, NULL, result->totedge);
|
||||
result_edge_bweight = static_cast<float *>(CustomData_add_layer(
|
||||
&result->edata, CD_BWEIGHT, CD_SET_DEFAULT, nullptr, result->totedge));
|
||||
}
|
||||
|
||||
/* initializes: (i_end, do_shell_align, mv). */
|
||||
|
@ -483,17 +482,17 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
float ofs_new_vgroup;
|
||||
|
||||
/* for clamping */
|
||||
float *vert_lens = NULL;
|
||||
float *vert_angs = NULL;
|
||||
float *vert_lens = nullptr;
|
||||
float *vert_angs = nullptr;
|
||||
const float offset = fabsf(smd->offset) * smd->offset_clamp;
|
||||
const float offset_sq = offset * offset;
|
||||
|
||||
/* for bevel weight */
|
||||
float *edge_angs = NULL;
|
||||
float *edge_angs = nullptr;
|
||||
|
||||
if (do_clamp) {
|
||||
vert_lens = MEM_malloc_arrayN(verts_num, sizeof(float), "vert_lens");
|
||||
copy_vn_fl(vert_lens, (int)verts_num, FLT_MAX);
|
||||
vert_lens = static_cast<float *>(MEM_malloc_arrayN(verts_num, sizeof(float), "vert_lens"));
|
||||
copy_vn_fl(vert_lens, int(verts_num), FLT_MAX);
|
||||
for (uint i = 0; i < edges_num; i++) {
|
||||
const float ed_len_sq = len_squared_v3v3(vert_positions[medge[i].v1],
|
||||
vert_positions[medge[i].v2]);
|
||||
|
@ -505,17 +504,18 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
if (do_angle_clamp || do_bevel_convex) {
|
||||
uint eidx;
|
||||
if (do_angle_clamp) {
|
||||
vert_angs = MEM_malloc_arrayN(verts_num, sizeof(float), "vert_angs");
|
||||
copy_vn_fl(vert_angs, (int)verts_num, 0.5f * M_PI);
|
||||
vert_angs = static_cast<float *>(MEM_malloc_arrayN(verts_num, sizeof(float), "vert_angs"));
|
||||
copy_vn_fl(vert_angs, int(verts_num), 0.5f * M_PI);
|
||||
}
|
||||
if (do_bevel_convex) {
|
||||
edge_angs = MEM_malloc_arrayN(edges_num, sizeof(float), "edge_angs");
|
||||
edge_angs = static_cast<float *>(MEM_malloc_arrayN(edges_num, sizeof(float), "edge_angs"));
|
||||
if (!do_rim) {
|
||||
edge_users = MEM_malloc_arrayN(edges_num, sizeof(*edge_users), "solid_mod edges");
|
||||
edge_users = static_cast<uint *>(
|
||||
MEM_malloc_arrayN(edges_num, sizeof(*edge_users), "solid_mod edges"));
|
||||
}
|
||||
}
|
||||
uint(*edge_user_pairs)[2] = MEM_malloc_arrayN(
|
||||
edges_num, sizeof(*edge_user_pairs), "edge_user_pairs");
|
||||
uint(*edge_user_pairs)[2] = static_cast<uint(*)[2]>(
|
||||
MEM_malloc_arrayN(edges_num, sizeof(*edge_user_pairs), "edge_user_pairs"));
|
||||
for (eidx = 0; eidx < edges_num; eidx++) {
|
||||
edge_user_pairs[eidx][0] = INVALID_UNUSED;
|
||||
edge_user_pairs[eidx][1] = INVALID_UNUSED;
|
||||
|
@ -589,7 +589,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
}
|
||||
if (do_clamp && offset > FLT_EPSILON) {
|
||||
/* always reset because we may have set before */
|
||||
if (dvert == NULL) {
|
||||
if (dvert == nullptr) {
|
||||
ofs_new_vgroup = ofs_new;
|
||||
}
|
||||
if (do_angle_clamp) {
|
||||
|
@ -641,7 +641,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
}
|
||||
if (do_clamp && offset > FLT_EPSILON) {
|
||||
/* always reset because we may have set before */
|
||||
if (dvert == NULL) {
|
||||
if (dvert == nullptr) {
|
||||
ofs_new_vgroup = ofs_orig;
|
||||
}
|
||||
if (do_angle_clamp) {
|
||||
|
@ -706,14 +706,15 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
const bool check_non_manifold = (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) != 0;
|
||||
#endif
|
||||
/* same as EM_solidify() in editmesh_lib.c */
|
||||
float *vert_angles = MEM_calloc_arrayN(
|
||||
verts_num, sizeof(float[2]), "mod_solid_pair"); /* 2 in 1 */
|
||||
float *vert_angles = static_cast<float *>(
|
||||
MEM_calloc_arrayN(verts_num, sizeof(float[2]), "mod_solid_pair")); /* 2 in 1 */
|
||||
float *vert_accum = vert_angles + verts_num;
|
||||
uint vidx;
|
||||
uint i;
|
||||
|
||||
if (vert_nors == NULL) {
|
||||
vert_nors = MEM_malloc_arrayN(verts_num, sizeof(float[3]), "mod_solid_vno");
|
||||
if (vert_nors == nullptr) {
|
||||
vert_nors = static_cast<float(*)[3]>(
|
||||
MEM_malloc_arrayN(verts_num, sizeof(float[3]), "mod_solid_vno"));
|
||||
for (i = 0; i < verts_num; i++) {
|
||||
copy_v3_v3(vert_nors[i], mesh_vert_normals[i]);
|
||||
}
|
||||
|
@ -792,24 +793,27 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
}
|
||||
|
||||
/* for angle clamp */
|
||||
float *vert_angs = NULL;
|
||||
float *vert_angs = nullptr;
|
||||
/* for bevel convex */
|
||||
float *edge_angs = NULL;
|
||||
float *edge_angs = nullptr;
|
||||
|
||||
if (do_angle_clamp || do_bevel_convex) {
|
||||
uint eidx;
|
||||
if (do_angle_clamp) {
|
||||
vert_angs = MEM_malloc_arrayN(verts_num, sizeof(float), "vert_angs even");
|
||||
copy_vn_fl(vert_angs, (int)verts_num, 0.5f * M_PI);
|
||||
vert_angs = static_cast<float *>(
|
||||
MEM_malloc_arrayN(verts_num, sizeof(float), "vert_angs even"));
|
||||
copy_vn_fl(vert_angs, int(verts_num), 0.5f * M_PI);
|
||||
}
|
||||
if (do_bevel_convex) {
|
||||
edge_angs = MEM_malloc_arrayN(edges_num, sizeof(float), "edge_angs even");
|
||||
edge_angs = static_cast<float *>(
|
||||
MEM_malloc_arrayN(edges_num, sizeof(float), "edge_angs even"));
|
||||
if (!do_rim) {
|
||||
edge_users = MEM_malloc_arrayN(edges_num, sizeof(*edge_users), "solid_mod edges");
|
||||
edge_users = static_cast<uint *>(
|
||||
MEM_malloc_arrayN(edges_num, sizeof(*edge_users), "solid_mod edges"));
|
||||
}
|
||||
}
|
||||
uint(*edge_user_pairs)[2] = MEM_malloc_arrayN(
|
||||
edges_num, sizeof(*edge_user_pairs), "edge_user_pairs");
|
||||
uint(*edge_user_pairs)[2] = static_cast<uint(*)[2]>(
|
||||
MEM_malloc_arrayN(edges_num, sizeof(*edge_user_pairs), "edge_user_pairs"));
|
||||
for (eidx = 0; eidx < edges_num; eidx++) {
|
||||
edge_user_pairs[eidx][0] = INVALID_UNUSED;
|
||||
edge_user_pairs[eidx][1] = INVALID_UNUSED;
|
||||
|
@ -863,9 +867,10 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
const float clamp_fac = 1 + (do_angle_clamp ? fabsf(smd->offset_fac) : 0);
|
||||
const float offset = fabsf(smd->offset) * smd->offset_clamp * clamp_fac;
|
||||
if (offset > FLT_EPSILON) {
|
||||
float *vert_lens_sq = MEM_malloc_arrayN(verts_num, sizeof(float), "vert_lens_sq");
|
||||
float *vert_lens_sq = static_cast<float *>(
|
||||
MEM_malloc_arrayN(verts_num, sizeof(float), "vert_lens_sq"));
|
||||
const float offset_sq = offset * offset;
|
||||
copy_vn_fl(vert_lens_sq, (int)verts_num, FLT_MAX);
|
||||
copy_vn_fl(vert_lens_sq, int(verts_num), FLT_MAX);
|
||||
for (i = 0; i < edges_num; i++) {
|
||||
const float ed_len = len_squared_v3v3(vert_positions[medge[i].v1],
|
||||
vert_positions[medge[i].v2]);
|
||||
|
@ -986,7 +991,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
MDeformVert *dst_dvert = BKE_mesh_deform_verts_for_write(result);
|
||||
|
||||
/* Ultimate security check. */
|
||||
if (dst_dvert != NULL) {
|
||||
if (dst_dvert != nullptr) {
|
||||
|
||||
if (rim_defgrp_index != -1) {
|
||||
for (uint i = 0; i < rimVerts; i++) {
|
||||
|
@ -1022,9 +1027,9 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
* do_side_normals is always false. */
|
||||
const bool do_side_normals = !BKE_mesh_vertex_normals_are_dirty(result);
|
||||
/* annoying to allocate these since we only need the edge verts, */
|
||||
float(*edge_vert_nos)[3] = do_side_normals ?
|
||||
MEM_calloc_arrayN(verts_num, sizeof(float[3]), __func__) :
|
||||
NULL;
|
||||
float(*edge_vert_nos)[3] = do_side_normals ? static_cast<float(*)[3]>(MEM_calloc_arrayN(
|
||||
verts_num, sizeof(float[3]), __func__)) :
|
||||
nullptr;
|
||||
float nor[3];
|
||||
#endif
|
||||
const float crease_rim = smd->crease_rim;
|
||||
|
@ -1035,15 +1040,16 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
int *orig_ed;
|
||||
uint j;
|
||||
|
||||
float *result_edge_crease = NULL;
|
||||
float *result_edge_crease = nullptr;
|
||||
if (crease_rim || crease_outer || crease_inner) {
|
||||
result_edge_crease = (float *)CustomData_add_layer(
|
||||
&result->edata, CD_CREASE, CD_SET_DEFAULT, NULL, result->totedge);
|
||||
&result->edata, CD_CREASE, CD_SET_DEFAULT, nullptr, result->totedge);
|
||||
}
|
||||
|
||||
/* add faces & edges */
|
||||
origindex_edge = CustomData_get_layer_for_write(&result->edata, CD_ORIGINDEX, result->totedge);
|
||||
orig_ed = (origindex_edge) ? &origindex_edge[(edges_num * stride) + newEdges] : NULL;
|
||||
origindex_edge = static_cast<int *>(
|
||||
CustomData_get_layer_for_write(&result->edata, CD_ORIGINDEX, result->totedge));
|
||||
orig_ed = (origindex_edge) ? &origindex_edge[(edges_num * stride) + newEdges] : nullptr;
|
||||
MEdge *ed = &medge[(edges_num * stride) + newEdges]; /* start after copied edges */
|
||||
for (i = 0; i < rimVerts; i++, ed++) {
|
||||
ed->v1 = new_vert_arr[i];
|
||||
|
@ -1082,8 +1088,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
|
||||
/* copy most of the face settings */
|
||||
CustomData_copy_data(
|
||||
&mesh->pdata, &result->pdata, (int)pidx, (int)((polys_num * stride) + i), 1);
|
||||
mp->loopstart = (int)(j + (loops_num * stride));
|
||||
&mesh->pdata, &result->pdata, int(pidx), int((polys_num * stride) + i), 1);
|
||||
mp->loopstart = int(j + (loops_num * stride));
|
||||
mp->flag = mpoly[pidx].flag;
|
||||
|
||||
/* notice we use 'mp->totloop' which is later overwritten,
|
||||
|
@ -1097,14 +1103,10 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex
|
|||
|
||||
mp->totloop = 4;
|
||||
|
||||
CustomData_copy_data(
|
||||
&mesh->ldata, &result->ldata, k2, (int)((loops_num * stride) + j + 0), 1);
|
||||
CustomData_copy_data(
|
||||
&mesh->ldata, &result->ldata, k1, (int)((loops_num * stride) + j + 1), 1);
|
||||
CustomData_copy_data(
|
||||
&mesh->ldata, &result->ldata, k1, (int)((loops_num * stride) + j + 2), 1);
|
||||
CustomData_copy_data(
|
||||
&mesh->ldata, &result->ldata, k2, (int)((loops_num * stride) + j + 3), 1);
|
||||
CustomData_copy_data(&mesh->ldata, &result->ldata, k2, int((loops_num * stride) + j + 0), 1);
|
||||
CustomData_copy_data(&mesh->ldata, &result->ldata, k1, int((loops_num * stride) + j + 1), 1);
|
||||
CustomData_copy_data(&mesh->ldata, &result->ldata, k1, int((loops_num * stride) + j + 2), 1);
|
||||
CustomData_copy_data(&mesh->ldata, &result->ldata, k2, int((loops_num * stride) + j + 3), 1);
|
||||
|
||||
if (flip == false) {
|
||||
ml[j].v = ed->v1;
|
File diff suppressed because it is too large
Load Diff
|
@ -6,13 +6,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
/* MOD_solidify_extrude.c */
|
||||
/* MOD_solidify_extrude.cc */
|
||||
|
||||
Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md,
|
||||
const ModifierEvalContext *ctx,
|
||||
Mesh *mesh);
|
||||
|
||||
/* MOD_solidify_nonmanifold.c */
|
||||
/* MOD_solidify_nonmanifold.cc */
|
||||
|
||||
Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md,
|
||||
const ModifierEvalContext *ctx,
|
|
@ -5,7 +5,6 @@
|
|||
* \ingroup modifiers
|
||||
*/
|
||||
|
||||
#include "BLI_alloca.h"
|
||||
#include "BLI_math.h"
|
||||
#include "BLI_math_geom.h"
|
||||
#include "BLI_task.h"
|
||||
|
@ -47,45 +46,45 @@
|
|||
#include "MOD_ui_common.h"
|
||||
#include "MOD_util.h"
|
||||
|
||||
typedef struct SDefAdjacency {
|
||||
struct SDefAdjacency *next;
|
||||
struct SDefAdjacency {
|
||||
SDefAdjacency *next;
|
||||
uint index;
|
||||
} SDefAdjacency;
|
||||
};
|
||||
|
||||
typedef struct SDefAdjacencyArray {
|
||||
struct SDefAdjacencyArray {
|
||||
SDefAdjacency *first;
|
||||
uint num; /* Careful, this is twice the number of polygons (avoids an extra loop) */
|
||||
} SDefAdjacencyArray;
|
||||
};
|
||||
|
||||
/**
|
||||
* Polygons per edge (only 2, any more will exit calculation).
|
||||
*/
|
||||
typedef struct SDefEdgePolys {
|
||||
struct SDefEdgePolys {
|
||||
uint polys[2], num;
|
||||
} SDefEdgePolys;
|
||||
};
|
||||
|
||||
typedef struct SDefBindCalcData {
|
||||
BVHTreeFromMesh *const treeData;
|
||||
const SDefAdjacencyArray *const vert_edges;
|
||||
const SDefEdgePolys *const edge_polys;
|
||||
SDefVert *const bind_verts;
|
||||
const MLoopTri *const looptri;
|
||||
const MPoly *const mpoly;
|
||||
const MEdge *const medge;
|
||||
const MLoop *const mloop;
|
||||
struct SDefBindCalcData {
|
||||
BVHTreeFromMesh *treeData;
|
||||
const SDefAdjacencyArray *vert_edges;
|
||||
const SDefEdgePolys *edge_polys;
|
||||
SDefVert *bind_verts;
|
||||
const MLoopTri *looptri;
|
||||
const MPoly *mpoly;
|
||||
const MEdge *medge;
|
||||
const MLoop *mloop;
|
||||
/** Coordinates to bind to, transformed into local space (compatible with `vertexCos`). */
|
||||
float (*const targetCos)[3];
|
||||
float (*targetCos)[3];
|
||||
/** Coordinates to bind (reference to the modifiers input argument). */
|
||||
float (*const vertexCos)[3];
|
||||
const float (*vertexCos)[3];
|
||||
float imat[4][4];
|
||||
const float falloff;
|
||||
float falloff;
|
||||
int success;
|
||||
/** Vertex group lookup data. */
|
||||
const MDeformVert *const dvert;
|
||||
int const defgrp_index;
|
||||
bool const invert_vgroup;
|
||||
bool const sparse_bind;
|
||||
} SDefBindCalcData;
|
||||
const MDeformVert *dvert;
|
||||
int defgrp_index;
|
||||
bool invert_vgroup;
|
||||
bool sparse_bind;
|
||||
};
|
||||
|
||||
/**
|
||||
* This represents the relationship between a point (a source coordinate)
|
||||
|
@ -94,7 +93,7 @@ typedef struct SDefBindCalcData {
|
|||
* \note Some of these values could be de-duplicated however these are only
|
||||
* needed once when running bind, so optimizing this structure isn't a priority.
|
||||
*/
|
||||
typedef struct SDefBindPoly {
|
||||
struct SDefBindPoly {
|
||||
/** Coordinates copied directly from the modifiers input. */
|
||||
float (*coords)[3];
|
||||
/** Coordinates projected into 2D space using `normal`. */
|
||||
|
@ -148,23 +147,23 @@ typedef struct SDefBindPoly {
|
|||
uint dominant_edge;
|
||||
/** When true `point_v2` is inside `coords_v2`. */
|
||||
bool inside;
|
||||
} SDefBindPoly;
|
||||
};
|
||||
|
||||
typedef struct SDefBindWeightData {
|
||||
struct SDefBindWeightData {
|
||||
SDefBindPoly *bind_polys;
|
||||
uint polys_num;
|
||||
uint binds_num;
|
||||
} SDefBindWeightData;
|
||||
};
|
||||
|
||||
typedef struct SDefDeformData {
|
||||
const SDefVert *const bind_verts;
|
||||
float (*const targetCos)[3];
|
||||
float (*const vertexCos)[3];
|
||||
const MDeformVert *const dvert;
|
||||
int const defgrp_index;
|
||||
bool const invert_vgroup;
|
||||
float const strength;
|
||||
} SDefDeformData;
|
||||
struct SDefDeformData {
|
||||
const SDefVert *bind_verts;
|
||||
float (*targetCos)[3];
|
||||
float (*vertexCos)[3];
|
||||
const MDeformVert *dvert;
|
||||
int defgrp_index;
|
||||
bool invert_vgroup;
|
||||
float strength;
|
||||
};
|
||||
|
||||
/* Bind result values */
|
||||
enum {
|
||||
|
@ -229,20 +228,21 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla
|
|||
BKE_modifier_copydata_generic(md, target, flag);
|
||||
|
||||
if (smd->verts) {
|
||||
tsmd->verts = MEM_dupallocN(smd->verts);
|
||||
tsmd->verts = static_cast<SDefVert *>(MEM_dupallocN(smd->verts));
|
||||
|
||||
for (int i = 0; i < smd->bind_verts_num; i++) {
|
||||
if (smd->verts[i].binds) {
|
||||
tsmd->verts[i].binds = MEM_dupallocN(smd->verts[i].binds);
|
||||
tsmd->verts[i].binds = static_cast<SDefBind *>(MEM_dupallocN(smd->verts[i].binds));
|
||||
|
||||
for (int j = 0; j < smd->verts[i].binds_num; j++) {
|
||||
if (smd->verts[i].binds[j].vert_inds) {
|
||||
tsmd->verts[i].binds[j].vert_inds = MEM_dupallocN(smd->verts[i].binds[j].vert_inds);
|
||||
tsmd->verts[i].binds[j].vert_inds = static_cast<uint *>(
|
||||
MEM_dupallocN(smd->verts[i].binds[j].vert_inds));
|
||||
}
|
||||
|
||||
if (smd->verts[i].binds[j].vert_weights) {
|
||||
tsmd->verts[i].binds[j].vert_weights = MEM_dupallocN(
|
||||
smd->verts[i].binds[j].vert_weights);
|
||||
tsmd->verts[i].binds[j].vert_weights = static_cast<float *>(
|
||||
MEM_dupallocN(smd->verts[i].binds[j].vert_weights));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *u
|
|||
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
|
||||
{
|
||||
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
|
||||
if (smd->target != NULL) {
|
||||
if (smd->target != nullptr) {
|
||||
DEG_add_object_relation(
|
||||
ctx->node, smd->target, DEG_OB_COMP_GEOMETRY, "Surface Deform Modifier");
|
||||
}
|
||||
|
@ -368,10 +368,10 @@ BLI_INLINE void sortPolyVertsTri(uint *indices,
|
|||
|
||||
BLI_INLINE uint nearestVert(SDefBindCalcData *const data, const float point_co[3])
|
||||
{
|
||||
BVHTreeNearest nearest = {
|
||||
.dist_sq = FLT_MAX,
|
||||
.index = -1,
|
||||
};
|
||||
BVHTreeNearest nearest{};
|
||||
nearest.dist_sq = FLT_MAX;
|
||||
nearest.index = -1;
|
||||
|
||||
const MPoly *poly;
|
||||
const MEdge *edge;
|
||||
const MLoop *loop;
|
||||
|
@ -489,19 +489,20 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
|
|||
float tot_weight = 0.0f;
|
||||
int inf_weight_flags = 0;
|
||||
|
||||
bwdata = MEM_callocN(sizeof(*bwdata), "SDefBindWeightData");
|
||||
if (bwdata == NULL) {
|
||||
bwdata = static_cast<SDefBindWeightData *>(MEM_callocN(sizeof(*bwdata), "SDefBindWeightData"));
|
||||
if (bwdata == nullptr) {
|
||||
data->success = MOD_SDEF_BIND_RESULT_MEM_ERR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bwdata->polys_num = data->vert_edges[nearest].num / 2;
|
||||
|
||||
bpoly = MEM_calloc_arrayN(bwdata->polys_num, sizeof(*bpoly), "SDefBindPoly");
|
||||
if (bpoly == NULL) {
|
||||
bpoly = static_cast<SDefBindPoly *>(
|
||||
MEM_calloc_arrayN(bwdata->polys_num, sizeof(*bpoly), "SDefBindPoly"));
|
||||
if (bpoly == nullptr) {
|
||||
freeBindData(bwdata);
|
||||
data->success = MOD_SDEF_BIND_RESULT_MEM_ERR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bwdata->bind_polys = bpoly;
|
||||
|
@ -531,8 +532,8 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
|
|||
int is_poly_valid;
|
||||
|
||||
bpoly->index = edge_polys[edge_ind].polys[i];
|
||||
bpoly->coords = NULL;
|
||||
bpoly->coords_v2 = NULL;
|
||||
bpoly->coords = nullptr;
|
||||
bpoly->coords_v2 = nullptr;
|
||||
|
||||
/* Copy poly data */
|
||||
poly = &data->mpoly[bpoly->index];
|
||||
|
@ -541,20 +542,20 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
|
|||
bpoly->verts_num = poly->totloop;
|
||||
bpoly->loopstart = poly->loopstart;
|
||||
|
||||
bpoly->coords = MEM_malloc_arrayN(
|
||||
poly->totloop, sizeof(*bpoly->coords), "SDefBindPolyCoords");
|
||||
if (bpoly->coords == NULL) {
|
||||
bpoly->coords = static_cast<float(*)[3]>(
|
||||
MEM_malloc_arrayN(poly->totloop, sizeof(*bpoly->coords), "SDefBindPolyCoords"));
|
||||
if (bpoly->coords == nullptr) {
|
||||
freeBindData(bwdata);
|
||||
data->success = MOD_SDEF_BIND_RESULT_MEM_ERR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bpoly->coords_v2 = MEM_malloc_arrayN(
|
||||
poly->totloop, sizeof(*bpoly->coords_v2), "SDefBindPolyCoords_v2");
|
||||
if (bpoly->coords_v2 == NULL) {
|
||||
bpoly->coords_v2 = static_cast<float(*)[2]>(
|
||||
MEM_malloc_arrayN(poly->totloop, sizeof(*bpoly->coords_v2), "SDefBindPolyCoords_v2"));
|
||||
if (bpoly->coords_v2 == nullptr) {
|
||||
freeBindData(bwdata);
|
||||
data->success = MOD_SDEF_BIND_RESULT_MEM_ERR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (int j = 0; j < poly->totloop; j++, loop++) {
|
||||
|
@ -595,7 +596,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
|
|||
if (is_poly_valid != MOD_SDEF_BIND_RESULT_SUCCESS) {
|
||||
freeBindData(bwdata);
|
||||
data->success = is_poly_valid;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bpoly->inside = isect_point_poly_v2(
|
||||
|
@ -651,7 +652,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
|
|||
bpoly->corner_edgemid_angles[1] < FLT_EPSILON) {
|
||||
freeBindData(bwdata);
|
||||
data->success = MOD_SDEF_BIND_RESULT_GENERIC_ERR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Check for infinite weights, and compute angular data otherwise. */
|
||||
|
@ -709,7 +710,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
|
|||
bpoly->point_edgemid_angles[0] + bpoly->point_edgemid_angles[1] < FLT_EPSILON) {
|
||||
freeBindData(bwdata);
|
||||
data->success = MOD_SDEF_BIND_RESULT_GENERIC_ERR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -783,7 +784,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
|
|||
if (isnan(corner_angle_weights[0]) || isnan(corner_angle_weights[1])) {
|
||||
freeBindData(bwdata);
|
||||
data->success = MOD_SDEF_BIND_RESULT_GENERIC_ERR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Find which edge the point is closer to */
|
||||
|
@ -800,7 +801,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data,
|
|||
if (bpoly->dominant_angle_weight < 0 || bpoly->dominant_angle_weight > 1) {
|
||||
freeBindData(bwdata);
|
||||
data->success = MOD_SDEF_BIND_RESULT_GENERIC_ERR;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bpoly->dominant_angle_weight = sinf(bpoly->dominant_angle_weight * M_PI_2);
|
||||
|
@ -940,7 +941,7 @@ BLI_INLINE float computeNormalDisplacement(const float point_co[3],
|
|||
|
||||
static void bindVert(void *__restrict userdata,
|
||||
const int index,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
SDefBindCalcData *const data = (SDefBindCalcData *)userdata;
|
||||
float point_co[3];
|
||||
|
@ -954,7 +955,7 @@ static void bindVert(void *__restrict userdata,
|
|||
sdvert->vertex_idx = index;
|
||||
|
||||
if (data->success != MOD_SDEF_BIND_RESULT_SUCCESS) {
|
||||
sdvert->binds = NULL;
|
||||
sdvert->binds = nullptr;
|
||||
sdvert->binds_num = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -971,7 +972,7 @@ static void bindVert(void *__restrict userdata,
|
|||
}
|
||||
|
||||
if (weight <= 0) {
|
||||
sdvert->binds = NULL;
|
||||
sdvert->binds = nullptr;
|
||||
sdvert->binds_num = 0;
|
||||
return;
|
||||
}
|
||||
|
@ -980,14 +981,15 @@ static void bindVert(void *__restrict userdata,
|
|||
copy_v3_v3(point_co, data->vertexCos[index]);
|
||||
bwdata = computeBindWeights(data, point_co);
|
||||
|
||||
if (bwdata == NULL) {
|
||||
sdvert->binds = NULL;
|
||||
if (bwdata == nullptr) {
|
||||
sdvert->binds = nullptr;
|
||||
sdvert->binds_num = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
sdvert->binds = MEM_calloc_arrayN(bwdata->binds_num, sizeof(*sdvert->binds), "SDefVertBindData");
|
||||
if (sdvert->binds == NULL) {
|
||||
sdvert->binds = static_cast<SDefBind *>(
|
||||
MEM_calloc_arrayN(bwdata->binds_num, sizeof(*sdvert->binds), "SDefVertBindData"));
|
||||
if (sdvert->binds == nullptr) {
|
||||
data->success = MOD_SDEF_BIND_RESULT_MEM_ERR;
|
||||
sdvert->binds_num = 0;
|
||||
return;
|
||||
|
@ -1008,16 +1010,16 @@ static void bindVert(void *__restrict userdata,
|
|||
sdbind->verts_num = bpoly->verts_num;
|
||||
|
||||
sdbind->mode = MOD_SDEF_MODE_NGON;
|
||||
sdbind->vert_weights = MEM_malloc_arrayN(
|
||||
bpoly->verts_num, sizeof(*sdbind->vert_weights), "SDefNgonVertWeights");
|
||||
if (sdbind->vert_weights == NULL) {
|
||||
sdbind->vert_weights = static_cast<float *>(MEM_malloc_arrayN(
|
||||
bpoly->verts_num, sizeof(*sdbind->vert_weights), "SDefNgonVertWeights"));
|
||||
if (sdbind->vert_weights == nullptr) {
|
||||
data->success = MOD_SDEF_BIND_RESULT_MEM_ERR;
|
||||
return;
|
||||
}
|
||||
|
||||
sdbind->vert_inds = MEM_malloc_arrayN(
|
||||
bpoly->verts_num, sizeof(*sdbind->vert_inds), "SDefNgonVertInds");
|
||||
if (sdbind->vert_inds == NULL) {
|
||||
sdbind->vert_inds = static_cast<uint *>(
|
||||
MEM_malloc_arrayN(bpoly->verts_num, sizeof(*sdbind->vert_inds), "SDefNgonVertInds"));
|
||||
if (sdbind->vert_inds == nullptr) {
|
||||
data->success = MOD_SDEF_BIND_RESULT_MEM_ERR;
|
||||
return;
|
||||
}
|
||||
|
@ -1048,16 +1050,16 @@ static void bindVert(void *__restrict userdata,
|
|||
sdbind->verts_num = bpoly->verts_num;
|
||||
|
||||
sdbind->mode = MOD_SDEF_MODE_CENTROID;
|
||||
sdbind->vert_weights = MEM_malloc_arrayN(
|
||||
3, sizeof(*sdbind->vert_weights), "SDefCentVertWeights");
|
||||
if (sdbind->vert_weights == NULL) {
|
||||
sdbind->vert_weights = static_cast<float *>(
|
||||
MEM_malloc_arrayN(3, sizeof(*sdbind->vert_weights), "SDefCentVertWeights"));
|
||||
if (sdbind->vert_weights == nullptr) {
|
||||
data->success = MOD_SDEF_BIND_RESULT_MEM_ERR;
|
||||
return;
|
||||
}
|
||||
|
||||
sdbind->vert_inds = MEM_malloc_arrayN(
|
||||
bpoly->verts_num, sizeof(*sdbind->vert_inds), "SDefCentVertInds");
|
||||
if (sdbind->vert_inds == NULL) {
|
||||
sdbind->vert_inds = static_cast<uint *>(
|
||||
MEM_malloc_arrayN(bpoly->verts_num, sizeof(*sdbind->vert_inds), "SDefCentVertInds"));
|
||||
if (sdbind->vert_inds == nullptr) {
|
||||
data->success = MOD_SDEF_BIND_RESULT_MEM_ERR;
|
||||
return;
|
||||
}
|
||||
|
@ -1095,16 +1097,16 @@ static void bindVert(void *__restrict userdata,
|
|||
sdbind->verts_num = bpoly->verts_num;
|
||||
|
||||
sdbind->mode = MOD_SDEF_MODE_LOOPTRI;
|
||||
sdbind->vert_weights = MEM_malloc_arrayN(
|
||||
3, sizeof(*sdbind->vert_weights), "SDefTriVertWeights");
|
||||
if (sdbind->vert_weights == NULL) {
|
||||
sdbind->vert_weights = static_cast<float *>(
|
||||
MEM_malloc_arrayN(3, sizeof(*sdbind->vert_weights), "SDefTriVertWeights"));
|
||||
if (sdbind->vert_weights == nullptr) {
|
||||
data->success = MOD_SDEF_BIND_RESULT_MEM_ERR;
|
||||
return;
|
||||
}
|
||||
|
||||
sdbind->vert_inds = MEM_malloc_arrayN(
|
||||
bpoly->verts_num, sizeof(*sdbind->vert_inds), "SDefTriVertInds");
|
||||
if (sdbind->vert_inds == NULL) {
|
||||
sdbind->vert_inds = static_cast<uint *>(
|
||||
MEM_malloc_arrayN(bpoly->verts_num, sizeof(*sdbind->vert_inds), "SDefTriVertInds"));
|
||||
if (sdbind->vert_inds == nullptr) {
|
||||
data->success = MOD_SDEF_BIND_RESULT_MEM_ERR;
|
||||
return;
|
||||
}
|
||||
|
@ -1154,8 +1156,8 @@ static void compactSparseBinds(SurfaceDeformModifierData *smd)
|
|||
}
|
||||
}
|
||||
|
||||
smd->verts = MEM_reallocN_id(
|
||||
smd->verts, sizeof(*smd->verts) * smd->bind_verts_num, "SDefBindVerts (sparse)");
|
||||
smd->verts = static_cast<SDefVert *>(MEM_reallocN_id(
|
||||
smd->verts, sizeof(*smd->verts) * smd->bind_verts_num, "SDefBindVerts (sparse)"));
|
||||
}
|
||||
|
||||
static bool surfacedeformBind(Object *ob,
|
||||
|
@ -1168,51 +1170,52 @@ static bool surfacedeformBind(Object *ob,
|
|||
Mesh *target,
|
||||
Mesh *mesh)
|
||||
{
|
||||
BVHTreeFromMesh treeData = {NULL};
|
||||
BVHTreeFromMesh treeData = {nullptr};
|
||||
const float(*positions)[3] = BKE_mesh_vert_positions(target);
|
||||
const MPoly *mpoly = BKE_mesh_polys(target);
|
||||
const MEdge *medge = BKE_mesh_edges(target);
|
||||
const MLoop *mloop = BKE_mesh_loops(target);
|
||||
uint tedges_num = target->totedge;
|
||||
int adj_result;
|
||||
SDefAdjacencyArray *vert_edges;
|
||||
SDefAdjacency *adj_array;
|
||||
SDefEdgePolys *edge_polys;
|
||||
|
||||
vert_edges = MEM_calloc_arrayN(target_verts_num, sizeof(*vert_edges), "SDefVertEdgeMap");
|
||||
if (vert_edges == NULL) {
|
||||
SDefAdjacencyArray *vert_edges = static_cast<SDefAdjacencyArray *>(
|
||||
MEM_calloc_arrayN(target_verts_num, sizeof(*vert_edges), "SDefVertEdgeMap"));
|
||||
if (vert_edges == nullptr) {
|
||||
BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
|
||||
return false;
|
||||
}
|
||||
|
||||
adj_array = MEM_malloc_arrayN(tedges_num, 2 * sizeof(*adj_array), "SDefVertEdge");
|
||||
if (adj_array == NULL) {
|
||||
SDefAdjacency *adj_array = static_cast<SDefAdjacency *>(
|
||||
MEM_malloc_arrayN(tedges_num, 2 * sizeof(*adj_array), "SDefVertEdge"));
|
||||
if (adj_array == nullptr) {
|
||||
BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
|
||||
MEM_freeN(vert_edges);
|
||||
return false;
|
||||
}
|
||||
|
||||
edge_polys = MEM_calloc_arrayN(tedges_num, sizeof(*edge_polys), "SDefEdgeFaceMap");
|
||||
if (edge_polys == NULL) {
|
||||
SDefEdgePolys *edge_polys = static_cast<SDefEdgePolys *>(
|
||||
MEM_calloc_arrayN(tedges_num, sizeof(*edge_polys), "SDefEdgeFaceMap"));
|
||||
if (edge_polys == nullptr) {
|
||||
BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
|
||||
MEM_freeN(vert_edges);
|
||||
MEM_freeN(adj_array);
|
||||
return false;
|
||||
}
|
||||
|
||||
smd_orig->verts = MEM_malloc_arrayN(verts_num, sizeof(*smd_orig->verts), "SDefBindVerts");
|
||||
if (smd_orig->verts == NULL) {
|
||||
smd_orig->verts = static_cast<SDefVert *>(
|
||||
MEM_malloc_arrayN(verts_num, sizeof(*smd_orig->verts), "SDefBindVerts"));
|
||||
if (smd_orig->verts == nullptr) {
|
||||
BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
|
||||
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
|
||||
return false;
|
||||
}
|
||||
|
||||
BKE_bvhtree_from_mesh_get(&treeData, target, BVHTREE_FROM_LOOPTRI, 2);
|
||||
if (treeData.tree == NULL) {
|
||||
if (treeData.tree == nullptr) {
|
||||
BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
|
||||
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
|
||||
MEM_freeN(smd_orig->verts);
|
||||
smd_orig->verts = NULL;
|
||||
smd_orig->verts = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1225,7 +1228,7 @@ static bool surfacedeformBind(Object *ob,
|
|||
freeAdjacencyMap(vert_edges, adj_array, edge_polys);
|
||||
free_bvhtree_from_mesh(&treeData);
|
||||
MEM_freeN(smd_orig->verts);
|
||||
smd_orig->verts = NULL;
|
||||
smd_orig->verts = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1239,27 +1242,26 @@ static bool surfacedeformBind(Object *ob,
|
|||
const bool invert_vgroup = (smd_orig->flags & MOD_SDEF_INVERT_VGROUP) != 0;
|
||||
const bool sparse_bind = (smd_orig->flags & MOD_SDEF_SPARSE_BIND) != 0;
|
||||
|
||||
SDefBindCalcData data = {
|
||||
.treeData = &treeData,
|
||||
.vert_edges = vert_edges,
|
||||
.edge_polys = edge_polys,
|
||||
.mpoly = mpoly,
|
||||
.medge = medge,
|
||||
.mloop = mloop,
|
||||
.looptri = BKE_mesh_runtime_looptri_ensure(target),
|
||||
.targetCos = MEM_malloc_arrayN(
|
||||
target_verts_num, sizeof(float[3]), "SDefTargetBindVertArray"),
|
||||
.bind_verts = smd_orig->verts,
|
||||
.vertexCos = vertexCos,
|
||||
.falloff = smd_orig->falloff,
|
||||
.success = MOD_SDEF_BIND_RESULT_SUCCESS,
|
||||
.dvert = dvert,
|
||||
.defgrp_index = defgrp_index,
|
||||
.invert_vgroup = invert_vgroup,
|
||||
.sparse_bind = sparse_bind,
|
||||
};
|
||||
SDefBindCalcData data{};
|
||||
data.treeData = &treeData;
|
||||
data.vert_edges = vert_edges;
|
||||
data.edge_polys = edge_polys;
|
||||
data.mpoly = mpoly;
|
||||
data.medge = medge;
|
||||
data.mloop = mloop;
|
||||
data.looptri = BKE_mesh_runtime_looptri_ensure(target);
|
||||
data.targetCos = static_cast<float(*)[3]>(
|
||||
MEM_malloc_arrayN(target_verts_num, sizeof(float[3]), "SDefTargetBindVertArray"));
|
||||
data.bind_verts = smd_orig->verts;
|
||||
data.vertexCos = vertexCos;
|
||||
data.falloff = smd_orig->falloff;
|
||||
data.success = MOD_SDEF_BIND_RESULT_SUCCESS;
|
||||
data.dvert = dvert;
|
||||
data.defgrp_index = defgrp_index;
|
||||
data.invert_vgroup = invert_vgroup;
|
||||
data.sparse_bind = sparse_bind;
|
||||
|
||||
if (data.targetCos == NULL) {
|
||||
if (data.targetCos == nullptr) {
|
||||
BKE_modifier_set_error(ob, (ModifierData *)smd_eval, "Out of memory");
|
||||
freeData((ModifierData *)smd_orig);
|
||||
return false;
|
||||
|
@ -1324,7 +1326,7 @@ static bool surfacedeformBind(Object *ob,
|
|||
|
||||
static void deformVert(void *__restrict userdata,
|
||||
const int index,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
const TaskParallelTLS *__restrict /*tls*/)
|
||||
{
|
||||
const SDefDeformData *const data = (SDefDeformData *)userdata;
|
||||
const SDefBind *sdbind = data->bind_verts[index].binds;
|
||||
|
@ -1352,28 +1354,21 @@ static void deformVert(void *__restrict userdata,
|
|||
|
||||
zero_v3(offset);
|
||||
|
||||
/* Allocate a `coords_buffer` that fits all the temp-data. */
|
||||
int max_verts = 0;
|
||||
for (int j = 0; j < sdbind_num; j++) {
|
||||
max_verts = MAX2(max_verts, sdbind[j].verts_num);
|
||||
}
|
||||
|
||||
const bool big_buffer = max_verts > 256;
|
||||
float(*coords_buffer)[3];
|
||||
|
||||
if (UNLIKELY(big_buffer)) {
|
||||
coords_buffer = MEM_malloc_arrayN(max_verts, sizeof(*coords_buffer), __func__);
|
||||
}
|
||||
else {
|
||||
coords_buffer = BLI_array_alloca(coords_buffer, max_verts);
|
||||
}
|
||||
/* Allocate a `coords_buffer` that fits all the temp-data. */
|
||||
blender::Array<blender::float3, 256> coords_buffer(max_verts);
|
||||
|
||||
for (int j = 0; j < sdbind_num; j++, sdbind++) {
|
||||
for (int k = 0; k < sdbind->verts_num; k++) {
|
||||
copy_v3_v3(coords_buffer[k], data->targetCos[sdbind->vert_inds[k]]);
|
||||
}
|
||||
|
||||
normal_poly_v3(norm, coords_buffer, sdbind->verts_num);
|
||||
normal_poly_v3(
|
||||
norm, reinterpret_cast<const float(*)[3]>(coords_buffer.data()), sdbind->verts_num);
|
||||
zero_v3(temp);
|
||||
|
||||
switch (sdbind->mode) {
|
||||
|
@ -1396,7 +1391,8 @@ static void deformVert(void *__restrict userdata,
|
|||
/* ---------- centroid mode ---------- */
|
||||
case MOD_SDEF_MODE_CENTROID: {
|
||||
float cent[3];
|
||||
mid_v3_v3_array(cent, coords_buffer, sdbind->verts_num);
|
||||
mid_v3_v3_array(
|
||||
cent, reinterpret_cast<const float(*)[3]>(coords_buffer.data()), sdbind->verts_num);
|
||||
|
||||
madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[0]], sdbind->vert_weights[0]);
|
||||
madd_v3_v3fl(temp, data->targetCos[sdbind->vert_inds[1]], sdbind->vert_weights[1]);
|
||||
|
@ -1415,10 +1411,6 @@ static void deformVert(void *__restrict userdata,
|
|||
|
||||
/* Add the offset to start coord multiplied by the strength and weight values. */
|
||||
madd_v3_v3fl(vertexCos, offset, data->strength * weight);
|
||||
|
||||
if (UNLIKELY(big_buffer)) {
|
||||
MEM_freeN(coords_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
static void surfacedeformModifier_do(ModifierData *md,
|
||||
|
@ -1434,7 +1426,7 @@ static void surfacedeformModifier_do(ModifierData *md,
|
|||
|
||||
/* Exit function if bind flag is not set (free bind data if any). */
|
||||
if (!(smd->flags & MOD_SDEF_BIND)) {
|
||||
if (smd->verts != NULL) {
|
||||
if (smd->verts != nullptr) {
|
||||
if (!DEG_is_active(ctx->depsgraph)) {
|
||||
BKE_modifier_set_error(ob, md, "Attempt to bind from inactive dependency graph");
|
||||
return;
|
||||
|
@ -1456,7 +1448,7 @@ static void surfacedeformModifier_do(ModifierData *md,
|
|||
target_polys_num = BKE_mesh_wrapper_poly_len(target);
|
||||
|
||||
/* If not bound, execute bind. */
|
||||
if (smd->verts == NULL) {
|
||||
if (smd->verts == nullptr) {
|
||||
if (!DEG_is_active(ctx->depsgraph)) {
|
||||
BKE_modifier_set_error(ob, md, "Attempt to unbind from inactive dependency graph");
|
||||
return;
|
||||
|
@ -1541,17 +1533,17 @@ static void surfacedeformModifier_do(ModifierData *md,
|
|||
const bool invert_vgroup = (smd->flags & MOD_SDEF_INVERT_VGROUP) != 0;
|
||||
|
||||
/* Actual vertex location update starts here */
|
||||
SDefDeformData data = {
|
||||
.bind_verts = smd->verts,
|
||||
.targetCos = MEM_malloc_arrayN(target_verts_num, sizeof(float[3]), "SDefTargetVertArray"),
|
||||
.vertexCos = vertexCos,
|
||||
.dvert = dvert,
|
||||
.defgrp_index = defgrp_index,
|
||||
.invert_vgroup = invert_vgroup,
|
||||
.strength = smd->strength,
|
||||
};
|
||||
SDefDeformData data{};
|
||||
data.bind_verts = smd->verts;
|
||||
data.targetCos = static_cast<float(*)[3]>(
|
||||
MEM_malloc_arrayN(target_verts_num, sizeof(float[3]), "SDefTargetVertArray"));
|
||||
data.vertexCos = vertexCos;
|
||||
data.dvert = dvert;
|
||||
data.defgrp_index = defgrp_index;
|
||||
data.invert_vgroup = invert_vgroup;
|
||||
data.strength = smd->strength;
|
||||
|
||||
if (data.targetCos != NULL) {
|
||||
if (data.targetCos != nullptr) {
|
||||
BKE_mesh_wrapper_vert_coords_copy_with_mat4(
|
||||
target, data.targetCos, target_verts_num, smd->mat);
|
||||
|
||||
|
@ -1571,48 +1563,48 @@ static void deformVerts(ModifierData *md,
|
|||
int verts_num)
|
||||
{
|
||||
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
|
||||
Mesh *mesh_src = NULL;
|
||||
Mesh *mesh_src = nullptr;
|
||||
|
||||
if (smd->defgrp_name[0] != '\0') {
|
||||
/* Only need to use mesh_src when a vgroup is used. */
|
||||
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false);
|
||||
mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false);
|
||||
}
|
||||
|
||||
surfacedeformModifier_do(md, ctx, vertexCos, verts_num, ctx->object, mesh_src);
|
||||
|
||||
if (!ELEM(mesh_src, NULL, mesh)) {
|
||||
BKE_id_free(NULL, mesh_src);
|
||||
if (!ELEM(mesh_src, nullptr, mesh)) {
|
||||
BKE_id_free(nullptr, mesh_src);
|
||||
}
|
||||
}
|
||||
|
||||
static void deformVertsEM(ModifierData *md,
|
||||
const ModifierEvalContext *ctx,
|
||||
struct BMEditMesh *em,
|
||||
BMEditMesh *em,
|
||||
Mesh *mesh,
|
||||
float (*vertexCos)[3],
|
||||
int verts_num)
|
||||
{
|
||||
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
|
||||
Mesh *mesh_src = NULL;
|
||||
Mesh *mesh_src = nullptr;
|
||||
|
||||
if (smd->defgrp_name[0] != '\0') {
|
||||
/* Only need to use mesh_src when a vgroup is used. */
|
||||
mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, verts_num, false);
|
||||
mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, nullptr, verts_num, false);
|
||||
}
|
||||
|
||||
/* TODO(@campbellbarton): use edit-mode data only (remove this line). */
|
||||
if (mesh_src != NULL) {
|
||||
if (mesh_src != nullptr) {
|
||||
BKE_mesh_wrapper_ensure_mdata(mesh_src);
|
||||
}
|
||||
|
||||
surfacedeformModifier_do(md, ctx, vertexCos, verts_num, ctx->object, mesh_src);
|
||||
|
||||
if (!ELEM(mesh_src, NULL, mesh)) {
|
||||
BKE_id_free(NULL, mesh_src);
|
||||
if (!ELEM(mesh_src, nullptr, mesh)) {
|
||||
BKE_id_free(nullptr, mesh_src);
|
||||
}
|
||||
}
|
||||
|
||||
static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
|
||||
static bool isDisabled(const Scene * /*scene*/, ModifierData *md, bool /*useRenderParams*/)
|
||||
{
|
||||
SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md;
|
||||
|
||||
|
@ -1621,11 +1613,11 @@ static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED
|
|||
*
|
||||
* In other cases it should be impossible to have a type mismatch.
|
||||
*/
|
||||
return (smd->target == NULL || smd->target->type != OB_MESH) &&
|
||||
!(smd->verts != NULL && !(smd->flags & MOD_SDEF_BIND));
|
||||
return (smd->target == nullptr || smd->target->type != OB_MESH) &&
|
||||
!(smd->verts != nullptr && !(smd->flags & MOD_SDEF_BIND));
|
||||
}
|
||||
|
||||
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
||||
{
|
||||
uiLayout *col;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
@ -1641,17 +1633,17 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiLayoutSetActive(col, !is_bound);
|
||||
uiItemR(col, ptr, "target", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "falloff", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "target", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "falloff", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "strength", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "strength", 0, nullptr, ICON_NONE);
|
||||
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL);
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiLayoutSetEnabled(col, !is_bound);
|
||||
uiLayoutSetActive(col, !is_bound && RNA_string_length(ptr, "vertex_group") != 0);
|
||||
uiItemR(col, ptr, "use_sparse_bind", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "use_sparse_bind", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
|
@ -1683,13 +1675,13 @@ static void blendWrite(BlendWriter *writer, const ID *id_owner, const ModifierDa
|
|||
/* Modifier coming from linked data cannot be bound from an override, so we can remove all
|
||||
* binding data, can save a significant amount of memory. */
|
||||
smd.bind_verts_num = 0;
|
||||
smd.verts = NULL;
|
||||
smd.verts = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
BLO_write_struct_at_address(writer, SurfaceDeformModifierData, md, &smd);
|
||||
|
||||
if (smd.verts != NULL) {
|
||||
if (smd.verts != nullptr) {
|
||||
SDefVert *bind_verts = smd.verts;
|
||||
BLO_write_struct_array(writer, SDefVert, smd.bind_verts_num, bind_verts);
|
||||
|
||||
|
@ -1754,22 +1746,22 @@ ModifierTypeInfo modifierType_SurfaceDeform = {
|
|||
/*copyData*/ copyData,
|
||||
|
||||
/*deformVerts*/ deformVerts,
|
||||
/*deformMatrices*/ NULL,
|
||||
/*deformMatrices*/ nullptr,
|
||||
/*deformVertsEM*/ deformVertsEM,
|
||||
/*deformMatricesEM*/ NULL,
|
||||
/*modifyMesh*/ NULL,
|
||||
/*modifyGeometrySet*/ NULL,
|
||||
/*deformMatricesEM*/ nullptr,
|
||||
/*modifyMesh*/ nullptr,
|
||||
/*modifyGeometrySet*/ nullptr,
|
||||
|
||||
/*initData*/ initData,
|
||||
/*requiredDataMask*/ requiredDataMask,
|
||||
/*freeData*/ freeData,
|
||||
/*isDisabled*/ isDisabled,
|
||||
/*updateDepsgraph*/ updateDepsgraph,
|
||||
/*dependsOnTime*/ NULL,
|
||||
/*dependsOnNormals*/ NULL,
|
||||
/*dependsOnTime*/ nullptr,
|
||||
/*dependsOnNormals*/ nullptr,
|
||||
/*foreachIDLink*/ foreachIDLink,
|
||||
/*foreachTexLink*/ NULL,
|
||||
/*freeRuntimeData*/ NULL,
|
||||
/*foreachTexLink*/ nullptr,
|
||||
/*freeRuntimeData*/ nullptr,
|
||||
/*panelRegister*/ panelRegister,
|
||||
/*blendWrite*/ blendWrite,
|
||||
/*blendRead*/ blendRead,
|
Loading…
Reference in New Issue