Blender  V2.93
render_shading.c
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  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program; if not, write to the Free Software Foundation,
13  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14  *
15  * The Original Code is Copyright (C) 2009 Blender Foundation.
16  * All rights reserved.
17  */
18 
23 #include <stdlib.h>
24 #include <string.h>
25 
26 #include "MEM_guardedalloc.h"
27 
28 #include "DNA_curve_types.h"
29 #include "DNA_light_types.h"
30 #include "DNA_lightprobe_types.h"
31 #include "DNA_material_types.h"
32 #include "DNA_node_types.h"
33 #include "DNA_object_types.h"
34 #include "DNA_particle_types.h"
35 #include "DNA_scene_types.h"
36 #include "DNA_space_types.h"
37 #include "DNA_world_types.h"
38 
39 #include "BLI_listbase.h"
40 #include "BLI_math_vector.h"
41 #include "BLI_utildefines.h"
42 
43 #include "BLT_translation.h"
44 
45 #include "BKE_anim_data.h"
46 #include "BKE_animsys.h"
47 #include "BKE_brush.h"
48 #include "BKE_context.h"
49 #include "BKE_curve.h"
50 #include "BKE_editmesh.h"
51 #include "BKE_font.h"
52 #include "BKE_global.h"
53 #include "BKE_image.h"
54 #include "BKE_layer.h"
55 #include "BKE_lib_id.h"
56 #include "BKE_linestyle.h"
57 #include "BKE_main.h"
58 #include "BKE_material.h"
59 #include "BKE_node.h"
60 #include "BKE_object.h"
61 #include "BKE_report.h"
62 #include "BKE_scene.h"
63 #include "BKE_texture.h"
64 #include "BKE_workspace.h"
65 #include "BKE_world.h"
66 
67 #include "DEG_depsgraph.h"
68 #include "DEG_depsgraph_build.h"
69 
70 #ifdef WITH_FREESTYLE
71 # include "BKE_freestyle.h"
72 # include "FRS_freestyle.h"
73 # include "RNA_enum_types.h"
74 #endif
75 
76 #include "RNA_access.h"
77 
78 #include "WM_api.h"
79 #include "WM_types.h"
80 
81 #include "ED_curve.h"
82 #include "ED_mesh.h"
83 #include "ED_node.h"
84 #include "ED_object.h"
85 #include "ED_paint.h"
86 #include "ED_render.h"
87 #include "ED_scene.h"
88 #include "ED_screen.h"
89 
90 #include "RNA_define.h"
91 
92 #include "UI_interface.h"
93 
94 #include "RE_engine.h"
95 #include "RE_pipeline.h"
96 
98 
99 #include "render_intern.h" /* own include */
100 
101 static bool object_materials_supported_poll_ex(bContext *C, const Object *ob);
102 
103 /* -------------------------------------------------------------------- */
108 {
109  bContext *C = user_data;
111  if (BKE_object_is_in_editmode(ob) == true) {
112  return true;
113  }
114  }
115  return false;
116 }
117 
119 {
122 }
123 
125 {
126  bContext *C = user_data;
128  if (BKE_object_is_in_editmode(ob) == false) {
129  return true;
130  }
131  }
132  return false;
133 }
134 
136 {
139 }
140 
143 /* -------------------------------------------------------------------- */
148 {
150  return false;
151  }
152  if (!OB_TYPE_SUPPORT_MATERIAL(ob->type)) {
153  return false;
154  }
155 
156  /* Material linked to object. */
157  if (ob->matbits && ob->actcol && ob->matbits[ob->actcol - 1]) {
158  return true;
159  }
160 
161  /* Material linked to obdata. */
162  const ID *data = ob->data;
163  return (data && !ID_IS_LINKED(data) && !ID_IS_OVERRIDE_LIBRARY(data));
164 }
165 
167 {
168  Object *ob = ED_object_context(C);
170 }
171 
174 /* -------------------------------------------------------------------- */
179 {
180  Main *bmain = CTX_data_main(C);
181  Object *ob = ED_object_context(C);
182 
183  if (!ob) {
184  return OPERATOR_CANCELLED;
185  }
186 
187  BKE_object_material_slot_add(bmain, ob);
188 
189  if (ob->mode & OB_MODE_TEXTURE_PAINT) {
193  }
194 
198 
199  return OPERATOR_FINISHED;
200 }
201 
203 {
204  /* identifiers */
205  ot->name = "Add Material Slot";
206  ot->idname = "OBJECT_OT_material_slot_add";
207  ot->description = "Add a new material slot";
208 
209  /* api callbacks */
212 
213  /* flags */
215 }
216 
219 /* -------------------------------------------------------------------- */
224 {
225  Object *ob = ED_object_context(C);
226 
227  if (!ob) {
228  return OPERATOR_CANCELLED;
229  }
230 
231  /* Removing material slots in edit mode screws things up, see bug T21822.*/
232  if (ob == CTX_data_edit_object(C)) {
233  BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode");
234  return OPERATOR_CANCELLED;
235  }
236 
238 
239  if (ob->mode & OB_MODE_TEXTURE_PAINT) {
243  }
244 
249 
250  return OPERATOR_FINISHED;
251 }
252 
254 {
255  /* identifiers */
256  ot->name = "Remove Material Slot";
257  ot->idname = "OBJECT_OT_material_slot_remove";
258  ot->description = "Remove the selected material slot";
259 
260  /* api callbacks */
263 
264  /* flags */
266 }
267 
270 /* -------------------------------------------------------------------- */
275 {
276  View3D *v3d = CTX_wm_view3d(C);
277  bool changed_multi = false;
278 
279  Object *obact = CTX_data_active_object(C);
280  const Material *mat_active = obact ? BKE_object_material_get(obact, obact->actcol) : NULL;
281 
282  uint objects_len = 0;
283  Object **objects = object_array_for_shading_edit_mode_enabled(C, &objects_len);
284  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
285  Object *ob = objects[ob_index];
286  short mat_nr_active = -1;
287 
288  if (ob->totcol == 0) {
289  continue;
290  }
291  if (obact && (mat_active == BKE_object_material_get(ob, obact->actcol))) {
292  /* Avoid searching since there may be multiple slots with the same material.
293  * For the active object or duplicates: match the material slot index first. */
294  mat_nr_active = obact->actcol - 1;
295  }
296  else {
297  /* Find the first matching material.
298  * Note: there may be multiple but that's not a common use case. */
299  for (int i = 0; i < ob->totcol; i++) {
300  const Material *mat = BKE_object_material_get(ob, i + 1);
301  if (mat_active == mat) {
302  mat_nr_active = i;
303  break;
304  }
305  }
306  if (mat_nr_active == -1) {
307  continue;
308  }
309  }
310 
311  bool changed = false;
312  if (ob->type == OB_MESH) {
314  BMFace *efa;
315  BMIter iter;
316 
317  if (em) {
318  BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
319  if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
320  changed = true;
321  efa->mat_nr = mat_nr_active;
322  }
323  }
324  }
325  }
326  else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
327  Nurb *nu;
328  ListBase *nurbs = BKE_curve_editNurbs_get((Curve *)ob->data);
329 
330  if (nurbs) {
331  for (nu = nurbs->first; nu; nu = nu->next) {
332  if (ED_curve_nurb_select_check(v3d, nu)) {
333  changed = true;
334  nu->mat_nr = mat_nr_active;
335  }
336  }
337  }
338  }
339  else if (ob->type == OB_FONT) {
340  EditFont *ef = ((Curve *)ob->data)->editfont;
341  int i, selstart, selend;
342 
343  if (ef && BKE_vfont_select_get(ob, &selstart, &selend)) {
344  for (i = selstart; i <= selend; i++) {
345  changed = true;
346  ef->textbufinfo[i].mat_nr = mat_nr_active + 1;
347  }
348  }
349  }
350 
351  if (changed) {
352  changed_multi = true;
355  }
356  }
357  MEM_freeN(objects);
358 
359  return (changed_multi) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
360 }
361 
363 {
364  /* identifiers */
365  ot->name = "Assign Material Slot";
366  ot->idname = "OBJECT_OT_material_slot_assign";
367  ot->description = "Assign active material slot to selection";
368 
369  /* api callbacks */
372 
373  /* flags */
375 }
376 
379 /* -------------------------------------------------------------------- */
384 {
385  bool changed_multi = false;
386  Object *obact = CTX_data_active_object(C);
387  const Material *mat_active = obact ? BKE_object_material_get(obact, obact->actcol) : NULL;
388 
389  uint objects_len = 0;
390  Object **objects = object_array_for_shading_edit_mode_enabled(C, &objects_len);
391  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
392  Object *ob = objects[ob_index];
393  short mat_nr_active = -1;
394 
395  if (ob->totcol == 0) {
396  continue;
397  }
398  if (obact && (mat_active == BKE_object_material_get(ob, obact->actcol))) {
399  /* Avoid searching since there may be multiple slots with the same material.
400  * For the active object or duplicates: match the material slot index first. */
401  mat_nr_active = obact->actcol - 1;
402  }
403  else {
404  /* Find the first matching material.
405  * Note: there may be multiple but that's not a common use case. */
406  for (int i = 0; i < ob->totcol; i++) {
407  const Material *mat = BKE_object_material_get(ob, i + 1);
408  if (mat_active == mat) {
409  mat_nr_active = i;
410  break;
411  }
412  }
413  if (mat_nr_active == -1) {
414  continue;
415  }
416  }
417 
418  bool changed = false;
419 
420  if (ob->type == OB_MESH) {
422 
423  if (em) {
424  changed = EDBM_deselect_by_material(em, mat_nr_active, select);
425  }
426  }
427  else if (ELEM(ob->type, OB_CURVE, OB_SURF)) {
428  ListBase *nurbs = BKE_curve_editNurbs_get((Curve *)ob->data);
429  Nurb *nu;
430  BPoint *bp;
431  BezTriple *bezt;
432  int a;
433 
434  if (nurbs) {
435  for (nu = nurbs->first; nu; nu = nu->next) {
436  if (nu->mat_nr == mat_nr_active) {
437  if (nu->bezt) {
438  a = nu->pntsu;
439  bezt = nu->bezt;
440  while (a--) {
441  if (bezt->hide == 0) {
442  changed = true;
443  if (select) {
444  bezt->f1 |= SELECT;
445  bezt->f2 |= SELECT;
446  bezt->f3 |= SELECT;
447  }
448  else {
449  bezt->f1 &= ~SELECT;
450  bezt->f2 &= ~SELECT;
451  bezt->f3 &= ~SELECT;
452  }
453  }
454  bezt++;
455  }
456  }
457  else if (nu->bp) {
458  a = nu->pntsu * nu->pntsv;
459  bp = nu->bp;
460  while (a--) {
461  if (bp->hide == 0) {
462  changed = true;
463  if (select) {
464  bp->f1 |= SELECT;
465  }
466  else {
467  bp->f1 &= ~SELECT;
468  }
469  }
470  bp++;
471  }
472  }
473  }
474  }
475  }
476  }
477 
478  if (changed) {
479  changed_multi = true;
482  }
483  }
484 
485  MEM_freeN(objects);
486 
487  return (changed_multi) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
488 }
489 
491 {
492  return material_slot_de_select(C, true);
493 }
494 
496 {
497  /* identifiers */
498  ot->name = "Select Material Slot";
499  ot->idname = "OBJECT_OT_material_slot_select";
500  ot->description = "Select by active material slot";
501 
502  /* api callbacks */
504 
505  /* flags */
507 }
508 
510 {
511  return material_slot_de_select(C, false);
512 }
513 
515 {
516  /* identifiers */
517  ot->name = "Deselect Material Slot";
518  ot->idname = "OBJECT_OT_material_slot_deselect";
519  ot->description = "Deselect by active material slot";
520 
521  /* api callbacks */
523 
524  /* flags */
526 }
527 
530 /* -------------------------------------------------------------------- */
535 {
536  Main *bmain = CTX_data_main(C);
537  Object *ob = ED_object_context(C);
538  Material ***matar_obdata;
539 
540  if (!ob || !(matar_obdata = BKE_object_material_array_p(ob))) {
541  return OPERATOR_CANCELLED;
542  }
543 
545 
546  Material ***matar_object = &ob->mat;
547 
548  Material **matar = MEM_callocN(sizeof(*matar) * (size_t)ob->totcol, __func__);
549  for (int i = ob->totcol; i--;) {
550  matar[i] = ob->matbits[i] ? (*matar_object)[i] : (*matar_obdata)[i];
551  }
552 
553  CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
554  if (ob != ob_iter && BKE_object_material_array_p(ob_iter)) {
555  /* If we are using the same obdata, we only assign slots in ob_iter that are using object
556  * materials, and not obdata ones. */
557  const bool is_same_obdata = ob->data == ob_iter->data;
558  BKE_object_material_array_assign(bmain, ob_iter, &matar, ob->totcol, is_same_obdata);
559 
560  if (ob_iter->totcol == ob->totcol) {
561  ob_iter->actcol = ob->actcol;
562  DEG_id_tag_update(&ob_iter->id, ID_RECALC_GEOMETRY);
564  }
565  }
566  }
567  CTX_DATA_END;
568 
569  MEM_freeN(matar);
570 
571  return OPERATOR_FINISHED;
572 }
573 
575 {
576  /* identifiers */
577  ot->name = "Copy Material to Selected";
578  ot->idname = "OBJECT_OT_material_slot_copy";
579  ot->description = "Copy material to selected objects";
580 
581  /* api callbacks */
583 
584  /* flags */
586 }
587 
590 /* -------------------------------------------------------------------- */
595 {
596  Object *ob = ED_object_context(C);
597 
598  uint *slot_remap;
599  int index_pair[2];
600 
601  int dir = RNA_enum_get(op->ptr, "direction");
602 
603  if (!ob || ob->totcol < 2) {
604  return OPERATOR_CANCELLED;
605  }
606 
607  /* up */
608  if (dir == 1 && ob->actcol > 1) {
609  index_pair[0] = ob->actcol - 2;
610  index_pair[1] = ob->actcol - 1;
611  ob->actcol--;
612  }
613  /* down */
614  else if (dir == -1 && ob->actcol < ob->totcol) {
615  index_pair[0] = ob->actcol - 1;
616  index_pair[1] = ob->actcol - 0;
617  ob->actcol++;
618  }
619  else {
620  return OPERATOR_CANCELLED;
621  }
622 
623  slot_remap = MEM_mallocN(sizeof(uint) * ob->totcol, __func__);
624 
625  range_vn_u(slot_remap, ob->totcol, 0);
626 
627  slot_remap[index_pair[0]] = index_pair[1];
628  slot_remap[index_pair[1]] = index_pair[0];
629 
630  BKE_object_material_remap(ob, slot_remap);
631 
632  MEM_freeN(slot_remap);
633 
637 
638  return OPERATOR_FINISHED;
639 }
640 
642 {
643  static const EnumPropertyItem material_slot_move[] = {
644  {1, "UP", 0, "Up", ""},
645  {-1, "DOWN", 0, "Down", ""},
646  {0, NULL, 0, NULL, NULL},
647  };
648 
649  /* identifiers */
650  ot->name = "Move Material";
651  ot->idname = "OBJECT_OT_material_slot_move";
652  ot->description = "Move the active material up/down in the list";
653 
654  /* api callbacks */
657 
658  /* flags */
660 
662  "direction",
663  material_slot_move,
664  0,
665  "Direction",
666  "Direction to move the active material towards");
667 }
668 
671 /* -------------------------------------------------------------------- */
676 {
677  /* Removing material slots in edit mode screws things up, see bug T21822. */
678  Object *ob_active = CTX_data_active_object(C);
679  if (ob_active && BKE_object_is_in_editmode(ob_active)) {
680  BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode");
681  return OPERATOR_CANCELLED;
682  }
683 
684  Main *bmain = CTX_data_main(C);
685  int removed = 0;
686 
687  uint objects_len = 0;
688  Object **objects = object_array_for_shading_edit_mode_disabled(C, &objects_len);
689  for (uint ob_index = 0; ob_index < objects_len; ob_index++) {
690  Object *ob = objects[ob_index];
691  int actcol = ob->actcol;
692  for (int slot = 1; slot <= ob->totcol; slot++) {
693  while (slot <= ob->totcol && !BKE_object_material_slot_used(ob->data, slot)) {
694  ob->actcol = slot;
696 
697  if (actcol >= slot) {
698  actcol--;
699  }
700 
701  removed++;
702  }
703  }
704  ob->actcol = actcol;
705 
707  }
708  MEM_freeN(objects);
709 
710  if (!removed) {
711  return OPERATOR_CANCELLED;
712  }
713 
714  BKE_reportf(op->reports, RPT_INFO, "Removed %d slots", removed);
715 
716  if (ob_active->mode & OB_MODE_TEXTURE_PAINT) {
720  }
721 
722  WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob_active);
725 
726  return OPERATOR_FINISHED;
727 }
728 
730 {
731  /* identifiers */
732  ot->name = "Remove Unused Slots";
733  ot->idname = "OBJECT_OT_material_slot_remove_unused";
734  ot->description = "Remove unused material slots";
735 
736  /* api callbacks */
739 
740  /* flags */
742 }
743 
746 /* -------------------------------------------------------------------- */
751 {
753  Main *bmain = CTX_data_main(C);
754  PointerRNA ptr, idptr;
755  PropertyRNA *prop;
756 
757  /* hook into UI */
759 
760  Object *ob = (prop && RNA_struct_is_a(ptr.type, &RNA_Object)) ? ptr.data : NULL;
761 
762  /* add or copy material */
763  if (ma) {
764  Material *new_ma = (Material *)BKE_id_copy_ex(
766  ma = new_ma;
767  }
768  else {
769  const char *name = DATA_("Material");
770  if (!(ob != NULL && ob->type == OB_GPENCIL)) {
771  ma = BKE_material_add(bmain, name);
772  }
773  else {
774  ma = BKE_gpencil_material_add(bmain, name);
775  }
776  ED_node_shader_default(C, &ma->id);
777  ma->use_nodes = true;
778  }
779 
780  if (prop) {
781  if (ob != NULL) {
782  /* Add slot follows user-preferences for creating new slots,
783  * RNA pointer assignment doesn't, see: T60014. */
784  if (BKE_object_material_get_p(ob, ob->actcol) == NULL) {
785  BKE_object_material_slot_add(bmain, ob);
786  }
787  }
788 
789  /* when creating new ID blocks, use is already 1, but RNA
790  * pointer use also increases user, so this compensates it */
791  id_us_min(&ma->id);
792 
793  RNA_id_pointer_create(&ma->id, &idptr);
794  RNA_property_pointer_set(&ptr, prop, idptr, NULL);
795  RNA_property_update(C, &ptr, prop);
796  }
797 
799 
800  return OPERATOR_FINISHED;
801 }
802 
804 {
805  /* identifiers */
806  ot->name = "New Material";
807  ot->idname = "MATERIAL_OT_new";
808  ot->description = "Add a new material";
809 
810  /* api callbacks */
813 
814  /* flags */
816 }
817 
820 /* -------------------------------------------------------------------- */
825 {
827  Main *bmain = CTX_data_main(C);
828  PointerRNA ptr, idptr;
829  PropertyRNA *prop;
830 
831  /* add or copy texture */
832  if (tex) {
833  tex = (Tex *)BKE_id_copy(bmain, &tex->id);
834  }
835  else {
836  tex = BKE_texture_add(bmain, DATA_("Texture"));
837  }
838 
839  /* hook into UI */
841 
842  if (prop) {
843  /* when creating new ID blocks, use is already 1, but RNA
844  * pointer use also increases user, so this compensates it */
845  id_us_min(&tex->id);
846 
847  RNA_id_pointer_create(&tex->id, &idptr);
848  RNA_property_pointer_set(&ptr, prop, idptr, NULL);
849  RNA_property_update(C, &ptr, prop);
850  }
851 
853 
854  return OPERATOR_FINISHED;
855 }
856 
858 {
859  /* identifiers */
860  ot->name = "New Texture";
861  ot->idname = "TEXTURE_OT_new";
862  ot->description = "Add a new texture";
863 
864  /* api callbacks */
866 
867  /* flags */
869 }
870 
873 /* -------------------------------------------------------------------- */
878 {
879  World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
880  Main *bmain = CTX_data_main(C);
881  PointerRNA ptr, idptr;
882  PropertyRNA *prop;
883 
884  /* add or copy world */
885  if (wo) {
886  World *new_wo = (World *)BKE_id_copy_ex(
888  wo = new_wo;
889  }
890  else {
891  wo = BKE_world_add(bmain, DATA_("World"));
892  ED_node_shader_default(C, &wo->id);
893  wo->use_nodes = true;
894  }
895 
896  /* hook into UI */
898 
899  if (prop) {
900  /* when creating new ID blocks, use is already 1, but RNA
901  * pointer use also increases user, so this compensates it */
902  id_us_min(&wo->id);
903 
904  RNA_id_pointer_create(&wo->id, &idptr);
905  RNA_property_pointer_set(&ptr, prop, idptr, NULL);
906  RNA_property_update(C, &ptr, prop);
907  }
908 
910 
911  return OPERATOR_FINISHED;
912 }
913 
915 {
916  /* identifiers */
917  ot->name = "New World";
918  ot->idname = "WORLD_OT_new";
919  ot->description = "Create a new world Data-Block";
920 
921  /* api callbacks */
923 
924  /* flags */
926 }
927 
930 /* -------------------------------------------------------------------- */
935 {
936  wmWindow *win = CTX_wm_window(C);
938  ViewLayer *view_layer_current = WM_window_get_active_view_layer(win);
939  ViewLayer *view_layer_new = BKE_view_layer_add(
940  scene, view_layer_current->name, view_layer_current, RNA_enum_get(op->ptr, "type"));
941 
942  if (win) {
943  WM_window_set_active_view_layer(win, view_layer_new);
944  }
945 
946  DEG_id_tag_update(&scene->id, 0);
949 
950  return OPERATOR_FINISHED;
951 }
952 
954 {
955  static EnumPropertyItem type_items[] = {
956  {VIEWLAYER_ADD_NEW, "NEW", 0, "New", "Add a new view layer"},
957  {VIEWLAYER_ADD_COPY, "COPY", 0, "Copy Settings", "Copy settings of current view layer"},
959  "EMPTY",
960  0,
961  "Blank",
962  "Add a new view layer with all collections disabled"},
963  {0, NULL, 0, NULL, NULL},
964  };
965 
966  /* identifiers */
967  ot->name = "Add View Layer";
968  ot->idname = "SCENE_OT_view_layer_add";
969  ot->description = "Add a view layer";
970 
971  /* api callbacks */
974 
975  /* flags */
977 
978  /* properties */
979  ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
980 }
981 
984 /* -------------------------------------------------------------------- */
989 {
992 }
993 
995 {
996  Main *bmain = CTX_data_main(C);
998  ViewLayer *view_layer = CTX_data_view_layer(C);
999 
1000  if (!ED_scene_view_layer_delete(bmain, scene, view_layer, NULL)) {
1001  return OPERATOR_CANCELLED;
1002  }
1003 
1005 
1006  return OPERATOR_FINISHED;
1007 }
1008 
1010 {
1011  /* identifiers */
1012  ot->name = "Remove View Layer";
1013  ot->idname = "SCENE_OT_view_layer_remove";
1014  ot->description = "Remove the selected view layer";
1015 
1016  /* api callbacks */
1019 
1020  /* flags */
1022 }
1023 
1026 /* -------------------------------------------------------------------- */
1031 {
1033  ViewLayer *view_layer = CTX_data_view_layer(C);
1034 
1035  BKE_view_layer_add_aov(view_layer);
1036 
1037  RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
1038  if (engine_type->update_render_passes) {
1039  RenderEngine *engine = RE_engine_create(engine_type);
1040  if (engine) {
1041  BKE_view_layer_verify_aov(engine, scene, view_layer);
1042  }
1043  RE_engine_free(engine);
1044  engine = NULL;
1045  }
1046 
1047  if (scene->nodetree) {
1049  }
1050 
1051  DEG_id_tag_update(&scene->id, 0);
1054 
1055  return OPERATOR_FINISHED;
1056 }
1057 
1059 {
1060  /* identifiers */
1061  ot->name = "Add AOV";
1062  ot->idname = "SCENE_OT_view_layer_add_aov";
1063  ot->description = "Add a Shader AOV";
1064 
1065  /* api callbacks */
1067 
1068  /* flags */
1070 }
1071 
1074 /* -------------------------------------------------------------------- */
1079 {
1081  ViewLayer *view_layer = CTX_data_view_layer(C);
1082 
1083  if (view_layer->active_aov == NULL) {
1084  return OPERATOR_FINISHED;
1085  }
1086 
1087  BKE_view_layer_remove_aov(view_layer, view_layer->active_aov);
1088 
1089  RenderEngineType *engine_type = RE_engines_find(scene->r.engine);
1090  if (engine_type->update_render_passes) {
1091  RenderEngine *engine = RE_engine_create(engine_type);
1092  if (engine) {
1093  BKE_view_layer_verify_aov(engine, scene, view_layer);
1094  }
1095  RE_engine_free(engine);
1096  engine = NULL;
1097  }
1098 
1099  if (scene->nodetree) {
1101  }
1102 
1103  DEG_id_tag_update(&scene->id, 0);
1106 
1107  return OPERATOR_FINISHED;
1108 }
1109 
1111 {
1112  /* identifiers */
1113  ot->name = "Remove AOV";
1114  ot->idname = "SCENE_OT_view_layer_remove_aov";
1115  ot->description = "Remove Active AOV";
1116 
1117  /* api callbacks */
1119 
1120  /* flags */
1122 }
1123 
1126 /* -------------------------------------------------------------------- */
1130 enum {
1134 };
1135 
1137 {
1138  if (scene->eevee.light_cache_data != NULL) {
1139  int subset = RNA_enum_get(op->ptr, "subset");
1140  switch (subset) {
1141  case LIGHTCACHE_SUBSET_ALL:
1143  break;
1146  break;
1148  /* Leave tag untouched. */
1149  break;
1150  }
1151  }
1152 }
1153 
1154 /* catch esc */
1155 static int light_cache_bake_modal(bContext *C, wmOperator *op, const wmEvent *event)
1156 {
1157  Scene *scene = (Scene *)op->customdata;
1158 
1159  /* no running blender, remove handler and pass through */
1162  if (lcache && (lcache->flag & LIGHTCACHE_INVALID)) {
1163  BKE_report(op->reports, RPT_ERROR, "Lightcache cannot allocate resources");
1164  return OPERATOR_CANCELLED;
1165  }
1167  }
1168 
1169  /* running render */
1170  switch (event->type) {
1171  case EVT_ESCKEY:
1172  return OPERATOR_RUNNING_MODAL;
1173  }
1174  return OPERATOR_PASS_THROUGH;
1175 }
1176 
1178 {
1180  Scene *scene = (Scene *)op->customdata;
1181 
1182  /* kill on cancel, because job is using op->reports */
1184 }
1185 
1186 /* executes blocking render */
1188 {
1189  ViewLayer *view_layer = CTX_data_view_layer(C);
1190  Main *bmain = CTX_data_main(C);
1192 
1193  G.is_break = false;
1194 
1195  /* TODO abort if selected engine is not eevee. */
1196  void *rj = EEVEE_lightbake_job_data_alloc(bmain, view_layer, scene, false, scene->r.cfra);
1197 
1199 
1200  short stop = 0, do_update;
1201  float progress; /* Not actually used. */
1202  EEVEE_lightbake_job(rj, &stop, &do_update, &progress);
1204 
1205  /* No redraw needed, we leave state as we entered it. */
1207 
1209 
1210  return OPERATOR_FINISHED;
1211 }
1212 
1213 static int light_cache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
1214 {
1216  wmWindow *win = CTX_wm_window(C);
1217  ViewLayer *view_layer = CTX_data_view_layer(C);
1218  Main *bmain = CTX_data_main(C);
1220  int delay = RNA_int_get(op->ptr, "delay");
1221 
1223  wm, win, bmain, view_layer, scene, delay, scene->r.cfra);
1224 
1225  if (!wm_job) {
1226  return OPERATOR_CANCELLED;
1227  }
1228 
1229  /* add modal handler for ESC */
1231 
1233 
1234  /* store actual owner of job, so modal operator could check for it,
1235  * the reason of this is that active scene could change when rendering
1236  * several layers from compositor T31800. */
1237  op->customdata = scene;
1238 
1239  WM_jobs_start(wm, wm_job);
1240 
1241  WM_cursor_wait(false);
1242 
1243  return OPERATOR_RUNNING_MODAL;
1244 }
1245 
1247 {
1248  static const EnumPropertyItem light_cache_subset_items[] = {
1250  "ALL",
1251  0,
1252  "All Light Probes",
1253  "Bake both irradiance grids and reflection cubemaps"},
1255  "DIRTY",
1256  0,
1257  "Dirty Only",
1258  "Only bake light probes that are marked as dirty"},
1260  "CUBEMAPS",
1261  0,
1262  "Cubemaps Only",
1263  "Try to only bake reflection cubemaps if irradiance grids are up to date"},
1264  {0, NULL, 0, NULL, NULL},
1265  };
1266 
1267  /* identifiers */
1268  ot->name = "Bake Light Cache";
1269  ot->idname = "SCENE_OT_light_cache_bake";
1270  ot->description = "Bake the active view layer lighting";
1271 
1272  /* api callbacks */
1277 
1278  ot->prop = RNA_def_int(ot->srna,
1279  "delay",
1280  0,
1281  0,
1282  2000,
1283  "Delay",
1284  "Delay in millisecond before baking starts",
1285  0,
1286  2000);
1288 
1289  ot->prop = RNA_def_enum(
1290  ot->srna, "subset", light_cache_subset_items, 0, "Subset", "Subset of probes to update");
1292 }
1293 
1296 /* -------------------------------------------------------------------- */
1301 {
1303 
1304  return scene->eevee.light_cache_data;
1305 }
1306 
1308 {
1310 
1311  /* kill potential bake job first (see T57011) */
1314 
1315  if (!scene->eevee.light_cache_data) {
1316  return OPERATOR_CANCELLED;
1317  }
1318 
1321 
1323 
1325 
1327 
1328  return OPERATOR_FINISHED;
1329 }
1330 
1332 {
1333  /* identifiers */
1334  ot->name = "Delete Light Cache";
1335  ot->idname = "SCENE_OT_light_cache_free";
1336  ot->description = "Delete cached indirect lighting";
1337 
1338  /* api callbacks */
1341 }
1342 
1345 /* -------------------------------------------------------------------- */
1350 {
1352 
1353  /* don't allow user to remove "left" and "right" views */
1354  return scene->r.actview > 1;
1355 }
1356 
1358 {
1360 
1363 
1365 
1366  return OPERATOR_FINISHED;
1367 }
1368 
1370 {
1371  /* identifiers */
1372  ot->name = "Add Render View";
1373  ot->idname = "SCENE_OT_render_view_add";
1374  ot->description = "Add a render view";
1375 
1376  /* api callbacks */
1378 
1379  /* flags */
1381 }
1382 
1385 /* -------------------------------------------------------------------- */
1390 {
1393 
1394  if (!BKE_scene_remove_render_view(scene, rv)) {
1395  return OPERATOR_CANCELLED;
1396  }
1397 
1399 
1400  return OPERATOR_FINISHED;
1401 }
1402 
1404 {
1405  /* identifiers */
1406  ot->name = "Remove Render View";
1407  ot->idname = "SCENE_OT_render_view_remove";
1408  ot->description = "Remove the selected render view";
1409 
1410  /* api callbacks */
1413 
1414  /* flags */
1416 }
1417 
1420 #ifdef WITH_FREESTYLE
1421 
1422 /* -------------------------------------------------------------------- */
1426 static bool freestyle_linestyle_check_report(FreestyleLineSet *lineset, ReportList *reports)
1427 {
1428  if (!lineset) {
1429  BKE_report(reports,
1430  RPT_ERROR,
1431  "No active lineset and associated line style to manipulate the modifier");
1432  return false;
1433  }
1434  if (!lineset->linestyle) {
1435  BKE_report(reports,
1436  RPT_ERROR,
1437  "The active lineset does not have a line style (indicating data corruption)");
1438  return false;
1439  }
1440 
1441  return true;
1442 }
1443 
1444 static bool freestyle_active_module_poll(bContext *C)
1445 {
1448 
1449  return module != NULL;
1450 }
1451 
1452 static int freestyle_module_add_exec(bContext *C, wmOperator *UNUSED(op))
1453 {
1455  ViewLayer *view_layer = CTX_data_view_layer(C);
1456 
1458 
1460 
1461  return OPERATOR_FINISHED;
1462 }
1463 
1464 void SCENE_OT_freestyle_module_add(wmOperatorType *ot)
1465 {
1466  /* identifiers */
1467  ot->name = "Add Freestyle Module";
1468  ot->idname = "SCENE_OT_freestyle_module_add";
1469  ot->description = "Add a style module into the list of modules";
1470 
1471  /* api callbacks */
1472  ot->exec = freestyle_module_add_exec;
1473 
1474  /* flags */
1476 }
1477 
1480 /* -------------------------------------------------------------------- */
1484 static int freestyle_module_remove_exec(bContext *C, wmOperator *UNUSED(op))
1485 {
1487  ViewLayer *view_layer = CTX_data_view_layer(C);
1490 
1492 
1493  DEG_id_tag_update(&scene->id, 0);
1495 
1496  return OPERATOR_FINISHED;
1497 }
1498 
1499 void SCENE_OT_freestyle_module_remove(wmOperatorType *ot)
1500 {
1501  /* identifiers */
1502  ot->name = "Remove Freestyle Module";
1503  ot->idname = "SCENE_OT_freestyle_module_remove";
1504  ot->description = "Remove the style module from the stack";
1505 
1506  /* api callbacks */
1507  ot->poll = freestyle_active_module_poll;
1508  ot->exec = freestyle_module_remove_exec;
1509 
1510  /* flags */
1512 }
1513 
1514 static int freestyle_module_move_exec(bContext *C, wmOperator *op)
1515 {
1517  ViewLayer *view_layer = CTX_data_view_layer(C);
1520  int dir = RNA_enum_get(op->ptr, "direction");
1521 
1522  if (BKE_freestyle_module_move(&view_layer->freestyle_config, module, dir)) {
1523  DEG_id_tag_update(&scene->id, 0);
1525  }
1526 
1527  return OPERATOR_FINISHED;
1528 }
1529 
1532 /* -------------------------------------------------------------------- */
1536 void SCENE_OT_freestyle_module_move(wmOperatorType *ot)
1537 {
1538  static const EnumPropertyItem direction_items[] = {
1539  {-1, "UP", 0, "Up", ""},
1540  {1, "DOWN", 0, "Down", ""},
1541  {0, NULL, 0, NULL, NULL},
1542  };
1543 
1544  /* identifiers */
1545  ot->name = "Move Freestyle Module";
1546  ot->idname = "SCENE_OT_freestyle_module_move";
1547  ot->description = "Change the position of the style module within in the list of style modules";
1548 
1549  /* api callbacks */
1550  ot->poll = freestyle_active_module_poll;
1551  ot->exec = freestyle_module_move_exec;
1552 
1553  /* flags */
1555 
1556  /* props */
1557  RNA_def_enum(ot->srna,
1558  "direction",
1559  direction_items,
1560  0,
1561  "Direction",
1562  "Direction to move the chosen style module towards");
1563 }
1564 
1567 /* -------------------------------------------------------------------- */
1571 static int freestyle_lineset_add_exec(bContext *C, wmOperator *UNUSED(op))
1572 {
1573  Main *bmain = CTX_data_main(C);
1575  ViewLayer *view_layer = CTX_data_view_layer(C);
1576 
1577  BKE_freestyle_lineset_add(bmain, &view_layer->freestyle_config, NULL);
1578 
1579  DEG_id_tag_update(&scene->id, 0);
1581 
1582  return OPERATOR_FINISHED;
1583 }
1584 
1585 void SCENE_OT_freestyle_lineset_add(wmOperatorType *ot)
1586 {
1587  /* identifiers */
1588  ot->name = "Add Line Set";
1589  ot->idname = "SCENE_OT_freestyle_lineset_add";
1590  ot->description = "Add a line set into the list of line sets";
1591 
1592  /* api callbacks */
1593  ot->exec = freestyle_lineset_add_exec;
1594 
1595  /* flags */
1597 }
1598 
1601 /* -------------------------------------------------------------------- */
1605 static bool freestyle_active_lineset_poll(bContext *C)
1606 {
1607  ViewLayer *view_layer = CTX_data_view_layer(C);
1608 
1609  if (!view_layer) {
1610  return false;
1611  }
1612 
1613  return BKE_freestyle_lineset_get_active(&view_layer->freestyle_config) != NULL;
1614 }
1615 
1616 static int freestyle_lineset_copy_exec(bContext *C, wmOperator *UNUSED(op))
1617 {
1618  ViewLayer *view_layer = CTX_data_view_layer(C);
1619 
1621 
1622  return OPERATOR_FINISHED;
1623 }
1624 
1625 void SCENE_OT_freestyle_lineset_copy(wmOperatorType *ot)
1626 {
1627  /* identifiers */
1628  ot->name = "Copy Line Set";
1629  ot->idname = "SCENE_OT_freestyle_lineset_copy";
1630  ot->description = "Copy the active line set to a buffer";
1631 
1632  /* api callbacks */
1633  ot->exec = freestyle_lineset_copy_exec;
1634  ot->poll = freestyle_active_lineset_poll;
1635 
1636  /* flags */
1638 }
1639 
1642 /* -------------------------------------------------------------------- */
1646 static int freestyle_lineset_paste_exec(bContext *C, wmOperator *UNUSED(op))
1647 {
1649  ViewLayer *view_layer = CTX_data_view_layer(C);
1650 
1652 
1653  DEG_id_tag_update(&scene->id, 0);
1655 
1656  return OPERATOR_FINISHED;
1657 }
1658 
1659 void SCENE_OT_freestyle_lineset_paste(wmOperatorType *ot)
1660 {
1661  /* identifiers */
1662  ot->name = "Paste Line Set";
1663  ot->idname = "SCENE_OT_freestyle_lineset_paste";
1664  ot->description = "Paste the buffer content to the active line set";
1665 
1666  /* api callbacks */
1667  ot->exec = freestyle_lineset_paste_exec;
1668  ot->poll = freestyle_active_lineset_poll;
1669 
1670  /* flags */
1672 }
1673 
1676 /* -------------------------------------------------------------------- */
1680 static int freestyle_lineset_remove_exec(bContext *C, wmOperator *UNUSED(op))
1681 {
1683  ViewLayer *view_layer = CTX_data_view_layer(C);
1684 
1686 
1687  DEG_id_tag_update(&scene->id, 0);
1689 
1690  return OPERATOR_FINISHED;
1691 }
1692 
1693 void SCENE_OT_freestyle_lineset_remove(wmOperatorType *ot)
1694 {
1695  /* identifiers */
1696  ot->name = "Remove Line Set";
1697  ot->idname = "SCENE_OT_freestyle_lineset_remove";
1698  ot->description = "Remove the active line set from the list of line sets";
1699 
1700  /* api callbacks */
1701  ot->exec = freestyle_lineset_remove_exec;
1702  ot->poll = freestyle_active_lineset_poll;
1703 
1704  /* flags */
1706 }
1707 
1710 /* -------------------------------------------------------------------- */
1714 static int freestyle_lineset_move_exec(bContext *C, wmOperator *op)
1715 {
1717  ViewLayer *view_layer = CTX_data_view_layer(C);
1718  int dir = RNA_enum_get(op->ptr, "direction");
1719 
1720  if (FRS_move_active_lineset(&view_layer->freestyle_config, dir)) {
1721  DEG_id_tag_update(&scene->id, 0);
1723  }
1724 
1725  return OPERATOR_FINISHED;
1726 }
1727 
1728 void SCENE_OT_freestyle_lineset_move(wmOperatorType *ot)
1729 {
1730  static const EnumPropertyItem direction_items[] = {
1731  {-1, "UP", 0, "Up", ""},
1732  {1, "DOWN", 0, "Down", ""},
1733  {0, NULL, 0, NULL, NULL},
1734  };
1735 
1736  /* identifiers */
1737  ot->name = "Move Line Set";
1738  ot->idname = "SCENE_OT_freestyle_lineset_move";
1739  ot->description = "Change the position of the active line set within the list of line sets";
1740 
1741  /* api callbacks */
1742  ot->exec = freestyle_lineset_move_exec;
1743  ot->poll = freestyle_active_lineset_poll;
1744 
1745  /* flags */
1747 
1748  /* props */
1749  RNA_def_enum(ot->srna,
1750  "direction",
1751  direction_items,
1752  0,
1753  "Direction",
1754  "Direction to move the active line set towards");
1755 }
1756 
1759 /* -------------------------------------------------------------------- */
1763 static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op)
1764 {
1765  Main *bmain = CTX_data_main(C);
1766  ViewLayer *view_layer = CTX_data_view_layer(C);
1768 
1769  if (!lineset) {
1770  BKE_report(op->reports, RPT_ERROR, "No active lineset to add a new line style to");
1771  return OPERATOR_CANCELLED;
1772  }
1773  if (lineset->linestyle) {
1774  id_us_min(&lineset->linestyle->id);
1775  lineset->linestyle = (FreestyleLineStyle *)BKE_id_copy(bmain, &lineset->linestyle->id);
1776  }
1777  else {
1778  lineset->linestyle = BKE_linestyle_new(bmain, "LineStyle");
1779  }
1780  DEG_id_tag_update(&lineset->linestyle->id, 0);
1782 
1783  return OPERATOR_FINISHED;
1784 }
1785 
1786 void SCENE_OT_freestyle_linestyle_new(wmOperatorType *ot)
1787 {
1788  /* identifiers */
1789  ot->name = "New Line Style";
1790  ot->idname = "SCENE_OT_freestyle_linestyle_new";
1791  ot->description = "Create a new line style, reusable by multiple line sets";
1792 
1793  /* api callbacks */
1794  ot->exec = freestyle_linestyle_new_exec;
1795  ot->poll = freestyle_active_lineset_poll;
1796 
1797  /* flags */
1799 }
1800 
1803 /* -------------------------------------------------------------------- */
1807 static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op)
1808 {
1809  ViewLayer *view_layer = CTX_data_view_layer(C);
1811  int type = RNA_enum_get(op->ptr, "type");
1812 
1813  if (!freestyle_linestyle_check_report(lineset, op->reports)) {
1814  return OPERATOR_CANCELLED;
1815  }
1816 
1818  BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type");
1819  return OPERATOR_CANCELLED;
1820  }
1821  DEG_id_tag_update(&lineset->linestyle->id, 0);
1823 
1824  return OPERATOR_FINISHED;
1825 }
1826 
1827 void SCENE_OT_freestyle_color_modifier_add(wmOperatorType *ot)
1828 {
1829  /* identifiers */
1830  ot->name = "Add Line Color Modifier";
1831  ot->idname = "SCENE_OT_freestyle_color_modifier_add";
1832  ot->description =
1833  "Add a line color modifier to the line style associated with the active lineset";
1834 
1835  /* api callbacks */
1837  ot->exec = freestyle_color_modifier_add_exec;
1838  ot->poll = freestyle_active_lineset_poll;
1839 
1840  /* flags */
1842 
1843  /* properties */
1844  ot->prop = RNA_def_enum(
1845  ot->srna, "type", rna_enum_linestyle_color_modifier_type_items, 0, "Type", "");
1846 }
1847 
1850 /* -------------------------------------------------------------------- */
1854 static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op)
1855 {
1856  ViewLayer *view_layer = CTX_data_view_layer(C);
1858  int type = RNA_enum_get(op->ptr, "type");
1859 
1860  if (!freestyle_linestyle_check_report(lineset, op->reports)) {
1861  return OPERATOR_CANCELLED;
1862  }
1863 
1865  BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type");
1866  return OPERATOR_CANCELLED;
1867  }
1868  DEG_id_tag_update(&lineset->linestyle->id, 0);
1870 
1871  return OPERATOR_FINISHED;
1872 }
1873 
1874 void SCENE_OT_freestyle_alpha_modifier_add(wmOperatorType *ot)
1875 {
1876  /* identifiers */
1877  ot->name = "Add Alpha Transparency Modifier";
1878  ot->idname = "SCENE_OT_freestyle_alpha_modifier_add";
1879  ot->description =
1880  "Add an alpha transparency modifier to the line style associated with the active lineset";
1881 
1882  /* api callbacks */
1884  ot->exec = freestyle_alpha_modifier_add_exec;
1885  ot->poll = freestyle_active_lineset_poll;
1886 
1887  /* flags */
1889 
1890  /* properties */
1891  ot->prop = RNA_def_enum(
1892  ot->srna, "type", rna_enum_linestyle_alpha_modifier_type_items, 0, "Type", "");
1893 }
1894 
1897 /* -------------------------------------------------------------------- */
1901 static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op)
1902 {
1903  ViewLayer *view_layer = CTX_data_view_layer(C);
1905  int type = RNA_enum_get(op->ptr, "type");
1906 
1907  if (!freestyle_linestyle_check_report(lineset, op->reports)) {
1908  return OPERATOR_CANCELLED;
1909  }
1910 
1912  BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type");
1913  return OPERATOR_CANCELLED;
1914  }
1915  DEG_id_tag_update(&lineset->linestyle->id, 0);
1917 
1918  return OPERATOR_FINISHED;
1919 }
1920 
1921 void SCENE_OT_freestyle_thickness_modifier_add(wmOperatorType *ot)
1922 {
1923  /* identifiers */
1924  ot->name = "Add Line Thickness Modifier";
1925  ot->idname = "SCENE_OT_freestyle_thickness_modifier_add";
1926  ot->description =
1927  "Add a line thickness modifier to the line style associated with the active lineset";
1928 
1929  /* api callbacks */
1931  ot->exec = freestyle_thickness_modifier_add_exec;
1932  ot->poll = freestyle_active_lineset_poll;
1933 
1934  /* flags */
1936 
1937  /* properties */
1938  ot->prop = RNA_def_enum(
1939  ot->srna, "type", rna_enum_linestyle_thickness_modifier_type_items, 0, "Type", "");
1940 }
1941 
1944 /* -------------------------------------------------------------------- */
1948 static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op)
1949 {
1950  ViewLayer *view_layer = CTX_data_view_layer(C);
1952  int type = RNA_enum_get(op->ptr, "type");
1953 
1954  if (!freestyle_linestyle_check_report(lineset, op->reports)) {
1955  return OPERATOR_CANCELLED;
1956  }
1957 
1959  BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type");
1960  return OPERATOR_CANCELLED;
1961  }
1962  DEG_id_tag_update(&lineset->linestyle->id, 0);
1964 
1965  return OPERATOR_FINISHED;
1966 }
1967 
1968 void SCENE_OT_freestyle_geometry_modifier_add(wmOperatorType *ot)
1969 {
1970  /* identifiers */
1971  ot->name = "Add Stroke Geometry Modifier";
1972  ot->idname = "SCENE_OT_freestyle_geometry_modifier_add";
1973  ot->description =
1974  "Add a stroke geometry modifier to the line style associated with the active lineset";
1975 
1976  /* api callbacks */
1978  ot->exec = freestyle_geometry_modifier_add_exec;
1979  ot->poll = freestyle_active_lineset_poll;
1980 
1981  /* flags */
1983 
1984  /* properties */
1985  ot->prop = RNA_def_enum(
1986  ot->srna, "type", rna_enum_linestyle_geometry_modifier_type_items, 0, "Type", "");
1987 }
1988 
1991 /* -------------------------------------------------------------------- */
1995 static int freestyle_get_modifier_type(PointerRNA *ptr)
1996 {
1998  return LS_MODIFIER_TYPE_COLOR;
1999  }
2001  return LS_MODIFIER_TYPE_ALPHA;
2002  }
2005  }
2008  }
2009  return -1;
2010 }
2011 
2012 static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op)
2013 {
2014  ViewLayer *view_layer = CTX_data_view_layer(C);
2017  LineStyleModifier *modifier = ptr.data;
2018 
2019  if (!freestyle_linestyle_check_report(lineset, op->reports)) {
2020  return OPERATOR_CANCELLED;
2021  }
2022 
2023  switch (freestyle_get_modifier_type(&ptr)) {
2025  BKE_linestyle_color_modifier_remove(lineset->linestyle, modifier);
2026  break;
2028  BKE_linestyle_alpha_modifier_remove(lineset->linestyle, modifier);
2029  break;
2032  break;
2035  break;
2036  default:
2037  BKE_report(
2038  op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier");
2039  return OPERATOR_CANCELLED;
2040  }
2041  DEG_id_tag_update(&lineset->linestyle->id, 0);
2043 
2044  return OPERATOR_FINISHED;
2045 }
2046 
2047 void SCENE_OT_freestyle_modifier_remove(wmOperatorType *ot)
2048 {
2049  /* identifiers */
2050  ot->name = "Remove Modifier";
2051  ot->idname = "SCENE_OT_freestyle_modifier_remove";
2052  ot->description = "Remove the modifier from the list of modifiers";
2053 
2054  /* api callbacks */
2055  ot->exec = freestyle_modifier_remove_exec;
2056  ot->poll = freestyle_active_lineset_poll;
2057 
2058  /* flags */
2060 }
2061 
2064 /* -------------------------------------------------------------------- */
2068 static int freestyle_modifier_copy_exec(bContext *C, wmOperator *op)
2069 {
2070  ViewLayer *view_layer = CTX_data_view_layer(C);
2073  LineStyleModifier *modifier = ptr.data;
2074 
2075  if (!freestyle_linestyle_check_report(lineset, op->reports)) {
2076  return OPERATOR_CANCELLED;
2077  }
2078 
2079  switch (freestyle_get_modifier_type(&ptr)) {
2081  BKE_linestyle_color_modifier_copy(lineset->linestyle, modifier, 0);
2082  break;
2084  BKE_linestyle_alpha_modifier_copy(lineset->linestyle, modifier, 0);
2085  break;
2087  BKE_linestyle_thickness_modifier_copy(lineset->linestyle, modifier, 0);
2088  break;
2090  BKE_linestyle_geometry_modifier_copy(lineset->linestyle, modifier, 0);
2091  break;
2092  default:
2093  BKE_report(
2094  op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier");
2095  return OPERATOR_CANCELLED;
2096  }
2097  DEG_id_tag_update(&lineset->linestyle->id, 0);
2099 
2100  return OPERATOR_FINISHED;
2101 }
2102 
2103 void SCENE_OT_freestyle_modifier_copy(wmOperatorType *ot)
2104 {
2105  /* identifiers */
2106  ot->name = "Copy Modifier";
2107  ot->idname = "SCENE_OT_freestyle_modifier_copy";
2108  ot->description = "Duplicate the modifier within the list of modifiers";
2109 
2110  /* api callbacks */
2111  ot->exec = freestyle_modifier_copy_exec;
2112  ot->poll = freestyle_active_lineset_poll;
2113 
2114  /* flags */
2116 }
2117 
2120 /* -------------------------------------------------------------------- */
2124 static int freestyle_modifier_move_exec(bContext *C, wmOperator *op)
2125 {
2126  ViewLayer *view_layer = CTX_data_view_layer(C);
2129  LineStyleModifier *modifier = ptr.data;
2130  int dir = RNA_enum_get(op->ptr, "direction");
2131  bool changed = false;
2132 
2133  if (!freestyle_linestyle_check_report(lineset, op->reports)) {
2134  return OPERATOR_CANCELLED;
2135  }
2136 
2137  switch (freestyle_get_modifier_type(&ptr)) {
2139  changed = BKE_linestyle_color_modifier_move(lineset->linestyle, modifier, dir);
2140  break;
2142  changed = BKE_linestyle_alpha_modifier_move(lineset->linestyle, modifier, dir);
2143  break;
2145  changed = BKE_linestyle_thickness_modifier_move(lineset->linestyle, modifier, dir);
2146  break;
2148  changed = BKE_linestyle_geometry_modifier_move(lineset->linestyle, modifier, dir);
2149  break;
2150  default:
2151  BKE_report(
2152  op->reports, RPT_ERROR, "The object the data pointer refers to is not a valid modifier");
2153  return OPERATOR_CANCELLED;
2154  }
2155 
2156  if (changed) {
2157  DEG_id_tag_update(&lineset->linestyle->id, 0);
2159  }
2160 
2161  return OPERATOR_FINISHED;
2162 }
2163 
2164 void SCENE_OT_freestyle_modifier_move(wmOperatorType *ot)
2165 {
2166  static const EnumPropertyItem direction_items[] = {
2167  {-1, "UP", 0, "Up", ""},
2168  {1, "DOWN", 0, "Down", ""},
2169  {0, NULL, 0, NULL, NULL},
2170  };
2171 
2172  /* identifiers */
2173  ot->name = "Move Modifier";
2174  ot->idname = "SCENE_OT_freestyle_modifier_move";
2175  ot->description = "Move the modifier within the list of modifiers";
2176 
2177  /* api callbacks */
2178  ot->exec = freestyle_modifier_move_exec;
2179  ot->poll = freestyle_active_lineset_poll;
2180 
2181  /* flags */
2183 
2184  /* props */
2185  RNA_def_enum(ot->srna,
2186  "direction",
2187  direction_items,
2188  0,
2189  "Direction",
2190  "Direction to move the chosen modifier towards");
2191 }
2192 
2195 /* -------------------------------------------------------------------- */
2199 static int freestyle_stroke_material_create_exec(bContext *C, wmOperator *op)
2200 {
2201  Main *bmain = CTX_data_main(C);
2202  ViewLayer *view_layer = CTX_data_view_layer(C);
2204 
2205  if (!linestyle) {
2206  BKE_report(op->reports, RPT_ERROR, "No active line style in the current scene");
2207  return OPERATOR_CANCELLED;
2208  }
2209 
2211 
2212  return OPERATOR_FINISHED;
2213 }
2214 
2215 void SCENE_OT_freestyle_stroke_material_create(wmOperatorType *ot)
2216 {
2217  /* identifiers */
2218  ot->name = "Create Freestyle Stroke Material";
2219  ot->idname = "SCENE_OT_freestyle_stroke_material_create";
2220  ot->description = "Create Freestyle stroke material for testing";
2221 
2222  /* api callbacks */
2223  ot->exec = freestyle_stroke_material_create_exec;
2224 
2225  /* flags */
2227 }
2228 
2229 #endif /* WITH_FREESTYLE */
2230 
2233 /* -------------------------------------------------------------------- */
2238 {
2239  ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).owner_id;
2240 
2241  if (id) {
2242  MTex **mtex_ar, *mtexswap;
2243  short act;
2244  int type = RNA_enum_get(op->ptr, "type");
2245  struct AnimData *adt = BKE_animdata_from_id(id);
2246 
2247  give_active_mtex(id, &mtex_ar, &act);
2248 
2249  if (type == -1) { /* Up */
2250  if (act > 0) {
2251  mtexswap = mtex_ar[act];
2252  mtex_ar[act] = mtex_ar[act - 1];
2253  mtex_ar[act - 1] = mtexswap;
2254 
2255  BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act - 1, -1, 0);
2256  BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act - 1, 0);
2257  BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
2258 
2259  set_active_mtex(id, act - 1);
2260  }
2261  }
2262  else { /* Down */
2263  if (act < MAX_MTEX - 1) {
2264  mtexswap = mtex_ar[act];
2265  mtex_ar[act] = mtex_ar[act + 1];
2266  mtex_ar[act + 1] = mtexswap;
2267 
2268  BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act + 1, -1, 0);
2269  BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, act, act + 1, 0);
2270  BKE_animdata_fix_paths_rename(id, adt, NULL, "texture_slots", NULL, NULL, -1, act, 0);
2271 
2272  set_active_mtex(id, act + 1);
2273  }
2274  }
2275 
2276  DEG_id_tag_update(id, 0);
2278  }
2279 
2280  return OPERATOR_FINISHED;
2281 }
2282 
2284 {
2285  static const EnumPropertyItem slot_move[] = {
2286  {-1, "UP", 0, "Up", ""},
2287  {1, "DOWN", 0, "Down", ""},
2288  {0, NULL, 0, NULL, NULL},
2289  };
2290 
2291  /* identifiers */
2292  ot->name = "Move Texture Slot";
2293  ot->idname = "TEXTURE_OT_slot_move";
2294  ot->description = "Move texture slots up and down";
2295 
2296  /* api callbacks */
2298 
2299  /* flags */
2301 
2302  RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", "");
2303 }
2304 
2307 /* -------------------------------------------------------------------- */
2311 /* material copy/paste */
2313 {
2314  Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
2315 
2316  if (ma == NULL) {
2317  return OPERATOR_CANCELLED;
2318  }
2319 
2321 
2322  return OPERATOR_FINISHED;
2323 }
2324 
2326 {
2327  /* identifiers */
2328  ot->name = "Copy Material";
2329  ot->idname = "MATERIAL_OT_copy";
2330  ot->description = "Copy the material settings and nodes";
2331 
2332  /* api callbacks */
2334 
2335  /* flags */
2336  /* no undo needed since no changes are made to the material */
2338 }
2339 
2342 /* -------------------------------------------------------------------- */
2347 {
2348  Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
2349 
2350  if (ma == NULL) {
2351  return OPERATOR_CANCELLED;
2352  }
2353 
2355 
2358 
2359  return OPERATOR_FINISHED;
2360 }
2361 
2363 {
2364  /* identifiers */
2365  ot->name = "Paste Material";
2366  ot->idname = "MATERIAL_OT_paste";
2367  ot->description = "Paste the material settings and nodes";
2368 
2369  /* api callbacks */
2371 
2372  /* flags */
2374 }
2375 
2378 /* -------------------------------------------------------------------- */
2382 static short mtexcopied = 0; /* must be reset on file load */
2384 
2386 { /* use for file reload */
2387  mtexcopied = 0;
2388 }
2389 
2390 static void copy_mtex_copybuf(ID *id)
2391 {
2392  MTex **mtex = NULL;
2393 
2394  switch (GS(id->name)) {
2395  case ID_PA:
2396  mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
2397  break;
2398  case ID_LS:
2399  mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
2400  break;
2401  default:
2402  break;
2403  }
2404 
2405  if (mtex && *mtex) {
2406  memcpy(&mtexcopybuf, *mtex, sizeof(MTex));
2407  mtexcopied = 1;
2408  }
2409  else {
2410  mtexcopied = 0;
2411  }
2412 }
2413 
2414 static void paste_mtex_copybuf(ID *id)
2415 {
2416  MTex **mtex = NULL;
2417 
2418  if (mtexcopied == 0 || mtexcopybuf.tex == NULL) {
2419  return;
2420  }
2421 
2422  switch (GS(id->name)) {
2423  case ID_PA:
2424  mtex = &(((ParticleSettings *)id)->mtex[(int)((ParticleSettings *)id)->texact]);
2425  break;
2426  case ID_LS:
2427  mtex = &(((FreestyleLineStyle *)id)->mtex[(int)((FreestyleLineStyle *)id)->texact]);
2428  break;
2429  default:
2430  BLI_assert(!"invalid id type");
2431  return;
2432  }
2433 
2434  if (mtex) {
2435  if (*mtex == NULL) {
2436  *mtex = MEM_mallocN(sizeof(MTex), "mtex copy");
2437  }
2438  else if ((*mtex)->tex) {
2439  id_us_min(&(*mtex)->tex->id);
2440  }
2441 
2442  memcpy(*mtex, &mtexcopybuf, sizeof(MTex));
2443 
2445  }
2446 }
2447 
2450 /* -------------------------------------------------------------------- */
2455 {
2456  ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).owner_id;
2457 
2458  if (id == NULL) {
2459  /* copying empty slot */
2461  return OPERATOR_CANCELLED;
2462  }
2463 
2464  copy_mtex_copybuf(id);
2465 
2466  return OPERATOR_FINISHED;
2467 }
2468 
2470 {
2471  ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).owner_id;
2472 
2473  return (id != NULL);
2474 }
2475 
2477 {
2478  /* identifiers */
2479  ot->name = "Copy Texture Slot Settings";
2480  ot->idname = "TEXTURE_OT_slot_copy";
2481  ot->description = "Copy the material texture settings and nodes";
2482 
2483  /* api callbacks */
2484  ot->exec = copy_mtex_exec;
2485  ot->poll = copy_mtex_poll;
2486 
2487  /* flags */
2488  /* no undo needed since no changes are made to the mtex */
2490 }
2491 
2494 /* -------------------------------------------------------------------- */
2499 {
2500  ID *id = CTX_data_pointer_get_type(C, "texture_slot", &RNA_TextureSlot).owner_id;
2501 
2502  if (id == NULL) {
2503  Material *ma = CTX_data_pointer_get_type(C, "material", &RNA_Material).data;
2504  Light *la = CTX_data_pointer_get_type(C, "light", &RNA_Light).data;
2505  World *wo = CTX_data_pointer_get_type(C, "world", &RNA_World).data;
2506  ParticleSystem *psys =
2507  CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem).data;
2510 
2511  if (ma) {
2512  id = &ma->id;
2513  }
2514  else if (la) {
2515  id = &la->id;
2516  }
2517  else if (wo) {
2518  id = &wo->id;
2519  }
2520  else if (psys) {
2521  id = &psys->part->id;
2522  }
2523  else if (linestyle) {
2524  id = &linestyle->id;
2525  }
2526 
2527  if (id == NULL) {
2528  return OPERATOR_CANCELLED;
2529  }
2530  }
2531 
2532  paste_mtex_copybuf(id);
2533 
2535 
2536  return OPERATOR_FINISHED;
2537 }
2538 
2540 {
2541  /* identifiers */
2542  ot->name = "Paste Texture Slot Settings";
2543  ot->idname = "TEXTURE_OT_slot_paste";
2544  ot->description = "Copy the texture settings and nodes";
2545 
2546  /* api callbacks */
2547  ot->exec = paste_mtex_exec;
2548 
2549  /* flags */
2551 }
2552 
struct AnimData * BKE_animdata_from_id(struct ID *id)
Definition: anim_data.c:96
void BKE_animdata_fix_paths_rename(struct ID *owner_id, struct AnimData *adt, struct ID *ref_id, const char *prefix, const char *oldName, const char *newName, int oldSubscript, int newSubscript, bool verify_paths)
Definition: anim_data.c:1079
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
struct Object * CTX_data_edit_object(const bContext *C)
Definition: context.c:1296
struct wmWindowManager * CTX_wm_manager(const bContext *C)
Definition: context.c:689
#define CTX_DATA_BEGIN(C, Type, instance, member)
Definition: BKE_context.h:252
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
Definition: context.c:456
struct ViewLayer * CTX_data_view_layer(const bContext *C)
Definition: context.c:1044
struct Object * CTX_data_active_object(const bContext *C)
Definition: context.c:1279
struct View3D * CTX_wm_view3d(const bContext *C)
Definition: context.c:760
struct Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Definition: context.c:1401
struct Main * CTX_data_main(const bContext *C)
Definition: context.c:1018
#define CTX_DATA_END
Definition: BKE_context.h:260
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
struct ListBase * BKE_curve_editNurbs_get(struct Curve *cu)
Definition: curve.c:437
BMEditMesh * BKE_editmesh_from_object(struct Object *ob)
Return the BMEditMesh for a given object.
Definition: editmesh.c:85
int BKE_vfont_select_get(struct Object *ob, int *r_start, int *r_end)
Definition: font.c:617
struct FreestyleModuleConfig * BKE_freestyle_module_add(struct FreestyleConfig *config)
Definition: freestyle.c:131
struct FreestyleLineSet * BKE_freestyle_lineset_add(struct Main *bmain, struct FreestyleConfig *config, const char *name)
Definition: freestyle.c:182
struct FreestyleLineSet * BKE_freestyle_lineset_get_active(struct FreestyleConfig *config)
Definition: freestyle.c:233
bool BKE_freestyle_module_move(struct FreestyleConfig *config, struct FreestyleModuleConfig *module_conf, int direction)
Definition: freestyle.c:159
bool BKE_freestyle_module_delete(struct FreestyleConfig *config, struct FreestyleModuleConfig *module_conf)
Definition: freestyle.c:146
struct ViewLayer * BKE_view_layer_add(struct Scene *scene, const char *name, struct ViewLayer *view_layer_source, const int type)
Definition: layer.c:200
@ VIEWLAYER_ADD_NEW
Definition: BKE_layer.h:50
@ VIEWLAYER_ADD_EMPTY
Definition: BKE_layer.h:51
@ VIEWLAYER_ADD_COPY
Definition: BKE_layer.h:52
void BKE_view_layer_verify_aov(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer)
Definition: layer.c:2095
struct ViewLayerAOV * BKE_view_layer_add_aov(struct ViewLayer *view_layer)
Definition: layer.c:2034
void BKE_view_layer_remove_aov(struct ViewLayer *view_layer, struct ViewLayerAOV *aov)
Definition: layer.c:2046
struct ID * BKE_id_copy(struct Main *bmain, const struct ID *id)
void id_us_min(struct ID *id)
Definition: lib_id.c:297
@ LIB_ID_COPY_ACTIONS
Definition: BKE_lib_id.h:129
@ LIB_ID_COPY_DEFAULT
Definition: BKE_lib_id.h:139
struct ID * BKE_id_copy_ex(struct Main *bmain, const struct ID *id, struct ID **r_newid, const int flag)
void id_us_plus(struct ID *id)
Definition: lib_id.c:288
Blender kernel freestyle line style functionality.
int BKE_linestyle_alpha_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier)
Definition: linestyle.c:1273
FreestyleLineStyle * BKE_linestyle_active_from_view_layer(struct ViewLayer *view_layer)
Definition: linestyle.c:818
int BKE_linestyle_color_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier)
Definition: linestyle.c:1034
LineStyleModifier * BKE_linestyle_geometry_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type)
Definition: linestyle.c:1650
LineStyleModifier * BKE_linestyle_geometry_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag)
bool BKE_linestyle_thickness_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
Definition: linestyle.c:1928
#define LS_MODIFIER_TYPE_COLOR
Definition: BKE_linestyle.h:33
#define LS_MODIFIER_TYPE_ALPHA
Definition: BKE_linestyle.h:34
LineStyleModifier * BKE_linestyle_color_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag)
Definition: linestyle.c:942
bool BKE_linestyle_color_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
Definition: linestyle.c:1916
LineStyleModifier * BKE_linestyle_thickness_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type)
Definition: linestyle.c:1347
LineStyleModifier * BKE_linestyle_color_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type)
Definition: linestyle.c:884
int BKE_linestyle_thickness_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier)
Definition: linestyle.c:1562
#define LS_MODIFIER_TYPE_GEOMETRY
Definition: BKE_linestyle.h:36
bool BKE_linestyle_alpha_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
Definition: linestyle.c:1922
FreestyleLineStyle * BKE_linestyle_new(struct Main *bmain, const char *name)
Definition: linestyle.c:807
bool BKE_linestyle_geometry_modifier_move(FreestyleLineStyle *linestyle, LineStyleModifier *modifier, int direction)
Definition: linestyle.c:1934
LineStyleModifier * BKE_linestyle_thickness_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag)
Definition: linestyle.c:1441
#define LS_MODIFIER_TYPE_THICKNESS
Definition: BKE_linestyle.h:35
LineStyleModifier * BKE_linestyle_alpha_modifier_add(FreestyleLineStyle *linestyle, const char *name, int type)
Definition: linestyle.c:1104
LineStyleModifier * BKE_linestyle_alpha_modifier_copy(FreestyleLineStyle *linestyle, const LineStyleModifier *m, const int flag)
int BKE_linestyle_geometry_modifier_remove(FreestyleLineStyle *linestyle, LineStyleModifier *modifier)
Definition: linestyle.c:1903
General operations, lookup, etc. for materials.
struct Material *** BKE_object_material_array_p(struct Object *ob)
Definition: material.c:323
bool BKE_object_material_slot_remove(struct Main *bmain, struct Object *ob)
Definition: material.c:1107
bool BKE_object_material_slot_used(struct ID *id, short actcol)
Definition: material.c:465
struct Material * BKE_object_material_get(struct Object *ob, short act)
Definition: material.c:697
struct Material * BKE_gpencil_material_add(struct Main *bmain, const char *name)
Definition: material.c:310
void BKE_material_copybuf_paste(struct Main *bmain, struct Material *ma)
Definition: material.c:1691
void BKE_material_copybuf_copy(struct Main *bmain, struct Material *ma)
Definition: material.c:1673
void BKE_object_material_remap(struct Object *ob, const unsigned int *remap)
Definition: material.c:947
struct Material * BKE_material_add(struct Main *bmain, const char *name)
Definition: material.c:301
bool BKE_object_material_slot_add(struct Main *bmain, struct Object *ob)
Definition: material.c:1091
struct Material ** BKE_object_material_get_p(struct Object *ob, short act)
Definition: material.c:645
short * BKE_object_material_len_p(struct Object *ob)
Definition: material.c:356
void BKE_object_material_array_assign(struct Main *bmain, struct Object *ob, struct Material ***matar, int totcol, const bool to_object_only)
Definition: material.c:1032
void ntreeCompositUpdateRLayers(struct bNodeTree *ntree)
General operations, lookup, etc. for blender objects.
bool BKE_object_is_in_editmode(const struct Object *ob)
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
void BKE_reportf(ReportList *reports, ReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
struct SceneRenderView * BKE_scene_add_render_view(struct Scene *sce, const char *name)
Definition: scene.c:2813
bool BKE_scene_remove_render_view(struct Scene *scene, struct SceneRenderView *srv)
Definition: scene.c:2834
bool give_active_mtex(struct ID *id, struct MTex ***mtex_ar, short *act)
Definition: texture.c:499
void set_active_mtex(struct ID *id, short act)
Definition: texture.c:525
struct Tex * BKE_texture_add(struct Main *bmain, const char *name)
Definition: texture.c:387
struct World * BKE_world_add(struct Main *bmain, const char *name)
Definition: world.c:214
#define BLI_assert(a)
Definition: BLI_assert.h:58
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void range_vn_u(unsigned int *array_tar, const int size, const unsigned int start)
Definition: math_vector.c:1182
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNUSED(x)
#define ELEM(...)
#define DATA_(msgid)
void DEG_id_tag_update(struct ID *id, int flag)
void DEG_relations_tag_update(struct Main *bmain)
@ ID_RECALC_COPY_ON_WRITE
Definition: DNA_ID.h:654
@ ID_RECALC_SELECT
Definition: DNA_ID.h:638
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:611
#define ID_IS_LINKED(_id)
Definition: DNA_ID.h:426
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition: DNA_ID.h:445
@ ID_LS
Definition: DNA_ID_enums.h:87
@ ID_PA
Definition: DNA_ID_enums.h:82
@ LIGHTCACHE_UPDATE_GRID
@ LIGHTCACHE_INVALID
@ LIGHTCACHE_UPDATE_CUBE
@ OB_MODE_TEXTURE_PAINT
Object is a sort of wrapper for general info.
#define OB_TYPE_SUPPORT_MATERIAL(_type)
@ OB_SURF
@ OB_FONT
@ OB_MESH
@ OB_CURVE
@ OB_GPENCIL
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_RUNNING_MODAL
@ OPERATOR_PASS_THROUGH
bool EDBM_deselect_by_material(struct BMEditMesh *em, const short index, const bool select)
void ED_node_shader_default(const struct bContext *C, struct ID *id)
struct Object * ED_object_context(const struct bContext *C)
Object ** ED_object_array_in_mode_or_selected(struct bContext *C, bool(*filter_fn)(struct Object *ob, void *user_data), void *filter_user_data, uint *r_objects_len)
bool ED_paint_proj_mesh_data_check(struct Scene *scene, struct Object *ob, bool *uvs, bool *mat, bool *tex, bool *stencil)
bool ED_scene_view_layer_delete(struct Main *bmain, struct Scene *scene, struct ViewLayer *layer, struct ReportList *reports) ATTR_NONNULL(1
void ED_update_for_newframe(struct Main *bmain, struct Depsgraph *depsgraph)
Definition: screen_edit.c:1617
bool ED_operator_object_active_local_editable_ex(struct bContext *C, const Object *ob)
Definition: screen_ops.c:373
struct Material * FRS_create_stroke_material(struct Main *bmain, struct FreestyleLineStyle *linestyle)
bool FRS_move_active_lineset(struct FreestyleConfig *config, int direction)
void FRS_paste_active_lineset(struct FreestyleConfig *config)
void FRS_copy_active_lineset(struct FreestyleConfig *config)
void FRS_delete_active_lineset(struct FreestyleConfig *config)
_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 type
Read Guarded memory(de)allocation.
StructRNA RNA_Material
StructRNA RNA_LineStyleColorModifier
StructRNA RNA_FreestyleModuleSettings
StructRNA RNA_LineStyleModifier
StructRNA RNA_ParticleSystem
StructRNA RNA_Light
StructRNA RNA_Object
StructRNA RNA_FreestyleLineStyle
StructRNA RNA_World
StructRNA RNA_LineStyleThicknessModifier
StructRNA RNA_LineStyleAlphaModifier
StructRNA RNA_TextureSlot
StructRNA RNA_Texture
StructRNA RNA_LineStyleGeometryModifier
@ PROP_SKIP_SAVE
Definition: RNA_types.h:204
#define C
Definition: RandGen.cpp:39
#define MAX_MTEX
Definition: Stroke.h:45
void UI_context_active_but_prop_get_templateID(struct bContext *C, struct PointerRNA *r_ptr, struct PropertyRNA **r_prop)
@ WM_JOB_TYPE_LIGHT_BAKE
Definition: WM_api.h:754
@ WM_JOB_TYPE_RENDER
Definition: WM_api.h:736
#define NC_WORLD
Definition: WM_types.h:288
#define NC_GEOM
Definition: WM_types.h:294
#define ND_DRAW
Definition: WM_types.h:362
@ OPTYPE_INTERNAL
Definition: WM_types.h:175
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_REGISTER
Definition: WM_types.h:153
#define ND_DATA
Definition: WM_types.h:408
#define NC_LINESTYLE
Definition: WM_types.h:301
#define ND_RENDER_OPTIONS
Definition: WM_types.h:335
#define ND_SHADING_PREVIEW
Definition: WM_types.h:380
#define NC_SCENE
Definition: WM_types.h:279
#define NA_ADDED
Definition: WM_types.h:464
#define ND_TOOLSETTINGS
Definition: WM_types.h:349
#define NA_EDITED
Definition: WM_types.h:462
#define NC_MATERIAL
Definition: WM_types.h:281
#define ND_SELECT
Definition: WM_types.h:407
#define NC_TEXTURE
Definition: WM_types.h:282
#define ND_LAYER
Definition: WM_types.h:350
#define ND_OB_SHADING
Definition: WM_types.h:358
#define NC_OBJECT
Definition: WM_types.h:280
#define ND_SHADING_LINKS
Definition: WM_types.h:379
static struct PyModuleDef module
@ BM_ELEM_SELECT
Definition: bmesh_class.h:471
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:26
#define BM_ITER_MESH(ele, iter, bm, itype)
@ BM_FACES_OF_MESH
#define SELECT
Scene scene
FreestyleLineStyle linestyle
void * user_data
bool ED_curve_nurb_select_check(View3D *v3d, Nurb *nu)
void * EEVEE_lightbake_job_data_alloc(struct Main *bmain, struct ViewLayer *view_layer, struct Scene *scene, bool run_as_job, int frame)
void EEVEE_lightbake_job(void *custom_data, short *stop, short *do_update, float *progress)
wmJob * EEVEE_lightbake_job_create(struct wmWindowManager *wm, struct wmWindow *win, struct Main *bmain, struct ViewLayer *view_layer, struct Scene *scene, int delay, int frame)
void EEVEE_lightbake_job_data_free(void *custom_data)
void EEVEE_lightcache_free(LightCache *lcache)
void EEVEE_lightcache_info_update(SceneEEVEE *eevee)
RenderEngine * RE_engine_create(RenderEngineType *type)
Definition: engine.c:133
RenderEngineType * RE_engines_find(const char *idname)
Definition: engine.c:108
void RE_engine_free(RenderEngine *engine)
Definition: engine.c:161
#define GS(x)
Definition: iris.c:241
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
static unsigned a[3]
Definition: RandGen.cpp:92
static Object ** object_array_for_shading_edit_mode_enabled(bContext *C, uint *r_objects_len)
static int light_cache_free_exec(bContext *C, wmOperator *UNUSED(op))
static int new_material_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_material_slot_add(wmOperatorType *ot)
void OBJECT_OT_material_slot_deselect(wmOperatorType *ot)
static int view_layer_remove_exec(bContext *C, wmOperator *UNUSED(op))
static int view_layer_add_exec(bContext *C, wmOperator *op)
static bool object_array_for_shading_edit_mode_disabled_filter(Object *ob, void *user_data)
static int light_cache_bake_modal(bContext *C, wmOperator *op, const wmEvent *event)
static int render_view_add_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_material_slot_copy(wmOperatorType *ot)
static MTex mtexcopybuf
static bool view_layer_remove_poll(bContext *C)
static void paste_mtex_copybuf(ID *id)
static bool light_cache_free_poll(bContext *C)
static void copy_mtex_copybuf(ID *id)
static int material_slot_select_exec(bContext *C, wmOperator *UNUSED(op))
static int material_slot_de_select(bContext *C, bool select)
void ED_render_clear_mtex_copybuf(void)
void OBJECT_OT_material_slot_select(wmOperatorType *ot)
void WORLD_OT_new(wmOperatorType *ot)
void OBJECT_OT_material_slot_remove_unused(wmOperatorType *ot)
static int view_layer_add_aov_exec(bContext *C, wmOperator *UNUSED(op))
static int paste_mtex_exec(bContext *C, wmOperator *UNUSED(op))
static int material_slot_remove_unused_exec(bContext *C, wmOperator *op)
void OBJECT_OT_material_slot_assign(wmOperatorType *ot)
static int paste_material_exec(bContext *C, wmOperator *UNUSED(op))
void MATERIAL_OT_paste(wmOperatorType *ot)
void MATERIAL_OT_new(wmOperatorType *ot)
static int material_slot_remove_exec(bContext *C, wmOperator *op)
void SCENE_OT_view_layer_add(wmOperatorType *ot)
static int view_layer_remove_aov_exec(bContext *C, wmOperator *UNUSED(op))
static int material_slot_add_exec(bContext *C, wmOperator *UNUSED(op))
void OBJECT_OT_material_slot_move(wmOperatorType *ot)
static int material_slot_copy_exec(bContext *C, wmOperator *UNUSED(op))
void TEXTURE_OT_new(wmOperatorType *ot)
static bool render_view_remove_poll(bContext *C)
static bool object_materials_supported_poll(bContext *C)
static int copy_material_exec(bContext *C, wmOperator *UNUSED(op))
static void light_cache_bake_tag_cache(Scene *scene, wmOperator *op)
static int material_slot_move_exec(bContext *C, wmOperator *op)
void MATERIAL_OT_copy(wmOperatorType *ot)
void SCENE_OT_light_cache_free(wmOperatorType *ot)
static int light_cache_bake_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
static int texture_slot_move_exec(bContext *C, wmOperator *op)
void TEXTURE_OT_slot_paste(wmOperatorType *ot)
void SCENE_OT_view_layer_add_aov(wmOperatorType *ot)
static int new_world_exec(bContext *C, wmOperator *UNUSED(op))
void TEXTURE_OT_slot_copy(wmOperatorType *ot)
void SCENE_OT_light_cache_bake(wmOperatorType *ot)
static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op))
static int light_cache_bake_exec(bContext *C, wmOperator *op)
void SCENE_OT_render_view_add(wmOperatorType *ot)
void SCENE_OT_view_layer_remove_aov(wmOperatorType *ot)
void OBJECT_OT_material_slot_remove(wmOperatorType *ot)
void TEXTURE_OT_slot_move(wmOperatorType *ot)
void SCENE_OT_view_layer_remove(wmOperatorType *ot)
static int material_slot_deselect_exec(bContext *C, wmOperator *UNUSED(op))
static Object ** object_array_for_shading_edit_mode_disabled(bContext *C, uint *r_objects_len)
static int copy_mtex_exec(bContext *C, wmOperator *UNUSED(op))
static bool object_array_for_shading_edit_mode_enabled_filter(Object *ob, void *user_data)
void SCENE_OT_render_view_remove(wmOperatorType *ot)
static int render_view_remove_exec(bContext *C, wmOperator *UNUSED(op))
@ LIGHTCACHE_SUBSET_DIRTY
@ LIGHTCACHE_SUBSET_CUBE
@ LIGHTCACHE_SUBSET_ALL
static int new_texture_exec(bContext *C, wmOperator *UNUSED(op))
static bool object_materials_supported_poll_ex(bContext *C, const Object *ob)
static bool copy_mtex_poll(bContext *C)
static void light_cache_bake_cancel(bContext *C, wmOperator *op)
static short mtexcopied
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
Definition: rna_access.c:844
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:122
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
Definition: rna_access.c:3673
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
Definition: rna_access.c:2317
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6308
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, int default_value, int hardmin, int hardmax, const char *ui_name, const char *ui_description, int softmin, int softmax)
Definition: rna_define.c:3585
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3771
const EnumPropertyItem rna_enum_linestyle_thickness_modifier_type_items[]
Definition: rna_linestyle.c:78
const EnumPropertyItem rna_enum_linestyle_geometry_modifier_type_items[]
Definition: rna_linestyle.c:99
const EnumPropertyItem rna_enum_linestyle_color_modifier_type_items[]
Definition: rna_linestyle.c:38
const EnumPropertyItem rna_enum_linestyle_alpha_modifier_type_items[]
Definition: rna_linestyle.c:58
struct BMesh * bm
Definition: BKE_editmesh.h:52
short mat_nr
Definition: bmesh_class.h:281
short hide
uint8_t f1
struct CharInfo * textbufinfo
Definition: BKE_font.h:49
struct FreestyleLineStyle * linestyle
Definition: DNA_ID.h:273
char name[66]
Definition: DNA_ID.h:283
void * last
Definition: DNA_listBase.h:47
void * first
Definition: DNA_listBase.h:47
struct Tex * tex
Definition: BKE_main.h:116
struct Nurb * next
BezTriple * bezt
BPoint * bp
short mat_nr
struct Material ** mat
char * matbits
void * data
ParticleSettings * part
struct StructRNA * type
Definition: RNA_types.h:51
void * data
Definition: RNA_types.h:52
struct ID * owner_id
Definition: RNA_types.h:50
char engine[32]
ListBase views
void(* update_render_passes)(struct RenderEngine *engine, struct Scene *scene, struct ViewLayer *view_layer)
Definition: RE_engine.h:107
struct LightCache * light_cache_data
struct bNodeTree * nodetree
struct RenderData r
ListBase view_layers
struct SceneEEVEE eevee
struct FreestyleConfig freestyle_config
ViewLayerAOV * active_aov
char name[64]
short use_nodes
short type
Definition: WM_types.h:577
Definition: wm_jobs.c:73
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:752
const char * name
Definition: WM_types.h:721
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:768
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
void(* cancel)(struct bContext *, struct wmOperator *)
Definition: WM_types.h:760
struct StructRNA * srna
Definition: WM_types.h:802
const char * description
Definition: WM_types.h:726
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
PropertyRNA * prop
Definition: WM_types.h:814
struct ReportList * reports
struct PointerRNA * ptr
__forceinline const avxb select(const avxb &m, const avxb &t, const avxb &f)
Definition: util_avxb.h:167
#define G(x, y, z)
void WM_cursor_wait(bool val)
Definition: wm_cursors.c:226
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
@ EVT_ESCKEY
PointerRNA * ptr
Definition: wm_files.c:3157
wmOperatorType * ot
Definition: wm_files.c:3156
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition: wm_jobs.c:450
bool WM_jobs_test(wmWindowManager *wm, void *owner, int job_type)
Definition: wm_jobs.c:223
void WM_jobs_kill_type(struct wmWindowManager *wm, void *owner, int job_type)
Definition: wm_jobs.c:572
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: wm_operators.c:982
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
Definition: wm_window.c:2286
void WM_window_set_active_view_layer(wmWindow *win, ViewLayer *view_layer)
Definition: wm_window.c:2306