Changeset View
Changeset View
Standalone View
Standalone View
source/blender/modifiers/intern/MOD_subsurf.c
| Show First 20 Lines • Show All 333 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| /* Don't show adaptive options if cycles isn't the active engine. */ | /* Don't show adaptive options if cycles isn't the active engine. */ | ||||
| const struct RenderEngineType *engine_type = CTX_data_engine_type(C); | const struct RenderEngineType *engine_type = CTX_data_engine_type(C); | ||||
| if (!STREQ(engine_type->idname, "CYCLES")) { | if (!STREQ(engine_type->idname, "CYCLES")) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* Only show adaptive options if this is the last modifier. */ | /* Only show adaptive options if this is the last modifier. */ | ||||
| PointerRNA md_ptr; | PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL); | ||||
| modifier_panel_get_property_pointers(C, panel, NULL, &md_ptr); | ModifierData *md = ptr->data; | ||||
| ModifierData *md = md_ptr.data; | |||||
| if (md->next != NULL) { | if (md->next != NULL) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| /* Don't show adaptive options if the cycles experimental feature set is disabled. */ | /* Don't show adaptive options if the cycles experimental feature set is disabled. */ | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| PointerRNA scene_ptr; | PointerRNA scene_ptr; | ||||
| RNA_id_pointer_create(&scene->id, &scene_ptr); | RNA_id_pointer_create(&scene->id, &scene_ptr); | ||||
| if (BKE_scene_uses_cycles(scene)) { | if (BKE_scene_uses_cycles(scene)) { | ||||
| PointerRNA cycles_ptr = RNA_pointer_get(&scene_ptr, "cycles"); | PointerRNA cycles_ptr = RNA_pointer_get(&scene_ptr, "cycles"); | ||||
| if (RNA_enum_get(&cycles_ptr, "feature_set") != 1) { /* EXPERIMENTAL */ | if (RNA_enum_get(&cycles_ptr, "feature_set") != 1) { /* EXPERIMENTAL */ | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| #endif | #endif | ||||
| static void panel_draw(const bContext *C, Panel *panel) | static void panel_draw(const bContext *C, Panel *panel) | ||||
| { | { | ||||
| uiLayout *layout = panel->layout; | uiLayout *layout = panel->layout; | ||||
| PointerRNA ptr; | |||||
| PointerRNA ob_ptr; | PointerRNA ob_ptr; | ||||
| modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr); | PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); | ||||
| /* Only test for adaptive subdivision if built with cycles. */ | /* Only test for adaptive subdivision if built with cycles. */ | ||||
| bool show_adaptive_options = false; | bool show_adaptive_options = false; | ||||
| bool ob_use_adaptive_subdivision = false; | bool ob_use_adaptive_subdivision = false; | ||||
| PointerRNA cycles_ptr = {NULL}; | PointerRNA cycles_ptr = {NULL}; | ||||
| PointerRNA ob_cycles_ptr = {NULL}; | PointerRNA ob_cycles_ptr = {NULL}; | ||||
| #ifdef WITH_CYCLES | #ifdef WITH_CYCLES | ||||
| PointerRNA scene_ptr; | PointerRNA scene_ptr; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| RNA_id_pointer_create(&scene->id, &scene_ptr); | RNA_id_pointer_create(&scene->id, &scene_ptr); | ||||
| if (BKE_scene_uses_cycles(scene)) { | if (BKE_scene_uses_cycles(scene)) { | ||||
| cycles_ptr = RNA_pointer_get(&scene_ptr, "cycles"); | cycles_ptr = RNA_pointer_get(&scene_ptr, "cycles"); | ||||
| ob_cycles_ptr = RNA_pointer_get(&ob_ptr, "cycles"); | ob_cycles_ptr = RNA_pointer_get(&ob_ptr, "cycles"); | ||||
| if (!RNA_pointer_is_null(&ob_cycles_ptr)) { | if (!RNA_pointer_is_null(&ob_cycles_ptr)) { | ||||
| ob_use_adaptive_subdivision = RNA_boolean_get(&ob_cycles_ptr, "use_adaptive_subdivision"); | ob_use_adaptive_subdivision = RNA_boolean_get(&ob_cycles_ptr, "use_adaptive_subdivision"); | ||||
| show_adaptive_options = get_show_adaptive_options(C, panel); | show_adaptive_options = get_show_adaptive_options(C, panel); | ||||
| } | } | ||||
| } | } | ||||
| #else | |||||
| UNUSED_VARS(C); | |||||
| #endif | #endif | ||||
| uiItemR(layout, &ptr, "subdivision_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); | uiItemR(layout, ptr, "subdivision_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| if (show_adaptive_options) { | if (show_adaptive_options) { | ||||
| uiItemR(layout, | uiItemR(layout, | ||||
| &ob_cycles_ptr, | &ob_cycles_ptr, | ||||
| "use_adaptive_subdivision", | "use_adaptive_subdivision", | ||||
| 0, | 0, | ||||
| Show All 9 Lines | float preview = MAX2(RNA_float_get(&cycles_ptr, "preview_dicing_rate") * | ||||
| RNA_float_get(&ob_cycles_ptr, "dicing_rate"), | RNA_float_get(&ob_cycles_ptr, "dicing_rate"), | ||||
| 0.1f); | 0.1f); | ||||
| char output[64]; | char output[64]; | ||||
| snprintf(output, 64, "Final Scale: Render %.2f px, Viewport %.2f px", render, preview); | snprintf(output, 64, "Final Scale: Render %.2f px, Viewport %.2f px", render, preview); | ||||
| uiItemL(layout, output, ICON_NONE); | uiItemL(layout, output, ICON_NONE); | ||||
| uiItemS(layout); | uiItemS(layout); | ||||
| uiItemR(layout, &ptr, "levels", 0, IFACE_("Levels Viewport"), ICON_NONE); | uiItemR(layout, ptr, "levels", 0, IFACE_("Levels Viewport"), ICON_NONE); | ||||
| } | } | ||||
| else { | else { | ||||
| uiLayout *col = uiLayoutColumn(layout, true); | uiLayout *col = uiLayoutColumn(layout, true); | ||||
| uiItemR(col, &ptr, "levels", 0, IFACE_("Levels Viewport"), ICON_NONE); | uiItemR(col, ptr, "levels", 0, IFACE_("Levels Viewport"), ICON_NONE); | ||||
| uiItemR(col, &ptr, "render_levels", 0, IFACE_("Render"), ICON_NONE); | uiItemR(col, ptr, "render_levels", 0, IFACE_("Render"), ICON_NONE); | ||||
| } | } | ||||
| uiItemR(layout, &ptr, "show_only_control_edges", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "show_only_control_edges", 0, NULL, ICON_NONE); | ||||
| modifier_panel_end(layout, &ptr); | modifier_panel_end(layout, ptr); | ||||
| } | } | ||||
| static void advanced_panel_draw(const bContext *C, Panel *panel) | static void advanced_panel_draw(const bContext *C, Panel *panel) | ||||
| { | { | ||||
| uiLayout *layout = panel->layout; | uiLayout *layout = panel->layout; | ||||
| PointerRNA ptr; | |||||
| PointerRNA ob_ptr; | PointerRNA ob_ptr; | ||||
| modifier_panel_get_property_pointers(C, panel, &ob_ptr, &ptr); | PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr); | ||||
| bool ob_use_adaptive_subdivision = false; | bool ob_use_adaptive_subdivision = false; | ||||
| bool show_adaptive_options = false; | bool show_adaptive_options = false; | ||||
| #ifdef WITH_CYCLES | #ifdef WITH_CYCLES | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| if (BKE_scene_uses_cycles(scene)) { | if (BKE_scene_uses_cycles(scene)) { | ||||
| PointerRNA ob_cycles_ptr = RNA_pointer_get(&ob_ptr, "cycles"); | PointerRNA ob_cycles_ptr = RNA_pointer_get(&ob_ptr, "cycles"); | ||||
| if (!RNA_pointer_is_null(&ob_cycles_ptr)) { | if (!RNA_pointer_is_null(&ob_cycles_ptr)) { | ||||
| ob_use_adaptive_subdivision = RNA_boolean_get(&ob_cycles_ptr, "use_adaptive_subdivision"); | ob_use_adaptive_subdivision = RNA_boolean_get(&ob_cycles_ptr, "use_adaptive_subdivision"); | ||||
| show_adaptive_options = get_show_adaptive_options(C, panel); | show_adaptive_options = get_show_adaptive_options(C, panel); | ||||
| } | } | ||||
| } | } | ||||
| #else | |||||
| UNUSED_VARS(C); | |||||
| #endif | #endif | ||||
| uiLayoutSetPropSep(layout, true); | uiLayoutSetPropSep(layout, true); | ||||
| uiLayoutSetActive(layout, !(show_adaptive_options && ob_use_adaptive_subdivision)); | uiLayoutSetActive(layout, !(show_adaptive_options && ob_use_adaptive_subdivision)); | ||||
| uiItemR(layout, &ptr, "quality", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "quality", 0, NULL, ICON_NONE); | ||||
| uiItemR(layout, &ptr, "uv_smooth", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "uv_smooth", 0, NULL, ICON_NONE); | ||||
| uiItemR(layout, &ptr, "use_creases", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "use_creases", 0, NULL, ICON_NONE); | ||||
| uiItemR(layout, &ptr, "use_custom_normals", 0, NULL, ICON_NONE); | uiItemR(layout, ptr, "use_custom_normals", 0, NULL, ICON_NONE); | ||||
| } | } | ||||
| static void panelRegister(ARegionType *region_type) | static void panelRegister(ARegionType *region_type) | ||||
| { | { | ||||
| PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Subsurf, panel_draw); | PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Subsurf, panel_draw); | ||||
| modifier_subpanel_register( | modifier_subpanel_register( | ||||
| region_type, "advanced", "Advanced", NULL, advanced_panel_draw, panel_type); | region_type, "advanced", "Advanced", NULL, advanced_panel_draw, panel_type); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines | |||||