ac6b263906
Cleanup: inconsistent parameter name
2021-08-04 12:32:25 +02:00
fd0b2b8dfd
Cleanup: use PyC_AsArray_FAST function where possible
...
Oversight in 2453dc1b0e .
2021-07-29 13:41:48 +10:00
2453dc1b0e
PyAPI: add multi-dimensional array conversion utility functions
...
Add array conversion functions that take dimension arguments.
- PyC_AsArray_Multi (version of PyC_AsArray).
- PyC_Tuple_PackArray_Multi_* (version of PyC_Tuple_Pack_*).
2021-07-29 11:04:33 +10:00
e37c876cd7
PyAPI: support different int sizes for PyC_AsArray
2021-07-27 22:38:50 +10:00
58eacb8e7c
Cleanup: pass sizeof array element to PyC_AsArray
...
Replace the is_double argument which was only used for single/double
precision floats.
This allows supporting different sized int types more easily.
2021-07-27 22:36:01 +10:00
c3a400b73f
Cleanup: use single back-tick quoting in comments
...
While doxygen supports both, conform to our style guide.
Note that single back-tick's are already used in a majority of comments.
2021-07-20 22:58:14 +10:00
9b89de2571
Cleanup: consistent use of tags: NOTE/TODO/FIXME/XXX
...
Also use doxy style function reference `#` prefix chars when
referencing identifiers.
2021-07-04 00:43:40 +10:00
1d8648b13a
Cleanup: repeated terms in code comments & error messages
2021-06-28 15:46:08 +10:00
f1e4903854
Cleanup: full sentences in comments, improve comment formatting
2021-06-26 21:50:48 +10:00
4b9ff3cd42
Cleanup: comment blocks, trailing space in comments
2021-06-24 15:59:34 +10:00
Leon Zandman
c317f111c1
Cleanup: Spelling Mistakes
...
This patch fixes many minor spelling mistakes, all in comments or
console output. Mostly contractions like can't, won't, don't, its/it's,
etc.
Differential Revision: https://developer.blender.org/D11663
Reviewed by Harley Acheson
2021-06-22 10:54:50 -07:00
5df6b4004c
Docs: improve imbuf.write docstring
...
The file path wasn't documented as being optional.
2021-06-21 12:25:36 +10:00
e9b4de43d8
Cleanup: rename id to owner_id for python id properties
...
This is consistent with the naming in `PointerRNA`.
2021-06-14 18:13:27 +02:00
f29a738e23
PyAPI: use keyword only arguments
...
Use keyword only arguments for the following functions.
- addon_utils.module_bl_info 2nd arg `info_basis`.
- addon_utils.modules 1st `module_cache`, 2nd arg `refresh`.
- addon_utils.modules_refresh 1st arg `module_cache`.
- bl_app_template_utils.activate 1nd arg `template_id`.
- bl_app_template_utils.import_from_id 2nd arg `ignore_not_found`.
- bl_app_template_utils.import_from_path 2nd arg `ignore_not_found`.
- bl_keymap_utils.keymap_from_toolbar.generate 2nd & 3rd args `use_fallback_keys` & `use_reset`.
- bl_keymap_utils.platform_helpers.keyconfig_data_oskey_from_ctrl 2nd arg `filter_fn`.
- bl_ui_utils.bug_report_url.url_prefill_from_blender 1st arg `addon_info`.
- bmesh.types.BMFace.copy 1st & 2nd args `verts`, `edges`.
- bmesh.types.BMesh.calc_volume 1st arg `signed`.
- bmesh.types.BMesh.from_mesh 2nd..4th args `face_normals`, `use_shape_key`, `shape_key_index`.
- bmesh.types.BMesh.from_object 3rd & 4th args `cage`, `face_normals`.
- bmesh.types.BMesh.transform 2nd arg `filter`.
- bmesh.types.BMesh.update_edit_mesh 2nd & 3rd args `loop_triangles`, `destructive`.
- bmesh.types.{BMVertSeq,BMEdgeSeq,BMFaceSeq}.sort 1st & 2nd arg `key`, `reverse`.
- bmesh.utils.face_split 4th..6th args `coords`, `use_exist`, `example`.
- bpy.data.libraries.load 2nd..4th args `link`, `relative`, `assets_only`.
- bpy.data.user_map 1st..3rd args `subset`, `key_types, `value_types`.
- bpy.msgbus.subscribe_rna 5th arg `options`.
- bpy.path.abspath 2nd & 3rd args `start` & `library`.
- bpy.path.clean_name 2nd arg `replace`.
- bpy.path.ensure_ext 3rd arg `case_sensitive`.
- bpy.path.module_names 2nd arg `recursive`.
- bpy.path.relpath 2nd arg `start`.
- bpy.types.EditBone.transform 2nd & 3rd arg `scale`, `roll`.
- bpy.types.Operator.as_keywords 1st arg `ignore`.
- bpy.types.Struct.{keyframe_insert,keyframe_delete} 2nd..5th args `index`, `frame`, `group`, `options`.
- bpy.types.WindowManager.popup_menu 2nd & 3rd arg `title`, `icon`.
- bpy.types.WindowManager.popup_menu_pie 3rd & 4th arg `title`, `icon`.
- bpy.utils.app_template_paths 1st arg `subdir`.
- bpy.utils.app_template_paths 1st arg `subdir`.
- bpy.utils.blend_paths 1st..3rd args `absolute`, `packed`, `local`.
- bpy.utils.execfile 2nd arg `mod`.
- bpy.utils.keyconfig_set 2nd arg `report`.
- bpy.utils.load_scripts 1st & 2nd `reload_scripts` & `refresh_scripts`.
- bpy.utils.preset_find 3rd & 4th args `display_name`, `ext`.
- bpy.utils.resource_path 2nd & 3rd arg `major`, `minor`.
- bpy.utils.script_paths 1st..4th args `subdir`, `user_pref`, `check_all`, `use_user`.
- bpy.utils.smpte_from_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.smpte_from_seconds 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.system_resource 2nd arg `subdir`.
- bpy.utils.time_from_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.time_to_frame 2nd & 3rd args `fps`, `fps_base`.
- bpy.utils.units.to_string 4th..6th `precision`, `split_unit`, `compatible_unit`.
- bpy.utils.units.to_value 4th arg `str_ref_unit`.
- bpy.utils.user_resource 2nd & 3rd args `subdir`, `create`
- bpy_extras.view3d_utils.location_3d_to_region_2d 4th arg `default`.
- bpy_extras.view3d_utils.region_2d_to_origin_3d 4th arg `clamp`.
- gpu.offscreen.unbind 1st arg `restore`.
- gpu_extras.batch.batch_for_shader 4th arg `indices`.
- gpu_extras.batch.presets.draw_circle_2d 4th arg `segments`.
- gpu_extras.presets.draw_circle_2d 4th arg `segments`.
- imbuf.types.ImBuf.resize 2nd arg `resize`.
- imbuf.write 2nd arg `filepath`.
- mathutils.kdtree.KDTree.find 2nd arg `filter`.
- nodeitems_utils.NodeCategory 3rd & 4th arg `descriptions`, `items`.
- nodeitems_utils.NodeItem 2nd..4th args `label`, `settings`, `poll`.
- nodeitems_utils.NodeItemCustom 1st & 2nd arg `poll`, `draw`.
- rna_prop_ui.draw 5th arg `use_edit`.
- rna_prop_ui.rna_idprop_ui_get 2nd arg `create`.
- rna_prop_ui.rna_idprop_ui_prop_clear 3rd arg `remove`.
- rna_prop_ui.rna_idprop_ui_prop_get 3rd arg `create`.
- rna_xml.xml2rna 2nd arg `root_rna`.
- rna_xml.xml_file_write 4th arg `skip_typemap`.
2021-06-09 03:05:44 +10:00
265d97556a
PyAPI: use iterators for ID property methods (keys, values & items)
...
- Matches changes in Python 3.x dictionary methods.
- Iterating now raises a run-time error if the property-group changes
size during iteration.
- IDPropertyGroup.iteritems() has been removed.
- IDPropertyGroup View & Iterator types have been added.
- Some set functionality from dict_keys/values/items aren't yet
supported (isdisjoint method and boolean set style operations).
Proposed as part of T85675.
2021-05-15 00:36:49 +10:00
3c09beb3b1
Fix memory leak in IDPropertyGroup.pop()
...
When popping ID-property groups/arrays,
ID-property was removed but not freed.
Now the value is converted to a native Python type and freed.
2021-05-14 19:25:29 +10:00
cc7691797c
Cleanup: remove unused BPy_IDProperty struct member
2021-05-11 12:30:06 +10:00
9801735b67
Fix T88190: Freed memory use when iterating over id-properties
...
The id-property iterator referenced a PyObject pointer without
increasing it's user count - allowing for errors if the value
goes out of scope during iteration.
2021-05-11 12:20:06 +10:00
5aee4ba143
Fix memory leak in Python IDproperty iterator
...
Looping over IDProperty keys or calling iteritems leaked memory.
Error in original Python idproperty support from
8768707610
2021-05-11 11:15:49 +10:00
f5060bc901
PyAPI: support retrieving the exception when running a string
...
- Optionally get the error as a single line.
- Support access the error as an allocated string.
- PyC_ExceptionBuffer_Simple was always printing to the `stdout` while
PyC_ExceptionBuffer didn't, now either print to the output.
Without this, callers are unable to do anything with the error string.
2021-04-13 15:28:43 +10:00
4d43683899
PyAPI: ImBuf.copy now copies the underlying imbuf
...
Without this, copy wasn't useful.
2021-04-08 20:19:26 +10:00
d5c6485372
Cleanup: clang format
2021-04-01 11:18:26 +11:00
3f47df577d
Cleanup: use new BLI_assert_unreachable macro
2021-03-24 12:38:08 +11:00
bb6765f28f
Cleanup: spelling
2021-03-18 09:36:44 +11:00
c47990f41c
PyAPI: expose imbuf.types.ImBuf, include in API docs
...
Without this, the ImBuf type wasn't part of documentation.
2021-02-25 12:04:23 +11:00
7bb2b910c0
Cleanup: doxygen sections
2021-02-20 15:35:00 +11:00
4430e8a008
Python: gpu module: add new submodules and types
...
This commit extends the gpu python API with:
```
gpu.types.Buffer #"__init__", "to_list"
gpu.types.GPUTexture #"__init__", "clear", "read", "format"
gpu.types.GPUFrameBuffer #"__init__", "bind", "clear", "is_bound", "viewport", ("__enter__", "__exit__" with "GPUFrameBufferStackContext")
gpu.types.GPUUniformBuf #"__init__", "update"
gpu.state #"blend_set", "blend_get", "depth_test_set", "depth_test_get", "depth_mask_set", "depth_mask_get", "viewport_set", "viewport_get", "line_width_set", "line_width_get", "point_size_set", "color_mask_set", "face_culling_set", "front_facing_set", "program_point_size_set"
```
Add these methods to existing objects:
```
gpu.types.GPUShader #"uniform_sample", "uniform_buffer"
```
Maniphest Tasks: T80481
Differential Revision: https://developer.blender.org/D8826
2021-02-17 12:27:19 -03:00
dae445d94a
Fix T85573: Building with Python 3.10a5 fails
...
Replace deprecated _PyUnicode_AsString{AndSize} usage.
T83626 still needs to be resolved before 3.10 is usable.
2021-02-13 23:09:55 +11:00
cafd6b519c
PyAPI: Use PyPreConfig & PyConfig for Python initialization
...
Use Python 3.8's API for setting the initial configuration.
This replaces a mix of our logic and direct calls to the Python API
and has no user visible changes.
Using the Python API makes the logic easier to follow and provides
utilities such as `PyConfig_SetBytesArgv`
that wasn't available in previous releases.
Note that this uses Python's utf8/wchar_t conversions,
which used to cause problems (see T31506).
Since `Py_UTF8Mode` was set, the systems locale isn't used for decoding,
allowing us to use Python's utility functions that call
`Py_DecodeLocale` internally.
Ref D10382
2021-02-12 08:10:12 +11:00
aa43e2ec29
PyAPI: use PyModule_AddType utility function
2021-02-12 08:08:16 +11:00
d21f445469
PyAPI: remove Python 3.7x compatibility code
...
This removes Python version checks needed to build with 3.8+ and 3.7x.
Ref D10381
2021-02-12 08:08:15 +11:00
606805d1b7
Cleanup: use 'r_' prefix for return arguments, order last
2021-02-05 22:34:03 +11:00
af88d23ffa
Revert "Fix typo; Documentation; Expose layer for framebuffer attachament; Add framebuffer viewport setter; Remove framebuffer restore; Expose framebuffer push/pop stack API; Remove blend modes; Remove depth_range_set; Implement GPU_face_culling, GPU_front_facing, GPU_point_size, GPU_line_width, GPU_viewport, GPU_color_mask and GPU_depth_mask"
...
This reverts commit 9db3d1951d .
This was an accidental commit of the patch D8826
2021-01-10 21:07:04 -03:00
9db3d1951d
Fix typo; Documentation; Expose layer for framebuffer attachament; Add framebuffer viewport setter; Remove framebuffer restore; Expose framebuffer push/pop stack API; Remove blend modes; Remove depth_range_set; Implement GPU_face_culling, GPU_front_facing, GPU_point_size, GPU_line_width, GPU_viewport, GPU_color_mask and GPU_depth_mask
2021-01-10 19:01:53 -03:00
b8e536f381
Fix imbuf.new & resize allowing zero & negative dimensions
2021-01-04 20:05:32 +11:00
a6285339ba
Cleanup: remove unused optional argument to imbuf.new
...
While this didn't cause any problems, it was incorrect.
2021-01-04 20:00:27 +11:00
fea1026bb8
Cleanup: use 'pragma once'
...
Add explanations for cases the header-guard defines are still used.
2021-01-04 17:38:11 +11:00
525364be31
Cleanup: reduce indirect DNA header inclusion
...
Remove DNA headers, using forward declarations where possible.
Also removed duplicate header, header including it's self
and unnecessary inclusion of libc system headers from BKE header.
2020-12-15 12:34:14 +11:00
ebe4bf6286
Fix another id-property name length check
...
Missed this in 6c9263d817
2020-12-09 17:33:11 +11:00
6c9263d817
Fix off by one error in id-property name validation
...
The Python API accepted a name with 64 bytes, clipping it to 63.
2020-12-09 17:16:43 +11:00
d1cedf53fa
Revert "Fix T78823: Slash in custom property name does not work"
...
This reverts commit cbae82ba96 .
This change introduced the following problems:
- We could no longer reliably duplicate or use an existing
custom property names.
- We could no longer assume a bone or ID name
can be used in a custom-property.
- Importers that support custom properties (such as FBX)
could fail with an exception creating custom properties.
2020-12-09 15:29:28 +11:00
c4d8f6a4a8
Cleanup: clang-format
2020-11-11 09:11:43 +11:00
cd9acfed4f
Cleanup: use preprocessor version check for PyTypeObject declaration
...
While `tp_print` was deprecated, Python 3.8+ uses this for
'tp_vectorcall_offset' which wasn't stated in the comment from
efd71aad4f .
Instead of suppressing clang-tidy, use preprocessor a check since
this properly represents the difference between Python versions.
2020-11-11 09:11:21 +11:00
f11f7ce08e
Cleanup: use ELEM macro (>2 args)
2020-11-06 12:54:19 +11:00
d49c71e96e
Cleanup: use logging for "Found bundled Python" message
...
This was added when Python was initially bundled so any problems
finding Python could be investigated.
Move this to use logging so we can show this information when needed.
2020-11-02 19:33:32 +11:00
5edba9b42f
Fix T81688: BPY_thread_save crashes with Python 3.9
...
Calling PyEval_ReleaseLock() was crashing with Python 3.9
because it accessed the NULL pointer set by PyThreadState_Swap().
This happened when calling ViewLayer.update() for example.
While the existing logic could be fixed by swapping the thread-state
back before calling PyEval_ReleaseLock(), this depends on functions
which are tagged to be removed by v4.0.
Replace use of deprecated functions by calling PyEval_SaveThread(),
instead of inlining the logic, using _PyThreadState_UncheckedGet()
to prevent Python aborting.
The call to PyEval_ThreadsInitialized has been removed
as threads are now initialized with Python.
This could be replaced with Py_IsInitialized() however it doesn't look
like this is necessary.
This is compatible with Python 3.7 & 3.9.
2020-10-14 18:52:02 +11:00
c7cd74fac3
Cleanup: multi-line comment blocks
2020-10-14 15:24:42 +11:00
2abfcebb0e
Cleanup: use C comments for descriptive text
...
Follow our code style guide by using C-comments for text descriptions.
2020-10-10 22:04:51 +11:00
d39043b5ae
Revert "Revert "BGL: Workaround broken bgl usage caused by GPU refactor""
...
This reverts commit f23bf4cb10 .
2020-10-09 16:33:59 +02:00
f23bf4cb10
Revert "BGL: Workaround broken bgl usage caused by GPU refactor"
...
This reverts commit f12b0373f3 .
2020-10-08 17:58:38 +02:00