Blender V5.3
multires_reshape.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "DNA_key_types.h"
12
14#include "BLI_offset_indices.hh"
15#include "BLI_span.hh"
16#include "BLI_virtual_array.hh"
17
18#include "BKE_multires.hh"
19
20namespace blender {
21
22struct Depsgraph;
23struct GridPaintMask;
24struct MDisps;
25struct Mesh;
27struct Object;
28namespace bke::subdiv {
29struct Subdiv;
30}
31struct SubdivCCG;
32
34 /* NOTE: Only available when context is initialized from object. */
35 Depsgraph *depsgraph;
37
40 /* Base mesh from original object.
41 * NOTE: Does NOT include any leading modifiers in it. */
48
49 /* Subdivision surface created for multires modifier.
50 *
51 * The coarse mesh of this subdivision surface is a base mesh with all deformation modifiers
52 * leading multires applied on it. */
55
56 struct {
57 /* Level at which displacement is being assigned to.
58 * It will be propagated up from this level to top.level. */
59 int level;
60
61 /* Grid size for reshape.level. */
62 int grid_size;
64
65 struct {
66 /* Top level of the displacement grids.
67 * The displacement will be propagated up to this level. */
68 int level;
69
70 /* Grid size for top.level. */
71 int grid_size;
72 } top;
73
74 struct {
75 /* Copy of original displacement and painting masks. */
78
79 int grid_size;
81
82 /* Number of grids which are required for base_mesh. */
84
85 /* Destination displacement and mask.
86 * Points to a custom data on a destination mesh. */
89
90 /* Indexed by grid index, contains face index in the base mesh from which the grid has
91 * been created (in other words, index of a face which contains loop corresponding to the grid
92 * index).
93 *
94 * There is exactly one grid per face corner, so this is simply the base mesh's corner to face
95 * map. Similarly, the first grid index of a face is `base_faces[face_index].start()`. */
97
98 /* Indexed by ptex face index, gives first grid index of the ptex face.
99 *
100 * Only computed when the reshape needs to map ptex coordinates back to grid coordinates, which
101 * is not the case when displacement is assigned at the top level.
102 *
103 * For non-quad base faces ptex face is created for every face corner, so it's similar to a
104 * grid in this case. In this case start grid index will be the only one for this ptex face.
105 *
106 * For quad base faces there is a single ptex face but 4 grids. So in this case there will be
107 * 4 grids for the ptex, starting at a value stored in this mapping. */
109
110 /* Indexed by base face index, returns first ptex face index corresponding
111 * to that base face. */
113
114 /* Vertex crease custom data layer, empty if none is present. */
116 /* Edge crease custom data layer, empty if none is present. */
118};
119
124struct GridCoord {
126 float u, v;
127};
128
132struct PTexCoord {
134 float u, v;
135};
136
145
150
151/* -------------------------------------------------------------------- */
154
160 Object *object,
161 const MultiresModifierData *mmd);
162
169 Depsgraph *depsgraph,
170 Object *object,
172
174 Depsgraph *depsgraph,
175 Object *object,
177
179 SubdivCCG *subdiv_ccg,
180 Mesh *base_mesh,
181 int top_level);
182
184 Object *object,
186 int top_level);
187
189 Object *object,
192 int top_level);
193
196
198
199/* -------------------------------------------------------------------- */
202
207 int grid_index);
208
212int multires_reshape_grid_to_corner(const MultiresReshapeContext *reshape_context, int grid_index);
213
214bool multires_reshape_is_quad_face(const MultiresReshapeContext *reshape_context, int face_index);
215
220 int grid_index);
221
226 const GridCoord *grid_coord);
227
232 const PTexCoord *ptex_coord);
233
239 int face_index,
240 int corner,
241 const float3 &dPdu,
242 const float3 &dPdv,
243 float3x3 &r_tangent_matrix);
244
250 const MultiresReshapeContext *reshape_context, const GridCoord *grid_coord);
252 const MultiresReshapeContext *reshape_context, const PTexCoord *ptex_coord);
253
258 const MultiresReshapeContext *reshape_context, const GridCoord *grid_coord);
259
261
262/* -------------------------------------------------------------------- */
265
271 const MultiresReshapeContext *reshape_context,
272 const GridCoord *grid_coord,
273 float3 &r_P,
274 float3x3 &r_tangent_matrix);
275
277
278/* -------------------------------------------------------------------- */
281
285void multires_reshape_ensure_grids(Mesh *mesh, int level);
286
288
289/* -------------------------------------------------------------------- */
292
302 const MultiresReshapeContext *reshape_context, Span<float3> positions);
303
305
306/* -------------------------------------------------------------------- */
309
320 SubdivCCG *subdiv_ccg);
321
323
324/* -------------------------------------------------------------------- */
327
332 const MultiresReshapeContext *reshape_context);
333
338 const MultiresReshapeContext *reshape_context);
339
341
342/* -------------------------------------------------------------------- */
345
354 const MultiresReshapeContext *reshape_context);
355
364
366
367/* -------------------------------------------------------------------- */
370
376
378 const MultiresReshapeContext *reshape_context);
379
381
382/* -------------------------------------------------------------------- */
385
393
399
405
410
418
420
421} // namespace blender
BMesh Iterators.
void multires_reshape_assign_final_coords_from_mdisps(const MultiresReshapeContext *reshape_context)
void multires_reshape_store_original_grids(MultiresReshapeContext *reshape_context)
void multires_reshape_smooth_object_grids(const MultiresReshapeContext *reshape_context, MultiresSubdivideModeType mode)
void multires_reshape_apply_base_update_mesh_coords(MultiresReshapeContext *reshape_context)
int multires_reshape_grid_to_face_index(const MultiresReshapeContext *reshape_context, int grid_index)
void multires_reshape_smooth_object_grids_with_details(const MultiresReshapeContext *reshape_context)
void multires_reshape_ensure_grids(Mesh *mesh, int level)
bke::subdiv::Subdiv * multires_reshape_create_subdiv(Depsgraph *depsgraph, Object *object, const MultiresModifierData *mmd)
GridCoord multires_reshape_ptex_coord_to_grid(const MultiresReshapeContext *reshape_context, const PTexCoord *ptex_coord)
void multires_reshape_apply_base_refit_base_mesh(MultiresReshapeContext *reshape_context)
bool multires_reshape_context_create_from_subdiv(MultiresReshapeContext *reshape_context, Object *object, MultiresModifierData *mmd, bke::subdiv::Subdiv *subdiv, int top_level)
void multires_reshape_assign_final_elements_from_orig_mdisps(const MultiresReshapeContext *reshape_context)
bool multires_reshape_assign_final_coords_from_vertcos(const MultiresReshapeContext *reshape_context, Span< float3 > positions)
ReshapeGridElement multires_reshape_grid_element_for_ptex_coord(const MultiresReshapeContext *reshape_context, const PTexCoord *ptex_coord)
void multires_reshape_apply_base_refine_from_base(MultiresReshapeContext *reshape_context)
void multires_reshape_free_original_grids(MultiresReshapeContext *reshape_context)
int multires_reshape_grid_to_corner(const MultiresReshapeContext *reshape_context, int grid_index)
int multires_reshape_grid_to_ptex_index(const MultiresReshapeContext *reshape_context, int grid_index)
MultiresSubdivideModeType
bool multires_reshape_context_create_from_base_mesh(MultiresReshapeContext *reshape_context, Depsgraph *depsgraph, Object *object, MultiresModifierData *mmd)
void multires_reshape_apply_base_update_shape_key(MultiresReshapeContext *reshape_context)
void multires_reshape_tangent_matrix_for_corner(const MultiresReshapeContext *reshape_context, int face_index, int corner, const float3 &dPdu, const float3 &dPdv, float3x3 &r_tangent_matrix)
MatBase< float, 3, 3 > float3x3
bool multires_reshape_context_create_from_object(MultiresReshapeContext *reshape_context, Depsgraph *depsgraph, Object *object, MultiresModifierData *mmd)
void multires_reshape_context_free(MultiresReshapeContext *reshape_context)
void multires_reshape_apply_base_refine_from_deform(MultiresReshapeContext *reshape_context)
void multires_reshape_object_grids_to_tangent_displacement(const MultiresReshapeContext *reshape_context)
ReshapeGridElement multires_reshape_grid_element_for_grid_coord(const MultiresReshapeContext *reshape_context, const GridCoord *grid_coord)
ReshapeConstGridElement multires_reshape_orig_grid_element_for_grid_coord(const MultiresReshapeContext *reshape_context, const GridCoord *grid_coord)
bool multires_reshape_assign_final_coords_from_ccg(const MultiresReshapeContext *reshape_context, SubdivCCG *subdiv_ccg)
void multires_reshape_evaluate_base_mesh_limit_at_grid(const MultiresReshapeContext *reshape_context, const GridCoord *grid_coord, float3 &r_P, float3x3 &r_tangent_matrix)
VecBase< float, 3 > float3
PTexCoord multires_reshape_grid_coord_to_ptex(const MultiresReshapeContext *reshape_context, const GridCoord *grid_coord)
bool multires_reshape_context_create_from_modifier(MultiresReshapeContext *reshape_context, Object *object, MultiresModifierData *mmd, int top_level)
bool multires_reshape_context_create_from_ccg(MultiresReshapeContext *reshape_context, SubdivCCG *subdiv_ccg, Mesh *base_mesh, int top_level)
bool multires_reshape_is_quad_face(const MultiresReshapeContext *reshape_context, int face_index)
struct blender::MultiresReshapeContext::@061205041363017306277142220221215107241001341347 orig
struct blender::MultiresReshapeContext::@021252173372013124221256162374334156074326245244 top
struct blender::MultiresReshapeContext::@034344347246210140240253130013212240027344072112 reshape