[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32709] trunk/blender: move geometry python module into mathutils.geometry, since it provides utility functions using mathutils types.
Campbell Barton
ideasman42 at gmail.com
Tue Oct 26 00:44:02 CEST 2010
Revision: 32709
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32709
Author: campbellbarton
Date: 2010-10-26 00:44:01 +0200 (Tue, 26 Oct 2010)
Log Message:
-----------
move geometry python module into mathutils.geometry, since it provides utility functions using mathutils types.
Modified Paths:
--------------
trunk/blender/doc/python_api/sphinx_doc_gen.py
trunk/blender/release/scripts/op/console_python.py
trunk/blender/release/scripts/op/io_scene_obj/import_obj.py
trunk/blender/release/scripts/op/object.py
trunk/blender/release/scripts/op/uvcalc_smart_project.py
trunk/blender/source/blender/python/generic/CMakeLists.txt
trunk/blender/source/blender/python/generic/mathutils.c
trunk/blender/source/blender/python/generic/mathutils.h
trunk/blender/source/blender/python/intern/bpy.c
trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
Added Paths:
-----------
trunk/blender/source/blender/python/generic/mathutils_geometry.c
trunk/blender/source/blender/python/generic/mathutils_geometry.h
Removed Paths:
-------------
trunk/blender/source/blender/python/generic/geometry.c
trunk/blender/source/blender/python/generic/geometry.h
Modified: trunk/blender/doc/python_api/sphinx_doc_gen.py
===================================================================
--- trunk/blender/doc/python_api/sphinx_doc_gen.py 2010-10-25 21:57:45 UTC (rev 32708)
+++ trunk/blender/doc/python_api/sphinx_doc_gen.py 2010-10-25 22:44:01 UTC (rev 32709)
@@ -364,7 +364,7 @@
fw(" These parts of the API are relatively stable and are unlikely to change significantly\n")
fw(" * data API, access to attributes of blender data such as mesh verts, material color, timeline frames and scene objects\n")
fw(" * user interface functions for defining buttons, creation of menus, headers, panels\n")
- fw(" * modules: bgl, mathutils and geometry\n")
+ fw(" * modules: bgl and mathutils\n")
fw(" * game engine modules\n")
fw("\n")
Modified: trunk/blender/release/scripts/op/console_python.py
===================================================================
--- trunk/blender/release/scripts/op/console_python.py 2010-10-25 21:57:45 UTC (rev 32708)
+++ trunk/blender/release/scripts/op/console_python.py 2010-10-25 22:44:01 UTC (rev 32709)
@@ -268,7 +268,7 @@
add_scrollback("Execute: Enter", 'OUTPUT')
add_scrollback("Autocomplete: Ctrl+Space", 'OUTPUT')
add_scrollback("Ctrl +/- Wheel: Zoom", 'OUTPUT')
- add_scrollback("Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bgl, blf, mathutils, geometry", 'OUTPUT')
+ add_scrollback("Builtin Modules: bpy, bpy.data, bpy.ops, bpy.props, bpy.types, bpy.context, bgl, blf, mathutils", 'OUTPUT')
add_scrollback("", 'OUTPUT')
add_scrollback(" WARNING!!! Blender 2.5 API is subject to change, see API reference for more info.", 'ERROR')
add_scrollback("", 'OUTPUT')
Modified: trunk/blender/release/scripts/op/io_scene_obj/import_obj.py
===================================================================
--- trunk/blender/release/scripts/op/io_scene_obj/import_obj.py 2010-10-25 21:57:45 UTC (rev 32708)
+++ trunk/blender/release/scripts/op/io_scene_obj/import_obj.py 2010-10-25 22:44:01 UTC (rev 32709)
@@ -35,7 +35,7 @@
import time
import bpy
import mathutils
-from geometry import PolyFill
+from mathutils.geometry import PolyFill
from io_utils import load_image, unpack_list, unpack_face_list
Modified: trunk/blender/release/scripts/op/object.py
===================================================================
--- trunk/blender/release/scripts/op/object.py 2010-10-25 21:57:45 UTC (rev 32708)
+++ trunk/blender/release/scripts/op/object.py 2010-10-25 22:44:01 UTC (rev 32709)
@@ -256,7 +256,7 @@
ob.active_shape_key_index = len(me.shape_keys.keys) - 1
ob.show_shape_key = True
- from geometry import BarycentricTransform
+ from mathutils.geometry import BarycentricTransform
from mathutils import Vector
if use_clamp and mode == 'OFFSET':
Modified: trunk/blender/release/scripts/op/uvcalc_smart_project.py
===================================================================
--- trunk/blender/release/scripts/op/uvcalc_smart_project.py 2010-10-25 21:57:45 UTC (rev 32708)
+++ trunk/blender/release/scripts/op/uvcalc_smart_project.py 2010-10-25 22:44:01 UTC (rev 32709)
@@ -22,9 +22,8 @@
# <pep8 compliant>
-from mathutils import Matrix, Vector
+from mathutils import Matrix, Vector, geometry
import time
-import geometry
import bpy
from math import cos, radians
Modified: trunk/blender/source/blender/python/generic/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/python/generic/CMakeLists.txt 2010-10-25 21:57:45 UTC (rev 32708)
+++ trunk/blender/source/blender/python/generic/CMakeLists.txt 2010-10-25 22:44:01 UTC (rev 32709)
@@ -34,10 +34,10 @@
bgl.c
blf_api.c
bpy_internal_import.c
- geometry.c
mathutils.c
mathutils_color.c
mathutils_euler.c
+ mathutils_geometry.c
mathutils_matrix.c
mathutils_quat.c
mathutils_vector.c
Deleted: trunk/blender/source/blender/python/generic/geometry.c
===================================================================
--- trunk/blender/source/blender/python/generic/geometry.c 2010-10-25 21:57:45 UTC (rev 32708)
+++ trunk/blender/source/blender/python/generic/geometry.c 2010-10-25 22:44:01 UTC (rev 32709)
@@ -1,841 +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 *****
- */
-
-#include "geometry.h"
-
-/* Used for PolyFill */
-#include "BKE_displist.h"
-#include "MEM_guardedalloc.h"
-#include "BLI_blenlib.h"
-
-#include "BKE_utildefines.h"
-#include "BKE_curve.h"
-#include "BLI_boxpack2d.h"
-#include "BLI_math.h"
-
-#define SWAP_FLOAT(a,b,tmp) tmp=a; a=b; b=tmp
-#define eps 0.000001
-
-
-/*-------------------------DOC STRINGS ---------------------------*/
-static char M_Geometry_doc[] = "The Blender geometry module\n\n";
-static char M_Geometry_Intersect_doc[] = "(v1, v2, v3, ray, orig, clip=1) - returns the intersection between a ray and a triangle, if possible, returns None otherwise";
-static char M_Geometry_TriangleArea_doc[] = "(v1, v2, v3) - returns the area size of the 2D or 3D triangle defined";
-static char M_Geometry_TriangleNormal_doc[] = "(v1, v2, v3) - returns the normal of the 3D triangle defined";
-static char M_Geometry_QuadNormal_doc[] = "(v1, v2, v3, v4) - returns the normal of the 3D quad defined";
-static char M_Geometry_LineIntersect_doc[] = "(v1, v2, v3, v4) - returns a tuple with the points on each line respectively closest to the other";
-static char M_Geometry_PolyFill_doc[] = "(veclist_list) - takes a list of polylines (each point a vector) and returns the point indicies for a polyline filled with triangles";
-static char M_Geometry_LineIntersect2D_doc[] = "(lineA_p1, lineA_p2, lineB_p1, lineB_p2) - takes 2 lines (as 4 vectors) and returns a vector for their point of intersection or None";
-static char M_Geometry_ClosestPointOnLine_doc[] = "(pt, line_p1, line_p2) - takes a point and a line and returns a (Vector, float) for the point on the line, and the bool so you can know if the point was between the 2 points";
-static char M_Geometry_PointInTriangle2D_doc[] = "(pt, tri_p1, tri_p2, tri_p3) - takes 4 vectors, one is the point and the next 3 define the triangle, only the x and y are used from the vectors";
-static char M_Geometry_PointInQuad2D_doc[] = "(pt, quad_p1, quad_p2, quad_p3, quad_p4) - takes 5 vectors, one is the point and the next 4 define the quad, only the x and y are used from the vectors";
-static char M_Geometry_BoxPack2D_doc[] = "";
-static char M_Geometry_BezierInterp_doc[] = "";
-
-//---------------------------------INTERSECTION FUNCTIONS--------------------
-//----------------------------------geometry.Intersect() -------------------
-static PyObject *M_Geometry_Intersect(PyObject *UNUSED(self), PyObject* args)
-{
- VectorObject *ray, *ray_off, *vec1, *vec2, *vec3;
- float dir[3], orig[3], v1[3], v2[3], v3[3], e1[3], e2[3], pvec[3], tvec[3], qvec[3];
- float det, inv_det, u, v, t;
- int clip = 1;
-
- if(!PyArg_ParseTuple(args, "O!O!O!O!O!|i", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &ray, &vector_Type, &ray_off , &clip)) {
- PyErr_SetString( PyExc_TypeError, "expected 5 vector types\n" );
- return NULL;
- }
- if(vec1->size != 3 || vec2->size != 3 || vec3->size != 3 || ray->size != 3 || ray_off->size != 3) {
- PyErr_SetString( PyExc_TypeError, "only 3D vectors for all parameters\n");
- return NULL;
- }
-
- if(!BaseMath_ReadCallback(vec1) || !BaseMath_ReadCallback(vec2) || !BaseMath_ReadCallback(vec3) || !BaseMath_ReadCallback(ray) || !BaseMath_ReadCallback(ray_off))
- return NULL;
-
- VECCOPY(v1, vec1->vec);
- VECCOPY(v2, vec2->vec);
- VECCOPY(v3, vec3->vec);
-
- VECCOPY(dir, ray->vec);
- normalize_v3(dir);
-
- VECCOPY(orig, ray_off->vec);
-
- /* find vectors for two edges sharing v1 */
- sub_v3_v3v3(e1, v2, v1);
- sub_v3_v3v3(e2, v3, v1);
-
- /* begin calculating determinant - also used to calculated U parameter */
- cross_v3_v3v3(pvec, dir, e2);
-
- /* if determinant is near zero, ray lies in plane of triangle */
- det = dot_v3v3(e1, pvec);
-
- if (det > -0.000001 && det < 0.000001) {
- Py_RETURN_NONE;
- }
-
- inv_det = 1.0f / det;
-
- /* calculate distance from v1 to ray origin */
- sub_v3_v3v3(tvec, orig, v1);
-
- /* calculate U parameter and test bounds */
- u = dot_v3v3(tvec, pvec) * inv_det;
- if (clip && (u < 0.0f || u > 1.0f)) {
- Py_RETURN_NONE;
- }
-
- /* prepare to test the V parameter */
- cross_v3_v3v3(qvec, tvec, e1);
-
- /* calculate V parameter and test bounds */
- v = dot_v3v3(dir, qvec) * inv_det;
-
- if (clip && (v < 0.0f || u + v > 1.0f)) {
- Py_RETURN_NONE;
- }
-
- /* calculate t, ray intersects triangle */
- t = dot_v3v3(e2, qvec) * inv_det;
-
- mul_v3_fl(dir, t);
- add_v3_v3v3(pvec, orig, dir);
-
- return newVectorObject(pvec, 3, Py_NEW, NULL);
-}
-//----------------------------------geometry.LineIntersect() -------------------
-/* Line-Line intersection using algorithm from mathworld.wolfram.com */
-static PyObject *M_Geometry_LineIntersect(PyObject *UNUSED(self), PyObject* args)
-{
- PyObject * tuple;
- VectorObject *vec1, *vec2, *vec3, *vec4;
- float v1[3], v2[3], v3[3], v4[3], i1[3], i2[3];
-
- if( !PyArg_ParseTuple( args, "O!O!O!O!", &vector_Type, &vec1, &vector_Type, &vec2, &vector_Type, &vec3, &vector_Type, &vec4 ) ) {
- PyErr_SetString( PyExc_TypeError, "expected 4 vector types\n" );
- return NULL;
- }
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list