Blender  V2.93
BlenderStrokeRenderer.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include "BlenderStrokeRenderer.h"
22 
23 #include "../application/AppConfig.h"
24 #include "../stroke/Canvas.h"
25 
26 #include "MEM_guardedalloc.h"
27 
28 #include "RNA_access.h"
29 #include "RNA_types.h"
30 
31 #include "DNA_camera_types.h"
32 #include "DNA_collection_types.h"
33 #include "DNA_linestyle_types.h"
34 #include "DNA_listBase.h"
35 #include "DNA_material_types.h"
36 #include "DNA_mesh_types.h"
37 #include "DNA_meshdata_types.h"
38 #include "DNA_object_types.h"
39 #include "DNA_scene_types.h"
40 #include "DNA_screen_types.h"
41 
42 #include "BKE_collection.h"
43 #include "BKE_customdata.h"
44 #include "BKE_global.h"
45 #include "BKE_idprop.h"
46 #include "BKE_layer.h"
47 #include "BKE_lib_id.h" /* free_libblock */
48 #include "BKE_material.h"
49 #include "BKE_mesh.h"
50 #include "BKE_node.h"
51 #include "BKE_object.h"
52 #include "BKE_scene.h"
53 
54 #include "BLI_ghash.h"
55 #include "BLI_listbase.h"
56 #include "BLI_math_color.h"
57 #include "BLI_math_vector.h"
58 #include "BLI_utildefines.h"
59 
60 #include "DEG_depsgraph.h"
61 #include "DEG_depsgraph_build.h"
62 
63 #include "RE_pipeline.h"
64 
65 #include "render_types.h"
66 
67 #include <climits>
68 
69 namespace Freestyle {
70 
71 const char *BlenderStrokeRenderer::uvNames[] = {"along_stroke", "along_stroke_tips"};
72 
74 {
76 
77  /* We use the same window manager for freestyle bmain as
78  * real bmain uses. This is needed because freestyle's
79  * bmain could be used to tag scenes for update, which
80  * implies call of ED_render_scene_update in some cases
81  * and that function requires proper window manager
82  * to present (sergey)
83  */
84  freestyle_bmain->wm = re->main->wm;
85 
86  // for stroke mesh generation
87  _width = re->winx;
88  _height = re->winy;
89 
90  old_scene = re->scene;
91 
92  char name[MAX_ID_NAME - 2];
93  BLI_snprintf(name, sizeof(name), "FRS%d_%s", render_count, re->scene->id.name + 2);
97  freestyle_scene->r.xsch = re->rectx; // old_scene->r.xsch
98  freestyle_scene->r.ysch = re->recty; // old_scene->r.ysch
99  freestyle_scene->r.xasp = 1.0f; // old_scene->r.xasp;
100  freestyle_scene->r.yasp = 1.0f; // old_scene->r.yasp;
103  freestyle_scene->r.size = 100; // old_scene->r.size
104  freestyle_scene->r.color_mgt_flag = 0; // old_scene->r.color_mgt_flag;
107  (re->r.scemode | ~R_FULL_SAMPLE);
114  strcpy(freestyle_scene->r.pic, old_scene->r.pic);
117  if (G.debug & G_DEBUG_FREESTYLE) {
118  cout << "Stroke rendering engine : " << freestyle_scene->r.engine << endl;
119  }
122 
123  // Copy ID properties, including Cycles render properties
124  if (old_scene->id.properties) {
126  }
127  // Copy eevee render settings.
129 
130  /* Render with transparent background. */
132 
133  if (G.debug & G_DEBUG_FREESTYLE) {
134  printf("%s: %d thread(s)\n", __func__, BKE_render_num_threads(&freestyle_scene->r));
135  }
136 
138 
139  // Scene layer.
141  view_layer->layflag = SCE_LAY_SOLID | SCE_LAY_ZTRA;
142 
143  // Camera
144  Object *object_camera = BKE_object_add(freestyle_bmain, view_layer, OB_CAMERA, nullptr);
145 
146  Camera *camera = (Camera *)object_camera->data;
147  camera->type = CAM_ORTHO;
148  camera->ortho_scale = max(re->rectx, re->recty);
149  camera->clip_start = 0.1f;
150  camera->clip_end = 100.0f;
151 
152  _z_delta = 0.00001f;
153  _z = camera->clip_start + _z_delta;
154 
155  object_camera->loc[0] = re->disprect.xmin + 0.5f * re->rectx;
156  object_camera->loc[1] = re->disprect.ymin + 0.5f * re->recty;
157  object_camera->loc[2] = 1.0f;
158 
159  freestyle_scene->camera = object_camera;
160 
161  // Reset serial mesh ID (used for BlenderStrokeRenderer::NewMesh())
162  _mesh_id = 0xffffffff;
163 
164  // Create a bNodeTree-to-Material hash table
165  _nodetree_hash = BLI_ghash_ptr_new("BlenderStrokeRenderer::_nodetree_hash");
166 
167  // Depsgraph
173 }
174 
176 {
177  BLI_ghash_free(_nodetree_hash, nullptr, nullptr);
178 
180 
182 
183  /* detach the window manager from freestyle bmain (see comments
184  * in add_freestyle() for more detail)
185  */
187 
189 }
190 
192 {
193  float z = _z;
194  BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this);
195  if (!(_z < _z_delta * 100000.0f)) {
196  self->_z_delta *= 10.0f;
197  }
198  self->_z += _z_delta;
199  return -z;
200 }
201 
203 {
204  unsigned mesh_id = _mesh_id;
205  BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this);
206  self->_mesh_id--;
207  return mesh_id;
208 }
209 
211  bNodeTree *iNodeTree,
212  bool do_id_user)
213 {
214  Material *ma = BKE_material_add(bmain, "stroke_shader");
215  bNodeTree *ntree;
216  bNode *output_linestyle = nullptr;
217  bNodeSocket *fromsock, *tosock;
218  PointerRNA fromptr, toptr;
219  NodeShaderAttribute *storage;
220 
221  id_us_min(&ma->id);
222 
223  if (iNodeTree) {
224  // make a copy of linestyle->nodetree
225  ntree = ntreeCopyTree_ex(iNodeTree, bmain, do_id_user);
226 
227  // find the active Output Line Style node
228  for (bNode *node = (bNode *)ntree->nodes.first; node; node = node->next) {
229  if (node->type == SH_NODE_OUTPUT_LINESTYLE && (node->flag & NODE_DO_OUTPUT)) {
230  output_linestyle = node;
231  break;
232  }
233  }
234  }
235  else {
236  ntree = ntreeAddTree(nullptr, "stroke_shader", "ShaderNodeTree");
237  }
238  ma->nodetree = ntree;
239  ma->use_nodes = 1;
241 
242  bNode *input_attr_color = nodeAddStaticNode(nullptr, ntree, SH_NODE_ATTRIBUTE);
243  input_attr_color->locx = 0.0f;
244  input_attr_color->locy = -200.0f;
245  storage = (NodeShaderAttribute *)input_attr_color->storage;
246  BLI_strncpy(storage->name, "Color", sizeof(storage->name));
247 
248  bNode *mix_rgb_color = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_RGB);
249  mix_rgb_color->custom1 = MA_RAMP_BLEND; // Mix
250  mix_rgb_color->locx = 200.0f;
251  mix_rgb_color->locy = -200.0f;
252  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_color->inputs, 0); // Fac
253  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
254  RNA_float_set(&toptr, "default_value", 0.0f);
255 
256  bNode *input_attr_alpha = nodeAddStaticNode(nullptr, ntree, SH_NODE_ATTRIBUTE);
257  input_attr_alpha->locx = 400.0f;
258  input_attr_alpha->locy = 300.0f;
259  storage = (NodeShaderAttribute *)input_attr_alpha->storage;
260  BLI_strncpy(storage->name, "Alpha", sizeof(storage->name));
261 
262  bNode *mix_rgb_alpha = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_RGB);
263  mix_rgb_alpha->custom1 = MA_RAMP_BLEND; // Mix
264  mix_rgb_alpha->locx = 600.0f;
265  mix_rgb_alpha->locy = 300.0f;
266  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_alpha->inputs, 0); // Fac
267  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
268  RNA_float_set(&toptr, "default_value", 0.0f);
269 
270  bNode *shader_emission = nodeAddStaticNode(nullptr, ntree, SH_NODE_EMISSION);
271  shader_emission->locx = 400.0f;
272  shader_emission->locy = -200.0f;
273 
274  bNode *input_light_path = nodeAddStaticNode(nullptr, ntree, SH_NODE_LIGHT_PATH);
275  input_light_path->locx = 400.0f;
276  input_light_path->locy = 100.0f;
277 
278  bNode *mix_shader_color = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_SHADER);
279  mix_shader_color->locx = 600.0f;
280  mix_shader_color->locy = -100.0f;
281 
282  bNode *shader_transparent = nodeAddStaticNode(nullptr, ntree, SH_NODE_BSDF_TRANSPARENT);
283  shader_transparent->locx = 600.0f;
284  shader_transparent->locy = 100.0f;
285 
286  bNode *mix_shader_alpha = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_SHADER);
287  mix_shader_alpha->locx = 800.0f;
288  mix_shader_alpha->locy = 100.0f;
289 
290  bNode *output_material = nodeAddStaticNode(nullptr, ntree, SH_NODE_OUTPUT_MATERIAL);
291  output_material->locx = 1000.0f;
292  output_material->locy = 100.0f;
293 
294  fromsock = (bNodeSocket *)BLI_findlink(&input_attr_color->outputs, 0); // Color
295  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_color->inputs, 1); // Color1
296  nodeAddLink(ntree, input_attr_color, fromsock, mix_rgb_color, tosock);
297 
298  fromsock = (bNodeSocket *)BLI_findlink(&mix_rgb_color->outputs, 0); // Color
299  tosock = (bNodeSocket *)BLI_findlink(&shader_emission->inputs, 0); // Color
300  nodeAddLink(ntree, mix_rgb_color, fromsock, shader_emission, tosock);
301 
302  fromsock = (bNodeSocket *)BLI_findlink(&shader_emission->outputs, 0); // Emission
303  tosock = (bNodeSocket *)BLI_findlink(&mix_shader_color->inputs, 2); // Shader (second)
304  nodeAddLink(ntree, shader_emission, fromsock, mix_shader_color, tosock);
305 
306  fromsock = (bNodeSocket *)BLI_findlink(&input_light_path->outputs, 0); // In Camera Ray
307  tosock = (bNodeSocket *)BLI_findlink(&mix_shader_color->inputs, 0); // Fac
308  nodeAddLink(ntree, input_light_path, fromsock, mix_shader_color, tosock);
309 
310  fromsock = (bNodeSocket *)BLI_findlink(&mix_rgb_alpha->outputs, 0); // Color
311  tosock = (bNodeSocket *)BLI_findlink(&mix_shader_alpha->inputs, 0); // Fac
312  nodeAddLink(ntree, mix_rgb_alpha, fromsock, mix_shader_alpha, tosock);
313 
314  fromsock = (bNodeSocket *)BLI_findlink(&input_attr_alpha->outputs, 0); // Color
315  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_alpha->inputs, 1); // Color1
316  nodeAddLink(ntree, input_attr_alpha, fromsock, mix_rgb_alpha, tosock);
317 
318  fromsock = (bNodeSocket *)BLI_findlink(&shader_transparent->outputs, 0); // BSDF
319  tosock = (bNodeSocket *)BLI_findlink(&mix_shader_alpha->inputs, 1); // Shader (first)
320  nodeAddLink(ntree, shader_transparent, fromsock, mix_shader_alpha, tosock);
321 
322  fromsock = (bNodeSocket *)BLI_findlink(&mix_shader_color->outputs, 0); // Shader
323  tosock = (bNodeSocket *)BLI_findlink(&mix_shader_alpha->inputs, 2); // Shader (second)
324  nodeAddLink(ntree, mix_shader_color, fromsock, mix_shader_alpha, tosock);
325 
326  fromsock = (bNodeSocket *)BLI_findlink(&mix_shader_alpha->outputs, 0); // Shader
327  tosock = (bNodeSocket *)BLI_findlink(&output_material->inputs, 0); // Surface
328  nodeAddLink(ntree, mix_shader_alpha, fromsock, output_material, tosock);
329 
330  if (output_linestyle) {
331  bNodeSocket *outsock;
332  bNodeLink *link;
333 
334  mix_rgb_color->custom1 = output_linestyle->custom1; // blend_type
335  mix_rgb_color->custom2 = output_linestyle->custom2; // use_clamp
336 
337  outsock = (bNodeSocket *)BLI_findlink(&output_linestyle->inputs, 0); // Color
338  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_color->inputs, 2); // Color2
339  link = (bNodeLink *)BLI_findptr(&ntree->links, outsock, offsetof(bNodeLink, tosock));
340  if (link) {
341  nodeAddLink(ntree, link->fromnode, link->fromsock, mix_rgb_color, tosock);
342  }
343  else {
344  float color[4];
345  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, outsock, &fromptr);
346  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
347  RNA_float_get_array(&fromptr, "default_value", color);
348  RNA_float_set_array(&toptr, "default_value", color);
349  }
350 
351  outsock = (bNodeSocket *)BLI_findlink(&output_linestyle->inputs, 1); // Color Fac
352  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_color->inputs, 0); // Fac
353  link = (bNodeLink *)BLI_findptr(&ntree->links, outsock, offsetof(bNodeLink, tosock));
354  if (link) {
355  nodeAddLink(ntree, link->fromnode, link->fromsock, mix_rgb_color, tosock);
356  }
357  else {
358  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, outsock, &fromptr);
359  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
360  RNA_float_set(&toptr, "default_value", RNA_float_get(&fromptr, "default_value"));
361  }
362 
363  outsock = (bNodeSocket *)BLI_findlink(&output_linestyle->inputs, 2); // Alpha
364  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_alpha->inputs, 2); // Color2
365  link = (bNodeLink *)BLI_findptr(&ntree->links, outsock, offsetof(bNodeLink, tosock));
366  if (link) {
367  nodeAddLink(ntree, link->fromnode, link->fromsock, mix_rgb_alpha, tosock);
368  }
369  else {
370  float color[4];
371  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, outsock, &fromptr);
372  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
373  color[0] = color[1] = color[2] = RNA_float_get(&fromptr, "default_value");
374  color[3] = 1.0f;
375  RNA_float_set_array(&toptr, "default_value", color);
376  }
377 
378  outsock = (bNodeSocket *)BLI_findlink(&output_linestyle->inputs, 3); // Alpha Fac
379  tosock = (bNodeSocket *)BLI_findlink(&mix_rgb_alpha->inputs, 0); // Fac
380  link = (bNodeLink *)BLI_findptr(&ntree->links, outsock, offsetof(bNodeLink, tosock));
381  if (link) {
382  nodeAddLink(ntree, link->fromnode, link->fromsock, mix_rgb_alpha, tosock);
383  }
384  else {
385  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, outsock, &fromptr);
386  RNA_pointer_create((ID *)ntree, &RNA_NodeSocket, tosock, &toptr);
387  RNA_float_set(&toptr, "default_value", RNA_float_get(&fromptr, "default_value"));
388  }
389 
390  for (bNode *node = (bNode *)ntree->nodes.first; node; node = node->next) {
391  if (node->type == SH_NODE_UVALONGSTROKE) {
392  // UV output of the UV Along Stroke node
393  bNodeSocket *sock = (bNodeSocket *)BLI_findlink(&node->outputs, 0);
394 
395  // add new UV Map node
396  bNode *input_uvmap = nodeAddStaticNode(nullptr, ntree, SH_NODE_UVMAP);
397  input_uvmap->locx = node->locx - 200.0f;
398  input_uvmap->locy = node->locy;
399  NodeShaderUVMap *storage = (NodeShaderUVMap *)input_uvmap->storage;
400  if (node->custom1 & 1) { // use_tips
401  BLI_strncpy(storage->uv_map, uvNames[1], sizeof(storage->uv_map));
402  }
403  else {
404  BLI_strncpy(storage->uv_map, uvNames[0], sizeof(storage->uv_map));
405  }
406  fromsock = (bNodeSocket *)BLI_findlink(&input_uvmap->outputs, 0); // UV
407 
408  // replace links from the UV Along Stroke node by links from the UV Map node
409  for (bNodeLink *link = (bNodeLink *)ntree->links.first; link; link = link->next) {
410  if (link->fromnode == node && link->fromsock == sock) {
411  nodeAddLink(ntree, input_uvmap, fromsock, link->tonode, link->tosock);
412  }
413  }
414  nodeRemSocketLinks(ntree, sock);
415  }
416  }
417  }
418 
419  nodeSetActive(ntree, output_material);
420  ntreeUpdateTree(bmain, ntree);
421 
422  return ma;
423 }
424 
426 {
427  RenderStrokeRepBasic(iStrokeRep);
428 }
429 
431 {
432  bNodeTree *nt = iStrokeRep->getNodeTree();
434  if (!ma) {
437  }
438  iStrokeRep->setMaterial(ma);
439 
440  const vector<Strip *> &strips = iStrokeRep->getStrips();
441  const bool hasTex = iStrokeRep->hasTex();
442  int totvert = 0, totedge = 0, totpoly = 0, totloop = 0;
443  int visible_faces, visible_segments;
444  for (vector<Strip *>::const_iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
445  Strip::vertex_container &strip_vertices = (*s)->vertices();
446 
447  // count visible faces and strip segments
448  test_strip_visibility(strip_vertices, &visible_faces, &visible_segments);
449  if (visible_faces == 0) {
450  continue;
451  }
452 
453  totvert += visible_faces + visible_segments * 2;
454  totedge += visible_faces * 2 + visible_segments;
455  totpoly += visible_faces;
456  totloop += visible_faces * 3;
457  }
458 
459  BlenderStrokeRenderer *self = const_cast<BlenderStrokeRenderer *>(this); // FIXME
460  vector<StrokeGroup *> *groups = hasTex ? &self->texturedStrokeGroups : &self->strokeGroups;
461  StrokeGroup *group;
462  if (groups->empty() || !(groups->back()->totvert + totvert < MESH_MAX_VERTS &&
463  groups->back()->materials.size() + 1 < MAXMAT)) {
464  group = new StrokeGroup;
465  groups->push_back(group);
466  }
467  else {
468  group = groups->back();
469  }
470  group->strokes.push_back(iStrokeRep);
471  group->totvert += totvert;
472  group->totedge += totedge;
473  group->totpoly += totpoly;
474  group->totloop += totloop;
475 
476  if (!group->materials.contains(ma)) {
477  group->materials.add_new(ma, group->materials.size());
478  }
479 }
480 
481 // Check if the triangle is visible (i.e., within the render image boundary)
483 {
484  int xl, xu, yl, yu;
485  Vec2r p;
486 
487  xl = xu = yl = yu = 0;
488  for (int i = 0; i < 3; i++) {
489  p = svRep[i]->point2d();
490  if (p[0] < 0.0) {
491  xl++;
492  }
493  else if (p[0] > _width) {
494  xu++;
495  }
496  if (p[1] < 0.0) {
497  yl++;
498  }
499  else if (p[1] > _height) {
500  yu++;
501  }
502  }
503  return !(xl == 3 || xu == 3 || yl == 3 || yu == 3);
504 }
505 
506 // Check the visibility of faces and strip segments.
508  int *visible_faces,
509  int *visible_segments) const
510 {
511  const int strip_vertex_count = strip_vertices.size();
512  Strip::vertex_container::iterator v[3];
513  StrokeVertexRep *svRep[3];
514  bool visible;
515 
516  // iterate over all vertices and count visible faces and strip segments
517  // (note: a strip segment is a series of visible faces, while two strip
518  // segments are separated by one or more invisible faces)
519  v[0] = strip_vertices.begin();
520  v[1] = v[0] + 1;
521  v[2] = v[0] + 2;
522  *visible_faces = *visible_segments = 0;
523  visible = false;
524  for (int n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
525  svRep[0] = *(v[0]);
526  svRep[1] = *(v[1]);
527  svRep[2] = *(v[2]);
528  if (test_triangle_visibility(svRep)) {
529  (*visible_faces)++;
530  if (!visible) {
531  (*visible_segments)++;
532  }
533  visible = true;
534  }
535  else {
536  visible = false;
537  }
538  }
539 }
540 
541 // Release allocated memory for stroke groups
543 {
544  vector<StrokeGroup *>::const_iterator it, itend;
545 
546  for (it = strokeGroups.begin(), itend = strokeGroups.end(); it != itend; ++it) {
547  delete (*it);
548  }
549  for (it = texturedStrokeGroups.begin(), itend = texturedStrokeGroups.end(); it != itend; ++it) {
550  delete (*it);
551  }
552 }
553 
554 // Build a scene populated by mesh objects representing stylized strokes
556 {
557  vector<StrokeGroup *>::const_iterator it, itend;
558 
559  for (it = strokeGroups.begin(), itend = strokeGroups.end(); it != itend; ++it) {
560  GenerateStrokeMesh(*it, false);
561  }
562  for (it = texturedStrokeGroups.begin(), itend = texturedStrokeGroups.end(); it != itend; ++it) {
563  GenerateStrokeMesh(*it, true);
564  }
565  return get_stroke_count();
566 }
567 
568 // Return the number of strokes
570 {
571  return strokeGroups.size() + texturedStrokeGroups.size();
572 }
573 
574 // Build a mesh object representing a group of stylized strokes
576 {
577 #if 0
578  Object *object_mesh = BKE_object_add(
581 #else
582  Object *object_mesh = NewMesh();
583 #endif
584  Mesh *mesh = (Mesh *)object_mesh->data;
585 
586  mesh->totvert = group->totvert;
587  mesh->totedge = group->totedge;
588  mesh->totpoly = group->totpoly;
589  mesh->totloop = group->totloop;
590  mesh->totcol = group->materials.size();
591 
593  &mesh->vdata, CD_MVERT, CD_CALLOC, nullptr, mesh->totvert);
595  &mesh->edata, CD_MEDGE, CD_CALLOC, nullptr, mesh->totedge);
597  &mesh->pdata, CD_MPOLY, CD_CALLOC, nullptr, mesh->totpoly);
599  &mesh->ldata, CD_MLOOP, CD_CALLOC, nullptr, mesh->totloop);
600 
601  MVert *vertices = mesh->mvert;
602  MEdge *edges = mesh->medge;
603  MPoly *polys = mesh->mpoly;
604  MLoop *loops = mesh->mloop;
605  MLoopUV *loopsuv[2] = {nullptr};
606 
607  if (hasTex) {
608  // First UV layer
610  &mesh->ldata, CD_MLOOPUV, CD_CALLOC, nullptr, mesh->totloop, uvNames[0]);
613  loopsuv[0] = mesh->mloopuv;
614 
615  // Second UV layer
617  &mesh->ldata, CD_MLOOPUV, CD_CALLOC, nullptr, mesh->totloop, uvNames[1]);
620  loopsuv[1] = mesh->mloopuv;
621  }
622 
623  // colors and transparency (the latter represented by grayscale colors)
625  &mesh->ldata, CD_MLOOPCOL, CD_CALLOC, nullptr, mesh->totloop, "Color");
627  &mesh->ldata, CD_MLOOPCOL, CD_CALLOC, nullptr, mesh->totloop, "Alpha");
628  mesh->mloopcol = colors;
629 
630  mesh->mat = (Material **)MEM_mallocN(sizeof(Material *) * mesh->totcol, "MaterialList");
631  for (const auto item : group->materials.items()) {
632  Material *material = item.key;
633  const int matnr = item.value;
634  mesh->mat[matnr] = material;
635  if (material) {
637  }
638  }
639 
641  // Data copy
643 
644  int vertex_index = 0, edge_index = 0, loop_index = 0;
645  int visible_faces, visible_segments;
646  bool visible;
647  Strip::vertex_container::iterator v[3];
648  StrokeVertexRep *svRep[3];
649  Vec2r p;
650 
651  for (vector<StrokeRep *>::const_iterator it = group->strokes.begin(),
652  itend = group->strokes.end();
653  it != itend;
654  ++it) {
655  const int matnr = group->materials.lookup_default((*it)->getMaterial(), 0);
656 
657  vector<Strip *> &strips = (*it)->getStrips();
658  for (vector<Strip *>::const_iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
659  Strip::vertex_container &strip_vertices = (*s)->vertices();
660  int strip_vertex_count = strip_vertices.size();
661 
662  // count visible faces and strip segments
663  test_strip_visibility(strip_vertices, &visible_faces, &visible_segments);
664  if (visible_faces == 0) {
665  continue;
666  }
667 
668  v[0] = strip_vertices.begin();
669  v[1] = v[0] + 1;
670  v[2] = v[0] + 2;
671 
672  visible = false;
673 
674  // Note: Mesh generation in the following loop assumes stroke strips
675  // to be triangle strips.
676  for (int n = 2; n < strip_vertex_count; n++, v[0]++, v[1]++, v[2]++) {
677  svRep[0] = *(v[0]);
678  svRep[1] = *(v[1]);
679  svRep[2] = *(v[2]);
680  if (!test_triangle_visibility(svRep)) {
681  visible = false;
682  }
683  else {
684  if (!visible) {
685  // first vertex
686  vertices->co[0] = svRep[0]->point2d()[0];
687  vertices->co[1] = svRep[0]->point2d()[1];
688  vertices->co[2] = get_stroke_vertex_z();
689  vertices->no[0] = 0;
690  vertices->no[1] = 0;
691  vertices->no[2] = SHRT_MAX;
692  ++vertices;
693  ++vertex_index;
694 
695  // second vertex
696  vertices->co[0] = svRep[1]->point2d()[0];
697  vertices->co[1] = svRep[1]->point2d()[1];
698  vertices->co[2] = get_stroke_vertex_z();
699  vertices->no[0] = 0;
700  vertices->no[1] = 0;
701  vertices->no[2] = SHRT_MAX;
702  ++vertices;
703  ++vertex_index;
704 
705  // first edge
706  edges->v1 = vertex_index - 2;
707  edges->v2 = vertex_index - 1;
708  ++edges;
709  ++edge_index;
710  }
711  visible = true;
712 
713  // vertex
714  vertices->co[0] = svRep[2]->point2d()[0];
715  vertices->co[1] = svRep[2]->point2d()[1];
716  vertices->co[2] = get_stroke_vertex_z();
717  vertices->no[0] = 0;
718  vertices->no[1] = 0;
719  vertices->no[2] = SHRT_MAX;
720  ++vertices;
721  ++vertex_index;
722 
723  // edges
724  edges->v1 = vertex_index - 1;
725  edges->v2 = vertex_index - 3;
726  ++edges;
727  ++edge_index;
728 
729  edges->v1 = vertex_index - 1;
730  edges->v2 = vertex_index - 2;
731  ++edges;
732  ++edge_index;
733 
734  // poly
735  polys->loopstart = loop_index;
736  polys->totloop = 3;
737  polys->mat_nr = matnr;
738  ++polys;
739 
740  // Even and odd loops connect triangles vertices differently
741  bool is_odd = n % 2;
742  // loops
743  if (is_odd) {
744  loops[0].v = vertex_index - 1;
745  loops[0].e = edge_index - 2;
746 
747  loops[1].v = vertex_index - 3;
748  loops[1].e = edge_index - 3;
749 
750  loops[2].v = vertex_index - 2;
751  loops[2].e = edge_index - 1;
752  }
753  else {
754  loops[0].v = vertex_index - 1;
755  loops[0].e = edge_index - 1;
756 
757  loops[1].v = vertex_index - 2;
758  loops[1].e = edge_index - 3;
759 
760  loops[2].v = vertex_index - 3;
761  loops[2].e = edge_index - 2;
762  }
763  loops += 3;
764  loop_index += 3;
765 
766  // UV
767  if (hasTex) {
768  // First UV layer (loopsuv[0]) has no tips (texCoord(0)).
769  // Second UV layer (loopsuv[1]) has tips: (texCoord(1)).
770  for (int L = 0; L < 2; L++) {
771  if (is_odd) {
772  loopsuv[L][0].uv[0] = svRep[2]->texCoord(L).x();
773  loopsuv[L][0].uv[1] = svRep[2]->texCoord(L).y();
774 
775  loopsuv[L][1].uv[0] = svRep[0]->texCoord(L).x();
776  loopsuv[L][1].uv[1] = svRep[0]->texCoord(L).y();
777 
778  loopsuv[L][2].uv[0] = svRep[1]->texCoord(L).x();
779  loopsuv[L][2].uv[1] = svRep[1]->texCoord(L).y();
780  }
781  else {
782  loopsuv[L][0].uv[0] = svRep[2]->texCoord(L).x();
783  loopsuv[L][0].uv[1] = svRep[2]->texCoord(L).y();
784 
785  loopsuv[L][1].uv[0] = svRep[1]->texCoord(L).x();
786  loopsuv[L][1].uv[1] = svRep[1]->texCoord(L).y();
787 
788  loopsuv[L][2].uv[0] = svRep[0]->texCoord(L).x();
789  loopsuv[L][2].uv[1] = svRep[0]->texCoord(L).y();
790  }
791  loopsuv[L] += 3;
792  }
793  }
794 
795  // colors and alpha transparency. vertex colors are in sRGB
796  // space by convention, so convert from linear
797  float rgba[3][4];
798 
799  for (int i = 0; i < 3; i++) {
800  copy_v3fl_v3db(rgba[i], &svRep[i]->color()[0]);
801  rgba[i][3] = svRep[i]->alpha();
802  }
803 
804  if (is_odd) {
805  linearrgb_to_srgb_uchar4(&colors[0].r, rgba[2]);
806  linearrgb_to_srgb_uchar4(&colors[1].r, rgba[0]);
807  linearrgb_to_srgb_uchar4(&colors[2].r, rgba[1]);
808  }
809  else {
810  linearrgb_to_srgb_uchar4(&colors[0].r, rgba[2]);
811  linearrgb_to_srgb_uchar4(&colors[1].r, rgba[1]);
812  linearrgb_to_srgb_uchar4(&colors[2].r, rgba[0]);
813  }
814  transp[0].r = transp[0].g = transp[0].b = colors[0].a;
815  transp[1].r = transp[1].g = transp[1].b = colors[1].a;
816  transp[2].r = transp[2].g = transp[2].b = colors[2].a;
817  colors += 3;
818  transp += 3;
819  }
820  } // loop over strip vertices
821  } // loop over strips
822  } // loop over strokes
823 
825 
826 #if 0 // XXX
827  BLI_assert(mesh->totvert == vertex_index);
828  BLI_assert(mesh->totedge == edge_index);
829  BLI_assert(mesh->totloop == loop_index);
830  BKE_mesh_validate(mesh, true, true);
831 #endif
832 }
833 
834 // A replacement of BKE_object_add() for better performance.
836 {
837  Object *ob;
838  char name[MAX_ID_NAME];
839  unsigned int mesh_id = get_stroke_mesh_id();
840 
841  BLI_snprintf(name, MAX_ID_NAME, "0%08xOB", mesh_id);
843  BLI_snprintf(name, MAX_ID_NAME, "0%08xME", mesh_id);
844  ob->data = BKE_mesh_add(freestyle_bmain, name);
845 
846  Collection *collection_master = freestyle_scene->master_collection;
847  BKE_collection_object_add(freestyle_bmain, collection_master, ob);
849 
852  &ob->id,
854 
855  return ob;
856 }
857 
859 {
860  Camera *camera = (Camera *)freestyle_scene->camera->data;
861  if (camera->clip_end < _z) {
862  camera->clip_end = _z + _z_delta * 100.0f;
863  }
864 #if 0
865  if (G.debug & G_DEBUG_FREESTYLE) {
866  cout << "clip_start " << camera->clip_start << ", clip_end " << camera->clip_end << endl;
867  }
868 #endif
869 
870  Render *freestyle_render = RE_NewSceneRender(freestyle_scene);
872 
873  RE_RenderFreestyleStrokes(
874  freestyle_render, freestyle_bmain, freestyle_scene, render && get_stroke_count() > 0);
875 
876  return freestyle_render;
877 }
878 
879 } /* namespace Freestyle */
bool BKE_collection_object_add(struct Main *bmain, struct Collection *collection, struct Object *ob)
Definition: collection.c:1134
CustomData interface, see also DNA_customdata_types.h.
void CustomData_set_layer_active(struct CustomData *data, int type, int n)
Definition: customdata.c:2401
@ CD_CALLOC
void * CustomData_add_layer_named(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem, const char *name)
Definition: customdata.c:2637
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
Definition: customdata.c:2620
@ G_DEBUG_FREESTYLE
Definition: BKE_global.h:140
struct IDProperty * IDP_CopyProperty_ex(const struct IDProperty *prop, const int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void id_us_min(struct ID *id)
Definition: lib_id.c:297
void id_us_plus(struct ID *id)
Definition: lib_id.c:288
struct Main * BKE_main_new(void)
Definition: main.c:45
void BKE_main_free(struct Main *mainvar)
Definition: main.c:53
General operations, lookup, etc. for materials.
void BKE_object_materials_test(struct Main *bmain, struct Object *ob, struct ID *id)
Definition: material.c:772
struct Material * BKE_material_add(struct Main *bmain, const char *name)
Definition: material.c:301
struct Mesh * BKE_mesh_add(struct Main *bmain, const char *name)
Definition: mesh.c:849
void BKE_mesh_update_customdata_pointers(struct Mesh *me, const bool do_ensure_tess_cd)
Definition: mesh.c:766
bool BKE_mesh_validate(struct Mesh *me, const bool do_verbose, const bool cddata_check_mask)
#define SH_NODE_MIX_SHADER
Definition: BKE_node.h:999
#define SH_NODE_UVMAP
Definition: BKE_node.h:1052
void nodeRemSocketLinks(struct bNodeTree *ntree, struct bNodeSocket *sock)
Definition: node.cc:2348
#define SH_NODE_EMISSION
Definition: BKE_node.h:1009
#define SH_NODE_UVALONGSTROKE
Definition: BKE_node.h:1056
struct bNodeTree * ntreeCopyTree_ex(const struct bNodeTree *ntree, struct Main *bmain, const bool do_id_user)
void ntreeUpdateTree(struct Main *main, struct bNodeTree *ntree)
Definition: node.cc:4262
struct bNodeLink * nodeAddLink(struct bNodeTree *ntree, struct bNode *fromnode, struct bNodeSocket *fromsock, struct bNode *tonode, struct bNodeSocket *tosock)
Definition: node.cc:2189
struct bNodeTree * ntreeAddTree(struct Main *bmain, const char *name, const char *idname)
Definition: node.cc:2529
struct bNode * nodeAddStaticNode(const struct bContext *C, struct bNodeTree *ntree, int type)
Definition: node.cc:2004
void nodeSetActive(struct bNodeTree *ntree, struct bNode *node)
Definition: node.cc:3694
#define SH_NODE_ATTRIBUTE
Definition: BKE_node.h:1000
#define SH_NODE_LIGHT_PATH
Definition: BKE_node.h:1011
General operations, lookup, etc. for blender objects.
struct Object * BKE_object_add_only_object(struct Main *bmain, int type, const char *name) ATTR_NONNULL(1) ATTR_RETURNS_NONNULL
Definition: object.c:2193
struct Object * BKE_object_add(struct Main *bmain, struct ViewLayer *view_layer, int type, const char *name) ATTR_NONNULL(1
void BKE_scene_set_background(struct Main *bmain, struct Scene *sce)
Definition: scene.c:2120
int BKE_render_num_threads(const struct RenderData *r)
struct Scene * BKE_scene_add(struct Main *bmain, const char *name)
Definition: scene.c:2078
void BKE_scene_copy_data_eevee(struct Scene *sce_dst, const struct Scene *sce_src)
#define BLI_assert(a)
Definition: BLI_assert.h:58
void BLI_ghash_insert(GHash *gh, void *key, void *val)
Definition: BLI_ghash.c:756
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
Definition: BLI_ghash.c:1008
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_ghash_lookup(GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
Definition: BLI_ghash.c:803
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:128
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void * BLI_findptr(const struct ListBase *listbase, const void *ptr, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
MINLINE void copy_v3fl_v3db(float r[3], const double a[3])
#define STRNCPY(dst, src)
Definition: BLI_string.h:163
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
Depsgraph * DEG_graph_new(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, eEvaluationMode mode)
Definition: depsgraph.cc:281
void DEG_graph_id_tag_update(struct Main *bmain, struct Depsgraph *depsgraph, struct ID *id, int flag)
@ DAG_EVAL_RENDER
Definition: DEG_depsgraph.h:62
void DEG_graph_free(Depsgraph *graph)
Definition: depsgraph.cc:314
void DEG_graph_tag_relations_update(struct Depsgraph *graph)
void DEG_relations_tag_update(struct Main *bmain)
void DEG_graph_relations_update(struct Depsgraph *graph)
@ ID_RECALC_TRANSFORM
Definition: DNA_ID.h:599
@ ID_RECALC_ANIMATION
Definition: DNA_ID.h:614
@ ID_RECALC_GEOMETRY
Definition: DNA_ID.h:611
#define MAX_ID_NAME
Definition: DNA_ID.h:269
@ CAM_ORTHO
Object groups, one object can be in many groups at once.
@ CD_MLOOPCOL
@ CD_MVERT
@ CD_MLOOPUV
These structs are the foundation for all linked lists in the library system.
@ MA_BM_HASHED
#define MAXMAT
#define MA_RAMP_BLEND
#define MESH_MAX_VERTS
#define NODE_DO_OUTPUT
Object is a sort of wrapper for general info.
@ OB_CAMERA
@ OB_MESH
#define R_SINGLE_LAYER
#define R_BORDER
@ R_ALPHAPREMUL
#define R_MULTIVIEW
#define SCE_LAY_ZTRA
#define R_IMF_IMTYPE_PNG
#define SCE_LAY_SOLID
#define R_FULL_SAMPLE
#define R_IMF_PLANES_RGBA
#define R_EDGE_FRS
#define R_NO_FRAME_UPDATE
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction SH_NODE_BSDF_TRANSPARENT
Group RGB to Bright Vector Camera Vector Combine Material Light SH_NODE_OUTPUT_LINESTYLE
Group SH_NODE_MIX_RGB
Group RGB to Bright Vector Camera Vector Combine SH_NODE_OUTPUT_MATERIAL
StructRNA RNA_NodeSocket
ATTR_WARN_UNUSED_RESULT const BMVert * v
bool test_triangle_visibility(StrokeVertexRep *svRep[3]) const
vector< StrokeGroup * > texturedStrokeGroups
vector< StrokeGroup * > strokeGroups
Render * RenderScene(Render *re, bool render)
void test_strip_visibility(Strip::vertex_container &strip_vertices, int *visible_faces, int *visible_segments) const
void GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
static Material * GetStrokeShader(Main *bmain, bNodeTree *iNodeTree, bool do_id_user)
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const
BlenderStrokeRenderer(Render *re, int render_count)
unsigned int get_stroke_mesh_id(void) const
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
std::vector< StrokeVertexRep * > vertex_container
Definition: StrokeRep.h:139
bNodeTree * getNodeTree() const
Definition: StrokeRep.h:227
bool hasTex() const
Definition: StrokeRep.h:232
void setMaterial(Material *mat)
Definition: StrokeRep.h:263
vector< Strip * > & getStrips()
Definition: StrokeRep.h:237
Vec2r & texCoord(bool tips=false)
Definition: StrokeRep.h:80
value_type x() const
Definition: VecMat.h:319
value_type y() const
Definition: VecMat.h:329
Value lookup_default(const Key &key, const Value &default_value) const
Definition: BLI_map.hh:524
void add_new(const Key &key, const Value &value)
Definition: BLI_map.hh:234
int64_t size() const
Definition: BLI_map.hh:854
ItemIterator items() const
Definition: BLI_map.hh:825
bool contains(const Key &key) const
Definition: BLI_map.hh:322
OperationNode * node
Material material
bNodeTree * ntree
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
#define L
inherits from class Rep
Definition: AppCanvas.cpp:32
Render * RE_NewSceneRender(const Scene *scene)
Definition: pipeline.c:598
void RNA_pointer_create(ID *id, StructRNA *type, void *data, PointerRNA *r_ptr)
Definition: rna_access.c:146
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
Definition: rna_access.c:6378
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6355
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
Definition: rna_access.c:6366
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
Definition: rna_access.c:6390
float clip_end
float clip_start
float ortho_scale
Definition: DNA_ID.h:273
IDProperty * properties
Definition: DNA_ID.h:314
char name[66]
Definition: DNA_ID.h:283
void * first
Definition: DNA_listBase.h:47
unsigned int v1
unsigned int v2
unsigned char a
unsigned char b
unsigned char r
unsigned char g
unsigned int e
unsigned int v
short mat_nr
float co[3]
short no[3]
Definition: BKE_main.h:116
ListBase wm
Definition: BKE_main.h:175
struct bNodeTree * nodetree
struct MEdge * medge
struct CustomData pdata ldata
struct MVert * mvert
struct MLoopCol * mloopcol
struct Material ** mat
int totedge
struct MLoopUV * mloopuv
int totvert
struct MLoop * mloop
int totpoly
short totcol
int totloop
struct MPoly * mpoly
void * data
char engine[32]
struct ImageFormatData im_format
char pic[1024]
float dither_intensity
int recty
Definition: render_types.h:97
RenderData r
Definition: render_types.h:113
int winy
Definition: render_types.h:92
struct Main * main
Definition: render_types.h:111
Scene * scene
Definition: render_types.h:112
int rectx
Definition: render_types.h:97
int winx
Definition: render_types.h:92
rcti disprect
Definition: render_types.h:93
struct Collection * master_collection
struct RenderData r
ListBase view_layers
struct Object * camera
ListBase nodes
ListBase links
short custom1
float locy
ListBase inputs
float locx
void * storage
short custom2
ListBase outputs
float xmax
Definition: DNA_vec_types.h:85
float xmin
Definition: DNA_vec_types.h:85
float ymax
Definition: DNA_vec_types.h:86
float ymin
Definition: DNA_vec_types.h:86
int ymin
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
float max
#define G(x, y, z)