| 
									
										
										
										
											2013-02-23 18:32:28 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * 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. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup freestyle | 
					
						
							| 
									
										
										
										
											2013-02-23 18:32:28 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-01 02:25:21 +00:00
										 |  |  | #include "BPy_FrsMaterial.h"
 | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "BPy_Convert.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | extern "C" { | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-31 17:46:58 +09:00
										 |  |  | #include "BLI_hash_mm2a.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //-------------------MODULE INITIALIZATION--------------------------------
 | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  | int FrsMaterial_Init(PyObject *module) | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-31 22:51:19 +10:00
										 |  |  |   if (module == NULL) { | 
					
						
							| 
									
										
										
										
											2009-09-27 00:32:20 +00:00
										 |  |  |     return -1; | 
					
						
							| 
									
										
										
										
											2019-05-31 22:51:19 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-31 22:51:19 +10:00
										 |  |  |   if (PyType_Ready(&FrsMaterial_Type) < 0) { | 
					
						
							| 
									
										
										
										
											2009-09-27 00:32:20 +00:00
										 |  |  |     return -1; | 
					
						
							| 
									
										
										
										
											2019-05-31 22:51:19 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  |   Py_INCREF(&FrsMaterial_Type); | 
					
						
							| 
									
										
										
										
											2010-05-09 18:05:33 +00:00
										 |  |  |   PyModule_AddObject(module, "Material", (PyObject *)&FrsMaterial_Type); | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   FrsMaterial_mathutils_register_callback(); | 
					
						
							| 
									
										
										
										
											2013-02-14 23:50:30 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-27 00:32:20 +00:00
										 |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //------------------------INSTANCE METHODS ----------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-14 23:50:30 +00:00
										 |  |  | PyDoc_STRVAR( | 
					
						
							|  |  |  |     FrsMaterial_doc, | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |     "Class defining a material.\n" | 
					
						
							|  |  |  |     "\n" | 
					
						
							|  |  |  |     ".. method:: __init__()\n" | 
					
						
							| 
									
										
										
										
											2020-10-22 17:20:57 -04:00
										 |  |  |     "            __init__(brother)\n" | 
					
						
							|  |  |  |     "            __init__(line, diffuse, ambient, specular, emission, shininess, priority)\n" | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |     "\n" | 
					
						
							| 
									
										
										
										
											2020-10-22 17:20:57 -04:00
										 |  |  |     "   Creates a :class:`FrsMaterial` using either default constructor,\n" | 
					
						
							|  |  |  |     "   copy constructor, or an overloaded constructor\n" | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |     "\n" | 
					
						
							| 
									
										
										
										
											2020-10-22 17:20:57 -04:00
										 |  |  |     "   :arg brother: A Material object to be used as a copy constructor.\n" | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  |     "   :type brother: :class:`Material`\n" | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  |     "   :arg line: The line color.\n" | 
					
						
							|  |  |  |     "   :type line: :class:`mathutils.Vector`, list or tuple of 4 float values\n" | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  |     "   :arg diffuse: The diffuse color.\n" | 
					
						
							|  |  |  |     "   :type diffuse: :class:`mathutils.Vector`, list or tuple of 4 float values\n" | 
					
						
							|  |  |  |     "   :arg ambient: The ambient color.\n" | 
					
						
							|  |  |  |     "   :type ambient: :class:`mathutils.Vector`, list or tuple of 4 float values\n" | 
					
						
							|  |  |  |     "   :arg specular: The specular color.\n" | 
					
						
							|  |  |  |     "   :type specular: :class:`mathutils.Vector`, list or tuple of 4 float values\n" | 
					
						
							|  |  |  |     "   :arg emission: The emissive color.\n" | 
					
						
							|  |  |  |     "   :type emission: :class:`mathutils.Vector`, list or tuple of 4 float values\n" | 
					
						
							|  |  |  |     "   :arg shininess: The shininess coefficient.\n" | 
					
						
							| 
									
										
										
										
											2014-09-19 13:22:20 +09:00
										 |  |  |     "   :type shininess: float\n" | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  |     "   :arg priority: The line color priority.\n" | 
					
						
							| 
									
										
										
										
											2014-09-19 13:22:20 +09:00
										 |  |  |     "   :type priority: int"); | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-14 23:50:30 +00:00
										 |  |  | static int FrsMaterial_init(BPy_FrsMaterial *self, PyObject *args, PyObject *kwds) | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  |   static const char *kwlist_1[] = {"brother", NULL}; | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  |   static const char *kwlist_2[] = { | 
					
						
							|  |  |  |       "line", "diffuse", "ambient", "specular", "emission", "shininess", "priority", NULL}; | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  |   PyObject *brother = 0; | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  |   float line[4], diffuse[4], ambient[4], specular[4], emission[4], shininess; | 
					
						
							|  |  |  |   int priority; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  |   if (PyArg_ParseTupleAndKeywords( | 
					
						
							|  |  |  |           args, kwds, "|O!", (char **)kwlist_1, &FrsMaterial_Type, &brother)) { | 
					
						
							|  |  |  |     if (!brother) { | 
					
						
							|  |  |  |       self->m = new FrsMaterial(); | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     else { | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  |       FrsMaterial *m = ((BPy_FrsMaterial *)brother)->m; | 
					
						
							|  |  |  |       if (!m) { | 
					
						
							|  |  |  |         PyErr_SetString(PyExc_RuntimeError, "invalid Material object"); | 
					
						
							|  |  |  |         return -1; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       self->m = new FrsMaterial(*m); | 
					
						
							| 
									
										
										
										
											2009-08-02 17:38:51 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-07-29 10:53:00 +10:00
										 |  |  |   else if ((void)PyErr_Clear(), | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  |            PyArg_ParseTupleAndKeywords(args, | 
					
						
							|  |  |  |                                        kwds, | 
					
						
							|  |  |  |                                        "O&O&O&O&O&fi", | 
					
						
							|  |  |  |                                        (char **)kwlist_2, | 
					
						
							|  |  |  |                                        convert_v4, | 
					
						
							|  |  |  |                                        line, | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  |                                        convert_v4, | 
					
						
							|  |  |  |                                        diffuse, | 
					
						
							|  |  |  |                                        convert_v4, | 
					
						
							|  |  |  |                                        ambient, | 
					
						
							|  |  |  |                                        convert_v4, | 
					
						
							|  |  |  |                                        specular, | 
					
						
							|  |  |  |                                        convert_v4, | 
					
						
							|  |  |  |                                        emission, | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  |                                        &shininess, | 
					
						
							|  |  |  |                                        &priority)) { | 
					
						
							|  |  |  |     self->m = new FrsMaterial(line, diffuse, ambient, specular, emission, shininess, priority); | 
					
						
							| 
									
										
										
										
											2013-02-21 02:57:44 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   else { | 
					
						
							| 
									
										
										
										
											2009-08-02 17:38:51 +00:00
										 |  |  |     PyErr_SetString(PyExc_TypeError, "invalid argument(s)"); | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  | static void FrsMaterial_dealloc(BPy_FrsMaterial *self) | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-02-16 17:13:59 +00:00
										 |  |  |   delete self->m; | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |   Py_TYPE(self)->tp_free((PyObject *)self); | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  | static PyObject *FrsMaterial_repr(BPy_FrsMaterial *self) | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-02-14 23:50:30 +00:00
										 |  |  |   return PyUnicode_FromFormat("Material - address: %p", self->m); | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | /*----------------------mathutils callbacks ----------------------------*/ | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | /* subtype */ | 
					
						
							|  |  |  | #define MATHUTILS_SUBTYPE_DIFFUSE 1
 | 
					
						
							|  |  |  | #define MATHUTILS_SUBTYPE_SPECULAR 2
 | 
					
						
							|  |  |  | #define MATHUTILS_SUBTYPE_AMBIENT 3
 | 
					
						
							|  |  |  | #define MATHUTILS_SUBTYPE_EMISSION 4
 | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  | #define MATHUTILS_SUBTYPE_LINE 5
 | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static int FrsMaterial_mathutils_check(BaseMathObject *bmo) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-05-31 22:51:19 +10:00
										 |  |  |   if (!BPy_FrsMaterial_Check(bmo->cb_user)) { | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |     return -1; | 
					
						
							| 
									
										
										
										
											2019-05-31 22:51:19 +10:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static int FrsMaterial_mathutils_get(BaseMathObject *bmo, int subtype) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user; | 
					
						
							|  |  |  |   switch (subtype) { | 
					
						
							| 
									
										
										
										
											2018-08-30 01:31:20 +10:00
										 |  |  |     case MATHUTILS_SUBTYPE_LINE: | 
					
						
							|  |  |  |       bmo->data[0] = self->m->lineR(); | 
					
						
							|  |  |  |       bmo->data[1] = self->m->lineG(); | 
					
						
							|  |  |  |       bmo->data[2] = self->m->lineB(); | 
					
						
							|  |  |  |       bmo->data[3] = self->m->lineA(); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_DIFFUSE: | 
					
						
							|  |  |  |       bmo->data[0] = self->m->diffuseR(); | 
					
						
							|  |  |  |       bmo->data[1] = self->m->diffuseG(); | 
					
						
							|  |  |  |       bmo->data[2] = self->m->diffuseB(); | 
					
						
							|  |  |  |       bmo->data[3] = self->m->diffuseA(); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_SPECULAR: | 
					
						
							|  |  |  |       bmo->data[0] = self->m->specularR(); | 
					
						
							|  |  |  |       bmo->data[1] = self->m->specularG(); | 
					
						
							|  |  |  |       bmo->data[2] = self->m->specularB(); | 
					
						
							|  |  |  |       bmo->data[3] = self->m->specularA(); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_AMBIENT: | 
					
						
							|  |  |  |       bmo->data[0] = self->m->ambientR(); | 
					
						
							|  |  |  |       bmo->data[1] = self->m->ambientG(); | 
					
						
							|  |  |  |       bmo->data[2] = self->m->ambientB(); | 
					
						
							|  |  |  |       bmo->data[3] = self->m->ambientA(); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_EMISSION: | 
					
						
							|  |  |  |       bmo->data[0] = self->m->emissionR(); | 
					
						
							|  |  |  |       bmo->data[1] = self->m->emissionG(); | 
					
						
							|  |  |  |       bmo->data[2] = self->m->emissionB(); | 
					
						
							|  |  |  |       bmo->data[3] = self->m->emissionA(); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |       return -1; | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static int FrsMaterial_mathutils_set(BaseMathObject *bmo, int subtype) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user; | 
					
						
							|  |  |  |   switch (subtype) { | 
					
						
							| 
									
										
										
										
											2018-08-30 01:31:20 +10:00
										 |  |  |     case MATHUTILS_SUBTYPE_LINE: | 
					
						
							|  |  |  |       self->m->setLine(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_DIFFUSE: | 
					
						
							|  |  |  |       self->m->setDiffuse(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_SPECULAR: | 
					
						
							|  |  |  |       self->m->setSpecular(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_AMBIENT: | 
					
						
							|  |  |  |       self->m->setAmbient(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_EMISSION: | 
					
						
							|  |  |  |       self->m->setEmission(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |       return -1; | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static int FrsMaterial_mathutils_get_index(BaseMathObject *bmo, int subtype, int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user; | 
					
						
							|  |  |  |   switch (subtype) { | 
					
						
							| 
									
										
										
										
											2018-08-30 01:31:20 +10:00
										 |  |  |     case MATHUTILS_SUBTYPE_LINE: { | 
					
						
							|  |  |  |       const float *color = self->m->line(); | 
					
						
							|  |  |  |       bmo->data[index] = color[index]; | 
					
						
							|  |  |  |     } break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_DIFFUSE: { | 
					
						
							|  |  |  |       const float *color = self->m->diffuse(); | 
					
						
							|  |  |  |       bmo->data[index] = color[index]; | 
					
						
							|  |  |  |     } break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_SPECULAR: { | 
					
						
							|  |  |  |       const float *color = self->m->specular(); | 
					
						
							|  |  |  |       bmo->data[index] = color[index]; | 
					
						
							|  |  |  |     } break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_AMBIENT: { | 
					
						
							|  |  |  |       const float *color = self->m->ambient(); | 
					
						
							|  |  |  |       bmo->data[index] = color[index]; | 
					
						
							|  |  |  |     } break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_EMISSION: { | 
					
						
							|  |  |  |       const float *color = self->m->emission(); | 
					
						
							|  |  |  |       bmo->data[index] = color[index]; | 
					
						
							|  |  |  |     } break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |       return -1; | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static int FrsMaterial_mathutils_set_index(BaseMathObject *bmo, int subtype, int index) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user; | 
					
						
							|  |  |  |   float color[4]; | 
					
						
							|  |  |  |   switch (subtype) { | 
					
						
							| 
									
										
										
										
											2018-08-30 01:31:20 +10:00
										 |  |  |     case MATHUTILS_SUBTYPE_LINE: | 
					
						
							|  |  |  |       copy_v4_v4(color, self->m->line()); | 
					
						
							|  |  |  |       color[index] = bmo->data[index]; | 
					
						
							|  |  |  |       self->m->setLine(color[0], color[1], color[2], color[3]); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_DIFFUSE: | 
					
						
							|  |  |  |       copy_v4_v4(color, self->m->diffuse()); | 
					
						
							|  |  |  |       color[index] = bmo->data[index]; | 
					
						
							|  |  |  |       self->m->setDiffuse(color[0], color[1], color[2], color[3]); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_SPECULAR: | 
					
						
							|  |  |  |       copy_v4_v4(color, self->m->specular()); | 
					
						
							|  |  |  |       color[index] = bmo->data[index]; | 
					
						
							|  |  |  |       self->m->setSpecular(color[0], color[1], color[2], color[3]); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_AMBIENT: | 
					
						
							|  |  |  |       copy_v4_v4(color, self->m->ambient()); | 
					
						
							|  |  |  |       color[index] = bmo->data[index]; | 
					
						
							|  |  |  |       self->m->setAmbient(color[0], color[1], color[2], color[3]); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case MATHUTILS_SUBTYPE_EMISSION: | 
					
						
							|  |  |  |       copy_v4_v4(color, self->m->emission()); | 
					
						
							|  |  |  |       color[index] = bmo->data[index]; | 
					
						
							|  |  |  |       self->m->setEmission(color[0], color[1], color[2], color[3]); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |       return -1; | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static Mathutils_Callback FrsMaterial_mathutils_cb = { | 
					
						
							|  |  |  |     FrsMaterial_mathutils_check, | 
					
						
							|  |  |  |     FrsMaterial_mathutils_get, | 
					
						
							|  |  |  |     FrsMaterial_mathutils_set, | 
					
						
							|  |  |  |     FrsMaterial_mathutils_get_index, | 
					
						
							| 
									
										
										
										
											2019-02-03 14:01:45 +11:00
										 |  |  |     FrsMaterial_mathutils_set_index, | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static unsigned char FrsMaterial_mathutils_cb_index = -1; | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | void FrsMaterial_mathutils_register_callback() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   FrsMaterial_mathutils_cb_index = Mathutils_RegisterCallback(&FrsMaterial_mathutils_cb); | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | /*----------------------FrsMaterial get/setters ----------------------------*/ | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  | PyDoc_STRVAR(FrsMaterial_line_doc, | 
					
						
							|  |  |  |              "RGBA components of the line color of the material.\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							| 
									
										
										
										
											2014-09-19 13:22:20 +09:00
										 |  |  |              ":type: :class:`mathutils.Vector`"); | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | static PyObject *FrsMaterial_line_get(BPy_FrsMaterial *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return Vector_CreatePyObject_cb( | 
					
						
							|  |  |  |       (PyObject *)self, 4, FrsMaterial_mathutils_cb_index, MATHUTILS_SUBTYPE_LINE); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int FrsMaterial_line_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   float color[4]; | 
					
						
							|  |  |  |   if (mathutils_array_parse(color, 4, 4, value, "value must be a 4-dimensional vector") == -1) { | 
					
						
							|  |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   self->m->setLine(color[0], color[1], color[2], color[3]); | 
					
						
							|  |  |  |   return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | PyDoc_STRVAR(FrsMaterial_diffuse_doc, | 
					
						
							|  |  |  |              "RGBA components of the diffuse color of the material.\n" | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |              "\n" | 
					
						
							| 
									
										
										
										
											2014-09-19 13:22:20 +09:00
										 |  |  |              ":type: :class:`mathutils.Vector`"); | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static PyObject *FrsMaterial_diffuse_get(BPy_FrsMaterial *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return Vector_CreatePyObject_cb( | 
					
						
							|  |  |  |       (PyObject *)self, 4, FrsMaterial_mathutils_cb_index, MATHUTILS_SUBTYPE_DIFFUSE); | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static int FrsMaterial_diffuse_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   float color[4]; | 
					
						
							| 
									
										
										
										
											2014-06-24 22:48:15 +09:00
										 |  |  |   if (mathutils_array_parse(color, 4, 4, value, "value must be a 4-dimensional vector") == -1) { | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   self->m->setDiffuse(color[0], color[1], color[2], color[3]); | 
					
						
							|  |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | PyDoc_STRVAR(FrsMaterial_specular_doc, | 
					
						
							|  |  |  |              "RGBA components of the specular color of the material.\n" | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |              "\n" | 
					
						
							| 
									
										
										
										
											2014-09-19 13:22:20 +09:00
										 |  |  |              ":type: :class:`mathutils.Vector`"); | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static PyObject *FrsMaterial_specular_get(BPy_FrsMaterial *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return Vector_CreatePyObject_cb( | 
					
						
							|  |  |  |       (PyObject *)self, 4, FrsMaterial_mathutils_cb_index, MATHUTILS_SUBTYPE_SPECULAR); | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static int FrsMaterial_specular_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   float color[4]; | 
					
						
							| 
									
										
										
										
											2014-06-24 22:48:15 +09:00
										 |  |  |   if (mathutils_array_parse(color, 4, 4, value, "value must be a 4-dimensional vector") == -1) { | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   self->m->setSpecular(color[0], color[1], color[2], color[3]); | 
					
						
							|  |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | PyDoc_STRVAR(FrsMaterial_ambient_doc, | 
					
						
							|  |  |  |              "RGBA components of the ambient color of the material.\n" | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |              "\n" | 
					
						
							| 
									
										
										
										
											2014-09-19 13:22:20 +09:00
										 |  |  |              ":type: :class:`mathutils.Color`"); | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static PyObject *FrsMaterial_ambient_get(BPy_FrsMaterial *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return Vector_CreatePyObject_cb( | 
					
						
							|  |  |  |       (PyObject *)self, 4, FrsMaterial_mathutils_cb_index, MATHUTILS_SUBTYPE_AMBIENT); | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static int FrsMaterial_ambient_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   float color[4]; | 
					
						
							| 
									
										
										
										
											2014-06-24 22:48:15 +09:00
										 |  |  |   if (mathutils_array_parse(color, 4, 4, value, "value must be a 4-dimensional vector") == -1) { | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   self->m->setAmbient(color[0], color[1], color[2], color[3]); | 
					
						
							|  |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | PyDoc_STRVAR(FrsMaterial_emission_doc, | 
					
						
							|  |  |  |              "RGBA components of the emissive color of the material.\n" | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |              "\n" | 
					
						
							| 
									
										
										
										
											2014-09-19 13:22:20 +09:00
										 |  |  |              ":type: :class:`mathutils.Color`"); | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static PyObject *FrsMaterial_emission_get(BPy_FrsMaterial *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return Vector_CreatePyObject_cb( | 
					
						
							|  |  |  |       (PyObject *)self, 4, FrsMaterial_mathutils_cb_index, MATHUTILS_SUBTYPE_EMISSION); | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static int FrsMaterial_emission_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   float color[4]; | 
					
						
							| 
									
										
										
										
											2014-06-24 22:48:15 +09:00
										 |  |  |   if (mathutils_array_parse(color, 4, 4, value, "value must be a 4-dimensional vector") == -1) { | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   self->m->setEmission(color[0], color[1], color[2], color[3]); | 
					
						
							|  |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | PyDoc_STRVAR(FrsMaterial_shininess_doc, | 
					
						
							|  |  |  |              "Shininess coefficient of the material.\n" | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |              "\n" | 
					
						
							| 
									
										
										
										
											2013-02-04 00:23:37 +00:00
										 |  |  |              ":type: float"); | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static PyObject *FrsMaterial_shininess_get(BPy_FrsMaterial *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return PyFloat_FromDouble(self->m->shininess()); | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static int FrsMaterial_shininess_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   float scalar; | 
					
						
							| 
									
										
										
										
											2019-07-10 14:41:19 +10:00
										 |  |  |   if ((scalar = PyFloat_AsDouble(value)) == -1.0f && PyErr_Occurred()) { | 
					
						
							|  |  |  |     /* parsed item not a number */ | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |     PyErr_SetString(PyExc_TypeError, "value must be a number"); | 
					
						
							|  |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   self->m->setShininess(scalar); | 
					
						
							|  |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  | PyDoc_STRVAR(FrsMaterial_priority_doc, | 
					
						
							|  |  |  |              "Line color priority of the material.\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              ":type: int"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *FrsMaterial_priority_get(BPy_FrsMaterial *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return PyLong_FromLong(self->m->priority()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int FrsMaterial_priority_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int scalar; | 
					
						
							|  |  |  |   if ((scalar = PyLong_AsLong(value)) == -1 && PyErr_Occurred()) { | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "value must be an integer"); | 
					
						
							|  |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   self->m->setPriority(scalar); | 
					
						
							|  |  |  |   return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  | static PyGetSetDef BPy_FrsMaterial_getseters[] = { | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |     {"line", | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  |      (getter)FrsMaterial_line_get, | 
					
						
							|  |  |  |      (setter)FrsMaterial_line_set, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |      FrsMaterial_line_doc, | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  |      NULL}, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |     {"diffuse", | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |      (getter)FrsMaterial_diffuse_get, | 
					
						
							|  |  |  |      (setter)FrsMaterial_diffuse_set, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |      FrsMaterial_diffuse_doc, | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |      NULL}, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |     {"specular", | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |      (getter)FrsMaterial_specular_get, | 
					
						
							|  |  |  |      (setter)FrsMaterial_specular_set, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |      FrsMaterial_specular_doc, | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |      NULL}, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |     {"ambient", | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |      (getter)FrsMaterial_ambient_get, | 
					
						
							|  |  |  |      (setter)FrsMaterial_ambient_set, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |      FrsMaterial_ambient_doc, | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |      NULL}, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |     {"emission", | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |      (getter)FrsMaterial_emission_get, | 
					
						
							|  |  |  |      (setter)FrsMaterial_emission_set, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |      FrsMaterial_emission_doc, | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |      NULL}, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |     {"shininess", | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |      (getter)FrsMaterial_shininess_get, | 
					
						
							|  |  |  |      (setter)FrsMaterial_shininess_set, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |      FrsMaterial_shininess_doc, | 
					
						
							| 
									
										
										
										
											2013-03-07 23:17:23 +00:00
										 |  |  |      NULL}, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |     {"priority", | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  |      (getter)FrsMaterial_priority_get, | 
					
						
							|  |  |  |      (setter)FrsMaterial_priority_set, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |      FrsMaterial_priority_doc, | 
					
						
							| 
									
										
										
										
											2014-07-07 15:54:46 +09:00
										 |  |  |      NULL}, | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |     {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-31 17:46:58 +09:00
										 |  |  | static PyObject *BPy_FrsMaterial_richcmpr(PyObject *objectA, | 
					
						
							|  |  |  |                                           PyObject *objectB, | 
					
						
							|  |  |  |                                           int comparison_type) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   const BPy_FrsMaterial *matA = NULL, *matB = NULL; | 
					
						
							|  |  |  |   bool result = 0; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-31 17:46:58 +09:00
										 |  |  |   if (!BPy_FrsMaterial_Check(objectA) || !BPy_FrsMaterial_Check(objectB)) { | 
					
						
							|  |  |  |     if (comparison_type == Py_NE) { | 
					
						
							|  |  |  |       Py_RETURN_TRUE; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-08-07 12:39:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Py_RETURN_FALSE; | 
					
						
							| 
									
										
										
										
											2015-05-31 17:46:58 +09:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-31 17:46:58 +09:00
										 |  |  |   matA = (BPy_FrsMaterial *)objectA; | 
					
						
							|  |  |  |   matB = (BPy_FrsMaterial *)objectB; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-31 17:46:58 +09:00
										 |  |  |   switch (comparison_type) { | 
					
						
							|  |  |  |     case Py_NE: | 
					
						
							|  |  |  |       result = (*matA->m) != (*matB->m); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case Py_EQ: | 
					
						
							|  |  |  |       result = (*matA->m) == (*matB->m); | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     default: | 
					
						
							|  |  |  |       PyErr_SetString(PyExc_TypeError, "Material does not support this comparison type"); | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-31 17:46:58 +09:00
										 |  |  |   if (result == true) { | 
					
						
							|  |  |  |     Py_RETURN_TRUE; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-08-07 12:39:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Py_RETURN_FALSE; | 
					
						
							| 
									
										
										
										
											2015-05-31 17:46:58 +09:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static Py_hash_t FrsMaterial_hash(PyObject *self) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return (Py_uhash_t)BLI_hash_mm2((const unsigned char *)self, sizeof(*self), 0); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  | /*-----------------------BPy_FrsMaterial type definition ------------------------------*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyTypeObject FrsMaterial_Type = { | 
					
						
							|  |  |  |     PyVarObject_HEAD_INIT(NULL, 0) "Material", /* tp_name */ | 
					
						
							|  |  |  |     sizeof(BPy_FrsMaterial),                   /* tp_basicsize */ | 
					
						
							|  |  |  |     0,                                         /* tp_itemsize */ | 
					
						
							| 
									
										
										
										
											2013-02-14 23:50:30 +00:00
										 |  |  |     (destructor)FrsMaterial_dealloc,           /* tp_dealloc */ | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |     0,                                         /* tp_print */ | 
					
						
							|  |  |  |     0,                                         /* tp_getattr */ | 
					
						
							|  |  |  |     0,                                         /* tp_setattr */ | 
					
						
							|  |  |  |     0,                                         /* tp_reserved */ | 
					
						
							| 
									
										
										
										
											2013-02-14 23:50:30 +00:00
										 |  |  |     (reprfunc)FrsMaterial_repr,                /* tp_repr */ | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |     0,                                         /* tp_as_number */ | 
					
						
							|  |  |  |     0,                                         /* tp_as_sequence */ | 
					
						
							|  |  |  |     0,                                         /* tp_as_mapping */ | 
					
						
							| 
									
										
										
										
											2015-05-31 17:46:58 +09:00
										 |  |  |     (hashfunc)FrsMaterial_hash,                /* tp_hash  */ | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |     0,                                         /* tp_call */ | 
					
						
							|  |  |  |     0,                                         /* tp_str */ | 
					
						
							|  |  |  |     0,                                         /* tp_getattro */ | 
					
						
							|  |  |  |     0,                                         /* tp_setattro */ | 
					
						
							|  |  |  |     0,                                         /* tp_as_buffer */ | 
					
						
							|  |  |  |     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,  /* tp_flags */ | 
					
						
							| 
									
										
										
										
											2013-02-14 23:50:30 +00:00
										 |  |  |     FrsMaterial_doc,                           /* tp_doc */ | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |     0,                                         /* tp_traverse */ | 
					
						
							|  |  |  |     0,                                         /* tp_clear */ | 
					
						
							| 
									
										
										
										
											2015-05-31 17:46:58 +09:00
										 |  |  |     (richcmpfunc)BPy_FrsMaterial_richcmpr,     /* tp_richcompare */ | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |     0,                                         /* tp_weaklistoffset */ | 
					
						
							|  |  |  |     0,                                         /* tp_iter */ | 
					
						
							|  |  |  |     0,                                         /* tp_iternext */ | 
					
						
							| 
									
										
										
										
											2013-02-24 02:32:56 +00:00
										 |  |  |     0,                                         /* tp_methods */ | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |     0,                                         /* tp_members */ | 
					
						
							| 
									
										
										
										
											2013-02-03 17:01:21 +00:00
										 |  |  |     BPy_FrsMaterial_getseters,                 /* tp_getset */ | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |     0,                                         /* tp_base */ | 
					
						
							|  |  |  |     0,                                         /* tp_dict */ | 
					
						
							|  |  |  |     0,                                         /* tp_descr_get */ | 
					
						
							|  |  |  |     0,                                         /* tp_descr_set */ | 
					
						
							|  |  |  |     0,                                         /* tp_dictoffset */ | 
					
						
							| 
									
										
										
										
											2013-02-14 23:50:30 +00:00
										 |  |  |     (initproc)FrsMaterial_init,                /* tp_init */ | 
					
						
							| 
									
										
										
										
											2010-04-17 23:47:47 +00:00
										 |  |  |     0,                                         /* tp_alloc */ | 
					
						
							|  |  |  |     PyType_GenericNew,                         /* tp_new */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-31 11:59:06 +00:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 |