== Transform: Warp ==
Adding special hotkey (MMB) to reverse the direction of the warp. Normal input is 0..360 mapped to the horizontal position of the mouse on the 3D view (the 3D view becomes a sort of giant horizontal slider), pressing MMB reverses the value to 0..-360 and back if you press it again. I've used MMB mostly because it's unused in Warp, easily accessible and already used to switches mode for Shear (shear x/y). Indirectly suggested by a user question on ba.
This commit is contained in:
@@ -303,6 +303,7 @@ void convertVecToDisplayNum(float *vec, float *num);
|
||||
void convertDisplayNumToVec(float *num, float *vec);
|
||||
|
||||
void initWarp(TransInfo *t);
|
||||
int handleEventWarp(TransInfo *t, unsigned short event, short val);
|
||||
int Warp(TransInfo *t, short mval[2]);
|
||||
|
||||
void initShear(TransInfo *t);
|
||||
|
||||
@@ -1399,6 +1399,7 @@ void initWarp(TransInfo *t)
|
||||
|
||||
t->mode = TFM_WARP;
|
||||
t->transform = Warp;
|
||||
t->handleEvent = handleEventWarp;
|
||||
|
||||
t->idx_max = 0;
|
||||
t->num.idx_max = 0;
|
||||
@@ -1435,6 +1436,24 @@ void initWarp(TransInfo *t)
|
||||
t->val= (max[0]-min[0])/2.0f; /* t->val is X dimension projected boundbox */
|
||||
}
|
||||
|
||||
int handleEventWarp(TransInfo *t, unsigned short event, short val)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
if (event == MIDDLEMOUSE && val)
|
||||
{
|
||||
// Use customData pointer to signal warp direction
|
||||
if (t->customData == 0)
|
||||
t->customData = (void*)1;
|
||||
else
|
||||
t->customData = 0;
|
||||
|
||||
status = 1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int Warp(TransInfo *t, short mval[2])
|
||||
{
|
||||
TransData *td = t->data;
|
||||
@@ -1465,6 +1484,11 @@ int Warp(TransInfo *t, short mval[2])
|
||||
|
||||
/* amount of degrees for warp */
|
||||
circumfac= 360.0f * InputHorizontalRatio(t, mval);
|
||||
|
||||
if (t->customData) /* non-null value indicates reversed input */
|
||||
{
|
||||
circumfac *= -1;
|
||||
}
|
||||
|
||||
snapGrid(t, &circumfac);
|
||||
applyNumInput(&t->num, &circumfac);
|
||||
|
||||
Reference in New Issue
Block a user