Merge branch 'master' into blender2.8
[blender.git] / source / blender / blenkernel / intern / subdiv_converter.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * The Original Code is Copyright (C) 2018 by Blender Foundation.
19  * All rights reserved.
20  *
21  * Contributor(s): Sergey Sharybin.
22  *
23  * ***** END GPL LICENSE BLOCK *****
24  */
25
26 /** \file blender/blenkernel/intern/subdiv_converter.c
27  *  \ingroup bke
28  */
29
30 #include "subdiv_converter.h"
31
32 #include "BLI_utildefines.h"
33
34 #include "opensubdiv_converter_capi.h"
35
36 void BKE_subdiv_converter_free(struct OpenSubdiv_Converter *converter)
37 {
38         if (converter->freeUserData) {
39                 converter->freeUserData(converter);
40         }
41 }
42
43 int BKE_subdiv_converter_vtx_boundary_interpolation_from_settings(
44         const SubdivSettings *settings)
45 {
46         switch (settings->vtx_boundary_interpolation) {
47                 case SUBDIV_VTX_BOUNDARY_NONE:
48                         return OSD_VTX_BOUNDARY_NONE;
49                 case SUBDIV_VTX_BOUNDARY_EDGE_ONLY:
50                         return OSD_VTX_BOUNDARY_EDGE_ONLY;
51                 case SUBDIV_VTX_BOUNDARY_EDGE_AND_CORNER:
52                         return OSD_VTX_BOUNDARY_EDGE_AND_CORNER;
53         }
54         BLI_assert(!"Unknown vtx boundary interpolation");
55         return OSD_VTX_BOUNDARY_EDGE_ONLY;
56 }
57
58 /*OpenSubdiv_FVarLinearInterpolation*/ int
59 BKE_subdiv_converter_fvar_linear_from_settings(const SubdivSettings *settings)
60 {
61         switch (settings->fvar_linear_interpolation) {
62                 case SUBDIV_FVAR_LINEAR_INTERPOLATION_NONE:
63                         return OSD_FVAR_LINEAR_INTERPOLATION_NONE;
64                 case SUBDIV_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY:
65                         return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY;
66                 case SUBDIV_FVAR_LINEAR_INTERPOLATION_CORNERS_AND_JUNCTIONS:
67                         return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1;
68                 case SUBDIV_FVAR_LINEAR_INTERPOLATION_CORNERS_JUNCTIONS_AND_CONCAVE:
69                         return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2;
70                 case SUBDIV_FVAR_LINEAR_INTERPOLATION_BOUNDARIES:
71                         return OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES;
72                 case SUBDIV_FVAR_LINEAR_INTERPOLATION_ALL:
73                         return OSD_FVAR_LINEAR_INTERPOLATION_ALL;
74         }
75         BLI_assert(!"Unknown fvar linear interpolation");
76         return OSD_FVAR_LINEAR_INTERPOLATION_NONE;
77 }