4 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version. The Blender
10 * Foundation also sells licenses for use in proprietary software under
11 * the Blender License. See http://www.blender.org/BL/ for information
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24 * All rights reserved.
26 * The Original Code is: all of this file.
28 * Contributor(s): none yet.
30 * ***** END GPL/BL DUAL LICENSE BLOCK *****
31 * i.t.t. wat de naam doet vermoeden: ook algemene lattice (calc) functies
42 #include "BLI_winstuff.h"
44 #include "MEM_guardedalloc.h"
46 #include "BLI_blenlib.h"
47 #include "BLI_arithb.h"
49 #include "DNA_object_types.h"
50 #include "DNA_scene_types.h"
51 #include "DNA_lattice_types.h"
52 #include "DNA_curve_types.h"
53 #include "DNA_key_types.h"
54 #include "DNA_view3d_types.h"
57 #include "BKE_displist.h"
58 #include "BKE_lattice.h"
59 #include "BKE_global.h"
61 #include "BIF_toolbox.h"
62 #include "BIF_space.h"
63 #include "BIF_screen.h"
64 #include "BIF_editlattice.h"
65 #include "BIF_editkey.h"
69 #include "BDR_editobject.h"
70 #include "BDR_drawobject.h"
77 #include "BKE_armature.h"
79 void apply_lattice(void)
84 if(okee("Apply Lattice Deform")==0) return;
88 if TESTBASELIB(base) {
89 if( (par= base->object->parent) ) {
90 if(par->type==OB_LATTICE) {
93 object_deform(base->object);
96 base->object->parent= 0;
103 allqueue(REDRAWVIEW3D, 0);
106 /* ***************************** */
111 void free_editLatt(void)
114 if(editLatt->def) MEM_freeN(editLatt->def);
121 static void setflagsLatt(int flag)
128 a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
140 void make_editLatt(void)
151 actkey= lt->key->block.first;
153 if(actkey->flag & SELECT) break;
154 actkey= actkey->next;
159 key_to_latt(actkey, lt);
162 editLatt= MEM_dupallocN(lt);
164 editLatt->def= MEM_dupallocN(lt->def);
170 void load_editLatt(void)
180 /* are there keys? */
182 actkey= lt->key->block.first;
184 if(actkey->flag & SELECT) break;
185 actkey= actkey->next;
190 /* active key: vertices */
191 tot= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
193 if(actkey->data) MEM_freeN(actkey->data);
195 fp=actkey->data= MEM_callocN(lt->key->elemsize*tot, "actkey->data");
196 actkey->totelem= tot;
200 VECCOPY(fp, bp->vec);
205 if(actkey) do_spec_key(lt->key);
211 lt->def= MEM_dupallocN(editLatt->def);
213 lt->flag= editLatt->flag;
215 lt->pntsu= editLatt->pntsu;
216 lt->pntsv= editLatt->pntsv;
217 lt->pntsw= editLatt->pntsw;
219 lt->typeu= editLatt->typeu;
220 lt->typev= editLatt->typev;
221 lt->typew= editLatt->typew;
225 void remake_editLatt(void)
227 if(okee("Reload Original data")==0) return;
230 allqueue(REDRAWVIEW3D, 0);
231 allqueue(REDRAWBUTSEDIT, 0);
235 void deselectall_Latt(void)
242 a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
244 allqueue(REDRAWVIEW3D, 0);
259 static BPoint *findnearestLattvert(int sel)
261 /* sel==1: selected get a disadvantage */
262 /* in bp nearest is written */
264 short dist= 100, temp, mval[2], a;
269 calc_lattverts_ext(); /* drawobject.c */
271 getmouseco_areawin(mval);
276 a= editLatt->pntsu*editLatt->pntsv*editLatt->pntsw;
280 temp= abs(mval[0]- bp1->s[0])+ abs(mval[1]- bp1->s[1]);
281 if( (bp1->f1 & 1)==sel) temp+=5;
294 void mouse_lattice(void)
298 bp= findnearestLattvert(1);
301 if((G.qual & LR_SHIFTKEY)==0) {
306 allqueue(REDRAWVIEW3D, 0);
310 if(bp->f1 & 1) bp->f1 &= ~1;
313 allqueue(REDRAWVIEW3D, 0);
320 rightmouse_transform();