src/raytracermodule.cc
branchpyrit
changeset 98 64638385798a
parent 97 2a853d284a6a
child 99 f3abdaa2e8fb
equal deleted inserted replaced
97:2a853d284a6a 98:64638385798a
   912 	Py_INCREF(Py_None);
   912 	Py_INCREF(Py_None);
   913 	return Py_None;
   913 	return Py_None;
   914 }
   914 }
   915 
   915 
   916 
   916 
   917 //=========================== Vertex Object (abstract) ===========================
   917 //=========================== Vertex Object ===========================
   918 
   918 
       
   919 static PyObject *Vertex_Constructor(PyObject* self, PyObject* args, PyObject *kwd);
   919 static void Vertex_Destructor(PyObject* self);
   920 static void Vertex_Destructor(PyObject* self);
   920 
   921 
   921 static PyMethodDef VertexMethods[] = {
   922 static PyMethodDef VertexMethods[] = {
   922 	{NULL, NULL}
   923 	{NULL, NULL}
   923 };
   924 };
   932 	VertexMethods,               /* tp_methods */
   933 	VertexMethods,               /* tp_methods */
   933 	0,                           /* tp_members */
   934 	0,                           /* tp_members */
   934 	0,                           /* tp_base */
   935 	0,                           /* tp_base */
   935 	0                            /* tp_init */
   936 	0                            /* tp_init */
   936 );
   937 );
       
   938 
       
   939 static PyObject* Vertex_Constructor(PyObject* self, PyObject* args, PyObject *kwd)
       
   940 {
       
   941 	VertexObject *v;
       
   942 	static char *kwdlist[] = {"vector", NULL};
       
   943 	PyObject *TVer = NULL;
       
   944 	Float vx, vy, vz;
       
   945 
       
   946 	if (!PyArg_ParseTupleAndKeywords(args, kwd, "O", kwdlist, &TVer))
       
   947 		return NULL;
       
   948 
       
   949 	if (TVer->ob_type == &VertexType)
       
   950 	{
       
   951 		v = PyObject_New(VertexObject, &VertexType);
       
   952 		v->vertex = new Vertex(*((VertexObject*)TVer)->vertex);
       
   953 	}
       
   954 	else
       
   955 	{
       
   956 		if (!PyArg_ParseTuple(TVer, "fff", &vx, &vy, &vz))
       
   957 			return NULL;
       
   958 
       
   959 		v = PyObject_New(VertexObject, &VertexType);
       
   960 		v->vertex = new Vertex(Vector(vx, vy, vz));
       
   961 	}
       
   962 	return (PyObject*)v;
       
   963 }
   937 
   964 
   938 static void Vertex_Destructor(PyObject* self)
   965 static void Vertex_Destructor(PyObject* self)
   939 {
   966 {
   940 	delete ((VertexObject *)self)->vertex;
   967 	delete ((VertexObject *)self)->vertex;
   941 	self->ob_type->tp_free(self);
   968 	self->ob_type->tp_free(self);