Blender V5.0
mathutils.hh File Reference
#include <Python.h>
#include "BLI_array.hh"
#include "BLI_vector.hh"
#include "mathutils_Color.hh"
#include "mathutils_Euler.hh"
#include "mathutils_Matrix.hh"
#include "mathutils_Quaternion.hh"
#include "mathutils_Vector.hh"

Go to the source code of this file.

Classes

struct  BaseMathObject
struct  Mathutils_Callback

Macros

#define BASE_MATH_NEW(struct_name, root_type, base_type)
#define BASE_MATH_FLAG_DEFAULT   0
#define BASE_MATH_MEMBERS(_data)
#define BaseMathObject_CheckExact(v)
#define BaseMath_CheckCallback(_self)
#define BaseMath_ReadCallback(_self)
#define BaseMath_WriteCallback(_self)
#define BaseMath_ReadIndexCallback(_self, _index)
#define BaseMath_WriteIndexCallback(_self, _index)
#define BaseMath_ReadCallback_ForWrite(_self)
#define BaseMath_ReadIndexCallback_ForWrite(_self, _index)
#define BaseMath_Prepare_ForWrite(_self)
#define BaseMathObject_Prepare_ForHash(_self)
#define BaseMathObject_Prepare_ForResize(_self, error_prefix)
#define BaseMath_Prepare_ForBufferAccess(_self, _view, _flags)
#define MU_ARRAY_ZERO   (1u << 30)
#define MU_ARRAY_SPILL   (1u << 31)
#define MU_ARRAY_FLAGS   (MU_ARRAY_ZERO | MU_ARRAY_SPILL)

Typedefs

using BaseMathCheckFunc = int (*)(BaseMathObject *)
using BaseMathGetFunc = int (*)(BaseMathObject *, int)
using BaseMathSetFunc = int (*)(BaseMathObject *, int)
using BaseMathGetIndexFunc = int (*)(BaseMathObject *, int, int)
using BaseMathSetIndexFunc = int (*)(BaseMathObject *, int, int)

Enumerations

enum  { BASE_MATH_FLAG_IS_WRAP = (1 << 0) , BASE_MATH_FLAG_IS_FROZEN = (1 << 1) , BASE_MATH_FLAG_HAS_BUFFER_VIEW = (1 << 2) }

Functions

PyObject * _BaseMathObject_new_impl (PyTypeObject *root_type, PyTypeObject *base_type)
PyObject * BaseMathObject_owner_get (BaseMathObject *self, void *)
PyObject * BaseMathObject_is_wrapped_get (BaseMathObject *self, void *)
PyObject * BaseMathObject_is_frozen_get (BaseMathObject *self, void *)
PyObject * BaseMathObject_is_valid_get (BaseMathObject *self, void *)
PyObject * BaseMathObject_freeze (BaseMathObject *self)
int BaseMathObject_traverse (BaseMathObject *self, visitproc visit, void *arg)
int BaseMathObject_clear (BaseMathObject *self)
void BaseMathObject_dealloc (BaseMathObject *self)
int BaseMathObject_is_gc (BaseMathObject *self)
PyMODINIT_FUNC PyInit_mathutils ()
int EXPP_FloatsAreEqual (float af, float bf, int maxDiff)
int EXPP_VectorsAreEqual (const float *vecA, const float *vecB, int size, int floatSteps)
unsigned char Mathutils_RegisterCallback (Mathutils_Callback *cb)
int _BaseMathObject_CheckCallback (BaseMathObject *self)
int _BaseMathObject_ReadCallback (BaseMathObject *self)
int _BaseMathObject_WriteCallback (BaseMathObject *self)
int _BaseMathObject_ReadIndexCallback (BaseMathObject *self, int index)
int _BaseMathObject_WriteIndexCallback (BaseMathObject *self, int index)
int _BaseMathObject_ResizeOkOrRaiseExc (BaseMathObject *self, const char *error_prefix)
int _BaseMathObject_RaiseBufferViewExc (BaseMathObject *self, Py_buffer *view, int flags)
void _BaseMathObject_RaiseFrozenExc (const BaseMathObject *self)
void _BaseMathObject_RaiseNotFrozenExc (const BaseMathObject *self)
int mathutils_array_parse (float *array, int array_num_min, int array_num_max, PyObject *value, const char *error_prefix)
int mathutils_array_parse_alloc (float **array, int array_num_min, PyObject *value, const char *error_prefix)
int mathutils_array_parse_alloc_v (float **array, int array_dim, PyObject *value, const char *error_prefix)
int mathutils_int_array_parse (int *array, int array_dim, PyObject *value, const char *error_prefix)
int mathutils_array_parse_alloc_vi (int **array, int array_dim, PyObject *value, const char *error_prefix)
bool mathutils_array_parse_alloc_viseq (PyObject *value, const char *error_prefix, blender::Array< blender::Vector< int > > &r_data)
int mathutils_any_to_rotmat (float rmat[3][3], PyObject *value, const char *error_prefix)
Py_hash_t mathutils_array_hash (const float *array, size_t array_len)
int column_vector_multiplication (float r_vec[4], VectorObject *vec, MatrixObject *mat)
PyObject * mathutils_dynstr_to_py (struct DynStr *ds)

