Blender  V2.93
multires_inline.h
Go to the documentation of this file.
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  * The Original Code is Copyright (C) 2018 by Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 #include "BKE_multires.h"
27 #include "BLI_math_vector.h"
28 #include "BLI_utildefines.h"
29 
30 BLI_INLINE void BKE_multires_construct_tangent_matrix(float tangent_matrix[3][3],
31  const float dPdu[3],
32  const float dPdv[3],
33  const int corner)
34 {
35  if (corner == 0) {
36  copy_v3_v3(tangent_matrix[0], dPdv);
37  copy_v3_v3(tangent_matrix[1], dPdu);
38  mul_v3_fl(tangent_matrix[0], -1.0f);
39  mul_v3_fl(tangent_matrix[1], -1.0f);
40  }
41  else if (corner == 1) {
42  copy_v3_v3(tangent_matrix[0], dPdu);
43  copy_v3_v3(tangent_matrix[1], dPdv);
44  mul_v3_fl(tangent_matrix[1], -1.0f);
45  }
46  else if (corner == 2) {
47  copy_v3_v3(tangent_matrix[0], dPdv);
48  copy_v3_v3(tangent_matrix[1], dPdu);
49  }
50  else if (corner == 3) {
51  copy_v3_v3(tangent_matrix[0], dPdu);
52  copy_v3_v3(tangent_matrix[1], dPdv);
53  mul_v3_fl(tangent_matrix[0], -1.0f);
54  }
55  else {
56  BLI_assert(!"Unhandled corner index");
57  }
58  cross_v3_v3v3(tangent_matrix[2], dPdu, dPdv);
59  normalize_v3(tangent_matrix[0]);
60  normalize_v3(tangent_matrix[1]);
61  normalize_v3(tangent_matrix[2]);
62 }
#define BLI_assert(a)
Definition: BLI_assert.h:58
#define BLI_INLINE
MINLINE float normalize_v3(float r[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
BLI_INLINE void BKE_multires_construct_tangent_matrix(float tangent_matrix[3][3], const float dPdu[3], const float dPdv[3], const int corner)