Blender V5.3
FRS_freestyle.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <iostream>
10
14
16
17#include "MEM_guardedalloc.h"
18
19#include "CLG_log.h"
20
22#include "DNA_freestyle_types.h"
23#include "DNA_material_types.h"
24#include "DNA_text_types.h"
25
26#include "BKE_callbacks.hh"
27#include "BKE_context.hh"
28#include "BKE_freestyle.h"
29#include "BKE_global.hh"
30#include "BKE_lib_id.hh"
31#include "BKE_linestyle.h"
32#include "BKE_scene.hh"
33#include "BKE_text.h"
34
35#include "BLT_translation.hh"
36
37#include "BLI_listbase.hh"
39#include "BLI_math_matrix_c.hh"
41#include "BLI_string_utf8.hh"
42
43#include "BPY_extern.hh"
44
46
47#include "IMB_imbuf.hh"
48#include "IMB_partial_update.hh"
49
50#include "pipeline.hh"
51
52#include "FRS_freestyle.h"
53
54using namespace std;
55using namespace Freestyle;
56
57namespace blender {
58
60
61static CLG_LogRef LOG = {"render.freestyle"};
62
63// Freestyle configuration
64static bool freestyle_is_initialized = false;
65static Config::Path *pathconfig = nullptr;
66static Controller *controller = nullptr;
67static AppView *view = nullptr;
68
69// line set buffer for copy & paste
71static bool lineset_copied = false;
72
73static void load_post_callback(Main * /*main*/,
74 PointerRNA ** /*pointers*/,
75 const int /*num_pointers*/,
76 void * /*arg*/)
77{
78 lineset_copied = false;
79}
80
82 /*next*/ nullptr,
83 /*prev*/ nullptr,
84 /*func*/ load_post_callback,
85 /*arg*/ nullptr,
86 /*alloc*/ 0};
87
88//=======================================================
89// Initialization
90//=======================================================
91
93{
95 return;
96 }
97
99 controller = new Controller();
100 view = new AppView;
102 controller->Clear();
103 g_freestyle.scene = nullptr;
104 lineset_copied = false;
105
107
109}
110
112{
113 if (G.debug & G_DEBUG_FREESTYLE) {
114 cout << "FRS_set_context: context 0x" << C << " scene 0x" << CTX_data_scene(C) << endl;
115 }
117}
118
120{
121 delete pathconfig;
122 delete controller;
123 delete view;
124}
125
126//=======================================================
127// Rendering
128//=======================================================
129
130static void init_view(Render *re)
131{
132 int width = re->winx;
133 int height = re->winy;
134 int xmin = re->disprect.xmin;
135 int ymin = re->disprect.ymin;
136 int xmax = re->disprect.xmax;
137 int ymax = re->disprect.ymax;
138
139 float thickness = 1.0f;
140 switch (re->scene->r.line_thickness_mode) {
142 thickness = re->scene->r.unit_line_thickness * (re->r.size / 100.0f);
143 break;
145 thickness = height / 480.0f;
146 break;
147 }
148
149 g_freestyle.viewport[0] = 0;
150 g_freestyle.viewport[1] = 0;
151 g_freestyle.viewport[2] = width;
152 g_freestyle.viewport[3] = height;
153
154 view->setWidth(width);
155 view->setHeight(height);
156 view->setBorder(xmin, ymin, xmax, ymax);
157 view->setThickness(thickness);
158
159 if (G.debug & G_DEBUG_FREESTYLE) {
160 cout << "\n=== Dimensions of the 2D image coordinate system ===" << endl;
161 cout << "Width : " << width << endl;
162 cout << "Height : " << height << endl;
163 if (re->r.mode & R_BORDER) {
164 cout << "Border : (" << xmin << ", " << ymin << ") - (" << xmax << ", " << ymax << ")"
165 << endl;
166 }
167 cout << "Unit line thickness : " << thickness << " pixel(s)" << endl;
168 }
169}
170
171static char *escape_quotes(char *name)
172{
173 char *s = MEM_new_array_uninitialized<char>(strlen(name) * 2 + 1, "escape_quotes");
174 char *p = s;
175 while (*name) {
176 /* Escape backslashes too, a trailing one would otherwise end the string literal. */
177 if (ELEM(*name, '\'', '\\')) {
178 *(p++) = '\\';
179 }
180 *(p++) = *(name++);
181 }
182 *p = '\0';
183 return s;
184}
185
186static char *create_lineset_handler(char *layer_name, char *lineset_name)
187{
188 const char *fmt = "__import__('parameter_editor').process('%s', '%s')\n";
189 char *s1 = escape_quotes(layer_name);
190 char *s2 = escape_quotes(lineset_name);
191 char *text = BLI_sprintfN(fmt, s1, s2);
192 MEM_delete(s1);
193 MEM_delete(s2);
194 return text;
195}
196
200
201// examines the conditions and returns true if the target edge type needs to be computed
203 int num_edge_types,
204 bool logical_and,
205 int target,
206 bool distinct)
207{
208 int target_condition = 0;
209 int num_non_target_positive_conditions = 0;
210 int num_non_target_negative_conditions = 0;
211
212 for (int i = 0; i < num_edge_types; i++) {
213 if (conditions[i].edge_type == target) {
214 target_condition = conditions[i].value;
215 }
216 else if (conditions[i].value > 0) {
217 ++num_non_target_positive_conditions;
218 }
219 else if (conditions[i].value < 0) {
220 ++num_non_target_negative_conditions;
221 }
222 }
223 if (distinct) {
224 // In this case, the 'target' edge type is assumed to appear on distinct edge
225 // of its own and never together with other edge types.
226 if (logical_and) {
227 if (num_non_target_positive_conditions > 0) {
228 return false;
229 }
230 if (target_condition > 0) {
231 return true;
232 }
233 if (target_condition < 0) {
234 return false;
235 }
236 if (num_non_target_negative_conditions > 0) {
237 return true;
238 }
239 }
240 else {
241 if (target_condition > 0) {
242 return true;
243 }
244 if (num_non_target_negative_conditions > 0) {
245 return true;
246 }
247 if (target_condition < 0) {
248 return false;
249 }
250 if (num_non_target_positive_conditions > 0) {
251 return false;
252 }
253 }
254 }
255 else {
256 // In this case, the 'target' edge type may appear together with other edge types.
257 if (target_condition > 0) {
258 return true;
259 }
260 if (target_condition < 0) {
261 return true;
262 }
263 if (logical_and) {
264 if (num_non_target_positive_conditions > 0) {
265 return false;
266 }
267 if (num_non_target_negative_conditions > 0) {
268 return true;
269 }
270 }
271 else {
272 if (num_non_target_negative_conditions > 0) {
273 return true;
274 }
275 if (num_non_target_positive_conditions > 0) {
276 return false;
277 }
278 }
279 }
280 return true;
281}
282
283static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
284{
285 // load mesh
286 re->i.infostr = RPT_("Freestyle: Mesh loading");
287 re->display->stats_draw(&re->i);
288 re->i.infostr = nullptr;
289 if (controller->LoadMesh(re, view_layer, depsgraph)) {
290 /* Returns if scene cannot be loaded or if empty. */
291 return;
292 }
293 if (re->display->test_break()) {
294 return;
295 }
296
297 // add style modules
298 FreestyleConfig *config = &view_layer->freestyle_config;
299
300 if (G.debug & G_DEBUG_FREESTYLE) {
301 cout << "\n=== Rendering options ===" << endl;
302 }
303 int layer_count = 0;
304
305 switch (config->mode) {
307 if (G.debug & G_DEBUG_FREESTYLE) {
308 cout << "Modules :" << endl;
309 }
310 for (FreestyleModuleConfig &module_conf : config->modules) {
311 if (module_conf.script && module_conf.is_displayed) {
312 const char *id_name = module_conf.script->id.name + 2;
313
314 /* Style modules are Python scripts, skip them if auto-run is disabled. */
315 if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC)) {
318 SNPRINTF_UTF8(G.autoexec_fail, RPT_("Freestyle style module '%s'"), id_name);
319 }
320 CLOG_WARN(&LOG, "Scripts disabled, skipping style module '%s'", id_name);
321 continue;
322 }
323
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 edge_type_condition conditions[] = {
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 : config->linesets) {
366 if (lineset.flags & FREESTYLE_LINESET_ENABLED) {
367 if (G.debug & G_DEBUG_FREESTYLE) {
368 cout << " " << layer_count + 1 << ": " << lineset.name << " - "
369 << (lineset.linestyle ? (lineset.linestyle->id.name + 2) : "<null>") << endl;
370 }
371 char *buffer = create_lineset_handler(view_layer->name, lineset.name);
372 controller->InsertStyleModule(layer_count, lineset.name, buffer);
373 controller->toggleLayer(layer_count, true);
374 MEM_delete(buffer);
375 if (!(lineset.selection & FREESTYLE_SEL_EDGE_TYPES) || !lineset.edge_types) {
376 ++use_ridges_and_valleys;
377 ++use_suggestive_contours;
378 ++use_material_boundaries;
379 }
380 else {
381 // conditions for feature edge selection by edge types
382 for (int i = 0; i < num_edge_types; i++) {
383 if (!(lineset.edge_types & conditions[i].edge_type)) {
384 conditions[i].value = 0; // no condition specified
385 }
386 else if (!(lineset.exclude_edge_types & conditions[i].edge_type)) {
387 conditions[i].value = 1; // condition: X
388 }
389 else {
390 conditions[i].value = -1; // condition: NOT X
391 }
392 }
393 // logical operator for the selection conditions
394 bool logical_and = ((lineset.flags & FREESTYLE_LINESET_FE_AND) != 0);
395 // negation operator
396 if (lineset.flags & FREESTYLE_LINESET_FE_NOT) {
397 // convert an Exclusive condition into an
398 // Inclusive equivalent using De Morgan's laws:
399 // - NOT (X OR Y) --> (NOT X) AND (NOT Y)
400 // - NOT (X AND Y) --> (NOT X) OR (NOT Y)
401 for (int i = 0; i < num_edge_types; i++) {
402 conditions[i].value *= -1;
403 }
404 logical_and = !logical_and;
405 }
407 conditions, num_edge_types, logical_and, FREESTYLE_FE_RIDGE_VALLEY, true))
408 {
409 ++use_ridges_and_valleys;
410 }
411 if (test_edge_type_conditions(conditions,
412 num_edge_types,
413 logical_and,
415 true))
416 {
417 ++use_suggestive_contours;
418 }
420 conditions, num_edge_types, logical_and, FREESTYLE_FE_MATERIAL_BOUNDARY, true))
421 {
422 ++use_material_boundaries;
423 }
424 }
425 layer_count++;
426 }
427 }
428 controller->setComputeRidgesAndValleysFlag(use_ridges_and_valleys > 0);
429 controller->setComputeSuggestiveContoursFlag(use_suggestive_contours > 0);
430 controller->setComputeMaterialBoundariesFlag(use_material_boundaries > 0);
431 break;
432 }
433
434 // set parameters
442
443 if (G.debug & G_DEBUG_FREESTYLE) {
444 cout << "Crease angle : " << controller->getCreaseAngle() << endl;
445 cout << "Sphere radius : " << controller->getSphereRadius() << endl;
446 cout << "Face smoothness : " << (controller->getFaceSmoothness() ? "enabled" : "disabled")
447 << endl;
448 cout << "Ridges and valleys : "
449 << (controller->getComputeRidgesAndValleysFlag() ? "enabled" : "disabled") << endl;
450 cout << "Suggestive contours : "
451 << (controller->getComputeSuggestiveContoursFlag() ? "enabled" : "disabled") << endl;
452 cout << "Suggestive contour Kr derivative epsilon : "
454 cout << "Material boundaries : "
455 << (controller->getComputeMaterialBoundariesFlag() ? "enabled" : "disabled") << endl;
456 cout << endl;
457 }
458
459 // set diffuse and z depth passes
460 RenderLayer *rl = RE_GetRenderLayer(re->result, view_layer->name);
461 bool diffuse = false, z = false;
462 for (RenderPass &rpass : rl->passes) {
463 float *rpass_buffer_data = rpass.ibuf->float_data_for_write();
465 controller->setPassDiffuse(rpass_buffer_data, rpass.rectx, rpass.recty);
466 diffuse = true;
467 }
468 if (STREQ(rpass.name, RE_PASSNAME_DEPTH)) {
469 controller->setPassZ(rpass_buffer_data, rpass.rectx, rpass.recty);
470 z = true;
471 }
472 }
473 if (G.debug & G_DEBUG_FREESTYLE) {
474 cout << "Passes :" << endl;
475 cout << " Diffuse = " << (diffuse ? "enabled" : "disabled") << endl;
476 cout << " Z = " << (z ? "enabled" : "disabled") << endl;
477 }
478
480 return;
481 }
482
483 // compute view map
484 re->i.infostr = RPT_("Freestyle: View map creation");
485 re->display->stats_draw(&re->i);
486 re->i.infostr = nullptr;
488}
489
490void FRS_composite_result(Render *re, ViewLayer *view_layer, Render *freestyle_render)
491{
492 if (freestyle_render == nullptr || freestyle_render->result == nullptr) {
494 // Create a blank render pass output.
496 re->result, RE_PASSNAME_FREESTYLE, 4, "RGBA", view_layer->name, re->viewname, true);
497 }
498 return;
499 }
500
501 RenderLayer *rl = render_get_single_layer(freestyle_render, freestyle_render->result);
502 if (!rl) {
503 if (G.debug & G_DEBUG_FREESTYLE) {
504 cout << "No source render layer to composite" << endl;
505 }
506 return;
507 }
508
509 const float *src = RE_RenderLayerGetPass(rl, RE_PASSNAME_COMBINED, freestyle_render->viewname);
510 if (!src) {
511 if (G.debug & G_DEBUG_FREESTYLE) {
512 cout << "No source result image to composite" << endl;
513 }
514 return;
515 }
516#if 0
517 if (G.debug & G_DEBUG_FREESTYLE) {
518 cout << "src: " << rl->rectx << " x " << rl->recty << endl;
519 }
520#endif
521
522 rl = RE_GetRenderLayer(re->result, view_layer->name);
523 if (!rl) {
524 if (G.debug & G_DEBUG_FREESTYLE) {
525 cout << "No destination render layer to composite to" << endl;
526 }
527 return;
528 }
529
530 const char *dest_pass;
533 re->result, RE_PASSNAME_FREESTYLE, 4, "RGBA", view_layer->name, re->viewname, true);
534 dest_pass = RE_PASSNAME_FREESTYLE;
535 }
536 else {
537 dest_pass = RE_PASSNAME_COMBINED;
538 }
539
540 ImBuf *dest_ibuf = RE_RenderLayerGetPassImBuf(rl, dest_pass, re->viewname);
541 float *dest = (dest_ibuf) ? dest_ibuf->float_data_for_write() : nullptr;
542 if (!dest) {
543 if (G.debug & G_DEBUG_FREESTYLE) {
544 cout << "No destination result image to composite to" << endl;
545 }
546 return;
547 }
548#if 0
549 if (G.debug & G_DEBUG_FREESTYLE) {
550 cout << "dest: " << rl->rectx << " x " << rl->recty << endl;
551 }
552#endif
553
554 const int rectx = re->rectx;
555 const int recty = re->recty;
556 for (int y = 0; y < recty; y++) {
557 for (int x = 0; x < rectx; x++) {
558 const float *pixSrc = src + 4 * (rectx * y + x);
559 if (pixSrc[3] > 0.0) {
560 float *pixDest = dest + 4 * (rectx * y + x);
561 blend_color_mix_float(pixDest, pixDest, pixSrc);
562 }
563 }
564 }
565
567}
568
569static int displayed_layer_count(ViewLayer *view_layer)
570{
571 int count = 0;
572
573 switch (view_layer->freestyle_config.mode) {
575 for (FreestyleModuleConfig &module : view_layer->freestyle_config.modules) {
576 if (module.script && module.is_displayed) {
577 count++;
578 }
579 }
580 break;
582 for (FreestyleLineSet &lineset : view_layer->freestyle_config.linesets) {
583 if (lineset.flags & FREESTYLE_LINESET_ENABLED) {
584 count++;
585 }
586 }
587 break;
588 }
589 return count;
590}
591
593{
594 return ((view_layer->flag & VIEW_LAYER_RENDER) && (view_layer->flag & VIEW_LAYER_FREESTYLE) &&
595 displayed_layer_count(view_layer) > 0);
596}
597
599{
600 if (G.debug & G_DEBUG_FREESTYLE) {
601 cout << endl;
602 cout << "#===============================================================" << endl;
603 cout << "# Freestyle" << endl;
604 cout << "#===============================================================" << endl;
605 }
606
607 init_view(re);
608
610}
611
613
615{
616 RenderMonitor monitor(re);
617 controller->setRenderMonitor(&monitor);
619 (view_layer->freestyle_config.flags & FREESTYLE_VIEW_MAP_CACHE) ? true : false);
620
621 if (G.debug & G_DEBUG_FREESTYLE) {
622 cout << endl;
623 cout << "----------------------------------------------------------" << endl;
624 cout << "| " << (re->scene->id.name + 2) << "|" << view_layer->name << endl;
625 cout << "----------------------------------------------------------" << endl;
626 }
627
628 /* Create depsgraph and evaluate scene. */
629 ViewLayer *scene_view_layer = (ViewLayer *)BLI_findstring(
630 &re->scene->view_layers, view_layer->name, offsetof(ViewLayer, name));
631 Depsgraph *depsgraph = DEG_graph_new(re->main, re->scene, scene_view_layer, DAG_EVAL_RENDER);
633
634 /* Init camera
635 * Objects are transformed into camera coordinate system, therefore the camera position
636 * is zero and the model-view matrix is the identity matrix. */
637 Object *ob_camera_orig = RE_GetCamera(re);
638 Object *ob_camera_eval = DEG_get_evaluated(depsgraph, ob_camera_orig);
641 RE_GetCameraWindow(re, ob_camera_eval, g_freestyle.proj);
642
643 // prepare Freestyle:
644 // - load mesh
645 // - add style modules
646 // - set parameters
647 // - compute view map
648 prepare(re, view_layer, depsgraph);
649
650 if (re->display->test_break()) {
652 if (G.debug & G_DEBUG_FREESTYLE) {
653 cout << "Break" << endl;
654 }
655 }
656 else {
657 // render and composite Freestyle result
658 if (controller->_ViewMap) {
659 // render strokes
660 re->i.infostr = RPT_("Freestyle: Stroke rendering");
661 re->display->stats_draw(&re->i);
662 re->i.infostr = nullptr;
664 int strokeCount = controller->DrawStrokes();
665 Render *freestyle_render = nullptr;
666 if (strokeCount > 0) {
667 freestyle_render = controller->RenderStrokes(re, true);
668 }
670 g_freestyle.scene = nullptr;
671
672 // composite result
673 FRS_composite_result(re, view_layer, freestyle_render);
674 if (freestyle_render) {
675 RE_FreeRender(freestyle_render);
676 }
677 }
678 }
679
680 DEG_graph_free(depsgraph);
681}
682
684{
685 // clear canvas
686 controller->Clear();
687}
688
690{
691 // free cache
693#if 0
694 if (G.debug & G_DEBUG_FREESTYLE) {
695 printf("View map cache freed\n");
696 }
697#endif
698}
699
700//=======================================================
701// Freestyle Panel Configuration
702//=======================================================
703
705{
707
708 if (lineset) {
710 lineset_buffer.flags = lineset->flags;
712 lineset_buffer.qi = lineset->qi;
714 lineset_buffer.qi_end = lineset->qi_end;
717 lineset_buffer.group = lineset->group;
718 STRNCPY(lineset_buffer.name, lineset->name);
719 lineset_copied = true;
720 }
721}
722
724{
725 if (!lineset_copied) {
726 return;
727 }
728
730
731 if (lineset) {
732 if (lineset->linestyle) {
733 id_us_min(&lineset->linestyle->id);
734 }
736 if (lineset->linestyle) {
737 id_us_plus(&lineset->linestyle->id);
738 }
739 lineset->flags = lineset_buffer.flags;
741 lineset->qi = lineset_buffer.qi;
743 lineset->qi_end = lineset_buffer.qi_end;
746 if (lineset->group) {
747 id_us_min(&lineset->group->id);
748 lineset->group = nullptr;
749 }
750 if (lineset_buffer.group) {
751 lineset->group = lineset_buffer.group;
752 id_us_plus(&lineset->group->id);
753 }
754 STRNCPY(lineset->name, lineset_buffer.name);
755 BKE_freestyle_lineset_unique_name(config, lineset);
757 }
758}
759
761{
763
764 if (lineset) {
765 BKE_freestyle_lineset_delete(config, lineset);
766 }
767}
768
769bool FRS_move_active_lineset(FreestyleConfig *config, int direction)
770{
772 return (lineset != nullptr) && BLI_listbase_link_move(&config->linesets, lineset, direction);
773}
774
775// Testing
776
778{
779 bNodeTree *nt = (linestyle->use_nodes) ? linestyle->nodetree : nullptr;
781 ma->id.us = 0;
782 return ma;
783}
784
785} // namespace blender
Configuration file.
Blender kernel freestyle line style functionality.
#define RAD2DEGF(_rad)
#define SNPRINTF_UTF8(dst, format,...)
#define RPT_(msgid)
#define CLOG_WARN(clg_ref,...)
Definition CLG_log.h:189
The spinal tap of the system.
Object groups, one object can be in many groups at once.
#define RE_PASSNAME_COMBINED
#define RE_PASSNAME_DEPTH
#define RE_PASSNAME_DIFFUSE_COLOR
#define RE_PASSNAME_FREESTYLE
Read Blender memory allocation and freeing.
#define ELEM(...)
#define STREQ(a, b)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
Definition btQuadWord.h:117
void setWidth(uint 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
void setHeight(uint height)
Definition AppView.h:53
static blender::Material * GetStrokeShader(blender::Main *bmain, blender::bNodeTree *iNodeTree, bool do_id_user)
int LoadMesh(blender::Render *re, blender::ViewLayer *view_layer, blender::Depsgraph *depsgraph)
void setComputeSuggestiveContoursFlag(bool b)
void setPassZ(float *buf, int width, int height)
bool getFaceSmoothness() const
bool getComputeMaterialBoundariesFlag() const
void setSphereRadius(float s)
Definition Controller.h:134
void setComputeMaterialBoundariesFlag(bool b)
void setVisibilityAlgo(int algo)
void setComputeRidgesAndValleysFlag(bool b)
void setFaceSmoothness(bool iBool)
void setPassDiffuse(float *buf, int width, int height)
float getSphereRadius() const
Definition Controller.h:138
void setContext(blender::bContext *C)
blender::Render * RenderStrokes(blender::Render *re, bool render)
void DeleteViewMap(bool freeCache=false)
bool getComputeSuggestiveContoursFlag() const
void setViewMapCache(bool iBool)
void toggleLayer(uint index, bool iDisplay)
void setSuggestiveContourKrDerivativeEpsilon(float dkr)
Definition Controller.h:142
void setCreaseAngle(float angle)
Definition Controller.h:126
float getCreaseAngle() const
Definition Controller.h:130
bool getComputeRidgesAndValleysFlag() const
float getSuggestiveContourKrDerivativeEpsilon() const
Definition Controller.h:146
void setView(AppView *iView)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
void InsertStyleModule(uint index, const char *iFileName)
#define offsetof(t, d)
inherits from class Rep
Definition AppCanvas.cpp:20
BMesh Iterators.
static char * create_lineset_handler(char *layer_name, char *lineset_name)
int FRS_is_freestyle_enabled(struct ViewLayer *view_layer)
void FRS_delete_active_lineset(struct FreestyleConfig *config)
void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph)
Definition scene.cc:2953
char * STRNCPY(char(&dst)[N], const char *src)
void FRS_free_view_map_cache(void)
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
@ BKE_CB_EVT_LOAD_POST
static int displayed_layer_count(ViewLayer *view_layer)
static void init_view(Render *re)
void DEG_graph_free(Depsgraph *graph)
Definition depsgraph.cc:307
void id_us_plus(ID *id)
Definition lib_id.cc:433
static AppView * view
struct FreestyleGlobals g_freestyle
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
static Config::Path * pathconfig
bool FRS_move_active_lineset(struct FreestyleConfig *config, int direction)
char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
Depsgraph * DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
Definition depsgraph.cc:279
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:615
@ FREESTYLE_RIDGES_AND_VALLEYS_FLAG
@ FREESTYLE_SUGGESTIVE_CONTOURS_FLAG
@ FREESTYLE_FACE_SMOOTHNESS_FLAG
@ FREESTYLE_MATERIAL_BOUNDARIES_FLAG
void BKE_freestyle_lineset_unique_name(struct FreestyleConfig *config, struct FreestyleLineSet *lineset)
Definition freestyle.cc:150
void RE_GetCameraWindow(Render *re, const Object *camera, float r_winmat[4][4])
Definition initrender.cc:62
ImBuf * RE_RenderLayerGetPassImBuf(RenderLayer *rl, const char *name, const char *viewname)
static bCallbackFuncStore load_post_callback_funcstore
void FRS_end_stroke_rendering(struct Render *re)
void FRS_init_stroke_renderer(struct Render *re)
static bool test_edge_type_conditions(edge_type_condition *conditions, int num_edge_types, bool logical_and, int target, bool distinct)
@ G_DEBUG_FREESTYLE
Global G
Definition blender.cc:57
void FRS_set_context(struct bContext *C)
void FRS_do_stroke_rendering(struct Render *re, struct ViewLayer *view_layer)
void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt)
Definition callbacks.cc:87
void FRS_exit(void)
static bool freestyle_is_initialized
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
void FRS_init(void)
struct FreestyleLineSet * BKE_freestyle_lineset_get_active(struct FreestyleConfig *config)
Definition freestyle.cc:214
bool BKE_freestyle_lineset_delete(struct FreestyleConfig *config, struct FreestyleLineSet *lineset)
Definition freestyle.cc:197
float * RE_RenderLayerGetPass(RenderLayer *rl, const char *name, const char *viewname)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
void unit_m4(float m[4][4])
void IMB_partial_update_mark_full(ImBuf *ibuf)
static char * escape_quotes(char *name)
static void load_post_callback(Main *, PointerRNA **, const int, void *)
MINLINE void zero_v3(float r[3])
@ R_LINE_THICKNESS_RELATIVE
@ R_LINE_THICKNESS_ABSOLUTE
static bool lineset_copied
void FRS_begin_stroke_rendering(struct Render *re)
@ G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET
@ G_FLAG_SCRIPT_AUTOEXEC_FAIL
@ G_FLAG_SCRIPT_AUTOEXEC
void FRS_composite_result(struct Render *re, struct ViewLayer *view_layer, struct Render *freestyle_render)
static FreestyleLineSet lineset_buffer
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)
@ FREESTYLE_FE_EXTERNAL_CONTOUR
@ FREESTYLE_FE_SUGGESTIVE_CONTOUR
@ FREESTYLE_FE_MATERIAL_BOUNDARY
static CLG_LogRef LOG
static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
Scene * CTX_data_scene(const bContext *C)
void FRS_copy_active_lineset(struct FreestyleConfig *config)
@ FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE
@ FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE
void FRS_paste_active_lineset(struct FreestyleConfig *config)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
struct Material * FRS_create_stroke_material(struct Main *bmain, struct FreestyleLineStyle *linestyle)
static Controller * controller
void id_us_min(ID *id)
Definition lib_id.cc:441
RenderLayer * render_get_single_layer(Render *re, RenderResult *rr)
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
Definition listbase.cc:443
Object * RE_GetCamera(Render *re)
Definition initrender.cc:31
@ FREESTYLE_CONTROL_EDITOR_MODE
@ FREESTYLE_CONTROL_SCRIPT_MODE
std::shared_ptr< RenderDisplay > display
RenderResult * result
ListBaseT< FreestyleModuleConfig > modules
eFreestyleControl_Mode mode
eFreestyleConfig_Flags flags
ListBaseT< FreestyleLineSet > linesets
eFreestyleLineSet_EdgeTypes exclude_edge_types
eFreestyleLineSet_Selection selection
struct FreestyleLineStyle * linestyle
eFreestyleLineSet_EdgeTypes edge_types
eFreestyleLineSet_Flags flags
char name[258]
Definition DNA_ID.h:433
float * float_data_for_write()
Definition allocimbuf.cc:79
ListBaseT< RenderPass > passes
Definition RE_pipeline.h:99
struct ImBuf * ibuf
Definition RE_pipeline.h:72
const char * infostr
RenderStats i
struct Main * main
char viewname[MAX_NAME]
ListBaseT< ViewLayer > view_layers
struct RenderData r
struct FreestyleConfig freestyle_config
eViewLayer_Flag flag