Variables

char BaseMathObject_is_wrapped_doc []
char BaseMathObject_is_frozen_doc []
char BaseMathObject_is_valid_doc []
char BaseMathObject_owner_doc []
char BaseMathObject_freeze_doc []

Macro Definition Documentation

◆ BASE_MATH_FLAG_DEFAULT

◆ BASE_MATH_MEMBERS

#define BASE_MATH_MEMBERS ( _data)
Value:
\
PyObject_VAR_HEAD \
float *_data; \ \
PyObject *cb_user; \ \
unsigned char cb_type; \ \
unsigned char cb_subtype; \ \
unsigned char flag
uint8_t flag
Definition wm_window.cc:145

Definition at line 54 of file mathutils.hh.

Referenced by BaseMathObject::BASE_MATH_MEMBERS().

◆ BASE_MATH_NEW

#define BASE_MATH_NEW ( struct_name,
root_type,
base_type )

◆ BaseMath_CheckCallback

#define BaseMath_CheckCallback ( _self)
Value:
(((_self)->cb_user ? _BaseMathObject_CheckCallback((BaseMathObject *)_self) : 0))
int _BaseMathObject_CheckCallback(BaseMathObject *self)
Definition mathutils.cc:539

Definition at line 139 of file mathutils.hh.

Referenced by BaseMathObject_is_valid_get().

◆ BaseMath_Prepare_ForBufferAccess

#define BaseMath_Prepare_ForBufferAccess ( _self,
_view,
_flags )
Value:
int _BaseMathObject_RaiseBufferViewExc(BaseMathObject *self, Py_buffer *view, int flags)
Definition mathutils.cc:638

Ensure BASE_MATH_FLAG_HAS_BUFFER_VIEW is supported.

Parameters
_viewThe view argument forwarded from #PyBufferProcs::bf_getbuffer.
_flagsThe flags argument forwarded from #PyBufferProcs::bf_getbuffer.
Returns
-1 and set an exception if the vector _self does not support buffer access.

Definition at line 183 of file mathutils.hh.

Referenced by Color_getbuffer(), Euler_getbuffer(), Matrix_getbuffer(), Quaternion_getbuffer(), and Vector_getbuffer().

◆ BaseMath_Prepare_ForWrite

#define BaseMath_Prepare_ForWrite ( _self)
Value:
0)
#define UNLIKELY(x)
void _BaseMathObject_RaiseFrozenExc(const BaseMathObject *self)
Definition mathutils.cc:604
@ BASE_MATH_FLAG_IS_FROZEN
Definition mathutils.hh:42

Definition at line 161 of file mathutils.hh.

Referenced by Color_ass_item(), Color_hsv_set(), Euler_ass_item(), Euler_order_set(), Euler_zero(), Matrix_zero(), Quaternion_ass_item(), vector_ass_item_internal(), and Vector_zero().

◆ BaseMath_ReadCallback

#define BaseMath_ReadCallback ( _self)
Value:
(((_self)->cb_user ? _BaseMathObject_ReadCallback((BaseMathObject *)_self) : 0))
int _BaseMathObject_ReadCallback(BaseMathObject *self)
Definition mathutils.cc:548

