- Added Blender.Run(script) + doc update (forgot to mention in my previous commit).

Trying to fix two mistakes from my previous commit:

- nmesh.transform(): forgot yesterday that affine vectors have 4th component = 0, now updated normals transformation accordingly.

- As Ton pointed, recursive parsing of scripts dirs in search of scripts was a mess.  I simply forgot about the "//" trick and much worse, to protect against worst cases ("/", for example). Now the code uses BLI_convertstringcode to take care of "//", doesn't process if dir = "/" and there are limits:

max depth for traversing subdirs = 4
max dirs in the tree = 30.

I'll work more on this, check more, but these changes were tested and should make the code safer, of course, so I'm committing.  Sorry about the mess, I should take lessons on defensive programming ...
This commit is contained in:
2005-03-19 18:23:05 +00:00
parent 0d1738e285
commit dd17f7e725
3 changed files with 62 additions and 23 deletions

View File

@@ -233,12 +233,20 @@ static PyObject *Blender_Get( PyObject * self, PyObject * args )
ret = EXPP_incr_ret( Py_None );
}
else if(StringEqual(str, "udatadir")) {
char udatadir[FILE_MAXDIR];
if (U.pythondir[0] != '\0') {
char upydir[FILE_MAXDIR];
if (BLI_exists(U.pythondir)) {
BLI_make_file_string("/", udatadir, U.pythondir, "bpydata/");
if (BLI_exists(udatadir))
ret = PyString_FromString(udatadir);
BLI_strncpy(upydir, U.pythondir, FILE_MAXDIR);
BLI_convertstringcode(upydir, G.sce, 0);
if (BLI_exists(upydir)) {
char udatadir[FILE_MAXDIR];
BLI_make_file_string("/", udatadir, upydir, "bpydata/");
if (BLI_exists(udatadir))
ret = PyString_FromString(udatadir);
}
}
if (!ret) ret = EXPP_incr_ret(Py_None);
}
@@ -247,14 +255,20 @@ static PyObject *Blender_Get( PyObject * self, PyObject * args )
if (sdir)
ret = PyString_FromString(sdir);
else
ret = EXPP_incr_ret( Py_None );
else
ret = EXPP_incr_ret( Py_None );
}
else if( StringEqual( str, "uscriptsdir" ) ) {
if( BLI_exists( U.pythondir ) )
ret = PyString_FromString( U.pythondir );
else
ret = EXPP_incr_ret( Py_None );
if (U.pythondir[0] != '\0') {
char upydir[FILE_MAXDIR];
BLI_strncpy(upydir, U.pythondir, FILE_MAXDIR);
BLI_convertstringcode(upydir, G.sce, 0);
if( BLI_exists( upydir ) )
ret = PyString_FromString( upydir );
}
if (!ret) ret = EXPP_incr_ret(Py_None);
}
/* According to the old file (opy_blender.c), the following if
statement is a quick hack and needs some clean up. */