Blender  V2.93
FRS_freestyle.cpp
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 #include <iostream>
22 #include <map>
23 #include <set>
24 
25 #include "../application/AppCanvas.h"
26 #include "../application/AppConfig.h"
27 #include "../application/AppView.h"
28 #include "../application/Controller.h"
29 
30 #include "BlenderStrokeRenderer.h"
31 
32 using namespace std;
33 using namespace Freestyle;
34 
35 #include "MEM_guardedalloc.h"
36 
37 #include "DNA_camera_types.h"
38 #include "DNA_collection_types.h"
39 #include "DNA_freestyle_types.h"
40 #include "DNA_material_types.h"
41 #include "DNA_text_types.h"
42 
43 #include "BKE_callbacks.h"
44 #include "BKE_context.h"
45 #include "BKE_freestyle.h"
46 #include "BKE_global.h"
47 #include "BKE_lib_id.h"
48 #include "BKE_linestyle.h"
49 #include "BKE_scene.h"
50 #include "BKE_text.h"
51 
52 #include "BLT_translation.h"
53 
54 #include "BLI_blenlib.h"
55 #include "BLI_math.h"
56 #include "BLI_math_color_blend.h"
57 
58 #include "BPY_extern.h"
59 
60 #include "DEG_depsgraph_query.h"
61 
62 #include "pipeline.h"
63 
64 #include "FRS_freestyle.h"
65 
66 extern "C" {
67 
68 #define DEFAULT_SPHERE_RADIUS 1.0f
69 #define DEFAULT_DKR_EPSILON 0.0f
70 
72 
73 // Freestyle configuration
74 static bool freestyle_is_initialized = false;
75 static Config::Path *pathconfig = nullptr;
76 static Controller *controller = nullptr;
77 static AppView *view = nullptr;
78 
79 // line set buffer for copy & paste
81 static bool lineset_copied = false;
82 
83 static void load_post_callback(struct Main * /*main*/,
84  struct PointerRNA ** /*pointers*/,
85  const int /*num_pointers*/,
86  void * /*arg*/)
87 {
88  lineset_copied = false;
89 }
90 
92  nullptr,
93  nullptr, /* next, prev */
94  load_post_callback, /* func */
95  nullptr, /* arg */
96  0 /* alloc */
97 };
98 
99 //=======================================================
100 // Initialization
101 //=======================================================
102 
103 void FRS_init()
104 {
106  return;
107  }
108 
109  pathconfig = new Config::Path;
110  controller = new Controller();
111  view = new AppView;
113  controller->Clear();
114  g_freestyle.scene = nullptr;
115  lineset_copied = false;
116 
118 
120 }
121 
123 {
124  if (G.debug & G_DEBUG_FREESTYLE) {
125  cout << "FRS_set_context: context 0x" << C << " scene 0x" << CTX_data_scene(C) << endl;
126  }
128 }
129 
130 void FRS_exit()
131 {
132  delete pathconfig;
133  delete controller;
134  delete view;
135 }
136 
137 //=======================================================
138 // Rendering
139 //=======================================================
140 
141 static void init_view(Render *re)
142 {
143  int width = re->winx;
144  int height = re->winy;
145  int xmin = re->disprect.xmin;
146  int ymin = re->disprect.ymin;
147  int xmax = re->disprect.xmax;
148  int ymax = re->disprect.ymax;
149 
150  float thickness = 1.0f;
151  switch (re->r.line_thickness_mode) {
153  thickness = re->r.unit_line_thickness * (re->r.size / 100.0f);
154  break;
156  thickness = height / 480.0f;
157  break;
158  }
159 
163 
164  view->setWidth(width);
166  view->setBorder(xmin, ymin, xmax, ymax);
167  view->setThickness(thickness);
168 
169  if (G.debug & G_DEBUG_FREESTYLE) {
170  cout << "\n=== Dimensions of the 2D image coordinate system ===" << endl;
171  cout << "Width : " << width << endl;
172  cout << "Height : " << height << endl;
173  if (re->r.mode & R_BORDER) {
174  cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")"
175  << endl;
176  }
177  cout << "Unit line thickness : " << thickness << " pixel(s)" << endl;
178  }
179 }
180 
181 static char *escape_quotes(char *name)
182 {
183  char *s = (char *)MEM_mallocN(strlen(name) * 2 + 1, "escape_quotes");
184  char *p = s;
185  while (*name) {
186  if (*name == '\'') {
187  *(p++) = '\\';
188  }
189  *(p++) = *(name++);
190  }
191  *p = '\0';
192  return s;
193 }
194 
195 static char *create_lineset_handler(char *layer_name, char *lineset_name)
196 {
197  const char *fmt = "__import__('parameter_editor').process('%s', '%s')\n";
198  char *s1 = escape_quotes(layer_name);
199  char *s2 = escape_quotes(lineset_name);
200  char *text = BLI_sprintfN(fmt, s1, s2);
201  MEM_freeN(s1);
202  MEM_freeN(s2);
203  return text;
204 }
205 
207  int edge_type, value;
208 };
209 
210 // examines the conditions and returns true if the target edge type needs to be computed
211 static bool test_edge_type_conditions(struct edge_type_condition *conditions,
212  int num_edge_types,
213  bool logical_and,
214  int target,
215  bool distinct)
216 {
217  int target_condition = 0;
218  int num_non_target_positive_conditions = 0;
219  int num_non_target_negative_conditions = 0;
220 
221  for (int i = 0; i < num_edge_types; i++) {
222  if (conditions[i].edge_type == target) {
223  target_condition = conditions[i].value;
224  }
225  else if (conditions[i].value > 0) {
226  ++num_non_target_positive_conditions;
227  }
228  else if (conditions[i].value < 0) {
229  ++num_non_target_negative_conditions;
230  }
231  }
232  if (distinct) {
233  // In this case, the 'target' edge type is assumed to appear on distinct edge
234  // of its own and never together with other edge types.
235  if (logical_and) {
236  if (num_non_target_positive_conditions > 0) {
237  return false;
238  }
239  if (target_condition > 0) {
240  return true;
241  }
242  if (target_condition < 0) {
243  return false;
244  }
245  if (num_non_target_negative_conditions > 0) {
246  return true;
247  }
248  }
249  else {
250  if (target_condition > 0) {
251  return true;
252  }
253  if (num_non_target_negative_conditions > 0) {
254  return true;
255  }
256  if (target_condition < 0) {
257  return false;
258  }
259  if (num_non_target_positive_conditions > 0) {
260  return false;
261  }
262  }
263  }
264  else {
265  // In this case, the 'target' edge type may appear together with other edge types.
266  if (target_condition > 0) {
267  return true;
268  }
269  if (target_condition < 0) {
270  return true;
271  }
272  if (logical_and) {
273  if (num_non_target_positive_conditions > 0) {
274  return false;
275  }
276  if (num_non_target_negative_conditions > 0) {
277  return true;
278  }
279  }
280  else {
281  if (num_non_target_negative_conditions > 0) {
282  return true;
283  }
284  if (num_non_target_positive_conditions > 0) {
285  return false;
286  }
287  }
288  }
289  return true;
290 }
291 
292 static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
293 {
294  // load mesh
295  re->i.infostr = TIP_("Freestyle: Mesh loading");
296  re->stats_draw(re->sdh, &re->i);
297  re->i.infostr = nullptr;
298  if (controller->LoadMesh(
299  re, view_layer, depsgraph)) { // returns if scene cannot be loaded or if empty
300  return;
301  }
302  if (re->test_break(re->tbh)) {
303  return;
304  }
305 
306  // add style modules
307  FreestyleConfig *config = &view_layer->freestyle_config;
308 
309  if (G.debug & G_DEBUG_FREESTYLE) {
310  cout << "\n=== Rendering options ===" << endl;
311  }
312  int layer_count = 0;
313 
314  switch (config->mode) {
316  if (G.debug & G_DEBUG_FREESTYLE) {
317  cout << "Modules :" << endl;
318  }
319  for (FreestyleModuleConfig *module_conf = (FreestyleModuleConfig *)config->modules.first;
320  module_conf;
321  module_conf = module_conf->next) {
322  if (module_conf->script && module_conf->is_displayed) {
323  const char *id_name = module_conf->script->id.name + 2;
324  if (G.debug & G_DEBUG_FREESTYLE) {
325  cout << " " << layer_count + 1 << ": " << id_name;
326  if (module_conf->script->filepath) {
327  cout << " (" << module_conf->script->filepath << ")";
328  }
329  cout << endl;
330  }
331  controller->InsertStyleModule(layer_count, id_name, module_conf->script);
332  controller->toggleLayer(layer_count, true);
333  layer_count++;
334  }
335  }
336  if (G.debug & G_DEBUG_FREESTYLE) {
337  cout << endl;
338  }
340  (config->flags & FREESTYLE_RIDGES_AND_VALLEYS_FLAG) ? true : false);
342  (config->flags & FREESTYLE_SUGGESTIVE_CONTOURS_FLAG) ? true : false);
344  (config->flags & FREESTYLE_MATERIAL_BOUNDARIES_FLAG) ? true : false);
345  break;
347  int use_ridges_and_valleys = 0;
348  int use_suggestive_contours = 0;
349  int use_material_boundaries = 0;
350  struct edge_type_condition conditions[] = {
352  {FREESTYLE_FE_BORDER, 0},
353  {FREESTYLE_FE_CREASE, 0},
360  };
361  int num_edge_types = ARRAY_SIZE(conditions);
362  if (G.debug & G_DEBUG_FREESTYLE) {
363  cout << "Linesets:" << endl;
364  }
365  for (FreestyleLineSet *lineset = (FreestyleLineSet *)config->linesets.first; lineset;
366  lineset = lineset->next) {
367  if (lineset->flags & FREESTYLE_LINESET_ENABLED) {
368  if (G.debug & G_DEBUG_FREESTYLE) {
369  cout << " " << layer_count + 1 << ": " << lineset->name << " - "
370  << (lineset->linestyle ? (lineset->linestyle->id.name + 2) : "<NULL>") << endl;
371  }
372  char *buffer = create_lineset_handler(view_layer->name, lineset->name);
373  controller->InsertStyleModule(layer_count, lineset->name, buffer);
374  controller->toggleLayer(layer_count, true);
375  MEM_freeN(buffer);
376  if (!(lineset->selection & FREESTYLE_SEL_EDGE_TYPES) || !lineset->edge_types) {
377  ++use_ridges_and_valleys;
378  ++use_suggestive_contours;
379  ++use_material_boundaries;
380  }
381  else {
382  // conditions for feature edge selection by edge types
383  for (int i = 0; i < num_edge_types; i++) {
384  if (!(lineset->edge_types & conditions[i].edge_type)) {
385  conditions[i].value = 0; // no condition specified
386  }
387  else if (!(lineset->exclude_edge_types & conditions[i].edge_type)) {
388  conditions[i].value = 1; // condition: X
389  }
390  else {
391  conditions[i].value = -1; // condition: NOT X
392  }
393  }
394  // logical operator for the selection conditions
395  bool logical_and = ((lineset->flags & FREESTYLE_LINESET_FE_AND) != 0);
396  // negation operator
397  if (lineset->flags & FREESTYLE_LINESET_FE_NOT) {
398  // convert an Exclusive condition into an
399  // Inclusive equivalent using De Morgan's laws:
400  // - NOT (X OR Y) --> (NOT X) AND (NOT Y)
401  // - NOT (X AND Y) --> (NOT X) OR (NOT Y)
402  for (int i = 0; i < num_edge_types; i++) {
403  conditions[i].value *= -1;
404  }
405  logical_and = !logical_and;
406  }
408  conditions, num_edge_types, logical_and, FREESTYLE_FE_RIDGE_VALLEY, true)) {
409  ++use_ridges_and_valleys;
410  }
411  if (test_edge_type_conditions(conditions,
412  num_edge_types,
413  logical_and,
415  true)) {
416  ++use_suggestive_contours;
417  }
418  if (test_edge_type_conditions(conditions,
419  num_edge_types,
420  logical_and,
422  true)) {
423  ++use_material_boundaries;
424  }
425  }
426  layer_count++;
427  }
428  }
429  controller->setComputeRidgesAndValleysFlag(use_ridges_and_valleys > 0);
430  controller->setComputeSuggestiveContoursFlag(use_suggestive_contours > 0);
431  controller->setComputeMaterialBoundariesFlag(use_material_boundaries > 0);
432  break;
433  }
434 
435  // set parameters
436  if (config->flags & FREESTYLE_ADVANCED_OPTIONS_FLAG) {
439  }
440  else {
443  }
449 
450  if (G.debug & G_DEBUG_FREESTYLE) {
451  cout << "Crease angle : " << controller->getCreaseAngle() << endl;
452  cout << "Sphere radius : " << controller->getSphereRadius() << endl;
453  cout << "Face smoothness : " << (controller->getFaceSmoothness() ? "enabled" : "disabled")
454  << endl;
455  cout << "Ridges and valleys : "
456  << (controller->getComputeRidgesAndValleysFlag() ? "enabled" : "disabled") << endl;
457  cout << "Suggestive contours : "
458  << (controller->getComputeSuggestiveContoursFlag() ? "enabled" : "disabled") << endl;
459  cout << "Suggestive contour Kr derivative epsilon : "
461  cout << "Material boundaries : "
462  << (controller->getComputeMaterialBoundariesFlag() ? "enabled" : "disabled") << endl;
463  cout << endl;
464  }
465 
466  // set diffuse and z depth passes
467  RenderLayer *rl = RE_GetRenderLayer(re->result, view_layer->name);
468  bool diffuse = false, z = false;
469  for (RenderPass *rpass = (RenderPass *)rl->passes.first; rpass; rpass = rpass->next) {
470  if (STREQ(rpass->name, RE_PASSNAME_DIFFUSE_COLOR)) {
471  controller->setPassDiffuse(rpass->rect, rpass->rectx, rpass->recty);
472  diffuse = true;
473  }
474  if (STREQ(rpass->name, RE_PASSNAME_Z)) {
475  controller->setPassZ(rpass->rect, rpass->rectx, rpass->recty);
476  z = true;
477  }
478  }
479  if (G.debug & G_DEBUG_FREESTYLE) {
480  cout << "Passes :" << endl;
481  cout << " Diffuse = " << (diffuse ? "enabled" : "disabled") << endl;
482  cout << " Z = " << (z ? "enabled" : "disabled") << endl;
483  }
484 
485  if (controller->hitViewMapCache()) {
486  return;
487  }
488 
489  // compute view map
490  re->i.infostr = TIP_("Freestyle: View map creation");
491  re->stats_draw(re->sdh, &re->i);
492  re->i.infostr = nullptr;
494 }
495 
496 void FRS_composite_result(Render *re, ViewLayer *view_layer, Render *freestyle_render)
497 {
498  RenderLayer *rl;
499  float *src, *dest, *pixSrc, *pixDest;
500  int x, y, rectx, recty;
501 
502  if (freestyle_render == nullptr || freestyle_render->result == nullptr) {
503  if (view_layer->freestyle_config.flags & FREESTYLE_AS_RENDER_PASS) {
504  // Create a blank render pass output.
506  re->result, RE_PASSNAME_FREESTYLE, 4, "RGBA", view_layer->name, re->viewname);
507  }
508  return;
509  }
510 
511  rl = render_get_active_layer(freestyle_render, freestyle_render->result);
512  if (!rl) {
513  if (G.debug & G_DEBUG_FREESTYLE) {
514  cout << "No source render layer to composite" << endl;
515  }
516  return;
517  }
518 
519  src = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, freestyle_render->viewname);
520  if (!src) {
521  if (G.debug & G_DEBUG_FREESTYLE) {
522  cout << "No source result image to composite" << endl;
523  }
524  return;
525  }
526 #if 0
527  if (G.debug & G_DEBUG_FREESTYLE) {
528  cout << "src: " << rl->rectx << " x " << rl->recty << endl;
529  }
530 #endif
531 
532  rl = RE_GetRenderLayer(re->result, view_layer->name);
533  if (!rl) {
534  if (G.debug & G_DEBUG_FREESTYLE) {
535  cout << "No destination render layer to composite to" << endl;
536  }
537  return;
538  }
539 
540  if (view_layer->freestyle_config.flags & FREESTYLE_AS_RENDER_PASS) {
542  re->result, RE_PASSNAME_FREESTYLE, 4, "RGBA", view_layer->name, re->viewname);
544  }
545  else {
547  }
548  if (!dest) {
549  if (G.debug & G_DEBUG_FREESTYLE) {
550  cout << "No destination result image to composite to" << endl;
551  }
552  return;
553  }
554 #if 0
555  if (G.debug & G_DEBUG_FREESTYLE) {
556  cout << "dest: " << rl->rectx << " x " << rl->recty << endl;
557  }
558 #endif
559 
560  rectx = re->rectx;
561  recty = re->recty;
562  for (y = 0; y < recty; y++) {
563  for (x = 0; x < rectx; x++) {
564  pixSrc = src + 4 * (rectx * y + x);
565  if (pixSrc[3] > 0.0) {
566  pixDest = dest + 4 * (rectx * y + x);
567  blend_color_mix_float(pixDest, pixDest, pixSrc);
568  }
569  }
570  }
571 }
572 
573 static int displayed_layer_count(ViewLayer *view_layer)
574 {
575  int count = 0;
576 
577  switch (view_layer->freestyle_config.mode) {
581  module;
582  module = module->next) {
583  if (module->script && module->is_displayed) {
584  count++;
585  }
586  }
587  break;
589  for (FreestyleLineSet *lineset =
591  lineset;
592  lineset = lineset->next) {
593  if (lineset->flags & FREESTYLE_LINESET_ENABLED) {
594  count++;
595  }
596  }
597  break;
598  }
599  return count;
600 }
601 
603 {
604  return ((view_layer->flag & VIEW_LAYER_RENDER) && (view_layer->flag & VIEW_LAYER_FREESTYLE) &&
605  displayed_layer_count(view_layer) > 0);
606 }
607 
609 {
610  if (G.debug & G_DEBUG_FREESTYLE) {
611  cout << endl;
612  cout << "#===============================================================" << endl;
613  cout << "# Freestyle" << endl;
614  cout << "#===============================================================" << endl;
615  }
616 
617  init_view(re);
618 
620 }
621 
623 {
624 }
625 
627 {
628  RenderMonitor monitor(re);
629  controller->setRenderMonitor(&monitor);
631  (view_layer->freestyle_config.flags & FREESTYLE_VIEW_MAP_CACHE) ? true : false);
632 
633  if (G.debug & G_DEBUG_FREESTYLE) {
634  cout << endl;
635  cout << "----------------------------------------------------------" << endl;
636  cout << "| " << (re->scene->id.name + 2) << "|" << view_layer->name << endl;
637  cout << "----------------------------------------------------------" << endl;
638  }
639 
640  /* Create depsgraph and evaluate scene. */
641  ViewLayer *scene_view_layer = (ViewLayer *)BLI_findstring(
642  &re->scene->view_layers, view_layer->name, offsetof(ViewLayer, name));
643  Depsgraph *depsgraph = DEG_graph_new(re->main, re->scene, scene_view_layer, DAG_EVAL_RENDER);
645 
646  /* Init camera
647  * Objects are transformed into camera coordinate system, therefore the camera position
648  * is zero and the modelview matrix is the identity matrix. */
649  Object *ob_camera_orig = RE_GetCamera(re);
650  Object *ob_camera_eval = DEG_get_evaluated_object(depsgraph, ob_camera_orig);
653  RE_GetCameraWindow(re, ob_camera_eval, g_freestyle.proj);
654 
655  // prepare Freestyle:
656  // - load mesh
657  // - add style modules
658  // - set parameters
659  // - compute view map
660  prepare(re, view_layer, depsgraph);
661 
662  if (re->test_break(re->tbh)) {
664  if (G.debug & G_DEBUG_FREESTYLE) {
665  cout << "Break" << endl;
666  }
667  }
668  else {
669  // render and composite Freestyle result
670  if (controller->_ViewMap) {
671  // render strokes
672  re->i.infostr = TIP_("Freestyle: Stroke rendering");
673  re->stats_draw(re->sdh, &re->i);
674  re->i.infostr = nullptr;
676  int strokeCount = controller->DrawStrokes();
677  Render *freestyle_render = nullptr;
678  if (strokeCount > 0) {
679  freestyle_render = controller->RenderStrokes(re, true);
680  }
682  g_freestyle.scene = nullptr;
683 
684  // composite result
685  FRS_composite_result(re, view_layer, freestyle_render);
686  if (freestyle_render) {
687  RE_FreeRender(freestyle_render);
688  }
689  }
690  }
691 
693 }
694 
696 {
697  // clear canvas
698  controller->Clear();
699 }
700 
702 {
703  // free cache
704  controller->DeleteViewMap(true);
705 #if 0
706  if (G.debug & G_DEBUG_FREESTYLE) {
707  printf("View map cache freed\n");
708  }
709 #endif
710 }
711 
712 //=======================================================
713 // Freestyle Panel Configuration
714 //=======================================================
715 
717 {
719 
720  if (lineset) {
722  lineset_buffer.flags = lineset->flags;
724  lineset_buffer.qi = lineset->qi;
725  lineset_buffer.qi_start = lineset->qi_start;
726  lineset_buffer.qi_end = lineset->qi_end;
729  lineset_buffer.group = lineset->group;
730  strcpy(lineset_buffer.name, lineset->name);
731  lineset_copied = true;
732  }
733 }
734 
736 {
737  if (!lineset_copied) {
738  return;
739  }
740 
742 
743  if (lineset) {
744  if (lineset->linestyle) {
745  id_us_min(&lineset->linestyle->id);
746  }
748  if (lineset->linestyle) {
749  id_us_plus(&lineset->linestyle->id);
750  }
751  lineset->flags = lineset_buffer.flags;
753  lineset->qi = lineset_buffer.qi;
754  lineset->qi_start = lineset_buffer.qi_start;
755  lineset->qi_end = lineset_buffer.qi_end;
758  if (lineset->group) {
759  id_us_min(&lineset->group->id);
760  lineset->group = nullptr;
761  }
762  if (lineset_buffer.group) {
763  lineset->group = lineset_buffer.group;
764  id_us_plus(&lineset->group->id);
765  }
766  strcpy(lineset->name, lineset_buffer.name);
767  BKE_freestyle_lineset_unique_name(config, lineset);
768  lineset->flags |= FREESTYLE_LINESET_CURRENT;
769  }
770 }
771 
773 {
775 
776  if (lineset) {
777  BKE_freestyle_lineset_delete(config, lineset);
778  }
779 }
780 
785 bool FRS_move_active_lineset(FreestyleConfig *config, int direction)
786 {
788  return (lineset != nullptr) && BLI_listbase_link_move(&config->linesets, lineset, direction);
789 }
790 
791 // Testing
792 
794 {
795  bNodeTree *nt = (linestyle->use_nodes) ? linestyle->nodetree : nullptr;
796  Material *ma = BlenderStrokeRenderer::GetStrokeShader(bmain, nt, true);
797  ma->id.us = 0;
798  return ma;
799 }
800 
801 } // extern "C"
void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt)
Definition: callbacks.c:77
@ BKE_CB_EVT_LOAD_POST
Definition: BKE_callbacks.h:50
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
bool BKE_freestyle_lineset_delete(struct FreestyleConfig *config, struct FreestyleLineSet *lineset)
Definition: freestyle.c:216
void BKE_freestyle_lineset_unique_name(struct FreestyleConfig *config, struct FreestyleLineSet *lineset)
Definition: freestyle.c:167
struct FreestyleLineSet * BKE_freestyle_lineset_get_active(struct FreestyleConfig *config)
Definition: freestyle.c:233
@ G_DEBUG_FREESTYLE
Definition: BKE_global.h:140
void id_us_min(struct ID *id)
Definition: lib_id.c:297
void id_us_plus(struct ID *id)
Definition: lib_id.c:288
Blender kernel freestyle line style functionality.
void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph)
Definition: scene.c:2794
void * BLI_findstring(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
Definition: listbase.c:475
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:1140
#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:281
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
@ DAG_EVAL_RENDER
Definition: DEG_depsgraph.h:62
void DEG_graph_free(Depsgraph *graph)
Definition: depsgraph.cc:314
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_CONTROL_EDITOR_MODE
@ FREESTYLE_CONTROL_SCRIPT_MODE
@ 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_LINESET_FE_AND
@ FREESTYLE_LINESET_ENABLED
@ FREESTYLE_LINESET_CURRENT
@ FREESTYLE_LINESET_FE_NOT
@ FREESTYLE_SEL_EDGE_TYPES
@ FREESTYLE_CULLING
@ FREESTYLE_FACE_SMOOTHNESS_FLAG
@ FREESTYLE_MATERIAL_BOUNDARIES_FLAG
@ FREESTYLE_ADVANCED_OPTIONS_FLAG
@ FREESTYLE_RIDGES_AND_VALLEYS_FLAG
@ FREESTYLE_VIEW_MAP_CACHE
@ FREESTYLE_SUGGESTIVE_CONTOURS_FLAG
@ FREESTYLE_AS_RENDER_PASS
@ FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE
@ FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE
@ 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
#define DEFAULT_DKR_EPSILON
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)
#define DEFAULT_SPHERE_RADIUS
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 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
_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
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:39
static struct PyModuleDef module
void setHeight(unsigned int height)
Definition: AppView.h:67
void setWidth(unsigned int width)
Definition: AppView.h:63
void setBorder(int xmin, int ymin, int xmax, int ymax)
Definition: AppView.h:71
void setThickness(float thickness)
Definition: AppView.h:75
Render * RenderStrokes(Render *re, bool render)
Definition: Controller.cpp:905
void setComputeSuggestiveContoursFlag(bool b)
Definition: Controller.cpp:848
void setPassZ(float *buf, int width, int height)
Definition: Controller.cpp:210
bool getFaceSmoothness() const
Definition: Controller.cpp:833
bool getComputeMaterialBoundariesFlag() const
Definition: Controller.cpp:863
void toggleLayer(unsigned index, bool iDisplay)
Definition: Controller.cpp:986
void setSphereRadius(float s)
Definition: Controller.h:142
void setComputeMaterialBoundariesFlag(bool b)
Definition: Controller.cpp:858
void setVisibilityAlgo(int algo)
Definition: Controller.cpp:757
void setComputeRidgesAndValleysFlag(bool b)
Definition: Controller.cpp:838
void setFaceSmoothness(bool iBool)
Definition: Controller.cpp:828
void setPassDiffuse(float *buf, int width, int height)
Definition: Controller.cpp:203
float getSphereRadius() const
Definition: Controller.h:146
void DeleteViewMap(bool freeCache=false)
Definition: Controller.cpp:421
int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
Definition: Controller.cpp:235
bool getComputeSuggestiveContoursFlag() const
Definition: Controller.cpp:853
void setViewMapCache(bool iBool)
Definition: Controller.cpp:808
void setContext(bContext *C)
Definition: Controller.cpp:217
void setSuggestiveContourKrDerivativeEpsilon(float dkr)
Definition: Controller.h:150
void setCreaseAngle(float angle)
Definition: Controller.h:134
float getCreaseAngle() const
Definition: Controller.h:138
void InsertStyleModule(unsigned index, const char *iFileName)
Definition: Controller.cpp:937
bool getComputeRidgesAndValleysFlag() const
Definition: Controller.cpp:843
float getSuggestiveContourKrDerivativeEpsilon() const
Definition: Controller.h:154
void setView(AppView *iView)
Definition: Controller.cpp:188
void setRenderMonitor(RenderMonitor *iRenderMonitor)
Definition: Controller.cpp:198
std::string id_name(void *id)
FreestyleLineStyle linestyle
const Depsgraph * depsgraph
void RE_GetCameraWindow(struct Render *re, struct Object *camera, float r_winmat[4][4])
Definition: initrender.c:205
struct Object * RE_GetCamera(Render *re)
Definition: initrender.c:169
int count
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
inherits from class Rep
Definition: AppCanvas.cpp:32
void RE_FreeRender(Render *re)
Definition: pipeline.c:627
float * RE_RenderLayerGetPass(volatile RenderLayer *rl, const char *name, const char *viewname)
Definition: pipeline.c:270
RenderLayer * render_get_active_layer(Render *re, RenderResult *rr)
Definition: pipeline.c:296
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
Definition: pipeline.c:276
void RE_create_render_pass(RenderResult *rr, const char *name, int channels, const char *chan_id, const char *layername, const char *viewname)
float viewpoint[3]
Definition: FRS_freestyle.h:36
float proj[4][4]
Definition: FRS_freestyle.h:38
float mv[4][4]
Definition: FRS_freestyle.h:37
struct Scene * scene
Definition: FRS_freestyle.h:33
struct Collection * group
struct FreestyleLineStyle * linestyle
struct bNodeTree * nodetree
int us
Definition: DNA_ID.h:293
char name[66]
Definition: DNA_ID.h:283
void * first
Definition: DNA_listBase.h:47
Definition: BKE_main.h:116
int line_thickness_mode
float unit_line_thickness
ListBase passes
Definition: RE_pipeline.h:108
const char * infostr
Definition: RE_pipeline.h:164
int recty
Definition: render_types.h:97
void * sdh
Definition: render_types.h:140
RenderResult * result
Definition: render_types.h:79
RenderData r
Definition: render_types.h:113
int winy
Definition: render_types.h:92
struct Main * main
Definition: render_types.h:111
Scene * scene
Definition: render_types.h:112
int rectx
Definition: render_types.h:97
char viewname[MAX_NAME]
Definition: render_types.h:154
RenderStats i
Definition: render_types.h:149
void * tbh
Definition: render_types.h:147
int winx
Definition: render_types.h:92
void(* stats_draw)(void *handle, RenderStats *ri)
Definition: render_types.h:139
int(* test_break)(void *handle)
Definition: render_types.h:146
rcti disprect
Definition: render_types.h:93
ListBase view_layers
struct FreestyleConfig freestyle_config
char name[64]
int ymin
Definition: DNA_vec_types.h:80
int ymax
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
int xmax
Definition: DNA_vec_types.h:79
#define G(x, y, z)