bake operator and UI, no feedback while baking yet
This commit is contained in:
@@ -547,8 +547,42 @@ class RENDER_PT_stamp(RenderButtonsPanel):
|
||||
sub.prop(rd, "stamp_note_text", text="")
|
||||
|
||||
|
||||
bpy.types.register(RENDER_MT_presets)
|
||||
class RENDER_PT_bake(RenderButtonsPanel):
|
||||
bl_label = "Bake"
|
||||
bl_default_closed = True
|
||||
COMPAT_ENGINES = {'BLENDER_RENDER'}
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
rd = context.scene.render_data
|
||||
wide_ui = context.region.width > narrowui
|
||||
|
||||
row = layout.row()
|
||||
row.operator("object.bake_image", icon='RENDER_STILL')
|
||||
row.prop(rd, "bake_type", text="")
|
||||
|
||||
col = layout.column()
|
||||
col.active = (rd.bake_type == 'NORMALS')
|
||||
col.prop(rd, "bake_normal_space")
|
||||
# col.prop(rd, "bake_aa_mode")
|
||||
# col.prop(rd, "bake_enable_aa")
|
||||
|
||||
col = layout.column()
|
||||
row = col.row(align=True)
|
||||
row.prop(rd, "bake_active")
|
||||
row.prop(rd, "bake_normalized")
|
||||
|
||||
row = col.row(align=True)
|
||||
row.prop(rd, "bake_clear")
|
||||
row.prop(rd, "bake_margin")
|
||||
|
||||
row = col.row(align=True)
|
||||
row.prop(rd, "bake_distance")
|
||||
row.prop(rd, "bake_bias")
|
||||
|
||||
|
||||
bpy.types.register(RENDER_MT_presets)
|
||||
bpy.types.register(RENDER_PT_render)
|
||||
bpy.types.register(RENDER_PT_layers)
|
||||
bpy.types.register(RENDER_PT_dimensions)
|
||||
@@ -559,3 +593,4 @@ bpy.types.register(RENDER_PT_encoding)
|
||||
bpy.types.register(RENDER_PT_performance)
|
||||
bpy.types.register(RENDER_PT_post_processing)
|
||||
bpy.types.register(RENDER_PT_stamp)
|
||||
bpy.types.register(RENDER_PT_bake)
|
||||
|
||||
@@ -85,6 +85,8 @@ int *mesh_get_x_mirror_faces(struct Object *ob, struct EditMesh *em);
|
||||
int join_mesh_exec(struct bContext *C, struct wmOperator *op);
|
||||
int join_mesh_shapes_exec(struct bContext *C, struct wmOperator *op);
|
||||
|
||||
void objects_bake_render(struct Scene *scene, short event, char **error_msg);
|
||||
|
||||
/* mesh_ops.c */
|
||||
void ED_operatortypes_mesh(void);
|
||||
void ED_operatormacros_mesh(void);
|
||||
|
||||
@@ -1197,7 +1197,7 @@ void objects_bake_render(Scene *scene, short event, char **error_msg)
|
||||
if(event>0) {
|
||||
bScreen *screen= NULL; // XXX CTX
|
||||
Render *re= RE_NewRender("_Bake View_");
|
||||
ScrArea *area= biggest_image_area(screen);
|
||||
ScrArea *area= NULL; //biggest_image_area(screen); // XXX
|
||||
ListBase threads;
|
||||
BakeRender bkr;
|
||||
int timer=0, tot; // XXX, sculptmode= G.f & G_SCULPTMODE;
|
||||
|
||||
@@ -1671,8 +1671,34 @@ void OBJECT_OT_shade_smooth(wmOperatorType *ot)
|
||||
/* flags */
|
||||
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
|
||||
}
|
||||
/* bake */
|
||||
|
||||
static int bake_image_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
char *error_msg= NULL;
|
||||
objects_bake_render(scene, 0, &error_msg);
|
||||
|
||||
if(error_msg) {
|
||||
BKE_report(op->reports, RPT_ERROR, error_msg);
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else {
|
||||
WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
void OBJECT_OT_bake_image(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Bake";
|
||||
ot->description= "Bake selected objects.";
|
||||
ot->idname= "OBJECT_OT_bake_image";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec= bake_image_exec;
|
||||
}
|
||||
|
||||
/* ********************** */
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ void OBJECT_OT_restrictview_clear(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_proxy_make(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_shade_smooth(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_shade_flat(struct wmOperatorType *ot);
|
||||
void OBJECT_OT_bake_image(struct wmOperatorType *ot);
|
||||
|
||||
/* object_select.c */
|
||||
void OBJECT_OT_select_all(struct wmOperatorType *ot);
|
||||
|
||||
@@ -81,6 +81,7 @@ void ED_operatortypes_object(void)
|
||||
WM_operatortype_append(OBJECT_OT_restrictview_set);
|
||||
WM_operatortype_append(OBJECT_OT_shade_smooth);
|
||||
WM_operatortype_append(OBJECT_OT_shade_flat);
|
||||
WM_operatortype_append(OBJECT_OT_bake_image);
|
||||
|
||||
WM_operatortype_append(OBJECT_OT_parent_set);
|
||||
WM_operatortype_append(OBJECT_OT_parent_no_inverse_set);
|
||||
|
||||
Reference in New Issue
Block a user