Cleanup: Move eight modifier files to C++
In preparation for moving mesh runtime data to C++.
This commit is contained in:
parent
53d937a170
commit
406a98aff8
|
@ -63,7 +63,7 @@ set(SRC
|
|||
intern/MOD_meshdeform.c
|
||||
intern/MOD_meshsequencecache.cc
|
||||
intern/MOD_mirror.c
|
||||
intern/MOD_multires.c
|
||||
intern/MOD_multires.cc
|
||||
intern/MOD_nodes.cc
|
||||
intern/MOD_none.c
|
||||
intern/MOD_normal_edit.cc
|
||||
|
@ -86,18 +86,18 @@ set(SRC
|
|||
intern/MOD_surfacedeform.c
|
||||
intern/MOD_triangulate.c
|
||||
intern/MOD_ui_common.c
|
||||
intern/MOD_util.c
|
||||
intern/MOD_uvproject.c
|
||||
intern/MOD_uvwarp.c
|
||||
intern/MOD_util.cc
|
||||
intern/MOD_uvproject.cc
|
||||
intern/MOD_uvwarp.cc
|
||||
intern/MOD_volume_displace.cc
|
||||
intern/MOD_volume_to_mesh.cc
|
||||
intern/MOD_warp.c
|
||||
intern/MOD_wave.cc
|
||||
intern/MOD_weighted_normal.c
|
||||
intern/MOD_weighted_normal.cc
|
||||
intern/MOD_weightvg_util.c
|
||||
intern/MOD_weightvgedit.c
|
||||
intern/MOD_weightvgmix.c
|
||||
intern/MOD_weightvgproximity.c
|
||||
intern/MOD_weightvgedit.cc
|
||||
intern/MOD_weightvgmix.cc
|
||||
intern/MOD_weightvgproximity.cc
|
||||
intern/MOD_weld.cc
|
||||
intern/MOD_wireframe.c
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ extern ModifierTypeInfo modifierType_MeshToVolume;
|
|||
extern ModifierTypeInfo modifierType_VolumeDisplace;
|
||||
extern ModifierTypeInfo modifierType_VolumeToMesh;
|
||||
|
||||
/* MOD_util.c */
|
||||
/* MOD_util.cc */
|
||||
|
||||
/**
|
||||
* Only called by `BKE_modifier.h/modifier.cc`
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* \ingroup modifiers
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <cstddef>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
|
@ -45,10 +45,10 @@
|
|||
#include "MOD_modifiertypes.h"
|
||||
#include "MOD_ui_common.h"
|
||||
|
||||
typedef struct MultiresRuntimeData {
|
||||
struct MultiresRuntimeData {
|
||||
/* Cached subdivision surface descriptor, with topology and settings. */
|
||||
struct Subdiv *subdiv;
|
||||
} MultiresRuntimeData;
|
||||
};
|
||||
|
||||
static void initData(ModifierData *md)
|
||||
{
|
||||
|
@ -87,11 +87,11 @@ static void copyData(const ModifierData *md_src, ModifierData *md_dst, const int
|
|||
|
||||
static void freeRuntimeData(void *runtime_data_v)
|
||||
{
|
||||
if (runtime_data_v == NULL) {
|
||||
if (runtime_data_v == nullptr) {
|
||||
return;
|
||||
}
|
||||
MultiresRuntimeData *runtime_data = (MultiresRuntimeData *)runtime_data_v;
|
||||
if (runtime_data->subdiv != NULL) {
|
||||
if (runtime_data->subdiv != nullptr) {
|
||||
BKE_subdiv_free(runtime_data->subdiv);
|
||||
}
|
||||
MEM_freeN(runtime_data);
|
||||
|
@ -106,8 +106,9 @@ static void freeData(ModifierData *md)
|
|||
static MultiresRuntimeData *multires_ensure_runtime(MultiresModifierData *mmd)
|
||||
{
|
||||
MultiresRuntimeData *runtime_data = (MultiresRuntimeData *)mmd->modifier.runtime;
|
||||
if (runtime_data == NULL) {
|
||||
runtime_data = MEM_callocN(sizeof(*runtime_data), "subsurf runtime");
|
||||
if (runtime_data == nullptr) {
|
||||
runtime_data = static_cast<MultiresRuntimeData *>(
|
||||
MEM_callocN(sizeof(*runtime_data), __func__));
|
||||
mmd->modifier.runtime = runtime_data;
|
||||
}
|
||||
return runtime_data;
|
||||
|
@ -189,8 +190,8 @@ static Mesh *multires_as_ccg(MultiresModifierData *mmd,
|
|||
/* NOTE: CCG becomes an owner of Subdiv descriptor, so can not share
|
||||
* this pointer. Not sure if it's needed, but might have a second look
|
||||
* on the ownership model here. */
|
||||
MultiresRuntimeData *runtime_data = mmd->modifier.runtime;
|
||||
runtime_data->subdiv = NULL;
|
||||
MultiresRuntimeData *runtime_data = static_cast<MultiresRuntimeData *>(mmd->modifier.runtime);
|
||||
runtime_data->subdiv = nullptr;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -210,7 +211,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
MultiresRuntimeData *runtime_data = multires_ensure_runtime(mmd);
|
||||
Subdiv *subdiv = subdiv_descriptor_ensure(mmd, &subdiv_settings, mesh);
|
||||
if (subdiv == NULL) {
|
||||
if (subdiv == nullptr) {
|
||||
/* Happens on bad topology, ut also on empty input mesh. */
|
||||
return result;
|
||||
}
|
||||
|
@ -235,7 +236,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
* stroke: i.e. when exiting blender right after stroke is done.
|
||||
* Annoying and not so much black-boxed as far as sculpting goes, and
|
||||
* surely there is a better way of solving this. */
|
||||
if (ctx->object->sculpt != NULL) {
|
||||
if (ctx->object->sculpt != nullptr) {
|
||||
SculptSession *sculpt_session = ctx->object->sculpt;
|
||||
sculpt_session->subdiv_ccg = result->runtime.subdiv_ccg;
|
||||
sculpt_session->multires.active = true;
|
||||
|
@ -243,9 +244,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
sculpt_session->multires.level = mmd->sculptlvl;
|
||||
sculpt_session->totvert = mesh->totvert;
|
||||
sculpt_session->totpoly = mesh->totpoly;
|
||||
sculpt_session->mvert = NULL;
|
||||
sculpt_session->mpoly = NULL;
|
||||
sculpt_session->mloop = NULL;
|
||||
sculpt_session->mvert = nullptr;
|
||||
sculpt_session->mpoly = nullptr;
|
||||
sculpt_session->mloop = nullptr;
|
||||
}
|
||||
// BKE_subdiv_stats_print(&subdiv->stats);
|
||||
}
|
||||
|
@ -260,8 +261,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
result = multires_as_mesh(mmd, ctx, mesh, subdiv);
|
||||
|
||||
if (use_clnors) {
|
||||
float(*lnors)[3] = CustomData_get_layer(&result->ldata, CD_NORMAL);
|
||||
BLI_assert(lnors != NULL);
|
||||
float(*lnors)[3] = static_cast<float(*)[3]>(CustomData_get_layer(&result->ldata, CD_NORMAL));
|
||||
BLI_assert(lnors != nullptr);
|
||||
BKE_mesh_set_custom_normals(result, lnors);
|
||||
CustomData_set_layer_flag(&mesh->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||
CustomData_set_layer_flag(&result->ldata, CD_NORMAL, CD_FLAG_TEMPORARY);
|
||||
|
@ -306,7 +307,7 @@ static void deformMatrices(ModifierData *md,
|
|||
|
||||
MultiresRuntimeData *runtime_data = multires_ensure_runtime(mmd);
|
||||
Subdiv *subdiv = subdiv_descriptor_ensure(mmd, &subdiv_settings, mesh);
|
||||
if (subdiv == NULL) {
|
||||
if (subdiv == nullptr) {
|
||||
/* Happens on bad topology, ut also on empty input mesh. */
|
||||
return;
|
||||
}
|
||||
|
@ -322,7 +323,7 @@ static void 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);
|
||||
|
||||
|
@ -337,7 +338,7 @@ static void panel_draw(const bContext *C, Panel *panel)
|
|||
uiItemR(col, ptr, "use_sculpt_base_mesh", 0, IFACE_("Sculpt Base Mesh"), ICON_NONE);
|
||||
UI_block_lock_clear(block);
|
||||
|
||||
uiItemR(layout, ptr, "show_only_control_edges", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "show_only_control_edges", 0, nullptr, ICON_NONE);
|
||||
|
||||
modifier_panel_end(layout, ptr);
|
||||
}
|
||||
|
@ -370,7 +371,7 @@ static void subdivisions_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
"OBJECT_OT_multires_subdivide",
|
||||
IFACE_("Subdivide"),
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_EXEC_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
|
@ -382,7 +383,7 @@ static void subdivisions_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
"OBJECT_OT_multires_subdivide",
|
||||
IFACE_("Simple"),
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_EXEC_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
|
@ -392,7 +393,7 @@ static void subdivisions_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
"OBJECT_OT_multires_subdivide",
|
||||
IFACE_("Linear"),
|
||||
ICON_NONE,
|
||||
NULL,
|
||||
nullptr,
|
||||
WM_OP_EXEC_DEFAULT,
|
||||
0,
|
||||
&op_ptr);
|
||||
|
@ -425,7 +426,7 @@ static void generate_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiLayout *col, *row;
|
||||
uiLayout *layout = panel->layout;
|
||||
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
||||
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
||||
MultiresModifierData *mmd = (MultiresModifierData *)ptr->data;
|
||||
|
||||
bool is_external = RNA_boolean_get(ptr, "is_external");
|
||||
|
@ -441,7 +442,7 @@ static void generate_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiItemO(row, IFACE_("Pack External"), ICON_NONE, "OBJECT_OT_multires_external_pack");
|
||||
uiLayoutSetPropSep(col, true);
|
||||
row = uiLayoutRow(col, false);
|
||||
uiItemR(row, ptr, "filepath", 0, NULL, ICON_NONE);
|
||||
uiItemR(row, ptr, "filepath", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
else {
|
||||
uiItemO(col, IFACE_("Save External..."), ICON_NONE, "OBJECT_OT_multires_external_save");
|
||||
|
@ -453,7 +454,7 @@ static void advanced_panel_draw(const bContext *UNUSED(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 has_displacement = RNA_int_get(ptr, "total_levels") != 0;
|
||||
|
||||
|
@ -461,27 +462,27 @@ static void advanced_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiLayoutSetActive(layout, !has_displacement);
|
||||
|
||||
uiItemR(layout, ptr, "quality", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "quality", 0, nullptr, ICON_NONE);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiLayoutSetActive(col, true);
|
||||
uiItemR(col, ptr, "uv_smooth", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "boundary_smooth", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "uv_smooth", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "boundary_smooth", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "use_creases", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_custom_normals", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_creases", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "use_custom_normals", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Multires, panel_draw);
|
||||
modifier_subpanel_register(
|
||||
region_type, "subdivide", "Subdivision", NULL, subdivisions_panel_draw, panel_type);
|
||||
modifier_subpanel_register(region_type, "shape", "Shape", NULL, shape_panel_draw, panel_type);
|
||||
region_type, "subdivide", "Subdivision", nullptr, subdivisions_panel_draw, panel_type);
|
||||
modifier_subpanel_register(region_type, "shape", "Shape", nullptr, shape_panel_draw, panel_type);
|
||||
modifier_subpanel_register(
|
||||
region_type, "generate", "Generate", NULL, generate_panel_draw, panel_type);
|
||||
region_type, "generate", "Generate", nullptr, generate_panel_draw, panel_type);
|
||||
modifier_subpanel_register(
|
||||
region_type, "advanced", "Advanced", NULL, advanced_panel_draw, panel_type);
|
||||
region_type, "advanced", "Advanced", nullptr, advanced_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
ModifierTypeInfo modifierType_Multires = {
|
||||
|
@ -496,24 +497,24 @@ ModifierTypeInfo modifierType_Multires = {
|
|||
|
||||
/* copyData */ copyData,
|
||||
|
||||
/* deformVerts */ NULL,
|
||||
/* deformVerts */ nullptr,
|
||||
/* deformMatrices */ deformMatrices,
|
||||
/* deformVertsEM */ NULL,
|
||||
/* deformMatricesEM */ NULL,
|
||||
/* 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,
|
||||
/* foreachIDLink */ nullptr,
|
||||
/* foreachTexLink */ nullptr,
|
||||
/* freeRuntimeData */ freeRuntimeData,
|
||||
/* 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"
|
||||
|
||||
|
@ -46,7 +46,7 @@ void MOD_init_texture(MappingInfoModifierData *dmd, const ModifierEvalContext *c
|
|||
{
|
||||
Tex *tex = dmd->texture;
|
||||
|
||||
if (tex == NULL) {
|
||||
if (tex == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd,
|
|||
float mapref_imat[4][4];
|
||||
|
||||
if (texmapping == MOD_DISP_MAP_OBJECT) {
|
||||
if (dmd->map_object != NULL) {
|
||||
if (dmd->map_object != nullptr) {
|
||||
Object *map_object = dmd->map_object;
|
||||
if (dmd->map_bone[0] != '\0') {
|
||||
bPoseChannel *pchan = BKE_pose_channel_find_name(map_object->pose, dmd->map_bone);
|
||||
|
@ -102,7 +102,8 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd,
|
|||
char uvname[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
|
||||
CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, dmd->uvlayer_name, uvname);
|
||||
const MLoopUV *mloop_uv = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPUV, uvname);
|
||||
const MLoopUV *mloop_uv = static_cast<const MLoopUV *>(
|
||||
CustomData_get_layer_named(&mesh->ldata, CD_MLOOPUV, uvname));
|
||||
|
||||
/* verts are given the UV from the first face that uses them */
|
||||
for (i = 0, mp = mpoly; i < polys_num; i++, mp++) {
|
||||
|
@ -134,17 +135,17 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd,
|
|||
for (i = 0; i < verts_num; i++, mv++, r_texco++) {
|
||||
switch (texmapping) {
|
||||
case MOD_DISP_MAP_LOCAL:
|
||||
copy_v3_v3(*r_texco, cos != NULL ? *cos : mv->co);
|
||||
copy_v3_v3(*r_texco, cos != nullptr ? *cos : mv->co);
|
||||
break;
|
||||
case MOD_DISP_MAP_GLOBAL:
|
||||
mul_v3_m4v3(*r_texco, ob->obmat, cos != NULL ? *cos : mv->co);
|
||||
mul_v3_m4v3(*r_texco, ob->obmat, cos != nullptr ? *cos : mv->co);
|
||||
break;
|
||||
case MOD_DISP_MAP_OBJECT:
|
||||
mul_v3_m4v3(*r_texco, ob->obmat, cos != NULL ? *cos : mv->co);
|
||||
mul_v3_m4v3(*r_texco, ob->obmat, cos != nullptr ? *cos : mv->co);
|
||||
mul_m4_v3(mapref_imat, *r_texco);
|
||||
break;
|
||||
}
|
||||
if (cos != NULL) {
|
||||
if (cos != nullptr) {
|
||||
cos++;
|
||||
}
|
||||
}
|
||||
|
@ -154,8 +155,8 @@ void MOD_previous_vcos_store(ModifierData *md, const float (*vert_coords)[3])
|
|||
{
|
||||
while ((md = md->next) && md->type == eModifierType_Armature) {
|
||||
ArmatureModifierData *amd = (ArmatureModifierData *)md;
|
||||
if (amd->multi && amd->vert_coords_prev == NULL) {
|
||||
amd->vert_coords_prev = MEM_dupallocN(vert_coords);
|
||||
if (amd->multi && amd->vert_coords_prev == nullptr) {
|
||||
amd->vert_coords_prev = static_cast<float(*)[3]>(MEM_dupallocN(vert_coords));
|
||||
}
|
||||
else {
|
||||
break;
|
||||
|
@ -171,25 +172,26 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob,
|
|||
const int verts_num,
|
||||
const bool use_orco)
|
||||
{
|
||||
if (mesh != NULL) {
|
||||
if (mesh != nullptr) {
|
||||
/* pass */
|
||||
}
|
||||
else if (ob->type == OB_MESH) {
|
||||
if (em) {
|
||||
mesh = BKE_mesh_wrapper_from_editmesh_with_coords(em, NULL, vertexCos, ob->data);
|
||||
mesh = BKE_mesh_wrapper_from_editmesh_with_coords(
|
||||
em, nullptr, vertexCos, static_cast<const Mesh *>(ob->data));
|
||||
}
|
||||
else {
|
||||
/* TODO(sybren): after modifier conversion of DM to Mesh is done, check whether
|
||||
* we really need a copy here. Maybe the CoW ob->data can be directly used. */
|
||||
Mesh *mesh_prior_modifiers = BKE_object_get_pre_modified_mesh(ob);
|
||||
mesh = (Mesh *)BKE_id_copy_ex(NULL,
|
||||
mesh = (Mesh *)BKE_id_copy_ex(nullptr,
|
||||
&mesh_prior_modifiers->id,
|
||||
NULL,
|
||||
nullptr,
|
||||
(LIB_ID_COPY_LOCALIZE | LIB_ID_COPY_CD_REFERENCE));
|
||||
mesh->runtime.deformed_only = 1;
|
||||
}
|
||||
|
||||
if (em != NULL) {
|
||||
if (em != nullptr) {
|
||||
/* pass */
|
||||
}
|
||||
/* TODO(sybren): after modifier conversion of DM to Mesh is done, check whether
|
||||
|
@ -210,9 +212,9 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob,
|
|||
/* Currently, that may not be the case every time
|
||||
* (texts e.g. tend to give issues,
|
||||
* also when deforming curve points instead of generated curve geometry... ). */
|
||||
if (mesh != NULL && mesh->totvert != verts_num) {
|
||||
BKE_id_free(NULL, mesh);
|
||||
mesh = NULL;
|
||||
if (mesh != nullptr && mesh->totvert != verts_num) {
|
||||
BKE_id_free(nullptr, mesh);
|
||||
mesh = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -232,7 +234,7 @@ void MOD_get_vgroup(
|
|||
*dvert = BKE_mesh_deform_verts(mesh);
|
||||
}
|
||||
else {
|
||||
*dvert = NULL;
|
||||
*dvert = nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -241,7 +243,7 @@ void MOD_get_vgroup(
|
|||
*dvert = BKE_lattice_deform_verts_get(ob);
|
||||
}
|
||||
else {
|
||||
*dvert = NULL;
|
||||
*dvert = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,7 +253,7 @@ void MOD_depsgraph_update_object_bone_relation(struct DepsNodeHandle *node,
|
|||
const char *bonename,
|
||||
const char *description)
|
||||
{
|
||||
if (object == NULL) {
|
||||
if (object == nullptr) {
|
||||
return;
|
||||
}
|
||||
if (bonename[0] != '\0' && object->type == OB_ARMATURE) {
|
|
@ -71,7 +71,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
|||
UVProjectModifierData *umd = (UVProjectModifierData *)md;
|
||||
bool do_add_own_transform = false;
|
||||
for (int i = 0; i < umd->projectors_num; i++) {
|
||||
if (umd->projectors[i] != NULL) {
|
||||
if (umd->projectors[i] != nullptr) {
|
||||
DEG_add_object_relation(
|
||||
ctx->node, umd->projectors[i], DEG_OB_COMP_TRANSFORM, "UV Project Modifier");
|
||||
do_add_own_transform = true;
|
||||
|
@ -82,12 +82,12 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
|||
}
|
||||
}
|
||||
|
||||
typedef struct Projector {
|
||||
struct Projector {
|
||||
Object *ob; /* object this projector is derived from */
|
||||
float projmat[4][4]; /* projection matrix */
|
||||
float normal[3]; /* projector normal in world space */
|
||||
void *uci; /* optional uv-project info (panorama projection) */
|
||||
} Projector;
|
||||
};
|
||||
|
||||
static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
||||
const ModifierEvalContext *UNUSED(ctx),
|
||||
|
@ -95,7 +95,6 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
|||
Mesh *mesh)
|
||||
{
|
||||
float(*coords)[3], (*co)[3];
|
||||
MLoopUV *mloop_uv;
|
||||
int i, verts_num, polys_num, loops_num;
|
||||
const MPoly *mp;
|
||||
Projector projectors[MOD_UVPROJECT_MAXPROJECTORS];
|
||||
|
@ -108,7 +107,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
|||
int free_uci = 0;
|
||||
|
||||
for (i = 0; i < umd->projectors_num; i++) {
|
||||
if (umd->projectors[i] != NULL) {
|
||||
if (umd->projectors[i] != nullptr) {
|
||||
projectors[projectors_num++].ob = umd->projectors[i];
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +120,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
|||
* (e.g. if a preceding modifier could not preserve it). */
|
||||
if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) {
|
||||
CustomData_add_layer_named(
|
||||
&mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, NULL, mesh->totloop, umd->uvlayer_name);
|
||||
&mesh->ldata, CD_MLOOPUV, CD_SET_DEFAULT, nullptr, mesh->totloop, umd->uvlayer_name);
|
||||
}
|
||||
|
||||
/* make sure we're using an existing layer */
|
||||
|
@ -131,17 +130,18 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
|||
for (i = 0; i < projectors_num; i++) {
|
||||
float tmpmat[4][4];
|
||||
float offsetmat[4][4];
|
||||
Camera *cam = NULL;
|
||||
Camera *cam = nullptr;
|
||||
/* calculate projection matrix */
|
||||
invert_m4_m4(projectors[i].projmat, projectors[i].ob->obmat);
|
||||
|
||||
projectors[i].uci = NULL;
|
||||
projectors[i].uci = nullptr;
|
||||
|
||||
if (projectors[i].ob->type == OB_CAMERA) {
|
||||
cam = (Camera *)projectors[i].ob->data;
|
||||
if (cam->type == CAM_PANO) {
|
||||
projectors[i].uci = BLI_uvproject_camera_info(projectors[i].ob, NULL, aspx, aspy);
|
||||
BLI_uvproject_camera_info_scale(projectors[i].uci, scax, scay);
|
||||
projectors[i].uci = BLI_uvproject_camera_info(projectors[i].ob, nullptr, aspx, aspy);
|
||||
BLI_uvproject_camera_info_scale(
|
||||
static_cast<ProjCameraInfo *>(projectors[i].uci), scax, scay);
|
||||
free_uci = 1;
|
||||
}
|
||||
else {
|
||||
|
@ -185,8 +185,8 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
|||
loops_num = mesh->totloop;
|
||||
|
||||
/* make sure we are not modifying the original UV map */
|
||||
mloop_uv = CustomData_duplicate_referenced_layer_named(
|
||||
&mesh->ldata, CD_MLOOPUV, uvname, loops_num);
|
||||
MLoopUV *mloop_uv = static_cast<MLoopUV *>(
|
||||
CustomData_duplicate_referenced_layer_named(&mesh->ldata, CD_MLOOPUV, uvname, loops_num));
|
||||
|
||||
coords = BKE_mesh_vert_coords_alloc(mesh, &verts_num);
|
||||
|
||||
|
@ -196,7 +196,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
|||
}
|
||||
|
||||
/* if only one projector, project coords to UVs */
|
||||
if (projectors_num == 1 && projectors[0].uci == NULL) {
|
||||
if (projectors_num == 1 && projectors[0].uci == nullptr) {
|
||||
for (i = 0, co = coords; i < verts_num; i++, co++) {
|
||||
mul_project_m4_v3(projectors[0].projmat, *co);
|
||||
}
|
||||
|
@ -213,7 +213,8 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
|||
do {
|
||||
uint lidx = mp->loopstart + fidx;
|
||||
uint vidx = loops[lidx].v;
|
||||
BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], projectors[0].uci);
|
||||
BLI_uvproject_from_camera(
|
||||
mloop_uv[lidx].uv, coords[vidx], static_cast<ProjCameraInfo *>(projectors[0].uci));
|
||||
} while (fidx--);
|
||||
}
|
||||
else {
|
||||
|
@ -256,7 +257,8 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
|
|||
do {
|
||||
uint lidx = mp->loopstart + fidx;
|
||||
uint vidx = loops[lidx].v;
|
||||
BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], best_projector->uci);
|
||||
BLI_uvproject_from_camera(
|
||||
mloop_uv[lidx].uv, coords[vidx], static_cast<ProjCameraInfo *>(best_projector->uci));
|
||||
} while (fidx--);
|
||||
}
|
||||
else {
|
||||
|
@ -308,7 +310,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemPointerR(layout, ptr, "uv_layer", &obj_data_ptr, "uv_layers", NULL, ICON_NONE);
|
||||
uiItemPointerR(layout, ptr, "uv_layer", &obj_data_ptr, "uv_layers", nullptr, ICON_NONE);
|
||||
|
||||
/* Aspect and Scale are only used for camera projectors. */
|
||||
bool has_camera = false;
|
||||
|
@ -323,17 +325,17 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
sub = uiLayoutColumn(layout, true);
|
||||
uiLayoutSetActive(sub, has_camera);
|
||||
uiItemR(sub, ptr, "aspect_x", 0, NULL, ICON_NONE);
|
||||
uiItemR(sub, ptr, "aspect_x", 0, nullptr, ICON_NONE);
|
||||
uiItemR(sub, ptr, "aspect_y", 0, IFACE_("Y"), ICON_NONE);
|
||||
|
||||
sub = uiLayoutColumn(layout, true);
|
||||
uiLayoutSetActive(sub, has_camera);
|
||||
uiItemR(sub, ptr, "scale_x", 0, NULL, ICON_NONE);
|
||||
uiItemR(sub, ptr, "scale_x", 0, nullptr, ICON_NONE);
|
||||
uiItemR(sub, ptr, "scale_y", 0, IFACE_("Y"), ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "projector_count", 0, IFACE_("Projectors"), ICON_NONE);
|
||||
RNA_BEGIN (ptr, projector_ptr, "projectors") {
|
||||
uiItemR(layout, &projector_ptr, "object", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, &projector_ptr, "object", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
RNA_END;
|
||||
|
||||
|
@ -357,24 +359,24 @@ ModifierTypeInfo modifierType_UVProject = {
|
|||
|
||||
/* 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,
|
||||
/* freeData */ nullptr,
|
||||
/* isDisabled */ nullptr,
|
||||
/* 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,
|
||||
};
|
|
@ -4,7 +4,7 @@
|
|||
* \ingroup modifiers
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
|
@ -79,7 +79,7 @@ static void matrix_from_obj_pchan(float mat[4][4], Object *ob, const char *bonen
|
|||
}
|
||||
}
|
||||
|
||||
typedef struct UVWarpData {
|
||||
struct UVWarpData {
|
||||
const MPoly *mpoly;
|
||||
const MLoop *mloop;
|
||||
MLoopUV *mloopuv;
|
||||
|
@ -89,13 +89,13 @@ typedef struct UVWarpData {
|
|||
|
||||
float (*warp_mat)[4];
|
||||
bool invert_vgroup;
|
||||
} UVWarpData;
|
||||
};
|
||||
|
||||
static void uv_warp_compute(void *__restrict userdata,
|
||||
const int i,
|
||||
const TaskParallelTLS *__restrict UNUSED(tls))
|
||||
{
|
||||
const UVWarpData *data = userdata;
|
||||
const UVWarpData *data = static_cast<const UVWarpData *>(userdata);
|
||||
|
||||
const MPoly *mp = &data->mpoly[i];
|
||||
const MLoop *ml = &data->mloop[mp->loopstart];
|
||||
|
@ -130,7 +130,6 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
{
|
||||
UVWarpModifierData *umd = (UVWarpModifierData *)md;
|
||||
int polys_num, loops_num;
|
||||
MLoopUV *mloopuv;
|
||||
const MDeformVert *dvert;
|
||||
int defgrp_index;
|
||||
char uvname[MAX_CUSTOMDATA_LAYER_NAME];
|
||||
|
@ -144,7 +143,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
return mesh;
|
||||
}
|
||||
|
||||
if (!ELEM(NULL, umd->object_src, umd->object_dst)) {
|
||||
if (!ELEM(nullptr, umd->object_src, umd->object_dst)) {
|
||||
float mat_src[4][4];
|
||||
float mat_dst[4][4];
|
||||
float imat_dst[4][4];
|
||||
|
@ -199,19 +198,19 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
loops_num = mesh->totloop;
|
||||
|
||||
/* make sure we are not modifying the original UV map */
|
||||
mloopuv = CustomData_duplicate_referenced_layer_named(
|
||||
&mesh->ldata, CD_MLOOPUV, uvname, loops_num);
|
||||
MLoopUV *mloopuv = static_cast<MLoopUV *>(
|
||||
CustomData_duplicate_referenced_layer_named(&mesh->ldata, CD_MLOOPUV, uvname, loops_num));
|
||||
MOD_get_vgroup(ctx->object, mesh, umd->vgroup_name, &dvert, &defgrp_index);
|
||||
|
||||
UVWarpData data = {
|
||||
.mpoly = polys,
|
||||
.mloop = loops,
|
||||
.mloopuv = mloopuv,
|
||||
.dvert = dvert,
|
||||
.defgrp_index = defgrp_index,
|
||||
.warp_mat = warp_mat,
|
||||
.invert_vgroup = invert_vgroup,
|
||||
};
|
||||
UVWarpData data{};
|
||||
data.mpoly = polys;
|
||||
data.mloop = loops;
|
||||
data.mloopuv = mloopuv;
|
||||
data.dvert = dvert;
|
||||
data.defgrp_index = defgrp_index;
|
||||
data.warp_mat = warp_mat;
|
||||
data.invert_vgroup = invert_vgroup;
|
||||
|
||||
TaskParallelSettings settings;
|
||||
BLI_parallel_range_settings_defaults(&settings);
|
||||
settings.use_threading = (polys_num > 1000);
|
||||
|
@ -255,31 +254,31 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemPointerR(layout, ptr, "uv_layer", &obj_data_ptr, "uv_layers", NULL, ICON_NONE);
|
||||
uiItemPointerR(layout, ptr, "uv_layer", &obj_data_ptr, "uv_layers", nullptr, ICON_NONE);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, ptr, "center", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "center", 0, nullptr, ICON_NONE);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, ptr, "axis_u", 0, IFACE_("Axis U"), ICON_NONE);
|
||||
uiItemR(col, ptr, "axis_v", 0, IFACE_("V"), ICON_NONE);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, ptr, "object_from", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "object_from", 0, nullptr, ICON_NONE);
|
||||
warp_obj_ptr = RNA_pointer_get(ptr, "object_from");
|
||||
if (!RNA_pointer_is_null(&warp_obj_ptr) && RNA_enum_get(&warp_obj_ptr, "type") == OB_ARMATURE) {
|
||||
PointerRNA warp_obj_data_ptr = RNA_pointer_get(&warp_obj_ptr, "data");
|
||||
uiItemPointerR(col, ptr, "bone_from", &warp_obj_data_ptr, "bones", NULL, ICON_NONE);
|
||||
uiItemPointerR(col, ptr, "bone_from", &warp_obj_data_ptr, "bones", nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
uiItemR(col, ptr, "object_to", 0, IFACE_("To"), ICON_NONE);
|
||||
warp_obj_ptr = RNA_pointer_get(ptr, "object_to");
|
||||
if (!RNA_pointer_is_null(&warp_obj_ptr) && RNA_enum_get(&warp_obj_ptr, "type") == OB_ARMATURE) {
|
||||
PointerRNA warp_obj_data_ptr = RNA_pointer_get(&warp_obj_ptr, "data");
|
||||
uiItemPointerR(col, ptr, "bone_to", &warp_obj_data_ptr, "bones", NULL, ICON_NONE);
|
||||
uiItemPointerR(col, ptr, "bone_to", &warp_obj_data_ptr, "bones", 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);
|
||||
}
|
||||
|
@ -288,20 +287,20 @@ static void transform_panel_draw(const bContext *UNUSED(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, "offset", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "scale", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "offset", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "scale", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "rotation", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
static void panelRegister(ARegionType *region_type)
|
||||
{
|
||||
PanelType *panel_type = modifier_panel_register(region_type, eModifierType_UVWarp, panel_draw);
|
||||
modifier_subpanel_register(
|
||||
region_type, "offset", "Transform", NULL, transform_panel_draw, panel_type);
|
||||
region_type, "offset", "Transform", nullptr, transform_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
ModifierTypeInfo modifierType_UVWarp = {
|
||||
|
@ -316,24 +315,24 @@ ModifierTypeInfo modifierType_UVWarp = {
|
|||
|
||||
/* 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,
|
||||
/* freeData */ nullptr,
|
||||
/* isDisabled */ nullptr,
|
||||
/* 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,
|
||||
};
|
|
@ -39,10 +39,10 @@
|
|||
|
||||
#define CLNORS_VALID_VEC_LEN (1e-6f)
|
||||
|
||||
typedef struct ModePair {
|
||||
struct ModePair {
|
||||
float val; /* Contains mode based value (face area / corner angle). */
|
||||
int index; /* Index value per poly or per loop. */
|
||||
} ModePair;
|
||||
};
|
||||
|
||||
/* Sorting function used in modifier, sorts in decreasing order. */
|
||||
static int modepair_cmp_by_val_inverse(const void *p1, const void *p2)
|
||||
|
@ -55,21 +55,21 @@ static int modepair_cmp_by_val_inverse(const void *p1, const void *p2)
|
|||
|
||||
/* There will be one of those per vertex
|
||||
* (simple case, computing one normal per vertex), or per smooth fan. */
|
||||
typedef struct WeightedNormalDataAggregateItem {
|
||||
struct WeightedNormalDataAggregateItem {
|
||||
float normal[3];
|
||||
|
||||
int loops_num; /* Count number of loops using this item so far. */
|
||||
float curr_val; /* Current max val for this item. */
|
||||
int curr_strength; /* Current max strength encountered for this item. */
|
||||
} WeightedNormalDataAggregateItem;
|
||||
};
|
||||
|
||||
#define NUM_CACHED_INVERSE_POWERS_OF_WEIGHT 128
|
||||
|
||||
typedef struct WeightedNormalData {
|
||||
const int verts_num;
|
||||
const int edges_num;
|
||||
const int loops_num;
|
||||
const int polys_num;
|
||||
struct WeightedNormalData {
|
||||
int verts_num;
|
||||
int edges_num;
|
||||
int loops_num;
|
||||
int polys_num;
|
||||
|
||||
const MVert *mvert;
|
||||
const float (*vert_normals)[3];
|
||||
|
@ -77,19 +77,19 @@ typedef struct WeightedNormalData {
|
|||
|
||||
const MLoop *mloop;
|
||||
short (*clnors)[2];
|
||||
const bool has_clnors; /* True if clnors already existed, false if we had to create them. */
|
||||
const float split_angle;
|
||||
bool has_clnors; /* True if clnors already existed, false if we had to create them. */
|
||||
float split_angle;
|
||||
|
||||
const MPoly *mpoly;
|
||||
const float (*polynors)[3];
|
||||
const int *poly_strength;
|
||||
|
||||
const MDeformVert *dvert;
|
||||
const int defgrp_index;
|
||||
const bool use_invert_vgroup;
|
||||
int defgrp_index;
|
||||
bool use_invert_vgroup;
|
||||
|
||||
const float weight;
|
||||
const short mode;
|
||||
float weight;
|
||||
short mode;
|
||||
|
||||
/* Lower-level, internal processing data. */
|
||||
float cached_inverse_powers_of_weight[NUM_CACHED_INVERSE_POWERS_OF_WEIGHT];
|
||||
|
@ -99,7 +99,7 @@ typedef struct WeightedNormalData {
|
|||
ModePair *mode_pair;
|
||||
|
||||
int *loop_to_poly;
|
||||
} WeightedNormalData;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check strength of given poly compared to those found so far for that given item
|
||||
|
@ -109,7 +109,7 @@ static bool check_item_poly_strength(WeightedNormalData *wn_data,
|
|||
WeightedNormalDataAggregateItem *item_data,
|
||||
const int mp_index)
|
||||
{
|
||||
BLI_assert(wn_data->poly_strength != NULL);
|
||||
BLI_assert(wn_data->poly_strength != nullptr);
|
||||
|
||||
const int mp_strength = wn_data->poly_strength[mp_index];
|
||||
|
||||
|
@ -141,9 +141,9 @@ static void aggregate_item_normal(WeightedNormalModifierData *wnmd,
|
|||
|
||||
float *cached_inverse_powers_of_weight = wn_data->cached_inverse_powers_of_weight;
|
||||
|
||||
const bool has_vgroup = dvert != NULL;
|
||||
const bool has_vgroup = dvert != nullptr;
|
||||
const bool vert_of_group = has_vgroup &&
|
||||
BKE_defvert_find_index(&dvert[mv_index], defgrp_index) != NULL;
|
||||
BKE_defvert_find_index(&dvert[mv_index], defgrp_index) != nullptr;
|
||||
|
||||
if (has_vgroup &&
|
||||
((vert_of_group && use_invert_vgroup) || (!vert_of_group && !use_invert_vgroup))) {
|
||||
|
@ -204,23 +204,24 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
|
|||
|
||||
const bool has_clnors = wn_data->has_clnors;
|
||||
const float split_angle = wn_data->split_angle;
|
||||
MLoopNorSpaceArray lnors_spacearr = {NULL};
|
||||
MLoopNorSpaceArray lnors_spacearr = {nullptr};
|
||||
|
||||
const bool keep_sharp = (wnmd->flag & MOD_WEIGHTEDNORMAL_KEEP_SHARP) != 0;
|
||||
const bool use_face_influence = (wnmd->flag & MOD_WEIGHTEDNORMAL_FACE_INFLUENCE) != 0 &&
|
||||
poly_strength != NULL;
|
||||
const bool has_vgroup = dvert != NULL;
|
||||
poly_strength != nullptr;
|
||||
const bool has_vgroup = dvert != nullptr;
|
||||
|
||||
float(*loop_normals)[3] = NULL;
|
||||
float(*loop_normals)[3] = nullptr;
|
||||
|
||||
WeightedNormalDataAggregateItem *items_data = NULL;
|
||||
WeightedNormalDataAggregateItem *items_data = nullptr;
|
||||
int items_num = 0;
|
||||
if (keep_sharp) {
|
||||
BLI_bitmap *done_loops = BLI_BITMAP_NEW(loops_num, __func__);
|
||||
|
||||
/* This will give us loop normal spaces,
|
||||
* we do not actually care about computed loop_normals for now... */
|
||||
loop_normals = MEM_calloc_arrayN((size_t)loops_num, sizeof(*loop_normals), __func__);
|
||||
loop_normals = static_cast<float(*)[3]>(
|
||||
MEM_calloc_arrayN((size_t)loops_num, sizeof(*loop_normals), __func__));
|
||||
BKE_mesh_normals_loop_split(mvert,
|
||||
wn_data->vert_normals,
|
||||
verts_num,
|
||||
|
@ -235,11 +236,12 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
|
|||
true,
|
||||
split_angle,
|
||||
&lnors_spacearr,
|
||||
has_clnors ? clnors : NULL,
|
||||
has_clnors ? clnors : nullptr,
|
||||
loop_to_poly);
|
||||
|
||||
items_num = lnors_spacearr.spaces_num;
|
||||
items_data = MEM_calloc_arrayN((size_t)items_num, sizeof(*items_data), __func__);
|
||||
items_data = static_cast<WeightedNormalDataAggregateItem *>(
|
||||
MEM_calloc_arrayN((size_t)items_num, sizeof(*items_data), __func__));
|
||||
|
||||
/* In this first loop, we assign each WeightedNormalDataAggregateItem
|
||||
* to its smooth fan of loops (aka lnor space). */
|
||||
|
@ -281,7 +283,8 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
|
|||
}
|
||||
else {
|
||||
items_num = verts_num;
|
||||
items_data = MEM_calloc_arrayN((size_t)items_num, sizeof(*items_data), __func__);
|
||||
items_data = static_cast<WeightedNormalDataAggregateItem *>(
|
||||
MEM_calloc_arrayN((size_t)items_num, sizeof(*items_data), __func__));
|
||||
if (use_face_influence) {
|
||||
for (int item_index = 0; item_index < items_num; item_index++) {
|
||||
items_data[item_index].curr_strength = FACE_STRENGTH_WEAK;
|
||||
|
@ -301,7 +304,9 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
|
|||
for (; ml_index < ml_index_end; ml_index++) {
|
||||
const int mv_index = mloop[ml_index].v;
|
||||
WeightedNormalDataAggregateItem *item_data =
|
||||
keep_sharp ? lnors_spacearr.lspacearr[ml_index]->user_data : &items_data[mv_index];
|
||||
keep_sharp ? static_cast<WeightedNormalDataAggregateItem *>(
|
||||
lnors_spacearr.lspacearr[ml_index]->user_data) :
|
||||
&items_data[mv_index];
|
||||
|
||||
aggregate_item_normal(
|
||||
wnmd, wn_data, item_data, mv_index, mp_index, mp_val, use_face_influence);
|
||||
|
@ -310,7 +315,7 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
|
|||
break;
|
||||
case MOD_WEIGHTEDNORMAL_MODE_ANGLE:
|
||||
case MOD_WEIGHTEDNORMAL_MODE_FACE_ANGLE:
|
||||
BLI_assert(loop_to_poly != NULL);
|
||||
BLI_assert(loop_to_poly != nullptr);
|
||||
|
||||
for (int i = 0; i < loops_num; i++) {
|
||||
const int ml_index = mode_pair[i].index;
|
||||
|
@ -319,7 +324,9 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
|
|||
const int mp_index = loop_to_poly[ml_index];
|
||||
const int mv_index = mloop[ml_index].v;
|
||||
WeightedNormalDataAggregateItem *item_data =
|
||||
keep_sharp ? lnors_spacearr.lspacearr[ml_index]->user_data : &items_data[mv_index];
|
||||
keep_sharp ? static_cast<WeightedNormalDataAggregateItem *>(
|
||||
lnors_spacearr.lspacearr[ml_index]->user_data) :
|
||||
&items_data[mv_index];
|
||||
|
||||
aggregate_item_normal(
|
||||
wnmd, wn_data, item_data, mv_index, mp_index, ml_val, use_face_influence);
|
||||
|
@ -342,7 +349,8 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
|
|||
* (before this modifier is applied, at start of this function),
|
||||
* so no need to recompute them here. */
|
||||
for (int ml_index = 0; ml_index < loops_num; ml_index++) {
|
||||
WeightedNormalDataAggregateItem *item_data = lnors_spacearr.lspacearr[ml_index]->user_data;
|
||||
WeightedNormalDataAggregateItem *item_data = static_cast<WeightedNormalDataAggregateItem *>(
|
||||
lnors_spacearr.lspacearr[ml_index]->user_data);
|
||||
if (!is_zero_v3(item_data->normal)) {
|
||||
copy_v3_v3(loop_normals[ml_index], item_data->normal);
|
||||
}
|
||||
|
@ -371,8 +379,8 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
|
|||
/* NOTE: in theory, we could avoid this extra allocation & copying...
|
||||
* But think we can live with it for now,
|
||||
* and it makes code simpler & cleaner. */
|
||||
float(*vert_normals)[3] = MEM_calloc_arrayN(
|
||||
(size_t)verts_num, sizeof(*loop_normals), __func__);
|
||||
float(*vert_normals)[3] = static_cast<float(*)[3]>(
|
||||
MEM_calloc_arrayN((size_t)verts_num, sizeof(*loop_normals), __func__));
|
||||
|
||||
for (int ml_index = 0; ml_index < loops_num; ml_index++) {
|
||||
const int mv_index = mloop[ml_index].v;
|
||||
|
@ -395,7 +403,8 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
|
|||
MEM_freeN(vert_normals);
|
||||
}
|
||||
else {
|
||||
loop_normals = MEM_calloc_arrayN((size_t)loops_num, sizeof(*loop_normals), __func__);
|
||||
loop_normals = static_cast<float(*)[3]>(
|
||||
MEM_calloc_arrayN((size_t)loops_num, sizeof(*loop_normals), __func__));
|
||||
|
||||
BKE_mesh_normals_loop_split(mvert,
|
||||
wn_data->vert_normals,
|
||||
|
@ -410,8 +419,8 @@ static void apply_weights_vertex_normal(WeightedNormalModifierData *wnmd,
|
|||
polys_num,
|
||||
true,
|
||||
split_angle,
|
||||
NULL,
|
||||
has_clnors ? clnors : NULL,
|
||||
nullptr,
|
||||
has_clnors ? clnors : nullptr,
|
||||
loop_to_poly);
|
||||
|
||||
for (int ml_index = 0; ml_index < loops_num; ml_index++) {
|
||||
|
@ -453,7 +462,8 @@ static void wn_face_area(WeightedNormalModifierData *wnmd, WeightedNormalData *w
|
|||
const MPoly *mp;
|
||||
int mp_index;
|
||||
|
||||
ModePair *face_area = MEM_malloc_arrayN((size_t)polys_num, sizeof(*face_area), __func__);
|
||||
ModePair *face_area = static_cast<ModePair *>(
|
||||
MEM_malloc_arrayN((size_t)polys_num, sizeof(*face_area), __func__));
|
||||
|
||||
ModePair *f_area = face_area;
|
||||
for (mp_index = 0, mp = mpoly; mp_index < polys_num; mp_index++, mp++, f_area++) {
|
||||
|
@ -479,14 +489,17 @@ static void wn_corner_angle(WeightedNormalModifierData *wnmd, WeightedNormalData
|
|||
const MPoly *mp;
|
||||
int mp_index;
|
||||
|
||||
int *loop_to_poly = MEM_malloc_arrayN((size_t)loops_num, sizeof(*loop_to_poly), __func__);
|
||||
int *loop_to_poly = static_cast<int *>(
|
||||
MEM_malloc_arrayN((size_t)loops_num, sizeof(*loop_to_poly), __func__));
|
||||
|
||||
ModePair *corner_angle = MEM_malloc_arrayN((size_t)loops_num, sizeof(*corner_angle), __func__);
|
||||
ModePair *corner_angle = static_cast<ModePair *>(
|
||||
MEM_malloc_arrayN((size_t)loops_num, sizeof(*corner_angle), __func__));
|
||||
|
||||
for (mp_index = 0, mp = mpoly; mp_index < polys_num; mp_index++, mp++) {
|
||||
const MLoop *ml_start = &mloop[mp->loopstart];
|
||||
|
||||
float *index_angle = MEM_malloc_arrayN((size_t)mp->totloop, sizeof(*index_angle), __func__);
|
||||
float *index_angle = static_cast<float *>(
|
||||
MEM_malloc_arrayN((size_t)mp->totloop, sizeof(*index_angle), __func__));
|
||||
BKE_mesh_calc_poly_angles(mp, ml_start, mvert, index_angle);
|
||||
|
||||
ModePair *c_angl = &corner_angle[mp->loopstart];
|
||||
|
@ -520,15 +533,18 @@ static void wn_face_with_angle(WeightedNormalModifierData *wnmd, WeightedNormalD
|
|||
const MPoly *mp;
|
||||
int mp_index;
|
||||
|
||||
int *loop_to_poly = MEM_malloc_arrayN((size_t)loops_num, sizeof(*loop_to_poly), __func__);
|
||||
int *loop_to_poly = static_cast<int *>(
|
||||
MEM_malloc_arrayN((size_t)loops_num, sizeof(*loop_to_poly), __func__));
|
||||
|
||||
ModePair *combined = MEM_malloc_arrayN((size_t)loops_num, sizeof(*combined), __func__);
|
||||
ModePair *combined = static_cast<ModePair *>(
|
||||
MEM_malloc_arrayN((size_t)loops_num, sizeof(*combined), __func__));
|
||||
|
||||
for (mp_index = 0, mp = mpoly; mp_index < polys_num; mp_index++, mp++) {
|
||||
const MLoop *ml_start = &mloop[mp->loopstart];
|
||||
|
||||
float face_area = BKE_mesh_calc_poly_area(mp, ml_start, mvert);
|
||||
float *index_angle = MEM_malloc_arrayN((size_t)mp->totloop, sizeof(*index_angle), __func__);
|
||||
float *index_angle = static_cast<float *>(
|
||||
MEM_malloc_arrayN((size_t)mp->totloop, sizeof(*index_angle), __func__));
|
||||
BKE_mesh_calc_poly_angles(mp, ml_start, mvert, index_angle);
|
||||
|
||||
ModePair *cmbnd = &combined[mp->loopstart];
|
||||
|
@ -573,7 +589,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
|
||||
Mesh *result;
|
||||
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);
|
||||
|
||||
const int verts_num = result->totvert;
|
||||
const int edges_num = result->totedge;
|
||||
|
@ -602,47 +618,47 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
|
||||
const float split_angle = mesh->smoothresh;
|
||||
short(*clnors)[2] = CustomData_get_layer(&result->ldata, CD_CUSTOMLOOPNORMAL);
|
||||
short(*clnors)[2] = static_cast<short(*)[2]>(
|
||||
CustomData_get_layer(&result->ldata, CD_CUSTOMLOOPNORMAL));
|
||||
|
||||
/* Keep info whether we had clnors,
|
||||
* it helps when generating clnor spaces and default normals. */
|
||||
const bool has_clnors = clnors != NULL;
|
||||
const bool has_clnors = clnors != nullptr;
|
||||
if (!clnors) {
|
||||
clnors = CustomData_add_layer(
|
||||
&result->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, NULL, loops_num);
|
||||
clnors = static_cast<short(*)[2]>(CustomData_add_layer(
|
||||
&result->ldata, CD_CUSTOMLOOPNORMAL, CD_SET_DEFAULT, nullptr, loops_num));
|
||||
}
|
||||
|
||||
const MDeformVert *dvert;
|
||||
int defgrp_index;
|
||||
MOD_get_vgroup(ctx->object, mesh, wnmd->defgrp_name, &dvert, &defgrp_index);
|
||||
|
||||
WeightedNormalData wn_data = {
|
||||
.verts_num = verts_num,
|
||||
.edges_num = edges_num,
|
||||
.loops_num = loops_num,
|
||||
.polys_num = polys_num,
|
||||
WeightedNormalData wn_data{};
|
||||
wn_data.verts_num = verts_num;
|
||||
wn_data.edges_num = edges_num;
|
||||
wn_data.loops_num = loops_num;
|
||||
wn_data.polys_num = polys_num;
|
||||
|
||||
.mvert = mvert,
|
||||
.vert_normals = BKE_mesh_vertex_normals_ensure(result),
|
||||
.medge = medge,
|
||||
wn_data.mvert = mvert;
|
||||
wn_data.vert_normals = BKE_mesh_vertex_normals_ensure(result);
|
||||
wn_data.medge = medge;
|
||||
|
||||
.mloop = mloop,
|
||||
.clnors = clnors,
|
||||
.has_clnors = has_clnors,
|
||||
.split_angle = split_angle,
|
||||
wn_data.mloop = mloop;
|
||||
wn_data.clnors = clnors;
|
||||
wn_data.has_clnors = has_clnors;
|
||||
wn_data.split_angle = split_angle;
|
||||
|
||||
.mpoly = mpoly,
|
||||
.polynors = BKE_mesh_poly_normals_ensure(mesh),
|
||||
.poly_strength = CustomData_get_layer_named(
|
||||
&result->pdata, CD_PROP_INT32, MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID),
|
||||
wn_data.mpoly = mpoly;
|
||||
wn_data.polynors = BKE_mesh_poly_normals_ensure(mesh);
|
||||
wn_data.poly_strength = static_cast<const int *>(CustomData_get_layer_named(
|
||||
&result->pdata, CD_PROP_INT32, MOD_WEIGHTEDNORMALS_FACEWEIGHT_CDLAYER_ID));
|
||||
|
||||
.dvert = dvert,
|
||||
.defgrp_index = defgrp_index,
|
||||
.use_invert_vgroup = (wnmd->flag & MOD_WEIGHTEDNORMAL_INVERT_VGROUP) != 0,
|
||||
wn_data.dvert = dvert;
|
||||
wn_data.defgrp_index = defgrp_index;
|
||||
wn_data.use_invert_vgroup = (wnmd->flag & MOD_WEIGHTEDNORMAL_INVERT_VGROUP) != 0;
|
||||
|
||||
.weight = weight,
|
||||
.mode = wnmd->mode,
|
||||
};
|
||||
wn_data.weight = weight;
|
||||
wn_data.mode = wnmd->mode;
|
||||
|
||||
switch (wnmd->mode) {
|
||||
case MOD_WEIGHTEDNORMAL_MODE_FACE:
|
||||
|
@ -704,16 +720,16 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "mode", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "weight", 0, IFACE_("Weight"), ICON_NONE);
|
||||
uiItemR(layout, ptr, "thresh", 0, IFACE_("Threshold"), ICON_NONE);
|
||||
|
||||
col = uiLayoutColumn(layout, false);
|
||||
uiItemR(col, ptr, "keep_sharp", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "use_face_influence", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "keep_sharp", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "use_face_influence", 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);
|
||||
}
|
||||
|
@ -735,24 +751,24 @@ ModifierTypeInfo modifierType_WeightedNormal = {
|
|||
|
||||
/* 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,
|
||||
};
|
|
@ -7,6 +7,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct CurveMapping;
|
||||
struct MDeformVert;
|
||||
struct MDeformWeight;
|
||||
|
@ -101,3 +105,7 @@ void weightvg_update_vg(struct MDeformVert *dvert,
|
|||
* Common vertex weight mask interface elements for the modifier panels.
|
||||
*/
|
||||
void weightvg_ui_common(const bContext *C, PointerRNA *ob_ptr, PointerRNA *ptr, uiLayout *layout);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* \ingroup modifiers
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
|
@ -96,7 +96,7 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma
|
|||
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
|
||||
}
|
||||
|
||||
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md)
|
||||
static bool dependsOnTime(Scene *UNUSED(scene), ModifierData *md)
|
||||
{
|
||||
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
|
||||
|
||||
|
@ -124,10 +124,10 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
|||
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
|
||||
bool need_transform_relation = false;
|
||||
|
||||
if (wmd->mask_texture != NULL) {
|
||||
if (wmd->mask_texture != nullptr) {
|
||||
DEG_add_generic_id_relation(ctx->node, &wmd->mask_texture->id, "WeightVGEdit Modifier");
|
||||
|
||||
if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
if (wmd->mask_tex_map_obj != nullptr && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
MOD_depsgraph_update_object_bone_relation(
|
||||
ctx->node, wmd->mask_tex_map_obj, wmd->mask_tex_map_bone, "WeightVGEdit Modifier");
|
||||
need_transform_relation = true;
|
||||
|
@ -142,9 +142,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
|||
}
|
||||
}
|
||||
|
||||
static bool isDisabled(const struct Scene *UNUSED(scene),
|
||||
ModifierData *md,
|
||||
bool UNUSED(useRenderParams))
|
||||
static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
|
||||
{
|
||||
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
|
||||
/* If no vertex group, bypass. */
|
||||
|
@ -153,11 +151,11 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
|
|||
|
||||
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
|
||||
{
|
||||
BLI_assert(mesh != NULL);
|
||||
BLI_assert(mesh != nullptr);
|
||||
|
||||
WeightVGEditModifierData *wmd = (WeightVGEditModifierData *)md;
|
||||
|
||||
MDeformWeight **dw = NULL;
|
||||
MDeformWeight **dw = nullptr;
|
||||
float *org_w; /* Array original weights. */
|
||||
float *new_w; /* Array new weights. */
|
||||
int i;
|
||||
|
@ -188,7 +186,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
|
||||
const bool has_mdef = CustomData_has_layer(&mesh->vdata, CD_MDEFORMVERT);
|
||||
/* If no vertices were ever added to an object's vgroup, dvert might be NULL. */
|
||||
/* If no vertices were ever added to an object's vgroup, dvert might be nullptr. */
|
||||
if (!has_mdef) {
|
||||
/* If this modifier is not allowed to add vertices, just return. */
|
||||
if (!do_add) {
|
||||
|
@ -204,9 +202,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
|
||||
/* Get org weights, assuming 0.0 for vertices not in given vgroup. */
|
||||
org_w = MEM_malloc_arrayN(verts_num, sizeof(float), "WeightVGEdit Modifier, org_w");
|
||||
new_w = MEM_malloc_arrayN(verts_num, sizeof(float), "WeightVGEdit Modifier, new_w");
|
||||
dw = MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), "WeightVGEdit Modifier, dw");
|
||||
org_w = static_cast<float *>(MEM_malloc_arrayN(verts_num, sizeof(float), __func__));
|
||||
new_w = static_cast<float *>(MEM_malloc_arrayN(verts_num, sizeof(float), __func__));
|
||||
dw = static_cast<MDeformWeight **>(
|
||||
MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), __func__));
|
||||
for (i = 0; i < verts_num; i++) {
|
||||
dw[i] = BKE_defvert_find_index(&dvert[i], defgrp_index);
|
||||
if (dw[i]) {
|
||||
|
@ -221,7 +220,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
const bool do_invert_mapping = (wmd->edit_flags & MOD_WVG_INVERT_FALLOFF) != 0;
|
||||
const bool do_normalize = (wmd->edit_flags & MOD_WVG_EDIT_WEIGHTS_NORMALIZE) != 0;
|
||||
if (do_invert_mapping || wmd->falloff_type != MOD_WVG_MAPPING_NONE) {
|
||||
RNG *rng = NULL;
|
||||
RNG *rng = nullptr;
|
||||
|
||||
if (wmd->falloff_type == MOD_WVG_MAPPING_RANDOM) {
|
||||
rng = BLI_rng_new_srandom(BLI_ghashutil_strhash(ctx->object->id.name + 2));
|
||||
|
@ -235,10 +234,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
|
||||
/* Do masking. */
|
||||
struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
||||
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
||||
weightvg_do_mask(ctx,
|
||||
verts_num,
|
||||
NULL,
|
||||
nullptr,
|
||||
org_w,
|
||||
new_w,
|
||||
ctx->object,
|
||||
|
@ -259,7 +258,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
defgrp_index,
|
||||
dw,
|
||||
verts_num,
|
||||
NULL,
|
||||
nullptr,
|
||||
org_w,
|
||||
do_add,
|
||||
wmd->add_threshold,
|
||||
|
@ -270,7 +269,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
/* If weight preview enabled... */
|
||||
#if 0 /* XXX Currently done in mod stack :/ */
|
||||
if (do_prev) {
|
||||
DM_update_weight_mcol(ob, dm, 0, org_w, 0, NULL);
|
||||
DM_update_weight_mcol(ob, dm, 0, org_w, 0, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -296,9 +295,9 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
col = uiLayoutColumn(layout, true);
|
||||
uiItemPointerR(col, ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE);
|
||||
uiItemPointerR(col, ptr, "vertex_group", &ob_ptr, "vertex_groups", nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "default_weight", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "default_weight", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
|
||||
|
||||
col = uiLayoutColumnWithHeading(layout, false, IFACE_("Group Add"));
|
||||
row = uiLayoutRow(col, true);
|
||||
|
@ -322,7 +321,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
uiItemR(sub, ptr, "remove_threshold", UI_ITEM_R_SLIDER, IFACE_("Threshold"), ICON_NONE);
|
||||
uiItemDecoratorR(row, ptr, "remove_threshold", 0);
|
||||
|
||||
uiItemR(layout, ptr, "normalize", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "normalize", 0, nullptr, ICON_NONE);
|
||||
|
||||
modifier_panel_end(layout, ptr);
|
||||
}
|
||||
|
@ -362,9 +361,9 @@ static void panelRegister(ARegionType *region_type)
|
|||
PanelType *panel_type = modifier_panel_register(
|
||||
region_type, eModifierType_WeightVGEdit, panel_draw);
|
||||
modifier_subpanel_register(
|
||||
region_type, "falloff", "Falloff", NULL, falloff_panel_draw, panel_type);
|
||||
region_type, "falloff", "Falloff", nullptr, falloff_panel_draw, panel_type);
|
||||
modifier_subpanel_register(
|
||||
region_type, "influence", "Influence", NULL, influence_panel_draw, panel_type);
|
||||
region_type, "influence", "Influence", nullptr, influence_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
static void blendWrite(BlendWriter *writer, const ID *UNUSED(id_owner), const ModifierData *md)
|
||||
|
@ -400,12 +399,12 @@ ModifierTypeInfo modifierType_WeightVGEdit = {
|
|||
|
||||
/* 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,
|
||||
|
@ -413,10 +412,10 @@ ModifierTypeInfo modifierType_WeightVGEdit = {
|
|||
/* isDisabled */ isDisabled,
|
||||
/* updateDepsgraph */ updateDepsgraph,
|
||||
/* dependsOnTime */ dependsOnTime,
|
||||
/* dependsOnNormals */ NULL,
|
||||
/* dependsOnNormals */ nullptr,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ foreachTexLink,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* freeRuntimeData */ nullptr,
|
||||
/* panelRegister */ panelRegister,
|
||||
/* blendWrite */ blendWrite,
|
||||
/* blendRead */ blendRead,
|
|
@ -144,7 +144,7 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma
|
|||
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
|
||||
}
|
||||
|
||||
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md)
|
||||
static bool dependsOnTime(Scene *UNUSED(scene), ModifierData *md)
|
||||
{
|
||||
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *)md;
|
||||
|
||||
|
@ -172,10 +172,10 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
|||
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *)md;
|
||||
bool need_transform_relation = false;
|
||||
|
||||
if (wmd->mask_texture != NULL) {
|
||||
if (wmd->mask_texture != nullptr) {
|
||||
DEG_add_generic_id_relation(ctx->node, &wmd->mask_texture->id, "WeightVGMix Modifier");
|
||||
|
||||
if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
if (wmd->mask_tex_map_obj != nullptr && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
MOD_depsgraph_update_object_bone_relation(
|
||||
ctx->node, wmd->mask_tex_map_obj, wmd->mask_tex_map_bone, "WeightVGMix Modifier");
|
||||
need_transform_relation = true;
|
||||
|
@ -190,9 +190,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
|||
}
|
||||
}
|
||||
|
||||
static bool isDisabled(const struct Scene *UNUSED(scene),
|
||||
ModifierData *md,
|
||||
bool UNUSED(useRenderParams))
|
||||
static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
|
||||
{
|
||||
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *)md;
|
||||
/* If no vertex group, bypass. */
|
||||
|
@ -201,14 +199,14 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
|
|||
|
||||
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
|
||||
{
|
||||
BLI_assert(mesh != NULL);
|
||||
BLI_assert(mesh != nullptr);
|
||||
|
||||
WeightVGMixModifierData *wmd = (WeightVGMixModifierData *)md;
|
||||
|
||||
MDeformWeight **dw1, **tdw1, **dw2, **tdw2;
|
||||
float *org_w;
|
||||
float *new_w;
|
||||
int *tidx, *indices = NULL;
|
||||
int *tidx, *indices = nullptr;
|
||||
int index_num = 0;
|
||||
int i;
|
||||
const bool invert_vgroup_mask = (wmd->flag & MOD_WVG_MIX_INVERT_VGROUP_MASK) != 0;
|
||||
|
@ -253,7 +251,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
|
||||
const bool has_mdef = CustomData_has_layer(&mesh->vdata, CD_MDEFORMVERT);
|
||||
/* If no vertices were ever added to an object's vgroup, dvert might be NULL. */
|
||||
/* If no vertices were ever added to an object's vgroup, dvert might be nullptr. */
|
||||
if (!has_mdef) {
|
||||
/* If not affecting all vertices, just return. */
|
||||
if (wmd->mix_set != MOD_WVG_SET_ALL) {
|
||||
|
@ -269,9 +267,11 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
|
||||
/* Find out which vertices to work on. */
|
||||
tidx = MEM_malloc_arrayN(verts_num, sizeof(int), "WeightVGMix Modifier, tidx");
|
||||
tdw1 = MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), "WeightVGMix Modifier, tdw1");
|
||||
tdw2 = MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), "WeightVGMix Modifier, tdw2");
|
||||
tidx = static_cast<int *>(MEM_malloc_arrayN(verts_num, sizeof(int), __func__));
|
||||
tdw1 = static_cast<MDeformWeight **>(
|
||||
MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), __func__));
|
||||
tdw2 = static_cast<MDeformWeight **>(
|
||||
MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), __func__));
|
||||
switch (wmd->mix_set) {
|
||||
case MOD_WVG_SET_A:
|
||||
/* All vertices in first vgroup. */
|
||||
|
@ -281,7 +281,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
tdw1[index_num] = dw;
|
||||
tdw2[index_num] = (defgrp_index_other >= 0) ?
|
||||
BKE_defvert_find_index(&dvert[i], defgrp_index_other) :
|
||||
NULL;
|
||||
nullptr;
|
||||
tidx[index_num++] = i;
|
||||
}
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
for (i = 0; i < verts_num; i++) {
|
||||
MDeformWeight *dw = (defgrp_index_other >= 0) ?
|
||||
BKE_defvert_find_index(&dvert[i], defgrp_index_other) :
|
||||
NULL;
|
||||
nullptr;
|
||||
if (dw) {
|
||||
tdw1[index_num] = BKE_defvert_find_index(&dvert[i], defgrp_index);
|
||||
tdw2[index_num] = dw;
|
||||
|
@ -305,7 +305,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
MDeformWeight *adw = BKE_defvert_find_index(&dvert[i], defgrp_index);
|
||||
MDeformWeight *bdw = (defgrp_index_other >= 0) ?
|
||||
BKE_defvert_find_index(&dvert[i], defgrp_index_other) :
|
||||
NULL;
|
||||
nullptr;
|
||||
if (adw || bdw) {
|
||||
tdw1[index_num] = adw;
|
||||
tdw2[index_num] = bdw;
|
||||
|
@ -319,7 +319,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
MDeformWeight *adw = BKE_defvert_find_index(&dvert[i], defgrp_index);
|
||||
MDeformWeight *bdw = (defgrp_index_other >= 0) ?
|
||||
BKE_defvert_find_index(&dvert[i], defgrp_index_other) :
|
||||
NULL;
|
||||
nullptr;
|
||||
if (adw && bdw) {
|
||||
tdw1[index_num] = adw;
|
||||
tdw2[index_num] = bdw;
|
||||
|
@ -334,7 +334,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
tdw1[i] = BKE_defvert_find_index(&dvert[i], defgrp_index);
|
||||
tdw2[i] = (defgrp_index_other >= 0) ?
|
||||
BKE_defvert_find_index(&dvert[i], defgrp_index_other) :
|
||||
NULL;
|
||||
nullptr;
|
||||
}
|
||||
index_num = -1;
|
||||
break;
|
||||
|
@ -347,12 +347,14 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
return mesh;
|
||||
}
|
||||
if (index_num != -1) {
|
||||
indices = MEM_malloc_arrayN(index_num, sizeof(int), "WeightVGMix Modifier, indices");
|
||||
indices = static_cast<int *>(MEM_malloc_arrayN(index_num, sizeof(int), __func__));
|
||||
memcpy(indices, tidx, sizeof(int) * index_num);
|
||||
dw1 = MEM_malloc_arrayN(index_num, sizeof(MDeformWeight *), "WeightVGMix Modifier, dw1");
|
||||
dw1 = static_cast<MDeformWeight **>(
|
||||
MEM_malloc_arrayN(index_num, sizeof(MDeformWeight *), __func__));
|
||||
memcpy(dw1, tdw1, sizeof(MDeformWeight *) * index_num);
|
||||
MEM_freeN(tdw1);
|
||||
dw2 = MEM_malloc_arrayN(index_num, sizeof(MDeformWeight *), "WeightVGMix Modifier, dw2");
|
||||
dw2 = static_cast<MDeformWeight **>(
|
||||
MEM_malloc_arrayN(index_num, sizeof(MDeformWeight *), __func__));
|
||||
memcpy(dw2, tdw2, sizeof(MDeformWeight *) * index_num);
|
||||
MEM_freeN(tdw2);
|
||||
}
|
||||
|
@ -365,8 +367,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
MEM_freeN(tidx);
|
||||
|
||||
org_w = MEM_malloc_arrayN(index_num, sizeof(float), "WeightVGMix Modifier, org_w");
|
||||
new_w = MEM_malloc_arrayN(index_num, sizeof(float), "WeightVGMix Modifier, new_w");
|
||||
org_w = static_cast<float *>(MEM_malloc_arrayN(index_num, sizeof(float), __func__));
|
||||
new_w = static_cast<float *>(MEM_malloc_arrayN(index_num, sizeof(float), __func__));
|
||||
|
||||
/* Mix weights. */
|
||||
for (i = 0; i < index_num; i++) {
|
||||
|
@ -388,7 +390,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
|
||||
/* Do masking. */
|
||||
struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
||||
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
||||
weightvg_do_mask(ctx,
|
||||
index_num,
|
||||
indices,
|
||||
|
@ -451,20 +453,20 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group_a", "invert_vertex_group_a", NULL);
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group_a", "invert_vertex_group_a", nullptr);
|
||||
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group_b", "invert_vertex_group_b", IFACE_("B"));
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
uiItemR(layout, ptr, "default_weight_a", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "default_weight_a", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "default_weight_b", 0, IFACE_("B"), ICON_NONE);
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
uiItemR(layout, ptr, "mix_set", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "mix_mode", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "mix_set", 0, nullptr, ICON_NONE);
|
||||
uiItemR(layout, ptr, "mix_mode", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "normalize", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "normalize", 0, nullptr, ICON_NONE);
|
||||
|
||||
modifier_panel_end(layout, ptr);
|
||||
}
|
||||
|
@ -484,7 +486,7 @@ static void panelRegister(ARegionType *region_type)
|
|||
PanelType *panel_type = modifier_panel_register(
|
||||
region_type, eModifierType_WeightVGMix, panel_draw);
|
||||
modifier_subpanel_register(
|
||||
region_type, "influence", "Influence", NULL, influence_panel_draw, panel_type);
|
||||
region_type, "influence", "Influence", nullptr, influence_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
ModifierTypeInfo modifierType_WeightVGMix = {
|
||||
|
@ -499,24 +501,24 @@ ModifierTypeInfo modifierType_WeightVGMix = {
|
|||
|
||||
/* 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 */ dependsOnTime,
|
||||
/* dependsOnNormals */ NULL,
|
||||
/* dependsOnNormals */ nullptr,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ foreachTexLink,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* freeRuntimeData */ nullptr,
|
||||
/* panelRegister */ panelRegister,
|
||||
/* blendWrite */ NULL,
|
||||
/* blendRead */ NULL,
|
||||
/* blendWrite */ nullptr,
|
||||
/* blendRead */ nullptr,
|
||||
};
|
|
@ -69,7 +69,7 @@
|
|||
/* Util macro. */
|
||||
#define OUT_OF_MEMORY() ((void)printf("WeightVGProximity: Out of memory.\n"))
|
||||
|
||||
typedef struct Vert2GeomData {
|
||||
struct Vert2GeomData {
|
||||
/* Read-only data */
|
||||
float (*v_cos)[3];
|
||||
|
||||
|
@ -79,17 +79,17 @@ typedef struct Vert2GeomData {
|
|||
|
||||
/* Write data, but not needing locking (two different threads will never write same index). */
|
||||
float *dist[3];
|
||||
} Vert2GeomData;
|
||||
};
|
||||
|
||||
/**
|
||||
* Data which is localized to each computed chunk
|
||||
* (i.e. thread-safe, and with continuous subset of index range).
|
||||
*/
|
||||
typedef struct Vert2GeomDataChunk {
|
||||
struct Vert2GeomDataChunk {
|
||||
/* Read-only data */
|
||||
float last_hit_co[3][3];
|
||||
bool is_init[3];
|
||||
} Vert2GeomDataChunk;
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback used by BLI_task 'for loop' helper.
|
||||
|
@ -98,8 +98,8 @@ static void vert2geom_task_cb_ex(void *__restrict userdata,
|
|||
const int iter,
|
||||
const TaskParallelTLS *__restrict tls)
|
||||
{
|
||||
Vert2GeomData *data = userdata;
|
||||
Vert2GeomDataChunk *data_chunk = tls->userdata_chunk;
|
||||
Vert2GeomData *data = static_cast<Vert2GeomData *>(userdata);
|
||||
Vert2GeomDataChunk *data_chunk = static_cast<Vert2GeomDataChunk *>(tls->userdata_chunk);
|
||||
|
||||
float tmp_co[3];
|
||||
int i;
|
||||
|
@ -151,17 +151,17 @@ static void get_vert2geom_distance(int verts_num,
|
|||
Mesh *target,
|
||||
const SpaceTransform *loc2trgt)
|
||||
{
|
||||
Vert2GeomData data = {0};
|
||||
Vert2GeomData data{};
|
||||
Vert2GeomDataChunk data_chunk = {{{0}}};
|
||||
|
||||
BVHTreeFromMesh treeData_v = {NULL};
|
||||
BVHTreeFromMesh treeData_e = {NULL};
|
||||
BVHTreeFromMesh treeData_f = {NULL};
|
||||
BVHTreeFromMesh treeData_v = {nullptr};
|
||||
BVHTreeFromMesh treeData_e = {nullptr};
|
||||
BVHTreeFromMesh treeData_f = {nullptr};
|
||||
|
||||
if (dist_v) {
|
||||
/* Create a BVH-tree of the given target's verts. */
|
||||
BKE_bvhtree_from_mesh_get(&treeData_v, target, BVHTREE_FROM_VERTS, 2);
|
||||
if (treeData_v.tree == NULL) {
|
||||
if (treeData_v.tree == nullptr) {
|
||||
OUT_OF_MEMORY();
|
||||
return;
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ static void get_vert2geom_distance(int verts_num,
|
|||
if (dist_e) {
|
||||
/* Create a BVH-tree of the given target's edges. */
|
||||
BKE_bvhtree_from_mesh_get(&treeData_e, target, BVHTREE_FROM_EDGES, 2);
|
||||
if (treeData_e.tree == NULL) {
|
||||
if (treeData_e.tree == nullptr) {
|
||||
OUT_OF_MEMORY();
|
||||
return;
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ static void get_vert2geom_distance(int verts_num,
|
|||
if (dist_f) {
|
||||
/* Create a BVH-tree of the given target's faces. */
|
||||
BKE_bvhtree_from_mesh_get(&treeData_f, target, BVHTREE_FROM_LOOPTRI, 2);
|
||||
if (treeData_f.tree == NULL) {
|
||||
if (treeData_f.tree == nullptr) {
|
||||
OUT_OF_MEMORY();
|
||||
return;
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ static void do_map(Object *ob,
|
|||
}
|
||||
|
||||
if (do_invert_mapping || mode != MOD_WVG_MAPPING_NONE) {
|
||||
RNG *rng = NULL;
|
||||
RNG *rng = nullptr;
|
||||
|
||||
if (mode == MOD_WVG_MAPPING_RANDOM) {
|
||||
rng = BLI_rng_new_srandom(BLI_ghashutil_strhash(ob->id.name + 2));
|
||||
|
@ -345,14 +345,14 @@ static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_ma
|
|||
/* No need to ask for CD_PREVIEW_MLOOPCOL... */
|
||||
}
|
||||
|
||||
static bool dependsOnTime(struct Scene *UNUSED(scene), ModifierData *md)
|
||||
static bool dependsOnTime(Scene *UNUSED(scene), ModifierData *md)
|
||||
{
|
||||
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md;
|
||||
|
||||
if (wmd->mask_texture) {
|
||||
return BKE_texture_dependsOnTime(wmd->mask_texture);
|
||||
}
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
|
||||
|
@ -374,10 +374,10 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
|||
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md;
|
||||
bool need_transform_relation = false;
|
||||
|
||||
if (wmd->proximity_ob_target != NULL) {
|
||||
if (wmd->proximity_ob_target != nullptr) {
|
||||
DEG_add_object_relation(
|
||||
ctx->node, wmd->proximity_ob_target, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier");
|
||||
if (wmd->proximity_ob_target->data != NULL &&
|
||||
if (wmd->proximity_ob_target->data != nullptr &&
|
||||
wmd->proximity_mode == MOD_WVG_PROXIMITY_GEOMETRY) {
|
||||
DEG_add_object_relation(
|
||||
ctx->node, wmd->proximity_ob_target, DEG_OB_COMP_GEOMETRY, "WeightVGProximity Modifier");
|
||||
|
@ -385,10 +385,10 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
|||
need_transform_relation = true;
|
||||
}
|
||||
|
||||
if (wmd->mask_texture != NULL) {
|
||||
if (wmd->mask_texture != nullptr) {
|
||||
DEG_add_generic_id_relation(ctx->node, &wmd->mask_texture->id, "WeightVGProximity Modifier");
|
||||
|
||||
if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
if (wmd->mask_tex_map_obj != nullptr && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) {
|
||||
MOD_depsgraph_update_object_bone_relation(
|
||||
ctx->node, wmd->mask_tex_map_obj, wmd->mask_tex_map_bone, "WeightVGProximity Modifier");
|
||||
need_transform_relation = true;
|
||||
|
@ -403,9 +403,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
|
|||
}
|
||||
}
|
||||
|
||||
static bool isDisabled(const struct Scene *UNUSED(scene),
|
||||
ModifierData *md,
|
||||
bool UNUSED(useRenderParams))
|
||||
static bool isDisabled(const Scene *UNUSED(scene), ModifierData *md, bool UNUSED(useRenderParams))
|
||||
{
|
||||
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md;
|
||||
/* If no vertex group, bypass. */
|
||||
|
@ -413,23 +411,23 @@ static bool isDisabled(const struct Scene *UNUSED(scene),
|
|||
return true;
|
||||
}
|
||||
/* If no target object, bypass. */
|
||||
return (wmd->proximity_ob_target == NULL);
|
||||
return (wmd->proximity_ob_target == nullptr);
|
||||
}
|
||||
|
||||
static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
|
||||
{
|
||||
BLI_assert(mesh != NULL);
|
||||
BLI_assert(mesh != nullptr);
|
||||
|
||||
WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md;
|
||||
MDeformWeight **dw, **tdw;
|
||||
float(*v_cos)[3] = NULL; /* The vertices coordinates. */
|
||||
float(*v_cos)[3] = nullptr; /* The vertices coordinates. */
|
||||
Object *ob = ctx->object;
|
||||
Object *obr = NULL; /* Our target object. */
|
||||
Object *obr = nullptr; /* Our target object. */
|
||||
int defgrp_index;
|
||||
float *tw = NULL;
|
||||
float *org_w = NULL;
|
||||
float *new_w = NULL;
|
||||
int *tidx, *indices = NULL;
|
||||
float *tw = nullptr;
|
||||
float *org_w = nullptr;
|
||||
float *new_w = nullptr;
|
||||
int *tidx, *indices = nullptr;
|
||||
int index_num = 0;
|
||||
int i;
|
||||
const bool invert_vgroup_mask = (wmd->proximity_flags & MOD_WVG_PROXIMITY_INVERT_VGROUP_MASK) !=
|
||||
|
@ -456,7 +454,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
|
||||
/* Get our target object. */
|
||||
obr = wmd->proximity_ob_target;
|
||||
if (obr == NULL) {
|
||||
if (obr == nullptr) {
|
||||
return mesh;
|
||||
}
|
||||
|
||||
|
@ -466,7 +464,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
return mesh;
|
||||
}
|
||||
const bool has_mdef = CustomData_has_layer(&mesh->vdata, CD_MDEFORMVERT);
|
||||
/* If no vertices were ever added to an object's vgroup, dvert might be NULL. */
|
||||
/* If no vertices were ever added to an object's vgroup, dvert might be nullptr. */
|
||||
/* As this modifier never add vertices to vgroup, just return. */
|
||||
if (!has_mdef) {
|
||||
return mesh;
|
||||
|
@ -479,9 +477,10 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
}
|
||||
|
||||
/* Find out which vertices to work on (all vertices in vgroup), and get their relevant weight. */
|
||||
tidx = MEM_malloc_arrayN(verts_num, sizeof(int), "WeightVGProximity Modifier, tidx");
|
||||
tw = MEM_malloc_arrayN(verts_num, sizeof(float), "WeightVGProximity Modifier, tw");
|
||||
tdw = MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), "WeightVGProximity Modifier, tdw");
|
||||
tidx = static_cast<int *>(MEM_malloc_arrayN(verts_num, sizeof(int), __func__));
|
||||
tw = static_cast<float *>(MEM_malloc_arrayN(verts_num, sizeof(float), __func__));
|
||||
tdw = static_cast<MDeformWeight **>(
|
||||
MEM_malloc_arrayN(verts_num, sizeof(MDeformWeight *), __func__));
|
||||
for (i = 0; i < verts_num; i++) {
|
||||
MDeformWeight *_dw = BKE_defvert_find_index(&dvert[i], defgrp_index);
|
||||
if (_dw) {
|
||||
|
@ -498,11 +497,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
return mesh;
|
||||
}
|
||||
if (index_num != verts_num) {
|
||||
indices = MEM_malloc_arrayN(index_num, sizeof(int), "WeightVGProximity Modifier, indices");
|
||||
indices = static_cast<int *>(MEM_malloc_arrayN(index_num, sizeof(int), __func__));
|
||||
memcpy(indices, tidx, sizeof(int) * index_num);
|
||||
org_w = MEM_malloc_arrayN(index_num, sizeof(float), "WeightVGProximity Modifier, org_w");
|
||||
org_w = static_cast<float *>(MEM_malloc_arrayN(index_num, sizeof(float), __func__));
|
||||
memcpy(org_w, tw, sizeof(float) * index_num);
|
||||
dw = MEM_malloc_arrayN(index_num, sizeof(MDeformWeight *), "WeightVGProximity Modifier, dw");
|
||||
dw = static_cast<MDeformWeight **>(
|
||||
MEM_malloc_arrayN(index_num, sizeof(MDeformWeight *), __func__));
|
||||
memcpy(dw, tdw, sizeof(MDeformWeight *) * index_num);
|
||||
MEM_freeN(tw);
|
||||
MEM_freeN(tdw);
|
||||
|
@ -511,20 +511,20 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
org_w = tw;
|
||||
dw = tdw;
|
||||
}
|
||||
new_w = MEM_malloc_arrayN(index_num, sizeof(float), "WeightVGProximity Modifier, new_w");
|
||||
new_w = static_cast<float *>(MEM_malloc_arrayN(index_num, sizeof(float), __func__));
|
||||
MEM_freeN(tidx);
|
||||
|
||||
/* Get our vertex coordinates. */
|
||||
if (index_num != verts_num) {
|
||||
float(*tv_cos)[3] = BKE_mesh_vert_coords_alloc(mesh, NULL);
|
||||
v_cos = MEM_malloc_arrayN(index_num, sizeof(float[3]), "WeightVGProximity Modifier, v_cos");
|
||||
float(*tv_cos)[3] = BKE_mesh_vert_coords_alloc(mesh, nullptr);
|
||||
v_cos = static_cast<float(*)[3]>(MEM_malloc_arrayN(index_num, sizeof(float[3]), __func__));
|
||||
for (i = 0; i < index_num; i++) {
|
||||
copy_v3_v3(v_cos[i], tv_cos[indices[i]]);
|
||||
}
|
||||
MEM_freeN(tv_cos);
|
||||
}
|
||||
else {
|
||||
v_cos = BKE_mesh_vert_coords_alloc(mesh, NULL);
|
||||
v_cos = BKE_mesh_vert_coords_alloc(mesh, nullptr);
|
||||
}
|
||||
|
||||
/* Compute wanted distances. */
|
||||
|
@ -543,19 +543,22 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
Mesh *target_mesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(obr);
|
||||
|
||||
/* We must check that we do have a valid target_mesh! */
|
||||
if (target_mesh != NULL) {
|
||||
if (target_mesh != nullptr) {
|
||||
|
||||
/* TODO: edit-mode versions of the BVH lookup functions are available so it could be
|
||||
* avoided. */
|
||||
BKE_mesh_wrapper_ensure_mdata(target_mesh);
|
||||
|
||||
SpaceTransform loc2trgt;
|
||||
float *dists_v = use_trgt_verts ? MEM_malloc_arrayN(index_num, sizeof(float), "dists_v") :
|
||||
NULL;
|
||||
float *dists_e = use_trgt_edges ? MEM_malloc_arrayN(index_num, sizeof(float), "dists_e") :
|
||||
NULL;
|
||||
float *dists_f = use_trgt_faces ? MEM_malloc_arrayN(index_num, sizeof(float), "dists_f") :
|
||||
NULL;
|
||||
float *dists_v = use_trgt_verts ? static_cast<float *>(MEM_malloc_arrayN(
|
||||
index_num, sizeof(float), __func__)) :
|
||||
nullptr;
|
||||
float *dists_e = use_trgt_edges ? static_cast<float *>(MEM_malloc_arrayN(
|
||||
index_num, sizeof(float), __func__)) :
|
||||
nullptr;
|
||||
float *dists_f = use_trgt_faces ? static_cast<float *>(MEM_malloc_arrayN(
|
||||
index_num, sizeof(float), __func__)) :
|
||||
nullptr;
|
||||
|
||||
BLI_SPACE_TRANSFORM_SETUP(&loc2trgt, ob, obr);
|
||||
get_vert2geom_distance(
|
||||
|
@ -595,7 +598,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
|
|||
wmd->cmap_curve);
|
||||
|
||||
/* Do masking. */
|
||||
struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
||||
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
||||
weightvg_do_mask(ctx,
|
||||
index_num,
|
||||
indices,
|
||||
|
@ -652,22 +655,22 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
|||
|
||||
uiLayoutSetPropSep(layout, true);
|
||||
|
||||
uiItemPointerR(layout, ptr, "vertex_group", &ob_ptr, "vertex_groups", NULL, ICON_NONE);
|
||||
uiItemPointerR(layout, ptr, "vertex_group", &ob_ptr, "vertex_groups", nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "target", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "target", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemS(layout);
|
||||
|
||||
uiItemR(layout, ptr, "proximity_mode", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "proximity_mode", 0, nullptr, ICON_NONE);
|
||||
if (RNA_enum_get(ptr, "proximity_mode") == MOD_WVG_PROXIMITY_GEOMETRY) {
|
||||
uiItemR(layout, ptr, "proximity_geometry", UI_ITEM_R_EXPAND, IFACE_("Geometry"), ICON_NONE);
|
||||
}
|
||||
|
||||
col = uiLayoutColumn(layout, true);
|
||||
uiItemR(col, ptr, "min_dist", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "max_dist", 0, NULL, ICON_NONE);
|
||||
uiItemR(col, ptr, "min_dist", 0, nullptr, ICON_NONE);
|
||||
uiItemR(col, ptr, "max_dist", 0, nullptr, ICON_NONE);
|
||||
|
||||
uiItemR(layout, ptr, "normalize", 0, NULL, ICON_NONE);
|
||||
uiItemR(layout, ptr, "normalize", 0, nullptr, ICON_NONE);
|
||||
}
|
||||
|
||||
static void falloff_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
||||
|
@ -706,9 +709,9 @@ static void panelRegister(ARegionType *region_type)
|
|||
PanelType *panel_type = modifier_panel_register(
|
||||
region_type, eModifierType_WeightVGProximity, panel_draw);
|
||||
modifier_subpanel_register(
|
||||
region_type, "falloff", "Falloff", NULL, falloff_panel_draw, panel_type);
|
||||
region_type, "falloff", "Falloff", nullptr, falloff_panel_draw, panel_type);
|
||||
modifier_subpanel_register(
|
||||
region_type, "influence", "Influence", NULL, influence_panel_draw, panel_type);
|
||||
region_type, "influence", "Influence", nullptr, influence_panel_draw, panel_type);
|
||||
}
|
||||
|
||||
static void blendWrite(BlendWriter *writer, const ID *UNUSED(id_owner), const ModifierData *md)
|
||||
|
@ -744,12 +747,12 @@ ModifierTypeInfo modifierType_WeightVGProximity = {
|
|||
|
||||
/* 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,
|
||||
|
@ -757,10 +760,10 @@ ModifierTypeInfo modifierType_WeightVGProximity = {
|
|||
/* isDisabled */ isDisabled,
|
||||
/* updateDepsgraph */ updateDepsgraph,
|
||||
/* dependsOnTime */ dependsOnTime,
|
||||
/* dependsOnNormals */ NULL,
|
||||
/* dependsOnNormals */ nullptr,
|
||||
/* foreachIDLink */ foreachIDLink,
|
||||
/* foreachTexLink */ foreachTexLink,
|
||||
/* freeRuntimeData */ NULL,
|
||||
/* freeRuntimeData */ nullptr,
|
||||
/* panelRegister */ panelRegister,
|
||||
/* blendWrite */ blendWrite,
|
||||
/* blendRead */ blendRead,
|
Loading…
Reference in New Issue