Definition at line 141 of file mathutils.hh.

Referenced by bpy_bmesh_transform(), C_Matrix_LocRotScale(), Color_add(), Color_channel_hsv_get(), Color_copy(), Color_div(), Color_getbuffer(), Color_hash(), Color_hsv_get(), Color_iadd(), Color_isub(), Color_mul(), Color_neg(), Color_repr(), Color_richcmpr(), Color_slice(), Color_str(), Color_sub(), Euler_copy(), Euler_getbuffer(), Euler_hash(), Euler_order_get(), Euler_repr(), Euler_richcmpr(), Euler_slice(), Euler_str(), Euler_to_matrix(), Euler_to_quaternion(), float_array_from_PyObject(), mathutils_any_to_rotmat(), mathutils_array_parse(), mathutils_array_parse_alloc(), mathutils_matrix_col_check(), mathutils_matrix_col_get(), mathutils_matrix_col_get_index(), mathutils_matrix_row_check(), mathutils_matrix_row_get(), mathutils_matrix_row_get_index(), mathutils_matrix_translation_check(), mathutils_matrix_translation_get(), mathutils_matrix_translation_get_index(), Matrix_add(), Matrix_copy(), Matrix_decompose(), Matrix_determinant(), Matrix_getbuffer(), Matrix_hash(), Matrix_imatmul(), Matrix_imul(), Matrix_invert(), Matrix_inverted(), Matrix_inverted_safe(), Matrix_is_identity_get(), Matrix_is_negative_get(), Matrix_is_orthogonal_axis_vectors_get(), Matrix_is_orthogonal_get(), Matrix_lerp(), Matrix_matmul(), Matrix_median_scale_get(), Matrix_mul(), Matrix_ParseCheck(), Matrix_repr(), Matrix_richcmpr(), Matrix_slice(), Matrix_str(), Matrix_sub(), Matrix_to_2x2(), Matrix_to_3x3(), Matrix_to_4x4(), Matrix_to_euler(), Matrix_to_quaternion(), Matrix_to_scale(), Matrix_to_translation(), Matrix_translation_get(), pygpu_shader_uniform_float(), Quaternion_add(), Quaternion_angle_get(), Quaternion_axis_vector_get(), Quaternion_copy(), Quaternion_cross(), Quaternion_dot(), Quaternion_getbuffer(), Quaternion_hash(), Quaternion_imatmul(), Quaternion_imul(), Quaternion_magnitude_get(), Quaternion_matmul(), Quaternion_mul(), Quaternion_neg(), Quaternion_repr(), Quaternion_richcmpr(), Quaternion_rotation_difference(), Quaternion_slerp(), Quaternion_slice(), Quaternion_str(), Quaternion_sub(), Quaternion_to_axis_angle(), Quaternion_to_euler(), Quaternion_to_exponential_map(), Quaternion_to_matrix(), Quaternion_to_swing_twist(), row_vector_multiplication(), validate_array(), Vec2f_ptr_from_Vector(), Vec3f_ptr_from_Color(), Vec3f_ptr_from_Vector(), Vec3r_ptr_from_Color(), Vec3r_ptr_from_Vector(), Vector_add(), Vector_angle(), Vector_angle_signed(), Vector_copy(), Vector_cross(), Vector_div(), Vector_dot(), Vector_getbuffer(), Vector_hash(), Vector_iadd(), Vector_imul(), Vector_isub(), Vector_length_get(), Vector_length_squared_get(), Vector_lerp(), Vector_matmul(), Vector_mul(), Vector_neg(), Vector_negate(), Vector_orthogonal(), Vector_project(), Vector_reflect(), Vector_repr(), Vector_richcmpr(), Vector_rotation_difference(), Vector_slerp(), Vector_slice(), Vector_str(), Vector_sub(), Vector_swizzle_get(), Vector_to_2d(), Vector_to_3d(), Vector_to_4d(), Vector_to_track_quat(), and Vector_to_tuple().

◆ BaseMath_ReadCallback_ForWrite

◆ BaseMath_ReadIndexCallback

