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

opensubdiv_topology_refiner_capi.h « opensubdiv « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 103ccd2c1f9532b0facd408a1e5e535ceb18e633 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2018 Blender Foundation. All rights reserved.
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// Author: Sergey Sharybin

#ifndef OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_
#define OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_

#include <stdint.h>  // for bool

#ifdef __cplusplus
extern "C" {
#endif

struct OpenSubdiv_Converter;
struct OpenSubdiv_TopologyRefinerInternal;

// Those settings don't really belong to OpenSubdiv's topology refiner, but
// we are keeping track of them on our side of topology refiner. This is to
// make it possible to ensure we are not trying to abuse same OpenSubdiv's
// topology refiner with different subdivision levels or with different
// adaptive settings.
typedef struct OpenSubdiv_TopologyRefinerSettings {
  bool is_adaptive;
  int level;
} OpenSubdiv_TopologyRefinerSettings;

typedef struct OpenSubdiv_TopologyRefiner {
  // Query subdivision level the refiner is created for.
  int (*getSubdivisionLevel)(
      const struct OpenSubdiv_TopologyRefiner* topology_refiner);
  bool (*getIsAdaptive)(
      const struct OpenSubdiv_TopologyRefiner* topology_refiner);

  // Query basic topology information from base level.
  int (*getNumVertices)(
      const struct OpenSubdiv_TopologyRefiner* topology_refiner);
  int (*getNumEdges)(
      const struct OpenSubdiv_TopologyRefiner* topology_refiner);
  int (*getNumFaces)(
      const struct OpenSubdiv_TopologyRefiner* topology_refiner);
  int (*getNumFaceVertices)(
      const struct OpenSubdiv_TopologyRefiner* topology_refiner,
      const int face_index);

  // Ptex face corresponds to OpenSubdiv's internal "patch" and to Blender's
  // subdivision grid. The rule commes as:
  // - Triangle face consist of 3 ptex faces, ordered in the order of
  //   face-vertices.
  // - Quad face consists of a single ptex face.
  // - N-gons (similar to triangle) consists of N ptex faces, ordered same
  //   way as for triangle.
  int (*getNumFacePtexFaces)(
      const struct OpenSubdiv_TopologyRefiner* topology_refiner,
      const int face_index);
  int (*getNumPtexFaces)(
      const struct OpenSubdiv_TopologyRefiner* topology_refiner);

  // Initialize a per-base-face offset measured in ptex face indices.
  //
  // Basically, face_ptex_offset[base_face_index] is a total number of ptex
  // faces created for bases faces [0 .. base_face_index - 1].
  //
  // The array must contain at least total number of ptex faces elements.
  void (*fillFacePtexIndexOffset)(
      const struct OpenSubdiv_TopologyRefiner* topology_refiner,
      int* face_ptex_index_offset);

  // Internal storage for the use in this module only.
  //
  // Tease: Contains actual OpenSubdiv's refiner and (optionally) some other
  // data and state needed for an internbal use.
  struct OpenSubdiv_TopologyRefinerInternal* internal;
} OpenSubdiv_TopologyRefiner;

OpenSubdiv_TopologyRefiner* openSubdiv_createTopologyRefinerFromConverter(
    struct OpenSubdiv_Converter* converter,
    const OpenSubdiv_TopologyRefinerSettings* settings);

void openSubdiv_deleteTopologyRefiner(
    OpenSubdiv_TopologyRefiner* topology_refiner);

// Compare given topology refiner with converter. Returns truth if topology
// refiner matches given converter, false otherwise.
//
// This allows users to construct converter (which is supposed to be cheap)
// and compare with existing refiner before going into more computationally
// complicated parts of subdivision process.
bool openSubdiv_topologyRefinerCompareWithConverter(
    const OpenSubdiv_TopologyRefiner* topology_refiner,
    const OpenSubdiv_Converter* converter);

#ifdef __cplusplus
}
#endif

#endif  // OPENSUBDIV_TOPOLOGY_REFINER_CAPI_H_