diff --git a/release/scripts/3ds_import.py b/release/scripts/3ds_import.py index 1963d2e7433..bcde82c4869 100644 --- a/release/scripts/3ds_import.py +++ b/release/scripts/3ds_import.py @@ -133,10 +133,12 @@ import BPyImage import BPyMessages -import struct -from struct import calcsize, unpack +try: + from struct import calcsize, unpack +except: + calcsize= unpack= None + -import os # If python version is less than 2.4, try to get set stuff from module try: @@ -958,7 +960,10 @@ def load_3ds(filename, PREF_UI= True): DEBUG= False if __name__=='__main__' and not DEBUG: - Blender.Window.FileSelector(load_3ds, 'Import 3DS', '*.3ds') + if calcsize==None: + Blender.Draw.PupMenu('Error%t|a full python installation not found') + else: + Blender.Window.FileSelector(load_3ds, 'Import 3DS', '*.3ds') # For testing compatibility #load_3ds('/metavr/convert/vehicle/truck_002/TruckTanker1.3DS', False) @@ -966,6 +971,7 @@ if __name__=='__main__' and not DEBUG: ''' else: + import os # DEBUG ONLY TIME= Blender.sys.time() import os diff --git a/source/blender/python/api2_2x/Geometry.c b/source/blender/python/api2_2x/Geometry.c index 80869889af7..cbb6d60632e 100644 --- a/source/blender/python/api2_2x/Geometry.c +++ b/source/blender/python/api2_2x/Geometry.c @@ -40,6 +40,7 @@ #include "BLI_blenlib.h" #include "BKE_utildefines.h" +#include "BKE_curve.h" #include "BLI_boxpack2d.h" #include "BLI_arithb.h" @@ -53,6 +54,7 @@ static PyObject *M_Geometry_ClosestPointOnLine( PyObject * self, PyObject * args static PyObject *M_Geometry_PointInTriangle2D( PyObject * self, PyObject * args ); static PyObject *M_Geometry_PointInQuad2D( PyObject * self, PyObject * args ); static PyObject *M_Geometry_BoxPack2D( PyObject * self, PyObject * args ); +static PyObject *M_Geometry_BezierInterp( PyObject * self, PyObject * args ); /*-------------------------DOC STRINGS ---------------------------*/ @@ -63,6 +65,7 @@ static char M_Geometry_ClosestPointOnLine_doc[] = "(pt, line_p1, line_p2) - take static char M_Geometry_PointInTriangle2D_doc[] = "(pt, tri_p1, tri_p2, tri_p3) - takes 4 vectors, one is the point and the next 3 define the triangle, only the x and y are used from the vectors"; static char M_Geometry_PointInQuad2D_doc[] = "(pt, quad_p1, quad_p2, quad_p3, quad_p4) - takes 5 vectors, one is the point and the next 4 define the quad, only the x and y are used from the vectors"; static char M_Geometry_BoxPack2D_doc[] = ""; +static char M_Geometry_BezierInterp_doc[] = ""; /*-----------------------METHOD DEFINITIONS ----------------------*/ struct PyMethodDef M_Geometry_methods[] = { {"PolyFill", ( PyCFunction ) M_Geometry_PolyFill, METH_O, M_Geometry_PolyFill_doc}, @@ -71,6 +74,7 @@ struct PyMethodDef M_Geometry_methods[] = { {"PointInTriangle2D", ( PyCFunction ) M_Geometry_PointInTriangle2D, METH_VARARGS, M_Geometry_PointInTriangle2D_doc}, {"PointInQuad2D", ( PyCFunction ) M_Geometry_PointInQuad2D, METH_VARARGS, M_Geometry_PointInQuad2D_doc}, {"BoxPack2D", ( PyCFunction ) M_Geometry_BoxPack2D, METH_O, M_Geometry_BoxPack2D_doc}, + {"BezierInterp", ( PyCFunction ) M_Geometry_BezierInterp, METH_VARARGS, M_Geometry_BezierInterp_doc}, {NULL, NULL, 0, NULL} }; @@ -469,3 +473,48 @@ static PyObject *M_Geometry_BoxPack2D( PyObject * self, PyObject * boxlist ) return Py_BuildValue( "ff", tot_width, tot_height); } + +static PyObject *M_Geometry_BezierInterp( PyObject * self, PyObject * args ) +{ + VectorObject *vec_k1, *vec_h1, *vec_k2, *vec_h2; + int resolu; + int dims; + int i; + float *coord_array, *fp; + + float k1[4] = {0.0, 0.0, 0.0, 0.0}; + float h1[4] = {0.0, 0.0, 0.0, 0.0}; + float k2[4] = {0.0, 0.0, 0.0, 0.0}; + float h2[4] = {0.0, 0.0, 0.0, 0.0}; + + float a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y, xi, yi, a1,a2,b1,b2, newvec[2]; + if( !PyArg_ParseTuple ( args, "O!O!O!O!i", + &vector_Type, &vec_k1, + &vector_Type, &vec_h1, + &vector_Type, &vec_h2, + &vector_Type, &vec_k2, &resolu) || (resolu<=1) + ) { + PyErr_SetString( PyExc_TypeError, "expected 4 vector types and an int greater then 1\n" ); + return NULL; + } + + dims= MAX4(vec_k1->size, vec_h1->size, vec_h2->size, vec_k2->size); + + for(i=0; i < vec_k1->size; i++) k1[i]= vec_k1->vec[i]; + for(i=0; i < vec_h1->size; i++) h1[i]= vec_h1->vec[i]; + for(i=0; i < vec_k2->size; i++) k2[i]= vec_k2->vec[i]; + for(i=0; i < vec_h2->size; i++) h2[i]= vec_h2->vec[i]; + + coord_array = MEM_callocN(dims * (resolu) * sizeof(float), "BezierInterp"); + for(i=0; i