Blender V4.3
paint_image_proj.cc File Reference

Functions to paint images in 2D and 3D. More...

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <utility>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_linklist.h"
#include "BLI_math_base_safe.h"
#include "BLI_math_bits.h"
#include "BLI_math_color_blend.h"
#include "BLI_math_geom.h"
#include "BLI_math_vector.hh"
#include "BLI_memarena.h"
#include "BLI_task.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "atomic_ops.h"
#include "BLT_translation.hh"
#include "IMB_imbuf.hh"
#include "IMB_interp.hh"
#include "DNA_brush_types.h"
#include "DNA_customdata_types.h"
#include "DNA_defs.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_node_types.h"
#include "DNA_object_enums.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_attribute.hh"
#include "BKE_brush.hh"
#include "BKE_camera.h"
#include "BKE_colorband.hh"
#include "BKE_colortools.hh"
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_global.hh"
#include "BKE_idprop.hh"
#include "BKE_image.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_main.hh"
#include "BKE_material.h"
#include "BKE_mesh.hh"
#include "BKE_mesh_mapping.hh"
#include "BKE_mesh_runtime.hh"
#include "BKE_node.hh"
#include "BKE_node_runtime.hh"
#include "BKE_object.hh"
#include "BKE_paint.hh"
#include "BKE_report.hh"
#include "BKE_scene.hh"
#include "BKE_screen.hh"
#include "DNA_screen_types.h"
#include "DNA_space_types.h"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_query.hh"
#include "ED_image.hh"
#include "ED_node.hh"
#include "ED_object.hh"
#include "ED_paint.hh"
#include "ED_screen.hh"
#include "ED_sculpt.hh"
#include "ED_uvedit.hh"
#include "ED_view3d.hh"
#include "ED_view3d_offscreen.hh"
#include "GPU_capabilities.hh"
#include "GPU_init_exit.hh"
#include "NOD_shader.h"
#include "UI_interface.hh"
#include "UI_resources.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "RNA_enum_types.hh"
#include "RNA_types.hh"
#include "IMB_colormanagement.hh"
#include "paint_intern.hh"

Go to the source code of this file.

Classes

struct  ProjPaintImage
 
struct  ProjStrokeHandle
 
struct  LoopSeamData
 
struct  ProjPaintState
 
union  PixelPointer
 
union  PixelStore
 
struct  ProjPixel
 
struct  ProjPixelClone
 
struct  TileInfo
 
struct  VertSeam
 
struct  ProjPaintLayerClone
 
struct  ProjPaintFaceLookup
 
struct  ProjPaintFaceCoSS
 
struct  PrepareImageEntry
 
struct  ProjectHandle
 

Macros

#define PROJ_BUCKET_BRUSH_DIV   4
 
#define PROJ_BUCKET_RECT_MIN   4
 
#define PROJ_BUCKET_RECT_MAX   256
 
#define PROJ_BOUNDBOX_DIV   8
 
#define PROJ_BOUNDBOX_SQUARED   (PROJ_BOUNDBOX_DIV * PROJ_BOUNDBOX_DIV)
 
#define PROJ_DEBUG_WINCLIP   1
 
#define PROJ_FACE_SEAM0   (1 << 0)
 
#define PROJ_FACE_SEAM1   (1 << 1)
 
#define PROJ_FACE_SEAM2   (1 << 2)
 
#define PROJ_FACE_NOSEAM0   (1 << 4)
 
#define PROJ_FACE_NOSEAM1   (1 << 5)
 
#define PROJ_FACE_NOSEAM2   (1 << 6)
 
#define PROJ_FACE_SEAM_INIT0   (1 << 8)
 
#define PROJ_FACE_SEAM_INIT1   (1 << 9)
 
#define PROJ_FACE_SEAM_INIT2   (1 << 10)
 
#define PROJ_FACE_DEGENERATE   (1 << 12)
 
#define PROJ_FACE_WINDING_INIT   1
 
#define PROJ_FACE_WINDING_CW   2
 
#define PROJ_FACE_SCALE_SEAM   0.99f
 
#define PROJ_SRC_VIEW   1
 
#define PROJ_SRC_IMAGE_CAM   2
 
#define PROJ_SRC_IMAGE_VIEW   3
 
#define PROJ_SRC_VIEW_FILL   4
 
#define PROJ_VIEW_DATA_ID   "view_data"
 
#define PROJ_VIEW_DATA_SIZE   (4 * 4 + 4 * 4 + 3)
 
#define PROJ_BUCKET_NULL   0
 
#define PROJ_BUCKET_INIT   (1 << 0)
 
#define PROJ_GEOM_TOLERANCE   0.00075f
 
#define PROJ_PIXEL_TOLERANCE   0.01f
 
#define PROJ_VERT_CULL   1
 
#define TILE_PENDING   POINTER_FROM_INT(-1)
 
#define PROJ_PAINT_STATE_SHARED_MEMCPY(ps_dst, ps_src)    MEMCPY_STRUCT_AFTER(ps_dst, ps_src, is_shared_user)
 
#define PROJ_PAINT_STATE_SHARED_CLEAR(ps)   MEMSET_STRUCT_AFTER(ps, 0, is_shared_user)
 
#define ISECT_TRUE   1
 
#define ISECT_TRUE_P1   2
 
#define ISECT_TRUE_P2   3
 
#define ISECT_1   (1)
 
#define ISECT_2   (1 << 1)
 
#define ISECT_3   (1 << 2)
 
#define ISECT_4   (1 << 3)
 
#define ISECT_ALL3   ((1 << 3) - 1)
 
#define ISECT_ALL4   ((1 << 4) - 1)
 
#define IMA_DEF_NAME   N_("Untitled")
 
Corner triangle accessor functions
#define PS_CORNER_TRI_AS_VERT_INDEX_3(ps, tri)    ps->corner_verts_eval[tri[0]], ps->corner_verts_eval[tri[1]], ps->corner_verts_eval[tri[2]],
 
#define PS_CORNER_TRI_AS_UV_3(uvlayer, face_i, tri)    uvlayer[face_i][tri[0]], uvlayer[face_i][tri[1]], uvlayer[face_i][tri[2]],
 
#define PS_CORNER_TRI_ASSIGN_UV_3(uv_tri, uvlayer, face_i, tri)
 

Enumerations

enum  {
  LAYER_BASE_COLOR , LAYER_SPECULAR , LAYER_ROUGHNESS , LAYER_METALLIC ,
  LAYER_NORMAL , LAYER_BUMP , LAYER_DISPLACEMENT
}
 

Functions

static void partial_redraw_array_init (ImagePaintPartialRedraw *pr)
 
BLI_INLINE uchar f_to_char (const float val)
 
static int project_paint_face_paint_tile (Image *ima, const float *uv)
 
static Materialtex_get_material (const ProjPaintState *ps, int face_i)
 
static TexPaintSlotproject_paint_face_paint_slot (const ProjPaintState *ps, int tri_index)
 
static Imageproject_paint_face_paint_image (const ProjPaintState *ps, int tri_index)
 
static TexPaintSlotproject_paint_face_clone_slot (const ProjPaintState *ps, int tri_index)
 
static Imageproject_paint_face_clone_image (const ProjPaintState *ps, int tri_index)
 
static int project_bucket_offset (const ProjPaintState *ps, const float projCoSS[2])
 
static int project_bucket_offset_safe (const ProjPaintState *ps, const float projCoSS[2])
 
static float VecZDepthOrtho (const float pt[2], const float v1[3], const float v2[3], const float v3[3], float w[3])
 
static float VecZDepthPersp (const float pt[2], const float v1[4], const float v2[4], const float v3[4], float w[3])
 
static int project_paint_PickFace (const ProjPaintState *ps, const float pt[2], float w[3])
 
static bool project_paint_PickColor (const ProjPaintState *ps, const float pt[2], float *rgba_fp, uchar *rgba, const bool interp)
 
static int project_paint_occlude_ptv (const float pt[3], const float v1[4], const float v2[4], const float v3[4], float w[3], const bool is_ortho)
 
static int project_paint_occlude_ptv_clip (const float pt[3], const float v1[4], const float v2[4], const float v3[4], const float v1_3d[3], const float v2_3d[3], const float v3_3d[3], float w[3], const bool is_ortho, RegionView3D *rv3d)
 
static bool project_bucket_point_occluded (const ProjPaintState *ps, LinkNode *bucketFace, const int orig_face, const float pixelScreenCo[4])
 
static int line_isect_y (const float p1[2], const float p2[2], const float y_level, float *x_isect)
 
