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.c95
1 files changed, 27 insertions, 68 deletions
diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c
index 725f9a34b25..70eba3903d0 100644
--- a/source/blender/blenkernel/intern/lattice.c
+++ b/source/blender/blenkernel/intern/lattice.c
@@ -1,4 +1,4 @@
-/**
+/*
* lattice.c
*
*
@@ -41,6 +41,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_cellalloc.h"
+#include "BLI_utildefines.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
@@ -50,6 +51,7 @@
#include "DNA_curve_types.h"
#include "DNA_key_types.h"
+#include "BKE_animsys.h"
#include "BKE_anim.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_displist.h"
@@ -60,7 +62,7 @@
#include "BKE_main.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
-#include "BKE_utildefines.h"
+
#include "BKE_deform.h"
//XXX #include "BIF_editdeform.h"
@@ -182,7 +184,7 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
MEM_freeN(vertexCos);
}
-Lattice *add_lattice(char *name)
+Lattice *add_lattice(const char *name)
{
Lattice *lt;
@@ -204,10 +206,6 @@ Lattice *copy_lattice(Lattice *lt)
ltn= copy_libblock(lt);
ltn->def= MEM_dupallocN(lt->def);
-
-#if 0 // XXX old animation system
- id_us_plus((ID *)ltn->ipo);
-#endif // XXX old animation system
ltn->key= copy_key(ltn->key);
if(ltn->key) ltn->key->from= (ID *)ltn;
@@ -234,6 +232,12 @@ void free_lattice(Lattice *lt)
MEM_freeN(editlt);
MEM_freeN(lt->editlatt);
}
+
+ /* free animation data */
+ if (lt->adt) {
+ BKE_free_animdata(&lt->id);
+ lt->adt= NULL;
+ }
}
@@ -248,11 +252,11 @@ void make_local_lattice(Lattice *lt)
* - mixed: make copy
*/
- if(lt->id.lib==0) return;
+ if(lt->id.lib==NULL) return;
if(lt->id.us==1) {
- lt->id.lib= 0;
+ lt->id.lib= NULL;
lt->id.flag= LIB_LOCAL;
- new_id(0, (ID *)lt, 0);
+ new_id(NULL, (ID *)lt, NULL);
return;
}
@@ -266,9 +270,9 @@ void make_local_lattice(Lattice *lt)
}
if(local && lib==0) {
- lt->id.lib= 0;
+ lt->id.lib= NULL;
lt->id.flag= LIB_LOCAL;
- new_id(0, (ID *)lt, 0);
+ new_id(NULL, (ID *)lt, NULL);
}
else if(local && lib) {
ltn= copy_lattice(lt);
@@ -278,7 +282,7 @@ void make_local_lattice(Lattice *lt)
while(ob) {
if(ob->data==lt) {
- if(ob->id.lib==0) {
+ if(ob->id.lib==NULL) {
ob->data= ltn;
ltn->id.us++;
lt->id.us--;
@@ -600,16 +604,6 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
}
#endif
-
- static float q_x90d[4] = {0.70710676908493, 0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180));
- static float q_y90d[4] = {0.70710676908493, 0.0, 0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180));
- static float q_z90d[4] = {0.70710676908493, 0.0, 0.0, 0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180));
-
- static float q_nx90d[4] = {0.70710676908493, -0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180));
- static float q_ny90d[4] = {0.70710676908493, 0.0, -0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180));
- static float q_nz90d[4] = {0.70710676908493, 0.0, 0.0, -0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180));
-
-
if(cd->no_rot_axis) { /* set by caller */
/* this is not exactly the same as 2.4x, since the axis is having rotation removed rather then
@@ -636,53 +630,18 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C
* Notice X,Y,Z Up all have light colors and each ordered CCW.
*
* Now for Neg Up XYZ, the colors are all dark, and ordered clockwise - Campbell
+ *
+ * note: moved functions into quat_apply_track/vec_apply_track
* */
+ copy_qt_qt(quat, new_quat);
+ copy_v3_v3(cent, co);
+
+ /* zero the axis which is not used,
+ * the big block of text above now applies to these 3 lines */
+ quat_apply_track(quat, axis-1, (axis==1 || axis==3) ? 1:0); /* up flag is a dummy, set so no rotation is done */
+ vec_apply_track(cent, axis-1);
+ cent[axis < 4 ? axis-1 : axis-4]= 0.0f;
- switch(axis) {
- case MOD_CURVE_POSX:
- mul_qt_qtqt(quat, new_quat, q_y90d);
-
- cent[0]= 0.0;
- cent[1]= co[2];
- cent[2]= co[1];
- break;
- case MOD_CURVE_NEGX:
- mul_qt_qtqt(quat, new_quat, q_ny90d);
-
- cent[0]= 0.0;
- cent[1]= -co[1];
- cent[2]= co[2];
-
- break;
- case MOD_CURVE_POSY:
- mul_qt_qtqt(quat, new_quat, q_x90d);
-
- cent[0]= co[2];
- cent[1]= 0.0;
- cent[2]= -co[0];
- break;
- case MOD_CURVE_NEGY:
- mul_qt_qtqt(quat, new_quat, q_nx90d);
-
- cent[0]= -co[0];
- cent[1]= 0.0;
- cent[2]= -co[2];
- break;
- case MOD_CURVE_POSZ:
- mul_qt_qtqt(quat, new_quat, q_z90d);
-
- cent[0]= co[1];
- cent[1]= -co[0];
- cent[2]= 0.0;
- break;
- case MOD_CURVE_NEGZ:
- mul_qt_qtqt(quat, new_quat, q_nz90d);
-
- cent[0]= co[0];
- cent[1]= -co[1];
- cent[2]= 0.0;
- break;
- }
/* scale if enabled */
if(cu->flag & CU_PATH_RADIUS)