Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-10-04 21:06:29 +0400
committerCampbell Barton <ideasman42@gmail.com>2006-10-04 21:06:29 +0400
commit0c6bb8c079008e280cf1cba774ca17b176c6082b (patch)
treed522327dad866ae7d14315c394e9dc42e93b72ac /source
parent0f497dea2bcc58211aecd4aaab90ed4031b31eb5 (diff)
mesh.transform() was applying the inverted 4x4 matrix to the normals, without removing the translation part.
iter with a char value did not allow for -1, my bad, using short now.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/Mesh.c15
-rw-r--r--source/blender/python/api2_2x/Mesh.h4
2 files changed, 10 insertions, 9 deletions
diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c
index 7f6f6734074..1bdb6ee679f 100644
--- a/source/blender/python/api2_2x/Mesh.c
+++ b/source/blender/python/api2_2x/Mesh.c
@@ -5867,8 +5867,8 @@ static PyObject *Mesh_transform( BPy_Mesh *self, PyObject *args )
if( recalc_normals ) {
/* loop through all the verts and transform normals by the inverse
* of the transpose of the supplied matrix */
- float invmat[4][4];
-
+ float invmat[4][4], vec[3], nx, ny, nz;
+
/*
* we only need to invert a 3x3 submatrix, because the 4th component of
* affine vectors is 0, but Mat4Invert reports non invertible matrices
@@ -5884,11 +5884,12 @@ static PyObject *Mesh_transform( BPy_Mesh *self, PyObject *args )
mv = mesh->mvert;
for( i = 0; i < mesh->totvert; i++, mv++ ) {
- float vec[3];
- vec[0] = (float)(mv->no[0] / 32767.0);
- vec[1] = (float)(mv->no[1] / 32767.0);
- vec[2] = (float)(mv->no[2] / 32767.0);
- Mat4MulVecfl( (float(*)[4])*invmat, vec );
+ nx= vec[0] = (float)(mv->no[0] / 32767.0);
+ ny= vec[1] = (float)(mv->no[1] / 32767.0);
+ nz= vec[2] = (float)(mv->no[2] / 32767.0);
+ vec[0] = nx*invmat[0][0] + ny*invmat[0][1] + nz*invmat[0][2];
+ vec[1] = nx*invmat[1][0] + ny*invmat[1][1] + nz*invmat[1][2];
+ vec[2] = nx*invmat[2][0] + ny*invmat[2][1] + nz*invmat[2][2];
Normalise( vec );
mv->no[0] = (short)(vec[0] * 32767.0);
mv->no[1] = (short)(vec[1] * 32767.0);
diff --git a/source/blender/python/api2_2x/Mesh.h b/source/blender/python/api2_2x/Mesh.h
index 43a1154b11e..2599ae38fe3 100644
--- a/source/blender/python/api2_2x/Mesh.h
+++ b/source/blender/python/api2_2x/Mesh.h
@@ -89,7 +89,7 @@ typedef struct {
PyObject_VAR_HEAD /* required python macro */
Mesh *mesh; /* points to a Mesh */
int index;
- char iter; /* char because it can only ever be between -1 and 2 */
+ short iter; /* char because it can only ever be between -1 and 2 */
} BPy_MEdge; /* a Mesh edge */
typedef struct {
@@ -102,7 +102,7 @@ typedef struct {
PyObject_VAR_HEAD /* required python macro */
Mesh * mesh;
int index;
- char iter; /* char because it can only ever be between -1 and 4 */
+ short iter; /* char because it can only ever be between -1 and 4 */
} BPy_MFace; /* a Mesh face */
typedef struct {