static int line_isect_x (const float p1[2], const float p2[2], const float x_level, float *y_isect)
 
static bool cmp_uv (const float vec2a[2], const float vec2b[2])
 
static bool pixel_bounds_uv (const float uv_quad[4][2], const int ibuf_x, const int ibuf_y, rcti *r_bounds_px)
 
static bool pixel_bounds_array (float(*uv)[2], const int ibuf_x, const int ibuf_y, int tot, rcti *r_bounds_px)
 
static void project_face_winding_init (const ProjPaintState *ps, const int tri_index)
 
static bool check_seam (const ProjPaintState *ps, const int orig_face, const int orig_i1_fidx, const int orig_i2_fidx, int *other_face, int *orig_fidx)
 
static VertSeamfind_adjacent_seam (const ProjPaintState *ps, uint loop_index, uint vert_index, VertSeam **r_seam)
 
static float compute_seam_normal (VertSeam *seam, VertSeam *adj, float r_no[2])
 
static void uv_image_outset (const ProjPaintState *ps, float(*orig_uv)[2], float(*puv)[2], uint tri_index, const int ibuf_x, const int ibuf_y)
 
static void insert_seam_vert_array (const ProjPaintState *ps, MemArena *arena, const int tri_index, const int fidx1, const int ibuf_x, const int ibuf_y)
 
static void project_face_seams_init (const ProjPaintState *ps, MemArena *arena, const int tri_index, const uint vert_index, bool init_all, const int ibuf_x, const int ibuf_y)
 
static void screen_px_from_ortho (const float uv[2], const float v1co[3], const float v2co[3], const float v3co[3], const float uv1co[2], const float uv2co[2], const float uv3co[2], float pixelScreenCo[4], float w[3])
 
static void screen_px_from_persp (const float uv[2], const float v1co[4], const float v2co[4], const float v3co[4], const float uv1co[2], const float uv2co[2], const float uv3co[2], float pixelScreenCo[4], float w[3])
 
static void screen_px_to_vector_persp (int winx, int winy, const float projmat_inv[4][4], const float view_pos[3], const float co_px[2], float r_dir[3])
 
static float screen_px_line_point_factor_v2_persp (const ProjPaintState *ps, const float p[2], const float v1[3], const float v2[3])
 
static void project_face_pixel (const float *tri_uv[3], ImBuf *ibuf_other, const float w[3], uchar rgba_ub[4], float rgba_f[4])
 
static float project_paint_uvpixel_mask (const ProjPaintState *ps, const int tri_index, const float w[3])
 
static int project_paint_pixel_sizeof (const short brush_type)
 
static int project_paint_undo_subtiles (const TileInfo *tinf, int tx, int ty)
 
static ProjPixelproject_paint_uvpixel_init (const ProjPaintState *ps, MemArena *arena, const TileInfo *tinf, int x_px, int y_px, const float mask, const int tri_index, const float pixelScreenCo[4], const float world_spaceCo[3], const float w[3])
 
static bool line_clip_rect2f (const rctf *cliprect, const rctf *rect, const float l1[2], const float l2[2], float l1_clip[2], float l2_clip[2])
 
static void scale_tri (float insetCos[3][3], const float *origCos[3], const float inset)
 
static float len_squared_v2v2_alt (const float v1[2], const float v2_1, const float v2_2)
 
static bool project_bucket_isect_circle (const float cent[2], const float radius_squared, const rctf *bucket_bounds)
 
static void rect_to_uvspace_ortho (const rctf *bucket_bounds, const float *v1coSS, const float *v2coSS, const float *v3coSS, const float *uv1co, const float *uv2co, const float *uv3co, float bucket_bounds_uv[4][2], const int flip)
 
static void rect_to_uvspace_persp (const rctf *bucket_bounds, const float *v1coSS, const float *v2coSS, const float *v3coSS, const float *uv1co, const float *uv2co, const float *uv3co, float bucket_bounds_uv[4][2], const int flip)
 
static bool IsectPT2Df_limit (const float pt[2], const float v1[2], const float v2[2], const float v3[2], const float limit)
 
static int float_z_sort_flip (const void *p1, const void *p2)
 
static int float_z_sort (const void *p1, const void *p2)
 
static bool line_rect_clip (const rctf *rect, const float l1[4], const float l2[4], const float uv1[2], const float uv2[2], float uv[2], bool is_ortho)
 
static void project_bucket_clip_face (const bool is_ortho, const bool is_flip_object, const rctf *cliprect, const rctf *bucket_bounds, const float *v1coSS, const float *v2coSS, const float *v3coSS, const float *uv1co, const float *uv2co, const float *uv3co, float bucket_bounds_uv[8][2], int *tot, bool cull)
 
static bool IsectPoly2Df (const float pt[2], const float uv[][2], const int tot)
 
static bool IsectPoly2Df_twoside (const float pt[2], const float uv[][2], const int tot)
 
static void project_paint_face_init (const ProjPaintState *ps, const int thread_index, const int bucket_index, const int tri_index, const int image_index, const rctf *clip_rect, const rctf *bucket_bounds, ImBuf *ibuf, ImBuf **tmpibuf)
 
static void project_paint_bucket_bounds (const ProjPaintState *ps, const float min[2], const float max[2], int bucketMin[2], int bucketMax[2])
 
static void project_bucket_bounds (const ProjPaintState *ps, const int bucket_x, const int bucket_y, rctf *r_bucket_bounds)
 
static void project_bucket_init (const ProjPaintState *ps, const int thread_index, const int bucket_index, const rctf *clip_rect, const rctf *bucket_bounds)
 
static bool project_bucket_face_isect (ProjPaintState *ps, int bucket_x, int bucket_y, const int3 &tri)
 
static void project_paint_delayed_face_init (ProjPaintState *ps, const int3 &corner_tri, const int tri_index)
 
static void proj_paint_state_viewport_init (ProjPaintState *ps, const char symmetry_flag)
 
static void proj_paint_state_screen_coords_init (ProjPaintState *ps, const int diameter)
 
static void proj_paint_state_cavity_init (ProjPaintState *ps)
 
static void proj_paint_state_seam_bleed_init (ProjPaintState *ps)
 
static void proj_paint_state_thread_init (ProjPaintState *ps, const bool reset_threads)
 
static void proj_paint_state_vert_flags_init (ProjPaintState *ps)
 
static void project_paint_bleed_add_face_user (const ProjPaintState *ps, MemArena *arena, const int3 &corner_tri, const int tri_index)
 
static bool proj_paint_state_mesh_eval_init (const bContext *C, ProjPaintState *ps)
 
static void proj_paint_layer_clone_init (ProjPaintState *ps, ProjPaintLayerClone *layer_clone)
 
static bool project_paint_clone_face_skip (ProjPaintState *ps, ProjPaintLayerClone *lc, const TexPaintSlot *slot, const int tri_index)
 
static void proj_paint_face_lookup_init (const ProjPaintState *ps, ProjPaintFaceLookup *face_lookup)
 
static bool project_paint_check_face_paintable (const ProjPaintState *ps, const ProjPaintFaceLookup *face_lookup, const int tri_i)
 
static void proj_paint_face_coSS_init (const ProjPaintState *ps, const int3 &corner_tri, ProjPaintFaceCoSS *coSS)
 
static bool project_paint_flt_max_cull (const ProjPaintState *ps, const ProjPaintFaceCoSS *coSS)
 
static bool project_paint_winclip (const ProjPaintState *ps, const ProjPaintFaceCoSS *coSS)
 
static void project_paint_build_proj_ima (ProjPaintState *ps, MemArena *arena, ListBase *used_images)
 
static void project_paint_prepare_all_faces (ProjPaintState *ps, MemArena *arena, const ProjPaintFaceLookup *face_lookup, ProjPaintLayerClone *layer_clone, const float(*mloopuv_base)[2], const bool is_multi_view)
 
static void project_paint_begin (const bContext *C, ProjPaintState *ps, const bool is_multi_view, const char symmetry_flag)
 
static void paint_proj_begin_clone (ProjPaintState *ps, const float mouse[2])
 
static void project_paint_end (ProjPaintState *ps)
 
static void partial_redraw_single_init (ImagePaintPartialRedraw *pr)
 
static bool partial_redraw_array_merge (ImagePaintPartialRedraw *pr, ImagePaintPartialRedraw *pr_other, int tot)
 
static bool project_image_refresh_tagged (ProjPaintState *ps)
 
static bool project_bucket_iter_init (ProjPaintState *ps, const float mval_f[2])
 
static bool project_bucket_iter_next (ProjPaintState *ps, int *bucket_index, rctf *bucket_bounds, const float mval[2])
 
