Fix T64842: crash rendering files with bevel curves
[blender.git] / source / blender / blenkernel / BKE_mesh_tangent.h
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 #ifndef __BKE_MESH_TANGENT_H__
17 #define __BKE_MESH_TANGENT_H__
18
19 /** \file
20  * \ingroup bke
21  */
22
23 void BKE_mesh_calc_loop_tangent_single_ex(const struct MVert *mverts,
24                                           const int numVerts,
25                                           const struct MLoop *mloops,
26                                           float (*r_looptangent)[4],
27                                           float (*loopnors)[3],
28                                           const struct MLoopUV *loopuv,
29                                           const int numLoops,
30                                           const struct MPoly *mpolys,
31                                           const int numPolys,
32                                           struct ReportList *reports);
33 void BKE_mesh_calc_loop_tangent_single(struct Mesh *mesh,
34                                        const char *uvmap,
35                                        float (*r_looptangents)[4],
36                                        struct ReportList *reports);
37
38 void BKE_mesh_calc_loop_tangent_ex(const struct MVert *mvert,
39                                    const struct MPoly *mpoly,
40                                    const uint mpoly_len,
41                                    const struct MLoop *mloop,
42                                    const struct MLoopTri *looptri,
43                                    const uint looptri_len,
44
45                                    struct CustomData *loopdata,
46                                    bool calc_active_tangent,
47                                    const char (*tangent_names)[64],
48                                    int tangent_names_len,
49                                    const float (*poly_normals)[3],
50                                    const float (*loop_normals)[3],
51                                    const float (*vert_orco)[3],
52                                    /* result */
53                                    struct CustomData *loopdata_out,
54                                    const uint loopdata_out_len,
55                                    short *tangent_mask_curr_p);
56
57 void BKE_mesh_calc_loop_tangents(struct Mesh *me_eval,
58                                  bool calc_active_tangent,
59                                  const char (*tangent_names)[MAX_NAME],
60                                  int tangent_names_len);
61
62 /* Helpers */
63 void BKE_mesh_add_loop_tangent_named_layer_for_uv(struct CustomData *uv_data,
64                                                   struct CustomData *tan_data,
65                                                   int numLoopData,
66                                                   const char *layer_name);
67
68 #define DM_TANGENT_MASK_ORCO (1 << 9)
69 void BKE_mesh_calc_loop_tangent_step_0(const struct CustomData *loopData,
70                                        bool calc_active_tangent,
71                                        const char (*tangent_names)[64],
72                                        int tangent_names_count,
73                                        bool *rcalc_act,
74                                        bool *rcalc_ren,
75                                        int *ract_uv_n,
76                                        int *rren_uv_n,
77                                        char *ract_uv_name,
78                                        char *rren_uv_name,
79                                        short *rtangent_mask);
80
81 #endif /* __BKE_MESH_TANGENT_H__ */