Making transform's code more Blenderish with a proper extern include file (BIF_transform.h) and extern function calls (BIF_*).
On a side note, Shear was fixed in last commit, just forgot to mention it. It wasn't acting correctly in Edit Mode (and Desoto was poking me about it every sunday).
This commit is contained in:
63
source/blender/include/BIF_transform.h
Executable file
63
source/blender/include/BIF_transform.h
Executable file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version. The Blender
|
||||
* Foundation also sells licenses for use in proprietary software under
|
||||
* the Blender License. See http://www.blender.org/BL/ for information
|
||||
* about this.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
||||
* All rights reserved.
|
||||
*
|
||||
* The Original Code is: all of this file.
|
||||
*
|
||||
* Contributor(s): none yet.
|
||||
*
|
||||
* ***** END GPL/BL DUAL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
#ifndef BIF_TRANSFORM_H
|
||||
#define BIF_TRANSFORM_H
|
||||
|
||||
/* ******************** Macros & Prototypes *********************** */
|
||||
|
||||
/* MODE AND NUMINPUT FLAGS */
|
||||
#define TFM_REPEAT 0
|
||||
#define TFM_TRANSLATION 1
|
||||
#define TFM_ROTATION 2
|
||||
#define TFM_RESIZE 3
|
||||
#define TFM_TOSPHERE 4
|
||||
#define TFM_SHEAR 5
|
||||
#define TFM_LAMP_ENERGY 6
|
||||
|
||||
#define PROP_SHARP 0
|
||||
#define PROP_SMOOTH 1
|
||||
#define PROP_ROOT 2
|
||||
#define PROP_LIN 3
|
||||
#define PROP_CONST 4
|
||||
|
||||
void Transform(int mode);
|
||||
|
||||
|
||||
extern struct TransInfo;
|
||||
struct TransInfo * BIF_GetTransInfo();
|
||||
void BIF_setSingleAxisConstraint(float vec[3]);
|
||||
void BIF_drawConstraint();
|
||||
void BIF_drawPropCircle();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
#include "mydevice.h"
|
||||
#include "butspace.h" // event codes
|
||||
|
||||
#include "transform_constraints.h"
|
||||
#include "BIF_transform.h"
|
||||
|
||||
/* Modules used */
|
||||
#include "render.h" // for ogl render
|
||||
@@ -1913,8 +1913,8 @@ void drawview3dspace(ScrArea *sa, void *spacedata)
|
||||
if(G.moving) {
|
||||
constline_callback();
|
||||
#ifdef NEWTRANSFORM
|
||||
drawConstraint();
|
||||
drawPropCircle();
|
||||
BIF_drawConstraint();
|
||||
BIF_drawPropCircle();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@
|
||||
|
||||
#include "blendef.h"
|
||||
|
||||
#include "transform.h"
|
||||
#include "BIF_transform.h"
|
||||
|
||||
#include "BIF_poseobject.h"
|
||||
|
||||
@@ -6726,7 +6726,7 @@ void std_rmouse_transform(void (*xf_func)(int))
|
||||
getmouseco_areawin(mval);
|
||||
if(abs(mval[0]-xo)+abs(mval[1]-yo) > 10) {
|
||||
#ifdef NEWTRANSFORM
|
||||
Transform(TRANSLATION);
|
||||
Transform(TFM_TRANSLATION);
|
||||
#else
|
||||
xf_func('g');
|
||||
#endif
|
||||
|
||||
@@ -712,9 +712,9 @@ int gesture(void)
|
||||
else if(curarea->spacetype==SPACE_OOPS) transform_oops('g');
|
||||
else {
|
||||
#ifdef NEWTRANSFORM
|
||||
if(i=='g') Transform(TRANSLATION);
|
||||
else if(i=='s') Transform(ROTATION);
|
||||
else Transform(RESIZE);
|
||||
if(i=='g') Transform(TFM_TRANSLATION);
|
||||
else if(i=='s') Transform(TFM_ROTATION);
|
||||
else Transform(TFM_RESIZE);
|
||||
#else
|
||||
transform(i);
|
||||
#endif
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
#include "blendef.h"
|
||||
#include "datatoc.h"
|
||||
|
||||
#include "transform.h"
|
||||
#include "BIF_transform.h"
|
||||
|
||||
#include "TPT_DependKludge.h"
|
||||
#ifdef NAN_TPT
|
||||
@@ -1216,7 +1216,7 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
}
|
||||
} else if((G.qual==0))
|
||||
#ifdef NEWTRANSFORM
|
||||
Transform(TRANSLATION);
|
||||
Transform(TFM_TRANSLATION);
|
||||
#else
|
||||
transform('g');
|
||||
#endif
|
||||
@@ -1473,14 +1473,14 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
}
|
||||
else if((G.qual==0))
|
||||
#ifdef NEWTRANSFORM
|
||||
Transform(ROTATION);
|
||||
Transform(TFM_ROTATION);
|
||||
#else
|
||||
transform('r');
|
||||
#endif
|
||||
}
|
||||
else if((G.qual==0))
|
||||
#ifdef NEWTRANSFORM
|
||||
Transform(ROTATION);
|
||||
Transform(TFM_ROTATION);
|
||||
#else
|
||||
transform('r');
|
||||
#endif
|
||||
@@ -1491,9 +1491,9 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
transform('N'); /* scale along normal */
|
||||
else if(G.qual==LR_CTRLKEY)
|
||||
#ifdef NEWTRANSFORM
|
||||
Transform(SHEAR);
|
||||
Transform(TFM_SHEAR);
|
||||
else if(G.qual==(LR_CTRLKEY|LR_ALTKEY))
|
||||
Transform(SHEAR);
|
||||
Transform(TFM_SHEAR);
|
||||
#else
|
||||
transform('S');
|
||||
#endif
|
||||
@@ -1501,9 +1501,9 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
snapmenu();
|
||||
else if(G.qual==0)
|
||||
#ifdef NEWTRANSFORM
|
||||
Transform(RESIZE);
|
||||
Transform(TFM_RESIZE);
|
||||
else if(G.qual==(LR_SHIFTKEY|LR_CTRLKEY))
|
||||
Transform(TOSPHERE);
|
||||
Transform(TFM_TOSPHERE);
|
||||
#else
|
||||
transform('s');
|
||||
#endif
|
||||
@@ -1518,11 +1518,11 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
|
||||
}
|
||||
else if((G.qual==0))
|
||||
#ifdef NEWTRANSFORM
|
||||
Transform(RESIZE);
|
||||
Transform(TFM_RESIZE);
|
||||
else if(G.qual==(LR_SHIFTKEY|LR_CTRLKEY))
|
||||
Transform(TOSPHERE);
|
||||
Transform(TFM_TOSPHERE);
|
||||
else if(G.qual==(LR_CTRLKEY|LR_ALTKEY))
|
||||
Transform(SHEAR);
|
||||
Transform(TFM_SHEAR);
|
||||
#else
|
||||
transform('s');
|
||||
#endif
|
||||
|
||||
@@ -112,8 +112,8 @@ extern void helpline(float *vec);
|
||||
#include "transform_numinput.h"
|
||||
|
||||
/* GLOBAL VARIABLE THAT SHOULD MOVED TO SCREEN MEMBER OR SOMETHING */
|
||||
TransInfo trans;
|
||||
int LastMode = TRANSLATION;
|
||||
TransInfo Trans;
|
||||
int LastMode = TFM_TRANSLATION;
|
||||
|
||||
/* ************************** Functions *************************** */
|
||||
|
||||
@@ -132,8 +132,8 @@ int allocTransData()
|
||||
return count;
|
||||
}
|
||||
|
||||
trans.total = count;
|
||||
trans.data= MEM_mallocN(trans.total*sizeof(TransData), "TransObData(EditMode)");
|
||||
Trans.total = count;
|
||||
Trans.data= MEM_mallocN(Trans.total*sizeof(TransData), "TransObData(EditMode)");
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -143,22 +143,22 @@ void createTransArmatureVerts()
|
||||
TransData *tv;
|
||||
float mtx[3][3], smtx[3][3];
|
||||
|
||||
trans.total = 0;
|
||||
Trans.total = 0;
|
||||
for (ebo=G.edbo.first;ebo;ebo=ebo->next){
|
||||
if (ebo->flag & BONE_TIPSEL){
|
||||
trans.total++;
|
||||
Trans.total++;
|
||||
}
|
||||
if (ebo->flag & BONE_ROOTSEL){
|
||||
trans.total++;
|
||||
Trans.total++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!trans.total) return;
|
||||
if (!Trans.total) return;
|
||||
|
||||
Mat3CpyMat4(mtx, G.obedit->obmat);
|
||||
Mat3Inv(smtx, mtx);
|
||||
|
||||
tv = trans.data = MEM_mallocN(trans.total*sizeof(TransData), "TransEditBone");
|
||||
tv = Trans.data = MEM_mallocN(Trans.total*sizeof(TransData), "TransEditBone");
|
||||
|
||||
Mat3CpyMat4(mtx, G.obedit->obmat);
|
||||
Mat3Inv(smtx, mtx);
|
||||
@@ -211,7 +211,7 @@ void createTransMBallVerts()
|
||||
Mat3CpyMat4(mtx, G.obedit->obmat);
|
||||
Mat3Inv(smtx, mtx);
|
||||
|
||||
tv = trans.data;
|
||||
tv = Trans.data;
|
||||
ml= editelems.first;
|
||||
while(ml) {
|
||||
if(ml->flag & SELECT) {
|
||||
@@ -256,7 +256,7 @@ void createTransCurveVerts()
|
||||
Mat3CpyMat4(mtx, G.obedit->obmat);
|
||||
Mat3Inv(smtx, mtx);
|
||||
|
||||
tv = trans.data;
|
||||
tv = Trans.data;
|
||||
nu= editNurb.first;
|
||||
while(nu) {
|
||||
if((nu->type & 7)==CU_BEZIER) {
|
||||
@@ -366,7 +366,7 @@ void createTransLatticeVerts()
|
||||
Mat3CpyMat4(mtx, G.obedit->obmat);
|
||||
Mat3Inv(smtx, mtx);
|
||||
|
||||
tv = trans.data;
|
||||
tv = Trans.data;
|
||||
bp= editLatt->def;
|
||||
a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
|
||||
while(a--) {
|
||||
@@ -419,7 +419,7 @@ void createTransEditVerts()
|
||||
for(eve= em->verts.first; eve; eve= eve->next) {
|
||||
if(eve->h==0 && (eve->f & SELECT)) {
|
||||
eve->f1= SELECT;
|
||||
trans.total++;
|
||||
Trans.total++;
|
||||
}
|
||||
else
|
||||
eve->f1= 0;
|
||||
@@ -434,7 +434,7 @@ void createTransEditVerts()
|
||||
}
|
||||
for(eve= em->verts.first; eve; eve= eve->next)
|
||||
if(eve->f1)
|
||||
trans.total++;
|
||||
Trans.total++;
|
||||
}
|
||||
else {
|
||||
EditFace *efa;
|
||||
@@ -447,28 +447,27 @@ void createTransEditVerts()
|
||||
}
|
||||
for(eve= em->verts.first; eve; eve= eve->next)
|
||||
if(eve->f1)
|
||||
trans.total++;
|
||||
Trans.total++;
|
||||
}
|
||||
|
||||
totsel = trans.total;
|
||||
totsel = Trans.total;
|
||||
/* proportional edit exception... */
|
||||
if((G.f & G_PROPORTIONAL) && trans.total) {
|
||||
if((G.f & G_PROPORTIONAL) && Trans.total) {
|
||||
for(eve= em->verts.first; eve; eve= eve->next) {
|
||||
if(eve->h==0 && (!(eve->f1 & SELECT))) {
|
||||
eve->f1 = 2;
|
||||
trans.total++;
|
||||
Trans.total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* and now make transverts */
|
||||
|
||||
if (!trans.total) return;
|
||||
if (!Trans.total) return;
|
||||
|
||||
Mat3CpyMat4(mtx, G.obedit->obmat);
|
||||
Mat3Inv(smtx, mtx);
|
||||
|
||||
tob = trans.data = MEM_mallocN(trans.total*sizeof(TransData), "TransEditVert");
|
||||
tob = Trans.data = MEM_mallocN(Trans.total*sizeof(TransData), "TransEditVert");
|
||||
|
||||
for (eve=em->verts.first; eve; eve=eve->next)
|
||||
{
|
||||
@@ -502,7 +501,7 @@ void createTransEditVerts()
|
||||
|
||||
tob->dist = -1;
|
||||
|
||||
td = trans.data;
|
||||
td = Trans.data;
|
||||
for (i = 0; i < totsel; i++, td++) {
|
||||
VecSubf(vec, tob->center, td->center);
|
||||
Mat3MulVecfl(mtx, vec);
|
||||
@@ -573,22 +572,22 @@ void createTransObject()
|
||||
base= FIRSTBASE;
|
||||
while(base) {
|
||||
if TESTBASELIB(base) {
|
||||
trans.total++;
|
||||
Trans.total++;
|
||||
totsel++;
|
||||
}
|
||||
else if (G.f & G_PROPORTIONAL) {
|
||||
ob= base->object;
|
||||
if (G.vd->lay & ob->lay) {
|
||||
trans.total++;
|
||||
Trans.total++;
|
||||
}
|
||||
}
|
||||
base= base->next;
|
||||
}
|
||||
|
||||
if(!trans.total)
|
||||
if(!Trans.total)
|
||||
return;
|
||||
|
||||
tob = trans.data = MEM_mallocN(trans.total*sizeof(TransData), "TransOb");
|
||||
tob = Trans.data = MEM_mallocN(Trans.total*sizeof(TransData), "TransOb");
|
||||
|
||||
base= FIRSTBASE;
|
||||
while(base) {
|
||||
@@ -627,7 +626,7 @@ void createTransObject()
|
||||
|
||||
tob->dist = -1;
|
||||
|
||||
td = trans.data;
|
||||
td = Trans.data;
|
||||
for (i = 0; i < totsel; i++, td++) {
|
||||
dist = VecLenf(tob->center, td->center);
|
||||
if (tob->dist == -1) {
|
||||
@@ -652,14 +651,14 @@ void createTransObject()
|
||||
THERE MUST BE A BETTER WAY TO DO THIS
|
||||
*/
|
||||
|
||||
tob = trans.data;
|
||||
for (i = 0; i < trans.total; i++, tob++) {
|
||||
tob = Trans.data;
|
||||
for (i = 0; i < Trans.total; i++, tob++) {
|
||||
ob = tob->ob->parent;
|
||||
while (ob) {
|
||||
TransData *td;
|
||||
int j, found = 0;
|
||||
td = trans.data;
|
||||
for (j = 0; j < trans.total; j++, td++) {
|
||||
td = Trans.data;
|
||||
for (j = 0; j < Trans.total; j++, td++) {
|
||||
if (ob == td->ob) {
|
||||
found = 1;
|
||||
tob->flag |= TD_NOACTION;
|
||||
@@ -722,45 +721,45 @@ void Transform(int mode) {
|
||||
|
||||
/* stupid PET initialisation code */
|
||||
/* START */
|
||||
if (trans.propsize == 0.0f) {
|
||||
trans.propsize = 1.0;
|
||||
if (Trans.propsize == 0.0f) {
|
||||
Trans.propsize = 1.0;
|
||||
}
|
||||
/* END */
|
||||
|
||||
if (mode == REPEAT) {
|
||||
if (mode == TFM_REPEAT) {
|
||||
mode = LastMode;
|
||||
}
|
||||
else {
|
||||
LastMode = mode;
|
||||
}
|
||||
|
||||
initTransModeFlags(&trans, mode);
|
||||
initTransModeFlags(&Trans, mode);
|
||||
|
||||
initTrans(&trans);
|
||||
initTrans(&Trans);
|
||||
|
||||
createTransData();
|
||||
|
||||
if (trans.total == 0)
|
||||
if (Trans.total == 0)
|
||||
return;
|
||||
|
||||
calculatePropRatio(&trans);
|
||||
calculateCenter(&trans);
|
||||
calculatePropRatio(&Trans);
|
||||
calculateCenter(&Trans);
|
||||
|
||||
switch (mode) {
|
||||
case TRANSLATION:
|
||||
initTranslation(&trans);
|
||||
case TFM_TRANSLATION:
|
||||
initTranslation(&Trans);
|
||||
break;
|
||||
case ROTATION:
|
||||
initRotation(&trans);
|
||||
case TFM_ROTATION:
|
||||
initRotation(&Trans);
|
||||
break;
|
||||
case RESIZE:
|
||||
initResize(&trans);
|
||||
case TFM_RESIZE:
|
||||
initResize(&Trans);
|
||||
break;
|
||||
case TOSPHERE:
|
||||
initToSphere(&trans);
|
||||
case TFM_TOSPHERE:
|
||||
initToSphere(&Trans);
|
||||
break;
|
||||
case SHEAR:
|
||||
initShear(&trans);
|
||||
case TFM_SHEAR:
|
||||
initShear(&Trans);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -769,21 +768,21 @@ void Transform(int mode) {
|
||||
event= extern_qread(&val);
|
||||
}
|
||||
|
||||
trans.redraw = 1;
|
||||
Trans.redraw = 1;
|
||||
|
||||
while (ret_val == 0) {
|
||||
getmouseco_areawin(mval);
|
||||
if (mval[0] != pmval[0] || mval[1] != pmval[1]) {
|
||||
trans.redraw = 1;
|
||||
Trans.redraw = 1;
|
||||
}
|
||||
if (trans.redraw) {
|
||||
if (Trans.redraw) {
|
||||
pmval[0] = mval[0];
|
||||
pmval[1] = mval[1];
|
||||
|
||||
if (trans.transform) {
|
||||
trans.transform(&trans, mval);
|
||||
if (Trans.transform) {
|
||||
Trans.transform(&Trans, mval);
|
||||
}
|
||||
trans.redraw = 0;
|
||||
Trans.redraw = 0;
|
||||
}
|
||||
while( qtest() ) {
|
||||
event= extern_qread(&val);
|
||||
@@ -791,8 +790,8 @@ void Transform(int mode) {
|
||||
if(val) {
|
||||
switch (event){
|
||||
case MIDDLEMOUSE:
|
||||
selectConstraint(&trans);
|
||||
trans.redraw = 1;
|
||||
selectConstraint(&Trans);
|
||||
Trans.redraw = 1;
|
||||
break;
|
||||
case ESCKEY:
|
||||
case RIGHTMOUSE:
|
||||
@@ -808,61 +807,61 @@ void Transform(int mode) {
|
||||
case SKEY:
|
||||
case RKEY:
|
||||
if (G.qual == LR_CTRLKEY)
|
||||
applyTransObjects(&trans);
|
||||
applyTransObjects(&Trans);
|
||||
else
|
||||
restoreTransObjects(&trans);
|
||||
restoreTransObjects(&Trans);
|
||||
break;
|
||||
case XKEY:
|
||||
if (G.qual == 0)
|
||||
setConstraint(&trans, MatI, (APPLYCON|CONAXIS0));
|
||||
setConstraint(&Trans, MatI, (APPLYCON|CONAXIS0));
|
||||
else if (G.qual == LR_CTRLKEY)
|
||||
setConstraint(&trans, MatI, (APPLYCON|CONAXIS1|CONAXIS2));
|
||||
setConstraint(&Trans, MatI, (APPLYCON|CONAXIS1|CONAXIS2));
|
||||
break;
|
||||
case YKEY:
|
||||
if (G.qual == 0)
|
||||
setConstraint(&trans, MatI, (APPLYCON|CONAXIS1));
|
||||
setConstraint(&Trans, MatI, (APPLYCON|CONAXIS1));
|
||||
else if (G.qual == LR_CTRLKEY)
|
||||
setConstraint(&trans, MatI, (APPLYCON|CONAXIS0|CONAXIS2));
|
||||
setConstraint(&Trans, MatI, (APPLYCON|CONAXIS0|CONAXIS2));
|
||||
break;
|
||||
case ZKEY:
|
||||
if (G.qual == 0)
|
||||
setConstraint(&trans, MatI, (APPLYCON|CONAXIS2));
|
||||
setConstraint(&Trans, MatI, (APPLYCON|CONAXIS2));
|
||||
else if (G.qual == LR_CTRLKEY)
|
||||
setConstraint(&trans, MatI, (APPLYCON|CONAXIS0|CONAXIS1));
|
||||
setConstraint(&Trans, MatI, (APPLYCON|CONAXIS0|CONAXIS1));
|
||||
break;
|
||||
case OKEY:
|
||||
if (G.qual==LR_SHIFTKEY) {
|
||||
extern int prop_mode;
|
||||
prop_mode = (prop_mode+1)%5;
|
||||
calculatePropRatio(&trans);
|
||||
trans.redraw= 1;
|
||||
calculatePropRatio(&Trans);
|
||||
Trans.redraw= 1;
|
||||
}
|
||||
break;
|
||||
case WHEELDOWNMOUSE:
|
||||
case PADPLUSKEY:
|
||||
if(G.f & G_PROPORTIONAL) {
|
||||
trans.propsize*= 1.1f;
|
||||
calculatePropRatio(&trans);
|
||||
trans.redraw= 1;
|
||||
Trans.propsize*= 1.1f;
|
||||
calculatePropRatio(&Trans);
|
||||
Trans.redraw= 1;
|
||||
}
|
||||
break;
|
||||
case WHEELUPMOUSE:
|
||||
case PADMINUS:
|
||||
if(G.f & G_PROPORTIONAL) {
|
||||
trans.propsize*= 0.90909090f;
|
||||
calculatePropRatio(&trans);
|
||||
trans.redraw= 1;
|
||||
Trans.propsize*= 0.90909090f;
|
||||
calculatePropRatio(&Trans);
|
||||
Trans.redraw= 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
trans.redraw |= handleNumInput(&(trans.num), event);
|
||||
Trans.redraw |= handleNumInput(&(Trans.num), event);
|
||||
arrows_move_cursor(event);
|
||||
}
|
||||
else {
|
||||
switch (event){
|
||||
case MIDDLEMOUSE:
|
||||
chooseConstraint(&trans);
|
||||
trans.redraw = 1;
|
||||
chooseConstraint(&Trans);
|
||||
Trans.redraw = 1;
|
||||
break;
|
||||
case LEFTMOUSE:
|
||||
case RIGHTMOUSE:
|
||||
@@ -874,13 +873,13 @@ void Transform(int mode) {
|
||||
}
|
||||
|
||||
if(ret_val == TRANS_CANCEL) {
|
||||
restoreTransObjects(&trans);
|
||||
restoreTransObjects(&Trans);
|
||||
}
|
||||
else {
|
||||
BIF_undo_push("Transform");
|
||||
}
|
||||
|
||||
postTrans(&trans);
|
||||
postTrans(&Trans);
|
||||
}
|
||||
|
||||
/* ************************** WRAP *************************** */
|
||||
@@ -1000,11 +999,11 @@ int Shear(TransInfo *t, short mval[2]) {
|
||||
/* ************************** RESIZE *************************** */
|
||||
|
||||
void initResize(TransInfo *t) {
|
||||
trans.fac = (float)sqrt( (float)
|
||||
Trans.fac = (float)sqrt( (float)
|
||||
(
|
||||
(trans.center2d[1] - trans.imval[1])*(trans.center2d[1] - trans.imval[1])
|
||||
(Trans.center2d[1] - Trans.imval[1])*(Trans.center2d[1] - Trans.imval[1])
|
||||
+
|
||||
(trans.center2d[0] - trans.imval[0])*(trans.center2d[0] - trans.imval[0])
|
||||
(Trans.center2d[0] - Trans.imval[0])*(Trans.center2d[0] - Trans.imval[0])
|
||||
) );
|
||||
|
||||
t->num.idx_max = 2;
|
||||
@@ -1110,11 +1109,11 @@ void initToSphere(TransInfo *t) {
|
||||
|
||||
t->val /= (float)t->total;
|
||||
|
||||
trans.fac = (float)sqrt( (float)
|
||||
Trans.fac = (float)sqrt( (float)
|
||||
(
|
||||
(trans.center2d[1] - trans.imval[1])*(trans.center2d[1] - trans.imval[1])
|
||||
(Trans.center2d[1] - Trans.imval[1])*(Trans.center2d[1] - Trans.imval[1])
|
||||
+
|
||||
(trans.center2d[0] - trans.imval[0])*(trans.center2d[0] - trans.imval[0])
|
||||
(Trans.center2d[0] - Trans.imval[0])*(Trans.center2d[0] - Trans.imval[0])
|
||||
) );
|
||||
|
||||
t->num.idx_max = 0;
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#define TRANSFORM_H
|
||||
|
||||
#include "transform_numinput.h"
|
||||
#include "BIF_transform.h"
|
||||
|
||||
/* ************************** Types ***************************** */
|
||||
|
||||
@@ -94,8 +95,6 @@ typedef struct TransInfo {
|
||||
|
||||
/* ******************** Macros & Prototypes *********************** */
|
||||
|
||||
//#define NEWTRANSFORM
|
||||
|
||||
/* MODE AND NUMINPUT FLAGS */
|
||||
#define NOCONSTRAINT 1
|
||||
#define NULLONE 2
|
||||
@@ -104,12 +103,13 @@ typedef struct TransInfo {
|
||||
#define NOFRACTION 16
|
||||
|
||||
|
||||
#define REPEAT 0
|
||||
#define TRANSLATION 1
|
||||
#define ROTATION 2
|
||||
#define RESIZE 3
|
||||
#define TOSPHERE 4
|
||||
#define SHEAR 5
|
||||
#define TFM_REPEAT 0
|
||||
#define TFM_TRANSLATION 1
|
||||
#define TFM_ROTATION 2
|
||||
#define TFM_RESIZE 3
|
||||
#define TFM_TOSPHERE 4
|
||||
#define TFM_SHEAR 5
|
||||
#define TFM_LAMP_ENERGY 6
|
||||
|
||||
#define APPLYCON 1
|
||||
#define CONAXIS0 2
|
||||
|
||||
@@ -111,8 +111,6 @@ extern ListBase editelems;
|
||||
|
||||
void recalcData();
|
||||
|
||||
extern TransInfo trans;
|
||||
|
||||
/* ************************** CONSTRAINTS ************************* */
|
||||
void getConstraintMatrix(TransInfo *t);
|
||||
|
||||
@@ -196,6 +194,7 @@ void applyAxisConstraintVec(TransInfo *t, TransData *td, float in[3], float out[
|
||||
* This insures that the rotation is always logically following the mouse.
|
||||
* (ie: not doing counterclockwise rotations when the mouse moves clockwise).
|
||||
*/
|
||||
|
||||
void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3])
|
||||
{
|
||||
if (!td && t->con.mode & APPLYCON) {
|
||||
@@ -228,6 +227,7 @@ void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3])
|
||||
* even if they aren't actually used in the callback function. (Which could happen
|
||||
* for weird constraints not yet designed. Along a path for example.)
|
||||
*/
|
||||
|
||||
int getConstraintSpaceDimension(TransInfo *t)
|
||||
{
|
||||
int n = 0;
|
||||
@@ -244,6 +244,32 @@ int getConstraintSpaceDimension(TransInfo *t)
|
||||
return n;
|
||||
}
|
||||
|
||||
void BIF_setSingleAxisConstraint(float vec[3]) {
|
||||
TransInfo *t = BIF_GetTransInfo();
|
||||
float space[3][3], v[3];
|
||||
VECCOPY(space[0], vec);
|
||||
|
||||
v[0] = vec[2];
|
||||
v[1] = vec[0];
|
||||
v[2] = vec[1];
|
||||
|
||||
Crossf(space[1], vec, v);
|
||||
Crossf(space[2], vec, space[1]);
|
||||
|
||||
Mat3CpyMat3(t->con.mtx, space);
|
||||
t->con.mode = (CONAXIS0|APPLYCON);
|
||||
getConstraintMatrix(t);
|
||||
|
||||
VECCOPY(t->con.center, t->center);
|
||||
if (G.obedit) {
|
||||
Mat4MulVecfl(G.obedit->obmat, t->con.center);
|
||||
}
|
||||
|
||||
t->con.applyVec = applyAxisConstraintVec;
|
||||
t->con.applyRot = applyAxisConstraintRot;
|
||||
t->redraw = 1;
|
||||
}
|
||||
|
||||
void setConstraint(TransInfo *t, float space[3][3], int mode) {
|
||||
Mat3CpyMat3(t->con.mtx, space);
|
||||
t->con.mode = mode;
|
||||
@@ -259,44 +285,44 @@ void setConstraint(TransInfo *t, float space[3][3], int mode) {
|
||||
t->redraw = 1;
|
||||
}
|
||||
|
||||
//void drawConstraint(TransCon *t) {
|
||||
void drawConstraint() {
|
||||
void BIF_drawConstraint()
|
||||
{
|
||||
int i = -1;
|
||||
TransCon *t = &(trans.con);
|
||||
TransInfo *t = BIF_GetTransInfo();
|
||||
TransCon *tc = &(t->con);
|
||||
|
||||
if (t->mode == 0)
|
||||
if (tc->mode == 0)
|
||||
return;
|
||||
|
||||
if (!(t->mode & APPLYCON)) {
|
||||
i = nearestAxisIndex(&trans);
|
||||
if (!(tc->mode & APPLYCON)) {
|
||||
i = nearestAxisIndex(t);
|
||||
}
|
||||
|
||||
if (t->mode & CONAXIS0) {
|
||||
if (tc->mode & CONAXIS0) {
|
||||
if (i == 0)
|
||||
drawLine(t->center, t->mtx[0], 255 - 'x');
|
||||
drawLine(tc->center, tc->mtx[0], 255 - 'x');
|
||||
else
|
||||
drawLine(t->center, t->mtx[0], 'x');
|
||||
drawLine(tc->center, tc->mtx[0], 'x');
|
||||
}
|
||||
if (t->mode & CONAXIS1) {
|
||||
if (tc->mode & CONAXIS1) {
|
||||
if (i == 1)
|
||||
drawLine(t->center, t->mtx[1], 255 - 'y');
|
||||
drawLine(tc->center, tc->mtx[1], 255 - 'y');
|
||||
else
|
||||
drawLine(t->center, t->mtx[1], 'y');
|
||||
drawLine(tc->center, tc->mtx[1], 'y');
|
||||
}
|
||||
if (t->mode & CONAXIS2) {
|
||||
if (tc->mode & CONAXIS2) {
|
||||
if (i == 2)
|
||||
drawLine(t->center, t->mtx[2], 255 - 'z');
|
||||
drawLine(tc->center, tc->mtx[2], 255 - 'z');
|
||||
else
|
||||
drawLine(t->center, t->mtx[2], 'z');
|
||||
drawLine(tc->center, tc->mtx[2], 'z');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* called from drawview.c, as ane xtra per-window draw option */
|
||||
void drawPropCircle()
|
||||
//void drawPropCircle(TransInfo *t)
|
||||
void BIF_drawPropCircle()
|
||||
{
|
||||
TransInfo *t = &trans;
|
||||
TransInfo *t = BIF_GetTransInfo();
|
||||
|
||||
if (G.f & G_PROPORTIONAL) {
|
||||
float tmat[4][4], imat[4][4];
|
||||
|
||||
@@ -107,7 +107,7 @@ extern ListBase editNurb;
|
||||
extern ListBase editelems;
|
||||
|
||||
/* GLOBAL VARIABLE THAT SHOULD MOVED TO SCREEN MEMBER OR SOMETHING */
|
||||
extern TransInfo trans;
|
||||
extern TransInfo Trans;
|
||||
|
||||
/* ************************** Functions *************************** */
|
||||
|
||||
@@ -152,23 +152,23 @@ void initTransModeFlags(TransInfo *t, int mode) {
|
||||
t->flags = 0;
|
||||
t->num.flags = 0;
|
||||
switch (mode) {
|
||||
case TRANSLATION:
|
||||
case TFM_TRANSLATION:
|
||||
break;
|
||||
case ROTATION:
|
||||
case TFM_ROTATION:
|
||||
break;
|
||||
case RESIZE:
|
||||
case TFM_RESIZE:
|
||||
t->num.flags |= NULLONE;
|
||||
if (!G.obedit) {
|
||||
t->flags |= NOZERO;
|
||||
t->num.flags |= NOZERO;
|
||||
}
|
||||
break;
|
||||
case TOSPHERE:
|
||||
case TFM_TOSPHERE:
|
||||
t->num.flags |= NULLONE;
|
||||
t->num.flags |= NONEGATIVE;
|
||||
t->flags |= NOCONSTRAINT;
|
||||
break;
|
||||
case SHEAR:
|
||||
case TFM_SHEAR:
|
||||
t->flags |= NOCONSTRAINT;
|
||||
break;
|
||||
}
|
||||
@@ -497,3 +497,7 @@ void calculatePropRatio(TransInfo *t)
|
||||
strcpy(t->proptext, "");
|
||||
}
|
||||
}
|
||||
|
||||
TransInfo * BIF_GetTransInfo() {
|
||||
return &Trans;
|
||||
}
|
||||
@@ -58,6 +58,7 @@ void calculateCenter(TransInfo *t);
|
||||
|
||||
void calculatePropRatio(TransInfo *t);
|
||||
|
||||
TransInfo * BIF_GetTransInfo();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user