Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/lattice.c')
-rw-r--r--source/blender/blenkernel/intern/lattice.c61
1 files changed, 45 insertions, 16 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index aaacba97d35..3f9143bb405 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -514,7 +514,7 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir)
/* co: local coord, result local too */
/* returns quaternion for rotation, using cd->no_rot_axis */
/* axis is using another define!!! */
-static float *calc_curve_deform(Object *par, float *co, short axis, CurveDeform *cd)
+static int calc_curve_deform(Object *par, float *co, short axis, CurveDeform *cd, float *quatp)
{
Curve *cu= par->data;
float fac, loc[4], dir[3], cent[3];
@@ -544,7 +544,7 @@ static float *calc_curve_deform(Object *par, float *co, short axis, CurveDeform
/* to be sure, mostly after file load */
if(cu->path==NULL) {
makeDispListCurveTypes(par, 0);
- if(cu->path==NULL) return NULL; // happens on append...
+ if(cu->path==NULL) return 0; // happens on append...
}
/* options */
@@ -570,14 +570,13 @@ static float *calc_curve_deform(Object *par, float *co, short axis, CurveDeform
}
if( where_on_path_deform(par, fac, loc, dir)) { /* returns OK */
- float q[4], mat[3][3];
- float *quat;
+ float q[4], mat[3][3], quat[4];
if(cd->no_rot_axis) /* set by caller */
dir[cd->no_rot_axis-1]= 0.0f;
/* -1 for compatibility with old track defines */
- quat= vectoquat(dir, axis-1, upflag); /* gives static quat */
+ vectoquat(dir, axis-1, upflag, quat);
/* the tilt */
if(loc[3]!=0.0) {
@@ -597,18 +596,26 @@ static float *calc_curve_deform(Object *par, float *co, short axis, CurveDeform
/* translation */
VECADD(co, cent, loc);
- return quat;
+ if(quatp)
+ QUATCOPY(quatp, quat);
+
+ return 1;
}
- return NULL;
+ return 0;
}
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;
+ Curve *cu;
+ int a, flag;
CurveDeform cd;
int use_vgroups;
-
+
+ if(cuOb->type != OB_CURVE)
+ return;
+
+ cu = cuOb->data;
+ flag = cu->flag;
cu->flag |= (CU_PATH|CU_FOLLOW); // needed for path & bevlist
init_curve_deform(cuOb, target, &cd, (cu->flag & CU_STRETCH)==0);
@@ -663,7 +670,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, defaxis, &cd);
+ calc_curve_deform(cuOb, vec, defaxis, &cd, NULL);
VecLerpf(vertexCos[a], vertexCos[a], vec,
dvert->dw[j].weight);
Mat4MulVecfl(cd.objectspace, vertexCos[a]);
@@ -681,7 +688,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], defaxis, &cd);
+ calc_curve_deform(cuOb, vertexCos[a], defaxis, &cd, NULL);
Mat4MulVecfl(cd.objectspace, vertexCos[a]);
}
}
@@ -694,8 +701,13 @@ void curve_deform_verts(Object *cuOb, Object *target, DerivedMesh *dm, float (*v
void curve_deform_vector(Object *cuOb, Object *target, float *orco, float *vec, float mat[][3], int no_rot_axis)
{
CurveDeform cd;
- float *quat;
+ float quat[4];
+ if(cuOb->type != OB_CURVE) {
+ Mat3One(mat);
+ return;
+ }
+
init_curve_deform(cuOb, target, &cd, 0); /* 0 no dloc */
cd.no_rot_axis= no_rot_axis; /* option to only rotate for XY, for example */
@@ -704,8 +716,7 @@ void curve_deform_vector(Object *cuOb, Object *target, float *orco, float *vec,
Mat4MulVecfl(cd.curvespace, vec);
- quat= calc_curve_deform(cuOb, vec, target->trackflag+1, &cd);
- if(quat) {
+ if(calc_curve_deform(cuOb, vec, target->trackflag+1, &cd, quat)) {
float qmat[3][3];
QuatToMat3(quat, qmat);
@@ -724,6 +735,9 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
int a;
int use_vgroups;
+ if(laOb->type != OB_LATTICE)
+ return;
+
init_latt_deform(laOb, target);
/* check whether to use vertex groups (only possible if target is a Mesh)
@@ -899,7 +913,10 @@ void lattice_calc_modifiers(Object *ob)
mti->deformVerts(md, ob, NULL, vertexCos, numVerts);
}
- if (vertexCos) {
+ /* always displist to make this work like derivedmesh */
+ if (!vertexCos) vertexCos = lattice_getVertexCos(ob, &numVerts);
+
+ {
DispList *dl = MEM_callocN(sizeof(*dl), "lt_dl");
dl->type = DL_VERTS;
dl->parts = 1;
@@ -909,3 +926,15 @@ void lattice_calc_modifiers(Object *ob)
BLI_addtail(&ob->disp, dl);
}
}
+
+struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt)
+{
+ if(oblatt->type == OB_LATTICE)
+ {
+ Lattice *lt = (oblatt==G.obedit)?editLatt:(Lattice*)oblatt->data;
+ return lt->dvert;
+ }
+
+ return NULL;
+}
+