7fee06021b8c50c77d13bce763940034a168e578
[blender.git] / intern / gawain / src / primitive.c
1
2 // Gawain geometric primitives
3 //
4 // This code is part of the Gawain library, with modifications
5 // specific to integration with Blender.
6 //
7 // Copyright 2017 Mike Erwin
8 //
9 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of
10 // the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
11
12 #include "primitive.h"
13
14 PrimitiveClass prim_class_of_type(PrimitiveType prim_type)
15         {
16         static const PrimitiveClass classes[] =
17                 {
18                 [PRIM_NONE] = PRIM_CLASS_NONE,
19                 [PRIM_POINTS] = PRIM_CLASS_POINT,
20                 [PRIM_LINES] = PRIM_CLASS_LINE,
21                 [PRIM_LINE_STRIP] = PRIM_CLASS_LINE,
22                 [PRIM_LINE_LOOP] = PRIM_CLASS_LINE,
23                 [PRIM_TRIANGLES] = PRIM_CLASS_SURFACE,
24                 [PRIM_TRIANGLE_STRIP] = PRIM_CLASS_SURFACE,
25                 [PRIM_TRIANGLE_FAN] = PRIM_CLASS_SURFACE,
26
27 #ifdef WITH_GL_PROFILE_COMPAT
28                 [PRIM_QUADS_XXX] = PRIM_CLASS_SURFACE,
29 #endif
30                 };
31
32         return classes[prim_type];
33         }
34
35 bool prim_type_belongs_to_class(PrimitiveType prim_type, PrimitiveClass prim_class)
36         {
37         if (prim_class == PRIM_CLASS_NONE && prim_type == PRIM_NONE)
38                 return true;
39
40         return prim_class & prim_class_of_type(prim_type);
41         }