diff options
author | Maxime Curioni <maxime.curioni@gmail.com> | 2009-10-07 09:16:23 +0400 |
---|---|---|
committer | Maxime Curioni <maxime.curioni@gmail.com> | 2009-10-07 09:16:23 +0400 |
commit | bae853a8a011cc2a6f339e55fd6f09a0cf61db90 (patch) | |
tree | e3e7e458303ccd7d59012ed1bce37ca8dd6571ce /source | |
parent | 043233943c4d48d2d59bcef18a31c47dfc9031df (diff) |
committed Tamito Kajiyama's RNA and GUI patch for Freestyle integration into Blender 2.5. As of I right now, Freestyle is back in the UI, but rendering still fails because of the texture manager.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/editors/render/SConscript | 2 | ||||
-rw-r--r-- | source/blender/editors/render/render_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/render/render_ops.c | 4 | ||||
-rw-r--r-- | source/blender/editors/render/render_shading.c | 121 | ||||
-rw-r--r-- | source/blender/freestyle/FRS_freestyle.h | 3 | ||||
-rw-r--r-- | source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp | 8 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_freestyle_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 84 |
10 files changed, 223 insertions, 8 deletions
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt index d13d7ce2ff2..bba441fd2a7 100644 --- a/source/blender/editors/CMakeLists.txt +++ b/source/blender/editors/CMakeLists.txt @@ -39,6 +39,7 @@ SET(INC ../windowmanager ../../../intern/audaspace/intern ../nodes ../gpu + ../freestyle ../blenfont ../ikplugin ) diff --git a/source/blender/editors/render/SConscript b/source/blender/editors/render/SConscript index bddc5ed10e0..ab1c0d11691 100644 --- a/source/blender/editors/render/SConscript +++ b/source/blender/editors/render/SConscript @@ -5,7 +5,7 @@ sources = env.Glob('*.c') incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' -incs += ' #/intern/guardedalloc ../../gpu' +incs += ' #/intern/guardedalloc ../../gpu ../../freestyle' incs += ' ../../makesrna ../../render/extern/include #/intern/elbeem/extern' incs += ' ../../blenloader' diff --git a/source/blender/editors/render/render_intern.h b/source/blender/editors/render/render_intern.h index dccc2d36002..e62bc175416 100644 --- a/source/blender/editors/render/render_intern.h +++ b/source/blender/editors/render/render_intern.h @@ -44,6 +44,10 @@ void WORLD_OT_new(struct wmOperatorType *ot); void SCENE_OT_render_layer_add(struct wmOperatorType *ot); void SCENE_OT_render_layer_remove(struct wmOperatorType *ot); +void SCENE_OT_freestyle_module_add(struct wmOperatorType *ot); +void SCENE_OT_freestyle_module_remove(struct wmOperatorType *ot); +void SCENE_OT_freestyle_module_move_up(struct wmOperatorType *ot); +void SCENE_OT_freestyle_module_move_down(struct wmOperatorType *ot); #endif /* RENDER_INTERN_H */ diff --git a/source/blender/editors/render/render_ops.c b/source/blender/editors/render/render_ops.c index 8b60582d466..7935b4f248b 100644 --- a/source/blender/editors/render/render_ops.c +++ b/source/blender/editors/render/render_ops.c @@ -50,5 +50,9 @@ void ED_operatortypes_render(void) WM_operatortype_append(SCENE_OT_render_layer_add); WM_operatortype_append(SCENE_OT_render_layer_remove); + WM_operatortype_append(SCENE_OT_freestyle_module_add); + WM_operatortype_append(SCENE_OT_freestyle_module_remove); + WM_operatortype_append(SCENE_OT_freestyle_module_move_up); + WM_operatortype_append(SCENE_OT_freestyle_module_move_down); } diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 56605ad0970..815bc8cee0b 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -58,6 +58,8 @@ #include "GPU_material.h" +#include "FRS_freestyle.h" + #include "RNA_access.h" #include "RNA_enum_types.h" @@ -643,3 +645,122 @@ void SCENE_OT_render_layer_remove(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; } +static int freestyle_module_add_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + + printf("freestyle_module_add_exec\n"); + FRS_add_module(); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_module_add(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Add Freestyle Module"; + ot->idname= "SCENE_OT_freestyle_module_add"; + ot->description="Add a style module into the list of modules."; + + /* api callbacks */ + ot->exec= freestyle_module_add_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int freestyle_module_remove_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); + FreestyleModuleConfig *module= ptr.data; + + printf("freestyle_module_remove_exec\n"); + FRS_delete_module(module, NULL); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_module_remove(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Remove Freestyle Module"; + ot->idname= "SCENE_OT_freestyle_module_remove"; + ot->description="Remove the style module from the stack."; + + /* api callbacks */ + ot->exec= freestyle_module_remove_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; +} + +static int freestyle_module_move_up_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); + FreestyleModuleConfig *module= ptr.data; + int active = RNA_boolean_get(op->ptr, "active"); + + printf("freestyle_module_move_up_exec\n"); + if(active) + FRS_move_up_module(module, NULL); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_module_move_up(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Move Up Freestyle Module"; + ot->idname= "SCENE_OT_freestyle_module_move_up"; + ot->description="Move the style module up in the stack."; + + /* api callbacks */ + ot->exec= freestyle_module_move_up_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* props */ + RNA_def_boolean(ot->srna, "active", 0, "Active", "True if the operator is enabled."); +} + +static int freestyle_module_move_down_exec(bContext *C, wmOperator *op) +{ + Scene *scene= CTX_data_scene(C); + PointerRNA ptr= CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings); + FreestyleModuleConfig *module= ptr.data; + int active = RNA_boolean_get(op->ptr, "active"); + + printf("freestyle_module_move_down_exec\n"); + if(active) + FRS_move_down_module(module, NULL); + + WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, scene); + + return OPERATOR_FINISHED; +} + +void SCENE_OT_freestyle_module_move_down(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Move Down Freestyle Module"; + ot->idname= "SCENE_OT_freestyle_module_move_down"; + ot->description="Move the style module down in the stack."; + + /* api callbacks */ + ot->exec= freestyle_module_move_down_exec; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* props */ + RNA_def_boolean(ot->srna, "active", 0, "Active", "True if the operator is enabled."); +} diff --git a/source/blender/freestyle/FRS_freestyle.h b/source/blender/freestyle/FRS_freestyle.h index 9d20c2c4763..96696b9cc1f 100644 --- a/source/blender/freestyle/FRS_freestyle.h +++ b/source/blender/freestyle/FRS_freestyle.h @@ -1,9 +1,6 @@ #ifndef FRS_FREESTYLE_H #define FRS_FREESTYLE_H -#define FREESTYLE_SUGGESTIVE_CONTOURS_FLAG 1 -#define FREESTYLE_RIDGES_AND_VALLEYS_FLAG 2 - #ifdef __cplusplus extern "C" { #endif diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index 74c9e377a15..6346c05b0d6 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -295,22 +295,22 @@ extern "C" { void FRS_delete_module(void *module_index_ptr, void *unused) { - FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr); + FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) module_index_ptr; BLI_freelinkN( freestyle_modules, module_conf); } void FRS_move_up_module(void *module_index_ptr, void *unused) { - FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr); - + FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) module_index_ptr; + BLI_remlink(freestyle_modules, module_conf); BLI_insertlink(freestyle_modules, module_conf->prev->prev, module_conf); } void FRS_move_down_module(void *module_index_ptr, void *unused) { - FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) BLI_findlink(freestyle_modules, (intptr_t)module_index_ptr); + FreestyleModuleConfig* module_conf = (FreestyleModuleConfig*) module_index_ptr; BLI_remlink(freestyle_modules, module_conf); BLI_insertlink(freestyle_modules, module_conf->next, module_conf); diff --git a/source/blender/makesdna/DNA_freestyle_types.h b/source/blender/makesdna/DNA_freestyle_types.h index 14c59d5adb2..fb07f33b533 100644 --- a/source/blender/makesdna/DNA_freestyle_types.h +++ b/source/blender/makesdna/DNA_freestyle_types.h @@ -3,6 +3,9 @@ #include "DNA_listBase.h" +#define FREESTYLE_SUGGESTIVE_CONTOURS_FLAG 1 +#define FREESTYLE_RIDGES_AND_VALLEYS_FLAG 2 + typedef struct FreestyleModuleConfig { struct FreestyleModuleConfig *next, *prev; diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 9ea7725b855..05a17f5eefd 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -203,6 +203,7 @@ extern StructRNA RNA_FluidFluidSettings; extern StructRNA RNA_FluidSettings; extern StructRNA RNA_FluidSimulationModifier; extern StructRNA RNA_FollowPathConstraint; +extern StructRNA RNA_FreestyleModuleSettings; extern StructRNA RNA_Function; extern StructRNA RNA_GameBooleanProperty; extern StructRNA RNA_GameFloatProperty; diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 9eea920e371..c1d2cd802ec 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -711,6 +711,12 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); + prop= RNA_def_property(srna, "freestyle", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_FRS); + RNA_def_property_ui_text(prop, "Freestyle", "Render stylized strokes in this Layer."); + if(scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + else RNA_def_property_clear_flag(prop, PROP_EDITABLE); + /* passes */ prop= RNA_def_property(srna, "pass_combined", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_COMBINED); @@ -827,6 +833,62 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) else RNA_def_property_clear_flag(prop, PROP_EDITABLE); } +static void rna_def_freestyle_settings(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + /* FreestyleModuleSettings */ + + srna= RNA_def_struct(brna, "FreestyleModuleSettings", NULL); + RNA_def_struct_sdna(srna, "FreestyleModuleConfig"); + RNA_def_struct_ui_text(srna, "Freestyle Module", "Style module configuration for specifying a style module."); + + prop= RNA_def_property(srna, "module_path", PROP_STRING, PROP_FILEPATH); + RNA_def_property_string_sdna(prop, NULL, "module_path"); + RNA_def_property_ui_text(prop, "Module Path", "Path to a style module file."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "is_displayed", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "is_displayed", 1); + RNA_def_property_ui_text(prop, "Is Displayed", "Enable this style module during the rendering."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + /* FreestyleSettings */ + + srna= RNA_def_struct(brna, "FreestyleSettings", NULL); + RNA_def_struct_sdna(srna, "FreestyleConfig"); + RNA_def_struct_nested(brna, srna, "SceneRenderLayer"); + RNA_def_struct_ui_text(srna, "Frestyle Settings", "Freestyle settings for a SceneRenderLayer datablock."); + + prop= RNA_def_property(srna, "modules", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "modules", NULL); + RNA_def_property_struct_type(prop, "FreestyleModuleSettings"); + RNA_def_property_ui_text(prop, "Style modules", "A list of style modules (to be applied from top to bottom)."); + + prop= RNA_def_property(srna, "suggestive_contours", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_SUGGESTIVE_CONTOURS_FLAG); + RNA_def_property_ui_text(prop, "Suggestive Contours", "Enable suggestive contours."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "ridges_and_valleys", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", FREESTYLE_RIDGES_AND_VALLEYS_FLAG); + RNA_def_property_ui_text(prop, "Ridges and Valleys", "Enable ridges and valleys."); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "sphere_radius", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "sphere_radius"); + RNA_def_property_range(prop, 0.0, 1000.0); + RNA_def_property_ui_text(prop, "Sphere Radius", "*TBD*"); + RNA_def_property_update(prop, NC_SCENE, NULL); + + prop= RNA_def_property(srna, "dkr_epsilon", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "dkr_epsilon"); + RNA_def_property_range(prop, 0.0, 1000.0); + RNA_def_property_ui_text(prop, "Dkr Epsilon", "*TBD*"); + RNA_def_property_update(prop, NC_SCENE, NULL); +} + static void rna_def_scene_game_data(BlenderRNA *brna) { StructRNA *srna; @@ -1115,11 +1177,22 @@ static void rna_def_scene_game_data(BlenderRNA *brna) static void rna_def_scene_render_layer(BlenderRNA *brna) { StructRNA *srna; + PropertyRNA *prop; srna= RNA_def_struct(brna, "SceneRenderLayer", NULL); RNA_def_struct_ui_text(srna, "Scene Render Layer", "Render layer."); rna_def_render_layer_common(srna, 1); + + /* Freestyle */ + + rna_def_freestyle_settings(brna); + + prop= RNA_def_property(srna, "freestyle_settings", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "freestyleConfig"); + RNA_def_property_struct_type(prop, "FreestyleSettings"); + RNA_def_property_ui_text(prop, "Freestyle Settings", ""); } static void rna_def_scene_render_data(BlenderRNA *brna) @@ -1714,6 +1787,11 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Edge Color", ""); RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + prop= RNA_def_property(srna, "freestyle", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE_FRS); + RNA_def_property_ui_text(prop, "Edge", "Draw stylized strokes using Freestyle."); + RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + prop= RNA_def_property(srna, "threads", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "threads"); RNA_def_property_range(prop, 1, 8); @@ -2244,6 +2322,12 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "GreasePencil"); RNA_def_property_ui_text(prop, "Grease Pencil Data", "Grease Pencil datablock"); + + /* Freestyle */ + prop= RNA_def_property(srna, "freestyle_current_layer_number", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "freestyle_current_layer_number"); + RNA_def_property_ui_text(prop, "Freestyle Current Layer Number", "Number of current layers in Freestyle."); + RNA_def_property_update(prop, NC_SCENE, NULL); /* Nestled Data */ rna_def_tool_settings(brna); |