Blender
V4.3
source
blender
python
intern
bpy_app_openvdb.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2015 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
9
#include "
BLI_utildefines.h
"
10
#include <Python.h>
11
12
#include "
bpy_app_openvdb.hh
"
13
14
#include "
../generic/py_capi_utils.hh
"
15
16
#ifdef WITH_OPENVDB
17
# include "
openvdb_capi.h
"
18
#endif
19
20
static
PyTypeObject
BlenderAppOVDBType
;
21
22
static
PyStructSequence_Field
app_openvdb_info_fields
[] = {
23
{
"supported"
,
"Boolean, True when Blender is built with OpenVDB support"
},
24
{
"version"
,
"The OpenVDB version as a tuple of 3 numbers"
},
25
{
"version_string"
,
"The OpenVDB version formatted as a string"
},
26
{
nullptr
},
27
};
28
29
static
PyStructSequence_Desc
app_openvdb_info_desc
= {
30
/*name*/
"bpy.app.openvdb"
,
31
/*doc*/
"This module contains information about OpenVDB blender is linked against"
,
32
/*fields*/
app_openvdb_info_fields
,
33
/*n_in_sequence*/
ARRAY_SIZE
(
app_openvdb_info_fields
) - 1,
34
};
35
36
static
PyObject *
make_openvdb_info
()
37
{
38
PyObject *openvdb_info;
39
int
pos
= 0;
40
41
#ifdef WITH_OPENVDB
42
int
curversion;
43
#endif
44
45
openvdb_info = PyStructSequence_New(&
BlenderAppOVDBType
);
46
if
(openvdb_info ==
nullptr
) {
47
return
nullptr
;
48
}
49
50
#ifndef WITH_OPENVDB
51
# define SetStrItem(str) PyStructSequence_SET_ITEM(openvdb_info, pos++, PyUnicode_FromString(str))
52
#endif
53
54
#define SetObjItem(obj) PyStructSequence_SET_ITEM(openvdb_info, pos++, obj)
55
56
#ifdef WITH_OPENVDB
57
curversion =
OpenVDB_getVersionHex
();
58
SetObjItem
(PyBool_FromLong(1));
59
SetObjItem
(
60
PyC_Tuple_Pack_I32
({curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256}));
61
SetObjItem
(PyUnicode_FromFormat(
62
"%2d, %2d, %2d"
, curversion >> 24, (curversion >> 16) % 256, (curversion >> 8) % 256));
63
#else
64
SetObjItem
(PyBool_FromLong(0));
65
SetObjItem
(
PyC_Tuple_Pack_I32
({0, 0, 0}));
66
SetStrItem
(
"Unknown"
);
67
#endif
68
69
if
(
UNLIKELY
(PyErr_Occurred())) {
70
Py_DECREF(openvdb_info);
71
return
nullptr
;
72
}
73
74
#undef SetStrItem
75
#undef SetObjItem
76
77
return
openvdb_info;
78
}
79
80
PyObject *
BPY_app_openvdb_struct
()
81
{
82
PyObject *
ret
;
83
84
PyStructSequence_InitType(&
BlenderAppOVDBType
, &
app_openvdb_info_desc
);
85
86
ret
=
make_openvdb_info
();
87
88
/* prevent user from creating new instances */
89
BlenderAppOVDBType
.tp_init =
nullptr
;
90
BlenderAppOVDBType
.tp_new =
nullptr
;
91
/* Without this we can't do `set(sys.modules)` #29635. */
92
BlenderAppOVDBType
.tp_hash = (hashfunc)_Py_HashPointer;
93
94
return
ret
;
95
}
BLI_utildefines.h
ARRAY_SIZE
#define ARRAY_SIZE(arr)
Definition
BLI_utildefines.h:296
UNLIKELY
#define UNLIKELY(x)
Definition
BLI_utildefines.h:554
app_openvdb_info_desc
static PyStructSequence_Desc app_openvdb_info_desc
Definition
bpy_app_openvdb.cc:29
BPY_app_openvdb_struct
PyObject * BPY_app_openvdb_struct()
Definition
bpy_app_openvdb.cc:80
make_openvdb_info
static PyObject * make_openvdb_info()
Definition
bpy_app_openvdb.cc:36
BlenderAppOVDBType
static PyTypeObject BlenderAppOVDBType
Definition
bpy_app_openvdb.cc:20
SetStrItem
#define SetStrItem(str)
app_openvdb_info_fields
static PyStructSequence_Field app_openvdb_info_fields[]
Definition
bpy_app_openvdb.cc:22
SetObjItem
#define SetObjItem(obj)
bpy_app_openvdb.hh
OpenVDB_getVersionHex
int OpenVDB_getVersionHex()
Definition
openvdb_capi.cc:8
openvdb_capi.h
pos
pos[]
Definition
overlay_armature_info.hh:107
py_capi_utils.hh
PyC_Tuple_Pack_I32
PyObject * PyC_Tuple_Pack_I32(const blender::Span< int > values)
Definition
py_capi_utils.hh:369
ret
return ret
Definition
python_utildefines.hh:31
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0