#define BaseMath_ReadIndexCallback ( _self,
_index )
Value:
(((_self)->cb_user ? _BaseMathObject_ReadIndexCallback((BaseMathObject *)_self, _index) : 0))
int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index)
Definition mathutils.cc:576

Definition at line 145 of file mathutils.hh.

Referenced by Color_item(), Euler_item(), Quaternion_item(), and vector_item_internal().

◆ BaseMath_ReadIndexCallback_ForWrite

#define BaseMath_ReadIndexCallback_ForWrite ( _self,
_index )
Value:
(BaseMath_ReadIndexCallback(_self, _index)))
#define BaseMath_ReadIndexCallback(_self, _index)
Definition mathutils.hh:145

Definition at line 156 of file mathutils.hh.

◆ BaseMath_WriteCallback

#define BaseMath_WriteCallback ( _self)
Value:
(((_self)->cb_user ? _BaseMathObject_WriteCallback((BaseMathObject *)_self) : 0))
int _BaseMathObject_WriteCallback(BaseMathObject *self)
Definition mathutils.cc:563

Definition at line 143 of file mathutils.hh.

Referenced by _BaseMathObject_RaiseBufferViewExc(), Color_ass_slice(), Color_channel_hsv_set(), Color_hsv_set(), Color_iadd(), Color_idiv(), Color_imul(), Color_isub(), Color_releasebuffer(), Euler_ass_slice(), Euler_make_compatible(), Euler_order_set(), Euler_releasebuffer(), Euler_rotate(), Euler_rotate_axis(), Euler_zero(), mathutils_matrix_col_set(), mathutils_matrix_col_set_index(), mathutils_matrix_row_set(), mathutils_matrix_row_set_index(), mathutils_matrix_translation_set(), mathutils_matrix_translation_set_index(), Matrix_adjugate(), Matrix_ass_item_col(), Matrix_ass_item_row(), Matrix_ass_slice(), Matrix_identity(), Matrix_imatmul(), Matrix_imul(), Matrix_invert(), Matrix_invert_safe(), Matrix_inverted_noargs(), Matrix_normalize(), Matrix_releasebuffer(), Matrix_rotate(), Matrix_translation_set(), Matrix_transpose(), Matrix_zero(), Quaternion_angle_set(), Quaternion_ass_slice(), Quaternion_axis_vector_set(), Quaternion_conjugate(), Quaternion_identity(), Quaternion_imatmul(), Quaternion_imul(), Quaternion_invert(), Quaternion_make_compatible(), Quaternion_negate(), Quaternion_normalize(), Quaternion_releasebuffer(), Quaternion_rotate(), Vector_ass_slice(), Vector_iadd(), Vector_idiv(), Vector_imul(), Vector_isub(), Vector_length_set(), Vector_negate(), Vector_normalize(), Vector_releasebuffer(), Vector_rotate(), Vector_swizzle_set(), and Vector_zero().

◆ BaseMath_WriteIndexCallback

#define BaseMath_WriteIndexCallback ( _self,
_index )
Value:
(((_self)->cb_user ? _BaseMathObject_WriteIndexCallback((BaseMathObject *)_self, _index) : 0))
int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index)
Definition mathutils.cc:590

Definition at line 147 of file mathutils.hh.

Referenced by Color_ass_item(), Euler_ass_item(), Quaternion_ass_item(), and vector_ass_item_internal().

◆ BaseMathObject_CheckExact

#define BaseMathObject_CheckExact ( v)
Value:
(Py_TYPE(v)->tp_dealloc == (destructor)BaseMathObject_dealloc)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void BaseMathObject_dealloc(BaseMathObject *self)
Definition mathutils.cc:740

Definition at line 79 of file mathutils.hh.

Referenced by BaseMathObject_dealloc(), and py_msgbus_rna_key_from_py().

◆ BaseMathObject_Prepare_ForHash

#define BaseMathObject_Prepare_ForHash ( _self)
Value:
(UNLIKELY(((_self)->flag & BASE_MATH_FLAG_IS_FROZEN) == 0) ? \
0)
void _BaseMathObject_RaiseNotFrozenExc(const BaseMathObject *self)
Definition mathutils.cc:609

