diff options
author | Willian Padovani Germano <wpgermano@gmail.com> | 2005-03-19 21:23:05 +0300 |
---|---|---|
committer | Willian Padovani Germano <wpgermano@gmail.com> | 2005-03-19 21:23:05 +0300 |
commit | dd17f7e725a9380c1e73b90cab8465bc0546fb8e (patch) | |
tree | 2f66bb4e4a89d1471d1ae90869a2ec9d0eca9a1e /source/blender/python/api2_2x/NMesh.c | |
parent | 0d1738e285c079a03fb9c0a2f5a68c0a1b38939f (diff) |
BPython:
- 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 ...
Diffstat (limited to 'source/blender/python/api2_2x/NMesh.c')
-rw-r--r-- | source/blender/python/api2_2x/NMesh.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c index 583a74e49a5..48ab3e46d62 100644 --- a/source/blender/python/api2_2x/NMesh.c +++ b/source/blender/python/api2_2x/NMesh.c @@ -3884,7 +3884,9 @@ static PyObject *NMesh_transform (PyObject *self, PyObject *args) * of the transpose of the supplied matrix */ float invmat[4][4]; - if (!Mat4Invert(invmat, mat->matrix)) + /* we only need to invert a 3x3 submatrix, because the 4th component of + * affine vectors is 0, but Mat4Invert reports non invertible matrices */ + if (!Mat4Invert((float(*)[4])*invmat, (float(*)[4])*mat->matrix)) return EXPP_ReturnPyObjError (PyExc_AttributeError, "given matrix is not invertible"); @@ -3893,12 +3895,9 @@ static PyObject *NMesh_transform (PyObject *self, PyObject *args) vx = mv->no[0]; vy = mv->no[1]; vz = mv->no[2]; - mv->no[0] = vx*invmat[0][0] + vy*invmat[0][1] + vz*invmat[0][2] + - invmat[0][3]; - mv->no[1] = vx*invmat[1][0] + vy*invmat[1][1] + vz*invmat[1][2] + - invmat[1][3]; - mv->no[2] = vx*invmat[2][0] + vy*invmat[2][1] + vz*invmat[2][2] + - invmat[2][3]; + mv->no[0] = vx*invmat[0][0] + vy*invmat[0][1] + vz*invmat[0][2]; + mv->no[1] = vx*invmat[1][0] + vy*invmat[1][1] + vz*invmat[1][2]; + mv->no[2] = vx*invmat[2][0] + vy*invmat[2][1] + vz*invmat[2][2]; Normalise(mv->no); Py_DECREF(mv); } |