Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorAndre Susano Pinto <andresusanopinto@gmail.com>2008-07-04 05:03:50 +0400
committerAndre Susano Pinto <andresusanopinto@gmail.com>2008-07-04 05:03:50 +0400
commitad310b5087ea1605ba235f9ed4cf8292fa4294f7 (patch)
tree647f26aa80c653aaaf936dbe9813f9371f4d61d0 /source
parenteca709e4811f7ddbad49633865481fca53a5d588 (diff)
Added modes Squash and Strech to SimpleDeform (need testing)
CHanged the add modifier menu to show a submenu for selecting the type of simpledeform.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/simple_deform.c50
-rw-r--r--source/blender/makesdna/DNA_modifier_types.h2
-rw-r--r--source/blender/src/buttons_editing.c77
3 files changed, 114 insertions, 15 deletions
diff --git a/source/blender/blenkernel/intern/simple_deform.c b/source/blender/blenkernel/intern/simple_deform.c
index bdd0b0e206b..548c53be8ba 100644
--- a/source/blender/blenkernel/intern/simple_deform.c
+++ b/source/blender/blenkernel/intern/simple_deform.c
@@ -66,6 +66,46 @@ static void simpleDeform_tapperXY(const float factor, const float *dcut, float *
}
}
+/* TODO strech and squash need review on function */
+static void simpleDeform_strech(const float factor, const float dcut[3], float *co)
+{
+ float x = co[0], y = co[1], z = co[2];
+ float scale;
+
+ scale = z*factor;
+ scale = scale*scale;
+
+ co[0] += x+x*scale;
+ co[1] += y+y*scale;
+
+ if(dcut)
+ {
+ co[0] += dcut[0]*scale;
+ co[1] += dcut[0]*scale;
+ co[2] += dcut[2];
+ }
+
+}
+
+static void simpleDeform_squash(const float factor, const float dcut[3], float *co)
+{
+ float x = co[0], y = co[1], z = co[2];
+ float scale;
+
+ scale = z*factor;
+ scale = -scale*scale;
+
+ co[0] += x+x*scale;
+ co[1] += y+y*scale;
+
+ if(dcut)
+ {
+ co[0] += dcut[0]*scale;
+ co[1] += dcut[0]*scale;
+ co[2] += dcut[2];
+ }
+}
+
static void simpleDeform_tapperX(const float factor, const float *dcut, float *co)
{
float x = co[0], y = co[1], z = co[2];
@@ -179,6 +219,16 @@ void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, f
axis_limit(2, smd->factor+1, *vertexCos, dcut);
simpleDeform_tapperXY(smd->factor[0], dcut, *vertexCos);
break;
+
+ case MOD_SIMPLEDEFORM_MODE_STRECH:
+ axis_limit(2, smd->factor+1, *vertexCos, dcut);
+ simpleDeform_strech(smd->factor[0], dcut, *vertexCos);
+ break;
+
+ case MOD_SIMPLEDEFORM_MODE_SQUASH:
+ axis_limit(2, smd->factor+1, *vertexCos, dcut);
+ simpleDeform_squash(smd->factor[0], dcut, *vertexCos);
+ break;
}
if(mod2ob)
diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h
index 5ee767efb83..74308579cf1 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -533,5 +533,7 @@ typedef struct SimpleDeformModifierData {
#define MOD_SIMPLEDEFORM_MODE_BEND 2
#define MOD_SIMPLEDEFORM_MODE_TAPER_X 3
#define MOD_SIMPLEDEFORM_MODE_TAPER_XY 4
+#define MOD_SIMPLEDEFORM_MODE_STRECH 5
+#define MOD_SIMPLEDEFORM_MODE_SQUASH 6
#endif
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c
index 5654ef0bbad..5985d473a5d 100644
--- a/source/blender/src/buttons_editing.c
+++ b/source/blender/src/buttons_editing.c
@@ -938,25 +938,62 @@ void do_modifier_panels(unsigned short event)
}
}
-static void modifiers_add(void *ob_v, int type)
+static void object_add_modifier(Object *ob, ModifierData *md)
{
- Object *ob = ob_v;
- ModifierTypeInfo *mti = modifierType_getInfo(type);
-
+ ModifierTypeInfo *mti = modifierType_getInfo(md->type);
if (mti->flags&eModifierTypeFlag_RequiresOriginalData) {
- ModifierData *md = ob->modifiers.first;
+ ModifierData *iter = ob->modifiers.first;
- while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) {
- md = md->next;
+ while (iter && modifierType_getInfo(iter->type)->type==eModifierTypeType_OnlyDeform) {
+ iter = iter->next;
}
- BLI_insertlinkbefore(&ob->modifiers, md, modifier_new(type));
+ BLI_insertlinkbefore(&ob->modifiers, iter, md);
} else {
- BLI_addtail(&ob->modifiers, modifier_new(type));
+ BLI_addtail(&ob->modifiers, md);
}
+}
+
+static void modifiers_add(void *ob_v, int type)
+{
+ object_add_modifier((Object*) ob_v, modifier_new(type));
BIF_undo_push("Add modifier");
}
+static void do_modifiers_select_simpledeform_typemenu(void *ob_v, int event)
+{
+ static const char *default_name[] = { "", "Twist", "Bend", "Taper X", "Taper XY", "Strech", "Squash" };
+ SimpleDeformModifierData *smd = (SimpleDeformModifierData*)modifier_new(eModifierType_SimpleDeform);
+ smd->mode = event;
+
+ if(smd->mode >= 0 && smd->mode < sizeof(default_name)/sizeof(*default_name))
+ strncpy( smd->modifier.name, default_name[ smd->mode ], sizeof(smd->modifier.name));
+
+ object_add_modifier((Object*) ob_v, (ModifierData*)smd);
+ BIF_undo_push("Add modifier");
+}
+
+static uiBlock *modifiers_select_simpledeform_typemenu(void *ob_v)
+{
+ uiBlock *block;
+ short yco = 20, menuwidth = 160;
+
+ block= uiNewBlock(&curarea->uiblocks, "modifiers_select_simpledeform_typemenu", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
+ uiBlockSetButmFunc(block, do_modifiers_select_simpledeform_typemenu, ob_v);
+
+ uiDefBut(block, BUTM, 1, "Twist", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, MOD_SIMPLEDEFORM_MODE_TWIST, "");
+ uiDefBut(block, BUTM, 1, "Bend", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, MOD_SIMPLEDEFORM_MODE_BEND, "");
+ uiDefBut(block, BUTM, 1, "Tapper X", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, MOD_SIMPLEDEFORM_MODE_TAPER_X, "");
+ uiDefBut(block, BUTM, 1, "Tapper XY", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, MOD_SIMPLEDEFORM_MODE_TAPER_XY, "");
+ uiDefBut(block, BUTM, 1, "Strech", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, MOD_SIMPLEDEFORM_MODE_STRECH, "");
+ uiDefBut(block, BUTM, 1, "Squash", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 1, MOD_SIMPLEDEFORM_MODE_SQUASH, "");
+
+ uiBlockSetDirection(block, UI_RIGHT);
+ uiTextBoundsBlock(block, 50);
+ return block;
+}
+
+
typedef struct MenuEntry {
char *name;
int ID;
@@ -1000,8 +1037,18 @@ static uiBlock *modifiers_add_menu(void *ob_v)
for(i = 0; i < numEntries; ++i)
- uiDefBut(block, BUTM, B_MODIFIER_RECALC, entries[i].name,
- 0, yco -= 20, 160, 19, NULL, 0, 0, 1, entries[i].ID, "");
+ {
+ if(entries[i].ID == eModifierType_SimpleDeform)
+ {
+ //TODO: this menu has a left space.. which loooks ugly :S
+ uiDefIconTextBlockBut(block, modifiers_select_simpledeform_typemenu, ob_v, ICON_RIGHTARROW_THIN, entries[i].name, 0, yco-=20, 160, 19, "");
+ }
+ else
+ {
+ uiDefBut(block, BUTM, B_MODIFIER_RECALC, entries[i].name,
+ 0, yco -= 20, 160, 19, NULL, 0, 0, 1, entries[i].ID, "");
+ }
+ }
uiTextBoundsBlock(block, 50);
uiBlockSetDirection(block, UI_DOWN);
@@ -1859,8 +1906,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
if (smd->shrinkType == MOD_SHRINKWRAP_NORMAL)
height += 19*5;
} else if (md->type==eModifierType_SimpleDeform) {
- SimpleDeformModifierData *smd = (SimpleDeformModifierData*) md;
- height += 19*5;
+ height += 19*4;
}
/* roundbox 4 free variables: corner-rounding, nop, roundbox type, shade */
uiDefBut(block, ROUNDBOX, 0, "", x-10, y-height-2, width, height-2, NULL, 5.0, 0.0, 12, 40, "");
@@ -2509,10 +2555,11 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
uiBlockEndAlign(block);
} else if (md->type==eModifierType_SimpleDeform) {
SimpleDeformModifierData *smd = (SimpleDeformModifierData*) md;
- char simpledeform_typemenu[]="Deform type%t|Twist %x1|Bend %x2|Taper %x3|TaperXY %x4";
+/*
+ char simpledeform_typemenu[]="Deform type%t|Twist %x1|Bend %x2|Taper %x3|TaperXY %x4|Strech %x5|Squash %x6";
uiDefButC(block, MENU, B_MODIFIER_RECALC, simpledeform_typemenu, lx,(cy-=19),buttonWidth,19, &smd->mode, 0, 0, 0, 0, "Selects type of deform");
-
+*/
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth-17,19, &smd->origin, "Origin of modifier space coordinates");