Blender V2.61 - r43446
Classes | Typedefs | Functions

object_bake.c File Reference

#include <string.h>
#include "MEM_guardedalloc.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DNA_world_types.h"
#include "DNA_object_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "BLI_blenlib.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BLI_math.h"
#include "BLI_math_geom.h"
#include "BKE_blender.h"
#include "BKE_screen.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_main.h"
#include "BKE_multires.h"
#include "BKE_report.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_modifier.h"
#include "BKE_DerivedMesh.h"
#include "BKE_subsurf.h"
#include "RE_pipeline.h"
#include "RE_shader_ext.h"
#include "PIL_time.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
#include "GPU_draw.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_object.h"
#include "object_intern.h"

Go to the source code of this file.

Classes

struct  MultiresBakerJobData
struct  MultiresBakeJob
struct  MultiresBakeRender
struct  MResolvePixelData
struct  MBakeRast
struct  MHeightBakeData
struct  MNormalBakeData
struct  BakeRender

Typedefs

typedef struct MultiresBakerJobData MultiresBakerJobData
typedef void(* MPassKnownData )(DerivedMesh *lores_dm, DerivedMesh *hires_dm, const void *bake_data, const int face_index, const int lvl, const float st[2], float tangmat[3][3], const int x, const int y)
typedef void *(* MInitBakeData )(MultiresBakeRender *bkr, Image *ima)
typedef void(* MApplyBakeData )(void *bake_data)
typedef void(* MFreeBakeData )(void *bake_data)
typedef void(* MFlushPixel )(const MResolvePixelData *data, const int x, const int y)
typedef struct BakeRender BakeRender

Functions

static void multiresbake_get_normal (const MResolvePixelData *data, float norm[], const int face_num, const int vert_index)
static void init_bake_rast (MBakeRast *bake_rast, const ImBuf *ibuf, const MResolvePixelData *data, MFlushPixel flush_pixel)
static void flush_pixel (const MResolvePixelData *data, const int x, const int y)
static void set_rast_triangle (const MBakeRast *bake_rast, const int x, const int y)
static void rasterize_half (const MBakeRast *bake_rast, const float s0_s, const float t0_s, const float s1_s, const float t1_s, const float s0_l, const float t0_l, const float s1_l, const float t1_l, const int y0_in, const int y1_in, const int is_mid_right)
static void bake_rasterize (const MBakeRast *bake_rast, const float st0_in[2], const float st1_in[2], const float st2_in[2])
static int multiresbake_test_break (MultiresBakeRender *bkr)
static void do_multires_bake (MultiresBakeRender *bkr, Image *ima, MPassKnownData passKnownData, MInitBakeData initBakeData, MApplyBakeData applyBakeData, MFreeBakeData freeBakeData)
static void interp_bilinear_quad_data (float data[4][3], float u, float v, float res[3])
static void interp_barycentric_tri_data (float data[3][3], float u, float v, float res[3])
static void interp_bilinear_grid (DMGridData *grid, int grid_size, float crn_x, float crn_y, int mode, float res[3])
static void get_ccgdm_data (DerivedMesh *lodm, DerivedMesh *hidm, const int *origindex, const int lvl, const int face_index, const float u, const float v, float co[3], float n[3])
static void interp_bilinear_mface (DerivedMesh *dm, MFace *mface, const float u, const float v, const int mode, float res[3])
static void interp_barycentric_mface (DerivedMesh *dm, MFace *mface, const float u, const float v, const int mode, float res[3])
static void * init_heights_data (MultiresBakeRender *bkr, Image *ima)
static void * init_normal_data (MultiresBakeRender *bkr, Image *UNUSED(ima))
static void free_normal_data (void *bake_data)
static void apply_heights_data (void *bake_data)
static void free_heights_data (void *bake_data)
static void apply_heights_callback (DerivedMesh *lores_dm, DerivedMesh *hires_dm, const void *bake_data, const int face_index, const int lvl, const float st[2], float UNUSED(tangmat[3][3]), const int x, const int y)
static void apply_tangmat_callback (DerivedMesh *lores_dm, DerivedMesh *hires_dm, const void *bake_data, const int face_index, const int lvl, const float st[2], float tangmat[3][3], const int x, const int y)
static void count_images (MultiresBakeRender *bkr)
static void bake_images (MultiresBakeRender *bkr)
static void finish_images (MultiresBakeRender *bkr)
static void multiresbake_start (MultiresBakeRender *bkr)
static int multiresbake_check (bContext *C, wmOperator *op)
static DerivedMeshmultiresbake_create_loresdm (Scene *scene, Object *ob, int *lvl)
static DerivedMeshmultiresbake_create_hiresdm (Scene *scene, Object *ob, int *lvl, int *simple)
static void clear_images (MTFace *mtface, int totface)
static int multiresbake_image_exec_locked (bContext *C, wmOperator *op)
static void init_multiresbake_job (bContext *C, MultiresBakeJob *bkj)
static void multiresbake_startjob (void *bkv, short *stop, short *do_update, float *progress)
static void multiresbake_freejob (void *bkv)
static int multiresbake_image_exec (bContext *C, wmOperator *op)
static int thread_break (void *UNUSED(arg))
static int test_bake_internal (bContext *C, ReportList *reports)
static void init_bake_internal (BakeRender *bkr, bContext *C)
static void finish_bake_internal (BakeRender *bkr)
static void * do_bake_render (void *bake_v)
static void bake_startjob (void *bkv, short *stop, short *do_update, float *progress)
static void bake_update (void *bkv)
static void bake_freejob (void *bkv)
static int objects_bake_render_modal (bContext *C, wmOperator *UNUSED(op), wmEvent *event)
static int is_multires_bake (Scene *scene)
static int objects_bake_render_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(_event))
static int bake_image_exec (bContext *C, wmOperator *op)
void OBJECT_OT_bake_image (wmOperatorType *ot)