static void do_projectpaint_clone (ProjPaintState *ps, ProjPixel *projPixel, float mask)
 
static void do_projectpaint_clone_f (ProjPaintState *ps, ProjPixel *projPixel, float mask)
 
static void do_projectpaint_smear (ProjPaintState *ps, ProjPixel *projPixel, float mask, MemArena *smearArena, LinkNode **smearPixels, const float co[2])
 
static void do_projectpaint_smear_f (ProjPaintState *ps, ProjPixel *projPixel, float mask, MemArena *smearArena, LinkNode **smearPixels_f, const float co[2])
 
static void do_projectpaint_soften_f (ProjPaintState *ps, ProjPixel *projPixel, float mask, MemArena *softenArena, LinkNode **softenPixels)
 
static void do_projectpaint_soften (ProjPaintState *ps, ProjPixel *projPixel, float mask, MemArena *softenArena, LinkNode **softenPixels)
 
static void do_projectpaint_draw (ProjPaintState *ps, ProjPixel *projPixel, const float texrgb[3], float mask, float dither, float u, float v)
 
static void do_projectpaint_draw_f (ProjPaintState *ps, ProjPixel *projPixel, const float texrgb[3], float mask)
 
static void do_projectpaint_mask (ProjPaintState *ps, ProjPixel *projPixel, float mask)
 
static void do_projectpaint_mask_f (ProjPaintState *ps, ProjPixel *projPixel, float mask)
 
static void image_paint_partial_redraw_expand (ImagePaintPartialRedraw *cell, const ProjPixel *projPixel)
 
static void copy_original_alpha_channel (ProjPixel *pixel, bool is_floatbuf)
 
static void do_projectpaint_thread (TaskPool *__restrict, void *ph_v)
 
static bool project_paint_op (void *state, const float lastpos[2], const float pos[2])
 
static void paint_proj_stroke_ps (const bContext *, void *ps_handle_p, const float prev_pos[2], const float pos[2], const bool eraser, float pressure, float distance, float size, ProjPaintState *ps)
 
void paint_proj_stroke (const bContext *C, void *ps_handle_p, const float prev_pos[2], const float pos[2], const bool eraser, float pressure, float distance, float size)
 
static void project_state_init (bContext *C, Object *ob, ProjPaintState *ps, int mode)
 
void * paint_proj_new_stroke (bContext *C, Object *ob, const float mouse[2], int mode)
 
void paint_proj_redraw (const bContext *C, void *ps_handle_p, bool final)
 
void paint_proj_stroke_done (void *ps_handle_p)
 
static int texture_paint_camera_project_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_project_image (wmOperatorType *ot)
 
static bool texture_paint_image_from_view_poll (bContext *C)
 
static int texture_paint_image_from_view_exec (bContext *C, wmOperator *op)
 
void PAINT_OT_image_from_view (wmOperatorType *ot)
 
void ED_paint_data_warning (ReportList *reports, bool has_uvs, bool has_mat, bool has_tex, bool has_stencil)
 
bool ED_paint_proj_mesh_data_check (Scene &scene, Object &ob, bool *r_has_uvs, bool *r_has_mat, bool *r_has_tex, bool *r_has_stencil)
 
static Materialget_or_create_current_material (bContext *C, Object *ob)
 
static Imageproj_paint_image_create (wmOperator *op, Main *bmain, bool is_data)
 
static const char * proj_paint_color_attribute_create (wmOperator *op, Object &ob)
 
static void default_paint_slot_color_get (int layer_type, Material *ma, float color[4])
 
static bool proj_paint_add_slot (bContext *C, wmOperator *op)
 
static int get_texture_layer_type (wmOperator *op, const char *prop_name)
 
static int texture_paint_add_texture_paint_slot_exec (bContext *C, wmOperator *op)
 
static void get_default_texture_layer_name_for_object (Object *ob, int texture_type, char *dst, int dst_maxncpy)
 
static int texture_paint_add_texture_paint_slot_invoke (bContext *C, wmOperator *op, const wmEvent *)
 
static void texture_paint_add_texture_paint_slot_ui (bContext *C, wmOperator *op)
 
void PAINT_OT_add_texture_paint_slot (wmOperatorType *ot)
 
static int add_simple_uvs_exec (bContext *C, wmOperator *)
 
static bool add_simple_uvs_poll (bContext *C)
 
void PAINT_OT_add_simple_uvs (wmOperatorType *ot)
 

Variables

static const EnumPropertyItem layer_type_items []
 

Detailed Description

Functions to paint images in 2D and 3D.

Definition in file paint_image_proj.cc.

Macro Definition Documentation

◆ IMA_DEF_NAME

#define IMA_DEF_NAME   N_("Untitled")

Definition at line 6894 of file paint_image_proj.cc.

Referenced by PAINT_OT_add_texture_paint_slot().

◆ ISECT_1

#define ISECT_1   (1)

Definition at line 2399 of file paint_image_proj.cc.

Referenced by project_bucket_clip_face().

◆ ISECT_2

#define ISECT_2   (1 << 1)

Definition at line 2400 of file paint_image_proj.cc.

Referenced by project_bucket_clip_face().

◆ ISECT_3

#define ISECT_3   (1 << 2)

Definition at line 2401 of file paint_image_proj.cc.

Referenced by project_bucket_clip_face().

◆ ISECT_4

#define ISECT_4   (1 << 3)

Definition at line 2402 of file paint_image_proj.cc.

Referenced by project_bucket_clip_face().

◆ ISECT_ALL3

#define ISECT_ALL3   ((1 << 3) - 1)

Definition at line 2403 of file paint_image_proj.cc.

Referenced by project_bucket_clip_face().

◆ ISECT_ALL4

#define ISECT_ALL4   ((1 << 4) - 1)

Definition at line 2404 of file paint_image_proj.cc.

Referenced by project_bucket_clip_face().

◆ ISECT_TRUE

#define ISECT_TRUE   1

Definition at line 925 of file paint_image_proj.cc.

Referenced by line_isect_x(), and line_isect_y().

◆ ISECT_TRUE_P1

#define ISECT_TRUE_P1   2

Definition at line 926 of file paint_image_proj.cc.

Referenced by line_isect_x(), and line_isect_y().

◆ ISECT_TRUE_P2

#define ISECT_TRUE_P2   3

Definition at line 927 of file paint_image_proj.cc.

Referenced by line_isect_x(), and line_isect_y().

◆ PROJ_BOUNDBOX_DIV

#define PROJ_BOUNDBOX_DIV   8

Definition at line 139 of file paint_image_proj.cc.

Referenced by project_paint_uvpixel_init().

◆ PROJ_BOUNDBOX_SQUARED

◆ PROJ_BUCKET_BRUSH_DIV

#define PROJ_BUCKET_BRUSH_DIV   4

Definition at line 134 of file paint_image_proj.cc.

Referenced by project_paint_begin().

◆ PROJ_BUCKET_INIT

#define PROJ_BUCKET_INIT   (1 << 0)

Definition at line 188 of file paint_image_proj.cc.

Referenced by project_bucket_init().

◆ PROJ_BUCKET_NULL

#define PROJ_BUCKET_NULL   0

Definition at line 187 of file paint_image_proj.cc.

Referenced by do_projectpaint_thread().

◆ PROJ_BUCKET_RECT_MAX

#define PROJ_BUCKET_RECT_MAX   256

Definition at line 137 of file paint_image_proj.cc.

Referenced by project_paint_begin().

◆ PROJ_BUCKET_RECT_MIN

#define PROJ_BUCKET_RECT_MIN   4

Definition at line 136 of file paint_image_proj.cc.

Referenced by project_paint_begin().

◆ PROJ_DEBUG_WINCLIP

#define PROJ_DEBUG_WINCLIP   1

Definition at line 145 of file paint_image_proj.cc.

◆ PROJ_FACE_DEGENERATE

#define PROJ_FACE_DEGENERATE   (1 << 12)

◆ PROJ_FACE_NOSEAM0

#define PROJ_FACE_NOSEAM0   (1 << 4)

Definition at line 157 of file paint_image_proj.cc.

Referenced by project_face_seams_init().

◆ PROJ_FACE_NOSEAM1

#define PROJ_FACE_NOSEAM1   (1 << 5)

Definition at line 158 of file paint_image_proj.cc.

◆ PROJ_FACE_NOSEAM2

#define PROJ_FACE_NOSEAM2   (1 << 6)

Definition at line 159 of file paint_image_proj.cc.

◆ PROJ_FACE_SCALE_SEAM

