Created initConstraint. It basicly just checks if the CON_APPLY has been set up (by the BIF_setConstraint calls for example) and calls startConstraint. This must be done because startConstraint uses data initialised when starting transform so it needs to be called after that.
Also changed some strcpy into strncpy.
This commit is contained in:
@@ -1342,6 +1342,8 @@ void Transform(int mode)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initConstraint(&Trans);
|
||||||
|
|
||||||
// Emptying event queue
|
// Emptying event queue
|
||||||
while( qtest() ) {
|
while( qtest() ) {
|
||||||
event= extern_qread(&val);
|
event= extern_qread(&val);
|
||||||
@@ -1611,6 +1613,8 @@ void ManipulatorTransform(int mode)
|
|||||||
initTrackball(&Trans);
|
initTrackball(&Trans);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initConstraint(&Trans);
|
||||||
|
|
||||||
Trans.flag |= T_USES_MANIPULATOR;
|
Trans.flag |= T_USES_MANIPULATOR;
|
||||||
Trans.redraw = 1;
|
Trans.redraw = 1;
|
||||||
@@ -2526,7 +2530,6 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) {
|
|||||||
sprintf(&tvec[20], "%.4f", vec[1]);
|
sprintf(&tvec[20], "%.4f", vec[1]);
|
||||||
sprintf(&tvec[40], "%.4f", vec[2]);
|
sprintf(&tvec[40], "%.4f", vec[2]);
|
||||||
}
|
}
|
||||||
printf(" idxmax %d\n", t->num.idx_max);
|
|
||||||
|
|
||||||
if (t->con.mode & CON_APPLY) {
|
if (t->con.mode & CON_APPLY) {
|
||||||
switch(t->num.idx_max) {
|
switch(t->num.idx_max) {
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ int getConstraintSpaceDimension(TransInfo *t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]) {
|
void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]) {
|
||||||
strcpy(t->con.text + 1, text);
|
strncpy(t->con.text + 1, text, 48);
|
||||||
Mat3CpyMat3(t->con.mtx, space);
|
Mat3CpyMat3(t->con.mtx, space);
|
||||||
t->con.mode = mode;
|
t->con.mode = mode;
|
||||||
getConstraintMatrix(t);
|
getConstraintMatrix(t);
|
||||||
@@ -538,7 +538,7 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[]) {
|
|||||||
setConstraint(t, t->data->axismtx, mode, text);
|
setConstraint(t, t->data->axismtx, mode, text);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strcpy(t->con.text + 1, text);
|
strncpy(t->con.text + 1, text, 48);
|
||||||
Mat3CpyMat3(t->con.mtx, t->data->axismtx);
|
Mat3CpyMat3(t->con.mtx, t->data->axismtx);
|
||||||
t->con.mode = mode;
|
t->con.mode = mode;
|
||||||
getConstraintMatrix(t);
|
getConstraintMatrix(t);
|
||||||
@@ -575,17 +575,15 @@ void BIF_setSingleAxisConstraint(float vec[3], char *text) {
|
|||||||
t->con.mode = (CON_AXIS0|CON_APPLY);
|
t->con.mode = (CON_AXIS0|CON_APPLY);
|
||||||
getConstraintMatrix(t);
|
getConstraintMatrix(t);
|
||||||
|
|
||||||
startConstraint(t);
|
/* start copying with an offset of 1, to reserve a spot for the SPACE char */
|
||||||
|
if(text) strncpy(t->con.text+1, text, 48); // 50 in struct
|
||||||
|
|
||||||
if(text) strncpy(t->con.text, text, 49); // 50 in struct
|
|
||||||
|
|
||||||
t->con.drawExtra = NULL;
|
t->con.drawExtra = NULL;
|
||||||
t->con.applyVec = applyAxisConstraintVec;
|
t->con.applyVec = applyAxisConstraintVec;
|
||||||
t->con.applySize = applyAxisConstraintSize;
|
t->con.applySize = applyAxisConstraintSize;
|
||||||
t->con.applyRot = applyAxisConstraintRot;
|
t->con.applyRot = applyAxisConstraintRot;
|
||||||
t->redraw = 1;
|
t->redraw = 1;
|
||||||
|
|
||||||
startConstraint(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BIF_setDualAxisConstraint(float vec1[3], float vec2[3]) {
|
void BIF_setDualAxisConstraint(float vec1[3], float vec2[3]) {
|
||||||
@@ -600,16 +598,12 @@ void BIF_setDualAxisConstraint(float vec1[3], float vec2[3]) {
|
|||||||
Mat3CpyMat3(t->con.mtx, space);
|
Mat3CpyMat3(t->con.mtx, space);
|
||||||
t->con.mode = (CON_AXIS0|CON_AXIS1|CON_APPLY);
|
t->con.mode = (CON_AXIS0|CON_AXIS1|CON_APPLY);
|
||||||
getConstraintMatrix(t);
|
getConstraintMatrix(t);
|
||||||
|
|
||||||
startConstraint(t);
|
|
||||||
|
|
||||||
t->con.drawExtra = NULL;
|
t->con.drawExtra = NULL;
|
||||||
t->con.applyVec = applyAxisConstraintVec;
|
t->con.applyVec = applyAxisConstraintVec;
|
||||||
t->con.applySize = applyAxisConstraintSize;
|
t->con.applySize = applyAxisConstraintSize;
|
||||||
t->con.applyRot = applyAxisConstraintRot;
|
t->con.applyRot = applyAxisConstraintRot;
|
||||||
t->redraw = 1;
|
t->redraw = 1;
|
||||||
|
|
||||||
startConstraint(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -683,6 +677,12 @@ void BIF_drawPropCircle()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initConstraint(TransInfo *t) {
|
||||||
|
if (t->con.mode & CON_APPLY) {
|
||||||
|
startConstraint(t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void startConstraint(TransInfo *t) {
|
void startConstraint(TransInfo *t) {
|
||||||
t->con.mode |= CON_APPLY;
|
t->con.mode |= CON_APPLY;
|
||||||
*t->con.text = ' ';
|
*t->con.text = ' ';
|
||||||
|
|||||||
@@ -47,8 +47,9 @@ void drawConstraint();
|
|||||||
//void drawPropCircle(TransInfo *t);
|
//void drawPropCircle(TransInfo *t);
|
||||||
void drawPropCircle();
|
void drawPropCircle();
|
||||||
|
|
||||||
void stopConstraint(TransInfo *t);
|
void initConstraint(TransInfo *t);
|
||||||
void startConstraint(TransInfo *t);
|
void startConstraint(TransInfo *t);
|
||||||
|
void stopConstraint(TransInfo *t);
|
||||||
|
|
||||||
void getConstraintMatrix(TransInfo *t);
|
void getConstraintMatrix(TransInfo *t);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user