[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38409] trunk/blender/source: move mathutils into its own lib.
Campbell Barton
ideasman42 at gmail.com
Fri Jul 15 06:01:50 CEST 2011
Revision: 38409
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38409
Author: campbellbarton
Date: 2011-07-15 04:01:47 +0000 (Fri, 15 Jul 2011)
Log Message:
-----------
move mathutils into its own lib.
Modified Paths:
--------------
trunk/blender/source/blender/python/CMakeLists.txt
trunk/blender/source/blender/python/SConscript
trunk/blender/source/blender/python/generic/CMakeLists.txt
trunk/blender/source/blender/python/intern/bpy.c
trunk/blender/source/blender/python/intern/bpy_interface.c
trunk/blender/source/blender/python/intern/bpy_rna.c
trunk/blender/source/blenderplayer/CMakeLists.txt
trunk/blender/source/creator/CMakeLists.txt
trunk/blender/source/gameengine/Expressions/PyObjectPlus.h
trunk/blender/source/gameengine/Ketsji/CMakeLists.txt
trunk/blender/source/gameengine/Ketsji/KX_PyMath.h
trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
trunk/blender/source/gameengine/Ketsji/SConscript
Added Paths:
-----------
trunk/blender/source/blender/python/mathutils/
trunk/blender/source/blender/python/mathutils/CMakeLists.txt
trunk/blender/source/blender/python/mathutils/mathutils.c
trunk/blender/source/blender/python/mathutils/mathutils.h
trunk/blender/source/blender/python/mathutils/mathutils_Color.c
trunk/blender/source/blender/python/mathutils/mathutils_Color.h
trunk/blender/source/blender/python/mathutils/mathutils_Euler.c
trunk/blender/source/blender/python/mathutils/mathutils_Euler.h
trunk/blender/source/blender/python/mathutils/mathutils_Matrix.c
trunk/blender/source/blender/python/mathutils/mathutils_Matrix.h
trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.c
trunk/blender/source/blender/python/mathutils/mathutils_Quaternion.h
trunk/blender/source/blender/python/mathutils/mathutils_Vector.c
trunk/blender/source/blender/python/mathutils/mathutils_Vector.h
trunk/blender/source/blender/python/mathutils/mathutils_geometry.c
trunk/blender/source/blender/python/mathutils/mathutils_geometry.h
Removed Paths:
-------------
trunk/blender/source/blender/python/generic/mathutils.c
trunk/blender/source/blender/python/generic/mathutils.h
trunk/blender/source/blender/python/generic/mathutils_Color.c
trunk/blender/source/blender/python/generic/mathutils_Color.h
trunk/blender/source/blender/python/generic/mathutils_Euler.c
trunk/blender/source/blender/python/generic/mathutils_Euler.h
trunk/blender/source/blender/python/generic/mathutils_Matrix.c
trunk/blender/source/blender/python/generic/mathutils_Matrix.h
trunk/blender/source/blender/python/generic/mathutils_Quaternion.c
trunk/blender/source/blender/python/generic/mathutils_Quaternion.h
trunk/blender/source/blender/python/generic/mathutils_Vector.c
trunk/blender/source/blender/python/generic/mathutils_Vector.h
trunk/blender/source/blender/python/generic/mathutils_geometry.c
trunk/blender/source/blender/python/generic/mathutils_geometry.h
Modified: trunk/blender/source/blender/python/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/python/CMakeLists.txt 2011-07-15 00:39:49 UTC (rev 38408)
+++ trunk/blender/source/blender/python/CMakeLists.txt 2011-07-15 04:01:47 UTC (rev 38409)
@@ -18,3 +18,4 @@
add_subdirectory(intern)
add_subdirectory(generic)
+add_subdirectory(mathutils)
Modified: trunk/blender/source/blender/python/SConscript
===================================================================
--- trunk/blender/source/blender/python/SConscript 2011-07-15 00:39:49 UTC (rev 38408)
+++ trunk/blender/source/blender/python/SConscript 2011-07-15 04:01:47 UTC (rev 38409)
@@ -1,6 +1,6 @@
#!/usr/bin/python
-# TODO, split into 2 files.
+# TODO, split into 3 files.
Import ('env')
@@ -18,9 +18,16 @@
defs.append('_DEBUG')
sources = env.Glob('generic/*.c')
-env.BlenderLib( libname = 'bf_python_ext', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [362,165]) # ketsji is 360
+env.BlenderLib( libname = 'bf_python_ext', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [363,165]) # ketsji is 360
+# mathutils
+defs = []
+
+sources = env.Glob('mathutils/*.c')
+env.BlenderLib( libname = 'bf_python_mathutils', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [361,165])
+
+
# bpy
defs = []
Modified: trunk/blender/source/blender/python/generic/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/python/generic/CMakeLists.txt 2011-07-15 00:39:49 UTC (rev 38408)
+++ trunk/blender/source/blender/python/generic/CMakeLists.txt 2011-07-15 04:01:47 UTC (rev 38409)
@@ -37,13 +37,6 @@
bgl.c
blf_py_api.c
bpy_internal_import.c
- mathutils.c
- mathutils_Color.c
- mathutils_Euler.c
- mathutils_Matrix.c
- mathutils_Quaternion.c
- mathutils_Vector.c
- mathutils_geometry.c
noise_py_api.c
py_capi_utils.c
@@ -51,13 +44,6 @@
bgl.h
blf_py_api.h
bpy_internal_import.h
- mathutils.h
- mathutils_Color.h
- mathutils_Euler.h
- mathutils_Matrix.h
- mathutils_Quaternion.h
- mathutils_Vector.h
- mathutils_geometry.h
noise_py_api.h
py_capi_utils.h
)
Deleted: trunk/blender/source/blender/python/generic/mathutils.c
===================================================================
--- trunk/blender/source/blender/python/generic/mathutils.c 2011-07-15 00:39:49 UTC (rev 38408)
+++ trunk/blender/source/blender/python/generic/mathutils.c 2011-07-15 04:01:47 UTC (rev 38409)
@@ -1,384 +0,0 @@
-/*
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * This is a new part of Blender.
- *
- * Contributor(s): Joseph Gilbert, Campbell Barton
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-/** \file blender/python/generic/mathutils.c
- * \ingroup pygen
- */
-
-#include <Python.h>
-
-#include "mathutils.h"
-
-#include "BLI_math.h"
-#include "BLI_utildefines.h"
-
-PyDoc_STRVAR(M_Mathutils_doc,
-"This module provides access to matrices, eulers, quaternions and vectors."
-);
-static int mathutils_array_parse_fast(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
-{
- PyObject *value_fast= NULL;
- PyObject *item;
-
- int i, size;
-
- /* non list/tuple cases */
- if(!(value_fast=PySequence_Fast(value, error_prefix))) {
- /* PySequence_Fast sets the error */
- return -1;
- }
-
- size= PySequence_Fast_GET_SIZE(value_fast);
-
- if(size > array_max || size < array_min) {
- if (array_max == array_min) {
- PyErr_Format(PyExc_ValueError,
- "%.200s: sequence size is %d, expected %d",
- error_prefix, size, array_max);
- }
- else {
- PyErr_Format(PyExc_ValueError,
- "%.200s: sequence size is %d, expected [%d - %d]",
- error_prefix, size, array_min, array_max);
- }
- Py_DECREF(value_fast);
- return -1;
- }
-
- i= size;
- do {
- i--;
- if(((array[i]= PyFloat_AsDouble((item= PySequence_Fast_GET_ITEM(value_fast, i)))) == -1.0f) && PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError,
- "%.200s: sequence index %d expected a number, "
- "found '%.200s' type, ",
- error_prefix, i, Py_TYPE(item)->tp_name);
- Py_DECREF(value_fast);
- return -1;
- }
- } while(i);
-
- Py_XDECREF(value_fast);
- return size;
-}
-
-/* helper functionm returns length of the 'value', -1 on error */
-int mathutils_array_parse(float *array, int array_min, int array_max, PyObject *value, const char *error_prefix)
-{
-#if 1 /* approx 6x speedup for mathutils types */
- int size;
-
- if( (VectorObject_Check(value) && (size= ((VectorObject *)value)->size)) ||
- (EulerObject_Check(value) && (size= 3)) ||
- (QuaternionObject_Check(value) && (size= 4)) ||
- (ColorObject_Check(value) && (size= 3))
- ) {
- if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
- return -1;
- }
-
- if(size > array_max || size < array_min) {
- if (array_max == array_min) {
- PyErr_Format(PyExc_ValueError,
- "%.200s: sequence size is %d, expected %d",
- error_prefix, size, array_max);
- }
- else {
- PyErr_Format(PyExc_ValueError,
- "%.200s: sequence size is %d, expected [%d - %d]",
- error_prefix, size, array_min, array_max);
- }
- return -1;
- }
-
- memcpy(array, ((BaseMathObject *)value)->data, size * sizeof(float));
- return size;
- }
- else
-#endif
- {
- return mathutils_array_parse_fast(array, array_min, array_max, value, error_prefix);
- }
-}
-
-int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error_prefix)
-{
- if(EulerObject_Check(value)) {
- if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
- return -1;
- }
- else {
- eulO_to_mat3(rmat, ((EulerObject *)value)->eul, ((EulerObject *)value)->order);
- return 0;
- }
- }
- else if (QuaternionObject_Check(value)) {
- if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
- return -1;
- }
- else {
- float tquat[4];
- normalize_qt_qt(tquat, ((QuaternionObject *)value)->quat);
- quat_to_mat3(rmat, tquat);
- return 0;
- }
- }
- else if (MatrixObject_Check(value)) {
- if(BaseMath_ReadCallback((BaseMathObject *)value) == -1) {
- return -1;
- }
- else if(((MatrixObject *)value)->col_size < 3 || ((MatrixObject *)value)->row_size < 3) {
- PyErr_Format(PyExc_ValueError,
- "%.200s: matrix must have minimum 3x3 dimensions",
- error_prefix);
- return -1;
- }
- else {
- matrix_as_3x3(rmat, (MatrixObject *)value);
- normalize_m3(rmat);
- return 0;
- }
- }
- else {
- PyErr_Format(PyExc_TypeError,
- "%.200s: expected a Euler, Quaternion or Matrix type, "
- "found %.200s", error_prefix, Py_TYPE(value)->tp_name);
- return -1;
- }
-}
-
-
-//----------------------------------MATRIX FUNCTIONS--------------------
-
-
-/* Utility functions */
-
-// LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon
-#define SIGNMASK(i) (-(int)(((unsigned int)(i))>>31))
-
-int EXPP_FloatsAreEqual(float af, float bf, int maxDiff)
-{ // solid, fast routine across all platforms
- // with constant time behavior
- int ai = *(int *)(&af);
- int bi = *(int *)(&bf);
- int test = SIGNMASK(ai^bi);
- int diff, v1, v2;
-
- assert((0 == test) || (0xFFFFFFFF == test));
- diff = (ai ^ (test & 0x7fffffff)) - bi;
- v1 = maxDiff + diff;
- v2 = maxDiff - diff;
- return (v1|v2) >= 0;
-}
-
-/*---------------------- EXPP_VectorsAreEqual -------------------------
- Builds on EXPP_FloatsAreEqual to test vectors */
-int EXPP_VectorsAreEqual(float *vecA, float *vecB, int size, int floatSteps)
-{
- int x;
- for (x=0; x< size; x++){
- if (EXPP_FloatsAreEqual(vecA[x], vecB[x], floatSteps) == 0)
- return 0;
- }
- return 1;
-}
-
-
-/* Mathutils Callbacks */
-
-/* for mathutils internal use only, eventually should re-alloc but to start with we only have a few users */
-static Mathutils_Callback *mathutils_callbacks[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
-
-int Mathutils_RegisterCallback(Mathutils_Callback *cb)
-{
- int i;
-
- /* find the first free slot */
- for(i= 0; mathutils_callbacks[i]; i++) {
- if(mathutils_callbacks[i]==cb) /* already registered? */
- return i;
- }
-
- mathutils_callbacks[i] = cb;
- return i;
-}
-
-/* use macros to check for NULL */
-int _BaseMathObject_ReadCallback(BaseMathObject *self)
-{
- Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
- if(cb->get(self, self->cb_subtype) != -1)
- return 0;
-
- if(!PyErr_Occurred()) {
- PyErr_Format(PyExc_RuntimeError,
- "%s read, user has become invalid",
- Py_TYPE(self)->tp_name);
- }
- return -1;
-}
-
-int _BaseMathObject_WriteCallback(BaseMathObject *self)
-{
- Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
- if(cb->set(self, self->cb_subtype) != -1)
- return 0;
-
- if(!PyErr_Occurred()) {
- PyErr_Format(PyExc_RuntimeError,
- "%s write, user has become invalid",
- Py_TYPE(self)->tp_name);
- }
- return -1;
-}
-
-int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
-{
- Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
- if(cb->get_index(self, self->cb_subtype, index) != -1)
- return 0;
-
- if(!PyErr_Occurred()) {
- PyErr_Format(PyExc_RuntimeError,
- "%s read index, user has become invalid",
- Py_TYPE(self)->tp_name);
- }
- return -1;
-}
-
-int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index)
-{
- Mathutils_Callback *cb= mathutils_callbacks[self->cb_type];
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list