Welcome to mirror list, hosted at ThFree Co, Russian Federation.

multires_unsubdivide.h « intern « blenkernel « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 09df77206947002794739b08a025b19f2615fb2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* SPDX-License-Identifier: GPL-2.0-or-later
 * Copyright 2020 Blender Foundation. All rights reserved. */

/** \file
 * \ingroup bke
 */

#pragma once

#include "BLI_sys_types.h"

struct BMesh;
struct Mesh;
struct MultiresModifierData;

typedef struct MultiresUnsubdivideGrid {
  /* For sanity checks. */
  int grid_index;
  int grid_size;

  /** Grid coordinates in object space. */
  float (*grid_co)[3];

} MultiresUnsubdivideGrid;

typedef struct MultiresUnsubdivideContext {
  /* Input Mesh to un-subdivide. */
  struct Mesh *original_mesh;
  struct MDisps *original_mdisp;

  /** Number of subdivision in the grids of the input mesh. */
  int num_original_levels;

  /** Level 0 base mesh after applying the maximum amount of unsubdivisions. */
  struct Mesh *base_mesh;

  /** Limit on how many levels down the unsubdivide operation should create, if possible. */
  int max_new_levels;

  /** New levels that were created after unsubdividing. */
  int num_new_levels;

  /**
   * Number of subdivisions that should be applied to the base mesh.
   * (num_new_levels + num_original_levels).
   */
  int num_total_levels;

  /** Data for the new grids, indexed by base mesh loop index. */
  int num_grids;
  struct MultiresUnsubdivideGrid *base_mesh_grids;

  /* Private data. */
  struct BMesh *bm_original_mesh;
  int *loop_to_face_map;
  int *base_to_orig_vmap;
} MultiresUnsubdivideContext;

/* --------------------------------------------------------------------
 * Construct/destruct reshape context.
 */

void multires_unsubdivide_context_init(MultiresUnsubdivideContext *context,
                                       struct Mesh *original_mesh,
                                       struct MultiresModifierData *mmd);
void multires_unsubdivide_context_free(MultiresUnsubdivideContext *context);

/* --------------------------------------------------------------------
 * Rebuild Lower Subdivisions.
 */

/* Rebuilds all subdivision to the level 0 base mesh. */
bool multires_unsubdivide_to_basemesh(MultiresUnsubdivideContext *context);