Blender  V2.93
Classes | Typedefs | Functions
object_bake_api.c File Reference
#include "MEM_guardedalloc.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "BLI_fileops.h"
#include "BLI_listbase.h"
#include "BLI_path_util.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
#include "BKE_modifier.h"
#include "BKE_node.h"
#include "BKE_object.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "RE_engine.h"
#include "RE_pipeline.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_object.h"
#include "ED_screen.h"
#include "ED_uvedit.h"
#include "object_intern.h"

Go to the source code of this file.

Classes

struct  BakeAPIRender
 

Typedefs

typedef struct BakeAPIRender BakeAPIRender
 

Functions

static void bake_set_props (wmOperator *op, Scene *scene)
 
static void bake_progress_update (void *bjv, float progress)
 
static int bake_modal (bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
 
static int bake_break (void *UNUSED(rjv))
 
static void bake_update_image (ScrArea *area, Image *image)
 
static bool write_internal_bake_pixels (Image *image, BakePixel pixel_array[], float *buffer, const int width, const int height, const int margin, const bool is_clear, const bool is_noncolor)
 
static void bake_targets_refresh (BakeTargets *targets)
 
static bool write_external_bake_pixels (const char *filepath, BakePixel pixel_array[], float *buffer, const int width, const int height, const int margin, ImageFormatData *im_format, const bool is_noncolor)
 
static bool is_noncolor_pass (eScenePassType pass_type)
 
static bool bake_object_check (ViewLayer *view_layer, Object *ob, const eBakeTarget target, ReportList *reports)
 
static bool bake_pass_filter_check (eScenePassType pass_type, const int pass_filter, ReportList *reports)
 
static bool bake_objects_check (Main *bmain, ViewLayer *view_layer, Object *ob, ListBase *selected_objects, ReportList *reports, const bool is_selected_to_active, const eBakeTarget target)
 
static void bake_targets_clear (Main *bmain, const bool is_tangent)
 
static Meshbake_mesh_new_from_object (Depsgraph *depsgraph, Object *object, const bool preserve_origindex)
 
static bool bake_targets_init_image_textures (const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, ReportList *reports)
 
static bool bake_targets_init_internal (const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, ReportList *reports)
 
static bool bake_targets_output_internal (const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, BakePixel *pixel_array, ReportList *reports)
 
static bool bake_targets_init_external (const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, ReportList *reports)
 
static bool bake_targets_output_external (const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, Object *ob_eval, Mesh *me, BakePixel *pixel_array, ReportList *reports)
 
static bool bake_targets_init_vertex_colors (BakeTargets *targets, Object *ob, ReportList *reports)
 
static int find_original_loop (const Mesh *me_orig, const int *vert_origindex, const int *poly_origindex, const int poly_eval, const int vert_eval)
 
static void bake_targets_populate_pixels_vertex_colors (BakeTargets *targets, Object *ob, Mesh *me_eval, BakePixel *pixel_array)
 
static void bake_result_add_to_rgba (float rgba[4], const float *result, const int num_channels)
 
static bool bake_targets_output_vertex_colors (BakeTargets *targets, Object *ob)
 
static bool bake_targets_init (const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, Object *ob_eval, ReportList *reports)
 
static void bake_targets_populate_pixels (const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, Mesh *me_eval, BakePixel *pixel_array)
 
static bool bake_targets_output (const BakeAPIRender *bkr, BakeTargets *targets, Object *ob, Object *ob_eval, Mesh *me_eval, BakePixel *pixel_array, ReportList *reports)
 
static void bake_targets_free (BakeTargets *targets)
 
static int bake (const BakeAPIRender *bkr, Object *ob_low, const ListBase *selected_objects, ReportList *reports)
 
static void bake_init_api_data (wmOperator *op, bContext *C, BakeAPIRender *bkr)
 
static int bake_exec (bContext *C, wmOperator *op)
 
static void bake_startjob (void *bkv, short *UNUSED(stop), short *do_update, float *progress)
 
static void bake_freejob (void *bkv)
 
static int bake_invoke (bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 
void OBJECT_OT_bake (wmOperatorType *ot)
 

Typedef Documentation

◆ BakeAPIRender

typedef struct BakeAPIRender BakeAPIRender

Function Documentation

◆ bake()

static int bake ( const BakeAPIRender bkr,
Object ob_low,
const ListBase selected_objects,
ReportList reports 
)
static

Definition at line 1235 of file object_bake_api.c.

References bake_mesh_new_from_object(), bake_targets_free(), bake_targets_init(), bake_targets_output(), bake_targets_populate_pixels(), bake_targets_refresh(), BASE_ENABLED_RENDER, Object::base_flag, BASE_VISIBLE_DEPSGRAPH, BKE_id_free(), BKE_mesh_new_from_object(), BKE_modifier_free(), BKE_modifiers_findby_type(), BKE_object_eval_reset(), BKE_object_handle_data_update(), BKE_report(), BKE_reportf(), BKE_scene_graph_update_tagged(), BLI_assert, BLI_findstring(), BLI_remlink(), BakeAPIRender::cage_extrusion, CD_MLOOPUV, copy_m4_m4(), BakeAPIRender::custom_cage, CustomData_get_named_layer(), DAG_EVAL_RENDER, Object::data, PointerRNA::data, DEG_get_evaluated_object(), DEG_graph_build_from_view_layer(), DEG_graph_free(), DEG_graph_new(), depsgraph, eModifierMode_Render, eModifierType_EdgeSplit, eModifierType_Multires, ListBase::first, MultiresModifierData::flags, Mesh::id, Object::id, if(), invert_m4_m4(), BakeAPIRender::is_cage, BakeHighPolyData::is_flip_object, is_negative_m4(), BakeAPIRender::is_selected_to_active, Mesh::ldata, BakeAPIRender::main, BakeAPIRender::max_ray_distance, BakeHighPolyData::me, MEM_callocN, MEM_freeN, MEM_mallocN, ModifierData::mode, Object::modifiers, ID::name, ModifierData::next, CollectionPointerLink::next, BakeAPIRender::normal_space, BakeAPIRender::normal_swizzle, NULL, BakeTargets::num_channels, BakeTargets::num_pixels, BakeHighPolyData::ob, BakeHighPolyData::ob_eval, OB_MESH, OB_RESTRICT_RENDER, Main::objects, Object::obmat, BakeHighPolyData::obmat, OPERATOR_CANCELLED, OPERATOR_FINISHED, BakeAPIRender::pass_filter, BakeAPIRender::pass_type, CollectionPointerLink::ptr, R_BAKE_POSX, R_BAKE_POSY, R_BAKE_POSZ, R_BAKE_SPACE_OBJECT, R_BAKE_SPACE_TANGENT, R_BAKE_SPACE_WORLD, R_BAKE_TARGET_VERTEX_COLORS, RE_bake_engine(), RE_bake_engine_set_engine_parameters(), RE_bake_has_engine(), RE_bake_normal_world_to_object(), RE_bake_normal_world_to_tangent(), RE_bake_normal_world_to_world(), RE_bake_pixels_populate_from_objects(), BakeAPIRender::render, Object::restrictflag, BakeTargets::result, RPT_ERROR, SCE_PASS_NORMAL, scene, BakeAPIRender::scene, SUBSURF_UV_SMOOTH_NONE, BakeAPIRender::target, Mesh::totloop, Mesh::totpoly, ModifierData::type, Object::type, BakeAPIRender::uv_layer, MultiresModifierData::uv_smooth, and BakeAPIRender::view_layer.

Referenced by bake_exec(), bake_set_props(), bake_startjob(), bake_targets_output_external(), and BKE_ptcache_bake().

◆ bake_break()

static int bake_break ( void *  UNUSEDrjv)
static

for exec() when there is no render job note: this wont check for the escape key being pressed, but doing so isn't thread-safe.

Definition at line 163 of file object_bake_api.c.

References G.

Referenced by bake_exec(), and bake_invoke().

◆ bake_exec()

static int bake_exec ( bContext C,
wmOperator op 
)
static

◆ bake_freejob()

static void bake_freejob ( void *  bkv)
static

Definition at line 1798 of file object_bake_api.c.

References BLI_freelistN(), G, MEM_freeN, and BakeAPIRender::selected_objects.

Referenced by bake_invoke().

◆ bake_init_api_data()

static void bake_init_api_data ( wmOperator op,
bContext C,
BakeAPIRender bkr 
)
static

◆ bake_invoke()

static int bake_invoke ( bContext C,
wmOperator op,
const wmEvent UNUSEDevent 
)
static

◆ bake_mesh_new_from_object()

static Mesh* bake_mesh_new_from_object ( Depsgraph depsgraph,
Object object,
const bool  preserve_origindex 
)
static

Definition at line 672 of file object_bake_api.c.

References BKE_mesh_new_from_object(), BKE_mesh_split_faces(), depsgraph, Mesh::flag, and ME_AUTOSMOOTH.

Referenced by bake().

◆ bake_modal()

static int bake_modal ( bContext C,
wmOperator UNUSEDop,
const wmEvent event 
)
static

◆ bake_object_check()

static bool bake_object_check ( ViewLayer view_layer,
Object ob,
const eBakeTarget  target,
ReportList reports 
)
static

◆ bake_objects_check()

static bool bake_objects_check ( Main bmain,
ViewLayer view_layer,
Object ob,
ListBase selected_objects,
ReportList reports,
const bool  is_selected_to_active,
const eBakeTarget  target 
)
static

◆ bake_pass_filter_check()

static bool bake_pass_filter_check ( eScenePassType  pass_type,
const int  pass_filter,
ReportList reports 
)
static

◆ bake_progress_update()

static void bake_progress_update ( void *  bjv,
float  progress 
)
static

Definition at line 129 of file object_bake_api.c.

References BakeAPIRender::do_update, and BakeAPIRender::progress.

Referenced by bake_invoke().

◆ bake_result_add_to_rgba()

static void bake_result_add_to_rgba ( float  rgba[4],
const float result,
const int  num_channels 
)
static

Definition at line 1075 of file object_bake_api.c.

References add_v3_v3(), add_v4_v4(), and result.

Referenced by bake_targets_output_vertex_colors().

◆ bake_set_props()

static void bake_set_props ( wmOperator op,
Scene scene 
)
static

◆ bake_startjob()

static void bake_startjob ( void *  bkv,
short *  UNUSEDstop,
short *  do_update,
float progress 
)
static

◆ bake_targets_clear()

static void bake_targets_clear ( Main bmain,
const bool  is_tangent 
)
static

◆ bake_targets_free()

static void bake_targets_free ( BakeTargets targets)
static

◆ bake_targets_init()

static bool bake_targets_init ( const BakeAPIRender bkr,
BakeTargets targets,
Object ob,
Object ob_eval,
ReportList reports 
)
static

◆ bake_targets_init_external()

static bool bake_targets_init_external ( const BakeAPIRender bkr,
BakeTargets targets,
Object ob,
ReportList reports 
)
static

◆ bake_targets_init_image_textures()

static bool bake_targets_init_image_textures ( const BakeAPIRender bkr,
BakeTargets targets,
Object ob,
ReportList reports 
)
static

◆ bake_targets_init_internal()

static bool bake_targets_init_internal ( const BakeAPIRender bkr,
BakeTargets targets,
Object ob,
ReportList reports 
)
static

◆ bake_targets_init_vertex_colors()

static bool bake_targets_init_vertex_colors ( BakeTargets targets,
Object ob,
ReportList reports 
)
static

◆ bake_targets_output()

static bool bake_targets_output ( const BakeAPIRender bkr,
BakeTargets targets,
Object ob,
Object ob_eval,
Mesh me_eval,
BakePixel pixel_array,
ReportList reports 
)
static

◆ bake_targets_output_external()

static bool bake_targets_output_external ( const BakeAPIRender bkr,
BakeTargets targets,
Object ob,
Object ob_eval,
Mesh me,
BakePixel pixel_array,
ReportList reports 
)
static

◆ bake_targets_output_internal()

static bool bake_targets_output_internal ( const BakeAPIRender bkr,
BakeTargets targets,
Object ob,
BakePixel pixel_array,
ReportList reports 
)
static

◆ bake_targets_output_vertex_colors()

static bool bake_targets_output_vertex_colors ( BakeTargets targets,
Object ob 
)
static

◆ bake_targets_populate_pixels()

static void bake_targets_populate_pixels ( const BakeAPIRender bkr,
BakeTargets targets,
Object ob,
Mesh me_eval,
BakePixel pixel_array 
)
static

◆ bake_targets_populate_pixels_vertex_colors()

static void bake_targets_populate_pixels_vertex_colors ( BakeTargets targets,
Object ob,
Mesh me_eval,
BakePixel pixel_array 
)
static

◆ bake_targets_refresh()

static void bake_targets_refresh ( BakeTargets targets)
static

◆ bake_update_image()

static void bake_update_image ( ScrArea area,
Image image 
)
static

◆ find_original_loop()

static int find_original_loop ( const Mesh me_orig,
const int *  vert_origindex,
const int *  poly_origindex,
const int  poly_eval,
const int  vert_eval 
)
static

◆ is_noncolor_pass()

static bool is_noncolor_pass ( eScenePassType  pass_type)
static

◆ OBJECT_OT_bake()

void OBJECT_OT_bake ( wmOperatorType ot)

◆ write_external_bake_pixels()

static bool write_external_bake_pixels ( const char *  filepath,
BakePixel  pixel_array[],
float buffer,
const int  width,
const int  height,
const int  margin,
ImageFormatData im_format,
const bool  is_noncolor 
)
static

◆ write_internal_bake_pixels()

static bool write_internal_bake_pixels ( Image image,
BakePixel  pixel_array[],
float buffer,
const int  width,
const int  height,
const int  margin,
const bool  is_clear,
const bool  is_noncolor 
)
static