17#include "RNA_prototypes.hh"
143 camera->clip_start = 0.1f;
144 camera->clip_end = 100.0f;
151 object_camera->
loc[2] = 1.0f;
210 bNode *output_linestyle =
nullptr;
224 output_linestyle =
node;
232 nullptr, &ma->
id,
"stroke_shader",
"ShaderNodeTree");
238 input_attr_color->
locx = 0.0f;
239 input_attr_color->
locy = -200.0f;
246 mix_rgb_color->
locx = 200.0f;
247 mix_rgb_color->
locy = -200.0f;
253 input_attr_alpha->
locx = 400.0f;
254 input_attr_alpha->
locy = 300.0f;
261 mix_rgb_alpha->
locx = 600.0f;
262 mix_rgb_alpha->
locy = 300.0f;
268 shader_emission->
locx = 400.0f;
269 shader_emission->
locy = -200.0f;
272 input_light_path->
locx = 400.0f;
273 input_light_path->
locy = 100.0f;
276 mix_shader_color->
locx = 600.0f;
277 mix_shader_color->
locy = -100.0f;
280 nullptr, ntree, SH_NODE_BSDF_TRANSPARENT);
281 shader_transparent->
locx = 600.0f;
282 shader_transparent->
locy = 100.0f;
285 mix_shader_alpha->
locx = 800.0f;
286 mix_shader_alpha->
locy = 100.0f;
290 output_material->
locx = 1000.0f;
291 output_material->
locy = 100.0f;
329 if (output_linestyle) {
372 color[0] = color[1] = color[2] =
RNA_float_get(&fromptr,
"default_value");
396 input_uvmap->
locx = node->locx - 200.0f;
397 input_uvmap->
locy = node->locy;
399 if (node->custom1 & 1) {
439 const vector<Strip *> &strips = iStrokeRep->
getStrips();
440 const bool hasTex = iStrokeRep->
hasTex();
441 int totvert = 0, totedge = 0, faces_num = 0, totloop = 0;
442 int visible_faces, visible_segments;
443 for (vector<Strip *>::const_iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
444 Strip::vertex_container &strip_vertices = (*s)->vertices();
448 if (visible_faces == 0) {
452 totvert += visible_faces + visible_segments * 2;
453 totedge += visible_faces * 2 + visible_segments;
454 faces_num += visible_faces;
455 totloop += visible_faces * 3;
461 if (groups->empty() || !(groups->back()->totvert + totvert <
MESH_MAX_VERTS &&
462 groups->back()->materials.size() + 1 <
MAXMAT))
465 groups->push_back(group);
468 group = groups->back();
470 group->
strokes.push_back(iStrokeRep);
471 group->totvert += totvert;
472 group->totedge += totedge;
473 group->faces_num += faces_num;
474 group->totloop += totloop;
476 if (!group->materials.contains(ma)) {
477 group->materials.add_new(ma, group->materials.size());
487 xl = xu = yl = yu = 0;
488 for (
int i = 0; i < 3; i++) {
503 return !(xl == 3 || xu == 3 || yl == 3 || yu == 3);
509 int *visible_segments)
const
511 const int strip_vertex_count = strip_vertices.size();
512 Strip::vertex_container::iterator
v[3];
519 v[0] = strip_vertices.begin();
522 *visible_faces = *visible_segments = 0;
524 for (
int n = 2; n < strip_vertex_count; n++,
v[0]++,
v[1]++,
v[2]++) {
531 (*visible_segments)++;
544 vector<StrokeGroup *>::const_iterator it, itend;
557 vector<StrokeGroup *>::const_iterator it, itend;
586 mesh->verts_num = group->totvert;
587 mesh->edges_num = group->totedge;
588 mesh->faces_num = group->faces_num;
589 mesh->corners_num = group->totloop;
590 mesh->totcol = group->materials.size();
627 for (
const auto item : group->materials.items()) {
629 const int matnr = item.value;
640 int vertex_index = 0, edge_index = 0, loop_index = 0, face_index = 0;
641 int visible_faces, visible_segments;
643 Strip::vertex_container::iterator
v[3];
647 for (vector<StrokeRep *>::const_iterator it = group->strokes.begin(),
648 itend = group->strokes.end();
652 const int matnr = group->materials.lookup_default((*it)->getMaterial(), 0);
654 vector<Strip *> &strips = (*it)->getStrips();
655 for (vector<Strip *>::const_iterator s = strips.begin(), send = strips.end(); s != send; ++s) {
656 Strip::vertex_container &strip_vertices = (*s)->vertices();
657 int strip_vertex_count = strip_vertices.size();
661 if (visible_faces == 0) {
665 v[0] = strip_vertices.begin();
673 for (
int n = 2; n < strip_vertex_count; n++,
v[0]++,
v[1]++,
v[2]++) {
683 vert_positions[vertex_index][0] = svRep[0]->
point2d()[0];
684 vert_positions[vertex_index][1] = svRep[0]->
point2d()[1];
690 vert_positions[vertex_index][0] = svRep[1]->
point2d()[0];
691 vert_positions[vertex_index][1] = svRep[1]->
point2d()[1];
697 edges[edge_index][0] = vertex_index - 2;
698 edges[edge_index][1] = vertex_index - 1;
704 vert_positions[vertex_index][0] = svRep[2]->
point2d()[0];
705 vert_positions[vertex_index][1] = svRep[2]->
point2d()[1];
710 edges[edge_index][0] = vertex_index - 1;
711 edges[edge_index][1] = vertex_index - 3;
714 edges[edge_index][0] = vertex_index - 1;
715 edges[edge_index][1] = vertex_index - 2;
719 face_offsets[face_index] = loop_index;
720 *material_indices = matnr;
728 corner_verts[0] = vertex_index - 1;
729 corner_edges[0] = edge_index - 2;
731 corner_verts[1] = vertex_index - 3;
732 corner_edges[1] = edge_index - 3;
734 corner_verts[2] = vertex_index - 2;
735 corner_edges[2] = edge_index - 1;
738 corner_verts[0] = vertex_index - 1;
739 corner_edges[0] = edge_index - 1;
741 corner_verts[1] = vertex_index - 2;
742 corner_edges[1] = edge_index - 3;
744 corner_verts[2] = vertex_index - 3;
745 corner_edges[2] = edge_index - 2;
755 for (
int L = 0;
L < 2;
L++) {
784 for (
int i = 0; i < 3; i++) {
786 rgba[i][3] = svRep[i]->
alpha();
799 transp[0].
r = transp[0].
g = transp[0].
b = colors[0].a;
800 transp[1].
r = transp[1].
g = transp[1].
b = colors[1].a;
801 transp[2].
r = transp[2].
g = transp[2].
b = colors[2].a;
846 if (camera->clip_end <
_z) {
851 cout <<
"clip_start " << camera->clip_start <<
", clip_end " << camera->clip_end << endl;
858 RE_RenderFreestyleStrokes(
861 return freestyle_render;
void BKE_id_attributes_active_color_set(struct ID *id, const char *name)
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
CustomData interface, see also DNA_customdata_types.h.
void * CustomData_add_layer_named(CustomData *data, eCustomDataType type, eCDAllocType alloctype, int totelem, blender::StringRef name)
const char * CustomData_get_layer_name(const CustomData *data, eCustomDataType type, int n)
void CustomData_set_layer_active(CustomData *data, eCustomDataType type, int n)
IDProperty * IDP_CopyProperty_ex(const IDProperty *prop, int flag) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Main * BKE_main_new(void)
void BKE_main_free(Main *bmain)
General operations, lookup, etc. for materials.
void BKE_object_materials_test(struct Main *bmain, struct Object *ob, struct ID *id)
struct Material * BKE_material_add(struct Main *bmain, const char *name)
bool BKE_mesh_validate(Mesh *mesh, bool do_verbose, bool cddata_check_mask)
Mesh * BKE_mesh_add(Main *bmain, const char *name)
void BKE_mesh_face_offsets_ensure_alloc(Mesh *mesh)
#define SH_NODE_MIX_RGB_LEGACY
#define SH_NODE_UVALONGSTROKE
#define SH_NODE_OUTPUT_MATERIAL
#define SH_NODE_OUTPUT_LINESTYLE
void BKE_ntree_update_main_tree(Main *bmain, bNodeTree *ntree, NodeTreeUpdateExtraParams *params)
General operations, lookup, etc. for blender objects.
Object * BKE_object_add(Main *bmain, Scene *scene, ViewLayer *view_layer, int type, const char *name) ATTR_NONNULL(1
Object * BKE_object_add_only_object(Main *bmain, int type, const char *name) ATTR_RETURNS_NONNULL
void BKE_scene_copy_data_eevee(Scene *sce_dst, const Scene *sce_src)
int BKE_render_num_threads(const RenderData *r)
Scene * BKE_scene_add(Main *bmain, const char *name)
void BKE_scene_set_background(Main *bmain, Scene *sce)
GHash * BLI_ghash_ptr_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
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, 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)
#define SNPRINTF(dst, format,...)
Class to define a canvas designed to draw style modules.
Depsgraph * DEG_graph_new(Main *bmain, Scene *scene, ViewLayer *view_layer, eEvaluationMode mode)
void DEG_graph_id_tag_update(Main *bmain, Depsgraph *depsgraph, ID *id, unsigned int flags)
void DEG_graph_free(Depsgraph *graph)
void DEG_relations_tag_update(Main *bmain)
void DEG_graph_tag_relations_update(Depsgraph *graph)
void DEG_graph_relations_update(Depsgraph *graph)
Object groups, one object can be in many groups at once.
These structs are the foundation for all linked lists in the library system.
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
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
static const char * uvNames[]
void GenerateStrokeMesh(StrokeGroup *group, bool hasTex)
virtual ~BlenderStrokeRenderer()
static Material * GetStrokeShader(Main *bmain, bNodeTree *iNodeTree, bool do_id_user)
virtual void RenderStrokeRep(StrokeRep *iStrokeRep) const
uint get_stroke_mesh_id(void) const
float get_stroke_vertex_z(void) const
BlenderStrokeRenderer(Render *re, int render_count)
Depsgraph * freestyle_depsgraph
int get_stroke_count() const
struct GHash * _nodetree_hash
virtual void RenderStrokeRepBasic(StrokeRep *iStrokeRep) const
void setMaterial(Material *mat)
vector< Strip * > & getStrips()
bNodeTree * getNodeTree() const
Vec2r & texCoord(bool tips=false)
void *(* MEM_mallocN)(size_t len, const char *str)
bNodeTree * node_tree_copy_tree_ex(const bNodeTree *ntree, Main *bmain, bool do_id_user)
void node_set_active(bNodeTree *ntree, bNode *node)
void node_remove_socket_links(bNodeTree *ntree, bNodeSocket *sock)
bNode * node_add_static_node(const bContext *C, bNodeTree *ntree, int type)
bNodeLink * node_add_link(bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock)
bNodeTree * node_tree_add_tree_embedded(Main *bmain, ID *owner_id, const char *name, const char *idname)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
float RNA_float_get(PointerRNA *ptr, const char *name)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
Render * RE_NewSceneRender(const Scene *scene)
vector< StrokeRep * > strokes
struct bNodeTree * nodetree
struct ImageFormatData im_format
struct Collection * master_collection