Cleanup: Move multires files to C++

For continued refactoring of the Mesh data structure. See T103343.
This commit is contained in:
Hans Goudey 2023-01-20 07:59:38 -06:00
parent c8a10c43b1
commit c07fdad03d
13 changed files with 455 additions and 435 deletions

View File

@ -156,7 +156,7 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, float
int mdisp_rot_face_to_crn(
struct MPoly *mpoly, int face_side, float u, float v, float *x, float *y);
/* Reshaping, define in multires_reshape.c */
/* Reshaping, define in multires_reshape.cc */
bool multiresModifier_reshapeFromVertcos(struct Depsgraph *depsgraph,
struct Object *object,
@ -204,7 +204,7 @@ void multiresModifier_subdivide_to_level(struct Object *object,
int top_level,
eMultiresSubdivideModeType mode);
/* Subdivision integration, defined in multires_subdiv.c */
/* Subdivision integration, defined in multires_subdiv.cc */
struct SubdivSettings;
struct SubdivToMeshSettings;

View File

@ -216,16 +216,16 @@ set(SRC
intern/modifier.cc
intern/movieclip.c
intern/multires.cc
intern/multires_reshape.c
intern/multires_reshape_apply_base.c
intern/multires_reshape_ccg.c
intern/multires_reshape_smooth.c
intern/multires_reshape_subdivide.c
intern/multires_reshape_util.c
intern/multires_reshape_vertcos.c
intern/multires_subdiv.c
intern/multires_unsubdivide.c
intern/multires_versioning.c
intern/multires_reshape.cc
intern/multires_reshape_apply_base.cc
intern/multires_reshape_ccg.cc
intern/multires_reshape_smooth.cc
intern/multires_reshape_subdivide.cc
intern/multires_reshape_util.cc
intern/multires_reshape_vertcos.cc
intern/multires_subdiv.cc
intern/multires_unsubdivide.cc
intern/multires_versioning.cc
intern/nla.c
intern/node.cc
intern/node_runtime.cc

View File

@ -30,9 +30,9 @@
/** \name Reshape from object
* \{ */
bool multiresModifier_reshapeFromVertcos(struct Depsgraph *depsgraph,
struct Object *object,
struct MultiresModifierData *mmd,
bool multiresModifier_reshapeFromVertcos(Depsgraph *depsgraph,
Object *object,
MultiresModifierData *mmd,
const float (*vert_coords)[3],
const int num_vert_coords)
{
@ -41,7 +41,7 @@ bool multiresModifier_reshapeFromVertcos(struct Depsgraph *depsgraph,
return false;
}
multires_reshape_store_original_grids(&reshape_context);
multires_reshape_ensure_grids(object->data, reshape_context.top.level);
multires_reshape_ensure_grids(static_cast<Mesh *>(object->data), reshape_context.top.level);
if (!multires_reshape_assign_final_coords_from_vertcos(
&reshape_context, vert_coords, num_vert_coords)) {
multires_reshape_context_free(&reshape_context);
@ -53,13 +53,13 @@ bool multiresModifier_reshapeFromVertcos(struct Depsgraph *depsgraph,
return true;
}
bool multiresModifier_reshapeFromObject(struct Depsgraph *depsgraph,
struct MultiresModifierData *mmd,
struct Object *dst,
struct Object *src)
bool multiresModifier_reshapeFromObject(Depsgraph *depsgraph,
MultiresModifierData *mmd,
Object *dst,
Object *src)
{
struct Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
struct Object *src_eval = DEG_get_evaluated_object(depsgraph, src);
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *src_eval = DEG_get_evaluated_object(depsgraph, src);
Mesh *src_mesh_eval = mesh_get_eval_final(depsgraph, scene_eval, src_eval, &CD_MASK_BAREMESH);
int num_deformed_verts;
@ -79,10 +79,10 @@ bool multiresModifier_reshapeFromObject(struct Depsgraph *depsgraph,
/** \name Reshape from modifier
* \{ */
bool multiresModifier_reshapeFromDeformModifier(struct Depsgraph *depsgraph,
struct Object *object,
struct MultiresModifierData *mmd,
struct ModifierData *deform_md)
bool multiresModifier_reshapeFromDeformModifier(Depsgraph *depsgraph,
Object *object,
MultiresModifierData *mmd,
ModifierData *deform_md)
{
MultiresModifierData highest_mmd = *mmd;
highest_mmd.sculptlvl = highest_mmd.totlvl;
@ -96,14 +96,14 @@ bool multiresModifier_reshapeFromDeformModifier(struct Depsgraph *depsgraph,
float(*deformed_verts)[3] = BKE_mesh_vert_coords_alloc(multires_mesh, &num_deformed_verts);
/* Apply deformation modifier on the multires, */
const ModifierEvalContext modifier_ctx = {
.depsgraph = depsgraph,
.object = object,
.flag = MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY,
};
ModifierEvalContext modifier_ctx{};
modifier_ctx.depsgraph = depsgraph;
modifier_ctx.object = object;
modifier_ctx.flag = MOD_APPLY_USECACHE | MOD_APPLY_IGNORE_SIMPLIFY;
BKE_modifier_deform_verts(
deform_md, &modifier_ctx, multires_mesh, deformed_verts, multires_mesh->totvert);
BKE_id_free(NULL, multires_mesh);
BKE_id_free(nullptr, multires_mesh);
/* Reshaping */
bool result = multiresModifier_reshapeFromVertcos(
@ -121,9 +121,7 @@ bool multiresModifier_reshapeFromDeformModifier(struct Depsgraph *depsgraph,
/** \name Reshape from grids
* \{ */
bool multiresModifier_reshapeFromCCG(const int tot_level,
Mesh *coarse_mesh,
struct SubdivCCG *subdiv_ccg)
bool multiresModifier_reshapeFromCCG(const int tot_level, Mesh *coarse_mesh, SubdivCCG *subdiv_ccg)
{
MultiresReshapeContext reshape_context;
if (!multires_reshape_context_create_from_ccg(
@ -159,8 +157,8 @@ void multiresModifier_subdivide(Object *object,
multiresModifier_subdivide_to_level(object, mmd, top_level, mode);
}
void multiresModifier_subdivide_to_level(struct Object *object,
struct MultiresModifierData *mmd,
void multiresModifier_subdivide_to_level(Object *object,
MultiresModifierData *mmd,
const int top_level,
const eMultiresSubdivideModeType mode)
{
@ -168,7 +166,7 @@ void multiresModifier_subdivide_to_level(struct Object *object,
return;
}
Mesh *coarse_mesh = object->data;
Mesh *coarse_mesh = static_cast<Mesh *>(object->data);
if (coarse_mesh->totloop == 0) {
/* If there are no loops in the mesh implies there is no CD_MDISPS as well. So can early output
* from here as there is nothing to subdivide. */
@ -182,7 +180,7 @@ void multiresModifier_subdivide_to_level(struct Object *object,
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->ldata, CD_MDISPS);
if (!has_mdisps) {
CustomData_add_layer(
&coarse_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, NULL, coarse_mesh->totloop);
&coarse_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, coarse_mesh->totloop);
}
/* NOTE: Subdivision happens from the top level of the existing multires modifier. If it is set
@ -238,9 +236,7 @@ void multiresModifier_subdivide_to_level(struct Object *object,
/** \name Apply base
* \{ */
void multiresModifier_base_apply(struct Depsgraph *depsgraph,
Object *object,
MultiresModifierData *mmd)
void multiresModifier_base_apply(Depsgraph *depsgraph, Object *object, MultiresModifierData *mmd)
{
multires_force_sculpt_rebuild(object);

View File

@ -81,8 +81,8 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape
base_mesh->totpoly,
base_mesh->totloop);
float(*origco)[3] = MEM_calloc_arrayN(
base_mesh->totvert, sizeof(float[3]), "multires apply base origco");
float(*origco)[3] = static_cast<float(*)[3]>(
MEM_calloc_arrayN(base_mesh->totvert, sizeof(float[3]), __func__));
for (int i = 0; i < base_mesh->totvert; i++) {
copy_v3_v3(origco[i], base_positions[i]);
}
@ -115,15 +115,15 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape
for (int j = 0; j < pmap[i].count; j++) {
const MPoly *p = &reshape_context->base_polys[pmap[i].indices[j]];
MPoly fake_poly;
MLoop *fake_loops;
float(*fake_co)[3];
float no[3];
/* Set up poly, loops, and coords in order to call BKE_mesh_calc_poly_normal(). */
fake_poly.totloop = p->totloop;
fake_poly.loopstart = 0;
fake_loops = MEM_malloc_arrayN(p->totloop, sizeof(MLoop), "fake_loops");
fake_co = MEM_malloc_arrayN(p->totloop, sizeof(float[3]), "fake_co");
MLoop *fake_loops = static_cast<MLoop *>(
MEM_malloc_arrayN(p->totloop, sizeof(MLoop), __func__));
float(*fake_co)[3] = static_cast<float(*)[3]>(
MEM_malloc_arrayN(p->totloop, sizeof(float[3]), __func__));
for (int k = 0; k < p->totloop; k++) {
const int vndx = reshape_context->base_loops[p->loopstart + k].v;
@ -165,20 +165,20 @@ void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape
void multires_reshape_apply_base_refine_from_base(MultiresReshapeContext *reshape_context)
{
BKE_subdiv_eval_refine_from_mesh(reshape_context->subdiv, reshape_context->base_mesh, NULL);
BKE_subdiv_eval_refine_from_mesh(reshape_context->subdiv, reshape_context->base_mesh, nullptr);
}
void multires_reshape_apply_base_refine_from_deform(MultiresReshapeContext *reshape_context)
{
struct Depsgraph *depsgraph = reshape_context->depsgraph;
Depsgraph *depsgraph = reshape_context->depsgraph;
Object *object = reshape_context->object;
MultiresModifierData *mmd = reshape_context->mmd;
BLI_assert(depsgraph != NULL);
BLI_assert(object != NULL);
BLI_assert(mmd != NULL);
BLI_assert(depsgraph != nullptr);
BLI_assert(object != nullptr);
BLI_assert(mmd != nullptr);
float(*deformed_verts)[3] = BKE_multires_create_deformed_base_mesh_vert_coords(
depsgraph, object, mmd, NULL);
depsgraph, object, mmd, nullptr);
BKE_subdiv_eval_refine_from_mesh(
reshape_context->subdiv, reshape_context->base_mesh, deformed_verts);

View File

@ -7,7 +7,7 @@
#include "multires_reshape.h"
#include <string.h>
#include <cstring>
#include "BLI_utildefines.h"
@ -15,21 +15,21 @@
#include "BKE_subdiv_ccg.h"
bool multires_reshape_assign_final_coords_from_ccg(const MultiresReshapeContext *reshape_context,
struct SubdivCCG *subdiv_ccg)
SubdivCCG *subdiv_ccg)
{
CCGKey reshape_level_key;
BKE_subdiv_ccg_key(&reshape_level_key, subdiv_ccg, reshape_context->reshape.level);
const int reshape_grid_size = reshape_context->reshape.grid_size;
const float reshape_grid_size_1_inv = 1.0f / (((float)reshape_grid_size) - 1.0f);
const float reshape_grid_size_1_inv = 1.0f / ((float(reshape_grid_size)) - 1.0f);
int num_grids = subdiv_ccg->num_grids;
for (int grid_index = 0; grid_index < num_grids; ++grid_index) {
CCGElem *ccg_grid = subdiv_ccg->grids[grid_index];
for (int y = 0; y < reshape_grid_size; ++y) {
const float v = (float)y * reshape_grid_size_1_inv;
const float v = float(y) * reshape_grid_size_1_inv;
for (int x = 0; x < reshape_grid_size; ++x) {
const float u = (float)x * reshape_grid_size_1_inv;
const float u = float(x) * reshape_grid_size_1_inv;
GridCoord grid_coord;
grid_coord.grid_index = grid_index;
@ -39,7 +39,7 @@ bool multires_reshape_assign_final_coords_from_ccg(const MultiresReshapeContext
ReshapeGridElement grid_element = multires_reshape_grid_element_for_grid_coord(
reshape_context, &grid_coord);
BLI_assert(grid_element.displacement != NULL);
BLI_assert(grid_element.displacement != nullptr);
memcpy(grid_element.displacement,
CCG_grid_elem_co(&reshape_level_key, ccg_grid, x, y),
sizeof(float[3]));
@ -66,7 +66,7 @@ bool multires_reshape_assign_final_coords_from_ccg(const MultiresReshapeContext
/* NOTE: There is a known bug in Undo code that results in first Sculpt step
* after a Memfile one to never be undone (see T83806). This might be the root cause of
* this inconsistency. */
if (reshape_level_key.has_mask && grid_element.mask != NULL) {
if (reshape_level_key.has_mask && grid_element.mask != nullptr) {
*grid_element.mask = *CCG_grid_elem_mask(&reshape_level_key, ccg_grid, x, y);
}
}

View File

@ -41,19 +41,19 @@
* Used to store pre-calculated information which is expensive or impossible to evaluate when
* traversing the final limit surface. */
typedef struct SurfacePoint {
struct SurfacePoint {
float P[3];
float tangent_matrix[3][3];
} SurfacePoint;
};
typedef struct SurfaceGrid {
struct SurfaceGrid {
SurfacePoint *points;
} SurfaceGrid;
};
/* Geometry elements which are used to simplify creation of topology refiner at the sculpt level.
* Contains a limited subset of information needed to construct topology refiner. */
typedef struct Vertex {
struct Vertex {
/* All grid coordinates which the vertex corresponding to.
* For a vertices which are created from inner points of grids there is always one coordinate. */
int num_grid_coords;
@ -61,36 +61,36 @@ typedef struct Vertex {
float sharpness;
bool is_infinite_sharp;
} Vertex;
};
typedef struct Corner {
struct Corner {
const Vertex *vertex;
int grid_index;
} Corner;
};
typedef struct Face {
struct Face {
int start_corner_index;
int num_corners;
} Face;
};
typedef struct Edge {
struct Edge {
int v1;
int v2;
float sharpness;
} Edge;
};
/* Storage of data which is linearly interpolated from the reshape level to the top level. */
typedef struct LinearGridElement {
struct LinearGridElement {
float mask;
} LinearGridElement;
};
typedef struct LinearGrid {
struct LinearGrid {
LinearGridElement *elements;
} LinearGrid;
};
typedef struct LinearGrids {
struct LinearGrids {
int num_grids;
int level;
@ -102,11 +102,11 @@ typedef struct LinearGrids {
/* Elements for all grids are allocated in a single array, for the allocation performance. */
LinearGridElement *elements_storage;
} LinearGrids;
};
/* Context which holds all information eeded during propagation and smoothing. */
typedef struct MultiresReshapeSmoothContext {
struct MultiresReshapeSmoothContext {
const MultiresReshapeContext *reshape_context;
/* Geometry at a reshape multires level. */
@ -158,7 +158,7 @@ typedef struct MultiresReshapeSmoothContext {
* NOTE: Uses same enumerator type as Subdivide operator, since the values are the same and
* decoupling type just adds extra headache to convert one enumerator to another. */
eMultiresSubdivideModeType smoothing_type;
} MultiresReshapeSmoothContext;
};
/** \} */
@ -171,8 +171,8 @@ static void linear_grids_init(LinearGrids *linear_grids)
linear_grids->num_grids = 0;
linear_grids->level = 0;
linear_grids->grids = NULL;
linear_grids->elements_storage = NULL;
linear_grids->grids = nullptr;
linear_grids->elements_storage = nullptr;
}
static void linear_grids_allocate(LinearGrids *linear_grids, int num_grids, int level)
@ -185,9 +185,10 @@ static void linear_grids_allocate(LinearGrids *linear_grids, int num_grids, int
linear_grids->level = level;
linear_grids->grid_size = grid_size;
linear_grids->grids = MEM_malloc_arrayN(num_grids, sizeof(LinearGrid), "linear grids");
linear_grids->elements_storage = MEM_calloc_arrayN(
num_grid_elements, sizeof(LinearGridElement), "linear elements storage");
linear_grids->grids = static_cast<LinearGrid *>(
MEM_malloc_arrayN(num_grids, sizeof(LinearGrid), __func__));
linear_grids->elements_storage = static_cast<LinearGridElement *>(
MEM_calloc_arrayN(num_grid_elements, sizeof(LinearGridElement), __func__));
for (int i = 0; i < num_grids; ++i) {
const size_t element_offset = grid_area * i;
@ -252,11 +253,12 @@ static void base_surface_grids_allocate(MultiresReshapeSmoothContext *reshape_sm
const int grid_size = reshape_context->top.grid_size;
const int grid_area = grid_size * grid_size;
SurfaceGrid *surface_grid = MEM_malloc_arrayN(num_grids, sizeof(SurfaceGrid), "delta grids");
SurfaceGrid *surface_grid = static_cast<SurfaceGrid *>(
MEM_malloc_arrayN(num_grids, sizeof(SurfaceGrid), __func__));
for (int grid_index = 0; grid_index < num_grids; ++grid_index) {
surface_grid[grid_index].points = MEM_calloc_arrayN(
grid_area, sizeof(SurfacePoint), "delta grid displacement");
surface_grid[grid_index].points = static_cast<SurfacePoint *>(
MEM_calloc_arrayN(grid_area, sizeof(SurfacePoint), __func__));
}
reshape_smooth_context->base_surface_grids = surface_grid;
@ -264,7 +266,7 @@ static void base_surface_grids_allocate(MultiresReshapeSmoothContext *reshape_sm
static void base_surface_grids_free(MultiresReshapeSmoothContext *reshape_smooth_context)
{
if (reshape_smooth_context->base_surface_grids == NULL) {
if (reshape_smooth_context->base_surface_grids == nullptr) {
return;
}
@ -308,13 +310,13 @@ static void base_surface_grids_write(const MultiresReshapeSmoothContext *reshape
/** \name Evaluation of subdivision surface at a reshape level
* \{ */
typedef void (*ForeachTopLevelGridCoordCallback)(
const MultiresReshapeSmoothContext *reshape_smooth_context,
const PTexCoord *ptex_coord,
const GridCoord *grid_coord,
void *userdata_v);
using ForeachTopLevelGridCoordCallback =
void (*)(const MultiresReshapeSmoothContext *reshape_smooth_context,
const PTexCoord *ptex_coord,
const GridCoord *grid_coord,
void *userdata_v);
typedef struct ForeachTopLevelGridCoordTaskData {
struct ForeachHighLevelCoordTaskData {
const MultiresReshapeSmoothContext *reshape_smooth_context;
int inner_grid_size;
@ -322,7 +324,7 @@ typedef struct ForeachTopLevelGridCoordTaskData {
ForeachTopLevelGridCoordCallback callback;
void *callback_userdata_v;
} ForeachHighLevelCoordTaskData;
};
/* Find grid index which given face was created for. */
static int get_face_grid_index(const MultiresReshapeSmoothContext *reshape_smooth_context,
@ -349,7 +351,7 @@ static GridCoord *vertex_grid_coord_with_grid_index(const Vertex *vertex, const
return &vertex->grid_coords[i];
}
}
return NULL;
return nullptr;
}
/* Get grid coordinates which correspond to corners of the given face.
@ -367,7 +369,7 @@ static void grid_coords_from_face_verts(const MultiresReshapeSmoothContext *resh
const int corner_index = face->start_corner_index + i;
const Corner *corner = &reshape_smooth_context->geometry.corners[corner_index];
grid_coords[i] = vertex_grid_coord_with_grid_index(corner->vertex, grid_index);
BLI_assert(grid_coords[i] != NULL);
BLI_assert(grid_coords[i] != nullptr);
}
}
@ -406,9 +408,9 @@ static void interpolate_grid_coord(GridCoord *result,
static void foreach_toplevel_grid_coord_task(void *__restrict userdata_v,
const int face_index,
const TaskParallelTLS *__restrict UNUSED(tls))
const TaskParallelTLS *__restrict /*tls*/)
{
ForeachHighLevelCoordTaskData *data = userdata_v;
ForeachHighLevelCoordTaskData *data = static_cast<ForeachHighLevelCoordTaskData *>(userdata_v);
const MultiresReshapeSmoothContext *reshape_smooth_context = data->reshape_smooth_context;
const int inner_grid_size = data->inner_grid_size;
@ -419,9 +421,9 @@ static void foreach_toplevel_grid_coord_task(void *__restrict userdata_v,
grid_coords_from_face_verts(reshape_smooth_context, face, face_grid_coords);
for (int y = 0; y < inner_grid_size; ++y) {
const float ptex_v = (float)y * inner_grid_size_1_inv;
const float ptex_v = float(y) * inner_grid_size_1_inv;
for (int x = 0; x < inner_grid_size; ++x) {
const float ptex_u = (float)x * inner_grid_size_1_inv;
const float ptex_u = float(x) * inner_grid_size_1_inv;
PTexCoord ptex_coord;
ptex_coord.ptex_face_index = face_index;
@ -446,7 +448,7 @@ static void foreach_toplevel_grid_coord(const MultiresReshapeSmoothContext *resh
ForeachHighLevelCoordTaskData data;
data.reshape_smooth_context = reshape_smooth_context;
data.inner_grid_size = (1 << level_difference) + 1;
data.inner_grid_size_1_inv = 1.0f / (float)(data.inner_grid_size - 1);
data.inner_grid_size_1_inv = 1.0f / float(data.inner_grid_size - 1);
data.callback = callback;
data.callback_userdata_v = callback_userdata_v;
@ -508,30 +510,30 @@ static void context_init(MultiresReshapeSmoothContext *reshape_smooth_context,
reshape_smooth_context->reshape_context = reshape_context;
reshape_smooth_context->geometry.num_vertices = 0;
reshape_smooth_context->geometry.vertices = NULL;
reshape_smooth_context->geometry.vertices = nullptr;
reshape_smooth_context->geometry.max_edges = 0;
reshape_smooth_context->geometry.num_edges = 0;
reshape_smooth_context->geometry.edges = NULL;
reshape_smooth_context->geometry.edges = nullptr;
reshape_smooth_context->geometry.num_corners = 0;
reshape_smooth_context->geometry.corners = NULL;
reshape_smooth_context->geometry.corners = nullptr;
reshape_smooth_context->geometry.num_faces = 0;
reshape_smooth_context->geometry.faces = NULL;
reshape_smooth_context->geometry.faces = nullptr;
linear_grids_init(&reshape_smooth_context->linear_delta_grids);
reshape_smooth_context->non_loose_base_edge_map = NULL;
reshape_smooth_context->reshape_subdiv = NULL;
reshape_smooth_context->base_surface_grids = NULL;
reshape_smooth_context->non_loose_base_edge_map = nullptr;
reshape_smooth_context->reshape_subdiv = nullptr;
reshape_smooth_context->base_surface_grids = nullptr;
reshape_smooth_context->smoothing_type = mode;
}
static void context_free_geometry(MultiresReshapeSmoothContext *reshape_smooth_context)
{
if (reshape_smooth_context->geometry.vertices != NULL) {
if (reshape_smooth_context->geometry.vertices != nullptr) {
for (int i = 0; i < reshape_smooth_context->geometry.num_vertices; ++i) {
MEM_SAFE_FREE(reshape_smooth_context->geometry.vertices[i].grid_coords);
}
@ -546,7 +548,7 @@ static void context_free_geometry(MultiresReshapeSmoothContext *reshape_smooth_c
static void context_free_subdiv(MultiresReshapeSmoothContext *reshape_smooth_context)
{
if (reshape_smooth_context->reshape_subdiv == NULL) {
if (reshape_smooth_context->reshape_subdiv == nullptr) {
return;
}
BKE_subdiv_free(reshape_smooth_context->reshape_subdiv);
@ -566,29 +568,30 @@ static bool foreach_topology_info(const SubdivForeachContext *foreach_context,
const int num_edges,
const int num_loops,
const int num_polygons,
const int *UNUSED(subdiv_polygon_offset))
const int * /*subdiv_polygon_offset*/)
{
MultiresReshapeSmoothContext *reshape_smooth_context = foreach_context->user_data;
MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<MultiresReshapeSmoothContext *>(foreach_context->user_data);
const int max_edges = reshape_smooth_context->smoothing_type == MULTIRES_SUBDIVIDE_LINEAR ?
num_edges :
reshape_smooth_context->geometry.max_edges;
/* NOTE: Calloc so the counters are re-set to 0 "for free". */
reshape_smooth_context->geometry.num_vertices = num_vertices;
reshape_smooth_context->geometry.vertices = MEM_calloc_arrayN(
num_vertices, sizeof(Vertex), "smooth vertices");
reshape_smooth_context->geometry.vertices = static_cast<Vertex *>(
MEM_calloc_arrayN(num_vertices, sizeof(Vertex), "smooth vertices"));
reshape_smooth_context->geometry.max_edges = max_edges;
reshape_smooth_context->geometry.edges = MEM_malloc_arrayN(
max_edges, sizeof(Edge), "smooth edges");
reshape_smooth_context->geometry.edges = static_cast<Edge *>(
MEM_malloc_arrayN(max_edges, sizeof(Edge), "smooth edges"));
reshape_smooth_context->geometry.num_corners = num_loops;
reshape_smooth_context->geometry.corners = MEM_malloc_arrayN(
num_loops, sizeof(Corner), "smooth corners");
reshape_smooth_context->geometry.corners = static_cast<Corner *>(
MEM_malloc_arrayN(num_loops, sizeof(Corner), "smooth corners"));
reshape_smooth_context->geometry.num_faces = num_polygons;
reshape_smooth_context->geometry.faces = MEM_malloc_arrayN(
num_polygons, sizeof(Face), "smooth faces");
reshape_smooth_context->geometry.faces = static_cast<Face *>(
MEM_malloc_arrayN(num_polygons, sizeof(Face), "smooth faces"));
return true;
}
@ -598,14 +601,15 @@ static void foreach_single_vertex(const SubdivForeachContext *foreach_context,
const int coarse_vertex_index,
const int subdiv_vertex_index)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = foreach_context->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<MultiresReshapeSmoothContext *>(foreach_context->user_data);
BLI_assert(subdiv_vertex_index < reshape_smooth_context->geometry.num_vertices);
Vertex *vertex = &reshape_smooth_context->geometry.vertices[subdiv_vertex_index];
vertex->grid_coords = MEM_reallocN(vertex->grid_coords,
sizeof(Vertex) * (vertex->num_grid_coords + 1));
vertex->grid_coords = static_cast<GridCoord *>(
MEM_reallocN(vertex->grid_coords, sizeof(Vertex) * (vertex->num_grid_coords + 1)));
vertex->grid_coords[vertex->num_grid_coords] = *grid_coord;
++vertex->num_grid_coords;
@ -616,7 +620,7 @@ static void foreach_single_vertex(const SubdivForeachContext *foreach_context,
const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context;
const float *cd_vertex_crease = reshape_context->cd_vertex_crease;
if (cd_vertex_crease == NULL) {
if (cd_vertex_crease == nullptr) {
return;
}
@ -630,13 +634,14 @@ static void foreach_single_vertex(const SubdivForeachContext *foreach_context,
vertex->sharpness = BKE_subdiv_crease_to_sharpness_f(crease);
}
/* TODO(sergey): De-duplicate with similar function in multires_reshape_vertcos.c */
/* TODO(sergey): De-duplicate with similar function in multires_reshape_vertcos.cc */
static void foreach_vertex(const SubdivForeachContext *foreach_context,
const PTexCoord *ptex_coord,
const int coarse_vertex_index,
const int subdiv_vertex_index)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = foreach_context->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(foreach_context->user_data);
const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context;
const GridCoord grid_coord = multires_reshape_ptex_coord_to_grid(reshape_context, ptex_coord);
@ -681,72 +686,70 @@ static void foreach_vertex(const SubdivForeachContext *foreach_context,
}
}
static void foreach_vertex_inner(const struct SubdivForeachContext *foreach_context,
void *UNUSED(tls),
static void foreach_vertex_inner(const SubdivForeachContext *foreach_context,
void * /*tls*/,
const int ptex_face_index,
const float ptex_face_u,
const float ptex_face_v,
const int UNUSED(coarse_poly_index),
const int UNUSED(coarse_corner),
const int /*coarse_poly_index*/,
const int /*coarse_corner*/,
const int subdiv_vertex_index)
{
const PTexCoord ptex_coord = {
.ptex_face_index = ptex_face_index,
.u = ptex_face_u,
.v = ptex_face_v,
};
PTexCoord ptex_coord{};
ptex_coord.ptex_face_index = ptex_face_index;
ptex_coord.u = ptex_face_u;
ptex_coord.v = ptex_face_v;
foreach_vertex(foreach_context, &ptex_coord, -1, subdiv_vertex_index);
}
static void foreach_vertex_every_corner(const struct SubdivForeachContext *foreach_context,
void *UNUSED(tls_v),
static void foreach_vertex_every_corner(const SubdivForeachContext *foreach_context,
void * /*tls_v*/,
const int ptex_face_index,
const float ptex_face_u,
const float ptex_face_v,
const int coarse_vertex_index,
const int UNUSED(coarse_face_index),
const int UNUSED(coarse_face_corner),
const int /*coarse_face_index*/,
const int /*coarse_face_corner*/,
const int subdiv_vertex_index)
{
const PTexCoord ptex_coord = {
.ptex_face_index = ptex_face_index,
.u = ptex_face_u,
.v = ptex_face_v,
};
PTexCoord ptex_coord{};
ptex_coord.ptex_face_index = ptex_face_index;
ptex_coord.u = ptex_face_u;
ptex_coord.v = ptex_face_v;
foreach_vertex(foreach_context, &ptex_coord, coarse_vertex_index, subdiv_vertex_index);
}
static void foreach_vertex_every_edge(const struct SubdivForeachContext *foreach_context,
void *UNUSED(tls_v),
static void foreach_vertex_every_edge(const SubdivForeachContext *foreach_context,
void * /*tls_v*/,
const int ptex_face_index,
const float ptex_face_u,
const float ptex_face_v,
const int UNUSED(coarse_edge_index),
const int UNUSED(coarse_face_index),
const int UNUSED(coarse_face_corner),
const int /*coarse_edge_index*/,
const int /*coarse_face_index*/,
const int /*coarse_face_corner*/,
const int subdiv_vertex_index)
{
const PTexCoord ptex_coord = {
.ptex_face_index = ptex_face_index,
.u = ptex_face_u,
.v = ptex_face_v,
};
PTexCoord ptex_coord{};
ptex_coord.ptex_face_index = ptex_face_index;
ptex_coord.u = ptex_face_u;
ptex_coord.v = ptex_face_v;
foreach_vertex(foreach_context, &ptex_coord, -1, subdiv_vertex_index);
}
static void foreach_loop(const struct SubdivForeachContext *foreach_context,
void *UNUSED(tls),
const int UNUSED(ptex_face_index),
const float UNUSED(ptex_face_u),
const float UNUSED(ptex_face_v),
const int UNUSED(coarse_loop_index),
static void foreach_loop(const SubdivForeachContext *foreach_context,
void * /*tls*/,
const int /*ptex_face_index*/,
const float /*ptex_face_u*/,
const float /*ptex_face_v*/,
const int /*coarse_loop_index*/,
const int coarse_poly_index,
const int coarse_corner,
const int subdiv_loop_index,
const int subdiv_vertex_index,
const int UNUSED(subdiv_edge_index))
const int /*subdiv_edge_index*/)
{
MultiresReshapeSmoothContext *reshape_smooth_context = foreach_context->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(foreach_context->user_data);
const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context;
BLI_assert(subdiv_loop_index < reshape_smooth_context->geometry.num_corners);
@ -759,13 +762,14 @@ static void foreach_loop(const struct SubdivForeachContext *foreach_context,
}
static void foreach_poly(const SubdivForeachContext *foreach_context,
void *UNUSED(tls),
const int UNUSED(coarse_poly_index),
void * /*tls*/,
const int /*coarse_poly_index*/,
const int subdiv_poly_index,
const int start_loop_index,
const int num_loops)
{
MultiresReshapeSmoothContext *reshape_smooth_context = foreach_context->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(foreach_context->user_data);
BLI_assert(subdiv_poly_index < reshape_smooth_context->geometry.num_faces);
@ -774,13 +778,14 @@ static void foreach_poly(const SubdivForeachContext *foreach_context,
face->num_corners = num_loops;
}
static void foreach_vertex_of_loose_edge(const struct SubdivForeachContext *foreach_context,
void *UNUSED(tls),
const int UNUSED(coarse_edge_index),
const float UNUSED(u),
static void foreach_vertex_of_loose_edge(const SubdivForeachContext *foreach_context,
void * /*tls*/,
const int /*coarse_edge_index*/,
const float /*u*/,
const int vertex_index)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = foreach_context->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(foreach_context->user_data);
Vertex *vertex = &reshape_smooth_context->geometry.vertices[vertex_index];
if (vertex->num_grid_coords != 0) {
@ -804,19 +809,20 @@ static void store_edge(MultiresReshapeSmoothContext *reshape_smooth_context,
edge->sharpness = BKE_subdiv_crease_to_sharpness_char(crease);
}
static void foreach_edge(const struct SubdivForeachContext *foreach_context,
void *UNUSED(tls),
static void foreach_edge(const SubdivForeachContext *foreach_context,
void * /*tls*/,
const int coarse_edge_index,
const int UNUSED(subdiv_edge_index),
const int /*subdiv_edge_index*/,
const bool is_loose,
const int subdiv_v1,
const int subdiv_v2)
{
MultiresReshapeSmoothContext *reshape_smooth_context = foreach_context->user_data;
MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<MultiresReshapeSmoothContext *>(foreach_context->user_data);
if (reshape_smooth_context->smoothing_type == MULTIRES_SUBDIVIDE_LINEAR) {
if (!is_loose) {
store_edge(reshape_smooth_context, subdiv_v1, subdiv_v2, (char)255);
store_edge(reshape_smooth_context, subdiv_v1, subdiv_v2, char(255));
}
return;
}
@ -875,17 +881,16 @@ static void geometry_create(MultiresReshapeSmoothContext *reshape_smooth_context
{
const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context;
SubdivForeachContext foreach_context = {
.topology_info = foreach_topology_info,
.vertex_inner = foreach_vertex_inner,
.vertex_every_corner = foreach_vertex_every_corner,
.vertex_every_edge = foreach_vertex_every_edge,
.loop = foreach_loop,
.poly = foreach_poly,
.vertex_of_loose_edge = foreach_vertex_of_loose_edge,
.edge = foreach_edge,
.user_data = reshape_smooth_context,
};
SubdivForeachContext foreach_context{};
foreach_context.topology_info = foreach_topology_info;
foreach_context.vertex_inner = foreach_vertex_inner;
foreach_context.vertex_every_corner = foreach_vertex_every_corner;
foreach_context.vertex_every_edge = foreach_vertex_every_edge;
foreach_context.loop = foreach_loop;
foreach_context.poly = foreach_poly;
foreach_context.vertex_of_loose_edge = foreach_vertex_of_loose_edge;
foreach_context.edge = foreach_edge;
foreach_context.user_data = reshape_smooth_context;
geometry_init_loose_information(reshape_smooth_context);
@ -904,53 +909,60 @@ static void geometry_create(MultiresReshapeSmoothContext *reshape_smooth_context
/** \name Generation of OpenSubdiv evaluator for topology created form reshape level
* \{ */
static OpenSubdiv_SchemeType get_scheme_type(const OpenSubdiv_Converter *UNUSED(converter))
static OpenSubdiv_SchemeType get_scheme_type(const OpenSubdiv_Converter * /*converter*/)
{
return OSD_SCHEME_CATMARK;
}
static OpenSubdiv_VtxBoundaryInterpolation get_vtx_boundary_interpolation(
const struct OpenSubdiv_Converter *converter)
const OpenSubdiv_Converter *converter)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = converter->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(converter->user_data);
const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context;
const SubdivSettings *settings = &reshape_context->subdiv->settings;
return BKE_subdiv_converter_vtx_boundary_interpolation_from_settings(settings);
return OpenSubdiv_VtxBoundaryInterpolation(
BKE_subdiv_converter_vtx_boundary_interpolation_from_settings(settings));
}
static OpenSubdiv_FVarLinearInterpolation get_fvar_linear_interpolation(
const OpenSubdiv_Converter *converter)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = converter->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(converter->user_data);
const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context;
const SubdivSettings *settings = &reshape_context->subdiv->settings;
return BKE_subdiv_converter_fvar_linear_from_settings(settings);
return OpenSubdiv_FVarLinearInterpolation(
BKE_subdiv_converter_fvar_linear_from_settings(settings));
}
static bool specifies_full_topology(const OpenSubdiv_Converter *UNUSED(converter))
static bool specifies_full_topology(const OpenSubdiv_Converter * /*converter*/)
{
return false;
}
static int get_num_faces(const OpenSubdiv_Converter *converter)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = converter->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(converter->user_data);
return reshape_smooth_context->geometry.num_faces;
}
static int get_num_vertices(const OpenSubdiv_Converter *converter)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = converter->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(converter->user_data);
return reshape_smooth_context->geometry.num_vertices;
}
static int get_num_face_vertices(const OpenSubdiv_Converter *converter, int face_index)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = converter->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(converter->user_data);
BLI_assert(face_index < reshape_smooth_context->geometry.num_faces);
const Face *face = &reshape_smooth_context->geometry.faces[face_index];
@ -961,7 +973,8 @@ static void get_face_vertices(const OpenSubdiv_Converter *converter,
int face_index,
int *face_vertices)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = converter->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(converter->user_data);
BLI_assert(face_index < reshape_smooth_context->geometry.num_faces);
const Face *face = &reshape_smooth_context->geometry.faces[face_index];
@ -973,9 +986,10 @@ static void get_face_vertices(const OpenSubdiv_Converter *converter,
}
}
static int get_num_edges(const struct OpenSubdiv_Converter *converter)
static int get_num_edges(const OpenSubdiv_Converter *converter)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = converter->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(converter->user_data);
return reshape_smooth_context->geometry.num_edges;
}
@ -983,7 +997,8 @@ static void get_edge_vertices(const OpenSubdiv_Converter *converter,
const int edge_index,
int edge_vertices[2])
{
const MultiresReshapeSmoothContext *reshape_smooth_context = converter->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(converter->user_data);
BLI_assert(edge_index < reshape_smooth_context->geometry.num_edges);
const Edge *edge = &reshape_smooth_context->geometry.edges[edge_index];
@ -993,7 +1008,8 @@ static void get_edge_vertices(const OpenSubdiv_Converter *converter,
static float get_edge_sharpness(const OpenSubdiv_Converter *converter, const int edge_index)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = converter->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(converter->user_data);
BLI_assert(edge_index < reshape_smooth_context->geometry.num_edges);
const Edge *edge = &reshape_smooth_context->geometry.edges[edge_index];
@ -1002,7 +1018,8 @@ static float get_edge_sharpness(const OpenSubdiv_Converter *converter, const int
static float get_vertex_sharpness(const OpenSubdiv_Converter *converter, const int vertex_index)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = converter->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(converter->user_data);
BLI_assert(vertex_index < reshape_smooth_context->geometry.num_vertices);
const Vertex *vertex = &reshape_smooth_context->geometry.vertices[vertex_index];
@ -1011,7 +1028,8 @@ static float get_vertex_sharpness(const OpenSubdiv_Converter *converter, const i
static bool is_infinite_sharp_vertex(const OpenSubdiv_Converter *converter, int vertex_index)
{
const MultiresReshapeSmoothContext *reshape_smooth_context = converter->user_data;
const MultiresReshapeSmoothContext *reshape_smooth_context =
static_cast<const MultiresReshapeSmoothContext *>(converter->user_data);
BLI_assert(vertex_index < reshape_smooth_context->geometry.num_vertices);
@ -1033,27 +1051,27 @@ static void converter_init(const MultiresReshapeSmoothContext *reshape_smooth_co
converter->getNumFaceVertices = get_num_face_vertices;
converter->getFaceVertices = get_face_vertices;
converter->getFaceEdges = NULL;
converter->getFaceEdges = nullptr;
converter->getEdgeVertices = get_edge_vertices;
converter->getNumEdgeFaces = NULL;
converter->getEdgeFaces = NULL;
converter->getNumEdgeFaces = nullptr;
converter->getEdgeFaces = nullptr;
converter->getEdgeSharpness = get_edge_sharpness;
converter->getNumVertexEdges = NULL;
converter->getVertexEdges = NULL;
converter->getNumVertexFaces = NULL;
converter->getVertexFaces = NULL;
converter->getNumVertexEdges = nullptr;
converter->getVertexEdges = nullptr;
converter->getNumVertexFaces = nullptr;
converter->getVertexFaces = nullptr;
converter->isInfiniteSharpVertex = is_infinite_sharp_vertex;
converter->getVertexSharpness = get_vertex_sharpness;
converter->getNumUVLayers = NULL;
converter->precalcUVLayer = NULL;
converter->finishUVLayer = NULL;
converter->getNumUVCoordinates = NULL;
converter->getFaceCornerUVIndex = NULL;
converter->getNumUVLayers = nullptr;
converter->precalcUVLayer = nullptr;
converter->finishUVLayer = nullptr;
converter->getNumUVCoordinates = nullptr;
converter->getFaceCornerUVIndex = nullptr;
converter->freeUserData = NULL;
converter->freeUserData = nullptr;
converter->user_data = (void *)reshape_smooth_context;
}
@ -1070,7 +1088,7 @@ static void reshape_subdiv_create(MultiresReshapeSmoothContext *reshape_smooth_c
Subdiv *reshape_subdiv = BKE_subdiv_new_from_converter(settings, &converter);
OpenSubdiv_EvaluatorSettings evaluator_settings = {0};
BKE_subdiv_eval_begin(reshape_subdiv, SUBDIV_EVALUATOR_TYPE_CPU, NULL, &evaluator_settings);
BKE_subdiv_eval_begin(reshape_subdiv, SUBDIV_EVALUATOR_TYPE_CPU, nullptr, &evaluator_settings);
reshape_smooth_context->reshape_subdiv = reshape_subdiv;
@ -1107,7 +1125,7 @@ BLI_INLINE const GridCoord *reshape_subdiv_refine_vertex_grid_coord(const Vertex
/* This is a loose vertex, the coordinate is not important. */
/* TODO(sergey): Once the subdiv_foreach() supports properly ignoring loose elements this
* should become an assert instead. */
return NULL;
return nullptr;
}
/* NOTE: All grid coordinates will point to the same object position, so can be simple and use
* first grid coordinate. */
@ -1122,7 +1140,7 @@ static void reshape_subdiv_refine_orig_P(
const GridCoord *grid_coord = reshape_subdiv_refine_vertex_grid_coord(vertex);
/* Check whether this is a loose vertex. */
if (grid_coord == NULL) {
if (grid_coord == nullptr) {
zero_v3(r_P);
return;
}
@ -1152,7 +1170,7 @@ static void reshape_subdiv_refine_final_P(
const GridCoord *grid_coord = reshape_subdiv_refine_vertex_grid_coord(vertex);
/* Check whether this is a loose vertex. */
if (grid_coord == NULL) {
if (grid_coord == nullptr) {
zero_v3(r_P);
return;
}
@ -1225,7 +1243,7 @@ static LinearGridElement linear_grid_element_final_get(
LinearGridElement linear_grid_element;
linear_grid_element_init(&linear_grid_element);
if (final_grid_element.mask != NULL) {
if (final_grid_element.mask != nullptr) {
linear_grid_element.mask = *final_grid_element.mask;
}
@ -1247,7 +1265,7 @@ static void linear_grid_element_delta_interpolate(
const int reshape_level = reshape_context->reshape.level;
const int reshape_level_grid_size = BKE_subdiv_grid_size_from_level(reshape_level);
const int reshape_level_grid_size_1 = reshape_level_grid_size - 1;
const float reshape_level_grid_size_1_inv = 1.0f / (float)(reshape_level_grid_size_1);
const float reshape_level_grid_size_1_inv = 1.0f / float(reshape_level_grid_size_1);
const float x_f = grid_coord->u * reshape_level_grid_size_1;
const float y_f = grid_coord->v * reshape_level_grid_size_1;
@ -1282,9 +1300,9 @@ static void linear_grid_element_delta_interpolate(
static void evaluate_linear_delta_grids_callback(
const MultiresReshapeSmoothContext *reshape_smooth_context,
const PTexCoord *UNUSED(ptex_coord),
const PTexCoord * /*ptex_coord*/,
const GridCoord *grid_coord,
void *UNUSED(userdata_v))
void * /*userdata_v*/)
{
LinearGridElement *linear_delta_element = linear_grid_element_get(
&reshape_smooth_context->linear_delta_grids, grid_coord);
@ -1300,7 +1318,8 @@ static void evaluate_linear_delta_grids(MultiresReshapeSmoothContext *reshape_sm
linear_grids_allocate(&reshape_smooth_context->linear_delta_grids, num_grids, top_level);
foreach_toplevel_grid_coord(reshape_smooth_context, evaluate_linear_delta_grids_callback, NULL);
foreach_toplevel_grid_coord(
reshape_smooth_context, evaluate_linear_delta_grids_callback, nullptr);
}
static void propagate_linear_data_delta(const MultiresReshapeSmoothContext *reshape_smooth_context,
@ -1315,7 +1334,7 @@ static void propagate_linear_data_delta(const MultiresReshapeSmoothContext *resh
const ReshapeConstGridElement orig_grid_element =
multires_reshape_orig_grid_element_for_grid_coord(reshape_context, grid_coord);
if (final_grid_element->mask != NULL) {
if (final_grid_element->mask != nullptr) {
*final_grid_element->mask = clamp_f(
orig_grid_element.mask + linear_delta_element->mask, 0.0f, 1.0f);
}
@ -1331,7 +1350,7 @@ static void evaluate_base_surface_grids_callback(
const MultiresReshapeSmoothContext *reshape_smooth_context,
const PTexCoord *ptex_coord,
const GridCoord *grid_coord,
void *UNUSED(userdata_v))
void * /*userdata_v*/)
{
float limit_P[3];
float tangent_matrix[3][3];
@ -1343,7 +1362,8 @@ static void evaluate_base_surface_grids_callback(
static void evaluate_base_surface_grids(const MultiresReshapeSmoothContext *reshape_smooth_context)
{
foreach_toplevel_grid_coord(reshape_smooth_context, evaluate_base_surface_grids_callback, NULL);
foreach_toplevel_grid_coord(
reshape_smooth_context, evaluate_base_surface_grids_callback, nullptr);
}
/** \} */
@ -1383,7 +1403,7 @@ static void evaluate_higher_grid_positions_with_details_callback(
const MultiresReshapeSmoothContext *reshape_smooth_context,
const PTexCoord *ptex_coord,
const GridCoord *grid_coord,
void *UNUSED(userdata_v))
void * /*userdata_v*/)
{
const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context;
@ -1433,14 +1453,14 @@ static void evaluate_higher_grid_positions_with_details(
const MultiresReshapeSmoothContext *reshape_smooth_context)
{
foreach_toplevel_grid_coord(
reshape_smooth_context, evaluate_higher_grid_positions_with_details_callback, NULL);
reshape_smooth_context, evaluate_higher_grid_positions_with_details_callback, nullptr);
}
static void evaluate_higher_grid_positions_callback(
const MultiresReshapeSmoothContext *reshape_smooth_context,
const PTexCoord *ptex_coord,
const GridCoord *grid_coord,
void *UNUSED(userdata_v))
void * /*userdata_v*/)
{
const MultiresReshapeContext *reshape_context = reshape_smooth_context->reshape_context;
Subdiv *reshape_subdiv = reshape_smooth_context->reshape_subdiv;
@ -1463,7 +1483,7 @@ static void evaluate_higher_grid_positions(
const MultiresReshapeSmoothContext *reshape_smooth_context)
{
foreach_toplevel_grid_coord(
reshape_smooth_context, evaluate_higher_grid_positions_callback, NULL);
reshape_smooth_context, evaluate_higher_grid_positions_callback, nullptr);
}
/** \} */

View File

@ -32,7 +32,8 @@ static void multires_subdivide_create_object_space_linear_grids(Mesh *mesh)
const MPoly *polys = BKE_mesh_polys(mesh);
const MLoop *loops = BKE_mesh_loops(mesh);
MDisps *mdisps = CustomData_get_layer_for_write(&mesh->ldata, CD_MDISPS, mesh->totloop);
MDisps *mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh->ldata, CD_MDISPS, mesh->totloop));
const int totpoly = mesh->totpoly;
for (int p = 0; p < totpoly; p++) {
const MPoly *poly = &polys[p];
@ -63,7 +64,7 @@ static void multires_subdivide_create_object_space_linear_grids(Mesh *mesh)
void multires_subdivide_create_tangent_displacement_linear_grids(Object *object,
MultiresModifierData *mmd)
{
Mesh *coarse_mesh = object->data;
Mesh *coarse_mesh = static_cast<Mesh *>(object->data);
multires_force_sculpt_rebuild(object);
MultiresReshapeContext reshape_context;
@ -73,7 +74,7 @@ void multires_subdivide_create_tangent_displacement_linear_grids(Object *object,
const bool has_mdisps = CustomData_has_layer(&coarse_mesh->ldata, CD_MDISPS);
if (!has_mdisps) {
CustomData_add_layer(
&coarse_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, NULL, coarse_mesh->totloop);
&coarse_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, coarse_mesh->totloop);
}
if (new_top_level == 1) {

View File

@ -39,7 +39,7 @@ Subdiv *multires_reshape_create_subdiv(Depsgraph *depsgraph,
{
Mesh *base_mesh;
if (depsgraph != NULL) {
if (depsgraph != nullptr) {
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
Object *object_eval = DEG_get_evaluated_object(depsgraph, object);
base_mesh = mesh_get_eval_deform(depsgraph, scene_eval, object_eval, &CD_MASK_BAREMESH);
@ -51,9 +51,10 @@ Subdiv *multires_reshape_create_subdiv(Depsgraph *depsgraph,
SubdivSettings subdiv_settings;
BKE_multires_subdiv_settings_init(&subdiv_settings, mmd);
Subdiv *subdiv = BKE_subdiv_new_from_mesh(&subdiv_settings, base_mesh);
if (!BKE_subdiv_eval_begin_from_mesh(subdiv, base_mesh, NULL, SUBDIV_EVALUATOR_TYPE_CPU, NULL)) {
if (!BKE_subdiv_eval_begin_from_mesh(
subdiv, base_mesh, nullptr, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) {
BKE_subdiv_free(subdiv);
return NULL;
return nullptr;
}
return subdiv;
}
@ -69,8 +70,8 @@ static void context_init_lookup(MultiresReshapeContext *reshape_context)
const MPoly *mpoly = reshape_context->base_polys;
const int num_faces = base_mesh->totpoly;
reshape_context->face_start_grid_index = MEM_malloc_arrayN(
num_faces, sizeof(int), "face_start_grid_index");
reshape_context->face_start_grid_index = static_cast<int *>(
MEM_malloc_arrayN(num_faces, sizeof(int), "face_start_grid_index"));
int num_grids = 0;
int num_ptex_faces = 0;
for (int face_index = 0; face_index < num_faces; ++face_index) {
@ -80,10 +81,10 @@ static void context_init_lookup(MultiresReshapeContext *reshape_context)
num_ptex_faces += (num_corners == 4) ? 1 : num_corners;
}
reshape_context->grid_to_face_index = MEM_malloc_arrayN(
num_grids, sizeof(int), "grid_to_face_index");
reshape_context->ptex_start_grid_index = MEM_malloc_arrayN(
num_ptex_faces, sizeof(int), "ptex_start_grid_index");
reshape_context->grid_to_face_index = static_cast<int *>(
MEM_malloc_arrayN(num_grids, sizeof(int), "grid_to_face_index"));
reshape_context->ptex_start_grid_index = static_cast<int *>(
MEM_malloc_arrayN(num_ptex_faces, sizeof(int), "ptex_start_grid_index"));
for (int face_index = 0, grid_index = 0, ptex_index = 0; face_index < num_faces; ++face_index) {
const int num_corners = mpoly[face_index].totloop;
const int num_face_ptex_faces = (num_corners == 4) ? 1 : num_corners;
@ -103,16 +104,16 @@ static void context_init_lookup(MultiresReshapeContext *reshape_context)
static void context_init_grid_pointers(MultiresReshapeContext *reshape_context)
{
Mesh *base_mesh = reshape_context->base_mesh;
reshape_context->mdisps = CustomData_get_layer_for_write(
&base_mesh->ldata, CD_MDISPS, base_mesh->totloop);
reshape_context->grid_paint_masks = CustomData_get_layer_for_write(
&base_mesh->ldata, CD_GRID_PAINT_MASK, base_mesh->totloop);
reshape_context->mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&base_mesh->ldata, CD_MDISPS, base_mesh->totloop));
reshape_context->grid_paint_masks = static_cast<GridPaintMask *>(
CustomData_get_layer_for_write(&base_mesh->ldata, CD_GRID_PAINT_MASK, base_mesh->totloop));
}
static void context_init_commoon(MultiresReshapeContext *reshape_context)
{
BLI_assert(reshape_context->subdiv != NULL);
BLI_assert(reshape_context->base_mesh != NULL);
BLI_assert(reshape_context->subdiv != nullptr);
BLI_assert(reshape_context->base_mesh != nullptr);
reshape_context->face_ptex_offset = BKE_subdiv_face_ptex_offset_get(reshape_context->subdiv);
@ -122,7 +123,7 @@ static void context_init_commoon(MultiresReshapeContext *reshape_context)
static bool context_is_valid(MultiresReshapeContext *reshape_context)
{
if (reshape_context->mdisps == NULL) {
if (reshape_context->mdisps == nullptr) {
/* Multi-resolution displacement has been removed before current changes were applies. */
return false;
}
@ -159,7 +160,7 @@ bool multires_reshape_context_create_from_base_mesh(MultiresReshapeContext *resh
reshape_context->base_polys = BKE_mesh_polys(base_mesh);
reshape_context->base_loops = BKE_mesh_loops(base_mesh);
reshape_context->subdiv = multires_reshape_create_subdiv(NULL, object, mmd);
reshape_context->subdiv = multires_reshape_create_subdiv(nullptr, object, mmd);
reshape_context->need_free_subdiv = true;
reshape_context->reshape.level = multires_get_level(
@ -207,8 +208,10 @@ bool multires_reshape_context_create_from_object(MultiresReshapeContext *reshape
reshape_context->top.level = mmd->totlvl;
reshape_context->top.grid_size = BKE_subdiv_grid_size_from_level(reshape_context->top.level);
reshape_context->cd_vertex_crease = CustomData_get_layer(&base_mesh->vdata, CD_CREASE);
reshape_context->cd_edge_crease = CustomData_get_layer(&base_mesh->edata, CD_CREASE);
reshape_context->cd_vertex_crease = static_cast<const float *>(
CustomData_get_layer(&base_mesh->vdata, CD_CREASE));
reshape_context->cd_edge_crease = static_cast<const float *>(
CustomData_get_layer(&base_mesh->edata, CD_CREASE));
context_init_commoon(reshape_context);
@ -244,11 +247,11 @@ bool multires_reshape_context_create_from_ccg(MultiresReshapeContext *reshape_co
}
bool multires_reshape_context_create_from_modifier(MultiresReshapeContext *reshape_context,
struct Object *object,
struct MultiresModifierData *mmd,
Object *object,
MultiresModifierData *mmd,
int top_level)
{
Subdiv *subdiv = multires_reshape_create_subdiv(NULL, object, mmd);
Subdiv *subdiv = multires_reshape_create_subdiv(nullptr, object, mmd);
const bool result = multires_reshape_context_create_from_subdiv(
reshape_context, object, mmd, subdiv, top_level);
@ -259,9 +262,9 @@ bool multires_reshape_context_create_from_modifier(MultiresReshapeContext *resha
}
bool multires_reshape_context_create_from_subdiv(MultiresReshapeContext *reshape_context,
struct Object *object,
struct MultiresModifierData *mmd,
struct Subdiv *subdiv,
Object *object,
MultiresModifierData *mmd,
Subdiv *subdiv,
int top_level)
{
context_zero(reshape_context);
@ -297,17 +300,17 @@ void multires_reshape_free_original_grids(MultiresReshapeContext *reshape_contex
MDisps *orig_mdisps = reshape_context->orig.mdisps;
GridPaintMask *orig_grid_paint_masks = reshape_context->orig.grid_paint_masks;
if (orig_mdisps == NULL && orig_grid_paint_masks == NULL) {
if (orig_mdisps == nullptr && orig_grid_paint_masks == nullptr) {
return;
}
const int num_grids = reshape_context->num_grids;
for (int grid_index = 0; grid_index < num_grids; grid_index++) {
if (orig_mdisps != NULL) {
if (orig_mdisps != nullptr) {
MDisps *orig_grid = &orig_mdisps[grid_index];
MEM_SAFE_FREE(orig_grid->disps);
}
if (orig_grid_paint_masks != NULL) {
if (orig_grid_paint_masks != nullptr) {
GridPaintMask *orig_paint_mask_grid = &orig_grid_paint_masks[grid_index];
MEM_SAFE_FREE(orig_paint_mask_grid->data);
}
@ -316,8 +319,8 @@ void multires_reshape_free_original_grids(MultiresReshapeContext *reshape_contex
MEM_SAFE_FREE(orig_mdisps);
MEM_SAFE_FREE(orig_grid_paint_masks);
reshape_context->orig.mdisps = NULL;
reshape_context->orig.grid_paint_masks = NULL;
reshape_context->orig.mdisps = nullptr;
reshape_context->orig.grid_paint_masks = nullptr;
}
void multires_reshape_context_free(MultiresReshapeContext *reshape_context)
@ -447,19 +450,19 @@ void multires_reshape_tangent_matrix_for_corner(const MultiresReshapeContext *re
ReshapeGridElement multires_reshape_grid_element_for_grid_coord(
const MultiresReshapeContext *reshape_context, const GridCoord *grid_coord)
{
ReshapeGridElement grid_element = {NULL, NULL};
ReshapeGridElement grid_element = {nullptr, nullptr};
const int grid_size = reshape_context->top.grid_size;
const int grid_x = lround(grid_coord->u * (grid_size - 1));
const int grid_y = lround(grid_coord->v * (grid_size - 1));
const int grid_element_index = grid_y * grid_size + grid_x;
if (reshape_context->mdisps != NULL) {
if (reshape_context->mdisps != nullptr) {
MDisps *displacement_grid = &reshape_context->mdisps[grid_coord->grid_index];
grid_element.displacement = displacement_grid->disps[grid_element_index];
}
if (reshape_context->grid_paint_masks != NULL) {
if (reshape_context->grid_paint_masks != nullptr) {
GridPaintMask *grid_paint_mask = &reshape_context->grid_paint_masks[grid_coord->grid_index];
grid_element.mask = &grid_paint_mask->data[grid_element_index];
}
@ -480,9 +483,9 @@ ReshapeConstGridElement multires_reshape_orig_grid_element_for_grid_coord(
ReshapeConstGridElement grid_element = {{0.0f, 0.0f, 0.0f}, 0.0f};
const MDisps *mdisps = reshape_context->orig.mdisps;
if (mdisps != NULL) {
if (mdisps != nullptr) {
const MDisps *displacement_grid = &mdisps[grid_coord->grid_index];
if (displacement_grid->disps != NULL) {
if (displacement_grid->disps != nullptr) {
const int grid_size = BKE_subdiv_grid_size_from_level(displacement_grid->level);
const int grid_x = lround(grid_coord->u * (grid_size - 1));
const int grid_y = lround(grid_coord->v * (grid_size - 1));
@ -492,9 +495,9 @@ ReshapeConstGridElement multires_reshape_orig_grid_element_for_grid_coord(
}
const GridPaintMask *grid_paint_masks = reshape_context->orig.grid_paint_masks;
if (grid_paint_masks != NULL) {
if (grid_paint_masks != nullptr) {
const GridPaintMask *paint_mask_grid = &grid_paint_masks[grid_coord->grid_index];
if (paint_mask_grid->data != NULL) {
if (paint_mask_grid->data != nullptr) {
const int grid_size = BKE_subdiv_grid_size_from_level(paint_mask_grid->level);
const int grid_x = lround(grid_coord->u * (grid_size - 1));
const int grid_y = lround(grid_coord->v * (grid_size - 1));
@ -540,8 +543,9 @@ static void allocate_displacement_grid(MDisps *displacement_grid, const int leve
{
const int grid_size = BKE_subdiv_grid_size_from_level(level);
const int grid_area = grid_size * grid_size;
float(*disps)[3] = MEM_calloc_arrayN(grid_area, sizeof(float[3]), "multires disps");
if (displacement_grid->disps != NULL) {
float(*disps)[3] = static_cast<float(*)[3]>(
MEM_calloc_arrayN(grid_area, sizeof(float[3]), "multires disps"));
if (displacement_grid->disps != nullptr) {
MEM_freeN(displacement_grid->disps);
}
/* TODO(sergey): Preserve data on the old level. */
@ -552,7 +556,7 @@ static void allocate_displacement_grid(MDisps *displacement_grid, const int leve
static void ensure_displacement_grid(MDisps *displacement_grid, const int level)
{
if (displacement_grid->disps != NULL && displacement_grid->level >= level) {
if (displacement_grid->disps != nullptr && displacement_grid->level >= level) {
return;
}
allocate_displacement_grid(displacement_grid, level);
@ -561,7 +565,8 @@ static void ensure_displacement_grid(MDisps *displacement_grid, const int level)
static void ensure_displacement_grids(Mesh *mesh, const int grid_level)
{
const int num_grids = mesh->totloop;
MDisps *mdisps = CustomData_get_layer_for_write(&mesh->ldata, CD_MDISPS, mesh->totloop);
MDisps *mdisps = static_cast<MDisps *>(
CustomData_get_layer_for_write(&mesh->ldata, CD_MDISPS, mesh->totloop));
for (int grid_index = 0; grid_index < num_grids; grid_index++) {
ensure_displacement_grid(&mdisps[grid_index], grid_level);
}
@ -569,9 +574,9 @@ static void ensure_displacement_grids(Mesh *mesh, const int grid_level)
static void ensure_mask_grids(Mesh *mesh, const int level)
{
GridPaintMask *grid_paint_masks = CustomData_get_layer_for_write(
&mesh->ldata, CD_GRID_PAINT_MASK, mesh->totloop);
if (grid_paint_masks == NULL) {
GridPaintMask *grid_paint_masks = static_cast<GridPaintMask *>(
CustomData_get_layer_for_write(&mesh->ldata, CD_GRID_PAINT_MASK, mesh->totloop));
if (grid_paint_masks == nullptr) {
return;
}
const int num_grids = mesh->totloop;
@ -587,7 +592,8 @@ static void ensure_mask_grids(Mesh *mesh, const int level)
MEM_freeN(grid_paint_mask->data);
}
/* TODO(sergey): Preserve data on the old level. */
grid_paint_mask->data = MEM_calloc_arrayN(grid_area, sizeof(float), "gpm.data");
grid_paint_mask->data = static_cast<float *>(
MEM_calloc_arrayN(grid_area, sizeof(float), "gpm.data"));
}
}
@ -608,10 +614,10 @@ void multires_reshape_store_original_grids(MultiresReshapeContext *reshape_conte
const MDisps *mdisps = reshape_context->mdisps;
const GridPaintMask *grid_paint_masks = reshape_context->grid_paint_masks;
MDisps *orig_mdisps = MEM_dupallocN(mdisps);
GridPaintMask *orig_grid_paint_masks = NULL;
if (grid_paint_masks != NULL) {
orig_grid_paint_masks = MEM_dupallocN(grid_paint_masks);
MDisps *orig_mdisps = static_cast<MDisps *>(MEM_dupallocN(mdisps));
GridPaintMask *orig_grid_paint_masks = nullptr;
if (grid_paint_masks != nullptr) {
orig_grid_paint_masks = static_cast<GridPaintMask *>(MEM_dupallocN(grid_paint_masks));
}
const int num_grids = reshape_context->num_grids;
@ -621,13 +627,14 @@ void multires_reshape_store_original_grids(MultiresReshapeContext *reshape_conte
* data when accessed during reshape process.
* Reshape process will ensure all grids are on top level, but that happens on separate set of
* grids which eventually replaces original one. */
if (orig_grid->disps != NULL) {
orig_grid->disps = MEM_dupallocN(orig_grid->disps);
if (orig_grid->disps != nullptr) {
orig_grid->disps = static_cast<float(*)[3]>(MEM_dupallocN(orig_grid->disps));
}
if (orig_grid_paint_masks != NULL) {
if (orig_grid_paint_masks != nullptr) {
GridPaintMask *orig_paint_mask_grid = &orig_grid_paint_masks[grid_index];
if (orig_paint_mask_grid->data != NULL) {
orig_paint_mask_grid->data = MEM_dupallocN(orig_paint_mask_grid->data);
if (orig_paint_mask_grid->data != nullptr) {
orig_paint_mask_grid->data = static_cast<float *>(
MEM_dupallocN(orig_paint_mask_grid->data));
}
}
}
@ -636,11 +643,11 @@ void multires_reshape_store_original_grids(MultiresReshapeContext *reshape_conte
reshape_context->orig.grid_paint_masks = orig_grid_paint_masks;
}
typedef void (*ForeachGridCoordinateCallback)(const MultiresReshapeContext *reshape_context,
const GridCoord *grid_coord,
void *userdata_v);
using ForeachGridCoordinateCallback = void (*)(const MultiresReshapeContext *reshape_context,
const GridCoord *grid_coord,
void *userdata_v);
typedef struct ForeachGridCoordinateTaskData {
struct ForeachGridCoordinateTaskData {
const MultiresReshapeContext *reshape_context;
int grid_size;
@ -648,27 +655,27 @@ typedef struct ForeachGridCoordinateTaskData {
ForeachGridCoordinateCallback callback;
void *callback_userdata_v;
} ForeachGridCoordinateTaskData;
};
static void foreach_grid_face_coordinate_task(void *__restrict userdata_v,
const int face_index,
const TaskParallelTLS *__restrict UNUSED(tls))
const TaskParallelTLS *__restrict /*tls*/)
{
ForeachGridCoordinateTaskData *data = userdata_v;
ForeachGridCoordinateTaskData *data = static_cast<ForeachGridCoordinateTaskData *>(userdata_v);
const MultiresReshapeContext *reshape_context = data->reshape_context;
const MPoly *mpoly = reshape_context->base_polys;
const int grid_size = data->grid_size;
const float grid_size_1_inv = 1.0f / (((float)grid_size) - 1.0f);
const float grid_size_1_inv = 1.0f / ((float(grid_size)) - 1.0f);
const int num_corners = mpoly[face_index].totloop;
int grid_index = reshape_context->face_start_grid_index[face_index];
for (int corner = 0; corner < num_corners; ++corner, ++grid_index) {
for (int y = 0; y < grid_size; ++y) {
const float v = (float)y * grid_size_1_inv;
const float v = float(y) * grid_size_1_inv;
for (int x = 0; x < grid_size; ++x) {
const float u = (float)x * grid_size_1_inv;
const float u = float(x) * grid_size_1_inv;
GridCoord grid_coord;
grid_coord.grid_index = grid_index;
@ -690,7 +697,7 @@ static void foreach_grid_coordinate(const MultiresReshapeContext *reshape_contex
ForeachGridCoordinateTaskData data;
data.reshape_context = reshape_context;
data.grid_size = BKE_subdiv_grid_size_from_level(level);
data.grid_size_1_inv = 1.0f / (((float)data.grid_size) - 1.0f);
data.grid_size_1_inv = 1.0f / ((float(data.grid_size)) - 1.0f);
data.callback = callback;
data.callback_userdata_v = userdata_v;
@ -707,7 +714,7 @@ static void foreach_grid_coordinate(const MultiresReshapeContext *reshape_contex
static void object_grid_element_to_tangent_displacement(
const MultiresReshapeContext *reshape_context,
const GridCoord *grid_coord,
void *UNUSED(userdata_v))
void * /*userdata_v*/)
{
float P[3];
float tangent_matrix[3][3];
@ -734,7 +741,7 @@ void multires_reshape_object_grids_to_tangent_displacement(
foreach_grid_coordinate(reshape_context,
reshape_context->top.level,
object_grid_element_to_tangent_displacement,
NULL);
nullptr);
}
/** \} */
@ -748,7 +755,7 @@ void multires_reshape_object_grids_to_tangent_displacement(
static void assign_final_coords_from_mdisps(const MultiresReshapeContext *reshape_context,
const GridCoord *grid_coord,
void *UNUSED(userdata_v))
void * /*userdata_v*/)
{
float P[3];
float tangent_matrix[3][3];
@ -766,12 +773,12 @@ void multires_reshape_assign_final_coords_from_mdisps(
const MultiresReshapeContext *reshape_context)
{
foreach_grid_coordinate(
reshape_context, reshape_context->top.level, assign_final_coords_from_mdisps, NULL);
reshape_context, reshape_context->top.level, assign_final_coords_from_mdisps, nullptr);
}
static void assign_final_elements_from_orig_mdisps(const MultiresReshapeContext *reshape_context,
const GridCoord *grid_coord,
void *UNUSED(userdata_v))
void * /*userdata_v*/)
{
float P[3];
float tangent_matrix[3][3];
@ -787,7 +794,7 @@ static void assign_final_elements_from_orig_mdisps(const MultiresReshapeContext
grid_coord);
add_v3_v3v3(grid_element.displacement, P, D);
if (grid_element.mask != NULL) {
if (grid_element.mask != nullptr) {
*grid_element.mask = orig_grid_element.mask;
}
}
@ -795,8 +802,10 @@ static void assign_final_elements_from_orig_mdisps(const MultiresReshapeContext
void multires_reshape_assign_final_elements_from_orig_mdisps(
const MultiresReshapeContext *reshape_context)
{
foreach_grid_coordinate(
reshape_context, reshape_context->top.level, assign_final_elements_from_orig_mdisps, NULL);
foreach_grid_coordinate(reshape_context,
reshape_context->top.level,
assign_final_elements_from_orig_mdisps,
nullptr);
}
/** \} */

View File

@ -15,12 +15,12 @@
#include "BKE_subdiv_foreach.h"
#include "BKE_subdiv_mesh.h"
typedef struct MultiresReshapeAssignVertcosContext {
struct MultiresReshapeAssignVertcosContext {
const MultiresReshapeContext *reshape_context;
const float (*vert_coords)[3];
const int num_vert_coords;
} MultiresReshapeAssignVertcosContext;
int num_vert_coords;
};
/**
* Set single displacement grid value at a reshape level to a corresponding vertex coordinate.
@ -31,21 +31,23 @@ static void multires_reshape_vertcos_foreach_single_vertex(
const GridCoord *grid_coord,
const int subdiv_vertex_index)
{
MultiresReshapeAssignVertcosContext *reshape_vertcos_context = foreach_context->user_data;
MultiresReshapeAssignVertcosContext *reshape_vertcos_context =
static_cast<MultiresReshapeAssignVertcosContext *>(foreach_context->user_data);
const float *coordinate = reshape_vertcos_context->vert_coords[subdiv_vertex_index];
ReshapeGridElement grid_element = multires_reshape_grid_element_for_grid_coord(
reshape_vertcos_context->reshape_context, grid_coord);
BLI_assert(grid_element.displacement != NULL);
BLI_assert(grid_element.displacement != nullptr);
copy_v3_v3(grid_element.displacement, coordinate);
}
/* TODO(sergey): De-duplicate with similar function in multires_reshape_smooth.c */
/* TODO(sergey): De-duplicate with similar function in multires_reshape_smooth.cc */
static void multires_reshape_vertcos_foreach_vertex(const SubdivForeachContext *foreach_context,
const PTexCoord *ptex_coord,
const int subdiv_vertex_index)
{
const MultiresReshapeAssignVertcosContext *reshape_vertcos_context = foreach_context->user_data;
const MultiresReshapeAssignVertcosContext *reshape_vertcos_context =
static_cast<MultiresReshapeAssignVertcosContext *>(foreach_context->user_data);
const MultiresReshapeContext *reshape_context = reshape_vertcos_context->reshape_context;
const GridCoord grid_coord = multires_reshape_ptex_coord_to_grid(reshape_context, ptex_coord);
@ -95,12 +97,13 @@ static void multires_reshape_vertcos_foreach_vertex(const SubdivForeachContext *
static bool multires_reshape_vertcos_foreach_topology_info(
const SubdivForeachContext *foreach_context,
const int num_vertices,
const int UNUSED(num_edges),
const int UNUSED(num_loops),
const int UNUSED(num_polygons),
const int *UNUSED(subdiv_polygon_offset))
const int /*num_edges*/,
const int /*num_loops*/,
const int /*num_polygons*/,
const int * /*subdiv_polygon_offset*/)
{
MultiresReshapeAssignVertcosContext *reshape_vertcos_context = foreach_context->user_data;
MultiresReshapeAssignVertcosContext *reshape_vertcos_context =
static_cast<MultiresReshapeAssignVertcosContext *>(foreach_context->user_data);
if (num_vertices != reshape_vertcos_context->num_vert_coords) {
return false;
}
@ -110,59 +113,56 @@ static bool multires_reshape_vertcos_foreach_topology_info(
/* SubdivForeachContext::vertex_inner() */
static void multires_reshape_vertcos_foreach_vertex_inner(
const SubdivForeachContext *foreach_context,
void *UNUSED(tls_v),
void * /*tls_v*/,
const int ptex_face_index,
const float ptex_face_u,
const float ptex_face_v,
const int UNUSED(coarse_face_index),
const int UNUSED(coarse_face_corner),
const int /*coarse_face_index*/,
const int /*coarse_face_corner*/,
const int subdiv_vertex_index)
{
const PTexCoord ptex_coord = {
.ptex_face_index = ptex_face_index,
.u = ptex_face_u,
.v = ptex_face_v,
};
PTexCoord ptex_coord{};
ptex_coord.ptex_face_index = ptex_face_index;
ptex_coord.u = ptex_face_u;
ptex_coord.v = ptex_face_v;
multires_reshape_vertcos_foreach_vertex(foreach_context, &ptex_coord, subdiv_vertex_index);
}
/* SubdivForeachContext::vertex_every_corner() */
static void multires_reshape_vertcos_foreach_vertex_every_corner(
const struct SubdivForeachContext *foreach_context,
void *UNUSED(tls_v),
const SubdivForeachContext *foreach_context,
void * /*tls_v*/,
const int ptex_face_index,
const float ptex_face_u,
const float ptex_face_v,
const int UNUSED(coarse_vertex_index),
const int UNUSED(coarse_face_index),
const int UNUSED(coarse_face_corner),
const int /*coarse_vertex_index*/,
const int /*coarse_face_index*/,
const int /*coarse_face_corner*/,
const int subdiv_vertex_index)
{
const PTexCoord ptex_coord = {
.ptex_face_index = ptex_face_index,
.u = ptex_face_u,
.v = ptex_face_v,
};
PTexCoord ptex_coord{};
ptex_coord.ptex_face_index = ptex_face_index;
ptex_coord.u = ptex_face_u;
ptex_coord.v = ptex_face_v;
multires_reshape_vertcos_foreach_vertex(foreach_context, &ptex_coord, subdiv_vertex_index);
}
/* SubdivForeachContext::vertex_every_edge() */
static void multires_reshape_vertcos_foreach_vertex_every_edge(
const struct SubdivForeachContext *foreach_context,
void *UNUSED(tls_v),
const SubdivForeachContext *foreach_context,
void * /*tls_v*/,
const int ptex_face_index,
const float ptex_face_u,
const float ptex_face_v,
const int UNUSED(coarse_edge_index),
const int UNUSED(coarse_face_index),
const int UNUSED(coarse_face_corner),
const int /*coarse_edge_index*/,
const int /*coarse_face_index*/,
const int /*coarse_face_corner*/,
const int subdiv_vertex_index)
{
const PTexCoord ptex_coord = {
.ptex_face_index = ptex_face_index,
.u = ptex_face_u,
.v = ptex_face_v,
};
PTexCoord ptex_coord{};
ptex_coord.ptex_face_index = ptex_face_index;
ptex_coord.u = ptex_face_u;
ptex_coord.v = ptex_face_v;
multires_reshape_vertcos_foreach_vertex(foreach_context, &ptex_coord, subdiv_vertex_index);
}
@ -171,19 +171,17 @@ bool multires_reshape_assign_final_coords_from_vertcos(
const float (*vert_coords)[3],
const int num_vert_coords)
{
MultiresReshapeAssignVertcosContext reshape_vertcos_context = {
.reshape_context = reshape_context,
.vert_coords = vert_coords,
.num_vert_coords = num_vert_coords,
};
MultiresReshapeAssignVertcosContext reshape_vertcos_context{};
reshape_vertcos_context.reshape_context = reshape_context;
reshape_vertcos_context.vert_coords = vert_coords;
reshape_vertcos_context.num_vert_coords = num_vert_coords;
SubdivForeachContext foreach_context = {
.topology_info = multires_reshape_vertcos_foreach_topology_info,
.vertex_inner = multires_reshape_vertcos_foreach_vertex_inner,
.vertex_every_edge = multires_reshape_vertcos_foreach_vertex_every_edge,
.vertex_every_corner = multires_reshape_vertcos_foreach_vertex_every_corner,
.user_data = &reshape_vertcos_context,
};
SubdivForeachContext foreach_context{};
foreach_context.topology_info = multires_reshape_vertcos_foreach_topology_info;
foreach_context.vertex_inner = multires_reshape_vertcos_foreach_vertex_inner;
foreach_context.vertex_every_edge = multires_reshape_vertcos_foreach_vertex_every_edge;
foreach_context.vertex_every_corner = multires_reshape_vertcos_foreach_vertex_every_corner;
foreach_context.user_data = &reshape_vertcos_context;
SubdivToMeshSettings mesh_settings;
mesh_settings.resolution = (1 << reshape_context->reshape.level) + 1;

View File

@ -90,7 +90,7 @@ static BMVert *unsubdivide_find_any_pole(BMesh *bm, int *elem_id, int elem)
{
BMIter iter;
BMVert *v;
BMVert *pole = NULL;
BMVert *pole = nullptr;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (is_vertex_in_id(v, elem_id, elem) && is_vertex_pole_three(v)) {
return v;
@ -161,7 +161,8 @@ static bool is_vertex_diagonal(BMVert *from_v, BMVert *to_v)
*/
static void unsubdivide_face_center_vertex_tag(BMesh *bm, BMVert *initial_vertex)
{
bool *visited_verts = MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices");
bool *visited_verts = static_cast<bool *>(
MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices"));
GSQueue *queue;
queue = BLI_gsqueue_new(sizeof(BMVert *));
@ -290,14 +291,14 @@ static bool unsubdivide_tag_disconnected_mesh_element(BMesh *bm, int *elem_id, i
* part of the base mesh. If it isn't, then there is no solution. */
GSQueue *initial_vertex = BLI_gsqueue_new(sizeof(BMVert *));
BMVert *initial_vertex_pole = unsubdivide_find_any_pole(bm, elem_id, elem);
if (initial_vertex_pole != NULL) {
if (initial_vertex_pole != nullptr) {
BLI_gsqueue_push(initial_vertex, &initial_vertex_pole);
}
/* Also try from the different 4 vertices of a quad in the current
* disconnected element ID. If a solution exists the search should return a valid solution from
* one of these vertices. */
BMFace *f, *init_face = NULL;
BMFace *f, *init_face = nullptr;
BMVert *v;
BMIter iter_a, iter_b;
BM_ITER_MESH (f, &iter_a, bm, BM_FACES_OF_MESH) {
@ -307,7 +308,7 @@ static bool unsubdivide_tag_disconnected_mesh_element(BMesh *bm, int *elem_id, i
break;
}
}
if (init_face != NULL) {
if (init_face != nullptr) {
break;
}
}
@ -352,7 +353,8 @@ static bool unsubdivide_tag_disconnected_mesh_element(BMesh *bm, int *elem_id, i
*/
static int unsubdivide_init_elem_ids(BMesh *bm, int *elem_id)
{
bool *visited_verts = MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices");
bool *visited_verts = static_cast<bool *>(
MEM_calloc_arrayN(bm->totvert, sizeof(bool), "visited vertices"));
int current_id = 0;
for (int i = 0; i < bm->totvert; i++) {
if (!visited_verts[i]) {
@ -459,7 +461,7 @@ static bool multires_unsubdivide_single_level(BMesh *bm)
BM_mesh_elem_table_ensure(bm, BM_VERT);
/* Build disconnected elements IDs. Each disconnected mesh element is evaluated separately. */
int *elem_id = MEM_calloc_arrayN(bm->totvert, sizeof(int), " ELEM ID");
int *elem_id = static_cast<int *>(MEM_calloc_arrayN(bm->totvert, sizeof(int), " ELEM ID"));
const int tot_ids = unsubdivide_init_elem_ids(bm, elem_id);
bool valid_tag_found = true;
@ -495,7 +497,7 @@ static BMEdge *edge_step(BMVert *v, BMEdge *edge, BMVert **r_next_vertex)
{
BMIter iter;
BMEdge *test_edge;
if (edge == NULL) {
if (edge == nullptr) {
(*r_next_vertex) = v;
return edge;
}
@ -505,7 +507,7 @@ static BMEdge *edge_step(BMVert *v, BMEdge *edge, BMVert **r_next_vertex)
return test_edge;
}
}
return NULL;
return nullptr;
}
static BMFace *face_step(BMEdge *edge, BMFace *f)
@ -539,7 +541,7 @@ static BMEdge *get_initial_edge_y(BMFace *f, BMEdge *edge_x, BMVert *initial_ver
}
}
}
return NULL;
return nullptr;
}
/**
@ -662,7 +664,8 @@ static void store_grid_data(MultiresUnsubdivideContext *context,
const int grid_size = BKE_ccg_gridsize(context->num_original_levels);
const int face_grid_size = BKE_ccg_gridsize(context->num_original_levels + 1);
const int face_grid_area = face_grid_size * face_grid_size;
float(*face_grid)[3] = MEM_calloc_arrayN(face_grid_area, sizeof(float[3]), "face_grid");
float(*face_grid)[3] = static_cast<float(*)[3]>(
MEM_calloc_arrayN(face_grid_area, sizeof(float[3]), "face_grid"));
for (int i = 0; i < poly->totloop; i++) {
const int loop_index = poly->loopstart + i;
@ -715,8 +718,8 @@ static void multires_unsubdivide_extract_single_grid_from_face_edge(
const int grid_size = BKE_ccg_gridsize(context->num_new_levels);
const int unsubdiv_grid_size = grid->grid_size = BKE_ccg_gridsize(context->num_total_levels);
grid->grid_size = unsubdiv_grid_size;
grid->grid_co = MEM_calloc_arrayN(
unsubdiv_grid_size * unsubdiv_grid_size, sizeof(float[3]), "grids coordinates");
grid->grid_co = static_cast<float(*)[3]>(MEM_calloc_arrayN(
unsubdiv_grid_size * unsubdiv_grid_size, sizeof(float[3]), "grids coordinates"));
/* Get the vertex on the corner of the grid. This vertex was tagged previously as it also exist
* on the base mesh. */
@ -861,17 +864,15 @@ static void multires_unsubdivide_get_grid_corners_on_base_mesh(BMFace *f1,
static BMesh *get_bmesh_from_mesh(Mesh *mesh)
{
const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(mesh);
BMesh *bm = BM_mesh_create(&allocsize,
&((struct BMeshCreateParams){
.use_toolflags = true,
}));
BM_mesh_bm_from_me(bm,
mesh,
(&(struct BMeshFromMeshParams){
.calc_face_normal = true,
.calc_vert_normal = true,
}));
BMeshCreateParams bm_create_params{};
bm_create_params.use_toolflags = true;
BMesh *bm = BM_mesh_create(&allocsize, &bm_create_params);
BMeshFromMeshParams bm_from_me_params{};
bm_from_me_params.calc_face_normal = true;
bm_from_me_params.calc_vert_normal = true;
BM_mesh_bm_from_me(bm, mesh, &bm_from_me_params);
return bm;
}
@ -901,11 +902,11 @@ static void multires_unsubdivide_add_original_index_datalayers(Mesh *mesh)
{
multires_unsubdivide_free_original_datalayers(mesh);
int *l_index = CustomData_add_layer_named(
&mesh->ldata, CD_PROP_INT32, CD_SET_DEFAULT, NULL, mesh->totloop, lname);
int *l_index = static_cast<int *>(CustomData_add_layer_named(
&mesh->ldata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, mesh->totloop, lname));
int *v_index = CustomData_add_layer_named(
&mesh->vdata, CD_PROP_INT32, CD_SET_DEFAULT, NULL, mesh->totvert, vname);
int *v_index = static_cast<int *>(CustomData_add_layer_named(
&mesh->vdata, CD_PROP_INT32, CD_SET_DEFAULT, nullptr, mesh->totvert, vname));
/* Initialize these data-layer with the indices in the current mesh. */
for (int i = 0; i < mesh->totloop; i++) {
@ -938,8 +939,8 @@ static void multires_unsubdivide_prepare_original_bmesh_for_extract(
bm_original_mesh, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT, false);
/* Get the mapping data-layer. */
context->base_to_orig_vmap = CustomData_get_layer_named_for_write(
&base_mesh->vdata, CD_PROP_INT32, vname, base_mesh->totvert);
context->base_to_orig_vmap = static_cast<int *>(CustomData_get_layer_named_for_write(
&base_mesh->vdata, CD_PROP_INT32, vname, base_mesh->totvert));
/* Tag the base mesh vertices in the original mesh. */
for (int i = 0; i < base_mesh->totvert; i++) {
@ -949,7 +950,8 @@ static void multires_unsubdivide_prepare_original_bmesh_for_extract(
}
/* Create a map from loop index to poly index for the original mesh. */
context->loop_to_face_map = MEM_calloc_arrayN(original_mesh->totloop, sizeof(int), "loop map");
context->loop_to_face_map = static_cast<int *>(
MEM_calloc_arrayN(original_mesh->totloop, sizeof(int), "loop map"));
for (int i = 0; i < original_mesh->totpoly; i++) {
const MPoly *poly = &original_polys[i];
@ -993,17 +995,19 @@ static void multires_unsubdivide_extract_grids(MultiresUnsubdivideContext *conte
BMesh *bm_original_mesh = context->bm_original_mesh;
context->num_grids = base_mesh->totloop;
context->base_mesh_grids = MEM_calloc_arrayN(
base_mesh->totloop, sizeof(MultiresUnsubdivideGrid), "grids");
context->base_mesh_grids = static_cast<MultiresUnsubdivideGrid *>(
MEM_calloc_arrayN(base_mesh->totloop, sizeof(MultiresUnsubdivideGrid), "grids"));
/* Based on the existing indices in the data-layers, generate two vertex indices maps. */
/* From vertex index in original to vertex index in base and from vertex index in base to vertex
* index in original. */
int *orig_to_base_vmap = MEM_calloc_arrayN(bm_original_mesh->totvert, sizeof(int), "orig vmap");
int *base_to_orig_vmap = MEM_calloc_arrayN(base_mesh->totvert, sizeof(int), "base vmap");
int *orig_to_base_vmap = static_cast<int *>(
MEM_calloc_arrayN(bm_original_mesh->totvert, sizeof(int), "orig vmap"));
int *base_to_orig_vmap = static_cast<int *>(
MEM_calloc_arrayN(base_mesh->totvert, sizeof(int), "base vmap"));
context->base_to_orig_vmap = CustomData_get_layer_named_for_write(
&base_mesh->vdata, CD_PROP_INT32, vname, base_mesh->totvert);
context->base_to_orig_vmap = static_cast<int *>(CustomData_get_layer_named_for_write(
&base_mesh->vdata, CD_PROP_INT32, vname, base_mesh->totvert));
for (int i = 0; i < base_mesh->totvert; i++) {
base_to_orig_vmap[i] = context->base_to_orig_vmap[i];
}
@ -1099,7 +1103,7 @@ static void multires_unsubdivide_extract_grids(MultiresUnsubdivideContext *conte
static void multires_unsubdivide_private_extract_data_free(MultiresUnsubdivideContext *context)
{
if (context->bm_original_mesh != NULL) {
if (context->bm_original_mesh != nullptr) {
BM_mesh_free(context->bm_original_mesh);
}
MEM_SAFE_FREE(context->loop_to_face_map);
@ -1107,7 +1111,7 @@ static void multires_unsubdivide_private_extract_data_free(MultiresUnsubdivideCo
void multires_unsubdivide_context_init(MultiresUnsubdivideContext *context,
Mesh *original_mesh,
struct MultiresModifierData *mmd)
MultiresModifierData *mmd)
{
context->original_mesh = original_mesh;
context->num_new_levels = 0;
@ -1143,12 +1147,10 @@ bool multires_unsubdivide_to_basemesh(MultiresUnsubdivideContext *context)
/* Store the new base-mesh as a mesh in context, free bmesh. */
context->base_mesh = BKE_mesh_new_nomain(0, 0, 0, 0, 0);
BM_mesh_bm_to_me(NULL,
bm_base_mesh,
context->base_mesh,
(&(struct BMeshToMeshParams){
.calc_object_remap = true,
}));
BMeshToMeshParams bm_to_me_params{};
bm_to_me_params.calc_object_remap = true;
BM_mesh_bm_to_me(nullptr, bm_base_mesh, context->base_mesh, &bm_to_me_params);
BM_mesh_free(bm_base_mesh);
/* Initialize bmesh and maps for the original mesh and extract the grids. */
@ -1181,8 +1183,8 @@ static void multires_create_grids_in_unsubdivided_base_mesh(MultiresUnsubdivideC
if (CustomData_has_layer(&base_mesh->ldata, CD_MDISPS)) {
CustomData_free_layers(&base_mesh->ldata, CD_MDISPS, base_mesh->totloop);
}
MDisps *mdisps = CustomData_add_layer(
&base_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, NULL, base_mesh->totloop);
MDisps *mdisps = static_cast<MDisps *>(CustomData_add_layer(
&base_mesh->ldata, CD_MDISPS, CD_SET_DEFAULT, nullptr, base_mesh->totloop));
const int totdisp = pow_i(BKE_ccg_gridsize(context->num_total_levels), 2);
const int totloop = base_mesh->totloop;
@ -1191,7 +1193,8 @@ static void multires_create_grids_in_unsubdivided_base_mesh(MultiresUnsubdivideC
/* Allocate the MDISPS grids and copy the extracted data from context. */
for (int i = 0; i < totloop; i++) {
float(*disps)[3] = MEM_calloc_arrayN(totdisp, sizeof(float[3]), "multires disps");
float(*disps)[3] = static_cast<float(*)[3]>(
MEM_calloc_arrayN(totdisp, sizeof(float[3]), __func__));
if (mdisps[i].disps) {
MEM_freeN(mdisps[i].disps);
@ -1209,13 +1212,13 @@ static void multires_create_grids_in_unsubdivided_base_mesh(MultiresUnsubdivideC
}
}
int multiresModifier_rebuild_subdiv(struct Depsgraph *depsgraph,
struct Object *object,
struct MultiresModifierData *mmd,
int multiresModifier_rebuild_subdiv(Depsgraph *depsgraph,
Object *object,
MultiresModifierData *mmd,
int rebuild_limit,
bool switch_view_to_lower_level)
{
Mesh *mesh = object->data;
Mesh *mesh = static_cast<Mesh *>(object->data);
multires_force_sculpt_rebuild(object);
@ -1255,24 +1258,24 @@ int multiresModifier_rebuild_subdiv(struct Depsgraph *depsgraph,
}
/* Copy the new base mesh to the original mesh. */
BKE_mesh_nomain_to_mesh(unsubdiv_context.base_mesh, object->data, object);
Mesh *base_mesh = object->data;
Mesh *base_mesh = static_cast<Mesh *>(object->data);
BKE_mesh_nomain_to_mesh(unsubdiv_context.base_mesh, base_mesh, object);
multires_create_grids_in_unsubdivided_base_mesh(&unsubdiv_context, base_mesh);
/* Update the levels in the modifier. Force always to display at level 0 as it contains the new
* created level. */
mmd->totlvl = (char)unsubdiv_context.num_total_levels;
mmd->totlvl = char(unsubdiv_context.num_total_levels);
if (switch_view_to_lower_level) {
mmd->sculptlvl = 0;
mmd->lvl = 0;
}
else {
mmd->sculptlvl = (char)(mmd->sculptlvl + unsubdiv_context.num_new_levels);
mmd->lvl = (char)(mmd->lvl + unsubdiv_context.num_new_levels);
mmd->sculptlvl = char(mmd->sculptlvl + unsubdiv_context.num_new_levels);
mmd->lvl = char(mmd->lvl + unsubdiv_context.num_new_levels);
}
mmd->renderlvl = (char)(mmd->renderlvl + unsubdiv_context.num_new_levels);
mmd->renderlvl = char(mmd->renderlvl + unsubdiv_context.num_new_levels);
/* Create a reshape context to convert the MDISPS data to tangent displacement. It can be the
* same as the previous one as a new Subdivision needs to be created for the new base mesh. */

View File

@ -18,14 +18,14 @@
#include "opensubdiv_converter_capi.h"
#include "subdiv_converter.h"
static float simple_to_catmull_clark_get_edge_sharpness(
const OpenSubdiv_Converter *UNUSED(converter), int UNUSED(manifold_edge_index))
static float simple_to_catmull_clark_get_edge_sharpness(const OpenSubdiv_Converter * /*converter*/,
int /*manifold_edge_index*/)
{
return 10.0f;
}
static bool simple_to_catmull_clark_is_infinite_sharp_vertex(
const OpenSubdiv_Converter *UNUSED(converter), int UNUSED(manifold_vertex_index))
const OpenSubdiv_Converter * /*converter*/, int /*manifold_vertex_index*/)
{
return true;
}
@ -35,7 +35,7 @@ static Subdiv *subdiv_for_simple_to_catmull_clark(Object *object, MultiresModifi
SubdivSettings subdiv_settings;
BKE_multires_subdiv_settings_init(&subdiv_settings, mmd);
Mesh *base_mesh = object->data;
const Mesh *base_mesh = static_cast<const Mesh *>(object->data);
OpenSubdiv_Converter converter;
BKE_subdiv_converter_init_for_mesh(&converter, &subdiv_settings, base_mesh);
@ -45,9 +45,10 @@ static Subdiv *subdiv_for_simple_to_catmull_clark(Object *object, MultiresModifi
Subdiv *subdiv = BKE_subdiv_new_from_converter(&subdiv_settings, &converter);
BKE_subdiv_converter_free(&converter);
if (!BKE_subdiv_eval_begin_from_mesh(subdiv, base_mesh, NULL, SUBDIV_EVALUATOR_TYPE_CPU, NULL)) {
if (!BKE_subdiv_eval_begin_from_mesh(
subdiv, base_mesh, nullptr, SUBDIV_EVALUATOR_TYPE_CPU, nullptr)) {
BKE_subdiv_free(subdiv);
return NULL;
return nullptr;
}
return subdiv;
@ -55,7 +56,7 @@ static Subdiv *subdiv_for_simple_to_catmull_clark(Object *object, MultiresModifi
void multires_do_versions_simple_to_catmull_clark(Object *object, MultiresModifierData *mmd)
{
const Mesh *base_mesh = object->data;
const Mesh *base_mesh = static_cast<const Mesh *>(object->data);
if (base_mesh->totloop == 0) {
return;
}

View File

@ -9,10 +9,6 @@
#include "BKE_subdiv.h"
#ifdef __cplusplus
extern "C" {
#endif
/* NOTE: Was initially used to get proper enumerator types, but this makes
* it tricky to compile without OpenSubdiv. */
/* #include "opensubdiv_converter_capi.h" */
@ -38,7 +34,3 @@ int BKE_subdiv_converter_vtx_boundary_interpolation_from_settings(const SubdivSe
/* TODO(sergey): Find a way to make it OpenSubdiv_FVarLinearInterpolation,
* without breaking compilation without OpenSubdiv. */
int BKE_subdiv_converter_fvar_linear_from_settings(const SubdivSettings *settings);
#ifdef __cplusplus
}
#endif