~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/python/api2_2x/vector.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $Id: vector.c,v 1.43 2006/11/17 17:50:43 khughes Exp $
 
2
 * $Id: vector.c,v 1.46 2007/03/30 12:39:21 campbellbarton Exp $
3
3
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or
640
640
                for(i = 0; i < vec->size; i++) {
641
641
                        vec->vec[i] *=  scalar;
642
642
                }
 
643
                
643
644
                Py_INCREF( v1 );
644
645
                return v1;
645
646
                
646
647
        } else if (MatrixObject_Check(v2)) {
647
648
                float vecCopy[4];
648
 
                int x,y, size= vec->size;
 
649
                int x,y, size = vec->size;
649
650
                MatrixObject *mat= (MatrixObject*)v2;
650
 
                        
651
 
                if(mat->colSize != vec->size){
 
651
                
 
652
                if(mat->colSize != size){
652
653
                        if(mat->rowSize == 4 && vec->size != 3){
653
654
                                return EXPP_ReturnPyObjError(PyExc_AttributeError, 
654
655
                                        "vector * matrix: matrix column size and the vector size must be the same");
655
 
                        }else{
 
656
                        } else {
656
657
                                vecCopy[3] = 1.0f;
657
658
                        }
658
659
                }
661
662
                        vecCopy[i] = vec->vec[i];
662
663
                }
663
664
                
 
665
                size = MIN2(size, mat->colSize);
 
666
                
664
667
                /*muliplication*/
665
 
                for(x = 0, i = 0; x < mat->colSize; x++) {
 
668
                for(x = 0, i = 0; x < size; x++, i++) {
666
669
                        double dot = 0.0f;
667
670
                        for(y = 0; y < mat->rowSize; y++) {
668
671
                                dot += mat->matrix[y][x] * vecCopy[y];
669
672
                        }
670
 
                        vec->vec[i++] = (float)dot;
 
673
                        vec->vec[i] = (float)dot;
671
674
                }
672
675
                Py_INCREF( v1 );
673
676
                return v1;
959
962
                        return EXPP_ReturnPyObjError(PyExc_AttributeError,
960
963
                                "vector.w: error, cannot get this axis for a 3D vector\n");
961
964
        
962
 
                return PyFloat_FromDouble(self->vec[4]);
 
965
                return PyFloat_FromDouble(self->vec[3]);
963
966
        default:
964
967
                {
965
968
                        char errstr[1024];
1061
1064
        dot= dot/param;
1062
1065
        
1063
1066
        for(i = 0; i < self->size; i++){
1064
 
                self->vec[i]= self->vec[i] / dot;
 
1067
                self->vec[i]= self->vec[i] / (float)dot;
1065
1068
        }
1066
1069
        
1067
1070
        return 0;