Cleanup: comments (long lines) in python
This commit is contained in:
@@ -875,10 +875,20 @@ static PyGetSetDef bpy_bmface_getseters[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static PyGetSetDef bpy_bmloop_getseters[] = {
|
static PyGetSetDef bpy_bmloop_getseters[] = {
|
||||||
/* generic */
|
/* generic */
|
||||||
/* flags are available but not used for loops. */
|
/* flags are available but not used for loops. */
|
||||||
// {(char *)"select", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_select_doc, (void *)BM_ELEM_SELECT},
|
#if 0
|
||||||
// {(char *)"hide", (getter)bpy_bm_elem_hflag_get, (setter)bpy_bm_elem_hflag_set, (char *)bpy_bm_elem_hide_doc, (void *)BM_ELEM_HIDDEN},
|
{(char *)"select",
|
||||||
|
(getter)bpy_bm_elem_hflag_get,
|
||||||
|
(setter)bpy_bm_elem_hflag_set,
|
||||||
|
(char *)bpy_bm_elem_select_doc,
|
||||||
|
(void *)BM_ELEM_SELECT},
|
||||||
|
{(char *)"hide",
|
||||||
|
(getter)bpy_bm_elem_hflag_get,
|
||||||
|
(setter)bpy_bm_elem_hflag_set,
|
||||||
|
(char *)bpy_bm_elem_hide_doc,
|
||||||
|
(void *)BM_ELEM_HIDDEN},
|
||||||
|
#endif
|
||||||
{(char *)"tag",
|
{(char *)"tag",
|
||||||
(getter)bpy_bm_elem_hflag_get,
|
(getter)bpy_bm_elem_hflag_get,
|
||||||
(setter)bpy_bm_elem_hflag_set,
|
(setter)bpy_bm_elem_hflag_set,
|
||||||
|
|||||||
@@ -164,7 +164,8 @@ PyObject *BPy_IDGroup_WrapData(ID *id, IDProperty *prop, IDProperty *parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0 /* UNUSED, currently assignment overwrites into new properties, rather than setting in-place */
|
/* UNUSED, currently assignment overwrites into new properties, rather than setting in-place. */
|
||||||
|
#if 0
|
||||||
static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject *value)
|
static int BPy_IDGroup_SetData(BPy_IDProperty *self, IDProperty *prop, PyObject *value)
|
||||||
{
|
{
|
||||||
switch (prop->type) {
|
switch (prop->type) {
|
||||||
|
|||||||
@@ -37,7 +37,8 @@
|
|||||||
#include "BLI_string.h"
|
#include "BLI_string.h"
|
||||||
|
|
||||||
#ifndef MATH_STANDALONE
|
#ifndef MATH_STANDALONE
|
||||||
/* only for BLI_strncpy_wchar_from_utf8, should replace with py funcs but too late in release now */
|
/* Only for BLI_strncpy_wchar_from_utf8,
|
||||||
|
* should replace with py funcs but too late in release now. */
|
||||||
# include "BLI_string_utf8.h"
|
# include "BLI_string_utf8.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -273,7 +274,8 @@ void PyC_ObSpitStr(char *result, size_t result_len, PyObject *var)
|
|||||||
const PyTypeObject *type = Py_TYPE(var);
|
const PyTypeObject *type = Py_TYPE(var);
|
||||||
PyObject *var_str = PyObject_Repr(var);
|
PyObject *var_str = PyObject_Repr(var);
|
||||||
if (var_str == NULL) {
|
if (var_str == NULL) {
|
||||||
/* We could print error here, but this may be used for generating errors - so don't for now. */
|
/* We could print error here,
|
||||||
|
* but this may be used for generating errors - so don't for now. */
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
}
|
}
|
||||||
BLI_snprintf(result,
|
BLI_snprintf(result,
|
||||||
@@ -765,7 +767,8 @@ void PyC_MainModule_Restore(PyObject *main_mod)
|
|||||||
Py_XDECREF(main_mod);
|
Py_XDECREF(main_mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* must be called before Py_Initialize, expects output of BKE_appdir_folder_id(BLENDER_PYTHON, NULL) */
|
/* Must be called before Py_Initialize,
|
||||||
|
* expects output of BKE_appdir_folder_id(BLENDER_PYTHON, NULL). */
|
||||||
void PyC_SetHomePath(const char *py_path_bundle)
|
void PyC_SetHomePath(const char *py_path_bundle)
|
||||||
{
|
{
|
||||||
if (py_path_bundle == NULL) {
|
if (py_path_bundle == NULL) {
|
||||||
@@ -803,7 +806,8 @@ void PyC_SetHomePath(const char *py_path_bundle)
|
|||||||
{
|
{
|
||||||
static wchar_t py_path_bundle_wchar[1024];
|
static wchar_t py_path_bundle_wchar[1024];
|
||||||
|
|
||||||
/* cant use this, on linux gives bug: #23018, TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 22008 */
|
/* Can't use this, on linux gives bug: #23018,
|
||||||
|
* TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 2008 */
|
||||||
/* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */
|
/* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */
|
||||||
|
|
||||||
BLI_strncpy_wchar_from_utf8(
|
BLI_strncpy_wchar_from_utf8(
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ Py_LOCAL_INLINE(PyObject *) Py_INCREF_RET(PyObject *op)
|
|||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* append & transfer ownership to the list, avoids inline Py_DECREF all over (which is quite a large macro) */
|
/* Append & transfer ownership to the list,
|
||||||
|
* avoids inline Py_DECREF all over (which is quite a large macro). */
|
||||||
Py_LOCAL_INLINE(int) PyList_APPEND(PyObject *op, PyObject *v)
|
Py_LOCAL_INLINE(int) PyList_APPEND(PyObject *op, PyObject *v)
|
||||||
{
|
{
|
||||||
int ret = PyList_Append(op, v);
|
int ret = PyList_Append(op, v);
|
||||||
|
|||||||
@@ -127,7 +127,8 @@ PyDoc_STRVAR(bpygpu_Batch_vertbuf_add_doc,
|
|||||||
" Add another vertex buffer to the Batch.\n"
|
" Add another vertex buffer to the Batch.\n"
|
||||||
" It is not possible to add more vertices to the batch using this method.\n"
|
" It is not possible to add more vertices to the batch using this method.\n"
|
||||||
" Instead it can be used to add more attributes to the existing vertices.\n"
|
" Instead it can be used to add more attributes to the existing vertices.\n"
|
||||||
" A good use case would be when you have a separate vertex buffer for vertex positions and vertex normals.\n"
|
" A good use case would be when you have a separate\n"
|
||||||
|
" vertex buffer for vertex positions and vertex normals.\n"
|
||||||
" Current a batch can have at most " STRINGIFY(GPU_BATCH_VBO_MAX_LEN) " vertex buffers.\n"
|
" Current a batch can have at most " STRINGIFY(GPU_BATCH_VBO_MAX_LEN) " vertex buffers.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" :param buf: The vertex buffer that will be added to the batch.\n"
|
" :param buf: The vertex buffer that will be added to the batch.\n"
|
||||||
|
|||||||
@@ -177,7 +177,8 @@ static PyObject *bpy_user_resource(PyObject *UNUSED(self), PyObject *args, PyObj
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* same logic as BKE_appdir_folder_id_create(), but best leave it up to the script author to create */
|
/* same logic as BKE_appdir_folder_id_create(),
|
||||||
|
* but best leave it up to the script author to create */
|
||||||
path = BKE_appdir_folder_id_user_notest(folder_id, subdir);
|
path = BKE_appdir_folder_id_user_notest(folder_id, subdir);
|
||||||
|
|
||||||
return PyC_UnicodeFromByte(path ? path : "");
|
return PyC_UnicodeFromByte(path ? path : "");
|
||||||
|
|||||||
@@ -40,10 +40,12 @@ static PyStructSequence_Field app_ocio_info_fields[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static PyStructSequence_Desc app_ocio_info_desc = {
|
static PyStructSequence_Desc app_ocio_info_desc = {
|
||||||
(char *)"bpy.app.ocio", /* name */
|
/* name */
|
||||||
(char
|
(char *)"bpy.app.ocio",
|
||||||
*)"This module contains information about OpenColorIO blender is linked against", /* doc */
|
/* doc */
|
||||||
app_ocio_info_fields, /* fields */
|
(char *)"This module contains information about OpenColorIO blender is linked against",
|
||||||
|
/* fields */
|
||||||
|
app_ocio_info_fields,
|
||||||
ARRAY_SIZE(app_ocio_info_fields) - 1,
|
ARRAY_SIZE(app_ocio_info_fields) - 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -47,13 +47,16 @@
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
/* The string used to separate context from actual message in PY_TRANSLATE RNA props. */
|
/** The string used to separate context from actual message in PY_TRANSLATE RNA props. */
|
||||||
const char *context_separator;
|
const char *context_separator;
|
||||||
/* A "named tuple" (StructSequence actually...) containing all C-defined contexts. */
|
/** A "named tuple" (StructSequence actually...) containing all C-defined contexts. */
|
||||||
PyObject *contexts;
|
PyObject *contexts;
|
||||||
/* A readonly mapping {C context id: python id} (actually, a MappingProxy). */
|
/** A readonly mapping {C context id: python id} (actually, a MappingProxy). */
|
||||||
PyObject *contexts_C_to_py;
|
PyObject *contexts_C_to_py;
|
||||||
/* A py dict containing all registered py dicts (order is more or less random, first match wins!). */
|
/**
|
||||||
|
* A py dict containing all registered py dicts
|
||||||
|
* (order is more or less random, first match wins!).
|
||||||
|
*/
|
||||||
PyObject *py_messages;
|
PyObject *py_messages;
|
||||||
} BlenderAppTranslations;
|
} BlenderAppTranslations;
|
||||||
|
|
||||||
@@ -111,8 +114,8 @@ static void _ghashutil_keyfree(void *ptr)
|
|||||||
/***** Python's messages cache *****/
|
/***** Python's messages cache *****/
|
||||||
|
|
||||||
/* We cache all messages available for a given locale from all py dicts into a single ghash.
|
/* We cache all messages available for a given locale from all py dicts into a single ghash.
|
||||||
* Changing of locale is not so common, while looking for a message translation is, so let's try to optimize
|
* Changing of locale is not so common, while looking for a message translation is,
|
||||||
* the later as much as we can!
|
* so let's try to optimize the later as much as we can!
|
||||||
* Note changing of locale, as well as (un)registering a message dict, invalidate that cache.
|
* Note changing of locale, as well as (un)registering a message dict, invalidate that cache.
|
||||||
*/
|
*/
|
||||||
static GHash *_translations_cache = NULL;
|
static GHash *_translations_cache = NULL;
|
||||||
@@ -148,7 +151,8 @@ static void _build_translations_cache(PyObject *py_messages, const char *locale)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
/* Try to get first complete locale, then language+country, then language+variant, then only language */
|
/* Try to get first complete locale, then language+country,
|
||||||
|
* then language+variant, then only language. */
|
||||||
lang_dict = PyDict_GetItemString(uuid_dict, locale);
|
lang_dict = PyDict_GetItemString(uuid_dict, locale);
|
||||||
if (!lang_dict && language_country) {
|
if (!lang_dict && language_country) {
|
||||||
lang_dict = PyDict_GetItemString(uuid_dict, language_country);
|
lang_dict = PyDict_GetItemString(uuid_dict, language_country);
|
||||||
@@ -393,8 +397,8 @@ static PyTypeObject BlenderAppTranslationsContextsType;
|
|||||||
static BLT_i18n_contexts_descriptor _contexts[] = BLT_I18NCONTEXTS_DESC;
|
static BLT_i18n_contexts_descriptor _contexts[] = BLT_I18NCONTEXTS_DESC;
|
||||||
|
|
||||||
/* These fields are just empty placeholders, actual values get set in app_translations_struct().
|
/* These fields are just empty placeholders, actual values get set in app_translations_struct().
|
||||||
* This allows us to avoid many handwriting, and above all, to keep all context definition stuff in BLT_translation.h!
|
* This allows us to avoid many handwriting, and above all,
|
||||||
*/
|
* to keep all context definition stuff in BLT_translation.h! */
|
||||||
static PyStructSequence_Field app_translations_contexts_fields[ARRAY_SIZE(_contexts)] = {{NULL}};
|
static PyStructSequence_Field app_translations_contexts_fields[ARRAY_SIZE(_contexts)] = {{NULL}};
|
||||||
|
|
||||||
static PyStructSequence_Desc app_translations_contexts_desc = {
|
static PyStructSequence_Desc app_translations_contexts_desc = {
|
||||||
|
|||||||
@@ -54,7 +54,10 @@ extern void BPY_update_rna_module(void);
|
|||||||
# include <opcode.h>
|
# include <opcode.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* for pydrivers (drivers using one-line Python expressions to express relationships between targets) */
|
/**
|
||||||
|
* For PyDrivers
|
||||||
|
* (drivers using one-line Python expressions to express relationships between targets).
|
||||||
|
*/
|
||||||
PyObject *bpy_pydriver_Dict = NULL;
|
PyObject *bpy_pydriver_Dict = NULL;
|
||||||
|
|
||||||
#ifdef USE_BYTECODE_WHITELIST
|
#ifdef USE_BYTECODE_WHITELIST
|
||||||
@@ -399,8 +402,10 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
|
|||||||
{
|
{
|
||||||
PyObject *driver_vars = NULL;
|
PyObject *driver_vars = NULL;
|
||||||
PyObject *retval = NULL;
|
PyObject *retval = NULL;
|
||||||
PyObject *
|
|
||||||
expr_vars; /* speed up by pre-hashing string & avoids re-converting unicode strings for every execution */
|
/* Speed up by pre-hashing string & avoids re-converting unicode strings for every execution. */
|
||||||
|
PyObject *expr_vars;
|
||||||
|
|
||||||
PyObject *expr_code;
|
PyObject *expr_code;
|
||||||
PyGILState_STATE gilstate;
|
PyGILState_STATE gilstate;
|
||||||
bool use_gil;
|
bool use_gil;
|
||||||
@@ -475,8 +480,9 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
|
|||||||
PyTuple_SET_ITEM(((PyObject *)driver_orig->expr_comp), 0, expr_code);
|
PyTuple_SET_ITEM(((PyObject *)driver_orig->expr_comp), 0, expr_code);
|
||||||
|
|
||||||
driver_orig->flag &= ~DRIVER_FLAG_RECOMPILE;
|
driver_orig->flag &= ~DRIVER_FLAG_RECOMPILE;
|
||||||
driver_orig->flag |=
|
|
||||||
DRIVER_FLAG_RENAMEVAR; /* maybe this can be removed but for now best keep until were sure */
|
/* Maybe this can be removed but for now best keep until were sure. */
|
||||||
|
driver_orig->flag |= DRIVER_FLAG_RENAMEVAR;
|
||||||
#ifdef USE_BYTECODE_WHITELIST
|
#ifdef USE_BYTECODE_WHITELIST
|
||||||
is_recompile = true;
|
is_recompile = true;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -116,8 +116,9 @@ static void gizmo_properties_init(wmGizmoType *gzt)
|
|||||||
|
|
||||||
/* Extract target property definitions from 'bl_target_properties' */
|
/* Extract target property definitions from 'bl_target_properties' */
|
||||||
{
|
{
|
||||||
/* picky developers will notice that 'bl_targets' won't work with inheritance
|
/* Picky developers will notice that 'bl_targets' won't work with inheritance
|
||||||
* get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) - campbell */
|
* get direct from the dict to avoid raising a load of attribute errors
|
||||||
|
* (yes this isnt ideal) - campbell. */
|
||||||
PyObject *py_class_dict = py_class->tp_dict;
|
PyObject *py_class_dict = py_class->tp_dict;
|
||||||
PyObject *bl_target_properties = PyDict_GetItem(py_class_dict,
|
PyObject *bl_target_properties = PyDict_GetItem(py_class_dict,
|
||||||
bpy_intern_str_bl_target_properties);
|
bpy_intern_str_bl_target_properties);
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_RNA, "bpy.rna");
|
|||||||
|
|
||||||
/* for internal use, when starting and ending python scripts */
|
/* for internal use, when starting and ending python scripts */
|
||||||
|
|
||||||
/* in case a python script triggers another python call, stop bpy_context_clear from invalidating */
|
/* In case a python script triggers another python call,
|
||||||
|
* stop bpy_context_clear from invalidating. */
|
||||||
static int py_call_level = 0;
|
static int py_call_level = 0;
|
||||||
|
|
||||||
// #define TIME_PY_RUN // simple python tests. prints on exit.
|
// #define TIME_PY_RUN // simple python tests. prints on exit.
|
||||||
|
|||||||
@@ -314,8 +314,9 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* when calling bpy.ops.wm.read_factory_settings() bpy.data's main pointer is freed by clear_globals(),
|
/* When calling bpy.ops.wm.read_factory_settings() bpy.data's main pointer
|
||||||
* further access will crash blender. setting context is not needed in this case, only calling because this
|
* is freed by clear_globals(), further access will crash blender.
|
||||||
|
* Setting context is not needed in this case, only calling because this
|
||||||
* function corrects bpy.data (internal Main pointer) */
|
* function corrects bpy.data (internal Main pointer) */
|
||||||
BPY_modules_update(C);
|
BPY_modules_update(C);
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,8 @@ static void operator_properties_init(wmOperatorType *ot)
|
|||||||
/* Only call this so pyrna_deferred_register_class gives a useful error
|
/* Only call this so pyrna_deferred_register_class gives a useful error
|
||||||
* WM_operatortype_append_ptr will call RNA_def_struct_identifier later.
|
* WM_operatortype_append_ptr will call RNA_def_struct_identifier later.
|
||||||
*
|
*
|
||||||
* Note the 'no_struct_map' function is used since the actual struct name is already used by the operator.
|
* Note the 'no_struct_map' function is used since the actual struct name
|
||||||
|
* is already used by the operator.
|
||||||
*/
|
*/
|
||||||
RNA_def_struct_identifier_no_struct_map(ot->srna, ot->idname);
|
RNA_def_struct_identifier_no_struct_map(ot->srna, ot->idname);
|
||||||
|
|
||||||
@@ -56,8 +57,9 @@ static void operator_properties_init(wmOperatorType *ot)
|
|||||||
|
|
||||||
/* set the default property: ot->prop */
|
/* set the default property: ot->prop */
|
||||||
{
|
{
|
||||||
/* picky developers will notice that 'bl_property' won't work with inheritance
|
/* Picky developers will notice that 'bl_property' won't work with inheritance
|
||||||
* get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal) - campbell */
|
* get direct from the dict to avoid raising a load of attribute errors (yes this isnt ideal)
|
||||||
|
* - campbell. */
|
||||||
PyObject *py_class_dict = py_class->tp_dict;
|
PyObject *py_class_dict = py_class->tp_dict;
|
||||||
PyObject *bl_property = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_property);
|
PyObject *bl_property = PyDict_GetItem(py_class_dict, bpy_intern_str_bl_property);
|
||||||
const char *prop_id;
|
const char *prop_id;
|
||||||
|
|||||||
@@ -2277,7 +2277,10 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// prop = RNA_def_boolean_array(srna, id, size, pydef ? def:NULL, name ? name : id, description);
|
#if 0
|
||||||
|
prop = RNA_def_boolean_array(
|
||||||
|
srna, id, size, pydef ? def : NULL, name ? name : id, description);
|
||||||
|
#endif
|
||||||
prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
|
prop = RNA_def_property(srna, id, PROP_BOOLEAN, subtype);
|
||||||
RNA_def_property_array(prop, size);
|
RNA_def_property_array(prop, size);
|
||||||
if (pydef) {
|
if (pydef) {
|
||||||
|
|||||||
@@ -189,7 +189,8 @@ static void id_weakref_pool_add(ID *id, BPy_DummyPointerRNA *pyrna)
|
|||||||
PyObject *weakref_capsule;
|
PyObject *weakref_capsule;
|
||||||
PyObject *weakref_cb_py;
|
PyObject *weakref_cb_py;
|
||||||
|
|
||||||
/* create a new function instance and insert the list as 'self' so we can remove ourself from it */
|
/* Create a new function instance and insert the list as 'self'
|
||||||
|
* so we can remove ourself from it. */
|
||||||
GHash *weakinfo_hash = id_weakref_pool_get(id); /* new or existing */
|
GHash *weakinfo_hash = id_weakref_pool_get(id); /* new or existing */
|
||||||
|
|
||||||
weakref_capsule = PyCapsule_New(weakinfo_hash, NULL, NULL);
|
weakref_capsule = PyCapsule_New(weakinfo_hash, NULL, NULL);
|
||||||
@@ -704,7 +705,8 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop)
|
|||||||
case PROP_QUATERNION:
|
case PROP_QUATERNION:
|
||||||
if (len == 3) { /* euler */
|
if (len == 3) { /* euler */
|
||||||
if (is_thick) {
|
if (is_thick) {
|
||||||
/* attempt to get order, only needed for thick types since wrapped with update via callbacks */
|
/* Attempt to get order,
|
||||||
|
* only needed for thick types since wrapped with update via callbacks. */
|
||||||
PropertyRNA *prop_eul_order = NULL;
|
PropertyRNA *prop_eul_order = NULL;
|
||||||
short order = pyrna_rotation_euler_order_get(ptr, EULER_ORDER_XYZ, &prop_eul_order);
|
short order = pyrna_rotation_euler_order_get(ptr, EULER_ORDER_XYZ, &prop_eul_order);
|
||||||
|
|
||||||
@@ -1433,7 +1435,8 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val)
|
|||||||
RNA_property_enum_items_ex(NULL, ptr, prop, true, &enum_item, NULL, &free_dummy);
|
RNA_property_enum_items_ex(NULL, ptr, prop, true, &enum_item, NULL, &free_dummy);
|
||||||
BLI_assert(!free_dummy);
|
BLI_assert(!free_dummy);
|
||||||
|
|
||||||
/* Do not print warning in case of DummyRNA_NULL_items, this one will never match any value... */
|
/* Do not print warning in case of DummyRNA_NULL_items,
|
||||||
|
* this one will never match any value... */
|
||||||
if (enum_item != DummyRNA_NULL_items) {
|
if (enum_item != DummyRNA_NULL_items) {
|
||||||
const char *ptr_name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
|
const char *ptr_name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL);
|
||||||
|
|
||||||
@@ -1846,7 +1849,8 @@ static int pyrna_py_to_prop(
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* same as bytes */
|
/* same as bytes */
|
||||||
/* XXX, this is suspect but needed for function calls, need to see if theres a better way */
|
/* XXX, this is suspect but needed for function calls,
|
||||||
|
* need to see if theres a better way. */
|
||||||
if (data) {
|
if (data) {
|
||||||
*((char **)data) = (char *)param;
|
*((char **)data) = (char *)param;
|
||||||
}
|
}
|
||||||
@@ -1902,7 +1906,8 @@ static int pyrna_py_to_prop(
|
|||||||
* if the prop is not an operator type and the pyobject is an operator,
|
* if the prop is not an operator type and the pyobject is an operator,
|
||||||
* use its properties in place of its self.
|
* use its properties in place of its self.
|
||||||
*
|
*
|
||||||
* this is so bad that its almost a good reason to do away with fake 'self.properties -> self'
|
* This is so bad that its almost a good reason to do away with fake
|
||||||
|
* 'self.properties -> self'
|
||||||
* class mixing if this causes problems in the future it should be removed.
|
* class mixing if this causes problems in the future it should be removed.
|
||||||
*/
|
*/
|
||||||
if ((ptr_type == &RNA_AnyType) && (BPy_StructRNA_Check(value))) {
|
if ((ptr_type == &RNA_AnyType) && (BPy_StructRNA_Check(value))) {
|
||||||
@@ -1997,8 +2002,9 @@ static int pyrna_py_to_prop(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* for function calls, we sometimes want to pass the 'ptr' directly,
|
/* For function calls, we sometimes want to pass the 'ptr' directly,
|
||||||
* watch out that it remains valid!, possibly we could support this later if needed */
|
* watch out that it remains valid!,
|
||||||
|
* possibly we could support this later if needed. */
|
||||||
BLI_assert(value_new == NULL);
|
BLI_assert(value_new == NULL);
|
||||||
if (value == Py_None) {
|
if (value == Py_None) {
|
||||||
*((void **)data) = NULL;
|
*((void **)data) = NULL;
|
||||||
@@ -4187,8 +4193,8 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname)
|
|||||||
ret = NULL;
|
ret = NULL;
|
||||||
}
|
}
|
||||||
else if (
|
else if (
|
||||||
name[0] ==
|
/* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */
|
||||||
'_') { /* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */
|
name[0] == '_') {
|
||||||
/* annoying exception, maybe we need to have different types for this... */
|
/* annoying exception, maybe we need to have different types for this... */
|
||||||
if (STR_ELEM(name, "__getitem__", "__setitem__") &&
|
if (STR_ELEM(name, "__getitem__", "__setitem__") &&
|
||||||
!RNA_struct_idprops_check(self->ptr.type)) {
|
!RNA_struct_idprops_check(self->ptr.type)) {
|
||||||
@@ -4312,9 +4318,11 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr
|
|||||||
* >>> bpy.types.Scene.foo = BoolProperty()
|
* >>> bpy.types.Scene.foo = BoolProperty()
|
||||||
* >>> bpy.types.Scene.foo
|
* >>> bpy.types.Scene.foo
|
||||||
* <bpy_struct, BoolProperty("foo")>
|
* <bpy_struct, BoolProperty("foo")>
|
||||||
* ...rather than returning the deferred class register tuple as checked by pyrna_is_deferred_prop()
|
* ...rather than returning the deferred class register tuple
|
||||||
|
* as checked by pyrna_is_deferred_prop()
|
||||||
*
|
*
|
||||||
* Disable for now, this is faking internal behavior in a way that's too tricky to maintain well. */
|
* Disable for now,
|
||||||
|
* this is faking internal behavior in a way that's too tricky to maintain well. */
|
||||||
# if 0
|
# if 0
|
||||||
if (ret == NULL) { // || pyrna_is_deferred_prop(ret)
|
if (ret == NULL) { // || pyrna_is_deferred_prop(ret)
|
||||||
StructRNA *srna = srna_from_self(cls, "StructRNA.__getattr__");
|
StructRNA *srna = srna_from_self(cls, "StructRNA.__getattr__");
|
||||||
@@ -4424,7 +4432,8 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (self->ptr.type == &RNA_Context) {
|
else if (self->ptr.type == &RNA_Context) {
|
||||||
/* code just raises correct error, context prop's cant be set, unless its apart of the py class */
|
/* Code just raises correct error, context prop's cant be set,
|
||||||
|
* unless its apart of the py class. */
|
||||||
bContext *C = self->ptr.data;
|
bContext *C = self->ptr.data;
|
||||||
if (C == NULL) {
|
if (C == NULL) {
|
||||||
PyErr_Format(PyExc_AttributeError,
|
PyErr_Format(PyExc_AttributeError,
|
||||||
@@ -5105,7 +5114,8 @@ static int foreach_parse_args(BPy_PropertyRNA *self,
|
|||||||
}
|
}
|
||||||
*size = RNA_raw_type_sizeof(*raw_type);
|
*size = RNA_raw_type_sizeof(*raw_type);
|
||||||
|
|
||||||
#if 0 /* works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks */
|
#if 0 /* works fine but not strictly needed,
|
||||||
|
* we could allow RNA_property_collection_raw_* to do the checks */
|
||||||
if ((*attr_tot) < 1) {
|
if ((*attr_tot) < 1) {
|
||||||
*attr_tot = 1;
|
*attr_tot = 1;
|
||||||
}
|
}
|
||||||
@@ -5130,8 +5140,9 @@ static int foreach_parse_args(BPy_PropertyRNA *self,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check 'attr_tot' otherwise we don't know if any values were set
|
/* Check 'attr_tot' otherwise we don't know if any values were set
|
||||||
* this isn't ideal because it means running on an empty list may fail silently when its not compatible. */
|
* this isn't ideal because it means running on an empty list may
|
||||||
|
* fail silently when its not compatible. */
|
||||||
if (*size == 0 && *attr_tot != 0) {
|
if (*size == 0 && *attr_tot != 0) {
|
||||||
PyErr_SetString(PyExc_AttributeError, "attribute does not support foreach method");
|
PyErr_SetString(PyExc_AttributeError, "attribute does not support foreach method");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -5997,7 +6008,8 @@ static PyObject *pyrna_func_call(BPy_FunctionRNA *self, PyObject *args, PyObject
|
|||||||
/* Check if we gave args that don't exist in the function
|
/* Check if we gave args that don't exist in the function
|
||||||
* printing the error is slow but it should only happen when developing.
|
* printing the error is slow but it should only happen when developing.
|
||||||
* the if below is quick, checking if it passed less keyword args then we gave.
|
* the if below is quick, checking if it passed less keyword args then we gave.
|
||||||
* (Don't overwrite the error if we have one, otherwise can skip important messages and confuse with args)
|
* (Don't overwrite the error if we have one,
|
||||||
|
* otherwise can skip important messages and confuse with args).
|
||||||
*/
|
*/
|
||||||
if (err == 0 && kw && (pykw_len > kw_tot)) {
|
if (err == 0 && kw && (pykw_len > kw_tot)) {
|
||||||
PyObject *key, *value;
|
PyObject *key, *value;
|
||||||
@@ -6894,7 +6906,8 @@ static PyObject *pyrna_prop_collection_iter_next(BPy_PropertyCollectionIterRNA *
|
|||||||
if ((PyObject *)pyrna != Py_None) {
|
if ((PyObject *)pyrna != Py_None) {
|
||||||
/* hold a reference to the iterator since it may have
|
/* hold a reference to the iterator since it may have
|
||||||
* allocated memory 'pyrna' needs. eg: introspecting dynamic enum's */
|
* allocated memory 'pyrna' needs. eg: introspecting dynamic enum's */
|
||||||
/* TODO, we could have an api call to know if this is needed since most collections don't */
|
/* TODO, we could have an api call to know if this is
|
||||||
|
* needed since most collections don't */
|
||||||
pyrna_struct_reference_set(pyrna, (PyObject *)self);
|
pyrna_struct_reference_set(pyrna, (PyObject *)self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7025,8 +7038,10 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna)
|
|||||||
/* sanity check, could skip this unless in debug mode */
|
/* sanity check, could skip this unless in debug mode */
|
||||||
if (newclass) {
|
if (newclass) {
|
||||||
PyObject *base_compare = pyrna_srna_PyBase(srna);
|
PyObject *base_compare = pyrna_srna_PyBase(srna);
|
||||||
//PyObject *slots = PyObject_GetAttrString(newclass, "__slots__"); // cant do this because it gets superclasses values!
|
/* Can't do this because it gets superclasses values! */
|
||||||
//PyObject *bases = PyObject_GetAttrString(newclass, "__bases__"); // can do this but faster not to.
|
// PyObject *slots = PyObject_GetAttrString(newclass, "__slots__");
|
||||||
|
/* Can do this but faster not to. */
|
||||||
|
// PyObject *bases = PyObject_GetAttrString(newclass, "__bases__");
|
||||||
PyObject *tp_bases = ((PyTypeObject *)newclass)->tp_bases;
|
PyObject *tp_bases = ((PyTypeObject *)newclass)->tp_bases;
|
||||||
PyObject *tp_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict,
|
PyObject *tp_slots = PyDict_GetItem(((PyTypeObject *)newclass)->tp_dict,
|
||||||
bpy_intern_str___slots__);
|
bpy_intern_str___slots__);
|
||||||
@@ -7077,7 +7092,10 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
|
|||||||
/* subclass equivalents
|
/* subclass equivalents
|
||||||
* - class myClass(myBase):
|
* - class myClass(myBase):
|
||||||
* some = 'value' # or ...
|
* some = 'value' # or ...
|
||||||
* - myClass = type(name='myClass', bases=(myBase,), dict={'__module__': 'bpy.types', '__slots__': ()})
|
* - myClass = type(
|
||||||
|
* name='myClass',
|
||||||
|
* bases=(myBase,), dict={'__module__': 'bpy.types', '__slots__': ()}
|
||||||
|
* )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Assume RNA_struct_py_type_get(srna) was already checked */
|
/* Assume RNA_struct_py_type_get(srna) was already checked */
|
||||||
@@ -7132,7 +7150,8 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* newclass will now have 2 ref's, ???, probably 1 is internal since decrefing here segfaults */
|
/* Newclass will now have 2 ref's, ???,
|
||||||
|
* probably 1 is internal since decrefing here segfaults. */
|
||||||
|
|
||||||
/* PyC_ObSpit("new class ref", newclass); */
|
/* PyC_ObSpit("new class ref", newclass); */
|
||||||
|
|
||||||
@@ -7884,7 +7903,8 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
|
|||||||
const int flag = RNA_function_flag(func);
|
const int flag = RNA_function_flag(func);
|
||||||
/* TODO(campbell): this is used for classmethod's too,
|
/* TODO(campbell): this is used for classmethod's too,
|
||||||
* even though class methods should have 'FUNC_USE_SELF_TYPE' set, see Operator.poll for eg.
|
* even though class methods should have 'FUNC_USE_SELF_TYPE' set, see Operator.poll for eg.
|
||||||
* Keep this as-is since its working but we should be using 'FUNC_USE_SELF_TYPE' for many functions. */
|
* Keep this as-is since its working but we should be using
|
||||||
|
* 'FUNC_USE_SELF_TYPE' for many functions. */
|
||||||
const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE);
|
const bool is_staticmethod = (flag & FUNC_NO_SELF) && !(flag & FUNC_USE_SELF_TYPE);
|
||||||
|
|
||||||
if (!(flag & FUNC_REGISTER)) {
|
if (!(flag & FUNC_REGISTER)) {
|
||||||
@@ -7909,8 +7929,9 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr,
|
|||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Py_DECREF(
|
/* No need to keep a ref, the class owns it (technically we should keep a ref but...). */
|
||||||
item); /* no need to keep a ref, the class owns it (technically we should keep a ref but...) */
|
Py_DECREF(item);
|
||||||
|
|
||||||
if (is_staticmethod) {
|
if (is_staticmethod) {
|
||||||
if (PyMethod_Check(item) == 0) {
|
if (PyMethod_Check(item) == 0) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
@@ -8198,7 +8219,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param
|
|||||||
else {
|
else {
|
||||||
arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
|
arg_count = ((PyCodeObject *)PyFunction_GET_CODE(item))->co_argcount;
|
||||||
}
|
}
|
||||||
// args = PyTuple_New(rna_function_arg_count(func)); /* first arg is included in 'item' */
|
#if 0
|
||||||
|
/* First arg is included in 'item'. */
|
||||||
|
args = PyTuple_New(rna_function_arg_count(func));
|
||||||
|
#endif
|
||||||
args = PyTuple_New(arg_count); /* first arg is included in 'item' */
|
args = PyTuple_New(arg_count); /* first arg is included in 'item' */
|
||||||
|
|
||||||
if (is_staticmethod) {
|
if (is_staticmethod) {
|
||||||
|
|||||||
@@ -24,7 +24,10 @@
|
|||||||
/* --- bpy build options --- */
|
/* --- bpy build options --- */
|
||||||
#ifdef WITH_PYTHON_SAFETY
|
#ifdef WITH_PYTHON_SAFETY
|
||||||
|
|
||||||
/* play it safe and keep optional for now, need to test further now this affects looping on 10000's of verts for eg. */
|
/**
|
||||||
|
* Play it safe and keep optional for now,
|
||||||
|
* need to test further now this affects looping on 10000's of verts for eg.
|
||||||
|
*/
|
||||||
# define USE_WEAKREFS
|
# define USE_WEAKREFS
|
||||||
|
|
||||||
/* method to invalidate removed py data, XXX, slow to remove objects, otherwise no overhead */
|
/* method to invalidate removed py data, XXX, slow to remove objects, otherwise no overhead */
|
||||||
@@ -146,8 +149,10 @@ typedef struct {
|
|||||||
PropertyRNA *prop;
|
PropertyRNA *prop;
|
||||||
|
|
||||||
/* Arystan: this is a hack to allow sub-item r/w access like: face.uv[n][m] */
|
/* Arystan: this is a hack to allow sub-item r/w access like: face.uv[n][m] */
|
||||||
int arraydim; /* array dimension, e.g: 0 for face.uv, 2 for face.uv[n][m], etc. */
|
/** Array dimension, e.g: 0 for face.uv, 2 for face.uv[n][m], etc. */
|
||||||
int arrayoffset; /* array first item offset, e.g. if face.uv is [4][2], arrayoffset for face.uv[n] is 2n */
|
int arraydim;
|
||||||
|
/** Array first item offset, e.g. if face.uv is [4][2], arrayoffset for face.uv[n] is 2n. */
|
||||||
|
int arrayoffset;
|
||||||
} BPy_PropertyArrayRNA;
|
} BPy_PropertyArrayRNA;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@@ -86,7 +86,8 @@ typedef struct ItemConvert_FuncArg {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* arr[3] = x, self->arraydim is 0, lvalue_dim is 1 */
|
/* arr[3] = x, self->arraydim is 0, lvalue_dim is 1 */
|
||||||
/* Ensures that a python sequence has expected number of items/sub-items and items are of desired type. */
|
/* Ensures that a python sequence has expected number of
|
||||||
|
* items/sub-items and items are of desired type. */
|
||||||
static int validate_array_type(PyObject *seq,
|
static int validate_array_type(PyObject *seq,
|
||||||
int dim,
|
int dim,
|
||||||
int totdim,
|
int totdim,
|
||||||
@@ -203,7 +204,10 @@ static int validate_array_type(PyObject *seq,
|
|||||||
else if (!check_item_type(item)) {
|
else if (!check_item_type(item)) {
|
||||||
Py_DECREF(item);
|
Py_DECREF(item);
|
||||||
|
|
||||||
/* BLI_snprintf(error_str, error_str_size, "sequence items should be of type %s", item_type_str); */
|
#if 0
|
||||||
|
BLI_snprintf(
|
||||||
|
error_str, error_str_size, "sequence items should be of type %s", item_type_str);
|
||||||
|
#endif
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"%s expected sequence items of type %s, not %s",
|
"%s expected sequence items of type %s, not %s",
|
||||||
error_prefix,
|
error_prefix,
|
||||||
|
|||||||
@@ -34,7 +34,8 @@
|
|||||||
#include "BKE_main.h"
|
#include "BKE_main.h"
|
||||||
|
|
||||||
#include "DNA_ID.h"
|
#include "DNA_ID.h"
|
||||||
/* Those folowing are only to support hack of not listing some internal 'backward' pointers in generated user_map... */
|
/* Those folowing are only to support hack of not listing some internal
|
||||||
|
* 'backward' pointers in generated user_map. */
|
||||||
#include "DNA_object_types.h"
|
#include "DNA_object_types.h"
|
||||||
#include "DNA_key_types.h"
|
#include "DNA_key_types.h"
|
||||||
|
|
||||||
@@ -97,11 +98,13 @@ static int foreach_libblock_id_user_map_callback(void *user_data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((GS(self_id->name) == ID_OB) && (id_p == (ID **)&((Object *)self_id)->proxy_from)) {
|
if ((GS(self_id->name) == ID_OB) && (id_p == (ID **)&((Object *)self_id)->proxy_from)) {
|
||||||
/* We skip proxy_from here, since it's some internal pointer which is not relevant info for py/API level. */
|
/* We skip proxy_from here,
|
||||||
|
* since it's some internal pointer which is not relevant info for py/API level. */
|
||||||
return IDWALK_RET_NOP;
|
return IDWALK_RET_NOP;
|
||||||
}
|
}
|
||||||
else if ((GS(self_id->name) == ID_KE) && (id_p == (ID **)&((Key *)self_id)->from)) {
|
else if ((GS(self_id->name) == ID_KE) && (id_p == (ID **)&((Key *)self_id)->from)) {
|
||||||
/* We skip from here, since it's some internal pointer which is not relevant info for py/API level. */
|
/* We skip from here,
|
||||||
|
* since it's some internal pointer which is not relevant info for py/API level. */
|
||||||
return IDWALK_RET_NOP;
|
return IDWALK_RET_NOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,14 +248,16 @@ static PyObject *bpy_user_map(PyObject *UNUSED(self), PyObject *args, PyObject *
|
|||||||
if (!data_cb.is_subset &&
|
if (!data_cb.is_subset &&
|
||||||
/* We do not want to pre-add keys of flitered out types. */
|
/* We do not want to pre-add keys of flitered out types. */
|
||||||
(key_types_bitmap == NULL || id_check_type(id, key_types_bitmap)) &&
|
(key_types_bitmap == NULL || id_check_type(id, key_types_bitmap)) &&
|
||||||
/* We do not want to pre-add keys when we have filter on value types, but not on key types. */
|
/* We do not want to pre-add keys when we have filter on value types,
|
||||||
|
* but not on key types. */
|
||||||
(val_types_bitmap == NULL || key_types_bitmap != NULL)) {
|
(val_types_bitmap == NULL || key_types_bitmap != NULL)) {
|
||||||
PyObject *key = data_cb.py_id_key_lookup_only;
|
PyObject *key = data_cb.py_id_key_lookup_only;
|
||||||
PyObject *set;
|
PyObject *set;
|
||||||
|
|
||||||
RNA_id_pointer_create(id, &((BPy_StructRNA *)key)->ptr);
|
RNA_id_pointer_create(id, &((BPy_StructRNA *)key)->ptr);
|
||||||
|
|
||||||
/* We have to insert the key now, otherwise ID unused would be missing from final dict... */
|
/* We have to insert the key now,
|
||||||
|
* otherwise ID unused would be missing from final dict... */
|
||||||
if ((set = PyDict_GetItem(data_cb.user_map, key)) == NULL) {
|
if ((set = PyDict_GetItem(data_cb.user_map, key)) == NULL) {
|
||||||
/* Cannot use our placeholder key here! */
|
/* Cannot use our placeholder key here! */
|
||||||
key = pyrna_id_CreatePyObject(id);
|
key = pyrna_id_CreatePyObject(id);
|
||||||
|
|||||||
@@ -66,8 +66,8 @@ static const char *bpyunits_ucategorie_items[] = {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* These fields are just empty placeholders, actual values get set in initializations functions.
|
* These fields are just empty placeholders, actual values get set in initializations functions.
|
||||||
* This allows us to avoid many handwriting, and above all, to keep all systems/categories definition stuff in
|
* This allows us to avoid many handwriting, and above all,
|
||||||
* ``BKE_unit.h``.
|
* to keep all systems/categories definition stuff in ``BKE_unit.h``.
|
||||||
*/
|
*/
|
||||||
static PyStructSequence_Field bpyunits_systems_fields[ARRAY_SIZE(bpyunits_usystem_items)];
|
static PyStructSequence_Field bpyunits_systems_fields[ARRAY_SIZE(bpyunits_usystem_items)];
|
||||||
static PyStructSequence_Field bpyunits_categories_fields[ARRAY_SIZE(bpyunits_ucategorie_items)];
|
static PyStructSequence_Field bpyunits_categories_fields[ARRAY_SIZE(bpyunits_ucategorie_items)];
|
||||||
@@ -281,9 +281,11 @@ static PyObject *bpyunits_to_string(PyObject *UNUSED(self), PyObject *args, PyOb
|
|||||||
|
|
||||||
{
|
{
|
||||||
/* Maximum expected length of string result:
|
/* Maximum expected length of string result:
|
||||||
* - number itself: precision + decimal dot + up to four 'above dot' digits.
|
* - Number itself: precision + decimal dot + up to four 'above dot' digits.
|
||||||
* - unit: up to ten chars (six currently, let's be conservative, also because we use some utf8 chars).
|
* - Unit: up to ten chars
|
||||||
* This can be repeated twice (e.g. 1m20cm), and we add ten more spare chars (spaces, trailing '\0'...).
|
* (six currently, let's be conservative, also because we use some utf8 chars).
|
||||||
|
* This can be repeated twice (e.g. 1m20cm), and we add ten more spare chars
|
||||||
|
* (spaces, trailing '\0'...).
|
||||||
* So in practice, 64 should be more than enough.
|
* So in practice, 64 should be more than enough.
|
||||||
*/
|
*/
|
||||||
char buf1[64], buf2[64], *str;
|
char buf1[64], buf2[64], *str;
|
||||||
|
|||||||
@@ -381,13 +381,16 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error
|
|||||||
|
|
||||||
/* LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon */
|
/* LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon */
|
||||||
/* XXX We may want to use 'safer' BLI's compare_ff_relative ultimately?
|
/* XXX We may want to use 'safer' BLI's compare_ff_relative ultimately?
|
||||||
* LomontRRDCompare4() is an optimized version of Dawson's AlmostEqual2sComplement() (see [1] and [2]).
|
* LomontRRDCompare4() is an optimized version of Dawson's AlmostEqual2sComplement()
|
||||||
* Dawson himself now claims this is not a 'safe' thing to do (pushing ULP method beyond its limits),
|
* (see [1] and [2]).
|
||||||
* an recommends using work from [3] instead, which is done in BLI func...
|
* Dawson himself now claims this is not a 'safe' thing to do
|
||||||
|
* (pushing ULP method beyond its limits),
|
||||||
|
* an recommends using work from [3] instead, which is done in BLI func...
|
||||||
*
|
*
|
||||||
* [1] http://www.randydillon.org/Papers/2007/everfast.htm
|
* [1] http://www.randydillon.org/Papers/2007/everfast.htm
|
||||||
* [2] http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
|
* [2] http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm
|
||||||
* [3] https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ instead
|
* [3] https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
|
||||||
|
* instead.
|
||||||
*/
|
*/
|
||||||
#define SIGNMASK(i) (-(int)(((unsigned int)(i)) >> 31))
|
#define SIGNMASK(i) (-(int)(((unsigned int)(i)) >> 31))
|
||||||
|
|
||||||
@@ -437,7 +440,8 @@ PyObject *mathutils_dynstr_to_py(struct DynStr *ds)
|
|||||||
|
|
||||||
/* Mathutils Callbacks */
|
/* Mathutils Callbacks */
|
||||||
|
|
||||||
/* for mathutils internal use only, eventually should re-alloc but to start with we only have a few users */
|
/* For mathutils internal use only,
|
||||||
|
* eventually should re-alloc but to start with we only have a few users. */
|
||||||
#define MATHUTILS_TOT_CB 17
|
#define MATHUTILS_TOT_CB 17
|
||||||
static Mathutils_Callback *mathutils_callbacks[MATHUTILS_TOT_CB] = {NULL};
|
static Mathutils_Callback *mathutils_callbacks[MATHUTILS_TOT_CB] = {NULL};
|
||||||
|
|
||||||
|
|||||||
@@ -1072,7 +1072,8 @@ static void matrix_invert_safe_internal(const MatrixObject *self, float *r_mat)
|
|||||||
if (det == 0.0f) {
|
if (det == 0.0f) {
|
||||||
const float eps = PSEUDOINVERSE_EPSILON;
|
const float eps = PSEUDOINVERSE_EPSILON;
|
||||||
|
|
||||||
/* We will copy self->matrix into r_mat (if needed), and modify it in place to add diagonal epsilon. */
|
/* We will copy self->matrix into r_mat (if needed),
|
||||||
|
* and modify it in place to add diagonal epsilon. */
|
||||||
in_mat = r_mat;
|
in_mat = r_mat;
|
||||||
|
|
||||||
switch (self->num_col) {
|
switch (self->num_col) {
|
||||||
|
|||||||
@@ -2377,12 +2377,15 @@ static PyObject *Vector_length_squared_get(VectorObject *self, void *UNUSED(clos
|
|||||||
* '((%s | SWIZZLE_VALID_AXIS) | '
|
* '((%s | SWIZZLE_VALID_AXIS) | '
|
||||||
* '((%s | SWIZZLE_VALID_AXIS) << SWIZZLE_BITS_PER_AXIS) | '
|
* '((%s | SWIZZLE_VALID_AXIS) << SWIZZLE_BITS_PER_AXIS) | '
|
||||||
* '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)) | '
|
* '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 2)) | '
|
||||||
* '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3))) ' %
|
* '((%s | SWIZZLE_VALID_AXIS) << (SWIZZLE_BITS_PER_AXIS * 3))) '
|
||||||
|
* %
|
||||||
* (axis_0_pos, axis_1_pos, axis_2_pos, axis_3_pos))
|
* (axis_0_pos, axis_1_pos, axis_2_pos, axis_3_pos))
|
||||||
*
|
*
|
||||||
* axises = axises[:-1]
|
* axises = axises[:-1]
|
||||||
* items = list(axis_dict.items())
|
* items = list(axis_dict.items())
|
||||||
* items.sort(key=lambda a: a[0].replace('x', '0').replace('y', '1').replace('z', '2').replace('w', '3'))
|
* items.sort(
|
||||||
|
* key=lambda a: a[0].replace('x', '0').replace('y', '1').replace('z', '2').replace('w', '3')
|
||||||
|
* )
|
||||||
*
|
*
|
||||||
* unique = set()
|
* unique = set()
|
||||||
* for key, val in items:
|
* for key, val in items:
|
||||||
|
|||||||
@@ -1043,7 +1043,13 @@ static PyObject *M_Geometry_points_in_planes(PyObject *UNUSED(self), PyObject *a
|
|||||||
if (len_squared_v3(n3n1) > eps) {
|
if (len_squared_v3(n3n1) > eps) {
|
||||||
const float quotient = dot_v3v3(N1, n2n3);
|
const float quotient = dot_v3v3(N1, n2n3);
|
||||||
if (fabsf(quotient) > eps) {
|
if (fabsf(quotient) > eps) {
|
||||||
/* potentialVertex = (n2n3 * N1[3] + n3n1 * N2[3] + n1n2 * N3[3]) * (-1.0 / quotient); */
|
/**
|
||||||
|
* <pre>
|
||||||
|
* potentialVertex = (
|
||||||
|
* (n2n3 * N1[3] + n3n1 * N2[3] + n1n2 * N3[3]) *
|
||||||
|
* (-1.0 / quotient));
|
||||||
|
* </pre>
|
||||||
|
*/
|
||||||
const float quotient_ninv = -1.0f / quotient;
|
const float quotient_ninv = -1.0f / quotient;
|
||||||
potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) +
|
potentialVertex[0] = ((n2n3[0] * N1[3]) + (n3n1[0] * N2[3]) +
|
||||||
(n1n2[0] * N3[3])) *
|
(n1n2[0] * N3[3])) *
|
||||||
|
|||||||
Reference in New Issue
Block a user