#define PROJ_FACE_SCALE_SEAM   0.99f

Definition at line 175 of file paint_image_proj.cc.

Referenced by project_paint_face_init().

◆ PROJ_FACE_SEAM0

#define PROJ_FACE_SEAM0   (1 << 0)

◆ PROJ_FACE_SEAM1

#define PROJ_FACE_SEAM1   (1 << 1)

Definition at line 154 of file paint_image_proj.cc.

Referenced by project_paint_face_init().

◆ PROJ_FACE_SEAM2

#define PROJ_FACE_SEAM2   (1 << 2)

Definition at line 155 of file paint_image_proj.cc.

Referenced by project_paint_face_init().

◆ PROJ_FACE_SEAM_INIT0

#define PROJ_FACE_SEAM_INIT0   (1 << 8)

Definition at line 162 of file paint_image_proj.cc.

Referenced by project_face_seams_init(), and project_paint_face_init().

◆ PROJ_FACE_SEAM_INIT1

#define PROJ_FACE_SEAM_INIT1   (1 << 9)

Definition at line 163 of file paint_image_proj.cc.

Referenced by project_paint_face_init().

◆ PROJ_FACE_SEAM_INIT2

#define PROJ_FACE_SEAM_INIT2   (1 << 10)

Definition at line 164 of file paint_image_proj.cc.

Referenced by project_paint_face_init().

◆ PROJ_FACE_WINDING_CW

#define PROJ_FACE_WINDING_CW   2

◆ PROJ_FACE_WINDING_INIT

#define PROJ_FACE_WINDING_INIT   1

◆ PROJ_GEOM_TOLERANCE

#define PROJ_GEOM_TOLERANCE   0.00075f

Definition at line 192 of file paint_image_proj.cc.

Referenced by cmp_uv(), and project_bucket_clip_face().

◆ PROJ_PAINT_STATE_SHARED_CLEAR

#define PROJ_PAINT_STATE_SHARED_CLEAR ( ps)    MEMSET_STRUCT_AFTER(ps, 0, is_shared_user)

Definition at line 404 of file paint_image_proj.cc.

Referenced by paint_proj_stroke_done().

◆ PROJ_PAINT_STATE_SHARED_MEMCPY

#define PROJ_PAINT_STATE_SHARED_MEMCPY ( ps_dst,
ps_src )    MEMCPY_STRUCT_AFTER(ps_dst, ps_src, is_shared_user)

This data is owned by ProjStrokeHandle.ps_views[0], all other views re-use the data.

Definition at line 401 of file paint_image_proj.cc.

Referenced by paint_proj_new_stroke().

◆ PROJ_PIXEL_TOLERANCE

#define PROJ_PIXEL_TOLERANCE   0.01f

◆ PROJ_SRC_IMAGE_CAM

#define PROJ_SRC_IMAGE_CAM   2

◆ PROJ_SRC_IMAGE_VIEW

#define PROJ_SRC_IMAGE_VIEW   3

◆ PROJ_SRC_VIEW

◆ PROJ_SRC_VIEW_FILL

◆ PROJ_VERT_CULL

#define PROJ_VERT_CULL   1

◆ PROJ_VIEW_DATA_ID

#define PROJ_VIEW_DATA_ID   "view_data"

◆ PROJ_VIEW_DATA_SIZE

#define PROJ_VIEW_DATA_SIZE   (4 * 4 + 4 * 4 + 3)

Definition at line 185 of file paint_image_proj.cc.

Referenced by texture_paint_camera_project_exec().

◆ PS_CORNER_TRI_AS_UV_3

#define PS_CORNER_TRI_AS_UV_3 ( uvlayer,
face_i,
tri )    uvlayer[face_i][tri[0]], uvlayer[face_i][tri[1]], uvlayer[face_i][tri[2]],

◆ PS_CORNER_TRI_AS_VERT_INDEX_3

#define PS_CORNER_TRI_AS_VERT_INDEX_3 ( ps,
tri )    ps->corner_verts_eval[tri[0]], ps->corner_verts_eval[tri[1]], ps->corner_verts_eval[tri[2]],

◆ PS_CORNER_TRI_ASSIGN_UV_3

#define PS_CORNER_TRI_ASSIGN_UV_3 ( uv_tri,
uvlayer,
face_i,
tri )
Value:
{ \
(uv_tri)[0] = uvlayer[face_i][tri[0]]; \
(uv_tri)[1] = uvlayer[face_i][tri[1]]; \
(uv_tri)[2] = uvlayer[face_i][tri[2]]; \
} \
((void)0)

Definition at line 536 of file paint_image_proj.cc.

Referenced by project_paint_PickColor().

◆ TILE_PENDING

#define TILE_PENDING   POINTER_FROM_INT(-1)

Definition at line 199 of file paint_image_proj.cc.

Referenced by project_paint_undo_subtiles(), and project_paint_uvpixel_init().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
LAYER_BASE_COLOR 
LAYER_SPECULAR 
LAYER_ROUGHNESS 
LAYER_METALLIC 
LAYER_NORMAL 
LAYER_BUMP 
LAYER_DISPLACEMENT 

Definition at line 6488 of file paint_image_proj.cc.

Function Documentation

◆ add_simple_uvs_exec()

◆ add_simple_uvs_poll()

static bool add_simple_uvs_poll ( bContext * C)
static

◆ check_seam()

◆ cmp_uv()

static bool cmp_uv ( const float vec2a[2],
const float vec2b[2] )
static

Definition at line 1004 of file paint_image_proj.cc.

References fabsf, fmodf, PROJ_GEOM_TOLERANCE, and true.

Referenced by check_seam(), and find_adjacent_seam().

◆ compute_seam_normal()

static float compute_seam_normal ( VertSeam * seam,
VertSeam * adj,
float r_no[2] )
static

Definition at line 1242 of file paint_image_proj.cc.

References VertSeam::angle, cosf, M_PI, and sinf.

Referenced by uv_image_outset().

◆ copy_original_alpha_channel()

static void copy_original_alpha_channel ( ProjPixel * pixel,
bool is_floatbuf )
static

Definition at line 5163 of file paint_image_proj.cc.

References premul_to_straight_v4_v4(), and straight_to_premul_v4_v4().

Referenced by do_projectpaint_thread().

◆ default_paint_slot_color_get()

static void default_paint_slot_color_get ( int layer_type,
Material * ma,
float color[4] )
static

◆ do_projectpaint_clone()

static void do_projectpaint_clone ( ProjPaintState * ps,
ProjPixel * projPixel,
float mask )
static

◆ do_projectpaint_clone_f()

static void do_projectpaint_clone_f ( ProjPaintState * ps,
ProjPixel * projPixel,
float mask )
static

◆ do_projectpaint_draw()

◆ do_projectpaint_draw_f()

◆ do_projectpaint_mask()

◆ do_projectpaint_mask_f()

◆ do_projectpaint_smear()

static void do_projectpaint_smear ( ProjPaintState * ps,
ProjPixel * projPixel,
float mask,
MemArena * smearArena,
LinkNode ** smearPixels,
const float co[2] )
static
Note
mask is used to modify the alpha here, this is not correct since it allows accumulation of color greater than 'projPixel->mask' however in the case of smear its not really that important to be correct as it is with clone and painting

Definition at line 4894 of file paint_image_proj.cc.

References blend_color_interpolate_byte(), BLI_linklist_prepend_arena(), PixelPointer::ch_pt, ProjPixel::pixel, and project_paint_PickColor().

Referenced by do_projectpaint_thread().

◆ do_projectpaint_smear_f()

static void do_projectpaint_smear_f ( ProjPaintState * ps,
ProjPixel * projPixel,
float mask,
MemArena * smearArena,
LinkNode ** smearPixels_f,
const float co[2] )
static

◆ do_projectpaint_soften()

◆ do_projectpaint_soften_f()

◆ do_projectpaint_thread()

static void do_projectpaint_thread ( TaskPool * __restrict,
void * ph_v )
static

Definition at line 5180 of file paint_image_proj.cc.

