* Changed the Curve Modifier to have it's own X/Y/Z axis deform direction
settings, rather than using the object's TrackX/Y/Z/etc buttons. This is good for two reasons: a) having the settings over in the object buttons before was terribly unintuitive and hidden, now it's more visible how to control the deformation, and b) now if you have more than one curve modifier, they can have their own settings, instead of being forced to use the object level data.
This commit is contained in:
@@ -53,7 +53,7 @@ void calc_latt_deform(float *co, float weight);
|
||||
void end_latt_deform(void);
|
||||
int object_deform_mball(struct Object *ob);
|
||||
void outside_lattice(struct Lattice *lt);
|
||||
void curve_deform_verts(struct Object *cuOb, struct Object *target, struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts, char *vgroup);
|
||||
void curve_deform_verts(struct Object *cuOb, struct Object *target, struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts, char *vgroup, short defaxis);
|
||||
void lattice_deform_verts(struct Object *laOb, struct Object *target,
|
||||
struct DerivedMesh *dm, float (*vertexCos)[3],
|
||||
int numVerts, char *vgroup);
|
||||
|
||||
@@ -514,14 +514,14 @@ static void calc_curve_deform(Object *par, float *co, short axis, CurveDeform *c
|
||||
float fac, loc[4], dir[3], *quat, q[4], mat[3][3], cent[3];
|
||||
short upflag, index;
|
||||
|
||||
if(axis==OB_POSX || axis==OB_NEGX) {
|
||||
if(axis==MOD_CURVE_POSX || axis==MOD_CURVE_NEGX) {
|
||||
upflag= OB_POSZ;
|
||||
cent[0]= 0.0;
|
||||
cent[1]= co[1];
|
||||
cent[2]= co[2];
|
||||
index= 0;
|
||||
}
|
||||
else if(axis==OB_POSY || axis==OB_NEGY) {
|
||||
else if(axis==MOD_CURVE_POSY || axis==MOD_CURVE_NEGY) {
|
||||
upflag= OB_POSZ;
|
||||
cent[0]= co[0];
|
||||
cent[1]= 0.0;
|
||||
@@ -548,7 +548,7 @@ static void calc_curve_deform(Object *par, float *co, short axis, CurveDeform *c
|
||||
|
||||
if( where_on_path_deform(par, fac, loc, dir)) { /* returns OK */
|
||||
|
||||
quat= vectoquat(dir, axis, upflag);
|
||||
quat= vectoquat(dir, axis-1, upflag); /* -1 for compatibility with old track defines */
|
||||
|
||||
/* the tilt */
|
||||
if(loc[3]!=0.0) {
|
||||
@@ -572,7 +572,7 @@ static void calc_curve_deform(Object *par, float *co, short axis, CurveDeform *c
|
||||
|
||||
}
|
||||
|
||||
void curve_deform_verts(Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3], int numVerts, char *vgroup)
|
||||
void curve_deform_verts(Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3], int numVerts, char *vgroup, short defaxis)
|
||||
{
|
||||
Curve *cu = cuOb->data;
|
||||
int a, flag = cu->flag;
|
||||
@@ -633,7 +633,7 @@ void curve_deform_verts(Object *cuOb, Object *target, DerivedMesh *dm, float (*v
|
||||
for(j = 0; j < dvert->totweight; j++) {
|
||||
if(dvert->dw[j].def_nr == index) {
|
||||
VECCOPY(vec, vertexCos[a]);
|
||||
calc_curve_deform(cuOb, vec, target->trackflag, &cd);
|
||||
calc_curve_deform(cuOb, vec, defaxis, &cd);
|
||||
VecLerpf(vertexCos[a], vertexCos[a], vec,
|
||||
dvert->dw[j].weight);
|
||||
Mat4MulVecfl(cd.objectspace, vertexCos[a]);
|
||||
@@ -651,7 +651,7 @@ void curve_deform_verts(Object *cuOb, Object *target, DerivedMesh *dm, float (*v
|
||||
}
|
||||
|
||||
for(a = 0; a < numVerts; a++) {
|
||||
calc_curve_deform(cuOb, vertexCos[a], target->trackflag, &cd);
|
||||
calc_curve_deform(cuOb, vertexCos[a], defaxis, &cd);
|
||||
Mat4MulVecfl(cd.objectspace, vertexCos[a]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,11 +173,19 @@ static int noneModifier_isDisabled(ModifierData *md)
|
||||
|
||||
/* Curve */
|
||||
|
||||
static void curveModifier_initData(ModifierData *md)
|
||||
{
|
||||
CurveModifierData *cmd = (CurveModifierData*) md;
|
||||
|
||||
cmd->defaxis = MOD_CURVE_POSX;
|
||||
}
|
||||
|
||||
static void curveModifier_copyData(ModifierData *md, ModifierData *target)
|
||||
{
|
||||
CurveModifierData *cmd = (CurveModifierData*) md;
|
||||
CurveModifierData *tcmd = (CurveModifierData*) target;
|
||||
|
||||
tcmd->defaxis = cmd->defaxis;
|
||||
tcmd->object = cmd->object;
|
||||
strncpy(tcmd->name, cmd->name, 32);
|
||||
}
|
||||
@@ -220,7 +228,7 @@ static void curveModifier_deformVerts(
|
||||
CurveModifierData *cmd = (CurveModifierData*) md;
|
||||
|
||||
curve_deform_verts(cmd->object, ob, derivedData, vertexCos, numVerts,
|
||||
cmd->name);
|
||||
cmd->name, cmd->defaxis);
|
||||
}
|
||||
|
||||
static void curveModifier_deformVertsEM(
|
||||
@@ -3418,6 +3426,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type)
|
||||
mti->type = eModifierTypeType_OnlyDeform;
|
||||
mti->flags = eModifierTypeFlag_AcceptsCVs
|
||||
| eModifierTypeFlag_SupportsEditmode;
|
||||
mti->initData = curveModifier_initData;
|
||||
mti->copyData = curveModifier_copyData;
|
||||
mti->isDisabled = curveModifier_isDisabled;
|
||||
mti->foreachObjectLink = curveModifier_foreachObjectLink;
|
||||
|
||||
@@ -5639,6 +5639,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
|
||||
for(ob = main->object.first; ob; ob= ob->id.next) {
|
||||
ModifierData *md;
|
||||
ListBase *list;
|
||||
list = &ob->constraints;
|
||||
|
||||
@@ -5679,12 +5680,24 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* copy old object level track settings to curve modifers */
|
||||
for (md=ob->modifiers.first; md; md=md->next) {
|
||||
if (md->type==eModifierType_Curve) {
|
||||
CurveModifierData *cmd = (CurveModifierData*) md;
|
||||
|
||||
if (cmd->defaxis == 0) cmd->defaxis = ob->trackflag+1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(ma = main->mat.first; ma; ma= ma->id.next) {
|
||||
if(ma->shad_alpha==0.0f)
|
||||
ma->shad_alpha= 1.0f;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
|
||||
|
||||
@@ -75,8 +75,18 @@ typedef struct CurveModifierData {
|
||||
|
||||
struct Object *object;
|
||||
char name[32]; /* optional vertexgroup name */
|
||||
short defaxis; /* axis along which curve deforms */
|
||||
char pad[6];
|
||||
} CurveModifierData;
|
||||
|
||||
/* CurveModifierData->defaxis */
|
||||
#define MOD_CURVE_POSX 1
|
||||
#define MOD_CURVE_POSY 2
|
||||
#define MOD_CURVE_POSZ 3
|
||||
#define MOD_CURVE_NEGX 4
|
||||
#define MOD_CURVE_NEGY 5
|
||||
#define MOD_CURVE_NEGZ 6
|
||||
|
||||
typedef struct BuildModifierData {
|
||||
ModifierData modifier;
|
||||
|
||||
|
||||
@@ -1232,7 +1232,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
|
||||
int isVirtual = md->mode&eModifierMode_Virtual;
|
||||
int x = *xco, y = *yco, color = md->error?TH_REDALERT:TH_BUT_NEUTRAL;
|
||||
int editing = (G.obedit==ob);
|
||||
short height=26, width = 295, buttonWidth = width-120-10;
|
||||
short height=26, width = 295, buttonWidth = width-120-10;
|
||||
char str[128];
|
||||
|
||||
/* rounded header */
|
||||
@@ -1319,7 +1319,7 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
|
||||
} else if (md->type==eModifierType_Lattice) {
|
||||
height = 48;
|
||||
} else if (md->type==eModifierType_Curve) {
|
||||
height = 48;
|
||||
height = 72;
|
||||
} else if (md->type==eModifierType_Build) {
|
||||
height = 86;
|
||||
} else if (md->type==eModifierType_Mirror) {
|
||||
@@ -1398,6 +1398,13 @@ static void draw_modifier(uiBlock *block, Object *ob, ModifierData *md, int *xco
|
||||
uiDefIDPoinBut(block, modifier_testCurveObj, ID_OB, B_CHANGEDEP, "Ob: ", lx, (cy-=19), buttonWidth,19, &cmd->object, "Curve object to deform with");
|
||||
but=uiDefBut(block, TEX, B_MODIFIER_RECALC, "VGroup: ", lx, (cy-=19), buttonWidth,19, &cmd->name, 0.0, 31.0, 0, 0, "Vertex Group name");
|
||||
uiButSetCompleteFunc(but, autocomplete_vgroup, (void *)ob);
|
||||
|
||||
uiDefButS(block, ROW,B_MODIFIER_RECALC,"X", lx, (cy-=19), 19,19, &cmd->defaxis, 12.0, MOD_CURVE_POSX, 0, 0, "The axis that the curve deforms along");
|
||||
uiDefButS(block, ROW,B_MODIFIER_RECALC,"Y", (lx+buttonWidth/6), cy, 19,19, &cmd->defaxis, 12.0, MOD_CURVE_POSY, 0, 0, "The axis that the curve deforms along");
|
||||
uiDefButS(block, ROW,B_MODIFIER_RECALC,"Z", (lx+2*buttonWidth/6), cy, 19,19, &cmd->defaxis, 12.0, MOD_CURVE_POSZ, 0, 0, "The axis that the curve deforms along");
|
||||
uiDefButS(block, ROW,B_MODIFIER_RECALC,"-X", (lx+3*buttonWidth/6), cy, 24,19, &cmd->defaxis, 12.0, MOD_CURVE_NEGX, 0, 0, "The axis that the curve deforms along");
|
||||
uiDefButS(block, ROW,B_MODIFIER_RECALC,"-Y", (lx+4*buttonWidth/6), cy, 24,19, &cmd->defaxis, 12.0, MOD_CURVE_NEGY, 0, 0, "The axis that the curve deforms along");
|
||||
uiDefButS(block, ROW,B_MODIFIER_RECALC,"-Z", (lx+buttonWidth-buttonWidth/6), cy, 24,19, &cmd->defaxis, 12.0, MOD_CURVE_NEGZ, 0, 0, "The axis that the curve deforms along");
|
||||
} else if (md->type==eModifierType_Build) {
|
||||
BuildModifierData *bmd = (BuildModifierData*) md;
|
||||
uiDefButF(block, NUM, B_MODIFIER_RECALC, "Start:", lx, (cy-=19), buttonWidth,19, &bmd->start, 1.0, MAXFRAMEF, 100, 0, "Specify the start frame of the effect");
|
||||
|
||||
Reference in New Issue
Block a user