3 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. The Blender
9 * Foundation also sells licenses for use in proprietary software under
10 * the Blender License. See http://www.blender.org/BL/ for information
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23 * All rights reserved.
25 * This is a new part of Blender.
27 * Contributor(s): Jacques Guignot, Stephen Swaney
29 * ***** END GPL/BL DUAL LICENSE BLOCK *****
36 #include <BLI_arithb.h>
37 #include <BLI_blenlib.h>
39 #include <BKE_displist.h>
40 #include <BKE_global.h>
41 #include <BKE_object.h>
42 #include <BKE_library.h>
43 #include <BKE_curve.h>
44 #include <BKE_utildefines.h>
45 #include <MEM_guardedalloc.h> /* because we wil be mallocing memory */
49 #include "gen_utils.h"
52 /*****************************************************************************/
53 /* The following string definitions are used for documentation strings. */
54 /* In Python these will be written to the console when doing a */
55 /* Blender.Curve.__doc__ */
56 /*****************************************************************************/
58 char M_Curve_doc[] = "The Blender Curve module\n\n\
59 This module provides access to **Curve Data** in Blender.\n\
61 New(opt name) : creates a new curve object with the given name (optional)\n\
62 Get(name) : retreives a curve with the given name (mandatory)\n\
63 get(name) : same as Get. Kept for compatibility reasons";
64 char M_Curve_New_doc[] = "";
65 char M_Curve_Get_doc[] = "xxx";
69 /*****************************************************************************/
70 /* Python API function prototypes for the Curve module. */
71 /*****************************************************************************/
72 static PyObject *M_Curve_New( PyObject * self, PyObject * args );
73 static PyObject *M_Curve_Get( PyObject * self, PyObject * args );
76 /*****************************************************************************/
77 /* Python BPy_Curve instance methods declarations: */
78 /*****************************************************************************/
79 static PyObject *Curve_getName( BPy_Curve * self );
80 static PyObject *Curve_setName( BPy_Curve * self, PyObject * args );
81 static PyObject *Curve_getPathLen( BPy_Curve * self );
82 static PyObject *Curve_setPathLen( BPy_Curve * self, PyObject * args );
83 static PyObject *Curve_getTotcol( BPy_Curve * self );
84 static PyObject *Curve_setTotcol( BPy_Curve * self, PyObject * args );
85 static PyObject *Curve_getMode( BPy_Curve * self );
86 static PyObject *Curve_setMode( BPy_Curve * self, PyObject * args );
87 static PyObject *Curve_getBevresol( BPy_Curve * self );
88 static PyObject *Curve_setBevresol( BPy_Curve * self, PyObject * args );
89 static PyObject *Curve_getResolu( BPy_Curve * self );
90 static PyObject *Curve_setResolu( BPy_Curve * self, PyObject * args );
91 static PyObject *Curve_getResolv( BPy_Curve * self );
92 static PyObject *Curve_setResolv( BPy_Curve * self, PyObject * args );
93 static PyObject *Curve_getWidth( BPy_Curve * self );
94 static PyObject *Curve_setWidth( BPy_Curve * self, PyObject * args );
95 static PyObject *Curve_getExt1( BPy_Curve * self );
96 static PyObject *Curve_setExt1( BPy_Curve * self, PyObject * args );
97 static PyObject *Curve_getExt2( BPy_Curve * self );
98 static PyObject *Curve_setExt2( BPy_Curve * self, PyObject * args );
99 static PyObject *Curve_getControlPoint( BPy_Curve * self, PyObject * args );
100 static PyObject *Curve_setControlPoint( BPy_Curve * self, PyObject * args );
101 static PyObject *Curve_getLoc( BPy_Curve * self );
102 static PyObject *Curve_setLoc( BPy_Curve * self, PyObject * args );
103 static PyObject *Curve_getRot( BPy_Curve * self );
104 static PyObject *Curve_setRot( BPy_Curve * self, PyObject * args );
105 static PyObject *Curve_getSize( BPy_Curve * self );
106 static PyObject *Curve_setSize( BPy_Curve * self, PyObject * args );
107 static PyObject *Curve_getNumCurves( BPy_Curve * self );
108 static PyObject *Curve_isNurb( BPy_Curve * self, PyObject * args );
109 static PyObject *Curve_isCyclic( BPy_Curve * self, PyObject * args);
110 static PyObject *Curve_getNumPoints( BPy_Curve * self, PyObject * args );
111 static PyObject *Curve_getNumPoints( BPy_Curve * self, PyObject * args );
113 static PyObject *Curve_appendPoint( BPy_Curve * self, PyObject * args );
114 static PyObject *Curve_appendNurb( BPy_Curve * self, PyObject * args );
116 static PyObject *Curve_getMaterials( BPy_Curve * self );
118 static PyObject *Curve_getIter( BPy_Curve * self );
119 static PyObject *Curve_iterNext( BPy_Curve * self );
120 static PyObject *Curve_update( BPy_Curve * self );
121 PyObject *Curve_getNurb( BPy_Curve * self, int n );
122 static int Curve_length( PyInstanceObject * inst );
123 void update_displists( void *data );
125 void makeDispList( Object * ob );
126 struct chartrans *text_to_curve( Object * ob, int mode );
129 /*****************************************************************************/
130 /* Python method definitions for Blender.Curve module: */
131 /*****************************************************************************/
132 struct PyMethodDef M_Curve_methods[] = {
133 {"New", ( PyCFunction ) M_Curve_New, METH_VARARGS, M_Curve_New_doc},
134 {"Get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc},
135 {"get", M_Curve_Get, METH_VARARGS, M_Curve_Get_doc},
136 {NULL, NULL, 0, NULL}
140 /*****************************************************************************/
141 /* Python BPy_Curve instance methods table: */
142 /*****************************************************************************/
143 static PyMethodDef BPy_Curve_methods[] = {
144 {"getName", ( PyCFunction ) Curve_getName,
145 METH_NOARGS, "() - Return Curve Data name"},
146 {"setName", ( PyCFunction ) Curve_setName,
147 METH_VARARGS, "() - Sets Curve Data name"},
148 {"getPathLen", ( PyCFunction ) Curve_getPathLen,
149 METH_NOARGS, "() - Return Curve path length"},
150 {"setPathLen", ( PyCFunction ) Curve_setPathLen,
151 METH_VARARGS, "(int) - Sets Curve path length"},
152 {"getTotcol", ( PyCFunction ) Curve_getTotcol,
153 METH_NOARGS, "() - Return the number of materials of the curve"},
154 {"setTotcol", ( PyCFunction ) Curve_setTotcol,
155 METH_VARARGS, "(int) - Sets the number of materials of the curve"},
156 {"getFlag", ( PyCFunction ) Curve_getMode,
157 METH_NOARGS, "() - Return flag (see the doc for semantic)"},
158 {"setFlag", ( PyCFunction ) Curve_setMode,
159 METH_VARARGS, "(int) - Sets flag (see the doc for semantic)"},
160 {"getBevresol", ( PyCFunction ) Curve_getBevresol,
161 METH_NOARGS, "() - Return bevel resolution"},
162 {"setBevresol", ( PyCFunction ) Curve_setBevresol,
163 METH_VARARGS, "(int) - Sets bevel resolution"},
164 {"getResolu", ( PyCFunction ) Curve_getResolu,
165 METH_NOARGS, "() - Return U resolution"},
166 {"setResolu", ( PyCFunction ) Curve_setResolu,
167 METH_VARARGS, "(int) - Sets U resolution"},
168 {"getResolv", ( PyCFunction ) Curve_getResolv,
169 METH_NOARGS, "() - Return V resolution"},
170 {"setResolv", ( PyCFunction ) Curve_setResolv,
171 METH_VARARGS, "(int) - Sets V resolution"},
172 {"getWidth", ( PyCFunction ) Curve_getWidth,
173 METH_NOARGS, "() - Return curve width"},
174 {"setWidth", ( PyCFunction ) Curve_setWidth,
175 METH_VARARGS, "(int) - Sets curve width"},
176 {"getExt1", ( PyCFunction ) Curve_getExt1,
177 METH_NOARGS, "() - Returns extent 1 of the bevel"},
178 {"setExt1", ( PyCFunction ) Curve_setExt1,
179 METH_VARARGS, "(int) - Sets extent 1 of the bevel"},
180 {"getExt2", ( PyCFunction ) Curve_getExt2,
181 METH_NOARGS, "() - Return extent 2 of the bevel "},
182 {"setExt2", ( PyCFunction ) Curve_setExt2,
183 METH_VARARGS, "(int) - Sets extent 2 of the bevel "},
184 {"getControlPoint", ( PyCFunction ) Curve_getControlPoint,
185 METH_VARARGS, "(int numcurve,int numpoint) -\
186 Gets a control point.Depending upon the curve type, returne a list of 4 or 9 floats"},
187 {"setControlPoint", ( PyCFunction ) Curve_setControlPoint,
188 METH_VARARGS, "(int numcurve,int numpoint,float x,float y,float z,\
189 float w)(nurbs) or (int numcurve,int numpoint,float x1,...,x9(bezier)\
190 Sets a control point "},
191 {"getLoc", ( PyCFunction ) Curve_getLoc,
192 METH_NOARGS, "() - Gets Location of the curve (a 3-tuple) "},
193 {"setLoc", ( PyCFunction ) Curve_setLoc,
194 METH_VARARGS, "(3-tuple) - Sets Location "},
195 {"getRot", ( PyCFunction ) Curve_getRot,
196 METH_NOARGS, "() - Gets curve rotation"},
197 {"setRot", ( PyCFunction ) Curve_setRot,
198 METH_VARARGS, "(3-tuple) - Sets curve rotation"},
199 {"getSize", ( PyCFunction ) Curve_getSize,
200 METH_NOARGS, "() - Gets curve size"},
201 {"setSize", ( PyCFunction ) Curve_setSize,
202 METH_VARARGS, "(3-tuple) - Sets curve size"},
203 {"getNumCurves", ( PyCFunction ) Curve_getNumCurves,
204 METH_NOARGS, "() - Gets number of curves in Curve"},
205 {"isNurb", ( PyCFunction ) Curve_isNurb,
207 "(nothing or integer) - returns 1 if curve is type Nurb, O otherwise."},
208 {"isCyclic", ( PyCFunction ) Curve_isCyclic,
209 METH_VARARGS, "( nothing or integer ) - returns true if curve is cyclic (closed), false otherwise."},
210 {"getNumPoints", ( PyCFunction ) Curve_getNumPoints,
212 "(nothing or integer) - returns the number of points of the specified curve"},
213 {"appendPoint", ( PyCFunction ) Curve_appendPoint, METH_VARARGS,
214 "( int numcurve, list of coordinates) - adds a new point to end of curve"},
215 {"appendNurb", ( PyCFunction ) Curve_appendNurb, METH_VARARGS,
216 "( new_nurb ) - adds a new nurb to the Curve"},
217 {"update", ( PyCFunction ) Curve_update, METH_NOARGS,
218 "( ) - updates display lists after changes to Curve"},
219 {"getMaterials", ( PyCFunction ) Curve_getMaterials, METH_NOARGS,
220 "() - returns list of materials assigned to this Curve"},
221 {NULL, NULL, 0, NULL}
225 /*****************************************************************************/
226 /* Python Curve_Type callback function prototypes: */
227 /*****************************************************************************/
228 static void CurveDeAlloc( BPy_Curve * msh );
229 /* static int CurvePrint (BPy_Curve *msh, FILE *fp, int flags); */
230 static int CurveSetAttr( BPy_Curve * msh, char *name, PyObject * v );
231 static PyObject *CurveGetAttr( BPy_Curve * msh, char *name );
232 static PyObject *CurveRepr( BPy_Curve * msh );
234 PyObject *Curve_CreatePyObject( struct Curve *curve );
235 int Curve_CheckPyObject( PyObject * py_obj );
236 struct Curve *Curve_FromPyObject( PyObject * py_obj );
238 static PySequenceMethods Curve_as_sequence = {
239 ( inquiry ) Curve_length, /* sq_length */
240 ( binaryfunc ) 0, /* sq_concat */
241 ( intargfunc ) 0, /* sq_repeat */
242 ( intargfunc ) Curve_getNurb, /* sq_item */
243 ( intintargfunc ) 0, /* sq_slice */
245 0, /* sq_ass_slice */
246 ( objobjproc ) 0, /* sq_contains */
252 /*****************************************************************************/
253 /* Python Curve_Type structure definition: */
254 /*****************************************************************************/
255 PyTypeObject Curve_Type = {
256 PyObject_HEAD_INIT( NULL ) /* required macro */
258 "Curve", /* tp_name - for printing */
259 sizeof( BPy_Curve ), /* tp_basicsize - for allocation */
260 0, /* tp_itemsize - for allocation */
261 /* methods for standard operations */
262 ( destructor ) CurveDeAlloc, /* tp_dealloc */
264 ( getattrfunc ) CurveGetAttr, /* tp_getattr */
265 ( setattrfunc ) CurveSetAttr, /* tp_setattr */
267 ( reprfunc ) CurveRepr, /* tp_repr */
268 /* methods for standard classes */
269 0, /* tp_as_number */
270 &Curve_as_sequence, /* tp_as_sequence */
271 0, /* tp_as_mapping */
277 0, /* tp_as_buffer */
278 /* Flags to define presence of optional/expaned features */
279 Py_TPFLAGS_HAVE_ITER, /* tp_flags */
280 0, /* tp_doc - documentation string */
283 /* delete references to contained objects */
286 0, /* tp_richcompare - rich comparisions */
287 0, /* tp_weaklistoffset - weak reference enabler */
289 /* new release 2.2 stuff - Iterators */
290 ( getiterfunc ) Curve_getIter, /* tp_iter */
291 ( iternextfunc ) Curve_iterNext, /* tp_iternext */
293 /* Attribute descriptor and subclassing stuff */
294 BPy_Curve_methods, /* tp_methods */
299 0, /* tp_descr_get; */
300 0, /* tp_descr_set; */
301 0, /* tp_dictoffset; */
305 0, /* tp_free; Low-level free-memory routine */
308 0, /* tp_mro; method resolution order */
315 /*****************************************************************************/
316 /* Function: M_Curve_New */
317 /* Python equivalent: Blender.Curve.New */
318 /*****************************************************************************/
319 static PyObject *M_Curve_New( PyObject * self, PyObject * args )
323 BPy_Curve *pycurve; /* for Curve Data object wrapper in Python */
324 Curve *blcurve = 0; /* for actual Curve Data we create in Blender */
326 if( !PyArg_ParseTuple( args, "|s", &name ) )
327 return ( EXPP_ReturnPyObjError
328 ( PyExc_AttributeError,
329 "expected string argument or no argument" ) );
331 blcurve = add_curve( OB_CURVE ); /* first create the Curve Data in Blender */
333 if( blcurve == NULL ) /* bail out if add_curve() failed */
334 return ( EXPP_ReturnPyObjError
335 ( PyExc_RuntimeError,
336 "couldn't create Curve Data in Blender" ) );
338 /* return user count to zero because add_curve() inc'd it */
340 /* create python wrapper obj */
341 pycurve = ( BPy_Curve * ) PyObject_NEW( BPy_Curve, &Curve_Type );
343 if( pycurve == NULL )
344 return ( EXPP_ReturnPyObjError
346 "couldn't create Curve Data object" ) );
348 pycurve->curve = blcurve; /* link Python curve wrapper to Blender Curve */
350 PyOS_snprintf( buf, sizeof( buf ), "%s", name );
351 rename_id( &blcurve->id, buf );
354 return ( PyObject * ) pycurve;
357 /*****************************************************************************/
358 /* Function: M_Curve_Get */
359 /* Python equivalent: Blender.Curve.Get */
360 /*****************************************************************************/
361 static PyObject *M_Curve_Get( PyObject * self, PyObject * args )
366 BPy_Curve *wanted_curv;
368 if( !PyArg_ParseTuple( args, "|s", &name ) ) /* expects nothing or a string */
369 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
370 "expected string argument" ) );
371 if( name ) { /*a name has been given */
372 /* Use the name to search for the curve requested */
374 curv_iter = G.main->curve.first;
376 while( ( curv_iter ) && ( wanted_curv == NULL ) ) {
378 if( strcmp( name, curv_iter->id.name + 2 ) == 0 ) {
379 wanted_curv = ( BPy_Curve * )
380 PyObject_NEW( BPy_Curve, &Curve_Type );
382 wanted_curv->curve = curv_iter;
385 curv_iter = curv_iter->id.next;
388 if( wanted_curv == NULL ) { /* Requested curve doesn't exist */
390 PyOS_snprintf( error_msg, sizeof( error_msg ),
391 "Curve \"%s\" not found", name );
392 return ( EXPP_ReturnPyObjError
393 ( PyExc_NameError, error_msg ) );
397 return ( PyObject * ) wanted_curv;
398 } /* end of if(name) */
400 /* no name has been given; return a list of all curves by name. */
403 curv_iter = G.main->curve.first;
404 curvlist = PyList_New( 0 );
406 if( curvlist == NULL )
407 return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
408 "couldn't create PyList" ) );
411 BPy_Curve *found_cur =
412 ( BPy_Curve * ) PyObject_NEW( BPy_Curve,
414 found_cur->curve = curv_iter;
415 PyList_Append( curvlist, ( PyObject * ) found_cur );
417 curv_iter = curv_iter->id.next;
424 /*****************************************************************************/
425 /* Function: Curve_Init */
426 /*****************************************************************************/
427 PyObject *Curve_Init( void )
431 Curve_Type.ob_type = &PyType_Type;
434 Py_InitModule3( "Blender.Curve", M_Curve_methods,
436 return ( submodule );
439 /*****************************************************************************/
440 /* Python BPy_Curve methods: */
441 /* gives access to */
442 /* name, pathlen totcol flag bevresol */
443 /* resolu resolv width ext1 ext2 */
444 /* controlpoint loc rot size */
446 /*****************************************************************************/
449 static PyObject *Curve_getName( BPy_Curve * self )
451 PyObject *attr = PyString_FromString( self->curve->id.name + 2 );
456 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
457 "couldn't get Curve.name attribute" ) );
460 static PyObject *Curve_setName( BPy_Curve * self, PyObject * args )
465 if( !PyArg_ParseTuple( args, "s", &( name ) ) )
466 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
467 "expected string argument" ) );
468 PyOS_snprintf( buf, sizeof( buf ), "%s", name );
469 rename_id( &self->curve->id, buf ); /* proper way in Blender */
471 Py_INCREF( Py_None );
475 static PyObject *Curve_getPathLen( BPy_Curve * self )
477 PyObject *attr = PyInt_FromLong( ( long ) self->curve->pathlen );
482 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
483 "couldn't get Curve.pathlen attribute" ) );
487 static PyObject *Curve_setPathLen( BPy_Curve * self, PyObject * args )
490 if( !PyArg_ParseTuple( args, "i", &( self->curve->pathlen ) ) )
491 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
492 "expected int argument" ) );
494 Py_INCREF( Py_None );
499 static PyObject *Curve_getTotcol( BPy_Curve * self )
501 PyObject *attr = PyInt_FromLong( ( long ) self->curve->totcol );
506 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
507 "couldn't get Curve.totcol attribute" ) );
511 static PyObject *Curve_setTotcol( BPy_Curve * self, PyObject * args )
514 if( !PyArg_ParseTuple( args, "i", &( self->curve->totcol ) ) )
515 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
516 "expected int argument" ) );
518 Py_INCREF( Py_None );
523 static PyObject *Curve_getMode( BPy_Curve * self )
525 PyObject *attr = PyInt_FromLong( ( long ) self->curve->flag );
530 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
531 "couldn't get Curve.flag attribute" ) );
535 static PyObject *Curve_setMode( BPy_Curve * self, PyObject * args )
538 if( !PyArg_ParseTuple( args, "i", &( self->curve->flag ) ) )
539 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
540 "expected int argument" ) );
542 Py_INCREF( Py_None );
547 static PyObject *Curve_getBevresol( BPy_Curve * self )
549 PyObject *attr = PyInt_FromLong( ( long ) self->curve->bevresol );
554 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
555 "couldn't get Curve.bevresol attribute" ) );
559 static PyObject *Curve_setBevresol( BPy_Curve * self, PyObject * args )
562 if( !PyArg_ParseTuple( args, "i", &( self->curve->bevresol ) ) )
563 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
564 "expected int argument" ) );
566 Py_INCREF( Py_None );
571 static PyObject *Curve_getResolu( BPy_Curve * self )
573 PyObject *attr = PyInt_FromLong( ( long ) self->curve->resolu );
578 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
579 "couldn't get Curve.resolu attribute" ) );
583 static PyObject *Curve_setResolu( BPy_Curve * self, PyObject * args )
586 if( !PyArg_ParseTuple( args, "i", &( self->curve->resolu ) ) )
587 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
588 "expected int argument" ) );
590 Py_INCREF( Py_None );
596 static PyObject *Curve_getResolv( BPy_Curve * self )
598 PyObject *attr = PyInt_FromLong( ( long ) self->curve->resolv );
603 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
604 "couldn't get Curve.resolv attribute" ) );
608 static PyObject *Curve_setResolv( BPy_Curve * self, PyObject * args )
611 if( !PyArg_ParseTuple( args, "i", &( self->curve->resolv ) ) )
612 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
613 "expected int argument" ) );
615 Py_INCREF( Py_None );
621 static PyObject *Curve_getWidth( BPy_Curve * self )
623 PyObject *attr = PyFloat_FromDouble( ( double ) self->curve->width );
628 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
629 "couldn't get Curve.width attribute" ) );
633 static PyObject *Curve_setWidth( BPy_Curve * self, PyObject * args )
636 if( !PyArg_ParseTuple( args, "f", &( self->curve->width ) ) )
637 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
638 "expected float argument" ) );
640 Py_INCREF( Py_None );
645 static PyObject *Curve_getExt1( BPy_Curve * self )
647 PyObject *attr = PyFloat_FromDouble( ( double ) self->curve->ext1 );
652 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
653 "couldn't get Curve.ext1 attribute" ) );
657 static PyObject *Curve_setExt1( BPy_Curve * self, PyObject * args )
660 if( !PyArg_ParseTuple( args, "f", &( self->curve->ext1 ) ) )
661 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
662 "expected float argument" ) );
664 Py_INCREF( Py_None );
670 static PyObject *Curve_getExt2( BPy_Curve * self )
672 PyObject *attr = PyFloat_FromDouble( ( double ) self->curve->ext2 );
677 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
678 "couldn't get Curve.ext2 attribute" ) );
682 static PyObject *Curve_setExt2( BPy_Curve * self, PyObject * args )
685 if( !PyArg_ParseTuple( args, "f", &( self->curve->ext2 ) ) )
686 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
687 "expected float argument" ) );
689 Py_INCREF( Py_None );
695 static PyObject *Curve_setControlPoint(BPy_Curve *self, PyObject *args)
697 Nurb*ptrnurb = self->curve->nurb.first;
698 int numcourbe,numpoint,i,j;
701 if (!ptrnurb){ Py_INCREF(Py_None);return Py_None;}
704 if (!PyArg_ParseTuple(args, "iiffff", &numcourbe,&numpoint,&x,&y,&z,&w))
705 return (EXPP_ReturnPyObjError (PyExc_AttributeError,
706 "expected int int float float float float arguments"));
708 if (!PyArg_ParseTuple(args, "iifffffffff", &numcourbe,&numpoint,
709 bez,bez+1,bez+2,bez+3,bez+4,bez+5,bez+6,bez+7,bez+8))
710 return (EXPP_ReturnPyObjError (PyExc_AttributeError,
711 "expected int int float float float float float float "
712 "float float float arguments"));
714 for(i = 0;i< numcourbe;i++)
715 ptrnurb=ptrnurb->next;
718 ptrnurb->bp[numpoint].vec[0] = x;
719 ptrnurb->bp[numpoint].vec[1] = y;
720 ptrnurb->bp[numpoint].vec[2] = z;
721 ptrnurb->bp[numpoint].vec[3] = w;
727 ptrnurb->bezt[numpoint].vec[i][j] = bez[i*3+j];
737 * Curve_setControlPoint
738 * this function sets an EXISTING control point.
739 * it does NOT add a new one.
742 static PyObject *Curve_setControlPoint( BPy_Curve * self, PyObject * args )
744 PyObject *listargs = 0;
745 Nurb *ptrnurb = self->curve->nurb.first;
746 int numcourbe, numpoint, i, j;
749 Py_INCREF( Py_None );
754 if( !PyArg_ParseTuple
755 ( args, "iiO", &numcourbe, &numpoint, &listargs ) )
756 return ( EXPP_ReturnPyObjError
757 ( PyExc_AttributeError,
758 "expected int int list arguments" ) );
760 if( !PyArg_ParseTuple
761 ( args, "iiO", &numcourbe, &numpoint, &listargs ) )
762 return ( EXPP_ReturnPyObjError
763 ( PyExc_AttributeError,
764 "expected int int list arguments" ) );
766 for( i = 0; i < numcourbe; i++ )
767 ptrnurb = ptrnurb->next;
770 for( i = 0; i < 4; i++ )
771 ptrnurb->bp[numpoint].vec[i] =
772 PyFloat_AsDouble( PyList_GetItem
776 for( i = 0; i < 3; i++ )
777 for( j = 0; j < 3; j++ )
778 ptrnurb->bezt[numpoint].vec[i][j] =
779 PyFloat_AsDouble( PyList_GetItem
783 Py_INCREF( Py_None );
787 static PyObject *Curve_getControlPoint( BPy_Curve * self, PyObject * args )
789 PyObject *liste = PyList_New( 0 ); /* return values */
793 /* input args: requested curve and point number on curve */
794 int numcourbe, numpoint;
796 if( !PyArg_ParseTuple( args, "ii", &numcourbe, &numpoint ) )
797 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
798 "expected int int arguments" ) );
799 if( ( numcourbe < 0 ) || ( numpoint < 0 ) )
800 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
801 " arguments must be non-negative" ) );
803 /* if no nurbs in this curve obj */
804 if( !self->curve->nurb.first )
807 /* walk the list of nurbs to find requested numcourbe */
808 ptrnurb = self->curve->nurb.first;
809 for( i = 0; i < numcourbe; i++ ) {
810 ptrnurb = ptrnurb->next;
811 if( !ptrnurb ) /* if zero, we ran just ran out of curves */
812 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
813 "curve index out of range" ) );
816 /* check numpoint param against pntsu */
817 if( numpoint >= ptrnurb->pntsu )
818 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
819 "point index out of range" ) );
821 if( ptrnurb->bp ) { /* if we are a nurb curve, you get 4 values */
822 for( i = 0; i < 4; i++ )
823 PyList_Append( liste,
824 PyFloat_FromDouble( ptrnurb->
829 if( ptrnurb->bezt ) { /* if we are a bezier, you get 9 values */
830 for( i = 0; i < 3; i++ )
831 for( j = 0; j < 3; j++ )
832 PyList_Append( liste,
833 PyFloat_FromDouble( ptrnurb->
845 static PyObject *Curve_getLoc( BPy_Curve * self )
848 PyObject *liste = PyList_New( 3 );
849 for( i = 0; i < 3; i++ )
850 PyList_SetItem( liste, i,
851 PyFloat_FromDouble( self->curve->loc[i] ) );
855 static PyObject *Curve_setLoc( BPy_Curve * self, PyObject * args )
857 PyObject *listargs = 0;
859 if( !PyArg_ParseTuple( args, "O", &listargs ) )
860 return EXPP_ReturnPyObjError( PyExc_AttributeError,
861 "expected list argument" );
862 if( !PyList_Check( listargs ) )
863 return ( EXPP_ReturnPyObjError
864 ( PyExc_TypeError, "expected a list" ) );
865 for( i = 0; i < 3; i++ ) {
866 PyObject *xx = PyList_GetItem( listargs, i );
867 self->curve->loc[i] = PyFloat_AsDouble( xx );
869 Py_INCREF( Py_None );
873 static PyObject *Curve_getRot( BPy_Curve * self )
877 PyObject *liste = PyList_New( 3 );
878 for( i = 0; i < 3; i++ )
879 PyList_SetItem( liste, i,
880 PyFloat_FromDouble( self->curve->rot[i] ) );
885 static PyObject *Curve_setRot( BPy_Curve * self, PyObject * args )
887 PyObject *listargs = 0;
889 if( !PyArg_ParseTuple( args, "O", &listargs ) )
890 return EXPP_ReturnPyObjError( PyExc_AttributeError,
891 "expected list argument" );
892 if( !PyList_Check( listargs ) )
893 return ( EXPP_ReturnPyObjError
894 ( PyExc_TypeError, "expected a list" ) );
895 for( i = 0; i < 3; i++ ) {
896 PyObject *xx = PyList_GetItem( listargs, i );
897 self->curve->rot[i] = PyFloat_AsDouble( xx );
899 Py_INCREF( Py_None );
903 static PyObject *Curve_getSize( BPy_Curve * self )
906 PyObject *liste = PyList_New( 3 );
907 for( i = 0; i < 3; i++ )
908 PyList_SetItem( liste, i,
909 PyFloat_FromDouble( self->curve->size[i] ) );
914 static PyObject *Curve_setSize( BPy_Curve * self, PyObject * args )
916 PyObject *listargs = 0;
918 if( !PyArg_ParseTuple( args, "O", &listargs ) )
919 return EXPP_ReturnPyObjError( PyExc_AttributeError,
920 "expected list argument" );
921 if( !PyList_Check( listargs ) )
922 return ( EXPP_ReturnPyObjError
923 ( PyExc_TypeError, "expected a list" ) );
924 for( i = 0; i < 3; i++ ) {
925 PyObject *xx = PyList_GetItem( listargs, i );
926 self->curve->size[i] = PyFloat_AsDouble( xx );
928 Py_INCREF( Py_None );
934 * Count the number of splines in a Curve Object
938 static PyObject *Curve_getNumCurves( BPy_Curve * self )
942 int num_curves = 0; /* start with no splines */
945 ptrnurb = self->curve->nurb.first;
946 if( ptrnurb ) { /* we have some nurbs in this curve */
949 ptrnurb = ptrnurb->next;
950 if( !ptrnurb ) /* no more curves */
955 ret_val = PyInt_FromLong( ( long ) num_curves );
961 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
962 "couldn't get number of curves" ) );
967 * count the number of points in a given spline
968 * int getNumPoints( curve_num=0 )
972 static PyObject *Curve_getNumPoints( BPy_Curve * self, PyObject * args )
976 int curve_num = 0; /* default spline number */
979 /* parse input arg */
980 if( !PyArg_ParseTuple( args, "|i", &curve_num ) )
981 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
982 "expected int argument" ) );
984 /* check arg - must be non-negative */
986 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
987 "argument must be non-negative" ) );
990 /* walk the list of curves looking for our curve */
991 ptrnurb = self->curve->nurb.first;
992 if( !ptrnurb ) { /* no splines in this Curve */
993 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
994 "no splines in this Curve" ) );
997 for( i = 0; i < curve_num; i++ ) {
998 ptrnurb = ptrnurb->next;
999 if( !ptrnurb ) /* if zero, we ran just ran out of curves */
1000 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1001 "curve index out of range" ) );
1004 /* pntsu is the number of points in curve */
1005 ret_val = PyInt_FromLong( ( long ) ptrnurb->pntsu );
1011 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
1012 "couldn't get number of points for curve" ) );
1016 * Test whether a given spline of a Curve is a nurb
1017 * as opposed to a bezier
1018 * int isNurb( curve_num=0 )
1021 static PyObject *Curve_isNurb( BPy_Curve * self, PyObject * args )
1023 int curve_num = 0; /* default value */
1029 /* parse and check input args */
1030 if( !PyArg_ParseTuple( args, "|i", &curve_num ) ) {
1031 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1032 "expected int argument" ) );
1034 if( curve_num < 0 ) {
1035 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1036 "curve number must be non-negative" ) );
1039 ptrnurb = self->curve->nurb.first;
1041 if( !ptrnurb ) /* no splines in this curve */
1042 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1043 "no splines in this Curve" ) );
1045 for( i = 0; i < curve_num; i++ ) {
1046 ptrnurb = ptrnurb->next;
1047 if( !ptrnurb ) /* if zero, we ran just ran out of curves */
1048 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1049 "curve index out of range" ) );
1052 /* right now, there are only two curve types, nurb and bezier. */
1053 is_nurb = ptrnurb->bp ? 1 : 0;
1055 ret_val = PyInt_FromLong( ( long ) is_nurb );
1060 return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
1061 "couldn't get curve type" ) );
1064 /* trying to make a check for closedness (cyclic), following on isNurb (above)
1065 copy-pasting done by antont@kyperjokki.fi */
1067 static PyObject *Curve_isCyclic( BPy_Curve * self, PyObject * args )
1069 int curve_num = 0; /* default value */
1072 * PyObject *ret_val;*/
1076 /* parse and check input args */
1077 if( !PyArg_ParseTuple( args, "|i", &curve_num ) ) {
1078 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1079 "expected int argument" ) );
1081 if( curve_num < 0 ) {
1082 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1083 "curve number must be non-negative" ) );
1086 ptrnurb = self->curve->nurb.first;
1088 if( !ptrnurb ) /* no splines in this curve */
1089 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1090 "no splines in this Curve" ) );
1092 for( i = 0; i < curve_num; i++ ) {
1093 ptrnurb = ptrnurb->next;
1094 if( !ptrnurb ) /* if zero, we ran just ran out of curves */
1095 return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
1096 "curve index out of range" ) );
1099 if( ptrnurb->flagu & CU_CYCLIC ){
1100 return EXPP_incr_ret_True();
1102 return EXPP_incr_ret_False();
1108 * Curve_appendPoint( numcurve, new_point )
1109 * append a new point to indicated spline
1112 static PyObject *Curve_appendPoint( BPy_Curve * self, PyObject * args )
1115 int nurb_num; /* index of curve we append to */
1116 PyObject *coord_args; /* coords for new point */
1117 Nurb *nurb = self->curve->nurb.first; /* first nurb in Curve */
1119 /* fixme - need to malloc new Nurb */
1121 return ( EXPP_ReturnPyObjError
1122 ( PyExc_AttributeError, "no nurbs in this Curve" ) );
1124 if( !PyArg_ParseTuple( args, "iO", &nurb_num, &coord_args ) )
1125 return ( EXPP_ReturnPyObjError
1126 ( PyExc_AttributeError,
1127 "expected int, coords as arguments" ) );
1130 chase down the list of Nurbs looking for our curve.
1132 for( i = 0; i < nurb_num; i++ ) {
1134 if( !nurb ) /* we ran off end of list */
1135 return ( EXPP_ReturnPyObjError
1136 ( PyExc_AttributeError,
1137 "curve index out of range" ) );
1140 return CurNurb_appendPointToNurb( nurb, coord_args );
1145 static PyObject *Curve_appendNurb( BPy_Curve * self, PyObject * args )
1147 Nurb *nurb_ptr = self->curve->nurb.first;
1148 Nurb **pptr = ( Nurb ** ) & ( self->curve->nurb.first );
1152 /* walk to end of nurblist */
1154 while( nurb_ptr->next ) {
1155 nurb_ptr = nurb_ptr->next;
1157 pptr = &nurb_ptr->next;
1160 /* malloc new nurb */
1161 new_nurb = ( Nurb * ) MEM_callocN( sizeof( Nurb ), "appendNurb" );
1163 return EXPP_ReturnPyObjError
1164 ( PyExc_MemoryError, "unable to malloc Nurb" );
1166 if( CurNurb_appendPointToNurb( new_nurb, args ) ) {
1168 new_nurb->resolu = 12;
1169 new_nurb->resolv = 12;
1171 if( new_nurb->bezt ) { /* do setup for bezt */
1172 new_nurb->type = CU_BEZIER;
1173 new_nurb->bezt->h1 = HD_ALIGN;
1174 new_nurb->bezt->h2 = HD_ALIGN;
1175 new_nurb->bezt->f1 = 1;
1176 new_nurb->bezt->f2 = 1;
1177 new_nurb->bezt->f3 = 1;
1178 /* calchandlesNurb( new_nurb ); */
1179 } else { /* set up bp */
1180 new_nurb->pntsv = 1;
1181 new_nurb->type = CU_NURBS;
1182 new_nurb->orderu = 4;
1183 new_nurb->flagu = 0;
1184 new_nurb->flagv = 0;
1185 new_nurb->bp->f1 = 0;
1186 new_nurb->knotsu = 0;
1187 /*makenots( new_nurb, 1, new_nurb->flagu >> 1); */
1191 freeNurb( new_nurb );
1192 return NULL; /* with PyErr already set */
1195 return EXPP_incr_ret( Py_None );
1201 * method to update display list for a Curve.
1202 * used. after messing with control points
1205 static PyObject *Curve_update( BPy_Curve * self )
1207 /* update_displists( ( void * ) self->curve ); */
1208 freedisplist( &self->curve->disp );
1210 Py_INCREF( Py_None );
1215 * Curve_getMaterials
1219 static PyObject *Curve_getMaterials( BPy_Curve * self )
1221 return ( EXPP_PyList_fromMaterialList( self->curve->mat,
1222 self->curve->totcol, 1 ) );
1231 * create an iterator for our Curve.
1232 * this iterator returns the Nurbs for this Curve.
1233 * the iter_pointer always points to the next available item or null
1236 static PyObject *Curve_getIter( BPy_Curve * self )
1238 self->iter_pointer = self->curve->nurb.first;
1241 return ( PyObject * ) self;
1248 * get the next item.
1249 * iter_pointer always points to the next available element
1250 * or NULL if at the end of the list.
1253 static PyObject *Curve_iterNext( BPy_Curve * self )
1255 PyObject *po; /* return value */
1258 if( self->iter_pointer ) {
1259 pnurb = self->iter_pointer;
1260 self->iter_pointer = pnurb->next; /* advance iterator */
1261 po = CurNurb_CreatePyObject( pnurb ); /* make a bpy_nurb */
1263 return ( PyObject * ) po;
1266 /* if iter_pointer was null, we are at end */
1267 return ( EXPP_ReturnPyObjError
1268 ( PyExc_StopIteration, "iterator at end" ) );
1273 /* tp_sequence methods */
1277 * returns the number of curves in a Curve
1278 * this is a tp_as_sequence method, not a regular instance method.
1281 static int Curve_length( PyInstanceObject * inst )
1283 if( Curve_CheckPyObject( ( PyObject * ) inst ) )
1284 return ( ( int ) PyInt_AsLong
1285 ( Curve_getNumCurves( ( BPy_Curve * ) inst ) ) );
1287 return EXPP_ReturnIntError( PyExc_RuntimeError,
1288 "arg is not a BPy_Curve" );
1296 * returns the Nth nurb in a Curve.
1297 * this is one of the tp_as_sequence methods, hence the int N argument.
1298 * it is called via the [] operator, not as a usual instance method.
1301 PyObject *Curve_getNurb( BPy_Curve * self, int n )
1307 /* bail if index < 0 */
1309 return ( EXPP_ReturnPyObjError( PyExc_IndexError,
1310 "index less than 0" ) );
1311 /* bail if no Nurbs in Curve */
1312 if( self->curve->nurb.first == 0 )
1313 return ( EXPP_ReturnPyObjError( PyExc_IndexError,
1314 "no Nurbs in this Curve" ) );
1315 /* set pointer to nth Nurb */
1316 for( pNurb = self->curve->nurb.first, i = 0;
1317 pNurb != 0 && i < n; pNurb = pNurb->next, ++i )
1320 if( !pNurb ) /* we came to the end of the list */
1321 return ( EXPP_ReturnPyObjError( PyExc_IndexError,
1322 "index out of range" ) );
1324 pyo = CurNurb_CreatePyObject( pNurb ); /* make a bpy_curnurb */
1325 return ( PyObject * ) pyo;
1331 /*****************************************************************************/
1332 /* Function: CurveDeAlloc */
1333 /* Description: This is a callback function for the BPy_Curve type. It is */
1334 /* the destructor function. */
1335 /*****************************************************************************/
1336 static void CurveDeAlloc( BPy_Curve * self )
1338 PyObject_DEL( self );
1341 /*****************************************************************************/
1342 /* Function: CurveGetAttr */
1343 /* Description: This is a callback function for the BPy_Curve type. It is */
1344 /* the function that accesses BPy_Curve "member variables" and */
1346 /*****************************************************************************/
1347 static PyObject *CurveGetAttr( BPy_Curve * self, char *name )
1349 PyObject *attr = Py_None;
1351 if( strcmp( name, "name" ) == 0 )
1352 attr = PyString_FromString( self->curve->id.name + 2 );
1353 if( strcmp( name, "pathlen" ) == 0 )
1354 attr = PyInt_FromLong( self->curve->pathlen );
1355 if( strcmp( name, "totcol" ) == 0 )
1356 attr = PyInt_FromLong( self->curve->totcol );
1357 if( strcmp( name, "flag" ) == 0 )
1358 attr = PyInt_FromLong( self->curve->flag );
1359 if( strcmp( name, "bevresol" ) == 0 )
1360 attr = PyInt_FromLong( self->curve->bevresol );
1361 if( strcmp( name, "resolu" ) == 0 )
1362 attr = PyInt_FromLong( self->curve->resolu );
1363 if( strcmp( name, "resolv" ) == 0 )
1364 attr = PyInt_FromLong( self->curve->resolv );
1365 if( strcmp( name, "width" ) == 0 )
1366 attr = PyFloat_FromDouble( self->curve->width );
1367 if( strcmp( name, "ext1" ) == 0 )
1368 attr = PyFloat_FromDouble( self->curve->ext1 );
1369 if( strcmp( name, "ext2" ) == 0 )
1370 attr = PyFloat_FromDouble( self->curve->ext2 );
1371 if( strcmp( name, "loc" ) == 0 )
1372 return Curve_getLoc( self );
1373 if( strcmp( name, "rot" ) == 0 )
1374 return Curve_getRot( self );
1375 if( strcmp( name, "size" ) == 0 )
1376 return Curve_getSize( self );
1378 if( strcmp( name, "numpts" ) == 0 )
1379 return Curve_getNumPoints( self );
1384 return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
1385 "couldn't create PyObject" ) );
1387 if( attr != Py_None )
1388 return attr; /* member attribute found, return it */
1390 /* not an attribute, search the methods table */
1391 return Py_FindMethod( BPy_Curve_methods, ( PyObject * ) self, name );
1394 /*****************************************************************************/
1395 /* Function: CurveSetAttr */
1396 /* Description: This is a callback function for the BPy_Curve type. It */
1397 /* sets Curve Data attributes (member variables). */
1398 /*****************************************************************************/
1399 static int CurveSetAttr( BPy_Curve * self, char *name, PyObject * value )
1402 PyObject *error = NULL;
1403 valtuple = Py_BuildValue( "(O)", value );
1404 /* resolu resolv width ext1 ext2 */
1406 return EXPP_ReturnIntError( PyExc_MemoryError,
1407 "CurveSetAttr: couldn't create PyTuple" );
1409 if( strcmp( name, "name" ) == 0 )
1410 error = Curve_setName( self, valtuple );
1411 else if( strcmp( name, "pathlen" ) == 0 )
1412 error = Curve_setPathLen( self, valtuple );
1413 else if( strcmp( name, "resolu" ) == 0 )
1414 error = Curve_setResolu( self, valtuple );
1415 else if( strcmp( name, "resolv" ) == 0 )
1416 error = Curve_setResolv( self, valtuple );
1417 else if( strcmp( name, "width" ) == 0 )
1418 error = Curve_setWidth( self, valtuple );
1419 else if( strcmp( name, "ext1" ) == 0 )
1420 error = Curve_setExt1( self, valtuple );
1421 else if( strcmp( name, "ext2" ) == 0 )
1422 error = Curve_setExt2( self, valtuple );
1423 else if( strcmp( name, "loc" ) == 0 )
1424 error = Curve_setLoc( self, valtuple );
1425 else if( strcmp( name, "rot" ) == 0 )
1426 error = Curve_setRot( self, valtuple );
1427 else if( strcmp( name, "size" ) == 0 )
1428 error = Curve_setSize( self, valtuple );
1431 Py_DECREF( valtuple );
1433 if( ( strcmp( name, "Types" ) == 0 )
1434 || ( strcmp( name, "Modes" ) == 0 ) )
1435 return ( EXPP_ReturnIntError
1436 ( PyExc_AttributeError,
1437 "constant dictionary -- cannot be changed" ) );
1440 return ( EXPP_ReturnIntError
1441 ( PyExc_KeyError, "attribute not found" ) );
1444 Py_DECREF( valtuple );
1446 if( error != Py_None )
1448 Py_DECREF( Py_None );
1453 /*****************************************************************************/
1454 /* Function: CurveRepr */
1455 /* Description: This is a callback function for the BPy_Curve type. It */
1456 /* builds a meaninful string to represent curve objects. */
1457 /*****************************************************************************/
1458 static PyObject *CurveRepr( BPy_Curve * self )
1459 { /* used by 'repr' */
1461 return PyString_FromFormat( "[Curve \"%s\"]",
1462 self->curve->id.name + 2 );
1467 * Curve_CreatePyObject
1468 * constructor to build a py object from blender data
1471 PyObject *Curve_CreatePyObject( struct Curve * curve )
1473 BPy_Curve *blen_object;
1475 blen_object = ( BPy_Curve * ) PyObject_NEW( BPy_Curve, &Curve_Type );
1477 if( blen_object == NULL ) {
1480 blen_object->curve = curve;
1481 return ( ( PyObject * ) blen_object );
1485 int Curve_CheckPyObject( PyObject * py_obj )
1487 return ( py_obj->ob_type == &Curve_Type );
1491 struct Curve *Curve_FromPyObject( PyObject * py_obj )
1493 BPy_Curve *blen_obj;
1495 blen_obj = ( BPy_Curve * ) py_obj;
1496 return ( blen_obj->curve );
1503 * NOTE: this func has been replaced by freedisplist() in the recent
1504 * display list refactoring.
1506 * walk across all objects looking for curves
1507 * so we can update their ob's disp list
1510 void update_displists( void *data )
1518 layer = G.scene->lay;
1520 base = G.scene->base.first;
1522 if( base->lay & layer ) {
1525 if( ELEM( ob->type, OB_CURVE, OB_SURF ) ) {
1526 if( ob != G.obedit ) {
1527 if( ob->data == data ) {
1531 } else if( ob->type == OB_FONT ) {
1532 Curve *cu = ob->data;
1533 if( cu->textoncurve ) {
1534 if( ( ( Curve * ) cu->textoncurve->
1536 text_to_curve( ob, 0 );
1542 if( base->next == 0 && G.scene->set
1543 && base == G.scene->base.last )
1544 base = G.scene->set->base.first;