References ProjPixel::bb_cell_index, BKE_brush_alpha_get(), BKE_brush_color_texture_get(), BKE_brush_curve_strength_clamped(), BKE_brush_sample_masktex(), BKE_brush_sample_tex_3d(), BKE_colorband_evaluate(), Brush::blend, ProjPaintState::blend, blend_color_mix_byte(), blend_color_mix_float(), BLI_assert, BLI_memarena_free(), BLI_memarena_new(), ProjPaintState::brush, BRUSH_ACCUMULATE, BRUSH_GRADIENT_LINEAR, BRUSH_GRADIENT_RADIAL, BRUSH_LOCK_ALPHA, MTex::brush_map_mode, ProjPaintState::brush_size, ProjPaintState::brush_type, BRUSH_USE_GRADIENT, ProjPaintState::bucketFlags, ProjPaintState::bucketRect, ImBuf::byte_buffer, PixelStore::ch, PixelPointer::ch_pt, CLAMP, copy_original_alpha_channel(), copy_v2_v2(), copy_v3_v3(), copy_v4_v4(), ImBufByteBuffer::data, ImBufFloatBuffer::data, ProjPaintState::dither, ProjPaintState::do_masking, do_projectpaint_clone(), do_projectpaint_clone_f(), do_projectpaint_draw(), do_projectpaint_draw_f(), do_projectpaint_mask(), do_projectpaint_mask_f(), do_projectpaint_smear(), do_projectpaint_smear_f(), do_projectpaint_soften(), do_projectpaint_soften_f(), dot_v2v2(), ELEM, PixelStore::f, PixelPointer::f_pt, false, Brush::flag, float, ImBuf::float_buffer, float_to_byte_dither_v3(), Brush::gradient, Brush::gradient_fill_mode, ProjPaintImage::ibuf, ProjPixel::image_index, IMAGE_PAINT_BRUSH_TYPE_CLONE, IMAGE_PAINT_BRUSH_TYPE_MASK, IMAGE_PAINT_BRUSH_TYPE_SMEAR, IMAGE_PAINT_BRUSH_TYPE_SOFTEN, image_paint_partial_redraw_expand(), IMB_BLEND_ADD_ALPHA, IMB_blend_color_byte(), IMB_blend_color_float(), IMB_BLEND_ERASE_ALPHA, blender::imbuf::interpolate_cubic_bspline_byte(), blender::imbuf::interpolate_cubic_bspline_fl(), ProjPaintState::is_maskbrush, ProjPaintState::is_texbrush, len_squared_v2(), len_squared_v2v2(), len_v2(), linearrgb_to_srgb_v3_v3(), mask(), ProjPixel::mask, ProjPixel::mask_accum, MEM_SIZE_OPTIMAL, min_ff(), MTEX_MAP_MODE_3D, mul_v3_fl(), mul_v4_v4fl(), ProjPixel::newColor, LinkNode::next, node, OB_MODE_TEXTURE_PAINT, ProjPixel::origColor, ProjPaintState::paint_color, ProjPaintState::paint_color_linear, ProjPaintImage::partRedrawRect, ProjPixel::pixel, pos, PROJ_BUCKET_NULL, PROJ_PIXEL_TOLERANCE, PROJ_SRC_VIEW, PROJ_SRC_VIEW_FILL, ProjPixel::projCoSS, project_bucket_init(), project_bucket_iter_next(), ProjPaintState::reproject_ibuf, rgb_float_to_uchar(), ProjPaintState::scene, ProjPaintState::source, sqrtf, sub_v2_v2v2(), ProjPaintImage::touch, PixelStore::uint_, PixelPointer::uint_pt, unit_float_to_uchar_clamp, unit_float_to_uchar_clamp_v3, ProjPixel::valid, ProjPixel::worldCoSS, ProjPixel::x_px, rctf::xmax, rctf::xmin, ProjPixel::y_px, rctf::ymax, rctf::ymin, and zero_v3().

Referenced by project_paint_op().

◆ ED_paint_data_warning()

void ED_paint_data_warning ( ReportList * reports,
bool has_uvs,
bool has_mat,
bool has_tex,
bool has_stencil )

◆ ED_paint_proj_mesh_data_check()

◆ f_to_char()

BLI_INLINE uchar f_to_char ( const float val)

Definition at line 121 of file paint_image_proj.cc.

References unit_float_to_uchar_clamp.

Referenced by do_projectpaint_draw(), and do_projectpaint_mask().

◆ find_adjacent_seam()

◆ float_z_sort()

static int float_z_sort ( const void * p1,
const void * p2 )
static

Definition at line 2423 of file paint_image_proj.cc.

Referenced by project_bucket_clip_face().

◆ float_z_sort_flip()

static int float_z_sort_flip ( const void * p1,
const void * p2 )
static

Clip the face by a bucket and set the uv-space bucket_bounds_uv so we have the clipped UVs to do pixel intersection tests with

Definition at line 2418 of file paint_image_proj.cc.

Referenced by project_bucket_clip_face().

◆ get_default_texture_layer_name_for_object()

static void get_default_texture_layer_name_for_object ( Object * ob,
int texture_type,
char * dst,
int dst_maxncpy )
static

◆ get_or_create_current_material()

static Material * get_or_create_current_material ( bContext * C,
Object * ob )
static

◆ get_texture_layer_type()

static int get_texture_layer_type ( wmOperator * op,
const char * prop_name )
static

◆ image_paint_partial_redraw_expand()

static void image_paint_partial_redraw_expand ( ImagePaintPartialRedraw * cell,
const ProjPixel * projPixel )
static

◆ insert_seam_vert_array()

◆ IsectPoly2Df()

static bool IsectPoly2Df ( const float pt[2],
const float uv[][2],
const int tot )
static
# This script creates faces in a blender scene from printed data above.
project_ls = [
...(output from above block)...
]
from Blender import Scene, Mesh, Window, sys, Mathutils
import bpy
V = Mathutils.Vector
def main():
scene = bpy.data.scenes.active
for item in project_ls:
bb = item[0]
uv = item[1]
poly = item[2]
me = bpy.data.meshes.new()
ob = scene.objects.new(me)
me.verts.extend([V(bb[0]).xyz, V(bb[1]).xyz, V(bb[2]).xyz, V(bb[3]).xyz])
me.faces.extend([(0,1,2,3),])
me.verts.extend([V(uv[0]).xyz, V(uv[1]).xyz, V(uv[2]).xyz])
me.faces.extend([(4,5,6),])
vs = [V(p).xyz for p in poly]
print len(vs)
l = len(me.verts)
me.verts.extend(vs)
i = l
while i < len(me.verts):
ii = i + 1
if ii == len(me.verts):
ii = l
me.edges.extend([i, ii])
i += 1
if __name__ == '__main__':
main()
int len
int main()
CCL_NAMESPACE_BEGIN struct Window V

Definition at line 2932 of file paint_image_proj.cc.

References line_point_side_v2().

Referenced by project_paint_face_init().

◆ IsectPoly2Df_twoside()

static bool IsectPoly2Df_twoside ( const float pt[2],
const float uv[][2],
const int tot )
static

Definition at line 2947 of file paint_image_proj.cc.

References line_point_side_v2().

Referenced by project_paint_face_init().

◆ IsectPT2Df_limit()

static bool IsectPT2Df_limit ( const float pt[2],
const float v1[2],
const float v2[2],
const float v3[2],
const float limit )
static

Definition at line 2407 of file paint_image_proj.cc.

References area_tri_v2(), and v2.

Referenced by project_bucket_clip_face().

◆ len_squared_v2v2_alt()

static float len_squared_v2v2_alt ( const float v1[2],
const float v2_1,
const float v2_2 )
static

Definition at line 2227 of file paint_image_proj.cc.

References x, and y.

Referenced by project_bucket_isect_circle().

◆ line_clip_rect2f()

static bool line_clip_rect2f ( const rctf * cliprect,
const rctf * rect,
const float l1[2],
const float l2[2],
float l1_clip[2],
float l2_clip[2] )
static

◆ line_isect_x()

static int line_isect_x ( const float p1[2],
const float p2[2],
const float x_level,
float * y_isect )
static

Definition at line 964 of file paint_image_proj.cc.

References fabsf, ISECT_TRUE, ISECT_TRUE_P1, and ISECT_TRUE_P2.

Referenced by line_clip_rect2f().

◆ line_isect_y()

static int line_isect_y ( const float p1[2],
const float p2[2],
const float y_level,
float * x_isect )
static

yuck, horizontal line, we can't do much here.

Definition at line 928 of file paint_image_proj.cc.

References fabsf, ISECT_TRUE, ISECT_TRUE_P1, and ISECT_TRUE_P2.

Referenced by line_clip_rect2f().

◆ line_rect_clip()

static bool line_rect_clip ( const rctf * rect,
const float l1[4],
const float l2[4],
const float uv1[2],
const float uv2[2],
float uv[2],
bool is_ortho )
static

Definition at line 2429 of file paint_image_proj.cc.

References FLT_MAX, min, min_ff(), rctf::xmax, rctf::xmin, rctf::ymax, and rctf::ymin.

