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 
17 /** \file
18  * \ingroup DNA
19  */
20 
21 #pragma once
22 
23 #include "DNA_freestyle_types.h"
24 #include "DNA_listBase.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /**
31  * Render-passes for EEVEE.
32  * #ViewLayerEEVEE.render_passes
33  */
34 typedef enum eViewLayerEEVEEPassType {
35   EEVEE_RENDER_PASS_COMBINED = (1 << 0),
36   EEVEE_RENDER_PASS_Z = (1 << 1),
37   EEVEE_RENDER_PASS_MIST = (1 << 2),
38   EEVEE_RENDER_PASS_NORMAL = (1 << 3),
39   EEVEE_RENDER_PASS_DIFFUSE_LIGHT = (1 << 4),
40   EEVEE_RENDER_PASS_DIFFUSE_COLOR = (1 << 5),
41   EEVEE_RENDER_PASS_SPECULAR_LIGHT = (1 << 6),
42   EEVEE_RENDER_PASS_SPECULAR_COLOR = (1 << 7),
43   EEVEE_RENDER_PASS_VOLUME_TRANSMITTANCE = (1 << 8),
44   EEVEE_RENDER_PASS_VOLUME_SCATTER = (1 << 9),
45   EEVEE_RENDER_PASS_EMIT = (1 << 10),
46   EEVEE_RENDER_PASS_ENVIRONMENT = (1 << 11),
47   EEVEE_RENDER_PASS_SHADOW = (1 << 12),
48   EEVEE_RENDER_PASS_AO = (1 << 13),
49   EEVEE_RENDER_PASS_BLOOM = (1 << 14),
50 } eViewLayerEEVEEPassType;
51 #define EEVEE_RENDER_PASS_MAX_BIT 15
52 
53 typedef struct Base {
54   struct Base *next, *prev;
55 
56   /* Flags which are based on the collections flags evaluation, does not
57    * include flags from object's restrictions. */
58   short flag_from_collection;
59 
60   /* Final flags, including both accumulated collection flags and object's
61    * restriction flags. */
62   short flag;
63 
64   unsigned short local_view_bits;
65   short sx, sy;
66   char _pad1[6];
67   struct Object *object;
68   unsigned int lay DNA_DEPRECATED;
69   int flag_legacy;
70   unsigned short local_collections_bits;
71   short _pad2[3];
72 
73   /* Pointer to an original base. Is initialized for evaluated view layer.
74    * NOTE: Only allowed to be accessed from within active dependency graph. */
75   struct Base *base_orig;
76   void *_pad;
77 } Base;
78 
79 typedef struct ViewLayerEngineData {
80   struct ViewLayerEngineData *next, *prev;
81   struct DrawEngineType *engine_type;
82   void *storage;
83   void (*free)(void *storage);
84 } ViewLayerEngineData;
85 
86 typedef struct LayerCollection {
87   struct LayerCollection *next, *prev;
88   struct Collection *collection;
89   struct SceneCollection *scene_collection DNA_DEPRECATED;
90   short flag;
91   short runtime_flag;
92   char _pad[4];
93 
94   /** Synced with collection->children. */
95   ListBase layer_collections;
96 
97   unsigned short local_collections_bits;
98   short _pad2[3];
99 } LayerCollection;
100 
101 /* Type containing EEVEE settings per view-layer */
102 typedef struct ViewLayerEEVEE {
103   int render_passes;
104   int _pad[1];
105 } ViewLayerEEVEE;
106 
107 typedef struct ViewLayer {
108   struct ViewLayer *next, *prev;
109   /** MAX_NAME. */
110   char name[64];
111   short flag;
112   char _pad[6];
113   /** ObjectBase. */
114   ListBase object_bases;
115   /** Default allocated now. */
116   struct SceneStats *stats;
117   struct Base *basact;
118 
119   /** A view layer has one top level layer collection, because a scene has only one top level
120    * collection. The layer_collections list always contains a single element. ListBase is
121    * convenient when applying functions to all layer collections recursively. */
122   ListBase layer_collections;
123   LayerCollection *active_collection;
124 
125   /* Old SceneRenderLayer data. */
126   int layflag;
127   /** Pass_xor has to be after passflag. */
128   int passflag;
129   float pass_alpha_threshold;
130   int samples;
131 
132   struct Material *mat_override;
133   /** Equivalent to datablocks ID properties. */
134   struct IDProperty *id_properties;
135 
136   struct FreestyleConfig freestyle_config;
137   struct ViewLayerEEVEE eevee;
138 
139   /* Runtime data */
140   /** ViewLayerEngineData. */
141   ListBase drawdata;
142   struct Base **object_bases_array;
143   struct GHash *object_bases_hash;
144 } ViewLayer;
145 
146 /* Base->flag */
147 enum {
148   /* User controlled flags. */
149   BASE_SELECTED = (1 << 0), /* Object is selected. */
150   BASE_HIDDEN = (1 << 8),   /* Object is hidden for editing. */
151 
152   /* Runtime evaluated flags. */
153   BASE_VISIBLE_DEPSGRAPH = (1 << 1), /* Object is enabled and visible for the depsgraph. */
154   BASE_SELECTABLE = (1 << 2),        /* Object can be selected. */
155   BASE_FROM_DUPLI = (1 << 3),        /* Object comes from duplicator. */
156   BASE_VISIBLE_VIEWLAYER = (1 << 4), /* Object is enabled and visible for the viewlayer. */
157   BASE_FROM_SET = (1 << 5),          /* Object comes from set. */
158   BASE_ENABLED_VIEWPORT = (1 << 6),  /* Object is enabled in viewport. */
159   BASE_ENABLED_RENDER = (1 << 7),    /* Object is enabled in final render */
160   /* BASE_DEPRECATED          = (1 << 9), */
161   BASE_HOLDOUT = (1 << 10),       /* Object masked out from render */
162   BASE_INDIRECT_ONLY = (1 << 11), /* Object only contributes indirectly to render */
163 };
164 
165 /* LayerCollection->flag */
166 enum {
167   /* LAYER_COLLECTION_DEPRECATED0 = (1 << 0), */
168   /* LAYER_COLLECTION_DEPRECATED1 = (1 << 1), */
169   /* LAYER_COLLECTION_DEPRECATED2 = (1 << 2), */
170   /* LAYER_COLLECTION_DEPRECATED3 = (1 << 3), */
171   LAYER_COLLECTION_EXCLUDE = (1 << 4),
172   LAYER_COLLECTION_HOLDOUT = (1 << 5),
173   LAYER_COLLECTION_INDIRECT_ONLY = (1 << 6),
174   LAYER_COLLECTION_HIDE = (1 << 7),
175   LAYER_COLLECTION_PREVIOUSLY_EXCLUDED = (1 << 8),
176 };
177 
178 /* Layer Collection->runtime_flag
179  * Keep it synced with base->flag based on g_base_collection_flags. */
180 enum {
181   LAYER_COLLECTION_HAS_OBJECTS = (1 << 0),
182   /* LAYER_COLLECTION_VISIBLE_DEPSGRAPH = (1 << 1), */ /* UNUSED */
183   LAYER_COLLECTION_RESTRICT_VIEWPORT = (1 << 2),
184   LAYER_COLLECTION_VISIBLE_VIEW_LAYER = (1 << 4),
185 };
186 
187 /* ViewLayer->flag */
188 enum {
189   VIEW_LAYER_RENDER = (1 << 0),
190   /* VIEW_LAYER_DEPRECATED  = (1 << 1), */
191   VIEW_LAYER_FREESTYLE = (1 << 2),
192 };
193 
194 /****************************** Deprecated ******************************/
195 
196 /* Compatibility with collections saved in early 2.8 versions,
197  * used in file reading and versioning code. */
198 #define USE_COLLECTION_COMPAT_28
199 
200 typedef struct SceneCollection {
201   struct SceneCollection *next, *prev;
202   /** MAX_NAME. */
203   char name[64];
204   /** For UI. */
205   int active_object_index;
206   short flag;
207   char type;
208   char _pad;
209   /** (Object *)LinkData->data. */
210   ListBase objects;
211   /** Nested collections. */
212   ListBase scene_collections;
213 } SceneCollection;
214 
215 #ifdef __cplusplus
216 }
217 #endif
218