Definition at line 166 of file mathutils.hh.

Referenced by Color_hash(), Euler_hash(), Matrix_hash(), Quaternion_hash(), and Vector_hash().

◆ BaseMathObject_Prepare_ForResize

#define BaseMathObject_Prepare_ForResize ( _self,
error_prefix )
Value:
int _BaseMathObject_ResizeOkOrRaiseExc(BaseMathObject *self, const char *error_prefix)
Definition mathutils.cc:615

Helper to de-duplicate checks for in-place resizing.

Returns
-1 and set an exception if the vector _self cannot be resized.

Definition at line 174 of file mathutils.hh.

Referenced by Matrix_resize_4x4(), Vector_resize(), Vector_resize_2d(), Vector_resize_3d(), and Vector_resize_4d().

◆ MU_ARRAY_FLAGS

#define MU_ARRAY_FLAGS   (MU_ARRAY_ZERO | MU_ARRAY_SPILL)

Definition at line 244 of file mathutils.hh.

Referenced by mathutils_array_parse(), and mathutils_array_parse_alloc_v().

◆ MU_ARRAY_SPILL

◆ MU_ARRAY_ZERO

Typedef Documentation

◆ BaseMathCheckFunc

using BaseMathCheckFunc = int (*)(BaseMathObject *)

Checks the user is still valid.

Definition at line 103 of file mathutils.hh.

◆ BaseMathGetFunc

using BaseMathGetFunc = int (*)(BaseMathObject *, int)

Gets the vector from the user.

Definition at line 105 of file mathutils.hh.

◆ BaseMathGetIndexFunc

using BaseMathGetIndexFunc = int (*)(BaseMathObject *, int, int)

Same as BaseMathGetFunc but only for an index.

Definition at line 109 of file mathutils.hh.

◆ BaseMathSetFunc

using BaseMathSetFunc = int (*)(BaseMathObject *, int)

Sets the users vector values once its modified.

Definition at line 107 of file mathutils.hh.

◆ BaseMathSetIndexFunc

using BaseMathSetIndexFunc = int (*)(BaseMathObject *, int, int)

Same as BaseMathSetFunc but only for an index.

Definition at line 111 of file mathutils.hh.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

#BaseMathObject.flag

Enumerator
BASE_MATH_FLAG_IS_WRAP 

Do not own the memory used in this vector,

Note
This is error prone if the memory may be freed while this vector is in use. Prefer using callbacks where possible, see: Mathutils_RegisterCallback
BASE_MATH_FLAG_IS_FROZEN 

Prevent changes to the vector so it can be used as a set or dictionary key for example. (typical use cases for tuple).

BASE_MATH_FLAG_HAS_BUFFER_VIEW 

When set, prevents calling freeze() and resize() while using the buffer protocol.

Note
memoryview & np.frombuffer pass the PyBUF_FORMAT | PyBUF_INDIRECT flags, and the object can be mutated, so PyBUF_WRITABLE can't be handled. That's why it's always necessary to check for write access.

Definition at line 31 of file mathutils.hh.

Function Documentation

◆ _BaseMathObject_CheckCallback()

int _BaseMathObject_CheckCallback ( BaseMathObject * self)
nodiscard

Definition at line 539 of file mathutils.cc.

References Mathutils_Callback::check, LIKELY, mathutils_callbacks, and self.

◆ _BaseMathObject_new_impl()

PyObject * _BaseMathObject_new_impl ( PyTypeObject * root_type,
PyTypeObject * base_type )
nodiscard

Definition at line 767 of file mathutils.cc.

References BaseMathObject_is_tracked(), BLI_assert, and ELEM.

◆ _BaseMathObject_RaiseBufferViewExc()

int _BaseMathObject_RaiseBufferViewExc ( BaseMathObject * self,
Py_buffer * view,
int flags )
nodiscard

◆ _BaseMathObject_RaiseFrozenExc()

void _BaseMathObject_RaiseFrozenExc ( const BaseMathObject * self)

Definition at line 604 of file mathutils.cc.

References self.

◆ _BaseMathObject_RaiseNotFrozenExc()

