diff options
Diffstat (limited to 'source')
353 files changed, 2475 insertions, 2335 deletions
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index a7150913290..4bffa5492b5 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -17,15 +17,15 @@ extern "C" { */ /* Blender major and minor version. */ -#define BLENDER_VERSION 304 +#define BLENDER_VERSION 305 /* Blender patch version for bugfix releases. */ #define BLENDER_VERSION_PATCH 0 /** Blender release cycle stage: alpha/beta/rc/release. */ -#define BLENDER_VERSION_CYCLE beta +#define BLENDER_VERSION_CYCLE alpha /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 6 +#define BLENDER_FILE_SUBVERSION 0 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index f761e28cbb4..1cdd3c02d8d 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -552,7 +552,6 @@ bool CustomData_verify_versions(struct CustomData *data, int index); /* BMesh specific custom-data stuff. */ -void CustomData_bmesh_update_active_layers(struct CustomData *fdata, struct CustomData *ldata); void CustomData_bmesh_init_pool(struct CustomData *data, int totelem, char htype); /** diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h index 109d3e6d977..431bc11b07f 100644 --- a/source/blender/blenkernel/BKE_dynamicpaint.h +++ b/source/blender/blenkernel/BKE_dynamicpaint.h @@ -119,7 +119,7 @@ struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings int dynamicPaint_createUVSurface(struct Scene *scene, struct DynamicPaintSurface *surface, float *progress, - short *do_update); + bool *do_update); /** * Calculate a single frame and included sub-frames for surface. */ diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 0ff7f50f71c..8f6786d4113 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -307,8 +307,6 @@ void BKE_mesh_translate(struct Mesh *me, const float offset[3], bool do_keys); void BKE_mesh_tessface_clear(struct Mesh *mesh); -void BKE_mesh_do_versions_cd_flag_init(struct Mesh *mesh); - void BKE_mesh_mselect_clear(struct Mesh *me); void BKE_mesh_mselect_validate(struct Mesh *me); /** @@ -974,11 +972,6 @@ void BKE_mesh_strip_loose_faces(struct Mesh *me); void BKE_mesh_strip_loose_polysloops(struct Mesh *me); void BKE_mesh_strip_loose_edges(struct Mesh *me); -/** - * If the mesh is from a very old blender version, - * convert #MFace.edcode to edge #ME_EDGEDRAW. - */ -void BKE_mesh_calc_edges_legacy(struct Mesh *me, bool use_old); void BKE_mesh_calc_edges_loose(struct Mesh *mesh); /** * Calculate edges from polygons. diff --git a/source/blender/blenkernel/BKE_mesh_legacy_convert.h b/source/blender/blenkernel/BKE_mesh_legacy_convert.h index 92182f8045b..5eae7bf3b22 100644 --- a/source/blender/blenkernel/BKE_mesh_legacy_convert.h +++ b/source/blender/blenkernel/BKE_mesh_legacy_convert.h @@ -95,8 +95,6 @@ void BKE_mesh_tessface_calc(struct Mesh *mesh); void BKE_mesh_tessface_ensure(struct Mesh *mesh); -void BKE_mesh_add_mface_layers(struct CustomData *fdata, struct CustomData *ldata, int total); - /** * Rotates the vertices of a face in case v[2] or v[3] (vertex index) is = 0. * this is necessary to make the if #MFace.v4 check for quads work. @@ -123,6 +121,13 @@ void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh); */ void BKE_mesh_do_versions_convert_mfaces_to_mpolys(struct Mesh *mesh); +/** + * Convert legacy #MFace.edcode to edge #ME_EDGEDRAW. + */ +void BKE_mesh_calc_edges_legacy(struct Mesh *me, bool use_old); + +void BKE_mesh_do_versions_cd_flag_init(struct Mesh *mesh); + /* Inlines */ /* NOTE(@sybren): Instead of -1 that function uses ORIGINDEX_NONE as defined in BKE_customdata.h, diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 6eb9650348a..4d883f9e31e 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -988,8 +988,6 @@ void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *outputs); void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth); void node_type_size_preset(struct bNodeType *ntype, eNodeSizePreset size); -void node_type_init(struct bNodeType *ntype, - void (*initfunc)(struct bNodeTree *ntree, struct bNode *node)); /** * \warning Nodes defining a storage type _must_ allocate this for new nodes. * Otherwise nodes will reload as undefined (T46619). @@ -1000,17 +998,6 @@ void node_type_storage(struct bNodeType *ntype, void (*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node)); -void node_type_update(struct bNodeType *ntype, - void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node)); -void node_type_group_update(struct bNodeType *ntype, - void (*group_update_func)(struct bNodeTree *ntree, - struct bNode *node)); - -void node_type_exec(struct bNodeType *ntype, - NodeInitExecFunction init_exec_fn, - NodeFreeExecFunction free_exec_fn, - NodeExecFunction exec_fn); -void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn); /** \} */ @@ -1018,7 +1005,7 @@ void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn); /** \name Node Generic Functions * \{ */ -bool BKE_node_is_connected_to_output(struct bNodeTree *ntree, struct bNode *node); +bool BKE_node_is_connected_to_output(const struct bNodeTree *ntree, const struct bNode *node); /* ************** COMMON NODES *************** */ @@ -1033,8 +1020,6 @@ bool BKE_node_is_connected_to_output(struct bNodeTree *ntree, struct bNode *node #define NODE_GROUP_OUTPUT 8 #define NODE_CUSTOM_GROUP 9 -void BKE_node_tree_unlink_id(ID *id, struct bNodeTree *ntree); - /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index 11c37a74a54..f0bb530e32b 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -170,7 +170,7 @@ int BKE_sound_scene_playing(struct Scene *scene); void BKE_sound_free_waveform(struct bSound *sound); -void BKE_sound_read_waveform(struct Main *bmain, struct bSound *sound, short *stop); +void BKE_sound_read_waveform(struct Main *bmain, struct bSound *sound, bool *stop); void BKE_sound_update_scene(struct Depsgraph *depsgraph, struct Scene *scene); diff --git a/source/blender/blenkernel/BKE_tracking.h b/source/blender/blenkernel/BKE_tracking.h index 89f30ce8ef8..70c1049b5d7 100644 --- a/source/blender/blenkernel/BKE_tracking.h +++ b/source/blender/blenkernel/BKE_tracking.h @@ -657,8 +657,8 @@ void BKE_tracking_reconstruction_context_free(struct MovieReconstructContext *co * callback in libmv side and passing to an interface. */ void BKE_tracking_reconstruction_solve(struct MovieReconstructContext *context, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress, char *stats_message, int message_size); diff --git a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc index ecf3be9bd81..3a86068d8e8 100644 --- a/source/blender/blenkernel/intern/curve_to_mesh_convert.cc +++ b/source/blender/blenkernel/intern/curve_to_mesh_convert.cc @@ -71,7 +71,7 @@ static void fill_mesh_topology(const int vert_offset, MEdge &edge = edges[profile_edge_offset + i_ring]; edge.v1 = ring_vert_offset + i_profile; edge.v2 = next_ring_vert_offset + i_profile; - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } } @@ -87,7 +87,7 @@ static void fill_mesh_topology(const int vert_offset, MEdge &edge = edges[ring_edge_offset + i_profile]; edge.v1 = ring_vert_offset + i_profile; edge.v2 = ring_vert_offset + i_next_profile; - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } } diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index e4405abdde8..8b791eb4a00 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -3597,39 +3597,6 @@ const char *CustomData_get_layer_name(const CustomData *data, const int type, co /* BMesh functions */ -void CustomData_bmesh_update_active_layers(CustomData *fdata, CustomData *ldata) -{ - int act; - - if (CustomData_has_layer(ldata, CD_MLOOPUV)) { - act = CustomData_get_active_layer(ldata, CD_MLOOPUV); - CustomData_set_layer_active(fdata, CD_MTFACE, act); - - act = CustomData_get_render_layer(ldata, CD_MLOOPUV); - CustomData_set_layer_render(fdata, CD_MTFACE, act); - - act = CustomData_get_clone_layer(ldata, CD_MLOOPUV); - CustomData_set_layer_clone(fdata, CD_MTFACE, act); - - act = CustomData_get_stencil_layer(ldata, CD_MLOOPUV); - CustomData_set_layer_stencil(fdata, CD_MTFACE, act); - } - - if (CustomData_has_layer(ldata, CD_PROP_BYTE_COLOR)) { - act = CustomData_get_active_layer(ldata, CD_PROP_BYTE_COLOR); - CustomData_set_layer_active(fdata, CD_MCOL, act); - - act = CustomData_get_render_layer(ldata, CD_PROP_BYTE_COLOR); - CustomData_set_layer_render(fdata, CD_MCOL, act); - - act = CustomData_get_clone_layer(ldata, CD_PROP_BYTE_COLOR); - CustomData_set_layer_clone(fdata, CD_MCOL, act); - - act = CustomData_get_stencil_layer(ldata, CD_PROP_BYTE_COLOR); - CustomData_set_layer_stencil(fdata, CD_MCOL, act); - } -} - void CustomData_bmesh_init_pool(CustomData *data, const int totelem, const char htype) { int chunksize; diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index b9cec17b6e0..e0ae3f42be6 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -2790,7 +2790,7 @@ static bool dynamicPaint_symmetrizeAdjData(PaintAdjData *ed, int active_points) int dynamicPaint_createUVSurface(Scene *scene, DynamicPaintSurface *surface, float *progress, - short *do_update) + bool *do_update) { /* Antialias jitter point relative coords */ const int aa_samples = (surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1; diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc index 0018c217964..2d613f24a0a 100644 --- a/source/blender/blenkernel/intern/mesh.cc +++ b/source/blender/blenkernel/intern/mesh.cc @@ -1608,38 +1608,6 @@ void BKE_mesh_tessface_clear(Mesh *mesh) mesh_tessface_clear_intern(mesh, true); } -void BKE_mesh_do_versions_cd_flag_init(Mesh *mesh) -{ - if (UNLIKELY(mesh->cd_flag)) { - return; - } - - const Span<MVert> verts = mesh->verts(); - const Span<MEdge> edges = mesh->edges(); - - for (const MVert &vert : verts) { - if (vert.bweight_legacy != 0) { - mesh->cd_flag |= ME_CDFLAG_VERT_BWEIGHT; - break; - } - } - - for (const MEdge &edge : edges) { - if (edge.bweight_legacy != 0) { - mesh->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT; - if (mesh->cd_flag & ME_CDFLAG_EDGE_CREASE) { - break; - } - } - if (edge.crease_legacy != 0) { - mesh->cd_flag |= ME_CDFLAG_EDGE_CREASE; - if (mesh->cd_flag & ME_CDFLAG_EDGE_BWEIGHT) { - break; - } - } - } -} - /* -------------------------------------------------------------------- */ /* MSelect functions (currently used in weight paint mode) */ diff --git a/source/blender/blenkernel/intern/mesh_calc_edges.cc b/source/blender/blenkernel/intern/mesh_calc_edges.cc index 5e6babdf7b4..4a4c2ebcbb0 100644 --- a/source/blender/blenkernel/intern/mesh_calc_edges.cc +++ b/source/blender/blenkernel/intern/mesh_calc_edges.cc @@ -146,7 +146,7 @@ static void serialize_and_initialize_deduplicated_edges(MutableSpan<EdgeMap> edg /* Initialize new edge. */ new_edge.v1 = item.key.v_low; new_edge.v2 = item.key.v_high; - new_edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + new_edge.flag = ME_EDGEDRAW; } item.value.index = new_edge_index; new_edge_index++; diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index 784d35a8d65..2255038a991 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -119,7 +119,7 @@ static void make_edges_mdata_extend(Mesh &mesh) BLI_edgehashIterator_getKey(ehi, &medge->v1, &medge->v2); BLI_edgehashIterator_setValue(ehi, POINTER_FROM_UINT(e_index)); - medge->flag = ME_EDGEDRAW | ME_EDGERENDER; + medge->flag = ME_EDGEDRAW; } BLI_edgehashIterator_free(ehi); @@ -223,7 +223,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba for (b = 1; b < dl->nr; b++) { medge->v1 = startvert + ofs + b - 1; medge->v2 = startvert + ofs + b; - medge->flag = ME_LOOSEEDGE | ME_EDGERENDER | ME_EDGEDRAW; + medge->flag = ME_LOOSEEDGE | ME_EDGEDRAW; medge++; } @@ -251,7 +251,7 @@ static Mesh *mesh_nurbs_displist_to_mesh(const Curve *cu, const ListBase *dispba else { medge->v2 = startvert + ofs + b + 1; } - medge->flag = ME_LOOSEEDGE | ME_EDGERENDER | ME_EDGEDRAW; + medge->flag = ME_LOOSEEDGE | ME_EDGEDRAW; medge++; } } @@ -706,7 +706,7 @@ void BKE_mesh_edges_set_draw_render(Mesh *mesh) { MutableSpan<MEdge> edges = mesh->edges_for_write(); for (int i = 0; i < mesh->totedge; i++) { - edges[i].flag |= ME_EDGEDRAW | ME_EDGERENDER; + edges[i].flag |= ME_EDGEDRAW; } } diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index df3057d9592..23426f8c087 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -30,6 +30,258 @@ #include "BKE_multires.h" /* -------------------------------------------------------------------- */ +/** \name Legacy Edge Calculation + * \{ */ + +struct EdgeSort { + uint v1, v2; + char is_loose, is_draw; +}; + +/* edges have to be added with lowest index first for sorting */ +static void to_edgesort(struct EdgeSort *ed, uint v1, uint v2, char is_loose, short is_draw) +{ + if (v1 < v2) { + ed->v1 = v1; + ed->v2 = v2; + } + else { + ed->v1 = v2; + ed->v2 = v1; + } + ed->is_loose = is_loose; + ed->is_draw = is_draw; +} + +static int vergedgesort(const void *v1, const void *v2) +{ + const struct EdgeSort *x1 = static_cast<const struct EdgeSort *>(v1); + const struct EdgeSort *x2 = static_cast<const struct EdgeSort *>(v2); + + if (x1->v1 > x2->v1) { + return 1; + } + if (x1->v1 < x2->v1) { + return -1; + } + if (x1->v2 > x2->v2) { + return 1; + } + if (x1->v2 < x2->v2) { + return -1; + } + + return 0; +} + +/* Create edges based on known verts and faces, + * this function is only used when loading very old blend files */ +static void mesh_calc_edges_mdata(const MVert * /*allvert*/, + const MFace *allface, + MLoop *allloop, + const MPoly *allpoly, + int /*totvert*/, + int totface, + int /*totloop*/, + int totpoly, + const bool use_old, + MEdge **r_medge, + int *r_totedge) +{ + const MPoly *mpoly; + const MFace *mface; + MEdge *medge, *med; + EdgeHash *hash; + struct EdgeSort *edsort, *ed; + int a, totedge = 0; + uint totedge_final = 0; + uint edge_index; + + /* we put all edges in array, sort them, and detect doubles that way */ + + for (a = totface, mface = allface; a > 0; a--, mface++) { + if (mface->v4) { + totedge += 4; + } + else if (mface->v3) { + totedge += 3; + } + else { + totedge += 1; + } + } + + if (totedge == 0) { + /* flag that mesh has edges */ + (*r_medge) = (MEdge *)MEM_callocN(0, __func__); + (*r_totedge) = 0; + return; + } + + ed = edsort = (EdgeSort *)MEM_mallocN(totedge * sizeof(struct EdgeSort), "EdgeSort"); + + for (a = totface, mface = allface; a > 0; a--, mface++) { + to_edgesort(ed++, mface->v1, mface->v2, !mface->v3, mface->edcode & ME_V1V2); + if (mface->v4) { + to_edgesort(ed++, mface->v2, mface->v3, 0, mface->edcode & ME_V2V3); + to_edgesort(ed++, mface->v3, mface->v4, 0, mface->edcode & ME_V3V4); + to_edgesort(ed++, mface->v4, mface->v1, 0, mface->edcode & ME_V4V1); + } + else if (mface->v3) { + to_edgesort(ed++, mface->v2, mface->v3, 0, mface->edcode & ME_V2V3); + to_edgesort(ed++, mface->v3, mface->v1, 0, mface->edcode & ME_V3V1); + } + } + + qsort(edsort, totedge, sizeof(struct EdgeSort), vergedgesort); + + /* count final amount */ + for (a = totedge, ed = edsort; a > 1; a--, ed++) { + /* edge is unique when it differs from next edge, or is last */ + if (ed->v1 != (ed + 1)->v1 || ed->v2 != (ed + 1)->v2) { + totedge_final++; + } + } + totedge_final++; + + medge = (MEdge *)MEM_callocN(sizeof(MEdge) * totedge_final, __func__); + + for (a = totedge, med = medge, ed = edsort; a > 1; a--, ed++) { + /* edge is unique when it differs from next edge, or is last */ + if (ed->v1 != (ed + 1)->v1 || ed->v2 != (ed + 1)->v2) { + med->v1 = ed->v1; + med->v2 = ed->v2; + if (use_old == false || ed->is_draw) { + med->flag = ME_EDGEDRAW; + } + if (ed->is_loose) { + med->flag |= ME_LOOSEEDGE; + } + + /* order is swapped so extruding this edge as a surface won't flip face normals + * with cyclic curves */ + if (ed->v1 + 1 != ed->v2) { + SWAP(uint, med->v1, med->v2); + } + med++; + } + else { + /* Equal edge, merge the draw-flag. */ + (ed + 1)->is_draw |= ed->is_draw; + } + } + /* last edge */ + med->v1 = ed->v1; + med->v2 = ed->v2; + med->flag = ME_EDGEDRAW; + if (ed->is_loose) { + med->flag |= ME_LOOSEEDGE; + } + + MEM_freeN(edsort); + + /* set edge members of mloops */ + hash = BLI_edgehash_new_ex(__func__, totedge_final); + for (edge_index = 0, med = medge; edge_index < totedge_final; edge_index++, med++) { + BLI_edgehash_insert(hash, med->v1, med->v2, POINTER_FROM_UINT(edge_index)); + } + + mpoly = allpoly; + for (a = 0; a < totpoly; a++, mpoly++) { + MLoop *ml, *ml_next; + int i = mpoly->totloop; + + ml_next = allloop + mpoly->loopstart; /* first loop */ + ml = &ml_next[i - 1]; /* last loop */ + + while (i-- != 0) { + ml->e = POINTER_AS_UINT(BLI_edgehash_lookup(hash, ml->v, ml_next->v)); + ml = ml_next; + ml_next++; + } + } + + BLI_edgehash_free(hash, nullptr); + + *r_medge = medge; + *r_totedge = totedge_final; +} + +void BKE_mesh_calc_edges_legacy(Mesh *me, const bool use_old) +{ + using namespace blender; + MEdge *medge; + int totedge = 0; + const Span<MVert> verts = me->verts(); + const Span<MPoly> polys = me->polys(); + MutableSpan<MLoop> loops = me->loops_for_write(); + + mesh_calc_edges_mdata(verts.data(), + (MFace *)CustomData_get_layer(&me->fdata, CD_MFACE), + loops.data(), + polys.data(), + verts.size(), + me->totface, + loops.size(), + polys.size(), + use_old, + &medge, + &totedge); + + if (totedge == 0) { + /* flag that mesh has edges */ + me->totedge = 0; + return; + } + + medge = (MEdge *)CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, medge, totedge); + me->totedge = totedge; + + BKE_mesh_strip_loose_faces(me); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name CD Flag Initialization + * \{ */ + +void BKE_mesh_do_versions_cd_flag_init(Mesh *mesh) +{ + using namespace blender; + if (UNLIKELY(mesh->cd_flag)) { + return; + } + + const Span<MVert> verts = mesh->verts(); + const Span<MEdge> edges = mesh->edges(); + + for (const MVert &vert : verts) { + if (vert.bweight_legacy != 0) { + mesh->cd_flag |= ME_CDFLAG_VERT_BWEIGHT; + break; + } + } + + for (const MEdge &edge : edges) { + if (edge.bweight_legacy != 0) { + mesh->cd_flag |= ME_CDFLAG_EDGE_BWEIGHT; + if (mesh->cd_flag & ME_CDFLAG_EDGE_CREASE) { + break; + } + } + if (edge.crease_legacy != 0) { + mesh->cd_flag |= ME_CDFLAG_EDGE_CREASE; + if (mesh->cd_flag & ME_CDFLAG_EDGE_BWEIGHT) { + break; + } + } + } +} + +/** \} */ + +/* -------------------------------------------------------------------- */ /** \name NGon Tessellation (NGon to MFace Conversion) * \{ */ @@ -278,6 +530,115 @@ static void convert_mfaces_to_mpolys(ID *id, #undef ME_FGON } +static void update_active_fdata_layers(CustomData *fdata, CustomData *ldata) +{ + int act; + + if (CustomData_has_layer(ldata, CD_MLOOPUV)) { + act = CustomData_get_active_layer(ldata, CD_MLOOPUV); + CustomData_set_layer_active(fdata, CD_MTFACE, act); + + act = CustomData_get_render_layer(ldata, CD_MLOOPUV); + CustomData_set_layer_render(fdata, CD_MTFACE, act); + + act = CustomData_get_clone_layer(ldata, CD_MLOOPUV); + CustomData_set_layer_clone(fdata, CD_MTFACE, act); + + act = CustomData_get_stencil_layer(ldata, CD_MLOOPUV); + CustomData_set_layer_stencil(fdata, CD_MTFACE, act); + } + + if (CustomData_has_layer(ldata, CD_PROP_BYTE_COLOR)) { + act = CustomData_get_active_layer(ldata, CD_PROP_BYTE_COLOR); + CustomData_set_layer_active(fdata, CD_MCOL, act); + + act = CustomData_get_render_layer(ldata, CD_PROP_BYTE_COLOR); + CustomData_set_layer_render(fdata, CD_MCOL, act); + + act = CustomData_get_clone_layer(ldata, CD_PROP_BYTE_COLOR); + CustomData_set_layer_clone(fdata, CD_MCOL, act); + + act = CustomData_get_stencil_layer(ldata, CD_PROP_BYTE_COLOR); + CustomData_set_layer_stencil(fdata, CD_MCOL, act); + } +} + +#ifndef NDEBUG +/** + * Debug check, used to assert when we expect layers to be in/out of sync. + * + * \param fallback: Use when there are no layers to handle, + * since callers may expect success or failure. + */ +static bool check_matching_legacy_layer_counts(CustomData *fdata, CustomData *ldata, bool fallback) +{ + int a_num = 0, b_num = 0; +# define LAYER_CMP(l_a, t_a, l_b, t_b) \ + ((a_num += CustomData_number_of_layers(l_a, t_a)) == \ + (b_num += CustomData_number_of_layers(l_b, t_b))) + + if (!LAYER_CMP(ldata, CD_MLOOPUV, fdata, CD_MTFACE)) { + return false; + } + if (!LAYER_CMP(ldata, CD_PROP_BYTE_COLOR, fdata, CD_MCOL)) { + return false; + } + if (!LAYER_CMP(ldata, CD_PREVIEW_MLOOPCOL, fdata, CD_PREVIEW_MCOL)) { + return false; + } + if (!LAYER_CMP(ldata, CD_ORIGSPACE_MLOOP, fdata, CD_ORIGSPACE)) { + return false; + } + if (!LAYER_CMP(ldata, CD_NORMAL, fdata, CD_TESSLOOPNORMAL)) { + return false; + } + if (!LAYER_CMP(ldata, CD_TANGENT, fdata, CD_TANGENT)) { + return false; + } + +# undef LAYER_CMP + + /* if no layers are on either CustomData's, + * then there was nothing to do... */ + return a_num ? true : fallback; +} +#endif + +static void add_mface_layers(CustomData *fdata, CustomData *ldata, int total) +{ + /* avoid accumulating extra layers */ + BLI_assert(!check_matching_legacy_layer_counts(fdata, ldata, false)); + + for (int i = 0; i < ldata->totlayer; i++) { + if (ldata->layers[i].type == CD_MLOOPUV) { + CustomData_add_layer_named( + fdata, CD_MTFACE, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); + } + if (ldata->layers[i].type == CD_PROP_BYTE_COLOR) { + CustomData_add_layer_named( + fdata, CD_MCOL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); + } + else if (ldata->layers[i].type == CD_PREVIEW_MLOOPCOL) { + CustomData_add_layer_named( + fdata, CD_PREVIEW_MCOL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); + } + else if (ldata->layers[i].type == CD_ORIGSPACE_MLOOP) { + CustomData_add_layer_named( + fdata, CD_ORIGSPACE, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); + } + else if (ldata->layers[i].type == CD_NORMAL) { + CustomData_add_layer_named( + fdata, CD_TESSLOOPNORMAL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); + } + else if (ldata->layers[i].type == CD_TANGENT) { + CustomData_add_layer_named( + fdata, CD_TANGENT, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); + } + } + + update_active_fdata_layers(fdata, ldata); +} + static void mesh_ensure_tessellation_customdata(Mesh *me) { if (UNLIKELY((me->totface != 0) && (me->totpoly == 0))) { @@ -296,7 +657,7 @@ static void mesh_ensure_tessellation_customdata(Mesh *me) if (tottex_tessface != tottex_original || totcol_tessface != totcol_original) { BKE_mesh_tessface_clear(me); - BKE_mesh_add_mface_layers(&me->fdata, &me->ldata, me->totface); + add_mface_layers(&me->fdata, &me->ldata, me->totface); /* TODO: add some `--debug-mesh` option. */ if (G.debug & G_DEBUG) { @@ -784,7 +1145,7 @@ static int mesh_tessface_calc(CustomData *fdata, /* #CD_ORIGINDEX will contain an array of indices from tessellation-faces to the polygons * they are directly tessellated from. */ CustomData_add_layer(fdata, CD_ORIGINDEX, CD_ASSIGN, mface_to_poly_map, totface); - BKE_mesh_add_mface_layers(fdata, ldata, totface); + add_mface_layers(fdata, ldata, totface); /* NOTE: quad detection issue - fourth vertidx vs fourth loopidx: * Polygons take care of their loops ordering, hence not of their vertices ordering. @@ -840,82 +1201,6 @@ void BKE_mesh_tessface_ensure(struct Mesh *mesh) } } -#ifndef NDEBUG -/** - * Debug check, used to assert when we expect layers to be in/out of sync. - * - * \param fallback: Use when there are no layers to handle, - * since callers may expect success or failure. - */ -static bool check_matching_legacy_layer_counts(CustomData *fdata, CustomData *ldata, bool fallback) -{ - int a_num = 0, b_num = 0; -# define LAYER_CMP(l_a, t_a, l_b, t_b) \ - ((a_num += CustomData_number_of_layers(l_a, t_a)) == \ - (b_num += CustomData_number_of_layers(l_b, t_b))) - - if (!LAYER_CMP(ldata, CD_MLOOPUV, fdata, CD_MTFACE)) { - return false; - } - if (!LAYER_CMP(ldata, CD_PROP_BYTE_COLOR, fdata, CD_MCOL)) { - return false; - } - if (!LAYER_CMP(ldata, CD_PREVIEW_MLOOPCOL, fdata, CD_PREVIEW_MCOL)) { - return false; - } - if (!LAYER_CMP(ldata, CD_ORIGSPACE_MLOOP, fdata, CD_ORIGSPACE)) { - return false; - } - if (!LAYER_CMP(ldata, CD_NORMAL, fdata, CD_TESSLOOPNORMAL)) { - return false; - } - if (!LAYER_CMP(ldata, CD_TANGENT, fdata, CD_TANGENT)) { - return false; - } - -# undef LAYER_CMP - - /* if no layers are on either CustomData's, - * then there was nothing to do... */ - return a_num ? true : fallback; -} -#endif - -void BKE_mesh_add_mface_layers(CustomData *fdata, CustomData *ldata, int total) -{ - /* avoid accumulating extra layers */ - BLI_assert(!check_matching_legacy_layer_counts(fdata, ldata, false)); - - for (int i = 0; i < ldata->totlayer; i++) { - if (ldata->layers[i].type == CD_MLOOPUV) { - CustomData_add_layer_named( - fdata, CD_MTFACE, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); - } - if (ldata->layers[i].type == CD_PROP_BYTE_COLOR) { - CustomData_add_layer_named( - fdata, CD_MCOL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); - } - else if (ldata->layers[i].type == CD_PREVIEW_MLOOPCOL) { - CustomData_add_layer_named( - fdata, CD_PREVIEW_MCOL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); - } - else if (ldata->layers[i].type == CD_ORIGSPACE_MLOOP) { - CustomData_add_layer_named( - fdata, CD_ORIGSPACE, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); - } - else if (ldata->layers[i].type == CD_NORMAL) { - CustomData_add_layer_named( - fdata, CD_TESSLOOPNORMAL, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); - } - else if (ldata->layers[i].type == CD_TANGENT) { - CustomData_add_layer_named( - fdata, CD_TANGENT, CD_SET_DEFAULT, nullptr, total, ldata->layers[i].name); - } - } - - CustomData_bmesh_update_active_layers(fdata, ldata); -} - /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc index f38efd2cf65..0887e26148a 100644 --- a/source/blender/blenkernel/intern/mesh_remesh_voxel.cc +++ b/source/blender/blenkernel/intern/mesh_remesh_voxel.cc @@ -426,23 +426,18 @@ void BKE_remesh_reproject_vertex_paint(Mesh *target, const Mesh *source) else { /* Lazily init vertex -> loop maps. */ if (!source_lmap) { - const MPoly *source_polys = (MPoly *)CustomData_get_layer(&source->pdata, CD_MPOLY); - const MLoop *source_loops = (MLoop *)CustomData_get_layer(&source->ldata, CD_MLOOP); - const MPoly *target_polys = (MPoly *)CustomData_get_layer(&target->pdata, CD_MPOLY); - const MLoop *target_loops = (MLoop *)CustomData_get_layer(&target->ldata, CD_MLOOP); - BKE_mesh_vert_loop_map_create(&source_lmap, &source_lmap_mem, - source_polys, - source_loops, + source->polys().data(), + source->loops().data(), source->totvert, source->totpoly, source->totloop); BKE_mesh_vert_loop_map_create(&target_lmap, &target_lmap_mem, - target_polys, - target_loops, + target->polys().data(), + target->loops().data(), target->totvert, target->totpoly, target->totloop); diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc index 9b140171912..9cd3b6e9e9e 100644 --- a/source/blender/blenkernel/intern/mesh_validate.cc +++ b/source/blender/blenkernel/intern/mesh_validate.cc @@ -1315,216 +1315,6 @@ void BKE_mesh_strip_loose_edges(Mesh *me) /** \name Mesh Edge Calculation * \{ */ -/* make edges in a Mesh, for outside of editmode */ - -struct EdgeSort { - uint v1, v2; - char is_loose, is_draw; -}; - -/* edges have to be added with lowest index first for sorting */ -static void to_edgesort(struct EdgeSort *ed, uint v1, uint v2, char is_loose, short is_draw) -{ - if (v1 < v2) { - ed->v1 = v1; - ed->v2 = v2; - } - else { - ed->v1 = v2; - ed->v2 = v1; - } - ed->is_loose = is_loose; - ed->is_draw = is_draw; -} - -static int vergedgesort(const void *v1, const void *v2) -{ - const struct EdgeSort *x1 = static_cast<const struct EdgeSort *>(v1); - const struct EdgeSort *x2 = static_cast<const struct EdgeSort *>(v2); - - if (x1->v1 > x2->v1) { - return 1; - } - if (x1->v1 < x2->v1) { - return -1; - } - if (x1->v2 > x2->v2) { - return 1; - } - if (x1->v2 < x2->v2) { - return -1; - } - - return 0; -} - -/* Create edges based on known verts and faces, - * this function is only used when loading very old blend files */ - -static void mesh_calc_edges_mdata(const MVert * /*allvert*/, - const MFace *allface, - MLoop *allloop, - const MPoly *allpoly, - int /*totvert*/, - int totface, - int /*totloop*/, - int totpoly, - const bool use_old, - MEdge **r_medge, - int *r_totedge) -{ - const MPoly *mpoly; - const MFace *mface; - MEdge *medge, *med; - EdgeHash *hash; - struct EdgeSort *edsort, *ed; - int a, totedge = 0; - uint totedge_final = 0; - uint edge_index; - - /* we put all edges in array, sort them, and detect doubles that way */ - - for (a = totface, mface = allface; a > 0; a--, mface++) { - if (mface->v4) { - totedge += 4; - } - else if (mface->v3) { - totedge += 3; - } - else { - totedge += 1; - } - } - - if (totedge == 0) { - /* flag that mesh has edges */ - (*r_medge) = (MEdge *)MEM_callocN(0, __func__); - (*r_totedge) = 0; - return; - } - - ed = edsort = (EdgeSort *)MEM_mallocN(totedge * sizeof(struct EdgeSort), "EdgeSort"); - - for (a = totface, mface = allface; a > 0; a--, mface++) { - to_edgesort(ed++, mface->v1, mface->v2, !mface->v3, mface->edcode & ME_V1V2); - if (mface->v4) { - to_edgesort(ed++, mface->v2, mface->v3, 0, mface->edcode & ME_V2V3); - to_edgesort(ed++, mface->v3, mface->v4, 0, mface->edcode & ME_V3V4); - to_edgesort(ed++, mface->v4, mface->v1, 0, mface->edcode & ME_V4V1); - } - else if (mface->v3) { - to_edgesort(ed++, mface->v2, mface->v3, 0, mface->edcode & ME_V2V3); - to_edgesort(ed++, mface->v3, mface->v1, 0, mface->edcode & ME_V3V1); - } - } - - qsort(edsort, totedge, sizeof(struct EdgeSort), vergedgesort); - - /* count final amount */ - for (a = totedge, ed = edsort; a > 1; a--, ed++) { - /* edge is unique when it differs from next edge, or is last */ - if (ed->v1 != (ed + 1)->v1 || ed->v2 != (ed + 1)->v2) { - totedge_final++; - } - } - totedge_final++; - - medge = (MEdge *)MEM_callocN(sizeof(MEdge) * totedge_final, __func__); - - for (a = totedge, med = medge, ed = edsort; a > 1; a--, ed++) { - /* edge is unique when it differs from next edge, or is last */ - if (ed->v1 != (ed + 1)->v1 || ed->v2 != (ed + 1)->v2) { - med->v1 = ed->v1; - med->v2 = ed->v2; - if (use_old == false || ed->is_draw) { - med->flag = ME_EDGEDRAW | ME_EDGERENDER; - } - if (ed->is_loose) { - med->flag |= ME_LOOSEEDGE; - } - - /* order is swapped so extruding this edge as a surface won't flip face normals - * with cyclic curves */ - if (ed->v1 + 1 != ed->v2) { - SWAP(uint, med->v1, med->v2); - } - med++; - } - else { - /* Equal edge, merge the draw-flag. */ - (ed + 1)->is_draw |= ed->is_draw; - } - } - /* last edge */ - med->v1 = ed->v1; - med->v2 = ed->v2; - med->flag = ME_EDGEDRAW; - if (ed->is_loose) { - med->flag |= ME_LOOSEEDGE; - } - med->flag |= ME_EDGERENDER; - - MEM_freeN(edsort); - - /* set edge members of mloops */ - hash = BLI_edgehash_new_ex(__func__, totedge_final); - for (edge_index = 0, med = medge; edge_index < totedge_final; edge_index++, med++) { - BLI_edgehash_insert(hash, med->v1, med->v2, POINTER_FROM_UINT(edge_index)); - } - - mpoly = allpoly; - for (a = 0; a < totpoly; a++, mpoly++) { - MLoop *ml, *ml_next; - int i = mpoly->totloop; - - ml_next = allloop + mpoly->loopstart; /* first loop */ - ml = &ml_next[i - 1]; /* last loop */ - - while (i-- != 0) { - ml->e = POINTER_AS_UINT(BLI_edgehash_lookup(hash, ml->v, ml_next->v)); - ml = ml_next; - ml_next++; - } - } - - BLI_edgehash_free(hash, nullptr); - - *r_medge = medge; - *r_totedge = totedge_final; -} - -void BKE_mesh_calc_edges_legacy(Mesh *me, const bool use_old) -{ - MEdge *medge; - int totedge = 0; - const Span<MVert> verts = me->verts(); - const Span<MPoly> polys = me->polys(); - MutableSpan<MLoop> loops = me->loops_for_write(); - - mesh_calc_edges_mdata(verts.data(), - (MFace *)CustomData_get_layer(&me->fdata, CD_MFACE), - loops.data(), - polys.data(), - verts.size(), - me->totface, - loops.size(), - polys.size(), - use_old, - &medge, - &totedge); - - if (totedge == 0) { - /* flag that mesh has edges */ - me->totedge = 0; - return; - } - - medge = (MEdge *)CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, medge, totedge); - me->totedge = totedge; - - BKE_mesh_strip_loose_faces(me); -} - void BKE_mesh_calc_edges_loose(Mesh *mesh) { const Span<MLoop> loops = mesh->loops(); @@ -1579,7 +1369,7 @@ void BKE_mesh_calc_edges_tessface(Mesh *mesh) BLI_edgesetIterator_step(ehi), i++, med++, index++) { BLI_edgesetIterator_getKey(ehi, &med->v1, &med->v2); - med->flag = ME_EDGEDRAW | ME_EDGERENDER; + med->flag = ME_EDGEDRAW; *index = ORIGINDEX_NONE; } BLI_edgesetIterator_free(ehi); diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index ad9d4e4fcca..aa6ca37f48c 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -4346,12 +4346,6 @@ void node_type_socket_templates(struct bNodeType *ntype, } } -void node_type_init(struct bNodeType *ntype, - void (*initfunc)(struct bNodeTree *ntree, struct bNode *node)) -{ - ntype->initfunc = initfunc; -} - void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth) { ntype->width = width; @@ -4399,33 +4393,6 @@ void node_type_storage(bNodeType *ntype, ntype->freefunc = freefunc; } -void node_type_update(struct bNodeType *ntype, - void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node)) -{ - ntype->updatefunc = updatefunc; -} - -void node_type_group_update(struct bNodeType *ntype, - void (*group_update_func)(struct bNodeTree *ntree, struct bNode *node)) -{ - ntype->group_update_func = group_update_func; -} - -void node_type_exec(struct bNodeType *ntype, - NodeInitExecFunction init_exec_fn, - NodeFreeExecFunction free_exec_fn, - NodeExecFunction exec_fn) -{ - ntype->init_exec_fn = init_exec_fn; - ntype->free_exec_fn = free_exec_fn; - ntype->exec_fn = exec_fn; -} - -void node_type_gpu(struct bNodeType *ntype, NodeGPUExecFunction gpu_fn) -{ - ntype->gpu_fn = gpu_fn; -} - /* callbacks for undefined types */ static bool node_undefined_poll(bNodeType * /*ntype*/, diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 1aef42ef037..51a20cf1e35 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -1025,7 +1025,7 @@ void BKE_sound_free_waveform(bSound *sound) sound->tags &= ~SOUND_TAGS_WAVEFORM_NO_RELOAD; } -void BKE_sound_read_waveform(Main *bmain, bSound *sound, short *stop) +void BKE_sound_read_waveform(Main *bmain, bSound *sound, bool *stop) { bool need_close_audio_handles = false; if (sound->playback_handle == NULL) { @@ -1041,8 +1041,11 @@ void BKE_sound_read_waveform(Main *bmain, bSound *sound, short *stop) int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND; waveform->data = MEM_mallocN(sizeof(float[3]) * length, "SoundWaveform.samples"); + /* Ideally this would take a boolean argument. */ + short stop_i16 = *stop; waveform->length = AUD_readSound( - sound->playback_handle, waveform->data, length, SOUND_WAVE_SAMPLES_PER_SECOND, stop); + sound->playback_handle, waveform->data, length, SOUND_WAVE_SAMPLES_PER_SECOND, &stop_i16); + *stop = stop_i16 != 0; } else { /* Create an empty waveform here if the sound couldn't be @@ -1381,7 +1384,7 @@ int BKE_sound_scene_playing(Scene *UNUSED(scene)) void BKE_sound_read_waveform(Main *bmain, bSound *sound, /* NOLINTNEXTLINE: readability-non-const-parameter. */ - short *stop) + bool *stop) { UNUSED_VARS(sound, stop, bmain); } diff --git a/source/blender/blenkernel/intern/subdiv_mesh.cc b/source/blender/blenkernel/intern/subdiv_mesh.cc index 3b97c1f5e68..e1c434f2b2e 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.cc +++ b/source/blender/blenkernel/intern/subdiv_mesh.cc @@ -794,7 +794,7 @@ static void subdiv_copy_edge_data(SubdivMeshContext *ctx, /* TODO: Ensure crease layer isn't copied to result. */ subdiv_edge->flag = 0; if (!ctx->settings->use_optimal_display) { - subdiv_edge->flag |= ME_EDGERENDER; + subdiv_edge->flag |= ME_EDGEDRAW; } if (ctx->edge_origindex != nullptr) { ctx->edge_origindex[subdiv_edge_index] = ORIGINDEX_NONE; @@ -804,7 +804,7 @@ static void subdiv_copy_edge_data(SubdivMeshContext *ctx, const int coarse_edge_index = coarse_edge - ctx->coarse_edges; CustomData_copy_data( &ctx->coarse_mesh->edata, &ctx->subdiv_mesh->edata, coarse_edge_index, subdiv_edge_index, 1); - subdiv_edge->flag |= ME_EDGERENDER; + subdiv_edge->flag |= ME_EDGEDRAW; } static void subdiv_mesh_edge(const SubdivForeachContext *foreach_context, diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index c37f4b1ea2f..80fb637b76e 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -962,7 +962,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge) int edgeSize = ccgSubSurf_getEdgeSize(ss); uint i = 0; short *edgeFlags = ccgdm->edgeFlags; - const short ed_interior_flag = ccgdm->drawInteriorEdges ? (ME_EDGEDRAW | ME_EDGERENDER) : 0; + const short ed_interior_flag = ccgdm->drawInteriorEdges ? ME_EDGEDRAW : 0; totface = ccgSubSurf_getNumFaces(ss); for (index = 0; index < totface; index++) { @@ -1005,11 +1005,11 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge) if (edgeFlags) { if (edgeIdx != -1) { - ed_flag |= ((edgeFlags[index] & (ME_SEAM | ME_SHARP)) | ME_EDGEDRAW | ME_EDGERENDER); + ed_flag |= ((edgeFlags[index] & (ME_SEAM | ME_SHARP)) | ME_EDGEDRAW); } } else { - ed_flag |= ME_EDGEDRAW | ME_EDGERENDER; + ed_flag |= ME_EDGEDRAW; } for (x = 0; x < edgeSize - 1; x++) { diff --git a/source/blender/blenkernel/intern/tracking_solver.c b/source/blender/blenkernel/intern/tracking_solver.c index 11041b4c0fd..e784c39ba08 100644 --- a/source/blender/blenkernel/intern/tracking_solver.c +++ b/source/blender/blenkernel/intern/tracking_solver.c @@ -56,8 +56,8 @@ typedef struct MovieReconstructContext { } MovieReconstructContext; typedef struct ReconstructProgressData { - short *stop; - short *do_update; + bool *stop; + bool *do_update; float *progress; char *stats_message; int message_size; @@ -465,8 +465,8 @@ static void reconstructionOptionsFromContext(libmv_ReconstructionOptions *recons } void BKE_tracking_reconstruction_solve(MovieReconstructContext *context, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress, char *stats_message, int message_size) diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index ee827cd8cd4..d71db8f71a5 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -141,19 +141,18 @@ static int write_audio_frame(FFMpegContext *context) frame->pts = context->audio_time / av_q2d(c->time_base); frame->nb_samples = context->audio_input_samples; frame->format = c->sample_fmt; - frame->channels = c->channels; - frame->channel_layout = c->channel_layout; + av_channel_layout_copy(&frame->ch_layout, &c->ch_layout); if (context->audio_deinterleave) { int channel, i; uint8_t *temp; - for (channel = 0; channel < c->channels; channel++) { + for (channel = 0; channel < c->ch_layout.nb_channels; channel++) { for (i = 0; i < frame->nb_samples; i++) { memcpy(context->audio_deinterleave_buffer + (i + channel * frame->nb_samples) * context->audio_sample_size, context->audio_input_buffer + - (c->channels * i + channel) * context->audio_sample_size, + (c->ch_layout.nb_channels * i + channel) * context->audio_sample_size, context->audio_sample_size); } } @@ -164,10 +163,11 @@ static int write_audio_frame(FFMpegContext *context) } avcodec_fill_audio_frame(frame, - c->channels, + c->ch_layout.nb_channels, c->sample_fmt, context->audio_input_buffer, - context->audio_input_samples * c->channels * context->audio_sample_size, + context->audio_input_samples * c->ch_layout.nb_channels * + context->audio_sample_size, 1); int success = 1; @@ -944,23 +944,23 @@ static AVStream *alloc_audio_stream(FFMpegContext *context, c->sample_rate = rd->ffcodecdata.audio_mixrate; c->bit_rate = context->ffmpeg_audio_bitrate * 1000; c->sample_fmt = AV_SAMPLE_FMT_S16; - c->channels = rd->ffcodecdata.audio_channels; + c->ch_layout.nb_channels = rd->ffcodecdata.audio_channels; switch (rd->ffcodecdata.audio_channels) { case FFM_CHANNELS_MONO: - c->channel_layout = AV_CH_LAYOUT_MONO; + av_channel_layout_from_mask(&c->ch_layout, AV_CH_LAYOUT_MONO); break; case FFM_CHANNELS_STEREO: - c->channel_layout = AV_CH_LAYOUT_STEREO; + av_channel_layout_from_mask(&c->ch_layout, AV_CH_LAYOUT_STEREO); break; case FFM_CHANNELS_SURROUND4: - c->channel_layout = AV_CH_LAYOUT_QUAD; + av_channel_layout_from_mask(&c->ch_layout, AV_CH_LAYOUT_QUAD); break; case FFM_CHANNELS_SURROUND51: - c->channel_layout = AV_CH_LAYOUT_5POINT1_BACK; + av_channel_layout_from_mask(&c->ch_layout, AV_CH_LAYOUT_5POINT1_BACK); break; case FFM_CHANNELS_SURROUND71: - c->channel_layout = AV_CH_LAYOUT_7POINT1; + av_channel_layout_from_mask(&c->ch_layout, AV_CH_LAYOUT_7POINT1); break; } @@ -1027,7 +1027,7 @@ static AVStream *alloc_audio_stream(FFMpegContext *context, * not sure if that is needed anymore, so let's try out if there are any * complaints regarding some FFmpeg versions users might have. */ context->audio_input_samples = AV_INPUT_BUFFER_MIN_SIZE * 8 / c->bits_per_coded_sample / - c->channels; + c->ch_layout.nb_channels; } else { context->audio_input_samples = c->frame_size; @@ -1037,11 +1037,11 @@ static AVStream *alloc_audio_stream(FFMpegContext *context, context->audio_sample_size = av_get_bytes_per_sample(c->sample_fmt); - context->audio_input_buffer = (uint8_t *)av_malloc(context->audio_input_samples * c->channels * - context->audio_sample_size); + context->audio_input_buffer = (uint8_t *)av_malloc( + context->audio_input_samples * c->ch_layout.nb_channels * context->audio_sample_size); if (context->audio_deinterleave) { context->audio_deinterleave_buffer = (uint8_t *)av_malloc( - context->audio_input_samples * c->channels * context->audio_sample_size); + context->audio_input_samples * c->ch_layout.nb_channels * context->audio_sample_size); } context->audio_time = 0.0f; @@ -1432,7 +1432,7 @@ int BKE_ffmpeg_start(void *context_v, AVCodecContext *c = context->audio_codec; AUD_DeviceSpecs specs; - specs.channels = c->channels; + specs.channels = c->ch_layout.nb_channels; switch (av_get_packed_sample_fmt(c->sample_fmt)) { case AV_SAMPLE_FMT_U8: diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 179a1a305d1..d13f3fe5ced 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -626,17 +626,6 @@ bool BLI_path_suffix(char *string, size_t maxlen, const char *suffix, const char bool BLI_path_parent_dir(char *path) { - char tmp[FILE_MAX]; - - STRNCPY(tmp, path); - /* Does all the work of normalizing the path for us. - * - * NOTE(@campbellbarton): While it's possible strip text after the second last slash, - * this would have to be clever and skip cases like "/./" & multiple slashes. - * Since this ends up solving some of the same problems as #BLI_path_normalize, - * call this function instead of attempting to handle them separately. */ - BLI_path_normalize(NULL, tmp); - /* Use #BLI_path_name_at_index instead of checking if the strings ends with `parent_dir` * to ensure the logic isn't confused by: * - Directory names that happen to end with `..`. @@ -644,18 +633,19 @@ bool BLI_path_parent_dir(char *path) * which would cause checking for a tailing `/../` fail. * Extracting the span of the final directory avoids both these issues. */ int tail_ofs = 0, tail_len = 0; - if (!BLI_path_name_at_index(tmp, -1, &tail_ofs, &tail_len)) { + if (!BLI_path_name_at_index(path, -1, &tail_ofs, &tail_len)) { return false; } if (tail_len == 1) { /* Last path is ".", as normalize should remove this, it's safe to assume failure. * This happens when the input a single period (possibly with slashes before or after). */ - if (tmp[tail_ofs] == '.') { + if (path[tail_ofs] == '.') { return false; } } - memcpy(path, tmp, tail_ofs); + /* Input paths should already be normalized if `..` is part of the path. */ + BLI_assert(!((tail_len == 2) && (path[tail_ofs] == '.') && (path[tail_ofs + 1] == '.'))); path[tail_ofs] = '\0'; return true; } diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index e4a93762da4..cdb63bd8075 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -44,6 +44,7 @@ #include "BKE_image.h" #include "BKE_main.h" /* for Main */ #include "BKE_mesh.h" /* for ME_ defines (patching) */ +#include "BKE_mesh_legacy_convert.h" #include "BKE_modifier.h" #include "BKE_particle.h" #include "BKE_pointcache.h" diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 9a0568a3589..23d514a7b12 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -62,6 +62,7 @@ #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_pointcache.h" +#include "BKE_mesh_legacy_convert.h" #include "SEQ_iterator.h" #include "SEQ_sequencer.h" diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 8125130490a..cff8eb5a2f7 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -732,8 +732,7 @@ short BM_edge_flag_to_mflag(BMEdge *e) return (((hflag & BM_ELEM_SEAM) ? ME_SEAM : 0) | ((hflag & BM_ELEM_DRAW) ? ME_EDGEDRAW : 0) | ((hflag & BM_ELEM_SMOOTH) == 0 ? ME_SHARP : 0) | - (BM_edge_is_wire(e) ? ME_LOOSEEDGE : 0) | /* not typical */ - ME_EDGERENDER); + (BM_edge_is_wire(e) ? ME_LOOSEEDGE : 0)); } char BM_face_flag_to_mflag(BMFace *f) { diff --git a/source/blender/compositor/realtime_compositor/CMakeLists.txt b/source/blender/compositor/realtime_compositor/CMakeLists.txt index 2402adcadaf..b4352248b5b 100644 --- a/source/blender/compositor/realtime_compositor/CMakeLists.txt +++ b/source/blender/compositor/realtime_compositor/CMakeLists.txt @@ -3,6 +3,7 @@ set(INC . algorithms + cached_resources ../../blenkernel ../../blenlib ../../gpu @@ -10,6 +11,7 @@ set(INC ../../makesdna ../../makesrna ../../nodes + ../../render ../../gpu/intern ../../../../intern/guardedalloc ) @@ -31,6 +33,7 @@ set(SRC intern/shader_node.cc intern/shader_operation.cc intern/simple_operation.cc + intern/static_cache_manager.cc intern/static_shader_manager.cc intern/texture_pool.cc intern/utilities.cc @@ -51,6 +54,7 @@ set(SRC COM_shader_node.hh COM_shader_operation.hh COM_simple_operation.hh + COM_static_cache_manager.hh COM_static_shader_manager.hh COM_texture_pool.hh COM_utilities.hh @@ -58,12 +62,22 @@ set(SRC algorithms/intern/algorithm_parallel_reduction.cc algorithms/COM_algorithm_parallel_reduction.hh + + cached_resources/intern/morphological_distance_feather_weights.cc + cached_resources/intern/symmetric_blur_weights.cc + cached_resources/intern/symmetric_separable_blur_weights.cc + + cached_resources/COM_cached_resource.hh + cached_resources/COM_morphological_distance_feather_weights.hh + cached_resources/COM_symmetric_blur_weights.hh + cached_resources/COM_symmetric_separable_blur_weights.hh ) set(LIB bf_gpu bf_nodes bf_imbuf + bf_render bf_blenlib bf_blenkernel ) diff --git a/source/blender/compositor/realtime_compositor/COM_context.hh b/source/blender/compositor/realtime_compositor/COM_context.hh index b5c8cea641f..80fb4f70ca4 100644 --- a/source/blender/compositor/realtime_compositor/COM_context.hh +++ b/source/blender/compositor/realtime_compositor/COM_context.hh @@ -9,6 +9,7 @@ #include "GPU_texture.h" +#include "COM_static_cache_manager.hh" #include "COM_static_shader_manager.hh" #include "COM_texture_pool.hh" @@ -22,14 +23,17 @@ namespace blender::realtime_compositor { * providing input data like render passes and the active scene, as well as references to the data * where the output of the evaluator will be written. The class also provides a reference to the * texture pool which should be implemented by the caller and provided during construction. - * Finally, the class have an instance of a static shader manager for convenient shader - * acquisition. */ + * Finally, the class have an instance of a static shader manager and a static resource manager + * for acquiring cached shaders and resources efficiently. */ class Context { private: /* A texture pool that can be used to allocate textures for the compositor efficiently. */ TexturePool &texture_pool_; /* A static shader manager that can be used to acquire shaders for the compositor efficiently. */ StaticShaderManager shader_manager_; + /* A static cache manager that can be used to acquire cached resources for the compositor + * efficiently. */ + StaticCacheManager cache_manager_; public: Context(TexturePool &texture_pool); @@ -67,6 +71,9 @@ class Context { /* Get a reference to the static shader manager of this context. */ StaticShaderManager &shader_manager(); + + /* Get a reference to the static cache manager of this context. */ + StaticCacheManager &cache_manager(); }; } // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/COM_static_cache_manager.hh b/source/blender/compositor/realtime_compositor/COM_static_cache_manager.hh new file mode 100644 index 00000000000..20fbb156879 --- /dev/null +++ b/source/blender/compositor/realtime_compositor/COM_static_cache_manager.hh @@ -0,0 +1,77 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +#include <memory> + +#include "BLI_map.hh" +#include "BLI_math_vec_types.hh" + +#include "COM_morphological_distance_feather_weights.hh" +#include "COM_symmetric_blur_weights.hh" +#include "COM_symmetric_separable_blur_weights.hh" + +namespace blender::realtime_compositor { + +/* ------------------------------------------------------------------------------------------------- + * Static Cache Manager + * + * A static cache manager is a collection of cached resources that can be retrieved when needed and + * created if not already available. In particular, each cached resource type has its own Map in + * the class, where all instances of that cached resource type are stored and tracked. See the + * CachedResource class for more information. + * + * The manager deletes the cached resources that are no longer needed. A cached resource is said to + * be not needed when it was not used in the previous evaluation. This is done through the + * following mechanism: + * + * - Before every evaluation, do the following: + * 1. All resources whose CachedResource::needed flag is false are deleted. + * 2. The CachedResource::needed flag of all remaining resources is set to false. + * - During evaluation, when retrieving any cached resource, set its CachedResource::needed flag to + * true. + * + * In effect, any resource that was used in the previous evaluation but was not used in the current + * evaluation will be deleted before the next evaluation. This mechanism is implemented in the + * reset() method of the class, which should be called before every evaluation. */ +class StaticCacheManager { + private: + /* A map that stores all SymmetricBlurWeights cached resources. */ + Map<SymmetricBlurWeightsKey, std::unique_ptr<SymmetricBlurWeights>> symmetric_blur_weights_; + + /* A map that stores all SymmetricSeparableBlurWeights cached resources. */ + Map<SymmetricSeparableBlurWeightsKey, std::unique_ptr<SymmetricSeparableBlurWeights>> + symmetric_separable_blur_weights_; + + /* A map that stores all MorphologicalDistanceFeatherWeights cached resources. */ + Map<MorphologicalDistanceFeatherWeightsKey, std::unique_ptr<MorphologicalDistanceFeatherWeights>> + morphological_distance_feather_weights_; + + public: + /* Reset the cache manager by deleting the cached resources that are no longer needed because + * they weren't used in the last evaluation and prepare the remaining cached resources to track + * their needed status in the next evaluation. See the class description for more information. + * This should be called before every evaluation. */ + void reset(); + + /* Check if there is an available SymmetricBlurWeights cached resource with the given parameters + * in the manager, if one exists, return it, otherwise, return a newly created one and add it to + * the manager. In both cases, tag the cached resource as needed to keep it cached for the next + * evaluation. */ + SymmetricBlurWeights &get_symmetric_blur_weights(int type, float2 radius); + + /* Check if there is an available SymmetricSeparableBlurWeights cached resource with the given + * parameters in the manager, if one exists, return it, otherwise, return a newly created one and + * add it to the manager. In both cases, tag the cached resource as needed to keep it cached for + * the next evaluation. */ + SymmetricSeparableBlurWeights &get_symmetric_separable_blur_weights(int type, float radius); + + /* Check if there is an available MorphologicalDistanceFeatherWeights cached resource with the + * given parameters in the manager, if one exists, return it, otherwise, return a newly created + * one and add it to the manager. In both cases, tag the cached resource as needed to keep it + * cached for the next evaluation. */ + MorphologicalDistanceFeatherWeights &get_morphological_distance_feather_weights(int type, + int radius); +}; + +} // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/cached_resources/COM_cached_resource.hh b/source/blender/compositor/realtime_compositor/cached_resources/COM_cached_resource.hh new file mode 100644 index 00000000000..fe3158ef52d --- /dev/null +++ b/source/blender/compositor/realtime_compositor/cached_resources/COM_cached_resource.hh @@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +namespace blender::realtime_compositor { + +/* ------------------------------------------------------------------------------------------------- + * Cached Resource. + * + * A cached resource is any resource that can be cached across compositor evaluations and across + * multiple operations. Cached resources are managed by an instance of a StaticCacheManager and are + * freed when they are no longer needed, a state which is represented by the `needed` member in the + * class. For more information on the caching mechanism, see the StaticCacheManager class. + * + * To add a new cached resource: + * + * - Create a derived class from CachedResource to represent the resource. + * - Create a key class that can be used in a Map to identify the resource. + * - Add a new Map to StaticCacheManager mapping the key to the resource. + * - Reset the contents of the added map in StaticCacheManager::reset. + * - Add an appropriate getter method in StaticCacheManager. + * + * See the existing cached resources for reference. */ +class CachedResource { + public: + /* A flag that represents the needed status of the cached resource. See the StaticCacheManager + * class for more information on how this member is utilized in the caching mechanism. */ + bool needed = true; +}; + +} // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/cached_resources/COM_morphological_distance_feather_weights.hh b/source/blender/compositor/realtime_compositor/cached_resources/COM_morphological_distance_feather_weights.hh new file mode 100644 index 00000000000..cd6827bdd6b --- /dev/null +++ b/source/blender/compositor/realtime_compositor/cached_resources/COM_morphological_distance_feather_weights.hh @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +#include <cstdint> + +#include "GPU_shader.h" +#include "GPU_texture.h" + +#include "COM_cached_resource.hh" + +namespace blender::realtime_compositor { + +/* ------------------------------------------------------------------------------------------------ + * Morphological Distance Feather Key. + */ +class MorphologicalDistanceFeatherWeightsKey { + public: + int type; + float radius; + + MorphologicalDistanceFeatherWeightsKey(int type, float radius); + + uint64_t hash() const; +}; + +bool operator==(const MorphologicalDistanceFeatherWeightsKey &a, + const MorphologicalDistanceFeatherWeightsKey &b); + +/* ------------------------------------------------------------------------------------------------- + * Morphological Distance Feather Weights. + * + * A cached resource that computes and caches 1D GPU textures containing the weights of the + * separable Gaussian filter of the given radius as well as an inverse distance falloff of the + * given type and radius. The weights and falloffs are symmetric, because the Gaussian and falloff + * functions are all even functions. Consequently, only the positive half of the filter is computed + * and the shader takes that into consideration. */ +class MorphologicalDistanceFeatherWeights : public CachedResource { + private: + GPUTexture *weights_texture_ = nullptr; + GPUTexture *distance_falloffs_texture_ = nullptr; + + public: + MorphologicalDistanceFeatherWeights(int type, int radius); + + ~MorphologicalDistanceFeatherWeights(); + + void compute_weights(int radius); + + void compute_distance_falloffs(int type, int radius); + + void bind_weights_as_texture(GPUShader *shader, const char *texture_name) const; + + void unbind_weights_as_texture() const; + + void bind_distance_falloffs_as_texture(GPUShader *shader, const char *texture_name) const; + + void unbind_distance_falloffs_as_texture() const; +}; + +} // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_blur_weights.hh b/source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_blur_weights.hh new file mode 100644 index 00000000000..05d3c7c6f3e --- /dev/null +++ b/source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_blur_weights.hh @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +#include <cstdint> + +#include "BLI_math_vec_types.hh" + +#include "GPU_shader.h" +#include "GPU_texture.h" + +#include "COM_cached_resource.hh" + +namespace blender::realtime_compositor { + +/* ------------------------------------------------------------------------------------------------ + * Symmetric Blur Weights Key. + */ +class SymmetricBlurWeightsKey { + public: + int type; + float2 radius; + + SymmetricBlurWeightsKey(int type, float2 radius); + + uint64_t hash() const; +}; + +bool operator==(const SymmetricBlurWeightsKey &a, const SymmetricBlurWeightsKey &b); + +/* ------------------------------------------------------------------------------------------------- + * Symmetric Blur Weights. + * + * A cached resource that computes and caches a 2D GPU texture containing the weights of the filter + * of the given type and radius. The filter is assumed to be symmetric, because the filter + * functions are evaluated on the normalized distance to the center. Consequently, only the upper + * right quadrant are computed and the shader takes that into consideration. */ +class SymmetricBlurWeights : public CachedResource { + private: + GPUTexture *texture_ = nullptr; + + public: + SymmetricBlurWeights(int type, float2 radius); + + ~SymmetricBlurWeights(); + + void bind_as_texture(GPUShader *shader, const char *texture_name) const; + + void unbind_as_texture() const; +}; + +} // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_separable_blur_weights.hh b/source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_separable_blur_weights.hh new file mode 100644 index 00000000000..85e75e4535d --- /dev/null +++ b/source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_separable_blur_weights.hh @@ -0,0 +1,53 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +#include <cstdint> + +#include "BLI_math_vec_types.hh" + +#include "GPU_shader.h" +#include "GPU_texture.h" + +#include "COM_cached_resource.hh" + +namespace blender::realtime_compositor { + +/* ------------------------------------------------------------------------------------------------ + * Symmetric Separable Blur Weights Key. + */ +class SymmetricSeparableBlurWeightsKey { + public: + int type; + float radius; + + SymmetricSeparableBlurWeightsKey(int type, float radius); + + uint64_t hash() const; +}; + +bool operator==(const SymmetricSeparableBlurWeightsKey &a, + const SymmetricSeparableBlurWeightsKey &b); + +/* ------------------------------------------------------------------------------------------------- + * Symmetric Separable Blur Weights. + * + * A cached resource that computes and caches a 1D GPU texture containing the weights of the + * separable filter of the given type and radius. The filter is assumed to be symmetric, because + * the filter functions are all even functions. Consequently, only the positive half of the filter + * is computed and the shader takes that into consideration. */ +class SymmetricSeparableBlurWeights : public CachedResource { + private: + GPUTexture *texture_ = nullptr; + + public: + SymmetricSeparableBlurWeights(int type, float radius); + + ~SymmetricSeparableBlurWeights(); + + void bind_as_texture(GPUShader *shader, const char *texture_name) const; + + void unbind_as_texture() const; +}; + +} // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/cached_resources/intern/morphological_distance_feather_weights.cc b/source/blender/compositor/realtime_compositor/cached_resources/intern/morphological_distance_feather_weights.cc new file mode 100644 index 00000000000..eac88b907b8 --- /dev/null +++ b/source/blender/compositor/realtime_compositor/cached_resources/intern/morphological_distance_feather_weights.cc @@ -0,0 +1,159 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <cmath> +#include <cstdint> + +#include "BLI_array.hh" +#include "BLI_hash.hh" +#include "BLI_index_range.hh" + +#include "RE_pipeline.h" + +#include "DNA_scene_types.h" + +#include "GPU_shader.h" +#include "GPU_texture.h" + +#include "COM_morphological_distance_feather_weights.hh" + +namespace blender::realtime_compositor { + +/* -------------------------------------------------------------------- + * Morphological Distance Feather Weights Key. + */ + +MorphologicalDistanceFeatherWeightsKey::MorphologicalDistanceFeatherWeightsKey(int type, + float radius) + : type(type), radius(radius) +{ +} + +uint64_t MorphologicalDistanceFeatherWeightsKey::hash() const +{ + return get_default_hash_2(type, radius); +} + +bool operator==(const MorphologicalDistanceFeatherWeightsKey &a, + const MorphologicalDistanceFeatherWeightsKey &b) +{ + return a.type == b.type && a.radius == b.radius; +} + +/* -------------------------------------------------------------------- + * Morphological Distance Feather Weights. + */ + +MorphologicalDistanceFeatherWeights::MorphologicalDistanceFeatherWeights(int type, int radius) +{ + compute_weights(radius); + compute_distance_falloffs(type, radius); +} + +MorphologicalDistanceFeatherWeights::~MorphologicalDistanceFeatherWeights() +{ + GPU_texture_free(weights_texture_); + GPU_texture_free(distance_falloffs_texture_); +} + +void MorphologicalDistanceFeatherWeights::compute_weights(int radius) +{ + /* The size of filter is double the radius plus 1, but since the filter is symmetric, we only + * compute half of it and no doubling happens. We add 1 to make sure the filter size is always + * odd and there is a center weight. */ + const int size = radius + 1; + Array<float> weights(size); + + float sum = 0.0f; + + /* First, compute the center weight. */ + const float center_weight = RE_filter_value(R_FILTER_GAUSS, 0.0f); + weights[0] = center_weight; + sum += center_weight; + + /* Second, compute the other weights in the positive direction, making sure to add double the + * weight to the sum of weights because the filter is symmetric and we only loop over half of + * it. Skip the center weight already computed by dropping the front index. */ + const float scale = radius > 0.0f ? 1.0f / radius : 0.0f; + for (const int i : weights.index_range().drop_front(1)) { + const float weight = RE_filter_value(R_FILTER_GAUSS, i * scale); + weights[i] = weight; + sum += weight * 2.0f; + } + + /* Finally, normalize the weights. */ + for (const int i : weights.index_range()) { + weights[i] /= sum; + } + + weights_texture_ = GPU_texture_create_1d("Weights", size, 1, GPU_R16F, weights.data()); +} + +/* Computes a falloff that is equal to 1 at an input of zero and decrease to zero at an input of 1, + * with the rate of decrease depending on the falloff type. */ +static float compute_distance_falloff(int type, float x) +{ + x = 1.0f - x; + + switch (type) { + case PROP_SMOOTH: + return 3.0f * x * x - 2.0f * x * x * x; + case PROP_SPHERE: + return std::sqrt(2.0f * x - x * x); + case PROP_ROOT: + return std::sqrt(x); + case PROP_SHARP: + return x * x; + case PROP_INVSQUARE: + return x * (2.0f - x); + case PROP_LIN: + return x; + default: + BLI_assert_unreachable(); + return x; + } +} + +void MorphologicalDistanceFeatherWeights::compute_distance_falloffs(int type, int radius) +{ + /* The size of the distance falloffs is double the radius plus 1, but since the falloffs are + * symmetric, we only compute half of them and no doubling happens. We add 1 to make sure the + * falloffs size is always odd and there is a center falloff. */ + const int size = radius + 1; + Array<float> falloffs(size); + + /* Compute the distance falloffs in the positive direction only, because the falloffs are + * symmetric. */ + const float scale = radius > 0.0f ? 1.0f / radius : 0.0f; + for (const int i : falloffs.index_range()) { + falloffs[i] = compute_distance_falloff(type, i * scale); + } + + distance_falloffs_texture_ = GPU_texture_create_1d( + "Distance Factors", size, 1, GPU_R16F, falloffs.data()); +} + +void MorphologicalDistanceFeatherWeights::bind_weights_as_texture(GPUShader *shader, + const char *texture_name) const +{ + const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name); + GPU_texture_bind(weights_texture_, texture_image_unit); +} + +void MorphologicalDistanceFeatherWeights::unbind_weights_as_texture() const +{ + GPU_texture_unbind(weights_texture_); +} + +void MorphologicalDistanceFeatherWeights::bind_distance_falloffs_as_texture( + GPUShader *shader, const char *texture_name) const +{ + const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name); + GPU_texture_bind(distance_falloffs_texture_, texture_image_unit); +} + +void MorphologicalDistanceFeatherWeights::unbind_distance_falloffs_as_texture() const +{ + GPU_texture_unbind(distance_falloffs_texture_); +} + +} // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/cached_resources/intern/symmetric_blur_weights.cc b/source/blender/compositor/realtime_compositor/cached_resources/intern/symmetric_blur_weights.cc new file mode 100644 index 00000000000..a22d32a8e18 --- /dev/null +++ b/source/blender/compositor/realtime_compositor/cached_resources/intern/symmetric_blur_weights.cc @@ -0,0 +1,115 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <cstdint> + +#include "BLI_array.hh" +#include "BLI_hash.hh" +#include "BLI_index_range.hh" +#include "BLI_math_vec_types.hh" +#include "BLI_math_vector.hh" + +#include "RE_pipeline.h" + +#include "GPU_shader.h" +#include "GPU_texture.h" + +#include "COM_symmetric_blur_weights.hh" + +namespace blender::realtime_compositor { + +/* -------------------------------------------------------------------- + * Symmetric Blur Weights Key. + */ + +SymmetricBlurWeightsKey::SymmetricBlurWeightsKey(int type, float2 radius) + : type(type), radius(radius) +{ +} + +uint64_t SymmetricBlurWeightsKey::hash() const +{ + return get_default_hash_3(type, radius.x, radius.y); +} + +bool operator==(const SymmetricBlurWeightsKey &a, const SymmetricBlurWeightsKey &b) +{ + return a.type == b.type && a.radius == b.radius; +} + +/* -------------------------------------------------------------------- + * Symmetric Blur Weights. + */ + +SymmetricBlurWeights::SymmetricBlurWeights(int type, float2 radius) +{ + /* The full size of filter is double the radius plus 1, but since the filter is symmetric, we + * only compute a single quadrant of it and so no doubling happens. We add 1 to make sure the + * filter size is always odd and there is a center weight. */ + const float2 scale = math::safe_divide(float2(1.0f), radius); + const int2 size = int2(math::ceil(radius)) + int2(1); + Array<float> weights(size.x * size.y); + + float sum = 0.0f; + + /* First, compute the center weight. */ + const float center_weight = RE_filter_value(type, 0.0f); + weights[0] = center_weight; + sum += center_weight; + + /* Then, compute the weights along the positive x axis, making sure to add double the weight to + * the sum of weights because the filter is symmetric and we only loop over the positive half + * of the x axis. Skip the center weight already computed by dropping the front index. */ + for (const int x : IndexRange(size.x).drop_front(1)) { + const float weight = RE_filter_value(type, x * scale.x); + weights[x] = weight; + sum += weight * 2.0f; + } + + /* Then, compute the weights along the positive y axis, making sure to add double the weight to + * the sum of weights because the filter is symmetric and we only loop over the positive half + * of the y axis. Skip the center weight already computed by dropping the front index. */ + for (const int y : IndexRange(size.y).drop_front(1)) { + const float weight = RE_filter_value(type, y * scale.y); + weights[size.x * y] = weight; + sum += weight * 2.0f; + } + + /* Then, compute the other weights in the upper right quadrant, making sure to add quadruple + * the weight to the sum of weights because the filter is symmetric and we only loop over one + * quadrant of it. Skip the weights along the y and x axis already computed by dropping the + * front index. */ + for (const int y : IndexRange(size.y).drop_front(1)) { + for (const int x : IndexRange(size.x).drop_front(1)) { + const float weight = RE_filter_value(type, math::length(float2(x, y) * scale)); + weights[size.x * y + x] = weight; + sum += weight * 4.0f; + } + } + + /* Finally, normalize the weights. */ + for (const int y : IndexRange(size.y)) { + for (const int x : IndexRange(size.x)) { + weights[size.x * y + x] /= sum; + } + } + + texture_ = GPU_texture_create_2d("Weights", size.x, size.y, 1, GPU_R16F, weights.data()); +} + +SymmetricBlurWeights::~SymmetricBlurWeights() +{ + GPU_texture_free(texture_); +} + +void SymmetricBlurWeights::bind_as_texture(GPUShader *shader, const char *texture_name) const +{ + const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name); + GPU_texture_bind(texture_, texture_image_unit); +} + +void SymmetricBlurWeights::unbind_as_texture() const +{ + GPU_texture_unbind(texture_); +} + +} // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/cached_resources/intern/symmetric_separable_blur_weights.cc b/source/blender/compositor/realtime_compositor/cached_resources/intern/symmetric_separable_blur_weights.cc new file mode 100644 index 00000000000..b8c47d5a5d0 --- /dev/null +++ b/source/blender/compositor/realtime_compositor/cached_resources/intern/symmetric_separable_blur_weights.cc @@ -0,0 +1,93 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <cstdint> + +#include "BLI_array.hh" +#include "BLI_hash.hh" +#include "BLI_index_range.hh" +#include "BLI_math_base.hh" + +#include "RE_pipeline.h" + +#include "GPU_shader.h" +#include "GPU_texture.h" + +#include "COM_symmetric_separable_blur_weights.hh" + +namespace blender::realtime_compositor { + +/* -------------------------------------------------------------------- + * Symmetric Separable Blur Weights Key. + */ + +SymmetricSeparableBlurWeightsKey::SymmetricSeparableBlurWeightsKey(int type, float radius) + : type(type), radius(radius) +{ +} + +uint64_t SymmetricSeparableBlurWeightsKey::hash() const +{ + return get_default_hash_2(type, radius); +} + +bool operator==(const SymmetricSeparableBlurWeightsKey &a, + const SymmetricSeparableBlurWeightsKey &b) +{ + return a.type == b.type && a.radius == b.radius; +} + +/* -------------------------------------------------------------------- + * Symmetric Separable Blur Weights. + */ + +SymmetricSeparableBlurWeights::SymmetricSeparableBlurWeights(int type, float radius) +{ + /* The size of filter is double the radius plus 1, but since the filter is symmetric, we only + * compute half of it and no doubling happens. We add 1 to make sure the filter size is always + * odd and there is a center weight. */ + const int size = math::ceil(radius) + 1; + Array<float> weights(size); + + float sum = 0.0f; + + /* First, compute the center weight. */ + const float center_weight = RE_filter_value(type, 0.0f); + weights[0] = center_weight; + sum += center_weight; + + /* Second, compute the other weights in the positive direction, making sure to add double the + * weight to the sum of weights because the filter is symmetric and we only loop over half of + * it. Skip the center weight already computed by dropping the front index. */ + const float scale = radius > 0.0f ? 1.0f / radius : 0.0f; + for (const int i : weights.index_range().drop_front(1)) { + const float weight = RE_filter_value(type, i * scale); + weights[i] = weight; + sum += weight * 2.0f; + } + + /* Finally, normalize the weights. */ + for (const int i : weights.index_range()) { + weights[i] /= sum; + } + + texture_ = GPU_texture_create_1d("Weights", size, 1, GPU_R16F, weights.data()); +} + +SymmetricSeparableBlurWeights::~SymmetricSeparableBlurWeights() +{ + GPU_texture_free(texture_); +} + +void SymmetricSeparableBlurWeights::bind_as_texture(GPUShader *shader, + const char *texture_name) const +{ + const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name); + GPU_texture_bind(texture_, texture_image_unit); +} + +void SymmetricSeparableBlurWeights::unbind_as_texture() const +{ + GPU_texture_unbind(texture_); +} + +} // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/intern/context.cc b/source/blender/compositor/realtime_compositor/intern/context.cc index 924398f6747..0b123a2c271 100644 --- a/source/blender/compositor/realtime_compositor/intern/context.cc +++ b/source/blender/compositor/realtime_compositor/intern/context.cc @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ #include "COM_context.hh" +#include "COM_static_cache_manager.hh" #include "COM_static_shader_manager.hh" #include "COM_texture_pool.hh" @@ -32,4 +33,9 @@ StaticShaderManager &Context::shader_manager() return shader_manager_; } +StaticCacheManager &Context::cache_manager() +{ + return cache_manager_; +} + } // namespace blender::realtime_compositor diff --git a/source/blender/compositor/realtime_compositor/intern/evaluator.cc b/source/blender/compositor/realtime_compositor/intern/evaluator.cc index 48457bec199..1cd7d4f8951 100644 --- a/source/blender/compositor/realtime_compositor/intern/evaluator.cc +++ b/source/blender/compositor/realtime_compositor/intern/evaluator.cc @@ -28,6 +28,7 @@ Evaluator::Evaluator(Context &context, bNodeTree &node_tree) void Evaluator::evaluate() { + context_.cache_manager().reset(); context_.texture_pool().reset(); if (!is_compiled_) { diff --git a/source/blender/compositor/realtime_compositor/intern/static_cache_manager.cc b/source/blender/compositor/realtime_compositor/intern/static_cache_manager.cc new file mode 100644 index 00000000000..da78412a815 --- /dev/null +++ b/source/blender/compositor/realtime_compositor/intern/static_cache_manager.cc @@ -0,0 +1,74 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +#include <memory> + +#include "BLI_math_vec_types.hh" + +#include "COM_morphological_distance_feather_weights.hh" +#include "COM_symmetric_blur_weights.hh" +#include "COM_symmetric_separable_blur_weights.hh" + +#include "COM_static_cache_manager.hh" + +namespace blender::realtime_compositor { + +/* -------------------------------------------------------------------- + * Static Cache Manager. + */ + +void StaticCacheManager::reset() +{ + /* First, delete all resources that are no longer needed. */ + symmetric_blur_weights_.remove_if([](auto item) { return !item.value->needed; }); + symmetric_separable_blur_weights_.remove_if([](auto item) { return !item.value->needed; }); + morphological_distance_feather_weights_.remove_if([](auto item) { return !item.value->needed; }); + + /* Second, reset the needed status of the remaining resources to false to ready them to track + * their needed status for the next evaluation. */ + for (auto &value : symmetric_blur_weights_.values()) { + value->needed = false; + } + for (auto &value : symmetric_separable_blur_weights_.values()) { + value->needed = false; + } + for (auto &value : morphological_distance_feather_weights_.values()) { + value->needed = false; + } +} + +SymmetricBlurWeights &StaticCacheManager::get_symmetric_blur_weights(int type, float2 radius) +{ + const SymmetricBlurWeightsKey key(type, radius); + + auto &weights = *symmetric_blur_weights_.lookup_or_add_cb( + key, [&]() { return std::make_unique<SymmetricBlurWeights>(type, radius); }); + + weights.needed = true; + return weights; +} + +SymmetricSeparableBlurWeights &StaticCacheManager::get_symmetric_separable_blur_weights( + int type, float radius) +{ + const SymmetricSeparableBlurWeightsKey key(type, radius); + + auto &weights = *symmetric_separable_blur_weights_.lookup_or_add_cb( + key, [&]() { return std::make_unique<SymmetricSeparableBlurWeights>(type, radius); }); + + weights.needed = true; + return weights; +} + +MorphologicalDistanceFeatherWeights &StaticCacheManager:: + get_morphological_distance_feather_weights(int type, int radius) +{ + const MorphologicalDistanceFeatherWeightsKey key(type, radius); + + auto &weights = *morphological_distance_feather_weights_.lookup_or_add_cb( + key, [&]() { return std::make_unique<MorphologicalDistanceFeatherWeights>(type, radius); }); + + weights.needed = true; + return weights; +} + +} // namespace blender::realtime_compositor diff --git a/source/blender/draw/CMakeLists.txt b/source/blender/draw/CMakeLists.txt index 4010b491141..5902dc18165 100644 --- a/source/blender/draw/CMakeLists.txt +++ b/source/blender/draw/CMakeLists.txt @@ -24,6 +24,8 @@ set(INC ../render ../render/intern ../compositor/realtime_compositor + ../compositor/realtime_compositor/algorithms + ../compositor/realtime_compositor/cached_resources ../windowmanager ../../../intern/atomic diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index 9bf0cce2af2..26a264c1716 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -142,7 +142,7 @@ typedef struct EEVEE_LightBake { struct GPUTexture *dummy_layer_color; int total, done; /* to compute progress */ - short *stop, *do_update; + bool *stop, *do_update; float *progress; /** For only handling the resources. */ @@ -778,7 +778,7 @@ wmJob *EEVEE_lightbake_job_create(struct wmWindowManager *wm, } if (old_lbake->stop != NULL) { - *old_lbake->stop = 1; + *old_lbake->stop = true; } BLI_mutex_unlock(old_lbake->mutex); } @@ -1359,13 +1359,13 @@ static bool lightbake_do_sample(EEVEE_LightBake *lbake, DRW_custom_pipeline(&draw_engine_eevee_type, depsgraph, render_callback, lbake); lbake->done += 1; *lbake->progress = lbake->done / (float)lbake->total; - *lbake->do_update = 1; + *lbake->do_update = true; eevee_lightbake_context_disable(lbake); return true; } -void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float *progress) +void EEVEE_lightbake_job(void *custom_data, bool *stop, bool *do_update, float *progress) { EEVEE_LightBake *lbake = (EEVEE_LightBake *)custom_data; Depsgraph *depsgraph = lbake->depsgraph; @@ -1394,8 +1394,8 @@ void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float /* Resource allocation can fail. Early exit in this case. */ if (lbake->lcache->flag & LIGHTCACHE_INVALID) { - *lbake->stop = 1; - *lbake->do_update = 1; + *lbake->stop = true; + *lbake->do_update = true; lbake->lcache->flag &= ~LIGHTCACHE_BAKING; eevee_lightbake_context_disable(lbake); eevee_lightbake_delete_resources(lbake); diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.h b/source/blender/draw/engines/eevee/eevee_lightcache.h index 4e94e1914a7..73961f1919d 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.h +++ b/source/blender/draw/engines/eevee/eevee_lightcache.h @@ -42,7 +42,7 @@ void *EEVEE_lightbake_job_data_alloc(struct Main *bmain, int frame); void EEVEE_lightbake_job_data_free(void *custom_data); void EEVEE_lightbake_update(void *custom_data); -void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float *progress); +void EEVEE_lightbake_job(void *custom_data, bool *stop, bool *do_update, float *progress); /** * This is to update the world irradiance and reflection contribution from diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index 4744c0db6ce..7c5e8313532 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -88,14 +88,14 @@ BLI_INLINE Material *workbench_object_material_get(Object *ob, int mat_nr) BLI_INLINE void workbench_material_get_image( Object *ob, int mat_nr, Image **r_image, ImageUser **r_iuser, eGPUSamplerState *r_sampler) { - bNode *node; + const bNode *node; *r_sampler = 0; ED_object_get_active_image(ob, mat_nr, r_image, r_iuser, &node, NULL); if (node && *r_image) { switch (node->type) { case SH_NODE_TEX_IMAGE: { - NodeTexImage *storage = node->storage; + const NodeTexImage *storage = node->storage; const bool use_filter = (storage->interpolation != SHD_INTERP_CLOSEST); const bool use_repeat = (storage->extension == SHD_IMAGE_EXTENSION_REPEAT); const bool use_clip = (storage->extension == SHD_IMAGE_EXTENSION_CLIP); @@ -105,7 +105,7 @@ BLI_INLINE void workbench_material_get_image( break; } case SH_NODE_TEX_ENVIRONMENT: { - NodeTexEnvironment *storage = node->storage; + const NodeTexEnvironment *storage = node->storage; const bool use_filter = (storage->interpolation != SHD_INTERP_CLOSEST); SET_FLAG_FROM_TEST(*r_sampler, use_filter, GPU_SAMPLER_FILTER); break; diff --git a/source/blender/draw/intern/draw_command.cc b/source/blender/draw/intern/draw_command.cc index 10dd63e05dc..6e999815e8d 100644 --- a/source/blender/draw/intern/draw_command.cc +++ b/source/blender/draw/intern/draw_command.cc @@ -166,7 +166,10 @@ void StateSet::execute(RecordingState &recording_state) const */ BLI_assert(DST.state_lock == 0); - if (!assign_if_different(recording_state.pipeline_state, new_state)) { + bool state_changed = assign_if_different(recording_state.pipeline_state, new_state); + bool clip_changed = assign_if_different(recording_state.clip_plane_count, clip_plane_count); + + if (!state_changed && !clip_changed) { return; } @@ -190,12 +193,7 @@ void StateSet::execute(RecordingState &recording_state) const } /* TODO: this should be part of shader state. */ - if (new_state & DRW_STATE_CLIP_PLANES) { - GPU_clip_distances(recording_state.view_clip_plane_count); - } - else { - GPU_clip_distances(0); - } + GPU_clip_distances(recording_state.clip_plane_count); if (new_state & DRW_STATE_IN_FRONT_SELECT) { /* XXX `GPU_depth_range` is not a perfect solution diff --git a/source/blender/draw/intern/draw_command.hh b/source/blender/draw/intern/draw_command.hh index ed75ac21031..12c9916ee6d 100644 --- a/source/blender/draw/intern/draw_command.hh +++ b/source/blender/draw/intern/draw_command.hh @@ -39,7 +39,7 @@ struct RecordingState { bool front_facing = true; bool inverted_view = false; DRWState pipeline_state = DRW_STATE_NO_DRAW; - int view_clip_plane_count = 0; + int clip_plane_count = 0; /** Used for gl_BaseInstance workaround. */ GPUStorageBuf *resource_id_buf = nullptr; @@ -325,6 +325,7 @@ struct Clear { struct StateSet { DRWState new_state; + int clip_plane_count; void execute(RecordingState &state) const; std::string serialize() const; diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c index 40b05dff51f..85701a10f4b 100644 --- a/source/blender/draw/intern/draw_manager_shader.c +++ b/source/blender/draw/intern/draw_manager_shader.c @@ -64,8 +64,8 @@ static void drw_deferred_shader_compilation_exec( void *custom_data, /* Cannot be const, this function implements wm_jobs_start_callback. * NOLINTNEXTLINE: readability-non-const-parameter. */ - short *stop, - short *UNUSED(do_update), + bool *stop, + bool *UNUSED(do_update), float *UNUSED(progress)) { GPU_render_begin(); diff --git a/source/blender/draw/intern/draw_pass.hh b/source/blender/draw/intern/draw_pass.hh index 892dfdddfcf..2c1fd16928e 100644 --- a/source/blender/draw/intern/draw_pass.hh +++ b/source/blender/draw/intern/draw_pass.hh @@ -159,8 +159,10 @@ class PassBase { * * IMPORTANT: This does not set the stencil mask/reference values. Add a call to state_stencil() * to ensure correct behavior of stencil aware draws. + * + * TODO(fclem): clip_plane_count should be part of shader state. */ - void state_set(DRWState state); + void state_set(DRWState state, int clip_plane_count = 0); /** * Clear the current frame-buffer. @@ -731,9 +733,13 @@ template<class T> inline void PassBase<T>::barrier(eGPUBarrier type) /** \name State Implementation * \{ */ -template<class T> inline void PassBase<T>::state_set(DRWState state) +template<class T> inline void PassBase<T>::state_set(DRWState state, int clip_plane_count) { - create_command(Type::StateSet).state_set = {state}; + /** \note This is for compatibility with the old clip plane API. */ + if (clip_plane_count > 0) { + state |= DRW_STATE_CLIP_PLANES; + } + create_command(Type::StateSet).state_set = {state, clip_plane_count}; } template<class T> diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc index a968bd07c87..de1f5181ac5 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc @@ -66,7 +66,7 @@ static void extract_edge_fac_init(const MeshRenderData *mr, * We could have a flag in the mesh instead or check the modifier stack. */ const MEdge *med = mr->medge; for (int e_index = 0; e_index < mr->edge_len; e_index++, med++) { - if ((med->flag & ME_EDGERENDER) == 0) { + if ((med->flag & ME_EDGEDRAW) == 0) { data->use_edge_render = true; break; } @@ -118,7 +118,7 @@ static void extract_edge_fac_iter_poly_mesh(const MeshRenderData *mr, if (data->use_edge_render) { const MEdge *med = &mr->medge[ml->e]; - data->vbo_data[ml_index] = (med->flag & ME_EDGERENDER) ? 255 : 0; + data->vbo_data[ml_index] = (med->flag & ME_EDGEDRAW) ? 255 : 0; } else { diff --git a/source/blender/editors/gpencil/gpencil_trace_ops.c b/source/blender/editors/gpencil/gpencil_trace_ops.c index 36165c6b7c0..1a18e10412e 100644 --- a/source/blender/editors/gpencil/gpencil_trace_ops.c +++ b/source/blender/editors/gpencil/gpencil_trace_ops.c @@ -45,7 +45,7 @@ typedef struct TraceJob { /* from wmJob */ struct Object *owner; - short *stop, *do_update; + bool *stop, *do_update; float *progress; bContext *C; @@ -198,7 +198,7 @@ static void trace_initialize_job_data(TraceJob *trace_job) } } -static void trace_start_job(void *customdata, short *stop, short *do_update, float *progress) +static void trace_start_job(void *customdata, bool *stop, bool *do_update, float *progress) { TraceJob *trace_job = customdata; @@ -257,7 +257,7 @@ static void trace_start_job(void *customdata, short *stop, short *do_update, flo trace_job->success = !trace_job->was_canceled; *do_update = true; - *stop = 0; + *stop = false; } static void trace_end_job(void *customdata) @@ -339,7 +339,7 @@ static int gpencil_trace_image_exec(bContext *C, wmOperator *op) ED_object_base_activate(job->C, job->base_active); if ((job->image->source == IMA_SRC_FILE) || (job->frame_num > 0)) { - short stop = 0, do_update = true; + bool stop = false, do_update = true; float progress; trace_start_job(job, &stop, &do_update, &progress); trace_end_job(job); diff --git a/source/blender/editors/include/ED_uvedit.h b/source/blender/editors/include/ED_uvedit.h index b97cd6a9099..5fea8711a84 100644 --- a/source/blender/editors/include/ED_uvedit.h +++ b/source/blender/editors/include/ED_uvedit.h @@ -73,8 +73,8 @@ bool ED_object_get_active_image(struct Object *ob, int mat_nr, struct Image **r_ima, struct ImageUser **r_iuser, - struct bNode **r_node, - struct bNodeTree **r_ntree); + const struct bNode **r_node, + const struct bNodeTree **r_ntree); void ED_object_assign_active_image(struct Main *bmain, struct Object *ob, int mat_nr, diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 9a4f98ebcd6..a5e2cd02f3b 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -1309,8 +1309,8 @@ static void ui_id_preview_image_render_size( const bContext *C, Scene *scene, ID *id, PreviewImage *pi, int size, const bool use_job); static void ui_studiolight_icon_job_exec(void *customdata, - short *UNUSED(stop), - short *UNUSED(do_update), + bool *UNUSED(stop), + bool *UNUSED(do_update), float *UNUSED(progress)) { Icon **tmp = (Icon **)customdata; diff --git a/source/blender/editors/interface/interface_panel.cc b/source/blender/editors/interface/interface_panel.cc index 24d8281aad8..05b6ecf29d5 100644 --- a/source/blender/editors/interface/interface_panel.cc +++ b/source/blender/editors/interface/interface_panel.cc @@ -2026,7 +2026,7 @@ static void ui_panel_drag_collapse_handler_add(const bContext *C, const bool was ui_panel_drag_collapse_handler, ui_panel_drag_collapse_handler_remove, dragcol_data, - 0); + eWM_EventHandlerFlag(0)); } /** @@ -2510,8 +2510,12 @@ static void panel_handle_data_ensure(const bContext *C, { if (panel->activedata == nullptr) { panel->activedata = MEM_callocN(sizeof(uiHandlePanelData), __func__); - WM_event_add_ui_handler( - C, &win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, panel, 0); + WM_event_add_ui_handler(C, + &win->modalhandlers, + ui_handler_panel, + ui_handler_remove_panel, + panel, + eWM_EventHandlerFlag(0)); } uiHandlePanelData *data = static_cast<uiHandlePanelData *>(panel->activedata); diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index b468360ff9b..9901f4e1836 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -1191,7 +1191,7 @@ static void mesh_add_edges(Mesh *mesh, int len) MutableSpan<MEdge> edges = mesh->edges_for_write(); for (MEdge &edge : edges.take_back(len)) { - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } bke::MutableAttributeAccessor attributes = mesh->attributes_for_write(); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 4b6ce69294f..91641de1605 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -461,7 +461,7 @@ static void init_multiresbake_job(bContext *C, MultiresBakeJob *bkj) CTX_DATA_END; } -static void multiresbake_startjob(void *bkv, short *stop, short *do_update, float *progress) +static void multiresbake_startjob(void *bkv, bool *stop, bool *do_update, float *progress) { MultiresBakerJobData *data; MultiresBakeJob *bkj = bkv; diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index d05badc8fee..d647578dc50 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -106,7 +106,7 @@ typedef struct BakeAPIRender { /* Progress Callbacks. */ float *progress; - short *do_update; + bool *do_update; /* Operator state. */ ReportList *reports; @@ -150,12 +150,12 @@ static int bake_modal(bContext *C, wmOperator *UNUSED(op), const wmEvent *event) * for exec() when there is no render job * NOTE: this won't check for the escape key being pressed, but doing so isn't thread-safe. */ -static int bake_break(void *UNUSED(rjv)) +static bool bake_break(void *UNUSED(rjv)) { if (G.is_break) { - return 1; + return true; } - return 0; + return false; } static void bake_update_image(ScrArea *area, Image *image) @@ -467,8 +467,8 @@ static bool bake_object_check(const Scene *scene, } for (int i = 0; i < ob->totcol; i++) { - bNodeTree *ntree = NULL; - bNode *node = NULL; + const bNodeTree *ntree = NULL; + const bNode *node = NULL; const int mat_nr = i + 1; Image *image; ED_object_get_active_image(ob, mat_nr, &image, NULL, &node, &ntree); @@ -1854,7 +1854,7 @@ finally: return result; } -static void bake_startjob(void *bkv, short *UNUSED(stop), short *do_update, float *progress) +static void bake_startjob(void *bkv, bool *UNUSED(stop), bool *do_update, float *progress) { BakeAPIRender *bkr = (BakeAPIRender *)bkv; diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index 85a35861329..a87e52db129 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -614,7 +614,7 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList * /*reports*/, if (k) { medge->v1 = cvert - 1; medge->v2 = cvert; - medge->flag = ME_EDGEDRAW | ME_EDGERENDER | ME_LOOSEEDGE; + medge->flag = ME_EDGEDRAW | ME_LOOSEEDGE; medge++; } else { @@ -633,7 +633,7 @@ bool ED_object_modifier_convert_psys_to_mesh(ReportList * /*reports*/, if (k) { medge->v1 = cvert - 1; medge->v2 = cvert; - medge->flag = ME_EDGEDRAW | ME_EDGERENDER | ME_LOOSEEDGE; + medge->flag = ME_EDGEDRAW | ME_LOOSEEDGE; medge++; } else { @@ -3023,7 +3023,7 @@ static bool ocean_bake_poll(bContext *C) struct OceanBakeJob { /* from wmJob */ struct Object *owner; - short *stop, *do_update; + bool *stop, *do_update; float *progress; int current_frame; struct OceanCache *och; @@ -3062,7 +3062,7 @@ static void oceanbake_update(void *customdata, float progress, int *cancel) *(oj->progress) = progress; } -static void oceanbake_startjob(void *customdata, short *stop, short *do_update, float *progress) +static void oceanbake_startjob(void *customdata, bool *stop, bool *do_update, float *progress) { OceanBakeJob *oj = static_cast<OceanBakeJob *>(customdata); @@ -3075,7 +3075,7 @@ static void oceanbake_startjob(void *customdata, short *stop, short *do_update, BKE_ocean_bake(oj->ocean, oj->och, oceanbake_update, (void *)oj); *do_update = true; - *stop = 0; + *stop = false; } static void oceanbake_endjob(void *customdata) diff --git a/source/blender/editors/object/object_remesh.cc b/source/blender/editors/object/object_remesh.cc index 69fa84aa260..a50fb28805e 100644 --- a/source/blender/editors/object/object_remesh.cc +++ b/source/blender/editors/object/object_remesh.cc @@ -654,7 +654,7 @@ enum eSymmetryAxes { struct QuadriFlowJob { /* from wmJob */ struct Object *owner; - short *stop, *do_update; + bool *stop, *do_update; float *progress; const struct wmOperator *op; @@ -836,7 +836,7 @@ static Mesh *remesh_symmetry_mirror(Object *ob, Mesh *mesh, eSymmetryAxes symmet return mesh_mirror; } -static void quadriflow_start_job(void *customdata, short *stop, short *do_update, float *progress) +static void quadriflow_start_job(void *customdata, bool *stop, bool *do_update, float *progress) { QuadriFlowJob *qj = static_cast<QuadriFlowJob *>(customdata); @@ -884,7 +884,7 @@ static void quadriflow_start_job(void *customdata, short *stop, short *do_update if (new_mesh == nullptr) { *do_update = true; - *stop = 0; + *stop = false; if (qj->success == 1) { /* This is not a user cancellation event. */ qj->success = 0; @@ -917,7 +917,7 @@ static void quadriflow_start_job(void *customdata, short *stop, short *do_update BKE_mesh_batch_cache_dirty_tag(static_cast<Mesh *>(ob->data), BKE_MESH_BATCH_DIRTY_ALL); *do_update = true; - *stop = 0; + *stop = false; } static void quadriflow_end_job(void *customdata) @@ -992,7 +992,7 @@ static int quadriflow_remesh_exec(bContext *C, wmOperator *op) if (op->flag == 0) { /* This is called directly from the exec operator, this operation is now blocking */ job->is_nonblocking_job = false; - short stop = 0, do_update = true; + bool stop = false, do_update = true; float progress; quadriflow_start_job(job, &stop, &do_update, &progress); quadriflow_end_job(job); diff --git a/source/blender/editors/object/object_transform.cc b/source/blender/editors/object/object_transform.cc index 0c2aca8b97b..7d0b62db827 100644 --- a/source/blender/editors/object/object_transform.cc +++ b/source/blender/editors/object/object_transform.cc @@ -7,6 +7,7 @@ #include <cstdlib> #include <cstring> +#include <limits> #include <numeric> #include "DNA_anim_types.h" @@ -1643,8 +1644,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) /* done */ } else if (around == V3D_AROUND_CENTER_BOUNDS) { - float3 min; - float3 max; + float3 min(std::numeric_limits<float>::max()); + float3 max(-std::numeric_limits<float>::max()); if (curves.bounds_min_max(min, max)) { cent = math::midpoint(min, max); } diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 41238eb171b..1a3f0f0f2ac 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -285,7 +285,7 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot) typedef struct DynamicPaintBakeJob { /* from wmJob */ void *owner; - short *stop, *do_update; + bool *stop, *do_update; float *progress; struct Main *bmain; @@ -429,7 +429,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) ED_update_for_newframe(job->bmain, job->depsgraph); } -static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update, float *progress) +static void dpaint_bake_startjob(void *customdata, bool *stop, bool *do_update, float *progress) { DynamicPaintBakeJob *job = customdata; @@ -450,7 +450,7 @@ static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update dynamicPaint_bakeImageSequence(job); *do_update = true; - *stop = 0; + *stop = false; } /* diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 314796e96e4..d5e55c99444 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -61,7 +61,7 @@ typedef struct FluidJob { /* from wmJob */ void *owner; - short *stop, *do_update; + bool *stop, *do_update; float *progress; const char *type; const char *name; @@ -349,7 +349,7 @@ static void fluid_bake_endjob(void *customdata) } } -static void fluid_bake_startjob(void *customdata, short *stop, short *do_update, float *progress) +static void fluid_bake_startjob(void *customdata, bool *stop, bool *do_update, float *progress) { FluidJob *job = customdata; FluidDomainSettings *fds = job->fmd->domain; @@ -428,7 +428,7 @@ static void fluid_bake_startjob(void *customdata, short *stop, short *do_update, *do_update = true; } if (stop) { - *stop = 0; + *stop = false; } } @@ -461,7 +461,7 @@ static void fluid_free_endjob(void *customdata) } } -static void fluid_free_startjob(void *customdata, short *stop, short *do_update, float *progress) +static void fluid_free_startjob(void *customdata, bool *stop, bool *do_update, float *progress) { FluidJob *job = customdata; FluidDomainSettings *fds = job->fmd->domain; @@ -504,7 +504,7 @@ static void fluid_free_startjob(void *customdata, short *stop, short *do_update, #endif *do_update = true; - *stop = 0; + *stop = false; /* Update scene so that viewport shows freed up scene */ ED_update_for_newframe(job->bmain, job->depsgraph); diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 97cd0d1d149..9fac93187ee 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -86,7 +86,7 @@ static bool ptcache_add_remove_poll(bContext *C) typedef struct PointCacheJob { wmWindowManager *wm; void *owner; - short *stop, *do_update; + bool *stop, *do_update; float *progress; PTCacheBaker *baker; @@ -126,7 +126,7 @@ static void ptcache_job_update(void *customdata, float progress, int *cancel) *(job->progress) = progress; } -static void ptcache_job_startjob(void *customdata, short *stop, short *do_update, float *progress) +static void ptcache_job_startjob(void *customdata, bool *stop, bool *do_update, float *progress) { PointCacheJob *job = customdata; @@ -144,7 +144,7 @@ static void ptcache_job_startjob(void *customdata, short *stop, short *do_update BKE_ptcache_bake(job->baker); *do_update = true; - *stop = 0; + *stop = false; } static void ptcache_job_endjob(void *customdata) diff --git a/source/blender/editors/render/render_internal.cc b/source/blender/editors/render/render_internal.cc index e66cabbc9f8..b05f430d198 100644 --- a/source/blender/editors/render/render_internal.cc +++ b/source/blender/editors/render/render_internal.cc @@ -69,7 +69,7 @@ #include "render_intern.hh" /* Render Callbacks */ -static int render_break(void *rjv); +static bool render_break(void *rjv); struct RenderJob { Main *main; @@ -87,8 +87,8 @@ struct RenderJob { Image *image; ImageUser iuser; bool image_outdated; - short *stop; - short *do_update; + bool *stop; + bool *do_update; float *progress; ReportList *reports; int orig_layer; @@ -637,7 +637,7 @@ static void current_scene_update(void *rjv, Scene *scene) rj->iuser.scene = scene; } -static void render_startjob(void *rjv, short *stop, short *do_update, float *progress) +static void render_startjob(void *rjv, bool *stop, bool *do_update, float *progress) { RenderJob *rj = static_cast<RenderJob *>(rjv); @@ -791,29 +791,29 @@ static void render_endjob(void *rjv) } /* called by render, check job 'stop' value or the global */ -static int render_breakjob(void *rjv) +static bool render_breakjob(void *rjv) { RenderJob *rj = static_cast<RenderJob *>(rjv); if (G.is_break) { - return 1; + return true; } if (rj->stop && *(rj->stop)) { - return 1; + return true; } - return 0; + return false; } /** * For exec() when there is no render job * NOTE: this won't check for the escape key being pressed, but doing so isn't thread-safe. */ -static int render_break(void * /*rjv*/) +static bool render_break(void * /*rjv*/) { if (G.is_break) { - return 1; + return true; } - return 0; + return false; } /* runs in thread, no cursor setting here works. careful with notifiers too (malloc conflicts) */ diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index 5aae48b1138..8e50e8c04d1 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -104,7 +104,7 @@ static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect); struct ShaderPreview { /* from wmJob */ void *owner; - short *stop, *do_update; + bool *stop, *do_update; Scene *scene; ID *id, *id_copy; @@ -1047,7 +1047,7 @@ static void shader_preview_update(void *spv, RenderResult * /*rr*/, struct rcti } /* called by renderer, checks job value */ -static int shader_preview_break(void *spv) +static bool shader_preview_break(void *spv) { ShaderPreview *sp = static_cast<ShaderPreview *>(spv); @@ -1223,7 +1223,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs } /* runs inside thread for material and icons */ -static void shader_preview_startjob(void *customdata, short *stop, short *do_update) +static void shader_preview_startjob(void *customdata, bool *stop, bool *do_update) { ShaderPreview *sp = static_cast<ShaderPreview *>(customdata); @@ -1408,7 +1408,7 @@ static void set_alpha(char *cp, int sizex, int sizey, char alpha) } } -static void icon_preview_startjob(void *customdata, short *stop, short *do_update) +static void icon_preview_startjob(void *customdata, bool *stop, bool *do_update) { ShaderPreview *sp = static_cast<ShaderPreview *>(customdata); @@ -1488,8 +1488,8 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat * does not run two of them at the same time. */ static void common_preview_startjob(void *customdata, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float * /*progress*/) { ShaderPreview *sp = static_cast<ShaderPreview *>(customdata); @@ -1509,8 +1509,8 @@ static void common_preview_startjob(void *customdata, static void other_id_types_preview_render(IconPreview *ip, IconPreviewSize *cur_size, const ePreviewRenderMethod pr_method, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { ShaderPreview *sp = MEM_cnew<ShaderPreview>("Icon ShaderPreview"); @@ -1570,8 +1570,8 @@ static int icon_previewimg_size_index_get(const IconPreviewSize *icon_size, } static void icon_preview_startjob_all_sizes(void *customdata, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { IconPreview *ip = (IconPreview *)customdata; @@ -1735,7 +1735,7 @@ class PreviewLoadJob { void push_load_request(PreviewImage *preview, eIconSizes icon_size); private: - static void run_fn(void *customdata, short *stop, short *do_update, float *progress); + static void run_fn(void *customdata, bool *stop, bool *do_update, float *progress); static void update_fn(void *customdata); static void end_fn(void *customdata); static void free_fn(void *customdata); @@ -1755,7 +1755,8 @@ PreviewLoadJob::~PreviewLoadJob() PreviewLoadJob &PreviewLoadJob::ensure_job(wmWindowManager *wm, wmWindow *win) { - wmJob *wm_job = WM_jobs_get(wm, win, nullptr, "Load Previews", 0, WM_JOB_TYPE_LOAD_PREVIEW); + wmJob *wm_job = WM_jobs_get( + wm, win, nullptr, "Load Previews", eWM_JobFlag(0), WM_JOB_TYPE_LOAD_PREVIEW); if (!WM_jobs_is_running(wm_job)) { PreviewLoadJob *job_data = MEM_new<PreviewLoadJob>("PreviewLoadJobData"); @@ -1776,7 +1777,7 @@ void PreviewLoadJob::load_jobless(PreviewImage *preview, const eIconSizes icon_s job_data.push_load_request(preview, icon_size); - short stop = 0, do_update = 0; + bool stop = false, do_update = false; float progress = 0; run_fn(&job_data, &stop, &do_update, &progress); update_fn(&job_data); @@ -1798,7 +1799,7 @@ void PreviewLoadJob::push_load_request(PreviewImage *preview, const eIconSizes i BLI_thread_queue_push(todo_queue_, &requested_previews_.back()); } -void PreviewLoadJob::run_fn(void *customdata, short *stop, short *do_update, float * /*progress*/) +void PreviewLoadJob::run_fn(void *customdata, bool *stop, bool *do_update, float * /*progress*/) { PreviewLoadJob *job_data = static_cast<PreviewLoadJob *>(customdata); @@ -1936,7 +1937,7 @@ void ED_preview_icon_render( } IconPreview ip = {nullptr}; - short stop = false, update = false; + bool stop = false, update = false; float progress = 0.0f; ED_preview_ensure_dbase(); diff --git a/source/blender/editors/render/render_shading.cc b/source/blender/editors/render/render_shading.cc index 83ce447e8cf..e5c2b9702e5 100644 --- a/source/blender/editors/render/render_shading.cc +++ b/source/blender/editors/render/render_shading.cc @@ -1398,7 +1398,7 @@ static int light_cache_bake_exec(bContext *C, wmOperator *op) light_cache_bake_tag_cache(scene, op); - short stop = 0, do_update; + bool stop = false, do_update; float progress; /* Not actually used. */ EEVEE_lightbake_job(rj, &stop, &do_update, &progress); EEVEE_lightbake_job_data_free(rj); diff --git a/source/blender/editors/sculpt_paint/sculpt_brush_types.c b/source/blender/editors/sculpt_paint/sculpt_brush_types.c index 92541d10a59..666fa884e03 100644 --- a/source/blender/editors/sculpt_paint/sculpt_brush_types.c +++ b/source/blender/editors/sculpt_paint/sculpt_brush_types.c @@ -1441,6 +1441,9 @@ static void do_rotate_brush_task_cb_ex(void *__restrict userdata, if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { continue; } + + SCULPT_automasking_node_update(ss, &automask_data, &vd); + float vec[3], rot[3][3]; const float fade = bstrength * SCULPT_brush_strength_factor(ss, brush, diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 9a690f36aab..10a037a1c3c 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -676,8 +676,8 @@ typedef struct PrefetchQueue { SpinLock spin; - short *stop; - short *do_update; + bool *stop; + bool *do_update; float *progress; } PrefetchQueue; @@ -819,7 +819,7 @@ static uchar *prefetch_thread_next_frame(PrefetchQueue *queue, (queue->initial_frame - queue->current_frame); } - *queue->do_update = 1; + *queue->do_update = true; *queue->progress = (float)frames_processed / (queue->end_frame - queue->start_frame); } } @@ -868,7 +868,7 @@ static void prefetch_task_func(TaskPool *__restrict pool, void *task_data) if (!result) { /* no more space in the cache, stop reading frames */ - *queue->stop = 1; + *queue->stop = true; break; } } @@ -880,8 +880,8 @@ static void start_prefetch_threads(MovieClip *clip, int end_frame, short render_size, short render_flag, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { int tot_thread = BLI_task_scheduler_num_threads(); @@ -918,7 +918,7 @@ static bool prefetch_movie_frame(MovieClip *clip, int frame, short render_size, short render_flag, - short *stop) + bool *stop) { MovieClipUser user = *DNA_struct_default_get(MovieClipUser); @@ -940,14 +940,14 @@ static bool prefetch_movie_frame(MovieClip *clip, if (!result) { /* no more space in the cache, we could stop prefetching here */ - *stop = 1; + *stop = true; } IMB_freeImBuf(ibuf); } else { /* error reading frame, fair enough stop attempting further reading */ - *stop = 1; + *stop = true; } } @@ -961,8 +961,8 @@ static void do_prefetch_movie(MovieClip *clip, int end_frame, short render_size, short render_flag, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { int frame; @@ -976,7 +976,7 @@ static void do_prefetch_movie(MovieClip *clip, frames_processed++; - *do_update = 1; + *do_update = true; *progress = (float)frames_processed / (end_frame - start_frame); } @@ -988,12 +988,12 @@ static void do_prefetch_movie(MovieClip *clip, frames_processed++; - *do_update = 1; + *do_update = true; *progress = (float)frames_processed / (end_frame - start_frame); } } -static void prefetch_startjob(void *pjv, short *stop, short *do_update, float *progress) +static void prefetch_startjob(void *pjv, bool *stop, bool *do_update, float *progress) { PrefetchJob *pj = pjv; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 486f9f9ccb0..2c0668625a0 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1219,8 +1219,8 @@ static void do_movie_proxy(void *pjv, int UNUSED(build_count), int *build_undistort_sizes, int build_undistort_count, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { ProxyJob *pj = pjv; @@ -1285,8 +1285,8 @@ typedef struct ProxyQueue { int efra; SpinLock spin; - const short *stop; - short *do_update; + const bool *stop; + bool *do_update; float *progress; } ProxyQueue; @@ -1343,7 +1343,7 @@ static uchar *proxy_thread_next_frame(ProxyQueue *queue, queue->cfra++; close(file); - *queue->do_update = 1; + *queue->do_update = true; *queue->progress = (float)(queue->cfra - queue->sfra) / (queue->efra - queue->sfra); } BLI_spin_unlock(&queue->spin); @@ -1392,8 +1392,8 @@ static void do_sequence_proxy(void *pjv, int build_undistort_count, /* Cannot be const, because it is assigned to a non-const variable. * NOLINTNEXTLINE: readability-non-const-parameter. */ - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { ProxyJob *pj = pjv; @@ -1452,7 +1452,7 @@ static void do_sequence_proxy(void *pjv, MEM_freeN(handles); } -static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress) +static void proxy_startjob(void *pjv, bool *stop, bool *do_update, float *progress) { ProxyJob *pj = pjv; MovieClip *clip = pj->clip; diff --git a/source/blender/editors/space_clip/tracking_ops_solve.c b/source/blender/editors/space_clip/tracking_ops_solve.c index bfa45053e96..ddfcaa282e3 100644 --- a/source/blender/editors/space_clip/tracking_ops_solve.c +++ b/source/blender/editors/space_clip/tracking_ops_solve.c @@ -87,7 +87,7 @@ static void solve_camera_updatejob(void *scv) BLI_strncpy(tracking->stats->message, scj->stats_message, sizeof(tracking->stats->message)); } -static void solve_camera_startjob(void *scv, short *stop, short *do_update, float *progress) +static void solve_camera_startjob(void *scv, bool *stop, bool *do_update, float *progress) { SolveCameraJob *scj = (SolveCameraJob *)scv; BKE_tracking_reconstruction_solve( diff --git a/source/blender/editors/space_clip/tracking_ops_track.c b/source/blender/editors/space_clip/tracking_ops_track.c index f6fd2980c19..2753af609e7 100644 --- a/source/blender/editors/space_clip/tracking_ops_track.c +++ b/source/blender/editors/space_clip/tracking_ops_track.c @@ -204,8 +204,8 @@ static void track_markers_startjob( void *tmv, /* Cannot be const, this function implements wm_jobs_start_callback. * NOLINTNEXTLINE: readability-non-const-parameter. */ - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { TrackMarkersJob *tmj = (TrackMarkersJob *)tmv; @@ -353,7 +353,7 @@ static int track_markers(bContext *C, wmOperator *op, bool use_job) return OPERATOR_RUNNING_MODAL; } - short stop = 0, do_update = 0; + bool stop = false, do_update = false; float progress = 0.0f; track_markers_startjob(tmj, &stop, &do_update, &progress); track_markers_endjob(tmj); diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index 3870178f119..9ca5b1da7da 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -246,7 +246,7 @@ struct FileList { bool (*check_dir_fn)(struct FileList *, char *, const bool); /* Fill filelist (to be called by read job). */ - void (*read_job_fn)(struct FileListReadJob *, short *, short *, float *); + void (*read_job_fn)(struct FileListReadJob *, bool *, bool *, float *); /* Filter an entry of current filelist. */ bool (*filter_fn)(struct FileListInternEntry *, const char *, FileListFilter *); @@ -295,24 +295,24 @@ enum { static ImBuf *gSpecialFileImages[SPECIAL_IMG_MAX]; static void filelist_readjob_main(FileListReadJob *job_params, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress); static void filelist_readjob_lib(FileListReadJob *job_params, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress); static void filelist_readjob_dir(FileListReadJob *job_params, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress); static void filelist_readjob_asset_library(FileListReadJob *job_params, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress); static void filelist_readjob_main_assets(FileListReadJob *job_params, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress); /* helper, could probably go in BKE actually? */ @@ -3401,7 +3401,7 @@ struct FileListReadJob { static void filelist_readjob_append_entries(FileListReadJob *job_params, ListBase *from_entries, int from_entries_num, - short *do_update) + bool *do_update) { BLI_assert(BLI_listbase_count(from_entries) == from_entries_num); if (from_entries_num <= 0) { @@ -3456,8 +3456,8 @@ static bool filelist_readjob_should_recurse_into_entry(const int max_recursion, static void filelist_readjob_recursive_dir_add_items(const bool do_lib, FileListReadJob *job_params, - const short *stop, - short *do_update, + const bool *stop, + bool *do_update, float *progress) { FileList *filelist = job_params->tmp_filelist; /* Use the thread-safe filelist queue. */ @@ -3594,8 +3594,8 @@ static void filelist_readjob_recursive_dir_add_items(const bool do_lib, static void filelist_readjob_do(const bool do_lib, FileListReadJob *job_params, - const short *stop, - short *do_update, + const bool *stop, + bool *do_update, float *progress) { FileList *filelist = job_params->tmp_filelist; /* Use the thread-safe filelist queue. */ @@ -3611,16 +3611,16 @@ static void filelist_readjob_do(const bool do_lib, } static void filelist_readjob_dir(FileListReadJob *job_params, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { filelist_readjob_do(false, job_params, stop, do_update, progress); } static void filelist_readjob_lib(FileListReadJob *job_params, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { filelist_readjob_do(true, job_params, stop, do_update, progress); @@ -3643,7 +3643,7 @@ static void filelist_asset_library_path(const FileListReadJob *job_params, /** * Load asset library data, which currently means loading the asset catalogs for the library. */ -static void filelist_readjob_load_asset_library_data(FileListReadJob *job_params, short *do_update) +static void filelist_readjob_load_asset_library_data(FileListReadJob *job_params, bool *do_update) { FileList *tmp_filelist = job_params->tmp_filelist; /* Use the thread-safe filelist queue. */ @@ -3667,8 +3667,8 @@ static void filelist_readjob_load_asset_library_data(FileListReadJob *job_params } static void filelist_readjob_main_assets_add_items(FileListReadJob *job_params, - short * /*stop*/, - short *do_update, + bool * /*stop*/, + bool *do_update, float * /*progress*/) { FileList *filelist = job_params->tmp_filelist; /* Use the thread-safe filelist queue. */ @@ -3729,8 +3729,8 @@ static bool filelist_contains_main(const FileList *filelist, const Main *bmain) } static void filelist_readjob_asset_library(FileListReadJob *job_params, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { FileList *filelist = job_params->tmp_filelist; /* Use the thread-safe filelist queue. */ @@ -3753,8 +3753,8 @@ static void filelist_readjob_asset_library(FileListReadJob *job_params, } static void filelist_readjob_main(FileListReadJob *job_params, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { /* TODO! */ @@ -3762,8 +3762,8 @@ static void filelist_readjob_main(FileListReadJob *job_params, } static void filelist_readjob_main_assets(FileListReadJob *job_params, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { FileList *filelist = job_params->tmp_filelist; /* Use the thread-safe filelist queue. */ @@ -3791,7 +3791,7 @@ static bool filelist_readjob_is_partial_read(const FileListReadJob *read_job) * some current entries are kept and we just call the readjob to update the main files (see * #FileListReadJob.only_main_data). */ -static void filelist_readjob_startjob(void *flrjv, short *stop, short *do_update, float *progress) +static void filelist_readjob_startjob(void *flrjv, bool *stop, bool *do_update, float *progress) { FileListReadJob *flrj = static_cast<FileListReadJob *>(flrjv); @@ -3939,8 +3939,8 @@ void filelist_readjob_start(FileList *filelist, const int space_notifier, const const bool no_threads = (filelist->tags & FILELIST_TAGS_NO_THREADS) || flrj->only_main_data; if (no_threads) { - short dummy_stop = false; - short dummy_do_update = false; + bool dummy_stop = false; + bool dummy_do_update = false; float dummy_progress = 0.0f; /* Single threaded execution. Just directly call the callbacks. */ diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index cea53908d4f..959f8b01ec8 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -1147,8 +1147,8 @@ static void fsmenu_bookmark_validate_job_startjob( void *fsmenuv, /* Cannot be const, this function implements wm_jobs_start_callback. * NOLINTNEXTLINE: readability-non-const-parameter. */ - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *UNUSED(progress)) { FSMenu *fsmenu = fsmenuv; diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 48b3d711bdf..e6eba45d45e 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -89,8 +89,8 @@ struct CompoJob { Depsgraph *compositor_depsgraph; bNodeTree *localtree; /* Jon system integration. */ - const short *stop; - short *do_update; + const bool *stop; + bool *do_update; float *progress; }; @@ -166,7 +166,7 @@ static int compo_get_recalc_flags(const bContext *C) } /* called by compo, only to check job 'stop' value */ -static int compo_breakjob(void *cjv) +static bool compo_breakjob(void *cjv) { CompoJob *cj = (CompoJob *)cjv; @@ -250,8 +250,8 @@ static void compo_progressjob(void *cjv, float progress) static void compo_startjob(void *cjv, /* Cannot be const, this function implements wm_jobs_start_callback. * NOLINTNEXTLINE: readability-non-const-parameter. */ - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { CompoJob *cj = (CompoJob *)cjv; diff --git a/source/blender/editors/space_sequencer/sequencer_drag_drop.c b/source/blender/editors/space_sequencer/sequencer_drag_drop.c index c892e7d7e55..d43ce26d2a1 100644 --- a/source/blender/editors/space_sequencer/sequencer_drag_drop.c +++ b/source/blender/editors/space_sequencer/sequencer_drag_drop.c @@ -505,8 +505,8 @@ typedef struct DropJobData { } DropJobData; static void prefetch_data_fn(void *custom_data, - short *UNUSED(stop), - short *UNUSED(do_update), + bool *UNUSED(stop), + bool *UNUSED(do_update), float *UNUSED(progress)) { DropJobData *job_data = (DropJobData *)custom_data; diff --git a/source/blender/editors/space_sequencer/sequencer_preview.c b/source/blender/editors/space_sequencer/sequencer_preview.c index 2820edc95aa..2410055d76d 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview.c +++ b/source/blender/editors/space_sequencer/sequencer_preview.c @@ -51,7 +51,7 @@ static void free_preview_job(void *data) } /* Only this runs inside thread. */ -static void preview_startjob(void *data, short *stop, short *do_update, float *progress) +static void preview_startjob(void *data, bool *stop, bool *do_update, float *progress) { PreviewJob *pj = data; PreviewJobAudio *previewjb; diff --git a/source/blender/editors/space_sequencer/sequencer_proxy.c b/source/blender/editors/space_sequencer/sequencer_proxy.c index c851d3a29d4..30817771015 100644 --- a/source/blender/editors/space_sequencer/sequencer_proxy.c +++ b/source/blender/editors/space_sequencer/sequencer_proxy.c @@ -118,7 +118,7 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) if (seq->flag & SELECT) { ListBase queue = {NULL, NULL}; LinkData *link; - short stop = 0, do_update; + bool stop = false, do_update; float progress; SEQ_proxy_rebuild_context(bmain, depsgraph, scene, seq, file_list, &queue, false); @@ -126,7 +126,7 @@ static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) for (link = queue.first; link; link = link->next) { struct SeqIndexBuildContext *context = link->data; SEQ_proxy_rebuild(context, &stop, &do_update, &progress); - SEQ_proxy_rebuild_finish(context, 0); + SEQ_proxy_rebuild_finish(context, false); } SEQ_relations_free_imbuf(scene, &ed->seqbase, false); } diff --git a/source/blender/editors/space_sequencer/sequencer_thumbnails.c b/source/blender/editors/space_sequencer/sequencer_thumbnails.c index 460054f3b44..d1606b14152 100644 --- a/source/blender/editors/space_sequencer/sequencer_thumbnails.c +++ b/source/blender/editors/space_sequencer/sequencer_thumbnails.c @@ -132,8 +132,8 @@ static void seq_get_thumb_image_dimensions(Sequence *seq, } static void thumbnail_start_job(void *data, - short *stop, - short *UNUSED(do_update), + bool *stop, + bool *UNUSED(do_update), float *UNUSED(progress)) { ThumbnailDrawJob *tj = data; diff --git a/source/blender/editors/transform/transform_snap_object.cc b/source/blender/editors/transform/transform_snap_object.cc index 24d76a50117..54085295e9e 100644 --- a/source/blender/editors/transform/transform_snap_object.cc +++ b/source/blender/editors/transform/transform_snap_object.cc @@ -35,6 +35,7 @@ #include "BKE_layer.h" #include "BKE_mesh.h" #include "BKE_mesh_runtime.h" +#include "BKE_mesh_wrapper.h" #include "BKE_object.h" #include "BKE_tracking.h" @@ -61,41 +62,6 @@ enum eViewProj { VIEW_PROJ_PERSP = -1, }; -/* SnapObjectContext.cache.mesh_map */ -struct SnapData_Mesh { - /* Loose edges, loose verts. */ - BVHTree *bvhtree[2]; - bool cached[2]; - - /* Looptris. */ - BVHTreeFromMesh treedata_mesh; - - const MPoly *poly; - bool has_looptris; - bool has_loose_edge; - bool has_loose_vert; - - void clear() - { - for (int i = 0; i < ARRAY_SIZE(this->bvhtree); i++) { - if (!this->cached[i]) { - BLI_bvhtree_free(this->bvhtree[i]); - } - this->bvhtree[i] = nullptr; - } - free_bvhtree_from_mesh(&this->treedata_mesh); - } - - ~SnapData_Mesh() - { - this->clear(); - } - -#ifdef WITH_CXX_GUARDEDALLOC - MEM_CXX_CLASS_ALLOC_FUNCS("SnapData_Mesh") -#endif -}; - /* SnapObjectContext.cache.editmesh_map */ struct SnapData_EditMesh { /* Verts, Edges. */ @@ -134,7 +100,6 @@ struct SnapObjectContext { int flag; - Map<const Object *, std::unique_ptr<SnapData_Mesh>> mesh_caches; Map<const BMEditMesh *, std::unique_ptr<SnapData_EditMesh>> editmesh_caches; /* Filter data, returns true to check this value */ @@ -161,6 +126,28 @@ struct SnapObjectContext { eSnapMode snap_to_flag; bool has_occlusion_plane; /* Ignore plane of occlusion in curves. */ } runtime; + + /* Output. */ + struct { + /* Location of snapped point on target surface. */ + float loc[3]; + /* Normal of snapped point on target surface. */ + float no[3]; + /* Index of snapped element on target object (-1 when no valid index is found). */ + int index; + /* Matrix of target object (may not be #Object.object_to_world with dupli-instances). */ + float obmat[4][4]; + /* List of #SnapObjectHitDepth (caller must free). */ + ListBase *hit_list; + /* Snapped object. */ + Object *ob; + /* Snapped data. */ + ID *data; + + float dist_sq; + + bool is_edit; + } ret; }; /** \} */ @@ -176,37 +163,48 @@ struct SnapObjectContext { * - In rare cases there is no evaluated mesh available and a null result doesn't imply an * edit-mesh, so callers need to account for a null edit-mesh too, see: T96536. */ -static const Mesh *mesh_for_snap(Object *ob_eval, eSnapEditType edit_mode_type, bool *r_use_hide) +static ID *data_for_snap(Object *ob_eval, eSnapEditType edit_mode_type, bool *r_use_hide) { - const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval); bool use_hide = false; - if (BKE_object_is_in_editmode(ob_eval)) { - if (edit_mode_type == SNAP_GEOM_EDIT) { - return nullptr; - } - const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(ob_eval); - const Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob_eval); + switch (ob_eval->type) { + case OB_MESH: { + Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval); + if (BKE_object_is_in_editmode(ob_eval)) { + if (edit_mode_type == SNAP_GEOM_EDIT) { + return nullptr; + } + + Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(ob_eval); + Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob_eval); - if ((edit_mode_type == SNAP_GEOM_FINAL) && editmesh_eval_final) { - if (editmesh_eval_final->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) { - return nullptr; + if ((edit_mode_type == SNAP_GEOM_FINAL) && editmesh_eval_final) { + if (editmesh_eval_final->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) { + return nullptr; + } + me_eval = editmesh_eval_final; + use_hide = true; + } + else if ((edit_mode_type == SNAP_GEOM_CAGE) && editmesh_eval_cage) { + if (editmesh_eval_cage->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) { + return nullptr; + } + me_eval = editmesh_eval_cage; + use_hide = true; + } } - me_eval = editmesh_eval_final; - use_hide = true; - } - else if ((edit_mode_type == SNAP_GEOM_CAGE) && editmesh_eval_cage) { - if (editmesh_eval_cage->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH) { - return nullptr; + if (r_use_hide) { + *r_use_hide = use_hide; } - me_eval = editmesh_eval_cage; - use_hide = true; + return (ID *)me_eval; } + default: + break; } if (r_use_hide) { *r_use_hide = use_hide; } - return me_eval; + return (ID *)ob_eval->data; } /** \} */ @@ -236,96 +234,31 @@ static void snap_editmesh_minmax(SnapObjectContext *sctx, } } -static SnapData_Mesh *snap_object_data_mesh_get(SnapObjectContext *sctx, - Object *ob_eval, - const Mesh *me_eval, - bool use_hide) +static void snap_object_data_mesh_get(SnapObjectContext *sctx, + Object *ob_eval, + const Mesh *me_eval, + bool use_hide, + BVHTreeFromMesh *r_treedata) { - SnapData_Mesh *sod; - bool init = false; - const Span<MVert> verts = me_eval->verts(); const Span<MEdge> edges = me_eval->edges(); const Span<MPoly> polys = me_eval->polys(); const Span<MLoop> loops = me_eval->loops(); - if (std::unique_ptr<SnapData_Mesh> *sod_p = sctx->mesh_caches.lookup_ptr(ob_eval)) { - sod = sod_p->get(); - bool is_dirty = false; - if (sod->treedata_mesh.tree && sod->treedata_mesh.cached && - !bvhcache_has_tree(me_eval->runtime->bvh_cache, sod->treedata_mesh.tree)) { - /* The tree is owned by the Mesh and may have been freed since we last used. */ - is_dirty = true; - } - else if (sod->bvhtree[0] && sod->cached[0] && - !bvhcache_has_tree(me_eval->runtime->bvh_cache, sod->bvhtree[0])) { - /* The tree is owned by the Mesh and may have been freed since we last used. */ - is_dirty = true; - } - else if (sod->bvhtree[1] && sod->cached[1] && - !bvhcache_has_tree(me_eval->runtime->bvh_cache, sod->bvhtree[1])) { - /* The tree is owned by the Mesh and may have been freed since we last used. */ - is_dirty = true; - } - else if (sod->treedata_mesh.looptri != me_eval->looptris().data()) { - is_dirty = true; - } - else if (sod->treedata_mesh.vert != verts.data()) { - is_dirty = true; - } - else if (sod->treedata_mesh.loop != loops.data()) { - is_dirty = true; - } - else if (sod->treedata_mesh.edge != edges.data()) { - is_dirty = true; - } - else if (sod->poly != polys.data()) { - is_dirty = true; - } - - if (is_dirty) { - sod->clear(); - init = true; - } + if (ob_eval->type == OB_MESH) { + /* Any existing #SnapData_EditMesh is now invalid. */ + sctx->editmesh_caches.remove(BKE_editmesh_from_object(ob_eval)); } - else { - if (ob_eval->type == OB_MESH) { - /* Any existing #SnapData_EditMesh is now invalid. */ - sctx->editmesh_caches.remove(BKE_editmesh_from_object(ob_eval)); - } - std::unique_ptr<SnapData_Mesh> sod_ptr = std::make_unique<SnapData_Mesh>(); - sod = sod_ptr.get(); - sctx->mesh_caches.add_new(ob_eval, std::move(sod_ptr)); + /* The BVHTree from looptris is always required. */ + BKE_bvhtree_from_mesh_get( + r_treedata, me_eval, use_hide ? BVHTREE_FROM_LOOPTRI_NO_HIDDEN : BVHTREE_FROM_LOOPTRI, 4); - init = true; - } - - if (init) { - /* The BVHTree from looptris is always required. */ - BLI_assert(sod->treedata_mesh.tree == nullptr); - BKE_bvhtree_from_mesh_get(&sod->treedata_mesh, - me_eval, - use_hide ? BVHTREE_FROM_LOOPTRI_NO_HIDDEN : BVHTREE_FROM_LOOPTRI, - 4); - - BLI_assert(sod->treedata_mesh.vert == verts.data()); - BLI_assert(!verts.data() || sod->treedata_mesh.vert_normals); - BLI_assert(sod->treedata_mesh.loop == loops.data()); - BLI_assert(!polys.data() || sod->treedata_mesh.looptri); - - sod->has_looptris = sod->treedata_mesh.tree != nullptr; - - /* Required for snapping with occlusion. */ - sod->treedata_mesh.edge = edges.data(); - sod->poly = polys.data(); - - /* Start assuming that it has each of these element types. */ - sod->has_loose_edge = true; - sod->has_loose_vert = true; - } - - return sod; + BLI_assert(r_treedata->vert == verts.data()); + BLI_assert(!verts.data() || r_treedata->vert_normals); + BLI_assert(r_treedata->loop == loops.data()); + BLI_assert(!polys.data() || r_treedata->looptri); + BLI_assert(!r_treedata->tree || r_treedata->looptri); } /* Searches for the #Mesh_Runtime associated with the object that is most likely to be updated due @@ -352,9 +285,6 @@ static SnapData_EditMesh *snap_object_data_editmesh_get(SnapObjectContext *sctx, SnapData_EditMesh *sod; bool init = false; - /* Any existing #SnapData_Mesh is now invalid. */ - sctx->mesh_caches.remove(ob_eval); - if (std::unique_ptr<SnapData_EditMesh> *sod_p = sctx->editmesh_caches.lookup_ptr(em)) { sod = sod_p->get(); bool is_dirty = false; @@ -411,15 +341,6 @@ static SnapData_EditMesh *snap_object_data_editmesh_get(SnapObjectContext *sctx, return sod; } -static BVHTreeFromMesh *snap_object_data_mesh_treedata_get(SnapObjectContext *sctx, - Object *ob_eval, - const Mesh *me_eval, - bool use_hide) -{ - SnapData_Mesh *sod = snap_object_data_mesh_get(sctx, ob_eval, me_eval, use_hide); - return &sod->treedata_mesh; -} - static BVHTreeFromEditMesh *snap_object_data_editmesh_treedata_get(SnapObjectContext *sctx, Object *ob_eval, BMEditMesh *em) @@ -473,12 +394,14 @@ static BVHTreeFromEditMesh *snap_object_data_editmesh_treedata_get(SnapObjectCon /** \name Iterator * \{ */ -using IterSnapObjsCallback = void (*)(SnapObjectContext *sctx, - const SnapObjectParams *params, - Object *ob_eval, - const float obmat[4][4], - bool is_object_active, - void *data); +using IterSnapObjsCallback = eSnapMode (*)(SnapObjectContext *sctx, + const SnapObjectParams *params, + Object *ob_eval, + ID *ob_data, + const float obmat[4][4], + bool is_object_active, + bool use_hide, + void *data); static bool snap_object_is_snappable(const SnapObjectContext *sctx, const eSnapTargetSelect snap_target_select, @@ -538,11 +461,14 @@ static bool snap_object_is_snappable(const SnapObjectContext *sctx, /** * Walks through all objects in the scene to create the list of objects to snap. */ -static void iter_snap_objects(SnapObjectContext *sctx, - const SnapObjectParams *params, - IterSnapObjsCallback sob_callback, - void *data) +static eSnapMode iter_snap_objects(SnapObjectContext *sctx, + const SnapObjectParams *params, + IterSnapObjsCallback sob_callback, + void *data) { + eSnapMode ret = SCE_SNAP_MODE_NONE; + eSnapMode tmp; + Scene *scene = DEG_get_input_scene(sctx->runtime.depsgraph); ViewLayer *view_layer = DEG_get_input_view_layer(sctx->runtime.depsgraph); const eSnapTargetSelect snap_target_select = params->snap_target_select; @@ -560,13 +486,34 @@ static void iter_snap_objects(SnapObjectContext *sctx, ListBase *lb = object_duplilist(sctx->runtime.depsgraph, sctx->scene, obj_eval); LISTBASE_FOREACH (DupliObject *, dupli_ob, lb) { BLI_assert(DEG_is_evaluated_object(dupli_ob->ob)); - sob_callback(sctx, params, dupli_ob->ob, dupli_ob->mat, is_object_active, data); + if ((tmp = sob_callback(sctx, + params, + dupli_ob->ob, + dupli_ob->ob_data, + dupli_ob->mat, + is_object_active, + false, + data)) != SCE_SNAP_MODE_NONE) { + ret = tmp; + } } free_object_duplilist(lb); } - sob_callback(sctx, params, obj_eval, obj_eval->object_to_world, is_object_active, data); + bool use_hide = false; + ID *ob_data = data_for_snap(obj_eval, params->edit_mode_type, &use_hide); + if ((tmp = sob_callback(sctx, + params, + obj_eval, + ob_data, + obj_eval->object_to_world, + is_object_active, + use_hide, + data)) != SCE_SNAP_MODE_NONE) { + ret = tmp; + } } + return ret; } /** \} */ @@ -767,14 +714,17 @@ static bool raycastMesh(SnapObjectContext *sctx, } /* Test BoundBox */ - const BoundBox *bb = BKE_object_boundbox_get(ob_eval); - if (bb) { - /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */ - if (!isect_ray_aabb_v3_simple( - ray_start_local, ray_normal_local, bb->vec[0], bb->vec[6], &len_diff, nullptr)) { - return retval; + if (ob_eval->data == me_eval) { + const BoundBox *bb = BKE_object_boundbox_get(ob_eval); + if (bb) { + /* was BKE_boundbox_ray_hit_check, see: cf6ca226fa58 */ + if (!isect_ray_aabb_v3_simple( + ray_start_local, ray_normal_local, bb->vec[0], bb->vec[6], &len_diff, nullptr)) { + return retval; + } } } + /* We pass a temp ray_start, set from object's boundbox, to avoid precision issues with * very far away ray_start values (as returned in case of ortho view3d), see T50486, T38358. */ @@ -787,23 +737,22 @@ static bool raycastMesh(SnapObjectContext *sctx, len_diff = 0.0f; } - SnapData_Mesh *sod = snap_object_data_mesh_get(sctx, ob_eval, me_eval, use_hide); + BVHTreeFromMesh treedata; + snap_object_data_mesh_get(sctx, ob_eval, me_eval, use_hide, &treedata); - BVHTreeFromMesh *treedata = &sod->treedata_mesh; - - if (treedata->tree == nullptr) { + if (treedata.tree == nullptr) { return retval; } float timat[3][3]; /* transpose inverse matrix for normals */ transpose_m3_m4(timat, imat); - BLI_assert(treedata->raycast_callback != nullptr); + BLI_assert(treedata.raycast_callback != nullptr); if (r_hit_list) { RayCastAll_Data data; - data.bvhdata = treedata; - data.raycast_callback = treedata->raycast_callback; + data.bvhdata = &treedata; + data.raycast_callback = treedata.raycast_callback; data.obmat = obmat; data.timat = timat; data.len_diff = len_diff; @@ -813,13 +762,8 @@ static bool raycastMesh(SnapObjectContext *sctx, data.hit_list = r_hit_list; data.retval = retval; - BLI_bvhtree_ray_cast_all(treedata->tree, - ray_start_local, - ray_normal_local, - 0.0f, - *ray_depth, - raycast_all_cb, - &data); + BLI_bvhtree_ray_cast_all( + treedata.tree, ray_start_local, ray_normal_local, 0.0f, *ray_depth, raycast_all_cb, &data); retval = data.retval; } @@ -828,15 +772,15 @@ static bool raycastMesh(SnapObjectContext *sctx, hit.index = -1; hit.dist = local_depth; - if (BLI_bvhtree_ray_cast(treedata->tree, + if (BLI_bvhtree_ray_cast(treedata.tree, ray_start_local, ray_normal_local, 0.0f, &hit, params->use_backface_culling ? mesh_looptri_raycast_backface_culling_cb : - treedata->raycast_callback, - treedata) != -1) { + treedata.raycast_callback, + &treedata) != -1) { hit.dist += len_diff; hit.dist /= local_scale; if (hit.dist <= *ray_depth) { @@ -855,7 +799,7 @@ static bool raycastMesh(SnapObjectContext *sctx, retval = true; if (r_index) { - *r_index = treedata->looptri[hit.index].poly; + *r_index = treedata.looptri[hit.index].poly; } } } @@ -1007,26 +951,21 @@ struct RaycastObjUserData { uint ob_index; /* read/write args */ float *ray_depth; - /* return args */ - float *r_loc; - float *r_no; - int *r_index; - Object **r_ob; - float (*r_obmat)[4]; - ListBase *r_hit_list; + bool use_occlusion_test; - bool ret; }; /** * \note Duplicate args here are documented at #snapObjectsRay */ -static void raycast_obj_fn(SnapObjectContext *sctx, - const SnapObjectParams *params, - Object *ob_eval, - const float obmat[4][4], - bool is_object_active, - void *data) +static eSnapMode raycast_obj_fn(SnapObjectContext *sctx, + const SnapObjectParams *params, + Object *ob_eval, + ID *ob_data, + const float obmat[4][4], + bool is_object_active, + bool use_hide, + void *data) { RaycastObjUserData *dt = static_cast<RaycastObjUserData *>(data); const uint ob_index = dt->ob_index++; @@ -1035,92 +974,74 @@ static void raycast_obj_fn(SnapObjectContext *sctx, float *ray_depth = dt->ray_depth; bool retval = false; + bool is_edit = false; if (use_occlusion_test) { if (ELEM(ob_eval->dt, OB_BOUNDBOX, OB_WIRE)) { /* Do not hit objects that are in wire or bounding box * display mode. */ - return; + return SCE_SNAP_MODE_NONE; } } - switch (ob_eval->type) { - case OB_MESH: { - const eSnapEditType edit_mode_type = params->edit_mode_type; - bool use_hide = false; - const Mesh *me_eval = mesh_for_snap(ob_eval, edit_mode_type, &use_hide); - if (me_eval == nullptr) { - BMEditMesh *em = BKE_editmesh_from_object(ob_eval); - if (UNLIKELY(!em)) { /* See #mesh_for_snap doc-string. */ - return; - } - BLI_assert_msg(em == BKE_editmesh_from_object(DEG_get_original_object(ob_eval)), - "Make sure there is only one pointer for looptris"); - retval = raycastEditMesh(sctx, - params, - dt->ray_start, - dt->ray_dir, - ob_eval, - em, - obmat, - ob_index, - ray_depth, - dt->r_loc, - dt->r_no, - dt->r_index, - dt->r_hit_list); - break; + if (ob_data == nullptr) { + if (ob_eval->type == OB_MESH) { + BMEditMesh *em = BKE_editmesh_from_object(ob_eval); + if (UNLIKELY(!em)) { /* See #mesh_for_snap doc-string. */ + return SCE_SNAP_MODE_NONE; } - retval = raycastMesh(sctx, - params, - dt->ray_start, - dt->ray_dir, - ob_eval, - me_eval, - obmat, - ob_index, - use_hide, - ray_depth, - dt->r_loc, - dt->r_no, - dt->r_index, - dt->r_hit_list); - break; - } - case OB_CURVES_LEGACY: - case OB_SURF: - case OB_FONT: { - if (!is_object_active) { - const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob_eval); - if (mesh_eval) { - retval = raycastMesh(sctx, - params, - dt->ray_start, - dt->ray_dir, - ob_eval, - mesh_eval, - obmat, - ob_index, - false, - ray_depth, - dt->r_loc, - dt->r_no, - dt->r_index, - dt->r_hit_list); - } + if (raycastEditMesh(sctx, + params, + dt->ray_start, + dt->ray_dir, + ob_eval, + em, + obmat, + ob_index, + ray_depth, + sctx->ret.loc, + sctx->ret.no, + &sctx->ret.index, + sctx->ret.hit_list)) { + retval = true; + is_edit = true; } - break; } + else { + return SCE_SNAP_MODE_NONE; + } + } + else if (GS(ob_data->name) != ID_ME) { + return SCE_SNAP_MODE_NONE; + } + else if (is_object_active && ELEM(ob_eval->type, OB_CURVES_LEGACY, OB_SURF, OB_FONT)) { + return SCE_SNAP_MODE_NONE; + } + else { + const Mesh *me_eval = (const Mesh *)ob_data; + retval = raycastMesh(sctx, + params, + dt->ray_start, + dt->ray_dir, + ob_eval, + me_eval, + obmat, + ob_index, + use_hide, + ray_depth, + sctx->ret.loc, + sctx->ret.no, + &sctx->ret.index, + sctx->ret.hit_list); } if (retval) { - if (dt->r_ob) { - *dt->r_ob = ob_eval; - } - if (dt->r_obmat) { - copy_m4_m4(dt->r_obmat, obmat); - } - dt->ret = true; + copy_m4_m4(sctx->ret.obmat, obmat); + sctx->ret.ob = ob_eval; + sctx->ret.data = ob_data; + sctx->ret.is_edit = is_edit; + return SCE_SNAP_MODE_FACE_RAYCAST; } + return SCE_SNAP_MODE_NONE; } /** @@ -1136,17 +1057,6 @@ static void raycast_obj_fn(SnapObjectContext *sctx, * * \param ray_depth: maximum depth allowed for r_co, * elements deeper than this value will be ignored. - * - * Output Args - * ----------- - * - * \param r_loc: Hit location. - * \param r_no: Hit normal (optional). - * \param r_index: Hit index or -1 when no valid index is found. - * (currently only set to the polygon index when using `snap_to == SCE_SNAP_MODE_FACE_RAYCAST`). - * \param r_ob: Hit object. - * \param r_obmat: Object matrix (may not be #Object.object_to_world with dupli-instances). - * \param r_hit_list: List of #SnapObjectHitDepth (caller must free). */ static bool raycastObjects(SnapObjectContext *sctx, const SnapObjectParams *params, @@ -1155,14 +1065,7 @@ static bool raycastObjects(SnapObjectContext *sctx, /* read/write args */ /* Parameters below cannot be const, because they are assigned to a * non-const variable (readability-non-const-parameter). */ - float *ray_depth /* NOLINT */, - /* return args */ - float r_loc[3] /* NOLINT */, - float r_no[3] /* NOLINT */, - int *r_index /* NOLINT */, - Object **r_ob, - float r_obmat[4][4], - ListBase *r_hit_list) + float *ray_depth /* NOLINT */) { const View3D *v3d = sctx->runtime.v3d; if (params->use_occlusion_test && v3d && XRAY_FLAG_ENABLED(v3d)) { @@ -1178,18 +1081,9 @@ static bool raycastObjects(SnapObjectContext *sctx, data.ray_dir = ray_dir; data.ob_index = 0; data.ray_depth = ray_depth; - data.r_loc = r_loc; - data.r_no = r_no; - data.r_index = r_index; - data.r_ob = r_ob; - data.r_obmat = r_obmat; - data.r_hit_list = r_hit_list; data.use_occlusion_test = params->use_occlusion_test; - data.ret = false; - iter_snap_objects(sctx, params, raycast_obj_fn, &data); - - return data.ret; + return iter_snap_objects(sctx, params, raycast_obj_fn, &data) != SCE_SNAP_MODE_NONE; } /** \} */ @@ -1201,15 +1095,6 @@ static bool raycastObjects(SnapObjectContext *sctx, struct NearestWorldObjUserData { const float *init_co; const float *curr_co; - /* return args */ - float *r_loc; - float *r_no; - int *r_index; - float r_dist_sq; - Object **r_ob; - float (*r_obmat)[4]; - ListBase *r_hit_list; - bool ret; }; static void nearest_world_tree_co(BVHTree *tree, @@ -1298,14 +1183,13 @@ static bool nearest_world_tree(SnapObjectContext * /*sctx*/, float co_local[3]; float no_local[3]; - int index; copy_v3_v3(co_local, init_co_local); for (int i = 0; i < params->face_nearest_steps; i++) { add_v3_v3(co_local, delta_local); nearest_world_tree_co( - tree, nearest_cb, treedata, co_local, co_local, no_local, &index, nullptr); + tree, nearest_cb, treedata, co_local, co_local, no_local, r_index, nullptr); } mul_v3_m4v3(r_loc, obmat, co_local); @@ -1315,10 +1199,6 @@ static bool nearest_world_tree(SnapObjectContext * /*sctx*/, normalize_v3(r_no); } - if (r_index) { - *r_index = index; - } - return true; } @@ -1335,16 +1215,17 @@ static bool nearest_world_mesh(SnapObjectContext *sctx, float *r_no, int *r_index) { - BVHTreeFromMesh *treedata = snap_object_data_mesh_treedata_get(sctx, ob_eval, me_eval, use_hide); - if (treedata == nullptr || treedata->tree == nullptr) { + BVHTreeFromMesh treedata; + snap_object_data_mesh_get(sctx, ob_eval, me_eval, use_hide, &treedata); + if (treedata.tree == nullptr) { return false; } return nearest_world_tree(sctx, params, - treedata->tree, - treedata->nearest_callback, - treedata, + treedata.tree, + treedata.nearest_callback, + &treedata, obmat, init_co, curr_co, @@ -1384,85 +1265,75 @@ static bool nearest_world_editmesh(SnapObjectContext *sctx, r_no, r_index); } -static void nearest_world_object_fn(SnapObjectContext *sctx, - const struct SnapObjectParams *params, - Object *ob_eval, - const float obmat[4][4], - bool is_object_active, - void *data) +static eSnapMode nearest_world_object_fn(SnapObjectContext *sctx, + const SnapObjectParams *params, + Object *ob_eval, + ID *ob_data, + const float obmat[4][4], + bool is_object_active, + bool use_hide, + void *data) { struct NearestWorldObjUserData *dt = static_cast<NearestWorldObjUserData *>(data); bool retval = false; - switch (ob_eval->type) { - case OB_MESH: { - const eSnapEditType edit_mode_type = params->edit_mode_type; - bool use_hide = false; - const Mesh *me_eval = mesh_for_snap(ob_eval, edit_mode_type, &use_hide); - if (me_eval) { - retval = nearest_world_mesh(sctx, - params, - ob_eval, - me_eval, - obmat, - use_hide, - dt->init_co, - dt->curr_co, - &dt->r_dist_sq, - dt->r_loc, - dt->r_no, - dt->r_index); + bool is_edit = false; + + if (ob_data == nullptr) { + if (ob_eval->type == OB_MESH) { + BMEditMesh *em = BKE_editmesh_from_object(ob_eval); + if (UNLIKELY(!em)) { /* See #data_for_snap doc-string. */ + return SCE_SNAP_MODE_NONE; } - else { - BMEditMesh *em = BKE_editmesh_from_object(ob_eval); - BLI_assert_msg(em == BKE_editmesh_from_object(DEG_get_original_object(ob_eval)), - "Make sure there is only one pointer for looptris"); - retval = nearest_world_editmesh(sctx, - params, - ob_eval, - em, - obmat, - dt->init_co, - dt->curr_co, - &dt->r_dist_sq, - dt->r_loc, - dt->r_no, - dt->r_index); + if (nearest_world_editmesh(sctx, + params, + ob_eval, + em, + obmat, + dt->init_co, + dt->curr_co, + &sctx->ret.dist_sq, + sctx->ret.loc, + sctx->ret.no, + &sctx->ret.index)) { + retval = true; + is_edit = true; } - break; } - case OB_CURVES_LEGACY: - case OB_SURF: - case OB_FONT: - if (!is_object_active) { - const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval); - if (me_eval) { - retval = nearest_world_mesh(sctx, - params, - ob_eval, - me_eval, - obmat, - false, - dt->init_co, - dt->curr_co, - &dt->r_dist_sq, - dt->r_loc, - dt->r_no, - dt->r_index); - } - } - break; + else { + return SCE_SNAP_MODE_NONE; + } + } + else if (GS(ob_data) != ID_ME) { + return SCE_SNAP_MODE_NONE; + } + else if (is_object_active && ELEM(ob_eval->type, OB_CURVES_LEGACY, OB_SURF, OB_FONT)) { + return SCE_SNAP_MODE_NONE; + } + else { + const Mesh *me_eval = (const Mesh *)ob_data; + retval = nearest_world_mesh(sctx, + params, + ob_eval, + me_eval, + obmat, + use_hide, + dt->init_co, + dt->curr_co, + &sctx->ret.dist_sq, + sctx->ret.loc, + sctx->ret.no, + &sctx->ret.index); } if (retval) { - if (dt->r_ob) { - *dt->r_ob = ob_eval; - } - if (dt->r_obmat) { - copy_m4_m4(dt->r_obmat, obmat); - } - dt->ret = true; + copy_m4_m4(sctx->ret.obmat, obmat); + sctx->ret.ob = ob_eval; + sctx->ret.data = ob_data; + sctx->ret.is_edit = is_edit; + return SCE_SNAP_MODE_FACE_NEAREST; } + return SCE_SNAP_MODE_NONE; } /** @@ -1475,39 +1346,17 @@ static void nearest_world_object_fn(SnapObjectContext *sctx, * \param params: Settings for snapping. * \param init_co: Initial location of source point. * \param prev_co: Current location of source point after transformation but before snapping. - * - * Output Args - * ----------- - * - * \param r_loc: Location of nearest point on target surface. - * \param r_no: Normal of nearest point on target surface. - * \param r_index: Index of nearest polygon on target surface. - * \param r_ob: Nearest target object. - * \param r_obmat: Nearest target matrix (may not be #Object.object_to_world with dupli-instances). */ static bool nearestWorldObjects(SnapObjectContext *sctx, const struct SnapObjectParams *params, const float init_co[3], - const float curr_co[3], - float *r_loc /* NOLINT */, - float *r_no /* NOLINT */, - int *r_index /* NOLINT */, - Object **r_ob, - float r_obmat[4][4]) + const float curr_co[3]) { NearestWorldObjUserData data = {}; data.init_co = init_co; data.curr_co = curr_co; - data.r_loc = r_loc; - data.r_no = r_no; - data.r_index = r_index; - data.r_dist_sq = FLT_MAX; - data.r_ob = r_ob; - data.r_obmat = r_obmat; - data.ret = false; - - iter_snap_objects(sctx, params, nearest_world_object_fn, &data); - return data.ret; + + return iter_snap_objects(sctx, params, nearest_world_object_fn, &data) != SCE_SNAP_MODE_NONE; } /** \} */ @@ -1854,7 +1703,7 @@ static void cb_snap_tri_verts(void *userdata, } } -static void nearest2d_data_init_mesh(SnapData_Mesh *sod, +static void nearest2d_data_init_mesh(const Mesh *mesh, bool is_persp, bool use_backface_culling, Nearest2dUserData *r_nearest2d) @@ -1865,11 +1714,11 @@ static void nearest2d_data_init_mesh(SnapData_Mesh *sod, r_nearest2d->get_tri_verts_index = cb_mlooptri_verts_get; r_nearest2d->get_tri_edges_index = cb_mlooptri_edges_get; - r_nearest2d->vert = sod->treedata_mesh.vert; - r_nearest2d->vert_normals = sod->treedata_mesh.vert_normals; - r_nearest2d->edge = sod->treedata_mesh.edge; - r_nearest2d->loop = sod->treedata_mesh.loop; - r_nearest2d->looptri = sod->treedata_mesh.looptri; + r_nearest2d->vert = mesh->verts().data(); + r_nearest2d->vert_normals = BKE_mesh_vertex_normals_ensure(mesh); + r_nearest2d->edge = mesh->edges().data(); + r_nearest2d->loop = mesh->loops().data(); + r_nearest2d->looptri = BKE_mesh_runtime_looptri_ensure(mesh); r_nearest2d->is_persp = is_persp; r_nearest2d->use_backface_culling = use_backface_culling; @@ -1900,26 +1749,20 @@ static void nearest2d_data_init_editmesh(SnapData_EditMesh *sod, static eSnapMode snap_mesh_polygon(SnapObjectContext *sctx, const SnapObjectParams *params, - Object *ob_eval, - const float obmat[4][4], /* read/write args */ - float *dist_px, - /* return args */ - float r_loc[3], - float r_no[3], - int *r_index) + float *dist_px) { eSnapMode elem = SCE_SNAP_MODE_NONE; float lpmat[4][4]; - mul_m4_m4m4(lpmat, sctx->runtime.pmat, obmat); + mul_m4_m4m4(lpmat, sctx->runtime.pmat, sctx->ret.obmat); DistProjectedAABBPrecalc neasrest_precalc; dist_squared_to_projected_aabb_precalc( &neasrest_precalc, lpmat, sctx->runtime.win_size, sctx->runtime.mval); float tobmat[4][4], clip_planes_local[MAX_CLIPPLANE_LEN][4]; - transpose_m4_m4(tobmat, obmat); + transpose_m4_m4(tobmat, sctx->ret.obmat); for (int i = sctx->runtime.clip_plane_len; i--;) { mul_v4_m4v4(clip_planes_local[i], tobmat, sctx->runtime.clip_plane[i]); } @@ -1929,23 +1772,23 @@ static eSnapMode snap_mesh_polygon(SnapObjectContext *sctx, nearest.dist_sq = square_f(*dist_px); Nearest2dUserData nearest2d; - std::unique_ptr<SnapData_Mesh> *sod_mesh = sctx->mesh_caches.lookup_ptr(ob_eval); - if (sod_mesh) { - nearest2d_data_init_mesh(sod_mesh->get(), + const Mesh *mesh = sctx->ret.data && GS(sctx->ret.data->name) == ID_ME ? + (const Mesh *)sctx->ret.data : + nullptr; + if (mesh) { + nearest2d_data_init_mesh(mesh, sctx->runtime.view_proj == VIEW_PROJ_PERSP, params->use_backface_culling, &nearest2d); - BVHTreeFromMesh *treedata = &sod_mesh->get()->treedata_mesh; - - const MPoly *mp = &sod_mesh->get()->poly[*r_index]; - const MLoop *ml = &treedata->loop[mp->loopstart]; + const MPoly *mp = &mesh->polys()[sctx->ret.index]; + const MLoop *ml = &nearest2d.loop[mp->loopstart]; if (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_EDGE) { elem = SCE_SNAP_MODE_EDGE; - BLI_assert(treedata->edge != nullptr); + BLI_assert(nearest2d.edge != nullptr); for (int i = mp->totloop; i--; ml++) { cb_snap_edge(&nearest2d, - ml->e, + (int)ml->e, &neasrest_precalc, clip_planes_local, sctx->runtime.clip_plane_len, @@ -1956,7 +1799,7 @@ static eSnapMode snap_mesh_polygon(SnapObjectContext *sctx, elem = SCE_SNAP_MODE_VERTEX; for (int i = mp->totloop; i--; ml++) { cb_snap_vert(&nearest2d, - ml->v, + (int)ml->v, &neasrest_precalc, clip_planes_local, sctx->runtime.clip_plane_len, @@ -1964,10 +1807,10 @@ static eSnapMode snap_mesh_polygon(SnapObjectContext *sctx, } } } - else { + else if (sctx->ret.is_edit) { /* The object's #BMEditMesh was used to snap instead. */ std::unique_ptr<SnapData_EditMesh> &sod_editmesh = sctx->editmesh_caches.lookup( - BKE_editmesh_from_object(ob_eval)); + BKE_editmesh_from_object(sctx->ret.ob)); BLI_assert(sod_editmesh.get() != nullptr); nearest2d_data_init_editmesh(sod_editmesh.get(), @@ -1978,7 +1821,7 @@ static eSnapMode snap_mesh_polygon(SnapObjectContext *sctx, BMEditMesh *em = sod_editmesh->treedata_editmesh.em; BM_mesh_elem_table_ensure(em->bm, BM_FACE); - BMFace *f = BM_face_at_index(em->bm, *r_index); + BMFace *f = BM_face_at_index(em->bm, sctx->ret.index); BMLoop *l_iter, *l_first; l_iter = l_first = BM_FACE_FIRST_LOOP(f); if (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_EDGE) { @@ -2012,19 +1855,19 @@ static eSnapMode snap_mesh_polygon(SnapObjectContext *sctx, if (nearest.index != -1) { *dist_px = sqrtf(nearest.dist_sq); - copy_v3_v3(r_loc, nearest.co); - mul_m4_v3(obmat, r_loc); + copy_v3_v3(sctx->ret.loc, nearest.co); + mul_m4_v3(sctx->ret.obmat, sctx->ret.loc); - if (r_no) { + { float imat[4][4]; - invert_m4_m4(imat, obmat); + invert_m4_m4(imat, sctx->ret.obmat); - copy_v3_v3(r_no, nearest.no); - mul_transposed_mat3_m4_v3(imat, r_no); - normalize_v3(r_no); + copy_v3_v3(sctx->ret.no, nearest.no); + mul_transposed_mat3_m4_v3(imat, sctx->ret.no); + normalize_v3(sctx->ret.no); } - *r_index = nearest.index; + sctx->ret.index = nearest.index; return elem; } @@ -2033,45 +1876,44 @@ static eSnapMode snap_mesh_polygon(SnapObjectContext *sctx, static eSnapMode snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, const SnapObjectParams *params, - Object *ob_eval, - const float obmat[4][4], float original_dist_px, const float prev_co[3], /* read/write args */ - float *dist_px, - /* return args */ - float r_loc[3], - float r_no[3], - int *r_index) + float *dist_px) { eSnapMode elem = SCE_SNAP_MODE_EDGE; - if (ob_eval->type != OB_MESH) { + if (sctx->ret.ob->type != OB_MESH) { return elem; } Nearest2dUserData nearest2d; { - std::unique_ptr<SnapData_Mesh> *sod_mesh = sctx->mesh_caches.lookup_ptr(ob_eval); - if (sod_mesh) { - nearest2d_data_init_mesh(sod_mesh->get(), + const Mesh *mesh = sctx->ret.data && GS(sctx->ret.data->name) == ID_ME ? + (const Mesh *)sctx->ret.data : + nullptr; + if (mesh) { + nearest2d_data_init_mesh(mesh, sctx->runtime.view_proj == VIEW_PROJ_PERSP, params->use_backface_culling, &nearest2d); } - else { + else if (sctx->ret.is_edit) { /* The object's #BMEditMesh was used to snap instead. */ std::unique_ptr<SnapData_EditMesh> &sod_editmesh = sctx->editmesh_caches.lookup( - BKE_editmesh_from_object(ob_eval)); + BKE_editmesh_from_object(sctx->ret.ob)); nearest2d_data_init_editmesh(sod_editmesh.get(), sctx->runtime.view_proj == VIEW_PROJ_PERSP, params->use_backface_culling, &nearest2d); } + else { + return elem; + } } int vindex[2]; - nearest2d.get_edge_verts_index(*r_index, &nearest2d, vindex); + nearest2d.get_edge_verts_index(sctx->ret.index, &nearest2d, vindex); const float *v_pair[2]; nearest2d.get_vert_co(vindex[0], &nearest2d, &v_pair[0]); @@ -2080,7 +1922,7 @@ static eSnapMode snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, DistProjectedAABBPrecalc neasrest_precalc; { float lpmat[4][4]; - mul_m4_m4m4(lpmat, sctx->runtime.pmat, obmat); + mul_m4_m4m4(lpmat, sctx->runtime.pmat, sctx->ret.obmat); dist_squared_to_projected_aabb_precalc( &neasrest_precalc, lpmat, sctx->runtime.win_size, sctx->runtime.mval); @@ -2118,12 +1960,12 @@ static eSnapMode snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, nearest.co)) { nearest.index = vindex[v_id]; elem = SCE_SNAP_MODE_VERTEX; - if (r_no) { + { float imat[4][4]; - invert_m4_m4(imat, obmat); - nearest2d.copy_vert_no(vindex[v_id], &nearest2d, r_no); - mul_transposed_mat3_m4_v3(imat, r_no); - normalize_v3(r_no); + invert_m4_m4(imat, sctx->ret.obmat); + nearest2d.copy_vert_no(vindex[v_id], &nearest2d, sctx->ret.no); + mul_transposed_mat3_m4_v3(imat, sctx->ret.no); + normalize_v3(sctx->ret.no); } } } @@ -2142,7 +1984,7 @@ static eSnapMode snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, vmid, &nearest.dist_sq, nearest.co)) { - nearest.index = *r_index; + nearest.index = sctx->ret.index; elem = SCE_SNAP_MODE_EDGE_MIDPOINT; } } @@ -2151,8 +1993,8 @@ static eSnapMode snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, if (prev_co && (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_EDGE_PERPENDICULAR)) { float v_near[3], va_g[3], vb_g[3]; - mul_v3_m4v3(va_g, obmat, v_pair[0]); - mul_v3_m4v3(vb_g, obmat, v_pair[1]); + mul_v3_m4v3(va_g, sctx->ret.obmat, v_pair[0]); + mul_v3_m4v3(vb_g, sctx->ret.obmat, v_pair[1]); lambda = line_point_factor_v3(prev_co, va_g, vb_g); if (IN_RANGE(lambda, 0.0f, 1.0f)) { @@ -2169,7 +2011,7 @@ static eSnapMode snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, v_near, &nearest.dist_sq, nearest.co)) { - nearest.index = *r_index; + nearest.index = sctx->ret.index; elem = SCE_SNAP_MODE_EDGE_PERPENDICULAR; } } @@ -2180,12 +2022,12 @@ static eSnapMode snap_mesh_edge_verts_mixed(SnapObjectContext *sctx, if (nearest.index != -1) { *dist_px = sqrtf(nearest.dist_sq); - copy_v3_v3(r_loc, nearest.co); + copy_v3_v3(sctx->ret.loc, nearest.co); if (elem != SCE_SNAP_MODE_EDGE_PERPENDICULAR) { - mul_m4_v3(obmat, r_loc); + mul_m4_v3(sctx->ret.obmat, sctx->ret.loc); } - *r_index = nearest.index; + sctx->ret.index = nearest.index; } return elem; @@ -2706,45 +2548,34 @@ static eSnapMode snapMesh(SnapObjectContext *sctx, float dist_px_sq = square_f(*dist_px); /* Test BoundBox */ - const BoundBox *bb = BKE_object_boundbox_get(ob_eval); - if (bb && - !snap_bound_box_check_dist( - bb->vec[0], bb->vec[6], lpmat, sctx->runtime.win_size, sctx->runtime.mval, dist_px_sq)) { - return SCE_SNAP_MODE_NONE; - } - - SnapData_Mesh *sod = snap_object_data_mesh_get(sctx, ob_eval, me_eval, use_hide); - - BVHTreeFromMesh *treedata, treedata_tmp; - treedata = &sod->treedata_mesh; - - if (sod->has_loose_edge && sod->bvhtree[0] == nullptr) { - sod->bvhtree[0] = BKE_bvhtree_from_mesh_get( - &treedata_tmp, me_eval, BVHTREE_FROM_LOOSEEDGES, 2); - if (sod->bvhtree[0] == nullptr) { - sod->has_loose_edge = false; + if (ob_eval->data == me_eval) { + const BoundBox *bb = BKE_object_boundbox_get(ob_eval); + if (!snap_bound_box_check_dist(bb->vec[0], + bb->vec[6], + lpmat, + sctx->runtime.win_size, + sctx->runtime.mval, + dist_px_sq)) { + return SCE_SNAP_MODE_NONE; } - sod->cached[0] = treedata_tmp.cached; } + BVHTreeFromMesh treedata, treedata_dummy; + snap_object_data_mesh_get(sctx, ob_eval, me_eval, use_hide, &treedata); + + BVHTree *bvhtree[2] = {nullptr}; + bvhtree[0] = BKE_bvhtree_from_mesh_get(&treedata_dummy, me_eval, BVHTREE_FROM_LOOSEEDGES, 2); + BLI_assert(treedata_dummy.cached); if (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_VERTEX) { - if (sod->has_loose_vert && sod->bvhtree[1] == nullptr) { - sod->bvhtree[1] = BKE_bvhtree_from_mesh_get( - &treedata_tmp, me_eval, BVHTREE_FROM_LOOSEVERTS, 2); - if (sod->bvhtree[1] == nullptr) { - sod->has_loose_vert = false; - } - sod->cached[1] = treedata_tmp.cached; - } - } - else { - /* Not necessary, just to keep the data more consistent. */ - sod->has_loose_vert = false; + bvhtree[1] = BKE_bvhtree_from_mesh_get(&treedata_dummy, me_eval, BVHTREE_FROM_LOOSEVERTS, 2); + BLI_assert(treedata_dummy.cached); } Nearest2dUserData nearest2d; - nearest2d_data_init_mesh( - sod, sctx->runtime.view_proj == VIEW_PROJ_PERSP, params->use_backface_culling, &nearest2d); + nearest2d_data_init_mesh(me_eval, + sctx->runtime.view_proj == VIEW_PROJ_PERSP, + params->use_backface_culling, + &nearest2d); BVHTreeNearest nearest{}; nearest.index = -1; @@ -2759,9 +2590,10 @@ static eSnapMode snapMesh(SnapObjectContext *sctx, mul_v4_m4v4(clip_planes_local[i], tobmat, sctx->runtime.clip_plane[i]); } - if (sod->bvhtree[1] && (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_VERTEX)) { + if (bvhtree[1]) { + BLI_assert(sctx->runtime.snap_to_flag & SCE_SNAP_MODE_VERTEX); /* snap to loose verts */ - BLI_bvhtree_find_nearest_projected(sod->bvhtree[1], + BLI_bvhtree_find_nearest_projected(bvhtree[1], lpmat, sctx->runtime.win_size, sctx->runtime.mval, @@ -2775,9 +2607,9 @@ static eSnapMode snapMesh(SnapObjectContext *sctx, } if (sctx->runtime.snap_to_flag & SCE_SNAP_MODE_EDGE) { - if (sod->bvhtree[0]) { + if (bvhtree[0]) { /* snap to loose edges */ - BLI_bvhtree_find_nearest_projected(sod->bvhtree[0], + BLI_bvhtree_find_nearest_projected(bvhtree[0], lpmat, sctx->runtime.win_size, sctx->runtime.mval, @@ -2788,9 +2620,9 @@ static eSnapMode snapMesh(SnapObjectContext *sctx, &nearest2d); } - if (treedata->tree) { + if (treedata.tree) { /* snap to looptris */ - BLI_bvhtree_find_nearest_projected(treedata->tree, + BLI_bvhtree_find_nearest_projected(treedata.tree, lpmat, sctx->runtime.win_size, sctx->runtime.mval, @@ -2807,9 +2639,9 @@ static eSnapMode snapMesh(SnapObjectContext *sctx, } else { BLI_assert(sctx->runtime.snap_to_flag & SCE_SNAP_MODE_VERTEX); - if (sod->bvhtree[0]) { + if (bvhtree[0]) { /* snap to loose edge verts */ - BLI_bvhtree_find_nearest_projected(sod->bvhtree[0], + BLI_bvhtree_find_nearest_projected(bvhtree[0], lpmat, sctx->runtime.win_size, sctx->runtime.mval, @@ -2820,9 +2652,9 @@ static eSnapMode snapMesh(SnapObjectContext *sctx, &nearest2d); } - if (treedata->tree) { + if (treedata.tree) { /* snap to looptri verts */ - BLI_bvhtree_find_nearest_projected(treedata->tree, + BLI_bvhtree_find_nearest_projected(treedata.tree, lpmat, sctx->runtime.win_size, sctx->runtime.mval, @@ -3042,118 +2874,130 @@ static eSnapMode snapEditMesh(SnapObjectContext *sctx, struct SnapObjUserData { /* read/write args */ float *dist_px; - /* return args */ - float *r_loc; - float *r_no; - int *r_index; - Object **r_ob; - float (*r_obmat)[4]; - eSnapMode ret; }; /** * \note Duplicate args here are documented at #snapObjectsRay */ -static void snap_obj_fn(SnapObjectContext *sctx, - const SnapObjectParams *params, - Object *ob_eval, - const float obmat[4][4], - bool is_object_active, - void *data) +static eSnapMode snap_obj_fn(SnapObjectContext *sctx, + const SnapObjectParams *params, + Object *ob_eval, + ID *ob_data, + const float obmat[4][4], + bool is_object_active, + bool use_hide, + void *data) { SnapObjUserData *dt = static_cast<SnapObjUserData *>(data); eSnapMode retval = SCE_SNAP_MODE_NONE; + bool is_edit = false; - switch (ob_eval->type) { - case OB_MESH: { - const eSnapEditType edit_mode_type = params->edit_mode_type; - bool use_hide; - const Mesh *me_eval = mesh_for_snap(ob_eval, edit_mode_type, &use_hide); - if (me_eval == nullptr) { - BMEditMesh *em = BKE_editmesh_from_object(ob_eval); - if (UNLIKELY(!em)) { /* See #mesh_for_snap doc-string. */ - return; - } - BLI_assert_msg(em == BKE_editmesh_from_object(DEG_get_original_object(ob_eval)), - "Make sure there is only one pointer for looptris"); - retval = snapEditMesh( - sctx, params, ob_eval, em, obmat, dt->dist_px, dt->r_loc, dt->r_no, dt->r_index); - break; - } - if (ob_eval->dt == OB_BOUNDBOX) { - /* Do not snap to objects that are in bounding box display mode */ - return; - } - - retval = snapMesh(sctx, - params, - ob_eval, - me_eval, - obmat, - use_hide, - dt->dist_px, - dt->r_loc, - dt->r_no, - dt->r_index); - break; + if (ob_data == nullptr && (ob_eval->type == OB_MESH)) { + BMEditMesh *em = BKE_editmesh_from_object(ob_eval); + if (UNLIKELY(!em)) { /* See #data_for_snap doc-string. */ + return SCE_SNAP_MODE_NONE; } - case OB_ARMATURE: - retval = snapArmature(sctx, + retval = snapEditMesh(sctx, + params, + ob_eval, + em, + obmat, + dt->dist_px, + sctx->ret.loc, + sctx->ret.no, + &sctx->ret.index); + if (retval) { + is_edit = true; + } + } + else if (ob_data == nullptr) { + retval = snap_object_center( + sctx, ob_eval, obmat, dt->dist_px, sctx->ret.loc, sctx->ret.no, &sctx->ret.index); + } + else { + switch (ob_eval->type) { + case OB_MESH: { + if (ob_eval->dt == OB_BOUNDBOX) { + /* Do not snap to objects that are in bounding box display mode */ + return SCE_SNAP_MODE_NONE; + } + if (GS(ob_data->name) == ID_ME) { + retval = snapMesh(sctx, params, ob_eval, + (const Mesh *)ob_data, obmat, - is_object_active, + use_hide, dt->dist_px, - dt->r_loc, - dt->r_no, - dt->r_index); - break; - case OB_CURVES_LEGACY: - case OB_SURF: - if (ob_eval->type == OB_CURVES_LEGACY || BKE_object_is_in_editmode(ob_eval)) { - retval = snapCurve( - sctx, params, ob_eval, obmat, dt->dist_px, dt->r_loc, dt->r_no, dt->r_index); - if (params->edit_mode_type != SNAP_GEOM_FINAL) { - break; + sctx->ret.loc, + sctx->ret.no, + &sctx->ret.index); } + break; } - ATTR_FALLTHROUGH; - case OB_FONT: { - const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob_eval); - if (mesh_eval) { - retval |= snapMesh(sctx, - params, - ob_eval, - mesh_eval, - obmat, - false, - dt->dist_px, - dt->r_loc, - dt->r_no, - dt->r_index); + case OB_ARMATURE: + retval = snapArmature(sctx, + params, + ob_eval, + obmat, + is_object_active, + dt->dist_px, + sctx->ret.loc, + sctx->ret.no, + &sctx->ret.index); + break; + case OB_CURVES_LEGACY: + case OB_SURF: + if (ob_eval->type == OB_CURVES_LEGACY || BKE_object_is_in_editmode(ob_eval)) { + retval = snapCurve(sctx, + params, + ob_eval, + obmat, + dt->dist_px, + sctx->ret.loc, + sctx->ret.no, + &sctx->ret.index); + if (params->edit_mode_type != SNAP_GEOM_FINAL) { + break; + } + } + ATTR_FALLTHROUGH; + case OB_FONT: { + const Mesh *mesh_eval = BKE_object_get_evaluated_mesh(ob_eval); + if (mesh_eval) { + retval |= snapMesh(sctx, + params, + ob_eval, + mesh_eval, + obmat, + false, + dt->dist_px, + sctx->ret.loc, + sctx->ret.no, + &sctx->ret.index); + } + break; } - break; + case OB_EMPTY: + case OB_GPENCIL: + case OB_LAMP: + retval = snap_object_center( + sctx, ob_eval, obmat, dt->dist_px, sctx->ret.loc, sctx->ret.no, &sctx->ret.index); + break; + case OB_CAMERA: + retval = snapCamera( + sctx, ob_eval, obmat, dt->dist_px, sctx->ret.loc, sctx->ret.no, &sctx->ret.index); + break; } - case OB_EMPTY: - case OB_GPENCIL: - case OB_LAMP: - retval = snap_object_center( - sctx, ob_eval, obmat, dt->dist_px, dt->r_loc, dt->r_no, dt->r_index); - break; - case OB_CAMERA: - retval = snapCamera(sctx, ob_eval, obmat, dt->dist_px, dt->r_loc, dt->r_no, dt->r_index); - break; } if (retval) { - if (dt->r_ob) { - *dt->r_ob = ob_eval; - } - if (dt->r_obmat) { - copy_m4_m4(dt->r_obmat, obmat); - } - dt->ret = retval; + copy_m4_m4(sctx->ret.obmat, obmat); + sctx->ret.ob = ob_eval; + sctx->ret.data = ob_data; + sctx->ret.is_edit = is_edit; } + return retval; } /** @@ -3168,42 +3012,18 @@ static void snap_obj_fn(SnapObjectContext *sctx, * --------------- * * \param dist_px: Maximum threshold distance (in pixels). - * - * Output Args - * ----------- - * - * \param r_loc: Hit location. - * \param r_no: Hit normal (optional). - * \param r_index: Hit index or -1 when no valid index is found. - * (currently only set to the polygon index when using `snap_to == SCE_SNAP_MODE_FACE_RAYCAST`). - * \param r_ob: Hit object. - * \param r_obmat: Object matrix (may not be #Object.object_to_world with dupli-instances). */ static eSnapMode snapObjectsRay(SnapObjectContext *sctx, const SnapObjectParams *params, /* read/write args */ /* Parameters below cannot be const, because they are assigned to a * non-const variable (readability-non-const-parameter). */ - float *dist_px /* NOLINT */, - /* return args */ - float r_loc[3] /* NOLINT */, - float r_no[3] /* NOLINT */, - int *r_index /* NOLINT */, - Object **r_ob, - float r_obmat[4][4]) + float *dist_px /* NOLINT */) { SnapObjUserData data = {}; data.dist_px = dist_px; - data.r_loc = r_loc; - data.r_no = r_no; - data.r_ob = r_ob; - data.r_index = r_index; - data.r_obmat = r_obmat; - data.ret = SCE_SNAP_MODE_NONE; - - iter_snap_objects(sctx, params, snap_obj_fn, &data); - return data.ret; + return iter_snap_objects(sctx, params, snap_obj_fn, &data); } /** \} */ @@ -3258,17 +3078,33 @@ bool ED_transform_snap_object_project_ray_ex(SnapObjectContext *sctx, sctx->runtime.depsgraph = depsgraph; sctx->runtime.v3d = v3d; - return raycastObjects(sctx, - params, - ray_start, - ray_normal, - ray_depth, - r_loc, - r_no, - r_index, - r_ob, - r_obmat, - nullptr); + zero_v3(sctx->ret.loc); + zero_v3(sctx->ret.no); + sctx->ret.index = -1; + zero_m4(sctx->ret.obmat); + sctx->ret.hit_list = nullptr; + sctx->ret.ob = nullptr; + sctx->ret.data = nullptr; + sctx->ret.dist_sq = FLT_MAX; + sctx->ret.is_edit = false; + + if (raycastObjects(sctx, params, ray_start, ray_normal, ray_depth)) { + copy_v3_v3(r_loc, sctx->ret.loc); + if (r_no) { + copy_v3_v3(r_no, sctx->ret.no); + } + if (r_index) { + *r_index = sctx->ret.index; + } + if (r_ob) { + *r_ob = sctx->ret.ob; + } + if (r_obmat) { + copy_m4_m4(r_obmat, sctx->ret.obmat); + } + return true; + } + return false; } bool ED_transform_snap_object_project_ray_all(SnapObjectContext *sctx, @@ -3292,17 +3128,7 @@ bool ED_transform_snap_object_project_ray_all(SnapObjectContext *sctx, float ray_depth_prev = ray_depth; #endif - bool retval = raycastObjects(sctx, - params, - ray_start, - ray_normal, - &ray_depth, - nullptr, - nullptr, - nullptr, - nullptr, - nullptr, - r_hit_list); + bool retval = raycastObjects(sctx, params, ray_start, ray_normal, &ray_depth); /* meant to be readonly for 'all' hits, ensure it is */ #ifdef DEBUG @@ -3393,18 +3219,21 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont sctx->runtime.region = region; sctx->runtime.v3d = v3d; + zero_v3(sctx->ret.loc); + zero_v3(sctx->ret.no); + sctx->ret.index = -1; + zero_m4(sctx->ret.obmat); + sctx->ret.hit_list = nullptr; + sctx->ret.ob = nullptr; + sctx->ret.data = nullptr; + sctx->ret.dist_sq = FLT_MAX; + sctx->ret.is_edit = false; + BLI_assert((snap_to_flag & SCE_SNAP_MODE_GEOM) != 0); eSnapMode retval = SCE_SNAP_MODE_NONE; bool has_hit = false; - Object *ob_eval = nullptr; - float loc[3]; - /* Not all snapping callbacks set the normal, - * initialize this since any hit copies both the `loc` and `no`. */ - float no[3] = {0.0f, 0.0f, 0.0f}; - float obmat[4][4]; - int index = -1; const RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata); @@ -3413,24 +3242,23 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont /* NOTE: if both face ray-cast and face nearest are enabled, first find result of nearest, then * override with ray-cast. */ if ((snap_to_flag & SCE_SNAP_MODE_FACE_NEAREST) && !has_hit) { - has_hit = nearestWorldObjects( - sctx, params, init_co, prev_co, loc, no, &index, &ob_eval, obmat); + has_hit = nearestWorldObjects(sctx, params, init_co, prev_co); if (has_hit) { retval = SCE_SNAP_MODE_FACE_NEAREST; - copy_v3_v3(r_loc, loc); + copy_v3_v3(r_loc, sctx->ret.loc); if (r_no) { - copy_v3_v3(r_no, no); + copy_v3_v3(r_no, sctx->ret.no); } if (r_ob) { - *r_ob = ob_eval; + *r_ob = sctx->ret.ob; } if (r_obmat) { - copy_m4_m4(r_obmat, obmat); + copy_m4_m4(r_obmat, sctx->ret.obmat); } if (r_index) { - *r_index = index; + *r_index = sctx->ret.index; } } } @@ -3444,38 +3272,28 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont float dummy_ray_depth = BVH_RAYCAST_DIST_MAX; - has_hit = raycastObjects(sctx, - params, - ray_start, - ray_normal, - &dummy_ray_depth, - loc, - no, - &index, - &ob_eval, - obmat, - nullptr); + has_hit = raycastObjects(sctx, params, ray_start, ray_normal, &dummy_ray_depth); if (has_hit) { if (r_face_nor) { - copy_v3_v3(r_face_nor, no); + copy_v3_v3(r_face_nor, sctx->ret.no); } if (snap_to_flag & SCE_SNAP_MODE_FACE_RAYCAST) { retval = SCE_SNAP_MODE_FACE_RAYCAST; - copy_v3_v3(r_loc, loc); + copy_v3_v3(r_loc, sctx->ret.loc); if (r_no) { - copy_v3_v3(r_no, no); + copy_v3_v3(r_no, sctx->ret.no); } if (r_ob) { - *r_ob = ob_eval; + *r_ob = sctx->ret.ob; } if (r_obmat) { - copy_m4_m4(r_obmat, obmat); + copy_m4_m4(r_obmat, sctx->ret.obmat); } if (r_index) { - *r_index = index; + *r_index = sctx->ret.index; } } } @@ -3512,11 +3330,11 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont sctx->runtime.has_occlusion_plane = false; /* By convention we only snap to the original elements of a curve. */ - if (has_hit && ob_eval->type != OB_CURVES_LEGACY) { + if (has_hit && sctx->ret.ob->type != OB_CURVES_LEGACY) { /* Compute the new clip_pane but do not add it yet. */ float new_clipplane[4]; - BLI_ASSERT_UNIT_V3(no); - plane_from_point_normal_v3(new_clipplane, loc, no); + BLI_ASSERT_UNIT_V3(sctx->ret.no); + plane_from_point_normal_v3(new_clipplane, sctx->ret.loc, sctx->ret.no); if (dot_v3v3(sctx->runtime.clip_plane[0], new_clipplane) > 0.0f) { /* The plane is facing the wrong direction. */ negate_v4(new_clipplane); @@ -3526,7 +3344,7 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont new_clipplane[3] += 0.01f; /* Try to snap only to the polygon. */ - elem_test = snap_mesh_polygon(sctx, params, ob_eval, obmat, &dist_px_tmp, loc, no, &index); + elem_test = snap_mesh_polygon(sctx, params, &dist_px_tmp); if (elem_test) { elem = elem_test; } @@ -3540,7 +3358,7 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont sctx->runtime.has_occlusion_plane = true; } - elem_test = snapObjectsRay(sctx, params, &dist_px_tmp, loc, no, &index, &ob_eval, obmat); + elem_test = snapObjectsRay(sctx, params, &dist_px_tmp); if (elem_test) { elem = elem_test; } @@ -3549,25 +3367,24 @@ static eSnapMode transform_snap_context_project_view3d_mixed_impl(SnapObjectCont (snap_to_flag & (SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE_MIDPOINT | SCE_SNAP_MODE_EDGE_PERPENDICULAR))) { sctx->runtime.snap_to_flag = snap_to_flag; - elem = snap_mesh_edge_verts_mixed( - sctx, params, ob_eval, obmat, *dist_px, prev_co, &dist_px_tmp, loc, no, &index); + elem = snap_mesh_edge_verts_mixed(sctx, params, *dist_px, prev_co, &dist_px_tmp); } if (elem & snap_to_flag) { retval = elem; - copy_v3_v3(r_loc, loc); + copy_v3_v3(r_loc, sctx->ret.loc); if (r_no) { - copy_v3_v3(r_no, no); + copy_v3_v3(r_no, sctx->ret.no); } if (r_ob) { - *r_ob = ob_eval; + *r_ob = sctx->ret.ob; } if (r_obmat) { - copy_m4_m4(r_obmat, obmat); + copy_m4_m4(r_obmat, sctx->ret.obmat); } if (r_index) { - *r_index = index; + *r_index = sctx->ret.index; } *dist_px = dist_px_tmp; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index b65f4889347..0e77a8ba4ad 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -111,8 +111,8 @@ bool ED_object_get_active_image(Object *ob, int mat_nr, Image **r_ima, ImageUser **r_iuser, - bNode **r_node, - bNodeTree **r_ntree) + const bNode **r_node, + const bNodeTree **r_ntree) { Material *ma = DEG_is_evaluated_object(ob) ? BKE_object_material_get_eval(ob, mat_nr) : BKE_object_material_get(ob, mat_nr); diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c index 80517979f30..6f44cc68a19 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c @@ -154,7 +154,7 @@ static bool bake_strokes(Object *ob, typedef struct LineartBakeJob { wmWindowManager *wm; void *owner; - short *stop, *do_update; + bool *stop, *do_update; float *progress; /* C or ob must have one != NULL. */ @@ -218,8 +218,8 @@ static void lineart_gpencil_guard_modifiers(LineartBakeJob *bj) } static void lineart_gpencil_bake_startjob(void *customdata, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { LineartBakeJob *bj = (LineartBakeJob *)customdata; @@ -337,7 +337,7 @@ static int lineart_gpencil_bake_common(bContext *C, } float pseduo_progress; - short pseduo_do_update; + bool pseduo_do_update; lineart_gpencil_bake_startjob(bj, NULL, &pseduo_do_update, &pseduo_progress); BLI_linklist_free(bj->objects, NULL); diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 5c76dfe52df..a05bc51fcea 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -358,14 +358,14 @@ struct IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, * Will rebuild all used indices and proxies at once. */ void IMB_anim_index_rebuild(struct IndexBuildContext *context, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress); /** * Finish rebuilding proxies/time-codes and free temporary contexts used. */ -void IMB_anim_index_rebuild_finish(struct IndexBuildContext *context, short stop); +void IMB_anim_index_rebuild_finish(struct IndexBuildContext *context, bool stop); /** * Return the length (in frames) of the given \a anim. diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 63836690ee4..d824b87f493 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -931,7 +931,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, return (IndexBuildContext *)context; } -static void index_rebuild_ffmpeg_finish(FFmpegIndexBuilderContext *context, int stop) +static void index_rebuild_ffmpeg_finish(FFmpegIndexBuilderContext *context, const bool stop) { int i; @@ -1012,8 +1012,8 @@ static void index_rebuild_ffmpeg_proc_decoded_frame(FFmpegIndexBuilderContext *c } static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, - const short *stop, - short *do_update, + const bool *stop, + bool *do_update, float *progress) { AVFrame *in_frame = av_frame_alloc(); @@ -1303,7 +1303,7 @@ static IndexBuildContext *index_fallback_create_context(struct anim *anim, return (IndexBuildContext *)context; } -static void index_rebuild_fallback_finish(FallbackIndexBuilderContext *context, int stop) +static void index_rebuild_fallback_finish(FallbackIndexBuilderContext *context, const bool stop) { struct anim *anim = context->anim; char filepath[FILE_MAX]; @@ -1330,8 +1330,8 @@ static void index_rebuild_fallback_finish(FallbackIndexBuilderContext *context, } static void index_rebuild_fallback(FallbackIndexBuilderContext *context, - const short *stop, - short *do_update, + const bool *stop, + bool *do_update, float *progress) { int count = IMB_anim_get_duration(context->anim, IMB_TC_NONE); @@ -1470,9 +1470,9 @@ IndexBuildContext *IMB_anim_index_rebuild_context(struct anim *anim, void IMB_anim_index_rebuild(struct IndexBuildContext *context, /* NOLINTNEXTLINE: readability-non-const-parameter. */ - short *stop, + bool *stop, /* NOLINTNEXTLINE: readability-non-const-parameter. */ - short *do_update, + bool *do_update, /* NOLINTNEXTLINE: readability-non-const-parameter. */ float *progress) { @@ -1494,7 +1494,7 @@ void IMB_anim_index_rebuild(struct IndexBuildContext *context, UNUSED_VARS(stop, do_update, progress); } -void IMB_anim_index_rebuild_finish(IndexBuildContext *context, short stop) +void IMB_anim_index_rebuild_finish(IndexBuildContext *context, const bool stop) { switch (context->anim_type) { #ifdef WITH_FFMPEG diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc index 546bc9d49cc..1ac4eacc997 100644 --- a/source/blender/io/alembic/exporter/abc_export_capi.cc +++ b/source/blender/io/alembic/exporter/abc_export_capi.cc @@ -72,8 +72,8 @@ static void report_job_duration(const ExportJobData *data) static void export_startjob(void *customdata, /* Cannot be const, this function implements wm_jobs_start_callback. * NOLINTNEXTLINE: readability-non-const-parameter. */ - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { ExportJobData *data = static_cast<ExportJobData *>(customdata); @@ -230,7 +230,7 @@ bool ABC_export(Scene *scene, } else { /* Fake a job context, so that we don't need NULL pointer checks while exporting. */ - short stop = 0, do_update = 0; + bool stop = false, do_update = false; float progress = 0.0f; blender::io::alembic::export_startjob(job, &stop, &do_update, &progress); diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc index b92ce5b4cfb..f6c11f6a684 100644 --- a/source/blender/io/alembic/intern/alembic_capi.cc +++ b/source/blender/io/alembic/intern/alembic_capi.cc @@ -427,8 +427,8 @@ struct ImportJobData { ArchiveReader *archive; std::vector<AbcObjectReader *> readers; - short *stop; - short *do_update; + bool *stop; + bool *do_update; float *progress; char error_code; @@ -446,7 +446,7 @@ static void report_job_duration(const ImportJobData *data) std::cout << '\n'; } -static void import_startjob(void *user_data, short *stop, short *do_update, float *progress) +static void import_startjob(void *user_data, bool *stop, bool *do_update, float *progress) { SCOPE_TIMER("Alembic import, objects reading and creation"); @@ -715,7 +715,7 @@ bool ABC_import(bContext *C, } else { /* Fake a job context, so that we don't need NULL pointer checks while importing. */ - short stop = 0, do_update = 0; + bool stop = false, do_update = false; float progress = 0.0f; import_startjob(job, &stop, &do_update, &progress); diff --git a/source/blender/io/collada/MeshImporter.cpp b/source/blender/io/collada/MeshImporter.cpp index 6d7593afb8b..1a28adf50a5 100644 --- a/source/blender/io/collada/MeshImporter.cpp +++ b/source/blender/io/collada/MeshImporter.cpp @@ -564,7 +564,7 @@ void MeshImporter::mesh_add_edges(Mesh *mesh, int len) /* set default flags */ medge = &edges[mesh->totedge]; for (int i = 0; i < len; i++, medge++) { - medge->flag = ME_EDGEDRAW | ME_EDGERENDER; + medge->flag = ME_EDGEDRAW; } mesh->totedge = totedge; diff --git a/source/blender/io/usd/intern/usd_capi_export.cc b/source/blender/io/usd/intern/usd_capi_export.cc index 3977daaca4a..bf25c03fb7a 100644 --- a/source/blender/io/usd/intern/usd_capi_export.cc +++ b/source/blender/io/usd/intern/usd_capi_export.cc @@ -57,8 +57,8 @@ static void report_job_duration(const ExportJobData *data) static void export_startjob(void *customdata, /* Cannot be const, this function implements wm_jobs_start_callback. * NOLINTNEXTLINE: readability-non-const-parameter. */ - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress) { ExportJobData *data = static_cast<ExportJobData *>(customdata); @@ -205,7 +205,7 @@ bool USD_export(bContext *C, } else { /* Fake a job context, so that we don't need NULL pointer checks while exporting. */ - short stop = 0, do_update = 0; + bool stop = false, do_update = false; float progress = 0.0f; blender::io::usd::export_startjob(job, &stop, &do_update, &progress); diff --git a/source/blender/io/usd/intern/usd_capi_import.cc b/source/blender/io/usd/intern/usd_capi_import.cc index b8cc43beeb9..680e9c758d3 100644 --- a/source/blender/io/usd/intern/usd_capi_import.cc +++ b/source/blender/io/usd/intern/usd_capi_import.cc @@ -126,8 +126,8 @@ struct ImportJobData { USDStageReader *archive; - short *stop; - short *do_update; + bool *stop; + bool *do_update; float *progress; char error_code; @@ -144,7 +144,7 @@ static void report_job_duration(const ImportJobData *data) std::cout << '\n'; } -static void import_startjob(void *customdata, short *stop, short *do_update, float *progress) +static void import_startjob(void *customdata, bool *stop, bool *do_update, float *progress) { ImportJobData *data = static_cast<ImportJobData *>(customdata); @@ -430,7 +430,7 @@ bool USD_import(struct bContext *C, } else { /* Fake a job context, so that we don't need NULL pointer checks while importing. */ - short stop = 0, do_update = 0; + bool stop = false, do_update = false; float progress = 0.0f; import_startjob(job, &stop, &do_update, &progress); diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc index 5c81cf7abca..5289a8c750a 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc @@ -7,8 +7,9 @@ #include <algorithm> #include <cstdio> +#include "BKE_attribute.hh" #include "BKE_blender_version.h" -#include "BKE_geometry_set.hh" +#include "BKE_mesh.h" #include "BLI_color.hh" #include "BLI_enumerable_thread_specific.hh" @@ -416,15 +417,12 @@ void OBJWriter::write_edges_indices(FormatHandler &fh, const OBJMesh &obj_mesh_data) const { /* NOTE: ensure_mesh_edges should be called before. */ - const int tot_edges = obj_mesh_data.tot_edges(); - for (int edge_index = 0; edge_index < tot_edges; edge_index++) { - const std::optional<std::array<int, 2>> vertex_indices = - obj_mesh_data.calc_loose_edge_vert_indices(edge_index); - if (!vertex_indices) { - continue; + const Span<MEdge> edges = obj_mesh_data.get_mesh()->edges(); + for (const int i : edges.index_range()) { + const MEdge &edge = edges[i]; + if (edge.flag & ME_LOOSEEDGE) { + fh.write_obj_edge(edge.v1 + offsets.vertex_offset + 1, edge.v2 + offsets.vertex_offset + 1); } - fh.write_obj_edge((*vertex_indices)[0] + offsets.vertex_offset + 1, - (*vertex_indices)[1] + offsets.vertex_offset + 1); } } diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc index f5a94b1fc8a..a95f917869b 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc @@ -183,7 +183,6 @@ void OBJMesh::ensure_mesh_normals() const void OBJMesh::ensure_mesh_edges() const { - BKE_mesh_calc_edges(export_mesh_eval_, true, false); BKE_mesh_calc_edges_loose(export_mesh_eval_); } @@ -507,13 +506,4 @@ const char *OBJMesh::get_poly_deform_group_name(const int16_t def_group_index) c return vertex_group.name; } -std::optional<std::array<int, 2>> OBJMesh::calc_loose_edge_vert_indices(const int edge_index) const -{ - const Span<MEdge> edges = export_mesh_eval_->edges(); - const MEdge &edge = edges[edge_index]; - if (edge.flag & ME_LOOSEEDGE) { - return std::array<int, 2>{int(edge.v1), int(edge.v2)}; - } - return std::nullopt; -} } // namespace blender::io::obj diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh index ec98468e2de..89ee6f4dea2 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh @@ -216,11 +216,6 @@ class OBJMesh : NonCopyable { const char *get_poly_deform_group_name(int16_t def_group_index) const; /** - * Calculate vertex indices of an edge's corners if it is a loose edge. - */ - std::optional<std::array<int, 2>> calc_loose_edge_vert_indices(int edge_index) const; - - /** * Calculate the order in which the polygons should be written into the file (sorted by material * index). */ diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc index 33ece88d3d4..56ad7fd4563 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc @@ -254,7 +254,6 @@ void MeshFromGeometry::create_edges(Mesh *mesh) dst_edge.v1 = mesh_geometry_.global_to_local_vertices_.lookup_default(src_edge.v1, 0); dst_edge.v2 = mesh_geometry_.global_to_local_vertices_.lookup_default(src_edge.v2, 0); BLI_assert(dst_edge.v1 < total_verts && dst_edge.v2 < total_verts); - dst_edge.flag = ME_LOOSEEDGE; } /* Set argument `update` to true so that existing, explicitly imported edges can be merged diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index a1781265278..f1c2dcaae68 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -73,7 +73,6 @@ enum { ME_SEAM = (1 << 2), /** Deprecated hide status. Now stored in ".hide_edge" attribute. */ /* ME_HIDE = (1 << 4), */ - ME_EDGERENDER = (1 << 5), ME_LOOSEEDGE = (1 << 7), ME_SHARP = (1 << 9), /* only reason this flag remains a 'short' */ }; diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 0b7c17d44bb..3161238dc2e 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -613,7 +613,7 @@ typedef struct bNodeTree { void (*progress)(void *, float progress); /** \warning may be called by different threads */ void (*stats_draw)(void *, const char *str); - int (*test_break)(void *); + bool (*test_break)(void *); void (*update_draw)(void *); void *tbh, *prh, *sdh, *udh; diff --git a/source/blender/modifiers/intern/MOD_mask.cc b/source/blender/modifiers/intern/MOD_mask.cc index 7fabd5c65fa..659a1625079 100644 --- a/source/blender/modifiers/intern/MOD_mask.cc +++ b/source/blender/modifiers/intern/MOD_mask.cc @@ -607,7 +607,7 @@ static void add_interpolated_polys_to_new_mesh(const Mesh &src_mesh, cut_edge.v1 = dst_loops[mp_dst.loopstart].v; cut_edge.v2 = cut_dst_loop.v; BLI_assert(cut_edge.v1 != cut_edge.v2); - cut_edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + cut_edge.flag = ME_EDGEDRAW; edge_index++; /* Only handle one of the cuts per iteration. */ diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index afd7f5a2e48..4ba274dbd8a 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -814,7 +814,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * /* add the new edge */ med_new->v1 = varray_stride + j; med_new->v2 = med_new->v1 - totvert; - med_new->flag = ME_EDGEDRAW | ME_EDGERENDER; + med_new->flag = ME_EDGEDRAW; if (!BLI_BITMAP_TEST(vert_tag, j)) { med_new->flag |= ME_LOOSEEDGE; } @@ -835,7 +835,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * for (i = 0; i < totvert; i++) { med_new->v1 = i; med_new->v2 = varray_stride + i; - med_new->flag = ME_EDGEDRAW | ME_EDGERENDER; + med_new->flag = ME_EDGEDRAW; if (!BLI_BITMAP_TEST(vert_tag, i)) { med_new->flag |= ME_LOOSEEDGE; } diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c b/source/blender/modifiers/intern/MOD_solidify_extrude.c index a662d729f52..08e9569bd95 100644 --- a/source/blender/modifiers/intern/MOD_solidify_extrude.c +++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c @@ -1045,7 +1045,7 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex for (i = 0; i < rimVerts; i++, ed++) { ed->v1 = new_vert_arr[i]; ed->v2 = (do_shell ? new_vert_arr[i] : i) + verts_num; - ed->flag |= ME_EDGEDRAW | ME_EDGERENDER; + ed->flag |= ME_EDGEDRAW; if (orig_ed) { *orig_ed = ORIGINDEX_NONE; diff --git a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c index 5948fefa8b3..9d0b5c30b5e 100644 --- a/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c +++ b/source/blender/modifiers/intern/MOD_solidify_nonmanifold.c @@ -2042,7 +2042,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, BLI_assert(v2 != MOD_SOLIDIFY_EMPTY_TAG); medge[insert].v1 = v1; medge[insert].v2 = v2; - medge[insert].flag = orig_medge[(*l)->old_edge].flag | ME_EDGEDRAW | ME_EDGERENDER; + medge[insert].flag = orig_medge[(*l)->old_edge].flag | ME_EDGEDRAW; if (result_edge_crease) { result_edge_crease[insert] = orig_edge_crease ? orig_edge_crease[(*l)->old_edge] : 0.0f; @@ -2206,8 +2206,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, } medge[edge_index].v1 = last_g->new_vert; medge[edge_index].v2 = g->new_vert; - medge[edge_index].flag = ME_EDGEDRAW | ME_EDGERENDER | - ((last_flag | flag) & (ME_SEAM | ME_SHARP)); + medge[edge_index].flag = ME_EDGEDRAW | ((last_flag | flag) & (ME_SEAM | ME_SHARP)); if (result_edge_crease) { result_edge_crease[edge_index] = max_ff(mv_crease, min_ff(last_max_crease, max_crease)); @@ -2240,7 +2239,7 @@ Mesh *MOD_solidify_nonmanifold_modifyMesh(ModifierData *md, last_g->open_face_edge = edge_index; medge[edge_index].v1 = last_g->new_vert; medge[edge_index].v2 = first_g->new_vert; - medge[edge_index].flag = ME_EDGEDRAW | ME_EDGERENDER | + medge[edge_index].flag = ME_EDGEDRAW | ((last_flag | first_flag) & (ME_SEAM | ME_SHARP)); if (result_edge_crease) { result_edge_crease[edge_index] = max_ff(mv_crease, diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c index e8280bc9c97..5bae6090758 100644 --- a/source/blender/modifiers/intern/MOD_triangulate.c +++ b/source/blender/modifiers/intern/MOD_triangulate.c @@ -86,7 +86,7 @@ static Mesh *triangulate_mesh(Mesh *mesh, /* force drawing of all edges (seems to be omitted in CDDM_from_bmesh) */ for (i = 0; i < edges_num; i++, me++) { - me->flag |= ME_EDGEDRAW | ME_EDGERENDER; + me->flag |= ME_EDGEDRAW; } return result; diff --git a/source/blender/nodes/composite/CMakeLists.txt b/source/blender/nodes/composite/CMakeLists.txt index 4255a2dde21..8bcc2a393d3 100644 --- a/source/blender/nodes/composite/CMakeLists.txt +++ b/source/blender/nodes/composite/CMakeLists.txt @@ -19,6 +19,7 @@ set(INC ../../windowmanager ../../compositor/realtime_compositor ../../compositor/realtime_compositor/algorithms + ../../compositor/realtime_compositor/cached_resources ../../../../intern/guardedalloc # dna_type_offsets.h diff --git a/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc b/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc index e2f4e80270e..dffdc4a9408 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc +++ b/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc @@ -108,7 +108,7 @@ void register_node_type_cmp_alphaover() cmp_node_type_base(&ntype, CMP_NODE_ALPHAOVER, "Alpha Over", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::cmp_node_alphaover_declare; ntype.draw_buttons = file_ns::node_composit_buts_alphaover; - node_type_init(&ntype, file_ns::node_alphaover_init); + ntype.initfunc = file_ns::node_alphaover_init; node_type_storage( &ntype, "NodeTwoFloats", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc index 25fefd33199..8c77df08211 100644 --- a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc +++ b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc @@ -74,7 +74,7 @@ void register_node_type_cmp_antialiasing() ntype.draw_buttons = file_ns::node_composit_buts_antialiasing; ntype.flag |= NODE_PREVIEW; node_type_size(&ntype, 170, 140, 200); - node_type_init(&ntype, file_ns::node_composit_init_antialiasing); + ntype.initfunc = file_ns::node_composit_init_antialiasing; node_type_storage( &ntype, "NodeAntiAliasingData", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc index af7581d845f..65990677ae3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc @@ -119,7 +119,7 @@ void register_node_type_cmp_bilateralblur() cmp_node_type_base(&ntype, CMP_NODE_BILATERALBLUR, "Bilateral Blur", NODE_CLASS_OP_FILTER); ntype.declare = file_ns::cmp_node_bilateralblur_declare; ntype.draw_buttons = file_ns::node_composit_buts_bilateralblur; - node_type_init(&ntype, file_ns::node_composit_init_bilateralblur); + ntype.initfunc = file_ns::node_composit_init_bilateralblur; node_type_storage( &ntype, "NodeBilateralBlurData", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.cc b/source/blender/nodes/composite/nodes/node_composite_blur.cc index a9372bdcfb7..6eacc685c7e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_blur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_blur.cc @@ -5,11 +5,7 @@ * \ingroup cmpnodes */ -#include <cstdint> - -#include "BLI_array.hh" #include "BLI_assert.h" -#include "BLI_index_range.hh" #include "BLI_math_base.hh" #include "BLI_math_vec_types.hh" #include "BLI_math_vector.hh" @@ -19,12 +15,13 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "RE_pipeline.h" - +#include "GPU_shader.h" #include "GPU_state.h" #include "GPU_texture.h" #include "COM_node_operation.hh" +#include "COM_symmetric_blur_weights.hh" +#include "COM_symmetric_separable_blur_weights.hh" #include "COM_utilities.hh" #include "node_composite_util.hh" @@ -92,192 +89,7 @@ static void node_composit_buts_blur(uiLayout *layout, bContext * /*C*/, PointerR using namespace blender::realtime_compositor; -/* A helper class that computes and caches a 1D GPU texture containing the weights of the separable - * filter of the given type and radius. The filter is assumed to be symmetric, because the filter - * functions are all even functions. Consequently, only the positive half of the filter is computed - * and the shader takes that into consideration. */ -class SymmetricSeparableBlurWeights { - private: - float radius_ = 1.0f; - int type_ = R_FILTER_GAUSS; - GPUTexture *texture_ = nullptr; - - public: - ~SymmetricSeparableBlurWeights() - { - if (texture_) { - GPU_texture_free(texture_); - } - } - - /* Check if a texture containing the weights was already computed for the given filter type and - * radius. If such texture exists, do nothing, otherwise, free the already computed texture and - * recompute it with the given filter type and radius. */ - void update(float radius, int type) - { - if (texture_ && type == type_ && radius == radius_) { - return; - } - - if (texture_) { - GPU_texture_free(texture_); - } - - /* The size of filter is double the radius plus 1, but since the filter is symmetric, we only - * compute half of it and no doubling happens. We add 1 to make sure the filter size is always - * odd and there is a center weight. */ - const int size = math::ceil(radius) + 1; - Array<float> weights(size); - - float sum = 0.0f; - - /* First, compute the center weight. */ - const float center_weight = RE_filter_value(type, 0.0f); - weights[0] = center_weight; - sum += center_weight; - - /* Second, compute the other weights in the positive direction, making sure to add double the - * weight to the sum of weights because the filter is symmetric and we only loop over half of - * it. Skip the center weight already computed by dropping the front index. */ - const float scale = radius > 0.0f ? 1.0f / radius : 0.0f; - for (const int i : weights.index_range().drop_front(1)) { - const float weight = RE_filter_value(type, i * scale); - weights[i] = weight; - sum += weight * 2.0f; - } - - /* Finally, normalize the weights. */ - for (const int i : weights.index_range()) { - weights[i] /= sum; - } - - texture_ = GPU_texture_create_1d("Weights", size, 1, GPU_R16F, weights.data()); - - type_ = type; - radius_ = radius; - } - - void bind_as_texture(GPUShader *shader, const char *texture_name) - { - const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name); - GPU_texture_bind(texture_, texture_image_unit); - } - - void unbind_as_texture() - { - GPU_texture_unbind(texture_); - } -}; - -/* A helper class that computes and caches a 2D GPU texture containing the weights of the filter of - * the given type and radius. The filter is assumed to be symmetric, because the filter functions - * are evaluated on the normalized distance to the center. Consequently, only the upper right - * quadrant are computed and the shader takes that into consideration. */ -class SymmetricBlurWeights { - private: - int type_ = R_FILTER_GAUSS; - float2 radius_ = float2(1.0f); - GPUTexture *texture_ = nullptr; - - public: - ~SymmetricBlurWeights() - { - if (texture_) { - GPU_texture_free(texture_); - } - } - - /* Check if a texture containing the weights was already computed for the given filter type and - * radius. If such texture exists, do nothing, otherwise, free the already computed texture and - * recompute it with the given filter type and radius. */ - void update(float2 radius, int type) - { - if (texture_ && type == type_ && radius == radius_) { - return; - } - - if (texture_) { - GPU_texture_free(texture_); - } - - /* The full size of filter is double the radius plus 1, but since the filter is symmetric, we - * only compute a single quadrant of it and so no doubling happens. We add 1 to make sure the - * filter size is always odd and there is a center weight. */ - const float2 scale = math::safe_divide(float2(1.0f), radius); - const int2 size = int2(math::ceil(radius)) + int2(1); - Array<float> weights(size.x * size.y); - - float sum = 0.0f; - - /* First, compute the center weight. */ - const float center_weight = RE_filter_value(type, 0.0f); - weights[0] = center_weight; - sum += center_weight; - - /* Then, compute the weights along the positive x axis, making sure to add double the weight to - * the sum of weights because the filter is symmetric and we only loop over the positive half - * of the x axis. Skip the center weight already computed by dropping the front index. */ - for (const int x : IndexRange(size.x).drop_front(1)) { - const float weight = RE_filter_value(type, x * scale.x); - weights[x] = weight; - sum += weight * 2.0f; - } - - /* Then, compute the weights along the positive y axis, making sure to add double the weight to - * the sum of weights because the filter is symmetric and we only loop over the positive half - * of the y axis. Skip the center weight already computed by dropping the front index. */ - for (const int y : IndexRange(size.y).drop_front(1)) { - const float weight = RE_filter_value(type, y * scale.y); - weights[size.x * y] = weight; - sum += weight * 2.0f; - } - - /* Then, compute the other weights in the upper right quadrant, making sure to add quadruple - * the weight to the sum of weights because the filter is symmetric and we only loop over one - * quadrant of it. Skip the weights along the y and x axis already computed by dropping the - * front index. */ - for (const int y : IndexRange(size.y).drop_front(1)) { - for (const int x : IndexRange(size.x).drop_front(1)) { - const float weight = RE_filter_value(type, math::length(float2(x, y) * scale)); - weights[size.x * y + x] = weight; - sum += weight * 4.0f; - } - } - - /* Finally, normalize the weights. */ - for (const int y : IndexRange(size.y)) { - for (const int x : IndexRange(size.x)) { - weights[size.x * y + x] /= sum; - } - } - - texture_ = GPU_texture_create_2d("Weights", size.x, size.y, 1, GPU_R16F, weights.data()); - - type_ = type; - radius_ = radius; - } - - void bind_as_texture(GPUShader *shader, const char *texture_name) - { - const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name); - GPU_texture_bind(texture_, texture_image_unit); - } - - void unbind_as_texture() - { - GPU_texture_unbind(texture_); - } -}; - class BlurOperation : public NodeOperation { - private: - /* Cached symmetric blur weights. */ - SymmetricBlurWeights blur_weights_; - /* Cached symmetric blur weights for the separable horizontal pass. */ - SymmetricSeparableBlurWeights blur_horizontal_weights_; - /* Cached symmetric blur weights for the separable vertical pass. */ - SymmetricSeparableBlurWeights blur_vertical_weights_; - public: using NodeOperation::NodeOperation; @@ -308,13 +120,16 @@ class BlurOperation : public NodeOperation { const Result &input_image = get_input("Image"); input_image.bind_as_texture(shader, "input_tx"); - blur_weights_.update(compute_blur_radius(), node_storage(bnode()).filtertype); - blur_weights_.bind_as_texture(shader, "weights_tx"); + const float2 blur_radius = compute_blur_radius(); + + const SymmetricBlurWeights &weights = context().cache_manager().get_symmetric_blur_weights( + node_storage(bnode()).filtertype, blur_radius); + weights.bind_as_texture(shader, "weights_tx"); Domain domain = compute_domain(); if (get_extend_bounds()) { /* Add a radius amount of pixels in both sides of the image, hence the multiply by 2. */ - domain.size += int2(math::ceil(compute_blur_radius())) * 2; + domain.size += int2(math::ceil(blur_radius)) * 2; } Result &output_image = get_result("Image"); @@ -326,7 +141,7 @@ class BlurOperation : public NodeOperation { GPU_shader_unbind(); output_image.unbind_as_image(); input_image.unbind_as_texture(); - blur_weights_.unbind_as_texture(); + weights.unbind_as_texture(); } GPUTexture *execute_separable_blur_horizontal_pass() @@ -341,12 +156,16 @@ class BlurOperation : public NodeOperation { const Result &input_image = get_input("Image"); input_image.bind_as_texture(shader, "input_tx"); - blur_horizontal_weights_.update(compute_blur_radius().x, node_storage(bnode()).filtertype); - blur_horizontal_weights_.bind_as_texture(shader, "weights_tx"); + const float2 blur_radius = compute_blur_radius(); + + const SymmetricSeparableBlurWeights &weights = + context().cache_manager().get_symmetric_separable_blur_weights( + node_storage(bnode()).filtertype, blur_radius.x); + weights.bind_as_texture(shader, "weights_tx"); Domain domain = compute_domain(); if (get_extend_bounds()) { - domain.size.x += int(math::ceil(compute_blur_radius().x)) * 2; + domain.size.x += int(math::ceil(blur_radius.x)) * 2; } /* We allocate an output image of a transposed size, that is, with a height equivalent to the @@ -367,7 +186,7 @@ class BlurOperation : public NodeOperation { GPU_shader_unbind(); input_image.unbind_as_texture(); - blur_horizontal_weights_.unbind_as_texture(); + weights.unbind_as_texture(); GPU_texture_image_unbind(horizontal_pass_result); return horizontal_pass_result; @@ -386,8 +205,12 @@ class BlurOperation : public NodeOperation { const int texture_image_unit = GPU_shader_get_texture_binding(shader, "input_tx"); GPU_texture_bind(horizontal_pass_result, texture_image_unit); - blur_vertical_weights_.update(compute_blur_radius().y, node_storage(bnode()).filtertype); - blur_vertical_weights_.bind_as_texture(shader, "weights_tx"); + const float2 blur_radius = compute_blur_radius(); + + const SymmetricSeparableBlurWeights &weights = + context().cache_manager().get_symmetric_separable_blur_weights( + node_storage(bnode()).filtertype, blur_radius.y); + weights.bind_as_texture(shader, "weights_tx"); Domain domain = compute_domain(); if (get_extend_bounds()) { @@ -405,7 +228,7 @@ class BlurOperation : public NodeOperation { GPU_shader_unbind(); output_image.unbind_as_image(); - blur_vertical_weights_.unbind_as_texture(); + weights.unbind_as_texture(); GPU_texture_unbind(horizontal_pass_result); } @@ -501,7 +324,7 @@ void register_node_type_cmp_blur() ntype.declare = file_ns::cmp_node_blur_declare; ntype.draw_buttons = file_ns::node_composit_buts_blur; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_blur); + ntype.initfunc = file_ns::node_composit_init_blur; node_type_storage( &ntype, "NodeBlurData", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc b/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc index a581d87a463..f09bf1f5afd 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc @@ -215,7 +215,7 @@ void register_node_type_cmp_bokehblur() cmp_node_type_base(&ntype, CMP_NODE_BOKEHBLUR, "Bokeh Blur", NODE_CLASS_OP_FILTER); ntype.declare = file_ns::cmp_node_bokehblur_declare; ntype.draw_buttons = file_ns::node_composit_buts_bokehblur; - node_type_init(&ntype, file_ns::node_composit_init_bokehblur); + ntype.initfunc = file_ns::node_composit_init_bokehblur; ntype.get_compositor_operation = file_ns::get_compositor_operation; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc b/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc index eb35b933d1b..8b817d3a677 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc +++ b/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc @@ -122,7 +122,7 @@ void register_node_type_cmp_bokehimage() ntype.declare = file_ns::cmp_node_bokehimage_declare; ntype.draw_buttons = file_ns::node_composit_buts_bokehimage; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_bokehimage); + ntype.initfunc = file_ns::node_composit_init_bokehimage; node_type_storage( &ntype, "NodeBokehImage", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_boxmask.cc b/source/blender/nodes/composite/nodes/node_composite_boxmask.cc index 668dc9d92de..17b5d64de91 100644 --- a/source/blender/nodes/composite/nodes/node_composite_boxmask.cc +++ b/source/blender/nodes/composite/nodes/node_composite_boxmask.cc @@ -157,7 +157,7 @@ void register_node_type_cmp_boxmask() cmp_node_type_base(&ntype, CMP_NODE_MASK_BOX, "Box Mask", NODE_CLASS_MATTE); ntype.declare = file_ns::cmp_node_boxmask_declare; ntype.draw_buttons = file_ns::node_composit_buts_boxmask; - node_type_init(&ntype, file_ns::node_composit_init_boxmask); + ntype.initfunc = file_ns::node_composit_init_boxmask; node_type_storage(&ntype, "NodeBoxMask", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_brightness.cc b/source/blender/nodes/composite/nodes/node_composite_brightness.cc index 6b9fef75524..08794914e91 100644 --- a/source/blender/nodes/composite/nodes/node_composite_brightness.cc +++ b/source/blender/nodes/composite/nodes/node_composite_brightness.cc @@ -81,7 +81,7 @@ void register_node_type_cmp_brightcontrast() cmp_node_type_base(&ntype, CMP_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::cmp_node_brightcontrast_declare; ntype.draw_buttons = file_ns::node_composit_buts_brightcontrast; - node_type_init(&ntype, file_ns::node_composit_init_brightcontrast); + ntype.initfunc = file_ns::node_composit_init_brightcontrast; ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc b/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc index 2fd2d6c8f71..be02f1ecd00 100644 --- a/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc @@ -182,7 +182,7 @@ void register_node_type_cmp_channel_matte() ntype.declare = file_ns::cmp_node_channel_matte_declare; ntype.draw_buttons = file_ns::node_composit_buts_channel_matte; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_channel_matte); + ntype.initfunc = file_ns::node_composit_init_channel_matte; node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc b/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc index e2ef96ea95e..4e035fcf5e0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc @@ -121,7 +121,7 @@ void register_node_type_cmp_chroma_matte() ntype.declare = file_ns::cmp_node_chroma_matte_declare; ntype.draw_buttons = file_ns::node_composit_buts_chroma_matte; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_chroma_matte); + ntype.initfunc = file_ns::node_composit_init_chroma_matte; node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_color_matte.cc b/source/blender/nodes/composite/nodes/node_composite_color_matte.cc index 2a20a4d995f..9233f61205d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_color_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_color_matte.cc @@ -119,7 +119,7 @@ void register_node_type_cmp_color_matte() ntype.declare = file_ns::cmp_node_color_matte_declare; ntype.draw_buttons = file_ns::node_composit_buts_color_matte; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_color_matte); + ntype.initfunc = file_ns::node_composit_init_color_matte; node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_color_spill.cc b/source/blender/nodes/composite/nodes/node_composite_color_spill.cc index ba829da83ed..cd129d53d6b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_color_spill.cc +++ b/source/blender/nodes/composite/nodes/node_composite_color_spill.cc @@ -196,7 +196,7 @@ void register_node_type_cmp_color_spill() cmp_node_type_base(&ntype, CMP_NODE_COLOR_SPILL, "Color Spill", NODE_CLASS_MATTE); ntype.declare = file_ns::cmp_node_color_spill_declare; ntype.draw_buttons = file_ns::node_composit_buts_color_spill; - node_type_init(&ntype, file_ns::node_composit_init_color_spill); + ntype.initfunc = file_ns::node_composit_init_color_spill; node_type_storage( &ntype, "NodeColorspill", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc b/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc index 3300896bfdf..aade1b639ab 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc @@ -210,7 +210,7 @@ void register_node_type_cmp_colorbalance() ntype.draw_buttons = file_ns::node_composit_buts_colorbalance; ntype.draw_buttons_ex = file_ns::node_composit_buts_colorbalance_ex; node_type_size(&ntype, 400, 200, 400); - node_type_init(&ntype, file_ns::node_composit_init_colorbalance); + ntype.initfunc = file_ns::node_composit_init_colorbalance; node_type_storage( &ntype, "NodeColorBalance", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc index c6051a42df6..5ff190ac2e4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc +++ b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc @@ -353,7 +353,7 @@ void register_node_type_cmp_colorcorrection() ntype.draw_buttons = file_ns::node_composit_buts_colorcorrection; ntype.draw_buttons_ex = file_ns::node_composit_buts_colorcorrection_ex; node_type_size(&ntype, 400, 200, 600); - node_type_init(&ntype, file_ns::node_composit_init_colorcorrection); + ntype.initfunc = file_ns::node_composit_init_colorcorrection; node_type_storage( &ntype, "NodeColorCorrection", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_common.cc b/source/blender/nodes/composite/nodes/node_composite_common.cc index 8dd88d098c4..cd119684a79 100644 --- a/source/blender/nodes/composite/nodes/node_composite_common.cc +++ b/source/blender/nodes/composite/nodes/node_composite_common.cc @@ -32,7 +32,7 @@ void register_node_type_cmp_group() node_type_size(&ntype, 140, 60, 400); ntype.labelfunc = node_group_label; - node_type_group_update(&ntype, node_group_update); + ntype.group_update_func = node_group_update; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc b/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc index 3e521144b8d..24928acedd9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc +++ b/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc @@ -78,7 +78,7 @@ void register_node_type_cmp_convert_color_space(void) ntype.declare = file_ns::CMP_NODE_CONVERT_COLOR_SPACE_declare; ntype.draw_buttons = file_ns::node_composit_buts_convert_colorspace; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_composit_init_convert_colorspace); + ntype.initfunc = file_ns::node_composit_init_convert_colorspace; node_type_storage( &ntype, "NodeConvertColorSpace", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_crop.cc b/source/blender/nodes/composite/nodes/node_composite_crop.cc index 96a5443921b..4539d2af92d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_crop.cc +++ b/source/blender/nodes/composite/nodes/node_composite_crop.cc @@ -230,7 +230,7 @@ void register_node_type_cmp_crop() cmp_node_type_base(&ntype, CMP_NODE_CROP, "Crop", NODE_CLASS_DISTORT); ntype.declare = file_ns::cmp_node_crop_declare; ntype.draw_buttons = file_ns::node_composit_buts_crop; - node_type_init(&ntype, file_ns::node_composit_init_crop); + ntype.initfunc = file_ns::node_composit_init_crop; node_type_storage(&ntype, "NodeTwoXYs", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc index fa3b14ae015..e95a306976c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc @@ -331,7 +331,7 @@ void register_node_type_cmp_cryptomatte() node_type_socket_templates( &ntype, file_ns::cmp_node_cryptomatte_in, file_ns::cmp_node_cryptomatte_out); node_type_size(&ntype, 240, 100, 700); - node_type_init(&ntype, file_ns::node_init_cryptomatte); + ntype.initfunc = file_ns::node_init_cryptomatte; ntype.initfunc_api = file_ns::node_init_api_cryptomatte; ntype.poll = file_ns::node_poll_cryptomatte; node_type_storage( @@ -418,7 +418,7 @@ void register_node_type_cmp_cryptomatte_legacy() cmp_node_type_base( &ntype, CMP_NODE_CRYPTOMATTE_LEGACY, "Cryptomatte (Legacy)", NODE_CLASS_MATTE); node_type_socket_templates(&ntype, nullptr, file_ns::cmp_node_cryptomatte_out); - node_type_init(&ntype, legacy_file_ns::node_init_cryptomatte_legacy); + ntype.initfunc = legacy_file_ns::node_init_cryptomatte_legacy; node_type_storage( &ntype, "NodeCryptomatte", file_ns::node_free_cryptomatte, file_ns::node_copy_cryptomatte); ntype.gather_link_search_ops = nullptr; diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.cc b/source/blender/nodes/composite/nodes/node_composite_curves.cc index b631f75e879..5799c6c1a09 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.cc +++ b/source/blender/nodes/composite/nodes/node_composite_curves.cc @@ -100,7 +100,7 @@ void register_node_type_cmp_curve_time() cmp_node_type_base(&ntype, CMP_NODE_TIME, "Time Curve", NODE_CLASS_INPUT); ntype.declare = file_ns::cmp_node_time_declare; node_type_size(&ntype, 200, 140, 320); - node_type_init(&ntype, file_ns::node_composit_init_curves_time); + ntype.initfunc = file_ns::node_composit_init_curves_time; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.get_compositor_operation = file_ns::get_compositor_operation; @@ -195,7 +195,7 @@ void register_node_type_cmp_curve_vec() ntype.declare = file_ns::cmp_node_curve_vec_declare; ntype.draw_buttons = file_ns::node_buts_curvevec; node_type_size(&ntype, 200, 140, 320); - node_type_init(&ntype, file_ns::node_composit_init_curve_vec); + ntype.initfunc = file_ns::node_composit_init_curve_vec; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; @@ -332,7 +332,7 @@ void register_node_type_cmp_curve_rgb() cmp_node_type_base(&ntype, CMP_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::cmp_node_rgbcurves_declare; node_type_size(&ntype, 200, 140, 320); - node_type_init(&ntype, file_ns::node_composit_init_curve_rgb); + ntype.initfunc = file_ns::node_composit_init_curve_rgb; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.cc b/source/blender/nodes/composite/nodes/node_composite_defocus.cc index 197e02bebad..584cca87740 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.cc +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.cc @@ -111,7 +111,7 @@ void register_node_type_cmp_defocus() cmp_node_type_base(&ntype, CMP_NODE_DEFOCUS, "Defocus", NODE_CLASS_OP_FILTER); ntype.declare = file_ns::cmp_node_defocus_declare; ntype.draw_buttons = file_ns::node_composit_buts_defocus; - node_type_init(&ntype, file_ns::node_composit_init_defocus); + ntype.initfunc = file_ns::node_composit_init_defocus; node_type_storage(&ntype, "NodeDefocus", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_denoise.cc b/source/blender/nodes/composite/nodes/node_composite_denoise.cc index 821b3c23a7b..9ae02dab505 100644 --- a/source/blender/nodes/composite/nodes/node_composite_denoise.cc +++ b/source/blender/nodes/composite/nodes/node_composite_denoise.cc @@ -82,7 +82,7 @@ void register_node_type_cmp_denoise() cmp_node_type_base(&ntype, CMP_NODE_DENOISE, "Denoise", NODE_CLASS_OP_FILTER); ntype.declare = file_ns::cmp_node_denoise_declare; ntype.draw_buttons = file_ns::node_composit_buts_denoise; - node_type_init(&ntype, file_ns::node_composit_init_denonise); + ntype.initfunc = file_ns::node_composit_init_denonise; node_type_storage(&ntype, "NodeDenoise", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_despeckle.cc b/source/blender/nodes/composite/nodes/node_composite_despeckle.cc index 1e15f9709fe..28ef022459b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_despeckle.cc +++ b/source/blender/nodes/composite/nodes/node_composite_despeckle.cc @@ -115,7 +115,7 @@ void register_node_type_cmp_despeckle() ntype.declare = file_ns::cmp_node_despeckle_declare; ntype.draw_buttons = file_ns::node_composit_buts_despeckle; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_despeckle); + ntype.initfunc = file_ns::node_composit_init_despeckle; ntype.get_compositor_operation = file_ns::get_compositor_operation; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc b/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc index cde537f7d4c..c3fb0885c4d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc @@ -101,7 +101,7 @@ void register_node_type_cmp_diff_matte() ntype.declare = file_ns::cmp_node_diff_matte_declare; ntype.draw_buttons = file_ns::node_composit_buts_diff_matte; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_diff_matte); + ntype.initfunc = file_ns::node_composit_init_diff_matte; node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.cc b/source/blender/nodes/composite/nodes/node_composite_dilate.cc index d659c46721d..cc4e09d4d0d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.cc +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.cc @@ -5,25 +5,20 @@ * \ingroup cmpnodes */ -#include <cmath> - -#include "BLI_array.hh" #include "BLI_assert.h" #include "BLI_math_base.hh" - -#include "DNA_scene_types.h" +#include "BLI_math_vec_types.hh" #include "RNA_access.h" #include "UI_interface.h" #include "UI_resources.h" -#include "RE_pipeline.h" - #include "GPU_shader.h" #include "GPU_state.h" #include "GPU_texture.h" +#include "COM_morphological_distance_feather_weights.hh" #include "COM_node_operation.hh" #include "COM_utilities.hh" @@ -64,161 +59,7 @@ static void node_composit_buts_dilateerode(uiLayout *layout, bContext * /*C*/, P using namespace blender::realtime_compositor; -/* Computes a falloff that is equal to 1 at an input of zero and decrease to zero at an input of 1, - * with the rate of decrease depending on the falloff type. */ -static float compute_distance_falloff(float x, int falloff_type) -{ - x = 1.0f - x; - - switch (falloff_type) { - case PROP_SMOOTH: - return 3.0f * x * x - 2.0f * x * x * x; - case PROP_SPHERE: - return std::sqrt(2.0f * x - x * x); - case PROP_ROOT: - return std::sqrt(x); - case PROP_SHARP: - return x * x; - case PROP_INVSQUARE: - return x * (2.0f - x); - case PROP_LIN: - return x; - default: - BLI_assert_unreachable(); - return x; - } -} - -/* A helper class that computes and caches 1D GPU textures containing the weights of the separable - * Gaussian filter of the given radius as well as an inverse distance falloff of the given type and - * radius. The weights and falloffs are symmetric, because the Gaussian and falloff functions are - * all even functions. Consequently, only the positive half of the filter is computed and the - * shader takes that into consideration. */ -class SymmetricSeparableMorphologicalDistanceFeatherWeights { - private: - int radius_ = 1; - int falloff_type_ = PROP_SMOOTH; - GPUTexture *weights_texture_ = nullptr; - GPUTexture *distance_falloffs_texture_ = nullptr; - - public: - ~SymmetricSeparableMorphologicalDistanceFeatherWeights() - { - if (weights_texture_) { - GPU_texture_free(weights_texture_); - } - - if (distance_falloffs_texture_) { - GPU_texture_free(distance_falloffs_texture_); - } - } - - /* Check if textures containing the weights and distance falloffs were already computed for the - * given distance falloff type and radius. If such textures exists, do nothing, otherwise, free - * the already computed textures and recompute it with the given distance falloff type and - * radius. */ - void update(int radius, int falloff_type) - { - if (weights_texture_ && distance_falloffs_texture_ && falloff_type == falloff_type_ && - radius == radius_) { - return; - } - - radius_ = radius; - falloff_type_ = falloff_type; - - compute_weights(); - compute_distance_falloffs(); - } - - void compute_weights() - { - if (weights_texture_) { - GPU_texture_free(weights_texture_); - } - - /* The size of filter is double the radius plus 1, but since the filter is symmetric, we only - * compute half of it and no doubling happens. We add 1 to make sure the filter size is always - * odd and there is a center weight. */ - const int size = radius_ + 1; - Array<float> weights(size); - - float sum = 0.0f; - - /* First, compute the center weight. */ - const float center_weight = RE_filter_value(R_FILTER_GAUSS, 0.0f); - weights[0] = center_weight; - sum += center_weight; - - /* Second, compute the other weights in the positive direction, making sure to add double the - * weight to the sum of weights because the filter is symmetric and we only loop over half of - * it. Skip the center weight already computed by dropping the front index. */ - const float scale = radius_ > 0.0f ? 1.0f / radius_ : 0.0f; - for (const int i : weights.index_range().drop_front(1)) { - const float weight = RE_filter_value(R_FILTER_GAUSS, i * scale); - weights[i] = weight; - sum += weight * 2.0f; - } - - /* Finally, normalize the weights. */ - for (const int i : weights.index_range()) { - weights[i] /= sum; - } - - weights_texture_ = GPU_texture_create_1d("Weights", size, 1, GPU_R16F, weights.data()); - } - - void compute_distance_falloffs() - { - if (distance_falloffs_texture_) { - GPU_texture_free(distance_falloffs_texture_); - } - - /* The size of the distance falloffs is double the radius plus 1, but since the falloffs are - * symmetric, we only compute half of them and no doubling happens. We add 1 to make sure the - * falloffs size is always odd and there is a center falloff. */ - const int size = radius_ + 1; - Array<float> falloffs(size); - - /* Compute the distance falloffs in the positive direction only, because the falloffs are - * symmetric. */ - const float scale = radius_ > 0.0f ? 1.0f / radius_ : 0.0f; - for (const int i : falloffs.index_range()) { - falloffs[i] = compute_distance_falloff(i * scale, falloff_type_); - } - - distance_falloffs_texture_ = GPU_texture_create_1d( - "Distance Factors", size, 1, GPU_R16F, falloffs.data()); - } - - void bind_weights_as_texture(GPUShader *shader, const char *texture_name) - { - const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name); - GPU_texture_bind(weights_texture_, texture_image_unit); - } - - void unbind_weights_as_texture() - { - GPU_texture_unbind(weights_texture_); - } - - void bind_distance_falloffs_as_texture(GPUShader *shader, const char *texture_name) - { - const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name); - GPU_texture_bind(distance_falloffs_texture_, texture_image_unit); - } - - void unbind_distance_falloffs_as_texture() - { - GPU_texture_unbind(distance_falloffs_texture_); - } -}; - class DilateErodeOperation : public NodeOperation { - private: - /* Cached symmetric blur weights and distance falloffs for the distance feature method. */ - SymmetricSeparableMorphologicalDistanceFeatherWeights distance_feather_weights_; - public: using NodeOperation::NodeOperation; @@ -414,9 +255,11 @@ class DilateErodeOperation : public NodeOperation { const Result &input_image = get_input("Mask"); input_image.bind_as_texture(shader, "input_tx"); - distance_feather_weights_.update(math::abs(get_distance()), node_storage(bnode()).falloff); - distance_feather_weights_.bind_weights_as_texture(shader, "weights_tx"); - distance_feather_weights_.bind_distance_falloffs_as_texture(shader, "falloffs_tx"); + const MorphologicalDistanceFeatherWeights &weights = + context().cache_manager().get_morphological_distance_feather_weights( + node_storage(bnode()).falloff, math::abs(get_distance())); + weights.bind_weights_as_texture(shader, "weights_tx"); + weights.bind_distance_falloffs_as_texture(shader, "falloffs_tx"); /* We allocate an output image of a transposed size, that is, with a height equivalent to the * width of the input and vice versa. This is done as a performance optimization. The shader @@ -437,8 +280,8 @@ class DilateErodeOperation : public NodeOperation { GPU_shader_unbind(); input_image.unbind_as_texture(); - distance_feather_weights_.unbind_weights_as_texture(); - distance_feather_weights_.unbind_distance_falloffs_as_texture(); + weights.unbind_weights_as_texture(); + weights.unbind_distance_falloffs_as_texture(); GPU_texture_image_unbind(horizontal_pass_result); return horizontal_pass_result; @@ -453,9 +296,11 @@ class DilateErodeOperation : public NodeOperation { const int texture_image_unit = GPU_shader_get_texture_binding(shader, "input_tx"); GPU_texture_bind(horizontal_pass_result, texture_image_unit); - distance_feather_weights_.update(math::abs(get_distance()), node_storage(bnode()).falloff); - distance_feather_weights_.bind_weights_as_texture(shader, "weights_tx"); - distance_feather_weights_.bind_distance_falloffs_as_texture(shader, "falloffs_tx"); + const MorphologicalDistanceFeatherWeights &weights = + context().cache_manager().get_morphological_distance_feather_weights( + node_storage(bnode()).falloff, math::abs(get_distance())); + weights.bind_weights_as_texture(shader, "weights_tx"); + weights.bind_distance_falloffs_as_texture(shader, "falloffs_tx"); const Domain domain = compute_domain(); Result &output_image = get_result("Mask"); @@ -468,8 +313,8 @@ class DilateErodeOperation : public NodeOperation { GPU_shader_unbind(); output_image.unbind_as_image(); - distance_feather_weights_.unbind_weights_as_texture(); - distance_feather_weights_.unbind_distance_falloffs_as_texture(); + weights.unbind_weights_as_texture(); + weights.unbind_distance_falloffs_as_texture(); GPU_texture_unbind(horizontal_pass_result); } @@ -535,7 +380,7 @@ void register_node_type_cmp_dilateerode() cmp_node_type_base(&ntype, CMP_NODE_DILATEERODE, "Dilate/Erode", NODE_CLASS_OP_FILTER); ntype.draw_buttons = file_ns::node_composit_buts_dilateerode; ntype.declare = file_ns::cmp_node_dilate_declare; - node_type_init(&ntype, file_ns::node_composit_init_dilateerode); + ntype.initfunc = file_ns::node_composit_init_dilateerode; node_type_storage( &ntype, "NodeDilateErode", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc b/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc index a5a253c2cca..452c83ef1b5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc @@ -199,7 +199,7 @@ void register_node_type_cmp_dblur() cmp_node_type_base(&ntype, CMP_NODE_DBLUR, "Directional Blur", NODE_CLASS_OP_FILTER); ntype.declare = file_ns::cmp_node_directional_blur_declare; ntype.draw_buttons = file_ns::node_composit_buts_dblur; - node_type_init(&ntype, file_ns::node_composit_init_dblur); + ntype.initfunc = file_ns::node_composit_init_dblur; node_type_storage( &ntype, "NodeDBlurData", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc b/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc index 87b66810fe3..16f79f4e730 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc @@ -123,7 +123,7 @@ void register_node_type_cmp_distance_matte() ntype.declare = file_ns::cmp_node_distance_matte_declare; ntype.draw_buttons = file_ns::node_composit_buts_distance_matte; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_distance_matte); + ntype.initfunc = file_ns::node_composit_init_distance_matte; node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc index 120b4d0d976..f06b64f10b5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc +++ b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc @@ -156,7 +156,7 @@ void register_node_type_cmp_ellipsemask() ntype.declare = file_ns::cmp_node_ellipsemask_declare; ntype.draw_buttons = file_ns::node_composit_buts_ellipsemask; node_type_size(&ntype, 260, 110, 320); - node_type_init(&ntype, file_ns::node_composit_init_ellipsemask); + ntype.initfunc = file_ns::node_composit_init_ellipsemask; node_type_storage( &ntype, "NodeEllipseMask", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.cc b/source/blender/nodes/composite/nodes/node_composite_glare.cc index 60d149a32b9..4352f519e4c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_glare.cc +++ b/source/blender/nodes/composite/nodes/node_composite_glare.cc @@ -105,7 +105,7 @@ void register_node_type_cmp_glare() cmp_node_type_base(&ntype, CMP_NODE_GLARE, "Glare", NODE_CLASS_OP_FILTER); ntype.declare = file_ns::cmp_node_glare_declare; ntype.draw_buttons = file_ns::node_composit_buts_glare; - node_type_init(&ntype, file_ns::node_composit_init_glare); + ntype.initfunc = file_ns::node_composit_init_glare; node_type_storage(&ntype, "NodeGlare", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc b/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc index a365929138c..2e09e44eddc 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc @@ -106,7 +106,7 @@ void register_node_type_cmp_huecorrect() cmp_node_type_base(&ntype, CMP_NODE_HUECORRECT, "Hue Correct", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::cmp_node_huecorrect_declare; node_type_size(&ntype, 320, 140, 500); - node_type_init(&ntype, file_ns::node_composit_init_huecorrect); + ntype.initfunc = file_ns::node_composit_init_huecorrect; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_image.cc b/source/blender/nodes/composite/nodes/node_composite_image.cc index 9efedf744ec..322f1eecf91 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.cc +++ b/source/blender/nodes/composite/nodes/node_composite_image.cc @@ -660,10 +660,10 @@ void register_node_type_cmp_image() static bNodeType ntype; cmp_node_type_base(&ntype, CMP_NODE_IMAGE, "Image", NODE_CLASS_INPUT); - node_type_init(&ntype, file_ns::node_composit_init_image); + ntype.initfunc = file_ns::node_composit_init_image; node_type_storage( &ntype, "ImageUser", file_ns::node_composit_free_image, file_ns::node_composit_copy_image); - node_type_update(&ntype, file_ns::cmp_node_image_update); + ntype.updatefunc = file_ns::cmp_node_image_update; ntype.get_compositor_operation = file_ns::get_compositor_operation; ntype.labelfunc = node_image_label; ntype.flag |= NODE_PREVIEW; @@ -879,8 +879,8 @@ void register_node_type_cmp_rlayers() ntype.flag |= NODE_PREVIEW; node_type_storage( &ntype, nullptr, file_ns::node_composit_free_rlayers, file_ns::node_composit_copy_rlayers); - node_type_update(&ntype, file_ns::cmp_node_rlayers_update); - node_type_init(&ntype, node_cmp_rlayers_outputs); + ntype.updatefunc = file_ns::cmp_node_rlayers_update; + ntype.initfunc = node_cmp_rlayers_outputs; node_type_size_preset(&ntype, NODE_SIZE_LARGE); nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_invert.cc b/source/blender/nodes/composite/nodes/node_composite_invert.cc index bbb2808c4ea..c8787ebb01b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_invert.cc +++ b/source/blender/nodes/composite/nodes/node_composite_invert.cc @@ -96,7 +96,7 @@ void register_node_type_cmp_invert() cmp_node_type_base(&ntype, CMP_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::cmp_node_invert_declare; ntype.draw_buttons = file_ns::node_composit_buts_invert; - node_type_init(&ntype, file_ns::node_composit_init_invert); + ntype.initfunc = file_ns::node_composit_init_invert; ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_keying.cc b/source/blender/nodes/composite/nodes/node_composite_keying.cc index 4b61e06a232..b2add06c541 100644 --- a/source/blender/nodes/composite/nodes/node_composite_keying.cc +++ b/source/blender/nodes/composite/nodes/node_composite_keying.cc @@ -95,7 +95,7 @@ void register_node_type_cmp_keying() cmp_node_type_base(&ntype, CMP_NODE_KEYING, "Keying", NODE_CLASS_MATTE); ntype.declare = file_ns::cmp_node_keying_declare; ntype.draw_buttons = file_ns::node_composit_buts_keying; - node_type_init(&ntype, file_ns::node_composit_init_keying); + ntype.initfunc = file_ns::node_composit_init_keying; node_type_storage( &ntype, "NodeKeyingData", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.cc b/source/blender/nodes/composite/nodes/node_composite_lensdist.cc index 1cf482ff6ff..e11ed0fbfb6 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lensdist.cc +++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.cc @@ -250,7 +250,7 @@ void register_node_type_cmp_lensdist() cmp_node_type_base(&ntype, CMP_NODE_LENSDIST, "Lens Distortion", NODE_CLASS_DISTORT); ntype.declare = file_ns::cmp_node_lensdist_declare; ntype.draw_buttons = file_ns::node_composit_buts_lensdist; - node_type_init(&ntype, file_ns::node_composit_init_lensdist); + ntype.initfunc = file_ns::node_composit_init_lensdist; node_type_storage( &ntype, "NodeLensDist", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.cc b/source/blender/nodes/composite/nodes/node_composite_levels.cc index 4c901372b9f..29212c7a76f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_levels.cc +++ b/source/blender/nodes/composite/nodes/node_composite_levels.cc @@ -201,7 +201,7 @@ void register_node_type_cmp_view_levels() ntype.declare = file_ns::cmp_node_levels_declare; ntype.draw_buttons = file_ns::node_composit_buts_view_levels; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_view_levels); + ntype.initfunc = file_ns::node_composit_init_view_levels; ntype.get_compositor_operation = file_ns::get_compositor_operation; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc b/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc index 8426efb0f1f..325f5dbd870 100644 --- a/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc @@ -104,7 +104,7 @@ void register_node_type_cmp_luma_matte() ntype.declare = file_ns::cmp_node_luma_matte_declare; ntype.draw_buttons = file_ns::node_composit_buts_luma_matte; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_luma_matte); + ntype.initfunc = file_ns::node_composit_init_luma_matte; node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_map_value.cc b/source/blender/nodes/composite/nodes/node_composite_map_value.cc index eacc003378a..ea80e7b03a8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_map_value.cc +++ b/source/blender/nodes/composite/nodes/node_composite_map_value.cc @@ -116,7 +116,7 @@ void register_node_type_cmp_map_value() cmp_node_type_base(&ntype, CMP_NODE_MAP_VALUE, "Map Value", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::cmp_node_map_value_declare; ntype.draw_buttons = file_ns::node_composit_buts_map_value; - node_type_init(&ntype, file_ns::node_composit_init_map_value); + ntype.initfunc = file_ns::node_composit_init_map_value; node_type_storage(&ntype, "TexMapping", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.cc b/source/blender/nodes/composite/nodes/node_composite_mask.cc index 5dfcc9a9ecf..895ef62a82d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.cc +++ b/source/blender/nodes/composite/nodes/node_composite_mask.cc @@ -104,7 +104,7 @@ void register_node_type_cmp_mask() cmp_node_type_base(&ntype, CMP_NODE_MASK, "Mask", NODE_CLASS_INPUT); ntype.declare = file_ns::cmp_node_mask_declare; ntype.draw_buttons = file_ns::node_composit_buts_mask; - node_type_init(&ntype, file_ns::node_composit_init_mask); + ntype.initfunc = file_ns::node_composit_init_mask; ntype.labelfunc = file_ns::node_mask_label; ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_math.cc b/source/blender/nodes/composite/nodes/node_composite_math.cc index 4baf057913e..e1dda06a41e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_math.cc +++ b/source/blender/nodes/composite/nodes/node_composite_math.cc @@ -96,7 +96,7 @@ void register_node_type_cmp_math() cmp_node_type_base(&ntype, CMP_NODE_MATH, "Math", NODE_CLASS_CONVERTER); ntype.declare = file_ns::cmp_node_math_declare; ntype.labelfunc = node_math_label; - node_type_update(&ntype, node_math_update); + ntype.updatefunc = node_math_update; ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_output_file.cc b/source/blender/nodes/composite/nodes/node_composite_output_file.cc index f27dec91b1c..f64e448842d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_output_file.cc +++ b/source/blender/nodes/composite/nodes/node_composite_output_file.cc @@ -470,7 +470,7 @@ void register_node_type_cmp_output_file() ntype.flag |= NODE_PREVIEW; node_type_storage( &ntype, "NodeImageMultiFile", file_ns::free_output_file, file_ns::copy_output_file); - node_type_update(&ntype, file_ns::update_output_file); + ntype.updatefunc = file_ns::update_output_file; ntype.get_compositor_operation = file_ns::get_compositor_operation; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.cc b/source/blender/nodes/composite/nodes/node_composite_rotate.cc index 5f3df3abd35..4cc1166b373 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rotate.cc +++ b/source/blender/nodes/composite/nodes/node_composite_rotate.cc @@ -95,7 +95,7 @@ void register_node_type_cmp_rotate() cmp_node_type_base(&ntype, CMP_NODE_ROTATE, "Rotate", NODE_CLASS_DISTORT); ntype.declare = file_ns::cmp_node_rotate_declare; ntype.draw_buttons = file_ns::node_composit_buts_rotate; - node_type_init(&ntype, file_ns::node_composit_init_rotate); + ntype.initfunc = file_ns::node_composit_init_rotate; ntype.get_compositor_operation = file_ns::get_compositor_operation; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.cc b/source/blender/nodes/composite/nodes/node_composite_scale.cc index c524d7b8da9..a4e28326d9d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_scale.cc +++ b/source/blender/nodes/composite/nodes/node_composite_scale.cc @@ -221,7 +221,7 @@ void register_node_type_cmp_scale() cmp_node_type_base(&ntype, CMP_NODE_SCALE, "Scale", NODE_CLASS_DISTORT); ntype.declare = file_ns::cmp_node_scale_declare; ntype.draw_buttons = file_ns::node_composit_buts_scale; - node_type_update(&ntype, file_ns::node_composite_update_scale); + ntype.updatefunc = file_ns::node_composite_update_scale; ntype.get_compositor_operation = file_ns::get_compositor_operation; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc b/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc index d3f8530ae8b..118ab6ccdf8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc +++ b/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc @@ -137,10 +137,10 @@ void register_node_type_cmp_separate_color() cmp_node_type_base(&ntype, CMP_NODE_SEPARATE_COLOR, "Separate Color", NODE_CLASS_CONVERTER); ntype.declare = file_ns::cmp_node_separate_color_declare; - node_type_init(&ntype, node_cmp_combsep_color_init); + ntype.initfunc = node_cmp_combsep_color_init; node_type_storage( &ntype, "NodeCMPCombSepColor", node_free_standard_storage, node_copy_standard_storage); - node_type_update(&ntype, file_ns::cmp_node_separate_color_update); + ntype.updatefunc = file_ns::cmp_node_separate_color_update; ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; nodeRegisterType(&ntype); @@ -243,10 +243,10 @@ void register_node_type_cmp_combine_color() cmp_node_type_base(&ntype, CMP_NODE_COMBINE_COLOR, "Combine Color", NODE_CLASS_CONVERTER); ntype.declare = file_ns::cmp_node_combine_color_declare; - node_type_init(&ntype, node_cmp_combsep_color_init); + ntype.initfunc = node_cmp_combsep_color_init; node_type_storage( &ntype, "NodeCMPCombSepColor", node_free_standard_storage, node_copy_standard_storage); - node_type_update(&ntype, file_ns::cmp_node_combine_color_update); + ntype.updatefunc = file_ns::cmp_node_combine_color_update; ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcomb_ycca.cc b/source/blender/nodes/composite/nodes/node_composite_sepcomb_ycca.cc index 82fc37a18f6..7c1461b4f6e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcomb_ycca.cc +++ b/source/blender/nodes/composite/nodes/node_composite_sepcomb_ycca.cc @@ -84,7 +84,7 @@ void register_node_type_cmp_sepycca() cmp_node_type_base( &ntype, CMP_NODE_SEPYCCA_LEGACY, "Separate YCbCrA (Legacy)", NODE_CLASS_CONVERTER); ntype.declare = file_ns::cmp_node_sepycca_declare; - node_type_init(&ntype, file_ns::node_composit_init_mode_sepycca); + ntype.initfunc = file_ns::node_composit_init_mode_sepycca; ntype.gather_link_search_ops = nullptr; ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; @@ -172,7 +172,7 @@ void register_node_type_cmp_combycca() cmp_node_type_base( &ntype, CMP_NODE_COMBYCCA_LEGACY, "Combine YCbCrA (Legacy)", NODE_CLASS_CONVERTER); ntype.declare = file_ns::cmp_node_combycca_declare; - node_type_init(&ntype, file_ns::node_composit_init_mode_combycca); + ntype.initfunc = file_ns::node_composit_init_mode_combycca; ntype.gather_link_search_ops = nullptr; ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_setalpha.cc b/source/blender/nodes/composite/nodes/node_composite_setalpha.cc index 725ae6e3fcb..99c4dae4a92 100644 --- a/source/blender/nodes/composite/nodes/node_composite_setalpha.cc +++ b/source/blender/nodes/composite/nodes/node_composite_setalpha.cc @@ -81,7 +81,7 @@ void register_node_type_cmp_setalpha() cmp_node_type_base(&ntype, CMP_NODE_SETALPHA, "Set Alpha", NODE_CLASS_CONVERTER); ntype.declare = file_ns::cmp_node_setalpha_declare; ntype.draw_buttons = file_ns::node_composit_buts_set_alpha; - node_type_init(&ntype, file_ns::node_composit_init_setalpha); + ntype.initfunc = file_ns::node_composit_init_setalpha; node_type_storage( &ntype, "NodeSetAlpha", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_split_viewer.cc b/source/blender/nodes/composite/nodes/node_composite_split_viewer.cc index f25d33033a2..b4e698f5096 100644 --- a/source/blender/nodes/composite/nodes/node_composite_split_viewer.cc +++ b/source/blender/nodes/composite/nodes/node_composite_split_viewer.cc @@ -125,7 +125,7 @@ void register_node_type_cmp_splitviewer() ntype.declare = file_ns::cmp_node_split_viewer_declare; ntype.draw_buttons = file_ns::node_composit_buts_splitviewer; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_splitviewer); + ntype.initfunc = file_ns::node_composit_init_splitviewer; node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc b/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc index d2ee9f567f2..798e60e9482 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc +++ b/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc @@ -68,7 +68,7 @@ void register_node_type_cmp_sunbeams() cmp_node_type_base(&ntype, CMP_NODE_SUNBEAMS, "Sun Beams", NODE_CLASS_OP_FILTER); ntype.declare = file_ns::cmp_node_sunbeams_declare; ntype.draw_buttons = file_ns::node_composit_buts_sunbeams; - node_type_init(&ntype, file_ns::init); + ntype.initfunc = file_ns::init; node_type_storage( &ntype, "NodeSunBeams", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_switchview.cc b/source/blender/nodes/composite/nodes/node_composite_switchview.cc index 9b21ecab335..9974e55cc1a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_switchview.cc +++ b/source/blender/nodes/composite/nodes/node_composite_switchview.cc @@ -173,7 +173,7 @@ void register_node_type_cmp_switch_view() node_type_socket_templates(&ntype, nullptr, file_ns::cmp_node_switch_view_out); ntype.draw_buttons_ex = file_ns::node_composit_buts_switch_view_ex; ntype.initfunc_api = file_ns::init_switch_view; - node_type_update(&ntype, file_ns::cmp_node_switch_view_update); + ntype.updatefunc = file_ns::cmp_node_switch_view_update; ntype.get_compositor_operation = file_ns::get_compositor_operation; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.cc b/source/blender/nodes/composite/nodes/node_composite_tonemap.cc index d26a01bb3c9..febbb9ddec5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_tonemap.cc +++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.cc @@ -332,7 +332,7 @@ void register_node_type_cmp_tonemap() cmp_node_type_base(&ntype, CMP_NODE_TONEMAP, "Tonemap", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::cmp_node_tonemap_declare; ntype.draw_buttons = file_ns::node_composit_buts_tonemap; - node_type_init(&ntype, file_ns::node_composit_init_tonemap); + ntype.initfunc = file_ns::node_composit_init_tonemap; node_type_storage(&ntype, "NodeTonemap", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_translate.cc b/source/blender/nodes/composite/nodes/node_composite_translate.cc index c8f9f8ee666..154be2d428a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_translate.cc +++ b/source/blender/nodes/composite/nodes/node_composite_translate.cc @@ -110,7 +110,7 @@ void register_node_type_cmp_translate() cmp_node_type_base(&ntype, CMP_NODE_TRANSLATE, "Translate", NODE_CLASS_DISTORT); ntype.declare = file_ns::cmp_node_translate_declare; ntype.draw_buttons = file_ns::node_composit_buts_translate; - node_type_init(&ntype, file_ns::node_composit_init_translate); + ntype.initfunc = file_ns::node_composit_init_translate; node_type_storage( &ntype, "NodeTranslateData", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc b/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc index 2870b07f207..d083051e9d2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc +++ b/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc @@ -134,7 +134,7 @@ void register_node_type_cmp_valtorgb() cmp_node_type_base(&ntype, CMP_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTER); ntype.declare = file_ns::cmp_node_valtorgb_declare; node_type_size(&ntype, 240, 200, 320); - node_type_init(&ntype, file_ns::node_composit_init_valtorgb); + ntype.initfunc = file_ns::node_composit_init_valtorgb; node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node; diff --git a/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc b/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc index 6d43647020f..6a44fcb1650 100644 --- a/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc +++ b/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc @@ -81,7 +81,7 @@ void register_node_type_cmp_vecblur() cmp_node_type_base(&ntype, CMP_NODE_VECBLUR, "Vector Blur", NODE_CLASS_OP_FILTER); ntype.declare = file_ns::cmp_node_vec_blur_declare; ntype.draw_buttons = file_ns::node_composit_buts_vecblur; - node_type_init(&ntype, file_ns::node_composit_init_vecblur); + ntype.initfunc = file_ns::node_composit_init_vecblur; node_type_storage( &ntype, "NodeBlurData", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.cc b/source/blender/nodes/composite/nodes/node_composite_viewer.cc index c83674fa9c1..682b0626ccd 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.cc +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.cc @@ -196,7 +196,7 @@ void register_node_type_cmp_viewer() ntype.draw_buttons = file_ns::node_composit_buts_viewer; ntype.draw_buttons_ex = file_ns::node_composit_buts_viewer_ex; ntype.flag |= NODE_PREVIEW; - node_type_init(&ntype, file_ns::node_composit_init_viewer); + ntype.initfunc = file_ns::node_composit_init_viewer; node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); ntype.get_compositor_operation = file_ns::get_compositor_operation; diff --git a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc index 7fc7829186a..3027a81807b 100644 --- a/source/blender/nodes/function/nodes/node_fn_boolean_math.cc +++ b/source/blender/nodes/function/nodes/node_fn_boolean_math.cc @@ -131,7 +131,7 @@ void register_node_type_fn_boolean_math() fn_node_type_base(&ntype, FN_NODE_BOOLEAN_MATH, "Boolean Math", NODE_CLASS_CONVERTER); ntype.declare = file_ns::fn_node_boolean_math_declare; ntype.labelfunc = file_ns::node_boolean_math_label; - node_type_update(&ntype, file_ns::node_boolean_math_update); + ntype.updatefunc = file_ns::node_boolean_math_update; ntype.build_multi_function = file_ns::fn_node_boolean_math_build_multi_function; ntype.draw_buttons = file_ns::fn_node_boolean_math_layout; ntype.gather_link_search_ops = file_ns::node_gather_link_searches; diff --git a/source/blender/nodes/function/nodes/node_fn_combine_color.cc b/source/blender/nodes/function/nodes/node_fn_combine_color.cc index fddf606dfc9..c5dd5dfff1a 100644 --- a/source/blender/nodes/function/nodes/node_fn_combine_color.cc +++ b/source/blender/nodes/function/nodes/node_fn_combine_color.cc @@ -97,8 +97,8 @@ void register_node_type_fn_combine_color(void) fn_node_type_base(&ntype, FN_NODE_COMBINE_COLOR, "Combine Color", NODE_CLASS_CONVERTER); ntype.declare = blender::nodes::fn_node_combine_color_declare; - node_type_update(&ntype, blender::nodes::fn_node_combine_color_update); - node_type_init(&ntype, blender::nodes::fn_node_combine_color_init); + ntype.updatefunc = blender::nodes::fn_node_combine_color_update; + ntype.initfunc = blender::nodes::fn_node_combine_color_init; node_type_storage( &ntype, "NodeCombSepColor", node_free_standard_storage, node_copy_standard_storage); ntype.build_multi_function = blender::nodes::fn_node_combine_color_build_multi_function; diff --git a/source/blender/nodes/function/nodes/node_fn_compare.cc b/source/blender/nodes/function/nodes/node_fn_compare.cc index 4dd8d0c6ba4..c0eb3e9ffd5 100644 --- a/source/blender/nodes/function/nodes/node_fn_compare.cc +++ b/source/blender/nodes/function/nodes/node_fn_compare.cc @@ -582,8 +582,8 @@ void register_node_type_fn_compare() fn_node_type_base(&ntype, FN_NODE_COMPARE, "Compare", NODE_CLASS_CONVERTER); ntype.declare = file_ns::fn_node_compare_declare; ntype.labelfunc = file_ns::node_compare_label; - node_type_update(&ntype, file_ns::node_compare_update); - node_type_init(&ntype, file_ns::node_compare_init); + ntype.updatefunc = file_ns::node_compare_update; + ntype.initfunc = file_ns::node_compare_init; node_type_storage( &ntype, "NodeFunctionCompare", node_free_standard_storage, node_copy_standard_storage); ntype.build_multi_function = file_ns::fn_node_compare_build_multi_function; diff --git a/source/blender/nodes/function/nodes/node_fn_input_bool.cc b/source/blender/nodes/function/nodes/node_fn_input_bool.cc index c68de06a91b..62e0358b0ae 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_bool.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_bool.cc @@ -43,7 +43,7 @@ void register_node_type_fn_input_bool() fn_node_type_base(&ntype, FN_NODE_INPUT_BOOL, "Boolean", 0); ntype.declare = file_ns::fn_node_input_bool_declare; - node_type_init(&ntype, file_ns::fn_node_input_bool_init); + ntype.initfunc = file_ns::fn_node_input_bool_init; node_type_storage( &ntype, "NodeInputBool", node_free_standard_storage, node_copy_standard_storage); ntype.build_multi_function = file_ns::fn_node_input_bool_build_multi_function; diff --git a/source/blender/nodes/function/nodes/node_fn_input_color.cc b/source/blender/nodes/function/nodes/node_fn_input_color.cc index 9a66066189a..af4c340efe7 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_color.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_color.cc @@ -46,7 +46,7 @@ void register_node_type_fn_input_color() fn_node_type_base(&ntype, FN_NODE_INPUT_COLOR, "Color", NODE_CLASS_INPUT); ntype.declare = file_ns::fn_node_input_color_declare; - node_type_init(&ntype, file_ns::fn_node_input_color_init); + ntype.initfunc = file_ns::fn_node_input_color_init; node_type_storage( &ntype, "NodeInputColor", node_free_standard_storage, node_copy_standard_storage); ntype.build_multi_function = file_ns::fn_node_input_color_build_multi_function; diff --git a/source/blender/nodes/function/nodes/node_fn_input_int.cc b/source/blender/nodes/function/nodes/node_fn_input_int.cc index 5285c242d88..c339d2a348e 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_int.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_int.cc @@ -43,7 +43,7 @@ void register_node_type_fn_input_int() fn_node_type_base(&ntype, FN_NODE_INPUT_INT, "Integer", 0); ntype.declare = file_ns::fn_node_input_int_declare; - node_type_init(&ntype, file_ns::fn_node_input_int_init); + ntype.initfunc = file_ns::fn_node_input_int_init; node_type_storage( &ntype, "NodeInputInt", node_free_standard_storage, node_copy_standard_storage); ntype.build_multi_function = file_ns::fn_node_input_int_build_multi_function; diff --git a/source/blender/nodes/function/nodes/node_fn_input_string.cc b/source/blender/nodes/function/nodes/node_fn_input_string.cc index a7172d9fcf9..9da17ef9a67 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_string.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_string.cc @@ -65,7 +65,7 @@ void register_node_type_fn_input_string() fn_node_type_base(&ntype, FN_NODE_INPUT_STRING, "String", NODE_CLASS_INPUT); ntype.declare = file_ns::fn_node_input_string_declare; - node_type_init(&ntype, file_ns::fn_node_input_string_init); + ntype.initfunc = file_ns::fn_node_input_string_init; node_type_storage( &ntype, "NodeInputString", file_ns::fn_node_input_string_free, file_ns::fn_node_string_copy); ntype.build_multi_function = file_ns::fn_node_input_string_build_multi_function; diff --git a/source/blender/nodes/function/nodes/node_fn_input_vector.cc b/source/blender/nodes/function/nodes/node_fn_input_vector.cc index 49c8a6284e0..f6feda4cad0 100644 --- a/source/blender/nodes/function/nodes/node_fn_input_vector.cc +++ b/source/blender/nodes/function/nodes/node_fn_input_vector.cc @@ -44,7 +44,7 @@ void register_node_type_fn_input_vector() fn_node_type_base(&ntype, FN_NODE_INPUT_VECTOR, "Vector", 0); ntype.declare = file_ns::fn_node_input_vector_declare; - node_type_init(&ntype, file_ns::fn_node_input_vector_init); + ntype.initfunc = file_ns::fn_node_input_vector_init; node_type_storage( &ntype, "NodeInputVector", node_free_standard_storage, node_copy_standard_storage); ntype.build_multi_function = file_ns::fn_node_input_vector_build_multi_function; diff --git a/source/blender/nodes/function/nodes/node_fn_random_value.cc b/source/blender/nodes/function/nodes/node_fn_random_value.cc index 9f842e81071..c923e6e7d16 100644 --- a/source/blender/nodes/function/nodes/node_fn_random_value.cc +++ b/source/blender/nodes/function/nodes/node_fn_random_value.cc @@ -218,8 +218,8 @@ void register_node_type_fn_random_value() static bNodeType ntype; fn_node_type_base(&ntype, FN_NODE_RANDOM_VALUE, "Random Value", NODE_CLASS_CONVERTER); - node_type_init(&ntype, file_ns::fn_node_random_value_init); - node_type_update(&ntype, file_ns::fn_node_random_value_update); + ntype.initfunc = file_ns::fn_node_random_value_init; + ntype.updatefunc = file_ns::fn_node_random_value_update; ntype.draw_buttons = file_ns::fn_node_random_value_layout; ntype.declare = file_ns::fn_node_random_value_declare; ntype.build_multi_function = file_ns::fn_node_random_value_build_multi_function; diff --git a/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc b/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc index 813d0a265f7..19afadb7a33 100644 --- a/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc +++ b/source/blender/nodes/function/nodes/node_fn_rotate_euler.cc @@ -132,7 +132,7 @@ void register_node_type_fn_rotate_euler() fn_node_type_base(&ntype, FN_NODE_ROTATE_EULER, "Rotate Euler", NODE_CLASS_CONVERTER); ntype.declare = file_ns::fn_node_rotate_euler_declare; ntype.draw_buttons = file_ns::fn_node_rotate_euler_layout; - node_type_update(&ntype, file_ns::fn_node_rotate_euler_update); + ntype.updatefunc = file_ns::fn_node_rotate_euler_update; ntype.build_multi_function = file_ns::fn_node_rotate_euler_build_multi_function; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/function/nodes/node_fn_separate_color.cc b/source/blender/nodes/function/nodes/node_fn_separate_color.cc index 19753f93b5c..e3efb76d155 100644 --- a/source/blender/nodes/function/nodes/node_fn_separate_color.cc +++ b/source/blender/nodes/function/nodes/node_fn_separate_color.cc @@ -213,8 +213,8 @@ void register_node_type_fn_separate_color(void) fn_node_type_base(&ntype, FN_NODE_SEPARATE_COLOR, "Separate Color", NODE_CLASS_CONVERTER); ntype.declare = blender::nodes::fn_node_separate_color_declare; - node_type_update(&ntype, blender::nodes::fn_node_separate_color_update); - node_type_init(&ntype, blender::nodes::fn_node_separate_color_init); + ntype.updatefunc = blender::nodes::fn_node_separate_color_update; + ntype.initfunc = blender::nodes::fn_node_separate_color_init; node_type_storage( &ntype, "NodeCombSepColor", node_free_standard_storage, node_copy_standard_storage); ntype.build_multi_function = blender::nodes::fn_node_separate_color_build_multi_function; diff --git a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc index 9af445090e9..33a58cada1b 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_accumulate_field.cc @@ -425,8 +425,8 @@ void register_node_type_geo_accumulate_field() geo_node_type_base(&ntype, GEO_NODE_ACCUMULATE_FIELD, "Accumulate Field", NODE_CLASS_CONVERTER); ntype.geometry_node_execute = file_ns::node_geo_exec; - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.draw_buttons = file_ns::node_layout; ntype.declare = file_ns::node_declare; ntype.gather_link_search_ops = file_ns::node_gather_link_searches; diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc index 1aea129bd53..1a0cb14f451 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_capture.cc @@ -241,8 +241,8 @@ void register_node_type_geo_attribute_capture() "NodeGeometryAttributeCapture", node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc index af55ef3f7ed..d31366f9c93 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_domain_size.cc @@ -132,7 +132,7 @@ void register_node_type_geo_attribute_domain_size() ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_layout; - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc index 3023c7bd751..e381133af30 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_attribute_statistic.cc @@ -396,8 +396,8 @@ void register_node_type_geo_attribute_statistic() &ntype, GEO_NODE_ATTRIBUTE_STATISTIC, "Attribute Statistic", NODE_CLASS_ATTRIBUTE); ntype.declare = file_ns::node_declare; - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; ntype.gather_link_search_ops = file_ns::node_gather_link_searches; diff --git a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc index 094aab65653..61780ee25bb 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_boolean.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_boolean.cc @@ -191,7 +191,7 @@ void register_node_type_geo_boolean() ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_layout; ntype.updatefunc = file_ns::node_update; - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; ntype.geometry_node_execute = file_ns::node_geo_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc index 1129e954360..6c41dbbe34c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_collection_info.cc @@ -150,7 +150,7 @@ void register_node_type_geo_collection_info() geo_node_type_base(&ntype, GEO_NODE_COLLECTION_INFO, "Collection Info", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_init(&ntype, file_ns::node_node_init); + ntype.initfunc = file_ns::node_node_init; node_type_storage(&ntype, "NodeGeometryCollectionInfo", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_common.cc b/source/blender/nodes/geometry/nodes/node_geo_common.cc index 531d37c3a89..90fb7e10570 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_common.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_common.cc @@ -23,7 +23,7 @@ void register_node_type_geo_group() node_type_size(&ntype, 140, 60, 400); ntype.labelfunc = node_group_label; - node_type_group_update(&ntype, node_group_update); + ntype.group_update_func = node_group_update; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc index 038309785fb..278d7c4bd24 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_convex_hull.cc @@ -87,7 +87,7 @@ static Mesh *hull_from_bullet(const Mesh *mesh, Span<float3> coords) MEdge &edge = edges[edge_index]; edge.v1 = v_from; edge.v2 = v_to; - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; /* Write edge index into both loops that have it. */ int reverse_index = plConvexHullGetReversedLoopIndex(hull, i); @@ -101,7 +101,7 @@ static Mesh *hull_from_bullet(const Mesh *mesh, Span<float3> coords) MEdge &edge = edges[0]; edge.v1 = 0; edge.v2 = 1; - edge.flag |= ME_EDGEDRAW | ME_EDGERENDER | ME_LOOSEEDGE; + edge.flag |= ME_EDGEDRAW | ME_LOOSEEDGE; edge_index++; } BLI_assert(edge_index == edges_num); diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc index 6eaa40bff03..a14661b4a50 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fill.cc @@ -90,7 +90,7 @@ static Mesh *cdt_to_mesh(const meshintersect::CDT_result<double> &result) for (const int i : IndexRange(result.edge.size())) { edges[i].v1 = result.edge[i].first; edges[i].v2 = result.edge[i].second; - edges[i].flag = ME_EDGEDRAW | ME_EDGERENDER; + edges[i].flag = ME_EDGEDRAW; } int i_loop = 0; for (const int i : IndexRange(result.face.size())) { @@ -155,7 +155,7 @@ void register_node_type_geo_curve_fill() geo_node_type_base(&ntype, GEO_NODE_FILL_CURVE, "Fill Curve", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_storage( &ntype, "NodeGeometryCurveFill", node_free_standard_storage, node_copy_standard_storage); ntype.declare = file_ns::node_declare; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc index 2b24b6cbf42..7a6fa799013 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_fillet.cc @@ -121,8 +121,8 @@ void register_node_type_geo_curve_fillet() node_type_storage( &ntype, "NodeGeometryCurveFillet", node_free_standard_storage, node_copy_standard_storage); ntype.declare = file_ns::node_declare; - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.geometry_node_execute = file_ns::node_geo_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc index 252f66c308f..9f0d40bb0d7 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_handle_type_selection.cc @@ -138,7 +138,7 @@ void register_node_type_geo_curve_handle_type_selection() &ntype, GEO_NODE_CURVE_HANDLE_TYPE_SELECTION, "Handle Type Selection", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_storage(&ntype, "NodeGeometryCurveSelectHandles", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc index cc32c8f5efc..e0148730710 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_arc.cc @@ -359,8 +359,8 @@ void register_node_type_geo_curve_primitive_arc() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_PRIMITIVE_ARC, "Arc", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; node_type_storage(&ntype, "NodeGeometryCurvePrimitiveArc", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc index b407ac47dc9..59c17365261 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_bezier_segment.cc @@ -119,7 +119,7 @@ void register_node_type_geo_curve_primitive_bezier_segment() static bNodeType ntype; geo_node_type_base( &ntype, GEO_NODE_CURVE_PRIMITIVE_BEZIER_SEGMENT, "Bezier Segment", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_storage(&ntype, "NodeGeometryCurvePrimitiveBezierSegment", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc index 35fdd6754cc..75f2116b237 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc @@ -217,8 +217,8 @@ void register_node_type_geo_curve_primitive_circle() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_PRIMITIVE_CIRCLE, "Curve Circle", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; node_type_storage(&ntype, "NodeGeometryCurvePrimitiveCircle", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc index 6b402a67450..d4ce1923178 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_line.cc @@ -119,8 +119,8 @@ void register_node_type_geo_curve_primitive_line() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_CURVE_PRIMITIVE_LINE, "Curve Line", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; node_type_storage(&ntype, "NodeGeometryCurvePrimitiveLine", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc index 44c2a078cb6..d4e37a98372 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_quadrilateral.cc @@ -274,8 +274,8 @@ void register_node_type_geo_curve_primitive_quadrilateral() ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; - node_type_update(&ntype, file_ns::node_update); - node_type_init(&ntype, file_ns::node_init); + ntype.updatefunc = file_ns::node_update; + ntype.initfunc = file_ns::node_init; node_type_storage(&ntype, "NodeGeometryCurvePrimitiveQuad", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc index 8b6a7064362..23a71af448d 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_resample.cc @@ -123,8 +123,8 @@ void register_node_type_geo_curve_resample() ntype.draw_buttons = file_ns::node_layout; node_type_storage( &ntype, "NodeGeometryCurveResample", node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.geometry_node_execute = file_ns::node_geo_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc index 3170d0aecac..bb31d9c1a57 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_sample.cc @@ -62,7 +62,7 @@ static void node_layout(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr) uiItemR(layout, ptr, "use_all_curves", 0, nullptr, ICON_NONE); } -static void node_type_init(bNodeTree * /*tree*/, bNode *node) +static void node_init(bNodeTree * /*tree*/, bNode *node) { NodeGeometryCurveSample *data = MEM_cnew<NodeGeometryCurveSample>(__func__); data->mode = GEO_NODE_CURVE_SAMPLE_FACTOR; @@ -570,8 +570,8 @@ void register_node_type_geo_curve_sample() geo_node_type_base(&ntype, GEO_NODE_SAMPLE_CURVE, "Sample Curve", NODE_CLASS_GEOMETRY); ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.declare = file_ns::node_declare; - node_type_init(&ntype, file_ns::node_type_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; node_type_storage( &ntype, "NodeGeometryCurveSample", node_free_standard_storage, node_copy_standard_storage); ntype.draw_buttons = file_ns::node_layout; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc index d37af6e5fe8..46377329fb4 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_set_handle_type.cc @@ -120,7 +120,7 @@ void register_node_type_geo_curve_set_handle_type() &ntype, GEO_NODE_CURVE_SET_HANDLE_TYPE, "Set Handle Type", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_storage(&ntype, "NodeGeometryCurveSetHandles", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc index 9ac6516ee7b..4b8251aadd3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_spline_type.cc @@ -87,7 +87,7 @@ void register_node_type_geo_curve_spline_type() geo_node_type_base(&ntype, GEO_NODE_CURVE_SPLINE_TYPE, "Set Spline Type", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_storage(&ntype, "NodeGeometryCurveSplineType", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc index e9eaa00b02d..268c927f782 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_to_points.cc @@ -216,7 +216,7 @@ void register_node_type_geo_curve_to_points() ntype.draw_buttons = file_ns::node_layout; node_type_storage( &ntype, "NodeGeometryCurveToPoints", node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc index 15c89d78276..3ec71877b7c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_trim.cc @@ -202,8 +202,8 @@ void register_node_type_geo_curve_trim() ntype.declare = file_ns::node_declare; node_type_storage( &ntype, "NodeGeometryCurveTrim", node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.gather_link_search_ops = file_ns::node_gather_link_searches; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc index 3e48a9fd923..8ed97f2019f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc @@ -1202,7 +1202,7 @@ void register_node_type_geo_delete_geometry() node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc index 95173bd23a5..f2e66e03d26 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_in_volume.cc @@ -278,8 +278,8 @@ void register_node_type_geo_distribute_points_in_volume() "NodeGeometryDistributePointsInVolume", node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, blender::nodes::node_distribute_points_in_volume_init); - node_type_update(&ntype, blender::nodes::node_distribute_points_in_volume_update); + ntype.initfunc = blender::nodes::node_distribute_points_in_volume_init; + ntype.updatefunc = blender::nodes::node_distribute_points_in_volume_update; node_type_size(&ntype, 170, 100, 320); ntype.declare = blender::nodes::geo_node_distribute_points_in_volume_declare; ntype.geometry_node_execute = blender::nodes::geo_node_distribute_points_in_volume_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc index c2cc70296ed..7c9501608a3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_distribute_points_on_faces.cc @@ -563,7 +563,7 @@ void register_node_type_geo_distribute_points_on_faces() GEO_NODE_DISTRIBUTE_POINTS_ON_FACES, "Distribute Points on Faces", NODE_CLASS_GEOMETRY); - node_type_update(&ntype, file_ns::node_point_distribute_points_on_faces_update); + ntype.updatefunc = file_ns::node_point_distribute_points_on_faces_update; node_type_size(&ntype, 170, 100, 320); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc index 486f900aca5..f048ec11f77 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_duplicate_elements.cc @@ -1149,7 +1149,7 @@ void register_node_type_geo_duplicate_elements() node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; ntype.draw_buttons = file_ns::node_layout; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.declare = file_ns::node_declare; diff --git a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc index 151ba3e59cc..0062abba909 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_extrude_mesh.cc @@ -154,7 +154,7 @@ static MEdge new_edge(const int v1, const int v2) MEdge edge; edge.v1 = v1; edge.v2 = v2; - edge.flag = (ME_EDGEDRAW | ME_EDGERENDER); + edge.flag = ME_EDGEDRAW; return edge; } @@ -1380,8 +1380,8 @@ void register_node_type_geo_extrude_mesh() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_EXTRUDE_MESH, "Extrude Mesh", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.geometry_node_execute = file_ns::node_geo_exec; node_type_storage( &ntype, "NodeGeometryExtrudeMesh", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc index f39337d3fc3..0d339620047 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_image_texture.cc @@ -402,7 +402,7 @@ void register_node_type_geo_image_texture() geo_node_type_base(&ntype, GEO_NODE_IMAGE_TEXTURE, "Image Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_layout; - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_storage( &ntype, "NodeGeometryImageTexture", node_free_standard_storage, node_copy_standard_storage); node_type_size_preset(&ntype, NODE_SIZE_LARGE); diff --git a/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc index 1063a022e9d..9d1f90ba0f3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_input_named_attribute.cc @@ -126,7 +126,7 @@ void register_node_type_geo_input_named_attribute() ntype.draw_buttons = file_ns::node_layout; ntype.gather_link_search_ops = file_ns::node_gather_link_searches; ntype.updatefunc = file_ns::node_update; - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_storage(&ntype, "NodeGeometryInputNamedAttribute", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc b/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc index ce8b078f195..8ab8c4afaa9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_merge_by_distance.cc @@ -132,7 +132,7 @@ void register_node_type_geo_merge_by_distance() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_MERGE_BY_DISTANCE, "Merge by Distance", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_storage(&ntype, "NodeGeometryMergeByDistance", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc index 31a3e967905..14f38efbd42 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_circle.cc @@ -127,7 +127,7 @@ static Mesh *create_circle_mesh(const float radius, /* Create outer edges. */ const short edge_flag = (fill_type == GEO_NODE_MESH_CIRCLE_FILL_NONE) ? ME_LOOSEEDGE : - (ME_EDGEDRAW | ME_EDGERENDER); /* NGON or TRIANGLE_FAN */ + ME_EDGEDRAW; /* NGON or TRIANGLE_FAN */ for (const int i : IndexRange(verts_num)) { MEdge &edge = edges[i]; edge.v1 = i; @@ -141,7 +141,7 @@ static Mesh *create_circle_mesh(const float radius, MEdge &edge = edges[verts_num + i]; edge.v1 = verts_num; edge.v2 = i; - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } } @@ -205,7 +205,7 @@ void register_node_type_geo_mesh_primitive_circle() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_MESH_PRIMITIVE_CIRCLE, "Mesh Circle", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_storage( &ntype, "NodeGeometryMeshCircle", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = file_ns::node_geo_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc index 4a9264b8464..dca91d2dc61 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cone.cc @@ -329,7 +329,7 @@ static void calculate_cone_edges(const MutableSpan<MEdge> &edges, const ConeConf MEdge &edge = edges[edge_index++]; edge.v1 = config.first_vert; edge.v2 = config.first_ring_verts_start + i; - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } } @@ -342,7 +342,7 @@ static void calculate_cone_edges(const MutableSpan<MEdge> &edges, const ConeConf MEdge &edge = edges[edge_index++]; edge.v1 = this_ring_vert_start + j; edge.v2 = this_ring_vert_start + ((j + 1) % config.circle_segments); - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } if (i == config.tot_edge_rings - 1) { /* There is one fewer ring of connecting edges. */ @@ -353,7 +353,7 @@ static void calculate_cone_edges(const MutableSpan<MEdge> &edges, const ConeConf MEdge &edge = edges[edge_index++]; edge.v1 = this_ring_vert_start + j; edge.v2 = next_ring_vert_start + j; - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } } @@ -363,7 +363,7 @@ static void calculate_cone_edges(const MutableSpan<MEdge> &edges, const ConeConf MEdge &edge = edges[edge_index++]; edge.v1 = config.last_ring_verts_start + i; edge.v2 = config.last_vert; - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } } } @@ -854,8 +854,8 @@ void register_node_type_geo_mesh_primitive_cone() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_MESH_PRIMITIVE_CONE, "Cone", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; node_type_storage( &ntype, "NodeGeometryMeshCone", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = file_ns::node_geo_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc index f192b385b1b..b02b1fbae27 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_cylinder.cc @@ -154,8 +154,8 @@ void register_node_type_geo_mesh_primitive_cylinder() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_MESH_PRIMITIVE_CYLINDER, "Cylinder", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; node_type_storage( &ntype, "NodeGeometryMeshCylinder", node_free_standard_storage, node_copy_standard_storage); ntype.declare = file_ns::node_declare; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc index 6f0b8283b72..e8ee057ee5c 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_grid.cc @@ -76,8 +76,7 @@ Mesh *create_grid_mesh(const int verts_x, const int y_edges_start = 0; const int x_edges_start = verts_x * edges_y; - const short edge_flag = (edges_x == 0 || edges_y == 0) ? ME_LOOSEEDGE : - ME_EDGEDRAW | ME_EDGERENDER; + const short edge_flag = (edges_x == 0 || edges_y == 0) ? ME_LOOSEEDGE : ME_EDGEDRAW; /* Build the horizontal edges in the X direction. */ threading::parallel_for(IndexRange(verts_x), 512, [&](IndexRange x_range) { diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc index 7faa7e23274..51a4f36507e 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_line.cc @@ -214,8 +214,8 @@ void register_node_type_geo_mesh_primitive_line() geo_node_type_base(&ntype, GEO_NODE_MESH_PRIMITIVE_LINE, "Mesh Line", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; node_type_storage( &ntype, "NodeGeometryMeshLine", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = file_ns::node_geo_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc index 4b43693f0f6..cfa1c477b28 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_uv_sphere.cc @@ -116,7 +116,7 @@ BLI_NOINLINE static void calculate_sphere_edge_indices(MutableSpan<MEdge> edges, MEdge &edge = edges[edge_index++]; edge.v1 = 0; edge.v2 = first_vert_ring_index_start + segment; - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } int ring_vert_index_start = 1; @@ -128,7 +128,7 @@ BLI_NOINLINE static void calculate_sphere_edge_indices(MutableSpan<MEdge> edges, MEdge &edge = edges[edge_index++]; edge.v1 = ring_vert_index_start + segment; edge.v2 = ring_vert_index_start + ((segment + 1) % segments); - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } /* Add the edges connecting to the next ring. */ @@ -137,7 +137,7 @@ BLI_NOINLINE static void calculate_sphere_edge_indices(MutableSpan<MEdge> edges, MEdge &edge = edges[edge_index++]; edge.v1 = ring_vert_index_start + segment; edge.v2 = next_ring_vert_index_start + segment; - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } } ring_vert_index_start += segments; @@ -150,7 +150,7 @@ BLI_NOINLINE static void calculate_sphere_edge_indices(MutableSpan<MEdge> edges, MEdge &edge = edges[edge_index++]; edge.v1 = last_vert_index; edge.v2 = last_vert_ring_start + segment; - edge.flag = ME_EDGEDRAW | ME_EDGERENDER; + edge.flag = ME_EDGEDRAW; } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc index d97a0e72060..d47e0c0f101 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_points.cc @@ -163,7 +163,7 @@ void register_node_type_geo_mesh_to_points() geo_node_type_base(&ntype, GEO_NODE_MESH_TO_POINTS, "Mesh to Points", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; ntype.draw_buttons = file_ns::node_layout; node_type_storage( &ntype, "NodeGeometryMeshToPoints", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc index 8885903f828..cf4d058cd31 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_mesh_to_volume.cc @@ -174,8 +174,8 @@ void register_node_type_geo_mesh_to_volume() geo_node_type_base(&ntype, GEO_NODE_MESH_TO_VOLUME, "Mesh to Volume", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; node_type_size(&ntype, 200, 120, 700); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; node_type_storage( diff --git a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc index 83a2ddb1629..f1a9987e721 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_object_info.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_object_info.cc @@ -106,7 +106,7 @@ void register_node_type_geo_object_info() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_OBJECT_INFO, "Object Info", NODE_CLASS_INPUT); - node_type_init(&ntype, file_ns::node_node_init); + ntype.initfunc = file_ns::node_node_init; node_type_storage( &ntype, "NodeGeometryObjectInfo", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = file_ns::node_geo_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc index 45f6820f2e5..d0b7f6a455f 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_volume.cc @@ -258,8 +258,8 @@ void register_node_type_geo_points_to_volume() node_free_standard_storage, node_copy_standard_storage); node_type_size(&ntype, 170, 120, 700); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; diff --git a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc index 21f4449baee..92a409f9db6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_proximity.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_proximity.cc @@ -228,7 +228,7 @@ void register_node_type_geo_proximity() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_PROXIMITY, "Geometry Proximity", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::geo_proximity_init); + ntype.initfunc = file_ns::geo_proximity_init; node_type_storage( &ntype, "NodeGeometryProximity", node_free_standard_storage, node_copy_standard_storage); ntype.declare = file_ns::node_declare; diff --git a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc index d248bc539b1..b3dbc9ee866 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_raycast.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_raycast.cc @@ -435,8 +435,8 @@ void register_node_type_geo_raycast() geo_node_type_base(&ntype, GEO_NODE_RAYCAST, "Raycast", NODE_CLASS_GEOMETRY); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; node_type_storage( &ntype, "NodeGeometryRaycast", node_free_standard_storage, node_copy_standard_storage); ntype.declare = file_ns::node_declare; diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc index 4d2db059798..22c18504985 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_index.cc @@ -325,8 +325,8 @@ void register_node_type_geo_sample_index() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_SAMPLE_INDEX, "Sample Index", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.declare = file_ns::node_declare; node_type_storage( &ntype, "NodeGeometrySampleIndex", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc index 8c5dad3a1c5..7028b013dc6 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest.cc @@ -334,7 +334,7 @@ void register_node_type_geo_sample_nearest() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_SAMPLE_NEAREST, "Sample Nearest", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc index 95bf7199d63..503f6264191 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_nearest_surface.cc @@ -267,8 +267,8 @@ void register_node_type_geo_sample_nearest_surface() geo_node_type_base( &ntype, GEO_NODE_SAMPLE_NEAREST_SURFACE, "Sample Nearest Surface", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); ntype.geometry_node_execute = file_ns::node_geo_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc index 2e8446ba559..0a6dd569395 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_sample_uv_surface.cc @@ -284,8 +284,8 @@ void register_node_type_geo_sample_uv_surface() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_SAMPLE_UV_SURFACE, "Sample UV Surface", NODE_CLASS_GEOMETRY); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; diff --git a/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc index 44d12466d9e..d4da5dda647 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_separate_geometry.cc @@ -87,7 +87,7 @@ void register_node_type_geo_separate_geometry() node_free_standard_storage, node_copy_standard_storage); - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc index c143203337a..48be899bec9 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_handles.cc @@ -174,7 +174,7 @@ void register_node_type_geo_set_curve_handles() ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.declare = file_ns::node_declare; ntype.minwidth = 100.0f; - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_storage(&ntype, "NodeGeometrySetCurveHandlePositions", node_free_standard_storage, diff --git a/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc b/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc index e2169966f5a..287c5920134 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_set_curve_normal.cc @@ -66,7 +66,7 @@ void register_node_type_geo_set_curve_normal() geo_node_type_base(&ntype, GEO_NODE_SET_CURVE_NORMAL, "Set Curve Normal", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; ntype.draw_buttons = file_ns::node_layout; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc index 3c85fd459e1..b71dba98daa 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_store_named_attribute.cc @@ -192,7 +192,7 @@ void register_node_type_geo_store_named_attribute() node_free_standard_storage, node_copy_standard_storage); node_type_size(&ntype, 140, 100, 700); - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; ntype.updatefunc = file_ns::node_update; ntype.declare = file_ns::node_declare; ntype.gather_link_search_ops = file_ns::node_gather_link_searches; diff --git a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc index 769a63f58cf..405c2761711 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_string_to_curves.cc @@ -405,8 +405,8 @@ void register_node_type_geo_string_to_curves() geo_node_type_base(&ntype, GEO_NODE_STRING_TO_CURVES, "String to Curves", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; node_type_size(&ntype, 190, 120, 700); node_type_storage(&ntype, "NodeGeometryStringToCurves", diff --git a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc index 2e6ad02bfd5..7b4608d32a5 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_subdivision_surface.cc @@ -191,7 +191,7 @@ void register_node_type_geo_subdivision_surface() ntype.declare = file_ns::node_declare; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); node_type_storage(&ntype, "NodeGeometrySubdivisionSurface", diff --git a/source/blender/nodes/geometry/nodes/node_geo_switch.cc b/source/blender/nodes/geometry/nodes/node_geo_switch.cc index 36be68f1a22..bd3ac271817 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_switch.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_switch.cc @@ -290,8 +290,8 @@ void register_node_type_geo_switch() geo_node_type_base(&ntype, GEO_NODE_SWITCH, "Switch", NODE_CLASS_CONVERTER); ntype.declare = file_ns::node_declare; - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; node_type_storage(&ntype, "NodeSwitch", node_free_standard_storage, node_copy_standard_storage); ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.geometry_node_execute_supports_laziness = true; diff --git a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc index cedc1ef845b..5cb78b3abe8 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_triangulate.cc @@ -100,7 +100,7 @@ void register_node_type_geo_triangulate() geo_node_type_base(&ntype, GEO_NODE_TRIANGULATE, "Triangulate", NODE_CLASS_GEOMETRY); ntype.declare = file_ns::node_declare; - node_type_init(&ntype, file_ns::geo_triangulate_init); + ntype.initfunc = file_ns::geo_triangulate_init; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc index e45ce6b42b4..eff3b969250 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_uv_unwrap.cc @@ -189,7 +189,7 @@ void register_node_type_geo_uv_unwrap() static bNodeType ntype; geo_node_type_base(&ntype, GEO_NODE_UV_UNWRAP, "UV Unwrap", NODE_CLASS_CONVERTER); - node_type_init(&ntype, file_ns::node_init); + ntype.initfunc = file_ns::node_init; node_type_storage( &ntype, "NodeGeometryUVUnwrap", node_free_standard_storage, node_copy_standard_storage); ntype.declare = file_ns::node_declare; diff --git a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc index e9050f9e6a1..53a8cd79f52 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_viewer.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_viewer.cc @@ -135,8 +135,8 @@ void register_node_type_geo_viewer() geo_node_type_base(&ntype, GEO_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT); node_type_storage( &ntype, "NodeGeometryViewer", node_free_standard_storage, node_copy_standard_storage); - node_type_update(&ntype, file_ns::node_update); - node_type_init(&ntype, file_ns::node_init); + ntype.updatefunc = file_ns::node_update; + ntype.initfunc = file_ns::node_init; ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_layout; ntype.draw_buttons_ex = file_ns::node_layout_ex; diff --git a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc index 88e7718ed3c..c076a6c08f3 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_volume_to_mesh.cc @@ -215,8 +215,8 @@ void register_node_type_geo_volume_to_mesh() node_type_storage( &ntype, "NodeGeometryVolumeToMesh", node_free_standard_storage, node_copy_standard_storage); node_type_size(&ntype, 170, 120, 700); - node_type_init(&ntype, file_ns::node_init); - node_type_update(&ntype, file_ns::node_update); + ntype.initfunc = file_ns::node_init; + ntype.updatefunc = file_ns::node_update; ntype.geometry_node_execute = file_ns::node_geo_exec; ntype.draw_buttons = file_ns::node_layout; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/intern/node_common.cc b/source/blender/nodes/intern/node_common.cc index d7cc0b6065a..975bf0c01ca 100644 --- a/source/blender/nodes/intern/node_common.cc +++ b/source/blender/nodes/intern/node_common.cc @@ -22,6 +22,7 @@ #include "BLT_translation.h" #include "BKE_node.h" +#include "BKE_node_runtime.hh" #include "BKE_node_tree_update.h" #include "RNA_types.h" @@ -86,8 +87,6 @@ bool nodeGroupPoll(const bNodeTree *nodetree, const bNodeTree *grouptree, const char **r_disabled_hint) { - bool valid = true; - /* unspecified node group, generally allowed * (if anything, should be avoided on operator level) */ @@ -106,11 +105,10 @@ bool nodeGroupPoll(const bNodeTree *nodetree, if (node->typeinfo->poll_instance && !node->typeinfo->poll_instance( const_cast<bNode *>(node), const_cast<bNodeTree *>(nodetree), r_disabled_hint)) { - valid = false; - break; + return false; } } - return valid; + return true; } static void add_new_socket_from_interface(bNodeTree &node_tree, @@ -255,7 +253,7 @@ void register_node_type_frame() ntype->free_self = (void (*)(bNodeType *))MEM_freeN; node_type_base(ntype, NODE_FRAME, "Frame", NODE_CLASS_LAYOUT); - node_type_init(ntype, node_frame_init); + ntype->initfunc = node_frame_init; node_type_storage(ntype, "NodeFrame", node_free_standard_storage, node_copy_standard_storage); node_type_size(ntype, 150, 100, 0); ntype->flag |= NODE_BACKGROUND; @@ -285,7 +283,7 @@ void register_node_type_reroute() ntype->free_self = (void (*)(bNodeType *))MEM_freeN; node_type_base(ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT); - node_type_init(ntype, node_reroute_init); + ntype->initfunc = node_reroute_init; nodeRegisterType(ntype); } @@ -381,53 +379,29 @@ void ntree_update_reroute_nodes(bNodeTree *ntree) } } -static bool node_is_connected_to_output_recursive(bNodeTree *ntree, bNode *node) +bool BKE_node_is_connected_to_output(const bNodeTree *ntree, const bNode *node) { - bNodeLink *link; - - /* avoid redundant checks, and infinite loops in case of cyclic node links */ - if (node->done) { - return false; - } - node->done = 1; - - /* main test, done before child loop so it catches output nodes themselves as well */ - if (node->typeinfo->nclass == NODE_CLASS_OUTPUT && node->flag & NODE_DO_OUTPUT) { - return true; + ntree->ensure_topology_cache(); + Stack<const bNode *> nodes_to_check; + for (const bNodeSocket *socket : node->output_sockets()) { + for (const bNodeLink *link : socket->directly_linked_links()) { + nodes_to_check.push(link->tonode); + } } - - /* test all connected nodes, first positive find is sufficient to return true */ - for (link = (bNodeLink *)ntree->links.first; link; link = link->next) { - if (link->fromnode == node) { - if (node_is_connected_to_output_recursive(ntree, link->tonode)) { - return true; + while (!nodes_to_check.is_empty()) { + const bNode *next_node = nodes_to_check.pop(); + for (const bNodeSocket *socket : next_node->output_sockets()) { + for (const bNodeLink *link : socket->directly_linked_links()) { + if (link->tonode->typeinfo->nclass == NODE_CLASS_OUTPUT && + link->tonode->flag & NODE_DO_OUTPUT) { + return true; + } + nodes_to_check.push(link->tonode); } } } - return false; -} - -bool BKE_node_is_connected_to_output(bNodeTree *ntree, bNode *node) -{ - bNode *tnode; - /* clear flags */ - for (tnode = (bNode *)ntree->nodes.first; tnode; tnode = tnode->next) { - tnode->done = 0; - } - - return node_is_connected_to_output_recursive(ntree, node); -} - -void BKE_node_tree_unlink_id(ID *id, struct bNodeTree *ntree) -{ - bNode *node; - - for (node = (bNode *)ntree->nodes.first; node; node = node->next) { - if (node->id == id) { - node->id = nullptr; - } - } + return false; } /** \} */ @@ -460,62 +434,53 @@ bNodeSocket *node_group_input_find_socket(bNode *node, const char *identifier) void node_group_input_update(bNodeTree *ntree, bNode *node) { bNodeSocket *extsock = (bNodeSocket *)node->outputs.last; - bNodeLink *link, *linknext, *exposelink; /* Adding a tree socket and verifying will remove the extension socket! * This list caches the existing links from the extension socket - * so they can be recreated after verification. - */ - ListBase tmplinks; + * so they can be recreated after verification. */ + Vector<bNodeLink> temp_links; /* find links from the extension socket and store them */ - BLI_listbase_clear(&tmplinks); - for (link = (bNodeLink *)ntree->links.first; link; link = linknext) { - linknext = link->next; + LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { if (nodeLinkIsHidden(link)) { continue; } if (link->fromsock == extsock) { - bNodeLink *tlink = MEM_cnew<bNodeLink>("temporary link"); - *tlink = *link; - BLI_addtail(&tmplinks, tlink); - + temp_links.append(*link); nodeRemLink(ntree, link); } } /* find valid link to expose */ - exposelink = nullptr; - for (link = (bNodeLink *)tmplinks.first; link; link = link->next) { + bNodeLink *exposelink = nullptr; + for (bNodeLink &link : temp_links) { /* XXX Multiple sockets can be connected to the extension socket at once, * in that case the arbitrary first link determines name and type. * This could be improved by choosing the "best" type among all links, * whatever that means. */ - if (!is_group_extension_socket(link->tonode, link->tosock)) { - exposelink = link; + if (!is_group_extension_socket(link.tonode, link.tosock)) { + exposelink = &link; break; } } if (exposelink) { - bNodeSocket *gsock, *newsock; - - gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->tonode, exposelink->tosock); + bNodeSocket *gsock = ntreeAddSocketInterfaceFromSocket( + ntree, exposelink->tonode, exposelink->tosock); node_group_input_update(ntree, node); - newsock = node_group_input_find_socket(node, gsock->identifier); + bNodeSocket *newsock = node_group_input_find_socket(node, gsock->identifier); /* redirect links from the extension socket */ - for (link = (bNodeLink *)tmplinks.first; link; link = link->next) { - bNodeLink *newlink = nodeAddLink(ntree, node, newsock, link->tonode, link->tosock); + for (bNodeLink &link : temp_links) { + bNodeLink *newlink = nodeAddLink(ntree, node, newsock, link.tonode, link.tosock); if (newlink->tosock->flag & SOCK_MULTI_INPUT) { - newlink->multi_input_socket_index = link->multi_input_socket_index; + newlink->multi_input_socket_index = link.multi_input_socket_index; } } } - BLI_freelistN(&tmplinks); group_verify_socket_list(*ntree, *node, ntree->inputs, node->outputs, SOCK_OUT, true); } @@ -527,8 +492,8 @@ void register_node_type_group_input() node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE); node_type_size(ntype, 140, 80, 400); - node_type_init(ntype, node_group_input_init); - node_type_update(ntype, node_group_input_update); + ntype->initfunc = node_group_input_init; + ntype->updatefunc = node_group_input_update; nodeRegisterType(ntype); } @@ -552,60 +517,51 @@ bNodeSocket *node_group_output_find_socket(bNode *node, const char *identifier) void node_group_output_update(bNodeTree *ntree, bNode *node) { bNodeSocket *extsock = (bNodeSocket *)node->inputs.last; - bNodeLink *link, *linknext, *exposelink; /* Adding a tree socket and verifying will remove the extension socket! * This list caches the existing links to the extension socket - * so they can be recreated after verification. - */ - ListBase tmplinks; + * so they can be recreated after verification. */ + Vector<bNodeLink> temp_links; /* find links to the extension socket and store them */ - BLI_listbase_clear(&tmplinks); - for (link = (bNodeLink *)ntree->links.first; link; link = linknext) { - linknext = link->next; + LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { if (nodeLinkIsHidden(link)) { continue; } if (link->tosock == extsock) { - bNodeLink *tlink = MEM_cnew<bNodeLink>("temporary link"); - *tlink = *link; - BLI_addtail(&tmplinks, tlink); - + temp_links.append(*link); nodeRemLink(ntree, link); } } /* find valid link to expose */ - exposelink = nullptr; - for (link = (bNodeLink *)tmplinks.first; link; link = link->next) { + bNodeLink *exposelink = nullptr; + for (bNodeLink &link : temp_links) { /* XXX Multiple sockets can be connected to the extension socket at once, * in that case the arbitrary first link determines name and type. * This could be improved by choosing the "best" type among all links, * whatever that means. */ - if (!is_group_extension_socket(link->fromnode, link->fromsock)) { - exposelink = link; + if (!is_group_extension_socket(link.fromnode, link.fromsock)) { + exposelink = &link; break; } } if (exposelink) { - bNodeSocket *gsock, *newsock; - /* XXX what if connecting virtual to virtual socket?? */ - gsock = ntreeAddSocketInterfaceFromSocket(ntree, exposelink->fromnode, exposelink->fromsock); + bNodeSocket *gsock = ntreeAddSocketInterfaceFromSocket( + ntree, exposelink->fromnode, exposelink->fromsock); node_group_output_update(ntree, node); - newsock = node_group_output_find_socket(node, gsock->identifier); + bNodeSocket *newsock = node_group_output_find_socket(node, gsock->identifier); /* redirect links to the extension socket */ - for (link = (bNodeLink *)tmplinks.first; link; link = link->next) { - nodeAddLink(ntree, link->fromnode, link->fromsock, node, newsock); + for (bNodeLink &link : temp_links) { + nodeAddLink(ntree, link.fromnode, link.fromsock, node, newsock); } } - BLI_freelistN(&tmplinks); group_verify_socket_list(*ntree, *node, ntree->outputs, node->inputs, SOCK_IN, true); } @@ -617,8 +573,8 @@ void register_node_type_group_output() node_type_base(ntype, NODE_GROUP_OUTPUT, "Group Output", NODE_CLASS_INTERFACE); node_type_size(ntype, 140, 80, 400); - node_type_init(ntype, node_group_output_init); - node_type_update(ntype, node_group_output_update); + ntype->initfunc = node_group_output_init; + ntype->updatefunc = node_group_output_update; ntype->no_muting = true; diff --git a/source/blender/nodes/shader/nodes/node_shader_add_shader.cc b/source/blender/nodes/shader/nodes/node_shader_add_shader.cc index f7b25225e30..8bdc5b91887 100644 --- a/source/blender/nodes/shader/nodes/node_shader_add_shader.cc +++ b/source/blender/nodes/shader/nodes/node_shader_add_shader.cc @@ -32,7 +32,7 @@ void register_node_type_sh_add_shader() sh_node_type_base(&ntype, SH_NODE_ADD_SHADER, "Add Shader", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_add_shader); + ntype.gpu_fn = file_ns::node_shader_gpu_add_shader; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.cc b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.cc index 5f30fe0dd30..85c49b47b81 100644 --- a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.cc +++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.cc @@ -66,8 +66,8 @@ void register_node_type_sh_ambient_occlusion() sh_node_type_base(&ntype, SH_NODE_AMBIENT_OCCLUSION, "Ambient Occlusion", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_ambient_occlusion; - node_type_init(&ntype, file_ns::node_shader_init_ambient_occlusion); - node_type_gpu(&ntype, file_ns::node_shader_gpu_ambient_occlusion); + ntype.initfunc = file_ns::node_shader_init_ambient_occlusion; + ntype.gpu_fn = file_ns::node_shader_gpu_ambient_occlusion; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.cc b/source/blender/nodes/shader/nodes/node_shader_attribute.cc index 4694599f064..44f5282b688 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.cc +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.cc @@ -86,10 +86,10 @@ void register_node_type_sh_attribute() sh_node_type_base(&ntype, SH_NODE_ATTRIBUTE, "Attribute", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_attribute; - node_type_init(&ntype, file_ns::node_shader_init_attribute); + ntype.initfunc = file_ns::node_shader_init_attribute; node_type_storage( &ntype, "NodeShaderAttribute", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_attribute); + ntype.gpu_fn = file_ns::node_shader_gpu_attribute; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_background.cc b/source/blender/nodes/shader/nodes/node_shader_background.cc index 1e41b66189a..a1e90757157 100644 --- a/source/blender/nodes/shader/nodes/node_shader_background.cc +++ b/source/blender/nodes/shader/nodes/node_shader_background.cc @@ -33,7 +33,7 @@ void register_node_type_sh_background() sh_node_type_base(&ntype, SH_NODE_BACKGROUND, "Background", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_background); + ntype.gpu_fn = file_ns::node_shader_gpu_background; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bevel.cc b/source/blender/nodes/shader/nodes/node_shader_bevel.cc index 14356a46125..53ce3876772 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bevel.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bevel.cc @@ -50,8 +50,8 @@ void register_node_type_sh_bevel() sh_node_type_base(&ntype, SH_NODE_BEVEL, "Bevel", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_bevel; - node_type_init(&ntype, file_ns::node_shader_init_bevel); - node_type_gpu(&ntype, file_ns::gpu_shader_bevel); + ntype.initfunc = file_ns::node_shader_init_bevel; + ntype.gpu_fn = file_ns::gpu_shader_bevel; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_blackbody.cc b/source/blender/nodes/shader/nodes/node_shader_blackbody.cc index 23e9a601045..a31653de4b2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_blackbody.cc +++ b/source/blender/nodes/shader/nodes/node_shader_blackbody.cc @@ -42,7 +42,7 @@ void register_node_type_sh_blackbody() sh_node_type_base(&ntype, SH_NODE_BLACKBODY, "Blackbody", NODE_CLASS_CONVERTER); ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_gpu(&ntype, file_ns::node_shader_gpu_blackbody); + ntype.gpu_fn = file_ns::node_shader_gpu_blackbody; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.cc b/source/blender/nodes/shader/nodes/node_shader_brightness.cc index 09f0e21208c..0b1930b0434 100644 --- a/source/blender/nodes/shader/nodes/node_shader_brightness.cc +++ b/source/blender/nodes/shader/nodes/node_shader_brightness.cc @@ -32,7 +32,7 @@ void register_node_type_sh_brightcontrast() sh_node_type_base(&ntype, SH_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_brightcontrast); + ntype.gpu_fn = file_ns::gpu_shader_brightcontrast; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc index 2071b78fa64..48a7c248ea9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.cc @@ -69,8 +69,8 @@ void register_node_type_sh_bsdf_anisotropic() ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_anisotropic; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_anisotropic); - node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_anisotropic); + ntype.initfunc = file_ns::node_shader_init_anisotropic; + ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_anisotropic; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc index a4f0e04576f..ba222a1a2c2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.cc @@ -45,7 +45,7 @@ void register_node_type_sh_bsdf_diffuse() sh_node_type_base(&ntype, SH_NODE_BSDF_DIFFUSE, "Diffuse BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_diffuse); + ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_diffuse; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc index b3c047c3a47..00d2ba4a119 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.cc @@ -57,8 +57,8 @@ void register_node_type_sh_bsdf_glass() sh_node_type_base(&ntype, SH_NODE_BSDF_GLASS, "Glass BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_glass); - node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_glass); + ntype.initfunc = file_ns::node_shader_init_glass; + ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_glass; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc index 7beecc0ecd4..edccd7314d2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.cc @@ -56,8 +56,8 @@ void register_node_type_sh_bsdf_glossy() sh_node_type_base(&ntype, SH_NODE_BSDF_GLOSSY, "Glossy BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_glossy); - node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_glossy); + ntype.initfunc = file_ns::node_shader_init_glossy; + ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_glossy; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc index f8a17e146f4..0498dcd0be5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair.cc @@ -58,7 +58,7 @@ void register_node_type_sh_bsdf_hair() ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_hair; node_type_size(&ntype, 150, 60, 200); - node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_hair); + ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_hair; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc index b1022a95783..fd127cfb8ae 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_hair_principled.cc @@ -129,9 +129,9 @@ void register_node_type_sh_bsdf_hair_principled() ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_principled_hair; node_type_size_preset(&ntype, NODE_SIZE_LARGE); - node_type_init(&ntype, file_ns::node_shader_init_hair_principled); - node_type_update(&ntype, file_ns::node_shader_update_hair_principled); - node_type_gpu(&ntype, file_ns::node_shader_gpu_hair_principled); + ntype.initfunc = file_ns::node_shader_init_hair_principled; + ntype.updatefunc = file_ns::node_shader_update_hair_principled; + ntype.gpu_fn = file_ns::node_shader_gpu_hair_principled; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc index adf2a9e8a19..82bf852455c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.cc @@ -245,9 +245,9 @@ void register_node_type_sh_bsdf_principled() ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_principled; node_type_size_preset(&ntype, NODE_SIZE_LARGE); - node_type_init(&ntype, file_ns::node_shader_init_principled); - node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_principled); - node_type_update(&ntype, file_ns::node_shader_update_principled); + ntype.initfunc = file_ns::node_shader_init_principled; + ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_principled; + ntype.updatefunc = file_ns::node_shader_update_principled; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc index a7111fd398f..d6ef63015f8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.cc @@ -55,8 +55,8 @@ void register_node_type_sh_bsdf_refraction() sh_node_type_base(&ntype, SH_NODE_BSDF_REFRACTION, "Refraction BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_refraction); - node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_refraction); + ntype.initfunc = file_ns::node_shader_init_refraction; + ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_refraction; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc index d0f70eb1c92..ba8e48ce410 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.cc @@ -59,7 +59,7 @@ void register_node_type_sh_bsdf_toon() ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_toon; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_toon); + ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_toon; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc index b8a2bf8043e..fcb3bcdd00a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.cc @@ -39,7 +39,7 @@ void register_node_type_sh_bsdf_translucent() sh_node_type_base(&ntype, SH_NODE_BSDF_TRANSLUCENT, "Translucent BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_translucent); + ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_translucent; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc index 8824c744fd3..4eba043ff2b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.cc @@ -35,7 +35,7 @@ void register_node_type_sh_bsdf_transparent() sh_node_type_base(&ntype, SH_NODE_BSDF_TRANSPARENT, "Transparent BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_transparent); + ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_transparent; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc index c4aaf371e46..67351dd7e19 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.cc @@ -44,7 +44,7 @@ void register_node_type_sh_bsdf_velvet() sh_node_type_base(&ntype, SH_NODE_BSDF_VELVET, "Velvet BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_bsdf_velvet); + ntype.gpu_fn = file_ns::node_shader_gpu_bsdf_velvet; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.cc b/source/blender/nodes/shader/nodes/node_shader_bump.cc index 5447198107b..9439f95d62b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bump.cc +++ b/source/blender/nodes/shader/nodes/node_shader_bump.cc @@ -78,7 +78,7 @@ void register_node_type_sh_bump() sh_node_type_base(&ntype, SH_NODE_BUMP, "Bump", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_bump; - node_type_gpu(&ntype, file_ns::gpu_shader_bump); + ntype.gpu_fn = file_ns::gpu_shader_bump; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.cc b/source/blender/nodes/shader/nodes/node_shader_camera.cc index 4d99d5ad17f..2752cd31c56 100644 --- a/source/blender/nodes/shader/nodes/node_shader_camera.cc +++ b/source/blender/nodes/shader/nodes/node_shader_camera.cc @@ -35,7 +35,7 @@ void register_node_type_sh_camera() sh_node_type_base(&ntype, SH_NODE_CAMERA, "Camera Data", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_camera); + ntype.gpu_fn = file_ns::gpu_shader_camera; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_clamp.cc b/source/blender/nodes/shader/nodes/node_shader_clamp.cc index 7680c6f99c4..5b7c216c4c3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_clamp.cc +++ b/source/blender/nodes/shader/nodes/node_shader_clamp.cc @@ -76,8 +76,8 @@ void register_node_type_sh_clamp() sh_fn_node_type_base(&ntype, SH_NODE_CLAMP, "Clamp", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_clamp_declare; ntype.draw_buttons = file_ns::node_shader_buts_clamp; - node_type_init(&ntype, file_ns::node_shader_init_clamp); - node_type_gpu(&ntype, file_ns::gpu_shader_clamp); + ntype.initfunc = file_ns::node_shader_init_clamp; + ntype.gpu_fn = file_ns::gpu_shader_clamp; ntype.build_multi_function = file_ns::sh_node_clamp_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc index 096884591ab..f5d405c7678 100644 --- a/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc +++ b/source/blender/nodes/shader/nodes/node_shader_color_ramp.cc @@ -140,10 +140,10 @@ void register_node_type_sh_valtorgb() sh_fn_node_type_base(&ntype, SH_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_valtorgb_declare; - node_type_init(&ntype, file_ns::node_shader_init_valtorgb); + ntype.initfunc = file_ns::node_shader_init_valtorgb; node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::gpu_shader_valtorgb); + ntype.gpu_fn = file_ns::gpu_shader_valtorgb; ntype.build_multi_function = file_ns::sh_node_valtorgb_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_common.cc b/source/blender/nodes/shader/nodes/node_shader_common.cc index 20d0d11ba86..9d1d788da9d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.cc +++ b/source/blender/nodes/shader/nodes/node_shader_common.cc @@ -93,8 +93,8 @@ void register_node_type_sh_group() node_type_size(&ntype, 140, 60, 400); ntype.labelfunc = node_group_label; - node_type_group_update(&ntype, node_group_update); - node_type_gpu(&ntype, gpu_group_execute); + ntype.group_update_func = node_group_update; + ntype.gpu_fn = gpu_group_execute; nodeRegisterType(&ntype); } @@ -109,5 +109,5 @@ void register_node_type_sh_custom_group(bNodeType *ntype) ntype->insert_link = node_insert_link_default; } - node_type_gpu(ntype, gpu_group_execute); + ntype->gpu_fn = gpu_group_execute; } diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.cc b/source/blender/nodes/shader/nodes/node_shader_curves.cc index c4dbc3ce6f1..0945c39ee50 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.cc +++ b/source/blender/nodes/shader/nodes/node_shader_curves.cc @@ -116,10 +116,10 @@ void register_node_type_sh_curve_vec() sh_fn_node_type_base(&ntype, SH_NODE_CURVE_VEC, "Vector Curves", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::sh_node_curve_vec_declare; - node_type_init(&ntype, file_ns::node_shader_init_curve_vec); + ntype.initfunc = file_ns::node_shader_init_curve_vec; node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); - node_type_gpu(&ntype, file_ns::gpu_shader_curve_vec); + ntype.gpu_fn = file_ns::gpu_shader_curve_vec; ntype.build_multi_function = file_ns::sh_node_curve_vec_build_multi_function; nodeRegisterType(&ntype); @@ -263,10 +263,10 @@ void register_node_type_sh_curve_rgb() sh_fn_node_type_base(&ntype, SH_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::sh_node_curve_rgb_declare; - node_type_init(&ntype, file_ns::node_shader_init_curve_rgb); + ntype.initfunc = file_ns::node_shader_init_curve_rgb; node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); - node_type_gpu(&ntype, file_ns::gpu_shader_curve_rgb); + ntype.gpu_fn = file_ns::gpu_shader_curve_rgb; ntype.build_multi_function = file_ns::sh_node_curve_rgb_build_multi_function; nodeRegisterType(&ntype); @@ -383,10 +383,10 @@ void register_node_type_sh_curve_float() sh_fn_node_type_base(&ntype, SH_NODE_CURVE_FLOAT, "Float Curve", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_curve_float_declare; - node_type_init(&ntype, file_ns::node_shader_init_curve_float); + ntype.initfunc = file_ns::node_shader_init_curve_float; node_type_size_preset(&ntype, NODE_SIZE_LARGE); node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); - node_type_gpu(&ntype, file_ns::gpu_shader_curve_float); + ntype.gpu_fn = file_ns::gpu_shader_curve_float; ntype.build_multi_function = file_ns::sh_node_curve_float_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_displacement.cc b/source/blender/nodes/shader/nodes/node_shader_displacement.cc index fd5a6107447..e71e2168701 100644 --- a/source/blender/nodes/shader/nodes/node_shader_displacement.cc +++ b/source/blender/nodes/shader/nodes/node_shader_displacement.cc @@ -54,8 +54,8 @@ void register_node_type_sh_displacement() sh_node_type_base(&ntype, SH_NODE_DISPLACEMENT, "Displacement", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::node_declare; - node_type_init(&ntype, file_ns::node_shader_init_displacement); - node_type_gpu(&ntype, file_ns::gpu_shader_displacement); + ntype.initfunc = file_ns::node_shader_init_displacement; + ntype.gpu_fn = file_ns::gpu_shader_displacement; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_eevee_specular.cc b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.cc index 5a058eec690..c13300bdac4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_eevee_specular.cc +++ b/source/blender/nodes/shader/nodes/node_shader_eevee_specular.cc @@ -80,7 +80,7 @@ void register_node_type_sh_eevee_specular() sh_node_type_base(&ntype, SH_NODE_EEVEE_SPECULAR, "Specular BSDF", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_eevee_specular); + ntype.gpu_fn = file_ns::node_shader_gpu_eevee_specular; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_emission.cc b/source/blender/nodes/shader/nodes/node_shader_emission.cc index 69c6094e92e..df6283f92dc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_emission.cc +++ b/source/blender/nodes/shader/nodes/node_shader_emission.cc @@ -34,7 +34,7 @@ void register_node_type_sh_emission() sh_node_type_base(&ntype, SH_NODE_EMISSION, "Emission", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_emission); + ntype.gpu_fn = file_ns::node_shader_gpu_emission; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.cc b/source/blender/nodes/shader/nodes/node_shader_fresnel.cc index abbfc5ad1d5..1e35942476a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_fresnel.cc +++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.cc @@ -36,7 +36,7 @@ void register_node_type_sh_fresnel() sh_node_type_base(&ntype, SH_NODE_FRESNEL, "Fresnel", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_fresnel); + ntype.gpu_fn = file_ns::node_shader_gpu_fresnel; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.cc b/source/blender/nodes/shader/nodes/node_shader_gamma.cc index 80419ed732c..327d9b134cd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_gamma.cc +++ b/source/blender/nodes/shader/nodes/node_shader_gamma.cc @@ -35,7 +35,7 @@ void register_node_type_sh_gamma() sh_node_type_base(&ntype, SH_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_gamma); + ntype.gpu_fn = file_ns::node_shader_gpu_gamma; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.cc b/source/blender/nodes/shader/nodes/node_shader_geometry.cc index e27b5290513..d7d5f4aa91f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geometry.cc +++ b/source/blender/nodes/shader/nodes/node_shader_geometry.cc @@ -68,7 +68,7 @@ void register_node_type_sh_geometry() sh_node_type_base(&ntype, SH_NODE_NEW_GEOMETRY, "Geometry", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_geometry); + ntype.gpu_fn = file_ns::node_shader_gpu_geometry; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_hair_info.cc b/source/blender/nodes/shader/nodes/node_shader_hair_info.cc index 2ae87f7bc51..4511c8a9ae6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hair_info.cc +++ b/source/blender/nodes/shader/nodes/node_shader_hair_info.cc @@ -39,7 +39,7 @@ void register_node_type_sh_hair_info() sh_node_type_base(&ntype, SH_NODE_HAIR_INFO, "Curves Info", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_hair_info); + ntype.gpu_fn = file_ns::node_shader_gpu_hair_info; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_holdout.cc b/source/blender/nodes/shader/nodes/node_shader_holdout.cc index ee754a7afa8..f3f8cef5a2d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_holdout.cc +++ b/source/blender/nodes/shader/nodes/node_shader_holdout.cc @@ -31,7 +31,7 @@ void register_node_type_sh_holdout() sh_node_type_base(&ntype, SH_NODE_HOLDOUT, "Holdout", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_rgb); + ntype.gpu_fn = file_ns::gpu_shader_rgb; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc index 3e057d3d230..7eb02a3bce2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc +++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.cc @@ -39,7 +39,7 @@ void register_node_type_sh_hue_sat() sh_node_type_base(&ntype, SH_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_gpu(&ntype, file_ns::gpu_shader_hue_sat); + ntype.gpu_fn = file_ns::gpu_shader_hue_sat; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_ies_light.cc b/source/blender/nodes/shader/nodes/node_shader_ies_light.cc index 65655ba2781..dee69eaf391 100644 --- a/source/blender/nodes/shader/nodes/node_shader_ies_light.cc +++ b/source/blender/nodes/shader/nodes/node_shader_ies_light.cc @@ -50,7 +50,7 @@ void register_node_type_sh_tex_ies() sh_node_type_base(&ntype, SH_NODE_TEX_IES, "IES Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_ies; - node_type_init(&ntype, file_ns::node_shader_init_tex_ies); + ntype.initfunc = file_ns::node_shader_init_tex_ies; node_type_storage( &ntype, "NodeShaderTexIES", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.cc b/source/blender/nodes/shader/nodes/node_shader_invert.cc index adcb0508093..ba2774e3b8f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_invert.cc +++ b/source/blender/nodes/shader/nodes/node_shader_invert.cc @@ -35,7 +35,7 @@ void register_node_type_sh_invert() sh_node_type_base(&ntype, SH_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_invert); + ntype.gpu_fn = file_ns::gpu_shader_invert; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_layer_weight.cc b/source/blender/nodes/shader/nodes/node_shader_layer_weight.cc index 5a56ee8bc75..f589f85fc89 100644 --- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.cc +++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.cc @@ -37,7 +37,7 @@ void register_node_type_sh_layer_weight() sh_node_type_base(&ntype, SH_NODE_LAYER_WEIGHT, "Layer Weight", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_layer_weight); + ntype.gpu_fn = file_ns::node_shader_gpu_layer_weight; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc b/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc index 1ee096c052f..fcaf1b31e77 100644 --- a/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc +++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.cc @@ -35,7 +35,7 @@ void register_node_type_sh_light_falloff() sh_node_type_base(&ntype, SH_NODE_LIGHT_FALLOFF, "Light Falloff", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_gpu(&ntype, file_ns::node_shader_gpu_light_falloff); + ntype.gpu_fn = file_ns::node_shader_gpu_light_falloff; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_light_path.cc b/source/blender/nodes/shader/nodes/node_shader_light_path.cc index 268a80af0ab..b04b2a2f022 100644 --- a/source/blender/nodes/shader/nodes/node_shader_light_path.cc +++ b/source/blender/nodes/shader/nodes/node_shader_light_path.cc @@ -42,7 +42,7 @@ void register_node_type_sh_light_path() sh_node_type_base(&ntype, SH_NODE_LIGHT_PATH, "Light Path", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_light_path); + ntype.gpu_fn = file_ns::node_shader_gpu_light_path; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_map_range.cc b/source/blender/nodes/shader/nodes/node_shader_map_range.cc index e0c1778f764..a906ee40b42 100644 --- a/source/blender/nodes/shader/nodes/node_shader_map_range.cc +++ b/source/blender/nodes/shader/nodes/node_shader_map_range.cc @@ -502,11 +502,11 @@ void register_node_type_sh_map_range() ntype.declare = file_ns::sh_node_map_range_declare; ntype.draw_buttons = file_ns::node_shader_buts_map_range; ntype.ui_class = file_ns::node_shader_map_range_ui_class; - node_type_init(&ntype, file_ns::node_shader_init_map_range); + ntype.initfunc = file_ns::node_shader_init_map_range; node_type_storage( &ntype, "NodeMapRange", node_free_standard_storage, node_copy_standard_storage); - node_type_update(&ntype, file_ns::node_shader_update_map_range); - node_type_gpu(&ntype, file_ns::gpu_shader_map_range); + ntype.updatefunc = file_ns::node_shader_update_map_range; + ntype.gpu_fn = file_ns::gpu_shader_map_range; ntype.build_multi_function = file_ns::sh_node_map_range_build_multi_function; ntype.gather_link_search_ops = file_ns::node_map_range_gather_link_searches; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.cc b/source/blender/nodes/shader/nodes/node_shader_mapping.cc index 89cd5af045b..f9cac93544f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.cc @@ -87,8 +87,8 @@ void register_node_type_sh_mapping() sh_node_type_base(&ntype, SH_NODE_MAPPING, "Mapping", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_mapping; - node_type_gpu(&ntype, file_ns::gpu_shader_mapping); - node_type_update(&ntype, file_ns::node_shader_update_mapping); + ntype.gpu_fn = file_ns::gpu_shader_mapping; + ntype.updatefunc = file_ns::node_shader_update_mapping; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_math.cc b/source/blender/nodes/shader/nodes/node_shader_math.cc index 3f25da4652d..5fe1bb48cc2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_math.cc @@ -190,8 +190,8 @@ void register_node_type_sh_math() sh_fn_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_math_declare; ntype.labelfunc = node_math_label; - node_type_gpu(&ntype, file_ns::gpu_shader_math); - node_type_update(&ntype, node_math_update); + ntype.gpu_fn = file_ns::gpu_shader_math; + ntype.updatefunc = node_math_update; ntype.build_multi_function = file_ns::sh_node_math_build_multi_function; ntype.gather_link_search_ops = file_ns::sh_node_math_gather_link_searches; diff --git a/source/blender/nodes/shader/nodes/node_shader_mix.cc b/source/blender/nodes/shader/nodes/node_shader_mix.cc index 878648105d1..bc928ddb49a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mix.cc @@ -456,9 +456,9 @@ void register_node_type_sh_mix() sh_fn_node_type_base(&ntype, SH_NODE_MIX, "Mix", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_mix_declare; ntype.ui_class = file_ns::sh_node_mix_ui_class; - node_type_gpu(&ntype, file_ns::gpu_shader_mix); - node_type_update(&ntype, file_ns::sh_node_mix_update); - node_type_init(&ntype, file_ns::node_mix_init); + ntype.gpu_fn = file_ns::gpu_shader_mix; + ntype.updatefunc = file_ns::sh_node_mix_update; + ntype.initfunc = file_ns::node_mix_init; node_type_storage( &ntype, "NodeShaderMix", node_free_standard_storage, node_copy_standard_storage); ntype.build_multi_function = file_ns::sh_node_mix_build_multi_function; diff --git a/source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc b/source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc index d1578b48c79..98771098f81 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mix_rgb.cc @@ -153,7 +153,7 @@ void register_node_type_sh_mix_rgb() sh_fn_node_type_base(&ntype, SH_NODE_MIX_RGB_LEGACY, "Mix (Legacy)", NODE_CLASS_OP_COLOR); ntype.declare = file_ns::sh_node_mix_rgb_declare; ntype.labelfunc = node_blend_label; - node_type_gpu(&ntype, file_ns::gpu_shader_mix_rgb); + ntype.gpu_fn = file_ns::gpu_shader_mix_rgb; ntype.build_multi_function = file_ns::sh_node_mix_rgb_build_multi_function; ntype.gather_link_search_ops = nullptr; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_mix_shader.cc b/source/blender/nodes/shader/nodes/node_shader_mix_shader.cc index 27e41406b48..135e3582483 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix_shader.cc +++ b/source/blender/nodes/shader/nodes/node_shader_mix_shader.cc @@ -33,7 +33,7 @@ void register_node_type_sh_mix_shader() sh_node_type_base(&ntype, SH_NODE_MIX_SHADER, "Mix Shader", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_mix_shader); + ntype.gpu_fn = file_ns::node_shader_gpu_mix_shader; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.cc b/source/blender/nodes/shader/nodes/node_shader_normal.cc index 49c075ac27e..c36744524f4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal.cc +++ b/source/blender/nodes/shader/nodes/node_shader_normal.cc @@ -44,7 +44,7 @@ void register_node_type_sh_normal() sh_node_type_base(&ntype, SH_NODE_NORMAL, "Normal", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_normal); + ntype.gpu_fn = file_ns::gpu_shader_normal; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc index 99cb5f6f525..4338cfd9457 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal_map.cc +++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.cc @@ -118,10 +118,10 @@ void register_node_type_sh_normal_map() ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_normal_map; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_normal_map); + ntype.initfunc = file_ns::node_shader_init_normal_map; node_type_storage( &ntype, "NodeShaderNormalMap", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::gpu_shader_normal_map); + ntype.gpu_fn = file_ns::gpu_shader_normal_map; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_object_info.cc b/source/blender/nodes/shader/nodes/node_shader_object_info.cc index 210f855b9e0..daa40d8dc63 100644 --- a/source/blender/nodes/shader/nodes/node_shader_object_info.cc +++ b/source/blender/nodes/shader/nodes/node_shader_object_info.cc @@ -37,7 +37,7 @@ void register_node_type_sh_object_info() sh_node_type_base(&ntype, SH_NODE_OBJECT_INFO, "Object Info", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_object_info); + ntype.gpu_fn = file_ns::node_shader_gpu_object_info; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_output_aov.cc b/source/blender/nodes/shader/nodes/node_shader_output_aov.cc index cc95db9d333..b668b5313ba 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_aov.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_aov.cc @@ -60,10 +60,10 @@ void register_node_type_sh_output_aov() sh_node_type_base(&ntype, SH_NODE_OUTPUT_AOV, "AOV Output", NODE_CLASS_OUTPUT); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_output_aov; - node_type_init(&ntype, file_ns::node_shader_init_output_aov); + ntype.initfunc = file_ns::node_shader_init_output_aov; node_type_storage( &ntype, "NodeShaderOutputAOV", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_output_aov); + ntype.gpu_fn = file_ns::node_shader_gpu_output_aov; ntype.no_muting = true; diff --git a/source/blender/nodes/shader/nodes/node_shader_output_light.cc b/source/blender/nodes/shader/nodes/node_shader_output_light.cc index 6e4483dbbe9..848e6c92e17 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_light.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_light.cc @@ -37,7 +37,7 @@ void register_node_type_sh_output_light() sh_node_type_base(&ntype, SH_NODE_OUTPUT_LIGHT, "Light Output", NODE_CLASS_OUTPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_output_light); + ntype.gpu_fn = file_ns::node_shader_gpu_output_light; ntype.no_muting = true; diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.cc b/source/blender/nodes/shader/nodes/node_shader_output_material.cc index 857c5eb68df..ff2628a891b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_material.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_material.cc @@ -53,7 +53,7 @@ void register_node_type_sh_output_material() sh_node_type_base(&ntype, SH_NODE_OUTPUT_MATERIAL, "Material Output", NODE_CLASS_OUTPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_output_material); + ntype.gpu_fn = file_ns::node_shader_gpu_output_material; ntype.no_muting = true; diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.cc b/source/blender/nodes/shader/nodes/node_shader_output_world.cc index f450e667cd9..2d75faa9e80 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_world.cc +++ b/source/blender/nodes/shader/nodes/node_shader_output_world.cc @@ -40,7 +40,7 @@ void register_node_type_sh_output_world() sh_node_type_base(&ntype, SH_NODE_OUTPUT_WORLD, "World Output", NODE_CLASS_OUTPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_output_world); + ntype.gpu_fn = file_ns::node_shader_gpu_output_world; ntype.no_muting = true; diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.cc b/source/blender/nodes/shader/nodes/node_shader_particle_info.cc index 76a91ab60aa..c86bb5866dd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_particle_info.cc +++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.cc @@ -44,7 +44,7 @@ void register_node_type_sh_particle_info() sh_node_type_base(&ntype, SH_NODE_PARTICLE_INFO, "Particle Info", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_particle_info); + ntype.gpu_fn = file_ns::gpu_shader_particle_info; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_point_info.cc b/source/blender/nodes/shader/nodes/node_shader_point_info.cc index 05b649490e4..fffa3abad03 100644 --- a/source/blender/nodes/shader/nodes/node_shader_point_info.cc +++ b/source/blender/nodes/shader/nodes/node_shader_point_info.cc @@ -32,7 +32,7 @@ void register_node_type_sh_point_info() sh_node_type_base(&ntype, SH_NODE_POINT_INFO, "Point Info", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_point_info); + ntype.gpu_fn = file_ns::node_shader_gpu_point_info; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.cc b/source/blender/nodes/shader/nodes/node_shader_rgb.cc index 1adbbbc48bc..d70df4a8e25 100644 --- a/source/blender/nodes/shader/nodes/node_shader_rgb.cc +++ b/source/blender/nodes/shader/nodes/node_shader_rgb.cc @@ -35,7 +35,7 @@ void register_node_type_sh_rgb() sh_node_type_base(&ntype, SH_NODE_RGB, "RGB", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_rgb); + ntype.gpu_fn = file_ns::gpu_shader_rgb; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc b/source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc index 1db3342733b..1e663d1b86f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc +++ b/source/blender/nodes/shader/nodes/node_shader_rgb_to_bw.cc @@ -36,7 +36,7 @@ void register_node_type_sh_rgbtobw() sh_node_type_base(&ntype, SH_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_rgbtobw_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_rgbtobw); + ntype.gpu_fn = file_ns::gpu_shader_rgbtobw; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_script.cc b/source/blender/nodes/shader/nodes/node_shader_script.cc index 8534ce129b4..213de85cb15 100644 --- a/source/blender/nodes/shader/nodes/node_shader_script.cc +++ b/source/blender/nodes/shader/nodes/node_shader_script.cc @@ -86,7 +86,7 @@ void register_node_type_sh_script() sh_node_type_base(&ntype, SH_NODE_SCRIPT, "Script", NODE_CLASS_SCRIPT); ntype.draw_buttons = file_ns::node_shader_buts_script; ntype.draw_buttons_ex = file_ns::node_shader_buts_script_ex; - node_type_init(&ntype, file_ns::init); + ntype.initfunc = file_ns::init; node_type_storage( &ntype, "NodeShaderScript", file_ns::node_free_script, file_ns::node_copy_script); diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcomb_color.cc b/source/blender/nodes/shader/nodes/node_shader_sepcomb_color.cc index 77ce6f5e4e4..94e5f19b840 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcomb_color.cc +++ b/source/blender/nodes/shader/nodes/node_shader_sepcomb_color.cc @@ -76,11 +76,11 @@ void register_node_type_sh_sepcolor() sh_node_type_base(&ntype, SH_NODE_SEPARATE_COLOR, "Separate Color", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_sepcolor_declare; - node_type_update(&ntype, file_ns::node_sepcolor_update); - node_type_init(&ntype, node_combsep_color_init); + ntype.updatefunc = file_ns::node_sepcolor_update; + ntype.initfunc = node_combsep_color_init; node_type_storage( &ntype, "NodeCombSepColor", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::gpu_shader_sepcolor); + ntype.gpu_fn = file_ns::gpu_shader_sepcolor; nodeRegisterType(&ntype); } @@ -152,11 +152,11 @@ void register_node_type_sh_combcolor() sh_node_type_base(&ntype, SH_NODE_COMBINE_COLOR, "Combine Color", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_combcolor_declare; - node_type_update(&ntype, file_ns::node_combcolor_update); - node_type_init(&ntype, node_combsep_color_init); + ntype.updatefunc = file_ns::node_combcolor_update; + ntype.initfunc = node_combsep_color_init; node_type_storage( &ntype, "NodeCombSepColor", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::gpu_shader_combcolor); + ntype.gpu_fn = file_ns::gpu_shader_combcolor; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc b/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc index b297ead1847..66ff5f82944 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc +++ b/source/blender/nodes/shader/nodes/node_shader_sepcomb_hsv.cc @@ -38,7 +38,7 @@ void register_node_type_sh_sephsv() sh_node_type_base(&ntype, SH_NODE_SEPHSV_LEGACY, "Separate HSV (Legacy)", NODE_CLASS_CONVERTER); ntype.declare = file_ns::node_declare_sephsv; - node_type_gpu(&ntype, file_ns::gpu_shader_sephsv); + ntype.gpu_fn = file_ns::gpu_shader_sephsv; ntype.gather_link_search_ops = nullptr; nodeRegisterType(&ntype); @@ -75,7 +75,7 @@ void register_node_type_sh_combhsv() sh_node_type_base(&ntype, SH_NODE_COMBHSV_LEGACY, "Combine HSV (Legacy)", NODE_CLASS_CONVERTER); ntype.declare = file_ns::node_declare_combhsv; - node_type_gpu(&ntype, file_ns::gpu_shader_combhsv); + ntype.gpu_fn = file_ns::gpu_shader_combhsv; ntype.gather_link_search_ops = nullptr; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcomb_rgb.cc b/source/blender/nodes/shader/nodes/node_shader_sepcomb_rgb.cc index c298998cad5..28c4eef823f 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcomb_rgb.cc +++ b/source/blender/nodes/shader/nodes/node_shader_sepcomb_rgb.cc @@ -79,7 +79,7 @@ void register_node_type_sh_seprgb() sh_fn_node_type_base( &ntype, SH_NODE_SEPRGB_LEGACY, "Separate RGB (Legacy)", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_seprgb_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_seprgb); + ntype.gpu_fn = file_ns::gpu_shader_seprgb; ntype.build_multi_function = file_ns::sh_node_seprgb_build_multi_function; ntype.gather_link_search_ops = nullptr; @@ -124,7 +124,7 @@ void register_node_type_sh_combrgb() sh_fn_node_type_base( &ntype, SH_NODE_COMBRGB_LEGACY, "Combine RGB (Legacy)", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_combrgb_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_combrgb); + ntype.gpu_fn = file_ns::gpu_shader_combrgb; ntype.build_multi_function = file_ns::sh_node_combrgb_build_multi_function; ntype.gather_link_search_ops = nullptr; diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcomb_xyz.cc b/source/blender/nodes/shader/nodes/node_shader_sepcomb_xyz.cc index 8849824ec0b..131ae16ef1b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcomb_xyz.cc +++ b/source/blender/nodes/shader/nodes/node_shader_sepcomb_xyz.cc @@ -97,7 +97,7 @@ void register_node_type_sh_sepxyz() sh_fn_node_type_base(&ntype, SH_NODE_SEPXYZ, "Separate XYZ", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_sepxyz_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_sepxyz); + ntype.gpu_fn = file_ns::gpu_shader_sepxyz; ntype.build_multi_function = file_ns::sh_node_sepxyz_build_multi_function; nodeRegisterType(&ntype); @@ -142,7 +142,7 @@ void register_node_type_sh_combxyz() sh_fn_node_type_base(&ntype, SH_NODE_COMBXYZ, "Combine XYZ", NODE_CLASS_CONVERTER); ntype.declare = file_ns::sh_node_combxyz_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_combxyz); + ntype.gpu_fn = file_ns::gpu_shader_combxyz; ntype.build_multi_function = file_ns::sh_node_combxyz_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc b/source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc index 7345e374937..38ae1f979a8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc +++ b/source/blender/nodes/shader/nodes/node_shader_shader_to_rgb.cc @@ -34,7 +34,7 @@ void register_node_type_sh_shadertorgb() sh_node_type_base(&ntype, SH_NODE_SHADERTORGB, "Shader to RGB", NODE_CLASS_CONVERTER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_shadertorgb); + ntype.gpu_fn = file_ns::node_shader_gpu_shadertorgb; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_squeeze.cc b/source/blender/nodes/shader/nodes/node_shader_squeeze.cc index 62e21088791..31965c5e13e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_squeeze.cc +++ b/source/blender/nodes/shader/nodes/node_shader_squeeze.cc @@ -36,7 +36,7 @@ void register_node_type_sh_squeeze() sh_node_type_base(&ntype, SH_NODE_SQUEEZE, "Squeeze Value", NODE_CLASS_CONVERTER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_squeeze); + ntype.gpu_fn = file_ns::gpu_shader_squeeze; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc index 29d42b20a80..bcf859251e3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc +++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.cc @@ -87,9 +87,9 @@ void register_node_type_sh_subsurface_scattering() ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_subsurface; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_subsurface_scattering); - node_type_gpu(&ntype, file_ns::node_shader_gpu_subsurface_scattering); - node_type_update(&ntype, file_ns::node_shader_update_subsurface_scattering); + ntype.initfunc = file_ns::node_shader_init_subsurface_scattering; + ntype.gpu_fn = file_ns::node_shader_gpu_subsurface_scattering; + ntype.updatefunc = file_ns::node_shader_update_subsurface_scattering; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.cc b/source/blender/nodes/shader/nodes/node_shader_tangent.cc index c2116c9c0ff..9b09eb09bba 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tangent.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tangent.cc @@ -89,8 +89,8 @@ void register_node_type_sh_tangent() ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_tangent; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_tangent); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tangent); + ntype.initfunc = file_ns::node_shader_init_tangent; + ntype.gpu_fn = file_ns::node_shader_gpu_tangent; node_type_storage( &ntype, "NodeShaderTangent", node_free_standard_storage, node_copy_standard_storage); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc index f6bcedbd19e..aaae1369d79 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.cc @@ -283,10 +283,10 @@ void register_node_type_sh_tex_brick() ntype.declare = file_ns::sh_node_tex_brick_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_brick; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_tex_brick); + ntype.initfunc = file_ns::node_shader_init_tex_brick; node_type_storage( &ntype, "NodeTexBrick", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_brick); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_brick; ntype.build_multi_function = file_ns::sh_node_brick_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc b/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc index c48f79698bb..bef3eb990eb 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.cc @@ -111,10 +111,10 @@ void register_node_type_sh_tex_checker() sh_fn_node_type_base(&ntype, SH_NODE_TEX_CHECKER, "Checker Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_checker_declare; - node_type_init(&ntype, file_ns::node_shader_init_tex_checker); + ntype.initfunc = file_ns::node_shader_init_tex_checker; node_type_storage( &ntype, "NodeTexChecker", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_checker); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_checker; ntype.build_multi_function = file_ns::sh_node_tex_checker_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc index 1edf8c2aa55..a295bda9d07 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.cc @@ -82,7 +82,7 @@ void register_node_type_sh_tex_coord() sh_node_type_base(&ntype, SH_NODE_TEX_COORD, "Texture Coordinate", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_coord; - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_coord); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_coord; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc b/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc index a145bce3f6f..60059a8f1c5 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.cc @@ -125,10 +125,10 @@ void register_node_type_sh_tex_environment() sh_node_type_base(&ntype, SH_NODE_TEX_ENVIRONMENT, "Environment Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::node_declare; - node_type_init(&ntype, file_ns::node_shader_init_tex_environment); + ntype.initfunc = file_ns::node_shader_init_tex_environment; node_type_storage( &ntype, "NodeTexEnvironment", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_environment); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_environment; ntype.labelfunc = node_image_label; node_type_size_preset(&ntype, NODE_SIZE_LARGE); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc index 75c469fe665..f7bff442420 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.cc @@ -157,10 +157,10 @@ void register_node_type_sh_tex_gradient() sh_fn_node_type_base(&ntype, SH_NODE_TEX_GRADIENT, "Gradient Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_gradient_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_gradient; - node_type_init(&ntype, file_ns::node_shader_init_tex_gradient); + ntype.initfunc = file_ns::node_shader_init_tex_gradient; node_type_storage( &ntype, "NodeTexGradient", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_gradient); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_gradient; ntype.build_multi_function = file_ns::sh_node_gradient_tex_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.cc b/source/blender/nodes/shader/nodes/node_shader_tex_image.cc index 80398871625..9f4f885fee1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.cc @@ -163,10 +163,10 @@ void register_node_type_sh_tex_image() sh_node_type_base(&ntype, SH_NODE_TEX_IMAGE, "Image Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_image_declare; - node_type_init(&ntype, file_ns::node_shader_init_tex_image); + ntype.initfunc = file_ns::node_shader_init_tex_image; node_type_storage( &ntype, "NodeTexImage", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_image); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_image; ntype.labelfunc = node_image_label; node_type_size_preset(&ntype, NODE_SIZE_LARGE); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc b/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc index b2ba0e52f02..f68f1747b21 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.cc @@ -177,10 +177,10 @@ void register_node_type_sh_tex_magic() sh_fn_node_type_base(&ntype, SH_NODE_TEX_MAGIC, "Magic Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_magic_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_magic; - node_type_init(&ntype, file_ns::node_shader_init_tex_magic); + ntype.initfunc = file_ns::node_shader_init_tex_magic; node_type_storage( &ntype, "NodeTexMagic", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_magic); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_magic; ntype.build_multi_function = file_ns::sh_node_magic_tex_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc index 9a7573fc870..e79b12b78b9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.cc @@ -535,11 +535,11 @@ void register_node_type_sh_tex_musgrave() ntype.declare = file_ns::sh_node_tex_musgrave_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_musgrave; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_tex_musgrave); + ntype.initfunc = file_ns::node_shader_init_tex_musgrave; node_type_storage( &ntype, "NodeTexMusgrave", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_musgrave); - node_type_update(&ntype, file_ns::node_shader_update_tex_musgrave); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_musgrave; + ntype.updatefunc = file_ns::node_shader_update_tex_musgrave; ntype.build_multi_function = file_ns::sh_node_musgrave_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc index 684c122f7fe..d72e9c3c451 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.cc @@ -249,11 +249,11 @@ void register_node_type_sh_tex_noise() sh_fn_node_type_base(&ntype, SH_NODE_TEX_NOISE, "Noise Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_noise_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_noise; - node_type_init(&ntype, file_ns::node_shader_init_tex_noise); + ntype.initfunc = file_ns::node_shader_init_tex_noise; node_type_storage( &ntype, "NodeTexNoise", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_noise); - node_type_update(&ntype, file_ns::node_shader_update_tex_noise); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_noise; + ntype.updatefunc = file_ns::node_shader_update_tex_noise; ntype.build_multi_function = file_ns::sh_node_noise_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc index 0d10d5a5047..4005265e49a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.cc @@ -103,7 +103,7 @@ void register_node_type_sh_tex_pointdensity() sh_node_type_base(&ntype, SH_NODE_TEX_POINTDENSITY, "Point Density", NODE_CLASS_TEXTURE); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_pointdensity; - node_type_init(&ntype, file_ns::node_shader_init_tex_pointdensity); + ntype.initfunc = file_ns::node_shader_init_tex_pointdensity; node_type_storage(&ntype, "NodeShaderTexPointDensity", file_ns::node_shader_free_tex_pointdensity, diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc index 44df6b2b1a1..faa0c0f0888 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.cc @@ -308,11 +308,11 @@ void register_node_type_sh_tex_sky() ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_sky; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_tex_sky); + ntype.initfunc = file_ns::node_shader_init_tex_sky; node_type_storage(&ntype, "NodeTexSky", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_sky); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_sky; /* Remove vector input for Nishita sky model. */ - node_type_update(&ntype, file_ns::node_shader_update_sky); + ntype.updatefunc = file_ns::node_shader_update_sky; ntype.gather_link_search_ops = file_ns::node_gather_link_searches; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc index 0ef73f0c5ef..f07ef1b6c60 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc @@ -1347,11 +1347,11 @@ void register_node_type_sh_tex_voronoi() sh_fn_node_type_base(&ntype, SH_NODE_TEX_VORONOI, "Voronoi Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_voronoi_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_voronoi; - node_type_init(&ntype, file_ns::node_shader_init_tex_voronoi); + ntype.initfunc = file_ns::node_shader_init_tex_voronoi; node_type_storage( &ntype, "NodeTexVoronoi", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_voronoi); - node_type_update(&ntype, file_ns::node_shader_update_tex_voronoi); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_voronoi; + ntype.updatefunc = file_ns::node_shader_update_tex_voronoi; ntype.build_multi_function = file_ns::sh_node_voronoi_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc b/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc index 91dbc149f78..f4effe28815 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.cc @@ -224,9 +224,9 @@ void register_node_type_sh_tex_wave() ntype.declare = file_ns::sh_node_tex_wave_declare; ntype.draw_buttons = file_ns::node_shader_buts_tex_wave; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_tex_wave); + ntype.initfunc = file_ns::node_shader_init_tex_wave; node_type_storage(&ntype, "NodeTexWave", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_tex_wave); + ntype.gpu_fn = file_ns::node_shader_gpu_tex_wave; ntype.build_multi_function = file_ns::sh_node_wave_tex_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc index 9a026567682..58787a9afa3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_white_noise.cc @@ -194,9 +194,9 @@ void register_node_type_sh_tex_white_noise() sh_fn_node_type_base(&ntype, SH_NODE_TEX_WHITE_NOISE, "White Noise Texture", NODE_CLASS_TEXTURE); ntype.declare = file_ns::sh_node_tex_white_noise_declare; ntype.draw_buttons = file_ns::node_shader_buts_white_noise; - node_type_init(&ntype, file_ns::node_shader_init_tex_white_noise); - node_type_gpu(&ntype, file_ns::gpu_shader_tex_white_noise); - node_type_update(&ntype, file_ns::node_shader_update_tex_white_noise); + ntype.initfunc = file_ns::node_shader_init_tex_white_noise; + ntype.gpu_fn = file_ns::gpu_shader_tex_white_noise; + ntype.updatefunc = file_ns::node_shader_update_tex_white_noise; ntype.build_multi_function = file_ns::sh_node_noise_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_uvmap.cc b/source/blender/nodes/shader/nodes/node_shader_uvmap.cc index e9d2b32bfd7..483e06f1192 100644 --- a/source/blender/nodes/shader/nodes/node_shader_uvmap.cc +++ b/source/blender/nodes/shader/nodes/node_shader_uvmap.cc @@ -70,10 +70,10 @@ void register_node_type_sh_uvmap() ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_uvmap; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, file_ns::node_shader_init_uvmap); + ntype.initfunc = file_ns::node_shader_init_uvmap; node_type_storage( &ntype, "NodeShaderUVMap", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_uvmap); + ntype.gpu_fn = file_ns::node_shader_gpu_uvmap; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_value.cc b/source/blender/nodes/shader/nodes/node_shader_value.cc index 0cd1a1f05f8..c190438c417 100644 --- a/source/blender/nodes/shader/nodes/node_shader_value.cc +++ b/source/blender/nodes/shader/nodes/node_shader_value.cc @@ -42,7 +42,7 @@ void register_node_type_sh_value() sh_fn_node_type_base(&ntype, SH_NODE_VALUE, "Value", NODE_CLASS_INPUT); ntype.declare = file_ns::sh_node_value_declare; - node_type_gpu(&ntype, file_ns::gpu_shader_value); + ntype.gpu_fn = file_ns::gpu_shader_value; ntype.build_multi_function = file_ns::sh_node_value_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.cc b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.cc index 64484f83320..c9e4f9c8e14 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_displacement.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_displacement.cc @@ -52,8 +52,8 @@ void register_node_type_sh_vector_displacement() sh_node_type_base( &ntype, SH_NODE_VECTOR_DISPLACEMENT, "Vector Displacement", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::node_declare; - node_type_init(&ntype, file_ns::node_shader_init_vector_displacement); - node_type_gpu(&ntype, file_ns::gpu_shader_vector_displacement); + ntype.initfunc = file_ns::node_shader_init_vector_displacement; + ntype.gpu_fn = file_ns::gpu_shader_vector_displacement; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc index 42b84617996..f7cf70aa8e1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_math.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_math.cc @@ -322,8 +322,8 @@ void register_node_type_sh_vect_math() ntype.declare = file_ns::sh_node_vector_math_declare; ntype.draw_buttons = file_ns::node_shader_buts_vect_math; ntype.labelfunc = node_vector_math_label; - node_type_gpu(&ntype, file_ns::gpu_shader_vector_math); - node_type_update(&ntype, file_ns::node_shader_update_vector_math); + ntype.gpu_fn = file_ns::gpu_shader_vector_math; + ntype.updatefunc = file_ns::node_shader_update_vector_math; ntype.build_multi_function = file_ns::sh_node_vector_math_build_multi_function; ntype.gather_link_search_ops = file_ns::sh_node_vector_math_gather_link_searches; diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc index 218ed0e54c9..bdf7360873d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_rotate.cc @@ -212,8 +212,8 @@ void register_node_type_sh_vector_rotate() sh_fn_node_type_base(&ntype, SH_NODE_VECTOR_ROTATE, "Vector Rotate", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::sh_node_vector_rotate_declare; ntype.draw_buttons = file_ns::node_shader_buts_vector_rotate; - node_type_gpu(&ntype, file_ns::gpu_shader_vector_rotate); - node_type_update(&ntype, file_ns::node_shader_update_vector_rotate); + ntype.gpu_fn = file_ns::gpu_shader_vector_rotate; + ntype.updatefunc = file_ns::node_shader_update_vector_rotate; ntype.build_multi_function = file_ns::sh_node_vector_rotate_build_multi_function; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc index 9037c6208fb..03fb954f088 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vector_transform.cc @@ -144,10 +144,10 @@ void register_node_type_sh_vect_transform() sh_node_type_base(&ntype, SH_NODE_VECT_TRANSFORM, "Vector Transform", NODE_CLASS_OP_VECTOR); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_vect_transform; - node_type_init(&ntype, file_ns::node_shader_init_vect_transform); + ntype.initfunc = file_ns::node_shader_init_vect_transform; node_type_storage( &ntype, "NodeShaderVectTransform", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::gpu_shader_vect_transform); + ntype.gpu_fn = file_ns::gpu_shader_vect_transform; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc index 6e2325bddf9..8f7e30b99df 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc +++ b/source/blender/nodes/shader/nodes/node_shader_vertex_color.cc @@ -69,10 +69,10 @@ void register_node_type_sh_vertex_color() sh_node_type_base(&ntype, SH_NODE_VERTEX_COLOR, "Color Attribute", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_vertex_color; - node_type_init(&ntype, file_ns::node_shader_init_vertex_color); + ntype.initfunc = file_ns::node_shader_init_vertex_color; node_type_storage( &ntype, "NodeShaderVertexColor", node_free_standard_storage, node_copy_standard_storage); - node_type_gpu(&ntype, file_ns::node_shader_gpu_vertex_color); + ntype.gpu_fn = file_ns::node_shader_gpu_vertex_color; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc b/source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc index d6a29f537ff..e50331585e3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc +++ b/source/blender/nodes/shader/nodes/node_shader_volume_absorption.cc @@ -33,7 +33,7 @@ void register_node_type_sh_volume_absorption() sh_node_type_base(&ntype, SH_NODE_VOLUME_ABSORPTION, "Volume Absorption", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_volume_absorption); + ntype.gpu_fn = file_ns::node_shader_gpu_volume_absorption; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_info.cc b/source/blender/nodes/shader/nodes/node_shader_volume_info.cc index 9f1feedc336..6a1bc070f68 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_info.cc +++ b/source/blender/nodes/shader/nodes/node_shader_volume_info.cc @@ -49,7 +49,7 @@ void register_node_type_sh_volume_info() sh_node_type_base(&ntype, SH_NODE_VOLUME_INFO, "Volume Info", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_volume_info); + ntype.gpu_fn = file_ns::node_shader_gpu_volume_info; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc b/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc index 2c5811045f0..4ff57042fe4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc +++ b/source/blender/nodes/shader/nodes/node_shader_volume_principled.cc @@ -142,8 +142,8 @@ void register_node_type_sh_volume_principled() sh_node_type_base(&ntype, SH_NODE_VOLUME_PRINCIPLED, "Principled Volume", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_LARGE); - node_type_init(&ntype, file_ns::node_shader_init_volume_principled); - node_type_gpu(&ntype, file_ns::node_shader_gpu_volume_principled); + ntype.initfunc = file_ns::node_shader_init_volume_principled; + ntype.gpu_fn = file_ns::node_shader_gpu_volume_principled; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.cc b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.cc index 1322a73ac37..b87792eef2e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_scatter.cc +++ b/source/blender/nodes/shader/nodes/node_shader_volume_scatter.cc @@ -38,7 +38,7 @@ void register_node_type_sh_volume_scatter() sh_node_type_base(&ntype, SH_NODE_VOLUME_SCATTER, "Volume Scatter", NODE_CLASS_SHADER); ntype.declare = file_ns::node_declare; - node_type_gpu(&ntype, file_ns::node_shader_gpu_volume_scatter); + ntype.gpu_fn = file_ns::node_shader_gpu_volume_scatter; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_wavelength.cc b/source/blender/nodes/shader/nodes/node_shader_wavelength.cc index 43bb4798e3f..6fa495c3ead 100644 --- a/source/blender/nodes/shader/nodes/node_shader_wavelength.cc +++ b/source/blender/nodes/shader/nodes/node_shader_wavelength.cc @@ -41,7 +41,7 @@ void register_node_type_sh_wavelength() sh_node_type_base(&ntype, SH_NODE_WAVELENGTH, "Wavelength", NODE_CLASS_CONVERTER); ntype.declare = file_ns::node_declare; node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_gpu(&ntype, file_ns::node_shader_gpu_wavelength); + ntype.gpu_fn = file_ns::node_shader_gpu_wavelength; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_wireframe.cc b/source/blender/nodes/shader/nodes/node_shader_wireframe.cc index ddabebfeec2..b125e7221a6 100644 --- a/source/blender/nodes/shader/nodes/node_shader_wireframe.cc +++ b/source/blender/nodes/shader/nodes/node_shader_wireframe.cc @@ -47,7 +47,7 @@ void register_node_type_sh_wireframe() sh_node_type_base(&ntype, SH_NODE_WIREFRAME, "Wireframe", NODE_CLASS_INPUT); ntype.declare = file_ns::node_declare; ntype.draw_buttons = file_ns::node_shader_buts_wireframe; - node_type_gpu(&ntype, file_ns::node_shader_gpu_wireframe); + ntype.gpu_fn = file_ns::node_shader_gpu_wireframe; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_at.c b/source/blender/nodes/texture/nodes/node_texture_at.c index 74f279d65c7..e2e635b7d92 100644 --- a/source/blender/nodes/texture/nodes/node_texture_at.c +++ b/source/blender/nodes/texture/nodes/node_texture_at.c @@ -45,7 +45,7 @@ void register_node_type_tex_at(void) tex_node_type_base(&ntype, TEX_NODE_AT, "At", NODE_CLASS_DISTORT); node_type_socket_templates(&ntype, inputs, outputs); node_type_size(&ntype, 140, 100, 320); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c index bfd43560c2d..b68bf4fcb8d 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.c +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c @@ -106,8 +106,8 @@ void register_node_type_tex_bricks(void) tex_node_type_base(&ntype, TEX_NODE_BRICKS, "Bricks", NODE_CLASS_PATTERN); node_type_socket_templates(&ntype, inputs, outputs); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, init); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.initfunc = init; + ntype.exec_fn = exec; ntype.flag |= NODE_PREVIEW; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.c b/source/blender/nodes/texture/nodes/node_texture_checker.c index 08f87cb7875..d66eb7e6953 100644 --- a/source/blender/nodes/texture/nodes/node_texture_checker.c +++ b/source/blender/nodes/texture/nodes/node_texture_checker.c @@ -56,7 +56,7 @@ void register_node_type_tex_checker(void) tex_node_type_base(&ntype, TEX_NODE_CHECKER, "Checker", NODE_CLASS_PATTERN); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; ntype.flag |= NODE_PREVIEW; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_combine_color.c b/source/blender/nodes/texture/nodes/node_texture_combine_color.c index 459553bc950..e6a8080bb48 100644 --- a/source/blender/nodes/texture/nodes/node_texture_combine_color.c +++ b/source/blender/nodes/texture/nodes/node_texture_combine_color.c @@ -69,8 +69,8 @@ void register_node_type_tex_combine_color(void) tex_node_type_base(&ntype, TEX_NODE_COMBINE_COLOR, "Combine Color", NODE_CLASS_OP_COLOR); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - node_type_update(&ntype, update); + ntype.exec_fn = exec; + ntype.updatefunc = update; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c index 96345b00a82..8ff4ad61387 100644 --- a/source/blender/nodes/texture/nodes/node_texture_common.c +++ b/source/blender/nodes/texture/nodes/node_texture_common.c @@ -155,8 +155,10 @@ void register_node_type_tex_group(void) node_type_size(&ntype, 140, 60, 400); ntype.labelfunc = node_group_label; - node_type_group_update(&ntype, node_group_update); - node_type_exec(&ntype, group_initexec, group_freeexec, group_execute); + ntype.group_update_func = node_group_update; + ntype.init_exec_fn = group_initexec; + ntype.free_exec_fn = group_freeexec; + ntype.exec_fn = group_execute; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c index e36bc248ed1..d41566be74c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_compose.c +++ b/source/blender/nodes/texture/nodes/node_texture_compose.c @@ -45,7 +45,7 @@ void register_node_type_tex_compose(void) tex_node_type_base( &ntype, TEX_NODE_COMPOSE_LEGACY, "Combine RGBA (Legacy)", NODE_CLASS_OP_COLOR); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.c b/source/blender/nodes/texture/nodes/node_texture_coord.c index e74dfd378d9..1babea310f4 100644 --- a/source/blender/nodes/texture/nodes/node_texture_coord.c +++ b/source/blender/nodes/texture/nodes/node_texture_coord.c @@ -35,7 +35,7 @@ void register_node_type_tex_coord(void) tex_node_type_base(&ntype, TEX_NODE_COORD, "Coordinates", NODE_CLASS_INPUT); node_type_socket_templates(&ntype, NULL, outputs); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c index dee4531746f..df75847dbe3 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.c +++ b/source/blender/nodes/texture/nodes/node_texture_curves.c @@ -52,9 +52,10 @@ void register_node_type_tex_curve_time(void) tex_node_type_base(&ntype, TEX_NODE_CURVE_TIME, "Time", NODE_CLASS_INPUT); node_type_socket_templates(&ntype, NULL, time_outputs); node_type_size_preset(&ntype, NODE_SIZE_LARGE); - node_type_init(&ntype, time_init); + ntype.initfunc = time_init; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); - node_type_exec(&ntype, node_initexec_curves, NULL, time_exec); + ntype.init_exec_fn = node_initexec_curves; + ntype.exec_fn = time_exec; nodeRegisterType(&ntype); } @@ -101,9 +102,11 @@ void register_node_type_tex_curve_rgb(void) tex_node_type_base(&ntype, TEX_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR); node_type_socket_templates(&ntype, rgb_inputs, rgb_outputs); node_type_size_preset(&ntype, NODE_SIZE_LARGE); - node_type_init(&ntype, rgb_init); + ntype.initfunc = rgb_init; node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); - node_type_exec(&ntype, node_initexec_curves, NULL, rgb_exec); + ntype.init_exec_fn = node_initexec_curves ; + ntype.exec_fn =rgb_exec ; + nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_decompose.c b/source/blender/nodes/texture/nodes/node_texture_decompose.c index 2d42fa4602e..ae7e80a6aab 100644 --- a/source/blender/nodes/texture/nodes/node_texture_decompose.c +++ b/source/blender/nodes/texture/nodes/node_texture_decompose.c @@ -64,7 +64,7 @@ void register_node_type_tex_decompose(void) tex_node_type_base(&ntype, TEX_NODE_DECOMPOSE_LEGACY, "Separate RGBA", NODE_CLASS_OP_COLOR); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_distance.c b/source/blender/nodes/texture/nodes/node_texture_distance.c index e236b6743a6..19918a9896e 100644 --- a/source/blender/nodes/texture/nodes/node_texture_distance.c +++ b/source/blender/nodes/texture/nodes/node_texture_distance.c @@ -46,7 +46,7 @@ void register_node_type_tex_distance(void) tex_node_type_base(&ntype, TEX_NODE_DISTANCE, "Distance", NODE_CLASS_CONVERTER); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c index 989d94953f7..454b58f4665 100644 --- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c +++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c @@ -94,7 +94,7 @@ void register_node_type_tex_hue_sat(void) tex_node_type_base(&ntype, TEX_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR); node_type_socket_templates(&ntype, inputs, outputs); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c index e94c78b41ea..8b859421762 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.c +++ b/source/blender/nodes/texture/nodes/node_texture_image.c @@ -94,9 +94,9 @@ void register_node_type_tex_image(void) tex_node_type_base(&ntype, TEX_NODE_IMAGE, "Image", NODE_CLASS_INPUT); node_type_socket_templates(&ntype, NULL, outputs); - node_type_init(&ntype, init); + ntype.initfunc = init; node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; ntype.labelfunc = node_image_label; ntype.flag |= NODE_PREVIEW; diff --git a/source/blender/nodes/texture/nodes/node_texture_invert.c b/source/blender/nodes/texture/nodes/node_texture_invert.c index 6343f5f2caa..526d47bef9c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_invert.c +++ b/source/blender/nodes/texture/nodes/node_texture_invert.c @@ -49,7 +49,7 @@ void register_node_type_tex_invert(void) tex_node_type_base(&ntype, TEX_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c index 5867d6b91e1..505ba51b4d8 100644 --- a/source/blender/nodes/texture/nodes/node_texture_math.c +++ b/source/blender/nodes/texture/nodes/node_texture_math.c @@ -322,8 +322,8 @@ void register_node_type_tex_math(void) tex_node_type_base(&ntype, TEX_NODE_MATH, "Math", NODE_CLASS_CONVERTER); node_type_socket_templates(&ntype, inputs, outputs); ntype.labelfunc = node_math_label; - node_type_exec(&ntype, NULL, NULL, exec); - node_type_update(&ntype, node_math_update); + ntype.exec_fn = exec; + ntype.updatefunc = node_math_update; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c index cd6b54c4cf8..15ca2280fe1 100644 --- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c @@ -56,7 +56,7 @@ void register_node_type_tex_mix_rgb(void) tex_node_type_base(&ntype, TEX_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR); node_type_socket_templates(&ntype, inputs, outputs); ntype.labelfunc = node_blend_label; - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c index b300ba9ef77..37e39dae22c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.c +++ b/source/blender/nodes/texture/nodes/node_texture_output.c @@ -138,9 +138,9 @@ void register_node_type_tex_output(void) tex_node_type_base(&ntype, TEX_NODE_OUTPUT, "Output", NODE_CLASS_OUTPUT); node_type_socket_templates(&ntype, inputs, NULL); node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, init); + ntype.initfunc = init; node_type_storage(&ntype, "TexNodeOutput", node_free_standard_storage, copy); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; ntype.flag |= NODE_PREVIEW; ntype.no_muting = true; diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c index d925c9f3554..f23c4f55820 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ b/source/blender/nodes/texture/nodes/node_texture_proc.c @@ -254,9 +254,9 @@ static void init(bNodeTree *UNUSED(ntree), bNode *node) tex_node_type_base(&ntype, TEX_NODE_PROC + TEXTYPE, Name, NODE_CLASS_TEXTURE); \ node_type_socket_templates(&ntype, name##_inputs, outputs); \ node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); \ - node_type_init(&ntype, init); \ + ntype.initfunc = init; \ node_type_storage(&ntype, "Tex", node_free_standard_storage, node_copy_standard_storage); \ - node_type_exec(&ntype, NULL, NULL, name##_exec); \ + ntype.exec_fn = name##_exec; \ ntype.flag |= NODE_PREVIEW; \ \ nodeRegisterType(&ntype); \ diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.c b/source/blender/nodes/texture/nodes/node_texture_rotate.c index 0bd2de76a9c..b31adefcbba 100644 --- a/source/blender/nodes/texture/nodes/node_texture_rotate.c +++ b/source/blender/nodes/texture/nodes/node_texture_rotate.c @@ -81,7 +81,7 @@ void register_node_type_tex_rotate(void) tex_node_type_base(&ntype, TEX_NODE_ROTATE, "Rotate", NODE_CLASS_DISTORT); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_scale.c b/source/blender/nodes/texture/nodes/node_texture_scale.c index d565146cf09..93a4db7677c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_scale.c +++ b/source/blender/nodes/texture/nodes/node_texture_scale.c @@ -54,7 +54,7 @@ void register_node_type_tex_scale(void) tex_node_type_base(&ntype, TEX_NODE_SCALE, "Scale", NODE_CLASS_DISTORT); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_separate_color.c b/source/blender/nodes/texture/nodes/node_texture_separate_color.c index a482a3f3421..030f7d79043 100644 --- a/source/blender/nodes/texture/nodes/node_texture_separate_color.c +++ b/source/blender/nodes/texture/nodes/node_texture_separate_color.c @@ -95,8 +95,8 @@ void register_node_type_tex_separate_color(void) tex_node_type_base(&ntype, TEX_NODE_SEPARATE_COLOR, "Separate Color", NODE_CLASS_OP_COLOR); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); - node_type_update(&ntype, update); + ntype.exec_fn = exec; + ntype.updatefunc = update; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c index 79cd8bbb1df..163a6516a58 100644 --- a/source/blender/nodes/texture/nodes/node_texture_texture.c +++ b/source/blender/nodes/texture/nodes/node_texture_texture.c @@ -78,7 +78,7 @@ void register_node_type_tex_texture(void) tex_node_type_base(&ntype, TEX_NODE_TEXTURE, "Texture", NODE_CLASS_INPUT); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; ntype.flag |= NODE_PREVIEW; nodeRegisterType(&ntype); diff --git a/source/blender/nodes/texture/nodes/node_texture_translate.c b/source/blender/nodes/texture/nodes/node_texture_translate.c index 7ce7722938d..a8c12116097 100644 --- a/source/blender/nodes/texture/nodes/node_texture_translate.c +++ b/source/blender/nodes/texture/nodes/node_texture_translate.c @@ -50,7 +50,7 @@ void register_node_type_tex_translate(void) tex_node_type_base(&ntype, TEX_NODE_TRANSLATE, "Translate", NODE_CLASS_DISTORT); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_valToNor.c b/source/blender/nodes/texture/nodes/node_texture_valToNor.c index 492aadf3281..d0fc5229e06 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToNor.c +++ b/source/blender/nodes/texture/nodes/node_texture_valToNor.c @@ -66,7 +66,7 @@ void register_node_type_tex_valtonor(void) tex_node_type_base(&ntype, TEX_NODE_VALTONOR, "Value to Normal", NODE_CLASS_CONVERTER); node_type_socket_templates(&ntype, inputs, outputs); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c index e41e83555fc..b2acef407e2 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c @@ -50,9 +50,9 @@ void register_node_type_tex_valtorgb(void) tex_node_type_base(&ntype, TEX_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTER); node_type_socket_templates(&ntype, valtorgb_in, valtorgb_out); node_type_size_preset(&ntype, NODE_SIZE_LARGE); - node_type_init(&ntype, valtorgb_init); + ntype.initfunc = valtorgb_init; node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); - node_type_exec(&ntype, NULL, NULL, valtorgb_exec); + ntype.exec_fn = valtorgb_exec; nodeRegisterType(&ntype); } @@ -91,7 +91,7 @@ void register_node_type_tex_rgbtobw(void) tex_node_type_base(&ntype, TEX_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTER); node_type_socket_templates(&ntype, rgbtobw_in, rgbtobw_out); - node_type_exec(&ntype, NULL, NULL, rgbtobw_exec); + ntype.exec_fn = rgbtobw_exec; nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_viewer.c b/source/blender/nodes/texture/nodes/node_texture_viewer.c index 72da751f8ef..1f31d62ed38 100644 --- a/source/blender/nodes/texture/nodes/node_texture_viewer.c +++ b/source/blender/nodes/texture/nodes/node_texture_viewer.c @@ -38,7 +38,7 @@ void register_node_type_tex_viewer(void) tex_node_type_base(&ntype, TEX_NODE_VIEWER, "Viewer", NODE_CLASS_OUTPUT); node_type_socket_templates(&ntype, inputs, NULL); - node_type_exec(&ntype, NULL, NULL, exec); + ntype.exec_fn = exec; ntype.no_muting = true; ntype.flag |= NODE_PREVIEW; diff --git a/source/blender/render/RE_multires_bake.h b/source/blender/render/RE_multires_bake.h index a478f124892..70ce46bc195 100644 --- a/source/blender/render/RE_multires_bake.h +++ b/source/blender/render/RE_multires_bake.h @@ -43,8 +43,8 @@ typedef struct MultiresBakeRender { float user_scale; /* User scale used to scale displacement when baking derivative map. */ - short *stop; - short *do_update; + bool *stop; + bool *do_update; float *progress; } MultiresBakeRender; diff --git a/source/blender/render/RE_pipeline.h b/source/blender/render/RE_pipeline.h index e9a90096dab..d12162c0b9a 100644 --- a/source/blender/render/RE_pipeline.h +++ b/source/blender/render/RE_pipeline.h @@ -398,7 +398,7 @@ void RE_display_update_cb(struct Render *re, void RE_stats_draw_cb(struct Render *re, void *handle, void (*f)(void *handle, RenderStats *rs)); void RE_progress_cb(struct Render *re, void *handle, void (*f)(void *handle, float)); void RE_draw_lock_cb(struct Render *re, void *handle, void (*f)(void *handle, bool lock)); -void RE_test_break_cb(struct Render *re, void *handle, int (*f)(void *handle)); +void RE_test_break_cb(struct Render *re, void *handle, bool (*f)(void *handle)); void RE_current_scene_update_cb(struct Render *re, void *handle, void (*f)(void *handle, struct Scene *scene)); diff --git a/source/blender/render/intern/multires_bake.c b/source/blender/render/intern/multires_bake.c index f701d9a987a..cfb91e86ad9 100644 --- a/source/blender/render/intern/multires_bake.c +++ b/source/blender/render/intern/multires_bake.c @@ -89,7 +89,7 @@ typedef struct { char *texels; const MResolvePixelData *data; MFlushPixel flush_pixel; - short *do_update; + bool *do_update; } MBakeRast; typedef struct { @@ -134,7 +134,7 @@ static void init_bake_rast(MBakeRast *bake_rast, const ImBuf *ibuf, const MResolvePixelData *data, MFlushPixel flush_pixel, - short *do_update) + bool *do_update) { BakeImBufuserData *userdata = (BakeImBufuserData *)ibuf->userdata; diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index 1971c6fe6be..17cf3b7ff74 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -177,7 +177,7 @@ static void stats_nothing(void * /*arg*/, RenderStats * /*rs*/) static void float_nothing(void * /*arg*/, float /*val*/) { } -static int default_break(void * /*arg*/) +static bool default_break(void * /*arg*/) { return G.is_break == true; } @@ -748,7 +748,7 @@ void RE_InitState(Render *re, if (re->rectx < 1 || re->recty < 1 || (BKE_imtype_is_movie(rd->im_format.imtype) && (re->rectx < 16 || re->recty < 16))) { BKE_report(re->reports, RPT_ERROR, "Image too small"); - re->ok = 0; + re->ok = false; return; } @@ -847,7 +847,7 @@ void RE_draw_lock_cb(Render *re, void *handle, void (*f)(void *handle, bool lock re->dlh = handle; } -void RE_test_break_cb(Render *re, void *handle, int (*f)(void *handle)) +void RE_test_break_cb(Render *re, void *handle, bool (*f)(void *handle)) { re->test_break = f; re->tbh = handle; @@ -1605,15 +1605,15 @@ const char *RE_GetActiveRenderView(Render *re) return re->viewname; } -/* evaluating scene options for general Blender render */ -static int render_init_from_main(Render *re, - const RenderData *rd, - Main *bmain, - Scene *scene, - ViewLayer *single_layer, - Object *camera_override, - int anim, - int anim_init) +/** Evaluating scene options for general Blender render. */ +static bool render_init_from_main(Render *re, + const RenderData *rd, + Main *bmain, + Scene *scene, + ViewLayer *single_layer, + Object *camera_override, + int anim, + int anim_init) { int winx, winy; rcti disprect; @@ -1647,7 +1647,7 @@ static int render_init_from_main(Render *re, /* not too nice, but it survives anim-border render */ if (anim) { re->disprect = disprect; - return 1; + return true; } /* @@ -1669,7 +1669,7 @@ static int render_init_from_main(Render *re, RE_InitState(re, nullptr, &scene->r, &scene->view_layers, single_layer, winx, winy, &disprect); if (!re->ok) { /* if an error was printed, abort */ - return 0; + return false; } /* initstate makes new result, have to send changed tags around */ @@ -1678,7 +1678,7 @@ static int render_init_from_main(Render *re, re->display_init(re->dih, re->result); re->display_clear(re->dch, re->result); - return 1; + return true; } void RE_SetReports(Render *re, ReportList *reports) @@ -1831,7 +1831,7 @@ static bool use_eevee_for_freestyle_render(Render *re) void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene, int render) { - re->result_ok = 0; + re->result_ok = false; if (render_init_from_main(re, &scene->r, bmain, scene, nullptr, nullptr, 0, 0)) { if (render) { char scene_engine[32]; @@ -1845,7 +1845,7 @@ void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene, int render change_renderdata_engine(re, scene_engine); } } - re->result_ok = 1; + re->result_ok = true; } void RE_RenderFreestyleExternal(Render *re) diff --git a/source/blender/render/intern/render_types.h b/source/blender/render/intern/render_types.h index ad58f081388..418acbca3b1 100644 --- a/source/blender/render/intern/render_types.h +++ b/source/blender/render/intern/render_types.h @@ -39,7 +39,8 @@ struct Render { int slot; /* state settings */ - short flag, ok, result_ok; + short flag; + bool ok, result_ok; /* result of rendering */ RenderResult *result; @@ -107,7 +108,7 @@ struct Render { void (*draw_lock)(void *handle, bool lock); void *dlh; - int (*test_break)(void *handle); + bool (*test_break)(void *handle); void *tbh; RenderStats i; diff --git a/source/blender/sequencer/SEQ_proxy.h b/source/blender/sequencer/SEQ_proxy.h index 00747f4b9cf..caf123afbcf 100644 --- a/source/blender/sequencer/SEQ_proxy.h +++ b/source/blender/sequencer/SEQ_proxy.h @@ -29,8 +29,8 @@ bool SEQ_proxy_rebuild_context(struct Main *bmain, struct ListBase *queue, bool build_only_on_bad_performance); void SEQ_proxy_rebuild(struct SeqIndexBuildContext *context, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress); void SEQ_proxy_rebuild_finish(struct SeqIndexBuildContext *context, bool stop); void SEQ_proxy_set(struct Sequence *seq, bool value); diff --git a/source/blender/sequencer/SEQ_render.h b/source/blender/sequencer/SEQ_render.h index 9c163de4230..e2672eef8b9 100644 --- a/source/blender/sequencer/SEQ_render.h +++ b/source/blender/sequencer/SEQ_render.h @@ -66,8 +66,8 @@ void SEQ_render_thumbnails(const struct SeqRenderData *context, struct Sequence *seq, struct Sequence *seq_orig, float frame_step, - rctf *view_area, - const short *stop); + const struct rctf *view_area, + const bool *stop); /** * Get cached thumbnails. */ @@ -82,7 +82,7 @@ struct ImBuf *SEQ_get_thumbnail(const struct SeqRenderData *context, float SEQ_render_thumbnail_first_frame_get(const struct Scene *scene, struct Sequence *seq, float frame_step, - struct rctf *view_area); + const struct rctf *view_area); /** * Get frame for first thumbnail. */ @@ -102,8 +102,8 @@ int SEQ_render_thumbnails_guaranteed_set_frame_step_get(const struct Scene *scen void SEQ_render_thumbnails_base_set(const struct SeqRenderData *context, struct Sequence *seq, struct Sequence *seq_orig, - rctf *view_area, - const short *stop); + const struct rctf *view_area, + const bool *stop); void SEQ_render_init_colorspace(struct Sequence *seq); void SEQ_render_new_render_data(struct Main *bmain, diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c index 87da2017296..21ce2cbdf9a 100644 --- a/source/blender/sequencer/intern/image_cache.c +++ b/source/blender/sequencer/intern/image_cache.c @@ -811,8 +811,11 @@ bool seq_cache_put_if_possible( return false; } -void seq_cache_thumbnail_put( - const SeqRenderData *context, Sequence *seq, float timeline_frame, ImBuf *i, rctf *view_area) +void seq_cache_thumbnail_put(const SeqRenderData *context, + Sequence *seq, + float timeline_frame, + ImBuf *i, + const rctf *view_area) { Scene *scene = context->scene; diff --git a/source/blender/sequencer/intern/image_cache.h b/source/blender/sequencer/intern/image_cache.h index a7ae130dc41..7b7e020c926 100644 --- a/source/blender/sequencer/intern/image_cache.h +++ b/source/blender/sequencer/intern/image_cache.h @@ -48,7 +48,7 @@ void seq_cache_thumbnail_put(const struct SeqRenderData *context, struct Sequence *seq, float timeline_frame, struct ImBuf *i, - rctf *view_area); + const struct rctf *view_area); bool seq_cache_put_if_possible(const struct SeqRenderData *context, struct Sequence *seq, float timeline_frame, diff --git a/source/blender/sequencer/intern/proxy.c b/source/blender/sequencer/intern/proxy.c index fc1df4dc3ac..eaea310f423 100644 --- a/source/blender/sequencer/intern/proxy.c +++ b/source/blender/sequencer/intern/proxy.c @@ -479,10 +479,7 @@ bool SEQ_proxy_rebuild_context(Main *bmain, return true; } -void SEQ_proxy_rebuild(SeqIndexBuildContext *context, - short *stop, - short *do_update, - float *progress) +void SEQ_proxy_rebuild(SeqIndexBuildContext *context, bool *stop, bool *do_update, float *progress) { const bool overwrite = context->overwrite; SeqRenderData render_context; diff --git a/source/blender/sequencer/intern/proxy_job.c b/source/blender/sequencer/intern/proxy_job.c index 8520c06f9a2..d7dfe0130d8 100644 --- a/source/blender/sequencer/intern/proxy_job.c +++ b/source/blender/sequencer/intern/proxy_job.c @@ -41,7 +41,7 @@ static void proxy_freejob(void *pjv) } /* Only this runs inside thread. */ -static void proxy_startjob(void *pjv, short *stop, short *do_update, float *progress) +static void proxy_startjob(void *pjv, bool *stop, bool *do_update, float *progress) { ProxyJob *pj = pjv; LinkData *link; @@ -52,7 +52,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog SEQ_proxy_rebuild(context, stop, do_update, progress); if (*stop) { - pj->stop = 1; + pj->stop = true; fprintf(stderr, "Canceling proxy rebuild on users request...\n"); break; } diff --git a/source/blender/sequencer/intern/render.c b/source/blender/sequencer/intern/render.c index e3fd9216842..5c6a59a5943 100644 --- a/source/blender/sequencer/intern/render.c +++ b/source/blender/sequencer/intern/render.c @@ -2010,7 +2010,7 @@ ImBuf *SEQ_render_give_ibuf_direct(const SeqRenderData *context, float SEQ_render_thumbnail_first_frame_get(const Scene *scene, Sequence *seq, float frame_step, - rctf *view_area) + const rctf *view_area) { int first_drawable_frame = max_iii( SEQ_time_left_handle_frame_get(scene, seq), seq->start, view_area->xmin); @@ -2102,8 +2102,8 @@ void SEQ_render_thumbnails(const SeqRenderData *context, Sequence *seq, Sequence *seq_orig, float frame_step, - rctf *view_area, - const short *stop) + const rctf *view_area, + const bool *stop) { SeqRenderState state; seq_render_state_init(&state); @@ -2163,8 +2163,8 @@ int SEQ_render_thumbnails_guaranteed_set_frame_step_get(const Scene *scene, cons void SEQ_render_thumbnails_base_set(const SeqRenderData *context, Sequence *seq, Sequence *seq_orig, - rctf *view_area, - const short *stop) + const rctf *view_area, + const bool *stop) { SeqRenderState state; seq_render_state_init(&state); diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 1f9de8040f6..329e22c156a 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -341,6 +341,18 @@ void WM_cursor_warp(struct wmWindow *win, int x, int y); /* Handlers. */ +typedef enum eWM_EventHandlerFlag { + /** After this handler all others are ignored. */ + WM_HANDLER_BLOCKING = (1 << 0), + /** Handler accepts double key press events. */ + WM_HANDLER_ACCEPT_DBL_CLICK = (1 << 1), + + /* Internal. */ + /** Handler tagged to be freed in #wm_handlers_do(). */ + WM_HANDLER_DO_FREE = (1 << 7), +} eWM_EventHandlerFlag; +ENUM_OPERATORS(eWM_EventHandlerFlag, WM_HANDLER_DO_FREE) + typedef bool (*EventHandlerPoll)(const ARegion *region, const struct wmEvent *event); struct wmEventHandler_Keymap *WM_event_add_keymap_handler(ListBase *handlers, wmKeyMap *keymap); struct wmEventHandler_Keymap *WM_event_add_keymap_handler_poll(ListBase *handlers, @@ -407,7 +419,7 @@ struct wmEventHandler_UI *WM_event_add_ui_handler(const struct bContext *C, wmUIHandlerFunc handle_fn, wmUIHandlerRemoveFunc remove_fn, void *user_data, - char flag); + eWM_EventHandlerFlag flag); /** * Return the first modal operator of type \a ot or NULL. @@ -450,15 +462,6 @@ void WM_event_modal_handler_region_replace(wmWindow *win, */ void WM_event_remove_handlers(struct bContext *C, ListBase *handlers); -/* handler flag */ -enum { - WM_HANDLER_BLOCKING = (1 << 0), /* after this handler all others are ignored */ - WM_HANDLER_ACCEPT_DBL_CLICK = (1 << 1), /* handler accepts double key press events */ - - /* internal */ - WM_HANDLER_DO_FREE = (1 << 7), /* handler tagged to be freed in wm_handlers_do() */ -}; - struct wmEventHandler_Dropbox *WM_event_add_dropbox_handler(ListBase *handlers, ListBase *dropboxes); @@ -1355,17 +1358,18 @@ void wmOrtho2_pixelspace(float x, float y); void wmGetProjectionMatrix(float mat[4][4], const struct rcti *winrct); /* threaded Jobs Manager */ -enum { +typedef enum eWM_JobFlag { WM_JOB_PRIORITY = (1 << 0), WM_JOB_EXCL_RENDER = (1 << 1), WM_JOB_PROGRESS = (1 << 2), -}; +} eWM_JobFlag; +ENUM_OPERATORS(enum eWM_JobFlag, WM_JOB_PROGRESS); /** * Identifying jobs by owner alone is unreliable, this isn't saved, * order can change (keep 0 for 'any'). */ -enum { +typedef enum eWM_JobType { WM_JOB_TYPE_ANY = 0, WM_JOB_TYPE_COMPOSITE, WM_JOB_TYPE_RENDER, @@ -1397,7 +1401,7 @@ enum { WM_JOB_TYPE_SEQ_DRAG_DROP_PREVIEW, /* add as needed, bake, seq proxy build * if having hard coded values is a problem */ -}; +} eWM_JobType; /** * \return current job or adds new job, but doesn't run it. @@ -1409,8 +1413,8 @@ struct wmJob *WM_jobs_get(struct wmWindowManager *wm, struct wmWindow *win, const void *owner, const char *name, - int flag, - int job_type); + eWM_JobFlag flag, + eWM_JobType job_type); /** * Returns true if job runs, for UI (progress) indicators. @@ -1432,8 +1436,8 @@ void WM_jobs_timer(struct wmJob *, double timestep, unsigned int note, unsigned void WM_jobs_delay_start(struct wmJob *, double delay_time); typedef void (*wm_jobs_start_callback)(void *custom_data, - short *stop, - short *do_update, + bool *stop, + bool *do_update, float *progress); void WM_jobs_callbacks(struct wmJob *, wm_jobs_start_callback startjob, @@ -1463,7 +1467,7 @@ void WM_jobs_stop(struct wmWindowManager *wm, const void *owner, void *startjob) */ void WM_jobs_kill(struct wmWindowManager *wm, void *owner, - void (*)(void *, short int *, short int *, float *)); + void (*)(void *, bool *, bool *, float *)); /** * Wait until every job ended. */ diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 181ec89cabd..c84df617f98 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -4535,7 +4535,7 @@ wmEventHandler_UI *WM_event_add_ui_handler(const bContext *C, wmUIHandlerFunc handle_fn, wmUIHandlerRemoveFunc remove_fn, void *user_data, - const char flag) + const eWM_EventHandlerFlag flag) { wmEventHandler_UI *handler = MEM_cnew<wmEventHandler_UI>(__func__); handler->head.type = WM_HANDLER_TYPE_UI; diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 5360f327a0a..fcfc83312b8 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -108,8 +108,10 @@ struct wmJob { /* internal */ const void *owner; - int flag; - short suspended, running, ready, do_update, stop, job_type; + eWM_JobFlag flag; + bool suspended, running, ready; + eWM_JobType job_type; + bool do_update, stop; float progress; /** For display in header, identification */ @@ -152,9 +154,9 @@ static void wm_job_main_thread_yield(wmJob *wm_job) /** * Finds if type or owner, compare for it, otherwise any matching job. */ -static wmJob *wm_job_find(const wmWindowManager *wm, const void *owner, const int job_type) +static wmJob *wm_job_find(const wmWindowManager *wm, const void *owner, const eWM_JobType job_type) { - if (owner && job_type) { + if (owner && (job_type != WM_JOB_TYPE_ANY)) { LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) { if (wm_job->owner == owner && wm_job->job_type == job_type) { return wm_job; @@ -168,7 +170,7 @@ static wmJob *wm_job_find(const wmWindowManager *wm, const void *owner, const in } } } - else if (job_type) { + else if (job_type != WM_JOB_TYPE_ANY) { LISTBASE_FOREACH (wmJob *, wm_job, &wm->jobs) { if (wm_job->job_type == job_type) { return wm_job; @@ -185,8 +187,8 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, - int flag, - int job_type) + const eWM_JobFlag flag, + const eWM_JobType job_type) { wmJob *wm_job = wm_job_find(wm, owner, job_type); @@ -593,7 +595,7 @@ void WM_jobs_stop(wmWindowManager *wm, const void *owner, void *startjob) void WM_jobs_kill(wmWindowManager *wm, void *owner, - void (*startjob)(void *, short int *, short int *, float *)) + void (*startjob)(void *, bool *, bool *, float *)) { LISTBASE_FOREACH_MUTABLE (wmJob *, wm_job, &wm->jobs) { if (wm_job->owner == owner || wm_job->startjob == startjob) { diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index edbfe0202de..f49be20e174 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -29,21 +29,21 @@ extern "C" { /* wmKeyMap is in DNA_windowmanager.h, it's saveable */ /** Custom types for handlers, for signaling, freeing */ -enum eWM_EventHandlerType { +typedef enum eWM_EventHandlerType { WM_HANDLER_TYPE_GIZMO = 1, WM_HANDLER_TYPE_UI, WM_HANDLER_TYPE_OP, WM_HANDLER_TYPE_DROPBOX, WM_HANDLER_TYPE_KEYMAP, -}; +} eWM_EventHandlerType; typedef bool (*EventHandlerPoll)(const ARegion *region, const wmEvent *event); typedef struct wmEventHandler { struct wmEventHandler *next, *prev; - enum eWM_EventHandlerType type; - char flag; /* WM_HANDLER_BLOCKING, ... */ + eWM_EventHandlerType type; + eWM_EventHandlerFlag flag; EventHandlerPoll poll; } wmEventHandler; |