~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/python/mathutils/mathutils.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
#include "BLI_math.h"
37
37
#include "BLI_utildefines.h"
38
 
#include "BLI_dynstr.h"
 
38
 
 
39
#ifndef MATH_STANDALONE
 
40
#  include "BLI_dynstr.h"
 
41
#endif
39
42
 
40
43
PyDoc_STRVAR(M_Mathutils_doc,
41
44
"This module provides access to matrices, eulers, quaternions and vectors."
133
136
        }
134
137
}
135
138
 
 
139
/* on error, -1 is returned and no allocation is made */
136
140
int mathutils_array_parse_alloc(float **array, int array_min, PyObject *value, const char *error_prefix)
137
141
{
138
142
        int size;
164
168
        {
165
169
                PyObject *value_fast = NULL;
166
170
                // *array = NULL;
 
171
                int ret;
167
172
 
168
173
                /* non list/tuple cases */
169
174
                if (!(value_fast = PySequence_Fast(value, error_prefix))) {
182
187
 
183
188
                *array = PyMem_Malloc(size * sizeof(float));
184
189
 
185
 
                return mathutils_array_parse_fast(*array, size, value_fast, error_prefix);
 
190
                ret = mathutils_array_parse_fast(*array, size, value_fast, error_prefix);
 
191
 
 
192
                if (ret == -1) {
 
193
                        PyMem_Free(*array);
 
194
                }
 
195
 
 
196
                return ret;
186
197
        }
187
198
}
188
199
 
268
279
}
269
280
 
270
281
 
271
 
//----------------------------------MATRIX FUNCTIONS--------------------
 
282
/* ----------------------------------MATRIX FUNCTIONS-------------------- */
272
283
 
273
284
 
274
285
/* Utility functions */
275
286
 
276
 
// LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon
 
287
/* LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon */
277
288
#define SIGNMASK(i) (-(int)(((unsigned int)(i)) >> 31))
278
289
 
279
290
int EXPP_FloatsAreEqual(float af, float bf, int maxDiff)
294
305
 
295
306
/*---------------------- EXPP_VectorsAreEqual -------------------------
296
307
 * Builds on EXPP_FloatsAreEqual to test vectors */
297
 
int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps)
 
308
int EXPP_VectorsAreEqual(const float *vecA, const float *vecB, int size, int floatSteps)
298
309
{
299
310
        int x;
300
311
        for (x = 0; x < size; x++) {
304
315
        return 1;
305
316
}
306
317
 
 
318
#ifndef MATH_STANDALONE
307
319
/* dynstr as python string utility funcions, frees 'ds'! */
308
320
PyObject *mathutils_dynstr_to_py(struct DynStr *ds)
309
321
{
316
328
        PyMem_Free(ds_buf);
317
329
        return ret;
318
330
}
 
331
#endif
319
332
 
320
333
/* silly function, we dont use arg. just check its compatible with __deepcopy__ */
321
334
int mathutils_deepcopy_args_check(PyObject *args)