Blender  V3.3
BKE_subdiv_foreach.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2018 Blender Foundation. All rights reserved. */
3 
8 #pragma once
9 
10 #include "BLI_sys_types.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 struct Mesh;
17 struct Subdiv;
20 
22  int num_vertices,
23  int num_edges,
24  int num_loops,
25  int num_polygons,
26  const int *subdiv_polygon_offset);
27 
29  void *tls,
30  int ptex_face_index,
31  float u,
32  float v,
33  int coarse_vertex_index,
34  int coarse_poly_index,
35  int coarse_corner,
36  int subdiv_vertex_index);
37 
39  void *tls,
40  int ptex_face_index,
41  float u,
42  float v,
43  int coarse_edge_index,
44  int coarse_poly_index,
45  int coarse_corner,
46  int subdiv_vertex_index);
47 
49  void *tls,
50  int ptex_face_index,
51  float u,
52  float v,
53  int coarse_poly_index,
54  int coarse_corner,
55  int subdiv_vertex_index);
56 
58  void *tls,
59  int coarse_edge_index,
60  int subdiv_edge_index,
61  bool is_loose,
62  int subdiv_v1,
63  int subdiv_v2);
64 
66  void *tls,
67  int ptex_face_index,
68  float u,
69  float v,
70  int coarse_loop_index,
71  int coarse_poly_index,
72  int coarse_corner,
73  int subdiv_loop_index,
74  int subdiv_vertex_index,
75  int subdiv_edge_index);
76 
78  void *tls,
79  int coarse_poly_index,
80  int subdiv_poly_index,
81  int start_loop_index,
82  int num_loops);
83 
85  void *tls,
86  int coarse_vertex_index,
87  int subdiv_vertex_index);
88 
90  void *tls,
91  int coarse_edge_index,
92  float u,
93  int subdiv_vertex_index);
94 
95 typedef struct SubdivForeachContext {
96  /* Is called when topology information becomes available.
97  * Is only called once.
98  *
99  * NOTE: If this callback returns false, the foreach loop is aborted.
100  */
102  /* These callbacks are called from every ptex which shares "emitting"
103  * vertex or edge.
104  */
107  /* Those callbacks are run once per subdivision vertex, ptex is undefined
108  * as in it will be whatever first ptex face happened to be traversed in
109  * the multi-threaded environment and which shares "emitting" vertex or
110  * edge.
111  */
114  /* Called exactly once, always corresponds to a single ptex face. */
116  /* Called once for each loose vertex. One loose coarse vertex corresponds
117  * to a single subdivision vertex.
118  */
120  /* Called once per vertex created for loose edge. */
122  /* NOTE: If subdivided edge does not come from coarse edge, ORIGINDEX_NONE
123  * will be passed as coarse_edge_index.
124  */
126  /* NOTE: If subdivided loop does not come from coarse loop, ORIGINDEX_NONE
127  * will be passed as coarse_loop_index.
128  */
131 
132  /* User-defined pointer, to allow callbacks know something about context the
133  * traversal is happening for.
134  */
135  void *user_data;
136 
137  /* Initial value of TLS data. */
139  /* Size of TLS data. */
141  /* Function to free TLS storage. */
142  void (*user_data_tls_free)(void *tls);
144 
145 /* Invokes callbacks in the order and with values which corresponds to creation
146  * of final subdivided mesh.
147  *
148  * Main goal is to abstract all the traversal routines to give geometry element
149  * indices (for vertices, edges, loops, polygons) in the same way as subdivision
150  * modifier will do for a dense mesh.
151  *
152  * Returns true if the whole topology was traversed, without any early exits.
153  *
154  * TODO(sergey): Need to either get rid of subdiv or of coarse_mesh.
155  * The main point here is to be able to get base level topology, which can be
156  * done with either of those. Having both of them is kind of redundant.
157  */
159  const struct SubdivForeachContext *context,
160  const struct SubdivToMeshSettings *mesh_settings,
161  const struct Mesh *coarse_mesh);
162 
163 #ifdef __cplusplus
164 }
165 #endif
void(* SubdivForeachPolygonCb)(const struct SubdivForeachContext *context, void *tls, int coarse_poly_index, int subdiv_poly_index, int start_loop_index, int num_loops)
bool(* SubdivForeachTopologyInformationCb)(const struct SubdivForeachContext *context, int num_vertices, int num_edges, int num_loops, int num_polygons, const int *subdiv_polygon_offset)
void(* SubdivForeachVertexFromCornerCb)(const struct SubdivForeachContext *context, void *tls, int ptex_face_index, float u, float v, int coarse_vertex_index, int coarse_poly_index, int coarse_corner, int subdiv_vertex_index)
void(* SubdivForeachEdgeCb)(const struct SubdivForeachContext *context, void *tls, int coarse_edge_index, int subdiv_edge_index, bool is_loose, int subdiv_v1, int subdiv_v2)
void(* SubdivForeachLooseCb)(const struct SubdivForeachContext *context, void *tls, int coarse_vertex_index, int subdiv_vertex_index)
void(* SubdivForeachVertexOfLooseEdgeCb)(const struct SubdivForeachContext *context, void *tls, int coarse_edge_index, float u, int subdiv_vertex_index)
void(* SubdivForeachLoopCb)(const struct SubdivForeachContext *context, void *tls, int ptex_face_index, float u, float v, int coarse_loop_index, int coarse_poly_index, int coarse_corner, int subdiv_loop_index, int subdiv_vertex_index, int subdiv_edge_index)
bool BKE_subdiv_foreach_subdiv_geometry(struct Subdiv *subdiv, const struct SubdivForeachContext *context, const struct SubdivToMeshSettings *mesh_settings, const struct Mesh *coarse_mesh)
void(* SubdivForeachVertexFromEdgeCb)(const struct SubdivForeachContext *context, void *tls, int ptex_face_index, float u, float v, int coarse_edge_index, int coarse_poly_index, int coarse_corner, int subdiv_vertex_index)
void(* SubdivForeachVertexInnerCb)(const struct SubdivForeachContext *context, void *tls, int ptex_face_index, float u, float v, int coarse_poly_index, int coarse_corner, int subdiv_vertex_index)
struct SubdivForeachContext SubdivForeachContext
ATTR_WARN_UNUSED_RESULT const BMVert * v
SyclQueue void void size_t num_bytes void
SubdivForeachVertexFromEdgeCb vertex_every_edge
SubdivForeachPolygonCb poly
SubdivForeachTopologyInformationCb topology_info
SubdivForeachLooseCb vertex_loose
SubdivForeachVertexInnerCb vertex_inner
SubdivForeachVertexOfLooseEdgeCb vertex_of_loose_edge
SubdivForeachEdgeCb edge
void(* user_data_tls_free)(void *tls)
SubdivForeachVertexFromEdgeCb vertex_edge
SubdivForeachVertexFromCornerCb vertex_corner
SubdivForeachVertexFromCornerCb vertex_every_corner
SubdivForeachLoopCb loop