Referenced by project_bucket_clip_face().

◆ PAINT_OT_add_simple_uvs()

◆ PAINT_OT_add_texture_paint_slot()

◆ PAINT_OT_image_from_view()

◆ PAINT_OT_project_image()

◆ paint_proj_begin_clone()

◆ paint_proj_new_stroke()

◆ paint_proj_redraw()

◆ paint_proj_stroke()

◆ paint_proj_stroke_done()

◆ paint_proj_stroke_ps()

◆ partial_redraw_array_init()

static void partial_redraw_array_init ( ImagePaintPartialRedraw * pr)
static

◆ partial_redraw_array_merge()

static bool partial_redraw_array_merge ( ImagePaintPartialRedraw * pr,
ImagePaintPartialRedraw * pr_other,
int tot )
static

◆ partial_redraw_single_init()

static void partial_redraw_single_init ( ImagePaintPartialRedraw * pr)
static

◆ pixel_bounds_array()

static bool pixel_bounds_array ( float(*) uv[2],
const int ibuf_x,
const int ibuf_y,
int tot,
rcti * r_bounds_px )
static

◆ pixel_bounds_uv()

static bool pixel_bounds_uv ( const float uv_quad[4][2],
const int ibuf_x,
const int ibuf_y,
rcti * r_bounds_px )
static

◆ proj_paint_add_slot()

static bool proj_paint_add_slot ( bContext * C,
wmOperator * op )
static

◆ proj_paint_color_attribute_create()

static const char * proj_paint_color_attribute_create ( wmOperator * op,
Object & ob )
static

◆ proj_paint_face_coSS_init()

static void proj_paint_face_coSS_init ( const ProjPaintState * ps,
const int3 & corner_tri,
ProjPaintFaceCoSS * coSS )
static

◆ proj_paint_face_lookup_init()

◆ proj_paint_image_create()

static Image * proj_paint_image_create ( wmOperator * op,
Main * bmain,
bool is_data )
static

◆ proj_paint_layer_clone_init()

◆ proj_paint_state_cavity_init()

◆ proj_paint_state_mesh_eval_init()

◆ proj_paint_state_screen_coords_init()

◆ proj_paint_state_seam_bleed_init()

◆ proj_paint_state_thread_init()

◆ proj_paint_state_vert_flags_init()

◆ proj_paint_state_viewport_init()

◆ project_bucket_bounds()

static void project_bucket_bounds ( const ProjPaintState * ps,
const int bucket_x,
const int bucket_y,
rctf * r_bucket_bounds )
static

◆ project_bucket_clip_face()

static void project_bucket_clip_face ( const bool is_ortho,
const bool is_flip_object,
const rctf * cliprect,
const rctf * bucket_bounds,
const float * v1coSS,
const float * v2coSS,
const float * v3coSS,
const float * uv1co,
const float * uv2co,
const float * uv3co,
float bucket_bounds_uv[8][2],
int * tot,
bool cull )
static

◆ project_bucket_face_isect()

static bool project_bucket_face_isect ( ProjPaintState * ps,
int bucket_x,
int bucket_y,
const int3 & tri )
static

◆ project_bucket_init()

◆ project_bucket_isect_circle()

static bool project_bucket_isect_circle ( const float cent[2],
const float radius_squared,
const rctf * bucket_bounds )
static
Note
Use a squared value so we can use len_squared_v2v2 be sure that you have done a bounds check first or this may fail.

Only give bucket_bounds as an arg because we need it elsewhere.

Definition at line 2242 of file paint_image_proj.cc.

References BLI_rctf_isect_pt_v(), len_squared_v2v2_alt(), true, rctf::xmax, rctf::xmin, rctf::ymax, and rctf::ymin.

Referenced by project_bucket_iter_next().

◆ project_bucket_iter_init()

◆ project_bucket_iter_next()

◆ project_bucket_offset()

static int project_bucket_offset ( const ProjPaintState * ps,
const float projCoSS[2] )
static

Fast projection bucket array lookup, use the safe version for bound checking.

Definition at line 607 of file paint_image_proj.cc.

References ProjPaintState::buckets_x, ProjPaintState::buckets_y, int, ProjPaintState::screen_height, ProjPaintState::screen_width, and ProjPaintState::screenMin.

Referenced by project_bucket_offset_safe().

◆ project_bucket_offset_safe()

static int project_bucket_offset_safe ( const ProjPaintState * ps,
const float projCoSS[2] )
static

◆ project_bucket_point_occluded()

◆ project_face_pixel()

static void project_face_pixel ( const float * tri_uv[3],
ImBuf * ibuf_other,
const float w[3],
uchar rgba_ub[4],
float rgba_f[4] )
static

◆ project_face_seams_init()

static void project_face_seams_init ( const ProjPaintState * ps,
MemArena * arena,
const int tri_index,
const uint vert_index,
bool init_all,
const int ibuf_x,
const int ibuf_y )
static

◆ project_face_winding_init()

◆ project_image_refresh_tagged()

◆ project_paint_begin()

static void project_paint_begin ( const bContext * C,
ProjPaintState * ps,
const bool is_multi_view,
const char symmetry_flag )
static

◆ project_paint_bleed_add_face_user()

◆ project_paint_bucket_bounds()

static void project_paint_bucket_bounds ( const ProjPaintState * ps,
const float min[2],
const float max[2],
int bucketMin[2],
int bucketMax[2] )
static

Takes floating point screen-space min/max and returns int min/max to be used as indices for ps->bucketRect, ps->bucketFlags

Definition at line 3443 of file paint_image_proj.cc.

References ProjPaintState::buckets_x, ProjPaintState::buckets_y, CLAMP, int, min, ProjPaintState::screen_height, ProjPaintState::screen_width, and ProjPaintState::screenMin.

Referenced by project_bucket_iter_init(), and project_paint_delayed_face_init().

◆ project_paint_build_proj_ima()

◆ project_paint_check_face_paintable()

◆ project_paint_clone_face_skip()

◆ project_paint_delayed_face_init()

◆ project_paint_end()

◆ project_paint_face_clone_image()

static Image * project_paint_face_clone_image ( const ProjPaintState * ps,
int tri_index )
static

◆ project_paint_face_clone_slot()

static TexPaintSlot * project_paint_face_clone_slot ( const ProjPaintState * ps,
int tri_index )
static

◆ project_paint_face_init()

static void project_paint_face_init ( const ProjPaintState * ps,
const int thread_index,
const int bucket_index,
const int tri_index,
const int image_index,
const rctf * clip_rect,
const rctf * bucket_bounds,
ImBuf * ibuf,
ImBuf ** tmpibuf )
static

Definition at line 2965 of file paint_image_proj.cc.

References ProjPaintState::arena_mt, BLI_linklist_prepend_arena(), BLI_thread_lock(), BLI_thread_unlock(), ProjPaintState::brush, MTex::brush_map_mode, ProjPaintState::bucketFaces, ProjPaintState::bucketRect, LoopSeamData::corner_dist_sq, ProjPaintState::corner_tri_faces_eval, ProjPaintState::corner_tris_eval, ProjPaintState::do_backfacecull, ProjPaintState::do_masking, ProjPaintState::do_occlude, ED_IMAGE_UNDO_TILE_NUMBER, ED_view3d_clipping_test(), equals_v2v2(), ProjPaintState::faceSeamFlags, flag, float, interp_v2_v2v2(), interp_v3_v3v3(), interp_v3_v3v3v3(), ProjPaintState::is_flip_object, ProjPaintState::is_ortho, isect_point_quad_v2(), isect_point_tri_v2(), IsectPoly2Df(), IsectPoly2Df_twoside(), len_squared_v2v2(), line_clip_rect2f(), line_point_factor_v2(), LOCK_CUSTOM1, ProjPaintState::loopSeamData, mask(), Brush::mtex, MTEX_MAP_MODE_3D, mul_m4_v4(), pixel_bounds_array(), pixel_bounds_uv(), ProjPaintState::poly_to_loop_uv, printf, PROJ_FACE_DEGENERATE, PROJ_FACE_SCALE_SEAM, PROJ_FACE_SEAM0, PROJ_FACE_SEAM1, PROJ_FACE_SEAM2, PROJ_FACE_SEAM_INIT0, PROJ_FACE_SEAM_INIT1, PROJ_FACE_SEAM_INIT2, PROJ_PIXEL_TOLERANCE, project_bucket_clip_face(), project_bucket_point_occluded(), project_face_seams_init(), project_paint_uvpixel_init(), project_paint_uvpixel_mask(), ProjPaintState::projectMat, ProjPaintState::projImages, PS_CORNER_TRI_AS_UV_3, PS_CORNER_TRI_AS_VERT_INDEX_3, resolve_quad_u_v2(), ProjPaintState::rv3d, RV3D_CLIPPING_ENABLED, scale_tri(), screen_px_from_ortho(), screen_px_from_persp(), screen_px_line_point_factor_v2_persp(), ProjPaintState::screenCoords, ProjPaintState::seam_bleed_px, ProjPaintState::seam_bleed_px_sq, LoopSeamData::seam_puvs, LoopSeamData::seam_uvs, ProjPaintState::thread_tot, ProjPaintState::tile_lock, UNPACK3, UNPACK4, UNUSED_VARS, uv_image_outset(), ProjPaintState::v3d, ProjPaintState::vert_positions_eval, w(), ProjPaintState::winx, ProjPaintState::winy, ImBuf::x, x, rcti::xmax, rcti::xmin, ImBuf::y, y, rcti::ymax, and rcti::ymin.

