2.5, continuing work with localizing paint modes.

* Replaced FACESEL_PAINT_TEST macro with paint_facesel_test. This removes one more thing from BKE_global, and it'll make it easier to localize.
* Fixed sculpt paint cursor sometimes not showing.
This commit is contained in:
Nicholas Bishop
2009-08-15 19:48:50 +00:00
parent 0ce5163cc0
commit 9d673cd354
15 changed files with 115 additions and 39 deletions

View File

@@ -127,11 +127,6 @@ typedef struct Global {
/* #define G_AUTOMATKEYS (1 << 30) also removed */
#define G_HIDDENHANDLES (1 << 31) /* used for curves only */
/* macro for testing face select mode
* Texture paint could be removed since selected faces are not used
* however hiding faces is useful */
#define FACESEL_PAINT_TEST ((G.f&G_FACESELECT) && (G.f & (G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT)))
/* G.fileflags */
#define G_AUTOPACK (1 << 0)

View File

@@ -0,0 +1,38 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2009 by Nicholas Bishop
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#ifndef BKE_PAINT_H
#define BKE_PAINT_H
struct Object;
/* testing face select mode
* Texture paint could be removed since selected faces are not used
* however hiding faces is useful */
int paint_facesel_test(struct Object *ob);
#endif

View File

@@ -72,6 +72,7 @@
#include "BKE_modifier.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_subsurf.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
@@ -2076,7 +2077,7 @@ static void clear_mesh_caches(Object *ob)
static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask)
{
Object *obact = scene->basact?scene->basact->object:NULL;
int editing = (FACESEL_PAINT_TEST)|(G.f & G_PARTICLEEDIT);
int editing = paint_facesel_test(ob)|(G.f & G_PARTICLEEDIT);
int needMapping = editing && (ob==obact);
float min[3], max[3];

View File

@@ -0,0 +1,37 @@
/*
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2009 by Nicholas Bishop
* All rights reserved.
*
* The Original Code is: all of this file.
*
* Contributor(s): none yet.
*
* ***** END GPL LICENSE BLOCK *****
*/
#include "DNA_object_types.h"
#include "BKE_global.h"
#include "BKE_paint.h"
int paint_facesel_test(Object *ob)
{
return (G.f&G_FACESELECT) && (G.f & (G_VERTEXPAINT|G_WEIGHTPAINT|G_TEXTUREPAINT));
}

View File

@@ -67,6 +67,7 @@
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_pointcache.h"
#include "BKE_softbody.h"
#include "BKE_texture.h"
@@ -891,7 +892,7 @@ void make_editMesh(Scene *scene, Object *ob)
evlist[a]= eve;
// face select sets selection in next loop
if( (FACESEL_PAINT_TEST)==0 )
if(!paint_facesel_test(ob))
eve->f |= (mvert->flag & 1);
if (mvert->flag & ME_HIDE) eve->h= 1;
@@ -966,7 +967,7 @@ void make_editMesh(Scene *scene, Object *ob)
if(mface->flag & ME_FACE_SEL) {
efa->f |= SELECT;
if(FACESEL_PAINT_TEST) {
if(paint_facesel_test(ob)) {
EM_select_face(efa, 1); /* flush down */
}
}

View File

@@ -65,6 +65,7 @@ editmesh_mods.c, UI level access, no geometry changes
#include "BKE_global.h"
#include "BKE_mesh.h"
#include "BKE_material.h"
#include "BKE_paint.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
#include "BKE_report.h"
@@ -242,7 +243,7 @@ int EM_mask_init_backbuf_border(ViewContext *vc, short mcords[][2], short tot, s
/* method in use for face selecting too */
if(vc->obedit==NULL) {
if(FACESEL_PAINT_TEST);
if(paint_facesel_test(vc->obact));
else return 0;
}
else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0;
@@ -297,7 +298,7 @@ int EM_init_backbuf_circle(ViewContext *vc, short xs, short ys, short rads)
/* method in use for face selecting too */
if(vc->obedit==NULL) {
if(FACESEL_PAINT_TEST);
if(paint_facesel_test(vc->obact));
else return 0;
}
else if(vc->v3d->drawtype<OB_SOLID || (vc->v3d->flag & V3D_ZBUF_SELECT)==0) return 0;

View File

@@ -98,6 +98,7 @@
#include "BKE_mesh.h"
#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_property.h"
#include "BKE_report.h"
@@ -4118,7 +4119,7 @@ void special_editmenu(Scene *scene, View3D *v3d)
if(ob->flag & OB_POSEMODE) {
// XXX pose_special_editmenu();
}
else if(FACESEL_PAINT_TEST) {
else if(paint_facesel_test(ob)) {
Mesh *me= get_mesh(ob);
MTFace *tface;
MFace *mface;

View File

@@ -1663,8 +1663,6 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *op)
/* Leave sculptmode */
ob->mode &= ~OB_MODE_SCULPT;
toggle_paint_cursor(C);
free_sculptsession(&ob->sculpt);
}
else {

View File

@@ -58,6 +58,7 @@
#include "BKE_mesh.h"
#include "BKE_node.h"
#include "BKE_packedFile.h"
#include "BKE_paint.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
@@ -1318,7 +1319,7 @@ void ED_image_uiblock_panel(const bContext *C, uiBlock *block, Image **ima_pp, I
}
/* exception, let's do because we only use this panel 3 times in blender... but not real good code! */
if( (FACESEL_PAINT_TEST) && sima && &sima->iuser==iuser)
if( (paint_facesel_test(CTX_data_active_object(C))) && sima && &sima->iuser==iuser)
return;
/* left side default per-image options, right half the additional options */

View File

@@ -60,6 +60,7 @@
#include "BKE_material.h"
#include "BKE_mesh.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_property.h"
#include "BKE_utildefines.h"
@@ -482,7 +483,7 @@ void draw_mesh_text(Scene *scene, Object *ob, int glsl)
if(ob == scene->obedit)
return;
else if(ob==OBACT)
if(FACESEL_PAINT_TEST)
if(paint_facesel_test(ob))
return;
ddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH);

View File

@@ -87,6 +87,7 @@
#include "BKE_mball.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_property.h"
#include "BKE_smoke.h"
@@ -2096,7 +2097,7 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object
}
}
if((me->drawflag & (ME_DRAWFACES)) || FACESEL_PAINT_TEST) { /* transp faces */
if((me->drawflag & (ME_DRAWFACES)) || paint_facesel_test(ob)) { /* transp faces */
unsigned char col1[4], col2[4], col3[4];
UI_GetThemeColor4ubv(TH_FACE, (char *)col1);
@@ -2255,7 +2256,7 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base
glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
// Unwanted combination.
if (ob==OBACT && FACESEL_PAINT_TEST) draw_wire = 0;
if (ob==OBACT && paint_facesel_test(ob)) draw_wire = 0;
if(dt==OB_BOUNDBOX) {
draw_bounding_volume(scene, ob);
@@ -2268,12 +2269,12 @@ static void draw_mesh_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base
else if(dt==OB_WIRE || totface==0) {
draw_wire = 1; /* draw wire only, no depth buffer stuff */
}
else if( (ob==OBACT && (G.f & G_TEXTUREPAINT || FACESEL_PAINT_TEST)) ||
else if( (ob==OBACT && (G.f & G_TEXTUREPAINT || paint_facesel_test(ob))) ||
CHECK_OB_DRAWTEXTURE(v3d, dt))
{
int faceselect= (ob==OBACT && FACESEL_PAINT_TEST);
int faceselect= (ob==OBACT && paint_facesel_test(ob));
if ((v3d->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !(G.f&G_PICKSEL || FACESEL_PAINT_TEST) && !draw_wire) {
if ((v3d->flag&V3D_SELECT_OUTLINE) && (base->flag&SELECT) && !(G.f&G_PICKSEL || paint_facesel_test(ob)) && !draw_wire) {
draw_mesh_object_outline(v3d, ob, dm);
}

View File

@@ -59,6 +59,7 @@
#include "BKE_key.h"
#include "BKE_object.h"
#include "BKE_global.h"
#include "BKE_paint.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
@@ -1102,7 +1103,7 @@ void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d)
int m;
#endif
if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || (FACESEL_PAINT_TEST));
if(G.f & G_VERTEXPAINT || G.f & G_WEIGHTPAINT || (scene->basact && paint_facesel_test(scene->basact->object)));
else if((G.f & G_TEXTUREPAINT) && scene->toolsettings && (scene->toolsettings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE));
else if((G.f & G_PARTICLEEDIT) && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT));
else if(scene->obedit && v3d->drawtype>OB_WIRE && (v3d->flag & V3D_ZBUF_SELECT));
@@ -1853,13 +1854,13 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d)
/* *********************** customdata **************** */
/* goes over all modes and view3d settings */
static CustomDataMask get_viewedit_datamask(bScreen *screen)
static CustomDataMask get_viewedit_datamask(bScreen *screen, Object *ob)
{
CustomDataMask mask = CD_MASK_BAREMESH;
ScrArea *sa;
/* check if we need tfaces & mcols due to face select or texture paint */
if(FACESEL_PAINT_TEST || G.f & G_TEXTUREPAINT)
if(paint_facesel_test(ob) || G.f & G_TEXTUREPAINT)
mask |= CD_MASK_MTFACE | CD_MASK_MCOL;
/* check if we need tfaces & mcols due to view mode */
@@ -1887,12 +1888,9 @@ static CustomDataMask get_viewedit_datamask(bScreen *screen)
if(G.f & G_WEIGHTPAINT)
mask |= CD_MASK_WEIGHT_MCOL;
/* XXX: is this even needed?
if(G.f & G_SCULPTMODE)
if(ob && ob->mode & OB_MODE_SCULPT)
mask |= CD_MASK_MDISPS;
*/
return mask;
}
@@ -1909,7 +1907,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
char *grid_unit= NULL;
/* from now on all object derived meshes check this */
v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C));
v3d->customdata_mask= get_viewedit_datamask(CTX_wm_screen(C), obact);
/* shadow buffers, before we setup matrices */
if(draw_glsl_material(scene, NULL, v3d, v3d->drawtype))

View File

@@ -54,6 +54,7 @@
#include "BKE_depsgraph.h"
#include "BKE_object.h"
#include "BKE_global.h"
#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
@@ -990,7 +991,7 @@ static int viewcenter_exec(bContext *C, wmOperator *op) /* like a localview with
}
}
}
else if (FACESEL_PAINT_TEST) {
else if (paint_facesel_test(ob)) {
// XXX ok= minmax_tface(min, max);
}
else if (G.f & G_PARTICLEEDIT) {

View File

@@ -61,6 +61,7 @@
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_paint.h"
#include "BKE_particle.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h" /* for VECCOPY */
@@ -526,7 +527,7 @@ static void do_view3d_view_alignviewmenu(bContext *C, void *arg, int event)
if ((obedit) && (obedit->type == OB_MESH)) {
editmesh_align_view_to_selected(v3d, event + 1);
}
else if (FACESEL_PAINT_TEST) {
else if (paint_facesel_test(CTX_data_active_object(C))) {
Object *obact= OBACT;
if (obact && obact->type==OB_MESH) {
Mesh *me= obact->data;
@@ -578,7 +579,7 @@ static uiBlock *view3d_view_alignviewmenu(bContext *C, ARegion *ar, void *arg_un
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Center Cursor and View All|Shift C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 6, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align Active Camera to View|Ctrl Alt NumPad 0", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
if (((obedit) && (obedit->type == OB_MESH)) || (FACESEL_PAINT_TEST)) {
if (((obedit) && (obedit->type == OB_MESH)) || (paint_facesel_test(CTX_data_active_object(C)))) {
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Top)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 2, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Front)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 1, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Align View to Selected (Side)|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
@@ -2810,7 +2811,7 @@ static void do_view3d_vpaintmenu(bContext *C, void *arg, int event)
BIF_undo();
break;
case 1: /* set vertex colors/weight */
if(FACESEL_PAINT_TEST)
if(paint_facesel_test(CTX_data_active_object(C)))
clear_vpaint_selectedfaces();
else /* we know were in vertex paint mode */
clear_vpaint();
@@ -2945,7 +2946,7 @@ static uiBlock *view3d_wpaintmenu(bContext *C, ARegion *ar, void *arg_unused)
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
if (FACESEL_PAINT_TEST) {
if (paint_facesel_test(CTX_data_active_object(C))) {
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Set Weight|Shift K", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 1, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
menunr++;
@@ -3724,7 +3725,7 @@ static void view3d_header_pulldowns(const bContext *C, uiBlock *block, Object *o
uiDefMenuBut(block, view3d_sculpt_menu, NULL, "Sculpt", xco, yco, xmax-3, 20, "");
xco+= xmax;
}
else if (FACESEL_PAINT_TEST) {
else if (paint_facesel_test(ob)) {
if (ob && ob->type == OB_MESH) {
xmax= GetButStringLength("Face");
uiDefPulldownBut(block, view3d_faceselmenu, NULL, "Face", xco,yco, xmax-3, 20, "");
@@ -3816,7 +3817,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
if(G.f & G_VERTEXPAINT) v3d->flag |= V3D_VERTEXPAINT;
if(G.f & G_WEIGHTPAINT) v3d->flag |= V3D_WEIGHTPAINT;
if (G.f & G_TEXTUREPAINT) v3d->flag |= V3D_TEXTUREPAINT;
if(FACESEL_PAINT_TEST) v3d->flag |= V3D_FACESELECT;
if(paint_facesel_test(ob)) v3d->flag |= V3D_FACESELECT;
uiDefIconTextButS(block, MENU, B_MODESELECT, (v3d->modeselect),view3d_modeselect_pup(scene) ,
xco,yco,126,20, &(v3d->modeselect), 0, 0, 0, 0, "Mode (Hotkeys: Tab, V, Ctrl Tab)");

View File

@@ -59,6 +59,7 @@
#include "BKE_depsgraph.h"
#include "BKE_object.h"
#include "BKE_global.h"
#include "BKE_paint.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_utildefines.h"
@@ -694,7 +695,7 @@ static void do_lasso_select_node(short mcords[][2], short moves, short select)
void view3d_lasso_select(bContext *C, ViewContext *vc, short mcords[][2], short moves, short select)
{
if(vc->obedit==NULL) {
if(FACESEL_PAINT_TEST)
if(paint_facesel_test(CTX_data_active_object(C)))
do_lasso_select_facemode(vc, mcords, moves, select);
else if(G.f & (G_VERTEXPAINT|G_TEXTUREPAINT|G_WEIGHTPAINT))
;
@@ -1341,7 +1342,7 @@ static int view3d_borderselect_exec(bContext *C, wmOperator *op)
rect.xmax= RNA_int_get(op->ptr, "xmax");
rect.ymax= RNA_int_get(op->ptr, "ymax");
if(obedit==NULL && (FACESEL_PAINT_TEST)) {
if(obedit==NULL && (paint_facesel_test(OBACT))) {
// XXX face_borderselect();
return OPERATOR_FINISHED;
}
@@ -1637,9 +1638,9 @@ static void mesh_circle_select(ViewContext *vc, int selecting, short *mval, floa
{
ToolSettings *ts= vc->scene->toolsettings;
int bbsel;
Object *ob= vc->obact;
if(vc->obedit==NULL && (FACESEL_PAINT_TEST)) {
Object *ob= vc->obact;
if(vc->obedit==NULL && paint_facesel_test(ob)) {
Mesh *me = ob?ob->data:NULL;
if (me) {