25 #include "../application/AppCanvas.h"
26 #include "../application/AppConfig.h"
27 #include "../application/AppView.h"
28 #include "../application/Controller.h"
68 #define DEFAULT_SPHERE_RADIUS 1.0f
69 #define DEFAULT_DKR_EPSILON 0.0f
125 cout <<
"FRS_set_context: context 0x" <<
C <<
" scene 0x" <<
CTX_data_scene(
C) << endl;
150 float thickness = 1.0f;
156 thickness =
height / 480.0f;
170 cout <<
"\n=== Dimensions of the 2D image coordinate system ===" << endl;
171 cout <<
"Width : " <<
width << endl;
172 cout <<
"Height : " <<
height << endl;
174 cout <<
"Border : (" << xmin <<
", " << ymin <<
") - (" << xmax <<
", " << ymax <<
")"
177 cout <<
"Unit line thickness : " << thickness <<
" pixel(s)" << endl;
183 char *s = (
char *)
MEM_mallocN(strlen(name) * 2 + 1,
"escape_quotes");
197 const char *fmt =
"__import__('parameter_editor').process('%s', '%s')\n";
217 int target_condition = 0;
218 int num_non_target_positive_conditions = 0;
219 int num_non_target_negative_conditions = 0;
221 for (
int i = 0; i < num_edge_types; i++) {
222 if (conditions[i].edge_type == target) {
223 target_condition = conditions[i].
value;
225 else if (conditions[i].value > 0) {
226 ++num_non_target_positive_conditions;
228 else if (conditions[i].value < 0) {
229 ++num_non_target_negative_conditions;
236 if (num_non_target_positive_conditions > 0) {
239 if (target_condition > 0) {
242 if (target_condition < 0) {
245 if (num_non_target_negative_conditions > 0) {
250 if (target_condition > 0) {
253 if (num_non_target_negative_conditions > 0) {
256 if (target_condition < 0) {
259 if (num_non_target_positive_conditions > 0) {
266 if (target_condition > 0) {
269 if (target_condition < 0) {
273 if (num_non_target_positive_conditions > 0) {
276 if (num_non_target_negative_conditions > 0) {
281 if (num_non_target_negative_conditions > 0) {
284 if (num_non_target_positive_conditions > 0) {
310 cout <<
"\n=== Rendering options ===" << endl;
314 switch (config->
mode) {
317 cout <<
"Modules :" << endl;
321 module_conf = module_conf->next) {
322 if (module_conf->script && module_conf->is_displayed) {
323 const char *
id_name = module_conf->script->id.name + 2;
325 cout <<
" " << layer_count + 1 <<
": " <<
id_name;
326 if (module_conf->script->filepath) {
327 cout <<
" (" << module_conf->script->filepath <<
")";
347 int use_ridges_and_valleys = 0;
348 int use_suggestive_contours = 0;
349 int use_material_boundaries = 0;
363 cout <<
"Linesets:" << endl;
366 lineset = lineset->next) {
369 cout <<
" " << layer_count + 1 <<
": " << lineset->name <<
" - "
370 << (lineset->linestyle ? (lineset->linestyle->id.name + 2) :
"<NULL>") << endl;
377 ++use_ridges_and_valleys;
378 ++use_suggestive_contours;
379 ++use_material_boundaries;
383 for (
int i = 0; i < num_edge_types; i++) {
384 if (!(lineset->edge_types & conditions[i].
edge_type)) {
385 conditions[i].
value = 0;
387 else if (!(lineset->exclude_edge_types & conditions[i].
edge_type)) {
388 conditions[i].
value = 1;
391 conditions[i].
value = -1;
402 for (
int i = 0; i < num_edge_types; i++) {
403 conditions[i].
value *= -1;
405 logical_and = !logical_and;
409 ++use_ridges_and_valleys;
416 ++use_suggestive_contours;
423 ++use_material_boundaries;
455 cout <<
"Ridges and valleys : "
457 cout <<
"Suggestive contours : "
459 cout <<
"Suggestive contour Kr derivative epsilon : "
461 cout <<
"Material boundaries : "
468 bool diffuse =
false,
z =
false;
480 cout <<
"Passes :" << endl;
481 cout <<
" Diffuse = " << (diffuse ?
"enabled" :
"disabled") << endl;
482 cout <<
" Z = " << (
z ?
"enabled" :
"disabled") << endl;
499 float *src, *dest, *pixSrc, *pixDest;
500 int x,
y, rectx, recty;
502 if (freestyle_render ==
nullptr || freestyle_render->
result ==
nullptr) {
514 cout <<
"No source render layer to composite" << endl;
522 cout <<
"No source result image to composite" << endl;
528 cout <<
"src: " << rl->
rectx <<
" x " << rl->
recty << endl;
535 cout <<
"No destination render layer to composite to" << endl;
550 cout <<
"No destination result image to composite to" << endl;
556 cout <<
"dest: " << rl->
rectx <<
" x " << rl->
recty << endl;
562 for (
y = 0;
y < recty;
y++) {
563 for (
x = 0;
x < rectx;
x++) {
564 pixSrc = src + 4 * (rectx *
y +
x);
565 if (pixSrc[3] > 0.0) {
566 pixDest = dest + 4 * (rectx *
y +
x);
592 lineset = lineset->next) {
612 cout <<
"#===============================================================" << endl;
613 cout <<
"# Freestyle" << endl;
614 cout <<
"#===============================================================" << endl;
635 cout <<
"----------------------------------------------------------" << endl;
636 cout <<
"| " << (re->
scene->
id.
name + 2) <<
"|" << view_layer->
name << endl;
637 cout <<
"----------------------------------------------------------" << endl;
665 cout <<
"Break" << endl;
677 Render *freestyle_render =
nullptr;
678 if (strokeCount > 0) {
686 if (freestyle_render) {
707 printf(
"View map cache freed\n");
758 if (lineset->
group) {
760 lineset->
group =
nullptr;
796 Material *ma = BlenderStrokeRenderer::GetStrokeShader(bmain, nt,
true);
void BKE_callback_add(bCallbackFuncStore *funcstore, eCbEvent evt)
struct Scene * CTX_data_scene(const bContext *C)
bool BKE_freestyle_lineset_delete(struct FreestyleConfig *config, struct FreestyleLineSet *lineset)
void BKE_freestyle_lineset_unique_name(struct FreestyleConfig *config, struct FreestyleLineSet *lineset)
struct FreestyleLineSet * BKE_freestyle_lineset_get_active(struct FreestyleConfig *config)
void id_us_min(struct ID *id)
void id_us_plus(struct ID *id)
Blender kernel freestyle line style functionality.
void BKE_scene_graph_update_for_newframe(struct Depsgraph *depsgraph)
void * BLI_findstring(const struct ListBase *listbase, const char *id, const int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void void void bool BLI_listbase_link_move(ListBase *listbase, void *vlink, int step) ATTR_NONNULL()
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
void unit_m4(float m[4][4])
MINLINE void zero_v3(float r[3])
size_t size_t char * BLI_sprintfN(const char *__restrict format,...) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_PRINTF_FORMAT(1
Depsgraph * DEG_graph_new(struct Main *bmain, struct Scene *scene, struct ViewLayer *view_layer, eEvaluationMode mode)
struct Depsgraph Depsgraph
void DEG_graph_free(Depsgraph *graph)
struct Object * DEG_get_evaluated_object(const struct Depsgraph *depsgraph, struct Object *object)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
Object groups, one object can be in many groups at once.
@ FREESTYLE_CONTROL_EDITOR_MODE
@ FREESTYLE_CONTROL_SCRIPT_MODE
@ FREESTYLE_FE_SILHOUETTE
@ FREESTYLE_FE_RIDGE_VALLEY
@ FREESTYLE_FE_EXTERNAL_CONTOUR
@ FREESTYLE_FE_SUGGESTIVE_CONTOUR
@ FREESTYLE_FE_MATERIAL_BOUNDARY
@ FREESTYLE_LINESET_FE_AND
@ FREESTYLE_LINESET_ENABLED
@ FREESTYLE_LINESET_CURRENT
@ FREESTYLE_LINESET_FE_NOT
@ FREESTYLE_SEL_EDGE_TYPES
@ FREESTYLE_FACE_SMOOTHNESS_FLAG
@ FREESTYLE_MATERIAL_BOUNDARIES_FLAG
@ FREESTYLE_ADVANCED_OPTIONS_FLAG
@ FREESTYLE_RIDGES_AND_VALLEYS_FLAG
@ FREESTYLE_VIEW_MAP_CACHE
@ FREESTYLE_SUGGESTIVE_CONTOURS_FLAG
@ FREESTYLE_AS_RENDER_PASS
@ FREESTYLE_ALGO_CULLED_ADAPTIVE_CUMULATIVE
@ FREESTYLE_ALGO_ADAPTIVE_CUMULATIVE
#define RE_PASSNAME_COMBINED
#define R_LINE_THICKNESS_ABSOLUTE
#define RE_PASSNAME_DIFFUSE_COLOR
#define RE_PASSNAME_FREESTYLE
#define R_LINE_THICKNESS_RELATIVE
#define DEFAULT_DKR_EPSILON
void FRS_paste_active_lineset(FreestyleConfig *config)
void FRS_end_stroke_rendering(Render *)
static bool test_edge_type_conditions(struct edge_type_condition *conditions, int num_edge_types, bool logical_and, int target, bool distinct)
struct FreestyleGlobals g_freestyle
static void prepare(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
void FRS_composite_result(Render *re, ViewLayer *view_layer, Render *freestyle_render)
int FRS_is_freestyle_enabled(ViewLayer *view_layer)
#define DEFAULT_SPHERE_RADIUS
static void init_view(Render *re)
static char * escape_quotes(char *name)
static bool lineset_copied
static int displayed_layer_count(ViewLayer *view_layer)
bool FRS_move_active_lineset(FreestyleConfig *config, int direction)
void FRS_delete_active_lineset(FreestyleConfig *config)
static bCallbackFuncStore load_post_callback_funcstore
static void load_post_callback(struct Main *, struct PointerRNA **, const int, void *)
void FRS_begin_stroke_rendering(Render *UNUSED(re))
void FRS_init_stroke_renderer(Render *re)
void FRS_free_view_map_cache(void)
static char * create_lineset_handler(char *layer_name, char *lineset_name)
void FRS_set_context(bContext *C)
static Controller * controller
Material * FRS_create_stroke_material(Main *bmain, struct FreestyleLineStyle *linestyle)
static bool freestyle_is_initialized
static Config::Path * pathconfig
void FRS_do_stroke_rendering(Render *re, ViewLayer *view_layer)
void FRS_copy_active_lineset(FreestyleConfig *config)
static FreestyleLineSet lineset_buffer
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
Read Guarded memory(de)allocation.
static struct PyModuleDef module
void setHeight(unsigned int height)
void setWidth(unsigned int width)
void setBorder(int xmin, int ymin, int xmax, int ymax)
void setThickness(float thickness)
Render * RenderStrokes(Render *re, bool render)
void setComputeSuggestiveContoursFlag(bool b)
void setPassZ(float *buf, int width, int height)
bool getFaceSmoothness() const
bool getComputeMaterialBoundariesFlag() const
void toggleLayer(unsigned index, bool iDisplay)
void setSphereRadius(float s)
void setComputeMaterialBoundariesFlag(bool b)
void setVisibilityAlgo(int algo)
void setComputeRidgesAndValleysFlag(bool b)
void setFaceSmoothness(bool iBool)
void setPassDiffuse(float *buf, int width, int height)
float getSphereRadius() const
void DeleteViewMap(bool freeCache=false)
int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
bool getComputeSuggestiveContoursFlag() const
void setViewMapCache(bool iBool)
void setContext(bContext *C)
void setSuggestiveContourKrDerivativeEpsilon(float dkr)
void setCreaseAngle(float angle)
float getCreaseAngle() const
void InsertStyleModule(unsigned index, const char *iFileName)
bool getComputeRidgesAndValleysFlag() const
float getSuggestiveContourKrDerivativeEpsilon() const
void setView(AppView *iView)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
std::string id_name(void *id)
FreestyleLineStyle linestyle
const Depsgraph * depsgraph
void RE_GetCameraWindow(struct Render *re, struct Object *camera, float r_winmat[4][4])
struct Object * RE_GetCamera(Render *re)
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
void *(* MEM_mallocN)(size_t len, const char *str)
void RE_FreeRender(Render *re)
float * RE_RenderLayerGetPass(volatile RenderLayer *rl, const char *name, const char *viewname)
RenderLayer * render_get_active_layer(Render *re, RenderResult *rr)
RenderLayer * RE_GetRenderLayer(RenderResult *rr, const char *name)
void RE_create_render_pass(RenderResult *rr, const char *name, int channels, const char *chan_id, const char *layername, const char *viewname)
struct Collection * group
struct FreestyleLineStyle * linestyle
struct bNodeTree * nodetree
float unit_line_thickness
void(* stats_draw)(void *handle, RenderStats *ri)
int(* test_break)(void *handle)
struct FreestyleConfig freestyle_config