Referenced by project_bucket_init().

◆ project_paint_face_paint_image()

◆ project_paint_face_paint_slot()

static TexPaintSlot * project_paint_face_paint_slot ( const ProjPaintState * ps,
int tri_index )
static

◆ project_paint_face_paint_tile()

static int project_paint_face_paint_tile ( Image * ima,
const float * uv )
static

◆ project_paint_flt_max_cull()

static bool project_paint_flt_max_cull ( const ProjPaintState * ps,
const ProjPaintFaceCoSS * coSS )
static

◆ project_paint_occlude_ptv()

static int project_paint_occlude_ptv ( const float pt[3],
const float v1[4],
const float v2[4],
const float v3[4],
float w[3],
const bool is_ortho )
static

Check if 'pt' is in front of the 3 verts on the Z axis (used for screen-space occlusion test)

Returns
  • 0: no occlusion.
  • -1: no occlusion but 2D intersection is true.
  • 1: occluded.
  • 2: occluded with w[3] weights set (need to know in some cases).

Definition at line 798 of file paint_image_proj.cc.

References isect_point_tri_v2(), v2, VecZDepthOrtho(), VecZDepthPersp(), and w().

Referenced by project_bucket_point_occluded(), and project_paint_occlude_ptv_clip().

◆ project_paint_occlude_ptv_clip()

static int project_paint_occlude_ptv_clip ( const float pt[3],
const float v1[4],
const float v2[4],
const float v3[4],
const float v1_3d[3],
const float v2_3d[3],
const float v3_3d[3],
float w[3],
const bool is_ortho,
RegionView3D * rv3d )
static

◆ project_paint_op()

static bool project_paint_op ( void * state,
const float lastpos[2],
const float pos[2] )
static

◆ project_paint_PickColor()

◆ project_paint_PickFace()

◆ project_paint_pixel_sizeof()

static int project_paint_pixel_sizeof ( const short brush_type)
static

◆ project_paint_prepare_all_faces()

static void project_paint_prepare_all_faces ( ProjPaintState * ps,
MemArena * arena,
const ProjPaintFaceLookup * face_lookup,
ProjPaintLayerClone * layer_clone,
const float(*) mloopuv_base[2],
const bool is_multi_view )
static

◆ project_paint_undo_subtiles()

◆ project_paint_uvpixel_init()

static ProjPixel * project_paint_uvpixel_init ( const ProjPaintState * ps,
MemArena * arena,
const TileInfo * tinf,
int x_px,
int y_px,
const float mask,
const int tri_index,
const float pixelScreenCo[4],
const float world_spaceCo[3],
const float w[3] )
static

Definition at line 1858 of file paint_image_proj.cc.

References ProjPixel::bb_cell_index, BKE_image_acquire_ibuf(), BKE_image_release_ibuf(), BLI_assert, BLI_memarena_alloc(), ProjPaintState::brush, MTex::brush_map_mode, ProjPaintState::brush_type, ImBuf::byte_buffer, PixelPointer::ch_pt, ProjPaintState::cloneOffset, copy_v2_v2(), copy_v3_v3(), ProjPaintState::corner_tri_faces_eval, ProjPaintState::corner_tris_eval, ImBufByteBuffer::data, ImBufFloatBuffer::data, ProjPaintState::do_masking, ED_IMAGE_UNDO_TILE_BITS, ED_IMAGE_UNDO_TILE_NUMBER, ED_IMAGE_UNDO_TILE_SIZE, PixelStore::f, PixelPointer::f_pt, ImBuf::float_buffer, ProjPaintImage::ibuf, ProjPixel::image_index, IMAGE_PAINT_BRUSH_TYPE_CLONE, int, linearrgb_to_srgb_uchar3(), ProjPixel::mask, ProjPixel::mask_accum, ProjPaintImage::maskRect, mod_i(), Brush::mtex, MTEX_MAP_MODE_3D, ProjPixel::newColor, ProjPixel::origColor, ProjPixel::pixel, ProjPaintState::pixel_sizeof, TileInfo::pjima, ProjPaintState::poly_to_loop_uv_clone, premul_to_straight_v4(), PROJ_BOUNDBOX_DIV, ProjPixel::projCoSS, project_face_pixel(), project_paint_face_clone_image(), project_paint_PickColor(), project_paint_pixel_sizeof(), project_paint_undo_subtiles(), ProjPaintState::projImages, PS_CORNER_TRI_AS_UV_3, srgb_to_linearrgb_uchar4(), straight_to_premul_v4_v4(), sub_v2_v2v2(), tile_index, TILE_PENDING, PixelStore::uint_, PixelPointer::uint_pt, ProjPaintImage::undoRect, ProjPaintImage::valid, ProjPixel::valid, w(), ProjPixel::worldCoSS, ImBuf::x, ProjPixel::x_px, ImBuf::y, ProjPixel::y_px, and zero_v4().

Referenced by project_paint_face_init().

◆ project_paint_uvpixel_mask()

◆ project_paint_winclip()

◆ project_state_init()

static void project_state_init ( bContext * C,
Object * ob,
ProjPaintState * ps,
int mode )
static

Definition at line 5835 of file paint_image_proj.cc.

References BKE_paint_brush(), BKE_paint_get_active_from_context(), Brush::blend, ProjPaintState::blend, BLI_assert, ProjPaintState::blurkernel, ProjPaintState::brush, BRUSH_DIR_IN, BRUSH_STROKE_INVERT, BRUSH_STROKE_NORMAL, BRUSH_STROKE_SMOOTH, ProjPaintState::brush_type, ProjPaintState::canvas_ima, ProjPaintState::cavity_curve, ProjPaintState::clone_ima, cosf, CTX_data_ensure_evaluated_depsgraph(), CTX_data_scene(), CTX_wm_region(), CTX_wm_region_view3d(), CTX_wm_view3d(), ProjPaintState::depsgraph, ProjPaintState::dither, ProjPaintState::do_backfacecull, ProjPaintState::do_layer_clone, ProjPaintState::do_layer_stencil, ProjPaintState::do_layer_stencil_inv, ProjPaintState::do_mask_cavity, ProjPaintState::do_mask_normal, ProjPaintState::do_masking, ProjPaintState::do_material_slots, ProjPaintState::do_occlude, ProjPaintState::do_stencil_brush, Brush::flag, float, Brush::image_brush_type, IMAGE_PAINT_BRUSH_TYPE_CLONE, IMAGE_PAINT_BRUSH_TYPE_DRAW, IMAGE_PAINT_BRUSH_TYPE_FILL, IMAGE_PAINT_BRUSH_TYPE_MASK, IMAGE_PAINT_BRUSH_TYPE_SOFTEN, IMAGEPAINT_MODE_MATERIAL, IMAGEPAINT_PROJECT_BACKFACE, IMAGEPAINT_PROJECT_FLAT, IMAGEPAINT_PROJECT_LAYER_CLONE, IMAGEPAINT_PROJECT_LAYER_STENCIL, IMAGEPAINT_PROJECT_LAYER_STENCIL_INV, IMAGEPAINT_PROJECT_XRAY, ProjPaintState::is_maskbrush, ProjPaintState::is_texbrush, M_PI_2, Brush::mask_mtex, ProjPaintState::mode, Brush::mtex, ProjPaintState::normal_angle, ProjPaintState::normal_angle__cos, ProjPaintState::normal_angle_inner, ProjPaintState::normal_angle_inner__cos, ProjPaintState::normal_angle_range, ProjPaintState::ob, ProjPaintState::paint, paint_new_blur_kernel(), PAINT_USE_CAVITY_MASK, paint_use_opacity_masking(), ProjPaintState::pixel_sizeof, project_paint_pixel_sizeof(), ProjPaintState::region, ProjPaintState::rv3d, ProjPaintState::scene, scene, ProjPaintState::seam_bleed_px, ProjPaintState::seam_bleed_px_sq, square_s(), ProjPaintState::stencil_ima, MTex::tex, and ProjPaintState::v3d.