void _BaseMathObject_RaiseNotFrozenExc ( const BaseMathObject * self)

Definition at line 609 of file mathutils.cc.

References self.

◆ _BaseMathObject_ReadCallback()

int _BaseMathObject_ReadCallback ( BaseMathObject * self)
nodiscard

Definition at line 548 of file mathutils.cc.

References Mathutils_Callback::get, LIKELY, mathutils_callbacks, and self.

◆ _BaseMathObject_ReadIndexCallback()

int _BaseMathObject_ReadIndexCallback ( BaseMathObject * self,
int index )
nodiscard

Definition at line 576 of file mathutils.cc.

References Mathutils_Callback::get_index, LIKELY, mathutils_callbacks, and self.

◆ _BaseMathObject_ResizeOkOrRaiseExc()

int _BaseMathObject_ResizeOkOrRaiseExc ( BaseMathObject * self,
const char * error_prefix )
nodiscard

To implement #BaseMath_Prepare_ForResize.

Definition at line 615 of file mathutils.cc.

References BASE_MATH_FLAG_HAS_BUFFER_VIEW, BASE_MATH_FLAG_IS_FROZEN, BASE_MATH_FLAG_IS_WRAP, self, and UNLIKELY.

◆ _BaseMathObject_WriteCallback()

int _BaseMathObject_WriteCallback ( BaseMathObject * self)
nodiscard

Definition at line 563 of file mathutils.cc.

References LIKELY, mathutils_callbacks, self, and Mathutils_Callback::set.

◆ _BaseMathObject_WriteIndexCallback()

int _BaseMathObject_WriteIndexCallback ( BaseMathObject * self,
int index )
nodiscard

Definition at line 590 of file mathutils.cc.

References LIKELY, mathutils_callbacks, self, and Mathutils_Callback::set_index.

◆ BaseMathObject_clear()

int BaseMathObject_clear ( BaseMathObject * self)

Definition at line 722 of file mathutils.cc.

References self.

Referenced by BaseMathObject_dealloc().

◆ BaseMathObject_dealloc()

void BaseMathObject_dealloc ( BaseMathObject * self)

◆ BaseMathObject_freeze()

PyObject * BaseMathObject_freeze ( BaseMathObject * self)
nodiscard

◆ BaseMathObject_is_frozen_get()

PyObject * BaseMathObject_is_frozen_get ( BaseMathObject * self,
void *  )
nodiscard

Definition at line 680 of file mathutils.cc.

References BASE_MATH_FLAG_IS_FROZEN, and self.

◆ BaseMathObject_is_gc()

int BaseMathObject_is_gc ( BaseMathObject * self)

Definition at line 762 of file mathutils.cc.

References self.

◆ BaseMathObject_is_valid_get()

PyObject * BaseMathObject_is_valid_get ( BaseMathObject * self,
void *  )
nodiscard

Definition at line 686 of file mathutils.cc.

References BaseMath_CheckCallback, and self.

◆ BaseMathObject_is_wrapped_get()

PyObject * BaseMathObject_is_wrapped_get ( BaseMathObject * self,
void *  )
nodiscard

Definition at line 673 of file mathutils.cc.

References BASE_MATH_FLAG_IS_WRAP, and self.

◆ BaseMathObject_owner_get()

PyObject * BaseMathObject_owner_get ( BaseMathObject * self,
void *  )
nodiscard

Definition at line 665 of file mathutils.cc.

References ret, and self.

◆ BaseMathObject_traverse()

int BaseMathObject_traverse ( BaseMathObject * self,
visitproc visit,
void * arg )

Definition at line 716 of file mathutils.cc.

References self.

◆ column_vector_multiplication()

int column_vector_multiplication ( float r_vec[4],
VectorObject * vec,
MatrixObject * mat )
nodiscard

Column vector multiplication (Matrix * Vector).

[1][4][7]   [a]
[2][5][8] * [b]
[3][6][9]   [c]
Note
Vector/Matrix multiplication is not commutative.
Assume read callbacks have been done first.

Referenced by Matrix_matmul().

◆ EXPP_FloatsAreEqual()