Detailed Description

Definition in file object_bake.c.


Typedef Documentation

typedef struct BakeRender BakeRender
typedef void(* MApplyBakeData)(void *bake_data)

Definition at line 124 of file object_bake.c.

typedef void(* MFlushPixel)(const MResolvePixelData *data, const int x, const int y)

Definition at line 142 of file object_bake.c.

typedef void(* MFreeBakeData)(void *bake_data)

Definition at line 125 of file object_bake.c.

typedef void*(* MInitBakeData)(MultiresBakeRender *bkr, Image *ima)

Definition at line 123 of file object_bake.c.

typedef void(* MPassKnownData)(DerivedMesh *lores_dm, DerivedMesh *hires_dm, const void *bake_data, const int face_index, const int lvl, const float st[2], float tangmat[3][3], const int x, const int y)

Definition at line 119 of file object_bake.c.


Function Documentation

static void apply_heights_callback ( DerivedMesh lores_dm,
DerivedMesh hires_dm,
const void *  bake_data,
const int  face_index,
const int  lvl,
const float  st[2],
float   UNUSEDtangmat[3][3],
const int  x,
const int  y 
) [static]
static void apply_heights_data ( void *  bake_data) [static]
static void apply_tangmat_callback ( DerivedMesh lores_dm,
DerivedMesh hires_dm,
const void *  bake_data,
const int  face_index,
const int  lvl,
const float  st[2],
float  tangmat[3][3],
const int  x,
const int  y 
) [static]
static void bake_freejob ( void *  bkv) [static]
static int bake_image_exec ( bContext C,
wmOperator op 
) [static]
static void bake_images ( MultiresBakeRender bkr) [static]
static void bake_rasterize ( const MBakeRast bake_rast,
const float  st0_in[2],
const float  st1_in[2],
const float  st2_in[2] 
) [static]

Definition at line 313 of file object_bake.c.

References ceilf, MBakeRast::h, rasterize_half(), SWAP, simple_enum_gen::w, and MBakeRast::w.

Referenced by do_multires_bake().

static void bake_startjob ( void *  bkv,
short *  stop,
short *  do_update,
float *  progress 
) [static]
static void bake_update ( void *  bkv) [static]
static void clear_images ( MTFace mtface,
int  totface 
) [static]
static void count_images ( MultiresBakeRender bkr) [static]
static void* do_bake_render ( void *  bake_v) [static]
static void do_multires_bake ( MultiresBakeRender bkr,
Image ima,
MPassKnownData  passKnownData,
MInitBakeData  initBakeData,
MApplyBakeData  applyBakeData,
MFreeBakeData  freeBakeData 
) [static]
static void finish_bake_internal ( BakeRender bkr) [static]
static void finish_images ( MultiresBakeRender bkr) [static]
static void flush_pixel ( const MResolvePixelData data,
const int  x,
const int  y 
) [static]
static void free_heights_data ( void *  bake_data) [static]

Definition at line 682 of file object_bake.c.

References MHeightBakeData::heights, MEM_freeN(), DerivedMesh::release, and MHeightBakeData::ssdm.

Referenced by bake_images().

static void free_normal_data ( void *  bake_data) [static]

