forked from bartvdbraak/blender
finish adding Geometry module, removed polyfill from mathutils, updated epydoc links and updated BPyMesh NGon function
This commit is contained in:
parent
156f2030fd
commit
6adf0e6543
@ -657,7 +657,7 @@ def ngon(from_data, indices, PREF_FIX_LOOPS= True):
|
||||
if verts[i][1]==verts[i-1][0]:
|
||||
verts.pop(i-1)
|
||||
|
||||
fill= Blender.Mathutils.PolyFill([verts])
|
||||
fill= Blender.Geometry.PolyFill([verts])
|
||||
|
||||
else:
|
||||
'''
|
||||
@ -767,7 +767,7 @@ def ngon(from_data, indices, PREF_FIX_LOOPS= True):
|
||||
vert_map[i+ii]= vert[2]
|
||||
ii+=len(verts)
|
||||
|
||||
fill= Blender.Mathutils.PolyFill([ [v[0] for v in loop] for loop in loop_list if len(loop) > 2 ])
|
||||
fill= Blender.Geometry.PolyFill([ [v[0] for v in loop] for loop in loop_list if len(loop) > 2 ])
|
||||
#draw_loops(loop_list)
|
||||
#raise 'done loop'
|
||||
# map to original indicies
|
||||
|
@ -75,6 +75,7 @@ struct ID; /*keep me up here */
|
||||
#include "Lamp.h"
|
||||
#include "Lattice.h"
|
||||
#include "Mathutils.h"
|
||||
#include "Geometry.h"
|
||||
#include "Mesh.h"
|
||||
#include "Metaball.h"
|
||||
#include "Modifier.h"
|
||||
@ -950,6 +951,7 @@ void M_Blender_Init(void)
|
||||
PyDict_SetItemString(dict, "Mesh", Mesh_Init());
|
||||
PyDict_SetItemString(dict, "Metaball", Metaball_Init());
|
||||
PyDict_SetItemString(dict, "Mathutils", Mathutils_Init());
|
||||
PyDict_SetItemString(dict, "Geometry", Geometry_Init());
|
||||
PyDict_SetItemString(dict, "Modifier", Modifier_Init());
|
||||
PyDict_SetItemString(dict, "NMesh", NMesh_Init());
|
||||
PyDict_SetItemString(dict, "Noise", Noise_Init());
|
||||
|
@ -37,11 +37,6 @@
|
||||
#include "BLI_rand.h"
|
||||
#include "BKE_utildefines.h"
|
||||
|
||||
/* Used for PolyFill */
|
||||
#include "BKE_displist.h"
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
#include "gen_utils.h"
|
||||
|
||||
//-------------------------DOC STRINGS ---------------------------
|
||||
@ -77,7 +72,6 @@ static char M_Mathutils_TriangleArea_doc[] = "(v1, v2, v3) - returns the area si
|
||||
static char M_Mathutils_TriangleNormal_doc[] = "(v1, v2, v3) - returns the normal of the 3D triangle defined";
|
||||
static char M_Mathutils_QuadNormal_doc[] = "(v1, v2, v3, v4) - returns the normal of the 3D quad defined";
|
||||
static char M_Mathutils_LineIntersect_doc[] = "(v1, v2, v3, v4) - returns a tuple with the points on each line respectively closest to the other";
|
||||
static char M_Mathutils_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_Mathutils_Point_doc[] = "Creates a 2d or 3d point object";
|
||||
//-----------------------METHOD DEFINITIONS ----------------------
|
||||
struct PyMethodDef M_Mathutils_methods[] = {
|
||||
@ -112,7 +106,6 @@ struct PyMethodDef M_Mathutils_methods[] = {
|
||||
{"TriangleNormal", ( PyCFunction ) M_Mathutils_TriangleNormal, METH_VARARGS, M_Mathutils_TriangleNormal_doc},
|
||||
{"QuadNormal", ( PyCFunction ) M_Mathutils_QuadNormal, METH_VARARGS, M_Mathutils_QuadNormal_doc},
|
||||
{"LineIntersect", ( PyCFunction ) M_Mathutils_LineIntersect, METH_VARARGS, M_Mathutils_LineIntersect_doc},
|
||||
{"PolyFill", ( PyCFunction ) M_Mathutils_PolyFill, METH_VARARGS, M_Mathutils_PolyFill_doc},
|
||||
{"Point", (PyCFunction) M_Mathutils_Point, METH_VARARGS, M_Mathutils_Point_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
@ -1537,100 +1530,6 @@ PyObject *M_Mathutils_LineIntersect( PyObject * self, PyObject * args )
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------Mathutils.PolyFill() -------------------
|
||||
/* PolyFill function, uses Blenders scanfill to fill multiple poly lines */
|
||||
PyObject *M_Mathutils_PolyFill( PyObject * self, PyObject * args )
|
||||
{
|
||||
PyObject *tri_list; /*return this list of tri's */
|
||||
PyObject *polyLineList, *polyLine, *polyVec;
|
||||
int i, len_polylines, len_polypoints;
|
||||
|
||||
/* display listbase */
|
||||
ListBase dispbase={NULL, NULL};
|
||||
DispList *dl;
|
||||
float *fp; /*pointer to the array of malloced dl->verts to set the points from the vectors */
|
||||
int index, *dl_face, totpoints=0;
|
||||
|
||||
|
||||
dispbase.first= dispbase.last= NULL;
|
||||
|
||||
|
||||
if( !PyArg_ParseTuple ( args, "O!", &PyList_Type, &polyLineList) ) {
|
||||
freedisplist(&dispbase);
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"expected a list of poly lines" );
|
||||
}
|
||||
|
||||
|
||||
if (EXPP_check_sequence_consistency( polyLineList, &PyList_Type ) != 1)
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"expected a list of lists of vectors" );
|
||||
|
||||
len_polylines = PySequence_Size( polyLineList );
|
||||
|
||||
for( i = 0; i < len_polylines; ++i ) {
|
||||
polyLine= PySequence_GetItem( polyLineList, i );
|
||||
|
||||
len_polypoints= PySequence_Size( polyLine );
|
||||
if (len_polypoints>2) { /* dont bother adding edges as polylines */
|
||||
if (EXPP_check_sequence_consistency( polyLine, &vector_Type ) != 1)
|
||||
return EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"expected a list of poly lines" );
|
||||
|
||||
dl= MEM_callocN(sizeof(DispList), "poly disp");
|
||||
BLI_addtail(&dispbase, dl);
|
||||
dl->type= DL_INDEX3;
|
||||
dl->nr= len_polypoints;
|
||||
dl->type= DL_POLY;
|
||||
dl->parts= 1; /* no faces, 1 edge loop */
|
||||
dl->col= 0; /* no material */
|
||||
dl->verts= fp= MEM_callocN( sizeof(float)*3*len_polypoints, "dl verts");
|
||||
dl->index= MEM_callocN(sizeof(int)*3*len_polypoints, "dl index");
|
||||
|
||||
for( index = 0; index<len_polypoints; ++index, fp+=3) {
|
||||
polyVec= PySequence_GetItem( polyLine, index );
|
||||
|
||||
fp[0] = ((VectorObject *)polyVec)->vec[0];
|
||||
fp[1] = ((VectorObject *)polyVec)->vec[1];
|
||||
if( ((VectorObject *)polyVec)->size > 2 )
|
||||
fp[2] = ((VectorObject *)polyVec)->vec[2];
|
||||
else
|
||||
fp[2]= 0.0f; /* if its a 2d vector then set the z to be zero */
|
||||
|
||||
totpoints++;
|
||||
Py_DECREF(polyVec);
|
||||
}
|
||||
}
|
||||
Py_DECREF(polyLine);
|
||||
}
|
||||
|
||||
if (totpoints) {
|
||||
/* now make the list to return */
|
||||
filldisplist(&dispbase, &dispbase);
|
||||
|
||||
|
||||
/* The faces are stored in a new DisplayList
|
||||
thats added to the head of the listbase */
|
||||
dl= dispbase.first;
|
||||
|
||||
tri_list= PyList_New(dl->parts);
|
||||
index= 0;
|
||||
|
||||
dl_face= dl->index;
|
||||
while(index < dl->parts) {
|
||||
PyList_SetItem(tri_list, index, Py_BuildValue("iii", dl_face[0], dl_face[1], dl_face[2]) );
|
||||
dl_face+= 3;
|
||||
index++;
|
||||
}
|
||||
freedisplist(&dispbase);
|
||||
} else {
|
||||
/* no points, do this so scripts dont barf */
|
||||
tri_list= PyList_New(0);
|
||||
}
|
||||
|
||||
return tri_list;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------NORMALS FUNCTIONS--------------------
|
||||
//----------------------------------Mathutils.QuadNormal() -------------------
|
||||
|
@ -72,7 +72,6 @@ PyObject *M_Mathutils_TriangleArea( PyObject * self, PyObject * args );
|
||||
PyObject *M_Mathutils_TriangleNormal( PyObject * self, PyObject * args );
|
||||
PyObject *M_Mathutils_QuadNormal( PyObject * self, PyObject * args );
|
||||
PyObject *M_Mathutils_LineIntersect( PyObject * self, PyObject * args );
|
||||
PyObject *M_Mathutils_PolyFill( PyObject * self, PyObject * args );
|
||||
PyObject *M_Mathutils_Point(PyObject * self, PyObject * args);
|
||||
//DEPRECATED
|
||||
PyObject *M_Mathutils_CopyMat(PyObject * self, PyObject * args);
|
||||
|
@ -22,6 +22,7 @@ The Blender Python API Reference
|
||||
- L{Curve}
|
||||
- L{Draw}
|
||||
- L{Effect}
|
||||
- L{Geometry} (*)
|
||||
- L{Group} (*)
|
||||
- L{Image}
|
||||
- L{Ipo} (*)
|
||||
|
Loading…
Reference in New Issue
Block a user