style cleanup

This commit is contained in:
2012-06-10 22:13:17 +00:00
parent 3d88176269
commit 869efe927c
8 changed files with 770 additions and 767 deletions

View File

@@ -1607,7 +1607,7 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
t->state = TRANS_STARTING;
if ( (prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) {
if ((prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) {
if (RNA_property_boolean_get(op->ptr, prop)) {
options |= CTX_TEXTURE;
}
@@ -2071,7 +2071,9 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
mul_qt_fl(quat, qlen);
/* quaternions flip w sign to accumulate rotations correctly */
if ( (nquat[0] < 0.0f && quat[0] > 0.0f) || (nquat[0] > 0.0f && quat[0] < 0.0f) ) {
if ((nquat[0] < 0.0f && quat[0] > 0.0f) ||
(nquat[0] > 0.0f && quat[0] < 0.0f))
{
mul_qt_fl(quat, -1.0f);
}
}
@@ -2818,9 +2820,9 @@ int Resize(TransInfo *t, const int mval[2])
float ratio;
int i;
char str[200];
/* for manipulator, center handle, the scaling can't be done relative to center */
if ( (t->flag & T_USES_MANIPULATOR) && t->con.mode == 0) {
if ((t->flag & T_USES_MANIPULATOR) && t->con.mode == 0) {
ratio = 1.0f - ((t->imval[0] - mval[0]) + (t->imval[1] - mval[1])) / 100.0f;
}
else {

View File

@@ -77,7 +77,7 @@ static void constraintAutoValues(TransInfo *t, float vec[3])
{
int mode = t->con.mode;
if (mode & CON_APPLY) {
float nval = (t->flag & T_NULL_ONE)?1.0f:0.0f;
float nval = (t->flag & T_NULL_ONE) ? 1.0f : 0.0f;
if ((mode & CON_AXIS0) == 0) {
vec[0] = nval;
@@ -95,21 +95,21 @@ void constraintNumInput(TransInfo *t, float vec[3])
{
int mode = t->con.mode;
if (mode & CON_APPLY) {
float nval = (t->flag & T_NULL_ONE)?1.0f:0.0f;
float nval = (t->flag & T_NULL_ONE) ? 1.0f : 0.0f;
if (getConstraintSpaceDimension(t) == 2) {
int axis = mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
if (axis == (CON_AXIS0|CON_AXIS1)) {
int axis = mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
if (axis == (CON_AXIS0 | CON_AXIS1)) {
/* vec[0] = vec[0]; */ /* same */
/* vec[1] = vec[1]; */ /* same */
vec[2] = nval;
}
else if (axis == (CON_AXIS1|CON_AXIS2)) {
else if (axis == (CON_AXIS1 | CON_AXIS2)) {
vec[2] = vec[1];
vec[1] = vec[0];
vec[0] = nval;
}
else if (axis == (CON_AXIS0|CON_AXIS2)) {
else if (axis == (CON_AXIS0 | CON_AXIS2)) {
/* vec[0] = vec[0]; */ /* same */
vec[2] = vec[1];
vec[1] = nval;
@@ -184,7 +184,7 @@ static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3])
{
if (t->spacetype == SPACE_VIEW3D) {
// View3D *v3d = t->sa->spacedata.first;
const float min_dist= 1.0f; // v3d->near;
const float min_dist = 1.0f; /* v3d->near; */
float dir[3];
float l;
@@ -194,7 +194,7 @@ static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3])
}
project_v3_v3v3(dir, dir, t->viewinv[2]);
l= len_v3(dir);
l = len_v3(dir);
if (l < min_dist) {
float diff[3];
@@ -211,7 +211,7 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
float norm[3], vec[3], factor, angle;
float t_con_center[3];
if (in[0]==0.0f && in[1]==0.0f && in[2]==0.0f)
if (in[0] == 0.0f && in[1] == 0.0f && in[2] == 0.0f)
return;
copy_v3_v3(t_con_center, t->con.center);
@@ -232,12 +232,12 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
project_v3_v3v3(vec, in, t->viewinv[1]);
factor = dot_v3v3(t->viewinv[1], vec) * 2.0f;
/* since camera distance is quite relative, use quadratic relationship. holding shift can compensate */
if (factor<0.0f) factor*= -factor;
else factor*= factor;
if (factor < 0.0f) factor *= -factor;
else factor *= factor;
copy_v3_v3(out, axis);
normalize_v3(out);
mul_v3_fl(out, -factor); /* -factor makes move down going backwards */
mul_v3_fl(out, -factor); /* -factor makes move down going backwards */
}
else {
float v[3], i1[3], i2[3];
@@ -276,10 +276,10 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3
sub_v3_v3v3(out, i1, t_con_center);
/* possible some values become nan when
* viewpoint and object are both zero */
if (!finite(out[0])) out[0]= 0.0f;
if (!finite(out[1])) out[1]= 0.0f;
if (!finite(out[2])) out[2]= 0.0f;
* viewpoint and object are both zero */
if (!finite(out[0])) out[0] = 0.0f;
if (!finite(out[1])) out[1] = 0.0f;
if (!finite(out[2])) out[2] = 0.0f;
}
}
}
@@ -386,7 +386,7 @@ static void applyObjectConstraintVec(TransInfo *t, TransData *td, float in[3], f
copy_v3_v3(out, pvec);
}
else {
int i=0;
int i = 0;
out[0] = out[1] = out[2] = 0.0f;
if (t->con.mode & CON_AXIS0) {
@@ -475,21 +475,21 @@ static void applyObjectConstraintSize(TransInfo *t, TransData *td, float smat[3]
static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle)
{
if (!td && t->con.mode & CON_APPLY) {
int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
switch (mode) {
case CON_AXIS0:
case (CON_AXIS1|CON_AXIS2):
copy_v3_v3(vec, t->con.mtx[0]);
break;
case CON_AXIS1:
case (CON_AXIS0|CON_AXIS2):
copy_v3_v3(vec, t->con.mtx[1]);
break;
case CON_AXIS2:
case (CON_AXIS0|CON_AXIS1):
copy_v3_v3(vec, t->con.mtx[2]);
break;
case CON_AXIS0:
case (CON_AXIS1 | CON_AXIS2):
copy_v3_v3(vec, t->con.mtx[0]);
break;
case CON_AXIS1:
case (CON_AXIS0 | CON_AXIS2):
copy_v3_v3(vec, t->con.mtx[1]);
break;
case CON_AXIS2:
case (CON_AXIS0 | CON_AXIS1):
copy_v3_v3(vec, t->con.mtx[2]);
break;
}
/* don't flip axis if asked to or if num input */
if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) {
@@ -517,26 +517,26 @@ static void applyAxisConstraintRot(TransInfo *t, TransData *td, float vec[3], fl
static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3], float *angle)
{
if (t->con.mode & CON_APPLY) {
int mode = t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2);
int mode = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
/* on setup call, use first object */
if (td == NULL) {
td= t->data;
td = t->data;
}
switch (mode) {
case CON_AXIS0:
case (CON_AXIS1|CON_AXIS2):
copy_v3_v3(vec, td->axismtx[0]);
break;
case CON_AXIS1:
case (CON_AXIS0|CON_AXIS2):
copy_v3_v3(vec, td->axismtx[1]);
break;
case CON_AXIS2:
case (CON_AXIS0|CON_AXIS1):
copy_v3_v3(vec, td->axismtx[2]);
break;
case CON_AXIS0:
case (CON_AXIS1 | CON_AXIS2):
copy_v3_v3(vec, td->axismtx[0]);
break;
case CON_AXIS1:
case (CON_AXIS0 | CON_AXIS2):
copy_v3_v3(vec, td->axismtx[1]);
break;
case CON_AXIS2:
case (CON_AXIS0 | CON_AXIS1):
copy_v3_v3(vec, td->axismtx[2]);
break;
}
if (angle && (mode & CON_NOFLIP) == 0 && hasNumInput(&t->num) == 0) {
if (dot_v3v3(vec, t->viewinv[2]) > 0.0f) {
@@ -604,33 +604,33 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
char text[40];
switch (orientation) {
case V3D_MANIP_GLOBAL:
case V3D_MANIP_GLOBAL:
{
float mtx[3][3]= MAT3_UNITY;
float mtx[3][3] = MAT3_UNITY;
BLI_snprintf(text, sizeof(text), ftext, "global");
setConstraint(t, mtx, mode, text);
}
break;
case V3D_MANIP_LOCAL:
BLI_snprintf(text, sizeof(text), ftext, "local");
setLocalConstraint(t, mode, text);
break;
case V3D_MANIP_NORMAL:
BLI_snprintf(text, sizeof(text), ftext, "normal");
setConstraint(t, t->spacemtx, mode, text);
break;
case V3D_MANIP_VIEW:
BLI_snprintf(text, sizeof(text), ftext, "view");
setConstraint(t, t->spacemtx, mode, text);
break;
case V3D_MANIP_GIMBAL:
BLI_snprintf(text, sizeof(text), ftext, "gimbal");
setConstraint(t, t->spacemtx, mode, text);
break;
default: /* V3D_MANIP_CUSTOM */
BLI_snprintf(text, sizeof(text), ftext, t->spacename);
setConstraint(t, t->spacemtx, mode, text);
break;
case V3D_MANIP_LOCAL:
BLI_snprintf(text, sizeof(text), ftext, "local");
setLocalConstraint(t, mode, text);
break;
case V3D_MANIP_NORMAL:
BLI_snprintf(text, sizeof(text), ftext, "normal");
setConstraint(t, t->spacemtx, mode, text);
break;
case V3D_MANIP_VIEW:
BLI_snprintf(text, sizeof(text), ftext, "view");
setConstraint(t, t->spacemtx, mode, text);
break;
case V3D_MANIP_GIMBAL:
BLI_snprintf(text, sizeof(text), ftext, "gimbal");
setConstraint(t, t->spacemtx, mode, text);
break;
default: /* V3D_MANIP_CUSTOM */
BLI_snprintf(text, sizeof(text), ftext, t->spacename);
setConstraint(t, t->spacemtx, mode, text);
break;
}
t->con.orientation = orientation;
@@ -682,8 +682,8 @@ void drawConstraint(TransInfo *t)
setlinestyle(1);
glBegin(GL_LINE_STRIP);
glVertex3fv(tc->center);
glVertex3fv(vec);
glVertex3fv(tc->center);
glVertex3fv(vec);
glEnd();
setlinestyle(0);
@@ -733,7 +733,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
float aspx, aspy;
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
glScalef(1.0f/aspx, 1.0f/aspy, 1.0);
glScalef(1.0f / aspx, 1.0f / aspy, 1.0);
}
set_inverted_drawing(1);
@@ -747,7 +747,7 @@ void drawPropCircle(const struct bContext *C, TransInfo *t)
static void drawObjectConstraint(TransInfo *t)
{
int i;
TransData * td = t->data;
TransData *td = t->data;
/* Draw the first one lighter because that's the one who controls the others.
* Meaning the transformation is projected on that one and just copied on the others
@@ -767,7 +767,7 @@ static void drawObjectConstraint(TransInfo *t)
td++;
for (i=1; i < t->total; i++, td++) {
for (i = 1; i < t->total; i++, td++) {
if (t->con.mode & CON_AXIS0) {
drawLine(t, td->ob->obmat[3], td->axismtx[0], 'X', 0);
}
@@ -791,7 +791,7 @@ void startConstraint(TransInfo *t)
void stopConstraint(TransInfo *t)
{
t->con.mode &= ~(CON_APPLY|CON_SELECT);
t->con.mode &= ~(CON_APPLY | CON_SELECT);
*t->con.text = '\0';
t->num.idx_max = t->idx_max;
}
@@ -803,21 +803,21 @@ void getConstraintMatrix(TransInfo *t)
unit_m3(t->con.pmtx);
if (!(t->con.mode & CON_AXIS0)) {
t->con.pmtx[0][0] =
t->con.pmtx[0][1] =
t->con.pmtx[0][2] = 0.0f;
t->con.pmtx[0][0] =
t->con.pmtx[0][1] =
t->con.pmtx[0][2] = 0.0f;
}
if (!(t->con.mode & CON_AXIS1)) {
t->con.pmtx[1][0] =
t->con.pmtx[1][1] =
t->con.pmtx[1][2] = 0.0f;
t->con.pmtx[1][0] =
t->con.pmtx[1][1] =
t->con.pmtx[1][2] = 0.0f;
}
if (!(t->con.mode & CON_AXIS2)) {
t->con.pmtx[2][0] =
t->con.pmtx[2][1] =
t->con.pmtx[2][2] = 0.0f;
t->con.pmtx[2][0] =
t->con.pmtx[2][1] =
t->con.pmtx[2][2] = 0.0f;
}
mul_m3_m3m3(mat, t->con.pmtx, t->con.imtx);
@@ -866,7 +866,7 @@ void postSelectConstraint(TransInfo *t)
static void setNearestAxis2d(TransInfo *t)
{
/* no correction needed... just use whichever one is lower */
if ( abs(t->mval[0]-t->con.imval[0]) < abs(t->mval[1]-t->con.imval[1]) ) {
if (abs(t->mval[0] - t->con.imval[0]) < abs(t->mval[1] - t->con.imval[1]) ) {
t->con.mode |= CON_AXIS1;
BLI_snprintf(t->con.text, sizeof(t->con.text), " along Y axis");
}
@@ -895,10 +895,10 @@ static void setNearestAxis3d(TransInfo *t)
* of two 2D points 30 pixels apart (that's the last factor in the formula) after
* projecting them with window_to_3d_delta and then get the length of that vector.
*/
zfac= t->persmat[0][3]*t->center[0]+ t->persmat[1][3]*t->center[1]+ t->persmat[2][3]*t->center[2]+ t->persmat[3][3];
zfac = len_v3(t->persinv[0]) * 2.0f/t->ar->winx * zfac * 30.0f;
zfac = t->persmat[0][3] * t->center[0] + t->persmat[1][3] * t->center[1] + t->persmat[2][3] * t->center[2] + t->persmat[3][3];
zfac = len_v3(t->persinv[0]) * 2.0f / t->ar->winx * zfac * 30.0f;
for (i = 0; i<3; i++) {
for (i = 0; i < 3; i++) {
copy_v3_v3(axis, t->con.mtx[i]);
mul_v3_fl(axis, zfac);
@@ -922,7 +922,7 @@ static void setNearestAxis3d(TransInfo *t)
if (len[0] <= len[1] && len[0] <= len[2]) {
if (t->modifiers & MOD_CONSTRAINT_PLANE) {
t->con.mode |= (CON_AXIS1|CON_AXIS2);
t->con.mode |= (CON_AXIS1 | CON_AXIS2);
BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s X axis", t->spacename);
}
else {
@@ -932,7 +932,7 @@ static void setNearestAxis3d(TransInfo *t)
}
else if (len[1] <= len[0] && len[1] <= len[2]) {
if (t->modifiers & MOD_CONSTRAINT_PLANE) {
t->con.mode |= (CON_AXIS0|CON_AXIS2);
t->con.mode |= (CON_AXIS0 | CON_AXIS2);
BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Y axis", t->spacename);
}
else {
@@ -942,7 +942,7 @@ static void setNearestAxis3d(TransInfo *t)
}
else if (len[2] <= len[1] && len[2] <= len[0]) {
if (t->modifiers & MOD_CONSTRAINT_PLANE) {
t->con.mode |= (CON_AXIS0|CON_AXIS1);
t->con.mode |= (CON_AXIS0 | CON_AXIS1);
BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Z axis", t->spacename);
}
else {
@@ -976,21 +976,21 @@ void setNearestAxis(TransInfo *t)
char constraintModeToChar(TransInfo *t)
{
if ((t->con.mode & CON_APPLY)==0) {
if ((t->con.mode & CON_APPLY) == 0) {
return '\0';
}
switch (t->con.mode & (CON_AXIS0|CON_AXIS1|CON_AXIS2)) {
case (CON_AXIS0):
case (CON_AXIS1|CON_AXIS2):
return 'X';
case (CON_AXIS1):
case (CON_AXIS0|CON_AXIS2):
return 'Y';
case (CON_AXIS2):
case (CON_AXIS0|CON_AXIS1):
return 'Z';
default:
return '\0';
switch (t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2)) {
case (CON_AXIS0):
case (CON_AXIS1 | CON_AXIS2):
return 'X';
case (CON_AXIS1):
case (CON_AXIS0 | CON_AXIS2):
return 'Y';
case (CON_AXIS2):
case (CON_AXIS0 | CON_AXIS1):
return 'Z';
default:
return '\0';
}
}
@@ -999,13 +999,13 @@ int isLockConstraint(TransInfo *t)
{
int mode = t->con.mode;
if ( (mode & (CON_AXIS0|CON_AXIS1)) == (CON_AXIS0|CON_AXIS1))
if ((mode & (CON_AXIS0 | CON_AXIS1)) == (CON_AXIS0 | CON_AXIS1))
return 1;
if ( (mode & (CON_AXIS1|CON_AXIS2)) == (CON_AXIS1|CON_AXIS2))
if ((mode & (CON_AXIS1 | CON_AXIS2)) == (CON_AXIS1 | CON_AXIS2))
return 1;
if ( (mode & (CON_AXIS0|CON_AXIS2)) == (CON_AXIS0|CON_AXIS2))
if ((mode & (CON_AXIS0 | CON_AXIS2)) == (CON_AXIS0 | CON_AXIS2))
return 1;
return 0;

View File

@@ -1909,7 +1909,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, TransDataExtension *tx
// Setting normals
copy_v3_v3(td->axismtx[2], eve->no);
td->axismtx[0][0] =
td->axismtx[0][0] =
td->axismtx[0][1] =
td->axismtx[0][2] =
td->axismtx[1][0] =

View File

@@ -828,7 +828,7 @@ static void recalcData_view3d(TransInfo *t)
DAG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */
}
}
else if ( (t->flag & T_POSE) && t->poseobj) {
else if ((t->flag & T_POSE) && t->poseobj) {
Object *ob = t->poseobj;
bArmature *arm = ob->data;

View File

@@ -64,18 +64,18 @@ static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2],
/* calculate ratio for shiftkey pos, and for total, and blend these for precision */
dx = (float)(mi->center[0] - mi->precision_mval[0]);
dy = (float)(mi->center[1] - mi->precision_mval[1]);
ratio = (float)sqrt( dx*dx + dy*dy);
ratio = sqrtf(dx * dx + dy * dy);
dx= (float)(mi->center[0] - mval[0]);
dy= (float)(mi->center[1] - mval[1]);
precise_ratio = (float)sqrt( dx*dx + dy*dy);
dx = (float)(mi->center[0] - mval[0]);
dy = (float)(mi->center[1] - mval[1]);
precise_ratio = (float)sqrt(dx * dx + dy * dy);
ratio = (ratio + (precise_ratio - ratio) / 10.0f) / mi->factor;
}
else {
dx = (float)(mi->center[0] - mval[0]);
dy = (float)(mi->center[1] - mval[1]);
ratio = (float)sqrt( dx*dx + dy*dy) / mi->factor;
ratio = sqrtf(dx * dx + dy * dy) / mi->factor;
}
output[0] = ratio;
@@ -98,12 +98,12 @@ static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const int mval[
{
if (mi->precision) {
output[0] = ( mi->imval[1] - mi->precision_mval[1] ) + ( mi->precision_mval[1] - mval[1] ) * 0.1f;
output[1] = ( mi->precision_mval[0] - mi->imval[0] ) + ( mval[0] - mi->precision_mval[0] ) * 0.1f;
output[0] = (mi->imval[1] - mi->precision_mval[1]) + (mi->precision_mval[1] - mval[1]) * 0.1f;
output[1] = (mi->precision_mval[0] - mi->imval[0]) + (mval[0] - mi->precision_mval[0]) * 0.1f;
}
else {
output[0] = (float)( mi->imval[1] - mval[1] );
output[1] = (float)( mval[0] - mi->imval[0] );
output[0] = (float)(mi->imval[1] - mval[1]);
output[1] = (float)(mval[0] - mi->imval[0]);
}
output[0] *= mi->factor;
@@ -191,7 +191,7 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mva
dx = data[2] - data[0];
dy = data[3] - data[1];
length = sqrt(dx*dx + dy*dy);
length = sqrt(dx * dx + dy * dy);
if (mi->precision) {
/* deal with Shift key by adding motion / 10 to motion before shift press */
@@ -199,7 +199,7 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const int mva
mdx = (mi->precision_mval[0] + (float)(mval[0] - mi->precision_mval[0]) / 10.0f) - data[2];
mdy = (mi->precision_mval[1] + (float)(mval[1] - mi->precision_mval[1]) / 10.0f) - data[3];
distance = (length != 0.0) ? (mdx * dx + mdy * dy) / length: 0.0;
distance = (length != 0.0) ? (mdx * dx + mdy * dy) / length : 0.0;
}
else {
int mdx, mdy;
@@ -217,11 +217,11 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2],
{
double dx2 = mval[0] - mi->center[0];
double dy2 = mval[1] - mi->center[1];
double B = sqrt(dx2*dx2+dy2*dy2);
double B = sqrt(dx2 * dx2 + dy2 * dy2);
double dx1 = mi->imval[0] - mi->center[0];
double dy1 = mi->imval[1] - mi->center[1];
double A = sqrt(dx1*dx1+dy1*dy1);
double A = sqrt(dx1 * dx1 + dy1 * dy1);
double dx3 = mval[0] - mi->imval[0];
double dy3 = mval[1] - mi->imval[1];
@@ -237,7 +237,7 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2],
float dphi;
dphi = saacos((float)deler);
if ( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
if ((dx1 * dy2 - dx2 * dy1) > 0.0) dphi = -dphi;
/* If the angle is zero, because of lack of precision close to the 1.0 value in acos
* approximate the angle with the opposite side of the normalized triangle
@@ -256,12 +256,12 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2],
dx = dx1 - dx2;
dy = dy1 - dy2;
dphi = sqrt(dx*dx + dy*dy);
if ( (dx1*dy2-dx2*dy1)>0.0 ) dphi= -dphi;
dphi = sqrt(dx * dx + dy * dy);
if ((dx1 * dy2 - dx2 * dy1) > 0.0) dphi = -dphi;
}
if (mi->precision) {
dphi = dphi/30.0f;
dphi = dphi / 30.0f;
}
/* if no delta angle, don't update initial position */
@@ -295,7 +295,7 @@ static void calcSpringFactor(MouseInput *mi)
((float)(mi->center[0] - mi->imval[0])) * ((float)(mi->center[0] - mi->imval[0])));
if (mi->factor == 0.0f) {
mi->factor= 1.0f; /* prevent Inf */
mi->factor = 1.0f; /* prevent Inf */
}
}
@@ -307,68 +307,68 @@ void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode)
#if 0
if (mi->data) {
MEM_freeN(mi->data);
mi->data= NULL;
mi->data = NULL;
}
#endif
switch (mode) {
case INPUT_VECTOR:
mi->apply = InputVector;
t->helpline = HLP_NONE;
break;
case INPUT_SPRING:
calcSpringFactor(mi);
mi->apply = InputSpring;
t->helpline = HLP_SPRING;
break;
case INPUT_SPRING_FLIP:
calcSpringFactor(mi);
mi->apply = InputSpringFlip;
t->helpline = HLP_SPRING;
break;
case INPUT_ANGLE:
mi->data = MEM_callocN(sizeof(double), "angle accumulator");
mi->apply = InputAngle;
t->helpline = HLP_ANGLE;
break;
case INPUT_TRACKBALL:
/* factor has to become setting or so */
mi->factor = 0.01f;
mi->apply = InputTrackBall;
t->helpline = HLP_TRACKBALL;
break;
case INPUT_HORIZONTAL_RATIO:
mi->factor = (float)(mi->center[0] - mi->imval[0]);
mi->apply = InputHorizontalRatio;
t->helpline = HLP_HARROW;
break;
case INPUT_HORIZONTAL_ABSOLUTE:
mi->apply = InputHorizontalAbsolute;
t->helpline = HLP_HARROW;
break;
case INPUT_VERTICAL_RATIO:
mi->apply = InputVerticalRatio;
t->helpline = HLP_VARROW;
break;
case INPUT_VERTICAL_ABSOLUTE:
mi->apply = InputVerticalAbsolute;
t->helpline = HLP_VARROW;
break;
case INPUT_CUSTOM_RATIO:
mi->apply = InputCustomRatio;
t->helpline = HLP_NONE;
break;
case INPUT_NONE:
default:
mi->apply = NULL;
break;
case INPUT_VECTOR:
mi->apply = InputVector;
t->helpline = HLP_NONE;
break;
case INPUT_SPRING:
calcSpringFactor(mi);
mi->apply = InputSpring;
t->helpline = HLP_SPRING;
break;
case INPUT_SPRING_FLIP:
calcSpringFactor(mi);
mi->apply = InputSpringFlip;
t->helpline = HLP_SPRING;
break;
case INPUT_ANGLE:
mi->data = MEM_callocN(sizeof(double), "angle accumulator");
mi->apply = InputAngle;
t->helpline = HLP_ANGLE;
break;
case INPUT_TRACKBALL:
/* factor has to become setting or so */
mi->factor = 0.01f;
mi->apply = InputTrackBall;
t->helpline = HLP_TRACKBALL;
break;
case INPUT_HORIZONTAL_RATIO:
mi->factor = (float)(mi->center[0] - mi->imval[0]);
mi->apply = InputHorizontalRatio;
t->helpline = HLP_HARROW;
break;
case INPUT_HORIZONTAL_ABSOLUTE:
mi->apply = InputHorizontalAbsolute;
t->helpline = HLP_HARROW;
break;
case INPUT_VERTICAL_RATIO:
mi->apply = InputVerticalRatio;
t->helpline = HLP_VARROW;
break;
case INPUT_VERTICAL_ABSOLUTE:
mi->apply = InputVerticalAbsolute;
t->helpline = HLP_VARROW;
break;
case INPUT_CUSTOM_RATIO:
mi->apply = InputCustomRatio;
t->helpline = HLP_NONE;
break;
case INPUT_NONE:
default:
mi->apply = NULL;
break;
}
/* bootstrap mouse input with initial values */
applyMouseInput(t, mi, mi->imval, t->values);
}
void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float [3]))
void setInputPostFct(MouseInput *mi, void (*post)(struct TransInfo *, float[3]))
{
mi->post = post;
}
@@ -389,21 +389,21 @@ int handleMouseInput(TransInfo *t, MouseInput *mi, wmEvent *event)
int redraw = TREDRAW_NOTHING;
switch (event->type) {
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
if (event->val == KM_PRESS) {
t->modifiers |= MOD_PRECISION;
/* shift is modifier for higher precision transform
* store the mouse position where the normal movement ended */
copy_v2_v2_int(mi->precision_mval, event->mval);
mi->precision = 1;
}
else {
t->modifiers &= ~MOD_PRECISION;
mi->precision = 0;
}
redraw = TREDRAW_HARD;
break;
case LEFTSHIFTKEY:
case RIGHTSHIFTKEY:
if (event->val == KM_PRESS) {
t->modifiers |= MOD_PRECISION;
/* shift is modifier for higher precision transform
* store the mouse position where the normal movement ended */
copy_v2_v2_int(mi->precision_mval, event->mval);
mi->precision = 1;
}
else {
t->modifiers &= ~MOD_PRECISION;
mi->precision = 0;
}
redraw = TREDRAW_HARD;
break;
}
return redraw;

File diff suppressed because it is too large Load Diff

View File

@@ -75,16 +75,16 @@ void BIF_clearTransformOrientation(bContext *C)
// Need to loop over all view3d
if (v3d && v3d->twmode >= V3D_MANIP_CUSTOM) {
v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
}
}
static TransformOrientation* findOrientationName(ListBase *lb, const char *name)
static TransformOrientation *findOrientationName(ListBase *lb, const char *name)
{
TransformOrientation *ts= NULL;
TransformOrientation *ts = NULL;
for (ts= lb->first; ts; ts = ts->next) {
if (strncmp(ts->name, name, sizeof(ts->name)-1) == 0) {
for (ts = lb->first; ts; ts = ts->next) {
if (strncmp(ts->name, name, sizeof(ts->name) - 1) == 0) {
return ts;
}
}
@@ -115,7 +115,7 @@ void BIF_createTransformOrientation(bContext *C, ReportList *reports, char *name
ts = createBoneSpace(C, reports, name, overwrite);
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
ts = createBoneSpace(C, reports, name, overwrite);
ts = createBoneSpace(C, reports, name, overwrite);
}
else {
ts = createObjectSpace(C, reports, name, overwrite);
@@ -143,7 +143,7 @@ TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(reports)
/* use object name if no name is given */
if (name[0] == 0) {
strncpy(name, ob->id.name+2, MAX_ID_NAME-2);
strncpy(name, ob->id.name + 2, MAX_ID_NAME - 2);
}
return addMatrixSpace(C, mat, name, overwrite);
@@ -262,7 +262,7 @@ int createSpaceNormalTangent(float mat[3][3], float normal[3], float tangent[3])
return 1;
}
TransformOrientation* addMatrixSpace(bContext *C, float mat[3][3], char name[], int overwrite)
TransformOrientation *addMatrixSpace(bContext *C, float mat[3][3], char name[], int overwrite)
{
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts = NULL;
@@ -301,7 +301,7 @@ void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target)
// Transform_fix_me NEED TO DO THIS FOR ALL VIEW3D
if (selected_index == i) {
v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
}
else if (selected_index > i) {
v3d->twmode--;
@@ -318,7 +318,7 @@ void BIF_removeTransformOrientation(bContext *C, TransformOrientation *target)
void BIF_removeTransformOrientationIndex(bContext *C, int index)
{
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts= BLI_findlink(transform_spaces, index);
TransformOrientation *ts = BLI_findlink(transform_spaces, index);
if (ts) {
View3D *v3d = CTX_wm_view3d(C);
@@ -327,7 +327,7 @@ void BIF_removeTransformOrientationIndex(bContext *C, int index)
// Transform_fix_me NEED TO DO THIS FOR ALL VIEW3D
if (selected_index == index) {
v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
v3d->twmode = V3D_MANIP_GLOBAL; /* fallback to global */
}
else if (selected_index > index) {
v3d->twmode--;
@@ -365,15 +365,15 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
{
Scene *scene;
ListBase *transform_spaces;
TransformOrientation *ts= NULL;
TransformOrientation *ts = NULL;
EnumPropertyItem global = {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""};
EnumPropertyItem global = {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""};
EnumPropertyItem normal = {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""};
EnumPropertyItem local = {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""};
EnumPropertyItem view = {V3D_MANIP_VIEW, "VIEW", 0, "View", ""};
EnumPropertyItem tmp = {0, "", 0, "", ""};
EnumPropertyItem *item= NULL;
int i = V3D_MANIP_CUSTOM, totitem= 0;
EnumPropertyItem *item = NULL;
int i = V3D_MANIP_CUSTOM, totitem = 0;
RNA_enum_item_add(&item, &totitem, &global);
RNA_enum_item_add(&item, &totitem, &normal);
@@ -381,7 +381,7 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
RNA_enum_item_add(&item, &totitem, &view);
if (C) {
scene= CTX_data_scene(C);
scene = CTX_data_scene(C);
if (scene) {
transform_spaces = &scene->transform_spaces;
@@ -394,7 +394,7 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
for (; ts; ts = ts->next) {
tmp.identifier = "CUSTOM";
tmp.name= ts->name;
tmp.name = ts->name;
tmp.value = i++;
RNA_enum_item_add(&item, &totitem, &tmp);
}
@@ -404,9 +404,9 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
return item;
}
const char * BIF_menustringTransformOrientation(const bContext *C, const char *title)
const char *BIF_menustringTransformOrientation(const bContext *C, const char *title)
{
const char* menu = IFACE_("%t|Global%x0|Local%x1|Gimbal%x4|Normal%x2|View%x3");
const char *menu = IFACE_("%t|Global%x0|Local%x1|Gimbal%x4|Normal%x2|View%x3");
ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
TransformOrientation *ts;
int i = V3D_MANIP_CUSTOM;
@@ -459,7 +459,7 @@ void applyTransformOrientation(const bContext *C, float mat[3][3], char *name)
break;
}
}
}
}
}
static int count_bone_select(bArmature *arm, ListBase *lb, int do_it)
@@ -468,7 +468,7 @@ static int count_bone_select(bArmature *arm, ListBase *lb, int do_it)
int do_next;
int total = 0;
for (bone= lb->first; bone; bone= bone->next) {
for (bone = lb->first; bone; bone = bone->next) {
bone->flag &= ~BONE_TRANSFORM;
do_next = do_it;
if (do_it) {
@@ -476,7 +476,7 @@ static int count_bone_select(bArmature *arm, ListBase *lb, int do_it)
if (bone->flag & BONE_SELECTED) {
bone->flag |= BONE_TRANSFORM;
total++;
do_next = FALSE; // no transform on children if one parent bone is selected
do_next = FALSE; // no transform on children if one parent bone is selected
}
}
}
@@ -493,55 +493,55 @@ void initTransformOrientation(bContext *C, TransInfo *t)
Object *obedit = CTX_data_active_object(C);
switch (t->current_orientation) {
case V3D_MANIP_GLOBAL:
unit_m3(t->spacemtx);
strcpy(t->spacename, "global");
break;
case V3D_MANIP_GIMBAL:
unit_m3(t->spacemtx);
if (gimbal_axis(ob, t->spacemtx)) {
strcpy(t->spacename, "gimbal");
case V3D_MANIP_GLOBAL:
unit_m3(t->spacemtx);
strcpy(t->spacename, "global");
break;
}
case V3D_MANIP_GIMBAL:
unit_m3(t->spacemtx);
if (gimbal_axis(ob, t->spacemtx)) {
strcpy(t->spacename, "gimbal");
break;
}
/* no gimbal fallthrough to normal */
case V3D_MANIP_NORMAL:
if (obedit || (ob && ob->mode & OB_MODE_POSE)) {
strcpy(t->spacename, "normal");
ED_getTransformOrientationMatrix(C, t->spacemtx, (v3d->around == V3D_ACTIVE));
break;
}
case V3D_MANIP_NORMAL:
if (obedit || (ob && ob->mode & OB_MODE_POSE)) {
strcpy(t->spacename, "normal");
ED_getTransformOrientationMatrix(C, t->spacemtx, (v3d->around == V3D_ACTIVE));
break;
}
/* no break we define 'normal' as 'local' in Object mode */
case V3D_MANIP_LOCAL:
strcpy(t->spacename, "local");
case V3D_MANIP_LOCAL:
strcpy(t->spacename, "local");
if (ob) {
copy_m3_m4(t->spacemtx, ob->obmat);
normalize_m3(t->spacemtx);
}
else {
unit_m3(t->spacemtx);
}
if (ob) {
copy_m3_m4(t->spacemtx, ob->obmat);
normalize_m3(t->spacemtx);
}
else {
unit_m3(t->spacemtx);
}
break;
break;
case V3D_MANIP_VIEW:
if (t->ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = t->ar->regiondata;
float mat[3][3];
case V3D_MANIP_VIEW:
if (t->ar->regiontype == RGN_TYPE_WINDOW) {
RegionView3D *rv3d = t->ar->regiondata;
float mat[3][3];
strcpy(t->spacename, "view");
copy_m3_m4(mat, rv3d->viewinv);
normalize_m3(mat);
copy_m3_m3(t->spacemtx, mat);
}
else {
unit_m3(t->spacemtx);
}
break;
default: /* V3D_MANIP_CUSTOM */
applyTransformOrientation(C, t->spacemtx, t->spacename);
break;
strcpy(t->spacename, "view");
copy_m3_m4(mat, rv3d->viewinv);
normalize_m3(mat);
copy_m3_m3(t->spacemtx, mat);
}
else {
unit_m3(t->spacemtx);
}
break;
default: /* V3D_MANIP_CUSTOM */
applyTransformOrientation(C, t->spacemtx, t->spacename);
break;
}
}
@@ -549,7 +549,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
{
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
Object *obedit= CTX_data_edit_object(C);
Object *obedit = CTX_data_edit_object(C);
Base *base;
Object *ob = OBACT;
int result = ORIENTATION_NONE;
@@ -566,14 +566,14 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
invert_m3_m3(mat, imat);
transpose_m3(mat);
ob= obedit;
ob = obedit;
if (ob->type==OB_MESH) {
Mesh *me= ob->data;
if (ob->type == OB_MESH) {
Mesh *me = ob->data;
BMEditMesh *em = me->edit_btmesh;
BMVert *eve;
BMEditSelection ese;
float vec[3]= {0, 0, 0};
float vec[3] = {0, 0, 0};
/* USE LAST SELECTED WITH ACTIVE */
if (activeOnly && BM_select_history_active_get(em->bm, &ese)) {
@@ -711,17 +711,17 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
}
} /* end editmesh */
else if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
Curve *cu= obedit->data;
Curve *cu = obedit->data;
Nurb *nu;
BezTriple *bezt;
int a;
ListBase *nurbs= BKE_curve_editNurbs_get(cu);
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
for (nu = nurbs->first; nu; nu = nu->next) {
/* only bezier has a normal */
if (nu->type == CU_BEZIER) {
bezt= nu->bezt;
a= nu->pntsu;
bezt = nu->bezt;
a = nu->pntsu;
while (a--) {
/* exception */
if ((bezt->f1 & SELECT) + (bezt->f2 & SELECT) + (bezt->f3 & SELECT) > SELECT) {
@@ -747,7 +747,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
result = ORIENTATION_NORMAL;
}
}
else if (obedit->type==OB_MBALL) {
else if (obedit->type == OB_MBALL) {
#if 0 // XXX
/* editmball.c */
MetaElem *ml, *ml_sel = NULL;
@@ -784,7 +784,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
bArmature *arm = obedit->data;
EditBone *ebone;
for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
for (ebone = arm->edbo->first; ebone; ebone = ebone->next) {
if (arm->layer & ebone->layer) {
if (ebone->flag & BONE_SELECTED) {
float tmat[3][3];
@@ -819,7 +819,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
}
}
else if (ob && (ob->mode & OB_MODE_POSE)) {
bArmature *arm= ob->data;
bArmature *arm = ob->data;
bPoseChannel *pchan;
int totsel;
@@ -828,7 +828,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
float imat[3][3], mat[3][3];
/* use channels to get stats */
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
if (pchan->bone && pchan->bone->flag & BONE_TRANSFORM) {
add_v3_v3(normal, pchan->pose_mat[2]);
add_v3_v3(plane, pchan->pose_mat[1]);
@@ -847,7 +847,7 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
result = ORIENTATION_EDGE;
}
}
else if (ob && (ob->mode & (OB_MODE_ALL_PAINT|OB_MODE_PARTICLE_EDIT))) {
else if (ob && (ob->mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) {
/* pass */
}
else {
@@ -855,10 +855,10 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
ob = OBACT;
if (ob && !(ob->flag & SELECT)) ob = NULL;
for (base= scene->base.first; base; base= base->next) {
for (base = scene->base.first; base; base = base->next) {
if (TESTBASELIB(v3d, base)) {
if (ob == NULL) {
ob= base->object;
ob = base->object;
break;
}
}
@@ -876,8 +876,8 @@ int getTransformOrientation(const bContext *C, float normal[3], float plane[3],
void ED_getTransformOrientationMatrix(const bContext *C, float orientation_mat[][3], int activeOnly)
{
float normal[3]={0.0, 0.0, 0.0};
float plane[3]={0.0, 0.0, 0.0};
float normal[3] = {0.0, 0.0, 0.0};
float plane[3] = {0.0, 0.0, 0.0};
int type;

View File

@@ -129,13 +129,13 @@ int BIF_snappingSupported(Object *obedit)
int validSnap(TransInfo *t)
{
return (t->tsnap.status & (POINT_INIT|TARGET_INIT)) == (POINT_INIT|TARGET_INIT) ||
(t->tsnap.status & (MULTI_POINTS|TARGET_INIT)) == (MULTI_POINTS|TARGET_INIT);
return (t->tsnap.status & (POINT_INIT | TARGET_INIT)) == (POINT_INIT | TARGET_INIT) ||
(t->tsnap.status & (MULTI_POINTS | TARGET_INIT)) == (MULTI_POINTS | TARGET_INIT);
}
int activeSnap(TransInfo *t)
{
return (t->modifiers & (MOD_SNAP|MOD_SNAP_INVERT)) == MOD_SNAP || (t->modifiers & (MOD_SNAP|MOD_SNAP_INVERT)) == MOD_SNAP_INVERT;
return (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP || (t->modifiers & (MOD_SNAP | MOD_SNAP_INVERT)) == MOD_SNAP_INVERT;
}
void drawSnapping(const struct bContext *C, TransInfo *t)
@@ -144,13 +144,13 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
unsigned char col[4], selectedCol[4], activeCol[4];
UI_GetThemeColor3ubv(TH_TRANSFORM, col);
col[3]= 128;
col[3] = 128;
UI_GetThemeColor3ubv(TH_SELECT, selectedCol);
selectedCol[3]= 128;
selectedCol[3] = 128;
UI_GetThemeColor3ubv(TH_ACTIVE, activeCol);
activeCol[3]= 192;
activeCol[3] = 192;
if (t->spacetype == SPACE_VIEW3D) {
TransSnapPoint *p;
@@ -187,31 +187,31 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
glColor4ubv(activeCol);
glBegin(GL_LINES);
glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]);
glVertex3f(t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0],
t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1],
t->tsnap.snapPoint[2] + t->tsnap.snapNormal[2]);
glEnd();
glVertex3f(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], t->tsnap.snapPoint[2]);
glVertex3f(t->tsnap.snapPoint[0] + t->tsnap.snapNormal[0],
t->tsnap.snapPoint[1] + t->tsnap.snapNormal[1],
t->tsnap.snapPoint[2] + t->tsnap.snapNormal[2]);
glEnd();
}
if (v3d->zbuf)
glEnable(GL_DEPTH_TEST);
}
else if (t->spacetype==SPACE_IMAGE) {
else if (t->spacetype == SPACE_IMAGE) {
/* This will not draw, and Im nor sure why - campbell */
#if 0
float xuser_asp, yuser_asp;
int wi, hi;
float w, h;
calc_image_view(G.sima, 'f'); // float
calc_image_view(G.sima, 'f'); // float
myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax);
glLoadIdentity();
ED_space_image_aspect(t->sa->spacedata.first, &xuser_aspx, &yuser_asp);
ED_space_image_width(t->sa->spacedata.first, &wi, &hi);
w = (((float)wi)/256.0f)*G.sima->zoom * xuser_asp;
h = (((float)hi)/256.0f)*G.sima->zoom * yuser_asp;
w = (((float)wi) / 256.0f) * G.sima->zoom * xuser_asp;
h = (((float)hi) / 256.0f) * G.sima->zoom * yuser_asp;
cpack(0xFFFFFF);
glTranslatef(t->tsnap.snapPoint[0], t->tsnap.snapPoint[1], 0.0f);
@@ -220,10 +220,10 @@ void drawSnapping(const struct bContext *C, TransInfo *t)
setlinestyle(0);
cpack(0x0);
fdrawline(-0.020/w, 0, -0.1/w, 0);
fdrawline(0.1/w, 0, .020/w, 0);
fdrawline(0, -0.020/h, 0, -0.1/h);
fdrawline(0, 0.1/h, 0, 0.020/h);
fdrawline(-0.020 / w, 0, -0.1 / w, 0);
fdrawline(0.1 / w, 0, .020 / w, 0);
fdrawline(0, -0.020 / h, 0, -0.1 / h);
fdrawline(0, 0.1 / h, 0, 0.020 / h);
glTranslatef(-t->tsnap.snapPoint[0], -t->tsnap.snapPoint[1], 0.0f);
setlinestyle(0);
@@ -261,12 +261,12 @@ void applyProject(TransInfo *t)
float imat[4][4];
int i;
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob = t->obedit?t->obedit:t->poseobj;
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
invert_m4_m4(imat, ob->obmat);
}
for (i = 0 ; i < t->total; i++, td++) {
for (i = 0; i < t->total; i++, td++) {
float iloc[3], loc[3], no[3];
float mval[2];
int dist = 1000;
@@ -278,12 +278,12 @@ void applyProject(TransInfo *t)
continue;
copy_v3_v3(iloc, td->loc);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob = t->obedit?t->obedit:t->poseobj;
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, iloc);
}
else if (t->flag & T_OBJECT) {
td->ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME;
td->ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME;
BKE_object_handle_update(t->scene, td->ob);
copy_v3_v3(iloc, td->ob->obmat[3]);
}
@@ -387,7 +387,7 @@ static void initSnappingMode(TransInfo *t)
/* Edit mode */
if (t->tsnap.applySnap != NULL && // A snapping function actually exist
(obedit != NULL && ELEM4(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE)) ) // Temporary limited to edit mode meshes, armature, curves
(obedit != NULL && ELEM4(obedit->type, OB_MESH, OB_ARMATURE, OB_CURVE, OB_LATTICE)) ) // Temporary limited to edit mode meshes, armature, curves
{
/* Exclude editmesh if using proportional edit */
if ((obedit->type == OB_MESH) && (t->flag & T_PROP_EDIT)) {
@@ -399,13 +399,13 @@ static void initSnappingMode(TransInfo *t)
}
/* Particles edit mode*/
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
(obedit == NULL && BASACT && BASACT->object && BASACT->object->mode & OB_MODE_PARTICLE_EDIT ))
(obedit == NULL && BASACT && BASACT->object && BASACT->object->mode & OB_MODE_PARTICLE_EDIT))
{
t->tsnap.modeSelect = SNAP_ALL;
}
/* Object mode */
else if (t->tsnap.applySnap != NULL && // A snapping function actually exist
(obedit == NULL) ) // Object Mode
(obedit == NULL) ) // Object Mode
{
t->tsnap.modeSelect = SNAP_NOT_SELECTED;
}
@@ -438,7 +438,7 @@ void initSnapping(TransInfo *t, wmOperator *op)
if (RNA_struct_property_is_set(op->ptr, "snap_point")) {
RNA_float_get_array(op->ptr, "snap_point", t->tsnap.snapPoint);
t->tsnap.status |= SNAP_FORCED|POINT_INIT;
t->tsnap.status |= SNAP_FORCED | POINT_INIT;
}
/* snap align only defined in specific cases */
@@ -497,33 +497,33 @@ static void setSnappingCallback(TransInfo *t)
}
switch (t->mode) {
case TFM_TRANSLATION:
t->tsnap.applySnap = ApplySnapTranslation;
t->tsnap.distance = TranslationBetween;
break;
case TFM_ROTATION:
t->tsnap.applySnap = ApplySnapRotation;
t->tsnap.distance = RotationBetween;
// Can't do TARGET_CENTER with rotation, use TARGET_MEDIAN instead
if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
t->tsnap.targetSnap = TargetSnapMedian;
}
break;
case TFM_RESIZE:
t->tsnap.applySnap = ApplySnapResize;
t->tsnap.distance = ResizeBetween;
// Can't do TARGET_CENTER with resize, use TARGET_MEDIAN instead
if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
t->tsnap.targetSnap = TargetSnapMedian;
}
break;
default:
t->tsnap.applySnap = NULL;
break;
case TFM_TRANSLATION:
t->tsnap.applySnap = ApplySnapTranslation;
t->tsnap.distance = TranslationBetween;
break;
case TFM_ROTATION:
t->tsnap.applySnap = ApplySnapRotation;
t->tsnap.distance = RotationBetween;
// Can't do TARGET_CENTER with rotation, use TARGET_MEDIAN instead
if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
t->tsnap.targetSnap = TargetSnapMedian;
}
break;
case TFM_RESIZE:
t->tsnap.applySnap = ApplySnapResize;
t->tsnap.distance = ResizeBetween;
// Can't do TARGET_CENTER with resize, use TARGET_MEDIAN instead
if (t->tsnap.target == SCE_SNAP_TARGET_CENTER) {
t->tsnap.target = SCE_SNAP_TARGET_MEDIAN;
t->tsnap.targetSnap = TargetSnapMedian;
}
break;
default:
t->tsnap.applySnap = NULL;
break;
}
}
@@ -550,7 +550,7 @@ int updateSelectedSnapPoint(TransInfo *t)
int closest_dist = 0;
int screen_loc[2];
for ( p = t->tsnap.points.first; p; p = p->next ) {
for (p = t->tsnap.points.first; p; p = p->next) {
int dx, dy;
int dist;
@@ -663,8 +663,8 @@ static float RotationBetween(TransInfo *t, float p1[3], float p2[3])
float angle, start[3], end[3], center[3];
copy_v3_v3(center, t->center);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= t->obedit?t->obedit:t->poseobj;
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, center);
}
@@ -719,8 +719,8 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3])
float d1[3], d2[3], center[3], len_d1;
copy_v3_v3(center, t->center);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= t->obedit?t->obedit:t->poseobj;
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, center);
}
@@ -739,7 +739,7 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3])
/********************** CALC **************************/
static void UNUSED_FUNCTION(CalcSnapGrid)(TransInfo *t, float *UNUSED(vec))
static void UNUSED_FUNCTION(CalcSnapGrid) (TransInfo * t, float *UNUSED(vec))
{
snapGridAction(t, t->tsnap.snapPoint, BIG_GEARS);
}
@@ -830,9 +830,9 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
if (max_dist != FLT_MAX) {
copy_v3_v3(loc, p);
/* XXX, is there a correct normal in this case ???, for now just z up */
no[0]= 0.0;
no[1]= 0.0;
no[2]= 1.0;
no[0] = 0.0;
no[1] = 0.0;
no[2] = 1.0;
found = 1;
}
@@ -861,12 +861,12 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec))
t->tsnap.status &= ~POINT_INIT;
}
}
else if (t->spacetype == SPACE_IMAGE && t->obedit != NULL && t->obedit->type==OB_MESH) {
else if (t->spacetype == SPACE_IMAGE && t->obedit != NULL && t->obedit->type == OB_MESH) {
/* same as above but for UV's */
Image *ima= ED_space_image(t->sa->spacedata.first);
Image *ima = ED_space_image(t->sa->spacedata.first);
float aspx, aspy, co[2];
UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co+1);
UI_view2d_region_to_view(&t->ar->v2d, t->mval[0], t->mval[1], co, co + 1);
if (ED_uvedit_nearest_uv(t->scene, t->obedit, ima, co, t->tsnap.snapPoint)) {
ED_space_image_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
@@ -888,8 +888,8 @@ static void TargetSnapCenter(TransInfo *t)
/* Only need to calculate once */
if ((t->tsnap.status & TARGET_INIT) == 0) {
copy_v3_v3(t->tsnap.snapTarget, t->center);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= t->obedit?t->obedit:t->poseobj;
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
}
@@ -905,7 +905,7 @@ static void TargetSnapActive(TransInfo *t)
TransData *active_td = NULL;
int i;
for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) {
for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
if (td->flag & TD_ACTIVE) {
active_td = td;
break;
@@ -915,8 +915,8 @@ static void TargetSnapActive(TransInfo *t)
if (active_td) {
copy_v3_v3(t->tsnap.snapTarget, active_td->center);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= t->obedit?t->obedit:t->poseobj;
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
}
@@ -942,14 +942,14 @@ static void TargetSnapMedian(TransInfo *t)
t->tsnap.snapTarget[1] = 0;
t->tsnap.snapTarget[2] = 0;
for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) {
for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
add_v3_v3(t->tsnap.snapTarget, td->center);
}
mul_v3_fl(t->tsnap.snapTarget, 1.0 / i);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= t->obedit?t->obedit:t->poseobj;
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, t->tsnap.snapTarget);
}
@@ -966,7 +966,7 @@ static void TargetSnapClosest(TransInfo *t)
/* Object mode */
if (t->flag & T_OBJECT) {
int i;
for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) {
for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
struct BoundBox *bb = BKE_object_boundbox_get(td->ob);
/* use boundbox if possible */
@@ -1008,14 +1008,14 @@ static void TargetSnapClosest(TransInfo *t)
}
else {
int i;
for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) {
for (td = t->data, i = 0; i < t->total && td->flag & TD_SELECTED; i++, td++) {
float loc[3];
float dist;
copy_v3_v3(loc, td->center);
if (t->flag & (T_EDIT|T_POSE)) {
Object *ob= t->obedit?t->obedit:t->poseobj;
if (t->flag & (T_EDIT | T_POSE)) {
Object *ob = t->obedit ? t->obedit : t->poseobj;
mul_m4_v3(ob->obmat, loc);
}
@@ -1230,10 +1230,10 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm
if (arm->edbo) {
EditBone *eBone;
for (eBone=arm->edbo->first; eBone; eBone=eBone->next) {
for (eBone = arm->edbo->first; eBone; eBone = eBone->next) {
if (eBone->layer & arm->layer) {
/* skip hidden or moving (selected) bones */
if ((eBone->flag & (BONE_HIDDEN_A|BONE_ROOTSEL|BONE_TIPSEL))==0) {
if ((eBone->flag & (BONE_HIDDEN_A | BONE_ROOTSEL | BONE_TIPSEL)) == 0) {
switch (snap_mode) {
case SCE_SNAP_MODE_VERTEX:
retval |= snapVertex(ar, eBone->head, NULL, obmat, NULL, ray_start, ray_start_local, ray_normal_local, mval, r_loc, NULL, r_dist, r_depth);
@@ -1251,10 +1251,10 @@ static int snapArmature(short snap_mode, ARegion *ar, Object *ob, bArmature *arm
bPoseChannel *pchan;
Bone *bone;
for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) {
bone= pchan->bone;
for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
bone = pchan->bone;
/* skip hidden bones */
if (bone && !(bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))) {
if (bone && !(bone->flag & (BONE_HIDDEN_P | BONE_HIDDEN_PG))) {
float *head_vec = pchan->pose_head;
float *tail_vec = pchan->pose_tail;
@@ -1313,22 +1313,22 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
switch (snap_mode) {
case SCE_SNAP_MODE_FACE:
{
#ifdef USE_BVH_FACE_SNAP // Added for durian
#ifdef USE_BVH_FACE_SNAP // Added for durian
BVHTreeRayHit hit;
BVHTreeFromMesh treeData;
/* local scale in normal direction */
float local_scale = len_v3(ray_normal_local);
treeData.em_evil= em;
treeData.em_evil = em;
bvhtree_from_mesh_faces(&treeData, dm, 0.0f, 4, 6);
hit.index = -1;
hit.dist = *r_depth * (*r_depth == FLT_MAX ? 1.0f : local_scale);
if (treeData.tree && BLI_bvhtree_ray_cast(treeData.tree, ray_start_local, ray_normal_local, 0.0f, &hit, treeData.raycast_callback, &treeData) != -1) {
if (hit.dist/local_scale <= *r_depth) {
*r_depth= hit.dist/local_scale;
if (hit.dist / local_scale <= *r_depth) {
*r_depth = hit.dist / local_scale;
copy_v3_v3(r_loc, hit.co);
copy_v3_v3(r_no, hit.no);
@@ -1356,7 +1356,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
EDBM_index_arrays_init(em, 0, 0, 1);
}
for ( i = 0; i < totface; i++) {
for (i = 0; i < totface; i++) {
BMFace *efa = NULL;
MFace *f = faces + i;
@@ -1384,7 +1384,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
BMLoop *l;
l = BM_iter_new(&iter, em->bm, BM_LOOPS_OF_FACE, efa);
for ( ; l; l=BM_iter_step(&iter)) {
for (; l; l = BM_iter_step(&iter)) {
if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) {
test = 0;
break;
@@ -1430,7 +1430,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
EDBM_index_arrays_init(em, 1, 0, 0);
}
for ( i = 0; i < totvert; i++) {
for (i = 0; i < totvert; i++) {
BMVert *eve = NULL;
MVert *v = verts + i;
@@ -1481,7 +1481,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
EDBM_index_arrays_init(em, 0, 1, 0);
}
for ( i = 0; i < totedge; i++) {
for (i = 0; i < totedge; i++) {
BMEdge *eed = NULL;
MEdge *e = edges + i;
@@ -1502,8 +1502,8 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh
eed = EDBM_edge_at_index(em, index);
if (eed && (BM_elem_flag_test(eed, BM_ELEM_HIDDEN) ||
BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)))
BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)))
{
test = 0;
}
@@ -1531,7 +1531,7 @@ static int snapObject(Scene *scene, ARegion *ar, Object *ob, int editobject, flo
const float ray_start[3], const float ray_normal[3], const float mval[2],
float r_loc[3], float r_no[3], int *r_dist, float *r_depth)
{
ToolSettings *ts= scene->toolsettings;
ToolSettings *ts = scene->toolsettings;
int retval = 0;
if (ob->type == OB_MESH) {
@@ -1580,18 +1580,18 @@ static int snapObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, c
*
* To solve that problem, we do it first as an exception.
* */
base= BASACT;
base = BASACT;
if (base && base->object && base->object->mode & OB_MODE_PARTICLE_EDIT) {
Object *ob = base->object;
retval |= snapObject(scene, ar, ob, 0, ob->obmat, ray_start, ray_normal, mval, r_loc, r_no, r_dist, &depth);
}
for ( base = FIRSTBASE; base != NULL; base = base->next ) {
if ( (BASE_VISIBLE(v3d, base)) &&
(base->flag & (BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA)) == 0 &&
for (base = FIRSTBASE; base != NULL; base = base->next) {
if ((BASE_VISIBLE(v3d, base)) &&
(base->flag & (BA_HAS_RECALC_OB | BA_HAS_RECALC_DATA)) == 0 &&
( (mode == SNAP_NOT_SELECTED && (base->flag & (SELECT|BA_WAS_SEL)) == 0) ||
(ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT)) )
((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL)) == 0) ||
(ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT) && base != BASACT)))
{
Object *ob = base->object;
@@ -1719,7 +1719,7 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4],
MFace *faces = dm->getTessFaceArray(dm);
int i;
for ( i = 0; i < totface; i++) {
for (i = 0; i < totface; i++) {
MFace *f = faces + i;
float lambda;
int result;
@@ -1837,7 +1837,7 @@ static int peelObjects(Scene *scene, View3D *v3d, ARegion *ar, Object *obedit, L
if (ob->type == OB_MESH) {
int val = 0;
if (ob != obedit && ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT|BA_WAS_SEL)) == 0) || ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT))) {
if (ob != obedit && ((mode == SNAP_NOT_SELECTED && (base->flag & (SELECT | BA_WAS_SEL)) == 0) || ELEM(mode, SNAP_ALL, SNAP_NOT_OBEDIT))) {
DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH);
val = peelDerivedMesh(ob, dm, ob->obmat, ray_start, ray_normal, mval, depth_peels);
@@ -1918,7 +1918,7 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea
if (max_index > 2) {
printf("applyGrid: invalid index %d, clamping\n", max_index);
max_index= 2;
max_index = 2;
}
// Early bailing out if no need to snap
@@ -1926,11 +1926,11 @@ static void applyGrid(TransInfo *t, float *val, int max_index, float fac[3], Gea
return;
/* evil hack - snapping needs to be adapted for image aspect ratio */
if ((t->spacetype==SPACE_IMAGE) && (t->mode==TFM_TRANSLATION)) {
ED_space_image_uv_aspect(t->sa->spacedata.first, asp, asp+1);
if ((t->spacetype == SPACE_IMAGE) && (t->mode == TFM_TRANSLATION)) {
ED_space_image_uv_aspect(t->sa->spacedata.first, asp, asp + 1);
}
for (i=0; i<=max_index; i++) {
val[i]= fac[action]*asp[i]*(float)floor(val[i]/(fac[action]*asp[i]) +0.5f);
for (i = 0; i <= max_index; i++) {
val[i] = fac[action] * asp[i] * (float)floor(val[i] / (fac[action] * asp[i]) + 0.5f);
}
}