Referenced by paint_proj_new_stroke(), and texture_paint_camera_project_exec().

◆ rect_to_uvspace_ortho()

static void rect_to_uvspace_ortho ( const rctf * bucket_bounds,
const float * v1coSS,
const float * v2coSS,
const float * v3coSS,
const float * uv1co,
const float * uv2co,
const float * uv3co,
float bucket_bounds_uv[4][2],
const int flip )
static

◆ rect_to_uvspace_persp()

static void rect_to_uvspace_persp ( const rctf * bucket_bounds,
const float * v1coSS,
const float * v2coSS,
const float * v3coSS,
const float * uv1co,
const float * uv2co,
const float * uv3co,
float bucket_bounds_uv[4][2],
const int flip )
static

◆ scale_tri()

static void scale_tri ( float insetCos[3][3],
const float * origCos[3],
const float inset )
static

Scale the tri about its center scaling by PROJ_FACE_SCALE_SEAM (0.99x) is used for getting fake UV pixel coords that are on the edge of the face but slightly inside it occlusion tests don't return hits on adjacent faces.

Definition at line 2206 of file paint_image_proj.cc.

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

Referenced by project_paint_face_init().

◆ screen_px_from_ortho()

static void screen_px_from_ortho ( const float uv[2],
const float v1co[3],
const float v2co[3],
const float v3co[3],
const float uv1co[2],
const float uv2co[2],
const float uv3co[2],
float pixelScreenCo[4],
float w[3] )
static

Definition at line 1517 of file paint_image_proj.cc.

References barycentric_weights_v2(), interp_v3_v3v3v3(), and w().

Referenced by project_paint_face_init().

◆ screen_px_from_persp()

static void screen_px_from_persp ( const float uv[2],
const float v1co[4],
const float v2co[4],
const float v3co[4],
const float uv1co[2],
const float uv2co[2],
const float uv3co[2],
float pixelScreenCo[4],
float w[3] )
static

Definition at line 1533 of file paint_image_proj.cc.

References barycentric_weights_v2(), interp_v3_v3v3v3(), and w().

Referenced by project_paint_face_init().

◆ screen_px_line_point_factor_v2_persp()

static float screen_px_line_point_factor_v2_persp ( const ProjPaintState * ps,
const float p[2],
const float v1[3],
const float v2[3] )
static

Special function to return the factor to a point along a line in pixel space.

This is needed since we can't use line_point_factor_v2 for perspective screen-space coords.

Parameters
p2D screen-space location.
v1,v23D object-space locations.

Definition at line 1600 of file paint_image_proj.cc.

References line_point_factor_v2(), project_plane_v3_v3v3(), ProjPaintState::projectMatInv, screen_px_to_vector_persp(), sub_v3_v3v3(), v2, ProjPaintState::viewPos, ProjPaintState::winx, and ProjPaintState::winy.

Referenced by project_paint_face_init().

◆ screen_px_to_vector_persp()

static void screen_px_to_vector_persp ( int winx,
int winy,
const float projmat_inv[4][4],
const float view_pos[3],
const float co_px[2],
float r_dir[3] )
static

Set a direction vector based on a screen location. (use for perspective view, else we can simply use ps->viewDir)

Similar functionality to ED_view3d_win_to_vector

Parameters
r_dirResulting direction (length is undefined).

Definition at line 1578 of file paint_image_proj.cc.

References mul_project_m4_v3(), and sub_v3_v3().

Referenced by screen_px_line_point_factor_v2_persp().

◆ tex_get_material()

◆ texture_paint_add_texture_paint_slot_exec()

static int texture_paint_add_texture_paint_slot_exec ( bContext * C,
wmOperator * op )
static

◆ texture_paint_add_texture_paint_slot_invoke()

◆ texture_paint_add_texture_paint_slot_ui()

◆ texture_paint_camera_project_exec()

static int texture_paint_camera_project_exec ( bContext * C,
wmOperator * op )
static

Definition at line 6095 of file paint_image_proj.cc.

References BKE_brush_size_get(), BKE_brush_size_set(), BKE_image_acquire_ibuf(), BKE_image_free_gputextures(), BKE_report(), BKE_view_layer_active_object_get(), BKE_view_layer_synced_ensure(), BLI_findlink(), ProjPaintState::brush, BRUSH_STROKE_NORMAL, ProjPaintState::brush_type, ImBuf::byte_buffer, CTX_data_main(), CTX_data_scene(), CTX_data_view_layer(), ImBufByteBuffer::data, ImBufFloatBuffer::data, ProjPaintState::do_masking, ED_image_undo_push_begin(), ED_image_undo_push_end(), ED_paint_data_warning(), ED_paint_proj_mesh_data_check(), ImBuf::float_buffer, IDP_ARRAY, IDP_FLOAT, IDP_GetProperties(), IDP_GetPropertyTypeFromGroup(), ProjPaintImage::ima, image(), IMAGE_PAINT_BRUSH_TYPE_DRAW, ProjPaintState::image_tot, IMAGEPAINT_DRAWING, Main::images, ProjPaintState::is_maskbrush, ProjPaintState::is_texbrush, IDProperty::len, ProjPaintState::mesh_eval, NA_EDITED, wmOperatorType::name, NC_IMAGE, NC_SCENE, ND_TOOLSETTINGS, OB_MESH, OPERATOR_CANCELLED, OPERATOR_FINISHED, pos, PROJ_SRC_IMAGE_CAM, PROJ_SRC_IMAGE_VIEW, PROJ_VIEW_DATA_ID, PROJ_VIEW_DATA_SIZE, project_image_refresh_tagged(), project_paint_begin(), project_paint_end(), project_paint_op(), project_state_init(), ProjPaintState::projImages, wmOperator::ptr, wmOperator::reports, ProjPaintState::reproject_ibuf, ProjPaintState::reproject_image, RNA_enum_get(), RPT_ERROR, ProjPaintState::source, IDProperty::subtype, tex, Texture3D, Object::type, wmOperator::type, and WM_event_add_notifier().

Referenced by PAINT_OT_project_image().

◆ texture_paint_image_from_view_exec()

◆ texture_paint_image_from_view_poll()

static bool texture_paint_image_from_view_poll ( bContext * C)
static

◆ uv_image_outset()

◆ VecZDepthOrtho()

static float VecZDepthOrtho ( const float pt[2],
const float v1[3],
const float v2[3],
const float v3[3],
float w[3] )
static

Definition at line 634 of file paint_image_proj.cc.

References barycentric_weights_v2(), v2, and w().

Referenced by project_paint_occlude_ptv(), and project_paint_PickFace().

◆ VecZDepthPersp()

static float VecZDepthPersp ( const float pt[2],
const float v1[4],
const float v2[4],
const float v3[4],
float w[3] )
static

Definition at line 641 of file paint_image_proj.cc.

References barycentric_weights_v2_persp(), v2, and w().

Referenced by project_paint_occlude_ptv(), and project_paint_PickFace().

Variable Documentation

◆ layer_type_items

const EnumPropertyItem layer_type_items[]
static
Initial value:
= {
{LAYER_BASE_COLOR, "BASE_COLOR", 0, "Base Color", ""},
{LAYER_SPECULAR, "SPECULAR", 0, "Specular IOR Level", ""},
{LAYER_ROUGHNESS, "ROUGHNESS", 0, "Roughness", ""},
{LAYER_METALLIC, "METALLIC", 0, "Metallic", ""},
{LAYER_NORMAL, "NORMAL", 0, "Normal", ""},
{LAYER_BUMP, "BUMP", 0, "Bump", ""},
{LAYER_DISPLACEMENT, "DISPLACEMENT", 0, "Displacement", ""},
{0, nullptr, 0, nullptr, nullptr},
}
@ LAYER_NORMAL
@ LAYER_DISPLACEMENT
@ LAYER_ROUGHNESS
@ LAYER_METALLIC
@ LAYER_BUMP
@ LAYER_BASE_COLOR
@ LAYER_SPECULAR

Definition at line 6498 of file paint_image_proj.cc.

Referenced by default_paint_slot_color_get(), get_default_texture_layer_name_for_object(), get_texture_layer_type(), PAINT_OT_add_texture_paint_slot(), and proj_paint_add_slot().