int EXPP_FloatsAreEqual ( float af,
float bf,
int maxDiff )
nodiscard

Definition at line 470 of file mathutils.cc.

References BLI_assert, diff(), SIGNMASK, and v2.

Referenced by EXPP_VectorsAreEqual(), and quat__axis_angle_sanitize().

◆ EXPP_VectorsAreEqual()

int EXPP_VectorsAreEqual ( const float * vecA,
const float * vecB,
int size,
int floatSteps )
nodiscard

◆ mathutils_any_to_rotmat()

int mathutils_any_to_rotmat ( float rmat[3][3],
PyObject * value,
const char * error_prefix )
nodiscard

◆ mathutils_array_hash()

Py_hash_t mathutils_array_hash ( const float * array,
size_t array_len )
nodiscard

helper function that returns a Python __hash__.

Note
consistent with the equivalent tuple of floats (CPython's tuplehash)

Definition at line 68 of file mathutils.cc.

References i, len, mult(), x, and y.

Referenced by Color_hash(), Euler_hash(), Matrix_hash(), Quaternion_hash(), and Vector_hash().

◆ mathutils_array_parse()

int mathutils_array_parse ( float * array,
int array_num_min,
int array_num_max,
PyObject * value,
const char * error_prefix )
nodiscard

Helper function.

Returns
length of value, -1 on error.

Definition at line 96 of file mathutils.cc.

References BaseMath_ReadCallback, CLAMP_MAX, ColorObject_Check, data, EulerObject_Check, flag, mathutils_array_parse_fast(), MU_ARRAY_FLAGS, MU_ARRAY_SPILL, MU_ARRAY_ZERO, num, Py_DECREF(), QuaternionObject_Check, and VectorObject_Check.

Referenced by bpy_bm_geometry_intersect_face_point(), bpy_bmface_normal_set(), BPy_BMLayerItem_SetItem(), BPy_BMLoopColor_AssignPyObject(), bpy_bmloopuv_uv_set(), bpy_bmvert_co_set(), bpy_bmvert_normal_set(), bpy_bmvertseq_new(), bpy_bmvertskin_radius_set(), bpy_slot_from_py(), C_BVHTree_FromPolygons(), C_Matrix_Diagonal(), C_Matrix_LocRotScale(), C_Matrix_OrthoProjection(), C_Matrix_Rotation(), C_Matrix_Scale(), C_Matrix_Shear(), C_Matrix_Translation(), Color_ass_slice(), Color_hsv_set(), Color_vectorcall(), convert_v2(), convert_v3(), convert_v4(), Euler_ass_slice(), Euler_make_compatible(), Euler_vectorcall(), FEdgeSharp_normal_left_set(), FEdgeSharp_normal_right_set(), FEdgeSmooth_normal_set(), Freestyle_blendRamp(), FrsMaterial_ambient_set(), FrsMaterial_diffuse_set(), FrsMaterial_emission_set(), FrsMaterial_line_set(), FrsMaterial_specular_set(), M_Geometry_area_tri(), M_Geometry_barycentric_transform(), M_Geometry_closest_point_on_tri(), M_Geometry_distance_point_to_plane(), M_Geometry_interpolate_bezier(), M_Geometry_intersect_line_line(), M_Geometry_intersect_line_line_2d(), M_Geometry_intersect_line_plane(), M_Geometry_intersect_line_sphere(), M_Geometry_intersect_line_sphere_2d(), M_Geometry_intersect_plane_plane(), M_Geometry_intersect_point_line(), M_Geometry_intersect_point_line_segment(), M_Geometry_intersect_point_quad_2d(), M_Geometry_intersect_point_tri(), M_Geometry_intersect_point_tri_2d(), M_Geometry_intersect_ray_tri(), M_Geometry_intersect_sphere_sphere_2d(), M_Geometry_intersect_tri_tri_2d(), M_Geometry_tessellate_polygon(), M_Geometry_volume_tetrahedron(), M_Interpolate_poly_3d_calc(), M_Noise_cell(), M_Noise_cell_vector(), M_Noise_fractal(), M_Noise_hetero_terrain(), M_Noise_hybrid_multi_fractal(), M_Noise_multi_fractal(), M_Noise_noise(), M_Noise_noise_vector(), M_Noise_ridged_multi_fractal(), M_Noise_turbulence(), M_Noise_turbulence_vector(), M_Noise_variable_lacunarity(), M_Noise_voronoi(), mathutils_array_parse_alloc_v(), Matrix_ass_item_col(), Matrix_ass_item_row(), Matrix_ass_slice(), Matrix_translation_set(), py_bvhtree_find_nearest(), py_bvhtree_find_nearest_range(), py_bvhtree_ray_cast(), py_kdtree_find(), py_kdtree_find_n(), py_kdtree_find_range(), py_kdtree_insert(), pygpu_framebuffer_clear(), pygpu_matrix_scale(), pygpu_matrix_translate(), pygpu_shader_uniform_float(), Quaternion_ass_slice(), Quaternion_axis_vector_set(), Quaternion_cross(), Quaternion_dot(), Quaternion_make_compatible(), Quaternion_rotation_difference(), Quaternion_slerp(), Quaternion_vectorcall(), StrokeAttribute_color_set(), StrokeAttribute_thickness_set(), StrokeVertex_point_set(), SVertex_point_2d_set(), SVertex_point_3d_set(), Vector_angle(), Vector_angle_signed(), Vector_cross(), Vector_reflect(), Vector_rotation_difference(), Vector_slerp(), and Vector_swizzle_set().

◆ mathutils_array_parse_alloc()

int mathutils_array_parse_alloc ( float ** array,
int array_num_min,
PyObject * value,
const char * error_prefix )
nodiscard

◆ mathutils_array_parse_alloc_v()

int mathutils_array_parse_alloc_v ( float ** array,
int array_dim,
PyObject * value,
const char * error_prefix )
nodiscard

◆ mathutils_array_parse_alloc_vi()

int mathutils_array_parse_alloc_vi ( int ** array,
int array_dim,
PyObject * value,
const char * error_prefix )
nodiscard

Parse sequence of array_dim sequences of integers and return allocated result.

Definition at line 335 of file mathutils.cc.

References i, mathutils_int_array_parse(), Py_DECREF(), and size().

Referenced by M_Geometry_delaunay_2d_cdt().

◆ mathutils_array_parse_alloc_viseq()

bool mathutils_array_parse_alloc_viseq ( PyObject * value,
const char * error_prefix,
blender::Array< blender::Vector< int > > & r_data )
nodiscard

Parse sequence of variable-length sequences of integers and fill r_data with their values.

Definition at line 372 of file mathutils.cc.

References blender::MutableSpan< T >::data(), i, mathutils_int_array_parse(), Py_DECREF(), blender::MutableSpan< T >::size(), and size().

Referenced by M_Geometry_delaunay_2d_cdt().

◆ mathutils_dynstr_to_py()

PyObject * mathutils_dynstr_to_py ( struct DynStr * ds)
nodiscard

◆ mathutils_int_array_parse()

int mathutils_int_array_parse ( int * array,
int array_dim,
PyObject * value,
const char * error_prefix )
nodiscard

Parse an sequence array_dim integers into array.

Definition at line 300 of file mathutils.cc.

References i, Py_DECREF(), and size().

Referenced by mathutils_array_parse_alloc_vi(), and mathutils_array_parse_alloc_viseq().

◆ Mathutils_RegisterCallback()

◆ PyInit_mathutils()

Variable Documentation

◆ BaseMathObject_freeze_doc

char BaseMathObject_freeze_doc[]
extern

Definition at line 691 of file mathutils.cc.

◆ BaseMathObject_is_frozen_doc

char BaseMathObject_is_frozen_doc[]
extern

Definition at line 678 of file mathutils.cc.

◆ BaseMathObject_is_valid_doc

char BaseMathObject_is_valid_doc[]
extern

Definition at line 685 of file mathutils.cc.

◆ BaseMathObject_is_wrapped_doc

char BaseMathObject_is_wrapped_doc[]
extern

Definition at line 671 of file mathutils.cc.

◆ BaseMathObject_owner_doc

char BaseMathObject_owner_doc[]
extern

Definition at line 664 of file mathutils.cc.