Blender V2.61 - r43446
Classes | Typedefs | Functions

paint_vertex.c File Reference

#include <math.h>
#include <string.h>
#include <unistd.h>
#include "MEM_guardedalloc.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "DNA_armature_types.h"
#include "DNA_mesh_types.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "DNA_brush_types.h"
#include "DNA_object_types.h"
#include "DNA_meshdata_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
#include "BKE_DerivedMesh.h"
#include "BKE_armature.h"
#include "BKE_action.h"
#include "BKE_brush.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_deform.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_report.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_armature.h"
#include "ED_mesh.h"
#include "ED_screen.h"
#include "ED_view3d.h"
#include "paint_intern.h"

Go to the source code of this file.

Classes

struct  WeightPaintInfo
struct  WPaintData
struct  VPaintData

Typedefs

typedef struct WeightPaintInfo WeightPaintInfo
typedef struct VPaintData VPaintData

Functions

int vertex_paint_mode_poll (bContext *C)
int vertex_paint_poll (bContext *C)
int weight_paint_mode_poll (bContext *C)
int weight_paint_poll (bContext *C)
static VPaintnew_vpaint (int wpaint)
static int * get_indexarray (Mesh *me)
static unsigned int rgba_to_mcol (float r, float g, float b, float a)
unsigned int vpaint_get_current_col (VPaint *vp)
static void do_shared_vertexcol (Mesh *me)
static void make_vertexcol (Object *ob)
static int wpaint_mirror_vgroup_ensure (Object *ob, const int vgroup_active)
static void copy_vpaint_prev (VPaint *vp, unsigned int *mcol, int tot)
static void copy_wpaint_prev (VPaint *wp, MDeformVert *dverts, int dcount)
void vpaint_fill (Object *ob, unsigned int paintcol)
void wpaint_fill (VPaint *wp, Object *ob, float paintweight)
static unsigned int mcol_blend (unsigned int col1, unsigned int col2, int fac)
static unsigned int mcol_add (unsigned int col1, unsigned int col2, int fac)
static unsigned int mcol_sub (unsigned int col1, unsigned int col2, int fac)
static unsigned int mcol_mul (unsigned int col1, unsigned int col2, int fac)
static unsigned int mcol_lighten (unsigned int col1, unsigned int col2, int fac)
static unsigned int mcol_darken (unsigned int col1, unsigned int col2, int fac)
static unsigned int vpaint_blend_tool (const int tool, const unsigned int col, const unsigned int paintcol, const int alpha_i)
static unsigned int vpaint_blend (VPaint *vp, unsigned int col, unsigned int colorig, const unsigned int paintcol, const int alpha_i, const int brush_alpha_value_i)
static int sample_backbuf_area (ViewContext *vc, int *indexar, int totface, int x, int y, float size)
static float calc_vp_strength_dl (VPaint *vp, ViewContext *vc, const float *vert_nor, const float mval[2], const float brush_size_pressure)
static float calc_vp_alpha_dl (VPaint *vp, ViewContext *vc, float vpimat[][3], const float *vert_nor, const float mval[2], const float brush_size_pressure, const float brush_alpha_pressure)
static float wpaint_blend_tool (const int tool, const float weight, const float paintval, const float alpha)
static float wpaint_blend (VPaint *wp, float weight, float weight_prev, const float alpha, float paintval, const float brush_alpha_value, const short do_flip, const short do_multipaint_totsel)
static int weight_sample_invoke (bContext *C, wmOperator *op, wmEvent *event)
void PAINT_OT_weight_sample (wmOperatorType *ot)
static EnumPropertyItemweight_paint_sample_enum_itemf (bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
static int weight_sample_group_exec (bContext *C, wmOperator *op)
void PAINT_OT_weight_sample_group (wmOperatorType *ot)
static void do_weight_paint_normalize_all (MDeformVert *dvert, const int defbase_tot, const char *vgroup_validmap)
static void do_weight_paint_normalize_all_active (MDeformVert *dvert, const int defbase_tot, const char *vgroup_validmap, const int vgroup_active)
static char has_locked_group (MDeformVert *dvert, const int defbase_tot, const char *bone_groups, const char *lock_flags)
static char * gen_lock_flags (Object *ob, int defbase_tot)
static int has_locked_group_selected (int defbase_tot, const char *defbase_sel, const char *lock_flags)
static void multipaint_selection (MDeformVert *dvert, const int defbase_tot, float change, const char *defbase_sel)
static float redistribute_change (MDeformVert *ndv, const int defbase_tot, char *change_status, const char change_me, int changeto, float totchange, float total_valid, char do_auto_normalize)
static float get_mp_change (MDeformVert *odv, const int defbase_tot, const char *defbase_sel, float brush_change)
static void enforce_locks (MDeformVert *odv, MDeformVert *ndv, const int defbase_tot, const char *defbase_sel, const char *lock_flags, const char *vgroup_validmap, char do_auto_normalize, char do_multipaint)
static void defvert_reset_to_prev (MDeformVert *dv_prev, MDeformVert *dv)
static void clamp_weights (MDeformVert *dvert)
static int apply_mp_locks_normalize (Mesh *me, const WeightPaintInfo *wpi, const unsigned int index, MDeformWeight *dw, MDeformWeight *tdw, float change, float oldChange, float oldw, float neww)
static int get_first_selected_nonzero_weight (MDeformVert *dvert, const int defbase_tot, const char *defbase_sel)
static char * wpaint_make_validmap (Object *ob)
static void do_weight_paint_vertex (VPaint *wp, Object *ob, const WeightPaintInfo *wpi, const unsigned int index, float alpha, float paintweight)
static int set_wpaint (bContext *C, wmOperator *UNUSED(op))
static int paint_poll_test (bContext *C)
void PAINT_OT_weight_paint_toggle (wmOperatorType *ot)
static int wpaint_stroke_test_start (bContext *C, wmOperator *op, wmEvent *UNUSED(event))
static void wpaint_stroke_update_step (bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
static void wpaint_stroke_done (bContext *C, struct PaintStroke *stroke)
static int wpaint_invoke (bContext *C, wmOperator *op, wmEvent *event)
static int wpaint_cancel (bContext *C, wmOperator *op)
void PAINT_OT_weight_paint (wmOperatorType *ot)
static int weight_paint_set_exec (bContext *C, wmOperator *UNUSED(op))
void PAINT_OT_weight_set (wmOperatorType *ot)
static int set_vpaint (bContext *C, wmOperator *op)
void PAINT_OT_vertex_paint_toggle (wmOperatorType *ot)
static int vpaint_stroke_test_start (bContext *C, struct wmOperator *op, wmEvent *UNUSED(event))
static void vpaint_paint_face (VPaint *vp, VPaintData *vpd, Object *ob, const unsigned int index, const float mval[2], const float brush_size_pressure, const float brush_alpha_pressure, int UNUSED(flip))
static void vpaint_stroke_update_step (bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
static void vpaint_stroke_done (bContext *C, struct PaintStroke *stroke)
static int vpaint_invoke (bContext *C, wmOperator *op, wmEvent *event)
static int vpaint_cancel (bContext *C, wmOperator *op)
void PAINT_OT_vertex_paint (wmOperatorType *ot)
static int weight_from_bones_poll (bContext *C)
static int weight_from_bones_exec (bContext *C, wmOperator *op)
void PAINT_OT_weight_from_bones (wmOperatorType *ot)

Detailed Description

Definition in file paint_vertex.c.


Typedef Documentation

typedef struct VPaintData VPaintData

Function Documentation

static int apply_mp_locks_normalize ( Mesh me,
const WeightPaintInfo wpi,
const unsigned int  index,
MDeformWeight dw,
MDeformWeight tdw,
float  change,
float  oldChange,
float  oldw,
float  neww 
) [static]
static float calc_vp_alpha_dl ( VPaint vp,
ViewContext vc,
float  vpimat[][3],
const float *  vert_nor,
const float  mval[2],
const float  brush_size_pressure,
const float  brush_alpha_pressure 
) [static]
static float calc_vp_strength_dl ( VPaint vp,
ViewContext vc,
const float *  vert_nor,
const float  mval[2],
const float  brush_size_pressure 
) [static]
static void clamp_weights ( MDeformVert dvert) [static]
static void copy_vpaint_prev ( VPaint vp,
unsigned int *  mcol,
int  tot 
) [static]
static void copy_wpaint_prev ( VPaint wp,
MDeformVert dverts,
int  dcount 
) [static]
static void defvert_reset_to_prev ( MDeformVert dv_prev,
MDeformVert dv 
) [static]
static void do_shared_vertexcol ( Mesh me) [static]
static void do_weight_paint_normalize_all ( MDeformVert dvert,
const int  defbase_tot,
const char *  vgroup_validmap 
) [static]
static void do_weight_paint_normalize_all_active ( MDeformVert dvert,
const int  defbase_tot,
const char *  vgroup_validmap,
const int  vgroup_active 
) [static]
static void do_weight_paint_vertex ( VPaint wp,
Object ob,
const WeightPaintInfo wpi,
const unsigned int  index,
float  alpha,
float  paintweight 
) [static]
static void enforce_locks ( MDeformVert odv,
MDeformVert ndv,
const int  defbase_tot,
const char *  defbase_sel,
const char *  lock_flags,
const char *  vgroup_validmap,
char  do_auto_normalize,
char  do_multipaint 
) [static]
static char* gen_lock_flags ( Object ob,
int  defbase_tot 
) [static]
static int get_first_selected_nonzero_weight ( MDeformVert dvert,
const int  defbase_tot,
const char *  defbase_sel 
) [static]
static int* get_indexarray ( Mesh me) [static]

Definition at line 151 of file paint_vertex.c.

References MEM_mallocN(), and Mesh::totface.

Referenced by vpaint_stroke_test_start(), and wpaint_stroke_test_start().

static float get_mp_change ( MDeformVert odv,
const int  defbase_tot,
const char *  defbase_sel,
float  brush_change 
) [static]
static char has_locked_group ( MDeformVert dvert,
const int  defbase_tot,
const char *  bone_groups,
const char *  lock_flags 
) [static]
static int has_locked_group_selected ( int  defbase_tot,
const char *  defbase_sel,
const char *  lock_flags 
) [static]

Definition at line 1213 of file paint_vertex.c.

References FALSE, i, and TRUE.

Referenced by apply_mp_locks_normalize().

static void make_vertexcol ( Object ob) [static]
static unsigned int mcol_add ( unsigned int  col1,
unsigned int  col2,
int  fac 
) [static]

Definition at line 523 of file paint_vertex.c.

Referenced by vpaint_blend_tool().

static unsigned int mcol_blend ( unsigned int  col1,
unsigned int  col2,
int  fac 
) [static]

Definition at line 500 of file paint_vertex.c.

Referenced by vpaint_blend_tool(), and vpaint_paint_face().

static unsigned int mcol_darken ( unsigned int  col1,
unsigned int  col2,
int  fac 
) [static]

Definition at line 621 of file paint_vertex.c.

Referenced by vpaint_blend_tool().

static unsigned int mcol_lighten ( unsigned int  col1,
unsigned int  col2,
int  fac 
) [static]

Definition at line 593 of file paint_vertex.c.

Referenced by vpaint_blend_tool().

static unsigned int mcol_mul ( unsigned int  col1,
unsigned int  col2,
int  fac 
) [static]

Definition at line 569 of file paint_vertex.c.

Referenced by vpaint_blend_tool().

static unsigned int mcol_sub ( unsigned int  col1,
unsigned int  col2,
int  fac 
) [static]

Definition at line 546 of file paint_vertex.c.

Referenced by vpaint_blend_tool().

static void multipaint_selection ( MDeformVert dvert,
const int  defbase_tot,
float  change,
const char *  defbase_sel 
) [static]
static VPaint* new_vpaint ( int  wpaint) [static]

Definition at line 139 of file paint_vertex.c.

References VPaint::flag, MEM_callocN(), VP_AREA, and VP_SPRAY.

Referenced by set_vpaint(), and set_wpaint().

void PAINT_OT_vertex_paint ( wmOperatorType ot)
void PAINT_OT_vertex_paint_toggle ( wmOperatorType ot)
void PAINT_OT_weight_from_bones ( wmOperatorType ot)
void PAINT_OT_weight_paint ( wmOperatorType ot)
void PAINT_OT_weight_paint_toggle ( wmOperatorType ot)
void PAINT_OT_weight_sample ( wmOperatorType ot)
void PAINT_OT_weight_sample_group ( wmOperatorType ot)
void PAINT_OT_weight_set ( wmOperatorType ot)
static int paint_poll_test ( bContext C) [static]
static float redistribute_change ( MDeformVert ndv,
const int  defbase_tot,
char *  change_status,
const char  change_me,
int  changeto,
float  totchange,
float  total_valid,
char  do_auto_normalize 
) [static]
static unsigned int rgba_to_mcol ( float  r,
float  g,
float  b,
float  a 
) [static]

Definition at line 160 of file paint_vertex.c.

Referenced by vpaint_get_current_col().

static int sample_backbuf_area ( ViewContext vc,
int *  indexar,
int  totface,
int  x,
int  y,
float  size 
) [static]
static int set_vpaint ( bContext C,
wmOperator op 
) [static]
static int set_wpaint ( bContext C,
wmOperator UNUSEDop 
) [static]
int vertex_paint_mode_poll ( bContext C)
int vertex_paint_poll ( bContext C)
static unsigned int vpaint_blend ( VPaint vp,
unsigned int  col,
unsigned int  colorig,
const unsigned int  paintcol,
const int  alpha_i,
const int  brush_alpha_value_i 
) [static]
static unsigned int vpaint_blend_tool ( const int  tool,
const unsigned int  col,
const unsigned int  paintcol,
const int  alpha_i 
) [static]
static int vpaint_cancel ( bContext C,
wmOperator op 
) [static]

Definition at line 2671 of file paint_vertex.c.

References OPERATOR_CANCELLED, and paint_stroke_cancel().

Referenced by PAINT_OT_vertex_paint().

void vpaint_fill ( Object ob,
unsigned int  paintcol 
)
unsigned int vpaint_get_current_col ( VPaint vp)
static int vpaint_invoke ( bContext C,
wmOperator op,
wmEvent event 
) [static]
static void vpaint_paint_face ( VPaint vp,
VPaintData vpd,
Object ob,
const unsigned int  index,
const float  mval[2],
const float  brush_size_pressure,
const float  brush_alpha_pressure,
int   UNUSEDflip 
) [static]
static void vpaint_stroke_done ( bContext C,
struct PaintStroke stroke 
) [static]
static int vpaint_stroke_test_start ( bContext C,
struct wmOperator op,
wmEvent UNUSEDevent 
) [static]
static void vpaint_stroke_update_step ( bContext C,
struct PaintStroke stroke,
PointerRNA itemptr 
) [static]
static int weight_from_bones_exec ( bContext C,
wmOperator op 
) [static]
static int weight_from_bones_poll ( bContext C) [static]
int weight_paint_mode_poll ( bContext C)
int weight_paint_poll ( bContext C)
static EnumPropertyItem* weight_paint_sample_enum_itemf ( bContext C,
PointerRNA UNUSEDptr,
PropertyRNA UNUSEDprop,
int *  free 
) [static]
static int weight_paint_set_exec ( bContext C,
wmOperator UNUSEDop 
) [static]
static int weight_sample_group_exec ( bContext C,
wmOperator op 
) [static]
static int weight_sample_invoke ( bContext C,
wmOperator op,
wmEvent event 
) [static]
static float wpaint_blend ( VPaint wp,
float  weight,
float  weight_prev,
const float  alpha,
float  paintval,
const float  brush_alpha_value,
const short  do_flip,
const short  do_multipaint_totsel 
) [static]
static float wpaint_blend_tool ( const int  tool,
const float  weight,
const float  paintval,
const float  alpha 
) [static]
static int wpaint_cancel ( bContext C,
wmOperator op 
) [static]

Definition at line 2357 of file paint_vertex.c.

References OPERATOR_CANCELLED, and paint_stroke_cancel().

Referenced by PAINT_OT_weight_paint().

void wpaint_fill ( VPaint wp,
Object ob,
float  paintweight 
)
static int wpaint_invoke ( bContext C,
wmOperator op,
wmEvent event 
) [static]
static char * wpaint_make_validmap ( Object ob) [static]
static int wpaint_mirror_vgroup_ensure ( Object ob,
const int  vgroup_active 
) [static]
static void wpaint_stroke_done ( bContext C,
struct PaintStroke stroke 
) [static]
static int wpaint_stroke_test_start ( bContext C,
wmOperator op,
wmEvent UNUSEDevent 
) [static]
static void wpaint_stroke_update_step ( bContext C,
struct PaintStroke stroke,
PointerRNA itemptr 
) [static]

Definition at line 2103 of file paint_vertex.c.

References Object::actcol, Object::actdef, ViewContext::ar, ToolSettings::auto_normalize, brush_alpha(), brush_size(), brush_use_alpha_pressure(), brush_use_size_pressure(), calc_vp_alpha_dl(), calc_vp_strength_dl(), CTX_data_scene(), CTX_data_tool_settings(), CTX_wm_region(), DAG_id_tag_update(), Object::data, WPaintData::defbase_tot, defvert_find_index(), defvert_verify_index(), do_weight_paint_vertex(), Mesh::dvert, ED_region_tag_redraw(), Mesh::editflag, MVert::flag, MDeformVert::flag, MFace::flag, VPaint::flag, get_selected_defgroups(), WPaintData::indexar, WPaintData::lock_flags, MFace::mat_nr, ME_EDIT_PAINT_MASK, ME_EDIT_VERT_SEL, ME_FACE_SEL, MEM_freeN(), MEM_mallocN(), Mesh::mface, mult_m4_m4m4(), ToolSettings::multipaint, Mesh::mvert, NULL, ViewContext::obact, Object::obmat, VPaint::paint, PAINT_BLEND_BLUR, paint_brush(), paint_stroke_mode_data(), RegionView3D::persmat, RNA_boolean_get(), RNA_float_get(), RNA_float_get_array(), ViewContext::rv3d, sample_backbuf_area(), SELECT, swap_m4m4(), Mesh::totface, totindex, MFace::v1, MFace::v2, MFace::v3, MFace::v4, WPaintData::vc, WPaintData::vertexcosnos, Brush::vertexpaint_tool, WPaintData::vgroup_active, WPaintData::vgroup_mirror, WPaintData::vgroup_validmap, ToolSettings::vgroup_weight, view3d_operator_needs_opengl(), view3d_sample_backbuf(), VP_AREA, VP_COLINDEX, VP_ONLYVGROUP, MDeformWeight::weight, ARegion::winrct, ToolSettings::wpaint, WPaintData::wpimat, rcti::xmin, and rcti::ymin.

Referenced by wpaint_invoke().