Blender  V3.3
FRS_freestyle.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <iostream>
8 #include <map>
9 #include <set>
10 
11 #include "../application/AppCanvas.h"
12 #include "../application/AppConfig.h"
13 #include "../application/AppView.h"
14 #include "../application/Controller.h"
15 
16 #include "BlenderStrokeRenderer.h"
17 
18 using namespace std;
19 using namespace Freestyle;
20 
21 #include "MEM_guardedalloc.h"
22 
23 #include "DNA_camera_types.h"
24 #include "DNA_collection_types.h"
25 #include "DNA_freestyle_types.h"
26 #include "DNA_material_types.h"
27 #include "DNA_text_types.h"
28 
29 #include "BKE_callbacks.h"
30 #include "BKE_context.h"
31 #include "BKE_freestyle.h"
32 #include "BKE_global.h"
33 #include "BKE_lib_id.h"
34 #include "BKE_linestyle.h"
35 #include "BKE_scene.h"
36 #include "BKE_text.h"
37 
38 #include "BLT_translation.h"
39 
40 #include "BLI_blenlib.h"
41 #include "BLI_math.h"
42 #include "BLI_math_color_blend.h"
43 
44 #include "BPY_extern.h"
45 
46 #include "DEG_depsgraph_query.h"
47 
48 #include "pipeline.h"
49 
50 #include "FRS_freestyle.h"
51 
52 extern "C" {
53 
55 
56 // Freestyle configuration
57 static bool freestyle_is_initialized = false;
58 static Config::Path *pathconfig = nullptr;
59 static Controller *controller = nullptr;
60 static AppView *view = nullptr;
61 
62 // line set buffer for copy & paste
64 static bool lineset_copied = false;
65 
66 static void load_post_callback(struct Main * /*main*/,
67  struct PointerRNA ** /*pointers*/,
68  const int /*num_pointers*/,
69  void * /*arg*/)
70 {
71  lineset_copied = false;
72 }
73 
75  nullptr, /* next */
76  nullptr, /* prev */
77  load_post_callback, /* func */
78  nullptr, /* arg */
79  0 /* alloc */
80 };
81 
82 //=======================================================
83 // Initialization
84 //=======================================================
85 
86 void FRS_init()
87 {
89  return;
90  }
91 
93  controller = new Controller();
94  view = new AppView;
96  controller->Clear();
97  g_freestyle.scene = nullptr;
98  lineset_copied = false;
99 
101 
103 }
104 
106 {
107  if (G.debug & G_DEBUG_FREESTYLE) {
108  cout << "FRS_set_context: context 0x" << C << " scene 0x" << CTX_data_scene(C) << endl;
109  }
111 }
112 
113 void FRS_exit()
114 {
115  delete pathconfig;
116  delete controller;
117  delete view;
118 }
119 
120 //=======================================================
121 // Rendering
122 //=======================================================
123 
124 static void init_view(Render *re)
125 {
126  int width = re->winx;
127  int height = re->winy;
128  int xmin = re->disprect.xmin;
129  int ymin = re->disprect.ymin;
130  int xmax = re->disprect.xmax;
131  int ymax = re->disprect.ymax;
132 
133  float thickness = 1.0f;
134  switch (re->r.line_thickness_mode) {
136  thickness = re->r.unit_line_thickness * (re->r.size / 100.0f);
137  break;
139  thickness = height / 480.0f;
140  break;
141  }
142 
146 
147  view->setWidth(width);
149  view->setBorder(xmin, ymin, xmax, ymax);
150  view->setThickness(thickness);
151 
152  if (G.debug & G_DEBUG_FREESTYLE) {
153  cout << "\n=== Dimensions of the 2D image coordinate system ===" << endl;
154  cout << "Width : " << width << endl;
155  cout << "Height : " << height << endl;
156  if (re->r.mode & R_BORDER) {
157  cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")"
158  << endl;
159  }
160  cout << "Unit line thickness : " << thickness << " pixel(s)" << endl;
161  }
162 }
163 
164 static char *escape_quotes(char *name)
165 {
166  char *s = (char *)MEM_mallocN(strlen(name) * 2 + 1, "escape_quotes");
167  char *p = s;
168  while (*name) {
169  if (*name == '\'') {
170  *(p++) = '\\';
171  }
172  *(p++) = *(name++);
173  }
174  *p = '\0';
175  return s;
176 }
177 
178 static char *create_lineset_handler(char *layer_name, char *lineset_name)
179 {
180  const char *fmt = "__import__('parameter_editor').process('%s', '%s')\n";
181  char *s1 = escape_quotes(layer_name);
182  char *s2 = escape_quotes(lineset_name);
183  char *text = BLI_sprintfN(fmt, s1, s2);
184  MEM_freeN(s1);
185  MEM_freeN(s2);
186  return text;
187 }
188 
190  int edge_type, value;
191 };
192 
193 // examines the conditions and returns true if the target edge type needs to be computed
194 static bool test_edge_type_conditions(struct edge_type_condition *conditions,
195  int num_edge_types,
196  bool logical_and,
197  int target,
198  bool distinct)
199 {
200  int target_condition = 0;
201  int num_non_target_positive_conditions = 0;
202  int num_non_target_negative_conditions = 0;
203 
204  for (int i = 0; i < num_edge_types; i++) {
205  if (conditions[i].edge_type == target) {
206  target_condition = conditions[i].value;
207  }
208  else if (conditions[i].value > 0) {
209  ++num_non_target_positive_conditions;
210  }
211  else if (conditions[i].value < 0) {
212  ++num_non_target_negative_conditions;
213  }
214  }
215  if (distinct) {
216  // In this case, the 'target' edge type is assumed to appear on distinct edge
217  // of its own and never together with other edge types.
218  if (logical_and) {
219  if (num_non_target_positive_conditions > 0) {
220  return false;
221  }
222  if (target_condition > 0) {
223  return true;
224  }
225  if (target_condition < 0) {
226  return false;
227  }
228  if (num_non_target_negative_conditions > 0) {
229  return true;
230  }
231  }
232  else {
233  if (target_condition > 0) {
234  return true;
235  }
236  if (num_non_target_negative_conditions > 0) {
237  return true;
238  }
239  if (target_condition < 0) {
240  return false;
241  }
242  if (num_non_target_positive_conditions > 0) {
243  return false;
244  }
245  }
246  }
247  else {
248  // In this case, the 'target' edge type may appear together with other edge types.
249  if (target_condition > 0) {
250  return true;
251  }
252  if (target_condition < 0) {
253  return true;
254  }
255  if (logical_and) {
256  if (num_non_target_positive_conditions > 0) {
257  return false;
258  }
259  if (num_non_target_negative_conditions > 0) {
260  return true;
261  }
262  }
263  else {
264  if (num_non_target_negative_conditions > 0) {
265  return true;
266  }
267  if (num_non_target_positive_conditions > 0) {
268  return false;
269  }
270  }
271  }
272  return true;
273 }
274 
275 static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
276 {
277  // load mesh
278  re->i.infostr = TIP_("Freestyle: Mesh loading");
279  re->stats_draw(re->sdh, &re->i);
280  re->i.infostr = nullptr;
281  if (controller->LoadMesh(
282  re, view_layer, depsgraph)) { // returns if scene cannot be loaded or if empty
283  return;
284  }
285  if (re->test_break(re->tbh)) {
286  return;
287  }
288 
289  // add style modules
290  FreestyleConfig *config = &view_layer->freestyle_config;
291 
292  if (G.debug & G_DEBUG_FREESTYLE) {
293  cout << "\n=== Rendering options ===" << endl;
294  }
295  int layer_count = 0;
296 
297  switch (config->mode) {
299  if (G.debug & G_DEBUG_FREESTYLE) {
300  cout << "Modules :" << endl;
301  }
302  for (FreestyleModuleConfig *module_conf = (FreestyleModuleConfig *)config->modules.first;
303  module_conf;
304  module_conf = module_conf->next) {
305  if (module_conf->script && module_conf->is_displayed) {
306  const char *id_name = module_conf->script->id.name + 2;
307  if (G.debug & G_DEBUG_FREESTYLE) {
308  cout << " " << layer_count + 1 << ": " << id_name;
309  if (module_conf->script->filepath) {
310  cout << " (" << module_conf->script->filepath << ")";
311  }
312  cout << endl;
313  }
314  controller->InsertStyleModule(layer_count, id_name, module_conf->script);
315  controller->toggleLayer(layer_count, true);
316  layer_count++;
317  }
318  }
319  if (G.debug & G_DEBUG_FREESTYLE) {
320  cout << endl;
321  }
323  (config->flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false);
325  (config->flags & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false);
327  (config->flags & FREESTYLE_MATERIAL_BOUNDARIES_FLAG) ? true : false);
328  break;
330  int use_ridges_and_valleys = 0;
331  int use_suggestive_contours = 0;
332  int use_material_boundaries = 0;
333  struct edge_type_condition conditions[] = {
335  {FREESTYLE_FE_BORDER, 0},
336  {FREESTYLE_FE_CREASE, 0},
343  };
344  int num_edge_types = ARRAY_SIZE(conditions);
345  if (G.debug & G_DEBUG_FREESTYLE) {
346  cout << "Linesets:" << endl;
347  }
348  for (FreestyleLineSet *lineset = (FreestyleLineSet *)config->linesets.first; lineset;
349  lineset = lineset->next) {
350  if (lineset->flags & FREESTYLE_LINESET_ENABLED) {
351  if (G.debug & G_DEBUG_FREESTYLE) {
352  cout << " " << layer_count + 1 << ": " << lineset->name << " - "
353  << (lineset->linestyle ? (lineset->linestyle->id.name + 2) : "<NULL>") << endl;
354  }
355  char *buffer = create_lineset_handler(view_layer->name, lineset->name);
356  controller->InsertStyleModule(layer_count, lineset->name, buffer);
357  controller->toggleLayer(layer_count, true);
358  MEM_freeN(buffer);
359  if (!(lineset->selection & FREESTYLE_SEL_EDGE_TYPES) || !lineset->edge_types) {
360  ++use_ridges_and_valleys;
361  ++use_suggestive_contours;
362  ++use_material_boundaries;
363  }
364  else {
365  // conditions for feature edge selection by edge types
366  for (int i = 0; i < num_edge_types; i++) {
367  if (!(lineset->edge_types & conditions[i].edge_type)) {
368  conditions[i].value = 0; // no condition specified
369  }
370  else if (!(lineset->exclude_edge_types & conditions[i].edge_type)) {
371  conditions[i].value = 1; // condition: X
372  }
373  else {
374  conditions[i].value = -1; // condition: NOT X
375  }
376  }
377  // logical operator for the selection conditions
378  bool logical_and = ((lineset->flags & FREESTYLE_LINESET_FE_AND) != 0);
379  // negation operator
380  if (lineset->flags & FREESTYLE_LINESET_FE_NOT) {
381  // convert an Exclusive condition into an
382  // Inclusive equivalent using De Morgan's laws:
383  // - NOT (X OR Y) --> (NOT X) AND (NOT Y)
384  // - NOT (X AND Y) --> (NOT X) OR (NOT Y)
385  for (int i = 0; i < num_edge_types; i++) {
386  conditions[i].value *= -1;
387  }
388  logical_and = !logical_and;
389  }
391  conditions, num_edge_types, logical_and, FREESTYLE_FE_RIDGE_VALLEY, true)) {
392  ++use_ridges_and_valleys;
393  }
394  if (test_edge_type_conditions(conditions,
395  num_edge_types,
396  logical_and,
398  true)) {
399  ++use_suggestive_contours;
400  }
401  if (test_edge_type_conditions(conditions,
402  num_edge_types,
403  logical_and,
405  true)) {
406  ++use_material_boundaries;
407  }
408  }
409  layer_count++;
410  }
411  }
412  controller->setComputeRidgesAndValleysFlag(use_ridges_and_valleys > 0);
413  controller->setComputeSuggestiveContoursFlag(use_suggestive_contours > 0);
414  controller->setComputeMaterialBoundariesFlag(use_material_boundaries > 0);
415  break;
416  }
417 
418  // set parameters
426 
427  if (G.debug & G_DEBUG_FREESTYLE) {
428  cout << "Crease angle : " << controller->getCreaseAngle() << endl;
429  cout << "Sphere radius : " << controller->getSphereRadius() << endl;
430  cout << "Face smoothness : " << (controller->getFaceSmoothness() ? "enabled" : "disabled")
431  << endl;
432  cout << "Ridges and valleys : "
433  << (controller->getComputeRidgesAndValleysFlag() ? "enabled" : "disabled") << endl;
434  cout << "Suggestive contours : "
435  << (controller->getComputeSuggestiveContoursFlag() ? "enabled" : "disabled") << endl;
436  cout << "Suggestive contour Kr derivative epsilon : "
438  cout << "Material boundaries : "
439  << (controller->getComputeMaterialBoundariesFlag() ? "enabled" : "disabled") << endl;
440  cout << endl;
441  }
442 
443  // set diffuse and z depth passes
444  RenderLayer *rl = RE_GetRenderLayer(re->result, view_layer->name);
445  bool diffuse = false, z = false;
446  for (RenderPass *rpass = (RenderPass *)rl->passes.first; rpass; rpass = rpass->next) {
447  if (STREQ(rpass->name, RE_PASSNAME_DIFFUSE_COLOR)) {
448  controller->setPassDiffuse(rpass->rect, rpass->rectx, rpass->recty);
449  diffuse = true;
450  }
451  if (STREQ(rpass->name, RE_PASSNAME_Z)) {
452  controller->setPassZ(rpass->rect, rpass->rectx, rpass->recty);
453  z = true;
454  }
455  }
456  if (G.debug & G_DEBUG_FREESTYLE) {
457  cout << "Passes :" << endl;
458  cout << " Diffuse = " << (diffuse ? "enabled" : "disabled") << endl;
459  cout << " Z = " << (z ? "enabled" : "disabled") << endl;
460  }
461 
462  if (controller->hitViewMapCache()) {
463  return;
464  }
465 
466  // compute view map
467  re->i.infostr = TIP_("Freestyle: View map creation");
468  re->stats_draw(re->sdh, &re->i);
469  re->i.infostr = nullptr;
471 }
472 
473 void FRS_composite_result(Render *re, ViewLayer *view_layer, Render *freestyle_render)
474 {
475  RenderLayer *rl;
476  float *src, *dest, *pixSrc, *pixDest;
477  int x, y, rectx, recty;
478 
479  if (freestyle_render == nullptr || freestyle_render->result == nullptr) {
480  if (view_layer->freestyle_config.flags & FREESTYLE_AS_RENDER_PASS) {
481  // Create a blank render pass output.
483  re->result, RE_PASSNAME_FREESTYLE, 4, "RGBA", view_layer->name, re->viewname, true);
484  }
485  return;
486  }
487 
488  rl = render_get_active_layer(freestyle_render, freestyle_render->result);
489  if (!rl) {
490  if (G.debug & G_DEBUG_FREESTYLE) {
491  cout << "No source render layer to composite" << endl;
492  }
493  return;
494  }
495 
496  src = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, freestyle_render->viewname);
497  if (!src) {
498  if (G.debug & G_DEBUG_FREESTYLE) {
499  cout << "No source result image to composite" << endl;
500  }
501  return;
502  }
503 #if 0
504  if (G.debug & G_DEBUG_FREESTYLE) {
505  cout << "src: " << rl->rectx << " x " << rl->recty << endl;
506  }
507 #endif
508 
509  rl = RE_GetRenderLayer(re->result, view_layer->name);
510  if (!rl) {
511  if (G.debug & G_DEBUG_FREESTYLE) {
512  cout << "No destination render layer to composite to" << endl;
513  }
514  return;
515  }
516 
517  if (view_layer->freestyle_config.flags & FREESTYLE_AS_RENDER_PASS) {
519  re->result, RE_PASSNAME_FREESTYLE, 4, "RGBA", view_layer->name, re->viewname, true);
521  }
522  else {
524  }
525  if (!dest) {
526  if (G.debug & G_DEBUG_FREESTYLE) {
527  cout << "No destination result image to composite to" << endl;
528  }
529  return;
530  }
531 #if 0
532  if (G.debug & G_DEBUG_FREESTYLE) {
533  cout << "dest: " << rl->rectx << " x " << rl->recty << endl;
534  }
535 #endif
536 
537  rectx = re->rectx;
538  recty = re->recty;
539  for (y = 0; y < recty; y++) {
540  for (x = 0; x < rectx; x++) {
541  pixSrc = src + 4 * (rectx * y + x);
542  if (pixSrc[3] > 0.0) {
543  pixDest = dest + 4 * (rectx * y + x);
544  blend_color_mix_float(pixDest, pixDest, pixSrc);
545  }
546  }
547  }
548 }
549 
550 static int displayed_layer_count(ViewLayer *view_layer)
551 {
552  int count = 0;
553 
554  switch (view_layer->freestyle_config.mode) {
558  module;
559  module = module->next) {
560  if (module->script && module->is_displayed) {
561  count++;
562  }
563  }
564  break;
566  for (FreestyleLineSet *lineset =
568  lineset;
569  lineset = lineset->next) {
570  if (lineset->flags & FREESTYLE_LINESET_ENABLED) {
571  count++;
572  }
573  }
574  break;
575  }
576  return count;
577 }
578 
580 {
581  return ((view_layer->flag & VIEW_LAYER_RENDER) && (view_layer->flag & VIEW_LAYER_FREESTYLE) &&
582  displayed_layer_count(view_layer) > 0);
583 }
584 
586 {
587  if (G.debug & G_DEBUG_FREESTYLE) {
588  cout << endl;
589  cout << "#===============================================================" << endl;
590  cout << "# Freestyle" << endl;
591  cout << "#===============================================================" << endl;
592  }
593 
594  init_view(re);
595 
597 }
598 
600 {
601 }
602 
604 {
605  RenderMonitor monitor(re);
606  controller->setRenderMonitor(&monitor);
608  (view_layer->freestyle_config.flags & FREESTYLE_VIEW_MAP_CACHE) ? true : false);
609 
610  if (G.debug & G_DEBUG_FREESTYLE) {
611  cout << endl;
612  cout << "----------------------------------------------------------" << endl;
613  cout << "| " << (re->scene->id.name + 2) << "|" << view_layer->name << endl;
614  cout << "----------------------------------------------------------" << endl;
615  }
616 
617  /* Create depsgraph and evaluate scene. */
618  ViewLayer *scene_view_layer = (ViewLayer *)BLI_findstring(
619  &re->scene->view_layers, view_layer->name, offsetof(ViewLayer, name));
620  Depsgraph *depsgraph = DEG_graph_new(re->main, re->scene, scene_view_layer, DAG_EVAL_RENDER);
622 
623  /* Init camera
624  * Objects are transformed into camera coordinate system, therefore the camera position
625  * is zero and the modelview matrix is the identity matrix. */
626  Object *ob_camera_orig = RE_GetCamera(re);
627  Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, ob_camera_orig);
630  RE_GetCameraWindow(re, ob_camera_eval, g_freestyle.proj);
631 
632  // prepare Freestyle:
633  // - load mesh
634  // - add style modules
635  // - set parameters
636  // - compute view map
637  prepare(re, view_layer, depsgraph);
638 
639  if (re->test_break(re->tbh)) {
641  if (G.debug & G_DEBUG_FREESTYLE) {
642  cout << "Break" << endl;
643  }
644  }
645  else {
646  // render and composite Freestyle result
647  if (controller->_ViewMap) {
648  // render strokes
649  re->i.infostr = TIP_("Freestyle: Stroke rendering");
650  re->stats_draw(re->sdh, &re->i);
651  re->i.infostr = nullptr;
653  int strokeCount = controller->DrawStrokes();
654  Render *freestyle_render = nullptr;
655  if (strokeCount > 0) {
656  freestyle_render = controller->RenderStrokes(re, true);
657  }
659  g_freestyle.scene = nullptr;
660 
661  // composite result
662  FRS_composite_result(re, view_layer, freestyle_render);
663  if (freestyle_render) {
664  RE_FreeRender(freestyle_render);
665  }
666  }
667  }
668 
670 }
671 
673 {
674  // clear canvas
675  controller->Clear();
676 }
677 
679 {
680  // free cache
681  controller->DeleteViewMap(true);
682 #if 0
683  if (G.debug & G_DEBUG_FREESTYLE) {
684  printf("View map cache freed\n");
685  }
686 #endif
687 }
688 
689 //=======================================================
690 // Freestyle Panel Configuration
691 //=======================================================
692 
694 {
696 
697  if (lineset) {
699  lineset_buffer.flags = lineset->flags;
701  lineset_buffer.qi = lineset->qi;
702  lineset_buffer.qi_start = lineset->qi_start;
703  lineset_buffer.qi_end = lineset->qi_end;
706  lineset_buffer.group = lineset->group;
707  strcpy(lineset_buffer.name, lineset->name);
708  lineset_copied = true;
709  }
710 }
711 
713 {
714  if (!lineset_copied) {
715  return;
716  }
717 
719 
720  if (lineset) {
721  if (lineset->linestyle) {
722  id_us_min(&lineset->linestyle->id);
723  }
725  if (lineset->linestyle) {
726  id_us_plus(&lineset->linestyle->id);
727  }
728  lineset->flags = lineset_buffer.flags;
730  lineset->qi = lineset_buffer.qi;
731  lineset->qi_start = lineset_buffer.qi_start;
732  lineset->qi_end = lineset_buffer.qi_end;
735  if (lineset->group) {
736  id_us_min(&lineset->group->id);
737  lineset->group = nullptr;
738  }
739  if (lineset_buffer.group) {
740  lineset->group = lineset_buffer.group;
741  id_us_plus(&lineset->group->id);
742  }
743  strcpy(lineset->name, lineset_buffer.name);
744  BKE_freestyle_lineset_unique_name(config, lineset);
745  lineset->flags |= FREESTYLE_LINESET_CURRENT;
746  }
747 }
748 
750 {
752 
753  if (lineset) {
754  BKE_freestyle_lineset_delete(config, lineset);
755  }
756 }
757 
758 bool FRS_move_active_lineset(FreestyleConfig *config, int direction)
759 {
761  return (lineset != nullptr) && BLI_listbase_link_move(&config->linesets, lineset, direction);
762 }
763 
764 // Testing
765 
767 {
768  bNodeTree *nt = (linestyle->use_nodes) ? linestyle->nodetree : nullptr;
769  Material *ma = BlenderStrokeRenderer::GetStrokeShader(bmain, nt, true);
770  ma->id.us = 0;
771  return ma;
772 }
773 
774 } // extern "C"
void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt)
Definition: callbacks.c:72
@ BKE_CB_EVT_LOAD_POST
Definition: BKE_callbacks.h:85
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
bool BKE_freestyle_lineset_delete(struct FreestyleConfig *config, struct FreestyleLineSet *lineset)
Definition: freestyle.c:196
void BKE_freestyle_lineset_unique_name(struct FreestyleConfig *config, struct FreestyleLineSet *lineset)
Definition: freestyle.c:147
struct FreestyleLineSet * BKE_freestyle_lineset_get_active(struct FreestyleConfig *config)
Definition: freestyle.c:213
@ G_DEBUG_FREESTYLE
Definition: BKE_global.h:181
void id_us_min(struct ID *id)
Definition: lib_id.c:313
void id_us_plus(struct ID *id)
Definition: lib_id.c:305
Blender kernel freestyle line style functionality.
void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph)
Definition: scene.cc:2728
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
Definition: listbase.c:405
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
void unit_m4(float m[4][4])
Definition: rct.c:1090
#define RAD2DEGF(_rad)
MINLINE void zero_v3(float r[3])
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
#define ARRAY_SIZE(arr)
#define UNUSED(x)
#define STREQ(a, b)
#define TIP_(msgid)
Depsgraph * DEG_graph_new(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, eEvaluationMode mode)
Definition: depsgraph.cc:267
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
@ DAG_EVAL_RENDER
Definition: DEG_depsgraph.h:46
void DEG_graph_free(Depsgraph *graph)
Definition: depsgraph.cc:295
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
Object groups, one object can be in many groups at once.
@ FREESTYLE_CULLING
@ FREESTYLE_FACE_SMOOTHNESS_FLAG
@ FREESTYLE_MATERIAL_BOUNDARIES_FLAG
@ FREESTYLE_RIDGES_AND_VALLEYS_FLAG
@ FREESTYLE_VIEW_MAP_CACHE
@ FREESTYLE_SUGGESTIVE_CONTOURS_FLAG
@ FREESTYLE_AS_RENDER_PASS
@ FREESTYLE_FE_EDGE_MARK
@ FREESTYLE_FE_BORDER
@ FREESTYLE_FE_SILHOUETTE
@ FREESTYLE_FE_RIDGE_VALLEY
@ FREESTYLE_FE_CREASE
@ FREESTYLE_FE_EXTERNAL_CONTOUR
@ FREESTYLE_FE_CONTOUR
@ FREESTYLE_FE_SUGGESTIVE_CONTOUR
@ FREESTYLE_FE_MATERIAL_BOUNDARY
@ FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE
@ FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE
@ FREESTYLE_SEL_EDGE_TYPES
@ FREESTYLE_LINESET_FE_AND
@ FREESTYLE_LINESET_ENABLED
@ FREESTYLE_LINESET_CURRENT
@ FREESTYLE_LINESET_FE_NOT
@ FREESTYLE_CONTROL_EDITOR_MODE
@ FREESTYLE_CONTROL_SCRIPT_MODE
@ VIEW_LAYER_FREESTYLE
@ VIEW_LAYER_RENDER
#define RE_PASSNAME_COMBINED
#define R_BORDER
#define R_LINE_THICKNESS_ABSOLUTE
#define RE_PASSNAME_DIFFUSE_COLOR
#define RE_PASSNAME_Z
#define RE_PASSNAME_FREESTYLE
#define R_LINE_THICKNESS_RELATIVE
void FRS_paste_active_lineset(FreestyleConfig *config)
void FRS_end_stroke_rendering(Render *)
static bool test_edge_type_conditions(struct edge_type_condition *conditions, int num_edge_types, bool logical_and, int target, bool distinct)
struct FreestyleGlobals g_freestyle
static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
void FRS_composite_result(Render *re, ViewLayer *view_layer, Render *freestyle_render)
int FRS_is_freestyle_enabled(ViewLayer *view_layer)
void FRS_init()
static void init_view(Render *re)
static char * escape_quotes(char *name)
static bool lineset_copied
static int displayed_layer_count(ViewLayer *view_layer)
bool FRS_move_active_lineset(FreestyleConfig *config, int direction)
void FRS_delete_active_lineset(FreestyleConfig *config)
static bCallbackFuncStore load_post_callback_funcstore
static void load_post_callback(struct Main *, struct PointerRNA **, const int, void *)
static AppView * view
void FRS_begin_stroke_rendering(Render *UNUSED(re))
void FRS_exit()
void FRS_init_stroke_renderer(Render *re)
void FRS_free_view_map_cache(void)
static char * create_lineset_handler(char *layer_name, char *lineset_name)
void FRS_set_context(bContext *C)
static Controller * controller
Material * FRS_create_stroke_material(Main *bmain, struct FreestyleLineStyle *linestyle)
static bool freestyle_is_initialized
static Config::Path * pathconfig
void FRS_do_stroke_rendering(Render *re, ViewLayer *view_layer)
void FRS_copy_active_lineset(FreestyleConfig *config)
static FreestyleLineSet lineset_buffer
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:25
void setHeight(unsigned int height)
Definition: AppView.h:53
void setWidth(unsigned int width)
Definition: AppView.h:49
void setBorder(int xmin, int ymin, int xmax, int ymax)
Definition: AppView.h:57
void setThickness(float thickness)
Definition: AppView.h:61
Render * RenderStrokes(Render *re, bool render)
Definition: Controller.cpp:890
void setComputeSuggestiveContoursFlag(bool b)
Definition: Controller.cpp:833
void setPassZ(float *buf, int width, int height)
Definition: Controller.cpp:195
bool getFaceSmoothness() const
Definition: Controller.cpp:818
bool getComputeMaterialBoundariesFlag() const
Definition: Controller.cpp:848
void toggleLayer(unsigned index, bool iDisplay)
Definition: Controller.cpp:971
void setSphereRadius(float s)
Definition: Controller.h:132
void setComputeMaterialBoundariesFlag(bool b)
Definition: Controller.cpp:843
void setVisibilityAlgo(int algo)
Definition: Controller.cpp:742
void setComputeRidgesAndValleysFlag(bool b)
Definition: Controller.cpp:823
void setFaceSmoothness(bool iBool)
Definition: Controller.cpp:813
void setPassDiffuse(float *buf, int width, int height)
Definition: Controller.cpp:188
float getSphereRadius() const
Definition: Controller.h:136
void DeleteViewMap(bool freeCache=false)
Definition: Controller.cpp:406
int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
Definition: Controller.cpp:220
bool getComputeSuggestiveContoursFlag() const
Definition: Controller.cpp:838
void setViewMapCache(bool iBool)
Definition: Controller.cpp:793
void setContext(bContext *C)
Definition: Controller.cpp:202
void setSuggestiveContourKrDerivativeEpsilon(float dkr)
Definition: Controller.h:140
void setCreaseAngle(float angle)
Definition: Controller.h:124
float getCreaseAngle() const
Definition: Controller.h:128
void InsertStyleModule(unsigned index, const char *iFileName)
Definition: Controller.cpp:922
bool getComputeRidgesAndValleysFlag() const
Definition: Controller.cpp:828
float getSuggestiveContourKrDerivativeEpsilon() const
Definition: Controller.h:144
void setView(AppView *iView)
Definition: Controller.cpp:173
void setRenderMonitor(RenderMonitor *iRenderMonitor)
Definition: Controller.cpp:183
std::string id_name(void *id)
FreestyleLineStyle linestyle
const Depsgraph * depsgraph
SyclQueue void void * src
SyclQueue void * dest
struct Object * RE_GetCamera(Render *re)
Definition: initrender.c:150
void RE_GetCameraWindow(struct Render *re, const struct Object *camera, float r_winmat[4][4])
Definition: initrender.c:181
int count
ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
#define G(x, y, z)
inherits from class Rep
Definition: AppCanvas.cpp:18
void RE_FreeRender(Render *re)
Definition: pipeline.c:584
RenderLayer * render_get_active_layer(Render *re, RenderResult *rr)
Definition: pipeline.c:264
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
Definition: pipeline.c:244
float * RE_RenderLayerGetPass(RenderLayer *rl, const char *name, const char *viewname)
Definition: pipeline.c:238
static struct PyModuleDef module
Definition: python.cpp:972
void RE_create_render_pass(RenderResult *rr, const char *name, int channels, const char *chan_id, const char *layername, const char *viewname, const bool allocate)
float viewpoint[3]
Definition: FRS_freestyle.h:22
float proj[4][4]
Definition: FRS_freestyle.h:24
float mv[4][4]
Definition: FRS_freestyle.h:23
struct Scene * scene
Definition: FRS_freestyle.h:19
struct Collection * group
struct FreestyleLineStyle * linestyle
struct bNodeTree * nodetree
int us
Definition: DNA_ID.h:388
char name[66]
Definition: DNA_ID.h:378
void * first
Definition: DNA_listBase.h:31
Definition: BKE_main.h:121
int line_thickness_mode
float unit_line_thickness
ListBase passes
Definition: RE_pipeline.h:95
const char * infostr
Definition: RE_pipeline.h:150
int recty
Definition: render_types.h:70
void * sdh
Definition: render_types.h:109
RenderResult * result
Definition: render_types.h:49
RenderData r
Definition: render_types.h:82
int winy
Definition: render_types.h:65
struct Main * main
Definition: render_types.h:80
Scene * scene
Definition: render_types.h:81
int rectx
Definition: render_types.h:70
char viewname[MAX_NAME]
Definition: render_types.h:123
RenderStats i
Definition: render_types.h:118
void * tbh
Definition: render_types.h:116
int winx
Definition: render_types.h:65
void(* stats_draw)(void *handle, RenderStats *ri)
Definition: render_types.h:108
int(* test_break)(void *handle)
Definition: render_types.h:115
rcti disprect
Definition: render_types.h:66
ListBase view_layers
struct FreestyleConfig freestyle_config
char name[64]
int ymin
Definition: DNA_vec_types.h:64
int ymax
Definition: DNA_vec_types.h:64
int xmin
Definition: DNA_vec_types.h:63
int xmax
Definition: DNA_vec_types.h:63