| 
									
										
										
										
											2022-02-11 09:07:11 +11:00
										 |  |  | /* SPDX-License-Identifier: GPL-2.0-or-later */ | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup bpygpu | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This file defines the gpu.select API. | 
					
						
							|  |  |  |  * | 
					
						
							| 
									
										
										
										
											2018-07-14 23:49:00 +02:00
										 |  |  |  * \note Currently only used for gizmo selection, | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  |  * will need to add begin/end and a way to access the hits. | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-07-20 22:52:31 +10:00
										 |  |  |  * - Use `bpygpu_` for local API. | 
					
						
							|  |  |  |  * - Use `BPyGPU` for public API. | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <Python.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BLI_utildefines.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "../generic/py_capi_utils.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "GPU_select.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-06-22 14:59:42 +10:00
										 |  |  | #include "gpu_py_select.h" /* Own include. */
 | 
					
						
							| 
									
										
										
										
											2018-09-05 21:10:42 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Methods
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  | PyDoc_STRVAR(pygpu_select_load_id_doc, | 
					
						
							| 
									
										
										
										
											2020-09-29 15:49:00 -04:00
										 |  |  |              ".. function:: load_id(id)\n" | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  |              "\n" | 
					
						
							|  |  |  |              "   Set the selection ID.\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							| 
									
										
										
										
											2020-02-20 15:38:58 +11:00
										 |  |  |              "   :param id: Number (32-bit uint).\n" | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  |              "   :type select: int\n"); | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  | static PyObject *pygpu_select_load_id(PyObject *UNUSED(self), PyObject *value) | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  | { | 
					
						
							|  |  |  |   uint id; | 
					
						
							|  |  |  |   if ((id = PyC_Long_AsU32(value)) == (uint)-1) { | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   GPU_select_load_id(id); | 
					
						
							|  |  |  |   Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-12-14 15:49:31 +11:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Module
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  | static struct PyMethodDef pygpu_select__tp_methods[] = { | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  |     /* Manage Stack */ | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |     {"load_id", (PyCFunction)pygpu_select_load_id, METH_O, pygpu_select_load_id_doc}, | 
					
						
							| 
									
										
										
										
											2019-02-03 14:01:45 +11:00
										 |  |  |     {NULL, NULL, 0, NULL}, | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  | PyDoc_STRVAR(pygpu_select__tp_doc, "This module provides access to selection."); | 
					
						
							|  |  |  | static PyModuleDef pygpu_select_module_def = { | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  |     PyModuleDef_HEAD_INIT, | 
					
						
							|  |  |  |     .m_name = "gpu.select", | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |     .m_doc = pygpu_select__tp_doc, | 
					
						
							|  |  |  |     .m_methods = pygpu_select__tp_methods, | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-11 13:53:20 -03:00
										 |  |  | PyObject *bpygpu_select_init(void) | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  | { | 
					
						
							|  |  |  |   PyObject *submodule; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-17 10:16:41 -03:00
										 |  |  |   submodule = PyModule_Create(&pygpu_select_module_def); | 
					
						
							| 
									
										
										
										
											2017-08-20 23:01:46 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return submodule; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ |