Blender  V2.93
Common.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 
21 #pragma once
22 
23 #ifndef MIN
24 # define MIN(a, b) ((a) <= (b) ? (a) : (b))
25 #endif
26 #ifndef MAX
27 # define MAX(a, b) ((a) >= (b) ? (a) : (b))
28 #endif
29 #ifndef CLAMP
30 # define CLAMP(x, a, b) MIN(MAX((x), (a)), (b))
31 #endif
32 
33 template<typename T> inline void swap(T &a, T &b)
34 {
35  T tmp = a;
36  a = b;
37  b = tmp;
38 }
39 
40 typedef unsigned char uint8;
41 typedef unsigned short uint16;
42 typedef unsigned int uint;
43 typedef unsigned int uint32;
44 typedef unsigned long long uint64;
45 
46 // copied from nvtt src/nvimage/nvimage.h
47 inline uint computePitch(uint w, uint bitsize, uint alignment)
48 {
49  return ((w * bitsize + 8 * alignment - 1) / (8 * alignment)) * alignment;
50 }
unsigned int uint
Definition: BLI_sys_types.h:83
unsigned short uint16
Definition: Common.h:41
unsigned int uint32
Definition: Common.h:43
unsigned long long uint64
Definition: Common.h:44
uint computePitch(uint w, uint bitsize, uint alignment)
Definition: Common.h:47
unsigned int uint
Definition: Common.h:42
void swap(T &a, T &b)
Definition: Common.h:33
unsigned char uint8
Definition: Common.h:40
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
#define T
static unsigned a[3]
Definition: RandGen.cpp:92