From edf557cb1c98c76fe56bcd21d7e8e461ce89d0d9 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 28 Jul 2008 00:21:34 +0000 Subject: * Fix for Aligorith's fix for my mistaken uninitialised variable in outliner.c - it was never needed in the first place. --- source/blender/src/outliner.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/outliner.c b/source/blender/src/outliner.c index a8e864998b1..3f328a0cfb2 100644 --- a/source/blender/src/outliner.c +++ b/source/blender/src/outliner.c @@ -3718,13 +3718,6 @@ static void outliner_draw_restrictbuts(uiBlock *block, SpaceOops *soops, ListBas uiButSetFunc(bt, restrictbutton_modifier_cb, ob, NULL); uiButSetFlag(bt, UI_NO_HILITE); - /* - bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Editmode, REDRAWALL, VICON_EDIT, - (int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, te->ys, 17, OL_H-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); - uiButSetFunc(bt, restrictbutton_modifier_cb, ob, NULL); - uiButSetFlag(bt, UI_NO_HILITE); - */ - bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, REDRAWALL, ICON_RESTRICT_RENDER_OFF, (int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, te->ys, 17, OL_H-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_modifier_cb, ob, NULL); @@ -3733,24 +3726,20 @@ static void outliner_draw_restrictbuts(uiBlock *block, SpaceOops *soops, ListBas else if(tselem->type==TSE_POSE_CHANNEL) { bPoseChannel *pchan= (bPoseChannel *)te->directdata; Bone *bone = pchan->bone; - - ob = (Object *)tselem->id; - + uiBlockSetEmboss(block, UI_EMBOSSN); bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, REDRAWALL, ICON_RESTRICT_VIEW_OFF, (int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, te->ys, 17, OL_H-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); - uiButSetFunc(bt, restrictbutton_bone_cb, ob, NULL); + uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); uiButSetFlag(bt, UI_NO_HILITE); } else if(tselem->type==TSE_EBONE) { EditBone *ebone= (EditBone *)te->directdata; - - ob = (Object *)tselem->id; - + uiBlockSetEmboss(block, UI_EMBOSSN); bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, REDRAWALL, ICON_RESTRICT_VIEW_OFF, (int)soops->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, te->ys, 17, OL_H-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); - uiButSetFunc(bt, restrictbutton_bone_cb, ob, NULL); + uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); uiButSetFlag(bt, UI_NO_HILITE); } } -- cgit v1.2.3 From 8162215f2a749edcb2fa24e5cc9d7de179ac1cb9 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 28 Jul 2008 04:08:46 +0000 Subject: Bugfix: Bone-locking should only be set if the bone (and not its parent/children) are selected. Transposition error from the patch (I had to manually apply as there were some oddities about the patch file). --- source/blender/src/editarmature.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/src') diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index d0f44263fb7..3d0f26960d6 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -2717,7 +2717,7 @@ void set_locks_armature_bones(short lock) for (ebone = G.edbo.first; ebone; ebone=ebone->next) { if (arm->layer & ebone->layer) { - if (ebone->flag & (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL)) { + if (ebone->flag & BONE_SELECTED) { if (lock) ebone->flag |= BONE_EDITMODE_LOCKED; else -- cgit v1.2.3 From 908337bee11f6b55c34a5880ea241b3975c35287 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 29 Jul 2008 15:48:31 +0000 Subject: Game Engine: alpha blending and sorting ======================================= Alpha blending + sorting was revised, to fix bugs and get it to work more predictable. * A new per texture face "Sort" setting defines if the face is alpha sorted or not, instead of abusing the "ZTransp" setting as it did before. * Existing files are converted to hopefully match the old behavior as much as possible with a version patch. * On new meshes the Sort flag is disabled by the default, to avoid unexpected and hard to find slowdowns. * Alpha sorting for faces was incredibly slow. Sorting faces in a mesh with 600 faces lowered the framerate from 200 to 70 fps in my test.. the sorting there case goes about 15x faster now, but it is still advised to use Clip Alpha if possible instead of regular Alpha. * There still various limitations in the alpha sorting code, I've added some comments to the code about this. Some docs at the bottom of the page: http://www.blender.org/development/current-projects/changes-since-246/realtime-glsl-materials/ Merged some fixes from the apricot branch, most important change is that tangents are now exactly the same as the rest of Blender, instead of being computed in the game engine with a different algorithm. Also, the subversion was bumped to 1. --- source/blender/src/buttons_editing.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/src') diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index 180fdc852ae..b26c52a92e2 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -6189,6 +6189,7 @@ static void editing_panel_mesh_texface(void) uiDefButBitS(block, TOG, TF_BILLBOARD2, B_TFACE_BILLB, "Billboard",660,110,60,19, &tf->mode, 0, 0, 0, 0, "Billboard with Z-axis constraint"); uiDefButBitS(block, TOG, TF_SHADOW, REDRAWVIEW3D, "Shadow", 720,110,60,19, &tf->mode, 0, 0, 0, 0, "Face is used for shadow"); uiDefButBitS(block, TOG, TF_BMFONT, REDRAWVIEW3D, "Text", 780,110,60,19, &tf->mode, 0, 0, 0, 0, "Enable bitmap text on face"); + uiDefButBitS(block, TOG, TF_ALPHASORT, REDRAWVIEW3D, "Sort", 840,110,60,19, &tf->mode, 0, 0, 0, 0, "Enable sorting of faces for correct alpha drawing (slow, use Clip Alpha instead when possible)"); uiBlockBeginAlign(block); uiBlockSetCol(block, TH_BUT_SETTING1); -- cgit v1.2.3 From 7f3c27995ed9a3adf04974f26b7b1a33f58adc5d Mon Sep 17 00:00:00 2001 From: Mal Duffin Date: Tue, 29 Jul 2008 21:49:59 +0000 Subject: Copy Attributes now has option to copy all physical attributes. There existed two options to copy only the mass, and only the damping, but no option to copy all of the physical attributes. This patch adds in this option, right under the Mass and Damping listings. --- source/blender/src/editobject.c | 13 ++++++++++++- source/blender/src/header_view3d.c | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'source/blender/src') diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 2f9addb106e..cbf7691754d 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -3506,6 +3506,17 @@ void copy_attr(short event) base->object->damping= ob->damping; base->object->rdamping= ob->rdamping; } + else if(event==11) { /* all physical attributes */ + base->object->gameflag = ob->gameflag; + base->object->inertia = ob->inertia; + base->object->formfactor = ob->formfactor; + base->object->damping= ob->damping; + base->object->rdamping= ob->rdamping; + base->object->mass= ob->mass; + if (ob->gameflag & OB_BOUNDS) { + base->object->boundtype = ob->boundtype; + } + } else if(event==17) { /* tex space */ copy_texture_space(base->object, ob); } @@ -3692,7 +3703,7 @@ void copy_attr_menu() * view3d_edit_object_copyattrmenu() and in toolbox.c */ - strcpy(str, "Copy Attributes %t|Location%x1|Rotation%x2|Size%x3|Draw Options%x4|Time Offset%x5|Dupli%x6|%l|Mass%x7|Damping%x8|Properties%x9|Logic Bricks%x10|Protected Transform%x29|%l"); + strcpy(str, "Copy Attributes %t|Location%x1|Rotation%x2|Size%x3|Draw Options%x4|Time Offset%x5|Dupli%x6|%l|Mass%x7|Damping%x8|All Physical Attributes%x11|Properties%x9|Logic Bricks%x10|Protected Transform%x29|%l"); strcat (str, "|Object Constraints%x22"); strcat (str, "|NLA Strips%x26"); diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 71bf0cd9bd4..0b48db461e6 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -2196,6 +2196,7 @@ static uiBlock *view3d_edit_object_copyattrmenu(void *arg_unused) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Mass|Ctrl C, 7", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Damping|Ctrl C, 8", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "All Physical Attributes|Ctrl C, 11", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 11, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Properties|Ctrl C, 9", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Logic Bricks|Ctrl C, 10", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 10, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Protected Transform |Ctrl C", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 29, ""); -- cgit v1.2.3 From 34bb44673469dc50e980dec86b5892789449b378 Mon Sep 17 00:00:00 2001 From: Mal Duffin Date: Tue, 29 Jul 2008 22:44:43 +0000 Subject: Simple changes to Motion Actuator UI. This includes... - Renaming dLoc and dRot as Loc and Rot ( as well as changing the tooltip to location and rotation ). dLoc and dRot are programming terms, not user terms. - Placing Loc and Rot as the two initial shown values, so that the physical ones are all shown together. I also changed it so that only Loc and Rot are shown in the UI, unless the object is Dynamic ( as the other values only make sense if it is dynamic ). These are just a few simple changes, that should make a lot of difference to users when learning how to use the GE. -------------------------------------- Things I'd *really* like to do to this, when I get a chance to code Blender again ( hopefully in a few days time, after I have finished teaching on the GE course )... Color / Colour tint the X,Y and Z entry boxes as slightly red, green and blue, to reflect the colour of the axis / transform gizmo ...or... Just show X,Y and Z labels above all of the values. Getting to grips with the whole XYZ thing is very confusing for users, esp when they are presented with 6 x 3 entry boxes. --- source/blender/src/buttons_logic.c | 89 ++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 38 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/buttons_logic.c b/source/blender/src/buttons_logic.c index 498edc0dfed..5cf1958678e 100644 --- a/source/blender/src/buttons_logic.c +++ b/source/blender/src/buttons_logic.c @@ -1654,53 +1654,66 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh wval = (width-100)/3; if (oa->type == ACT_OBJECT_NORMAL) { - ysize= 175; - + if ( ob->gameflag & OB_DYNAMIC ) + { + ysize= 175; + } + else + { + ysize= 72; + } + glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefBut(block, LABEL, 0, "Force", xco, yco-45, 55, 19, NULL, 0, 0, 0, 0, "Sets the force"); - uiDefButF(block, NUM, 0, "", xco+45, yco-45, wval, 19, oa->forceloc, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-45, wval, 19, oa->forceloc+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-45, wval, 19, oa->forceloc+2, -10000.0, 10000.0, 10, 0, ""); - - uiDefBut(block, LABEL, 0, "Torque", xco, yco-64, 55, 19, NULL, 0, 0, 0, 0, "Sets the torque"); - uiDefButF(block, NUM, 0, "", xco+45, yco-64, wval, 19, oa->forcerot, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-64, wval, 19, oa->forcerot+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-64, wval, 19, oa->forcerot+2, -10000.0, 10000.0, 10, 0, ""); + uiDefBut(block, LABEL, 0, "Loc", xco, yco-45, 45, 19, NULL, 0, 0, 0, 0, "Sets the location"); + uiDefButF(block, NUM, 0, "", xco+45, yco-45, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-45, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-45, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, ""); - uiDefBut(block, LABEL, 0, "dLoc", xco, yco-87, 45, 19, NULL, 0, 0, 0, 0, "Sets the dLoc"); - uiDefButF(block, NUM, 0, "", xco+45, yco-87, wval, 19, oa->dloc, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-87, wval, 19, oa->dloc+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-87, wval, 19, oa->dloc+2, -10000.0, 10000.0, 10, 0, ""); - - uiDefBut(block, LABEL, 0, "dRot", xco, yco-106, 45, 19, NULL, 0, 0, 0, 0, "Sets the dRot"); - uiDefButF(block, NUM, 0, "", xco+45, yco-106, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-106, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-106, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, ""); + uiDefBut(block, LABEL, 0, "Rot", xco, yco-64, 45, 19, NULL, 0, 0, 0, 0, "Sets the rotation"); + uiDefButF(block, NUM, 0, "", xco+45, yco-64, wval, 19, oa->drot, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-64, wval, 19, oa->drot+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-64, wval, 19, oa->drot+2, -10000.0, 10000.0, 10, 0, ""); + + uiDefButBitS(block, TOG, ACT_DLOC_LOCAL, 0, "L", xco+45+3*wval, yco-45, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButBitS(block, TOG, ACT_DROT_LOCAL, 0, "L", xco+45+3*wval, yco-64, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + + if ( ob->gameflag & OB_DYNAMIC ) + { + uiDefBut(block, LABEL, 0, "Force", xco, yco-87, 55, 19, NULL, 0, 0, 0, 0, "Sets the force"); + uiDefButF(block, NUM, 0, "", xco+45, yco-87, wval, 19, oa->forceloc, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-87, wval, 19, oa->forceloc+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-87, wval, 19, oa->forceloc+2, -10000.0, 10000.0, 10, 0, ""); - uiDefBut(block, LABEL, 0, "linV", xco, yco-129, 45, 19, NULL, 0, 0, 0, 0, "Sets the linear velocity"); - uiDefButF(block, NUM, 0, "", xco+45, yco-129, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-129, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-129, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, ""); + uiDefBut(block, LABEL, 0, "Torque", xco, yco-106, 55, 19, NULL, 0, 0, 0, 0, "Sets the torque"); + uiDefButF(block, NUM, 0, "", xco+45, yco-106, wval, 19, oa->forcerot, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-106, wval, 19, oa->forcerot+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-6106, wval, 19, oa->forcerot+2, -10000.0, 10000.0, 10, 0, ""); + } - uiDefBut(block, LABEL, 0, "angV", xco, yco-148, 45, 19, NULL, 0, 0, 0, 0, "Sets the angular velocity"); - uiDefButF(block, NUM, 0, "", xco+45, yco-148, wval, 19, oa->angularvelocity, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+wval, yco-148, wval, 19, oa->angularvelocity+1, -10000.0, 10000.0, 10, 0, ""); - uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-148, wval, 19, oa->angularvelocity+2, -10000.0, 10000.0, 10, 0, ""); + if ( ob->gameflag & OB_DYNAMIC ) + { + uiDefBut(block, LABEL, 0, "LinV", xco, yco-129, 45, 19, NULL, 0, 0, 0, 0, "Sets the linear velocity"); + uiDefButF(block, NUM, 0, "", xco+45, yco-129, wval, 19, oa->linearvelocity, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-129, wval, 19, oa->linearvelocity+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-129, wval, 19, oa->linearvelocity+2, -10000.0, 10000.0, 10, 0, ""); - uiDefBut(block, LABEL, 0, "damp", xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Number of frames to reach the target velocity"); - uiDefButS(block, NUM, 0, "", xco+45, yco-171, wval, 19, &oa->damping, 0.0, 1000.0, 100, 0, ""); - - uiDefButBitS(block, TOG, ACT_FORCE_LOCAL, 0, "L", xco+45+3*wval, yco-45, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButBitS(block, TOG, ACT_TORQUE_LOCAL, 0, "L", xco+45+3*wval, yco-64, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButBitS(block, TOG, ACT_DLOC_LOCAL, 0, "L", xco+45+3*wval, yco-87, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButBitS(block, TOG, ACT_DROT_LOCAL, 0, "L", xco+45+3*wval, yco-106, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButBitS(block, TOG, ACT_LIN_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-129, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); - uiDefButBitS(block, TOG, ACT_ANG_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-148, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefBut(block, LABEL, 0, "AngV", xco, yco-148, 45, 19, NULL, 0, 0, 0, 0, "Sets the angular velocity"); + uiDefButF(block, NUM, 0, "", xco+45, yco-148, wval, 19, oa->angularvelocity, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+wval, yco-148, wval, 19, oa->angularvelocity+1, -10000.0, 10000.0, 10, 0, ""); + uiDefButF(block, NUM, 0, "", xco+45+2*wval, yco-148, wval, 19, oa->angularvelocity+2, -10000.0, 10000.0, 10, 0, ""); - uiDefButBitS(block, TOG, ACT_ADD_LIN_VEL, 0, "add",xco+45+3*wval+15, yco-129, 35, 19, &oa->flag, 0.0, 0.0, 0, 0, "Toggles between ADD and SET linV"); + uiDefBut(block, LABEL, 0, "Damp", xco, yco-171, 45, 19, NULL, 0, 0, 0, 0, "Number of frames to reach the target velocity"); + uiDefButS(block, NUM, 0, "", xco+45, yco-171, wval, 19, &oa->damping, 0.0, 1000.0, 100, 0, ""); + + uiDefButBitS(block, TOG, ACT_FORCE_LOCAL, 0, "L", xco+45+3*wval, yco-87, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButBitS(block, TOG, ACT_TORQUE_LOCAL, 0, "L", xco+45+3*wval, yco-106, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButBitS(block, TOG, ACT_LIN_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-129, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButBitS(block, TOG, ACT_ANG_VEL_LOCAL, 0, "L", xco+45+3*wval, yco-148, 15, 19, &oa->flag, 0.0, 0.0, 0, 0, "Local transformation"); + uiDefButBitS(block, TOG, ACT_ADD_LIN_VEL, 0, "add",xco+45+3*wval+15, yco-129, 35, 19, &oa->flag, 0.0, 0.0, 0, 0, "Toggles between ADD and SET linV"); + } } else if (oa->type == ACT_OBJECT_SERVO) { ysize= 172; -- cgit v1.2.3 From 7b819bc6316ac32c60dd6a0e404bc9e2a781feba Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 30 Jul 2008 09:07:56 +0000 Subject: == Grease Pencil - Eraser (First Draft) == This commit introduces the ability to erase strokes. Admittedly, the code for this is not totally stable yet, and doesn't always produce optimum results. I'm committing now for backup purposes. It currently uses the lasso code to check whether segments of the strokes (a segment occurs between two recorded points) occur inside a region defined by the 'eraser' stroke, or any intersections it makes with the 'eraser' stroke. There are multiple ways to erase strokes: * With 'Draw Mode' on, use RMB-drag to erase * With a tablet, use the 'eraser' end of the stylus * Hold the Alt Key, and use the 'selection' mouse-button (i.e. LMB if mouse-button swapping is on, RMB otherwise) to erase. For this one, this is necessary to avoid overriding the view-rotation hotkey combo for 2-button mice! Todo: * 3d-strokes are not correctly mapped back to screen-space for sampling yet * Drawing of eraser strokes is still not distinctive enough * After running a few times, may cause stack corruption/segfaults, so be careful! == Bugfixes == * Grease-Pencil Onion-Skinning works again. Onionskining was being supplied the wrong frames, and the alpha factor was still the old one used for 0-255 ranged colour values --- source/blender/src/drawgpencil.c | 92 ++++++++-- source/blender/src/editview.c | 2 +- source/blender/src/gpencil.c | 358 ++++++++++++++++++++++++++++++--------- 3 files changed, 358 insertions(+), 94 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/drawgpencil.c b/source/blender/src/drawgpencil.c index e07dec90629..733310bfda7 100644 --- a/source/blender/src/drawgpencil.c +++ b/source/blender/src/drawgpencil.c @@ -280,11 +280,15 @@ short draw_gpencil_panel (uiBlock *block, bGPdata *gpd, ScrArea *sa) /* show override lmb-clicks button + painting lock */ uiBlockBeginAlign(block); - uiDefButBitI(block, TOG, GP_DATA_EDITPAINT, B_REDR, "Draw Mode", 170, 225, 130, 20, &gpd->flag, 0, 0, 0, 0, "Interpret LMB-click as new strokes (same as holding Shift-Key per stroke)"); - - uiBlockSetCol(block, TH_BUT_SETTING); - uiDefIconButBitI(block, ICONTOG, GP_DATA_LMBPLOCK, B_REDR, ICON_UNLOCKED, 300, 225, 20, 20, &gpd->flag, 0.0, 0.0, 0, 0, "Painting cannot occur with Shift-LMB (when making selections)"); - uiBlockSetCol(block, TH_AUTO); + if ((gpd->flag & GP_DATA_EDITPAINT)==0) { + uiDefButBitI(block, TOG, GP_DATA_EDITPAINT, B_REDR, "Draw Mode", 170, 225, 130, 20, &gpd->flag, 0, 0, 0, 0, "Interpret click-drag as new strokes"); + + uiBlockSetCol(block, TH_BUT_SETTING); + uiDefIconButBitI(block, ICONTOG, GP_DATA_LMBPLOCK, B_REDR, ICON_UNLOCKED, 300, 225, 20, 20, &gpd->flag, 0.0, 0.0, 0, 0, "Painting cannot occur with Shift-LMB (when making selections)"); + uiBlockSetCol(block, TH_AUTO); + } + else + uiDefButBitI(block, TOG, GP_DATA_EDITPAINT, B_REDR, "Draw Mode", 170, 225, 150, 20, &gpd->flag, 0, 0, 0, 0, "Interpret click-drag as new strokes"); uiBlockEndAlign(block); /* 'view align' button (naming depends on context) */ @@ -313,6 +317,66 @@ enum { GP_DRAWDATA_ONLYV2D = (1<<2), /* only draw 'canvas' strokes */ }; +/* draw stroke in buffer */ +static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thickness, short dflag, short sflag) +{ + tGPspoint *pt; + int i; + + /* error checking */ + if ((points == NULL) || (totpoints <= 0)) + return; + + /* check if buffer can be drawn */ + if (dflag & (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_ONLYV2D)) + return; + + /* if drawing a single point, draw it larger */ + if (totpoints == 1) { + /* draw point */ + glBegin(GL_POINTS); + glVertex2f(points->x, points->y); + glEnd(); + } + else if (sflag & GP_STROKE_ERASER) { + /* draw stroke curve - just standard thickness */ + setlinestyle(4); + glLineWidth(1.0f); + + glBegin(GL_LINE_STRIP); + for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + glVertex2f(pt->x, pt->y); + } + glEnd(); + + setlinestyle(0); + } + else { + float oldpressure = 0.0f; + + /* draw stroke curve */ + setlinestyle(2); + + glBegin(GL_LINE_STRIP); + for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + if (fabs(pt->pressure - oldpressure) > 0.2f) { + glEnd(); + glLineWidth(pt->pressure * thickness); + glBegin(GL_LINE_STRIP); + + glVertex2f(pt->x, pt->y); + + oldpressure = pt->pressure; + } + else + glVertex2f(pt->x, pt->y); + } + glEnd(); + + setlinestyle(0); + } +} + /* draw a given stroke */ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness, short dflag, short sflag, short debug, int winx, int winy) { @@ -489,8 +553,8 @@ static void gp_draw_data (bGPdata *gpd, int winx, int winy, int dflag) /* check if frame is drawable */ if ((gpf->framenum - gf->framenum) <= gpl->gstep) { /* alpha decreases with distance from curframe index */ - tcolor[3] = color[3] - (i * 0.7); - gp_draw_strokes(gpf, winx, winy, dflag, debug, lthick, tcolor); + tcolor[3] = color[3] - (i/gpl->gstep); + gp_draw_strokes(gf, winx, winy, dflag, debug, lthick, tcolor); } else break; @@ -501,8 +565,8 @@ static void gp_draw_data (bGPdata *gpd, int winx, int winy, int dflag) /* check if frame is drawable */ if ((gf->framenum - gpf->framenum) <= gpl->gstep) { /* alpha decreases with distance from curframe index */ - tcolor[3] = color[3] - (i * 0.7); - gp_draw_strokes(gpf, winx, winy, dflag, debug, lthick, tcolor); + tcolor[3] = color[3] - (i/gpl->gstep); + gp_draw_strokes(gf, winx, winy, dflag, debug, lthick, tcolor); } else break; @@ -515,12 +579,12 @@ static void gp_draw_data (bGPdata *gpd, int winx, int winy, int dflag) /* draw the strokes for the ghost frames (at half of the alpha set by user) */ if (gpf->prev) { tcolor[3] = (color[3] / 7); - gp_draw_strokes(gpf, winx, winy, dflag, debug, lthick, tcolor); + gp_draw_strokes(gpf->prev, winx, winy, dflag, debug, lthick, tcolor); } if (gpf->next) { tcolor[3] = (color[3] / 4); - gp_draw_strokes(gpf, winx, winy, dflag, debug, lthick, tcolor); + gp_draw_strokes(gpf->next, winx, winy, dflag, debug, lthick, tcolor); } /* restore alpha */ @@ -533,15 +597,13 @@ static void gp_draw_data (bGPdata *gpd, int winx, int winy, int dflag) gp_draw_strokes(gpf, winx, winy, dflag, debug, lthick, tcolor); /* Check if may need to draw the active stroke cache, only if this layer is the active layer - * that is being edited. (Stroke cache is currently stored in gp-data) + * that is being edited. (Stroke buffer is currently stored in gp-data) */ if ((G.f & G_GREASEPENCIL) && (gpl->flag & GP_LAYER_ACTIVE) && (gpf->flag & GP_FRAME_PAINT)) { /* Buffer stroke needs to be drawn with a different linestyle to help differentiate them from normal strokes. */ - setlinestyle(2); - gp_draw_stroke(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag, debug, winx, winy); - setlinestyle(0); + gp_draw_stroke_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag); } } diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c index e3ec69975de..f58248be161 100644 --- a/source/blender/src/editview.c +++ b/source/blender/src/editview.c @@ -298,7 +298,7 @@ int lasso_inside(short mcords[][2], short moves, short sx, short sy) } /* edge version for lasso select. we assume boundbox check was done */ -static int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1) +int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, int y1) { short v1[2], v2[2]; int a; diff --git a/source/blender/src/gpencil.c b/source/blender/src/gpencil.c index 24ed6a7b0ba..fe01106919f 100644 --- a/source/blender/src/gpencil.c +++ b/source/blender/src/gpencil.c @@ -57,6 +57,7 @@ #include "BIF_gl.h" #include "BIF_glutil.h" #include "BIF_butspace.h" +#include "BIF_editview.h" #include "BIF_graphics.h" #include "BIF_interface.h" #include "BIF_mywindow.h" @@ -683,7 +684,7 @@ typedef struct tGPsdata { bGPDframe *gpf; /* frame we're working on */ short status; /* current status of painting */ - short paintmode; /* mode for painting (L_MOUSE or R_MOUSE for now) */ + short paintmode; /* mode for painting */ } tGPsdata; /* values for tGPsdata->status */ @@ -693,6 +694,12 @@ enum { GP_STATUS_DONE /* painting done */ }; +/* values for tGPsdata->paintmode */ +enum { + GP_PAINTMODE_DRAW = 0, + GP_PAINTMODE_ERASER +}; + /* Return flags for adding points to stroke buffer */ enum { GP_STROKEADD_INVALID = -2, /* error occurred - insufficient info to do so */ @@ -710,9 +717,9 @@ static void gp_session_validatebuffer (tGPsdata *p) /* clear memory of buffer (or allocate it if starting a new session) */ if (gpd->sbuffer) - memset(gpd->sbuffer, 0, sizeof(bGPDspoint)*GP_STROKE_BUFFER_MAX); + memset(gpd->sbuffer, 0, sizeof(tGPspoint)*GP_STROKE_BUFFER_MAX); else - gpd->sbuffer= MEM_callocN(sizeof(bGPDspoint)*GP_STROKE_BUFFER_MAX, "gp_session_strokebuffer"); + gpd->sbuffer= MEM_callocN(sizeof(tGPspoint)*GP_STROKE_BUFFER_MAX, "gp_session_strokebuffer"); /* reset indices */ gpd->sbuffer_size = 0; @@ -850,6 +857,25 @@ static void gp_session_cleanup (tGPsdata *p) gpd->sbuffer_sflag= 0; } +/* check if the current mouse position is suitable for adding a new point */ +static short gp_stroke_filtermval (tGPsdata *p, short mval[2], short pmval[2]) +{ + short dx= abs(mval[0] - pmval[0]); + short dy= abs(mval[1] - pmval[1]); + + /* check if mouse moved at least certain distance on both axes (best case) */ + if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) + return 1; + + /* check if the distance since the last point is significant enough */ + else if (sqrt(dx*dx + dy*dy) > MIN_EUCLIDEAN_PX) + return 1; + + /* mouse 'didn't move' */ + else + return 0; +} + /* convert screen-coordinates to buffer-coordinates */ static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[]) { @@ -884,30 +910,11 @@ static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[]) } } -/* check if the current mouse position is suitable for adding a new point */ -static short gp_stroke_filtermval (tGPsdata *p, short mval[2], short pmval[2]) -{ - short dx= abs(mval[0] - pmval[0]); - short dy= abs(mval[1] - pmval[1]); - - /* check if mouse moved at least certain distance on both axes (best case) */ - if ((dx > MIN_MANHATTEN_PX) && (dy > MIN_MANHATTEN_PX)) - return 1; - - /* check if the distance since the last point is significant enough */ - else if (sqrt(dx*dx + dy*dy) > MIN_EUCLIDEAN_PX) - return 1; - - /* mouse 'didn't move' */ - else - return 0; -} - /* add current stroke-point to buffer (returns whether point was successfully added) */ static short gp_stroke_addpoint (tGPsdata *p, short mval[2], float pressure) { bGPdata *gpd= p->gpd; - bGPDspoint *pt; + tGPspoint *pt; /* check if still room in buffer */ if (gpd->sbuffer_size >= GP_STROKE_BUFFER_MAX) @@ -915,12 +922,13 @@ static short gp_stroke_addpoint (tGPsdata *p, short mval[2], float pressure) /* get pointer to destination point */ - pt= gpd->sbuffer + gpd->sbuffer_size; + pt= ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size); - /* convert screen-coordinates to appropriate coordinates (and store them) */ - gp_stroke_convertcoords(p, mval, &pt->x); - - /* store other settings */ + /* store settings */ + pt->x= mval[0]; + pt->y= mval[1]; + pt->xf= (float)mval[0]; + pt->yf= (float)mval[0]; pt->pressure= pressure; /* increment counters */ @@ -933,38 +941,13 @@ static short gp_stroke_addpoint (tGPsdata *p, short mval[2], float pressure) return GP_STROKEADD_NORMAL; } -/* smooth a stroke (in buffer) before storing it */ -static void gp_stroke_smooth (tGPsdata *p) -{ - bGPdata *gpd= p->gpd; - int i=0, cmx=gpd->sbuffer_size; - - // fixme: currently disabled as it damages too much sometimes - return; - - /* don't try if less than 2 points in buffer */ - if ((cmx <= 2) || (gpd->sbuffer == NULL)) - return; - - /* apply weighting-average (note doing this along path sequentially does introduce slight error) */ - for (i=0; i < gpd->sbuffer_size; i++) { - bGPDspoint *pc= (gpd->sbuffer + i); - bGPDspoint *pb= (i-1 > 0)?(pc-1):(pc); - bGPDspoint *pa= (i-2 > 0)?(pc-2):(pb); - bGPDspoint *pd= (i+1 < cmx)?(pc+1):(pc); - bGPDspoint *pe= (i+2 < cmx)?(pc+2):(pd); - - pc->x= (0.1*pa->x + 0.2*pb->x + 0.4*pc->x + 0.2*pd->x + 0.1*pe->x); - pc->y= (0.1*pa->y + 0.2*pb->y + 0.4*pc->y + 0.2*pd->y + 0.1*pe->y); - } -} - /* make a new stroke from the buffer data */ static void gp_stroke_newfrombuffer (tGPsdata *p) { bGPdata *gpd= p->gpd; bGPDstroke *gps; - bGPDspoint *pt, *ptc; + bGPDspoint *pt; + tGPspoint *ptc; int i, totelem; /* get total number of points to allocate space for */ @@ -990,7 +973,12 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) /* copy points from the buffer to the stroke */ for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++) { - memcpy(pt, ptc, sizeof(bGPDspoint)); + /* convert screen-coordinates to appropriate coordinates (and store them) */ + gp_stroke_convertcoords(p, &ptc->x, &pt->x); + + /* copy pressure */ + pt->pressure= ptc->pressure; + pt++; } @@ -998,10 +986,202 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) BLI_addtail(&p->gpf->strokes, gps); } +/* --- 'Eraser' for 'Paint' Tool ------ */ +/* User should draw 'circles' around the parts of the sketches they wish to + * delete instead of drawing squiggles over existing lines. This should be + * easier to manage than if it was done otherwise. + */ + +/* convert gp-buffer stroke into mouse-coordinates array */ +static short (*gp_stroke_eraser_2mco (bGPdata *gpd))[2] +{ + tGPspoint *pt; + short (*mcoords)[2]; + int i; + + /* allocate memory for coordinates array */ + mcoords= MEM_mallocN(sizeof(*mcoords)*gpd->sbuffer_size,"gp_buf_mcords"); + + /* copy coordinates */ + for (pt=gpd->sbuffer, i=0; i < gpd->sbuffer_size; i++, pt++) { + mcoords[i][0]= pt->x; + mcoords[i][1]= pt->y; + } + + /* return */ + return mcoords; +} + +/* eraser tool evaluation per curve */ +static void gp_stroke_eraser_dostroke (tGPsdata *p, short mcoords[][2], short moves, bGPDframe *gpf, bGPDstroke *gps) +{ + bGPDspoint *pt1, *pt2; + short x0=0, y0=0, x1=0, y1=0; + short xyval[2]; + int i; + + if (gps->totpoints == 0) { + /* just free stroke */ + if (gps->points) + MEM_freeN(gps->points); + BLI_freelinkN(&gpf->strokes, gps); + } + else if (gps->totpoints == 1) { + /* get coordinates */ + if (gps->flag & GP_STROKE_3DSPACE) { + // FIXME: this may not be the correct correction + project_short(&gps->points->x, xyval); + x0= xyval[0]; + x1= xyval[1]; + } + else if (gps->flag & GP_STROKE_2DSPACE) { + ipoco_to_areaco_noclip(p->v2d, &gps->points->x, xyval); + x0= xyval[0]; + y0= xyval[1]; + } + else { + x0= (gps->points->x / 1000 * p->sa->winx); + y0= (gps->points->y / 1000 * p->sa->winy); + } + + /* only check if point is inside */ + if (lasso_inside(mcoords, moves, x0, y0)) { + /* free stroke */ + MEM_freeN(gps->points); + BLI_freelinkN(&gpf->strokes, gps); + } + } + else { + /* loop over the points in the stroke, checking for intersections + * - an intersection will require the stroke to be split + */ + for (i=0; (i+1) < gps->totpoints; i++) { + /* get points to work with */ + pt1= gps->points + i; + pt2= gps->points + i + 1; + + /* get coordinates */ + if (gps->flag & GP_STROKE_3DSPACE) { + // FIXME: may not be correct correction + project_short(&gps->points->x, xyval); + x0= xyval[0]; + x1= xyval[1]; + } + else if (gps->flag & GP_STROKE_2DSPACE) { + ipoco_to_areaco_noclip(p->v2d, &pt1->x, xyval); + x0= xyval[0]; + y0= xyval[1]; + + ipoco_to_areaco_noclip(p->v2d, &pt2->x, xyval); + x1= xyval[0]; + y1= xyval[1]; + } + else { + x0= (pt1->x / 1000 * p->sa->winx); + y0= (pt1->y / 1000 * p->sa->winy); + x1= (pt2->x / 1000 * p->sa->winx); + y1= (pt2->y / 1000 * p->sa->winy); + } + + /* check if point segment of stroke had anything to do with + * eraser region (either within stroke painted, or on its lines) + * - this assumes that linewidth is irrelevant + * - handled using the lasso-select checking code + */ + if (lasso_inside_edge(mcoords, moves, x0, y0, x1, x1)) { + bGPDspoint *pt_tmp= gps->points; + bGPDstroke *gsn = NULL; + + /* if stroke only had two points, get rid of stroke */ + if (gps->totpoints == 2) { + /* free stroke points, then stroke */ + MEM_freeN(pt_tmp); + BLI_freelinkN(&gpf->strokes, gps); + + /* nothing left in stroke, so stop */ + break; + } + + /* if last segment, just remove segment from the stroke */ + else if (i == gps->totpoints - 2) { + /* allocate new points array, and assign most of the old stroke there */ + gps->totpoints--; + gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*gps->totpoints); + + /* free temp buffer */ + MEM_freeN(pt_tmp); + + /* nothing left in stroke, so stop */ + break; + } + + /* if first segment, just remove segment from the stroke */ + else if (i == 0) { + /* allocate new points array, and assign most of the old stroke there */ + gps->totpoints--; + gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp + 1, sizeof(bGPDspoint)*gps->totpoints); + + /* free temp buffer */ + MEM_freeN(pt_tmp); + + /* no break here, as there might still be stuff to remove in this stroke */ + } + + /* segment occurs in 'middle' of stroke, so split */ + else { + /* duplicate stroke, and assign 'later' data to that stroke */ + gsn= MEM_dupallocN(gps); + gsn->prev= gsn->next= NULL; + BLI_insertlinkafter(&gpf->strokes, gps, gsn); + + gsn->totpoints= gps->totpoints - i; + gsn->points= MEM_callocN(sizeof(bGPDspoint)*gsn->totpoints, "gp_stroke_points"); + memcpy(gsn->points, pt_tmp + i, sizeof(bGPDspoint)*gsn->totpoints); + + /* adjust existing stroke */ + gps->totpoints= i; + gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*i); + + /* free temp buffer */ + MEM_freeN(pt_tmp); + + /* nothing left in stroke, so stop */ + break; + } + } + } + } +} + +/* -------- */ + +/* erase strokes which fall under the eraser strokes */ +static void gp_stroke_doeraser (tGPsdata *p) +{ + bGPdata *gpd= p->gpd; + bGPDframe *gpf= p->gpf; + bGPDstroke *gps; + short (*mcoords)[2]; + + /* get buffer-stroke coordinates as shorts array */ + mcoords= gp_stroke_eraser_2mco(gpd); + + /* loop over strokes, checking segments for intersections */ + for (gps= gpf->strokes.first; gps; gps= gps->next) { + gp_stroke_eraser_dostroke(p, mcoords, gpd->sbuffer_size, gpf, gps); + } + + /* free mcoords array */ + MEM_freeN(mcoords); +} + /* ---------- 'Paint' Tool ------------ */ /* init new stroke */ -static void gp_paint_initstroke (tGPsdata *p, short mousebutton) +static void gp_paint_initstroke (tGPsdata *p, short paintmode) { /* get active layer (or add a new one if non-existent) */ p->gpl= gpencil_layer_getactive(p->gpd); @@ -1025,14 +1205,10 @@ static void gp_paint_initstroke (tGPsdata *p, short mousebutton) else p->gpf->flag |= GP_FRAME_PAINT; - /* set 'eraser' for this stroke if using eraser or right-mouse in action */ - if ( get_activedevice() == 2 || (mousebutton & R_MOUSE) ) { + /* set 'eraser' for this stroke if using eraser */ + p->paintmode= paintmode; + if (p->paintmode == GP_PAINTMODE_ERASER) p->gpd->sbuffer_sflag |= GP_STROKE_ERASER; - - // for now: eraser isn't ready for prime-time yet, so no painting available here yet - p->status= GP_STATUS_ERROR; - return; - } /* check if points will need to be made in view-aligned space */ if (p->gpd->flag & GP_DATA_VIEWALIGN) { @@ -1062,12 +1238,10 @@ static void gp_paint_initstroke (tGPsdata *p, short mousebutton) /* finish off a stroke (clears buffer, but doesn't finish the paint operation) */ static void gp_paint_strokeend (tGPsdata *p) { - /* sanitize stroke-points in buffer (remove jitter) */ - gp_stroke_smooth(p); - /* check if doing eraser or not */ if (p->gpd->sbuffer_sflag & GP_STROKE_ERASER) { /* get rid of relevant sections of strokes */ + gp_stroke_doeraser(p); } else { /* transfer stroke to frame */ @@ -1100,7 +1274,7 @@ static void gp_paint_cleanup (tGPsdata *p) /* -------- */ /* main call to paint a new stroke */ -short gpencil_paint (short mousebutton) +short gpencil_paint (short mousebutton, short paintmode) { tGPsdata p; short prevmval[2], mval[2]; @@ -1113,7 +1287,7 @@ short gpencil_paint (short mousebutton) gp_session_cleanup(&p); return 0; } - gp_paint_initstroke(&p, mousebutton); + gp_paint_initstroke(&p, paintmode); if (p.status == GP_STATUS_ERROR) { gp_session_cleanup(&p); return 0; @@ -1188,7 +1362,10 @@ short gpencil_paint (short mousebutton) setcursor_space(p.sa->spacetype, CURSOR_STD); /* check size of buffer before cleanup, to determine if anything happened here */ - ok= p.gpd->sbuffer_size; + if (paintmode == GP_PAINTMODE_ERASER) + ok= (p.gpd->sbuffer_size > 1); + else + ok= p.gpd->sbuffer_size; /* cleanup */ gp_paint_cleanup(&p); @@ -1202,7 +1379,7 @@ short gpencil_paint (short mousebutton) /* All event (loops) handling checking if stroke drawing should be initiated * should call this function. */ -short gpencil_do_paint (ScrArea *sa, short mousebutton) +short gpencil_do_paint (ScrArea *sa, short mbut) { bGPdata *gpd = gpencil_data_getactive(sa); short retval= 0; @@ -1211,18 +1388,43 @@ short gpencil_do_paint (ScrArea *sa, short mousebutton) if (gpd == NULL) return 0; - /* currently, we will only paint if: + /* currently, we will only 'paint' if: * 1. draw-mode on gpd is set (for accessibility reasons) * (single 'dots' are only available via this method) * 2. if shift-modifier is held + lmb -> 'quick paint' + * + * OR + * + * draw eraser stroke if: + * 1. using the eraser on a tablet + * 2. draw-mode on gpd is set (for accessiblity reasons) + * (eraser is mapped to right-mouse) + * 3. Alt + 'select' mouse-button + * i.e. if LMB = select: Alt-LMB + * if RMB = select: Alt-RMB */ - if (gpd->flag & GP_DATA_EDITPAINT) { - /* try to paint */ - retval = gpencil_paint(mousebutton); + if (get_activedevice() == 2) { + /* eraser on a tablet - always try to erase strokes */ + retval = gpencil_paint(mbut, GP_PAINTMODE_ERASER); } - else if (!(gpd->flag & GP_DATA_LMBPLOCK) && (G.qual == LR_SHIFTKEY)) { - /* try to paint */ - retval = gpencil_paint(mousebutton); + else if (gpd->flag & GP_DATA_EDITPAINT) { + /* try to paint/erase */ + if (mbut == L_MOUSE) + retval = gpencil_paint(mbut, GP_PAINTMODE_DRAW); + else if (mbut == R_MOUSE) + retval = gpencil_paint(mbut, GP_PAINTMODE_ERASER); + } + else if (!(gpd->flag & GP_DATA_LMBPLOCK)) { + /* try to paint/erase as not locked */ + if ((G.qual == LR_SHIFTKEY) && (mbut == L_MOUSE)) { + retval = gpencil_paint(mbut, GP_PAINTMODE_DRAW); + } + else if (G.qual == LR_ALTKEY) { + if ((U.flag & USER_LMOUSESELECT) && (mbut == L_MOUSE)) + retval = gpencil_paint(mbut, GP_PAINTMODE_ERASER); + else if (!(U.flag & USER_LMOUSESELECT) && (mbut == R_MOUSE)) + retval = gpencil_paint(mbut, GP_PAINTMODE_ERASER); + } } /* return result of trying to paint */ -- cgit v1.2.3 From f3a4f3adaf4de26c45e0b5264e2e52b089ce7891 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 30 Jul 2008 09:20:05 +0000 Subject: Grease Pencil Bugfixes: * Segfaults with eraser should now be fixed * Attempted fixed for sequencer redraw problems with buttons --- source/blender/src/gpencil.c | 5 +++-- source/blender/src/space.c | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/gpencil.c b/source/blender/src/gpencil.c index fe01106919f..f4274b853cc 100644 --- a/source/blender/src/gpencil.c +++ b/source/blender/src/gpencil.c @@ -1163,14 +1163,15 @@ static void gp_stroke_doeraser (tGPsdata *p) { bGPdata *gpd= p->gpd; bGPDframe *gpf= p->gpf; - bGPDstroke *gps; + bGPDstroke *gps, *gpn; short (*mcoords)[2]; /* get buffer-stroke coordinates as shorts array */ mcoords= gp_stroke_eraser_2mco(gpd); /* loop over strokes, checking segments for intersections */ - for (gps= gpf->strokes.first; gps; gps= gps->next) { + for (gps= gpf->strokes.first; gps; gps= gpn) { + gpn= gps->next; gp_stroke_eraser_dostroke(p, mcoords, gpd->sbuffer_size, gpf, gps); } diff --git a/source/blender/src/space.c b/source/blender/src/space.c index c30f6ca9f54..b4702788e0c 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -5119,7 +5119,10 @@ static void winqreadseqspace(ScrArea *sa, void *spacedata, BWinEvent *evt) } } - if(doredraw) scrarea_queue_winredraw(curarea); + if(doredraw) { + scrarea_queue_winredraw(curarea); + scrarea_queue_headredraw(curarea); + } } -- cgit v1.2.3 From 2d3a57eaa3ce9237ca5334a8fbcd23b1b060739e Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Wed, 30 Jul 2008 11:21:10 +0000 Subject: Bugfix for mesh deformer under windows --> uninitialized variable was used in meshdeform_inside_cage() --- source/blender/src/meshlaplacian.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/src') diff --git a/source/blender/src/meshlaplacian.c b/source/blender/src/meshlaplacian.c index 4d84672185a..60f569ecf0e 100644 --- a/source/blender/src/meshlaplacian.c +++ b/source/blender/src/meshlaplacian.c @@ -1281,9 +1281,9 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) outside[1] = co[1] + (mdb->max[1] - mdb->min[1] + 1.0f)*MESHDEFORM_OFFSET[i][1]; outside[2] = co[2] + (mdb->max[2] - mdb->min[2] + 1.0f)*MESHDEFORM_OFFSET[i][2]; + VECCOPY(start, co); VECSUB(dir, outside, start); Normalize(dir); - VECCOPY(start, co); isect = meshdeform_ray_tree_intersect(mdb, start, outside); if(isect && !isect->facing) -- cgit v1.2.3 From d66449996cb719138d1fe3e6838fd403cf64a512 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 31 Jul 2008 12:23:29 +0000 Subject: == Grease Pencil Eraser - Tweaks == Improved accuracy of the eraser a bit. Now it does a boundbox test first before trying to erase strokes, which means that other (rather unrelated) strokes are less likely to be affected as well. --- source/blender/src/editview.c | 2 +- source/blender/src/gpencil.c | 171 +++++++++++++++++++++++------------------- 2 files changed, 95 insertions(+), 78 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/editview.c b/source/blender/src/editview.c index f58248be161..a3fcad7885c 100644 --- a/source/blender/src/editview.c +++ b/source/blender/src/editview.c @@ -371,7 +371,7 @@ static void do_lasso_select_objects(short mcords[][2], short moves, short select } } -static void lasso_select_boundbox(rcti *rect, short mcords[][2], short moves) +void lasso_select_boundbox(rcti *rect, short mcords[][2], short moves) { short a; diff --git a/source/blender/src/gpencil.c b/source/blender/src/gpencil.c index f4274b853cc..eef21323a44 100644 --- a/source/blender/src/gpencil.c +++ b/source/blender/src/gpencil.c @@ -48,6 +48,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_userdef_types.h" +#include "DNA_vec_types.h" #include "DNA_view3d_types.h" #include "BKE_global.h" @@ -920,7 +921,6 @@ static short gp_stroke_addpoint (tGPsdata *p, short mval[2], float pressure) if (gpd->sbuffer_size >= GP_STROKE_BUFFER_MAX) return GP_STROKEADD_OVERFLOW; - /* get pointer to destination point */ pt= ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size); @@ -1012,8 +1012,76 @@ static short (*gp_stroke_eraser_2mco (bGPdata *gpd))[2] return mcoords; } -/* eraser tool evaluation per curve */ -static void gp_stroke_eraser_dostroke (tGPsdata *p, short mcoords[][2], short moves, bGPDframe *gpf, bGPDstroke *gps) +/* eraser tool - remove segment from stroke/split stroke (after lasso inside) */ +static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) +{ + bGPDspoint *pt_tmp= gps->points; + bGPDstroke *gsn = NULL; + + /* if stroke only had two points, get rid of stroke */ + if (gps->totpoints == 2) { + /* free stroke points, then stroke */ + MEM_freeN(pt_tmp); + BLI_freelinkN(&gpf->strokes, gps); + + /* nothing left in stroke, so stop */ + return 1; + } + + /* if last segment, just remove segment from the stroke */ + else if (i == gps->totpoints - 2) { + /* allocate new points array, and assign most of the old stroke there */ + gps->totpoints--; + gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*gps->totpoints); + + /* free temp buffer */ + MEM_freeN(pt_tmp); + + /* nothing left in stroke, so stop */ + return 1; + } + + /* if first segment, just remove segment from the stroke */ + else if (i == 0) { + /* allocate new points array, and assign most of the old stroke there */ + gps->totpoints--; + gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp + 1, sizeof(bGPDspoint)*gps->totpoints); + + /* free temp buffer */ + MEM_freeN(pt_tmp); + + /* no break here, as there might still be stuff to remove in this stroke */ + return 0; + } + + /* segment occurs in 'middle' of stroke, so split */ + else { + /* duplicate stroke, and assign 'later' data to that stroke */ + gsn= MEM_dupallocN(gps); + gsn->prev= gsn->next= NULL; + BLI_insertlinkafter(&gpf->strokes, gps, gsn); + + gsn->totpoints= gps->totpoints - i; + gsn->points= MEM_callocN(sizeof(bGPDspoint)*gsn->totpoints, "gp_stroke_points"); + memcpy(gsn->points, pt_tmp + i, sizeof(bGPDspoint)*gsn->totpoints); + + /* adjust existing stroke */ + gps->totpoints= i; + gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*i); + + /* free temp buffer */ + MEM_freeN(pt_tmp); + + /* nothing left in stroke, so stop */ + return 1; + } +} + +/* eraser tool - evaluation per stroke */ +static void gp_stroke_eraser_dostroke (tGPsdata *p, short mcoords[][2], short moves, rcti *rect, bGPDframe *gpf, bGPDstroke *gps) { bGPDspoint *pt1, *pt2; short x0=0, y0=0, x1=0, y1=0; @@ -1044,11 +1112,14 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, short mcoords[][2], short mo y0= (gps->points->y / 1000 * p->sa->winy); } - /* only check if point is inside */ - if (lasso_inside(mcoords, moves, x0, y0)) { - /* free stroke */ - MEM_freeN(gps->points); - BLI_freelinkN(&gpf->strokes, gps); + /* do boundbox check first */ + if (BLI_in_rcti(rect, x0, y0)) { + /* only check if point is inside */ + if (lasso_inside(mcoords, moves, x0, y0)) { + /* free stroke */ + MEM_freeN(gps->points); + BLI_freelinkN(&gpf->strokes, gps); + } } } else { @@ -1083,73 +1154,17 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, short mcoords[][2], short mo y1= (pt2->y / 1000 * p->sa->winy); } - /* check if point segment of stroke had anything to do with - * eraser region (either within stroke painted, or on its lines) - * - this assumes that linewidth is irrelevant - * - handled using the lasso-select checking code - */ - if (lasso_inside_edge(mcoords, moves, x0, y0, x1, x1)) { - bGPDspoint *pt_tmp= gps->points; - bGPDstroke *gsn = NULL; - - /* if stroke only had two points, get rid of stroke */ - if (gps->totpoints == 2) { - /* free stroke points, then stroke */ - MEM_freeN(pt_tmp); - BLI_freelinkN(&gpf->strokes, gps); - - /* nothing left in stroke, so stop */ - break; - } - - /* if last segment, just remove segment from the stroke */ - else if (i == gps->totpoints - 2) { - /* allocate new points array, and assign most of the old stroke there */ - gps->totpoints--; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*gps->totpoints); - - /* free temp buffer */ - MEM_freeN(pt_tmp); - - /* nothing left in stroke, so stop */ - break; - } - - /* if first segment, just remove segment from the stroke */ - else if (i == 0) { - /* allocate new points array, and assign most of the old stroke there */ - gps->totpoints--; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp + 1, sizeof(bGPDspoint)*gps->totpoints); - - /* free temp buffer */ - MEM_freeN(pt_tmp); - - /* no break here, as there might still be stuff to remove in this stroke */ - } - - /* segment occurs in 'middle' of stroke, so split */ - else { - /* duplicate stroke, and assign 'later' data to that stroke */ - gsn= MEM_dupallocN(gps); - gsn->prev= gsn->next= NULL; - BLI_insertlinkafter(&gpf->strokes, gps, gsn); - - gsn->totpoints= gps->totpoints - i; - gsn->points= MEM_callocN(sizeof(bGPDspoint)*gsn->totpoints, "gp_stroke_points"); - memcpy(gsn->points, pt_tmp + i, sizeof(bGPDspoint)*gsn->totpoints); - - /* adjust existing stroke */ - gps->totpoints= i; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*i); - - /* free temp buffer */ - MEM_freeN(pt_tmp); - - /* nothing left in stroke, so stop */ - break; + /* check that point segment of the boundbox of the eraser stroke */ + if (BLI_in_rcti(rect, x0, y0) || BLI_in_rcti(rect, x1, y1)) { + /* check if point segment of stroke had anything to do with + * eraser region (either within stroke painted, or on its lines) + * - this assumes that linewidth is irrelevant + * - handled using the lasso-select checking code + */ + if (lasso_inside_edge(mcoords, moves, x0, y0, x1, x1)) { + /* if function returns true, break this loop (as no more point to check) */ + if (gp_stroke_eraser_splitdel(gpf, gps, i)) + break; } } } @@ -1165,14 +1180,16 @@ static void gp_stroke_doeraser (tGPsdata *p) bGPDframe *gpf= p->gpf; bGPDstroke *gps, *gpn; short (*mcoords)[2]; + rcti rect; - /* get buffer-stroke coordinates as shorts array */ + /* get buffer-stroke coordinates as shorts array, and then get bounding box */ mcoords= gp_stroke_eraser_2mco(gpd); + lasso_select_boundbox(&rect, mcoords, gpd->sbuffer_size); /* loop over strokes, checking segments for intersections */ for (gps= gpf->strokes.first; gps; gps= gpn) { gpn= gps->next; - gp_stroke_eraser_dostroke(p, mcoords, gpd->sbuffer_size, gpf, gps); + gp_stroke_eraser_dostroke(p, mcoords, gpd->sbuffer_size, &rect, gpf, gps); } /* free mcoords array */ -- cgit v1.2.3 From 115dfb22ccd267f22b9980652acbf479c8b3ac5a Mon Sep 17 00:00:00 2001 From: Roland Hess Date: Fri, 1 Aug 2008 12:56:29 +0000 Subject: Ipo Editor would not allow access to either World or Lamp texture Ipos. Now it does. Fixes bug #17379. --- source/blender/src/editipo.c | 11 ++++++++++- source/blender/src/header_ipo.c | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c index c5dd41e16d5..63c301658f2 100644 --- a/source/blender/src/editipo.c +++ b/source/blender/src/editipo.c @@ -82,6 +82,7 @@ #include "BKE_group.h" #include "BKE_ipo.h" #include "BKE_key.h" +#include "BKE_main.h" #include "BKE_material.h" #include "BKE_particle.h" #include "BKE_texture.h" @@ -933,6 +934,9 @@ static void make_editipo(void) ob->ipowin= ID_TE; make_texture_editipo(G.sipo); } + else if(G.scene->world && give_current_world_texture()) { + make_texture_editipo(G.sipo); + } } else if(G.sipo->blocktype==ID_CA) { if (ob) { @@ -1120,6 +1124,11 @@ static void get_ipo_context(short blocktype, ID **from, Ipo **ipo, char *actname *from= (ID *)tex; if(tex) *ipo= tex->ipo; } + else if(G.scene->world) { + Tex *tex= give_current_world_texture(); + *from= (ID *)tex; + if(tex) *ipo= tex->ipo; + } } else if(blocktype==ID_MA) { if(ob) { @@ -6002,4 +6011,4 @@ void move_to_frame(void) } } BIF_undo_push("Set frame to selected Ipo vertex"); -} +} \ No newline at end of file diff --git a/source/blender/src/header_ipo.c b/source/blender/src/header_ipo.c index 15caf325ec6..59d542e72ec 100644 --- a/source/blender/src/header_ipo.c +++ b/source/blender/src/header_ipo.c @@ -970,7 +970,7 @@ static char *ipo_modeselect_pup(void) if(ob && ob->type==OB_LAMP) str += sprintf(str,formatstring, "Lamp",ID_LA, ICON_LAMP); - if(ob && give_current_texture(ob, ob->actcol)) + if((ob && give_current_texture(ob, ob->actcol))||(give_current_world_texture())) str += sprintf(str,formatstring, "Texture",ID_TE, ICON_TEXTURE); if(ob){ -- cgit v1.2.3 From fc52146342bf2116db92f9b3b4d718178946986d Mon Sep 17 00:00:00 2001 From: Mal Duffin Date: Fri, 1 Aug 2008 21:12:47 +0000 Subject: --- source/blender/src/header_info.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index dac7c7bc2c6..d972f4e6368 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -1078,9 +1078,9 @@ static uiBlock *info_filemenu(void *arg_unused) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Screenshot Subwindow|Ctrl F3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 24, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Screenshot All|Ctrl Shift F3", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 25, ""); #if GAMEBLENDER == 1 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Runtime...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 22, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Game As Runtime...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 22, ""); #ifdef _WIN32 - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Dynamic Runtime...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 23, ""); +// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Dynamic Runtime...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 23, ""); #endif #endif uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); -- cgit v1.2.3 From aa02e605f1eb4d34f6e7b62a0647d23f784de553 Mon Sep 17 00:00:00 2001 From: Mal Duffin Date: Fri, 1 Aug 2008 21:17:54 +0000 Subject: Fix for GE Make Runtime menu option Doh - I forgot to add a comment to the previous commit. This adds a file exists check for Make Dynamic Runtime for the GE. It also removes this menu option for now, as the required file ( blenderdynplayer.exe ) hasn't been included with the Blender app for quite a few releases ( therefore the feature has been broken ). I also renamed the option, to make it a bit more understandable. This might even be better moved to the Game menu, but I didn't want to do that ( yet :) ) --- source/blender/src/header_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/src') diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index d972f4e6368..c14e88770f9 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -1080,7 +1080,7 @@ static uiBlock *info_filemenu(void *arg_unused) #if GAMEBLENDER == 1 uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Game As Runtime...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 22, ""); #ifdef _WIN32 -// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Dynamic Runtime...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 23, ""); +// uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Save Dynamic Runtime...", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 23, ""); #endif #endif uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); -- cgit v1.2.3 From b11790e08fc61dfc9fce017bde7d7c1ec6cb5f98 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sat, 2 Aug 2008 06:11:35 +0000 Subject: * Minor tweaks to file menu item naming --- source/blender/src/header_info.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index c14e88770f9..6e264590082 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -1026,7 +1026,7 @@ static uiBlock *info_externalfiles(void *arg_unused) block= uiNewBlock(&curarea->uiblocks, "info_externalfiles", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin); uiBlockSetButmFunc(block, do_info_externalfiles, NULL); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pack into Blend", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pack into .blend file", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 1, ""); #if 0 uiDefBut(block, BUTM, 1, "Unpack Data to current dir", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 2, "Removes all packed files from the project and saves them to the current directory"); #endif @@ -1036,8 +1036,8 @@ static uiBlock *info_externalfiles(void *arg_unused) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Relative", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 10, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make all Paths Absolute", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 11, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Report Missing Files", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 12, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Missing Files", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 13, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Report Missing Files...", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 12, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Missing Files...", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 13, ""); uiBlockSetDirection(block, UI_RIGHT); uiTextBoundsBlock(block, 60); -- cgit v1.2.3 From 38aa350173f4e34f2cc2b32bd9c0c52bda31a987 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sat, 2 Aug 2008 06:29:15 +0000 Subject: * (slightly modified) old patch #7471 from Davide Vercelli - menu items for Show All Layers/Show Previous layers in the 3D View. Sorry this took so long! --- source/blender/src/header_view3d.c | 15 +++++++++++++-- source/blender/src/toolbox.c | 9 ++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 0b48db461e6..4a7772fd10b 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -166,9 +166,9 @@ void do_layer_buttons(short event) if(event==-1 && (G.qual & LR_CTRLKEY)) { G.vd->scenelock= !G.vd->scenelock; do_view3d_buttons(B_SCENELOCK); - } else if (event==-1) { + } else if (event<0) { if(G.vd->lay== (1<<20)-1) { - if(G.qual & LR_SHIFTKEY) G.vd->lay= oldlay; + if(event==-2 || G.qual & LR_SHIFTKEY) G.vd->lay= oldlay; } else { oldlay= G.vd->lay; @@ -605,6 +605,9 @@ static void do_view3d_viewmenu(void *arg, int event) case 21: /* Grease Pencil */ add_blockhandler(curarea, VIEW3D_HANDLER_GREASEPENCIL, UI_PNL_UNSTOW); break; + case 22: /* View all layers */ + do_layer_buttons(-2); + break; } allqueue(REDRAWVIEW3D, 1); } @@ -648,6 +651,11 @@ static uiBlock *view3d_viewmenu(void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + if(G.vd->lay== (1<<20)-1) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View Previous Layers|Shift ~", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 22, ""); + else uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show All Layers| ~", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 22, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + if(G.vd->localview) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Local View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); else uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_DEHLT, "Local View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 7, ""); if(!G.vd->localview) uiDefIconTextBut(block, BUTM, 1, ICON_CHECKBOX_HLT, "Global View|NumPad /", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, ""); @@ -726,6 +734,9 @@ void do_view3d_select_object_typemenu(void *arg, int event) case 10: /* Lamp */ selectall_type(OB_LAMP); break; + case 20: + do_layer_buttons(-2); + break; } allqueue(REDRAWVIEW3D, 0); } diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c index 94d38ee1635..8a8d7c8cec7 100644 --- a/source/blender/src/toolbox.c +++ b/source/blender/src/toolbox.c @@ -125,8 +125,6 @@ void asciitoraw(int ch, unsigned short *event, unsigned short *qual) { - if( isalpha(ch)==0 ) return; - if( isupper(ch) ) { *qual= LEFTSHIFTKEY; ch= tolower(ch); @@ -804,7 +802,10 @@ static void tb_do_hotkey(void *arg, int event) case 'd': key= PAGEDOWNKEY; break; } } - else asciitoraw(event, &key, &qual[3]); + else if (isalpha(event)) + asciitoraw(event, &key, &qual[3]); + else if (event == '~') + key = ACCENTGRAVEKEY; for (i=0;i<4;i++) { @@ -1213,6 +1214,8 @@ static TBitem tb_view[]= { { 0, "Ortho/Perspective|NumPad 5", TB_PAD|'5', NULL}, { 0, "Local/Global View|NumPad /", TB_PAD|'/', NULL}, { 0, "SEPR", 0, NULL}, +{ 0, "Show All Layers|Shift ~", TB_SHIFT|'~', NULL}, +{ 0, "SEPR", 0, NULL}, { 0, "Align View", 0, tb_view_alignview}, { 0, "SEPR", 0, NULL}, { 0, "View Selected|NumPad .", TB_PAD|'.', NULL}, -- cgit v1.2.3 From 82d87b2ab9d467ced67129c0fe602de2ca8c0b9c Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Sat, 2 Aug 2008 06:31:56 +0000 Subject: * patch #17394 by Vilem Novak - add menu item for 'Make Proxy Object'. Thanks! --- source/blender/src/header_view3d.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 4a7772fd10b..d834bd70321 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -651,7 +651,7 @@ static uiBlock *view3d_viewmenu(void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - if(G.vd->lay== (1<<20)-1) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "View Previous Layers|Shift ~", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 22, ""); + if(G.vd->lay== (1<<20)-1) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show Previous Layers|Shift ~", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 22, ""); else uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Show All Layers| ~", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 22, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); @@ -2478,8 +2478,11 @@ static void do_view3d_edit_objectmenu(void *arg, int event) case 15: /* Object Panel */ add_blockhandler(curarea, VIEW3D_HANDLER_OBJECT, UI_PNL_UNSTOW); break; + case 16: /* make proxy object*/ + make_proxy(); + break; #ifdef WITH_VERSE - case 16: /* Share Object at Verse server */ + case 17: /* Share Object at Verse server */ if(session_list.first != session_list.last) session = session_menu(); else session = session_list.first; if(session) b_verse_push_object(session, ob); @@ -2504,7 +2507,7 @@ static uiBlock *view3d_edit_objectmenu(void *arg_unused) if (base) ob= base->object; if(ob && (ob->type == OB_MESH) && (!ob->vnode)) { - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Share at Verse Server", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Share at Verse Server", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 17, ""); uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); } } @@ -2530,6 +2533,7 @@ static uiBlock *view3d_edit_objectmenu(void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Make Proxy|Ctrl Alt P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 16, ""); uiDefIconTextBlockBut(block, view3d_edit_object_makelinksmenu, NULL, ICON_RIGHTARROW_THIN, "Make Links", 0, yco-=20, 120, 19, ""); uiDefIconTextBlockBut(block, view3d_edit_object_singleusermenu, NULL, ICON_RIGHTARROW_THIN, "Make Single User", 0, yco-=20, 120, 19, ""); uiDefIconTextBlockBut(block, view3d_edit_object_makelocalmenu, NULL, ICON_RIGHTARROW_THIN, "Make Local", 0, yco-=20, 120, 19, ""); -- cgit v1.2.3 From 341655eab72d4e77da8b7de8c1108daf06809118 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Sat, 2 Aug 2008 09:44:01 +0000 Subject: == imagebrowser == - HKEY now toggles hide/show dotfiles --- source/blender/src/editimasel.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/src') diff --git a/source/blender/src/editimasel.c b/source/blender/src/editimasel.c index 67e10d771e0..97ddc2e0f1d 100644 --- a/source/blender/src/editimasel.c +++ b/source/blender/src/editimasel.c @@ -1076,6 +1076,12 @@ void winqreadimaselspace(ScrArea *sa, void *spacedata, BWinEvent *evt) toggle_blockhandler(sa, IMASEL_HANDLER_IMAGE, UI_PNL_UNSTOW); scrarea_queue_winredraw(sa); break; + case HKEY: + simasel->flag ^= FILE_HIDE_DOT; + BIF_filelist_free(simasel->files); + do_draw= 1; + do_headdraw= 1; + break; case PKEY: if(G.qual & LR_SHIFTKEY) { extern char bprogname[]; /* usiblender.c */ -- cgit v1.2.3 From 03f9c6a3fc5968a4bfeff159341d47bf3b24d766 Mon Sep 17 00:00:00 2001 From: Mal Duffin Date: Sat, 2 Aug 2008 17:08:16 +0000 Subject: Copies all required DLLS for Save Game as Runtime. Under Windows, all DLLs are copied to the same folder as the runtime .EXE, so that the process becomes a single click and deploy solution. Linux doesn't require this ( thx for info centralnoise ) and will update to work on OS/X after I do a bit of research on .a and .so files ( thx for info kaito ). --- source/blender/src/header_info.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'source/blender/src') diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index 6e264590082..4e43819cb71 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -540,6 +540,40 @@ static void check_packAll() } } +static void copy_game_dll(char *dll_filename, char *source_dir, char *dest_dir) +{ + char source_filename[FILE_MAX]; + char dest_filename[FILE_MAX]; + + strcpy( source_filename, source_dir ); + strcat( source_filename, dll_filename ); + + strcpy( dest_filename, dest_dir ); + strcat( dest_filename, dll_filename ); + + if(!BLI_exists(dest_filename)) { + BLI_copy_fileops( source_filename, dest_filename ); + } +} + +static void copy_all_game_dlls(char *str) +{ +#define GAME_DLL_COUNT 7 + char *game_dll_list[GAME_DLL_COUNT]={"gnu_gettext.dll", "libpng.dll", "libtiff.dll", "pthreadVC2.dll", "python25.dll", "SDL.dll", "zlib.dll"}; + + char dest_dir[FILE_MAX]; + char source_dir[FILE_MAX]; + int i; + + strcpy(source_dir, get_install_dir()); + strcat(source_dir, "\\"); + BLI_split_dirfile_basic(str, dest_dir, NULL); + + for (i= 0; i< GAME_DLL_COUNT; i++) { + copy_game_dll(game_dll_list[i], source_dir, dest_dir ); + }; +} + static int write_runtime(char *str, char *exename) { char *freestr= NULL; @@ -587,7 +621,14 @@ static void write_runtime_check(char *str) #endif write_runtime(str, player); + +#ifdef _WIN32 + // get a list of the .DLLs in the Blender folder and copy all of these to the destination folder if they don't exist + copy_all_game_dlls(str); +#endif } + + /* end keyed functions */ /************************** MAIN MENU *****************************/ -- cgit v1.2.3 From 27b259345e4a23abef42b603f01dc77082791f9a Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 3 Aug 2008 11:55:45 +0000 Subject: Grease Pencil Drawing: Some WIP code for 'nicer' drawing of thick 2d-strokes that will hopefully result in smoother lines, particularly with abrupt direction changes. Currently the code is hidden behind the rt button (for rt != 0), as in some cases, it still looks rather bad. --- source/blender/src/drawgpencil.c | 308 ++++++++++++++++++++++++++++----------- 1 file changed, 223 insertions(+), 85 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/drawgpencil.c b/source/blender/src/drawgpencil.c index 733310bfda7..ee28049e2c0 100644 --- a/source/blender/src/drawgpencil.c +++ b/source/blender/src/drawgpencil.c @@ -310,6 +310,8 @@ short draw_gpencil_panel (uiBlock *block, bGPdata *gpd, ScrArea *sa) /* ************************************************** */ /* GREASE PENCIL DRAWING */ +/* ----- General Defines ------ */ + /* flags for sflag */ enum { GP_DRAWDATA_NOSTATUS = (1<<0), /* don't draw status info */ @@ -317,7 +319,9 @@ enum { GP_DRAWDATA_ONLYV2D = (1<<2), /* only draw 'canvas' strokes */ }; -/* draw stroke in buffer */ +/* ----- Tool Buffer Drawing ------ */ + +/* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thickness, short dflag, short sflag) { tGPspoint *pt; @@ -377,115 +381,232 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick } } -/* draw a given stroke */ -static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness, short dflag, short sflag, short debug, int winx, int winy) +/* ----- Existing Strokes Drawing (3D and Point) ------ */ + +/* draw a given stroke - just a single dot (only one point) */ +static void gp_draw_stroke_point (bGPDspoint *points, short sflag, int winx, int winy) +{ + /* draw point */ + if (sflag & GP_STROKE_3DSPACE) { + glBegin(GL_POINTS); + glVertex3f(points->x, points->y, points->z); + glEnd(); + } + else if (sflag & GP_STROKE_2DSPACE) { + glBegin(GL_POINTS); + glVertex2f(points->x, points->y); + glEnd(); + } + else { + const float x= (points->x / 1000 * winx); + const float y= (points->y / 1000 * winy); + + glBegin(GL_POINTS); + glVertex2f(x, y); + glEnd(); + } +} + +/* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */ +static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thickness, short dflag, short sflag, short debug, int winx, int winy) { bGPDspoint *pt; + float oldpressure = 0.0f; int i; - /* error checking */ - if ((points == NULL) || (totpoints <= 0)) - return; - - /* check if stroke can be drawn */ - if ((dflag & GP_DRAWDATA_ONLY3D) && !(sflag & GP_STROKE_3DSPACE)) - return; - if (!(dflag & GP_DRAWDATA_ONLY3D) && (sflag & GP_STROKE_3DSPACE)) - return; - if ((dflag & GP_DRAWDATA_ONLYV2D) && !(sflag & GP_STROKE_2DSPACE)) - return; - if (!(dflag & GP_DRAWDATA_ONLYV2D) && (sflag & GP_STROKE_2DSPACE)) - return; - - /* if drawing a single point, draw it larger */ - if (totpoints == 1) { - /* draw point */ - if (sflag & GP_STROKE_3DSPACE) { - glBegin(GL_POINTS); - glVertex3f(points->x, points->y, points->z); + /* draw stroke curve */ + glBegin(GL_LINE_STRIP); + for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + if (fabs(pt->pressure - oldpressure) > 0.2f) { glEnd(); - } - else if (sflag & GP_STROKE_2DSPACE) { - glBegin(GL_POINTS); - glVertex2f(points->x, points->y); - glEnd(); - } - else { - const float x= (points->x / 1000 * winx); - const float y= (points->y / 1000 * winy); + glLineWidth(pt->pressure * thickness); + glBegin(GL_LINE_STRIP); - glBegin(GL_POINTS); - glVertex2f(x, y); - glEnd(); + glVertex3f(pt->x, pt->y, pt->z); + + oldpressure = pt->pressure; } + else + glVertex3f(pt->x, pt->y, pt->z); } - else { - float oldpressure = 0.0f; + glEnd(); + + /* draw debug points of curve on top? */ + if (debug) { + glBegin(GL_POINTS); + for (i=0, pt=points; i < totpoints && pt; i++, pt++) + glVertex3f(pt->x, pt->y, pt->z); + glEnd(); + } +} + +/* ----- Fancy 2D-Stroke Drawing ------ */ + +/* draw a given stroke in 2d */ +static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness, short dflag, short sflag, short debug, int winx, int winy) +{ + /* if thickness is less than 3, 'smooth' opengl lines look better */ + if ((thickness < 3) || (G.rt==0)) { + bGPDspoint *pt; + int i; - /* draw stroke curve */ glBegin(GL_LINE_STRIP); for (i=0, pt=points; i < totpoints && pt; i++, pt++) { - float x, y, z; - - if (sflag & GP_STROKE_3DSPACE) { - x= pt->x; - y= pt->y; - z= pt->z; + if (sflag & GP_STROKE_2DSPACE) { + glVertex2f(pt->x, pt->y); + } + else { + const float x= (pt->x / 1000 * winx); + const float y= (pt->y / 1000 * winy); + + glVertex2f(x, y); } - else if (sflag & GP_STROKE_2DSPACE) { - x= pt->x; - y= pt->y; - z= 0; + } + glEnd(); + } + else { /* tesselation code: currently only enabled with rt != 0 */ + bGPDspoint *pt1, *pt2; + float p0[2], p1[2], pm[2]; + int i; + + glShadeModel(GL_FLAT); + glBegin(GL_QUAD_STRIP); + + for (i=0, pt1=points, pt2=points+1; i < (totpoints-1); i++, pt1++, pt2++) { + float s0[2], s1[2]; /* segment 'center' points */ + float t0[2], t1[2]; /* tesselated coordinates */ + float m1[2], m2[2]; /* gradient and normal */ + float pthick, dist; /* thickness at segment point, and length of segment */ + float sminorang; /* minor angle between strokes */ + + /* get x and y coordinates from points */ + if (sflag & GP_STROKE_2DSPACE) { + s0[0]= pt1->x; s0[1]= pt1->y; + s1[0]= pt2->x; s1[1]= pt2->y; } else { - x= (pt->x / 1000 * winx); - y= (pt->y / 1000 * winy); - z= 0; + s0[0]= (pt1->x / 1000 * winx); + s0[1]= (pt1->y / 1000 * winy); + s1[0]= (pt2->x / 1000 * winx); + s1[1]= (pt2->y / 1000 * winy); + } + + /* calculate gradient and normal - 'angle'=(ny/nx) */ + m1[1]= s1[1] - s0[1]; + m1[0]= s1[0] - s0[0]; + dist = Vec2Lenf(s0, s1); + m2[1]= -(m1[0]) / dist; + m2[0]= m1[1] / dist; + + /* if the first segment, initialise the first segment using segment's normal */ + if (i == 0) { + pthick= (pt1->pressure * thickness); + + // TODO: also draw/do a round end-cap first + + p0[0]= s0[0] - (pthick * m2[0]); + p0[1]= s0[1] - (pthick * m2[1]); + p1[0]= s1[0] + (pthick * m2[0]); + p1[1]= s1[1] + (pthick * m2[1]); + + Vec2Copyf(pm, m1); } - if (fabs(pt->pressure - oldpressure) > 0.2f) { - glEnd(); - glLineWidth(pt->pressure * thickness); - glBegin(GL_LINE_STRIP); + /* if the minor angle between the current segment and the previous one is less than 90 degrees */ + if (i) + sminorang= NormalizedVecAngle2_2D(pm, m1); + else + sminorang= 0.0f; + + if ((IS_EQ(sminorang, 0)==0) && (abs(sminorang) < M_PI_2) ) + { + float closep[2]; - if (sflag & GP_STROKE_3DSPACE) - glVertex3f(x, y, z); + /* recalculate startpoint of segment, where the new start-line: + * - starts a new gl-quad-strip + * - uses the vert of old startpoint closer to our endpoint + * - distance between new startpoints = distance between old startpoints + * - new startpoints occur on same gradient as old segment does (has potential for some 'minor' overlap, but ok) + */ + + /* find the closer vertex, and distance between startpoints */ + if (Vec2Lenf(p0, s1) > Vec2Lenf(p1, s1)) + Vec2Copyf(closep, p1); else - glVertex2f(x, y); + Vec2Copyf(closep, p0); + + /* determine which side this closer vertex should be on */ + pthick= (pt1->pressure * thickness * 2); + if ( ((closep[0] - s0[0]) > 0) || ((closep[1] - s0[1]) > 0) ) { + /* assumes this is the 'second' point, (i.e. the 'plus' one), so the other is subtracting */ + p0[0]= closep[0] - (pthick * pm[0]); + p0[1]= closep[1] - (pthick * pm[1]); + p1[0]= closep[0]; + p1[1]= closep[1]; + } + else if ( ((closep[0] - s0[0]) < 0) || ((closep[1] - s0[1]) < 0) ) { + /* assumes this is the 'first' point, (i.e. the 'minus' one), so the other is adding */ + p0[0]= closep[0]; + p0[1]= closep[1]; + p1[0]= closep[0] + (pthick * pm[0]); + p1[1]= closep[1] + (pthick * pm[1]); + } - oldpressure = pt->pressure; + /* reset gl-states! */ + glEnd(); + glBegin(GL_QUAD_STRIP); } - else { - if (sflag & GP_STROKE_3DSPACE) - glVertex3f(x, y, z); - else - glVertex2f(x, y); + + /* do the end of this segment */ + pthick= (pt2->pressure * thickness); + t0[0] = s1[0] - (pthick * m2[0]); + t0[1] = s1[1] - (pthick * m2[1]); + t1[0] = s1[0] + (pthick * m2[0]); + t1[1] = s1[1] + (pthick * m2[1]); + + /* draw this segment */ + glVertex2f(p0[0], p0[1]); + glVertex2f(p1[0], p1[1]); + glVertex2f(t0[0], t0[1]); + glVertex2f(t1[0], t1[1]); + + // TODO: draw end cap if last segment + if (i == totpoints-2) { + } + + /* store current points for next segment to use */ + Vec2Copyf(p0, t0); + Vec2Copyf(p1, t1); + Vec2Copyf(pm, m1); } + glEnd(); + } + + /* draw debug points of curve on top? (original stroke points) */ + if (debug) { + bGPDspoint *pt; + int i; - /* draw debug points of curve on top? */ - if (debug) { - glBegin(GL_POINTS); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { - if (sflag & GP_STROKE_3DSPACE) { - glVertex3f(pt->x, pt->y, pt->z); - } - else if (sflag & GP_STROKE_2DSPACE) { - glVertex2f(pt->x, pt->y); - } - else { - const float x= (pt->x / 1000 * winx); - const float y= (pt->y / 1000 * winy); - - glVertex2f(x, y); - } + glBegin(GL_POINTS); + for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + if (sflag & GP_STROKE_2DSPACE) { + glVertex2f(pt->x, pt->y); + } + else { + const float x= (pt->x / 1000 * winx); + const float y= (pt->y / 1000 * winy); + + glVertex2f(x, y); } - glEnd(); } + glEnd(); } } +/* ----- General Drawing ------ */ + /* draw a set of strokes */ static void gp_draw_strokes (bGPDframe *gpf, int winx, int winy, int dflag, short debug, short lthick, float color[4]) @@ -495,9 +616,26 @@ static void gp_draw_strokes (bGPDframe *gpf, int winx, int winy, int dflag, shor /* set color first (may need to reset it again later too) */ glColor4f(color[0], color[1], color[2], color[3]); - for (gps= gpf->strokes.first; gps; gps= gps->next) { - /* just draw the stroke once */ - gp_draw_stroke(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, winx, winy); + for (gps= gpf->strokes.first; gps; gps= gps->next) { + /* check if stroke can be drawn */ + if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE)) + continue; + if (!(dflag & GP_DRAWDATA_ONLY3D) && (gps->flag & GP_STROKE_3DSPACE)) + continue; + if ((dflag & GP_DRAWDATA_ONLYV2D) && !(gps->flag & GP_STROKE_2DSPACE)) + continue; + if (!(dflag & GP_DRAWDATA_ONLYV2D) && (gps->flag & GP_STROKE_2DSPACE)) + continue; + if ((gps->points == 0) || (gps->totpoints < 1)) + continue; + + /* check which stroke-drawer to use */ + if (gps->totpoints == 1) + gp_draw_stroke_point(gps->points, gps->flag, winx, winy); + else if (dflag & GP_DRAWDATA_ONLY3D) + gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, winx, winy); + else if (gps->totpoints > 1) + gp_draw_stroke(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, winx, winy); } } @@ -656,7 +794,7 @@ static void gp_draw_data (bGPdata *gpd, int winx, int winy, int dflag) glColor4f(0, 0, 0, 1); } -/* ----------- */ +/* ----- Grease Pencil Sketches Drawing API ------ */ /* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly * Note: this gets called twice - first time with onlyv2d=1 to draw 'canvas' strokes, second time with onlyv2d=0 for screen-aligned strokes -- cgit v1.2.3 From cad3b73144c2ee82feb9659c130664baf9a1aa4d Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 3 Aug 2008 15:35:56 +0000 Subject: == Sequencer == This fixes: [#17413] Sequencer: Blender crashes pressing R on a color strip --- source/blender/src/editseq.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/src') diff --git a/source/blender/src/editseq.c b/source/blender/src/editseq.c index 12019a9dab9..e9d0b57a166 100644 --- a/source/blender/src/editseq.c +++ b/source/blender/src/editseq.c @@ -644,6 +644,7 @@ static int seq_is_parent(Sequence *par, Sequence *seq) static int seq_is_predecessor(Sequence *pred, Sequence *seq) { + if (!pred) return 0; if(pred == seq) return 0; else if(seq_is_parent(pred, seq)) return 1; else if(pred->seq1 && seq_is_predecessor(pred->seq1, seq)) return 1; -- cgit v1.2.3 From 7fc6741bcf631c14a0009b051c248e9750fb9987 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 3 Aug 2008 15:45:53 +0000 Subject: == Sequencer == This fixes: [#17405] Sequencer: unselected black strips are unreadable using [#17418] Fix for bug #17405: unselected black seq strips text unreadable Thanks to Roelf De Kock for providing the patch and mindrones for the bug report :) --- source/blender/src/drawseq.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/drawseq.c b/source/blender/src/drawseq.c index cc431c73a2e..71a777c9056 100644 --- a/source/blender/src/drawseq.c +++ b/source/blender/src/drawseq.c @@ -98,7 +98,7 @@ int no_rightbox=0, no_leftbox= 0; static void draw_seq_handle(Sequence *seq, SpaceSeq *sseq, float pixelx, short direction); static void draw_seq_extensions(Sequence *seq, SpaceSeq *sseq); -static void draw_seq_text(Sequence *seq, float x1, float x2, float y1, float y2); +static void draw_seq_text(Sequence *seq, float x1, float x2, float y1, float y2, char *background_col); static void draw_shadedstrip(Sequence *seq, char *col, float x1, float y1, float x2, float y2); static void draw_seq_strip(struct Sequence *seq, struct ScrArea *sa, struct SpaceSeq *sseq, int outline_tint, float pixelx); @@ -604,7 +604,7 @@ static void draw_seq_extensions(Sequence *seq, SpaceSeq *sseq) } /* draw info text on a sequence strip */ -static void draw_seq_text(Sequence *seq, float x1, float x2, float y1, float y2) +static void draw_seq_text(Sequence *seq, float x1, float x2, float y1, float y2, char *background_col) { float v1[2], v2[2]; int len, size; @@ -670,8 +670,13 @@ static void draw_seq_text(Sequence *seq, float x1, float x2, float y1, float y2) mval[1]= 1; areamouseco_to_ipoco(G.v2d, mval, &x1, &x2); - if(seq->flag & SELECT) cpack(0xFFFFFF); - else cpack(0); + if(seq->flag & SELECT){ + cpack(0xFFFFFF); + }else if ((((int)background_col[0] + (int)background_col[1] + (int)background_col[2]) / 3) < 50){ + cpack(0x505050); /* use lighter text colour for dark background */ + }else{ + cpack(0); + } glRasterPos3f(x1, y1+SEQ_STRIP_OFSBOTTOM, 0.0); BMF_DrawString(G.font, strp); } @@ -740,7 +745,7 @@ so wave file sample drawing precission is zoom adjusted static void draw_seq_strip(Sequence *seq, ScrArea *sa, SpaceSeq *sseq, int outline_tint, float pixelx) { float x1, x2, y1, y2; - char col[3], is_single_image; + char col[3], background_col[3], is_single_image; /* we need to know if this is a single image/color or not for drawing */ is_single_image = (char)check_single_seq(seq); @@ -755,13 +760,14 @@ static void draw_seq_strip(Sequence *seq, ScrArea *sa, SpaceSeq *sseq, int outli /* get the correct color per strip type*/ - get_seq_color3ubv(seq, col); + //get_seq_color3ubv(seq, col); + get_seq_color3ubv(seq, background_col); /* draw the main strip body */ if (is_single_image) /* single image */ - draw_shadedstrip(seq, col, seq_tx_get_final_left(seq, 0), y1, seq_tx_get_final_right(seq, 0), y2); + draw_shadedstrip(seq, background_col, seq_tx_get_final_left(seq, 0), y1, seq_tx_get_final_right(seq, 0), y2); else /* normal operation */ - draw_shadedstrip(seq, col, x1, y1, x2, y2); + draw_shadedstrip(seq, background_col, x1, y1, x2, y2); /* draw additional info and controls */ if (seq->type == SEQ_RAM_SOUND) @@ -814,7 +820,7 @@ static void draw_seq_strip(Sequence *seq, ScrArea *sa, SpaceSeq *sseq, int outli /* nice text here would require changing the view matrix for texture text */ if( (x2-x1) / pixelx > 32) { - draw_seq_text(seq, x1, x2, y1, y2); + draw_seq_text(seq, x1, x2, y1, y2, background_col); } } -- cgit v1.2.3 From 855fa737d70d4b01ef129a27ffc7d89b65dbc590 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 3 Aug 2008 15:56:35 +0000 Subject: == Sequencer == Fixes: [#15082] Sequencer: for image strips, the Input file field disappears if the cursor is out of the selected strip also it wasn't really a bug, since the file name of image input strips _has_ to depend on CFRA. Well, we choose the next possible image strip, which is most likely the thing, most people expected... --- source/blender/src/buttons_scene.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source/blender/src') diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index 3b0167d673c..fb6a7636e16 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -763,7 +763,16 @@ static void seq_panel_input() } if (last_seq->type == SEQ_IMAGE) { - StripElem * se = give_stripelem(last_seq, CFRA); + int cfra = CFRA; + StripElem * se; + + if(last_seq->startdisp >cfra) { + cfra = last_seq->startdisp; + } else if (last_seq->enddisp <= cfra) { + cfra = last_seq->enddisp - 1; + } + + se = give_stripelem(last_seq, cfra); if (se) { uiDefBut(block, TEX, -- cgit v1.2.3 From 3598dcd2796f819bd762f88c2d275816fed0e0d6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Aug 2008 01:57:22 +0000 Subject: * KX_GameObject.cpp - error with getMesh(), was returning None rather then an error with invalid args. also memory leak with getVectTo() if invalid args were given. * Material.c - functions for get/setRayTransGlossSamples were not being used. * BPY_interface.c - removed function GetName(), since everything else just uses id->name+2. * header_info.c - added ifdef win32 around copy_game_dll since its not needed for other os's yet --- source/blender/src/header_info.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/src') diff --git a/source/blender/src/header_info.c b/source/blender/src/header_info.c index 4e43819cb71..a9280d9dd19 100644 --- a/source/blender/src/header_info.c +++ b/source/blender/src/header_info.c @@ -540,6 +540,7 @@ static void check_packAll() } } +#ifdef _WIN32 static void copy_game_dll(char *dll_filename, char *source_dir, char *dest_dir) { char source_filename[FILE_MAX]; @@ -573,6 +574,7 @@ static void copy_all_game_dlls(char *str) copy_game_dll(game_dll_list[i], source_dir, dest_dir ); }; } +#endif static int write_runtime(char *str, char *exename) { -- cgit v1.2.3 From 2e6a3710bba93cf2d6b86cf511a123068ead61bd Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 4 Aug 2008 11:47:17 +0000 Subject: * Armature hierarchy selection tools These are for use in pose mode or armature edit mode, to let you quickly traverse up and down a chain of bones. It's quite useful for bones that are in hard-to-click places. The tools are: *Select parent/child ( [ and ] ) selects the parent or child of the active bone, deselecting the original active bone * Extend select parent/child (shift [ and shift ] ) selects the parent or child of the active bone, adding to the selection Thanks to Joshua for reviewing this so promptly! PS. I'd like to use these [ and ] keys more widely in blender as consistent 'select next / previous' tools. I can imagine it being very useful for a lot of things like keyframes, nodes, mesh edges, etc. --- source/blender/src/editarmature.c | 164 +++++++++++++++++++------------------ source/blender/src/header_view3d.c | 58 ++++++++++--- source/blender/src/poseobject.c | 61 ++++++++++++++ source/blender/src/space.c | 17 +++- 4 files changed, 205 insertions(+), 95 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 3d0f26960d6..80c24f3a989 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -1033,87 +1033,6 @@ static void *get_nearest_bone (short findunsel) return NULL; } -/* used by posemode and editmode */ -void select_bone_parent (void) -{ - Object *ob; - bArmature *arm; - - /* get data */ - if (G.obedit) - ob= G.obedit; - else if (OBACT) - ob= OBACT; - else - return; - arm= (bArmature *)ob->data; - - /* determine which mode armature is in */ - if ((!G.obedit) && (ob->flag & OB_POSEMODE)) { - /* deal with pose channels */ - /* channels are sorted on dependency, so the loop below won't result in a flood-select */ - bPoseChannel *pchan=NULL; - - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - /* check if bone in original selection */ - if (pchan->bone->flag & BONE_SELECTED) { - bPoseChannel *chanpar= pchan->parent; - - /* check if any parent */ - if ((chanpar) && ((chanpar->bone->flag & BONE_SELECTED)==0)) { - chanpar->bone->flag |= BONE_SELECTED; - select_actionchannel_by_name (ob->action, pchan->name, 1); - } - } - } - } - else if (G.obedit) { - /* deal with editbones */ - EditBone *curbone, *parbone, *parpar; - - /* prevent floods */ - for (curbone= G.edbo.first; curbone; curbone= curbone->next) - curbone->temp= NULL; - - for (curbone= G.edbo.first; curbone; curbone= curbone->next) { - /* check if bone selected */ - if ((curbone->flag & BONE_SELECTED) && curbone->temp==NULL) { - parbone= curbone->parent; - - /* check if any parent */ - if ((parbone) && ((parbone->flag & BONE_SELECTED)==0)) { - /* select the parent bone */ - parbone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - - /* check if parent has parent */ - parpar= parbone->parent; - - if ((parpar) && (parbone->flag & BONE_CONNECTED)) { - parpar->flag |= BONE_TIPSEL; - } - /* tag this bone to not flood selection */ - parbone->temp= parbone; - } - } - } - - /* to be sure... */ - for (curbone= G.edbo.first; curbone; curbone= curbone->next) - curbone->temp= NULL; - - } - - /* undo + redraw pushes */ - countall(); // flushes selection! - - allqueue (REDRAWVIEW3D, 0); - allqueue (REDRAWBUTSEDIT, 0); - allqueue(REDRAWBUTSOBJECT, 0); - allqueue(REDRAWOOPS, 0); - - BIF_undo_push("Select Parent"); -} - /* helper for setflag_sel_bone() */ static void bone_setflag (int *bone, int flag, short mode) { @@ -1139,6 +1058,89 @@ static void bone_setflag (int *bone, int flag, short mode) } } +/* Get the first available child of an editbone */ +static EditBone *editbone_get_child(EditBone *pabone, short use_visibility) +{ + Object *ob; + bArmature *arm; + EditBone *curbone, *chbone=NULL; + + if (!G.obedit) return NULL; + else ob= G.obedit; + arm= (bArmature *)ob->data; + + for (curbone= G.edbo.first; curbone; curbone= curbone->next) { + if (curbone->parent == pabone) { + if (use_visibility) { + if ((arm->layer & curbone->layer) && !(pabone->flag & BONE_HIDDEN_A)) + chbone = curbone; + } + else + chbone = curbone; + } + } + + return chbone; +} + +void armature_select_hierarchy(short direction, short add_to_sel) +{ + Object *ob; + bArmature *arm; + EditBone *curbone, *pabone, *chbone; + + if (!G.obedit) return; + else ob= G.obedit; + arm= (bArmature *)ob->data; + + for (curbone= G.edbo.first; curbone; curbone= curbone->next) { + if (arm->layer & curbone->layer) { + if (curbone->flag & (BONE_ACTIVE)) { + if (direction == BONE_SELECT_PARENT) { + if (curbone->parent == NULL) continue; + else pabone = curbone->parent; + + if ((arm->layer & pabone->layer) && !(pabone->flag & BONE_HIDDEN_A)) { + pabone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL; + + if (!add_to_sel) curbone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + curbone->flag &= ~BONE_ACTIVE; + break; + } + + } else { // BONE_SELECT_CHILD + chbone = editbone_get_child(curbone, 1); + if (chbone == NULL) continue; + + if ((arm->layer & chbone->layer) && !(chbone->flag & BONE_HIDDEN_A)) { + chbone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + + if (!add_to_sel) { + curbone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL); + if (curbone->parent) curbone->parent->flag &= ~BONE_TIPSEL; + } + curbone->flag &= ~BONE_ACTIVE; + break; + } + } + } + } + } + + countall(); // flushes selection! + + allqueue (REDRAWVIEW3D, 0); + allqueue (REDRAWBUTSEDIT, 0); + allqueue (REDRAWBUTSOBJECT, 0); + allqueue (REDRAWOOPS, 0); + + if (direction==BONE_SELECT_PARENT) + BIF_undo_push("Select edit bone parent"); + if (direction==BONE_SELECT_CHILD) + BIF_undo_push("Select edit bone child"); +} + /* used by posemode and editmode */ void setflag_armature (short mode) { diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index d834bd70321..948023bebfb 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -1325,12 +1325,21 @@ static void do_view3d_select_armaturemenu(void *arg, int event) case 2: /* Select/Deselect all */ deselectall_armature(1, 1); break; - case 3: /* Select Parent(s) */ - select_bone_parent(); - break; - case 4: /* Swap Select All */ + case 3: /* Swap Select All */ deselectall_armature(3, 1); break; + case 4: /* Select parent */ + armature_select_hierarchy(BONE_SELECT_PARENT, 0); + break; + case 5: /* Select child */ + armature_select_hierarchy(BONE_SELECT_CHILD, 0); + break; + case 6: /* Extend Select parent */ + armature_select_hierarchy(BONE_SELECT_PARENT, 1); + break; + case 7: /* Extend Select child */ + armature_select_hierarchy(BONE_SELECT_CHILD, 1); + break; } allqueue(REDRAWVIEW3D, 0); } @@ -1348,11 +1357,18 @@ static uiBlock *view3d_select_armaturemenu(void *arg_unused) uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Inverse|Ctrl I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Swap Select All|Ctrl I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Parent|[", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Child|]", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Select Parent|Shift [", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Select Child|Shift ]", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Parent(s)|P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); } @@ -1379,12 +1395,21 @@ static void do_view3d_select_pose_armaturemenu(void *arg, int event) case 3: /* Select Target(s) of Constraint(s) */ pose_select_constraint_target(); break; - case 4: /* Select Bone's Parent */ - select_bone_parent(); - break; case 5: /* Swap Select All */ deselectall_posearmature(OBACT, 3, 1); break; + case 6: /* Select parent */ + pose_select_hierarchy(BONE_SELECT_PARENT, 0); + break; + case 7: /* Select child */ + pose_select_hierarchy(BONE_SELECT_CHILD, 0); + break; + case 8: /* Extend Select parent */ + pose_select_hierarchy(BONE_SELECT_PARENT, 1); + break; + case 9: /* Extend Select child */ + pose_select_hierarchy(BONE_SELECT_CHILD, 1); + break; } allqueue(REDRAWVIEW3D, 0); } @@ -1404,8 +1429,17 @@ static uiBlock *view3d_select_pose_armaturemenu(void *arg_unused) uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select/Deselect All|A", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 2, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Swap Select All|Ctrl I", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 5, ""); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Constraint Target|W", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 3, ""); - uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Parent(s)|P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 4, ""); - + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Parent|[", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 6, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Select Child|]", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 7, ""); + + uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, ""); + + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Select Parent|Shift [", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 8, ""); + uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Extend Select Child|Shift ]", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, 9, ""); + if(curarea->headertype==HEADERTOP) { uiBlockSetDirection(block, UI_DOWN); } diff --git a/source/blender/src/poseobject.c b/source/blender/src/poseobject.c index b054b435002..28b8729a247 100644 --- a/source/blender/src/poseobject.c +++ b/source/blender/src/poseobject.c @@ -479,6 +479,67 @@ void pose_select_constraint_target(void) } +void pose_select_hierarchy(short direction, short add_to_sel) +{ + Object *ob= OBACT; + bArmature *arm= ob->data; + bPoseChannel *pchan; + Bone *curbone, *pabone, *chbone; + + /* paranoia checks */ + if (!ob && !ob->pose) return; + if (ob==G.obedit || (ob->flag & OB_POSEMODE)==0) return; + + for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + curbone= pchan->bone; + + if (arm->layer & curbone->layer) { + if (curbone->flag & (BONE_ACTIVE)) { + if (direction == BONE_SELECT_PARENT) { + + if (pchan->parent == NULL) continue; + else pabone= pchan->parent->bone; + + if ((arm->layer & pabone->layer) && !(pabone->flag & BONE_HIDDEN_P)) { + + if (!add_to_sel) curbone->flag &= ~BONE_SELECTED; + curbone->flag &= ~BONE_ACTIVE; + pabone->flag |= (BONE_ACTIVE|BONE_SELECTED); + + select_actionchannel_by_name (ob->action, pchan->name, 0); + select_actionchannel_by_name (ob->action, pchan->parent->name, 1); + break; + } + } else { // BONE_SELECT_CHILD + + if (pchan->child == NULL) continue; + else chbone = pchan->child->bone; + + if ((arm->layer & chbone->layer) && !(chbone->flag & BONE_HIDDEN_P)) { + + if (!add_to_sel) curbone->flag &= ~BONE_SELECTED; + curbone->flag &= ~BONE_ACTIVE; + chbone->flag |= (BONE_ACTIVE|BONE_SELECTED); + + select_actionchannel_by_name (ob->action, pchan->name, 0); + select_actionchannel_by_name (ob->action, pchan->child->name, 1); + break; + } + } + } + } + } + + allqueue (REDRAWVIEW3D, 0); + allqueue (REDRAWBUTSOBJECT, 0); + allqueue (REDRAWOOPS, 0); + + if (direction==BONE_SELECT_PARENT) + BIF_undo_push("Select pose bone parent"); + if (direction==BONE_SELECT_CHILD) + BIF_undo_push("Select pose bone child"); +} + /* context: active channel */ void pose_special_editmenu(void) { diff --git a/source/blender/src/space.c b/source/blender/src/space.c index b4702788e0c..8d86336e12e 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -2428,7 +2428,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) else if(G.qual==LR_ALTKEY && G.obedit->type==OB_ARMATURE) clear_bone_parent(); else if((G.qual==0) && (G.obedit->type==OB_ARMATURE)) - select_bone_parent(); + armature_select_hierarchy(BONE_SELECT_PARENT, 1); // 1 = add to selection else if((G.qual==(LR_CTRLKEY|LR_ALTKEY)) && (G.obedit->type==OB_ARMATURE)) separate_armature(); else if((G.qual==0) && G.obedit->type==OB_MESH) @@ -2458,7 +2458,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) start_RBSimulation(); } else if((G.qual==0) && (OBACT) && (OBACT->type==OB_ARMATURE) && (OBACT->flag & OB_POSEMODE)) - select_bone_parent(); + pose_select_hierarchy(BONE_SELECT_PARENT, 1); // 1 = add to selection else if((G.qual==0)) { start_game(); } @@ -2761,6 +2761,19 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) scrarea_queue_winredraw(curarea); break; + case LEFTBRACKETKEY: + if ((G.obedit) && (G.obedit->type == OB_ARMATURE)) + armature_select_hierarchy(BONE_SELECT_PARENT, (G.qual == LR_SHIFTKEY)); + else if ((ob) && (ob->flag & OB_POSEMODE)) + pose_select_hierarchy(BONE_SELECT_PARENT, (G.qual == LR_SHIFTKEY)); + break; + case RIGHTBRACKETKEY: + if ((G.obedit) && (G.obedit->type == OB_ARMATURE)) + armature_select_hierarchy(BONE_SELECT_CHILD, (G.qual == LR_SHIFTKEY)); + if ((ob) && (ob->flag & OB_POSEMODE)) + pose_select_hierarchy(BONE_SELECT_CHILD, (G.qual == LR_SHIFTKEY)); + break; + case PADSLASHKEY: if(G.qual==0) { if(G.vd->localview) { -- cgit v1.2.3 From 9e968cea4743640848a6e878de7fc1de47dc69b3 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 5 Aug 2008 03:29:46 +0000 Subject: Bugfix #16673: Segfault when using Bake Constraints Script There were several buggy things here (in order of significance): 1) PyAPI method didn't check to make sure that there was an active posechannel when deleting posechannel constraints. This was required by constraint_active_func() to be able to update the 'active' flags for the constraints in that stack 2) PyAPI method removed the links to the constraint data from the constraints list, even though that wasn't necessary, and may have caused memory leaks. 3) constraint_active_func() had no error checking for no constraints-stack being found --- source/blender/src/buttons_object.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/src') diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 2c7802c3302..58f3bff09c8 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -173,6 +173,7 @@ static void constraint_active_func(void *ob_v, void *con_v) } lb= get_active_constraints(ob); + if (lb == NULL) return; for(con= lb->first; con; con= con->next) { if(con==con_v) con->flag |= CONSTRAINT_ACTIVE; @@ -307,7 +308,7 @@ void del_constr_func (void *ob_v, void *con_v) } /* remove constraint itself */ lb= get_active_constraints(ob_v); - free_constraint_data (con); + free_constraint_data(con); BLI_freelinkN(lb, con); constraint_active_func(ob_v, NULL); -- cgit v1.2.3 From 5d62ad194d7c6cbdda1e445ca2645395831f4b69 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 7 Aug 2008 01:02:06 +0000 Subject: added back copy buttons to "Texture Face" panel. --- source/blender/src/buttons_editing.c | 88 ++--- source/blender/src/editmesh_mods.c | 653 ++++++++++++++++++----------------- 2 files changed, 383 insertions(+), 358 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index b26c52a92e2..cb6f7e629fa 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -5671,13 +5671,9 @@ void sculptmode_draw_interface_textures(uiBlock *block, unsigned short cx, unsig void do_fpaintbuts(unsigned short event) { - Mesh *me; Object *ob; bDeformGroup *defGroup; - MTFace *activetf, *tf; - MFace *mf; - MCol *activemcol; - int a; + MTFace *activetf; SculptData *sd= &G.scene->sculptdata; ID *id, *idtest; extern VPaint Gwp; /* from vpaint */ @@ -5695,45 +5691,19 @@ void do_fpaintbuts(unsigned short event) vpaint_dogamma(); break; case B_COPY_TF_MODE: + EM_mesh_copy_face(4); /* todo, get rid of magic numbers */ + break; + case B_COPY_TF_TRANSP: + EM_mesh_copy_face(5); + break; case B_COPY_TF_UV: + EM_mesh_copy_face(3); + break; case B_COPY_TF_COL: + EM_mesh_copy_face(6); + break; case B_COPY_TF_TEX: - me= get_mesh(OBACT); - activetf= get_active_mtface(NULL, &activemcol, 0); - - if(me && activetf) { - for (a=0, tf=me->mtface, mf=me->mface; a < me->totface; a++, tf++, mf++) { - if(tf!=activetf && (mf->flag & ME_FACE_SEL)) { - if(event==B_COPY_TF_MODE) { - tf->mode= activetf->mode; - tf->transp= activetf->transp; - } - else if(event==B_COPY_TF_UV) { - memcpy(tf->uv, activetf->uv, sizeof(tf->uv)); - tf->tpage= activetf->tpage; - tf->tile= activetf->tile; - - if(activetf->mode & TF_TILES) tf->mode |= TF_TILES; - else tf->mode &= ~TF_TILES; - - } - else if(event==B_COPY_TF_TEX) { - tf->tpage= activetf->tpage; - tf->tile= activetf->tile; - - if(activetf->mode & TF_TILES) tf->mode |= TF_TILES; - else tf->mode &= ~TF_TILES; - } - else if(event==B_COPY_TF_COL && activemcol) - memcpy(&me->mcol[a*4], activemcol, sizeof(MCol)*4); - } - } - - DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); - do_shared_vertexcol(me); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWIMAGE, 0); - } + EM_mesh_copy_face(2); break; case B_SET_VCOL: if(FACESEL_PAINT_TEST) @@ -6170,8 +6140,20 @@ static void editing_panel_mesh_texface(void) if(uiNewPanel(curarea, block, "Texture Face", "Editing", 960, 0, 318, 204)==0) return; tf = get_active_mtface(NULL, NULL, 0); + if(tf) { + uiDefBut(block, LABEL, B_NOP, "Active Face Mode", 600,185,300,19, NULL, 0.0, 0.0, 0, 0, "Face mode its used for TexFace display and the game engine "); + uiDefBut(block, BUT,B_COPY_TF_MODE, "Copy", 850,185,50,19, 0, 0, 0, 0, 0, "Copy active faces mode to other selected (View3D Ctrl+C)"); + + /* Other copy buttons, layout isnt that nice */ uiBlockBeginAlign(block); + uiDefBut(block, BUT,B_COPY_TF_UV, "CopyUV", 600,15,100,19, 0, 0, 0, 0, 0, "Copy active faces UVs to other selected (View3D Ctrl+C)"); + uiDefBut(block, BUT,B_COPY_TF_TEX, "CopyTex", 700,15,100,19, 0, 0, 0, 0, 0, "Copy active faces Texture to other selected (View3D Ctrl+C)"); + uiDefBut(block, BUT,B_COPY_TF_COL, "CopyColor", 800,15,100,19, 0, 0, 0, 0, 0, "Copy active faces Color to other selected (View3D Ctrl+C)"); + uiBlockEndAlign(block); + + uiBlockBeginAlign(block); + uiDefButBitS(block, TOG, TF_TEX, B_REDR_3D_IMA, "Tex", 600,160,60,19, &tf->mode, 0, 0, 0, 0, "Render face with texture"); uiDefButBitS(block, TOG, TF_TILES, B_REDR_3D_IMA, "Tiles", 660,160,60,19, &tf->mode, 0, 0, 0, 0, "Use tilemode for face"); uiDefButBitS(block, TOG, TF_LIGHT, REDRAWVIEW3D, "Light", 720,160,60,19, &tf->mode, 0, 0, 0, 0, "Use light for face"); @@ -6182,24 +6164,30 @@ static void editing_panel_mesh_texface(void) uiDefButBitS(block, TOG, TF_SHAREDCOL, REDRAWVIEW3D, "Shared", 600,135,60,19, &tf->mode, 0, 0, 0, 0, "Blend vertex colors across face when vertices are shared"); uiDefButBitS(block, TOG, TF_TWOSIDE, REDRAWVIEW3D, "Twoside",660,135,60,19, &tf->mode, 0, 0, 0, 0, "Render face twosided"); uiDefButBitS(block, TOG, TF_OBCOL, REDRAWVIEW3D, "ObColor",720,135,60,19, &tf->mode, 0, 0, 0, 0, "Use ObColor instead of vertex colors"); - - uiBlockBeginAlign(block); + uiBlockEndAlign(block); + uiBlockBeginAlign(block); uiDefButBitS(block, TOG, TF_BILLBOARD, B_TFACE_HALO, "Halo", 600,110,60,19, &tf->mode, 0, 0, 0, 0, "Screen aligned billboard"); uiDefButBitS(block, TOG, TF_BILLBOARD2, B_TFACE_BILLB, "Billboard",660,110,60,19, &tf->mode, 0, 0, 0, 0, "Billboard with Z-axis constraint"); uiDefButBitS(block, TOG, TF_SHADOW, REDRAWVIEW3D, "Shadow", 720,110,60,19, &tf->mode, 0, 0, 0, 0, "Face is used for shadow"); uiDefButBitS(block, TOG, TF_BMFONT, REDRAWVIEW3D, "Text", 780,110,60,19, &tf->mode, 0, 0, 0, 0, "Enable bitmap text on face"); uiDefButBitS(block, TOG, TF_ALPHASORT, REDRAWVIEW3D, "Sort", 840,110,60,19, &tf->mode, 0, 0, 0, 0, "Enable sorting of faces for correct alpha drawing (slow, use Clip Alpha instead when possible)"); - + uiBlockEndAlign(block); + + uiDefBut(block, LABEL, B_NOP, "Active Face Alpha Blending (Transp)", 600,75,300,19, NULL, 0.0, 0.0, 0, 0, "Face mode its used for TexFace display and the game engine"); + uiDefBut(block, BUT,B_COPY_TF_TRANSP, "Copy", 850,75,50,19, 0, 0, 0, 0, 0, "Copy active faces transp to other selected (View3D Ctrl+C)"); + uiBlockBeginAlign(block); uiBlockSetCol(block, TH_BUT_SETTING1); - uiDefButC(block, ROW, REDRAWVIEW3D, "Opaque", 600,80,60,19, &tf->transp, 2.0, (float)TF_SOLID,0, 0, "Render color of textured face as color"); - uiDefButC(block, ROW, REDRAWVIEW3D, "Add", 660,80,60,19, &tf->transp, 2.0, (float)TF_ADD, 0, 0, "Render face transparent and add color of face"); - uiDefButC(block, ROW, REDRAWVIEW3D, "Alpha", 720,80,60,19, &tf->transp, 2.0, (float)TF_ALPHA,0, 0, "Render polygon transparent, depending on alpha channel of the texture"); - uiDefButC(block, ROW, REDRAWVIEW3D, "Clip Alpha", 780,80,80,19, &tf->transp, 2.0, (float)TF_CLIP,0, 0, "Use the images alpha values clipped with no blending (binary alpha)"); - } - else + uiDefButC(block, ROW, REDRAWVIEW3D, "Opaque", 600,50,60,19, &tf->transp, 2.0, (float)TF_SOLID,0, 0, "Render color of textured face as color"); + uiDefButC(block, ROW, REDRAWVIEW3D, "Add", 660,50,60,19, &tf->transp, 2.0, (float)TF_ADD, 0, 0, "Render face transparent and add color of face"); + uiDefButC(block, ROW, REDRAWVIEW3D, "Alpha", 720,50,60,19, &tf->transp, 2.0, (float)TF_ALPHA,0, 0, "Render polygon transparent, depending on alpha channel of the texture"); + uiDefButC(block, ROW, REDRAWVIEW3D, "Clip Alpha", 780,50,80,19, &tf->transp, 2.0, (float)TF_CLIP,0, 0, "Use the images alpha values clipped with no blending (binary alpha)"); + uiBlockEndAlign(block); + + } else { uiDefBut(block,LABEL,B_NOP, "(No Active Face)", 10,200,150,19,0,0,0,0,0,""); + } } diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c index c7a75b32df1..6dfbd67720b 100644 --- a/source/blender/src/editmesh_mods.c +++ b/source/blender/src/editmesh_mods.c @@ -1432,361 +1432,398 @@ int mesh_layers_menu(CustomData *data, int type) { return ret; } -/* ctrl+c in mesh editmode */ -void mesh_copy_menu(void) +void EM_mesh_copy_edge(short type) { EditMesh *em = G.editMesh; EditSelection *ese; - short ret, change=0; + short change=0; + + EditEdge *eed, *eed_act; + float vec[3], vec_mid[3], eed_len, eed_len_act; if (!em) return; ese = em->selected.last; + if (!ese) return; - /* Faces can have a NULL ese, so dont return on a NULL ese here */ + eed_act = (EditEdge*)ese->data; - if(ese && ese->type == EDITVERT) { - - if (!ese) return; - /*EditVert *ev, *ev_act = (EditVert*)ese->data; - ret= pupmenu("");*/ - } else if(ese && ese->type == EDITEDGE) { - EditEdge *eed, *eed_act; - float vec[3], vec_mid[3], eed_len, eed_len_act; - - if (!ese) return; - - eed_act = (EditEdge*)ese->data; - - ret= pupmenu("Copy Active Edge to Selected%t|Crease%x1|Bevel Weight%x2|Length%x3"); - if (ret<1) return; - - eed_len_act = VecLenf(eed_act->v1->co, eed_act->v2->co); - - switch (ret) { - case 1: /* copy crease */ - for(eed=em->edges.first; eed; eed=eed->next) { - if (eed->f & SELECT && eed != eed_act && eed->crease != eed_act->crease) { - eed->crease = eed_act->crease; - change = 1; - } + switch (type) { + case 1: /* copy crease */ + for(eed=em->edges.first; eed; eed=eed->next) { + if (eed->f & SELECT && eed != eed_act && eed->crease != eed_act->crease) { + eed->crease = eed_act->crease; + change = 1; } - break; - case 2: /* copy bevel weight */ - for(eed=em->edges.first; eed; eed=eed->next) { - if (eed->f & SELECT && eed != eed_act && eed->bweight != eed_act->bweight) { - eed->bweight = eed_act->bweight; - change = 1; - } + } + break; + case 2: /* copy bevel weight */ + for(eed=em->edges.first; eed; eed=eed->next) { + if (eed->f & SELECT && eed != eed_act && eed->bweight != eed_act->bweight) { + eed->bweight = eed_act->bweight; + change = 1; } - break; - - case 3: /* copy length */ - - for(eed=em->edges.first; eed; eed=eed->next) { - if (eed->f & SELECT && eed != eed_act) { - - eed_len = VecLenf(eed->v1->co, eed->v2->co); - - if (eed_len == eed_len_act) continue; - /* if this edge is zero length we cont do anything with it*/ - if (eed_len == 0.0f) continue; - if (eed_len_act == 0.0f) { - VecAddf(vec_mid, eed->v1->co, eed->v2->co); - VecMulf(vec_mid, 0.5); - VECCOPY(eed->v1->co, vec_mid); - VECCOPY(eed->v2->co, vec_mid); - } else { - /* copy the edge length */ - VecAddf(vec_mid, eed->v1->co, eed->v2->co); - VecMulf(vec_mid, 0.5); - - /* SCALE 1 */ - VecSubf(vec, eed->v1->co, vec_mid); - VecMulf(vec, eed_len_act/eed_len); - VecAddf(eed->v1->co, vec, vec_mid); - - /* SCALE 2 */ - VecSubf(vec, eed->v2->co, vec_mid); - VecMulf(vec, eed_len_act/eed_len); - VecAddf(eed->v2->co, vec, vec_mid); - } - change = 1; + } + break; + + case 3: /* copy length */ + eed_len_act = VecLenf(eed_act->v1->co, eed_act->v2->co); + for(eed=em->edges.first; eed; eed=eed->next) { + if (eed->f & SELECT && eed != eed_act) { + + eed_len = VecLenf(eed->v1->co, eed->v2->co); + + if (eed_len == eed_len_act) continue; + /* if this edge is zero length we cont do anything with it*/ + if (eed_len == 0.0f) continue; + if (eed_len_act == 0.0f) { + VecAddf(vec_mid, eed->v1->co, eed->v2->co); + VecMulf(vec_mid, 0.5); + VECCOPY(eed->v1->co, vec_mid); + VECCOPY(eed->v2->co, vec_mid); + } else { + /* copy the edge length */ + VecAddf(vec_mid, eed->v1->co, eed->v2->co); + VecMulf(vec_mid, 0.5); + + /* SCALE 1 */ + VecSubf(vec, eed->v1->co, vec_mid); + VecMulf(vec, eed_len_act/eed_len); + VecAddf(eed->v1->co, vec, vec_mid); + + /* SCALE 2 */ + VecSubf(vec, eed->v2->co, vec_mid); + VecMulf(vec, eed_len_act/eed_len); + VecAddf(eed->v2->co, vec, vec_mid); } + change = 1; } - - if (change) - recalc_editnormals(); - - - break; } + + if (change) + recalc_editnormals(); + + break; + } + + if (change) { + DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWBUTSEDIT, 0); - } else if(ese==NULL || ese->type == EDITFACE) { - EditFace *efa, *efa_act; - MTFace *tf, *tf_act = NULL; - MCol *mcol, *mcol_act = NULL; - - efa_act = EM_get_actFace(0); - - if (efa_act) { - ret= pupmenu( - "Copy Face Selected%t|" - "Active Material%x1|Active Image%x2|Active UV Coords%x3|" - "Active Mode%x4|Active Transp%x5|Active Vertex Colors%x6|%l|" - - "TexFace UVs from layer%x7|" - "TexFace Images from layer%x8|" - "TexFace All from layer%x9|" - "Vertex Colors from layer%x10"); - if (ret<1) return; - tf_act = CustomData_em_get(&em->fdata, efa_act->data, CD_MTFACE); - mcol_act = CustomData_em_get(&em->fdata, efa_act->data, CD_MCOL); - } else { - ret= pupmenu( - "Copy Face Selected%t|" - - /* Make sure these are always the same as above */ - "TexFace UVs from layer%x7|" - "TexFace Images from layer%x8|" - "TexFace All from layer%x9|" - "Vertex Colors from layer%x10"); - if (ret<1) return; + BIF_undo_push("Copy Edge Attribute"); + } +} + +void EM_mesh_copy_face(short type) +{ + EditMesh *em = G.editMesh; + short change=0; + + EditFace *efa, *efa_act; + MTFace *tf, *tf_act = NULL; + MCol *mcol, *mcol_act = NULL; + if (!em) return; + efa_act = EM_get_actFace(0); + + if (!efa_act) return; + + tf_act = CustomData_em_get(&em->fdata, efa_act->data, CD_MTFACE); + mcol_act = CustomData_em_get(&em->fdata, efa_act->data, CD_MCOL); + + switch (type) { + case 1: /* copy material */ + for(efa=em->faces.first; efa; efa=efa->next) { + if (efa->f & SELECT && efa->mat_nr != efa_act->mat_nr) { + efa->mat_nr = efa_act->mat_nr; + change = 1; + } } - - switch (ret) { - case 1: /* copy material */ - for(efa=em->faces.first; efa; efa=efa->next) { - if (efa->f & SELECT && efa->mat_nr != efa_act->mat_nr) { - efa->mat_nr = efa_act->mat_nr; - change = 1; + break; + case 2: /* copy image */ + if (!tf_act) { + error("mesh has no uv/image layers"); + return; + } + for(efa=em->faces.first; efa; efa=efa->next) { + if (efa->f & SELECT && efa != efa_act) { + tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (tf_act->tpage) { + tf->tpage = tf_act->tpage; + tf->mode |= TF_TEX; + } else { + tf->tpage = NULL; + tf->mode &= ~TF_TEX; } + tf->tile= tf_act->tile; + change = 1; } - break; - case 2: /* copy image */ - if (!tf_act) { - error("mesh has no uv/image layers"); - return; + } + break; + + case 3: /* copy UV's */ + if (!tf_act) { + error("mesh has no uv/image layers"); + return; + } + for(efa=em->faces.first; efa; efa=efa->next) { + if (efa->f & SELECT && efa != efa_act) { + tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + memcpy(tf->uv, tf_act->uv, sizeof(tf->uv)); + change = 1; } - for(efa=em->faces.first; efa; efa=efa->next) { - if (efa->f & SELECT && efa != efa_act) { - tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - if (tf_act->tpage) { - tf->tpage = tf_act->tpage; - tf->mode |= TF_TEX; - } else { - tf->tpage = NULL; - tf->mode &= ~TF_TEX; - } - tf->tile= tf_act->tile; - change = 1; - } + } + break; + case 4: /* mode's */ + if (!tf_act) { + error("mesh has no uv/image layers"); + return; + } + for(efa=em->faces.first; efa; efa=efa->next) { + if (efa->f & SELECT && efa != efa_act) { + tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf->mode= tf_act->mode; + change = 1; } - break; - - case 3: /* copy UV's */ - if (!tf_act) { - error("mesh has no uv/image layers"); - return; + } + break; + case 5: /* copy transp's */ + if (!tf_act) { + error("mesh has no uv/image layers"); + return; + } + for(efa=em->faces.first; efa; efa=efa->next) { + if (efa->f & SELECT && efa != efa_act) { + tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + tf->transp= tf_act->transp; + change = 1; } + } + break; + + case 6: /* copy vcols's */ + if (!mcol_act) { + error("mesh has no color layers"); + return; + } else { + /* guess the 4th color if needs be */ + float val =- 1; + + if (!efa_act->v4) { + /* guess the othe vale, we may need to use it + * + * Modifying the 4th value of the mcol is ok here since its not seen + * on a triangle + * */ + val = ((float)(mcol_act->r + (mcol_act+1)->r + (mcol_act+2)->r)) / 3; CLAMP(val, 0, 255); + (mcol_act+3)->r = (char)val; + + val = ((float)(mcol_act->g + (mcol_act+1)->g + (mcol_act+2)->g)) / 3; CLAMP(val, 0, 255); + (mcol_act+3)->g = (char)val; + + val = ((float)(mcol_act->b + (mcol_act+1)->b + (mcol_act+2)->b)) / 3; CLAMP(val, 0, 255); + (mcol_act+3)->b = (char)val; + } + + for(efa=em->faces.first; efa; efa=efa->next) { if (efa->f & SELECT && efa != efa_act) { - tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - memcpy(tf->uv, tf_act->uv, sizeof(tf->uv)); + /* TODO - make copy from tri to quad guess the 4th vert */ + mcol = CustomData_em_get(&em->fdata, efa->data, CD_MCOL); + memcpy(mcol, mcol_act, sizeof(MCol)*4); change = 1; } } - break; - case 4: /* mode's */ - if (!tf_act) { - error("mesh has no uv/image layers"); + } + break; + } + + if (change) { + DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); + allqueue(REDRAWVIEW3D, 0); + allqueue(REDRAWBUTSEDIT, 0); + if (type==3) { + allqueue(REDRAWIMAGE, 0); + } + + BIF_undo_push("Copy Face Attribute"); + } +} + + +void EM_mesh_copy_face_layer(short type) +{ + EditMesh *em = G.editMesh; + short change=0; + + EditFace *efa; + MTFace *tf, *tf_from; + MCol *mcol, *mcol_from; + + if (!em) return; + + switch(type) { + case 7: + case 8: + case 9: + if (CustomData_number_of_layers(&em->fdata, CD_MTFACE)<2) { + error("mesh does not have multiple uv/image layers"); + return; + } else { + int layer_orig_idx, layer_idx; + + layer_idx = mesh_layers_menu(&em->fdata, CD_MTFACE); + if (layer_idx<0) return; + + /* warning, have not updated mesh pointers however this is not needed since we swicth back */ + layer_orig_idx = CustomData_get_active_layer(&em->fdata, CD_MTFACE); + if (layer_idx==layer_orig_idx) return; - } + + /* get the tfaces */ + CustomData_set_layer_active(&em->fdata, CD_MTFACE, (int)layer_idx); + /* store the tfaces in our temp */ for(efa=em->faces.first; efa; efa=efa->next) { - if (efa->f & SELECT && efa != efa_act) { - tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - tf->mode= tf_act->mode; - change = 1; - } + if (efa->f & SELECT) { + efa->tmp.p = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + } } - break; - case 5: /* copy transp's */ - if (!tf_act) { - error("mesh has no uv/image layers"); + CustomData_set_layer_active(&em->fdata, CD_MTFACE, layer_orig_idx); + } + break; + + case 10: /* select vcol layers - make sure this stays in sync with above code */ + if (CustomData_number_of_layers(&em->fdata, CD_MCOL)<2) { + error("mesh does not have multiple color layers"); + return; + } else { + int layer_orig_idx, layer_idx; + + layer_idx = mesh_layers_menu(&em->fdata, CD_MCOL); + if (layer_idx<0) return; + + /* warning, have not updated mesh pointers however this is not needed since we swicth back */ + layer_orig_idx = CustomData_get_active_layer(&em->fdata, CD_MCOL); + if (layer_idx==layer_orig_idx) return; - } + + /* get the tfaces */ + CustomData_set_layer_active(&em->fdata, CD_MCOL, (int)layer_idx); + /* store the tfaces in our temp */ for(efa=em->faces.first; efa; efa=efa->next) { - if (efa->f & SELECT && efa != efa_act) { - tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - tf->transp= tf_act->transp; - change = 1; - } - } - break; - - case 6: /* copy vcols's */ - if (!mcol_act) { - error("mesh has no color layers"); - return; - } else { - /* guess the 4th color if needs be */ - float val =- 1; - - if (!efa_act->v4) { - /* guess the othe vale, we may need to use it - * - * Modifying the 4th value of the mcol is ok here since its not seen - * on a triangle - * */ - val = ((float)(mcol_act->r + (mcol_act+1)->r + (mcol_act+2)->r)) / 3; CLAMP(val, 0, 255); - (mcol_act+3)->r = (char)val; - - val = ((float)(mcol_act->g + (mcol_act+1)->g + (mcol_act+2)->g)) / 3; CLAMP(val, 0, 255); - (mcol_act+3)->g = (char)val; - - val = ((float)(mcol_act->b + (mcol_act+1)->b + (mcol_act+2)->b)) / 3; CLAMP(val, 0, 255); - (mcol_act+3)->b = (char)val; - } - - - for(efa=em->faces.first; efa; efa=efa->next) { - if (efa->f & SELECT && efa != efa_act) { - /* TODO - make copy from tri to quad guess the 4th vert */ - mcol = CustomData_em_get(&em->fdata, efa->data, CD_MCOL); - memcpy(mcol, mcol_act, sizeof(MCol)*4); - change = 1; - } - } - } - - break; - - /* Copy from layer - Warning! tf_act and mcol_act will be NULL here */ - case 7: - case 8: - case 9: - if (CustomData_number_of_layers(&em->fdata, CD_MTFACE)<2) { - error("mesh does not have multiple uv/image layers"); - return; - } else { - int layer_orig_idx, layer_idx; - - layer_idx = mesh_layers_menu(&em->fdata, CD_MTFACE); - if (layer_idx<0) return; - - /* warning, have not updated mesh pointers however this is not needed since we swicth back */ - layer_orig_idx = CustomData_get_active_layer(&em->fdata, CD_MTFACE); - if (layer_idx==layer_orig_idx) - return; - - /* get the tfaces */ - CustomData_set_layer_active(&em->fdata, CD_MTFACE, (int)layer_idx); - /* store the tfaces in our temp */ - for(efa=em->faces.first; efa; efa=efa->next) { - if (efa->f & SELECT) { - efa->tmp.p = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - } - } - CustomData_set_layer_active(&em->fdata, CD_MTFACE, layer_orig_idx); - } - break; - - case 10: /* select vcol layers - make sure this stays in sync with above code */ - if (CustomData_number_of_layers(&em->fdata, CD_MCOL)<2) { - error("mesh does not have multiple color layers"); - return; - } else { - int layer_orig_idx, layer_idx; - - layer_idx = mesh_layers_menu(&em->fdata, CD_MCOL); - if (layer_idx<0) return; - - /* warning, have not updated mesh pointers however this is not needed since we swicth back */ - layer_orig_idx = CustomData_get_active_layer(&em->fdata, CD_MCOL); - if (layer_idx==layer_orig_idx) - return; - - /* get the tfaces */ - CustomData_set_layer_active(&em->fdata, CD_MCOL, (int)layer_idx); - /* store the tfaces in our temp */ - for(efa=em->faces.first; efa; efa=efa->next) { - if (efa->f & SELECT) { - efa->tmp.p = CustomData_em_get(&em->fdata, efa->data, CD_MCOL); - } - } - CustomData_set_layer_active(&em->fdata, CD_MCOL, layer_orig_idx); - + if (efa->f & SELECT) { + efa->tmp.p = CustomData_em_get(&em->fdata, efa->data, CD_MCOL); + } } - break; + CustomData_set_layer_active(&em->fdata, CD_MCOL, layer_orig_idx); + } - - /* layer copy only - sanity checks done above */ - switch (ret) { - case 7: /* copy UV's only */ - for(efa=em->faces.first; efa; efa=efa->next) { - if (efa->f & SELECT) { - tf_act = (MTFace *)efa->tmp.p; /* not active but easier to use this way */ - tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - memcpy(tf->uv, tf_act->uv, sizeof(tf->uv)); - change = 1; - } + break; + } + + /* layer copy only - sanity checks done above */ + switch (type) { + case 7: /* copy UV's only */ + for(efa=em->faces.first; efa; efa=efa->next) { + if (efa->f & SELECT) { + tf_from = (MTFace *)efa->tmp.p; /* not active but easier to use this way */ + tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + memcpy(tf->uv, tf_from->uv, sizeof(tf->uv)); + change = 1; } - break; - case 8: /* copy image settings only */ - for(efa=em->faces.first; efa; efa=efa->next) { - if (efa->f & SELECT) { - tf_act = (MTFace *)efa->tmp.p; /* not active but easier to use this way */ - tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - if (tf_act->tpage) { - tf->tpage = tf_act->tpage; - tf->mode |= TF_TEX; - } else { - tf->tpage = NULL; - tf->mode &= ~TF_TEX; - } - tf->tile= tf_act->tile; - change = 1; + } + break; + case 8: /* copy image settings only */ + for(efa=em->faces.first; efa; efa=efa->next) { + if (efa->f & SELECT) { + tf_from = (MTFace *)efa->tmp.p; /* not active but easier to use this way */ + tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + if (tf_from->tpage) { + tf->tpage = tf_from->tpage; + tf->mode |= TF_TEX; + } else { + tf->tpage = NULL; + tf->mode &= ~TF_TEX; } + tf->tile= tf_from->tile; + change = 1; } - break; - case 9: /* copy all tface info */ - for(efa=em->faces.first; efa; efa=efa->next) { - if (efa->f & SELECT) { - tf_act = (MTFace *)efa->tmp.p; /* not active but easier to use this way */ - tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - memcpy(tf->uv, ((MTFace *)efa->tmp.p)->uv, sizeof(tf->uv)); - tf->tpage = tf_act->tpage; - tf->mode = tf_act->mode; - tf->transp = tf_act->transp; - change = 1; - } + } + break; + case 9: /* copy all tface info */ + for(efa=em->faces.first; efa; efa=efa->next) { + if (efa->f & SELECT) { + tf_from = (MTFace *)efa->tmp.p; /* not active but easier to use this way */ + tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); + memcpy(tf->uv, ((MTFace *)efa->tmp.p)->uv, sizeof(tf->uv)); + tf->tpage = tf_from->tpage; + tf->mode = tf_from->mode; + tf->transp = tf_from->transp; + change = 1; } - break; - case 10: - for(efa=em->faces.first; efa; efa=efa->next) { - if (efa->f & SELECT) { - mcol_act = (MCol *)efa->tmp.p; - mcol = CustomData_em_get(&em->fdata, efa->data, CD_MCOL); - memcpy(mcol, mcol_act, sizeof(MCol)*4); - change = 1; - } + } + break; + case 10: + for(efa=em->faces.first; efa; efa=efa->next) { + if (efa->f & SELECT) { + mcol_from = (MCol *)efa->tmp.p; + mcol = CustomData_em_get(&em->fdata, efa->data, CD_MCOL); + memcpy(mcol, mcol_from, sizeof(MCol)*4); + change = 1; } - break; } - + break; } - + if (change) { DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWBUTSEDIT, 0); - if (ese==NULL || ese->type == EDITFACE) BIF_undo_push("Copy Face Attribute"); - else if ( ese->type == EDITEDGE) BIF_undo_push("Copy Edge Attribute"); - else if ( ese->type == EDITVERT) BIF_undo_push("Copy Vert Attribute"); - + BIF_undo_push("Copy Face Layer"); } +} + + +/* ctrl+c in mesh editmode */ +void mesh_copy_menu(void) +{ + EditMesh *em = G.editMesh; + EditSelection *ese; + int ret; + if (!em) return; + ese = em->selected.last; + + /* Faces can have a NULL ese, so dont return on a NULL ese here */ + + if(ese && ese->type == EDITVERT) { + /* EditVert *ev, *ev_act = (EditVert*)ese->data; + ret= pupmenu(""); */ + } else if(ese && ese->type == EDITEDGE) { + ret= pupmenu("Copy Active Edge to Selected%t|Crease%x1|Bevel Weight%x2|Length%x3"); + if (ret<1) return; + + EM_mesh_copy_edge(ret); + + } else if(ese==NULL || ese->type == EDITFACE) { + ret= pupmenu( + "Copy Face Selected%t|" + "Active Material%x1|Active Image%x2|Active UV Coords%x3|" + "Active Mode%x4|Active Transp%x5|Active Vertex Colors%x6|%l|" + + "TexFace UVs from layer%x7|" + "TexFace Images from layer%x8|" + "TexFace All from layer%x9|" + "Vertex Colors from layer%x10"); + if (ret<1) return; + + if (ret<=6) { + EM_mesh_copy_face(ret); + } else { + EM_mesh_copy_face_layer(ret); + } + } } -- cgit v1.2.3 From 277a420a90bf34585e3e79adfb30c9c48252bc65 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 8 Aug 2008 10:15:08 +0000 Subject: == PoseLib: Add New (on Current Frame) == When adding poses to a PoseLib, it is now possible to make them be added on the current frame. It is still recommended to use the default method (plain Add New), as it is prevents poses stored in the PoseLib from being overwritten accidentally. --- source/blender/src/poselib.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/poselib.c b/source/blender/src/poselib.c index fb2bfe5b605..6aeef7c75c2 100644 --- a/source/blender/src/poselib.c +++ b/source/blender/src/poselib.c @@ -312,7 +312,7 @@ void poselib_add_current_pose (Object *ob, int val) /* mode - add new or replace existing */ if (val == 0) { if ((ob->poselib) && (ob->poselib->markers.first)) { - val= pupmenu("PoseLib Add Current Pose%t|Add New%x1|Replace Existing%x2"); + val= pupmenu("PoseLib Add Current Pose%t|Add New%x1|Add New (Current Frame)%x3|Replace Existing%x2"); if (val <= 0) return; } else @@ -347,7 +347,10 @@ void poselib_add_current_pose (Object *ob, int val) act= poselib_validate(ob); /* get frame */ - frame= poselib_get_free_index(act); + if (val == 3) + frame= CFRA; + else /* if (val == 1) */ + frame= poselib_get_free_index(act); /* add pose to poselib - replaces any existing pose there */ for (marker= act->markers.first; marker; marker= marker->next) { -- cgit v1.2.3 From 7cbfe780443c46ab34da93839e70d6ed6217a390 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 9 Aug 2008 10:50:59 +0000 Subject: Bugfix #17465: "Pose Edit Not Possible" message activated on 3D navigation When navigating the 3d-view with a bone (or bones) selected, 'Rest Pose' enabled for the armature, and 'Orbit Around Selection' turned on, a "Pose Edit Not Possible" warning would pop up every time the view was manipulated. Was caused by a missing check for the 'TFM_DUMMY' transform mode used when calculating center to use (based on active item) --- source/blender/src/transform_conversions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index 8f83434e528..9f2f58d0cdb 100644 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -913,8 +913,8 @@ static void createTransPose(TransInfo *t, Object *ob) if (arm==NULL || ob->pose==NULL) return; if (arm->flag & ARM_RESTPOS) { - if(t->mode!=TFM_BONESIZE) { - notice ("Pose edit not possible while Rest Position is enabled"); + if(ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE)==0) { + notice("Pose edit not possible while Rest Position is enabled"); return; } } -- cgit v1.2.3 From 2fe31596e3fb13f723fe54a426b0695d836b464b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 10 Aug 2008 03:10:07 +0000 Subject: == Armature Editing Tweaks == * New Tool: Switch Direction This tool switches the direction of selected bones in EditMode, and can be found under the Specials Menu (WKey). It also adjusts the parenting, so that continuous chains can still be linked. * Bone Locking: Removed Lock/Unlock functions from Specials menu, and moved this functionality under the Toggle/Set/Clear Bone Settings tools (Shift/Ctrl-Shift/Alt W respectively) --- source/blender/src/editarmature.c | 86 ++++++++++++++++++++++++++------------- source/blender/src/editobject.c | 8 ++-- 2 files changed, 60 insertions(+), 34 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 80c24f3a989..2d5c689a754 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -1159,17 +1159,18 @@ void setflag_armature (short mode) /* get flag to set (sync these with the ones used in eBone_Flag */ if (mode == 2) - flag= pupmenu("Disable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5"); + flag= pupmenu("Disable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6"); else if (mode == 1) - flag= pupmenu("Enable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5"); + flag= pupmenu("Enable Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6"); else - flag= pupmenu("Toggle Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5"); + flag= pupmenu("Toggle Setting%t|Draw Wire%x1|Deform%x2|Mult VG%x3|Hinge%x4|No Scale%x5|Locked%x6"); switch (flag) { case 1: flag = BONE_DRAWWIRE; break; case 2: flag = BONE_NO_DEFORM; break; case 3: flag = BONE_MULT_VG_ENV; break; case 4: flag = BONE_HINGE; break; case 5: flag = BONE_NO_SCALE; break; + case 6: flag = BONE_EDITMODE_LOCKED; break; default: return; } @@ -2711,32 +2712,6 @@ void show_all_armature_bones(void) BIF_undo_push("Reveal Bones"); } -/* Sets editmode transform locks for bones (adds if lock==1, clears otherwise) */ -void set_locks_armature_bones(short lock) -{ - bArmature *arm= G.obedit->data; - EditBone *ebone; - - for (ebone = G.edbo.first; ebone; ebone=ebone->next) { - if (arm->layer & ebone->layer) { - if (ebone->flag & BONE_SELECTED) { - if (lock) - ebone->flag |= BONE_EDITMODE_LOCKED; - else - ebone->flag &= ~BONE_EDITMODE_LOCKED; - } - } - } - countall(); - allqueue(REDRAWVIEW3D, 0); - allqueue(REDRAWBUTSEDIT, 0); - - if (lock) - BIF_undo_push("Lock Bones"); - else - BIF_undo_push("Unlock Bones"); -} - /* check for null, before calling! */ static void bone_connect_to_existing_parent(EditBone *bone) { @@ -3176,6 +3151,59 @@ void subdivide_armature(int numcuts) else BIF_undo_push("Subdivide multi"); } +/* switch direction of bone chains */ +void switch_direction_armature (void) +{ + bArmature *arm= (G.obedit) ? G.obedit->data : NULL; + ListBase chains = {NULL, NULL}; + LinkData *chain; + + /* error checking paranoia */ + if (arm == NULL) + return; + + /* get chains of bones (ends on chains) */ + chains_find_tips(&chains); + if (chains.first == NULL) return; + + /* loop over chains, only considering selected and visible bones */ + for (chain= chains.first; chain; chain= chain->next) { + EditBone *ebo, *child=NULL, *parent=NULL; + + /* loop over bones in chain */ + for (ebo= chain->data; ebo; child= ebo, ebo=parent) { + parent= ebo->parent; + + /* only if selected and editable */ + if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) { + /* swap head and tail coordinates */ + SWAP(float, ebo->head[0], ebo->tail[0]); + SWAP(float, ebo->head[1], ebo->tail[1]); + SWAP(float, ebo->head[2], ebo->tail[2]); + + /* do parent swapping: + * - use 'child' as new parent + * - connected flag is only set if points are coincidental + */ + ebo->parent= child; + if ((child) && VecEqual(ebo->head, child->tail)) + ebo->flag |= BONE_CONNECTED; + else + ebo->flag &= ~BONE_CONNECTED; + + /* FIXME: other things that need fixing? + * i.e. roll? + */ + } + } + } + + /* free chains */ + BLI_freelistN(&chains); + + BIF_undo_push("Switch Direction"); +} + /* ***************** Pose tools ********************* */ void clear_armature(Object *ob, char mode) diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index cbf7691754d..fee967bcd9a 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -2760,7 +2760,7 @@ void special_editmenu(void) DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); } else if(G.obedit->type==OB_ARMATURE) { - nr= pupmenu("Specials%t|Subdivide %x1|Subdivide Multi%x2|Flip Left-Right Names%x3|%l|AutoName Left-Right%x4|AutoName Front-Back%x5|AutoName Top-Bottom%x6|%l|Lock%x7|Unlock%x8"); + nr= pupmenu("Specials%t|Subdivide %x1|Subdivide Multi%x2|Switch Direction%x7|Flip Left-Right Names%x3|%l|AutoName Left-Right%x4|AutoName Front-Back%x5|AutoName Top-Bottom%x6"); if(nr==1) subdivide_armature(1); if(nr==2) { @@ -2773,10 +2773,8 @@ void special_editmenu(void) else if(ELEM3(nr, 4, 5, 6)) { armature_autoside_names(nr-4); } - else if(nr==7) - set_locks_armature_bones(1); - else if(nr==8) - set_locks_armature_bones(0); + else if(nr == 7) + switch_direction_armature(); } else if(G.obedit->type==OB_LATTICE) { static float weight= 1.0f; -- cgit v1.2.3 From f3c138e1315a7a957e8f0e6a95c4235f43be3195 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 10 Aug 2008 03:39:09 +0000 Subject: Changed a few places where visibility for EditMode bones is tested, so that they now use a macro I introduced in the previous commit. --- source/blender/src/editarmature.c | 65 ++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 31 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/editarmature.c b/source/blender/src/editarmature.c index 2d5c689a754..35986fcff4a 100644 --- a/source/blender/src/editarmature.c +++ b/source/blender/src/editarmature.c @@ -854,6 +854,7 @@ static void separate_armature_bones (Object *ob, short sel) BLI_freelistN(&edbo); } +/* separate selected bones into their armature */ void separate_armature (void) { Object *oldob, *newob; @@ -1094,13 +1095,13 @@ void armature_select_hierarchy(short direction, short add_to_sel) arm= (bArmature *)ob->data; for (curbone= G.edbo.first; curbone; curbone= curbone->next) { - if (arm->layer & curbone->layer) { + if (EBONE_VISIBLE(arm, curbone)) { if (curbone->flag & (BONE_ACTIVE)) { if (direction == BONE_SELECT_PARENT) { if (curbone->parent == NULL) continue; else pabone = curbone->parent; - if ((arm->layer & pabone->layer) && !(pabone->flag & BONE_HIDDEN_A)) { + if (EBONE_VISIBLE(arm, pabone)) { pabone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL; @@ -1109,11 +1110,12 @@ void armature_select_hierarchy(short direction, short add_to_sel) break; } - } else { // BONE_SELECT_CHILD + } + else { // BONE_SELECT_CHILD chbone = editbone_get_child(curbone, 1); if (chbone == NULL) continue; - if ((arm->layer & chbone->layer) && !(chbone->flag & BONE_HIDDEN_A)) { + if (EBONE_VISIBLE(arm, chbone)) { chbone->flag |= (BONE_ACTIVE|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); if (!add_to_sel) { @@ -1726,12 +1728,12 @@ void auto_align_armature(short mode) float *cursor= give_cursor(); for (ebone = G.edbo.first; ebone; ebone=ebone->next) { - if (arm->layer & ebone->layer) { + if (EBONE_VISIBLE(arm, ebone)) { if (arm->flag & ARM_MIRROR_EDIT) flipbone = armature_bone_get_mirrored(ebone); if ((ebone->flag & BONE_SELECTED) || - (flipbone && flipbone->flag & BONE_SELECTED)) + (flipbone && (flipbone->flag & BONE_SELECTED))) { /* specific method used to calculate roll depends on mode */ if (mode == 1) { @@ -1976,7 +1978,7 @@ void addvert_armature(void) /* find the active or selected bone */ for (ebone = G.edbo.first; ebone; ebone=ebone->next) { - if (arm->layer & ebone->layer) { + if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & (BONE_ACTIVE|BONE_TIPSEL)) break; } @@ -1984,7 +1986,7 @@ void addvert_armature(void) if (ebone==NULL) { for (ebone = G.edbo.first; ebone; ebone=ebone->next) { - if (arm->layer & ebone->layer) { + if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & (BONE_ACTIVE|BONE_ROOTSEL)) break; } @@ -2067,11 +2069,12 @@ static EditBone *get_named_editbone(char *name) { EditBone *eBone; - if (name) + if (name) { for (eBone=G.edbo.first; eBone; eBone=eBone->next) { if (!strcmp(name, eBone->name)) return eBone; } + } return NULL; } @@ -2137,7 +2140,7 @@ void adduplicate_armature(void) /* Select mirrored bones */ if (arm->flag & ARM_MIRROR_EDIT) { for (curBone=G.edbo.first; curBone; curBone=curBone->next) { - if (arm->layer & curBone->layer) { + if (EBONE_VISIBLE(arm, curBone)) { if (curBone->flag & BONE_SELECTED) { eBone = armature_bone_get_mirrored(curBone); if (eBone) @@ -2149,13 +2152,13 @@ void adduplicate_armature(void) /* Find the selected bones and duplicate them as needed */ for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) { - if (arm->layer & curBone->layer) { + if (EBONE_VISIBLE(arm, curBone)) { if (curBone->flag & BONE_SELECTED) { eBone=MEM_callocN(sizeof(EditBone), "addup_editbone"); eBone->flag |= BONE_SELECTED; /* Copy data from old bone to new bone */ - memcpy (eBone, curBone, sizeof(EditBone)); + memcpy(eBone, curBone, sizeof(EditBone)); curBone->temp = eBone; eBone->temp = curBone; @@ -2205,7 +2208,7 @@ void adduplicate_armature(void) /* Run though the list and fix the pointers */ for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) { - if (arm->layer & curBone->layer) { + if (EBONE_VISIBLE(arm, curBone)) { if (curBone->flag & BONE_SELECTED) { eBone=(EditBone*) curBone->temp; @@ -2237,7 +2240,7 @@ void adduplicate_armature(void) /* Deselect the old bones and select the new ones */ for (curBone=G.edbo.first; curBone && curBone!=firstDup; curBone=curBone->next) { - if (arm->layer & curBone->layer) + if (EBONE_VISIBLE(arm, curBone)) curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL | BONE_ACTIVE); } @@ -2374,7 +2377,7 @@ void fill_bones_armature(void) /* loop over all bones, and only consider if visible */ for (ebo= G.edbo.first; ebo; ebo= ebo->next) { - if ((arm->layer & ebo->layer) && !(ebo->flag & BONE_HIDDEN_A)) { + if (EBONE_VISIBLE(arm, ebo)) { if (!(ebo->flag & BONE_CONNECTED) && (ebo->flag & BONE_ROOTSEL)) fill_add_joint(ebo, 0, &points); if (ebo->flag & BONE_TIPSEL) @@ -2609,7 +2612,7 @@ void merge_armature(void) /* only consider bones that are visible and selected */ for (ebo=chain->data; ebo; child=ebo, ebo=ebo->parent) { /* check if visible + selected */ - if ( (arm->layer & ebo->layer) && !(ebo->flag & BONE_HIDDEN_A) && + if ( EBONE_VISIBLE(arm, ebo) && ((ebo->flag & BONE_CONNECTED) || (ebo->parent==NULL)) && (ebo->flag & (BONE_SELECTED|BONE_ACTIVE)) ) { @@ -2660,7 +2663,7 @@ void hide_selected_armature_bones(void) EditBone *ebone; for (ebone = G.edbo.first; ebone; ebone=ebone->next) { - if (arm->layer & ebone->layer) { + if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & (BONE_SELECTED)) { ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL|BONE_ACTIVE); ebone->flag |= BONE_HIDDEN_A; @@ -2679,7 +2682,7 @@ void hide_unselected_armature_bones(void) for (ebone = G.edbo.first; ebone; ebone=ebone->next) { bArmature *arm= G.obedit->data; - if (arm->layer & ebone->layer) { + if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL)); else { ebone->flag &= ~BONE_ACTIVE; @@ -2778,7 +2781,7 @@ void make_bone_parent(void) /* find active bone to parent to */ for (actbone = G.edbo.first; actbone; actbone=actbone->next) { - if (arm->layer & actbone->layer) { + if (EBONE_VISIBLE(arm, actbone)) { if (actbone->flag & BONE_ACTIVE) break; } @@ -2790,7 +2793,7 @@ void make_bone_parent(void) /* find selected bones */ for (ebone = G.edbo.first; ebone; ebone=ebone->next) { - if (arm->layer & ebone->layer) { + if (EBONE_VISIBLE(arm, ebone)) { if ((ebone->flag & BONE_SELECTED) && (ebone != actbone)) { foundselbone++; if (ebone->parent != actbone) allchildbones= 1; @@ -2826,7 +2829,7 @@ void make_bone_parent(void) else { /* loop through all editbones, parenting all selected bones to the active bone */ for (selbone = G.edbo.first; selbone; selbone=selbone->next) { - if (arm->layer & selbone->layer) { + if (EBONE_VISIBLE(arm, selbone)) { if ((selbone->flag & BONE_SELECTED) && (selbone!=actbone)) { /* parent selbone to actbone */ bone_connect_to_new_parent(selbone, actbone, val); @@ -2884,7 +2887,7 @@ void clear_bone_parent(void) if (val<1) return; for (ebone = G.edbo.first; ebone; ebone=ebone->next) { - if (arm->layer & ebone->layer) { + if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_SELECTED) { if (arm->flag & ARM_MIRROR_EDIT) flipbone = armature_bone_get_mirrored(ebone); @@ -2934,7 +2937,7 @@ void unique_editbone_name (ListBase *ebones, char *name) } for (number = 1; number <=999; number++) { - sprintf (tempname, "%s.%03d", name, number); + sprintf(tempname, "%s.%03d", name, number); if (!editbone_name_exists(ebones, tempname)) { BLI_strncpy(name, tempname, 32); return; @@ -2955,7 +2958,7 @@ void extrude_armature(int forked) /* since we allow root extrude too, we have to make sure selection is OK */ for (ebone = G.edbo.first; ebone; ebone=ebone->next) { - if (arm->layer & ebone->layer) { + if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_ROOTSEL) { if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { if (ebone->parent->flag & BONE_TIPSEL) @@ -2967,7 +2970,7 @@ void extrude_armature(int forked) /* Duplicate the necessary bones */ for (ebone = G.edbo.first; ((ebone) && (ebone!=first)); ebone=ebone->next) { - if (arm->layer & ebone->layer) { + if (EBONE_VISIBLE(arm, ebone)) { /* we extrude per definition the tip */ do_extrude= 0; if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED)) @@ -2981,7 +2984,7 @@ void extrude_armature(int forked) if (do_extrude) { /* we re-use code for mirror editing... */ flipbone= NULL; - if(arm->flag & ARM_MIRROR_EDIT) { + if (arm->flag & ARM_MIRROR_EDIT) { flipbone= armature_bone_get_mirrored(ebone); if (flipbone) { forked= 0; // we extrude 2 different bones @@ -3011,7 +3014,7 @@ void extrude_armature(int forked) newbone->parent = ebone; newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone - + if (newbone->parent) newbone->flag |= BONE_CONNECTED; } else { @@ -3021,7 +3024,7 @@ void extrude_armature(int forked) newbone->flag= BONE_TIPSEL; - if (newbone->parent && ebone->flag & BONE_CONNECTED) { + if (newbone->parent && (ebone->flag & BONE_CONNECTED)) { newbone->flag |= BONE_CONNECTED; } } @@ -3040,8 +3043,8 @@ void extrude_armature(int forked) BLI_strncpy (newbone->name, ebone->name, 32); if (flipbone && forked) { // only set if mirror edit - if(strlen(newbone->name)<30) { - if(a==0) strcat(newbone->name, "_L"); + if (strlen(newbone->name)<30) { + if (a==0) strcat(newbone->name, "_L"); else strcat(newbone->name, "_R"); } } @@ -3086,7 +3089,7 @@ void subdivide_armature(int numcuts) if (numcuts < 1) return; for (mbone = G.edbo.last; mbone; mbone= mbone->prev) { - if (arm->layer & mbone->layer) { + if (EBONE_VISIBLE(arm, mbone)) { if (mbone->flag & BONE_SELECTED) { for (i=numcuts+1; i>1; i--) { /* compute cut ratio first */ -- cgit v1.2.3 From d2750f7bda1e5e4e43df330ab49e677105e00d4f Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Wed, 13 Aug 2008 17:38:38 +0000 Subject: Snap menu header rewording, to make documentation clearer (there was "mode" and "snap mode"). This can and should be merged for 2.47, as the docs will use those wordings. --- source/blender/src/header_view3d.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/src') diff --git a/source/blender/src/header_view3d.c b/source/blender/src/header_view3d.c index 948023bebfb..fcf4caf4522 100644 --- a/source/blender/src/header_view3d.c +++ b/source/blender/src/header_view3d.c @@ -5139,7 +5139,7 @@ static char *snapmode_pup(void) static char string[512]; char *str = string; - str += sprintf(str, "%s", "Snap Mode: %t"); + str += sprintf(str, "%s", "Snap Element: %t"); str += sprintf(str, "%s", "|Vertex%x0"); str += sprintf(str, "%s", "|Edge%x1"); str += sprintf(str, "%s", "|Face%x2"); @@ -5777,7 +5777,7 @@ void view3d_buttons(void) xco+= XIC; uiDefIconTextButS(block, ICONTEXTROW,B_REDR, ICON_VERTEXSEL, snapmode_pup(), xco,0,XIC+10,YIC, &(G.scene->snap_mode), 0.0, 0.0, 0, 0, "Snapping mode"); xco+= XIC; - uiDefButS(block, MENU, B_NOP, "Mode%t|Closest%x0|Center%x1|Median%x2|Active%x3",xco,0,70,YIC, &G.scene->snap_target, 0, 0, 0, 0, "Snap Target Mode"); + uiDefButS(block, MENU, B_NOP, "Snap Mode%t|Closest%x0|Center%x1|Median%x2|Active%x3",xco,0,70,YIC, &G.scene->snap_target, 0, 0, 0, 0, "Snap Target Mode"); xco+= 70; } else { uiDefIconButBitS(block, TOG, SCE_SNAP, B_REDR, ICON_SNAP_GEAR,xco,0,XIC,YIC, &G.scene->snap_flag, 0, 0, 0, 0, "Snap while Ctrl is held during transform (Shift Tab)"); -- cgit v1.2.3