2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02: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"
|
|
|
|
|
|
2023-12-01 03:39:03 +01:00
|
|
|
#include "GPU_select.hh"
|
2017-08-20 23:01:46 +10:00
|
|
|
|
2024-03-23 10:06:45 -04:00
|
|
|
#include "gpu_py.hh"
|
|
|
|
|
#include "gpu_py_select.hh" /* Own include. */
|
2018-09-05 21:10:42 -03:00
|
|
|
|
2017-08-20 23:01:46 +10:00
|
|
|
/* -------------------------------------------------------------------- */
|
|
|
|
|
/** \name Methods
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_select_load_id_doc,
|
|
|
|
|
".. function:: load_id(id)\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" Set the selection ID.\n"
|
|
|
|
|
"\n"
|
|
|
|
|
" :arg id: Number (32-bit uint).\n"
|
|
|
|
|
" :type select: int\n");
|
2023-07-21 19:41:03 +02:00
|
|
|
static PyObject *pygpu_select_load_id(PyObject * /*self*/, PyObject *value)
|
2017-08-20 23:01:46 +10:00
|
|
|
{
|
|
|
|
|
uint id;
|
2023-07-22 11:33:36 +10:00
|
|
|
if ((id = PyC_Long_AsU32(value)) == uint(-1)) {
|
2023-07-21 19:41:03 +02:00
|
|
|
return nullptr;
|
2017-08-20 23:01:46 +10:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
* \{ */
|
|
|
|
|
|
2023-06-03 08:36:28 +10:00
|
|
|
static 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},
|
2023-07-21 19:41:03 +02:00
|
|
|
{nullptr, nullptr, 0, nullptr},
|
2017-08-20 23:01:46 +10:00
|
|
|
};
|
|
|
|
|
|
2024-01-25 10:22:16 +11:00
|
|
|
PyDoc_STRVAR(
|
|
|
|
|
/* Wrap. */
|
|
|
|
|
pygpu_select__tp_doc,
|
|
|
|
|
"This module provides access to selection.");
|
2021-02-17 10:16:41 -03:00
|
|
|
static PyModuleDef pygpu_select_module_def = {
|
2023-07-16 17:43:31 +10:00
|
|
|
/*m_base*/ PyModuleDef_HEAD_INIT,
|
2022-11-08 11:13:58 +11:00
|
|
|
/*m_name*/ "gpu.select",
|
|
|
|
|
/*m_doc*/ pygpu_select__tp_doc,
|
|
|
|
|
/*m_size*/ 0,
|
|
|
|
|
/*m_methods*/ pygpu_select__tp_methods,
|
2023-07-21 19:41:03 +02:00
|
|
|
/*m_slots*/ nullptr,
|
|
|
|
|
/*m_traverse*/ nullptr,
|
|
|
|
|
/*m_clear*/ nullptr,
|
|
|
|
|
/*m_free*/ nullptr,
|
2017-08-20 23:01:46 +10:00
|
|
|
};
|
|
|
|
|
|
2023-07-22 11:33:36 +10:00
|
|
|
PyObject *bpygpu_select_init()
|
2017-08-20 23:01:46 +10:00
|
|
|
{
|
|
|
|
|
PyObject *submodule;
|
|
|
|
|
|
2022-11-29 13:55:37 -03:00
|
|
|
submodule = bpygpu_create_module(&pygpu_select_module_def);
|
2017-08-20 23:01:46 +10:00
|
|
|
|
|
|
|
|
return submodule;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \} */
|