Definition at line 639 of file object_bake.c.

References MEM_freeN().

Referenced by bake_images().

static void get_ccgdm_data ( DerivedMesh lodm,
DerivedMesh hidm,
const int *  origindex,
const int  lvl,
const int  face_index,
const float  u,
const float  v,
float  co[3],
float  n[3] 
) [static]
static void init_bake_internal ( BakeRender bkr,
bContext C 
) [static]
static void init_bake_rast ( MBakeRast bake_rast,
const ImBuf ibuf,
const MResolvePixelData data,
MFlushPixel  flush_pixel 
) [static]
static void* init_heights_data ( MultiresBakeRender bkr,
Image ima 
) [static]
static void init_multiresbake_job ( bContext C,
MultiresBakeJob bkj 
) [static]
static void* init_normal_data ( MultiresBakeRender bkr,
Image UNUSEDima 
) [static]
static void interp_barycentric_mface ( DerivedMesh dm,
MFace mface,
const float  u,
const float  v,
const int  mode,
float  res[3] 
) [static]
static void interp_barycentric_tri_data ( float  data[3][3],
float  u,
float  v,
float  res[3] 
) [static]

Definition at line 465 of file object_bake.c.

References add_v3_v3(), copy_v3_v3(), and mul_v3_fl().

Referenced by interp_barycentric_mface().

static void interp_bilinear_grid ( DMGridData grid,
int  grid_size,
float  crn_x,
float  crn_y,
int  mode,
float  res[3] 
) [static]

Definition at line 479 of file object_bake.c.

References co, copy_v3_v3(), data, and interp_bilinear_quad_data().

Referenced by get_ccgdm_data().

static void interp_bilinear_mface ( DerivedMesh dm,
MFace mface,
const float  u,
const float  v,
const int  mode,
float  res[3] 
) [static]
static void interp_bilinear_quad_data ( float  data[4][3],
float  u,
float  v,
float  res[3] 
) [static]

Definition at line 451 of file object_bake.c.

References add_v3_v3(), copy_v3_v3(), and mul_v3_fl().

Referenced by interp_bilinear_grid(), and interp_bilinear_mface().

static int is_multires_bake ( Scene scene) [static]
static int multiresbake_check ( bContext C,
wmOperator op 
) [static]
static DerivedMesh* multiresbake_create_hiresdm ( Scene scene,
Object ob,
int *  lvl,
int *  simple 
) [static]
static DerivedMesh* multiresbake_create_loresdm ( Scene scene,
Object ob,
int *  lvl 
) [static]
static void multiresbake_freejob ( void *  bkv) [static]
static void multiresbake_get_normal ( const MResolvePixelData data,
float  norm[],
const int  face_num,
const int  vert_index 
) [static]
static int multiresbake_image_exec ( bContext C,
wmOperator op 
) [static]
static int multiresbake_image_exec_locked ( bContext C,
wmOperator op 
) [static]
static void multiresbake_start ( MultiresBakeRender bkr) [static]
static void multiresbake_startjob ( void *  bkv,
short *  stop,
short *  do_update,
float *  progress 
) [static]
static int multiresbake_test_break ( MultiresBakeRender bkr) [static]

Definition at line 354 of file object_bake.c.

References G, and MultiresBakeRender::stop.

Referenced by do_multires_bake().

void OBJECT_OT_bake_image ( wmOperatorType ot)
static int objects_bake_render_invoke ( bContext C,
wmOperator op,
wmEvent UNUSED_event 
) [static]
static int objects_bake_render_modal ( bContext C,
wmOperator UNUSEDop,
wmEvent event 
) [static]
static void rasterize_half ( const MBakeRast bake_rast,
const float  s0_s,
const float  t0_s,
const float  s1_s,
const float  t1_s,
const float  s0_l,
const float  t0_l,
const float  s1_l,
const float  t1_l,
const int  y0_in,
const int  y1_in,
const int  is_mid_right 
) [static]

Definition at line 274 of file object_bake.c.

References ceilf, fabsf, MBakeRast::h, set_rast_triangle(), SWAP, simple_enum_gen::w, and MBakeRast::w.

Referenced by bake_rasterize().

static void set_rast_triangle ( const MBakeRast bake_rast,
const int  x,
const int  y 
) [static]
static int test_bake_internal ( bContext C,
ReportList reports 
) [static]
static int thread_break ( void *  UNUSEDarg) [static]

Definition at line 1250 of file object_bake.c.

References G.

Referenced by bake_image_exec(), and bake_startjob().