- Weightpaint back (CTRL+TAB or menu)
  Also weightpaint is sortof non-modal, allowing to use all existing
  hotkeys while in paint mode. Only leftmouse is overridden.
- Made vpaint and wpaint entirely local, stored in scene (and saved!)
- Small bugfix (also in 2.48): on weightpaint mode, all armature objects
  in 3d window were drawing as active poses. Now only the armature 
  deformer is.

Nice point for the UI agenda: are paint modes on ACTION mouse? Only then
you can combine it with SELECT mouse...
This commit is contained in:
Ton Roosendaal 2009-01-10 14:19:14 +00:00
parent a7932f7452
commit dd97c08006
22 changed files with 602 additions and 433 deletions

View File

@ -2054,15 +2054,16 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask)
{
Mesh *me = ob->data;
float min[3], max[3];
int needMapping= 0; //
//int needMapping= 0;
Object *obact = scene->basact?scene->basact->object:NULL;
int editing = (FACESEL_PAINT_TEST)|(G.f & G_PARTICLEEDIT);
int needMapping = editing && (ob==obact);
clear_mesh_caches(ob);
// XXX Object *obact = scene->basact?scene->basact->object:NULL;
// int editing = (FACESEL_PAINT_TEST)|(G.f & G_PARTICLEEDIT);
// int needMapping = editing && (ob==obact);
// if( (G.f & G_WEIGHTPAINT) && ob==obact ) {
if(dataMask & CD_MASK_WEIGHTPAINT) {
if( (G.f & G_WEIGHTPAINT) && ob==obact ) {
// if(dataMask & CD_MASK_WEIGHTPAINT) {
MCol *wpcol = (MCol*)calc_weightpaint_colors(ob);
int layernum = CustomData_number_of_layers(&me->fdata, CD_MCOL);
int prevactive = CustomData_get_active_layer(&me->fdata, CD_MCOL);

View File

@ -167,7 +167,12 @@ void free_scene(Scene *sce)
BLI_freelistN(&sce->transform_spaces);
BLI_freelistN(&sce->r.layers);
if(sce->toolsettings){
if(sce->toolsettings) {
if(sce->toolsettings->vpaint)
MEM_freeN(sce->toolsettings->vpaint);
if(sce->toolsettings->wpaint)
MEM_freeN(sce->toolsettings->wpaint);
MEM_freeN(sce->toolsettings);
sce->toolsettings = NULL;
}

View File

@ -3604,7 +3604,10 @@ static void direct_link_scene(FileData *fd, Scene *sce)
sce->radio= newdataadr(fd, sce->radio);
sce->toolsettings= newdataadr(fd, sce->toolsettings);
if(sce->toolsettings) {
sce->toolsettings->vpaint= newdataadr(fd, sce->toolsettings->vpaint);
sce->toolsettings->wpaint= newdataadr(fd, sce->toolsettings->wpaint);
}
sce->sculptdata.session= NULL;
/* SculptData textures */
for(a=0; a<MAX_MTEX; ++a)

View File

@ -1472,6 +1472,10 @@ static void write_scenes(WriteData *wd, ListBase *scebase)
writestruct(wd, DATA, "Radio", 1, sce->radio);
writestruct(wd, DATA, "ToolSettings", 1, sce->toolsettings);
if(sce->toolsettings->vpaint)
writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->vpaint);
if(sce->toolsettings->wpaint)
writestruct(wd, DATA, "VPaint", 1, sce->toolsettings->wpaint);
for(a=0; a<MAX_MTEX; ++a)
writestruct(wd, DATA, "MTex", 1, sce->sculptdata.mtex[a]);

View File

@ -89,6 +89,15 @@ void ED_anim_dag_flush_update(const bContext *C)
DAG_scene_flush_update(scene, screen_view3d_layers(screen), 0);
}
/* flushes changes from object to all relations in scene */
void ED_anim_object_flush_update(const bContext *C, Object *ob)
{
Scene *scene= CTX_data_scene(C);
bScreen *screen= CTX_wm_screen(C);
DAG_object_update_flags(scene, ob, screen_view3d_layers(screen));
}
/* results in fully updated anim system */
/* in future sound should be on WM level, only 1 sound can play! */

View File

@ -99,10 +99,7 @@ static void error_libdata() {}
static void BIF_undo_push() {}
static void adduplicate() {}
static void countall() {}
static void vertexgroup_select_by_name() {}
static void deselect_actionchannels() {}
static void add_vert_to_defgroup() {}
static void create_dverts() {}
static void select_actionchannel_by_name() {}
/* ************* XXX *************** */
@ -3563,7 +3560,7 @@ static int bone_looper(Object *ob, Bone *bone, void *data,
}
/* called from editview.c, for mode-less pose selection */
/* assumes scene obact and basact... XXX */
/* assumes scene obact and basact is still on old situation */
int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend)
{
Object *ob= base->object;
@ -3605,8 +3602,8 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor
/* in weightpaint we select the associated vertex group too */
if (G.f & G_WEIGHTPAINT) {
if (nearBone->flag & BONE_ACTIVE) {
vertexgroup_select_by_name(ob, nearBone->name);
DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
vertexgroup_select_by_name(OBACT, nearBone->name);
DAG_object_flush_update(scene, OBACT, OB_RECALC_DATA);
}
}

View File

@ -58,20 +58,17 @@
#include "BLO_sys_types.h" // for intptr_t support
#include "ED_armature.h"
#include "ED_mesh.h"
#include "meshlaplacian.h"
/* ************* XXX *************** */
static void remove_vert_defgroup() {}
static int mesh_get_x_mirror_vert() {return 0;}
static void waitcursor() {}
static void progress_bar() {}
static void start_progress_bar() {}
static void end_progress_bar() {}
static float get_vert_defgroup() {return 0.0;}
static void add_vert_to_defgroup() {}
#define WEIGHT_REPLACE 0
#define WEIGHT_ADD 0
static void error() {}
/* ************* XXX *************** */

View File

@ -52,6 +52,7 @@
#include "BKE_action.h"
#include "BKE_armature.h"
#include "BKE_blender.h"
#include "BKE_context.h"
#include "BKE_constraint.h"
#include "BKE_deform.h"
#include "BKE_depsgraph.h"
@ -66,8 +67,10 @@
#include "BIF_gl.h"
#include "ED_armature.h"
#include "ED_anim_api.h"
#include "ED_keyframing.h"
#include "ED_object.h"
#include "ED_mesh.h"
#include "ED_view3d.h"
#include "armature_intern.h"
@ -81,8 +84,6 @@ static void error() {};
static void BIF_undo_push() {}
static void countall() {}
static void add_constraint() {}
static void vertexgroup_select_by_name() {}
static int screen_view3d_layers() {return 0;}
static void select_actionchannel_by_name() {}
static int autokeyframe_cfra_can_key() {return 0;}
static void autokeyframe_pose_cb_func() {}
@ -194,7 +195,7 @@ int ED_pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan)
/* For the object with pose/action: create path curves for selected bones
* This recalculates the WHOLE path within the pchan->pathsf and pchan->pathef range
*/
void pose_calculate_path(Scene *scene, Object *ob)
void pose_calculate_path(bContext *C, Scene *scene, Object *ob)
{
bArmature *arm;
bPoseChannel *pchan;
@ -230,10 +231,10 @@ void pose_calculate_path(Scene *scene, Object *ob)
/* hack: for unsaved files, set OB_RECALC so that paths can get calculated */
if ((ob->recalc & OB_RECALC)==0) {
ob->recalc |= OB_RECALC;
DAG_object_update_flags(scene, ob, screen_view3d_layers());
ED_anim_object_flush_update(C, ob);
}
else
DAG_object_update_flags(scene, ob, screen_view3d_layers());
ED_anim_object_flush_update(C, ob);
/* malloc the path blocks */
@ -288,7 +289,7 @@ void pose_calculate_path(Scene *scene, Object *ob)
/* For the object with pose/action: update paths for those that have got them
* This should selectively update paths that exist...
*/
void pose_recalculate_paths(Scene *scene, Object *ob)
void pose_recalculate_paths(bContext *C, Scene *scene, Object *ob)
{
bArmature *arm;
bPoseChannel *pchan;
@ -324,10 +325,10 @@ void pose_recalculate_paths(Scene *scene, Object *ob)
/* hack: for unsaved files, set OB_RECALC so that paths can get calculated */
if ((ob->recalc & OB_RECALC)==0) {
ob->recalc |= OB_RECALC;
DAG_object_update_flags(scene, ob, screen_view3d_layers());
ED_anim_object_flush_update(C, ob);
}
else
DAG_object_update_flags(scene, ob, screen_view3d_layers());
ED_anim_object_flush_update(C, ob);
for (CFRA=sfra; CFRA<=efra; CFRA++) {
/* do all updates */
@ -1628,7 +1629,7 @@ void pose_special_editmenu(Scene *scene)
pose_flip_names();
}
else if(nr==3) {
pose_calculate_path(ob);
pose_calculate_path(C, ob);
}
else if(nr==4) {
pose_clear_paths(ob);

View File

@ -30,6 +30,7 @@
#define ED_ANIM_API_H
struct ID;
struct Scene;
struct ListBase;
struct bContext;
struct wmWindowManager;
@ -321,8 +322,11 @@ void ANIM_nla_mapping_apply_ipo(struct Object *ob, struct Ipo *ipo, short restor
/* --------- anim_deps.c, animation updates -------- */
/* generic update flush, reads from Context screen (layers) and scene */
/* generic update flush, reads from Context screen (layers) and scene */
void ED_anim_dag_flush_update(const struct bContext *C);
/* only flush object */
void ED_anim_object_flush_update(const struct bContext *C, struct Object *ob);
/* flush + do the actual update for all involved objects */
void ED_update_for_newframe(const struct bContext *C, int mute);
/* pose <-> action syncing */

View File

@ -91,7 +91,7 @@ void ED_armature_edit_remake(struct Object *obedit);
int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int *buffer,
short hits, short extend);
void mouse_armature(struct bContext *C, short mval[2], int extend);
struct Bone *get_indexed_bone (struct Object *ob, int index);
float ED_rollBoneToVector(EditBone *bone, float new_up_axis[3]);
void transform_armature_mirror_update(struct Object *obedit);

View File

@ -28,6 +28,7 @@
#ifndef ED_MESH_H
#define ED_MESH_H
struct ID;
struct View3D;
struct ARegion;
struct EditMesh;
@ -130,12 +131,17 @@ int EM_init_backbuf_circle(struct ViewContext *vc, short xs, short ys, short r
#define WEIGHT_SUBTRACT 3
void add_defgroup (Object *ob);
void remove_vert_defgroup (Object *ob, struct bDeformGroup *dg, int vertnum);
void create_dverts(struct ID *id);
float get_vert_defgroup (Object *ob, struct bDeformGroup *dg, int vertnum);
void remove_vert_defgroup (Object *ob, struct bDeformGroup *dg, int vertnum);
void remove_verts_defgroup (Object *obedit, int allverts);
struct bDeformGroup *add_defgroup_name (Object *ob, char *name);
struct MDeformWeight *verify_defweight (struct MDeformVert *dv, int defgroup);
struct MDeformWeight *get_defweight (struct MDeformVert *dv, int defgroup);
bDeformGroup *add_defgroup_name (Object *ob, char *name);
void vertexgroup_select_by_name(Object *ob, char *name);
void add_vert_to_defgroup (Object *ob, struct bDeformGroup *dg, int vertnum,
float weight, int assignmode);
struct bDeformGroup *add_defgroup_name (Object *ob, char *name);
struct MDeformWeight *verify_defweight (struct MDeformVert *dv, int defgroup);
struct MDeformWeight *get_defweight (struct MDeformVert *dv, int defgroup);
#endif /* ED_MESH_H */

View File

@ -53,29 +53,6 @@ typedef struct ViewContext {
short mval[2];
} ViewContext;
typedef struct VPaint {
float r, g, b, a;
float size; /* of brush */
float gamma, mul;
short mode, flag;
int tot, pad; /* allocation size of prev buffers */
unsigned int *vpaint_prev; /* previous mesh colors */
struct MDeformVert *wpaint_prev; /* previous vertex weights */
void *paintcursor; /* wm handle */
} VPaint;
/* Gvp.flag and Gwp.flag */
#define VP_COLINDEX 1
#define VP_AREA 2
#define VP_SOFT 4
#define VP_NORMALS 8
#define VP_SPRAY 16
#define VP_MIRROR_X 32
#define VP_HARD 64
#define VP_ONLYVGROUP 128
float *give_cursor(struct Scene *scene, struct View3D *v3d);

View File

@ -725,7 +725,7 @@ intptr_t mesh_octree_table(Object *ob, EditMesh *em, float *co, char mode)
* we are using the undeformed coordinates*/
INIT_MINMAX(min, max);
if(me->edit_mesh==em) {
if(em && me->edit_mesh==em) {
EditVert *eve;
for(eve= em->verts.first; eve; eve= eve->next)
@ -766,7 +766,7 @@ intptr_t mesh_octree_table(Object *ob, EditMesh *em, float *co, char mode)
MeshOctree.table= MEM_callocN(MOC_RES*MOC_RES*MOC_RES*sizeof(void *), "sym table");
if(me->edit_mesh==em) {
if(em && me->edit_mesh==em) {
EditVert *eve;
for(eve= em->verts.first; eve; eve= eve->next) {

View File

@ -1629,7 +1629,6 @@ void OBJECT_OT_set_restrictview(wmOperatorType *ot)
/* ************* Slow Parent ******************* */
static int object_set_slowparent_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
CTX_DATA_BEGIN(C, Base*, base, visible_bases) {

View File

@ -62,6 +62,7 @@
#include "BKE_DerivedMesh.h"
#include "BKE_global.h"
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_ipo.h"
#include "BKE_utildefines.h"
@ -2542,9 +2543,10 @@ int draw_armature(Scene *scene, View3D *v3d, Base *base, int dt, int flag)
if ((flag & DRAW_SCENESET)==0) {
if(ob==OBACT)
arm->flag |= ARM_POSEMODE;
else if(G.f & G_WEIGHTPAINT)
arm->flag |= ARM_POSEMODE;
else if(G.f & G_WEIGHTPAINT) {
if(OBACT && ob==modifiers_isDeformedByArmature(OBACT))
arm->flag |= ARM_POSEMODE;
}
draw_pose_paths(scene, v3d, ob);
}
}

View File

@ -142,9 +142,10 @@ void ED_view3d_exit_paint_modes(bContext *C)
{
if(G.f & G_VERTEXPAINT)
WM_operator_name_call(C, "VIEW3D_OT_vpaint_toggle", WM_OP_EXEC_REGION_WIN, NULL, NULL);
else if(G.f & G_VERTEXPAINT)
WM_operator_name_call(C, "VIEW3D_OT_wpaint_toggle", WM_OP_EXEC_REGION_WIN, NULL, NULL);
// if(G.f & G_TEXTUREPAINT) set_texturepaint();
// if(G.f & G_WEIGHTPAINT) set_wpaint();
// if(G.f & G_SCULPTMODE) set_sculptmode();
// if(G.f & G_PARTICLEEDIT) PE_set_particle_edit();
@ -5434,7 +5435,7 @@ static void do_view3d_buttons(bContext *C, void *arg, int event)
if(obedit)
ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR); /* exit editmode and undo */
// XXX set_wpaint();
WM_operator_name_call(C, "VIEW3D_OT_wpaint_toggle", WM_OP_EXEC_REGION_WIN, NULL, NULL);
}
}
else if (v3d->modeselect == V3D_POSEMODE_SEL) {

View File

@ -122,6 +122,8 @@ void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc);
/* vpaint.c */
void VIEW3D_OT_vpaint_toggle(struct wmOperatorType *ot);
void VIEW3D_OT_vpaint(struct wmOperatorType *ot);
void VIEW3D_OT_wpaint_toggle(struct wmOperatorType *ot);
void VIEW3D_OT_wpaint(struct wmOperatorType *ot);
/* view3d_view.c */
void VIEW3D_OT_smoothview(struct wmOperatorType *ot);

View File

@ -80,7 +80,9 @@ void view3d_operatortypes(void)
WM_operatortype_append(VIEW3D_OT_setcameratoview);
WM_operatortype_append(VIEW3D_OT_drawtype);
WM_operatortype_append(VIEW3D_OT_vpaint_toggle);
WM_operatortype_append(VIEW3D_OT_wpaint_toggle);
WM_operatortype_append(VIEW3D_OT_vpaint);
WM_operatortype_append(VIEW3D_OT_wpaint);
transform_operatortypes();
}
@ -92,6 +94,7 @@ void view3d_keymap(wmWindowManager *wm)
/* paint poll checks mode */
WM_keymap_verify_item(keymap, "VIEW3D_OT_vpaint", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_wpaint", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0);
@ -155,6 +158,7 @@ void view3d_keymap(wmWindowManager *wm)
WM_keymap_add_item(keymap, "VIEW3D_OT_set_camera_to_view", PAD0, KM_PRESS, KM_ALT|KM_CTRL, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_vpaint_toggle", VKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW3D_OT_wpaint_toggle", TABKEY, KM_PRESS, KM_CTRL, 0);
/* TODO - this is just while we have no way to load a text datablock */
RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_run_pyfile", PKEY, KM_PRESS, 0, 0)->ptr, "filename", "test.py");

View File

@ -1067,14 +1067,14 @@ static void mouse_select(bContext *C, short *mval, short extend, short obcenter)
basact->flag|= SELECT;
basact->object->flag= basact->flag;
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, basact->object);
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, basact->object);
/* in weightpaint, we use selected bone to select vertexgroup, so no switch to new active object */
if(G.f & G_WEIGHTPAINT) {
/* prevent activating */
basact= NULL;
}
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, basact->object);
WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, basact->object);
}
/* prevent bone selecting to pass on to object selecting */
@ -1449,7 +1449,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
while (base->selcol == (*col & 0xFFFF)) { /* we got an object */
if(*col & 0xFFFF0000) { /* we got a bone */
bone = NULL; // XXX get_indexed_bone(base->object, *col & ~(BONESEL_ANY));
bone = get_indexed_bone(base->object, *col & ~(BONESEL_ANY));
if(bone) {
if(selecting) {
bone->flag |= BONE_SELECTED;

File diff suppressed because it is too large Load Diff

View File

@ -58,6 +58,9 @@ void ED_editors_exit(bContext *C)
/* frees all editmode undos */
undo_editmode_clear();
/* global in meshtools... */
mesh_octree_table(ob, NULL, NULL, 'e');
if(ob) {
if(ob->type==OB_MESH) {
Mesh *me= ob->data;

View File

@ -374,7 +374,34 @@ typedef struct TransformOrientation {
float mat[3][3];
} TransformOrientation;
typedef struct VPaint {
float r, g, b, a;
float size; /* of brush */
float gamma, mul;
short mode, flag;
int tot, pad; /* allocation size of prev buffers */
unsigned int *vpaint_prev; /* previous mesh colors */
struct MDeformVert *wpaint_prev; /* previous vertex weights */
void *paintcursor; /* wm handle */
} VPaint;
/* VPaint flag */
#define VP_COLINDEX 1
#define VP_AREA 2
#define VP_SOFT 4
#define VP_NORMALS 8
#define VP_SPRAY 16
#define VP_MIRROR_X 32
#define VP_HARD 64
#define VP_ONLYVGROUP 128
typedef struct ToolSettings {
VPaint *vpaint; /* vertex paint */
VPaint *wpaint; /* weight paint */
/* Subdivide Settings */
short cornertype;
short editbutflag;