From cbf278246fd0e9e94b1c91055a0744552bedae6c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 27 Feb 2008 14:17:32 +0000 Subject: Fix for bug: cross platform strand render differences with kink/branch. This time is was due to different accuracy of floating point computation, now it uses does a comparison a bit different to avoid this. Also changed the vectoquat function to be threadsafe. --- source/blender/blenkernel/intern/lattice.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/lattice.c') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 2b815c28cc5..8e89b0d7966 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -575,14 +575,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) { -- cgit v1.2.3 From 780ea713d59423ef9679ff131f53f00a97a82410 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 27 Feb 2008 17:43:23 +0000 Subject: Fix for making vectoquat threadsafe, missed a warning. --- source/blender/blenkernel/intern/lattice.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern/lattice.c') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 8e89b0d7966..47175a789b1 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -519,7 +519,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]; @@ -549,7 +549,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 */ @@ -601,9 +601,12 @@ 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) @@ -667,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]); @@ -685,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]); } } @@ -698,7 +701,7 @@ 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]; 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 */ @@ -708,8 +711,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); -- cgit v1.2.3 From eb667866dfde9a227259b0f9bfeaab7fdeaef7ce Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 4 Apr 2008 12:33:01 +0000 Subject: Fix for bug #8870: crash converting curve to mesh. The object was being used for curve deform, but after conversion wasn't a curve anymore, and there was no check for this. --- source/blender/blenkernel/intern/lattice.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/lattice.c') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 47175a789b1..479dd38eb89 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -611,11 +611,16 @@ static int calc_curve_deform(Object *par, float *co, short axis, CurveDeform *cd 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); @@ -703,6 +708,11 @@ void curve_deform_vector(Object *cuOb, Object *target, float *orco, float *vec, CurveDeform cd; 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 */ @@ -730,6 +740,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) -- cgit v1.2.3 From 5d0a207ecb843c4c73be897cfccbf3a0d2db574b Mon Sep 17 00:00:00 2001 From: Chris Want Date: Wed, 16 Apr 2008 22:40:48 +0000 Subject: Patch from GSR that a) fixes a whole bunch of GPL/BL license blocks that were previously missed; and b) greatly increase my ohloh stats! --- source/blender/blenkernel/intern/lattice.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern/lattice.c') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 479dd38eb89..e8bcae42d5a 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -4,15 +4,12 @@ * * $Id$ * - * ***** BEGIN GPL/BL DUAL LICENSE BLOCK ***** + * ***** BEGIN GPL 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. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -30,7 +27,7 @@ * * Contributor(s): none yet. * - * ***** END GPL/BL DUAL LICENSE BLOCK ***** + * ***** END GPL LICENSE BLOCK ***** */ #include -- cgit v1.2.3 From 433c43932b3b057530465982ddef8be0ee27b673 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 20 Jul 2008 16:06:40 +0000 Subject: Bugfix #16662 Curve modifier on lattice suffered drawing updates, only when the system was not animated though, missed depsgraph calls then. Solved it by forcing lattice to always return displist for its vertices, that's same as for how mesh/curve works now. --- source/blender/blenkernel/intern/lattice.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern/lattice.c') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index e8bcae42d5a..54915058bab 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -915,7 +915,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; -- cgit v1.2.3 From ec462b8cead8766c9b12a962d460818d68788015 Mon Sep 17 00:00:00 2001 From: Andre Susano Pinto Date: Mon, 3 Nov 2008 23:17:36 +0000 Subject: Added Lattice vgroup support to shrinkwrap and simple deform modifier. --- source/blender/blenkernel/intern/lattice.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'source/blender/blenkernel/intern/lattice.c') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 54915058bab..2737cac149e 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -928,3 +928,15 @@ void lattice_calc_modifiers(Object *ob) BLI_addtail(&ob->disp, dl); } } + +struct MDeform* 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; +} + -- cgit v1.2.3 From ca80578e4ee67280764aeaf4f562afe2bbc7519c Mon Sep 17 00:00:00 2001 From: Andre Susano Pinto Date: Tue, 4 Nov 2008 01:05:44 +0000 Subject: Simple warning fixes --- source/blender/blenkernel/intern/lattice.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern/lattice.c') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 2737cac149e..6614c657647 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -929,7 +929,7 @@ void lattice_calc_modifiers(Object *ob) } } -struct MDeform* lattice_get_deform_verts(struct Object *oblatt) +struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt) { if(oblatt->type == OB_LATTICE) { -- cgit v1.2.3