diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h index 939c4348461..d8719f399ae 100644 --- a/source/blender/blenlib/BLI_math_matrix.h +++ b/source/blender/blenlib/BLI_math_matrix.h @@ -84,7 +84,7 @@ void mul_v3_m4v3(float r[3], float M[4][4], float v[3]); void mul_mat3_m4_v3(float M[4][4], float r[3]); void mul_m4_v4(float M[4][4], float r[4]); void mul_v4_m4v4(float r[4], float M[4][4], float v[4]); -void mul_project_m4_v4(float M[4][4], float r[3]); +void mul_project_m4_v3(float M[4][4], float vec[3]); void mul_m3_v3(float M[3][3], float r[3]); void mul_v3_m3v3(float r[3], float M[3][3], float a[3]); diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 9fde87d734f..5edf6e28d4c 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -340,11 +340,9 @@ void mul_mat3_m4_v3(float mat[][4], float *vec) vec[2]= x*mat[0][2] + y*mat[1][2] + mat[2][2]*vec[2]; } -void mul_project_m4_v4(float mat[][4], float *vec) +void mul_project_m4_v3(float mat[][4], float vec[3]) { - float w; - - w = vec[0]*mat[0][3] + vec[1]*mat[1][3] + vec[2]*mat[2][3] + mat[3][3]; + const float w= vec[0]*mat[0][3] + vec[1]*mat[1][3] + vec[2]*mat[2][3] + mat[3][3]; mul_m4_v3(mat, vec); vec[0] /= w; diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index b054a5b0a6e..a5d2e0b38c7 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -271,7 +271,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* if only one projector, project coords to UVs */ if(num_projectors == 1 && projectors[0].uci==NULL) for(i = 0, co = coords; i < numVerts; ++i, ++co) - mul_project_m4_v4(projectors[0].projmat, *co); + mul_project_m4_v3(projectors[0].projmat, *co); mface = dm->getFaceArray(dm); numFaces = dm->getNumFaces(dm); @@ -345,11 +345,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, project_from_camera(tface->uv[3], coords[mf->v4], best_projector->uci); } else { - mul_project_m4_v4(best_projector->projmat, co1); - mul_project_m4_v4(best_projector->projmat, co2); - mul_project_m4_v4(best_projector->projmat, co3); + mul_project_m4_v3(best_projector->projmat, co1); + mul_project_m4_v3(best_projector->projmat, co2); + mul_project_m4_v3(best_projector->projmat, co3); if(mf->v4) - mul_project_m4_v4(best_projector->projmat, co4); + mul_project_m4_v3(best_projector->projmat, co4); /* apply transformed coords as UVs */ tface->uv[0][0] = co1[0];